Skip to content

docs(vscode): analyze webview tab vs sidebar performance differences#7303

Closed
kilo-code-bot[bot] wants to merge 1 commit into
mainfrom
analysis/webview-tab-vs-sidebar-performance
Closed

docs(vscode): analyze webview tab vs sidebar performance differences#7303
kilo-code-bot[bot] wants to merge 1 commit into
mainfrom
analysis/webview-tab-vs-sidebar-performance

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot Bot commented Mar 19, 2026

Summary

  • Adds a detailed analysis document investigating potential performance issues when the Kilo Code extension webview runs in an editor tab versus the default sidebar position
  • Identifies three compounding root causes: unthrottled per-token SSE streaming with no event coalescing, lack of visibility-aware message gating, and duplicate KiloProvider processing when both sidebar and tab are open
  • Provides prioritized recommendations from short-term (16ms event coalescing) to long-term (virtual scrolling, removing retainContextWhenHidden for non-critical panels)

Key Findings

  1. No event coalescing — Per-token postMessage calls during streaming overwhelm the webview. The codebase already documents this as a planned improvement in sdk-sse-adapter.ts:22-27.
  2. No visibility awareness — Neither the extension host nor the webview checks visibility before processing events. The sidebar gets implicit throttling from VS Code when hidden; the tab does not.
  3. Duplicate work — Opening Kilo in a tab while the sidebar is active creates two independent KiloProvider instances processing the same SSE events.
  4. No virtual scrolling — All messages rendered in DOM; wider tab viewport = more layout work per update.
  5. Identical code pathsresolveWebviewView() and resolveWebviewPanel() use the same HTML, bundle, and message handling — no tab-specific logic exists.

This is a research/analysis document only — no behavioral changes.

…erences

Investigates potential performance issues when the extension webview runs
in an editor tab compared to the default sidebar, identifying unthrottled
per-token streaming, lack of visibility-aware message gating, and duplicate
KiloProvider processing as the primary factors.

- `KiloProvider.postMessage()` (`src/KiloProvider.ts:2606-2622`) fires unconditionally regardless of whether the webview is visible
- The webview JS has no `visibilitychange` listener and no `document.hidden` checks
- `WebviewView` (sidebar) does not expose `onDidChangeViewState` -- the extension cannot detect sidebar visibility changes at all
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Sidebar visibility detection is described inconsistently

The recommendation section later points to WebviewView.onDidChangeVisibility, and this extension already targets VS Code ^1.108.0. Framing sidebar visibility changes as impossible turns this from "not implemented today" into "cannot be done", which changes the conclusion of finding #2.

Suggested change
- `WebviewView` (sidebar) does not expose `onDidChangeViewState` -- the extension cannot detect sidebar visibility changes at all
- `WebviewView` (sidebar) is not currently using visibility APIs, so sidebar updates are never gated on visibility


**Tab impact:** An editor tab typically occupies 2-4x the pixel area of the sidebar. Wider viewports mean:

- Text wraps less, producing taller rendered messages
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: This bullet describes the wrap behavior backwards

A wider viewport means lines wrap less, so each rendered message is typically shorter rather than taller.

Suggested change
- Text wraps less, producing taller rendered messages
- Text wraps less, producing shorter rendered messages

@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot Bot commented Mar 19, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/docs/infrastructure/webview-tab-vs-sidebar-performance.md 42 Finding #2 says sidebar visibility cannot be detected, but the same doc later recommends WebviewView.onDidChangeVisibility, so the analysis currently overstates the limitation.

SUGGESTION

File Line Issue
packages/kilo-vscode/docs/infrastructure/webview-tab-vs-sidebar-performance.md 76 The bullet says less wrapping makes messages taller, but a wider viewport usually makes each rendered message shorter.
Other Observations (not in diff)

No issues found in unchanged code that required summary-only notes.

Files Reviewed (1 files)
  • packages/kilo-vscode/docs/infrastructure/webview-tab-vs-sidebar-performance.md - 2 issues

Reviewed by gpt-5.4-20260305 · 437,344 tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant