fix(terminal): make Claude Code OSC 8 hyperlinks clickable (#1132)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-04-26 11:18:02 -07:00
committed by GitHub
co-authored by Orca
parent a351b7a1cc
commit dd9bf888e9
3 changed files with 28 additions and 2 deletions
+9 -1
View File
@@ -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<string, string>
env.LANG ??= 'en_US.UTF-8'
+10
View File
@@ -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')
+9 -1
View File
@@ -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<string, string>
for (const key of args.envToDelete ?? []) {
delete spawnEnv[key]