snapdrift 0.10.0 → 0.12.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,93 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.0 - 2026-09-16
4
+
5
+ ### Fixes
6
+
7
+ - **PR comments no longer render `[object Object]` for a viewport.** A viewport is
8
+ either a preset name or a `{ width, height }` object, and the PR-comment renderer
9
+ stringified it directly. Hosted diff runs always build the object form, so every
10
+ hosted report printed the useless placeholder in its Error, Drift signals, and
11
+ Dimension shifts tables. All three report renderers now share one
12
+ `formatViewport` helper (exported from `@snapdrift/adapter-report-md`).
13
+
14
+ ### Features
15
+
16
+ - **`compareImages` accepts a per-call `maxPixels` union-canvas ceiling.**
17
+ `MAX_COMPARISON_PIXELS` (32 Mi) is a *process memory* bound, not an algorithm
18
+ property, so callers with a larger envelope — a dedicated diff Lambda — can raise
19
+ it while callers sharing a small host keep the default. A missing, non-positive,
20
+ or non-finite value falls back to the default, so the guard cannot be removed by
21
+ accident. The `ComparisonTooLargeError` message now reports the ceiling that was
22
+ actually exceeded.
23
+
24
+ ### Documentation
25
+
26
+ - Document that `migrate-baselines --to snap` is unsupported and point to
27
+ `snapdrift baseline` as the supported way to seed a hosted project. The
28
+ integration guide still described the retired upload direction as a working
29
+ one-shot command, and the contracts reference documented its request body,
30
+ idempotency, and storage behavior as if it succeeded. Both contradicted the
31
+ CLI, which has failed the direction since 0.7.0 with a pointer to
32
+ `snapdrift baseline`.
33
+ - Document the screenshot size budget's memory cost for `maxPixels` callers: the
34
+ comparison retains both decoded RGBA inputs plus the optional diff canvas, so the
35
+ floor is roughly 12 bytes per union pixel before PNG overhead (~32-35 measured end
36
+ to end), and the ceiling should be sized against a measured peak rather than that
37
+ arithmetic.
38
+
39
+ ### Workspace packages
40
+
41
+ - `@snapdrift/adapter-report-md` 1.2.1 publishes the `[object Object]` viewport fix;
42
+ `@snapdrift/compare-core` 1.3.0 publishes the per-call `maxPixels` option and the
43
+ new size-budget guidance.
44
+ - The root package's dependency floors move to `^1.2.1` (adapter-report-md) and
45
+ `^1.3.0` (compare-core) so `snapdrift` 0.12.0 actually requires those fixes. A
46
+ retained lockfile resolution of adapter-report-md 1.2.0 still satisfies `^1.2.0`,
47
+ so without the floor bump an upgrade of `snapdrift` alone could install the
48
+ unfixed report renderer.
49
+
50
+ ## 0.11.0 - 2026-09-14
51
+
52
+ ### Behavior changes
53
+
54
+ - **Local comparisons now always use comparison policy v1.** `generateDriftReport`
55
+ synthesizes `{ "version": 1, "threshold": diff.threshold }` when neither the
56
+ caller nor `diff.comparisonPolicy` supplies a policy, matching the CLI and both
57
+ providers. Dimension mismatches are now `changed[]` signals with union-canvas
58
+ metadata instead of `dimensionChanges[]` (which stays in the summary contract
59
+ but is empty for local comparisons). The strict same-dimension comparator
60
+ remains available to direct `@snapdrift/compare-core` / `comparePngs` callers
61
+ that pass no policy.
62
+
63
+ ### Performance
64
+
65
+ - `compareImages` short-circuits byte-identical buffers and can skip rendering
66
+ the diff PNG via `renderDiffImage: false`; drift reports only render diff
67
+ images for changed routes and resolve/read route PNGs concurrently.
68
+ - Union-canvas size limits are now checked against the PNG IHDR header before
69
+ decoding, so oversized images are rejected before allocating decoded buffers.
70
+
71
+ ### Fixes
72
+
73
+ - `compareImages`, `generateDiffImage`, and `compareWithIgnoreRegions` now reject
74
+ malformed ignore regions and highlight colors instead of silently masking
75
+ nothing or coercing `undefined` channels.
76
+
77
+ ### Features
78
+
79
+ - **Workspace packages** — publish `@snapdrift/compare-core` 1.2.0 and
80
+ `@snapdrift/adapter-fs` 1.3.0 with the new comparison options, validation, and
81
+ performance behavior. The new `renderDiffImage: false` option is surfaced
82
+ through a separate overload, so existing `compareImages` / `comparePngs`
83
+ callers keep a non-optional `diffImageBuffer` with no type or runtime change.
84
+
85
+ ### Documentation
86
+
87
+ - Document the full-page screenshot pixel budget, viewport/device-scale
88
+ estimates, custom-viewport semantics, and remediation for
89
+ `comparison_too_large` failures.
90
+
3
91
  ## 0.10.0 - 2026-09-10
4
92
 
5
93
  ### Fixes
package/README.md CHANGED
@@ -48,7 +48,7 @@ You keep ownership of checkout, build, startup, readiness, and teardown. SnapDri
48
48
 
49
49
  ```yaml
50
50
  - name: SnapDrift Baseline
51
- uses: ranacseruet/snapdrift@v0.10.0
51
+ uses: ranacseruet/snapdrift@v0.12.0
52
52
  with:
53
53
  mode: baseline
54
54
  repo-config-path: .github/snapdrift.json
@@ -60,7 +60,7 @@ With `provider: "snap"`, baseline publication is a complete, fail-closed snapsho
60
60
 
61
61
  ```yaml
62
62
  - name: SnapDrift Report
63
- uses: ranacseruet/snapdrift@v0.10.0
63
+ uses: ranacseruet/snapdrift@v0.12.0
64
64
  with:
65
65
  mode: pr-diff
66
66
  github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -107,7 +107,7 @@ Start with `report-only` while baselines settle. Move to `fail-on-changes` or st
107
107
  |------|--------------------|
108
108
  | `report-only` | Never |
109
109
  | `fail-on-changes` | Any capture exceeds threshold |
110
- | `fail-on-incomplete` | Captures are missing, dimensions shift, or comparison errors occur |
110
+ | `fail-on-incomplete` | Captures are missing or comparison errors occur |
111
111
  | `strict` | Any drift signal or incomplete comparison appears |
112
112
 
113
113
  ## Current constraints
@@ -115,8 +115,9 @@ Start with `report-only` while baselines settle. Move to `fail-on-changes` or st
115
115
  - Ubuntu runners only (local CLI works on any OS Node 22+ supports)
116
116
  - Full-page capture only
117
117
  - Viewport presets: `desktop` (1440×900) and `mobile` (390×844), or custom `{ "width": number, "height": number }`
118
+ - Full-page comparisons are bounded to a 32 Mi-pixel union canvas; see the [screenshot size budget](docs/contracts.md#screenshot-size-budget) for viewport, device-scale, and remediation guidance
118
119
  - One global `diff.threshold`
119
- - Unequal dimensions remain strict by default; local updated clients may opt in with `diff.comparisonPolicy: { "version": 1, "threshold": number }`
120
+ - Unequal dimensions compare on a top-left-aligned union canvas via comparison policy v1, which is always applied (synthesized from `diff.threshold` when `diff.comparisonPolicy` is absent)
120
121
  - Local provider writes artifacts to the runner filesystem; for a hosted backend with a dashboard and a shared baseline store, configure `provider: "snap"` (see the [Integration Guide](docs/integration-guide.md#hosted-snap-provider))
121
122
  - Hosted Snap baselines publish only from the default branch and always include the complete configured route set
122
123
 
package/action.yml CHANGED
@@ -155,7 +155,7 @@ runs:
155
155
  - name: SnapDrift baseline
156
156
  id: baseline
157
157
  if: inputs.mode == 'baseline'
158
- uses: ranacseruet/snapdrift/actions/baseline@80d61b668942dd87c33cf51598623a904becf82f # v0.10.0
158
+ uses: ranacseruet/snapdrift/actions/baseline@e4b92c2243c6e69594cab7405f68eb58fe94587e # v0.12.0
159
159
  with:
160
160
  repo-config-path: ${{ inputs.repo-config-path }}
161
161
  route-ids: ${{ inputs.route-ids }}
@@ -165,7 +165,7 @@ runs:
165
165
  - name: SnapDrift pull request diff
166
166
  id: pr-diff
167
167
  if: inputs.mode == 'pr-diff'
168
- uses: ranacseruet/snapdrift/actions/pr-diff@80d61b668942dd87c33cf51598623a904becf82f # v0.10.0
168
+ uses: ranacseruet/snapdrift/actions/pr-diff@e4b92c2243c6e69594cab7405f68eb58fe94587e # v0.12.0
169
169
  with:
170
170
  github-token: ${{ inputs.github-token }}
171
171
  repo-config-path: ${{ inputs.repo-config-path }}
package/docs/contracts.md CHANGED
@@ -40,7 +40,7 @@ SnapDrift reads runtime behavior from `.github/snapdrift.json` by default.
40
40
  | `snap.apiKey` | `string` | Inline API key with `${VAR}` interpolation (mutually exclusive with `snap.apiKeyEnv`) |
41
41
  | `snap.projectId` | `string` | Snap project ID or `"auto"` (default: `"auto"`, derives from `GITHUB_REPOSITORY`) |
42
42
  | `snap.onUnavailable` | `string` | Behavior when Snap is unreachable: `"fail"` (default), `"warn-and-skip"`, or `"fallback-local"` |
43
- | `diff.comparisonPolicy` | `{ "version": 1, "threshold": number }` | Optional local opt-in to top-left-aligned unequal-dimension comparison; absent preserves strict legacy dimension handling |
43
+ | `diff.comparisonPolicy` | `{ "version": 1, "threshold": number }` | Accepted for compatibility; comparison policy v1 is always applied when absent. `threshold` must match `diff.threshold` |
44
44
 
45
45
  When `provider: "snap"` is set, the `snap` block is required. Exactly one of `snap.apiKeyEnv` or `snap.apiKey` must be present. `snap.apiKey` accepts `${VAR}` interpolation (for example `"${SNAP_API_KEY}"`); the referenced environment variable must be set at runtime or the config loader throws.
46
46
 
@@ -210,9 +210,9 @@ The pull request drift bundle contains:
210
210
  | Field | Type | Description |
211
211
  |:------|:-----|:------------|
212
212
  | `dashboardUrl` | `string?` | Snap dashboard URL for the run (set by `SnapProvider`; omitted by `LocalProvider`) |
213
- | `comparisonPolicy` | `{ "version": 1, "threshold": number }?` | Exact v1 comparison policy used by the local adapter when opted in |
213
+ | `comparisonPolicy` | `{ "version": 1, "threshold": number }?` | Effective v1 comparison policy used by the local adapter (synthesized from `diff.threshold` when not configured) |
214
214
 
215
- When v1 comparison is enabled, each affected `changed[]` item may also contain
215
+ When v1 comparison is applied, each affected `changed[]` item may also contain
216
216
  `comparison` with `baseline`, `current`, and `canvas` `{ width, height }`
217
217
  objects, `dimensionsChanged`, and the effective `totalPixels` denominator. A
218
218
  local changed item with a generated image contains `diffImagePath`, relative to
@@ -229,7 +229,7 @@ path as a GitHub-hosted image URL.
229
229
  |:-------|:--------|
230
230
  | `clean` | All captures matched within threshold |
231
231
  | `changes-detected` | One or more captures exceeded threshold |
232
- | `incomplete` | Missing captures, dimension shifts, or comparison errors occurred |
232
+ | `incomplete` | Missing captures or comparison errors occurred |
233
233
  | `skipped` | The report was intentionally skipped |
234
234
 
235
235
  ### Skipped summary
@@ -251,9 +251,9 @@ Additional missing-baseline fields: `baselineAvailable`, `currentResultsPath`.
251
251
  - Mismatch ratio is `different_pixels / total_pixels`
252
252
  - `diff.threshold` applies per screenshot
253
253
  - Missing captures are counted separately from drift signals
254
- - Without `diff.comparisonPolicy`, dimension mismatches skip pixel comparison and land in `dimensionChanges[]`.
255
- - With the exact v1 policy `{ "version": 1, "threshold": number }`, images are top-left aligned on a max-dimension union canvas with no scaling. Overlap pixels are compared, one-sided pixels count as changed (including transparent pixels), and empty union corners do not enter the denominator. Dimension changes land in `changed[]` with comparison metadata and a generated local diff image.
256
- - For v1, `diff.comparisonPolicy.threshold` is applied after pixel aggregation. A mismatch exactly equal to the threshold is matched; a dimension change is still a changed signal independent of ratio.
254
+ - Comparison policy v1 `{ "version": 1, "threshold": number }` is always applied. When `diff.comparisonPolicy` is absent, SnapDrift synthesizes it from `diff.threshold`. Images are top-left aligned on a max-dimension union canvas with no scaling. Overlap pixels are compared, one-sided pixels count as changed (including transparent pixels), and empty union corners do not enter the denominator. Dimension changes land in `changed[]` with comparison metadata and a generated local diff image.
255
+ - `dimensionChanges[]` remains part of the summary contract but is empty for local comparisons in v1. Strict same-dimension comparison (`compareBuffers`) remains available to direct `@snapdrift/compare-core`/`comparePngs` callers that pass no policy.
256
+ - Threshold is applied after pixel aggregation. A mismatch exactly equal to the threshold is matched; a dimension change is still a changed signal independent of ratio.
257
257
  - `diff.mode` controls enforcement, not summary generation
258
258
 
259
259
  ## Drift modes
@@ -278,6 +278,67 @@ directly, not just for the guarded enforcement step inside `actions/pr-diff`.
278
278
  | `desktop` | 1440 | 900 | 1 | No | No |
279
279
  | `mobile` | 390 | 844 | 3 | Yes | Yes |
280
280
 
281
+ ## Screenshot size budget
282
+
283
+ SnapDrift compares full-page screenshots using their rendered raster dimensions.
284
+ The unequal-dimension comparator bounds the union canvas at `32 × 1024 × 1024`
285
+ pixels (`33,554,432` pixels). A comparison is oversized when:
286
+
287
+ ```text
288
+ max(baselineWidth, currentWidth) × max(baselineHeight, currentHeight) > 33,554,432
289
+ ```
290
+
291
+ This is a raster-pixel limit, not a direct CSS viewport limit. Full-page capture
292
+ height is the document height, and `deviceScaleFactor` increases both raster
293
+ width and raster height. The baseline/current union also means that a dimension
294
+ change can make an otherwise valid image exceed the budget. Leave headroom for
295
+ horizontal overflow or other layout changes that increase the rendered image
296
+ dimensions.
297
+
298
+ The comparator reports this condition with the stable error code
299
+ `comparison_too_large` and includes the baseline, current, and union-canvas
300
+ dimensions in the error message. The ceiling that was exceeded is included too,
301
+ since a caller may raise it per call.
302
+
303
+ `32 × 1024 × 1024` is the *default* ceiling, not an algorithm property. The cost
304
+ is dominated by the decoded images: both RGBA inputs (4 bytes per pixel each) are
305
+ retained plus, when the diff image is rendered (the default), a union-sized diff
306
+ canvas — at least ~12 bytes per union pixel when both inputs approach the union
307
+ dimensions, before PNG decode/encode overhead. Measured end-to-end RSS on real
308
+ full-page captures is ~32-35 bytes per union pixel (~1.16 GB at 33.8 M pixels,
309
+ ~3.37 GB at 103.9 M), so the default bounds a comparison to a process with a few
310
+ GB of headroom.
311
+
312
+ Direct `@snapdrift/compare-core` callers running in a larger memory envelope can
313
+ pass `compareImages(..., { maxPixels })` to raise it for that call. **Size
314
+ `maxPixels` against your own measured peak**, not against the byte-per-pixel
315
+ arithmetic: PNG decode and encode overhead, GC, and concurrency all add to it. A
316
+ missing, non-finite, or sub-1 `maxPixels` falls back to the default; fractions are
317
+ floored (`16.9` becomes `16`). The sub-1 rule matters because a positive fraction
318
+ such as `0.5` floors to `0`, which would otherwise reject every comparison.
319
+ SnapDrift's own local and hosted paths keep the default, because the host process
320
+ — not the image — decides how much memory is actually safe.
321
+
322
+ Approximate maximum full-page CSS heights below
323
+ assume that the raster width remains equal to the configured CSS width and that
324
+ the document height scales by the same device scale factor:
325
+
326
+ | Configuration | CSS viewport | Scale factor | Approx. maximum full-page CSS height |
327
+ |:--------------|:-------------|-------------:|-------------------------------------:|
328
+ | `desktop` preset | 1440 × 900 | 1 | 23,301 px |
329
+ | `mobile` preset | 390 × 844 | 3 | 9,559 px |
330
+ | Custom 390 × 844 viewport | 390 × 844 | 1 | 86,037 px |
331
+
332
+ These are planning estimates, not guarantees. Check the actual `width` and
333
+ `height` recorded in the capture results or screenshot manifest, then apply the
334
+ union-canvas formula above. A custom viewport object currently uses scale factor
335
+ 1 with `isMobile: false` and `hasTouch: false`; it is therefore not equivalent
336
+ to the named `mobile` preset. Use it to avoid unnecessary raster inflation only
337
+ when the route does not require mobile device emulation. Otherwise, reduce the
338
+ captured document or fixture height, or split the coverage across routes when
339
+ that matches the product behavior. Do not resize or crop screenshots, or lower
340
+ `diff.threshold`, to work around this limit.
341
+
281
342
  ## Capture defaults
282
343
 
283
344
  | Setting | Value |
@@ -314,18 +375,16 @@ All three directories can be overridden with `--baseline-dir`, `--current-dir`,
314
375
 
315
376
  ### migrate-baselines
316
377
 
317
- Migrate baselines between local storage and Snap. Both directions require a `snap` block in `snapdrift.json` (or `--to local` for the `snap → local` direction, since the export call still talks to Snap first).
378
+ Move baselines between local storage and Snap. Only the `snap → local` direction is supported; it requires a `snap` block in `snapdrift.json` (the export call talks to Snap).
318
379
 
319
- **Upload local baselines to Snap:**
380
+ **Upload local baselines to Snap — not supported:**
320
381
 
321
382
  ```
322
- snapdrift migrate-baselines --to snap [--config <path>] [--baseline-dir <dir>]
383
+ snapdrift migrate-baselines --to snap # always fails
323
384
  ```
324
385
 
325
- - Reads `results.json`, `manifest.json`, and `screenshots/*.png` from the local baseline directory.
326
- - Uploads as the initial accepted baseline on Snap via `POST /v1/visual/projects/:id/baselines`.
327
- - Idempotent: if a baseline already exists for the same commit SHA (derived from `GITHUB_SHA` or `git rev-parse HEAD`), the upload is skipped.
328
- - Screenshots are base64-encoded in the request body; very large suites may want to migrate per-route.
386
+ - The command exits with an error. Snap cannot accept a pre-built local baseline bundle: the screenshots it carries are never uploaded to Snap storage, and its manifest references local filenames rather than Snap object keys, so the call could only ever create a baseline with no pixels behind it. Snap rejects the request with `400 unsupported_baseline_body` (i2Dev-com/snap#653); the legacy `SnapProvider.migrateBaselineFromLocal()` path was removed in 0.7.0.
387
+ - **Use `snapdrift baseline` instead** — with `provider: "snap"` it captures each route through Snap so the images actually land in storage, then publishes a baseline referencing the stored objects. Canonical hosted publication is CI-only (default-branch job); see [`snapdrift baseline`](local-cli.md#snapdrift-baseline).
329
388
 
330
389
  **Download Snap baselines to local:**
331
390
 
@@ -46,7 +46,7 @@ SnapDrift owns route selection, capture, comparison, skipped-report generation,
46
46
 
47
47
  ```yaml
48
48
  - name: SnapDrift Baseline
49
- uses: ranacseruet/snapdrift@v0.10.0
49
+ uses: ranacseruet/snapdrift@v0.12.0
50
50
  with:
51
51
  mode: baseline
52
52
  repo-config-path: .github/snapdrift.json
@@ -71,7 +71,7 @@ Then add SnapDrift after the app is running:
71
71
 
72
72
  ```yaml
73
73
  - name: SnapDrift Report
74
- uses: ranacseruet/snapdrift@v0.10.0
74
+ uses: ranacseruet/snapdrift@v0.12.0
75
75
  with:
76
76
  mode: pr-diff
77
77
  github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -86,8 +86,8 @@ The wrappers remain published in their own right, and are equivalent to the disp
86
86
 
87
87
  | Entry point | Equivalent to |
88
88
  |-------------|---------------|
89
- | `ranacseruet/snapdrift@v0.10.0` with `mode: baseline` | `ranacseruet/snapdrift/actions/baseline@v0.10.0` |
90
- | `ranacseruet/snapdrift@v0.10.0` with `mode: pr-diff` | `ranacseruet/snapdrift/actions/pr-diff@v0.10.0` |
89
+ | `ranacseruet/snapdrift@v0.12.0` with `mode: baseline` | `ranacseruet/snapdrift/actions/baseline@v0.12.0` |
90
+ | `ranacseruet/snapdrift@v0.12.0` with `mode: pr-diff` | `ranacseruet/snapdrift/actions/pr-diff@v0.12.0` |
91
91
 
92
92
  Use the wrappers directly when you want to skip the dispatcher's input indirection, and the lower-level `capture`, `compare`, `scope`, `resolve-baseline`, `stage`, `comment`, and `enforce` actions when you need to orchestrate the stages yourself.
93
93
 
@@ -130,7 +130,7 @@ jobs:
130
130
  done
131
131
 
132
132
  - name: SnapDrift Report
133
- uses: ranacseruet/snapdrift@v0.10.0
133
+ uses: ranacseruet/snapdrift@v0.12.0
134
134
  with:
135
135
  mode: pr-diff
136
136
  github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -170,7 +170,7 @@ jobs:
170
170
  done
171
171
 
172
172
  - name: SnapDrift Report
173
- uses: ranacseruet/snapdrift@v0.10.0
173
+ uses: ranacseruet/snapdrift@v0.12.0
174
174
  with:
175
175
  mode: pr-diff
176
176
  github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -249,10 +249,11 @@ When `provider: "snap"` and `baseUrl` points to a local address (localhost, `127
249
249
 
250
250
  With the Snap provider, the PR comment includes a **"View in dashboard →"** link that points to `${apiUrl}/dashboard/visual/${projectId}/runs/${runId}`. The local provider omits the link.
251
251
 
252
- Migrating an existing local repo to the Snap provider is a one-shot CLI command:
252
+ To adopt the hosted provider, seed the project with a hosted baseline. `migrate-baselines --to snap` is **not** the way to do it — Snap cannot accept a pre-built local baseline bundle, because the screenshots it carries are never uploaded to Snap storage and its manifest references local filenames rather than Snap object keys. Use `snapdrift baseline` with `provider: "snap"` instead: it captures each route through Snap so the pixels actually land in storage before the baseline manifest is published. Canonical hosted publication is CI-only — run it from your default-branch job, where GitHub Actions supplies the publication metadata automatically (other CI systems set `SNAPDRIFT_PUBLICATION_WORKFLOW_REF` and `SNAPDRIFT_PUBLICATION_SEQUENCE`); a plain local checkout fails before creating a hosted run.
253
253
 
254
254
  ```bash
255
- snapdrift migrate-baselines --to snap
255
+ # In CI, on the default branch, with provider: "snap"
256
+ snapdrift baseline
256
257
  ```
257
258
 
258
259
  Conversely, downloading a Snap baseline back to a local directory (useful for reproducible local debugging) is:
@@ -297,9 +298,6 @@ snapdrift capture
297
298
  # After making changes, compare and open the HTML report
298
299
  snapdrift diff --open
299
300
 
300
- # Migrate an established local baseline to the hosted Snap backend
301
- snapdrift migrate-baselines --to snap
302
-
303
301
  # Translate a snap/github-action workflow into snapdrift.json
304
302
  snapdrift init --from-snap-action .github/workflows/snap.yml
305
303
  ```
@@ -311,11 +309,10 @@ See the [Local CLI guide](local-cli.md) for full command reference, flags, direc
311
309
  ## Refresh the baseline automatically
312
310
 
313
311
  After an intentional layout change merges, the baseline can be republished as
314
- usual. Legacy local comparisons still require like-for-like dimensions; an
315
- updated local client may opt into the exact
316
- `diff.comparisonPolicy: { "version": 1, "threshold": number }` contract to
317
- compare unequal frames on a union canvas and keep the dimension metadata in the
318
- report.
312
+ usual. Local comparisons always apply comparison policy v1
313
+ (`{ "version": 1, "threshold": number }`) — synthesized from `diff.threshold`
314
+ when not configured — so unequal frames are compared on a union canvas and
315
+ dimension metadata stays in the report.
319
316
 
320
317
  Use the provided workflow template to refresh the baseline automatically on every push to your default branch (i.e. every merge):
321
318
 
@@ -343,15 +340,31 @@ Grant `issues: write` and `pull-requests: write` to the job.
343
340
  The Snap client never retries 4xx and never falls back, even when `onUnavailable` is set. Inspect the response body — the most common cause is a project-id mismatch between `GITHUB_REPOSITORY` (auto-derived) and the project's id on Snap.
344
341
 
345
342
  **Screenshots have different dimensions**
346
- Without `diff.comparisonPolicy`, SnapDrift reports this as a legacy dimension
347
- shift and skips pixel comparison. With the exact v1 policy, it compares the
348
- top-left-aligned union canvas, records the route in `changed[]`, and writes a
349
- local diff PNG; refresh the baseline after an intentional change when you want
350
- future runs to return to equal-size comparisons.
343
+ SnapDrift compares the top-left-aligned union canvas, records the route in
344
+ `changed[]`, and writes a local diff PNG. Refresh the baseline after an
345
+ intentional change when you want future runs to return to equal-size
346
+ comparisons.
351
347
 
352
348
  **A route appears in `errors[]`**
353
349
  Capture failed before comparison. Confirm the app is fully ready and reachable before SnapDrift runs.
354
350
 
351
+ **`comparison_too_large` or `union canvas ... exceeds the maximum`**
352
+
353
+ The baseline/current screenshot union is larger than the 33,554,432-pixel
354
+ comparison budget. Because captures are full-page, a short configured viewport
355
+ can still produce an oversized image when the document is tall; the named
356
+ `mobile` preset also renders at device scale factor 3. Inspect the actual image
357
+ dimensions in the capture results or manifest and calculate
358
+ `max(baselineWidth, currentWidth) × max(baselineHeight, currentHeight)`.
359
+
360
+ If the route does not need mobile device emulation, a custom viewport object uses
361
+ scale factor 1 and can avoid unnecessary raster inflation. Otherwise reduce the
362
+ captured content or fixture height, or split the coverage across routes when
363
+ appropriate. Do not resize/crop images or lower `diff.threshold`; neither changes
364
+ the capture budget and either can hide a layout regression. See the [screenshot
365
+ size budget](contracts.md#screenshot-size-budget) for the preset estimates and
366
+ custom-viewport semantics.
367
+
355
368
  **Playwright install runs even though `provider: "snap"`**
356
369
  That's expected for the Snap local-capture hybrid. Playwright runs locally to render the page, then the resulting screenshot is uploaded to Snap. The hybrid kicks in only when `baseUrl` points to a local address; for remote `baseUrl` Snap's render worker captures directly.
357
370
 
package/docs/local-cli.md CHANGED
@@ -225,7 +225,7 @@ After running `capture` and `diff` with default paths:
225
225
  summary.json # structured drift summary
226
226
  summary.md # human-readable markdown report
227
227
  report.html # self-contained HTML report with side-by-side images
228
- diffs/ # v1 generated diff PNGs, when comparisonPolicy is enabled
228
+ diffs/ # generated diff PNGs for changed routes
229
229
  ```
230
230
 
231
231
  Add `.snapdrift/` to your `.gitignore` to keep local run output out of version control.
@@ -272,7 +272,7 @@ Comparing against baseline ...
272
272
  Report: .snapdrift/diff/report.html
273
273
  ```
274
274
 
275
- **Incomplete run** (errors, missing captures, or legacy dimension shifts):
275
+ **Incomplete run** (errors or missing captures):
276
276
 
277
277
  ```
278
278
  ❌ SnapDrift — incomplete
@@ -281,7 +281,7 @@ Report: .snapdrift/diff/report.html
281
281
  Changed: 0
282
282
  Missing: 1
283
283
  Errors: 1
284
- Dim diff: 1
284
+ Dim diff: 0
285
285
 
286
286
  Report: .snapdrift/diff/report.html
287
287
  ```
@@ -290,14 +290,15 @@ The `Missing`, `Errors`, and `Dim diff` lines only print when their count is gre
290
290
 
291
291
  The `report.html` path is printed whenever the status is anything other than `clean`; pass `--open` to also launch it in your default browser.
292
292
 
293
- To compare unequal local screenshot dimensions, add the exact opt-in policy to
294
- `diff`:
293
+ SnapDrift always applies comparison policy v1. It synthesizes the policy from
294
+ `diff.threshold` when `diff` does not declare one, so the explicit opt-in is only
295
+ needed to pin a non-default threshold:
295
296
 
296
297
  ```json
297
298
  "comparisonPolicy": { "version": 1, "threshold": 0.01 }
298
299
  ```
299
300
 
300
- The v1 report includes the baseline, current, and union-canvas dimensions in
301
+ The report includes the baseline, current, and union-canvas dimensions in
301
302
  `summary.md` and `report.html`, and stores changed-route diff PNGs under
302
303
  `.snapdrift/diff/diffs/`. A completed dimension comparison is a normal changed
303
304
  signal, so `fail-on-incomplete` does not fail solely because its dimensions
@@ -309,7 +310,7 @@ differ; `fail-on-changes` and `strict` still enforce it.
309
310
 
310
311
  | Variable | Applies to | Description |
311
312
  |:---------|:-----------|:------------|
312
- | `SNAPDRIFT_CAPTURE_CONCURRENCY` | `capture`, `diff` | Max concurrent route captures per viewport context (positive integer, default `5`). Set to `1` to restore serial behavior for apps with shared session or auth state. |
313
+ | `SNAPDRIFT_CAPTURE_CONCURRENCY` | `capture`, `diff` | Max concurrent route operations (positive integer, default `5`): route captures per viewport context, and per-route resolve/compare during `diff`. Set to `1` to restore serial behavior for apps with shared session or auth state. |
313
314
  | `SNAPDRIFT_CONFIG_PATH` | `capture`, `diff`, `migrate-baselines` | Override the config file path. Equivalent to `--config`. |
314
315
  | `SNAPDRIFT_ROUTE_IDS` | `capture`, `baseline`, `diff` | Comma-separated route ids to scope to. Equivalent to `--routes`; it may not reduce a hosted baseline's complete route set. |
315
316
 
@@ -82,7 +82,7 @@ jobs:
82
82
 
83
83
  - name: Publish SnapDrift baseline
84
84
  if: steps.baseline_candidate.outputs.current == 'true'
85
- uses: ranacseruet/snapdrift@v0.10.0
85
+ uses: ranacseruet/snapdrift@v0.12.0
86
86
  with:
87
87
  mode: baseline
88
88
  repo-config-path: .github/snapdrift.json
package/lib/provider.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // @ts-check
2
2
 
3
- import { loadSnapdriftConfig, runBaselineCapture, generateDriftReport, stageArtifacts } from '@snapdrift/adapter-fs';
3
+ import { runBaselineCapture, generateDriftReport, stageArtifacts } from '@snapdrift/adapter-fs';
4
4
  import { buildReportCommentBody } from '@snapdrift/adapter-report-md';
5
5
  import {
6
6
  SnapProvider,
@@ -43,12 +43,7 @@ export class LocalProvider {
43
43
  * @returns {Promise<DiffResult>}
44
44
  */
45
45
  async diff(options) {
46
- const { config } = await loadSnapdriftConfig(options.configPath);
47
- const comparisonPolicy = config.diff.comparisonPolicy ?? {
48
- version: 1,
49
- threshold: config.diff.threshold
50
- };
51
- return generateDriftReport({ ...options, comparisonPolicy });
46
+ return generateDriftReport(options);
52
47
  }
53
48
 
54
49
  /**
@@ -46,7 +46,6 @@ const BINARY_REQUEST_TIMEOUT_MS = 120 * 1000;
46
46
  const POLL_INTERVAL_MS = 2000;
47
47
  const MAX_OPERATION_DURATION_MS = 10 * 60 * 1000;
48
48
  const MAX_STABLE_INCOMPLETE_POLLS = 30;
49
- const MAX_COMPARISON_PIXELS = 32 * 1024 * 1024;
50
49
  const BASELINE_RUN_SUCCESS_STATUS = 'new';
51
50
  const BASELINE_CAPTURE_SUCCESS_STATUS = 'new';
52
51
  const TERMINAL_CAPTURE_STATUSES = new Set(['new', 'diffed', 'error']);
@@ -178,8 +177,7 @@ function isComparisonMetadata(value) {
178
177
  canvas.height === Math.max(baseline.height, current.height) &&
179
178
  Number.isInteger(comparison.totalPixels) &&
180
179
  comparison.totalPixels >= 0 &&
181
- comparison.totalPixels <= canvas.width * canvas.height &&
182
- canvas.width * canvas.height <= MAX_COMPARISON_PIXELS
180
+ comparison.totalPixels <= canvas.width * canvas.height
183
181
  );
184
182
  }
185
183
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snapdrift",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "SnapDrift captures, compares, and reports UI drift for Playwright-based app checks.",
@@ -102,9 +102,9 @@
102
102
  "registry": "https://registry.npmjs.org"
103
103
  },
104
104
  "dependencies": {
105
- "@snapdrift/adapter-fs": "^1.2.0",
106
- "@snapdrift/adapter-report-md": "^1.2.0",
107
- "@snapdrift/compare-core": "^1.1.0",
105
+ "@snapdrift/adapter-fs": "^1.3.0",
106
+ "@snapdrift/adapter-report-md": "^1.2.1",
107
+ "@snapdrift/compare-core": "^1.3.0",
108
108
  "@snapdrift/manifest": "^1.4.0",
109
109
  "js-yaml": "^5.4.0",
110
110
  "playwright": "^1.59.1",