rendered markdown links include trailing ')' in clickable URL

Open 💬 2 comments Opened Apr 10, 2026 by terkesi

What version of Codex CLI is running?

codex-cli 0.118.0

What subscription do you have?

Business

Which model were you using?

gpt-5.4 xhigh fast

What platform is your computer?

Darwin 24.6.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

WezTerm 20240203-110809-5046fc22 (latest version. not the nightly channel)

What issue are you seeing?

When codex renders a markdown link like [PR #496](https://github.com/org/repo/pull/496), the TUI output looks like:

PR #496 (https://github.com/org/repo/pull/496)

The problem is terminal emulators (WezTerm, iTerm2, Terminal.app, etc.) include the trailing ) in the clickable URL — so you end up navigating to https://github.com/org/repo/pull/496) which 404s.

What steps can reproduce the bug?

  1. Have codex output any markdown link to a remote URL (e.g. a PR link)
  2. Click the rendered URL in the terminal
  3. Browser navigates to the URL with a trailing ) appended — 404

What is the expected behavior?

Clicking the URL should navigate to the correct destination without the trailing ).

-------------

Additional information

Root cause

pop_link() in codex-rs/tui/src/markdown_render.rs (around line 596) pushes " (", the styled URL, then ")" as separate spans. The closing paren is character-adjacent to the URL, and most terminals' URL detection heuristics will grab it since there's no matching ( inside the URL itself.

self.push_span(" (".into());
self.push_span(Span::styled(link.destination, self.styles.link));
self.push_span(")".into());

-------------

Suggested fix

Swap the parens for a separator that won't get captured — something like an em-dash works fine here since the URL is already styled (cyan + underline) so the visual grouping isn't lost:

self.push_span(" — ".into());
self.push_span(Span::styled(link.destination, self.styles.link));

The test url_link_shows_destination in markdown_render_tests.rs would need the same update.

View original on GitHub ↗

2 Comments

Smeet23 · 4 months ago

Root cause analysis + fix

The issue is in pop_link() in codex-rs/tui/src/markdown_render.rs. It wraps the URL in " (" and ")" as adjacent spans:

self.push_span(" (".into());
self.push_span(Span::styled(link.destination, self.styles.link));
self.push_span(")".into());

Terminal emulators (WezTerm, iTerm2, Terminal.app) use heuristics to detect clickable URLs. Since the closing ) is character-adjacent to the URL with no matching ( inside the URL itself, terminals grab it as part of the link — resulting in https://github.com/org/repo/pull/496) which 404s.

Fix

Replace the paren wrapping with an em-dash separator. The URL is already visually distinct via cyan+underline styling, so the parens aren't needed for readability:

self.push_span(" — ".into());
self.push_span(Span::styled(link.destination, self.styles.link));

Before: PR #496 (https://github.com/org/repo/pull/496)
After: PR #496 — https://github.com/org/repo/pull/496

I've tested this locally — the two unit tests (link and url_link_shows_destination) and the markdown_render_complex_snapshot snapshot all needed updating, and cargo test -p codex-tui -- markdown passes cleanly (122 tests, 0 failures) after the change. Happy to share the branch if useful.

matthias-scale · 24 days ago

Confirmed still reproducible on Linux with codex-cli 0.146.0 in the Codex terminal workflow displayed through WezTerm.

A standard Markdown link rendered by Codex as label (https://host/path) opens https://host/path) when clicked; the final ) is included in the browser target. A standalone raw URL avoids the problem.

This is the same behavior described in the issue, and it remains present in the current installed release. The proposed renderer change to avoid placing a closing parenthesis directly after the URL would address this terminal-linkifier failure mode.