Cursor prompt

Cursor: Implement Infinite Scroll

Cursor-based pagination with IntersectionObserver, loading states, error recovery, and scroll position restoration.

Implement infinite scroll for the {{entity}} list in {{project_name}}.

## API Endpoint: {{api_endpoint}}
## Items per page: {{page_size}}

### Cursor-Based Pagination (preferred over offset)
API returns: { data: T[], nextCursor: string | null, hasMore: boolean }
Query pattern: WHERE id > $cursor ORDER BY id ASC LIMIT $limit
Prevents duplicate/skipped items when new records are added while scrolling.

### usePaginatedList Hook
```typescript
const { items, isLoading, isFetchingMore, hasMore, error, loadMore } =
  usePaginatedList<{{entity_type}}>(endpoint, pageSize);
```
- Accumulates all pages into a single items array
- Uses SWR Infinite or React Query Infinite for caching and deduplication
- Exposes loadMore() for manual trigger (also called by IntersectionObserver)

### IntersectionObserver Trigger
Place a sentinel div after the last list item.
When sentinel enters the viewport: call loadMore() if hasMore && !isFetchingMore.
Settings: threshold: 0.1, rootMargin: "0px 0px 200px 0px" (pre-load 200px early).

### Loading States
- Initial load: skeleton cards matching real card dimensions
- Loading more: small spinner centered below last item
- Error: "Failed to load" with Retry button — preserve already-loaded items
- End of list: subtle "That's everything" message

### Scroll Position Restoration
On navigation away: save scrollY to sessionStorage with list identifier.
On back-navigation: restore scroll position after items re-render.

### Output
usePaginatedList hook, InfiniteList component, sentinel component, and API handler.

Fill in: {{entity}}, {{project_name}}, {{api_endpoint}}, {{page_size}}, {{entity_type}}. In Loopy you fill these in a form and copy the finished prompt in one click.