Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(spaces-web): a teleport run waits until it finishes, not 30 seconds (#4941)

dduponta2fe430f7ae3
diff --git a/apps/cua-spaces-web/src/bridge/__tests__/hosts.test.ts b/apps/cua-spaces-web/src/bridge/__tests__/hosts.test.ts
index 3c05c95c7e..e5fff8b4b3 100644
--- a/apps/cua-spaces-web/src/bridge/__tests__/hosts.test.ts
+++ b/apps/cua-spaces-web/src/bridge/__tests__/hosts.test.ts
@@ -754,6 +754,31 @@ describe("webkit adapter", () => {
}
});
+ it("waits as long as a teleport run takes, past the call timeout", async () => {
+ vi.useFakeTimers();
+ try {
+ const report = { appId: "vscode", installed: ["code"], sent: [], imported: [], skipped: [], launched: true, warnings: [] };
+ let answer!: (a: Answer) => void;
+ const { win } = webkitHost((req) => (req.method === "teleport.run" ? new Promise<Answer>((r) => (answer = r)) : ok(null)));
+ const call = createWebkitAdapter(win, { timeoutMs: 1_000 }).call("teleport.run", {
+ spaceId: "local:dev",
+ plan: { json: "{}" } as never,
+ consent: {} as never,
+ runId: "run-1",
+ });
+ const settled = call.then(
+ (r) => ({ ok: true as const, r }),
+ (e: unknown) => ({ ok: false as const, e }),
+ );
+ // An install that downloads the app: minutes, not the call timeout.
+ await vi.advanceTimersByTimeAsync(120_000);
+ answer(ok(report));
+ expect(await settled).toEqual({ ok: true, r: report });
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+
it("reads the host's own settings rows and picks their options with settings.choose", async () => {
const choice = (id: string, active: string) => ({ id, kind: "choice", label: "", enabled: true, options: ["auto", "builtin", "system"].map((o) => ({ id: o, label: o, active: o === active })) });
const toggle = (id: string, on: boolean) => ({ id, kind: "toggle", label: "", enabled: true, options: [{ id: "on", label: "On", active: on }, { id: "off", label: "Off", active: !on }] });
diff --git a/apps/cua-spaces-web/src/bridge/ops/webkit-pages.ts b/apps/cua-spaces-web/src/bridge/ops/webkit-pages.ts
index 6fc9267cdf..7b0c6f9bc1 100644
--- a/apps/cua-spaces-web/src/bridge/ops/webkit-pages.ts
+++ b/apps/cua-spaces-web/src/bridge/ops/webkit-pages.ts
@@ -210,7 +210,9 @@ export function webkitPageOps(request: Request, toHostStatus: (h: WkHostState) =
"teleport.thumbnail": call("teleport.thumbnail"),
"teleport.plan": async ({ spaceId, entry, move, files, sensitiveGroups }) =>
planFromWk(await request<Json>("teleport.plan", { spaceId, entry: { id: entry?.id }, move, files, sensitiveGroups })),
- "teleport.run": ({ spaceId, plan, consent, runId }) => request("teleport.run", { spaceId, plan: { json: plan?.json }, consent, runId }),
+ // As long as the run takes (an install downloads the app); it reports
+ // progress as it goes (teleport.progress) and answers when it is done.
+ "teleport.run": ({ spaceId, plan, consent, runId }) => request("teleport.run", { spaceId, plan: { json: plan?.json }, consent, runId }, null),
"teleport.sites": async ({ providerId }) => snake(await request("teleport.sites", { providerId })) as KvInventory,
"teleport.remembered": async ({ providerId, spaceId }) => (await request<string[] | null>("teleport.remembered", { providerId, spaceId })) ?? null,
"teleport.streamWindow": none("teleport.streamWindow"),