Repository navigation
Conversation
nwparker
force-pushed
the
nwparker/ime-test-fixtures
branch
from
August 1, 2026 08:10
ae0784f to
2a55af0
Compare
nwparker
force-pushed
the
nwparker/ime-test-fixtures
branch
from
August 1, 2026 08:12
2a55af0 to
0df9009
Compare
nwparker
force-pushed
the
nwparker/ime-test-fixtures
branch
from
August 1, 2026 08:20
0df9009 to
02239a4
Compare
This was referenced Aug 1, 2026
nwparker
force-pushed
the
nwparker/ime-test-fixtures
branch
2 times, most recently
from
August 1, 2026 08:43
ca8eda2 to
d64da8c
Compare
nwparker
force-pushed
the
nwparker/ime-test-fixtures
branch
2 times, most recently
from
August 1, 2026 09:17
7d3746e to
f0497dd
Compare
nwparker
force-pushed
the
nwparker/ime-test-fixtures
branch
2 times, most recently
from
August 1, 2026 10:14
f65dfe0 to
b2b6ebc
Compare
nwparker
force-pushed
the
nwparker/ime-test-fixtures
branch
3 times, most recently
from
August 2, 2026 03:16
0f1db5a to
cf70f6b
Compare
5 of 6 tasks
Synthetic keystrokes cannot produce a composition — KeyboardEvents dispatched through CDP bypass the OS input-method layer — so the IME suites each grew their own ad-hoc dispatch helpers that assert against invented event orderings. Adds a trace harness that replays an event sequence captured from a real engine, stamping the observed buffer before each event so the code under test sees what the browser actually produced. Traces carry a provenance field: `recorded` traces come from a real engine and are authoritative, `derived` traces pin current behavior but prove nothing about the engine, so a fix justified only by a derived trace is visibly unverified. Two of the four seeded traces are recorded from ibus-hangul in CI; the Telex and Pinyin ones are derived and say so. Also replaces 17 inline `nativeEvent.isComposing` guards with one predicate. `isComposing` alone misses the extra keydown Safari emits after compositionend and the engines that report only keyCode 229 or key 'Process', so each call site was subtly different. The shared predicate adds a document-wide composition flag cleared on focusout, because compositionend is not delivered when the composing element loses focus. It also tracks the composing target and revalidates that the target is still connected on read: Chromium fires no focusout when a focused node is removed, so a composer that unmounts mid-composition would otherwise latch the flag on for the session and kill every Enter-to-commit surface in the app. The three remaining TaskPage sites go through shouldSuppressEnterSubmit, which now delegates to the same predicate. An earlier version of this message called them telemetry-only; they are Enter-submit gates, so bare isComposing was missing an IME-owned Enter on Windows and Android. Trace assertions compare an interpretation derived from event data against each trace's declared final state. The previous assertion read back the buffer the harness itself had stamped, so it could not fail. Co-authored-by: Orca <[email protected]>
An Escape the IME owns always arrives marked, so an unmarked one means the document flag has drifted. compositionend is not guaranteed, and eleven call sites guard Escape above their key dispatch, so the drift left rename fields, search boxes and pickers with no way to cancel. Matches the rule xterm-bypass-policy.ts already applies to the terminal. Co-authored-by: Orca <[email protected]>
The schema could not express repeat or selectionDirection, and the replayer coerced an absent isComposing to false — the one distinction the field is typed `boolean | undefined` to capture. repeat is what a press-and-hold accent panel is recognised by, so a trace recorded for that quirk could not reproduce it. Co-authored-by: Orca <[email protected]>
The Escape exemption assumes an IME-owned Escape arrives marked. Nothing recorded showed that, so the assumption lived only in prose. Encode it as a labelled derived trace with the command that promotes it. Co-authored-by: Orca <[email protected]>
nwparker
force-pushed
the
nwparker/ime-test-fixtures
branch
from
August 2, 2026 04:49
21b091b to
22991a5
Compare
Contributor
Author
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
Collapses the app's scattered IME guards onto one predicate, and adds the trace harness that lets IME behavior be tested without an IME.
Before this, each surface open-coded its own composition check. They disagreed: some tested only
isComposing, some onlykeyCode === 229, some nothing at all.isImeCompositionKeyDownis now the single place that decides a keystroke belongs to an IME, and 14 call sites migrate to it.The predicate checks an app-wide composition flag as well as the per-event bits, because the two cover opposite gaps.
keyCode === 229(Windows) andkey === 'Process'(Android) mark a key the IME consumed, and 229 is also what catches Safari's extra keydown aftercompositionend— the flag is already cleared by then, so it cannot help there. The flag covers the reverse: keys arriving during a live composition that carry neither marker.The app-wide flag tracks the composing target, not a bare boolean, and revalidates on read that the target is still connected. Clearing on blur is the usual answer, because browsers do not reliably deliver
compositionendwhen the composing element loses focus — but blur alone is not enough here: Chromium fires nofocusoutwhen a focused node is removed, so a composer that unmounts mid-composition would latch the flag on for the rest of the session and silently kill every Enter-to-commit surface in the app. Editors that scope composition state per editor instance escape this, since the state dies with the editor; a document-scoped flag has to revalidate instead.shouldSuppressEnterSubmitnow delegates to the same predicate, which brings the three remainingTaskPage.tsxsites in with it. An earlier revision of this PR described those three as telemetry-only reads; that was wrong — they are Enter-submit gates, so bareisComposingwas missing an IME-owned Enter on Windows and Android.Escape is exempt from the derived flag
The flag is derived state, and
compositionendis not guaranteed to arrive. When it drifts, every key it guards goes dead — and eleven call sites guard Escape above their key dispatch, so the casualties are the rename fields, search boxes, pickers and panels whose only way out is Escape.An Escape the IME owns should arrive marked (
isComposing,229, or'Process') and is still suppressed by the clauses above. An unmarked Escape therefore means the flag has drifted, and swallowing it strands the user behind a flag nothing is going to clear. So the flag no longer applies to Escape; the per-event markers still do.How well-evidenced that premise is, stated plainly: no trace in this stack contains a mid-composition Escape, recorded or derived, so the marking is argued rather than shown. The nearest evidence is the candidate-navigation trace, where mid-composition
ArrowDown/ArrowUpcarryisComposing: truewith their own keyCodes (40/38) rather than 229 — exactly the shape the argument needs — but that trace isderived. The singlerecordedtrace contains no mid-composition non-Processkey at all.The cost of being wrong is also not symmetric with the terminal's, which is why it is worth naming rather than burying.
xterm-bypass-policy.tsaccepts "worst case one extra keypress" for the same rule — benign. Here the Escape handlers runonClear()andonClose(), so an IME-owned-but-unmarked Escape would discard a search query or close a panel while the user was only dismissing a candidate window. Before this change that case was a silent no-op. The trade is still the right one — the drift outage is concrete and reproducible, this case is hypothetical — but it trades a no-op for a possible wrong action, not a free win. #11927's recorder settles it: one macOS or Windows recording of Escape during a candidate window turns this from derived reasoning into evidence.This is the rule
xterm-bypass-policy.tsalready applies in the terminal, where Escape is deliberately absent fromTERMINAL_IME_OWNED_KEYSfor exactly this reason. Before this change the two disagreed about the same keystroke depending on which pane had focus. Fixing it in the predicate rather than at the call sites is what keeps them in agreement — patching eleven handlers would have re-created the scatter this PR exists to remove.Recovery was already bounded rather than permanent, since the target revalidation above clears the flag on the next focus change. The failure was "Escape and Enter silently do nothing until you click away and back," with nothing telling the user that is the fix.
Trace harness and provenance
ime-composition-trace.test-fixtures.tsreplays an event sequence against a real input element, stamping each event's observed buffer state in before dispatching it, so the code under test sees byte-for-byte what a browser produced.Each trace declares its
provenance:recorded— captured from a real engine, authoritative.derived— reconstructed from a documented event ordering. Pins current behavior, but cannot prove the ordering is what the engine really emits.Six traces: five
derived, onerecorded. Read theprovenancefield, not this paragraph — but the shape of the set is worth stating up front, because the five derived ones are not all derived the same way.IBUS_HANGUL_TERMINAL_JAMO_COMMIT_TRACErecordedtests/e2e/terminal-ime-boundary-probe.tson ubuntu-22.04 (run 30691057123)IBUS_HANGUL_RETAINED_COMMIT_TRACEderivedtests/e2e/terminal-ime-observed-event-sequences.tsreplays in CIIBUS_HANGUL_MIXED_LATIN_TRACEderivedTELEX_BACKSPACE_MID_COMPOSITION_TRACEderivedCANDIDATE_ARROW_NAVIGATION_TRACEderivedCANDIDATE_ESCAPE_DISMISSAL_TRACEderivedime-composition-keyboard-event.tsTwo of the derived traces are transcriptions of sequences CI hand-dispatches rather than captures, with selection offsets reconstructed as a collapsed caret at end-of-buffer. The other three are reconstructed from a documented event ordering around a real reported bug — they pin the behavior that was fixed, but nothing in them proves the engine emits that exact ordering.
Promotion is not blocked on someone's physical hardware, and an earlier revision of this paragraph wrongly said it was. The hangul trace above was recorded by CI, on a runner, from a real engine — that is what the IBus engine matrix higher in this stack exists to make routine, and
CANDIDATE_ESCAPE_DISMISSAL_TRACEnamesconfig/scripts/record-ime-trace.mjsas its promotion path. What is genuinely still missing is coverage for engines the Linux matrix cannot host: macOS-native and Windows IMEs. Those need a human at the keyboard.The trace assertions compare an interpretation derived from event data against each trace's declared final state, per the AGENTS.md rule that committed text comes from ranges and event data, never from diffing two observations of a mutable buffer. An earlier revision asserted the textarea's final contents instead, which was vacuous: the harness stamps that state in itself, so the assertion held no matter what any listener did.
Three fields the harness could not previously carry:
isComposing: undefinedboolean | undefinedprecisely so a Safari trace can be told from a Chromium one. The replayer coalesced it tofalseon construction and the repair function declined to touch it, so the one distinction it exists to express could not be reproduced.repeatselectionDirectionThe first is the one worth flagging:
undefinedis a recorded value, not a missing one, and constructing anInputEventcoerces it. The replayer now defines the property explicitly, the same way it already patches the legacykeyCode.Screenshots
No visual change — this preserves existing behavior at every migrated call site and fixes the sites that had no guard.
Testing
pnpm lint— oxlint 0 warnings / 0 errorspnpm typecheckpnpm test— predicate + trace-replay suites passpnpm audit:code-quality:type-awarepnpm build— not runexpected true to be false) and pass with itcompositionenddata: the new assertions failed, the old one still passedexpected true to be false(Escape),expected false to be undefined(isComposing),expected false to be true(repeat),expected [ 'none' ] to deeply equal [ 'backward' ](selection direction)AI Review Report
A subagent audited the predicate against the behavior real engines produce rather than against what the spec implies. Four properties a correct composition guard needs, all reproduced here:
isComposing,229,'Process') rather thanisComposingalone.One deliberate design choice, now documented in the code: the
229/'Process'markers are unconditional, with no opt-out argument.xterm-bypass-policy.tslets a bare229keydown through on macOS/Linux, so the two look inconsistent — a review pass raised exactly that. The divergence is correct, but the original justification ("only the terminal needs it") named the wrong reason, and the comment now states the right one: the terminal needs the keystroke because xterm'sCompositionHelperreads the committed glyph off the helper textarea, whereas callers of this predicate receive committed text throughinput. A marked keydown carries nothing they could act on — itskeyis'Process'or'Unidentified', never the glyph — so suppressing it costs no input.The one call site that looked like a counterexample, the emulator screen keyboard, was checked and is not one: it forwards through an ASCII/named-key USB HID table, which returns
nullfor'Process'and drops the keystroke identically whether or not the guard fires. At one site suppressing is better than merely harmless — the address picker concatenatesevent.keyinto a typeahead prefix, which'Process'would have poisoned.Cross-platform: the predicate is explicitly the union of the macOS, Windows (
229), and Android ('Process') markers; no platform branch, because all three markers are safe to check everywhere.Security Audit
Notes
Base: #11894. The trace harness added here is the test substrate for #11896 and #11897.