@aarwitz/tapp 0.19.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tapp",
3
3
  "description": "Give Claude hands and eyes on iOS, Android, and web apps, with exploration, replayable flows, evidence, and deterministic CI gates.",
4
- "version": "0.19.0",
4
+ "version": "0.19.1",
5
5
  "author": {
6
6
  "name": "Aaron Horowitz",
7
7
  "url": "https://github.com/aarwitz"
@@ -24,7 +24,7 @@
24
24
  "command": "npx",
25
25
  "args": [
26
26
  "-y",
27
- "@aarwitz/tapp@0.19.0",
27
+ "@aarwitz/tapp@0.19.1",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
package/browser/app.js CHANGED
@@ -106,7 +106,12 @@ function applyAccessMode() {
106
106
  // runner, a release gate, a decision. A hosted visitor auditing a URL has none of them, and
107
107
  // showing the empty frames makes a working run look like a broken one.
108
108
  for (const node of document.querySelectorAll("[data-repo-only]")) node.classList.add("hidden");
109
- setHeading("tapp", "Give it a public website and it will audit the pages read-only.");
109
+ // "What the last run proved" reports a release decision. A read-only website audit never
110
+ // produces one, so the panel can only ever say "No run yet" here.
111
+ document.querySelector(".summary-panel")?.classList.add("hidden");
112
+ // refreshSession() runs on every poll, so this must not overwrite a heading the current run
113
+ // already set — that is what made "Website audit" revert to "tapp" when a run finished.
114
+ if (!state.headingOwnedByRun) setHeading("tapp", "Give it a public website and it will audit the pages read-only.");
110
115
  const note = $("#privacy-note-detail");
111
116
  if (note) note.textContent = "Websites are audited read-only in the cloud; nothing is clicked. iOS, Android and folders on your own machine need tapp there: npx -y @aarwitz/tapp@latest app";
112
117
  }
@@ -569,7 +574,10 @@ async function runOperation(name, body = {}, { input = "" } = {}) {
569
574
 
570
575
  // "What should tapp test?" — route by what was typed. The server classifies again and refuses
571
576
  // what the mode cannot do (a hosted Studio cannot open a path on your machine).
572
- function setHeading(title, summary) {
577
+ // `owned` marks a heading as belonging to whatever is happening now, so periodic re-renders
578
+ // leave it alone until something else takes over.
579
+ function setHeading(title, summary, { owned = false } = {}) {
580
+ state.headingOwnedByRun = owned;
573
581
  const heading = $("#app-name");
574
582
  if (heading) heading.textContent = title;
575
583
  const note = $("#app-summary");
@@ -580,7 +588,7 @@ function setHeading(title, summary) {
580
588
  // simulator build, a repository that needs a toolchain. The engine answers with where they do
581
589
  // run; show that answer where it stays put, not in a toast that disappears in six seconds.
582
590
  function answerSelfHost(answer) {
583
- setHeading("Run this on your machine", "The cloud Studio audits websites; this target needs your toolchain.");
591
+ setHeading("Run this on your machine", "The cloud Studio audits websites; this target needs your toolchain.", { owned: true });
584
592
  document.querySelector(".summary-panel")?.classList.add("hidden");
585
593
  document.querySelector(".device-stage")?.classList.add("hidden");
586
594
  state.transcript = [];
@@ -598,8 +606,8 @@ async function startFromPrompt(raw) {
598
606
  state.promptRun = true; state.promptPlatform = "web";
599
607
  showProduct(); activateView("overview"); renderDeviceChrome(); renderChat();
600
608
  document.querySelector(".device-stage")?.classList.remove("hidden");
601
- document.querySelector(".summary-panel")?.classList.remove("hidden");
602
- if (state.session?.access === "anonymous") setHeading("Website audit", "Read-only. Nothing on the page is clicked.");
609
+ if (state.session?.access !== "anonymous") document.querySelector(".summary-panel")?.classList.remove("hidden");
610
+ if (state.session?.access === "anonymous") setHeading("Website audit", "Read-only. Nothing on the page is clicked.", { owned: true });
603
611
  const result = await runOperation("audit", { url: prompt.value }, { input: prompt.value });
604
612
  state.selectedRunId = result?.capture?.id || state.selectedRunId;
605
613
  return;
@@ -16,6 +16,7 @@ import { initializeProductProject, prepareProductTarget, readProductProject, run
16
16
  import { readCaptureProvenance } from "./capture-provenance.js";
17
17
  import { collectShots } from "./html-report.js";
18
18
  import { classifyPrompt } from "../../browser/view-model.js";
19
+ import { JobLanes } from "./job-lanes.js";
19
20
 
20
21
  const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
21
22
  const assetRoot = path.join(packageRoot, "browser");
@@ -450,18 +451,17 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
450
451
  const sessionToken = crypto.randomBytes(32).toString("base64url");
451
452
  const csrfToken = crypto.randomBytes(24).toString("base64url");
452
453
  const jobs = new Map();
453
- let activeMutation = null;
454
+ // Work is serialized per lane rather than globally; see job-lanes.js for why.
455
+ const OPERATOR_LANE = "operator";
456
+ const lanes = new JobLanes({ operatorLane: OPERATOR_LANE });
454
457
  let liveSession = null;
455
458
  let liveManagedRuntime = null;
456
459
  let origin = "";
457
460
 
458
- const startJob = (operation, work, repositoryId = registry.current()?.id || null) => {
459
- if (activeMutation) {
460
- const error = new Error(`Operation '${activeMutation.operation}' is still running`);
461
- error.statusCode = 409;
462
- throw error;
463
- }
464
- const job = { id: crypto.randomBytes(10).toString("hex"), operation, repositoryId, status: "running", createdAt: new Date().toISOString(), progress: [] };
461
+ const startJob = (operation, work, repositoryId = registry.current()?.id || null, { lane = OPERATOR_LANE } = {}) => {
462
+ const job = { id: crypto.randomBytes(10).toString("hex"), operation, repositoryId, lane, status: "running", createdAt: new Date().toISOString(), progress: [] };
463
+ const claimed = lanes.claim(lane, job);
464
+ if (!claimed.ok) throw Object.assign(new Error(claimed.message), { statusCode: claimed.statusCode });
465
465
  const progress = (entry) => {
466
466
  const normalized = typeof entry === "string" ? { text: entry } : entry || {};
467
467
  job.progress.push({ at: new Date().toISOString(), phase: normalized.phase || operation, text: String(normalized.text || "").slice(-1200), ...(normalized.current ? { current: normalized.current, total: normalized.total } : {}), ...(normalized.screen ? { screen: String(normalized.screen).slice(0, 200) } : {}) });
@@ -471,7 +471,6 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
471
471
  if (normalized.screenshot && path.isAbsolute(normalized.screenshot)) job.latestFrame = normalized.screenshot;
472
472
  };
473
473
  jobs.set(job.id, job);
474
- activeMutation = job;
475
474
  Promise.resolve().then(() => work(progress)).then((result) => {
476
475
  job.status = "completed";
477
476
  job.result = result;
@@ -480,7 +479,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
480
479
  job.error = { message: error.message || String(error), ...(error.details ? { details: error.details } : {}) };
481
480
  }).finally(() => {
482
481
  job.completedAt = new Date().toISOString();
483
- if (activeMutation === job) activeMutation = null;
482
+ lanes.release(lane, job);
484
483
  });
485
484
  return job;
486
485
  };
@@ -668,7 +667,8 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
668
667
 
669
668
  if (request.method === "POST" && url.pathname === "/api/repositories/select") {
670
669
  requireMutationAuth(request, hosted ? publicOrigins : origin, csrfToken);
671
- if (activeMutation) throw Object.assign(new Error(`Operation '${activeMutation.operation}' is still running`), { statusCode: 409 });
670
+ const busy = lanes.running(OPERATOR_LANE);
671
+ if (busy) throw Object.assign(new Error(`Operation '${busy.operation}' is still running`), { statusCode: 409 });
672
672
  if (liveSession?.active) throw Object.assign(new Error("End the active live session before changing repositories"), { statusCode:409 });
673
673
  const body = await readJsonBody(request);
674
674
  const repository = registry.select(body.id);
@@ -789,7 +789,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
789
789
  onPage: (page, n) => progress({ phase: "explore", text: `Audited ${page.url} — ${page.findings.length} finding(s)`, current: n, total: pages, ...(page.screenshot ? { screenshot: page.screenshot } : {}) }),
790
790
  });
791
791
  return hosted ? hostedPayload(summary) : summary;
792
- }, null);
792
+ }, null, { lane: visitorId || OPERATOR_LANE });
793
793
  job.visitorId = visitorId;
794
794
  json(response, 202, { job: publicJob(job, { hosted }) });
795
795
  return;
@@ -0,0 +1,49 @@
1
+ // Who is allowed to be running right now.
2
+ //
3
+ // A local Studio owns one simulator, one repository and one live session, so the operator's work
4
+ // is strictly one at a time. A public Studio has many visitors whose website audits share none of
5
+ // that — each drives its own browser and writes its own capture — so serializing them globally
6
+ // only makes a working Studio look broken to the second person through the door.
7
+ //
8
+ // Lanes are that distinction: the operator has one, every visitor has their own, and the machine
9
+ // keeps a ceiling because it is finite. The ceiling and a lane conflict are different answers:
10
+ // "busy, try again" is not the same as "your own run is still going".
11
+ export class JobLanes {
12
+ constructor({ operatorLane = "operator", maxConcurrentGuests = 3 } = {}) {
13
+ this.operatorLane = operatorLane;
14
+ this.maxConcurrentGuests = maxConcurrentGuests;
15
+ this.active = new Map();
16
+ }
17
+
18
+ get guestsRunning() {
19
+ let count = 0;
20
+ for (const lane of this.active.keys()) if (lane !== this.operatorLane) count += 1;
21
+ return count;
22
+ }
23
+
24
+ running(lane) {
25
+ return this.active.get(lane) || null;
26
+ }
27
+
28
+ /**
29
+ * Take the lane, or explain why not. Returns `{ ok: true }`, or `{ ok: false, statusCode,
30
+ * message }` — 409 when this lane is already working, 503 when the machine is at its ceiling.
31
+ */
32
+ claim(lane, job) {
33
+ const busy = this.active.get(lane);
34
+ if (busy) {
35
+ return { ok: false, statusCode: 409, message: `Operation '${busy.operation}' is still running` };
36
+ }
37
+ if (lane !== this.operatorLane && this.guestsRunning >= this.maxConcurrentGuests) {
38
+ return { ok: false, statusCode: 503, message: "This Studio is busy with other runs right now; try again in a minute." };
39
+ }
40
+ this.active.set(lane, job);
41
+ return { ok: true };
42
+ }
43
+
44
+ // Releasing is idempotent and only ever clears the job that holds the lane, so a late
45
+ // completion cannot free a lane someone else has since taken.
46
+ release(lane, job) {
47
+ if (this.active.get(lane) === job) this.active.delete(lane);
48
+ }
49
+ }
@@ -1213,9 +1213,15 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1213
1213
  const video = page.video();
1214
1214
  await context.close().catch(() => {});
1215
1215
  if (video) {
1216
- await video.path()
1217
- .then((p) => fs.renameSync(p, path.join(outDir, "exploration.webm")))
1218
- .catch(() => {});
1216
+ const finalPath = path.join(outDir, "exploration.webm");
1217
+ await video.path().then((p) => fs.renameSync(p, finalPath)).catch(() => {});
1218
+ // Playwright records VP9, which QuickTime and Preview cannot open. Write an H.264 sibling
1219
+ // so the evidence is playable where it lands, instead of needing a conversion step that
1220
+ // whoever opens it has to know about. Best effort: no ffmpeg just means no mp4.
1221
+ if (fs.existsSync(finalPath)) {
1222
+ const { writePlayableCopy } = await import("./capture-frames.js");
1223
+ await writePlayableCopy(finalPath).catch(() => {});
1224
+ }
1219
1225
  }
1220
1226
  await browser.close().catch(() => {});
1221
1227
  }
@@ -364,7 +364,13 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, recordVide
364
364
  if (video) {
365
365
  try {
366
366
  const produced = await video.path();
367
- if (produced && fs.existsSync(produced)) fs.renameSync(produced, path.join(recordVideoDir, "replay.webm"));
367
+ if (produced && fs.existsSync(produced)) {
368
+ const finalPath = path.join(recordVideoDir, "replay.webm");
369
+ fs.renameSync(produced, finalPath);
370
+ // VP9 is unopenable in QuickTime and Preview; ship an H.264 sibling beside it.
371
+ const { writePlayableCopy } = await import("./capture-frames.js");
372
+ await writePlayableCopy(finalPath).catch(() => {});
373
+ }
368
374
  } catch { /* the replay result matters more than its recording */ }
369
375
  }
370
376
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "mcpName": "io.github.aarwitz/tapp",
5
5
  "description": "Let coding agents verify UI changes on real iOS, Android, and web surfaces, then enforce reviewed proof in deterministic CI.",
6
6
  "license": "MIT",
@@ -96,7 +96,7 @@
96
96
  "mobile"
97
97
  ],
98
98
  "scripts": {
99
- "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-audit.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
99
+ "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-audit.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
100
100
  "test:browser-journey": "node --test tests/browser-journey.test.js",
101
101
  "test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
102
102
  }