Skip to content

fix(desktop): publish native menu zoom changes - #46773

Merged
Hona merged 1 commit into
v2from
menu-zoom-sync
Sep 2, 2026
Merged

fix(desktop): publish native menu zoom changes#46773
Hona merged 1 commit into
v2from
menu-zoom-sync

Conversation

@Hona

@Hona Hona commented Sep 2, 2026

Copy link
Copy Markdown
Member

Summary

  • The native View → Zoom In / Zoom Out / Actual Size menu changed the window zoom factor without emitting WindowZoomChanged, so the renderer's webviewZoom signal stayed stale. Anything laid out from that signal (titlebar insets, native view bounds) drifted from the real zoom until the next keyboard or pinch zoom.
  • Route the menu actions through one setZoomFactor(win, factor) in windows/appearance.ts that clamps, applies, updates the titlebar overlay, and publishes the event.
  • Seed webviewZoom from getZoomFactor() on renderer start so a reload while zoomed does not reset the signal to 1.
flowchart LR
    Menu[Native View menu] --> Set[setZoomFactor]
    Keys[Ctrl +/- keys] --> Set
    Pinch[zoom-changed] --> Set
    Set --> Titlebar[updateTitlebar]
    Set --> Event[WindowZoomChanged]
    Event --> Signal[renderer webviewZoom]
Loading

Copilot AI lite review requested due to automatic review settings September 2, 2026 08:56
@Hona
Hona requested a review from Brendonovich as a code owner September 2, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are a couple of correctness/robustness nits in the changed code paths (notably an unhandled rejection risk on renderer startup) that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes desktop zoom state desynchronization by routing native menu zoom actions through a single main-process zoom setter that emits WindowZoomChanged, and by seeding the renderer’s webviewZoom signal from the main process on reload so layout-dependent signals reflect the actual persisted zoom.

Changes:

  • Add renderer startup seeding of webviewZoom using api.getZoomFactor() to preserve zoom state across renderer reloads.
  • Introduce setZoomFactor(win, factor) in the main window appearance module to clamp, apply, and publish zoom changes.
  • Update native menu zoom handlers to call setZoomFactor (instead of directly mutating webContents and only updating the titlebar).
File summaries
File Description
packages/desktop/src/renderer/window/zoom.ts Seed webviewZoom from the main-process zoom factor on renderer start to avoid stale zoom-derived layout after reload.
packages/desktop/src/main/windows/index.ts Re-export setZoomFactor from the windows module for use by other main-process code (menu actions).
packages/desktop/src/main/windows/appearance.ts Add setZoomFactor helper that clamps + applies zoom and publishes WindowZoomChanged via updateZoom.
packages/desktop/src/main/native/menu-actions.ts Route View → Zoom menu actions through setZoomFactor so zoom changes emit the IPC event and keep renderer state in sync.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +49 to +54
// A renderer reload keeps the window's zoom, so seed the signal from main.
void api.getZoomFactor().then((factor) => {
if (requestedZoom !== 1) return
requestedZoom = clamp(factor)
setWebviewZoom(requestedZoom)
})
Comment on lines 1 to +3
import { BrowserWindow } from "electron"
import type { DesktopMenuAction } from "@opencode-ai/app/desktop-menu"
import { updateTitlebar } from "../windows"
import { setZoomFactor } from "../windows"
@Hona
Hona merged commit eead95e into v2 Sep 2, 2026
11 checks passed
@Hona
Hona deleted the menu-zoom-sync branch September 2, 2026 09:07
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.

2 participants