Skip to content
Source
Sign inSign up
pingdotgg/t3code

[codex] fix desktop context menu zoom positioning #2620

Closedjuliusmarmingewants to merge 1 commit intomain fromt3code/195ddd89opened View on GitHub

juliusmarmingecommented

What changed

  • Scale desktop context menu coordinates by the renderer zoom factor before sending them to Electron's native Menu.popup API.
  • 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 fmt
  • bun lint (passed with existing unrelated warnings)
  • bun typecheck
  • bun run test --filter=@t3tools/desktop -- desktopZoom contextMenuPosition ElectronMenu DesktopWindow

Note

Fix desktop context menu zoom positioning and titlebar CSS variable sync

  • Adds scaleContextMenuPositionForElectron in contextMenuPosition.ts to multiply context menu coordinates by the current webFrame zoom factor before sending them via IPC, fixing misaligned menus at non-default zoom levels.
  • Adds resolveDesktopZoomCssVariables in desktopZoom.ts to compute zoom-compensated --desktop-titlebar-height and --desktop-titlebar-leading-offset CSS variables.
  • The preload writes these CSS variables on startup, on window/visualViewport resize, and when the main process sends desktop:zoom-factor-changed over a new IPC channel.
  • DesktopWindow.ts emits desktop:zoom-factor-changed with the current zoom factor on zoom-changed and did-finish-load events.
  • In Electron, the sidebar wordmark is hidden via a ResizeObserver/resize listener when the header has insufficient horizontal space.
Macroscope summarized 412962e.

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. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 569d1ff4-2bc1-4b49-b750-c0511512c501

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `t3code/195ddd89`

      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      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).
    4. 🚀 Expo continuous deployment is ready!

      • Project → t3-code
      • Platforms → android, ios
      • Scheme → t3code-preview
       🤖 Android🍎 iOS
      Fingerprint971e873f513ad97675807fa4bf5eb9577ad935ce3d9696e1c58021a1749a75e2a781a9012f956663
      Build DetailsBuild Permalink
      DetailsDistribution: INTERNAL
      Build profile: preview:dev
      Runtime version: 971e873f513ad97675807fa4bf5eb9577ad935ce
      App version: 0.1.0
      Git commit: df68d2e210b3d459b5c02ccee9424163cd643dd6
      Build Permalink
      DetailsDistribution: INTERNAL
      Build profile: preview:dev
      Runtime version: 3d9696e1c58021a1749a75e2a781a9012f956663
      App version: 0.1.0
      Git commit: df68d2e210b3d459b5c02ccee9424163cd643dd6
      Update DetailsUpdate Permalink
      DetailsBranch: pr-2620
      Runtime version: 971e873f513ad97675807fa4bf5eb9577ad935ce
      Git commit: df68d2e210b3d459b5c02ccee9424163cd643dd6
      Update Permalink
      DetailsBranch: pr-2620
      Runtime version: 3d9696e1c58021a1749a75e2a781a9012f956663
      Git commit: df68d2e210b3d459b5c02ccee9424163cd643dd6
      Update QR
    5. 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.

Sign in to join this conversation.