634 commit 1#685
Conversation
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds token validation to the ChangesAuth Token Validation and Error Display
Sequence DiagramsequenceDiagram
participant Tracker as TrackerComponent
participant Hook as useGitHubAuth
participant GitHub as GitHubAPI
Tracker->>Hook: setToken / setUsername
Hook->>Hook: clear error, recreate Octokit
Note over Hook: debounce 500ms
Hook->>GitHub: GET /user (octokit.request)
GitHub-->>Hook: 200 OK or 401/403 / error
Hook->>Hook: map response to user-facing error or clear
Hook-->>Tracker: expose error / setError / getOctokit
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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
🤖 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.
Inline comments:
In `@src/hooks/useGitHubAuth.ts`:
- Around line 9-16: The useMemo callback in useGitHubAuth currently calls
setError(''), which is a side effect and must be removed; update the hook by
deleting setError('') from the useMemo that creates octokit and instead clear
the error inside the existing validation useEffect (or add a new useEffect) that
watches username and token, calling setError('') only when performing
validation; keep the octokit creation logic (new Octokit({ auth: token }) vs new
Octokit()) in the useMemo that depends on [username, token] so memoization is
preserved and no state updates occur during memo computation.
- Around line 25-52: The validateAuth flow can leave prior octokit requests
completing after a new token is entered, so update the validateAuth effect to
create an AbortController each run, pass controller.signal into
octokit.request('GET /user'), and call controller.abort() in the effect cleanup
to cancel any in-flight request when the timeout/effect re-runs; inside
validateAuth detect aborts (e.g., check for DOMException/aborted error) and
avoid calling setError or setState when aborted, and still clearTimeout/clear
the controller in the existing cleanup so validateAuth and the timeout are both
cancelled correctly.
🪄 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: 13178db0-6f17-4776-9236-166f5ca3ba2d
📒 Files selected for processing (2)
src/hooks/useGitHubAuth.tssrc/pages/Tracker/Tracker.tsx
|
/assign |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Related Issue
Description
This PR fixes authentication error handling on the Tracker page by properly surfacing GitHub authentication failures to users.
Changes Made
Enhanced
useGitHubAuthto expose anerrorstate for authentication-related failures.Added automatic GitHub token validation with a debounce when the token changes.
Implemented validation against GitHub's
GET /userendpoint to verify token authenticity.Added specific handling for common authentication scenarios:
Updated the Tracker page to consume and display
authError.Separated authentication errors from data-fetching errors for clearer user feedback.
User Impact
Users now receive clear and actionable authentication error messages instead of generic data-fetching errors, making it easier to identify and resolve GitHub credential issues.
How Has This Been Tested?
Screenshots (if applicable)
N/A
Type of Change
Summary by CodeRabbit
New Features
Bug Fixes