Skip to content

Per-tab zoom - #485

Open
ianu82 wants to merge 3 commits into
pr/downloads-shelffrom
pr/per-tab-zoom
Open

Per-tab zoom#485
ianu82 wants to merge 3 commits into
pr/downloads-shelffrom
pr/per-tab-zoom

Conversation

@ianu82

@ianu82 ianu82 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What

Per-tab zoom, Chrome-style:

  • ⌘+ / ⌘− zoom the active tab in and out along Chrome's step ladder (50% → 300%); ⌘0 resets to 100%.
  • Zoom is per tab and persists in the session model, so a tab comes back at its zoom after an app restart.
  • Tabs zoomed away from 100% show a small percentage badge in the address field; clicking it resets to 100%.
  • Odd values (e.g. restored from an old session) snap to the nearest step before stepping again. The steps live in main (browser-logic.ts) so renderer and main can't drift, and there are tests covering set / apply / persist.

Stacked on pr/downloads-shelf.

For QA

  1. On any page: ⌘+ zooms in steps (100 → 110 → 125 …), ⌘− steps back down, ⌘0 returns to exactly 100%.
  2. Zoom one tab, switch to another: the other tab is unaffected; switching back keeps your zoom.
  3. With zoom ≠ 100% the address field shows the percentage badge — clicking it resets.
  4. Restart the app: zoomed tabs restore at their zoom level.
  5. Zoom all the way out (50%) and in (300%): it clamps at both ends, no runaway values.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92d08174a4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/browser/browser-manager.ts Outdated
if (!tab) return { ok: false };
const zoom = logic.nextZoomFactor(tab.zoom ?? 1, direction);
patch(id, { zoom });
views.get(id)?.webContents.setZoomFactor(zoom);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep Electron zoom state from leaking across tabs

When two embedded tabs are on the same origin, calling Electron's setZoomFactor here does not stay scoped to the one tab whose model was patched; Electron documents zoom as same-origin policy (webContents docs), so zooming https://example.com/a also changes other example.com tab views while their zoom field remains 1 and no badge/persisted state is updated. This makes the new per-tab zoom model diverge from the actual rendered zoom for same-origin tabs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — the manager re-asserts the tab's model zoom on activation and full navigation, so same-origin tabs can't leak Electron's per-origin zoom into each other's views (3b89a32).

ianu82 added 3 commits July 23, 2026 10:32
Chrome's zoom ladder owned by main so renderer and main can't drift:
⌘= / ⌘+ / ⌘- steps through it (ties snap to the lower step), ⌘0 resets
to 100%. The factor lives on the tab model and persists in tabs.json,
applies to live views on set and to new views on creation, and a small
pill inside the omnibox shows the current zoom (click resets). Pure
nextZoomFactor is unit-tested; manager test covers set + apply.
Codex on #485: Electron's setZoomFactor is per-origin for the session,
so two tabs on one origin share the rendered zoom while the model says
per-tab. The manager now re-asserts the tab's model zoom whenever the
view could be showing another origin's value — on tab activation and on
full navigation — so rendered zoom tracks the active tab again. Test
covers the same-origin-neighbour case; FakeWebContents gains the
setZoomFactor spy the activation path now always calls.
@ianu82
ianu82 force-pushed the pr/downloads-shelf branch from bda3509 to ec16bd7 Compare July 23, 2026 17:44
@ianu82
ianu82 force-pushed the pr/per-tab-zoom branch from 92d0817 to 3b89a32 Compare July 23, 2026 17:44
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