Fix main window stranded on unreachable Space in menu-bar-only mode#647
Fix main window stranded on unreachable Space in menu-bar-only mode#647shreeraman96 wants to merge 2 commits into
Conversation
Reveal the main window with .moveToActiveSpace so it is collected onto the user's current Space instead of being ordered front on a Space the user cannot reach (no Dock icon or Cmd+Tab in accessory mode). Covers launch reveal, reopen, and menu-bar Settings paths. Fixes #646
|
The PR Policy check is blocking this PR because required template information is missing. Please update the PR description with:
Visual files detected:
Screenshots or video are required for UI, UX, settings, onboarding, overlay, menu bar, or visual behavior changes. If this PR has no visual changes, check the no-visual-change box in the template. If this remains incomplete for 48 hours after opening, the PR may be closed. |
Greptile SummaryThis PR fixes a bug where the main window can be stranded on an unreachable Mission Control Space in menu-bar-only (accessory) mode, leaving the app effectively windowless with no Dock icon or Cmd+Tab to recover it.
|
| import AppKit | ||
| @testable import FluidVoice_Debug | ||
| import XCTest | ||
|
|
||
| final class WindowRevealTests: XCTestCase { |
There was a problem hiding this comment.
Test lives in the wrong target.
WindowRevealTests is a focused unit test for window collection-behavior; it belongs in a general unit-test target, not FluidDictationIntegrationTests, which is set up for dictation end-to-end tests. Placing it here means the window regression guard only runs when the heavier integration suite runs, and it makes the test target's scope harder to reason about over time.
Prompt To Fix With AI
This is a comment left during a code review.
Path: Tests/FluidDictationIntegrationTests/WindowRevealTests.swift
Line: 1-5
Comment:
**Test lives in the wrong target.** `WindowRevealTests` is a focused unit test for window collection-behavior; it belongs in a general unit-test target, not `FluidDictationIntegrationTests`, which is set up for dictation end-to-end tests. Placing it here means the window regression guard only runs when the heavier integration suite runs, and it makes the test target's scope harder to reason about over time.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
FluidDictationIntegrationTests is currently the repo's only test target — focused unit tests already live there (e.g. HotkeyShortcutTests, LLMClientRequestBodyTests). Happy to move this when a dedicated unit-test target exists, but adding one is out of scope for this fix.
Addresses review: permanently inserting the flag would make every future direct ordering call also collect the window to the active Space. The behavior is now restored on the next runloop pass; the regression test asserts both the reveal-time flag and the restoration.
Description
The window server can leave the main window bound to another Space — including a defunct one from a previous session — where
orderFrontRegardless()"succeeds" invisibly. In menu-bar-only mode (Hide from Dock & App Switcher) the user has no Dock icon or Cmd+Tab to recover it, so the app appears windowless: launch shows nothing, and menu bar → Settings... does nothing, while the log claims "Brought main window to front".Fix: add
NSWindow.revealOnActiveSpace()which inserts.moveToActiveSpaceinto the window's collection behavior before ordering front, so every reveal collects the window onto the Space the user is currently viewing. Used in both reveal paths:AppDelegate.bringMainWindowToFrontIfPresent()(launch/reopen/notification) andMenuBarManager.bringToFront(_:)(menu bar → Settings/openMainWindow).Type of Change
Related Issue or Discussion
Closes #646
Testing
swiftlint --strict --config .swiftlint.yml Sourcesswiftformat --config .swiftformat SourcesFluidDictationIntegrationTests/WindowRevealTests(new regression test) — passedLive verification: with the app in accessory mode, stranded the main window on another Space, then clicked menu bar → Settings... — the window is collected onto the current Space. Reproduced the pre-fix failure the same way.
Screenshots / Video
Notes
No pixel-level UI changes — the fix changes where the window appears (always the user's active Space). A screenshot cannot capture Space collection; the Testing section describes the live repro/verification instead. Side benefit: opening from the menu bar now brings the window to the user's current Space rather than relying on macOS to switch Spaces.