Kill publish_context_state() — screens lock the agent directly

F1 and F2 screens now call agent.context_state_summary() directly
via try_lock/lock instead of reading from a shared RwLock cache.
Removes SharedContextState, publish_context_state(), and
publish_context_state_with_scores().

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-07 03:03:24 -04:00
parent 48c843234d
commit 04e260c081
6 changed files with 30 additions and 64 deletions

View file

@ -27,7 +27,6 @@ use ratatui::{
};
use std::io;
use crate::agent::context::SharedContextState;
/// Status info for the bottom status bar.
#[derive(Debug, Clone)]
@ -126,7 +125,6 @@ pub struct App {
pub should_quit: bool,
pub submitted: Vec<String>,
pub(crate) context_info: Option<ContextInfo>,
pub(crate) shared_context: SharedContextState,
pub(crate) agent_state: Vec<crate::mind::SubconsciousSnapshot>,
pub(crate) walked_count: usize,
pub(crate) channel_status: Vec<ChannelStatus>,
@ -134,7 +132,7 @@ pub struct App {
}
impl App {
pub fn new(model: String, shared_context: SharedContextState, active_tools: crate::agent::tools::SharedActiveTools) -> Self {
pub fn new(model: String, active_tools: crate::agent::tools::SharedActiveTools) -> Self {
Self {
status: StatusInfo {
dmn_state: "resting".into(), dmn_turns: 0, dmn_max_turns: 20,
@ -149,7 +147,7 @@ impl App {
top_k: 20,
active_tools,
should_quit: false, submitted: Vec::new(),
context_info: None, shared_context,
context_info: None,
agent_state: Vec::new(),
walked_count: 0,
channel_status: Vec::new(), idle_info: None,
@ -202,7 +200,6 @@ pub async fn start(cli: crate::user::CliArgs) -> Result<()> {
let mind = crate::mind::Mind::new(config, turn_tx);
let shared_context = mind.agent.lock().await.shared_context.clone();
let shared_active_tools = mind.agent.lock().await.active_tools.clone();
let mut result = Ok(());
@ -216,7 +213,7 @@ pub async fn start(cli: crate::user::CliArgs) -> Result<()> {
// UI event loop
s.spawn(async {
result = run(
tui::App::new(String::new(), shared_context, shared_active_tools),
tui::App::new(String::new(), shared_active_tools),
&mind, mind_tx,
).await;
});
@ -337,7 +334,7 @@ pub async fn run(
Box::new(crate::user::chat::InteractScreen::new(
mind.agent.clone(), mind.shared.clone(), mind_tx.clone(),
)),
Box::new(crate::user::context::ConsciousScreen::new()),
Box::new(crate::user::context::ConsciousScreen::new(mind.agent.clone())),
Box::new(crate::user::subconscious::SubconsciousScreen::new()),
Box::new(crate::user::unconscious::UnconsciousScreen::new()),
Box::new(crate::user::thalamus::ThalamusScreen::new()),
@ -455,12 +452,6 @@ 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 {