Cap icon indicating copy to clipboard operation
Cap copied to clipboard

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

Open dennyschroeder opened this issue 6 months ago • 6 comments

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

dennyschroeder avatar May 21 '26 16:05 dennyschroeder

CAP-720

linear[bot] avatar May 21 '26 16:05 linear[bot]

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:

  • #1843 reports that "Always show dock icon" isn't working as expected
  • #1844 reports duplicate dock icons with multiple monitors
  • PR #1849 (merged) recently fixed duplicate dock icon issues by removing redundant set_activation_policy(Accessory) calls

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.

tembo[bot] avatar May 21 '26 16:05 tembo[bot]

Image

dennyschroeder avatar May 21 '26 17:05 dennyschroeder

@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

ManthanNimodiya avatar May 21 '26 17:05 ManthanNimodiya

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! 🚀🙌

dennyschroeder avatar May 22 '26 07:05 dennyschroeder

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

ManthanNimodiya avatar May 22 '26 10:05 ManthanNimodiya