feat(tui): make markdown links and URLs clickable in the terminal#2498
Open
silvin-lubecki wants to merge 1 commit intodocker:mainfrom
Open
feat(tui): make markdown links and URLs clickable in the terminal#2498silvin-lubecki wants to merge 1 commit intodocker:mainfrom
silvin-lubecki wants to merge 1 commit intodocker:mainfrom
Conversation
Member
|
/review |
Member
|
@silvin-lubecki did you address the feedback of the agent? |
Problem: Long URLs (e.g., Grafana dashboard links with encoded query parameters) were rendered as plain text in the TUI and were not clickable. Markdown links like [text](url) displayed both the link text AND the full URL, which cluttered the output. URLs inside code blocks that wrapped across multiple lines were impossible to click in any terminal. Solution: Emit OSC 8 hyperlink escape sequences around URLs so that terminals with native support (iTerm2, Kitty, WezTerm) render them as clickable links. For terminals without OSC 8 support (like Warp), extend the TUI's existing hover/click URL detection system to read OSC 8 sequences and resolve clicks on the visible link text to the hidden URL. Changes: Markdown renderer (fast_renderer.go): - [text](url) now emits OSC 8 sequences around the visible text instead of displaying the raw URL in parentheses - Bare URLs (https://...) in inline text are auto-detected and wrapped in OSC 8 sequences - URLs in fenced code blocks are detected and wrapped in OSC 8 - ansiStringWidth(), splitWordsWithStyles(), breakWord() updated to skip OSC sequences in width calculations and word splitting - updateActiveStyles() filters out OSC 8 sequences so hyperlinks are not incorrectly propagated across line wraps - fixHyperlinkWrapping() uses lipgloss.WrapWriter to ensure each wrapped line gets its own OSC 8 open/close pair URL detection (urldetect.go): - New extractOSC8Links() parses OSC 8 sequences from rendered lines and maps them to display column positions - New findAllURLSpans() merges OSC 8 links with visible URL detection, giving priority to OSC 8 spans on overlap - urlAtPosition() and updateHoveredURL() updated to use the combined detection, enabling hover underline and click-to-open for OSC 8 links Assisted-By: docker-agent
881a965 to
cadf778
Compare
Contributor
Author
|
@dgageot PTAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
Long URLs (e.g., Grafana dashboard links with encoded query parameters) were rendered as plain text in the TUI and were not clickable. Markdown links like text displayed both the link text AND the full URL, which cluttered the output. URLs inside code blocks that wrapped across multiple lines were impossible to click in any terminal.
Solution:
Emit OSC 8 hyperlink escape sequences around URLs so that terminals with native support (iTerm2, Kitty, WezTerm) render them as clickable links. For terminals without OSC 8 support (like Warp), extend the TUI's existing hover/click URL detection system to read OSC 8 sequences and resolve clicks on the visible link text to the hidden URL.
Changes:
Markdown renderer (fast_renderer.go):
URL detection (urldetect.go):
Assisted-By: docker-agent