fix(mobile): fail an open of an app the device does not have as TEST_SETUP_FAILED

KA
4h ago
+93-14

What

  • Opening an app the device doesn't have now fails with TEST_SETUP_FAILED (exit 2) when agent-device reports APP_NOT_INSTALLED. That covers Android launches, iOS display names, an iOS simulator's app.clearState(), and an app-targeted device.setPermission(), plus app.open(), app.restart(), device.openApp() and device.openLink() into that app.
  • The message names the app and the device, and tells you to install it (device.installApp() for the target's own build) or check the bundle id.
  • Not fixed here, still ENGINE_FAILURE: a launch of a missing dotted iOS bundle id (simulator or physical device) and an Android openLink bound to a missing package. agent-device starts these without an install check. A custom-scheme openLink on iOS is handed to the OS rather than launched as the named app; the OS routes the URL to whichever app handles the scheme, so it never reports a missing app.

Why

  • A missing app is a setup mistake, not a device fault, and agent-device's advice (Run install before open) points at its own CLI.
  • On an iOS simulator, agent-device skips its install check for a dotted bundle id and goes straight to simctl launch. When that fails it works out APP_NOT_INSTALLED but only sets details.hint and rethrows COMMAND_FAILED. I dropped the hint text match, since every other classification in errors.ts keys on a code. The simulator case needs agent-device to throw APP_NOT_INSTALLED; after a pin bump this PR picks it up unchanged.

How it works

  1. notInstalledCause (packages/mobile/src/errors.ts) accepts APP_NOT_INSTALLED only.
  2. appNotInstalled turns that failure into a ConfigurationError('TEST_SETUP_FAILED') and keeps the agent-device error as cause.
  3. The surface's open(), openLink() into a named app, setPermission and clearState pass their failures through it. open_app still reads isAppNotInstalled, so a wrong app returns INVALID_ARGUMENT to the model.

Issue

Refs #2281

Verified

  • pnpm --filter @e2e-dev/mobile typecheck and the engine, tools and errors unit tests pass at 0a6684de8. docs:check-errors passes.
  • Each of the four wraps (open, openLink, setPermission, clearState) has a unit test from APP_NOT_INSTALLED; reverting one fails it.
  • Not run: a live iOS simulator or Android emulator on this head. An earlier run of the first version of this change on an iPhone 17 Pro simulator showed the iOS open going to TEST_SETUP_FAILED through the hint match, which is gone now. The APP_NOT_INSTALLED path comes from unit tests and agent-device's source.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

Summary by CodeRabbit

  • Bug Fixes

    • App operations now report TEST_SETUP_FAILED with the app name and installation guidance when the target app isn’t installed. This applies to opening apps, changing app permissions, opening links for a known app, and clearing app state.
    • Missing iOS bundle IDs and Android packages that fail without an installation check continue to report ENGINE_FAILURE.
  • Documentation

    • Expanded mobile troubleshooting and reference guidance to explain these errors and how to resolve installation issues.