Fix status bar: show per-section budget breakdown

Budget display shows: sys 12% id 5% jnl 8% conv 40% = 15K/24K
Old conversation log entries silently skipped (journal has context).

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-08 16:53:23 -04:00
parent 9c0533966a
commit 31e813f57d
2 changed files with 13 additions and 1 deletions

View file

@ -56,6 +56,7 @@ impl ConversationLog {
if let Ok(node) = serde_json::from_str::<AstNode>(line) { if let Ok(node) = serde_json::from_str::<AstNode>(line) {
nodes.push(node); nodes.push(node);
} }
// Old format entries silently skipped — journal has the context
} }
Ok(nodes) Ok(nodes)
} }

View file

@ -843,7 +843,18 @@ impl ScreenView for InteractScreen {
.unwrap_or_default(); .unwrap_or_default();
} }
if let Ok(ctx) = self.agent.context.try_lock() { if let Ok(ctx) = self.agent.context.try_lock() {
app.status.context_budget = format!("{} tokens", ctx.tokens()); let budget = crate::agent::context::context_budget_tokens();
let sys = ctx.system().iter().map(|n| n.tokens()).sum::<usize>();
let id = ctx.identity().iter().map(|n| n.tokens()).sum::<usize>();
let jnl = ctx.journal().iter().map(|n| n.tokens()).sum::<usize>();
let conv = ctx.conversation().iter().map(|n| n.tokens()).sum::<usize>();
let total = sys + id + jnl + conv;
let pct = |n: usize| if budget > 0 { n * 100 / budget } else { 0 };
app.status.context_budget = format!(
"sys {}% id {}% jnl {}% conv {}% = {}K/{}K",
pct(sys), pct(id), pct(jnl), pct(conv),
total / 1000, budget / 1000,
);
} }
{ {
let mind = self.shared_mind.lock().unwrap(); let mind = self.shared_mind.lock().unwrap();