fix: restore URL content fetching for @url context menu mentions#11858
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: restore URL content fetching for @url context menu mentions#11858roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
When users paste a URL via the @url context menu option, the URL content is now actually fetched using axios+cheerio instead of just inserting a quoted reference. This was broken after the browser feature was removed. - Add fetchUrlContent utility using axios for HTTP and cheerio for HTML text extraction - Add URL mention handling in parseMentions() to fetch and include content as a MentionContentBlock - Add comprehensive tests for both the utility and integration Closes #11856
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.
Related GitHub Issue
Closes: #11856
Description
This PR attempts to address Issue #11856 where the
@urlcontext menu option ("Paste URL to fetch contents") was not actually fetching any URL content. After the browser feature was removed, URL mentions inparseMentions()were only replaced with a quoted string reference without fetching the actual page content.Changes:
New
fetchUrlContentutility (src/core/mentions/fetchUrlContent.ts): Usesaxiosfor HTTP requests andcheeriofor HTML text extraction. Strips scripts, styles, nav, footer, and other non-content elements, preferring<main>/<article>content. Handles non-HTML content types (plain text, JSON) as raw text. Includes timeout, redirect limits, and content length truncation.Updated
parseMentions()(src/core/mentions/index.ts): Added URL mention handling in the mention processing loop. URL content is now fetched and included as aMentionContentBlockwith type"url", consistent with how file/folder mentions work. Error handling provides informative messages when fetch fails.Updated text replacement: URL mentions now show "(see below for fetched content)" to indicate content will follow, matching the pattern used by other mention types.
No new dependencies were added --
axiosandcheerioare already inpackage.json.Feedback and guidance are welcome.
Test Procedure
fetchUrlContent.spec.tscovering: HTML extraction, non-HTML content, JSON handling, content truncation, error propagation, body fallback, and missing content-type.index.spec.tscovering: text replacement, content block generation, error handling, and truncation indication.Run tests:
Pre-Submission Checklist
Documentation Updates
Additional Notes
The implementation uses a lightweight approach with
axios+cheeriofor URL content extraction instead of the previously removed browser/puppeteer-based approach. This avoids the complexity and resource overhead of a headless browser while still providing useful page content for most websites. JavaScript-rendered content will not be captured, but static HTML content (which covers most documentation, articles, and reference pages) will work correctly.Interactively review PR in Roo Code Cloud