Skip to content

Provider initialization hangs webview indefinitely when no provider is reachable #99

Description

@hellodk

Problem

When the configured provider (e.g., llamacpp) is unreachable, the extension hangs during loadProvider() initialization, leaving the webview showing "loading..." forever with no error feedback.

Users see an infinite loading bar with no way to know:

  • Which provider failed
  • Why it failed (network timeout, connection refused, etc.)
  • How to fix it

Root Cause

  • Provider initialization is synchronous and blocking
  • No timeout on provider connection attempts
  • Webview doesn't render until provider is ready
  • No error messaging path to webview

Solution

  1. Async, non-blocking initialization

    • Render webview immediately with "provider initializing..." state
    • Spawn provider connection in background with 5-second timeout
  2. Clear error messaging

    • Capture specific error (timeout, connection refused, auth failed, etc.)
    • Send detailed error to webview: "Provider llamacpp at http://192.168.1.24:21434 timed out after 5s"
  3. Recovery UI in webview

    • Show error with provider name and URL
    • Add "Retry", "Configure Provider", "Test Connection" buttons
    • Link to settings panel to change provider
  4. Graceful fallback

    • Try fallback providers if primary fails
    • Suggest using local ollama if available

Acceptance Criteria

  • Webview renders within 1 second (before provider is ready)
  • Provider initialization times out after 5 seconds max
  • Unreachable provider shows specific error in webview (not generic "loading...")
  • Error message includes provider name, URL, and timeout reason
  • User can retry, configure, or switch provider from error UI
  • Detailed logs in output panel for troubleshooting
  • All existing tests pass
  • E2E test: start with unreachable provider → see error → switch provider → works

Tests Required

  • Unit: provider timeout handling
  • Unit: error message formatting
  • Integration: webview error message delivery
  • E2E: unreachable provider → error UI → recovery

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions