fix(compose): deliver Enter as a discrete write so wrapping lines submit#101
Merged
Conversation
fix: skip Termux setup in Debian release build
fix: make release workflow pass under act
A single read carrying <text>+CR is treated as a paste by some remote TUIs (Claude Code / Ink-style apps), which insert the trailing CR as a literal newline instead of submitting. Sending Enter as a separate, slightly delayed write makes it an isolated keypress that submits regardless of line length.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When composing over a mobile/SSH terminal, submitting a long line that wraps in compose-mode sometimes inserts a newline into the remote app's input instead of submitting it — the line "doesn't send," and the next line gets concatenated onto it.
Root cause
onSendcurrently does:Both calls fire in the same tick, so the line text and the Enter/CR are flushed together and arrive at the remote in a single terminal
read()(verified with anstraceof the receiving app: one read, e.g."…long line…\r", a single trailing0x0d, no bracketed-paste markers).Some remote TUIs — Claude Code and other Ink/readline-style apps — classify a single read that delivers a whole long line ending in CR as a paste, and insert the trailing CR as a literal newline rather than treating it as a submit keypress. A short line (fits one line) is treated as typed input and submits fine; a wrapping line is treated as pasted and its CR becomes a newline. That length/wrap dependence is exactly the observed intermittency.
Fix
Deliver the Enter as a separate write, a short moment after the text, so the remote sees it as an isolated keypress rather than part of a pasted burst:
This is length-independent by construction and has no downside for shells or well-behaved TUIs (an isolated CR is a normal Enter everywhere). The 120 ms is a conservative gap chosen to survive SSH/tmux write coalescing; it can be tuned.
Testing
Validated on-device (Android, over SSH+tmux into a Claude Code session): before, long wrapping compose lines intermittently inserted a newline instead of submitting; after, repeated long wrapping lines submit reliably, and short lines are unaffected.