fix(tui): detect Alacritty for OSC 8 hyperlinks without TERM_PROGRAM (#11777)

Hyperlink detection recognised Alacritty only through
`TERM_PROGRAM=alacritty`, and Alacritty never sets `TERM_PROGRAM`. So in
a default Alacritty setup, pi fell back to `hyperlinks: false` and
rendered Markdown links as `label (url)` instead of clickable OSC 8
links.

Alacritty does set two other variables, which this change now checks:
- `TERM=alacritty` when its terminfo entry is installed (otherwise
`TERM=xterm-256color`);
- `ALACRITTY_WINDOW_ID` for the shell on Unix and macOS. This covers the
common macOS case where the terminfo entry is missing.

The tmux and screen checks still run first, so behaviour inside
multiplexers is unchanged.

**Testing**
- Added a `detectCapabilities` test covering `TERM=alacritty` and
`TERM=xterm-256color` with `ALACRITTY_WINDOW_ID`. It fails without the
change and passes with it.
- `node --test test/*.test.ts` in `packages/tui`: 1121 passing tests.
- `npm run check` passes.
- Checked `detectCapabilities()` with clean environments:
- Before: `TERM=alacritty` and `ALACRITTY_WINDOW_ID=123` both gave
`hyperlinks: false`.
  - After: both give `hyperlinks: true`.
- Plain `xterm-256color` and tmux with `ALACRITTY_WINDOW_ID` still give
`false`.

Fixes #11767

Requested by @badlogic

Co-authored-by: triagent <triagent@localhost>
This commit is contained in:
robopipi[bot] 2026-11-04 09:26:27 +01:00 • committed by GitHub
parent b64e6badd6
commit 2af8a42f5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -43,6 +43,7 @@ const ENV_KEYS = [
"WEZTERM_PANE",
"ITERM_SESSION_ID",
"WT_SESSION",
"ALACRITTY_WINDOW_ID",
"CMUX_WORKSPACE_ID",
"WARP_SESSION_ID",
"WARP_TERMINAL_SESSION_UUID",
@ -445,6 +446,15 @@ describe("detectCapabilities", () => {
});
});
it("enables hyperlinks for Alacritty without TERM_PROGRAM", () => {
withEnv({ TERM: "alacritty", COLORTERM: "truecolor" }, () => {
assert.deepStrictEqual(detectCapabilities(), { images: null, trueColor: true, hyperlinks: true });
});
withEnv({ TERM: "xterm-256color", COLORTERM: "truecolor", ALACRITTY_WINDOW_ID: "1" }, () => {
assert.deepStrictEqual(detectCapabilities(), { images: null, trueColor: true, hyperlinks: true });
});
});
it("enables Alacritty capabilities for Zed", () => {
withEnv({ TERM_PROGRAM: "zed" }, () => {
assert.deepStrictEqual(detectCapabilities(), { images: null, trueColor: true, hyperlinks: true });