From dd9bf888e904bf79d3f4209f87b1889777e2a620 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 26 Apr 2026 11:18:02 -0700 Subject: [PATCH] fix(terminal): make Claude Code OSC 8 hyperlinks clickable (#1132) Co-authored-by: Orca --- src/main/daemon/pty-subprocess.ts | 10 +++++++++- src/main/ipc/pty.test.ts | 10 ++++++++++ src/main/providers/local-pty-provider.ts | 10 +++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main/daemon/pty-subprocess.ts b/src/main/daemon/pty-subprocess.ts index 4f8a67546..123818f68 100644 --- a/src/main/daemon/pty-subprocess.ts +++ b/src/main/daemon/pty-subprocess.ts @@ -45,7 +45,15 @@ export function createPtySubprocess(opts: PtySubprocessOptions): SubprocessHandl // Why: TUIs feature-gate on TERM_PROGRAM_VERSION. The daemon is forked // by main (daemon-init.ts:93) with the parent's env, so ORCA_APP_VERSION // — set in src/main/index.ts from app.getVersion() — is inherited here. - TERM_PROGRAM_VERSION: process.env.ORCA_APP_VERSION ?? '0.0.0-dev' + TERM_PROGRAM_VERSION: process.env.ORCA_APP_VERSION ?? '0.0.0-dev', + // Why: opt tools (Claude Code, ls --hyperlink, etc.) into emitting OSC 8 + // hyperlinks. The `supports-hyperlinks` npm package gates on a hard-coded + // TERM_PROGRAM allowlist (iTerm.app / WezTerm / vscode) and returns false + // for TERM_PROGRAM=Orca, so callers drop OSC 8 output entirely and emit + // bare text instead. xterm.js in Orca parses OSC 8 and the pane's + // linkHandler routes clicks, so forcing the advertisement is safe and + // restores clickable refs like `owner/repo#123` / `PR#123`. + FORCE_HYPERLINK: '1' } as Record env.LANG ??= 'en_US.UTF-8' diff --git a/src/main/ipc/pty.test.ts b/src/main/ipc/pty.test.ts index 6f3754d6a..9dbc0dc39 100644 --- a/src/main/ipc/pty.test.ts +++ b/src/main/ipc/pty.test.ts @@ -288,6 +288,16 @@ describe('registerPtyHandlers', () => { expect(env.TERM_PROGRAM).toBe('Orca') }) + it('advertises OSC 8 hyperlink support via FORCE_HYPERLINK', async () => { + // Why: the supports-hyperlinks npm package hard-codes a TERM_PROGRAM + // allowlist (iTerm.app / WezTerm / vscode) and reports false for + // TERM_PROGRAM=Orca, so tools like Claude Code emit plain text instead + // of ESC]8;; wrappers. Setting FORCE_HYPERLINK=1 forces the detector to + // return true; xterm.js + our linkHandler handle the sequences natively. + const env = await spawnAndGetEnv() + expect(env.FORCE_HYPERLINK).toBe('1') + }) + it('surfaces ORCA_APP_VERSION as TERM_PROGRAM_VERSION for TUI feature gating', async () => { const env = await spawnAndGetEnv(undefined, { ORCA_APP_VERSION: '1.2.3-test' }) expect(env.TERM_PROGRAM_VERSION).toBe('1.2.3-test') diff --git a/src/main/providers/local-pty-provider.ts b/src/main/providers/local-pty-provider.ts index 3871aa00b..ca447ce19 100644 --- a/src/main/providers/local-pty-provider.ts +++ b/src/main/providers/local-pty-provider.ts @@ -181,7 +181,15 @@ export class LocalPtyProvider implements IPtyProvider { // autodetection, bat/delta paging hints). Sourced from ORCA_APP_VERSION // which main/index.ts seeds from app.getVersion() at startup; the // fallback keeps tests and non-Electron runs working. - TERM_PROGRAM_VERSION: process.env.ORCA_APP_VERSION ?? '0.0.0-dev' + TERM_PROGRAM_VERSION: process.env.ORCA_APP_VERSION ?? '0.0.0-dev', + // Why: opt tools (Claude Code, ls --hyperlink, etc.) into emitting OSC 8 + // hyperlinks. The `supports-hyperlinks` npm package gates on a hard-coded + // TERM_PROGRAM allowlist (iTerm.app / WezTerm / vscode) and returns false + // for TERM_PROGRAM=Orca, so callers drop OSC 8 output entirely and emit + // bare text instead. xterm.js in Orca parses OSC 8 and the pane's + // linkHandler routes clicks, so forcing the advertisement is safe and + // restores clickable refs like `owner/repo#123` / `PR#123`. + FORCE_HYPERLINK: '1' } as Record for (const key of args.envToDelete ?? []) { delete spawnEnv[key]