Skip to content

[Bug]: Cap remains active in macOS App Switcher (Cmd+Tab) after closing Main Window with 'X' #1859

Closed

Description

@dennyschroeder

Hi @richiemcilroy,

I noticed an issue with how Cap handles its window lifecycle and application state on macOS, which heavily disrupts the daily workflow when switching between applications.

The Bug:
Cap functions beautifully as a Menubar utility. However, when I click "Open Main Window" from the Menubar dropdown and then subsequently close this main control panel using the red "X" button in the top-left corner, the window disappears, but Cap remains trapped in an ambiguous state.

  • The Problem: Even though there is no active window on my screen, Cap still appears as an active application inside the macOS Dock and, more importantly, inside the macOS App Switcher (Cmd + Tab / Alt-Tab).
  • When I use Cmd + Tab to cycle through my open applications, I land on Cap, but it focuses nothing because the window was closed. I have to click into another app to make the Menubar focus shift away from Cap.

Proposed Solution:
Please modify the window-close behavior. When the Main Window is closed via the "X" button, the application should dynamically adjust its activation policy (NSApplication.ActivationPolicy) to act strictly as a background/menubar agent (.accessory). It should completely disappear from the Dock and the Cmd + Tab App Switcher until explicitly opened again from the Menubar.
Greetings, Denny

Activity

  1. linear commented on May 21, 2026

    @linear
  2. tembo commented on May 21, 2026

    @tembo

    Looking at the codebase, the dock/app-switcher visibility is managed in apps/desktop/src-tauri/src/permissions.rs via sync_macos_dock_visibility() (around lines 177-210). This function is called on WindowEvent::Destroyed in lib.rs:4833.

    The current behavior is intentional based on the hide_dock_icon setting in General Settings (general_settings.rs:132). When this setting is disabled (the default), Cap keeps the dock icon visible even when no windows are open. The activation policy only switches to .accessory when hide_dock_icon is enabled AND no dock-activating windows are visible.

    Related context:

    Key code locations:

    • permissions.rs: sync_macos_dock_visibility() controls the policy toggle
    • windows.rs:825-836: activates_dock() defines which windows trigger dock sync (Main, Editor, ScreenshotEditor, Settings, Upgrade, ModeSelect, Onboarding)
    • lib.rs:4660-4706: Main window destruction cleanup (doesn't explicitly call dock sync, relies on the generic handler at line 4833)

    The behavior you're describing would require either:

    1. Enabling the existing "Hide dock icon" setting in General Settings, or
    2. Changing the default behavior so Cap always acts as a menubar-only app when the Main Window is closed

    Given the recent dock-related fixes in PR #1849, any changes here should be careful not to reintroduce the duplicate dock icon race conditions that were just resolved.

  3. dennyschroeder commented on May 21, 2026

    @dennyschroeder
    Author
    Image
  4. ManthanNimodiya commented on May 21, 2026

    @ManthanNimodiya
    Contributor

    @dennyschroeder @richiemcilroy, a setting already exists for this, disabling "Always show dock icon" in Settings removes Cap from the dock and app switcher when no windows are open.
    The problem was the sync never fired when the main window was closed, so the setting had no effect, this PR #1865 fixes that. Thanks

  5. dennyschroeder commented on May 22, 2026

    @dennyschroeder
    Author

    Wow, that was incredibly fast! Thank you so much for the lightning-fast fix and for confirming the bug. Can't wait for the next release to test it out. You guys are awesome! 🚀🙌

  6. ManthanNimodiya commented on May 22, 2026

    @ManthanNimodiya
    Contributor

    @dennyschroeder , glad we could get to it quickly.
    Reports like yours make it much easier to track and fix, keep them coming

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions