feat: add context percent to status line (#17637)

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
jif-oaiandCodex authored and GitHub committed 2026-04-14 14:27:24 +01:00
1 parent 34a9ca083e
commit e6947f85f6
5 files changed
+89 -9

No files matched your search

@@ -8,14 +8,14 @@ expression: "render_lines(&view, 72)"
Type to search
>
› [x] model-name Current model name
[x] current-dir Current working directory
[x] git-branch Current Git branch (omitted when unavaila…
[ ] model-with-reasoning Current model name with reasoning level
[ ] project-root Project root directory (omitted when unav…
[ ] context-remaining Percentage of context window remaining (o…
[ ] context-used Percentage of context window used (omitte…
[ ] five-hour-limit Remaining usage on 5-hour usage limit (om…
› [x] model-name Current model name
[x] current-dir Current working directory
[x] git-branch Current Git branch (omitted when unavail…
[ ] model-with-reasoning Current model name with reasoning level
[ ] project-root Project root directory (omitted when una…
[ ] context-remaining Percentage of context window remaining (…
[ ] context-remaining-... Percentage of context window remaining (…
[ ] context-used Percentage of context window used (omitt…
gpt-5-codex · ~/codex-rs · jif/statusline-preview
Use ↑↓ to navigate, ←→ to move, space to select, enter to confirm, esc
@@ -66,6 +66,10 @@ pub(crate) enum StatusLineItem {
/// Percentage of context window remaining.
ContextRemaining,
/// Percentage of context window remaining.
#[strum(to_string = "context-remaining-percent")]
ContextRemainingPercent,
/// Percentage of context window used.
///
/// Also accepts the legacy `context-usage` config value.
@@ -115,6 +119,9 @@ impl StatusLineItem {
StatusLineItem::ContextRemaining => {
"Percentage of context window remaining (omitted when unknown)"
}
StatusLineItem::ContextRemainingPercent => {
"Percentage of context window remaining (omitted when unknown)"
}
StatusLineItem::ContextUsed => {
"Percentage of context window used (omitted when unknown)"
}
@@ -325,6 +332,18 @@ mod tests {
);
}
#[test]
fn context_remaining_percent_is_separate_selectable_id() {
assert_eq!(
StatusLineItem::ContextRemainingPercent.to_string(),
"context-remaining-percent"
);
assert_eq!(
"context-remaining-percent".parse::<StatusLineItem>(),
Ok(StatusLineItem::ContextRemainingPercent)
);
}
#[test]
fn preview_uses_runtime_values() {
let preview_data = StatusLinePreviewData::from_iter([