Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(model-picker): restore variant reset
Ahmar55b15b719c39
diff --git a/src/components/ModelPicker.simple.test.ts b/src/components/ModelPicker.simple.test.tsindex 0f3d83db7e..574c9bd594 100644--- a/src/components/ModelPicker.simple.test.ts+++ b/src/components/ModelPicker.simple.test.ts@@ -488,6 +488,24 @@ describe("the model picker in Simple mode", () => {}));});+ it("lets a contained Antigravity picker return a named variant to the session setting", () => {+ const variants = [{ id: "low", label: "Low" }, { id: "high", label: "High" }];+ fixture.instances = [{ ...engine("antigravity", "antigravityAgent", "Google Gemini", "subscription", [+ { id: "gemini-3.8-flash", label: "Gemini 3.8 Flash", variants },+ ]), capabilities: { modelVariants: true } }];+ const forBot = { ...bot(undefined, "antigravity", "gemini-3.8-flash"), modelSelection: {+ instanceId: "antigravity", model: "gemini-3.8-flash", variant: "high",+ } };+ const opened = open(forBot, { contained: true });+ const simple = pane(opened)!;+ expect(opened.html).toContain("Use session setting");+ expect((simple.props as { onResetVariant?: () => void }).onResetVariant).toBeTypeOf("function");+ (simple.props as { onResetVariant: () => void }).onResetVariant();+ expect(fixture.dispatch).toHaveBeenLastCalledWith(expect.objectContaining({+ type: "setModel", selection: { instanceId: "antigravity", model: "gemini-3.8-flash" },+ }));+ });+it.each([[true, true], [false, false], [null, false]] as const)("lets the bot panel's picker, given the open thread, set the default only for the Cloud owner (owner: %s)",(ownerOrAdmin, updatesDefault) => {diff --git a/src/components/ModelPicker.test.ts b/src/components/ModelPicker.test.tsindex 0251ac793b..413a1af221 100644--- a/src/components/ModelPicker.test.ts+++ b/src/components/ModelPicker.test.ts@@ -26,8 +26,9 @@ vi.mock("@/state/store", async (importOriginal) => ({// These cases cover the full picker; Simple mode has its own file.vi.mock("@/lib/interface-mode", () => ({ useAdvancedMode: () => true, setAdvancedMode: () => {} }));-const { EffortRow, ModelPicker, ModelVariantRow, modelSelectionForPick } = await import("./ModelPicker");+const { EffortRow, ModelPicker, ModelVariantRow } = await import("./ModelPicker");const { ClaudeAccountSelect, ModelEngineRail } = await import("./ModelPickerFull");+const { modelSelectionForPick } = await import("@/lib/model-choices");afterAll(() => vi.unstubAllGlobals());diff --git a/src/components/ModelPicker.tsx b/src/components/ModelPicker.tsxindex b4e20dd405..e3a81599d5 100644--- a/src/components/ModelPicker.tsx+++ b/src/components/ModelPicker.tsx@@ -7,7 +7,8 @@ import type { ModelVariantOption } from "../../shared/runtime-events";import { filterCustomModels, partitionCustomModels, suggestedModels } from "@/lib/custom-models";import { configuredModelInstances, isClaudeAccount, isCustomOnly, SIGN_IN_FAMILY_LABEL, signInFamily } from "@/lib/engine-rail";import { modelName, simpleModelMenu } from "@/lib/simple-model-menu";-import { choiceIsSelected, modelChoices, type ModelChoice } from "@/lib/model-choices";+import { choiceIsSelected, modelChoices, modelSelectionForPick, type ModelChoice } from "@/lib/model-choices";+export { modelSelectionForPick } from "@/lib/model-choices";import { pickerPlacement, type PickerPlacement } from "@/lib/picker-placement";import { isTypeaheadKey, TYPEAHEAD_RESET_MS, typeaheadMatch, typeaheadText, type Typeahead } from "@/lib/menu-keys";import { usePopoverDismiss } from "@/hooks/use-popover-dismiss";@@ -233,16 +234,6 @@ export function ModelVariantRow({ bot, threadId, updateBotDefault, className, la);}-export function modelSelectionForPick(selection: ModelSelection, instance: InstanceInfo, model: string): ModelSelection {- const next: ModelSelection = { instanceId: instance.instanceId, model };- if (instance.instanceId === selection.instanceId) {- if (instance.capabilities?.modelVariants) {- if (model === selection.model && selection.variant !== undefined) next.variant = selection.variant;- } else if (selection.effort) next.effort = selection.effort;- }- return next;-}-const POPOVER_WIDTH = 420;const POPOVER_HEIGHT = 600;export const SIMPLE_POPOVER_WIDTH = 300;@@ -535,6 +526,12 @@ export function ModelPicker({close(true);};+ const resetVariant = contained && selection.variant !== undefined ? () => {+ const { variant: _variant, ...nextSelection } = selection;+ dispatch({ type: "setModel", botId: bot.id, threadId: threadId ?? bot.threadId, updateBotDefault: !threadId || simpleUpdatesBotDefault, selection: nextSelection });+ close(true);+ } : undefined;+const official = railInstance ? modelChoices(railInstance, railInstance.models.options.filter((option) => !option.custom)) : [];const custom = railInstance?.models.options.filter((option) => option.custom) ?? [];const currentModel = selection.instanceId === railInstance?.instanceId@@ -1097,6 +1094,7 @@ export function ModelPicker({onSetUp={openFull}onCheckAgain={(instance) => refreshModels(instance.instanceId)}onManage={openEngines}+ onResetVariant={resetVariant}/>) : fullPane}</div>diff --git a/src/components/SimpleModelMenu.tsx b/src/components/SimpleModelMenu.tsxindex 7a08fc2d7c..c51d7f8b06 100644--- a/src/components/SimpleModelMenu.tsx+++ b/src/components/SimpleModelMenu.tsx@@ -24,6 +24,7 @@ export interface SimpleMenuActions {onSetUp: (instance: InstanceInfo, keyboard: boolean) => void;onCheckAgain: (instance: InstanceInfo) => void;onManage: () => void;+ onResetVariant?: () => void;}export interface SimpleModelMenuProps extends SimpleMenuActions {@@ -276,6 +277,12 @@ export function SimpleModelMenu(props: SimpleModelMenuProps) {<div role="separator" className={MENU_SEPARATOR} /></>)}+ {props.onResetVariant && (+ <button type="button" data-menu-row data-simple-variant-default onClick={props.onResetVariant} className={MENU_ROW}>+ <Gutter />+ <span className="min-w-0 flex-1 truncate">{t("model.variant.session")}</span>+ </button>+ )}<button type="button" data-menu-row data-simple-manage onClick={props.onManage} className={MENU_ROW}><Gutter><Settings size={16} strokeWidth={MENU_STROKE} className={MENU_ICON} aria-hidden="true" /></Gutter><span className="min-w-0 flex-1 truncate">{t("model.simple.manage")}</span>diff --git a/src/lib/model-choices.ts b/src/lib/model-choices.tsindex 50941a47bf..23303bfbfe 100644--- a/src/lib/model-choices.ts+++ b/src/lib/model-choices.ts@@ -21,3 +21,12 @@ export function modelChoices(instance: InstanceInfo, options: readonly ModelOptiexport function choiceIsSelected(choice: ModelChoice, selection: ModelSelection): boolean {return (choice.nativeModel ?? choice.id) === selection.model && choice.variant === selection.variant;}++export function modelSelectionForPick(selection: ModelSelection, instance: InstanceInfo, model: string): ModelSelection {+ const next: ModelSelection = { instanceId: instance.instanceId, model };+ if (instance.instanceId === selection.instanceId) {+ if (instance.capabilities?.modelVariants && model === selection.model && selection.variant !== undefined) next.variant = selection.variant;+ else if (!instance.capabilities?.modelVariants && selection.effort) next.effort = selection.effort;+ }+ return next;+}