Skip to content

fix(windows): Hand typing back to the previous window when the quick message pill closes #1577

Closed

Description

@omesser

What

On Windows, when the quick message pill closes (Enter or Escape), typing should go back to the window you were in, the way it now does on macOS and X11 since #1566. If that window is gone, typing should go to the window in front.

Why

#1566 kept Windows on main's focus behavior and moved the Windows hand-back to its own PR. Today nothing hands the foreground window back on Windows when the pill closes.

Done when

  • On Windows, after Enter or Escape closes the pill, typing lands in the window that was in front before the pill opened.
  • If that window closed while the pill was open, typing goes to the window in front.
  • Clicking the pill still always takes the keyboard, and a sprite click with no pill open still leaves typing where it was.
  • A Windows scenario script on fidget's verification scripting system covers these cases, with fail-fast waits, and ships with the PR.

Follow-up from #1566. Related: #1572 (two displays).

— Cursor agent (P. Coder), on @omesser's behalf.

Activity

  1. added this to the V1 milestone on Oct 17, 2026
  2. added
    bugSomething isn't working
    windowsRun the Windows compile job on this pull request
    on Oct 17, 2026
  3. omesser commented on Oct 17, 2026

    @omesser
    OwnerAuthor

    #1587 merged (9c6a892). It's groundwork for this issue's scenario, not the hand-back itself.

    On main now

    • Start-FidgetPiped in scripts/scenarios/wait-helpers.win.ps1 launches Fidget with stdout and stderr piped, so each trace line wakes Wait-OnChanges as Fidget writes it, instead of waiting for Windows to flush process.log.
    • Every Windows scenario and both verify-anchor-*-win.ps1 scripts launch through it, and test-wait-helpers.ps1 checks the pipe wake under Windows PowerShell 5.1 in CI.

    Still open here (nothing below is done)

    • On Windows, Enter or Escape closing the pill hands typing back to the window that was in front, or to the window in front if that one closed.
    • Clicking the pill still always takes the keyboard, and a sprite click with no pill open leaves typing where it was.
    • The Windows scenario for these cases, built on the piped waits with 3 s caps, ships with that PR.
    • The migrated scenarios haven't run live on a Windows desktop with test(windows): Scenario waits wake on each line of Fidget's piped stderr #1587 yet. The first live run should confirm that debug Fidget sharing the scenario's console (no separate console window) doesn't change the focus results.

    Leaving this open.

    — Cursor agent (P. Coder), on @omesser's behalf.

  4. omesser commented on Oct 17, 2026

    @omesser
    OwnerAuthor

    #1583 merged (2f1819f). It adds the tracing and the Windows scenario this fix needs, not the hand-back itself.

    On main now

    • With FIDGET_TRACE_BUBBLE on, Windows Fidget prints an overlay: pill open SetForegroundWindow(...) line showing what the call returned and which window ended up in front, and each overlay prints overlay: <label> page loaded.
    • scripts/scenarios/chat-close-pill-type.win.ps1 checks four cases against a uniquely named Notepad file, with 3 s waits: a sprite click leaves typing in Notepad, hovering opens the pill and typing lands in it, Escape closes the pill, and clicking Notepad takes focus back from the pill.

    Still open here

    • On Windows, Enter or Escape closing the pill hands typing back to the window that was in front, or to the window in front if that one closed. The scenario checks that Escape closes the pill, not where typing goes afterward.
    • Scenario cases for Enter, typing after close, the closed-window fallback, and clicking the pill to take the keyboard ship with the fix.
    • The scenario hasn't run live on a Windows desktop yet. That first run is what shows whether Windows refuses the pill the foreground.
    • scripts/scenarios/README.md still says chat-close-pill-type has "no Windows leaf yet" in the X11 paragraph. The fix PR should drop that line.

    Leaving this open.

    — Cursor agent (P. Coder), on @omesser's behalf.

  5. omesser commented on Oct 18, 2026

    @omesser
    OwnerAuthor

    #1593 merged (83733db). It stops the hover-opened pill from closing itself on Windows, which this issue's hand-back needs first. It is not the hand-back itself.

    On main now

    • A window blur in the overlay's page no longer closes the pill by itself. The page asks the new overlay_has_foreground command (on Windows, whether GetForegroundWindow() is the overlay; false elsewhere), and only a false answer runs windowBlurred. So WebView2's blur right after SetForegroundWindow no longer closes an empty, just-opened pill.
    • The pill's field takes the caret only after overlay_request_focus returns.
    • Under FIDGET_TRACE_BUBBLE, each window blur prints window blur foreground=<true|false>.
    • chat-close-pill-type.win.ps1 judges case 2 from the moment the pill opened, and case 4 waits for window blur foreground=false and the pill's closed line within 3 s of the click. The script's Notepad placement next to fullscreen apps, bring-to-front fallback, one-character-at-a-time typing and FAIL-on-error line also landed here.
    • The live Windows run at 7d527055 passed in 7.4 s (sprite click, hover and type, Escape, click-away).

    Still open here

    • On Windows, Enter or Escape closing the pill hands typing back to the window that was in front, or to the window in front if that one closed.
    • Clicking the pill still always takes the keyboard, and a sprite click with no pill open leaves typing where it was.
    • Scenario cases for Enter, typing after close, the closed-window fallback, and clicking the pill.
    • scripts/scenarios/README.md still says chat-close-pill-type has "no Windows leaf yet".

    All of these are in #1590, which was stacked on #1593 and is next.

    Leaving this open.

    — Cursor agent (P. Coder), on @omesser's behalf.

  6. omesser commented on Oct 18, 2026

    @omesser
    OwnerAuthor

    #1590 merged (6e7e8f4). That's the Windows hand-back itself, so this is done.

    On main now

    • When an overlay's last pill closes with Enter or Escape, Windows platform::hand_back_keyboard restores the window that was in front at pill-open, if Fidget's overlay still holds the foreground and that window still exists.
    • If that window closed, it steps aside to the frontmost visible window (skipping Fidget's own, minimized and cloaked windows). If the user already moved on, nothing moves.
    • overlay_request_focus remembers the foreground window right before SetForegroundWindow, skipping Fidget's own windows. The decision is the shared pill_focus::hand_back, same as macOS and X11.
    • chat-close-pill-type.win.ps1 covers sprite click (typing stays put), Escape and Enter (Restore, typing lands in Notepad), the closed-window fallback (StepAside), click-away (Stay), and clicking the pill (it takes the keyboard, then Escape hands it back). Every wait is 3 s from its trigger.
    • Live pass on DESKTOP-UQIE144 at b92365ec, 12.5 s, all cases ok (output in feat(windows): Keyboard hand-back for quick message pill #1590's comments).

    Done when

    • Enter or Escape hands typing back to the window in front before the pill opened.
    • If that window closed, typing goes to the window in front.
    • Clicking the pill takes the keyboard; a sprite click with no pill leaves typing where it was.
    • The Windows scenario ships with the PR, with fail-fast waits.

    The stale "no Windows leaf yet" line in scripts/scenarios/README.md is still there; that's tracked in #1606.

    Closing as completed.

    — Cursor agent (P. Coder), on @omesser's behalf.

  7. moved this from Todo to Done in Fidgeton Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwindowsRun the Windows compile job on this pull request

    Projects

    • Status
      Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions