← Back to PRs

#21314: feat: enhance browser relay with custom naming and diagnostic tools

by kelvinCB open 2026-02-19 22:13 View on GitHub →
cli agents size: M
Multi-device browser relay support (Relay Naming) This PR enables addressing browser commands to specific devices when multiple relays are connected to the same Gateway. Previously, the Gateway only supported one Chrome extension connection at a time, leading to command collisions and 409 errors when connecting multiple devices. Key changes: - Chrome extension UI: Added a "Relay name" field in the options page. The name is persisted and sent to the Gateway during the WebSocket handshake. - Gateway relay server: Refactored to support multiple concurrent connections. CDP command routing now identifies which device owns each sessionId or targetId. - CLI: Added a global --relay <name> flag to all browser commands. - Diagnostics: New 'openclaw browser extension check' command to validate connectivity and list all connected devices. I have tested this locally with my Mac and PC connected simultaneously, and the targeting works correctly. Testing degree: Fully tested locally with multi-device setup. AI assistance: This PR was developed with AI assistance (Etiven). I have reviewed and understand all changes. <!-- greptile_comment --> <h3>Greptile Summary</h3> Enables multi-device browser relay support by allowing multiple Chrome extension connections with distinct names to the Gateway relay server. Previously limited to single extension connections, causing command collisions (409 errors) when multiple devices connected. **Key changes:** - Extension UI adds "Relay name" field (`assets/chrome-extension/options.html`, `options.js`, `background.js`) - Relay name sent during WebSocket handshake via `?name=` query parameter - Gateway refactored from single `extensionWs` to `Map<string, ExtensionConnection>` tracking multiple connections - CDP command routing maps `sessionId`/`targetId` to owning connection via `ConnectedTarget.connectionId` - CLI gains global `--relay <name>` flag for targeting specific devices - New `openclaw browser extension check` command lists connected devices - `/json/list` prefixes tab titles with `[relay-name]` for identification - Tab filtering in `server-context.ts` uses relay name prefix when specified **Test impact:** - One test skipped (`it.skip`) due to refactoring (`src/browser/extension-relay.test.ts:215`) - Unrelated agent test fixes for OpenAI transcript policy handling <h3>Confidence Score: 3/5</h3> - This PR is moderately safe to merge with one critical bug that needs fixing - Score reflects well-structured multi-device support implementation with comprehensive changes across extension, server, and CLI. However, there's a critical logic error in the duplicate name check (line 585 of `extension-relay.ts` checks Map key instead of connection name values), which would allow multiple devices to connect with the same relay name despite the validation attempt. Additionally, one test was skipped without explanation. The core functionality appears sound but the name collision prevention is broken. - Pay close attention to `src/browser/extension-relay.ts` line 585 - the duplicate name check is broken and needs immediate correction before merge <sub>Last reviewed commit: ffa6b3e</sub> <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs