Skip to content

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

fix: preserve Call for shared viewers during active turns

Locksley Lennox9900d7fbda3d
diff --git a/src/components/Composer.simple.test.ts b/src/components/Composer.simple.test.ts
index e8a0b64a80..33005b7989 100644
--- a/src/components/Composer.simple.test.ts
+++ b/src/components/Composer.simple.test.ts
@@ -14,6 +14,7 @@ import { BOT_BUTTON, botButtonTone } from "@/lib/bot-button";
const fixture = vi.hoisted(() => ({
advanced: false,
+ admin: true,
agentsMcp: true,
dispatch: vi.fn(),
call: null as Record<string, unknown> | null,
@@ -33,7 +34,7 @@ vi.mock("@/state/store", async (importOriginal) => {
});
vi.mock("@/lib/analytics", () => ({ track: vi.fn() }));
vi.mock("@/lib/cloud-guest", async (importOriginal) => ({ ...await importOriginal<typeof import("@/lib/cloud-guest")>(), useReactor: () => "user" }));
-vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => true }));
+vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => fixture.admin }));
vi.mock("@/lib/interface-mode", () => ({ useAdvancedMode: () => fixture.advanced, setAdvancedMode: vi.fn() }));
vi.mock("./CallView", () => ({ CallButton: (props: Record<string, unknown>) => {
fixture.call = props;
@@ -87,6 +88,7 @@ function openPlus() {
beforeEach(() => {
fixture.advanced = false;
+ fixture.admin = true;
fixture.agentsMcp = true;
fixture.liveCall = null;
fixture.config = undefined;
@@ -418,3 +420,13 @@ describe("the Advanced composer", () => {
});
});
});
+
+it.each([false, true])("keeps Call for a shared viewer without Stop permission (waiting for teammates: %s)", waiting => {
+ fixture.admin = false;
+ fixture.config = { team: true };
+ const shared: Bot = { ...bot, tasks: [{ threadId: bot.threadId, title: "Shared", createdAt: 1, busy: !waiting, waitingForTeammates: waiting, askedBy: { id: "other-person", name: "Other person" } }] };
+ restoreComposerDraft(`bot:${bot.id}:${bot.threadId}`, { text: "Follow-up from another viewer", attachments: [] });
+ render({ bot: shared });
+ expect(container.querySelector('[aria-label="Stop this turn"]')).toBeNull();
+ expect(fixture.call).toMatchObject({ bot: { id: "atlas" }, placement: "composer" });
+});
diff --git a/src/components/Composer.tsx b/src/components/Composer.tsx
index 55a8531b7e..6a397386dd 100644
--- a/src/components/Composer.tsx
+++ b/src/components/Composer.tsx
@@ -511,7 +511,7 @@ export function Composer({
const mayAct = useMayAct(), mayStop = !sharedChat || mayAct(profile?.tasks?.find((task) => task.threadId === threadId)?.askedBy);
const stoppable = (busy || Boolean(!group && bot?.waitingForTeammates)) && mayStop;
const stopInSlot = simpleDock && stoppable && !locked && !hasContent && !calling;
- const callShown = !simpleDock || !hasContent || stoppable || calling;
+ const callShown = !simpleDock || !hasContent || busy || Boolean(!group && bot?.waitingForTeammates) || calling;
const slot = slotColors(bot?.color, Boolean(group));
// A one-to-one bot at work: Enter does the chosen follow-up and Ctrl/⌘ with it the other one. Rooms keep their own queue.
const followUpFor = (alternate: boolean) => resolveFollowUp({ running: busy && !group && Boolean(bot), alternate, preferred: followUpDefault, canSteer }) ?? undefined;