Skip to content

Multi-line command editor with cursor, copy/paste, and syntax awareness #8

Description

@CKGrafico

Problem

Commands like 'gh issue list --label to refine --limit 1 --json number,title,body --jq {number: .[0].number, title: .[0].title, body: .[0].body}' are edited in a single-line input that:

  • Truncates long commands (no wrapping)
  • Has broken cursor movement (OpenTUI input steals arrow keys)
  • Ctrl+C/X/V/A broken (stale closures in useInputShortcuts)
  • No way to see the full command while editing
  • The copy button is a band-aid, not a solution

Solution

Build a proper command editor component on Ink.

Options (in order of complexity)

A) Use ink-text-input with showCursor=true - single line but with proper cursor, copy/paste via Ctrl+C/X/V/A, arrow key navigation within the text. Already 10x better than OpenTUI. Simplest.

B) Build a multi-line textarea on useInput - wraps long commands, supports multi-line paste, arrow-key cursor movement in 2D (up/down for line navigation, left/right for char). Medium complexity.

C) External editor integration - press a key to open dollar-EDITOR (vim/nano), return the edited command. Full power but breaks TUI flow. Good as an option, not as the default.

Recommended approach

Start with A (ink-text-input with showCursor). It solves 90% of the problem:

  • Cursor works (arrow keys move within text)
  • Copy/paste works (Ink useInput is fresh, no stale closures)
  • Single line but the input doesn't truncate (text scrolls horizontally)

Add B (multi-line) as enhancement if needed for chain commands that are very long.

Add C (external editor) as an option triggered by a key (e.g. press 'e' in the command field to open external editor).

Features

  • Cursor visible and movable with left/right arrows
  • Backspace, delete, home, end
  • Ctrl+C copies (when not quitting), Ctrl+V pastes, Ctrl+A select all, Ctrl+X cut
  • Placeholder text when empty (example command)
  • Copy button (the existing band-aid, kept as convenience)
  • Validation feedback (red text if command is empty on submit)
  • Submit on Enter (or Tab to move to next field)

Acceptance criteria

  • Text input with visible cursor
  • Arrow-key cursor movement (left/right within text)
  • Backspace and delete work
  • Ctrl+C/X/V/A work for copy/cut/paste/select-all
  • Placeholder text shows when empty
  • Copy button still works
  • Validation feedback on empty submit
  • Enter or Tab submits/moves to next field

Depends on #7 (architecture rebuild). Part of v2.0.0 epic #4

Metadata

Metadata

Assignees

No one assigned

    Labels

    v2.0.0v2.0.0 rebuild

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions