Doubao-powered voice input for Linux, Wayland and Omarchy
feat(reports): linear-style CI summary with per-case durations
quanru747da45228ce
diff --git a/scripts/build-pages-report.mjs b/scripts/build-pages-report.mjsindex cb5ee2b..c491151 100644--- a/scripts/build-pages-report.mjs+++ b/scripts/build-pages-report.mjs@@ -16,8 +16,17 @@ import {} from './omarchy-shell-evidence.mjs';import { reportCases } from './report-cases.mjs';-const MANIFEST_VERSION = 5;-const SUPPORTED_MANIFEST_VERSIONS = new Set([1, 2, 3, 4, MANIFEST_VERSION]);+const MANIFEST_VERSION = 6;+const SUPPORTED_MANIFEST_VERSIONS = new Set([1, 2, 3, 4, 5, MANIFEST_VERSION]);++export function formatDuration(durationMs) {+ if (!Number.isFinite(durationMs) || durationMs < 0) return '';+ const totalSeconds = Math.round(durationMs / 1000);+ const minutes = Math.floor(totalSeconds / 60);+ const seconds = totalSeconds % 60;+ if (minutes === 0) return `${seconds}s`;+ return `${minutes}m${String(seconds).padStart(2, '0')}s`;+}function parseArguments(argv) {const options = {};@@ -212,6 +221,9 @@ function buildReportEntry({caseId: testCase.caseId,name: testCase.name,status: testCase.status,+ ...(Number.isFinite(testCase.durationMs)+ ? { durationMs: testCase.durationMs }+ : {}),stepId: testCase.stepId,selection: testCase.selection,description: testCase.description,@@ -386,6 +398,8 @@ function validReportEntry(entry, files) {typeof testCase.caseId === 'string' &&typeof testCase.name === 'string' &&['success', 'failed'].includes(testCase.status) &&+ (testCase.durationMs === undefined ||+ Number.isInteger(testCase.durationMs)) &&(typeof testCase.stepId === 'string' ||testCase.selection === 'workflow-failure') &&['last-screenshot', 'first-failing-screenshot', 'workflow-failure'].includes(@@ -493,7 +507,7 @@ function escapeHtml(value) {.replaceAll("'", ''');}-function formatDuration(durationMs) {+function formatModelDuration(durationMs) {if (durationMs === null) return 'Unavailable';return `${(durationMs / 1000).toFixed(2)} s`;}@@ -533,6 +547,7 @@ function buildRunIndex(report) {<tr><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><strong>${escapeHtml(descriptionLabel)}:</strong> ${escapeHtml(testCase.description)}</td></tr>`;@@ -549,7 +564,7 @@ function buildRunIndex(report) {</div><div class="table-wrap"><table>- <thead><tr><th>Result</th><th>Case</th><th>Node screenshot</th><th>AI response / error</th></tr></thead>+ <thead><tr><th>Result</th><th>Case</th><th>Duration</th><th>Node screenshot</th><th>AI response / error</th></tr></thead><tbody>${rows}</tbody></table>@@ -579,9 +594,10 @@ function buildRunIndex(report) {th { font-size: .78rem; text-transform: uppercase; }th:nth-child(1) { width: 7rem; }th:nth-child(2) { width: 17rem; }- th:nth-child(3) { width: 34%; }+ th:nth-child(3) { width: 6rem; }+ th:nth-child(4) { width: 34%; }td { line-height: 1.45; }- td.status { white-space: nowrap; }+ td.status, td.duration { white-space: nowrap; }img { border: 1px solid #8885; border-radius: .5rem; display: block; height: auto; width: 100%; }@media (max-width: 900px) {body { padding: 1rem .6rem 3rem; }@@ -612,7 +628,7 @@ function buildIndex(reports) {<td>${escapeHtml(report.label ?? 'Midscene E2E')}</td><td>${escapeHtml(report.generatedAt)}</td><td>${escapeHtml(report.successRate.toFixed(1))}%</td>- <td>${escapeHtml(formatDuration(report.averageDurationMs))}</td>+ <td>${escapeHtml(formatModelDuration(report.averageDurationMs))}</td><td>${escapeHtml(report.modelCallCount)}</td><td>${report.tokenUsage === null ? 'Unavailable' : escapeHtml(report.tokenUsage.toLocaleString('en-US'))}</td><td><a href="${escapeHtml(report.workflowUrl)}">Actions run</a></td>diff --git a/scripts/render-ci-report-summary.mjs b/scripts/render-ci-report-summary.mjsindex 8f2f2d2..9f65c6d 100644--- a/scripts/render-ci-report-summary.mjs+++ b/scripts/render-ci-report-summary.mjs@@ -3,6 +3,8 @@import { appendFile, readFile } from 'node:fs/promises';import process from 'node:process';+import { formatDuration } from './build-pages-report.mjs';+function parseArguments(argv) {const options = {};for (let index = 0; index < argv.length; index += 2) {@@ -39,7 +41,7 @@ function stepUrl(baseUrl, reportPath, stepId) {return url.href;}-function markdownCell(value) {+function inlineCell(value) {return String(value).replaceAll('\\', '\\\\').replaceAll('|', '\\|')@@ -48,21 +50,62 @@ function markdownCell(value) {.replaceAll('\n', ' ');}-function entryResult(entry) {+function entryCounts(entry) {const parts = [];if (entry.scenarios.total > 0) {parts.push(- `${entry.scenarios.passed}/${entry.scenarios.total} scenarios passed`,+ `${entry.scenarios.passed}/${entry.scenarios.total} cases`,);}if (entry.assertions.total > 0) {parts.push(- `${entry.assertions.passed}/${entry.assertions.total} visual assertions passed`,+ `${entry.assertions.passed}/${entry.assertions.total} assertions`,);}return `**${entry.label}: ${parts.join(' · ') || 'report captured'}.**`;}+function caseTarget(pagesUrl, entry, testCase) {+ return stepUrl(+ pagesUrl,+ testCase.reportPath ?? entry.reportPath,+ testCase.stepId,+ );+}++function failureReason(testCase) {+ if (testCase.selection === 'workflow-failure') {+ return inlineCell(+ `CI failure before node capture — ${testCase.description ?? ''}`,+ );+ }+ const label = {+ ai: 'AI: ',+ error: 'Error: ',+ result: 'Result: ',+ }[testCase.descriptionKind];+ return inlineCell(`${label ?? ''}${testCase.description ?? ''}`);+}++// 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 target = caseTarget(pagesUrl, entry, testCase);+ const image = reportUrl(pagesUrl, testCase.previewPath);+ const name = inlineCell(testCase.name);+ return `[](${target})<br>[${name}](${target})`;+ });+ const rows = [];+ for (let index = 0; index < cells.length; index += 3) {+ const row = cells.slice(index, index + 3);+ while (row.length < 3) row.push('');+ rows.push(`| ${row.join(' | ')} |`);+ }+ if (rows.length === 0) return '';+ return ['| | | |', '|:--|:--|:--|', ...rows].join('\n');+}+export function renderReportSummary({manifest,pagesUrl,@@ -87,6 +130,30 @@ export function renderReportSummary({const title = `${summaryTitle} × Midscene · ${allPassed ? 'passed' : 'failure captured'}`;++ const groupedCases = report.entries.flatMap((entry) => {+ if (!Array.isArray(entry.cases) || entry.cases.length === 0) {+ throw new Error(`${entry.label} does not contain case evidence`);+ }+ return entry.cases.map((testCase) => ({ entry, testCase }));+ });+ groupedCases.forEach(({ testCase }) => {+ if (!testCase.description || !testCase.descriptionKind) {+ throw new Error(`${testCase.name} does not contain node text evidence`);+ }+ });++ const passedCases = groupedCases.filter(+ ({ testCase }) => testCase.status === 'success',+ );+ const failedCases = groupedCases.filter(+ ({ testCase }) => testCase.status !== 'success',+ );+ const totalCases = groupedCases.length;+ const passedCount = passedCases.length;+ const passRate =+ totalCases === 0 ? 0 : Math.round((passedCount / totalCases) * 100);+const historyUrl = normalizedBaseUrl(pagesUrl).href;const links = [...report.entries.flatMap((entry) => {@@ -98,52 +165,78 @@ export function renderReportSummary({}),`[Report history](${historyUrl})`,].join(' · ');- const caseTables = report.entries.map((entry) => {- if (!Array.isArray(entry.cases) || entry.cases.length === 0) {- throw new Error(`${entry.label} does not contain case evidence`);- }- const rows = entry.cases.map((testCase) => {- if (!testCase.description || !testCase.descriptionKind) {- throw new Error(`${testCase.name} does not contain node text evidence`);- }- const target = stepUrl(- pagesUrl,- testCase.reportPath ?? entry.reportPath,- testCase.stepId,++ const sections = [+ `## ${title}`,+ '',+ `**${passedCount}/${totalCases} cases · ${passRate}% passed**`,+ '',+ report.entries.map(entryCounts).join('\n\n'),+ '',+ links,+ '',+ ];++ if (failedCases.length === 0) {+ sections.push(`**All ${totalCases} cases passed.**`, '');+ } else {+ sections.push(+ `### Failures (${failedCases.length})`,+ '',+ '| Case | Duration | Reason |',+ '|:--|:--|:--|',+ ...failedCases.map(({ entry, testCase }) => {+ const target = caseTarget(pagesUrl, entry, testCase);+ const duration = formatDuration(testCase.durationMs) || '—';+ return `| ❌ [${inlineCell(testCase.name)}](${target}) | ${duration} | ${failureReason(testCase)} |`;+ }),+ '',+ `### Failed screenshots (${failedCases.length})`,+ '',+ screenshotGrid(pagesUrl, report.entries, failedCases),+ '',+ );+ }++ sections.push(+ `<details>`,+ `<summary>All screenshots (${totalCases})</summary>`,+ '',+ screenshotGrid(pagesUrl, report.entries, [+ ...passedCases,+ ...failedCases,+ ]),+ '',+ `</details>`,+ '',+ `<details>`,+ `<summary>Passed cases (${passedCount})</summary>`,+ '',+ ...report.entries.flatMap((entry) => {+ const passed = (entry.cases ?? []).filter(+ (testCase) => testCase.status === 'success',);- const image = reportUrl(pagesUrl, testCase.previewPath);- const status = testCase.status === 'success' ? '✅ Passed' : '❌ Failed';- const evidence =- testCase.status === 'success'- ? 'Last screenshot'- : testCase.selection === 'workflow-failure'- ? 'CI failure before node capture'- : 'First failing screenshot';- const descriptionLabel = {- ai: '**AI:** ',- error: '**Error:** ',- result: '**Result:** ',- }[testCase.descriptionKind];- return `| ${status} | [${markdownCell(testCase.name)}](${target}) | [](${target}) | ${descriptionLabel}${markdownCell(testCase.description)} |`;- });- return `### ${entry.label}--| Result | Case | Node screenshot | AI response / error |-|:--|:--|:--|:--|-${rows.join('\n')}`;- })- .join('\n\n');-- return `## ${title}--${report.entries.map(entryResult).join('\n\n')}--${links}--${caseTables}--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.-`;+ if (passed.length === 0) return [];+ return [+ `**${entry.label}**`,+ '',+ ...passed.map((testCase) => {+ const target = caseTarget(pagesUrl, entry, testCase);+ const duration = formatDuration(testCase.durationMs);+ return `- ✅ [${inlineCell(testCase.name)}](${target})${+ duration ? ` — ${duration}` : ''+ }`;+ }),+ '',+ ];+ }),+ `</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.',+ '',+ );++ return sections.join('\n');}async function main() {diff --git a/scripts/report-cases.mjs b/scripts/report-cases.mjsindex afd3490..b7ebcbe 100644--- a/scripts/report-cases.mjs+++ b/scripts/report-cases.mjs@@ -188,6 +188,7 @@ export function reportCases(run, projectName, { reportHtml } = {}) {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',diff --git a/tests/contracts/test_pages_report_history.mjs b/tests/contracts/test_pages_report_history.mjsindex 1bcb741..679f036 100644--- a/tests/contracts/test_pages_report_history.mjs+++ b/tests/contracts/test_pages_report_history.mjs@@ -54,8 +54,8 @@ test('records every shard and renders the Summary before Pages deployment', asyn);assert.match(source,- /max-parallel: 5/,- `${workflow} must start all four product shards and its auxiliary project together`,+ /^\s*max-parallel: [1-5]$/m,+ `${workflow} must declare an explicit matrix concurrency (1 while the model endpoint is rate-limited, 5 otherwise)`,);assert.match(source, /if-no-files-found: error/);assert.match(source, /Create bundle even when every shard failed early/);@@ -188,11 +188,13 @@ function runnerScript({status: statuses.every((item) => item === 'success')? 'success': 'failed',+ durationMs: 12000 + attemptIndex * 1000,steps: statuses.map((stepStatus, stepIndex) => ({id: `assert-${attemptIndex}-${stepIndex}`,node: assertionCount || assertionAttempts ? 'aiAssert' : 'aiAct',title: `Evidence ${attemptIndex}-${stepIndex}`,status: stepStatus,+ durationMs: 4000 + stepIndex * 500,...(stepStatus === 'failed'? {error: {@@ -580,6 +582,7 @@ test('publishes the Doubao Say report as the primary CI entrance', async (contexcaseId: 'case-ubuntu',name: 'ubuntu visual case',status: 'success',+ durationMs: 12000,stepId: 'assert-0-0',selection: 'last-screenshot',description: 'AI explanation 0-0',@@ -603,6 +606,7 @@ test('publishes the Doubao Say report as the primary CI entrance', async (contexcaseId: 'case-omarchy-shell',name: 'omarchy-shell visual case',status: 'success',+ durationMs: 12000,stepId: 'assert-0-2',selection: 'last-screenshot',description: 'AI explanation 0-2',@@ -855,7 +859,7 @@ test('restores retained history before adding the new run', async (context) => {'utf8',),);- assert.equal(writtenManifest.version, 5);+ assert.equal(writtenManifest.version, 6);assert.equal(writtenManifest.reports[0].reportPath, 'reports/200/index.html');assert.equal(writtenManifest.reports[0].workflowUrl,@@ -1004,6 +1008,7 @@ test('renders one full-width section per structured report entry', () => {caseId: 'case-ubuntu',name: 'Launch and finish onboarding',status: 'success',+ durationMs: 73000,stepId: 'case-ubuntu:steps:8',selection: 'last-screenshot',description: 'The setup completion state is visible.',@@ -1028,6 +1033,7 @@ test('renders one full-width section per structured report entry', () => {caseId: 'case-polishing',name: 'Polish selected text',status: 'success',+ durationMs: 52000,stepId: 'case-polishing:steps:5',selection: 'last-screenshot',description: 'The polished text is visible.',@@ -1050,19 +1056,26 @@ test('renders one full-width section per structured report entry', () => {});assert.match(summary, /Ubuntu × Midscene · passed/);- assert.match(summary, /Doubao Say: 6\/6 scenarios passed/);- assert.match(summary, /Polishing overlay report: 1\/1 scenarios passed/);+ assert.match(summary, /\*\*2\/2 cases · 100% passed\*\*/);+ assert.match(summary, /Doubao Say: 6\/6 cases · 5\/5 assertions\./);assert.match(summary,- /\| Result \| Case \| Node screenshot \| AI response \/ error \|/,+ /Polishing overlay report: 1\/1 cases · 8\/8 assertions\./,);- assert.match(summary, /✅ Passed/);+ assert.match(summary, /\*\*All 2 cases passed\.\*\*/);+ assert.doesNotMatch(summary, /### Failures/);assert.match(summary,/index\.html#runner-step=case-ubuntu%3Asteps%3A8/,);- assert.match(summary, /Last screenshot: Launch and finish onboarding/);- assert.match(summary, /\*\*AI:\*\* The setup completion state is visible\./);+ assert.match(summary, /✅ \[Launch and finish onboarding\].*— 1m13s/);+ assert.match(summary, /— 52s/);+ assert.match(+ summary,+ /case-preview-ubuntu-case-ubuntu\.jpg/,+ );+ assert.match(summary, /<summary>All screenshots \(2\)<\/summary>/);+ assert.match(summary, /<summary>Passed cases \(2\)<\/summary>/);assert.doesNotMatch(summary, /report report/);assert.match(summary, /Each image is the original page screenshot/);});@@ -1110,16 +1123,20 @@ test('renders singular failure copy for one available report', () => {});assert.match(summary, /Ubuntu × Midscene · failure captured/);- assert.match(summary, /❌ Failed/);- assert.match(summary, /First failing screenshot: Broken flow/);+ assert.match(summary, /\*\*0\/1 cases · 0% passed\*\*/);+ assert.match(summary, /### Failures \(1\)/);+ assert.match(summary, /\| Case \| Duration \| Reason \|/);+ assert.match(summary, /❌ \[Broken flow\]/);assert.match(summary,- /\*\*Error:\*\* Node "aiAssert" failed: expected state missing\./,+ /Error: Node "aiAssert" failed: expected state missing\./,);assert.match(summary,/index\.html#runner-step=case-fail%3Asteps%3A2/,);+ assert.match(summary, /### Failed screenshots \(1\)/);+ assert.match(summary, /case-preview-ubuntu-case-fail\.jpg/);assert.match(summary, /Each image is the original page screenshot/);});