Open History to see the last commit
1import { ThreadId } from "@t3tools/contracts";
2import { describe, expect, it } from "vitest";
3
4import { collectActiveTerminalThreadIds } from "./terminalStateCleanup";
5
6const threadId = (id: string): ThreadId => ThreadId.makeUnsafe(id);
7
8describe("collectActiveTerminalThreadIds", () => {
9 it("retains non-deleted server threads", () => {
10 const activeThreadIds = collectActiveTerminalThreadIds({
11 snapshotThreads: [
12 { id: threadId("server-1"), deletedAt: null },
13 { id: threadId("server-2"), deletedAt: null },
14 ],
15 draftThreadIds: [],
16 });
17
18 expect(activeThreadIds).toEqual(new Set([threadId("server-1"), threadId("server-2")]));
19 });
20
21 it("ignores deleted server threads and keeps local draft threads", () => {
22 const activeThreadIds = collectActiveTerminalThreadIds({
23 snapshotThreads: [
24 { id: threadId("server-active"), deletedAt: null },
25 { id: threadId("server-deleted"), deletedAt: "2026-03-05T08:00:00.000Z" },
26 ],
27 draftThreadIds: [threadId("local-draft")],
28 });
29
30 expect(activeThreadIds).toEqual(new Set([threadId("server-active"), threadId("local-draft")]));
31 });
32});