Sources: enabling a feed triggers an immediate sync (#195)#198
Merged
Conversation
Enabling TWIC or Lichess Broadcasts now kicks off a download+import right
away instead of only becoming eligible for the scheduler's next tick — so
it no longer feels like "I enabled it, nothing happened."
The `POST /sources/{key}/enabled` quick-mutation submits a `sources_sync`
for the source after the enable write, when:
- it's a feed (bulk sources like Ajedrez get their own one-shot action, #196),
- a sync isn't already queued/running for it, and
- no first-run pipeline owns the database (setup sentinel absent).
Maintenance after the import is size-matched, which `sources_sync` already
does (full for bulk, light for a feed).
A new `sync` flag on the endpoint (default true) lets the wizard opt out:
its own first-run pipeline does the initial load, so `applySourceSelection`
now passes sync=false to avoid double-importing.
Verified live: enabling TWIC submits a running `sources_sync twic`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019KdPPg7P3bZ5p2RRhZZcv2
) Two follow-ups from testing: 1. Enabling a second feed while the first was still importing left its toggle greyed and its sync unqueued until the first finished. The enable endpoint's state write serializes on the single writer behind the running import, and it was awaited (blocking the HTTP response, hence the toggle) AND the sync was submitted only after that write. Now: submit the sync first (so it queues immediately, behind the running one), then apply the enable write fire-and-forget (`spawn_fn`) on the interactive path so the response returns at once. The wizard path (sync=false) still awaits — the writer is idle there and `startSetup` reads the enabled set right after, so the write must be committed first. Verified live: a second enable returns in <1ms while the first syncs, and its sources_sync is queued. 2. The wizard's first-run pipeline submitted a "Download <src>" + "Import <src>" pair per source, while enabling from Maintenance submits one "Sync <src>" (sources_sync). Unify: the wizard now submits sources_sync too, so onboarding shows the same single job. First-run still gets the full identity-first maintenance (request_maintenance(true) upfront, coalesced with each sync's request). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KdPPg7P3bZ5p2RRhZZcv2
The immediate-sync was gated on `!setup_sentinel_present`, so re-enabling a feed via Maintenance while the wizard's first-run pipeline was still running did nothing — no job queued. The guard was redundant (the wizard's own enables pass sync=false) and harmful: the scheduler is held off during first-run, so the interactive enable is the only path that would queue a sync. Drop the sentinel gate; the sync=false (wizard) and already-syncing (dedup) checks already prevent double-imports. Verified live: with a setup sentinel present, enabling a feed now submits its sources_sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KdPPg7P3bZ5p2RRhZZcv2
jozef2svrcek
added a commit
that referenced
this pull request
Jul 25, 2026
…jedrez, per-card metrics + incremental dedup Lands the tested batch behind the 0.9.9 draft: - #194 (PR #200): configurable daily update-check time + next-run visibility. - #195 (PR #198): enabling a feed triggers an immediate sync. - #196 (PR #199): Ajedrez one-shot "Download & import" action instead of a toggle. - #197 (PR #201): per-source metrics moved into each card; aggregated blocks dropped. - PR #203: crisp high-contrast toggle icon. Plus follow-up work validated during testing: - Incremental dedup_games via a `deduped` marker; unified single maintenance pass (supersedes the closed PR #204). - Sync init shows the indeterminate bar instead of a stuck 100%. - Enable-flag write persists before the sync is dispatched; toggle state derived from the job pipeline + a module-level intent store, so it survives navigation. - FIDE card reflects background (scheduler / post-sync) refreshes. - Coalesced maintenance is pinned to the queue tail the moment a feed is enabled.
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.
Closes #195.
Enabling TWIC or Lichess Broadcasts now kicks off a download+import immediately instead of only becoming eligible for the scheduler's next tick — fixing the "I enabled it, nothing happened" feel.
How
The
POST /sources/{key}/enabledquick-mutation (from #191) submits asources_syncafter the enable write, when all hold:Maintenance after the import is size-matched (the decided option) —
sources_syncalready requestsfullfor a bulk import and the light pass for a feed.Avoiding a double-import during onboarding
A new
syncflag on the endpoint (defaulttrue) lets the wizard opt out: its own first-run pipeline (startSetup) does the initial load, soapplySourceSelectionpassessync=false. The sentinel guard is a second line of defence (covers a resume too).Verified
Live test:
POST /sources/twic/enabled {sync:true}→ a runningsources_sync twicjob appears immediately. (sync=falseand bulk sources are guarded by simple boolean checks and submit nothing.)Build + clippy (
-D warnings) + 45 chess-db tests green; frontend builds.🤖 Generated with Claude Code
https://claude.ai/code/session_019KdPPg7P3bZ5p2RRhZZcv2