Files
CatoandClaude Opus 5.5 f1c5a7a654 feat(tools): task-flow criteria + measurement; answer first, one header, one empty state (#117)
* chore(ux): task flows with step and time budgets; production baseline

Ten top tasks across five audiences, each with a success criterion, a step
budget (clicks, keystrokes, choices and screens of scrolling) and a
time-to-first-answer budget, driven at 390 and 1440. Plus a dead-end check:
every empty or error state must offer the next action.

Baseline against production: 9 of 20 task runs pass; 3 of 5 empty/error
states are dead ends.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat(tools): answer first, one header, one empty state, no dead ends

Measured by scripts/ux (baseline in the previous commit), then fixed worst first:

- X-ray: names the biggest single-source risk, the country most weight rests
  on alone, and the most-shared bottleneck first (lib/xray/headline.ts,
  ranking only); scrolls the answer into view; Ctrl/Cmd+Enter runs; a list
  nobody could read offers the sample instead of a blank report; shared
  PageHeader; privacy note folded to one line; placeholder no longer looks
  like a filled portfolio.
- Scenarios: result first, picker folded under it; presets before the form;
  a Copy link button instead of a printed URL; an unreadable ?at says so.
- Careers: regions (Europe, North America, …) in the place filter, so
  "process engineers in Europe" is one choice, not thirty; results before
  the hiring sidebar on a phone.
- Data series: shared PageHeader and filter bar (auto-applies), search reads
  the bottleneck name, 40 rows then Show more (all 145 made a 1 MB page).
- Science pipeline: PageHeader with the counts in one line; jump links to
  what the feeds collected.
- Bottleneck pages: a signed-out reader sees Follow (sign in, come back)
  instead of nothing.
- Update news now: Try again on failure; a next step when nothing is new.
- Shared: Empty takes an action (desk, exposure, careers, series, pipeline,
  x-ray, reader views); a real not-found page with ways on; filter bars show
  one loading state; CopyLink; desk settings use PageHeader.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 00:40:42 -07:00

89 lines
3.4 KiB
JavaScript

/**
* Markdown for one run, and for a before/after pair.
*
* node scripts/ux/report.mjs reports/before.json reports/after.json > reports/compare.md
*/
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
const cell = (r) =>
r
? `${r.pass ? 'pass' : 'FAIL'} · ${r.steps} steps${r.seconds !== null ? ` · ${r.seconds}s` : ''}`
: '—';
export function markdown(report) {
const lines = [
`# UX task flows — ${report.label}`,
'',
`${report.base} · ${report.at}`,
'',
'Steps = clicks, keystrokes into a field, choices, ticks, and screens of scrolling to reach',
'what you act on or read. Budgets are per task; a task passes only inside both.',
'',
'| Task | Audience | Budget | 390 | 1440 |',
'| --- | --- | --- | --- | --- |',
];
for (const t of report.tasks) {
const [phone, desk] = [390, 1440].map((w) => t.runs.find((r) => r.viewport === w));
lines.push(
`| **${t.id}** — ${t.task} | ${t.audience} | ≤${t.maxSteps} steps, ≤${t.maxSeconds}s | ${cell(phone)} | ${cell(desk)} |`,
);
}
lines.push('', '## Why a task failed', '');
for (const t of report.tasks)
for (const r of t.runs)
if (!r.pass) lines.push(`- ${t.id} @${r.viewport}: ${r.why ?? 'not answered'}`);
lines.push('', '## Success criteria', '');
for (const t of report.tasks) lines.push(`- **${t.id}**: ${t.success}`);
lines.push('', '## Dead ends (every empty or error state must offer the next action)', '');
lines.push('| State | 390 | 1440 |', '| --- | --- | --- |');
for (const d of report.deadEnds) {
const [phone, desk] = [390, 1440].map((w) => d.runs.find((r) => r.viewport === w));
const show = (r) =>
!r
? '—'
: !r.found
? 'no message found'
: r.pass
? `ok (${r.actions.join(', ')})`
: 'DEAD END';
lines.push(`| \`${d.path}\` | ${show(phone)} | ${show(desk)} |`);
}
lines.push('', '## Step logs', '');
for (const t of report.tasks)
for (const r of t.runs) lines.push(`- ${t.id} @${r.viewport}: ${r.log.join(' → ') || '—'}`);
return `${lines.join('\n')}\n`;
}
export function compare(before, after) {
const lines = [
`# UX task flows — ${before.label} vs ${after.label}`,
'',
`${before.base} (${before.at.slice(0, 16)}) → ${after.base} (${after.at.slice(0, 16)})`,
'',
'| Task | Budget | 390 before | 390 after | 1440 before | 1440 after |',
'| --- | --- | --- | --- | --- | --- |',
];
for (const t of after.tasks) {
const b = before.tasks.find((x) => x.id === t.id);
const at = (set, w) => set?.runs.find((r) => r.viewport === w);
lines.push(
`| ${t.id} | ≤${t.maxSteps} steps, ≤${t.maxSeconds}s | ${cell(at(b, 390))} | ${cell(at(t, 390))} | ${cell(at(b, 1440))} | ${cell(at(t, 1440))} |`,
);
}
const passes = (r) => r.tasks.flatMap((t) => t.runs).filter((x) => x.pass).length;
const total = (r) => r.tasks.flatMap((t) => t.runs).length;
const open = (r) => r.deadEnds.flatMap((d) => d.runs).filter((x) => !x.pass).length;
lines.push(
'',
`Task runs passing: ${passes(before)}/${total(before)} → ${passes(after)}/${total(after)}.`,
`Dead ends: ${open(before)} → ${open(after)}.`,
);
return `${lines.join('\n')}\n`;
}
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const [a, b] = process.argv.slice(2).map((p) => JSON.parse(readFileSync(p, 'utf8')));
process.stdout.write(b ? compare(a, b) : markdown(a));
}