From 695e47cd6119e9f0451a9cc8be68843124741387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Mon, 23 Nov 2026 20:03:30 +0100 Subject: [PATCH] fix(codex): download the Testing Studio runtime on first use --- apps/claude/server/server.ts | 7 +- apps/codex-plugin/server/index.ts | 10 +++ apps/codex-plugin/tooling/package.mjs | 10 ++- apps/codex-plugin/tooling/smoke-package.mjs | 59 ++++++++++++- docs/releases.md | 8 +- docs/telemetry.md | 9 +- package-lock.json | 4 +- package.json | 2 +- packages/core/src/e2e-runtime.ts | 23 ++++- packages/core/src/panel-runtime.ts | 79 +++++++++++------- packages/core/src/telemetry.ts | 6 +- packages/core/src/testing-setup.ts | 5 +- packages/core/src/testing-tools.ts | 39 ++++++++- packages/core/test/panel-runtime.test.ts | 22 ++--- packages/core/test/telemetry.test.ts | 7 +- packages/shared/src/telemetry.ts | 2 +- packages/shared/src/testing-runtime.ts | 6 ++ packages/shared/src/version.ts | 2 +- packages/ui/src/components/testing-setup.tsx | 2 +- packages/ui/src/components/testing-view.tsx | 54 ++++++++++++ packages/ui/src/testing-panel.ts | 20 ++++- tooling/hosts/fixtures.ts | 1 + tooling/hosts/hosts.spec.ts | 37 ++++++++ .../codex/testing-runtime-dark.png | Bin 0 -> 14823 bytes .../codex/testing-runtime-light.png | Bin 0 -> 14546 bytes tooling/hosts/visual.spec.ts | 19 +++++ tooling/panel-runtime.mjs | 18 ++-- website/src/content/docs/docs/testing.md | 2 + 28 files changed, 373 insertions(+), 80 deletions(-) create mode 100644 packages/shared/src/testing-runtime.ts create mode 100644 tooling/hosts/screenshots/codex/testing-runtime-dark.png create mode 100644 tooling/hosts/screenshots/codex/testing-runtime-light.png diff --git a/apps/claude/server/server.ts b/apps/claude/server/server.ts index 5051df56..5a634cf5 100644 --- a/apps/claude/server/server.ts +++ b/apps/claude/server/server.ts @@ -12,5 +12,10 @@ import { downloadedPanelRuntime, panelRuntimeReleaseSchema, usePanelRuntime } fr // applies to the panel's native parts and the Testing Studio runner. The package pins // their release archive in panel-runtime.json, which the server downloads on first use. const pinned = await readFile(new URL("./panel-runtime.json", import.meta.url), "utf8").catch(() => undefined); -if (pinned !== undefined) usePanelRuntime(downloadedPanelRuntime(panelRuntimeReleaseSchema.parse(JSON.parse(pinned)))); +if (pinned !== undefined) { + const metadata: unknown = JSON.parse(pinned); + const release = panelRuntimeReleaseSchema.parse(metadata); + const download = downloadedPanelRuntime(release); + usePanelRuntime(download.ensure); +} await runStdioServer({ panel: createPanel({ inline: false }), features: [agentDeviceTools(readAgentDeviceCatalog()), browserPanel({ always: true })] }); diff --git a/apps/codex-plugin/server/index.ts b/apps/codex-plugin/server/index.ts index d0f50ee2..f001293b 100644 --- a/apps/codex-plugin/server/index.ts +++ b/apps/codex-plugin/server/index.ts @@ -1,4 +1,7 @@ import "@mobile-dev/core/instrument.ts"; +import { readFile } from "node:fs/promises"; +import { useDownloadedTestingRuntime } from "@mobile-dev/core/e2e-runtime.ts"; +import { panelRuntimeReleaseSchema } from "@mobile-dev/core/panel-runtime.ts"; import { runStdioServer } from "@mobile-dev/core/stdio-server.ts"; import { createPanel } from "@mobile-dev/core/panel-tools.ts"; import { agentDeviceTools, readAgentDeviceCatalog } from "@mobile-dev/core/agent-device-tools.ts"; @@ -9,6 +12,13 @@ import { panelSelection } from "./panel-selection.ts"; // Codex's server: the shared server with Mobile Dev's panel and agent-device's commands, plus // the updater for Codex plugin installs. +if (!process.env.MOBILE_DEV_E2E_RUNTIME?.trim()) { + const pin = new URL("./testing-runtime.json", import.meta.url); + const source = await readFile(pin, "utf8"); + const metadata: unknown = JSON.parse(source); + const release = panelRuntimeReleaseSchema.parse(metadata); + useDownloadedTestingRuntime(release); +} const inline = panelPlacement("inline") === "inline"; const panelContext = inline ? panelSelection : browserPanel({ always: true }); const features = [agentDeviceTools(readAgentDeviceCatalog()), codexUpdates, panelContext]; diff --git a/apps/codex-plugin/tooling/package.mjs b/apps/codex-plugin/tooling/package.mjs index 5f837249..86638c3b 100644 --- a/apps/codex-plugin/tooling/package.mjs +++ b/apps/codex-plugin/tooling/package.mjs @@ -5,6 +5,7 @@ import { telemetryBuildEnvironment } from "../../../tooling/telemetry-build.mjs" import { pluginMarketplace } from "./plugin-marketplace.mjs"; import { buildCodexHost } from "./build.mjs"; import { assertRuntime, RELEASE_DOCUMENTS, releaseVersion, stageRuntime } from "../../../tooling/host-runtime.mjs"; +import { packPanelRuntime } from "../../../tooling/panel-runtime.mjs"; import { sharedSkills } from "../../../tooling/plugin-hosts.mjs"; const telemetryEnvironment = telemetryBuildEnvironment(); @@ -20,7 +21,10 @@ await rm(plugin, { recursive: true, force: true }); await mkdir(plugin, { recursive: true }); await copyFile(`${source}/.mcp.json`, `${plugin}/.mcp.json`); for (const path of RELEASE_DOCUMENTS) await copyFile(path, `${plugin}/${path}`); -await stageRuntime(`${plugin}/dist`); +await stageRuntime(`${plugin}/dist`, { exclude: ["e2e"] }); +const runtime = await packPanelRuntime(manifest.version, { release: telemetryEnvironment === "release", testingOnly: true }); +const runtimePin = JSON.stringify(runtime.pin, null, 2); +await writeFile(`${plugin}/dist/testing-runtime.json`, runtimePin + "\n"); await buildCodexHost(telemetryEnvironment, `${plugin}/dist`); for (const path of [".codex-plugin", "assets"]) await cp(`${source}/${path}`, `${plugin}/${path}`, { recursive: true, verbatimSymlinks: true }); for (const skill of sharedSkills) await cp(skill, `${plugin}/skills/${basename(skill)}`, { recursive: true, verbatimSymlinks: true }); @@ -42,4 +46,8 @@ const files = await readdir(plugin); if (windows) execFileSync("tar.exe", ["-a", "-cf", archive, ...files], { cwd: plugin }); else execFileSync("zip", ["-qr", archive, ...files], { cwd: plugin }); if ((await stat(archive)).size > 100_000_000) throw new Error("The plugin ZIP exceeds the 100 MB upload limit."); +const tar = windows ? "tar.exe" : "/usr/bin/tar"; +const members = execFileSync(tar, ["-tf", archive], { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 }); +const entries = members.trimEnd().split("\n").length; +if (entries > 5000) throw new Error(`The plugin ZIP has ${entries} entries. The upload limit is 5000.`); console.log(`Plugin: ${plugin}\nMarketplace: ${marketplace}\nZIP: ${archive}`); diff --git a/apps/codex-plugin/tooling/smoke-package.mjs b/apps/codex-plugin/tooling/smoke-package.mjs index ba6779bc..b5b6552f 100644 --- a/apps/codex-plugin/tooling/smoke-package.mjs +++ b/apps/codex-plugin/tooling/smoke-package.mjs @@ -2,6 +2,9 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; import { access, cp, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; +import { pathToFileURL } from "node:url"; +import { setTimeout as delay } from "node:timers/promises"; +import { testingRuntimeArchive } from "../../../tooling/panel-runtime.mjs"; import { join, resolve } from "node:path"; import assert from "node:assert/strict"; import { createHash } from "node:crypto"; @@ -16,6 +19,21 @@ let transport; let runtimeTransport; let browserTransport; +async function prepareTestingRuntime(client) { + const deadline = Date.now() + 60_000; + let name = "mobile_testing_prepare_runtime"; + for (;;) { + const response = await client.callTool({ name, arguments: {} }); + assert.ok(!response.isError, JSON.stringify(response.content)); + const progress = response.structuredContent.progress; + assert.notEqual(progress.phase, "failed", progress.message); + if (progress.phase === "ready") return; + assert.ok(Date.now() < deadline, "Testing Studio installation timed out"); + name = "mobile_testing_runtime_progress"; + await delay(100); + } +} + function uiIdentity(text) { const user = text.match(/name="mobile-dev-user-id" content="(anon_[a-f0-9]{32})"/); const session = text.match(/name="mobile-dev-session-id" content="(run_[a-f0-9]{32})"/); @@ -94,6 +112,23 @@ try { const manifestText = await readFile(manifestPath, "utf8"); const manifest = JSON.parse(manifestText); assert.equal(manifest.name, "mobile-dev"); + const runtimeName = testingRuntimeArchive(manifest.version); + const archive = resolve("release", runtimeName); + const pinPath = join(plugin, "dist/testing-runtime.json"); + const pin = JSON.parse(await readFile(pinPath, "utf8")); + const bytes = await readFile(archive); + assert.equal(pin.bytes, bytes.length); + assert.equal(pin.sha256, createHash("sha256").update(bytes).digest("hex")); + assert.equal(pin.version, manifest.version); + if (telemetryConfig.environment === "release") { + const repository = process.env.GITHUB_REPOSITORY || "callstackincubator/codex-mobile-dev-plugin"; + assert.equal(pin.url, `https://github.com/${repository}/releases/download/v${manifest.version}/${runtimeName}`); + } + // Serve the exact release bytes from a local file before the GitHub release exists. + const localPin = { ...pin, url: pathToFileURL(archive).href }; + await writeFile(pinPath, JSON.stringify(localPin)); + delete serverEnv.MOBILE_DEV_E2E_RUNTIME; + serverEnv.LOCALAPPDATA = fixtureHome; transport = new StdioClientTransport({ command: serverConfig.command, args: serverConfig.args, cwd: serverCwd, stderr: "pipe", env: serverEnv, }); @@ -127,10 +162,21 @@ try { for (const name of ["mobile_list_ios_devices", "mobile_list_android_devices", "mobile_boot_android_emulator", "mobile_android_stream_session", "mobile_ios_mirror_session", "mobile_ios_mirror_reset", "mobile_ios_mirror_close"]) assert.ok(tools.tools.some(tool => tool.name === name)); for (const name of ["device_open", "device_snapshot", "device_press", "device_screenshot"]) assert.ok(tools.tools.some(tool => tool.name === name), name); await access(join(plugin, "dist/agent-device/tools.json")); - await access(join(plugin, "dist/e2e/node_modules/e2e/dist/cli/bin.js")); - await access(join(plugin, "dist/e2e/node_modules/@e2e-dev/mobile/dist/nodes.js")); - await access(join(plugin, "dist/e2e/release.json")); - await access(join(plugin, "dist/e2e/THIRD_PARTY_NOTICES.txt")); + await assert.rejects(access(join(plugin, "dist/e2e")), { code: "ENOENT" }); + const testingConfig = () => client.callTool({ name: "mobile_testing_project_config", arguments: { projectPath: temporary } }); + const cold = await testingConfig(); + assert.equal(cold.isError, undefined, JSON.stringify(cold.content)); + assert.equal(cold.structuredContent.needsRuntime, true); + const runtimeRoot = cold.structuredContent.runtime.root; + await assert.rejects(access(runtimeRoot), { code: "ENOENT" }); + await prepareTestingRuntime(client); + const warm = await testingConfig(); + assert.equal(warm.structuredContent.needsRuntime, false); + for (const path of ["node_modules/e2e/dist/cli/bin.js", "node_modules/@e2e-dev/mobile/dist/nodes.js", "release.json", "THIRD_PARTY_NOTICES.txt"]) { + await access(join(runtimeRoot, path)); + } + const runner = join(runtimeRoot, "node_modules/e2e/dist/cli/bin.js"); + execFileSync(process.execPath, [runner, "--version"], { encoding: "utf8", timeout: 15_000 }); const physicalMirror = tools.tools.find(tool => tool.name === "mobile_ios_mirror_session"); assert.deepEqual(physicalMirror._meta.ui.visibility, ["app"]); await access(join(plugin, "dist/serve-emu/src/cli.mjs")); @@ -209,9 +255,14 @@ try { assert.equal(workspace._meta.ui.resourceUri, `ui://mobile-dev/${manifest.version}/workspace.html`); assert.deepEqual(resource.contents[0]._meta.ui.csp.connectDomains, ["https://o4512180958068736.ingest.de.sentry.io"]); assert.deepEqual(resource.contents[0]._meta.ui.csp.resourceDomains, []); + // A fresh MCP process must be able to use the cached runner with the release unavailable. + const offlineArchive = join(temporary, "unavailable.tar.gz"); + const offlinePin = { ...pin, url: pathToFileURL(offlineArchive).href }; + await writeFile(pinPath, JSON.stringify(offlinePin)); runtimeTransport = new StdioClientTransport({ command: serverConfig.command, args: serverConfig.args, cwd: serverCwd, stderr: "pipe", env: serverEnv }); const runtime = new Client({ name: "mobile-dev-package-runtime", version: "1" }); await runtime.connect(runtimeTransport); + await prepareTestingRuntime(runtime); const runtimeResource = await runtime.readResource({ uri: entrypoint._meta.ui.resourceUri }); if (process.env.MOBILE_DEV_TELEMETRY === "off") { assert.deepEqual(runtimeResource.contents[0], resource.contents[0]); diff --git a/docs/releases.md b/docs/releases.md index b9537166..b15296af 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -24,8 +24,8 @@ A prerelease version, such as `0.1.172-test.1`, runs the same workflow as a test deployment. Set that version in the same three places on a branch, commit it as `chore(release): prepare 0.1.172-test.1`, and push the commit and its `v0.1.172-test.1` tag. The workflow builds, tests and packages it like a release and -publishes a GitHub prerelease with every package, including Claude's panel runtime -archive, which the Claude plugin of that build downloads. A prerelease is never +publishes a GitHub prerelease with every package, including the runtime archives pinned by the +Codex and Claude packages. A prerelease is never marked Latest, later release notes skip it, and it stays off `release/latest` and `release/claude`, so Codex and Claude users do not receive it. Install its Claude plugin from the prerelease's `claude-plugin` ZIP to test the full download. Delete @@ -84,7 +84,9 @@ tags and draft releases do not truncate the list. The first public release lists the full source history. Later releases also include a link to the full diff. Download `mobile-dev--darwin-arm64.zip` directly from the release's -assets for manual store upload. The same ZIP is also retained, with the +assets for manual store upload. The Codex ZIP contains at most 5,000 entries. Testing Studio downloads +`mobile-dev--testing-runtime-darwin-arm64.tar.gz` from the same release on first use +and caches it after verifying the pinned size and SHA-256. The same ZIP is also retained, with the Claude packages, as one Actions artifact for 30 days; extract the Actions artifact wrapper before uploading the plugin ZIP. Publishing a GitHub release does not submit or publish it to the OpenAI plugin directory. A tag that already has a GitHub release will fail release diff --git a/docs/telemetry.md b/docs/telemetry.md index c401af76..a1f26c7e 100644 --- a/docs/telemetry.md +++ b/docs/telemetry.md @@ -35,13 +35,16 @@ Behavior never depends on this value; it only attributes measurements and errors model context updates by `outcome` (`stored`, `invalid` or `too_large`), and `browser_panel.context_bytes` records the size of stored updates in bytes; the context's text and images are never sent. -- Packages that download the device and Testing Studio runtime, such as Claude's, measure that - step. `panel_runtime.ready` records, in milliseconds, how long the runtime took to be +- Codex measures its Testing Studio runtime download. Claude measures its combined + device and Testing Studio runtime download. `panel_runtime.ready` records, in milliseconds, how long the runtime took to be ready on its first use in a server, by `outcome`: `cached` when a complete folder was already there, `downloaded` for a download, checksum check and extraction, or `failed` with a bounded `reason` (`network`, `http`, `checksum`, `archive` or `filesystem`). `panel_runtime.download_bytes` records the archive size - of each download, including the Testing Studio runtime since 0.1.191. A failure + of each download. Claude includes Testing Studio since 0.1.191. Codex reports its + standalone archive since 0.1.192. Both metrics identify the archive with `runtime` + (`testing` or `panel`). The UI’s installation progress polls are excluded + from MCP traces and product analytics. A failure surfaces as the expected `download_failed` outcome; checksum, archive and filesystem failures are also captured as `panel_runtime.prepare` errors with a `panel_runtime_failure` tag, while offline diff --git a/package-lock.json b/package-lock.json index 7b9bb74b..2395f3b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mobile-dev", - "version": "0.1.191", + "version": "0.1.192", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mobile-dev", - "version": "0.1.191", + "version": "0.1.192", "workspaces": [ "packages/shared", "packages/core", diff --git a/package.json b/package.json index a5f6f497..a47d5703 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mobile-dev", - "version": "0.1.191", + "version": "0.1.192", "private": true, "workspaces": [ "packages/shared", diff --git a/packages/core/src/e2e-runtime.ts b/packages/core/src/e2e-runtime.ts index 8f2c6b3b..1b209a1c 100644 --- a/packages/core/src/e2e-runtime.ts +++ b/packages/core/src/e2e-runtime.ts @@ -4,7 +4,15 @@ import { readFile } from "node:fs/promises"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { ExpectedOperationError } from "@mobile-dev/shared/error-reporting.ts"; -import { panelRuntimePath } from "./panel-runtime.ts"; +import { downloadedPanelRuntime, panelRuntimeDirectory, panelRuntimePath, type PanelRuntimeRelease } from "./panel-runtime.ts"; +import pinnedRuntime from "../../runtimes/e2e/package.json" with { type: "json" }; + +export let testingRuntimeDownload: ReturnType | undefined; + +export function useDownloadedTestingRuntime(release: PanelRuntimeRelease) { + const directory = panelRuntimeDirectory(process.env, "testing-runtime"); + testingRuntimeDownload = downloadedPanelRuntime(release, directory, true); +} export type TestingRuntimeMode = "project" | "bundled"; @@ -24,6 +32,10 @@ export const PROJECT_CLI = "node_modules/.bin/e2e"; /** Resolves the E2E runtime from the source tree or the packaged host's runtime. */ export async function bundledE2eRoot(): Promise { + if (testingRuntimeDownload) { + const directory = await testingRuntimeDownload.ensure(); + return join(directory, "e2e"); + } const configured = process.env.MOBILE_DEV_E2E_RUNTIME?.trim(); const root = configured || (modulePath.endsWith(".ts") ? resolve(moduleDirectory, "../../runtimes/e2e") @@ -39,6 +51,15 @@ async function version(root: string, name: string): Promise { } export async function bundledRuntimeDescriptor(reason?: string): Promise { + // Project discovery also runs behind the device panel. Reading its metadata must stay offline. + if (testingRuntimeDownload) { + const root = join(testingRuntimeDownload.target, "e2e"); + return { + mode: "bundled", root, reason, + e2eVersion: pinnedRuntime.dependencies.e2e, + mobileVersion: pinnedRuntime.dependencies["@e2e-dev/mobile"], + }; + } const root = await bundledE2eRoot(); return { mode: "bundled", diff --git a/packages/core/src/panel-runtime.ts b/packages/core/src/panel-runtime.ts index 7490f7fd..eb9f1206 100644 --- a/packages/core/src/panel-runtime.ts +++ b/packages/core/src/panel-runtime.ts @@ -10,6 +10,7 @@ import { fileURLToPath } from "node:url"; import { promisify } from "node:util"; import { z } from "zod"; import { ExpectedOperationError } from "@mobile-dev/shared/error-reporting.ts"; +import type { TestingRuntimeProgress } from "@mobile-dev/shared/testing-runtime.ts"; import { captureServerError, recordPanelRuntime } from "./telemetry.ts"; /** The parts in the downloadable runtime, as laid out in dist/. */ @@ -40,8 +41,9 @@ export const panelRuntimeReleaseSchema = z.object({ export type PanelRuntimeRelease = z.infer; export class PanelRuntimeUnavailableError extends ExpectedOperationError { - constructor(detail: string) { - super("download_failed", `Mobile Dev could not download its device and testing runtime: ${detail} Check the internet connection, then try again.`); + constructor(detail: string, testingOnly: boolean) { + const runtime = testingOnly ? "Testing Studio runtime" : "device and testing runtime"; + super("download_failed", `Mobile Dev could not install its ${runtime}: ${detail} Check the internet connection, then try again.`); } } @@ -57,10 +59,10 @@ const installed = /^\d+\.\d+\.\d+(?:-[\da-zA-Z.-]+)?-[0-9a-f]{12}$/; const run = promisify(execFile); /** The persistent folder for downloaded runtimes: the plugin's data folder in Claude Code, else the user's cache. */ -export function panelRuntimeDirectory(env: NodeJS.ProcessEnv = process.env) { - if (env.CLAUDE_PLUGIN_DATA) return join(env.CLAUDE_PLUGIN_DATA, "panel-runtime"); +export function panelRuntimeDirectory(env: NodeJS.ProcessEnv = process.env, folder = "panel-runtime") { + if (folder === "panel-runtime" && env.CLAUDE_PLUGIN_DATA) return join(env.CLAUDE_PLUGIN_DATA, "panel-runtime"); const cache = process.platform === "win32" ? env.LOCALAPPDATA || join(homedir(), "AppData", "Local") : join(homedir(), "Library", "Caches"); - return join(cache, "mobile-dev", "panel-runtime"); + return join(cache, "mobile-dev", folder); } /** @@ -68,50 +70,65 @@ export function panelRuntimeDirectory(env: NodeJS.ProcessEnv = process.env) { * use. Each version extracts into its own folder, which appears only once complete, so * servers of other sessions and releases can share the directory. */ -export function downloadedPanelRuntime(release: PanelRuntimeRelease, directory = panelRuntimeDirectory()): () => Promise { +export function downloadedPanelRuntime(release: PanelRuntimeRelease, directory = panelRuntimeDirectory(), testingOnly = false) { const target = join(directory, `${release.version}-${release.sha256.slice(0, 12)}`); let ready: Promise | undefined; - return () => { - ready ??= prepare(release, directory, target).catch(error => { + const progress: TestingRuntimeProgress = { phase: "idle", received: 0, total: release.bytes }; + function ensure() { + if (ready) return ready; + progress.phase = "checking"; + progress.received = 0; + delete progress.message; + ready = prepare(release, directory, target, testingOnly, progress).then(root => { + progress.phase = "ready"; + return root; + }, error => { + progress.phase = "failed"; + progress.message = errorText(error); ready = undefined; throw error; }); return ready; - }; + } + return { target, ensure, progress }; } -async function prepare(release: PanelRuntimeRelease, directory: string, target: string): Promise { +async function prepare(release: PanelRuntimeRelease, directory: string, target: string, testingOnly: boolean, progress: TestingRuntimeProgress): Promise { const startedAt = performance.now(); - if (await complete(target, release)) { - recordPanelRuntime("cached", performance.now() - startedAt); + const runtime = testingOnly ? "testing" : "panel"; + if (await complete(target, release, testingOnly)) { + recordPanelRuntime(runtime, "cached", performance.now() - startedAt); return target; } - try { await install(release, directory, target); } + try { await install(release, directory, target, testingOnly, progress); } catch (error) { const failure = error instanceof RuntimeFailure ? error : new RuntimeFailure("filesystem", errorText(error)); - recordPanelRuntime("failed", performance.now() - startedAt, undefined, failure.reason); + recordPanelRuntime(runtime, "failed", performance.now() - startedAt, undefined, failure.reason); // Offline machines and unreachable releases are expected; a mismatch or a broken archive is not. if (failure.reason !== "network" && failure.reason !== "http") captureServerError(failure, "panel_runtime.prepare", { tags: { panel_runtime_failure: failure.reason } }); - throw new PanelRuntimeUnavailableError(failure.message); + throw new PanelRuntimeUnavailableError(failure.message, testingOnly); } - recordPanelRuntime("downloaded", performance.now() - startedAt, release.bytes); + recordPanelRuntime(runtime, "downloaded", performance.now() - startedAt, release.bytes); void removeOtherVersions(directory, target).catch(() => {}); return target; } -async function install(release: PanelRuntimeRelease, directory: string, target: string) { +async function install(release: PanelRuntimeRelease, directory: string, target: string, testingOnly: boolean, progress: TestingRuntimeProgress) { const suffix = randomBytes(6).toString("hex"); const archive = join(directory, `.download-${suffix}.tar.gz`); const staging = join(directory, `.staging-${suffix}`); try { await mkdir(directory, { recursive: true }); - await download(new URL(release.url), archive, release); - await extract(archive, staging); + progress.phase = "downloading"; + const url = new URL(release.url); + await download(url, archive, release, progress); + progress.phase = "installing"; + await extract(archive, staging, testingOnly); await writeFile(join(staging, "panel-runtime.json"), JSON.stringify(release) + "\n"); try { await rename(staging, target); } catch (error) { // Another server finished the same version first. - if (await complete(target, release) === false) throw error; + if (await complete(target, release, testingOnly) === false) throw error; } } finally { await rm(archive, { force: true }); @@ -119,13 +136,14 @@ async function install(release: PanelRuntimeRelease, directory: string, target: } } -async function complete(target: string, release: PanelRuntimeRelease) { +async function complete(target: string, release: PanelRuntimeRelease, testingOnly: boolean) { try { const marker: unknown = JSON.parse(await readFile(join(target, "panel-runtime.json"), "utf8")); if (typeof marker !== "object" || marker === null || ("sha256" in marker && marker.sha256 === release.sha256) === false) return false; - await access(join(target, "baguette/Baguette"), constants.X_OK); const e2eCli = join(target, E2E_CLI); await access(e2eCli); + if (testingOnly) return true; + await access(join(target, "baguette/Baguette"), constants.X_OK); for (const name of ["simslim", "avdslim"]) { const executable = join(target, "resource-saving", name); await access(executable, constants.X_OK); @@ -134,7 +152,7 @@ async function complete(target: string, release: PanelRuntimeRelease) { } catch { return false; } } -async function download(url: URL, destination: string, release: PanelRuntimeRelease) { +async function download(url: URL, destination: string, release: PanelRuntimeRelease, progress: TestingRuntimeProgress) { let body: Readable; if (url.protocol === "file:") body = createReadStream(fileURLToPath(url)); else { @@ -150,6 +168,7 @@ async function download(url: URL, destination: string, release: PanelRuntimeRele transform(chunk: Buffer, _encoding, callback) { size += chunk.byteLength; if (size > release.bytes) return callback(new RuntimeFailure("checksum", "the archive is larger than the release it pins.")); + progress.received = size; hash.update(chunk); callback(null, chunk); }, @@ -162,14 +181,15 @@ async function download(url: URL, destination: string, release: PanelRuntimeRele if (size !== release.bytes || hash.digest("hex") !== release.sha256) throw new RuntimeFailure("checksum", "the archive does not match the release it pins."); } -async function extract(archive: string, staging: string) { +async function extract(archive: string, staging: string, testingOnly: boolean) { + const parts: readonly string[] = testingOnly ? ["e2e"] : PANEL_RUNTIME_PARTS; const tar = process.platform === "win32" ? "tar.exe" : "/usr/bin/tar"; const { stdout } = await run(tar, ["-tzf", archive], { maxBuffer: 16 * 1024 * 1024 }).catch(error => { throw new RuntimeFailure("archive", `the archive could not be read (${errorText(error)}).`); }); for (const member of stdout.split(/\r?\n/).filter(Boolean)) { const segments = member.replace(/^\.\//, "").split("/"); - if (/[\\:]/.test(member) || member.startsWith("/") || segments.includes("..") || (PANEL_RUNTIME_PARTS as readonly string[]).includes(segments[0]) === false) { + if (/[\\:]/.test(member) || member.startsWith("/") || segments.includes("..") || parts.includes(segments[0]) === false) { throw new RuntimeFailure("archive", "the archive holds files outside the device runtime."); } } @@ -179,16 +199,17 @@ async function extract(archive: string, staging: string) { throw new RuntimeFailure("archive", `the archive could not be extracted (${errorText(error)}).`); }); await assertPlainFiles(staging); - for (const part of PANEL_RUNTIME_PARTS) { + for (const part of parts) { await access(join(staging, part)).catch(() => { throw new RuntimeFailure("archive", `the archive is missing ${part}.`); }); } - await access(join(staging, "baguette/Baguette"), constants.X_OK).catch(() => { - throw new RuntimeFailure("archive", "the simulator backend in the archive is not executable."); - }); const e2eCli = join(staging, E2E_CLI); await access(e2eCli).catch(() => { throw new RuntimeFailure("archive", "the archive is missing the Testing Studio runner."); }); + if (testingOnly) return; + await access(join(staging, "baguette/Baguette"), constants.X_OK).catch(() => { + throw new RuntimeFailure("archive", "the simulator backend in the archive is not executable."); + }); for (const name of ["simslim", "avdslim"]) { const executable = join(staging, "resource-saving", name); await access(executable, constants.X_OK).catch(() => { throw new RuntimeFailure("archive", "a resource optimizer in the archive is not executable."); }); diff --git a/packages/core/src/telemetry.ts b/packages/core/src/telemetry.ts index 8fcd96c4..43576cc9 100644 --- a/packages/core/src/telemetry.ts +++ b/packages/core/src/telemetry.ts @@ -38,11 +38,11 @@ export function recordBrowserPanelContext(outcome: "stored" | "invalid" | "too_l * How long the panel's downloaded runtime took to be ready, by outcome: found complete, * downloaded and extracted, or failed with a bounded reason. Sizes only for downloads. */ -export function recordPanelRuntime(outcome: "cached" | "downloaded" | "failed", duration: number, bytes?: number, reason?: string) { +export function recordPanelRuntime(runtime: "panel" | "testing", outcome: "cached" | "downloaded" | "failed", duration: number, bytes?: number, reason?: string) { if (process.env.MOBILE_DEV_TELEMETRY === "off") return; - const attributes = { component: "server", outcome, ...reason ? { reason } : {} }; + const attributes = { component: "server", runtime, outcome, ...reason ? { reason } : {} }; Sentry.metrics.distribution("panel_runtime.ready", duration, { attributes, unit: "millisecond" }); - if (bytes !== undefined) Sentry.metrics.distribution("panel_runtime.download_bytes", bytes, { attributes: { component: "server" }, unit: "byte" }); + if (bytes !== undefined) Sentry.metrics.distribution("panel_runtime.download_bytes", bytes, { attributes: { component: "server", runtime }, unit: "byte" }); } export function recordIosMirrorSharing(captures: number, subscribers: number, dropped: number) { diff --git a/packages/core/src/testing-setup.ts b/packages/core/src/testing-setup.ts index 7c6ae2c2..98cd7613 100644 --- a/packages/core/src/testing-setup.ts +++ b/packages/core/src/testing-setup.ts @@ -5,7 +5,7 @@ import { lstat, mkdir, readFile, readdir, rename, symlink, unlink, writeFile } f import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path"; import { pathToFileURL } from "node:url"; import { ExpectedOperationError } from "@mobile-dev/shared/error-reporting.ts"; -import { bundledE2eRoot } from "./e2e-runtime.ts"; +import { bundledE2eRoot, testingRuntimeDownload } from "./e2e-runtime.ts"; import { TESTING_DIRECTORY } from "./testing-projects.ts"; import type { BundledModelProvider } from "./testing-run.ts"; @@ -74,7 +74,8 @@ const SUBSCRIPTION_IDS = ["openai", "github-copilot", "opencode-console", "space export async function readTestingLoginStatus(): Promise { const status = Object.fromEntries(SUBSCRIPTION_IDS.map(id => [id, false])) as TestingLoginStatus; try { - const root = await bundledE2eRoot(); + // Reading login status is part of background project discovery. + const root = testingRuntimeDownload ? join(testingRuntimeDownload.target, "e2e") : await bundledE2eRoot(); const store = join(root, "node_modules/e2e/dist/oauth/store.js"); const url = pathToFileURL(store); const module = await import(url.href) as { diff --git a/packages/core/src/testing-tools.ts b/packages/core/src/testing-tools.ts index 66f11059..cf7a199b 100644 --- a/packages/core/src/testing-tools.ts +++ b/packages/core/src/testing-tools.ts @@ -14,6 +14,7 @@ import type { TestingAgentContext } from "./testing-agent.ts"; import { TestDraftStore } from "./testing-drafts.ts"; import { MAX_DRAFT_STEPS, recordedStepSchema, testDraftIdSchema } from "@mobile-dev/shared/test-drafts.ts"; import type { TestDraft } from "@mobile-dev/shared/test-drafts.ts"; +import { bundledE2eRoot, testingRuntimeDownload } from "./e2e-runtime.ts"; import { TestingDevices } from "./testing-device.ts"; import { runRecordedTest, sweepLaneFiles } from "./testing-run.ts"; import type { TestRunRequest } from "./testing-run.ts"; @@ -24,7 +25,7 @@ import type { DeviceOps } from "./testing-prepare.ts"; import { deviceIdSchema } from "@mobile-dev/shared/panel-target.ts"; import { simulatorBundleForPid } from "./device-apps/apps.ts"; import type { BundledModelProvider } from "./testing-run.ts"; -import { answerTestingSetup, applyTestingSetup, cancelTestingSetup, inspectTestingSetup, planTestingSetup, readTestingModelPreference, saveTestingModelPreference, SETUP_PROVIDERS, startTestingLogin, testingSetupProgress } from "./testing-setup.ts"; +import { answerTestingSetup, applyTestingSetup, cancelTestingSetup, inspectTestingSetup, planTestingSetup, readTestingLoginStatus, readTestingModelPreference, saveTestingModelPreference, SETUP_PROVIDERS, startTestingLogin, testingSetupProgress } from "./testing-setup.ts"; import type { SetupOptions } from "./testing-setup.ts"; const read = { readOnlyHint: true, destructiveHint: false, openWorldHint: false }; @@ -321,9 +322,37 @@ export function registerTestingTools(server: McpServer, projects: TestingProject ? await (matrix.foregroundBundle ?? simulatorBundleForPid)(foregroundDeviceId, foregroundPid).catch(() => undefined) : undefined); const bundleId = resolved && !LAUNCHER_APP.test(resolved) ? resolved : undefined; const project = await inspectProject(selected, foregroundPlatform && bundleId ? { platform: foregroundPlatform, bundleId } : undefined); - return dataResult({ ...project, setup: await inspectTestingSetup(project.path, project.configPath || undefined), modelPreference: await readTestingModelPreference(), providers: SETUP_PROVIDERS }); + const needsRuntime = project.runtimeMode === "bundled" && testingRuntimeDownload && testingRuntimeDownload.progress.phase !== "ready"; + return dataResult({ ...project, needsRuntime: Boolean(needsRuntime), setup: await inspectTestingSetup(project.path, project.configPath || undefined), modelPreference: await readTestingModelPreference(), providers: SETUP_PROVIDERS }); })); + const download = testingRuntimeDownload; + if (download) { + const currentProgress = async () => { + const loginStatus = download.progress.phase === "ready" ? await readTestingLoginStatus() : undefined; + return dataResult({ progress: { ...download.progress }, loginStatus }); + }; + registerAppTool(server, "mobile_testing_prepare_runtime", { + title: "Prepare the Testing Studio runtime", + description: "Start the pinned Testing Studio download on first use, or retry a failed installation.", + inputSchema: { retry: z.boolean().optional() }, + annotations: { ...write, openWorldHint: true }, + _meta: appVisibility, + }, safe(async ({ retry }: { retry?: boolean }) => { + const phase = download.progress.phase; + if (phase === "idle" || (phase === "failed" && retry)) { + // Polls report the terminal error without holding the initial MCP request open. + void download.ensure().catch(() => {}); + } + return currentProgress(); + })); + registerAppTool(server, "mobile_testing_runtime_progress", { + title: "Read Testing Studio download progress", + description: "Read the current download and installation status.", + inputSchema: {}, annotations: read, _meta: appVisibility, + }, safe(currentProgress)); + } + const setupTarget = z.object({ name: z.string().min(1).max(128), platform: z.enum(["ios", "android"]), bundleId: z.string().min(1).max(512) }); const setupOptions = z.object({ targets: z.array(setupTarget).min(1).max(100), @@ -380,7 +409,8 @@ export function registerTestingTools(server: McpServer, projects: TestingProject const project = await inspectProject(selected, { platform, bundleId }); // The refs go no further than the server: the panel records selectors and drives the mirror, // so an agent-device handle per element would be a few kilobytes a read that nothing reads. - const { tree, screen } = await devices.read({ deviceId, platform, projectPath: selected, runtimeRoot: project.runtime.root, bundleId }); + const runtimeRoot = project.runtimeMode === "bundled" ? await bundledE2eRoot() : project.runtime.root; + const { tree, screen } = await devices.read({ deviceId, platform, projectPath: selected, runtimeRoot, bundleId }); return dataResult({ tree, ...(screen ? { screen } : {}) }); })); @@ -418,8 +448,9 @@ export function registerTestingTools(server: McpServer, projects: TestingProject ?? project.targets.find(entry => entry.platform === platform && (!bundleId || entry.bundleId === bundleId)) ?? project.targets[0]; const bundledSource = project.runtimeMode === "bundled" ? (untilSource ?? await readTestFile(selected, relativePath)) : untilSource; + const runtimeRoot = project.runtimeMode === "bundled" ? await bundledE2eRoot() : project.runtime.root; const request: TestRunRequest = { ...paths, ...(timeoutMs === undefined ? {} : { timeoutMs }), ...(target ? { target } : {}), - ...(bundledSource === undefined ? {} : { untilSource: bundledSource }), runtime: { mode: project.runtimeMode, root: project.runtime.root }, + ...(bundledSource === undefined ? {} : { untilSource: bundledSource }), runtime: { mode: project.runtimeMode, root: runtimeRoot }, ...(project.runtimeMode === "bundled" && platform && bundleId ? { bundledTarget: { platform, bundleId } } : project.runtimeMode === "bundled" && selectedTarget?.platform && selectedTarget.bundleId ? { bundledTarget: { platform: selectedTarget.platform as "ios" | "android", bundleId: selectedTarget.bundleId } } : {}), ...(model ? { model } : {}) }; diff --git a/packages/core/test/panel-runtime.test.ts b/packages/core/test/panel-runtime.test.ts index 8bbd5c7b..56fbc66c 100644 --- a/packages/core/test/panel-runtime.test.ts +++ b/packages/core/test/panel-runtime.test.ts @@ -67,17 +67,17 @@ test("the runtime downloads once, verifies, and is shared by later servers", asy const server = await serve(t, () => ({ status: 200, body: bytes })); const pinned = { ...release, url: server.url }; const first = downloadedPanelRuntime(pinned, data); - const [root, again] = await Promise.all([first(), first()]); + const [root, again] = await Promise.all([first.ensure(), first.ensure()]); assert.equal(root, again); assert.equal(root, join(data, `1.2.3-${release.sha256.slice(0, 12)}`)); assert.equal(execFileSync(process.execPath, [join(root, "serve-emu/src/cli.mjs")], { encoding: "utf8" }).trim(), "serve-emu"); if (process.platform !== "win32") assert.equal(execFileSync(join(root, "baguette/Baguette"), { encoding: "utf8" }), "baguette\n"); assert.equal(server.requests(), 1); // Another server, as another session starts, finds the complete folder. - assert.equal(await downloadedPanelRuntime(pinned, data)(), root); + assert.equal(await downloadedPanelRuntime(pinned, data).ensure(), root); assert.equal(server.requests(), 1); assert.deepEqual(await readdir(data), [`1.2.3-${release.sha256.slice(0, 12)}`]); - usePanelRuntime(first); + usePanelRuntime(first.ensure); assert.equal(await panelRuntimePath("serve-emu/src/cli.mjs"), join(root, "serve-emu/src/cli.mjs")); const e2e = await panelRuntimePath("e2e"); assert.equal(e2e, join(root, "e2e")); @@ -86,7 +86,7 @@ test("the runtime downloads once, verifies, and is shared by later servers", asy test("an archive that does not match its pin is refused and leaves nothing behind", async t => { const { release, data } = await archive(t); for (const pinned of [{ ...release, sha256: "0".repeat(64) }, { ...release, bytes: release.bytes - 1 }]) { - await assert.rejects(downloadedPanelRuntime(pinned, data)(), (error: Error) => { + await assert.rejects(downloadedPanelRuntime(pinned, data).ensure(), (error: Error) => { assert.ok(error instanceof PanelRuntimeUnavailableError); assert.match(error.message, /does not match|larger than/); return true; @@ -97,7 +97,7 @@ test("an archive that does not match its pin is refused and leaves nothing behin test("an archive with files outside the parts is refused", async t => { const outside = await archive(t, async root => { await writeFile(join(root, "payload.sh"), ""); return ["payload.sh"]; }); - await assert.rejects(downloadedPanelRuntime(outside.release, outside.data)(), /outside the device runtime/); + await assert.rejects(downloadedPanelRuntime(outside.release, outside.data).ensure(), /outside the device runtime/); }); test("an archive with links is refused", async t => { @@ -107,7 +107,7 @@ test("an archive with links is refused", async t => { throw error; }); if (!linked) return; - await assert.rejects(downloadedPanelRuntime(linked.release, linked.data)(), /links or special files/); + await assert.rejects(downloadedPanelRuntime(linked.release, linked.data).ensure(), /links or special files/); assert.deepEqual(await readdir(linked.data), []); }); @@ -116,14 +116,14 @@ test("an unreachable release is an expected failure that the next open retries", let status = 404; const server = await serve(t, () => ({ status, body: status === 200 ? bytes : undefined })); const runtime = downloadedPanelRuntime({ ...release, url: server.url }, data); - await assert.rejects(runtime(), (error: Error) => { + await assert.rejects(runtime.ensure(), (error: Error) => { assert.ok(error instanceof ExpectedOperationError); assert.equal(error.outcome, "download_failed"); assert.match(error.message, /HTTP 404/); return true; }); status = 200; - assert.match(await runtime(), /1\.2\.3-/); + assert.match(await runtime.ensure(), /1\.2\.3-/); assert.equal(server.requests(), 2); }); @@ -137,7 +137,7 @@ test("a new version keeps the newest other version and removes older ones", asyn const time = new Date(Date.now() - age * 60 * 60_000); await utimes(path, time, time); } - await downloadedPanelRuntime(release, data)(); + await downloadedPanelRuntime(release, data).ensure(); // Pruning runs after the runtime is ready; give it time on a loaded machine. await t.waitFor(async () => assert.deepEqual((await readdir(data)).sort(), ["1.1.0-bbbbbbbbbbbb", `1.2.3-${release.sha256.slice(0, 12)}`]), { timeout: 15_000 }); }); @@ -145,9 +145,9 @@ test("a new version keeps the newest other version and removes older ones", asyn test("a prerelease pins and installs its runtime like a release", async t => { const { release, data } = await archive(t); const pinned = panelRuntimeReleaseSchema.parse({ ...release, version: "0.1.172-test.1" }); - assert.equal(await downloadedPanelRuntime(pinned, data)(), join(data, `0.1.172-test.1-${release.sha256.slice(0, 12)}`)); + assert.equal(await downloadedPanelRuntime(pinned, data).ensure(), join(data, `0.1.172-test.1-${release.sha256.slice(0, 12)}`)); // A later release replaces it like any other version. - await downloadedPanelRuntime({ ...release, version: "0.1.172" }, data)(); + await downloadedPanelRuntime({ ...release, version: "0.1.172" }, data).ensure(); assert.equal((await readdir(data)).length, 2); }); diff --git a/packages/core/test/telemetry.test.ts b/packages/core/test/telemetry.test.ts index 7e075c8e..3fa713a5 100644 --- a/packages/core/test/telemetry.test.ts +++ b/packages/core/test/telemetry.test.ts @@ -1445,8 +1445,8 @@ test("browser session counts describe plugin resources and honor telemetry opt-o recordBrowserPanelSessions(0); recordBrowserPanelContext("stored", 2048); recordBrowserPanelContext("too_large"); - recordPanelRuntime("downloaded", 1200, 7_000_000); - recordPanelRuntime("failed", 30, undefined, "network"); + recordPanelRuntime("testing", "downloaded", 1200, 7_000_000); + recordPanelRuntime("panel", "failed", 30, undefined, "network"); recordResourceSaving("ios", true, "success", 2500); recordResourceSaving("android", false, "failed", 100); await Sentry.flush(); @@ -1457,6 +1457,7 @@ test("browser session counts describe plugin resources and honor telemetry opt-o contains(sent, '"outcome":{"value":"too_large"'); contains(sent, "panel_runtime.ready"); contains(sent, "panel_runtime.download_bytes"); + contains(sent, '"runtime":{"value":"testing"'); contains(sent, "resource_saving.apply"); contains(sent, "resource_saving.duration"); contains(sent, '"reason":{"value":"network"'); @@ -1465,7 +1466,7 @@ test("browser session counts describe plugin resources and honor telemetry opt-o process.env.MOBILE_DEV_TELEMETRY = "off"; recordBrowserPanelSessions(3); recordBrowserPanelContext("stored", 10); - recordPanelRuntime("cached", 5); + recordPanelRuntime("panel", "cached", 5); recordResourceSaving("ios", false, "success", 10); await Sentry.flush(); assert.equal(JSON.stringify(envelopes), sent); diff --git a/packages/shared/src/telemetry.ts b/packages/shared/src/telemetry.ts index d4c9a095..bd98af28 100644 --- a/packages/shared/src/telemetry.ts +++ b/packages/shared/src/telemetry.ts @@ -52,7 +52,7 @@ type Metric = Parameters>[0]; const frequentTools = new Set([ "mobile_stream_input", "mobile_android_stream_input", "mobile_ios_mirror_input", "mobile_read_logs", "mobile_read_cpu", "mobile_read_display_fps", "mobile_logs_keep_alive", "mobile_log_sources", "mobile_performance_sources", - "mobile_read_performance_recording", + "mobile_read_performance_recording", "mobile_testing_runtime_progress", "mobile_appflow_status", "mobile_appflow_next_decision", "mobile_appflow_result", "mobile_list_simulators", "mobile_list_ios_devices", "mobile_list_android_devices", // agent-device's discovery and state lookups, as the plugin servers serve them. diff --git a/packages/shared/src/testing-runtime.ts b/packages/shared/src/testing-runtime.ts new file mode 100644 index 00000000..afa7f096 --- /dev/null +++ b/packages/shared/src/testing-runtime.ts @@ -0,0 +1,6 @@ +export interface TestingRuntimeProgress { + phase: "idle" | "checking" | "downloading" | "installing" | "ready" | "failed"; + received: number; + total: number; + message?: string; +} diff --git a/packages/shared/src/version.ts b/packages/shared/src/version.ts index 384a3656..496b158e 100644 --- a/packages/shared/src/version.ts +++ b/packages/shared/src/version.ts @@ -1 +1 @@ -export const PLUGIN_VERSION = "0.1.191"; +export const PLUGIN_VERSION = "0.1.192"; diff --git a/packages/ui/src/components/testing-setup.tsx b/packages/ui/src/components/testing-setup.tsx index 16c55815..c33476b7 100644 --- a/packages/ui/src/components/testing-setup.tsx +++ b/packages/ui/src/components/testing-setup.tsx @@ -16,7 +16,7 @@ type SetupPlanView = { id: string; actions: { action: string; path: string; deta type SetupTarget = { name: string; platform: "ios" | "android"; bundleId: string }; const RUNTIME_HELP = { - bundled: "Bundled runtime: Testing Studio runs tests with the e2e runtime that ships with Mobile Dev. Nothing is written to your project; tests and config stay in Mobile Dev's private state.", + bundled: "Bundled runtime: Testing Studio runs tests with the e2e runtime provided by Mobile Dev. Nothing is written to your project; tests and config stay in Mobile Dev's private state.", project: "Project runtime: Testing Studio runs tests with the e2e packages installed in your project, using its own e2e config file.", } as const; diff --git a/packages/ui/src/components/testing-view.tsx b/packages/ui/src/components/testing-view.tsx index 6990670c..f33a7351 100644 --- a/packages/ui/src/components/testing-view.tsx +++ b/packages/ui/src/components/testing-view.tsx @@ -1,5 +1,6 @@ import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react"; import { BotIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, CircleIcon, CircleXIcon, CopyIcon, FileCode2Icon, FilePlus2Icon, FlaskConicalIcon, FolderOpenIcon, GripVerticalIcon, HistoryIcon, LoaderCircleIcon, MoreHorizontalIcon, MousePointerClickIcon, PlayIcon, SaveIcon, SquareIcon, Trash2Icon, UserIcon, WandSparklesIcon, XIcon } from "lucide-react"; +import type { TestingRuntimeProgress } from "@mobile-dev/shared/testing-runtime.ts"; import { TestingNote } from "./testing-note"; import type { DeviceAppsStore } from "../device-apps.ts"; import { platformLabel } from "../testing-panel.ts"; @@ -270,6 +271,10 @@ export function TestingView({ panel, deviceApps }: { panel: TestingPanel; device const device = devices.device; // The Run button's "N devices" needs the device list before the setup popover is ever opened. useEffect(() => { if (state.available && state.projectPath) void panel.loadMatrixDevices(); }, [panel, state.available, state.projectPath, state.runtimeMode]); + if (state.needsRuntime) return
+ + +
; const booted = device?.state === "Booted" || device?.state === "connected"; const target = state.targets.find(entry => entry.name === state.targetName) ?? state.targets[0]; const mismatch = panel.targetMismatch; @@ -325,6 +330,55 @@ export function TestingView({ panel, deviceApps }: { panel: TestingPanel; device ; } +function TestingRuntimeInstall({ panel, projectPath }: { panel: TestingPanel; projectPath: string }) { + const [attempt, setAttempt] = useState(0); + const [progress, setProgress] = useState(); + const [error, setError] = useState(""); + useEffect(() => { + let active = true; + let timer: ReturnType; + let start: { retry: boolean } | undefined = { retry: attempt > 0 }; + async function poll() { + if (document.hidden) { + document.addEventListener("visibilitychange", poll, { once: true }); + return; + } + try { + const next = await panel.runtimeProgress(projectPath, start); + if (!active) return; + start = undefined; + setProgress(next); + if (next.phase === "failed") setError(next.message ?? "The download failed."); + else if (next.phase !== "ready") timer = setTimeout(poll, 500); + } catch (failure) { + if (active) setError(failure instanceof Error ? failure.message : String(failure)); + } + } + void poll(); + return () => { + active = false; + clearTimeout(timer); + document.removeEventListener("visibilitychange", poll); + }; + }, [panel, projectPath, attempt]); + + if (error) return + Testing Studio setup failed + {error} + + + ; + const downloading = progress?.phase === "downloading"; + const installing = progress?.phase === "installing"; + const title = downloading ? "Downloading the Testing Studio runtime" : installing ? "Installing the Testing Studio runtime" : "Checking the Testing Studio runtime"; + return
+ {title} + {downloading && <> + {(progress.received / 1e6).toFixed(1)} of {(progress.total / 1e6).toFixed(1)} MB} + {(downloading || installing) &&

This version downloads once. Testing Studio opens automatically when it’s ready.

} +
; +} + /** * What the panel says while the user's own coding agent is writing the flow. * diff --git a/packages/ui/src/testing-panel.ts b/packages/ui/src/testing-panel.ts index a2016f94..899d23de 100644 --- a/packages/ui/src/testing-panel.ts +++ b/packages/ui/src/testing-panel.ts @@ -1,3 +1,4 @@ +import type { TestingRuntimeProgress } from "@mobile-dev/shared/testing-runtime.ts"; import type { HostBridge } from "./host-bridge.ts"; import type { DeviceAppsStore } from "./device-apps.ts"; import { captureUiError, countUiEvent, getUiTelemetryAttributes, recordUiTiming } from "./telemetry.ts"; @@ -113,6 +114,7 @@ export type TestingSnapshot = { providers: TestingProviderOption[]; modelPickerOpen: boolean; setupOpen: boolean; + needsRuntime?: boolean; loadingProject: boolean; pickingProject: boolean; launching: boolean; @@ -349,7 +351,7 @@ export class TestingPanel { private syncTreeSource() { const projectPath = this.snapshot.projectPath; const bundleId = this.target?.bundleId ?? ""; - const key = this.disposed || !projectPath || !bundleId ? "" : `${projectPath}\u0000${bundleId}`; + const key = this.disposed || this.snapshot.needsRuntime || !projectPath || !bundleId ? "" : `${projectPath}\u0000${bundleId}`; if (key === this.treeSourceKey) return; this.treeSourceKey = key; testRecorder.useTreeSource(key ? this.treeSource(projectPath, bundleId) : undefined); @@ -617,7 +619,7 @@ export class TestingPanel { this.draftRevision = testRecorder.getSnapshot().revision; this.draftFlowId = ""; this.pendingModelAction = undefined; - this.update({ projectPath: path, targets: [], targetName: "", configPath: "", runtimeMode: "bundled", setupState: "available", setupDetails: undefined, targetSource: "none", projectWarning: "", appLaunched: false, + this.update({ projectPath: path, needsRuntime: false, targets: [], targetName: "", configPath: "", runtimeMode: "bundled", setupState: "available", setupDetails: undefined, targetSource: "none", projectWarning: "", appLaunched: false, overwritePath: "", savedRevision: -1, savedPath: "", draftId: "", drafts: [], tests: [], error: null }); void this.refreshDrafts(); void this.refreshTests(); @@ -647,7 +649,7 @@ export class TestingPanel { loginStatus: Object.fromEntries(Object.entries(loginData).map(([key, value]) => [key, value === true])), } : undefined; const providers = (Array.isArray(data.providers) ? data.providers : []).map(entry => object(entry)).filter((entry): entry is Record => entry !== null).map(entry => ({ id: text(entry.id), label: text(entry.label), ...(text(entry.subscription) ? { subscription: text(entry.subscription) } : {}), ...(text(entry.defaultModel) ? { defaultModel: text(entry.defaultModel) } : {}) })).filter(entry => entry.id && entry.label); - this.update({ targets, targetName: preferred?.name ?? "", configPath: text(data.configPath), runtimeMode: data.runtimeMode === "project" ? "project" : "bundled", setupState: data.setupState === "configured" ? "configured" : "available", setupDetails, targetSource: ["project", "expo-cli", "static-expo", "foreground"].includes(text(data.targetSource)) ? text(data.targetSource) as TestingSnapshot["targetSource"] : "none", projectWarning: text(data.warning), modelPreference, providers }); + this.update({ targets, targetName: preferred?.name ?? "", needsRuntime: data.needsRuntime === true, configPath: text(data.configPath), runtimeMode: data.runtimeMode === "project" ? "project" : "bundled", setupState: data.setupState === "configured" ? "configured" : "available", setupDetails, targetSource: ["project", "expo-cli", "static-expo", "foreground"].includes(text(data.targetSource)) ? text(data.targetSource) as TestingSnapshot["targetSource"] : "none", projectWarning: text(data.warning), modelPreference, providers }); } catch (error) { if (revision === this.loadRevision) this.update({ error: error instanceof Error ? error.message : String(error) }); } finally { @@ -655,6 +657,18 @@ export class TestingPanel { } } + async runtimeProgress(projectPath: string, start?: { retry: boolean }) { + const revision = this.loadRevision; + const tool = start ? "mobile_testing_prepare_runtime" : "mobile_testing_runtime_progress"; + const response = await this.call(tool, start ?? {}); + const data = response.structuredContent as { progress: TestingRuntimeProgress; loginStatus?: Record }; + if (data.progress.phase === "ready" && !this.disposed && revision === this.loadRevision && projectPath === this.snapshot.projectPath) { + const setupDetails = this.snapshot.setupDetails; + this.update({ needsRuntime: false, ...(setupDetails && data.loginStatus ? { setupDetails: { ...setupDetails, loginStatus: data.loginStatus } } : {}) }); + } + return data.progress; + } + /** Records against another target the config declares. */ selectTarget(name: string) { if (!this.snapshot.targets.some(entry => entry.name === name)) return; diff --git a/tooling/hosts/fixtures.ts b/tooling/hosts/fixtures.ts index e02dead9..0aca286d 100644 --- a/tooling/hosts/fixtures.ts +++ b/tooling/hosts/fixtures.ts @@ -28,6 +28,7 @@ export async function startServer(target: Target) { // No device tools on PATH or in the home directory: the tests see no devices on any machine. env: { PATH: "/usr/bin:/bin", HOME: home, MOBILE_DEV_TELEMETRY: "off", + MOBILE_DEV_E2E_RUNTIME: join(root, "packages/runtimes/e2e"), ...(process.platform === "win32" ? { PATH: home, USERPROFILE: home, LOCALAPPDATA: home, APPDATA: home } : {}), ...(target === "mac" ? { MOBILE_DEV_HOST: "mac" } : {}), }, diff --git a/tooling/hosts/hosts.spec.ts b/tooling/hosts/hosts.spec.ts index 5224de1d..d67a20d1 100644 --- a/tooling/hosts/hosts.spec.ts +++ b/tooling/hosts/hosts.spec.ts @@ -121,6 +121,43 @@ test.describe("MCP Apps hosts", () => { expect(pageErrors).toEqual([]); }); + test("Testing Studio downloads on open and recovers from a failed installation", async ({ openView, server, target, pageErrors }) => { + test.skip(target !== "codex"); + let phase = "downloading"; + let configReads = 0; + let polls = 0; + const callTool = server.client.callTool.bind(server.client); + server.client.callTool = async (request, ...options) => { + if (request.name === "mobile_testing_project_config") { + configReads++; + return { content: [], structuredContent: { runtimeMode: "bundled", targets: [], needsRuntime: true } }; + } + if (request.name === "mobile_testing_prepare_runtime" || request.name === "mobile_testing_runtime_progress") { + polls++; + if (request.arguments?.retry) phase = "installing"; + const progress = { phase, received: 5_000_000, total: 25_000_000, message: "The download was interrupted." }; + return { content: [], structuredContent: { progress } }; + } + return callTool(request, ...options); + }; + const { view } = await openView("mobile_open_workspace"); + await expect.poll(() => configReads).toBeGreaterThan(0); + expect(polls).toBe(0); + await view.locator("#tool-select").click(); + await view.getByRole("option", { name: "Testing Studio" }).click(); + await expect(view.getByRole("progressbar")).toHaveAttribute("value", "5000000"); + await expect(view.getByText("5.0 of 25.0 MB")).toBeVisible(); + phase = "failed"; + await expect(view.getByText("The download was interrupted.")).toBeVisible(); + await view.getByRole("button", { name: "Retry download" }).click(); + await expect(view.getByText("Installing the Testing Studio runtime")).toBeVisible(); + phase = "ready"; + await expect(view.getByText("Installing the Testing Studio runtime")).toHaveCount(0); + await expect(view.getByRole("button", { name: "Retry download" })).toHaveCount(0); + await expect(view.locator("[data-testing-blocker]")).toBeVisible(); + expect(pageErrors).toEqual([]); + }); + test("the Testing panel puts the mirror, the preview and the steps side by side", async ({ openView, page, server }) => { test.skip(hasPanel(server) === false, "This target's server renders no panel in the chat."); // Recording is done by tapping the mirror and read back in the preview beside it, so the three diff --git a/tooling/hosts/screenshots/codex/testing-runtime-dark.png b/tooling/hosts/screenshots/codex/testing-runtime-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..4bd11380073b228c8a42acb5b5f52f3a0c864df7 GIT binary patch literal 14823 zcmeHuXH-*byKUTTWh;UmmAbd6s5F({RYX8~?}Q@KL3#-xTU1aG5Rndv^xgzQ4G|EK z8cG6zkRT!n1PCQ00g{l*H^%wK8TX8P&OPV;xWB&qNJdt9v(~$wXU_MTna?{DBOTsT z0;d1~0I#0zV>1BY*be~Ux2->ZJKFN~?Y(aRz*&Ia7%jPWP z{Z1o`-85x4Oi}iLH8Syys2T9{cZBQ0O0kt zaloG!U!DLI{2>SUL;Lfw2eLZVr7`my1dcmT+&!SCO^cEz71O=frizdoX0DKyAlvh?&AY0ws-U(X0Lf#M1 z^#&;^|Jd>KLDdOEl&`1FYXPASeC@HXbJYxG0dADh=vyyoUYdU|?fH!W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=uMcYj zujz+BN~?KW%Nr0X^3Urw`_KQ8r!JA^-EEvh>~#nNLOV)*%R)iMwKI2cYv1`oR;h=~ zTtZQG=~SuwP~g#hf~~91A^jHdFuLBMV#wR-5RMy7bB+3MAJac6D=8fU(tP}YuP6S& z=*-*&93GgNnHd{@9s;b{-T3&=;^;4VuDo!_%6LY0cH}=iqmf<5YaT$PY-uIcm0h5A=&Cs2O6d`B;7l1k$5ttH)}-$cBZNOV@t?!Q|2GEWe*iZB z|MM*M<{O7xzzO$%W(58ZwEh2|0r=OZ|5KwE|4N4c^wi3~LiexG{YR#p{*^EP%9sD= u^M$2*1OVW27jw>H4<{3k|5I-801EvzZUmSLGY(e(5AK`lSKfQ_>c0T0^Bw^J literal 0 HcmV?d00001 diff --git a/tooling/hosts/visual.spec.ts b/tooling/hosts/visual.spec.ts index 352f2955..eb5657f3 100644 --- a/tooling/hosts/visual.spec.ts +++ b/tooling/hosts/visual.spec.ts @@ -26,6 +26,25 @@ for (const theme of themes) test.describe(`${theme}`, { tag: "@visual" }, () => } }); + test("Testing Studio runtime download", async ({ openView, server }) => { + const callTool = server.client.callTool.bind(server.client); + server.client.callTool = async (request, ...options) => { + if (request.name === "mobile_testing_project_config") { + return { content: [], structuredContent: { runtimeMode: "bundled", targets: [], needsRuntime: true } }; + } + if (request.name === "mobile_testing_prepare_runtime" || request.name === "mobile_testing_runtime_progress") { + return { content: [], structuredContent: { progress: { phase: "downloading", received: 5_000_000, total: 25_000_000 } } }; + } + return callTool(request, ...options); + }; + const { view } = await openView("mobile_open_workspace", { theme, width: 480 }); + await view.locator("#tool-select").click(); + await view.getByRole("option", { name: "Testing Studio" }).click(); + const studio = view.getByRole("region", { name: "Testing Studio", exact: true }); + await expect(studio.getByRole("progressbar")).toBeVisible(); + await expect(studio).toHaveScreenshot(`testing-runtime-${theme}.png`); + }); + test(`panel beside the chat`, async ({ openView }) => { const { view } = await openView("mobile_open_simulator", { theme, displayMode: "inline", width: 480, arguments: { platform: "ios" } }); await expect(view.locator("#ios-panel")).toBeVisible(); diff --git a/tooling/panel-runtime.mjs b/tooling/panel-runtime.mjs index 31d18912..62af8117 100644 --- a/tooling/panel-runtime.mjs +++ b/tooling/panel-runtime.mjs @@ -6,6 +6,8 @@ import { pathToFileURL } from "node:url"; import { DOWNLOADED_RUNTIME_PARTS } from "./host-runtime.mjs"; /** The panel runtime archive each release attaches beside its packages. */ +const platform = process.platform === "win32" ? `win32-${process.arch}` : "darwin-arm64"; +export const testingRuntimeArchive = version => `mobile-dev-${version}-testing-runtime-${platform}.tar.gz`; export const panelRuntimeArchive = version => `mobile-dev-${version}-panel-runtime-darwin-arm64.tar.gz`; /** @@ -14,20 +16,24 @@ export const panelRuntimeArchive = version => `mobile-dev-${version}-panel-runti * release, under the tag `v`; a local build pins the file it just wrote, so * development packages work before anything is published. */ -export async function packPanelRuntime(version, { release = false, repository = defaultRepository() } = {}) { - const archive = resolve("release", panelRuntimeArchive(version)); +export async function packPanelRuntime(version, { release = false, repository = defaultRepository(), testingOnly = false } = {}) { + const name = testingOnly ? testingRuntimeArchive(version) : panelRuntimeArchive(version); + const parts = testingOnly ? ["e2e"] : DOWNLOADED_RUNTIME_PARTS; + const archive = resolve("release", name); await rm(archive, { force: true }); // The runtime accepts plain files. Testing Studio invokes the runner directly. - execFileSync("tar", [ - "-czf", archive, "--no-mac-metadata", "--exclude", ".DS_Store", - "--exclude", "e2e/node_modules/.bin", "-C", "dist", ...DOWNLOADED_RUNTIME_PARTS, + const tar = process.platform === "win32" ? "tar.exe" : "/usr/bin/tar"; + const metadataFlags = process.platform === "darwin" ? ["--no-mac-metadata"] : []; + execFileSync(tar, [ + "-czf", archive, ...metadataFlags, "--exclude", ".DS_Store", + "--exclude", "e2e/node_modules/.bin", "-C", "dist", ...parts, ], { env: { ...process.env, COPYFILE_DISABLE: "1" }, }); const bytes = await readFile(archive); const { size } = await stat(archive); const url = release - ? `https://github.com/${repository}/releases/download/v${version}/${panelRuntimeArchive(version)}` + ? `https://github.com/${repository}/releases/download/v${version}/${name}` : pathToFileURL(archive).href; return { archive, pin: { version, url, sha256: createHash("sha256").update(bytes).digest("hex"), bytes: size } }; } diff --git a/website/src/content/docs/docs/testing.md b/website/src/content/docs/docs/testing.md index 3f1f9e5a..cfa84ad5 100644 --- a/website/src/content/docs/docs/testing.md +++ b/website/src/content/docs/docs/testing.md @@ -16,6 +16,8 @@ You don't need an e2e project to start. Testing Studio works in two modes, and t | **No project** | Nothing is open, or the folder has no usable `e2e.config.ts` | Mobile Dev's bundled e2e runtime | Mobile Dev's private storage, listed under **In Testing Studio** | | **Project** | A folder with an `e2e.config.ts`, a mobile target with a bundle ID, and the project's own `e2e` CLI installed | The project's own e2e CLI and `@e2e-dev/mobile` | The project's `tests/` directory | +In Codex, opening Testing Studio in **No project** mode downloads the runner once for this plugin version. You can follow the download in the tab and retry there if it fails. Later sessions use the cached runner offline. + In **No project** mode the test runs against the app in front of the mirror, and each saved test remembers that app, so later runs open the same one. Nothing is written to any of your folders. In **Project** mode Mobile Dev never installs or replaces your test runner, and a run never downloads a CLI with `npx`.