agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

feat(browser): explicit `ao preview` / `ao browser open` should reveal the Browser panel for the session you are viewing

Open AgentWrapper opened this issue 2 months ago • 1 comments

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 when previewUrl/previewRevision changes. If the Browser panel is already visible it clears the badge; otherwise it calls setBrowserUnseen(sessionId, true) and returns. The setInspectorViewForSession(sessionId, "browser") + setInspectorOpenForSession(sessionId, true) pair was removed by PR #4146 (commit 30a7c20f6).
  • The agent-activity effect (around SessionView.tsx:1369) badges on any browserView.agentBrowserActive, so ao browser open is treated identically to a passive snapshot, click, or errors call — 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 carries action and phase, pushed on browser:agentActivity and surfaced by useBrowserView as agentBrowserActivity.
  • The action strings come straight from the CLI: ao browser open sends "open" (backend/internal/cli/browser.go:91) and ao browser tab new sends "tab-new"; every passive command sends its own distinct verb.
  • previewRevision only changes when someone runs ao 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

  1. From the session on screen, ao preview README.md opens the inspector on the Browser tab showing the rendered file, with no unseen badge left behind.
  2. From the session on screen, ao browser open http://localhost:5173 does the same.
  3. A ao preview / ao browser open in a different session badges that session and does not change what the user is looking at.
  4. ao browser snapshot / click / fill / errors on the viewed session while the Browser tab is hidden still only badges — no reveal.
  5. Revealing never steals OS window focus and never changes the routed session or project.
  6. A terminated session's stale previewUrl still reveals nothing (existing hasBrowserContent guard).

Reproduction

  1. Open a session in the desktop app and park the inspector on Summary (or Reviews).
  2. From that session's worker shell, run ao preview README.md.
  3. Observed: the command reports success; the Browser tab shows an unseen dot; the panel stays on Summary.
  4. Expected: the inspector opens on Browser with the rendered README.
  5. 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.

AgentWrapper avatar Sep 08 '26 06:09 AgentWrapper

Assigned to @Vaibhaav-Tiwari

Rishet11 avatar Sep 15 '26 18:09 Rishet11