Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix(tui): remove duplicate context statusline item (#18054)

Eric Traut8475d51655a3
diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__status_line_setup__tests__setup_view_snapshot_uses_runtime_preview_values.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__status_line_setup__tests__setup_view_snapshot_uses_runtime_preview_values.snap
index 679aa77f4a..20aca1e334 100644
--- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__status_line_setup__tests__setup_view_snapshot_uses_runtime_preview_values.snap
+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__status_line_setup__tests__setup_view_snapshot_uses_runtime_preview_values.snap
@@ -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 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…
+› [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…
gpt-5-codex · ~/codex-rs · jif/statusline-preview
Use ↑↓ to navigate, ←→ to move, space to select, enter to confirm, esc
diff --git a/codex-rs/tui/src/bottom_pane/status_line_setup.rs b/codex-rs/tui/src/bottom_pane/status_line_setup.rs
index b5fe8456ed..4c7e29c053 100644
--- a/codex-rs/tui/src/bottom_pane/status_line_setup.rs
+++ b/codex-rs/tui/src/bottom_pane/status_line_setup.rs
@@ -66,10 +66,6 @@ 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.
@@ -119,9 +115,6 @@ 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)"
}
@@ -321,7 +314,7 @@ mod tests {
}
#[test]
- fn context_remaining_is_separate_selectable_id() {
+ fn context_remaining_is_selectable_id() {
assert_eq!(
"context-remaining".parse::<StatusLineItem>(),
Ok(StatusLineItem::ContextRemaining)
@@ -332,18 +325,6 @@ 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([
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__status_line_model_with_reasoning_context_remaining_percent_footer.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__status_line_model_with_reasoning_context_remaining_footer.snap
similarity index 100%
rename from codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__status_line_model_with_reasoning_context_remaining_percent_footer.snap
rename to codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__status_line_model_with_reasoning_context_remaining_footer.snap
diff --git a/codex-rs/tui/src/chatwidget/status_surfaces.rs b/codex-rs/tui/src/chatwidget/status_surfaces.rs
index ba95da93b3..a744711c2c 100644
--- a/codex-rs/tui/src/chatwidget/status_surfaces.rs
+++ b/codex-rs/tui/src/chatwidget/status_surfaces.rs
@@ -450,7 +450,7 @@ impl ChatWidget {
Some(format!("{} used", format_tokens_compact(total)))
}
}
- StatusLineItem::ContextRemaining | StatusLineItem::ContextRemainingPercent => self
+ StatusLineItem::ContextRemaining => self
.status_line_context_remaining_percent()
.map(|remaining| format!("Context {remaining}% left")),
StatusLineItem::ContextUsed => self
diff --git a/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs b/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs
index e59928ff1c..75ca9d1fba 100644
--- a/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs
+++ b/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs
@@ -914,24 +914,6 @@ async fn status_line_legacy_context_usage_renders_context_used_percent() {
);
}
-#[tokio::test]
-async fn status_line_context_remaining_percent_renders_labeled_percent() {
- let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
- chat.thread_id = Some(ThreadId::new());
- chat.config.tui_status_line = Some(vec!["context-remaining-percent".to_string()]);
-
- chat.refresh_status_line();
-
- assert_eq!(
- status_line_text(&chat),
- Some("Context 100% left".to_string())
- );
- assert!(
- drain_insert_history(&mut rx).is_empty(),
- "context-remaining-percent should remain a valid status line item"
- );
-}
-
#[tokio::test]
async fn status_line_branch_state_resets_when_git_branch_disabled() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
@@ -1200,7 +1182,7 @@ async fn status_line_model_with_reasoning_fast_footer_snapshot() {
}
#[tokio::test]
-async fn status_line_model_with_reasoning_context_remaining_percent_footer_snapshot() {
+async fn status_line_model_with_reasoning_context_remaining_footer_snapshot() {
use ratatui::Terminal;
use ratatui::backend::TestBackend;
@@ -1211,7 +1193,7 @@ async fn status_line_model_with_reasoning_context_remaining_percent_footer_snaps
chat.config.cwd = test_project_path().abs();
chat.config.tui_status_line = Some(vec![
"model-with-reasoning".to_string(),
- "context-remaining-percent".to_string(),
+ "context-remaining".to_string(),
"current-dir".to_string(),
]);
chat.set_reasoning_effort(Some(ReasoningEffortConfig::XHigh));
@@ -1228,7 +1210,7 @@ async fn status_line_model_with_reasoning_context_remaining_percent_footer_snaps
.draw(|f| chat.render(f.area(), f.buffer_mut()))
.expect("draw model-with-reasoning footer");
assert_chatwidget_snapshot!(
- "status_line_model_with_reasoning_context_remaining_percent_footer",
+ "status_line_model_with_reasoning_context_remaining_footer",
normalized_backend_snapshot(terminal.backend())
);
}