fix(frontend): ensure isLive is false whenever polling is the active source (Closes #904) - #923
Merged
Topmatrixmor2014 merged 1 commit intoAug 26, 2026
Conversation
…source (Closes FinChippay#904) - startPolling now explicitly sets isLive(false) so that polling is the active data source is always reflected in the consumer-facing indicator. - Adds 3 targeted tests for FinChippay#904: 1. isLive drops after a stream error hands over to polling 2. A stale reconnect from an old account cannot flip isLive back on 3. Account switches cleanly reset the live flag before the new stream delivers anything - Fixes stale test assertions (token= -> ticket=) and adds apiFetch mock so SSE tests can actually create EventSource instances.
🤖 Greptile AI Code ReviewGreptile will automatically review this PR (2 file(s) changed). Review gates:
|
3 tasks
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.
Summary
Fixes #904 — the
useBalanceStreamhook could leaveisLive: trueon the UI even when polling was the active data source, or carry a stale "live" badge across account switches.Root cause
startPolling()was never assertingsetIsLive(false). It is reached from several paths that skipcloseSource():EventSourcesupportnew EventSource(...)construction failureIn all of those the consumer's
isLiveindicator was left at whatever the previous session/account had set it to, so a "live" badge could persist while polling was actually running.Changes
frontend/lib/useBalanceStream.tsstartPollingnow explicitly callssetIsLive(false)so polling as the active source is always reflected in the consumer-facing indicator.frontend/__tests__/balance-stream.test.tsxisLivedrops to false after a stream error hands over to polling.isLiveback on.token=→ticket=after the short-lived-ticket auth change) and added anapiFetchmock so SSE tests can actually constructEventSourceinstances.Verification
npm test -- __tests__/balance-stream.test.tsx→ 16/16 passing