Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Bot panel: a Reasoning pick is also the bot's default, like a Model pick (#6980)
Milind Sonice495e71a653
diff --git a/server/thread-model.test.ts b/server/thread-model.test.tsindex d92a68a2bf..84e58e78de 100644--- a/server/thread-model.test.ts+++ b/server/thread-model.test.ts@@ -67,6 +67,23 @@ describe("threads follow their bot's model", () => {expect(ownModel(open(), bot.id, picked.threadId)).toEqual(codex);});+ it("a reasoning level saved as the bot's default from a thread reaches its followers and new threads, not a thread with its own level", () => {+ const store = open();+ const bot = store.createBot();+ const picked = bot.threadId;+ const follower = store.createTask(bot.id, "Follower")!;+ const own = store.createTask(bot.id, "Own level")!;+ store.switchTaskModel(bot.id, own.threadId, { ...sonnet, effort: "low" }, false, false);++ store.switchTaskModel(bot.id, picked, { ...sonnet, effort: "high" }, true, false);+ expect(store.bot(bot.id)!.modelSelection).toEqual({ ...sonnet, effort: "high" });+ expect(ownModel(store, bot.id, picked)).toBeUndefined();+ expect(runsOn(store, bot.id, follower.threadId)).toEqual({ ...sonnet, effort: "high" });+ expect(runsOn(store, bot.id, own.threadId)).toEqual({ ...sonnet, effort: "low" });+ expect(runsOn(store, bot.id, store.createTask(bot.id, "Fresh")!.threadId)).toEqual({ ...sonnet, effort: "high" });+ expect(open().bot(bot.id)!.modelSelection).toEqual({ ...sonnet, effort: "high" });+ });+it("picking the bot's own model in a thread is following the bot", () => {const store = open();const bot = store.createBot();diff --git a/src/components/BotSettingsDialog.simple.test.ts b/src/components/BotSettingsDialog.simple.test.tsindex 95fd4b0f03..5daedc92ad 100644--- a/src/components/BotSettingsDialog.simple.test.ts+++ b/src/components/BotSettingsDialog.simple.test.ts@@ -659,7 +659,29 @@ describe("the Details tab", () => {expect(capture(() => EffortRow(row.props as Parameters<typeof EffortRow>[0])).html).toMatch(/<option value="max" selected="">/);});- it.each([true, false, null] as const)("sets a reasoning level on the open conversation only, whatever its model (owner: %s)", (ownerOrAdmin) => {+ it("sets an owner's reasoning level on the open conversation and as the bot's default, as the Model row does", () => {+ fixture.ownerOrAdmin = true;+ expect(pickHigh(thread())).toEqual({+ type: "setModel", botId: "scout", threadId: "thread-scout", updateBotDefault: true, selection: { ...opus, effort: "high" },+ });+ const haiku = { instanceId: "claude", model: "claude-haiku-4-5" };+ expect(pickHigh(thread({ ...haiku, effort: "low" }))).toEqual({+ type: "setModel", botId: "scout", threadId: "thread-scout", updateBotDefault: true, selection: { ...haiku, effort: "high" },+ });+ });++ it("keeps an owner's pick in a conversation on another engine to that conversation when the bot's approval level would first drop to Ask", () => {+ fixture.ownerOrAdmin = true;+ fixture.storeState = { ...fixture.storeState, instances: [engine(), engine({ instanceId: "codex", driverKind: "codex" })] };+ const codex = { instanceId: "codex", model: "gpt-5.6" };+ const onCodex = (approvalMode: Bot["approvalMode"]) => ({ ...thread({ ...codex, effort: "low" }), approvalMode });+ expect(pickHigh(onCodex("edits"))).toEqual({ type: "setModel", botId: "scout", threadId: "thread-scout", selection: { ...codex, effort: "high" } });+ expect(pickHigh(onCodex("full"))).toEqual({+ type: "setModel", botId: "scout", threadId: "thread-scout", updateBotDefault: true, selection: { ...codex, effort: "high" },+ });+ });++ it.each([false, null] as const)("sets a guest's reasoning level on the open conversation only, whatever its model (owner: %s)", (ownerOrAdmin) => {fixture.ownerOrAdmin = ownerOrAdmin;expect(pickHigh(thread())).toEqual({ type: "setModel", botId: "scout", threadId: "thread-scout", selection: { ...opus, effort: "high" } });const haiku = { instanceId: "claude", model: "claude-haiku-4-5" };@@ -677,7 +699,8 @@ describe("the Details tab", () => {fixture.ownerOrAdmin = ownerOrAdmin;blank();const haiku = { instanceId: "claude", model: "claude-haiku-4-5", effort: "max" as const };- expect(pickHigh(thread(haiku))).toEqual({ type: "setModel", botId: "scout", threadId: "new-chat-scout", selection: { ...opus, effort: "high" } });+ expect(pickHigh(thread(haiku))).toEqual({ type: "setModel", botId: "scout", threadId: "new-chat-scout",+ ...(ownerOrAdmin ? { updateBotDefault: true } : {}), selection: { ...opus, effort: "high" } });});it("shows the blank chat's choices in both rows, and a held level as picked", () => {@@ -700,6 +723,10 @@ describe("the Details tab", () => {const variants = capture(() => EffortRow(row.props as Parameters<typeof EffortRow>[0])).nodes[0]!;expect(variants.props.threadId).toBe("new-chat-scout");expect((variants.props.bot as Bot).modelSelection).toEqual({ ...opus, effort: "low" });+ expect(variants.props.updateBotDefault).toBe(false);+ fixture.ownerOrAdmin = true;+ const owned = ofType(botTab(thread({ ...opus, variant: "deep" })), EffortRow)!;+ expect(capture(() => EffortRow(owned.props as Parameters<typeof EffortRow>[0])).nodes[0]!.props.updateBotDefault).toBe(true);});it("leaves another bot's blank chat alone", () => {diff --git a/src/components/bot-panel/DetailsTab.tsx b/src/components/bot-panel/DetailsTab.tsxindex 08a1d7e262..a3d498b3db 100644--- a/src/components/bot-panel/DetailsTab.tsx+++ b/src/components/bot-panel/DetailsTab.tsx@@ -13,6 +13,8 @@ import { TryAsking } from "./TryAsking";import { Card, CardLabel, LabelAction, panelActionCls, NavRow, RowIcon, rowCls, RowText } from "./rows";import { useStoreDispatch, useStoreSelector } from "@/state/store-select";import { newChatBot } from "@/state/new-chat";+import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";+import { approvalModeFor, modelSwitchNeedsAsk } from "../../../shared/approval-mode";type Derived = ReturnType<typeof useBotSettingsDerived>;@@ -53,6 +55,14 @@ export function DetailsTab({ bot, derived, onOpen }: {// set the blank chat's choices, which the first send applies to the conversation it makes.const newChat = useStoreSelector((state) => state.newChat);const thread = currentTaskBot(newChatBot(bot, newChat));+ // Like the Model row, a Reasoning pick is also the bot's default, so new conversations start at it. A guest's pick+ // stays in their own conversation, and so does one that would move the bot onto an engine its approval level must+ // first drop to Ask for: the Model row asks about that, this row has nowhere to.+ const ownerOrAdmin = useOwnerOrAdmin();+ const instances = useStoreSelector((state) => state.instances);+ const driverOf = (instanceId: string) => instances.find((instance) => instance.instanceId === instanceId)?.driverKind;+ const reasoningSetsDefault = ownerOrAdmin === true+ && !modelSwitchNeedsAsk(approvalModeFor(bot), driverOf(bot.modelSelection.instanceId), driverOf(thread.modelSelection.instanceId));const routinesOn = derived.botRoutines.filter((routine) => routine.enabled).length;const conversationItems = CONVERSATION_ITEMS.flatMap((key) => items.filter((item) => item.key === key));@@ -73,6 +83,7 @@ export function DetailsTab({ bot, derived, onOpen }: {<EffortRowbot={thread}threadId={thread.threadId}+ updateBotDefault={reasoningSetsDefault}compactclassName={cn(rowCls, "min-w-0 flex-1 rounded-[8px]")}label={<span className="flex shrink-0 items-center gap-2.5"><RowIcon icon={Sparkles} /><RowText title={t("model.simple.reasoning")} /></span>}