Skip to content

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

Tell the person when a Steer with pictures waits for the next turn

koeria8089f84e36d1
diff --git a/server/direct-send.ts b/server/direct-send.ts
index 2cffa8e103..edc9ba61c4 100644
--- a/server/direct-send.ts
+++ b/server/direct-send.ts
@@ -28,4 +28,4 @@ export interface DirectSendInput {
export type DirectSendReceipt =
| { ok: true; threadId: string; message: Message; steered?: true }
- | { ok: true; queued: true; queueId: string; threadId: string; reason?: SteerQueueReason; why?: string };
+ | { ok: true; queued: true; queueId: string; threadId: string; reason?: SteerQueueReason; why?: string; blockedBy?: "images" };
diff --git a/server/index.ts b/server/index.ts
index 9152332cc5..7769ffc0af 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -7307,7 +7307,7 @@ async function acceptDirectSend(
});
if (personsOwn && !chose) personFirst.wait(threadId, {});
if (chose === "restart") await restartForPerson(botId, threadId, trigger);
- return { ok: true as const, queued: true as const, queueId: queued.id, threadId };
+ return { ok: true as const, queued: true as const, queueId: queued.id, threadId, ...(busyAdmission.action === "queue" && busyAdmission.blockedBy ? { blockedBy: busyAdmission.blockedBy } : {}) };
}
return startOrQueueDirectMessage(botId, threadId, text, replyTo, sendId, sender, trigger, via, callId, dataContext, app, mentions);
},
diff --git a/server/steer-e2e.test.ts b/server/steer-e2e.test.ts
index 02131b5aab..b200d3345c 100644
--- a/server/steer-e2e.test.ts
+++ b/server/steer-e2e.test.ts
@@ -1049,9 +1049,10 @@ posixOnly("mid-turn steering e2e", () => {
const imagePath = join(attachments, "123e4567-e89b-42d3-a456-426614174008.png");
writeFileSync(imagePath, "codex png");
const imageText = `see this\n\n<attached-image path="${imagePath}" name="codex.png" />`;
- const queued = await api("POST", `/api/bots/${created.id}/messages`, { text: imageText });
+ const queued = await api("POST", `/api/bots/${created.id}/messages`, { text: imageText, followUp: "steer" });
expect(queued.status).toBe(202);
- expect(queued.body).toMatchObject({ ok: true, queued: true });
+ expect(queued.body).toMatchObject({ ok: true, queued: true, blockedBy: "images" });
+ expect(queued.body.steered).toBeUndefined();
const still = await api("POST", `/api/bots/${created.id}/queue/${queued.body.queueId}/steer`, {
threadId: created.threadId,
diff --git a/src/state/store.test.ts b/src/state/store.test.ts
index db7729e406..b6bab26898 100644
--- a/src/state/store.test.ts
+++ b/src/state/store.test.ts
@@ -3029,6 +3029,27 @@ describe("restoring the open conversation", () => {
expect(seen.notice).toMatchObject({ kind: "note", text: expect.stringContaining("Nothing was stopped") });
});
+ it("a Steer send that stays queued because of pictures says why", async () => {
+ const { stream } = await boot();
+ stream.send(hello());
+ await settle();
+ vi.stubGlobal("fetch", (path: string) => Promise.resolve(new Response(JSON.stringify(
+ path.replace(/\?since=[^&]*$/, "").startsWith("/api/bots/bot-1/messages")
+ ? { ok: true, queued: true, threadId: "bot-1-thread", queueId: "q-image-send", blockedBy: "images" }
+ : {},
+ ))));
+ flushSync(() => dispatch({
+ type: "send",
+ botId: "bot-1",
+ text: "see this",
+ threadId: "bot-1-thread",
+ followUp: "steer",
+ sendId: "send-image",
+ }));
+ await settle();
+ expect(seen.notice).toEqual({ kind: "steer-images", botName: null });
+ });
+
it("the provider restores the conversation remembered on this device", async () => {
const { stored, stream } = await boot({ [LAST_CONVERSATION_KEY]: "room-1" });
stream.send(hello());
diff --git a/src/state/store.tsx b/src/state/store.tsx
index 6018718807..61a12ba552 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -2374,16 +2374,8 @@ export function StoreProvider({ children }: { children: ReactNode }) {
rawDispatch({ type: "messageAdded", threadId: body.threadId, message: body.message });
rawDispatch({ type: "forkPanelMessage", threadId: body.threadId, message: body.message });
}
- if (
- body?.queued &&
- typeof body.threadId === "string" &&
- typeof body.queueId === "string"
- ) {
- rawDispatch({
- type: "optimisticMessageRemoved",
- threadId: body.threadId,
- sendId,
- });
+ if (body?.queued && typeof body.threadId === "string" && typeof body.queueId === "string") {
+ rawDispatch({ type: "optimisticMessageRemoved", threadId: body.threadId, sendId });
rawDispatch({
type: "pendingQueued",
threadId: body.threadId,
@@ -2391,6 +2383,7 @@ export function StoreProvider({ children }: { children: ReactNode }) {
text: action.text,
reason: body.reason === "capacity" || body.reason === "group-turn" ? body.reason : undefined,
});
+ if (body.blockedBy === "images") wrapped({ type: "notice", notice: { kind: "steer-images", botName: null } });
}
})
.catch((error) => {