Repository navigation
fix(mcp): say headed for an engine that shows its app itself - #2371
okwasniewski wants to merge 3 commits into
Conversation
open_session printed the run's headed flag, so a desktop target with desktop({ headed: true }) read as headless. An engine now declares headed: true when an option of its own shows its surface, and the session line and usage report follow it.
A core that predates Engine.headed refuses the key at config load. Also covers the usage report with a host test, says in the open_session docs that such an engine is headed either way, and leaves the attached-session path as it was.
🟢 e2e web: 95 passedAll 95 tests in 43 files
Tested by e2e 0.25.0 · 1m 2s · web · run artifacts |
🟢 e2e web agent: 34 passed35 agent steps · 26 replayed from cache · 25 model calls · 133.8k tokens (94% cached) · $0.0055 All 34 tests in 5 files
Tested by e2e 0.25.0 · 1m 37s · web · run artifacts |
🟢 e2e android agent: 20 passed24 agent steps · 15 replayed from cache · 45 model calls · 288.7k tokens (87% cached) · $0.0167 All 20 tests in 1 file
Tested by e2e 0.25.0 · 5m 45s · android-emulator · run artifacts |
MicrobenchmarksFor ⚪ No case changed by 0.5% or more. Repeatability: two builds of the head agree in every case, 10 trials each. Base A direction is reported only when the trial ranges of base and head do not overlap and the change is at least 0.5%. 4 unchanged cases
How this is measuredInstructions per iteration: the difference between a run of N and of 3N iterations, divided by 2N, so startup, loading, warmup, and compilation cancel. 5 trial(s) per case and checkout. Lower is better. Machine: linux x64, AMD EPYC, Node v26.13.1, valgrind-3.22.0, ASLR off.
Workflow run: each job's summary, and |
🟢 e2e ios: 67 passed, 1 skippedAll 68 tests in 8 files
Tested by e2e 0.25.0 · 8m 20s · ios-simulator · run artifacts |
🟢 e2e android: 68 passed, 1 skippedAll 69 tests in 8 files
Tested by e2e 0.25.0 · 10m 28s · android-emulator · run artifacts |
🟢 e2e ios agent: 1 flaky, 20 passed, 1 skipped25 agent steps · 12 replayed from cache · 62 model calls · 499.1k tokens (83% cached) · $0.0324
|
| Test | Agent | Time | |
|---|---|---|---|
| tests-agent/scenarios.e2e.ts · 1 flaky, 20 passed, 1 skipped | 25 steps · 62 calls | 8m 46s | |
| 🟢 | act completes Login Form | 1 step | 41.6s |
| 🟢 | act completes Infinite Scroll List | 1 step | 39.2s |
| 🟢 | act completes Modal Flow | 1 step | 11.6s |
| 🟢 | act completes Bottom Tabs | 1 step | 7.9s |
| 🟢 | act completes Text Input Variations | 1 step | 13.1s |
| 🟢 | act completes Broken Accessibility | 2 steps · 5 calls | 20.6s |
| 🟢 | act completes Vision Only | 2 steps · 6 calls | 24.4s |
| act completes Gestures (1 failed attempt first) | 1 step · 11 calls | 52.0s | |
| 🟢 | act completes Async States | 1 step · 7 calls | 20.8s |
| 🟢 | act completes Debounced Search | 1 step · 1 call | 28.6s |
| 🟢 | act completes Flattened Registration Form | 2 steps · 1 call | 28.0s |
| 🟢 | act completes Flattened Login | 2 steps · 14 calls | 1m 13s |
| 🟢 | act completes Sticky Chrome Target | 1 step | 13.7s |
| 🟢 | act completes WebView Accessibility | 1 step | 12.7s |
| 🟢 | act completes Permission Prompt | 1 step | 12.4s |
| 🟢 | act completes Photo Picker | 1 step · 2 calls | 28.4s |
| 🟢 | act completes Product Catalog | 1 step | 10.7s |
| 🟢 | act completes Error Recovery | 1 step | 9.7s |
| 🟢 | act completes Choice Controls | 1 step · 6 calls | 34.8s |
| 🟢 | act completes Stripe PaymentSheet | 1 step · 9 calls | 31.4s |
| 🟢 | act completes Apple Pay | 1 step | 11.7s |
| ⏭️ | act completes Apple Pay Billing Address (skipped: the CI simulator's Apple Pay sheet skips the billing-address step, so the scenario cannot be completed there) |
Tested by e2e 0.25.0 · 9m 15s · ios-simulator · run artifacts
Engine.headed meant 'always shown' beside three info fields named headed that mean 'the run asked'. Rename it before release, and compute what a session shows in one helper so an attached session reports the same as a standalone one.
What
open_sessionine2e mcpsaysheadedfor a target whose engine shows its app through an option of its own, such asdesktop({ headed: true }). It saidheadless.An engine declares it with a new optional contract field:
Why
A desktop target with
desktop({ headed: true })opened overe2e mcpasSession ... (platform macos, engine desktop ...), headless;while the engine brought the app forward and used the real pointer and keyboard. The line printed only the run's flag (open_session {headed}or--headed), and the engine had no way to say its option overrides it.How it works
Engine.alwaysHeadedis a new optional boolean: an option of the engine shows its surface on every run, whatever the run asks (packages/core/src/engine/index.ts:868). It is not namedheaded, becauseEngineInitInfo.headed,EnginePrepareInfo.headedandEngineDoctorInfo.headedmean "the run asked".defineEnginechecks and copies it like the other boolean flags (packages/core/src/engine/manifest.ts:319).EngineManifest.alwaysHeaded(packages/core/src/engine/protocol/protocol.ts:129),describeEngineand the manifest comparison (packages/core/src/engine/protocol/manifest.ts:35), the client handle,engine-manifest-v1.schema.json, and both fixtures.desktop()declares it when itsheadedoption is on (packages/desktop/src/engine.ts:55). Its peer floor on@e2e-dev/coreande2egoes to>=0.25.1: an older core refuses the unknown key at config load.showsSurface(engine, requested)isrequested || engine.alwaysHeaded(packages/core/src/engine/manifest.ts:17). A standalone session uses it for the opening line and the usage report once the target is resolved (packages/e2e/src/mcp/session.ts:453), and a session attached to a held test uses it for the usage report (packages/e2e/src/run/worker/held-test-tools.ts:201). The engine is still handed what was asked, soEngineInitInfo.headedkeeps its meaning.docs/reference/engine.mdx(underinit, besideinfo.headed; it is not a capability) anddocs/reference/engine-protocol.mdx, and one clause onopen_session'sheadedindocs/reference/mcp.mdxand the tool's own description.Dropped alternative: returning the state from
init. It would change a required method's return type and thelifecycle/initwire reply for one line of text; the desktop option is known when the engine is created.Not changed:
open_session {attach}) prints no headed word. Its usage report follows the same rule as a standalone session.alwaysHeadedis not the general answer to "is this session visible".@e2e-dev/mobilenever reads the run'sheaded, and a hosted browser cannot honor it, soopen_session {headed: true}on those still saysheaded. That needs a separate decision.headlessfor a native app in the background is unchanged.Verified
Ran it locally: yes
desktop({ headed: true })run takes the shared screen, pointer and keyboard on this machine, so it was not run):packages/e2e/tests/integration/mcp-server.test.tsopens a session over the built CLI's stdio on an engine that declaresalwaysHeaded: true, with nothing asking for headed, and reads), headed;.mcp-session-host.test.tsasserts the engine'sinitstill gotheaded: falseand the usage summary saystrue.mcp-step-attachment.test.tsholds a test on such an engine in a run without--headed, attaches, and readsheaded: truein the opening; with the helper call reverted it readsfalse. On maindefineEnginerefuses thealwaysHeadedkey, so all three fail there.apps/desktop-testbed, native driver built from this branch), a reale2e mcpstdio session in background mode:headlessheadeddesktop(), nothing askedheadlessheadlessopen_session {headed: true}or--headedheadedheadedNo terminal recording or video: the change is one word in an MCP reply.