Fix tray reliability and macOS popup placement - #117
Open
demetrius-skypulse wants to merge 4 commits into
Open
Conversation
demetrius-skypulse
marked this pull request as ready for review
July 31, 2026 21:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #95.
Summary
Fix cross-platform tray-menu lifecycle failures plus macOS-specific popup presentation failures:
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-icondependency, 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.visibleFrameandNSWindow.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
tauri2.10.3,tauri-build2.5.6,tauri-runtime2.10.1,tauri-runtime-wry2.10.1, and@tauri-apps/api2.10.1. The direct runtime constraints are intentional: pinning only the top-leveltauricrate 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
Menuinstance for the lifetime of the trayaccounts.jsonchangesvisibleFrameon the main threadScope
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.tomlcargo check --locked --manifest-path src-tauri/Cargo.tomlcargo test --locked --manifest-path src-tauri/Cargo.toml— 36 passedpnpm buildcargo tree --locked -p codex-switcher --depth 1confirms Tauri 2.10.3 and both runtime crates at 2.10.1Y=19to safeY=37tray-icon0.21.3, andmuda0.17.1 Windows backendscargo xwin check --target x86_64-pc-windows-msvccargo xwin test --target x86_64-pc-windows-msvc --no-run— all Windows test executables compiled and linkedcargo xwin build --target x86_64-pc-windows-msvc --release --bin codex-switcher— produced a 64-bit Windows GUI executableWindows runtime validation is still requested because #95 is intermittent and cannot be reproduced faithfully on macOS.