Skip to content

fix: deliver shift+enter's esc cr as one write - #182

Merged
scode merged 1 commit into
mainfrom
pr/shift-enter-single-write
Aug 19, 2026
Merged

scode merged 1 commit into
mainfrom
pr/shift-enter-single-write

Conversation

@scode

@scode scode commented Aug 19, 2026

Copy link
Copy Markdown
Owner

No description provided.

@scode
scode force-pushed the pr/create-default-install branch from 8579319 to 8fdf796 Compare August 19, 2026 14:45
@scode
scode force-pushed the pr/shift-enter-single-write branch from e1ba71f to b90bf7c Compare August 19, 2026 14:45
@scode
scode changed the base branch from pr/create-default-install to main August 19, 2026 14:59
The chord had two producers: the keydown handler sent the ESC and
xterm's own Enter path sent the CR, one websocket message apart — and
a message this small is one send-keys command and one pty write
(measured on the pinned tmux 3.7b: two commands land as two reads ~7ms
apart, never coalesced). Line editors that disambiguate a lone ESC by
read boundary saw Escape then Enter: Codex submitted the prompt
instead of inserting a newline (openai/codex#21699 shows the same
symptom in tmux, though its own diagnosis is extended-key negotiation
rather than write splitting), and a zsh with vi-mode's KEYTIMEOUT=1
sits on the same edge. bash's 500ms readline timeout papered over the
split, which is why it shipped.

The keydown now arms a merge instead of sending, and the onData
wrapper glues the ESC onto the \r xterm emits synchronously for that
same keystroke — one message, one write, with xterm's Enter-path side
effects kept intact. The arm lives exactly one keydown dispatch (a
microtask queued at arm time expires it), so a chord whose \r never
materializes leaves no stale arm to prefix a later unrelated Enter,
and the ESC is never flushed alone. Verified in a scratch tmux 3.7b
that single-write ESC CR inserts a real line break in codex-cli
0.147.0 and Claude Code 2.1.235, so one sequence serves every pane
and no per-target branching is needed.
@scode
scode force-pushed the pr/shift-enter-single-write branch from b90bf7c to b76652c Compare August 19, 2026 14:59
@scode
scode merged commit 85f54f3 into main Aug 19, 2026
8 checks passed
@scode
scode deleted the pr/shift-enter-single-write branch August 19, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant