fix(web): surface paper stats loading errors#141
Conversation
|
Deployment failed with the following error: Learn More: https://vercel.com/hirokis-projects-afd618c7?upgradeToPro=build-rate-limit |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the robustness and user experience of the paper statistics display. It ensures that users receive clear feedback when statistics fail to load, provides more accurate loading state indications, and prevents common issues related to asynchronous operations and component lifecycle management in React. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves the user experience by handling and surfacing errors from the paper stats API call. It also correctly keeps the loading indicator active until the fetch is complete and attempts to prevent state updates on unmounted components.
I've left a couple of comments for improvement:
- A suggestion to deduplicate a repeated error string for better maintainability.
- A more critical point about the incomplete implementation of the cancellation logic, which doesn't fully prevent state updates on unmount as intended.
Additionally, while the error handling logic has been added, there are no corresponding tests to verify these new error states. Adding tests for API failures (e.g., 401, 403, 404 responses) would make this change more robust and prevent future regressions.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Summary
Validation
Split out of #138 to keep review scoped to the paper detail stats UX fix.
Greptile Summary
このPRは2つの独立した改善をまとめています:(1)
paper-detail-client.tsxにおけるfetchStatsのリファクタリングでエラーハンドリングとローディング状態の管理を改善、(2)users.tsの検索キャッシュを真の LRU(Least Recently Used)実装に改善し、テストを高速化。主な変更点:
fetchStatsが HTTP エラーステータス(401/403/404 など)をstatsErrorステートに反映するよう改善setStats(null)を呼び出し、古いデータとエラーメッセージが同時表示される問題を修正mountedRefとisCancelledコールバックを組み合わせたcanUpdateStateでアンマウント後のステート更新を防止applyCountedViewからの再フェッチがwithLoading: falseでサイレント実行されるよう変更し、既存のローディング状態を上書きしない意図を明示getCachedResultsでキャッシュヒット時に Map の末尾へ再挿入することで真の LRU 昇格を実装MAX_CACHE_SIZE=3の小さなキャッシュで再実装し、1002 リクエスト送信を廃止指摘事項:
finallyブロックがwithLoading: falseのフェッチ完了時にもsetStatsLoading(false)を呼び出すため、初回ロードと再フェッチが並行した場合にローディングインジケーターが早期消灯してしまう可能性があるConfidence Score: 3/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant C as PaperDetailClient participant E1 as useEffect(stats) participant E2 as useEffect(view tracking) participant API as API Server C->>E1: paper.id が確定 E1->>C: fetchStats({ withLoading: true }) C->>C: statsLoading = true C->>API: GET /api/papers/:id/stats C->>E2: paper.id が確定 E2->>API: POST /api/papers/:id/views API-->>E2: { counted: true } E2->>C: applyCountedView() C->>C: publicViewCount + 1 C->>C: fetchStats({ withLoading: false }) ← サイレント再フェッチ C->>API: GET /api/papers/:id/stats Note over C,API: バックグラウンドフェッチが先に完了した場合 API-->>C: stats data (再フェッチ) C->>C: finally: setStatsLoading(false) ⚠️ 初回ロード中なのに false に API-->>C: stats data (初回フェッチ) C->>C: setStats(data) C->>C: finally: setStatsLoading(false)Prompt To Fix All With AI
Last reviewed commit: a89a874