Skip to content

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

Show Pause and Resume every bot in the Advanced-mode bot menu

Bugfixer 2f71e1762b928
diff --git a/src/components/SidebarBotMenu.tsx b/src/components/SidebarBotMenu.tsx
index 3a4685b259..6aec518e60 100644
--- a/src/components/SidebarBotMenu.tsx
+++ b/src/components/SidebarBotMenu.tsx
@@ -207,6 +207,16 @@ export function BotContextMenu({
);
const divider = (key: string) => <div key={key} role="separator" className={MENU_ITEM_SEPARATOR} />;
+ // Only the owner or an admin pauses; a bot paused with its department is resumed from the department's menu.
+ const pausedHere = isPausedHere(state.config, "bot", bot.id), everyBotPaused = isEveryBotPaused(state.config);
+ const pause = admin !== true ? null : item(pausedHere ? <Play size={16} className="text-ink-secondary" /> : <Pause size={16} className="text-ink-secondary" />,
+ t(pausedHere ? "pause.resumeBot" : "pause.pauseBot"),
+ () => { void setPaused("bot", bot.id, !pausedHere).catch((error: unknown) => dispatch({ type: "error", message: error instanceof Error ? error.message : String(error) })); },
+ !pausedHere && isBotHeld(state.config, bot.id) ? { disabled: true, hint: t(everyBotPaused ? "pause.byAll" : "pause.byDepartment") } : undefined);
+ const pauseAll = admin !== true ? null : item(everyBotPaused ? <Play size={16} className="text-ink-secondary" /> : <Pause size={16} className="text-ink-secondary" />,
+ t(everyBotPaused ? "pause.resumeAll" : "pause.pauseAll"),
+ () => { void setEveryBotPaused(!everyBotPaused).catch((error: unknown) => dispatch({ type: "error", message: error instanceof Error ? error.message : String(error) })); });
+
if (simpleMenu) {
const showFlyout = (key: Flyout, focus: boolean) => {
more.openNow(key);
@@ -263,15 +273,6 @@ export function BotContextMenu({
{ disabled: readingBotId !== null, keepOpen: true },
)
: item(<BellDot size={16} className="text-ink-secondary" />, t("sidebar.bot.simple.markUnread"), () => dispatch({ type: "markUnread", botId: bot.id }));
- // Only the owner or an admin pauses; a bot paused with its department is resumed from the department's menu.
- const pausedHere = isPausedHere(state.config, "bot", bot.id), everyBotPaused = isEveryBotPaused(state.config);
- const pause = admin !== true ? null : item(pausedHere ? <Play size={16} className="text-ink-secondary" /> : <Pause size={16} className="text-ink-secondary" />,
- t(pausedHere ? "pause.resumeBot" : "pause.pauseBot"),
- () => { void setPaused("bot", bot.id, !pausedHere).catch((error: unknown) => dispatch({ type: "error", message: error instanceof Error ? error.message : String(error) })); },
- !pausedHere && isBotHeld(state.config, bot.id) ? { disabled: true, hint: t(everyBotPaused ? "pause.byAll" : "pause.byDepartment") } : undefined);
- const pauseAll = admin !== true ? null : item(everyBotPaused ? <Play size={16} className="text-ink-secondary" /> : <Pause size={16} className="text-ink-secondary" />,
- t(everyBotPaused ? "pause.resumeAll" : "pause.pauseAll"),
- () => { void setEveryBotPaused(!everyBotPaused).catch((error: unknown) => dispatch({ type: "error", message: error instanceof Error ? error.message : String(error) })); });
const moreItems = remoteClient ? [editProfile, owner, ...deleteAll] : [
editProfile,
pause,
@@ -437,6 +438,8 @@ export function BotContextMenu({
(!member || ownEdit) && item(<Copy size={16} className="text-ink-secondary" />, t("sidebar.bot.duplicate"), () =>
dispatch({ type: "duplicateBot", botId: bot.id }),
),
+ pause,
+ pauseAll,
divider("d2"),
item(<ClipboardCopy size={16} className="text-ink-secondary" />, t("sidebar.copyConversationId"), () => {
void copyText(bot.threadId);
diff --git a/src/components/SidebarBotRead.test.ts b/src/components/SidebarBotRead.test.ts
index 5df9454106..2968c05635 100644
--- a/src/components/SidebarBotRead.test.ts
+++ b/src/components/SidebarBotRead.test.ts
@@ -122,6 +122,31 @@ describe("bot menu bulk reads", () => {
});
});
+describe("Advanced mode's bot menu", () => {
+ const paused = (all: boolean) => { state = { ...state, config: { ...state.config!, pausedByPerson: { bots: [], departments: [], ...(all ? { all: true as const } : {}) }, heldBots: all ? [bot.id] : [] } }; };
+
+ it("offers Pause bot and Pause every bot while nothing is paused", () => {
+ paused(false); draw();
+ expect(button("Pause bot").disabled).toBe(false);
+ expect(button("Pause every bot")).toBeDefined();
+ });
+
+ it("offers Resume every bot while every bot is paused, as the paused line tells the person", async () => {
+ const fetch = vi.fn(async (_url: unknown, _init?: RequestInit) => new Response(JSON.stringify({ stopped: 0 }), { headers: { "content-type": "application/json" } }));
+ vi.stubGlobal("fetch", fetch); paused(true); draw();
+ expect(button("Pause bot").disabled).toBe(true);
+ flushSync(() => button("Resume every bot").click());
+ await expect.poll(() => fetch.mock.calls.length).toBe(1);
+ expect(JSON.parse(String(fetch.mock.calls[0]![1]?.body))).toEqual({ kind: "all", paused: false });
+ });
+
+ it("keeps the pause items off a paired desktop's menu", () => {
+ window.ogb = { remoteClient: { active: true } } as typeof window.ogb;
+ paused(true); draw();
+ expect(button("Resume every bot")).toBeUndefined();
+ });
+});
+
describe("Simple mode's bot menu", () => {
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
const sheet = () => document.querySelector<HTMLElement>('[data-bot-menu][aria-label="Actions for Reviewer"]')!;