Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

fix: keep an app-set zoom out of the version history

Luis Ortiza985c1d584ac
diff --git a/AGENTS.md b/AGENTS.md
index 88f4818..e33c1c5 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -604,6 +604,12 @@ rewrites the steps already captured. It recomputes from `clickPoint` and the fra
already holds, so nothing is re-captured and nothing is lost. A guide therefore stores no zoom of its
own β€” the level lives per screenshot and the control simply rewrites each one.
+Version history does not report a zoom. `snapshot-diff` counts a changed `edits.viewport` as a crop,
+and zoom writes that same field, so re-zooming a guide read back as "3 images cropped" β€” the history
+describing the app's own framing as the user's edit. The diff now counts it only when `zoomLevel` is
+absent on one side or the other, which is exactly when a person set the region. Cropping a step by
+hand still registers, including when it replaces an app-set zoom.
+
Which steps it may touch is `edits.zoomLevel` itself: present means the app chose the region, absent
means a person did. `AnnotationEditor` clears it whenever the crop tool writes a new viewport, so a
hand-cropped step survives every later re-zoom. `rezoomEdits` returns null for those, and for a step
diff --git a/packages/core/src/guides/__tests__/snapshot-diff.test.ts b/packages/core/src/guides/__tests__/snapshot-diff.test.ts
index 110d3dc..9d8837d 100644
--- a/packages/core/src/guides/__tests__/snapshot-diff.test.ts
+++ b/packages/core/src/guides/__tests__/snapshot-diff.test.ts
@@ -208,6 +208,28 @@ describe('diffSnapshots', () => {
expect(diffSnapshots(a, b)).toEqual({ ...empty, cropped: 1 });
});
+ it('does not count a zoom change as cropped', () => {
+ const a = like([step('s1', 'Same', 'sc1')], {
+ screenshots: [shot('sc1', 's1', { zoomLevel: 1, viewport: { x: 0, y: 0, width: 100, height: 50 } })],
+ });
+ const b = like([step('s1', 'Same', 'sc1')], {
+ screenshots: [shot('sc1', 's1', { zoomLevel: 2, viewport: { x: 25, y: 12, width: 50, height: 25 } })],
+ });
+
+ expect(diffSnapshots(a, b)).toEqual(empty);
+ });
+
+ it('counts a hand crop over an app-set zoom as cropped', () => {
+ const a = like([step('s1', 'Same', 'sc1')], {
+ screenshots: [shot('sc1', 's1', { zoomLevel: 1, viewport: { x: 0, y: 0, width: 100, height: 50 } })],
+ });
+ const b = like([step('s1', 'Same', 'sc1')], {
+ screenshots: [shot('sc1', 's1', { viewport: { x: 10, y: 0, width: 80, height: 50 } })],
+ });
+
+ expect(diffSnapshots(a, b)).toEqual({ ...empty, cropped: 1 });
+ });
+
it('does not count an annotation change as cropped', () => {
const a = like([step('s1', 'Same', 'sc1')], {
screenshots: [shot('sc1', 's1', { viewport: { x: 0, y: 0, width: 100, height: 50 }, annotations: [box] })],
diff --git a/packages/core/src/guides/snapshot-diff.ts b/packages/core/src/guides/snapshot-diff.ts
index a25e851..d55b928 100644
--- a/packages/core/src/guides/snapshot-diff.ts
+++ b/packages/core/src/guides/snapshot-diff.ts
@@ -105,7 +105,8 @@ export function diffSnapshots(from: SnapshotLike, to: SnapshotLike): SnapshotDif
const beforeEdits = beforeRow.edits ?? {};
const afterEdits = afterRow.edits ?? {};
- if (differs(beforeEdits.viewport, afterEdits.viewport)) cropped++;
+ const byHand = beforeEdits.zoomLevel === undefined || afterEdits.zoomLevel === undefined;
+ if (byHand && differs(beforeEdits.viewport, afterEdits.viewport)) cropped++;
if (
differs(drawings(beforeEdits), drawings(afterEdits)) ||
differs(resolveTarget(beforeRow), resolveTarget(afterRow))