Skip to content

fix(desktop-browser): ask the user before a page's alert, confirm, or leave-site prompt is answered - #8432

Open
waleedlatif1 wants to merge 3 commits into
stagingfrom
fix/browser-page-dialogs
Open

waleedlatif1 wants to merge 3 commits into
stagingfrom
fix/browser-page-dialogs

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • A page's alert and confirm on the user's own page now wait for the user in a Sim modal (titled with the page's host), instead of being answered instantly — a site's "Delete this?" no longer silently cancels. The user is only asked when the page is on screen and is theirs: the agent's page (not taken over), a hidden panel, or another chat's browser keep the shell answering, so there is no new friction for work the user did not start
  • Agent actions keep the shell answering dialogs (the requested answer, or dismissal), so the agent never blocks; hidden tabs are answered as before; an agent action on a tab with an unanswered dialog dismisses it first
  • Leaving a page that guards unsaved work (beforeunload) from browser chrome — URL bar, Back/Forward, Reload, reload shortcuts — now asks "Leave site?": Stay keeps the page and its draft, Leave replays the navigation once. Electron decides an unload in two places (will-prevent-unload and the CDP dialog), so both consult one claimUserLeave decision
  • Compatible across versions: the shell keeps answering dialogs itself until the renderer sends enable-page-dialogs, and older shells ignore that action
  • A strip-mirrored tab switch (claim: false) now leaves the new page unclaimed instead of inheriting the previous page's claim, matching switchTab's documented intent
  • New BrowserPageState.dialog and respond-dialog / enable-page-dialogs panel actions in @sim/browser-protocol
  • Tab-close prompts and in-page link navigations keep today's behavior (not in scope here)

Type of Change

  • Bug fix

Testing

  • New apps/desktop/e2e/browser-page-dialogs.spec.ts (Playwright _electron, JSON check report to DESKTOP_BROWSER_DIALOGS_REPORT_PATH): shell still answers without the renderer opt-in; the user's confirm waits and their answer reaches the page; agent clicks (with and without a requested answer) never wait on the user; leaving a draft from the URL bar asks and Stay keeps it; Leave navigates without asking twice; the agent's unclaimed page and an off-screen panel stay automatic. Fails on staging at the user-confirm check, passes on this branch (3/3 repeats); removing the agent-ownership guard turns the agent check red
  • browser-focus.spec.ts still passes on this build
  • vitest desktop (875) and sim browser suites (196), type-check both apps, bun run lint, check-block-registry, bun run check:audits, docs-manifest:check

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 30, 2026 1:33am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/desktop/src/main/browser-agent/session.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds user-facing dialogs for page alerts and navigation confirmations.

The PR appears safe to merge; no outstanding finding or new PR-caused issue was established.

Summary

The PR lets the desktop browser ask the user about dialogs on their visible, claimed page while retaining automatic answers for agent work and pages the user cannot see. It also adds a leave-site decision for browser-chrome navigation and regression coverage for those paths.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Page opens dialog] --> B{Visible user-owned page?}
  B -- No --> C[Shell answers automatically]
  B -- Yes --> D{Beforeunload?}
  D -- No --> E[Show alert or confirm in Sim]
  D -- Yes --> F[Show Leave site decision]
  F -- Stay --> G[Keep page and draft]
  F -- Leave --> H[Replay navigation once]
Loading

Reviews (4) · Last reviewed commit: "fix(desktop-browser): label frame dialog..."

Comment thread apps/desktop/src/main/browser-agent/session.ts Outdated
Comment thread apps/desktop/e2e/browser-page-dialogs.spec.ts
Comment thread apps/desktop/src/main/browser-agent/session.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

Comment thread apps/desktop/src/main/browser-agent/session.ts
Comment thread apps/desktop/src/main/browser-agent/session.ts Outdated
Comment thread apps/desktop/e2e/browser-page-dialogs.spec.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/desktop/src/main/browser-agent/session.ts

This branch was previously deployed

1 inactive deployment
Preview — ce07a73a Deployed Sep 30, 2026 by vercel[bot]
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