fix(screenshots): keep deleted captures regenerable#259
Conversation
Plan reported only the slots it had no capture for, so a screenshot deleted from the temp folder left its database row behind and its slot never came back as pending. Plan now reports the full baseline with the existing captures attached, and the GUI resolves slot occupancy from it: deleting an image prunes local state only once the file is gone, and a regenerated slot deletes the capture it replaces.
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deleting a screenshot from the temp folder left it permanently un-regenerable: its database row stayed behind, its slot never came back as pending, and nothing in the GUI would produce it again.
Why
Planreported only the slots it had no capture for. The slots it already had were simply omitted from the result, so the plan carried no record that they existed at all. That made the plan lossy in the one direction that mattered: a caller could not tell "this slot is filled" apart from "this slot is not part of the baseline", and once a file vanished from disk there was nothing left to reconcile the orphaned row against.The service was also doing the reconciliation itself — statting files, matching timestamps back to baseline selections, nearest-matching un-indexed captures onto free slots — which is where the state got collapsed.
Fix
Plannow reports the full baseline with any existing captures attached to their slots. Slot occupancy becomes something callers derive from the plan rather than something the plan decides for them, and the reconciliation logic inservice.gocollapses accordingly (roughly 90 lines removed).The GUI resolves occupancy from that baseline via a new
utils/screenshotSlots.ts:buildExistingSlotImagesmaps captures onto their slotspendingSelectionsderives what still needs generatingstaleSlotPathsidentifies rows whose file is goneTwo consequences fall out of doing it this way. Deleting an image now prunes local state only once the file is actually gone, so a failed delete no longer desyncs the UI from disk. And regenerating a slot deletes the capture it replaces, instead of orphaning it.
slotTolerance/selectionTimestampin that file mirrorscreenshotTimestampMatchesSelectionon the Go side; the comment there points at the Go original so the two stay in step.Tests
internal/services/screenshots/scenarios_test.go— new, covers the plan/delete/regenerate cycles end to end.gui/frontend/src/utils/screenshotSlots.test.ts— new, covers the slot helpers.cmd/upbrr/interactive_test.go— the CLI path reports the baseline the same way.go build ./...,go vet, Go tests, pluspnpm typecheck/pnpm lint/pnpm test:unit(214 tests) all pass.