Skip to content

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

Rooms: let a busy-room send follow the steer setting, like one-to-one

koeriab875d3abf5ce
diff --git a/src/components/Composer.tsx b/src/components/Composer.tsx
index fbbb0b658e..8a648502ae 100644
--- a/src/components/Composer.tsx
+++ b/src/components/Composer.tsx
@@ -526,9 +526,9 @@ export function Composer({
const stopInSlot = simpleDock && stoppable && !locked && !hasContent && !calling;
const callShown = singleRow || !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;
- const steersNow = group ? canSteer : followUpFor(false) === "steer";
+ // A bot at work: Enter does the chosen follow-up and Ctrl/⌘ with it the other one. A room joins in when its speaking engine can steer.
+ const followUpFor = (alternate: boolean) => resolveFollowUp({ running: busy && (group ? roomSteers : Boolean(bot)), alternate, preferred: followUpDefault, canSteer }) ?? undefined;
+ const steersNow = followUpFor(false) === "steer";
const sendNames = fork.command ? { label: t("composer.command.forkDesc"), title: t("composer.command.forkDesc") }
: sendLabels({ simple: !advanced, busy, canSteer: steersNow, name: busyName, sendLabel });
const retryFailedSend = (failed: FailedComposerSend) => {
@@ -556,7 +556,7 @@ export function Composer({
},
};
if (group) {
- dispatch({ type: "sendGroup", groupId: group.id, mode: failedMode, ...retry });
+ dispatch({ type: "sendGroup", groupId: group.id, mode: failedMode, ...(failed.followUp ? { followUp: failed.followUp } : {}), ...retry });
} else if (bot) {
dispatch({ type: "send", botId: bot.id, mode: failedMode, followUp: failed.followUp, ...retry });
}
@@ -602,7 +602,7 @@ export function Composer({
replyToId: replyTo?.id,
threadId,
mode: effectiveChannelMode, mentions: sentDraft.mentions,
- ...(points ? { pointed: points.pointed } : {}),
+ ...(points ? { pointed: points.pointed } : {}), ...(followUp ? { followUp } : {}),
onError: () => { points?.restore(); restoreDraft(sentDraft); },
});
roomMessageSent(effectiveChannelMode, busy);
diff --git a/src/state/store.test.ts b/src/state/store.test.ts
index c7aae53507..25b3eec42b 100644
--- a/src/state/store.test.ts
+++ b/src/state/store.test.ts
@@ -3040,6 +3040,33 @@ describe("restoring the open conversation", () => {
expect(seen.notice).toMatchObject({ kind: "note", text: expect.stringContaining("Nothing was stopped"), threadId: "room-thread" });
});
+ it("a room send with the steer follow-up hands its fresh queue head to the running turn", async () => {
+ const { stream } = await boot();
+ stream.send(hello());
+ await settle();
+ const steered: string[] = [];
+ vi.stubGlobal("fetch", (path: string) => {
+ const clean = path.replace(/\?since=[^&]*$/, "");
+ if (clean === "/api/groups/room-1/messages") {
+ return Promise.resolve(new Response(JSON.stringify({ ok: true, queued: true, threadId: "room-thread", queueId: "q-fresh" })));
+ }
+ if (clean === "/api/groups/room-1/queue/q-fresh/steer") {
+ steered.push(clean);
+ return Promise.resolve(new Response(JSON.stringify({ ok: true, steered: true, threadId: "room-thread", messages: [], queueIds: ["q-fresh"] })));
+ }
+ return Promise.resolve(new Response(JSON.stringify({})));
+ });
+
+ flushSync(() => dispatch({ type: "sendGroup", groupId: "room-1", text: "join in", sendId: "s-steer", followUp: "steer" }));
+ await settle();
+ expect(steered).toEqual(["/api/groups/room-1/queue/q-fresh/steer"]);
+
+ steered.length = 0;
+ flushSync(() => dispatch({ type: "sendGroup", groupId: "room-1", text: "just queue it", sendId: "s-queue", followUp: "queue" }));
+ await settle();
+ expect(steered).toEqual([]);
+ });
+
it("a Steer send that stays queued because of pictures says why", async () => {
const { stream } = await boot();
stream.send(hello());
diff --git a/src/state/store.tsx b/src/state/store.tsx
index 9fd0e33a1f..5fb52586a1 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -632,6 +632,7 @@ export type Action =
replyToId?: string;
threadId?: string;
mode?: "chat" | "goal"; mentions?: string[]; pointed?: import("../../shared/app-frame/point").PointedElement[];
+ followUp?: import("../../shared/follow-up").FollowUp;
onError?: () => void;
}
| {
@@ -2633,6 +2634,17 @@ export function StoreProvider({ children }: { children: ReactNode }) {
queueId: body.queueId,
text: action.text,
});
+ // The chosen "Sending while a bot works" applies in rooms too: hand the fresh queue head
+ // to the running turn. A driver that cannot steer keeps the queue and says so.
+ if (action.followUp === "steer") {
+ wrapped({
+ type: "steerGroupQueued",
+ groupId: action.groupId,
+ threadId: body.threadId,
+ queueId: body.queueId,
+ onSettled: () => {},
+ });
+ }
}
})
.catch((error) => {