Skip to content

fix(screenshots): keep deleted captures regenerable#259

Open
maksii wants to merge 1 commit into
mainfrom
fix/screenshot-regeneration
Open

fix(screenshots): keep deleted captures regenerable#259
maksii wants to merge 1 commit into
mainfrom
fix/screenshot-regeneration

Conversation

@maksii

@maksii maksii commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

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

Plan reported 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

Plan now 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 in service.go collapses accordingly (roughly 90 lines removed).

The GUI resolves occupancy from that baseline via a new utils/screenshotSlots.ts:

  • buildExistingSlotImages maps captures onto their slots
  • pendingSelections derives what still needs generating
  • staleSlotPaths identifies rows whose file is gone

Two 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 / selectionTimestamp in that file mirror screenshotTimestampMatchesSelection on 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, plus pnpm typecheck / pnpm lint / pnpm test:unit (214 tests) all pass.

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.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@maksii, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9f9dbd4c-b920-462b-bf21-414d4430857d

📥 Commits

Reviewing files that changed from the base of the PR and between 5a00fc7 and 30684f0.

📒 Files selected for processing (9)
  • cmd/upbrr/interactive.go
  • cmd/upbrr/interactive_test.go
  • gui/frontend/src/app.tsx
  • gui/frontend/src/hooks/useScreenshots.ts
  • gui/frontend/src/pages/screenshots/index.tsx
  • gui/frontend/src/utils/screenshotSlots.test.ts
  • gui/frontend/src/utils/screenshotSlots.ts
  • internal/services/screenshots/scenarios_test.go
  • internal/services/screenshots/service.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/screenshot-regeneration

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant