Skip to content

feat: Add Reset Filters and Clear Persisted Session Actions in Tracker Dashboard#398

Open
surjeetkumar8006 wants to merge 5 commits into
GitMetricsLab:mainfrom
surjeetkumar8006:feat-reset-filters-logout
Open

feat: Add Reset Filters and Clear Persisted Session Actions in Tracker Dashboard#398
surjeetkumar8006 wants to merge 5 commits into
GitMetricsLab:mainfrom
surjeetkumar8006:feat-reset-filters-logout

Conversation

@surjeetkumar8006
Copy link
Copy Markdown
Contributor

@surjeetkumar8006 surjeetkumar8006 commented May 22, 2026

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 a logout function to clear credentials from sessionStorage and reset local authentication states.
  • src/hooks/useGitHubData.ts: Added a clearData function to clear issues, pull requests, stats, and data error states from the dashboard's view.
  • src/pages/Tracker/Tracker.tsx:
    • Implemented handleResetFilters to restore all filter inputs to default values and remove active filter settings from localStorage.
    • Implemented handleLogout which triggers session logout, resets fetched issues/PRs, and clears active filters in one action.
    • Added a Logout button next to the "Fetch Data" button inside the authentication form (rendered only when session data exists).
    • Added a Reset Filters button inside the filters row (rendered only when non-default filters are active).

Checklist

  • Tested the changes locally
  • Verified that "Logout" clears credentials and resets dashboard state
  • Verified that "Reset Filters" removes all filters from storage and resets the UI
  • Verified that the application builds successfully without TypeScript or compile errors

Summary by CodeRabbit

  • New Features

    • Added logout button to clear authentication credentials and reset session data.
    • Added reset filters button to clear search parameters, date ranges, and view state.
  • Chores

    • Updated package naming configuration.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 22, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 17d6c79
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a11a23593765e000898fe02
😎 Deploy Preview https://deploy-preview-398--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 22, 2026

Warning

Review limit reached

@surjeetkumar8006, we couldn't start this review because you've used your available PR reviews for now.

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 @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 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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6a04d0cb-a41f-471e-a5b5-c24983fa5003

📥 Commits

Reviewing files that changed from the base of the PR and between a1fc751 and 17d6c79.

📒 Files selected for processing (4)
  • src/components/Navbar.tsx
  • src/components/__test__/Navbar.test.tsx
  • src/hooks/useGitHubAuth.ts
  • src/hooks/useGitHubData.ts
📝 Walkthrough

Walkthrough

This 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.

Changes

Session Management and Filter Reset

Layer / File(s) Summary
Package metadata normalization
package.json
Package name updated from "GitHub Tracker" to "github-tracker" (lowercase hyphenated format).
Auth hook sessionStorage persistence and logout
src/hooks/useGitHubAuth.ts
useEffect synchronizes username/token to sessionStorage keys (tracker_username, tracker_token); new logout function clears auth state and removes sessionStorage entries; getOctokit simplified to return existing instance directly.
Data hook clear capability
src/hooks/useGitHubData.ts
New clearData callback invalidates in-flight requests via request-id ref and resets all state (issues, PRs, totals, error, rateLimited) to defaults.
Tracker page logout and reset UI
src/pages/Tracker/Tracker.tsx
Extracts logout from useGitHubAuth and clearData from useGitHubData; adds handleLogout to execute logout, clearData, then reset filters; adds handleResetFilters to clear local component state and localStorage entries; conditionally renders Logout button when authenticated and Reset Filters button when state differs from defaults.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • GitMetricsLab/github_tracker#397: Implements the reset-filters and session-clear features by adding logout capability to useGitHubAuth, clearData to useGitHubData, and UI handlers to Tracker.tsx.

Possibly related PRs

  • GitMetricsLab/github_tracker#293: Adds sessionStorage persistence, logout, and clearData integration alongside auth and filter reset UI changes in the same hook and component files.
  • GitMetricsLab/github_tracker#238: Modifies useGitHubAuth and Tracker auth flow handling around optional token state; this PR's logout/clearData changes are directly adjacent to that PR's PAT-optional implementation.
  • GitMetricsLab/github_tracker#255: Touches useGitHubData and Tracker.tsx to refactor data fetching and reset behavior; this PR's clearData and reset UI are direct integration points with those same files.

Suggested labels

type:feature

Poem

🐰 A logout springs forth with gleaming care,
sessionStorage whispers secrets fair,
Clear the slate, reset the view,
Filters fresh, the session's through!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding Reset Filters and Clear Persisted Session Actions to the Tracker Dashboard, which aligns with the changeset's core objectives.
Description check ✅ Passed The description covers all required template sections, including Related Issue, Description, Changes Made, and Type of Change. The author provided comprehensive details about modifications and included testing verification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@surjeetkumar8006
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@surjeetkumar8006
Copy link
Copy Markdown
Contributor Author

Implemented all requested improvements and addressed automated review feedback.
The PR is now updated, tested locally, and ready for final review/merge. Thanks!

@surjeetkumar8006
Copy link
Copy Markdown
Contributor Author

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!

@mehul-m-prajapati
Copy link
Copy Markdown
Collaborator

@surjeetkumar8006 : resolve conflicts

@surjeetkumar8006
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 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 win

Fix useGitHubAuth hook (undefined symbols + broken error contract)

  • src/hooks/useGitHubAuth.ts references useEffect, octokit, and setError without importing/declaring them.
  • The hook no longer returns error, but src/pages/Tracker/Tracker.tsx consumes error: authError → contract break.
  • The session persistence effect removes tracker_username / tracker_token from sessionStorage on mount because it never hydrates username/token from 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

📥 Commits

Reviewing files that changed from the base of the PR and between fb173e1 and a1fc751.

📒 Files selected for processing (4)
  • package.json
  • src/hooks/useGitHubAuth.ts
  • src/hooks/useGitHubData.ts
  • src/pages/Tracker/Tracker.tsx

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

All requested changes and review feedback have been addressed successfully.
The latest fixes have been pushed, all checks are passing, and there are no merge conflicts remaining.

The PR has been tested locally and is now ready for final review and merge. Thank you!

@surjeetkumar8006
Copy link
Copy Markdown
Contributor Author

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!

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.

3 participants