Skip to content

feat: Implement cursor-based infinite scrolling for Model Directory (#51)#92

Open
nitishchaubeyy wants to merge 3 commits into
AditthyaSS:mainfrom
nitishchaubeyy:feat/infinite-scroll
Open

feat: Implement cursor-based infinite scrolling for Model Directory (#51)#92
nitishchaubeyy wants to merge 3 commits into
AditthyaSS:mainfrom
nitishchaubeyy:feat/infinite-scroll

Conversation

@nitishchaubeyy

Copy link
Copy Markdown
Contributor

Description

This PR resolves #51 by replacing the heavy client-side filtering and static data loading with a highly performant, cursor-based infinite scrolling architecture.

Note: I also bundled in a quick UI cleanup for the Modalities table column to prevent text overlapping with the icons, and fixed a stray TypeScript error.

Key Changes

Backend (src/app/api/models/route.ts)

  • Transitioned from offset-based to Prisma's cursor-based pagination using cursor and skip: 1.
  • Shifted filter processing (Provider, Modality, License, Search) to the database level via Prisma where clauses to ensure paginated chunks are accurate and scalable.
  • Implemented a stable sort fallback (appending id: "asc" to orderBy) so cursors never skip ties.

Frontend (src/app/models/page.tsx & ModelTable.tsx)

  • Integrated Intersection Observer logic to trigger automatic network requests when the user scrolls near the bottom of the directory.
  • Refactored state management to seamlessly append new model chunks to the existing array without layout shifts.
  • Added dynamic URLSearchParams generation to pass active UI filters down to the API route natively.
  • Cleaned up the Modalities column in the table to display clean tooltips rather than overlapping text/icons.

⚠️ Note for Maintainers Regarding Dependencies

To implement the Intersection Observer reliably, this feature relies on the react-intersection-observer package.

I remember the rule to make sure package.json and package-lock.json aren't touched separately or bundled blindly into feature PRs.

To respect that, I have intentionally excluded the package.json and lockfile updates from this commit.

Let me know how you'd prefer to handle adding this necessary package (e.g., push the lockfile updates to this PR, or handle it in a separate dependency PR).

Fixes

Closes #51

@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

@nitishchaubeyy is attempting to deploy a commit to the aditthyass' projects Team on Vercel.

A member of the Team first needs to authorize it.

@nitishchaubeyy

Copy link
Copy Markdown
Contributor Author

Hey @AditthyaSS ,

Just a quick heads-up regarding the dependencies! To implement the Intersection Observer reliably for the infinite scroll, I needed to install the react-intersection-observer package.

I remember you mentioning earlier to make sure package.json and package-lock.json aren't touched separately. I have left those dependency updates out of this commit to respect that rule.

Let me know how you'd prefer to handle adding this necessary package! I can either push the lockfile updates to this PR if you give the green light, or we can handle it in a separate dependency PR!

@AditthyaSS

Copy link
Copy Markdown
Owner

@nitishchaubeyy i can see some merege conflicts please resolve it...

@nitishchaubeyy

Copy link
Copy Markdown
Contributor Author

@AditthyaSS The conflicts on this branch has been resolved as well.

@AditthyaSS

Copy link
Copy Markdown
Owner

@nitishchaubeyy Please solve the conflicts ..Then only the PR can be merged src/app/api/models/route.js

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Implement Cursor-Based Infinite Scrolling for Model Directory

2 participants