@aarwitz/tapp 0.35.5 → 0.35.7

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.
package/browser/app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { customerProductContract } from "./product-contract.js";
2
- import { classifyPrompt, narrate, narrateFinding, operationIsPending, summarize } from "./view-model.js";
2
+ import { classifyPrompt, coverageGraph, groupFindings, narrate, narrateFinding, operationIsPending, severityTally, summarize } from "./view-model.js";
3
3
 
4
4
  const API_BASE = String(document.querySelector('meta[name="tapp-api-base"]')?.content || "").replace(/\/$/, "");
5
5
  const LOGIN_URL = String(document.querySelector('meta[name="tapp-login-url"]')?.content || "");
@@ -141,6 +141,10 @@ function activateView(view) {
141
141
  $$('.primary-nav [data-view]').forEach((button) => button.classList.toggle("active", button.dataset.view === view));
142
142
  history.replaceState(null, "", `#${view}`);
143
143
  window.scrollTo({ top:0, behavior:"instant" });
144
+ // Findings and Coverage read whichever run is selected; render on arrival so they are never a
145
+ // stale picture of a run the person has since changed in another view.
146
+ if (view === "findings") renderFindings();
147
+ if (view === "coverage") renderCoverage();
144
148
  }
145
149
 
146
150
  // A hosted Studio has no Mac, no simulator and no access to the visitor's disk, so folders,
@@ -742,6 +746,9 @@ function renderRuns() {
742
746
  const chosen = runs.find((run) => run.id === state.selectedRunId) || runs[0];
743
747
  if (chosen) state.selectedRunId = chosen.id;
744
748
  renderRunDetail(chosen);
749
+ setCount("#findings-count", runFindings(chosen).length);
750
+ if (state.activeView === "findings") renderFindings();
751
+ if (state.activeView === "coverage") renderCoverage();
745
752
  }
746
753
 
747
754
  function detailLists(report) {
@@ -770,6 +777,214 @@ function renderRunDetail(run) {
770
777
  $("#run-detail").innerHTML = `<div class="run-detail-head"><div><p class="eyebrow">${esc(report.gate?.failed ? "BLOCKED" : report.inconclusive ? "INCONCLUSIVE" : "RELEASE RUN")}</p><h2>${esc(report.headline || "Release gate completed")}</h2><small><code>${esc(run.id)}</code> · ${compactDate(run.createdAt)}</small></div>${reportLink(report, "Visual report")}</div><div class="run-stats"><div><strong>${report.screensExplored || 0}</strong><small>states</small></div><div><strong>${report.actionsPerformed || 0}</strong><small>actions</small></div><div><strong>${contracts.filter((item) => item.passed).length}/${contracts.length}</strong><small>contracts</small></div><div><strong>${report.findingCounts?.total ?? (report.findings || []).length}</strong><small>findings</small></div></div><h3>Decision rationale</h3><ul class="detail-list">${(report.gate?.reasons || ["No blocking gate reason reported."]).map((item) => `<li>${esc(item)}</li>`).join("")}</ul><h3>Deterministic contracts</h3>${contracts.length ? contracts.map((contract) => `<div class="contract-result"><span class="${contract.passed ? "pass" : "fail"}">${contract.passed ? "✓" : "×"}</span><div><strong>${esc(contract.title || contract.name || contract.path)}</strong><small>${esc(contract.detail || contract.path || "Deterministic replay")}</small></div></div>`).join("") : '<p class="muted">No committed release contracts applied to this target.</p>'}${detailLists(report)}`;
771
778
  }
772
779
 
780
+ // ---- Findings and Coverage: reading a run (TM-794) ------------------------------------------
781
+ // Both views read the run the Runs view has selected, so picking a run in one picks it in all
782
+ // three. Neither computes anything about the run: Findings arranges the findings the engine
783
+ // reported, and Coverage draws the map the engine wrote beside the capture.
784
+
785
+ function selectedRun() {
786
+ const runs = allRuns();
787
+ return runs.find((run) => run.id === state.selectedRunId) || runs[0] || null;
788
+ }
789
+
790
+ // What a run reported, in the engine's own two kinds. A read-only audit keeps them apart on
791
+ // purpose: an *issue* is broken, an *observation* is something a person would notice and not
792
+ // like. Merging them would say a site is broken because its body text is faint, so the view
793
+ // keeps the separation the engine drew and groups each side on its own.
794
+ function runSections(run) {
795
+ if (!run) return [];
796
+ const page = (item) => ({ ...item, screen: item.screen || item.pages?.[0] || "" });
797
+ if (run.kind === "audit") {
798
+ return [
799
+ { id: "issues", title: "Broken", note: "Structural defects the pages were served with.", empty: "Nothing broken was observed. That says the pages are served without structural defects, not that the site works.", items: (run.audit?.issues || []).map(page) },
800
+ { id: "observations", title: "Worth a look", note: "Not broken — things a person would notice and may not like.", empty: "", items: (run.audit?.observations || []).map(page) },
801
+ ];
802
+ }
803
+ const report = run.kind === "explore" ? run.explore?.report : run.report;
804
+ return [{ id: "findings", title: "Findings", note: "", empty: "Nothing was found in the surfaces this run exercised. That is not the same as “this works”.", items: (report?.findings || []).map(page) }];
805
+ }
806
+
807
+ // Every finding a run reported, whatever kind of run it is — what the nav badge counts.
808
+ function runFindings(run) {
809
+ return runSections(run).flatMap((section) => section.items);
810
+ }
811
+
812
+ function runLabel(run) {
813
+ if (!run) return "";
814
+ if (run.kind === "audit") { try { return `Audit · ${new URL(run.audit.url).host}`; } catch { return `Audit · ${run.audit.url}`; } }
815
+ if (run.kind === "explore") return `Explore · ${run.explore.target || run.explore.platform}`;
816
+ return run.report?.headline ? String(run.report.headline).slice(0, 60) : `Release run ${run.id.slice(-8)}`;
817
+ }
818
+
819
+ // What a run drove, so its evidence can be shown in that thing's shape.
820
+ function runPlatform(run) {
821
+ if (!run) return "";
822
+ if (run.kind === "audit") return "web";
823
+ if (run.kind === "explore") return run.explore?.platform || "";
824
+ return run.report?.platform || "";
825
+ }
826
+
827
+ // The capture a run's evidence lives in. Explorations and audits are named for it; a gate run
828
+ // carries it inside its report.
829
+ function runCaptureId(run) {
830
+ if (!run) return "";
831
+ if (run.kind === "audit" || run.kind === "explore") return run.id;
832
+ return captureId(run.report);
833
+ }
834
+
835
+ function renderRunPicker(selector) {
836
+ const runs = allRuns();
837
+ const node = $(selector);
838
+ if (!node) return;
839
+ node.innerHTML = runs.map((run) => `<option value="${esc(run.id)}"${run.id === state.selectedRunId ? " selected" : ""}>${esc(runLabel(run))} · ${esc(compactDate(run.createdAt))}</option>`).join("");
840
+ node.classList.toggle("hidden", runs.length < 2);
841
+ }
842
+
843
+ function renderFindings() {
844
+ const run = selectedRun();
845
+ renderRunPicker("#findings-run");
846
+ const body = $("#findings-body");
847
+ if (!run) { body.innerHTML = '<div class="empty">No run yet. Put a URL in the prompt and tapp will go and look.</div>'; return; }
848
+ const sections = runSections(run).map((section) => ({ ...section, groups: groupFindings(section.items) }));
849
+ const total = sections.reduce((sum, section) => sum + section.items.length, 0);
850
+ const kinds = sections.reduce((sum, section) => sum + section.groups.length, 0);
851
+ $("#findings-title").textContent = runLabel(run);
852
+ $("#findings-note").textContent = total
853
+ ? `${total} in ${kinds} kind${kinds === 1 ? "" : "s"}, worst first. An observation, not a release decision.`
854
+ : "An observation, not a release decision.";
855
+ body.innerHTML = `<div class="findings-tally">${findingsTally(sections)}${evidenceLink(runCaptureId(run), "Visual report")}</div>
856
+ ${sections.filter((section) => section.groups.length || section.empty).map((section) => `
857
+ <section class="findings-section">
858
+ <h2>${esc(section.title)}${section.items.length ? ` <i>${section.items.length}</i>` : ""}</h2>
859
+ ${section.note ? `<p class="muted">${esc(section.note)}</p>` : ""}
860
+ ${section.groups.length ? section.groups.map(findingGroupHtml).join("") : `<p class="muted">${esc(section.empty)}</p>`}
861
+ </section>`).join("")}`;
862
+ }
863
+
864
+ function findingsTally(sections) {
865
+ return severityTally(sections.flatMap((section) => section.items))
866
+ .map(({ severity, count }) => `<span class="sev-tally ${esc(severity)}">${count} ${esc(severity)}</span>`).join("");
867
+ }
868
+
869
+ // Where one finding is, said once. An audit reports the pages a finding appears on, so naming
870
+ // the first of them and then counting them again reads as `on / (7 pages)`.
871
+ function findingWhere(item) {
872
+ const pages = item.pages || [];
873
+ if (pages.length > 1) return `on ${pages.length} pages`;
874
+ if (pages.length === 1) return `on ${pages[0]}`;
875
+ return item.screen ? `on ${item.screen}` : "";
876
+ }
877
+
878
+ // One kind of problem: its name in the engine's words, how many places it covers, and — once
879
+ // opened — every one of those places. A group that is already serious opens itself.
880
+ function findingGroupHtml(group) {
881
+ // A group of one is already fully written on its own row; opening it would show the same
882
+ // sentence again, so it is a row rather than something to click.
883
+ const item = group.count === 1 ? group.items[0] : null;
884
+ if (item) {
885
+ const where = findingWhere(item);
886
+ return `<div class="finding-group single">
887
+ <span class="sev-dot ${esc(group.severity)}" aria-hidden="true"></span>
888
+ <span class="group-label">${esc(group.label)}</span>
889
+ ${where ? `<span class="group-count">${esc(where)}</span>` : ""}
890
+ </div>`;
891
+ }
892
+ return `<details class="finding-group"${group.severity === "critical" || group.severity === "high" ? " open" : ""}>
893
+ <summary>
894
+ <span class="sev-dot ${esc(group.severity)}" aria-hidden="true"></span>
895
+ <span class="group-label">${esc(group.label)}</span>
896
+ <span class="group-count">${group.count}${group.screens.length > 1 ? ` · ${group.screens.length} screens` : ""}</span>
897
+ </summary>
898
+ <ul class="detail-list">${group.items.map((item) => `<li>
899
+ <b class="sev-${esc(String(item.severity || "info").toLowerCase())}">${esc(item.severity || "info")}</b> · ${esc(item.title || item.type || "Finding")}
900
+ <small>${esc(findingWhere(item))}</small>
901
+ </li>`).join("")}</ul>
902
+ </details>`;
903
+ }
904
+
905
+ function renderCoverage() {
906
+ const run = selectedRun();
907
+ renderRunPicker("#coverage-run");
908
+ const body = $("#coverage-body");
909
+ const counts = $("#coverage-counts");
910
+ if (!run) { counts.innerHTML = ""; body.innerHTML = '<div class="empty">No run yet.</div>'; return; }
911
+ const id = runCaptureId(run);
912
+ if (!id) { counts.innerHTML = ""; body.innerHTML = '<div class="empty">This run kept no capture, so there is no map to draw.</div>'; return; }
913
+ const cached = state.coverage?.[id];
914
+ if (!cached) { counts.innerHTML = ""; body.innerHTML = '<div class="empty">Reading the map this run wrote…</div>'; loadCoverage(id); return; }
915
+ if (cached.error) { counts.innerHTML = ""; body.innerHTML = `<div class="empty">${esc(cached.error)}</div>`; return; }
916
+ const graph = cached.graph;
917
+ if (!graph.screens.length) { counts.innerHTML = ""; body.innerHTML = '<div class="empty">This run recorded no screens. Older runs, and runs that never got past the first screen, have no map.</div>'; return; }
918
+
919
+ const actions = run.kind === "explore" ? run.explore?.report?.actionsPerformed : run.report?.actionsPerformed;
920
+ // A card takes the shape of the thing it is a picture of, the same rule the stage follows: a
921
+ // web page is landscape, a phone is portrait. Forced into the wrong one, `cover` crops a web
922
+ // still so hard that the screen's own name is cut off the left edge of its card.
923
+ const platform = runPlatform(run);
924
+ counts.innerHTML = `<span><b>${graph.counts.screens}</b> screens</span><span><b>${graph.counts.transitions}</b> transitions</span>${
925
+ actions ? `<span><b>${actions}</b> actions</span>` : ""}${evidenceLink(id, "Visual report")}`;
926
+
927
+ const byId = new Map(graph.screens.map((screen) => [screen.id, screen]));
928
+ // A run with no transitions has no path to draw. That is the normal and correct outcome of a
929
+ // read-only audit, which opens pages and clicks nothing — so say that, rather than labelling
930
+ // every page "no recorded way in" and reading as a fault in the run.
931
+ if (!graph.counts.transitions) {
932
+ body.innerHTML = `<p class="muted coverage-note">${run.kind === "audit"
933
+ ? "Nothing was clicked in this read-only pass, so no path between pages was recorded. These are the pages it opened."
934
+ : "This run recorded no way from one screen to another, so there is no path to draw. These are the screens it reached."}</p>
935
+ <div class="coverage-map flat" data-platform="${esc(platform)}">${graph.screens.map((screen) => screenCardHtml(screen, id)).join("")}</div>`;
936
+ return;
937
+ }
938
+ body.innerHTML = `<div class="coverage-map" data-platform="${esc(platform)}">${graph.columns.map((column, index) => {
939
+ const screens = column.map((screenId) => byId.get(screenId)).filter(Boolean);
940
+ if (!screens.length) return "";
941
+ const unreached = screens.every((screen) => !screen.reached);
942
+ return `<div class="coverage-column">
943
+ <p class="coverage-column-head">${unreached ? "No recorded way in" : index === 0 ? "Started here" : `${index} step${index === 1 ? "" : "s"} in`}</p>
944
+ ${screens.map((screen) => screenCardHtml(screen, id, { deadEnds: true })).join("")}
945
+ </div>`;
946
+ }).join("")}</div>
947
+ <p class="muted coverage-note">Only transitions the engine recorded are drawn. A screen with no recorded way in is in its own column, never implied to follow from the one beside it.</p>`;
948
+ }
949
+
950
+ // One screen: the still the run wrote, what the engine called it, and what led on from it. A
951
+ // screen with no still says so rather than borrowing another screen's picture. `deadEnds` is on
952
+ // only where it means something: in a path, a screen nothing led on from is a dead end worth
953
+ // naming; where the run recorded no transitions at all, every screen is one and saying so is noise.
954
+ function screenCardHtml(screen, captureId, { deadEnds = false } = {}) {
955
+ return `<article class="screen-card${screen.reached ? "" : " orphan"}">
956
+ <div class="screen-shot">${screen.shot
957
+ ? `<img loading="lazy" src="${esc(captureUrl(captureId, screen.shot))}" alt="${esc(screen.name)}">`
958
+ : '<span class="screen-shot-none">no picture</span>'}
959
+ ${screen.shotIsOfBaseScreen ? '<span class="screen-note" title="The stills are named for the screen, not the state, so this is that screen in a different state.">picture is of another state</span>' : ""}
960
+ </div>
961
+ <strong>${esc(screen.name)}</strong>
962
+ <small>${screen.controls} control${screen.controls === 1 ? "" : "s"}</small>
963
+ ${screen.outgoing.length
964
+ ? `<ul class="screen-exits">${screen.outgoing.map((exit) => `<li>${esc(exit.label)} <span>→ ${esc(exit.toName)}</span></li>`).join("")}</ul>`
965
+ : deadEnds ? '<p class="screen-exits-none">nothing led on from here</p>' : ""}
966
+ </article>`;
967
+ }
968
+
969
+ // The map is written beside the run, not sent with the run list, so it is fetched once per
970
+ // capture and kept. A capture from before the map was written answers 404; say so plainly.
971
+ async function loadCoverage(id) {
972
+ state.coverage ||= {};
973
+ if (state.coverage[id]) return;
974
+ state.coverage[id] = { loading: true };
975
+ try {
976
+ const [map, files] = await Promise.all([
977
+ fetch(captureUrl(id, "ui-map.json")).then((response) => response.ok ? response.json() : Promise.reject(new Error("no map"))),
978
+ api(`/api/captures/${encodeURIComponent(id)}/files`).catch(() => ({ shots: [] })),
979
+ ]);
980
+ const platform = map?.app?.platforms?.[0] || "";
981
+ state.coverage[id] = { graph: coverageGraph(map, files.shots || [], { platform }) };
982
+ } catch {
983
+ state.coverage[id] = { error: "This run wrote no map. Runs from before tapp recorded one, and runs that ended on the first screen, have nothing to draw." };
984
+ }
985
+ if (state.activeView === "coverage") renderCoverage();
986
+ }
987
+
773
988
  // ---- tapp chat: the engine's progress log, rendered as a transcript -------------------------
774
989
  function renderChat() {
775
990
  const node = $("#chat-transcript");
@@ -1179,6 +1394,11 @@ document.addEventListener("click", (event) => {
1179
1394
  }
1180
1395
  });
1181
1396
 
1397
+ document.addEventListener("change", (event) => {
1398
+ const picker = event.target.closest("#findings-run, #coverage-run");
1399
+ if (picker) { state.selectedRunId = picker.value; renderRuns(); }
1400
+ });
1401
+
1182
1402
  document.addEventListener("submit", (event) => {
1183
1403
  const audit = event.target.closest("form.audit-form");
1184
1404
  if (audit) { event.preventDefault(); auditWebsite(audit.elements.url.value).catch((error) => toast(error.message, true)); return; }
@@ -13,6 +13,8 @@
13
13
  <body>
14
14
  <svg hidden aria-hidden="true" xmlns="http://www.w3.org/2000/svg">
15
15
  <symbol id="i-grid" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="5" height="5" rx="1"/><rect x="9" y="2" width="5" height="5" rx="1"/><rect x="2" y="9" width="5" height="5" rx="1"/><rect x="9" y="9" width="5" height="5" rx="1"/></symbol>
16
+ <symbol id="i-alert" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M8 2.2 14.3 13H1.7z" stroke-linejoin="round"/><path d="M8 6.3v3"/><circle cx="8" cy="11.3" r=".55" fill="currentColor" stroke="none"/></symbol>
17
+ <symbol id="i-map" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1.6" y="4" width="4.3" height="4.3" rx="1"/><rect x="10.1" y="2.3" width="4.3" height="4.3" rx="1"/><rect x="10.1" y="9.4" width="4.3" height="4.3" rx="1"/><path d="M5.9 6.15h1.9a1 1 0 0 1 1 1v4.4a1 1 0 0 0 1 1h.3M8.8 6.15h1.3"/></symbol>
16
18
  <symbol id="i-play" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="8" cy="8" r="6.25"/><path d="M6.5 5.5v5l4-2.5z" fill="currentColor" stroke="none"/></symbol>
17
19
  <symbol id="i-folder" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 4.5A1.5 1.5 0 0 1 3.5 3h3l1.5 1.5h4.5A1.5 1.5 0 0 1 14 6v5.5A1.5 1.5 0 0 1 12.5 13h-9A1.5 1.5 0 0 1 2 11.5z"/></symbol>
18
20
  <symbol id="i-branch" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="4" cy="3.5" r="1.5"/><circle cx="4" cy="12.5" r="1.5"/><circle cx="12" cy="5" r="1.5"/><path d="M4 5v6M12 6.5c0 3-8 2-8 4.5"/></symbol>
@@ -90,6 +92,8 @@
90
92
  <nav class="primary-nav" aria-label="Product navigation">
91
93
  <button data-view="overview" class="active"><span><svg><use href="#i-grid"/></svg></span>Overview</button>
92
94
  <button data-view="runs"><span><svg><use href="#i-play"/></svg></span>Runs <i id="run-count" class="zero">0</i></button>
95
+ <button data-view="findings"><span><svg><use href="#i-alert"/></svg></span>Findings <i id="findings-count" class="zero">0</i></button>
96
+ <button data-view="coverage"><span><svg><use href="#i-map"/></svg></span>Coverage</button>
93
97
  <button data-view="platforms"><span><svg><use href="#i-grid"/></svg></span>Platforms</button>
94
98
  <button data-view="admin" id="admin-nav" class="hidden"><span><svg><use href="#i-grid"/></svg></span>Admin</button>
95
99
  </nav>
@@ -168,6 +172,21 @@
168
172
  </section>
169
173
  </section>
170
174
 
175
+ <section class="workspace-view" data-view-panel="findings">
176
+ <div class="view-heading simple">
177
+ <div><p class="eyebrow">Findings</p><h1 id="findings-title">What the last run noticed</h1><p id="findings-note">Grouped by kind, worst first. Every finding is inside a group — nothing is dropped, and nothing here is a verdict.</p></div>
178
+ <select id="findings-run" class="run-picker" aria-label="Which run"></select>
179
+ </div>
180
+ <div id="findings-body"><div class="empty">No run yet.</div></div>
181
+ </section>
182
+ <section class="workspace-view" data-view-panel="coverage">
183
+ <div class="view-heading simple">
184
+ <div><p class="eyebrow">Coverage</p><h1>Where the run went</h1><p>Each screen tapp reached, and the action that led to the next one. Drawn from the map the engine wrote during the run.</p></div>
185
+ <select id="coverage-run" class="run-picker" aria-label="Which run"></select>
186
+ </div>
187
+ <div class="coverage-counts" id="coverage-counts"></div>
188
+ <div id="coverage-body"><div class="empty">No run yet.</div></div>
189
+ </section>
171
190
  <section class="workspace-view" data-view-panel="platforms">
172
191
  <div class="view-heading simple"><div><p class="eyebrow">Platforms</p><h1>What tapp can drive</h1><p>tapp is one engine with a driver per platform. This page says what this Studio can start right now, and where the rest runs.</p></div></div>
173
192
  <div id="platform-list"><div class="empty">Checking this machine…</div></div>
@@ -16,6 +16,15 @@ export const customerProductContract = Object.freeze({
16
16
  views: [
17
17
  { id: "overview", label: "Overview", capabilities: ["target-selection", "release-check", "live-feed", "progress-transcript", "live-session", "flow-recording", "latest-evidence"] },
18
18
  { id: "runs", label: "Runs", capabilities: ["run-history", "run-detail", "evidence-page", "website-audit"] },
19
+ // Findings and Coverage are how a run is READ. The engine keeps every finding distinct, by
20
+ // type|screen|target, so a regression stays visible; that same identity makes one site-wide
21
+ // problem arrive as thirty-four lines. Findings groups them for reading and drops none of
22
+ // them. Coverage draws the screens the run reached, and the action between each pair, from
23
+ // the map the engine already wrote beside the run. Neither measures anything, and neither
24
+ // judges: they show what a run recorded (TM-794, restoring what ADR-0006 moved out on
25
+ // 2026-10-15 — the report page kept the findings but never had the map).
26
+ { id: "findings", label: "Findings", capabilities: ["finding-groups", "finding-detail", "run-selection"] },
27
+ { id: "coverage", label: "Coverage", capabilities: ["screen-map", "transition-labels", "run-selection"] },
19
28
  // Only an owner of this deployment ever sees this one (TAPP_ADMIN_EMAILS); to anybody else
20
29
  // the nav item is absent and the route is a 404.
21
30
  // Says what tapp drives, what THIS Studio can start, and what to do about the difference.
@@ -30,6 +39,8 @@ export const customerProductContract = Object.freeze({
30
39
  "Repositories are opened from the machine the Studio runs on; nothing is uploaded or cloned by the Studio.",
31
40
  "Deterministic replay and ordinary merge decisions are keyless.",
32
41
  "The admin view reports counts about this deployment; credentials are encrypted and are never decrypted to be shown.",
42
+ "Findings groups for reading only: every finding the engine reported is inside exactly one group, and grouping never changes what was found or how a finding is identified.",
43
+ "Coverage draws only transitions the engine recorded. A screen it reached with no recorded way in is shown as such, never implied to follow from the screen drawn beside it.",
33
44
  "The Platforms view states what this machine can start, computed from the machine; a platform with no driver says so in those words and is never described as needing different hardware.",
34
45
  ],
35
46
  });
@@ -108,3 +108,188 @@ export function summarize(name, result = {}, { access = "" } = {}) {
108
108
  if (report?.headline) return { tone: "neutral", pill: `${report.screensExplored || 0} screens · ${report.actionsPerformed || 0} actions · ${(report.findings || []).length} findings`, text: /not a release decision/i.test(report.headline) ? report.headline : `${report.headline} An observation, not a release decision.` };
109
109
  return { tone: "neutral", pill: "Done", text: `${name} completed.` };
110
110
  }
111
+
112
+ // ---------------------------------------------------------------------------
113
+ // Findings, grouped so a run can be read (TM-794)
114
+ // ---------------------------------------------------------------------------
115
+ // The engine keeps every finding distinct — its signature is type|screen|target, so two dead
116
+ // buttons on one screen stay two findings and fixing one while breaking the other still reads as
117
+ // a change. That identity is right for regressions and wrong for reading: one site-wide contrast
118
+ // problem arrives as thirty-four lines and buries the two things worth fixing. Grouping is
119
+ // therefore a view concern only. Nothing here drops a finding; every one of them is inside a group.
120
+
121
+ const SEVERITY_ORDER = ["critical", "high", "medium", "low", "info"];
122
+ const severityRank = (value) => {
123
+ const index = SEVERITY_ORDER.indexOf(String(value || "info").toLowerCase());
124
+ return index === -1 ? SEVERITY_ORDER.length : index;
125
+ };
126
+
127
+ function prettyType(value) {
128
+ const text = String(value || "finding").replace(/[_-]+/g, " ").trim();
129
+ return text ? text[0].toUpperCase() + text.slice(1) : "Finding";
130
+ }
131
+
132
+ // The group's name is the engine's own words where the group agrees on them: the longest prefix
133
+ // every title shares, cut back to a word boundary. Thirty-four titles starting `Hard to read: "…`
134
+ // name themselves "Hard to read". When they share too little to be a name, fall back to the type.
135
+ function groupLabel(items, type) {
136
+ const titles = items.map((item) => String(item?.title || "")).filter(Boolean);
137
+ if (!titles.length) return prettyType(type);
138
+ if (titles.length === 1) return titles[0];
139
+ let prefix = titles[0];
140
+ for (const title of titles.slice(1)) {
141
+ let index = 0;
142
+ while (index < prefix.length && index < title.length && prefix[index] === title[index]) index += 1;
143
+ prefix = prefix.slice(0, index);
144
+ if (!prefix) break;
145
+ }
146
+ // The shared prefix usually stops inside a word — `Hard to read: "S` for "Services" and
147
+ // "Scope…". Drop that partial word, unless the prefix is a whole title (identical titles on
148
+ // different screens), where the last word really is the engine's and keeping it is right.
149
+ const cut = titles.includes(prefix) ? prefix : prefix.replace(/\S+$/u, "");
150
+ const trimmed = cut.replace(/[\s"'‘’“”:;,.\-—(\[]+$/u, "").trim();
151
+ return trimmed.length >= 8 ? trimmed : prettyType(type);
152
+ }
153
+
154
+ export function groupFindings(findings = []) {
155
+ const groups = new Map();
156
+ for (const finding of findings) {
157
+ if (!finding) continue;
158
+ const type = String(finding.type || finding.category || "finding");
159
+ if (!groups.has(type)) groups.set(type, []);
160
+ groups.get(type).push(finding);
161
+ }
162
+ return [...groups.entries()]
163
+ .map(([type, items]) => {
164
+ const severity = [...items].sort((a, b) => severityRank(a.severity) - severityRank(b.severity))[0]?.severity || "info";
165
+ const screens = [...new Set(items.map((item) => item.screen).filter(Boolean))];
166
+ return {
167
+ type,
168
+ label: groupLabel(items, type),
169
+ severity: String(severity).toLowerCase(),
170
+ count: items.length,
171
+ screens,
172
+ // Worst first inside the group too, so opening it does not start on a trailing low.
173
+ items: [...items].sort((a, b) => severityRank(a.severity) - severityRank(b.severity)),
174
+ };
175
+ })
176
+ .sort((a, b) => severityRank(a.severity) - severityRank(b.severity) || b.count - a.count || a.label.localeCompare(b.label));
177
+ }
178
+
179
+ // The row of counts above the list, worst kind first. It is counted from the findings
180
+ // themselves, so it can never claim a severity the list below it does not show.
181
+ export function severityTally(items = []) {
182
+ const counts = new Map();
183
+ for (const item of items) {
184
+ if (!item) continue;
185
+ const severity = String(item.severity || "info").toLowerCase();
186
+ counts.set(severity, (counts.get(severity) || 0) + 1);
187
+ }
188
+ return [...counts.entries()]
189
+ .sort(([a], [b]) => severityRank(a) - severityRank(b))
190
+ .map(([severity, count]) => ({ severity, count }));
191
+ }
192
+
193
+ // ---------------------------------------------------------------------------
194
+ // Coverage: the shape of what a run walked through (TM-794)
195
+ // ---------------------------------------------------------------------------
196
+ // Every capture already holds the map the engine built from its own markers: screens it reached,
197
+ // and the action that led from one to the next. Nothing here measures anything — it arranges what
198
+ // the engine recorded into columns by distance from the screen the run started on, and joins each
199
+ // screen to the stills written beside it. A screen the engine saw but never recorded a way into
200
+ // is listed as such rather than quietly placed next to the others.
201
+
202
+ const screenKey = (value) => String(value || "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
203
+
204
+ // `tap "Pricing"`, `open /solutions`, `back` — the engine's own action, not a sentence about it.
205
+ export function transitionLabel(action = {}) {
206
+ const type = String(action?.type || "").trim() || "goes to";
207
+ const target = String(action?.target || "").trim();
208
+ return target ? `${type} “${target}”` : type;
209
+ }
210
+
211
+ export function coverageGraph(uiMap, shots = [], { platform = "" } = {}) {
212
+ const nodes = Array.isArray(uiMap?.nodes) ? uiMap.nodes : [];
213
+ const edges = Array.isArray(uiMap?.edges) ? uiMap.edges : [];
214
+ if (!nodes.length) return { screens: [], columns: [], counts: { screens: 0, transitions: 0 }, entryId: "", unreachable: [] };
215
+
216
+ // The stills are named for the screen they are of (`state_3_pricing.png`), which is the node's
217
+ // own key with its separators spelled differently. Match on that and nothing cleverer: a screen
218
+ // with no still shows as a named card, never as a guess at someone else's picture.
219
+ const byKey = new Map();
220
+ for (const shot of shots) {
221
+ const key = screenKey(shot?.caption);
222
+ if (!key) continue;
223
+ if (!byKey.has(key)) byKey.set(key, []);
224
+ byKey.get(key).push(shot.src);
225
+ }
226
+
227
+ const entryId = uiMap?.app?.entryNodes?.[platform] || Object.values(uiMap?.app?.entryNodes || {})[0] || nodes[0].id;
228
+ const outgoing = new Map(nodes.map((node) => [node.id, []]));
229
+ for (const edge of edges) {
230
+ if (!outgoing.has(edge?.from)) continue;
231
+ outgoing.get(edge.from).push(edge);
232
+ }
233
+
234
+ const depth = new Map([[entryId, 0]]);
235
+ let frontier = [entryId];
236
+ while (frontier.length) {
237
+ const next = [];
238
+ for (const id of frontier) {
239
+ for (const edge of outgoing.get(id) || []) {
240
+ if (!edge?.to || depth.has(edge.to) || !outgoing.has(edge.to)) continue;
241
+ depth.set(edge.to, depth.get(id) + 1);
242
+ next.push(edge.to);
243
+ }
244
+ }
245
+ frontier = next;
246
+ }
247
+
248
+ const reachedDepth = Math.max(0, ...[...depth.values()]);
249
+ const unreachable = nodes.filter((node) => !depth.has(node.id)).map((node) => node.id);
250
+ const nameById = new Map(nodes.map((node) => [node.id, node.name || node.semanticKey || node.id]));
251
+
252
+ const screens = nodes.map((node) => {
253
+ const key = screenKey(node.semanticKey || node.name);
254
+ // The engine marks a screen it met in a second structural state (`variant`, with the screen it
255
+ // is a state of in `baseSemanticKey`). The stills are captioned by title, so they cannot tell
256
+ // those apart. Fall back to the base screen's still for a variant and say that is what it is,
257
+ // rather than either showing nothing or implying the picture is of this exact state.
258
+ const base = node.variant ? screenKey(node.baseSemanticKey) : "";
259
+ const matched = byKey.get(key) || (base ? byKey.get(base) || [] : []);
260
+ const borrowed = !(byKey.get(key) || []).length && matched.length > 0;
261
+ return {
262
+ id: node.id,
263
+ name: node.stateLabel || node.name || node.semanticKey || "Screen",
264
+ key: node.semanticKey || key,
265
+ variantOf: node.variant ? (node.name || node.baseSemanticKey || "") : "",
266
+ // A screen the run never found a recorded way into sits in a column of its own, after the
267
+ // ones it did — never implied to follow from the last screen simply by being drawn there.
268
+ column: depth.has(node.id) ? depth.get(node.id) : reachedDepth + 1,
269
+ reached: depth.has(node.id),
270
+ shot: matched[0] || null,
271
+ shotCount: matched.length,
272
+ // True when the picture is of this screen in a different state than the one recorded here.
273
+ shotIsOfBaseScreen: borrowed,
274
+ controls: (node.controls || []).length,
275
+ outgoing: (outgoing.get(node.id) || []).map((edge) => ({
276
+ label: transitionLabel(edge.action),
277
+ to: edge.to,
278
+ toName: nameById.get(edge.to) || "",
279
+ })),
280
+ };
281
+ });
282
+
283
+ const columns = [];
284
+ for (const screen of screens) {
285
+ (columns[screen.column] ||= []).push(screen.id);
286
+ }
287
+
288
+ return {
289
+ screens,
290
+ columns: columns.map((column) => column || []),
291
+ counts: { screens: nodes.length, transitions: edges.length },
292
+ entryId,
293
+ unreachable,
294
+ };
295
+ }
@@ -1,6 +1,7 @@
1
1
  # Browser Studio
2
2
 
3
- Status: current product contract as of 2026-10-19 (ADR-0006, owner decision, amended). Supersedes
3
+ Status: current product contract as of 2026-11-15 (ADR-0006, owner decision, amended twice:
4
+ 2026-10-19, and TM-794 on 2026-11-15 bringing Findings and Coverage back). Supersedes
4
5
  the "desktop-parity Command Center" framing of 2026-10-14.
5
6
 
6
7
  The Studio in `browser/` is the one browser surface. It is a **run viewer**: point Tapp at a
@@ -44,6 +45,8 @@ refuses what the mode cannot do: a hosted Studio cannot open a path or a build o
44
45
  |---|---|---|
45
46
  | Overview | The **stage**: the device as large as the window allows, in its platform's aspect ratio (phone portrait for iOS and Android, browser landscape for web), showing the live frame or the newest screenshot the run wrote. The **chat** floats over its corner on a translucent ground, collapses to a pill, and narrates the engine's own progress log one emoji-led line at a time (👆 Tapped, ⌨️ Typed, 🔐 Signed in, 📍 Opened, 🧭 Reached, 📸 screenshots inline), then attaches the recording and `report.html` and ends with a pill — `✓ Ready to merge`, `× Do not merge`, `◐ Inconclusive`, or for an exploration its counts — and the headline. Nothing is generated after the fact and nothing is a score. Below the stage: the detected targets (an explicit choice when there are several), the live-session controls, and the current decision from the last gate. | `open`, `initialize` (inspect, then build + explore), `explore-build`, live session `start / act / save-flow / end`, release check |
46
47
  | Runs | Every run on this repository, every exploration started from the prompt, and every read-only website audit, newest first; each opens its evidence page. A URL field runs an audit from here. | `gate`, `audit` |
48
+ | Findings | What the selected run reported, **grouped by kind** and worst first: one row per kind with the count of places it covers (`Hard to read · 34 · 4 screens`), opening onto every individual place. The engine's identity for a finding is `type|screen|target`, so one site-wide problem arrives as dozens of lines and buries the two worth fixing; grouping is a reading aid in the view and drops nothing — every finding is inside exactly one group. A read-only audit's two kinds stay apart, as the engine draws them: **Broken** (structural defects) and **Worth a look** (not broken; what a person would notice). Never a verdict. | — |
49
+ | Coverage | The screens the selected run reached, in columns by distance from the screen it started on, each a card with the still the run wrote and the actions that led on from it (`tap "Pricing" → Pricing`). Built from the `ui-map.json` the engine writes into every capture: `nodes` are screens, `edges` the recorded transitions. Only recorded transitions are drawn — a screen reached with no recorded way in gets its own column and says so, and a run with no transitions at all (a read-only audit clicks nothing) is a plain grid of what it opened, with the reason stated. | — |
47
50
 
48
51
  A **website audit** is `explore --read-only`: up to twenty same-origin pages (twelve by default) are rendered and read —
49
52
  dead controls, broken images/assets/links, failed requests, JS exceptions, mixed content,
@@ -54,12 +57,20 @@ real small-business sites in October 2026; the remaining findings were verified
54
57
 
55
58
  ## What was removed, and where it lives instead
56
59
 
57
- The Contracts, Coverage and Settings views, the six-step journey stepper, and the folder-upload,
60
+ The Contracts and Settings views, the six-step journey stepper, and the folder-upload,
58
61
  GitHub-clone and remote-runner onboarding were removed on 2026-10-15. Reviewing and promoting
59
- contracts is `tapp plan` / `tapp validate` in the repository; coverage is on every run's
60
- `report.html`; actors and credentials live in `.tapp/project.json`; CI installation is `tapp ci`.
61
- The Studio keeps only what a browser does better than a terminal: watching a real device while a
62
- run happens, driving it by hand, and reading evidence.
62
+ contracts is `tapp plan` / `tapp validate` in the repository; actors and credentials live in
63
+ `.tapp/project.json`; CI installation is `tapp ci`. The Studio keeps only what a browser does
64
+ better than a terminal: watching a real device while a run happens, driving it by hand, and
65
+ reading evidence.
66
+
67
+ **Findings and Coverage came back on 2026-11-15** (TM-794, owner decision). They were removed in
68
+ the same pass on the argument that `report.html` already carried them. It carries the findings —
69
+ as the same flat list, which is the problem — and it never carried the map at all: the engine has
70
+ written `ui-map.json` into every capture throughout, and nothing drew it. Reading a run is a thing
71
+ a browser does better than a terminal, so it belongs to the same rule as the rest of the Studio.
72
+ Neither view computes anything: Findings groups what the engine reported, Coverage arranges the
73
+ map it wrote. Neither judges — only the gate does.
63
74
 
64
75
  ## Verified reference journey
65
76
 
@@ -68,7 +79,9 @@ target choice, exploration, a live session that records a Flow, the gate, and th
68
79
  `tests/browser-onboarding.test.js` covers the no-repository start and a read-only website audit;
69
80
  `tests/browser-product.test.js` covers authentication, CSRF, the audit operation and the removed
70
81
  endpoints answering 404. `tests/browser-chat-narration.test.js` covers prompt classification and
71
- the chat's narration and summary without a browser.
82
+ the chat's narration and summary without a browser, and
83
+ `tests/browser-run-reading.test.js` covers finding groups and the coverage graph the same way —
84
+ the browser journey then drives both views against a real run.
72
85
 
73
86
  ## Hosted relationship
74
87
 
@@ -365,6 +365,17 @@ export class AndroidDriver {
365
365
 
366
366
  async back() { await this.adb(["shell", "input", "keyevent", "KEYCODE_BACK"]); return { status: "ok" }; }
367
367
 
368
+ /**
369
+ * Is the soft keyboard on screen? Back means "close the keyboard" while it is, and "leave this
370
+ * screen" once it is not — so anything that presses Back to uncover a control has to ask first
371
+ * (TM-554).
372
+ */
373
+ async imeShowing() {
374
+ const r = await this.adb(["shell", "dumpsys", "input_method"]);
375
+ if (r.code !== 0) return false;
376
+ return /\bmInputShown=true\b/.test(String(r.stdout || ""));
377
+ }
378
+
368
379
  async swipe(direction = "up") {
369
380
  const points = {
370
381
  up: [540, 1500, 540, 500], down: [540, 500, 540, 1500],