Repository navigation
Conversation
c27126c to
787ba98
Compare
787ba98 to
0964124
Compare
a8a6894 to
b92ab08
Compare
57d6dcf to
877b571
Compare
877b571 to
818123d
Compare
818123d to
b513a74
Compare
b513a74 to
666a2a0
Compare
666a2a0 to
5e5ddd7
Compare
5e5ddd7 to
ab2bf67
Compare
ab2bf67 to
4dcdb23
Compare
4dcdb23 to
b7d2c99
Compare
b7d2c99 to
2edcbf7
Compare
e9baec0 to
659de87
Compare
…inal Two ways a committed composition was lost or corrupted. The composition route called preventDefault() before checking whether it owned the session. A route installed mid-composition never saw the matching session start, so it suppressed xterm's own insertion and then returned without delivering anything — the commit vanished. Ownership is now decided first; preventDefault stays for sessions the route does own, including the ones it deliberately drops after a transport swap, since that drop is its decision to make. The deferred-newline fallback fired `finish` directly, bypassing the pending-composition re-check that the event path uses. A composition still open at 200 ms got a newline sent into the middle of its preedit. The deadline now re-arms while a composition is pending, and its 2 s ceiling is measured from the last compositionupdate rather than from the start. A slow candidate window no longer splits the preedit, and neither does multi-segment bunsetsu conversion, which stays legitimately pending well past any fixed total-elapsed ceiling. A composition that stops progressing still cannot strand the keystroke. Co-authored-by: Orca <[email protected]> The re-arm also treats a live compositionupdate as evidence in its own right, not just a session the route recorded. A route installed while a composition was already in flight never saw that session start, so it has nothing to report as pending and the deadline would otherwise split that composition too.
659de87 to
0ada936
Compare
|
Heads up — I've opened #12120 as a draft that ports part of Taken: only the deferred-newline fallback re-arm — the Not taken: the composition-route ownership/ I kept your bunsetsu rationale in the comments verbatim, since the idle-vs-total-elapsed Not meant to supersede this PR. Happy to close mine, and glad to be corrected if I've |
Ports only the fallback re-arm portion of stablyai#11896 commit ab2bf67; transport-routing changes are intentionally excluded. Co-authored-by: Neil <[email protected]>
|
Heads up now that #12265 has landed: the fallback re-arm from this PR is the one piece of
const fallbackTimer = window.setTimeout(finish, fallbackMs) // line 45
I had ported just that hunk into #12120 — the
Happy to leave it entirely to you — this is your hunk and your rationale, and the |
|
Validation data for this draft, since it is the last piece of #11878 still open on I measured when the deferred newline actually fires, on Two scenarios. In both, a newline is deferred at t=0 with a composition already open.
B is the one that matters. On A is not a regression. 2100 ms is the idle ceiling doing its job. Measuring idle from the last
Caveat on what this is and is not: this is unit-level with fake timers, so it establishes the ordering and the deadline behaviour, not real-device timing. I have a Windows 11 + Microsoft Korean IME (2-beolsik) machine and can run the real-device pass against a build of this branch whenever one exists — that was the gap that held up the predicate fix too, and I would rather not have it hold this one up as well. Related, in case it saves someone a search: #11983 stacks the defer-time session capture on top of this, which covers the other half I raised on #11878 — a session that starts after the defer holding the newline hostage. Between the two the fallback path looks fully addressed; nothing further from me. |
|
Duplicate of #12942 and obsolete for the same reason: all four files it touches were deleted by #13128 (17b3dff). The deferral mechanism was the bug — on 1.4.171 it wrote a Shift+Enter payload to the PTY with no Enter pressed, 10/10, at 203-218 ms after keydown. If commit-splitting still reproduces on current main, please reopen with a trace. |
Summary
Three terminal IME bugs, all of which corrupt committed CJK text.
1. Dropped commits after a transport swap. The composition route delivered a finished commit to whatever transport was current at delivery time. If the pty was swapped mid-composition, the text landed on the wrong pty. The route now checks transport identity and ownership before delivering, and deliberately drops when the captured transport is gone — that drop is the route's decision to make, rather than silently writing to a stranger.
2. Newlines split the preedit. The deferred-newline fallback called
finishdirectly, bypassing the pending-composition re-check the event path uses. A composition still open at 200 ms got a newline sent into the middle of its preedit — you press Enter, and your half-converted Japanese gets cut in two with a line break through it.The deadline now re-arms while a composition is pending. Its 2 s ceiling is measured from the last
compositionupdate, not from the start: multi-segment bunsetsu conversion legitimately keeps a Japanese composition pending far longer than any fixed total-elapsed budget, so a wall-clock ceiling would reintroduce exactly the split it is meant to prevent. A composition that stops progressing still cannot strand the keystroke.3. Compositions already in flight when the route installs. The re-arm asked the route whether a composition was pending, but a route installed mid-composition never saw that session start, so it had nothing recorded to report — and the deadline split that composition too. A live
compositionupdatenow counts as evidence in its own right.Screenshots
No visual change in the UI chrome. The user-visible effect is in terminal text: committed CJK no longer lands on the wrong pty or gets bisected by a newline.
Testing
pnpm lintpnpm typecheckpnpm test— 2905 passing across the terminal-pane and IME suitespnpm build— not runOn the idle ceiling specifically: the new test (
holds the newline through a long conversion that keeps updating its preedit) was verified to fail without the fix and pass with it, so it is a real regression test rather than a tautology.AI Review Report
A review subagent found the wall-clock ceiling bug in my own first version of this PR — the original 2 s budget was absolute, which would split any conversion running longer than 2 s. A total-elapsed ceiling is the wrong shape for this: composition length is a property of what the user is typing, not of anything going wrong. The bound that is actually meaningful is idle time — a composition that has stopped progressing. Fixed here, with the regression test above.
Also verified while fixing it: xterm's own
CompositionHelper.blur():245-247already finalizes on blur, so the original "compositionend is not guaranteed on focus loss" rationale was not the real justification for the ceiling. The comment now states the actual one — a composition that stops progressing.Cross-platform: the deferral is driven by DOM composition events and the xterm session events, both platform-neutral. SSH and folder-workspace cases are unaffected — the route keys on transport identity, which is the same abstraction for local, SSH, and relay ptys, and the drop-on-missing-transport path is what makes an SSH reconnect safe.
Security Audit
Notes
Base: #11895. Depends on #11894 for the readable
CompositionHelpersource.