{
});
describe("resolveSidebarThreadStatus", () => {
- const session = {
- threadId: ThreadId.make("thread-1"),
-describe("resolveSidebarV2Status", () => {
const runtime = {
status: "running" as const,
activeRunId: null,
@@ -735,20 +729,16 @@ describe("resolveSidebarV2Status", () => {
const idle = { hasPendingApprovals: false, hasPendingUserInput: false, runtime: null };
- it("prioritizes approval over a running session", () => {
- expect(resolveSidebarThreadStatus({ ...idle, hasPendingApprovals: true, session })).toBe(
it("prioritizes approval over a running runtime", () => {
- expect(resolveSidebarV2Status({ ...idle, hasPendingApprovals: true, runtime })).toBe(
+ expect(resolveSidebarThreadStatus({ ...idle, hasPendingApprovals: true, runtime })).toBe(
"approval",
);
});
- it("prioritizes awaiting input over a running session, below approval", () => {
- expect(resolveSidebarThreadStatus({ ...idle, hasPendingUserInput: true, session })).toBe(
+ it("prioritizes awaiting input over a running runtime, below approval", () => {
+ expect(resolveSidebarThreadStatus({ ...idle, hasPendingUserInput: true, runtime })).toBe(
"input",
);
- it("prioritizes awaiting input over a running runtime, below approval", () => {
- expect(resolveSidebarV2Status({ ...idle, hasPendingUserInput: true, runtime })).toBe("input");
expect(
resolveSidebarThreadStatus({
...idle,
@@ -759,10 +749,8 @@ describe("resolveSidebarV2Status", () => {
).toBe("approval");
});
- it("reports working for running and starting sessions", () => {
- expect(resolveSidebarThreadStatus({ ...idle, session })).toBe("working");
it("reports working for running and starting runtimes", () => {
- expect(resolveSidebarV2Status({ ...idle, runtime })).toBe("working");
+ expect(resolveSidebarThreadStatus({ ...idle, runtime })).toBe("working");
expect(
resolveSidebarThreadStatus({
...idle,
@@ -792,10 +780,8 @@ describe("resolveSidebarV2Status", () => {
).toBe("waiting");
});
- it("defaults to ready with no session", () => {
- expect(resolveSidebarThreadStatus({ ...idle, session: null })).toBe("ready");
it("defaults to ready with no runtime", () => {
- expect(resolveSidebarV2Status(idle)).toBe("ready");
+ expect(resolveSidebarThreadStatus(idle)).toBe("ready");
});
it("keeps a waiting runtime visible ahead of unread and woke presentation", () => {
@@ -856,136 +842,6 @@ describe("sortThreadsForSidebar", () => {
});
});
-describe("pinOrderKeyBetween", () => {
- it("produces keys that sort between their bounds", () => {
- const middle = pinOrderKeyBetween(null, null)!;
- const top = pinOrderKeyBetween(null, middle)!;
- const bottom = pinOrderKeyBetween(middle, null)!;
- expect(top < middle).toBe(true);
- expect(middle < bottom).toBe(true);
-
- const between = pinOrderKeyBetween(top, middle)!;
- expect(top < between && between < middle).toBe(true);
- });
-
- it("extends into new digits when bounds are adjacent", () => {
- const key = pinOrderKeyBetween("g", "h")!;
- expect("g" < key && key < "h").toBe(true);
- });
-
- it("stays strictly ordered under repeated top insertion", () => {
- // Every new pin lands at the head of the arranged run; keys must keep
- // sorting before the previous head without ever bottoming out.
- let head: string | null = null;
- const keys: string[] = [];
- for (let i = 0; i < 100; i += 1) {
- const key: string = pinOrderKeyBetween(null, head)!;
- expect(key).not.toBeNull();
- if (head !== null) expect(key < head).toBe(true);
- keys.push(key);
- head = key;
- }
- expect(new Set(keys).size).toBe(100);
- });
-
- it("stays strictly ordered under repeated middle insertion", () => {
- let low = pinOrderKeyBetween(null, null)!;
- let high = pinOrderKeyBetween(low, null)!;
- for (let i = 0; i < 100; i += 1) {
- const key: string = pinOrderKeyBetween(low, high)!;
- expect(low < key && key < high).toBe(true);
- if (i % 2 === 0) low = key;
- else high = key;
- }
- });
-
- it("returns null for corrupt or out-of-order bounds instead of throwing", () => {
- expect(pinOrderKeyBetween("z", "a")).toBeNull();
- expect(pinOrderKeyBetween("A!", null)).toBeNull();
- expect(pinOrderKeyBetween(null, "ma")).toBeNull();
- expect(pinOrderKeyBetween("m", "m")).toBeNull();
- });
-});
-
-describe("planPinnedReorder", () => {
- it("writes only the moved thread when neighbors are keyed", () => {
- const assignments = planPinnedReorder({
- orderedIds: ["a", "c", "b"],
- keysById: new Map([
- ["a", "f"],
- ["b", "m"],
- ["c", "t"],
- ]),
- movedId: "c",
- });
- expect(assignments).toHaveLength(1);
- expect(assignments[0]!.id).toBe("c");
- expect(assignments[0]!.orderKey > "f" && assignments[0]!.orderKey < "m").toBe(true);
- });
-
- it("treats list edges as open bounds", () => {
- const assignments = planPinnedReorder({
- orderedIds: ["b", "a"],
- keysById: new Map([
- ["a", "m"],
- ["b", null],
- ]),
- movedId: "b",
- });
- expect(assignments).toHaveLength(1);
- expect(assignments[0]!.orderKey < "m").toBe(true);
- });
-
- it("materializes keys for the whole section when a neighbor is keyless", () => {
- const assignments = planPinnedReorder({
- orderedIds: ["b", "a", "c"],
- keysById: new Map([
- ["a", null],
- ["b", "m"],
- ["c", null],
- ]),
- movedId: "b",
- });
- expect(assignments.map((entry) => entry.id)).toEqual(["b", "a", "c"]);
- const keys = assignments.map((entry) => entry.orderKey);
- expect([...keys].sort()).toEqual(keys);
- expect(new Set(keys).size).toBe(keys.length);
- });
-});
-
-describe("sortPinnedThreadsForSidebar", () => {
- const pinnable = (input: { id: string; createdAt: string; pinOrderKey?: string | null }) => ({
- id: input.id,
- createdAt: input.createdAt,
- pinOrderKey: input.pinOrderKey ?? null,
- });
-
- it("sorts keyed threads by key ahead of keyless threads in creation order", () => {
- const sorted = sortPinnedThreadsForSidebar([
- pinnable({ id: "keyless-old", createdAt: "2026-03-09T08:00:00.000Z" }),
- pinnable({ id: "second", createdAt: "2026-03-09T09:00:00.000Z", pinOrderKey: "t" }),
- pinnable({ id: "keyless-new", createdAt: "2026-03-09T12:00:00.000Z" }),
- pinnable({ id: "first", createdAt: "2026-03-09T07:00:00.000Z", pinOrderKey: "g" }),
- ]);
-
- expect(sorted.map((thread) => thread.id)).toEqual([
- "first",
- "second",
- "keyless-new",
- "keyless-old",
- ]);
- });
-
- it("breaks equal keys by id so raced writes render identically everywhere", () => {
- const sorted = sortPinnedThreadsForSidebar([
- pinnable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z", pinOrderKey: "m" }),
- pinnable({ id: "a", createdAt: "2026-03-09T11:00:00.000Z", pinOrderKey: "m" }),
- ]);
-
- expect(sorted.map((thread) => thread.id)).toEqual(["a", "b"]);
- });
-});
-
describe("sortSettledThreadsForSidebar", () => {
const settled = (input: {
id: string;
@@ -1876,3 +1732,133 @@ describe("resolveThreadLastVisitedAt", () => {
expect(resolveThreadLastVisitedAt(null, "2026-07-30T10:00:00.000Z")).toBeUndefined();
});
});
+
+describe("pinOrderKeyBetween", () => {
+ it("produces keys that sort between their bounds", () => {
+ const middle = pinOrderKeyBetween(null, null)!;
+ const top = pinOrderKeyBetween(null, middle)!;
+ const bottom = pinOrderKeyBetween(middle, null)!;
+ expect(top < middle).toBe(true);
+ expect(middle < bottom).toBe(true);
+
+ const between = pinOrderKeyBetween(top, middle)!;
+ expect(top < between && between < middle).toBe(true);
+ });
+
+ it("extends into new digits when bounds are adjacent", () => {
+ const key = pinOrderKeyBetween("g", "h")!;
+ expect("g" < key && key < "h").toBe(true);
+ });
+
+ it("stays strictly ordered under repeated top insertion", () => {
+ // Every new pin lands at the head of the arranged run; keys must keep
+ // sorting before the previous head without ever bottoming out.
+ let head: string | null = null;
+ const keys: string[] = [];
+ for (let i = 0; i < 100; i += 1) {
+ const key: string = pinOrderKeyBetween(null, head)!;
+ expect(key).not.toBeNull();
+ if (head !== null) expect(key < head).toBe(true);
+ keys.push(key);
+ head = key;
+ }
+ expect(new Set(keys).size).toBe(100);
+ });
+
+ it("stays strictly ordered under repeated middle insertion", () => {
+ let low = pinOrderKeyBetween(null, null)!;
+ let high = pinOrderKeyBetween(low, null)!;
+ for (let i = 0; i < 100; i += 1) {
+ const key: string = pinOrderKeyBetween(low, high)!;
+ expect(low < key && key < high).toBe(true);
+ if (i % 2 === 0) low = key;
+ else high = key;
+ }
+ });
+
+ it("returns null for corrupt or out-of-order bounds instead of throwing", () => {
+ expect(pinOrderKeyBetween("z", "a")).toBeNull();
+ expect(pinOrderKeyBetween("A!", null)).toBeNull();
+ expect(pinOrderKeyBetween(null, "ma")).toBeNull();
+ expect(pinOrderKeyBetween("m", "m")).toBeNull();
+ });
+});
+
+describe("planPinnedReorder", () => {
+ it("writes only the moved thread when neighbors are keyed", () => {
+ const assignments = planPinnedReorder({
+ orderedIds: ["a", "c", "b"],
+ keysById: new Map([
+ ["a", "f"],
+ ["b", "m"],
+ ["c", "t"],
+ ]),
+ movedId: "c",
+ });
+ expect(assignments).toHaveLength(1);
+ expect(assignments[0]!.id).toBe("c");
+ expect(assignments[0]!.orderKey > "f" && assignments[0]!.orderKey < "m").toBe(true);
+ });
+
+ it("treats list edges as open bounds", () => {
+ const assignments = planPinnedReorder({
+ orderedIds: ["b", "a"],
+ keysById: new Map([
+ ["a", "m"],
+ ["b", null],
+ ]),
+ movedId: "b",
+ });
+ expect(assignments).toHaveLength(1);
+ expect(assignments[0]!.orderKey < "m").toBe(true);
+ });
+
+ it("materializes keys for the whole section when a neighbor is keyless", () => {
+ const assignments = planPinnedReorder({
+ orderedIds: ["b", "a", "c"],
+ keysById: new Map([
+ ["a", null],
+ ["b", "m"],
+ ["c", null],
+ ]),
+ movedId: "b",
+ });
+ expect(assignments.map((entry) => entry.id)).toEqual(["b", "a", "c"]);
+ const keys = assignments.map((entry) => entry.orderKey);
+ expect([...keys].sort()).toEqual(keys);
+ expect(new Set(keys).size).toBe(keys.length);
+ });
+});
+
+describe("sortPinnedThreadsForSidebar", () => {
+ const pinnable = (input: { id: string; createdAt: string; pinOrderKey?: string | null }) => ({
+ id: input.id,
+ createdAt: input.createdAt,
+ pinOrderKey: input.pinOrderKey ?? null,
+ });
+
+ it("sorts keyed threads by key ahead of keyless threads in creation order", () => {
+ const sorted = sortPinnedThreadsForSidebar([
+ pinnable({ id: "keyless-old", createdAt: "2026-03-09T08:00:00.000Z" }),
+ pinnable({ id: "second", createdAt: "2026-03-09T09:00:00.000Z", pinOrderKey: "t" }),
+ pinnable({ id: "keyless-new", createdAt: "2026-03-09T12:00:00.000Z" }),
+ pinnable({ id: "first", createdAt: "2026-03-09T07:00:00.000Z", pinOrderKey: "g" }),
+ ]);
+
+ expect(sorted.map((thread) => thread.id)).toEqual([
+ "first",
+ "second",
+ "keyless-new",
+ "keyless-old",
+ ]);
+ });
+
+ it("breaks equal keys by id so raced writes render identically everywhere", () => {
+ const sorted = sortPinnedThreadsForSidebar([
+ pinnable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z", pinOrderKey: "m" }),
+ pinnable({ id: "a", createdAt: "2026-03-09T11:00:00.000Z", pinOrderKey: "m" }),
+ ]);
+
+ expect(sorted.map((thread) => thread.id)).toEqual(["a", "b"]);
+ });
+});
diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts
index 8513910157..fdbd87b56e 100644
--- a/apps/web/src/components/Sidebar.logic.ts
+++ b/apps/web/src/components/Sidebar.logic.ts
@@ -495,8 +495,6 @@ export function resolveThreadRowClassName(input: {
);
}
-// ── Sidebar thread status model ─────────────────────────────────────
-// Five visual states, three colors: color is reserved for "act now"
// ── Sidebar v2 status model ─────────────────────────────────────────
// Six visual states, three colors: color is reserved for "act now"
// (approval), "in motion" (working), and "broken" (failed). Ready is the
@@ -507,14 +505,7 @@ export function resolveThreadRowClassName(input: {
// false Done.
// Unread completion is tracked separately: it describes whether a ready
// thread needs attention, not what the thread is currently doing.
-export type SidebarThreadStatus =
- | "approval"
- | "input"
- | "working"
- | "monitoring"
- | "failed"
- | "ready";
-export type SidebarV2Status = "approval" | "input" | "working" | "waiting" | "failed" | "ready";
+export type SidebarThreadStatus = "approval" | "input" | "working" | "waiting" | "failed" | "ready";
type SidebarThreadStatusInput = Pick<
SidebarThreadSummary,
@@ -553,7 +544,7 @@ export type SidebarV2TopStatusKind =
| "working";
export function resolveSidebarV2TopStatus(input: {
- readonly status: SidebarV2Status;
+ readonly status: SidebarThreadStatus;
readonly isUnread: boolean;
readonly isWoke: boolean;
}): SidebarV2TopStatusKind | null {
@@ -578,7 +569,7 @@ export function resolveSidebarV2TopStatus(input: {
return input.isUnread ? "done" : null;
}
-export function shouldShowSidebarV2Duration(status: SidebarV2Status): boolean {
+export function shouldShowSidebarV2Duration(status: SidebarThreadStatus): boolean {
return status === "working";
}
@@ -615,7 +606,7 @@ export function firstValidTimestamp(
return null;
}
-// Sidebar sort: static creation order, newest thread on top. Activity NEVER
+// v2 sort: static creation order, newest thread on top. Activity NEVER
// reorders the list — a row holds its position from open until settled, so
// the screen only moves at lifecycle transitions. Status (including pending
// approval) is carried by each card's edge strip, not by position.
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index cff457aad5..faf24e12f6 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -1,29 +1,3 @@
-import {
- ArchiveIcon,
- ArrowUpDownIcon,
- ChevronRightIcon,
- CloudIcon,
- ContainerIcon,
- FolderPlusIcon,
- GitForkIcon,
- Globe2Icon,
- LoaderIcon,
- SearchIcon,
- SquarePenIcon,
- TerminalIcon,
- TriangleAlertIcon,
-} from "lucide-react";
-import {
- ChangeRequestStatusIcon,
- prStatusIndicator,
- PrStatusTooltipContent,
- resolveThreadPr,
- terminalStatusFromRunningIds,
- ThreadStatusLabel,
- ThreadWorktreeIndicator,
-} from "./ThreadStatusIndicators";
-import { ProjectFavicon } from "./ProjectFavicon";
-import { useAtomValue } from "@effect/atom-react";
import { autoAnimate } from "@formkit/auto-animate";
import { useAtomValue } from "@effect/atom-react";
import * as Schema from "effect/Schema";
@@ -133,14 +107,6 @@ import { useNowMinute } from "../hooks/useNowMinute";
import { useEnvironments, usePrimaryEnvironmentId } from "../state/environments";
import { useProjects, useThreadShells } from "../state/entities";
import { environmentServerConfigsAtom, primaryServerKeybindingsAtom } from "../state/server";
-import { useComposerDraftStore } from "../composerDraftStore";
-import { useNewThreadHandler } from "../hooks/useHandleNewThread";
-import { useDesktopUpdateState } from "../state/desktopUpdate";
-
-import { useMarkThreadUnread, useThreadActions } from "../hooks/useThreadActions";
-import { projectEnvironment } from "../state/projects";
-import { useEnvironmentQuery } from "../state/query";
-import { threadEnvironment, useEnvironmentThread } from "../state/threads";
import { vcsEnvironment } from "../state/vcs";
import { threadEnvironment } from "../state/threads";
import { useEnvironmentQuery } from "../state/query";
@@ -150,91 +116,12 @@ import {
resolveActiveThreadRouteRef,
resolveThreadRouteTarget,
} from "../threadRoutes";
-import { stackedThreadToast, toastManager } from "./ui/toast";
-import { formatRelativeTimeLabel } from "../timestampFormat";
-import { SettingsSidebarNav } from "./settings/SettingsSidebarNav";
-import { Kbd } from "./ui/kbd";
-import {
- getArm64IntelBuildWarningDescription,
- getDesktopUpdateActionError,
- getDesktopUpdateInstallConfirmationMessage,
- isDesktopUpdateButtonDisabled,
- resolveDesktopUpdateButtonAction,
- shouldShowArm64IntelBuildWarning,
- shouldToastDesktopUpdateActionResult,
-} from "./desktopUpdate.logic";
-import { showDesktopUpdateDownloadedToast } from "./desktopUpdate.toast";
-import { Alert, AlertAction, AlertDescription, AlertTitle } from "./ui/alert";
-import { Button } from "./ui/button";
-import {
- Dialog,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogPanel,
- DialogPopup,
- DialogTitle,
-} from "./ui/dialog";
-import { Input } from "./ui/input";
-import { Menu, MenuGroup, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "./ui/menu";
-import {
- NumberField,
- NumberFieldDecrement,
- NumberFieldGroup,
- NumberFieldIncrement,
- NumberFieldInput,
-} from "./ui/number-field";
-import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select";
-import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
-import {
- SidebarContent,
- SidebarGroup,
- SidebarMenu,
- SidebarMenuButton,
- SidebarMenuItem,
- SidebarMenuSub,
- SidebarMenuSubButton,
- SidebarMenuSubItem,
- useSidebar,
-} from "./ui/sidebar";
-import { useThreadSelectionStore } from "../threadSelectionStore";
-import { openCommandPalette } from "../commandPaletteBus";
-import {
- archiveSelectedThreadEntries,
- buildMultiSelectThreadContextMenuItems,
- getSidebarForkParentThreadId,
- getSidebarThreadIdsToPrewarm,
- isSidebarSubagentThread,
- resolveAdjacentThreadId,
- isContextMenuPointerDown,
- isTrailingDoubleClick,
- resolveProjectStatusIndicator,
- resolveThreadLastVisitedAt,
- resolveThreadRowClassName,
- resolveThreadStatusPill,
- orderItemsByPreferredIds,
- shouldClearThreadSelectionOnMouseDown,
- sortProjectsForSidebar,
- useThreadJumpHintVisibility,
- ThreadStatusPill,
-} from "./Sidebar.logic";
-import { sortThreads } from "../lib/threadSort";
-import { SidebarChromeFooter, SidebarChromeHeader } from "./sidebar/SidebarChrome";
-import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
-import { useIsMobile } from "~/hooks/useMediaQuery";
-import { CommandDialogTrigger } from "./ui/command";
-import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
-import { primaryServerKeybindingsAtom } from "../state/server";
-import {
- derivePhysicalProjectKey,
- deriveProjectGroupingOverrideKey,
- getProjectOrderKey,
- selectProjectGroupingSettings,
-} from "../logicalProject";
+import { formatRelativeTimeLabel, parseTimestampDate } from "../timestampFormat";
import type { SidebarThreadSummary } from "../types";
import { cn } from "~/lib/utils";
import { buildThreadActionMenuItems } from "./threadActionMenu.logic";
import {
+ filterSidebarV2VisibleThreads,
buildBulkTitleRegenerationContextMenuItem,
formatWorkingDurationLabel,
firstValidTimestampMs,
@@ -431,7 +318,7 @@ function SidebarThreadTooltip({
{modelLabel}
@@ -448,7 +335,7 @@ function SidebarThreadTooltip({
) : null}
- {thread.session?.lastError ? (
+ {thread.runtime?.lastError ? (