Skip to content

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

fix(settings): keep dialog overlays covering the full window

vastsa8f52643134fc
diff --git a/apps/desktop/src/components/extensions/McpEditorSheet.tsx b/apps/desktop/src/components/extensions/McpEditorSheet.tsx
index 532b9c42c..cb9ffbccf 100644
--- a/apps/desktop/src/components/extensions/McpEditorSheet.tsx
+++ b/apps/desktop/src/components/extensions/McpEditorSheet.tsx
@@ -12,7 +12,7 @@ import {
type McpTransport,
type ProjectRecord,
} from "@pi-desktop/shared";
-import { Button, Field, Input, TooltipButton, cx } from "../ui";
+import { Button, Field, Input, TooltipButton, cx, portalOverlay } from "../ui";
import { IconPlay, IconServer, IconTerminal, IconX } from "../icons";
import { ScopeControl } from "./ScopeControl";
import { KeyValueRows, pairsToRecord, recordToPairs, type KeyValuePair } from "./KeyValueRows";
@@ -292,7 +292,7 @@ export function McpEditorSheet({
const insecureHttp =
draft.transport === "http" && isNonLoopbackHttpMcpUrl(draft.url.trim());
- return (
+ return portalOverlay(
<div
className="overlay ext-sheet-overlay"
role="presentation"
diff --git a/apps/desktop/src/components/settings/OAuthLoginDialog.tsx b/apps/desktop/src/components/settings/OAuthLoginDialog.tsx
index 340c35edb..e9985c6b7 100644
--- a/apps/desktop/src/components/settings/OAuthLoginDialog.tsx
+++ b/apps/desktop/src/components/settings/OAuthLoginDialog.tsx
@@ -12,7 +12,7 @@ import { useTranslation } from "react-i18next";
import type { OAuthPromptRequest, OAuthVendor } from "@pi-desktop/shared";
import type { OAuthLoginSession } from "../../lib/oauth-login-session";
import { canSubmitOAuthPrompt } from "../../lib/oauth-login-prompt";
-import { Button, Input, TooltipButton, cx } from "../ui";
+import { Button, Input, TooltipButton, cx, portalOverlay } from "../ui";
import { IconCheck, IconCopy, IconExternal } from "../icons";
type AuthUrlState = { url: string; instructions?: string; opened: boolean };
@@ -144,7 +144,7 @@ export function OAuthLoginDialog({
};
const canSubmitAnswer = canSubmitOAuthPrompt(prompt, answer);
- return (
+ return portalOverlay(
<div className="overlay provider-dialog-overlay" role="presentation">
<div
className="dialog oauth-dialog"
diff --git a/apps/desktop/src/components/settings/ProviderSetupDialog.tsx b/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
index f029a31ce..f36723c62 100644
--- a/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
+++ b/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
@@ -16,7 +16,7 @@ import {
} from "@pi-desktop/shared";
import { api } from "../../lib/api";
import { pairsToRecord, recordToPairs } from "../extensions/KeyValueRows";
-import { Button, Field, Input } from "../ui";
+import { Button, Field, Input, portalOverlay } from "../ui";
import { ProviderHeadersEditor } from "./ProviderHeadersEditor";
import { SettingsMenuSelect } from "./SettingsMenuSelect";
import { useProviderModels } from "./useProviderModels";
@@ -317,7 +317,7 @@ export function ProviderSetupDialog({
!baseUrlIssue &&
models.length > 0;
- return (
+ return portalOverlay(
<div
className="overlay provider-setup-overlay"
role="presentation"
diff --git a/apps/desktop/src/components/settings/SkillEditorSheet.tsx b/apps/desktop/src/components/settings/SkillEditorSheet.tsx
index 7e97c29f5..28963fce2 100644
--- a/apps/desktop/src/components/settings/SkillEditorSheet.tsx
+++ b/apps/desktop/src/components/settings/SkillEditorSheet.tsx
@@ -7,7 +7,7 @@ import {
type AgentCapabilityLevel,
type UserSkillRecord,
} from "@pi-desktop/shared";
-import { Button, Field, Input, Textarea, TooltipButton, cx } from "../ui";
+import { Button, Field, Input, Textarea, TooltipButton, cx, portalOverlay } from "../ui";
import { IconFolderOpen, IconX } from "../icons";
/** Hard cap host-core enforces on a skill document. */
@@ -194,7 +194,7 @@ export function SkillEditorSheet({
setDraft(next);
};
- return (
+ return portalOverlay(
<div
className="overlay ext-sheet-overlay"
role="presentation"
diff --git a/apps/desktop/src/components/settings/SubagentEditorSheet.tsx b/apps/desktop/src/components/settings/SubagentEditorSheet.tsx
index da81ab132..c26032f18 100644
--- a/apps/desktop/src/components/settings/SubagentEditorSheet.tsx
+++ b/apps/desktop/src/components/settings/SubagentEditorSheet.tsx
@@ -19,7 +19,7 @@ import {
type UserSubagentRecord,
} from "@pi-desktop/shared";
import { useAppStore } from "../../stores/app-store";
-import { Button, Field, Input, Textarea, TooltipButton, cx } from "../ui";
+import { Button, Field, Input, Textarea, TooltipButton, cx, portalOverlay } from "../ui";
import { IconChevronRight, IconFolderOpen, IconX } from "../icons";
import {
groupSubagentModelChoices,
@@ -638,7 +638,7 @@ export function SubagentEditorSheet({
setNameTouched(true);
};
- return (
+ return portalOverlay(
<div
className="overlay ext-sheet-overlay"
role="presentation"
diff --git a/apps/desktop/src/components/settings/VendorAccountDialog.tsx b/apps/desktop/src/components/settings/VendorAccountDialog.tsx
index 269f7194c..420353155 100644
--- a/apps/desktop/src/components/settings/VendorAccountDialog.tsx
+++ b/apps/desktop/src/components/settings/VendorAccountDialog.tsx
@@ -16,7 +16,7 @@ import {
} from "@pi-desktop/shared";
import { useTranslation } from "react-i18next";
import { pairsToRecord, recordToPairs } from "../extensions/KeyValueRows";
-import { Button, Field, Input } from "../ui";
+import { Button, Field, Input, portalOverlay } from "../ui";
import { ProviderHeadersEditor } from "./ProviderHeadersEditor";
import { useProviderModels } from "./useProviderModels";
import { ModelSelectionPanes, useModelSelection } from "./ModelSelectionPanes";
@@ -98,7 +98,7 @@ export function VendorAccountDialog({
});
};
- return (
+ return portalOverlay(
<div
className="overlay vendor-account-overlay"
role="presentation"
diff --git a/apps/desktop/src/components/settings/VendorPickerDialog.tsx b/apps/desktop/src/components/settings/VendorPickerDialog.tsx
index 8485ffae9..5e180f74f 100644
--- a/apps/desktop/src/components/settings/VendorPickerDialog.tsx
+++ b/apps/desktop/src/components/settings/VendorPickerDialog.tsx
@@ -2,7 +2,7 @@
import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import type { OAuthVendor } from "@pi-desktop/shared";
-import { Button } from "../ui";
+import { Button, portalOverlay } from "../ui";
export function VendorPickerDialog({
vendors,
@@ -24,7 +24,7 @@ export function VendorPickerDialog({
return () => window.removeEventListener("keydown", onKeyDown);
}, [onClose]);
- return (
+ return portalOverlay(
<div className="overlay provider-dialog-overlay" role="presentation">
<div
className="dialog oauth-dialog"
diff --git a/apps/desktop/src/components/ui.tsx b/apps/desktop/src/components/ui.tsx
index 239d99335..72b7a1b2c 100644
--- a/apps/desktop/src/components/ui.tsx
+++ b/apps/desktop/src/components/ui.tsx
@@ -15,6 +15,12 @@ import {
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`. */
+export function portalOverlay(node: ReactNode) {
+ return typeof document === "undefined" ? node : createPortal(node, document.body);
+}
+
function setRef<T>(ref: Ref<T> | undefined, value: T | null) {
if (typeof ref === "function") ref(value);
else if (ref) (ref as { current: T | null }).current = value;
diff --git a/apps/desktop/src/styles/chat-shell.css b/apps/desktop/src/styles/chat-shell.css
index 2671f1ce2..c3619a012 100644
--- a/apps/desktop/src/styles/chat-shell.css
+++ b/apps/desktop/src/styles/chat-shell.css
@@ -168,14 +168,18 @@
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.
+*/
@keyframes route-surface-in {
from {
opacity: 0;
- transform: translateY(5px);
}
to {
opacity: 1;
- transform: translateY(0);
}
}
diff --git a/apps/desktop/test/settings-dialog-overlay.test.mjs b/apps/desktop/test/settings-dialog-overlay.test.mjs
new file mode 100644
index 000000000..b2929bd39
--- /dev/null
+++ b/apps/desktop/test/settings-dialog-overlay.test.mjs
@@ -0,0 +1,43 @@
+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 = (rel) => readFile(new URL(rel, import.meta.url), "utf8");
+
+const overlaySources = [
+ "../src/components/settings/ProviderSetupDialog.tsx",
+ "../src/components/settings/VendorAccountDialog.tsx",
+ "../src/components/settings/VendorPickerDialog.tsx",
+ "../src/components/settings/OAuthLoginDialog.tsx",
+ "../src/components/settings/SkillEditorSheet.tsx",
+ "../src/components/settings/SubagentEditorSheet.tsx",
+ "../src/components/extensions/McpEditorSheet.tsx",
+];
+
+test("route entrance does not leave a transform containing block", async () => {
+ const styles = await loadStyles();
+ const start = styles.indexOf("@keyframes route-surface-in");
+ assert.notEqual(start, -1, "missing @keyframes route-surface-in");
+ const next = styles.indexOf("@keyframes", start + 1);
+ const block = styles.slice(start, next === -1 ? undefined : next);
+ assert.doesNotMatch(block, /transform:/);
+ assert.match(block, /opacity:\s*0/);
+});
+
+test("settings overlays are fixed to the viewport and portaled to document.body", 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/);
+
+ const ui = await read("../src/components/ui.tsx");
+ assert.match(ui, /export function portalOverlay/);
+ assert.match(ui, /createPortal\(node, document\.body\)/);
+
+ for (const rel of overlaySources) {
+ const source = await read(rel);
+ assert.match(source, /portalOverlay\(/, `${rel} must portal its overlay`);
+ }
+});
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index 7a7fd5693..233558e76 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -15,7 +15,10 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (
`--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.
+ 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.
- Returning to the app restores the prior sidebar collapsed/expanded state
without a sidebar entrance animation or a width ramp. Real toggle and
automatic 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.md
index d185e33c3..f21adcac0 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 that stays inside the overlay (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 `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
- The model picker searches and toggles multiple models without using a native
multiple select. Its portaled menu closes on outside press, Escape, scroll,
and resize; model selection immediately adds or removes its configuration
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 346780584..5f1836478 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -12275,7 +12275,9 @@ plugin-form fixtures in an isolated temporary directory at runtime.
theme 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. On macOS all ancestors behind the rail are transparent, while right
+ 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
+ all ancestors behind the rail are transparent, while right
content and titlebar stay opaque. Returning to an expanded sidebar starts and
stays at 275px without sidebar-in events; a collapsed sidebar stays absent.
A real reopen still produces sidebar-in and a width ramp. Legacy theme color
@@ -12293,7 +12295,8 @@ plugin-form fixtures in an isolated temporary directory at runtime.
Windows/Linux or OS material/theme validation. Optional
`PI_DESKTOP_LAYOUT_ARTIFACT_DIR` captures renderer screenshots. State tests in
`sidebar-settings-return.test.mjs` cover initial presentation, both interrupted
- phases, hidden-state changes and reversals. `pnpm test:e2e:theme-surfaces`
+ phases, hidden-state changes and reversals. `settings-dialog-overlay.test.mjs`
+ covers the full-window overlay contract. `pnpm test:e2e:theme-surfaces`
verifies the opaque fallback and legacy theme override in real Chromium.
#### E2E-AGENT-alt-enter-steers-active-turn: Enter follows up and Alt+Enter steers the active turn
diff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.md
index 4f58410c2..f748c241e 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 下设置外壳透明,右侧内容区与顶部条仍不透明。只有内容区内部播放路由入场,
- 导航背景本身不淡入、不位移。
+ macOS 下设置外壳透明,右侧内容区与顶部条仍不透明。只有内容区内部播放路由入场(仅透明度,不位移),
+ 导航背景本身不淡入、不位移。设置弹框和抽屉挂到 `document.body`,遮罩覆盖整窗含导轨。
- 返回应用直接恢复原来的侧栏折叠/展开状态,不播放入场动画或从零宽度展开。
可见主界面中的真实开关和自动折叠/恢复仍播放动画;首次显示和路由恢复不触发。
- 导轨顶部:交通灯区域和**搜索设置...**药丸