fix(vt): store OSC 8 hyperlink params and uri in correct fields#868
Open
paultyng wants to merge 2 commits into
Open
fix(vt): store OSC 8 hyperlink params and uri in correct fields#868paultyng wants to merge 2 commits into
paultyng wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #868 +/- ##
==========================================
- Coverage 38.14% 36.90% -1.25%
==========================================
Files 196 21 -175
Lines 16750 1837 -14913
==========================================
- Hits 6390 678 -5712
+ Misses 9959 1070 -8889
+ Partials 401 89 -312 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
handleHyperlink stored parts[1] (the params slot) into Link.URL and parts[2] (the uri slot) into Link.Params. The OSC 8 wire format per egmontkov's de facto spec (https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) is `ESC ] 8 ; <params> ; <uri> ST` — params first, uri second — so the assignments were swapped. Symptom downstream: every OSC 8 hyperlink that round-trips through Buffer.Render() (e.g. a vscreen-style snapshot/replay) emits bytes with the two fields back in the OPPOSITE slots from their original input. When xterm.js parses those re-emitted bytes its setHyperlink falls through to the empty-uri rejection branch and never registers the link, so the styled text renders but the hover/click handlers never fire. Same defect affects any consumer that re-renders cells back to ANSI. Adds osc_test.go with two subtests: - empty params, populated uri (the common case — gh, claude, coreutils, testagent's /link all emit this form) - populated params and uri (id=...:tag=... form) Both subtests assert via Emulator.CellAt(0,0).Link that URL and Params land in their spec slots.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
handleHyperlinkstores the OSC 8 params slot intoLink.URLand the URI slot intoLink.Params. The two fields are swapped.Problem
OSC 8 wire format:
After
bytes.Split(data, ';')on valid8;<params>;<uri>input,parts[1]is<params>andparts[2]is<uri>. The handler does the opposite.Impact
Any consumer that round-trips cells back to ANSI via
ansi.SetHyperlink(cell.Link.URL, cell.Link.Params)re-emits with the slots swapped. The common caseESC]8;;<uri>STbecomesESC]8;<uri>;ST— URI in the params slot, URI slot empty. xterm.js's parser rejects it via the empty-URI branch; the styled text renders but is not clickable.In-repo:
cellbuffollows this exact pattern atscreen.go:734,
wrap.go:90,
pen.go:66,
writer.go:126,
so any
cellbufconsumer whose cells were populated byvtinherits the swap.Common emitters of OSC 8 whose output would round-trip incorrectly:
GNU coreutils
ls --hyperlink,ripgrep,
fd.
Changes
vt/osc.go: swap the two assignments.vt/osc_test.go(new): two subtests viaEmulator.CellAt(0,0).Link,covering empty-params and populated-params forms. Both fail on
mainwith field-value assertions surfacing the swap; pass with the fix.
Testing
go test -race ./vt/...passes locally; CI covers Linux/macOS/Windows.