fix(tui): preserve raw LF for Shift+Enter newline#18229
Conversation
|
Tested on WSL2 + Windows Terminal. Ctrl+Enter works correctly for inserting newlines after this patch. Note for Windows Terminal users: Shift+Enter sends CR (same as Enter) rather than LF, so Shift+Enter still submits -- Ctrl+Enter is the reliable shortcut on that platform until Kitty keyboard protocol is fully negotiated. Would be worth updating the PR description or a follow-up comment to note the platform difference in case other WSL users find this PR. |
|
I ended up creating a skill to auto-reapply this patch after every Hermes update, been three weeks and this is still open. |
|
I built a small follow-up branch on top of this PR that keeps the CR/LF preservation from #18229 but gates the raw-LF newline fallback so it doesn't turn every bare LF into multiline intent in thin/local PTY environments where plain Enter may also arrive as LF. Branch / compare: What it adds:
Local verification on the branch:
Happy to turn this into a patch against this PR if that shape is useful; I avoided opening a competing PR since this PR already owns the root cause. |
Summary
Fixes TUI multiline input for terminal stacks that distinguish plain Enter and Shift+Enter by raw CR/LF bytes.
The TUI
TextInputalready checksevent.keypress.raw === '\n'to insert a newline, buthermes-inkwas clearingrawfor both\rand\nwhen normalizing them tokey.return. This meant LF from Shift+Enter/Ctrl+J could no longer be distinguished from CR from Enter, so it submitted instead of inserting a newline.This PR preserves
keypress.rawfor CR/LF and adds regression coverage.Fixes #18228
Test Plan
npm --prefix ui-tui test -- parse-keypress.test.ts --runnpm --prefix ui-tui run build13) and Shift+Enter sends LF (10); after the fix, Shift+Enter inserts a newline and Enter submits.