From 81ef5ff08ee2df4ad696f4f1eced9e8b71da722f Mon Sep 17 00:00:00 2001 From: Yaroslav Volovich Date: Mon, 23 Feb 2026 19:31:36 +0000 Subject: [PATCH] Use natural numbering in /fork picker --- codex-rs/tui/src/fork_turn_picker.rs | 10 +++++----- ...tui__fork_turn_picker__tests__fork_turn_picker.snap | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/codex-rs/tui/src/fork_turn_picker.rs b/codex-rs/tui/src/fork_turn_picker.rs index 81f662a323..bcb5725640 100644 --- a/codex-rs/tui/src/fork_turn_picker.rs +++ b/codex-rs/tui/src/fork_turn_picker.rs @@ -318,7 +318,7 @@ impl ForkTurnPickerScreen { if display_number == 0 || display_number > self.turns.len() { return; } - let idx = self.turns.len().saturating_sub(display_number); + let idx = display_number.saturating_sub(1); self.select_index(idx); } @@ -384,7 +384,7 @@ impl ForkTurnPickerScreen { key_hint::plain(KeyCode::Enter).into(), " to fork, ".dim(), key_hint::plain(KeyCode::Esc).into(), - " to cancel, digits jump (1 = latest)".dim(), + " to cancel, digits jump to row".dim(), ]); Paragraph::new(hints) .wrap(Wrap { trim: false }) @@ -394,7 +394,7 @@ impl ForkTurnPickerScreen { fn render_turn_list(&self, area: Rect, buf: &mut Buffer) { let block = Block::default() .borders(Borders::ALL) - .title("Turns (oldest to newest, 1 = latest)"); + .title("Turns (oldest to newest)"); let inner = block.inner(area); block.render(area, buf); @@ -487,7 +487,7 @@ impl ForkTurnPickerScreen { Line::from(vec![ "Selected: ".dim(), format!("{display_number}:").cyan(), - if display_number == 1 { + if self.selected + 1 == self.turns.len() { Span::from(" (latest)").dim() } else { Span::from("") @@ -508,7 +508,7 @@ impl ForkTurnPickerScreen { } fn display_turn_number(&self, idx: usize) -> usize { - self.turns.len().saturating_sub(idx) + idx.saturating_add(1) } } diff --git a/codex-rs/tui/src/snapshots/codex_tui__fork_turn_picker__tests__fork_turn_picker.snap b/codex-rs/tui/src/snapshots/codex_tui__fork_turn_picker__tests__fork_turn_picker.snap index 39e5b4e8a0..b13f9f47cc 100644 --- a/codex-rs/tui/src/snapshots/codex_tui__fork_turn_picker__tests__fork_turn_picker.snap +++ b/codex-rs/tui/src/snapshots/codex_tui__fork_turn_picker__tests__fork_turn_picker.snap @@ -5,8 +5,8 @@ expression: terminal.backend() /fork select a turn Choose a turn from the current conversation to fork after. 3 turns available. The newest turn is selected by default. -┌Turns (oldest to newest, 1 = latest)──────────────────────────────────────┐ -│ 3: Initial bug report with stack trace and repro steps │ +┌Turns (oldest to newest)──────────────────────────────────────────────────┐ +│ 1: Initial bug report with stack trace and repro steps │ │ Short answer: not via the current app-server protocol. │ │› 2: Please also handle macOS path edge cases when filenames contain ... │ │ Acknowledged. I will cover macOS path handling and spaces. │ @@ -22,5 +22,4 @@ Choose a turn from the current conversation to fork after. │ │ │Forking here omits 1 newer turn from the new thread. │ └──────────────────────────────────────────────────────────────────────────┘ -Use ↑/↓ (or j/k) to choose, enter to fork, esc to cancel, digits jump (1 = -latest) +Use ↑/↓ (or j/k) to choose, enter to fork, esc to cancel, digits jump to row