Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds live progress updates to the Collections “Optimizations” view by introducing conditional polling while optimizations are running, with request cancellation and tab-visibility awareness to reduce unnecessary network traffic.
Changes:
- Introduced a polling loop that re-fetches optimizations only while
result.runningis non-empty and the tab is visible. - Refactored fetching into an async
runFetchthat aborts in-flight requests viaAbortController. - Added cleanup for timeouts/requests on unmount and when
collectionNamechanges.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0a6bbac to
d3e1ef7
Compare
generall
requested changes
Apr 10, 2026
Member
There was a problem hiding this comment.
there are a few problems:
- there are no refresh animation
- logic of stopping pooling is inconsistent - it should either always refresh or not refresh. Current logic stop refreshing if everything is optimized, but in practice optimizations can start again at any moment. Refresh should either be always on or there should be a button to stop it
- selection of the optimization tasks is lost on refresh
d3e1ef7 to
ae4c6b0
Compare
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.
This PR adds live updating of ongoing optimization progress.
The next description is generated with Copilot. It looks correct to me:
Polling and Data Fetching Improvements:
POLL_ACTIVE_MS).runFetchfunction that usesAbortControllerto cancel in-flight requests when a new fetch is triggered or the component unmounts, preventing race conditions and memory leaks.Component Lifecycle and Cleanup:
My initial prompts to ai:
ProgressGrid shows an optimization progress. But if there is an ongoing optimization, the status won't. Please add polling to the Optimizations component every 10s for ongoing optimization.
Poll only when something is running — After each response, if result.running (or your equivalent) is non-empty, schedule the next fetch in N seconds; if idle/empty, stop or use a much longer interval. That avoids hammering the API when nothing is changing.
Respect tab visibility — Use the Page Visibility API: pause or slow polling when document.hidden is true.
Single in-flight request — Ignore starting a new poll tick if the previous request hasn’t finished, or abort the previous request when starting a new one (AbortController), so you don’t queue traffic.
Reasonable interval — Often 2–5s while optimizing is enough; sub-second is usually unnecessary load.
Clean up on unmount — Clear setInterval / setTimeout and abort fetches so leaving the page stops all requests.
ProgressGrid and Timeline already react to data changes; you only need the parent (Optimizations) to call fetchData on that schedule (or use a data library that does refetch intervals for you).