Repository navigation
Fix selected language choice after KWrite preedit echoes - #31
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.
🔵 Needs a closer look
The fix targets subtle input-method revision-leasing behavior whose real-world correctness depends on KWrite/Wayland client echo semantics that the PR itself notes are still pending GUI verification.
No open issues 🎉
What changed in this PR
This PR fixes a user-facing bug in the IBus adapter's whole-word language-choice feature. On KWrite/Wayland, when the client echoes its visible preedit back into its surrounding-text report, Core invalidates the previously displayed language-choice revision, but the adapter kept highlighting the now-stale cached offer. As a result, selecting a row (e.g. top → Down to pick топ) and pressing Tab hid the table without committing the chosen reading. The fix makes an explicit Up/Down arrow re-read the current Core offer (rebinding to its live revision) before stepping the selection, so a subsequently selected Tab accepts a valid lease.
Changes:
- In
_language_choice_key, an Up/Down arrow now calls_refresh_language_choice()to rebind the cached offer to the current Core revision before stepping, and consumes the key (returnsTrue) if the offer was invalidated. - Adds native adapter tests covering Down/Up/Down selection indices, single commit, unchanged preedit/profile during arrows, and rejection of stale-after-selection Tab.
| File | Description |
|---|---|
| ibus/smartkey_engine.py | Arrow branch refreshes the Core language-choice offer before stepping selection, so a fresh arrow binds the live revision while selected Tab keeps its original lease. |
| ibus/test_native_language_choice.py | New native adapter tests simulating the KWrite preedit echo, asserting arrow selection indices, single commit, unchanged preedit/learned state, and stale-Tab rejection. |
Review effort: Balanced
When KWrite echoes visible preedit into its surrounding-text report, Core correctly invalidates the previously displayed language-choice revision. The IBus adapter could still highlight that cached offer; pressing Tab then hid the table without committing the selected word. In the actual private KWrite/Wayland reproduction,
top→ Down visibly selectedтоп, but Tab lefttopcomposing.An explicit Up/Down now reads the current Core offer before selecting a row. Tab continues to accept only the selected revision. Changes after selection still invalidate acceptance; no Core revision rule or automatic language switching changes.
Validation:
849bc3cwith the missingтопcommit, then passes with the adapter change.The audited native module is reused from clean
849bc3cfor these isolated Python-adapter checks. Reviewed adapter source is clean commit8ff112827c5308d3817bd38e2b92af284cb2097c. Exact-head CI run 39056416038 passed all seven jobs. Independent actual private KWrite/Wayland plus stock IBus panel verification passed for bothtop/топanddraftyt/драфтът: default Space preserved Latin, Down only highlighted, and Tab committed the selected alternative once and retired composition. Canonicaltodoand exact saved bytes also passed. Conditional physical replay in the declared Bulgarian context and copied profile producedтърси в листовете todo неделя сутрин. Host runtime delivery is pending. The original progressive duplicate episode remains unverified.