Repository navigation
fix: keep the launch Metro port for mobile cdp; persistent Hermes connection - #91
Merged
cryptotavares merged 9 commits intoNov 18, 2026
Conversation
…es/mmcli-p2-03-hermes-session
`mm launch --platform ios|android --metro-port <n>` stored the port on the session but `mm cdp` and `mm hermes-targets` resolved their target per call and fell back to `HERMES_METRO_PORT`/8081 (baseline B5), so they could reach another worktree's Metro. - `MobilePlatformDriver` options gain `metroPort`, `deviceId` and `appId`; `setHermesDefaults` keeps the launch values for later Hermes calls. - Precedence: per-call flag, then the driver/launch value, then `HERMES_METRO_PORT`/`HERMES_APP_ID`, then 8081/platform default. - `cdp` reuses one persistent device-mcp `HermesClient` per session target and is never retargeted: a call with a different port or app id uses a one-shot `runHermesCdp`. Releases without `HermesClient` (0.7.0) always take the one-shot path. - `hermes-targets` reports `sessionMetroPort`, `pinnedDeviceId`, `connected` and `deviceId`; a CDP failure names the Metro port it tried.
…es/mmcli-p2-03-hermes-session # Conflicts: # CHANGELOG.md # README.md # SKILL.md
…es/mmcli-p2-03-hermes-session # Conflicts: # CHANGELOG.md
…es/mmcli-p2-03-hermes-session
…r-cdp' into cryptotavares/mmcli-p2-03-hermes-session
The changelog is generated when a release is created.
…r-cdp' into cryptotavares/mmcli-p2-03-hermes-session
…r-cdp' into cryptotavares/mmcli-p2-03-hermes-session # Conflicts: # README.md
seaona
approved these changes
Nov 18, 2026
seaona
left a comment
Member
There was a problem hiding this comment.
Once device-mcp ships HermesClient, state-changing Hermes commands persist the same way as in the previous PR #90. On the emulator, Debugger.enable plus Debugger.pause froze the app's JS until Debugger.resume. The tap didn't act for at least 13 s, and any mm command that needs JS would time out. On mobile the risk is higher than on the browser, for two reasons:
- --fresh is browser-only and silently ignored on mobile. The only way to get a one-shot call is to pass a different port or app ID.
- SKILL.md:680 describes the persistent connection only as reuse, with no warning.
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
mm launch --platform ios|android --metro-port 8085stored the port, butmm cdpandmm hermes-targetsresolved it again for each call and fell back toHERMES_METRO_PORTor 8081 (baseline B5). On a machine with a second Metro on 8081 they reached the wrong app; without one they failed. Every Hermes call also opened its own WebSocket.MobilePlatformDriveroptions gainmetroPort,deviceIdandappId. New optionalIPlatformDriver.setHermesDefaults(): the launch tool applies--metro-port/--device-idto the driver after a successful mobile launch, so B5 is fixed with no consumer change.--metro-port/--app-id, then the driver (launch) value, thenHERMES_METRO_PORT/HERMES_APP_ID, then 8081 / the platform default. CDP failures name the port they tried.HermesClient(feat: HermesClient, a persistent Hermes CDP connection device-mcp#54),cdpkeeps one persistent client per session target. A per-call port or app id that differs uses a one-shot call, so the persistent client is never retargeted. The client is closed ondispose(). With device-mcp 0.7.0 (noHermesClient), core keeps the one-shotrunHermesCdppath (feature-detected).hermes-targetsalso reportssessionMetroPort,pinnedDeviceId,connectedanddeviceId(additive).Part of the mm CLI v2 effort: ticket
P2-03(Tier 2).Stacked on #90 (review that first).
Depends on MetaMask/device-mcp#54: the persistent connection needs a device-mcp release with
HermesClient, then a dependency bump here. The B5 fix works with the released 0.7.0.Breaking changes
None. New options and output fields only.
Consumer impact
tests/llm-workflow/{ metroPort, deviceId, appId }when constructingMobilePlatformDriver(patch ready). Core already applies the launch values itself.Proof
Yalc build in Mobile (dev client 8.19.0, iOS sim + Android emulator, Metro 8085, launched with
--metro-port 8085),mm cdp Runtime.evaluate 1+1without--metro-port, 10 runs:hermes-targetssaysmetroPort: 8081, metroDown: truesessionMetroPort: 8085, p50 15–40 mshermes-targetsafter a callconnected: true,pinnedDeviceIdset,deviceId= launch deviceThe before build reached Metro only with an explicit
--metro-port 8085(90 ms per call on Android). The raw client bench is in MetaMask/device-mcp#54 (Android p50 165 → 5 ms).Unit tests
Covers the precedence table, launch applies the port, one client for two calls, one-shot on a per-call override, fallback without
HermesClient, close on dispose, the pin persisting, and the newhermes-targetsfields.CI=1thresholds not lowered;tsc -p tsconfig.build.jsonandyarn lintclean.