From d7f431d9cff6c4eae6f52f0fac07f162a3369047 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:47:25 -0700 Subject: [PATCH] Re-enable WebGL for remote-runtime terminals (#5048) PR #4946 forced terminalGpuAcceleration to 'off' whenever a remote runtime environment is active, as a conservative workaround alongside the real fixes (CSS anchor-name encoding and rebuilding the WebGL renderer after replay bytes parse). That left every remote-runtime terminal on the slower DOM renderer even though the post-replay rebuildPaneWebgl already covers the snapshot-after-attach race. Remove the forced-off resolver so remote-runtime panes honor the user GPU setting again. The snapshot path (onSnapshot -> processData with replayingBufferedData -> onReplayData -> rebuildPaneWebgl after parse) keeps the glyph atlas in sync, and attachWebgl re-checks all guards (gpuRenderingEnabled, deferred attachment, context loss) on rebuild. Co-authored-by: Orca --- .../use-terminal-pane-lifecycle.test.ts | 19 ------------ .../use-terminal-pane-lifecycle.ts | 31 ++++--------------- 2 files changed, 6 insertions(+), 44 deletions(-) diff --git a/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts b/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts index 8aee66514eb..8c7400939da 100644 --- a/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts +++ b/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts @@ -1,6 +1,5 @@ import { describe, expect, it, vi } from 'vitest' import { - resolveTerminalGpuAccelerationForRuntime, shouldDetachPaneTransportOnUnmount, splitPaneWithOneShotStartup, suppressIntentionalPaneCloseExit @@ -126,24 +125,6 @@ describe('shouldDetachPaneTransportOnUnmount', () => { }) }) -describe('resolveTerminalGpuAccelerationForRuntime', () => { - it('forces DOM rendering while a remote runtime is active', () => { - expect(resolveTerminalGpuAccelerationForRuntime('env-1', 'on')).toBe('off') - }) - - it('honors the user GPU setting for local terminals', () => { - expect(resolveTerminalGpuAccelerationForRuntime(null, 'on')).toBe('on') - }) - - it('defaults local terminals to auto when the setting is missing', () => { - expect(resolveTerminalGpuAccelerationForRuntime(null, undefined)).toBe('auto') - }) - - it('treats blank runtime ids as local', () => { - expect(resolveTerminalGpuAccelerationForRuntime(' ', 'auto')).toBe('auto') - }) -}) - describe('suppressIntentionalPaneCloseExit', () => { it('suppresses the pane PTY exit before intentional close teardown destroys the transport', () => { const suppressPtyExit = vi.fn() diff --git a/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts b/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts index ecb8e78276e..7f721fc0d9f 100644 --- a/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts +++ b/src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts @@ -310,16 +310,6 @@ export function shouldDetachPaneTransportOnUnmount(args: { ) } -export function resolveTerminalGpuAccelerationForRuntime( - activeRuntimeEnvironmentId: GlobalSettings['activeRuntimeEnvironmentId'] | null | undefined, - terminalGpuAcceleration: GlobalSettings['terminalGpuAcceleration'] | null | undefined -): GlobalSettings['terminalGpuAcceleration'] { - if (activeRuntimeEnvironmentId?.trim()) { - return 'off' - } - return terminalGpuAcceleration ?? 'auto' -} - export function useTerminalPaneLifecycle({ tabId, worktreeId, @@ -1058,12 +1048,10 @@ export function useTerminalPaneLifecycle({ // so PTYs survive navigation. Creating WebGL for those offscreen panes // still consumes Chromium's context budget and can blank visible panes. initialRenderingSuspended: !isVisibleRef.current, - // Why: remote-runtime snapshots arrive after pane open; WebGL can hold an - // empty atlas/canvas while the server-side buffer is already populated. - terminalGpuAcceleration: resolveTerminalGpuAccelerationForRuntime( - settingsRef.current?.activeRuntimeEnvironmentId, - settingsRef.current?.terminalGpuAcceleration - ), + // Why: remote-runtime panes honor the user GPU setting too — snapshots + // that arrive after WebGL attaches are handled by the post-replay + // rebuildPaneWebgl in pty-connection's replay callback. + terminalGpuAcceleration: settingsRef.current?.terminalGpuAcceleration ?? 'auto', debugLabel: `tab:${tabId}/wt:${worktreeId}` }) @@ -1382,15 +1370,8 @@ export function useTerminalPaneLifecycle({ }, [settings, systemPrefersDark, effectiveMacOptionAsAlt]) useEffect(() => { - // Why: remote-runtime panes stay on DOM rendering; local panes still honor - // the user's GPU setting and can switch live when settings change. - managerRef.current?.setTerminalGpuAcceleration( - resolveTerminalGpuAccelerationForRuntime( - settings?.activeRuntimeEnvironmentId, - settings?.terminalGpuAcceleration - ) - ) - }, [settings?.activeRuntimeEnvironmentId, settings?.terminalGpuAcceleration, managerRef]) + managerRef.current?.setTerminalGpuAcceleration(settings?.terminalGpuAcceleration ?? 'auto') + }, [settings?.terminalGpuAcceleration, managerRef]) useEffect(() => { const manager = managerRef.current