Skip to content

UP/DOWN should navigate visual lines on wrapped input, deferring history cycling to first/last visual line #22009

@ddiall

Description

@ddiall

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:

  1. 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.

  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/tuiTerminal UI (ui-tui/ + tui_gateway/)type/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions