Merge branch 'main' into remove-legacy-archive-migration

This commit is contained in:
Federico Jaramillo Martinez
2026-07-28 20:21:22 +02:00
committed by GitHub
3 changed files with 17 additions and 7 deletions
@@ -1,10 +1,13 @@
import { resolve } from "node:path";
import { describe, expect, it, vi } from "vitest"; import { describe, expect, it, vi } from "vitest";
import { countOutOfListingChildren, locateOutOfListingParents } from "./parentSessionLocator.js"; import { countOutOfListingChildren, locateOutOfListingParents } from "./parentSessionLocator.js";
import type { SessionHeaderSummary } from "./sessionFileHeader.js"; import type { SessionHeaderSummary } from "./sessionFileHeader.js";
const PARENT_PATH = "/sessions/--srv-other--/parent.jsonl"; const PARENT_PATH = "/sessions/--srv-other--/parent.jsonl";
const LISTING_CWD = "/srv/dev/pi-web"; const LISTING_CWD = "/srv/dev/pi-web";
const PARENT_CWD = "/srv/other-worktree"; // Resolved because the locator canonicalizes header cwds: a bare "/srv/..." is
// drive-relative on Windows and would land on the runner's current drive.
const PARENT_CWD = resolve("/srv/other-worktree");
describe("locateOutOfListingParents", () => { describe("locateOutOfListingParents", () => {
it("reports the cwd and id of a parent that is not in the listing", async () => { it("reports the cwd and id of a parent that is not in the listing", async () => {
@@ -1,13 +1,16 @@
import { mkdtemp, rm, writeFile } from "node:fs/promises"; import { mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join, resolve } from "node:path";
import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { PiSessionService, type PiSessionListEntry } from "./piSessionService.js"; import { PiSessionService, type PiSessionListEntry } from "./piSessionService.js";
import { CapturingSessionEventHub, emptyArchiveStore, fakeSessionManager, sessionRecord, testModelRuntime, type SessionGateway } from "./piSessionService.testSupport.js"; import { CapturingSessionEventHub, emptyArchiveStore, fakeSessionManager, sessionRecord, testModelRuntime, type SessionGateway } from "./piSessionService.testSupport.js";
const TEST_AGENT_DIR = "/tmp/pi-web-test-agent"; const TEST_AGENT_DIR = "/tmp/pi-web-test-agent";
const CHILD_CWD = "/srv/dev/pi-web"; const CHILD_CWD = "/srv/dev/pi-web";
const PARENT_CWD = "/srv/dev/pi-web-feature"; // Resolved because the service canonicalizes header cwds before annotating: a
// bare "/srv/..." is drive-relative on Windows and would land on the runner's
// current drive.
const PARENT_CWD = resolve("/srv/dev/pi-web-feature");
let tempDir: string; let tempDir: string;
@@ -694,9 +694,13 @@ describe("PiSessionService daemon-owned unread state", () => {
it("clears unread for sessions archived and deleted by cleanup", async () => { it("clears unread for sessions archived and deleted by cleanup", async () => {
const unreadStore = new SessionUnreadStore({ createCatalogId: () => "catalog-test" }); const unreadStore = new SessionUnreadStore({ createCatalogId: () => "catalog-test" });
completeStoreWork(unreadStore, "cleanup-archive", "/old-project"); // Resolved because the service canonicalizes cwds before forgetting unread:
completeStoreWork(unreadStore, "cleanup-delete", "/old-project"); // a bare "/old-project" is drive-relative on Windows and would land on the
const archivedRecord = { sessionId: "cleanup-delete", cwd: "/old-project", archivedAt: "2026-04-01T00:00:00.000Z", archivePath: "/archive/cleanup-delete.jsonl" }; // runner's current drive, so the seeded marker would never match.
const oldProjectCwd = resolve("/old-project");
completeStoreWork(unreadStore, "cleanup-archive", oldProjectCwd);
completeStoreWork(unreadStore, "cleanup-delete", oldProjectCwd);
const archivedRecord = { sessionId: "cleanup-delete", cwd: oldProjectCwd, archivedAt: "2026-04-01T00:00:00.000Z", archivePath: "/archive/cleanup-delete.jsonl" };
const service = new PiSessionService(new CapturingSessionEventHub(), { const service = new PiSessionService(new CapturingSessionEventHub(), {
agentDir: TEST_AGENT_DIR, agentDir: TEST_AGENT_DIR,
modelRuntime: testModelRuntime, modelRuntime: testModelRuntime,
@@ -705,7 +709,7 @@ describe("PiSessionService daemon-owned unread state", () => {
sessionManager: { sessionManager: {
create: () => fakeSessionManager(), create: () => fakeSessionManager(),
list: () => Promise.resolve([]), list: () => Promise.resolve([]),
listAll: () => Promise.resolve([sessionRecord("cleanup-archive", "/old-project")]), listAll: () => Promise.resolve([sessionRecord("cleanup-archive", oldProjectCwd)]),
open: () => fakeSessionManager(), open: () => fakeSessionManager(),
}, },
archiveStore: { archiveStore: {