TypeScript
test: remove unreachable sidebar helper suites (#26920)
t3-code-bot[bot]f2dd1a4468aa
diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.tsindex fde82414afa..669c805492b 100644--- a/apps/web/src/components/Sidebar.logic.test.ts+++ b/apps/web/src/components/Sidebar.logic.test.ts@@ -2,12 +2,11 @@ import { presentThreadShell } from "@t3tools/client-runtime/state/models";import { isThreadWorking as isSidebarThreadWorking } from "@t3tools/client-runtime/state/thread-inbox";import * as DateTime from "effect/DateTime";import { deriveActiveWorkStartedAt } from "../session-logic.ts";-import { describe, expect, it, vi } from "vite-plus/test";+import { describe, expect, it } from "vite-plus/test";import * as Cause from "effect/Cause";import { AsyncResult } from "effect/reactivity";import {shouldCreateNewThreadInCurrentProject,- archiveSelectedThreadEntries,deleteSelectedThreadEntries,getFallbackThreadIdAfterDelete,hasUnseenCompletion,@@ -16,7 +15,6 @@ import {isSidebarEnvironmentDisconnected,orderItemsByPreferredIds,pinOrderKeyBetween,- resolveProjectStatusIndicator,resolveSidebarSweepKeys,resolveSidebarThreadStatus,resolveThreadStatusPill,@@ -28,7 +26,6 @@ import {planSidebarThreadDrop,resolveSidebarReorderableThreadKeys,sortPinnedThreadsForSidebar,- sortProjectsForSidebar,sortScopedProjectsForSidebar,sortSidebarV2ProjectGroups,shouldNavigateAfterThreadPark,@@ -140,43 +137,6 @@ describe("deleteSelectedThreadEntries", () => {});});-describe("archiveSelectedThreadEntries", () => {- const entries = [{ threadKey: "one" }, { threadKey: "two" }, { threadKey: "three" }] as const;- const success = { _tag: "Success" } as const;- const failure = { _tag: "Failure" } as const;-- it("stops at a mutation failure and retains prior successes", async () => {- const archive = vi.fn(async (entry: (typeof entries)[number], onArchived: () => void) => {- if (entry.threadKey === "two") return failure;- onArchived();- return success;- });- const outcome = await archiveSelectedThreadEntries({ entries, archive });-- expect(archive).toHaveBeenCalledTimes(2);- expect(outcome).toEqual({- archivedThreadKeys: ["one"],- mutationFailure: failure,- followupFailures: [],- });- });-- it("continues after a post-archive failure", async () => {- const archive = vi.fn(async (entry: (typeof entries)[number], onArchived: () => void) => {- onArchived();- return entry.threadKey === "two" ? failure : success;- });- const outcome = await archiveSelectedThreadEntries({ entries, archive });-- expect(archive).toHaveBeenCalledTimes(3);- expect(outcome).toEqual({- archivedThreadKeys: ["one", "two", "three"],- mutationFailure: null,- followupFailures: [failure],- });- });-});-describe("sidebar thread lineage helpers", () => {it("maps an open subagent to its nearest visible ancestor's sidebar row", () => {const environmentId = EnvironmentId.make("environment-row");@@ -589,40 +549,6 @@ describe("resolveThreadStatusPill", () => {});});-describe("resolveProjectStatusIndicator", () => {- it("ranks waiting below active work and above plan-ready", () => {- const waiting = {- label: "Waiting" as const,- colorClass: "text-sidebar-muted-foreground",- dotClass: "bg-sidebar-muted-foreground",- pulse: false,- };-- expect(- resolveProjectStatusIndicator([- waiting,- {- label: "Working",- colorClass: "text-sky-600",- dotClass: "bg-sky-500",- pulse: true,- },- ]),- ).toMatchObject({ label: "Working" });- expect(- resolveProjectStatusIndicator([- {- label: "Plan Ready",- colorClass: "text-violet-600",- dotClass: "bg-violet-500",- pulse: false,- },- waiting,- ]),- ).toMatchObject({ label: "Waiting" });- });-});-function makeProject(overrides: Partial<Project> = {}): Project {const { defaultModelSelection, ...rest } = overrides;return {@@ -703,54 +629,6 @@ describe("getFallbackThreadIdAfterDelete", () => {expect(fallbackThreadId).toBe(ThreadId.make("thread-next"));});});-describe("sortProjectsForSidebar", () => {- it("sorts projects by the most recent user message across their threads", () => {- const projects = [- makeProject({ id: ProjectId.make("project-1"), title: "Older project" }),- makeProject({ id: ProjectId.make("project-2"), title: "Newer project" }),- ];- const threads = [- makeThread({- projectId: ProjectId.make("project-1"),- updatedAt: "2026-03-09T10:20:00.000Z",- messages: [- {- id: "message-1" as never,- role: "user",- text: "older project user message",- runId: null,- createdAt: "2026-03-09T10:01:00.000Z",- updatedAt: "2026-03-09T10:01:00.000Z",- streaming: false,- },- ],- }),- makeThread({- id: ThreadId.make("thread-2"),- projectId: ProjectId.make("project-2"),- updatedAt: "2026-03-09T10:05:00.000Z",- messages: [- {- id: "message-2" as never,- role: "user",- text: "newer project user message",- runId: null,- createdAt: "2026-03-09T10:05:00.000Z",- updatedAt: "2026-03-09T10:05:00.000Z",- streaming: false,- },- ],- }),- ];-- const sorted = sortProjectsForSidebar(projects, threads, "updated_at");-- expect(sorted.map((project) => project.id)).toEqual([- ProjectId.make("project-2"),- ProjectId.make("project-1"),- ]);- });-});describe("sortScopedProjectsForSidebar", () => {it("keeps identical project ids in different environments separate", () => {diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.tsindex 0f51d231d33..55cf694c2b7 100644--- a/apps/web/src/components/Sidebar.logic.ts+++ b/apps/web/src/components/Sidebar.logic.ts@@ -587,38 +587,6 @@ export async function deleteSelectedThreadEntries<return { deletedThreadKeys, firstFailure };}-export async function archiveSelectedThreadEntries<- TEntry extends { readonly threadKey: string },- TResult extends { readonly _tag: "Success" | "Failure" },->(input: {- entries: readonly TEntry[];- archive: (entry: TEntry, onArchived: () => void) => Promise<TResult>;-}): Promise<{- archivedThreadKeys: readonly string[];- mutationFailure: Extract<TResult, { readonly _tag: "Failure" }> | null;- followupFailures: readonly Extract<TResult, { readonly _tag: "Failure" }>[];-}> {- const archivedThreadKeys: string[] = [];- const followupFailures: Extract<TResult, { readonly _tag: "Failure" }>[] = [];-- for (const entry of input.entries) {- let didArchive = false;- const result = await input.archive(entry, () => {- didArchive = true;- });- if (didArchive || result._tag === "Success") archivedThreadKeys.push(entry.threadKey);- if (result._tag === "Success") continue;- const failure = result as Extract<TResult, { readonly _tag: "Failure" }>;- if (didArchive) {- followupFailures.push(failure);- continue;- }- return { archivedThreadKeys, mutationFailure: failure, followupFailures };- }-- return { archivedThreadKeys, mutationFailure: null, followupFailures };-}-export function isSidebarHiddenThread(thread: Pick<SidebarThreadSummary, "lineage">): boolean {return !isListedThreadLineage(thread.lineage);}@@ -710,18 +678,6 @@ export interface ThreadStatusPill {pulse: boolean;}-const THREAD_STATUS_PRIORITY: Record<ThreadStatusPill["label"], number> = {- "Pending Approval": 5,- "Awaiting Input": 4,- "Guest Request": 3.75,- Failed: 3.5,- Working: 3,- Connecting: 3,- Waiting: 2.5,- "Plan Ready": 2,- Completed: 1,-};-type ThreadStatusInput = Pick<SidebarThreadSummary,| "hasActionableProposedPlan"@@ -1254,24 +1210,6 @@ export function resolveThreadStatusPill(input: {return null;}-export function resolveProjectStatusIndicator(- statuses: ReadonlyArray<ThreadStatusPill | null>,-): ThreadStatusPill | null {- let highestPriorityStatus: ThreadStatusPill | null = null;-- for (const status of statuses) {- if (status === null) continue;- if (- highestPriorityStatus === null ||- THREAD_STATUS_PRIORITY[status.label] > THREAD_STATUS_PRIORITY[highestPriorityStatus.label]- ) {- highestPriorityStatus = status;- }- }-- return highestPriorityStatus;-}-export function getFallbackThreadIdAfterDelete<T extends Pick<Thread, "id" | "projectId" | "createdAt" | "updatedAt"> & ThreadSortInput,>(input: {@@ -1340,29 +1278,6 @@ function sortProjectsByActivity<TProject extends SidebarProject>(.map(({ project }) => project);}-export function sortProjectsForSidebar<- TProject extends SidebarProject,- TThread extends Pick<Thread, "projectId" | "createdAt" | "updatedAt"> & ThreadSortInput,->(- projects: readonly TProject[],- threads: readonly TThread[],- sortOrder: SidebarProjectSortOrder,-): TProject[] {- const threadsByProjectId = new Map<string, TThread[]>();- for (const thread of threads) {- const existing = threadsByProjectId.get(thread.projectId) ?? [];- existing.push(thread);- threadsByProjectId.set(thread.projectId, existing);- }-- return sortProjectsByActivity(- projects,- sortOrder,- (project) => threadsByProjectId.get(project.id) ?? [],- (left, right) => left.title.localeCompare(right.title) || left.id.localeCompare(right.id),- );-}-export function sortLogicalProjectsForSidebar<TProject extends LogicalSidebarProject,TThread extends ScopedSidebarThread,