Skip to content

Zoom a focused browser page with ⌘= / ⌘- / ⌘0, ⌘+ and pinch - #225

Merged
yansfil merged 2 commits into
mainfrom
fix/browser-page-zoom
Sep 28, 2026
Merged

yansfil merged 2 commits into
mainfrom
fix/browser-page-zoom

Conversation

@yansfil

@yansfil yansfil commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Summary

In a browser display, ⌘= / ⌘- / ⌘0 used to hand focus back to the shell and resize the terminal or editor text, and a trackpad pinch did nothing.
Now, while a page holds the keyboard, the text-size commands zoom that page in Chrome's steps (25% to 500%, reset to 100%) and the page keeps focus.
⌘+ (⌘⇧=) also zooms in, and pinch zoom is enabled up to 3x.
With the shell focused, the same commands size text exactly as before.
Routing is by command id in DesktopHost.sendCommand, so a rebound text-size chord zooms the page too.

Page A at 125% after two native ⌘= presses with the page focused

Review

  • Please judge: ⌘+ is answered by the host before the page, unless the operator bound ⌘⇧= to a command, in which case that binding wins.
  • Please judge: zoom is Chromium's per-host level inside a Workspace's page partition, so same-host pages in one Workspace zoom together (Chrome behaves the same). Nothing is persisted.
  • Files to watch: desktop/src/main/host.ts - sendCommand is the app-menu path for every command; the zoom branch runs only for the three text-size ids while a visible page is focused.
  • Files to watch: desktop/src/main/browser.ts - pinch limits are re-applied on every main-frame did-navigate, because they live in the renderer and a cross-site navigation swaps it (failure path: a rejected call is logged as browser.pinch_zoom_failed).

Evidence

  • Confirmed: new desktop e2e zoom: drives the menu commands with the page focused and checks the zoom steps 1.1, 1.25, 1.1, 1, 0.9, 1, plus ⌘⇧= to 1.1. The page keeps focus throughout and no pane_text_scale / editor_text_scale is sent.
  • Confirmed: the same e2e moves focus to the shell, and text_larger / text_reset then send exactly one text-scale event each while the page zoom stays put.
  • Confirmed: a CDP pinch gesture raises visualViewport.scale above 1.2, and does so again after the page navigates to another site in a new renderer process (PID checked).
  • Confirmed: the pinch assertions are not vacuous. With the limits call removed, the first pinch fails. With it applied only once, the post-navigation pinch fails.
  • Confirmed: native keys through macOS. A throwaway spec posted real CGEvent key presses to the dev app's process on the operator's Mac. With the page focused: ⌘= 1.1, ⌘= 1.25, ⌘⇧= 1.5, ⌘- 1.25, ⌘0 1, each once. With the shell focused: ⌘= and ⌘0 each sent one text-scale event and the page did not zoom.
  • Confirmed: browserSync.test.ts unit-tests the step table against Chromium's kPresetZoomFactors, the clamping at both ends, and off-step starting values.
  • Confirmed: the browser.spec.ts, keys.spec.ts and close-policy.spec.ts desktop suites passed (7/7), along with desktop typecheck, lint and unit tests (44).
  • Not confirmed: a physical trackpad pinch. Pinch was proven with CDP Input.synthesizePinchGesture, not by hand.
  • Not confirmed: the ⌘⇧= override when an operator binds that chord to a command. It is covered by code only, not by a test.
  • Not confirmed (flaky): across repeated local runs, the long browser: test failed some of the time at browser.spec.ts:350, the enterWorkspace after a relaunch. That is the known relaunch race from Find the hide CLI when the desktop app starts without the operator's PATH #166 and outside this diff.
More evidence

Page B pinched to about 2x after a cross-site navigation into a new renderer

AI tooling: mostly AI tools. By hand I compared each zoom step, focus state and text-scale count against the e2e output and the native key-press transcript.

@yansfil
yansfil merged commit 6d317bb into main Sep 28, 2026
7 checks passed
@yansfil
yansfil deleted the fix/browser-page-zoom branch September 28, 2026 04:31
yansfil added a commit that referenced this pull request Sep 28, 2026
Brings in browser page zoom (#225), which touches only the desktop host
and its docs.
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.

1 participant