feat: enable OSC 8 hyperlink clicking with Cmd/Ctrl modifier #117
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
getHyperlinkUriAPI to WASM to retrieve the actual URI for hyperlinked cellsProblem
OSC 8 hyperlinks (created with escape sequences like
\e]8;;http://example.com\e\\Link text\e]8;;\e\\) were visually detected and underlined on hover, but Cmd+clicking them did nothing. Additionally, when multiple hyperlinks existed on the same line, all links would incorrectly open the same URL.Root Causes
Missing WASM API: The WASM didn't expose a function to retrieve the hyperlink URI. The
hyperlink_idfield in cells was just a boolean (0 or 1) indicating presence of a hyperlink, not a unique identifier.Incorrect link caching: The
LinkDetectorcached links byh${hyperlinkId}, but since all hyperlinks havehyperlink_id=1, all links on a line would share the same cache key, causing only the last discovered link to be returned for any hyperlink cell.Solution
Added
ghostty_terminal_get_hyperlink_uri(row, col)to the WASM API that looks up the actual URI from Ghostty's internal hyperlink storage.Updated
OSC8LinkProviderto use the new WASM API to fetch URIs, with proper coordinate conversion from buffer rows to viewport rows.Fixed
LinkDetectorto cache links by position range (r${row}:${startX}-${endX}) instead of hyperlink_id, ensuring each link is cached uniquely.Test Plan
printf '\e]8;;http://example.com\e\\Link text\e]8;;\e\\\n'printf '\e]8;;http://google.com\e\\Google\e]8;;\e\\ and \e]8;;http://github.com\e\\GitHub\e]8;;\e\\\n'🤖 Generated with Claude Code