Skip to content

Commit 8475d51

Browse files
fix(tui): remove duplicate context statusline item (#18054)
Addresses #18045 Problem: `/statusline` exposed both `context-remaining` and `context-remaining-percent` after conflicting PRs attempted to address the same context-status issue, including #17637, allowing duplicate footer segments. Solution: Remove the duplicate `context-remaining-percent` status-line item and update status-line tests and snapshots to use only canonical `context-remaining`.
1 parent b4be361 commit 8475d51

5 files changed

Lines changed: 13 additions & 50 deletions

codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__status_line_setup__tests__setup_view_snapshot_uses_runtime_preview_values.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ expression: "render_lines(&view, 72)"
88

99
Type to search
1010
>
11-
› [x] model-name Current model name
12-
[x] current-dir Current working directory
13-
[x] git-branch Current Git branch (omitted when unavail
14-
[ ] model-with-reasoning Current model name with reasoning level
15-
[ ] project-root Project root directory (omitted when una
16-
[ ] context-remaining Percentage of context window remaining (…
17-
[ ] context-remaining-... Percentage of context window remaining (
18-
[ ] context-used Percentage of context window used (omitt
11+
› [x] model-name Current model name
12+
[x] current-dir Current working directory
13+
[x] git-branch Current Git branch (omitted when unavaila
14+
[ ] model-with-reasoning Current model name with reasoning level
15+
[ ] project-root Project root directory (omitted when unav
16+
[ ] context-remaining Percentage of context window remaining (o
17+
[ ] context-used Percentage of context window used (omitte
18+
[ ] five-hour-limit Remaining usage on 5-hour usage limit (om
1919

2020
gpt-5-codex · ~/codex-rs · jif/statusline-preview
2121
Use ↑↓ to navigate, ←→ to move, space to select, enter to confirm, esc

codex-rs/tui/src/bottom_pane/status_line_setup.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ pub(crate) enum StatusLineItem {
6666
/// Percentage of context window remaining.
6767
ContextRemaining,
6868

69-
/// Percentage of context window remaining.
70-
#[strum(to_string = "context-remaining-percent")]
71-
ContextRemainingPercent,
72-
7369
/// Percentage of context window used.
7470
///
7571
/// Also accepts the legacy `context-usage` config value.
@@ -119,9 +115,6 @@ impl StatusLineItem {
119115
StatusLineItem::ContextRemaining => {
120116
"Percentage of context window remaining (omitted when unknown)"
121117
}
122-
StatusLineItem::ContextRemainingPercent => {
123-
"Percentage of context window remaining (omitted when unknown)"
124-
}
125118
StatusLineItem::ContextUsed => {
126119
"Percentage of context window used (omitted when unknown)"
127120
}
@@ -321,7 +314,7 @@ mod tests {
321314
}
322315

323316
#[test]
324-
fn context_remaining_is_separate_selectable_id() {
317+
fn context_remaining_is_selectable_id() {
325318
assert_eq!(
326319
"context-remaining".parse::<StatusLineItem>(),
327320
Ok(StatusLineItem::ContextRemaining)
@@ -332,18 +325,6 @@ mod tests {
332325
);
333326
}
334327

335-
#[test]
336-
fn context_remaining_percent_is_separate_selectable_id() {
337-
assert_eq!(
338-
StatusLineItem::ContextRemainingPercent.to_string(),
339-
"context-remaining-percent"
340-
);
341-
assert_eq!(
342-
"context-remaining-percent".parse::<StatusLineItem>(),
343-
Ok(StatusLineItem::ContextRemainingPercent)
344-
);
345-
}
346-
347328
#[test]
348329
fn preview_uses_runtime_values() {
349330
let preview_data = StatusLinePreviewData::from_iter([

codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__status_line_model_with_reasoning_context_remaining_percent_footer.snap renamed to codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__status_line_model_with_reasoning_context_remaining_footer.snap

File renamed without changes.

codex-rs/tui/src/chatwidget/status_surfaces.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ impl ChatWidget {
450450
Some(format!("{} used", format_tokens_compact(total)))
451451
}
452452
}
453-
StatusLineItem::ContextRemaining | StatusLineItem::ContextRemainingPercent => self
453+
StatusLineItem::ContextRemaining => self
454454
.status_line_context_remaining_percent()
455455
.map(|remaining| format!("Context {remaining}% left")),
456456
StatusLineItem::ContextUsed => self

codex-rs/tui/src/chatwidget/tests/status_and_layout.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -914,24 +914,6 @@ async fn status_line_legacy_context_usage_renders_context_used_percent() {
914914
);
915915
}
916916

917-
#[tokio::test]
918-
async fn status_line_context_remaining_percent_renders_labeled_percent() {
919-
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
920-
chat.thread_id = Some(ThreadId::new());
921-
chat.config.tui_status_line = Some(vec!["context-remaining-percent".to_string()]);
922-
923-
chat.refresh_status_line();
924-
925-
assert_eq!(
926-
status_line_text(&chat),
927-
Some("Context 100% left".to_string())
928-
);
929-
assert!(
930-
drain_insert_history(&mut rx).is_empty(),
931-
"context-remaining-percent should remain a valid status line item"
932-
);
933-
}
934-
935917
#[tokio::test]
936918
async fn status_line_branch_state_resets_when_git_branch_disabled() {
937919
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() {
12001182
}
12011183

12021184
#[tokio::test]
1203-
async fn status_line_model_with_reasoning_context_remaining_percent_footer_snapshot() {
1185+
async fn status_line_model_with_reasoning_context_remaining_footer_snapshot() {
12041186
use ratatui::Terminal;
12051187
use ratatui::backend::TestBackend;
12061188

@@ -1211,7 +1193,7 @@ async fn status_line_model_with_reasoning_context_remaining_percent_footer_snaps
12111193
chat.config.cwd = test_project_path().abs();
12121194
chat.config.tui_status_line = Some(vec![
12131195
"model-with-reasoning".to_string(),
1214-
"context-remaining-percent".to_string(),
1196+
"context-remaining".to_string(),
12151197
"current-dir".to_string(),
12161198
]);
12171199
chat.set_reasoning_effort(Some(ReasoningEffortConfig::XHigh));
@@ -1228,7 +1210,7 @@ async fn status_line_model_with_reasoning_context_remaining_percent_footer_snaps
12281210
.draw(|f| chat.render(f.area(), f.buffer_mut()))
12291211
.expect("draw model-with-reasoning footer");
12301212
assert_chatwidget_snapshot!(
1231-
"status_line_model_with_reasoning_context_remaining_percent_footer",
1213+
"status_line_model_with_reasoning_context_remaining_footer",
12321214
normalized_backend_snapshot(terminal.backend())
12331215
);
12341216
}

0 commit comments

Comments
 (0)