Skip to content

test(e2e): run the native IBus E2E suite across four input engines - #11898

Draft
nwparker wants to merge 5 commits into
nwparker/ime-key-event-policyfrom
nwparker/ime-ci-matrix
Draft

nwparker wants to merge 5 commits into
nwparker/ime-key-event-policyfrom
nwparker/ime-ci-matrix

Conversation

@nwparker

@nwparker nwparker commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Generalizes the native IBus E2E suite from one hardcoded engine to a four-engine matrix, so the terminal IME path is exercised against genuinely different input methods rather than only Korean.

Engine Language Input style being covered
ibus-hangul Korean Jamo composition, no candidate window
ibus-libpinyin Chinese Candidate window + numeric selection
ibus-anthy Japanese Multi-segment bunsetsu conversion
ibus-unikey Vietnamese Telex diacritic composition

These are exactly the four shapes the fixes in this stack reason about — #11896's idle ceiling exists because of anthy's multi-segment conversion, and the candidate-key guards exist because of libpinyin.

  • terminal-ibus-engine-profiles.mjs holds per-engine session config (GSettings schema, apt package).
  • run-terminal-ibus-engine-e2e.mjs (renamed from the hangul-specific runner) is parameterized by --engine=.
  • terminal-ibus-engine-input-profiles.ts holds the keystroke scripts and expected text.
  • The workflow runs one matrix leg per engine with fail-fast: false, and uploads evidence under a per-engine artifact name.

Status of the expectations

All four legs are green and all four assert hard. Run 30732014605 on the head of this branch: hangul, libpinyin, anthy, unikey, every one passing both the structural oracle and the exact committed text.

Getting there took three findings, each written up in its own section below, because they are the substance of this PR rather than incidental fixes:

  1. Three of the four engines never selected at all — a silent non-zero exit from the ibus CLI, not a fault in this suite. Fixed by verifying selection with a read-back.
  2. libpinyin and anthy were transcribed rather than observed; both were reproduced independently and promoted.
  3. unikey produced a genuine ordering defect, in the keystroke script rather than in the app. Fixed and now verified.

The two-tier oracle stays in place for engines added later:

const assertExpectedText = engine.expectationsVerified ? expect : expect.soft

A new engine lands with expectationsVerified: false, asserts softly for one observational run so a distro dictionary difference reports the real text instead of a bare failure, and is promoted once seen green. Nothing currently uses the soft tier.

The GSettings schema ids and key encodings are transcribed from each engine's upstream source for the version Ubuntu 22.04 ships — not read off an installed schema. A wrong id fails loudly in configureEngine rather than silently mis-configuring. This is stated in the file header rather than left implicit, and all four have now selected and configured successfully in CI.

fail-fast: false matters independently: one engine's dictionary drifting must not mask a real regression in another.

Screenshots

No visual change — CI only.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — 9 passing contract tests in terminal-ime-e2e-workflow.test.mjs, including a cross-file check that the engine ids in the workflow, the session profiles, and the input profiles all agree (they are joined only by that id at runtime, so a rename is otherwise invisible until CI)
  • pnpm build — not run
  • Added or updated high-quality tests that would catch regressions

Not run locally: the native IBus suite itself, which requires Linux + X11 + IBus. It runs nightly and on manual dispatch.

AI Review Report

The subagent that first drafted the engine profiles overclaimed their provenance, stating the schema ids had been read from each engine's installed GSettings schema. They had not — no IBus sources were present locally. I verified this, and rewrote the file header to state the actual provenance and mark the entries unverified. Flagging it here because "CI config that looks verified but is not" is the kind of thing that quietly rots.

Cross-platform: this suite is Linux/X11-specific by nature (IBus + xdotool). It is gated to ubuntu-22.04 and does not affect macOS or Windows contributors. Note that this stack does not add macOS or Windows IME CI — there is no free runner with a scriptable IME on either, so those platforms remain covered by unit tests and recorded traces (#11895) only.

Lifecycle hygiene is asserted by test: IBus processes are killed by process group, never by killall/pkill, and --replace is never passed — so the suite cannot disturb an IBus daemon it does not own.

Security Audit

  • Command execution: the runner spawns IBus, xfwm4, and xdotool with fixed argument lists; the only variable is the engine id, which is constrained to the four keys in the profile map. Process termination is scoped to the runner's own process group.
  • CI trigger surface: the pull_request trigger is removed (taking ci: run only changed E2E specs on pull requests #11834's change), so this runs only on schedule or manual dispatch — it cannot be triggered by an untrusted PR.
  • permissions: contents: read, and checkout uses persist-credentials: false.
  • No auth, secrets, path handling, or IPC changes.

Notes

Top of the stack. Base: #11897.

The follow-up this PR originally deferred — promoting the three soft-asserting engines after a green run — is done here rather than left open; the sections below are how.

Dispatch results, and the engine-selection fix

Dispatching the workflow (runs 30695084257, 30695394183, 30695559706) showed only one of the four legs selecting its engine:

The cause is in the ibus CLI, not in this suite. ibus engine <name> performs the D-Bus SetGlobalEngine call first and then invokes setxkbmap from the engine's declared XKB layout. When the engine declares no layout of its own, the CLI assembles an argument list with nothing in it and returns failure with nothing written to either stream — after the selection has already succeeded. Of the four engines only hangul declares a real layout (kr/kr104); libpinyin and anthy declare default and exit 1 silently, and unikey declares *, which makes setxkbmap itself fail and so at least produces a warning. Reproduced in a 22.04 container against all four engines: every one of them is correctly selected, and ibus engine with no argument reports the right engine in every case.

The fix is to stop gating on the exit status and verify by read-back instead — ibus engine with no argument was already telling the truth. Both call sites do this now: waitForEngine in the runner, and the equivalent selection in the spec, where execFileSync was throwing on the same non-zero status. The spec's existing expect(active).toBe(engine.ibusEngineName) assertion was already the correct oracle; it just never got the chance to run.

Regression risk to the green leg is nil: hangul still runs ibus engine hangul, which still exits 0 and still applies its layout. The read-back adds a condition it already satisfies on the first attempt.

Two other hypotheses were disproved rather than left open. Preloading engines has no effect — SetGlobalEngine never consults that setting, and run 30695559706 failed identically. A focused input context is not required either: the daemon falls back to a fake context it creates and focuses at startup, and all four engines select with nothing focused.

Two of the three unverified legs are now hard assertions

With selection fixed, the committed text for libpinyin and anthy was reproduced independently in a 22.04 container — same engine versions, same GSettings, same keystroke scripts, same IBUS_ENABLE_SYNC_MODE=1 — using hangul as a control, which reproduced 한abc글 codepoint for codepoint. Both matched the transcribed strings exactly (你好 = U+4F60 U+597D, ひらがな = U+3072 U+3089 U+304C U+306A), three repetitions per run, identical across runs. Both are promoted to expectationsVerified: true.

unikey stays soft, and the reason is recorded in the profile rather than left as an open question. Its characters are right, but the grouping per repetition is not: under IBUS_ENABLE_SYNC_MODE=1 the Return reaches the client before the engine commits the pending final word, so việt lands after the newline and migrates into the next repetition — tiếng việt\nviệttiếng \nviệttiếng \nviệt rather than three identical lines. Deterministic, and it disappears with sync mode off.

Unikey is the only one of the four where a single keypress must both trigger a commit and be forwarded: hangul's Return meets an already-empty preedit, anthy uses two Returns, libpinyin commits on space. So this is specific to that script, not a general property of the harness.

Worth flagging for reviewers: the per-repetition equality assertion in the spec is not gated on expectationsVerified, so if this ordering carries to the real path the Unikey leg fails there first, before any text comparison. Flipping its flag would only obscure which oracle failed. The reproduction used a GTK text sink rather than Electron/xterm.js, so whether it carries is genuinely untested — the first observational run answers that on the real path, which is the cheapest way to find out.

The observational run answered it: it carries

Run 30731720723, on the read-back fix. hangul, anthy and libpinyin all green — selection is fixed and the two promoted legs hold on the real path. unikey failed exactly where this section predicted: the structural equality oracle, before any text comparison.

The received bytes decode to the predicted shape. Expected every repetition to equal 7469e1babf6e67200a (tiếng + \n); the run interleaved 7669e1bb87747469e1babf6e67200a (việt + tiếng + \n) and 7669e1bb87740a (việt + \n). So the trailing word commits into the following line through Electron and xterm.js just as it did through the GTK sink.

No bytes are lost — việt + tiếng \n is everything that was typed, in order. Nothing in the app can force an engine to commit, and the deferred-newline hold in #11896 cannot help here: Telex keeps a word open indefinitely rather than ending the composition, so the hold expires on its idle ceiling and forwards the newline, which is the correct thing for it to do. The defect was in the scenario, which asked Return to flush a preedit this engine never flushes on Return.

Fixed by closing the word with a trailing space, so the commit trigger and the forwarded key are no longer the same keypress — the property this section already identified as unique to Unikey. Preferred over IBUS_ENABLE_SYNC_MODE=0 for that leg, which would have diverged its timing semantics from the other three and hidden the ordering rather than resolving it. expectedText becomes tiếng việt .

Run 30732014605, on that fix, is green on all four legs. unikey is promoted to expectationsVerified: true — the last soft assertion in the matrix, and the string was verified rather than assumed, since a soft assertion still fails the test. So the matrix now asserts exactly what it observes, on every engine.

Worth stating plainly what this leg did and did not find: no app defect. Every byte typed reached the PTY in order in both the failing and the passing run. What the failing run caught was a keystroke script that asked an engine to flush on a key it does not flush on. That is a real thing for this suite to catch — it is the difference between a harness that encodes one engine's habits and one that holds against four — but it should not be read as a terminal IME bug that this PR fixes.

@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from 34f18bf to 8944e39 Compare August 1, 2026 08:10
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from 8944e39 to f9f116d Compare August 1, 2026 08:12
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from f9f116d to f81ddb4 Compare August 1, 2026 08:20
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from f81ddb4 to ad5fb7f Compare August 1, 2026 08:25
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from ad5fb7f to eb37d04 Compare August 1, 2026 08:31
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from eb37d04 to f58597d Compare August 1, 2026 08:37
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from f58597d to eda7c92 Compare August 1, 2026 08:43
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from eda7c92 to ad092dc Compare August 1, 2026 08:50
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from ad092dc to 001e1f2 Compare August 1, 2026 09:17
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from 001e1f2 to e54213a Compare August 1, 2026 10:04
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch 2 times, most recently from 68f093b to beec252 Compare August 1, 2026 10:16
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch 3 times, most recently from 0bac0f8 to 2070f71 Compare August 1, 2026 23:44
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from 2070f71 to 8b3e205 Compare August 2, 2026 02:34
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from 8b3e205 to c3957db Compare August 2, 2026 03:16
@nwparker nwparker changed the title test(ime): run the native IBus E2E suite across four input engines test(e2e): run the native IBus E2E suite across four input engines Aug 2, 2026
@nwparker nwparker closed this Aug 2, 2026
@nwparker nwparker reopened this Aug 2, 2026
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from 7693b52 to 1c510af Compare August 2, 2026 03:51
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from 1c510af to f4300a1 Compare August 2, 2026 04:09
nwparker and others added 5 commits August 1, 2026 21:47
The native suite only ever exercised ibus-hangul, so every non-Korean IME
regression had to be caught by hand. Generalize the runner and spec over an
engine profile and add ibus-libpinyin (Pinyin), ibus-anthy (Romaji/kana) and
ibus-unikey (Telex) as matrix legs, covering the candidate-window, multi-commit
and rule-based rewriting shapes that Hangul alone does not produce.

Session config (apt package, GSettings, `ibus engine` name) and the keystroke
scripts live in separate files because one is loaded by the Node runner and the
other by the Playwright spec. They are joined only by the engine id, so the
contract test asserts the two sets agree and that the workflow matrix covers
exactly them.

Only the hangul expectations have been recorded from a real run. The other three
engines' committed glyphs are predicted from their input rules, so the exact-text
oracle is `expect.soft` for them while the structural oracle stays hard: every
repetition must produce identical bytes, in the engine's script, with xterm's
onData matching what the PTY received. That is the half that actually detects
the duplication and leaked-ASCII bugs, and it holds without knowing the glyphs.
A first green run turns each `expectationsVerified` to true.

fail-fast is off so a drifting libpinyin candidate cannot mask a hangul
regression, and evidence uploads are per-engine because upload-artifact rejects
a duplicate name.
Telex commits on a word boundary, not on Return, so the final syllable was
still composing when Return fired and committed into the following line.
No two repetitions agreed. The other three engines commit on Return.

Co-authored-by: Orca <[email protected]>
@nwparker
nwparker force-pushed the nwparker/ime-ci-matrix branch from 1587d5b to 7ce99a7 Compare August 2, 2026 04:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant