Skip to content

Webview panel creation is slow (300ms-1s+)  #13

@SunYanbox

Description

@SunYanbox

Description

Both the one-shot PR creation and step-by-step PR webview panels take noticeably long to open (estimated 300ms to 1s+), hurting UX.

Root Causes

Looking at src/inputService.ts:

  1. Large inline HTML payload — All four webview HTML templates (getWebviewHtml, getStepByStepHtml, getAddCommitHtml, getFinalizePrHtml) inline ~250 lines of CSS each. getWebviewHtml and getAddCommitHtml also render one DOM entry per changed file, generating substantial markup when there are many files.

  2. Full diff renderer included upfront — The diff-view CSS, JS rendering logic, and inline styles are loaded even though most users won't expand diffs immediately.

  3. VSCode Webview overheadcreateWebviewPanel + setting panel.webview.html with a large string is inherently slow on the extension host. String concatenation via template literals blocks the JS thread.

  4. Synchronous HTML generationgetWebviewHtml() runs synchronously with all files rendered eagerly. With 50+ changed files, the template literal alone takes non-trivial time.

Affected Code

  • src/inputService.ts — all get*Html() functions (lines 26-528, 686-879, 881-1246, 1248-1412)
  • Called via createWebviewPanel in collectInputs() (line 537) and collectStepByStepInputs() (line 1421)

Suggested Solution

  1. Lazy-load diff CSS/JS — only inject diff-related styles and scripts when the user double-clicks to expand a file diff
  2. Minimize inline CSS — extract shared styles or reduce duplication across the four templates
  3. Virtualized file list — when there are 50+ files, render only the visible ones and use scroll event to render more
  4. Async HTML generation — use setTimeout(0) to yield to the UI thread between template chunks
  5. Consider a single shared webview with routing instead of 4 separate panel types, so the HTML/CSS is loaded once

No implementation required — design discussion only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions