Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(plugin-view): follow the app type scale in docked plugin pages (#1930)

Alger5c445b575ac2
diff --git a/apps/desktop/electron/main/bootstrap/app-lifecycle.ts b/apps/desktop/electron/main/bootstrap/app-lifecycle.ts
index b3f95f99c..f222bfaf5 100644
--- a/apps/desktop/electron/main/bootstrap/app-lifecycle.ts
+++ b/apps/desktop/electron/main/bootstrap/app-lifecycle.ts
@@ -11,6 +11,7 @@ import {
isThemeColorScheme,
traySessionTitle,
migrateKeybindingOverrides,
+ resolveFontScale,
type AppMenuCommand,
type CloseBehavior,
type KeybindingOverrides,
@@ -393,6 +394,17 @@ export function createApplicationLifecycle({
});
}
+ /**
+ * Window zoom composes with the Appearance type scale inside a docked plugin
+ * view, so a zoom applied to the main window has to reach those pages too.
+ * Otherwise a panel that was in proportion drifts as soon as the user zooms
+ * the app. A detached plugin window zooms only itself.
+ */
+ function resyncDockedPluginZoom(target: BrowserWindow) {
+ if (target !== state.mainWindow) return;
+ pluginViews.resyncZoom();
+ }
+
function executeNativeMenuAction(
action: NativeMenuAction,
target: BrowserWindow | null = state.mainWindow,
@@ -435,12 +447,15 @@ export function createApplicationLifecycle({
break;
case "zoomIn":
contents.setZoomFactor(Math.min(3, contents.getZoomFactor() * 1.1));
+ resyncDockedPluginZoom(target);
break;
case "zoomOut":
contents.setZoomFactor(Math.max(0.5, contents.getZoomFactor() / 1.1));
+ resyncDockedPluginZoom(target);
break;
case "resetZoom":
contents.setZoomFactor(1);
+ resyncDockedPluginZoom(target);
break;
case "toggleFullScreen": {
// Entering fullscreen from a maximized window leaves both flags set on
@@ -635,6 +650,7 @@ export function createApplicationLifecycle({
theme?: unknown;
keybindings?: unknown;
developerMode?: unknown;
+ fontScale?: unknown;
} | null) {
const locale =
typeof settings?.language === "string" &&
@@ -656,6 +672,11 @@ export function createApplicationLifecycle({
.catch(() => {});
}
applyAppThemePreference(settings?.theme);
+ // A docked plugin view is its own web page, so the renderer's `--font-scale`
+ // cannot reach it. The host repeats the Appearance type scale as that page's
+ // zoom, which is what keeps the bundled Browser and Files panels in
+ // proportion with the app (D343 / ADR 0180).
+ pluginViews.setFontScale(resolveFontScale({ fontScale: settings?.fontScale }));
// Persisted keybindings can still carry the retired window ids (D438); the
// main process is the only reader when the window never opens, so it folds
// them itself instead of relying on a renderer write-back.
diff --git a/apps/desktop/electron/main/bootstrap/startup.ts b/apps/desktop/electron/main/bootstrap/startup.ts
index 5049da9b4..4981e0091 100644
--- a/apps/desktop/electron/main/bootstrap/startup.ts
+++ b/apps/desktop/electron/main/bootstrap/startup.ts
@@ -99,6 +99,7 @@ export type StartupDependencies = {
theme?: unknown;
keybindings?: unknown;
developerMode?: unknown;
+ fontScale?: unknown;
} | null) => void;
applyDeveloperMode: (settings?: { developerMode?: unknown } | null) => void;
applyMacosWindowTranslucency: (
@@ -325,6 +326,7 @@ export function registerApplicationStartup(deps: StartupDependencies): void {
theme?: unknown;
keybindings?: unknown;
developerMode?: unknown;
+ fontScale?: unknown;
macosWindowTranslucency?: unknown;
preventScreenSleep?: unknown;
keepAwakeWhileRunning?: unknown;
diff --git a/apps/desktop/electron/main/browser-host.ts b/apps/desktop/electron/main/browser-host.ts
index 5f4576c7d..50fb18e89 100644
--- a/apps/desktop/electron/main/browser-host.ts
+++ b/apps/desktop/electron/main/browser-host.ts
@@ -47,6 +47,25 @@ export function clampGuestBounds(
};
}
+/**
+ * Convert a chrome page's hole from its own CSS pixels to DIP.
+ *
+ * A docked view follows the app's Appearance type scale as page zoom
+ * (`PluginViewHost`), so a rect the page measured at 125% covers 1.25 DIP per
+ * pixel in the window. Without this the guest page would sit in a hole smaller
+ * than the one the chrome actually draws from 100% type upward.
+ */
+export function scaleGuestHole(hole: BrowserRect, scale: unknown): BrowserRect {
+ const factor = Number(scale);
+ if (!Number.isFinite(factor) || factor <= 0 || factor === 1) return hole;
+ return {
+ x: hole.x * factor,
+ y: hole.y * factor,
+ width: hole.width * factor,
+ height: hole.height * factor,
+ };
+}
+
function asRect(value: unknown): BrowserRect | null {
if (!value || typeof value !== "object") return null;
const record = value as Record<string, unknown>;
@@ -74,6 +93,12 @@ type ChromeSurface = {
viewId: string;
visible: boolean;
bounds: BrowserRect;
+ /**
+ * Page zoom the chrome page is painting at. The page measures its guest hole
+ * in its own CSS pixels, so once the host scales that page with the app's
+ * type scale one chrome CSS pixel covers `scale` DIP (see `scaleGuestHole`).
+ */
+ scale?: number;
};
type BrowserRevealWaiter = {
@@ -616,7 +641,10 @@ export class BrowserHost {
private guestBounds(): BrowserRect | null {
if (!this.chrome?.visible || !this.hole || this.holePluginId !== this.chrome.pluginId) return null;
- return clampGuestBounds(this.chrome.bounds, this.hole);
+ return clampGuestBounds(
+ this.chrome.bounds,
+ scaleGuestHole(this.hole, this.chrome.scale),
+ );
}
private applyGuest(): void {
diff --git a/apps/desktop/electron/main/ipc/settings-ipc.ts b/apps/desktop/electron/main/ipc/settings-ipc.ts
index 2adec295e..6e9d2ed0e 100644
--- a/apps/desktop/electron/main/ipc/settings-ipc.ts
+++ b/apps/desktop/electron/main/ipc/settings-ipc.ts
@@ -21,6 +21,7 @@ export type SettingsIpcDependencies = {
theme?: unknown;
keybindings?: unknown;
developerMode?: unknown;
+ fontScale?: unknown;
} | null) => void;
applyDeveloperMode: (settings?: { developerMode?: unknown } | null) => void;
applyPreventScreenSleep: (settings?: { preventScreenSleep?: unknown } | null) => void;
@@ -116,6 +117,9 @@ export function registerSettingsIpc({
theme?: unknown;
keybindings?: unknown;
developerMode?: unknown;
+ // A docked plugin view follows the saved type scale (D343), so the
+ // Appearance write has to carry it to the host's view zoom.
+ fontScale?: unknown;
} | null,
);
applyDeveloperMode(validatedSettings as { developerMode?: unknown } | null);
diff --git a/apps/desktop/electron/main/plugin-view-host.ts b/apps/desktop/electron/main/plugin-view-host.ts
index a4976d3d1..e473712b4 100644
--- a/apps/desktop/electron/main/plugin-view-host.ts
+++ b/apps/desktop/electron/main/plugin-view-host.ts
@@ -1,4 +1,10 @@
-import { session, shell, WebContentsView, type BrowserWindow } from "electron";
+import {
+ session,
+ shell,
+ WebContentsView,
+ type BrowserWindow,
+ type WebContents,
+} from "electron";
import { join } from "node:path";
import { getModuleDirectory } from "./module-path";
import { parseAllowedExternalUrl } from "./safe-open-external";
@@ -14,6 +20,7 @@ import {
scaleBoundsToDip,
type PluginViewBounds,
} from "./plugin-view-bounds";
+import { normalizePluginViewScale, pluginViewZoom } from "./plugin-view-scale";
import {
applyPluginEgressPolicy,
pluginSessionPartition,
@@ -110,6 +117,13 @@ export class PluginViewHost {
/** Last CSS-pixel rect from the renderer, so zoom changes can rescale. */
private lastCssBounds: PluginViewBounds | null = null;
private clock = 0;
+ /**
+ * Appearance → Font size multiplier the app is painting at (D343). A docked
+ * view repeats it as page zoom; see `plugin-view-scale.ts`.
+ */
+ private fontScale = 1;
+ /** Factor already pushed to the live pages, so a resize does not re-push it. */
+ private appliedZoom: number | null = null;
private onBlockedRequest?: PluginPanelBlockedRequest;
/**
* Identity of the pages allowed to use the bridge, keyed by web contents. A
@@ -133,6 +147,12 @@ export class PluginViewHost {
viewId: string;
visible: boolean;
bounds: PluginViewBounds;
+ /**
+ * Zoom the visible page is painting at. A chrome page that reports its
+ * guest hole in its own CSS pixels (`pi.browser`) needs this to convert
+ * back to DIP once the host applied the app's type scale.
+ */
+ scale: number;
} | null,
) => void;
@@ -174,7 +194,9 @@ export class PluginViewHost {
}
const visible = this.visibleKey ? this.views.get(this.visibleKey) : null;
visible?.view.setBounds(this.bounds);
- this.emitSurface();
+ // The window zoom is part of the docked page zoom, so the pages follow it
+ // and the surface carries the new factor behind the browser guest rect.
+ this.resyncZoom();
};
try {
contents.on("zoom-changed", onChange);
@@ -296,9 +318,33 @@ export class PluginViewHost {
this.bounds = scaleBoundsToDip(this.lastCssBounds, this.currentZoomFactor());
const visible = this.visibleKey ? this.views.get(this.visibleKey) : null;
visible?.view.setBounds(this.bounds);
+ this.syncZoom();
this.emitSurface();
}
+ /**
+ * Follow the app's Appearance type scale (D343). A docked view is its own web
+ * page, so `--font-scale` on the app document cannot reach it; the host
+ * repeats the same factor as that page's zoom. Live views are rescaled in
+ * place, so neither plugin state nor scroll position is lost.
+ */
+ setFontScale(scale: number): void {
+ const next = normalizePluginViewScale(scale);
+ if (next === this.fontScale) return;
+ this.fontScale = next;
+ this.resyncZoom();
+ }
+
+ /**
+ * Re-assert the composed zoom after the window's own zoom changed. Menu Zoom
+ * In / Out / Reset scale the app page only, so without this the docked pages
+ * would keep the old factor and drift out of proportion with the app.
+ */
+ resyncZoom(): void {
+ this.applyZoomToAll(this.viewZoom());
+ if (this.visibleKey) this.emitSurface();
+ }
+
private currentZoomFactor(): number {
const contents = this.window && !this.window.isDestroyed() ? this.window.webContents : null;
if (!contents || contents.isDestroyed()) return 1;
@@ -306,6 +352,39 @@ export class PluginViewHost {
return Number.isFinite(zoom) && zoom > 0 ? zoom : 1;
}
+ /** Zoom every docked page paints at: the app type scale times window zoom. */
+ private viewZoom(): number {
+ return pluginViewZoom(this.fontScale, this.currentZoomFactor());
+ }
+
+ /**
+ * Re-apply the factor only when it drifted. The renderer re-measures a zoomed
+ * window by reporting bounds again, so this is the path that catches a zoom
+ * whose `zoom-changed` never arrived (menu zoom, restored window) without
+ * poking every page on each resize frame.
+ */
+ private syncZoom(): void {
+ const zoom = this.viewZoom();
+ if (zoom === this.appliedZoom) return;
+ this.applyZoomToAll(zoom);
+ }
+
+ private applyZoomToAll(zoom: number): void {
+ this.appliedZoom = zoom;
+ for (const entry of this.views.values()) {
+ this.applyZoom(entry.view.webContents, zoom);
+ }
+ }
+
+ private applyZoom(wc: WebContents, zoom: number): void {
+ if (wc.isDestroyed()) return;
+ try {
+ wc.setZoomFactor(zoom);
+ } catch {
+ // A page being torn down rejects the change; its next load re-applies it.
+ }
+ }
+
/**
* Show exactly one view, or none.
*
@@ -396,6 +475,7 @@ export class PluginViewHost {
viewId: this.visibleKey.slice(separator + 1),
visible: true,
bounds: this.bounds,
+ scale: this.viewZoom(),
});
}
@@ -448,6 +528,10 @@ export class PluginViewHost {
if (allowed) void shell.openExternal(allowed);
return { action: "deny" };
});
+ // A page renders at 100% until the host can touch it, so set the factor now
+ // and again on each fresh document: the first paint is already sized.
+ this.applyZoom(wc, this.viewZoom());
+ wc.on("dom-ready", () => this.applyZoom(wc, this.viewZoom()));
return view;
}
}
diff --git a/apps/desktop/electron/main/plugin-view-scale.ts b/apps/desktop/electron/main/plugin-view-scale.ts
new file mode 100644
index 000000000..ffe43252c
--- /dev/null
+++ b/apps/desktop/electron/main/plugin-view-scale.ts
@@ -0,0 +1,36 @@
+/**
+ * Type-scale propagation for docked plugin work-panel views.
+ *
+ * A docked view is its own web page, so neither the renderer's `--font-scale`
+ * (D343 / ADR 0180) nor the window's own zoom reaches it: the plugin page keeps
+ * painting its author-sized 12px/13px chrome while the app around it grows.
+ * The host repeats the same factor as that page's zoom instead. At
+ * `fontScale * windowZoom` one CSS pixel inside the plugin paints at the same
+ * DIP size as one CSS pixel in the app, so text and control proportions match
+ * without asking plugins to ship a host design-token ramp.
+ *
+ * The rules stay here, free of Electron, so they are unit-testable.
+ */
+
+export const DEFAULT_PLUGIN_VIEW_SCALE = 1;
+
+/** Coerce a settings or window value into a usable zoom factor. */
+export function normalizePluginViewScale(value: unknown): number {
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
+ return DEFAULT_PLUGIN_VIEW_SCALE;
+ }
+ return value;
+}
+
+/**
+ * Zoom one docked view page needs to match the app: the Appearance type scale
+ * multiplied by the window zoom, because the app paints both in one window.
+ *
+ * Rounded so a settled pair of factors does not re-apply a zoom that only
+ * differs in floating-point noise.
+ */
+export function pluginViewZoom(scale: number, windowZoom: number): number {
+ const composed =
+ normalizePluginViewScale(scale) * normalizePluginViewScale(windowZoom);
+ return Number(composed.toFixed(4));
+}
\ No newline at end of file
diff --git a/apps/desktop/test/browser-guest-hole-scale.test.mjs b/apps/desktop/test/browser-guest-hole-scale.test.mjs
new file mode 100644
index 000000000..8babe1f82
--- /dev/null
+++ b/apps/desktop/test/browser-guest-hole-scale.test.mjs
@@ -0,0 +1,123 @@
+import assert from "node:assert/strict";
+import { register } from "node:module";
+import test from "node:test";
+
+register(new URL("./helpers/ts-import-hooks.mjs", import.meta.url));
+const { BrowserHost, scaleGuestHole } = await import(
+ "../electron/main/browser-host.ts"
+);
+
+/**
+ * The Browser chrome reports the rect of its guest hole in its own CSS pixels
+ * while the window places the guest in DIP. A docked view follows the app's
+ * type scale as page zoom, so one chrome CSS pixel covers more than one DIP once
+ * the user raises the Appearance font size; the guest has to follow, or it would
+ * sit in a hole smaller than the chrome actually draws.
+ */
+
+const VIEW = { x: 100, y: 20, width: 400, height: 600 };
+
+function harness() {
+ const panes = [];
+ const host = new BrowserHost({
+ createPane: (onState) => {
+ let state = null;
+ const pane = {
+ bounds: null,
+ visible: false,
+ setWindow: () => {},
+ setBounds(bounds) {
+ this.bounds = bounds;
+ },
+ setVisible(visible) {
+ this.visible = visible;
+ },
+ getState: () => state,
+ getWebContents: () => null,
+ invalidateNavigation: () => {},
+ navigateAndWait(target) {
+ state = {
+ url: target,
+ title: target,
+ isLoading: false,
+ canGoBack: false,
+ canGoForward: false,
+ };
+ onState(state);
+ return Promise.resolve(state);
+ },
+ dispose() {
+ this.visible = false;
+ },
+ };
+ panes.push(pane);
+ return pane;
+ },
+ isPluginLoaded: () => true,
+ getFileRoots: async () => [],
+ onState: () => {},
+ });
+ host.setWindow({
+ isDestroyed: () => false,
+ contentView: { children: [], addChildView() {}, removeChildView() {} },
+ });
+ return { host, panes };
+}
+
+async function place(hole, surface) {
+ const { host, panes } = harness();
+ host.setChromeSurface({
+ pluginId: "pi.browser",
+ viewId: "browser",
+ visible: true,
+ bounds: VIEW,
+ ...surface,
+ });
+ host.setChromeSession("session", "tab");
+ await host.navigate({ url: "/page.html" }, "session");
+ host.setGuestHole("pi.browser", hole);
+ return panes.at(-1).bounds;
+}
+
+test("scaleGuestHole leaves a 100% chrome hole in DIP", () => {
+ assert.deepEqual(scaleGuestHole({ x: 0, y: 30, width: 400, height: 570 }, 1), {
+ x: 0,
+ y: 30,
+ width: 400,
+ height: 570,
+ });
+ assert.deepEqual(scaleGuestHole({ x: 8, y: 8, width: 8, height: 8 }, undefined), {
+ x: 8,
+ y: 8,
+ width: 8,
+ height: 8,
+ });
+});
+
+test("scaleGuestHole multiplies a zoomed chrome hole by its page zoom", () => {
+ assert.deepEqual(
+ scaleGuestHole({ x: 4, y: 36, width: 320, height: 480 }, 1.25),
+ { x: 5, y: 45, width: 400, height: 600 },
+ );
+});
+
+test("an unusable chrome zoom keeps the hole at 100%", () => {
+ const hole = { x: 1, y: 2, width: 3, height: 4 };
+ for (const bad of [0, -1, Number.NaN, Number.POSITIVE_INFINITY]) {
+ assert.deepEqual(scaleGuestHole(hole, bad), hole);
+ }
+});
+
+test("the guest is placed under the chrome at the app's type scale", async () => {
+ const hole = { x: 0, y: 30, width: 400, height: 570 };
+ // 100%: the chrome's CSS pixels already are DIP.
+ assert.deepEqual(await place(hole), { x: 100, y: 50, width: 400, height: 570 });
+ // 125%: a 30 CSS px chrome bar is 37.5 DIP tall, and the guest fills the rest
+ // of the same 400x600 view instead of ending 142 DIP too early.
+ assert.deepEqual(await place(hole, { scale: 1.25 }), {
+ x: 100,
+ y: 57,
+ width: 400,
+ height: 562,
+ });
+});
\ No newline at end of file
diff --git a/apps/desktop/test/plugin-view-scale.test.mjs b/apps/desktop/test/plugin-view-scale.test.mjs
new file mode 100644
index 000000000..6e0882917
--- /dev/null
+++ b/apps/desktop/test/plugin-view-scale.test.mjs
@@ -0,0 +1,43 @@
+import assert from "node:assert/strict";
+import { register } from "node:module";
+import test from "node:test";
+
+register(new URL("./helpers/ts-import-hooks.mjs", import.meta.url));
+const { DEFAULT_PLUGIN_VIEW_SCALE, normalizePluginViewScale, pluginViewZoom } =
+ await import("../electron/main/plugin-view-scale.ts");
+
+/**
+ * A docked plugin view is its own web page, so the app's `--font-scale` and the
+ * window zoom never reach it as CSS. The host republishes both as that page's
+ * zoom instead; these are the rules it composes them with (D343 / ADR 0180).
+ */
+
+test("the default factor leaves a plugin page at its author size", () => {
+ assert.equal(DEFAULT_PLUGIN_VIEW_SCALE, 1);
+ assert.equal(pluginViewZoom(1, 1), 1);
+ // Nothing to apply: a view opened at 100% keeps painting 12px/13px chrome.
+ assert.equal(normalizePluginViewScale(1), 1);
+});
+
+test("the Appearance type scale and the window zoom compose", () => {
+ assert.equal(pluginViewZoom(1.25, 1), 1.25);
+ assert.equal(pluginViewZoom(1, 1.1), 1.1);
+ // Both are painted into one window, so a 125% type scale inside a 90% window
+ // needs the same product a CSS pixel in the app sees.
+ assert.equal(pluginViewZoom(1.25, 0.9), 1.125);
+ assert.equal(pluginViewZoom(0.85, 1.1), 0.935);
+});
+
+test("the composed factor is stable for an unchanged pair", () => {
+ // A settled scale must not re-apply a zoom that only differs in float noise.
+ assert.equal(pluginViewZoom(1.15, 1.1), pluginViewZoom(1.15, 1.1));
+ assert.equal(pluginViewZoom(1.15, 1.1), 1.265);
+});
+
+test("an unusable factor falls back instead of poisoning the page zoom", () => {
+ for (const bad of [0, -1, Number.NaN, Number.POSITIVE_INFINITY, "1.25", null, undefined]) {
+ assert.equal(normalizePluginViewScale(bad), 1);
+ }
+ assert.equal(pluginViewZoom(Number.NaN, 1), 1);
+ assert.equal(pluginViewZoom(1.25, 0), 1.25);
+});
\ No newline at end of file
diff --git a/apps/desktop/test/plugin-work-panel-views.test.mjs b/apps/desktop/test/plugin-work-panel-views.test.mjs
index 28e5aae42..06c9575d5 100644
--- a/apps/desktop/test/plugin-work-panel-views.test.mjs
+++ b/apps/desktop/test/plugin-work-panel-views.test.mjs
@@ -295,3 +295,29 @@ test("host panel events reach docked views as well as detached windows", () => {
assert.match(mainSource, /plugins\.broadcastEvent\("appearance:changed"/);
assert.match(mainSource, /function setCurrentWorkspacePath/);
});
+
+test("docked views follow the app's type scale and the window zoom", () => {
+ const lifecycleSource = readMainModuleSync("bootstrap/app-lifecycle.ts");
+ const browserHostSource = read("electron/main/browser-host.ts");
+ // A docked view is its own page, so the Appearance type scale has to be
+ // republished as that page's zoom: the settings path feeds it in, a live view
+ // is rescaled in place, and a window zoom re-asserts the composed factor.
+ assert.match(
+ lifecycleSource,
+ /pluginViews\.setFontScale\(resolveFontScale\(\{ fontScale: settings\?\.fontScale \}\)\)/,
+ );
+ assert.match(lifecycleSource, /function resyncDockedPluginZoom\(target: BrowserWindow\)/);
+ assert.match(lifecycleSource, /resyncDockedPluginZoom\(target\);/);
+ assert.match(viewHostSource, /setFontScale\(scale: number\): void/);
+ assert.match(viewHostSource, /wc\.setZoomFactor\(zoom\)/);
+ // Every fresh document re-applies it, so a reload or a navigation cannot
+ // leave a plugin page at its author size.
+ assert.match(viewHostSource, /wc\.on\("dom-ready", \(\) => this\.applyZoom\(wc, this\.viewZoom\(\)\)\)/);
+ // The browser guest is placed from chrome CSS pixels, so the surface carries
+ // the factor the chrome is painting at.
+ assert.match(viewHostSource, /scale: this\.viewZoom\(\)/);
+ assert.match(
+ browserHostSource,
+ /scaleGuestHole\(this\.hole, this\.chrome\.scale\)/,
+ );
+});
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 4f00068b4..d2bf1b3cd 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -11891,8 +11891,11 @@ This test plan spec is accepted when:
3) Drag the slider to 125%. Confirm Trenta becomes selected and
every `--text-*` surface and icon grows further. Confirm the UI never
shows a px field.
- 4) Use Zoom In, then Reset Zoom. Confirm window zoom still scales chrome
- and that the type scale remains 125% after reset.
+ 4) Open the Browser and Files work-panel tabs, then use Zoom In and Reset
+ Zoom. Confirm window zoom still scales chrome, that the type scale
+ remains 125% after reset, and that both docked plugin pages follow it:
+ their text and controls keep the same proportion as the app, and the
+ Browser guest page still fills the area under its per-type-size toolbar.
5) Restart the app and confirm the 125% scale is still applied
(`AppSettings.fontScale` = 1.25).
6) Choose Grande. Confirm the whole UI returns to 100% immediately;
@@ -11903,13 +11906,20 @@ This test plan spec is accepted when:
`AppSettings.fontScale` (absent means 1) and sets `--font-scale`, multiplying
every `--text-*` token and shared Lucide icon. Window Zoom In/Out/Reset remains
independent.
+ Docked plugin work-panel views (the bundled Browser and Files pages) repeat
+ that multiplier — times the window zoom — as their own page zoom instead of
+ importing the app tokens, so they stay in proportion at every setting, and a
+ `pi.browser` guest rect is converted with the same factor. Detached plugin
+ windows and widgets keep their own base size.
Invalid values are rejected or clamped. No protocol or schema version bump.
- **Specs linked**: `04-ux/06-settings-ia.md`, `04-ux/07-ui-design-system.md`,
ADR 0180, D343
- **Acceptance**: A (core shell), B (settings), H (localization)
- **Milestone**: M5+
- **Status**: Unit-covered (`packages/shared/src/font-size.test.ts`,
- `apps/desktop/test/settings-font-size.test.mjs`); full UI journey Draft
+ `apps/desktop/test/settings-font-size.test.mjs`,
+ `apps/desktop/test/plugin-view-scale.test.mjs`,
+ `apps/desktop/test/browser-guest-hole-scale.test.mjs`); full UI journey Draft
(run only in a capable environment when this surface changes)
#### E2E-127: macOS keeps the app in the Dock and Cmd+Tab
diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.md
index 1fa87f3a0..ef9753b28 100644
--- a/docs/spec/07-plugins/03-plugin-api.md
+++ b/docs/spec/07-plugins/03-plugin-api.md
@@ -1422,6 +1422,20 @@ works in either placement. The only differences are chrome and the view
`location` below: a docked view has no window-control capsule and no drag band,
and its `--pi-plugin-titlebar-height` is `0px` rather than `46px`.
+A docked view also follows the host's type size. Its page cannot inherit the
+renderer's `--font-scale`, because it is not the app document, so the host
+repeats the Appearance font size (D343 / ADR 0180) multiplied by the window zoom
+as that page's zoom factor and re-applies it to every fresh document. At that
+factor one CSS pixel inside the plugin paints at the same DIP size as one CSS
+pixel in the app, so author-sized text and controls keep their proportion with
+the panel around them at every setting — no reload, and no host design tokens for
+the plugin to adopt. Two consequences a view author can observe: page pixels are
+the scaled page's own pixels, so a rect handed back to a host API that positions
+native content (`browser.setBounds` in `pi.browser`) is converted by the host,
+and a page that pins layout to fixed window metrics must scale them itself.
+Detached `ui.panel` windows and floating widgets keep their own base size: they
+are their own windows, not a surface composited inside the app.
+
Detached panel pages using the current chrome contract declare
`<meta name="pi-plugin-chrome" content="v2">` and use the published variable
for normal-flow top spacing. The host preserves that page-owned spacing. A
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index d81d00726..943c5867f 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -6933,14 +6933,14 @@ eleven-tool-round desktop paths are verified by
1) 打开设置 → 常规,确认外观卡片在字体行下方显示字体大小,「大杯」选中,滑杆为 100%。
2) 选择「超大杯」。确认会话、输入框、设置标签、侧栏会话标题和 Lucide 图标无需重载即按相对阶一起变大,控件显示 115%。
3) 把滑杆拖到 125%。确认「超超大杯」被选中,全部 `--text-*` 表面和图标继续变大。确认界面没有 px 输入。
- 4) 使用放大,再重置缩放。确认窗口缩放仍会放大 chrome,重置后文字比例仍为 125%。
+ 4) 打开「浏览器」和「文件浏览器」两个工作面板标签,再使用放大与重置缩放。确认窗口缩放仍会放大 chrome、重置后文字比例仍为 125%,且两个停靠插件页跟随该比例:文字与控件和应用的相对大小一致,浏览器访客页仍铺满按新字号绘制的工具栏下方区域。
5) 重启应用,确认 125% 仍然生效(`AppSettings.fontScale` = 1.25)。
6) 选择「大杯」。确认整个界面立即回到 100%;重启后默认仍保留。
-- **预期**:字体大小为星巴克式杯型档位中杯 / 大杯 / 超大杯 / 超超大杯,加上 80%–150%、步进 2.5% 的百分比滑杆。选择持久化为 `AppSettings.fontScale`(缺失表示 1),并设置 `--font-scale` 乘以全部 `--text-*` 令牌和共享 Lucide 图标。窗口放大/缩小/重置保持独立。无效值被拒绝或钳制。无协议/存储版本升级。
+- **预期**:字体大小为星巴克式杯型档位中杯 / 大杯 / 超大杯 / 超超大杯,加上 80%–150%、步进 2.5% 的百分比滑杆。选择持久化为 `AppSettings.fontScale`(缺失表示 1),并设置 `--font-scale` 乘以全部 `--text-*` 令牌和共享 Lucide 图标。窗口放大/缩小/重置保持独立。停靠的插件工作面板视图(自带的「浏览器」和「文件浏览器」页)不导入应用令牌,而是把该倍率乘以窗口缩放作为自身页面缩放,因此在任何设置下都与应用保持比例,`pi.browser` 的访客矩形也按同一倍率换算。独立插件窗口与挂件保持自己的基础尺寸。无效值被拒绝或钳制。无协议/存储版本升级。
- **关联规格**:`04-ux/06-settings-ia.md`、`04-ux/07-ui-design-system.md`、ADR 0180、D343
- **验收**:A(核心 shell)、B(设置)、H(本地化)
- **里程碑**:M5+
-- **状态**:单元覆盖(`packages/shared/src/font-size.test.ts`、`apps/desktop/test/settings-font-size.test.mjs`);完整 UI 旅程为草稿(除非用户明确要求,否则不要本地跑 E2E)
+- **状态**:单元覆盖(`packages/shared/src/font-size.test.ts`、`apps/desktop/test/settings-font-size.test.mjs`、`apps/desktop/test/plugin-view-scale.test.mjs`、`apps/desktop/test/browser-guest-hole-scale.test.mjs`);完整 UI 旅程为草稿(除非用户明确要求,否则不要本地跑 E2E)
#### E2E-130:Read 生成的 tag 可被 Edit 直接使用而无需重读
diff --git a/docs/zh-CN/spec/07-plugins/03-plugin-api.md b/docs/zh-CN/spec/07-plugins/03-plugin-api.md
index e291f0f51..200acd82a 100644
--- a/docs/zh-CN/spec/07-plugins/03-plugin-api.md
+++ b/docs/zh-CN/spec/07-plugins/03-plugin-api.md
@@ -1144,6 +1144,16 @@ window.pluginBridge.on(event, handler)
视图 `location`:停靠视图没有窗口控制胶囊、没有拖拽带,其
`--pi-plugin-titlebar-height` 为 `0px` 而非 `46px`。
+停靠视图同时跟随宿主的文字大小。它不是应用文档,无法继承渲染器的
+`--font-scale`,因此宿主把「外观 → 字体大小」(D343 / ADR 0180)乘以窗口缩放,
+作为该页面的缩放因子,并在每个新文档上重新应用。在该因子下,插件内的一个 CSS
+像素与应用内的一个 CSS 像素绘制成同样的 DIP,因此作者原有尺寸的文字与控件在任何
+设置下都与周围面板保持比例——既不需要重载,也不要求插件改用宿主设计令牌。
+视图作者能观察到的两个后果:页面像素是缩放后页面自己的像素,所以回传给「由宿主
+摆放原生内容」的 API(`pi.browser` 的 `browser.setBounds`)的矩形由宿主换算;
+把布局钉在固定窗口尺寸上的页面需要自行缩放这些值。独立 `ui.panel` 窗口与浮动
+挂件保持自己的基础尺寸:它们是独立窗口,而不是合成进应用内的表面。
+
停靠视图还可以被指定一个要展示的对象。工作面板选项卡本来就携带的 `location`
会投递给任何贡献视图——不再只限 `pi.browser`(它的地址栏保留自己的导航通道):
创建时它作为视图入口 URL 的 `piViewOpen` 查询参数传递,文档加载完成后则通过