fix(baseball): stop infinite loading on Events when coach has zero teams (#444)#641
Conversation
…444) EventsClient initialized `loading` to true but only ran fetchEvents() when teams.length > 0. A showcase coach with no teams never cleared loading, so the Events page was stuck on a skeleton forever with a "Loading…" subtitle. Add an else branch: when auth is ready (authLoading === false) and the coach has no teams, reset events to [] and set loading false so the page falls through to the existing honest empty state. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017VUauUXsm9aXegShmpJi5n
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
PR Summary by QodoFix Events infinite loading when coach has zero teams
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
93 rules 1. No memory doc update
|
| } else if (!authLoading) { | ||
| // Auth is ready but the coach has no teams (e.g. a new showcase org): | ||
| // clear the skeleton and fall through to the honest empty state instead | ||
| // of spinning on `loading` forever. | ||
| setEvents([]); | ||
| setLoading(false); |
There was a problem hiding this comment.
1. No memory doc update 📘 Rule violation ⚙ Maintainability
This change alters user-visible behavior by clearing the Events loading skeleton when `teams.length === 0, but there is no corresponding update to memory/features/*` docs and no explicit comment explaining why a doc update is unnecessary.
Agent Prompt
## Issue description
A user-visible behavior change was made (coaches with zero teams now exit loading and see the empty state), but the `memory/features/*` documentation was not updated and there is no explicit in-code rationale for omitting a doc update.
## Issue Context
PR adds a new branch that sets `events` to `[]` and `loading` to `false` when auth is ready and `teams.length === 0`, changing what users see on the Events page.
## Fix Focus Areas
- src/app/baseball/(dashboard)/dashboard/events/EventsClient.tsx[174-179]
- memory/features/calendar-events.md[91-98]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| } else if (!authLoading) { | ||
| // Auth is ready but the coach has no teams (e.g. a new showcase org): | ||
| // clear the skeleton and fall through to the honest empty state instead | ||
| // of spinning on `loading` forever. | ||
| setEvents([]); | ||
| setLoading(false); | ||
| } |
There was a problem hiding this comment.
2. Teams-loading misread as empty 🐞 Bug ≡ Correctness
The new else if (!authLoading) branch sets loading false whenever teams.length === 0, even if teams are still being fetched, so coaches with teams can briefly see the “No upcoming events” empty state before teams arrive. This occurs because useTeams() loads teams asynchronously and exposes isLoading, but EventsClient doesn’t gate the empty-teams path on it.
Agent Prompt
### Issue description
`EventsClient` treats `teams.length === 0` as a final state once `authLoading` is false, but `useTeams()` begins with `teams=[]` and fetches teams asynchronously. This can show the empty state briefly for coaches who actually have teams.
### Issue Context
`useTeams()` already exposes `isLoading`, and other pages (e.g. OrgDashboard) use it to avoid falling through to an empty state before team data is loaded.
### Fix Focus Areas
- src/app/baseball/(dashboard)/dashboard/events/EventsClient.tsx[102-181]
### Suggested change
1. Read `isLoading` from `useTeams()`:
- `const { teams, isLoading: teamsLoading } = useTeams();`
2. Update the effect to avoid the empty-teams branch while teams are still loading:
- If `teamsLoading` is true, do nothing (keep skeleton / loading state).
- Only when `!teamsLoading && !authLoading && teams.length === 0`, clear events and set `loading` false.
3. Add `teamsLoading` to the effect dependency array.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| } else if (!authLoading) { | ||
| // Auth is ready but the coach has no teams (e.g. a new showcase org): | ||
| // clear the skeleton and fall through to the honest empty state instead | ||
| // of spinning on `loading` forever. | ||
| setEvents([]); | ||
| setLoading(false); | ||
| } |
There was a problem hiding this comment.
3. Stale fetcherror on no-teams 🐞 Bug ☼ Reliability
When teams.length === 0, the new branch sets events and loading but does not reset fetchError, so an old fetch error banner can persist even though the UI is now in an expected no-teams empty state. This can happen if a fetch previously failed and teams later becomes empty in the same session.
Agent Prompt
### Issue description
The `teams.length === 0` path sets `events=[]` and `loading=false` but leaves any previous `fetchError` intact, so the error banner can remain visible in an expected empty state.
### Issue Context
`fetchError` is rendered regardless of `loading`, and is only cleared inside `fetchEvents()`.
### Fix Focus Areas
- src/app/baseball/(dashboard)/dashboard/events/EventsClient.tsx[133-181]
- src/app/baseball/(dashboard)/dashboard/events/EventsClient.tsx[371-399]
### Suggested change
In the `teams.length === 0` branch (and/or alongside the `setEvents([])` call), add `setFetchError(null)` so the UI doesn’t retain a stale error when no fetch is being performed.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
🤖 Mission Control — PR summary Changes: Clears the Events page loading state when a (showcase) coach has zero teams, so it shows the empty state instead of an infinite skeleton. Closes #444. |
What & why
EventsClientinitializedloadingtotruebut only calledfetchEvents()whenteams.length > 0. A showcase coach with no teams never cleared loading, leaving the Events page stuck on a skeleton forever with a perpetual "Loading…" subtitle (broken empty state for new showcase orgs).Fix
One-file guard in
src/app/baseball/(dashboard)/dashboard/events/EventsClient.tsx. In the fetch effect, when auth is ready (authLoading === false) andteams.length === 0, reseteventsto[]and setloadingfalse so the page falls through to the existing honest empty state. No new fetch, no other files touched.Acceptance criteria
teams.length === 0, setloadingfalse and show the empty state.🤖 Generated with Claude Code