Skip to content

rendered markdown links include trailing ')' in clickable URL #17342

@terkesi

Description

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displaybugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions