Skip to content

Conversation

ManiBAJPAI22
Copy link

@ManiBAJPAI22 ManiBAJPAI22 commented Aug 22, 2025

Background

The Stats component in web/src/pages/Courts/CourtDetails/Stats/index.tsx currently does not handle loading and error states when fetching data from multiple sources (court details and coin prices). This improvement will help users understand when data is being loaded or if there are any issues with data fetching.

Changes Made

  • Loading State: Added loading spinner while data is being fetched
  • Error State: Added error message display when data fetching fails
  • Multi-Source Handling: Handle both court details and coin prices loading/error states
  • User Experience: Improve user experience with proper feedback during data operations

Technical Implementation

  • Court Details: Uses isLoading and error from useCourtDetails hook (standard React Query)
  • Coin Prices: Enhanced useCoinPrice hook to return isLoading and error properties
  • Loading: Shows <Spinner /> component during data fetch for both sources
  • Error: Shows styled <ErrorMessage> component with theme-consistent styling
  • Conditional Rendering: Only renders StatsContent when both data sources are successfully loaded

Files Changed

  • web/src/hooks/useCoinPrice.tsx - Enhanced to return isLoading and error
  • web/src/pages/Courts/CourtDetails/Stats/index.tsx - Added loading/error handling

References


PR-Codex overview

This PR focuses on enhancing the useCoinPrice hook and the Stats component by adding loading and error handling states, improving user feedback during data fetching.

Detailed summary

  • Added isLoading and error states to the useCoinPrice hook.
  • Updated the Stats component to handle loading and error states.
  • Introduced a Spinner component for loading indication.
  • Added an ErrorMessage styled component for error display.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Stats page now shows a loading spinner while data loads and displays a clear error message if statistics fail to load.
    • Price retrieval now surfaces loading and error states so the UI can reflect in-progress or failed price fetches.
  • Documentation

    • Project README content was removed (documentation cleared).

ManiBAJPAI22 and others added 7 commits August 16, 2025 03:38
## Summary

This PR significantly improves the developer experience for local Kleros v2 setup by adding missing configuration steps and comprehensive troubleshooting guidance. 

## What's Added

### 🔧 Environment Setup Section
- **API key requirements**: Step-by-step instructions for Alchemy and WalletConnect setup
- **Environment file configuration**: Complete `.env.local` file creation with all required variables
- **Alternative configuration methods**: Instructions for updating existing `.env.local.public`

### 🛠️ Comprehensive Troubleshooting Section
- **8 common setup issues** with exact error messages and copy-paste solutions:
  1. Volta yarn version errors (`volta pin yarn`)
  2. Module resolution errors (kleros-app build dependency)
  3. Environment variable errors (missing API keys)
  4. Graph Node fulltext search errors (schema modification)
  5. GraphQL code generation failures (endpoint testing)
  6. Docker/Graph Node connection issues (port conflicts)
  7. Web frontend loading issues (browser debugging)
  8. Simulate task errors (working alternatives)

## Issues Addressed

This PR addresses real-world problems that block new contributors:

- **Missing environment variables** cause runtime errors with no clear guidance
- **Volta configuration issues** prevent yarn commands from working  
- **Missing build dependencies** cause module resolution failures
- **Broken simulation commands** (`simulate:all` task doesn't exist)
- **No troubleshooting guidance** when things go wrong
- **Port number discrepancies** between docs and actual behavior

## Testing

These improvements are based on actual setup experience where each documented issue was encountered and resolved during a fresh repository clone and setup process.

## Impact

This change will:
- ✅ **Reduce onboarding friction** for new developers
- ✅ **Save hours of debugging time** with ready solutions
- ✅ **Improve developer experience** with clear, actionable guidance
- ✅ **Prevent common setup failures** that discourage contributions

## Breaking Changes

None. This is purely additive documentation that enhances the existing setup process without changing any functionality.
…up-troubleshooting

docs: Add comprehensive setup guide and troubleshooting section
Copy link

netlify bot commented Aug 22, 2025

👷 Deploy request for kleros-v2-testnet pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 4742f14

Copy link

netlify bot commented Aug 22, 2025

👷 Deploy request for kleros-v2-testnet-devtools pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 4742f14

Copy link

netlify bot commented Aug 22, 2025

👷 Deploy request for kleros-v2-university pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 4742f14

Copy link

netlify bot commented Aug 22, 2025

👷 Deploy request for kleros-v2-neo pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 4742f14

Copy link
Contributor

coderabbitai bot commented Aug 22, 2025

Walkthrough

Removed README.md content entirely. Extended useCoinPrice to return isLoading and error. Updated Courts/CourtDetails/Stats to show a Spinner while loading and an error message on fetch failure, wiring new hook outputs to the UI.

Changes

Cohort / File(s) Summary
Documentation removal
README.md
Removed entire README content (now empty).
Hook: coin price loading/error surface
web/src/hooks/useCoinPrice.tsx
Destructures and returns isLoading and error from useQuery alongside existing prices and isError. No fetch logic changes.
Courts Stats UI loading/error handling
web/src/pages/Courts/CourtDetails/Stats/index.tsx
Consumes isLoading/error from hooks; renders <Spinner /> when loading and an ErrorMessage when errors occur; passes loaded data to StatsContent.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant StatsPage as Courts/CourtDetails/Stats
  participant CourtHook as useCourtDetails
  participant PriceHook as useCoinPrice
  participant CourtAPI as Court Data Source
  participant PriceAPI as Price API

  User->>StatsPage: Open Court Details → Stats
  StatsPage->>CourtHook: request court details
  StatsPage->>PriceHook: request coin prices
  par Parallel fetch
    CourtHook->>CourtAPI: fetch court data
    PriceHook->>PriceAPI: fetch price data
  end

  alt Any isLoading
    StatsPage-->>User: Render Spinner
  else Any error
    StatsPage-->>User: Render "Failed to load statistics"
  else Success
    StatsPage-->>User: Render StatsContent (court data + prices)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested labels

Type: Feature🗿, Package: Web, Type: UX

Suggested reviewers

  • alcercu
  • kemuru
  • Harman-singh-waraich

Poem

I nibble bytes and hop through code tonight,
Spinning while prices load in soft moonlight.
If errors thump, I thump back once or twice—
Then stats bloom bright, and docs gone silent, nice. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5b7d953 and 4742f14.

📒 Files selected for processing (1)
  • README.md (0 hunks)
💤 Files with no reviewable changes (1)
  • README.md
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

224-226: Grammar: singular subject.

“Every versions were saved…” → “Every version was saved…”

Apply this diff:

-Every versions were saved as `subgraph.yaml.bak.<timestamp>`.
+Every version was saved as `subgraph.yaml.bak.<timestamp>`.
🧹 Nitpick comments (3)
web/src/hooks/useCoinPrice.tsx (1)

3-7: Type safety and input shape: prefer a single array parameter over rest args.

The fetcher currently takes (...coinIds) and is called with an array (fetchCoinPrices(coinIds)). JS coerces [["a","b"]].join(",") to "a,b", which “works by accident” but is brittle. Make the parameter explicitly coinIds: string[] to avoid confusion and future regressions.

Apply this diff to clarify the contract:

-const fetchCoinPrices = async (...coinIds) => {
-  const response = await fetch(`https://coins.llama.fi/prices/current/${coinIds.join(",")}?searchWidth=1h`);
+const fetchCoinPrices = async (coinIds: string[], signal?: AbortSignal): Promise<Prices> => {
+  const response = await fetch(
+    `https://coins.llama.fi/prices/current/${coinIds.join(",")}?searchWidth=1h`,
+    { signal }
+  );
   const data = await response.json();
   return data.coins;
 };

And ensure the queryFn passes the signal and array (see previous comment).

web/src/pages/Courts/CourtDetails/Stats/index.tsx (2)

75-77: Add accessibility: announce the error message to assistive tech.

Expose the error via an ARIA live region so screen readers get notified immediately.

Apply this diff:

-  if (courtError || pricesError) {
-    return <ErrorMessage>Failed to load statistics</ErrorMessage>;
-  }
+  if (courtError || pricesError) {
+    return <ErrorMessage role="alert" aria-live="assertive">Failed to load statistics</ErrorMessage>;
+  }

Optionally, consider adding a “Retry” button by exposing refetch from both hooks for a better recovery path.


66-69: Consider using isFetching for background refresh UX (optional).

isLoading only covers the initial load. If you want to avoid spinner flicker during background refetches, keep as-is. If you prefer to indicate ongoing background activity, you could also read isFetching from both queries and render a lighter inline progress indicator instead of replacing the whole section.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f02d718 and 5b7d953.

📒 Files selected for processing (3)
  • README.md (7 hunks)
  • web/src/hooks/useCoinPrice.tsx (1 hunks)
  • web/src/pages/Courts/CourtDetails/Stats/index.tsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
web/src/pages/Courts/CourtDetails/Stats/index.tsx (2)
web/src/hooks/queries/useCourtDetails.ts (1)
  • useCourtDetails (33-45)
web/src/hooks/useCoinPrice.tsx (1)
  • useCoinPrice (13-32)
🪛 LanguageTool
README.md

[grammar] ~69-~69: There might be a mistake here.
Context: ... API Key** (for blockchain connectivity) - Sign up at [alchemy.com](https://www.alc...

(QB_NEW_EN)


[grammar] ~73-~73: There might be a mistake here.
Context: ...ct Project ID** (for wallet connections) - Sign up at [cloud.walletconnect.com](htt...

(QB_NEW_EN)


[grammar] ~238-~238: There might be a mistake here.
Context: ...Solutions - Volta Yarn Version Errors - Pin yarn version in the project root. ...

(QB_NEW_EN)


[grammar] ~245-~245: There might be a mistake here.
Context: ...rn ``` - Module Resolution Errors - Build the kleros-app package first. ...

(QB_NEW_EN)


[grammar] ~252-~252: There might be a mistake here.
Context: ... ``` - Environment Variable Errors - Ensure all required variables are presen...

(QB_NEW_EN)


[grammar] ~258-~258: There might be a mistake here.
Context: ... - **Graph Node Fulltext Search Errors** - Remove@fulltext` directives from the s...

(QB_NEW_EN)


[grammar] ~296-~296: There might be a mistake here.
Context: ...ost:8000/). - Simulate Task Not Found - Run tests: `yarn workspace @kleros/klero...

(QB_NEW_EN)


[grammar] ~297-~297: There might be a mistake here.
Context: ...imulate Task Not Found** - Run tests: yarn workspace @kleros/kleros-v2-contracts test - Use dispute bot: `yarn workspace @kleros...

(QB_NEW_EN)


[grammar] ~298-~298: There might be a mistake here.
Context: ...v2-contracts test - Use dispute bot:yarn workspace @kleros/kleros-v2-contracts bot:disputor` - Or simulate disputes via the web interfa...

(QB_NEW_EN)

🪛 markdownlint-cli2 (0.17.2)
README.md

77-77: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


81-81: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


94-94: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


241-241: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


248-248: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


261-261: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


275-275: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


287-287: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (2)
web/src/hooks/useCoinPrice.tsx (1)

16-21: Good addition: exposing loading and error states from the hook.

Surfacing isLoading and error aligns the hook with React Query conventions and enables proper UI fallbacks upstream. No issues with the destructuring itself.

web/src/pages/Courts/CourtDetails/Stats/index.tsx (1)

71-73: Spinner fallback path looks good.

Returning a single, centered <Spinner /> while either source is loading is appropriate and keeps the UI simple.

@ManiBAJPAI22 ManiBAJPAI22 marked this pull request as ready for review August 22, 2025 09:16
@ManiBAJPAI22 ManiBAJPAI22 requested a review from a team as a code owner August 22, 2025 09:16
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