Skip to content

Emit OSC 8 terminal hyperlinks from WriteLink via Spectre Markup#133

Merged
boxofyellow merged 3 commits into
mainfrom
copilot/emit-osc8-hyperlinks
May 16, 2026
Merged

Emit OSC 8 terminal hyperlinks from WriteLink via Spectre Markup#133
boxofyellow merged 3 commits into
mainfrom
copilot/emit-osc8-hyperlinks

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

✨ Enhancement

Inline links rendered by ConsoleRendererBase.WriteLink (covering both LinkInline and AutolinkInline) now emit Spectre.Console's [link=...]...[/] markup, producing OSC 8 terminal hyperlinks in capable terminals. Previously links were only discoverable via the post-render numbered menu.

Implementation approach:

  • DisplayOptions.UseTerminalHyperlinks — new opt-out bool (default true); added to Clone().
  • ConsoleRendererBase.WriteLink — when the option is enabled and the URL is non-empty, wraps the emitted link text with [link={Markup.Escape(url)}]...[/]. URL is escaped so URLs containing [/] don't break Spectre's markup parser. No-op when URL is empty (e.g. [](path) reference-style cases) to avoid emitting an empty hyperlink target.
var useHyperlink = Options.UseTerminalHyperlinks && !string.IsNullOrEmpty(url);
if (useHyperlink) AddInLine($"[link={Markup.Escape(url)}]");
// ... existing [text](url) emission ...
if (useHyperlink) AddInLine("[/]");
  • Tests — added 5 cases in RendererTests exercising default-on, opt-out, autolink wrapping, bracketed-URL escaping, and Clone() preservation. They use a TestConsole with EmitAnsiSequences = true and Profile.Capabilities.Links = true to assert on the OSC 8 sequences directly.

Existing linkInline / autolinkInline / bracketEscaping golden fixtures required no updates: TestConsole.Output strips the new markup unless link capabilities are explicitly enabled, so the plain-text layout fixtures are unaffected.

Copilot AI changed the title [WIP] Consider emitting OSC 8 terminal hyperlinks via Markup link tag Emit OSC 8 terminal hyperlinks from WriteLink via Spectre Markup May 15, 2026
Copilot AI requested a review from boxofyellow May 15, 2026 01:53
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.74%. Comparing base (ba02956) to head (f67e96e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #133      +/-   ##
==========================================
+ Coverage   95.71%   95.74%   +0.03%     
==========================================
  Files          29       29              
  Lines        1635     1647      +12     
  Branches      172      175       +3     
==========================================
+ Hits         1565     1577      +12     
  Misses         46       46              
  Partials       24       24              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread DisplayOptions.cs
Copilot AI and others added 3 commits May 16, 2026 07:27
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
@boxofyellow boxofyellow force-pushed the copilot/emit-osc8-hyperlinks branch from d1d66d0 to f67e96e Compare May 16, 2026 11:29
@boxofyellow boxofyellow marked this pull request as ready for review May 16, 2026 11:30
@boxofyellow boxofyellow merged commit 140b595 into main May 16, 2026
12 checks passed
@boxofyellow boxofyellow deleted the copilot/emit-osc8-hyperlinks branch May 16, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Spectre.Console] Consider emitting OSC 8 terminal hyperlinks via Markup link tag

2 participants