Skip to content

Integrated Browser: Fix buggy Right Click -> Copy into New Window#288207

Merged
jruales merged 8 commits intomainfrom
jruales/integrated-browser-copy-new-window
Jan 20, 2026
Merged

Integrated Browser: Fix buggy Right Click -> Copy into New Window#288207
jruales merged 8 commits intomainfrom
jruales/integrated-browser-copy-new-window

Conversation

@jruales
Copy link
Copy Markdown
Contributor

@jruales jruales commented Jan 16, 2026

Fixes #284525
(Copy into New Window was very buggy. Not to be confused with Move into New Window, which has been working fine.)

This PR does the following:

  • Creates an independent browser editor to avoid linked state
  • Adds a resize observer to fix some issues where sometimes the copied window ended up with a zero-size webview or where a moved window ended up with a squashed webview until the user resized the window

Related feature: #286579

Copilot AI review requested due to automatic review settings January 16, 2026 01:31
Copy link
Copy Markdown
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

This pull request adds support for copying integrated browser editors into new windows. The main change is implementing the copy() method in BrowserEditorInput to create independent browser view instances with new unique IDs. Additionally, the PR refactors the view initialization logic in BrowserEditor to use a ResizeObserver for handling window layout changes, replacing the previous scheduleAtNextAnimationFrame approach.

Changes:

  • Implemented copy() method in BrowserEditorInput to create new browser instances with unique IDs when copying to new windows
  • Replaced animation frame scheduling with ResizeObserver for more reliable layout handling during window moves/resizes
  • Added layoutAsync() helper method to ensure proper view attachment before operations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/vs/workbench/contrib/browserView/electron-browser/browserEditorInput.ts Added copy() method to create independent browser editor instances with new UUIDs and injected IInstantiationService
src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts Refactored initialization to use ResizeObserver for layout handling and added layoutAsync() method; removed unused scheduleAtNextAnimationFrame import
Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts:725

  • The layout() and layoutAsync() methods contain duplicated logic for calculating and passing layout parameters. Consider refactoring to extract the common layout logic into a shared helper method that both methods can call, with only the async/await handling differing between them.
	override layout(): void {
		void this.layoutAsync();
	}

	/**
	 * Async version of layout that waits for the layout to complete.
	 */
	private async layoutAsync(): Promise<void> {
		if (this._model) {
			this.checkOverlays();

			const containerRect = this._browserContainer.getBoundingClientRect();
			await this._model.layout({
				windowId: this.group.windowId,
				x: containerRect.left,
				y: containerRect.top,
				width: containerRect.width,
				height: containerRect.height,
				zoomFactor: getZoomFactor(this.window)
			});
		}
	}

	override clearInput(): void {
		this._inputDisposables.clear();

		// Cancel any active element selection
		if (this._elementSelectionCts) {
			this._elementSelectionCts.dispose(true);
			this._elementSelectionCts = undefined;
		}

		void this._model?.setVisible(false);
		this._model = undefined;

		this._canGoBackContext.reset();

@jruales jruales changed the title Integrated Browser: Support Copy into New Window Integrated Browser: Support Right Click -> Copy into New Window Jan 16, 2026
@jruales jruales marked this pull request as ready for review January 16, 2026 01:51
@jruales jruales requested a review from kycutler January 16, 2026 01:51
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 16, 2026
@jruales jruales requested a review from Copilot January 16, 2026 01:53
Copy link
Copy Markdown
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

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

Comment thread src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts Outdated
Comment thread src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts Outdated
@jruales jruales changed the title Integrated Browser: Support Right Click -> Copy into New Window Integrated Browser: Fix buggy Right Click -> Copy into New Window Jan 16, 2026
Comment thread src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts Outdated
@jruales jruales enabled auto-merge (squash) January 20, 2026 18:40
@jruales jruales merged commit 653e4d8 into main Jan 20, 2026
22 checks passed
@jruales jruales deleted the jruales/integrated-browser-copy-new-window branch January 20, 2026 19:01
@jruales jruales added browser-integration Web browsing features integrated into VS Code (e.g. integrated browser) and removed browser-integration Web browsing features integrated into VS Code (e.g. integrated browser) labels Jan 26, 2026
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrated Browser: unexpected behavior with "Copy into New Window"

3 participants