Skip to content

fix: preserve markdown hyperlink targets#1058

Open
kitlangton wants to merge 22 commits into
anomalyco:mainfrom
kitlangton:markdown-link-hyperlink-fix-pr
Open

fix: preserve markdown hyperlink targets#1058
kitlangton wants to merge 22 commits into
anomalyco:mainfrom
kitlangton:markdown-link-hyperlink-fix-pr

Conversation

@kitlangton

@kitlangton kitlangton commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Render concealed Markdown links as compact clickable labels only after OSC 8 hyperlink support is detected.
  • Preserve a visible label (destination) fallback while hyperlink support is unavailable or unknown.
  • Detect and style visible bare URLs without hyperlinking URLs inside Markdown code spans.
  • Preserve distinct markup.link.label and markup.link.url styling.
  • Keep generated native chunk styles isolated across live buffers while reusing stable per-buffer slots and cleaning them up on replacement/detach.
  • Detect OSC 8 support in Zed and VS Code integrated terminals through the existing terminal identity path.

Before

Clickable-capable terminals displayed redundant destinations:

Check out OpenTUI (https://github.com/sst/opentui) for more.

After

When OSC 8 support is detected:

Check out OpenTUI for more.

The displayed OpenTUI label retains its label style and carries the hidden https://github.com/sst/opentui OSC 8 target.

When OSC 8 support is unavailable or not yet detected, OpenTUI preserves the visible fallback:

Check out OpenTUI (https://github.com/sst/opentui) for more.

Simplify And Safety Review

  • Removed added renderer hyperlink override configuration and TypeScript FFI wiring; terminal capability detection is the single source of truth.
  • Made label-only concealment capability-driven rather than adding a public rendering option.
  • Removed redundant explicit Markdown-link regex scanning; parser URL ranges walk across intervening conceal highlights to associate labels.
  • Kept the event-driven capability refresh path because rebuilding Markdown children during renderSelf() produces an empty transition frame.
  • Limited bare-URL fallback so inline/fenced raw Markdown content is not linkified; concealed formatting delimiters are excluded from generated targets.
  • Kept one-character labels clickable while preserving safety for synthetic one-character conceal replacements.
  • Added support for compact titled Markdown links.
  • Avoided restyling clickable label text with URL colors when label and URL theme styles differ.
  • Replaced transient native style churn with stable per-buffer style slots, cleaning surplus/transitional styles on replacement/detach while preserving the TextBuffer.clear() highlight-retention contract.
  • Hardened SyntaxStyle insertion rollback on allocation failure.
  • Ensured OSC 8 links are opened after cursor positioning on newly rendered rows.
  • Reused the canonical terminal-name path for Zed and VS Code hyperlink detection.

Verification

  • bun test src/lib/detect-links.test.ts passes: 12 pass, 0 fail.
  • TypeScript and Zig formatting checks pass for changed files.
  • Earlier CI runs found and drove fixes for conceal-range label association and compact-link whitespace.
  • The final simplify pass found and fixes single-character labels, titled links, formatted bare URLs, stable style-slot reuse, plain-text replacement cleanup, safe style insertion rollback, and OSC 8 cursor-order output.
  • A rejected simplification moved capability refresh into renderSelf() and produced an empty transition frame; commit 0a9d460b restores the previously-safe event-driven refresh.
  • Local renderer/native test execution is blocked by the local Zig linker failure already observed for current clean worktrees; CI builds the native library from source and is the authoritative native verification path.

kitlangton and others added 21 commits May 15, 2026 21:49
…implify

# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
#
# Conflicts:
#	packages/core/src/renderables/__tests__/Markdown.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants