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();
|
.unwrap_or_default();
|
||||||
}
|
}
|
||||||
if let Ok(ctx) = self.agent.context.try_lock() {
|
if let Ok(ctx) = self.agent.context.try_lock() {
|
||||||
let budget = crate::agent::context::context_budget_tokens();
|
let window = crate::agent::context::context_window();
|
||||||
let sys = ctx.system().iter().map(|n| n.tokens()).sum::<usize>();
|
if window > 0 {
|
||||||
let id = ctx.identity().iter().map(|n| n.tokens()).sum::<usize>();
|
let sys = ctx.system().iter().map(|n| n.tokens()).sum::<usize>();
|
||||||
let jnl = ctx.journal().iter().map(|n| n.tokens()).sum::<usize>();
|
let id = ctx.identity().iter().map(|n| n.tokens()).sum::<usize>();
|
||||||
let (mem, conv) = {
|
let jnl = ctx.journal().iter().map(|n| n.tokens()).sum::<usize>();
|
||||||
let mut mem = 0usize;
|
let mut mem = 0usize;
|
||||||
let mut conv = 0usize;
|
let mut conv = 0usize;
|
||||||
for n in ctx.conversation() {
|
for n in ctx.conversation() {
|
||||||
|
|
@ -894,15 +894,14 @@ impl ScreenView for InteractScreen {
|
||||||
conv += t;
|
conv += t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(mem, conv)
|
let used = sys + id + jnl + mem + conv;
|
||||||
};
|
let free = window.saturating_sub(used);
|
||||||
let total = sys + id + jnl + mem + conv;
|
let pct = |n: usize| if n == 0 { 0 } else { ((n * 100) / window).max(1) };
|
||||||
let pct = |n: usize| if budget > 0 { n * 100 / budget } else { 0 };
|
app.status.context_budget = format!(
|
||||||
app.status.context_budget = format!(
|
"sys:{}% id:{}% jnl:{}% mem:{}% conv:{}% free:{}%",
|
||||||
"sys {}% id {}% jnl {}% mem {}% conv {}% = {}K/{}K",
|
pct(sys), pct(id), pct(jnl), pct(mem), pct(conv), pct(free),
|
||||||
pct(sys), pct(id), pct(jnl), pct(mem), pct(conv),
|
);
|
||||||
total / 1000, budget / 1000,
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let mind = self.shared_mind.lock().unwrap();
|
let mind = self.shared_mind.lock().unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue