Repository navigation
fix(cli): snapshot --output clears only the frames it wrote - #6176
Queued
miguel-heygen wants to merge 2 commits into
Queued
miguel-heygen wants to merge 2 commits into
miguel-heygen wants to merge 2 commits into
Conversation
2 of 4 tasks
Contributor
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 1 important · 0 nits · head 35929f40
I checked the pattern against every name the command writes: frame-NN-at-* and at-* (snapshot.ts:907-914), ref-/pair- (:972-974), beat-/seam- and the review sheets (snapshotReview.ts:237-318), and the paged contact-sheet-N.jpg (contactSheet.ts:157). All of them match. CI is green at this head.
- important (follow-up, not gating):
createSnapshotContactSheet(packages/cli/src/capture/contactSheet.ts:222-223) still picks up everyframe-*.pngin the folder. Before this PR, the cleanup had always deleted those. Now a user image likeframe-hero.png, which your own test keeps, survives and ends up as a tile on the newcontact-sheet.jpgthe agent reviews. Filtering there by/^frame-\d+-at-[\d.]+s\.png$/(orSNAPSHOT_IMAGE_NAME) would fix it.
— Genesis
miguel-heygen
added this pull request to the merge queue
Oct 24, 2026
Any commits made after this event will not be merged.
This branch has not been deployed
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.
What
hyperframes snapshot --output <dir>now deletes only the images a snapshot run writes (its frame, review,--againstand contact-sheet names). Every other image in that folder is left alone. Before this change it deleted every.png,.jpgand.jpegin the folder, sohyperframes snapshot . -o assetsor-o .erased the project's own images.Why
Data loss. The cleanup before each run used
/\.(png|jpg|jpeg)$/ion everything in the output folder, and nothing checked that a file had come from an earlier snapshot run. A user who pointed--outputat the project folder or itsassets/folder lost every image in it, with no prompt and nothing in the output to say so.Related work
Builds on the
--keepnaming from #5605. No overlapping open PR.How
One exported pattern,
SNAPSHOT_IMAGE_NAMEinsnapshot.ts, sits next toformatSnapshotTimestampand covers every image name a run writes into its folder:frame-NN-at-Xs.png--keepstillsat-Xs.png--againstreference framesref-[NN-]at-Xs.pngand pair sheetspair-[NN-]at-Xs.jpg--reviewstillsbeat-NN-at-Xs.pngandseam-NN-S-at-Xs.pngcontact-sheet[-N].jpg,review-beats[-N].jpg,review-phone[-N].jpgandreview-seam-NN.jpg--zoomwrites under the same frame names. The cleanup uses this pattern instead of the extension check, so the files it reports asreplacedare exactly the files it deletes.Why a name pattern and not a manifest of what the last run wrote: every name above is fixed by the command, so a pattern needs no extra state. A manifest would add a file the user can delete or edit, and it would miss frames written by versions that never wrote one.
The match is now case-sensitive. The command only writes lowercase names, so
Notes.PNGis a user file.The managed default folder needs no special case. Each run gets a fresh folder, so the run has nothing to clear there.
No new flag and no prompt. Other commands keep the deletes they already do.
Test plan
New tests in
packages/cli/src/commands/snapshot-contactSheet.test.tsdrive the real command through citty'srunCommand, with the browser and server mocked the same way the file's other tests do:--outputcases.--outputpoints atsnapshots/, at the project folder itself, and atassets/. Each folder starts with user images (hero.png,logo.jpg,Notes.PNG,frame-hero.png) and earlier output (default,--keep,--againstand review frames, and paged sheets). After the run, every user image is unchanged, every earlier output file is gone, and the new frames are in place.reviewFramesproduces matches the pattern, so a later--reviewchange that renames its stills fails here.What I ran:
snapshot.tsfrommainand the new tests, the three--outputcases fail withENOENT ... hero.png: the user's image was deleted.snapshot-contactSheet.test.ts,snapshot.test.tsandsnapshotReview.test.tspassed 3 runs in a row (100 tests each run).What I did not exercise: a real browser capture,
--review,--againstor--zoomrun end to end (their names are checked against the pattern, not captured), and Windows.Size: under the 100-line floor on purpose, a lone urgent data-loss fix with no open PR of this lane to fold into.