Repository navigation
fix(ibus): hand off preedit before native completion - #30
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 933e92e209
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🔵 Needs a closer look
It changes an input-method key-dispatch hot path whose motivating fix relies on real-client GUI behavior (the PR notes the private KWrite completion run is still pending), which warrants human verification beyond the unit tests.
1 open issue
What changed in this PR
This PR fixes a conflict between SmartKey's live IBus preedit and a native editor's Ctrl+Space completion (observed in KWrite). Previously the adapter forwarded Ctrl+Space while still holding its typed prefix and ghost, so native completion competed with the IME and could drop the composition. The change intercepts Ctrl+Space in do_process_key_event and hands off the typed prefix via the existing delivery-only flush_preedit_for_layout() API before forwarding the shortcut — without treating the handoff as a word boundary or training on the unfinished word.
Changes:
- On
Ctrl+Space(matching the actual raw/keyval dispatch route, allowing incidental Caps/NumLock), flush the preedit for delivery, retire language choice / active prediction / surrounding-text cache / O1 attribution, then returnFalseto forward the original shortcut; older cores lacking the optional API keep their existing route. - Hoisted
has_keycode_apiso both the newis_spaceroute selection and the existing keycode dispatch share one computation. - Added 25 native-adapter contract tests covering raw/keyval identity, client-owned text, repeated handoff, release/modifier boundaries, sensitive input, language choices, and fallback-API behavior.
| File | Description |
|---|---|
| ibus/smartkey_engine.py | Adds the Ctrl+Space preedit-handoff branch and hoists has_keycode_api; the core behavioral change. |
| ibus/test_native_key_contract.py | Adds native-adapter tests validating handoff routing, non-learning, guard interaction, and fallback behavior. |
Review effort: Balanced
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae275fc7b1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 222b8d8ac7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 454de855e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 860248a067
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
smartkey/ibus/smartkey_engine.py
Lines 2317 to 2318 in fd97ea9
When the native popup is active and the raw-key path delivers another refinement letter, the core emits a CommitText delta, but this normal tracing call does not pass delivery_only=True. _trace_key_result therefore records the typed refinement as an accept event even though no SmartKey prediction was accepted. The handoff itself now avoids that false event, but subsequent native-owned delivery commits still corrupt the diagnostic acceptance stream; use the already captured native_owned_before state to mark these calls as delivery-only.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Native completion handoff and refinement
This change delivers SmartKey’s typed prefix once before forwarding Ctrl+Space to a native editor. The editor can then filter and accept its own completion while SmartKey retains only the logical prefix needed for raw-letter refinement. Native completion delivery does not train an unfinished word or count as a SmartKey prediction acceptance.
The final head is
849bc3c40963cab396c53a839f6d16af5d3e1390. Follow-up fixes cover fresh surrounding-text callback epochs, identifier prefixes, native navigation including PageUp/PageDown, unknown native acceptance and O1 attribution, sentence-boundary hints, and delivery-only diagnostic traces. Actual later caret/context changes still retire stale ownership.Validation on the exact final source/artifact:
Hide → Commit("todo") → Forward, then empty Core state and inactive preedit. The intermediateтодоhypothesis is allowed by the existing tested boundary-normalization contract.The physical-refocus premise is explicit. Earlier no-refocus trials remain incomplete: the expected ordinary boundary callbacks were absent and Save-button focus was observed. Those trials are preserved and do not establish ordinary continuation. The original reported progressive-duplication string has not been independently reproduced. This run establishes the bounded synthetic workflow and does not reconstruct the user’s historical keystream.
Runtime delivery completed on 2026-10-17: the exact accepted wheel was installed before canonical master was fast-forwarded to
849bc3c. One normal activation completed, and the new Factory was observed mapping the exact accepted native module. The actual post-activation personal profile was byte-identical to the fresh saved pre-install profile; both strict S/default-save/C comparisons passed. The existing IBus, Chrome and KWrite process identities were preserved. This records runtime delivery and profile preservation; the historical progressive-duplication report remains unreproduced and open.