@aarwitz/tapp 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tapp",
3
3
  "description": "Give Claude hands and eyes on iOS, Android, and web apps, with exploration, replayable flows, evidence, and deterministic CI gates.",
4
- "version": "0.26.0",
4
+ "version": "0.27.0",
5
5
  "author": {
6
6
  "name": "Aaron Horowitz",
7
7
  "url": "https://github.com/aarwitz"
@@ -24,7 +24,7 @@
24
24
  "command": "npx",
25
25
  "args": [
26
26
  "-y",
27
- "@aarwitz/tapp@0.26.0",
27
+ "@aarwitz/tapp@0.27.0",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
package/browser/app.js CHANGED
@@ -499,6 +499,16 @@ async function keepJourney(form) {
499
499
  } catch (error) { toast(error.message, true); }
500
500
  }
501
501
 
502
+ // Not defects — what a person would notice and not like. Shown apart from issues, and labelled
503
+ // so nobody reads "nothing is broken" and "this is fine" as the same sentence.
504
+ function renderObservations(audit) {
505
+ const observations = audit.observations || [];
506
+ if (!observations.length) return "";
507
+ return `<h3>Worth a look <i class="zero">${observations.length}</i></h3>
508
+ <p class="muted">Not broken — things a person would notice and may not like.</p>
509
+ <ul class="detail-list">${observations.slice(0, 40).map((o) => `<li><b>${esc(o.severity)}</b> · ${esc(o.title)}${o.pages?.length > 1 ? ` <small>(${o.pages.length} pages)</small>` : ""}</li>`).join("")}</ul>`;
510
+ }
511
+
502
512
  function renderRuns() {
503
513
  renderJourneys();
504
514
  renderActors();
@@ -541,7 +551,7 @@ function renderRunDetail(run) {
541
551
  const audit = run.audit;
542
552
  const counts = audit.findingCounts || {};
543
553
  const issues = audit.issues || [];
544
- $("#run-detail").innerHTML = `<div class="run-detail-head"><div><p class="eyebrow">READ-ONLY AUDIT</p><h2>${esc(audit.url)}</h2><small><code>${esc(audit.id)}</code> · ${compactDate(audit.createdAt)} · nothing was clicked</small></div>${evidenceLink(audit.id, "Visual report")}</div><div class="run-stats"><div><strong>${audit.pagesAudited || 0}</strong><small>pages</small></div><div><strong>${issues.length}</strong><small>distinct issues</small></div><div><strong>${counts.high || 0}</strong><small>high</small></div><div><strong>${counts.medium || 0}</strong><small>medium</small></div></div><h3>Issues</h3>${issues.length ? `<ul class="detail-list">${issues.slice(0, 40).map((issue) => `<li><b>${esc(issue.severity)}</b> · ${esc(issue.title)}${issue.pages?.length > 1 ? ` <small>(${issue.pages.length} pages)</small>` : ""}</li>`).join("")}</ul>` : '<p class="muted">Nothing broken was observed. This says the pages are served without structural defects, not that the site works.</p>'}${detailLists(audit)}`;
554
+ $("#run-detail").innerHTML = `<div class="run-detail-head"><div><p class="eyebrow">READ-ONLY AUDIT</p><h2>${esc(audit.url)}</h2><small><code>${esc(audit.id)}</code> · ${compactDate(audit.createdAt)} · nothing was clicked</small></div>${evidenceLink(audit.id, "Visual report")}</div><div class="run-stats"><div><strong>${audit.pagesAudited || 0}</strong><small>pages</small></div><div><strong>${issues.length}</strong><small>distinct issues</small></div><div><strong>${counts.high || 0}</strong><small>high</small></div><div><strong>${counts.medium || 0}</strong><small>medium</small></div></div><h3>Issues</h3>${issues.length ? `<ul class="detail-list">${issues.slice(0, 40).map((issue) => `<li><b>${esc(issue.severity)}</b> · ${esc(issue.title)}${issue.pages?.length > 1 ? ` <small>(${issue.pages.length} pages)</small>` : ""}</li>`).join("")}</ul>` : '<p class="muted">Nothing broken was observed. This says the pages are served without structural defects, not that the site works.</p>'}${renderObservations(audit)}${detailLists(audit)}`;
545
555
  return;
546
556
  }
547
557
  if (run.kind === "explore") {
@@ -93,7 +93,11 @@ export function summarize(name, result = {}, { access = "" } = {}) {
93
93
  // A visitor only ever gets the read-only look; say what the next step is, because the
94
94
  // interesting part of any real application is behind its sign-in.
95
95
  const next = access === "anonymous" ? " Sign in and tapp will go inside — and ask you for a test account if it meets a sign-in." : "";
96
- return { tone: issues ? "caution" : "ready", pill: issues ? `${issues} issue${issues === 1 ? "" : "s"} found` : "✓ Nothing broken observed", text: `${result.pagesAudited || 0} page(s) rendered read-only — nothing was clicked. ${issues ? "Each issue is listed in the run detail with the pages it appears on." : "This says the pages are served without structural defects, not that the site works."}${next}` };
96
+ // Two numbers, never merged: what is broken, and what a person would notice and not like.
97
+ const noticed = result.observationCount || 0;
98
+ const pill = issues ? `${issues} issue${issues === 1 ? "" : "s"}${noticed ? ` · ${noticed} to notice` : ""}` : noticed ? `${noticed} thing${noticed === 1 ? "" : "s"} a person would notice` : "✓ Nothing broken observed";
99
+ const noticedText = noticed ? ` It also found ${noticed} thing${noticed === 1 ? "" : "s"} a person would notice — faint text, controls too small to tap on a phone, copy nobody finished — listed under “Worth a look”.` : "";
100
+ return { tone: issues ? "caution" : noticed ? "caution" : "ready", pill, text: `${result.pagesAudited || 0} page(s) rendered read-only — nothing was clicked. ${issues ? "Each issue is listed in the run detail with the pages it appears on." : "Nothing is broken."}${noticedText}${next}` };
97
101
  }
98
102
  if (gateOutcome) {
99
103
  const tone = { pass: "ready", fail: "blocked", inconclusive: "caution" }[gateOutcome] || "caution";
@@ -217,6 +217,9 @@ function listAudits(limit = 50, owner = null) {
217
217
  url: summary.url, pagesAudited: summary.pagesAudited || 0, pagesWithUnverifiableWiring: summary.pagesWithUnverifiableWiring || 0,
218
218
  findingCounts: summary.findingCounts || {}, issueCount: summary.issueCount ?? (summary.issues || []).length,
219
219
  issues: (summary.issues || []).slice(0, 60), checkedFor: summary.checkedFor || [], notChecked: summary.notChecked || [],
220
+ // Things a person would notice and not like — carried through so the run detail can show
221
+ // them under "Worth a look", apart from the defect count.
222
+ observations: (summary.observations || []).slice(0, 60), observationCount: summary.observationCount ?? (summary.observations || []).length,
220
223
  });
221
224
  }
222
225
  return audits.sort((a, b) => b.createdAt.localeCompare(a.createdAt)).slice(0, limit);
@@ -0,0 +1,277 @@
1
+ // Things a person would notice and not like.
2
+ //
3
+ // Separate from defects on purpose. A broken image or a 404 is a *defect*: the page does not do
4
+ // what it says. Text nobody can read, a button too small to hit on a phone, a label that says
5
+ // "Click here", "Lorem ipsum" left in a paragraph — none of those are broken, and all of them are
6
+ // the first thing a real visitor reacts to. tapp reports them as **observations**, counted and
7
+ // listed apart from issues, so "3 issues" never quietly means "3 issues and 14 opinions".
8
+ //
9
+ // Every check here is deterministic and reads the rendered page — no model, no API key, no
10
+ // judgement call that cannot be re-derived from the DOM. Each is capped so one bad page cannot
11
+ // produce a thousand lines, and each carries the selector it came from so the report can point.
12
+ const CAPS = { contrast: 8, tap: 8, clipped: 6, overlap: 4, placeholder: 5, unlabelled: 6, nameless: 6, tiny: 5, alt: 6 };
13
+
14
+ /**
15
+ * Run the in-page pass. Returns raw observations; `observationFindings` turns them into findings.
16
+ *
17
+ * Two passes: the page as rendered, then the same page at phone width. Size-and-space questions —
18
+ * is this big enough to tap, does the text fit, does the page scroll sideways — have no honest
19
+ * answer at desktop width, where a 20px-tall nav link is simply a nav link. They are asked on a
20
+ * phone, which is where most people meet the page and where the answer is interesting.
21
+ */
22
+ export async function collectPageObservations(page, { caps = CAPS, phone = { width: 390, height: 844 } } = {}) {
23
+ const pass = async (mode) => page.evaluate(({ limits, mode: m }) => {
24
+ const out = [];
25
+ let n = 0;
26
+ const tag = (el) => { n += 1; el.setAttribute("data-tapp-observation", String(n)); return `[data-tapp-observation="${n}"]`; };
27
+ const rect = (el) => el.getBoundingClientRect();
28
+ const visible = (el) => {
29
+ if (!el || !el.getClientRects || el.getClientRects().length === 0) return false;
30
+ const style = getComputedStyle(el);
31
+ if (style.visibility === "hidden" || style.display === "none" || Number(style.opacity) === 0) return false;
32
+ const box = rect(el);
33
+ return box.width > 0 && box.height > 0 && box.bottom > 0 && box.right > 0;
34
+ };
35
+ const textOf = (el) => (el.innerText || el.textContent || "").replace(/\s+/g, " ").trim();
36
+ const count = (kind) => out.filter((o) => o.kind === kind).length;
37
+
38
+ // ── colour contrast ────────────────────────────────────────────────────────────────────
39
+ const parseColor = (value) => {
40
+ const m = String(value).match(/rgba?\(([^)]+)\)/);
41
+ if (!m) return null;
42
+ const parts = m[1].split(",").map((p) => parseFloat(p.trim()));
43
+ return { r: parts[0], g: parts[1], b: parts[2], a: parts.length > 3 ? parts[3] : 1 };
44
+ };
45
+ const luminance = ({ r, g, b }) => {
46
+ const channel = (c) => { const s = c / 255; return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4; };
47
+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
48
+ };
49
+ const backgroundOf = (el) => {
50
+ let node = el;
51
+ while (node && node !== document.documentElement) {
52
+ const bg = parseColor(getComputedStyle(node).backgroundColor);
53
+ if (bg && bg.a > 0.75) return bg;
54
+ node = node.parentElement;
55
+ }
56
+ return { r: 255, g: 255, b: 255, a: 1 };
57
+ };
58
+ const ratio = (fg, bg) => {
59
+ const a = luminance(fg) + 0.05;
60
+ const b = luminance(bg) + 0.05;
61
+ return a > b ? a / b : b / a;
62
+ };
63
+ const textNodes = [...document.querySelectorAll("p,span,a,li,h1,h2,h3,h4,h5,h6,button,label,td,th,small,strong,em,div")].slice(0, 1200);
64
+ for (const el of textNodes) {
65
+ if (count("low_contrast") >= limits.contrast) break;
66
+ // Only elements whose own text is the thing being read.
67
+ const own = [...el.childNodes].filter((node) => node.nodeType === 3).map((node) => node.textContent).join("").replace(/\s+/g, " ").trim();
68
+ if (own.length < 8 || !visible(el)) continue;
69
+ const style = getComputedStyle(el);
70
+ const fg = parseColor(style.color);
71
+ if (!fg || fg.a < 0.75) continue;
72
+ // A background image can carry any colour; the computed ratio would be fiction.
73
+ if (getComputedStyle(el).backgroundImage !== "none") continue;
74
+ const bg = backgroundOf(el);
75
+ const size = parseFloat(style.fontSize) || 16;
76
+ const bold = Number(style.fontWeight) >= 700;
77
+ const large = size >= 24 || (size >= 18.66 && bold);
78
+ const need = large ? 3 : 4.5;
79
+ const got = ratio(fg, bg);
80
+ if (got + 0.05 < need) out.push({ kind: "low_contrast", selector: tag(el), text: own.slice(0, 60), ratio: Math.round(got * 10) / 10, need, size: Math.round(size) });
81
+ }
82
+
83
+ // ── controls too small to hit, and controls sitting on top of each other ───────────────
84
+ const interactive = [...document.querySelectorAll('a[href],button,[role="button"],input[type="submit"],input[type="button"],select,summary')].filter(visible).slice(0, 200);
85
+ for (const el of (m === "phone" ? interactive : [])) {
86
+ if (count("tiny_tap_target") >= limits.tap) break;
87
+ const box = rect(el);
88
+ // Inline links inside a sentence are read, not tapped at their own size; judge standalone
89
+ // controls only (a link that is its own block, or any button).
90
+ const inlineLink = el.tagName === "A" && getComputedStyle(el).display.startsWith("inline") && box.height < 30 && textOf(el).length > 0 && el.parentElement && textOf(el.parentElement).length > textOf(el).length + 10;
91
+ if (inlineLink) continue;
92
+ // Footer link lists are dense everywhere and nobody is surprised by them; reporting six
93
+ // of them buries the button someone actually needs to hit.
94
+ if (el.tagName === "A" && el.closest("footer,[role=contentinfo]")) continue;
95
+ if (box.width < 32 || box.height < 32) out.push({ kind: "tiny_tap_target", selector: tag(el), label: textOf(el).slice(0, 40) || el.getAttribute("aria-label") || el.tagName.toLowerCase(), width: Math.round(box.width), height: Math.round(box.height) });
96
+ }
97
+ for (let i = 0; m === "phone" && i < interactive.length && count("overlapping_controls") < limits.overlap; i += 1) {
98
+ for (let j = i + 1; j < interactive.length; j += 1) {
99
+ const a = rect(interactive[i]);
100
+ const b = rect(interactive[j]);
101
+ if (interactive[i].contains(interactive[j]) || interactive[j].contains(interactive[i])) continue;
102
+ const overlap = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left)) * Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));
103
+ const smaller = Math.min(a.width * a.height, b.width * b.height);
104
+ if (smaller > 0 && overlap / smaller > 0.6) {
105
+ out.push({ kind: "overlapping_controls", selector: tag(interactive[i]), other: textOf(interactive[j]).slice(0, 30), label: textOf(interactive[i]).slice(0, 30) });
106
+ break;
107
+ }
108
+ }
109
+ }
110
+
111
+ // ── text cut off by its own box (and, on a phone, a page that scrolls sideways) ────────
112
+ if (m === "phone") {
113
+ const doc = document.documentElement;
114
+ const wide = Math.max(doc.scrollWidth, document.body ? document.body.scrollWidth : 0) - window.innerWidth;
115
+ if (wide > 2) out.push({ kind: "phone_overflow", overflow: Math.round(wide), viewport: window.innerWidth });
116
+ }
117
+ for (const el of textNodes) {
118
+ if (count("clipped_text") >= limits.clipped) break;
119
+ if (!visible(el)) continue;
120
+ const style = getComputedStyle(el);
121
+ if (!/hidden|clip/.test(style.overflow + style.overflowX)) continue;
122
+ if (style.textOverflow === "ellipsis") continue; // deliberate truncation, and it shows
123
+ const text = textOf(el);
124
+ if (text.length < 10) continue;
125
+ if (el.scrollWidth > el.clientWidth + 4) out.push({ kind: "clipped_text", selector: tag(el), text: text.slice(0, 60), cut: el.scrollWidth - el.clientWidth });
126
+ }
127
+
128
+ // ── copy nobody meant to ship (asked once, at the page's own width) ────────────────────
129
+ const body = m === "phone" ? "" : (document.body?.innerText || "").replace(/\s+/g, " ");
130
+ for (const pattern of [/lorem ipsum[^.]{0,80}/i, /dolor sit amet[^.]{0,60}/i, /\bTODO\b[^.]{0,60}/, /\bFIXME\b[^.]{0,60}/, /coming soon[^.]{0,40}/i, /placeholder[^.]{0,40}/i, /\btest test\b[^.]{0,30}/i, /\bundefined\b|\bNaN\b|\[object Object\]/]) {
131
+ if (count("placeholder_copy") >= limits.placeholder) break;
132
+ const found = body.match(pattern);
133
+ if (found) out.push({ kind: "placeholder_copy", text: found[0].trim().slice(0, 80) });
134
+ }
135
+
136
+ // ── things a person cannot identify ────────────────────────────────────────────────────
137
+ for (const el of (m === "phone" ? [] : [...document.querySelectorAll("input,select,textarea")].filter(visible).slice(0, 80))) {
138
+ if (count("unlabelled_field") >= limits.unlabelled) break;
139
+ const type = (el.getAttribute("type") || "").toLowerCase();
140
+ if (["hidden", "submit", "button", "image", "reset"].includes(type)) continue;
141
+ const labelled = (el.id && document.querySelector(`label[for="${CSS.escape(el.id)}"]`)) || el.closest("label")
142
+ || el.getAttribute("aria-label") || el.getAttribute("aria-labelledby") || el.getAttribute("placeholder") || el.getAttribute("title");
143
+ if (!labelled) out.push({ kind: "unlabelled_field", selector: tag(el), name: el.getAttribute("name") || type || el.tagName.toLowerCase() });
144
+ }
145
+ for (const el of (m === "phone" ? [] : interactive)) {
146
+ if (count("nameless_control") >= limits.nameless) break;
147
+ const name = textOf(el) || el.getAttribute("aria-label") || el.getAttribute("title") || el.querySelector("img[alt]")?.getAttribute("alt") || "";
148
+ if (!name.trim()) out.push({ kind: "nameless_control", selector: tag(el), tagName: el.tagName.toLowerCase() });
149
+ }
150
+ const vague = new Set(["click here", "here", "read more", "learn more", "more", "link", "this"]);
151
+ const vagueLinks = m === "phone" ? [] : [...document.querySelectorAll("a[href]")].filter(visible).map(textOf).filter((t) => vague.has(t.toLowerCase()));
152
+ if (vagueLinks.length) out.push({ kind: "vague_link_text", total: vagueLinks.length, sample: [...new Set(vagueLinks)].slice(0, 3) });
153
+
154
+ // ── text too small to read comfortably ─────────────────────────────────────────────────
155
+ for (const el of (m === "phone" ? [] : textNodes)) {
156
+ if (count("tiny_text") >= limits.tiny) break;
157
+ if (!visible(el)) continue;
158
+ const own = [...el.childNodes].filter((node) => node.nodeType === 3).map((node) => node.textContent).join("").trim();
159
+ if (own.length < 25) continue;
160
+ const size = parseFloat(getComputedStyle(el).fontSize) || 16;
161
+ if (size < 12) out.push({ kind: "tiny_text", selector: tag(el), size: Math.round(size * 10) / 10, text: own.replace(/\s+/g, " ").slice(0, 50) });
162
+ }
163
+
164
+ // ── pictures with nothing to say, and a page with no headline ──────────────────────────
165
+ for (const img of (m === "phone" ? [] : [...document.images].filter(visible).slice(0, 120))) {
166
+ if (count("image_without_alt") >= limits.alt) break;
167
+ const box = rect(img);
168
+ if (box.width < 48 || box.height < 48) continue;
169
+ if (!img.hasAttribute("alt")) out.push({ kind: "image_without_alt", selector: tag(img), src: (img.getAttribute("src") || "").slice(0, 100) });
170
+ }
171
+ if (m !== "phone") {
172
+ const h1s = [...document.querySelectorAll("h1")].filter(visible);
173
+ if (h1s.length === 0) out.push({ kind: "no_headline" });
174
+ else if (h1s.length > 2) out.push({ kind: "many_headlines", total: h1s.length });
175
+
176
+ const title = (document.title || "").trim();
177
+ if (!title || /^(document|untitled|index|home page|react app|vite app)$/i.test(title)) out.push({ kind: "weak_page_title", title: title.slice(0, 60) });
178
+
179
+ const nav = performance.getEntriesByType?.("navigation")?.[0];
180
+ const loaded = nav?.loadEventEnd && nav.startTime !== undefined ? nav.loadEventEnd - nav.startTime : 0;
181
+ if (loaded > 4000) out.push({ kind: "slow_page", ms: Math.round(loaded) });
182
+ }
183
+
184
+ return out.map((o) => (m === "phone" ? { ...o, phone: true } : o));
185
+ }, { limits: caps, mode });
186
+
187
+ try {
188
+ const desktop = await pass("desktop");
189
+ const was = page.viewportSize?.();
190
+ // Only worth asking when the page is not already at phone width — and never mid-exploration,
191
+ // where resizing the window would disturb the run that is clicking through the app.
192
+ if (!phone || !was || was.width <= 600) return desktop;
193
+ let mobile = [];
194
+ try {
195
+ await page.setViewportSize(phone);
196
+ await page.waitForTimeout(350);
197
+ mobile = await pass("phone");
198
+ } finally {
199
+ await page.setViewportSize(was).catch(() => {});
200
+ await page.waitForTimeout(150);
201
+ }
202
+ return [...desktop, ...mobile];
203
+ } catch {
204
+ // An observation pass must never be the reason a run fails.
205
+ return [];
206
+ }
207
+ }
208
+
209
+ /** Turn raw observations into the finding shape the report and the Studio already render. */
210
+ export function observationFindings(raw = []) {
211
+ const out = [];
212
+ for (const o of raw) {
213
+ const base = { category: "polish", severity: "low", selector: o.selector || null };
214
+ switch (o.kind) {
215
+ case "low_contrast":
216
+ out.push({ ...base, type: "low_contrast", title: `Hard to read: “${o.text}” is ${o.ratio}:1 against its background (needs ${o.need}:1 at ${o.size}px)`, target: o.selector || o.text });
217
+ break;
218
+ case "tiny_tap_target":
219
+ out.push({ ...base, type: "tiny_tap_target", title: `On a phone, “${o.label}” is ${o.width}×${o.height}px — smaller than a fingertip (about 44px)`, target: o.label });
220
+ break;
221
+ case "phone_overflow":
222
+ out.push({ ...base, severity: "medium", type: "phone_overflow", title: `On a phone the page is ${o.overflow}px wider than the ${o.viewport}px screen — it scrolls sideways`, target: `overflow:${o.overflow}` });
223
+ break;
224
+ case "overlapping_controls":
225
+ out.push({ ...base, type: "overlapping_controls", title: `Overlapping controls: “${o.label}” sits on top of “${o.other}” — one of them takes the tap`, target: o.label });
226
+ break;
227
+ case "clipped_text":
228
+ out.push({ ...base, type: "clipped_text", title: `${o.phone ? "On a phone, text" : "Text"} is cut off: “${o.text}” overflows its box by ${o.cut}px with nothing to show it was trimmed`, target: o.text });
229
+ break;
230
+ case "placeholder_copy":
231
+ out.push({ ...base, severity: "medium", type: "placeholder_copy", title: `Unfinished copy on the page: “${o.text}”`, target: o.text });
232
+ break;
233
+ case "unlabelled_field":
234
+ out.push({ ...base, type: "unlabelled_field", title: `Form field “${o.name}” has no label, placeholder or title — nothing says what to type`, target: o.name });
235
+ break;
236
+ case "nameless_control":
237
+ out.push({ ...base, type: "nameless_control", title: `A <${o.tagName}> with no text or label — neither a person nor a screen reader can tell what it does`, target: o.selector });
238
+ break;
239
+ case "vague_link_text":
240
+ out.push({ ...base, type: "vague_link_text", title: `${o.total} link(s) say only ${o.sample.map((s) => `“${s}”`).join(", ")} — the text alone does not say where they go`, target: o.sample[0] });
241
+ break;
242
+ case "tiny_text":
243
+ out.push({ ...base, type: "tiny_text", title: `Very small text (${o.size}px): “${o.text}”`, target: o.text });
244
+ break;
245
+ case "image_without_alt":
246
+ out.push({ ...base, type: "image_without_alt", title: `Image has no alt text: ${o.src}`, target: o.src });
247
+ break;
248
+ case "no_headline":
249
+ out.push({ ...base, type: "no_headline", title: "The page has no visible <h1> — nothing states what this page is", target: "h1" });
250
+ break;
251
+ case "many_headlines":
252
+ out.push({ ...base, type: "many_headlines", title: `${o.total} <h1> headlines on one page — the page claims several subjects`, target: "h1" });
253
+ break;
254
+ case "weak_page_title":
255
+ out.push({ ...base, type: "weak_page_title", title: `The browser tab says “${o.title || "(nothing)"}” — a bookmark or a tab cannot be told apart`, target: "title" });
256
+ break;
257
+ case "slow_page":
258
+ out.push({ ...base, severity: "medium", type: "slow_page", title: `The page took ${(o.ms / 1000).toFixed(1)}s to finish loading`, target: `${o.ms}ms` });
259
+ break;
260
+ default:
261
+ break;
262
+ }
263
+ }
264
+ return out;
265
+ }
266
+
267
+ /** What this pass looked for, in the words the report uses. */
268
+ export const OBSERVATION_SCOPE = [
269
+ "text too faint to read, or too small",
270
+ "controls too small to tap, or overlapping, at phone width",
271
+ "text cut off by its own box, and pages that scroll sideways on a phone",
272
+ "unfinished copy (lorem ipsum, TODO, “coming soon”, undefined)",
273
+ "fields with no label and controls with no name",
274
+ "links that say only “click here”",
275
+ "images with no alt text, pages with no headline, weak tab titles",
276
+ "pages that take more than four seconds to load",
277
+ ];
@@ -18,6 +18,7 @@ import {
18
18
  auditFindingsFromControls, slug,
19
19
  } from "./web-explorer.js";
20
20
  import { buildQaReport } from "./report.js";
21
+ import { collectPageObservations, observationFindings, OBSERVATION_SCOPE } from "./page-observations.js";
21
22
  import { writeHtmlReport } from "./html-report.js";
22
23
  import { buildUiMapFromMarkers, writeUiMap } from "./ui-map.js";
23
24
  import { writeCaptureProvenance } from "./capture-provenance.js";
@@ -254,8 +255,11 @@ async function auditOnePage(context, target, { timeoutMs, linkCheckLimit, captur
254
255
 
255
256
  const structural = auditFindingsFromControls(controls.dead).map((f, i) => ({ ...f, selector: controls.dead[i].selector }));
256
257
  const findings = [...structural, ...healthFindings(health.findings), ...loadFindings, ...links.findings];
258
+ // Things a person would notice and not like — counted and listed apart from defects, so the
259
+ // issue count never quietly includes opinions. See page-observations.js.
260
+ const observations = observationFindings(await collectPageObservations(page));
257
261
  const screen = target.pathname + target.search;
258
- for (const f of findings) { f.screen = screen; if (!f.url) f.url = page.url(); }
262
+ for (const f of [...findings, ...observations]) { f.screen = screen; if (!f.url) f.url = page.url(); }
259
263
 
260
264
  // Where this page's screenshot landed, so a live viewer can show the page being audited
261
265
  // instead of an empty panel. Absolute, because that is what the progress channel forwards.
@@ -272,21 +276,22 @@ async function auditOnePage(context, target, { timeoutMs, linkCheckLimit, captur
272
276
  framePath = path.join(capture.dir, `frame_${capture.states}.png`);
273
277
  await page.screenshot({ path: framePath }).catch(() => { framePath = statePath; });
274
278
  capture.emit("STATE", { screen, url: page.url(), elements: controls.controlCount, role: "page", controls: controls.dead.map((d) => d.label).filter(Boolean).slice(0, 40), inputs: [], settled: true, screenshot: stateName });
275
- for (const f of findings) {
279
+ for (const f of [...findings, ...observations]) {
276
280
  if (f.selector) {
277
281
  capture.evidence += 1;
278
282
  const name = `evidence_${capture.evidence}_${slug(f.type)}.png`;
279
283
  const shot = await captureElementEvidence(page, page.locator(f.selector), capture.dir, name);
280
284
  if (shot) f.evidence = shot;
281
285
  }
282
- capture.emit("ISSUE", { type: f.type, severity: f.severity, title: f.title, screen, ...(f.target ? { target: f.target } : {}), url: f.url, ...(f.evidence ? { evidence: f.evidence } : {}) });
286
+ capture.emit("ISSUE", { type: f.type, severity: f.severity, ...(f.category ? { category: f.category } : {}), title: f.title, screen, ...(f.target ? { target: f.target } : {}), url: f.url, ...(f.evidence ? { evidence: f.evidence } : {}) });
283
287
  }
284
288
  }
285
- for (const f of findings) delete f.selector;
289
+ for (const f of [...findings, ...observations]) delete f.selector;
286
290
 
287
291
  return {
288
292
  url: page.url(),
289
293
  title: controls.title,
294
+ observations,
290
295
  ...(observationOnly ? { visibleText: await page.locator("body").innerText({ timeout: bounded }).then(text => text.slice(0, 12000)).catch(() => ""),
291
296
  visibleTextLimit: 12000 } : {}),
292
297
  ...(page.video() ? { recording: path.basename(await page.video().path()) } : {}),
@@ -367,7 +372,7 @@ export function dedupeSiteIssues(findings = []) {
367
372
  existing.occurrences += 1;
368
373
  continue;
369
374
  }
370
- byKey.set(key, { type: f.type, severity: f.severity, title: f.title, target: f.target ?? null, evidence: f.evidence || null, pages: page ? [page] : [], occurrences: 1 });
375
+ byKey.set(key, { type: f.type, severity: f.severity, ...(f.category ? { category: f.category } : {}), title: f.title, target: f.target ?? null, evidence: f.evidence || null, pages: page ? [page] : [], occurrences: 1 });
371
376
  }
372
377
  const rank = { critical: 0, high: 1, medium: 2, low: 3 };
373
378
  return [...byKey.values()].sort((a, b) => (rank[a.severity] ?? 4) - (rank[b.severity] ?? 4) || b.pages.length - a.pages.length);
@@ -492,6 +497,7 @@ export async function auditWebSite({
492
497
  // Closing the context finalizes page recordings before evidence is uploaded.
493
498
  await context.close();
494
499
  const findings = results.flatMap((r) => r.findings);
500
+ const observations = dedupeSiteIssues(results.flatMap((r) => r.observations || []));
495
501
  const issues = dedupeSiteIssues(findings);
496
502
  const bySeverity = { critical: 0, high: 0, medium: 0, low: 0 };
497
503
  for (const f of findings) if (f.severity in bySeverity) bySeverity[f.severity] += 1;
@@ -514,6 +520,11 @@ export async function auditWebSite({
514
520
  // link that answers 404 on six pages is one thing to fix, and one line in an email.
515
521
  issues,
516
522
  issueCount: issues.length,
523
+ // Not defects: things a person would notice and not like, kept in their own list so the
524
+ // issue count stays a count of things that are broken.
525
+ observations,
526
+ observationCount: observations.length,
527
+ lookedForAlso: OBSERVATION_SCOPE,
517
528
  checkedFor: scope.checkedFor,
518
529
  notChecked: [...scope.notChecked, ...observationLimits, ...(skippedLinks.size ? ["Potential action/signed links and robots exclusions were not fetched; see skippedLinks."] : [])],
519
530
  pages: results,
@@ -541,6 +552,7 @@ export async function auditWebPage({ url, timeoutMs = NAV_TIMEOUT_MS, device = "
541
552
  controlsExamined: page.controlsExamined,
542
553
  linksChecked: page.linksChecked,
543
554
  findings: page.findings,
555
+ observations: page.observations || [],
544
556
  checkedFor: site.checkedFor,
545
557
  notChecked: site.notChecked,
546
558
  capture: site.capture,
@@ -826,6 +826,13 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
826
826
 
827
827
  const deadline = Date.now() + timeoutSec * 1000;
828
828
  const issues = []; // emitted immediately; kept for counting only
829
+ // Things a person would notice and not like, asked once per route (page-observations.js). They
830
+ // carry category "polish" so a reader can tell them from defects.
831
+ const observedRoutes = new Set();
832
+ const observation = (o, screen) => {
833
+ issues.push(o.type);
834
+ emit("ISSUE", { t: Date.now() - startedAtMs, type: o.type, severity: o.severity, category: "polish", title: o.title, screen, ...(o.target ? { target: o.target } : {}), url: page.url() });
835
+ };
829
836
  const issue = (type, severity, title, screen, target, sourceUrl, evidence) => {
830
837
  issues.push(type);
831
838
  // Findings belong to the page that CARRIED the defect. Async detectors default to the
@@ -1005,6 +1012,11 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1005
1012
  const evidenceKey = splitting ? `${key}::${screen}::${signature}` : `${key}::${screen}`;
1006
1013
  currentScreen = screen;
1007
1014
  emit("STATE", { t: Date.now() - startedAtMs, screen, url: key, ...(signature ? { signature } : {}), elements: info.controlCount, role: webScreenRole(screen, info.inputs), controls: info.controls, inputs: info.inputs, settled: !info.busy });
1015
+ if (!observedRoutes.has(key) && observedRoutes.size < 8) {
1016
+ observedRoutes.add(key);
1017
+ const { collectPageObservations, observationFindings } = await import("./page-observations.js");
1018
+ for (const found of observationFindings(await collectPageObservations(page, { phone: null }))) observation(found, screen);
1019
+ }
1008
1020
  const completedNavigation = pendingNavigation;
1009
1021
  const transitionFrom = webTransitionOrigin(completedNavigation, lastScreen);
1010
1022
  const transitionAction = completedNavigation?.action || lastActionTarget;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "mcpName": "io.github.aarwitz/tapp",
5
5
  "description": "Let coding agents verify UI changes on real iOS, Android, and web surfaces, then enforce reviewed proof in deterministic CI.",
6
6
  "license": "MIT",
@@ -96,7 +96,7 @@
96
96
  "mobile"
97
97
  ],
98
98
  "scripts": {
99
- "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-audit.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/access-jwt.test.js tests/studio-client.test.js tests/journeys.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
99
+ "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-audit.test.js tests/page-observations.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/access-jwt.test.js tests/studio-client.test.js tests/journeys.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
100
100
  "test:browser-journey": "node --test tests/browser-journey.test.js",
101
101
  "test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
102
102
  }