Skip to content

feat(extension): introduce BrowserModel with explicit handshake#40411

Merged
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:feat-extension-browser-model
Apr 24, 2026
Merged

feat(extension): introduce BrowserModel with explicit handshake#40411
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:feat-extension-browser-model

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented Apr 24, 2026

Summary

  • v2 relay-side BrowserModel: new abstraction (browserModel.ts) owns the tab map and translates between chrome.* and CDP dialects. ExtensionProtocolV2 becomes a thin demuxer.
  • Explicit handshake: Target.setAutoAttach no longer blocks on the user's tab pick. Instead the extension pushes chrome.tabs.onCreated for the selected tab (or none) followed by extension.initialized; establishExtensionConnection waits for this before returning, so CDP traffic always meets a populated model.
  • V2 deferred WS: the relay WebSocket is only opened once the user clicks Allow. If the user rejects or closes the connect tab, the daemon keeps waiting — intentional, v1 keeps its eager behavior.
  • Typed sink lifecycle: handlers now get a sendToCDPClient via connectOverCDP() only after ready() resolves; before that they're silent by construction.
  • Thread chrome.tabs.Tab end-to-end from the connect page to ConnectedTabGroup.attachTab; drop TabInfo and the chrome.tabs.get round-trip.

- Replace the blocking `extension.selectTab` command with an `extension.initialized` event pushed by the extension after reporting initial tabs via `chrome.tabs.onCreated`.
- Add `BrowserModel` abstraction that owns the tab map and translates between chrome.* dialect and CDP dialect on the relay side.
- Gate Playwright CDP traffic on `handler.ready()`: `establishExtensionConnection` awaits the handshake before `connectOverCDP` is called, so `Target.setAutoAttach` is answered from a populated model.
- Thread `chrome.tabs.Tab` objects end-to-end from the connect page through to `ConnectedTabGroup.attachTab`, eliminating `TabInfo` and `chrome.tabs.get` round-trips.
- Handlers now get a `sendToCDPClient` sink via `connectOverCDP` only after ready, and `onExtensionDisconnect` aborts a pending `ready()` when the user rejects or closes the connect tab.
@yury-s yury-s merged commit 16a3c2f into microsoft:main Apr 24, 2026
8 of 10 checks passed
@yury-s yury-s deleted the feat-extension-browser-model branch April 24, 2026 19:00
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

8 failed
❌ [firefox] › mcp/cli-devtools.spec.ts:141 › video-start-stop @mcp-windows-latest
❌ [firefox] › mcp/cli-devtools.spec.ts:155 › video-chapter @mcp-windows-latest
❌ [firefox] › mcp/cli-session.spec.ts:142 › session reopen with different config @mcp-windows-latest
❌ [firefox] › mcp/http.spec.ts:103 › http transport browser lifecycle (isolated) @mcp-windows-latest
❌ [firefox] › mcp/http.spec.ts:142 › http transport browser sigint @mcp-windows-latest
❌ [msedge] › mcp/dashboard.spec.ts:185 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest
❌ [msedge] › mcp/dashboard.spec.ts:207 › should enter annotate mode on fresh dashboard.tsx mount with -s --annotate @mcp-windows-latest
❌ [msedge] › mcp/dashboard.spec.ts:231 › should switch screencast to -s session on show --annotate @mcp-windows-latest

6669 passed, 928 skipped


Merge workflow run.

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.

2 participants