use super::Fullness;
pub fn render(ui: &mut egui::Ui, full: &Fullness) {
ui.horizontal(|ui| {
ui.label(format!("context {}%", full.percent()));
ui.weak(format!(
"({} / {} tok · {})",
full.prompt_tokens, full.window, full.model
))
.on_hover_text(hover(full));
});
}
fn hover(full: &Fullness) -> String {
format!(
"The prompt {}'s latest step sent, against the context_window \
models.yaml declares for it — how full this conversation's context is \
now, not what it has spent (the budget line above sums every step of \
the whole descent). A provider that reports its cached prefix \
separately makes this a floor.",
full.model
)
}
#[cfg(test)]
mod tests {
use super::*;
fn painted(full: &Fullness) -> String {
crate::paint_probe::paint(|ui| render(ui, full))
}
#[test]
fn renders_the_percent_and_the_evidence_behind_it() {
let text = painted(&Fullness {
model: "claude-sonnet-5".to_owned(),
prompt_tokens: 50_000,
window: 200_000,
});
assert!(text.contains("context 25%"), "got:\n{text}");
assert!(
text.contains("(50000 / 200000 tok · claude-sonnet-5)"),
"got:\n{text}"
);
}
#[test]
fn the_hover_says_which_figure_this_is() {
let full = Fullness {
model: "gpt-5.4".to_owned(),
prompt_tokens: 1,
window: 400_000,
};
let hover = hover(&full);
assert!(hover.contains("gpt-5.4"), "got: {hover}");
assert!(hover.contains("context_window"), "got: {hover}");
assert!(hover.contains("floor"), "got: {hover}");
assert!(painted(&full).contains("context 0%"));
}
}