Files
sovereign_browser_rust/src/agent_chat.rs
T

32 lines
1.1 KiB
Rust

//! Agent chat entry points.
//!
//! Port of `agent_chat.c` / `agent_chat.h` from the C project.
use crate::agent_chat_store;
/// Initialize the agent chat module.
pub fn agent_chat_init() {
agent_chat_store::agent_chat_store_init();
}
/// Route URL-bar input of the form `; <message>` to the embedded agent.
///
/// Mirrors the C `agent_chat_route_input` (agent_chat.c:17): opens the
/// agent sidebar (if hidden) so the chat appears next to the current
/// page, then starts the agent loop with the message. The sidebar's chat
/// page polls `sovereign://agents/messages`, so it picks up the reply.
pub fn agent_chat_route_input(message: Option<&str>) -> Result<(), String> {
if !crate::tab_manager::tab_manager_sidebar_visible() {
crate::tab_manager::tab_manager_toggle_sidebar();
}
match message.map(str::trim).filter(|m| !m.is_empty()) {
Some(msg) => crate::agent_loop::agent_loop_run(msg),
None => Ok(()),
}
}
/// The current chat session id, if one has been chosen.
pub fn agent_chat_session_id() -> Option<String> {
agent_chat_store::agent_chat_store_session_id()
}