@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/bin/tapp.js CHANGED
@@ -1488,7 +1488,7 @@ switch (command) {
1488
1488
  break;
1489
1489
  }
1490
1490
  if (!["run", "validate"].includes(verb) || !flowPath) {
1491
- console.error("usage: tapp validate --example\n tapp flow steps [--json]\n tapp run <flow.yml|glob> [...more] [--var NAME=VALUE ...] [--platform ios|android|web] [--actor NAME] [--email VALUE] [--password VALUE] [--url URL] [--app-id ID] [--apk FILE] [--serial ID]\n tapp validate <flow.yml|glob> [...more]\n Several Flows (or a glob) run in sequence and print one line per Flow; exit 1 if any failed.");
1491
+ console.error("usage: tapp validate --example\n tapp flow steps [--json]\n tapp run <flow.yml|glob> [...more] [--var NAME=VALUE ...] [--platform ios|android|web] [--actor NAME] [--email VALUE] [--password VALUE] [--url URL] [--app-id ID] [--apk FILE] [--serial ID] [--record out.mp4 [--hold 3s]] [--no-report]\n tapp validate <flow.yml|glob> [...more]\n Several Flows (or a glob) run in sequence and print one line per Flow; exit 1 if any failed.");
1492
1492
  process.exit(2);
1493
1493
  }
1494
1494
  // Several Flows in one command (field issue #9): the shell usually expands the glob, but a
@@ -1648,10 +1648,95 @@ switch (command) {
1648
1648
  requireMacFor("iOS Flow replay");
1649
1649
  invocation = ["bash", [path.join(packageRoot, "scripts", "run-flow.sh"), absolute, typeof flags["bundle-id"] === "string" ? flags["bundle-id"] : flow.app || ""]];
1650
1650
  }
1651
+ // --record / --hold (TM-497). tapp owns the recorder so the video and the step times come out
1652
+ // of the same run; before this the wrapper started simctl by hand and the two clocks drifted.
1653
+ const recordTo = typeof flags.record === "string" && flags.record ? path.resolve(flags.record) : "";
1654
+ let holdMs = 0;
1655
+ let recorder = null;
1656
+ if (recordTo || flags.hold !== undefined) {
1657
+ const { parseHold } = await import(path.join(packageRoot, "mcp-server", "src", "flow-recording.js"));
1658
+ try { holdMs = parseHold(flags.hold === true ? "" : flags.hold); }
1659
+ catch (error) { console.error(`❌ ${error.message}`); process.exit(2); }
1660
+ }
1661
+ if (recordTo) {
1662
+ if (platform !== "ios") { console.error(`❌ --record records an iOS simulator (this Flow is ${platform})`); process.exit(2); }
1663
+ const { prepareRecorder, recorderToolingError, startRecording } = await import(path.join(packageRoot, "mcp-server", "src", "sim-recorder.js"));
1664
+ const missing = recorderToolingError();
1665
+ if (missing) { console.error(`❌ ${missing}`); process.exit(2); }
1666
+ const ready = prepareRecorder(env.TAPP_UDID);
1667
+ if (!ready.ok) { console.error(`❌ ${ready.error}`); process.exit(2); }
1668
+ // One line, because a repair nobody is told about costs the same three re-records next time.
1669
+ for (const note of ready.repaired) console.log(` recorder: ${note}`);
1670
+ recorder = startRecording({ udid: env.TAPP_UDID, out: recordTo, holdMs });
1671
+ // The recorder marks itself on a still screen; the flow must not start before that mark, or
1672
+ // the first change in the file is the app moving and the whole clock is wrong.
1673
+ await recorder.ready();
1674
+ }
1675
+ const flowStartedAtMs = Date.now();
1651
1676
  const result = spawnSync(invocation[0], invocation[1], { stdio: "inherit", env });
1677
+ if (recorder) {
1678
+ const stopped = await recorder.stop();
1679
+ if (!stopped.ok) {
1680
+ console.error(`\n⚠️ ${stopped.error}`);
1681
+ } else {
1682
+ const { flowStartedAtEpochMs, parseFlowSteps, writeStepsSidecar } = await import(path.join(packageRoot, "mcp-server", "src", "flow-recording.js"));
1683
+ const logText = fs.existsSync(flowLog) ? fs.readFileSync(flowLog, "utf8") : "";
1684
+ const steps = parseFlowSteps(logText);
1685
+ // The runner's own start, not this process's: on iOS most of a minute passes building and
1686
+ // launching the harness while the recorder is already rolling, and using the CLI's clock
1687
+ // puts every step that far too early in the video.
1688
+ const startedAt = flowStartedAtEpochMs(logText) ?? flowStartedAtMs;
1689
+ // The recorder writes a frame when the screen CHANGES, so a flow that ends on a still
1690
+ // screen leaves the file ending before the flow does and the last steps land past its end.
1691
+ // Cloning the final frame covers that gap; the hold comes on top of it. This happens
1692
+ // before the sidecar is written so the sidecar can be told the file's real length.
1693
+ const { padTail, tailMsFor } = await import(path.join(packageRoot, "mcp-server", "src", "sim-recorder.js"));
1694
+ const { stepsInVideoTime } = await import(path.join(packageRoot, "mcp-server", "src", "flow-recording.js"));
1695
+ const placed = stepsInVideoTime(steps, { flowStartedAtMs: startedAt, recordingStartedAtMs: stopped.startedAtMs });
1696
+ const lastStepEndMs = placed.length ? placed[placed.length - 1].end * 1000 : 0;
1697
+ // TAPP_RECORD_DEBUG keeps the capture exactly as simctl wrote it, before any tail is added,
1698
+ // and prints the two clocks. This is what a report of "the step times are wrong" needs:
1699
+ // every timing bug found while building this was invisible in the finished file.
1700
+ if (process.env.TAPP_RECORD_DEBUG === "1") {
1701
+ fs.copyFileSync(recordTo, `${recordTo}.raw.mp4`);
1702
+ console.error(`[record] capture ${(stopped.durationMs / 1000).toFixed(3)}s, ${stopped.frames} frames, first frame at ${stopped.startedAtMs}, flow started at ${startedAt} (+${((startedAt - stopped.startedAtMs) / 1000).toFixed(3)}s), last step ends ${(lastStepEndMs / 1000).toFixed(3)}s`);
1703
+ console.error(`[record] capture kept unpadded at ${recordTo}.raw.mp4`);
1704
+ }
1705
+ const held = padTail(recordTo, tailMsFor({ durationMs: stopped.durationMs, lastStepEndMs, holdMs }));
1706
+ if (held.error) console.error(`⚠️ ${held.error}`);
1707
+ const finalMs = held.durationMs ?? stopped.durationMs;
1708
+ // Say how much of the finished file is a held frame rather than captured picture. The
1709
+ // recorder stops writing when the screen stops changing, so the tail is always partly a
1710
+ // clone — a few seconds on a normal run. One take ended its capture 26 seconds before the
1711
+ // flow did and the rest was a single frozen frame, and the finished file gave no sign of
1712
+ // it; anyone editing that would have found out the hard way.
1713
+ const heldMs = Math.max(0, finalMs - stopped.durationMs);
1714
+ const sidecar = writeStepsSidecar(recordTo, steps, {
1715
+ flowStartedAtMs: startedAt, recordingStartedAtMs: stopped.startedAtMs, holdMs,
1716
+ name: flow.name || "", videoDurationMs: finalMs,
1717
+ });
1718
+ console.log(`\nRecording: ${recordTo} (${(finalMs / 1000).toFixed(1)}s — ${(stopped.durationMs / 1000).toFixed(1)}s captured${heldMs > 500 ? `, ${(heldMs / 1000).toFixed(1)}s holding the last screen` : ""})`);
1719
+ console.log(`Step times: ${sidecar.path} (${sidecar.steps.length} step${sidecar.steps.length === 1 ? "" : "s"} in the video's own seconds)`);
1720
+ }
1721
+ }
1652
1722
  const evidenceWritten = fs.existsSync(evidenceDir) && fs.readdirSync(evidenceDir).length > 0;
1653
1723
  if (evidenceWritten) console.log(`\nEvidence: ${evidenceDir}`);
1654
1724
  else console.error("\n⚠️ Evidence unavailable — the platform runner did not write any artifacts for this Flow run.");
1725
+ // A machine linked to an account reports how the journey went — the name and the result,
1726
+ // never the Flow, a credential or a screenshot (ADR-0011 §4). The same rule as the Studio on
1727
+ // this machine, so an iOS or Android journey run from a terminal shows on the account too.
1728
+ // `--no-report` keeps one run to itself; a Studio that cannot be reached never fails the run.
1729
+ if (flags["no-report"] !== true) {
1730
+ const { studioLinkFor, reportStudioJourney, flowResultFromLog } = await import(path.join(packageRoot, "mcp-server", "src", "studio-client.js"));
1731
+ const link = studioLinkFor();
1732
+ if (link) {
1733
+ const verdict = flowResultFromLog(fs.existsSync(flowLog) ? fs.readFileSync(flowLog, "utf8") : "") || {};
1734
+ try {
1735
+ await reportStudioJourney(link, { name: flow.name || path.basename(flowPath, path.extname(flowPath)), platform, url: flow.url || "", steps: (flow.steps || []).length, machine: os.hostname(), passed: verdict.passed ?? result.status === 0, executed: verdict.executed ?? 0, total: verdict.total ?? (flow.steps || []).length, failed: verdict.failed ?? 0 });
1736
+ console.log(`Reported to ${link.origin}${link.email ? ` as ${link.email}` : ""}`);
1737
+ } catch (error) { console.error(`⚠️ Could not report to ${link.origin}: ${error.message}`); }
1738
+ }
1739
+ }
1655
1740
  await pruneEvidenceQuietly();
1656
1741
  process.exit(result.status ?? 1);
1657
1742
  }
@@ -2011,6 +2096,16 @@ switch (command) {
2011
2096
  + `${usage.oldestMs ? `, oldest ${formatAge(Date.now() - usage.oldestMs)}` : ""} · ${window}`);
2012
2097
  }
2013
2098
 
2099
+ // Evidence an older Tapp wrote into its own source checkout (TM-651): the clearing-out above
2100
+ // never looks there, so it stays until someone deletes it. Mentioned once it exists.
2101
+ const repoCaptures = path.join(packageRoot, "captures");
2102
+ const stray = evidenceUsage({ root: repoCaptures });
2103
+ report.strayEvidence = stray.runs ? { path: repoCaptures, runs: stray.runs, bytes: stray.bytes } : null;
2104
+ if (stray.runs) {
2105
+ say(` ⚠️ Old evidence in the Tapp checkout — ${formatStorage(stray.bytes)} in ${stray.runs} run${stray.runs === 1 ? "" : "s"} at ${repoCaptures}`
2106
+ + ` · never cleared automatically; Tapp no longer writes there, so delete it once: rm -rf "${repoCaptures}"`);
2107
+ }
2108
+
2014
2109
  say("\n Platforms:");
2015
2110
  if (process.platform === "darwin") {
2016
2111
  const xcode = run("xcode-select", ["-p"]);
package/browser/app.css CHANGED
@@ -569,6 +569,19 @@ dialog::backdrop { background:rgba(0,0,0,.6); }
569
569
  .signin-row input { flex:1 1 220px; font:inherit; padding:9px 12px; border-radius:10px; border:1px solid var(--line); background:rgba(0,0,0,.15); color:inherit; }
570
570
  .signin-row button { font:inherit; padding:9px 14px; border-radius:10px; cursor:pointer; }
571
571
  .signin-sent { margin:0; }
572
+ /* The front door's second answer (ADR-0011): what runs on the person's own machine, with the command. */
573
+ .selfhost-card { max-width:560px; margin:14px auto 0; padding:14px 16px; border-radius:var(--tapp-radius-lg, 14px); border:1px solid var(--line); background:var(--control); font-size:13px; line-height:1.5; }
574
+ .selfhost-card p { margin:0 0 10px; }
575
+ .selfhost-card small { display:block; margin-top:8px; color:var(--tapp-text-faint); }
576
+ .selfhost-row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
577
+ .selfhost-row code { flex:1 1 220px; font-family:var(--tapp-font-mono); font-size:12.5px; padding:9px 12px; border-radius:10px; border:1px solid var(--line); background:rgba(0,0,0,.25); color:inherit; overflow-wrap:anywhere; }
578
+ .selfhost-row button { font:inherit; font-size:12px; padding:7px 12px; border-radius:999px; border:1px solid var(--line); background:var(--control); color:inherit; cursor:pointer; }
579
+ /* Linking this machine to an account (ADR-0011 §4). */
580
+ .link-form { display:grid; gap:8px; max-width:560px; }
581
+ .link-form input { font:inherit; padding:9px 12px; border-radius:10px; border:1px solid var(--line); background:rgba(0,0,0,.15); color:inherit; }
582
+ .link-form .ask-actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
583
+ .link-form small, .link-state small { color:var(--tapp-text-faint); }
584
+ .link-state { display:flex; gap:10px; align-items:center; flex-wrap:wrap; font-size:13px; }
572
585
  .actor-row { display:grid; grid-template-columns:1fr auto auto; gap:10px; align-items:center; padding:8px 10px; border-bottom:1px solid var(--tapp-border); font-size:13px; }
573
586
  .actor-row:last-child { border-bottom:0; }
574
587
  .actor-row small { color:var(--muted); }
@@ -630,4 +643,80 @@ dialog::backdrop { background:rgba(0,0,0,.6); }
630
643
  .platform-state.needs-machine { color:var(--tapp-amber-soft); border-color:rgba(210,153,34,.38); }
631
644
 
632
645
  /* A suggestion this Studio cannot start is dimmed, not deleted: pressing it still answers. */
633
- .prompt-suggestions [data-kind].elsewhere { opacity:.62; }
646
+
647
+ /* ---- Findings and Coverage (TM-794) -------------------------------------------------------
648
+ Findings reads as a short list of kinds a person can scan, each opening onto the individual
649
+ places. Coverage reads left to right, one column per step away from the screen the run
650
+ started on, the way the run actually went. */
651
+
652
+ .run-picker { min-width:240px; max-width:340px; padding:7px 10px; border:1px solid var(--line); border-radius:var(--radius); background:var(--control); color:var(--ink); font-size:11px; }
653
+
654
+ .findings-tally { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-bottom:14px; }
655
+ .findings-tally .button-link { margin-top:0; margin-left:auto; }
656
+ .sev-tally { border:1px solid var(--line); border-radius:999px; padding:4px 11px; font-size:11px; font-weight:600; color:var(--muted); background:var(--control); }
657
+ .sev-tally.critical,.sev-tally.high { color:var(--tapp-red); border-color:rgba(248,81,73,.45); background:var(--tapp-red-bg); }
658
+ .sev-tally.medium { color:var(--tapp-amber-soft); border-color:rgba(210,153,34,.45); background:var(--tapp-amber-bg); }
659
+
660
+ .finding-group { border:1px solid var(--line); border-radius:var(--radius); background:var(--paper); margin-bottom:8px; }
661
+ .finding-group>summary { display:flex; align-items:center; gap:10px; padding:12px 14px; cursor:pointer; list-style:none; }
662
+ .finding-group>summary::-webkit-details-marker { display:none; }
663
+ .finding-group>summary::after { content:"▾"; width:14px; text-align:center; color:var(--muted); font-size:11px; line-height:1; transition:transform .12s ease; }
664
+ .finding-group.single { display:flex; align-items:center; gap:10px; padding:12px 14px; }
665
+ .finding-group.single .group-count { color:var(--faint); }
666
+ .finding-group[open]>summary::after { transform:rotate(180deg); }
667
+ .finding-group>summary:hover { background:var(--wash); border-radius:var(--radius); }
668
+ .group-label { flex:1; font-weight:600; font-size:13px; }
669
+ .group-count { color:var(--muted); font-size:11px; font-variant-numeric:tabular-nums; }
670
+ .sev-dot { width:8px; height:8px; border-radius:50%; background:var(--faint); flex:none; }
671
+ .sev-dot.critical,.sev-dot.high { background:var(--tapp-red); }
672
+ .sev-dot.medium { background:var(--tapp-amber); }
673
+ .sev-dot.low { background:var(--tapp-text-faint); }
674
+ .finding-group .detail-list { padding:0 18px 14px 34px; }
675
+ .finding-group .detail-list li { margin-bottom:5px; }
676
+ .finding-group .detail-list b { text-transform:uppercase; font-size:9px; letter-spacing:.06em; }
677
+ .detail-list b.sev-critical,.detail-list b.sev-high { color:var(--tapp-red); }
678
+ .detail-list b.sev-medium { color:var(--tapp-amber-soft); }
679
+
680
+ .coverage-counts { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-bottom:16px; }
681
+ .coverage-counts span { border:1px solid var(--line); border-radius:999px; padding:5px 12px; font-size:11px; color:var(--muted); background:var(--control); }
682
+ .coverage-counts span b { color:var(--ink); font-size:13px; margin-right:4px; font-variant-numeric:tabular-nums; }
683
+ .coverage-counts .button-link { margin-top:0; margin-left:auto; }
684
+
685
+ .coverage-map { display:flex; gap:22px; align-items:flex-start; overflow-x:auto; padding-bottom:10px; }
686
+ .coverage-column { display:flex; flex-direction:column; gap:14px; flex:none; width:210px; }
687
+ .coverage-column-head { margin:0 0 2px; color:var(--faint); font-size:10px; font-weight:700; letter-spacing:.1em; text-transform:uppercase; }
688
+
689
+ .screen-card { border:1px solid var(--line); border-radius:var(--radius-lg); background:var(--paper); padding:10px; }
690
+ .screen-card.orphan { border-style:dashed; }
691
+ .screen-card strong { display:block; margin-top:9px; font-size:12px; line-height:1.3; }
692
+ .screen-card>small { display:block; margin-top:3px; color:var(--faint); font-size:10px; }
693
+ /* The card is the shape of the thing it is a picture of. A web still forced into a phone's
694
+ portrait box loses its left edge to `cover`, taking the screen's own name with it. */
695
+ .screen-shot { position:relative; aspect-ratio:3/4; border-radius:var(--radius); overflow:hidden; background:var(--wash); display:flex; align-items:center; justify-content:center; }
696
+ .coverage-map[data-platform="web"] .screen-shot,
697
+ .coverage-map[data-platform="macos"] .screen-shot { aspect-ratio:16/10; }
698
+ .coverage-map[data-platform="web"] .coverage-column,
699
+ .coverage-map[data-platform="macos"] .coverage-column { width:260px; }
700
+ .screen-shot img { width:100%; height:100%; object-fit:cover; object-position:top center; }
701
+ .screen-shot-none { color:var(--faint); font-size:10px; }
702
+ .screen-note { position:absolute; left:6px; right:6px; bottom:6px; padding:3px 6px; border-radius:4px; background:rgba(9,12,17,.82); color:var(--tapp-amber-soft); font-size:9px; text-align:center; }
703
+ .screen-exits { margin:9px 0 0; padding:0; list-style:none; display:flex; flex-direction:column; gap:4px; }
704
+ .screen-exits li { color:var(--muted); font-size:10px; line-height:1.35; }
705
+ .screen-exits li span { color:var(--faint); }
706
+ .screen-exits-none { margin:9px 0 0; color:var(--faint); font-size:10px; }
707
+ .coverage-note { margin-top:14px; font-size:11px; }
708
+
709
+ @media (max-width:860px) {
710
+ .coverage-column { width:168px; }
711
+ .run-picker { min-width:0; width:100%; max-width:none; }
712
+ }
713
+
714
+ .findings-section { margin-bottom:26px; }
715
+ .findings-section h2 { font-size:14px; margin-bottom:4px; }
716
+ .findings-section h2 i { color:var(--muted); font-style:normal; font-size:12px; font-variant-numeric:tabular-nums; }
717
+ .findings-section>.muted { font-size:11px; margin-bottom:10px; }
718
+
719
+ /* A run with no recorded transitions has no path to lay out, so its screens are a plain grid. */
720
+ .coverage-map.flat { display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:16px; overflow-x:visible; }
721
+ .coverage-map.flat[data-platform="web"] { grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); }
722
+ .coverage-map.flat .screen-card { width:auto; }