Encourage browser tab reuse in open tools#306973
Merged
Conversation
Contributor
There was a problem hiding this comment.
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?: booleanparameter 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
forceNewis set), butOpenBrowserToolNonAgenticData.modelDescriptionstill tells the model to "Open a new browser page…" and omits the reuse/forceNewguidance that exists inOpenBrowserToolData. 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);
}
src/vs/workbench/contrib/browserView/electron-browser/tools/openBrowserTool.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/browserView/electron-browser/tools/openBrowserToolNonAgentic.ts
Show resolved
Hide resolved
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @jrualesMatched files:
|
Yoyokrazy
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #306971