Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(ui): restore workbench home spacing and capability navigation (#2058)

Call Whiteb821f22f55b2
diff --git a/docs/plans/2026-09-18-workbench-general-settings.md b/docs/plans/2026-09-18-workbench-general-settings.md
index 5e49c846b..d6081c958 100644
--- a/docs/plans/2026-09-18-workbench-general-settings.md
+++ b/docs/plans/2026-09-18-workbench-general-settings.md
@@ -1,5 +1,119 @@
# Shared Workbench and General Settings — issue #2012
+## Current PM scope and acceptance (2026-09-20)
+
+The 11:24 PM continuation ruling supersedes the broader exploratory queue scope
+recorded below. Two real `ChatPage` probes on unchanged peer head `7450fd669`
+reproduced bootstrap/refresh overwrites in both arrival directions. The bounded
+repair shares successful snapshot ordering between those readers, retains the
+peer refresh-generation regression and existing send/session guards, and verifies
+that a newer failed read still permits an older successful fallback. Route-lifetime,
+optimistic remove and recall behavior are unchanged; this continuation does not
+claim new repairs or acceptance evidence for those broader hypotheses.
+
+After controlled reproduction of the CI drag failure, PM additionally authorized
+the existing desktop expanded-project test's viewport and visibility precondition
+correction described under "Review round 3 repair". The final scope relative to
+peer head `f227722436` is `ChatPage.tsx`, `ChatPage.hydration.test.tsx`,
+`ui/e2e/project-order/order.spec.ts`, and this plan. Product sidebar, Composer and
+drag behavior remain unchanged. Local candidate `430c5c630` passed 97 focused
+tests, typecheck, lint and build, the two affected browser cases, and the full
+project-order suite (16 passed, two declared platform skips, zero retries).
+PM independently reran six selected queue regressions successfully. These local
+results require fresh exact-head remote review and CI before PR acceptance.
+
+## Historical PM diagnosis: queue snapshot ordering (review 5259163447)
+
+This records the initial diagnosis at `73a8556dd`; its exploratory scope and
+acceptance list were narrowed by the current PM ruling above. Counts and CI state
+in this section are observations from that earlier checkpoint.
+
+The refreshed head `73a8556ddbcc41f13bb8434a2b4fe2d81aacb060` received one
+new actionable finding, inline `4055864365`, thread `PRRT_kwDOPbFPYs6kGUYR`.
+Independent complete inventory: ten reviews, twelve inline comments, three issue
+comments, eight threads with all nested pages exhausted; seven resolved and this
+one open. This is the sixth findings-bearing head and eighth historical finding.
+The current sixteen observed lint jobs have fourteen successes and two pending;
+CI is not the review gate and does not remove this finding.
+
+Causal diagnosis: send invocation identity protects one mutation's completion,
+but queue snapshots also come from initial/authorization bootstrap, SSE queue
+updates, reconnect recovery and mutation-triggered reads. An older successful
+read can overwrite a newer successful read because all these writes do not share
+an ordering owner. This is a repeated asynchronous stale-state class, so the PM
+has stopped blind patching and inspected every `setQueue`, `refreshQueue`, and
+`sendQueueNow` caller before authorizing the bounded repair below.
+
+The invariant is: within the active route lifetime, an older queue snapshot must
+not overwrite a newer successfully committed snapshot. A failed newer read must
+not by itself discard an older valid successful fallback. Bootstrap and ordinary
+refresh snapshots use the same queue ordering boundary; send-now keeps its
+additional invocation admission guard. Leaving and returning to the same Session
+must not re-admit an earlier route lifetime's reads or mutation completions.
+Inspect optimistic remove and successful recall writes as part of this same queue
+owner: a pre-mutation read must not resurrect a removed row; an explicit recovery
+read may restore the authoritative row when removal fails. Keep existing error,
+loading, Stop, spinner and server-authoritative queue behavior.
+
+Authorized implementation scope is `ChatPage.tsx`, its existing
+`ChatPage.hydration.test.tsx` consumer (and `ChatQueueRow.test.tsx` only if needed),
+and this plan. Reuse the adjacent transcript snapshot ordering pattern where
+appropriate; no shared hook, API, dependency, sidebar, Composer or backend change.
+The prior byte-parity assertion describes the mechanical refresh phase only;
+this separately recorded correctness fix is the sole newly authorized production
+delta over original #2058. No architecture rewrite or owner question is required.
+
+Acceptance requires a deterministic red reproduction on unchanged `73a8556dd`,
+then passing real ChatPage consumers for late post-send versus newer SSE reads,
+bootstrap overlap, route A-to-B-to-A lifetime rejection, and newer-read failure
+fallback; cover remove/recall boundaries if changed. Verify visible queue rows and
+their actions, not only helper internals. Run relevant existing tests, typechecks,
+repository lint and UI build. One implementation lane prepares a local committed
+candidate only; PM independently spot-checks code and consumer evidence before
+pushing. Keep the original PM Watch/cursor unchanged, no manual review trigger or
+CI rerun, and require new exact-head review/CI with this thread addressed afterward.
+
+## Owner resolution: PR #2058 over #2061 (2026-09-20)
+
+At 10:30 Asia/Shanghai the owner explicitly selected the complete PR #2058
+presentation when resolving its conflict with merged PR #2061. This decision
+supersedes the sidebar presentation and persistence contract in the retained
+historical `2026-09-20-sidebar-31-alignment.md` plan.
+
+Merge actual master `4de519cce2f7254325a88f652b31f510a7a8ff70` into PR #2058
+head `5b0dab0cbb13fac318e5bfc4bb1778a90d02aca6`, preserving the latter's
+`WorkbenchSidebar.tsx` and `WorkbenchSidebar.inbox.test.tsx` in full. Search
+remains a full-width row below the brand; the logo, Inbox, and capability rows
+follow #2058. Capabilities start expanded and retain their collapsed state while
+the sidebar owner remains mounted, including across Settings, without storing
+that preference in localStorage. Keep #2058's Composer spacing and queue send
+feedback, current authorization filters, and Settings activity boundaries.
+
+The initial conflict-resolution refresh kept all production and test content
+byte-identical to the original #2058 head. Re-run the affected consumers,
+hermetic browser geometry/capability cases, typechecks, lint, and UI build, then
+obtain fresh exact-head Codex review and CI. Historical green results do not
+qualify for the refreshed head. This authorizes updating the existing PR, not
+merging or deploying it. Any later review repair must be recorded with its
+scope and validation below.
+
+PM review inventory before this refresh: nine reviews, eleven inline comments,
+two issue comments, and seven resolved whole-PR threads, including exhausted
+nested pages. The seven original findings span five heads: `366793a02f` (1),
+`24357fb9ee` (2), `8d743f3d42` (1), `e47847a109` (1), and `ad60570259` (2).
+Root causes are documentation drift, server-authoritative queue retention,
+destructive voice-control placement, stale invocation effects, and disconnected
+sidebar state/translation consumers. The stale-invocation class repeated on two
+heads and requires PM diagnosis under the circuit breaker. Independent inspection
+confirms the current invocation predicate gates the settled response, error,
+queue-refresh result, and spinner cleanup; the sidebar toggle and eyebrow have
+live consumers. The current focused consumers pass. This round preserves those
+repairs and resolves the owner-selected presentation conflict. A later exact-head
+review also identified a queue-read ordering race; that repair and its validation
+are recorded below. Any new finding requires complete inventory and a fresh PM
+causal/scope ruling before further edits or pushes.
+
+
Owner authorized parallel implementation on 2026-09-18 02:36 Asia/Shanghai. PM session: sestqz5wvu5ty. Branch feat/workbench-general-settings starts at GitHub-verified master 4019b704c99afe16223d475fccd9e1cb94a109d7 in its own worktree. #2011 is a separate active lane; #2013 remains deferred. Historical #2010-only or sequential-dispatch language is superseded by this explicit instruction.
## Outcome
@@ -69,7 +183,8 @@ the user has not answered, while the shell's own location follows the foreground
## Implementation record
- **Shell** — `AppShell` sidebar at 248 on `--sidebar-background`, brand row (mark, title, `workbench.eyebrow`)
- with Search and Inbox as siblings, always-expanded capability navigation via one `SidebarNavRow` carrying the
+ with full-width Search and Inbox rows below it, a capability navigation group that is expanded by default and can be
+ collapsed, with each entry rendered by one `SidebarNavRow` carrying the
three source states on tokens, real project/session tree or true empty state, Apps/Settings footer, version and
live service badge. Nav-state tokens (`--nav-selected-bg`/`-border`, `--nav-hover-bg`, `--sidebar-background`,
`--logo-well-background`, `--illustration-card-border`, `--desktop-overlay-shadow`) and the
@@ -270,6 +385,48 @@ by label so it fails on the history, not on the element type. Unit scope adds th
root and holds internal back destinations to links. Re-validated: the six browser cases on the built app, the five
affected unit files (91), the browser suite's `typecheck`, `lint` on the changed files, and `build`.
+## Review round 3 repair — queue snapshot commit ordering
+
+One finding exposed a race between overlapping authoritative queue reads. A
+post-send refresh could start before a newly queued row was inserted, while a
+later `queue.updated` refresh started after it; if the later snapshot resolved
+first, the older response could still pass the send-now predicate and overwrite
+the visible queue, hiding the new row and its Recall/Remove controls.
+
+The existing session and send-now ownership guards remain unchanged. The peer
+repair at `7450fd669` made the shared `refreshQueue` path assign every read a
+monotonic generation and commit a successful response only when it is not older
+than the latest committed read. This continuation puts the bootstrap queue
+snapshot through that same issued/committed sequence, so initial and
+authorization bootstrap cannot overwrite a newer ordinary refresh. Failed reads
+still do not advance the committed generation, preserving a valid older
+successful fallback. This is a read-ordering repair, not a queue ownership or
+server-claim change.
+
+`ChatPage.hydration.test.tsx` covers the peer reverse-resolution case, both
+bootstrap/refresh directions through the real `ChatPage` consumer, and the
+newer-read failure fallback; the queue row consumer remains covered by its
+existing tests. The continuation candidate passed 97 focused tests (hydration
+and queue-row consumers), UI test typechecks, the UI lint baseline, and the
+production build. Before the later fixture correction, the existing project-order
+suite also passed once with `retries: 0` (16 passed, 2 declared skips); at that
+earlier checkpoint no drag source or test had changed.
+
+The remaining CI failure in the expanded desktop drag case was then reproduced
+on the synthetic merge with the same product and fixture source. At the default
+`1280x720` viewport, expanding project 0 makes the next header's center land at
+`y=722`, outside the viewport; pointer-held sidebar auto-scroll moves rows under
+that fixed destination. Controlled holds produced final project-0 indices 2, 5,
+7, and 7. The same coordinates at `1280x1000`, where the list has no overflow,
+produced the intended index 1 in all four holds. This is a test geometry and
+auto-scroll timing issue, not evidence of a product drag defect; manual dragging
+also behaved normally. The existing desktop case now keeps its device width,
+uses height 1000, and asserts the destination header is fully inside the visible
+tree and viewport before pickup. Mobile behavior and the exact index/session
+assertions remain unchanged. The complete project-order suite passed once after
+this correction with `retries: 0`: 16 passed and 2 declared skips. No product
+drag source or unrelated browser test changed.
+
## Producer integration — what the end-to-end run found
Wiring the merged producer into the home was one function body, as planned. Driving it end to end was not, and
diff --git a/ui/e2e/project-order/order.spec.ts b/ui/e2e/project-order/order.spec.ts
index e87b4f75c..7809a0a5a 100644
--- a/ui/e2e/project-order/order.spec.ts
+++ b/ui/e2e/project-order/order.spec.ts
@@ -113,10 +113,22 @@ test('keyboard movement and cancellation use the existing header', async ({ page
});
test('an expanded project carries its sessions through a drag', async ({ page, isMobile }) => {
+ if (!isMobile) {
+ // Keep this desktop case about reordering an expanded project, rather than
+ // testing the sidebar's auto-scroll behavior while the pointer is outside
+ // the viewport. Preserve the device width so the responsive layout stays
+ // the same as the normal Desktop Chrome project.
+ const viewport = page.viewportSize();
+ await page.setViewportSize({ width: viewport?.width ?? 1280, height: 1000 });
+ }
await header(page, 0).click();
await expect(rows(page).first().getByText('Conversation 1', { exact: true })).toBeVisible();
const source = (await header(page, 0).boundingBox())!;
const target = (await header(page, 1).boundingBox())!;
+ const treeBox = (await tree(page).boundingBox())!;
+ expect(target.y).toBeGreaterThanOrEqual(treeBox.y);
+ expect(target.y + target.height).toBeLessThanOrEqual(treeBox.y + treeBox.height);
+ expect(target.y + target.height).toBeLessThanOrEqual(page.viewportSize()!.height);
const x = source.x + source.width / 2;
const y = source.y + source.height / 2;
const dest = target.y + target.height / 2;
diff --git a/ui/e2e/workbench-general/geometry.spec.ts b/ui/e2e/workbench-general/geometry.spec.ts
index 5b7964fd5..ceabc24f5 100644
--- a/ui/e2e/workbench-general/geometry.spec.ts
+++ b/ui/e2e/workbench-general/geometry.spec.ts
@@ -22,9 +22,9 @@ const APPEARANCE_CARD = 'section.bg-surface-2:has([role="radiogroup"])';
const WORKSPACE_CHIP = 'Workspace: /Users/max/工作区/中文项目';
const MOBILE_NAV = 'nav.fixed.bottom-0';
const ULTRA = { width: 1920, height: 1000 };
-// A phone one iPhone-generation shorter. The composer has to clear the tab bar
-// because of where it is anchored, not because 844 happens to leave room.
-const NARROW_SHORT = { width: 390, height: 667 };
+// A short phone that still requires scrolling after the composer spacing was
+// tightened. The composer must clear the tab bar even when the home cannot fit.
+const NARROW_SHORT = { width: 390, height: 568 };
const MODEL_HUB_AGENT = {
backend: 'codex',
@@ -251,7 +251,7 @@ test.describe('workbench home geometry', () => {
// Continue the typed draft on the existing short phone. Here overflow
// must be real: the controls clear the bar even in a crowded layout.
await page.setViewportSize(NARROW_SHORT);
- await page.waitForFunction(() => window.innerHeight === 667);
+ await page.waitForFunction((height) => window.innerHeight === height, NARROW_SHORT.height);
const overflow = await page.locator(SHELL_SCROLL).evaluate((node) => ({
top: node.scrollTop,
hidden: node.scrollHeight - node.clientHeight,
diff --git a/ui/e2e/workbench-general/sidebar-capabilities.spec.ts b/ui/e2e/workbench-general/sidebar-capabilities.spec.ts
new file mode 100644
index 000000000..8f36a4dd0
--- /dev/null
+++ b/ui/e2e/workbench-general/sidebar-capabilities.spec.ts
@@ -0,0 +1,43 @@
+import { expect, test } from '@playwright/test';
+
+import { DESKTOP, open, serveProduct } from './support';
+
+for (const copy of [
+ { lang: 'en', capabilities: 'Capabilities', search: 'Search', inbox: 'Inbox', close: 'Close Settings' },
+ { lang: 'zh', capabilities: '能力', search: '搜索', inbox: '收件箱', close: '关闭设置' },
+] as const) {
+ test(`capability navigation survives retained Settings (${copy.lang})`, async ({ page }, info) => {
+ const denied = await serveProduct(page, copy.lang);
+ await page.setViewportSize(DESKTOP);
+ await open(page, '/', { lang: copy.lang });
+
+ const sidebar = page.locator('aside.fixed');
+ const toggle = sidebar.getByRole('button', { name: copy.capabilities, exact: true });
+ const destinations = sidebar.locator('#workbench-capability-nav a');
+ await expect(sidebar.getByText('Agent OS', { exact: true })).toBeVisible();
+ await expect(toggle).toHaveAttribute('aria-expanded', 'true');
+ await expect(destinations).toHaveCount(4);
+
+ await toggle.click();
+ await expect(toggle).toHaveAttribute('aria-expanded', 'false');
+ await expect(destinations).toHaveCount(0);
+ await expect(sidebar.getByRole('button', { name: copy.search, exact: true })).toBeVisible();
+ await expect(sidebar.getByRole('link', { name: copy.inbox, exact: true })).toBeVisible();
+
+ await sidebar.locator('[data-settings-toggle="true"]').click();
+ const settings = page.locator('[data-settings-overlay="true"]');
+ await expect(settings).toBeVisible();
+ await expect(toggle).toBeHidden();
+ await settings.getByRole('button', { name: copy.close, exact: true }).click();
+ await expect(toggle).toBeVisible();
+ await expect(toggle).toHaveAttribute('aria-expanded', 'false');
+
+ // The native toggle retains keyboard behavior after the shell reactivates.
+ await toggle.focus();
+ await page.keyboard.press('Enter');
+ await expect(toggle).toHaveAttribute('aria-expanded', 'true');
+ await expect(destinations).toHaveCount(4);
+ await page.screenshot({ path: info.outputPath('sidebar-expanded.png') });
+ expect(denied).toEqual([]);
+ });
+}
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsx
index 05d111c1c..707720741 100644
--- a/ui/src/components/AppShell.tsx
+++ b/ui/src/components/AppShell.tsx
@@ -369,7 +369,7 @@ export const AppShell: React.FC = () => {
<ConfigRecoveryNotice config={config} />
{/* Windows cover the sidebar (z-10 < z-20). AppsLauncher portals its button and Dock
above the window layer so app switching remains reachable even when maximized. */}
- {/* Sidebar Y1TiVV — 248 wide by default, 20/16 padding, top group and bottom
+ {/* Sidebar Y1TiVV — 248 wide by default, 16px padding, top group and bottom
cluster pushed apart. The brand row, navigation and projects are one unit
inside WorkbenchSidebar; this frame owns only the column and the bottom.
The width is SidebarResizer's --app-sidebar-w, shared with Workbench
@@ -395,7 +395,7 @@ export const AppShell: React.FC = () => {
then version on the left and the live service status on the right.
AppsLauncher keeps its layout slot here while its interactive surface
floats above app windows. */}
- <div className="relative flex shrink-0 flex-col gap-2.5">
+ <div className="relative flex shrink-0 flex-col gap-2">
<div className="flex h-[39px] items-stretch gap-2">
{canUseApps && (
<RouteSurfaceActivityBoundary active={!settingsOpen}>
diff --git a/ui/src/components/workbench/ChatPage.hydration.test.tsx b/ui/src/components/workbench/ChatPage.hydration.test.tsx
index 5655fb235..662f39915 100644
--- a/ui/src/components/workbench/ChatPage.hydration.test.tsx
+++ b/ui/src/components/workbench/ChatPage.hydration.test.tsx
@@ -34,6 +34,7 @@ const mocks = vi.hoisted(() => ({
onMessageNew: (message: ReturnType<typeof projectedMessage>) => void;
onTurnStart: (data: { session_id: string }) => void;
onTurnEnd: (data: { session_id: string }) => void;
+ onQueueUpdated: (data: { session_id: string }) => void;
},
composer: null as ComposerProps | null,
authorizationCapabilities: {
@@ -183,6 +184,11 @@ const projectedMessage = (id: string, text: string) => ({
read_at: null,
});
+const queuedMessage = (id: string, text: string) => ({
+ ...projectedMessage(id, text),
+ type: 'queued' as const,
+});
+
const SessionSwitcher = ({ sessionId = 'session-running', label = 'switch chat', search = '' }: {
sessionId?: string;
label?: string;
@@ -409,6 +415,125 @@ describe('ChatPage transcript hydration', () => {
expect(screen.queryByText(projected.text)).toBeNull();
});
+ it('does not let an older queue refresh overwrite a newer queue snapshot', async () => {
+ const staleRefresh = deferred<{ queued: ReturnType<typeof queuedMessage>[] }>();
+ const currentRefresh = deferred<{ queued: ReturnType<typeof queuedMessage>[] }>();
+ const stale = queuedMessage('queued-stale', 'stale queued row');
+ const current = queuedMessage('queued-current', 'new queued row');
+ mocks.api.getSession.mockResolvedValue({ id: 'session-new' });
+ mocks.api.getSessionBootstrap.mockResolvedValue(bootstrapPayload('session-new'));
+ mocks.api.listSessionQueue
+ .mockReset()
+ .mockReturnValueOnce(staleRefresh.promise)
+ .mockReturnValueOnce(currentRefresh.promise);
+
+ render(
+ <MemoryRouter initialEntries={['/chat/session-new']}>
+ <Routes>
+ <Route path="/chat/:sessionId" element={<ChatPage />} />
+ </Routes>
+ </MemoryRouter>,
+ );
+
+ await waitFor(() => expect(mocks.events).not.toBeNull());
+ act(() => {
+ mocks.events?.onQueueUpdated({ session_id: 'session-new' });
+ mocks.events?.onQueueUpdated({ session_id: 'session-new' });
+ });
+ await waitFor(() => expect(mocks.api.listSessionQueue).toHaveBeenCalledTimes(2));
+
+ await act(async () => currentRefresh.resolve({ queued: [current] }));
+ await waitFor(() => expect(screen.getByText(current.text)).toBeTruthy());
+
+ await act(async () => staleRefresh.resolve({ queued: [stale] }));
+ expect(screen.getByText(current.text)).toBeTruthy();
+ expect(screen.queryByText(stale.text)).toBeNull();
+ });
+
+ it('does not let delayed bootstrap erase a newer queue refresh', async () => {
+ const delayedBootstrap = deferred<ReturnType<typeof bootstrapPayload>>();
+ const current = queuedMessage('bootstrap-current', 'current queued row');
+ mocks.api.getSession.mockResolvedValue({ id: 'session-new' });
+ mocks.api.getSessionBootstrap.mockReset().mockReturnValue(delayedBootstrap.promise);
+ mocks.api.listSessionQueue.mockReset().mockResolvedValue({ queued: [current] });
+
+ render(
+ <MemoryRouter initialEntries={['/chat/session-new']}>
+ <Routes>
+ <Route path="/chat/:sessionId" element={<ChatPage />} />
+ </Routes>
+ </MemoryRouter>,
+ );
+
+ await waitFor(() => expect(mocks.api.getSessionBootstrap).toHaveBeenCalledTimes(1));
+ await act(async () => mocks.events?.onQueueUpdated({ session_id: 'session-new' }));
+ expect(mocks.api.listSessionQueue).toHaveBeenCalledTimes(1);
+
+ await act(async () => delayedBootstrap.resolve(bootstrapPayload('session-new')));
+ expect(screen.getByText(current.text)).toBeTruthy();
+ });
+
+ it('does not let an older queue refresh erase a newer bootstrap snapshot', async () => {
+ const staleRefresh = deferred<{ queued: ReturnType<typeof queuedMessage>[] }>();
+ const current = queuedMessage('bootstrap-current', 'current bootstrap row');
+ mocks.api.getSession.mockResolvedValue({ id: 'session-new' });
+ mocks.api.getSessionBootstrap.mockResolvedValue(bootstrapPayload('session-new'));
+ mocks.api.listSessionQueue.mockReset().mockReturnValue(staleRefresh.promise);
+
+ render(
+ <MemoryRouter initialEntries={['/chat/session-new']}>
+ <Routes>
+ <Route path="/chat/:sessionId" element={<ChatPage />} />
+ </Routes>
+ </MemoryRouter>,
+ );
+
+ await waitFor(() => expect(screen.queryByText('common.loading')).toBeNull());
+ act(() => mocks.events?.onQueueUpdated({ session_id: 'session-new' }));
+ await waitFor(() => expect(mocks.api.listSessionQueue).toHaveBeenCalledTimes(1));
+
+ mocks.api.getSessionBootstrap.mockResolvedValue({
+ ...bootstrapPayload('session-new'),
+ queued: [current],
+ });
+ act(() => mocks.events?.onAuthorizationChanged({ resource_kinds: [] }));
+ await waitFor(() => expect(screen.getByText(current.text)).toBeTruthy());
+
+ await act(async () => staleRefresh.resolve({ queued: [] }));
+ expect(screen.getByText(current.text)).toBeTruthy();
+ });
+
+ it('keeps an older successful queue read after a newer read fails', async () => {
+ const olderRead = deferred<{ queued: ReturnType<typeof queuedMessage>[] }>();
+ const newerRead = deferred<{ queued: ReturnType<typeof queuedMessage>[] }>();
+ const current = queuedMessage('queue-fallback', 'fallback queued row');
+ mocks.api.getSession.mockResolvedValue({ id: 'session-new' });
+ mocks.api.getSessionBootstrap.mockResolvedValue(bootstrapPayload('session-new'));
+ mocks.api.listSessionQueue
+ .mockReset()
+ .mockReturnValueOnce(olderRead.promise)
+ .mockReturnValueOnce(newerRead.promise);
+
+ render(
+ <MemoryRouter initialEntries={['/chat/session-new']}>
+ <Routes>
+ <Route path="/chat/:sessionId" element={<ChatPage />} />
+ </Routes>
+ </MemoryRouter>,
+ );
+
+ await waitFor(() => expect(mocks.events).not.toBeNull());
+ act(() => {
+ mocks.events?.onQueueUpdated({ session_id: 'session-new' });
+ mocks.events?.onQueueUpdated({ session_id: 'session-new' });
+ });
+ await waitFor(() => expect(mocks.api.listSessionQueue).toHaveBeenCalledTimes(2));
+
+ await act(async () => newerRead.reject(new Error('newer queue read failed')));
+ await act(async () => olderRead.resolve({ queued: [current] }));
+ expect(screen.getByText(current.text)).toBeTruthy();
+ });
+
it.each([
{ kind: 'detached', type: 'result', metadata: { detached: true, activity_id: 'background-1' } },
{
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index b8434ccf1..9161874dd 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -880,6 +880,32 @@ export const ChatPage: React.FC = () => {
// Send-while-busy queue (messages sent while a turn runs, shown above the
// composer) + the loaded draft to seed the composer with.
const [queue, setQueue] = useState<WorkbenchMessage[]>([]);
+ const [sendingQueueNow, setSendingQueueNow] = useState(false);
+ // Each send-now invocation owns its completion state. A request can survive
+ // navigation away and back to the same session, so the session id alone is
+ // not enough to keep an older request from clearing a newer spinner.
+ const queueSendGenerationRef = useRef(0);
+ // Queue reads can overlap independently of send-now (for example, a
+ // queue.updated event can start a newer read while the post-send refresh is
+ // still in flight). Only a read that is not older than the latest committed
+ // read may replace the visible queue, so an older response cannot resurrect
+ // rows that a newer snapshot already observed as gone or hide newly queued
+ // rows.
+ const queueReadGenerationRef = useRef(0);
+ const committedQueueReadGenerationRef = useRef(0);
+ const beginQueueSnapshotRead = useCallback((requestSessionId: string) => {
+ const generation = ++queueReadGenerationRef.current;
+ return () => {
+ if (
+ requestSessionId !== sessionIdRef.current
+ || generation < committedQueueReadGenerationRef.current
+ ) {
+ return false;
+ }
+ committedQueueReadGenerationRef.current = generation;
+ return true;
+ };
+ }, []);
const [initialDraft, setInitialDraft] = useState<string | null>(null);
const draftTimerRef = useRef<number | null>(null);
// The debounced draft save still owed to the server, tagged with the session
@@ -1254,16 +1280,19 @@ export const ChatPage: React.FC = () => {
// The send-while-busy queue (pending messages shown above the composer).
// Re-fetched on mount + on every ``queue.updated`` (enqueue / flush / remove).
- const refreshQueue = useCallback(async () => {
+ const refreshQueue = useCallback(async (isCurrentRequest?: () => boolean) => {
if (!sessionId) return;
+ const claimQueueSnapshot = beginQueueSnapshotRead(sessionId);
try {
const res = await api.listSessionQueue(sessionId, { cache: false });
+ if (isCurrentRequest && !isCurrentRequest()) return;
if (sessionId !== sessionIdRef.current) return; // switched chats mid-fetch
+ if (!claimQueueSnapshot()) return;
setQueue(res.queued ?? []);
} catch {
/* leave the last-known queue; the next queue.updated refetches */
}
- }, [api, sessionId]);
+ }, [api, beginQueueSnapshotRead, sessionId]);
// Returns false only when the fetch itself failed, so the transcript scroller can
// re-arm and let a later scroll retry; true for success / no-op / stale session.
@@ -1456,6 +1485,7 @@ export const ChatPage: React.FC = () => {
// payload so remote links don't pay a tunnel round-trip per widget.
const bootstrapIsCurrent = await sessionRowRefreshGateRef.current.begin();
const epochAtRequest = turnEpochRef.current;
+ const claimQueueSnapshot = beginQueueSnapshotRead(sessionId);
const bootstrap = await api.getSessionBootstrap(sessionId);
// Drop a response if the user switched chats or a newer bootstrap for
// this route began while it was in flight.
@@ -1513,7 +1543,7 @@ export const ChatPage: React.FC = () => {
}
setHydratedTranscriptSessionId(sessionId);
setFailedBootstrapSessionId(null);
- setQueue(bootstrap.queued ?? []);
+ if (claimQueueSnapshot()) setQueue(bootstrap.queued ?? []);
setInitialDraft(bootstrap.draft?.text ?? '');
// Restore Stop for a turn that is still running (e.g. opened in another tab
// or reloaded mid-turn). markWorking on the live branch so a racing
@@ -1553,7 +1583,7 @@ export const ChatPage: React.FC = () => {
// of its own loading state into a premature not-found / error view.
if (requestIsCurrent()) setLoading(false);
}
- }, [api, sessionId, markWorking, scheduleActivityRefresh, refreshSessionRow, beginTranscriptSnapshotRead, installServerSession]);
+ }, [api, sessionId, markWorking, scheduleActivityRefresh, refreshSessionRow, beginTranscriptSnapshotRead, beginQueueSnapshotRead, installServerSession]);
// Clear per-session state the instant the session changes (React Router swaps
// only :sessionId, reusing this instance), before the new session's
@@ -1599,6 +1629,7 @@ export const ChatPage: React.FC = () => {
setWorking(false);
setRuntimeState(emptyRuntimeState());
setQueue([]);
+ setSendingQueueNow(false);
setInitialDraft(sessionId ? api.getCachedSessionDraft(sessionId) : null);
// Clear all Agent Activity state so the previous session's groups / live buffer
// never leak into the new chat (refresh re-reads the toggle + summary).
@@ -2296,15 +2327,24 @@ export const ChatPage: React.FC = () => {
const sendQueueNow = useCallback(async () => {
// "立即发送": interrupt the running turn + flush the queue now. The queue
// flushes as one merged turn, so this runs the whole queue.
- if (!sessionId || queue.length === 0) return;
+ const sid = sessionId;
+ if (!sid || queue.length === 0 || sendingQueueNow) return;
+ const requestGeneration = ++queueSendGenerationRef.current;
+ const isCurrentRequest = () =>
+ requestGeneration === queueSendGenerationRef.current && sid === sessionIdRef.current;
+ // Give the click an immediate visual response while the request interrupts
+ // the current turn. The queue stays visible until admission succeeds so a
+ // failed or ambiguous request never hides work the user may need to retry.
+ setSendingQueueNow(true);
// A turn is about to run (the flushed queue) — reflect it immediately so
// Stop stays available even if the controller's turn.start is missed/delayed
// (especially for the idle-flush case that starts a fresh turn) (Codex P2).
markWorking();
try {
- const res = await api.sendQueuedNow(sessionId, queue[0].id);
- // Drop the response if the user switched chats mid-request (Codex P2).
- if (sessionId !== sessionIdRef.current) return;
+ const res = await api.sendQueuedNow(sid, queue[0].id);
+ // Drop every effect from a request that lost ownership while it was in
+ // flight, including responses that arrive after a newer send starts.
+ if (!isCurrentRequest()) return;
if (res && res.ok === false) {
// stop_failed: the controller left the ORIGINAL turn running and the
// queue intact — keep Stop visible so the user can still interrupt it
@@ -2315,17 +2355,26 @@ export const ChatPage: React.FC = () => {
// Nothing was actually flushed (a stale queue item already gone) — no
// turn is starting, so drop the optimistic working state + resync.
setWorking(false);
- void refreshQueue();
+ } else {
+ // A successful admission may only claim the compatible prefix (for
+ // example, attachment rows can remain queued behind an active turn).
+ // Re-read the authoritative queue instead of assuming the whole visible
+ // batch was flushed.
}
+ await refreshQueue(isCurrentRequest);
} catch (err) {
- // Same session guard as the success path: a rejection after a chat switch
- // must not clear the new chat's working / stamp this error on it (Codex P2).
- if (sessionId === sessionIdRef.current) {
+ // The same ownership guard applies to failures: an older request must not
+ // clear the new chat's working state or surface a stale error.
+ if (isCurrentRequest()) {
setWorking(false);
setError(errorMessage(err) ?? String(err));
}
+ } finally {
+ if (isCurrentRequest()) {
+ setSendingQueueNow(false);
+ }
}
- }, [api, sessionId, queue, t, refreshQueue, markWorking]);
+ }, [api, sessionId, queue, sendingQueueNow, t, refreshQueue, markWorking]);
useEffect(() => {
refresh();
@@ -2939,7 +2988,13 @@ export const ChatPage: React.FC = () => {
holding pre-archive rows, and every button here writes: Send now POSTs
the flush, Recall appends into the disabled composer. */}
{writable && (
- <QueueStrip queue={queue} onRemove={removeQueued} onRecall={recallQueued} onSendNow={sendQueueNow} />
+ <QueueStrip
+ queue={queue}
+ onRemove={removeQueued}
+ onRecall={recallQueued}
+ onSendNow={sendQueueNow}
+ sendingNow={sendingQueueNow}
+ />
)}
{sessionId && !readOnly && capabilities.can_use_vault_secrets && pendingApprovals.length > 0 ? (
<VaultApprovalFloat offscreen={offscreenApprovals} pending={pendingApprovals} onResolved={refreshVaultRequests} />
@@ -3354,7 +3409,8 @@ export const QueueStrip: React.FC<{
onRemove: (id: string) => void;
onRecall: (item: WorkbenchMessage) => void;
onSendNow: () => void;
-}> = ({ queue, onRemove, onRecall, onSendNow }) => {
+ sendingNow?: boolean;
+}> = ({ queue, onRemove, onRecall, onSendNow, sendingNow = false }) => {
const { t } = useTranslation();
if (queue.length === 0) return null;
const retryRequired = queue.some((item) => item.requires_explicit_retry === true);
@@ -3366,8 +3422,23 @@ export const QueueStrip: React.FC<{
<Clock className="size-3" />
{t(retryRequired ? 'chat.queue.retryRequired' : 'chat.queue.title', { count: queue.length })}
</span>
- <Button type="button" variant="ghost" size="sm" onClick={onSendNow} className="h-6 px-2 text-[11px] text-cyan-ink">
- {t('chat.queue.sendNow')}
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ onClick={onSendNow}
+ disabled={sendingNow}
+ aria-busy={sendingNow}
+ className="h-6 min-w-[60px] justify-center px-2 text-[11px] text-cyan-ink"
+ >
+ {sendingNow ? (
+ <>
+ <Loader2 className="size-3.5 animate-spin" aria-hidden="true" />
+ {t('chat.queue.sendingNow')}
+ </>
+ ) : (
+ t('chat.queue.sendNow')
+ )}
</Button>
</div>
{retryRequired && <p className="px-1 pb-1.5 text-[11px] text-muted">{t('chat.queue.retryHint')}</p>}
diff --git a/ui/src/components/workbench/ChatQueueRow.test.tsx b/ui/src/components/workbench/ChatQueueRow.test.tsx
index 42de12aae..034e26208 100644
--- a/ui/src/components/workbench/ChatQueueRow.test.tsx
+++ b/ui/src/components/workbench/ChatQueueRow.test.tsx
@@ -148,6 +148,25 @@ describe('QueueStrip — compatible queued messages read as one batch', () => {
expect(screen.getByText('Queued · 1')).toBeTruthy();
});
+ it('gives immediate feedback and blocks duplicate sends while flushing', () => {
+ render(
+ <I18nextProvider i18n={i18n}>
+ <QueueStrip
+ queue={[queued()]}
+ onRemove={vi.fn()}
+ onRecall={vi.fn()}
+ onSendNow={vi.fn()}
+ sendingNow
+ />
+ </I18nextProvider>,
+ );
+
+ const button = screen.getByRole('button', { name: 'Sending…' });
+ expect((button as HTMLButtonElement).disabled).toBe(true);
+ expect(button.getAttribute('aria-busy')).toBe('true');
+ expect(button.querySelector('svg')).toBeTruthy();
+ });
+
it('uses one shared bubble and reveals each original row boundary on hover or focus', () => {
const html = wrap(
<QueueStrip
diff --git a/ui/src/components/workbench/Composer.tsx b/ui/src/components/workbench/Composer.tsx
index 64861f540..521d8d01a 100644
--- a/ui/src/components/workbench/Composer.tsx
+++ b/ui/src/components/workbench/Composer.tsx
@@ -1694,11 +1694,32 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function Compo
</>
);
- // Send / Stop / Queue / Discard — one cluster, so the two-row layout can put it
- // at the end of the action row without either box owning a second copy.
+ // Send / Stop / Queue controls stay at the trailing edge of the action row.
+ // Voice discard is rendered separately so the destructive action can stay at
+ // the opposite edge from the primary voice control in the two-row layout.
//
// A running agent turn keeps its Stop escape hatch even during voice capture.
// Queue/Send withdraw while capture owns the draft.
+ const voiceDiscardControl = voiceDiscardAvailable && (
+ <Button
+ type="button"
+ variant="destructive-soft"
+ size="icon"
+ onClick={() => {
+ if (recording) abortRecording();
+ else if (voiceRetainedSession) discardVoiceSession(voiceRetainedSession);
+ }}
+ aria-label={t(
+ recording
+ ? 'chat.compose.cancelRecording'
+ : 'chat.compose.voiceDiscard',
+ )}
+ className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}
+ >
+ <Trash2 className="size-4" />
+ </Button>
+ );
+
const sendControls = (
<>
{busyControls ? (
@@ -1752,29 +1773,6 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function Compo
<Send className="size-4" />
</Button>
) : null}
- {/* Destructive voice actions stay at the opposite edge from the primary
- voice slot. Finish is never adjacent to Trash; once a failed or
- recovered recording is retained, Send remains available before the
- rightmost Trash action. */}
- {voiceDiscardAvailable && (
- <Button
- type="button"
- variant="destructive-soft"
- size="icon"
- onClick={() => {
- if (recording) abortRecording();
- else if (voiceRetainedSession) discardVoiceSession(voiceRetainedSession);
- }}
- aria-label={t(
- recording
- ? 'chat.compose.cancelRecording'
- : 'chat.compose.voiceDiscard',
- )}
- className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}
- >
- <Trash2 className="size-4" />
- </Button>
- )}
</>
);
@@ -1839,14 +1837,17 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function Compo
{actions ? (
/* Two-row box (design TfqkD): the input on top, then an action row
carrying the caller's pickers on the left and Send on the right. */
- <div className="flex w-full flex-col gap-[22px] rounded-2xl border border-border-strong bg-surface-2 p-[18px] shadow-[0_-4px_24px_-12px_rgba(0,0,0,0.5)]">
+ <div className="flex w-full flex-col gap-3 rounded-2xl border border-border-strong bg-surface-2 p-3 shadow-[0_-4px_24px_-12px_rgba(0,0,0,0.5)]">
<div className="flex w-full items-end gap-1.5">{inputControl}</div>
<div className="flex w-full items-end justify-between gap-2">
<div className="flex min-w-0 flex-1 flex-wrap items-center gap-1">
- {mediaControls}
+ {voiceDiscardControl}
{actions}
</div>
- <div className="flex shrink-0 items-center gap-1.5">{sendControls}</div>
+ <div className="flex shrink-0 items-center gap-1.5">
+ {mediaControls}
+ {sendControls}
+ </div>
</div>
</div>
) : (
@@ -1859,6 +1860,7 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function Compo
{mediaControls}
{inputControl}
{sendControls}
+ {voiceDiscardControl}
</div>
)}
</div>
diff --git a/ui/src/components/workbench/WorkbenchSidebar.inbox.test.tsx b/ui/src/components/workbench/WorkbenchSidebar.inbox.test.tsx
index ce36d4690..3445e9148 100644
--- a/ui/src/components/workbench/WorkbenchSidebar.inbox.test.tsx
+++ b/ui/src/components/workbench/WorkbenchSidebar.inbox.test.tsx
@@ -1,11 +1,13 @@
/* @vitest-environment jsdom */
import { createInstance } from 'i18next';
-import { cleanup, fireEvent, render, screen } from '@testing-library/react';
+import { cleanup, render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
import { I18nextProvider, initReactI18next } from 'react-i18next';
import { MemoryRouter } from 'react-router-dom';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { RouteSurfaceActivityBoundary } from '../RouteSurfaceActivityBoundary';
+import { tabModifierLabel } from '../../apps/appLaunch';
const inbox = vi.hoisted(() => ({
totalUnread: 0,
@@ -14,20 +16,17 @@ const inbox = vi.hoisted(() => ({
unreadBySession: {} as Record<string, number>,
markRead: vi.fn(),
}));
-const auth = vi.hoisted(() => ({
- capabilities: {
- can_chat: true,
- can_manage_projects: true,
- can_use_files: true,
- can_use_agents: true,
- can_use_skills: true,
- can_use_vault_secrets: true,
- } as Record<string, boolean>,
-}));
const hookCalls = vi.hoisted(() => ({
inbox: vi.fn(),
tree: vi.fn(),
}));
+const capabilities = vi.hoisted(() => ({
+ can_chat: true,
+ can_manage_projects: true,
+ can_use_agents: true,
+ can_use_skills: true,
+ can_use_vault_secrets: true,
+}));
vi.mock('../../context/WorkbenchInboxContext', () => ({
useWorkbenchInbox: (options?: { feed?: boolean }) => {
@@ -36,7 +35,7 @@ vi.mock('../../context/WorkbenchInboxContext', () => ({
},
}));
vi.mock('../../context/InstanceAuthorizationContext', () => ({
- useInstanceAuthorization: () => auth,
+ useInstanceAuthorization: () => ({ capabilities }),
}));
vi.mock('../../context/WorkbenchProjectsContext', () => ({
useWorkbenchProjectsTree: (options?: { active?: boolean }) => {
@@ -74,40 +73,33 @@ void i18n.use(initReactI18next).init({
interpolation: { escapeValue: false },
});
-const renderSidebar = (
- { active = true, onOpenSearch }: { active?: boolean; onOpenSearch?: () => void } = {},
-) => render(
+const sidebarElement = (active = true, onOpenSearch?: () => void) => (
<I18nextProvider i18n={i18n}>
<MemoryRouter initialEntries={['/']}>
<RouteSurfaceActivityBoundary active={active}>
<WorkbenchSidebar onOpenSearch={onOpenSearch} />
</RouteSurfaceActivityBoundary>
</MemoryRouter>
- </I18nextProvider>,
+ </I18nextProvider>
);
+const renderSidebar = (active = true, onOpenSearch?: () => void) => render(sidebarElement(active, onOpenSearch));
const inboxIcon = () => screen.getByRole('link', { name: en.workbench.nav.inbox }).querySelector('svg')!;
-const capabilityToggle = () => screen.getByRole('button', { name: en.nav.capabilities });
-const capabilityHrefs = () =>
- [en.workbench.nav.agents, en.workbench.nav.skills, en.workbench.nav.harness, en.workbench.nav.vaults]
- .map((name) => screen.queryByRole('link', { name })?.getAttribute('href') ?? null);
beforeEach(() => {
inbox.totalUnread = 0;
inbox.unreadSessions = 0;
inbox.inboxSessions = [];
inbox.unreadBySession = {};
- auth.capabilities = {
+ hookCalls.inbox.mockClear();
+ hookCalls.tree.mockClear();
+ Object.assign(capabilities, {
can_chat: true,
can_manage_projects: true,
- can_use_files: true,
can_use_agents: true,
can_use_skills: true,
can_use_vault_secrets: true,
- };
- window.localStorage.clear();
- hookCalls.inbox.mockClear();
- hookCalls.tree.mockClear();
+ });
});
afterEach(() => {
@@ -122,8 +114,7 @@ describe('Workbench sidebar inbox counter', () => {
const link = screen.getByRole('link', { name: en.workbench.nav.inbox });
// A zero badge is still a badge — an empty inbox draws no attention at all.
expect(link.textContent).toBe(en.workbench.nav.inbox);
- // Cyan is the unread read; the resting row is plain foreground ink.
- expect(inboxIcon().getAttribute('class')).toContain('text-foreground');
+ expect(inboxIcon().getAttribute('class')).toContain('text-muted');
expect(inboxIcon().getAttribute('class')).not.toContain('text-cyan-ink');
});
@@ -144,99 +135,93 @@ describe('Workbench sidebar inbox counter', () => {
expect(screen.getByRole('link', { name: en.workbench.nav.inbox }).textContent).toBe(`${en.workbench.nav.inbox}99+`);
});
- it('withdraws feed and tree activation while the retained sidebar is hidden', () => {
- renderSidebar({ active: false });
-
- expect(hookCalls.inbox).toHaveBeenCalledWith({ feed: false });
- expect(hookCalls.tree).toHaveBeenCalledWith({ active: false });
- });
-});
-
-describe('Workbench sidebar capabilities section', () => {
- it('lists every capability row the authorization admits', () => {
+ it('shows the platform-appropriate search shortcut', () => {
renderSidebar();
- expect(capabilityHrefs()).toEqual(['/agents', '/skills', '/harness', '/vaults']);
+ expect(screen.getByText(`${tabModifierLabel()}K`)).toBeTruthy();
});
- it('leaves out a capability the authorization withholds', () => {
- auth.capabilities.can_use_skills = false;
- auth.capabilities.can_use_vault_secrets = false;
- renderSidebar();
+ it('withdraws feed and tree activation while the retained sidebar is hidden', () => {
+ renderSidebar(false);
- expect(capabilityHrefs()).toEqual(['/agents', null, '/harness', null]);
+ expect(hookCalls.inbox).toHaveBeenCalledWith({ feed: false });
+ expect(hookCalls.tree).toHaveBeenCalledWith({ active: false });
});
+});
- it('drops the whole section when no capability is admitted', () => {
- auth.capabilities.can_chat = false;
- auth.capabilities.can_use_agents = false;
- auth.capabilities.can_use_skills = false;
- auth.capabilities.can_use_vault_secrets = false;
- renderSidebar();
-
- expect(screen.queryByRole('button', { name: en.nav.capabilities })).toBeNull();
- expect(capabilityHrefs()).toEqual([null, null, null, null]);
+describe('Workbench sidebar capability navigation', () => {
+ it('can collapse and restore the capability links', async () => {
+ const user = userEvent.setup();
+ const onOpenSearch = vi.fn();
+ renderSidebar(true, onOpenSearch);
+ const destinations = [
+ en.workbench.nav.agents,
+ en.workbench.nav.skills,
+ en.workbench.nav.harness,
+ en.workbench.nav.vaults,
+ ];
+
+ const toggle = screen.getByRole('button', { name: en.nav.capabilities });
+ expect(toggle.getAttribute('aria-expanded')).toBe('true');
+ expect(screen.getByRole('link', { name: `${en.appShell.title} Agent OS` }).getAttribute('href')).toBe('/');
+ expect(screen.getByRole('navigation').id).toBe(toggle.getAttribute('aria-controls'));
+ for (const name of destinations) expect(screen.getByRole('link', { name })).toBeTruthy();
+
+ await user.click(toggle);
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
+ for (const name of destinations) expect(screen.queryByRole('link', { name })).toBeNull();
+ expect(screen.getByRole('link', { name: en.workbench.nav.inbox })).toBeTruthy();
+ expect(screen.getByText(en.workbench.projectsLabel)).toBeTruthy();
+ await user.click(screen.getByRole('button', { name: en.workbench.search.entry }));
+ expect(onOpenSearch).toHaveBeenCalledOnce();
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
+
+ await user.click(toggle);
+ expect(toggle.getAttribute('aria-expanded')).toBe('true');
+ for (const name of destinations) expect(screen.getByRole('link', { name })).toBeTruthy();
});
- it('collapses on demand and remembers the choice across a remount', () => {
- renderSidebar();
- expect(capabilityToggle().getAttribute('aria-expanded')).toBe('true');
-
- fireEvent.click(capabilityToggle());
+ it('preserves collapsed navigation across Settings suspension and reactivation', async () => {
+ const user = userEvent.setup();
+ const { rerender } = renderSidebar();
+ await user.click(screen.getByRole('button', { name: en.nav.capabilities }));
- expect(capabilityToggle().getAttribute('aria-expanded')).toBe('false');
- expect(capabilityHrefs()).toEqual([null, null, null, null]);
- expect(window.localStorage.getItem('vibe-remote:caps-collapsed')).toBe('1');
+ rerender(sidebarElement(false));
+ expect(hookCalls.inbox).toHaveBeenLastCalledWith({ feed: false });
+ expect(hookCalls.tree).toHaveBeenLastCalledWith({ active: false });
- cleanup();
- renderSidebar();
-
- // The rows stay away after the remount, and expanding again writes the
- // choice back rather than merely dropping the key.
- expect(capabilityToggle().getAttribute('aria-expanded')).toBe('false');
- fireEvent.click(capabilityToggle());
- expect(capabilityHrefs()).toEqual(['/agents', '/skills', '/harness', '/vaults']);
- expect(window.localStorage.getItem('vibe-remote:caps-collapsed')).toBe('0');
+ rerender(sidebarElement(true));
+ expect(hookCalls.inbox).toHaveBeenLastCalledWith({ feed: true });
+ expect(hookCalls.tree).toHaveBeenLastCalledWith({ active: true });
+ expect(screen.getByRole('button', { name: en.nav.capabilities }).getAttribute('aria-expanded')).toBe('false');
+ expect(screen.queryByRole('link', { name: en.workbench.nav.agents })).toBeNull();
});
- it('stays expanded when local storage cannot be read', () => {
- const getItem = vi.spyOn(Storage.prototype, 'getItem').mockImplementation(() => {
- throw new Error('denied');
- });
- try {
- renderSidebar();
- expect(capabilityToggle().getAttribute('aria-expanded')).toBe('true');
- } finally {
- getItem.mockRestore();
- }
- });
-});
-
-describe('Workbench sidebar search entry', () => {
- it('sits in the Projects header immediately before the add-project button', () => {
+ it('only restores destinations permitted by the current authorization', async () => {
+ const user = userEvent.setup();
+ capabilities.can_chat = false;
+ capabilities.can_use_skills = false;
+ capabilities.can_use_vault_secrets = false;
renderSidebar();
- const search = screen.getByRole('button', { name: en.workbench.search.entry });
- const addProject = screen.getByRole('button', { name: en.workbench.addProject });
- expect(search.parentElement).toBe(addProject.parentElement);
- expect(search.nextElementSibling).toBe(addProject);
- });
-
- it('opens the palette through the callback the shell owns', () => {
- const onOpenSearch = vi.fn();
- renderSidebar({ onOpenSearch });
+ const toggle = screen.getByRole('button', { name: en.nav.capabilities });
+ await user.click(toggle);
+ await user.click(toggle);
- fireEvent.click(screen.getByRole('button', { name: en.workbench.search.entry }));
-
- expect(onOpenSearch).toHaveBeenCalledTimes(1);
+ expect(screen.getByRole('link', { name: en.workbench.nav.agents })).toBeTruthy();
+ expect(screen.queryByRole('link', { name: en.workbench.nav.skills })).toBeNull();
+ expect(screen.queryByRole('link', { name: en.workbench.nav.harness })).toBeNull();
+ expect(screen.queryByRole('link', { name: en.workbench.nav.vaults })).toBeNull();
});
- it('stays available to a member who cannot create projects', () => {
- auth.capabilities.can_manage_projects = false;
- auth.capabilities.can_use_files = false;
+ it('omits the capability group when no destinations are permitted', () => {
+ capabilities.can_chat = false;
+ capabilities.can_use_agents = false;
+ capabilities.can_use_skills = false;
+ capabilities.can_use_vault_secrets = false;
renderSidebar();
- expect(screen.getByRole('button', { name: en.workbench.search.entry })).toBeTruthy();
- expect(screen.queryByRole('button', { name: en.workbench.addProject })).toBeNull();
+ expect(screen.queryByRole('button', { name: en.nav.capabilities })).toBeNull();
+ expect(screen.queryByRole('navigation')).toBeNull();
});
});
diff --git a/ui/src/components/workbench/WorkbenchSidebar.tsx b/ui/src/components/workbench/WorkbenchSidebar.tsx
index c80fa2b96..2a2273ba2 100644
--- a/ui/src/components/workbench/WorkbenchSidebar.tsx
+++ b/ui/src/components/workbench/WorkbenchSidebar.tsx
@@ -29,6 +29,7 @@ import type { LucideIcon } from 'lucide-react';
import { useRouteSurfaceActive } from '../../lib/routeSurfaceActivity';
import { useLatestRef } from '../../lib/useLatestRef';
+import { tabModifierLabel } from '../../apps/appLaunch';
import { useWorkbenchInbox } from '../../context/WorkbenchInboxContext';
import { useWorkbenchProjectsActions, useWorkbenchProjectsTree } from '../../context/WorkbenchProjectsContext';
@@ -69,12 +70,9 @@ const CAPABILITY_NAV: CapabilityNavItem[] = [
{ to: '/vaults', i18nKey: 'workbench.nav.vaults', icon: KeyRound },
];
-const CAPS_COLLAPSED_KEY = 'vibe-remote:caps-collapsed';
-
-// One capability row, in the published v3.1.0 treatment: a 13px medium label
-// behind a 16px icon on a rounded-lg row, with mint reserved for the selected
-// state. The mint wash, hairline, and glow all resolve from theme tokens, so
-// Light and Dark each get their own value.
+// One navigation row (design m8K59, 216 x 40). Selected / hover / default are the
+// three states the approved source draws, each on its own token so Light and Dark
+// follow the table instead of a hard-coded neon.
const SidebarNavRow: React.FC<{
to: string;
end?: boolean;
@@ -86,10 +84,10 @@ const SidebarNavRow: React.FC<{
end={end}
className={({ isActive }) =>
clsx(
- 'group flex items-center gap-2.5 rounded-lg border px-3 py-2 text-[13px] font-medium transition-colors',
+ 'group flex h-10 items-center gap-2.5 rounded-xl border px-3 text-[13px] transition-colors',
isActive
- ? 'border-mint/30 bg-mint/[0.08] text-foreground shadow-glow-sm-mint'
- : 'border-transparent text-muted hover:bg-foreground/[0.04] hover:text-foreground',
+ ? 'border-[var(--nav-selected-border)] bg-[var(--nav-selected-bg)] font-semibold text-foreground shadow-[var(--shadow-glow-nav-mint)]'
+ : 'border-transparent font-medium text-muted hover:bg-[var(--nav-hover-bg)] hover:text-foreground',
)
}
>
@@ -97,7 +95,7 @@ const SidebarNavRow: React.FC<{
<>
<Icon
className={clsx(
- 'size-4 shrink-0',
+ 'size-[17px] shrink-0',
isActive ? 'text-mint-ink' : 'text-muted group-hover:text-foreground',
)}
/>
@@ -759,25 +757,7 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOp
const [popoverOpen, setPopoverOpen] = useState(false);
const closeTimer = useRef<number | null>(null);
const [showNewProject, setShowNewProject] = useState(false);
- // Capabilities section is collapsible to free room for Projects; the choice is
- // remembered (best-effort localStorage, same convention as the other toggles).
- const [capsCollapsed, setCapsCollapsed] = useState<boolean>(() => {
- try {
- return window.localStorage.getItem(CAPS_COLLAPSED_KEY) === '1';
- } catch {
- return false;
- }
- });
- const toggleCaps = () =>
- setCapsCollapsed((prev) => {
- const next = !prev;
- try {
- window.localStorage.setItem(CAPS_COLLAPSED_KEY, next ? '1' : '0');
- } catch {
- /* best-effort */
- }
- return next;
- });
+ const [capabilitiesOpen, setCapabilitiesOpen] = useState(true);
// 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
@@ -824,14 +804,13 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOp
}, [totalUnread]);
// Fill the sidebar column and cap its height so the project list (and only the
- // project list) scrolls; the brand row, Inbox and Capabilities stay pinned. The
- // Inbox hover popover stays OUT of any overflow box below, so it is never clipped.
+ // project list) scrolls; the brand row and navigation stay pinned. The Inbox
+ // hover popover stays OUT of any overflow box below, so it is never clipped.
return (
- <div className="flex min-h-0 flex-1 flex-col gap-2.5">
- {/* Brand row — the whole brand opens the new-conversation home. The mark
- keeps the published v3.1.0 chip treatment (32px, mint hairline over a
- mint wash, resting glow that strengthens on hover) inside this sidebar's
- own padding, so the adjustable width still governs the column. */}
+ <div className="flex min-h-0 flex-1 flex-col gap-4">
+ {/* Brand row tLDP1 — the whole brand opens the new-conversation home.
+ Search and Inbox live in full-width rows below it so the shell keeps one
+ clear reading order at every supported sidebar width. */}
<div className="flex shrink-0 items-center py-2">
<Link
to="/"
@@ -843,49 +822,52 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOp
src={logoImg}
alt=""
aria-hidden="true"
- className="size-8 shrink-0 rounded-lg border border-mint/35 bg-mint/[0.08] object-cover shadow-glow-sm-mint transition-shadow group-hover:shadow-glow-md-mint"
+ className="h-9 w-[38px] shrink-0 rounded-[7px] border border-mint/35 bg-[var(--logo-well-background)] object-cover transition-shadow group-hover:shadow-glow-sm-mint"
/>
<div className="min-w-0 leading-tight">
<div className="truncate text-[13px] font-semibold text-foreground">{t('appShell.title')}</div>
- <div className="truncate text-[11px] text-muted">{t('appShell.subtitle')}</div>
+ <div className="truncate text-[11px] text-muted">{t('workbench.eyebrow')}</div>
</div>
</Link>
</div>
+ <Button
+ type="button"
+ variant="ghost"
+ className="h-9 w-full justify-start rounded-lg px-2.5 text-[13px] text-muted hover:text-foreground"
+ aria-label={t('workbench.search.entry')}
+ onClick={onOpenSearch}
+ >
+ <Search className="size-[17px]" />
+ <span>{t('workbench.search.entry')}</span>
+ <kbd className="ml-auto rounded border border-border-strong px-1.5 py-0.5 font-mono text-[10px] font-medium text-muted">{tabModifierLabel()}K</kbd>
+ </Button>
+
{/* Inbox entry — hover opens the floating popover (portaled above the chat).
- Search is a compact icon in the Projects header below, so this row keeps
- the full width the published design gives it. At zero unread there is no
- badge node at all and the icon stays uncoloured; both reads come from the
- same real counter. */}
+ At zero unread there is no badge node at all and the icon stays muted;
+ both reads come from the same real counter. */}
<Popover open={popoverOpen} onOpenChange={(open) => { if (!open) setPopoverOpen(false); }}>
<PopoverAnchor asChild>
<div className="w-full" onMouseEnter={openPopover} onMouseLeave={queueClose}>
<NavLink
to="/inbox"
aria-label={t('workbench.nav.inbox')}
- className={({ isActive }) =>
- clsx(
- 'group flex w-full items-center gap-2.5 rounded-lg border px-3 py-2.5 text-[13px] font-semibold transition-colors',
- // Cyan active state per design.pen ze15A — mint is reserved
- // for sessions / projects so the two reads stay distinct.
- isActive
- ? 'border-cyan/40 bg-cyan-soft text-foreground shadow-glow-sm-cyan'
- : 'border-border-strong text-foreground hover:bg-foreground/[0.04]',
- )
- }
+ className="relative flex h-9 w-full items-center gap-2.5 rounded-lg px-2.5 text-[13px] transition-colors hover:bg-[var(--nav-hover-bg)]"
>
{({ isActive }) => (
<>
- {/* Cyan is what unread means here, so the counter colours the
- icon on any route — not only while Inbox is the open one. */}
- <Inbox className={clsx('size-4', badge || isActive ? 'text-cyan-ink' : 'text-foreground')} />
- <span className="flex-1">{t('workbench.nav.inbox')}</span>
+ <Inbox
+ className={clsx(
+ 'size-[17px]',
+ badge ? 'text-cyan-ink' : isActive ? 'text-foreground' : 'text-muted',
+ )}
+ />
+ <span className={clsx(isActive ? 'font-semibold text-foreground' : 'font-medium text-muted')}>{t('workbench.nav.inbox')}</span>
{badge && (
- <span className="inline-flex min-w-[1.25rem] items-center justify-center rounded-full bg-cyan px-1.5 py-0.5 font-mono text-[9px] font-bold text-accent-foreground shadow-glow-xs-cyan">
+ <span className="ml-auto inline-flex min-w-[18px] items-center justify-center rounded-full border border-surface bg-cyan px-[4px] font-mono text-[9px] font-bold leading-[14px] text-primary-foreground">
{badge}
</span>
)}
- <ChevronRight className="size-3.5 text-muted opacity-0 transition-opacity group-hover:opacity-100" />
</>
)}
</NavLink>
@@ -904,59 +886,47 @@ export const WorkbenchSidebar: React.FC<{ onOpenSearch?: () => void }> = ({ onOp
/>
</Popover>
- {/* Capabilities — a collapsible group, so a long project list can reclaim
- the rows. Only the destinations the current authorization admits are
- rendered, and the header disappears with them. */}
- {capabilityNav.length > 0 && <div className="flex shrink-0 flex-col gap-1.5">
- <button
- type="button"
- onClick={toggleCaps}
- aria-expanded={!capsCollapsed}
- className="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"
- >
- <span className="flex-1 text-left">{t('nav.capabilities')}</span>
- <ChevronDown className={clsx('size-3.5 shrink-0 transition-transform', capsCollapsed && '-rotate-90')} />
- </button>
- {!capsCollapsed && (
- <nav className="flex flex-col gap-0.5">
- {capabilityNav.map(({ to, i18nKey, icon }) => (
- <SidebarNavRow key={to} to={to} icon={icon} label={t(i18nKey)} />
- ))}
- </nav>
- )}
- </div>}
+ {/* Navigation m8K59 — the home brand is the new-conversation entry, so
+ capability destinations are the only rows in this group. */}
+ {capabilityNav.length > 0 && (
+ <div className="flex shrink-0 flex-col gap-1">
+ <button
+ type="button"
+ className="group flex h-7 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)}
+ >
+ {capabilitiesOpen ? <ChevronDown className="size-3" /> : <ChevronRight className="size-3" />}
+ <span>{t('nav.capabilities')}</span>
+ </button>
+ {capabilitiesOpen && (
+ <nav id="workbench-capability-nav" className="flex flex-col gap-0.5">
+ {capabilityNav.map(({ to, i18nKey, icon }) => (
+ <SidebarNavRow key={to} to={to} icon={icon} label={t(i18nKey)} />
+ ))}
+ </nav>
+ )}
+ </div>
+ )}
- {/* Projects section — 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; ⌘K still opens the same
- palette from anywhere. */}
+ {/* Projects section t7o96 — the label on the left and the create
+ affordance on the right; Search has its own row below the brand. */}
<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">
+ <span className="font-mono text-[10px] font-bold uppercase tracking-[0.16em] text-muted">
{t('workbench.projectsLabel')}
</span>
- <div className="flex items-center gap-0.5">
- <Button
- type="button"
- variant="ghost"
- size="icon"
- className="size-7 shrink-0 text-muted hover:text-foreground"
- aria-label={t('workbench.search.entry')}
- onClick={onOpenSearch}
- >
- <Search className="size-4" />
- </Button>
- {canCreateProject && <Button
- type="button"
- variant="ghost"
- size="icon"
- className="size-7 shrink-0 text-muted hover:text-foreground"
- aria-label={t('workbench.addProject')}
- onClick={() => setShowNewProject(true)}
- >
- <FolderPlus className="size-4" />
- </Button>}
- </div>
+ {canCreateProject && <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="size-[22px] shrink-0 text-muted hover:text-foreground"
+ aria-label={t('workbench.addProject')}
+ onClick={() => setShowNewProject(true)}
+ >
+ <FolderPlus className="size-[15px]" />
+ </Button>}
</div>
<div className="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto pr-0.5">
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 2f4d20207..ddba01526 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -2476,7 +2476,7 @@
"resizeSidebar": "Resize sidebar"
},
"workbench": {
- "eyebrow": "Workbench",
+ "eyebrow": "Agent OS",
"placeholderTitle": "Your AI workbench is coming together",
"placeholderBody": "Agents, Skills, Harness, and Vaults will live here. For now, jump into the control panel to configure platforms and backends.",
"home": {
@@ -4296,6 +4296,7 @@
"retryRequired": "Retry needed · {{count}}",
"retryHint": "Automatic startup retries stopped after failure. Your input is retained. Resolve the error, then use Send now or Retry on the failure notice.",
"sendNow": "Send now",
+ "sendingNow": "Sending…",
"recall": "Recall to input",
"remove": "Remove from queue",
"attachments": {
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 99eba1de8..16b372714 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -2476,7 +2476,7 @@
"resizeSidebar": "调整侧栏宽度"
},
"workbench": {
- "eyebrow": "工作台",
+ "eyebrow": "Agent OS",
"placeholderTitle": "你的 AI 工作台正在搭建",
"placeholderBody": "Agents、Skills、Harness、Vaults 将会汇聚到这里。现在先进控制面板配置平台和 backend。",
"home": {
@@ -4296,6 +4296,7 @@
"retryHint": "启动失败,自动重试已停止,原输入已保留。排查错误后,点击“立即发送”或失败提示上的“重试”。",
"title": "排队中 · {{count}}",
"sendNow": "立即发送",
+ "sendingNow": "发送中…",
"recall": "撤回到输入框",
"remove": "移出队列",
"attachments": {