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 |   74 +++++++++++++++++++++++++++++++++++--
 1 files changed, 70 insertions(+), 4 deletions(-)

diff --git a/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1 b/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1
index cf43713..7f9639b 100644
--- a/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1
+++ b/privatevoice.src/scripts/QA-WINDOWS-PREVIEW.ps1
@@ -38,6 +38,7 @@
 $LogPath = Join-Path $AppDataDir "app.log"
 $Timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
 $EvidenceDir = Join-Path $PackageDir "qa-evidence-$Timestamp"
+$TargetPath = Join-Path $EvidenceDir "qa-target.txt"
 $Results = [System.Collections.Generic.List[string]]::new()
 
 New-Item -ItemType Directory -Path $EvidenceDir -Force | Out-Null
@@ -62,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)) {
@@ -84,12 +126,36 @@
 
 if (-not $CollectOnly) {
     Write-Step "Manual runtime check"
+    @(
+        "PrivateVoice Windows Preview QA Target",
+        "Click after the marker below, dictate one short Chinese sentence, then press Ctrl+S in Notepad.",
+        "DICTATION_RESULT:"
+    ) | Set-Content -Encoding UTF8 $TargetPath
+    try {
+        Start-Process -FilePath "notepad.exe" -ArgumentList "`"$TargetPath`"" | Out-Null
+        Add-Result $Results "Notepad target launched" $true $TargetPath
+    } catch {
+        Add-Result $Results "Notepad target launched" $false $_.Exception.Message
+    }
     Write-Host "1. Keep this PowerShell window open." -ForegroundColor White
     Write-Host "2. In PrivateVoice, make sure the SenseVoice model is installed and the engine is ready." -ForegroundColor White
-    Write-Host "3. Open Notepad or a browser text field." -ForegroundColor White
-    Write-Host "4. Use the configured hotkey and speak: 这是 Windows 预览版测试。" -ForegroundColor White
-    Write-Host "5. Confirm whether the text appears in the target input field." -ForegroundColor White
-    Read-Host "Press Enter after you complete one dictation attempt"
+    Write-Host "3. Use the Notepad window opened by this script as the target input field." -ForegroundColor White
+    Write-Host "4. Click after DICTATION_RESULT:, use the configured hotkey, and speak one short Chinese sentence." -ForegroundColor White
+    Write-Host "5. Confirm the recognized text appears in Notepad, press Ctrl+S in Notepad, then return here." -ForegroundColor White
+    Read-Host "Press Enter after you save the Notepad target file"
+}
+
+if (Test-Path $TargetPath) {
+    Copy-Item $TargetPath (Join-Path $EvidenceDir "qa-target-captured.txt") -Force
+    $targetText = Get-Content $TargetPath -Raw -ErrorAction SilentlyContinue
+    $marker = "DICTATION_RESULT:"
+    $markerIndex = $targetText.IndexOf($marker)
+    $dictationText = ""
+    if ($markerIndex -ge 0) {
+        $dictationText = $targetText.Substring($markerIndex + $marker.Length).Trim()
+    }
+    $dictationText | Set-Content -Encoding UTF8 (Join-Path $EvidenceDir "qa-target-dictation-text.txt")
+    Add-Result $Results "target file saved with dictation text" ($dictationText.Length -gt 0) "chars=$($dictationText.Length)"
 }
 
 Write-Step "Collecting logs"

--
Gitblit v1.9.3