Skip to content

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

fix(keys): say when a saved key's engine can't run and how to install it

AdityaUmalefb283eab7570
diff --git a/src/components/keys/KeyRow.test.ts b/src/components/keys/KeyRow.test.ts
index 5ebabaca03..198cc9c7c9 100644
--- a/src/components/keys/KeyRow.test.ts
+++ b/src/components/keys/KeyRow.test.ts
@@ -88,6 +88,31 @@ describe("a saved key", () => {
expect(html).toContain("••••••••a1b2");
expect(html).toContain("data-key-replace");
});
+
+ it("says a saved key waits on its engine's own CLI and shows how to install it", () => {
+ fixture.config = { deepseek: { configured: true, last4: "9z9z" } };
+ const deepseek = (state: "available" | "unavailable") => ({ instanceId: "deepseek", driverKind: "deepseekAgent", displayName: "DeepSeek Harness",
+ snapshot: { state }, install: { platform: "linux", command: { linux: "npm install -g @deepseek-ai/dsh" } }, models: { default: "m", options: [] } }) as unknown as InstanceInfo;
+ fixture.instances = [deepseek("unavailable")];
+ const html = render({ id: "deepseek" });
+ 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("••••••••9z9z");
+
+ 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.
+ fixture.config = { xai: { configured: true, last4: "8y8y" } };
+ fixture.instances = [{ ...deepseek("unavailable"), instanceId: "grok", displayName: "Grok" }, { ...deepseek("available"), instanceId: "xaiApi", install: undefined }];
+ 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");
+ });
});
describe("a key that comes with the Cloud plan", () => {
diff --git a/src/components/keys/KeyRow.tsx b/src/components/keys/KeyRow.tsx
index 67a4739c7c..bd2dbeae01 100644
--- a/src/components/keys/KeyRow.tsx
+++ b/src/components/keys/KeyRow.tsx
@@ -129,6 +129,13 @@ export function KeyRow({
const saved = savedState(entry, state.config);
const engineRejected = (state.instances ?? []).some((instance) => instance.access === "api" && keyForInstance(instance.instanceId) === entry.id
&& instance.snapshot.state === "available" && instance.snapshot.authenticated === false);
+ // A key engine with its own CLI (DeepSeek Harness) can't use a saved key until that CLI runs here.
+ const keyEngines = saved.configured ? (state.instances ?? []).filter((instance) => keyForInstance(instance.instanceId) === entry.id) : [];
+ 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 rejected = !works && (rejectedHere ?? (saved.configured && engineRejected));
const failure = problem ?? (rejected && !busy ? t("keys.testRejected") : null);
const editing = !saved.configured || replacing;
@@ -330,7 +337,7 @@ export function KeyRow({
<button type="button" data-key-own className="ui-button" onClick={() => { setOwnKey(true); focusAfter.current = "input"; }}>{t("keys.row.useOwn")}</button>
</div>
)}
- {(notice || failure || other || warning || note || verdict || (fieldShown && target.href) || (!fieldShown && saved.configured && target.test)) && (
+ {(notice || failure || other || warning || installCommand || note || verdict || (fieldShown && target.href) || (!fieldShown && saved.configured && target.test)) && (
<div className="flex flex-col gap-1.5 text-[12px] leading-4">
{notice && <p role="alert" className="text-danger">{notice}</p>}
{failure && (
@@ -351,6 +358,15 @@ export function KeyRow({
<span>{warning}</span>
</p>
)}
+ {installCommand && missingEngine && (
+ <div data-key-engine-missing className="flex flex-col gap-1">
+ <p className="flex gap-1.5 text-warning">
+ <TriangleAlert size={13} aria-hidden="true" className="mt-px shrink-0" />
+ <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>
+ </div>
+ )}
{note && <p className="text-ink-secondary">{note}</p>}
{verdict && <p role="status" className="whitespace-pre-line text-ink-secondary">{verdict}</p>}
{(fieldShown && target.href) || (!fieldShown && saved.configured && target.test) ? (
diff --git a/src/locales/en.json b/src/locales/en.json
index ea55e72505..2eaa2640bf 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -7214,6 +7214,7 @@
"keys.row.didntWork": "Didn't work",
"keys.row.failed": "Didn't work: {reason}",
"keys.row.looksLike": "That looks like the {label}, not this one.",
+ "keys.row.engineMissing": "Saved, but {engine} can't run on this computer yet, so this key isn't used. Install it with this command, then check again:",
"keys.row.notKept": "The key didn't stay saved. Try again.",
"keys.row.newKey": "Paste the new key",
"keys.row.show": "Show key",