feat(terminal): expose FORCE_HYPERLINK as a user setting (default on) (#963)

* 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
This commit is contained in:
Neil
2026-04-22 18:20:57 -07:00
committed by GitHub
parent 68e8e119b7
commit fc64baf7d1
9 changed files with 129 additions and 3 deletions
@@ -84,6 +84,7 @@ function createSettings(overrides: Partial<GlobalSettings> = {}): GlobalSettings
terminalMacOptionAsAltMigrated: true,
experimentalTerminalDaemon: false,
experimentalTerminalDaemonNoticeShown: false,
terminalForceHyperlink: true,
...overrides
}
}
+1
View File
@@ -78,6 +78,7 @@ function createSettings(overrides: Partial<GlobalSettings> = {}): GlobalSettings
terminalMacOptionAsAltMigrated: true,
experimentalTerminalDaemon: false,
experimentalTerminalDaemonNoticeShown: false,
terminalForceHyperlink: true,
...overrides
}
}
+1
View File
@@ -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
@@ -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
+22 -2
View File
@@ -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<string, string>
// 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.
@@ -657,6 +657,58 @@ export function TerminalPane({
) : null}
</SearchableSetting>
<SearchableSetting
title="Force Hyperlink Escapes"
description="Set FORCE_HYPERLINK=1 in every terminal so tools emit OSC-8 clickable links. Turn off if your shell startup is slow."
keywords={[
'terminal',
'hyperlink',
'link',
'osc',
'osc8',
'osc-8',
'force_hyperlink',
'slow',
'startup',
'zsh',
'zshrc',
'oh-my-zsh',
'p10k',
'powerlevel10k'
]}
className="flex items-center justify-between gap-4 px-1 py-2"
>
<div className="space-y-0.5">
<Label>Force Hyperlink Escapes</Label>
<p className="text-xs text-muted-foreground">
Sets{' '}
<code className="rounded bg-muted px-1 py-0.5 text-[11px]">FORCE_HYPERLINK=1</code> in
every spawned terminal so tools like <code>ls</code>, <code>git</code>, and{' '}
<code>eza</code> 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.
</p>
</div>
<button
role="switch"
aria-checked={settings.terminalForceHyperlink}
onClick={() =>
updateSettings({
terminalForceHyperlink: !settings.terminalForceHyperlink
})
}
className={`relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors ${
settings.terminalForceHyperlink ? 'bg-foreground' : 'bg-muted-foreground/30'
}`}
>
<span
className={`pointer-events-none block size-3.5 rounded-full bg-background shadow-sm transition-transform ${
settings.terminalForceHyperlink ? 'translate-x-4' : 'translate-x-0.5'
}`}
/>
</button>
</SearchableSetting>
{isMac ? (
<SearchableSetting
title="Option as Alt"
@@ -108,6 +108,27 @@ export const TERMINAL_ADVANCED_SEARCH_ENTRIES: SettingsSearchEntry[] = [
title: 'Scrollback Size',
description: 'Maximum terminal scrollback buffer size.',
keywords: ['terminal', 'scrollback', 'buffer', 'memory']
},
{
title: 'Force Hyperlink Escapes',
description:
'Set FORCE_HYPERLINK=1 in every terminal so tools emit OSC-8 clickable links. Turn off if your shell startup is slow.',
keywords: [
'terminal',
'hyperlink',
'link',
'osc',
'osc8',
'osc-8',
'force_hyperlink',
'slow',
'startup',
'zsh',
'zshrc',
'oh-my-zsh',
'p10k',
'powerlevel10k'
]
}
]
+6 -1
View File
@@ -153,7 +153,12 @@ export function getDefaultSettings(homedir: string): GlobalSettings {
terminalMacOptionAsAlt: 'auto',
terminalMacOptionAsAltMigrated: false,
experimentalTerminalDaemon: false,
experimentalTerminalDaemonNoticeShown: false
experimentalTerminalDaemonNoticeShown: false,
// Why: keep the historical default (on) so no existing user's terminal
// loses clickable-link emission on upgrade. Users with heavy zshrc setups
// can disable it from Settings → Terminal → Advanced to reclaim startup
// time.
terminalForceHyperlink: true
}
}
+9
View File
@@ -714,6 +714,15 @@ export type GlobalSettings = {
* toast shown to users upgrading from v1.3.0 (where the daemon was on by
* default). Set to true the first time the toast fires so it never repeats. */
experimentalTerminalDaemonNoticeShown: boolean
/** When true, Orca sets FORCE_HYPERLINK=1 in every spawned PTY's env. That
* makes modern CLIs (oh-my-zsh's supports_hyperlinks(), coreutils, the Rust
* supports-hyperlinks crate, etc.) emit OSC-8 hyperlink escapes even when
* they would otherwise skip them. Defaults to true to preserve prior
* behavior, but users with heavy shell init (large oh-my-zsh / p10k / nvm /
* pyenv / conda setups) can measurably speed up terminal start by turning
* this off — the extra branching and escape emission across the many
* subshells fired during rc init can multiply startup time. */
terminalForceHyperlink: boolean
}
export type NotificationEventSource = 'agent-task-complete' | 'terminal-bell' | 'test'