Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 58 additions & 59 deletions src/pages/Tracker/Tracker.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react"
import React, { useState, useEffect } from 'react'
import {
IssueOpenedIcon,
IssueClosedIcon,
Expand Down Expand Up @@ -156,6 +156,7 @@ const Home: React.FC = () => {
const totalCount = tab === 0 ? totalIssues : totalPrs;

return (

<Container maxWidth="lg" sx={{ mt: 4, minHeight: "80vh", color: theme.palette.text.primary }}>
{/* Auth Form */}
<Paper elevation={1} sx={{ p: 2, mb: 4, backgroundColor: theme.palette.background.paper }}>
Expand Down Expand Up @@ -277,65 +278,63 @@ const Home: React.FC = () => {
</Box>
) : (
<Box sx={{ maxHeight: "400px", overflowY: "auto" }}>

<TableContainer component={Paper}>

<Table size="small">

<TableHead>
<TableRow>
<TableCell>Title</TableCell>
<TableCell align="center">Repository</TableCell>
<TableCell align="center">State</TableCell>
<TableCell>Created</TableCell>
</TableRow>
</TableHead>

<TableBody>
{currentFilteredData.map((item) => (
<TableRow key={item.id}>

<TableCell sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
{getStatusIcon(item)}
<Link
href={item.html_url}
target="_blank"
rel="noopener noreferrer"
underline="hover"
sx={{ color: theme.palette.primary.main }}
>
{item.title}
</Link>
</TableCell>


<TableCell align="center">
{item.repository_url.split("/").slice(-1)[0]}
</TableCell>

<TableCell align="center">
{item.pull_request?.merged_at ? "merged" : item.state}
</TableCell>

<TableCell>{formatDate(item.created_at)}</TableCell>

</TableRow>
))}
</TableBody>

</Table>

<TablePagination
component="div"
count={totalCount}
page={page}
onPageChange={handlePageChange}
rowsPerPage={ROWS_PER_PAGE}
rowsPerPageOptions={[ROWS_PER_PAGE]}
/>

</TableContainer>
{currentFilteredData.length === 0 ? (
<Box textAlign="center" my={4} color="gray">
<p>
{tab === 0
? "No issues found for this user."
: "No pull requests found for this user."}
</p>
</Box>
) : (
<TableContainer component={Paper}>
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Title</TableCell>
<TableCell align="center">Repository</TableCell>
<TableCell align="center">State</TableCell>
<TableCell>Created</TableCell>
</TableRow>
</TableHead>

<TableBody>
{currentFilteredData.map((item) => (
<TableRow key={item.id}>
<TableCell sx={{ display: "flex", alignItems: "center", gap: 1 }}>
{getStatusIcon(item)}
<Link
href={item.html_url}
target="_blank"
rel="noopener noreferrer"
underline="hover"
sx={{ color: theme.palette.primary.main }}
>
{item.title}
</Link>
</TableCell>
<TableCell align="center">
{item.repository_url.split("/").slice(-1)[0]}
</TableCell>
<TableCell align="center">
{item.pull_request?.merged_at ? "merged" : item.state}
</TableCell>
Comment on lines +320 to +321
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.

<TableCell>{formatDate(item.created_at)}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
<TablePagination
component="div"
count={totalCount}
page={page}
onPageChange={handlePageChange}
rowsPerPage={ROWS_PER_PAGE}
rowsPerPageOptions={[ROWS_PER_PAGE]}
/>
</TableContainer>
)}
</Box>
)}
</Container>
);
Expand Down