Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Show New bot on a desktop paired to another computer
AdityaUmale62ebd470fd99
diff --git a/src/lib/use-owner-or-admin.test.ts b/src/lib/use-owner-or-admin.test.tsindex 2183647d62..d85d147f00 100644--- a/src/lib/use-owner-or-admin.test.ts+++ b/src/lib/use-owner-or-admin.test.ts@@ -18,6 +18,7 @@ afterEach(() => {root = null;vi.useRealTimers();vi.unstubAllGlobals();+ delete (window as { ogb?: unknown }).ogb;});async function mount() {@@ -74,4 +75,15 @@ describe("useOwnerOrAdmin", () => {expect(seen.at(-1)).toBe(true);expect(fetch).toHaveBeenCalledOnce();});++ it("shows owner controls on a paired desktop, whose companion does not serve the session route", async () => {+ const fetch = vi.fn<typeof globalThis.fetch>(async () => new Response(JSON.stringify({ error: "no route: GET /api/auth/session" }), { status: 404 }));+ vi.stubGlobal("fetch", fetch);+ (window as { ogb?: unknown }).ogb = { remoteClient: { active: true } };++ await mount();+ await act(async () => { await vi.advanceTimersByTimeAsync(60_000); });+ expect(seen.at(-1)).toBe(true);+ expect(fetch).not.toHaveBeenCalled();+ });});diff --git a/src/lib/use-owner-or-admin.ts b/src/lib/use-owner-or-admin.tsindex 01ed6cc689..401c2f321c 100644--- a/src/lib/use-owner-or-admin.ts+++ b/src/lib/use-owner-or-admin.ts@@ -11,6 +11,13 @@ const listeners = new Set<(allowed: boolean) => void>();function lookUp(): void {retry = null;if (known !== null || looking || !listeners.size) return;+ // A paired desktop reaches the host through its companion, which does not serve the session route; the host already+ // treats that device as its owner, so owner controls such as New bot stay shown.+ if (typeof window !== "undefined" && window.ogb?.remoteClient?.active === true) {+ known = true;+ for (const listener of listeners) listener(true);+ return;+ }looking = true;void readSessionState().then((state) => state.kind === "unreachable" ? null : isOwnerOrAdmin(state), () => null)