Skip to content

fix(web): keep GBP Sync button disabled until the sync run completes#678

Merged
arberx merged 2 commits into
mainfrom
arberx/gbp-sync-button-state
Jun 3, 2026
Merged

fix(web): keep GBP Sync button disabled until the sync run completes#678
arberx merged 2 commits into
mainfrom
arberx/gbp-sync-button-state

Conversation

@arberx
Copy link
Copy Markdown
Member

@arberx arberx commented Jun 3, 2026

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.

  • Hand the queued run to the global RunNotificationObserver via trackRun, keeping the button disabled (and reading "Syncing…") until the run reaches a terminal status.
  • Drop the eager GBP query invalidation; the observer now invalidates the GBP queries only once the data is actually refreshed and fires the completion toast — mirroring the existing GSC-sync tracking pattern.
  • Add gbp-sync to the run-tracker source actions, thread projectId into GbpSection, 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 /runs window (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.

  • Stamp each tracked run with trackedAt; give up on any run absent from /runs past STALE_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.
  • Absence is only ever the aged-out case (an in-flight run is still in the window) and the TTL adds grace, so a legitimately running sync is never cleared early. The observer is shared, so this hardens gsc-sync as well.
  • The give-up rule is a pure, unit-tested selectStaleTrackedRuns; an observer test covers the end-to-end reconcile.

arberx and others added 2 commits June 3, 2026 11:42
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>
@arberx arberx merged commit a1d126b into main Jun 3, 2026
12 checks passed
@arberx arberx deleted the arberx/gbp-sync-button-state branch June 3, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant