Skip to content

Conversation

@xyOz-dev
Copy link
Contributor

@xyOz-dev xyOz-dev commented Jun 18, 2025

Related GitHub Issue

Closes #4705

Description

Fixed RegEx to filter common link appendages

Test Procedure

See closed issue.

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.

Important

Fixes URL parsing in MarkdownBlock.tsx by removing trailing punctuation from links.

  • Bug Fix:
    • In MarkdownBlock.tsx, updated regex in remarkUrlToLink to remove trailing punctuation from URLs, ensuring correct link formation.
    • Handles common link appendages like periods, commas, semicolons, colons, exclamation marks, question marks, and quotes.

This description was created by Ellipsis for 6798836. You can customize this summary. It will automatically update as commits are pushed.

@xyOz-dev xyOz-dev requested review from cte, jr and mrubens as code owners June 18, 2025 15:41
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jun 18, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 18, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 18, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 18, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 18, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @xyOz-dev!

I made a small change so that the new regex only changes the actual link and not the text shown, it should have the same effect as your fix but now the punctuation is preserved on the actual text.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 18, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 18, 2025
await (async () => {
const linkElement = screen.getByRole("link")
expect(linkElement).toHaveAttribute("href", "https://example.com")
expect(linkElement.textContent).toBe("https://example.com.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it expected that the trailing period is part of the link text?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the expected behaviour is to show the punctuation in the chat block but link to it without a trailing ., So it seems to be correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the expected behaviour is to show the punctuation in the chat block but link to it without a trailing ., So it seems to be correct.

I didnt personally write the test, my original code just removed the trailing period, Dan updated it slightly.

Copy link
Collaborator

@mrubens mrubens Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, looks like the period is still visually inside of the link even though the href is correct.
Screenshot 2025-06-18 at 3 42 29 PM

IMO we should handle it like Github does 👇 (I don't feel strongly about stripping the https:// though)

Check out this link: https://example.com/.

Copy link
Member

@daniel-lxs daniel-lxs Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I made it so that the actual text keeps the period instead of just removing all punctuation, since it might look weird if the model is doing something like https://example1.com, https://example2.com, etc. and the punctuation is stripped.

However what you are suggesting might be even better:
image

Keeping the punctuation without the link highlight.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this test be failing now if it's fixed to behave like the above? Or am I confused?

@daniel-lxs daniel-lxs moved this from PR [Needs Review] to PR [Changes Requested] in Roo Code Roadmap Jun 18, 2025
@hannesrudolph hannesrudolph moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Jun 19, 2025
@hannesrudolph
Copy link
Collaborator

@daniel-lxs apparently its good now!

Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @xyOz-dev!
LGTM

image

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 19, 2025
@daniel-lxs
Copy link
Member

daniel-lxs commented Jun 19, 2025

This is how it looks now @mrubens

Now it behaves like github does.

image

@mrubens
Copy link
Collaborator

mrubens commented Jun 20, 2025

I'm still confused by https://github.com/RooCodeInc/Roo-Code/pull/4841/files#r2157619976 - what am I missing?

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 20, 2025
@daniel-lxs
Copy link
Member

@mrubens
I fixed the issues with this PR, the test wasn't really checking anything and while the actual code worked it was nesting the elements.
Should work as expected now.

@mrubens mrubens merged commit 93b8f6d into RooCodeInc:main Jun 20, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 20, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 20, 2025
cte pushed a commit that referenced this pull request Jun 24, 2025
* Update MarkdownBlock.tsx

* fix: correct URL handling in MarkdownBlock and add tests for trailing punctuation

* Fix URL punctuation rendering

* fix: improve URL handling in MarkdownBlock and update tests for trailing punctuation

---------

Co-authored-by: Daniel Riccio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Chat view: URLs followed by periods incorrectly include period in clickable link

4 participants