fix(web): keep agent browser preview visible #9484
main fromrefs/pull/9484/head·merged by maria-rcks View on GitHubAgent-driven browser operations only surfaced the floating preview when creating a tab, and docking that tab permanently discarded the display intent. This keeps the intent across reused operations and right-panel transitions, while respecting explicit hide requests and the user's auto-show preference. Verified with 135 focused tests, web and contracts typechecks, focused lint and formatting, and a production web build. Built with gpt-5.6-sol in T3 Code through the Codex harness.
Note
Medium Risk Changes Electron webview layering and preview automation presentation rules (auto-show/suppression), which affects visible UI and agent workflows but not auth or data handling.
Overview Fixes agent browser preview visibility when the same tab is docked in the right panel or reused by later automation calls, with correct stacking against the compact right-panel sheet.
Floating preview vs right panel: The mini-player store is no longer closed when the matching preview is shown in the right panel; shouldRenderPreviewMiniPlayer hides the floating UI instead so intent survives panel transitions. The right-panel sheet can render under an overlapping mini-player via underFloatingPreview and a dedicated z-[35] layer on backdrop/viewport.
Stacking: Browser surface presentation now carries zIndex (default 30) from BrowserSurfaceSlot through the surface store into hosted webview wrapper styles; the mini player uses PREVIEW_MINI_PLAYER_WEBVIEW_Z_INDEX (48) with adjusted chrome layers.
Automation: Non-open operations can auto-open the floating preview when browserAutoShowFloatingPreview is on, unless the tab was explicitly suppressed by a prior open/show: false. Suppression is tracked per thread/runtime tab in PreviewAutomationHosts. Settings/contracts copy now describes auto-show when an agent uses a browser, not only on open.
Note: BrowserSurfacePresentation now requires zIndex on in-tree consumers.
Note
Keep agent browser preview visible across right panel and automation use#
- Adds z-index to
BrowserSurfacePresentationso hosted webviews use the surface's requested layer instead of a fixed default, andBrowserSurfaceSlotpublishes z-index on lease and layer change - Reworks mini-player visibility in
ChatViewContent:shouldRenderPreviewMiniPlayerhides the floating preview only when the same tab renders in the right panel, preserving the mini-player store entry so it reappears when the panel changes - Adds
shouldAutoShowPreviewForAutomationUseandexplicitlySuppressesPreviewMiniPlayerso non-open automation operations auto-show the mini-player for an existing tab when the preference is enabled, while explicit background requests suppress and close it - Splits
ThreadPreviewMiniPlayerinto shell, webview, and control layers, and adds a lower layer class forRightPanelSheetwhen it overlaps a floating preview - Updates the auto-show setting description and documentation to cover agent reuse of an existing preview
- Risk:
browserSurfaceStore.presentnow includes z-index in the no-op comparison; callers that previously relied on a no-op presentation when only the layer changed will now trigger a state update
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/preview/PreviewAutomationHosts.tsx line 316OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -311,3 +313,4 @@311313 );312314 const [automationConnectionAtom] = useState(() => Atom.make<string | null>(null));313315 const automationConnectionId = useAtomValue(automationConnectionAtom);316+ const presentationSuppressedTabsRef = useRef(new Map<string, Set<string>>());
🟡 Medium
preview/PreviewAutomationHosts.tsx:316An explicit hide for
tab_1persists across a server restart and suppresses auto-show for the new server's unrelatedtab_1, so subsequentnavigate/interaction requests leave the preview hidden despite the user's enabled preference.presentationSuppressedTabsRefkeys only bythreadIdand process-localtabId, while tab ids restart fromtab_1; store and compare the server-scoped runtime identity (includingserverEpoch, such asactiveRuntimeTabId) instead.🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/preview/PreviewAutomationHosts.tsx around line 316: An explicit hide for `tab_1` persists across a server restart and suppresses auto-show for the new server's unrelated `tab_1`, so subsequent `navigate`/interaction requests leave the preview hidden despite the user's enabled preference. `presentationSuppressedTabsRef` keys only by `threadId` and process-local `tabId`, while tab ids restart from `tab_1`; store and compare the server-scoped runtime identity (including `serverEpoch`, such as `activeRuntimeTabId`) instead.Note
Written by
gpt-5.6-solon behalf of MariaFixed in 533421dd46. Suppression now uses the runtime tab identity, which includes the environment, thread, server epoch, and process-local tab id, so a restarted server cannot inherit an older tab suppression. The focused test set (204 tests), web/contracts typechecks, formatting, and focused lint pass locally.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — The PR changes default-enabled automation behavior so browser operations beyond opening a tab can surface a floating preview, while coordinating stacking across the hosted webview, mini-player, and right-panel sheet. Its stateful suppression logic and changes to shared browser and Sheet infrastructure make the runtime impact broader than a small isolated UI fix.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).maria-rcks merged this12e8997
maria-rcks closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed