From cc6c6c6053ae06ac1514139e283c06ad9ddf07b4 Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Tue, 5 May 2026 13:54:21 -0500 Subject: [PATCH] fix(scroll): Up/Down arrows now scroll transcript when composer is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The should_scroll_with_arrows gate was hardcoded to false since the initial commit, which meant bare Up/Down arrows always navigated composer history — they never scrolled the transcript view. Users in virtual terminals (Ghostty, Codex, Kitty-protocol terminals) were especially affected because they couldn't use the specialized Cmd+Up / Alt+Up shortcuts. The gate now returns true when the composer input is empty (or whitespace-only), so bare arrows scroll the transcript. When text is present, arrows still navigate composer history to recall previous prompts. Added 3 tests covering empty, whitespace-only, and text-filled composer states. --- crates/tui/src/tui/ui.rs | 8 ++++++-- crates/tui/src/tui/ui/tests.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/crates/tui/src/tui/ui.rs b/crates/tui/src/tui/ui.rs index 73daacb0..3a49f1a5 100644 --- a/crates/tui/src/tui/ui.rs +++ b/crates/tui/src/tui/ui.rs @@ -7378,8 +7378,12 @@ fn is_ctrl_h_backspace(key: &KeyEvent) -> bool { && !key.modifiers.contains(KeyModifiers::SUPER) } -fn should_scroll_with_arrows(_app: &App) -> bool { - false +fn should_scroll_with_arrows(app: &App) -> bool { + // When the composer is empty (or only whitespace), Up/Down arrows + // scroll the transcript. When the composer has text, they navigate + // composer history so the user can recall previous prompts. + // Cmd+Up / Alt+Up always scroll regardless, handled upstream. + app.input.trim().is_empty() } fn extract_reasoning_header(text: &str) -> Option { diff --git a/crates/tui/src/tui/ui/tests.rs b/crates/tui/src/tui/ui/tests.rs index d44bcb64..5bbe9c0c 100644 --- a/crates/tui/src/tui/ui/tests.rs +++ b/crates/tui/src/tui/ui/tests.rs @@ -3134,3 +3134,34 @@ fn checklist_write_renders_dedicated_card() { "raw JSON must NOT appear: {joined}" ); } + +// ---- scroll_with_arrows ---- + +#[test] +fn scroll_with_arrows_returns_true_when_input_empty() { + let app = create_test_app(); + assert!( + super::should_scroll_with_arrows(&app), + "empty composer: Up/Down should scroll transcript" + ); +} + +#[test] +fn scroll_with_arrows_returns_true_when_input_only_whitespace() { + let mut app = create_test_app(); + app.input = " ".to_string(); + assert!( + super::should_scroll_with_arrows(&app), + "whitespace-only composer: Up/Down should scroll transcript" + ); +} + +#[test] +fn scroll_with_arrows_returns_false_when_input_has_text() { + let mut app = create_test_app(); + app.input = "hello".to_string(); + assert!( + !super::should_scroll_with_arrows(&app), + "text in composer: Up/Down should navigate history" + ); +}