Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(sidebar): keep projects reachable at high zoom
Linuxdazhaof266499ee30c
diff --git a/apps/desktop/src/components/Sidebar.tsx b/apps/desktop/src/components/Sidebar.tsxindex b0c9ae018..0c233a2c7 100644--- a/apps/desktop/src/components/Sidebar.tsx+++ b/apps/desktop/src/components/Sidebar.tsx@@ -2610,7 +2610,7 @@ export function Sidebar({</div></div>- <div className="sidebar-body no-drag">+ <div className="sidebar-body no-drag" onScroll={() => closeMenus(false)}><SidebarPrimaryNav onNewTask={onNewTask} onBeforeNavigate={() => closeMenus(false)} />{pinnedSessions.length > 0 ? (@@ -2757,7 +2757,7 @@ export function Sidebar({</div><div- className={`sidebar-session-groups min-h-0 flex-1 overflow-auto px-0.5 ${projectsDropActive ? "is-drop-target" : ""}`}+ className={`sidebar-session-groups px-0.5 ${projectsDropActive ? "is-drop-target" : ""}`}onScroll={() => {if (sessionMenu || projectMenu || sectionMenu || sortOpen) closeMenus(false);}}diff --git a/apps/desktop/src/styles/chrome.css b/apps/desktop/src/styles/chrome.cssindex 69a14f54c..f034528e9 100644--- a/apps/desktop/src/styles/chrome.css+++ b/apps/desktop/src/styles/chrome.css@@ -1445,7 +1445,7 @@flex: 1 1 auto;flex-direction: column;padding: 0 8px 6px;- overflow: hidden;+ overflow: hidden auto;}.brand {diff --git a/apps/desktop/src/styles/sidebar-threads.css b/apps/desktop/src/styles/sidebar-threads.cssindex c60d2ad93..ec2931a4c 100644--- a/apps/desktop/src/styles/sidebar-threads.css+++ b/apps/desktop/src/styles/sidebar-threads.css@@ -106,7 +106,8 @@.sidebar-session-groups {display: flex;- min-height: 0;+ /* Keep room for a project header and one conversation row with their insets. */+ min-height: 60px;/* Basis 0, not auto: with a content-derived basis the scroller's resolvedheight is re-solved from its own content, so collapsing the first projectnudges the whole list up a few pixels before it settles back. */@@ -119,7 +120,6 @@gap: 1px;overflow-x: hidden;overflow-y: auto;- overscroll-behavior-y: contain;padding-top: 2px;}@@ -303,30 +303,30 @@/* Ten compact 28px rows plus the nine 1px gaps between them, and the 2pxlabel inset, before the Recent list starts scrolling internally. */max-height: 291px;- min-height: 0;overflow-x: hidden;overflow-y: auto;- overscroll-behavior-y: contain;/* 2px below the section label, matching every label-to-content pair. */padding: 2px 2px 0;}-.sidebar-standalone-sessions {+.sidebar-standalone-sessions,+.sidebar-pinned-sessions {+ display: grid;min-width: 0;- flex: 0 0 auto;+ /* Allow shrinking below the list's intrinsic height while keeping its label+ and a compact row reachable. */+ min-height: 60px;+ flex: 0 1 auto;+ grid-template-rows: auto minmax(30px, 1fr);}/* Projects hidden in Settings: the session list takes the freed height. */.sidebar-standalone-sessions.is-fill {- display: flex;- min-height: 0;flex: 1 1 auto;- flex-direction: column;}.sidebar-standalone-sessions.is-fill .sidebar-session-group-body.standalone {max-height: none;- flex: 1 1 auto;}.sidebar-session-empty {@@ -336,18 +336,12 @@line-height: var(--leading-compact);}-.sidebar-pinned-sessions {- min-width: 0;- flex: 0 0 auto;-}-.sidebar-session-group-body.pinned {/* Eight compact 28px rows plus their seven 1px gaps, and the 2px labelinset. */max-height: min(233px, 30vh);overflow-x: hidden;overflow-y: auto;- overscroll-behavior-y: contain;/* 2px below the section label, matching every label-to-content pair. */padding: 2px 2px 0;}diff --git a/apps/desktop/test/fixtures/sidebar-height.tsx b/apps/desktop/test/fixtures/sidebar-height.tsxnew file mode 100644index 000000000..50581d74a--- /dev/null+++ b/apps/desktop/test/fixtures/sidebar-height.tsx@@ -0,0 +1,62 @@+import { flushSync } from "react-dom";+import { createRoot } from "react-dom/client";+import i18n from "i18next";+import { initReactI18next } from "react-i18next";+import { Sidebar } from "../../src/components/Sidebar";+import { useAppStore } from "../../src/stores/app-store";+import "../../src/styles/globals.css";++async function renderSidebar() {+ await i18n.use(initReactI18next).init({+ lng: "en",+ resources: { en: { translation: { nav: { recentSessions: "Recent sessions" } } } },+ });++ const projectPath = "/fixture/project";+ const calls: string[] = [];+ const sessions = Array.from({ length: 19 }, (_, index) => {+ const date = new Date(Date.UTC(2026, 0, 1, 0, 19 - index)).toISOString();+ return {+ id: `session-${index}`,+ title: `Session ${index}`,+ projectPath,+ createdAt: date,+ updatedAt: date,+ };+ });+ useAppStore.setState({+ page: "chat",+ sessions,+ openProjectPaths: [projectPath],+ sessionMeta: { "session-0": { pinned: true } },+ prefetchSession: async () => {},+ selectSession: async (id) => { calls.push(id); },+ });+ const root = createRoot(document.getElementById("root")!);+ flushSync(() => root.render(+ <div className="app-shell">+ <div className="app-shell-body">+ <Sidebar+ sidebarWidth={280}+ sidebarToggleShortcut=""+ onToggleSidebar={() => {}}+ onNewTask={() => {}}+ onWidthChange={() => {}}+ onWidthCommit={() => {}}+ onResizeCollapse={() => {}}+ />+ </div>+ </div>,+ ));+ return {+ calls,+ showMorePins() {+ const pins = [sessions[0], ...sessions.slice(-6)];+ useAppStore.setState({+ sessionMeta: Object.fromEntries(pins.map(({ id }) => [id, { pinned: true }])),+ });+ },+ };+}++Object.assign(window, { sidebarProbe: renderSidebar() });diff --git a/apps/desktop/test/sidebar-height.test.mjs b/apps/desktop/test/sidebar-height.test.mjsnew file mode 100644index 000000000..8f6bb1254--- /dev/null+++ b/apps/desktop/test/sidebar-height.test.mjs@@ -0,0 +1,152 @@+import assert from "node:assert/strict";+import { execFile } from "node:child_process";+import { mkdtemp, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import test from "node:test";+import { promisify } from "node:util";+import tailwindcss from "@tailwindcss/vite";+import { build } from "vite";+import { repositoryRoot, resolveElectronBinary } from "../../../scripts/e2e/boot.mjs";++const root = repositoryRoot();+const desktop = join(root, "apps/desktop");+const run = promisify(execFile);++const inspectSidebar = async () => {+ await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));+ const body = document.querySelector(".sidebar-body");+ const recent = document.querySelector(".sidebar-session-group-body.standalone");+ const pinned = document.querySelector(".sidebar-session-group-body.pinned");+ const projects = document.querySelector(".sidebar-session-groups");+ const pointFor = (selector) => {+ const element = document.querySelector(selector);+ if (!element) return null;+ const box = element.getBoundingClientRect();+ const x = box.left + box.width / 2;+ const y = box.top + box.height / 2;+ return element.contains(document.elementFromPoint(x, y)) ? { x, y } : null;+ };+ return {+ viewport: innerHeight,+ pinned: pinned.clientHeight,+ recent: recent.clientHeight,+ recentCount: recent.querySelectorAll("[data-sidebar-session-row]").length,+ projectHeight: projects.clientHeight,+ project: pointFor('.sidebar-session-groups [data-sidebar-session-row="session-1"] .thread-item-main'),+ settings: pointFor('[data-nav="settings"]'),+ outerOverflow: body.scrollHeight - body.clientHeight,+ outerScroll: getComputedStyle(body).overflowY,+ };+};++test("sidebar keeps project sessions and Settings reachable after loading more and zooming", {+ skip: process.platform === "linux" && !process.env.DISPLAY && "Electron requires a display",+}, async (t) => {+ const temp = await mkdtemp(join(tmpdir(), "pi-sidebar-height-"));+ try {+ await build({+ configFile: false,+ root: desktop,+ base: "./",+ logLevel: "error",+ plugins: [tailwindcss()],+ esbuild: { jsx: "automatic" },+ resolve: {+ alias: [+ { find: /^@pi-desktop\/shared$/, replacement: join(root, "packages/shared/src/index.ts") },+ { find: /^@pi-desktop\/i18n$/, replacement: join(root, "packages/i18n/src/index.ts") },+ ],+ },+ build: {+ outDir: temp,+ target: "esnext",+ cssCodeSplit: false,+ rollupOptions: {+ input: join(desktop, "test/fixtures/sidebar-height.tsx"),+ output: {+ format: "iife",+ inlineDynamicImports: true,+ entryFileNames: "sidebar.js",+ assetFileNames: "assets/[name][extname]",+ },+ },+ },+ });+ await writeFile(join(temp, "index.html"), `<!doctype html>+ <html lang="en" data-platform="${process.platform}"><meta charset="utf-8">+ <meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:">+ <link rel="stylesheet" href="assets/style.css"><div id="root"></div><script defer src="sidebar.js"></script>`);+ await writeFile(join(temp, "main.cjs"), `+const assert = require("node:assert/strict");+const { app, BrowserWindow } = require("electron");+const { join } = require("node:path");+app.setPath("userData", join(__dirname, "profile"));+app.whenReady().then(async () => {+ const win = new BrowserWindow({+ show: false, width: 1040, height: 720, useContentSize: true,+ webPreferences: { sandbox: true, backgroundThrottling: false },+ });+ const wc = win.webContents;+ const evaluate = (code) => wc.executeJavaScript(code);+ const inspect = () => evaluate(${JSON.stringify(`(${inspectSidebar})()`)});+ await win.loadFile(join(__dirname, "index.html"));+ await evaluate("window.sidebarProbe.then(() => true)");+ assert.equal((await inspect()).recentCount, 7);+ await evaluate(${JSON.stringify('document.querySelector(\'[data-action="recent-sessions-load-more"]\').click()')});+ const loaded = await inspect();+ assert.equal(loaded.recentCount, 17);+ assert.ok(loaded.project, JSON.stringify(loaded));++ const compactZoom = win.getContentSize()[1] / 490;+ wc.setZoomFactor(compactZoom);+ const compact = await inspect();+ assert.ok(Math.abs(compact.viewport - 490) <= 1, JSON.stringify(compact));+ assert.equal(compact.recentCount, 17);+ assert.ok(compact.project, "Project row clipped: " + JSON.stringify(compact));+ assert.ok(compact.recent < loaded.recent, JSON.stringify(compact));+ assert.ok(compact.settings, JSON.stringify(compact));+ const point = {+ x: Math.round(compact.project.x * wc.getZoomFactor()),+ y: Math.round(compact.project.y * wc.getZoomFactor()),+ button: "left", clickCount: 1,+ };+ wc.sendInputEvent({ type: "mouseDown", ...point });+ wc.sendInputEvent({ type: "mouseUp", ...point });+ await inspect();+ assert.deepEqual(await evaluate("window.sidebarProbe.then(({ calls }) => calls)"), ["session-1"]);+ console.log(JSON.stringify({ compactViewport: compact.viewport, recentHeight: compact.recent, projectHeight: compact.projectHeight }));++ wc.setZoomFactor(3);+ const extreme = await inspect();+ assert.ok(extreme.outerOverflow > 0);+ assert.equal(extreme.outerScroll, "auto");+ await evaluate("document.querySelector('[data-nav=settings]').scrollIntoView()");+ assert.ok((await inspect()).settings);+ await evaluate("document.querySelector('.sidebar-session-groups').scrollIntoView()");+ assert.ok((await inspect()).project);++ wc.setZoomFactor(1);+ const restored = await inspect();+ assert.equal(restored.recentCount, loaded.recentCount);+ assert.equal(restored.recent, loaded.recent);+ assert.ok(restored.project);++ await evaluate("window.sidebarProbe.then((probe) => probe.showMorePins())");+ const roomyPins = await inspect();+ wc.setZoomFactor(compactZoom);+ const compactPins = await inspect();+ assert.ok(compactPins.pinned < roomyPins.pinned, JSON.stringify(compactPins));+ assert.ok(compactPins.project, JSON.stringify(compactPins));+}).then(() => app.exit(0), (error) => { console.error(error); app.exit(1); });+`);+ const env = { ...process.env };+ delete env.ELECTRON_RUN_AS_NODE;+ const { stdout } = await run(resolveElectronBinary(root).electronBinary, [join(temp, "main.cjs")], {+ env, timeout: 30_000,+ });+ t.diagnostic(stdout.trim());+ } finally {+ await rm(temp, { recursive: true, force: true });+ }+});diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 698e767ae..053c7ba08 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -1716,11 +1716,14 @@ near-zero duration. A folded group keeps its rows mounted, `aria-hidden`, and`updatedAt` first. A project conversation therefore appears both in Recentand in its project group, so it stays visible while that project is folded;a temporary conversation appears only in Recent. Recent opens with seven- rows; a trailing Load more button appends ten more per click. Its body is a- 291px window over ten compact 28px rows, their 1px row gaps, and the 2px- label inset; it scrolls internally when more rows are loaded. The Projects list uses the remaining- sidebar height and scrolls independently; neither region scrolls the footer- or primary navigation. Both list scrollbars use the same global 6px,+ rows; a trailing Load more button appends ten more per click. With Projects+ shown, Recent sessions can grow to 291px, and both Recent and Pinned sessions+ shrink into independently scrolling lists when the sidebar runs out of room.+ The Projects list uses the remaining height and reserves room for a project+ header and one conversation row. When the minimum sizes exceed the+ available height, the sidebar body scrolls so Projects and Settings remain+ reachable. Resizing or changing zoom preserves the loaded rows. The list+ scrollbars use the same global 6px,trackless, transparent-at-rest rule as the conversation and work-panelscrollbars; the semantic-ink thumb appears when its list is hovered, focused,or scrolling and remains visible while dragging, so the independent regionsdiff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex 786207fb2..ccbdb8384 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -1881,11 +1881,12 @@ Project drag/drop follows these patterns:### 9.2 Sidebar scrolling-- The Recent sessions body is capped at ten compact rows and scrolls- internally once Load more has added rows beyond that height.-- Retained project groups occupy the remaining sidebar height and scroll in a- separate region. Both regions stay independent from the footer and primary- navigation.+- When Projects is shown, Recent sessions is capped at ten compact rows.+ Recent and Pinned sessions scroll internally as the sidebar gets shorter,+ keeping room for a project header and conversation row.+- Retained project groups scroll in their own region. If the minimum heights+ overflow the window, the sidebar body scrolls to expose Projects and the+ Settings footer. Loaded conversations stay loaded when space returns.- No horizontal scroll in sidebar- Scroll indicators use the platform's subtle overlay treatment withoutchanging either region's width. The 6px thumb is transparent at rest anddiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex d8fbb21d7..4f2e0b67f 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -215,6 +215,7 @@ identify the platform validation still needed.| A / C — Unicode stdio framing | E2E-RPC-unicode-separators || C / G / Quality — Plugins navigation | E2E-NAV-plugins-button-goes-back || C / D / Quality — Sidebar row states | E2E-LAYOUT-sidebar-row-states |+| C / D / Quality — Sidebar lists at high zoom | E2E-LAYOUT-sidebar-height || E / Quality — Browser screenshot timeout recovery | E2E-BROWSER-capture-resize || A / C / Quality — Sidebar material and settings return | E2E-LAYOUT-sidebar-settings || C / Quality — Destination loading and focus | E2E-087b |diff --git a/docs/spec/06-delivery/e2e/ui-shell.md b/docs/spec/06-delivery/e2e/ui-shell.mdindex a27e4e6e6..7872086cd 100644--- a/docs/spec/06-delivery/e2e/ui-shell.md+++ b/docs/spec/06-delivery/e2e/ui-shell.md@@ -3548,6 +3548,24 @@ PowerShell-launched fixture; activation must not restore the native outline.`sidebar-navigation.test.mjs`, `sidebar-pinned-rendering.test.mjs`, and`sidebar-project-sessions.test.mjs`.+## E2E-LAYOUT-sidebar-height++- **Preconditions**: Pinned sessions, Recent sessions, and Projects are visible.+ Seed one pinned conversation, at least seventeen unpinned conversations, and+ an expanded project containing a conversation.+- **Steps**: Click Load more in Recent sessions. Zoom in until the effective+ viewport height is roughly 490 CSS px. Click a conversation in the project.+ Zoom in further until the sidebar's minimum sizes overflow the viewport.+ Scroll to the Projects list and the Settings footer, then reset zoom.+- **Expected**: Recent and Pinned sessions can scroll within their lists.+ The project conversation opens at 490 CSS px. At extreme zoom the sidebar+ body scrolls and both Projects and Settings stay reachable. Resetting zoom+ restores space without resetting the loaded Recent sessions.+- **Specs linked**: `04-ux/08-component-spec.md`, `04-ux/09-interaction-patterns.md` §9.2+- **Acceptance**: C, D, Quality+- **Status**: Renderer coverage in `apps/desktop/test/sidebar-height.test.mjs`.+ The application menu shortcut and installed Windows build are manual checks.+## E2E-LAYOUT-sidebar-settings- **Preconditions**: Built desktop, isolated host/profile, visible chat sidebar.