Skip to content

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

fix(sidebar): fold project groups as one continuous surface

ZeroYa6003e9194ef
diff --git a/apps/desktop/src/components/Sidebar.tsx b/apps/desktop/src/components/Sidebar.tsx
index 97c7ad97f..47dc2c6d5 100644
--- a/apps/desktop/src/components/Sidebar.tsx
+++ b/apps/desktop/src/components/Sidebar.tsx
@@ -1599,9 +1599,10 @@ export function Sidebar({
return (
<section
key={entry.key}
- className={`sidebar-session-group project-group ${entry.active ? "active" : ""} ${entry.meta.archived ? "archived" : ""} ${dropProjectKey === entry.key ? "is-drop-target" : ""} ${draggingProjectKey === entry.key ? "is-dragging" : ""} ${dropIndicator?.key === entry.key ? (dropIndicator.insertAfter ? "is-drop-after" : "is-drop-before") : ""}`}
+ className={`sidebar-session-group project-group ${entry.meta.archived ? "archived" : ""} ${dropProjectKey === entry.key ? "is-drop-target" : ""} ${draggingProjectKey === entry.key ? "is-dragging" : ""} ${dropIndicator?.key === entry.key ? (dropIndicator.insertAfter ? "is-drop-after" : "is-drop-before") : ""}`}
aria-labelledby={projectId}
data-sidebar-project-group={entry.key}
+ data-current-workspace={entry.active ? "true" : undefined}
onDragOver={(event) => {
onProjectDropTargetOver(event, entry);
}}
@@ -1732,10 +1733,15 @@ export function Sidebar({
className={`sidebar-session-group-body project ${collapsedProject ? "collapsed" : ""}`}
role="region"
aria-hidden={collapsedProject}
+ inert={collapsedProject ? true : undefined}
>
- {entry.sessions.length > 0 ? renderTimeGroupedSessions(visibleSessions) : (
- <div className="sidebar-session-empty">{t("nav.noProjectSessions")}</div>
- )}
+ <div className="sidebar-session-group-clip">
+ <div className="sidebar-session-group-list">
+ {entry.sessions.length > 0 ? renderTimeGroupedSessions(visibleSessions) : (
+ <div className="sidebar-session-empty">{t("nav.noProjectSessions")}</div>
+ )}
+ </div>
+ </div>
</div>
</section>
);
@@ -2004,7 +2010,7 @@ export function Sidebar({
return (
<aside
- className={cx("sidebar", className)}
+ className={cx("sidebar", "sidebar-surface", className)}
data-window-blur={windowFocused ? undefined : "true"}
onAnimationEnd={onAnimationEnd}
>
diff --git a/apps/desktop/src/styles/responsive.css b/apps/desktop/src/styles/responsive.css
index bcf7429e3..cedc07b9a 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-shell-full,
+ .settings-content-inner,
.jump-latest-btn,
.chat-error-notice,
.work-panel,
@@ -54,6 +54,16 @@
transition-duration: 0.01ms !important;
}
+ /* The project fold is a height change: keep both endpoints, drop the travel. */
+ .sidebar-session-group-body.project {
+ transition-duration: 0.01ms !important;
+ }
+
+ .thread-item,
+ .sidebar-session-group-header {
+ transition-duration: 0.01ms !important;
+ }
+
.route-pending-indicator {
animation: none;
border-color: var(--ds-text-muted);
diff --git a/apps/desktop/test/sidebar-collapse-animation.test.mjs b/apps/desktop/test/sidebar-collapse-animation.test.mjs
index 9e4f679ca..6bafcfbca 100644
--- a/apps/desktop/test/sidebar-collapse-animation.test.mjs
+++ b/apps/desktop/test/sidebar-collapse-animation.test.mjs
@@ -16,44 +16,27 @@ const topbarSource = await readFile(
const globalStyles = await loadStyles();
test("the sidebar forwards collapse-animation props to the aside element", () => {
- // The aside must accept a className (the exit flag) and an animation-end
- // callback so App can keep it mounted through the exit keyframe, then unmount.
- assert.match(sidebarSource, /cx\("sidebar", className\)/);
+ assert.match(sidebarSource, /cx\("sidebar", "sidebar-surface", className\)/);
assert.match(sidebarSource, /onAnimationEnd=\{onAnimationEnd\}/);
assert.match(sidebarSource, /className\?:\s*string;/);
- assert.match(
- sidebarSource,
- /onAnimationEnd\?:\s*ReactAnimationEventHandler<HTMLElement>;/,
- );
+ assert.match(sidebarSource, /onAnimationEnd\?:\s*ReactAnimationEventHandler<HTMLElement>;/);
});
test("collapsing keeps the sidebar mounted until its exit animation ends", () => {
- // Mirror the work-panel mount-then-animate-then-unmount state machine: the
- // sidebar stays in the tree while `sidebarExiting` is true, gets the
- // `is-exiting` class, and fires `handleSidebarAnimationEnd` on animation end.
assert.match(appSource, /!sidebarCollapsed \|\| sidebarExiting \?/);
- assert.match(
- appSource,
- /className=\{sidebarExiting \? "is-exiting" : undefined\}/,
- );
+ assert.match(appSource, /className=\{cx\(sidebarEntering && "is-entering", sidebarExiting && "is-exiting"\)\}/);
assert.match(appSource, /onAnimationEnd=\{handleSidebarAnimationEnd\}/);
- assert.match(
- appSource,
- /if \(!event\.animationName\.startsWith\("sidebar-out"\)\) return;/,
- );
- // Expanding from the collapsed titlebar must route through the same machine
- // so the entrance animation plays too.
- assert.match(
- appSource,
- /CollapsedTitlebarActions[\s\S]*?onToggleSidebar/,
- );
+ assert.match(appSource, /event\.target !== event\.currentTarget/);
+ assert.match(appSource, /!event\.animationName\.startsWith\(expected\)/);
+ assert.match(appSource, /CollapsedTitlebarActions[\s\S]*?onToggleSidebar/);
});
-test("the sidebar entrance/exit keyframes and exit rule exist", () => {
- // Entrance animation applied to every mount (matches the work-panel dock).
- const sidebarBlock = globalStyles.match(/\.sidebar\s*\{[\s\S]*?\}/)?.[0] ?? "";
+test("only explicit sidebar entrance plays the expand keyframe", () => {
+ const sidebarBlock = globalStyles.match(/\.sidebar\s*\{[^}]*\}/)?.[0] ?? "";
+ assert.doesNotMatch(sidebarBlock, /animation:/);
+ const entranceBlock = globalStyles.match(/\.sidebar\.is-entering\s*\{[^}]*\}/)?.[0] ?? "";
assert.match(
- sidebarBlock,
+ entranceBlock,
/animation:\s*sidebar-in var\(--motion-duration-normal\) var\(--motion-ease-out\) both/,
);
// Exit rule swaps to the sidebar-out keyframe and blocks interaction.
@@ -213,6 +196,96 @@ test("reduced motion drops the collapse animation and its top-bar tracking", ()
);
});
+/** One CSS rule's declarations, with its comments removed. */
+function rule(selector) {
+ const block =
+ globalStyles.match(new RegExp(`${selector}\\s*\\{[\\s\\S]*?\\}`))?.[0] ?? "";
+ return block.replace(/\/\*[\s\S]*?\*\//g, "");
+}
+
+test("a project group folds as one grid row instead of a max-height wipe", () => {
+ const projectRule = rule(String.raw`\.sidebar-session-group-body\.project`);
+ assert.match(projectRule, /display:\s*grid/);
+ assert.match(projectRule, /grid-template-rows:\s*1fr/);
+ assert.match(
+ projectRule,
+ /transition:\s*grid-template-rows var\(--motion-duration-normal\) var\(--motion-ease-out\)/,
+ );
+ // A height clamp and an opacity transition are the two ways this fold can be
+ // staged apart from the row the rows are laid out in.
+ assert.doesNotMatch(projectRule, /max-height/);
+ assert.doesNotMatch(projectRule, /opacity/);
+ assert.doesNotMatch(projectRule, /padding-(top|bottom)/);
+
+ const collapsedRule = rule(
+ String.raw`\.sidebar-session-group-body\.project\.collapsed`,
+ );
+ assert.match(collapsedRule, /grid-template-rows:\s*0fr/);
+ assert.match(collapsedRule, /pointer-events:\s*none/);
+ // The rows leave by being clipped, so nothing fades and nothing keeps a
+ // height of its own.
+ assert.doesNotMatch(collapsedRule, /opacity/);
+ assert.doesNotMatch(collapsedRule, /max-height/);
+
+ // The shared body rule must not carry either one onto the project body, and
+ // the pinned and standalone bodies keep the plain column.
+ const baseRule = rule(String.raw`\.sidebar-session-group-body`);
+ assert.match(baseRule, /display:\s*flex/);
+ assert.match(baseRule, /flex-direction:\s*column/);
+ assert.doesNotMatch(baseRule, /max-height/);
+ assert.doesNotMatch(baseRule, /opacity/);
+ assert.doesNotMatch(baseRule, /grid-template-rows/);
+});
+
+test("the clip closes the 0fr row and the list owns the group inset", () => {
+ const clipRule = rule(String.raw`\.sidebar-session-group-clip`);
+ assert.match(clipRule, /min-height:\s*0/);
+ assert.match(clipRule, /overflow:\s*hidden/);
+ // Vertical padding on the animating box or on the clip holds the 0fr row open
+ // and leaves a tail behind after the rows are gone.
+ assert.doesNotMatch(clipRule, /padding/);
+
+ const listRule = rule(String.raw`\.sidebar-session-group-list`);
+ assert.match(listRule, /display:\s*flex/);
+ assert.match(listRule, /flex-direction:\s*column/);
+ assert.match(listRule, /gap:\s*1px/);
+ assert.match(listRule, /padding-top:\s*2px/);
+ assert.match(listRule, /padding-bottom:\s*7px/);
+
+ // The 8px tail is the list's own 7px plus the scroller's 1px gap, so an
+ // expanded group is followed by 8px and a collapsed one by 1px either way.
+ assert.match(rule(String.raw`\.sidebar-session-groups`), /gap:\s*1px/);
+});
+
+test("the project body renders the grid, clip, and list layers", () => {
+ assert.match(
+ sidebarSource,
+ /className=\{`sidebar-session-group-body project \$\{collapsedProject \? "collapsed" : ""\}`\}/,
+ );
+ assert.match(sidebarSource, /aria-hidden=\{collapsedProject\}/);
+ // `inert` is the React 19 boolean form, and only while folded: the rows stay
+ // mounted inside the 0fr row, so they must leave the tab order as well as the
+ // accessibility tree.
+ assert.match(sidebarSource, /inert=\{collapsedProject \? true : undefined\}/);
+ assert.match(
+ sidebarSource,
+ /<div className="sidebar-session-group-clip">\s*<div className="sidebar-session-group-list">/,
+ );
+ // The list layer has to be innermost, or the rows sit outside the inset the
+ // fold is supposed to carry away.
+ assert.match(
+ sidebarSource,
+ /sidebar-session-group-list">\s*\{entry\.sessions\.length > 0 \? renderTimeGroupedSessions\(visibleSessions\) : \(/,
+ );
+});
+
+test("reduced motion keeps the fold's endpoints and drops its travel", () => {
+ assert.match(
+ globalStyles,
+ /@media \(prefers-reduced-motion: reduce\)[\s\S]*?\.sidebar-session-group-body\.project\s*\{\s*transition-duration:\s*0\.01ms !important;/,
+ );
+});
+
test("the sidebar toggle never captures a stale collapsed state", () => {
// The keydown and native-menu handlers register once; toggleSidebar reads the
// shell state through refs and spends work-panel width on reopen, so the old
@@ -224,17 +297,10 @@ test("the sidebar toggle never captures a stale collapsed state", () => {
appSource,
/setSidebarCollapsed\(\(collapsed\) => !collapsed\)/,
);
- // The exit flag is adjusted during render, never in an effect: an effect runs
- // after the commit, so the collapsing render unmounts the dock outright and
- // the effect remounts it — one painted frame with no dock at all.
- assert.match(
- appSource,
- /const prevSidebarCollapsed = useRef\(sidebarCollapsed\);\s*if \(prevSidebarCollapsed\.current !== sidebarCollapsed\) \{\s*prevSidebarCollapsed\.current = sidebarCollapsed;\s*setSidebarExiting\(sidebarCollapsed\);\s*\}/,
- );
- assert.doesNotMatch(
- appSource,
- /useEffect\(\(\) => \{\s*setSidebarExiting\(sidebarCollapsed\);\s*\},\s*\[sidebarCollapsed\]\);/,
- );
+ assert.match(appSource, /useSidebarTransition\(\s*sidebarCollapsed,\s*ready && page !== "settings"/);
+ assert.match(appSource, /if \(current !== transition\) setTransition\(current\)/);
+ assert.match(appSource, /return \(\) => window\.clearTimeout\(timer\)/);
+ assert.match(appSource, /state === current \? \{ \.\.\.state, phase: "idle" \} : state/);
// Both shortcut dispatch paths depend on the stable toggle.
assert.match(appSource, /\[showToast, toggleSidebar\],/);
assert.match(appSource, /settings\?\.keybindings,\s*toggleSidebar,/);
diff --git a/apps/desktop/test/sidebar-pinned-rendering.test.mjs b/apps/desktop/test/sidebar-pinned-rendering.test.mjs
index 5c59f9e3f..b3e914d34 100644
--- a/apps/desktop/test/sidebar-pinned-rendering.test.mjs
+++ b/apps/desktop/test/sidebar-pinned-rendering.test.mjs
@@ -39,8 +39,9 @@ test("sidebar renders global pins once, outside project folding and history limi
session("archived-pin", "/open"),
session("archived-project-pin", "/archived"),
];
+ const now = Date.now();
const normal = Array.from({ length: 11 }, (_, index) =>
- session(`normal-${String(index).padStart(2, "0")}`, "/open", new Date().toISOString()),
+ session(`normal-${String(index).padStart(2, "0")}`, "/open", new Date(now - index * 1_000).toISOString()),
);
const meta = Object.fromEntries(pins.map(({ id }) => [id, { pinned: true }]));
meta["archived-pin"].archived = true;
@@ -56,6 +57,9 @@ test("sidebar renders global pins once, outside project folding and history limi
openProjects: [],
workspace: null,
activeProjectPath: null,
+ activeSessionId: null,
+ selectingSessionId: null,
+ page: "chat",
projectCollapsed: {},
sessionView: { sort: "recent", archived: false },
};
@@ -118,10 +122,77 @@ test("sidebar renders global pins once, outside project folding and history limi
collapsedGroup,
/class="sidebar-session-group-body project collapsed"[^>]*aria-hidden="true"/,
);
+ // A folded group keeps its rows mounted inside a 0fr grid row, so the same
+ // element has to leave the tab order too: `aria-hidden` alone still lets a
+ // keyboard walk into invisible rows.
+ assert.match(collapsedGroup, /inert=""/);
+ assert.match(
+ collapsedGroup,
+ /<div class="sidebar-session-group-clip"><div class="sidebar-session-group-list">/,
+ );
assert.deepEqual(rows(collapsedGroup), ["collapsed-pin"], "unpin returns to folded history");
+
+ // The same three layers carry an expanded group, which is neither hidden
+ // from AT nor inert.
+ const openGroup =
+ html.match(/data-sidebar-project-group="\/open"[\s\S]*?<\/section>/)?.[0] ?? "";
+ assert.match(
+ openGroup,
+ /class="sidebar-session-group-body project "[^>]*aria-hidden="false"/,
+ );
+ assert.doesNotMatch(openGroup, /inert/);
+ assert.match(
+ openGroup,
+ /<div class="sidebar-session-group-clip"><div class="sidebar-session-group-list">/,
+ );
+ assert.ok(rows(openGroup).length > 0, "an expanded group renders its rows");
+
+ // A retained project with no sessions is the empty state, and it has to sit
+ // in the same list layer so the fold animates it away too.
+ const withEmptyProject = render({
+ openProjectPaths: [...seed.openProjectPaths, "/empty"],
+ });
+ const emptyGroup =
+ withEmptyProject.match(/data-sidebar-project-group="\/empty"[\s\S]*?<\/section>/)?.[0] ?? "";
+ assert.match(
+ emptyGroup,
+ /<div class="sidebar-session-group-clip"><div class="sidebar-session-group-list"><div class="sidebar-session-empty">/,
+ );
+ assert.deepEqual(rows(emptyGroup), [], "an empty project renders no session rows");
const restored = render({ sessionView: { sort: "recent", archived: true } });
assert.equal(rows(pinnedSection(restored)).length, pins.length);
assert.equal(rows(restored).length, new Set(rows(restored)).size);
+
+ const selectedRows = (markup) => [...markup.matchAll(
+ /class="thread-item active[^"]*" data-sidebar-session-row="([^"]+)"/g,
+ )].map((match) => match[1]);
+ for (const id of ["normal-00", "open-pin", "temporary-normal", "temporary-pin"]) {
+ const selected = render({ activeProjectPath: "/open", activeSessionId: id });
+ assert.deepEqual(selectedRows(selected), [id]);
+ assert.match(selected, /data-sidebar-project-group="\/open" data-current-workspace="true"/);
+ assert.match(selected, /sidebar-project-active-dot/);
+ assert.doesNotMatch(selected, /class="sidebar-session-group project-group [^"]*\bactive\b/);
+ }
+ const selecting = render({
+ activeProjectPath: "/open", activeSessionId: "normal-00", selectingSessionId: "open-pin",
+ });
+ assert.deepEqual(selectedRows(selecting), ["open-pin"]);
+ const foldedSelection = render({
+ activeProjectPath: "/open", activeSessionId: "normal-00",
+ projectMeta: { ...seed.projectMeta, "/open": { collapsed: true } },
+ });
+ assert.deepEqual(selectedRows(foldedSelection), ["normal-00"]);
+ assert.match(foldedSelection, /data-current-workspace="true"[\s\S]*?aria-hidden="true" inert=""/);
+ assert.doesNotMatch(foldedSelection, /class="sidebar-session-group project-group [^"]*\bactive\b/);
+ for (const overrides of [
+ { activeSessionId: null },
+ { activeSessionId: "normal-00", page: "settings" },
+ ]) {
+ const withoutSelection = render({ activeProjectPath: "/open", ...overrides });
+ assert.deepEqual(selectedRows(withoutSelection), []);
+ assert.match(withoutSelection, /data-current-workspace="true"/);
+ assert.doesNotMatch(withoutSelection, /class="sidebar-session-group project-group [^"]*\bactive\b/);
+ }
} finally {
globalThis.document = previousDocument;
await server.close();
diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.md
index 110ef6280..af3687e18 100644
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@ -1340,8 +1340,17 @@ Project drag/drop follows these patterns:
the conversation, or activates and toggles the project group, exactly as a
click on the title does; a no-hover pointer gets the controls revealed so it
never meets a hidden target.
+- Project headers and conversation rows (project, pinned and standalone) use
+ the same full-row hover surface, radius and transition. The title button is
+ transparent; hover never draws a nested title tile. The selected conversation
+ keeps its selected fill on hover. A current workspace uses only the project
+ dot, not another selected background; folding a selected child or leaving the
+ chat page never promotes its project to a selected navigation item.
+- Keyboard focus keeps its outline independently of selection. The add and
+ overflow buttons retain local hover feedback, and drag-target paint takes
+ precedence over ordinary header hover.
- Hover paint belongs to the pointer that caused it. When the window loses
- focus the row and the project title drop their hover background and their
+ focus the row and the project header drop their hover background and their
revealed actions hide, so nothing is left lit or armed after the window
returns; moving the pointer over the row again re-arms it.
- Revealed actions become clickable the moment the row is hovered or focused,
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 316512b9f..e5d4c9310 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -7430,6 +7430,8 @@ identify the platform validation still needed.
| Acceptance | Scenarios |
|---|---|
| C / G / Quality — Plugins navigation | E2E-NAV-plugins-button-goes-back |
+| C / D / Quality — Sidebar row states | E2E-LAYOUT-sidebar-row-states |
+| A / C / Quality — Sidebar material and settings return | E2E-LAYOUT-sidebar-settings |
| B / F / Security — Provider copy | E2E-PROVIDER-copy-config-without-credentials |
| A — App startup | E2E-001, E2E-002, E2E-003, E2E-004, E2E-067, E2E-076, E2E-079, E2E-092, E2E-097, E2E-143, E2E-150, E2E-168, E2E-204 |
| B — Model config | E2E-005, E2E-006, E2E-007, E2E-038, E2E-050, E2E-052, E2E-055, E2E-066, E2E-080, E2E-082, E2E-102c, E2E-102d, E2E-102e, E2E-151, E2E-154, E2E-163, E2E-166, E2E-172, E2E-174, E2E-197, E2E-005G, E2E-005J, E2E-199, E2E-201, E2E-202, E2E-203, E2E-205, E2E-206, E2E-209 |
@@ -12125,6 +12127,124 @@ plugin-form fixtures in an isolated temporary directory at runtime.
window-drag and visual checks remain required on each platform. Branch runs
are exploratory and do not satisfy the integrated-main gate.
+#### E2E-LAYOUT-sidebar-project-group-fold
+
+- **Preconditions**: Four retained sidebar project groups, seeded through the
+ host: one holding five sessions across four date buckets, one holding a single
+ session, one holding none, and one holding ten pinned sessions.
+ `prefers-reduced-motion` is unset.
+- **Steps**:
+ 1. Inspect the groups: body layering, row and date-label counts, the empty
+ state, the tail each expanded group contributes to the next one, and the
+ non-project lists' budgets.
+ 2. Collapse the multi-row group with a real pointer click on its directory row —
+ scrolled into view and confirmed to hit that button — and read the group
+ body's height, opacity, resolved `grid-template-rows`, and the distance to
+ the next group on every frame for about half a second, while recording the
+ fold's own `transitionrun` / `transitionend`.
+ 3. Expand it again and confirm the open geometry returns.
+ 4. Collapse and re-expand it within the same motion.
+ 5. Repeat the collapse with `prefers-reduced-motion: reduce` emulated.
+ 6. Scroll the pinned list to its last row.
+- **Expected**: A project group is one grid row (`grid-template-rows: 1fr`) that
+ animates to `0fr` over the 200ms normal duration — no `max-height` clamp, no
+ opacity transition — so the fold is a single continuous height ramp with no
+ plateau followed by a snap, and `opacity` stays 1 on every frame: the rows are
+ clipped, never faded. The fold fires one transition and its own event reports
+ the 200ms normal duration. The rows are clipped by an inner `min-height: 0`
+ box, and the 1px row gap plus the group's 2px / 7px inset sit on the list inside
+ that clip, so the inset travels with the rows. An expanded group's 7px inset
+ plus the 1px scroller gap read as an 8px tail to the group below it; the last
+ group in the list has no neighbour, so it is checked against its own inset and
+ clip instead. A folded group's tail leaves with its rows, its section is its
+ header plus the 1px scroller gap, and its rows stay mounted past the clipped
+ edge while the group is `aria-hidden` and `inert`. A reversal mid-flight turns
+ on the frame it reached and settles back on the open height without
+ overshooting, and the empty group folds its empty state the same way. Under
+ reduced motion both endpoints are kept and the travel is dropped. The pinned
+ list holds eight rows inside `min(233px, 30vh)` and scrolls to its remaining
+ rows, and the standalone list keeps its flex column and 146px budget. The group
+ indent, ordering, and workspace state are unchanged.
+- **Specs linked**: `04-ux/01-ui-ia.md`, `04-ux/07-ui-design-system.md` §6.1 and
+ §13, `04-ux/08-component-spec.md` §6.2, `08-meta/decisions-log.md`
+ (2026-09-16, sidebar list rhythm and project-group fold)
+- **Acceptance**: Quality
+- **Milestone**: Post-M6 desktop shell maintenance
+- **Status**: Automated (`scripts/e2e-three-column-layout.mjs` via
+ `pnpm test:e2e:layout` — host-seeded groups and pins, a hit-tested CDP pointer
+ click, per-frame height and opacity sampling across the real fold, the
+ transition's own reported duration, mid-flight reversal, and reduced-motion
+ emulation). Unit coverage in
+ `apps/desktop/test/sidebar-collapse-animation.test.mjs` and
+ `apps/desktop/test/sidebar-pinned-rendering.test.mjs`. The sampled values are
+ renderer geometry, not an eyes-on visual pass.
+
+#### E2E-LAYOUT-sidebar-row-states
+
+- **Preconditions**: Host-seeded project, pinned and standalone conversations;
+ a current workspace; built desktop with isolated data and profile directories.
+- **Steps**: In dark and light themes, select a project conversation, hover its
+ project title and an unselected conversation, then hover the selected row.
+ Exercise the window-blur handler, drop-target styling, project action hover
+ and keyboard Tab/Shift+Tab focus. Fold and reopen the selected conversation's
+ group. Select pinned and standalone conversations. Open Settings and return.
+ Enable reduced motion and inspect both row transition durations.
+- **Expected**: Project and conversation hover backgrounds, radii and transitions
+ match. The title button stays transparent. Only a conversation uses selected
+ fill, which wins over hover; workspace identity remains a separate dot with
+ no persistent header fill. Folding never promotes the project to selected.
+ Pinned and standalone rows use the same selected surface. Keyboard focus
+ retains an outline, action buttons retain local feedback, drop-target paint
+ wins over hover, and blur releases hover without clearing selection. Settings
+ replaces sidebar navigation, and returning restores conversation and workspace
+ context without a second selected row. Rendered component tests additionally
+ cover no selected session, a pending destination and non-chat page state.
+- **Specs linked**: `04-ux/01-ui-ia.md`, `04-ux/08-component-spec.md`,
+ `04-ux/09-interaction-patterns.md` §9.1c
+- **Acceptance**: C, D, Quality
+- **Milestone**: Post-M6 desktop shell maintenance
+- **Status**: Automated via `pnpm test:e2e:layout` and
+ `scripts/e2e/sidebar-row-states.mjs`: real CDP pointer/keyboard input and
+ computed-style assertions. Window blur/focus events and the drop-target class
+ are injected for those styling checks; this is not a native focus/drag test.
+ Unit coverage: `sidebar-navigation.test.mjs`, `sidebar-pinned-rendering.test.mjs`.
+
+#### E2E-LAYOUT-sidebar-settings
+
+- **Preconditions**: Built desktop, isolated host/profile, visible chat sidebar.
+- **Steps**:
+ 1. In dark/light palettes and darwin/win32/linux CSS branches, compare the
+ home sidebar and Settings rail color, image layers, size and position.
+ Inspect transparent ancestors and opaque settings content/titlebar.
+ 2. Return through Back to app while tracing sidebar insertion, width and
+ animationstart events. Repeat quick round trips, a previously collapsed
+ sidebar, and settings navigation interrupting an entrance.
+ 3. Explicitly reopen a collapsed sidebar, then repeat settings return with
+ reduced motion. Repeat material comparisons with legacy and canonical
+ 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
+ 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
+ input remains supported for both rails, and a canonical override wins.
+- **Specs linked**: `04-ux/06-settings-ia.md`, `04-ux/07-ui-design-system.md`,
+ `04-ux/08-component-spec.md` §1.4 and §1.7
+- **Acceptance**: A, C, Quality
+- **Milestone**: Post-M6 desktop shell maintenance
+- **Status**: Automated via `pnpm test:e2e:layout` and
+ `scripts/e2e/sidebar-settings.mjs`, with trusted CDP pointer/keyboard input,
+ mutation-time and subsequent geometry samples, animation events and computed
+ styles. CDP focus emulation keeps the isolated page painting while its native
+ window is occluded; otherwise Chromium can freeze CSS motion and hover input.
+ Platform branches and palettes are renderer emulation, not native
+ 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`
+ 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
- **Preconditions**: A session with a configured model and a controllable
diff --git a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
index 5e27ea53f..cd01e7657 100644
--- a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
+++ b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
@@ -1009,6 +1009,16 @@ Mode/provider/model/permission/shell 配置和新提示仍然存在
- 选择**打开文件夹**打开系统文件中的项目目录
管理器而不更改活动会话记录。
+### 9.1c 侧边栏行状态与操作
+
+- 项目标题与项目、置顶、独立会话行共享整行悬停背景、圆角和过渡。
+ 标题按钮透明,不叠加内层背景;已选中会话在悬停时保持选中背景。
+- 当前工作区仅通过项目圆点表达,不再使用另一份选中背景。折叠选中会话
+ 的分组、离开聊天页或没有选中会话,都不会让项目标题成为选中导航项。
+- 键盘焦点保留独立轮廓;新建和更多操作按钮保留局部悬停反馈;拖拽目标
+ 提示优先于普通悬停背景。
+- 窗口失焦时释放悬停背景和操作显露,不清除当前会话选中背景。
+
### 9. 2 侧边栏滚动
- 独立的会话主体有五个紧凑的行和卷轴
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.md
index 0f22169f0..897ebff7a 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
@@ -4926,6 +4926,8 @@ IPC 请求无法关闭。
| 验收 | 应用场景 |
|---|---|
| C / G / Quality — Plugins navigation | E2E-NAV-plugins-button-goes-back |
+| C / D / Quality — 侧边栏行状态 | E2E-LAYOUT-sidebar-row-states |
+| A / C / Quality — 侧栏材质与设置返回 | E2E-LAYOUT-sidebar-settings |
| B / F / Security — 提供商复制 | E2E-PROVIDER-copy-config-without-credentials |
| A — 应用程序启动 | E2E-001、E2E-002、E2E-003、E2E-004、E2E-067、E2E-076、E2E-079、E2E-092、E2E-097、E2E-143、E2E-150、E2E-168、E2E-204、E2E-217 |
| B——模型配置 | E2E-005、E2E-005G、E2E-006、E2E-007、E2E-038、E2E-050、E2E-052、E2E-055、E2E-066、E2E-080、E2E-082、E2E-151、E2E-005J、E2E-199、E2E-201、E2E-202、E2E-203、E2E-209、E2E-166 |
@@ -7332,6 +7334,84 @@ runner 会在运行时的隔离临时目录中生成六个插件形态 fixture
states). DOM/CDP clicks are not native hit-test proof. Native pointer, drag
and visual checks remain required; branch runs are exploratory only.
+#### E2E-LAYOUT-sidebar-project-group-fold
+
+- **前提条件**:通过宿主预置四个保留的侧边栏项目分组:一个横跨四个日期桶共五个会话,一个只有单个会话,一个没有任何会话,一个带十个已固定会话。未设置 `prefers-reduced-motion`。
+- **步骤**:
+ 1. 检查这些分组:主体分层、行数与日期标签数、空状态、每个展开分组贡献给下一个分组的尾部间距,
+ 以及非项目列表的预算。
+ 2. 用真实指针点击项目目录行(先滚动进视野并确认命中该按钮)折叠多行分组,在约半秒内逐帧读取
+ 分组主体的高度、opacity、解析后的 `grid-template-rows`,以及到下一个分组的距离,
+ 同时记录该折叠自身的 `transitionrun` / `transitionend`。
+ 3. 再次展开,确认打开的几何形态恢复。
+ 4. 在同一次运动中先折叠再展开。
+ 5. 在模拟 `prefers-reduced-motion: reduce` 的情况下重复折叠。
+ 6. 把固定列表滚动到它的最后一行。
+- **预期**:项目分组是一个网格行(`grid-template-rows: 1fr`),在 200ms 的正常时长内动画到
+ `0fr` —— 没有 `max-height` 夹取,也没有 opacity 过渡 —— 因此折叠是一条连续的高度斜坡,
+ 不会先出现平台期再瞬间跳变,并且每一帧的 `opacity` 都保持为 1:行是被裁剪的,从不淡出。
+ 一次折叠只触发一次过渡,其自身事件报告 200ms 的正常时长。行由内层带 `min-height: 0` 的盒
+ 裁剪,1px 行间隙与分组的 2px / 7px 内缩量位于该裁剪层内部的列表上,因此内缩量随行一起移动。
+ 展开分组的 7px 内缩量加上滚动容器的 1px 间隙,与下一个分组之间形成 8px 尾部间距;列表中的
+ 最后一个分组没有邻居,因此改为校验它自身的内缩量与裁剪层。折叠分组的尾部随行一起消失,
+ 其区块等于标题加上 1px 滚动容器间隙,行仍挂载在被裁剪的边缘之外,同时分组处于
+ `aria-hidden` 与 `inert`。中途反转会从它已经到达的那一帧转向,并回到打开高度而不越界;
+ 空分组以同样方式折叠其空状态。在减弱动态效果下保留两端状态并去掉位移。固定列表在
+ `min(233px, 30vh)` 内显示八行并可滚动到其余行,独立列表保持其弹性列与 146px 预算。
+ 分组的缩进、顺序与工作区状态均不变。
+- **链接规格**:`04-ux/01-ui-ia.md`、`04-ux/07-ui-design-system.md` §6.1 与 §13、
+ `04-ux/08-component-spec.md` §6.2、`08-meta/decisions-log.md`(2026-09-16 侧边栏列表节奏与项目分组折叠)
+- **验收**:品质
+- **里程碑**:Post-M6 desktop shell maintenance
+- **状态**:已自动化(`scripts/e2e-three-column-layout.mjs`,经 `pnpm test:e2e:layout`):
+ 宿主预置分组与固定项、经过命中校验的 CDP 指针点击、在真实折叠上逐帧采样高度与 opacity、
+ 读取过渡自身报告的时长、中途反转,以及减弱动态效果模拟。
+ 单元覆盖见 `apps/desktop/test/sidebar-collapse-animation.test.mjs` 与
+ `apps/desktop/test/sidebar-pinned-rendering.test.mjs`。采样值是渲染器几何数据,
+ 不是人眼视觉验收。
+
+#### E2E-LAYOUT-sidebar-row-states
+
+- **前提条件**:宿主预置项目、置顶和独立会话,存在当前工作区;应用使用隔离的数据与 profile。
+- **步骤**:分别在深浅主题下选中项目会话,悬停项目标题、未选中和已选中会话;
+ 检查失焦处理、拖拽目标样式、操作按钮悬停及 Tab/Shift+Tab 焦点;折叠后展开
+ 选中会话的分组,切换置顶与独立会话,打开设置再返回;开启减少动态效果,
+ 确认项目与会话行的悬停过渡均接近零时长。
+- **预期**:项目与会话共享整行悬停背景、圆角和过渡,标题按钮透明;选中背景
+ 只属于会话且优先于悬停。工作区仅通过圆点表达,折叠不会转移选中态。
+ 置顶和独立会话样式一致;焦点轮廓、独立操作按钮反馈和拖拽目标优先级保留。
+ 失焦释放悬停而不清除选中;设置替换侧栏,返回后恢复会话与工作区上下文。
+ 渲染测试另覆盖没有选中会话、切换中的目标和非聊天页状态。
+- **链接规格**:`04-ux/01-ui-ia.md`、`04-ux/08-component-spec.md`、`04-ux/09-interaction-patterns.md` §9.1c
+- **验收**:C、D、品质
+- **里程碑**:Post-M6 desktop shell maintenance
+- **状态**:经 `pnpm test:e2e:layout` 调用 `scripts/e2e/sidebar-row-states.mjs` 自动验证,
+ 使用真实 CDP 指针/键盘输入及计算样式断言。失焦/聚焦事件与拖拽类由测试注入,
+ 这两项不等同于原生窗口焦点或真实拖拽测试。单元覆盖:
+ `sidebar-navigation.test.mjs`、`sidebar-pinned-rendering.test.mjs`。
+
+#### E2E-LAYOUT-sidebar-settings
+
+- **前提条件**:构建后的桌面应用、隔离宿主与 profile,聊天侧栏可见。
+- **步骤**:在深浅主题及 darwin/win32/linux CSS 分支比较主侧栏与设置导航的颜色、
+ 背景图、尺寸和位置,检查祖先透明度及右侧不透明背景;返回时记录挂载、宽度及
+ animationstart。重复快速往返、原本折叠、入场被设置打断和减少动态效果场景,
+ 确认真实展开仍有动画。另验证旧主题色、标准侧栏色及背景图覆盖。
+- **预期**:两处导航共用材质,设置导航和外壳不播入场,只有不透明内容区内部动画。
+ macOS 下侧栏祖先透明,右侧内容和顶部条不透明。返回时展开侧栏始终为 275px,
+ 无 sidebar-in;原本折叠则保持不显示。真实展开仍有动画与宽度变化;旧主题颜色
+ 作为共享回退保留,显式标准 token 优先。
+- **链接规格**:`04-ux/06-settings-ia.md`、`04-ux/07-ui-design-system.md`、
+ `04-ux/08-component-spec.md` §1.4、§1.7
+- **验收**:A、C、品质
+- **里程碑**:Post-M6 desktop shell maintenance
+- **状态**:`pnpm test:e2e:layout` 调用 `scripts/e2e/sidebar-settings.mjs`,使用可信
+ CDP 指针/键盘、挂载时与后续几何采样、动画事件及计算样式。测试启用 CDP 焦点模拟,
+ 防止原生窗口被遮挡后 Chromium 冻结动画与悬停输入。平台和主题为渲染层模拟,
+ 不等同于原生 Windows/Linux 或系统材质/主题验证。可通过 `PI_DESKTOP_LAYOUT_ARTIFACT_DIR`
+ 保存渲染截图。`sidebar-settings-return.test.mjs` 覆盖首次显示、两种中断阶段、
+ 隐藏时状态变化和反转;`pnpm test:e2e:theme-surfaces` 在真实 Chromium 验证不透明回退及旧主题覆盖。
+
#### E2E-AGENT-alt-enter-steers-active-turn:Enter 排队跟进,Alt+Enter 向当前回合补充指令
- **前提条件**:会话已配置模型,能够控制流式回复或工具完成时机;附件场景使用支持图像的模型。
diff --git a/scripts/e2e-three-column-layout.mjs b/scripts/e2e-three-column-layout.mjs
index 4ce659967..8267edc66 100644
--- a/scripts/e2e-three-column-layout.mjs
+++ b/scripts/e2e-three-column-layout.mjs
@@ -18,12 +18,16 @@
* host-core binary (target/debug, target/release, or PI_DESKTOP_HOST_BIN).
*/
import { spawn } from "node:child_process";
-import { existsSync, mkdtempSync, rmSync } from "node:fs";
+import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { setTimeout as delay } from "node:timers/promises";
+import { Host } from "./e2e/host.mjs";
+import { checkSidebarRowStates } from "./e2e/sidebar-row-states.mjs";
+import { checkSidebarSettings } from "./e2e/sidebar-settings.mjs";
+
const __dirname = dirname(fileURLToPath(import.meta.url));
const root = join(__dirname, "..");
const appDir = join(root, "apps", "desktop");
@@ -52,6 +56,121 @@ function resolveHostBinary() {
return found;
}
+/**
+ * Seed four retained project groups into the same throwaway data directory the
+ * app will open, using only the host protocol:
+ *
+ * alpha five sessions across four date buckets, so the group draws date
+ * labels as well as rows
+ * beta one session, the smallest non-empty group
+ * gamma no sessions, the empty group
+ * delta ten sessions that the renderer pins, so the Pinned section has more
+ * rows than its eight-row budget
+ *
+ * `session.import` is the only protocol entry point that accepts a session's own
+ * timestamps, which is what puts rows in the yesterday / this-week / older
+ * buckets. The retained-tab list, the pin set, and the project ordering are
+ * renderer-local, so they are handed to the app through its own persisted
+ * sidebar preferences.
+ *
+ * `tempDirs` receives the project root as soon as it exists, so a failure here
+ * still leaves the caller's clean-up able to remove it.
+ */
+async function seedSidebarProjects(hostBinary, dataDir, tempDirs) {
+ const projectRoot = realpathSync(mkdtempSync(join(tmpdir(), "pi-layout-projects-")));
+ tempDirs.push(projectRoot);
+ const alpha = join(projectRoot, "alpha");
+ const beta = join(projectRoot, "beta");
+ const gamma = join(projectRoot, "gamma");
+ const delta = join(projectRoot, "delta");
+ for (const dir of [alpha, beta, gamma, delta]) mkdirSync(dir, { recursive: true });
+
+ const startOfToday = new Date();
+ startOfToday.setHours(0, 0, 0, 0);
+ const dayStart = startOfToday.getTime();
+ const stamp = (ms) => new Date(ms).toISOString();
+ // `getTimeGroup` buckets on the calendar day, so these offsets are anchored to
+ // local midnight rather than to the current clock time.
+ const alphaRows = [
+ ["alpha today b", Date.now() - 120_000],
+ ["alpha today a", Date.now() - 60_000],
+ ["alpha yesterday", dayStart - 60_000],
+ ["alpha this week", dayStart - 3 * 86400_000],
+ ["alpha older", dayStart - 20 * 86400_000],
+ ];
+ const betaRows = [["beta today", Date.now() - 60_000]];
+ // Ten rows, so the Pinned section's eight-row budget has to scroll.
+ const deltaRows = Array.from({ length: 10 }, (_, index) => [
+ `delta pinned ${index}`,
+ Date.now() - 60_000 - index * 1_000,
+ ]);
+ const alphaSessionIds = [];
+
+ const host = new Host(hostBinary, dataDir);
+ try {
+ await host.start();
+ await host.call("workspace.set", { path: alpha });
+ const importRow = async (id, title, projectPath, updatedMs) => {
+ const result = await host.call("session.import", {
+ session: {
+ id,
+ title,
+ messageCount: 0,
+ projectPath,
+ modelId: null,
+ providerId: null,
+ mode: "agent",
+ thinkingLevel: "medium",
+ permissionMode: "inherit",
+ createdAt: stamp(updatedMs - 3_600_000),
+ updatedAt: stamp(updatedMs),
+ },
+ messages: [],
+ });
+ if (!result?.imported) {
+ throw new Error(`session.import skipped ${id}: ${JSON.stringify(result)}`);
+ }
+ };
+ for (const [index, [title, updatedMs]] of alphaRows.entries()) {
+ const id = `e2e-fold-alpha-${index}`;
+ await importRow(id, title, alpha, updatedMs);
+ alphaSessionIds.push(id);
+ }
+ await importRow("e2e-fold-beta-0", betaRows[0][0], beta, betaRows[0][1]);
+ await importRow("e2e-state-standalone", "standalone state probe", null, Date.now());
+ const pinnedSessionIds = [];
+ for (const [index, [title, updatedMs]] of deltaRows.entries()) {
+ const id = `e2e-fold-delta-${index}`;
+ await importRow(id, title, delta, updatedMs);
+ pinnedSessionIds.push(id);
+ }
+
+ // The host canonicalizes every project path; read the stored values back so
+ // the renderer's retained-tab list matches exactly.
+ const listed = await host.call("session.list");
+ const rows = listed?.sessions ?? [];
+ const canonical = (sessionId) =>
+ rows.find((session) => session.id === sessionId)?.projectPath ?? null;
+ const paths = {
+ alpha: canonical("e2e-fold-alpha-0"),
+ beta: canonical("e2e-fold-beta-0"),
+ gamma,
+ delta: canonical("e2e-fold-delta-0"),
+ };
+ if (!paths.alpha || !paths.beta || !paths.delta) {
+ throw new Error(`seeded sessions carry no project path: ${JSON.stringify(paths)}`);
+ }
+ return {
+ paths,
+ alphaSessionIds,
+ pinnedSessionIds,
+ keys: [paths.alpha, paths.beta, paths.gamma, paths.delta],
+ };
+ } finally {
+ await host.stop();
+ }
+}
+
class CdpClient {
constructor(ws) {
this.ws = ws;
@@ -176,6 +295,23 @@ async function main() {
const hostBinary = resolveHostBinary();
const dataDir = mkdtempSync(join(tmpdir(), "pi-layout-data-"));
const profileDir = mkdtempSync(join(tmpdir(), "pi-layout-profile-"));
+ // Every throwaway directory, created before the child exists so a seeding
+ // failure cannot leak one.
+ const tempDirs = [dataDir, profileDir];
+ const removeTempDirs = () => {
+ for (const dir of tempDirs) {
+ try {
+ rmSync(dir, { recursive: true, force: true });
+ } catch {}
+ }
+ };
+ let sidebarSeed = null;
+ try {
+ sidebarSeed = await seedSidebarProjects(hostBinary, dataDir, tempDirs);
+ } catch (error) {
+ removeTempDirs();
+ throw error;
+ }
const child = spawn(
electronBin,
[`--remote-debugging-port=${cdpPort}`, `--user-data-dir=${profileDir}`, "."],
@@ -204,19 +340,15 @@ async function main() {
if (process.platform === "win32" || !child.pid) child.kill("SIGKILL");
else process.kill(-child.pid, "SIGKILL");
} catch {}
- for (const dir of [dataDir, profileDir]) {
- try {
- rmSync(dir, { recursive: true, force: true });
- } catch {}
- }
+ removeTempDirs();
};
const timeout = setTimeout(() => {
- console.error("FAIL three-column layout — timeout after 180s");
+ console.error("FAIL three-column layout — timeout after 420s");
console.error(output.slice(-2_000));
cleanup();
process.exit(1);
- }, 180_000);
+ }, 420_000);
try {
const target = await waitFor(async () => {
@@ -233,6 +365,7 @@ async function main() {
const cdp = await CdpClient.connect(target.webSocketDebuggerUrl);
activeCdp = cdp;
await cdp.send("Runtime.enable");
+ await cdp.send("Emulation.setFocusEmulationEnabled", { enabled: true });
const measure = () => cdp.evaluate(MEASURE);
const rig = async (expression) => {
@@ -300,6 +433,12 @@ async function main() {
"startup splash cleared",
);
await rig(`window.__PI_DESKTOP__.ensureVisualFixtures()`);
+ // The seeded workspace already holds more sessions than the capture fixture
+ // is willing to add, so activate a seeded one: the shell needs an active
+ // session before the work panel can open.
+ await rig(
+ `window.__PI_DESKTOP__.selectSession(${JSON.stringify(sidebarSeed.alphaSessionIds[0])})`,
+ );
await waitFor(
() =>
cdp.evaluate(
@@ -1038,6 +1177,462 @@ async function main() {
}
await cdp.evaluate(`document.documentElement.dataset.theme = ${JSON.stringify(originalTheme)}`);
+ // 7. Sidebar project-group fold: one grid row, no fade, no snap.
+ //
+ // Measures the fold as it paints instead of restating the stylesheet.
+ const groupSelector = (key) =>
+ `[data-sidebar-project-group=${JSON.stringify(key)}]`;
+
+ const FOLD_PROBE = (key) => `(() => {
+ const section = document.querySelector(${JSON.stringify(groupSelector(key))});
+ const body = section?.querySelector(".sidebar-session-group-body.project") ?? null;
+ if (!body) return null;
+ const clip = section.querySelector(".sidebar-session-group-clip");
+ const list = section.querySelector(".sidebar-session-group-list");
+ const next = section.nextElementSibling;
+ const rows = body.querySelectorAll("[data-sidebar-session-row]");
+ const lastRow = rows.length > 0
+ ? rows[rows.length - 1]
+ : body.querySelector(".sidebar-session-empty");
+ const style = getComputedStyle(body);
+ const box = body.getBoundingClientRect();
+ return {
+ now: performance.now(),
+ key: section.getAttribute("data-sidebar-project-group"),
+ nextKey: next?.getAttribute("data-sidebar-project-group") ?? null,
+ collapsed: body.classList.contains("collapsed"),
+ inert: body.hasAttribute("inert"),
+ ariaHidden: body.getAttribute("aria-hidden"),
+ display: style.display,
+ gridRows: style.gridTemplateRows,
+ transitionProperty: style.transitionProperty,
+ transitionDuration: style.transitionDuration,
+ height: box.height,
+ bottom: box.bottom,
+ opacity: Number(style.opacity),
+ rows: rows.length,
+ dateHeaders: body.querySelectorAll(".sidebar-time-group-header").length,
+ emptyState: !!body.querySelector(".sidebar-session-empty"),
+ clipMinHeight: clip ? getComputedStyle(clip).minHeight : null,
+ clipOverflowY: clip ? getComputedStyle(clip).overflowY : null,
+ listGap: list ? getComputedStyle(list).rowGap : null,
+ listPadTop: list ? getComputedStyle(list).paddingTop : null,
+ listPadBottom: list ? getComputedStyle(list).paddingBottom : null,
+ // The scroller's own gap between two groups.
+ gapToNext: next
+ ? Math.round((next.getBoundingClientRect().top - box.bottom) * 100) / 100
+ : null,
+ // The 8px tail the rhythm promises: the last row (or the empty state) to
+ // the next group's header, which is the group's own 7px inset plus that
+ // 1px scroller gap.
+ lastRowBottom: lastRow ? lastRow.getBoundingClientRect().bottom : null,
+ contentTail:
+ next && lastRow
+ ? Math.round(
+ (next.getBoundingClientRect().top -
+ lastRow.getBoundingClientRect().bottom) * 100) / 100
+ : null,
+ };
+ })()`;
+
+ // A trusted pointer click, so the app's own hit testing and the row's click
+ // path both run. The button is scrolled into view and the point is confirmed
+ // to hit it before the press.
+ const toggleProjectGroup = async (key) => {
+ const deadline = Date.now() + 3_000;
+ let target = null;
+ while (Date.now() < deadline) {
+ target = await cdp.evaluate(`(() => {
+ const control = document.querySelector(${JSON.stringify(groupSelector(key) + " .sidebar-session-group-title")});
+ if (!control) return null;
+ control.scrollIntoView({ block: "nearest" });
+ const box = control.getBoundingClientRect();
+ const x = Math.round(box.left + box.width / 2);
+ const y = Math.round(box.top + box.height / 2);
+ const hit = document.elementFromPoint(x, y);
+ return { x, y, hit: !!hit && (hit === control || control.contains(hit)) };
+ })()`);
+ if (target?.hit) break;
+ await delay(100);
+ }
+ if (!target) throw new Error(`sidebar group ${key} has no title control`);
+ if (!target.hit) {
+ throw new Error(`sidebar group ${key} title is not hittable at ${target.x},${target.y}`);
+ }
+ await cdp.send("Input.dispatchMouseEvent", {
+ type: "mousePressed",
+ x: target.x,
+ y: target.y,
+ button: "left",
+ clickCount: 1,
+ buttons: 1,
+ });
+ await cdp.send("Input.dispatchMouseEvent", {
+ type: "mouseReleased",
+ x: target.x,
+ y: target.y,
+ button: "left",
+ clickCount: 1,
+ buttons: 0,
+ });
+ };
+
+ // The fold's own transition events are the duration evidence; wall clock
+ // sampled from this side measures the polling loop, not the animation.
+ const startFoldTrace = (key) =>
+ cdp.evaluate(`(() => {
+ const section = document.querySelector(${JSON.stringify(groupSelector(key))});
+ const body = section.querySelector(".sidebar-session-group-body.project");
+ if (window.__piFoldTrace) {
+ body.removeEventListener("transitionrun", window.__piFoldTrace.onRun);
+ body.removeEventListener("transitionend", window.__piFoldTrace.onEnd);
+ }
+ const trace = { start: performance.now(), runs: [], ends: [] };
+ const isFold = (event) => event.propertyName === "grid-template-rows";
+ trace.onRun = (event) => {
+ if (isFold(event)) trace.runs.push(Math.round(performance.now() - trace.start));
+ };
+ trace.onEnd = (event) => {
+ if (!isFold(event)) return;
+ trace.ends.push({
+ // Transition events report seconds.
+ ranMs: Math.round(event.elapsedTime * 1000),
+ atMs: Math.round(performance.now() - trace.start),
+ });
+ };
+ body.addEventListener("transitionrun", trace.onRun);
+ body.addEventListener("transitionend", trace.onEnd);
+ window.__piFoldTrace = trace;
+ return true;
+ })()`);
+
+ // Projected to plain values: the trace holds listeners, which do not survive
+ // the return-by-value boundary.
+ const readFoldTrace = () =>
+ cdp.evaluate(`({ runs: window.__piFoldTrace.runs, ends: window.__piFoldTrace.ends })`);
+
+ // Read from the outside rather than from a page timer: an occluded Electron
+ // window throttles requestAnimationFrame, while `Runtime.evaluate` keeps
+ // resolving the interpolated value for as long as the transition runs.
+ const sampleFold = async (key, steps, togglesAt) => {
+ await startFoldTrace(key);
+ const frames = [];
+ for (let step = 0; step < steps; step += 1) {
+ if (togglesAt.includes(step)) await toggleProjectGroup(key);
+ const frame = await cdp.evaluate(FOLD_PROBE(key));
+ if (!frame) throw new Error(`sidebar group ${key} is not rendered`);
+ frames.push(frame);
+ await delay(8);
+ }
+ return { frames, trace: await readFoldTrace() };
+ };
+
+ await cdp.send("Page.enable");
+ const sidebarPreferences = {
+ sessionMeta: Object.fromEntries(
+ sidebarSeed.pinnedSessionIds.map((id) => [id, { pinned: true }]),
+ ),
+ projectMeta: {
+ [sidebarSeed.paths.alpha]: { order: 0 },
+ [sidebarSeed.paths.beta]: { order: 1 },
+ [sidebarSeed.paths.gamma]: { order: 2 },
+ [sidebarSeed.paths.delta]: { order: 3 },
+ },
+ projectSort: "manual",
+ sessionView: { sort: "recent", archived: false },
+ openProjectPaths: sidebarSeed.keys,
+ };
+ await cdp.evaluate(
+ `window.localStorage.setItem("pi.desktop.sidebarPreferences", ${JSON.stringify(JSON.stringify(sidebarPreferences))})`,
+ );
+ await cdp.send("Page.reload", {});
+ // The retained-tab list is renderer-local and only read at startup, so the
+ // reload is what puts beta and gamma in the sidebar. Poll for the reloaded
+ // document's own DOM and keep the last reading for the failure detail.
+ const reloadDeadline = Date.now() + 90_000;
+ let reloadState = null;
+ while (Date.now() < reloadDeadline) {
+ reloadState = await cdp
+ .evaluate(`(() => ({
+ splash: !!document.querySelector(".startup-splash"),
+ sidebar: !!document.querySelector(".sidebar"),
+ keys: [...document.querySelectorAll("[data-sidebar-project-group]")].map((el) => el.getAttribute("data-sidebar-project-group")),
+ }))()`)
+ .catch((error) => ({ error: String(error.message).slice(0, 160) }));
+ const keys = reloadState.keys ?? [];
+ if (
+ sidebarSeed.keys.every((key) => keys.includes(key)) &&
+ reloadState.splash === false
+ ) {
+ break;
+ }
+ await delay(200);
+ }
+ // The assertion is that the seeded groups are back, not that the sidebar
+ // holds exactly those: the flow above this point can leave a project of its
+ // own, and the fold checks address the seeded groups by key.
+ const reloadedKeys = reloadState?.keys ?? [];
+ check(
+ reloadState?.splash === false &&
+ sidebarSeed.keys.every((key) => reloadedKeys.includes(key)),
+ "the seeded project groups are back after a renderer reload",
+ JSON.stringify(reloadState),
+ );
+ if (reloadState?.sidebar === false) {
+ await clickSidebarToggle();
+ }
+
+ const [alpha, beta, gamma] = await Promise.all(
+ [sidebarSeed.paths.alpha, sidebarSeed.paths.beta, sidebarSeed.paths.gamma].map(
+ (key) => cdp.evaluate(FOLD_PROBE(key)),
+ ),
+ );
+ const betaKey = sidebarSeed.paths.beta;
+
+ check(
+ alpha?.display === "grid" &&
+ alpha.gridRows !== "0px" &&
+ alpha.clipMinHeight === "0px" &&
+ alpha.clipOverflowY === "hidden" &&
+ alpha.listGap === "1px" &&
+ alpha.listPadTop === "2px" &&
+ alpha.listPadBottom === "7px",
+ "a project group folds as a three-layer grid, not a max-height box",
+ JSON.stringify({ alpha, beta, gamma }),
+ );
+ check(
+ alpha?.rows === 5 && alpha.dateHeaders === 3 && alpha.height > 0,
+ "the seeded multi-row group draws its rows and every date label",
+ JSON.stringify(alpha),
+ );
+ check(
+ beta?.rows === 1 && beta.height > 0 && beta.dateHeaders === 0,
+ "a one-row group folds the same way",
+ JSON.stringify(beta),
+ );
+ check(
+ gamma?.rows === 0 && gamma.emptyState === true && gamma.height > 0,
+ "an empty group folds its empty state like any other content",
+ JSON.stringify(gamma),
+ );
+ check(
+ alpha?.opacity === 1 &&
+ alpha.transitionProperty === "grid-template-rows" &&
+ alpha.transitionDuration === "0.2s" &&
+ alpha.inert === false &&
+ alpha.ariaHidden === "false",
+ "the grid transition is the only motion and opacity never animates",
+ JSON.stringify(alpha),
+ );
+ // The 8px tail is measurable only against a following group. The last group
+ // in the list has no neighbour, so it is proven from the group's own geometry
+ // instead — either layout is valid, and neither assertion depends on how many
+ // other projects the run happens to leave behind.
+ const seededTails = [alpha, beta, gamma].map((group) =>
+ group.nextKey
+ ? Math.abs(group.contentTail - 8) < 0.6
+ : group.contentTail === null &&
+ group.listPadBottom === "7px" &&
+ group.clipMinHeight === "0px" &&
+ group.clipOverflowY === "hidden",
+ );
+ check(
+ alpha.nextKey === betaKey &&
+ beta.nextKey === sidebarSeed.paths.gamma &&
+ seededTails.every(Boolean),
+ "the group's 7px inset plus the 1px scroller gap read as an 8px tail, empty state included",
+ JSON.stringify({
+ next: [alpha.nextKey, beta.nextKey, gamma.nextKey],
+ tails: [alpha.contentTail, beta.contentTail, gamma.contentTail],
+ tailsOk: seededTails,
+ }),
+ );
+
+ const listBudgets = await cdp.evaluate(`(() => {
+ const measure = (body) => {
+ if (!body) return null;
+ const rows = [...body.querySelectorAll("[data-sidebar-session-row]")];
+ const box = body.getBoundingClientRect();
+ return {
+ display: getComputedStyle(body).display,
+ maxHeight: parseFloat(getComputedStyle(body).maxHeight),
+ clientHeight: body.clientHeight,
+ scrollHeight: body.scrollHeight,
+ rows: rows.length,
+ rowsInside:
+ rows.filter((row) => row.getBoundingClientRect().bottom <= box.bottom + 0.5)
+ .length,
+ };
+ };
+ const pinned = measure(document.querySelector(".sidebar-session-group-body.pinned"));
+ return {
+ standalone: measure(document.querySelector(".sidebar-session-group-body.standalone")),
+ pinned,
+ // The renderer's budgets are min(233px, 30vh) and a flat 146px.
+ pinnedBudget: Math.min(233, window.innerHeight * 0.3),
+ };
+ })()`);
+ check(
+ listBudgets.standalone?.display === "flex" &&
+ listBudgets.standalone?.maxHeight === 146,
+ "the standalone list keeps its flex column and 146px budget",
+ JSON.stringify(listBudgets.standalone),
+ );
+ check(
+ listBudgets.pinned?.display === "flex" &&
+ listBudgets.pinned.rows === sidebarSeed.pinnedSessionIds.length &&
+ Math.abs(listBudgets.pinned.clientHeight - listBudgets.pinnedBudget) <= 1 &&
+ listBudgets.pinned.scrollHeight > listBudgets.pinned.clientHeight &&
+ listBudgets.pinned.rowsInside === 8,
+ "the seeded pinned list holds eight rows inside its 233px budget and scrolls the rest",
+ JSON.stringify({ pinned: listBudgets.pinned, budget: listBudgets.pinnedBudget }),
+ );
+ const pinnedScrolled = await cdp.evaluate(`(() => {
+ const body = document.querySelector(".sidebar-session-group-body.pinned");
+ if (!body) return null;
+ body.scrollTop = body.scrollHeight;
+ const rows = [...body.querySelectorAll("[data-sidebar-session-row]")];
+ const box = body.getBoundingClientRect();
+ const last = rows[rows.length - 1];
+ return {
+ scrollTop: body.scrollTop,
+ lastRowFullyInside:
+ last.getBoundingClientRect().bottom <= box.bottom + 0.5 &&
+ last.getBoundingClientRect().top >= box.top - 0.5,
+ };
+ })()`);
+ check(
+ pinnedScrolled !== null &&
+ pinnedScrolled.scrollTop > 0 &&
+ pinnedScrolled.lastRowFullyInside === true,
+ "the pinned list scrolls to its last row inside the budget",
+ JSON.stringify(pinnedScrolled),
+ );
+
+ const { frames: collapsedFrames, trace: collapseTrace } = await sampleFold(
+ sidebarSeed.paths.alpha,
+ 40,
+ [3],
+ );
+ const restHeight = collapsedFrames[2].height;
+ const settled = collapsedFrames[collapsedFrames.length - 1];
+ const midFrames = collapsedFrames.filter(
+ (frame) => frame.height > 0.5 && frame.height < restHeight - 0.5,
+ );
+ let reversed = false;
+ for (let index = 1; index < collapsedFrames.length; index += 1) {
+ if (collapsedFrames[index].height > collapsedFrames[index - 1].height + 0.75) {
+ reversed = true;
+ }
+ }
+ check(
+ midFrames.length >= 4 && !reversed,
+ "the collapse paints a continuous multi-frame height ramp with no plateau",
+ `mid-frames=${midFrames.length} heights=${collapsedFrames.map((f) => Math.round(f.height)).join(",")}`,
+ );
+ check(
+ Math.abs(restHeight - alpha.height) < 0.6 &&
+ settled.height <= 0.5 &&
+ settled.gridRows === "0px",
+ "the fold reaches its full height and closes completely",
+ `rest=${restHeight} settled=${settled.height}`,
+ );
+ check(
+ collapseTrace.runs.length === 1 &&
+ collapseTrace.ends.length === 1 &&
+ Math.abs(collapseTrace.ends[0].ranMs - 200) <= 10,
+ "the fold is one transition that runs for the declared 200ms",
+ JSON.stringify(collapseTrace),
+ );
+ check(
+ collapsedFrames.every((frame) => frame.opacity === 1),
+ "opacity stays 1 for every frame of the fold — the rows are clipped, not faded",
+ JSON.stringify([...new Set(collapsedFrames.map((f) => f.opacity))]),
+ );
+ check(
+ settled.gapToNext !== null &&
+ Math.abs(settled.gapToNext - 1) < 0.6 &&
+ settled.lastRowBottom !== null &&
+ settled.lastRowBottom > settled.bottom,
+ "the group's own tail leaves with its rows: the folded section is its header plus the 1px scroller gap, and the rows sit past the clipped edge",
+ `gap=${settled.gapToNext} rows ${Math.round(settled.lastRowBottom - settled.bottom)}px past the section`,
+ );
+ check(
+ settled.collapsed === true &&
+ settled.inert === true &&
+ settled.ariaHidden === "true",
+ "the folded group leaves the tab order while its rows stay mounted",
+ JSON.stringify(settled),
+ );
+
+ const { frames: reopenFrames, trace: reopenTrace } = await sampleFold(
+ sidebarSeed.paths.alpha,
+ 40,
+ [3],
+ );
+ const reopenedFold = reopenFrames[reopenFrames.length - 1];
+ check(
+ Math.abs(reopenedFold.height - restHeight) < 0.6 &&
+ reopenedFold.collapsed === false &&
+ reopenedFold.inert === false &&
+ Math.abs(reopenedFold.contentTail - 8) < 0.6 &&
+ reopenTrace.ends.length === 1 &&
+ Math.abs(reopenTrace.ends[0].ranMs - 200) <= 10,
+ "expanding restores the same height and the 8px tail in one 200ms transition",
+ JSON.stringify({ reopenedFold, trace: reopenTrace }),
+ );
+
+ // A reversal mid-flight must continue from the frame it is on rather than
+ // restarting or settling on a stale endpoint.
+ const { frames: reversalFrames } = await sampleFold(sidebarSeed.paths.alpha, 46, [3, 9]);
+ const reversalEnd = reversalFrames[reversalFrames.length - 1];
+ const reversalDipped = Math.min(...reversalFrames.map((frame) => frame.height));
+ check(
+ Math.abs(reversalEnd.height - restHeight) < 0.6,
+ "a collapse reversed mid-flight settles back on the open height",
+ `end=${reversalEnd.height} rest=${restHeight} dip=${Math.round(reversalDipped)}`,
+ );
+ check(
+ reversalDipped < restHeight - 0.5 &&
+ !reversalFrames.some((frame) => frame.height > restHeight + 0.75),
+ "the reversed fold turns on the frame it reached and never overshoots",
+ `dip=${Math.round(reversalDipped)} max=${Math.round(Math.max(...reversalFrames.map((f) => f.height)))}`,
+ );
+
+ await cdp.send("Emulation.setEmulatedMedia", {
+ features: [{ name: "prefers-reduced-motion", value: "reduce" }],
+ });
+ const { frames: reducedFrames, trace: reducedTrace } = await sampleFold(
+ sidebarSeed.paths.alpha,
+ 24,
+ [3],
+ );
+ const reducedSettled = reducedFrames[reducedFrames.length - 1];
+ const reducedMids = reducedFrames.filter(
+ (frame) => frame.height > 0.5 && frame.height < restHeight - 0.5,
+ );
+ check(
+ reducedSettled.height <= 0.5 &&
+ reducedSettled.collapsed === true &&
+ reducedMids.length <= 1 &&
+ reducedTrace.ends.length >= 1 &&
+ reducedTrace.ends[0].ranMs <= 5,
+ "reduced motion keeps the endpoints and drops the travel",
+ JSON.stringify({ mids: reducedMids.length, settled: reducedSettled.height, trace: reducedTrace }),
+ );
+ await cdp.send("Emulation.setEmulatedMedia", { features: [] });
+ await toggleProjectGroup(sidebarSeed.paths.alpha);
+ await waitFor(
+ () => cdp.evaluate(`${FOLD_PROBE(sidebarSeed.paths.alpha)}.collapsed === false`),
+ "the folded group reopens after the reduced-motion probe",
+ );
+ await cdp.evaluate(`document.documentElement.dataset.theme = ${JSON.stringify(originalTheme)}`);
+
+ await checkSidebarRowStates({ cdp, check, waitFor, seed: sidebarSeed });
+ await checkSidebarSettings({
+ cdp, check, waitFor, artifactDir: process.env.PI_DESKTOP_LAYOUT_ARTIFACT_DIR,
+ });
+
const failed = results.filter((entry) => !entry.ok);
console.log(
`\nE2E-LAYOUT-three-column-width-priority: ${results.length - failed.length}/${results.length} checks passed`,
diff --git a/scripts/e2e/sidebar-row-states.mjs b/scripts/e2e/sidebar-row-states.mjs
new file mode 100644
index 000000000..4df7ec1fe
--- /dev/null
+++ b/scripts/e2e/sidebar-row-states.mjs
@@ -0,0 +1,217 @@
+import { setTimeout as delay } from "node:timers/promises";
+
+export async function checkSidebarRowStates({ cdp, check, waitFor, seed }) {
+ const group = (key) => `[data-sidebar-project-group=${JSON.stringify(key)}]`;
+ const row = (id) => `[data-sidebar-session-row=${JSON.stringify(id)}]`;
+ const title = (key) => `${group(key)} .project-toggle`;
+ const header = (key) => `${group(key)} .sidebar-session-group-header`;
+ const transparent = "rgba(0, 0, 0, 0)";
+ const originalTheme = await cdp.evaluate("document.documentElement.dataset.theme");
+
+ const paint = (selector) => cdp.evaluate(`(() => {
+ const element = document.querySelector(${JSON.stringify(selector)});
+ if (!element) throw new Error('Missing row-state target');
+ const style = getComputedStyle(element);
+ return {
+ background: style.backgroundColor, color: style.color,
+ radius: style.borderRadius, transition: style.transition,
+ duration: parseFloat(style.transitionDuration),
+ outline: style.outlineStyle, outlineWidth: parseFloat(style.outlineWidth),
+ focusVisible: element.matches(':focus-visible'), hovered: element.matches(':hover'),
+ selected: element.classList.contains('active'),
+ current: element.getAttribute('data-current-workspace'),
+ };
+ })()`);
+ const point = async (selector) => {
+ let target;
+ await waitFor(async () => {
+ target = await cdp.evaluate(`(() => {
+ const element = document.querySelector(${JSON.stringify(selector)});
+ if (!element) return null;
+ element.scrollIntoView({ block: 'nearest' });
+ const box = element.getBoundingClientRect();
+ const x = Math.round(box.left + box.width / 2);
+ const y = Math.round(box.top + box.height / 2);
+ const hit = document.elementFromPoint(x, y);
+ return { x, y, hit: hit === element || element.contains(hit) };
+ })()`);
+ return target?.hit;
+ }, `row-state target is hittable: ${selector}`);
+ return target;
+ };
+ const move = async (x, y) => {
+ await cdp.send("Input.dispatchMouseEvent", { type: "mouseMoved", x, y });
+ await delay(180);
+ };
+ const hover = async (selector) => {
+ const target = await point(selector);
+ await move(target.x, target.y);
+ };
+ const click = async (selector) => {
+ const target = await point(selector);
+ await cdp.send("Input.dispatchMouseEvent", {
+ type: "mousePressed", x: target.x, y: target.y, button: "left", buttons: 1, clickCount: 1,
+ });
+ await cdp.send("Input.dispatchMouseEvent", {
+ type: "mouseReleased", x: target.x, y: target.y, button: "left", buttons: 0, clickCount: 1,
+ });
+ };
+ const selectedIds = () => cdp.evaluate(`
+ [...document.querySelectorAll('.thread-item.active')].map(el => el.dataset.sidebarSessionRow)
+ `);
+ const select = async (id) => {
+ await click(`${row(id)} .thread-item-main`);
+ await waitFor(async () => {
+ const ids = await selectedIds();
+ return ids.length === 1 && ids[0] === id;
+ }, `only session ${id} is selected`);
+ await move(600, 120);
+ };
+ const pressTab = async (reverse = false) => {
+ const modifiers = reverse ? 8 : 0;
+ await cdp.send("Input.dispatchKeyEvent", {
+ type: "keyDown", key: "Tab", code: "Tab", windowsVirtualKeyCode: 9, modifiers,
+ });
+ await cdp.send("Input.dispatchKeyEvent", {
+ type: "keyUp", key: "Tab", code: "Tab", windowsVirtualKeyCode: 9, modifiers,
+ });
+ };
+
+ try {
+ await cdp.evaluate("window.dispatchEvent(new Event('focus'))");
+ for (const theme of ["dark", "light"]) {
+ await cdp.evaluate(`document.documentElement.dataset.theme = ${JSON.stringify(theme)}`);
+ const id = seed.alphaSessionIds[0];
+ await select(id);
+ const selectedRest = await paint(row(id));
+ const groupRest = await paint(header(seed.paths.alpha));
+ const context = await paint(group(seed.paths.alpha));
+ check(
+ groupRest.background === transparent && context.current === "true" && !context.selected &&
+ selectedRest.selected && selectedRest.background !== transparent,
+ `${theme} selected conversation is independent from the unfilled current workspace`,
+ JSON.stringify({ groupRest, context, selectedRest }),
+ );
+ await hover(title(seed.paths.alpha));
+ const groupHover = await paint(header(seed.paths.alpha));
+ const titleHover = await paint(title(seed.paths.alpha));
+ await hover(`${row(seed.alphaSessionIds[1])} .thread-item-main`);
+ const rowHover = await paint(row(seed.alphaSessionIds[1]));
+ check(
+ groupHover.hovered && rowHover.hovered && groupHover.background !== transparent &&
+ groupHover.background === rowHover.background && groupHover.color === rowHover.color &&
+ groupHover.radius === rowHover.radius && groupHover.transition === rowHover.transition &&
+ titleHover.background === transparent,
+ `${theme} project and conversation hover share one row surface, never a nested title fill`,
+ JSON.stringify({ groupHover, titleHover, rowHover }),
+ );
+ await hover(`${row(id)} .thread-item-main`);
+ const selectedHover = await paint(row(id));
+ check(
+ selectedHover.hovered && selectedHover.background === selectedRest.background,
+ `${theme} selected fill wins over hover without a second background`,
+ JSON.stringify({ selectedRest, selectedHover }),
+ );
+
+ await hover(title(seed.paths.alpha));
+ await cdp.evaluate("window.dispatchEvent(new Event('blur'))");
+ await delay(180);
+ const blurredHeader = await paint(header(seed.paths.alpha));
+ const blurredSelected = await paint(row(id));
+ check(
+ blurredHeader.background === transparent && blurredSelected.background === selectedRest.background,
+ `${theme} window-blur handling releases hover but preserves selection`,
+ JSON.stringify({ blurredHeader, blurredSelected }),
+ );
+ await cdp.evaluate("window.dispatchEvent(new Event('focus'))");
+ await hover(title(seed.paths.alpha));
+ await cdp.evaluate(`document.querySelector(${JSON.stringify(group(seed.paths.alpha))}).classList.add('is-drop-target')`);
+ await delay(180);
+ const dropHover = await paint(header(seed.paths.alpha));
+ check(
+ dropHover.background !== groupHover.background && dropHover.outline === "solid",
+ `${theme} drop-target styling retains priority over header hover`,
+ JSON.stringify(dropHover),
+ );
+ await cdp.evaluate(`document.querySelector(${JSON.stringify(group(seed.paths.alpha))}).classList.remove('is-drop-target')`);
+
+ await hover(`${header(seed.paths.alpha)} .sidebar-session-group-add`);
+ const actionHover = await paint(`${header(seed.paths.alpha)} .sidebar-session-group-add`);
+ check(
+ actionHover.hovered && actionHover.background !== transparent &&
+ (await paint(title(seed.paths.alpha))).background === transparent,
+ `${theme} independent project action keeps its own hover feedback`,
+ JSON.stringify(actionHover),
+ );
+ await move(600, 120);
+ await cdp.evaluate(`document.querySelector(${JSON.stringify(title(seed.paths.alpha))}).focus()`);
+ await pressTab();
+ await pressTab(true);
+ const focusedTitle = await paint(title(seed.paths.alpha));
+ check(
+ focusedTitle.focusVisible && focusedTitle.outline !== "none" && focusedTitle.outlineWidth > 0 &&
+ focusedTitle.background === transparent && (await paint(header(seed.paths.alpha))).background === transparent,
+ `${theme} keyboard focus has an outline without a second selection surface`,
+ JSON.stringify(focusedTitle),
+ );
+ await click(title(seed.paths.alpha));
+ await waitFor(() => cdp.evaluate(`document.querySelector(${JSON.stringify(group(seed.paths.alpha) + ' .sidebar-session-group-body')}).inert`), "selected group folds");
+ await move(600, 120);
+ check(
+ (await selectedIds()).join() === id && (await paint(header(seed.paths.alpha))).background === transparent,
+ `${theme} folding a selected conversation never transfers selection to its project`,
+ );
+ await click(title(seed.paths.alpha));
+ await waitFor(() => cdp.evaluate(`!document.querySelector(${JSON.stringify(group(seed.paths.alpha) + ' .sidebar-session-group-body')}).inert`), "selected group reopens");
+ await delay(250);
+
+ const pinnedId = seed.pinnedSessionIds[0];
+ await select(pinnedId);
+ check(
+ (await paint(group(seed.paths.delta))).current === "true" &&
+ (await paint(header(seed.paths.delta))).background === transparent &&
+ (await paint(row(pinnedId))).background === selectedRest.background,
+ `${theme} pinned conversations use the same selection without selecting their group`,
+ );
+ await select("e2e-state-standalone");
+ check(
+ (await paint(row("e2e-state-standalone"))).background === selectedRest.background &&
+ await cdp.evaluate("!document.querySelector('.project-group.active') && !document.querySelector('[data-current-workspace]')"),
+ `${theme} standalone conversation selection clears workspace context without selecting a group`,
+ );
+ await select(id);
+ await click('[data-nav="settings"]');
+ await waitFor(() => cdp.evaluate("!!document.querySelector('.settings-shell')"), "settings opens");
+ await move(600, 120);
+ check(
+ (await selectedIds()).length === 0 && await cdp.evaluate("!document.querySelector('.sidebar')"),
+ `${theme} settings replaces navigation without leaving stale selected rows`,
+ );
+ await click('[data-nav="back-to-app"]');
+ await waitFor(() => cdp.evaluate("!!document.querySelector('.sidebar')"), "sidebar returns from settings");
+ await move(600, 120);
+ check(
+ (await selectedIds()).join() === id && (await paint(group(seed.paths.alpha))).current === "true" &&
+ (await paint(header(seed.paths.alpha))).background === transparent,
+ `${theme} returning from settings restores conversation selection and independent workspace context`,
+ );
+ }
+ await cdp.send("Emulation.setEmulatedMedia", {
+ features: [{ name: "prefers-reduced-motion", value: "reduce" }],
+ });
+ const reducedHeader = await paint(header(seed.paths.alpha));
+ const reducedRow = await paint(row(seed.alphaSessionIds[0]));
+ check(
+ reducedHeader.duration <= 0.00001 && reducedRow.duration <= 0.00001,
+ "reduced motion suppresses both project and conversation hover transitions",
+ JSON.stringify({ reducedHeader, reducedRow }),
+ );
+ } finally {
+ await cdp.send("Emulation.setEmulatedMedia", { features: [] });
+ await cdp.evaluate(`(() => {
+ document.documentElement.dataset.theme = ${JSON.stringify(originalTheme)};
+ document.querySelectorAll('.project-group.is-drop-target').forEach(el => el.classList.remove('is-drop-target'));
+ window.dispatchEvent(new Event('focus'));
+ })()`);
+ }
+}