Skip to content

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

Following conversations take a default-only model change at once

laijsg13b8b294f9447
diff --git a/shared/thread-model.ts b/shared/thread-model.ts
index 9139e51e3f..b306203dc2 100644
--- a/shared/thread-model.ts
+++ b/shared/thread-model.ts
@@ -20,3 +20,10 @@ export function threadsOnOwnModel<T extends { modelSelection?: ModelSelection; f
): T[] {
return tasks.filter((task) => task.followsBotModel === false && !sameModelSelection(task.modelSelection ?? botModel, botModel));
}
+
+export function followBotModel<T extends { modelSelection?: ModelSelection; followsBotModel?: boolean }>(
+ botModel: ModelSelection,
+ tasks: readonly T[] | undefined,
+): T[] | undefined {
+ return tasks?.map((task) => task.followsBotModel ? { ...task, modelSelection: botModel } : task);
+}
diff --git a/src/state/store.test.ts b/src/state/store.test.ts
index db7729e406..6cd0dd6033 100644
--- a/src/state/store.test.ts
+++ b/src/state/store.test.ts
@@ -172,6 +172,16 @@ describe("independent bot threads", () => {
expect(updated.bots[0]?.tasks?.[1]).toEqual(bot.tasks?.[1]);
});
+ it("moves following threads with a default-only model change and leaves own picks alone", () => {
+ const following = { threadId: "third", title: "Third", createdAt: 3, modelSelection: bot.modelSelection, followsBotModel: true };
+ const own = { ...bot.tasks![0]!, followsBotModel: false };
+ const selection = { instanceId: "codex", model: "new-default", effort: "low" as const };
+ const updated = reducer({ ...start(), bots: [{ ...bot, tasks: [own, following] }] }, { type: "setModel", botId: bot.id, selection });
+ expect(updated.bots[0]?.modelSelection).toEqual(selection);
+ expect(currentTaskBot(updated.bots[0]!, "third").modelSelection).toEqual(selection);
+ expect(updated.bots[0]?.tasks?.[0]).toEqual(own);
+ });
+
it("does not persist request-only model scope on a task", () => {
const updated = reducer(start(), { type: "updateTask", botId: bot.id, threadId: "first", patch: { modelSelection: bot.modelSelection, updateBotDefault: true } });
expect(updated.bots[0]?.tasks?.[0]).not.toHaveProperty("updateBotDefault");
diff --git a/src/state/store.tsx b/src/state/store.tsx
index c63c5d6cea..d59985a5a6 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -30,7 +30,7 @@ import type { MausColor, MausMotion } from "@/lib/mascot";
import type { BotAvatarCrop } from "../../shared/bot-avatar";
import { approvalModeFor, type ApprovalMode } from "../../shared/approval-mode";
import { askResetBridge, desktopCapabilitiesNow } from "@/lib/desktop"; import { isBotLimitRefusal, showCreatedPaused, stoppedAtBotLimit } from "@/lib/bot-limit";
-import { sameModelSelection } from "../../shared/thread-model";
+import { followBotModel, sameModelSelection } from "../../shared/thread-model";
import type { BotBodyId } from "../../shared/bot-body";
import { StoreRefContext } from "./store-ref-context";
import type { QuestionRequestCardData } from "../../shared/ask-question";
@@ -1344,7 +1344,7 @@ export function reducer(state: AppState, action: Action): AppState {
return updateBot(picked, action.botId, (bot) => ({ ...bot, tasks: bot.tasks?.map((task) => task.threadId !== action.threadId ? task
: { ...task, followsBotModel: Boolean(action.updateBotDefault) || sameModelSelection(action.selection, bot.modelSelection) }) }));
}
- return reconcileModelVariantSessions(updateBot(state, action.botId, (b) => ({ ...b, modelSelection: action.selection })));
+ return reconcileModelVariantSessions(updateBot(state, action.botId, (b) => ({ ...b, modelSelection: action.selection, tasks: followBotModel(action.selection, b.tasks) })));
case "updateTask": {
const patch = taskPatchFields(action.patch);
return reconcileModelVariantSessions(updateBot(state, action.botId, (bot) => ({