Skip to content

feat(installer): auto-install WebView2 Runtime during Windows setup#3120

Open
yyyzl wants to merge 2 commits intoagentscope-ai:mainfrom
yyyzl:feat/installer-webview2-auto-install
Open

feat(installer): auto-install WebView2 Runtime during Windows setup#3120
yyyzl wants to merge 2 commits intoagentscope-ai:mainfrom
yyyzl:feat/installer-webview2-auto-install

Conversation

@yyyzl
Copy link
Copy Markdown
Contributor

@yyyzl yyyzl commented Apr 8, 2026

Description

Follow-up to #3119. While #3119 adds a runtime fail-fast check that turns the silent white-screen into a clear error message, this PR goes one step further by automatically installing WebView2 Runtime during the Windows NSIS installer, so most users never encounter the error at all.

How it works:

  1. Before installing CoPaw files, a hidden NSIS section checks the Windows registry for WebView2 Runtime (same 3 locations + 0.0.0.0 filtering as desktop_cmd.py)
  2. If WebView2 is already installed → skip (log "already installed, skipping")
  3. If missing → download the official Microsoft Evergreen Bootstrapper (~1.8 MB) via NSISdl::download and run it with /silent /install
  4. If the download fails (e.g. no network) → show a MessageBox directing the user to install manually

Key design decisions:

  • No admin required — the bootstrapper supports per-user install, matching the existing RequestExecutionLevel user in the NSIS config
  • Non-blocking — if WebView2 install fails, CoPaw installation still proceeds; the runtime check from fix(desktop): fail fast when WebView2 is unavailable on Windows #3119 will catch it at launch
  • Defense in depth — installer auto-install (preventive) + runtime detection (safety net) cover all scenarios: new installs, pip installs, post-install WebView2 removal/damage

Related Issue: Relates to #3119

Security Considerations: The bootstrapper is downloaded from Microsoft's official redirect URL (go.microsoft.com/fwlink/p/?LinkId=2124703). No third-party sources.

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. With WebView2 present — installer should log "WebView2 Runtime already installed, skipping" in the detail panel and proceed normally
  2. Without WebView2 — installer should download the bootstrapper, install silently, then proceed to install CoPaw files
  3. Without network — installer should show a MessageBox with manual install instructions and continue installing CoPaw
  4. CI build — the desktop-release.yml workflow uses negrutiu/nsis-install@v2 which includes NSISdl plugin; makensis should compile successfully

Recommended test environment: Alibaba Cloud Wuying (无影云电脑) or a clean Windows VM without Edge/WebView2.

Local Verification Evidence

pre-commit run --all-files
# Passed (NSIS files are not checked by pre-commit)

Additional Notes

  • The WebView2 GUID and registry locations are intentionally kept in sync with src/copaw/cli/desktop_cmd.py — both use {F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}
  • NSISdl is a built-in NSIS plugin, no extra dependencies needed
  • The hidden section prefix (-WebView2) ensures it runs automatically without appearing in the component selection UI

Copilot AI review requested due to automatic review settings April 8, 2026 17:01
@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.

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 adds automated detection and installation of the WebView2 Runtime to the NSIS installer script. The review identified several critical issues: the registry detection logic fails to account for 64-bit registry redirection, the use of the NSISdl plugin is incompatible with the provided HTTPS/redirected URL, and the installer fails to validate the exit code of the WebView2 bootstrapper. It is recommended to use SetRegView for registry checks, switch to the inetc plugin for secure downloads, and implement explicit exit code validation to ensure the runtime is correctly installed.

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

Adds a Windows installer-time safety measure to reduce first-run failures of CoPaw Desktop by ensuring the Microsoft Edge WebView2 Runtime is present during NSIS setup.

Changes:

  • Adds WebView2 Runtime registry detection to the NSIS installer.
  • If missing, downloads Microsoft’s Evergreen WebView2 bootstrapper and runs a silent install.
  • If download fails, shows a manual-install MessageBox and continues installing CoPaw.

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

@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 🙏 Same as #3119 — bot feedback addressed in ab132b7, clean merge onto latest main. Let me know if you'd like me to split or adjust anything. Thanks!

@celestialhorse51D
Copy link
Copy Markdown
Collaborator

Currently, when the code detects that WebView2 is missing or the installation has failed, it simply displays an English error message. Clicking “OK” causes the installation of the main program to proceed immediately. This approach poses a significant risk to the user experience, and we recommend optimizing the error messaging and workflow.

⚠️ Problem Analysis

  • Language Barrier: English prompts are not user-friendly for Chinese users and may cause them to overlook critical error messages due to language barriers.
  • Unclear Consequences: Users may mistakenly believe the installation process has completed successfully, but will encounter a “blank screen” and be unable to use the software upon launch. This can easily lead users to misjudge the situation as a serious bug in the software itself, negatively impacting the user experience.

💡 Recommended Fix

We recommend modifying the MessageBox prompt content and interaction logic by selecting one of the following two solutions to clearly inform users of the risks and provide a solution:

Solution 1: Interactive Guidance

  • Logic: Replace the current single-button prompt with a “Yes/No” dual-button interaction.
  • Process:
    1. Step 1 (Inform of Consequences and Ask): The pop-up clearly informs the user that the system is missing the WebView2 component and explains that failure to install it will prevent the software from running (resulting in a blank screen). Ask the user, “Do you still want to continue with the installation?”
    2. Step 2 (Follow-up Guidance):
      • If the user selects “Yes” (continue installation): The installer continues, but on the installation completion page or in a subsequent pop-up, the user is reminded again that they must manually download WebView2, and a download link is provided.
      • If the user selects “No”: Terminate the installer.

Option 2: Forced Blocking Mode

  • Logic: When WebView2 is not detected on the system, the installation is immediately and forcibly terminated; the user is no longer allowed to click “OK” to continue.
  • Process:
    • Pop-up prompt: “WebView2 runtime is not installed on your system. CoPaw Desktop cannot run. Please manually install WebView2 and try again.”
    • After clicking “OK,” the installation process is immediately terminated by calling Abort.

@yyyzl
Copy link
Copy Markdown
Contributor Author

yyyzl commented Apr 12, 2026

感谢反馈,这个问题确实存在 👍

我倾向于采用方案一(交互引导),理由:

  1. 有些用户可能在离线环境下先安装主程序,之后再单独装 WebView2,强制阻断会让这种场景无法操作
  2. 用户已经下载了安装包,直接终止安装体验也不好
  3. 方案一既能清楚告知后果(白屏风险),又把选择权留给用户

具体改动计划:

  • 两处 MessageBoxMB_OK 改为 MB_YESNO,文案改为中文,明确说明不装 WebView2 会导致白屏
  • 选「否」调用 Abort 终止安装
  • 选「是」继续安装,安装完成后再弹一次提醒,附上 WebView2 下载链接

如果你对这个方案没有补充意见,我这边就开始改了。

Copilot AI review requested due to automatic review settings April 12, 2026 14:45
@yyyzl
Copy link
Copy Markdown
Contributor Author

yyyzl commented Apr 12, 2026

已提交修复:b4e0ad9

改动内容:

  • 两处 MessageBoxMB_OK 英文改为 MB_YESNO 中文,明确告知白屏风险
  • 用户选「否」→ 终止安装;选「是」→ 继续安装
  • 安装完成后如果 WebView2 未成功安装,弹窗提醒并附中文下载链接

请 review,如有需要调整的地方请随时提出。

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 1 out of 1 changed files in this pull request and generated 2 comments.


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

Detect WebView2 Runtime via registry before installing CoPaw Desktop.
If missing, download the official Microsoft Bootstrapper (~1.8 MB) and
run it silently — no admin rights needed since the installer already
uses per-user installation.  If the download fails (e.g. no network),
a message box directs the user to install manually.

This complements the runtime fail-fast check in desktop_cmd.py so that
most users never see the "WebView2 not found" error at launch time.
Copilot AI review requested due to automatic review settings April 12, 2026 16:42
@yyyzl yyyzl force-pushed the feat/installer-webview2-auto-install branch from 63c515a to c791a84 Compare April 12, 2026 16:42
@yyyzl
Copy link
Copy Markdown
Contributor Author

yyyzl commented Apr 12, 2026

@celestialhorse51D Rebased onto latest main — adapted all changes for the CoPaw → QwenPaw rebranding (#3285):

  • Old copaw_desktop.nsi → new desktop.nsi (matching the rename in Refactor: CoPaw is Officially Rebranding to QwenPaw #3285)
  • All user-facing strings updated: "CoPaw Desktop" → "QwenPaw Desktop"
  • All COPAW_VERSIONQWENPAW_VERSION, install paths/registry keys updated accordingly
  • WebView2 detection + auto-install logic and Chinese interactive prompts (from your feedback) are preserved as-is

The 4 previous commits were consolidated into a single commit (c791a84) during rebase since they all modified the same file. Please re-review when you get a chance. Thanks!

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 1 out of 1 changed files in this pull request and generated 3 comments.


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

…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
@yyyzl
Copy link
Copy Markdown
Contributor Author

yyyzl commented Apr 12, 2026

@celestialhorse51D New commit d76eafd — based on Copilot feedback, improved the WebView2 install verification:

  • After running the bootstrapper, now re-runs registry detection to check actual WebView2 presence instead of relying solely on exit code (avoids false warnings for "reboot required" cases)
  • Post-install reminder also re-checks before showing, so users with a successful install are not unnecessarily warned

No changes to the Chinese interactive prompt logic from your earlier feedback.

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 Under Review

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants