Skip to content

fix(desktop): fail fast when WebView2 is unavailable on Windows#3119

Open
yyyzl wants to merge 5 commits intoagentscope-ai:mainfrom
yyyzl:fix/windows-webview2-white-screen
Open

fix(desktop): fail fast when WebView2 is unavailable on Windows#3119
yyyzl wants to merge 5 commits intoagentscope-ai:mainfrom
yyyzl:fix/windows-webview2-white-screen

Conversation

@yyyzl
Copy link
Copy Markdown
Contributor

@yyyzl yyyzl commented Apr 8, 2026

Description

On a small number of Windows machines, launching CoPaw Desktop shows a blank white window with no error feedback. The root cause is a missing or damaged Microsoft Edge WebView2 Runtime — without it, pywebview silently falls back to the legacy MSHTML/IE renderer which cannot render the Vite-built frontend.

This PR turns that silent white-screen into a fail-fast with an actionable error message:

  • Detects WebView2 Runtime presence via Windows registry before launching
  • If missing: shows a native MessageBox error dialog + stderr message with a download link
  • Forces gui="edgechromium" in webview.start() to prevent silent MSHTML fallback
  • Wraps webview.start() exceptions with a clear WebView2-specific error on Windows
  • Updates troubleshooting docs (EN + ZH) to cover damaged/repair scenarios

Verified on Alibaba Cloud Wuying (无影云电脑) where WebView2 was initially missing — after this change the error dialog appeared immediately with the download link, and after installing WebView2 the app launched normally.

Related Issue: N/A (discovered during user testing on cloud desktops)

Security Considerations: N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactoring

Component(s) Affected

  • Core / Backend (app, agents, config, providers, utils, local_models)
  • Console (frontend web UI)
  • Channels (DingTalk, Feishu, QQ, Discord, iMessage, etc.)
  • Skills
  • CLI
  • Documentation (website)
  • Tests
  • CI/CD
  • Scripts / Deploy

Checklist

  • I ran pre-commit run --all-files locally and it passes
  • If pre-commit auto-fixed files, I committed those changes and reran checks
  • I ran tests locally (pytest or as relevant) and they pass
  • Documentation updated (if needed)
  • Ready for review

Testing

  1. Unit tests — 4 new tests in tests/unit/cli/test_cli_desktop.py:

    • test_detect_windows_webview2_runtime_version_returns_first_valid — skips 0.0.0.0, returns first real version
    • test_detect_windows_webview2_runtime_version_returns_none — returns None when no valid version found
    • test_ensure_desktop_webview_available_requires_webview2_runtime — exits with code 1 and shows MessageBox when WebView2 missing
    • test_start_desktop_window_forces_edgechromium_on_windows — verifies gui="edgechromium" is passed on Windows
  2. Manual verification — Tested on Alibaba Cloud Wuying (无影云电脑), a Windows environment without WebView2 pre-installed:

    • Before fix: blank white window, no error
    • After fix: native error dialog with download link appears immediately
    • After installing WebView2: app launches normally

Local Verification Evidence

pytest tests/unit/cli/test_cli_desktop.py -v
# 4 passed

pre-commit run --all-files
# Passed

Additional Notes

  • The WebView2 Runtime GUID {F3017226-FE2A-4295-8BDF-00C3A9A7E4C5} is the official Evergreen Runtime identifier from Microsoft
  • Registry detection covers all three standard locations: HKLM WOW6432Node, HKLM native, and HKCU
  • Version 0.0.0.0 is filtered out as it indicates an uninstalled/placeholder state
  • A follow-up PR may add WebView2 auto-install to the NSIS installer for an even smoother first-run experience

Copilot AI review requested due to automatic review settings April 8, 2026 16:57
@github-project-automation github-project-automation bot moved this to Todo in QwenPaw Apr 8, 2026
@github-actions github-actions bot added the first-time-contributor PR created by a first time contributor label Apr 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Welcome to CoPaw! 🐾

Hi @yyyzl, thank you for your first Pull Request! 🎉

🙌 Join Developer Community

Thanks so much for your contribution! We'd love to invite you to join the official CoPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page:
https://copaw.agentscope.io/docs/community

We truly appreciate your enthusiasm—and look forward to your future contributions! 😊

We'll review your PR soon.


Tip

⭐ If you find CoPaw useful, please give us a Star!

Star CoPaw

Staying ahead

Star CoPaw on GitHub and be instantly notified of new releases.

Your star helps more developers discover this project! 🐾

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Windows CoPaw Desktop launcher experience by detecting missing/damaged Microsoft Edge WebView2 Runtime up-front and failing fast with an actionable, user-visible error instead of silently showing a blank white window.

Changes:

  • Add Windows registry detection for WebView2 Runtime and show a native MessageBox + stderr guidance when unavailable.
  • Force pywebview to use gui="edgechromium" on Windows and wrap webview.start() failures with WebView2-specific remediation messaging.
  • Update Desktop troubleshooting docs (EN/ZH) and add unit tests covering registry detection, fail-fast behavior, and forced GUI selection.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/copaw/cli/desktop_cmd.py Adds WebView2 runtime detection, fail-fast abort helper, and forces EdgeChromium backend on Windows.
tests/unit/cli/test_cli_desktop.py Adds unit tests for WebView2 detection, fail-fast behavior, and gui="edgechromium" enforcement.
website/public/docs/desktop.en.md Updates troubleshooting guidance for missing/damaged WebView2 and points users to Debug launcher output.
website/public/docs/desktop.zh.md Same troubleshooting updates as EN, localized for ZH readers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces robust checks for the Microsoft Edge WebView2 Runtime on Windows to prevent silent failures or blank windows when launching the desktop application. Key additions include registry-based runtime detection, native error dialogs for missing dependencies, and forcing the edgechromium renderer on Windows. The changes also include comprehensive unit tests for the new utility functions and updated documentation for troubleshooting. I have no feedback to provide as there were no review comments to evaluate.

@xieyxclack xieyxclack requested a review from rayrayraykk April 9, 2026 02:33
@yyyzl
Copy link
Copy Markdown
Contributor Author

yyyzl commented Apr 10, 2026

@rayrayraykk Friendly ping 🙏 This PR has been open for a few days and is ready for review — all bot comments have been addressed, and I just verified it still merges cleanly onto the latest main. Whenever you have a moment, take a look? Thanks!

yyyzl added 2 commits April 13, 2026 00:49
The generic _abort_desktop_launch call after the Windows-specific
if-block was unreachable on Windows because _abort_desktop_launch
always raises SystemExit.  Restructure as if/else so the control
flow is explicit.
Copilot AI review requested due to automatic review settings April 12, 2026 16:50
@yyyzl yyyzl force-pushed the fix/windows-webview2-white-screen branch from 220c185 to 5e51272 Compare April 12, 2026 16:50
@yyyzl yyyzl requested a deployment to maintainer-approved April 12, 2026 16:50 — with GitHub Actions Waiting
@yyyzl
Copy link
Copy Markdown
Contributor Author

yyyzl commented Apr 12, 2026

Rebased onto latest main to adapt for the CoPaw → QwenPaw rebranding (#3285):

  • src/copaw/cli/desktop_cmd.pysrc/qwenpaw/cli/desktop_cmd.py (matching the rename in Refactor: CoPaw is Officially Rebranding to QwenPaw #3285)
  • All user-facing strings updated: "CoPaw Desktop" → "QwenPaw Desktop"
  • Test import updated: from copaw.clifrom qwenpaw.cli
  • Website docs adapted with QwenPaw branding

Both commits preserved cleanly.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

yyyzl added a commit to yyyzl/CoPaw that referenced this pull request Apr 12, 2026
…t code

- Re-run _DetectWebView2 after bootstrapper to check actual install state
  instead of relying solely on process exit code (which may be non-zero
  for reboot-required or other non-failure cases)
- Gate post-install reminder on actual WebView2 absence, not just $R9 flag
- Update GUID comment to reference agentscope-ai#3119 explicitly
- Wrap long line in error message to stay under 79 chars (flake8 E501)
- Fix black formatting in test assertion
- Add pylint disable for protected-access in test file
@yyyzl yyyzl requested a deployment to maintainer-approved April 12, 2026 16:58 — with GitHub Actions Waiting
Previous fix used black defaults (88), but project pre-commit uses
--line-length=79.
Copilot AI review requested due to automatic review settings April 12, 2026 17:06
@yyyzl yyyzl requested a deployment to maintainer-approved April 12, 2026 17:06 — with GitHub Actions Waiting
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Extract the duplicated WebView2 download URL + troubleshooting
guidance into _WEBVIEW2_TROUBLESHOOT_SUFFIX constant, reused by
both _ensure_desktop_webview_available() and the webview.start()
exception handler.
@yyyzl yyyzl requested a deployment to maintainer-approved April 12, 2026 17:17 — with GitHub Actions Waiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time-contributor PR created by a first time contributor

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants