Skip to content

Fix tray reliability and macOS popup placement - #117

Open
demetrius-skypulse wants to merge 4 commits into
Lampese:mainfrom
demetrius-skypulse:agent/fix-macos-tray-reliability
Open

Fix tray reliability and macOS popup placement#117
demetrius-skypulse wants to merge 4 commits into
Lampese:mainfrom
demetrius-skypulse:agent/fix-macos-tray-reliability

Conversation

@demetrius-skypulse

@demetrius-skypulse demetrius-skypulse commented Jul 31, 2026

Copy link
Copy Markdown

Related to #95.

Summary

Fix cross-platform tray-menu lifecycle failures plus macOS-specific popup presentation failures:

  • keep one native tray menu attached for the application lifetime and update its account rows in place
  • avoid replacing the native menu during periodic account and usage refreshes
  • provide an explicit repair path when the current tray display mode is reselected
  • make the original React/Tauri tray popup visible in full-screen Spaces
  • keep the macOS popup below the camera housing/notch and within the target display
  • allow the close flow to quit completely instead of forcing the app to remain in the Dock or menu bar
  • hold the popup implementation on the verified Tauri 2.10 runtime because Tauri 2.11 regresses its macOS presentation

Root causes

Native tray menu becomes unresponsive

Usage and account updates rebuilt and reattached the complete native tray menu. This lifecycle was shared by Windows, macOS, and Linux. In the Windows backend used by the pinned tray-icon dependency, replacing a menu detaches the old menu subclass from the hidden tray window, attaches the new one, updates the popup-menu handle, and replaces the retained menu. Repeating that lifecycle is a plausible cause of #95's report that every command in the Windows menu, including Quit, becomes unresponsive.

The revised path attaches the native menu once during setup. Routine usage updates only refresh the compact tray title, while account/storage changes replace the account rows inside the existing menu. The stable-menu correction is platform-neutral and is expected to address #95, but the issue should remain open until the reporter validates a Windows build over time.

On macOS, repeatedly replacing the native menu could also leave the status item alive but no longer painted. A transient settings read failure could fall back to the default text-only mode and clear the configured icon.

Popup opens behind full-screen apps or under the camera housing

The popup did not opt into the all-Spaces and full-screen auxiliary window behavior, so it could open behind a full-screen application even though its right-click native menu remained available.

Popup placement also used the tray click's Y coordinate. On a Mac with a camera housing, this positioned the popup inside the physically obscured menu-bar region. The macOS path now performs placement on AppKit's main thread using NSScreen.visibleFrame and NSWindow.setFrameTopLeftPoint, Apple's native safe-content and screen-coordinate APIs. Other platforms retain the Tauri positioning path with horizontal display-edge clamping.

Tauri 2.11 rendering regression

The dependency declarations used compatible version ranges, so a lockfile refresh could move the popup from the working Tauri 2.10 window stack to Tauri 2.11. A controlled bisect reproduced the failure on the 2.11 stack and restored the original React popup on Tauri 2.10 without replacing it with a native AppKit popover.

The PR now pins tauri 2.10.3, tauri-build 2.5.6, tauri-runtime 2.10.1, tauri-runtime-wry 2.10.1, and @tauri-apps/api 2.10.1. The direct runtime constraints are intentional: pinning only the top-level tauri crate still allowed Cargo to resolve its runtime crates to 2.11.

Close button cannot quit

The main window's close-behavior prompt only offered Show in Dock and Menu Bar Only. That made the close button unable to terminate the application. The prompt now includes an explicit Quit Codex Switcher action while retaining both background-running choices.

Changes

  • retain one native Menu instance for the lifetime of the tray
  • update account rows in place when accounts.json changes
  • update only the tray title during routine usage refreshes
  • reload settings without silently substituting an icon-clearing display mode
  • reapply visibility, icon/template state, and title when repairing the tray display
  • configure the macOS popup with all-Spaces/full-screen-auxiliary collection behavior and popup-menu window level
  • position the macOS popup against the clicked screen's visibleFrame on the main thread
  • add a clearly labeled Quit Codex Switcher action to the close-behavior prompt
  • add regression coverage for popup edge clamping
  • constrain the complete Tauri popup runtime to the verified 2.10 compatibility boundary

Scope

This PR does not include the colored macOS status-item title or the later platform-renderer refactor. It preserves the existing React popup and contains only the tray lifecycle, popup rendering/placement, close-flow, and required runtime compatibility fixes.

Validation

  • cargo fmt --check --manifest-path src-tauri/Cargo.toml
  • cargo check --locked --manifest-path src-tauri/Cargo.toml
  • cargo test --locked --manifest-path src-tauri/Cargo.toml — 36 passed
  • pnpm build
  • cargo tree --locked -p codex-switcher --depth 1 confirms Tauri 2.10.3 and both runtime crates at 2.10.1
  • bundled macOS app passed strict local signature verification
  • manual validation in a full-screen Space on a notched MacBook display
  • WindowServer measurement confirmed the popup moved from clipped Y=19 to safe Y=37
  • controlled runtime test confirmed the original React popup works on the pinned 2.10 stack
  • source-level verification against Tauri 2.10.3, tray-icon 0.21.3, and muda 0.17.1 Windows backends
  • cargo xwin check --target x86_64-pc-windows-msvc
  • cargo xwin test --target x86_64-pc-windows-msvc --no-run — all Windows test executables compiled and linked
  • cargo xwin build --target x86_64-pc-windows-msvc --release --bin codex-switcher — produced a 64-bit Windows GUI executable

Windows runtime validation is still requested because #95 is intermittent and cannot be reproduced faithfully on macOS.

@demetrius-skypulse
demetrius-skypulse marked this pull request as ready for review July 31, 2026 21:40
@demetrius-skypulse demetrius-skypulse changed the title Fix macOS tray reliability and popup placement Fix tray reliability and macOS popup placement Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant