-
Notifications
You must be signed in to change notification settings - Fork 5
Fix truncated URLs in web search results opening broken links #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
When web search results are collapsed, URLs were being truncated for display but the truncated text was also used as the href. Now URLs that would be cut by truncation are converted to markdown links that preserve the full URL in the href while showing truncated display text. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughReplaces ad-hoc 150-character truncation in UnifiedChat tool output previews with a new helper Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryFixed broken links in collapsed web search results by implementing smart truncation that preserves full URLs. When truncation would cut a plain URL, the function now converts it to a markdown link with truncated display text but full href, ensuring clicks navigate to the correct destination.
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant UnifiedChat
participant Markdown Utils
participant Markdown Component
User->>UnifiedChat: View tool output (web search results)
UnifiedChat->>UnifiedChat: Check if output > 150 chars
alt Output needs truncation
UnifiedChat->>Markdown Utils: truncateMarkdownPreservingLinks(output, 150)
Markdown Utils->>Markdown Utils: Precompute markdown link ranges
Markdown Utils->>Markdown Utils: Find plain URLs not in markdown
alt Truncation point in plain URL
Markdown Utils->>Markdown Utils: Convert URL to markdown link [truncated...](full-url)
Markdown Utils-->>UnifiedChat: Return markdown with preserved href
else Truncation point in markdown link
Markdown Utils->>Markdown Utils: Truncate before markdown link
Markdown Utils-->>UnifiedChat: Return truncated text + "..."
else Safe truncation
Markdown Utils->>Markdown Utils: Truncate at maxLength
Markdown Utils-->>UnifiedChat: Return truncated text + "..."
end
UnifiedChat->>Markdown Component: Render preview with preserved links
Markdown Component-->>User: Display truncated text with clickable full URL
else Output fits in preview
UnifiedChat->>Markdown Component: Render full output
Markdown Component-->>User: Display full text
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
This checks for both incomplete markdown links and URLs in the href portion. Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Deploying maple with
|
| Latest commit: |
e511237
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e01a9004.maple-ca8.pages.dev |
| Branch Preview URL: | https://linkfix.maple-ca8.pages.dev |
Greptile's behavior is changing!From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
|
|
||
| // Helper function to truncate text while preserving clickable links | ||
| // Converts plain URLs that would be truncated into markdown links with full href but truncated display | ||
| function truncateMarkdownPreservingLinks(text: string, maxLength: number): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should move to a utility file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed code review feedback: moved truncateMarkdownPreservingLinks function from UnifiedChat.tsx to a dedicated utility file at frontend/src/utils/markdown.ts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks. Please rebase into a single commit since this is a tiny change and only needs to be one commit.
Move the truncateMarkdownPreservingLinks function from UnifiedChat.tsx to a dedicated utils/markdown.ts file per code review feedback. Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@frontend/src/utils/markdown.ts`:
- Around line 10-43: Precompute all markdown link ranges by iterating
mdLinkRegex (/\[([^\]]*)\]\(([^)]+)\)/g) first and collect their start/end
indices, then when scanning plain URLs with urlRegex use those ranges to skip
any URL match whose index falls inside an existing markdown link (instead of
current brittle isInMarkdownLink heuristic); also reuse the same markdown link
ranges when checking truncation (so when maxLength falls inside a markdown link
range you truncate before the whole link as you do now), and ensure the urls
array only contains plain-URL matches that are not inside any md link range.
Replace brittle isInMarkdownLink heuristic with proper range-based detection: precompute all markdown link ranges first, then use those ranges to filter plain URLs and check truncation points. Co-Authored-By: Claude Opus 4.5 <[email protected]>
When web search results are collapsed, URLs were being truncated for display but the truncated text was also used as the href. Now URLs that would be cut by truncation are converted to markdown links that preserve the full URL in the href while showing truncated display text.
Fixes #387
Summary by CodeRabbit
Bug Fixes
Notes
✏️ Tip: You can customize this high-level summary in your review settings.