Skip to content

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

fix(sidebar): unify row states and settings material

ZeroY4f3bf1c03fc8
diff --git a/apps/desktop/src/features/app/AppShell.tsx b/apps/desktop/src/features/app/AppShell.tsx
index f073d3d13..41d88504a 100644
--- a/apps/desktop/src/features/app/AppShell.tsx
+++ b/apps/desktop/src/features/app/AppShell.tsx
@@ -53,6 +53,7 @@ export function AppShell() {
searchOpen,
setSearchOpen,
sidebarCollapsed,
+ sidebarEntering,
sidebarExiting,
sidebarWidth,
handleSidebarWidthChange,
@@ -100,7 +101,7 @@ export function AppShell() {
<>
{!sidebarCollapsed || sidebarExiting ? (
<Sidebar
- className={sidebarExiting ? "is-exiting" : undefined}
+ className={cx(sidebarEntering && "is-entering", sidebarExiting && "is-exiting")}
onAnimationEnd={handleSidebarAnimationEnd}
onToggleSidebar={toggleSidebar}
sidebarToggleShortcut={sidebarToggleShortcut}
diff --git a/apps/desktop/src/features/app/useAppShellRuntime.tsx b/apps/desktop/src/features/app/useAppShellRuntime.tsx
index 6b730905e..75b109d1b 100644
--- a/apps/desktop/src/features/app/useAppShellRuntime.tsx
+++ b/apps/desktop/src/features/app/useAppShellRuntime.tsx
@@ -1,4 +1,5 @@
-import { useCallback, useEffect, useLayoutEffect, useRef, useState, type AnimationEvent as ReactAnimationEvent } from "react";
+import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
+import { useSidebarTransition } from "./useSidebarTransition";
import { useTranslation } from "react-i18next";
import {
KEYBOARD_SHORTCUTS,
@@ -68,7 +69,10 @@ export function useAppShellRuntime() {
const [searchOpen, setSearchOpen] = useState(false);
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
const [sidebarWidth] = useState(() => loadSidebarWidth());
- const [sidebarExiting, setSidebarExiting] = useState(false);
+ const { sidebarEntering, sidebarExiting, handleSidebarAnimationEnd } = useSidebarTransition(
+ sidebarCollapsed,
+ ready && page !== "settings",
+ );
const [shellWidth, setShellWidth] = useState(0);
const appShellRef = useRef<HTMLDivElement>(null);
const sidebarCollapsedRef = useRef(sidebarCollapsed);
@@ -142,33 +146,6 @@ export function useAppShellRuntime() {
autoCollapsedSidebarRef.current = true;
setSidebarCollapsed(true);
}, []);
- // Keep the exit flag in sync with the collapsed state so collapsing plays
- // the sidebar-out keyframe and expanding cancels it (mirrors the work-panel
- // mount-then-animate-then-unmount machine).
- //
- // This is adjusted during render, not in an effect. An effect runs after the
- // commit, so the collapsing render would evaluate `!collapsed || exiting` as
- // `false || false` and unmount the dock outright; the effect then remounts it
- // with `is-exiting`. That paints one frame with no dock at all — the whole
- // sidebar blinks out and back before the collapse keyframe even starts.
- const prevSidebarCollapsed = useRef(sidebarCollapsed);
- if (prevSidebarCollapsed.current !== sidebarCollapsed) {
- prevSidebarCollapsed.current = sidebarCollapsed;
- setSidebarExiting(sidebarCollapsed);
- }
- const handleSidebarAnimationEnd = (event: ReactAnimationEvent<HTMLElement>) => {
- if (event.target !== event.currentTarget) return;
- if (!sidebarExiting) return;
- if (!event.animationName.startsWith("sidebar-out")) return;
- setSidebarExiting(false);
- };
-
- // Fallback in case animationend is skipped (e.g. display:none mid-flight).
- useEffect(() => {
- if (!sidebarExiting) return;
- const timer = window.setTimeout(() => setSidebarExiting(false), 240);
- return () => window.clearTimeout(timer);
- }, [sidebarExiting]);
const [presentedWorkPanelOpen, setPresentedWorkPanelOpen] = useState(false);
const [workPanelMaximized, setWorkPanelMaximized] = useState(false);
const [workPanelExiting, setWorkPanelExiting] = useState(false);
@@ -860,6 +837,7 @@ export function useAppShellRuntime() {
setSearchOpen,
sidebarCollapsed,
setSidebarCollapsed,
+ sidebarEntering,
sidebarExiting,
sidebarWidth,
handleSidebarWidthChange,
diff --git a/apps/desktop/src/features/app/useSidebarTransition.ts b/apps/desktop/src/features/app/useSidebarTransition.ts
new file mode 100644
index 000000000..56f7526c3
--- /dev/null
+++ b/apps/desktop/src/features/app/useSidebarTransition.ts
@@ -0,0 +1,46 @@
+import { useEffect, useState, type AnimationEvent } from "react";
+
+type SidebarTransition = {
+ collapsed: boolean;
+ presented: boolean;
+ phase: "idle" | "entering" | "exiting";
+};
+
+export function nextSidebarTransition(
+ previous: SidebarTransition,
+ collapsed: boolean,
+ presented: boolean,
+): SidebarTransition {
+ if (previous.collapsed === collapsed && previous.presented === presented) return previous;
+ const phase = presented && previous.presented && previous.collapsed !== collapsed
+ ? collapsed ? "exiting" : "entering"
+ : "idle";
+ return { collapsed, presented, phase };
+}
+
+export function useSidebarTransition(collapsed: boolean, presented: boolean) {
+ const [transition, setTransition] = useState<SidebarTransition>({ collapsed, presented, phase: "idle" });
+ const current = nextSidebarTransition(transition, collapsed, presented);
+ if (current !== transition) setTransition(current);
+
+ useEffect(() => {
+ if (current.phase === "idle") return;
+ const timer = window.setTimeout(() => {
+ setTransition((state) => state === current ? { ...state, phase: "idle" } : state);
+ }, 240);
+ return () => window.clearTimeout(timer);
+ }, [current]);
+
+ const handleSidebarAnimationEnd = (event: AnimationEvent<HTMLElement>) => {
+ if (event.target !== event.currentTarget) return;
+ const expected = current.phase === "entering" ? "sidebar-in" : "sidebar-out";
+ if (current.phase === "idle" || !event.animationName.startsWith(expected)) return;
+ setTransition((state) => state === current ? { ...state, phase: "idle" } : state);
+ };
+
+ return {
+ sidebarEntering: current.phase === "entering",
+ sidebarExiting: current.phase === "exiting",
+ handleSidebarAnimationEnd,
+ };
+}
diff --git a/apps/desktop/src/features/settings/SettingsPage.tsx b/apps/desktop/src/features/settings/SettingsPage.tsx
index 4649229d1..a93b84ee2 100644
--- a/apps/desktop/src/features/settings/SettingsPage.tsx
+++ b/apps/desktop/src/features/settings/SettingsPage.tsx
@@ -226,7 +226,7 @@ export function SettingsPage() {
return (
<div className="settings-shell settings-shell-full">
<div className="settings-titlebar" aria-hidden="true" />
- <aside className="settings-nav" aria-label={t("settings.title")}>
+ <aside className="settings-nav sidebar-surface" aria-label={t("settings.title")}>
<div className="settings-nav-top drag">
<div className="settings-search-wrap no-drag">
<IconSearch size={14} />
diff --git a/apps/desktop/src/styles/chat-shell.css b/apps/desktop/src/styles/chat-shell.css
index 9e447d682..71e4fb6dd 100644
--- a/apps/desktop/src/styles/chat-shell.css
+++ b/apps/desktop/src/styles/chat-shell.css
@@ -165,7 +165,7 @@
}
.route-surface,
-.settings-shell-full {
+.settings-content-inner {
animation: route-surface-in var(--motion-duration-normal) var(--motion-ease-out)
both;
}
diff --git a/apps/desktop/src/styles/chrome.css b/apps/desktop/src/styles/chrome.css
index d54e90dd7..d87c80afb 100644
--- a/apps/desktop/src/styles/chrome.css
+++ b/apps/desktop/src/styles/chrome.css
@@ -11,7 +11,8 @@
:root[data-platform="darwin"],
:root[data-platform="darwin"] body,
:root[data-platform="darwin"] #root,
-:root[data-platform="darwin"] .app-shell {
+:root[data-platform="darwin"] .app-shell,
+:root[data-platform="darwin"] .settings-shell {
background: transparent;
}
@@ -32,8 +33,7 @@
/*
* On macOS the splash is glass, so the shell that mounts under it as soon as
* `ready` flips would bleed through the tint. Hide it until the exit fade,
- * then cross-fade with a transition — not an animation, because `.sidebar`
- * owns `sidebar-in` and swapping animation-name would replay it after boot.
+ * then cross-fade without replaying the dock's explicit toggle animation.
*/
:root[data-platform="darwin"] .app-shell.is-booting:has(.startup-splash:not(.is-exiting))
> :not(.startup-splash) {
@@ -187,6 +187,14 @@
}
}
+.sidebar-surface,
+.sidebar-rail {
+ background-color: var(--ds-bg-sidebar, var(--ds-bg-primary));
+ background-image: var(--ds-bg-sidebar-image, none);
+ background-repeat: no-repeat;
+ background-size: cover;
+}
+
.sidebar {
width: var(--ds-sidebar-width);
min-width: 0;
@@ -198,17 +206,9 @@
flex-direction: column;
overflow: hidden;
position: relative;
- background-color: var(--ds-bg-sidebar, var(--ds-bg-primary));
- background-image: var(--ds-bg-sidebar-image, none);
- background-repeat: no-repeat;
- background-size: cover;
- /* No seam against the main pane (D297): the sidebar's own surface tone is
- the only edge cue on every platform, as it already was on macOS glass. */
- /*
- * Animate the flex allocation with the dock motion. A transform-only
- * animation leaves MainChat at its final width before the first frame,
- * making sidebar collapse feel like a layout jump.
- */
+}
+
+.sidebar.is-entering {
animation: sidebar-in var(--motion-duration-normal) var(--motion-ease-out) both;
}
@@ -339,10 +339,6 @@
flex: 0 0 56px;
display: flex;
flex-direction: column;
- background-color: var(--ds-bg-sidebar, var(--ds-bg-primary));
- background-image: var(--ds-bg-sidebar-image, none);
- background-repeat: no-repeat;
- background-size: cover;
}
/*
@@ -353,7 +349,7 @@
* The main pane and titlebars remain opaque `bg-primary`.
*/
:root[data-platform="darwin"] .startup-splash,
-:root[data-platform="darwin"] .sidebar,
+:root[data-platform="darwin"] .sidebar-surface,
:root[data-platform="darwin"] .sidebar-rail {
background-color: var(--ds-sidebar-glass-tint);
background-image: var(--ds-bg-sidebar-image, none),
diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.css
index 57f414636..34c05bcea 100644
--- a/apps/desktop/src/styles/settings.css
+++ b/apps/desktop/src/styles/settings.css
@@ -47,7 +47,6 @@
width: var(--ds-settings-nav-width);
flex: 0 0 var(--ds-settings-nav-width);
/* D297: no right rule; the rail's own tone separates it from the content. */
- background: var(--ds-settings-rail-bg);
padding: 0;
gap: 0;
overflow: hidden;
diff --git a/apps/desktop/src/styles/tokens.css b/apps/desktop/src/styles/tokens.css
index e3241e727..2e7e71537 100644
--- a/apps/desktop/src/styles/tokens.css
+++ b/apps/desktop/src/styles/tokens.css
@@ -36,7 +36,8 @@
--accent-900: #303030;
--ds-bg-primary: var(--gray-900);
- --ds-bg-sidebar: var(--ds-bg-under); /* Codex surface-under / sideBar */
+ --ds-settings-rail-bg: var(--ds-bg-under);
+ --ds-bg-sidebar: var(--ds-settings-rail-bg, var(--ds-bg-under));
/*
* Optional paint layer for the sidebar surface (gradients / images).
* `--ds-bg-sidebar` stays a color so color-mix, borders, and macOS glass
@@ -104,8 +105,7 @@
--ds-accent-soft: var(--gray-300);
/* Focus rings / resize affordances. Tied to the accent so themes stay monochrome. */
--ds-focus: var(--ds-accent);
- /* Settings rail and shared inset searches keep their built-in surface tones. */
- --ds-settings-rail-bg: #000000;
+ /* Settings fields and shared inset searches keep their built-in tones. */
--ds-settings-field-bg: #212121;
--ds-settings-nav-active: color-mix(in oklab, var(--gray-0) 10%, transparent);
--ds-field-inset-bg: color-mix(in oklab, var(--ds-text-primary) 5%, transparent);
@@ -208,7 +208,8 @@
color-scheme: light;
/* Codex electron-light */
--ds-bg-primary: #ffffff;
- --ds-bg-sidebar: #f3f3f3;
+ --ds-settings-rail-bg: #f3f3f3;
+ --ds-bg-sidebar: var(--ds-settings-rail-bg, #f3f3f3);
--ds-bg-secondary: #f9f9f9;
--ds-bg-tertiary: #f3f3f3;
--ds-bg-inset: #ededed;
@@ -242,7 +243,6 @@
--ds-accent-hover: #303030;
--ds-accent-soft: #5d5d5d;
--ds-focus: var(--ds-accent);
- --ds-settings-rail-bg: #f4f4f4;
--ds-settings-field-bg: #ffffff;
--ds-settings-nav-active: color-mix(in oklab, #1a1c1f 12%, #ffffff);
--ds-field-inset-bg: #f3f3f3;
diff --git a/apps/desktop/test/macos-sidebar-vibrancy.test.mjs b/apps/desktop/test/macos-sidebar-vibrancy.test.mjs
index 957775f6e..004fbebfb 100644
--- a/apps/desktop/test/macos-sidebar-vibrancy.test.mjs
+++ b/apps/desktop/test/macos-sidebar-vibrancy.test.mjs
@@ -99,7 +99,7 @@ test("native theme source maps preferences and only resets vibrancy on change",
test("the macOS startup splash shares the sidebar glass tint and sheen", () => {
const macGlassBlock =
stylesSource.match(
- /:root\[data-platform="darwin"\] \.startup-splash,\n:root\[data-platform="darwin"\] \.sidebar,\n:root\[data-platform="darwin"\] \.sidebar-rail\s*\{[^}]*\}/,
+ /:root\[data-platform="darwin"\] \.startup-splash,\n:root\[data-platform="darwin"\] \.sidebar-surface,\n:root\[data-platform="darwin"\] \.sidebar-rail\s*\{[^}]*\}/,
)?.[0] ?? "";
assert.match(macGlassBlock, /background-color:\s*var\(--ds-sidebar-glass-tint\)/);
assert.match(macGlassBlock, /var\(--ds-sidebar-glass-sheen-top\)/);
@@ -113,10 +113,6 @@ test("the macOS startup splash shares the sidebar glass tint and sheen", () => {
assert.match(baseSplashBlock, /background:\s*var\(--ds-bg-primary\)/);
assert.doesNotMatch(baseSplashBlock, /glass/);
- // The shell mounts under the splash once `ready` flips; behind glass it must
- // stay hidden until the exit fade, then cross-fade in rather than bleed
- // through the tint. A transition, not an animation: `.sidebar` owns its
- // `sidebar-in` mount animation and swapping animation-name would replay it.
assert.match(
stylesSource,
/:root\[data-platform="darwin"\] \.app-shell\.is-booting:has\(\.startup-splash:not\(\.is-exiting\)\)\s*>\s*:not\(\.startup-splash\)\s*\{\s*visibility:\s*hidden;/,
@@ -130,7 +126,7 @@ test("the macOS startup splash shares the sidebar glass tint and sheen", () => {
test("only macOS sidebar and splash surfaces receive the translucent glass treatment", () => {
const macGlassBlock =
stylesSource.match(
- /:root\[data-platform="darwin"\] \.startup-splash,\n:root\[data-platform="darwin"\] \.sidebar,\n:root\[data-platform="darwin"\] \.sidebar-rail\s*\{[^}]*\}/,
+ /:root\[data-platform="darwin"\] \.startup-splash,\n:root\[data-platform="darwin"\] \.sidebar-surface,\n:root\[data-platform="darwin"\] \.sidebar-rail\s*\{[^}]*\}/,
)?.[0] ?? "";
assert.match(macGlassBlock, /background-color:\s*var\(--ds-sidebar-glass-tint\)/);
// Sheen, not a flat tint — this is what keeps the material reading as glass.
@@ -145,7 +141,7 @@ test("only macOS sidebar and splash surfaces receive the translucent glass treat
const macAncestorBlock =
stylesSource.match(
- /:root\[data-platform="darwin"\],\n:root\[data-platform="darwin"\] body,\n:root\[data-platform="darwin"\] #root,\n:root\[data-platform="darwin"\] \.app-shell\s*\{[^}]*\}/,
+ /:root\[data-platform="darwin"\],\n:root\[data-platform="darwin"\] body,\n:root\[data-platform="darwin"\] #root,\n:root\[data-platform="darwin"\] \.app-shell,\n:root\[data-platform="darwin"\] \.settings-shell\s*\{[^}]*\}/,
)?.[0] ?? "";
assert.match(macAncestorBlock, /background:\s*transparent/);
diff --git a/apps/desktop/test/sidebar-settings-return.test.mjs b/apps/desktop/test/sidebar-settings-return.test.mjs
new file mode 100644
index 000000000..43c62cde0
--- /dev/null
+++ b/apps/desktop/test/sidebar-settings-return.test.mjs
@@ -0,0 +1,63 @@
+import assert from "node:assert/strict";
+import { readFile } from "node:fs/promises";
+import test from "node:test";
+import { nextSidebarTransition } from "../src/features/app/useSidebarTransition.ts";
+import { loadStyles } from "./helpers/styles.mjs";
+
+const idle = (collapsed = false, presented = true) => ({ collapsed, presented, phase: "idle" });
+
+test("initial shell presentation and settings return never play sidebar entrance", () => {
+ assert.deepEqual(nextSidebarTransition(idle(false, false), false, true), idle());
+ for (const collapsed of [false, true]) {
+ const hidden = nextSidebarTransition(idle(collapsed), collapsed, false);
+ assert.deepEqual(hidden, idle(collapsed, false));
+ assert.deepEqual(nextSidebarTransition(hidden, collapsed, true), idle(collapsed));
+ }
+});
+
+test("only a collapsed-state change on a presented shell animates", () => {
+ const leaving = nextSidebarTransition(idle(), true, true);
+ assert.equal(leaving.phase, "exiting");
+ assert.strictEqual(nextSidebarTransition(leaving, true, true), leaving);
+ const reopening = nextSidebarTransition(leaving, false, true);
+ assert.equal(reopening.phase, "entering");
+ assert.equal(nextSidebarTransition(reopening, true, true).phase, "exiting");
+ assert.equal(nextSidebarTransition(idle(true), false, true).phase, "entering");
+});
+
+test("settings interrupts either phase and rapid return cannot replay it", () => {
+ for (const phase of ["entering", "exiting"]) {
+ const collapsed = phase === "exiting";
+ const hidden = nextSidebarTransition({ collapsed, presented: true, phase }, collapsed, false);
+ assert.equal(hidden.phase, "idle");
+ assert.equal(nextSidebarTransition(hidden, collapsed, true).phase, "idle");
+ }
+ const restoredWhileHidden = nextSidebarTransition(idle(true, false), false, false);
+ assert.deepEqual(restoredWhileHidden, idle(false, false));
+ assert.deepEqual(nextSidebarTransition(restoredWhileHidden, false, true), idle());
+ assert.deepEqual(nextSidebarTransition(idle(true, false), false, true), idle());
+});
+
+test("home and settings use the same material without animating the settings plate", async () => {
+ const [styles, sidebar, settings] = await Promise.all([
+ loadStyles(),
+ readFile(new URL("../src/components/Sidebar.tsx", import.meta.url), "utf8"),
+ readFile(new URL("../src/features/settings/SettingsPage.tsx", import.meta.url), "utf8"),
+ ]);
+ assert.match(sidebar, /cx\("sidebar", "sidebar-surface", className\)/);
+ assert.match(settings, /className="settings-nav sidebar-surface"/);
+ assert.match(styles, /\.sidebar-surface,\s*\.sidebar-rail\s*\{[^}]*background-color:\s*var\(--ds-bg-sidebar[^}]*background-image:\s*var\(--ds-bg-sidebar-image/);
+ assert.match(styles, /:root\[data-platform="darwin"\] \.sidebar-surface,/);
+ assert.match(styles, /:root\[data-platform="darwin"\] \.settings-shell\s*\{\s*background:\s*transparent;/);
+ for (const selector of ["settings-content", "settings-titlebar"]) {
+ assert.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.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\)/);
+ assert.match(styles, /--ds-settings-rail-bg:\s*var\(--ds-bg-under\)/);
+ assert.match(styles, /--ds-settings-rail-bg:\s*#f3f3f3/);
+ assert.doesNotMatch(styles, /--ds-settings-rail-bg:\s*var\(--ds-bg-sidebar/);
+});
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index 1d6e94c59..dc5175eb9 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -10,7 +10,16 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (
shows a compact loading/failure state with a retry action instead of an empty
section.
-- Left settings rail only (sidebar surface `#f4f4f4` light / `#000` dark), **~275px** (Codex gold at 1200-wide)
+- Left settings rail only, **275px**, using the same `sidebar-surface` material
+ 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.
+- 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;
+ initial presentation and route restoration do not.
- Top of rail: traffic-light clearance and the pill **Search settings…**
- The **Back to app** (`返回应用`) action is pinned to the foot of the rail, not
the top: it keeps its chevron + label form as a 32px control, and it shares
@@ -692,7 +701,7 @@ the current window width:
| Token | Value |
|---|---|
| Rail width | ~275px (`--ds-settings-nav-width`, shared by the rail and the top band inset) |
-| Rail light bg | `#f4f4f4` |
+| Rail surface | Shared sidebar material; light opaque fallback `#f3f3f3`, native glass on macOS |
| Top band | content pane only, inset by the rail width; rail keeps its own surface |
| Active nav pill | denser 6px/10px pad, ~8px radius, gray mix on rail |
| Section title | 28px / 560, first baseline ~y70 |
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 89986a485..d667d398f 100644
--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md
+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md
@@ -7,7 +7,12 @@
设置是一个**全窗口页面**,取代了应用程序侧边栏+主镶边(Codex 电子行为):
-- 仅左侧设置导轨(侧边栏表面 `#f4f4f4` 浅色/`#000` 深色),**~275px**(Codex 金色,宽度为 1200)
+- 左侧设置导航宽 **275px**,与主侧栏共享 `sidebar-surface` 材质:macOS 使用原生
+ vibrancy 加相同 tint/sheen,Windows/Linux 使用不透明 `--ds-bg-sidebar`,并共享可选背景图。
+ macOS 下设置外壳透明,右侧内容区与顶部条仍不透明。只有内容区内部播放路由入场,
+ 导航背景本身不淡入、不位移。
+- 返回应用直接恢复原来的侧栏折叠/展开状态,不播放入场动画或从零宽度展开。
+ 可见主界面中的真实开关和自动折叠/恢复仍播放动画;首次显示和路由恢复不触发。
- 导轨顶部:交通灯区域和**搜索设置...**药丸
- **返回应用程序**(`返回应用`)固定在导轨底部而不是顶部:保留箭头+文字形式,作为
32px 控件与主外壳侧边栏底部图标行(设置/插件/通知)处于同一条水平带上,
@@ -350,7 +355,7 @@ Token 用量**不是设置目的地**(D335 / ADR 0173)。已完成回合历
| 代币 | 价值 |
|---|---|
| 导轨宽度 | 〜275像素(`--ds-settings-nav-width`,由导轨与顶部带的内缩共用) |
-| 轨道灯背景 | `#f4f4f4` |
+| 导航背景 | 与主侧栏共享材质;浅色不透明回退为 `#f3f3f3`,macOS 使用原生毛玻璃 |
| 顶部带 | 仅内容窗格,按导轨宽度内缩;导轨保留自己的表面 |
| 主动导航药丸 | 更密集的 6px/10px 焊盘,~8px 半径,轨道上的灰色混合 |
| 章节标题 | 28px / 560,第一条基线 ~y70 |
diff --git a/scripts/e2e-theme-surfaces.mjs b/scripts/e2e-theme-surfaces.mjs
index f3893d693..ca466c9c0 100644
--- a/scripts/e2e-theme-surfaces.mjs
+++ b/scripts/e2e-theme-surfaces.mjs
@@ -20,7 +20,7 @@ try {
assert(css.length, "Build the app with pnpm build:js before running this check");
await cp(join(renderer, "assets"), join(temp, "assets"), { recursive: true });
await writeFile(join(temp, "index.html"), `<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self' data:"><title>Theme surface regression</title>${css.map((path) => `<link rel="stylesheet" href="${path}">`).join("")}<style>body { padding: 32px; display: flex; gap: 32px; align-items: flex-start; } .fixture-controls { width: 420px; display: grid; gap: 24px; } .fixture-prose { width: 420px; display: grid; gap: 12px; } .settings-shell-full { width: 275px; height: 340px; } .settings-toggle { margin: 20px; } /* The veils are fixed full-screen layers in the app; keep them in flow here so they do not cover the other fixtures. Only position changes, never the paint. */ .fixture-controls .overlay, .fixture-controls .plugins-modal-backdrop { position: static; inset: auto; padding: 12px; animation: none; }</style><body>
- <section class="settings-shell-full"><nav class="settings-nav"><div class="settings-nav-top"><input class="settings-search" placeholder="Search settings"></div><div class="settings-nav-scroll"><button class="settings-nav-item active">General</button><button class="settings-nav-item">Appearance</button><button class="settings-toggle on" aria-label="Enabled"><span class="settings-toggle-thumb"></span></button></div></nav></section>
+ <section class="settings-shell-full"><nav class="settings-nav sidebar-surface"><div class="settings-nav-top"><input class="settings-search" placeholder="Search settings"></div><div class="settings-nav-scroll"><button class="settings-nav-item active">General</button><button class="settings-nav-item">Appearance</button><button class="settings-toggle on" aria-label="Enabled"><span class="settings-toggle-thumb"></span></button></div></nav></section>
<section class="fixture-controls"><div class="composer-shell">Composer surface</div><input class="plugins-search" placeholder="Search plugins"><div class="agent-capability-search-wrap"><input class="agent-capability-search" placeholder="Search capabilities"></div><div class="overlay">Dialog scrim</div><div class="plugins-modal-backdrop">Permission veil</div></section>
<section class="fixture-controls"><div class="composer-stack"><section class="asktool-card"><div class="asktool-card-header"><span class="asktool-card-title">Question</span></div><button class="asktool-option">Blue</button><button class="asktool-option selected">Green</button><input class="asktool-custom-input" placeholder="Other" aria-label="Other"></section></div></section>
<section class="fixture-prose"><div class="prose-chat"><p>Answer prose with a <kbd>K</kbd> keycap and an <code>inline chip</code>.</p></div><div class="thinking-prose"><code>thinking code</code></div><div class="code-block-head">Code card head band</div><div class="mermaid-block-body">Mermaid canvas</div><button class="send-btn" disabled>Send</button></section>
diff --git a/scripts/e2e/sidebar-settings.mjs b/scripts/e2e/sidebar-settings.mjs
new file mode 100644
index 000000000..f2d123d23
--- /dev/null
+++ b/scripts/e2e/sidebar-settings.mjs
@@ -0,0 +1,219 @@
+import { mkdir, writeFile } from "node:fs/promises";
+import { join } from "node:path";
+import { setTimeout as delay } from "node:timers/promises";
+
+export async function checkSidebarSettings({ cdp, check, waitFor, artifactDir }) {
+ const original = await cdp.evaluate(`({
+ platform: document.documentElement.dataset.platform,
+ theme: document.documentElement.dataset.theme,
+ style: document.documentElement.getAttribute('style'),
+ })`);
+ const capture = async (name) => {
+ if (!artifactDir) return;
+ await mkdir(artifactDir, { recursive: true });
+ const image = await cdp.send("Page.captureScreenshot", { format: "png", captureBeyondViewport: false });
+ await writeFile(join(artifactDir, `${name}.png`), Buffer.from(image.data, "base64"));
+ };
+ const click = async (selector) => {
+ let target;
+ await waitFor(async () => {
+ target = await cdp.evaluate(`(() => {
+ const el = document.querySelector(${JSON.stringify(selector)});
+ if (!el) return null;
+ el.scrollIntoView({ block: 'nearest' });
+ const rect = el.getBoundingClientRect();
+ const x = Math.round(rect.left + rect.width / 2);
+ const y = Math.round(rect.top + rect.height / 2);
+ const hit = document.elementFromPoint(x, y);
+ return { x, y, hit: hit === el || el.contains(hit) };
+ })()`);
+ return target?.hit;
+ }, `settings probe target: ${selector}`);
+ for (const type of ["mousePressed", "mouseReleased"]) {
+ await cdp.send("Input.dispatchMouseEvent", {
+ type, x: target.x, y: target.y, button: "left",
+ buttons: type === "mousePressed" ? 1 : 0, clickCount: 1,
+ });
+ }
+ };
+ const settingsShortcut = async () => {
+ for (const type of ["keyDown", "keyUp"]) {
+ await cdp.send("Input.dispatchKeyEvent", {
+ type, key: ",", code: "Comma", windowsVirtualKeyCode: 188,
+ modifiers: original.platform === "darwin" ? 4 : 2,
+ });
+ }
+ };
+ const material = (selector) => cdp.evaluate(`(() => {
+ const el = document.querySelector(${JSON.stringify(selector)});
+ const style = getComputedStyle(el);
+ const rect = el.getBoundingClientRect();
+ const ancestors = [];
+ for (let parent = el.parentElement; parent; parent = parent.parentElement) {
+ ancestors.push(getComputedStyle(parent).backgroundColor);
+ }
+ return {
+ color: style.backgroundColor, image: style.backgroundImage,
+ size: style.backgroundSize, repeat: style.backgroundRepeat,
+ animation: style.animationName, opacity: style.opacity,
+ width: rect.width, height: rect.height, top: rect.top, ancestors,
+ content: getComputedStyle(document.querySelector('.settings-content, .main-pane')).backgroundColor,
+ titlebar: document.querySelector('.settings-titlebar')
+ ? getComputedStyle(document.querySelector('.settings-titlebar')).backgroundColor : null,
+ shellAnimation: document.querySelector('.settings-shell')
+ ? getComputedStyle(document.querySelector('.settings-shell')).animationName : null,
+ };
+ })()`);
+ const startTrace = async () => {
+ await cdp.evaluate(`(() => {
+ window.__settingsSidebarTrace?.stop();
+ const trace = { frames: [], animations: [] };
+ const sample = () => {
+ const el = document.querySelector('.sidebar');
+ if (el) trace.frames.push({ width: el.getBoundingClientRect().width,
+ animation: getComputedStyle(el).animationName });
+ };
+ const observer = new MutationObserver(sample);
+ observer.observe(document.querySelector('.app-shell'), { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });
+ const onStart = event => {
+ if (event.target.matches('.sidebar')) trace.animations.push(event.animationName);
+ };
+ document.addEventListener('animationstart', onStart, true);
+ trace.stop = () => { observer.disconnect(); document.removeEventListener('animationstart', onStart, true); };
+ window.__settingsSidebarTrace = trace;
+ })()`);
+ };
+ const finishTrace = async () => {
+ for (let i = 0; i < 24; i++) {
+ await cdp.evaluate(`(() => {
+ const el = document.querySelector('.sidebar');
+ if (el) window.__settingsSidebarTrace.frames.push({ width: el.getBoundingClientRect().width,
+ animation: getComputedStyle(el).animationName });
+ })()`);
+ await delay(10);
+ }
+ return cdp.evaluate(`(() => {
+ const trace = window.__settingsSidebarTrace;
+ trace.stop();
+ return { frames: trace.frames, animations: trace.animations };
+ })()`);
+ };
+ const returnToApp = async (width, label, collapsed = false) => {
+ await startTrace();
+ await click('[data-nav="back-to-app"]');
+ await waitFor(() => cdp.evaluate("!document.querySelector('.settings-shell')"), "settings closes");
+ const trace = await finishTrace();
+ check(
+ trace.animations.length === 0 && (collapsed
+ ? trace.frames.length === 0
+ : trace.frames.length > 0 && trace.frames.every(frame => Math.abs(frame.width - width) < 0.5 && frame.animation === "none")),
+ `${label}: settings return restores layout without sidebar entrance`,
+ JSON.stringify({ animations: trace.animations, widths: trace.frames.map(frame => Math.round(frame.width)) }),
+ );
+ };
+ const toggle = '[data-nav="toggle-sidebar"]';
+
+ try {
+ await cdp.evaluate("window.dispatchEvent(new Event('focus'))");
+ for (const platform of ["darwin", "win32", "linux"]) {
+ for (const theme of ["dark", "light"]) {
+ await cdp.evaluate(`Object.assign(document.documentElement.dataset, ${JSON.stringify({ platform, theme })})`);
+ const home = await material('.sidebar');
+ if (platform === original.platform) await capture(`home-${theme}`);
+ await click('[data-nav="settings"]');
+ await waitFor(() => cdp.evaluate("!!document.querySelector('.settings-nav')"), "settings rail mounts");
+ const settings = await material('.settings-nav');
+ check(
+ ["color", "image", "size", "repeat", "width", "height", "top"].every(key => home[key] === settings[key]) &&
+ settings.animation === "none" && settings.shellAnimation === "none" && settings.opacity === "1",
+ `${platform}/${theme}: home and settings share one stationary sidebar material`,
+ JSON.stringify({ home, settings }),
+ );
+ check(
+ settings.content === home.content && settings.titlebar === home.content &&
+ (platform !== "darwin" || settings.ancestors.every(color => color === "rgba(0, 0, 0, 0)")),
+ `${platform}/${theme}: sidebar ancestry reveals material while content and titlebar stay opaque`,
+ JSON.stringify(settings),
+ );
+ if (platform === original.platform) {
+ await delay(250);
+ await capture(`settings-${theme}`);
+ }
+ await returnToApp(home.width, `${platform}/${theme}`);
+ }
+ }
+
+ await cdp.evaluate(`document.documentElement.dataset.platform = ${JSON.stringify(original.platform)}`);
+ for (const theme of ["dark", "light"]) {
+ await cdp.evaluate(`document.documentElement.dataset.theme = ${JSON.stringify(theme)}`);
+ for (const kind of ["legacy", "canonical"]) {
+ await cdp.evaluate(`(() => {
+ const root = document.documentElement;
+ root.style.setProperty('--ds-settings-rail-bg', '#243645');
+ if (${JSON.stringify(kind)} === 'canonical') root.style.setProperty('--ds-bg-sidebar', '#39563d');
+ root.style.setProperty('--ds-bg-sidebar-image', 'linear-gradient(180deg, #243645, #39563d)');
+ })()`);
+ const home = await material('.sidebar');
+ await click('[data-nav="settings"]');
+ await waitFor(() => cdp.evaluate("!!document.querySelector('.settings-nav')"), "custom-theme settings mounts");
+ const settings = await material('.settings-nav');
+ const effective = await cdp.evaluate("getComputedStyle(document.documentElement).getPropertyValue('--ds-bg-sidebar').trim()");
+ check(
+ home.color === settings.color && home.image === settings.image &&
+ effective === (kind === "legacy" ? "#243645" : "#39563d"),
+ `${theme}/${kind}: theme colors and images affect both rails, canonical token wins`,
+ JSON.stringify({ home: home.color, settings: settings.color, image: settings.image, effective }),
+ );
+ await returnToApp(home.width, `${theme}/${kind}`);
+ }
+ await cdp.evaluate(`(() => {
+ for (const name of ['--ds-settings-rail-bg', '--ds-bg-sidebar', '--ds-bg-sidebar-image'])
+ document.documentElement.style.removeProperty(name);
+ })()`);
+ }
+
+ const width = (await material('.sidebar')).width;
+ for (let i = 0; i < 3; i++) {
+ await click('[data-nav="settings"]');
+ await waitFor(() => cdp.evaluate("!!document.querySelector('.settings-nav')"), "rapid settings navigation");
+ await returnToApp(width, `rapid round trip ${i + 1}`);
+ }
+
+ await click(toggle);
+ await waitFor(() => cdp.evaluate("!document.querySelector('.sidebar')"), "manual collapse completes");
+ await settingsShortcut();
+ await waitFor(() => cdp.evaluate("!!document.querySelector('.settings-nav')"), "settings opens with sidebar collapsed");
+ await returnToApp(width, "collapsed sidebar", true);
+ await startTrace();
+ await click('.ct-lead .ct-icon-btn');
+ const expanded = await finishTrace();
+ check(
+ expanded.animations.includes("sidebar-in") && expanded.frames.some(frame => frame.width > 0 && frame.width < width - 1) &&
+ Math.abs(expanded.frames.at(-1).width - width) < 0.5,
+ "explicit reopen still plays sidebar entrance and restores full width",
+ JSON.stringify({ animations: expanded.animations, widths: expanded.frames.map(frame => Math.round(frame.width)) }),
+ );
+
+ await click(toggle);
+ await waitFor(() => cdp.evaluate("!document.querySelector('.sidebar')"), "collapse before interrupted entrance");
+ await click('.ct-lead .ct-icon-btn');
+ await settingsShortcut();
+ await waitFor(() => cdp.evaluate("!!document.querySelector('.settings-nav')"), "settings interrupts entrance");
+ await returnToApp(width, "interrupted entrance");
+
+ await cdp.send("Emulation.setEmulatedMedia", { features: [{ name: "prefers-reduced-motion", value: "reduce" }] });
+ await click('[data-nav="settings"]');
+ await waitFor(() => cdp.evaluate("!!document.querySelector('.settings-nav')"), "reduced-motion settings");
+ await returnToApp(width, "reduced motion");
+ } finally {
+ await cdp.send("Emulation.setEmulatedMedia", { features: [] });
+ await cdp.evaluate(`(() => {
+ window.__settingsSidebarTrace?.stop();
+ delete window.__settingsSidebarTrace;
+ const root = document.documentElement;
+ root.dataset.platform = ${JSON.stringify(original.platform)};
+ root.dataset.theme = ${JSON.stringify(original.theme)};
+ ${original.style === null ? "root.removeAttribute('style')" : `root.setAttribute('style', ${JSON.stringify(original.style)})`};
+ })()`);
+ }
+}
diff --git a/scripts/e2e/theme-surfaces.js b/scripts/e2e/theme-surfaces.js
index 09ff1d506..2c491532d 100644
--- a/scripts/e2e/theme-surfaces.js
+++ b/scripts/e2e/theme-surfaces.js
@@ -1,6 +1,6 @@
/** Real CSS cascade probe; fixture classes use the built app's complete stylesheet. */
-// Built-in sRGB paint and shadows sampled from the pre-fix a9053531 app.
-const DEFAULT_RGBA = {"light":{"rail":[244,244,244,255],"search":[255,255,255,255],"active":[224,224,225,255],"knob":[255,255,255,255],"composer":[255,255,255,255],"pluginSearch":[243,243,243,255],"capabilitySearch":[243,243,243,255],"pluginFocus":[255,255,255,255],"capabilityFocus":[255,255,255,255],"scrim":[25,29,32,71],"modalVeil":[25,28,31,82],"toolRow":[51,51,51,5],"toolRowPlain":[51,51,51,5],"toolRowError":[51,51,51,5],"codeHead":[28,28,28,9],"mermaidCanvas":[255,255,255,255],"thinkingCode":[240,240,240,255],"sendDisabled":[142,142,144,255],"kbd":[26,26,26,20]},"dark":{"rail":[0,0,0,255],"search":[33,33,33,255],"active":[255,255,255,26],"knob":[24,24,24,255],"composer":[33,33,33,245],"pluginSearch":[255,255,255,13],"capabilitySearch":[255,255,255,13],"pluginFocus":[255,255,255,18],"capabilityFocus":[255,255,255,18],"scrim":[0,0,0,115],"modalVeil":[24,24,24,199],"toolRow":[255,255,255,9],"toolRowPlain":[0,0,0,0],"toolRowError":[255,99,99,18],"codeHead":[255,255,255,10],"mermaidCanvas":[35,35,35,255],"thinkingCode":[255,255,255,11],"sendDisabled":[255,255,255,46],"kbd":[255,255,255,20]}};
+// Built-in sRGB paint; the settings rail shares the sidebar's opaque fallback.
+const DEFAULT_RGBA = {"light":{"rail":[243,243,243,255],"search":[255,255,255,255],"active":[224,224,225,255],"knob":[255,255,255,255],"composer":[255,255,255,255],"pluginSearch":[243,243,243,255],"capabilitySearch":[243,243,243,255],"pluginFocus":[255,255,255,255],"capabilityFocus":[255,255,255,255],"scrim":[25,29,32,71],"modalVeil":[25,28,31,82],"toolRow":[51,51,51,5],"toolRowPlain":[51,51,51,5],"toolRowError":[51,51,51,5],"codeHead":[28,28,28,9],"mermaidCanvas":[255,255,255,255],"thinkingCode":[240,240,240,255],"sendDisabled":[142,142,144,255],"kbd":[26,26,26,20]},"dark":{"rail":[0,0,0,255],"search":[33,33,33,255],"active":[255,255,255,26],"knob":[24,24,24,255],"composer":[33,33,33,245],"pluginSearch":[255,255,255,13],"capabilitySearch":[255,255,255,13],"pluginFocus":[255,255,255,18],"capabilityFocus":[255,255,255,18],"scrim":[0,0,0,115],"modalVeil":[24,24,24,199],"toolRow":[255,255,255,9],"toolRowPlain":[0,0,0,0],"toolRowError":[255,99,99,18],"codeHead":[255,255,255,10],"mermaidCanvas":[35,35,35,255],"thinkingCode":[255,255,255,11],"sendDisabled":[255,255,255,46],"kbd":[255,255,255,20]}};
const DEFAULT_SHADOWS = {"light":{"knob":"rgba(0, 0, 0, 0.22) 0px 1px 2px 0px","composer":"rgba(0, 0, 0, 0.04) 0px 3px 7.5px 0px, rgba(0, 0, 0, 0.05) 0px 0px 20px 0px","pluginFocus":"oklab(0.22559 -0.00131416 -0.00642684 / 0.35) 0px 0px 0px 1px","capabilityFocus":"oklab(0.22559 -0.00131416 -0.00642684 / 0.35) 0px 0px 0px 1px"},"dark":{"knob":"rgba(0, 0, 0, 0.16) 0px 1px 2px 0px","composer":"rgba(0, 0, 0, 0.04) 0px 3px 7.5px 0px, rgba(0, 0, 0, 0.05) 0px 0px 20px 0px","pluginFocus":"oklab(0.999994 0.0000455678 0.0000200868 / 0.45) 0px 0px 0px 1px","capabilityFocus":"oklab(0.999994 0.0000455678 0.0000200868 / 0.45) 0px 0px 0px 1px"}};
/**
* Surface entries are `[selector, token]` for a surface the token fills,