Skip to content

Conversation

@ali-0507
Copy link

@ali-0507 ali-0507 commented Aug 23, 2025

Solve Issue no #197

Summary

This PR fixes the empty state issue in the Issues/PRs tab.
Now, instead of showing an empty table with pagination, the UI displays
a clear message when no data is available.

Changes Made

  • Added conditional rendering in Issues.tsx.
  • Show "No issues found" or "No pull requests found" message.
  • Table + pagination now render only when data exists.

Testing

  • Tested locally using a dummy GitHub ID and personal access token in .env.
  • The app now fetches data correctly without exposing secrets.
    Screenshot_24-8-2025_0913_localhost

Summary by CodeRabbit

  • New Features
    • Added tab-aware empty-state messaging in the Tracker list, showing clear messages when no results are found for issues or pull requests.
    • Improved UX by hiding the table and pagination when no results are available, reducing visual clutter.
    • No changes to normal behavior: when results exist, the same table and pagination are displayed as before.

@netlify
Copy link

netlify bot commented Aug 23, 2025

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit e202b35
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/68aa0fa9e45ad80008acf871
😎 Deploy Preview https://deploy-preview-199--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
Contributor

coderabbitai bot commented Aug 23, 2025

Walkthrough

Conditional UI update in Tracker page: if the filtered list is empty, render a centered, tab-specific empty-state message; otherwise render the existing table with pagination. Also standardizes import quotes to single quotes. No changes to exports.

Changes

Cohort / File(s) Summary
Tracker empty state & formatting
src/pages/Tracker/Tracker.tsx
Add conditional rendering for empty-state message (tab-aware for issues vs pull requests); retain existing table with pagination when data exists; switch import quotes to single quotes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant TrackerPage as Tracker Page
  participant UI as UI Renderer

  User->>TrackerPage: Open tab (Issues/PRs)
  TrackerPage->>TrackerPage: Compute currentFilteredData
  alt currentFilteredData.length == 0
    TrackerPage->>UI: Render centered empty-state (tab-specific text)
  else
    TrackerPage->>UI: Render Table (Title, Repository, State, Created, Pagination)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit peeked at lists so bare,
“No issues! No PRs!”—empty air.
If data hops in, tables appear,
With rows that march from there to here.
Till then I munch my lettuce leaf—
UI serene, succinct, and brief. 🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/pages/Tracker/Tracker.tsx (1)

173-179: UI Token Field Still Required; Implement Env Fallback or Remove

We ran searches across all TS/TSX files and confirmed there is no usage of import.meta.env.VITE_GITHUB_TOKEN or process.env.REACT_APP_GITHUB_TOKEN/ID. The useGitHubAuth hook unconditionally manages token via React state, and the Tracker page always renders a required PAT input. This conflicts with the PR’s stated goal of “moved GitHub ID & Token to environmental variable.”

Recommendations:

  • Gate or hide the Personal Access Token field when an environment token is present. For example:
    // src/pages/Tracker/Tracker.tsx
    const envToken = import.meta.env.VITE_GITHUB_TOKEN || '';
    
    return (
      <>
        {!envToken && (
          <TextField
            label="Personal Access Token"
            value={token}
            onChange={e => setToken(e.target.value)}
            type="password"
            required
            sx={{ flex: 1, minWidth: 150 }}
          />
        )}
        {/* use envToken || token when calling Octokit */}
      </>
    );
  • Or remove the front-end token input entirely and implement a backend-mediated auth flow (OAuth App or GitHub App with server exchange).
  • Security reminder: Vite/CRA env vars are baked into the client bundle and are not secure storage for real PATs. A backend proxy or OAuth exchange is required for any production-grade authentication.

Please update src/hooks/useGitHubAuth.ts (lines 5–7) and src/pages/Tracker/Tracker.tsx (around lines 173–179) to reflect one of the above approaches.

🧹 Nitpick comments (7)
src/pages/Tracker/Tracker.tsx (7)

282-282: Use theme palette instead of hard-coded gray for better theming accessibility.

Hard-coding “gray” can clash in dark mode or custom themes. Prefer palette tokens.

-            <Box textAlign="center" my={4} color="gray">
+            <Box textAlign="center" my={4} sx={{ color: theme.palette.text.secondary }}>

317-318: Show owner/repo for clarity and parity with ContributorProfile.

This currently shows only the repo name. Displaying owner/repo is more informative and matches ContributorProfile.tsx.

-                {item.repository_url.split("/").slice(-1)[0]}
+                {item.repository_url.split('/').slice(-2).join('/')}

38-46: Unify item type to reflect both Issues Search and Pulls API shapes.

Add an optional merged_at to accommodate PR items coming from the Pulls API and avoid any casts downstream.

 interface GitHubItem {
   id: number;
   title: string;
   state: string;
   created_at: string;
-  pull_request?: { merged_at: string | null };
+  // For PRs from Pulls API
+  merged_at?: string | null;
+  // For items originating from Search Issues API
+  pull_request?: { merged_at?: string | null };
   repository_url: string;
   html_url: string;
 }

284-287: Clarify empty-state copy when client-side filters are active.

When filters are applied, “No X found for this user.” can be misleading if other pages might contain matches. Consider a page-aware message.

-           {tab === 0
-             ? "No issues found for this user."
-             : "No pull requests found for this user."}
+           {filtersActive
+             ? (tab === 0
+                 ? "No matching issues on this page. Adjust filters or try a different page."
+                 : "No matching pull requests on this page. Adjust filters or try a different page.")
+             : (tab === 0
+                 ? "No issues found for this user."
+                 : "No pull requests found for this user.")}

Add once near your state hooks:

const filtersActive =
  (tab === 0 ? issueFilter !== 'all' : prFilter !== 'all') ||
  !!searchTitle || !!selectedRepo || !!startDate || !!endDate;

74-80: Reset to the first page when filters change to reduce “empty current page” confusion.

Without this, narrowing filters while on a later page can yield an empty-state even if earlier pages have matches.

   const [endDate, setEndDate] = useState("");
 
+  // Jump back to page 0 whenever filters change
+  useEffect(() => {
+    setPage(0);
+  }, [issueFilter, prFilter, searchTitle, selectedRepo, startDate, endDate]);

327-334: Pagination count vs. client-side filtering can mislead users.

count={totalCount} reflects server totals, but rows are filtered per-page on the client. Consider:

  • Hiding pagination when filtersActive && currentFilteredData.length === 0, or
  • Keeping pagination but acknowledging page-level emptiness in the empty-state message (see prior comment), or
  • Moving filters server-side so count reflects filtered totals.

88-93: Minor: avoid potential double fetch on submit when page != 0.

handleSubmit calls fetchData and also sets page(0), which triggers the useEffect fetch—leading to two requests when the current page is not 0.

-  const handleSubmit = (e: React.FormEvent<HTMLFormElement>): void => {
+  const handleSubmit = (e: React.FormEvent<HTMLFormElement>): void => {
     e.preventDefault();
-    setPage(0);
-    fetchData(username, 1, ROWS_PER_PAGE);
+    const was = page;
+    setPage(0);
+    if (was === 0) {
+      fetchData(username, 1, ROWS_PER_PAGE);
+    }
   };

Alternative: centralize all fetches in event handlers (submit/page change) and remove the useEffect fetch, or track a submittedUsername to trigger the effect intentionally.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cda5a3a and e202b35.

📒 Files selected for processing (1)
  • src/pages/Tracker/Tracker.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/pages/Tracker/Tracker.tsx (1)
src/pages/ContributorProfile/ContributorProfile.tsx (2)
  • pr (74-88)
  • ContributorProfile (11-95)
🔇 Additional comments (1)
src/pages/Tracker/Tracker.tsx (1)

281-289: Empty-state UX is a clear improvement.

Conditional rendering avoids an empty table/pagination and gives users immediate, contextual feedback. Nicely done.

Also applies to: 290-337

Comment on lines +320 to +321
{item.pull_request?.merged_at ? "merged" : item.state}
</TableCell>
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Merged status detection may be unreliable depending on the source API.

If PRs come from GitHub’s Search Issues API, pull_request.merged_at is not included; merged_at exists on PR objects from the Pulls API. Current logic could under-report “merged”.

-                {item.pull_request?.merged_at ? "merged" : item.state}
+                {(item as any).merged_at || item.pull_request?.merged_at ? 'merged' : item.state}

Follow-up:

  • If you’d rather avoid any, extend the type (see next comment) and use item.merged_at ?? item.pull_request?.merged_at.
  • Please verify where prs are fetched/normalized.

Run this to locate data shaping and confirm the available fields:


🏁 Script executed:

#!/bin/bash
# Inspect how PRs are fetched and whether merged_at is present or mapped.
rg -nP -C3 --type=ts --type=tsx '\b(search/issues|pulls)\b|merged_at|pull_request' src

Length of output: 116


🏁 Script executed:

#!/bin/bash
# Locate the Tracker.tsx file
fd --extension tsx Tracker.tsx

# Find all occurrences of merged_at with context
grep -R -n -C3 "merged_at" src

# Find all occurrences of pull_request with context
grep -R -n -C3 "pull_request" src

# Print code around the relevant snippet in Tracker.tsx (lines 250-360)
sed -n '250,360p' src/pages/Tracker/Tracker.tsx

Length of output: 6937


🏁 Script executed:

#!/bin/bash
# Locate where data is fetched/normalized in Tracker.tsx
grep -R -n -C2 "useEffect" src/pages/Tracker/Tracker.tsx
grep -R -n -C2 "fetch(" src/pages/Tracker/Tracker.tsx
grep -R -n -C2 "axios" src/pages/Tracker/Tracker.tsx
grep -R -n -C2 "graphql" src/pages/Tracker/Tracker.tsx

Length of output: 468


🏁 Script executed:

#!/bin/bash
# Locate the fetchData function and inspect its implementation
grep -R -n -C3 "fetchData" src/pages/Tracker/Tracker.tsx

# Print the top of the file to view data fetching logic (lines 1–150)
sed -n '1,150p' src/pages/Tracker/Tracker.tsx

Length of output: 4316


🏁 Script executed:

#!/bin/bash
# Locate useGitHubData hook file
fd useGitHubData src/hooks

# Print first 200 lines of useGitHubData implementation
sed -n '1,200p' src/hooks/useGitHubData.ts

Length of output: 2033


Ensure merged status detection is accurate by fetching PRs via the Pull Requests API
The current useGitHubData.fetchData implementation calls GitHub’s GET /search/issues endpoint for both issues and PRs. That endpoint’s pull_request objects do not include merged_at — only url, html_url, diff_url, and patch_url — so

{item.pull_request?.merged_at ? "merged" : item.state}

will always fall back to item.state, under-reporting merged PRs (github.com).

Action items:

  • src/hooks/useGitHubData.ts
    • For PRs (type === 'pr'), replace or augment fetchPaginated with a call to octokit.rest.pulls.list (or octokit.pulls.list) so each PR record includes its real merged_at value (github.com).
  • src/pages/Tracker/Tracker.tsx
    • Extend the GitHubItem type to match the Pull Requests API shape (e.g. add merged_at: string | null at top level or under pull_request).
    • Update the status cell and filter logic to use that actual merged_at field for detecting merged PRs.

Once PRs are fetched through the Pulls API (or via a GraphQL query for mergedAt), item.pull_request?.merged_at will be populated correctly and merged PRs will render as “merged.”

🤖 Prompt for AI Agents
In src/pages/Tracker/Tracker.tsx around lines 320-321 and
src/hooks/useGitHubData.ts, the UI checks item.pull_request?.merged_at but
search/issues does not return merged_at; update fetching for PRs to use the
Pulls API so each PR includes merged_at (e.g. in src/hooks/useGitHubData.ts,
when type === 'pr' call octokit.rest.pulls.list or equivalent paginated pulls
endpoint instead of GET /search/issues), then extend the GitHubItem type in
Tracker.tsx to include merged_at (either at top-level for PR items or under
pull_request) and change the status cell and any filter logic to read that
merged_at field to determine "merged" status.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant