Skip to content

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

fix(desktop): integrate preview hit regions with shared chrome geometry

ZeroYaa956c73bb1f
diff --cc apps/desktop/src/styles/chrome.css
index 88e77fdf2,526ddd8ff..c84176620
--- a/apps/desktop/src/styles/chrome.css
+++ b/apps/desktop/src/styles/chrome.css
@@@ -1108,22 -1104,15 +1104,17 @@@
user-select: none;
}
-/* Window-level chrome for preview mode: the topbar that normally owns the drag
- band and the window controls lives in MainChat, which preview mode does not
- render, so the shell reserves the same 46px band itself. */
-.app-shell.work-panel-maximized .work-panel-header {
- -webkit-app-region: drag;
+.app-shell.work-panel-maximized {
+ --preview-chrome-inset: 8px;
- --preview-chrome-action-lane: 30px;
++ --preview-chrome-action-lane: calc(var(--ds-control-size) + 8px);
}
-.app-shell.work-panel-maximized .work-panel-header button {
- -webkit-app-region: no-drag;
+.app-shell.work-panel-maximized.sidebar-collapsed {
+ --preview-chrome-action-lane: var(--ds-preview-action-lane-width);
+}
+
+:root[data-platform="darwin"] .app-shell.work-panel-maximized.sidebar-collapsed {
- --preview-chrome-inset: 76px;
- }
-
- :root[data-platform="darwin"][data-fullscreen="true"]
- .app-shell.work-panel-maximized.sidebar-collapsed {
- --preview-chrome-inset: 8px;
++ --preview-chrome-inset: var(--ds-window-lead-inset);
}
.window-chrome-row {
diff --cc apps/desktop/test/traffic-light-reserve.test.mjs
index 000000000,f23cb4cc6..ce91bbc94
mode 000000,100644..100644
--- a/apps/desktop/test/traffic-light-reserve.test.mjs
+++ b/apps/desktop/test/traffic-light-reserve.test.mjs
@@@ -1,0 -1,128 +1,132 @@@
+ import assert from "node:assert/strict";
+ import { readFile } from "node:fs/promises";
+ import test from "node:test";
+ import { loadStyles } from "./helpers/styles.mjs";
+
+ const read = (relative) => readFile(new URL(relative, import.meta.url), "utf8");
+
+ const sharedSource = await read("../../../packages/shared/src/window-chrome.ts");
+ const windowSource = await read("../electron/main/bootstrap/window.ts");
+ const entrySource = await read("../src/main.tsx");
+ const tokensSource = await read("../src/styles/tokens.css");
+ const chromeSource = await read("../src/styles/chrome.css");
+ const workPanelSource = await read("../src/styles/work-panel.css");
+ const globalStyles = await loadStyles();
+
+ test("the macOS traffic lights have one geometry owner across processes", () => {
+ // The renderer reserves space for these buttons, so a second literal for
+ // where they sit is exactly the drift the shared constant exists to prevent.
+ assert.match(
+ windowSource,
+ /trafficLightPosition:\s*MAC_TRAFFIC_LIGHT_POSITION/,
+ );
+ assert.doesNotMatch(windowSource, /trafficLightPosition:\s*\{\s*x:/);
+ assert.match(
+ sharedSource,
+ /export const MAC_TRAFFIC_LIGHT_POSITION = \{ x: 16, y: 16 \}/,
+ );
+ // The footprint the renderer reserves is derived from the position the main
+ // process applies, so moving the buttons moves the reserve with them.
+ assert.match(
+ sharedSource,
+ /export const MAC_TRAFFIC_LIGHT_EDGE_DIP =\s*MAC_TRAFFIC_LIGHT_POSITION\.x \+ MAC_TRAFFIC_LIGHT_CLUSTER_WIDTH_DIP;/,
+ );
+ });
+
+ test("the renderer publishes the native footprint before first paint", () => {
+ assert.match(
+ entrySource,
+ /import \{ MAC_TRAFFIC_LIGHT_EDGE_DIP \} from "@pi-desktop\/shared";/,
+ );
+ const bootstrap = entrySource.slice(
+ 0,
+ entrySource.indexOf("installScrollbarReveal(document)"),
+ );
+ const platform = bootstrap.indexOf("dataset.platform");
+ const publish = bootstrap.indexOf('"--ds-traffic-light-edge"');
+ assert.ok(
+ platform !== -1 && publish > platform,
+ "the inset is published after the platform attribute that gates it",
+ );
+ assert.match(
+ bootstrap,
+ /if \(document\.documentElement\.dataset\.platform === "darwin"\) \{\s*document\.documentElement\.style\.setProperty\(\s*"--ds-traffic-light-edge",\s*`\$\{MAC_TRAFFIC_LIGHT_EDGE_DIP\}px`,\s*\);\s*\}/,
+ );
+ });
+
+ test("every shell surface reserves the shared lead inset", () => {
+ // Comments may quote the old footprint while explaining the geometry; only
+ // declarations can drift.
+ const declarationsOnly = (css) => css.replace(/\/\*[\s\S]*?\*\//g, "");
+ for (const [name, source] of [
+ ["chrome.css", chromeSource],
+ ["work-panel.css", workPanelSource],
+ ["tokens.css", tokensSource],
+ ]) {
+ assert.doesNotMatch(
+ declarationsOnly(source),
+ /76px/,
+ `${name} must not restate the traffic-light footprint`,
+ );
+ }
+ // One composition, on the platform that has the buttons.
+ assert.match(
+ chromeSource,
+ /:root\[data-platform="darwin"\] \{\s*--ds-window-lead-inset: calc\(\s*var\(--ds-traffic-light-edge\) \+ var\(--ds-traffic-light-gap\)\s*\);/,
+ );
+ assert.equal(
+ [...globalStyles.matchAll(/--ds-window-lead-inset:\s*calc\(/g)].length,
+ 1,
+ "the reserve is composed in exactly one place",
+ );
+ // The four surfaces that reach the window's left edge consume it.
+ assert.match(
+ chromeSource,
+ /:root\[data-platform="darwin"\] \.sidebar-header \{[\s\S]*?padding-left:\s*var\(--ds-window-lead-inset\);/,
+ );
+ assert.match(
+ chromeSource,
- /:root\[data-platform="darwin"\] \.window-chrome-row:not\(\.sidebar-expanded\) \{[\s\S]*?padding-left:\s*var\(--ds-window-lead-inset\);/,
++ /:root\[data-platform="darwin"\] \.app-shell\.work-panel-maximized\.sidebar-collapsed \{[^}]*--preview-chrome-inset:\s*var\(--ds-window-lead-inset\);/,
++ );
++ assert.match(
++ chromeSource,
++ /\.window-chrome-row \{[^}]*padding-left:\s*var\(--preview-chrome-inset\);/,
+ );
+ assert.match(
+ chromeSource,
+ /:root\[data-platform="darwin"\] \.conversation-topbar\.ct-collapsed \{[\s\S]*?--ct-lead-inset:\s*var\(--ds-window-lead-inset\)/,
+ );
+ assert.match(
+ workPanelSource,
- /\.work-panel-header \{[\s\S]*?padding-left: calc\(\s*var\(--ds-window-lead-inset\) \+ var\(--ds-preview-action-lane-width\)\s*\);/,
++ /\.work-panel-header \{[^}]*margin-left: calc\(var\(--preview-chrome-inset\) \+ var\(--preview-chrome-action-lane\)\);/,
+ );
+ });
+
+ test("the reserve collapses where there are no native traffic lights", () => {
+ assert.match(tokensSource, /--ds-traffic-light-edge: 0px/);
+ assert.match(tokensSource, /--ds-traffic-light-gap: 12px/);
+ assert.match(tokensSource, /--ds-window-lead-inset: 0px/);
+ // Fullscreen hides the buttons: the reserve becomes the ordinary gutter.
+ assert.match(
+ chromeSource,
+ /:root\[data-platform="darwin"\]\[data-fullscreen="true"\] \{\s*--ds-window-lead-inset: 8px;/,
+ );
+ // The titlebar row already pads 12px, so its title adds only the difference —
+ // clamped, because a platform without native lights (or fullscreen) resolves
+ // the reserve to 0 or 8px and the difference must not go negative.
+ assert.match(
+ chromeSource,
+ /\.main-titlebar-left \{[\s\S]*?padding-left:\s*max\(0px, calc\(var\(--ds-window-lead-inset\) - 12px\)\);/,
+ );
+ // Windows/Linux draw their own controls on the right and reserve nothing on
+ // the left.
+ for (const rule of globalStyles.matchAll(
+ /:root\[data-platform="(?:win32|linux)"\][^{]*\{([^}]*)\}/g,
+ )) {
+ assert.doesNotMatch(
+ rule[1],
+ /--ds-window-lead-inset/,
+ "only macOS reserves space for native traffic lights",
+ );
+ }
+ });
diff --cc apps/desktop/test/work-panel.test.mjs
index 22e877eaf,6f4c7bd62..755be4487
--- a/apps/desktop/test/work-panel.test.mjs
+++ b/apps/desktop/test/work-panel.test.mjs
@@@ -576,19 -576,20 +576,18 @@@ test("preview mode keeps shell actions
appSource,
/case "newTask":[\s\S]*?if \(workPanelMaximizedRef\.current\) setWorkPanelMaximized\(false\);/,
);
- assert.match(
- globalStyles,
- /\.window-chrome-row \{[\s\S]*?-webkit-app-region: drag;/,
- );
- assert.match(
- globalStyles,
- /\.window-chrome-row\.sidebar-expanded \{[\s\S]*?left: var\(--ds-sidebar-width\);/,
- );
- assert.match(
- globalStyles,
- /:root\[data-platform="darwin"\] \.window-chrome-row:not\(\.sidebar-expanded\) \{[\s\S]*?padding-left:\s*var\(--ds-window-lead-inset\);/,
- );
- assert.match(
- globalStyles,
- /:root\[data-platform="darwin"\][\s\S]*?\.app-shell\.work-panel-maximized\.sidebar-collapsed\s+\.work-panel-header\s*\{[^}]*padding-left:\s*calc\(\s*var\(--ds-window-lead-inset\) \+ var\(--ds-preview-action-lane-width\)\s*\);/,
- );
+ const row = globalStyles.match(/\.window-chrome-row \{[^}]*\}/)?.[0] ?? "";
+ const spacer = globalStyles.match(/\.window-chrome-drag \{[^}]*\}/)?.[0] ?? "";
+ assert.match(row, /pointer-events:\s*none/);
+ assert.match(row, /padding-left:\s*var\(--preview-chrome-inset\)/);
+ assert.ok(spacer);
+ assert.doesNotMatch(row + spacer, /app-region:|background:/);
+ assert.match(globalStyles, /\.window-chrome-row button \{[^}]*pointer-events:\s*auto;[^}]*app-region:\s*no-drag;/);
+ assert.match(globalStyles, /\.window-chrome-row\.sidebar-expanded \{[^}]*left: var\(--ds-sidebar-width\);/);
- assert.match(globalStyles, /\.app-shell\.work-panel-maximized \{[^}]*--preview-chrome-inset:\s*8px;[^}]*--preview-chrome-action-lane:\s*30px;/);
++ assert.match(globalStyles, /\.app-shell\.work-panel-maximized \{[^}]*--preview-chrome-inset:\s*8px;[^}]*--preview-chrome-action-lane:\s*calc\(var\(--ds-control-size\) \+ 8px\);/);
+ assert.match(globalStyles, /\.app-shell\.work-panel-maximized\.sidebar-collapsed \{[^}]*--preview-chrome-action-lane:\s*var\(--ds-preview-action-lane-width\);/);
- assert.match(globalStyles, /:root\[data-platform="darwin"\] \.app-shell\.work-panel-maximized\.sidebar-collapsed \{[^}]*--preview-chrome-inset:\s*76px;/);
- assert.match(globalStyles, /:root\[data-platform="darwin"\]\[data-fullscreen="true"\]\s+\.app-shell\.work-panel-maximized\.sidebar-collapsed \{[^}]*--preview-chrome-inset:\s*8px;/);
++ assert.match(globalStyles, /:root\[data-platform="darwin"\] \.app-shell\.work-panel-maximized\.sidebar-collapsed \{[^}]*--preview-chrome-inset:\s*var\(--ds-window-lead-inset\);/);
+ assert.match(globalStyles, /\.app-shell\.work-panel-maximized \.work-panel-header \{[^}]*margin-left:\s*calc\(var\(--preview-chrome-inset\) \+ var\(--preview-chrome-action-lane\)\);[^}]*padding-left:\s*0;/);
+ assert.match(globalStyles, /\.work-panel-header \{[^}]*app-region:\s*drag;/);
+ assert.match(globalStyles, /\.app-shell\.work-panel-maximized \.work-panel-main \{[^}]*var\(--ds-bg-dock-raised\) 0 var\(--ds-toolbar-height\)/);
});
diff --cc docs/adr/0238-three-column-width-priority.md
index ce539175e,32a705149..d43c5337e
--- a/docs/adr/0238-three-column-width-priority.md
+++ b/docs/adr/0238-three-column-width-priority.md
@@@ -65,18 -65,8 +65,18 @@@ MainChat to its floor while the expande
(never persisted, ends with the panel) and never changes native bounds.
Because MainChat is absent in this mode, AppShell supplies a window-level
46px chrome row with New Task, sidebar, and native window controls.
- Collapsed-sidebar preview reserves 76px on the left for macOS traffic lights
- in windowed mode and 8px in fullscreen.
- Collapsed-sidebar preview reserves 88px on the left for macOS traffic lights
- in windowed mode and 8px in fullscreen (D433).
++ Collapsed-sidebar preview reserves the shared `--ds-window-lead-inset` on
++ the left: 88px in windowed macOS and 8px in fullscreen (D433).
+ Hit-region amendment (2026-09-16): the chrome row and its spacer declare
+ neither drag nor no-drag, and pass pointer events through outside controls.
+ The panel header is the sole drag owner within the preview pane. Its actual
+ border box excludes the left shell-action lane plus an 8px gap in both
+ sidebar states, including expanded-sidebar New Task. All platforms use an
- 8px left inset except collapsed-sidebar windowed macOS (76px). The existing
++ 8px left inset except collapsed-sidebar windowed macOS (88px). The existing
+ right native-control border exclusion remains unchanged. Header-height
+ background paint fills the excluded lane without an opaque control overlay.
+ Native pointer clicks and window dragging require native validation;
+ renderer geometry and DOM/CDP event dispatch are not native hit-test proof.
## Consequences
diff --cc docs/spec/04-ux/01-ui-ia.md
index 4f9da1523,0373d981d..35c866b4b
--- a/docs/spec/04-ux/01-ui-ia.md
+++ b/docs/spec/04-ux/01-ui-ia.md
@@@ -80,13 -80,13 +80,16 @@@ destination, chat as the home surface,
notification action; the durable local inbox opens from the sidebar footer
bell instead (D130/D117). In work-panel preview mode, MainChat is unmounted
and a window-level 46px chrome row keeps New Task, sidebar, and native window
- controls available. In macOS collapsed-sidebar preview, the panel header
- reserves the 88px windowed (8px fullscreen) traffic-light inset plus the
- preview action lane and an 8px gap, so its first tab never overlaps either
- the traffic lights or the preview controls. The inset is the shared
+ controls available without owning a drag or no-drag rectangle across the
+ panel. The panel header alone owns dragging in the preview pane; its actual
+ border box starts after the shell action lane plus an 8px gap, including the
+ expanded-sidebar New Task button, on every platform. The left inset is 8px,
- or 76px for collapsed-sidebar windowed macOS. Its right native-control
++ or 88px for collapsed-sidebar windowed macOS. Its right native-control
+ exclusion is unchanged. Header paint fills the excluded lane without an
- opaque overlay hiding tabs or panel actions.
++ opaque overlay hiding tabs or panel actions. The macOS inset uses the shared
+ `--ds-window-lead-inset` token — the cluster's 76px right edge (from
+ `@pi-desktop/shared`) plus a 12px gap — and the main process positions the
+ buttons from that same shared geometry.
- **Work panel**: docked right column (not an overlay) opened by an artifact,
the viewport-fixed toggle, or `Cmd/Ctrl + J`. File, URL, browser-preview, and
successful workspace-edit artifacts create their resources atomically. The
diff --cc docs/spec/04-ux/07-ui-design-system.md
index e71a02ea4,9fc77546d..0842a8324
--- a/docs/spec/04-ux/07-ui-design-system.md
+++ b/docs/spec/04-ux/07-ui-design-system.md
@@@ -1043,13 -1046,14 +1046,18 @@@ retain the fade-and-slide exit
Preview mode is a transient shell state: MainChat is unmounted and the work
panel occupies the client width beside the sidebar. A window-level 46px chrome
-row owns the drag area, New Task/sidebar actions, and native window controls.
-Collapsed-sidebar preview reserves 88px on the left for macOS traffic lights in
-windowed mode and 8px in fullscreen. That reserve is the shared
-`--ds-window-lead-inset` token — the traffic-light cluster's 76px right edge
-(native geometry from `@pi-desktop/shared`, the same constants the main process
-positions the buttons with) plus a 12px gap. The maximized panel header retains
-that native reserve, then adds the preview action lane and an 8px gap before its
-first tab.
+row is pointer-transparent outside New Task/sidebar and native window controls;
+it declares neither drag nor no-drag across the panel. The panel header alone
+owns the preview pane's drag area. Its border box, not just its padding, excludes
+the left action lane plus an 8px gap in both sidebar states on all platforms.
- The left inset is 8px except for collapsed-sidebar windowed macOS (76px).
++The left inset is 8px except for collapsed-sidebar windowed macOS (88px).
++That macOS reserve is the shared `--ds-window-lead-inset` token — the traffic-light
++cluster's 76px right edge (native geometry from `@pi-desktop/shared`, the same
++constants the main process positions the buttons with) plus a 12px gap.
++The action lane uses the shared 28px control size plus an 8px gap when expanded,
++and the shared preview action lane (two controls, 4px spacing, 8px gap) when collapsed.
+The right native-control exclusion remains unchanged. The panel paints the
+header-height background behind the excluded lane without covering its controls.
### 10.1 Responsive collapse
diff --cc docs/spec/04-ux/08-component-spec.md
index f8f77dd45,d19d825ad..33a295dd7
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@@ -65,10 -65,13 +65,14 @@@ Outer frame that positions Topbar, Side
native window bounds stay unchanged.
- Work panel preview: the header maximize action temporarily unmounts MainChat
and expands the panel across the client area beside the sidebar. A window-level
- 46px chrome row owns the drag area, New Task/sidebar actions, and native
- window controls. On macOS, collapsed-sidebar preview reserves 88px on the
- left in windowed mode and 8px in fullscreen for the traffic lights. That
- reserve is the shared `--ds-window-lead-inset` token — the traffic-light
- cluster's right edge (76px, from `@pi-desktop/shared`) plus a 12px gap — and
- the main process places the buttons from that same shared geometry, so the
- reserve and the buttons cannot drift apart.
+ 46px chrome row keeps New Task/sidebar and native window controls, with
+ pointer passthrough and no drag/no-drag rectangle outside its controls.
+ The panel header alone owns dragging in the preview pane; its border box
+ excludes the shell action lane in both sidebar states on every platform.
++ On macOS, collapsed-sidebar preview reserves 88px in windowed mode and 8px
++ in fullscreen through the shared `--ds-window-lead-inset` token — the
++ traffic-light cluster's right edge (76px, from `@pi-desktop/shared`) plus a
++ 12px gap. The main process uses that same shared geometry.
- Work panel resize: its inner left-edge handle changes the committed panel
width in the renderer, so dragging left gives the panel more internal space
and dragging right returns space to MainChat (§5.4)
@@@ -240,11 -243,10 +244,12 @@@ combined model × reasoning selection (
while the panel is closed. While the panel is open, that 120px band plus the
toggle overlay the panel header instead, and the header ends its box before
the band so the panel tab strip and `+` stay clear of the native control band.
- In macOS windowed preview mode, a collapsed sidebar also adds the 88px
- traffic-light reserve and the preview action lane plus an 8px gap to the
- panel header itself, keeping its first tab clear; fullscreen uses the 8px
- native reserve but retains the preview action lane.
+ In preview mode the header's left border box starts after the shell actions
+ plus an 8px gap, including expanded-sidebar New Task, on every platform.
- The left inset is 8px except collapsed-sidebar windowed macOS (76px).
++ The left inset is 8px except collapsed-sidebar windowed macOS (88px through
++ the shared lead-inset token). Fullscreen retains the action lane.
+ Header-height background paint fills the excluded lane without an opaque
+ overlay hiding tabs or panel actions.
Resource close actions stay in their tabs so a second header `×` does not echo
the native Windows close control (D357).
- Title cluster (task title) flexes and shows at most the first 10 Unicode
diff --cc docs/spec/04-ux/09-interaction-patterns.md
index 63f8bdabd,a2094f4d6..f99821f6b
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@@ -1096,13 -1096,11 +1096,14 @@@ Work-panel and application-window resiz
- Preview mode unmounts MainChat and lets the work panel fill the client area
beside the sidebar. A window-level 46px chrome row keeps New Task, sidebar,
- and native window controls available. In collapsed-sidebar macOS preview, the
- panel header reserves the 88px windowed (8px fullscreen) traffic-light inset,
- the preview action lane, and an 8px gap before its first tab. That 88px is the
- shared `--ds-window-lead-inset` token: the traffic-light cluster's 76px right
- edge (native geometry from `@pi-desktop/shared`) plus a 12px gap.
+ and native window controls available through a pointer-transparent row that
+ declares neither drag nor no-drag across the panel. The panel header's drag
+ border box starts after the shell actions plus an 8px gap, including expanded
+ sidebar New Task. All platforms use an 8px left inset, except collapsed-sidebar
- windowed macOS (76px). Native pointer clicks must operate the controls and
- dragging empty header space must move the window; DOM/CDP clicks alone do
- not establish native hit testing.
++ windowed macOS (88px). That reserve uses `--ds-window-lead-inset`: the
++ traffic-light cluster's 76px right edge (from `@pi-desktop/shared`) plus 12px.
++ Native pointer clicks must operate the controls and dragging empty header
++ space must move the window; DOM/CDP clicks alone do not establish native hit testing.
The expanded sidebar is fixed at 275px. Collapse/open changes only whether the
column is present; the historical resize handle is hidden and legacy width
diff --cc docs/spec/06-delivery/04-e2e-test-plan.md
index f770662fc,533b7c03b..bd6e80b4e
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@@ -12238,13 -12230,14 +12238,16 @@@ plugin-form fixtures in an isolated tem
keeps whatever sidebar state the user chose last. The mode is transient: it is
not persisted and ends when the panel closes. Preview mode keeps the shell's
new-task, sidebar, and system-window actions reachable while MainChat is
- absent. On non-fullscreen macOS with the sidebar collapsed, the preview row
- renders the traffic-light lead inset (`--ds-window-lead-inset` — the cluster's
- 76px right edge plus the 12px gap, so 88px) as its own left padding, and the
- first preview action starts at or beyond that rendered value; the check reads
- the resolved padding rather than restating the number. After opening a real
- work panel tab, its first tab starts at least 8px to the right of the preview
- action group; fullscreen uses the 8px native inset but retains that action
- lane.
+ absent. The panel header is the sole drag owner in the preview pane. Its
+ actual border box and first tab start at least 8px after the shell actions,
+ including expanded-sidebar New Task, on every platform. Left inset is 8px
- except collapsed-sidebar windowed macOS (76px). The right native-control
- border exclusion remains intact. Controls receive native clicks without
- moving the window; empty header space still drags it. Header-height background
- paint fills the excluded lane without hiding panel controls.
++ except collapsed-sidebar windowed macOS (88px). The preview row renders the
++ shared `--ds-window-lead-inset` (76px native cluster edge plus a 12px gap)
++ as its own left padding; the check reads the resolved padding rather than
++ restating the number. Fullscreen retains the action lane with an 8px inset.
++ The right native-control border exclusion remains intact. Controls receive
++ native clicks without moving the window; empty header space still drags it.
++ Header-height background paint fills the excluded lane without hiding controls.
- **Specs linked**: `04-ux/01-ui-ia.md`, `04-ux/07-ui-design-system.md` §10,
`04-ux/08-component-spec.md` §5, `04-ux/09-interaction-patterns.md` §8,
ADR 0238 §6, issue #289
diff --cc docs/zh-CN/spec/04-ux/01-ui-ia.md
index 2c4b24084,fa1f564af..65e22bbf6
--- a/docs/zh-CN/spec/04-ux/01-ui-ia.md
+++ b/docs/zh-CN/spec/04-ux/01-ui-ia.md
@@@ -66,13 -66,9 +66,15 @@@
后接固定的 `+` 新建入口;关闭操作归属于各标签,因此 Windows 原生关闭
控件旁不再重复呈现第二个 `×`。工作面板预览模式会卸载 MainChat,
并在窗口级 46px chrome 行中保留新建任务、侧边栏和本机窗口控件。
- macOS 非全屏且侧边栏折叠时,左侧预留 88px(全屏为 8px),避免与交通灯重叠。
- 该预留量是共享 token `--ds-window-lead-inset` —— 灯簇右缘 76px(来自
- `@pi-desktop/shared`)加 12px 间隙 —— 主进程用同一份共享几何放置按钮。
+ The row and spacer declare neither drag nor no-drag and pass pointer events
+ through outside controls. The panel header alone owns dragging in the preview
+ pane. Its border box excludes the shell action lane plus an 8px gap in both
+ sidebar states, including expanded-sidebar New Task, on every platform.
- The left inset is 8px except collapsed-sidebar windowed macOS (76px).
++ The left inset is 8px except collapsed-sidebar windowed macOS (88px), using
++ `--ds-window-lead-inset`: the shared native cluster's 76px edge plus 12px.
++ The main process uses the same geometry from `@pi-desktop/shared`.
+ Right native-control exclusion is unchanged; header-height background paint
+ fills the left lane without an opaque overlay covering panel controls.
Windows/Linux 使用无菜单的无框架 46px 行,并在
左侧和可访问的最小化/最大化或恢复/关闭控件
右(D129)。目的地历史以快捷键为主(`Cmd/Ctrl+[` 和
diff --cc docs/zh-CN/spec/04-ux/07-ui-design-system.md
index f8d4f4a2a,114dee29c..3f1061efd
--- a/docs/zh-CN/spec/04-ux/07-ui-design-system.md
+++ b/docs/zh-CN/spec/04-ux/07-ui-design-system.md
@@@ -939,13 -941,11 +941,17 @@@ Linux 保留淡入淡出和滑动退出
- 面板 open/collapse/final 关闭和分隔符提交更新已提交
首选宽度。本机边缘调整窗口大小并重排 MainChat。
- 预览模式是临时的 shell 状态:卸载 MainChat,工作面板填充侧边栏之外的客户区。
- 窗口级 46px chrome 行保留拖动区域、新建任务、侧边栏和本机窗口控件。
- 侧边栏折叠时,macOS 窗口模式左侧预留 88px,全屏预留 8px 给交通灯。
- 该预留量是共享 token `--ds-window-lead-inset` —— 交通灯簇 76px 右缘
- (来自 `@pi-desktop/shared` 的原生几何,与主进程放置按钮所用常量相同)
- 加 12px 间隙。
+ The 46px chrome row retains shell and native controls but declares neither
+ drag nor no-drag across the panel and passes pointer events through outside
+ controls. The panel header alone owns dragging in the preview pane. Its
+ border box excludes shell actions plus an 8px gap in both sidebar states on
+ every platform. The left inset is 8px except collapsed-sidebar windowed macOS
- (76px). Right native-control exclusion is unchanged. Header-height background
++ (88px through `--ds-window-lead-inset`: the shared 76px native cluster edge
++ plus 12px, from the same `@pi-desktop/shared` geometry used by main).
++ The expanded action lane uses the shared 28px control size plus 8px; the
++ collapsed lane uses two controls, 4px spacing and an 8px gap.
++ Right native-control exclusion is unchanged. Header-height background
+ paint fills the excluded lane without covering panel controls.
- 外层外壳在每个平台上都保留原生边缘/角落调整大小。无边框标题栏的
拖动区域不会替代操作系统的调整大小所有权。300ms 的稳定边界等待窗口
可避免恢复逻辑与慢速指针手势竞争,原生调整大小/移动事件停止 600ms 后
diff --cc docs/zh-CN/spec/04-ux/08-component-spec.md
index 9cac541e1,5cdf2f4d1..7c5c4323c
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@@ -70,14 -70,11 +70,16 @@@
工作面板标题带通过让自身盒子在该保留带之前结束来承载它——
用外边距而非内边距——因为原生拖拽矩形就是边框盒。
- 工作面板预览:标题栏最大化操作会临时卸载 MainChat,并让面板填充侧边栏
- 之外的客户区。窗口级 46px chrome 行负责拖动区域、新建任务、侧边栏和本机
- 窗口控件。macOS 侧边栏折叠时,窗口模式左侧预留 88px,全屏预留 8px 给交通灯。
- 该预留量就是共享 token `--ds-window-lead-inset` —— 灯簇右缘(76px,来自
- `@pi-desktop/shared`)加 12px 间隙 —— 主进程也用同一份共享几何放置按钮,
- 因此预留量与按钮不会漂移。
+ 之外的客户区。
+ The 46px chrome row keeps shell/native controls but has no drag/no-drag
+ rectangle and passes pointer events through outside controls. The panel
+ header alone owns dragging in the preview pane; its border box excludes
+ shell actions plus an 8px gap in both sidebar states on every platform.
- The left inset is 8px except collapsed-sidebar windowed macOS (76px).
++ The left inset is 8px except collapsed-sidebar windowed macOS (88px through
++ `--ds-window-lead-inset`: the shared 76px native cluster edge plus 12px).
++ Main uses the same native geometry from `@pi-desktop/shared`.
+ Right native-control exclusion is unchanged. Header-height paint fills the
+ left lane without an opaque overlay hiding tabs or panel actions.
- 工作面板调整大小:左边缘拖动手柄(§5.4)
- 窗口大小调整:本机边缘仅在打开作品时更改 MainChat 宽度
面板保持其承诺的宽度;响应式布局如下
diff --cc docs/zh-CN/spec/04-ux/09-interaction-patterns.md
index d8659e585,7d828e496..d15d43277
--- a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
+++ b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
@@@ -851,14 -851,11 +851,16 @@@ Mode/provider/model/permission/shell �
(预订始终为 0)。
- 后台会话工件永远不会更新可见面板。
-- 预览模式会卸载 MainChat,让工作面板填充侧边栏之外的客户区。窗口级 46px
- chrome 行保留新建任务、侧边栏和本机窗口控件;侧边栏折叠时,macOS 窗口模式
- 左侧预留 88px,全屏预留 8px 给交通灯。这 88px 是共享 token
- `--ds-window-lead-inset`:交通灯簇右缘 76px(来自 `@pi-desktop/shared` 的
- 原生几何)加 12px 间隙。
+- Preview mode unmounts MainChat and fills the client area beside the sidebar.
+ The 46px chrome row keeps shell/native controls but declares neither drag nor
+ no-drag across the panel and passes pointer events through outside controls.
+ The panel header alone owns dragging in the preview pane; its border box
+ excludes shell actions plus an 8px gap in both sidebar states on all platforms.
- The left inset is 8px except collapsed-sidebar windowed macOS (76px).
++ The left inset is 8px except collapsed-sidebar windowed macOS (88px through
++ `--ds-window-lead-inset`: the 76px native cluster edge from
++ `@pi-desktop/shared` plus a 12px gap).
+ Native clicks must operate controls and empty-header drags must move the
+ window; DOM/CDP clicks alone are not native hit-test proof.
展开侧边栏固定为 275px。折叠/展开只改变列是否存在;历史上的调整大小手柄
会隐藏,旧的宽度偏好不会继续持久化。
diff --cc docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index cc97d7126,207c14ed8..26b093c21
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@@ -7219,37 -7221,6 +7221,38 @@@ runner 会在运行时的隔离临时�
- **里程碑**:M6 之后的桌面外壳维护
- **状态**:已自动化(`scripts/e2e-three-column-layout.mjs`,经 `pnpm test:e2e:layout` —— 固定窗口宽度不变、指针拖动全程 360px 下限、左栏让位/恢复、370px 重开目标);单元覆盖见 `work-panel-resize.test.mjs`
+#### E2E-LAYOUT-work-panel-maximize
+
+- **Preconditions**: A desktop session has an open work panel with a real tab.
+- **Steps**:
+ 1. Record the panel width and enter preview mode.
+ 2. Inspect the header border box with the sidebar collapsed and expanded on
+ macOS windowed/fullscreen and Windows/Linux. Check row/spacer drag ownership.
+ 3. With native pointer input, click centers and edges of sidebar and New Task
+ controls. Reenter preview and operate tabs, close, add, restore, panel toggle
+ and native controls. Drag empty header space. Repeat in light/dark themes.
+- **Expected**: MainChat is absent while preview fills the client area beside
+ the sidebar; native bounds and persisted preferred width are unchanged, the
+ divider is inert, and restore retains the last chosen sidebar state. The row
+ and spacer declare neither drag nor no-drag and pass pointer events through
+ outside controls. The panel header is the sole drag owner in the preview pane;
+ its border box and first tab start at least 8px after shell actions, including
+ expanded-sidebar New Task. Left inset is 8px except collapsed-sidebar windowed
- macOS (76px); right native-control exclusion is unchanged. Controls receive
++ macOS (88px through the shared lead-inset token); checks read resolved row
++ padding rather than duplicating native geometry. Right exclusion is unchanged. Controls receive
+ native clicks without window movement; empty-header drags move the window.
+ New Task exits preview to an editable composer. Header-height paint fills the
+ excluded lane without hiding panel controls.
+- **Specs linked**: `04-ux/01-ui-ia.md`, `04-ux/07-ui-design-system.md` §10,
+ `04-ux/08-component-spec.md` §5, `04-ux/09-interaction-patterns.md` §8, ADR 0238
+- **Acceptance**: F (persistence), Quality
+- **Milestone**: Post-M6 desktop shell maintenance
+- **Status**: Partially automated by `scripts/e2e-three-column-layout.mjs`
+ (preview entry/exit, DOM action behavior, header border-box exclusion,
+ row/spacer ownership, all-platform/fullscreen CSS fixtures in both sidebar
+ states). DOM/CDP clicks are not native hit-test proof. Native pointer, drag
+ and visual checks remain required; branch runs are exploratory only.
+
#### E2E-AGENT-alt-enter-steers-active-turn:Enter 排队跟进,Alt+Enter 向当前回合补充指令
- **前提条件**:会话已配置模型,能够控制流式回复或工具完成时机;附件场景使用支持图像的模型。
diff --cc scripts/e2e-three-column-layout.mjs
index c3f0d85df,63909b01a..867c6bf9e
--- a/scripts/e2e-three-column-layout.mjs
+++ b/scripts/e2e-three-column-layout.mjs
@@@ -477,59 -514,37 +514,59 @@@ async function main()
`window ${beforeMaximize.windowWidth} -> ${maximizing.windowWidth}`,
);
- const openedTabPreview = await cdp.evaluate(`(() => {
- const actionGroup = document.querySelector(
- ".window-chrome-row .titlebar-nav",
+ // CSS geometry and DOM behavior are not proof of native titlebar hit testing.
+ const checkPreviewHitRegions = async (label) => {
+ const geometry = await cdp.evaluate(`(() => {
+ const row = document.querySelector(".window-chrome-row");
+ const spacer = document.querySelector(".window-chrome-drag");
+ const header = document.querySelector(".work-panel-header");
+ const actions = [...row.querySelectorAll("[data-nav]")];
+ const headerBox = header.getBoundingClientRect();
+ const firstTab = document.querySelector(".work-panel-tab");
+ const controls = row.querySelector(".window-controls");
+ const sidebar = document.querySelector(".sidebar");
+ const platform = document.documentElement.dataset.platform;
- const fullscreen = document.documentElement.dataset.fullscreen === "true";
- const inset = platform === "darwin" && !fullscreen && !sidebar ? 76 : 8;
++ const inset = parseFloat(getComputedStyle(row).paddingLeft);
+ const actionRight = Math.max(...actions.map(el => el.getBoundingClientRect().right));
+ return {
+ headerLeft: headerBox.left,
+ headerRight: headerBox.right,
+ actionRight,
+ leftClear: actions.length > 0 && headerBox.left >= actionRight + 8,
+ insetClear: actions[0].getBoundingClientRect().left >= (sidebar?.getBoundingClientRect().right ?? 0) + inset,
+ rightClear: headerBox.right <= window.innerWidth -
+ (platform === "win32" || platform === "linux" ? 120 : 0) &&
+ (!controls || headerBox.right <= controls.getBoundingClientRect().left),
+ tabClear: !firstTab || firstTab.getBoundingClientRect().left >= actionRight + 8,
+ rowRegion: getComputedStyle(row).webkitAppRegion,
+ spacerRegion: getComputedStyle(spacer).webkitAppRegion,
+ headerRegion: getComputedStyle(header).webkitAppRegion,
+ passThrough: getComputedStyle(row).pointerEvents === "none",
+ actionsInteractive: actions.every(el => getComputedStyle(el).pointerEvents === "auto" && getComputedStyle(el).webkitAppRegion === "no-drag"),
+ };
+ })()`);
+ check(
+ geometry.leftClear && geometry.insetClear && geometry.rightClear && geometry.tabClear &&
+ geometry.rowRegion === "none" && geometry.spacerRegion === "none" &&
+ geometry.headerRegion === "drag" && geometry.passThrough && geometry.actionsInteractive,
+ `preview header border box excludes shell controls (${label}; geometry only)`,
+ JSON.stringify(geometry),
);
- const firstTab = document.querySelector(".work-panel-tab");
- const header = document.querySelector(".work-panel-header");
- const actionGroupBox = actionGroup?.getBoundingClientRect();
- const firstTabBox = firstTab?.getBoundingClientRect();
- return {
- platform: window.piDesktop?.platform ?? "unknown",
- fullscreen: document.documentElement.dataset.fullscreen === "true",
- actionGroupRight: actionGroupBox
- ? Math.round(actionGroupBox.right)
- : null,
- firstTabLeft: firstTabBox ? Math.round(firstTabBox.left) : null,
- headerPaddingLeft: header
- ? Math.round(parseFloat(getComputedStyle(header).paddingLeft))
- : null,
- };
- })()`);
- check(
- openedTabPreview.firstTabLeft !== null &&
- (openedTabPreview.platform !== "darwin" ||
- openedTabPreview.actionGroupRight === null ||
- openedTabPreview.firstTabLeft >=
- openedTabPreview.actionGroupRight + 8),
- "opened work-panel tabs clear the preview action group",
- JSON.stringify(openedTabPreview),
- );
+ };
+ const originalPlatform = await cdp.evaluate(`document.documentElement.dataset.platform`);
+ const originalFullscreen = await cdp.evaluate(`document.documentElement.dataset.fullscreen`);
+ for (const platform of ["darwin", "win32", "linux"]) {
+ for (const fullscreen of [false, true]) {
+ await cdp.evaluate(`document.documentElement.dataset.platform = ${JSON.stringify(platform)}; document.documentElement.dataset.fullscreen = "${fullscreen}"`);
+ for (let state = 0; state < 2; state += 1) {
+ await checkPreviewHitRegions(`${platform}, fullscreen=${fullscreen}, sidebar=${(await measure()).sidebarKind}`);
+ await clickSidebarToggle();
+ }
+ }
+ }
+ await cdp.evaluate(`document.documentElement.dataset.platform = ${JSON.stringify(originalPlatform)}; ${originalFullscreen === undefined ? "delete document.documentElement.dataset.fullscreen" : `document.documentElement.dataset.fullscreen = ${JSON.stringify(originalFullscreen)}`}`);
const previewActions = await cdp.evaluate(`(() => {
+ const row = document.querySelector(".window-chrome-row");
const firstAction =
document.querySelector('.window-chrome-row [data-nav="toggle-sidebar"]') ??
document.querySelector('.window-chrome-row [data-nav="new-task"]');