Skip to content

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

Check the new base URL also when the pending key check fails

AdityaUmale6e63cd4b6c33
diff --git a/src/components/keys/KeyRow.tsx b/src/components/keys/KeyRow.tsx
index e345f6144a..c68e9a204b 100644
--- a/src/components/keys/KeyRow.tsx
+++ b/src/components/keys/KeyRow.tsx
@@ -192,6 +192,7 @@ export function KeyRow({
}
return check.result;
} catch (cause) {
+ if (mine === generation.current && checkedAt.current !== at) return await runCheck();
if (mine === generation.current) setProblem(errorText(cause));
return "unverified";
}
diff --git a/src/components/keys/KeysPage.dom.test.ts b/src/components/keys/KeysPage.dom.test.ts
index 7b72bfe6c7..8b5261ca41 100644
--- a/src/components/keys/KeysPage.dom.test.ts
+++ b/src/components/keys/KeysPage.dom.test.ts
@@ -355,6 +355,28 @@ describe("the OpenAI-compatible key check", () => {
expect(row("openaiCompat")!.textContent).not.toContain("Didn't work");
});
+ it("checks again when the base URL changes while a check that then fails is still running", async () => {
+ fx.config = { ...fx.config, openaiCompat: { configured: true, last4: "1234" } };
+ const tested: Array<string | undefined> = [];
+ let failFirst: (cause: Error) => void = () => {};
+ fx.api.mockImplementation((path: string) => {
+ if (path !== "/api/keys/test") return Promise.resolve({});
+ const url = (fx.config.openaiCompat as { url?: string }).url;
+ tested.push(url);
+ if (tested.length === 1) return new Promise((_resolve, reject) => { failFirst = reject; });
+ return Promise.resolve({ ok: true, check: "models", models: ["venice-uncensored"] });
+ });
+ page();
+ flushSync(() => section("servers").querySelector<HTMLButtonElement>("button[aria-expanded]")!.click());
+ flushSync(() => setConfig({ ...fx.config, openaiCompat: { configured: true, last4: "1234", url: "https://api.example.test/v1" } }));
+ await vi.waitFor(() => expect(tested).toEqual(["https://api.example.test/v1"]));
+ flushSync(() => setConfig({ ...fx.config, openaiCompat: { configured: true, last4: "1234", url: "https://api.venice.ai/api/v1" } }));
+ failFirst(new Error("network down"));
+ await vi.waitFor(() => expect(row("openaiCompat")!.textContent).toContain("venice-uncensored"));
+ expect(tested).toEqual(["https://api.example.test/v1", "https://api.venice.ai/api/v1"]);
+ expect(row("openaiCompat")!.textContent).not.toContain("network down");
+ });
+
it("does not check the key when the page opens or nothing about the address changed", async () => {
fx.config = { ...fx.config, openaiCompat: { configured: true, last4: "1234", url: "https://api.venice.ai/api/v1" } };
fx.api.mockResolvedValue({});