Skip to content

Browser: make Playwright per workspace#299055

Merged
kycutler merged 2 commits intomainfrom
kycutler/linguistic-echidna
Mar 4, 2026
Merged

Browser: make Playwright per workspace#299055
kycutler merged 2 commits intomainfrom
kycutler/linguistic-echidna

Conversation

@kycutler
Copy link
Contributor

@kycutler kycutler commented Mar 3, 2026

Fixes #298763

@kycutler kycutler requested review from Copilot and jruales March 3, 2026 20:32
@vs-code-engineering
Copy link

vs-code-engineering bot commented Mar 3, 2026

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts

@deepak1556

Matched files:

  • src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an issue where Playwright-driven integrated browser pages could open in the wrong VS Code workspace window by making the Playwright/browser-view plumbing window-aware end-to-end.

Changes:

  • Send the renderer’s vscodeWindowId to the shared process and create a per-window Playwright service instance.
  • Thread windowId through browser view group creation and CDP target creation so editor-opening IPC targets the intended window.
  • Replace the shared-process Playwright service channel wiring with a custom PlaywrightChannel that scopes instances per IPC connection.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/vs/workbench/services/browserView/electron-browser/playwrightWorkbenchService.ts Initializes the shared-process Playwright channel with the current window id.
src/vs/platform/browserView/node/playwrightService.ts Binds Playwright operations to a specific window via windowId when creating a browser view group.
src/vs/platform/browserView/node/playwrightChannel.ts New per-connection IPC channel that creates/disposes a per-window PlaywrightService.
src/vs/platform/browserView/node/browserViewGroupRemoteService.ts Updates remote group creation to require windowId and forward it to main process.
src/vs/platform/browserView/electron-main/browserViewMainService.ts Opens browser view editors in a specific window (by id) instead of always the focused window.
src/vs/platform/browserView/electron-main/browserViewGroupMainService.ts Requires windowId when creating a new browser view group.
src/vs/platform/browserView/electron-main/browserViewGroup.ts Stores a default windowId for the group and forwards it to target creation.
src/vs/platform/browserView/common/playwrightService.ts Updates the Playwright service interface (brand marker removed in this PR).
src/vs/platform/browserView/common/cdp/types.ts Extends CDP createTarget to optionally accept a windowId.
src/vs/platform/browserView/common/browserViewGroup.ts Updates group service contract to require windowId for group creation.
src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts Registers the new PlaywrightChannel instead of proxying a singleton Playwright service.
Comments suppressed due to low confidence (1)

src/vs/platform/browserView/common/playwrightService.ts:22

  • IPlaywrightService is declared via createDecorator, but the interface no longer includes the standard readonly _serviceBrand: undefined; marker used throughout the codebase to make service types nominal. Consider restoring the _serviceBrand to keep type-safety consistent with other services (e.g. IBrowserViewGroupMainService in src/vs/platform/browserView/electron-main/browserViewGroupMainService.ts).
export const IPlaywrightService = createDecorator<IPlaywrightService>('playwrightService');

/**
 * A service for using Playwright to connect to and automate the integrated browser.
 *
 * Pages must be explicitly tracked via {@link startTrackingPage} (or implicitly via
 * {@link openPage}) before they can be interacted with.
 */
export interface IPlaywrightService {
	/**
	 * Fires when the set of tracked pages changes.
	 * The event value is the full list of currently tracked view IDs.
	 */
	readonly onDidChangeTrackedPages: Event<readonly string[]>;

return source as Event<T>;
}

call<T>(ctx: string, command: string, arg?: unknown): Promise<T> {
Copy link
Contributor

@jruales jruales Mar 4, 2026

Choose a reason for hiding this comment

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

Nit: since an __initialize call is kind of like a constructor, maybe put call method definition before listen method definition in this file

@kycutler kycutler merged commit d356c79 into main Mar 4, 2026
20 checks passed
@kycutler kycutler deleted the kycutler/linguistic-echidna branch March 4, 2026 23:08
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.

Agent opened browser *in another workspace window*

3 participants