From 9a96b6f5091be1424f542965c00ae62dd29be991 Mon Sep 17 00:00:00 2001 From: pash-openai Date: Wed, 25 Feb 2026 21:28:37 -0800 Subject: [PATCH] Hide local file link destinations in TUI markdown (#12705) ## Summary - hide appended destinations for local path-style markdown links in the TUI renderer - keep web links rendering with their visible destination and style link labels consistently - add markdown renderer tests and a snapshot for the new file-link output ## Testing - just fmt - cargo test -p codex-tui image --- codex-rs/tui/src/markdown_render.rs | 41 +++++++++++++++--- codex-rs/tui/src/markdown_render_tests.rs | 42 ++++++++++++++++++- ...s__markdown_render_file_link_snapshot.snap | 5 +++ 3 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 codex-rs/tui/src/snapshots/codex_tui__markdown_render__markdown_render_tests__markdown_render_file_link_snapshot.snap diff --git a/codex-rs/tui/src/markdown_render.rs b/codex-rs/tui/src/markdown_render.rs index ba8b47d5e..a7e80acae 100644 --- a/codex-rs/tui/src/markdown_render.rs +++ b/codex-rs/tui/src/markdown_render.rs @@ -85,6 +85,30 @@ pub(crate) fn render_markdown_text_with_width(input: &str, width: Option) w.text } +#[derive(Clone, Debug)] +struct LinkState { + destination: String, + show_destination: bool, +} + +fn should_render_link_destination(dest_url: &str) -> bool { + !is_local_path_like_link(dest_url) +} + +fn is_local_path_like_link(dest_url: &str) -> bool { + dest_url.starts_with("file://") + || dest_url.starts_with('/') + || dest_url.starts_with("~/") + || dest_url.starts_with("./") + || dest_url.starts_with("../") + || dest_url.starts_with("\\\\") + || matches!( + dest_url.as_bytes(), + [drive, b':', separator, ..] + if drive.is_ascii_alphabetic() && matches!(separator, b'/' | b'\\') + ) +} + struct Writer<'a, I> where I: Iterator>, @@ -95,7 +119,7 @@ where inline_styles: Vec