fix(desktop): agent browser opens show in the right pane, even when away
SA
7d ago+192+192+012345678901234567890123456789-82-82-01234567890123456789
What & why
When an agent opened a browser while the right pane was closed, the browser never appeared (reported by Kiet). Background browser opens (browser.onOpenRequest with show: false, handled in useBrowserOpenRequests → openBackgroundBrowser) wrote the browser into the center layout. moveViewerPanesToRight then moved it to the right pane, and nothing opened the right pane. That happened whether the workspace was on screen or not.
Now the open writes the right state directly:
- The browser goes straight into
rightPaneLayoutas the active tab, andrightSidebarOpenis set totrue, in one row update. If you are in another workspace, the right pane is open on the new browser when you come back. - When the workspace is on screen in this window, the browser is added to the live right store instead (found through the slot-aware registry from #9204), without keyboard focus, so the new tab becomes active there too. The row-to-store sync keeps each window's own active tab, so a row write alone would not have switched to it.
- Why not reuse #9204's
open browserop: it always adds a new tab. The browser bridge's default target iscurrent-tab, which reuses the agent's unpinned browser, so with the op everysuperset browser openwould pile up a new tab. This uses the right store's own placement (placeInTabs) instead. - The background browser's saved state (URL, title...) is written to whichever layout holds the pane. Before, it only searched
paneLayout, so it lost track of the pane once it was moved right. createPaneLayoutStoreis shared byuseV2WorkspacePaneLayoutand the background open, so both build right-pane stores the same way (getPaneKey,placeInTabs).openUrlInV2Workspacetakes an optionalpaneIdandfocus. The background open sets the pane id upfront instead of reading back the active pane.
This replaces an earlier idea of a hook that opens the sidebar whenever a pane appears in the right store: that only works while the workspace is on screen.
How I tested it
openBackgroundBrowser.test.ts, rewritten:- the browser becomes the active right pane tab;
- the center layout and other workspaces are unchanged;
rightSidebarOpenis set;current-tabreplaces the unpinned right-pane browser, never a pinned one;- successive opens give distinct panes;
- a mounted right store gets the pane live with no
focusRequest.
bun run typecheckinapps/desktop,bun run lint, and the full desktopbun test(8,871 pass, 0 fail). Rebased on main after #9204: typecheck, lint and the renderer route suites (1,458 pass) re-run.- Not verified in the running app. I have not driven it over CDP (agent opens a browser with the right pane closed, on screen and away).
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (CI fails on lint warnings too) - "Allow edits from maintainers" is checked on fork PRs
- I have signed the CLA (the bot asks on your first PR)
Summary by CodeRabbit
- New Features
- Background browser requests now open in the workspace’s right sidebar. New-tab requests activate a browser tab there, while current-tab requests replace an unpinned browser tab and preserve pinned tabs.
- Bug Fixes
- Opening a background browser no longer changes the center layout or another workspace. Repeated requests create separate tabs, and browser tabs opened in an already-mounted sidebar update without taking keyboard focus.