Skip to content

fix(browser): scope navigate events by surfaceId#25

Merged
amirlehmam merged 1 commit into
amirlehmam:masterfrom
schroldgames:fix/browser-navigate-scoping
Jun 8, 2026
Merged

fix(browser): scope navigate events by surfaceId#25
amirlehmam merged 1 commit into
amirlehmam:masterfrom
schroldgames:fix/browser-navigate-scoping

Conversation

@schroldgames

Copy link
Copy Markdown
Contributor

Summary

  • All wmux:browser-navigate CustomEvents were broadcasts — every open BrowserPane responded, so the wrong pane would navigate when multiple browser surfaces existed, and dev-server auto-navigate fired on all of them indiscriminately
  • Adds a surfaceId field to the event detail; BrowserPane ignores events that don't target its own id (events with no surfaceId remain broadcasts for back-compat)
  • open-in-browser.ts resolves the target surface's id from the split tree and passes it in both the immediate and deferred navigate dispatches
  • App.tsx auto-navigate on dev-server port detection now passes the workspace's browser surface id instead of an empty string

Files changed

File Change
src/preload/index.ts Forward surfaceId arg through the navigate event detail
src/renderer/components/Browser/BrowserPane.tsx Scope event handler — ignore events targeting a different surface
src/renderer/utils/open-in-browser.ts Resolve browser surfaceId from split tree; pass it in navigate dispatches
src/renderer/App.tsx Pass correct surfaceId on dev-server auto-navigate

Test plan

  • Open two workspaces each with a browser pane — navigating one should not affect the other
  • Trigger dev-server auto-navigate (start a local server on a detected port) — confirm only the active workspace's browser pane navigates
  • wmux browser open <url> from CLI — confirm it targets the correct pane
  • Backwards compat: dispatch wmux:browser-navigate with no surfaceId — confirm it still navigates the first available pane

🤖 Generated with Claude Code

Previously all wmux:browser-navigate events were broadcasts — any open
BrowserPane in any workspace would respond to them. This caused the wrong
pane to navigate when multiple browser surfaces existed, and meant dev-server
auto-navigate fired on every pane indiscriminately.

- Pass surfaceId in the wmux:browser-navigate CustomEvent detail
- BrowserPane handler ignores events whose surfaceId doesn't match its own
  (events with no surfaceId are still treated as broadcasts for back-compat)
- open-in-browser.ts resolves the target browser surface's id and includes
  it in both the immediate and deferred navigate dispatches
- App.tsx auto-navigate on dev-server detection passes the workspace's
  browser surface id instead of an empty string

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@schroldgames schroldgames force-pushed the fix/browser-navigate-scoping branch from 79a374f to a989d40 Compare June 6, 2026 21:53
@amirlehmam amirlehmam merged commit 5347e23 into amirlehmam:master Jun 8, 2026
@amirlehmam

Copy link
Copy Markdown
Owner

Merged and shipped in v0.8.3. Thanks @schroldgames — surface-scoped navigate events pair nicely with the new browser/markdown tab menu (#28).

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