fix(station-boards): push last snapshot on subscribe when one exists - #482
Merged
Merged
Conversation
Symptom: switching views (station -> home, or any other view that uses createStationBoardsController) showed scheduled-only vehicles for up to one poll cycle (15 s today) before live GPS buses reappeared, even when data was already flowing on the previous view. Root cause: subscribeStationBoards explicitly skipped the late-subscribe catch-up that the previous implementation had (`void pushOne(sub, getReconciledSnapshot())`). PR #454 removed it in 2026-07 to fix an incoming-first flicker in StationCard groups on cold start. That reasoning was correct for the FIRST-EVER subscription (before tickLive has run, getReconciledSnapshot returns null, and pushing scheduled-only vehicles does cause a flicker). It was wrong for every subsequent subscription, where the snapshot exists, has merged GPS data, and is what the stream is currently broadcasting. Fix: push the last good snapshot on subscribe, but only when getReconciledSnapshot() returns non-null. The cold-start path (snapshot === null) is unchanged, so the PR #454 flicker fix is preserved. The new view now paints the same merged-with-GPS data the previous view was showing, within a microtask of subscribing. The next tickLive (within livePollMs) replaces it with a fresher snapshot.
ciotlos
approved these changes
Aug 7, 2026
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.
Symptom
Switching between views (e.g. station view -> home, or any pair of views that use
createStationBoardsController) showed scheduled-only vehicles for up to one poll cycle (15 s today) before live GPS buses reappeared, even when data was already flowing on the previous view.Root cause
subscribeStationBoardsinsrc/lib/workers/gtfs/stationSubscribers.tsexplicitly skipped the late-subscribe catch-up. PR #454 removed it on 2026-07-22 to fix an incoming-first flicker in StationCard groups on cold start, but the regression is that the new view's subscriber now waits for the nexttickLiveto receive its first push.PR #454 was correct for the first-ever subscription (before the first
tickLivehas run,getReconciledSnapshot()returns null, and pushing the empty scheduled-only board does cause flicker). It was wrong for every subsequent subscription, where a non-null snapshot already exists and is what the stream is currently broadcasting.Fix
In
subscribeStationBoards, push the last good snapshot on subscribe but only whengetReconciledSnapshot()is non-null. The cold-start path is unchanged (the null check skips the push), so the PR #454 flicker fix is preserved. Every subsequent subscription paints within a microtask with the same merged-with-GPS data the stream is currently showing.The new view now reads the most recent merged snapshot the moment its controller mounts. The next
tickLive(withinlivePollMs= 15 s) replaces it with a fresher one.Verification
npx vitest run)svelte-check0 errorsRelated
PR #454 (
fix: eliminate incoming-first flicker in StationCard groups) is the fix this restores the missing half of. The two together are the complete solution: no flicker on cold start, no 15 s wait on view switch.