Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
App tests start each page fresh; an engine that worked on this page keeps the setup page away
milind-soni696ab34be3c7
diff --git a/src/App.engine-status.test.ts b/src/App.engine-status.test.tsindex f135a19b71..78119b80e0 100644--- a/src/App.engine-status.test.ts+++ b/src/App.engine-status.test.ts@@ -13,8 +13,10 @@ vi.mock("./state/store", async (original) => ({}));vi.mock("./lib/analytics", () => ({ initAnalytics: () => {}, track: () => {}, emailGateDone: () => true }));const { default: App } = await import("./App");+const { forgetWorkedEngines } = await import("./lib/onboarding");-afterEach(() => { vi.unstubAllGlobals(); });+// Each test is a fresh page: which engines worked is remembered only for a page's own life.+afterEach(() => { vi.unstubAllGlobals(); forgetWorkedEngines(); });it("keeps a saved conversation visible through an unavailable engine status and recovery", () => {vi.stubGlobal("fetch", () => new Promise(() => {}));@@ -59,3 +61,23 @@ it("offers AI setup when there is no conversation and every engine is unavailablcontainer.remove();}});++it("keeps the setup page away for an engine that worked earlier on this page, whose status check later fails", () => {+ vi.stubGlobal("fetch", () => new Promise(() => {}));+ const claude = (snapshot: AppState["instances"][number]["snapshot"]) => ({ instanceId: "claude", driverKind: "claudeAgent", displayName: "Claude", models: { default: "", options: [] }, snapshot });+ state = { ...initialState, connected: true, hydrated: true, instances: [claude({ state: "available", authenticated: true })] };+ const container = document.createElement("div");+ document.body.append(container);+ const root = createRoot(container);+ try {+ flushSync(() => root.render(createElement(App)));+ for (const snapshot of [{ state: "unavailable", reason: "CLI probe timed out", busy: true }, { state: "unavailable", reason: "CLI probe timed out" }] as const) {+ state = { ...state, instances: [claude(snapshot)] };+ flushSync(() => root.render(createElement(App)));+ expect(container.textContent).not.toContain("Check again");+ }+ } finally {+ root.unmount();+ container.remove();+ }+});diff --git a/src/lib/onboarding.ts b/src/lib/onboarding.tsindex 4ca2b30bb3..ff9891bbdb 100644--- a/src/lib/onboarding.ts+++ b/src/lib/onboarding.ts@@ -253,6 +253,8 @@ type EngineRow = { instanceId: string; snapshot: { state: string; busy?: true; a/** Engines seen available since this page loaded. */const workedThisSession = new Set<string>();+/** A fresh page, as a new load starts (tests). */+export const forgetWorkedEngines = (): void => workedThisSession.clear();/** Notes the engines available now; true for one that was available earlier since this page loaded. A setup page never* replaces a working engine that reads unavailable later: the app's usual waiting view stays while the server checks it