Skip to content

Commit 5519dcd

Browse files
committed
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.
1 parent 12cddc9 commit 5519dcd

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -747,35 +747,29 @@ export class ClineProvider
747747

748748
// Initialize out-of-scope variables that need to receive persistent
749749
// global state values.
750-
this.getState().then(
751-
({
752-
terminalShellIntegrationTimeout = Terminal.defaultShellIntegrationTimeout,
753-
terminalShellIntegrationDisabled = false,
754-
terminalCommandDelay = 0,
755-
terminalZshClearEolMark = true,
756-
terminalZshOhMy = false,
757-
terminalZshP10k = false,
758-
terminalPowershellCounter = false,
759-
terminalZdotdir = false,
760-
}) => {
761-
Terminal.setShellIntegrationTimeout(terminalShellIntegrationTimeout)
762-
Terminal.setShellIntegrationDisabled(terminalShellIntegrationDisabled)
763-
Terminal.setCommandDelay(terminalCommandDelay)
764-
Terminal.setTerminalZshClearEolMark(terminalZshClearEolMark)
765-
Terminal.setTerminalZshOhMy(terminalZshOhMy)
766-
Terminal.setTerminalZshP10k(terminalZshP10k)
767-
Terminal.setPowershellCounter(terminalPowershellCounter)
768-
Terminal.setTerminalZdotdir(terminalZdotdir)
769-
},
770-
)
771-
772-
this.getState().then(({ ttsEnabled }) => {
773-
setTtsEnabled(ttsEnabled ?? false)
774-
})
750+
const {
751+
terminalShellIntegrationTimeout = Terminal.defaultShellIntegrationTimeout,
752+
terminalShellIntegrationDisabled = false,
753+
terminalCommandDelay = 0,
754+
terminalZshClearEolMark = true,
755+
terminalZshOhMy = false,
756+
terminalZshP10k = false,
757+
terminalPowershellCounter = false,
758+
terminalZdotdir = false,
759+
ttsEnabled,
760+
ttsSpeed,
761+
} = await this.getState()
775762

776-
this.getState().then(({ ttsSpeed }) => {
777-
setTtsSpeed(ttsSpeed ?? 1)
778-
})
763+
Terminal.setShellIntegrationTimeout(terminalShellIntegrationTimeout)
764+
Terminal.setShellIntegrationDisabled(terminalShellIntegrationDisabled)
765+
Terminal.setCommandDelay(terminalCommandDelay)
766+
Terminal.setTerminalZshClearEolMark(terminalZshClearEolMark)
767+
Terminal.setTerminalZshOhMy(terminalZshOhMy)
768+
Terminal.setTerminalZshP10k(terminalZshP10k)
769+
Terminal.setPowershellCounter(terminalPowershellCounter)
770+
Terminal.setTerminalZdotdir(terminalZdotdir)
771+
setTtsEnabled(ttsEnabled ?? false)
772+
setTtsSpeed(ttsSpeed ?? 1)
779773

780774
// Set up webview options with proper resource roots
781775
const resourceRoots = [this.contextProxy.extensionUri]

0 commit comments

Comments
 (0)