Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

test(acp): dispose each permission card's ACP instance before the next replaces it

RGB-loop9500ff2e861c
diff --git a/server/drivers/acp/acp.test.ts b/server/drivers/acp/acp.test.ts
index 8f683a7967..cc84aaccbc 100644
--- a/server/drivers/acp/acp.test.ts
+++ b/server/drivers/acp/acp.test.ts
@@ -1676,10 +1676,18 @@ describe("ACP turns (fake CLI)", () => {
});
const touch = { sessionUpdate: "tool_call", toolCallId: "call_1", title: "bash: touch marker", kind: "execute", status: "pending", rawInput: { command: "touch marker" } };
+ // A test can open several cards; afterEach disposes only the last instance, so each card disposes the one it replaces.
+ let earlierCard: { instance: ProviderInstance; recorder: EventRecorder } | undefined;
+ afterEach(() => { earlierCard = undefined; });
const permissionCard = async (threadId: string, prior: unknown[], toolCall: unknown) => {
+ if (earlierCard) {
+ earlierCard.recorder.stop();
+ await earlierCard.instance.dispose();
+ }
process.env.FAKE_ACP_PERMISSION_PRIOR_UPDATES = JSON.stringify(prior);
process.env.FAKE_ACP_PERMISSION_TOOL_CALL = JSON.stringify(toolCall);
await create(GrokAgentDriver, "permission");
+ earlierCard = { instance, recorder };
const { turnId } = await instance.adapter.sendTurn({ threadId, text: "go", cwd: scratch });
const opened = await recorder.until((event) => event.type === "request.opened" && event.turnId === turnId);
await instance.adapter.respondToRequest(threadId, opened.requestId!, { behavior: "deny" });