Skip to content

fix(desktop): agent browser opens show in the right pane, even when away - #9047

Open
saddlepaddle wants to merge 1 commit into
mainfrom
superset/auto-open-sidebar-on-new-tab-pane-8a556750
Open

saddlepaddle wants to merge 1 commit into
mainfrom
superset/auto-open-sidebar-on-new-tab-pane-8a556750

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

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 rightPaneLayout as the active tab, and rightSidebarOpen is set to true, 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 feat(cli): let agents drive the right sidebar with superset panes #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 feat(cli): let agents drive the right sidebar with superset panes #9204's open browser op: it always adds a new tab. The browser bridge's default target is current-tab, which reuses the agent's unpinned browser, so with the op every superset browser open would 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.
  • createPaneLayoutStore is shared by useV2WorkspacePaneLayout and the background open, so both build right-pane stores the same way (getPaneKey, placeInTabs).
  • openUrlInV2Workspace takes an optional paneId and focus. 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;
    • rightSidebarOpen is set;
    • current-tab replaces 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 typecheck in apps/desktop, bun run lint, and the full desktop bun test (8,871 pass, 0 fail). Rebased on main after feat(cli): let agents drive the right sidebar with superset panes #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 lint and bun run typecheck pass (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.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 419ddc86-d67f-4f17-bc06-5fc4a1122650
Commits

Reviewing files that changed from the base of the PR and between 9d4a80a and 847031c.

Files selected for processing: 2
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2WorkspacePaneLayout/useV2WorkspacePaneLayout.ts
  • apps/desktop/src/renderer/routes/_authenticated/components/GlobalBrowserLifecycle/hooks/useBrowserOpenRequests/utils/openBackgroundBrowser/openBackgroundBrowser.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

Background browser requests now open in the workspace’s right pane. The flow assigns pane IDs, disables focus, handles mounted and unmounted right-pane stores, and persists unmounted layout state. Pane-layout store construction now uses a slot-aware factory, and browser state updates inspect tabs in both layouts.

Changes: Right-pane browser opening

Layer / File(s) Summary
Register and create slot-specific pane stores
apps/desktop/src/renderer/routes/.../useV2WorkspacePaneLayout/...
The workspace hook now creates pane stores through a slot-aware factory. The factory configures pane placement for the rightPaneLayout slot.
Open background browsers in the right pane
apps/desktop/src/renderer/routes/.../openUrlInV2Workspace.ts, apps/desktop/src/renderer/routes/.../useBrowserOpenRequests.ts, apps/desktop/src/renderer/routes/.../openBackgroundBrowser/*
The open flow supplies a pane ID and disables focus. It uses a mounted right-pane store when available; otherwise, it creates and persists the right-pane layout and selection. Browser state updates now inspect tabs in both pane layouts. Tests cover new-tab opening, current-tab replacement, distinct pane IDs, and the mounted-store path.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant useBrowserOpenRequests
  participant openBackgroundBrowser
  participant openUrlInV2Workspace
  participant rightPaneStore
  participant collections
  participant rightSidebar
  useBrowserOpenRequests->>openBackgroundBrowser: background browser request
  openBackgroundBrowser->>openUrlInV2Workspace: URL, paneId, focus false
  openUrlInV2Workspace->>rightPaneStore: addTab or openPane
  alt right-pane store is mounted
    openBackgroundBrowser->>rightSidebar: open sidebar
  else right-pane store is unmounted
    openBackgroundBrowser->>collections: persist rightPaneLayout and selection
    openBackgroundBrowser->>rightSidebar: open sidebar
  end
Loading

Suggested reviewers: kitenite

Merge Risk: Minimal · up to 84703

Background browser opens move to the right pane; no merge-blocking risk was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the main change: agent browser opens from the background now show the browser in the right pane. The title is in conventional commit format and matches the changeset, which routes back…
Description check Passed The description follows the template. It has a 'What & why' section that explains the bug, the cause, and the fix, and it references related PR #9204. It has a 'How I tested it' section that lists the…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: agent browser opens from the background now show the browser in the right pane. The title is in conventional commit format and matches the changeset, which routes background browser opens to rightPaneLayout and sets rightSidebarOpen. The title does not mention the live-store update or the helper refactor, which is expected for a short title.

Full details: Description check

Explanation

The description follows the template. It has a 'What & why' section that explains the bug, the cause, and the fix, and it references related PR #9204. It has a 'How I tested it' section that lists the unit test coverage, the typecheck, lint, and test runs, and a clear note that the change was not verified in the running app. The checklist is present. Two checklist items are unchecked: the fork-maintainer edit item, which may not apply, and the CLA item, which the author has not confirmed. The template also asks for screenshots for user-visible bug fixes, and none are included. The description does not link an issue number, though the template asks for one when available.

Resolution

Optional: add screenshots or a CDP capture of the before and after behavior, since the template asks for them on user-visible bug fixes. Optional: link a tracking issue if one exists. Confirm the CLA and fork-maintainer checklist items, or mark them as not applicable.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 7 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Background browser opens now select a browser in the right pane and open the sidebar, including when the user is in another workspace.

  • Background browser opens appear in the workspace’s right pane.

No actionable issues were found. Review evidence came from code inspection; the running desktop app was not tested.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Background browser request] --> B{Right store mounted?}
  B -->|Yes| C[Open browser in live right store]
  C --> D[Hook saves right layout]
  C --> E[Open right sidebar]
  B -->|No| F[Build right store from saved layout]
  F --> G[Save right layout and open sidebar together]
  E --> H[Start browser runtime]
  G --> H
  H --> I[Save browser state in its layout]
Loading

Reviews (1) · Last reviewed commit: "fix(desktop): agent browser opens show i..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) ✅ View Branch
Vercel API (Vercel) ✅ Open Preview
Vercel Web (Vercel) ✅ Open Preview
Vercel Marketing (Vercel) ✅ Open Preview
Vercel Docs (Vercel) ✅ Open Preview

Preview updates automatically with new commits

A browser that an agent opened in the background was written into the
center layout. moveViewerPanesToRight then moved it to the right pane,
and nothing opened the right pane, so it never appeared.

Write it straight into rightPaneLayout as the active tab and set
rightSidebarOpen in the same update. When the workspace is mounted in
this window, apply it to the live right store instead, without keyboard
focus, so the new tab becomes active there too. The background
browser's state is saved into whichever layout holds the pane.

This branch was previously deployed

1 inactive deployment
preview — 847031c8 Deployed Nov 1, 2026 by saddlepaddle via Deploy Web #13525
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