fix(tui): wrap markdown links in Link so Ghostty/iTerm/kitty get real OSC 8 hyperlinks

renderLink was discarding the URL entirely — it rendered the label as amber
underlined text and dropped the href. Result: Cmd+Click / Ctrl+Click did
nothing in any terminal, including Ghostty.

Now both markdown links `[label](url)` and bare `https://…` URLs are wrapped
in @hermes/ink's Link component, which emits OSC 8 (\\x1b]8;;url\\x07label\\x1b]8;;\\x07)
when supportsHyperlinks() returns true. ADDITIONAL_HYPERLINK_TERMINALS already
includes ghostty, iTerm2, kitty, alacritty, Hyper.

Autolinks that look like bare emails (foo@bar.com) now prepend mailto: in the
href so they open the mail client correctly.

Also adds a typed declaration for Link in hermes-ink.d.ts.
This commit is contained in:
Brooklyn Nicholson
2026-04-18 14:39:24 -05:00
parent a7f4d756b7
commit 5c8b291607
2 changed files with 24 additions and 11 deletions

View File

@@ -63,6 +63,11 @@ declare module '@hermes/ink' {
export const Box: React.ComponentType<any>
export const AlternateScreen: React.ComponentType<any>
export const Ansi: React.ComponentType<any>
export const Link: React.ComponentType<{
readonly children?: React.ReactNode
readonly fallback?: React.ReactNode
readonly url: string
}>
export const NoSelect: React.ComponentType<any>
export const ScrollBox: React.ComponentType<any>
export const Text: React.ComponentType<any>