@@ -1419,6 +1419,44 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { |
1419 | 1419 | }), |
1420 | 1420 | ); |
1421 | 1421 |
|
| 1422 | + it.effect("discovers a Pi project from the valid header after an incomplete line", () => |
| 1423 | + Effect.gen(function* () { |
| 1424 | + const fileSystem = yield* FileSystem.FileSystem; |
| 1425 | + const path = yield* Path.Path; |
| 1426 | + const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); |
| 1427 | + const codexHomePath = yield* makeTempDir("t3code-codex-home-"); |
| 1428 | + const piAgentDir = yield* makeTempDir("t3code-pi-agent-"); |
| 1429 | + const projects = yield* makeTempDir("t3code-projects-"); |
| 1430 | + const workspace = path.join(projects, "session-workspace"); |
| 1431 | + const otherWorkspace = path.join(projects, "other-workspace"); |
| 1432 | + yield* fileSystem.makeDirectory(workspace); |
| 1433 | + yield* fileSystem.makeDirectory(otherWorkspace); |
| 1434 | + const header = { type: "session", version: 3, id: "pi-session" }; |
| 1435 | + |
| 1436 | + yield* writeTranscript({ |
| 1437 | + filePath: path.join(piAgentDir, "sessions", "--workspace--", "pi-session.jsonl"), |
| 1438 | + contents: [ |
| 1439 | + encodeTranscriptRecord({ ...header, cwd: otherWorkspace }).slice(0, -1), |
| 1440 | + encodeTranscriptRecord({ ...header, cwd: workspace }), |
| 1441 | + encodeTranscriptRecord({ |
| 1442 | + type: "message", |
| 1443 | + id: "prompt", |
| 1444 | + parentId: null, |
| 1445 | + timestamp: "2026-01-01T00:00:00.000Z", |
| 1446 | + message: { role: "user", content: "Review this project" }, |
| 1447 | + }), |
| 1448 | + ].join("\n"), |
| 1449 | + mtimeMs: Date.parse("2026-01-01T00:00:00.000Z"), |
| 1450 | + }); |
| 1451 | + |
| 1452 | + const result = yield* runScan({ claudeHomePath, codexHomePath, piAgentDir }); |
| 1453 | + |
| 1454 | + expect( |
| 1455 | + result.candidates.map((candidate) => path.relative(projects, candidate.path)), |
| 1456 | + ).toEqual(["session-workspace"]); |
| 1457 | + }), |
| 1458 | + ); |
| 1459 | + |
1422 | 1460 | it.effect("reads a complete transcript record at the exact chunk boundary", () => |
1423 | 1461 | Effect.gen(function* () { |
1424 | 1462 | const path = yield* Path.Path; |
|