[codex] fix desktop context menu zoom positioning #2620
What changed#
- Scale desktop context menu coordinates by the renderer zoom factor before sending them to Electron's native
Menu.popupAPI. - Make the macOS destructive trash icon explicit theme-aware by generating separate light/dark native image variants and keeping template-image mode enabled.
- Publish Electron zoom into CSS variables so macOS titlebar chrome spacing stays aligned with the native traffic lights under zoom.
- Tune titlebar X spacing in screen space: zoom-in keeps full native clearance, while zoom-out gradually reduces apparent left spacing with an 82px traffic-light-safe floor. Y/titlebar-height compensation remains unchanged.
- Hide the Electron sidebar wordmark only when the measured rendered wordmark no longer fits between the traffic-light clearance and the sidebar rail.
- Removed the polling-based titlebar zoom sync; the renderer now updates from load, resize/visualViewport resize, and the Electron zoom message path with requestAnimationFrame coalescing.
- Added focused tests for context menu zoom math, theme-matched menu icons, and titlebar zoom CSS variable math.
Why#
React mouse events report positions in the web page's zoomed CSS pixel coordinate space, while Electron's native menu popup positioning expects unzoomed window coordinates. When the user zoomed the desktop app out, right-click context menus opened offset from the pointer.
The trash icon also came from a black named native image and did not reliably tint against dark native menus, so the icon now uses Electron's active native theme when the menu template is built.
The sidebar logo/header used a fixed CSS pixel offset to clear the macOS traffic-light buttons. Electron zoom scales that web offset, but the native titlebar buttons do not move. The horizontal titlebar spacing now follows a gentler zoom-out curve so small zoom levels reduce excessive spacing without letting the logo enter the traffic-light area. At very small zoom levels, the wordmark now hides only once its measured rendered width no longer fits in the remaining header slot.
Validation#
bun fmtbun lint(passed with existing unrelated warnings)bun typecheckbun run test --filter=@t3tools/desktop -- desktopZoom contextMenuPosition ElectronMenu DesktopWindow
Note
Fix desktop context menu zoom positioning and titlebar CSS variable sync#
- Adds
scaleContextMenuPositionForElectronin contextMenuPosition.ts to multiply context menu coordinates by the currentwebFramezoom factor before sending them via IPC, fixing misaligned menus at non-default zoom levels. - Adds
resolveDesktopZoomCssVariablesin desktopZoom.ts to compute zoom-compensated--desktop-titlebar-heightand--desktop-titlebar-leading-offsetCSS variables. - The preload writes these CSS variables on startup, on window/visualViewport resize, and when the main process sends
desktop:zoom-factor-changedover a new IPC channel. - DesktopWindow.ts emits
desktop:zoom-factor-changedwith the current zoom factor onzoom-changedanddid-finish-loadevents. - In Electron, the sidebar wordmark is hidden via a
ResizeObserver/resize listener when the header has insufficient horizontal space.
Note
Low Risk Desktop UI/preload IPC changes with focused unit tests; no auth, data, or security-sensitive paths.
Overview
Fixes misaligned native context menus when the desktop app is zoomed by scaling popup coordinates from CSS pixels to what Electron expects before IPC (scaleContextMenuPositionForElectron in preload).
Adds zoom-aware macOS sidebar titlebar layout: the main process pushes the current zoom factor via desktop:zoom-factor-changed; preload sets --desktop-zoom-factor, --desktop-titlebar-height, and --desktop-titlebar-leading-offset (with a gentler zoom-out curve and a traffic-light-safe minimum leading offset). The Electron sidebar header uses those variables instead of fixed 52px / 90px padding.
The sidebar wordmark hides (keeps layout space) when measured width no longer fits the header after padding, using ResizeObserver and viewport resize coalescing.
Unit tests cover context-menu scaling and titlebar CSS math.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 412962ec464686d85c85fadb8ef9a888c0a56fb5. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved
Targeted bug fix for desktop context menu positioning when zoomed. Adds well-tested utility functions for scaling coordinates/CSS variables by zoom factor, with straightforward mathematical logic and no broader behavioral changes.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
🚀 Expo continuous deployment is ready!
- Project → t3-code
- Platforms → android, ios
- Scheme → t3code-preview
🤖 Android 🍎 iOS Fingerprint 971e873f513ad97675807fa4bf5eb9577ad935ce 3d9696e1c58021a1749a75e2a781a9012f956663 Build Details Build Permalink Details
Distribution:INTERNAL
Build profile:preview:dev
Runtime version:971e873f513ad97675807fa4bf5eb9577ad935ce
App version:0.1.0
Git commit:df68d2e210b3d459b5c02ccee9424163cd643dd6Build Permalink Details
Distribution:INTERNAL
Build profile:preview:dev
Runtime version:3d9696e1c58021a1749a75e2a781a9012f956663
App version:0.1.0
Git commit:df68d2e210b3d459b5c02ccee9424163cd643dd6Update Details Update Permalink Details
Branch:pr-2620
Runtime version:971e873f513ad97675807fa4bf5eb9577ad935ce
Git commit:df68d2e210b3d459b5c02ccee9424163cd643dd6Update Permalink Details
Branch:pr-2620
Runtime version:3d9696e1c58021a1749a75e2a781a9012f956663
Git commit:df68d2e210b3d459b5c02ccee9424163cd643dd6Update QR Note
🤖 GPT-5.6 Sol responding on behalf of Theo
We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together.
Current main converts context-menu coordinates inside ElectronMenu. This branch converts them again in the preload path, which would scale the coordinates twice, and its other UI changes do not fix that problem.
If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
569d1ff4-2bc1-4b49-b750-c0511512c501You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.