Capture: setup, heal & expand
Explore a running app live via --record, write .pitafix/capture.json, CAPTURE.md, and a replay script (or pitafix.trace/1), heal failing captures, and cover dark files.
PitaFix maps a UI project in two phases: interactive exploration (drive the running app live via --record MCP tools) followed by deterministic replay (commit .pitafix/capture.json, .pitafix/CAPTURE.md, and a small replay script in the project's language).
Choose the capture mode
| Target stack | kind | Recording path |
|---|---|---|
| Web app (Next.js, React, Rails, Vue, static) | "web" | Localhost Chromium/CEF recorder (POST /v1/sessions or --record MCP) |
Native iOS (Xcode 26+, iOS 26+, swapify) | "mobile" | Swapify iOS recorder (platform: "ios"; run swapify init --no-agents once) |
| Android, KMP, Flutter, SwiftUI without Swapify, desktop | "mobile" / "native" / "trace" | Write Level-0 pitafix.trace/1 + pitafix.tree/1 folders into $PITAFIX_TRACES_DIR/<unique-run-id>/ |
Phase 1: Explore live (--record MCP)
- Run
pitafix doctor --project . --jsonto verify local toolchains. - Boot the app on fresh fixture or local data (follow Trust & boundaries).
- Call
record_start(base_url+data_source: "fixture"for web, orplatform: "ios"for Swapify iOS). - Start each flow with
record_journeyusing a stableid,name, andsection. - Drive screens with
record_step, inspecting live DOM/elements between actions viarecord_inspect. Passprivate: trueon sensitive web inputs androuteto normalize dynamic URLs (/items/123→/items/:id). - Report unreached routes via
record_unreached, then close withrecord_finish.
Phase 2: Write .pitafix/
.pitafix/capture.json(full schema and byte limits in Schemas):
{
"schema": "pitafix.project-capture/1",
"kind": "web",
"name": "Storefront",
"command": ["node", ".pitafix/capture.mjs"],
"diffScoped": true
}.pitafix/capture.<ext>(capture.mjs,capture.rb,capture.py,capture.go,capture.sh):- Boots and tears down local fixture servers/DBs cleanly in
finally/ensure/defer. - Calls
$PITAFIX_RECORDER_URLwithAuthorization: Bearer $PITAFIX_RECORDER_TOKEN(endpoints and minimal Node, Swapify iOS, and Rails attribution examples in Recorder API). - Honors diff-scoped runs when
diffScoped: true: whenPITAFIX_DIFF_SCOPED === "1", run only journey IDs inPITAFIX_AFFECTED_JOURNEYS(exit0cleanly when empty). - For non-web Level-0 captures, write
$PITAFIX_TRACES_DIR/<unique-run-id>/trace.ndjson+artifacts/*.png+artifacts/*.tree.json(format in Schemas); PitaFix auto-ingests on exit (or runpitafix ingest --project . <dir>).
- Boots and tears down local fixture servers/DBs cleanly in
.pitafix/CAPTURE.md: concise playbook covering boot commands, fixture seeding, test login, journey inventory, and gotchas for future runs.
Sidecar bundles for read-only repos
Place capture.json, CAPTURE.md, and the script in <PITAFIX_DATA_DIR>/projects/<rootCommit>/capture/ (or run pitafix record run --project <repo> --config /path/to/capture.json). Resolve sibling fixtures from the script's own path, locate the repo via $PITAFIX_PROJECT_ROOT (fallback: cwd), export a throwaway copy with git -C "$PITAFIX_PROJECT_ROOT" archive "${PITAFIX_COMMIT:-HEAD}" | tar -x -C "$tmp", and delete $tmp on exit.
Heal a broken capture
- Read
.pitafix/CAPTURE.md,.pitafix/capture.json, the Capture Log failure report, and recentgit diff. - Reproduce the failing step via
--recordMCP and inspect live roles/labels/test_ids withrecord_inspect. - Patch the script using resilient
role+nameortestIdselectors while preserving existing journeyids so screen comments stay attached. Update.pitafix/CAPTURE.mdif boot or seed steps changed.
| Symptom | Likely cause | Fix |
|---|---|---|
proxyRefused non-empty | External host blocked by loopback proxy | Mock locally (preferred) or add bare hostname to allowedHosts for human approval |
/step returns HTTP 200 with status: "failed" | Missing selector, timeout, or blocking modal | Inspect screenshotPath and elements returned in the failed step or call record_inspect |
attributionsCount: 0 on web steps | Missing source maps or uninstrumented backend | Enable source maps on local build, or post backend files to $PITAFIX_ATTRIBUTION_URL via X-Request-Id |
| Capture hangs until timeout | Child server inherited stdio or ignored SIGTERM | Stop servers/DBs in cleanup hooks and close inherited stdio |
| Diff-scoped run fails on 0 matches | Script treated empty PITAFIX_AFFECTED_JOURNEYS as error | Exit 0 when PITAFIX_DIFF_SCOPED === "1" and PITAFIX_AFFECTED_JOURNEYS is empty |
Expand coverage for new screens & dark files
- Run
pitafix affected --project . --from HEAD~1 --json(or MCPlist_dark_files+get_app_map) to locateNewDarkFilesandunreachedRoutes. - Drive the new routes live with
--recordMCP using existing fixture/auth helpers from.pitafix/CAPTURE.md. - Add the new journeys/steps to
.pitafix/capture.<ext>and drop reached routes fromunreached.
Completion criteria
pitafix record run --project .exits0withfailedSteps: 0, ingesting screenshots, UI trees, and attributions.- Existing journey IDs stay intact unless a flow was removed from the app; newly targeted routes drop from
unreachedRoutes/list_dark_files. - Zero dev servers, test databases, or temp directories remain after exit, and
.pitafix/CAPTURE.mdmatches the script.