Skip to content

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

Settings: ModelGo in the first three provider rows, directly above Cursor (#7557)

Milind Sonib3e824cdffac
diff --git a/src/components/EngineLibrary.tsx b/src/components/EngineLibrary.tsx
index bbb40c3e59..f97004e9e7 100644
--- a/src/components/EngineLibrary.tsx
+++ b/src/components/EngineLibrary.tsx
@@ -5,6 +5,7 @@ import { ArrowUpRight, Check, ChevronDown, RefreshCw } from "lucide-react";
import { type InstanceInfo } from "@/state/store";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
+import { sponsorRowRaised } from "@/lib/modelgo-offer";
import { InstanceProviderMark } from "./ProviderIcons";
import { useStoreActions } from "@/state/store-select";
@@ -79,16 +80,19 @@ export function EngineCard({ instance, children, summary, bare = false }: { inst
);
}
-export function EngineSections({ instances, renderEngine, isReady = engineReady }: {
+export function EngineSections({ instances, renderEngine, isReady = engineReady, offerModelgo = false }: {
instances: InstanceInfo[];
renderEngine: (instance: InstanceInfo) => ReactNode;
isReady?: (instance: InstanceInfo) => boolean;
+ /** The sponsor's provider stands among the first three of its section, where it may be offered (modelgoOfferable). */
+ offerModelgo?: boolean;
}) {
// Flat, instance-keyed siblings: separate section parents would remount a card that moves between groups and drop
// unsaved input.
return <div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))] items-start gap-3">
{[true, false].flatMap((ready) => {
- const rows = instances.filter((instance) => isReady(instance) === ready);
+ const listed = instances.filter((instance) => isReady(instance) === ready);
+ const rows = offerModelgo ? sponsorRowRaised(listed, listed.find((instance) => instance.driverKind === "modelgo"), (instance) => instance.driverKind === "cursorAgent") : listed;
if (!rows.length) return [];
const label = t(ready ? "onboarding.engines.ready" : "onboarding.engines.needsSetup");
return [
diff --git a/src/components/EnginesSettings.gemini.dom.test.ts b/src/components/EnginesSettings.gemini.dom.test.ts
index 10e4743d97..b6f570a8b1 100644
--- a/src/components/EnginesSettings.gemini.dom.test.ts
+++ b/src/components/EnginesSettings.gemini.dom.test.ts
@@ -117,7 +117,7 @@ describe("Settings → AI → Providers: Google AI Studio (#6352)", () => {
});
});
-describe("Settings → AI → Providers: ModelGo sits in the main list, after Google's row", () => {
+describe("Settings → AI → Providers: ModelGo sits in the main list, among its first three rows", () => {
const provider = (instanceId: string, driverKind: string, snapshot: InstanceInfo["snapshot"] = { state: "unavailable", reason: "No API key" }) => ({
instanceId, driverKind, displayName: instanceId === "modelgo" ? "ModelGo" : instanceId, access: "api", snapshot, models: { default: "model", options: [] },
} as unknown as InstanceInfo);
@@ -125,7 +125,7 @@ describe("Settings → AI → Providers: ModelGo sits in the main list, after Go
const order = () => [...container.querySelectorAll("[data-simple-engine]")].map((row) => row.getAttribute("data-simple-engine"));
const moreCount = () => [...container.querySelectorAll("button")].find((button) => button.textContent?.includes("More providers"))?.textContent;
- it("follows Google AI Studio, outside More providers, which no longer counts it", async () => {
+ it("follows Google AI Studio when nothing else leads, outside More providers, which no longer counts it", async () => {
fixture.state = { ...fixture.state, instances: [provider("groq", "groq"), provider("modelgo", "modelgo"), provider("mistral", "mistral")] };
await closed();
expect(order()).toEqual(["google-ai-studio", "modelgo"]);
@@ -136,7 +136,7 @@ describe("Settings → AI → Providers: ModelGo sits in the main list, after Go
expect(order().filter((id) => id === "modelgo"), "listed once, the fold open too").toHaveLength(1);
});
- it("follows the ready rows where Google's row is not offered, and stays among them, once, when it is ready itself", async () => {
+ it("follows the ready rows where Google's row is not offered, and keeps a higher place, once, when it is ready itself", async () => {
const ready = { state: "available", authenticated: true } as const;
fixture.state = { ...fixture.state, instances: [provider("modelgo", "modelgo"), provider("groq", "groq", ready), gemini(GEMINI_URL)] };
await closed();
@@ -159,3 +159,75 @@ describe("Settings → AI → Providers: ModelGo sits in the main list, after Go
expect(moreCount()).toContain("1");
});
});
+
+describe("Settings → AI → Providers: ModelGo stands directly above Cursor, within the first three rows", () => {
+ // The rows a fresh install lists first, in the server's order: sign-in agents lead the Simple list, Droid has no sign-in.
+ const agent = (instanceId: string, driverKind: string, signIn = true) => ({
+ instanceId, driverKind, displayName: instanceId, access: "subscription", cliDefault: instanceId, snapshot: { state: "unavailable", reason: "Not installed" },
+ models: { default: "model", options: [] }, ...(signIn ? { authentication: { method: "browser" } } : {}),
+ } as unknown as InstanceInfo);
+ const key = (instanceId: string, driverKind: string, snapshot: InstanceInfo["snapshot"] = { state: "unavailable", reason: "No API key" }) => ({
+ instanceId, driverKind, displayName: instanceId === "modelgo" ? "ModelGo" : instanceId, access: "api", snapshot, models: { default: "model", options: [] },
+ } as unknown as InstanceInfo);
+ const [grok, kimi, droid, cursor, vibe] = [agent("grok", "grokAgent"), agent("kimi", "kimiAgent"), agent("droid", "droidAgent", false), agent("cursor", "cursorAgent"), agent("mistralVibe", "mistralVibeAgent")];
+ const fleet = [grok, kimi, droid, cursor, vibe, key("groq", "groq"), key("modelgo", "modelgo"), key("meta", "meta")];
+ const simple = async (open = false) => { await act(async () => { root.render(createElement(EnginesSettings, { simple: true, more: { id: "more", open, onToggle: () => {} } })); }); };
+ const advanced = async () => { await act(async () => { root.render(createElement(EnginesSettings)); }); };
+ const order = () => [...container.querySelectorAll("[data-simple-engine]")].map((row) => row.getAttribute("data-simple-engine"));
+ const cards = () => [...container.querySelectorAll("[data-engine-card]")].map((card) => card.getAttribute("data-engine-card"));
+ const raised = (ids: Array<string | null>) => { expect(ids.indexOf("modelgo")).toBeGreaterThanOrEqual(0); expect(ids.indexOf("modelgo")).toBeLessThan(3); };
+
+ it("takes Cursor's third place in the Simple list, the others keeping their order, and is listed once with the fold open", async () => {
+ fixture.state = { ...fixture.state, instances: fleet };
+ await simple();
+ expect(order().slice(0, 6)).toEqual(["grok", "kimi", "modelgo", "cursor", "mistralVibe", "google-ai-studio"]);
+ await simple(true);
+ expect(order().filter((id) => id === "modelgo")).toHaveLength(1);
+ expect(order().slice(0, 4)).toEqual(["grok", "kimi", "modelgo", "cursor"]);
+ });
+
+ it("goes directly above Cursor when Cursor leads, and third when Cursor is lower or gone", async () => {
+ fixture.state = { ...fixture.state, instances: [cursor, grok, kimi, key("modelgo", "modelgo")] };
+ await simple();
+ expect(order().slice(0, 3)).toEqual(["modelgo", "cursor", "grok"]);
+ fixture.state = { ...fixture.state, instances: [grok, kimi, vibe, cursor, key("modelgo", "modelgo")] };
+ await simple();
+ expect(order().slice(0, 5)).toEqual(["grok", "kimi", "modelgo", "mistralVibe", "cursor"]);
+ fixture.state = { ...fixture.state, instances: [grok, kimi, vibe, key("modelgo", "modelgo")] };
+ await simple();
+ expect(order().slice(0, 4)).toEqual(["grok", "kimi", "modelgo", "mistralVibe"]);
+ });
+
+ it("keeps that place, once, when ModelGo is set up", async () => {
+ fixture.state = { ...fixture.state, instances: [grok, kimi, droid, cursor, vibe, key("modelgo", "modelgo", { state: "available", authenticated: true })] };
+ await simple(true);
+ expect(order().slice(0, 4)).toEqual(["grok", "kimi", "modelgo", "cursor"]);
+ expect(order().filter((id) => id === "modelgo")).toHaveLength(1);
+ });
+
+ it("leaves the order alone where ModelGo may not be offered, and stays hidden once hidden", async () => {
+ fixture.state = { ...fixture.state, instances: fleet, config: { managedPolicy: { organizationName: "Acme", companyModelsOnly: false, allowedEngines: ["groq"] } } };
+ await simple();
+ expect(order().slice(0, 4)).toEqual(["grok", "kimi", "cursor", "mistralVibe"]);
+ expect(order()).not.toContain("modelgo");
+ fixture.state = { ...fixture.state, instances: fleet.filter((instance) => instance.instanceId !== "modelgo"), config: {} };
+ fixture.hidden = [{ instanceId: "modelgo", driverKind: "modelgo", displayName: "ModelGo" }];
+ await simple(true);
+ expect(order().slice(0, 4)).toEqual(["grok", "kimi", "cursor", "mistralVibe"]);
+ expect(order()).not.toContain("modelgo");
+ });
+
+ it("stands third, above Cursor, among the Advanced list's providers that need setting up", async () => {
+ fixture.state = { ...fixture.state, instances: fleet };
+ await advanced();
+ expect(cards().slice(0, 5)).toEqual(["grok", "kimi", "modelgo", "droid", "cursor"]);
+ raised(cards());
+ const ready = { state: "available", authenticated: true } as const;
+ fixture.state = { ...fixture.state, instances: [grok, cursor, key("groq", "groq", ready), key("mistral", "mistral", ready), key("meta", "meta", ready), key("modelgo", "modelgo", ready)] };
+ await advanced();
+ expect(cards(), "set up, it is third among the ready ones").toEqual(["groq", "mistral", "modelgo", "meta", "grok", "cursor"]);
+ fixture.state = { ...fixture.state, instances: fleet, config: { managedPolicy: { organizationName: "Acme", companyModelsOnly: false, allowedEngines: ["groq"] } } };
+ await advanced();
+ expect(cards().slice(0, 4)).toEqual(["grok", "kimi", "droid", "cursor"]);
+ });
+});
diff --git a/src/components/EnginesSettings.tsx b/src/components/EnginesSettings.tsx
index 61d1235c46..e318965be2 100644
--- a/src/components/EnginesSettings.tsx
+++ b/src/components/EnginesSettings.tsx
@@ -27,7 +27,7 @@ import { InstanceProviderMark } from "./ProviderIcons";
import { GEMINI_PRESET, GeminiServer, hasGeminiServer } from "./OpenAiCompatServers";
import { HiddenEngines, HiddenProviderRows, useHiddenProviders } from "./HiddenProviders";
import { AdminOnly } from "./AdminOnly";
-import { modelgoOfferable } from "@/lib/modelgo-offer";
+import { modelgoOfferable, sponsorRowRaised } from "@/lib/modelgo-offer";
import { sameFields, useStoreActions, useStoreSelector } from "@/state/store-select";
export { HiddenEngines };
@@ -500,18 +500,19 @@ function SimpleEngines({ rows, isReady, renderEngine, more, accountsOnly = false
accountsOnly?: boolean;
/** Offer the Google AI Studio row: no Gemini server is added yet and this workspace can add one. */
offerGemini?: boolean;
- /** The sponsor's provider sits in the main list, after the Google AI Studio row, where it may be offered (modelgoOfferable). */
+ /** The sponsor's provider sits in the main list, among its first three rows, where it may be offered (modelgoOfferable). */
offerModelgo?: boolean;
}) {
const [opened, setOpened] = useState<string | null>(null);
// A hidden provider is gone from the instance list, so without these rows nothing in Settings brings it back.
const allHidden = useHiddenProviders(), hidden = accountsOnly ? [] : allHidden;
const featured = rows.filter((instance) => accountsOnly || isReady(instance) || instance.authentication !== undefined || hasGeminiServer([instance]));
- const modelgo = offerModelgo && !accountsOnly && !featured.some((instance) => instance.driverKind === "modelgo")
- ? rows.find((instance) => instance.driverKind === "modelgo") : undefined;
+ const modelgo = offerModelgo && !accountsOnly ? rows.find((instance) => instance.driverKind === "modelgo") : undefined;
const others = rows.filter((instance) => !featured.includes(instance) && instance !== modelgo);
// A hidden Gemini server comes back through its own hidden row; adding another would only make a second one.
const gemini = offerGemini && !hidden.some((provider) => provider.driverKind === "openai-compat" && provider.displayName === GEMINI_PRESET.name);
+ const main = sponsorRowRaised<InstanceInfo | "google-ai-studio">([...featured, ...(gemini ? ["google-ai-studio" as const] : []),
+ ...(modelgo && !featured.includes(modelgo) ? [modelgo] : [])], modelgo, (entry) => entry !== "google-ai-studio" && entry.driverKind === "cursorAgent");
const folded = others.length + hidden.length;
const row = (instance: InstanceInfo, compact: boolean) => {
const open = opened === instance.instanceId;
@@ -521,9 +522,8 @@ function SimpleEngines({ rows, isReady, renderEngine, more, accountsOnly = false
return (
<SettingsGroup label={t("settings.ai.providers")} actions={<RefreshEngines />}>
<SettingsRows icons>
- {featured.map((instance) => row(instance, false))}
- {gemini && <GeminiProviderRow open={opened === "google-ai-studio"} onToggle={() => setOpened(opened === "google-ai-studio" ? null : "google-ai-studio")} />}
- {modelgo && row(modelgo, false)}
+ {main.map((entry) => entry !== "google-ai-studio" ? row(entry, false)
+ : <GeminiProviderRow key={entry} open={opened === entry} onToggle={() => setOpened(opened === entry ? null : entry)} />)}
{folded > 0 && (
<SettingsFoldRow id={more.id} title={t("settings.ai.moreProviders")} value={String(folded)} open={more.open} onToggle={more.onToggle}
leading={<span aria-hidden="true" />}>
@@ -601,7 +601,7 @@ export function EnginesSettings({ simple = false, more }: { simple?: boolean; mo
</div>
<RefreshEngines />
</div>
- <EngineSections instances={rows} isReady={isReady} renderEngine={renderEngine} />
+ <EngineSections instances={rows} isReady={isReady} renderEngine={renderEngine} offerModelgo={modelgoOfferable(state.policy)} />
{orphanEndpoints && <div className="px-4"><ClaudeEndpoints /><ClaudeBedrockEndpoints /></div>}
{orphanCodexEndpoints && <div className="px-4"><CodexEndpoints /></div>}
<HiddenEngines />
diff --git a/src/lib/modelgo-offer.ts b/src/lib/modelgo-offer.ts
index df795ee676..dd9a8b94a4 100644
--- a/src/lib/modelgo-offer.ts
+++ b/src/lib/modelgo-offer.ts
@@ -16,3 +16,14 @@ export function modelgoOfferable(policy: ManagedPolicySummary | null | undefined
if (!policy || policy.team) return true;
return !policy.companyModelsOnly && (policy.allowedEngines === "all" || policy.allowedEngines.includes("modelgo"));
}
+
+/** The sponsor's row moves up to third place, or higher to stand directly above the first row `under` picks; a row
+ * already higher keeps its place, and the other rows keep their order. */
+export function sponsorRowRaised<T>(rows: readonly T[], sponsor: T | undefined, under: (row: T) => boolean): T[] {
+ const from = sponsor === undefined ? -1 : rows.indexOf(sponsor);
+ if (from < 0) return [...rows];
+ const rest = rows.filter((_, index) => index !== from);
+ const above = rest.findIndex(under);
+ const at = Math.min(from, 2, above < 0 ? 2 : above);
+ return [...rest.slice(0, at), rows[from], ...rest.slice(at)];
+}