Repository navigation
Conversation
- GET /api/v2/downloads attaches a preparation object to preparing entries: queue state and position, or the running encode's progress and estimated time left, ranked the same way as the admin preparation queue. - The download capability reports preparation_progress. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e833e707a9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…paration-progress # Conflicts: # scripts/ci/db-contracts.txt
A running prepare job whose lease expired is claimable again, so the preparation view now reports it as queued, with a queue position and without its stale progress. Both the device-facing preparation object and the admin preparation queue use this classification. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f38d116888
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…paration-progress # Conflicts: # scripts/ci/db-contracts.txt
…ports ClaimNext now breaks created_at ties by id, the same order the reported queue position uses. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb957b2eef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…paration-progress
Ranking the preparation queue covers every unfinished job on the server, so download list reads now share one snapshot per node, refreshed at most every 5 seconds, instead of ranking the queue on each request. Concurrent readers wait for a single refresh. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbe27e9dd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…paration-progress # Conflicts: # scripts/ci/db-contracts.txt
…ving A running encode's progress and estimate are reported only while its worker marks progress available and the last sample is under 30 seconds old (six flush intervals). A worker whose reports stopped no longer shows a frozen percentage. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0e6c716e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
When the queue ranking fails, readers waiting on that refresh now get an empty snapshot for the snapshot TTL instead of each repeating the failing query. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ality (#1880) * feat(downloads): let season downloads and series monitors choose a quality - Native season and series batches accept any advertised quality preset, resolved per episode; episodes the preset cannot reach are skipped with quality_unavailable. - Monitors store a quality (new column, default original) and register new episodes in it, preparing files before the monitor lock and pacing prepared episodes to the account's free concurrent download slots. - The download capability reports bulk_quality and monitor_quality. - /api/v1 batches stay original-only. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(downloads): share free download slots across concurrent monitor syncs A monitor sync with prepared episodes now holds the account's quota lock from counting free concurrent download slots until its rows commit, so monitors of one account syncing at once cannot each claim every free slot. Quality is still resolved before any lock. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(downloads): count prepared replacements and ready files correctly - A season page that replaces an existing entry with a prepared file does so under the quota lock and counts toward the concurrent limit when the replacement adds an active download. - A monitor sync re-reads the monitor before queueing encodes and queues none when the monitor was edited or paused since planning. - An episode whose prepared file is already ready takes no free slot. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(downloads): count version changes and refuse stale guards before encoding - A prepared replacement that switches the episode to another media file counts toward the concurrent limit. - A replacement whose expected revision is stale is refused before its encode is queued. - The monitor PATCH body declares quality's preset enum. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(downloads): count prepared replacements by readiness, not the period - A prepared replacement counts toward the concurrent limit only when its entry isn't already active and the target's prepared file isn't ready, using the same lookup as monitor pacing. - The period quota counts only new downloads; a replacement updates its entry in place. QuantityLimiter.CheckCounts takes the two counts apart. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * feat(downloads): report preparation progress on listed downloads (#1881) * feat(downloads): report preparation progress on listed downloads - GET /api/v2/downloads attaches a preparation object to preparing entries: queue state and position, or the running encode's progress and estimated time left, ranked the same way as the admin preparation queue. - The download capability reports preparation_progress. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(downloads): count a job whose worker lease expired as queued A running prepare job whose lease expired is claimable again, so the preparation view now reports it as queued, with a queue position and without its stale progress. Both the device-facing preparation object and the admin preparation queue use this classification. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(downloads): claim prepare jobs in the order the queue position reports ClaimNext now breaks created_at ties by id, the same order the reported queue position uses. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * perf(downloads): share one preparation queue snapshot per node Ranking the preparation queue covers every unfinished job on the server, so download list reads now share one snapshot per node, refreshed at most every 5 seconds, instead of ranking the queue on each request. Concurrent readers wait for a single refresh. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(downloads): stop reporting encode progress once samples stop arriving A running encode's progress and estimate are reported only while its worker marks progress available and the last sample is under 30 seconds old (six flush intervals). A worker whose reports stopped no longer shows a frozen percentage. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(downloads): share a failed preparation refresh among waiting readers When the queue ranking fails, readers waiting on that refresh now get an empty snapshot for the snapshot TTL instead of each repeating the failing query. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> * chore(api): drop the breaking-change approval consumed by #1925 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Problem
Related issue: N/A
Validation tasks: none
A download the server has to prepare first (a remux or a lower-quality transcode)
sits in
preparingwith no sign of how long it will take. Encodes run one or twoat a time, so a season can wait an hour, and clients can only show a spinner. They
cannot tell "waiting behind ten other jobs" from "almost done".
This adds the queue position and encode progress to listed preparing downloads,
so clients can show "3rd in line" or "35%, 6 min left".
Approach
GET /api/v2/downloadsattaches apreparationobject to each entry whosestatus is
preparingand that is linked to a prepare job:state:queued,running, orretrying;queue_position: 1-based place among every queued job on the server, whilequeued;
progressandremaining_seconds: the encoded fraction and the time left atthe encode's reported speed, once a running encode reports them.
views rank the queue the same way, and that ranking follows the order workers
claim jobs in. A running job whose worker lease expired is claimable again,
so both views now count it as queued, without its stale progress. The claim
query breaks ties the same way the position does.
preparation_progress. Other responses thatreturn an entry do not carry
preparation.warning.
Stacked on #1880 (download quality for season batches and monitors); it
shares that PR's capability struct and generated contracts. It does not depend on
its behaviour.
Validation
gofmt,go vet, changed-line lint on the touched packages, andthe downloads and API v2 test packages. The only failures are the two that also
fail on
main(see feat(downloads): let season downloads and series monitors choose a quality #1880).Postgres (another account's job ahead, a job waiting out a retry backoff, a
finished job, a ready row), and the v2 transport. The Postgres test is added to
scripts/ci/db-contracts.txt.{"state":"queued","queue_position":5}. A running encode's percentage was notobserved there; the tests cover it.
Risks
queue_positioncounts every queued job on the server, so a user can infer howmany prepare jobs other accounts have queued. It does not reveal whose jobs or
what they are.
it at most once every 5 seconds and shares the result across list reads, so
its cost grows with the queue, not with the number of polling clients;
positions and progress can be up to 5 seconds stale.
Checklist
AI Disclosure
queue_positionreveals server-wide queue depth and that the ranking runs on every list read; both are under Risks. On the PR, Codex found that a job whose worker lease expired still read as running with frozen progress; fixed in f38d116. Later passes found that the claim query brokecreated_atties differently from the reported position (fixed in fb957b2) and that every list read ranked the whole queue (now a 5-second snapshot per node, bbe27e9).🤖 Generated with Claude Code
Note
Add preparation progress reporting to listed downloads in the v2 API
preparationobject on rows in queued, running, or retrying state, with queue position, progress fraction (0-1), and remaining seconds. OnlyGET /api/v2/downloadsattaches it.DownloadPreparationtype in download_registry.go and preparation_status.go; OpenAPI contract, docs, and generated TypeScript schema are updated.preparation_progress: truewhen the downloads service is configured.preparation_progressis now a required field in the download capability schema in openapi.json, so old capability responses without it fail validation. Also,preparationStatesCTEin preparations.go now classifies expired running leases as queued.Macroscope summarized 7538192.