Skip to content

[codex] fix desktop context menu zoom positioning#2620

Open
juliusmarminge wants to merge 1 commit intomainfrom
t3code/195ddd89
Open

[codex] fix desktop context menu zoom positioning#2620
juliusmarminge wants to merge 1 commit intomainfrom
t3code/195ddd89

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented May 9, 2026

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 sync CSS zoom variables to renderer

  • Scales context menu popup coordinates by the Electron renderer zoom factor via scaleContextMenuPositionForElectron in preload.ts before sending to the main process, fixing misaligned menus at non-default zoom levels.
  • Adds applyDesktopZoomCssVariables in preload.ts to compute and set CSS custom properties for titlebar height and leading offset based on the current zoom factor, kept in sync on load, resize, and via the new ZOOM_FACTOR_CHANGED_CHANNEL IPC channel.
  • Emits zoom factor updates from DesktopWindow to the renderer on zoom-changed and did-finish-load events.
  • Hides the sidebar wordmark in Electron when there is insufficient header width, updating responsively via ResizeObserver and viewport resize events.
  • On macOS, destructive menu icons now use theme-appropriate (dark/light) template images with separate caches per theme.

Macroscope summarized c06f7ed.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

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: 6ca0b4bf-be90-402b-9199-5679df084a06

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.

@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels May 9, 2026
@juliusmarminge juliusmarminge marked this pull request as ready for review May 9, 2026 17:22
@juliusmarminge juliusmarminge marked this pull request as draft May 9, 2026 17:25
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels May 9, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 9, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 9, 2026

Approvability

Verdict: Approved

Desktop-focused bug fix that corrects context menu positioning when zoomed. The changes add well-tested utility functions for zoom scaling and CSS variable management, with no impact on security or core business logic.

You can customize Macroscope's approvability policy. Learn more.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels May 9, 2026
@juliusmarminge juliusmarminge force-pushed the t3code/195ddd89 branch 3 times, most recently from cc46328 to 0b6fbb3 Compare May 9, 2026 17:47
@juliusmarminge juliusmarminge marked this pull request as ready for review May 9, 2026 17:56
@macroscopeapp macroscopeapp Bot dismissed their stale review May 9, 2026 17:57

Dismissing prior approval to re-evaluate c06f7ed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant