hermes - 💡(How to fix) Fix [Meta]: hermes-ink TextInput visual-line navigation and clipboard gaps

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

The hermes-ink fork's <TextInput> component has several systemic gaps in input handling, all stemming from the same codebase (ui-tui/src/components/textInput.tsx and hermes-ink/packages/ink/src/parse-keypress.ts). These make the TUI input area behave unexpectedly compared to standard terminal editors or tools like Claude Code/OpenCode.

Root Cause

3. Shift+Enter / Ctrl+Enter newline parity (#18228 / PR #18229)

Shift+Enter and Ctrl+Enter submit instead of inserting a newline when the terminal sends CR (0x0D) instead of LF (0x0A). Root cause: parse-keypress.ts normalizes both to key.return = true and discards the raw byte. PR #18229 preserves keypress.raw for CR/LF. Currently only Ctrl+J (0x0A) works for newlines on Windows Terminal.

Fix Action

Fix / Workaround

4. Backspace on newline characters (#18394)

Backspace cannot delete newline characters inserted into the prompt. The \ backslash workaround produces a state desync where lines above become "fixed" and the cursor cannot navigate back. Root cause suspected in React state sync between vRef/curRef and the render cycle.

RAW_BUFFERClick to expand / collapse

Summary

The hermes-ink fork's <TextInput> component has several systemic gaps in input handling, all stemming from the same codebase (ui-tui/src/components/textInput.tsx and hermes-ink/packages/ink/src/parse-keypress.ts). These make the TUI input area behave unexpectedly compared to standard terminal editors or tools like Claude Code/OpenCode.

Sub-Issues

1. HOME/END on wrapped visual lines (#22008)

<Home> maps to position 0 and <End> to v.length, ignoring visual wrapping. For long prompts that wrap across multiple terminal lines, pressing Home goes to the logical start instead of the start of the visible line. The fix exists in inputMetrics.ts (visualLines(), cursorLayout()) but is unused by the key handlers.

2. UP/DOWN on wrapped visual lines (#22009)

lineNav() (textInput.tsx:153) and the global handler (useInputHandlers.ts:381) use lastIndexOf("\n") to decide navigation. For wrapped single-line prompts, no \n exists, so Up always cycles history instead of moving the cursor up one visual line. Needs visual-line-aware column-anchored navigation.

3. Shift+Enter / Ctrl+Enter newline parity (#18228 / PR #18229)

Shift+Enter and Ctrl+Enter submit instead of inserting a newline when the terminal sends CR (0x0D) instead of LF (0x0A). Root cause: parse-keypress.ts normalizes both to key.return = true and discards the raw byte. PR #18229 preserves keypress.raw for CR/LF. Currently only Ctrl+J (0x0A) works for newlines on Windows Terminal.

4. Backspace on newline characters (#18394)

Backspace cannot delete newline characters inserted into the prompt. The \ backslash workaround produces a state desync where lines above become "fixed" and the cursor cannot navigate back. Root cause suspected in React state sync between vRef/curRef and the render cycle.

5. Right-click always pastes, never copies (no issue filed)

The mouse handler (textInput.tsx:975) calls event.stopImmediatePropagation() on right-click and always emits a paste, regardless of whether text is selected. This prevents the terminal emulator from doing its native right-click=copy-if-selected behavior. On macOS, endMouseSelection() copies on selection end, but that path is macOS-only (line 682). There is no non-macOS keyboard shortcut to copy selected text from the input prompt.

Affected Environments

  • Windows Terminal + WSL2 (most commonly reported)
  • Terminal emulators that send CR (0x0D) for modified Enter keys
  • Non-macOS platforms without native selection-copy integration

Proposed Approach

These issues share fix patterns in the same files. A collective improvement to textInput.tsx could address 1, 2, and 5 together with visual-line-aware navigation + mouse handler parity. Issues 3 and 4 are in parse-keypress.ts (different file, similar root cause of raw byte handling).

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING