Skip to content

fix(app): reset stale modifiers on focus loss, drop duplicate focus restore#27

Merged
simota merged 1 commit into
mainfrom
fix/tab-close-regressions
Jul 17, 2026
Merged

fix(app): reset stale modifiers on focus loss, drop duplicate focus restore#27
simota merged 1 commit into
mainfrom
fix/tab-close-regressions

Conversation

@simota

@simota simota commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

#26(タブ閉じ後入力不能の修正)の回帰2件を修正。

  • 勝手にSearchモード: ⌘Wでのタブ閉じ時、Cmd釈放のflagsChangedが破棄済みビューに落ちてwinitに届かず、保持modifiersがSUPERのまま固着。次の素のfcmd+fと解決されSearch(Find)が開いていた。Focused(false)RestoreFocusでmodifiersをリセット(次の実押下でwinitが再送するため副作用なし)。
  • 時々クラッシュ: #26がFocused(true)に足したbelt-and-suspendersブロックが、全フォーカス獲得時(teardown中含む)にwinitハンドラ内で同期makeFirstResponder:+IMEトグルを実行し再入/teardown競合の窓を作っていた。除去し、フォーカス復元は遅延RestoreFocus経路(firstResponder+IME再アーム維持)に一本化。※クラッシュはバックトレース未取得のため仮説ベースの対処。

Test plan

  • cargo build / cargo clippy --workspace クリーン、cargo test -p noa-app: 967 passed(新規回帰テスト plain_f_with_reset_modifiers_does_not_resolve_to_find 含む)
  • 実機smoke: ⌘T→⌘W→素のf打鍵でSearchが開かないこと・入力が効くこと・タブ開閉連打でクラッシュしないこと

…estore

Two regressions from the native-tab-close focus fix (#26):

Search opening uninvited: closing a tab with cmd+w destroys the view
before the Cmd-release flagsChanged reaches winit, so the app's stored
modifiers stay stuck holding SUPER and the next plain keypress on the
surviving tab resolves as a chord (plain f -> cmd+f -> Search/Find).
Reset stored modifiers on Focused(false) and in the RestoreFocus
handler; winit re-sends ModifiersChanged on the next real modifier
press, so nothing is lost. Regression test locks the resolution
semantics the reset relies on.

Intermittent crash on the same gesture: the belt-and-suspenders block
added to Focused(true) ran makeFirstResponder: plus an IME off/on
toggle synchronously inside the winit handler on every focus gain,
including mid-teardown ones — a re-entrancy/teardown race. Remove it;
focus restore after tab close lives solely on the deferred
RestoreFocus path, which keeps the first-responder + IME re-arm.

@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: 57361f4662

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

// chord (a plain `f` → `cmd+f` → Search/Find). Clear on focus
// loss; winit re-sends `ModifiersChanged` on the next real
// modifier press, so nothing is lost.
self.modifiers = winit::keyboard::ModifiersState::empty();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve held modifiers across internal focus switches

The code just below notes that macOS can deliver the outgoing tab/window's Focused(false) after the incoming one is already focused; clearing the global self.modifiers in that outgoing event drops still-held Cmd/Shift. If a user holds ⌘⇧ and presses ] repeatedly to cycle tabs, the first switch can succeed but the next KeyboardInput is resolved with empty modifiers (the state is only restored by a later modifier change), so the shortcut is ignored or sent to the PTY. Gate this reset to actual app deactivation or another stale-modifier recovery path rather than every focus loss.

Useful? React with 👍 / 👎.

@simota
simota merged commit 8f8588e into main Jul 17, 2026
1 check passed
@simota
simota deleted the fix/tab-close-regressions branch July 17, 2026 11:51
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