fix(scan): visible chain-paused banner and explicit fetch-error states#100
Conversation
The idle/unreachable banner used an 8% orange tint at 11px in a thin strip; on the desktop stats ribbon it blended into the page and users missed that the chain had stopped producing blocks. Raise to a 16% tint with a 2px border, 13px semibold label, an AlertTriangle icon, and role="alert" so the state is visible and announced.
… loading Stat cards now show a retry control when a fetch fails with no data, instead of the same dash used for an empty value. Wired to the home stats cards via the error and retry the hooks already expose. Analytics loading uses a skeleton instead of the empty-state box.
fetchValidators and fetchAccountsTop returned [] on a failed request, so an outage looked like a genuinely empty list. Return null on failure so the hook flags an error, and render a retry state on both pages instead of the empty placeholder.
📝 WalkthroughWalkthroughThe scan app now distinguishes fetch failure from empty data in validators and top accounts requests. Shared stat cards can render error states with retry actions, and validators, accounts, and home pages wire those states into their UI. Analytics replaces its initial loading empty state with a skeleton. Sequence Diagram(s)sequenceDiagram
participant User
participant ValidatorsPage
participant UseValidators as useValidators(network)
participant FetchValidators as fetchValidators
participant StatCard
User->>ValidatorsPage: open page
ValidatorsPage->>UseValidators: load validators
UseValidators->>FetchValidators: request data
FetchValidators-->>UseValidators: data or null
UseValidators-->>ValidatorsPage: data, error, retry
ValidatorsPage->>StatCard: render stats with error/onRetry
alt error
User->>StatCard: click retry
StatCard->>ValidatorsPage: onRetry()
ValidatorsPage->>UseValidators: retry
else data
ValidatorsPage->>StatCard: show values
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
apps/scan/app/[locale]/HomeContent.tsx (1)
385-395: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: stats-derived cards are wired inconsistently.
active_validators,tokens_deployed,total_burned, andblock_rewardnow surfacestatsError/retryStats, butblock_heightandtotal_transactions(also derived fromstats) do not. That's defensible since the latter fall back to WS/derived values, but the split means a stats outage shows "failed" retry chips on some cards while sibling cards quietly render "—". Consider documenting or unifying the intent.Also applies to: 404-414
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/scan/app/`[locale]/HomeContent.tsx around lines 385 - 395, The stats-derived cards are wired inconsistently in HomeContent, where some StatCard instances use statsError/retryStats and others rely on fallback values, creating mixed failure states. Update the rendering in HomeContent to either consistently pass statsError and retryStats to all cards derived from stats, or explicitly keep the fallback behavior for block_height and total_transactions and document that intent alongside the StatCard setup so the split is clear and maintainable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/scan/app/`[locale]/HomeContent.tsx:
- Around line 385-395: The stats-derived cards are wired inconsistently in
HomeContent, where some StatCard instances use statsError/retryStats and others
rely on fallback values, creating mixed failure states. Update the rendering in
HomeContent to either consistently pass statsError and retryStats to all cards
derived from stats, or explicitly keep the fallback behavior for block_height
and total_transactions and document that intent alongside the StatCard setup so
the split is clear and maintainable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 44488f55-300a-42ca-a339-365cc187a49c
📒 Files selected for processing (8)
apps/scan/app/[locale]/HomeContent.tsxapps/scan/app/[locale]/accounts/page.tsxapps/scan/app/[locale]/analytics/page.tsxapps/scan/app/[locale]/validators/page.tsxapps/scan/components/common/StatCard.tsxapps/scan/lib/api.tsapps/scan/messages/en.jsonapps/scan/messages/id.json
Three state-handling fixes for the block explorer.
Chain-paused banner
The idle / unreachable banner was an 8% orange tint at 11px in a thin strip, easy to miss on the desktop stats ribbon. Raised to a 16% tint with a 2px border, 13px semibold label, an AlertTriangle icon, and role="alert".
Fetch errors are now visible
The data hooks already compute an
errorflag, but no component consumed it, so a failed fetch rendered the same dash as a genuinely empty value. Two changes:StatCardgains an explicit error + retry state, distinct from the empty dash. Wired to the home stats cards.fetchValidatorsandfetchAccountsTopreturned[]on a failed request, so an outage looked like a genuinely empty list. They now returnnullon failure so the hook flags an error, and the validators and accounts pages render a retry state instead of the empty placeholder.Analytics loading
Loading reused the empty-state component ("Loading analytics..."). It now uses a skeleton, so loading and empty are distinct.
Testing
typecheck and build pass. Verified live: with the mainnet validator/account endpoints currently failing, both pages render the retry state ("Gagal memuat data") instead of a misleading empty list. New i18n keys added to id.json and en.json.
Summary by CodeRabbit
Bug Fixes
New Features