pub struct ChatApp {Show 22 fields
pub model_name: String,
pub history: Vec<ChatHistoryEntry>,
pub textarea: TextArea<'static>,
pub mode: ChatMode,
pub editor_text: String,
pub scroll_offset: usize,
pub status: Option<String>,
pub cols: u16,
pub rows: u16,
pub quit: bool,
pub session_id: Option<Uuid>,
pub show_thinking: bool,
pub pending_toasts: Vec<String>,
pub pending_prompts: VecDeque<String>,
pub gen_config: Arc<RwLock<ChatGenConfig>>,
pub settings_draft: ChatGenConfig,
pub requested_context_window: Option<usize>,
pub is_server_spawned: bool,
pub tool_descriptions: HashMap<String, String>,
pub tool_call_format: ToolCallFormat,
pub pending_tool_calls: usize,
pub spinner_tick: u32,
/* private fields */
}Fields§
§model_name: String§history: Vec<ChatHistoryEntry>§textarea: TextArea<'static>§mode: ChatMode§editor_text: StringCurrent text content held by the editor (set on Ctrl-E, read on Ctrl-S).
scroll_offset: usizeNumber of lines from the tail to scroll back (0 = show tail).
status: Option<String>§cols: u16§rows: u16§quit: bool§session_id: Option<Uuid>UUID for this private session (used as the storage filename key).
show_thinking: boolWhether to display thinking blocks expanded (Ctrl-O to toggle).
pending_toasts: Vec<String>Error messages queued for the outer compositor to surface as toasts. Drained by the event loop each tick (see shell_handlers.rs).
pending_prompts: VecDeque<String>Prompts queued while an inference is in flight.
gen_config: Arc<RwLock<ChatGenConfig>>Shared generation config (read by spawner each invocation).
settings_draft: ChatGenConfigIn-progress edits to generation config (committed on Enter, discarded on Esc).
requested_context_window: Option<usize>Set when user saves a new context_window; polled by shell_handlers to trigger model reload. 0 = use model default.
is_server_spawned: boolTrue when this ChatApp is hosted inside TuiService (server-spawned). In that mode, context window changes are surfaced as a toast rather than triggering an automatic model reload.
tool_descriptions: HashMap<String, String>UUID → human-readable description map built once from list_tools().
tool_call_format: ToolCallFormatFormat-specific markers to detect in the token stream.
pending_tool_calls: usizeNumber of tool calls dispatched but not yet resolved.
spinner_tick: u32Spinner frame index — incremented each tick while tool calls are in flight.
Implementations§
Source§impl ChatApp
impl ChatApp
pub fn new( model_name: String, cols: u16, rows: u16, spawner: StreamSpawner, ) -> Self
Sourcepub fn new_private(
model_name: String,
cols: u16,
rows: u16,
spawner: StreamSpawner,
session_id: Uuid,
load_hook: LoadHook,
save_hook: SaveHook,
) -> Self
pub fn new_private( model_name: String, cols: u16, rows: u16, spawner: StreamSpawner, session_id: Uuid, load_hook: LoadHook, save_hook: SaveHook, ) -> Self
Create a private chat app with encrypted history persistence.
load_hook is called immediately to restore any prior conversation.
save_hook is called after each StreamComplete to persist history.
Sourcepub fn with_gen_config(self, gen_config: Arc<RwLock<ChatGenConfig>>) -> Self
pub fn with_gen_config(self, gen_config: Arc<RwLock<ChatGenConfig>>) -> Self
Replace the default gen_config with a pre-created Arc (to share with the spawner).
Sourcepub fn with_server_spawned(self) -> Self
pub fn with_server_spawned(self) -> Self
Mark this ChatApp as server-spawned (hosted inside TuiService).
When true, context window changes from the Settings modal push a toast with CLI instructions rather than triggering an automatic model reload.
Sourcepub fn with_vfs(self, ns: Arc<Namespace>, subject: Subject) -> Self
pub fn with_vfs(self, ns: Arc<Namespace>, subject: Subject) -> Self
Attach a VFS namespace for /path command routing.
The Tcl shell owner thread and the direct-Namespace driver thread (see
crate::shell_driver) are both created lazily on first use, because
TclShell is !Send and ChatApp must cross a thread boundary in
spawn_app_process before it can settle on the thread its owner will
spawn from.
Sourcepub fn with_vfs_proxy(
self,
ns: Arc<Namespace>,
subject: Subject,
_vfs_tx: Sender<VfsRequest>,
) -> Self
pub fn with_vfs_proxy( self, ns: Arc<Namespace>, subject: Subject, _vfs_tx: Sender<VfsRequest>, ) -> Self
Attach VFS namespace for /path command routing (compat shim).
The _vfs_tx parameter is ignored — TclShell now awaits namespace
operations directly. This method exists for call-site compatibility;
prefer with_vfs for new code.
Sourcepub fn with_tool_caller(
self,
tool_caller: ToolCaller,
tool_descriptions: HashMap<String, String>,
tool_call_format: ToolCallFormat,
) -> Self
pub fn with_tool_caller( self, tool_caller: ToolCaller, tool_descriptions: HashMap<String, String>, tool_call_format: ToolCallFormat, ) -> Self
Configure tool calling. Call after construction if the MCP service is available.
tool_caller executes a tool by UUID and sends ToolCallResult back.
tool_descriptions maps UUID → human label for display purposes.
format selects the model-specific tool call syntax.
Sourcepub fn on_stream_complete(&mut self)
pub fn on_stream_complete(&mut self)
Signal that the inference stream completed successfully.
Sourcepub fn on_stream_cancelled(&mut self)
pub fn on_stream_cancelled(&mut self)
Signal that the inference stream was cancelled.
Sourcepub fn on_stream_error(&mut self, msg: String)
pub fn on_stream_error(&mut self, msg: String)
Signal an inference error.
Sourcepub fn on_template_error(&mut self, msg: String)
pub fn on_template_error(&mut self, msg: String)
Signal a template application error.
Sourcepub fn submit_message_payload(&mut self, user_text: String) -> String
pub fn submit_message_payload(&mut self, user_text: String) -> String
Build the inference request payload as a JSON string (for WASM OSC output).
Trait Implementations§
Source§impl TerminalApp for ChatApp
Available on non-WASI only.
impl TerminalApp for ChatApp
Source§fn handle_input(&mut self, key: KeyPress) -> bool
fn handle_input(&mut self, key: KeyPress) -> bool
Source§fn tick(&mut self, _delta_ms: u64) -> bool
fn tick(&mut self, _delta_ms: u64) -> bool
Source§fn should_quit(&self) -> bool
fn should_quit(&self) -> bool
Auto Trait Implementations§
impl !Freeze for ChatApp
impl !RefUnwindSafe for ChatApp
impl Send for ChatApp
impl !Sync for ChatApp
impl Unpin for ChatApp
impl UnsafeUnpin for ChatApp
impl !UnwindSafe for ChatApp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more