From dbf61e52aa3003f6926934daa725b1ce4fb79293 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 10 Jul 2026 19:08:48 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8F=97=20Web=20Probe=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=87=87=E9=9B=86=E5=90=88=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-probe-observe-collect.test.ts | 36 +++++++++++++++++++ .../hwlab-node/web-probe-observe-collect.ts | 3 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/scripts/src/hwlab-node/web-probe-observe-collect.test.ts b/scripts/src/hwlab-node/web-probe-observe-collect.test.ts index 7db6f765..1c882939 100644 --- a/scripts/src/hwlab-node/web-probe-observe-collect.test.ts +++ b/scripts/src/hwlab-node/web-probe-observe-collect.test.ts @@ -135,6 +135,42 @@ test("collects an exact failed command artifact without treating artifact failur expect(String(rendered.renderedText)).toContain("terminal event arrived before subscriber disconnect"); }); +test("accepts the standard file collect envelope without requiring a summary view", () => { + const options = collectOptions(); + options.collectView = "files"; + options.collectFile = "commands/failed/cmd-fixture.json"; + const payload = buildNodeWebProbeObserveCollectPayload(options, { workspace: "/workspace" }, { + command: ["trans", "NC01:/workspace", "sh"], + cwd: "/repo", + exitCode: 0, + stdout: JSON.stringify({ + ok: true, + command: "web-probe-observe collect", + stateDir: "/remote/state", + mode: "file", + requestedFile: options.collectFile, + resolvedFile: options.collectFile, + file: { + relative: options.collectFile, + byteCount: 21885, + sha256: "sha256:fixture", + jsonSummary: { topLevelKeys: ["ok", "commandId", "type", "failedAt", "error"] }, + }, + valuesRedacted: true, + }), + stderr: "", + signal: null, + timedOut: false, + } satisfies CommandResult); + + expect(payload.ok).toBe(true); + expect(payload.status).toBe("collected"); + expect(payload.degradedReason).toBeNull(); + const collect = payload.collect as Record; + expect(collect.mode).toBe("file"); + expect(collect.file.byteCount).toBe(21885); +}); + function collectOptions(): NodeWebProbeObserveOptions { return { action: "observe", diff --git a/scripts/src/hwlab-node/web-probe-observe-collect.ts b/scripts/src/hwlab-node/web-probe-observe-collect.ts index b85568b4..7c2f108b 100644 --- a/scripts/src/hwlab-node/web-probe-observe-collect.ts +++ b/scripts/src/hwlab-node/web-probe-observe-collect.ts @@ -89,6 +89,7 @@ export function buildNodeWebProbeObserveCollectPayload( export function isWebObserveCollectJsonContract(value: Record, requestedFile: string | null = null): boolean { const command = stringOrNull(value.command); const view = stringOrNull(value.view); + const mode = stringOrNull(value.mode); const stateDir = stringOrNull(value.stateDir); if (commandArtifactBucket(value, requestedFile) !== null) return true; if (value.ok === false) { @@ -98,7 +99,7 @@ export function isWebObserveCollectJsonContract(value: Record, || stringOrNull(value.error) !== null; } return command === "web-probe-observe collect" - && view !== null + && (view !== null || mode === "file") && stateDir !== null; }