Skip to content

[PERF] resolveWebviewView triggers redundant getState() calls (x3) #11319

@0xMink

Description

@0xMink

Summary

resolveWebviewView() in src/core/webview/ClineProvider.ts calls this.getState().then(...) three times to read terminal and TTS settings. Each call runs the full getState() path (including CloudService/ContextProxy reads), creating redundant work during view activation.

Grep: resolveWebviewView + this.getState().then

Impact: Eliminates ~2 redundant async getState() executions during view activation, reducing duplicate reads and ensuring a single consistent settings snapshot. Three separate calls can theoretically return different values if settings change mid-resolution, making this both a performance and a correctness concern.

Affected location

Search pattern: this.getState().then in resolveWebviewView

  • Terminal settings fetch (~line 756)
  • TTS enabled fetch (~line 778)
  • TTS speed fetch (~line 782)

Suggested fix

Consolidate into a single await this.getState() with destructuring. resolveWebviewView is already async, so this is consistent with the rest of the method.

Note: Preserve existing error-handling behavior when consolidating.

const {
    terminalShellIntegrationTimeout = Terminal.defaultShellIntegrationTimeout,
    terminalShellIntegrationDisabled = false,
    terminalCommandDelay = 0,
    terminalZshClearEolMark = true,
    terminalZshOhMy = false,
    terminalZshP10k = false,
    terminalPowershellCounter = false,
    terminalZdotdir = false,
    ttsEnabled,
    ttsSpeed,
} = await this.getState()

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)

Acceptance criteria

  • getState() is called once instead of three times during view resolution
  • Terminal and TTS settings are still applied correctly
  • No behavioral change (including error handling)

Problem: resolveWebviewView() triggers three redundant getState() calls during view resolution.

Context: Any user opening the Roo Code panel; duplicates cloud/context reads and can apply inconsistent settings if state changes mid-resolution.

Reproduction steps:

  1. Open the Roo Code panel (or reload VS Code)
  2. Add temporary logging/breakpoints around getState() to observe three invocations in resolveWebviewView

Expected result: One getState() execution; single snapshot applied.

Actual result: Three independent getState() executions.

App Version: v3.47.3

API Provider / Model Used: N/A (not provider-dependent)

Roadmap alignment: Enhanced User Experience (faster activation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions