Skip to content

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

fix: keep a busy reasoning pick off the bot default when the thread has its own model

AdityaUmalef07ff7d311f6
diff --git a/server/index.ts b/server/index.ts
index a93e622de4..815e8d26c3 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -2682,7 +2682,6 @@ function checkedModelSelection(
}
selection.variant = value.variant;
}
- // Each turn reads its reasoning level when it starts, so effort or variant may change while the bot works; the model may not.
const modelChanged = current && (selection.instanceId !== current.selection.instanceId || selection.model !== current.selection.model);
if (current?.busy && modelChanged) {
return { ok: false, status: 409, error: "the bot is working — stop it before changing models" };
diff --git a/src/components/ModelPicker.dom.test.ts b/src/components/ModelPicker.dom.test.ts
index 8ff528bf24..6bbd1a3898 100644
--- a/src/components/ModelPicker.dom.test.ts
+++ b/src/components/ModelPicker.dom.test.ts
@@ -446,16 +446,33 @@ describe("while the bot is working", () => {
const panel = menu()!.querySelector<HTMLElement>("[data-model-busy]")!;
expect(panel.textContent).toContain("Reasoning level applies from the next message");
expect(panel.textContent).toContain("Stop this thread's turn before changing its model");
- expect(menu()!.textContent).not.toContain("Claude Sonnet 5.5");
+ expect(panel.textContent).toContain("The bot's model: this thread, groups, and every thread that uses the bot's model.");
+ for (const option of three) expect(menu()!.textContent).not.toContain(option.label);
const effort = panel.querySelector<HTMLSelectElement>("select")!;
effort.value = "high";
flushSync(() => effort.dispatchEvent(new Event("change", { bubbles: true })));
expect(fixture.dispatch).toHaveBeenLastCalledWith(expect.objectContaining({
- type: "setModel", botId: "scout", threadId: "thread-scout",
+ type: "setModel", botId: "scout", threadId: "thread-scout", updateBotDefault: true,
selection: { instanceId: "claude", model: "claude-opus-5-5", effort: "high" },
}));
});
+ it("keeps a reasoning pick on a thread with its own model to that thread, so the bot's model is not overwritten", async () => {
+ const busy = { ...ownModelThread("claude-sonnet-5-5", "claude-opus-5-5"), busy: true };
+ fixture.bots = fixture.bots.map((bot) => ({ ...bot, busy: true }));
+ render(busy);
+ await openWith("click");
+ const panel = menu()!.querySelector<HTMLElement>("[data-model-busy]")!;
+ expect(panel.textContent).toContain("This thread only. It keeps this model when the bot's model changes.");
+ const effort = panel.querySelector<HTMLSelectElement>("select")!;
+ effort.value = "high";
+ flushSync(() => effort.dispatchEvent(new Event("change", { bubbles: true })));
+ const sent = fixture.dispatch.mock.lastCall![0];
+ expect(sent).toMatchObject({ type: "setModel", botId: "scout", threadId: "thread-scout",
+ selection: { instanceId: "claude", model: "claude-sonnet-5-5", effort: "high" } });
+ expect(sent.updateBotDefault).toBeUndefined();
+ });
+
it("stays locked when the engine has no reasoning level to change", () => {
fixture.instances = [{ ...claude(three), capabilities: {} }];
const busy = { ...scout(), busy: true };
diff --git a/src/components/ModelPicker.tsx b/src/components/ModelPicker.tsx
index 7695a75cf0..39649b73a4 100644
--- a/src/components/ModelPicker.tsx
+++ b/src/components/ModelPicker.tsx
@@ -225,7 +225,6 @@ export function ModelPicker({
const { state, dispatch: storeDispatch, refreshInstances, refreshModels: refreshInstanceModels } = useStore();
const [open, setOpen] = useState(false);
const { bot, dispatch } = useAiSwitch({ bot: shown, threadId, contained, dispatch: storeDispatch, setOpen: (next) => (next ? openMenu() : setOpen(false)) });
- // While the bot works the menu still opens to its reasoning level, which applies from the next turn; the model stays locked.
const busyInstance = bot.busy && !contained ? state.instances.find((instance) => instance.instanceId === bot.modelSelection.instanceId) : undefined;
const locked = Boolean(bot.busy) && !(busyInstance && offersReasoning(state, busyInstance, bot.modelSelection, threadId ?? bot.threadId));
const motion = useMenuMotion(open && !locked);
@@ -451,6 +450,9 @@ export function ModelPicker({
const botModelName = botModelInstance
? `${botModelInstance.displayName} · ${modelLabel(botModelInstance, profile.modelSelection.model)}`
: profile.modelSelection.model;
+ // Only a thread on the bot's own model may carry a busy reasoning change to the bot default; otherwise the save would also copy this thread's model to the bot.
+ const busyUpdatesBotDefault = Boolean(threadId) && (simpleView ? simpleUpdatesBotDefault : scope === "bot")
+ && bot.modelSelection.instanceId === profile.modelSelection.instanceId && bot.modelSelection.model === profile.modelSelection.model;
const ownModelThreads = threadsOnOwnModel(profile.modelSelection, profile.tasks ?? []).length;
const pickBotModel = () => {
@@ -977,10 +979,15 @@ export function ModelPicker({
compact
bot={shown}
threadId={threadId}
- updateBotDefault={Boolean(threadId) && (simpleView ? simpleUpdatesBotDefault : scope === "bot")}
+ updateBotDefault={busyUpdatesBotDefault}
className="px-3.5 py-[5px]"
label={<span className="text-[13px] leading-[18px] text-ink">{active?.capabilities?.modelVariants ? t("model.simple.reasoning") : t("model.section.effort")}</span>}
/>
+ {threadId && (
+ <p data-model-busy-scope className="px-3.5 py-1 text-[12px] leading-4 text-ink-tertiary">
+ {t(busyUpdatesBotDefault ? "model.scope.botHelp" : "model.scope.threadHelp")}
+ </p>
+ )}
<p className="px-3.5 py-1 text-[12px] leading-4 text-ink-tertiary">{t("model.reasoningNextTurn")}</p>
<p className="px-3.5 py-1 text-[12px] leading-4 text-ink-tertiary">{t(threadId ? "model.threadBusy" : "model.busy")}</p>
</div>