Skip to content

Doubao-powered voice input for Linux, Wayland and Omarchy

fix(reports): preserve cases without node screenshots

quanru8b56c5823a87
diff --git a/scripts/build-pages-report.mjs b/scripts/build-pages-report.mjs
index a00f11e..7d627ee 100644
--- a/scripts/build-pages-report.mjs
+++ b/scripts/build-pages-report.mjs
@@ -16,8 +16,16 @@ import {
} from './omarchy-shell-evidence.mjs';
import { reportCases } from './report-cases.mjs';
-const MANIFEST_VERSION = 6;
-const SUPPORTED_MANIFEST_VERSIONS = new Set([1, 2, 3, 4, 5, MANIFEST_VERSION]);
+const MANIFEST_VERSION = 7;
+const SUPPORTED_MANIFEST_VERSIONS = new Set([
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ MANIFEST_VERSION,
+]);
export function formatDuration(durationMs) {
if (!Number.isFinite(durationMs) || durationMs < 0) return '';
@@ -231,7 +239,11 @@ async function buildReportEntry({
selection: testCase.selection,
description: testCase.description,
descriptionKind: testCase.descriptionKind,
- previewPath: `${path.posix.dirname(reportPath)}/${testCase.previewFile}`,
+ ...(testCase.previewFile
+ ? {
+ previewPath: `${path.posix.dirname(reportPath)}/${testCase.previewFile}`,
+ }
+ : {}),
...(includeCaseReportPath ? { reportPath } : {}),
}));
return {
@@ -407,9 +419,12 @@ function validReportEntry(entry, files) {
Number.isInteger(testCase.durationMs)) &&
(typeof testCase.stepId === 'string' ||
testCase.selection === 'workflow-failure') &&
- ['last-screenshot', 'first-failing-screenshot', 'workflow-failure'].includes(
- testCase.selection,
- ) &&
+ [
+ 'last-screenshot',
+ 'first-failing-screenshot',
+ 'first-failing-no-screenshot',
+ 'workflow-failure',
+ ].includes(testCase.selection) &&
(testCase.description === undefined ||
(typeof testCase.description === 'string' &&
testCase.description.length > 0)) &&
@@ -417,7 +432,9 @@ function validReportEntry(entry, files) {
['ai', 'error', 'result'].includes(testCase.descriptionKind)) &&
(testCase.description === undefined) ===
(testCase.descriptionKind === undefined) &&
- files?.includes(testCase.previewPath) &&
+ (testCase.selection === 'first-failing-no-screenshot'
+ ? testCase.previewPath === undefined
+ : files?.includes(testCase.previewPath)) &&
(testCase.reportPath === undefined ||
files?.includes(testCase.reportPath)),
)))
@@ -541,7 +558,9 @@ function buildRunIndex(report) {
const rows = entry.cases
.map((testCase) => {
const target = runStepHref(entry, testCase);
- const image = path.basename(testCase.previewPath);
+ const image = testCase.previewPath
+ ? path.basename(testCase.previewPath)
+ : null;
const status = testCase.status === 'success' ? '✅ Passed' : '❌ Failed';
const descriptionLabel = {
ai: 'AI',
@@ -553,7 +572,7 @@ function buildRunIndex(report) {
<td class="status">${status}</td>
<td><a href="${escapeHtml(target)}">${escapeHtml(testCase.name)}</a></td>
<td class="duration">${escapeHtml(formatDuration(testCase.durationMs))}</td>
- <td><a href="${escapeHtml(target)}"><img src="${escapeHtml(image)}" alt="${escapeHtml(testCase.name)} node screenshot" loading="lazy"></a></td>
+ <td>${image ? `<a href="${escapeHtml(target)}"><img src="${escapeHtml(image)}" alt="${escapeHtml(testCase.name)} node screenshot" loading="lazy"></a>` : '<span class="unavailable">Not available</span>'}</td>
<td><strong>${escapeHtml(descriptionLabel)}:</strong> ${escapeHtml(testCase.description)}</td>
</tr>`;
})
@@ -946,7 +965,7 @@ export async function buildPagesReport(options) {
{ passed: 0, tests: 0 },
);
const casePreviewFiles = entries.flatMap((entry) =>
- entry.cases.map((testCase) => testCase.previewPath),
+ entry.cases.map((testCase) => testCase.previewPath).filter(Boolean),
);
const screenshotFiles = screenshotCopies.map(
(copy) => `${reportPrefix}/${copy.destination}`,
@@ -1001,7 +1020,12 @@ export async function buildPagesReport(options) {
}
for (const entry of entries) {
for (const testCase of entry.cases) {
- if (testCase.selection === 'workflow-failure') continue;
+ if (
+ testCase.selection === 'workflow-failure' ||
+ testCase.selection === 'first-failing-no-screenshot'
+ ) {
+ continue;
+ }
await copyFile(
await findUniqueFile(
reportDirectory,
diff --git a/scripts/render-ci-report-summary.mjs b/scripts/render-ci-report-summary.mjs
index 9f65c6d..1e8e323 100644
--- a/scripts/render-ci-report-summary.mjs
+++ b/scripts/render-ci-report-summary.mjs
@@ -90,12 +90,14 @@ function failureReason(testCase) {
// GFM has no layout grid, so a 3-column table of linked thumbnails acts as
// one. Each cell is the screenshot with the case name as caption below it.
function screenshotGrid(pagesUrl, entries, cases) {
- const cells = cases.map(({ entry, testCase }) => {
+ const cells = cases
+ .filter(({ testCase }) => testCase.previewPath)
+ .map(({ entry, testCase }) => {
const target = caseTarget(pagesUrl, entry, testCase);
const image = reportUrl(pagesUrl, testCase.previewPath);
const name = inlineCell(testCase.name);
return `[![${name}](${image})](${target})<br>[${name}](${target})`;
- });
+ });
const rows = [];
for (let index = 0; index < cells.length; index += 3) {
const row = cells.slice(index, index + 3);
@@ -149,6 +151,12 @@ export function renderReportSummary({
const failedCases = groupedCases.filter(
({ testCase }) => testCase.status !== 'success',
);
+ const failedScreenshots = failedCases.filter(
+ ({ testCase }) => testCase.previewPath,
+ );
+ const screenshotCases = groupedCases.filter(
+ ({ testCase }) => testCase.previewPath,
+ );
const totalCases = groupedCases.length;
const passedCount = passedCases.length;
const passRate =
@@ -191,21 +199,19 @@ export function renderReportSummary({
return `| ❌ [${inlineCell(testCase.name)}](${target}) | ${duration} | ${failureReason(testCase)} |`;
}),
'',
- `### Failed screenshots (${failedCases.length})`,
+ `### Failed screenshots (${failedScreenshots.length})`,
'',
- screenshotGrid(pagesUrl, report.entries, failedCases),
+ screenshotGrid(pagesUrl, report.entries, failedScreenshots) ||
+ '_No failed-case screenshots were produced._',
'',
);
}
sections.push(
`<details>`,
- `<summary>All screenshots (${totalCases})</summary>`,
+ `<summary>All screenshots (${screenshotCases.length})</summary>`,
'',
- screenshotGrid(pagesUrl, report.entries, [
- ...passedCases,
- ...failedCases,
- ]),
+ screenshotGrid(pagesUrl, report.entries, screenshotCases),
'',
`</details>`,
'',
@@ -232,7 +238,7 @@ export function renderReportSummary({
}),
`</details>`,
'',
- 'Each image is the original page screenshot used by that node. A CI failure card is shown only when a shard stops before Midscene can capture a node. Click a case name or image to open its evidence.',
+ 'Each image is the original page screenshot used by that node. Cases remain linked to their native report when Midscene stops before producing a node screenshot. A CI failure card is shown only when a shard stops before Midscene can capture a report. Click a case name or image to open its evidence.',
'',
);
diff --git a/scripts/report-cases.mjs b/scripts/report-cases.mjs
index 7c3e6ea..2e4f79b 100644
--- a/scripts/report-cases.mjs
+++ b/scripts/report-cases.mjs
@@ -131,19 +131,18 @@ function evidenceForStep(step, embedded) {
}
}
const selected = candidates.at(-1);
- if (!selected) {
- throw new Error(`Step ${step.id} has no embedded node screenshot`);
- }
const error = normalizedText(step.error?.message);
const result = normalizedText(step.output?.summary);
- const description = error ?? selected.explanation ?? result;
+ const description = error ?? selected?.explanation ?? result;
if (!description) {
throw new Error(`Step ${step.id} has no AI response or error text`);
}
return {
- screenshot: embedded.images.get(selected.screenshotId),
+ ...(selected
+ ? { screenshot: embedded.images.get(selected.screenshotId) }
+ : {}),
description,
- descriptionKind: error ? 'error' : selected.explanation ? 'ai' : 'result',
+ descriptionKind: error ? 'error' : selected?.explanation ? 'ai' : 'result',
};
}
@@ -161,9 +160,10 @@ export async function reportCases(
? await embeddedReportData(reportHtml, reportFile)
: null;
return (project.documents ?? []).flatMap((document) =>
- (document.cases ?? []).map((testCase) => {
+ (document.cases ?? []).flatMap((testCase) => {
const attempt = testCase.attempts?.at(-1);
if (!attempt) {
+ if (testCase.status === 'not-run') return [];
throw new Error(
`Case ${testCase.name ?? testCase.caseId} has no attempt`,
);
@@ -185,21 +185,35 @@ export async function reportCases(
throw new Error('Midscene case metadata is incomplete');
}
const evidence = embedded ? evidenceForStep(step, embedded) : null;
- return {
+ if (passed && embedded && !evidence?.screenshot) {
+ throw new Error(`Step ${step.id} has no embedded node screenshot`);
+ }
+ const selection = passed
+ ? 'last-screenshot'
+ : evidence && !evidence.screenshot
+ ? 'first-failing-no-screenshot'
+ : 'first-failing-screenshot';
+ return [{
caseId: testCase.caseId,
name: testCase.name,
status: passed ? 'success' : 'failed',
durationMs: attempt.durationMs,
stepId: step.id,
stepTitle: step.title ?? step.node,
- selection: passed ? 'last-screenshot' : 'first-failing-screenshot',
- previewFile: casePreviewFileName(
- projectName,
- testCase.caseId,
- evidence?.screenshot.extension,
- ),
+ selection,
+ ...(evidence?.screenshot
+ ? {
+ previewFile: casePreviewFileName(
+ projectName,
+ testCase.caseId,
+ evidence.screenshot.extension,
+ ),
+ }
+ : embedded
+ ? {}
+ : { previewFile: casePreviewFileName(projectName, testCase.caseId) }),
...(evidence ?? {}),
- };
+ }];
}),
);
}
diff --git a/tests/contracts/test_pages_report_history.mjs b/tests/contracts/test_pages_report_history.mjs
index 9694546..f3e47cb 100644
--- a/tests/contracts/test_pages_report_history.mjs
+++ b/tests/contracts/test_pages_report_history.mjs
@@ -233,6 +233,59 @@ ${
<script type="midscene_test_run_dump">${JSON.stringify(run)}</script>`;
}
+function runnerWithoutScreenshot({ project, startedAt }) {
+ const run = {
+ startedAt,
+ status: 'failed',
+ summary: { total: 2, passed: 0, failed: 1, notRun: 1 },
+ projects: [
+ {
+ name: project,
+ documents: [
+ {
+ cases: [
+ {
+ caseId: `case-${project}`,
+ name: `${project} damaged-agent case`,
+ status: 'failed',
+ attempts: [
+ {
+ status: 'failed',
+ durationMs: 480000,
+ steps: [
+ {
+ id: 'act-without-execution',
+ node: 'aiAct',
+ title: 'Timed-out action',
+ status: 'failed',
+ error: {
+ message:
+ 'AI call hard timeout; no stable Agent execution reference was captured',
+ },
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ {
+ cases: [
+ {
+ caseId: `not-run-${project}`,
+ name: `${project} not-run case`,
+ status: 'not-run',
+ attempts: [],
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ };
+ return `<script type="midscene_test_run_dump">${JSON.stringify(run)}</script>`;
+}
+
const fixtureHtml = `<!doctype html><html><body>report
<script type="midscene_web_dump">{"usage":{"_midscene_call_id":"call-1","time_cost":2500,"total_tokens":120}}</script>
<script type="midscene_web_dump">{"message":"raw
@@ -940,7 +993,7 @@ test('restores retained history before adding the new run', async (context) => {
'utf8',
),
);
- assert.equal(writtenManifest.version, 6);
+ assert.equal(writtenManifest.version, 7);
assert.equal(writtenManifest.reports[0].reportPath, 'reports/200/index.html');
assert.equal(
writtenManifest.reports[0].workflowUrl,
@@ -1316,6 +1369,74 @@ test('pairs an original node screenshot with its AI text or error', async () =>
assert.deepEqual(failure.screenshot.bytes, Buffer.from('/9j/2Q==', 'base64'));
});
+test('preserves a failed case and skips a not-run case after agent damage', async () => {
+ const html = runnerWithoutScreenshot({
+ project: 'ubuntu',
+ startedAt: '2026-09-21T12:00:00Z',
+ });
+ const cases = await reportCases(testRunDump(html), 'ubuntu', {
+ reportHtml: html,
+ });
+ assert.equal(cases.length, 1);
+ const [testCase] = cases;
+
+ assert.equal(testCase.name, 'ubuntu damaged-agent case');
+ assert.equal(testCase.stepId, 'act-without-execution');
+ assert.equal(testCase.selection, 'first-failing-no-screenshot');
+ assert.equal(testCase.previewFile, undefined);
+ assert.equal(testCase.screenshot, undefined);
+ assert.equal(testCase.descriptionKind, 'error');
+ assert.match(testCase.description, /no stable Agent execution reference/);
+});
+
+test('publishes all case metadata when one report has no node screenshot', async (context) => {
+ const root = await mkdtemp(path.join(os.tmpdir(), 'pages-no-node-shot-'));
+ const reportDirectory = path.join(root, 'artifact');
+ const nativeDirectory = path.join(reportDirectory, 'report');
+ await mkdir(nativeDirectory, { recursive: true });
+ const html = runnerWithoutScreenshot({
+ project: 'ubuntu',
+ startedAt: '2026-09-21T12:00:00Z',
+ });
+ await writeFile(path.join(nativeDirectory, 'test-run-ubuntu.html'), html);
+ await writeFile(path.join(reportDirectory, 'report-preview.png'), 'preview');
+ const siteDirectory = path.join(root, 'site');
+ const server = await startServer((_request, response) =>
+ response.writeHead(404).end(),
+ );
+ context.after(server.close);
+
+ const manifest = await buildPagesReport({
+ ...options(reportDirectory, siteDirectory, server.url),
+ });
+ const [testCase] = manifest.reports[0].entries[0].cases;
+ assert.equal(manifest.version, 7);
+ assert.equal(testCase.selection, 'first-failing-no-screenshot');
+ assert.equal(testCase.previewPath, undefined);
+ assert.match(testCase.description, /no stable Agent execution reference/);
+ assert.doesNotMatch(JSON.stringify(manifest.reports[0].files), /case-preview/);
+
+ const runIndex = await readFile(
+ path.join(siteDirectory, 'reports', '200', 'index.html'),
+ 'utf8',
+ );
+ assert.match(runIndex, /ubuntu damaged-agent case/);
+ assert.match(runIndex, /Not available/);
+
+ const summary = renderReportSummary({
+ manifest,
+ pagesUrl: 'https://example.test/doubao-say/',
+ producerResult: 'failure',
+ runId: '200',
+ summaryTitle: 'Ubuntu',
+ });
+ assert.match(summary, /Failures \(1\)/);
+ assert.match(summary, /Failed screenshots \(0\)/);
+ assert.match(summary, /No failed-case screenshots were produced/);
+ assert.match(summary, /All screenshots \(0\)/);
+ assert.match(summary, /ubuntu damaged-agent case/);
+});
+
test('finds Omarchy evidence by project instead of assertion wording', async () => {
const root = await mkdtemp(path.join(os.tmpdir(), 'shell-project-'));
const reportDirectory = path.join(root, 'report');
diff --git a/tests/e2e/capture-report-preview.mjs b/tests/e2e/capture-report-preview.mjs
index aeb2601..db26b6f 100644
--- a/tests/e2e/capture-report-preview.mjs
+++ b/tests/e2e/capture-report-preview.mjs
@@ -140,6 +140,12 @@ try {
reportHtml: report.html,
reportFile: report.file,
})) {
+ if (!testCase.screenshot) {
+ console.log(
+ `Skipped node screenshot for ${testCase.name} at ${testCase.stepId} because Midscene did not produce one.`,
+ );
+ continue;
+ }
const caseOutput = path.join(reportDirectory, testCase.previewFile);
await writeFile(caseOutput, testCase.screenshot.bytes);
console.log(