Skip to content

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

Keep VPS idle timer active when a manual desktop action or deletion fails

Lin271eae14f69e
diff --git a/server/index.ts b/server/index.ts
index eb82d04b78..3e60d34e62 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -9074,8 +9074,6 @@ async function deleteBotWithLifecycle(botId: string, revalidate: () => void = ()
}
stopScreenPoller(bot.id);
activeVpsThreads.delete(bot.id);
- vps.stopVpsDesktopTunnel(bot.id);
- cancelVpsIdle(bot.id);
lastReply.delete(bot.threadId);
const target = perBotLocalVmTarget(bot.id);
localVmIdles.get(target.key)?.cancel();
@@ -9083,6 +9081,8 @@ async function deleteBotWithLifecycle(botId: string, revalidate: () => void = ()
// Re-check the reviewed receipt at the final durable mutation, so a concurrent profile edit cannot be erased under a stale approval.
revalidate();
store.deleteBot(bot.id, setupRequest); sharedVm.botDeleted(bot.id); computerControlRevision.delete(bot.id);
+ vps.stopVpsDesktopTunnel(bot.id);
+ cancelVpsIdle(bot.id);
skillReview.dropBot(bot.id);
memoryUpkeep.forgetBot(bot.id);
calendarCalls!.removeBot(bot.id);
@@ -15047,7 +15047,6 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
? desktopViewerUrl(`vps/${botId}`, bot.threadId) : result.joinUrl });
}
const action = m[2] === "provision" ? "provision" : m[2] === "remove" ? "remove" : "stop";
- cancelVpsIdle(botId);
const status = await vps.vpsComputerAction(action, vpsConfigForBot(cfg, bot), botId);
if (status.container === "running") touchVpsIdle(bot);
else cancelVpsIdle(botId);
diff --git a/server/vps-routing.test.ts b/server/vps-routing.test.ts
index ab5001d255..92f593e0f3 100644
--- a/server/vps-routing.test.ts
+++ b/server/vps-routing.test.ts
@@ -375,6 +375,16 @@ global.setTimeout = (fn, ms, ...args) => schedule(fn, ms === ${TEST_IDLE_MINUTES
expect((await api("PUT", "/api/config", { vps: { sshAlias: "alpha-vps" } })).status).toBe(200);
expect((await api("POST", `${path}/computer/viewer-close?threadId=${bot.threadId}`, {})).status).toBe(200);
await waitStoppedOnB(since, "idle stop on B after default-server switch");
+
+ running();
+ expect((await api("POST", `${path}/computer/provision`, {})).status).toBe(200);
+ since = readFileSync(dockerLog, "utf8").length;
+ writeFileSync(downB, "");
+ expect((await api("POST", `${path}/computer/provision`, {})).status).toBe(409);
+ expect((await api("POST", `${path}/computer/sleep`, {})).status).toBe(409);
+ expect((await api("POST", `${path}/computer/remove`, {})).status).toBe(409);
+ rmSync(downB, { force: true });
+ await waitStoppedOnB(since, "idle stop on B after failed manual provision, sleep and remove");
} finally {
rmSync(downA, { force: true });
rmSync(downB, { force: true });