Repository navigation
fix(macos): Quick message pill can be focused after chat closes - #1566
Conversation
Adds TRACE_BUBBLE output to overlay_request_focus and close_chat to diagnose the root cause of #1565. The scenario opens chat, closes it, then shows the pill and verifies via traces that the overlay cannot become key. Expected failure: after chat closes, app_active=true, has_key_window=false, and can_become_key=false, preventing the pill from accepting keyboard input. Co-authored-by: Oded Messer <odedmesser@gmail.com>
Root cause: overlay's canBecomeKeyWindow always returns NO. After chat calls activate_for_typing and makeKeyAndOrderFront, then closes, the app is active but has no key window. The pill's set_focus() fails because the overlay refuses to become key. Solution: Track allowed-to-become-key windows in a global HashSet. When requesting overlay focus, add the window, call set_focus(), then remove it. The flag is only consulted when deciding to make a window key, not when keeping it key. Implementation: - overlay_panel.rs: Add ALLOWED_KEY_WINDOWS, make canBecomeKeyWindow check this set, export allow_overlay_focus() to manage it - platform/macos/mod.rs: Export allow_overlay_focus - main.rs: Wrap set_focus() with allow_overlay_focus(true/false) calls Co-authored-by: Oded Messer <odedmesser@gmail.com>
dd81487 to
ff87f03
Compare
Rewrites scenario to type into the pill and verify the typed text appears in the draft trace, instead of asserting on internal traces. Uses shared wait-helpers.mac.sh with trigger-based waits (2-3s) that start from actual events instead of fixed sleeps. Co-authored-by: Oded Messer <odedmesser@gmail.com>
ff87f03 to
ef4584e
Compare
Co-authored-by: Oded Messer <odedmesser@gmail.com>
43c8313 to
cda2e20
Compare
- Wait for first frame line before reading sprite position - Wait for second 'bubble: quick' occurrence using wait_for_count - Click pill text field before typing (matches user steps) - Replace fixed sleep with event-based wait (bubble: none) - Add wait_for_count helper to wait-helpers.mac.sh Co-authored-by: Oded Messer <odedmesser@gmail.com>
The function was trying to call window.as_webview_window() which doesn't exist on tauri::Window. Since the overlay is always a WebviewWindow, change the command signature to take WebviewWindow directly, which Tauri will inject correctly. Co-authored-by: Oded Messer <odedmesser@gmail.com>
fb7df41 to
f61150c
Compare
|
"but the overlay is configured to refuse focus so that sprite clicks don't steal focus from your other apps" - why that is the case? I think it's debateable. but in any case, clicking the QM pill whenever it's visible should take focus. 100% always |
The refusal goes back to 323b7fa, "Add transparent overlay with alpha hit-testing" (towards #1). That was before the pill existed. The overlay spans the whole desktop, and the overlay was made to refuse key status so that clicking the sprite never interrupts typing in another app. Nothing else depends on it. Plan, now pushed at fc55f59: while the pill is open, the overlay accepts keyboard focus, so clicking the pill always takes the keyboard, whatever the Chat history and whichever app is in front. Once the pill closes, it goes back to refusing. A sprite click with no pill open still won't steal your typing. If you'd rather drop the refusal entirely, that's a one-line follow-up.
— Cursor agent (P. Coder), on @omesser's behalf. |
… sprite-click case
…er-chat-close-1098
…; Escape closes the pill (#1565)
…on or pill timer traces, one owner gate, one keep-typed body, walk_visible, leaner scenario
…held its change notice 3 s and the late press met a hover-opened pill
…beside any open ones, and closes only that tab (and the window if it opened Notepad)
…ts monitor and never touching it
…the given evidence dir on Windows, so a rerun keeps the earlier one
omesser
left a comment
There was a problem hiding this comment.
Soft Open
Tip: 2fbb939a
What changed
- Cuts from the last Architect review are in:
FocusAtoms, the activation and pill timer traces,spriteHovered, the rosterforgetand the scenario debugging are gone. The X11 and Windows filters now reuseatoms.rsandperch_candidate, and macOS reuseswalk_visible. - Windows leaf added:
chat-close-pill-type.win.ps1runs the same cases against Notepad. It types into its own uniquely named tab, closes only that tab on cleanup, logs any fullscreen app without touching it, and writes a fresh evidence folder per run. - Live runs: The body reports macOS PASS on all 11 checks and X11 PASS 3 of 3 at
d6711706. App code has not changed since then.
What is wrong
- Windows leaf polls
process.logevery 50 ms:Wait-Checkcaps eachWaitForChangedat 50 ms and then rereads the whole log, which grows fast withFIDGET_TRACE_FRAMES=1. That is the sleep-loop file polling that closed #1563. It also copiesWait-OnChangesfromwait-helpers.win.ps1instead of fixing the shared helper. - No passing Windows run: The only Windows run, at
d6711706, failed at sprite-click. enter, escape and click-away have never run on Windows, and Windows behavior changes in this PR.
Soft-FIX
- Event-driven Windows wait: Drop the 50 ms reread. If NTFS holds change notices for the open log, find a signal that fires on time instead of polling. If the shared
Wait-OnChangeshas the same gap, fix it there so every Windows leaf benefits. - Windows live run: Run
chat-close-pill-type.win.ps1 --goon DESKTOP-UQIE144 at the new tip and post a PASS on all four cases.
Verified: read the change since 473e3d47 and confirmed each earlier cut on the tip. Compared Wait-Check with Wait-OnChanges. The Windows unit tests and the leaf can't run on this Linux host.
— Cursor agent (Architect), on @omesser's behalf.
…ay's webview reports, not at the Shell's first frame
…auses; the overlay asks the Shell whether it still holds the keyboard
…ario leaf and verify tests move to their own PR Reverts b5d87c7 and the Windows remember_foreground/hand_back_keyboard, Candidate/next_in_front and the overlay_request_focus remember. Windows hand_back_keyboard is a no-op, as on main.
omesser
left a comment
There was a problem hiding this comment.
Soft+Hard — tip c81647b — Cleared
| Axis | Verdict |
|---|---|
| Soft | Pass |
| Spec | Pass |
| Hard | Pass |
| Total | Cleared |
Soft — Pass
- Coverage sentence: it now says the pill's JS tests and the macOS and X11 scenario runs cover the shared behavior, and that Windows CI builds and tests the Rust, including the hand-back that does nothing on Windows. That is accurate.
- Rest of the body: accurate. Windows native focus is unchanged from main, the hand-back and its scenario come in their own PR, and the intended Windows differences are listed (Escape closes the pill, a click away keeps its text, hover comes from the Shell's hit test).
Spec — Pass
- Carries over from 5557902818: there is no manual Windows check, by Oded's ruling, and Windows has no live scenario yet; one comes with the hand-back PR. The macOS run 134449, the X11 runs,
focus_return10/10 and the 8/10 uncommitted live runs stand as recorded there. Neither of the two failures blocks.
Hard — Pass
- Tip: still
c81647b, with only the body changed. - CI: all checks green.
— Cursor agent (P. Architect), on @omesser's behalf.
Starts from the #1566-era chat-close-pill-type.win.ps1 (a85979d), which finds our Notepad tab through UI Automation, saves with Ctrl+S before reading the doc, closes only its own tab (and the window only if it opened Notepad), and writes a fresh folder per run. Cut to the four cases main can pass: sprite click, hover-open then type "two", Escape, click into Notepad. Prints the pill-open SetForegroundWindow line. No sleeps: presses are held until Fidget traces click: down, and each word is one SendInput. Aims at the sprite's middle from the frame line and the overlay's sprite size. Self-check modes cover every waited-on trace line, the aim, the Notepad cleanup plan, the overlay gate and reruns; the scenario.rs tests from a85979d are restored alongside the new ones. Addresses #1577
Starts from the #1566-era chat-close-pill-type.win.ps1 (a85979d), which finds our Notepad tab through UI Automation, saves with Ctrl+S before reading the doc, closes only its own tab (and the window only if it opened Notepad), and writes a fresh folder per run. Cut to the four cases main can pass: sprite click, hover-open then type "two", Escape, click into Notepad. Prints the pill-open SetForegroundWindow line. No sleeps: presses are held until Fidget traces click: down, and each word is one SendInput. Aims at the sprite's middle from the frame line and the overlay's sprite size. Self-check modes cover every waited-on trace line, the aim, the Notepad cleanup plan, the overlay gate and reruns; the scenario.rs tests from a85979d are restored alongside the new ones. Addresses #1577
Addresses #1565
What
On macOS, once you had opened and closed Chat, the quick message pill would show up but wouldn't take typing. Now it takes typing every time it opens.
Windows keeps main's focus behavior in this PR; its hand-back moves to its own PR.
On Wayland, where typing goes after the pill closes is up to the compositor. Wayland doesn't let one app hand the keyboard to another app's window.
Why
On macOS the overlay never accepted the keyboard, so that clicking the sprite wouldn't steal it. After Chat closed, Fidget stayed in front with no window that could take keys, and typing went nowhere. Now an overlay accepts the keyboard only while one of its pills is open, and gives it back when that pill closes.
How to test
On a Mac, with TextEdit quit:
It checks Accessibility and Automation (TextEdit, System Events) first and stops with a message if either is missing. Each step gives up after 3 s. It covers 8 cases: a click on the sprite, the pill before Chat and after Chat, the pill with TextEdit in front, Enter, Escape, TextEdit quitting while the pill is open, and a click through the overlay.
macOS live run: PASS (all 11 checks) at d671170, run 134449.
Linux X11 live run at d671170: real Fidget (standing BMO, fixture Harness) on a private Xvfb display with xfwm4 and mousepad, driven by xdotool. PASS on each case: a sprite click leaves typing in the editor; the pill opens on hover and takes typing; Enter hands typing back to the editor; Escape hands it back; a click into the editor keeps the pill's "nine" while "ten" lands at the click. 3 of 3 runs passed, about 9 s each. Not covered on X11: Chat open and close, and the editor quitting while the pill is open. The Xvfb tests in
focus_return.rsalso pass.Windows: the native focus code is unchanged from main. Nothing hands the foreground window back when the pill closes. The Windows hand-back (remember and restore the foreground window, step aside,
overlay_holds_keyboard) moves to its own PR, and a Windows scenario script comes with it.The shared pill behavior applies on every OS, Windows included: Escape closes the pill, clicking away keeps its text, and resting the cursor on the sprite opens it through the Shell's hit test. The pill's JS tests and the macOS and X11 scenario runs above cover it. Windows CI builds and tests the Rust, including the hand-back, which does nothing on Windows.
— Cursor agent (P. Coder), on @omesser's behalf.