From 6734008d5fcd972fc3af653609e9110a1724ce88 Mon Sep 17 00:00:00 2001 From: Rodrigo Dantes Gonzalez Mantuano Date: Sat, 14 Nov 2026 17:16:12 +0100 Subject: [PATCH 1/5] feat(web): the sidebar folds the idle threads away The threads no agent is working on had no way out of the way: they sat between Pinned and Working with no header, while Working and Settled both fold. The Idle shelf gives them the same header and the same toggle, so a pile of waiting threads can be put away and brought back. --- .../src/components/Sidebar.browser.test.tsx | 43 +++++++++++++++++ apps/web/src/components/Sidebar.drag.ts | 3 ++ apps/web/src/components/Sidebar.logic.ts | 1 + apps/web/src/components/Sidebar.tsx | 47 +++++++++++++++++-- .../components/sidebar/SidebarListMarkers.tsx | 14 +++--- 5 files changed, 98 insertions(+), 10 deletions(-) diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx index be674b66520d2..95a824301ed76 100644 --- a/apps/web/src/components/Sidebar.browser.test.tsx +++ b/apps/web/src/components/Sidebar.browser.test.tsx @@ -208,6 +208,49 @@ describe("sidebar render isolation", () => { }); }); +describe("the Idle shelf", () => { + it("folds the threads no agent is working on away", async () => { + using stack = new DisposableStack(); + const previousSettings = getClientSettings(); + stack.defer(() => __setClientSettingsForTests(previousSettings)); + __setClientSettingsForTests({ ...DEFAULT_CLIENT_SETTINGS }); + window.localStorage.removeItem("t3code:sidebar:idle-expanded"); + vi.mocked(useProjects).mockReturnValue([project("active")]); + vi.mocked(useHandleNewThread).mockReturnValue({ + activeDraftThread: null, + activeThread: null, + defaultProjectRef: null, + defaultProjectFallbackReady: true, + handleNewThread: vi.fn().mockResolvedValue(null), + routeDraftId: null, + routeThreadRef: null, + }); + vi.mocked(useQuietThreadShells).mockReturnValue([ + makeThreadFixture({ + id: ThreadId.make("thread-idle"), + environmentId: EnvironmentId.make("local"), + projectId: ProjectId.make("active"), + title: "Idle thread", + }), + ]); + + await using screen = await render( + + + , + ); + + const toggle = screen.getByTestId("sidebar-idle-shelf-toggle"); + const row = screen.getByTestId("sidebar-row-card"); + await expect.element(toggle).toHaveAttribute("aria-expanded", "true"); + await vi.waitFor(() => expect(row.element().textContent).toContain("Idle thread")); + + await userEvent.click(toggle); + await expect.element(toggle).toHaveAttribute("aria-expanded", "false"); + await vi.waitFor(() => expect(row.query()).toBeNull()); + }); +}); + describe("sidebar thread rename", () => { // regression: #35151 an untouched rename wrote back the title it opened with over a newer one it.each(["{Enter}", "{Tab}"])( diff --git a/apps/web/src/components/Sidebar.drag.ts b/apps/web/src/components/Sidebar.drag.ts index 76f2c9bf3a3ec..207115886ad9f 100644 --- a/apps/web/src/components/Sidebar.drag.ts +++ b/apps/web/src/components/Sidebar.drag.ts @@ -175,6 +175,9 @@ export function createSidebarSortingStrategy(input: { marker("pinned-header"); projected.push(...groups.pinned); marker("pinned-divider"); + if (items.some((item) => item.kind === "marker" && item.marker === "idle-header")) { + marker("idle-header"); + } section("active"); if (items.some((item) => item.kind === "marker" && item.marker === "working-header")) { marker("working-header"); diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts index 351505c4c666c..4017b00b2d05f 100644 --- a/apps/web/src/components/Sidebar.logic.ts +++ b/apps/web/src/components/Sidebar.logic.ts @@ -209,6 +209,7 @@ export type SidebarListMarker = | "active-placeholder" | "settled-placeholder" | "pinned-divider" + | "idle-header" | "working-header" | "snoozed-header" | "settled-header"; diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 3cb77464473b4..b8c2d18a8d286 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -335,6 +335,7 @@ const SETTLED_TAIL_PAGE_COUNT = 25; const SETTLED_SHELF_EXPANDED_KEY = "t3code:sidebar:settled-expanded"; const SNOOZED_SHELF_EXPANDED_KEY = "t3code:sidebar:snoozed-expanded"; const WORKING_SHELF_EXPANDED_KEY = "t3code:sidebar:working-expanded"; +const IDLE_SHELF_EXPANDED_KEY = "t3code:sidebar:idle-expanded"; const inboxReturns = createInboxReturnTracker(); @@ -467,6 +468,12 @@ function useSidebarThreads(input: { false, Schema.Boolean, ); + // Idle threads are the ones no agent is working on; the shelf folds them away. + const [idleShelfExpanded, setIdleShelfExpanded] = useLocalStorage( + IDLE_SHELF_EXPANDED_KEY, + true, + Schema.Boolean, + ); // Shared with the old per-project sidebar, so folders keep their open state. const projectExpandedById = useUiStateStore((store) => store.projectExpandedById); const setProjectExpanded = useUiStateStore((store) => store.setProjectExpanded); @@ -526,6 +533,13 @@ function useSidebarThreads(input: { const visibleWorkingThreads = workingShelfExpanded ? workingThreads : routeThreadOnly(workingThreads, routeRowThreadKey); + // Folders list the idle threads inside each project, so they need no shelf. + const idleShelfEnabled = folderGroups === null; + const visibleActiveThreads = idleShelfEnabled + ? idleShelfExpanded + ? activeThreads + : routeThreadOnly(activeThreads, routeRowThreadKey) + : activeThreads; const projectFolders = folderGroups === null ? null @@ -549,7 +563,7 @@ function useSidebarThreads(input: { const orderedThreads = [ ...pinnedThreads, ...(projectFolders === null - ? activeThreads + ? visibleActiveThreads : projectFolders.flatMap((folder) => folder.threads)), ...visibleWorkingThreads, ...visibleSnoozedThreads, @@ -591,6 +605,10 @@ function useSidebarThreads(input: { toggleSnoozedShelf: () => setSnoozedShelfExpanded((value) => !value), workingShelfExpanded, toggleWorkingShelf: () => setWorkingShelfExpanded((value) => !value), + idleShelfEnabled, + idleShelfExpanded, + toggleIdleShelf: () => setIdleShelfExpanded((value) => !value), + visibleActiveThreads, projectFolders, toggleProjectFolder: (group: SidebarProjectSnapshot) => { const keys = sidebarFolderExpansionKeys(group); @@ -1313,6 +1331,10 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve toggleSnoozedShelf, workingShelfExpanded, toggleWorkingShelf, + idleShelfEnabled, + idleShelfExpanded, + toggleIdleShelf, + visibleActiveThreads, projectFolders, toggleProjectFolder, renderedSettledThreads, @@ -1954,7 +1976,10 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve const pinnedRows = rowsOf(pinnedThreads, "pinned"); items.push(...pinnedRows); items.push({ kind: "marker", marker: "pinned-divider" }); - const activeRows = rowsOf(activeThreads, "active"); + const activeRows = rowsOf(visibleActiveThreads, "active"); + if (idleShelfEnabled && activeThreads.length > 0) { + items.push({ kind: "marker", marker: "idle-header" }); + } items.push({ kind: "marker", marker: "active-placeholder" }); items.push(...activeRows); if (workingThreads.length > 0) { @@ -3527,7 +3552,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve , @@ -3538,7 +3563,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve , ); break; + case "idle-header": + items.push( + , + ); + break; case "working-header": items.push( void }; }) { const shelf = - props.marker === "working-header" - ? "working" - : props.marker === "snoozed-header" - ? "snoozed" - : "settled"; + props.marker === "idle-header" + ? "idle" + : props.marker === "working-header" + ? "working" + : props.marker === "snoozed-header" + ? "snoozed" + : "settled"; return ( Date: Mon, 16 Nov 2026 09:18:41 +0100 Subject: [PATCH 2/5] fix(web): keep the running threads visible when Idle folds Without a Working shelf the running threads sit among the idle ones, so folding the Idle shelf hid the threads an agent is working on. The partition now tracks them, and the shelf keeps them and the thread on screen. Model: minimax/MiniMax-M3.1-Flash, Harness: opencode --- .../src/components/Sidebar.browser.test.tsx | 63 +++++++++++++++++++ apps/web/src/components/Sidebar.tsx | 35 ++++++++--- 2 files changed, 90 insertions(+), 8 deletions(-) diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx index 95a824301ed76..e978488ad9fdd 100644 --- a/apps/web/src/components/Sidebar.browser.test.tsx +++ b/apps/web/src/components/Sidebar.browser.test.tsx @@ -7,6 +7,8 @@ import { DEFAULT_CLIENT_SETTINGS, EnvironmentId, ProjectId, + ProviderInstanceId, + RunId, ThreadId, type ScopedThreadRef, } from "@t3tools/contracts"; @@ -249,6 +251,67 @@ describe("the Idle shelf", () => { await expect.element(toggle).toHaveAttribute("aria-expanded", "false"); await vi.waitFor(() => expect(row.query()).toBeNull()); }); + + it("keeps a running thread visible when the shelf folds", async () => { + using stack = new DisposableStack(); + const previousSettings = getClientSettings(); + stack.defer(() => __setClientSettingsForTests(previousSettings)); + // Without a Working shelf the running threads sit among the idle ones. + __setClientSettingsForTests({ + ...DEFAULT_CLIENT_SETTINGS, + sidebarWorkingShelfEnabled: false, + }); + window.localStorage.removeItem("t3code:sidebar:idle-expanded"); + vi.mocked(useProjects).mockReturnValue([project("active")]); + vi.mocked(useHandleNewThread).mockReturnValue({ + activeDraftThread: null, + activeThread: null, + defaultProjectRef: null, + defaultProjectFallbackReady: true, + handleNewThread: vi.fn().mockResolvedValue(null), + routeDraftId: null, + routeThreadRef: null, + }); + vi.mocked(useQuietThreadShells).mockReturnValue([ + makeThreadFixture({ + id: ThreadId.make("thread-running"), + environmentId: EnvironmentId.make("local"), + projectId: ProjectId.make("active"), + title: "Running thread", + runtime: { + status: "running", + activeRunId: RunId.make("run-1"), + providerInstanceId: ProviderInstanceId.make("codex"), + providerName: null, + lastError: null, + updatedAt: "2026-01-01T00:00:00.000Z", + }, + }), + makeThreadFixture({ + id: ThreadId.make("thread-idle"), + environmentId: EnvironmentId.make("local"), + projectId: ProjectId.make("active"), + title: "Idle thread", + }), + ]); + + await using screen = await render( + + + , + ); + + const toggle = screen.getByTestId("sidebar-idle-shelf-toggle"); + await vi.waitFor(() => + expect(screen.getByTestId("sidebar-row-card").elements()).toHaveLength(2), + ); + + await userEvent.click(toggle); + await vi.waitFor(() => + expect(screen.getByTestId("sidebar-row-card").elements()).toHaveLength(1), + ); + await expect.element(screen.getByText("Running thread")).toBeVisible(); + }); }); describe("sidebar thread rename", () => { diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index b8c2d18a8d286..e9f745c68629c 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -499,8 +499,14 @@ function useSidebarThreads(input: { clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`, }); - const { pinnedThreads, activeThreads, workingThreads, snoozedThreads, settledThreads } = - partition; + const { + pinnedThreads, + activeThreads, + workingThreads, + snoozedThreads, + settledThreads, + runningAmongIdle, + } = partition; // Older settled threads load in pages; the shelf lists them only as far as they are loaded. const olderSettledShelf = useOlderSettledShelf({ scopes: olderSettledScopes([...serverConfigs.keys()], scopedProjectKeys), @@ -535,10 +541,15 @@ function useSidebarThreads(input: { : routeThreadOnly(workingThreads, routeRowThreadKey); // Folders list the idle threads inside each project, so they need no shelf. const idleShelfEnabled = folderGroups === null; + const routedActiveThreads = new Set(routeThreadOnly(activeThreads, routeRowThreadKey)); const visibleActiveThreads = idleShelfEnabled ? idleShelfExpanded ? activeThreads - : routeThreadOnly(activeThreads, routeRowThreadKey) + : // Folding the shelf keeps the thread on screen and the threads an agent + // is working on, which are not idle at all. + activeThreads.filter( + (thread) => runningAmongIdle.has(thread) || routedActiveThreads.has(thread), + ) : activeThreads; const projectFolders = folderGroups === null @@ -649,11 +660,18 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) { const pinned: EnvironmentThreadShell[] = []; const active: EnvironmentThreadShell[] = []; const working: EnvironmentThreadShell[] = []; - const inbox = (thread: EnvironmentThreadShell, manuallyMoved = false) => - workingShelfEnabled && - (manuallyMoved ? isThreadWorking(thread) : inboxObservation.isWorking(thread)) - ? working - : active; + // Without a Working shelf the running threads sit among the idle ones, so + // they are tracked to stay visible when the Idle shelf folds. + const runningAmongIdle = new Set(); + const inbox = (thread: EnvironmentThreadShell, manuallyMoved = false) => { + if ( + workingShelfEnabled && + (manuallyMoved ? isThreadWorking(thread) : inboxObservation.isWorking(thread)) + ) + return working; + if (!workingShelfEnabled && isThreadWorking(thread)) runningAmongIdle.add(thread); + return active; + }; const snoozed: EnvironmentThreadShell[] = []; const settled: EnvironmentThreadShell[] = []; const { draggableThreadKeys, activeReorderableThreadKeys } = resolveSidebarReorderableThreadKeys({ @@ -724,6 +742,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) { getId: (thread) => scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)), }), workingThreads: sortWorkingThreadsBySend(working), + runningAmongIdle, snoozedThreads: snoozed.toSorted( (left, right) => firstValidTimestampMs(left.snoozedUntil ?? null) - From 5c5d26e93fae004127aa0fa29ad068fd125d8259 Mon Sep 17 00:00:00 2001 From: Rodrigo Dantes Gonzalez Mantuano Date: Mon, 16 Nov 2026 09:36:06 +0100 Subject: [PATCH 3/5] fix(web): track the running threads by key, not by object An optimistic drop replaces the thread it moves, so the copy in the list was not the one the partition had recorded. The key is tracked instead, so the running row stays visible while the reorder waits for the server. Model: minimax/MiniMax-M3.1-Flash, Harness: opencode --- apps/web/src/components/Sidebar.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index e9f745c68629c..9682ecba5ef03 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -541,14 +541,18 @@ function useSidebarThreads(input: { : routeThreadOnly(workingThreads, routeRowThreadKey); // Folders list the idle threads inside each project, so they need no shelf. const idleShelfEnabled = folderGroups === null; - const routedActiveThreads = new Set(routeThreadOnly(activeThreads, routeRowThreadKey)); + const routedActiveThreads = new Set( + routeThreadOnly(activeThreads, routeRowThreadKey).map(threadShellKey), + ); const visibleActiveThreads = idleShelfEnabled ? idleShelfExpanded ? activeThreads : // Folding the shelf keeps the thread on screen and the threads an agent // is working on, which are not idle at all. activeThreads.filter( - (thread) => runningAmongIdle.has(thread) || routedActiveThreads.has(thread), + (thread) => + runningAmongIdle.has(threadShellKey(thread)) || + routedActiveThreads.has(threadShellKey(thread)), ) : activeThreads; const projectFolders = @@ -661,15 +665,17 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) { const active: EnvironmentThreadShell[] = []; const working: EnvironmentThreadShell[] = []; // Without a Working shelf the running threads sit among the idle ones, so - // they are tracked to stay visible when the Idle shelf folds. - const runningAmongIdle = new Set(); + // they are tracked to stay visible when the Idle shelf folds. The key is + // tracked rather than the object, because an optimistic drop replaces it. + const runningAmongIdle = new Set(); const inbox = (thread: EnvironmentThreadShell, manuallyMoved = false) => { if ( workingShelfEnabled && (manuallyMoved ? isThreadWorking(thread) : inboxObservation.isWorking(thread)) ) return working; - if (!workingShelfEnabled && isThreadWorking(thread)) runningAmongIdle.add(thread); + if (!workingShelfEnabled && isThreadWorking(thread)) + runningAmongIdle.add(threadShellKey(thread)); return active; }; const snoozed: EnvironmentThreadShell[] = []; From efadfede00f3b0e12ce5b43833c56afb1e37ef57 Mon Sep 17 00:00:00 2001 From: Rodrigo Dantes Gonzalez Mantuano Date: Mon, 16 Nov 2026 10:17:38 +0100 Subject: [PATCH 4/5] fix(web): link the idle rows to their header for the arrow keys The tree reaches a shelf's rows through their navigation parent, so the idle rows had none: ArrowRight could not enter them and they could not return to the header. They now name the idle shelf, like the working, snoozed and settled rows. Model: minimax/MiniMax-M3.1-Flash, Harness: opencode --- .../src/components/Sidebar.browser.test.tsx | 37 +++++++++++++++++++ apps/web/src/components/Sidebar.tsx | 4 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx index e978488ad9fdd..3577dcb525693 100644 --- a/apps/web/src/components/Sidebar.browser.test.tsx +++ b/apps/web/src/components/Sidebar.browser.test.tsx @@ -252,6 +252,43 @@ describe("the Idle shelf", () => { await vi.waitFor(() => expect(row.query()).toBeNull()); }); + it("links the idle rows to their header for the arrow keys", async () => { + using stack = new DisposableStack(); + const previousSettings = getClientSettings(); + stack.defer(() => __setClientSettingsForTests(previousSettings)); + __setClientSettingsForTests({ ...DEFAULT_CLIENT_SETTINGS }); + window.localStorage.removeItem("t3code:sidebar:idle-expanded"); + vi.mocked(useProjects).mockReturnValue([project("active")]); + vi.mocked(useHandleNewThread).mockReturnValue({ + activeDraftThread: null, + activeThread: null, + defaultProjectRef: null, + defaultProjectFallbackReady: true, + handleNewThread: vi.fn().mockResolvedValue(null), + routeDraftId: null, + routeThreadRef: null, + }); + vi.mocked(useQuietThreadShells).mockReturnValue([ + makeThreadFixture({ + id: ThreadId.make("thread-idle"), + environmentId: EnvironmentId.make("local"), + projectId: ProjectId.make("active"), + title: "Idle thread", + }), + ]); + + await using screen = await render( + + + , + ); + + const header = screen.container.querySelector('[data-sidebar-row="shelf:idle"]'); + expect(header).not.toBeNull(); + const row = screen.container.querySelector('[data-sidebar-parent="shelf:idle"]'); + expect(row).not.toBeNull(); + }); + it("keeps a running thread visible when the shelf folds", async () => { using stack = new DisposableStack(); const previousSettings = getClientSettings(); diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 9682ecba5ef03..81c59b2f751bb 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -3433,7 +3433,9 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve section === "snoozed" || section === "settled" ? `shelf:${section}` - : undefined) + : section === "active" && idleShelfEnabled + ? "shelf:idle" + : undefined) } variantAction={ section === "snoozed" From 2a0c07f8ab466ff986245b790dcf0d63d61d843b Mon Sep 17 00:00:00 2001 From: Rodrigo Dantes Gonzalez Mantuano Date: Mon, 16 Nov 2026 10:31:02 +0100 Subject: [PATCH 5/5] test(web): wait for the idle shelf rows in the browser test The plain assertions ran before the rows were mounted. They now retry like the other browser assertions. Model: minimax/MiniMax-M3.1-Flash, Harness: opencode --- apps/web/src/components/Sidebar.browser.test.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx index 3577dcb525693..f4dc44f2c5006 100644 --- a/apps/web/src/components/Sidebar.browser.test.tsx +++ b/apps/web/src/components/Sidebar.browser.test.tsx @@ -283,10 +283,16 @@ describe("the Idle shelf", () => { , ); - const header = screen.container.querySelector('[data-sidebar-row="shelf:idle"]'); - expect(header).not.toBeNull(); - const row = screen.container.querySelector('[data-sidebar-parent="shelf:idle"]'); - expect(row).not.toBeNull(); + await vi.waitFor(() => + expect( + screen.container.querySelector('[data-sidebar-row="shelf:idle"]'), + ).not.toBeNull(), + ); + await vi.waitFor(() => + expect( + screen.container.querySelector('[data-sidebar-parent="shelf:idle"]'), + ).not.toBeNull(), + ); }); it("keeps a running thread visible when the shelf folds", async () => {