Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(shell): restore default sidebar and panel width on handle double-click
vastsac2ec26527628
diff --git a/apps/desktop/src/components/Sidebar.tsx b/apps/desktop/src/components/Sidebar.tsxindex 7f00f423b..9df938072 100644--- a/apps/desktop/src/components/Sidebar.tsx+++ b/apps/desktop/src/components/Sidebar.tsx@@ -53,7 +53,11 @@ import {SIDEBAR_WIDTH_MAX,SIDEBAR_WIDTH_MIN,} from "../lib/sidebar-preferences";-import { SIDEBAR_RESIZE_STEP, sidebarPointerResize } from "../lib/sidebar-resize";+import {+ SIDEBAR_RESIZE_STEP,+ sidebarPointerResize,+ sidebarResetWidth,+} from "../lib/sidebar-resize";import { BrandLogo } from "./BrandLogo";import { NotificationCenter } from "./NotificationCenter";import { ProjectEditDialog } from "./ProjectEditDialog";@@ -401,6 +405,16 @@ export function Sidebar({onWidthCommit(nextWidth);}, [onWidthCommit, sidebarWidth, widthMax]);+ /**+ * Double-click reset: the shell's default width, clamped by the live+ * three-column budget. A pointer gesture that is somehow still open is+ * dropped first so its release cannot overwrite the reset.+ */+ const resetSidebarWidth = useCallback(() => {+ if (sidebarResizeRef.current) finishSidebarResize(true);+ onWidthCommit(sidebarResetWidth(widthMax));+ }, [finishSidebarResize, onWidthCommit, widthMax]);+useEffect(() => {if (!sidebarResizing) return;const onKeyDown = (event: KeyboardEvent) => {@@ -2393,6 +2407,7 @@ export function Sidebar({onPointerCancel={cancelSidebarResize}onLostPointerCapture={cancelSidebarResize}onKeyDown={handleSidebarResizeKeyDown}+ onDoubleClick={resetSidebarWidth}/></aside>);diff --git a/apps/desktop/src/components/workpanel/WorkPanel.tsx b/apps/desktop/src/components/workpanel/WorkPanel.tsxindex ff81e0b42..b96c5bb83 100644--- a/apps/desktop/src/components/workpanel/WorkPanel.tsx+++ b/apps/desktop/src/components/workpanel/WorkPanel.tsx@@ -44,6 +44,8 @@ import {WORK_PANEL_MIN_WIDTH,clampWorkPanelWidth,workPanelLayout,+ workPanelResetWidth,+ workPanelWidthBounds,} from "../../lib/work-panel-resize";const TAB_ICONS = {@@ -395,8 +397,10 @@ export function WorkPanel({// While maximized there is no second column to trade width with.if (maximized) return;const step = event.shiftKey ? 32 : 16;- const minimum = Math.min(panelMinimum, layout.maxPanelWidth);- const maximum = Math.max(minimum, layout.maxPanelWidth);+ const { minimum, maximum } = workPanelWidthBounds(+ panelMinimum,+ layout.maxPanelWidth,+ );let nextWidth: number | null = null;if (event.key === "ArrowLeft") nextWidth = renderPanelWidth + step;else if (event.key === "ArrowRight") nextWidth = renderPanelWidth - step;@@ -409,6 +413,25 @@ export function WorkPanel({[finishPanelResize, layout.maxPanelWidth, maximized, panelMinimum, renderPanelWidth, setWidth],);+ /**+ * Double-click reset: the default width, kept inside the same live bounds+ * the keyboard path uses, so a reset never breaches the MainChat floor or+ * reopens a compact panel wider than the window allows.+ */+ const onPanelResizeReset = useCallback(+ (event: React.MouseEvent<HTMLDivElement>) => {+ // While maximized there is no second column to trade width with.+ if (maximized) return;+ // A gesture that is still open (a second pointer) must not overwrite the+ // reset when it is finally released.+ const drag = panelResizeState.current;+ if (drag) finishPanelResize(event.currentTarget, drag.pointerId, true);+ setPanelDragWidth(null);+ setWidth(workPanelResetWidth(panelMinimum, layout.maxPanelWidth));+ },+ [finishPanelResize, layout.maxPanelWidth, maximized, panelMinimum, setWidth],+ );+const activePluginView =activeTab?.kind === "plugin"? pluginViews.find((view) => view.ref === activeTab.resource)@@ -465,6 +488,7 @@ export function WorkPanel({onPointerCancel={onPanelResizeCancel}onLostPointerCapture={onPanelResizeCancel}onKeyDown={onPanelResizeKeyDown}+ onDoubleClick={onPanelResizeReset}/><div className="work-panel-main"><header className="work-panel-header">diff --git a/apps/desktop/src/lib/sidebar-resize.ts b/apps/desktop/src/lib/sidebar-resize.tsindex 14984c5c3..f67ff21d7 100644--- a/apps/desktop/src/lib/sidebar-resize.ts+++ b/apps/desktop/src/lib/sidebar-resize.ts@@ -39,6 +39,15 @@ export function sidebarPointerResize({return { type: "width", width: clampSidebarWidth(raw, maxWidth) };}+/**+ * Double-click reset for the expanded-sidebar separator. The default stays+ * inside the live budget so resetting a squeezed three-column window cannot+ * push MainChat under its 450px floor.+ */+export function sidebarResetWidth(maxWidth = SIDEBAR_WIDTH_MAX): number {+ return clampSidebarWidth(SIDEBAR_WIDTH_DEFAULT, 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 450pxdiff --git a/apps/desktop/src/lib/work-panel-resize.ts b/apps/desktop/src/lib/work-panel-resize.tsindex a18340ab4..589f9db30 100644--- a/apps/desktop/src/lib/work-panel-resize.ts+++ b/apps/desktop/src/lib/work-panel-resize.ts@@ -46,6 +46,33 @@ export function clampWorkPanelWidth(return Math.max(workPanelWidthLimits(min).min, width);}+/**+ * Live bounds for a manual panel width: the compact minimum replaces the+ * regular minimum while the panel is below it, and the shared three-column+ * budget caps the growth. Pointer, keyboard, and reset paths share it so a+ * reset can never breach the MainChat floor.+ */+export function workPanelWidthBounds(+ panelMinimum = WORK_PANEL_MIN_WIDTH,+ maxPanelWidth: number,+) {+ const minimum = Math.min(panelMinimum, maxPanelWidth);+ return { minimum, maximum: Math.max(minimum, maxPanelWidth) };+}++/**+ * Double-click reset for the panel separator: the default width, clamped to+ * the live bounds, so a window narrower than the default keeps its budget cap.+ */+export function workPanelResetWidth(+ panelMinimum = WORK_PANEL_MIN_WIDTH,+ maxPanelWidth: number,+) {+ const { minimum, maximum } = workPanelWidthBounds(panelMinimum, maxPanelWidth);+ const target = Math.min(Math.max(WORK_PANEL_DEFAULT_WIDTH, minimum), maximum);+ return clampWorkPanelWidth(target, minimum);+}+export type WorkPanelLayout = {mainWidth: number;panelWidth: number;diff --git a/apps/desktop/test/sidebar-resize-math.test.mjs b/apps/desktop/test/sidebar-resize-math.test.mjsindex 63f0ec64c..04c37f96b 100644--- a/apps/desktop/test/sidebar-resize-math.test.mjs+++ b/apps/desktop/test/sidebar-resize-math.test.mjs@@ -9,6 +9,7 @@ import {SIDEBAR_COLLAPSE_THRESHOLD,SIDEBAR_RESIZE_STEP,sidebarPointerResize,+ sidebarResetWidth,sidebarWidthBudget,} from "../src/lib/sidebar-resize.ts";import {@@ -106,3 +107,13 @@ test("the live sidebar budget keeps MainChat above its floor", () => {assert.equal(1200 - capped - 360, MAIN_PANE_MIN_WIDTH + 1);assert.equal(SIDEBAR_WIDTH_DEFAULT, 275);});++test("double-click resets the sidebar to its default inside the live budget", () => {+ assert.equal(sidebarResetWidth(), SIDEBAR_WIDTH_DEFAULT);+ assert.equal(sidebarResetWidth(SIDEBAR_WIDTH_MAX), SIDEBAR_WIDTH_DEFAULT);+ assert.equal(sidebarResetWidth(300), SIDEBAR_WIDTH_DEFAULT);+ // A squeezed three-column window keeps its cap, so the reset can never push+ // MainChat under its 450px floor.+ assert.equal(sidebarResetWidth(250), 250);+ assert.equal(sidebarResetWidth(SIDEBAR_WIDTH_MIN - 100), SIDEBAR_WIDTH_MIN);+});diff --git a/apps/desktop/test/sidebar-resize.test.mjs b/apps/desktop/test/sidebar-resize.test.mjsindex d4156ef50..e9a722806 100644--- a/apps/desktop/test/sidebar-resize.test.mjs+++ b/apps/desktop/test/sidebar-resize.test.mjs@@ -26,6 +26,8 @@ test("the sidebar exposes an accessible pointer and keyboard resize handle", ()assert.match(sidebarSource, /finishSidebarResize\(true, true\)/);assert.match(sidebarSource, /onResizeCollapse/);assert.match(sidebarSource, /sidebarPointerResize\(/);+ assert.match(sidebarSource, /onDoubleClick=\{resetSidebarWidth\}/);+ assert.match(sidebarSource, /sidebarResetWidth\(widthMax\)/);});test("sidebar width is shell-owned and the resize affordance is edge-anchored", () => {diff --git a/apps/desktop/test/work-panel-resize.test.mjs b/apps/desktop/test/work-panel-resize.test.mjsindex 4fea033c2..3c7baa0c7 100644--- a/apps/desktop/test/work-panel-resize.test.mjs+++ b/apps/desktop/test/work-panel-resize.test.mjs@@ -13,6 +13,8 @@ import {committedWorkPanelChatWidth,parseWorkPanelChatWidth,workPanelLayout,+ workPanelResetWidth,+ workPanelWidthBounds,workPanelChatWidthFromPointer,workPanelWidthForSidebarReopen,} from "../src/lib/work-panel-resize.ts";@@ -218,3 +220,38 @@ test("accepts only bounded integer conversation widths over IPC", () => {assert.equal(parseWorkPanelChatWidth({ width: "1200" }), null);assert.equal(parseWorkPanelChatWidth(null), null);});++test("double-click resets the panel to its default width", () => {+ assert.equal(WORK_PANEL_DEFAULT_WIDTH, 360);+ assert.equal(+ workPanelResetWidth(WORK_PANEL_MIN_WIDTH, 800),+ WORK_PANEL_DEFAULT_WIDTH,+ );+ assert.equal(+ workPanelResetWidth(WORK_PANEL_COMPACT_MIN_WIDTH, 800),+ WORK_PANEL_DEFAULT_WIDTH,+ );+ assert.equal(+ workPanelResetWidth(WORK_PANEL_MIN_WIDTH, 400),+ WORK_PANEL_DEFAULT_WIDTH,+ );+});++test("a reset stays inside the live bounds instead of breaching MainChat", () => {+ // A narrower budget than the default keeps the capped width.+ assert.equal(workPanelResetWidth(WORK_PANEL_MIN_WIDTH, 300), 300);+ assert.equal(workPanelResetWidth(WORK_PANEL_COMPACT_MIN_WIDTH, 120), 120);+ assert.deepEqual(workPanelWidthBounds(WORK_PANEL_COMPACT_MIN_WIDTH, 120), {+ minimum: WORK_PANEL_COMPACT_MIN_WIDTH,+ maximum: 120,+ });+ // The three-column budget replaces the regular minimum when it is smaller.+ assert.deepEqual(workPanelWidthBounds(WORK_PANEL_MIN_WIDTH, 120), {+ minimum: 120,+ maximum: 120,+ });+ assert.deepEqual(workPanelWidthBounds(WORK_PANEL_MIN_WIDTH, 800), {+ minimum: WORK_PANEL_MIN_WIDTH,+ maximum: 800,+ });+});diff --git a/apps/desktop/test/work-panel.test.mjs b/apps/desktop/test/work-panel.test.mjsindex 3bc32f268..98b0c0ef9 100644--- a/apps/desktop/test/work-panel.test.mjs+++ b/apps/desktop/test/work-panel.test.mjs@@ -402,6 +402,13 @@ test("work panel separator exposes internal panel width resizing", () => {assert.match(panelSource, /onPointerCancel=\{onPanelResizeCancel\}/);assert.match(panelSource, /onLostPointerCapture=\{onPanelResizeCancel\}/);assert.match(panelSource, /onKeyDown=\{onPanelResizeKeyDown\}/);+ assert.match(panelSource, /onDoubleClick=\{onPanelResizeReset\}/);+ assert.match(+ panelSource,+ /if \(drag\) finishPanelResize\(event\.currentTarget, drag\.pointerId, true\)/,+ );+ assert.match(panelSource, /workPanelResetWidth\(panelMinimum, layout\.maxPanelWidth\)/);+ assert.match(panelSource, /workPanelWidthBounds\(/);assert.match(panelSource, /data-work-panel-resizing/);assert.match(globalStyles, /\.work-panel-resize \{[^}]*width:\s*10px;/s);assert.match(globalStyles, /touch-action:\s*none/);diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex ce34a8ad2..ff6943100 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -480,6 +480,8 @@ visually distinct from list content.reflows continuously, the press position remains anchored, and the finalwidth is saved on release. Focus the edge handle and use ArrowLeft/Right,Home, or End for keyboard resizing; Escape cancels an active pointer resize.+ Double-click the handle to restore the default 275px width, clamped by the+ live three-column budget so the reset never breaches the MainChat floor.- Click the viewport-fixed work-panel toggle to reveal or hide the panelwithout deleting tabs; the work-panel header keeps its tab strip and fixed `+`menu, while each tab owns resource closing@@ -1081,7 +1083,10 @@ entirely inside the plugin's isolated page:and starting panel width, so grabbing the handle cannot jump the divider;moves are frame-coalesced. Escape, pointer cancellation, and lost capturerestore the press-time panel width. The 10px hit area keeps a column-resize- cursor and suppresses text selection during the gesture.+ cursor and suppresses text selection during the gesture. A double-click on+ the divider restores the default 360px width, clamped by the same live+ minimum and three-column budget, so a reset never breaches the MainChat+ floor.- Persistence: all session contexts are renderer runtime state only. On appstartup, open state, tabs, active-tab selection, file requests, and Browserresources reset; only the committed preferred `{width}` remains indiff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex 3794d530d..27f3ea12b 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -1021,7 +1021,8 @@ Work-panel and application-window resizing are implemented in MVP:- The inner divider's target clamps to the shared three-column budget(`client width - 450px - expanded sidebar`, with no fixed pixel cap); pointer movement isframe-coalesced and release commits the preferred width. Escape, pointer- cancellation, and lost capture restore the press-time panel width.+ cancellation, and lost capture restore the press-time panel width. A+ double-click restores the default 360px width inside those same live bounds.- Opening and closing animate the dock's `width` and `flex-basis` together withthe bounded opacity/transform feedback, so MainChat reflows continuouslyinside the existing client area without crossing its 450px minimum instead of@@ -1054,6 +1055,7 @@ Work-panel and application-window resizing are implemented in MVP:The expanded sidebar is user-resizable from 240px to 520px (default 275px) viathe right-edge handle. Pointer motion below 160px collapses the sidebar andkeeps the preferred expanded width. Keyboard Arrow/Home/End resize without collapsing.+Double-clicking the handle restores the 275px default inside the live budget.Project ordering is implemented for retained project groups. There is noreorder 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.mdindex 42899fe0d..96f82e04d 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -3169,7 +3169,9 @@ identify the platform validation still needed.7) Drag the inner left-edge handle left and right across its bounds; verifypointer-down does not jump the divider or resize the native window, cancel onegesture with Escape, then focus the handle and exercise Arrow/Shift+Arrow/Home/End.- Commit a different panel width with Browser active. 8) Record MainChat width+ Commit a different panel width with Browser active, double-click the divider and+ confirm the default 360px width returns (or the live budget when it is smaller),+ then commit a different width again. 8) Record MainChat widthand native bounds while opening, repeating the same open action, resizing thepanel, collapsing, reopening, and closing the final resource. Repeat collapseon Windows while watching the entire frameless window. 9) With the panel open,@@ -3208,7 +3210,8 @@ identify the platform validation still needed.inner divider exposes the panel width to assistive technology and supportsthe documented keyboard steps. Pointer-down preserves the starting width,movement follows the pointer continuously, and release commits once only when- the target changed. Escape or cancellation restores the press-time width.+ the target changed. Escape or cancellation restores the press-time width, and a+ double-click restores the 360px default inside the live bounds.Browser preview does not intercept an active divider drag.A and B independently restore their runtime open state, ordered tabs, activetab, and Browser resource; selecting a project without an active conversation@@ -9901,12 +9904,17 @@ This test plan spec is accepted when:6. Start a resize, press Escape or cancel the pointer, then restart the app.Collapse and re-expand the sidebar as a separate check; the preferredexpanded width must return.+ 7. Drag the handle wide, double-click it, and confirm the width returns to the+ default 275px. Repeat after a minimum-width drag and on a squeezed window+ where the live cap is the binding bound.- **Expected**: The handle is discoverable on direct hover/focus without afull-height white/accent rail when the sidebar body is hovered, has no nativewindow drag or text-selection side effect, and remains anchored to the presspoint. MainChat follows the live width until its 450px floor. Pointer releasesaves one clamped preferred width; Escape/cancellation restores the starting- width without saving it. A pointer width below 160px collapses the sidebar as+ width without saving it. Double-clicking the handle restores the default+ 275px width, clamped to the live budget so the reset never breaches the 450px+ MainChat floor. A pointer width below 160px collapses the sidebar asa user action and restores the preferred expanded width on reopen. Keyboardchanges commit immediately and expose localized width semantics. The savedwidth survives relaunch and is restored after sidebar collapse; collapse does