Repository navigation
feat: add loading state to useOHLCVRealtime hook - #38863
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0562975. Configure here.
Smart E2E Test SelectionSelected E2E tags: No E2E tests selected AI Confidence: 95 E2E reasoningExpand to readAll three changed files are unit-test level changes with no E2E smoke test impact:
No E2E smoke spec files, page objects, selectors, flows, or shared test infrastructure are modified. The changes are confined to a React hook implementation and its unit tests. The |
|




Description
Downstream bridge/limit-order flows need to distinguish “still waiting for the first OHLCV price lookup” from “lookup finished with no bar.”
useOHLCVRealtimepreviously exposed onlylatestBar, so both cases looked likenull.This PR adds an
isLoadingflag on the hook result. It istruefor the current channel until the first bar arrives (WebSocket or settled/latestpoll) or the first non-aborted poll completes without data. It resets when the asset/channel changes, staysfalsewhen the hook is disabled or misconfigured, and settles when subscribe fails without a follow-up poll. Unit tests cover the loading lifecycle. No UI callers consumeisLoadingyet (follow-up for SWAPS-5274).Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-5274
Manual testing steps
N/A — hook-only change with unit test coverage; no product surface uses
isLoadingin this PR.Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Additive hook API with unit tests only; no UI or bridge behavior changes until a follow-up wires in isLoading.
Overview
useOHLCVRealtimenow returnsisLoading, so callers can tell “still waiting for the first price for this asset/channel” apart from “lookup finished with no bar” (both werelatestBar: nullbefore).Loading stays true until the first bar arrives over the WebSocket or the first non-aborted
/latestpoll completes (with or without data). It goes true again when the asset/channel changes, stays false when the hook is disabled or misconfigured, and settles when subscribe fails with no follow-up poll. Implementation tracks asettledChannelalongside existinglatestBarlogic.Unit tests cover the full
isLoadinglifecycle; BridgeuseLiveTokenFiatRatetests only update mocks to include the new field—no product code readsisLoadingyet (planned follow-up for SWAPS-5274).Reviewed by Cursor Bugbot for commit 5b5a18e. Bugbot is set up for automated code reviews on this repo. Configure here.