Repository navigation
Conversation
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 08:10
2f63e95 to
567545e
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 08:12
567545e to
d7e89aa
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 08:20
d7e89aa to
0263ced
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 08:25
0263ced to
2cb70b2
Compare
This was referenced Aug 1, 2026
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 08:31
2cb70b2 to
f506553
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 08:37
f506553 to
219792a
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 08:43
219792a to
e623f4a
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 08:50
e623f4a to
6208a5d
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 09:17
6208a5d to
395aa29
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 10:04
395aa29 to
a3c54c1
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 1, 2026 10:14
a3c54c1 to
9d69804
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
2 times, most recently
from
August 2, 2026 02:34
281dea2 to
fe92be0
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 2, 2026 03:16
fe92be0 to
cf2d2d7
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 2, 2026 03:51
cf2d2d7 to
b9c88b5
Compare
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 2, 2026 04:09
b9c88b5 to
978157e
Compare
…ifted Escape was suppressed whenever the terminal's derived composition flag was set. That flag is not the per-event `isComposing` bit — it is tracked from composition events, and compositionend is not guaranteed, so it can stand until the tracker's 10 s stale expiry. For up to that long, Escape never reached the PTY and vim could not leave insert mode, with no way to recover. An Escape the IME really owns arrives marked, by `isComposing` or by keyCode 229 / key 'Process', and those clauses still suppress it. An unmarked one only ever means the flag has drifted. Letting a drifted Escape through bounds recovery by keystrokes rather than by the expiry timer. Escape does not take the finalize-then-encode path the other keys take: our vendored xterm build gives it its own branch in `CompositionHelper.keydown` (:278-282), ahead of the `_finalizeComposition` fall-through. While xterm still believes a composition is in flight that branch cancels — discarding the preedit and returning false — and `CoreBrowserTerminal._keyDown` (:875-879) then returns before `evaluateKeyDown`, so no `\x1b` is written. The cancel clears xterm's `_isComposing` but not this tracker, so the next Escape passes through. Worst case is one extra keypress; when only the tracker drifted and xterm has already settled, the first Escape reaches the shell. The rest of the IME-owned set — arrows, Backspace, Delete, Enter, Home/End, PageUp/PageDown — is unchanged: those are candidate-window keys and forwarding them mid-composition is what the set exists to prevent. Co-authored-by: Orca <[email protected]>
nwparker
force-pushed
the
nwparker/ime-key-event-policy
branch
from
August 2, 2026 04:49
978157e to
c801b88
Compare
Contributor
Author
|
Obsolete, and in a good way: |
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.
Summary
Escape was suppressed in the terminal whenever the derived composition flag was set. That flag is not the per-event
isComposingbit — it is tracked from composition events, andcompositionendis not guaranteed, so it can stand until the tracker's 10 s stale expiry. For up to that long Escape never reached the pty, vim could not leave insert mode, and there was no way to recover.Escape is now removed from
TERMINAL_IME_OWNED_KEYS. An Escape the IME really owns still arrives marked — byisComposing, orkeyCode 229/key 'Process'— and the existing clauses still suppress it. An unmarked Escape only ever means the flag has drifted.What letting it through actually costs
Escape does not take the finalize-then-encode path the other IME-owned keys take. Our vendored xterm build gives it its own branch in
CompositionHelper.keydown(:278-282), ahead of the_finalizeCompositionfall-through. While xterm still believes a composition is in flight, that branch cancels — discarding the preedit and returningfalse— andCoreBrowserTerminal._keyDown:875-879then returns beforeevaluateKeyDown, so no\x1bis written.The cancel clears xterm's
_isComposingbut not the terminal's tracker, so the next Escape passes through. Worst case is one extra keypress; when only the tracker drifted and xterm has already settled, the first Escape reaches the shell. Either way recovery is bounded by keystrokes instead of by a 10 s timer.The rest of the IME-owned set — arrows, Backspace, Delete, Enter, Home/End, PageUp/PageDown — is unchanged. Those are candidate-window keys, and forwarding them mid-composition is exactly what the set exists to prevent.
Screenshots
No visual change. Behavioral: Escape reaches the shell instead of being swallowed.
Testing
pnpm lintpnpm typecheckpnpm test— 28 passing inxterm-bypass-policy.test.ts, 2905 across the terminal-pane and IME suitespnpm build— not runisComposing,229, and'Process'is still suppressed)AI Review Report
This PR's stated rationale was wrong in its first version and a review subagent caught it, which is worth flagging explicitly for reviewers.
The original claim was that
CompositionHelper.keydownfinalizes an in-flight composition before returning true, so the preedit would be committed and the Escape encoded after it. That is true of upstream xterm and true of the other keys — but false for Escape in our patched build, because our patch adds the cancel branch at:278three lines above the block that was traced. I re-verified this directly againstnode_modules/@xterm/xterm/src/browser/input/CompositionHelper.tsrather than taking the reviewer's word for it, and confirmed the full chain including the early return atCoreBrowserTerminal._keyDown:875-879. The commit message, the code comment, and the architecture doc in #11893 were all corrected.The change itself was correct throughout; only the reasoning was wrong. Swallowing Escape for a 10 s window with no recovery is strictly worse than costing at most one extra keypress.
The general rule this follows: guard every key at the top of keydown on evidence the event itself carries, and keep the suppression set enumerated rather than implicit. Under that rule Escape does not belong in the set — an Escape the IME really owns arrives marked and is suppressed by the marker clauses; an unmarked one only ever means our derived flag has drifted. Orca's terminal guard is unusual in consulting a derived flag that can outlive the composition at all, which is exactly why Escape must not be suppressed on that flag alone.
Cross-platform: the marked-Escape clauses cover the Windows (
229) and Android ('Process') markers as well asisComposing, so IME-owned Escape stays suppressed on all three platforms. NometaKeyor path handling in this diff.Security Audit
\x1bto the pty in a case where it was previously swallowed. Escape is not a privileged or destructive byte, and the user pressed the key — this restores intended input rather than synthesizing it.Notes
Base: #11896. Reviewers wanting to check the xterm trace should read the
srcpatch from #11894.