| 1 | import * as Schema from "effect/Schema"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { AgentSessionScanResult } from "./agentSessions.ts"; |
| 5 | |
| 6 | const decodeScanResult = Schema.decodeUnknownSync(AgentSessionScanResult); |
| 7 | |
| 8 | const 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 | |
| 17 | describe("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 | }); |