Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(diagnostic-tool): address CodeRabbit review

EtienneLescotea9bd62740ff
diff --git a/.github/workflows/diagnostic-artifact.yml b/.github/workflows/diagnostic-artifact.yml
index 24a87c2ad..eb9279113 100644
--- a/.github/workflows/diagnostic-artifact.yml
+++ b/.github/workflows/diagnostic-artifact.yml
@@ -43,14 +43,25 @@ jobs:
- name: Smoke-test the bundle
shell: pwsh
+ # The actual capture path is exercised by users with a real desktop
+ # session. A non-interactive runner has no display, so WGC cannot
+ # capture frames and the helper exits before emitting [stop-timing].
+ # Validate bundle structure + CLI parser instead of running capture.
run: |
$ErrorActionPreference = "Stop"
Expand-Archive -Path openscreen-diagnostic-windows-x64.zip -DestinationPath smoke
$smoke = Resolve-Path "smoke/openscreen-diagnostic-windows-x64"
- & "$smoke/diagnostic.bat" --duration 3 --output "$smoke/smoke.json"
- $report = Get-Content "$smoke/smoke.json" -Raw | ConvertFrom-Json
- if ($report.exitCode -ne 0) { throw "Smoke test failed: exitCode=$($report.exitCode)" }
- if ($report.stopTiming.Count -lt 1) { throw "Smoke test produced no [stop-timing] entries" }
+ foreach ($rel in @(
+ "diagnostic.mjs",
+ "diagnostic.bat",
+ "README.md",
+ "helpers/win32-x64/wgc-capture.exe"
+ )) {
+ $p = Join-Path $smoke $rel
+ if (-not (Test-Path $p)) { throw "Smoke test: missing $rel" }
+ }
+ & "$smoke/diagnostic.bat" --help | Out-Null
+ if ($LASTEXITCODE -ne 0) { throw "diagnostic.bat --help exited $LASTEXITCODE" }
- name: Upload Windows diagnostic bundle
uses: actions/upload-artifact@v4
diff --git a/scripts/diagnostic-tool/README.md b/scripts/diagnostic-tool/README.md
index aa286210c..046468e3e 100644
--- a/scripts/diagnostic-tool/README.md
+++ b/scripts/diagnostic-tool/README.md
@@ -20,7 +20,7 @@ Linux is not currently supported — OpenScreen has no Linux native helper.
## Usage
-```
+```text
node diagnostic.mjs --duration 10 --output ./diag.json
```
@@ -49,7 +49,7 @@ stop cleanup is slow.
## Layout
-```
+```text
scripts/diagnostic-tool/
README.md
diagnostic.mjs # the tool
diff --git a/scripts/diagnostic-tool/diagnostic.bat b/scripts/diagnostic-tool/diagnostic.bat
index d709fe751..95c0f721d 100644
--- a/scripts/diagnostic-tool/diagnostic.bat
+++ b/scripts/diagnostic-tool/diagnostic.bat
@@ -1,3 +1,3 @@
-@echo off
-setlocal
+@echo off
+setlocal
node "%~dp0diagnostic.mjs" %*
\ No newline at end of file
diff --git a/scripts/diagnostic-tool/diagnostic.mjs b/scripts/diagnostic-tool/diagnostic.mjs
index 77875ec5e..3b08d798c 100644
--- a/scripts/diagnostic-tool/diagnostic.mjs
+++ b/scripts/diagnostic-tool/diagnostic.mjs
@@ -45,14 +45,27 @@ function parseArgs(argv) {
source: "display",
help: false,
};
+ const requireNumber = (raw, flag) => {
+ const n = Number(raw);
+ if (!Number.isFinite(n) || n <= 0) {
+ throw new Error(`${flag} requires a positive number, got: ${raw}`);
+ }
+ return n;
+ };
for (let i = 0; i < argv.length; i += 1) {
const arg = argv[i];
if (arg === "--duration" || arg === "-d") {
- opts.duration = Number(argv[++i]) * 1000;
+ const value = argv[++i];
+ if (value === undefined) throw new Error(`${arg} requires a value`);
+ opts.duration = requireNumber(value, arg) * 1000;
} else if (arg === "--output" || arg === "-o") {
- opts.output = argv[++i];
+ const value = argv[++i];
+ if (value === undefined) throw new Error(`${arg} requires a value`);
+ opts.output = value;
} else if (arg === "--source") {
- opts.source = argv[++i];
+ const value = argv[++i];
+ if (value === undefined) throw new Error(`${arg} requires a value`);
+ opts.source = value;
} else if (arg === "--window") {
opts.source = "window";
} else if (arg === "--help" || arg === "-h") {