Add copy current URL as markdown link on artifact page - #68
Conversation
Introduce a Markdown link toolbar action that copies the current page URL formatted as [artifact title](url), with bracket escaping in labels. Includes unit tests for link formatting and an e2e test for the copy flow. Co-authored-by: Aanish Bhirud <baanish@users.noreply.github.com>
Deploying agent-render with
|
| Latest commit: |
faa606b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3779a3bd.agent-render.pages.dev |
| Branch Preview URL: | https://cursor-copy-markdown-link-3c.agent-render.pages.dev |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a ChangesMarkdown Link Copy Feature
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (4 files)
Previous Review Summary (commit a223376)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit a223376)Status: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (4 files)
Reviewed by gpt-5.4-mini-2026-03-17 · 131,214 tokens |
| */ | ||
| export function formatMarkdownLink(label: string, href: string): string { | ||
| const trimmedLabel = label.trim() || href; | ||
| return `[${escapeMarkdownLinkLabel(trimmedLabel)}](${href})`; |
There was a problem hiding this comment.
WARNING: href is inserted into the markdown destination without escaping ) or backslashes, so links with those characters can be rendered incorrectly or truncated by markdown parsers.
Escaping the destination before formatting the link would make the helper safe for arbitrary URLs.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| it("falls back to the URL when the label is blank", () => { | ||
| expect(formatMarkdownLink(" ", "https://example.com/")).toBe("[https://example.com/](https://example.com/)"); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Missing test case for backslash escaping in the label.
escapeMarkdownLinkLabel escapes \ → \\ before handling brackets; without a test for this path a regression (e.g. dropping the first .replace) would go undetected, and artifact filenames from Windows paths can legitimately contain backslashes.
| it("falls back to the URL when the label is blank", () => { | |
| expect(formatMarkdownLink(" ", "https://example.com/")).toBe("[https://example.com/](https://example.com/)"); | |
| }); | |
| }); | |
| it("falls back to the URL when the label is blank", () => { | |
| expect(formatMarkdownLink(" ", "https://example.com/")).toBe("[https://example.com/](https://example.com/)"); | |
| }); | |
| it("escapes backslashes in the label", () => { | |
| expect(formatMarkdownLink("path\\to\\file", "https://example.com/")).toBe( | |
| "[path\\\\to\\\\file](https://example.com/)", | |
| ); | |
| }); | |
| }); |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a223376006
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| */ | ||
| export function formatMarkdownLink(label: string, href: string): string { | ||
| const trimmedLabel = label.trim() || href; | ||
| return `[${escapeMarkdownLinkLabel(trimmedLabel)}](${href})`; |
There was a problem hiding this comment.
Escape markdown link destinations
When users copy a link for a supported arx/arx2 fragment that uses the base76 wire form, the fragment payload can contain literal ) characters; inserting window.location.href directly between ( and ) makes Markdown close the destination at the first such character, so the pasted link is truncated and no longer decodes. Escape or wrap the destination, e.g. use an angle-bracket destination with any required escaping, before copying it.
Useful? React with 👍 / 👎.
URLs with literal ) characters (e.g. arx base76 fragments) can truncate markdown link destinations. Angle-bracket wrapping keeps the full href intact; nested < and > are percent-encoded. Co-authored-by: Aanish Bhirud <baanish@users.noreply.github.com>
Summary
Adds a Markdown link action to the artifact toolbar that copies the current page URL formatted as a markdown inline link, e.g.
[viewer-shell.tsx](https://example.com/#agent-render=...).The link label uses the same heading text shown for the active artifact (title → filename → id), with bracket escaping so labels containing
[or]remain valid markdown.Changes
formatMarkdownLink()helper insrc/lib/markdown-link.tsTest plan
npm run lintnpm run typechecknpm run test -- tests/markdown-link.test.tsnpm run test:e2e -- tests/e2e/viewer.spec.ts -g "markdown link"Summary by CodeRabbit