Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

Sidebar.logic.test.ts

1,426 lines42.9 KB

1import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
2import {
3 archiveSelectedThreadEntries,
4 buildMultiSelectThreadContextMenuItems,
5 createThreadJumpHintVisibilityController,
6 getSidebarThreadIdsToPrewarm,
7 getVisibleSidebarThreadIds,
8 resolveAdjacentThreadId,
9 getFallbackThreadIdAfterDelete,
10 getVisibleThreadsForProject,
11 getProjectSortTimestamp,
12 hasUnseenCompletion,
13 isContextMenuPointerDown,
14 isTrailingDoubleClick,
15 orderItemsByPreferredIds,
16 resolveProjectStatusIndicator,
17 resolveSidebarStageBadgeLabel,
18 resolveThreadRowClassName,
19 resolveSidebarV2Status,
20 resolveThreadStatusPill,
21 resolveWorkingStartedAt,
22 formatWorkingDurationLabel,
23 shouldNavigateAfterProjectRemoval,
24 shouldClearThreadSelectionOnMouseDown,
25 sortLogicalProjectsForSidebar,
26 sortSettledThreadsForSidebarV2,
27 sortThreadsForSidebarV2,
28 sortProjectsForSidebar,
29 sortScopedProjectsForSidebar,
30 THREAD_JUMP_HINT_SHOW_DELAY_MS,
31} from "./Sidebar.logic";
32import {
33 EnvironmentId,
34 OrchestrationLatestTurn,
35 ProjectId,
36 ProviderInstanceId,
37 ThreadId,
38} from "@t3tools/contracts";
39​
40import {
41 DEFAULT_INTERACTION_MODE,
42 DEFAULT_RUNTIME_MODE,
43 type Project,
44 type Thread,
45} from "../types";
46​
47const localEnvironmentId = EnvironmentId.make("environment-local");
48​
49describe("shouldNavigateAfterProjectRemoval", () => {
50 const projectThreads = [{ environmentId: "environment-local", id: "thread-1" }];
51​
52 it("navigates away from a draft route owned by the removed project", () => {
53 expect(
54 shouldNavigateAfterProjectRemoval({
55 routeTarget: { kind: "draft", draftId: "draft-1" as never },
56 projectThreads,
57 projectDraftId: "draft-1",
58 }),
59 ).toBe(true);
60 });
61​
62 it("does not navigate away from a different draft route", () => {
63 expect(
64 shouldNavigateAfterProjectRemoval({
65 routeTarget: { kind: "draft", draftId: "draft-2" as never },
66 projectThreads,
67 projectDraftId: "draft-1",
68 }),
69 ).toBe(false);
70 });
71​
72 it("navigates away from a server thread owned by the removed project", () => {
73 expect(
74 shouldNavigateAfterProjectRemoval({
75 routeTarget: {
76 kind: "server",
77 threadRef: {
78 environmentId: EnvironmentId.make("environment-local"),
79 threadId: ThreadId.make("thread-1"),
80 },
81 },
82 projectThreads,
83 projectDraftId: null,
84 }),
85 ).toBe(true);
86 });
87​
88 it("does not navigate from an unrelated route", () => {
89 expect(
90 shouldNavigateAfterProjectRemoval({
91 routeTarget: null,
92 projectThreads,
93 projectDraftId: null,
94 }),
95 ).toBe(false);
96 });
97});
98​
99describe("archiveSelectedThreadEntries", () => {
100 const entries = [{ threadKey: "one" }, { threadKey: "two" }, { threadKey: "three" }] as const;
101 const success = { _tag: "Success" } as const;
102 const failure = { _tag: "Failure" } as const;
103​
104 it("records every entry after full success", async () => {
105 const outcome = await archiveSelectedThreadEntries({
106 entries,
107 archive: async (_entry, onArchived) => {
108 onArchived();
109 return success;
110 },
111 });
112​
113 expect(outcome).toEqual({
114 archivedThreadKeys: ["one", "two", "three"],
115 mutationFailure: null,
116 followupFailures: [],
117 });
118 });
119​
120 it("stops at a mutation failure and retains prior successes", async () => {
121 const archive = vi.fn(async (entry: (typeof entries)[number], onArchived: () => void) => {
122 if (entry.threadKey === "two") return failure;
123 onArchived();
124 return success;
125 });
126 const outcome = await archiveSelectedThreadEntries({ entries, archive });
127​
128 expect(archive).toHaveBeenCalledTimes(2);
129 expect(outcome).toEqual({
130 archivedThreadKeys: ["one"],
131 mutationFailure: failure,
132 followupFailures: [],
133 });
134 });
135​
136 it("continues after a post-archive failure", async () => {
137 const archive = vi.fn(async (entry: (typeof entries)[number], onArchived: () => void) => {
138 onArchived();
139 return entry.threadKey === "two" ? failure : success;
140 });
141 const outcome = await archiveSelectedThreadEntries({ entries, archive });
142​
143 expect(archive).toHaveBeenCalledTimes(3);
144 expect(outcome).toEqual({
145 archivedThreadKeys: ["one", "two", "three"],
146 mutationFailure: null,
147 followupFailures: [failure],
148 });
149 });
150});
151​
152describe("buildMultiSelectThreadContextMenuItems", () => {
153 it("offers bulk archive with the selected count", () => {
154 expect(
155 buildMultiSelectThreadContextMenuItems({ count: 3, hasRunningThread: false }),
156 ).toContainEqual({ id: "archive", label: "Archive (3)", disabled: false });
157 });
158​
159 it("disables bulk archive when a selected thread is running", () => {
160 expect(
161 buildMultiSelectThreadContextMenuItems({ count: 2, hasRunningThread: true }),
162 ).toContainEqual({ id: "archive", label: "Archive (2)", disabled: true });
163 });
164});
165​
166describe("resolveSidebarStageBadgeLabel", () => {
167 it("returns Nightly for nightly primary server versions", () => {
168 expect(
169 resolveSidebarStageBadgeLabel({
170 primaryServerVersion: "0.0.28-nightly.20260616.12",
171 fallbackStageLabel: "Alpha",
172 }),
173 ).toBe("Nightly");
174 });
175​
176 it("returns the fallback label for stable primary server versions", () => {
177 expect(
178 resolveSidebarStageBadgeLabel({
179 primaryServerVersion: "0.0.27",
180 fallbackStageLabel: "Alpha",
181 }),
182 ).toBe("Alpha");
183 });
184​
185 it("returns the fallback label when the primary server version is missing", () => {
186 expect(
187 resolveSidebarStageBadgeLabel({
188 primaryServerVersion: null,
189 fallbackStageLabel: "Dev",
190 }),
191 ).toBe("Dev");
192 });
193​
194 it("returns the fallback label for malformed nightly prerelease versions", () => {
195 expect(
196 resolveSidebarStageBadgeLabel({
197 primaryServerVersion: "0.0.28-nightly.20260616",
198 fallbackStageLabel: "Alpha",
199 }),
200 ).toBe("Alpha");
201 });
202});
203​
204function makeLatestTurn(overrides?: {
205 completedAt?: string | null;
206 startedAt?: string | null;
207}): OrchestrationLatestTurn {
208 return {
209 turnId: "turn-1" as never,
210 state: "completed",
211 assistantMessageId: null,
212 requestedAt: "2026-03-09T10:00:00.000Z",
213 startedAt:
214 overrides?.startedAt !== undefined ? overrides.startedAt : "2026-03-09T10:00:00.000Z",
215 completedAt:
216 overrides?.completedAt !== undefined ? overrides.completedAt : "2026-03-09T10:05:00.000Z",
217 };
219​
220describe("hasUnseenCompletion", () => {
221 it("returns true when a thread completed after its last visit", () => {
222 expect(
223 hasUnseenCompletion({
224 hasActionableProposedPlan: false,
225 hasPendingApprovals: false,
226 hasPendingUserInput: false,
227 interactionMode: "default",
228 latestTurn: makeLatestTurn(),
229 lastVisitedAt: "2026-03-09T10:04:00.000Z",
230 session: null,
231 }),
232 ).toBe(true);
233 });
234​
235 it("treats a missing client visit marker as read", () => {
236 expect(
237 hasUnseenCompletion({
238 hasActionableProposedPlan: false,
239 hasPendingApprovals: false,
240 hasPendingUserInput: false,
241 interactionMode: "default",
242 latestTurn: makeLatestTurn(),
243 lastVisitedAt: undefined,
244 session: null,
245 }),
246 ).toBe(false);
247 });
248});
249​
250describe("createThreadJumpHintVisibilityController", () => {
251 beforeEach(() => {
252 vi.useFakeTimers();
253 });
254​
255 afterEach(() => {
256 vi.useRealTimers();
257 });
258​
259 it("delays showing jump hints until the configured delay elapses", () => {
260 const visibilityChanges: boolean[] = [];
261 const controller = createThreadJumpHintVisibilityController({
262 delayMs: THREAD_JUMP_HINT_SHOW_DELAY_MS,
263 onVisibilityChange: (visible) => {
264 visibilityChanges.push(visible);
265 },
266 });
267​
268 controller.sync(true);
269 vi.advanceTimersByTime(THREAD_JUMP_HINT_SHOW_DELAY_MS - 1);
270​
271 expect(visibilityChanges).toEqual([]);
272​
273 vi.advanceTimersByTime(1);
274​
275 expect(visibilityChanges).toEqual([true]);
276 });
277​
278 it("hides immediately when the modifiers are released", () => {
279 const visibilityChanges: boolean[] = [];
280 const controller = createThreadJumpHintVisibilityController({
281 delayMs: THREAD_JUMP_HINT_SHOW_DELAY_MS,
282 onVisibilityChange: (visible) => {
283 visibilityChanges.push(visible);
284 },
285 });
286​
287 controller.sync(true);
288 vi.advanceTimersByTime(THREAD_JUMP_HINT_SHOW_DELAY_MS);
289 controller.sync(false);
290​
291 expect(visibilityChanges).toEqual([true, false]);
292 });
293​
294 it("cancels a pending reveal when the modifier is released early", () => {
295 const visibilityChanges: boolean[] = [];
296 const controller = createThreadJumpHintVisibilityController({
297 delayMs: THREAD_JUMP_HINT_SHOW_DELAY_MS,
298 onVisibilityChange: (visible) => {
299 visibilityChanges.push(visible);
300 },
301 });
302​
303 controller.sync(true);
304 vi.advanceTimersByTime(Math.floor(THREAD_JUMP_HINT_SHOW_DELAY_MS / 2));
305 controller.sync(false);
306 vi.advanceTimersByTime(THREAD_JUMP_HINT_SHOW_DELAY_MS);
307​
308 expect(visibilityChanges).toEqual([]);
309 });
310});
311​
312describe("getSidebarThreadIdsToPrewarm", () => {
313 it("returns only the first visible thread ids up to the prewarm limit", () => {
314 expect(getSidebarThreadIdsToPrewarm(["t1", "t2", "t3"], 2)).toEqual(["t1", "t2"]);
315 });
316​
317 it("returns all visible thread ids when they fit within the limit", () => {
318 expect(getSidebarThreadIdsToPrewarm(["t1", "t2"], 10)).toEqual(["t1", "t2"]);
319 });
320​
321 it("returns no thread ids when the limit is zero", () => {
322 expect(getSidebarThreadIdsToPrewarm(["t1", "t2"], 0)).toEqual([]);
323 });
324});
325​
326describe("shouldClearThreadSelectionOnMouseDown", () => {
327 it("preserves selection for thread items", () => {
328 const child = {
329 closest: (selector: string) =>
330 selector.includes("[data-thread-item]") ? ({} as Element) : null,
331 } as unknown as HTMLElement;
332​
333 expect(shouldClearThreadSelectionOnMouseDown(child)).toBe(false);
334 });
335​
336 it("preserves selection for thread list toggle controls", () => {
337 const selectionSafe = {
338 closest: (selector: string) =>
339 selector.includes("[data-thread-selection-safe]") ? ({} as Element) : null,
340 } as unknown as HTMLElement;
341​
342 expect(shouldClearThreadSelectionOnMouseDown(selectionSafe)).toBe(false);
343 });
344​
345 it("clears selection for unrelated sidebar clicks", () => {
346 const unrelated = {
347 closest: () => null,
348 } as unknown as HTMLElement;
349​
350 expect(shouldClearThreadSelectionOnMouseDown(unrelated)).toBe(true);
351 });
352});
353​
354describe("isTrailingDoubleClick", () => {
355 it("treats a single click as a normal activation", () => {
356 expect(isTrailingDoubleClick(1)).toBe(false);
357 });
358​
359 it("treats synthetic/keyboard activations (detail 0) as a normal activation", () => {
360 expect(isTrailingDoubleClick(0)).toBe(false);
361 });
362​
363 it("ignores the second click of a double-click so it does not navigate", () => {
364 expect(isTrailingDoubleClick(2)).toBe(true);
365 });
366​
367 it("ignores further clicks of a triple-click", () => {
368 expect(isTrailingDoubleClick(3)).toBe(true);
369 });
370});
371​
372describe("orderItemsByPreferredIds", () => {
373 it("keeps preferred ids first, skips stale ids, and preserves the relative order of remaining items", () => {
374 const ordered = orderItemsByPreferredIds({
375 items: [
376 { id: ProjectId.make("project-1"), name: "One" },
377 { id: ProjectId.make("project-2"), name: "Two" },
378 { id: ProjectId.make("project-3"), name: "Three" },
379 ],
380 preferredIds: [
381 ProjectId.make("project-3"),
382 ProjectId.make("project-missing"),
383 ProjectId.make("project-1"),
384 ],
385 getId: (project) => project.id,
386 });
387​
388 expect(ordered.map((project) => project.id)).toEqual([
389 ProjectId.make("project-3"),
390 ProjectId.make("project-1"),
391 ProjectId.make("project-2"),
392 ]);
393 });
394​
395 it("does not duplicate items when preferred ids repeat", () => {
396 const ordered = orderItemsByPreferredIds({
397 items: [
398 { id: ProjectId.make("project-1"), name: "One" },
399 { id: ProjectId.make("project-2"), name: "Two" },
400 ],
401 preferredIds: [
402 ProjectId.make("project-2"),
403 ProjectId.make("project-1"),
404 ProjectId.make("project-2"),
405 ],
406 getId: (project) => project.id,
407 });
408​
409 expect(ordered.map((project) => project.id)).toEqual([
410 ProjectId.make("project-2"),
411 ProjectId.make("project-1"),
412 ]);
413 });
414​
415 it("honors projectOrder physical keys via getProjectOrderKey", async () => {
416 // Regression guard for #1904 / the regression introduced by #2055:
417 // `projectOrder` is populated with physical keys (envId + cwd-derived)
418 // by the store and by drag-end handlers. Readers must identify projects
419 // with the same key format, or manual sort silently snaps back.
420 const { getProjectOrderKey } = await import("../logicalProject");
421 const projects = [
422 {
423 environmentId: EnvironmentId.make("environment-local"),
424 id: ProjectId.make("id-alpha"),
425 workspaceRoot: "/work/alpha",
426 },
427 {
428 environmentId: EnvironmentId.make("environment-local"),
429 id: ProjectId.make("id-beta"),
430 workspaceRoot: "/work/beta",
431 },
432 {
433 environmentId: EnvironmentId.make("environment-local"),
434 id: ProjectId.make("id-gamma"),
435 workspaceRoot: "/work/gamma",
436 },
437 ];
438 const ordered = orderItemsByPreferredIds({
439 items: projects,
440 preferredIds: [getProjectOrderKey(projects[2]!), getProjectOrderKey(projects[0]!)],
441 getId: getProjectOrderKey,
442 });
443​
444 expect(ordered.map((project) => project.workspaceRoot)).toEqual([
445 "/work/gamma",
446 "/work/alpha",
447 "/work/beta",
448 ]);
449 });
450​
451 it("resolves legacy preference aliases without materializing project state", () => {
452 const ordered = orderItemsByPreferredIds({
453 items: [
454 { id: "physical-a", cwd: "/work/a" },
455 { id: "physical-b", cwd: "/work/b" },
456 { id: "physical-c", cwd: "/work/c" },
457 ],
458 preferredIds: ["legacy:/work/c", "legacy:/work/a"],
459 getId: (project) => project.id,
460 getPreferenceIds: (project) => [project.id, `legacy:${project.cwd}`],
461 });
462​
463 expect(ordered.map((project) => project.id)).toEqual([
464 "physical-c",
465 "physical-a",
466 "physical-b",
467 ]);
468 });
469});
470​
471describe("resolveAdjacentThreadId", () => {
472 it("resolves adjacent thread ids in ordered sidebar traversal", () => {
473 const threads = [
474 ThreadId.make("thread-1"),
475 ThreadId.make("thread-2"),
476 ThreadId.make("thread-3"),
477 ];
478​
479 expect(
480 resolveAdjacentThreadId({
481 threadIds: threads,
482 currentThreadId: threads[1] ?? null,
483 direction: "previous",
484 }),
485 ).toBe(threads[0]);
486 expect(
487 resolveAdjacentThreadId({
488 threadIds: threads,
489 currentThreadId: threads[1] ?? null,
490 direction: "next",
491 }),
492 ).toBe(threads[2]);
493 expect(
494 resolveAdjacentThreadId({
495 threadIds: threads,
496 currentThreadId: null,
497 direction: "next",
498 }),
499 ).toBe(threads[0]);
500 expect(
501 resolveAdjacentThreadId({
502 threadIds: threads,
503 currentThreadId: null,
504 direction: "previous",
505 }),
506 ).toBe(threads[2]);
507 expect(
508 resolveAdjacentThreadId({
509 threadIds: threads,
510 currentThreadId: threads[0] ?? null,
511 direction: "previous",
512 }),
513 ).toBeNull();
514 });
515});
516​
517describe("getVisibleSidebarThreadIds", () => {
518 it("returns only the rendered visible thread order across projects", () => {
519 expect(
520 getVisibleSidebarThreadIds([
521 {
522 renderedThreadIds: [
523 ThreadId.make("thread-12"),
524 ThreadId.make("thread-11"),
525 ThreadId.make("thread-10"),
526 ],
527 },
528 {
529 renderedThreadIds: [ThreadId.make("thread-8"), ThreadId.make("thread-6")],
530 },
531 ]),
532 ).toEqual([
533 ThreadId.make("thread-12"),
534 ThreadId.make("thread-11"),
535 ThreadId.make("thread-10"),
536 ThreadId.make("thread-8"),
537 ThreadId.make("thread-6"),
538 ]);
539 });
540​
541 it("skips threads from collapsed projects whose thread panels are not shown", () => {
542 expect(
543 getVisibleSidebarThreadIds([
544 {
545 shouldShowThreadPanel: false,
546 renderedThreadIds: [ThreadId.make("thread-hidden-2"), ThreadId.make("thread-hidden-1")],
547 },
548 {
549 shouldShowThreadPanel: true,
550 renderedThreadIds: [ThreadId.make("thread-12"), ThreadId.make("thread-11")],
551 },
552 ]),
553 ).toEqual([ThreadId.make("thread-12"), ThreadId.make("thread-11")]);
554 });
555});
556​
557describe("isContextMenuPointerDown", () => {
558 it("treats secondary-button presses as context menu gestures on all platforms", () => {
559 expect(
560 isContextMenuPointerDown({
561 button: 2,
562 ctrlKey: false,
563 isMac: false,
564 }),
565 ).toBe(true);
566 });
567​
568 it("treats ctrl+primary-click as a context menu gesture on macOS", () => {
569 expect(
570 isContextMenuPointerDown({
571 button: 0,
572 ctrlKey: true,
573 isMac: true,
574 }),
575 ).toBe(true);
576 });
577​
578 it("does not treat ctrl+primary-click as a context menu gesture off macOS", () => {
579 expect(
580 isContextMenuPointerDown({
581 button: 0,
582 ctrlKey: true,
583 isMac: false,
584 }),
585 ).toBe(false);
586 });
587});
588​
589describe("resolveSidebarV2Status", () => {
590 const session = {
591 threadId: ThreadId.make("thread-1"),
592 status: "running" as const,
593 providerName: "Codex",
594 providerInstanceId: ProviderInstanceId.make("codex"),
595 runtimeMode: DEFAULT_RUNTIME_MODE,
596 activeTurnId: "turn-1" as never,
597 lastError: null,
598 updatedAt: "2026-03-09T10:00:00.000Z",
599 };
600​
601 const idle = { hasPendingApprovals: false, hasPendingUserInput: false };
602​
603 it("prioritizes approval over a running session", () => {
604 expect(resolveSidebarV2Status({ ...idle, hasPendingApprovals: true, session })).toBe(
605 "approval",
606 );
607 });
608​
609 it("prioritizes awaiting input over a running session, below approval", () => {
610 expect(resolveSidebarV2Status({ ...idle, hasPendingUserInput: true, session })).toBe("input");
611 expect(
612 resolveSidebarV2Status({
613 ...idle,
614 hasPendingApprovals: true,
615 hasPendingUserInput: true,
616 session,
617 }),
618 ).toBe("approval");
619 });
620​
621 it("reports working for running and starting sessions", () => {
622 expect(resolveSidebarV2Status({ ...idle, session })).toBe("working");
623 expect(
624 resolveSidebarV2Status({
625 ...idle,
626 session: { ...session, status: "starting" as const },
627 }),
628 ).toBe("working");
629 });
630​
631 it("reports failed only while the session status is error", () => {
632 expect(
633 resolveSidebarV2Status({
634 ...idle,
635 session: { ...session, status: "error" as const, lastError: "boom" },
636 }),
637 ).toBe("failed");
638 expect(
639 resolveSidebarV2Status({
640 ...idle,
641 session: { ...session, status: "stopped" as const, lastError: "persisted" },
642 }),
643 ).toBe("ready");
644 expect(
645 resolveSidebarV2Status({
646 ...idle,
647 session: { ...session, status: "ready" as const, lastError: "persisted" },
648 }),
649 ).toBe("ready");
650 });
651​
652 it("defaults to ready with no session", () => {
653 expect(resolveSidebarV2Status({ ...idle, session: null })).toBe("ready");
654 });
655});
656​
657describe("sortThreadsForSidebarV2", () => {
658 const sortable = (input: { id: string; createdAt: string }) => ({
659 id: input.id,
660 createdAt: input.createdAt,
661 });
662​
663 it("orders by creation time, newest first, ignoring activity", () => {
664 const sorted = sortThreadsForSidebarV2([
665 sortable({ id: "oldest", createdAt: "2026-03-09T08:00:00.000Z" }),
666 sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
667 sortable({ id: "middle", createdAt: "2026-03-09T10:00:00.000Z" }),
668 ]);
669​
670 expect(sorted.map((thread) => thread.id)).toEqual(["newest", "middle", "oldest"]);
671 });
672​
673 it("breaks creation-time ties by id so the order is stable", () => {
674 const sorted = sortThreadsForSidebarV2([
675 sortable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z" }),
676 sortable({ id: "a", createdAt: "2026-03-09T10:00:00.000Z" }),
677 ]);
678​
679 expect(sorted.map((thread) => thread.id)).toEqual(["a", "b"]);
680 });
681});
682​
683describe("sortSettledThreadsForSidebarV2", () => {
684 const settled = (input: {
685 id: string;
686 settledAt?: string | null;
687 latestUserMessageAt?: string | null;
688 latestTurn?: OrchestrationLatestTurn | null;
689 updatedAt?: string;
690 }) => ({
691 id: input.id,
692 settledAt: input.settledAt ?? null,
693 latestUserMessageAt: input.latestUserMessageAt ?? null,
694 latestTurn: input.latestTurn ?? null,
695 updatedAt: input.updatedAt ?? "2026-03-09T09:00:00.000Z",
696 });
697​
698 it("orders by settle time, most recently settled first", () => {
699 const sorted = sortSettledThreadsForSidebarV2([
700 settled({
701 id: "settled-first",
702 settledAt: "2026-03-09T10:00:00.000Z",
703 // Created/active later than the other thread: settle time must win.
704 latestUserMessageAt: "2026-03-09T09:59:00.000Z",
705 }),
706 settled({
707 id: "settled-last",
708 settledAt: "2026-03-09T12:00:00.000Z",
709 latestUserMessageAt: "2026-03-09T08:00:00.000Z",
710 }),
711 ]);
712​
713 expect(sorted.map((thread) => thread.id)).toEqual(["settled-last", "settled-first"]);
714 });
715​
716 it("falls back to last activity for auto-settled threads without a settledAt stamp", () => {
717 const sorted = sortSettledThreadsForSidebarV2([
718 settled({ id: "auto-old", latestUserMessageAt: "2026-03-09T08:00:00.000Z" }),
719 settled({ id: "explicit", settledAt: "2026-03-09T10:00:00.000Z" }),
720 settled({ id: "auto-recent", latestUserMessageAt: "2026-03-09T11:00:00.000Z" }),
721 ]);
722​
723 expect(sorted.map((thread) => thread.id)).toEqual(["auto-recent", "explicit", "auto-old"]);
724 });
725​
726 it("counts a turn completion as activity for auto-settled threads", () => {
727 // The message came in before the other thread's, but its turn finished
728 // after: completion time is the real "work ended" moment.
729 const sorted = sortSettledThreadsForSidebarV2([
730 settled({ id: "message-only", latestUserMessageAt: "2026-03-09T10:04:00.000Z" }),
731 settled({
732 id: "completed-later",
733 latestUserMessageAt: "2026-03-09T10:00:00.000Z",
734 latestTurn: makeLatestTurn({ completedAt: "2026-03-09T10:30:00.000Z" }),
735 }),
736 ]);
737​
738 expect(sorted.map((thread) => thread.id)).toEqual(["completed-later", "message-only"]);
739 });
740​
741 it("breaks timestamp ties by id so the order is stable", () => {
742 const sorted = sortSettledThreadsForSidebarV2([
743 settled({ id: "b", settledAt: "2026-03-09T10:00:00.000Z" }),
744 settled({ id: "a", settledAt: "2026-03-09T10:00:00.000Z" }),
745 ]);
746​
747 expect(sorted.map((thread) => thread.id)).toEqual(["a", "b"]);
748 });
749});
750​
751describe("resolveWorkingStartedAt", () => {
752 const session = {
753 threadId: ThreadId.make("thread-1"),
754 status: "running" as const,
755 providerName: "Codex",
756 providerInstanceId: ProviderInstanceId.make("codex"),
757 runtimeMode: DEFAULT_RUNTIME_MODE,
758 activeTurnId: "turn-1" as never,
759 lastError: null,
760 updatedAt: "2026-03-09T10:02:00.000Z",
761 };
762​
763 it("uses the running turn's start time", () => {
764 expect(
765 resolveWorkingStartedAt({
766 latestTurn: makeLatestTurn({ completedAt: null }),
767 session,
768 }),
769 ).toBe("2026-03-09T10:00:00.000Z");
770 });
771​
772 it("uses the request time while a turn awaits adoption", () => {
773 expect(
774 resolveWorkingStartedAt({
775 latestTurn: makeLatestTurn({ startedAt: null, completedAt: null }),
776 session,
777 }),
778 ).toBe("2026-03-09T10:00:00.000Z");
779 });
780​
781 it("falls back to the session transition when the latest turn already completed", () => {
782 expect(
783 resolveWorkingStartedAt({
784 latestTurn: makeLatestTurn(),
785 session,
786 }),
787 ).toBe("2026-03-09T10:02:00.000Z");
788 });
789​
790 it("skips a malformed startedAt instead of returning it", () => {
791 expect(
792 resolveWorkingStartedAt({
793 latestTurn: makeLatestTurn({ startedAt: "not-a-date", completedAt: null }),
794 session,
795 }),
796 ).toBe("2026-03-09T10:00:00.000Z");
797 });
798​
799 it("returns null with neither a running turn nor a session", () => {
800 expect(resolveWorkingStartedAt({ latestTurn: null, session: null })).toBeNull();
801 });
802});
803​
804describe("formatWorkingDurationLabel", () => {
805 it("formats seconds, minutes, and hours", () => {
806 expect(formatWorkingDurationLabel(0)).toBe("0s");
807 expect(formatWorkingDurationLabel(42_000)).toBe("42s");
808 expect(formatWorkingDurationLabel(5 * 60_000)).toBe("5m");
809 expect(formatWorkingDurationLabel(90 * 60_000)).toBe("1h 30m");
810 });
811​
812 it("clamps negative and non-finite elapsed values to zero", () => {
813 expect(formatWorkingDurationLabel(-5_000)).toBe("0s");
814 expect(formatWorkingDurationLabel(Number.NaN)).toBe("0s");
815 });
816});
817​
818describe("resolveThreadStatusPill", () => {
819 const baseThread = {
820 hasActionableProposedPlan: false,
821 hasPendingApprovals: false,
822 hasPendingUserInput: false,
823 interactionMode: "plan" as const,
824 latestTurn: null,
825 lastVisitedAt: undefined,
826 session: {
827 threadId: ThreadId.make("thread-1"),
828 status: "running" as const,
829 providerName: "Codex",
830 providerInstanceId: ProviderInstanceId.make("codex"),
831 runtimeMode: DEFAULT_RUNTIME_MODE,
832 activeTurnId: "turn-1" as never,
833 lastError: null,
834 updatedAt: "2026-03-09T10:00:00.000Z",
835 },
836 };
837​
838 it("shows pending approval before all other statuses", () => {
839 expect(
840 resolveThreadStatusPill({
841 thread: {
842 ...baseThread,
843 hasPendingApprovals: true,
844 hasPendingUserInput: true,
845 },
846 }),
847 ).toMatchObject({ label: "Pending Approval", pulse: false });
848 });
849​
850 it("shows awaiting input when plan mode is blocked on user answers", () => {
851 expect(
852 resolveThreadStatusPill({
853 thread: {
854 ...baseThread,
855 hasPendingUserInput: true,
856 },
857 }),
858 ).toMatchObject({ label: "Awaiting Input", pulse: false });
859 });
860​
861 it("falls back to working when the thread is actively running without blockers", () => {
862 expect(
863 resolveThreadStatusPill({
864 thread: baseThread,
865 }),
866 ).toMatchObject({ label: "Working", pulse: true });
867 });
868​
869 it("shows plan ready when a settled plan turn has a proposed plan ready for follow-up", () => {
870 expect(
871 resolveThreadStatusPill({
872 thread: {
873 ...baseThread,
874 hasActionableProposedPlan: true,
875 latestTurn: makeLatestTurn(),
876 session: {
877 ...baseThread.session,
878 status: "ready",
879 activeTurnId: null,
880 },
881 },
882 }),
883 ).toMatchObject({ label: "Plan Ready", pulse: false });
884 });
885​
886 it("does not manufacture completed state without a client visit marker", () => {
887 expect(
888 resolveThreadStatusPill({
889 thread: {
890 ...baseThread,
891 latestTurn: makeLatestTurn(),
892 session: {
893 ...baseThread.session,
894 status: "ready",
895 activeTurnId: null,
896 },
897 },
898 }),
899 ).toBeNull();
900 });
901​
902 it("shows completed when there is an unseen completion and no active blocker", () => {
903 expect(
904 resolveThreadStatusPill({
905 thread: {
906 ...baseThread,
907 interactionMode: "default",
908 latestTurn: makeLatestTurn(),
909 lastVisitedAt: "2026-03-09T10:04:00.000Z",
910 session: {
911 ...baseThread.session,
912 status: "ready",
913 activeTurnId: null,
914 },
915 },
916 }),
917 ).toMatchObject({ label: "Completed", pulse: false });
918 });
919});
920​
921describe("resolveThreadRowClassName", () => {
922 it("uses the active sidebar surface when a thread is both selected and active", () => {
923 const className = resolveThreadRowClassName({ isActive: true, isSelected: true });
924 expect(className).toContain("bg-sidebar-row-active");
925 expect(className).toContain("text-sidebar-foreground");
926 expect(className).not.toContain("bg-primary");
927 });
928​
929 it("uses selected hover colors for selected threads", () => {
930 const className = resolveThreadRowClassName({ isActive: false, isSelected: true });
931 expect(className).toContain("bg-sidebar-row-selected");
932 expect(className).toContain("hover:bg-sidebar-row-active");
933 expect(className).not.toContain("bg-primary");
934 });
935​
936 it("uses the active sidebar surface for active-only threads", () => {
937 const className = resolveThreadRowClassName({ isActive: true, isSelected: false });
938 expect(className).toContain("bg-sidebar-row-active");
939 expect(className).toContain("hover:bg-sidebar-row-active");
940 });
941});
942​
943describe("resolveProjectStatusIndicator", () => {
944 it("returns null when no threads have a notable status", () => {
945 expect(resolveProjectStatusIndicator([null, null])).toBeNull();
946 });
947​
948 it("surfaces the highest-priority actionable state across project threads", () => {
949 expect(
950 resolveProjectStatusIndicator([
951 {
952 label: "Completed",
953 colorClass: "text-emerald-600",
954 dotClass: "bg-emerald-500",
955 pulse: false,
956 },
957 {
958 label: "Pending Approval",
959 colorClass: "text-amber-600",
960 dotClass: "bg-amber-500",
961 pulse: false,
962 },
963 {
964 label: "Working",
965 colorClass: "text-sky-600",
966 dotClass: "bg-sky-500",
967 pulse: true,
968 },
969 ]),
970 ).toMatchObject({ label: "Pending Approval", dotClass: "bg-amber-500" });
971 });
972​
973 it("prefers plan-ready over completed when no stronger action is needed", () => {
974 expect(
975 resolveProjectStatusIndicator([
976 {
977 label: "Completed",
978 colorClass: "text-emerald-600",
979 dotClass: "bg-emerald-500",
980 pulse: false,
981 },
982 {
983 label: "Plan Ready",
984 colorClass: "text-violet-600",
985 dotClass: "bg-violet-500",
986 pulse: false,
987 },
988 ]),
989 ).toMatchObject({ label: "Plan Ready", dotClass: "bg-violet-500" });
990 });
991});
992​
993describe("getVisibleThreadsForProject", () => {
994 it("includes the active thread even when it falls below the folded preview", () => {
995 const threads = Array.from({ length: 8 }, (_, index) =>
996 makeThread({
997 id: ThreadId.make(`thread-${index + 1}`),
998 title: `Thread ${index + 1}`,
999 }),
1000 );
1001​
1002 const result = getVisibleThreadsForProject({
1003 threads,
1004 activeThreadId: ThreadId.make("thread-8"),
1005 isThreadListExpanded: false,
1006 previewLimit: 6,
1007 });
1008​
1009 expect(result.hasHiddenThreads).toBe(true);
1010 expect(result.visibleThreads.map((thread) => thread.id)).toEqual([
1011 ThreadId.make("thread-1"),
1012 ThreadId.make("thread-2"),
1013 ThreadId.make("thread-3"),
1014 ThreadId.make("thread-4"),
1015 ThreadId.make("thread-5"),
1016 ThreadId.make("thread-6"),
1017 ThreadId.make("thread-8"),
1018 ]);
1019 expect(result.hiddenThreads.map((thread) => thread.id)).toEqual([ThreadId.make("thread-7")]);
1020 });
1021​
1022 it("returns all threads when the list is expanded", () => {
1023 const threads = Array.from({ length: 8 }, (_, index) =>
1024 makeThread({
1025 id: ThreadId.make(`thread-${index + 1}`),
1026 }),
1027 );
1028​
1029 const result = getVisibleThreadsForProject({
1030 threads,
1031 activeThreadId: ThreadId.make("thread-8"),
1032 isThreadListExpanded: true,
1033 previewLimit: 6,
1034 });
1035​
1036 expect(result.hasHiddenThreads).toBe(true);
1037 expect(result.visibleThreads.map((thread) => thread.id)).toEqual(
1038 threads.map((thread) => thread.id),
1039 );
1040 expect(result.hiddenThreads).toEqual([]);
1041 });
1042});
1043​
1044function makeProject(overrides: Partial<Project> = {}): Project {
1045 const { defaultModelSelection, ...rest } = overrides;
1046 return {
1047 id: ProjectId.make("project-1"),
1048 environmentId: localEnvironmentId,
1049 title: "Project",
1050 workspaceRoot: "/tmp/project",
1051 repositoryIdentity: null,
1052 defaultModelSelection: {
1053 instanceId: ProviderInstanceId.make("codex"),
1054 model: "gpt-5.4",
1055 ...defaultModelSelection,
1056 },
1057 createdAt: "2026-03-09T10:00:00.000Z",
1058 updatedAt: "2026-03-09T10:00:00.000Z",
1059 scripts: [],
1060 ...rest,
1061 };
1063​
1064function makeThread(overrides: Partial<Thread> = {}): Thread {
1065 return {
1066 id: ThreadId.make("thread-1"),
1067 environmentId: localEnvironmentId,
1068 projectId: ProjectId.make("project-1"),
1069 title: "Thread",
1070 modelSelection: {
1071 instanceId: ProviderInstanceId.make("codex"),
1072 model: "gpt-5.4",
1073 ...overrides?.modelSelection,
1074 },
1075 runtimeMode: DEFAULT_RUNTIME_MODE,
1076 interactionMode: DEFAULT_INTERACTION_MODE,
1077 session: null,
1078 messages: [],
1079 proposedPlans: [],
1080 createdAt: "2026-03-09T10:00:00.000Z",
1081 archivedAt: null,
1082 settledOverride: null,
1083 settledAt: null,
1084 deletedAt: null,
1085 updatedAt: "2026-03-09T10:00:00.000Z",
1086 latestTurn: null,
1087 branch: null,
1088 worktreePath: null,
1089 checkpoints: [],
1090 activities: [],
1091 ...overrides,
1092 };
1094​
1095describe("getFallbackThreadIdAfterDelete", () => {
1096 it("returns the top remaining thread in the deleted thread's project sidebar order", () => {
1097 const fallbackThreadId = getFallbackThreadIdAfterDelete({
1098 threads: [
1099 makeThread({
1100 id: ThreadId.make("thread-oldest"),
1101 projectId: ProjectId.make("project-1"),
1102 createdAt: "2026-03-09T10:00:00.000Z",
1103 messages: [],
1104 }),
1105 makeThread({
1106 id: ThreadId.make("thread-active"),
1107 projectId: ProjectId.make("project-1"),
1108 createdAt: "2026-03-09T10:05:00.000Z",
1109 messages: [],
1110 }),
1111 makeThread({
1112 id: ThreadId.make("thread-newest"),
1113 projectId: ProjectId.make("project-1"),
1114 createdAt: "2026-03-09T10:10:00.000Z",
1115 messages: [],
1116 }),
1117 makeThread({
1118 id: ThreadId.make("thread-other-project"),
1119 projectId: ProjectId.make("project-2"),
1120 createdAt: "2026-03-09T10:20:00.000Z",
1121 messages: [],
1122 }),
1123 ],
1124 deletedThreadId: ThreadId.make("thread-active"),
1125 sortOrder: "created_at",
1126 });
1127​
1128 expect(fallbackThreadId).toBe(ThreadId.make("thread-newest"));
1129 });
1130​
1131 it("skips other threads being deleted in the same action", () => {
1132 const fallbackThreadId = getFallbackThreadIdAfterDelete({
1133 threads: [
1134 makeThread({
1135 id: ThreadId.make("thread-active"),
1136 projectId: ProjectId.make("project-1"),
1137 createdAt: "2026-03-09T10:05:00.000Z",
1138 messages: [],
1139 }),
1140 makeThread({
1141 id: ThreadId.make("thread-newest"),
1142 projectId: ProjectId.make("project-1"),
1143 createdAt: "2026-03-09T10:10:00.000Z",
1144 messages: [],
1145 }),
1146 makeThread({
1147 id: ThreadId.make("thread-next"),
1148 projectId: ProjectId.make("project-1"),
1149 createdAt: "2026-03-09T10:07:00.000Z",
1150 messages: [],
1151 }),
1152 ],
1153 deletedThreadId: ThreadId.make("thread-active"),
1154 deletedThreadIds: new Set([ThreadId.make("thread-active"), ThreadId.make("thread-newest")]),
1155 sortOrder: "created_at",
1156 });
1157​
1158 expect(fallbackThreadId).toBe(ThreadId.make("thread-next"));
1159 });
1160});
1161describe("sortProjectsForSidebar", () => {
1162 it("sorts projects by the most recent user message across their threads", () => {
1163 const projects = [
1164 makeProject({ id: ProjectId.make("project-1"), title: "Older project" }),
1165 makeProject({ id: ProjectId.make("project-2"), title: "Newer project" }),
1166 ];
1167 const threads = [
1168 makeThread({
1169 projectId: ProjectId.make("project-1"),
1170 updatedAt: "2026-03-09T10:20:00.000Z",
1171 messages: [
1173 id: "message-1" as never,
1174 role: "user",
1175 text: "older project user message",
1176 turnId: null,
1177 createdAt: "2026-03-09T10:01:00.000Z",
1178 updatedAt: "2026-03-09T10:01:00.000Z",
1179 streaming: false,
1180 },
1181 ],
1182 }),
1183 makeThread({
1184 id: ThreadId.make("thread-2"),
1185 projectId: ProjectId.make("project-2"),
1186 updatedAt: "2026-03-09T10:05:00.000Z",
1187 messages: [
1189 id: "message-2" as never,
1190 role: "user",
1191 text: "newer project user message",
1192 turnId: null,
1193 createdAt: "2026-03-09T10:05:00.000Z",
1194 updatedAt: "2026-03-09T10:05:00.000Z",
1195 streaming: false,
1196 },
1197 ],
1198 }),
1199 ];
1200​
1201 const sorted = sortProjectsForSidebar(projects, threads, "updated_at");
1202​
1203 expect(sorted.map((project) => project.id)).toEqual([
1204 ProjectId.make("project-2"),
1205 ProjectId.make("project-1"),
1206 ]);
1207 });
1208​
1209 it("falls back to project timestamps when a project has no threads", () => {
1210 const sorted = sortProjectsForSidebar(
1212 makeProject({
1213 id: ProjectId.make("project-1"),
1214 title: "Older project",
1215 updatedAt: "2026-03-09T10:01:00.000Z",
1216 }),
1217 makeProject({
1218 id: ProjectId.make("project-2"),
1219 title: "Newer project",
1220 updatedAt: "2026-03-09T10:05:00.000Z",
1221 }),
1222 ],
1223 [],
1224 "updated_at",
1225 );
1226​
1227 expect(sorted.map((project) => project.id)).toEqual([
1228 ProjectId.make("project-2"),
1229 ProjectId.make("project-1"),
1230 ]);
1231 });
1232​
1233 it("falls back to name and id ordering when projects have no sortable timestamps", () => {
1234 const sorted = sortProjectsForSidebar(
1236 makeProject({
1237 id: ProjectId.make("project-2"),
1238 title: "Beta",
1239 createdAt: "invalid-created-at" as never,
1240 updatedAt: "invalid-updated-at" as never,
1241 }),
1242 makeProject({
1243 id: ProjectId.make("project-1"),
1244 title: "Alpha",
1245 createdAt: "invalid-created-at" as never,
1246 updatedAt: "invalid-updated-at" as never,
1247 }),
1248 ],
1249 [],
1250 "updated_at",
1251 );
1252​
1253 expect(sorted.map((project) => project.id)).toEqual([
1254 ProjectId.make("project-1"),
1255 ProjectId.make("project-2"),
1256 ]);
1257 });
1258​
1259 it("preserves manual project ordering", () => {
1260 const projects = [
1261 makeProject({ id: ProjectId.make("project-2"), title: "Second" }),
1262 makeProject({ id: ProjectId.make("project-1"), title: "First" }),
1263 ];
1264​
1265 const sorted = sortProjectsForSidebar(projects, [], "manual");
1266​
1267 expect(sorted.map((project) => project.id)).toEqual([
1268 ProjectId.make("project-2"),
1269 ProjectId.make("project-1"),
1270 ]);
1271 });
1272​
1273 it("ignores archived threads when sorting projects", () => {
1274 const sorted = sortProjectsForSidebar(
1276 makeProject({
1277 id: ProjectId.make("project-1"),
1278 title: "Visible project",
1279 updatedAt: "2026-03-09T10:01:00.000Z",
1280 }),
1281 makeProject({
1282 id: ProjectId.make("project-2"),
1283 title: "Archived-only project",
1284 updatedAt: "2026-03-09T10:00:00.000Z",
1285 }),
1286 ],
1288 makeThread({
1289 id: ThreadId.make("thread-visible"),
1290 projectId: ProjectId.make("project-1"),
1291 updatedAt: "2026-03-09T10:02:00.000Z",
1292 archivedAt: null,
1293 }),
1294 makeThread({
1295 id: ThreadId.make("thread-archived"),
1296 projectId: ProjectId.make("project-2"),
1297 updatedAt: "2026-03-09T10:10:00.000Z",
1298 archivedAt: "2026-03-09T10:11:00.000Z",
1299 }),
1300 ].filter((thread) => thread.archivedAt === null),
1301 "updated_at",
1302 );
1303​
1304 expect(sorted.map((project) => project.id)).toEqual([
1305 ProjectId.make("project-1"),
1306 ProjectId.make("project-2"),
1307 ]);
1308 });
1309​
1310 it("returns the project timestamp when no threads are present", () => {
1311 const timestamp = getProjectSortTimestamp(
1312 makeProject({ updatedAt: "2026-03-09T10:10:00.000Z" }),
1313 [],
1314 "updated_at",
1315 );
1316​
1317 expect(timestamp).toBe(Date.parse("2026-03-09T10:10:00.000Z"));
1318 });
1319});
1320​
1321describe("sortScopedProjectsForSidebar", () => {
1322 it("keeps identical project ids in different environments separate", () => {
1323 const remoteEnvironmentId = EnvironmentId.make("environment-remote");
1324 const sharedProjectId = ProjectId.make("shared-project");
1325 const projects = [
1326 makeProject({
1327 environmentId: localEnvironmentId,
1328 id: sharedProjectId,
1329 title: "Local project",
1330 }),
1331 makeProject({
1332 environmentId: remoteEnvironmentId,
1333 id: sharedProjectId,
1334 title: "Remote project",
1335 }),
1336 ];
1337 const threads = [
1338 makeThread({
1339 environmentId: localEnvironmentId,
1340 projectId: sharedProjectId,
1341 updatedAt: "2026-03-09T10:02:00.000Z",
1342 }),
1343 makeThread({
1344 environmentId: remoteEnvironmentId,
1345 projectId: sharedProjectId,
1346 updatedAt: "2026-03-09T10:10:00.000Z",
1347 }),
1348 ];
1349​
1350 const sorted = sortScopedProjectsForSidebar(projects, threads, "updated_at");
1351​
1352 expect(sorted.map((project) => project.title)).toEqual(["Remote project", "Local project"]);
1353 });
1354​
1355 it("does not use archived threads as project activity", () => {
1356 const projects = [
1357 makeProject({
1358 id: ProjectId.make("project-visible"),
1359 title: "Visible project",
1360 updatedAt: "2026-03-09T10:01:00.000Z",
1361 }),
1362 makeProject({
1363 id: ProjectId.make("project-archived"),
1364 title: "Archived-only project",
1365 updatedAt: "2026-03-09T10:00:00.000Z",
1366 }),
1367 ];
1368 const threads = [
1369 makeThread({
1370 id: ThreadId.make("thread-visible"),
1371 projectId: ProjectId.make("project-visible"),
1372 updatedAt: "2026-03-09T10:02:00.000Z",
1373 }),
1374 makeThread({
1375 id: ThreadId.make("thread-archived"),
1376 projectId: ProjectId.make("project-archived"),
1377 updatedAt: "2026-03-09T10:10:00.000Z",
1378 archivedAt: "2026-03-09T10:11:00.000Z",
1379 }),
1380 ];
1381​
1382 const sorted = sortScopedProjectsForSidebar(projects, threads, "updated_at");
1383​
1384 expect(sorted.map((project) => project.title)).toEqual([
1385 "Visible project",
1386 "Archived-only project",
1387 ]);
1388 });
1389});
1390​
1391describe("sortLogicalProjectsForSidebar", () => {
1392 it("uses saved order only in manual mode and activity order otherwise", () => {
1393 const olderProjectId = ProjectId.make("project-older");
1394 const newerProjectId = ProjectId.make("project-newer");
1395 const projects = [
1397 ...makeProject({ id: olderProjectId, title: "Older project" }),
1398 projectKey: "logical-older",
1399 memberProjectRefs: [{ environmentId: localEnvironmentId, projectId: olderProjectId }],
1400 },
1402 ...makeProject({ id: newerProjectId, title: "Newer project" }),
1403 projectKey: "logical-newer",
1404 memberProjectRefs: [{ environmentId: localEnvironmentId, projectId: newerProjectId }],
1405 },
1406 ];
1407 const threads = [
1408 makeThread({
1409 projectId: olderProjectId,
1410 updatedAt: "2026-03-09T10:01:00.000Z",
1411 }),
1412 makeThread({
1413 id: ThreadId.make("thread-newer"),
1414 projectId: newerProjectId,
1415 updatedAt: "2026-03-09T10:05:00.000Z",
1416 }),
1417 ];
1418​
1419 expect(sortLogicalProjectsForSidebar(projects, threads, "manual")).toEqual(projects);
1420 expect(
1421 sortLogicalProjectsForSidebar(projects, threads, "updated_at").map(
1422 (project) => project.projectKey,
1423 ),
1424 ).toEqual(["logical-newer", "logical-older"]);
1425 });
1426});