Skip to content

fix(tui): enable OSC 8 hyperlink detection for tree-sitter markdown#20400

Open
mugnimaestra wants to merge 1 commit intoanomalyco:devfrom
mugnimaestra:fix/osc8-link-detection
Open

fix(tui): enable OSC 8 hyperlink detection for tree-sitter markdown#20400
mugnimaestra wants to merge 1 commit intoanomalyco:devfrom
mugnimaestra:fix/osc8-link-detection

Conversation

@mugnimaestra
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #14966

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

URLs in tree-sitter markdown rendering don't emit OSC 8 hyperlink sequences, so Cmd/Ctrl+Click breaks when a URL wraps across terminal lines. The terminal's own URL auto-detection only sees the truncated portion on the clicked line.

This wires up the detectLinks hook from @opentui/core (added in anomalyco/opentui#736) to the markdown <code> renderable. The hook post-processes tree-sitter highlights, detects URL-bearing scopes, and sets chunk.link = { url } so the renderer emits proper OSC 8 escape sequences.

2-line change:

  1. Import detectLinks from @opentui/core
  2. Pass onChunks={detectLinks} to the markdown <code> element in TextPart

How did you verify your code works?

  • Manually tested in iTerm2: Cmd+Click opens the full correct URL even when the link wraps across multiple terminal lines
  • Verified existing tests still pass

Screenshots / recordings

See video in #14966 for the broken behavior. After this fix, wrapped URLs are fully clickable.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add detectLinks from @opentui/core as onChunks callback on the
markdown code renderable. This enables OSC 8 hyperlink sequences
for URLs in tree-sitter rendered markdown, making Cmd/Ctrl+Click
work correctly for wrapped links.

Depends on anomalyco/opentui#736
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URLs in tree-sitter markdown rendering have no OSC 8 hyperlink support (links break at line wrap)

1 participant