From fc64baf7d1094631e34f95c16fa0f11280f1336a Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Wed, 22 Apr 2026 18:20:57 -0700 Subject: [PATCH] feat(terminal): expose FORCE_HYPERLINK as a user setting (default on) (#963) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(terminal): drop FORCE_HYPERLINK=1 from PTY spawn env FORCE_HYPERLINK=1 was set on every local PTY. It is read by oh-my-zsh's supports_hyperlinks(), the Rust supports-hyperlinks crate, GNU coreutils, and other tooling — so forcing it on makes every subprocess invoked during shell init take extra branches and emit OSC-8 escapes. Reproduced locally with a heavy zshrc (oh-my-zsh + p10k + nvm + pyenv): time-to-prompt jumps from ~600 ms without the variable to ~2000 ms with it (3.2×) on a clean sandbox. Stacked with the user-reported configuration (conda init, gcloud completions, compaudit over Homebrew paths, corporate network calls) that multiplier applied to a long serial chain of forks can stretch into "terminal is effectively never ready." xterm still renders OSC-8 hyperlinks when tools emit them on their own detection, so link support in Orca is preserved. VS Code does not set this variable either. * feat(terminal): make FORCE_HYPERLINK opt-out via settings, default on The previous commit on this branch removed FORCE_HYPERLINK=1 from PTY spawn env entirely. Revise: keep the historical default (on) so existing users don't silently lose OSC-8 hyperlink emission from tooling that checks this flag, but expose a toggle in Settings → Terminal → Advanced so users with heavy rc files (oh-my-zsh + powerlevel10k + nvm + pyenv + conda, etc.) can turn it off and reclaim the shell-startup time that the extra subprocess branching and escape emission was costing them. - Add `terminalForceHyperlink: boolean` to GlobalSettings (default true) - LocalPtyProvider gains an `isForceHyperlinkEnabled` hook; IPC wires it from the live settings snapshot - New SearchableSetting row in TerminalPane with zshrc-adjacent search keywords so users troubleshooting slow startup find it - Unit tests cover both default-on and opt-out paths --- .../runtime-home-service.test.ts | 1 + src/main/codex-accounts/service.test.ts | 1 + src/main/ipc/pty.ts | 1 + src/main/providers/local-pty-provider.test.ts | 16 ++++++ src/main/providers/local-pty-provider.ts | 24 ++++++++- .../src/components/settings/TerminalPane.tsx | 52 +++++++++++++++++++ .../components/settings/terminal-search.ts | 21 ++++++++ src/shared/constants.ts | 7 ++- src/shared/types.ts | 9 ++++ 9 files changed, 129 insertions(+), 3 deletions(-) diff --git a/src/main/codex-accounts/runtime-home-service.test.ts b/src/main/codex-accounts/runtime-home-service.test.ts index f4c93b895..36e9ea85a 100644 --- a/src/main/codex-accounts/runtime-home-service.test.ts +++ b/src/main/codex-accounts/runtime-home-service.test.ts @@ -84,6 +84,7 @@ function createSettings(overrides: Partial = {}): GlobalSettings terminalMacOptionAsAltMigrated: true, experimentalTerminalDaemon: false, experimentalTerminalDaemonNoticeShown: false, + terminalForceHyperlink: true, ...overrides } } diff --git a/src/main/codex-accounts/service.test.ts b/src/main/codex-accounts/service.test.ts index f786b6fe3..b412debf8 100644 --- a/src/main/codex-accounts/service.test.ts +++ b/src/main/codex-accounts/service.test.ts @@ -78,6 +78,7 @@ function createSettings(overrides: Partial = {}): GlobalSettings terminalMacOptionAsAltMigrated: true, experimentalTerminalDaemon: false, experimentalTerminalDaemonNoticeShown: false, + terminalForceHyperlink: true, ...overrides } } diff --git a/src/main/ipc/pty.ts b/src/main/ipc/pty.ts index aa9934764..577dd996c 100644 --- a/src/main/ipc/pty.ts +++ b/src/main/ipc/pty.ts @@ -146,6 +146,7 @@ export function registerPtyHandlers( if (localProvider instanceof LocalPtyProvider) { localProvider.configure({ isHistoryEnabled: () => getSettings?.()?.terminalScopeHistoryByWorktree ?? true, + isForceHyperlinkEnabled: () => getSettings?.()?.terminalForceHyperlink ?? true, buildSpawnEnv: (id, baseEnv) => { const selectedCodexHomePath = getSelectedCodexHomePath?.() ?? null diff --git a/src/main/providers/local-pty-provider.test.ts b/src/main/providers/local-pty-provider.test.ts index 6166d84be..a08583019 100644 --- a/src/main/providers/local-pty-provider.test.ts +++ b/src/main/providers/local-pty-provider.test.ts @@ -120,6 +120,22 @@ describe('LocalPtyProvider', () => { expect(spawnCall[2].env.CUSTOM_VAR).toBe('custom-value') }) + it('sets FORCE_HYPERLINK=1 by default to preserve legacy behavior', async () => { + await provider.spawn({ cols: 80, rows: 24 }) + const spawnCall = spawnMock.mock.calls.at(-1)! + expect(spawnCall[2].env.FORCE_HYPERLINK).toBe('1') + }) + + it('omits FORCE_HYPERLINK when isForceHyperlinkEnabled returns false', async () => { + // Why: users with heavy shell init (oh-my-zsh + p10k + nvm + pyenv) can + // disable FORCE_HYPERLINK from Settings. Verify the opt-out reaches the + // spawn env so OSC-8-reading tools stop emitting the extra escapes. + provider.configure({ isForceHyperlinkEnabled: () => false }) + await provider.spawn({ cols: 80, rows: 24 }) + const spawnCall = spawnMock.mock.calls.at(-1)! + expect(spawnCall[2].env.FORCE_HYPERLINK).toBeUndefined() + }) + it('combines HOMEDRIVE and HOMEPATH for Windows default cwd', async () => { const platform = Object.getOwnPropertyDescriptor(process, 'platform') const originalUserProfile = process.env.USERPROFILE diff --git a/src/main/providers/local-pty-provider.ts b/src/main/providers/local-pty-provider.ts index 58b11901e..662e2a84d 100644 --- a/src/main/providers/local-pty-provider.ts +++ b/src/main/providers/local-pty-provider.ts @@ -92,6 +92,12 @@ export type LocalPtyProviderOptions = { /** Whether worktree-scoped shell history is enabled. When true (or absent) * and a worktreeId is provided, HISTFILE is scoped per-worktree. */ isHistoryEnabled?: () => boolean + /** Whether to set FORCE_HYPERLINK=1 in spawned PTYs. Historically always on; + * now user-togglable because the extra OSC-8 emission branches in oh-my-zsh, + * coreutils, and the Rust supports-hyperlinks crate can compound to a + * significant shell-startup slowdown with heavy rc files. When absent, + * defaults to the prior behavior (on). */ + isForceHyperlinkEnabled?: () => boolean onSpawned?: (id: string) => void onExit?: (id: string, code: number) => void onData?: (id: string, data: string, timestamp: number) => void @@ -177,10 +183,24 @@ 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', - FORCE_HYPERLINK: '1' + TERM_PROGRAM_VERSION: process.env.ORCA_APP_VERSION ?? '0.0.0-dev' } as Record + // Why: FORCE_HYPERLINK=1 is read by oh-my-zsh's supports_hyperlinks(), the + // Rust supports-hyperlinks crate, GNU coreutils, and other tooling. + // Forcing it on makes every subprocess invoked during shell init take + // extra branches and emit OSC-8 escapes, which compounded with a heavy + // zshrc (oh-my-zsh + p10k + nvm + pyenv + conda) can 3×+ the startup time + // — reported by users as a multi-minute-to-hour "terminal hang." + // We keep the historical default (on) so existing users don't lose link + // emission silently, but expose it as a toggle so users with heavy rc + // files can opt out. Orca's xterm still renders OSC-8 hyperlinks when + // tools emit them on their own detection, so link support is preserved + // for the typical modern CLI even when this toggle is off. + if (this.opts.isForceHyperlinkEnabled?.() ?? true) { + spawnEnv.FORCE_HYPERLINK = '1' + } + spawnEnv.LANG ??= 'en_US.UTF-8' // Why: On Windows, LANG alone does not control the console code page. diff --git a/src/renderer/src/components/settings/TerminalPane.tsx b/src/renderer/src/components/settings/TerminalPane.tsx index b13ce6b76..67d2b290f 100644 --- a/src/renderer/src/components/settings/TerminalPane.tsx +++ b/src/renderer/src/components/settings/TerminalPane.tsx @@ -657,6 +657,58 @@ export function TerminalPane({ ) : null} + +
+ +

+ Sets{' '} + FORCE_HYPERLINK=1 in + every spawned terminal so tools like ls, git, and{' '} + eza emit OSC-8 clickable links. Disable if your shell startup feels slow + — heavy setups (oh-my-zsh, powerlevel10k, nvm, pyenv, conda) can take measurably + longer with this on. Only affects newly spawned terminals. +

+
+ +
+ {isMac ? (