feat(browser): explicit `ao preview` / `ao browser open` should reveal the Browser panel for the session you are viewing
Summary
An explicit ao preview <target> or ao browser open <url> from the session the user is currently viewing succeeds, but the Browser panel is not revealed — the inspector only badges the Browser tab as unseen. The user has to notice the badge and click the tab to see the thing they just asked for.
This is current, intentional behavior, not an accidental regression. PR #4146 ("non-disruptive preview reveal") deliberately replaced the force-reveal with a badge, and CLAUDE.md documents it. This issue asks to narrow that rule, not to revert it.
Reported by: @itrytoohard (maintainer), relayed via an AO worker session
Analyzed against: ddf1e54f1
Confidence: High — exact code path traced below.
Current behavior
frontend/src/renderer/components/SessionView.tsx
- The preview-target effect (around
SessionView.tsx:1330) fires whenpreviewUrl/previewRevisionchanges. If the Browser panel is already visible it clears the badge; otherwise it callssetBrowserUnseen(sessionId, true)and returns. ThesetInspectorViewForSession(sessionId, "browser")+setInspectorOpenForSession(sessionId, true)pair was removed by PR #4146 (commit30a7c20f6). - The agent-activity effect (around
SessionView.tsx:1369) badges on anybrowserView.agentBrowserActive, soao browser openis treated identically to a passivesnapshot,click, orerrorscall — badge only, never reveal.
Net effect: the two commands whose entire purpose is "show me this page" are the ones that don't show it.
Why PR #4146 was right, and what it over-corrected
PR #4146's rationale — quoted from its own code comment — is that a new preview target used to "force-switch the inspector to the Browser tab and pop it open, even if the user was looking at something else entirely (Reviews, a different session's Files tab, mid-typing in chat)."
The genuinely disruptive case there is a background session grabbing the foreground. That is worth preventing and must stay prevented. But the fix was applied to all preview targets, including one the user is staring at right now, having just asked for it. Since SessionView is mounted only for the routed session (routes/_shell.projects.$projectId_.sessions.$sessionId.tsx), "the session whose SessionView is mounted" is already exactly "the session the user is viewing" — the disruptive cross-session case and the wanted same-session case are separable with information the renderer already has.
Requested behavior
| Trigger | Session being viewed | Other session |
|---|---|---|
ao preview <target> (new preview target) |
Reveal Browser panel | Badge only (unchanged) |
ao browser open <url>, ao browser tab new |
Reveal Browser panel | Badge only (unchanged) |
ao browser snapshot / click / fill / act / errors / … |
Badge only (unchanged) | Badge only (unchanged) |
| No browser content / terminated session | No badge (unchanged) | No badge (unchanged) |
Revealing means: open the inspector and switch it to the Browser tab for that session. It does not mean raising the OS window, changing the routed session, or changing projects — a background worker must never pull the user's navigation to itself.
Intent contract — already present, no API change needed
The renderer can already tell explicit-open from passive inspection:
BrowserAgentActivityState(frontend/src/main/browser-view-host.ts:110) already carriesactionandphase, pushed onbrowser:agentActivityand surfaced byuseBrowserViewasagentBrowserActivity.- The action strings come straight from the CLI:
ao browser opensends"open"(backend/internal/cli/browser.go:91) andao browser tab newsends"tab-new"; every passive command sends its own distinct verb. previewRevisiononly changes when someone runsao preview, so a preview-key change is inherently explicit.
So this needs no daemon route, no OpenAPI change, and no contract regeneration — it is a renderer-side policy change over signals the main process already emits.
Acceptance criteria
- From the session on screen,
ao preview README.mdopens the inspector on the Browser tab showing the rendered file, with no unseen badge left behind. - From the session on screen,
ao browser open http://localhost:5173does the same. - A
ao preview/ao browser openin a different session badges that session and does not change what the user is looking at. ao browser snapshot/click/fill/errorson the viewed session while the Browser tab is hidden still only badges — no reveal.- Revealing never steals OS window focus and never changes the routed session or project.
- A terminated session's stale
previewUrlstill reveals nothing (existinghasBrowserContentguard).
Reproduction
- Open a session in the desktop app and park the inspector on Summary (or Reviews).
- From that session's worker shell, run
ao preview README.md. - Observed: the command reports success; the Browser tab shows an unseen dot; the panel stays on Summary.
- Expected: the inspector opens on Browser with the rendered README.
- Repeat with
ao browser open http://localhost:5173— same observed result.
Related
- PR #4146 — introduced the current badge-only behavior (the behavior this issue narrows).
- PR #3359 — the earlier "open first browser content automatically and badge background activity" split this builds on.
- #2809 — agents opening the OS browser instead of the AO in-app preview; same "the preview must actually be seen" goal.
Docs
CLAUDE.md currently instructs agents that ao preview "does not steal focus or force the Browser tab open" and to tell the user to check the Browser tab. That guidance needs updating alongside the behavior change.
Assigned to @Vaibhaav-Tiwari