diff --git a/apps/server/src/engine/routes.ts b/apps/server/src/engine/routes.ts index 139bf61c5..9096c08c9 100644 --- a/apps/server/src/engine/routes.ts +++ b/apps/server/src/engine/routes.ts @@ -130,7 +130,7 @@ export function agentRoutes(service: AgentService): Hono<{ Variables: { owner: s return c.json(identity); }); app.get("/notifications", async (c) => - c.json((await service.snapshot(c.get("owner"))).notifications), + c.json(await service.db.list(c.get("owner"), "notifications")), ); app.post("/notifications/:id/read", async (c) => { const notification = await service.db.compareAndSwap( diff --git a/tests/agent-api.test.ts b/tests/agent-api.test.ts index c3b58a34a..4de0cdfe8 100644 --- a/tests/agent-api.test.ts +++ b/tests/agent-api.test.ts @@ -254,6 +254,15 @@ test("idea dismissal survives refresh and concurrent acceptance creates one goal await read(`/tasks/${results[0].taskId}/control`, { action: "cancel" }); }); +test("notification reads do not load the full agent workspace", async (t) => { + t.mock.method(server.agent, "snapshot", async () => { + throw new Error("notifications route must not call snapshot"); + }); + const response = await request("/notifications"); + assert.equal(response.status, 200, await response.clone().text()); + assert.ok(Array.isArray(await response.json())); +}); + test("sample monitor saves its baseline and deduplicates notifications for repeated changes", async () => { await read("/sample-page", { text: "No tables available" }); const monitor = await read(