Repository navigation
Clamp desktop zoom to 50-300% in 10% steps - #4299
Merged
Merged
Conversation
Zoom In/Out/Actual Size were Electron roles, which step the zoom level by 0.5 (about 9.5%) with no bounds. They are now menu items that call the same main-process handler as the zoom indicator. nextZoomFactor steps by 10 percentage points, snaps off-grid factors onto that grid, and clamps to BB_DESKTOP_MIN/MAX_ZOOM_PERCENT from the desktop contract. The indicator disables zoom out at 50% and zoom in at 300%. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Electron's zoom roles act on webContents.getFocusedWebContents(), so Cmd+/- inside an embedded browser tab or DevTools zoomed that page. Routing the menu through the app window changed that to zoom the whole app. The menu now zooms the focused page with the clamped 10% step; the indicator's IPC still zooms the app window that sent it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
vznh
force-pushed
the
feat/desktop-zoom-limits
branch
from
September 24, 2026 21:58
618e18a to
1303b2b
Compare
vznh
marked this pull request as ready for review
September 24, 2026 21:59
Contributor
Author
|
@SawyerHood looking for a review here! should be quick |
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.
Human comments
Zoom level is atypical and I made the choice to clamp so unexpected behavior is less likely. This also is part of a general approach to make sure other elements (sidebar(s), content) behave as expected when zooming out instead of:

What was wrong
Follows #4288.
Zoom In, Zoom Out, and Actual Size were Electron menu roles. Those step the zoom level by ±0.5 (about 9.5%: 100, 110, 120, 131, 144…) with no bounds, and they run entirely inside Electron, so bb could neither clamp them nor share a step with the zoom indicator.
What changed
apps/desktop/src/desktop-zoom.ts(new):nextZoomFactoris a pure function. It steps by 10 percentage points, snaps off-grid factors onto the 10% grid, and clamps to 50–300%. Reset returns 100%.packages/desktop-contract/src/info.ts: addsBB_DESKTOP_MIN_ZOOM_PERCENT(50) andBB_DESKTOP_MAX_ZOOM_PERCENT(300), shared by desktop and app.apps/desktop/src/menu.ts: the three zoom roles become menu items with the same labels and accelerators. Their clicks go through a new injectedzoomFocusedPagecallback, following the existingreloadWindowpattern.apps/desktop/src/main.ts:zoomWebContentsappliesnextZoomFactorviasetZoomFactor. The View menu targetswebContents.getFocusedWebContents(), the same page Electron's roles zoomed (Electron 44.3.0lib/browser/api/menu.ts:93), so an embedded browser tab or DevTools still zooms itself rather than the whole app. The indicator'sbb-desktop:zoom-commandIPC zooms the app window that sent it.DesktopZoomIndicator.tsx: − is disabled at 50% and + at 300%.How you verified
pnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/desktop --filter=@bb/desktop-contractpasses.pnpm exec turbo run test --filter=@bb/desktoppasses: 48 files, 440 tests.desktop-zoom.test.tscovers 10% steps, reset, clamping at both ends, and off-grid factors, including a legacy role step (1.0954…) and float drift (0.9999…).menu.test.tschecks that all three zoom items callzoomFocusedPagewith the right command and keep their accelerators.DesktopZoomIndicator.test.tsxpasses 7/7. It includes the disabled − at 50% and + at 300%.