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

terminalStateCleanup.ts

25 lines699 Bytes

1import type { ThreadId } from "@t3tools/contracts";
2​
3interface TerminalRetentionThread {
4 id: ThreadId;
5 deletedAt: string | null;
6}
7​
8interface CollectActiveTerminalThreadIdsInput {
9 snapshotThreads: readonly TerminalRetentionThread[];
10 draftThreadIds: Iterable<ThreadId>;
12​
13export function collectActiveTerminalThreadIds(
14 input: CollectActiveTerminalThreadIdsInput,
15): Set<ThreadId> {
16 const activeThreadIds = new Set<ThreadId>();
17 for (const thread of input.snapshotThreads) {
18 if (thread.deletedAt !== null) continue;
19 activeThreadIds.add(thread.id);
20 }
21 for (const draftThreadId of input.draftThreadIds) {
22 activeThreadIds.add(draftThreadId);
23 }
24 return activeThreadIds;