Skip to content

feat(chat): include page URL context when sending browser elements to copilot chat#298099

Open
stjepko-xyz wants to merge 2 commits intomicrosoft:mainfrom
stjepko-xyz:feat/attach-page-url-to-chat
Open

feat(chat): include page URL context when sending browser elements to copilot chat#298099
stjepko-xyz wants to merge 2 commits intomicrosoft:mainfrom
stjepko-xyz:feat/attach-page-url-to-chat

Conversation

@stjepko-xyz
Copy link

Summary

When using the intergrated browser include the page URL as context when sending browser elements to Copilot Chat, so Copilot knows which route/page the element belongs to. See issue: #298025

Details

  • Add pageUrl field to IElementData and IElementVariableEntry interfaces
  • Retrieve the current page URL via CDP Runtime.evaluate('document.location.href') in getNodeData(), inside the existing enrichment try/catch block
  • Include Page URL: in the context text sent to the model for both Simple Browser and Integrated Browser
  • Add chat.sendElementsToChat.attachURL setting (default: true, tag: preview) to make URL inclusion optional, matching the pattern of attachCSS and attachImages
  • Show a "PAGE URL" section in the element hover tooltip in chat

Results

Screenshot 2026-02-26 at 22 13 18 Screenshot 2026-02-26 at 22 13 32 Screenshot 2026-02-26 at 22 17 15

How to test

  1. Open a website in Simple Browser or Integrated Browser
  2. Click "Add Element to Chat" and select an element
  3. Verify the chat attachment value text includes Page URL: <url>
  4. Hover over the element chip in chat and verify the "PAGE URL" section appears
  5. Disable chat.sendElementsToChat.attachURL in settings, select another element, and verify the URL
    is no longer included

Copilot AI review requested due to automatic review settings February 26, 2026 21:38
@vs-code-engineering
Copy link

vs-code-engineering bot commented Feb 26, 2026

📬 CODENOTIFY

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

@kycutler

Matched files:

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

@jruales

Matched files:

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

Copy link
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

Adds optional page URL context to “Add Element to Chat” so Copilot Chat can better understand which page/route a selected DOM element came from (Simple Browser + Integrated Browser).

Changes:

  • Extends element attachment data structures to carry an optional pageUrl.
  • Captures the current page URL via CDP (Runtime.evaluate) when collecting element node data.
  • Surfaces the URL in the model context text and in the element attachment hover UI; adds a chat.sendElementsToChat.attachURL setting to toggle inclusion.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/vs/workbench/contrib/chat/common/attachments/chatVariableEntries.ts Adds pageUrl?: string to element variable entries.
src/vs/workbench/contrib/chat/browser/chat.contribution.ts Registers new chat.sendElementsToChat.attachURL configuration setting.
src/vs/workbench/contrib/chat/browser/attachments/simpleBrowserEditorOverlay.ts Includes Page URL: line in Simple Browser element context; populates pageUrl on the attachment entry.
src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentWidgets.ts Adds a “PAGE URL” section to the element hover UI and enables rich hover when URL is present.
src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts Includes page URL in Integrated Browser element context and passes through pageUrl on attachments.
src/vs/platform/browserElements/electron-main/nativeBrowserElementsMainService.ts Retrieves page URL during node enrichment and returns it in element data.
src/vs/platform/browserElements/common/browserElements.ts Adds pageUrl?: string to IElementData.

@stjepko-xyz
Copy link
Author

@microsoft-github-policy-service agree

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.

6 participants