feat: Diffwatch — visual regression capture system#40
Open
pastarita wants to merge 9 commits intoTextureHQ:mainfrom
Open
feat: Diffwatch — visual regression capture system#40pastarita wants to merge 9 commits intoTextureHQ:mainfrom
pastarita wants to merge 9 commits intoTextureHQ:mainfrom
Conversation
Full architecture spec for automated before/after screenshot pipeline: - Capture manifest schema for declaring routes, selectors, viewports - Dual-server git worktree strategy for parallel base/PR capture - Color-rationalized annotation system (red/green/blue/orange/yellow) - Side-by-side composition engine with title/footer bars - GitHub issue upload for permanent image hosting - File-to-route mapping for auto-manifest generation - GitHub Actions workflow integration - CLI interface with selective capture support
Added: actual TypeScript implementations for capture, annotate, compose, diff, and upload modules. Added open-source tool landscape comparison (Lost Pixel, Argos CI, Chromatic, Percy, BackstopJS, reg-suit, Playwright built-in). Corrected image hosting strategy to GitHub branch storage per API research. Added recommendation matrix for tool selection.
Working pipeline: Playwright captures screenshots at specified routes and viewports, sharp+SVG draws color-coded bounding boxes (red/green/ blue/orange/yellow), compose engine creates side-by-side BEFORE|AFTER images with title bar and footer, pixelmatch computes pixel diffs. Modules: - playwright-capture.ts: browser automation + bbox recording - annotate.ts: SVG overlay compositing via sharp - compose.ts: side-by-side image composition - diff.ts: pixelmatch diff detection - capture-vr.ts: orchestrator (worktree, servers, pipeline) - capture-manifest.json: 10 capture targets for welcome-pr - file-route-map.json: file→route mapping for auto-manifest New scripts: npm run vr:capture, npm run vr:capture:pr-only New devDeps: playwright, sharp, pixelmatch, pngjs, wait-on
The base worktree was missing public/data/ (gitignored, generated by prebuild), causing all data pages to 404. Now syncs data/ and runs prebuild in the worktree. Also improves content readiness detection.
Port 3100 was occupied by another process, causing all BEFORE captures to show 404 pages or a different app's UI. Moved to 4100/4101 and added a pre-flight port check that fails fast with a clear error message.
Each targeted re-run now appends _00, _01, _02… to comparison, annotated, and diff filenames. An unversioned "latest" copy is also maintained at the base stem for easy reference. This gives local traceability when re-running the pipeline for specific captures without overwriting previous results.
…inals Each vr:capture run now deletes old _NN files before writing the new version, keeping only the latest ordinal per stem across comparisons, annotated, and diffs directories. Also updates PR description template to use DRAG_DROP placeholder convention for manual image upload.
…n template - detect-alerts.ts: edge-margin red pill scanner for Next.js error indicators - clean.ts: safe cleanup with run-log.jsonl archival - PR_DESCRIPTION_DIFFWATCH.md: PR description for diffwatch as standalone PR
|
@pastarita is attempting to deploy a commit to the Texture Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Diffwatch is a visual regression capture system for CommonGrid. It automates before/after screenshot generation, region annotation, pixel diffing, side-by-side comparison composition, and alert detection — producing a markdown report and catalog for PR review. Built as dev tooling during the hello-pr UX overhaul to systematically verify 25+ visual changes across 9 pages and 3 viewport tiers.
Change Type
feat— New feature or capabilityfix— Bug fixdocs— Documentation onlychore— Build, CI, dependency, or tooling changesstylerefactortestperfUser-facing change? No — dev tooling only
Breaking change? No
Changeset Overview
featcommitsfixcommitsdocscommitschorecommitsMotivation
The hello-pr branch accumulated 25+ commits touching 9 pages across 3 viewport tiers. We wanted first-class observability of visual changes directly within the PR description — not as a manual appendix, but as an automated, reproducible artifact that an agent or developer can generate on demand.
Diffwatch applies established visual regression analysis methods — before/after capture, pixel diffing, annotated comparison composition — in an agent-first paradigm where the default workflow is automated capture rather than manual screenshotting. The pipeline is manifest-driven: define targets (routes, regions, viewports), and Diffwatch handles the full cycle — parallel dev servers via git worktree isolation, headless Chromium capture, region annotation, pixel diff quantification, side-by-side composition, error indicator detection, and markdown report generation.
Design Decisions
node-canvasbuildArchitecture & Dependency
graph TD subgraph "Configuration" MANIFEST[capture-manifest.json<br>routes, regions, viewports] ROUTEMAP[file-route-map.json<br>source file → route mapping] end subgraph "Pipeline" ORCH[capture-vr.ts<br>orchestrator + CLI] PW[playwright-capture.ts<br>Chromium automation] ANN[annotate.ts<br>Sharp SVG bounding boxes] DIFF[diff.ts<br>pixelmatch pixel diff] COMP[compose.ts<br>side-by-side composition] ALERT[detect-alerts.ts<br>red pill corner scanner] end subgraph "Lifecycle" CLEAN[clean.ts<br>safe clear + run-log ledger] end subgraph "Output" CAPS[captures/<br>before · after · annotated<br>comparisons · diffs] CAT[catalog.json] RPT[pr-screenshots.md] LOG[run-log.jsonl] end MANIFEST --> ORCH ORCH --> PW --> CAPS ORCH --> ANN --> CAPS ORCH --> DIFF --> CAPS ORCH --> COMP --> CAPS ORCH --> ALERT ORCH --> CAT & RPT CLEAN --> LOG style ORCH fill:#fef08a,stroke:#a16207,color:#713f12 style ALERT fill:#fecaca,stroke:#b91c1c,color:#7f1d1d style MANIFEST fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f style CLEAN fill:#e0e7ff,stroke:#4338ca,color:#312e81Execution Flow
flowchart LR CLI[CLI args] --> PRE[Prebuild<br>+ port check] PRE --> SRV[Start servers<br>PR:4101 Base:4100] SRV --> CAP[Playwright<br>capture loop] CAP --> KILL[Kill servers<br>remove worktree] KILL --> ANN[Annotate<br>+ diff] ANN --> SCAN[Alert<br>scan] SCAN --> OUT[Compose<br>+ report] style CLI fill:#f8fafc,stroke:#64748b,color:#1e293b style SRV fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f style CAP fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f style KILL fill:#fecaca,stroke:#b91c1c,color:#7f1d1d style SCAN fill:#fef08a,stroke:#a16207,color:#713f12 style OUT fill:#bbf7d0,stroke:#15803d,color:#14532dRisk Assessment
Commit Log
2622431ca3ae6bf1175663494749ffecf2f534f46dCommit Clustering by Shared File
capture-vr.tsvisual-regression-system.mdcapture-manifest.jsonFile Impact Matrix
scripts/visual-regression/capture-vr.tsscripts/visual-regression/playwright-capture.tsscripts/visual-regression/annotate.tsscripts/visual-regression/compose.tsscripts/visual-regression/diff.tsscripts/visual-regression/detect-alerts.tsscripts/visual-regression/clean.tsscripts/visual-regression/capture-manifest.jsonscripts/visual-regression/file-route-map.jsondocs/visual-regression-system.mdpackage.json.gitignoreChangelog
Added
npm run vr:capture— full before/after screenshot pipeline via git worktree + parallel dev serversnpm run vr:capture:pr-only— PR-only mode (skip base worktree)npm run vr:clean— safe output clear with run-log archivalnpm run vr:clean:all— full clear including run-log--base-ref,--captures,--viewports,--skip-capture,--skip-base,--skip-compose,--outputScreenshots / Recordings
Diffwatch is dev tooling — no user-facing screenshots. Example outputs from the hello-pr run:
Example Comparison Output
Side-by-side composition: title bar with description and viewport, BEFORE | AFTER panels, footer with branch labels.
Example Alert Detection
Red pill indicator (Next.js "1 Issue") detected in bottom-left corner of sort-chevrons capture.
Reviewer Checklist
.envvalues committedscripts/visual-regression/ordocs/.visual-regression/is in.gitignorenpm run vr:captureruns to completionnpm run vr:cleanarchives metadata and clears outputdocs/visual-regression-system.mdmatches implementationTest Plan
Automated
npm run vr:capturecompletes without errors (full pipeline)npm run vr:capture -- --captures badge-variants --viewports desktop(filtered run)npm run vr:capture -- --skip-capture(reprocess existing screenshots)npm run vr:clean(archive + clear)npm run vr:clean -- --dry-run(preview without deleting)Manual
Deferred Work