Files
oh-my-pi/packages/coding-agent/test/tools/hub-list.test.ts
T
roboomp 66837a96be fix(hub): restored persisted peers after resume
Moved persisted roster discovery out of the Agent Hub UI so model-facing coordination can use the same disk-backed registration path.

Rehydrated parked peers before an empty hub list response and added a crash-resume regression test.

Fixes #5864
2026-07-17 15:20:43 +00:00

43 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import * as path from "node:path";
import { AgentRegistry, MAIN_AGENT_ID } from "@oh-my-pi/pi-coding-agent/registry/agent-registry";
import { executeList } from "@oh-my-pi/pi-coding-agent/tools/hub/messaging";
import { TempDir } from "@oh-my-pi/pi-utils";
describe("hub list", () => {
it("restores persisted peers after the process registry is lost", async () => {
using tempDir = TempDir.createSync("@omp-hub-list-persisted-");
const sessionFile = path.join(tempDir.path(), "main.jsonl");
const workerSessionFile = path.join(tempDir.path(), "main", "Worker.jsonl");
await Bun.write(sessionFile, "");
await Bun.write(workerSessionFile, "");
const registry = new AgentRegistry();
registry.register({
id: MAIN_AGENT_ID,
displayName: MAIN_AGENT_ID,
kind: "main",
session: null,
sessionFile,
status: "running",
});
const result = await executeList(registry, MAIN_AGENT_ID);
if (!result.details) throw new Error("Expected coordination details");
expect(result.details.peers).toEqual([
expect.objectContaining({
id: "Worker",
kind: "sub",
status: "parked",
parentId: MAIN_AGENT_ID,
}),
]);
const content = result.content[0];
if (content?.type !== "text") throw new Error("Expected text result");
expect(content.text).toContain("Worker");
expect(content.text).toContain("parked");
expect(registry.get("Worker")?.sessionFile).toBe(workerSessionFile);
});
});