Skip to content

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

feat(desktop): restore a resizable sidebar that collapses below 160px

vastsa168d893fa3a0
diff --git a/apps/desktop/src/components/Sidebar.tsx b/apps/desktop/src/components/Sidebar.tsx
index 3c6b0e880..7f00f423b 100644
--- a/apps/desktop/src/components/Sidebar.tsx
+++ b/apps/desktop/src/components/Sidebar.tsx
@@ -53,6 +53,7 @@ import {
SIDEBAR_WIDTH_MAX,
SIDEBAR_WIDTH_MIN,
} from "../lib/sidebar-preferences";
+import { SIDEBAR_RESIZE_STEP, sidebarPointerResize } from "../lib/sidebar-resize";
import { BrandLogo } from "./BrandLogo";
import { NotificationCenter } from "./NotificationCenter";
import { ProjectEditDialog } from "./ProjectEditDialog";
@@ -96,7 +97,7 @@ type ProjectEntry = {
};
const VIEWPORT_PADDING = 8;
-const SIDEBAR_RESIZE_STEP = 16;
+
/** Private MIME so a sidebar session drag is never mistaken for an OS file drop. */
const SESSION_DRAG_MIME = "application/x-pi-desktop-session";
@@ -198,16 +199,20 @@ export function Sidebar({
onToggleSidebar,
sidebarToggleShortcut,
sidebarWidth,
+ widthMax = SIDEBAR_WIDTH_MAX,
onWidthChange,
onWidthCommit,
+ onResizeCollapse,
className,
onAnimationEnd,
}: {
onToggleSidebar: () => void;
sidebarToggleShortcut: string;
sidebarWidth: number;
+ widthMax?: number;
onWidthChange: (width: number) => void;
onWidthCommit: (width: number) => void;
+ onResizeCollapse: () => void;
className?: string;
onAnimationEnd?: ReactAnimationEventHandler<HTMLElement>;
}) {
@@ -305,10 +310,13 @@ export function Sidebar({
insertAfter: boolean,
) => void>(() => {});
- const finishSidebarResize = useCallback((cancelled: boolean) => {
+ const finishSidebarResize = useCallback((cancelled: boolean, collapse = false) => {
const state = sidebarResizeRef.current;
if (!state) return;
- if (cancelled) {
+ if (collapse) {
+ // Keep the previewed width for the exit animation and persist nothing:
+ // the shell restores the preferred expanded width on reopen.
+ } else if (cancelled) {
onWidthChange(state.startWidth);
} else {
onWidthChange(state.currentWidth);
@@ -321,13 +329,16 @@ export function Sidebar({
state.handle.releasePointerCapture(state.pointerId);
}
setSidebarResizing(false);
- }, [onWidthChange, onWidthCommit]);
+ if (collapse) onResizeCollapse();
+ }, [onResizeCollapse, onWidthChange, onWidthCommit]);
const startSidebarResize = useCallback((event: ReactPointerEvent<HTMLDivElement>) => {
if (event.button !== 0 || sidebarResizeRef.current) return;
event.preventDefault();
event.stopPropagation();
event.currentTarget.focus({ preventScroll: true });
+ // Anchor to the rendered width so pressing the handle never resizes the
+ // column; the live budget only limits where the gesture may land.
const startWidth = clampSidebarWidth(sidebarWidth);
sidebarResizeRef.current = {
pointerId: event.pointerId,
@@ -340,20 +351,28 @@ export function Sidebar({
setSidebarResizing(true);
document.documentElement.setAttribute("data-sidebar-resizing", "true");
event.currentTarget.setPointerCapture(event.pointerId);
- }, [sidebarWidth]);
+ }, [sidebarWidth, widthMax]);
const moveSidebarResize = useCallback((event: ReactPointerEvent<HTMLDivElement>) => {
const state = sidebarResizeRef.current;
if (!state || state.pointerId !== event.pointerId) return;
- const nextWidth = clampSidebarWidth(state.startWidth + event.clientX - state.startX);
- state.currentWidth = nextWidth;
+ const result = sidebarPointerResize({
+ startWidth: state.startWidth,
+ deltaX: event.clientX - state.startX,
+ maxWidth: widthMax,
+ });
+ if (result.type === "collapse") {
+ finishSidebarResize(true, true);
+ return;
+ }
+ state.currentWidth = result.width;
if (state.frame) return;
state.frame = requestAnimationFrame(() => {
if (sidebarResizeRef.current !== state) return;
state.frame = 0;
onWidthChange(state.currentWidth);
});
- }, [onWidthChange]);
+ }, [finishSidebarResize, onWidthChange, widthMax]);
const endSidebarResize = useCallback((event: ReactPointerEvent<HTMLDivElement>) => {
if (sidebarResizeRef.current?.pointerId !== event.pointerId) return;
@@ -369,17 +388,18 @@ export function Sidebar({
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
event.preventDefault();
event.stopPropagation();
- const currentWidth = clampSidebarWidth(sidebarWidth);
+ const currentWidth = clampSidebarWidth(sidebarWidth, widthMax);
const nextWidth = event.key === "Home"
? SIDEBAR_WIDTH_MIN
: event.key === "End"
- ? SIDEBAR_WIDTH_MAX
+ ? clampSidebarWidth(widthMax, widthMax)
: clampSidebarWidth(
currentWidth + (event.key === "ArrowRight" ? SIDEBAR_RESIZE_STEP : -SIDEBAR_RESIZE_STEP),
+ widthMax,
);
if (nextWidth === currentWidth) return;
onWidthCommit(nextWidth);
- }, [onWidthCommit, sidebarWidth]);
+ }, [onWidthCommit, sidebarWidth, widthMax]);
useEffect(() => {
if (!sidebarResizing) return;
@@ -2363,9 +2383,9 @@ export function Sidebar({
aria-orientation="vertical"
aria-label={t("nav.resizeSidebar")}
aria-valuemin={SIDEBAR_WIDTH_MIN}
- aria-valuemax={SIDEBAR_WIDTH_MAX}
- aria-valuenow={clampSidebarWidth(sidebarWidth)}
- aria-valuetext={t("nav.sidebarWidth", { width: clampSidebarWidth(sidebarWidth) })}
+ aria-valuemax={clampSidebarWidth(widthMax, widthMax)}
+ aria-valuenow={clampSidebarWidth(sidebarWidth, widthMax)}
+ aria-valuetext={t("nav.sidebarWidth", { width: clampSidebarWidth(sidebarWidth, widthMax) })}
tabIndex={0}
onPointerDown={startSidebarResize}
onPointerMove={moveSidebarResize}
diff --git a/apps/desktop/src/features/app/AppShell.tsx b/apps/desktop/src/features/app/AppShell.tsx
index 428f6690c..20be3b699 100644
--- a/apps/desktop/src/features/app/AppShell.tsx
+++ b/apps/desktop/src/features/app/AppShell.tsx
@@ -1,20 +1,20 @@
-import { lazy, Suspense, type CSSProperties, type ReactNode } from "react";
-import { TooltipButton, cx } from "../../components/ui";
+import { type CSSProperties, lazy, type ReactNode, Suspense } from "react";
+import { ChatSurface } from "../../components/ChatSurface";
+import { ConversationTopbar } from "../../components/ConversationTopbar";
+import { ExtensionPromptHost } from "../../components/ExtensionPromptDialog";
import {
IconNewSession,
IconPanel,
IconPanelOpen,
} from "../../components/icons";
-import { Sidebar } from "../../components/Sidebar";
-import { ConversationTopbar } from "../../components/ConversationTopbar";
-import { WorkPanel } from "../../components/workpanel/WorkPanel";
-import { ChatSurface } from "../../components/ChatSurface";
+import { ProjectCreateDialog } from "../../components/ProjectCreateDialog";
import { SearchDialog } from "../../components/SearchDialog";
+import { Sidebar } from "../../components/Sidebar";
import { ToastHost } from "../../components/Toast";
-import { ExtensionPromptHost } from "../../components/ExtensionPromptDialog";
-import { ProjectCreateDialog } from "../../components/ProjectCreateDialog";
import { UpdateBanner } from "../../components/UpdateBanner";
+import { cx, TooltipButton } from "../../components/ui";
import { WindowControls } from "../../components/WindowControls";
+import { WorkPanel } from "../../components/workpanel/WorkPanel";
import { api } from "../../lib/api";
import { CollapsedTitlebarActions, RoutePending } from "./chrome";
import { useAppShellRuntime } from "./useAppShellRuntime";
@@ -56,8 +56,10 @@ export function AppShell() {
sidebarEntering,
sidebarExiting,
sidebarWidth,
+ sidebarWidthMax,
handleSidebarWidthChange,
handleSidebarWidthCommit,
+ handleSidebarResizeCollapse,
toggleSidebar,
reopenSidebar,
autoCollapseSidebar,
@@ -106,8 +108,10 @@ export function AppShell() {
onToggleSidebar={toggleSidebar}
sidebarToggleShortcut={sidebarToggleShortcut}
sidebarWidth={sidebarWidth}
+ widthMax={sidebarWidthMax}
onWidthChange={handleSidebarWidthChange}
onWidthCommit={handleSidebarWidthCommit}
+ onResizeCollapse={handleSidebarResizeCollapse}
/>
) : null}
diff --git a/apps/desktop/src/features/app/useAppShellRuntime.tsx b/apps/desktop/src/features/app/useAppShellRuntime.tsx
index 75b109d1b..104700bb2 100644
--- a/apps/desktop/src/features/app/useAppShellRuntime.tsx
+++ b/apps/desktop/src/features/app/useAppShellRuntime.tsx
@@ -1,33 +1,34 @@
-import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
-import { useSidebarTransition } from "./useSidebarTransition";
-import { useTranslation } from "react-i18next";
import {
- KEYBOARD_SHORTCUTS,
+ type AppMenuCommand,
isActiveInProject,
isThemeColorScheme,
+ KEYBOARD_SHORTCUTS,
+ type KeyboardShortcutId,
keybindingDisplayParts,
keybindingMatchesEvent,
resolveFontScale,
resolveKeybinding,
- type AppMenuCommand,
- type KeyboardShortcutId,
type ShortcutPlatform,
} from "@pi-desktop/shared";
-import { useAppStore } from "../../stores/app-store";
-import { api } from "../../lib/api";
+import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
import { installRendererApi } from "../../capture/renderer-api";
-import { commitWorkPanelPresentation } from "../../lib/work-panel-presentation";
-import { browserPluginTab } from "../../lib/work-panel-tabs";
-import {
- MAIN_PANE_MIN_WIDTH,
- workPanelWidthForSidebarReopen,
-} from "../../lib/work-panel-resize";
+import { StartupSplash } from "../../components/StartupSplash";
+import { api } from "../../lib/api";
import {
clampSidebarWidth,
loadSidebarWidth,
saveSidebarWidth,
} from "../../lib/sidebar-preferences";
-import { StartupSplash } from "../../components/StartupSplash";
+import { sidebarWidthBudget } from "../../lib/sidebar-resize";
+import { commitWorkPanelPresentation } from "../../lib/work-panel-presentation";
+import {
+ MAIN_PANE_MIN_WIDTH,
+ workPanelWidthForSidebarReopen,
+} from "../../lib/work-panel-resize";
+import { browserPluginTab } from "../../lib/work-panel-tabs";
+import { useAppStore } from "../../stores/app-store";
+import { useSidebarTransition } from "./useSidebarTransition";
const MODIFIER_ONLY_KEYS = new Set([
"Alt",
@@ -68,7 +69,7 @@ export function useAppShellRuntime() {
const [searchOpen, setSearchOpen] = useState(false);
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
- const [sidebarWidth] = useState(() => loadSidebarWidth());
+ const [sidebarWidth, setSidebarWidth] = useState(() => loadSidebarWidth());
const { sidebarEntering, sidebarExiting, handleSidebarAnimationEnd } = useSidebarTransition(
sidebarCollapsed,
ready && page !== "settings",
@@ -77,6 +78,12 @@ export function useAppShellRuntime() {
const appShellRef = useRef<HTMLDivElement>(null);
const sidebarCollapsedRef = useRef(sidebarCollapsed);
const sidebarWidthRef = useRef(sidebarWidth);
+ /**
+ * The last width the user actually committed. A drag preview never writes
+ * it, so a drag that collapses the sidebar and a later reopen return the
+ * preferred column instead of the narrow preview the gesture stopped at.
+ */
+ const sidebarPreferredWidthRef = useRef(sidebarWidth);
const shellWidthRef = useRef(shellWidth);
const workPanelWidthRef = useRef(workPanelWidth);
const workPanelOpenRef = useRef(workPanelVisible);
@@ -104,14 +111,33 @@ export function useAppShellRuntime() {
observer.observe(shell);
return () => observer.disconnect();
}, []);
- // The sidebar is a fixed-width column: it only collapses and opens.
- const handleSidebarWidthChange = useCallback(() => {}, []);
- const handleSidebarWidthCommit = useCallback(() => {}, []);
+ const resolveSidebarMax = () =>
+ sidebarWidthBudget({
+ containerWidth: appShellRef.current?.clientWidth || shellWidthRef.current,
+ workPanelOpen: workPanelOpenRef.current,
+ workPanelWidth: workPanelWidthRef.current,
+ workPanelMaximized: workPanelMaximizedRef.current,
+ });
+ const handleSidebarWidthChange = useCallback((width: number) => {
+ setSidebarWidth(clampSidebarWidth(width, resolveSidebarMax()));
+ }, []);
+ const handleSidebarWidthCommit = useCallback((width: number) => {
+ const nextWidth = clampSidebarWidth(width, resolveSidebarMax());
+ sidebarPreferredWidthRef.current = nextWidth;
+ setSidebarWidth(nextWidth);
+ saveSidebarWidth(nextWidth);
+ }, []);
+ const handleSidebarResizeCollapse = useCallback(() => {
+ autoCollapsedSidebarRef.current = false;
+ setSidebarCollapsed(true);
+ }, []);
// Reopening prefers the right column: the work panel gives up width first so
// MainChat keeps the width it already had, and only a would-be breach of the
- // 450px floor falls back to the 460px reopen target.
+ // 450px floor falls back to the 460px reopen target. The column comes back at
+ // the user's preferred width, which a collapsing drag never overwrites.
const reopenSidebar = useCallback(() => {
if (!sidebarCollapsedRef.current) return;
+ const preferredWidth = clampSidebarWidth(sidebarPreferredWidthRef.current);
if (workPanelOpenRef.current && !workPanelMaximizedRef.current) {
const currentPanelWidth = workPanelWidthRef.current;
const width =
@@ -120,12 +146,13 @@ export function useAppShellRuntime() {
currentPanelWidth + MAIN_PANE_MIN_WIDTH;
const nextPanelWidth = workPanelWidthForSidebarReopen({
containerWidth: width,
- sidebarWidth: sidebarWidthRef.current,
+ sidebarWidth: preferredWidth,
currentPanelWidth,
});
useAppStore.getState().setWorkPanelWidth(nextPanelWidth);
}
autoCollapsedSidebarRef.current = false;
+ setSidebarWidth(preferredWidth);
setSidebarCollapsed(false);
}, []);
@@ -824,6 +851,13 @@ export function useAppShellRuntime() {
: workPanelToggleLabel;
+ const sidebarWidthMax = sidebarWidthBudget({
+ containerWidth: shellWidth,
+ workPanelOpen: workPanelVisible || presentedWorkPanelOpen,
+ workPanelWidth,
+ workPanelMaximized,
+ });
+
return {
t,
ready,
@@ -840,8 +874,10 @@ export function useAppShellRuntime() {
sidebarEntering,
sidebarExiting,
sidebarWidth,
+ sidebarWidthMax,
handleSidebarWidthChange,
handleSidebarWidthCommit,
+ handleSidebarResizeCollapse,
toggleSidebar,
reopenSidebar,
autoCollapseSidebar,
diff --git a/apps/desktop/src/lib/sidebar-preferences.ts b/apps/desktop/src/lib/sidebar-preferences.ts
index c6279eaec..40927efb8 100644
--- a/apps/desktop/src/lib/sidebar-preferences.ts
+++ b/apps/desktop/src/lib/sidebar-preferences.ts
@@ -46,15 +46,13 @@ export const SIDEBAR_WIDTH_MIN = 240;
export const SIDEBAR_WIDTH_DEFAULT = 275;
export const SIDEBAR_WIDTH_MAX = 520;
-/**
- * The sidebar is a fixed-width column: it collapses and opens, but its width is
- * not resizable. The historical fixed value is 275px, which the design tokens
- * already use as the preferred value of `--ds-sidebar-width`; a persisted
- * preference from the resizable era is ignored on purpose.
- */
-export function clampSidebarWidth(value?: number): number {
- void value;
- return SIDEBAR_WIDTH_DEFAULT;
+export function clampSidebarWidth(value: number, max = SIDEBAR_WIDTH_MAX): number {
+ if (!Number.isFinite(value)) return SIDEBAR_WIDTH_DEFAULT;
+ const upper = Math.min(
+ SIDEBAR_WIDTH_MAX,
+ Math.max(SIDEBAR_WIDTH_MIN, Math.round(max)),
+ );
+ return Math.round(Math.min(upper, Math.max(SIDEBAR_WIDTH_MIN, value)));
}
function storage(): Storage | null {
@@ -224,11 +222,12 @@ export function saveSidebarPreferences(value: SidebarPreferences): void {
}
export function loadSidebarWidth(): number {
- return SIDEBAR_WIDTH_DEFAULT;
+ const value = read(SIDEBAR_WIDTH_KEY);
+ return typeof value === "number" ? clampSidebarWidth(value) : SIDEBAR_WIDTH_DEFAULT;
}
-export function saveSidebarWidth(): void {
- // The width is fixed; nothing to persist.
+export function saveSidebarWidth(value: number): void {
+ write(SIDEBAR_WIDTH_KEY, clampSidebarWidth(value));
}
export function sessionIsPinned(id: string, meta: Record<string, SessionMeta>): boolean {
diff --git a/apps/desktop/src/lib/sidebar-resize.ts b/apps/desktop/src/lib/sidebar-resize.ts
new file mode 100644
index 000000000..14984c5c3
--- /dev/null
+++ b/apps/desktop/src/lib/sidebar-resize.ts
@@ -0,0 +1,69 @@
+import {
+ clampSidebarWidth,
+ SIDEBAR_WIDTH_DEFAULT,
+ SIDEBAR_WIDTH_MAX,
+ SIDEBAR_WIDTH_MIN,
+} from "./sidebar-preferences.ts";
+import { MAIN_PANE_MIN_WIDTH, WORK_PANEL_MIN_WIDTH } from "./work-panel-resize.ts";
+
+/** Keyboard and pointer step for the expanded-sidebar separator. */
+export const SIDEBAR_RESIZE_STEP = 16;
+
+/**
+ * Pointer width below this collapses the sidebar instead of leaving a cramped
+ * column. The preferred expanded width is left untouched.
+ */
+export const SIDEBAR_COLLAPSE_THRESHOLD = 160;
+
+export type SidebarPointerResize =
+ | { type: "width"; width: number }
+ | { type: "collapse" };
+
+export function sidebarPointerResize({
+ startWidth,
+ deltaX,
+ maxWidth = SIDEBAR_WIDTH_MAX,
+}: {
+ startWidth: number;
+ deltaX: number;
+ maxWidth?: number;
+}): SidebarPointerResize {
+ if (!Number.isFinite(startWidth) || !Number.isFinite(deltaX)) {
+ return {
+ type: "width",
+ width: clampSidebarWidth(SIDEBAR_WIDTH_DEFAULT, maxWidth),
+ };
+ }
+ const raw = startWidth + deltaX;
+ if (raw < SIDEBAR_COLLAPSE_THRESHOLD) return { type: "collapse" };
+ return { type: "width", width: clampSidebarWidth(raw, maxWidth) };
+}
+
+/**
+ * Live upper bound for a user-chosen sidebar width. The three-column budget
+ * still belongs to MainChat: this cap keeps a resize from crossing the 450px
+ * floor and tripping D408's sidebar yield.
+ */
+export function sidebarWidthBudget({
+ containerWidth,
+ workPanelOpen,
+ workPanelWidth,
+ workPanelMaximized = false,
+}: {
+ containerWidth: number;
+ workPanelOpen: boolean;
+ workPanelWidth: number;
+ workPanelMaximized?: boolean;
+}): number {
+ const width = Math.max(0, Math.round(containerWidth));
+ if (width <= 0) return SIDEBAR_WIDTH_MAX;
+ if (workPanelMaximized) {
+ return Math.min(
+ SIDEBAR_WIDTH_MAX,
+ Math.max(SIDEBAR_WIDTH_MIN, width - WORK_PANEL_MIN_WIDTH),
+ );
+ }
+ const panel = workPanelOpen ? Math.max(0, Math.round(workPanelWidth)) : 0;
+ const budget = width - MAIN_PANE_MIN_WIDTH - panel - 1;
+ return Math.min(SIDEBAR_WIDTH_MAX, Math.max(SIDEBAR_WIDTH_MIN, budget));
+}
diff --git a/apps/desktop/src/styles/chrome.css b/apps/desktop/src/styles/chrome.css
index dab9bf2b8..ae36daaee 100644
--- a/apps/desktop/src/styles/chrome.css
+++ b/apps/desktop/src/styles/chrome.css
@@ -213,8 +213,6 @@
}
.sidebar-resize-handle {
- /* The sidebar is fixed-width: collapse/open only, never dragged. */
- display: none;
position: absolute;
top: 0;
right: 0;
diff --git a/apps/desktop/test/sidebar-preferences.test.mjs b/apps/desktop/test/sidebar-preferences.test.mjs
index b43f662b4..51987fb5f 100644
--- a/apps/desktop/test/sidebar-preferences.test.mjs
+++ b/apps/desktop/test/sidebar-preferences.test.mjs
@@ -378,11 +378,12 @@ test("persists retained project paths and per-project collapse state", () => {
}
});
-test("keeps the expanded sidebar at its fixed width without persistence", () => {
+test("clamps and persists the expanded sidebar width", () => {
assert.equal(clampSidebarWidth(Number.NaN), SIDEBAR_WIDTH_DEFAULT);
- assert.equal(clampSidebarWidth(SIDEBAR_WIDTH_MIN - 1), SIDEBAR_WIDTH_DEFAULT);
- assert.equal(clampSidebarWidth(312.4), SIDEBAR_WIDTH_DEFAULT);
- assert.equal(clampSidebarWidth(SIDEBAR_WIDTH_MAX + 1), SIDEBAR_WIDTH_DEFAULT);
+ assert.equal(clampSidebarWidth(SIDEBAR_WIDTH_MIN - 1), SIDEBAR_WIDTH_MIN);
+ assert.equal(clampSidebarWidth(312.4), 312);
+ assert.equal(clampSidebarWidth(SIDEBAR_WIDTH_MAX + 1), SIDEBAR_WIDTH_MAX);
+ assert.equal(clampSidebarWidth(400, 300), 300);
const values = new Map();
const previousStorage = globalThis.localStorage;
@@ -410,10 +411,9 @@ test("keeps the expanded sidebar at its fixed width without persistence", () =>
try {
assert.equal(loadSidebarWidth(), SIDEBAR_WIDTH_DEFAULT);
saveSidebarWidth(SIDEBAR_WIDTH_MAX + 100);
- assert.equal(loadSidebarWidth(), SIDEBAR_WIDTH_DEFAULT);
+ assert.equal(loadSidebarWidth(), SIDEBAR_WIDTH_MAX);
saveSidebarWidth(SIDEBAR_WIDTH_MIN - 100);
- assert.equal(loadSidebarWidth(), SIDEBAR_WIDTH_DEFAULT);
- assert.equal(values.size, 0);
+ assert.equal(loadSidebarWidth(), SIDEBAR_WIDTH_MIN);
} finally {
globalThis.localStorage = previousStorage;
}
diff --git a/apps/desktop/test/sidebar-resize-math.test.mjs b/apps/desktop/test/sidebar-resize-math.test.mjs
new file mode 100644
index 000000000..63f0ec64c
--- /dev/null
+++ b/apps/desktop/test/sidebar-resize-math.test.mjs
@@ -0,0 +1,108 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import {
+ SIDEBAR_WIDTH_DEFAULT,
+ SIDEBAR_WIDTH_MAX,
+ SIDEBAR_WIDTH_MIN,
+} from "../src/lib/sidebar-preferences.ts";
+import {
+ SIDEBAR_COLLAPSE_THRESHOLD,
+ SIDEBAR_RESIZE_STEP,
+ sidebarPointerResize,
+ sidebarWidthBudget,
+} from "../src/lib/sidebar-resize.ts";
+import {
+ MAIN_PANE_MIN_WIDTH,
+ WORK_PANEL_MIN_WIDTH,
+} from "../src/lib/work-panel-resize.ts";
+
+test("pointer resize clamps to the expanded range and collapses below the snap threshold", () => {
+ assert.equal(SIDEBAR_COLLAPSE_THRESHOLD, 160);
+ assert.equal(SIDEBAR_RESIZE_STEP, 16);
+ assert.deepEqual(
+ sidebarPointerResize({ startWidth: 275, deltaX: 0 }),
+ { type: "width", width: 275 },
+ );
+ assert.deepEqual(
+ sidebarPointerResize({ startWidth: 275, deltaX: 37.6 }),
+ { type: "width", width: 313 },
+ );
+ assert.deepEqual(
+ sidebarPointerResize({ startWidth: 275, deltaX: -40 }),
+ { type: "width", width: SIDEBAR_WIDTH_MIN },
+ );
+ assert.deepEqual(
+ sidebarPointerResize({ startWidth: 275, deltaX: 400 }),
+ { type: "width", width: SIDEBAR_WIDTH_MAX },
+ );
+ assert.deepEqual(
+ sidebarPointerResize({ startWidth: 275, deltaX: 160, maxWidth: 300 }),
+ { type: "width", width: 300 },
+ );
+ assert.deepEqual(
+ sidebarPointerResize({
+ startWidth: 275,
+ deltaX: SIDEBAR_COLLAPSE_THRESHOLD - 275 - 1,
+ }),
+ { type: "collapse" },
+ );
+ assert.deepEqual(
+ sidebarPointerResize({
+ startWidth: 275,
+ deltaX: SIDEBAR_COLLAPSE_THRESHOLD - 275,
+ }),
+ { type: "width", width: SIDEBAR_WIDTH_MIN },
+ );
+});
+
+test("the live sidebar budget keeps MainChat above its floor", () => {
+ assert.equal(
+ sidebarWidthBudget({
+ containerWidth: 1040,
+ workPanelOpen: false,
+ workPanelWidth: 360,
+ }),
+ SIDEBAR_WIDTH_MAX,
+ );
+ assert.equal(
+ sidebarWidthBudget({
+ containerWidth: 1200,
+ workPanelOpen: true,
+ workPanelWidth: 360,
+ }),
+ 389,
+ );
+ assert.equal(
+ sidebarWidthBudget({
+ containerWidth: 1040,
+ workPanelOpen: true,
+ workPanelWidth: 360,
+ }),
+ SIDEBAR_WIDTH_MIN,
+ );
+ assert.equal(
+ sidebarWidthBudget({
+ containerWidth: 1200,
+ workPanelOpen: true,
+ workPanelWidth: 360,
+ workPanelMaximized: true,
+ }),
+ SIDEBAR_WIDTH_MAX,
+ );
+ assert.equal(
+ sidebarWidthBudget({
+ containerWidth: 600,
+ workPanelOpen: false,
+ workPanelWidth: 0,
+ workPanelMaximized: true,
+ }),
+ Math.max(SIDEBAR_WIDTH_MIN, 600 - WORK_PANEL_MIN_WIDTH),
+ );
+ const capped = sidebarWidthBudget({
+ containerWidth: 1200,
+ workPanelOpen: true,
+ workPanelWidth: 360,
+ });
+ assert.equal(1200 - capped - 360, MAIN_PANE_MIN_WIDTH + 1);
+ assert.equal(SIDEBAR_WIDTH_DEFAULT, 275);
+});
diff --git a/apps/desktop/test/sidebar-resize.test.mjs b/apps/desktop/test/sidebar-resize.test.mjs
index 624a8c5a9..d4156ef50 100644
--- a/apps/desktop/test/sidebar-resize.test.mjs
+++ b/apps/desktop/test/sidebar-resize.test.mjs
@@ -11,25 +11,35 @@ const sidebarSource = await readFile(
const appSource = await readAppSource();
const globalStyles = await loadStyles();
-test("the sidebar keeps a fixed width and only exposes collapse/open chrome", () => {
+test("the sidebar exposes an accessible pointer and keyboard resize handle", () => {
assert.match(sidebarSource, /className=\{cx\("sidebar-resize-handle no-drag"/);
assert.match(sidebarSource, /role="separator"/);
assert.match(sidebarSource, /aria-orientation="vertical"/);
- assert.match(appSource, /loadSidebarWidth\(\)/);
- assert.doesNotMatch(appSource, /saveSidebarWidth\(nextWidth\)/);
- assert.match(
- globalStyles,
- /\.sidebar-resize-handle\s*\{[\s\S]*?display:\s*none;/,
- );
+ assert.match(sidebarSource, /onPointerDown=\{startSidebarResize\}/);
+ assert.match(sidebarSource, /onPointerMove=\{moveSidebarResize\}/);
+ assert.match(sidebarSource, /onPointerCancel=\{cancelSidebarResize\}/);
+ assert.match(sidebarSource, /onLostPointerCapture=\{cancelSidebarResize\}/);
+ assert.match(sidebarSource, /requestAnimationFrame\(\(\) =>/);
+ assert.match(sidebarSource, /event\.key === "ArrowRight"/);
+ assert.match(sidebarSource, /event\.key === "Home"/);
+ assert.match(sidebarSource, /finishSidebarResize\(true\)/);
+ assert.match(sidebarSource, /finishSidebarResize\(true, true\)/);
+ assert.match(sidebarSource, /onResizeCollapse/);
+ assert.match(sidebarSource, /sidebarPointerResize\(/);
});
-test("sidebar width is shell-owned and the hidden edge has no resize affordance", () => {
+test("sidebar width is shell-owned and the resize affordance is edge-anchored", () => {
+ assert.match(appSource, /loadSidebarWidth\(\)/);
+ assert.match(appSource, /saveSidebarWidth\(nextWidth\)/);
+ assert.match(appSource, /handleSidebarResizeCollapse/);
+ assert.match(appSource, /sidebarPreferredWidthRef/);
assert.match(appSource, /"--ds-sidebar-width": `\$\{sidebarWidth\}px`/);
assert.match(globalStyles, /\.sidebar\s*\{[\s\S]*?position:\s*relative/);
- assert.match(
- globalStyles,
- /\.sidebar-resize-handle\s*\{[\s\S]*?display:\s*none;/,
- );
+ assert.match(globalStyles, /\.sidebar-resize-handle\s*\{[\s\S]*?right:\s*0;[\s\S]*?cursor:\s*col-resize/);
+ assert.match(globalStyles, /\.sidebar-resize-handle\s*\{[\s\S]*?touch-action:\s*none/);
+ const handleBlock = globalStyles.match(/\.sidebar-resize-handle\s*\{[^}]+\}/)?.[0] ?? "";
+ assert.match(handleBlock, /cursor:\s*col-resize/);
+ assert.doesNotMatch(handleBlock, /display:\s*none/);
});
test("sidebar hover does not paint a full-height resize rail", () => {
diff --git a/docs/adr/0141-sidebar-width-resize.md b/docs/adr/0141-sidebar-width-resize.md
index a0aeb1c48..40d92ec0d 100644
--- a/docs/adr/0141-sidebar-width-resize.md
+++ b/docs/adr/0141-sidebar-width-resize.md
@@ -1,6 +1,6 @@
# ADR 0141: Make Expanded Sidebar Width User-Resizable
-- Status: Accepted
+- Status: Accepted (amended by [ADR 0290](0290-resizable-sidebar-collapse-threshold.md))
- Date: 2026-09-01
## Context
diff --git a/docs/adr/0238-three-column-width-priority.md b/docs/adr/0238-three-column-width-priority.md
index d43c5337e..48ef27932 100644
--- a/docs/adr/0238-three-column-width-priority.md
+++ b/docs/adr/0238-three-column-width-priority.md
@@ -1,6 +1,6 @@
# ADR 0238: Prioritize MainChat in the three-column shell
-- Status: Accepted
+- Status: Accepted (sidebar width clamp amended by [ADR 0290](0290-resizable-sidebar-collapse-threshold.md))
- Date: 2026-09-13
- Amends: [ADR 0226](0226-reserve-chat-width-for-composer-controls.md) ·
[ADR 0151](0151-internal-work-panel-dock.md) ·
diff --git a/docs/adr/0290-resizable-sidebar-collapse-threshold.md b/docs/adr/0290-resizable-sidebar-collapse-threshold.md
new file mode 100644
index 000000000..dfffa5872
--- /dev/null
+++ b/docs/adr/0290-resizable-sidebar-collapse-threshold.md
@@ -0,0 +1,74 @@
+# ADR 0290: Restore Resizable Sidebar Width with Collapse-Below-Threshold
+
+- Status: Accepted
+- Date: 2026-09-19
+- Decision: D451
+- Amends: [ADR 0141](0141-sidebar-width-resize.md) ·
+ [ADR 0238](0238-three-column-width-priority.md)
+- Related: [01-ui-ia](../spec/04-ux/01-ui-ia.md) ·
+ [07-ui-design-system §10](../spec/04-ux/07-ui-design-system.md) ·
+ [08-component-spec](../spec/04-ux/08-component-spec.md) ·
+ [09-interaction-patterns §8](../spec/04-ux/09-interaction-patterns.md) ·
+ E2E-168
+
+## Context
+
+ADR 0141 made the expanded sidebar a persisted `240px..520px` column. D408 /
+ADR 0238 later pinned that column at 275px and hid the handle so the
+three-column budget could treat the left dock as a constant while MainChat
+kept a 450px floor.
+
+Users still need to widen the sidebar for long project and session labels, and
+to reclaim space. The right work panel already has a pointer divider; the left
+column should match that affordance. Dragging past a usable minimum should
+fold the sidebar rather than leave a cramped strip.
+
+## Decision
+
+1. Restore ADR 0141's renderer-owned handle on the expanded sidebar's right
+ edge. Pointer motion previews a width anchored at press, rounded and
+ clamped to `240px..520px` (default `275px`). Pointer release persists the
+ preferred width. Keyboard ArrowLeft/ArrowRight step 16px; Home and End
+ select the live bounds; keyboard changes commit immediately. Escape,
+ cancellation, lost capture, and unmount restore the press-time width.
+2. A pointer width below `160px` collapses the sidebar immediately. Collapse
+ is a user action: it does not record an automatic-yield, and it does not
+ persist the in-progress width. Reopening restores the preferred expanded
+ width from the start of the gesture (or the last committed value). Keyboard
+ resize never collapses; `Cmd/Ctrl+B` remains the keyboard fold.
+3. The live maximum is the three-column remainder after MainChat's 450px floor
+ and, when the work panel occupies space, its requested width. A user-chosen
+ sidebar width therefore cannot trip D408's `<= 450px` yield. Work-panel
+ growth and window shrink still collapse the expanded sidebar at that
+ threshold. Preview mode (MainChat unmounted) caps the sidebar so the panel
+ keeps at least its 244px minimum.
+4. Renderer only. No IPC, native-window bounds, host protocol, or storage
+ schema change. The existing `pi.desktop.sidebarWidth` preference is the
+ persistence key.
+
+## Consequences
+
+- Long labels and compact workspaces share one persisted width instead of a
+ fixed 275px column.
+- Dragging the handle left past the snap threshold folds the sidebar the same
+ way the explicit collapse control does, without writing a sub-minimum width.
+- MainChat's 450px floor and the work-panel yield order stay intact.
+
+## Alternatives rejected
+
+### Keep the D408 fixed 275px column
+
+Rejected because it blocks the same inspection and space-reclaiming need ADR
+0141 already recorded, and the live budget can cap a user-chosen width without
+freezing it.
+
+### Collapse at 240px with no snap zone
+
+Rejected because hitting the minimum during a small adjustment would fold the
+sidebar. The 160px threshold requires an explicit extra drag past the floor.
+
+### Persist the in-progress width on collapse
+
+Rejected because collapse is a cancel of the current gesture plus a fold. The
+preferred expanded width stays the value captured at pointer-down (or the last
+committed width).
diff --git a/docs/adr/README.md b/docs/adr/README.md
index a9b1b5d58..774427b77 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -316,4 +316,5 @@ Each ADR includes:
| 0287 | [Host-rendered plugin scenic Settings surfaces](0287-host-rendered-plugin-scenic-settings-surfaces.md) | Accepted for implementation |
| 0288 | [Package-local theme assets remain available](0288-package-local-theme-assets.md) | Accepted for implementation (amends ADR 0255) |
| 0289 | [Signed macOS GitHub Releases and in-app update delivery](0289-signed-macos-github-releases.md) | Accepted (D450; amends ADR 0022 / 0145 / 0191 / 0204 / D078) |
+| 0290 | [Restore resizable sidebar width with collapse-below-threshold](0290-resizable-sidebar-collapse-threshold.md) | Accepted (D451; amends ADR 0141 / ADR 0238) |
| turn-process-and-thinking-display | [Turn process and thinking presentation](turn-process-and-thinking-display.md) | Accepted |
diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.md
index 7a97679e7..d677b96ed 100644
--- a/docs/spec/04-ux/01-ui-ia.md
+++ b/docs/spec/04-ux/01-ui-ia.md
@@ -40,8 +40,8 @@ destination, chat as the home surface, tools and permissions inline.
non-destructive pin/archive actions, an independent conversation-branch
command, and sortable views. Projects not retained in the sidebar remain
discoverable through Settings → Project archive.
- Collapsible to an icon rail (Cmd/Ctrl+B). Its expanded column is fixed at
- 275px; persisted resize preferences from older builds are ignored.
+ Collapsible to an icon rail (Cmd/Ctrl+B). Its expanded column is user-resizable
+ from 240px to 520px (default 275px); dragging below 160px collapses it.
- **Product identity**: runtime shell copy uses `PI-Desktop`; the home hero and
sidebar reuse the derived `src/assets/brand/logo-*.png` marks, while composer prompt
rows have no leading brand icon and session-creation controls use a dedicated
diff --git a/docs/spec/04-ux/07-ui-design-system.md b/docs/spec/04-ux/07-ui-design-system.md
index 9b64633be..1ac641d1c 100644
--- a/docs/spec/04-ux/07-ui-design-system.md
+++ b/docs/spec/04-ux/07-ui-design-system.md
@@ -497,9 +497,9 @@ same 6px contract and scroll-reveal mark. This keeps first-party surfaces such
as the Files view aligned with the host renderer; the external page loaded
inside the Browser guest remains page-owned and keeps its own scrollbar style.
-The expanded sidebar is a fixed 275px column. Collapse/open changes only whether
-the column is present; the historical resize handle is hidden and legacy width
-preferences are not persisted.
+The expanded sidebar is user-resizable from 240px to 520px (default 275px).
+Dragging the right-edge handle below 160px collapses the column. Collapse/open
+preserves the preferred expanded width.
The profile menu is `280px` wide, opens `8px` above the footer, and uses the
standard opaque elevated-menu surface, subtle border, and dialog shadow. Its
@@ -1040,7 +1040,7 @@ Codex parity decisions (D034/D070) supersede any older value here.
|---|---|---|
| Titlebar row height | 46px | Codex toolbar rhythm (D034); traffic lights {x:16,y:16} |
| Sidebar width (collapsed) | 48px | Icon-only rail |
-| Sidebar width (expanded) | 275px | Fixed column; collapse/open does not resize it |
+| Sidebar width (expanded) | 240–520px (default 275px) | Right-edge handle; drag below 160px collapses (ADR 0141 / ADR 0290) |
| Main pane minimum readable width | 450px | The MainChat hard floor; the sidebar yields before it is breached (ADR 0238) |
| Work panel width (closed) | 0px | Hidden by default |
| Work panel width (open) | `≥244px` (new-profile default 360px), capped by `client width - 450px - expanded sidebar` with no fixed pixel cap | the panel is an in-flow column whose width is taken from the existing client area; the renderer owns its divider (ADR 0033 / ADR 0151 / ADR 0238); saved widths remain unchanged |
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index 0ed92af0a..2005341c2 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -5,12 +5,12 @@
> Interaction behavior: [09-interaction-patterns.md](09-interaction-patterns.md)
-> Shell layout is Codex-aligned: left thread sidebar (fixed 275px), main transcript, floating bottom composer with runtime mode/permission/model controls, and a compact action-only top bar. Prefer neutral charcoal surfaces over blue-slate chrome.
+> Shell layout is Codex-aligned: left thread sidebar (240–520px, default 275px), main transcript, floating bottom composer with runtime mode/permission/model controls, and a compact action-only top bar. Prefer neutral charcoal surfaces over blue-slate chrome.
>
> **Precedence rule**: where a metric or copy string below disagrees with a
> Codex parity decision in [decisions-log §D](../08-meta/decisions-log.md)
> (D034+), the decision log wins — it tracks the live gold captures. Known
-> updated values: sidebar 275px fixed, toolbar 46px (not 44px),
+> updated values: sidebar 240–520px (default 275px), toolbar 46px (not 44px),
> composer placeholder per D094/D066, home empty stack and bottom composer per
> D111/D204/D206,
> Projects index table per D066/D133, settings full-page shell per D063 with the
@@ -30,7 +30,7 @@ Outer frame that positions Topbar, Sidebar, MainChat, and WorkPanel. Owns resize
```text
+------------------+------------------------------+------------------+
| Sidebar | MainChat | WorkPanel |
-| (275px / 48px) | (flex-1) | (≥244px / dynamic|
+| (240–520px / 48px) | (flex-1) | (≥244px / dynamic|
| | | hidden) |
+------------------+------------------------------+------------------+
| Titlebar row: 46px, traffic lights at {x:16,y:16} (D034/D070) |
@@ -60,9 +60,9 @@ Outer frame that positions Topbar, Sidebar, MainChat, and WorkPanel. Owns resize
restore the full retained layout directly. Entering Settings cancels either
pending phase, including during rapid navigation; no hidden shell is kept
mounted solely to suppress animation.
-- Sidebar width: the expanded column is fixed at 275px. Collapse/open changes
- only whether the column is present; the historical resize handle is hidden
- and legacy persisted width preferences are ignored.
+- Sidebar width: the expanded column is user-resizable from 240px to 520px
+ (default 275px) via the right-edge handle. Dragging below 160px collapses
+ the sidebar and preserves the preferred expanded width (ADR 0141 / ADR 0290).
- Work panel collapse: the sole control is the viewport-fixed toggle in the
window's top-right corner, available on every non-Settings route whether the
panel is open or closed. It does not sit in the work-panel content header.
@@ -92,8 +92,8 @@ Outer frame that positions Topbar, Sidebar, MainChat, and WorkPanel. Owns resize
### 1.6 MVP constraints
-- Sidebar width is fixed at 275px and remains independent from the collapsed
- icon-rail state; the work panel remains adjustable from its own divider
+- Sidebar width is user-resizable from 240px to 520px (default 275px) and
+ remains independent from the collapsed icon-rail state; the work panel remains adjustable from its own divider
- The main pane renders one active transcript and one selected workspace while
the sidebar may retain several project tabs/groups
- Sidebar and work-panel dock transitions animate their flex allocation as well
@@ -402,7 +402,7 @@ visually distinct from list content.
| State | Behavior |
|---|---|
| Expanded | Full session titles visible |
-| Sidebar width | Fixed at 275px; collapse/open changes only column presence |
+| Sidebar width | 240–520px (default 275px); drag below 160px collapses |
| Collapsed | Icon rail — hover shows tooltip with session title |
| Active session | Accent-blue outlined status ring plus active row background |
| Selecting session | Destination row receives the active treatment immediately while transcript/workspace resolution continues |
diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.md
index 7be654eb5..bb1e13669 100644
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@ -1045,9 +1045,9 @@ Work-panel and application-window resizing are implemented in MVP:
Native pointer clicks must operate the controls and dragging empty header
space must move the window; DOM/CDP clicks alone do not establish native hit testing.
-The expanded sidebar is fixed at 275px. Collapse/open changes only whether the
-column is present; the historical resize handle is hidden and legacy width
-preferences are ignored.
+The expanded sidebar is user-resizable from 240px to 520px (default 275px) via
+the right-edge handle. Pointer motion below 160px collapses the sidebar and
+keeps the preferred expanded width. Keyboard Arrow/Home/End resize without collapsing.
Project ordering is implemented for retained project groups. There is no
reorder grip. Pressing the project title and moving 8px starts a project drag,
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index b48a92d80..818aa589f 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -9886,33 +9886,38 @@ This test plan spec is accepted when:
3. With the work panel open or on a small supported window, continue the
resize toward the maximum; inspect the composer toolbar while the main
pane reflows.
- 4. Repeat with a target below the minimum and above the maximum; release and
- confirm the sidebar width stops at 240px and 520px respectively while the
- MainChat reservation remains intact.
+ 4. Repeat with a target below 240px and above the live maximum; release and
+ confirm the sidebar width stops at 240px and the live cap (at most 520px)
+ while MainChat stays at or above 450px. Continue the drag below 160px and
+ confirm the sidebar collapses immediately without saving the in-progress
+ width.
5. Focus the edge handle and press ArrowLeft/ArrowRight, Home, and End;
- inspect the separator's current ARIA value.
+ inspect the separator's current ARIA value. ArrowLeft at 240px must not
+ collapse the sidebar.
6. Start a resize, press Escape or cancel the pointer, then restart the app.
- Collapse and re-expand the sidebar as a separate check.
+ Collapse and re-expand the sidebar as a separate check; the preferred
+ expanded width must return.
- **Expected**: The handle is discoverable on direct hover/focus without a
full-height white/accent rail when the sidebar body is hovered, has no native
window drag or text-selection side effect, and remains anchored to the press
- point. MainChat follows the live width until its 515px floor. Pointer release saves one clamped
- preferred width; Escape/cancellation restores the starting width without
- saving it. Keyboard changes commit immediately and expose localized width
- semantics. The saved width survives relaunch and is restored after sidebar
- collapse; collapse does not convert the preferred width into the icon-rail
- width. MainChat never falls below its reserved 515px width, and the composer
- toolbar keeps its left and right groups on one row without squeezed buttons.
- Mode/permission labels remain single-line and ellipsized; no toolbar text is
- vertically split or overlapped.
+ point. MainChat follows the live width until its 450px floor. Pointer release
+ saves one clamped preferred width; Escape/cancellation restores the starting
+ width without saving it. A pointer width below 160px collapses the sidebar as
+ a user action and restores the preferred expanded width on reopen. Keyboard
+ changes commit immediately and expose localized width semantics. The saved
+ width survives relaunch and is restored after sidebar collapse; collapse does
+ not convert the preferred width into the icon-rail width. MainChat never
+ falls below 450px, and the composer toolbar keeps its left and right groups
+ on one row without squeezed buttons. Mode/permission labels remain
+ single-line and ellipsized; no toolbar text is vertically split or overlapped.
- **Specs linked**: `04-ux/01-ui-ia.md`, `04-ux/07-ui-design-system.md`,
`04-ux/08-component-spec.md`, `04-ux/09-interaction-patterns.md`,
- ADR 0141, ADR 0226, D280, D401
+ ADR 0141, ADR 0238, ADR 0290, D280, D408, D451
- **Acceptance**: A (app shell), F (persistence), Quality
- **Milestone**: M6+
- **Status**: Unit/source-contract covered (`sidebar-preferences.test.mjs`,
- `sidebar-resize.test.mjs`); rendered desktop drag and relaunch journey
- remains pending
+ `sidebar-resize.test.mjs`, `sidebar-resize-math.test.mjs`); rendered desktop
+ drag and relaunch journey remains pending
#### E2E-162: A vendor account and an AI service offer the same model picker
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index d08dfb891..5daefa366 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -3125,8 +3125,8 @@ D193, and D194.
- Sidebar collapse remains independent from the preferred expanded width. No
IPC, native-window bounds, work-panel reservation, or project/session order
contract changes. See ADR 0141 and E2E-168.
-- D408 supersedes this width contract for the live shell: the expanded sidebar
- is fixed at 275px and the historical resize handle is hidden.
+- D408 later pinned the live shell at 275px and hid the handle. D451 / ADR 0290
+ restores the resizable handle and adds collapse below 160px.
## 2026-09-01 — Non-loopback HTTP MCP endpoints are supported (D281)
@@ -6061,3 +6061,20 @@ that was sitting at the bottom — including after the turn had finished.
changes; the existing `prompt/enhance` payload is unchanged. See
`04-ux/12-prompt-enhancement.md` §3 and §5, ADR 0121, and
`06-delivery/04-e2e-test-plan.md` E2E-259.
+
+## 2026-09-19 — Restore resizable sidebar width with collapse-below-threshold (D451)
+
+- Amend D408 / ADR 0238 and restore ADR 0141: the expanded sidebar is again a
+ renderer-owned `240px..520px` column (default `275px`). The right-edge handle
+ previews width from the pointer-down position, persists on release, and
+ supports ArrowLeft/ArrowRight (16px), Home, and End. Escape, cancellation,
+ lost capture, and unmount restore the press-time width.
+- A pointer width below `160px` collapses the sidebar immediately as a user
+ action. The preferred expanded width is not overwritten. Keyboard resize never
+ collapses; `Cmd/Ctrl+B` remains the keyboard fold.
+- The live maximum is the three-column remainder after MainChat's 450px floor
+ and an occupying work panel's requested width, so a user-chosen sidebar width
+ does not trip D408's yield. Work-panel growth and window shrink still collapse
+ the expanded sidebar at that threshold.
+- Renderer only: existing `pi.desktop.sidebarWidth` preference, no IPC or native
+ window change. See ADR 0290 and E2E-168.
diff --git a/docs/zh-CN/adr/index.md b/docs/zh-CN/adr/index.md
index 968f3b345..24fac4ef4 100644
--- a/docs/zh-CN/adr/index.md
+++ b/docs/zh-CN/adr/index.md
@@ -26,7 +26,7 @@ ADR 记录那些不应被静默改变的架构选择。中文入口与英文索
| [ADR 0128:瞬时 provider 故障的有界重试](/adr/0128-bounded-transient-provider-retry) | 为瞬时 provider 故障共享一个有界重试预算,跨请求设置和流式传输阶段共用四次重试 |
| [ADR 0131:大段 Composer 粘贴写入会话临时目录](/adr/0131-large-text-paste-session-reference) | 超过可配置阈值的纯文本粘贴保存为会话临时文件,并在原位置插入内联 `@` 引用 |
| [ADR 0137:保留的会话面板](/adr/0137-retained-session-panes) | 最近访问的会话各自保留一个已挂载的面板(上限三个),切换是可见性交换而不是重建转录 |
-| [ADR 0141:展开侧边栏宽度可调整](/adr/0141-sidebar-width-resize) | 展开侧边栏通过右边缘手柄调整 240–520px 宽度,并持久化首选值 |
+| [ADR 0141:展开侧边栏宽度可调整](/adr/0141-sidebar-width-resize) | 展开侧边栏通过右边缘手柄调整 240–520px 宽度;拖过 160px 会收起(ADR 0290) |
| [ADR 0142:允许非回环 HTTP MCP 端点](/adr/0142-allow-non-loopback-http-mcp) | 支持局域网 MCP,并明确提示明文连接风险,插件仍受网络白名单约束 |
| [ADR 0145:发布本机 macOS Intel 工件](/adr/0145-native-macos-intel-release-lane) | 通过匹配的 macOS 原生运行器发布 arm64 与 Intel x64 DMG/ZIP,两个架构工件均带有明确后缀,并合并更新源 |
| [ADR 0148:明确禁用应用快捷键](/adr/0148-explicitly-disable-keyboard-shortcuts) | 缺少覆盖使用默认值,`null` 表示未绑定并关闭渲染器、菜单和启动器分发 |
@@ -296,6 +296,7 @@ ADR 记录那些不应被静默改变的架构选择。中文入口与英文索
| 0285 | [`packages/racp` 的 `RACP-WS` 传输](/adr/0285-racp-ws-transport) | 已接受(实施中)(D448;ADR 0205 R2) |
| turn-process-and-thinking-display | [回合过程与思考展示](/adr/turn-process-and-thinking-display) | 已接受 |
| 0289 | [签名的 macOS GitHub Release 与应用内更新](/adr/0289-signed-macos-github-releases) | 已接受(D450;修订 ADR 0022 / 0145 / 0191 / 0204 / D078) |
+| 0290 | [恢复可拖拽侧边栏宽度,过窄时收起](/adr/0290-resizable-sidebar-collapse-threshold) | 已接受(D451;修订 ADR 0141 / ADR 0238) |
## 什么时候看 ADR
diff --git a/scripts/e2e-three-column-layout.mjs b/scripts/e2e-three-column-layout.mjs
index 034d51f5e..ee098006f 100644
--- a/scripts/e2e-three-column-layout.mjs
+++ b/scripts/e2e-three-column-layout.mjs
@@ -1124,17 +1124,17 @@ async function main() {
const e2eChromeSidebar = await cdp.evaluate(e2eChromeProbe);
check(
e2eChromeSidebar.sidebarWidth === null || e2eChromeSidebar.sidebarWidth === 275,
- "sidebar stays at its fixed width",
+ "sidebar defaults to 275px when no preference is stored",
JSON.stringify(e2eChromeSidebar),
);
check(
- e2eChromeSidebar.handleVisible === false,
- "the sidebar edge is no longer a resize affordance",
+ e2eChromeSidebar.sidebarWidth === null || e2eChromeSidebar.handleVisible === true,
+ "the expanded sidebar edge is a resize affordance",
JSON.stringify(e2eChromeSidebar),
);
check(
e2eChromeSidebar.storedWidth === null,
- "sidebar width is no longer persisted",
+ "no sidebar width preference is stored at launch",
JSON.stringify(e2eChromeSidebar),
);