Skip to content

Fix React Native auto-selection for duplicate debugger targets#14

Open
V3RON wants to merge 1 commit intomasterfrom
fix/react-native-target-dedupe
Open

Fix React Native auto-selection for duplicate debugger targets#14
V3RON wants to merge 1 commit intomasterfrom
fix/react-native-target-dedupe

Conversation

@V3RON
Copy link
Copy Markdown
Contributor

@V3RON V3RON commented May 6, 2026

Summary

Users connecting to React Native through Metro now get a single effective target when Metro exposes duplicate entries for the same device and app, and agent-cdp auto-selects the newest one. This prevents the common failure mode where the tool attaches to an older page like ...-1 instead of the active debugger page like ...-2.

Backward compatibility

Existing Chrome target discovery is unchanged. Existing React Native discovery remains compatible for unique targets; this only collapses duplicate React Native entries whose ids match the <logicalDeviceId>-<number> pattern and share the same discovery source, app id, and logical device id. Daemon lifecycle, CLI commands, output format, and target id format remain unchanged.

Risks

React Native target lists that intentionally rely on multiple pages for the same app and logical device could now show only the newest matching entry. This is limited to duplicate-style ids from Metro and does not affect non-matching React Native ids or Chrome targets.

Manual testing

  1. Start Metro with a React Native app that exposes duplicate inspector targets for the same logical device, such as ...-1 and ...-2.
  2. Run agent-cdp target list --url http://127.0.0.1:8081 and verify only the newest matching React Native target is shown.
  3. Clear any existing selection with agent-cdp target clear, then run a command that auto-selects a target, such as agent-cdp console list.
  4. Verify agent-cdp attaches to the newest React Native target instead of failing or attaching to the stale entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant