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 ? (