Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
feat(ui): collapse the sidebar Projects section and remember section state (#3116)
Call White0d2f71ee81d0
diff --git a/docs/plans/workbench-refinements.md b/docs/plans/workbench-refinements.mdnew file mode 100644index 000000000..82d91ac6d--- /dev/null+++ b/docs/plans/workbench-refinements.md@@ -0,0 +1,308 @@+# Workbench refinements++Status: approved by the owner on 2026-11-01, together with the answers to the+design questions (see "Owner decisions"). Mockups are on the Show Page of the+design Session.++Three refinements to the Workbench:++1. The Inbox separates Bot conversations from ordinary Sessions, and+ notifications can be switched per category.+2. The sidebar's Projects section collapses like Capabilities.+3. Runs of Harness messages in a conversation fold into one group.++Delivery: items 2 and 3 are front-end only and ship now, one PR each. Item 1+waits for the Bots backend (`docs/plans/bots.md`, PR 4 of its delivery plan):+the server work goes to the GPT line, the interface to the Claude line.++## Owner decisions (2026-11-01)++- A category whose notifications are off does not count in aggregate badges.+- The switches belong to the account, not the device.+- Muting a single Bot comes later; the storage reserves room for it.+- The desktop app notifying for Bot replies is the next small step after item 1.+- A Session's first message never folds into a Harness group.+- The preferences live in `state_meta`, not a new table (orchestrator, same day).++## 1. Inbox categories and notification switches++Implement after the Bots backend has merged.++### Current facts++- Unread means an unread Agent `result` row, counted per Session, excluding+ archived and non-foreground Sessions+ (`storage/messages_service.py::unread_counts_by_session`, `total_unread`).+ `vibe/message_types.json` marks `result` as the only `unread` type; `result`+ and `error` as `webPush`; and `notify` with `backend_failure` through+ `webPushWhenEvents`.+- `GET /api/inbox` (`vibe/ui_server.py::inbox_list`) returns the paged feed plus+ `unread_by_session`, `unread_total`, and `unread_sessions`.+- `ui/src/context/WorkbenchInboxProvider.tsx` owns `unreadBySession` and+ `totalUnread`, and mirrors the total to the PWA app badge (`setAppBadge`, plus+ a `vibe.app-badge-current` message to the service worker) and the tab favicon+ (`syncFaviconBadge`). `WorkbenchSidebar.tsx` renders the Inbox entry and+ `InboxHoverPopover`; `InboxPage.tsx` holds the Unread/All filter,+ `WebPushControl`, and mark-all-read.+- Web Push: `core/message_mirror.py` calls+ `core/web_push_notifications.py::maybe_notify_inbox_message` for each new+ Workbench Agent message of a notifiable type. `_send_to_enabled_subscriptions`+ waits 3 s, skips a message already read, resolves the owners from the latest+ user message's `_web_push_user_key(s)`, applies the Personal or Organization+ authorization and the Project policy, then sends to every enabled+ subscription of each owner with `badge_count` from+ `_badge_count_for_user_key`. Subscriptions are per device+ (`storage/web_push_service.py`).+- `ui/public/push-sw.js` shows a notification for every push (iOS requires it,+ so a push cannot be dropped on the device) and refreshes the app badge from+ `/api/inbox?platform=avibe&limit=1` → `unread_total`.+- Desktop app: `desktop/runtime-host/src/notifications.rs` follows+ `/api/events` and raises OS notifications only for `vaults.updated` (a+ pending approval) and `runs.updated` (a background run reaching a terminal+ state); the Dock badge reads `/api/inbox` → `unread_total`. The tray+ "Notifications" item (`desktop/src-tauri/src/notifications.rs`) stores a+ per-shell switch. No OS notification is raised for Agent replies. Contract:+ `docs/plans/desktop-notifications-sse.md`.+- The desktop pet lists Sessions with unread replies+ (`ui/src/pet/usePetReplyActivities.ts`). IM platforms notify through their+ own apps.+- On the owner's machine, foreground Sessions produced 4,139 Agent replies in+ the 30 days before the design, about 138 pushable messages a day.++### Behavior++Categories:++- `bot`: the message's Session is the permanent Session of a current Bot+ (`ses_<handle>` of an enabled Bot).+- `session`: every other Inbox Session, and workspace-addressed failure notices+ that have no Session.+- Bots are owner-only in phase 1, so other members have one category and see+ only the master switch.++Preferences belong to the account (`user_key`: `local` or `remote:<sub>`),+default all on:++| Field | Meaning |+| --- | --- |+| `enabled` | master switch |+| `bots` | Bot messages |+| `sessions` | ordinary Session messages |++A category is **loud** when `enabled` and its own switch are on, otherwise+**quiet**. A quiet message is not pushed and not counted in aggregate badges;+it is still delivered, listed, and unread.++| Path | Category quiet | Master off |+| --- | --- | --- |+| Web Push (every subscribed device) | nothing sent for that category | nothing sent |+| PWA app icon badge, desktop Dock badge, tab favicon | count excludes the category | cleared |+| Sidebar Inbox icon | number counts loud categories; grey dot when only quiet unread remains | grey dot when anything is unread |+| Desktop OS notifications | `run.terminal` for that category's Sessions suppressed; Vault approvals still notify | none |+| Per-conversation counts (Bot avatars, project-tree Session rows, Inbox rows) | unchanged; Inbox rows of a quiet category draw their count grey | unchanged |+| Pet, IM | unchanged | unchanged |++- `badge_total` is the unread sum over loud categories. With the default+ preferences it equals `unread_total`, which keeps the Inbox total of+ `docs/plans/bots.md` D5.+- Vault approvals block on the user and are not messages: they notify while+ `enabled` is on, whatever the category.+- The Web Push test ignores categories; its toast says when a category is+ quiet.+- The tray item stays the device switch for desktop OS notifications, as the+ subscription is for Web Push. The device switch and the account preference+ must both allow a notification.+- Next step after this item: the desktop app raises an OS notification for a Bot+ reply while Bot messages are loud and its window is not focused.++### UI++- Inbox popover and Inbox page: two sections, Bots first, then Sessions. Each+ section header shows its unread count; a quiet section shows a grey count and+ a "Muted" mark. The popover shows up to three Bot rows and three Session+ rows, unread first within each, with the existing "more unread in the full+ Inbox" link per section. A Bot row is avatar, display name, and preview; it+ needs no Bot tag inside its own section. The page keeps Unread/All and adds+ "mark this section read" to the Sessions header.+- `NotificationMenu`: the master switch, Bot messages, Session messages (with a+ one-line note when Sessions are off), this device's push state with Test or+ Enable, and a link to Settings › Notifications. It opens from a bell in the+ popover header (left of "Mark all read") and from a "Notifications: All /+ Bots only / Sessions only / Off" button on the Inbox page toolbar. The bell is+ `Bell` when everything is on, `BellMinus` with a short label when partial, and+ `BellOff` when off. The hover popover stays open while the portaled menu is+ open.+- Settings › Notifications, a new page right after General in+ `ui/src/components/settings/SettingsLayout.tsx`: the same switches with+ one-line explanations, "This device" with the full `WebPushControl` (moved out+ of the Inbox toolbar), and a note that desktop OS notifications are switched+ from the tray menu.+- Sidebar Inbox icon: a cyan number for `badge_total`; a grey dot with no number+ when `badge_total` is 0 and anything is unread.++### Server and API++- Storage: `state_meta` key `notification_preferences:<user_key>`, value JSON+ `{"enabled": true, "bots": true, "sessions": true}`, read and written through+ the existing `get_state_meta` / `set_state_meta` helpers; no migration. A+ missing key or field means on; unknown fields are preserved on write. A later+ per-Bot mute adds `muted_bots: [<handle>, ...]` to the same value.+- `GET /api/notifications/preferences` and `PUT /api/notifications/preferences`,+ scoped to the caller's `user_key` (the key `_web_push_user_key` resolves),+ with CSRF like other writes. A write publishes SSE+ `notifications.preferences.updated`.+- One helper owns categorization, for example a Bot-session-id set read from the+ Bot registry, shared by the Inbox listing, push gating, and badges. The+ category cannot come from the scope: Bot Sessions have none.+- `GET /api/inbox`: each row gains `category`; the response gains+ `unread_by_category` (`{bot, session}`) and the caller's `badge_total`. An+ optional `category=bot|session` filter on `list_inbox_sessions` lets each+ Inbox page section page on its own.+- Web Push: `_send_to_enabled_subscriptions` drops, after authorization and the+ Project policy, the owners for whom the message is quiet, recording a new+ `muted` disposition in the diagnostics ring; `_badge_count_for_user_key`+ returns `badge_total`.+- Service worker: the badge refresh reads `badge_total`, falling back to+ `unread_total` for an older server.+- Desktop runtime-host: the Dock badge reads `badge_total` (falling back to+ `unread_total`). For `run.terminal`, the run detail it already fetches gains+ `notification_category`, and the host reads preferences from+ `GET /api/notifications/preferences` on connect and on+ `notifications.preferences.updated`. This revises the frozen contract in+ `docs/plans/desktop-notifications-sse.md` and ships as its own PR after the+ server part.++### Code that changes++- Server: `storage/messages_service.py` (category split and filter),+ `vibe/ui_server.py` (`/api/inbox` fields and preference routes),+ `core/web_push_notifications.py`, a small preference service over+ `state_meta`, and the Bot-session helper.+- Web: `WorkbenchInboxProvider.tsx` and `WorkbenchInboxContext.ts` (expose+ `unreadByCategory`, `badgeTotal`, and the preferences; the app badge, favicon,+ and worker message use `badgeTotal`), `WorkbenchSidebar.tsx` (popover sections+ and bell), `InboxPage.tsx` (sections and notification button;+ `WebPushControl` leaves the toolbar), a new `NotificationMenu.tsx`, a new+ `settings/SettingsNotificationsPage.tsx` with its route,+ `ui/public/push-sw.js`, and `en`/`zh` strings.+- Desktop: `desktop/runtime-host/src/notifications.rs`.+- Tests: push gating per category and master switch, badge totals per+ preference, the `/api/inbox` fields, the worker fallback, section rendering,+ menu state, and desktop host filtering against a fake server.++## 2. Collapsible Projects++### Current facts++- In `WorkbenchSidebar.tsx`, Capabilities is a header button (label on the+ left, chevron on the right, turned `-90deg` when closed) over a `nav`. Its+ state is `useState(true)`, so it reopens on every reload.+- The Projects header has the label on the left and borderless Search and New+ project icons on the right, and does not collapse.+- Per-browser UI memory follows `ui/src/lib/agentsViewMemory.ts`: versioned+ `avibe.*` keys and best-effort `localStorage`.++### Behavior++- Projects collapses like Capabilities. Header: the label (toggle), Search, New+ project, and the chevron (toggle). Both sections' chevrons sit at the right+ edge in one column.+- Collapsed, the header keeps Search and New project; the list is hidden and the+ footer stays pinned. The header shows no unread or running summary: the Inbox+ icon and the Bot avatars carry unread.+- Creating a project while the section is collapsed opens it, so the new+ project is visible. Navigation never opens it otherwise.+- Both sections' open state persists per browser under `localStorage` key+ `avibe.sidebar.sections.v1` as `{"capabilities": true, "projects": true}`.+ Both default to open; a missing, unknown, or corrupt value reads as open.+- The mobile `ProjectsPage` is unchanged.++### Code that changes++- `WorkbenchSidebar.tsx`: the Projects header becomes a row of a toggle button+ over the label, the two icon buttons, and a chevron toggle button, with+ `aria-expanded` and `aria-controls`; Capabilities reads and writes the same+ memory.+- A new `ui/src/lib/sidebarSectionsMemory.ts` with tests, and sidebar tests for+ collapsing, persistence, and New project reopening the section.++## 3. Auto-collapse Harness messages++### Current facts++- A Harness row is the `isHarness` branch of `MessageRow` in+ `ui/src/components/workbench/ChatPage.tsx`: a cyan `RoleAvatar` with a clock,+ the source label from `harnessChipLabelKey` (`ui/src/lib/chatTrigger.ts`), and+ a dashed chip with a one-line preview that expands per row. The render kind+ `harness` covers the `harness` and `vault` types.+- `Transcript` renders the loaded messages in order and places Activity chips+ from `activity.beforeAnchor` and `activity.afterAnchor`.+- A Turn that ends without a reply writes no visible row. If it had activity,+ its group anchors `after` its trigger+ (`storage/agent_activity_service.py::_build_groups`); otherwise it leaves+ nothing.+- Across every Web Session on the owner's machine at design time: 33,628+ Harness inputs against 12,535 user messages; 4,960 runs of two or more held+ 20,304 of them (60%); folding leaves 18,284 Harness items (46% fewer); 73% of+ runs ended with an Agent reply; 45% mixed sources; runs lasted about 52+ minutes on average and 323 lasted over two hours; 371 runs started at the+ Session's first message; about half of the inputs inside runs were followed+ by Activity.++### Rule++- A groupable row is a transcript row that renders as `harness`, except the+ Session's first message when the loaded window starts at the beginning of the+ Session (no older page and index 0).+- A run is two or more groupable rows with nothing visible between them except+ Activity chips anchored `after` a member of the run (Turns that did not reply,+ including interrupted ones).+- Anything else visible breaks a run: user rows, annotation cards, and Agent+ rows of any kind (replies, mid-Turn `output`, `interim`, status and failure+ notices, errors). A chip anchored `before` a breaking reply belongs to that+ reply and stays outside.+- Time gaps and source kinds do not break a run. A single groupable row renders+ as today.+- A pure function, `groupHarnessRuns`, turns the loaded messages into+ transcript items: a single message, or a Harness group with its ordered+ members.++### Look++- Collapsed, the default: a header with a cyan `RoleAvatar` (layers icon),+ "N Harness messages", per-source counts using the existing source labels,+ and the first and last times; below it a dashed chip stacked over two offset+ sheets, showing "Latest", the latest member's source, and its one-line+ preview. The whole chip toggles.+- Expanded: the same header with "Collapse"; the members in their existing+ rendering, with their Activity chips, on a cyan left rail; a trailing collapse+ link.++### Behavior++- Live: a group at the tail grows in place. The count and the latest preview+ update; a collapsed group stays collapsed and an expanded one appends. The+ running Activity card stays at the transcript tail, outside the group. If+ that Turn ends without a reply its chip joins the group; if it replies, the+ reply closes the group.+- A single row that becomes a run of two forms a collapsed group, unless that+ row was expanded, in which case the group starts expanded.+- Unread: Harness inputs are never unread (only `result` is), so groups carry no+ unread mark and change no counts. Opening a Session still lands at the tail.+- Scroll: toggling keeps the group header in place (the existing anchor logic);+ a reader following the tail stays pinned; a jump or search target inside a+ group expands that group before scrolling and highlights the row; older pages+ prepended above can grow a group at its top.+- State: the set of expanded member ids, in memory for the open Session. A+ group is expanded when any member is in the set, so growth at either end+ keeps its state. Nothing is persisted.+- Web transcript only: search, copy, Retry eligibility, the API, and IM are+ unchanged.++### Code that changes++- `ChatPage.tsx` `Transcript`: render items instead of raw messages, route the+ members' after-chips into their group, and expand on jump.+- A new `HarnessGroup` component reusing the Harness row and `ActivityChip`; a+ new `ui/src/lib/harnessGroups.ts` with unit tests for the break rules, the+ first-message rule, live growth, and anchor routing; `en`/`zh` strings.diff --git a/ui/src/components/workbench/WorkbenchSidebar.inbox.test.tsx b/ui/src/components/workbench/WorkbenchSidebar.inbox.test.tsxindex 498a3ed5a..9ac73e981 100644--- a/ui/src/components/workbench/WorkbenchSidebar.inbox.test.tsx+++ b/ui/src/components/workbench/WorkbenchSidebar.inbox.test.tsx@@ -63,6 +63,14 @@ vi.mock('../../context/WindowManagerContext', () => ({ useWindowManager: () => (vi.mock('../../context/useUnsavedChangesActionGuard', () => ({useUnsavedChangesActionGuard: () => (run: () => void) => run,}));+// The dialog's own flow is covered elsewhere; here only its completion matters.+vi.mock('./NewProjectDialog', () => ({+ NewProjectDialog: ({ onCreated }: { onCreated: (project: { id: string }) => void }) => (+ <button type="button" onClick={() => onCreated({ id: 'proj_new' })}>+ finish new project+ </button>+ ),+}));import en from '../../i18n/en.json';import { WorkbenchSidebar } from './WorkbenchSidebar';@@ -87,8 +95,11 @@ const sidebarElement = (active = true, onOpenSearch?: () => void) => (const renderSidebar = (active = true, onOpenSearch?: () => void) => render(sidebarElement(active, onOpenSearch));const inboxIcon = () => screen.getByRole('link', { name: en.workbench.nav.inbox }).querySelector('svg')!;+const projectsToggle = () => screen.getByRole('button', { name: en.workbench.projectsLabel });beforeEach(() => {+ // Section open state is remembered per browser; every case starts from a fresh one.+ window.localStorage.clear();inbox.totalUnread = 0;inbox.unreadSessions = 0;inbox.inboxSessions = [];@@ -144,9 +155,9 @@ describe('Workbench sidebar inbox counter', () => {const onOpenSearch = vi.fn();const { rerender } = renderSidebar(true, onOpenSearch);- const header = screen.getByText(en.workbench.projectsLabel).parentElement!;- expect(within(header).getAllByRole('button').map((button) => button.getAttribute('aria-label')))- .toEqual([en.workbench.search.entry, en.workbench.addProject]);+ const header = projectsToggle().parentElement!;+ expect(within(header).getAllByRole('button').map((button) => button.getAttribute('aria-label') ?? button.textContent))+ .toEqual([en.workbench.projectsLabel, en.workbench.search.entry, en.workbench.addProject]);// Search is not a project-creation affordance: withholding creation must// take the add control away and leave the palette entry exactly where it is.@@ -241,3 +252,54 @@ describe('Workbench sidebar capability navigation', () => {expect(screen.queryByRole('navigation')).toBeNull();});});++describe('Workbench sidebar projects section', () => {+ it('collapses the project list and keeps Search and New project in its header', async () => {+ const user = userEvent.setup();+ const onOpenSearch = vi.fn();+ const { container } = renderSidebar(true, onOpenSearch);++ expect(projectsToggle().getAttribute('aria-expanded')).toBe('true');+ expect(container.querySelector(`#${projectsToggle().getAttribute('aria-controls')}`)).toBeTruthy();+ expect(screen.getByText(en.workbench.projectsEmpty)).toBeTruthy();++ await user.click(projectsToggle());+ expect(projectsToggle().getAttribute('aria-expanded')).toBe('false');+ expect(screen.queryByText(en.workbench.projectsEmpty)).toBeNull();+ expect(screen.getByRole('button', { name: en.workbench.addProject })).toBeTruthy();+ await user.click(screen.getByRole('button', { name: en.workbench.search.entry }));+ expect(onOpenSearch).toHaveBeenCalledOnce();++ // The chevron closing the row is a second pointer target for the same toggle.+ const chevron = projectsToggle().parentElement!.lastElementChild as HTMLElement;+ await user.click(chevron);+ expect(projectsToggle().getAttribute('aria-expanded')).toBe('true');+ expect(screen.getByText(en.workbench.projectsEmpty)).toBeTruthy();+ });++ it('remembers both collapsed groups across a reload', async () => {+ const user = userEvent.setup();+ const first = renderSidebar();+ await user.click(screen.getByRole('button', { name: en.nav.capabilities }));+ await user.click(projectsToggle());+ first.unmount();++ renderSidebar();+ expect(screen.getByRole('button', { name: en.nav.capabilities }).getAttribute('aria-expanded')).toBe('false');+ expect(screen.queryByRole('link', { name: en.workbench.nav.agents })).toBeNull();+ expect(projectsToggle().getAttribute('aria-expanded')).toBe('false');+ expect(screen.queryByText(en.workbench.projectsEmpty)).toBeNull();+ });++ it('opens the list when a project is created while it is collapsed', async () => {+ const user = userEvent.setup();+ renderSidebar();+ await user.click(projectsToggle());++ await user.click(screen.getByRole('button', { name: en.workbench.addProject }));+ await user.click(screen.getByRole('button', { name: 'finish new project' }));++ expect(projectsToggle().getAttribute('aria-expanded')).toBe('true');+ expect(screen.getByText(en.workbench.projectsEmpty)).toBeTruthy();+ });+});diff --git a/ui/src/components/workbench/WorkbenchSidebar.tsx b/ui/src/components/workbench/WorkbenchSidebar.tsxindex 5a8001ed9..a33caaa5a 100644--- a/ui/src/components/workbench/WorkbenchSidebar.tsx+++ b/ui/src/components/workbench/WorkbenchSidebar.tsx@@ -28,6 +28,7 @@ import clsx from 'clsx';import type { LucideIcon } from 'lucide-react';import { writeInboxFilter } from '../../lib/inboxFilterMemory';+import { useSidebarSectionOpen } from '../../lib/sidebarSectionsMemory';import { useRouteSurfaceActive } from '../../lib/routeSurfaceActivity';import { useLatestRef } from '../../lib/useLatestRef';@@ -815,7 +816,9 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOpconst [popoverOpen, setPopoverOpen] = useState(false);const closeTimer = useRef<number | null>(null);const [showNewProject, setShowNewProject] = useState(false);- const [capabilitiesOpen, setCapabilitiesOpen] = useState(true);+ // Both groups remember, per browser, whether the user left them open.+ const [capabilitiesOpen, setCapabilitiesOpen] = useSidebarSectionOpen('capabilities');+ const [projectsOpen, setProjectsOpen] = useSidebarSectionOpen('projects');// Small open/close delays so the popover doesn't flicker as the cursor// brushes through the inbox row on its way somewhere else, and survives@@ -955,7 +958,7 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOpclassName="group flex items-center gap-1 px-1 font-mono text-[10px] font-bold uppercase tracking-[0.18em] text-muted transition-colors hover:text-foreground"aria-expanded={capabilitiesOpen}aria-controls="workbench-capability-nav"- onClick={() => setCapabilitiesOpen((open) => !open)}+ onClick={() => setCapabilitiesOpen(!capabilitiesOpen)}><span className="flex-1 text-left">{t('nav.capabilities')}</span><ChevronDown className={clsx('size-3.5 shrink-0 transition-transform', !capabilitiesOpen && '-rotate-90')} />@@ -970,17 +973,25 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOp</div>)}- {/* Projects section t7o96 — the label on the left (matching the- Capabilities label style) and the borderless search + add icons grouped- on the right. Search sits immediately before add and stays reachable- for everyone who could reach it before, including the people this- instance does not let create a project; ⌘K still opens the same- palette from anywhere. */}+ {/* Projects section t7o96 — collapses like Capabilities: the label and the+ chevron closing the row both toggle it, and the chevron sits in the same+ right-edge column as the Capabilities one. The borderless search + add+ icons stay between them, so they remain reachable while the list is+ hidden. Search sits immediately before add and stays reachable for+ everyone who could reach it before, including the people this instance+ does not let create a project; ⌘K still opens the same palette from+ anywhere. */}<div className="flex min-h-0 flex-1 flex-col gap-1.5">- <div className="flex items-center justify-between px-1">- <span className="font-mono text-[10px] font-bold uppercase tracking-[0.18em] text-muted">- {t('workbench.projectsLabel')}- </span>+ <div className="flex items-center px-1">+ <button+ type="button"+ className="flex h-7 min-w-0 flex-1 items-center text-left font-mono text-[10px] font-bold uppercase tracking-[0.18em] text-muted transition-colors hover:text-foreground"+ aria-expanded={projectsOpen}+ aria-controls="workbench-project-list"+ onClick={() => setProjectsOpen(!projectsOpen)}+ >+ <span className="truncate">{t('workbench.projectsLabel')}</span>+ </button><div className="flex items-center gap-0.5"><Buttontype="button"@@ -1003,9 +1014,20 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOp<FolderPlus className="size-4" /></Button>}</div>+ {/* A second pointer target for the label's toggle, so it is hidden from+ assistive tech and the tab order: the label button is the control. */}+ <button+ type="button"+ tabIndex={-1}+ aria-hidden="true"+ className="ml-0.5 flex h-7 w-3.5 shrink-0 items-center justify-center text-muted transition-colors hover:text-foreground"+ onClick={() => setProjectsOpen(!projectsOpen)}+ >+ <ChevronDown className={clsx('size-3.5 shrink-0 transition-transform', !projectsOpen && '-rotate-90')} />+ </button></div>- <div className="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto pr-0.5">+ {projectsOpen && <div id="workbench-project-list" className="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto pr-0.5">{projects === null && !projectsError && (<div className="flex items-center gap-2 rounded-md border border-dashed border-border px-3 py-3 text-[11px] text-muted"><Loader2 className="size-3 animate-spin" />@@ -1067,13 +1089,17 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOp);}}</SortableProjectList>}- </div>+ </div>}</div>{showNewProject && canCreateProject && (<NewProjectDialogonClose={() => setShowNewProject(false)}- onCreated={() => setShowNewProject(false)}+ onCreated={() => {+ setShowNewProject(false);+ // A project just created must be visible, even if the list was collapsed.+ setProjectsOpen(true);+ }}/>)}</div>diff --git a/ui/src/i18n/keyCoverage.test.ts b/ui/src/i18n/keyCoverage.test.tsindex 42e685592..e814e9749 100644--- a/ui/src/i18n/keyCoverage.test.ts+++ b/ui/src/i18n/keyCoverage.test.ts@@ -890,6 +890,7 @@ const NON_KEY_LITERALS = ['avibe.editor.fontSize.v1','avibe.editor.recents.v1','avibe.pet.devBinding',+ 'avibe.sidebar.sections.v1','avibe.terminal.fontSize.v1','avibe.terminal.sessionId','avibe.vault.crypto',diff --git a/ui/src/lib/sidebarSectionsMemory.test.ts b/ui/src/lib/sidebarSectionsMemory.test.tsnew file mode 100644index 000000000..2dff90b29--- /dev/null+++ b/ui/src/lib/sidebarSectionsMemory.test.ts@@ -0,0 +1,61 @@+import { describe, expect, it, vi } from 'vitest';++import { readSidebarSectionOpen, writeSidebarSectionOpen } from './sidebarSectionsMemory';++const KEY = 'avibe.sidebar.sections.v1';++function memoryStorage(initial: Record<string, string> = {}) {+ const values: Record<string, string> = { ...initial };+ return {+ storage: {+ getItem: vi.fn((key: string) => values[key] ?? null),+ setItem: vi.fn((key: string, next: string) => {+ values[key] = next;+ }),+ },+ values,+ };+}++describe('sidebar sections memory', () => {+ it('records each section independently and keeps entries it does not own', () => {+ const memory = memoryStorage({ [KEY]: JSON.stringify({ bots: false }) });++ writeSidebarSectionOpen('projects', false, memory.storage);+ expect(readSidebarSectionOpen('projects', memory.storage)).toBe(false);+ expect(readSidebarSectionOpen('capabilities', memory.storage)).toBe(true);++ writeSidebarSectionOpen('capabilities', false, memory.storage);+ writeSidebarSectionOpen('projects', true, memory.storage);+ expect(readSidebarSectionOpen('capabilities', memory.storage)).toBe(false);+ expect(readSidebarSectionOpen('projects', memory.storage)).toBe(true);+ // A section a newer build added survives this build's writes.+ expect(JSON.parse(memory.values[KEY])).toEqual({ bots: false, capabilities: false, projects: true });+ });++ it.each([+ ['nothing stored', undefined],+ ['corrupt JSON', '{"projects":'],+ ['a non-object value', '[false]'],+ ['a non-boolean entry', JSON.stringify({ projects: 'no', capabilities: 0 })],+ ])('opens every section when the browser holds %s', (_label, stored) => {+ const memory = memoryStorage(stored === undefined ? {} : { [KEY]: stored });++ expect(readSidebarSectionOpen('projects', memory.storage)).toBe(true);+ expect(readSidebarSectionOpen('capabilities', memory.storage)).toBe(true);+ });++ it('degrades to open and stays silent when storage is unavailable', () => {+ const blocked = {+ getItem: vi.fn(() => {+ throw new Error('blocked');+ }),+ setItem: vi.fn(() => {+ throw new Error('blocked');+ }),+ };++ expect(() => writeSidebarSectionOpen('projects', false, blocked)).not.toThrow();+ expect(readSidebarSectionOpen('projects', blocked)).toBe(true);+ });+});diff --git a/ui/src/lib/sidebarSectionsMemory.ts b/ui/src/lib/sidebarSectionsMemory.tsnew file mode 100644index 000000000..832d46dfa--- /dev/null+++ b/ui/src/lib/sidebarSectionsMemory.ts@@ -0,0 +1,55 @@+// Remembers which collapsible Workbench sidebar sections the user left open, so+// a reload or a new window keeps the layout they chose. A layout preference of+// this browser, not of the account: it is never sent to the server.+//+// Storage conventions mirror agentsViewMemory: versioned `avibe.*` key,+// injectable storage for tests, best-effort try/catch so private mode or+// blocked storage degrades to the default rather than throwing.+import { useCallback, useState } from 'react';++export type SidebarSection = 'capabilities' | 'projects';++const STORAGE_KEY = 'avibe.sidebar.sections.v1';++type ViewStorage = Pick<Storage, 'getItem' | 'setItem'>;++function browserStorage(storage?: ViewStorage): ViewStorage | undefined {+ return storage ?? (typeof window !== 'undefined' ? window.localStorage : undefined);+}++function readAll(storage?: ViewStorage): Record<string, unknown> {+ try {+ const parsed: unknown = JSON.parse(browserStorage(storage)?.getItem(STORAGE_KEY) ?? '{}');+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? (parsed as Record<string, unknown>) : {};+ } catch {+ return {};+ }+}++/** Every section opens unless this browser recorded it closed: a missing,+ * unknown, or corrupt value never hides navigation. */+export function readSidebarSectionOpen(section: SidebarSection, storage?: ViewStorage): boolean {+ return readAll(storage)[section] !== false;+}++export function writeSidebarSectionOpen(section: SidebarSection, open: boolean, storage?: ViewStorage): void {+ try {+ // Keep the other sections' entries, including ones a newer build wrote.+ browserStorage(storage)?.setItem(STORAGE_KEY, JSON.stringify({ ...readAll(storage), [section]: open }));+ } catch {+ // Layout memory is best-effort in private browsing and restricted storage contexts.+ }+}++/** A section's open state, read once on mount and recorded on every change. */+export function useSidebarSectionOpen(section: SidebarSection): readonly [boolean, (open: boolean) => void] {+ const [open, setOpenState] = useState(() => readSidebarSectionOpen(section));+ const setOpen = useCallback(+ (next: boolean) => {+ setOpenState(next);+ writeSidebarSectionOpen(section, next);+ },+ [section],+ );+ return [open, setOpen] as const;+}