Repository navigation
fix(plugin-view): follow the app type scale in docked plugin pages - #1930
Conversation
A `contributes.views` page is its own webContents, so neither the renderer's `--font-scale` nor the window zoom reached it. The bundled Browser and Files panels kept author-sized 12/13px chrome while the app around them grew, so the two never looked like one product at any font-size setting. The host now republishes the Appearance multiplier (times the window zoom) as the docked page's own zoom, re-applies it to every fresh document, and rescales live views in place so plugin state survives. `pi.browser` measures its guest hole in the chrome page's CSS pixels, so the guest rect is converted with the same factor and a website keeps filling the area the toolbar leaves. Detached plugin windows and widgets keep their own base size; they are their own windows rather than surfaces composited inside the app. D343 / ADR 0180 introduced the global type scale for the app document only.
The PR gate requires the target tip to be an ancestor of the pull request head, and upstream landed 32 commits after this branch was prepared, so the base was no longer an ancestor. Merged rather than rebased: the branch is already published on the fork and shared as a pull request. No conflict touched this change; the conflict-free merge is followed by the same static and unit checks.
|
核实了这条描述的事实基础,成立,而且能定位到具体缺口。
实现时有一个容易踩的点:这里需要两个不同的因子,不能共用一个。
更正一句:我上一条把这条当成了 issue( |
muzimu217
left a comment
There was a problem hiding this comment.
The premise checks out and the two-factor split — the part I flagged before reading the diff — is implemented correctly.
Premise verified. --font-scale lives on the app document (FontSizeRow.tsx:36-38 writes AppSettings.fontScale; consumers use var(--font-scale)), a contributes.views page is its own webContents, and plugin-view-host.ts had no setZoomFactor call at all before this PR, so neither the variable nor menu zoom could reach the docked pages.
The two factors are kept apart, which is the trap here:
- page zoom is composed —
pluginViewZoom(this.fontScale, this.currentZoomFactor())— so the plugin's CSS grows with both the Appearance scale and window zoom; - the host's own view bounds still convert with the window factor alone (
scaleBoundsToDip(lastCssBounds, this.currentZoomFactor())), so the panel rectangle is not multiplied byfontScalea second time; - the browser guest hole, which the chrome page measures in its own CSS pixels, multiplies by the composed scale (
scaleGuestHole(hole, chrome.scale)inbrowser-host.ts), which is the correct direction for that one — it is the only rect that lives in the zoomed page's coordinate space.
New views are not stranded. appliedZoom makes syncZoom() a no-op when the factor is unchanged, but a freshly created view still gets applyZoom(wc, this.viewZoom()) at creation and again on dom-ready, so a view opened after the last scale change does not render at 1.0.
Two small questions, neither blocking:
setZoomFactormakes the host the owner of the docked page's zoom; a plugin that callswindow.devicePixelRatio-based sizing or sets its own zoom will now be overridden. Worth one sentence in03-plugin-api.mdsaying the host owns page zoom for docked views, so plugin authors do not try to compensate twice.resyncZoom()re-emits the surface when a view is visible, which is what makes the guest hole pick up the new scale. If a view is not visible at the moment the window zoom changes, its surface is emitted when it becomes visible again — worth confirming the reveal path recomputeschrome.scalerather than reusing the previous surface, otherwise a hidden-then-revealed browser would keep the old hole.
The probe's proxy asserts that every tunnel it sees targets the fixture, but Chromium's own component updater reaches the configured session proxy while the probe is installed. On a cold CI runner that CONNECT arrives at an unrelated moment — a gvt1.com CDN host in the failing run — and the assertion fired through the probe's uncaughtException path even though every probe step had already been logged green. A CONNECT for any host but the fixture is now refused with 502 and never counted, so `tunnels` keeps measuring fixture traffic only, and a self-check asserts that refusal instead of relying on the runner staying quiet.
|
Coordination note: this PR's top commit ( |
vastsa
left a comment
There was a problem hiding this comment.
The report is confirmed: docked plugin views are separate WebContents, so the app renderer's --font-scale cannot reach Browser/Files. The composed page zoom and matching Browser guest-hole conversion address that boundary, and the PR documents the observable plugin-view effect.
Validated on a candidate containing current main: 29/29 targeted tests passed, Desktop TypeScript check passed, and electron-vite build passed. The full UI journey remains draft in the E2E plan, so I did not run it. Thanks for the focused fix and tests.
Problem
The two bundled work-panel plugins — Browser (
pi.browser) and Files(
pi.file-manager) — do not follow the app's own type size.Both are
contributes.viewssurfaces, so each is a separatewebContentsthatthe host composites into the work panel. Settings → General → Appearance →
Font size only sets
--font-scaleon the app document (D343 / ADR 0180), andmenu Zoom In/Out/Reset only zooms the focused page. Neither reaches a docked
plugin page, so those two panels keep their author-sized
12px/13pxchromewhile everything around them grows: at 125 % app type the Browser address bar and
the Files tree look like a different product, and the same drift happens as soon
as the window is zoomed.
Fix
The host now republishes the app's type factor to a docked page as that page's
own zoom —
fontScale × window zoom— instead of expecting plugin CSS to adopthost design tokens:
PluginViewHost.setFontScale()takes the persistedAppSettings.fontScalefrom the existing settings path (
applyApplicationMenuSettings), andresyncZoom()re-asserts the composed factor after a menu zoom.dom-ready, so a reload or anavigation cannot leave a page at its author size. Live views are rescaled in
place: no reload, no lost plugin state or scroll position.
one CSS pixel in the app, which is what makes text and control proportions
match — and it composes correctly with window zoom, because both operate in the
same window.
pi.browserguest geometry. The Browser chrome measures the rect of its guesthole in its own CSS pixels; the window places the guest in DIP. Once the chrome
page is scaled, one chrome pixel covers more than one DIP, so the host converts
the incoming hole with the same factor (
scaleGuestHole) — otherwise the websiteinside would sit in a hole smaller than the toolbar actually draws. The
scaletravels on the existing
onSurfacepayload; no new channel and no plugin codechange.
Scope
app window — exactly the two bundled plugins above, and any third-party view.
ui.panelwindows and floating widgets deliberately keep their ownbase size: they are their own windows, not a surface inside the app, and their
46px native drag band is DIP-based. Say the word if you would rather have them
follow the setting too; that needs the published
--pi-plugin-titlebar-heightto be divided by the same factor.
pi.browseror the vendoredpi.file-manager.Test plan
Unit / contract:
apps/desktop/test/plugin-view-scale.test.mjs— composition rules: identity at100 %,
1.25 × 0.9, settled pairs stable, unusable factors fall back to 1.apps/desktop/test/browser-guest-hole-scale.test.mjs—scaleGuestHoleand theend-to-end guest rect through a real
BrowserHost: at 125 % a 30 CSS px chromebar becomes 37.5 DIP and the guest fills the remaining 400×600 view instead of
ending 142 DIP too early.
apps/desktop/test/plugin-work-panel-views.test.mjs— source contract that thesettings path feeds the factor in, that a fresh document re-applies it, and that
the surface carries the factor.
Manual (dev build,
pnpm dev):with the app instead of staying at 12/13px.
+/-/0: the docked pages follow the window zoom as well.toolbar, and resizing the panel keeps it aligned.
Checks run on this branch:
pnpm build:js(desktopelectron-vite build+ packagebuilds) passes;
tsc -p apps/desktop/tsconfig.json --noEmitreports 0 errors; thethree test files above pass 25/25. The full
apps/desktopsuite was not run tocompletion here —
update-cache.test.mjsfails on Windows path assertions that areunrelated to this change. No
verify:ui:*run.Docs
docs/spec/07-plugins/03-plugin-api.md— docked views now follow the host typesize; consequences for plugin authors (page pixels are the scaled page's own
pixels; fixed window metrics must scale themselves).
docs/spec/06-delivery/04-e2e-test-plan.md— E2E-193 (font size) step 4 and itsexpected result now cover the two bundled views.