Skip to content

fix(browser): carry agent_driven on OpenTab across cold start, retry, promote, and 3P plugins - #306

Merged
Hona merged 3 commits into
devfrom
ws1-fix4-agent-driven
Nov 20, 2026
Merged

Hona merged 3 commits into
devfrom
ws1-fix4-agent-driven

Conversation

@Hona

@Hona Hona commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes notes/review-rd-engine.md Finding 4 (agent_driven Loss Across Cold Start, Crash+Retry, promote_open, Reconnect, and Third-Party Plugins) and all 3 Round-1 READER-9 findings (091d1cd9), reconciled with origin/dev 5da64743 (#294 + #274).

Merge Reconciliation (origin/dev 5da64743, #294 + #274)

  • apps/browser-engine/src/wire.rs (HostMsg::OpenTab): kept #274's 4 extension fields (isolated, allow_extension_pages, is_popup, ext_open_request_id) alongside agent_driven.
  • apps/browser-engine/src/engine.rs (open_tab, HostMsg::OpenTab, Linux ReopenTabs, HostMsg::SetAgentDriven): enforced let allow_ext = allow_extension_pages && !isolated && !agent_driven;, delegated HostMsg::SetAgentDriven to handle_set_agent_driven, passed was_agent directly in Linux ReopenTabs, kept engine.rs at 1,489 / 1,500 lines.
  • apps/browser-engine/src/engine/extensions.rs: updated handle_set_agent_driven (Ordering::Release + snap.agent_driven = agent_driven + allowed_ext_ids.clear() + ext.set_tab_agent_driven), updated notify_ext_tab_opened to call ext.set_tab_agent_driven(tab_id, true) atomically on cold-start agent_driven tabs before running effects, updated unmanaged extension open_tab call site and open_seed_probe TabSnapshot (agent_driven: false).
  • apps/desktop/src/surfaces/browser/mod.rs: kept #294's is_safe_local_workspace_root.

Round-1 READER-9 Findings Closed

  1. All third-party plugin tab-driving methods mark the tab controlled first (apps/desktop/src/plugin_host/native/browser/{scope.rs, browser.rs, chrome.rs}):
    • TabScope::driver verifies bundled Tier::Bundled "browser" identity so third-party plugins (and non-bundled overrides) get TabDriver::Plugin(display_name) while MCP tools get TabDriver::Agent.
    • Every tab-driving Luau method marks the tab controlled before mutating: Browser:OpenAsync, BrowserTab:DevtoolsAsync, Navigate, Back, Forward, Reload, Stop, ReloadIgnoreCache, Find, StopFinding, Inspect, Highlight, SetZoom, SetViewport, Show, ClearSiteAsync, ClearCacheAsync.
  2. Honest driver attribution + blocked sign-in / file picker UI notice with 1-click way out (crates/browser-pane/src/prompts/{mod,host}.rs, apps/desktop/src/surfaces/browser/prompts/view.rs, crates/opencode-i18n/locales/rune/en.json):
    • Added TabDriver::{Agent, Plugin(String)} (sanitized, capped at 64 chars) inherited across pop-ups and context-menu opens.
    • Permission bar now says "The plugin {{name}} is controlling this tab. Your answer applies this one time." for plugin-driven tabs vs "The agent is working in this tab. Your answer applies this one time." for agents.
    • AuthAgentRequired, FileChooserBlocked, and older-engine app-cancelled AuthRequest set blocked_guard_notice = true (cleared on document navigation or dismiss), rendering a one-line notice bar naming the plugin or agent, explaining sign-in prompts and file pickers are off, and offering an "Open in new tab" button (opens a clean human tab at the same URL preserving isolation context/proxy).
    • 4 new i18n keys (crates/opencode-i18n/locales/rune/en.json): rune.browser.prompt.controlled.agent, rune.browser.prompt.controlled.openNewTab, rune.browser.prompt.controlled.plugin, rune.browser.prompt.perm.plugin.
  3. Three ordering / race holes closed:
    • start_preview tab reuse (apps/desktop/src/surfaces/browser/rpc/exec/nav.rs:353): calls set_agent_driven(hid, true) before navigate_browser_tab.
    • Older-engine AuthRequest (crates/browser-pane/src/prompts/host.rs:249): when t.prompts.agent_driven is true, cancels immediately (HostMsg::AnswerAuth { username: None, password: None }), sets agent_auth_required + blocked_guard_notice, and never pops an HTTP auth modal.
    • Cold-start early flip (crates/browser-pane/src/client.rs:852-886) sends HostMsg::SetAgentDriven immediately before Navigate; context-menu "open-link" / "open-image" (apps/desktop/src/surfaces/browser/context_menu.rs) merges live tab.prompts.agent_driven / driver at click time.

(Zero tests added/edited; zero .github/ edits; zero new third-party crates.)

Verification (All 5 Targets + Live Proofs)

  • Previous head (091d1cd9) CI: 6/6 pass (build-macos, build-windows (arm64/x64), guardrails, plan, publish-pr-build).
  • Guardrails: 5/5 passed (engine.rs 1,489/1,500; client.rs 1,469/1,500; 376 i18n keys).
  • Windows: apps/browser-engine --bins, cargo check --workspace, cargo build -p opencode-desktop, cargo check -p browser-pane --no-default-features — clean (0 warnings).
  • wasm32 (scripts/web.ps1 -Check): clean (0 warnings; 1,041 files, no std::time).
  • Linux (adais, x86_64-unknown-linux-gnu, type-checked only): --workspace --all-targets clean (47 s) + apps/browser-engine --bins clean (engine-linux-exit=0).
  • macOS (air, aarch64-apple-darwin, under mac-lock-as.py): --workspace clean (8 s, air_free: 67.3 GiB).
  • Live CEF 156 + Desktop proofs (proof/ws1/fix4-agent-driven.md, proof/ws1/fix4-plugin-notice.png, OPENCODE_RUNE_OTEL=0, scratch profiles):
    • prove-fix4-agent-driven.ts: cold-start HTTP 401 -> AuthAgentRequired (anyAuthPrompt: false), cold-start <input type="file"> -> FileChooserBlocked, #274 invariant (agent_driven: true + allow_extension_pages: true chrome-extension:// -> refused), human tab flipped before Navigate(/auth) -> AuthAgentRequired, reconnect TabList preserves agent_driven: true on all 4 tabs.
    • prove-fix4-desktop.ts: real opencode-desktop.exe + scratch 3P plugin "Demo Helper" + fake older-engine socket proved Finding 1 (set_agent_driven before navigate on human tab), Finding 2 (honest plugin notice bar + "Open in new tab" + honest permission bar, zero false "The agent is working in this tab"), and Finding 3 (older-engine AuthRequest auto-cancelled, zero auth modal).
    • #292 regression proofs rerun on merged head (prove-fix1-v2.ts + prove-fix1-r4.ts): ALL PASS.

Held non-draft awaiting READER-9 second read before merge (do not self-merge).

Hona added a commit that referenced this pull request Nov 20, 2026
- Fold security-confirmed merged PRs #292 (6d7a6ed, WS-1 mandatory
  RemoteServer proxy), #294 (ae3e910, BROWSER-UI file-link/click-to-run
  fix with known symlink/junction root limitation), and #274 (5da6474,
  WS-9 engine MV3 extension host, inert without --extension flags)
- Update browser Reviewed column: #301 in rework (#287 eager-attach
  time_updated regression still live on dev), #296/#298/#302/#303/#305/#306
  in rework, #307 open for pre-merge security review
- Audit upstream anomalyco/opencode fe8def6854..4122af0206 (+2 commits:
  1 skipped #65255 core/codemode, 1 added UP-135 #65215 -> WS-8)
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

… UI, controlled notice bar, and close ordering races
@Hona
Hona merged commit b5167f7 into dev Nov 20, 2026
7 checks passed
@Hona
Hona deleted the ws1-fix4-agent-driven branch November 20, 2026 20:32
Hona added a commit that referenced this pull request Nov 20, 2026
Hona added a commit that referenced this pull request Nov 20, 2026
…ven across previews and unconditional file:// ban
Hona added a commit that referenced this pull request Nov 20, 2026
…P-143 (#318)

- Fold confirmed merged PRs #307 (a1e7d0d, click-to-load reply videos),
  #306 (b5167f7, atomic agent_driven), #301 (6522f11, routed-session
  attach + recency closing #287 regression), #296 (95cb36a, legacy
  rune_mcp suppression + Half::is_builtin + check_cdp), #303 (6fb05ce,
  oc-preview:// app routing + raw file:// ban completing UP-095-PREVIEWS),
  and #316 (6e98fc2, Rune 7a707454 / #1307 strict local video opening)
- Add missing browser follow-up rows UP-095-3P-CONTRACT (#296 narrow
  third-party plugin browser contract gap) and UP-095-PROMPT-GATE
  (new-session-start-only prompt gate split from #302)
- Record #302 split (tunnel vs gate), #314 masking stream paused pending
  owner decision on agent-tab contexts, and updated browser Reviewed entries
- Audit upstream anomalyco/opencode 4122af0206..b9a60d9d07 (+11 commits:
  3 skipped, 8 added UP-136..UP-143)
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