Skip to content

feat(preprod): Poll snapshot ZIP build status before downloading - #116827

Closed
NicoHinderling wants to merge 2 commits into
masterfrom
nico/feat/resumable-snapshot-zip-download-frontend
Closed

NicoHinderling wants to merge 2 commits into
masterfrom
nico/feat/resumable-snapshot-zip-download-frontend

Conversation

@NicoHinderling

@NicoHinderling NicoHinderling commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Points the "Download Images" action at the new async, resumable snapshot-archive endpoint (.../snapshots/<id>/archive/) added in #116825.

That endpoint no longer streams the ZIP synchronously. Instead, a plain GET .../archive/ returns {status} and enqueues a background build, and GET .../archive/?download=true serves the finished, resumable file. So clicking "Download Images" now:

  1. Triggers/awaits the build by polling the status endpoint every 3s while building (via useApiQuery + refetchInterval, matching the existing preprod polling pattern in snapshots.tsx).
  2. Once ready, downloads the file via downloadFromHref(..., '.../archive/?download=true').
  3. Shows a "Preparing…" state on the menu item and toasts for in-progress / success / failure.

Depends on the backend PR (#116825) being deployed first (the /archive/ endpoint must exist). The old /download/ endpoint is untouched, so there is no deploy-ordering risk: this PR can merge whenever, and the old endpoint is removed in a later cleanup once nothing references it. Behind the existing organizations:preprod-snapshots flag.

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 3, 2026
@NicoHinderling
NicoHinderling changed the base branch from master to graphite-base/116827 June 3, 2026 23:45
@NicoHinderling
NicoHinderling force-pushed the nico/feat/resumable-snapshot-zip-download-frontend branch from 4c5baa4 to a4402be Compare June 3, 2026 23:45
@NicoHinderling
NicoHinderling force-pushed the graphite-base/116827 branch from 0801156 to c0153d5 Compare June 3, 2026 23:45
@NicoHinderling
NicoHinderling changed the base branch from graphite-base/116827 to nico/feat/resumable-snapshot-zip-download June 3, 2026 23:45

NicoHinderling commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@NicoHinderling
NicoHinderling force-pushed the nico/feat/resumable-snapshot-zip-download-frontend branch from a4402be to 37594af Compare June 4, 2026 00:26
@NicoHinderling
NicoHinderling force-pushed the nico/feat/resumable-snapshot-zip-download-frontend branch from 37594af to e1d921b Compare June 4, 2026 03:04
@NicoHinderling
NicoHinderling force-pushed the nico/feat/resumable-snapshot-zip-download branch from c8d9154 to 6d6c297 Compare June 4, 2026 03:23
@NicoHinderling
NicoHinderling force-pushed the nico/feat/resumable-snapshot-zip-download-frontend branch from e1d921b to 611a7c8 Compare June 4, 2026 03:23
@NicoHinderling
NicoHinderling marked this pull request as ready for review June 4, 2026 03:25
@NicoHinderling
NicoHinderling requested a review from a team as a code owner June 4, 2026 03:25
@NicoHinderling
NicoHinderling force-pushed the nico/feat/resumable-snapshot-zip-download-frontend branch from 611a7c8 to e26604c Compare June 4, 2026 03:52

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e26604cd89390725c094e0e5e858af0f7bf29f79. Configure here.

Base automatically changed from nico/feat/resumable-snapshot-zip-download to master June 4, 2026 06:14
@NicoHinderling
NicoHinderling requested review from a team as code owners June 4, 2026 06:14
The Download Images action now polls the new /archive/ status endpoint
and downloads the prepared ZIP via ?download=true once the build is
ready, registering the new route URL in the getApiUrl known-URLs typing.

Previously the "Preparing…" toast auto-dismissed after ~6s while the
build kept running in the background, leaving the user with no feedback.
Read the "progress" field from the archive status poll and re-issue the
loading toast on every 3s tick so it stays visible and shows the live
build percentage, with copy letting the user know they can leave and
download again later.

Co-Authored-By: Claude <[email protected]>
@NicoHinderling
NicoHinderling force-pushed the nico/feat/resumable-snapshot-zip-download-frontend branch from e26604c to 8664f63 Compare June 4, 2026 06:15
A second "Download Images" click reused the cached {status: "ready"} from
the status query (staleTime: 0 serves stale cache synchronously) and fired
the download immediately, skipping the prepare/poll flow. If the archive
was no longer ready server-side, the download would 409 without re-preparing.

Clear the cached status when a new prepare starts so the effect waits for a
fresh ready response before downloading.

Co-Authored-By: Claude <[email protected]>
if (!isPreparingDownload || !downloadStatus) {
return;
}
if (downloadStatus.status === 'ready') {

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.

Out of curiosity, would it be equivalent to use a switch for this sort of thing, or is there a meaningful difference b/w them (or reason to favor one vs another)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

could definitely do a switch, this is still a WIP PR and not even sure if we'll end up shipping this polling logic yet though. still testing on large uploads

This branch was successfully deployed

1 active deployment
Preview — 23572ac0 Deployed Jun 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants