Open History to see the last commit
1import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2import { expect, it } from "vite-plus/test";
3
4import { matchComposerThreadItems, type ComposerThreadCandidate } from "./composerThreadItems.ts";
5
6const environmentId = EnvironmentId.make("env-composer");
7
8function shell(
9 id: string,
10 title: string,
11 overrides: Partial<ComposerThreadCandidate> = {},
12): ComposerThreadCandidate {
13 return {
14 environmentId,
15 id: ThreadId.make(id),
16 title,
17 branch: null,
18 createdAt: "2026-10-01T00:00:00.000Z",
19 updatedAt: "2026-10-01T00:00:00.000Z",
20 latestUserMessageAt: null,
21 opens: null,
22 archivedAt: null,
23 lineage: { rootThreadId: ThreadId.make(id), parentThreadId: null, relationshipToParent: null },
24 ...overrides,
25 };
26}
27
28it("ranks thread mentions like the palette and leaves out subagent threads", () => {
29 const items = matchComposerThreadItems({
30 shells: [
31 shell("newer-mid-word", "Remodel the settings page", {
32 updatedAt: "2026-10-20T00:00:00.000Z",
33 }),
34 shell("word", "Fix model picker"),
35 shell("subagent", "Model review", {
36 lineage: {
37 rootThreadId: ThreadId.make("word"),
38 parentThreadId: ThreadId.make("word"),
39 relationshipToParent: "subagent",
40 },
41 }),
42 shell("other-environment", "Model docs", { environmentId: EnvironmentId.make("env-other") }),
43 ],
44 environmentId,
45 excludeThreadId: null,
46 query: "model",
47 now: Date.parse("2026-10-23T00:00:00.000Z"),
48 });
49 expect(items.map((item) => item.thread.threadId)).toEqual(["word", "newer-mid-word"]);
50});