Skip to content

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

Reject any thread-scoped notice for a conversation that is not open

koeria3a3137508d01
diff --git a/src/state/store.test.ts b/src/state/store.test.ts
index b7ef8290ea..183fe96042 100644
--- a/src/state/store.test.ts
+++ b/src/state/store.test.ts
@@ -3114,6 +3114,25 @@ describe("restoring the open conversation", () => {
expect(seen.notice).toEqual(current);
});
+ it("ignores a held room-steer note arriving after navigation without erasing the current notice", async () => {
+ const { stream } = await boot();
+ stream.send(hello());
+ await settle();
+ let respond!: (response: Response) => void;
+ vi.stubGlobal("fetch", () => new Promise<Response>((resolve) => { respond = resolve; }));
+ const settled = vi.fn();
+ flushSync(() => dispatch({ type: "select", id: "room-1" }));
+ flushSync(() => dispatch({ type: "steerGroupQueued", groupId: "room-1", queueId: "delayed-room-plain", onSettled: settled }));
+ await settle();
+ flushSync(() => dispatch({ type: "select", id: "bot-2" }));
+ const current = { kind: "steer-images" as const, botName: null, threadId: "bot-2-thread" };
+ flushSync(() => dispatch({ type: "notice", notice: current }));
+ respond(new Response(JSON.stringify({ ok: true, queued: true, threadId: "room-thread" })));
+ await settle();
+ expect(settled).toHaveBeenCalledOnce();
+ expect(seen.notice).toEqual(current);
+ });
+
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 b6a43974e4..35271d46f9 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -2248,7 +2248,7 @@ export function StoreProvider({ children }: { children: ReactNode }) {
return botBeforeSend ? openOnboardingCard(botBeforeSend) : undefined;
})();
const threadOf = (s: AppState) => { const bot = s.bots.find((b) => b.id === s.selectedId); return s.groups.find((g) => g.id === s.selectedId)?.threadId ?? bot?.switchingTo ?? bot?.threadId; }, previousOpened = threadOf(store.getState());
- if (action.type === "notice" && action.notice?.kind === "steer-images" && action.notice.threadId !== previousOpened) return;
+ if (action.type === "notice" && action.notice?.threadId !== undefined && action.notice.threadId !== previousOpened) return;
if (
action.type !== "cancelQueued" &&
action.type !== "cancelGroupQueued" &&