Skip to content

fix(ibus): hand off preedit before native completion - #30

Merged
RMANOV merged 10 commits into
masterfrom
fix/native-completion-handoff
Oct 17, 2026
Merged

RMANOV merged 10 commits into
masterfrom
fix/native-completion-handoff

Conversation

@RMANOV

@RMANOV RMANOV commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

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:

  • Native adapter/package: 280 passed; ordinary Python: 776 passed, 2 existing skips.
  • Full Core: 968 passed, 1 existing ignored, with all 76 Rust/Cargo files proved byte-identical to the final clean source. Formatting and Core Clippy with warnings denied pass.
  • Exact-head CI: 7/7 successful, run 39042819707, attempt 1.
  • Real private Wayland/KWrite run: prefix handoff, raw Bulgarian refinement, native filtering and native LONG insertion, followed by an explicitly observed physical click back into the editor, fresh ordinary input and exact saved bytes. The terminal Space produced exactly one callback-bound 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.

@RMANOV
RMANOV marked this pull request as ready for review October 17, 2026 11:56
Copilot AI balanced review requested due to automatic review settings October 17, 2026 11:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T14:58:53.190158Z 849bc3c New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ibus/smartkey_engine.py Resolved
Comment thread ibus/smartkey_engine.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 return False to forward the original shortcut; older cores lacking the optional API keep their existing route.
  • Hoisted has_keycode_api so both the new is_space route 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

Comment thread ibus/smartkey_engine.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ibus/smartkey_engine.py Resolved
Comment thread crates/smartkey-core/src/input.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/smartkey-core/src/master_loop.rs Resolved
Comment thread crates/smartkey-core/src/input.rs Resolved
Comment thread crates/smartkey-core/src/input.rs Resolved
Comment thread ibus/smartkey_engine.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/smartkey-core/src/input.rs Resolved
Comment thread crates/smartkey-core/src/input.rs Resolved
Comment thread crates/smartkey-core/src/master_loop.rs Resolved
Comment thread ibus/smartkey_engine.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ibus/smartkey_engine.py Resolved
Comment thread crates/smartkey-core/src/input.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

if tracing:
self._trace_key_result(keyval, key_release, actions, result)

P2 Badge Suppress acceptance traces for native refinement commits

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".

Comment thread crates/smartkey-core/src/input.rs Resolved
@RMANOV
RMANOV merged commit 849bc3c into master Oct 17, 2026
7 checks passed
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.

2 participants