feat(tui): detect Rex terminal for OSC 8 hyperlinks

Rex supports OSC 8 but was treated as an unknown terminal, so links fell back to the `text (url)` format.

Detect it via TERM_PROGRAM=rex and enable hyperlinks and truecolor. Images stay off because Rex only partially implements the Kitty graphics protocol (no Unicode placeholders). The check runs before the outer-terminal checks so leaked variables like KITTY_WINDOW_ID don't win.

Closes #11131
This commit is contained in:
Petr Houška 2026-10-19 22:01:41 +02:00
parent 61060ddf8c
commit 0ed1b04314
2 changed files with 19 additions and 0 deletions

View file

@ -92,6 +92,12 @@ function detectCapabilitiesFromEnvironment(tmuxForwardsHyperlink: () => boolean)
return { images: "kitty", trueColor: hasTrueColorHint, hyperlinks: true };
}
// Rex supports OSC 8 hyperlinks but only partially implements the Kitty graphics protocol
// (no Unicode placeholders), so leave images off. Check it before outer-terminal detection.
if (termProgram === "rex") {
return { images: null, trueColor: true, hyperlinks: true };
}
if (process.env.KITTY_WINDOW_ID || termProgram === "kitty") {
return { images: "kitty", trueColor: true, hyperlinks: true };
}

View file

@ -330,6 +330,19 @@ describe("detectCapabilities", () => {
});
});
// #11131
it("enables hyperlinks without images for Rex", () => {
withEnv({ TERM_PROGRAM: "rex", TERM: "xterm-256color", KITTY_WINDOW_ID: "1" }, () => {
const caps = detectCapabilities();
assert.strictEqual(caps.hyperlinks, true);
assert.strictEqual(caps.images, null);
assert.strictEqual(caps.trueColor, true);
});
withEnv({ TERM_PROGRAM: "rex", PI_HYPERLINKS: "0" }, () => {
assert.strictEqual(detectCapabilities().hyperlinks, false);
});
});
it("enables hyperlinks for Ghostty", () => {
withEnv({ TERM_PROGRAM: "ghostty" }, () => {
const caps = detectCapabilities();