Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(overlays): keep route-level overlays above the window chrome
ZeroY4eb970fe1d86
diff --git a/apps/desktop/src/pages/PluginsPage.tsx b/apps/desktop/src/pages/PluginsPage.tsxindex 6c2a6f66e..dcc9d70fd 100644--- a/apps/desktop/src/pages/PluginsPage.tsx+++ b/apps/desktop/src/pages/PluginsPage.tsx@@ -86,6 +86,7 @@ export function PluginsPage() {key={action.key}type="button"role="menuitem"+ data-action={action.key}onClick={() => {setHeaderMenu(false);void action.run();diff --git a/apps/desktop/src/styles/chat-shell.css b/apps/desktop/src/styles/chat-shell.cssindex 97d3f313d..c0d02af6a 100644--- a/apps/desktop/src/styles/chat-shell.css+++ b/apps/desktop/src/styles/chat-shell.css@@ -164,16 +164,18 @@.route-surface,.settings-content-enter {- animation: route-surface-in var(--motion-duration-normal) var(--motion-ease-out)- both;+ /* No `forwards`/`both` fill: this entrance ends on the element's own state,+ so a fill would only keep the animation "in effect" — and with it the+ stacking context that left route-level overlays (the plugin modals, the+ plugin detail sheet) underneath the opaque titlebar band. */+ animation: route-surface-in var(--motion-duration-normal) var(--motion-ease-out);}/*- Do not animate `.settings-content-inner`. Chromium promotes an animated- ancestor onto a compositor layer that becomes a containing block for- `position: fixed`, so settings dialogs would cover only the content pane.- Opacity-only keyframes still leave that layer while `animation-fill-mode:- both` is in effect.+ Do not animate `.settings-content-inner`. An animated ancestor is a stacking+ context, and it can become a containing block for `position: fixed`, which is+ what made settings dialogs cover only the content pane. Keep the keyframes+ opacity-only and keep the fill off.*/@keyframes route-surface-in {from {diff --git a/apps/desktop/src/styles/overlays.css b/apps/desktop/src/styles/overlays.cssindex 46401e799..7db4fc673 100644--- a/apps/desktop/src/styles/overlays.css+++ b/apps/desktop/src/styles/overlays.css@@ -316,7 +316,9 @@}.release-notes-overlay {- z-index: 80;+ /* z-dialog, like every other overlay: leaf popups (60) and toasts (50) keep+ painting above it. */+ z-index: 40;}.release-notes-dialog {diff --git a/apps/desktop/src/styles/plugins.css b/apps/desktop/src/styles/plugins.cssindex b00ec885b..81e5a08f8 100644--- a/apps/desktop/src/styles/plugins.css+++ b/apps/desktop/src/styles/plugins.css@@ -1241,7 +1241,8 @@.plugins-sheet-layer {position: fixed;inset: 0;- z-index: 60;+ /* z-dialog: the sheet is a dialog surface, so it stays under leaf popups. */+ z-index: 40;display: flex;justify-content: flex-end;}@@ -1735,7 +1736,8 @@.plugins-modal-backdrop {position: fixed;inset: 0;- z-index: 80;+ /* z-dialog: leaf popups (z-index 60) and toasts (50) stay above the veil. */+ z-index: 40;display: flex;align-items: center;justify-content: center;diff --git a/apps/desktop/test/settings-dialog-overlay.test.mjs b/apps/desktop/test/settings-dialog-overlay.test.mjsindex 258b7f7e9..27c052235 100644--- a/apps/desktop/test/settings-dialog-overlay.test.mjs+++ b/apps/desktop/test/settings-dialog-overlay.test.mjs@@ -27,6 +27,17 @@ test("route entrance does not leave a transform containing block", async () => {styles,/\.route-surface,\s*\.settings-content-inner\s*\{[^}]*animation:\s*route-surface-in/,);+ // No fill either: the entrance ends on the element's own state, so a fill+ // would only keep the animation in effect — and with it the stacking context+ // that left route-level overlays (the plugin modals, the plugin detail+ // sheet) underneath the opaque titlebar band.+ const entrance = styles.match(+ /\.route-surface,\n\.settings-content-enter \{[^}]*\}/,+ );+ assert.ok(entrance, "missing the route entrance rule");+ const animation = entrance[0].match(/animation:[^;]*;/);+ assert.ok(animation, "missing the route entrance animation");+ assert.doesNotMatch(animation[0], /\bboth\b|\bforwards\b/);});test("settings overlays mount on a viewport-fixed host outside the app shell", async () => {@@ -49,3 +60,36 @@ test("settings overlays mount on a viewport-fixed host outside the app shell", aassert.match(source, /portalOverlay\(/, `${rel} must portal its overlay`);}});++// A route overlay is no longer trapped under the window chrome (see the+// entrance-fill assertion above), which puts it back in the root stacking+// context with its own z-index. Everything a dialog raises from inside itself —+// a select list, a toast — is portaled to `document.body` and therefore sits in+// that same context, so it must out-rank the overlay that spawned it or it+// lands underneath the scrim and stops taking clicks.+test("leaf popups and toasts keep painting above the route overlays", async () => {+ const styles = await loadStyles();+ const layer = (selector) => {+ const block = styles.match(new RegExp(`(?:^|\\n)${selector} \\{[^}]*\\}`));+ assert.ok(block, `missing ${selector}`);+ const value = block[0].match(/z-index:\s*(\d+)/);+ assert.ok(value, `${selector} states no z-index`);+ return Number(value[1]);+ };++ const veil = layer("\\.plugins-modal-backdrop");+ const sheet = layer("\\.plugins-sheet-layer");+ const notes = layer("\\.release-notes-overlay");+ const toast = layer("\\.toast-viewport");+ const selectMenu = layer("\\.settings-menu-select-menu");++ for (const [name, value] of [+ ["plugins-modal-backdrop", veil],+ ["plugins-sheet-layer", sheet],+ ["release-notes-overlay", notes],+ ]) {+ assert.ok(value <= 40, `${name} must sit on z-dialog (40), not ${value}`);+ }+ assert.ok(selectMenu > veil && selectMenu > sheet);+ assert.ok(toast > veil && toast > sheet);+});diff --git a/docs/spec/04-ux/07-ui-design-system.md b/docs/spec/04-ux/07-ui-design-system.mdindex 39dd560e9..7b8ff2b31 100644--- a/docs/spec/04-ux/07-ui-design-system.md+++ b/docs/spec/04-ux/07-ui-design-system.md@@ -1023,6 +1023,13 @@ Rules:renderer layer, so no `z-index` in the table above can raise a popover overthem. A body-portaled popover clamps to the conversation pane, which endswhere the work panel begins, instead of to the viewport.+- A route surface holds no stacking context once its entrance animation+ finishes, so an overlay authored inside a route page — a modal, a sheet, or+ their scrims — covers the titlebar band without any `z-index` juggling. On+ Windows/Linux the renderer-drawn window controls stay above renderer overlays.+ Route overlays therefore sit on `z-dialog` (40): a leaf popup (60) or a toast+ (50) a dialog raises — portaled to `document.body`, so in that same stacking+ context — keeps painting above the dialog's scrim and keeps taking clicks.## 10. Layout shell metricsdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 8c6e02b97..57766579b 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -12236,6 +12236,12 @@ plugin-form fixtures in an isolated temporary directory at runtime.28px square on a transparent seat with only a semantic hover wash, so theheader shows quiet icons rather than filled or raised squares. The collapsetoggle's open state changes its glyph and ink only.+- **Overlay coverage measured in the running app**: on the Plugins route a plugin+ modal opens; the modal veil is the topmost hit at the work-panel toggle inside+ the titlebar band; the titlebar band is not the topmost hit there, so it does+ not paint over the modal veil; and closing the modal leaves the route clean.+ `pnpm test:e2e:layout` asserts those four hits as renderer DOM/CDP evidence,+ not as native hit-test proof.- **Specs linked**: `04-ux/01-ui-ia.md`, `04-ux/07-ui-design-system.md` §10,`04-ux/08-component-spec.md` §1 and §5, `04-ux/09-interaction-patterns.md` §8,ADR 0238diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex 9c24e3ed2..4b95a75d5 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -5945,3 +5945,41 @@ that was sitting at the bottom — including after the turn had finished.See `04-ux/06-settings-ia.md`, `04-ux/07-ui-design-system.md`,`04-ux/08-component-spec.md` and E2E-LAYOUT-sidebar-settings in`06-delivery/04-e2e-test-plan.md`.++## 2026-09-17 — A route surface stops holding a stacking context after its entrance++- The plugin install consent modal — and the plugin detail sheet with it — painted+ under the opaque 46px titlebar band, so the band was not covered by the modal's+ scrim and the band's controls stayed clickable. A route page is authored inside+ `.route-surface`, whose entrance animation carried+ `animation-fill-mode: both`: the fill kept the finished entrance "in effect"+ for as long as the page was mounted, and therefore kept the surface a stacking+ context, so an overlay rendered inside the page could not paint above the+ chrome.+- `.route-surface` and `.settings-content-enter` no longer carry `forwards` /+ `both` on their entrance (`apps/desktop/src/styles/chat-shell.css`). The+ entrance ends on the element's own state, so the fill was redundant; without it+ the surface stops holding a stacking context once the entrance finishes, and an+ overlay authored inside a route page paints above the titlebar band again. The+ keyframes stay opacity-only and the entrance still plays.+- The plugin detail sheet keeps reserving `--ds-toolbar-height` at its top+ (`apps/desktop/src/styles/plugins.css`), because on Windows/Linux the+ renderer-drawn window controls own that top-right corner at `z-index: 200` and+ stay above any overlay's z-index.+- The plugin overlays returned to `z-dialog` (40) from their off-scale `80` and+ `60` (`plugins.css`, and the release-notes overlay with them): once the route+ surface stopped trapping them they competed in the root stacking context, and+ at 80 they covered the leaf popups (60) and toasts (50) a dialog raises from+ inside itself — the install dialog's "copied" toast among them. A source test+ pins that relationship now.+- Renderer only: no IPC, storage, schema, protocol, or plugin-SDK change, and no+ new default. See `04-ux/07-ui-design-system.md` §9,+ `apps/desktop/test/settings-dialog-overlay.test.mjs`, and+ `06-delivery/04-e2e-test-plan.md` E2E-LAYOUT-three-column-width-priority (its+ four overlay assertions live in `scripts/e2e-three-column-layout.mjs`).+- Not done, and recorded as a follow-up: true modality — inertness, focus+ containment, shortcut stand-down — needs these overlays on the browser's top+ layer (`<dialog>.showModal()`). That is blocked until the popups, tooltips, and+ toasts they open, which are portaled to `document.body`, also move to the top+ layer, because top-layer content paints above them and makes them unusable; an+ attempt was withdrawn for exactly that reason.diff --git a/docs/zh-CN/spec/04-ux/07-ui-design-system.md b/docs/zh-CN/spec/04-ux/07-ui-design-system.mdindex da2272980..9afb5abf7 100644--- a/docs/zh-CN/spec/04-ux/07-ui-design-system.md+++ b/docs/zh-CN/spec/04-ux/07-ui-design-system.md@@ -913,6 +913,7 @@ UTF-8 写入活动会话的临时 `pasted/` 目录,并在粘贴位置显示一- 浏览器预览与插件视图是原生表面,合成在所有渲染层之上,因此上表中的任何 `z-index` 都无法把浮层抬到它们之上。Portal 到 body 的浮层改为钳制到会话面板(其终点即工作面板的起点),而不是视口。+- 路由表面在入场动画结束后不持有堆叠上下文,因此编写在路由页面内的浮层 —— 模态框、抽屉或它们的遮罩 —— 无需调整 `z-index` 即可覆盖标题栏带。在 Windows/Linux 上,渲染器绘制的窗口控件位于渲染器浮层之上。因此路由浮层位于 `z-dialog`(40):对话框自身弹出的叶子级弹出层(60)或 toast(50)—— 两者均 portal 到 `document.body`,处于同一堆叠上下文 —— 仍绘制在该对话框遮罩之上,并仍可点击。## 10. 布局 shell 指标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.mdindex d0de4f30f..082e028e2 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@@ -7392,6 +7392,7 @@ runner 会在运行时的隔离临时目录中生成六个插件形态 fixtureAutomated by `pnpm test:e2e:layout` using real route components and DOM/CDPinteraction. This is renderer evidence, not native Windows/Linux hit-test proof.- **预期**:原生窗口宽度全程不变。MainChat 永不低于 360px —— 包含拖动过程中以及 `sidebar-out` 仍占位弹性空间期间。工作面板有效上限为客户端宽度减去 360px 下限与展开的左栏宽度,且无固定像素上限。预算耗尽时展开的左栏立即收起,面板之后仍可继续增长。手动重开优先占用右栏宽度;能保住当前 MainChat 则保持,否则落在 370px 的重开目标。关闭面板只恢复由布局机制收起的左栏。分隔线的 ARIA 最小/最大值遵循同一动态预算。+- **在运行中的应用里实测的浮层覆盖**:在 Plugins 路由上打开一个插件模态框;模态遮罩是标题栏带内工作面板开关处的命中首选;标题栏带不是命中首选,因此不会绘制在模态遮罩之上;关闭模态框后路由保持干净。这四项命中由 `pnpm test:e2e:layout` 断言,属于渲染器 DOM/CDP 证据,不是原生命中测试证明。- **链接规格**:`04-ux/01-ui-ia.md`、`04-ux/07-ui-design-system.md` §10、`04-ux/08-component-spec.md` §1 与 §5、`04-ux/09-interaction-patterns.md` §8、ADR 0238- **验收**:F(持久化)、品质- **里程碑**:M6 之后的桌面外壳维护diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex d8c505f64..94dbaeb04 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -4409,3 +4409,12 @@ that amendment are retired by ADR 0268; the upstream work-panel lifecycle stays.- 旧 `--ds-settings-rail-bg` 作为共享颜色的可选回退保留,显式 `--ds-bg-sidebar` 优先;不修改主题或原生窗口 API。- 侧栏挂载不再等同于展开。专用过渡 hook 只响应可见主界面的折叠状态变化,设置导航取消未完成阶段,返回恢复既有宽度和状态,不重播 `sidebar-in`。动画事件防护、超时清理、自动恢复及减少动态效果仍保留;首次显示由原有启动揭示处理,不再叠加侧栏宽度动画。- 不改变 item 缩进、宽度、工作区状态、数据或权限。见 `04-ux/06-settings-ia.md`、`04-ux/07-ui-design-system.md`、`04-ux/08-component-spec.md` 及 `06-delivery/04-e2e-test-plan.md` 的 E2E-LAYOUT-sidebar-settings。++## 2026-09-17 —— 路由表面在入场动画结束后不再持有堆叠上下文++- 插件安装同意模态框 —— 以及随后的插件详情抽屉 —— 原本绘制在不透明的 46px 标题栏带之下,因此该栏没有被模态遮罩覆盖,栏内控件仍然可点击。路由页面挂载在 `.route-surface` 内,而它的入场动画带有 `animation-fill-mode: both`:填充让已结束的入场动画在页面挂载期间始终「生效」,从而让该表面持续成为堆叠上下文,页面内渲染的浮层因此无法绘制到窗口 chrome 之上。+- `.route-surface` 与 `.settings-content-enter` 的入场动画不再声明 `forwards` / `both` 填充(`apps/desktop/src/styles/chat-shell.css`)。入场动画的终点就是元素自身的状态,因此该填充本是多余的;去掉之后,入场结束时表面不再持有堆叠上下文,路由页面内的浮层重新绘制在标题栏带之上。关键帧仍然只有 opacity,入场动画照常播放。+- 插件详情抽屉保留顶部的 `--ds-toolbar-height` 预留(`apps/desktop/src/styles/plugins.css`):在 Windows/Linux 上该右上角归渲染器绘制的窗口控件所有(`z-index: 200`),它们位于任何浮层的 z-index 之上。+- 插件浮层从刻度外的 `80` 与 `60` 归回到 `z-dialog`(40)(`plugins.css`,发行说明浮层一并处理):路由表面不再困住它们之后,它们就在根堆叠上下文中参与比较,而在 80 上会盖住对话框自身弹出的叶子级弹出层(60)与 toast(50)—— 其中包括安装对话框的「已复制」提示。现在有源测试钉住这一关系。+- 仅渲染层:无 IPC、存储、schema、协议或插件 SDK 改动,也没有新增默认值。见 `04-ux/07-ui-design-system.md` §9、`apps/desktop/test/settings-dialog-overlay.test.mjs`,以及 `06-delivery/04-e2e-test-plan.md` 的 E2E-LAYOUT-three-column-width-priority(其四条浮层断言位于 `scripts/e2e-three-column-layout.mjs`)。+- 未做、留作后续的事项:真正的模态 —— 不可交互化、焦点收束、快捷键让位 —— 需要这些浮层进入浏览器顶层(`<dialog>.showModal()`)。在它们打开的弹出菜单、工具提示与 toast(portal 到 `document.body`)同样迁入顶层之前,这一步无法进行,因为顶层内容会绘制在它们之上并使其不可用;此前的一次尝试正因此被撤回。diff --git a/scripts/e2e-three-column-layout.mjs b/scripts/e2e-three-column-layout.mjsindex 8267edc66..15e5bc60d 100644--- a/scripts/e2e-three-column-layout.mjs+++ b/scripts/e2e-three-column-layout.mjs@@ -826,6 +826,74 @@ async function main() {),"plugin route remains visible after preview mode",);+ // E2E: a plugin modal covers the window chrome. The 46px band is an opaque+ // absolute row, and the route surface must not hold a stacking context that+ // leaves the modal's veil underneath it — that is what put the band over+ // the install consent. The viewport-fixed work-panel toggle sits inside the+ // band and used to paint over the veil too; it must not any more.+ const modalCoverage = await cdp.evaluate(`(async () => {+ document.querySelector(".plugins-header-menu")?.click?.();+ for (let i = 0; i < 20; i += 1) {+ if (document.querySelector('[role="menuitem"][data-action="newFromTemplate"]')) break;+ await new Promise((r) => setTimeout(r, 100));+ }+ document+ .querySelector('[role="menuitem"][data-action="newFromTemplate"]')+ ?.click?.();+ await new Promise((r) => setTimeout(r, 400));+ const veil = document.querySelector(".plugins-modal-backdrop");+ if (!veil) return { opened: false };+ const toggle = document.querySelector(".app-work-panel-toggle");+ const toggleBox = toggle?.getBoundingClientRect();+ const toggleStack = toggleBox+ ? document.elementsFromPoint(+ toggleBox.left + toggleBox.width / 2,+ toggleBox.top + toggleBox.height / 2,+ )+ : [];+ // The band opts out of pointer events, so it is made an explicit target+ // for this one measurement and put back afterwards.+ const band = document.querySelector(".main-titlebar");+ const previous = band?.style.pointerEvents ?? "";+ if (band) band.style.pointerEvents = "auto";+ const bandBox = band?.getBoundingClientRect();+ const bandStack = bandBox+ ? document.elementsFromPoint(+ bandBox.left + bandBox.width / 2,+ bandBox.top + bandBox.height / 2,+ )+ : [];+ if (band) band.style.pointerEvents = previous;+ return {+ opened: true,+ veilIsTopmostAtToggle: toggleStack[0] === veil,+ bandIsTopmost: bandStack[0] === band,+ bandTopmost: (bandStack[0]?.className ?? bandStack[0]?.tagName ?? "").toString().slice(0, 40),+ };+ })()`);+ check(+ modalCoverage.opened === true,+ "a plugin modal opens over the plugins route",+ JSON.stringify(modalCoverage),+ );+ check(+ modalCoverage.veilIsTopmostAtToggle === true,+ "the modal veil covers the work-panel toggle in the titlebar band",+ JSON.stringify(modalCoverage),+ );+ check(+ modalCoverage.bandIsTopmost === false,+ "the titlebar band does not paint over the modal veil",+ JSON.stringify(modalCoverage),+ );+ const modalClosed = await cdp.evaluate(`(async () => {+ document+ .querySelector(".plugins-modal-backdrop .plugins-modal-actions button")+ ?.click?.();+ await new Promise((r) => setTimeout(r, 300));+ return !document.querySelector(".plugins-modal-backdrop");+ })()`);+ check(modalClosed === true, "the plugin modal closes and leaves the route clean");// Once Extensions is active the footer Plugins button reuses the existing// Back action, so a second activation returns to the previous destination// (E2E-NAV-plugins-button-goes-back).