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(settings): host dialog overlays on a viewport-fixed root
vastsa259441de66da
diff --git a/apps/desktop/src/components/ui.tsx b/apps/desktop/src/components/ui.tsxindex 72b7a1b2c..0030e632c 100644--- a/apps/desktop/src/components/ui.tsx+++ b/apps/desktop/src/components/ui.tsx@@ -16,9 +16,20 @@ export function cx(...parts: Array<string | false | null | undefined>) {return parts.filter(Boolean).join(" ");}-/** Mount a modal overlay on document.body so a transformed ancestor cannot trap `position: fixed`. */+const OVERLAY_ROOT_ID = "pi-desktop-overlays";++function overlayRoot(): HTMLElement {+ const existing = document.getElementById(OVERLAY_ROOT_ID);+ if (existing instanceof HTMLElement) return existing;+ const root = document.createElement("div");+ root.id = OVERLAY_ROOT_ID;+ document.documentElement.appendChild(root);+ return root;+}++/** Mount a modal overlay on a viewport-fixed host so a transformed ancestor cannot trap `position: fixed`. */export function portalOverlay(node: ReactNode) {- return typeof document === "undefined" ? node : createPortal(node, document.body);+ return typeof document === "undefined" ? node : createPortal(node, overlayRoot());}function setRef<T>(ref: Ref<T> | undefined, value: T | null) {diff --git a/apps/desktop/src/features/settings/SettingsPage.tsx b/apps/desktop/src/features/settings/SettingsPage.tsxindex a93b84ee2..9dfcbdeb2 100644--- a/apps/desktop/src/features/settings/SettingsPage.tsx+++ b/apps/desktop/src/features/settings/SettingsPage.tsx@@ -299,6 +299,7 @@ export function SettingsPage() {<div className="settings-content"><div className="settings-content-inner">+ <div className="settings-content-enter"><h1 className="settings-section-title">{activeExtension?.label ?? t(activeTitleKey)}</h1>{activeExtension ? (@@ -487,6 +488,7 @@ export function SettingsPage() {)}</>}+ </div></div></div></div>diff --git a/apps/desktop/src/styles/chat-shell.css b/apps/desktop/src/styles/chat-shell.cssindex c3619a012..97d3f313d 100644--- a/apps/desktop/src/styles/chat-shell.css+++ b/apps/desktop/src/styles/chat-shell.css@@ -163,16 +163,17 @@}.route-surface,-.settings-content-inner {+.settings-content-enter {animation: route-surface-in var(--motion-duration-normal) var(--motion-ease-out)both;}/*- Opacity only. `animation-fill-mode: both` would otherwise leave a transform- on this ancestor, which becomes a containing block for `position: fixed`- descendants. Settings dialogs would then cover the content pane instead of- the window, leaking the rail and section title behind the scrim.+ 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.*/@keyframes route-surface-in {from {diff --git a/apps/desktop/src/styles/responsive.css b/apps/desktop/src/styles/responsive.cssindex cedc07b9a..13405a3e9 100644--- a/apps/desktop/src/styles/responsive.css+++ b/apps/desktop/src/styles/responsive.css@@ -35,7 +35,7 @@@media (prefers-reduced-motion: reduce) {.route-surface,- .settings-content-inner,+ .settings-content-enter,.jump-latest-btn,.chat-error-notice,.work-panel,diff --git a/apps/desktop/src/styles/ui-kit.css b/apps/desktop/src/styles/ui-kit.cssindex ddda1ba73..623188b52 100644--- a/apps/desktop/src/styles/ui-kit.css+++ b/apps/desktop/src/styles/ui-kit.css@@ -143,6 +143,17 @@color: var(--ds-warning);}+#pi-desktop-overlays {+ position: fixed;+ inset: 0;+ z-index: 40;+ pointer-events: none;+}++#pi-desktop-overlays > .overlay {+ pointer-events: auto;+}+.overlay {position: fixed;inset: 0;diff --git a/apps/desktop/test/settings-dialog-overlay.test.mjs b/apps/desktop/test/settings-dialog-overlay.test.mjsindex b2929bd39..258b7f7e9 100644--- a/apps/desktop/test/settings-dialog-overlay.test.mjs+++ b/apps/desktop/test/settings-dialog-overlay.test.mjs@@ -23,18 +23,26 @@ test("route entrance does not leave a transform containing block", async () => {const block = styles.slice(start, next === -1 ? undefined : next);assert.doesNotMatch(block, /transform:/);assert.match(block, /opacity:\s*0/);+ assert.doesNotMatch(+ styles,+ /\.route-surface,\s*\.settings-content-inner\s*\{[^}]*animation:\s*route-surface-in/,+ );});-test("settings overlays are fixed to the viewport and portaled to document.body", async () => {+test("settings overlays mount on a viewport-fixed host outside the app shell", async () => {const styles = await loadStyles();- const overlay = styles.match(/\.overlay \{[\s\S]*?\n\}/);- assert.ok(overlay, "missing .overlay rule");- assert.match(overlay[0], /position:\s*fixed/);- assert.match(overlay[0], /inset:\s*0/);+ assert.match(styles, /\n\.overlay \{\n position: fixed;\n inset: 0;/);++ const host = styles.match(/#pi-desktop-overlays \{[\s\S]*?\n\}/);+ assert.ok(host, "missing overlay host rule");+ assert.match(host[0], /position:\s*fixed/);+ assert.match(host[0], /inset:\s*0/);const ui = await read("../src/components/ui.tsx");assert.match(ui, /export function portalOverlay/);- assert.match(ui, /createPortal\(node, document\.body\)/);+ assert.match(ui, /pi-desktop-overlays/);+ assert.match(ui, /document\.documentElement\.appendChild/);+ assert.doesNotMatch(ui, /createPortal\(node, document\.body\)/);for (const rel of overlaySources) {const source = await read(rel);diff --git a/apps/desktop/test/sidebar-settings-return.test.mjs b/apps/desktop/test/sidebar-settings-return.test.mjsindex 43c62cde0..e7f3e9228 100644--- a/apps/desktop/test/sidebar-settings-return.test.mjs+++ b/apps/desktop/test/sidebar-settings-return.test.mjs@@ -53,7 +53,7 @@ test("home and settings use the same material without animating the settings plaassert.match(styles, new RegExp(`\\.${selector}\\s*\\{[^}]*background:\\s*var\\(--ds-bg-primary\\);`));}assert.doesNotMatch(styles, /\.settings-shell-full \.settings-nav\s*\{[^}]*background:/);- assert.match(styles, /\.route-surface,\s*\.settings-content-inner\s*\{[^}]*animation:\s*route-surface-in/);+ assert.match(styles, /\.route-surface,\s*\.settings-content-enter\s*\{[^}]*animation:\s*route-surface-in/);assert.doesNotMatch(styles, /\.route-surface,\s*\.settings-shell-full\s*\{/);assert.match(styles, /--ds-bg-sidebar:\s*var\(--ds-settings-rail-bg, var\(--ds-bg-under\)\)/);assert.match(styles, /--ds-bg-sidebar:\s*var\(--ds-settings-rail-bg, #f3f3f3\)/);diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.mdindex 233558e76..d70f88c25 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -14,11 +14,11 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (as the main sidebar: native vibrancy with shared tint/sheen on macOS, opaque`--ds-bg-sidebar` on Windows/Linux, and shared optional background imagery.macOS settings-wrapper ancestry is transparent; the content pane and its- titlebar remain opaque. Only the inner settings content enters with a route- animation; the rail and its backing never fade or translate. That entrance- is opacity-only so it cannot leave a transform containing block. Settings- dialogs and sheets portal to `document.body` and cover the full window,- including the rail.+ titlebar remain opaque. Only a nested settings content enter wrapper plays a+ route animation; the scrolling inner pane, rail, and backing never fade or+ translate. That entrance is opacity-only. Settings dialogs and sheets portal+ to a viewport-fixed `#pi-desktop-overlays` host on the document element and+ cover the full window, including the rail.- Returning to the app restores the prior sidebar collapsed/expanded statewithout a sidebar entrance animation or a width ramp. Real toggle andautomatic collapse/restore transitions on the visible shell still animate;diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex f21adcac0..9d2c487ff 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -3309,7 +3309,7 @@ compatibility remains owned by pi-ai.| Busy row | Test/update/delete actions disabled for that card |### 19.4 Interactions-- Add provider opens a modal dialog on a full-window overlay portaled to `document.body` (it can shrink below its 1040px preferred width). Focused credential fields keep their 2px accent ring fully visible: the scrolling body reserves that gutter instead of clipping the ring. Cancel/close resets fields and dismisses the dialog+- Add provider opens a modal dialog on a full-window overlay portaled to `#pi-desktop-overlays` on the document element (it can shrink below its 1040px preferred width). Focused credential fields keep their 2px accent ring fully visible: the scrolling body reserves that gutter instead of clipping the ring. Cancel/close resets fields and dismisses the dialog- The model picker searches and toggles multiple models without using a nativemultiple select. Its portaled menu closes on outside press, Escape, scroll,and resize; model selection immediately adds or removes its configurationdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 5f1836478..fdb03a0a7 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -12274,9 +12274,9 @@ plugin-form fixtures in an isolated temporary directory at runtime.reduced motion. Repeat material comparisons with legacy and canonicaltheme color overrides and a sidebar background image.- **Expected**: Both navigation surfaces share one material. Settings navigation- and shell have no entrance animation; only content inside its opaque pane- animates, and that motion is opacity-only so it cannot trap `position: fixed`- overlays. Settings dialogs cover the full window, including the rail. On macOS+ and shell have no entrance animation; only a nested content-enter wrapper+ inside its opaque pane animates, and that motion is opacity-only so it cannot+ trap `position: fixed` overlays. Settings dialogs cover the full window, including the rail. On macOSall ancestors behind the rail are transparent, while rightcontent and titlebar stay opaque. Returning to an expanded sidebar starts andstays at 275px without sidebar-in events; a collapsed sidebar stays absent.diff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.mdindex f748c241e..4aad9e7f5 100644--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md@@ -9,8 +9,8 @@- 左侧设置导航宽 **275px**,与主侧栏共享 `sidebar-surface` 材质:macOS 使用原生vibrancy 加相同 tint/sheen,Windows/Linux 使用不透明 `--ds-bg-sidebar`,并共享可选背景图。- macOS 下设置外壳透明,右侧内容区与顶部条仍不透明。只有内容区内部播放路由入场(仅透明度,不位移),- 导航背景本身不淡入、不位移。设置弹框和抽屉挂到 `document.body`,遮罩覆盖整窗含导轨。+ macOS 下设置外壳透明,右侧内容区与顶部条仍不透明。只有内容区内部的入场包装播放路由入场(仅透明度,不位移),+ 滚动容器、导航背景本身不淡入、不位移。设置弹框和抽屉挂到文档根上的 `#pi-desktop-overlays`,遮罩覆盖整窗含导轨。- 返回应用直接恢复原来的侧栏折叠/展开状态,不播放入场动画或从零宽度展开。可见主界面中的真实开关和自动折叠/恢复仍播放动画;首次显示和路由恢复不触发。- 导轨顶部:交通灯区域和**搜索设置...**药丸