Skip to content

Recover inferred language choice and respect KDE Bulgarian layout - #29

Merged
RMANOV merged 5 commits into
masterfrom
codex/smartkey-phrase-20261017
Oct 17, 2026
Merged

RMANOV merged 5 commits into
masterfrom
codex/smartkey-phrase-20261017

Conversation

@RMANOV

@RMANOV RMANOV commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

An inferred language choice could remain locked after later typed characters lost all prefix support in that language and gained support in the other. Reconsider that one-sided case, update prediction evidence, and anchor the inferred lock to the supporting suffix. Backspace now also updates the detector from the surviving corpus-supported prefix before choosing a completion. Explicitly accepted choices and ambiguous/OOV choices retain their contracts; English terms such as todo remain valid in Bulgarian text.

KDE layout selection and IBus engine selection are independent. Selecting KDE Bulgarian while SmartKey remained active previously entered automatic physical-key interpretation. An optional read-only KDE observer now forwards explicit BG keyboard input and resumes automatic interpretation on return to US. It retires the owned typed prefix once, using a Core/PyO3 delivery-only API that does not learn an unfinished word as completed. Real focus-loss behavior is unchanged.

The observer survives initial metadata failures and recovers through owner/layout signals or an unverified-only focus retry. Layout-list changes invalidate indexed metadata before refresh, so a failed read cannot route a new index through an obsolete list. Ordinary verified layout signals use the cache. Both package and flat-module entrypoints load the helper; startup validates the mandatory native handoff API before loading personal data or processing keys. No engine/layout/global configuration change is introduced.

Validation for exact head 9025850e353d1516aa849fe47e59fda9c2aeb83d:

  • Actual RED/GREEN reproductions cover inferred recovery, detector retraction after Backspace, delayed KDE availability, list-reorder read failures, unfinished-word learning, package/flat imports, and missing/noncallable native APIs. Independent reviews cover the source changes.
  • Fresh clean isolated wheel: 196 native tests passed; full ordinary Python suite: 769 passed, two existing IBus-typelib skips. The six O1 startup fixture failures seen on the previous head were corrected by adding the required callable API to three test doubles; their behavior assertions remain intact and the fake method raises if startup calls it.
  • Full Core: 925 passed, one existing ignored test, from byte-identical Rust/Cargo sources (all 75 files checked against the actual 9c450d8 execution); formatting and exact CI Core Clippy pass. Actual private Wayland/KDE/IBus/KWrite: five checkpoints pass with all private processes reaped and host process identities unchanged. Exact-head GitHub CI: all seven jobs succeeded.

A failed refresh now withdraws observer verification while retaining the last manual routing value. The existing focus retry recovers without another KDE signal; successful validated metadata restores verification. Fourteen actual failing regressions now pass, including eight cases through the real adapter focus path. The complete related observer/adapter/startup group passes all 63 tests.

The separately reported duplicated-completion episode remains unresolved. Bounded private KWrite checks with a copied profile, matching completion settings, and queued Right/Tab input did not reproduce it. Source/package/private GUI evidence does not claim user-session acceptance.

@RMANOV
RMANOV marked this pull request as ready for review October 17, 2026 08:44
Copilot AI balanced review requested due to automatic review settings October 17, 2026 08:44
@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-17T09:45:39.469190Z 9025850 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: 28e90cfe18

ℹ️ 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/kde_layout.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 per-keystroke core scoring semantics and adds system DBus/IBus lifecycle integration whose real-session behavior cannot be fully validated automatically, warranting final human review.

No open issues 🎉

What changed in this PR

This PR fixes two independent defects in the SmartKey input method. First, an inferred language-prefix lock in the dual-buffer scorer could survive even after the growing word lost all corpus support on the locked side while the other language still had support, keeping the wrong script displayed/committed. The fix re-scores a non-explicitly-locked buffer only in that one-sided case, re-anchors the inferred lock to the new deciding prefix (so deleting it retracts the lock), and routes detector feeding through a new rescored flag. Second, selecting KDE's Bulgarian keyboard layout while SmartKey stayed active still applied automatic physical-key interpretation; the PR adds an optional, read-only KDE metadata observer so an explicit BG layout forwards ordinary keystrokes (retiring any owned prefix once) and returning to US resumes automatic interpretation.

Changes:

  • Dual-buffer: recover an inferred lock when the current winner loses prefix support but the other side retains it, and re-anchor inferred_lock_len on a post-lock flip.
  • Add ibus/kde_layout.py read-only KDE layout observer plus engine wiring (_init_kde_layout_observer, _manual_layout_for_key, do_destroy cleanup) that bypasses prediction/learning/tracing in manual BG mode.
  • Update existing Rust/Python tests to the corrected one-sided recovery output and add new Core integration and KDE/adapter tests.
File Description
crates/​smartkey-core/​src/​dual_buffer.rs Re-anchor inferred_lock_len to current length when a post-lock flip occurs, so deleting the new deciding prefix retracts the lock.
crates/​smartkey-core/​src/​input.rs Add one-sided unsupported_winner recovery in handle_dual_buffer_key; gate detector feed on a real rescored instead of !was_locked; update characterization tests.
crates/​smartkey-core/​src/​master_loop.rs Update terminal-alignment contract test to the recovered статия/статияx word.
crates/​smartkey-core/​tests/​language_phrase.rs New Core integration tests covering recovery, retraction/retype, explicit-accept survival, OOV ambiguity, and the todo case.
crates/​smartkey-core/​tests/​language_choice.rs Adjust fixture so EN keeps stat prefix support, isolating the one-sided boundary correction.
ibus/​kde_layout.py New optional read-only KDE DBus layout observer with metadata validation and subscription cleanup.
ibus/​smartkey_engine.py Wire the observer into init/focus/destroy and add manual-BG passthrough gating after the sensitive-field hard stop.
ibus/​test_kde_layout.py Contract tests for the observer (validation, owner loss, partial-subscription cleanup, bounded read-only DBus).
ibus/​test_manual_layout.py Adapter tests for manual-BG passthrough, resume-to-US, sensitive hard stop, and lifecycle.
ibus/​test_native_language_evidence.py Update expected suffix to the recovered статияx.

I verified the recovery gating preserves prior behavior for explicitly-locked and still-supported buffers (only adding a per-keystroke score_both on inferred-locked buffers), that the manual-mode block is correctly placed after the fail-closed sensitive-field stop, that spurious zero-key events are still consumed rather than triggering mode transitions, and that observer cleanup is idempotent and guarded against late callbacks. I did not find concrete defects to comment on.

Review effort: Balanced

@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: 7375340aa8

ℹ️ 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

@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: 1208d6df5f

ℹ️ 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/kde_layout.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: 9c450d890b

ℹ️ 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/kde_layout.py Resolved
@RMANOV
RMANOV merged commit 9025850 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