Skip to content

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

fix(acp): forget a closed Vibe session when its re-load is refused

AdityaUmale67720ac1f646
diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.ts
index f4e4bc594f..b68209ab0a 100644
--- a/server/drivers/acp/core.ts
+++ b/server/drivers/acp/core.ts
@@ -1225,7 +1225,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
const selectionParams = narrowsNativeTools(turn.toolScope)
? support.toolScopeSessionParams!(turn, init, mcpServers.length > 0, { config: turnConfig, env, cwd }) : {};
let loaded = false;
- if (cursor && (!support.closeBeforeLiveLoad || liveSessionId !== cursor || await request("session/close", { sessionId: cursor }, 30_000).then(() => true, () => false))) {
+ if (cursor && (!support.closeBeforeLiveLoad || liveSessionId !== cursor || await request("session/close", { sessionId: cursor }, 30_000).then(() => { session.sessionId = session.sessionKey = null; return true; }, () => false))) {
try {
await request(
support.resumeMethod === "resume" ? "session/resume" : "session/load",
diff --git a/server/drivers/acp/mistral-vibe.test.ts b/server/drivers/acp/mistral-vibe.test.ts
index 8776768b5d..e90123bed6 100644
--- a/server/drivers/acp/mistral-vibe.test.ts
+++ b/server/drivers/acp/mistral-vibe.test.ts
@@ -1,4 +1,4 @@
-import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
@@ -164,6 +164,36 @@ describe("Mistral (Vibe) ACP driver", () => {
expect(Number(readFileSync(launches, "utf8"))).toBe(processes);
});
+ it("forgets a closed live session when its re-load is refused, so the next turn loads it instead of prompting the closed copy", async () => {
+ const reject = join(scratch, "reject");
+ const rpc = join(scratch, "rpc.jsonl");
+ const { instance, recorder } = await create({
+ MISTRAL_API_KEY: "engine-fixture-key", FAKE_ACP_COPY_LIVE_LOAD: "1", FAKE_ACP_TEXT_REPLY: "hello",
+ FAKE_ACP_REJECT_LIVE_LOAD_FILE: reject, FAKE_ACP_REJECT_LIVE_LOAD_DSH: "1", FAKE_ACP_RPC_APPEND_FILE: rpc,
+ });
+ const agents = (token: string) => ({
+ command: process.execPath,
+ args: ["/app/dist-server/agents-proxy.js"],
+ env: { OMB_HARNESS_URL: "http://127.0.0.1:8799", OMB_COMMS_TOKEN: token, OMB_BOT_ID: "sprout", OMB_THREAD_ID: "mistral-vibe-refused" },
+ });
+ const run = async (text: string, token: string, resume: boolean) => {
+ const { turnId } = await instance.adapter.sendTurn({
+ threadId: "mistral-vibe-refused", text, model: "mistral-medium-3.5", approvalMode: "ask",
+ ...(resume ? { resumeCursor: "fake-acp-session" } : {}), integrations: { agents: agents(token) },
+ });
+ return recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);
+ };
+ const methods = () => readFileSync(rpc, "utf8").trim().split("\n").map((line) => (JSON.parse(line) as { method: string }).method);
+ expect(await run("one", "token-one", false)).toMatchObject({ ok: true });
+ writeFileSync(reject, "1");
+ expect(await run("two", "token-two", true)).toMatchObject({ ok: false });
+ expect(methods().slice(-2)).toEqual(["session/close", "session/load"]);
+ const before = methods().length;
+ rmSync(reject);
+ expect(await run("three", "token-one", true)).toMatchObject({ ok: true });
+ expect(methods().slice(before)).toContain("session/load");
+ });
+
it("turns Vibe's session/request_permission into an approval card and answers with the person's choice", async () => {
const answer = join(scratch, "permission.txt");
const { instance, recorder } = await create({ FAKE_ACP_MODE: "permission", FAKE_ACP_PERMISSION_ANSWER: answer });