Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(keys): reuse the platform fallback and offer Check again on the missing-engine hint
AdityaUmale9d01d6bb46da
diff --git a/src/components/EngineSetup.tsx b/src/components/EngineSetup.tsxindex be69851cb6..cf30de8f5a 100644--- a/src/components/EngineSetup.tsx+++ b/src/components/EngineSetup.tsx@@ -1,6 +1,6 @@import { useEffect, useState } from "react";import { AlertTriangle, Check, Copy, Download, ExternalLink, KeyRound, Loader2, LogIn, TerminalSquare, X } from "lucide-react";-import { api, type EngineInstall, type InstanceInfo, useStore } from "@/state/store";+import { api, type InstanceInfo, useStore } from "@/state/store";import { cn } from "@/lib/cn";import { t } from "@/lib/i18n";import { copyText } from "@/lib/copy-text";@@ -8,26 +8,13 @@ import { DEVICE_SIGN_IN_COPY, DeviceSignIn, deviceSignInProvider } from "./Devicimport { ClaudeSignIn } from "./ClaudeSignIn";import { RefreshEngines } from "./EngineLibrary";import { AppCopyNotice, AppCopySetup } from "./EngineAppCopy";-import { noteAppCopySwitch } from "@/state/engine-install";+import { installCommandFor, noteAppCopySwitch } from "@/state/engine-install";++export { installCommandFor };import { keyEntry, keyForInstance, type KeyId } from "./keys/key-catalog";import { openKeySettings } from "./keys/key-focus";import { KeyRow, SavedKeyLine } from "./keys/KeyRow";-type Platform = "darwin" | "win32" | "linux";--function hostPlatform(): Platform {- const platform = window.ogb?.platform;- if (platform === "darwin" || platform === "win32" || platform === "linux") return platform;- const userAgent = navigator.userAgent;- if (userAgent.includes("Mac")) return "darwin";- if (userAgent.includes("Win")) return "win32";- return "linux";-}--export function installCommandFor(install: EngineInstall | undefined): string | null {- return install?.command?.[install.platform ?? hostPlatform()] ?? null;-}-export function needsSignIn(instance: InstanceInfo | undefined): boolean {return instance?.snapshot.state === "available" && instance.snapshot.authenticated === false;}diff --git a/src/components/keys/KeyRow.test.ts b/src/components/keys/KeyRow.test.tsindex 198cc9c7c9..6521e15c7d 100644--- a/src/components/keys/KeyRow.test.ts+++ b/src/components/keys/KeyRow.test.ts@@ -98,8 +98,12 @@ describe("a saved key", () => {expect(html).toContain("data-key-engine-missing");expect(html).toContain("Saved, but DeepSeek Harness can't run on this computer yet");expect(html).toContain("npm install -g @deepseek-ai/dsh");+ expect(html).toContain("data-key-engine-check");expect(html).toContain("••••••••9z9z");+ // Without the server's platform, the command for this computer's platform is used.+ fixture.instances = [{ ...deepseek("unavailable"), install: { command: { linux: "npm install -g @deepseek-ai/dsh" } } } as InstanceInfo];+ expect(render({ id: "deepseek" })).toContain("data-key-engine-missing");fixture.instances = [deepseek("available")];expect(render({ id: "deepseek" })).not.toContain("data-key-engine-missing");// The xAI key also feeds the xAI API engine, so a missing Grok CLI doesn't leave it unused.@@ -108,7 +112,6 @@ describe("a saved key", () => {expect(render({ id: "xai" })).not.toContain("data-key-engine-missing");fixture.instances = [{ ...deepseek("unavailable"), instanceId: "grok", displayName: "Grok" }];expect(render({ id: "xai" })).toContain("data-key-engine-missing");- fixture.config = { deepseek: { configured: true, last4: "9z9z" } };fixture.config = {};fixture.instances = [deepseek("unavailable")];expect(render({ id: "deepseek" })).not.toContain("data-key-engine-missing");diff --git a/src/components/keys/KeyRow.tsx b/src/components/keys/KeyRow.tsxindex bd2dbeae01..e7c7f4c8ed 100644--- a/src/components/keys/KeyRow.tsx+++ b/src/components/keys/KeyRow.tsx@@ -1,6 +1,7 @@import { useEffect, useId, useRef, useState, type ReactNode } from "react";import { Check, CircleAlert, ExternalLink, Eye, EyeOff, Loader2, TriangleAlert } from "lucide-react";import { useStore } from "@/state/store";+import { installCommandFor } from "@/state/engine-install";import { cn } from "@/lib/cn";import { t } from "@/lib/i18n";import type { KeyResult, KeyVia } from "@/lib/analytics-allowlist";@@ -96,7 +97,7 @@ export function KeyRow({className?: string;children?: ReactNode;}) {- const { state, dispatch } = useStore();+ const { state, dispatch, refreshInstances } = useStore();const titleId = useId();const [draft, setDraft] = useState("");const [shown, setShown] = useState(false);@@ -107,6 +108,7 @@ export function KeyRow({const [notice, setNotice] = useState<string | null>(null);const [verdict, setVerdict] = useState<string | null>(null);const [works, setWorks] = useState(false);+ const [enginesChecking, setEnginesChecking] = useState(false);const busyRef = useRef(false);const generation = useRef(0);const inputRef = useRef<HTMLInputElement>(null);@@ -134,8 +136,7 @@ export function KeyRow({const missingEngine = keyEngines.some((instance) => instance.snapshot.state === "available")? undefined: keyEngines.find((instance) => instance.snapshot.state === "unavailable");- const missingInstall = missingEngine?.install;- const installCommand = missingInstall?.platform ? missingInstall.command?.[missingInstall.platform] : undefined;+ const installCommand = installCommandFor(missingEngine?.install);const rejected = !works && (rejectedHere ?? (saved.configured && engineRejected));const failure = problem ?? (rejected && !busy ? t("keys.testRejected") : null);const editing = !saved.configured || replacing;@@ -365,6 +366,10 @@ export function KeyRow({<span>{t("keys.row.engineMissing", { engine: missingEngine.displayName })}</span></p><code className="select-all break-all rounded-md bg-inset px-2 py-1 font-mono text-[12px] text-ink">{installCommand}</code>+ <button type="button" data-key-engine-check className="cursor-pointer self-start text-ink-secondary hover:text-ink hover:underline disabled:opacity-50" disabled={enginesChecking}+ onClick={() => { setEnginesChecking(true); void refreshInstances().finally(() => setEnginesChecking(false)); }}>+ {enginesChecking ? t("common.checking") : t("common.checkAgain")}+ </button></div>)}{note && <p className="text-ink-secondary">{note}</p>}diff --git a/src/state/engine-install.ts b/src/state/engine-install.tsindex 09e12a7dd0..9bc957dbcc 100644--- a/src/state/engine-install.ts+++ b/src/state/engine-install.ts@@ -14,6 +14,22 @@ export interface EngineInstall {appCopy?: boolean;}+type Platform = NonNullable<EngineInstall["platform"]>;++function hostPlatform(): Platform {+ const platform = window.ogb?.platform;+ if (platform === "darwin" || platform === "win32" || platform === "linux") return platform;+ const userAgent = navigator.userAgent;+ if (userAgent.includes("Mac")) return "darwin";+ if (userAgent.includes("Win")) return "win32";+ return "linux";+}++/** The command that installs this engine where the server runs, falling back to this computer's platform. */+export function installCommandFor(install: EngineInstall | undefined): string | null {+ return install?.command?.[install.platform ?? hostPlatform()] ?? null;+}+// Engines an install switched to the app's own copy because the copy their CLI found doesn't start. The line saying so// outlives the setup panel that showed it (the engine turns Ready), until the person dismisses it or leaves Settings.let switched: ReadonlySet<string> = new Set();