Match subdomains when checking for existing browser pages#311084
Match subdomains when checking for existing browser pages#311084
Conversation
Co-authored-by: Copilot <copilot@github.com>
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @jrualesMatched files:
|
There was a problem hiding this comment.
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.com↔www.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
| // Check for subdomain matches | ||
| if ( | ||
| editorUrl?.host && parsed.host && | ||
| ( | ||
| editorUrl.host.endsWith('.' + parsed.host) || | ||
| parsed.host.endsWith('.' + editorUrl.host) | ||
| ) |
There was a problem hiding this comment.
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).
Fixes #306971