Skip to content

Emit OSC 8 hyperlinks for links #106

Description

@brainkim

This issue was generated by Claude Code.

An a[href] renders underlined in LinkText, but the terminal doesn't know it's a link. Activation does nothing: the engine can't follow a hyperlink, and runActivationBehavior says so. The terminal can, if the painter marks the cells with OSC 8:

ESC ] 8 ; id=<id> ; <url> ESC \  …text…  ESC ] 8 ; ; ESC \

iTerm2, kitty, WezTerm, Ghostty, foot and Alacritty then let the user open the link with a modifier-click or on hover, regardless of mouse reporting, since the terminal handles that click itself. tmux 3.4+ passes OSC 8 through.

What it takes:

  • A per-cell link slot in the screen grid, next to the packed attributes, holding an index into a per-frame link table (url + id).
  • The diff serializer opens and closes the OSC 8 string around runs whose link changes, the way it does for SGR.
  • A stable id per link element across frames, so a link that breaks across lines or is repainted stays one link to the terminal.
  • Only absolute http, https, mailto and file URLs; href="#x" and relative URLs mean nothing outside the document. a.href already resolves against the document URL.
  • Tests: the bytes for a link, a link wrapped across two lines sharing one id, and no OSC 8 for a placeholder anchor or a fragment link.

Out of scope: following a link in-engine, which stays with the app's click listener.

🤖 Generated with Claude Code

https://claude.ai/code/session_015Bw3yEu4cfkuDkaZ3RSy4D

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions