AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(frontend/copilot): paginate session sidebar so threads past 50 stay reachable (#13128)
### Why / What / How **Why.** The CoPilot session sidebar fetched only the first 50 sessions and stopped. Any user with more than 50 chats lost access to every older thread through the UI even though the backend already supported `offset` and returned a `total` count. Threads weren't lost in the DB — they were just invisible. **What.** Wire proper pagination into the sidebar and mobile drawer with a "Load older chats" affordance, backed by a single shared infinite-query hook. Reroute all session-list cache invalidations so they refresh every loaded page, not just page 1. **How.** - New `useSessionList` hook wraps `useInfiniteQuery` around the existing `getV2ListSessions` fetcher: page size 50, `offset` pageParam, `refetchInterval` 10s, `getNextPageParam` derived from `total`. - Hook lives on a fresh `SESSION_LIST_QUERY_KEY` so the infinite cache doesn't collide with the orval-generated single-query key shape (which would break shape-sensitive cache readers). - `ChatSidebar` and `MobileDrawer` consume the hook and render a ghost `Button` with `loading` state at the end of the list when `hasMore`. - `useSessionTitlePoll` walks `InfiniteData` pages via a small `flattenSessions` helper instead of reading the legacy single-page response. - Five invalidation callsites (`useChatSession`, `useCopilotNotifications`, `useSessionDeletion`, `useSessionTitlePoll`, `ChatSidebar`) updated to invalidate the new key, so create/delete/rename/cross-tab-sync still refresh the sidebar correctly. ### Changes 🏗️ - Add `frontend/src/app/(platform)/copilot/useSessionList.ts` (shared paginated hook + `SESSION_LIST_QUERY_KEY` + `flattenSessions` cache walker). - `ChatSidebar.tsx`: replace single-page `useGetV2ListSessions` with `useSessionList`, add Load-more button, point invalidations at the new key. - `MobileDrawer.tsx`: mirror the same paginated fetch + Load-more affordance. - `useSessionTitlePoll.ts`: walk infinite-cache pages; invalidate the new key. - `useChatSession.ts`, `useCopilotNotifications.ts`, `useSessionDeletion.ts`: switch invalidation calls to `SESSION_LIST_QUERY_KEY`. ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [ ] I have tested my changes according to the test plan: - [x] `pnpm types` — clean - [x] `pnpm lint` — clean (only pre-existing img-tag warnings) - [x] `pnpm test:unit src/app/(platform)/copilot` — 59 files / 929 tests pass, including the existing `ChatSidebar` delete + status-indicator suites against the new wiring - [ ] Manual: seed a user with >50 sessions; confirm "Load older chats" appears, paginates correctly, and that the button disappears when `loaded === total` - [ ] Manual: confirm the 10s refetch still surfaces running/queued/processing indicators on all loaded pages - [ ] Manual: delete / rename / create-new-session — confirm the sidebar refreshes - [ ] Manual: cross-tab `localStorage` storage event still invalidates the list - [ ] Manual: title-poll still animates the new title in after stream completion --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
U
Ubbe committed
1a4fecf8120d72580ce38c6c2b6a34ff363b0f82
Parent: 29bc11a
Committed by GitHub <noreply@github.com>
on 5/18/2026, 9:43:05 AM