Files
plugins/packages/agent-console/test/v1/interrupt-audit.test.ts
T
qingnian108 39f5427420 agent-console 1.3.4: Stop ends the turn at once on ACP, Claude and Codex (#768)
Stop now ends the turn at once, and a resend right after it is safe, on
all three paths:
- ACP (Devin, Cursor, Copilot, OpenCode, Pi, dsh): session/cancel goes as
  a notification, the local turn ends at once, and a resend waits for the
  cancel and the previous prompt to settle.
- Claude: the result FIFO (turnGen, awaitingResult, skipResultGens) lives
  on each CLI process, and a replaced CLI's leftover stdout is ignored.
  After a crash the queue stays open, so the next send resumes with
  --resume.
- Codex: a turn whose turn/start response arrives after Stop is
  interrupted by its own response id.

Run at 0cf12a96 on mote with HOME=$(mktemp -d):
- root bun test: 6171 pass, 0 fail;
- bun scripts/check.mjs agent-console: ok;
- in packages/agent-console: npm ci, npm run check (tsc) and npm run
  build are ok, daemon/dist is byte-identical to the committed one, and
  verify:build is OK;
- npx vitest run: 68 files, 507 passed, 17 skipped.

Broken by hand, then acp-interrupt, claude-cli and codex-interrupt were
run again. Each mutant was red:
- codex: wasCancelled forced false: 1 fail;
- codex: interrupt() no longer ends the local turn: 5 fail;
- acp: pendingCancelSettle not awaited: 1 fail;
- acp: the late prompt settle ends the turn without the activeTurnId
  guard: 1 fail;
- claude: a replaced CLI's stdout no longer ignored: 1 fail;
- claude: interrupt no longer marks its gen in skipResultGens: 2 fail;
- claude: a crash closes the queue instead of setting needsRestart: 2 fail.

Not tried: a real Claude or Codex CLI. The PR says Devin 3000.11.3 was
tried live.
Not blocking: a Codex turn/start response that arrives after
turn/completed sends an extra turn/interrupt and leaves one
staleCodexTurns entry.
2026-11-06 13:49:42 +08:00

25 lines
1.1 KiB
TypeScript

// Transport matrix: which of the 8 catalog agents share ACP session/cancel vs a custom interrupt path.
import { describe, expect, it } from "vitest";
import { PROVIDER_CATALOG } from "../../daemon/src/providers/catalog.js";
import { isAcpCatalogId, acpConfigForEntry } from "../../daemon/src/providers/acp/specs.js";
describe("interrupt transport audit", () => {
it("catalog has the 8 supported agents", () => {
expect(PROVIDER_CATALOG.map((e) => e.id)).toEqual([
"claude", "codex", "cursor", "copilot", "opencode", "pi", "devin", "dsh",
]);
});
it("Claude and Codex are custom; the other six share ACP AcpSession", () => {
const byId = Object.fromEntries(PROVIDER_CATALOG.map((e) => [e.id, e]));
expect(isAcpCatalogId("claude")).toBe(false);
expect(isAcpCatalogId("codex")).toBe(false);
for (const id of ["cursor", "copilot", "opencode", "pi", "devin", "dsh"]) {
expect(isAcpCatalogId(id)).toBe(true);
expect(acpConfigForEntry(byId[id], "test")).not.toBeNull();
}
expect(acpConfigForEntry(byId.claude, "test")).toBeNull();
expect(acpConfigForEntry(byId.codex, "test")).toBeNull();
});
});