Skip to content

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

Thread links: a thread the server no longer has says so

milind-soni18650562901b
diff --git a/src/state/notification-open.test.ts b/src/state/notification-open.test.ts
index 8680c7b158..016cd3a32b 100644
--- a/src/state/notification-open.test.ts
+++ b/src/state/notification-open.test.ts
@@ -181,6 +181,7 @@ describe("following a notification", () => {
server = { ...server, tasks: server.tasks!.filter((task) => task.threadId !== "finished") };
await followNotification();
expect(scoutNow().threadId).toBe("left-behind");
+ expect(state.notice).toEqual({ kind: "thread-gone", botName: null });
expect(reads()).toEqual([]);
stream().send({ kind: "bot", bot: structuredClone(server) });
await settle();
diff --git a/src/state/store.tsx b/src/state/store.tsx
index f12a426fe8..2a142e0e7a 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -2741,7 +2741,7 @@ export function StoreProvider({ children }: { children: ReactNode }) {
const message = error instanceof Error ? error.message : String(error);
settle(message);
if (action.type === "newTask" && action.onError) action.onError(message);
- else showError(error);
+ else if (action.type === "switchTask" && error instanceof ApiError && error.status === 404) rawDispatch({ type: "notice", notice: { kind: "thread-gone", botName: null } }); else showError(error);
});
break;
}
@@ -2773,7 +2773,7 @@ export function StoreProvider({ children }: { children: ReactNode }) {
case "switchGroupTask":
api<{ group?: Partial<Group> & { id: string } }>(`/api/groups/${action.groupId}/tasks/${action.threadId}?messages=${SWITCH_MESSAGE_COUNT}`, { method: "POST" })
.then(roomAnswer(action.groupId, true))
- .catch(showError);
+ .catch((error) => (error instanceof ApiError && error.status === 404 ? rawDispatch({ type: "notice", notice: { kind: "thread-gone", botName: null } }) : showError(error)));
break;
case "renameGroupTask":
case "pinGroupTask":