From 5519dcd18ac0c9da4be028fd167813c3eec0c752 Mon Sep 17 00:00:00 2001 From: 0xMink Date: Sun, 8 Feb 2026 17:35:23 -0500 Subject: [PATCH] perf(refactor): consolidate getState calls in resolveWebviewView Replace three separate this.getState().then() calls with a single await this.getState() and destructuring. This avoids running the full getState() method (CloudService calls, ContextProxy reads, etc.) three times during webview view resolution. --- src/core/webview/ClineProvider.ts | 50 ++++++++++++++----------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index fc15a8dd5c..54b5c42348 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -747,35 +747,29 @@ export class ClineProvider // Initialize out-of-scope variables that need to receive persistent // global state values. - this.getState().then( - ({ - terminalShellIntegrationTimeout = Terminal.defaultShellIntegrationTimeout, - terminalShellIntegrationDisabled = false, - terminalCommandDelay = 0, - terminalZshClearEolMark = true, - terminalZshOhMy = false, - terminalZshP10k = false, - terminalPowershellCounter = false, - terminalZdotdir = false, - }) => { - Terminal.setShellIntegrationTimeout(terminalShellIntegrationTimeout) - Terminal.setShellIntegrationDisabled(terminalShellIntegrationDisabled) - Terminal.setCommandDelay(terminalCommandDelay) - Terminal.setTerminalZshClearEolMark(terminalZshClearEolMark) - Terminal.setTerminalZshOhMy(terminalZshOhMy) - Terminal.setTerminalZshP10k(terminalZshP10k) - Terminal.setPowershellCounter(terminalPowershellCounter) - Terminal.setTerminalZdotdir(terminalZdotdir) - }, - ) - - this.getState().then(({ ttsEnabled }) => { - setTtsEnabled(ttsEnabled ?? false) - }) + const { + terminalShellIntegrationTimeout = Terminal.defaultShellIntegrationTimeout, + terminalShellIntegrationDisabled = false, + terminalCommandDelay = 0, + terminalZshClearEolMark = true, + terminalZshOhMy = false, + terminalZshP10k = false, + terminalPowershellCounter = false, + terminalZdotdir = false, + ttsEnabled, + ttsSpeed, + } = await this.getState() - this.getState().then(({ ttsSpeed }) => { - setTtsSpeed(ttsSpeed ?? 1) - }) + Terminal.setShellIntegrationTimeout(terminalShellIntegrationTimeout) + Terminal.setShellIntegrationDisabled(terminalShellIntegrationDisabled) + Terminal.setCommandDelay(terminalCommandDelay) + Terminal.setTerminalZshClearEolMark(terminalZshClearEolMark) + Terminal.setTerminalZshOhMy(terminalZshOhMy) + Terminal.setTerminalZshP10k(terminalZshP10k) + Terminal.setPowershellCounter(terminalPowershellCounter) + Terminal.setTerminalZdotdir(terminalZdotdir) + setTtsEnabled(ttsEnabled ?? false) + setTtsSpeed(ttsSpeed ?? 1) // Set up webview options with proper resource roots const resourceRoots = [this.contextProxy.extensionUri]