add:add about page content, start with github-api#15
Conversation
📝 WalkthroughWalkthroughA new GitHub project badge component ( Changes
Sequence DiagramsequenceDiagram
participant Component as GitHubProjectBadge
participant Hook as useGitHubProject Hook
participant GH as GitHub API
participant UI as React Rendering
Component->>Hook: owner, repo
activate Hook
Hook->>GH: fetch repository data
Hook->>GH: fetch user profile data
Note over Hook: Concurrent requests
par
GH-->>Hook: repository response
and
GH-->>Hook: profile response
end
Hook->>Hook: Normalize & merge data
Hook->>Hook: Update state (data, isLoading)
deactivate Hook
Hook-->>Component: { data, isLoading, error }
Component->>UI: Render badge with fetched metadata
activate UI
alt isLoading
UI->>UI: Show placeholder text
else variant: compact
UI->>UI: Render star link
else variant: detailed
UI->>UI: Render profile card with avatar & bio
end
deactivate UI
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
app/client/src/hooks/useGitHubProject.ts (1)
48-50: Reset stale project data when starting a new fetch.When
ownerorrepochanges, the fetch begins by settingsetIsLoading(true)andsetError(null)at lines 48-49, but the previousdatapersists in state. While loading, stale repository metadata remains visible. If the request fails, old data lingers alongside the error message.🧹 Small fix
const fetchProject = async () => { setIsLoading(true) setError(null) + setData(null)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/client/src/hooks/useGitHubProject.ts` around lines 48 - 50, The hook useGitHubProject leaves previous repository data visible when starting a new fetch; before calling fetchProject (when owner or repo changes) clear stale data by calling the data state setter (e.g., setData(null) or setProject(null)) together with setIsLoading(true) and setError(null). Update the effect or fetch handler that currently calls setIsLoading and setError to also reset the stored data (reference: useGitHubProject, setIsLoading, setError, setData/setProject) so the UI doesn't show stale metadata during loading or after a failed request.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/client/src/components/ui/GitHubProjectBadge.tsx`:
- Around line 24-25: The hook call in GitHubProjectBadge only destructures data
and isLoading from useGitHubProject, so failed requests show as "0 stars";
update the call to also destructure error (e.g., const { data, isLoading, error
} = useGitHubProject(owner, repo)) and then change the render logic in both the
compact and detailed variants (the JSX that currently shows star count at lines
around the compact and detailed display) to: while isLoading keep the loader, if
error show an explicit unavailable fallback (e.g., "—" or "N/A" / "unavailable")
instead of 0, otherwise show data.stars; apply the same conditional check in
both compact and detailed render branches to avoid misleading star values.
In `@app/client/src/hooks/useGitHubProject.ts`:
- Around line 43-61: Add a module-level in-flight + TTL cache (e.g., a Map
called githubProjectCache keyed by `${owner}/${repo}`) and use it inside the
useGitHubProject hook (and its inner fetchProject) so simultaneous mounts share
the same Promise and recent results are returned without new network calls; on
hook mount check the cache entry: if entry exists and not expired return its
data (or await its stored promise), if a live promise exists return/await it,
otherwise create the fetch Promise, store it in githubProjectCache immediately,
and on resolution store the resolved data with an expiresAt timestamp (TTL like
30s) and clear or replace on error; keep per-hook AbortController/ignore flags
to let callers ignore late results but do not cancel the shared in-flight
Promise. Ensure you reference useGitHubProject and fetchProject when
adding/using githubProjectCache, and update setIsLoading/setError/setProject
based on the (possibly cached) result.
---
Nitpick comments:
In `@app/client/src/hooks/useGitHubProject.ts`:
- Around line 48-50: The hook useGitHubProject leaves previous repository data
visible when starting a new fetch; before calling fetchProject (when owner or
repo changes) clear stale data by calling the data state setter (e.g.,
setData(null) or setProject(null)) together with setIsLoading(true) and
setError(null). Update the effect or fetch handler that currently calls
setIsLoading and setError to also reset the stored data (reference:
useGitHubProject, setIsLoading, setError, setData/setProject) so the UI doesn't
show stale metadata during loading or after a failed request.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bb173f2d-2073-416f-a131-acc07623b08c
⛔ Files ignored due to path filters (2)
app/client/public/favicon.svgis excluded by!**/*.svgapp/client/public/img/naturalsql.pngis excluded by!**/*.png
📒 Files selected for processing (4)
app/client/src/components/ui/GitHubProjectBadge.tsxapp/client/src/hooks/useGitHubProject.tsapp/client/src/layout/Footer.tsxapp/client/src/pages/About.tsx
Summary by CodeRabbit
Release Notes
New Features
Documentation