1import * as Schema from "effect/Schema";
2import { describe, expect, it } from "vite-plus/test";
3
4import { AgentSessionScanResult } from "./agentSessions.ts";
5
6const decodeScanResult = Schema.decodeUnknownSync(AgentSessionScanResult);
7
8const candidate = {
9 path: "/projects/repo",
10 title: "repo",
11 sources: ["codex"],
12 threadCount: 3,
13 lastActiveAt: "2026-08-20T12:00:00.000Z",
14 alreadyImported: false,
15} as const;
16
17describe("AgentSessionScanResult", () => {
18 it("decodes candidates from servers that predate the git scan", () => {
19 const result = decodeScanResult({
20 candidates: [candidate],
21 scannedAt: "2026-08-22T12:00:00.000Z",
22 });
23
24 expect(result.candidates[0]?.git).toBeUndefined();
25 });
26
27 it("preserves reported git identity", () => {
28 const git = { remoteKey: "github.com/pingdotgg/t3code", repository: "pingdotgg/t3code" };
29 const result = decodeScanResult({
30 candidates: [{ ...candidate, git }],
31 scannedAt: "2026-08-22T12:00:00.000Z",
32 });
33
34 expect(result.candidates[0]?.git).toEqual(git);
35 });
36});