feat(frontend): async reel generation via submit + poll - #35
Merged
Conversation
Photo reels now submit POST /reels/jobs and poll GET /reels/jobs/{id} rather
than blocking on a single multi-minute request that 504s at the edge proxy.
The job's terminal result is the identical ReelResponse shape, so the success
and error render paths are shared with the synchronous flow unchanged. The
synthetic (no-photo) path stays a direct blocking call (the job route requires
at least one photo). Guard rails: ~4s interval, ~12min wall-clock ceiling
(surfaced through the existing 504 timeout copy), a 3-consecutive transient
error budget, an immediate first tick (offline jobs finish instantly), and
unmount-safe cleanup. lib/progress.ts and the humanized copy are reused, not
changed.
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
Photo reels now use the backend's async job flow (
POST /reels/jobs→ pollGET /reels/jobs/{id}) instead of a single blocking request that 504s at the Firebase/Cloud Run edge on a multi-minute live render. Closes the M2 gap end-to-end (each request stays well under the proxy cap).Changes (frontend only)
lib/api.ts:submitReelJob+getReelJob+ Zod schemas;resultreusesReelResponseSchema. Sync client kept.lib/queries.ts:useSubmitReelJob+usePollReelJob(interval loop, ~4s tick, ~12min ceiling → synthesized 504 reusing the existing timeout copy, 3-consecutive-error budget, immediate first tick, unmount-safe).GenerateReel.tsx: photo path → submit+poll; synthetic (no-photo) path stays a direct blocking call.isPending/isSuccess/errorderived to bridge submit→poll.lib/progress.ts+ humanized copy reused unchanged.Additive
Backend untouched (both sync + async endpoints remain).
useUploadReelkept for callers. Only generation-flow tests updated (GenerateReel/api/queries/e2e mocks). 191 tests pass locally; CI re-verifies.