Skip to content

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

fix: preserve person pause state in client config frames

Afloatb0ef5d2f09d6
diff --git a/src/components/PauseMenus.dom.test.ts b/src/components/PauseMenus.dom.test.ts
index bbc0aee2d8..49716dd942 100644
--- a/src/components/PauseMenus.dom.test.ts
+++ b/src/components/PauseMenus.dom.test.ts
@@ -2,11 +2,13 @@
import { act, createElement } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import { configStatusFromFrame, type ConfigStatusFrame } from "@/lib/config-status-frame";
+import type { ConfigStatus } from "@/state/config-status";
const fixture = vi.hoisted(() => ({
calls: [] as Array<{ path: string; body: unknown }>,
admin: true as boolean | null,
- config: { pausedByPerson: { bots: [] as string[], departments: [] as string[] }, heldBots: [] as string[] },
+ config: { pausedByPerson: { bots: [] as string[], departments: [] as string[] }, heldBots: [] as string[] } as Pick<ConfigStatus, "pausedByPerson" | "heldBots">,
}));
vi.mock("@/state/api", () => ({ api: async (path: string, init: { body: string }) => { fixture.calls.push({ path, body: JSON.parse(init.body) }); return { stopped: 2 }; } }));
vi.mock("@/state/store", () => ({ api: vi.fn(), useStore: () => ({ state: { config: fixture.config, bots: [], groups: [] }, dispatch: vi.fn() }) }));
@@ -25,6 +27,10 @@ beforeEach(() => {
afterEach(async () => { await act(async () => root.unmount()); container.remove(); vi.unstubAllGlobals(); });
const menu = (onRead = vi.fn()) => createElement(TeamMenuItems, { department: "Sales", onRead, onAddBots: vi.fn(), onRename: vi.fn(), onShare: vi.fn(), onDelete: vi.fn() });
+const baseFrame: ConfigStatusFrame = {
+ composio: { configured: false }, box: { configured: false }, vps: { configured: false, sshAlias: "" },
+ rooms: { turnTimeoutMinutes: 10 }, localVm: { mode: "shared", maxInstances: 1 },
+};
it("lets an admin pause a department, and resume it once paused", async () => {
const onRead = vi.fn();
@@ -35,9 +41,18 @@ it("lets an admin pause a department, and resume it once paused", async () => {
expect(fixture.calls).toEqual([{ path: "/api/paused", body: { kind: "department", id: "Sales", paused: true } }]);
expect(onRead).toHaveBeenCalled();
- fixture.config = { pausedByPerson: { bots: [], departments: ["Sales"] }, heldBots: [] };
+ const pausedFrame = { ...baseFrame, pausedByPerson: { bots: [], departments: ["Sales"] }, heldBots: ["ada"] };
+ fixture.config = configStatusFromFrame(pausedFrame);
await act(async () => root.render(menu()));
- expect(container.querySelector('[data-team-pause="resume"]')!.textContent).toBe("Resume department");
+ const resume = container.querySelector<HTMLButtonElement>('[data-team-pause="resume"]');
+ expect(resume?.textContent).toBe("Resume department");
+ await act(async () => resume!.click());
+ expect(fixture.calls.at(-1)).toEqual({ path: "/api/paused", body: { kind: "department", id: "Sales", paused: false } });
+
+ const resumedFrame = { ...baseFrame, pausedByPerson: { bots: [], departments: [] }, heldBots: [] };
+ fixture.config = configStatusFromFrame(resumedFrame);
+ await act(async () => root.render(menu()));
+ expect(container.querySelector('[data-team-pause="pause"]')?.textContent).toBe("Pause department");
});
it("offers nothing to someone who is not an owner or admin", async () => {
diff --git a/src/lib/config-status-frame.test.ts b/src/lib/config-status-frame.test.ts
new file mode 100644
index 0000000000..f8725cb1a6
--- /dev/null
+++ b/src/lib/config-status-frame.test.ts
@@ -0,0 +1,24 @@
+import { expect, it } from "vitest";
+import { configStatusFromFrame, type ConfigStatusFrame } from "./config-status-frame";
+
+const baseFrame: ConfigStatusFrame = {
+ composio: { configured: false }, box: { configured: false }, vps: { configured: false, sshAlias: "" },
+ rooms: { turnTimeoutMinutes: 10 }, localVm: { mode: "shared", maxInstances: 1 },
+};
+
+it("keeps person-paused bots and departments through a config broadcast", () => {
+ const frame = { ...baseFrame, pausedByPerson: { bots: ["ada"], departments: ["Sales"] }, heldBots: ["ada", "bo"] };
+ expect(configStatusFromFrame(frame)).toMatchObject({ pausedByPerson: frame.pausedByPerson, heldBots: frame.heldBots });
+});
+
+it("keeps empty pause lists after the person resumes the last bot or department", () => {
+ const frame = { ...baseFrame, pausedByPerson: { bots: [], departments: [] }, heldBots: [] };
+ expect(configStatusFromFrame(frame)).toMatchObject({ pausedByPerson: frame.pausedByPerson, heldBots: [] });
+});
+
+it("leaves older servers' missing pause fields absent and keeps plan pauses separate", () => {
+ const config = configStatusFromFrame({ ...baseFrame, awakeLimit: 3, pausedBots: ["plan-limited"] });
+ expect(config).not.toHaveProperty("pausedByPerson");
+ expect(config).not.toHaveProperty("heldBots");
+ expect(config).toMatchObject({ awakeLimit: 3, pausedBots: ["plan-limited"] });
+});
diff --git a/src/lib/config-status-frame.ts b/src/lib/config-status-frame.ts
index 7355ef9ba7..6ddc797d4e 100644
--- a/src/lib/config-status-frame.ts
+++ b/src/lib/config-status-frame.ts
@@ -3,7 +3,7 @@ import type { ConfigStatus } from "@/state/config-status";
// A section left out here is wiped from state.config whenever a config frame lands.
export type ConfigStatusFrame = Pick<
ConfigStatus,
- "awakeLimit" | "pausedBots" | "xai" | "mistral" | "cerebras" | "groq" | "greenference" | "modelgo" | "meta" | "deepseek" | "xResearch" | "treg" | "postiz" | "anthropic" | "openai" | "openrouter" | "openaiCompat" | "fleet" | "composio" | "box" | "vps" | "rooms" | "mcp" | "threads" | "automaticRecovery" | "cacheKeepWarm" | "localVm" | "opencodeGo" | "tts" | "decider" | "helpers" | "imageGen" | "live" | "savedKeys" | "profile" | "everyBotRules" | "language" | "features" | "onboarding" | "browserEngine" | "browserProfiles" | "edition" | "budgets" | "billing" | "managedPolicy" | "cloudHome" | "team" | "workspaceBanner" | "toolGroups"
+ "awakeLimit" | "pausedBots" | "pausedByPerson" | "heldBots" | "xai" | "mistral" | "cerebras" | "groq" | "greenference" | "modelgo" | "meta" | "deepseek" | "xResearch" | "treg" | "postiz" | "anthropic" | "openai" | "openrouter" | "openaiCompat" | "fleet" | "composio" | "box" | "vps" | "rooms" | "mcp" | "threads" | "automaticRecovery" | "cacheKeepWarm" | "localVm" | "opencodeGo" | "tts" | "decider" | "helpers" | "imageGen" | "live" | "savedKeys" | "profile" | "everyBotRules" | "language" | "features" | "onboarding" | "browserEngine" | "browserProfiles" | "edition" | "budgets" | "billing" | "managedPolicy" | "cloudHome" | "team" | "workspaceBanner" | "toolGroups"
>;
export function configStatusFromFrame(frame: ConfigStatusFrame): ConfigStatus {
@@ -42,6 +42,7 @@ export function configStatusFromFrame(frame: ConfigStatusFrame): ConfigStatus {
budgets: frame.budgets,
billing: frame.billing,
managedPolicy: frame.managedPolicy,
+ ...(frame.pausedByPerson ? { pausedByPerson: frame.pausedByPerson } : {}), ...(frame.heldBots ? { heldBots: frame.heldBots } : {}),
...(frame.cloudHome ? { cloudHome: true } : {}), ...(frame.team ? { team: frame.team } : {}), ...(frame.awakeLimit !== undefined ? { awakeLimit: frame.awakeLimit } : {}), ...(frame.pausedBots ? { pausedBots: frame.pausedBots } : {}), ...(frame.workspaceBanner ? { workspaceBanner: frame.workspaceBanner } : {}),
};
}