@devries-cameron20 / t3code Mirror · read-only / commits / f2dd1a4468
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 08:15 UTC

test: remove unreachable sidebar helper suites (#26920)

Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com> Co-authored-by: maria-rcks <maria@kuuro.net>

t3-code-bot[bot] committed Nov 1, 2026 at 21:02 UTC f2dd1a4468aa113675ddfc00b2983bc9f8d842ef
2 files changed +1 -208
apps/web/src/components/Sidebar.logic.test.ts
+1 -123
@@ -2,12 +2,11 @@ import { presentThreadShell } from "@t3tools/client-runtime/state/models";
2 import { isThreadWorking as isSidebarThreadWorking } from "@t3tools/client-runtime/state/thread-inbox";
3 import * as DateTime from "effect/DateTime";
4 import { deriveActiveWorkStartedAt } from "../session-logic.ts";
5 -import { describe, expect, it, vi } from "vite-plus/test";
5 +import { describe, expect, it } from "vite-plus/test";
6 import * as Cause from "effect/Cause";
7 import { AsyncResult } from "effect/reactivity";
8 import {
9 shouldCreateNewThreadInCurrentProject,
10 - archiveSelectedThreadEntries,
10 deleteSelectedThreadEntries,
11 getFallbackThreadIdAfterDelete,
12 hasUnseenCompletion,
@@ -16,7 +15,6 @@ import {
15 isSidebarEnvironmentDisconnected,
16 orderItemsByPreferredIds,
17 pinOrderKeyBetween,
19 - resolveProjectStatusIndicator,
18 resolveSidebarSweepKeys,
19 resolveSidebarThreadStatus,
20 resolveThreadStatusPill,
@@ -28,7 +26,6 @@ import {
26 planSidebarThreadDrop,
27 resolveSidebarReorderableThreadKeys,
28 sortPinnedThreadsForSidebar,
31 - sortProjectsForSidebar,
29 sortScopedProjectsForSidebar,
30 sortSidebarV2ProjectGroups,
31 shouldNavigateAfterThreadPark,
@@ -140,43 +137,6 @@ describe("deleteSelectedThreadEntries", () => {
137 });
138 });
139
143 -describe("archiveSelectedThreadEntries", () => {
144 - const entries = [{ threadKey: "one" }, { threadKey: "two" }, { threadKey: "three" }] as const;
145 - const success = { _tag: "Success" } as const;
146 - const failure = { _tag: "Failure" } as const;
147 -
148 - it("stops at a mutation failure and retains prior successes", async () => {
149 - const archive = vi.fn(async (entry: (typeof entries)[number], onArchived: () => void) => {
150 - if (entry.threadKey === "two") return failure;
151 - onArchived();
152 - return success;
153 - });
154 - const outcome = await archiveSelectedThreadEntries({ entries, archive });
155 -
156 - expect(archive).toHaveBeenCalledTimes(2);
157 - expect(outcome).toEqual({
158 - archivedThreadKeys: ["one"],
159 - mutationFailure: failure,
160 - followupFailures: [],
161 - });
162 - });
163 -
164 - it("continues after a post-archive failure", async () => {
165 - const archive = vi.fn(async (entry: (typeof entries)[number], onArchived: () => void) => {
166 - onArchived();
167 - return entry.threadKey === "two" ? failure : success;
168 - });
169 - const outcome = await archiveSelectedThreadEntries({ entries, archive });
170 -
171 - expect(archive).toHaveBeenCalledTimes(3);
172 - expect(outcome).toEqual({
173 - archivedThreadKeys: ["one", "two", "three"],
174 - mutationFailure: null,
175 - followupFailures: [failure],
176 - });
177 - });
178 -});
179 -
140 describe("sidebar thread lineage helpers", () => {
141 it("maps an open subagent to its nearest visible ancestor's sidebar row", () => {
142 const environmentId = EnvironmentId.make("environment-row");
@@ -589,40 +549,6 @@ describe("resolveThreadStatusPill", () => {
549 });
550 });
551
592 -describe("resolveProjectStatusIndicator", () => {
593 - it("ranks waiting below active work and above plan-ready", () => {
594 - const waiting = {
595 - label: "Waiting" as const,
596 - colorClass: "text-sidebar-muted-foreground",
597 - dotClass: "bg-sidebar-muted-foreground",
598 - pulse: false,
599 - };
600 -
601 - expect(
602 - resolveProjectStatusIndicator([
603 - waiting,
604 - {
605 - label: "Working",
606 - colorClass: "text-sky-600",
607 - dotClass: "bg-sky-500",
608 - pulse: true,
609 - },
610 - ]),
611 - ).toMatchObject({ label: "Working" });
612 - expect(
613 - resolveProjectStatusIndicator([
614 - {
615 - label: "Plan Ready",
616 - colorClass: "text-violet-600",
617 - dotClass: "bg-violet-500",
618 - pulse: false,
619 - },
620 - waiting,
621 - ]),
622 - ).toMatchObject({ label: "Waiting" });
623 - });
624 -});
625 -
552 function makeProject(overrides: Partial<Project> = {}): Project {
553 const { defaultModelSelection, ...rest } = overrides;
554 return {
@@ -703,54 +629,6 @@ describe("getFallbackThreadIdAfterDelete", () => {
629 expect(fallbackThreadId).toBe(ThreadId.make("thread-next"));
630 });
631 });
706 -describe("sortProjectsForSidebar", () => {
707 - it("sorts projects by the most recent user message across their threads", () => {
708 - const projects = [
709 - makeProject({ id: ProjectId.make("project-1"), title: "Older project" }),
710 - makeProject({ id: ProjectId.make("project-2"), title: "Newer project" }),
711 - ];
712 - const threads = [
713 - makeThread({
714 - projectId: ProjectId.make("project-1"),
715 - updatedAt: "2026-03-09T10:20:00.000Z",
716 - messages: [
717 - {
718 - id: "message-1" as never,
719 - role: "user",
720 - text: "older project user message",
721 - runId: null,
722 - createdAt: "2026-03-09T10:01:00.000Z",
723 - updatedAt: "2026-03-09T10:01:00.000Z",
724 - streaming: false,
725 - },
726 - ],
727 - }),
728 - makeThread({
729 - id: ThreadId.make("thread-2"),
730 - projectId: ProjectId.make("project-2"),
731 - updatedAt: "2026-03-09T10:05:00.000Z",
732 - messages: [
733 - {
734 - id: "message-2" as never,
735 - role: "user",
736 - text: "newer project user message",
737 - runId: null,
738 - createdAt: "2026-03-09T10:05:00.000Z",
739 - updatedAt: "2026-03-09T10:05:00.000Z",
740 - streaming: false,
741 - },
742 - ],
743 - }),
744 - ];
745 -
746 - const sorted = sortProjectsForSidebar(projects, threads, "updated_at");
747 -
748 - expect(sorted.map((project) => project.id)).toEqual([
749 - ProjectId.make("project-2"),
750 - ProjectId.make("project-1"),
751 - ]);
752 - });
753 -});
632
633 describe("sortScopedProjectsForSidebar", () => {
634 it("keeps identical project ids in different environments separate", () => {
apps/web/src/components/Sidebar.logic.ts
-85
@@ -587,38 +587,6 @@ export async function deleteSelectedThreadEntries<
587 return { deletedThreadKeys, firstFailure };
588 }
589
590 -export async function archiveSelectedThreadEntries<
591 - TEntry extends { readonly threadKey: string },
592 - TResult extends { readonly _tag: "Success" | "Failure" },
593 ->(input: {
594 - entries: readonly TEntry[];
595 - archive: (entry: TEntry, onArchived: () => void) => Promise<TResult>;
596 -}): Promise<{
597 - archivedThreadKeys: readonly string[];
598 - mutationFailure: Extract<TResult, { readonly _tag: "Failure" }> | null;
599 - followupFailures: readonly Extract<TResult, { readonly _tag: "Failure" }>[];
600 -}> {
601 - const archivedThreadKeys: string[] = [];
602 - const followupFailures: Extract<TResult, { readonly _tag: "Failure" }>[] = [];
603 -
604 - for (const entry of input.entries) {
605 - let didArchive = false;
606 - const result = await input.archive(entry, () => {
607 - didArchive = true;
608 - });
609 - if (didArchive || result._tag === "Success") archivedThreadKeys.push(entry.threadKey);
610 - if (result._tag === "Success") continue;
611 - const failure = result as Extract<TResult, { readonly _tag: "Failure" }>;
612 - if (didArchive) {
613 - followupFailures.push(failure);
614 - continue;
615 - }
616 - return { archivedThreadKeys, mutationFailure: failure, followupFailures };
617 - }
618 -
619 - return { archivedThreadKeys, mutationFailure: null, followupFailures };
620 -}
621 -
590 export function isSidebarHiddenThread(thread: Pick<SidebarThreadSummary, "lineage">): boolean {
591 return !isListedThreadLineage(thread.lineage);
592 }
@@ -710,18 +678,6 @@ export interface ThreadStatusPill {
678 pulse: boolean;
679 }
680
713 -const THREAD_STATUS_PRIORITY: Record<ThreadStatusPill["label"], number> = {
714 - "Pending Approval": 5,
715 - "Awaiting Input": 4,
716 - "Guest Request": 3.75,
717 - Failed: 3.5,
718 - Working: 3,
719 - Connecting: 3,
720 - Waiting: 2.5,
721 - "Plan Ready": 2,
722 - Completed: 1,
723 -};
724 -
681 type ThreadStatusInput = Pick<
682 SidebarThreadSummary,
683 | "hasActionableProposedPlan"
@@ -1254,24 +1210,6 @@ export function resolveThreadStatusPill(input: {
1210 return null;
1211 }
1212
1257 -export function resolveProjectStatusIndicator(
1258 - statuses: ReadonlyArray<ThreadStatusPill | null>,
1259 -): ThreadStatusPill | null {
1260 - let highestPriorityStatus: ThreadStatusPill | null = null;
1261 -
1262 - for (const status of statuses) {
1263 - if (status === null) continue;
1264 - if (
1265 - highestPriorityStatus === null ||
1266 - THREAD_STATUS_PRIORITY[status.label] > THREAD_STATUS_PRIORITY[highestPriorityStatus.label]
1267 - ) {
1268 - highestPriorityStatus = status;
1269 - }
1270 - }
1271 -
1272 - return highestPriorityStatus;
1273 -}
1274 -
1213 export function getFallbackThreadIdAfterDelete<
1214 T extends Pick<Thread, "id" | "projectId" | "createdAt" | "updatedAt"> & ThreadSortInput,
1215 >(input: {
@@ -1340,29 +1278,6 @@ function sortProjectsByActivity<TProject extends SidebarProject>(
1278 .map(({ project }) => project);
1279 }
1280
1343 -export function sortProjectsForSidebar<
1344 - TProject extends SidebarProject,
1345 - TThread extends Pick<Thread, "projectId" | "createdAt" | "updatedAt"> & ThreadSortInput,
1346 ->(
1347 - projects: readonly TProject[],
1348 - threads: readonly TThread[],
1349 - sortOrder: SidebarProjectSortOrder,
1350 -): TProject[] {
1351 - const threadsByProjectId = new Map<string, TThread[]>();
1352 - for (const thread of threads) {
1353 - const existing = threadsByProjectId.get(thread.projectId) ?? [];
1354 - existing.push(thread);
1355 - threadsByProjectId.set(thread.projectId, existing);
1356 - }
1357 -
1358 - return sortProjectsByActivity(
1359 - projects,
1360 - sortOrder,
1361 - (project) => threadsByProjectId.get(project.id) ?? [],
1362 - (left, right) => left.title.localeCompare(right.title) || left.id.localeCompare(right.id),
1363 - );
1364 -}
1365 -
1281 export function sortLogicalProjectsForSidebar<
1282 TProject extends LogicalSidebarProject,
1283 TThread extends ScopedSidebarThread,