OSC8 hyperlink span incorrectly includes trailing ) from markdown image syntax

Resolved 💬 3 comments Opened Jun 4, 2026 by gitmpr Closed Jul 8, 2026

Description

When Claude Code renders tool output containing a markdown image reference, it emits an OSC8 hyperlink whose span includes the closing ) of the ![alt](url) syntax. This causes the ) to be part of the clickable URL in terminals that support OSC8, resulting in a broken link when ctrl+clicking.

Steps to reproduce

In a terminal with OSC8 support (e.g. Ghostty, Kitty, WezTerm), run a tool that produces markdown image output — for example the gh image extension:

gh image screenshot.png --repo owner/repo

Claude Code renders the output as:

![screenshot.png](https://github.com/user-attachments/assets/4aa7c5c3-58ab-4d15-b6fa-e962c6d072e3)

Ctrl+hover over the URL — the clickable region includes the trailing ).

Expected

OSC8 span covers only the URL:

https://github.com/user-attachments/assets/4aa7c5c3-58ab-4d15-b6fa-e962c6d072e3

Actual

OSC8 span covers the URL plus the closing parenthesis:

https://github.com/user-attachments/assets/4aa7c5c3-58ab-4d15-b6fa-e962c6d072e3)

The status bar at the bottom of the terminal confirms the ) is inside the OSC8 span:

!2026-06-04_09-34.png

Root cause

The issue is confirmed to be in Claude Code's OSC8 emission, not in the terminal's regex-based URL detection. Verified by running the same string via plain echo in a separate terminal window — Ghostty's regex correctly strips the trailing ). The bug only manifests inside Claude Code's output, where OSC8 takes priority over the terminal's regex fallback.

OSC8 gives the emitting application full authority over the hyperlink span. When the span is wrong, the terminal has no mechanism to correct it — the fix belongs in the emitter.

Environment

  • Claude Code 2.1.162
  • Terminal: Ghostty 1.3.0 (Linux, GTK)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗