Summary
In the TUI TextInput, pressing or on a single-line prompt that wraps across multiple terminal rows always cycles prompt history. Expected behavior: / should navigate the cursor to the adjacent visual line (like GNU Readline or any terminal shell), only deferring to history cycling when the cursor is on the first or last visual line.
Expected Behavior
- on a wrapped line (cursor not on first visual line): move cursor up one visual line, anchoring the same column position (clamped to the line's length)
- on the first visual line: cycle backward through prompt history (current behavior)
- on a wrapped line (cursor not on last visual line): move cursor down one visual line, anchored column position
- on the last visual line: cycle forward or clear prompt (current behavior)
Affected Code
Two locations:
-
lineNav() in ui-tui/src/components/textInput.tsx (~line 153): currently traverses \n delimiters only. Needs visual-line awareness via visualLines() and cursorLayout() from inputMetrics.ts.
-
useInputHandlers.ts (~line 381): global handler checks lastIndexOf(n, ...) to decide whether to cycle history. For wrapped (no-\n) input, this always returns -1, so history is cycled even when the cursor is on a middle visual line. This check needs to account for visual lines.
Bonus: Ctrl+PgUp / Ctrl+PgDn
Currently PgUp/PgDn scroll the chat transcript, but Ctrl+PgUp (scroll to top of transcript) and Ctrl+PgDn (scroll to bottom of transcript) are unmapped. Worth considering as part of this input navigation pass.
Related
Summary
In the TUI TextInput, pressing or on a single-line prompt that wraps across multiple terminal rows always cycles prompt history. Expected behavior: / should navigate the cursor to the adjacent visual line (like GNU Readline or any terminal shell), only deferring to history cycling when the cursor is on the first or last visual line.
Expected Behavior
Affected Code
Two locations:
lineNav()inui-tui/src/components/textInput.tsx(~line 153): currently traverses\ndelimiters only. Needs visual-line awareness viavisualLines()andcursorLayout()frominputMetrics.ts.useInputHandlers.ts(~line 381): global handler checkslastIndexOf(n, ...)to decide whether to cycle history. For wrapped (no-\n) input, this always returns-1, so history is cycled even when the cursor is on a middle visual line. This check needs to account for visual lines.Bonus: Ctrl+PgUp / Ctrl+PgDn
Currently PgUp/PgDn scroll the chat transcript, but Ctrl+PgUp (scroll to top of transcript) and Ctrl+PgDn (scroll to bottom of transcript) are unmapped. Worth considering as part of this input navigation pass.
Related