Skip to content

fix(tui): keep wrapped markdown links clickable#21559

Open
HaleTom wants to merge 6 commits intoanomalyco:devfrom
HaleTom:wrap-links
Open

fix(tui): keep wrapped markdown links clickable#21559
HaleTom wants to merge 6 commits intoanomalyco:devfrom
HaleTom:wrap-links

Conversation

@HaleTom
Copy link
Copy Markdown

@HaleTom HaleTom commented Apr 8, 2026

Issue for this PR

Closes #14966

Related: #18394
Overlaps: #20400
Upstream: anomalyco/opentui#735, anomalyco/opentui#736, anomalyco/opentui#737

Type of change

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

What does this PR do?

Wires detectLinks into the non-experimental markdown <code filetype=\"markdown\"> path in TUI session rendering.

This ensures tree-sitter markdown chunks carry hyperlink metadata so wrapped markdown URLs remain one clickable OSC 8 target instead of relying on terminal auto-detection at visual wraps.

Why use this instead of #20400?

#20400 proves the same minimal code path, but it relies on manual verification only.

This PR keeps the fix small and in the same location, but adds renderer-level regression coverage for the wrapped-link behavior. The new test renders a super-long file URL through OpenTUI's test renderer, verifies the wrapped lines reconstruct the original URL, and verifies every wrapped line carries the same nonzero hyperlink identity across the row boundary.

That makes this PR safer to merge and maintain because the exact wrap regression now has an automated test instead of depending on a terminal-specific manual check.

How did you verify your code works?

  • Added renderer-level regression coverage in packages/opencode/test/cli/tui/markdown-link-wrap.test.ts
  • bun test --timeout 30000 packages/opencode/test/cli/tui/markdown-link-wrap.test.ts
  • bun typecheck in packages/opencode

Screenshots / recordings

Not a UI screenshot change.

Checklist

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

Wire detectLinks into the non-experimental markdown code path so tree-sitter rendered URLs emit OSC 8 metadata instead of falling back to terminal auto-detection that breaks at line wraps.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

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

HaleTom and others added 3 commits April 9, 2026 08:53
Add PR.md with linked issue/PR strategy learnings and add GAPS.md capturing questions, unexpecteds, and user review queue refs for follow-up decisions.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Remove PR/GAPS tracking docs and add a focused regression test that guards detectLinks wiring in the non-experimental markdown TextPart path.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Replace the source-structure check with a renderer-level behavior test that uses detectLinks and asserts wrapped URL lines preserve one shared link id across the row boundary.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@HaleTom HaleTom marked this pull request as ready for review April 9, 2026 13:47
Copilot AI review requested due to automatic review settings April 9, 2026 13:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes wrapped markdown URLs becoming unclickable in the TUI by ensuring the non-experimental tree-sitter markdown rendering path attaches OSC 8 hyperlink metadata to URL chunks.

Changes:

  • Wire detectLinks into the non-experimental markdown <code filetype="markdown"> render path in the session UI.
  • Add a renderer-level regression test that verifies a long URL wraps across multiple rows while retaining a single, stable hyperlink id.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx Adds detectLinks to markdown <code> rendering so URL chunks get OSC 8 hyperlink metadata.
packages/opencode/test/cli/tui/markdown-link-wrap.test.ts Adds a regression test asserting wrapped URL lines preserve a single hyperlink identity across visual wraps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Comment thread packages/opencode/test/cli/tui/markdown-link-wrap.test.ts Outdated
HaleTom and others added 2 commits April 10, 2026 10:28
Apply detectLinks to the reasoning markdown path and harden the wrap regression test so renderer cleanup is guaranteed even when assertions fail.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Extend the renderer-level wrap regression to cover reasoning-shaped markdown content so every render path touched by the review fix has behavior coverage.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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.

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

2 participants