Restore format_budget: window-based %, free%, colon format, .max(1)
Matched the old format_budget behavior: uses context_window as denominator (not budget), shows free%, uses colon separators, .max(1) for non-zero sections. Added mem% split. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
bbffc2213e
commit
bf1fa62d14
1 changed files with 13 additions and 14 deletions
|
|
@ -879,11 +879,11 @@ impl ScreenView for InteractScreen {
|
|||
.unwrap_or_default();
|
||||
}
|
||||
if let Ok(ctx) = self.agent.context.try_lock() {
|
||||
let budget = crate::agent::context::context_budget_tokens();
|
||||
let window = crate::agent::context::context_window();
|
||||
if window > 0 {
|
||||
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 (mem, conv) = {
|
||||
let mut mem = 0usize;
|
||||
let mut conv = 0usize;
|
||||
for n in ctx.conversation() {
|
||||
|
|
@ -894,16 +894,15 @@ impl ScreenView for InteractScreen {
|
|||
conv += t;
|
||||
}
|
||||
}
|
||||
(mem, conv)
|
||||
};
|
||||
let total = sys + id + jnl + mem + conv;
|
||||
let pct = |n: usize| if budget > 0 { n * 100 / budget } else { 0 };
|
||||
let used = sys + id + jnl + mem + conv;
|
||||
let free = window.saturating_sub(used);
|
||||
let pct = |n: usize| if n == 0 { 0 } else { ((n * 100) / window).max(1) };
|
||||
app.status.context_budget = format!(
|
||||
"sys {}% id {}% jnl {}% mem {}% conv {}% = {}K/{}K",
|
||||
pct(sys), pct(id), pct(jnl), pct(mem), pct(conv),
|
||||
total / 1000, budget / 1000,
|
||||
"sys:{}% id:{}% jnl:{}% mem:{}% conv:{}% free:{}%",
|
||||
pct(sys), pct(id), pct(jnl), pct(mem), pct(conv), pct(free),
|
||||
);
|
||||
}
|
||||
}
|
||||
{
|
||||
let mind = self.shared_mind.lock().unwrap();
|
||||
app.status.dmn_state = mind.dmn.label().to_string();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue