Skip to content

fix: pagination added#5

Merged
arnabnandy7 merged 2 commits into
mainfrom
feature/paginationCase
Jun 26, 2026
Merged

fix: pagination added#5
arnabnandy7 merged 2 commits into
mainfrom
feature/paginationCase

Conversation

@arnabnandy7

@arnabnandy7 arnabnandy7 commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Search results now support pagination with a Load More option.
    • Pagination is consistently propagated through the search flow, including page tracking.
  • Bug Fixes

    • Page values are validated and normalized, defaulting to page 1 when missing or invalid.
    • Loading additional pages now appends new results instead of replacing the existing list.

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
@arnabnandy7 arnabnandy7 self-assigned this Jun 26, 2026
@arnabnandy7 arnabnandy7 added the bug Something isn't working label Jun 26, 2026
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openissue-dev Ready Ready Preview, Comment Jun 26, 2026 8:20pm

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e75245c-08c0-4d7f-84a9-a979b2d00403

📥 Commits

Reviewing files that changed from the base of the PR and between bc89d81 and 5e765d4.

📒 Files selected for processing (1)
  • src/app/api/search/route.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/api/search/route.ts

📝 Walkthrough

Walkthrough

The issue search flow now accepts a page parameter end to end. The API route forwards it to GitHub search, the response includes the current page, and IssueFinder stores results locally with a Load More path for additional pages.

Changes

Issue Search Pagination

Layer / File(s) Summary
Search service page support
src/features/issues/types/search.ts, src/features/issues/server/github-search.ts, tests/features/issues/server/github-search.test.ts
SearchResponse includes page, searchGitHubIssues forwards page to GitHub search, and the service test checks the request URL and returned page.
API route page forwarding
src/app/api/search/route.ts, tests/app/api/search/route.test.ts
/api/search reads and normalizes page from the query string, passes it to searchGitHubIssues, and the route test reflects the added field.
IssueFinder pagination UI
src/features/issues/components/issue-finder.tsx
IssueFinder keeps a local issue list, page state, hasMore, and load-more state, resets them on new searches, and renders a Load More button when more results are available.

Sequence Diagram(s)

sequenceDiagram
  participant IssueFinder
  participant SearchRoute as "/api/search route"
  participant searchGitHubIssues
  participant GitHubSearchAPI as "GitHub /search/issues"

  IssueFinder->>SearchRoute: GET tech, label, sort, linkedPr, page
  SearchRoute->>searchGitHubIssues: searchGitHubIssues({ ...page })
  searchGitHubIssues->>GitHubSearchAPI: GET page query parameter
  GitHubSearchAPI-->>searchGitHubIssues: Search results page
  searchGitHubIssues-->>SearchRoute: SearchResponse with page
  SearchRoute-->>IssueFinder: JSON issues, totalCount, page
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through pages, one by one,
Carrots in hand, the search begun.
More issues gleam beyond the hay,
A Load More button lights the way.
Hop hop—page two, page three, hooray!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change by indicating pagination was added.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/paginationCase

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

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
tests/app/api/search/route.test.ts (1)

52-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add an explicit page query test.

The route’s new behavior is forwarding ?page=...; this only covers the default. Add a case for ?tech=React&page=3 expecting page: 3, plus an invalid value if you want to lock normalization.

🤖 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 `@tests/app/api/search/route.test.ts` at line 52, The search route tests only
cover the default page value, so add an explicit query case for the route
handler in the search API tests. Update the existing test suite around the
route’s request parsing to include a request with ?tech=React&page=3 and assert
the downstream call receives page: 3, and optionally add an invalid page case to
verify normalization behavior in the same handler path.
src/features/issues/components/issue-finder.tsx (1)

135-135: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Dedupe appended pages by issue ID.

Paginated live search results can overlap as issues move between pages; appending blindly can render duplicate cards and duplicate React keys.

Proposed append guard
-      setIssues((prev) => [...prev, ...payload.issues]);
+      setIssues((prev) => {
+        const seen = new Set(prev.map((issue) => issue.id));
+        return [...prev, ...payload.issues.filter((issue) => !seen.has(issue.id))];
+      });
🤖 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/features/issues/components/issue-finder.tsx` at line 135, The issue list
append in issue-finder should dedupe paginated results by issue ID instead of
blindly concatenating pages, since overlapping pages can create duplicate cards
and React keys. Update the setIssues callback to merge prev and payload.issues
while filtering out items whose issue ID already exists in the accumulated list,
using the unique issue identifier exposed by the issue objects in IssueFinder.
tests/features/issues/server/github-search.test.ts (1)

103-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover a non-default page value.

This asserts the default path, but the pagination contract also needs a case like page: 2 to prove the service forwards caller-provided pages instead of always returning/requesting 1.

🤖 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 `@tests/features/issues/server/github-search.test.ts` around lines 103 - 104,
The github-search pagination test only covers the default page value, so add
coverage for a caller-provided non-default page in the relevant test case for
the search service. Update the assertions around the github search URL and
result handling in github-search.test.ts to use a page like 2, and verify the
service forwards that value into the request URL and preserves it on the
returned result instead of always using 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/features/issues/components/issue-finder.tsx`:
- Around line 75-79: The new-search reset in issue-finder is only clearing the
rendered issues list, so stale `data` can still drive the query, total, and
`hasMore` state if the next request fails. Update the search reset path in
`IssueFinder` to also clear or invalidate the previous response state alongside
`setIssues([])` and `setPage(1)`, so the component no longer reads old `data`
after a fresh search begins.
- Around line 119-124: The “Load More” flow in issue-finder is reading the
current editable form values instead of the last submitted search criteria.
Update the search state in issue-finder.tsx so the initial submit snapshots the
submitted params, and have the load-more handler build its request from that
stored snapshot rather than tech/label/sort/linkedPr form state. Use the
existing issue-finder component handlers and URLSearchParams construction to
locate the submit/load-more logic and keep page increments tied to the last
successful search.

---

Nitpick comments:
In `@src/features/issues/components/issue-finder.tsx`:
- Line 135: The issue list append in issue-finder should dedupe paginated
results by issue ID instead of blindly concatenating pages, since overlapping
pages can create duplicate cards and React keys. Update the setIssues callback
to merge prev and payload.issues while filtering out items whose issue ID
already exists in the accumulated list, using the unique issue identifier
exposed by the issue objects in IssueFinder.

In `@tests/app/api/search/route.test.ts`:
- Line 52: The search route tests only cover the default page value, so add an
explicit query case for the route handler in the search API tests. Update the
existing test suite around the route’s request parsing to include a request with
?tech=React&page=3 and assert the downstream call receives page: 3, and
optionally add an invalid page case to verify normalization behavior in the same
handler path.

In `@tests/features/issues/server/github-search.test.ts`:
- Around line 103-104: The github-search pagination test only covers the default
page value, so add coverage for a caller-provided non-default page in the
relevant test case for the search service. Update the assertions around the
github search URL and result handling in github-search.test.ts to use a page
like 2, and verify the service forwards that value into the request URL and
preserves it on the returned result instead of always using 1.
🪄 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 Plus

Run ID: 39c1ccff-da01-4a69-b4ee-0fa50daaaaae

📥 Commits

Reviewing files that changed from the base of the PR and between 2376a79 and bc89d81.

📒 Files selected for processing (6)
  • src/app/api/search/route.ts
  • src/features/issues/components/issue-finder.tsx
  • src/features/issues/server/github-search.ts
  • src/features/issues/types/search.ts
  • tests/app/api/search/route.test.ts
  • tests/features/issues/server/github-search.test.ts

Comment thread src/features/issues/components/issue-finder.tsx
Comment thread src/features/issues/components/issue-finder.tsx
@arnabnandy7 arnabnandy7 merged commit c4e36bb into main Jun 26, 2026
7 checks passed
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant