Skip to content

feat(extension): coordinate browser execution across panels - #5694

Open
iscekic wants to merge 9 commits into
browser-task-0787-s7from
browser-task-0787-s8
Open

feat(extension): coordinate browser execution across panels#5694
iscekic wants to merge 9 commits into
browser-task-0787-s7from
browser-task-0787-s8

Conversation

@iscekic

@iscekic iscekic commented Aug 29, 2026

Copy link
Copy Markdown
Contributor
  • Chat and workflow settings explain when browser control is blocked and show the controlling session when available.
  • Blocked messages stay in the draft. Blocked queued messages wait for “Resume queued message” instead of restarting automatically.
  • Blocked workflows keep entered values and leave the parameter form open. “Resume workflow” lets you retry a retained request from chat.
  • Cancelling a workflow form or closing its settings prevents a delayed run. Closing a conversation also cancels submissions that have not started.
  • Changing or closing a target tab while submission waits preserves the input instead of silently choosing another tab. Started runs keep their target and stop if it closes.
  • If the browser cannot confirm an action’s result, it blocks further browser work and shows recovery instructions. These require closing affected tabs, or every target tab when the affected set is unknown.
  • Unsupported browsers explain why command-line browser work is unavailable and keep ordinary local work available until recovery is required.

Summary

BrowserExecutionCoordinator separates PROVIDER_OWNER_LOCK from BROWSER_EXECUTION_LOCK; BrowserAdmission grants shared local or exclusive delegated BrowserExecutionLease values, rejecting local requests behind delegated owners or waiters. BrowserLockStorage stores safetySchema under BROWSER_EXECUTION_SAFETY_KEY and ownerSchema under OWNER_KEY; missing safety records default empty, uncertainty or storage errors block execution, and BrowserExecutionSnapshot reports display-only ownership. BrowserRecovery needs Web Locks, drained actions, and closed affected tabs; unsupported browsers permit local work but persist uncertainty as allTabs, requiring all target tabs closed.

Files
  • apps/extension/entrypoints/sidepanel/browser-execution-lock.ts — Source, added, 509 changed lines. Adds origin-scoped coordination, authenticated-session ownership labels, cancellable delegated admission, and lease release after runners and awaited actions finish. Storage watchers and 500 ms polling report native occupancy; sanitized owner records never authorize work. Serializes native quarantine writes, retains failed leases for coordinator-owned recovery retries, and preserves allTabs through reloads and restored support. Recovery never steals an active execution lock or waits behind one.
  • apps/extension/entrypoints/sidepanel/browser-execution-lock.test.ts — Test, added, 701 changed lines. Adds coordinator regression coverage for shared local execution, exclusive delegation, waiter cancellation, quarantine persistence, unsupported contexts, and explicit recovery.

BrowserRunContext carries credentials, settings, approvals, and callbacks; callers must supply ExecutionGuard, a lease, and a fixed tab with allowTabFallback: false. runBrowserTurn and runBrowserWorkflow reuse existing runners and return LlmTurnOutcome or BrowserWorkflowOutcome; local callers resolve fallback first, while delegated callers supply approved tabs. effectsUncertain persists quarantine before result conversion or another model turn; toolResults excludes unconfirmed actions, and target-tab closure aborts execution.

Files
  • apps/extension/entrypoints/sidepanel/browser-run-context.ts — Source, added, 234 changed lines. Extracts existing safe and dangerous runner setup and workflow and remote Model Context Protocol (MCP) adapters without adding another agent. Keeps gateway credentials separate from remote fetch and shares one lease across workflows, actions, and recursive continuation. A transient WeakMap transfers workflow reservations without changing the existing request shape or persisting a lease.

AgentChatPanel acquires BrowserAdmission before clearing drafts, draining queued messages, or consuming workflows, then rechecks conversation activity and model availability. Blocked input requires explicit resubmission or resume; a changed or closed target cannot redirect a pending submission. Stop, conversation closure or deletion, history replacement, and unmount cancel pending admission; workflow execution and model continuation retain one lease until awaited work ends.

Files
  • apps/extension/entrypoints/sidepanel/agent-chat-panel.tsx — Source, modified, 894 changed lines. Routes chat and direct workflows through the guarded context, snapshots targets before admission, checks actual tab existence, and preserves edits made during admission. Adds current blocker feedback, explicit queue and workflow resume controls, and reservation cleanup; uncertain workflow results stop before any model continuation. Workflow requests now use the panel’s Jotai store consistently; legacy requests without a reserved lease acquire admission before execution.
  • apps/extension/entrypoints/sidepanel/agent-chat-panel.test.ts — Test, modified, 1,282 changed lines. Expands regression coverage for admission races, retained input, fixed tabs, cancellation, local concurrency, workflow uncertainty, and release after awaited work ends.

WorkflowRow.onRun now accepts an AbortSignal and returns Promise<boolean>; the new blocker prop keeps rejection feedback above the parameter form. Settings uses reserveWorkflowLease and chat uses takeWorkflowLease to share admission without changing WorkflowRunRequest or workflowRunRequestAtom. Cancelled or unmounted forms cannot publish delayed requests; failed admission retains parameters, and pending workflows reject duplicate submissions.

Files
  • apps/extension/entrypoints/sidepanel/workflow-settings.tsx — Source, modified, 91 changed lines. Acquires admission before publishing a request or closing Settings, preserves the initiating conversation, rejects replacement of pending requests, and releases unused leases. Displays current ownership, quarantine, and unsupported-browser messages instead of retaining an old owner claim.
  • apps/extension/entrypoints/sidepanel/workflow-row.tsx — Source, modified, 69 changed lines. Awaits admission before dismissing the parameter form, prevents duplicate submissions, and aborts pending submissions on Cancel or unmount. Shows blocker feedback above the open form.
  • apps/extension/entrypoints/sidepanel/workflow-settings.test.tsx — Test, modified, 364 changed lines. Expands Settings and parameter-form coverage for retained values, cancellation, lease transfer, pending requests, and ownership feedback.

An abstract syntax tree (AST) inventory rejects unguarded runner imports, calls, aliases, element access, and direct browser dispatch outside approved adapters. New callers use runBrowserTurn or runBrowserWorkflow; only executeEvalToolCall(event) and the read-only sendTabDebuggerRequest retain named legacy exceptions with removal conditions. Admission-order checks and mutation fixtures protect the boundary; runtime guards and native browser verification remain necessary for model-authored JavaScript and scheduling.

Files
  • apps/extension/entrypoints/sidepanel/browser-action-boundary.test.ts — Test, added, 504 changed lines. Adds table-driven chat, queue, Settings, workflow, and continuation checks, plus alias, direct-dispatch, and static injected-code mutation fixtures. Inventories fixed injected helpers and permits later provider callers through the guarded public run interface without expanding the adapter exceptions.

Tests: 4 files changed—agent-chat-panel.test.ts, browser-action-boundary.test.ts, browser-execution-lock.test.ts, and workflow-settings.test.tsx—with 2,851 changed lines. The handoff records 4/4 passing checks: focused Vitest, formatting, type-aware lint/type checking, and git diff --check.
Generated: 0 files changed.


Verification

Manual browser and visual verification did not run. This slice limits local verification to changed-file checks and unit tests; native multi-panel proof remains assigned to level 13.

Visual Changes

Visual Changes: N/A

Reviewer Notes

This level adds coordination infrastructure only; it does not enable the complete browser provider. Approvals, persistence integration, provider execution, and supervision controls are outside this level.

Human steps

  • before merge: Complete the section’s gates, including native Chrome, Firefox, real CLI, and local relay verification.
  • before merge: Merge lower stack levels before this level.
  • after merge: Merge higher stack levels in order.
  • after merge, if recovery is required: Close affected target tabs before requesting explicit recovery.
  • after merge, if allTabs is set: Close every target tab before requesting explicit recovery.
  • after merge, if Web Locks are unavailable: Restore native Web Locks support before recovery. Restart the browser context after restoring support.
  • after merge, if safety storage fails: Restore storage access before requesting recovery.

This level requires no new environment values, secrets, database migrations, or manual data conversion.

Notes

Live browser verification is pending. Native Chrome and Firefox behavior, the real CLI, and the local relay remain required before human-ready.

Stacked PRs — merge bottom to top. Each level shows only its own diff.

Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.

  1. browser-task-0787feat(browser-task): define negotiated job contracts #5638
  2. browser-task-0787-s2feat(session-ingest): persist owned browser jobs #5644
  3. browser-task-0787-s3feat(session-ingest): route fenced browser providers #5648
  4. browser-task-0787-s4feat(cloud-agent-sdk): support browser provider jobs #5653
  5. browser-task-0787-s7fix(extension): expose honest browser runner outcomes #5681
  6. browser-task-0787-s8feat(extension): coordinate browser execution across panels #5694 ← this PR
  7. browser-task-0787-s9fix(extension): invalidate ended browser task approvals #5698
  8. browser-task-0787-s10feat(extension): persist browser jobs and profile consent #5702 (tip)

@kilo-code-bot

kilo-code-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (9 files)
  • apps/extension/entrypoints/sidepanel/agent-chat-panel.test.ts
  • apps/extension/entrypoints/sidepanel/agent-chat-panel.tsx
  • apps/extension/entrypoints/sidepanel/browser-action-boundary.test.ts
  • apps/extension/entrypoints/sidepanel/browser-execution-lock.test.ts
  • apps/extension/entrypoints/sidepanel/browser-execution-lock.ts
  • apps/extension/entrypoints/sidepanel/browser-run-context.ts
  • apps/extension/entrypoints/sidepanel/workflow-row.tsx
  • apps/extension/entrypoints/sidepanel/workflow-settings.test.tsx
  • apps/extension/entrypoints/sidepanel/workflow-settings.tsx

Reviewed by grok-4.6 · Input: 384.6K · Output: 31.6K · Cached: 796.3K

Review guidance: REVIEW.md from base branch browser-task-0787-s7

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