Skip to content

Preserve browser popup state across IPC handoff - #335987

Draft
Dmitriy Vasyura (dmitrivMS) wants to merge 9 commits into
mainfrom
agents/browser-reliability-fix-smoke-popup
Draft

Dmitriy Vasyura (dmitrivMS) wants to merge 9 commits into
mainfrom
agents/browser-reliability-fix-smoke-popup

Conversation

@dmitrivMS

@dmitrivMS Dmitriy Vasyura (dmitrivMS) commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes a race where a popup finishes loading before the workbench subscribes to its events, leaving the tab's title or loading state stale (smoke failure).

  • Reconcile state after subscribing with a lightweight, versioned navigation snapshot.
  • Prevent out-of-order events and stale favicon fetches from overwriting newer state.
  • Preserve editor identity and native-page/editor closure coupling.

Initial navigation and ERR_ABORTED handling are unchanged.

Validation

  • Regression coverage for delayed handoff, snapshot/event ordering, favicon races, and editor lifecycle.
  • Windows Code OSS: build, 221 browser unit tests, 24 API/CDP/tool tests (2 existing skips), and 7 integrated-browser smoke tests passed.
  • Native negative controls confirm the intended fixes. Full lifecycle and cross-platform stress qualification remain pending.

Fixes #320443.

Reconcile native navigation state after dynamic event subscription and reject stale snapshots or already-included events. Preserve newer per-field updates, editor identity, and closure coupling, with deterministic model and production workbench/IPC coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 12, 2026 22:23

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Async favicon completion can still overwrite newer navigation state, and reconciliation adds avoidable heavyweight IPC and screenshot work.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 1 High severity · 2 Medium severity

Open findings (3)
What changed in this PR

This PR adds versioned browser navigation-state reconciliation across the main-process/renderer IPC boundary to recover popup state missed before subscription.

Changes:

  • Versions navigation, title, loading, favicon events, and snapshots.
  • Reconciles model state after event subscriptions while preserving editor lifecycle.
  • Adds deterministic model and workbench regression coverage.
File Description
browserAutoReloadFeatures.test.ts Versions mock navigation events.
browserViewWorkbenchService.test.ts Tests popup handoff through IPC/workbench layers.
browserViewModel.test.ts Updates model test state fixtures.
browserEditorInput.test.ts Updates navigation event fixture.
browserViewModelState.test.ts Tests snapshot/event ordering and closure.
browserView.test.ts Updates browser model fixtures.
browserViewWorkbenchService.ts Makes input disposal handling one-shot.
browserView.ts (workbench) Adds per-field reconciliation and local events.
browserView.ts (electron-main) Versions authoritative browser state updates.
browserView.ts (platform) Extends browser state/event contracts with versions.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/platform/browserView/electron-main/browserView.ts Outdated
Comment thread src/vs/workbench/contrib/browserView/common/browserView.ts Outdated
Comment thread src/vs/workbench/contrib/browserView/common/browserView.ts Outdated
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added vscode-build VS Code build process issues engineering VS Code - Build / issue tracking / etc. labels Sep 12, 2026
Guard asynchronous favicon application against newer requests and navigation. Use navigation-only snapshots and suppress unchanged loading notifications from snapshots while preserving native events. Add deterministic regressions for the review feedback on #335987.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Cross-host redirects can still retain or publish stale favicon state despite navigation invalidation.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

Open findings (1)
Resolved findings (3)

Comment thread src/vs/platform/browserView/electron-main/browserView.ts Outdated
Use the pending navigation URL for redirect chains and invalidate favicon work before clearing authoritative state. Cover snapshots, history, late completions, same-host and subframe redirects, and rejected navigations through actual BrowserView handlers with an injectable native view factory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Access main-process Electron APIs through its default export so BrowserView can be dynamically imported by the renderer unit runner with its injected native view. Reproduce the CI ESM linking failure and validate all 47 targeted tests with native ESM loading instead of CommonJS bundling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Programmatic cross-host navigation can retain stale favicons, and title-only reconciliation emits false navigation events.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 2 Medium severity

Open findings (2)
Resolved findings (1)

Comment thread src/vs/platform/browserView/electron-main/browserView.ts
Comment thread src/vs/workbench/contrib/browserView/common/browserView.ts Outdated
Comment thread src/vs/platform/browserView/electron-main/browserView.ts
Comment thread src/vs/platform/browserView/electron-main/browserView.ts
Preserve pending favicon work for diverted previews and clear authoritative state for accepted programmatic navigation. Publish silently changed icons after commit without rewriting the old history entry. Reconcile title and favicon snapshots without synthetic navigation, while clearing restored label fallbacks. Cover Electron event order and real native-to-model delivery with deterministic ESM regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve the committed favicon across provisional navigation and restore it when an uncommitted load stops, without reviving stale favicon requests. Complete registered cleanup when Electron has already cleared a closed view's WebContents.

Add 13 regressions for abort ordering, model synchronization, and native/editor/window disposal.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Provisional favicon completions can still corrupt committed history or overwrite state after terminal navigation failure.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 2 High severity

Open findings (2)
Resolved findings (2)

Comment thread src/vs/platform/browserView/electron-main/browserView.ts Outdated
Comment thread src/vs/platform/browserView/electron-main/browserView.ts
@github-actions

github-actions Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Base: 3e8601c5 Current: 9c461f74

No screenshot changes.

Defer favicon history updates until navigation commits, including replacement entries and same-document updates during a pending load. Invalidate pending favicon requests and clear provisional icons on non-aborted main-frame failures.

Add 14 regressions for commit, abort, history replacement, subframes, and failure/completion ordering. Addresses the additional favicon review feedback on #335987.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@saitanallensantiago26-beep

Summary

Fixes a race where a popup finishes loading before the workbench subscribes to its events, leaving the tab's title or loading state stale (smoke failure).

  • Reconcile state after subscribing with a lightweight, versioned navigation snapshot.
  • Prevent out-of-order events and stale favicon fetches from overwriting newer state.
  • Preserve editor identity and native-page/editor closure coupling.

Initial navigation and ERR_ABORTED handling are unchanged.

Validation

  • Regression coverage for delayed handoff, snapshot/event ordering, favicon races, and editor lifecycle.
  • Windows Code OSS: build, 221 browser unit tests, 24 API/CDP/tool tests (2 existing skips), and 7 integrated-browser smoke tests passed.
  • Native negative controls confirm the intended fixes. Full lifecycle and cross-platform stress qualification remain pending.

@dmitrivMS Dmitriy Vasyura (dmitrivMS) added browser-integration Web browsing features integrated into VS Code (e.g. integrated browser) and removed simple-browser labels Sep 13, 2026
@dmitrivMS Dmitriy Vasyura (dmitrivMS) changed the title browser: preserve popup state across IPC handoff Preserve browser popup state across IPC handoff Sep 13, 2026
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added this to the 1.139.0 milestone Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

browser-integration Web browsing features integrated into VS Code (e.g. integrated browser) engineering VS Code - Build / issue tracking / etc. vscode-build VS Code build process issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Error] unhandlederror-Cannot read properties of undefined (reading 'isDestroyed')

3 participants