Skip to content

fix(scan): visible chain-paused banner and explicit fetch-error states#100

Merged
github-actions[bot] merged 3 commits into
mainfrom
fix/scan-error-states
Jun 25, 2026
Merged

fix(scan): visible chain-paused banner and explicit fetch-error states#100
github-actions[bot] merged 3 commits into
mainfrom
fix/scan-error-states

Conversation

@satyakwok

@satyakwok satyakwok commented Jun 25, 2026

Copy link
Copy Markdown
Member

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 error flag, but no component consumed it, so a failed fetch rendered the same dash as a genuinely empty value. Two changes:

  1. StatCard gains an explicit error + retry state, distinct from the empty dash. Wired to the home stats cards.
  2. fetchValidators and fetchAccountsTop returned [] on a failed request, so an outage looked like a genuinely empty list. They now return null on 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

    • Added clearer failure states across the scan dashboard, including retry actions when account, validator, or stat data cannot be loaded.
    • Improved loading behavior on the analytics page with a cleaner placeholder instead of an empty error-style card.
    • Distinguished between “no data” and “request failed” so pages can show the right message.
  • New Features

    • Added localized error and retry text in supported languages.
    • Enhanced stat cards to support in-card error display and retry handling.

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.
@github-actions github-actions Bot enabled auto-merge (squash) June 25, 2026 04:32
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning Missing the required Summary/Test plan/Related structure; it uses narrative sections instead of the template's headings and checklist. Add a ## Summary, a ## Test plan bullet checklist covering happy path and edge cases, and a ## Related section with links or issues.
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: a more visible chain-paused banner and explicit fetch-error states.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/scan-error-states

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/scan/app/[locale]/HomeContent.tsx (1)

385-395: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: stats-derived cards are wired inconsistently.

active_validators, tokens_deployed, total_burned, and block_reward now surface statsError/retryStats, but block_height and total_transactions (also derived from stats) 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8d8a08c and 717d360.

📒 Files selected for processing (8)
  • apps/scan/app/[locale]/HomeContent.tsx
  • apps/scan/app/[locale]/accounts/page.tsx
  • apps/scan/app/[locale]/analytics/page.tsx
  • apps/scan/app/[locale]/validators/page.tsx
  • apps/scan/components/common/StatCard.tsx
  • apps/scan/lib/api.ts
  • apps/scan/messages/en.json
  • apps/scan/messages/id.json

@github-actions github-actions Bot merged commit 753759d into main Jun 25, 2026
7 checks passed
@satyakwok satyakwok deleted the fix/scan-error-states branch June 25, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant