Use sockets to update latest block/batch on home page#3353
Use sockets to update latest block/batch on home page#3353
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. To trigger a review, include ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2338b24. Configure here.
| label: statsData?.total_blocks?.title || 'Total blocks', | ||
| value: Number(statsData?.total_blocks?.value || apiData?.total_blocks).toLocaleString(), | ||
| label: 'Latest block', | ||
| value: Number(blocksQuery.data?.[0]?.height || statsData?.total_blocks?.value || apiData?.total_blocks).toLocaleString(), |
There was a problem hiding this comment.
Fallback value semantically mismatches "Latest block" label
Low Severity
When blocksQuery.data is an empty array (no blocks returned by API), the value falls back to statsData?.total_blocks?.value or apiData?.total_blocks, which represent the total block count, not the latest block height. The label reads "Latest block" but the displayed number would be total blocks (off by one from the actual latest height). The falsy check on height also means block height 0 would incorrectly trigger this fallback path.
Reviewed by Cursor Bugbot for commit 2338b24. Configure here.
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |


Description and Related Issue(s)
Resolves #3245
Checklist for PR author
Note
Medium Risk
Introduces live socket-driven cache updates for homepage stats, which can cause stale/incorrect UI if event payloads or query keys don’t match expectations, but changes are localized to the homepage widgets.
Overview
Homepage stats now derive the Latest block value from the
general:homepage_blocksendpoint (with a stub placeholder) instead of treating it as a "total blocks" metric, and the widget label is updated accordingly (including degraded/fallback UI and mocks).Adds websocket subscriptions on the homepage stats panel to push real-time updates into the React Query cache for
blocks:new_blockand (for Arbitrum/zkEVM) latest batch events, with guardrails to disable sockets during placeholder/error states and to de-duplicate/sort incoming items.Reviewed by Cursor Bugbot for commit 2338b24. Bugbot is set up for automated code reviews on this repo. Configure here.