Fix streaming entry duplication and context state freshness

Replace pop+push of streaming entries with finalize_streaming() which
finds the unstamped assistant entry and updates it in place. The
streaming entry IS the assistant message — just stamp it when done.

Also: set dirty flag on agent_changed/turn_watch so the TUI actually
redraws when the agent state changes. Publish context state on F2
switch so the debug screen shows current data.

Age out images during compact() so old screenshots don't bloat the
request payload on startup.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-06 22:20:22 -04:00
parent d5e6f55da9
commit 8971e6841b
2 changed files with 58 additions and 29 deletions

View file

@ -377,6 +377,7 @@ pub async fn run(
// Replay conversation after Mind init completes (non-blocking check)
let mut startup_done = false;
let mut dirty = true; // render on first loop
loop {
tokio::select! {
@ -389,9 +390,13 @@ pub async fn run(
}
}
_ = agent_changed.notified() => {}
_ = agent_changed.notified() => {
dirty = true;
}
_ = turn_watch.changed() => {}
_ = turn_watch.changed() => {
dirty = true;
}
Some(channels) = channel_rx.recv() => {
app.set_channel_status(channels);
@ -419,8 +424,6 @@ pub async fn run(
if !pending.is_empty() { idle_state.user_activity(); }
let mut dirty = false;
while !pending.is_empty() || dirty {
let global_pos = pending.iter().position(|e| is_global_event(e))
.unwrap_or(pending.len());
@ -448,6 +451,12 @@ pub async fn run(
let idx = n as usize;
if idx >= 1 && idx <= screens.len() {
active_screen = idx;
// Refresh context state when switching to the conscious screen
if idx == 2 {
if let Ok(mut ag) = agent.try_lock() {
ag.publish_context_state();
}
}
}
} else if key.modifiers.contains(KeyModifiers::CONTROL) {
match key.code {