mind: restore age_out_images and publish_context_state after turns

These were called from handle_turn_result before the refactor but
got lost during the MindState migration. Re-add them in the turn
completion path. Delete the trivial refresh_context_state wrapper.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2026-04-05 03:38:42 -04:00
parent 01b07a7f28
commit 402bae4178
3 changed files with 9 additions and 8 deletions

View file

@ -851,10 +851,6 @@ impl Agent {
}
/// Called after any change to context state (working stack, etc).
fn refresh_context_state(&mut self) {
self.publish_context_state();
}
/// Load working stack from disk.
fn load_working_stack(&mut self) {
if let Ok(data) = std::fs::read_to_string(working_stack::file_path()) {
@ -886,7 +882,7 @@ impl Agent {
/// Replace base64 image data in older messages with text placeholders.
/// Keeps the 2 most recent images live (enough for motion/comparison).
/// The tool result message before each image records what was loaded.
fn age_out_images(&mut self) {
pub fn age_out_images(&mut self) {
// Find image entries newest-first, skip 1 (caller is about to add another)
let to_age: Vec<usize> = self.context.entries.iter().enumerate()
.rev()

View file

@ -24,10 +24,9 @@ use tokio::sync::{mpsc, Mutex};
use crate::agent::{Agent, TurnResult};
use crate::agent::api::ApiClient;
use crate::agent::api::types as api_types;
use crate::config::{self, AppConfig, SessionConfig};
use crate::user::{self as tui};
use crate::user::ui_channel::{self, ContextInfo, StatusInfo, StreamTarget, UiMessage};
use crate::user::ui_channel::{self, StatusInfo, StreamTarget, UiMessage};
use crate::subconscious::learn;
/// Compaction threshold — context is rebuilt when prompt tokens exceed this.
@ -373,6 +372,13 @@ impl Mind {
crate::user::event_loop::cmd_switch_model(&self.agent, &name, &self.ui_tx).await;
}
// Post-turn maintenance
{
let mut ag = self.agent.lock().await;
ag.age_out_images();
ag.publish_context_state();
}
cmds.push(MindCommand::Compact);
if !self.config.no_agents {
cmds.push(MindCommand::Score);

View file

@ -13,7 +13,6 @@ use tokio::sync::Mutex;
use crate::agent::Agent;
use crate::agent::api::ApiClient;
use crate::config::SessionConfig;
use crate::user::{self as tui, HotkeyAction};
use crate::user::ui_channel::{self, UiMessage};