Repository navigation
Conversation
4dd0475 to
a801aef
Compare
a801aef to
2765621
Compare
0d0667c to
35c4e37
Compare
35c4e37 to
8ee0087
Compare
8ee0087 to
85930b3
Compare
85930b3 to
7e56fff
Compare
5e91f4b to
ca2ef24
Compare
CDP-dispatched keystrokes bypass the OS input-method layer, so no amount of page.keyboard.type() produces a real composition. The Linux matrix drives ibus through X11, but there is no macOS or Windows IME CI, and on those platforms a human typing into a page is the only way to get a trace that can honestly be labelled recorded. pnpm ime:record serves a localhost page that captures the same field set as tests/e2e/terminal-ime-boundary-probe.ts — including the selection offsets at each event, which are what distinguish a recorded trace from a reconstructed one — and writes it in the shape the fixture loader already consumes. Nothing leaves the machine. The engine name and the description of what the human typed are left as TODOs in the output, because the page cannot observe either. Co-authored-by: Orca <[email protected]>
The recorder captured isComposing faithfully and then lost it at the POST: JSON.stringify omits an undefined value, so the written trace had no such key at all. null carries it instead. Adds repeat and selectionDirection, and a contract test so a field the recorder learns about cannot again go somewhere the schema cannot hold it. Co-authored-by: Orca <[email protected]>
ca2ef24 to
eeba5e6
Compare
|
Leaving this open — not superseded. #13128 (17b3dff) removed the first-party composition layer, but a trace recorder is orthogonal to which layer owns composition, and If anything this got more valuable, not less. The recurring lesson across this whole stack was that hand-written event sequences encode what we assume an IME does, and real ones disagree — a CJK source rewrites Needs a rebase onto the new baseline. Worth carrying two rules the recorder should enforce, both learned the hard way: report keys-requested vs keys-inserted so a silent no-op cannot pass as a null result, and match controls by column, not character count — Hangul is two cells per syllable. |
Summary
Adds
pnpm ime:record— a localhost page that captures a real IME composition trace from your own machine and your own input method, in the exact JSON shape the fixture loader already consumes.This exists because of a hard limit: CDP-dispatched keystrokes bypass the OS input-method layer, so no amount of
page.keyboard.type()produces a realcompositionstart→compositionendpair. The Linux matrix in #11898 gets around this by driving ibus through X11 withxdotool, which works — but there is no macOS or Windows IME CI, and there is unlikely to be one soon. On those platforms a human typing into a page is the only way to get a trace that can honestly be labelledrecordedrather thanderived.The page records the same field set as
tests/e2e/terminal-ime-boundary-probe.ts, including the target'svalue,selectionStartandselectionEndat each event. Those offsets are the whole point: they are what distinguishes a recorded trace from a reconstructed one. A real engine sendscompositionupdatewith the preedit character selected (selectionStart: 0, selectionEnd: 1) so it can replace it, and no hand-written fixture guesses that.isComposingis stored as the engine reported it and is deliberately not coerced — Safari reportsundefinedrather thanfalse, and the trace type models that distinction.An earlier revision of this PR made that claim while not delivering it. The recorder did read
event.isComposinguncoerced, but the trace is POSTed withJSON.stringify, which omits undefined-valued keys outright — so the written file had noisComposingkey at all, and the bit was gone before the payload left the browser. It is now carried asnull, which JSON can express, and transcribed back toundefinedin the fixture. The replayer half of the same round trip is fixed in #11895.Two more fields the page now captures, both added because a trace recorded without them cannot reproduce the quirk it was recorded for:
repeat— the accent panel a macOS press-and-hold opens is recognisable by nothing else. Since macOS press-and-hold is the single quirk most in need of a hand-recorded trace, a recorder that flattened it would have undercut the PR's own purpose.selectionDirection— without it no trace can express a backward selection, so a preedit replacement range is only ever representable as a collapsed caret.Two fields are emitted as explicit
TODOs, because the page genuinely cannot observe them: the input method's name, and a description of what the human typed.Everything is served from
127.0.0.1and written totest-results/ime-recordings/(already gitignored). Nothing is uploaded.Screenshots
Terminal-only; the recorder page is a local dev tool, not app UI.
Testing
pnpm lint— oxlint cleanpnpm typecheckpnpm test—record-ime-trace.test.mjs(new) holds the recorder and the fixture schema in lockstep: it fails if the page starts capturing a field the schema cannot express, which is exactly the drift that produced theisComposingbug abovepnpm build— not runnode --checkon the module does not validate it; extracted and syntax-checked separatelyStated plainly: the recorder's browser-side
record()runs in a page string and is not executed by any test. The contract test checks which fields it captures, not that a real browser hands them over correctly — only an actual recording session does that, which is the manual step this tool exists for.AI Review Report
The captured schema is intentionally identical to the CI probe's, so traces from either source deserialize through one loader. Its shape is what faithful replay requires: environment + initial state + event list + final state, with per-event observed buffer state, and
isComposingtypedboolean | undefinedso Safari reproduces faithfully.Cross-platform: pure Node
httppluspath.join; no shell-out, so noopen/xdg-open/startdivergence. The URL is printed rather than auto-opened for that reason. Platform and browser are inferred from the user agent, with WebKit and Gecko checked before Chromium because Electron reports a Chrome token too.Security Audit
127.0.0.1only, on a port overridable viaORCA_IME_RECORDER_PORT. No outbound requests.[a-z0-9-]before being used as a filename, so a crafted name cannot traverse out of the output directory.test-results/, which is gitignored. Note the recordedvaluefields contain whatever the operator typed — review a trace before committing it as a fixture.Notes
Top of stack #11899, on #11898. Companion to the ibus matrix rather than a replacement: CI covers hangul/libpinyin/anthy/unikey on Linux, this covers everything else.