Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(shell): browser-level verification for sidebar icon-collapse (#5676)

Honey Tyagief93d21f2acb
diff --git a/app/test/playwright/specs/sidebar-icon-collapse.spec.ts b/app/test/playwright/specs/sidebar-icon-collapse.spec.ts
new file mode 100644
index 0000000000..a45de0d44d
--- /dev/null
+++ b/app/test/playwright/specs/sidebar-icon-collapse.spec.ts
@@ -0,0 +1,302 @@
+import { expect, type Page, test } from '@playwright/test';
+
+import {
+ bootAuthenticatedPage,
+ dismissWalkthroughIfPresent,
+ waitForAppReady,
+} from '../helpers/core-rpc';
+
+/**
+ * Browser-level verification for issue #5676 ("Visually verify sidebar
+ * icon-collapse mode on desktop").
+ *
+ * jsdom cannot composite, has no window chrome, and does not paint CSS custom
+ * properties, so the unit suite can only assert class names and inline widths.
+ * These specs run against real Chromium: computed styles here are *resolved*
+ * colours, so a wrong token (`bg-line` instead of `bg-line-chrome`) fails even
+ * though the class name looks plausible.
+ *
+ * What this covers, per the issue's acceptance criteria:
+ *
+ * 1. Collapsed-state contract — `collapsible="icon"` keeps a real, non-zero
+ * {@link ICON_WIDTH_PX}px column mounted across repeated toggles and window
+ * resizes (the DOM half of the punch-through question; the native-layer half
+ * stays manual, see docs/qa/sidebar-icon-collapse.md).
+ * 2. Traffic-light clearance — the collapsed rail reserves its draggable strip
+ * above every rail item (geometry only; clickability is macOS-manual).
+ * 3. Seam colour — the rail indicator resolves to the live `--line-chrome`
+ * token on hover and focus, in light and dark, across four theme presets,
+ * and never to the plain `--line` token it replaced.
+ * 4. Drag resize — pointer drag resizes the column, arrow keys step it by
+ * {@link KEYBOARD_STEP_PX}, and the width persists across an app restart
+ * (`VITE_OPENHUMAN_E2E_RESTART_APP_AS_RELOAD` makes that a page reload in
+ * the web E2E build).
+ *
+ * Set `PW_SIDEBAR_SHOTS=1` to drop evidence screenshots into
+ * `test-results/sidebar-shots/`.
+ */
+
+const SIDEBAR = '[data-testid="root-shell-sidebar"]';
+const RAIL = '[data-testid="root-shell-divider"]';
+const REOPEN = '[data-testid="root-shell-reopen"]';
+const COLLAPSE_BUTTON = '[data-analytics-id="sidebar-header-collapse"]';
+
+/** Mirrors `SIDEBAR_ICON_WIDTH` in `app/src/components/ui/Sidebar.tsx`. */
+const ICON_WIDTH_PX = 56;
+/** Mirrors `SIDEBAR_KEYBOARD_STEP` in `app/src/components/ui/Sidebar.tsx`. */
+const KEYBOARD_STEP_PX = 16;
+/** Mirrors `WINDOW_DRAG_BAR_HEIGHT` in `app/src/components/layout/shell/WindowDragBar.tsx`. */
+const DRAG_STRIP_HEIGHT_PX = 28;
+/** Mirrors `SIDEBAR_MIN_WIDTH` / `SIDEBAR_MAX_WIDTH` in `app/src/components/ui/Sidebar.tsx`. */
+const MIN_WIDTH_PX = 188;
+const MAX_WIDTH_PX = 420;
+
+const SHOTS_DIR = 'test-results/sidebar-shots';
+
+interface ThemeCombo {
+ name: string;
+ familyId: string;
+ variant: 'light' | 'dark';
+}
+
+/**
+ * Four of the five built-in families, in both modes, including a light variant
+ * of a dark-default family (Matrix). The issue asks for at least two presets;
+ * these five cover classic (both), ocean, matrix-light and HAL 9000.
+ */
+const THEME_COMBOS: ThemeCombo[] = [
+ { name: 'classic-light', familyId: 'classic', variant: 'light' },
+ { name: 'classic-dark', familyId: 'classic', variant: 'dark' },
+ { name: 'ocean-dark', familyId: 'ocean', variant: 'dark' },
+ { name: 'matrix-light', familyId: 'matrix', variant: 'light' },
+ { name: 'hal9000-dark', familyId: 'hal9000', variant: 'dark' },
+];
+
+function tripleToRgb(triple: string): string {
+ const [r, g, b] = triple.trim().split(/\s+/).map(Number);
+ return `rgb(${r}, ${g}, ${b})`;
+}
+
+/**
+ * Seed the persisted theme before any app script boots. redux-persist stores
+ * every slice field as an individually stringified JSON value under
+ * `persist:<key>`, and requires `_persist` to treat the blob as valid.
+ */
+async function seedTheme(page: Page, combo: ThemeCombo): Promise<void> {
+ await page.addInitScript(({ familyId, variant }) => {
+ try {
+ const raw = localStorage.getItem('persist:theme');
+ const parsed: Record<string, string> = raw ? JSON.parse(raw) : {};
+ parsed.activeThemeId = JSON.stringify(familyId);
+ parsed.themeVariant = JSON.stringify(variant);
+ parsed.mode = JSON.stringify(variant);
+ if (!parsed._persist) {
+ parsed._persist = JSON.stringify({ version: -1, rehydrated: true });
+ }
+ localStorage.setItem('persist:theme', JSON.stringify(parsed));
+ } catch {
+ /* best effort: fall back to the default Classic light theme */
+ }
+ }, combo);
+}
+
+async function bootOnChat(page: Page, combo?: ThemeCombo): Promise<void> {
+ if (combo) await seedTheme(page, combo);
+ await bootAuthenticatedPage(page, 'pw-sidebar-shell', '/chat');
+ await dismissWalkthroughIfPresent(page);
+}
+
+async function sidebarWidthPx(page: Page): Promise<number> {
+ return page.locator(SIDEBAR).evaluate(el => el.getBoundingClientRect().width);
+}
+
+/**
+ * `sidebarWidth` as read back out of the per-user persisted layout blob
+ * (`${userId}:persist:layout`), i.e. what an app restart would rehydrate.
+ */
+async function persistedSidebarWidth(page: Page): Promise<number | null> {
+ return page.evaluate(() => {
+ const uid = localStorage.getItem('OPENHUMAN_ACTIVE_USER_ID');
+ const raw = uid ? localStorage.getItem(`${uid}:persist:layout`) : null;
+ if (!raw) return null;
+ try {
+ const parsed = JSON.parse(raw) as { panels?: string };
+ const panels = typeof parsed.panels === 'string' ? JSON.parse(parsed.panels) : parsed.panels;
+ const panel = panels?.['app-shell'] as { sidebarWidth?: number } | undefined;
+ return typeof panel?.sidebarWidth === 'number' ? panel.sidebarWidth : null;
+ } catch {
+ return null;
+ }
+ });
+}
+
+/** Resolved `R G B` triple of a token custom property on `<html>`. */
+async function tokenTriple(page: Page, token: string): Promise<string> {
+ return page.evaluate(
+ name => getComputedStyle(document.documentElement).getPropertyValue(name).trim(),
+ token
+ );
+}
+
+test.describe('Sidebar icon-collapse verification (#5676)', () => {
+ test('collapsed state keeps a real icon-width column mounted through toggles and resizes', async ({
+ page,
+ }) => {
+ await bootOnChat(page);
+
+ const sidebar = page.locator(SIDEBAR);
+ await expect(sidebar).toHaveAttribute('data-collapsible', 'icon');
+ await expect(sidebar).toHaveAttribute('data-state', 'expanded');
+
+ if (process.env.PW_SIDEBAR_SHOTS) {
+ await page.screenshot({ path: `${SHOTS_DIR}/expanded.png`, fullPage: false });
+ }
+
+ // Collapse via the header control the same way a user would.
+ await page.click(COLLAPSE_BUTTON);
+ await expect(sidebar).toHaveAttribute('data-state', 'collapsed');
+
+ // The column must stay mounted and hold the fixed icon width.
+ await expect(sidebar).toBeVisible();
+ expect(await sidebarWidthPx(page)).toBe(ICON_WIDTH_PX);
+ // The resize seam belongs to the expanded state only.
+ await expect(page.locator(RAIL)).toHaveCount(0);
+ // The reopen affordance and the icon nav rail are present inside the column.
+ await expect(page.locator(REOPEN)).toBeVisible();
+ await expect(sidebar.locator('nav').first()).toBeVisible();
+
+ if (process.env.PW_SIDEBAR_SHOTS) {
+ await page.screenshot({ path: `${SHOTS_DIR}/collapsed.png`, fullPage: false });
+ }
+
+ // Toggle repeatedly: the column must survive every transition mounted.
+ for (let i = 0; i < 3; i += 1) {
+ await page.locator(REOPEN).click();
+ await expect(sidebar).toHaveAttribute('data-state', 'expanded');
+ await page.click(COLLAPSE_BUTTON);
+ await expect(sidebar).toHaveAttribute('data-state', 'collapsed');
+ expect(await sidebarWidthPx(page)).toBe(ICON_WIDTH_PX);
+ }
+
+ // Resize the window while collapsed: the rail must keep its width.
+ await page.setViewportSize({ width: 1000, height: 700 });
+ expect(await sidebarWidthPx(page)).toBe(ICON_WIDTH_PX);
+ await page.setViewportSize({ width: 1280, height: 720 });
+
+ // Reopen once more so later assertions see the expanded shell.
+ await page.locator(REOPEN).click();
+ await expect(sidebar).toHaveAttribute('data-state', 'expanded');
+ });
+
+ test('collapsed rail reserves a traffic-light-clearing drag strip above its items', async ({
+ page,
+ }) => {
+ await bootOnChat(page);
+ await page.click(COLLAPSE_BUTTON);
+ await expect(page.locator(REOPEN)).toBeVisible();
+
+ const sidebarBox = await page.locator(SIDEBAR).boundingBox();
+ const strip = page.locator(`${SIDEBAR} [data-tauri-drag-region]`).first();
+ const stripBox = await strip.boundingBox();
+ if (!sidebarBox || !stripBox) throw new Error('collapsed rail geometry missing');
+
+ // Full-width strip pinned to the top of the column, one title-bar tall.
+ expect(stripBox.height).toBe(DRAG_STRIP_HEIGHT_PX);
+ expect(stripBox.x).toBeCloseTo(sidebarBox.x, 0);
+ expect(stripBox.y).toBeCloseTo(sidebarBox.y, 0);
+ expect(stripBox.width).toBeGreaterThanOrEqual(ICON_WIDTH_PX - 1);
+
+ // Every interactive item starts below the strip, clear of the lights zone.
+ const reopenBox = await page.locator(REOPEN).boundingBox();
+ expect(reopenBox?.y ?? 0).toBeGreaterThanOrEqual(stripBox.y + stripBox.height - 1);
+ });
+
+ for (const combo of THEME_COMBOS) {
+ test(`seam indicator resolves to line-chrome, never line: ${combo.name}`, async ({ page }) => {
+ await bootOnChat(page, combo);
+
+ // The seeded family/variant actually applied.
+ const isDark = await page.locator('html').evaluate(el => el.classList.contains('dark'));
+ expect(isDark).toBe(combo.variant === 'dark');
+ await expect(page.locator(SIDEBAR)).toHaveAttribute('data-state', 'expanded');
+
+ const chromeRgb = tripleToRgb(await tokenTriple(page, '--line-chrome'));
+ const plainLineRgb = tripleToRgb(await tokenTriple(page, '--line'));
+ // The two tokens must actually differ, or this assertion proves nothing.
+ expect(chromeRgb).not.toBe(plainLineRgb);
+
+ const rail = page.locator(RAIL);
+ const indicator = rail.locator('span').last();
+
+ // At rest the seam paints nothing.
+ const restColor = await indicator.evaluate(el => getComputedStyle(el).backgroundColor);
+ expect(restColor).toBe('rgba(0, 0, 0, 0)');
+
+ // Hover: resolved background settles exactly on --line-chrome. The
+ // indicator carries `transition-colors`, so poll rather than race it.
+ await rail.hover();
+ await expect
+ .poll(async () => indicator.evaluate(el => getComputedStyle(el).backgroundColor))
+ .toBe(chromeRgb);
+
+ // Focus: same verdict through the group-focus variant.
+ await rail.focus();
+ await expect
+ .poll(async () => indicator.evaluate(el => getComputedStyle(el).backgroundColor))
+ .toBe(chromeRgb);
+
+ if (process.env.PW_SIDEBAR_SHOTS) {
+ await page.screenshot({
+ path: `${SHOTS_DIR}/seam-hover-${combo.name}.png`,
+ fullPage: false,
+ });
+ }
+ });
+ }
+
+ test('drag resizes the column, arrow keys step it, and the width survives a restart', async ({
+ page,
+ }) => {
+ await bootOnChat(page);
+
+ const before = Math.round(await sidebarWidthPx(page));
+ expect(before).toBeGreaterThanOrEqual(MIN_WIDTH_PX);
+ expect(before).toBeLessThanOrEqual(MAX_WIDTH_PX);
+
+ // Pointer drag the rail +60px, like a mouse user would.
+ const rail = page.locator(RAIL);
+ const box = await rail.boundingBox();
+ if (!box) throw new Error('resize rail not mounted');
+ const grabY = box.y + box.height / 2;
+ await page.mouse.move(box.x + box.width / 2, grabY);
+ await page.mouse.down();
+ await page.mouse.move(box.x + box.width / 2 + 60, grabY, { steps: 10 });
+ await page.mouse.up();
+
+ const dragged = Math.min(MAX_WIDTH_PX, Math.max(MIN_WIDTH_PX, before + 60));
+ // The gesture commits once on release; poll instead of racing React.
+ await expect.poll(() => sidebarWidthPx(page), { timeout: 5_000 }).toBeCloseTo(dragged, 0);
+
+ // Arrow-key resize still applies, in both directions.
+ await rail.focus();
+ await page.keyboard.press('ArrowRight');
+ await expect
+ .poll(() => sidebarWidthPx(page), { timeout: 5_000 })
+ .toBeCloseTo(Math.min(MAX_WIDTH_PX, dragged + KEYBOARD_STEP_PX), 0);
+ await page.keyboard.press('ArrowLeft');
+ await expect.poll(() => sidebarWidthPx(page), { timeout: 5_000 }).toBeCloseTo(dragged, 0);
+
+ // The committed width reaches the per-user persisted blob (redux-persist
+ // throttles its writes, so wait for the payload rather than racing it).
+ await expect.poll(() => persistedSidebarWidth(page), { timeout: 5_000 }).toBe(dragged);
+
+ // App restart: in the web E2E build the sanctioned analogue of relaunching
+ // the desktop app is a full reload, which rehydrates that same blob.
+ await page.reload();
+ await waitForAppReady(page);
+ await dismissWalkthroughIfPresent(page);
+
+ await expect(page.locator(SIDEBAR)).toHaveAttribute('data-state', 'expanded');
+ await expect.poll(() => sidebarWidthPx(page), { timeout: 5_000 }).toBeCloseTo(dragged, 0);
+ });
+});
diff --git a/docs/QA-SIDEBAR-ICON-COLLAPSE.md b/docs/QA-SIDEBAR-ICON-COLLAPSE.md
new file mode 100644
index 0000000000..56ae90d871
--- /dev/null
+++ b/docs/QA-SIDEBAR-ICON-COLLAPSE.md
@@ -0,0 +1,127 @@
+# QA: Sidebar icon-collapse mode on desktop
+
+Closes the verification ask in [#5676]. The root shell's sidebar moved from
+`collapsible="offcanvas"` (column unmounts when collapsed) to
+`collapsible="icon"` (a real ~56px column that stays mounted), and `AppSidebar`
+now renders its own icon-only body by reading `useSidebar().state`. Three of the
+properties that changed are invisible to jsdom, and one is invisible to any
+browser: they need eyes on a real desktop build.
+
+Verification is split into two layers:
+
+| Layer | Covers | Where |
+| -------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
+| **Automated, real Chromium** against the web E2E build (real core + mock backend, same as CI Full) | Collapsed-state DOM contract, drag-strip geometry, resolved seam colours across modes and presets, resize + persistence mechanics | `app/test/playwright/specs/sidebar-icon-collapse.spec.ts` |
+| **Manual, desktop app** | Native-layer punch-through, macOS traffic-light clickability, persistence across a true process restart | This checklist |
+
+The automated layer already proves the following, so the manual pass does not
+need to re-derive them (it should still notice anything odd):
+
+- The collapsed column stays mounted at exactly 56px (`SIDEBAR_ICON_WIDTH`)
+ through three expand/collapse toggles and a window resize; the resize rail is
+ absent while collapsed; the reopen trigger and icon nav render inside the
+ column.
+- The collapsed rail's first element is a full-width, 28px (`h-7`) strip at the
+ very top of the column carrying `data-tauri-drag-region`, and every rail item
+ starts below it.
+- The resize seam indicator's rendered background resolves to exactly the live
+ `--line-chrome` token on hover and on focus, never the plain `--line` token,
+ in light and dark across Classic, Ocean, Matrix (light) and HAL 9000.
+- Pointer drag resizes the column (+60px drag lands as +60px width, clamped to
+ 188..420), arrow keys step by 16px both directions, and the committed width
+ reaches the per-user persisted layout blob and survives a page reload.
+
+Run the automated layer with:
+
+```bash
+pnpm test:e2e:web -- test/playwright/specs/sidebar-icon-collapse.spec.ts
+# or against an existing build:
+bash app/scripts/e2e-web-session.sh test/playwright/specs/sidebar-icon-collapse.spec.ts
+```
+
+Set `PW_SIDEBAR_SHOTS=1` to also drop evidence screenshots into
+`app/test-results/sidebar-shots/`.
+
+---
+
+## How to run the manual pass
+
+1. Build or run the desktop app for your platform (`pnpm dev:app`, or an
+ installed build). Sign in far enough to see the main shell with the sidebar.
+2. Walk the checklist below, ticking each box only after verifying the expected
+ outcome with your own eyes.
+3. Record results in the sign-off block and paste it into #5676.
+4. A defect found here is fixed separately: file it and link it from #5676.
+ Do not widen this issue.
+
+### macOS (required)
+
+- [ ] **No punch-through while collapsed** — Collapse the sidebar (header
+ button or mod+B). Look at the narrowed icon column: no content from
+ outside the app window bleeds through, no stale frame ghosts inside it,
+ and the chrome background reads continuous behind the rail icons. Then
+ toggle expanded <-> collapsed five times fast, and drag-resize the window
+ by its edges while collapsed. Expected: the rail repaints cleanly every
+ time; no flash of wrong content, no black rectangle, no torn frame.
+- [ ] **Traffic lights stay clear while collapsed** — With the sidebar
+ collapsed, the macOS window controls must sit on bare draggable chrome,
+ fully visible and clickable, not overlapping the first rail icon. Click
+ each traffic light (close last). Expected: every click lands on the
+ control, none gets swallowed by a rail button; dragging the window by the
+ strip above the icons moves the window.
+- [ ] **Traffic lights stay clear while expanded** — Same check with the
+ sidebar expanded: the controls sit over the sidebar header's empty left
+ edge and remain clickable.
+- [ ] **Seam colour under real compositing** — Expand the sidebar, hover the
+ 1px resize seam at the sidebar's right edge, then focus it with Tab.
+ Expected: a hairline appears on hover/focus, visibly matching the chrome
+ hairline tone, in both Appearance modes and under at least two theme
+ presets (Settings > Appearance / Theme Studio). It must not read as
+ nearly invisible (the old plain `line` token failure) nor as a hard black
+ line.
+- [ ] **Drag resize and true-restart persistence** — Drag the seam; the column
+ tracks the pointer and clamps at its narrowest/widest. Focus the seam and
+ press Left/Right; expected: 16px steps. Quit the app entirely (mod+Q) and
+ relaunch. Expected: the sidebar reopens at the dragged width. Also
+ collapse, quit, relaunch: expected: still collapsed.
+
+### Windows (recommended)
+
+- [ ] **No punch-through while collapsed** — Same steps as the macOS
+ punch-through item. The compositing concern is not macOS-specific; only
+ the traffic-light one is.
+- [ ] **Drag resize and true-restart persistence** — Same steps as the macOS
+ resize item. The title bar here is native, so skip the traffic-light row.
+
+### Linux (recommended)
+
+- [ ] **No punch-through while collapsed** — Same steps as the macOS
+ punch-through item, on the WebKitGTK build.
+- [ ] **Drag resize and true-restart persistence** — Same steps as the macOS
+ resize item. The title bar here is native, so skip the traffic-light row.
+
+---
+
+## Why the punch-through precondition was believed gone (context)
+
+The original `offcanvas` choice recorded: "the native webview glued to the
+content bounds has historically punched through a zero-width-but-present
+column." That mechanism belonged to CEF's per-provider child webviews
+(`webview_accounts` / the CDP scanners), which positioned a separate native
+surface by tracking a DOM placeholder's bounds. Both halves are gone: the CDP
+scanners and `webview_accounts` in #5478, and CEF itself in #5456 (Wry now;
+one webview total). `icon` mode additionally keeps the column non-zero-width in
+every state, which was the specific trigger. This pass exists because static
+analysis is the wrong instrument for a compositing question, not because the
+old failure was imaginary.
+
+## Sign-off
+
+```text
+Issue: #5676
+Tester: @<github-handle>
+Date: YYYY-MM-DD
+Platform(s) tested: [macOS arm64] [macOS x64] [Windows] [Linux]
+Automated suite commit/sha: <sha>
+Notes:
+```