Open History to see the last commit
1import { presentThreadShell } from "@t3tools/client-runtime/state/models";
2import * as DateTime from "effect/DateTime";
3import { deriveActiveWorkStartedAt } from "../session-logic.ts";
4import { describe, expect, it, vi } from "vite-plus/test";
5import * as Cause from "effect/Cause";
6import { AsyncResult } from "effect/reactivity";
7import {
8 archiveSelectedThreadEntries,
9 deleteSelectedThreadEntries,
10 getFallbackThreadIdAfterDelete,
11 hasUnseenCompletion,
12 resolveSidebarRowThreadId,
13 isSidebarThreadWorking,
14 orderItemsByPreferredIds,
15 pinOrderKeyBetween,
16 resolveProjectStatusIndicator,
17 resolveSidebarSweepKeys,
18 resolveSidebarThreadStatus,
19 resolveSidebarV2TopStatus,
20 resolveThreadStatusPill,
21 resolveWorkingStartedAt,
22 searchSidebarThreads,
23 shouldRecedeSidebarThread,
24 sortInboxThreadsByReturn,
25 resolveSidebarDropTarget,
26 planSidebarThreadDrop,
27 sortPinnedThreadsForSidebar,
28 sortProjectsForSidebar,
29 sortScopedProjectsForSidebar,
30 sortSidebarV2ProjectGroups,
31 shouldNavigateAfterThreadPark,
32 type SidebarListItem,
33 type SidebarListMarker,
34 type SidebarSection,
35 resolveSidebarDropVerb,
36} from "./Sidebar.logic";
37import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";
38import { EnvironmentId, ProjectId, ProviderInstanceId, RunId, ThreadId } from "@t3tools/contracts";
39
40import {
41 DEFAULT_INTERACTION_MODE,
42 DEFAULT_RUNTIME_MODE,
43 type Project,
44 type Thread,
45} from "../types";
46import { makeThreadFixture, type ThreadFixtureOverrides } from "../test-fixtures";
47import {
48 completeSidebarRouteReveal,
49 pendingSidebarRouteReveal,
50 resolveSidebarRouteReveal,
51} from "./sidebar/routeReveal";
52
53const localEnvironmentId = EnvironmentId.make("environment-local");
54
55describe("deleteSelectedThreadEntries", () => {
56 const entries = [{ threadKey: "one" }, { threadKey: "two" }, { threadKey: "three" }] as const;
57 const success = AsyncResult.success(undefined);
58 const failure = AsyncResult.failure(Cause.fail(new Error("Delete failed")));
59 const interrupted = AsyncResult.failure(Cause.interrupt());
60
61 it("waits for each delete and excludes only earlier successes from worktree checks", async () => {
62 let resolveDelete!: (result: typeof success) => void;
63 const pendingDelete = new Promise<typeof success>((resolve) => {
64 resolveDelete = resolve;
65 });
66 const worktreeChecks: { threadKey: string; deletedThreadKeys: string[] }[] = [];
67 const deletion = deleteSelectedThreadEntries({
68 entries,
69 delete: async ({ threadKey }, deletedThreadKeys) => {
70 worktreeChecks.push({ threadKey, deletedThreadKeys: [...deletedThreadKeys] });
71 return threadKey === "one" ? pendingDelete : success;
72 },
73 });
74
75 expect(worktreeChecks).toEqual([{ threadKey: "one", deletedThreadKeys: [] }]);
76 resolveDelete(success);
77 const outcome = await deletion;
78
79 expect(worktreeChecks).toEqual([
80 { threadKey: "one", deletedThreadKeys: [] },
81 { threadKey: "two", deletedThreadKeys: ["one"] },
82 { threadKey: "three", deletedThreadKeys: ["one", "two"] },
83 ]);
84 expect(outcome).toEqual({
85 deletedThreadKeys: new Set(["one", "two", "three"]),
86 firstFailure: null,
87 });
88 });
89
90 it("continues after ordinary failures and keeps the first failure", async () => {
91 const laterFailure = AsyncResult.failure(Cause.fail(new Error("Later failure")));
92 const deletedKeysAtLastEntry: string[][] = [];
93 const outcome = await deleteSelectedThreadEntries({
94 entries: [...entries, { threadKey: "four" }],
95 delete: async ({ threadKey }, deletedThreadKeys) => {
96 if (threadKey === "one") return failure;
97 if (threadKey === "three") return laterFailure;
98 if (threadKey === "four") deletedKeysAtLastEntry.push([...deletedThreadKeys]);
99 return success;
100 },
101 });
102
103 expect(deletedKeysAtLastEntry).toEqual([["two"]]);
104 expect(outcome).toEqual({
105 deletedThreadKeys: new Set(["two", "four"]),
106 firstFailure: failure,
107 });
108 });
109
110 it.each([
111 { firstResult: success, deletedThreadKeys: new Set(["one"]), firstFailure: null },
112 { firstResult: failure, deletedThreadKeys: new Set<string>(), firstFailure: failure },
113 ])("stops on interruption and preserves earlier results %#", async (testCase) => {
114 const attemptedThreadKeys: string[] = [];
115 const outcome = await deleteSelectedThreadEntries({
116 entries,
117 delete: async ({ threadKey }) => {
118 attemptedThreadKeys.push(threadKey);
119 return threadKey === "one" ? testCase.firstResult : interrupted;
120 },
121 });
122
123 expect(attemptedThreadKeys).toEqual(["one", "two"]);
124 expect(outcome).toEqual({
125 deletedThreadKeys: testCase.deletedThreadKeys,
126 firstFailure: testCase.firstFailure,
127 });
128 });
129});
130
131describe("archiveSelectedThreadEntries", () => {
132 const entries = [{ threadKey: "one" }, { threadKey: "two" }, { threadKey: "three" }] as const;
133 const success = { _tag: "Success" } as const;
134 const failure = { _tag: "Failure" } as const;
135
136 it("stops at a mutation failure and retains prior successes", async () => {
137 const archive = vi.fn(async (entry: (typeof entries)[number], onArchived: () => void) => {
138 if (entry.threadKey === "two") return failure;
139 onArchived();
140 return success;
141 });
142 const outcome = await archiveSelectedThreadEntries({ entries, archive });
143
144 expect(archive).toHaveBeenCalledTimes(2);
145 expect(outcome).toEqual({
146 archivedThreadKeys: ["one"],
147 mutationFailure: failure,
148 followupFailures: [],
149 });
150 });
151
152 it("continues after a post-archive failure", async () => {
153 const archive = vi.fn(async (entry: (typeof entries)[number], onArchived: () => void) => {
154 onArchived();
155 return entry.threadKey === "two" ? failure : success;
156 });
157 const outcome = await archiveSelectedThreadEntries({ entries, archive });
158
159 expect(archive).toHaveBeenCalledTimes(3);
160 expect(outcome).toEqual({
161 archivedThreadKeys: ["one", "two", "three"],
162 mutationFailure: null,
163 followupFailures: [failure],
164 });
165 });
166});
167
168describe("sidebar thread lineage helpers", () => {
169 it("maps an open subagent to its nearest visible ancestor's sidebar row", () => {
170 const environmentId = EnvironmentId.make("environment-row");
171 const otherEnvironmentId = EnvironmentId.make("environment-other");
172 const subagentOf = (id: string, parentId: ThreadId, environment = environmentId) =>
173 makeThreadFixture({
174 id: ThreadId.make(id),
175 environmentId: environment,
176 lineage: {
177 rootThreadId: parentId,
178 parentThreadId: parentId,
179 relationshipToParent: "subagent",
180 },
181 });
182 const root = makeThreadFixture({ id: ThreadId.make("thread-root"), environmentId });
183 const fork = makeThreadFixture({
184 id: ThreadId.make("thread-fork"),
185 environmentId,
186 lineage: {
187 rootThreadId: root.id,
188 parentThreadId: root.id,
189 relationshipToParent: "fork",
190 },
191 });
192 const child = subagentOf("thread-child", root.id);
193 const grandchild = subagentOf("thread-grandchild", child.id);
194 const forkChild = subagentOf("thread-fork-child", fork.id);
195 const orphan = subagentOf("thread-orphan", ThreadId.make("thread-missing"));
196 const elsewhere = subagentOf("thread-elsewhere", root.id, otherEnvironmentId);
197 const threads = [root, fork, child, grandchild, forkChild, orphan, elsewhere];
198
199 expect(resolveSidebarRowThreadId(child.id, environmentId, threads)).toBe(root.id);
200 expect(resolveSidebarRowThreadId(grandchild.id, environmentId, threads)).toBe(root.id);
201 expect(resolveSidebarRowThreadId(forkChild.id, environmentId, threads)).toBe(fork.id);
202 expect(resolveSidebarRowThreadId(elsewhere.id, otherEnvironmentId, threads)).toBe(elsewhere.id);
203 expect(resolveSidebarRowThreadId(orphan.id, environmentId, threads)).toBe(orphan.id);
204 const loopA = subagentOf("thread-loop-a", ThreadId.make("thread-loop-b"));
205 const loopB = subagentOf("thread-loop-b", loopA.id);
206 expect(resolveSidebarRowThreadId(loopA.id, environmentId, [loopA, loopB])).toBe(loopA.id);
207 });
208});
209
210function makeLatestRun(overrides?: {
211 completedAt?: string | null;
212 startedAt?: string | null;
213}): NonNullable<Thread["latestRun"]> {
214 return {
215 runId: "turn-1" as never,
216 status: "completed",
217 assistantMessageId: null,
218 requestedAt: "2026-03-09T10:00:00.000Z",
219 startedAt:
220 overrides?.startedAt !== undefined ? overrides.startedAt : "2026-03-09T10:00:00.000Z",
221 completedAt:
222 overrides?.completedAt !== undefined ? overrides.completedAt : "2026-03-09T10:05:00.000Z",
223 };
224}
225
226describe("orderItemsByPreferredIds", () => {
227 it("resolves legacy preference aliases without materializing project state", () => {
228 const ordered = orderItemsByPreferredIds({
229 items: [
230 { id: "physical-a", cwd: "/work/a" },
231 { id: "physical-b", cwd: "/work/b" },
232 { id: "physical-c", cwd: "/work/c" },
233 ],
234 preferredIds: ["legacy:/work/c", "legacy:/work/a"],
235 getId: (project) => project.id,
236 getPreferenceIds: (project) => [project.id, `legacy:${project.cwd}`],
237 });
238
239 expect(ordered.map((project) => project.id)).toEqual([
240 "physical-c",
241 "physical-a",
242 "physical-b",
243 ]);
244 });
245});
246
247describe("resolveSidebarThreadStatus", () => {
248 const runtime = {
249 status: "running" as const,
250 activeRunId: null,
251 providerInstanceId: ProviderInstanceId.make("codex"),
252 providerName: "Codex",
253 lastError: null,
254 updatedAt: "2026-03-09T10:00:00.000Z",
255 };
256
257 const idle = { hasPendingApprovals: false, hasPendingUserInput: false, runtime: null };
258
259 it("prioritizes awaiting input over a running runtime, below approval", () => {
260 expect(
261 resolveSidebarThreadStatus({
262 ...idle,
263 hasPendingUserInput: true,
264 runtime,
265 blockedOnThreadWait: true,
266 }),
267 ).toBe("input");
268 expect(
269 resolveSidebarThreadStatus({
270 ...idle,
271 hasPendingApprovals: true,
272 hasPendingUserInput: true,
273 blockedOnThreadWait: true,
274 runtime,
275 }),
276 ).toBe("approval");
277 });
278
279 it("shows a waiting guest message as a Request, below the agent's own requests", () => {
280 expect(resolveSidebarThreadStatus({ ...idle, pendingGuestMessageCount: 1, runtime })).toBe(
281 "request",
282 );
283 expect(
284 resolveSidebarThreadStatus({
285 ...idle,
286 hasPendingUserInput: true,
287 pendingGuestMessageCount: 1,
288 }),
289 ).toBe("input");
290 });
291
292 it("keeps usage-limit stops Limited and visible until the thread recovers", () => {
293 const limited = {
294 ...runtime,
295 status: "failed" as const,
296 lastError: "Plan limit reached",
297 lastErrorClass: "usage_limit" as const,
298 };
299 expect(resolveSidebarThreadStatus({ ...idle, runtime: limited })).toBe("limited");
300 expect(
301 resolveSidebarThreadStatus({ ...idle, runtime: { ...limited, status: "running" } }),
302 ).toBe("working");
303 expect(
304 resolveSidebarThreadStatus({ ...idle, runtime: { ...limited, status: "completed" } }),
305 ).toBe("ready");
306 expect(resolveSidebarV2TopStatus({ status: "limited", isUnread: false, isWoke: false })).toBe(
307 "limited",
308 );
309 expect(
310 shouldRecedeSidebarThread({
311 status: "limited",
312 isUnread: false,
313 isWoke: false,
314 isActive: false,
315 isSelected: false,
316 }),
317 ).toBe(false);
318 });
319
320 it("reports failed only while the latest run failed", () => {
321 expect(
322 resolveSidebarThreadStatus({
323 ...idle,
324 runtime: { ...runtime, status: "failed" as const, lastError: "boom" },
325 }),
326 ).toBe("failed");
327 expect(
328 resolveSidebarThreadStatus({
329 ...idle,
330 runtime: { ...runtime, status: "completed" as const, lastError: "persisted" },
331 }),
332 ).toBe("ready");
333 expect(
334 resolveSidebarThreadStatus({
335 ...idle,
336 runtime: { ...runtime, status: "idle" as const, lastError: "persisted" },
337 }),
338 ).toBe("waiting");
339 });
340});
341
342describe("searchSidebarThreads", () => {
343 const searchThread = (id: string, title: string, latestUserMessageAt: string) => ({
344 environmentId: localEnvironmentId,
345 id: ThreadId.make(id),
346 title,
347 branch: null,
348 createdAt: "2026-01-01T00:00:00.000Z",
349 updatedAt: latestUserMessageAt,
350 latestUserMessageAt,
351 opens: null,
352 });
353 const threads = [
354 searchThread("thread-1", "Fix workspace search", "2026-10-20T00:00:00.000Z"),
355 searchThread("thread-2", "Review providers", "2026-10-22T00:00:00.000Z"),
356 searchThread("thread-3", "WORKTREE cleanup", "2026-09-01T00:00:00.000Z"),
357 searchThread("thread-4", "Homework notes", "2026-10-22T00:00:00.000Z"),
358 ];
359 const now = Date.parse("2026-10-23T00:00:00.000Z");
360 const contentKeys = (...ids: ReadonlyArray<string>) =>
361 new Set(
362 ids.map((id) =>
363 threadSearchMatchKey({ environmentId: localEnvironmentId, threadId: ThreadId.make(id) }),
364 ),
365 );
366
367 it("ranks word matches by recent use, then lists message matches once", () => {
368 expect(searchSidebarThreads(threads, "work", contentKeys("thread-1", "thread-2"), now)).toEqual(
369 {
370 titleMatches: [threads[0], threads[2], threads[3]],
371 contentMatches: [threads[1]],
372 },
373 );
374 });
375});
376
377describe("resolveWorkingStartedAt", () => {
378 const runtime = {
379 status: "running" as const,
380 providerName: "Codex",
381 providerInstanceId: ProviderInstanceId.make("codex"),
382 activeRunId: RunId.make("turn-1"),
383 lastError: null,
384 updatedAt: "2026-03-09T10:02:00.000Z",
385 };
386
387 it("does not invent a start from activity updates when the newest run completed", () => {
388 expect(
389 resolveWorkingStartedAt({
390 latestRun: makeLatestRun(),
391 runtime,
392 }),
393 ).toBeNull();
394 });
395
396 it.each(["queued", "cancelled"] as const)(
397 "shares the detail timer when a newer run is %s",
398 (status) => {
399 const activityStartedAt = "2026-03-09T10:00:00.000Z";
400 const latestRun = {
401 ...makeLatestRun(),
402 runId: RunId.make("newer-run"),
403 status,
404 startedAt: null,
405 completedAt: status === "queued" ? null : "2026-03-09T10:05:00.000Z",
406 };
407 for (const updatedAt of ["2026-03-09T10:30:00.000Z", "2026-03-09T10:50:00.000Z"]) {
408 const activeRuntime = { ...runtime, updatedAt, activityStartedAt };
409 expect(resolveWorkingStartedAt({ latestRun, runtime: activeRuntime })).toBe(
410 activityStartedAt,
411 );
412 expect(deriveActiveWorkStartedAt(latestRun, activeRuntime, updatedAt)).toBe(
413 activityStartedAt,
414 );
415 }
416 expect(
417 deriveActiveWorkStartedAt(
418 latestRun,
419 { ...runtime, activityStartedAt: null },
420 "2026-03-09T10:50:00.000Z",
421 ),
422 ).toBeNull();
423 },
424 );
425});
426
427describe("resolveThreadStatusPill", () => {
428 const baseThread = {
429 hasActionableProposedPlan: false,
430 hasPendingApprovals: false,
431 hasPendingUserInput: false,
432 interactionMode: "plan" as const,
433 latestRun: null,
434 lastVisitedAt: undefined,
435 runtime: {
436 status: "running" as const,
437 providerName: "Codex",
438 providerInstanceId: ProviderInstanceId.make("codex"),
439 activeRunId: "turn-1" as never,
440 lastError: null,
441 updatedAt: "2026-03-09T10:00:00.000Z",
442 },
443 };
444
445 it("shows an active thread wait without a pulse and resumes Working when it ends", () => {
446 const blocked = { ...baseThread, blockedOnThreadWait: true };
447 expect(resolveSidebarThreadStatus(blocked)).toBe("waiting");
448 expect(resolveThreadStatusPill({ thread: blocked })).toMatchObject({
449 label: "Waiting",
450 pulse: false,
451 });
452
453 const resumed = { ...blocked, blockedOnThreadWait: false };
454 expect(resolveSidebarThreadStatus(resumed)).toBe("working");
455 expect(resolveThreadStatusPill({ thread: resumed })).toMatchObject({
456 label: "Working",
457 pulse: true,
458 });
459 });
460
461 it("shows waiting for an idle thread with pending background tasks", () => {
462 expect(
463 resolveThreadStatusPill({
464 thread: {
465 ...baseThread,
466 pendingBackgroundTasks: [
467 { taskId: "bg-1", description: "Watch build", kind: "monitor", awaited: true },
468 ],
469 runtime: {
470 ...baseThread.runtime,
471 status: "idle",
472 activeRunId: null,
473 },
474 },
475 }),
476 ).toMatchObject({
477 label: "Waiting",
478 colorClass: "text-sidebar-muted-foreground",
479 dotClass: "bg-sidebar-muted-foreground",
480 pulse: false,
481 });
482 });
483
484 it("shows plan ready when a settled plan turn has a proposed plan ready for follow-up", () => {
485 expect(
486 resolveThreadStatusPill({
487 thread: {
488 ...baseThread,
489 hasActionableProposedPlan: true,
490 latestRun: makeLatestRun(),
491 runtime: {
492 ...baseThread.runtime,
493 status: "completed",
494 activeRunId: null,
495 },
496 },
497 }),
498 ).toMatchObject({ label: "Plan Ready", pulse: false });
499 });
500
501 it("does not manufacture completed state without a client visit marker", () => {
502 expect(
503 resolveThreadStatusPill({
504 thread: {
505 ...baseThread,
506 latestRun: makeLatestRun(),
507 runtime: {
508 ...baseThread.runtime,
509 status: "completed",
510 activeRunId: null,
511 },
512 },
513 }),
514 ).toBeNull();
515 });
516
517 it("shows completed when there is an unseen completion and no active blocker", () => {
518 expect(
519 resolveThreadStatusPill({
520 thread: {
521 ...baseThread,
522 interactionMode: "default",
523 latestRun: makeLatestRun(),
524 lastVisitedAt: "2026-03-09T10:04:00.000Z",
525 runtime: {
526 ...baseThread.runtime,
527 status: "completed",
528 activeRunId: null,
529 },
530 },
531 }),
532 ).toMatchObject({ label: "Completed", pulse: false });
533 });
534
535 it("shows failed, not completed, when the unseen run failed", () => {
536 expect(
537 resolveThreadStatusPill({
538 thread: {
539 ...baseThread,
540 interactionMode: "default",
541 latestRun: { ...makeLatestRun(), status: "failed" },
542 lastVisitedAt: "2026-03-09T10:04:00.000Z",
543 runtime: {
544 ...baseThread.runtime,
545 status: "failed",
546 activeRunId: null,
547 lastError: "Provider turn failed.",
548 },
549 },
550 }),
551 ).toMatchObject({ label: "Failed", pulse: false });
552 });
553
554 it("shows failed, not plan ready, when a plan run proposed a plan and then failed", () => {
555 expect(
556 resolveThreadStatusPill({
557 thread: {
558 ...baseThread,
559 hasActionableProposedPlan: true,
560 latestRun: { ...makeLatestRun(), status: "failed" },
561 lastVisitedAt: "2026-03-09T10:04:00.000Z",
562 runtime: { ...baseThread.runtime, status: "failed", activeRunId: null },
563 },
564 }),
565 ).toMatchObject({ label: "Failed" });
566 });
567
568 it("drops the failed pill once the failure has been seen", () => {
569 expect(
570 resolveThreadStatusPill({
571 thread: {
572 ...baseThread,
573 interactionMode: "default",
574 latestRun: { ...makeLatestRun(), status: "failed" },
575 lastVisitedAt: "2026-03-09T10:06:00.000Z",
576 runtime: { ...baseThread.runtime, status: "failed", activeRunId: null },
577 },
578 }),
579 ).toBeNull();
580 });
581});
582
583describe("resolveProjectStatusIndicator", () => {
584 it("ranks waiting below active work and above plan-ready", () => {
585 const waiting = {
586 label: "Waiting" as const,
587 colorClass: "text-sidebar-muted-foreground",
588 dotClass: "bg-sidebar-muted-foreground",
589 pulse: false,
590 };
591
592 expect(
593 resolveProjectStatusIndicator([
594 waiting,
595 {
596 label: "Working",
597 colorClass: "text-sky-600",
598 dotClass: "bg-sky-500",
599 pulse: true,
600 },
601 ]),
602 ).toMatchObject({ label: "Working" });
603 expect(
604 resolveProjectStatusIndicator([
605 {
606 label: "Plan Ready",
607 colorClass: "text-violet-600",
608 dotClass: "bg-violet-500",
609 pulse: false,
610 },
611 waiting,
612 ]),
613 ).toMatchObject({ label: "Waiting" });
614 });
615});
616
617function makeProject(overrides: Partial<Project> = {}): Project {
618 const { defaultModelSelection, ...rest } = overrides;
619 return {
620 id: ProjectId.make("project-1"),
621 environmentId: localEnvironmentId,
622 title: "Project",
623 workspaceRoot: "/tmp/project",
624 repositoryIdentity: null,
625 defaultModelSelection: {
626 instanceId: ProviderInstanceId.make("codex"),
627 model: "gpt-5.4",
628 ...defaultModelSelection,
629 },
630 createdAt: "2026-03-09T10:00:00.000Z",
631 updatedAt: "2026-03-09T10:00:00.000Z",
632 scripts: [],
633 ...rest,
634 };
635}
636
637function makeThread(overrides: ThreadFixtureOverrides = {}): Thread {
638 return makeThreadFixture({
639 id: ThreadId.make("thread-1"),
640 environmentId: localEnvironmentId,
641 projectId: ProjectId.make("project-1"),
642 title: "Thread",
643 modelSelection: {
644 instanceId: ProviderInstanceId.make("codex"),
645 model: "gpt-5.4",
646 ...overrides?.modelSelection,
647 },
648 runtimeMode: DEFAULT_RUNTIME_MODE,
649 interactionMode: DEFAULT_INTERACTION_MODE,
650 runtime: null,
651 messages: [],
652 proposedPlans: [],
653 createdAt: "2026-03-09T10:00:00.000Z",
654 archivedAt: null,
655 settledOverride: null,
656 settledAt: null,
657 deletedAt: null,
658 updatedAt: "2026-03-09T10:00:00.000Z",
659 latestRun: null,
660 branch: null,
661 worktreePath: null,
662 ...overrides,
663 });
664}
665
666describe("getFallbackThreadIdAfterDelete", () => {
667 it("skips other threads being deleted in the same action", () => {
668 const fallbackThreadId = getFallbackThreadIdAfterDelete({
669 threads: [
670 makeThread({
671 id: ThreadId.make("thread-active"),
672 projectId: ProjectId.make("project-1"),
673 createdAt: "2026-03-09T10:05:00.000Z",
674 messages: [],
675 }),
676 makeThread({
677 id: ThreadId.make("thread-newest"),
678 projectId: ProjectId.make("project-1"),
679 createdAt: "2026-03-09T10:10:00.000Z",
680 messages: [],
681 }),
682 makeThread({
683 id: ThreadId.make("thread-next"),
684 projectId: ProjectId.make("project-1"),
685 createdAt: "2026-03-09T10:07:00.000Z",
686 messages: [],
687 }),
688 ],
689 deletedThreadId: ThreadId.make("thread-active"),
690 deletedThreadIds: new Set([ThreadId.make("thread-active"), ThreadId.make("thread-newest")]),
691 sortOrder: "created_at",
692 });
693
694 expect(fallbackThreadId).toBe(ThreadId.make("thread-next"));
695 });
696});
697describe("sortProjectsForSidebar", () => {
698 it("sorts projects by the most recent user message across their threads", () => {
699 const projects = [
700 makeProject({ id: ProjectId.make("project-1"), title: "Older project" }),
701 makeProject({ id: ProjectId.make("project-2"), title: "Newer project" }),
702 ];
703 const threads = [
704 makeThread({
705 projectId: ProjectId.make("project-1"),
706 updatedAt: "2026-03-09T10:20:00.000Z",
707 messages: [
708 {
709 id: "message-1" as never,
710 role: "user",
711 text: "older project user message",
712 runId: null,
713 createdAt: "2026-03-09T10:01:00.000Z",
714 updatedAt: "2026-03-09T10:01:00.000Z",
715 streaming: false,
716 },
717 ],
718 }),
719 makeThread({
720 id: ThreadId.make("thread-2"),
721 projectId: ProjectId.make("project-2"),
722 updatedAt: "2026-03-09T10:05:00.000Z",
723 messages: [
724 {
725 id: "message-2" as never,
726 role: "user",
727 text: "newer project user message",
728 runId: null,
729 createdAt: "2026-03-09T10:05:00.000Z",
730 updatedAt: "2026-03-09T10:05:00.000Z",
731 streaming: false,
732 },
733 ],
734 }),
735 ];
736
737 const sorted = sortProjectsForSidebar(projects, threads, "updated_at");
738
739 expect(sorted.map((project) => project.id)).toEqual([
740 ProjectId.make("project-2"),
741 ProjectId.make("project-1"),
742 ]);
743 });
744});
745
746describe("sortScopedProjectsForSidebar", () => {
747 it("keeps identical project ids in different environments separate", () => {
748 const remoteEnvironmentId = EnvironmentId.make("environment-remote");
749 const sharedProjectId = ProjectId.make("shared-project");
750 const projects = [
751 makeProject({
752 environmentId: localEnvironmentId,
753 id: sharedProjectId,
754 title: "Local project",
755 }),
756 makeProject({
757 environmentId: remoteEnvironmentId,
758 id: sharedProjectId,
759 title: "Remote project",
760 }),
761 ];
762 const threads = [
763 makeThread({
764 environmentId: localEnvironmentId,
765 projectId: sharedProjectId,
766 updatedAt: "2026-03-09T10:02:00.000Z",
767 }),
768 makeThread({
769 environmentId: remoteEnvironmentId,
770 projectId: sharedProjectId,
771 updatedAt: "2026-03-09T10:10:00.000Z",
772 }),
773 ];
774
775 const sorted = sortScopedProjectsForSidebar(projects, threads, "updated_at");
776
777 expect(sorted.map((project) => project.title)).toEqual(["Remote project", "Local project"]);
778 });
779
780 it("does not use archived threads as project activity", () => {
781 const projects = [
782 makeProject({
783 id: ProjectId.make("project-visible"),
784 title: "Visible project",
785 updatedAt: "2026-03-09T10:01:00.000Z",
786 }),
787 makeProject({
788 id: ProjectId.make("project-archived"),
789 title: "Archived-only project",
790 updatedAt: "2026-03-09T10:00:00.000Z",
791 }),
792 ];
793 const threads = [
794 makeThread({
795 id: ThreadId.make("thread-visible"),
796 projectId: ProjectId.make("project-visible"),
797 updatedAt: "2026-03-09T10:02:00.000Z",
798 }),
799 makeThread({
800 id: ThreadId.make("thread-archived"),
801 projectId: ProjectId.make("project-archived"),
802 updatedAt: "2026-03-09T10:10:00.000Z",
803 archivedAt: "2026-03-09T10:11:00.000Z",
804 }),
805 ];
806
807 const sorted = sortScopedProjectsForSidebar(projects, threads, "updated_at");
808
809 expect(sorted.map((project) => project.title)).toEqual([
810 "Visible project",
811 "Archived-only project",
812 ]);
813 });
814});
815
816describe("sortSidebarV2ProjectGroups", () => {
817 it("does not let a hidden subagent thread reorder projects", () => {
818 const olderProjectId = ProjectId.make("project-older");
819 const newerProjectId = ProjectId.make("project-newer");
820 const olderRootThreadId = ThreadId.make("thread-older-root");
821 const projects = [
822 {
823 ...makeProject({ id: olderProjectId, title: "A older project" }),
824 projectKey: "logical-older",
825 memberProjectRefs: [{ environmentId: localEnvironmentId, projectId: olderProjectId }],
826 },
827 {
828 ...makeProject({ id: newerProjectId, title: "Z newer project" }),
829 projectKey: "logical-newer",
830 memberProjectRefs: [{ environmentId: localEnvironmentId, projectId: newerProjectId }],
831 },
832 ];
833 const threads = [
834 makeThread({
835 id: olderRootThreadId,
836 projectId: olderProjectId,
837 updatedAt: "2026-03-09T10:01:00.000Z",
838 }),
839 makeThread({
840 id: ThreadId.make("thread-newer-root"),
841 projectId: newerProjectId,
842 updatedAt: "2026-03-09T10:05:00.000Z",
843 }),
844 makeThread({
845 id: ThreadId.make("thread-hidden-subagent"),
846 projectId: olderProjectId,
847 updatedAt: "2026-03-09T10:10:00.000Z",
848 lineage: {
849 rootThreadId: olderRootThreadId,
850 parentThreadId: olderRootThreadId,
851 relationshipToParent: "subagent",
852 },
853 }),
854 ];
855
856 expect(
857 sortSidebarV2ProjectGroups(projects, threads, "updated_at", new Set()).map(
858 (project) => project.projectKey,
859 ),
860 ).toEqual(["logical-newer", "logical-older"]);
861 });
862});
863
864describe("pinOrderKeyBetween", () => {
865 it("stays strictly ordered under repeated top insertion", () => {
866 let head: string | null = null;
867 const keys: string[] = [];
868 for (let i = 0; i < 100; i += 1) {
869 const key: string = pinOrderKeyBetween(null, head)!;
870 expect(key).not.toBeNull();
871 if (head !== null) expect(key < head).toBe(true);
872 keys.push(key);
873 head = key;
874 }
875 expect(new Set(keys).size).toBe(100);
876 });
877
878 it("stays strictly ordered under repeated middle insertion", () => {
879 let low = pinOrderKeyBetween(null, null)!;
880 let high = pinOrderKeyBetween(low, null)!;
881 for (let i = 0; i < 100; i += 1) {
882 const key: string = pinOrderKeyBetween(low, high)!;
883 expect(low < key && key < high).toBe(true);
884 if (i % 2 === 0) low = key;
885 else high = key;
886 }
887 });
888
889 it("returns null for corrupt or out-of-order bounds instead of throwing", () => {
890 expect(pinOrderKeyBetween("z", "a")).toBeNull();
891 expect(pinOrderKeyBetween("A!", null)).toBeNull();
892 expect(pinOrderKeyBetween(null, "ma")).toBeNull();
893 expect(pinOrderKeyBetween("m", "m")).toBeNull();
894 });
895});
896
897describe("sortPinnedThreadsForSidebar", () => {
898 const pinnable = (input: { id: string; createdAt: string; pinOrderKey?: string | null }) => ({
899 id: input.id,
900 createdAt: input.createdAt,
901 pinOrderKey: input.pinOrderKey ?? null,
902 });
903
904 it("sorts keyed threads by key ahead of keyless threads in creation order", () => {
905 const sorted = sortPinnedThreadsForSidebar([
906 pinnable({ id: "keyless-old", createdAt: "2026-03-09T08:00:00.000Z" }),
907 pinnable({ id: "second", createdAt: "2026-03-09T09:00:00.000Z", pinOrderKey: "t" }),
908 pinnable({ id: "keyless-new", createdAt: "2026-03-09T12:00:00.000Z" }),
909 pinnable({ id: "first", createdAt: "2026-03-09T07:00:00.000Z", pinOrderKey: "g" }),
910 ]);
911
912 expect(sorted.map((thread) => thread.id)).toEqual([
913 "first",
914 "second",
915 "keyless-new",
916 "keyless-old",
917 ]);
918 });
919
920 it("breaks equal keys by id so raced writes render identically everywhere", () => {
921 const sorted = sortPinnedThreadsForSidebar([
922 pinnable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z", pinOrderKey: "m" }),
923 pinnable({ id: "a", createdAt: "2026-03-09T11:00:00.000Z", pinOrderKey: "m" }),
924 ]);
925
926 expect(sorted.map((thread) => thread.id)).toEqual(["a", "b"]);
927 });
928});
929
930describe("resolveSidebarSweepKeys", () => {
931 const ordered = ["a", "b", "c", "d", "blocked"];
932 const canSettle = (key: string) => key !== "blocked";
933
934 it("leaves out rows that cannot settle and rows that left the list", () => {
935 expect(resolveSidebarSweepKeys(ordered, "c", "blocked", canSettle)).toEqual(["c", "d"]);
936 expect(resolveSidebarSweepKeys(ordered, "gone", "a", canSettle)).toEqual([]);
937 });
938});
939
940describe("navigation after parking a thread", () => {
941 it.each([
942 ["settle", "settled", null, "thread", true],
943 ["settle", "active", null, "thread", false],
944 ["settle", "settled", null, "other-thread", false],
945 ["snooze", null, "2099-01-01T00:00:00.000Z", "thread", true],
946 ["snooze", null, null, "thread", false],
947 ["snooze", null, "2026-09-12T09:00:00.000Z", "thread", false],
948 ["snooze", null, "2099-01-01T00:00:00.000Z", "thread", false, true],
949 ["snooze", null, "2099-01-01T00:00:00.000Z", "other-thread", false],
950 ] as const)(
951 "%s with state %s / %s on %s navigates: %s",
952 (
953 action,
954 settledOverride,
955 snoozedUntil,
956 currentThreadKey,
957 expected,
958 hasPendingApprovals: boolean = false,
959 ) => {
960 expect(
961 shouldNavigateAfterThreadPark({
962 threadKey: "thread",
963 currentThreadKey,
964 action,
965 now: "2026-09-12T10:00:00.000Z",
966 thread: {
967 settledOverride,
968 snoozedUntil,
969 snoozedAt: null,
970 session: null,
971 latestTurn: null,
972 hasPendingApprovals,
973 hasPendingUserInput: false,
974 },
975 }),
976 ).toBe(expected);
977 },
978 );
979});
980
981describe("unseen completion with background work", () => {
982 it.each([
983 {
984 roster: "dev server",
985 task: { kind: "command" },
986 status: "ready",
987 topStatus: "done",
988 receded: false,
989 pill: "Completed",
990 },
991 {
992 roster: "dev server watchdog",
993 task: { kind: "monitor" },
994 status: "ready",
995 topStatus: "done",
996 receded: false,
997 pill: "Completed",
998 },
999 {
1000 roster: "awaited command",
1001 task: { kind: "command", awaited: true },
1002 status: "waiting",
1003 topStatus: "waiting",
1004 receded: true,
1005 pill: "Waiting",
1006 },
1007 ] as const)("presents a completed thread with a $roster roster", (expected) => {
1008 const thread = presentThreadShell(localEnvironmentId, {
1009 ...makeThreadFixture().source,
1010 latestRunId: RunId.make("run-background-completion"),
1011 status: "completed",
1012 latestRunCompletedAt: DateTime.makeUnsafe("2026-06-20T01:00:00.000Z"),
1013 lastVisitedAt: DateTime.makeUnsafe("2026-06-20T00:59:00.000Z"),
1014 pendingBackgroundTasks: [{ taskId: "background-work", ...expected.task }],
1015 });
1016 const status = resolveSidebarThreadStatus(thread);
1017 const isUnread = hasUnseenCompletion(thread);
1018
1019 expect(isUnread).toBe(true);
1020 expect(status).toBe(expected.status);
1021 expect(resolveSidebarV2TopStatus({ status, isUnread, isWoke: false })).toBe(expected.topStatus);
1022 expect(
1023 shouldRecedeSidebarThread({
1024 status,
1025 isUnread,
1026 isWoke: false,
1027 isActive: false,
1028 isSelected: false,
1029 }),
1030 ).toBe(expected.receded);
1031 expect(isSidebarThreadWorking(thread)).toBe(expected.receded);
1032 expect(resolveThreadStatusPill({ thread })).toMatchObject({ label: expected.pill });
1033 });
1034});
1035
1036describe("Working shelf (beta)", () => {
1037 const runtime = {
1038 status: "running" as const,
1039 activeRunId: null,
1040 providerInstanceId: ProviderInstanceId.make("codex"),
1041 providerName: "Codex",
1042 lastError: null,
1043 updatedAt: "2026-03-09T10:00:00.000Z",
1044 };
1045 const backgroundTask = {
1046 taskId: "bg-1",
1047 description: "Watch build",
1048 kind: "monitor" as const,
1049 awaited: true as const,
1050 };
1051 const idle = {
1052 hasActionableProposedPlan: false,
1053 hasPendingApprovals: false,
1054 hasPendingUserInput: false,
1055 interactionMode: "default" as const,
1056 latestRun: makeLatestRun(),
1057 runtime: null,
1058 };
1059 const waiting = {
1060 ...idle,
1061 runtime: { ...runtime, status: "idle" as const },
1062 pendingBackgroundTasks: [backgroundTask],
1063 };
1064
1065 it("folds away running threads and threads waiting on background work only", () => {
1066 expect(isSidebarThreadWorking({ ...idle, runtime })).toBe(true);
1067 expect(isSidebarThreadWorking(waiting)).toBe(true);
1068 expect(isSidebarThreadWorking(idle)).toBe(false);
1069 expect(isSidebarThreadWorking({ ...idle, runtime, hasPendingApprovals: true })).toBe(false);
1070 expect(isSidebarThreadWorking({ ...idle, runtime, hasPendingUserInput: true })).toBe(false);
1071 expect(
1072 isSidebarThreadWorking({
1073 ...waiting,
1074 runtime: { ...runtime, status: "failed" as const, lastError: "boom" },
1075 }),
1076 ).toBe(false);
1077 });
1078
1079 it("keeps a ready plan in the inbox while background work runs", () => {
1080 expect(
1081 isSidebarThreadWorking({
1082 ...waiting,
1083 interactionMode: "plan",
1084 hasActionableProposedPlan: true,
1085 }),
1086 ).toBe(false);
1087 });
1088
1089 describe("sortInboxThreadsByReturn", () => {
1090 const thread = (
1091 id: string,
1092 input: { createdAt: string; completedAt?: string | null; unsettledAt?: string },
1093 ) => ({
1094 id: ThreadId.make(id),
1095 environmentId: localEnvironmentId,
1096 createdAt: input.createdAt,
1097 unsettledAt: input.unsettledAt ?? null,
1098 latestRun:
1099 input.completedAt === undefined
1100 ? null
1101 : { ...makeLatestRun({ completedAt: input.completedAt }), requestedAt: input.createdAt },
1102 });
1103
1104 it("puts the thread that finished last on top, whatever its age", () => {
1105 const sorted = sortInboxThreadsByReturn([
1106 thread("new", { createdAt: "2026-03-09T11:00:00.000Z" }),
1107 thread("old-finished-now", {
1108 createdAt: "2026-03-01T09:00:00.000Z",
1109 completedAt: "2026-03-09T12:00:00.000Z",
1110 }),
1111 thread("reopened", {
1112 createdAt: "2026-03-02T09:00:00.000Z",
1113 unsettledAt: "2026-03-09T11:30:00.000Z",
1114 }),
1115 ]);
1116 expect(sorted.map((entry) => entry.id)).toEqual(["old-finished-now", "reopened", "new"]);
1117 });
1118
1119 it("counts a return the server does not stamp, like an approval request", () => {
1120 const waiting = thread("asks-approval", {
1121 createdAt: "2026-03-09T09:00:00.000Z",
1122 completedAt: null,
1123 });
1124 const finished = thread("finished", {
1125 createdAt: "2026-03-09T09:30:00.000Z",
1126 completedAt: "2026-03-09T11:00:00.000Z",
1127 });
1128 expect(sortInboxThreadsByReturn([finished, waiting]).map((entry) => entry.id)).toEqual([
1129 "finished",
1130 "asks-approval",
1131 ]);
1132 expect(
1133 sortInboxThreadsByReturn([finished, waiting], (entry) =>
1134 entry === waiting ? Date.parse("2026-03-09T11:05:00.000Z") : undefined,
1135 ).map((entry) => entry.id),
1136 ).toEqual(["asks-approval", "finished"]);
1137 });
1138 });
1139
1140 describe("dragging", () => {
1141 const marker = (name: SidebarListMarker): SidebarListItem => ({ kind: "marker", marker: name });
1142 const row = (key: string, section: SidebarSection): SidebarListItem => ({
1143 kind: "thread",
1144 key,
1145 section,
1146 });
1147 const items: readonly SidebarListItem[] = [
1148 marker("pinned-header"),
1149 row("p1", "pinned"),
1150 marker("pinned-divider"),
1151 row("a1", "active"),
1152 row("a2", "active"),
1153 marker("working-header"),
1154 row("w1", "working"),
1155 marker("settled-header"),
1156 row("s1", "settled"),
1157 ];
1158
1159 it("never drops into the Working shelf, and keeps it out of the inbox order", () => {
1160 expect(resolveSidebarDropTarget(items, "a1", "w1")).toBeNull();
1161 expect(resolveSidebarDropTarget(items, "p1", "a2")).toEqual({
1162 section: "active",
1163 pinnedOrder: [],
1164 activeOrder: ["a1", "a2", "p1"],
1165 });
1166 expect(resolveSidebarDropVerb("active", "working")).toBeNull();
1167 });
1168
1169 it.each([
1170 ["pinned", "p1"],
1171 ["active", "a2"],
1172 ["settled", "s1"],
1173 ] as const)(
1174 "does not move a Working thread into %s when its reference drag ends in the sidebar",
1175 (section, overKey) => {
1176 const target = resolveSidebarDropTarget(items, "w1", overKey);
1177 expect(target?.section).toBe(section);
1178 expect(
1179 planSidebarThreadDrop({
1180 activeKey: "w1",
1181 activeSection: "working",
1182 target: target!,
1183 pinnedOrder: ["p1"],
1184 pinnedKeysById: new Map([["p1", "m"]]),
1185 activeOrder: ["a1", "a2"],
1186 activeKeysById: new Map([
1187 ["a1", "f"],
1188 ["a2", "t"],
1189 ]),
1190 activeTimeOrdered: true,
1191 }),
1192 ).toEqual({ kind: "none" });
1193 },
1194 );
1195
1196 it("arranges the rows it can write when another row's server cannot store an order", () => {
1197 const plan = planSidebarThreadDrop({
1198 activeKey: "a2",
1199 activeSection: "active",
1200 target: {
1201 section: "active",
1202 pinnedOrder: [],
1203 activeOrder: ["offline", "a2", "a1"],
1204 },
1205 pinnedOrder: [],
1206 pinnedKeysById: new Map(),
1207 activeOrder: ["offline", "a1", "a2"],
1208 activeKeysById: new Map([
1209 ["offline", null],
1210 ["a1", null],
1211 ["a2", null],
1212 ]),
1213 activeReorderableKeys: new Set(["a1", "a2"]),
1214 });
1215 expect(plan.kind).toBe("move-active");
1216 if (plan.kind !== "move-active") return;
1217 expect(plan.assignments.map(({ id }) => id)).toEqual(["a2", "a1"]);
1218 const [a2, a1] = plan.assignments.map(({ orderKey }) => orderKey);
1219 expect(a2! < a1!).toBe(true);
1220
1221 const above = planSidebarThreadDrop({
1222 activeKey: "a2",
1223 activeSection: "active",
1224 target: { section: "active", pinnedOrder: [], activeOrder: ["a2", "offline"] },
1225 pinnedOrder: [],
1226 pinnedKeysById: new Map(),
1227 activeOrder: ["offline", "a2"],
1228 activeKeysById: new Map([
1229 ["offline", "m"],
1230 ["a2", "t"],
1231 ]),
1232 activeReorderableKeys: new Set(["a2"]),
1233 });
1234 expect(above.kind === "move-active" && above.assignments[0]!.orderKey < "m").toBe(true);
1235 });
1236
1237 it("only changes lifecycle when the inbox is time-ordered", () => {
1238 const base = {
1239 pinnedOrder: ["p1"],
1240 pinnedKeysById: new Map([["p1", "m"]]),
1241 activeOrder: ["a1", "a2"],
1242 activeKeysById: new Map([
1243 ["a1", "f"],
1244 ["a2", "t"],
1245 ]),
1246 activeTimeOrdered: true,
1247 };
1248 expect(
1249 planSidebarThreadDrop({
1250 ...base,
1251 activeKey: "a1",
1252 activeSection: "active",
1253 target: { section: "active", pinnedOrder: ["p1"], activeOrder: ["a2", "a1"] },
1254 }),
1255 ).toEqual({ kind: "none" });
1256 expect(
1257 planSidebarThreadDrop({
1258 ...base,
1259 activeKey: "p1",
1260 activeSection: "pinned",
1261 target: { section: "active", pinnedOrder: [], activeOrder: ["a1", "p1", "a2"] },
1262 }),
1263 ).toEqual({
1264 kind: "move-active",
1265 order: null,
1266 assignments: [],
1267 unpin: true,
1268 unsettle: false,
1269 unsnooze: false,
1270 });
1271 });
1272 });
1273});
1274
1275describe("pendingSidebarRouteReveal", () => {
1276 it("keeps a revealed thread settled across a mount that reads no route params", () => {
1277 const reveal = { observedKey: null, pendingKey: null };
1278 expect(pendingSidebarRouteReveal(reveal, "env:a1")).toBe("env:a1");
1279 completeSidebarRouteReveal(reveal);
1280
1281 // Back from Settings: location commits before the thread match does.
1282 expect(pendingSidebarRouteReveal(reveal, null)).toBeNull();
1283 expect(pendingSidebarRouteReveal(reveal, "env:a1")).toBeNull();
1284
1285 expect(pendingSidebarRouteReveal(reveal, "env:b1")).toBe("env:b1");
1286 });
1287
1288 it("keeps a pending reveal through a render without route params", () => {
1289 const reveal = { observedKey: null, pendingKey: null };
1290 pendingSidebarRouteReveal(reveal, "env:a1");
1291 expect(pendingSidebarRouteReveal(reveal, null)).toBeNull();
1292 expect(pendingSidebarRouteReveal(reveal, "env:a1")).toBe("env:a1");
1293 });
1294});
1295
1296describe("resolveSidebarRouteReveal", () => {
1297 const scopedProjectKeys = new Set(["environment-test:project-scoped"]);
1298 const hidden = makeThreadFixture({ projectId: ProjectId.make("project-other") });
1299 const hiddenKey = "environment-test:thread-test";
1300 const findThread = (key: string) => (key === hiddenKey ? hidden : undefined);
1301
1302 it("widens the scope for a newly opened thread the scope hides", () => {
1303 expect(
1304 resolveSidebarRouteReveal({
1305 reveal: { observedKey: "environment-test:other", pendingKey: null },
1306 routeKey: hiddenKey,
1307 isSearching: false,
1308 scopedProjectKeys,
1309 delegatedUnderParent: new Set(),
1310 findThread,
1311 }),
1312 ).toEqual({ pendingKey: hiddenKey, widensScope: true });
1313 });
1314
1315 it("never widens for a thread whose reveal already completed", () => {
1316 // A remount's once-per-mount scroll must keep the scope the user chose.
1317 expect(
1318 resolveSidebarRouteReveal({
1319 reveal: { observedKey: hiddenKey, pendingKey: null },
1320 routeKey: hiddenKey,
1321 isSearching: false,
1322 scopedProjectKeys,
1323 delegatedUnderParent: new Set(),
1324 findThread,
1325 }),
1326 ).toEqual({ pendingKey: null, widensScope: false });
1327 });
1328
1329 it("widens again for a thread reopened before the thread between them listed its row", () => {
1330 // The user scoped away from the open thread, then went to a thread whose row
1331 // never mounted, then came back.
1332 const reveal = { observedKey: hiddenKey, pendingKey: null };
1333 const resolve = (routeKey: string) =>
1334 resolveSidebarRouteReveal({
1335 reveal,
1336 routeKey,
1337 isSearching: false,
1338 scopedProjectKeys,
1339 delegatedUnderParent: new Set(),
1340 findThread,
1341 });
1342 resolve("environment-test:unlisted");
1343 expect(resolve(hiddenKey)).toEqual({ pendingKey: hiddenKey, widensScope: true });
1344 });
1345
1346 it("holds a pending reveal without widening while searching", () => {
1347 expect(
1348 resolveSidebarRouteReveal({
1349 reveal: { observedKey: hiddenKey, pendingKey: hiddenKey },
1350 routeKey: hiddenKey,
1351 isSearching: true,
1352 scopedProjectKeys,
1353 delegatedUnderParent: new Set(),
1354 findThread,
1355 }),
1356 ).toEqual({ pendingKey: hiddenKey, widensScope: false });
1357 });
1358});