* WIP: fix archive tab reconciliation * fix: converge archive into AgentManager for cross-session propagation CLI archive left agent tabs visible in passive app clients because Session.archiveAgentState only notified the archiving session's own subscription. LoopService had the same gap via AgentManager.archiveAgent. Converge on AgentManager.archiveAgent as the single canonical archive path: persist updatedAt, call notifyAgentState before closeAgent so all sessions receive the archived snapshot. Delete Session.archiveAgentState and make handleArchiveAgentRequest a thin wrapper.
107 lines
3.7 KiB
TypeScript
107 lines
3.7 KiB
TypeScript
import { randomUUID } from "node:crypto";
|
|
import { test } from "./fixtures";
|
|
import { createTempGitRepo } from "./helpers/workspace";
|
|
import {
|
|
archiveAgentFromDaemon,
|
|
archiveAgentFromSessions,
|
|
connectArchiveTabDaemonClient,
|
|
createIdleAgent,
|
|
expectSessionRowVisible,
|
|
expectWorkspaceArchiveOutcome,
|
|
openSessions,
|
|
openWorkspaceWithAgents,
|
|
primeAdditionalPage,
|
|
resetSeededPageState,
|
|
reloadWorkspace,
|
|
} from "./helpers/archive-tab";
|
|
|
|
test.describe("Archive tab reconciliation", () => {
|
|
let client: Awaited<ReturnType<typeof connectArchiveTabDaemonClient>>;
|
|
let tempRepo: { path: string; cleanup: () => Promise<void> };
|
|
|
|
test.beforeAll(async () => {
|
|
tempRepo = await createTempGitRepo("archive-tab-");
|
|
client = await connectArchiveTabDaemonClient();
|
|
});
|
|
|
|
test.afterAll(async () => {
|
|
await client?.close();
|
|
await tempRepo?.cleanup();
|
|
});
|
|
|
|
test("non-UI archive prunes the archived tab across open pages and reload", async ({ page }) => {
|
|
const archived = await createIdleAgent(client, {
|
|
cwd: tempRepo.path,
|
|
title: `cli-archive-${randomUUID().slice(0, 8)}`,
|
|
});
|
|
const surviving = await createIdleAgent(client, {
|
|
cwd: tempRepo.path,
|
|
title: `cli-control-${randomUUID().slice(0, 8)}`,
|
|
});
|
|
const passivePage = await page.context().newPage();
|
|
|
|
try {
|
|
await primeAdditionalPage(passivePage);
|
|
await resetSeededPageState(page);
|
|
await resetSeededPageState(passivePage);
|
|
await openSessions(page);
|
|
await expectSessionRowVisible(page, archived.title);
|
|
await expectSessionRowVisible(page, surviving.title);
|
|
await openSessions(passivePage);
|
|
await expectSessionRowVisible(passivePage, archived.title);
|
|
await expectSessionRowVisible(passivePage, surviving.title);
|
|
await openWorkspaceWithAgents(page, [archived, surviving]);
|
|
await openWorkspaceWithAgents(passivePage, [archived, surviving]);
|
|
await archiveAgentFromDaemon(client, archived.id);
|
|
await expectWorkspaceArchiveOutcome(page, {
|
|
archivedAgentId: archived.id,
|
|
survivingAgentId: surviving.id,
|
|
});
|
|
await expectWorkspaceArchiveOutcome(passivePage, {
|
|
archivedAgentId: archived.id,
|
|
survivingAgentId: surviving.id,
|
|
});
|
|
await reloadWorkspace(passivePage, tempRepo.path);
|
|
await expectWorkspaceArchiveOutcome(passivePage, {
|
|
archivedAgentId: archived.id,
|
|
survivingAgentId: surviving.id,
|
|
});
|
|
} finally {
|
|
await passivePage.close();
|
|
}
|
|
});
|
|
|
|
test("Sessions archive prunes the archived tab across open pages", async ({ page }) => {
|
|
const archived = await createIdleAgent(client, {
|
|
cwd: tempRepo.path,
|
|
title: `ui-archive-${randomUUID().slice(0, 8)}`,
|
|
});
|
|
const surviving = await createIdleAgent(client, {
|
|
cwd: tempRepo.path,
|
|
title: `ui-control-${randomUUID().slice(0, 8)}`,
|
|
});
|
|
const passivePage = await page.context().newPage();
|
|
|
|
try {
|
|
await primeAdditionalPage(passivePage);
|
|
await resetSeededPageState(page);
|
|
await resetSeededPageState(passivePage);
|
|
await openWorkspaceWithAgents(page, [archived, surviving]);
|
|
await openWorkspaceWithAgents(passivePage, [archived, surviving]);
|
|
await openSessions(page);
|
|
await archiveAgentFromSessions(page, { agentId: archived.id, title: archived.title });
|
|
await reloadWorkspace(page, tempRepo.path);
|
|
await expectWorkspaceArchiveOutcome(page, {
|
|
archivedAgentId: archived.id,
|
|
survivingAgentId: surviving.id,
|
|
});
|
|
await expectWorkspaceArchiveOutcome(passivePage, {
|
|
archivedAgentId: archived.id,
|
|
survivingAgentId: surviving.id,
|
|
});
|
|
} finally {
|
|
await passivePage.close();
|
|
}
|
|
});
|
|
});
|