From 59af0fd53a6128392a436decae967e0631dd2f33 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 21 Nov 2025 20:14:32 +0100 Subject: [PATCH] fix: markdown link rendering for links with identical text and href --- packages/coding-agent/CHANGELOG.md | 4 ++++ packages/tui/src/components/markdown.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 82e1cb74..48ba1695 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- **Markdown Link Rendering**: Fixed links with identical text and href (e.g., `https://github.com/badlogic/pi-mono/pull/48/files`) being rendered twice. Now correctly compares raw text instead of styled text (which contains ANSI codes) when determining if link text matches href. + ## [0.8.5] - 2025-11-21 ### Fixed diff --git a/packages/tui/src/components/markdown.ts b/packages/tui/src/components/markdown.ts index 79b03ddb..fa59d48c 100644 --- a/packages/tui/src/components/markdown.ts +++ b/packages/tui/src/components/markdown.ts @@ -321,7 +321,8 @@ export class Markdown implements Component { case "link": { const linkText = this.renderInlineTokens(token.tokens || []); // If link text matches href, only show the link once - if (linkText === token.href) { + // Compare raw text (token.text) not styled text (linkText) since linkText has ANSI codes + if (token.text === token.href) { result += this.theme.link(this.theme.underline(linkText)) + this.applyDefaultStyle(""); } else { result +=