From 913b25529de9fb28fe9d212cc13492430db5a7c6 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Tue, 30 Jun 2026 03:43:10 +0800
Subject: [PATCH] Collect Windows runtime preflight evidence

---
 privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1   |   41 +++++++++++++++++++++++++++++++++++++++++
 privatevoice.src/scripts/build-windows-preview.sh |    2 +-
 CHANGELOG.md                                      |    2 +-
 CODEGRAPH.md                                      |    2 +-
 4 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e58c779..7b8f291 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,7 +16,7 @@
 ### Windows 技术预览
 
 - **新增 Windows 预览构建脚本**:`privatevoice.src/scripts/build-windows-preview.sh` 可生成 Windows x64 预览目录和 zip。
-- **内置 Windows 真机 QA 采集脚本**:预览包包含 `QA-WINDOWS-PREVIEW.ps1`,用于启动 App、打开 Notepad 目标文件、提示完成一次听写,并收集日志和目标文本证据。
+- **内置 Windows 真机 QA 采集脚本**:预览包包含 `QA-WINDOWS-PREVIEW.ps1`,用于采集 WebView2 / 音频端点预检信息、启动 App、打开 Notepad 目标文件、提示完成一次听写,并收集日志和目标文本证据。
 - **新增 Windows QA 证据验证脚本**:`privatevoice.src/scripts/verify-windows-qa-evidence.sh` 可检查返回的 `qa-evidence-*.zip` 是否证明启动、引擎、录音、识别和上屏。
 - **预览版只开放 SenseVoice**:Windows build 中其他模型仍可见但置灰禁用,避免用户选择尚未验证的模型导致启动或识别失败。
 - **打包 sherpa/onnxruntime 运行时 DLL**:预览包包含 `onnxruntime.dll`、`sherpa-onnx-c-api.dll`、`sherpa-onnx-cxx-api.dll`。
diff --git a/CODEGRAPH.md b/CODEGRAPH.md
index 2493f99..29cf5d2 100644
--- a/CODEGRAPH.md
+++ b/CODEGRAPH.md
@@ -60,7 +60,7 @@
 ## Known Gaps
 
 - Windows runtime QA must still be performed on Windows 10/11 hardware.
-- Run `QA-WINDOWS-PREVIEW.ps1` from the extracted preview package to collect startup, engine, recording, recognition, paste, and Notepad target text evidence.
+- Run `QA-WINDOWS-PREVIEW.ps1` from the extracted preview package to collect WebView2/audio preflight, startup, engine, recording, recognition, paste, and Notepad target text evidence.
 - After evidence is returned, run `verify-windows-qa-evidence.sh` and require `WINDOWS_QA_EVIDENCE_PASS` before claiming the goal complete.
 - The Windows preview zip is unsigned and not an installer.
 - SmartScreen / Defender prompts are expected for local testing.
diff --git a/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1 b/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1
index b9c1581..7f9639b 100644
--- a/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1
+++ b/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1
@@ -63,6 +63,47 @@
     Add-Result $Results "system info collected" $false $_.Exception.Message
 }
 
+Write-Step "Collecting Windows runtime preflight"
+try {
+    $webview2Entries = @()
+    $uninstallRoots = @(
+        "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
+        "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*",
+        "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
+    )
+    foreach ($root in $uninstallRoots) {
+        $webview2Entries += Get-ItemProperty $root -ErrorAction SilentlyContinue |
+            Where-Object { $_.DisplayName -match "WebView2" } |
+            Select-Object DisplayName, DisplayVersion, Publisher, InstallLocation
+    }
+    if ($webview2Entries.Count -gt 0) {
+        $webview2Entries | Format-List | Out-String | Set-Content -Encoding UTF8 (Join-Path $EvidenceDir "webview2-runtime.txt")
+    } else {
+        "No WebView2 Runtime entry found in standard uninstall registry paths. App startup logs remain authoritative." |
+            Set-Content -Encoding UTF8 (Join-Path $EvidenceDir "webview2-runtime.txt")
+    }
+    Add-Result $Results "WebView2 registry inventory collected" $true "entries=$($webview2Entries.Count)"
+} catch {
+    Add-Result $Results "WebView2 registry inventory collected" $false $_.Exception.Message
+}
+
+try {
+    if (Get-Command Get-PnpDevice -ErrorAction SilentlyContinue) {
+        Get-PnpDevice -Class AudioEndpoint -ErrorAction SilentlyContinue |
+            Select-Object Status, Class, FriendlyName, InstanceId |
+            Format-Table -AutoSize | Out-String |
+            Set-Content -Encoding UTF8 (Join-Path $EvidenceDir "audio-endpoints.txt")
+    } else {
+        Get-CimInstance Win32_SoundDevice -ErrorAction SilentlyContinue |
+            Select-Object Status, Name, Manufacturer, DeviceID |
+            Format-Table -AutoSize | Out-String |
+            Set-Content -Encoding UTF8 (Join-Path $EvidenceDir "audio-endpoints.txt")
+    }
+    Add-Result $Results "audio endpoint inventory collected" $true
+} catch {
+    Add-Result $Results "audio endpoint inventory collected" $false $_.Exception.Message
+}
+
 if (-not $CollectOnly -and -not $NoLaunch) {
     Write-Step "Launching app"
     if (-not (Test-Path $ExePath)) {
diff --git a/privatevoice.src/scripts/build-windows-preview.sh b/privatevoice.src/scripts/build-windows-preview.sh
index 4549ac9..2ed1fdf 100755
--- a/privatevoice.src/scripts/build-windows-preview.sh
+++ b/privatevoice.src/scripts/build-windows-preview.sh
@@ -74,7 +74,7 @@
 3. Right-click "QA-WINDOWS-PREVIEW.ps1" and choose "Run with PowerShell".
 4. If PowerShell blocks scripts, run this command from the extracted folder:
    powershell -ExecutionPolicy Bypass -File .\\QA-WINDOWS-PREVIEW.ps1
-5. Follow the on-screen checklist. It will launch the app, open a Notepad target file, ask you to dictate once, and collect logs plus the saved target text.
+5. Follow the on-screen checklist. It will collect WebView2/audio preflight data, launch the app, open a Notepad target file, ask you to dictate once, and collect logs plus the saved target text.
 6. You can also run "PrivateVoice Dictation.exe" directly after QA.
 
 Known limitations:

--
Gitblit v1.9.3