Repository navigation
fix(terminal): Shift+Enter inserts a newline in TUI apps (Claude Code) - #111
Conversation
xterm.js emits a plain \r for both Enter and Shift+Enter, so TUI apps like Claude Code can't distinguish them and treat Shift+Enter as submit. Intercept Shift+Enter in the custom key handler and write ESC+CR — the same sequence Alt/Option+Enter produces and that Claude Code's /terminal-setup wires up — so it inserts a newline instead of submitting. Ctrl/Alt/Meta are excluded so Ctrl+Shift+Enter (zoom pane) is untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
i use another harness than claude code and for me shift enter works (windows) |
…roadcast mode Follow-up to #111: sending ESC+CR via pty.write bypassed broadcast-input mode (issue #64) — Shift+Enter only reached the focused pane while every other keystroke fanned out. terminal.input() feeds onData, which owns the broadcast fan-out, so the newline now behaves like any other key. Also bump to 0.29.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWsKzWVX4PXbYeymcMSDP3
|
Merged — thanks @AvoChang, this is a clean fix and the choice of One small follow-up landed on master (2b7202f): the sequence is now sent via @arnonuem re: "shift enter works for me in another harness" — worth noting that xterm.js (which wmux embeds) doesn't support Shipping in v0.29.0. |
Problem
In a wmux terminal running Claude Code, Shift+Enter does not insert a newline — it submits the prompt instead. This works in cmux but was broken in wmux.
Root cause
xterm.js emits a plain
\r(carriage return) for both Enter and Shift+Enter, so a TUI app can't distinguish them and treats Shift+Enter as submit. wmux's custom key handler inuseTerminal.tshad no mapping for Shift+Enter.Claude Code recognizes
ESC + CR(\x1b\r) as a newline — the same sequence Alt/Option+Enter produces, and exactly what Claude Code's/terminal-setupconfigures for iTerm2/VSCode.Fix
Intercept Shift+Enter in the terminal's
attachCustomKeyEventHandlerand write\x1b\rto the PTY, returningfalseto suppress xterm's default\r.Testing
npm run build:rendererpasses.🤖 Generated with Claude Code