Skip to content

fix(app): discard IME preedit and OS composition on window focus loss#3

Merged
simota merged 1 commit into
mainfrom
fix/ime-preedit-focus-loss
Jul 12, 2026
Merged

fix(app): discard IME preedit and OS composition on window focus loss#3
simota merged 1 commit into
mainfrom
fix/ime-preedit-focus-loss

Conversation

@simota

@simota simota commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the intermittent "screen looks frozen and keyboard input stops" report. Leaving an IME composition open across a window focus loss (e.g. Cmd+Tab mid-変換) left preedit non-empty, so keyboard_preedit_should_swallow_key swallowed every keypress after refocus until the IME happened to emit another event. Pane-level focus switches already guarded against this (focus_switch_plan); the window-level Focused(false) path did not.

On Focused(false), when a pane or modal preedit is active:

  • commit (clear) the focused pane's preedit and sync the auto-approve ime_preedit_active guard
  • drop the window's modal_preedit
  • toggle set_ime_allowed(false)/true so the AppKit-side marked text is discarded instead of replaying on refocus (same pattern as focus_pane)

Test plan

  • cargo test -p noa-app: 787 passed (new regression test ime_commit_preedit_clears_composition_without_encoding_it)
  • cargo clippy -p noa-app --all-targets: clean
  • Manual: start a Japanese composition in a pane, Cmd+Tab away before committing, Cmd+Tab back and type — keys register immediately; stale composition is not replayed or committed to the pty.

A live composition left open across a window focus loss (e.g. Cmd+Tab
mid-conversion) kept keyboard_preedit_should_swallow_key returning true
after refocus, silently swallowing every keypress until the IME happened
to emit another event. Pane-level focus switches already guarded against
this (focus_switch_plan), but the window-level Focused(false) path did
not.

On Focused(false), commit the focused pane's preedit, sync the
auto-approve ime_preedit_active guard, drop the window's modal preedit,
and toggle set_ime_allowed(false)/true so the AppKit-side marked text is
discarded instead of replaying on refocus.
@simota simota merged commit 68c8dd4 into main Jul 12, 2026
1 check passed
@simota simota deleted the fix/ime-preedit-focus-loss branch July 12, 2026 09:14
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