anomalyco / anomalyco/opencode

TUI: markdown links paint as `label (url)` instead of label-only OSC 8

Open
#45,001 3 comments 0 reactions 1 assignee View on GitHub

@kommander is already working on this.

Since Aug 25, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

When an assistant message contains a markdown link [label](https://example.com/path), OpenCode’s TUI correctly attaches an OSC 8 hyperlink, but still renders the URL in the clear as:

label (https://example.com/path)

Expected (terminals with OSC 8, e.g. Warp): visible text is only label, clickable via OSC 8. The href should not appear next to the label.

Environment
  • OpenCode 1.18.23 (opencode-ai)
  • Terminal: Warp (OSC 8 works — span is underlined/clickable)
  • OS: Linux
Steps to reproduce
  1. Have the agent (or paste as assistant content) output:
    See [codecrafters-io/build-your-own-x](https://github.com/codecrafters-io/build-your-own-x).
    
  2. View the message in the TUI.
Actual

Visible: codecrafters-io/build-your-own-x (https://github.com/codecrafters-io/build-your-own-x)
OSC 8 covers the whole span (label + paren URL).

Expected

Visible: codecrafters-io/build-your-own-x only
OSC 8 target: https://github.com/codecrafters-io/build-your-own-x

Why it matters

Agents are instructed to use short labels (owner/repo, etc.) so tables and lists stay readable. Appending the full URL defeats that and breaks narrow layouts (tables especially).

Agents must not emit raw OSC 8 in chat (control chars are stripped/mangled). The only workable path is markdown links → TUI paint. So the TUI needs to conceal the href when OSC 8 is available.

Root cause (1.18.23)

Inline markdown renderer, case "link" (minified opencode.exe):

case "link": {
  let $ = { url: _.href };
  if (this._conceal) {
    for (let Z of _.tokens)
      this.renderInlineTokenWithStyle(Z, J, "markup.link.label", $);
    J.push(this.createChunk(" (", "markup.link", $));
    J.push(this.createChunk(_.href, "markup.link.url", $));
    J.push(this.createChunk(")", "markup.link", $));
  } else {
    // raw [label](href)
    ...
  }
}
  • createChunk(..., { url: href }) correctly sets the OSC 8 link field.
  • With _conceal default true (_contentDefaultOptions has conceal: !0), it still appends " (" + href + ")".

Related symbols: OSC8LinkProvider, _linkifyMarkdownChunks, conceal: !0.

Suggested fix

When conceal is on and hyperlinks are supported (OSC 8 / setHyperlinksCapability), render only the label tokens with { url: href }. Skip the " (", href, ")" chunks.

Optional fallback when OSC 8 is unavailable: keep today’s label (url) (or bare URL) so non-OSC terminals still show a usable target.

Out of scope / related

Not the same as wrap/click bugs:

  • #14966 (closed) — OSC 8 missing on tree-sitter plain URLs
  • #35649 — wrapped links not clickable (Kitty)
  • #44442 — Ctrl+click with mouse capture

This issue is only about visible href duplication next to an already-linked label.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.