Skip to content

fix(agentic): match RN 0.81 Bridgeless inspector targets#29895

Merged
abretonc7s merged 2 commits into
mainfrom
fix/agentic-cdp-rn081-targets
May 8, 2026
Merged

fix(agentic): match RN 0.81 Bridgeless inspector targets#29895
abretonc7s merged 2 commits into
mainfrom
fix/agentic-cdp-rn081-targets

Conversation

@abretonc7s

@abretonc7s abretonc7s commented May 8, 2026

Copy link
Copy Markdown
Contributor

Description

yarn a:ios was failing at the CDP-wait step on RN 0.81+ builds with Still waiting... app may still be loading JS bundle followed by a timeout, even when the simulator was booted, the app was running, and __AGENTIC__ was actually exposed and reachable on Metro's inspector port.

Root cause: scripts/perps/agentic/lib/target-discovery.js filters Metro /json/list results by t.title matching /react|hermes/i. With RN 0.81 + Hermes Bridgeless the inspector titles are bundle-id-only (e.g. io.metamask.MetaMask (mm-5)) and the runtime kind moved into description (React Native Bridgeless [C++ connection]). The old filter excluded every Bridgeless target — discoverAllTargets() returned [], cdp-bridge.js status returned empty, the preflight loop timed out.

Verified on a freshly built RN 0.81.5 simulator session before the patch:

  • curl http://localhost:<port>/json/list returned a Bridgeless target whose appId was io.metamask.MetaMask and description was React Native Bridgeless [C++ connection].
  • Manually opening a WS to that target and running Runtime.evaluate("typeof __AGENTIC__") returned object (the bridge was there the whole time).
  • node scripts/perps/agentic/cdp-bridge.js status returned [] (empty), confirming the agentic discovery filter dropped the target.

After the patch, cdp-bridge.js status on the same session returns:

{
  "account": { "address": "0x8dc623...9003", "id": "0285a92b-...", "name": "" },
  "route": { "key": "Wallet-...", "name": "Wallet" },
  "deviceName": "mm-5",
  "platform": "ios"
}

The fix relaxes the candidate filter in both discoverTarget and discoverAllTargets to also accept targets whose description contains bridgeless or hermes. Pre-0.81 behavior is unchanged because the legacy title-based clause still matches first; the new branch only fires when the title doesn't match. No behavior change on Android or older RN builds.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: Agentic CDP discovery works on RN 0.81 Bridgeless inspector

  Scenario: yarn a:ios on RN 0.81+ build
    Given the engineer has a clean RN 0.81+ debug build of MetaMask installed on a simulator
    And the app is running and exposes __AGENTIC__ via Metro's inspector
    When the engineer runs "yarn a:ios"
    Then the preflight CDP wait passes within a few seconds (rather than timing out)
    And "node scripts/perps/agentic/cdp-bridge.js status" returns a non-empty payload with the running route and selected account

  Scenario: Pre-RN-0.81 builds remain unaffected
    Given a pre-0.81 RN debug build whose inspector titles still say "React Native (...)" or "Hermes (...)"
    When the engineer runs "yarn a:ios"
    Then target discovery still picks the legacy title match (no behavior change)

  Scenario: Probe still gates by __AGENTIC__
    Given a non-MetaMask Hermes target appears on the same Metro
    When discoverAllTargets runs
    Then the probe step still rejects targets that don't expose __AGENTIC__ (the filter only widens the candidate set; the __AGENTIC__ probe is unchanged)

Screenshots/Recordings

Before

N/A — agentic CDP-wait failure mode is text-only:

[4/5] Connecting CDP
  Waiting for app to expose debug target
  Still waiting... app may still be loading JS bundle
  Taking longer than usual — check device
  CDP timeout — diagnostic probe:
    port <port>: 2 targets
      - io.metamask.MetaMask (mm-5) (device=mm-5)
      - io.metamask.MetaMask (mm-5) (device=mm-5)

After

N/A — same path now succeeds without timing out (yarn a:ios proceeds to the wallet setup step).

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
  • I've tested with a power user scenario
  • I've instrumented key operations with Sentry traces for production performance metrics

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Low risk: narrow change to debug-target discovery heuristics, only broadening candidate matching to include RN 0.81+ Bridgeless targets; primary risk is accidentally matching an extra non-RN CDP target in unusual Metro setups.

Overview
Fixes Agentic CDP target discovery on RN 0.81+ Bridgeless by widening the Metro /json/list candidate filter to accept targets identified via description (e.g., containing bridgeless/hermes) when title no longer contains "React Native"/"Hermes".

This update is applied consistently in both discoverTarget() and discoverAllTargets(), preserving the legacy title-based matching for pre-0.81 builds while allowing Bridgeless sessions to be selected and probed for __AGENTIC__.

Reviewed by Cursor Bugbot for commit 3fcd99a. Bugbot is set up for automated code reviews on this repo. Configure here.

The agentic CDP target discovery (`scripts/perps/agentic/lib/target-discovery.js`)
filtered Metro `/json/list` results by `t.title` matching `/react|hermes/i`. With
React Native 0.81 + Hermes Bridgeless, the inspector titles are bundle-id-only
(e.g. `io.metamask.MetaMask (mm-5)`) and the runtime kind moved into
`description` (e.g. `React Native Bridgeless [C++ connection]`).

The old filter excluded every Bridgeless target → `discoverAllTargets()` returned
`[]` → `cdp-bridge.js status` returned empty → `yarn a:ios` preflight CDP wait
timed out even when `__AGENTIC__` was actually exposed and reachable.

Relax the candidate filter in both `discoverTarget` and `discoverAllTargets` to
also accept targets whose `description` contains `bridgeless` or `hermes`.
Behavior on pre-0.81 builds is unchanged (the legacy title-based clause still
matches first).
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbotv2 metamaskbotv2 Bot added the team-perps Perps team label May 8, 2026
@github-actions github-actions Bot added the size-S label May 8, 2026
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 97%
click to see 🤖 AI reasoning details

E2E Test Selection:
The only changed file is scripts/perps/agentic/lib/target-discovery.js, a developer tooling script in the agentic automation toolkit for Perps development. The change updates the Chrome DevTools Protocol (CDP) target discovery logic to support React Native 0.81+ Bridgeless mode by also matching debugger targets via the description field (containing "bridgeless" or "hermes") in addition to the existing title-based matching. This is purely a developer tooling improvement with no impact on: (1) app production code, (2) E2E test infrastructure, (3) performance test framework, or (4) any shared components. The file has no importers in the codebase. No E2E tests need to run for this change.

Performance Test Selection:
The change is in a developer tooling script with no impact on app rendering, data loading, state management, or any user-facing flows. No performance tests are warranted.

View GitHub Actions results

@abretonc7s abretonc7s marked this pull request as ready for review May 8, 2026 06:15
@abretonc7s abretonc7s requested a review from a team as a code owner May 8, 2026 06:15
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.51%. Comparing base (4797726) to head (7e3cbed).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #29895   +/-   ##
=======================================
  Coverage   81.50%   81.51%           
=======================================
  Files        5328     5328           
  Lines      141146   141146           
  Branches    32157    32157           
=======================================
+ Hits       115046   115054    +8     
+ Misses      18239    18231    -8     
  Partials     7861     7861           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@abretonc7s abretonc7s enabled auto-merge May 8, 2026 06:27
@abretonc7s abretonc7s added skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. skip-e2e skip E2E test jobs labels May 8, 2026
@sonarqubecloud

sonarqubecloud Bot commented May 8, 2026

Copy link
Copy Markdown

@abretonc7s abretonc7s added this pull request to the merge queue May 8, 2026
Merged via the queue into main with commit cbb5cf4 May 8, 2026
58 of 60 checks passed
@abretonc7s abretonc7s deleted the fix/agentic-cdp-rn081-targets branch May 8, 2026 14:28
@github-actions github-actions Bot locked and limited conversation to collaborators May 8, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.78.0 Issue or pull request that will be included in release 7.78.0 label May 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.78.0 Issue or pull request that will be included in release 7.78.0 size-S skip-e2e skip E2E test jobs skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants