fix(web): keep GBP Sync button disabled until the sync run completes#678
Merged
Conversation
POST /gbp/sync queues an async gbp-sync run and returns immediately, but the Sync button re-enabled the instant the POST resolved. Hand the queued run to the global RunNotificationObserver via trackRun so the button stays disabled until the run reaches a terminal status, the GBP queries are invalidated only once the data is actually refreshed, and a completion toast fires — rather than invalidating eagerly against stale data. Mirrors the existing GSC-sync tracking pattern. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A tracked gbp-sync/gsc-sync run can age out of the capped GET /runs response (default 500 rows / since-window; cron syncs alone can fill it in under an hour) before RunNotificationObserver sees it reach a terminal status. The observer then skips it forever (`if (!run) continue`) and never clears it, so the Sync/Run button wedges on "Syncing…"/"Running…" indefinitely — and the state is persisted in sessionStorage, so it survives reloads. Stamp each tracked run with `trackedAt` and give up on any run absent from /runs past STALE_TRACKED_RUN_MS: refresh the kind's queries with whatever is current, surface a neutral toast, and drop the tracked run so its button re-enables. Absence is only ever the aged-out case (an in-flight run is still in the window) and the TTL adds a grace, so a legitimately running sync is never cleared early. The give-up rule is a pure, unit-tested `selectStaleTrackedRuns`; an observer test covers the end-to-end reconcile. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
POST /gbp/sync queues an async gbp-sync run and returns immediately, but the Sync button re-enabled the instant the POST resolved instead of waiting for the background sync to finish.
trackRun, keeping the button disabled (and reading "Syncing…") until the run reaches a terminal status.gbp-syncto the run-tracker source actions, threadprojectIdintoGbpSection, bump the package version to 4.69.2, and cover the flow with tests.Follow-up (hardening): a tracked run can no longer wedge the button.
A tracked sync run can age out of the capped
GET /runswindow (default 500 rows / since-window; cron syncs alone can fill it within an hour) before the observer sees it reach a terminal status. The observer then skips it forever (if (!run) continue) and never clears it, so the Sync/Run button stays disabled on "Syncing…" / "Running…" indefinitely, and the state is persisted in sessionStorage so it survives reloads.trackedAt; give up on any run absent from/runspastSTALE_TRACKED_RUN_MS(10m). Refresh the kind's queries with whatever is current, surface a neutral toast, and drop the tracked run so its button re-enables.selectStaleTrackedRuns; an observer test covers the end-to-end reconcile.