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 <poc@bcachefs.org>
This commit is contained in:
parent
5c9590ada7
commit
7237baba11
1 changed files with 16 additions and 4 deletions
|
|
@ -883,12 +883,24 @@ impl ScreenView for InteractScreen {
|
||||||
let sys = ctx.system().iter().map(|n| n.tokens()).sum::<usize>();
|
let sys = ctx.system().iter().map(|n| n.tokens()).sum::<usize>();
|
||||||
let id = ctx.identity().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 jnl = ctx.journal().iter().map(|n| n.tokens()).sum::<usize>();
|
||||||
let conv = ctx.conversation().iter().map(|n| n.tokens()).sum::<usize>();
|
let (mem, conv) = {
|
||||||
let total = sys + id + jnl + 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 };
|
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 {}% conv {}% = {}K/{}K",
|
"sys {}% id {}% jnl {}% mem {}% conv {}% = {}K/{}K",
|
||||||
pct(sys), pct(id), pct(jnl), pct(conv),
|
pct(sys), pct(id), pct(jnl), pct(mem), pct(conv),
|
||||||
total / 1000, budget / 1000,
|
total / 1000, budget / 1000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue