Files
owlen/crates/owlen-tui/src/code_app.rs

45 lines
1.1 KiB
Rust

use anyhow::Result;
use owlen_core::session::SessionController;
use owlen_core::ui::{AppState, InputMode};
use tokio::sync::mpsc;
use crate::chat_app::{ChatApp, SessionEvent};
use crate::events::Event;
const DEFAULT_SYSTEM_PROMPT: &str =
"You are OWLEN Code Assistant. Provide detailed, actionable programming help.";
pub struct CodeApp {
inner: ChatApp,
}
impl CodeApp {
pub fn new(mut controller: SessionController) -> (Self, mpsc::UnboundedReceiver<SessionEvent>) {
controller
.conversation_mut()
.push_system_message(DEFAULT_SYSTEM_PROMPT.to_string());
let (inner, rx) = ChatApp::new(controller);
(Self { inner }, rx)
}
pub async fn handle_event(&mut self, event: Event) -> Result<AppState> {
self.inner.handle_event(event).await
}
pub fn handle_session_event(&mut self, event: SessionEvent) -> Result<()> {
self.inner.handle_session_event(event)
}
pub fn mode(&self) -> InputMode {
self.inner.mode()
}
pub fn inner(&self) -> &ChatApp {
&self.inner
}
pub fn inner_mut(&mut self) -> &mut ChatApp {
&mut self.inner
}
}