feat: Add Reset Filters and Clear Persisted Session Actions in Tracker Dashboard#398
feat: Add Reset Filters and Clear Persisted Session Actions in Tracker Dashboard#398surjeetkumar8006 wants to merge 5 commits into
Conversation
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 43 minutes and 7 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, 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 trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR adds session persistence and user logout capability to the GitHub Tracker app. It normalizes the package name, implements sessionStorage persistence for auth credentials in useGitHubAuth, introduces a logout function, adds data clearing via useGitHubData, and wires both into the Tracker page with new Logout and Reset Filters buttons. ChangesSession Management and Filter Reset
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Implemented all requested improvements and addressed automated review feedback. |
|
Hi maintainers, All requested changes and review feedback have been addressed. The PR has been tested locally, all checks are passing, and there are no merge conflicts. This feature adds reset filters and clear session/logout functionality to improve the Tracker dashboard UX. Please review and merge when convenient. Thank you! |
|
@surjeetkumar8006 : resolve conflicts |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/hooks/useGitHubAuth.ts (1)
1-2:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winFix
useGitHubAuthhook (undefined symbols + brokenerrorcontract)
src/hooks/useGitHubAuth.tsreferencesuseEffect,octokit, andsetErrorwithout importing/declaring them.- The hook no longer returns
error, butsrc/pages/Tracker/Tracker.tsxconsumeserror: authError→ contract break.- The session persistence effect removes
tracker_username/tracker_tokenfromsessionStorageon mount because it never hydratesusername/tokenfrom storage.🔧 Proposed fix
-import { useState, useMemo } from 'react'; +import { useState, useMemo, useEffect } from 'react'; import { Octokit } from '`@octokit/core`'; export const useGitHubAuth = () => { const [username, setUsername] = useState(''); const [token, setToken] = useState(''); + const [error, setError] = useState(''); + const octokit = useMemo( + () => (token ? new Octokit({ auth: token }) : new Octokit()), + [token] + ); useEffect(() => { @@ return { username, setUsername, token, setToken, + error, getOctokit, logout, }; };Also add sessionStorage hydration for
username/token(or guard the persistence effect) so stored credentials aren’t deleted on the initial mount.🤖 Prompt for 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. In `@src/hooks/useGitHubAuth.ts` around lines 1 - 2, The hook useGitHubAuth is missing useEffect import, a defined octokit instance, and the setError state setter while also no longer returning error (breaking Tracker which expects error: authError); update imports to include useEffect, add a useState for error with setter setError and ensure the hook returns { error } (or error: authError) to match Tracker, create octokit via useMemo (e.g., const octokit = useMemo(() => new Octokit({ auth: token }), [token]) so it exists when used, and fix the sessionStorage logic by hydrating username and token from sessionStorage on mount (or guard the persistence effect) so the effect that writes/removes tracker_username/tracker_token does not wipe stored credentials immediately; reference useGitHubAuth, useEffect, useMemo, octokit, setError, error/authError, username, token, and sessionStorage when making these changes.
🤖 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 8-19: The effect is clearing sessionStorage on mount because
username/token default to ''; fix by restoring saved credentials into state
before the effect runs: in useGitHubAuth read
sessionStorage.getItem('tracker_username') and
sessionStorage.getItem('tracker_token') and use those values as the initial
state (or set them once on mount via setUsername/setToken) so username/token are
populated before the useEffect that writes/removes keys runs; update the hook
initialization (or add an "initialized" flag) and keep the existing useEffect
logic referencing username and token.
In `@src/hooks/useGitHubData.ts`:
- Around line 242-250: clearData currently increments lastRequestId.current and
resets issues/prs/counts/error/rateLimited but doesn't reset the loading flag,
so if a stale in-flight request's finally block bails on updating (due to
requestId mismatch) loading can remain true; update clearData to also call
setLoading(false) so the spinner is cleared, and ensure this interacts correctly
with the request flow that checks lastRequestId.current in the fetch's finally
block.
---
Outside diff comments:
In `@src/hooks/useGitHubAuth.ts`:
- Around line 1-2: The hook useGitHubAuth is missing useEffect import, a defined
octokit instance, and the setError state setter while also no longer returning
error (breaking Tracker which expects error: authError); update imports to
include useEffect, add a useState for error with setter setError and ensure the
hook returns { error } (or error: authError) to match Tracker, create octokit
via useMemo (e.g., const octokit = useMemo(() => new Octokit({ auth: token }),
[token]) so it exists when used, and fix the sessionStorage logic by hydrating
username and token from sessionStorage on mount (or guard the persistence
effect) so the effect that writes/removes tracker_username/tracker_token does
not wipe stored credentials immediately; reference useGitHubAuth, useEffect,
useMemo, octokit, setError, error/authError, username, token, and sessionStorage
when making these changes.
🪄 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: 96c533c2-7bf2-4e22-a981-b5ff79ac2382
📒 Files selected for processing (4)
package.jsonsrc/hooks/useGitHubAuth.tssrc/hooks/useGitHubData.tssrc/pages/Tracker/Tracker.tsx
|
All requested changes and review feedback have been addressed successfully. The PR has been tested locally and is now ready for final review and merge. Thank you! |
|
Hi @mehul-m-prajapati all requested changes and review feedback have been addressed successfully. The PR is updated, tested locally, all checks are passing, and there are no merge conflicts remaining. Kindly review and merge the PR when convenient. Thank you! |
Description
This PR resolves issue #397 by introducing dedicated UI actions to reset active filters and clear persisted authentication sessions in the Tracker dashboard.
Changes Made
src/hooks/useGitHubAuth.ts: Added alogoutfunction to clear credentials fromsessionStorageand reset local authentication states.src/hooks/useGitHubData.ts: Added aclearDatafunction to clear issues, pull requests, stats, and data error states from the dashboard's view.src/pages/Tracker/Tracker.tsx:handleResetFiltersto restore all filter inputs to default values and remove active filter settings fromlocalStorage.handleLogoutwhich triggers session logout, resets fetched issues/PRs, and clears active filters in one action.Checklist
Summary by CodeRabbit
New Features
Chores