Skip to content

editor: download snapshots and complete capture feedback - #1129

Open
angelim wants to merge 3 commits into
pascalorg:mainfrom
angelim:fix/snapshot-download
Open

angelim wants to merge 3 commits into
pascalorg:mainfrom
angelim:fix/snapshot-download

Conversation

@angelim

@angelim angelim commented Oct 23, 2026 •

Copy link
Copy Markdown

What does this PR do?

In the standalone editor, clicking the snapshot shutter captured an image but only uploaded it as the project's thumbnail. The host never emitted snapshot:saved, leaving the overlay on “Capturing…” without exporting a file.

Download user snapshots with a project-based filename and the image's actual extension, then acknowledge completion so the overlay shows “Saved” and exits. Keep automatic thumbnail uploads on their existing path. Correlate shutter requests with save/failure events so unrelated captures cannot complete the overlay, and show capture/download failures while enabling retry.

Host integration: the overlay now supplies a cameraData.requestId; hosts must process manual captures before skipping background request IDs and echo the exact ID on snapshot:saved. Return/reject the capture callback promise so failures can reach the overlay. See the package README's Snapshot completion section.

URL lifetime: the standalone download's blob URL remains valid for 60 seconds, then is revoked. It is a temporary download URL, not persistent image storage. A regression test covers deferred cleanup.

Thumbnail behavior: intentionally, a manual snapshot downloads without replacing the project's thumbnail. Background thumbnail captures continue to upload as before.

How to test

  1. Run bun install --frozen-lockfile and bun dev --filter=editor --ui=stream, then open a saved project.
  2. Open Command+K → Take Snapshot, select Standard 16:9, and press the shutter. A 1920 × 1080 WebP should download; the overlay should show “Saved” and exit.
  3. Repeat with Standard 9:16. Verify a 1080 × 1920 image downloads. Choose the desired levels explicitly; Whole building includes the roof.
  4. Check that ordinary background thumbnail saves do not download files. Capture/download failures should display an error and enable another attempt.

Validation completed:

  • bun run check (passes with existing repository warnings)
  • bun run check-types (all 13 tasks passed)
  • bun run build --filter=editor^... (all six dependency builds passed)
  • bun test apps/editor/lib/snapshot-download.test.ts packages/editor/src/components/editor/snapshot-capture.test.ts packages/editor/src/components/editor/thumbnail-generator.test.ts (47 tests passed)
  • Browser verification: 16:9 and 9:16 downloads decoded at the expected dimensions, capture mode exited, and the browser console had no errors.

Screenshots / screen recording

Generic demo room; no private house plan is shown.

16:9 capture completed

snapshot-review-saved

Error feedback and retry

snapshot-review-error

Optional: attach snapshot-review-export.webp, the actual downloaded 1920 × 1080 demo image.
snapshot-review-export

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

Note

Medium Risk
Changes the snapshot host contract (requestId correlation and promise rejection) and capture UX; integrators that skip manual captures with requestIds may see a stuck shutter until updated.

Overview
Manual snapshot shutter presses now download a file in the standalone editor instead of only uploading the project thumbnail. A new downloadSnapshot helper triggers a browser download with a sanitized project-based filename, emits snapshot:saved only after the download starts (with a 60s blob URL), and scene-loader routes captures with captureMode through that path while background thumbnail autosaves stay on the existing upload route.

The snapshot overlay and isOverlaySnapshotSave are updated to correlate completion via a per-shutter requestId: the overlay tracks a pending ID, listens for snapshot:capture-failed, shows an error with retry, and exits “Saved” only when the matching snapshot:saved arrives—so unrelated background captures cannot dismiss the UI. Package README documents the host onThumbnailCapture contract for integrators.

Reviewed by Cursor Bugbot for commit 4bffaf0. Bugbot is set up for automated code reviews on this repo. Configure here.

@Aymericr Aymericr added bug Something isn't working bot:bugs labels Oct 23, 2026 — with Cursor

@Aymericr Aymericr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, @angelim! The fix is well scoped and the plumbing checks out: tagging the shutter with a requestId lets the existing runSnapshotCapture failure path report back to the overlay, and keeping background thumbnails on the upload path makes sense. The tests are nice too.

One blocker before we can merge:

  • Screenshots or a short screen recording. This changes visible behavior (the download, the "Saved" state, and the new error message), so please add a quick clip or screenshots of a 16:9 capture finishing and of the error state.

A few smaller things worth a look:

  1. Revoking the object URL at 0 ms in downloadImage. Some browsers (Safari and Firefox in particular) can cancel or fail the download if the blob URL is revoked right after click(). A longer delay (for example 30 to 60 seconds) is the usual safe choice. Related: the url emitted on snapshot:saved is already revoked by the time anyone reads it, so listeners can't use it. Either keep it alive or document that it's informational only.
  2. Other hosts. Since the overlay now always sends a requestId and isOverlaySnapshotSave requires it to be echoed back, any other host of @pascal-app/editor that emits snapshot:saved without the requestId, or skips captures that carry one (the old if (cameraData.requestId) return pattern), will now leave the overlay stuck on "Capturing…". Worth a note in the PR description so host implementers know to echo it.
  3. Thumbnail behavior change. Before this, a manual shutter in the standalone editor also updated the project thumbnail. Now it only downloads. That seems intended from your description, just confirming it is.

Once the screenshots are in I'm happy to take another look.

@angelim

angelim commented Oct 23, 2026

Copy link
Copy Markdown
Author

screenshots added in PR description

@angelim
angelim requested a review from Aymericr October 23, 2026 01:50
kvnloo added a commit to kvnloo/editor that referenced this pull request Nov 6, 2026
Cover overlapping manual download success/failure and background save events
so an unrelated snapshot cannot complete a pending manual shutter.

Upstream PR pascalorg#1129 author: Alexandre Angelim (angelim).
kvnloo added a commit to kvnloo/editor that referenced this pull request Nov 6, 2026
Factor the standalone onThumbnailCapture handler into a testable host adapter.
Use an injected clock and cover manual success, rejected download, and
background thumbnail no-ack through the public EditorProps callback.

Original snapshot PR pascalorg#1129 author: Alexandre Angelim (angelim).
Resolve the import conflict in snapshot-capture-overlay.tsx by keeping
both sides: SnapshotCaptureFailedEvent from this branch, plus isTypingTarget
and the @pascal-app/viewer/ui HUD imports from main. No other changes.

Copy link
Copy Markdown
Member

Merged main into this branch to resolve the import conflict in snapshot-capture-overlay.tsx (kept both sides); no other changes.

@Aymericr Aymericr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Maintainer] LGTM at 4bffaf0

Traced the manual capture path end to end: the overlay tags each shutter press with a requestId, the generator copies captureMode and resolution onto cameraData in all three capture branches (tiled, pipeline, fallback), and scene-loader downloads on captureMode before the requestId early return, so manual captures download and resolve the shutter instead of being dropped. Busy or thrown captures still report snapshot:capture-failed with the id, and the point-ask crop stays ephemeral, so it never reaches the host download path. Screenshots are in the description.

Non-blocking:

  • The overlay now only accepts snapshot:saved with a matching requestId. Any host whose onThumbnailCapture handler doesn't emit that event will leave the shutter on "Capturing…" with no timeout. A short timeout that falls back to an error toast would make that failure visible.
  • onThumbnailCapture is typed => void on the generator props while deliverSnapshot accepts void | Promise<void>. Widening the prop type would make it clear async hosts are awaited.

This LGTM is conditional on CI going green at this head. Right now only Cursor Bugbot has run; the fork workflows still need maintainer approval.

This branch has not been deployed

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

Labels

bot:bugs bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants