Skip to content

Match subdomains when checking for existing browser pages#311084

Merged
kycutler merged 1 commit intomainfrom
kycutler/subdomainreuse
Apr 17, 2026
Merged

Match subdomains when checking for existing browser pages#311084
kycutler merged 1 commit intomainfrom
kycutler/subdomainreuse

Conversation

@kycutler
Copy link
Copy Markdown
Contributor

Fixes #306971

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 19:55
@kycutler kycutler self-assigned this Apr 17, 2026
@kycutler kycutler enabled auto-merge (squash) April 17, 2026 19:55
@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

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 updates the integrated browser tab reuse heuristic so that “already open” detection considers subdomain relationships, helping discourage agents from repeatedly opening new tabs when a relevant page is already available.

Changes:

  • Extend existing-page detection to treat parent-domain/subdomain pairs as matches (e.g. example.comwww.example.com).
  • Return those subdomain-matching editors in the “already open” tool result.
Show a summary per file
File Description
src/vs/workbench/contrib/browserView/electron-browser/tools/browserToolHelpers.ts Adds subdomain-based matching when finding existing browser pages by host.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines +180 to +186
// Check for subdomain matches
if (
editorUrl?.host && parsed.host &&
(
editorUrl.host.endsWith('.' + parsed.host) ||
parsed.host.endsWith('.' + editorUrl.host)
)
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

The subdomain comparison uses host, which typically includes the port. This can cause subdomain matching to fail when either URL has an explicit port (e.g. www.example.com:443 vs example.com), and also makes the suffix check slightly less semantically correct than comparing hostnames. Consider using parsed.hostname/editorUrl.hostname for the subdomain logic (while keeping the existing exact host equality check for hostname+port matching).

Copilot uses AI. Check for mistakes.
@kycutler kycutler merged commit 78f1999 into main Apr 17, 2026
30 checks passed
@kycutler kycutler deleted the kycutler/subdomainreuse branch April 17, 2026 21:13
@vs-code-engineering vs-code-engineering Bot added this to the 1.117.0 milestone Apr 17, 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