Skip to content

Fix: Implement filter and auth credentials persistence on page refresh (#291)#293

Open
surjeetkumar8006 wants to merge 4 commits into
GitMetricsLab:mainfrom
surjeetkumar8006:fix-filter-persistence
Open

Fix: Implement filter and auth credentials persistence on page refresh (#291)#293
surjeetkumar8006 wants to merge 4 commits into
GitMetricsLab:mainfrom
surjeetkumar8006:fix-filter-persistence

Conversation

@surjeetkumar8006
Copy link
Copy Markdown

@surjeetkumar8006 surjeetkumar8006 commented May 17, 2026

Description

This PR resolves issue #291 by implementing localStorage persistence for the tracking dashboard filters and GitHub authentication credentials.

Previously, refreshing the page would reset all selected filters and require the user to re-enter their GitHub username and Personal Access Token.

Changes Made:

  • src/pages/Tracker/Tracker.tsx: Initialized filter states (tab, page, issue/PR state filters, search queries, and dates) using localStorage.getItem and added a useEffect to sync them.
  • src/hooks/useGitHubAuth.ts: Ensured the GitHub username and Token are also stored and retrieved from localStorage so users stay authenticated on reload.
  • tsconfig.app.json: Removed an unsupported TypeScript compiler option to resolve VS Code syntax warnings.

Related Issue

Fixes #291

Checklist

  • Tested the changes locally
  • Verified that filters persist after page reload
  • Verified that authentication credentials persist after page reload

Summary by CodeRabbit

  • New Features
    • GitHub authentication credentials are now automatically saved and restored across sessions.
    • Tracker page configuration, including filters, tabs, pagination, and search queries, is now persisted between sessions for a seamless user experience.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 17, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 494453d
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a0980c5fa36a40008681be0
😎 Deploy Preview https://deploy-preview-293--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Warning

Rate limit exceeded

@surjeetkumar8006 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 37 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 18e30a5b-fa08-493b-81e9-69e3d981644a

📥 Commits

Reviewing files that changed from the base of the PR and between 4b4e5b3 and 494453d.

📒 Files selected for processing (1)
  • src/hooks/useGitHubAuth.ts
📝 Walkthrough

Walkthrough

This PR adds localStorage persistence to GitHub authentication state and tracker UI state (filters, pagination, tabs). Users' selections now survive page refreshes, resolving the filter loss bug reported in issue #291. Two hooks are updated to read prior state on mount and save updates via useEffect.

Changes

localStorage State Persistence

Layer / File(s) Summary
GitHub authentication state persistence
src/hooks/useGitHubAuth.ts
The useGitHubAuth hook initializes username and token from localStorage instead of empty strings, and persists both values back to localStorage whenever they change via useEffect.
Tracker UI state persistence
src/pages/Tracker/Tracker.tsx
The tracker page initializes tab, page, and all filter fields from localStorage instead of fixed defaults, and saves all state changes back to localStorage via useEffect.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

gssoc25, level2

Poem

🐇 A rabbit hops through time with glee,
Remembering each choice with localStorage!
Filters saved, state restored with care—
No more resets in the refreshed air.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: implementing localStorage persistence for filters and authentication credentials on page refresh.
Description check ✅ Passed The description provides context, lists specific changes, links to the related issue, and includes a testing checklist, mostly following the template structure.
Linked Issues check ✅ Passed The PR successfully implements localStorage persistence for tracking dashboard filters and GitHub credentials, directly addressing the bug in issue #291 where filters reset on page refresh.
Out of Scope Changes check ✅ Passed The changes in tsconfig.app.json (removing unsupported compiler option) and the core filter/auth persistence changes are all within scope of issue #291.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 5-6: The hook useGitHubAuth is storing sensitive GitHub
credentials in localStorage via the state initializers for username and token
(the useState calls that read 'tracker_username' and 'tracker_token'), which is
insecure; replace this client-side persistence with a server-side session flow
where the PAT is never stored in browser storage and is instead kept in an
httpOnly cookie or backend session and accessed via authenticated API endpoints
from the frontend; if a backend session cannot be implemented immediately,
change the storage fallback to sessionStorage (read/write
'tracker_username'/'tracker_token' from sessionStorage) as a temporary
mitigation or implement client-side encryption before persisting, but prefer
updating the authentication flow in useGitHubAuth to delegate storage and token
refresh to the server.
🪄 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: da78dd20-77df-4f11-86fd-cc0aa3ed58e1

📥 Commits

Reviewing files that changed from the base of the PR and between a2452b3 and 4b4e5b3.

📒 Files selected for processing (3)
  • src/hooks/useGitHubAuth.ts
  • src/pages/Tracker/Tracker.tsx
  • tsconfig.app.json

Comment thread src/hooks/useGitHubAuth.ts Outdated
@surjeetkumar8006
Copy link
Copy Markdown
Author

Updated the PR based on review feedback:

  • Replaced localStorage with sessionStorage for GitHub credentials
  • Resolved the Octokit import issue
  • Re-tested filter persistence and authentication flow

All checks are now passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: Filter persistence broken on page refresh

2 participants