From 7237baba11ff4b27645ed7f8bd69b2a7a01814c0 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 8 Apr 2026 21:19:38 -0400 Subject: [PATCH] Split memory vs conversation tokens in status bar budget Memory nodes in the conversation section are now counted separately: sys X% id Y% jnl Z% mem W% conv V% = NK/MK Co-Authored-By: Proof of Concept --- src/user/chat.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/user/chat.rs b/src/user/chat.rs index 451c10e..5d6c965 100644 --- a/src/user/chat.rs +++ b/src/user/chat.rs @@ -883,12 +883,24 @@ impl ScreenView for InteractScreen { let sys = ctx.system().iter().map(|n| n.tokens()).sum::(); let id = ctx.identity().iter().map(|n| n.tokens()).sum::(); let jnl = ctx.journal().iter().map(|n| n.tokens()).sum::(); - let conv = ctx.conversation().iter().map(|n| n.tokens()).sum::(); - let total = sys + id + jnl + conv; + let (mem, conv) = { + let mut mem = 0usize; + let mut conv = 0usize; + for n in ctx.conversation() { + let t = n.tokens(); + if matches!(n, AstNode::Leaf(l) if matches!(l.body(), NodeBody::Memory { .. })) { + mem += t; + } else { + conv += t; + } + } + (mem, conv) + }; + let total = sys + id + jnl + mem + 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), + "sys {}% id {}% jnl {}% mem {}% conv {}% = {}K/{}K", + pct(sys), pct(id), pct(jnl), pct(mem), pct(conv), total / 1000, budget / 1000, ); }