fix(tui): stateful session with identity, memory, banner
Two fixes for the TUI: 1. **Raw LLM responses** — was stateless, creating fresh messages every turn. Added + methods that accumulate conversation history, inject identity, load past memory, run browser init, and compress context — identical to the interactive loop but designed for external callers. 2. **Banner flash** — removed call that fired to stdout *before* TUI entered alternate screen. TUI already shows the robot head via as initial chat content. Also added getter and field to AgentLoop.
This commit is contained in:
34
src/main.rs
34
src/main.rs
@@ -555,9 +555,6 @@ async fn cmd_setup() -> anyhow::Result<()> {
|
||||
async fn cmd_tui() -> anyhow::Result<()> {
|
||||
tracing::info!("Launching TUI with live agent");
|
||||
|
||||
// Print banner to stdout too (for logs/terminal buffer)
|
||||
gyandoot_tui::banner::print_banner();
|
||||
|
||||
// Load agent config
|
||||
let config = load_agent_config();
|
||||
|
||||
@@ -569,22 +566,39 @@ async fn cmd_tui() -> anyhow::Result<()> {
|
||||
let agent = gyandoot_agent::agent_loop::AgentLoop::new(config);
|
||||
let agent_event_tx = event_tx.clone();
|
||||
tokio::spawn(async move {
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Status("INITIALISING...".to_string())).await;
|
||||
|
||||
// Init session (browser, identity, memory — like interactive run())
|
||||
if let Err(e) = agent.init_session().await {
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Status(
|
||||
format!("SESSION INIT ERROR: {}", e)
|
||||
)).await;
|
||||
} else {
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Status("AGENT READY".to_string())).await;
|
||||
}
|
||||
|
||||
// Send initial telemetry
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Status("AGENT READY".to_string())).await;
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Telemetry {
|
||||
provider: agent.config().provider.default.clone(),
|
||||
model: agent.config().model.clone(),
|
||||
total_tokens: 0,
|
||||
max_tokens: agent.config().max_tokens,
|
||||
msg_count: 0,
|
||||
}).await;
|
||||
|
||||
// Process messages from TUI
|
||||
while let Some(user_msg) = user_rx.recv().await {
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Status("PROCESSING...".to_string())).await;
|
||||
match agent.run_conversation(&user_msg).await {
|
||||
Ok(output) => {
|
||||
match agent.session_turn(&user_msg).await {
|
||||
Ok(text) => {
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Telemetry {
|
||||
provider: "—".to_string(), // populated from config
|
||||
model: "—".to_string(),
|
||||
provider: agent.config().provider.default.clone(),
|
||||
model: agent.config().model.clone(),
|
||||
total_tokens: 0,
|
||||
max_tokens: 4096,
|
||||
max_tokens: agent.config().max_tokens,
|
||||
msg_count: 0,
|
||||
}).await;
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Response(output.text)).await;
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Response(text)).await;
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = agent_event_tx.send(gyandoot_tui::tui::TuiEvent::Status(
|
||||
|
||||
Reference in New Issue
Block a user