Skip to content

Clamp desktop zoom to 50-300% in 10% steps - #4299

Merged
SawyerHood merged 2 commits into
get-bb:mainfrom
vznh:feat/desktop-zoom-limits
Sep 24, 2026
Merged

SawyerHood merged 2 commits into
get-bb:mainfrom
vznh:feat/desktop-zoom-limits

Conversation

@vznh

@vznh vznh commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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:
Screenshot 2026-09-24 at 5 56 48 PM

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): nextZoomFactor is 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: adds BB_DESKTOP_MIN_ZOOM_PERCENT (50) and BB_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 injected zoomFocusedPage callback, following the existing reloadWindow pattern.
  • apps/desktop/src/main.ts: zoomWebContents applies nextZoomFactor via setZoomFactor. The View menu targets webContents.getFocusedWebContents(), the same page Electron's roles zoomed (Electron 44.3.0 lib/browser/api/menu.ts:93), so an embedded browser tab or DevTools still zooms itself rather than the whole app. The indicator's bb-desktop:zoom-command IPC zooms the app window that sent it.
  • DesktopZoomIndicator.tsx: − is disabled at 50% and + at 300%.
  • No server/daemon wire changes. This is desktop window chrome, so there is no CLI/SDK surface.

How you verified

  • pnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/desktop --filter=@bb/desktop-contract passes.
  • pnpm exec turbo run test --filter=@bb/desktop passes: 48 files, 440 tests.
    • desktop-zoom.test.ts covers 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.ts checks that all three zoom items call zoomFocusedPage with the right command and keep their accelerators.
  • DesktopZoomIndicator.test.tsx passes 7/7. It includes the disabled − at 50% and + at 300%.

AGENT GENERATED

vznh and others added 2 commits September 24, 2026 17:57
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
vznh force-pushed the feat/desktop-zoom-limits branch from 618e18a to 1303b2b Compare September 24, 2026 21:58
@vznh
vznh marked this pull request as ready for review September 24, 2026 21:59
@vznh

vznh commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@SawyerHood looking for a review here! should be quick

@SawyerHood
SawyerHood merged commit 3f35250 into get-bb:main Sep 24, 2026
16 checks passed
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