Conversation
There was a problem hiding this comment.
Hey - 我发现了 1 个问题
面向 AI Agents 的提示
请根据本次代码审查中的评论进行修改:
## 单条评论
### 评论 1
<location> `.github/workflows/build.yml:134-135` </location>
<code_context>
+ shell: pwsh
+ run: |
+ # 优先使用 WebView2 Runtime,其次使用 Edge 安装目录
+ $wv2Base = "C:\Program Files (x86)\Microsoft\EdgeWebView\Application"
+ if (-not (Test-Path $wv2Base)) {
+ $wv2Base = "C:\Program Files (x86)\Microsoft\Edge\Application"
+ }
</code_context>
<issue_to_address>
**suggestion:** 建议同时检测 64 位的安装路径,以改进对 WebView2/Edge 的检测。
在某些系统上,WebView2/Edge 会安装在 `C:\Program Files\...`(64 位)而不是 `C:\Program Files (x86)\...` 下,因此如果仅检测 x86 路径,可能会错误地认为没有可用的 runtime。建议同时检查 `Program Files (x86)` 和 `Program Files` 两个目录,并在失败前从所有路径中选择发现的最新版本。
</issue_to_address>帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据反馈改进之后的评审。
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `.github/workflows/build.yml:134-135` </location>
<code_context>
+ shell: pwsh
+ run: |
+ # 优先使用 WebView2 Runtime,其次使用 Edge 安装目录
+ $wv2Base = "C:\Program Files (x86)\Microsoft\EdgeWebView\Application"
+ if (-not (Test-Path $wv2Base)) {
+ $wv2Base = "C:\Program Files (x86)\Microsoft\Edge\Application"
+ }
</code_context>
<issue_to_address>
**suggestion:** Consider also probing 64-bit installation paths to improve WebView2/Edge detection.
On some systems WebView2/Edge installs under `C:\Program Files\...` (64-bit) rather than `C:\Program Files (x86)\...`, so limiting detection to the x86 path can incorrectly report that no runtime is available. Consider checking both `Program Files (x86)` and `Program Files`, then selecting the newest version found across all paths before failing.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR adds support for a "fixed-webview" build variant that bundles a fixed version of the WebView2 runtime with the Windows x86_64 distribution. This allows users to run the application without needing to install or rely on the system-installed WebView2 runtime.
Changes:
- Modified startup logic to detect and use bundled WebView2 runtime from
webview2_runtimedirectory - Updated fallback behavior to only attempt system WebView2 installation when no bundled runtime is present
- Added CI workflow step to create fixed-webview build artifacts for Windows x86_64
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src-tauri/src/main.rs | Added detection logic for bundled WebView2 runtime directory and conditional system WebView2 installation |
| .github/workflows/build.yml | Added workflow steps to copy WebView2 runtime from GitHub Actions Windows runner and upload as separate artifact |
Comments suppressed due to low confidence (1)
.github/workflows/build.yml:130
- The fixed-webview variant is only built for x86_64 architecture. This asymmetry means aarch64 Windows users won't have access to a bundled WebView2 runtime. If this is intentional due to WebView2 availability or testing constraints on ARM64, consider adding a comment explaining why. Otherwise, consider enabling this for aarch64 as well, or document the limitation in the PR description.
if: matrix.arch == 'x86_64'
解决没有arm64的问题
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - 我发现了两个问题,并给出了一些整体反馈:
- 当前工作流会针对所有 Windows 架构都执行 WebView2 固定版本运行时的下载步骤,但注释指出 arm64 打包尚未支持;建议为该步骤以及
fixed-webview构件上传添加条件(例如if: matrix.arch == 'x86_64'),以避免在不支持的架构上出现失败或产生误导性的构件。 - WebView2 固定版本运行时的版本号目前是硬编码在工作流里的;建议把它提取到一个统一的 env/matrix 变量中(并考虑在构件名称或日志输出中复用它),这样以后升级版本时就不容易出错。
面向 AI 代理的提示词
Please address the comments from this code review:
## Overall Comments
- The workflow always runs the WebView2 fixed-runtime download for all Windows architectures, but the comment notes that arm64 packaging is not supported yet; consider guarding this step and the `fixed-webview` artifact upload with a condition (e.g. `if: matrix.arch == 'x86_64'`) to avoid failures or misleading artifacts for unsupported arches.
- The WebView2 fixed runtime version is currently hardcoded in the workflow; extracting it to a single env/matrix variable (and possibly reusing it in the artifact name or log output) would make future version bumps less error‑prone.
## Individual Comments
### Comment 1
<location> `.github/workflows/build.yml:134-136` </location>
<code_context>
+ run: |
+ $archMap = @{ 'x86_64' = 'x64'; 'aarch64' = 'arm64' }
+ $arch = $archMap['${{ matrix.arch }}']
+ $version = '133.0.3065.92'
+ $cabName = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab"
+ $uri = "https://github.com/westinyang/WebView2RuntimeArchive/releases/download/$version/$cabName"
+
+ Write-Host "Downloading $cabName ..."
</code_context>
<issue_to_address>
**🚨 issue (security):** Relying on a third-party GitHub mirror without integrity checks introduces supply-chain risk.
This downloads `westinyang/WebView2RuntimeArchive` artifacts without any integrity verification, so a compromise of that repo/release would inject a malicious WebView2 runtime into your CI artifacts. Please either fetch the runtime from an official Microsoft source or add a pinned checksum verification of the CAB before using it to mitigate this supply-chain risk.
</issue_to_address>
### Comment 2
<location> `.github/workflows/build.yml:129-135` </location>
<code_context>
+ - name: Download WebView2 Fixed Version Runtime
+ shell: pwsh
+ run: |
+ $archMap = @{ 'x86_64' = 'x64'; 'aarch64' = 'arm64' }
+ $arch = $archMap['${{ matrix.arch }}']
+ $version = '133.0.3065.92'
+ $cabName = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab"
</code_context>
<issue_to_address>
**suggestion:** Handle unknown architectures more defensively to avoid silent misconfiguration.
If `matrix.arch` ever changes (e.g. to `amd64`) or a new architecture is added, `$archMap[...]` will return `$null`, producing an invalid CAB name/URL and a confusing failure. Consider validating the key first and throwing a clear error when it’s missing:
```pwsh
$matrixArch = '${{ matrix.arch }}'
if (-not $archMap.ContainsKey($matrixArch)) {
throw "Unsupported architecture: $matrixArch"
}
$arch = $archMap[$matrixArch]
```
```suggestion
- name: Download WebView2 Fixed Version Runtime
shell: pwsh
run: |
$archMap = @{ 'x86_64' = 'x64'; 'aarch64' = 'arm64' }
$matrixArch = '${{ matrix.arch }}'
if (-not $archMap.ContainsKey($matrixArch)) {
throw "Unsupported architecture: $matrixArch"
}
$arch = $archMap[$matrixArch]
$version = '133.0.3065.92'
$cabName = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab"
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've found 2 issues, and left some high level feedback:
- The workflow always runs the WebView2 fixed-runtime download for all Windows architectures, but the comment notes that arm64 packaging is not supported yet; consider guarding this step and the
fixed-webviewartifact upload with a condition (e.g.if: matrix.arch == 'x86_64') to avoid failures or misleading artifacts for unsupported arches. - The WebView2 fixed runtime version is currently hardcoded in the workflow; extracting it to a single env/matrix variable (and possibly reusing it in the artifact name or log output) would make future version bumps less error‑prone.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The workflow always runs the WebView2 fixed-runtime download for all Windows architectures, but the comment notes that arm64 packaging is not supported yet; consider guarding this step and the `fixed-webview` artifact upload with a condition (e.g. `if: matrix.arch == 'x86_64'`) to avoid failures or misleading artifacts for unsupported arches.
- The WebView2 fixed runtime version is currently hardcoded in the workflow; extracting it to a single env/matrix variable (and possibly reusing it in the artifact name or log output) would make future version bumps less error‑prone.
## Individual Comments
### Comment 1
<location> `.github/workflows/build.yml:134-136` </location>
<code_context>
+ run: |
+ $archMap = @{ 'x86_64' = 'x64'; 'aarch64' = 'arm64' }
+ $arch = $archMap['${{ matrix.arch }}']
+ $version = '133.0.3065.92'
+ $cabName = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab"
+ $uri = "https://github.com/westinyang/WebView2RuntimeArchive/releases/download/$version/$cabName"
+
+ Write-Host "Downloading $cabName ..."
</code_context>
<issue_to_address>
**🚨 issue (security):** Relying on a third-party GitHub mirror without integrity checks introduces supply-chain risk.
This downloads `westinyang/WebView2RuntimeArchive` artifacts without any integrity verification, so a compromise of that repo/release would inject a malicious WebView2 runtime into your CI artifacts. Please either fetch the runtime from an official Microsoft source or add a pinned checksum verification of the CAB before using it to mitigate this supply-chain risk.
</issue_to_address>
### Comment 2
<location> `.github/workflows/build.yml:129-135` </location>
<code_context>
+ - name: Download WebView2 Fixed Version Runtime
+ shell: pwsh
+ run: |
+ $archMap = @{ 'x86_64' = 'x64'; 'aarch64' = 'arm64' }
+ $arch = $archMap['${{ matrix.arch }}']
+ $version = '133.0.3065.92'
+ $cabName = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab"
</code_context>
<issue_to_address>
**suggestion:** Handle unknown architectures more defensively to avoid silent misconfiguration.
If `matrix.arch` ever changes (e.g. to `amd64`) or a new architecture is added, `$archMap[...]` will return `$null`, producing an invalid CAB name/URL and a confusing failure. Consider validating the key first and throwing a clear error when it’s missing:
```pwsh
$matrixArch = '${{ matrix.arch }}'
if (-not $archMap.ContainsKey($matrixArch)) {
throw "Unsupported architecture: $matrixArch"
}
$arch = $archMap[$matrixArch]
```
```suggestion
- name: Download WebView2 Fixed Version Runtime
shell: pwsh
run: |
$archMap = @{ 'x86_64' = 'x64'; 'aarch64' = 'arm64' }
$matrixArch = '${{ matrix.arch }}'
if (-not $archMap.ContainsKey($matrixArch)) {
throw "Unsupported architecture: $matrixArch"
}
$arch = $archMap[$matrixArch]
$version = '133.0.3065.92'
$cabName = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab"
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - 我在这里给出了一些整体性的反馈:
- 在
main.rs中,只要设置了WEBVIEW2_BROWSER_EXECUTABLE_FOLDER,你就会跳过调用webview2::ensure_webview2(),但没有验证该路径是否真的存在;建议在跳过安装之前检查该目录是否存在且有效,这样当环境变量配置错误时就能避免一些令人困惑的故障。 - WebView2 运行时的下载步骤在工作流中直接硬编码了版本和 GUID 映射;建议把这些提取为命名清晰的变量,或者放入单独的脚本中,这样将来更新运行时版本(以及相应的 GUID)时就更不容易出错。
提供给 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- In `main.rs`, you skip `webview2::ensure_webview2()` whenever `WEBVIEW2_BROWSER_EXECUTABLE_FOLDER` is set, but don’t verify that the path actually exists; consider checking that the directory is present/valid before skipping installation to avoid confusing failures when the env var is set incorrectly.
- The WebView2 runtime download step hardcodes the version and GUID map directly in the workflow; consider centralizing these as clearly named variables or a separate script so that updating the runtime version (and matching GUIDs) is less error‑prone in future.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- In
main.rs, you skipwebview2::ensure_webview2()wheneverWEBVIEW2_BROWSER_EXECUTABLE_FOLDERis set, but don’t verify that the path actually exists; consider checking that the directory is present/valid before skipping installation to avoid confusing failures when the env var is set incorrectly. - The WebView2 runtime download step hardcodes the version and GUID map directly in the workflow; consider centralizing these as clearly named variables or a separate script so that updating the runtime version (and matching GUIDs) is less error‑prone in future.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `main.rs`, you skip `webview2::ensure_webview2()` whenever `WEBVIEW2_BROWSER_EXECUTABLE_FOLDER` is set, but don’t verify that the path actually exists; consider checking that the directory is present/valid before skipping installation to avoid confusing failures when the env var is set incorrectly.
- The WebView2 runtime download step hardcodes the version and GUID map directly in the workflow; consider centralizing these as clearly named variables or a separate script so that updating the runtime version (and matching GUIDs) is less error‑prone in future.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
.github/workflows/build.yml:165
- The Remove-Item command could fail if files are in use or permissions are insufficient, but errors are silently ignored. While this might be intentional for cleanup, it could hide issues. Consider adding -ErrorAction SilentlyContinue explicitly to document the intentional error suppression, or remove the -Force flag and let it fail gracefully if cleanup is important.
Remove-Item $cabName, $tempDir -Recurse -Force
讲真我感觉用不上加 但这就是vibe coding的魅力
There was a problem hiding this comment.
Hey - 我发现了 1 个问题
给 AI 代理的提示词
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src-tauri/src/main.rs:19-26` </location>
<code_context>
std::env::set_var("WEBVIEW2_USER_DATA_FOLDER", &webview_data_dir);
+
+ // 检测内置的 WebView2 固定版本运行时
+ let webview2_runtime_dir = exe_dir.join("webview2_runtime");
+ if webview2_runtime_dir.exists() {
+ std::env::set_var(
+ "WEBVIEW2_BROWSER_EXECUTABLE_FOLDER",
</code_context>
<issue_to_address>
**suggestion (bug_risk):** 使用目录级别的检查而不是 `exists()`,以避免配置错误。
如果 `webview2_runtime` 是一个文件或损坏的符号链接,`exists()` 仍然会返回 true,我们就会把 `WEBVIEW2_BROWSER_EXECUTABLE_FOLDER` 设置为一个无效路径,从而在后续造成更难排查的故障。使用 `webview2_runtime_dir.is_dir()` 可以确保只有在该路径确实是包含运行时的目录时,才会设置这个环境变量。
```suggestion
// 检测内置的 WebView2 固定版本运行时
let webview2_runtime_dir = exe_dir.join("webview2_runtime");
if webview2_runtime_dir.is_dir() {
std::env::set_var(
"WEBVIEW2_BROWSER_EXECUTABLE_FOLDER",
&webview2_runtime_dir,
);
}
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会利用这些反馈来改进后续的评审。
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src-tauri/src/main.rs:19-26` </location>
<code_context>
std::env::set_var("WEBVIEW2_USER_DATA_FOLDER", &webview_data_dir);
+
+ // 检测内置的 WebView2 固定版本运行时
+ let webview2_runtime_dir = exe_dir.join("webview2_runtime");
+ if webview2_runtime_dir.exists() {
+ std::env::set_var(
+ "WEBVIEW2_BROWSER_EXECUTABLE_FOLDER",
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Use a directory-specific check instead of exists() to avoid misconfiguration.
If `webview2_runtime` is a file or broken symlink, `exists()` still returns true and we’ll set `WEBVIEW2_BROWSER_EXECUTABLE_FOLDER` to an invalid path, causing harder-to-diagnose failures later. Using `webview2_runtime_dir.is_dir()` ensures the env var is only set when the path is actually a directory containing the runtime.
```suggestion
// 检测内置的 WebView2 固定版本运行时
let webview2_runtime_dir = exe_dir.join("webview2_runtime");
if webview2_runtime_dir.is_dir() {
std::env::set_var(
"WEBVIEW2_BROWSER_EXECUTABLE_FOLDER",
&webview2_runtime_dir,
);
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
|
不要这玩意,内置 webview 我干嘛不直接用 electron 现在一启动就有提示 webview 不可用并自动下载,已经足够覆盖绝大多数情况了 |
需要在 MaaEnd/MaaEnd#618 之前合并,还得发个版
这套不能给arm64打包,等我换个方案
从nyanpasu那里抄了一下思路,改完了
AGPL就是好,可以到处抄(
好了 现在和gpl完全没关系了 只抄思路不算抄)
Summary by Sourcery
添加一个在 Windows 平台上的构建变体,该变体会打包一个固定版本的 WebView2 运行时,并调整应用启动逻辑,使其优先使用打包的运行时,仅在不存在打包运行时时才触发 WebView2 的安装。
增强内容:
构建:
Original summary in English
Summary by Sourcery
Add a Windows build variant that bundles a fixed WebView2 runtime and adjust the application startup logic to prefer the bundled runtime while only triggering WebView2 installation when no bundled runtime is present.
Enhancements:
Build:
Summary by Sourcery
添加一个 Windows 构建变体,其中捆绑固定版本的 WebView2 运行时,并更新启动逻辑:优先使用捆绑的运行时,仅在必要时回退到系统安装的运行时。
增强功能:
构建:
Original summary in English
Summary by Sourcery
Add a Windows build variant that bundles a fixed WebView2 runtime and updates startup logic to prefer the bundled runtime while falling back to system installation only when necessary.
Enhancements:
Build:
Summary by Sourcery
添加一个 Windows 构建变体,捆绑一个固定版本的 WebView2 运行时,并更新启动行为:优先使用捆绑的运行时,仅在不存在捆绑运行时时才从系统安装 WebView2。
Enhancements:
Build:
Original summary in English
Summary by Sourcery
Add a Windows build variant that bundles a fixed WebView2 runtime and updates startup behavior to prefer the bundled runtime while only installing WebView2 from the system when no bundled runtime is present.
Enhancements:
Build:
Summary by Sourcery
添加一个包含固定版本 WebView2 运行时的 Windows 构建变体,并更新应用启动逻辑,使其优先使用捆绑的运行时,仅在不存在捆绑运行时时才安装 WebView2。
增强功能:
构建:
Original summary in English
Summary by Sourcery
Add a Windows build variant that bundles a fixed WebView2 runtime and updates the app startup to prefer the bundled runtime while only installing WebView2 when no bundled runtime is present.
Enhancements:
Build: