@aarwitz/tapp 0.35.6 → 0.35.8

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,
@@ -149,6 +153,16 @@ function activateView(view) {
149
153
  // On a public Studio a person is a visitor until they sign in, and an account after. Both slots
150
154
  // (prompt screen and sidebar) show the same thing. A local Studio has neither: the one person at
151
155
  // the keyboard is the operator.
156
+ // What the cloud will do for this account, in a word: the trial's days left, that it ended, or
157
+ // that there is nothing to count (ADR-0011 §3). Never shown to the deployment's owner.
158
+ function planPill(plan) {
159
+ if (!plan || plan.kind === "owner") return "";
160
+ if (plan.kind === "paid") return `<span class="journey-status passing" title="On a plan">plan</span>`;
161
+ if (plan.kind === "lapsed") return `<span class="journey-status failing" title="Cloud runs are for accounts on a plan — write to hello@runtapp.com">trial ended</span>`;
162
+ const days = plan.daysLeft ?? 0;
163
+ return `<span class="journey-status ${days <= 3 ? "failing" : "never"}" title="Free trial until ${esc(String(plan.endsAt || "").slice(0, 10))}">trial · ${esc(String(days))} day${days === 1 ? "" : "s"} left</span>`;
164
+ }
165
+
152
166
  function renderAccount() {
153
167
  const session = state.session || {};
154
168
  const isPublic = session.access === "anonymous" || session.access === "account";
@@ -156,7 +170,7 @@ function renderAccount() {
156
170
  slot.classList.toggle("hidden", !isPublic);
157
171
  if (!isPublic) continue;
158
172
  slot.innerHTML = session.access === "account"
159
- ? `<span class="account-email" title="${esc(session.email || "")}">${esc(session.email || "")}</span><button type="button" data-signout>Sign out</button>`
173
+ ? `<span class="account-email" title="${esc(session.email || "")}">${esc(session.email || "")}</span>${planPill(session.plan)}<button type="button" data-signout>Sign out</button>`
160
174
  : `<button type="button" class="primary" data-signin>Sign in</button>`;
161
175
  }
162
176
  $("#signin-card")?.classList.toggle("hidden", session.access !== "anonymous" || !state.signInOpen);
@@ -206,21 +220,24 @@ function applyAccessMode() {
206
220
  // one where most of it says "ready".
207
221
  renderPlatformStrip();
208
222
  renderPlatforms();
223
+ renderStudioLink();
209
224
  if (session.access !== "anonymous" && session.access !== "account") return;
210
225
  const signedIn = session.access === "account";
211
226
  const accepts = new Set(session.accepts || ["url"]);
212
- // A target this Studio cannot START is still a thing tapp does. It used to be deleted from
213
- // the screen, which is how a cross-platform product came to look like a website checker: the
214
- // hosted Studio erased every mention of iOS, Android and folders. Keep them, mark them, and
215
- // let the answer be "here is where that runs" (ADR-0010).
227
+ // A target this Studio cannot START is still a thing tapp does — on the person's own machine.
228
+ // It used to be deleted from the screen, which is how a cross-platform product came to look
229
+ // like a website checker; then dimmed but offered (ADR-0010), so a stranger learned what the
230
+ // page could not do by trying it. Now the self-host card names it, with the command, before
231
+ // anyone types it (ADR-0011): an example nobody can start here is not offered as something to
232
+ // type here. Typing one anyway still gets the "here is where that runs" answer.
216
233
  for (const button of document.querySelectorAll("[data-kind]")) {
217
234
  const kind = button.dataset.kind;
218
235
  const usable = kind === "url" ? accepts.has("url") : accepts.has(kind);
219
- button.closest("li")?.classList.remove("hidden");
220
- button.classList.toggle("elsewhere", !usable);
236
+ button.closest("li")?.classList.toggle("hidden", !usable);
221
237
  }
238
+ $("#selfhost-card")?.classList.remove("hidden");
222
239
  const input = $("#prompt-input");
223
- if (input) input.placeholder = accepts.has("path") ? input.placeholder : "A website URL — or an .app, .apk or repo to be told where it runs…";
240
+ if (input) input.placeholder = accepts.has("path") ? input.placeholder : "A website URL — https://…";
224
241
  // Everything that only means something against a source repository: a target to build, a
225
242
  // runner, a release gate, a decision. A hosted visitor auditing a URL has none of them, and
226
243
  // showing the empty frames makes a working run look like a broken one.
@@ -233,8 +250,8 @@ function applyAccessMode() {
233
250
  if (!state.headingOwnedByRun) setHeading("tapp", signedIn ? "Give it a website. If there is a sign-in, I will ask you for a test account and remember it." : "Give it a public website and it will audit the pages read-only.");
234
251
  const note = $("#privacy-note-detail");
235
252
  if (note) note.textContent = signedIn
236
- ? "Websites are explored in the cloud. Test accounts you give tapp are kept encrypted, used only to sign in, and never shown again. iOS, Android and folders on your own machine run the same Studio there: npx -y @aarwitz/tapp@latest app"
237
- : "Websites are audited read-only in the cloud; nothing is clicked. Sign in to go inside a site. iOS, Android and folders on your own machine run the same Studio there: npx -y @aarwitz/tapp@latest app";
253
+ ? "Public websites are explored in the cloud. Test accounts you give tapp are kept encrypted, used only to sign in, and never shown again."
254
+ : "Public websites are audited read-only in the cloud; nothing is clicked. Sign in to go inside a site from here.";
238
255
  $("#actors-panel")?.classList.toggle("hidden", !signedIn);
239
256
  $("#journeys-panel")?.classList.toggle("hidden", !signedIn);
240
257
  $("#agent-panel")?.classList.toggle("hidden", !signedIn);
@@ -342,7 +359,7 @@ function renderAdmin() {
342
359
 
343
360
  <section class="panel section">
344
361
  <div class="section-heading compact"><div><p class="eyebrow">Accounts</p><h2>People with a tapp account <i class="zero">${data.accounts.length}</i></h2><p>Test accounts are counted, never shown — tapp cannot show them.</p></div></div>
345
- ${data.accounts.length ? data.accounts.map((account) => `<div class="actor-row"><span><strong>${esc(account.email)}</strong>${owner(account.email) ? ' <small class="journey-status passing">owner</small>' : ""}<br><small>joined ${esc(compactDate(account.createdAt))}${account.lastSeenAt ? ` · last seen ${esc(compactDate(account.lastSeenAt))}` : ""}</small></span><span><small>${account.journeys} journey${account.journeys === 1 ? "" : "s"}${account.failing ? ` · <b class="journey-status failing">${account.failing} failing</b>` : ""}${account.neverRun ? ` · ${account.neverRun} never run` : ""}</small></span><span><small>${account.testAccounts} test account${account.testAccounts === 1 ? "" : "s"} · ${account.tokens} token${account.tokens === 1 ? "" : "s"}</small></span></div>`).join("") : '<div class="empty">Nobody has signed in yet.</div>'}
362
+ ${data.accounts.length ? data.accounts.map((account) => `<div class="actor-row"><span><strong>${esc(account.email)}</strong>${owner(account.email) ? ' <small class="journey-status passing">owner</small>' : ` ${planPill(account.plan)}`}<br><small>joined ${esc(compactDate(account.createdAt))}${account.lastSeenAt ? ` · last seen ${esc(compactDate(account.lastSeenAt))}` : ""}</small></span><span><small>${account.journeys} journey${account.journeys === 1 ? "" : "s"}${account.failing ? ` · <b class="journey-status failing">${account.failing} failing</b>` : ""}${account.neverRun ? ` · ${account.neverRun} never run` : ""}<br>${account.testAccounts} test account${account.testAccounts === 1 ? "" : "s"} · ${account.tokens} token${account.tokens === 1 ? "" : "s"}</small></span><span class="journey-actions">${owner(account.email) ? "" : `<button class="quiet" type="button" data-plan-account="${esc(account.id)}" data-plan-kind="trial" data-plan-days="30">+30 days</button>${account.plan?.kind === "paid" ? "" : `<button class="quiet" type="button" data-plan-account="${esc(account.id)}" data-plan-kind="paid">Mark paid</button>`}`}</span></div>`).join("") : '<div class="empty">Nobody has signed in yet.</div>'}
346
363
  </section>
347
364
 
348
365
  <section class="panel section">
@@ -616,6 +633,24 @@ function journeyStatus(status) {
616
633
  return `<span class="journey-status ${status.passed ? "passing" : "failing"}">${status.passed ? "passing" : "failing"} · ${esc(compactDate(status.at))}</span>`;
617
634
  }
618
635
 
636
+ // The link from this machine to an account on a hosted Studio (ADR-0011 §4). Local only.
637
+ function renderStudioLink() {
638
+ const panel = $("#link-panel");
639
+ const body = $("#link-body");
640
+ if (!panel || !body) return;
641
+ const local = state.session?.mode === "local";
642
+ panel.classList.toggle("hidden", !local);
643
+ if (!local) return;
644
+ const link = state.session?.studioLink;
645
+ body.innerHTML = link
646
+ ? `<div class="link-state"><span class="journey-status passing">connected</span><span>${esc(link.email || "")} · <small>${esc(link.origin)}</small></span><button class="quiet" type="button" data-unlink-studio>Disconnect</button></div>`
647
+ : `<form class="link-form" id="link-form" autocomplete="off">
648
+ <input id="link-origin" name="origin" type="url" value="https://app.runtapp.com" aria-label="Studio URL" spellcheck="false">
649
+ <input id="link-token" name="token" type="password" placeholder="tapp_… — a token from your Studio, under “Your coding agent”" aria-label="Token" autocomplete="off" required>
650
+ <div class="ask-actions"><button class="primary" type="submit" id="link-connect">Connect</button><small>The token is kept on this machine only, readable by you.</small></div>
651
+ </form>`;
652
+ }
653
+
619
654
  function renderJourneys() {
620
655
  const node = $("#journeys-list");
621
656
  if (!node) return;
@@ -630,7 +665,9 @@ function renderJourneys() {
630
665
  if (!journeys.length) { node.innerHTML = '<div class="empty">No journeys yet. Explore a site — when a run gets somewhere, tapp offers to keep it.</div>'; return; }
631
666
  const groups = new Map();
632
667
  for (const journey of journeys) { const key = journey.group || ""; if (!groups.has(key)) groups.set(key, []); groups.get(key).push(journey); }
633
- const row = (j) => `<div class="journey-row"><span class="journey-platform ${esc(j.platform || "web")}">${esc(j.platform || "web")}</span><span class="journey-name">${esc(j.name)}<br><small>${j.steps || 0} steps · ${journeyStatus(j.status)}</small></span><span></span><span class="journey-actions"><button class="quiet" data-run-journey="${esc(j.slug)}" title="Replay this journey">▶ Run</button>${j.source === "kept" ? `<button class="quiet" data-forget-journey="${esc(j.slug)}" title="Forget this journey">Forget</button>` : ""}</span></div>`;
668
+ // A reported journey ran on the owner's own machine: it is listed with where, and cannot be
669
+ // run from here — the cloud has no flow for it, only the result (ADR-0011 §4).
670
+ const row = (j) => `<div class="journey-row"><span class="journey-platform ${esc(j.platform || "web")}">${esc(j.platform || "web")}</span><span class="journey-name">${esc(j.name)}<br><small>${j.steps || 0} steps · ${journeyStatus(j.status)}${j.source === "reported" ? ` · runs on ${esc(j.machine || "your machine")}` : ""}</small></span><span></span><span class="journey-actions">${j.source === "reported" ? "" : `<button class="quiet" data-run-journey="${esc(j.slug)}" title="Replay this journey">▶ Run</button>`}${j.source === "kept" || j.source === "reported" ? `<button class="quiet" data-forget-journey="${esc(j.slug)}" title="Forget this journey">Forget</button>` : ""}</span></div>`;
634
671
  node.innerHTML = [...groups.entries()].sort(([a], [b]) => (a === "" ? -1 : b === "" ? 1 : a.localeCompare(b))).map(([group, items]) =>
635
672
  group === ""
636
673
  ? items.map(row).join("")
@@ -742,6 +779,9 @@ function renderRuns() {
742
779
  const chosen = runs.find((run) => run.id === state.selectedRunId) || runs[0];
743
780
  if (chosen) state.selectedRunId = chosen.id;
744
781
  renderRunDetail(chosen);
782
+ setCount("#findings-count", runFindings(chosen).length);
783
+ if (state.activeView === "findings") renderFindings();
784
+ if (state.activeView === "coverage") renderCoverage();
745
785
  }
746
786
 
747
787
  function detailLists(report) {
@@ -770,6 +810,214 @@ function renderRunDetail(run) {
770
810
  $("#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
811
  }
772
812
 
813
+ // ---- Findings and Coverage: reading a run (TM-794) ------------------------------------------
814
+ // Both views read the run the Runs view has selected, so picking a run in one picks it in all
815
+ // three. Neither computes anything about the run: Findings arranges the findings the engine
816
+ // reported, and Coverage draws the map the engine wrote beside the capture.
817
+
818
+ function selectedRun() {
819
+ const runs = allRuns();
820
+ return runs.find((run) => run.id === state.selectedRunId) || runs[0] || null;
821
+ }
822
+
823
+ // What a run reported, in the engine's own two kinds. A read-only audit keeps them apart on
824
+ // purpose: an *issue* is broken, an *observation* is something a person would notice and not
825
+ // like. Merging them would say a site is broken because its body text is faint, so the view
826
+ // keeps the separation the engine drew and groups each side on its own.
827
+ function runSections(run) {
828
+ if (!run) return [];
829
+ const page = (item) => ({ ...item, screen: item.screen || item.pages?.[0] || "" });
830
+ if (run.kind === "audit") {
831
+ return [
832
+ { 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) },
833
+ { 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) },
834
+ ];
835
+ }
836
+ const report = run.kind === "explore" ? run.explore?.report : run.report;
837
+ 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) }];
838
+ }
839
+
840
+ // Every finding a run reported, whatever kind of run it is — what the nav badge counts.
841
+ function runFindings(run) {
842
+ return runSections(run).flatMap((section) => section.items);
843
+ }
844
+
845
+ function runLabel(run) {
846
+ if (!run) return "";
847
+ if (run.kind === "audit") { try { return `Audit · ${new URL(run.audit.url).host}`; } catch { return `Audit · ${run.audit.url}`; } }
848
+ if (run.kind === "explore") return `Explore · ${run.explore.target || run.explore.platform}`;
849
+ return run.report?.headline ? String(run.report.headline).slice(0, 60) : `Release run ${run.id.slice(-8)}`;
850
+ }
851
+
852
+ // What a run drove, so its evidence can be shown in that thing's shape.
853
+ function runPlatform(run) {
854
+ if (!run) return "";
855
+ if (run.kind === "audit") return "web";
856
+ if (run.kind === "explore") return run.explore?.platform || "";
857
+ return run.report?.platform || "";
858
+ }
859
+
860
+ // The capture a run's evidence lives in. Explorations and audits are named for it; a gate run
861
+ // carries it inside its report.
862
+ function runCaptureId(run) {
863
+ if (!run) return "";
864
+ if (run.kind === "audit" || run.kind === "explore") return run.id;
865
+ return captureId(run.report);
866
+ }
867
+
868
+ function renderRunPicker(selector) {
869
+ const runs = allRuns();
870
+ const node = $(selector);
871
+ if (!node) return;
872
+ node.innerHTML = runs.map((run) => `<option value="${esc(run.id)}"${run.id === state.selectedRunId ? " selected" : ""}>${esc(runLabel(run))} · ${esc(compactDate(run.createdAt))}</option>`).join("");
873
+ node.classList.toggle("hidden", runs.length < 2);
874
+ }
875
+
876
+ function renderFindings() {
877
+ const run = selectedRun();
878
+ renderRunPicker("#findings-run");
879
+ const body = $("#findings-body");
880
+ if (!run) { body.innerHTML = '<div class="empty">No run yet. Put a URL in the prompt and tapp will go and look.</div>'; return; }
881
+ const sections = runSections(run).map((section) => ({ ...section, groups: groupFindings(section.items) }));
882
+ const total = sections.reduce((sum, section) => sum + section.items.length, 0);
883
+ const kinds = sections.reduce((sum, section) => sum + section.groups.length, 0);
884
+ $("#findings-title").textContent = runLabel(run);
885
+ $("#findings-note").textContent = total
886
+ ? `${total} in ${kinds} kind${kinds === 1 ? "" : "s"}, worst first. An observation, not a release decision.`
887
+ : "An observation, not a release decision.";
888
+ body.innerHTML = `<div class="findings-tally">${findingsTally(sections)}${evidenceLink(runCaptureId(run), "Visual report")}</div>
889
+ ${sections.filter((section) => section.groups.length || section.empty).map((section) => `
890
+ <section class="findings-section">
891
+ <h2>${esc(section.title)}${section.items.length ? ` <i>${section.items.length}</i>` : ""}</h2>
892
+ ${section.note ? `<p class="muted">${esc(section.note)}</p>` : ""}
893
+ ${section.groups.length ? section.groups.map(findingGroupHtml).join("") : `<p class="muted">${esc(section.empty)}</p>`}
894
+ </section>`).join("")}`;
895
+ }
896
+
897
+ function findingsTally(sections) {
898
+ return severityTally(sections.flatMap((section) => section.items))
899
+ .map(({ severity, count }) => `<span class="sev-tally ${esc(severity)}">${count} ${esc(severity)}</span>`).join("");
900
+ }
901
+
902
+ // Where one finding is, said once. An audit reports the pages a finding appears on, so naming
903
+ // the first of them and then counting them again reads as `on / (7 pages)`.
904
+ function findingWhere(item) {
905
+ const pages = item.pages || [];
906
+ if (pages.length > 1) return `on ${pages.length} pages`;
907
+ if (pages.length === 1) return `on ${pages[0]}`;
908
+ return item.screen ? `on ${item.screen}` : "";
909
+ }
910
+
911
+ // One kind of problem: its name in the engine's words, how many places it covers, and — once
912
+ // opened — every one of those places. A group that is already serious opens itself.
913
+ function findingGroupHtml(group) {
914
+ // A group of one is already fully written on its own row; opening it would show the same
915
+ // sentence again, so it is a row rather than something to click.
916
+ const item = group.count === 1 ? group.items[0] : null;
917
+ if (item) {
918
+ const where = findingWhere(item);
919
+ return `<div class="finding-group single">
920
+ <span class="sev-dot ${esc(group.severity)}" aria-hidden="true"></span>
921
+ <span class="group-label">${esc(group.label)}</span>
922
+ ${where ? `<span class="group-count">${esc(where)}</span>` : ""}
923
+ </div>`;
924
+ }
925
+ return `<details class="finding-group"${group.severity === "critical" || group.severity === "high" ? " open" : ""}>
926
+ <summary>
927
+ <span class="sev-dot ${esc(group.severity)}" aria-hidden="true"></span>
928
+ <span class="group-label">${esc(group.label)}</span>
929
+ <span class="group-count">${group.count}${group.screens.length > 1 ? ` · ${group.screens.length} screens` : ""}</span>
930
+ </summary>
931
+ <ul class="detail-list">${group.items.map((item) => `<li>
932
+ <b class="sev-${esc(String(item.severity || "info").toLowerCase())}">${esc(item.severity || "info")}</b> · ${esc(item.title || item.type || "Finding")}
933
+ <small>${esc(findingWhere(item))}</small>
934
+ </li>`).join("")}</ul>
935
+ </details>`;
936
+ }
937
+
938
+ function renderCoverage() {
939
+ const run = selectedRun();
940
+ renderRunPicker("#coverage-run");
941
+ const body = $("#coverage-body");
942
+ const counts = $("#coverage-counts");
943
+ if (!run) { counts.innerHTML = ""; body.innerHTML = '<div class="empty">No run yet.</div>'; return; }
944
+ const id = runCaptureId(run);
945
+ if (!id) { counts.innerHTML = ""; body.innerHTML = '<div class="empty">This run kept no capture, so there is no map to draw.</div>'; return; }
946
+ const cached = state.coverage?.[id];
947
+ if (!cached) { counts.innerHTML = ""; body.innerHTML = '<div class="empty">Reading the map this run wrote…</div>'; loadCoverage(id); return; }
948
+ if (cached.error) { counts.innerHTML = ""; body.innerHTML = `<div class="empty">${esc(cached.error)}</div>`; return; }
949
+ const graph = cached.graph;
950
+ 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; }
951
+
952
+ const actions = run.kind === "explore" ? run.explore?.report?.actionsPerformed : run.report?.actionsPerformed;
953
+ // A card takes the shape of the thing it is a picture of, the same rule the stage follows: a
954
+ // web page is landscape, a phone is portrait. Forced into the wrong one, `cover` crops a web
955
+ // still so hard that the screen's own name is cut off the left edge of its card.
956
+ const platform = runPlatform(run);
957
+ counts.innerHTML = `<span><b>${graph.counts.screens}</b> screens</span><span><b>${graph.counts.transitions}</b> transitions</span>${
958
+ actions ? `<span><b>${actions}</b> actions</span>` : ""}${evidenceLink(id, "Visual report")}`;
959
+
960
+ const byId = new Map(graph.screens.map((screen) => [screen.id, screen]));
961
+ // A run with no transitions has no path to draw. That is the normal and correct outcome of a
962
+ // read-only audit, which opens pages and clicks nothing — so say that, rather than labelling
963
+ // every page "no recorded way in" and reading as a fault in the run.
964
+ if (!graph.counts.transitions) {
965
+ body.innerHTML = `<p class="muted coverage-note">${run.kind === "audit"
966
+ ? "Nothing was clicked in this read-only pass, so no path between pages was recorded. These are the pages it opened."
967
+ : "This run recorded no way from one screen to another, so there is no path to draw. These are the screens it reached."}</p>
968
+ <div class="coverage-map flat" data-platform="${esc(platform)}">${graph.screens.map((screen) => screenCardHtml(screen, id)).join("")}</div>`;
969
+ return;
970
+ }
971
+ body.innerHTML = `<div class="coverage-map" data-platform="${esc(platform)}">${graph.columns.map((column, index) => {
972
+ const screens = column.map((screenId) => byId.get(screenId)).filter(Boolean);
973
+ if (!screens.length) return "";
974
+ const unreached = screens.every((screen) => !screen.reached);
975
+ return `<div class="coverage-column">
976
+ <p class="coverage-column-head">${unreached ? "No recorded way in" : index === 0 ? "Started here" : `${index} step${index === 1 ? "" : "s"} in`}</p>
977
+ ${screens.map((screen) => screenCardHtml(screen, id, { deadEnds: true })).join("")}
978
+ </div>`;
979
+ }).join("")}</div>
980
+ <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>`;
981
+ }
982
+
983
+ // One screen: the still the run wrote, what the engine called it, and what led on from it. A
984
+ // screen with no still says so rather than borrowing another screen's picture. `deadEnds` is on
985
+ // only where it means something: in a path, a screen nothing led on from is a dead end worth
986
+ // naming; where the run recorded no transitions at all, every screen is one and saying so is noise.
987
+ function screenCardHtml(screen, captureId, { deadEnds = false } = {}) {
988
+ return `<article class="screen-card${screen.reached ? "" : " orphan"}">
989
+ <div class="screen-shot">${screen.shot
990
+ ? `<img loading="lazy" src="${esc(captureUrl(captureId, screen.shot))}" alt="${esc(screen.name)}">`
991
+ : '<span class="screen-shot-none">no picture</span>'}
992
+ ${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>' : ""}
993
+ </div>
994
+ <strong>${esc(screen.name)}</strong>
995
+ <small>${screen.controls} control${screen.controls === 1 ? "" : "s"}</small>
996
+ ${screen.outgoing.length
997
+ ? `<ul class="screen-exits">${screen.outgoing.map((exit) => `<li>${esc(exit.label)} <span>→ ${esc(exit.toName)}</span></li>`).join("")}</ul>`
998
+ : deadEnds ? '<p class="screen-exits-none">nothing led on from here</p>' : ""}
999
+ </article>`;
1000
+ }
1001
+
1002
+ // The map is written beside the run, not sent with the run list, so it is fetched once per
1003
+ // capture and kept. A capture from before the map was written answers 404; say so plainly.
1004
+ async function loadCoverage(id) {
1005
+ state.coverage ||= {};
1006
+ if (state.coverage[id]) return;
1007
+ state.coverage[id] = { loading: true };
1008
+ try {
1009
+ const [map, files] = await Promise.all([
1010
+ fetch(captureUrl(id, "ui-map.json")).then((response) => response.ok ? response.json() : Promise.reject(new Error("no map"))),
1011
+ api(`/api/captures/${encodeURIComponent(id)}/files`).catch(() => ({ shots: [] })),
1012
+ ]);
1013
+ const platform = map?.app?.platforms?.[0] || "";
1014
+ state.coverage[id] = { graph: coverageGraph(map, files.shots || [], { platform }) };
1015
+ } catch {
1016
+ 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." };
1017
+ }
1018
+ if (state.activeView === "coverage") renderCoverage();
1019
+ }
1020
+
773
1021
  // ---- tapp chat: the engine's progress log, rendered as a transcript -------------------------
774
1022
  function renderChat() {
775
1023
  const node = $("#chat-transcript");
@@ -1080,7 +1328,7 @@ function setHeading(title, summary, { owned = false } = {}) {
1080
1328
  // simulator build, a repository that needs a toolchain. The engine answers with where they do
1081
1329
  // run; show that answer where it stays put, not in a toast that disappears in six seconds.
1082
1330
  function answerSelfHost(answer) {
1083
- setHeading("Run this on your machine", "The cloud Studio audits websites; this target needs your toolchain.", { owned: true });
1331
+ setHeading("Run this on your machine", "The cloud Studio runs public websites; this target runs on your own machine, with the same Studio.", { owned: true });
1084
1332
  document.querySelector(".summary-panel")?.classList.add("hidden");
1085
1333
  document.querySelector(".device-stage")?.classList.add("hidden");
1086
1334
  state.transcript = [];
@@ -1170,6 +1418,20 @@ document.addEventListener("click", (event) => {
1170
1418
  if (runButton) { state.selectedRunId = runButton.dataset.runId; renderRuns(); }
1171
1419
  const suggestion = event.target.closest("[data-prompt]");
1172
1420
  if (suggestion) { const input = $("#prompt-input"); input.value = suggestion.dataset.prompt; input.focus(); input.select(); }
1421
+ if (event.target.closest("[data-unlink-studio]")) {
1422
+ api("/api/studio-link", { method:"DELETE" }).then(async () => { toast("Disconnected."); await refreshSession(); }).catch((error) => toast(error.message, true));
1423
+ }
1424
+ const planButton = event.target.closest("[data-plan-account]");
1425
+ if (planButton) {
1426
+ const { planAccount, planKind, planDays } = planButton.dataset;
1427
+ api("/api/admin/plan", { method:"POST", body: JSON.stringify({ accountId: planAccount, kind: planKind, days: planDays ? Number(planDays) : undefined }) })
1428
+ .then(async () => { toast(planKind === "paid" ? "Marked paid." : `Trial set to ${planDays} days from today.`); await loadAdmin(); renderAdmin(); })
1429
+ .catch((error) => toast(error.message, true));
1430
+ }
1431
+ if (event.target.closest("#selfhost-copy")) {
1432
+ const text = $("#selfhost-command")?.textContent || "";
1433
+ navigator.clipboard?.writeText(text).then(() => toast("Copied. Run it in a terminal on your machine."), () => toast("Select the command and copy it.", true));
1434
+ }
1173
1435
  const liveControl = event.target.closest("[data-live-control]");
1174
1436
  if (liveControl) {
1175
1437
  const target = liveControl.dataset.liveTarget;
@@ -1179,6 +1441,25 @@ document.addEventListener("click", (event) => {
1179
1441
  }
1180
1442
  });
1181
1443
 
1444
+ document.addEventListener("submit", async (event) => {
1445
+ const form = event.target.closest("#link-form");
1446
+ if (!form) return;
1447
+ event.preventDefault();
1448
+ const button = $("#link-connect");
1449
+ if (button) button.disabled = true;
1450
+ try {
1451
+ await api("/api/studio-link", { method:"POST", body: JSON.stringify({ origin: $("#link-origin")?.value || "", token: $("#link-token")?.value || "" }) });
1452
+ toast("Connected. Journeys run here will report to your account.");
1453
+ await refreshSession();
1454
+ } catch (error) { toast(error.message, true); }
1455
+ finally { if (button) button.disabled = false; }
1456
+ });
1457
+
1458
+ document.addEventListener("change", (event) => {
1459
+ const picker = event.target.closest("#findings-run, #coverage-run");
1460
+ if (picker) { state.selectedRunId = picker.value; renderRuns(); }
1461
+ });
1462
+
1182
1463
  document.addEventListener("submit", (event) => {
1183
1464
  const audit = event.target.closest("form.audit-form");
1184
1465
  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>
@@ -63,10 +65,18 @@
63
65
  <li><button type="button" data-kind="github" data-prompt="owner/repo"><span>🐙</span><b>owner/repo</b><small>clone from GitHub into an isolated workspace, then the same</small></button></li>
64
66
  <li><button type="button" data-kind="build" data-prompt="com.company.app"><span>📱</span><b>com.company.app</b><small>explore a build already on the booted simulator (or give a .app / .apk)</small></button></li>
65
67
  </ul>
68
+ <!-- The front door (ADR-0011): on a hosted Studio, everything a website is not runs on the
69
+ person's own machine, and the page says so — with the command — before anyone types
70
+ one. Hidden on a local Studio, which is that machine. -->
71
+ <section class="selfhost-card hidden" id="selfhost-card">
72
+ <p class="selfhost-lead"><strong>Everything else runs on your own machine.</strong> Your repositories, iOS and Android builds, macOS apps, staging and localhost — the same Studio, on your Mac or PC, and nothing leaves it.</p>
73
+ <div class="selfhost-row"><code id="selfhost-command">npx -y @aarwitz/tapp@latest app</code><button class="quiet" type="button" id="selfhost-copy">Copy</button></div>
74
+ <small>Needs Node.js 20 or newer. It opens this same Studio in your browser, on your machine — no account needed.</small>
75
+ </section>
66
76
  <!-- Signing in to a public Studio: an email address and a link, nothing else. Hidden on a
67
77
  local Studio, where the one person at the keyboard is the operator already. -->
68
78
  <section class="signin-card hidden" id="signin-card" aria-live="polite">
69
- <p class="signin-lead"><strong>Sign in to go inside a site.</strong> tapp can stop at a sign-in and ask you for a test account, then remember it — for that it needs to know it is you.</p>
79
+ <p class="signin-lead"><strong>Sign in to go inside a site from here.</strong> tapp can stop at a sign-in and ask you for a test account, then remember it — for that it needs to know it is you. The cloud is free for 14 days, no card; your own machine is never gated.</p>
70
80
  <div id="signin-providers"></div>
71
81
  <form id="signin-form" autocomplete="email">
72
82
  <div class="signin-row"><input id="signin-email" name="email" type="email" placeholder="you@company.com" required><button class="primary" type="submit" id="signin-send">Email me a link</button></div>
@@ -90,6 +100,8 @@
90
100
  <nav class="primary-nav" aria-label="Product navigation">
91
101
  <button data-view="overview" class="active"><span><svg><use href="#i-grid"/></svg></span>Overview</button>
92
102
  <button data-view="runs"><span><svg><use href="#i-play"/></svg></span>Runs <i id="run-count" class="zero">0</i></button>
103
+ <button data-view="findings"><span><svg><use href="#i-alert"/></svg></span>Findings <i id="findings-count" class="zero">0</i></button>
104
+ <button data-view="coverage"><span><svg><use href="#i-map"/></svg></span>Coverage</button>
93
105
  <button data-view="platforms"><span><svg><use href="#i-grid"/></svg></span>Platforms</button>
94
106
  <button data-view="admin" id="admin-nav" class="hidden"><span><svg><use href="#i-grid"/></svg></span>Admin</button>
95
107
  </nav>
@@ -168,6 +180,21 @@
168
180
  </section>
169
181
  </section>
170
182
 
183
+ <section class="workspace-view" data-view-panel="findings">
184
+ <div class="view-heading simple">
185
+ <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>
186
+ <select id="findings-run" class="run-picker" aria-label="Which run"></select>
187
+ </div>
188
+ <div id="findings-body"><div class="empty">No run yet.</div></div>
189
+ </section>
190
+ <section class="workspace-view" data-view-panel="coverage">
191
+ <div class="view-heading simple">
192
+ <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>
193
+ <select id="coverage-run" class="run-picker" aria-label="Which run"></select>
194
+ </div>
195
+ <div class="coverage-counts" id="coverage-counts"></div>
196
+ <div id="coverage-body"><div class="empty">No run yet.</div></div>
197
+ </section>
171
198
  <section class="workspace-view" data-view-panel="platforms">
172
199
  <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
200
  <div id="platform-list"><div class="empty">Checking this machine…</div></div>
@@ -200,6 +227,14 @@
200
227
  </div>
201
228
  <div id="token-list"><div class="empty">No tokens yet.</div></div>
202
229
  </section>
230
+ <!-- Results flow up, the browser never reaches down (ADR-0011 §4): a self-hosted Studio
231
+ reports journeys run here to an account on app.runtapp.com. Local only. -->
232
+ <section class="panel section hidden" id="link-panel">
233
+ <div class="section-heading compact">
234
+ <div><p class="eyebrow">Your tapp account</p><h2>Report what runs here to your account</h2><p id="link-note">Journeys you run on this machine — including against staging and localhost — show up on your account with how their last run went. Nothing else leaves this machine: not the journey, not a credential, not a screenshot.</p></div>
235
+ </div>
236
+ <div id="link-body"></div>
237
+ </section>
203
238
  <section class="panel section" id="journeys-panel">
204
239
  <div class="section-heading compact"><div><p class="eyebrow">Journeys</p><h2>What this app has proven <i id="journey-count" class="zero">0</i></h2><p id="journeys-note">Each replays exactly as written — no model, no key. Keep one from any run that got somewhere; run it any time to prove it still works.</p></div></div>
205
240
  <div id="journeys-list"><div class="empty">No journeys yet.</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
  });