SerializeAddon.serialize() drops OSC 8 hyperlinks (urlId not emitted)
Summary
SerializeAddon.serialize() never emits OSC 8 hyperlink sequences. Hyperlinks live on buffer cells as an internal numeric urlId (extended attrs) with the URI stored in OscLinkService, and the ANSI StringSerializeHandler only reads SGR attributes — so a serialized buffer replays with all link styling (underline SGR) intact but no hyperlink data at all.
Repro
const term = new Terminal({ cols: 80, rows: 10, scrollback: 1000, allowProposedApi: true });
const addon = new SerializeAddon();
term.loadAddon(addon);
term.write("see \u001b]8;;https://example.org/pr-123\u001b\\\u001b[4mPR #123\u001b[24m\u001b]8;;\u001b\\ and more\r\n");
term.write("", () => {
const snapshot = addon.serialize();
console.log(snapshot);
// "see \u001b[4mPR #123\u001b[0m and more\r\n..." — no ]8; sequences, no URI
});
Replay that string into any xterm: the label is underlined but OscLinkProvider.provideLinks finds no urlId on the cells, so the link is not hoverable and not clickable.
Impact
Any consumer that snapshots and restores buffers (tab hibernation, session restore, terminal handoff) silently loses every hyperlink. Plain-text URLs recovered by WebLinks survive, which makes it look intermittent — OSC 8-dense TUIs are hit hardest.
Suggested fix
In the ANSI StringSerializeHandler, track the cell's urlId alongside the SGR diff and emit OSC 8 open/close on transitions:
private _nextCell(cell, ...) {
...
const cellUrlId = cell.hasExtendedAttrs?.() ? cell.extended?.urlId : 0;
if (cellUrlId !== this._activeUrlId) {
if (this._activeUrlId) this._currentRow += "\u001b]8;;\u001b\\";
if (cellUrlId) {
const uri = this._oscLinkService.getLinkData(cellUrlId)?.uri;
if (uri) this._currentRow += `\u001b]8;;${uri}\u001b\\`;
}
this._activeUrlId = cellUrlId;
}
...
}
Access to OscLinkService would need to be exposed to the addon (it is not reachable from the public Terminal API today — we reach it via terminal._core._oscLinkService). Links spanning wrapped rows can simply be closed before each row separator and re-opened on the next row; the restored cells reconstruct the wrapped range via _getRangeWithLineWrap.
Tested against @xterm/[email protected] / @xterm/[email protected].
(This is a significant bug for us — Electron app terminal snapshots — happy to contribute a PR if the maintainers agree on the approach.)
Duplicate of #4531
#4531 tracks OSC 8 hyperlinks being dropped by both serialize() and serializeAsHTML(). Carrying over the fix suggested here: track each cell's urlId in StringSerializeHandler next to the SGR diff, and emit OSC 8 open/close whenever it changes. The addon would need access to the link URIs in OscLinkService, which the public API doesn't expose today. #6206 fixes the related underline corruption on hyperlink cells, but not the OSC 8 output itself.