Skip to content

Encourage browser tab reuse in open tools#306973

Merged
kycutler merged 1 commit intomainfrom
kycutler/reusetabs
Mar 31, 2026
Merged

Encourage browser tab reuse in open tools#306973
kycutler merged 1 commit intomainfrom
kycutler/reusetabs

Conversation

@kycutler
Copy link
Copy Markdown
Contributor

Closes #306971

Copilot AI review requested due to automatic review settings March 31, 2026 23:18
@kycutler kycutler self-assigned this Mar 31, 2026
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 PR addresses tab-spam from browser tools by encouraging reuse of an already-open integrated browser page (by host) instead of always opening a new one.

Changes:

  • Adds a forceNew?: boolean parameter to the open-browser tool schema to allow explicitly opening a new page.
  • Implements “reuse existing page by host” behavior for both agentic (OpenBrowserTool) and non-agentic (OpenBrowserToolNonAgentic) open flows.
  • Centralizes the reuse detection + “already open” tool result formatting in browserToolHelpers.ts.

Reviewed changes

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

File Description
src/vs/workbench/contrib/browserView/electron-browser/tools/openBrowserTool.ts Adds forceNew param and reuses an existing tracked page with the same host when possible.
src/vs/workbench/contrib/browserView/electron-browser/tools/openBrowserToolNonAgentic.ts Applies the same reuse behavior for the non-agentic open tool.
src/vs/workbench/contrib/browserView/electron-browser/tools/browserToolHelpers.ts Introduces shared helper to find an existing page by host and return an “already open” result.
Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/browserView/electron-browser/tools/openBrowserToolNonAgentic.ts:58

  • This tool now prefers reusing an existing page by default (unless forceNew is set), but OpenBrowserToolNonAgenticData.modelDescription still tells the model to "Open a new browser page…" and omits the reuse/forceNew guidance that exists in OpenBrowserToolData. Updating the non-agentic tool's model description to reflect the new default behavior will better align with the PR goal (discouraging tab spam) and reduce unnecessary calls that immediately return "already open".
		if (!params.forceNew) {
			const existing = await findExistingPageByHost(this.editorService, undefined, params.url);
			if (existing) {
				return alreadyOpenResult(existing);
			}

@kycutler kycutler marked this pull request as ready for review March 31, 2026 23:28
@kycutler kycutler enabled auto-merge (squash) March 31, 2026 23:29
@vs-code-engineering
Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

@jruales

Matched files:

  • src/vs/workbench/contrib/browserView/electron-browser/tools/browserToolHelpers.ts
  • src/vs/workbench/contrib/browserView/electron-browser/tools/openBrowserTool.ts
  • src/vs/workbench/contrib/browserView/electron-browser/tools/openBrowserToolNonAgentic.ts

@kycutler kycutler merged commit e52f1d1 into main Mar 31, 2026
22 checks passed
@kycutler kycutler deleted the kycutler/reusetabs branch March 31, 2026 23:37
@vs-code-engineering vs-code-engineering bot added this to the 1.115.0 milestone Mar 31, 2026
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.

Discourage agents from opening new tabs when there are others to use

3 participants