diff --git a/apps/web/src/components/Sidebar.browser.test.tsx b/apps/web/src/components/Sidebar.browser.test.tsx
index be674b66520d2..f4dc44f2c5006 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";
@@ -208,6 +210,153 @@ 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());
+ });
+
+ 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(
+
+
+ ,
+ );
+
+ 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 () => {
+ 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", () => {
// 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..81c59b2f751bb 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);
@@ -492,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),
@@ -526,6 +539,22 @@ 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 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(threadShellKey(thread)) ||
+ routedActiveThreads.has(threadShellKey(thread)),
+ )
+ : activeThreads;
const projectFolders =
folderGroups === null
? null
@@ -549,7 +578,7 @@ function useSidebarThreads(input: {
const orderedThreads = [
...pinnedThreads,
...(projectFolders === null
- ? activeThreads
+ ? visibleActiveThreads
: projectFolders.flatMap((folder) => folder.threads)),
...visibleWorkingThreads,
...visibleSnoozedThreads,
@@ -591,6 +620,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);
@@ -631,11 +664,20 @@ 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. 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(threadShellKey(thread));
+ return active;
+ };
const snoozed: EnvironmentThreadShell[] = [];
const settled: EnvironmentThreadShell[] = [];
const { draggableThreadKeys, activeReorderableThreadKeys } = resolveSidebarReorderableThreadKeys({
@@ -706,6 +748,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) -
@@ -1313,6 +1356,10 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
toggleSnoozedShelf,
workingShelfExpanded,
toggleWorkingShelf,
+ idleShelfEnabled,
+ idleShelfExpanded,
+ toggleIdleShelf,
+ visibleActiveThreads,
projectFolders,
toggleProjectFolder,
renderedSettledThreads,
@@ -1954,7 +2001,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) {
@@ -3383,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"
@@ -3527,7 +3579,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
,
@@ -3538,7 +3590,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 (