Enhance WebPageLoader for markdown content extraction#320146
Draft
karthiknadig wants to merge 3 commits into
Draft
Enhance WebPageLoader for markdown content extraction#320146karthiknadig wants to merge 3 commits into
karthiknadig wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the WebPageLoader (Electron main process) to prefer text/markdown during HTTP content negotiation and to treat text/markdown main-frame responses as directly-extractable content, with accompanying unit test updates.
Changes:
- Add
Acceptheader formainFramerequests to prefertext/markdownovertext/html. - Detect
text/markdownresponses and switch extraction to a simplified “document text content” path. - Extend/adjust unit tests to cover the new request/response behavior.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/webContentExtractor/electron-main/webPageLoader.ts | Adds markdown-preferred negotiation + markdown response detection/extraction path. |
| src/vs/platform/webContentExtractor/test/electron-main/webPageLoader.test.ts | Updates header-modification tests and adds markdown negotiation/extraction tests. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/platform/webContentExtractor/test/electron-main/webPageLoader.test.ts:1026
- The simulated sub-resource request omits
resourceType, but Electron provides a concrete non-main-frame value for these (e.g.stylesheet). Passing an explicit non-mainFrametype makes the test more realistic and avoids the test depending onresourceTypebeing missing.
// Simulate a sub-resource request (no resourceType)
callback(
{
url: 'https://example.com/style.css',
requestHeaders: {
'TestHeader': 'TestValue'
}
},
- Files reviewed: 2/2 changed files
- Comments generated: 3
Comment on lines
+197
to
+201
| // Detect markdown responses for direct extraction without DOM rendering | ||
| if (details.resourceType === 'mainFrame' && contentType?.split(';')[0].trim() === 'text/markdown') { | ||
| this._receivedMarkdown = true; | ||
| this.trace(`Received text/markdown response, will extract raw content`); | ||
| } |
Comment on lines
+446
to
+451
| // If the server returned text/markdown, extract the raw body directly | ||
| // without DOM-based extraction — the content is already in the ideal format. | ||
| if (this._receivedMarkdown) { | ||
| this.trace(`Extracting raw markdown content from response body`); | ||
| result = await this._window.webContents.executeJavaScript('document.body?.innerText ?? document.documentElement?.textContent ?? ""') ?? ''; | ||
| return; |
| const uri = URI.parse('https://learn.microsoft.com/en-us/docs'); | ||
|
|
||
| const loader = createWebPageLoader(uri); | ||
| setupDebuggerMock(); |
Contributor
jruales
previously approved these changes
Jun 5, 2026
- Reset _receivedMarkdown on every mainFrame response instead of latching - Use textContent instead of innerText to avoid forced layout - Strengthen test with long AX content to ensure markdown branch is exercised
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.


Implement support for extracting markdown content from web pages by modifying the WebPageLoader to prefer markdown responses during content negotiation. Update tests to verify the new functionality and ensure proper handling of markdown content types.