Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(desktop): resolve relative desktop-viewer join links before opening the native viewer
koeria4610d0a26e27
diff --git a/src/components/computer-takeover.test.ts b/src/components/computer-takeover.test.tsindex de238b61ec..845f4cd272 100644--- a/src/components/computer-takeover.test.ts+++ b/src/components/computer-takeover.test.ts@@ -122,6 +122,19 @@ describe("the app's viewer window", () => {expect(reloaded.viewerClosedRelease("scout")).toEqual({ action: "release", controlLeaseId: requests[0]!.lease });});+ it("opens the native viewer with a whole address when the server names its viewer page by path", async () => {+ const open = vi.fn(async () => true);+ vi.stubGlobal("ogb", { desktopViewer: { open } });+ await openProviderDesktop({+ botId: "scout", title: "Scout's live desktop", request, current: () => true,+ join: async () => ({ joinUrl: "/desktop-viewer#target=vps/scout" }),+ });+ expect(open).toHaveBeenCalledWith(+ new URL("/desktop-viewer#target=vps/scout", location.href).toString(), "Scout's live desktop", "scout",+ );+ expect(requests.map((entry) => entry.action)).toEqual(["take"]);+ });+it("gives back, once the reopened viewer closes, the hold of an open a reload of the page cut off during its join", async () => {vi.stubGlobal("ogb", { desktopViewer: { open: vi.fn(async () => true) } });void openProviderDesktop({ botId: "scout", title: "Scout's live desktop", request, current: () => true, join: () => new Promise(() => {}) });diff --git a/src/components/computer-takeover.ts b/src/components/computer-takeover.tsindex 0f68b6859d..3effb38d8a 100644--- a/src/components/computer-takeover.ts+++ b/src/components/computer-takeover.ts@@ -75,7 +75,9 @@ export async function openProviderDesktop({ botId, title, request, join, currentif (mine && window.ogb?.desktopViewer) recordViewerLease(botId, mine);if (!current()) throw changed();const { joinUrl } = await join(AbortSignal.timeout(JOIN_TIMEOUT_MS), mine);- const viewerUrl = typeof joinUrl === "string" && joinUrl ? joinUrl : null;+ // A server reached over the network hands back its own viewer page as a path; the native viewer window+ // (and any consumer of the link) needs a whole address, so resolve it against the page this is.+ const viewerUrl = typeof joinUrl === "string" && joinUrl ? new URL(joinUrl, location.href).toString() : null;if (!current()) throw changed();if (!viewerUrl) throw new LocalizedPanelError("computer.err.noDesktopLink");if (window.ogb?.desktopViewer) {