fix: validate JD01 source browser launch

This commit is contained in:
Codex
2026-06-29 09:38:32 +00:00
parent d9cbc1434c
commit a4a475de53
2 changed files with 26 additions and 2 deletions
+25 -1
View File
@@ -644,7 +644,8 @@ function sourceWorkspaceStatusFromFields(fields: Record<string, string>, exitCod
&& missingFiles.length === 0
&& fields.playwrightPackagePresent === "yes"
&& fields.browserExecutablePresent === "yes"
&& fields.launcherImportOk === "yes";
&& fields.launcherImportOk === "yes"
&& fields.browserLaunchOk === "yes";
return {
ok,
workspace: fields.workspace || null,
@@ -672,6 +673,9 @@ function sourceWorkspaceStatusFromFields(fields: Record<string, string>, exitCod
browserExecutableErrorTail: fields.browserExecutableErrorTail || null,
launcherImportOk: fields.launcherImportOk === "yes",
launcherImportExitCode: numericField(fields.launcherImportExitCode),
browserLaunchOk: fields.browserLaunchOk === "yes",
browserLaunchExitCode: numericField(fields.browserLaunchExitCode),
browserLaunchErrorTail: fields.browserLaunchErrorTail || null,
statusShortLines: numericField(fields.statusShortLines),
statusShortPreview: fields.statusShortPreview || null,
valuesPrinted: false,
@@ -876,6 +880,23 @@ function sourceWorkspaceStatusScript(spec: HwlabRuntimeLaneSpec, sourceWorkspace
" launcher_import_exit=$?",
" [ \"$launcher_import_exit\" = 0 ] && launcher_import_ok=yes",
"fi",
"browser_launch_ok=no",
"browser_launch_exit=",
"browser_launch_error_tail=",
"if command -v node >/dev/null 2>&1 && [ \"$launcher_import_ok\" = yes ]; then",
" (cd \"$workspace\" && PLAYWRIGHT_BROWSERS_PATH=0 timeout 30s node --input-type=module - <<'NODE'",
"const doctor = await import('./scripts/src/browser-launcher.mjs').then((mod) => mod.browserDoctor());",
"if (doctor.status !== 'pass') {",
" console.error(JSON.stringify({ failureCode: doctor.failureCode, error: doctor.error, browser: doctor.browser, managedBrowser: doctor.managedBrowser, remediation: doctor.remediation }));",
" process.exit(1);",
"}",
"console.log(JSON.stringify({ status: doctor.status, browser: doctor.browser, managedBrowser: doctor.managedBrowser }));",
"NODE",
" ) >/tmp/hwlab-source-workspace-browser-launch.out 2>/tmp/hwlab-source-workspace-browser-launch.err",
" browser_launch_exit=$?",
" browser_launch_error_tail=$(tail -n 20 /tmp/hwlab-source-workspace-browser-launch.err 2>/dev/null | tr '\\n\\t' ' ' | cut -c1-1000)",
" [ \"$browser_launch_exit\" = 0 ] && browser_launch_ok=yes",
"fi",
"status_short_lines=$(printf '%s' \"$status_short\" | sed '/^$/d' | wc -l | tr -d ' ')",
"status_short_preview=$(printf '%s' \"$status_short\" | tr '\\n\\t' ' ' | cut -c1-1000)",
"printf 'workspace\\t%s\\n' \"$workspace\"",
@@ -903,6 +924,9 @@ function sourceWorkspaceStatusScript(spec: HwlabRuntimeLaneSpec, sourceWorkspace
"printf 'browserExecutableErrorTail\\t%s\\n' \"$browser_executable_error_tail\"",
"printf 'launcherImportOk\\t%s\\n' \"$launcher_import_ok\"",
"printf 'launcherImportExitCode\\t%s\\n' \"$launcher_import_exit\"",
"printf 'browserLaunchOk\\t%s\\n' \"$browser_launch_ok\"",
"printf 'browserLaunchExitCode\\t%s\\n' \"$browser_launch_exit\"",
"printf 'browserLaunchErrorTail\\t%s\\n' \"$browser_launch_error_tail\"",
"printf 'statusShortLines\\t%s\\n' \"$status_short_lines\"",
"printf 'statusShortPreview\\t%s\\n' \"$status_short_preview\"",
].join("\n");