Skip to content

feat(frontend/copilot): paginate session sidebar so threads past 50 stay reachable - #13128

Merged
0ubbe merged 7 commits into
devfrom
feat/copilot-paginate-sessions
May 18, 2026
Merged

feat(frontend/copilot): paginate session sidebar so threads past 50 stay reachable#13128
0ubbe merged 7 commits into
devfrom
feat/copilot-paginate-sessions

Conversation

@0ubbe

@0ubbe 0ubbe commented May 15, 2026

Copy link
Copy Markdown
Contributor

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:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • pnpm types — clean
    • pnpm lint — clean (only pre-existing img-tag warnings)
    • 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

… reachable

The session sidebar called `useGetV2ListSessions({ limit: 50 })` once and
never asked for more, so users with more than 50 chats lost access to
every older thread via the UI even though the backend already supported
`offset` + returned a `total`. Switch the sidebar and mobile drawer to a
shared `useInfiniteQuery`-backed `useSessionList` hook, add a "Load older
chats" affordance, and reroute existing session-list invalidations
(title poll, delete, create, cross-tab sync, rename) to the new key so
they refresh every loaded page.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 97e53464-fbaf-4fae-836d-cf8700f1384b

📥 Commits

Reviewing files that changed from the base of the PR and between 75805cd and 1b56656.

📒 Files selected for processing (3)
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/__tests__/ChatSidebar.test.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/MobileDrawer.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/MobileDrawer.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/tests/ChatSidebar.test.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: check API types
  • GitHub Check: integration_test
  • GitHub Check: Seer Code Review
  • GitHub Check: Check PR Status
  • GitHub Check: end-to-end tests
  • GitHub Check: Analyze (typescript)
  • GitHub Check: Analyze (python)

Walkthrough

Adds a paginated session-list hook (useSessionList) with constants and helpers, consolidates cache invalidation to SESSION_LIST_QUERY_KEY, updates ChatSidebar and MobileDrawer to use the hook and render a "Load older chats" control, and adapts title-polling and tests to the infinite-data shape.

Changes

Session list pagination and consumption

Layer / File(s) Summary
Pagination hook and utilities
autogpt_platform/frontend/src/app/(platform)/copilot/useSessionList.ts
New useSessionList hook uses useInfiniteQuery with page size 50 and 10s refetch interval. Exports SESSION_LIST_QUERY_KEY, SESSION_LIST_PAGE_SIZE, helpers flattenSessions and countLoadedSessions.
Cache invalidation consolidation
autogpt_platform/frontend/src/app/(platform)/copilot/useChatSession.ts, autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotNotifications.ts, autogpt_platform/frontend/src/app/(platform)/copilot/useSessionDeletion.ts
Mutation and notification hooks now invalidate the session-list cache using SESSION_LIST_QUERY_KEY instead of the generated getGetV2ListSessionsQueryKey() helper.
ChatSidebar pagination UI and tests
autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx, autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/__tests__/ChatSidebar.test.tsx
ChatSidebar consumes useSessionList (sessions, hasMore, isLoadingMore, loadMore), updates invalidate calls to SESSION_LIST_QUERY_KEY, removes legacy sessionsResponse fallback, and conditionally renders a "Load older chats" footer button. Tests added for pagination visibility and offset-based fetch behavior.
MobileDrawer pagination UI
autogpt_platform/frontend/src/app/(platform)/copilot/components/MobileDrawer/MobileDrawer.tsx
Switched to useSessionList, uses pagination flags and shows a "Load older chats" button when hasMore is true with loading/disabled state.
Session title polling refactor
autogpt_platform/frontend/src/app/(platform)/copilot/useSessionTitlePoll.ts
Polling now reads the infinite session-list cache via SESSION_LIST_QUERY_KEY and flattenSessions to detect titles; invalidation timing adjusted to refresh before polling and after failed attempts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Swiftyos
  • Bentlybro

Poem

🐇 I dig through pages, fifty at a hop,

Older chats revealed with a single pop.
Shared keys keep caches neat and bright,
A button fetches history into the light.
Hooray — this rabbit loves a tidy byte!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% 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
Title check ✅ Passed The title accurately describes the main change: implementing pagination for the session sidebar to make threads beyond the initial 50 reachable.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, clearly explaining the why, what, and how with specific details about pagination, hook implementation, and cache invalidation updates.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/copilot-paginate-sessions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added platform/frontend AutoGPT Platform - Front end size/l labels May 15, 2026
@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

🔍 PR Overlap Detection

This check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early.

🔴 Merge Conflicts Detected

The following PRs have been tested and will have merge conflicts if merged after this PR. Consider coordinating with the authors.

Summary: 1 conflict(s), 0 medium risk, 0 low risk (out of 1 PRs with file overlap)


Auto-generated on push. Ignores: openapi.json, lock files.

Comment thread autogpt_platform/frontend/src/app/(platform)/copilot/useSessionList.ts Outdated
@codecov

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.37%. Comparing base (29bc11a) to head (1b56656).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #13128      +/-   ##
==========================================
- Coverage   71.41%   71.37%   -0.04%     
==========================================
  Files        2210     2211       +1     
  Lines      166745   166761      +16     
  Branches    17015    17019       +4     
==========================================
- Hits       119075   119032      -43     
- Misses      44128    44172      +44     
- Partials     3542     3557      +15     
Flag Coverage Δ
platform-frontend 36.69% <74.07%> (+0.01%) ⬆️
platform-frontend-e2e 30.86% <53.33%> (-0.49%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 79.77% <ø> (ø)
Platform Frontend 41.55% <71.42%> (-0.17%) ⬇️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…face

Adds three integration tests in ChatSidebar.test.tsx that pin the new
pagination wiring:
- "Load older chats" hides when total === loaded
- button renders when total > loaded
- clicking advances the offset (read from the request) and hides the
  button once the final page resolves

Also drops the unused getV2ListSessionsResponse re-export, the unused
total field on the hook return, and the now-orphaned getTotal helper.
Documents the refetchInterval refetches-all-pages trade-off inline
since TanStack Query v5 removed refetchPage and the worst case is
bounded by the user's session count.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@0ubbe
0ubbe marked this pull request as ready for review May 15, 2026 14:32
@0ubbe
0ubbe requested a review from a team as a code owner May 15, 2026 14:32
@0ubbe
0ubbe requested review from Bentlybro and Swiftyos and removed request for a team May 15, 2026 14:32
@0ubbe

0ubbe commented May 18, 2026

Copy link
Copy Markdown
Contributor Author
older-chats.mov

@github-actions github-actions Bot added the conflicts Automatically applied to PRs with merge conflicts label May 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

…sion list)

Combine paginated session-list hook with the new chat-search UX that
landed on dev:
- ChatSidebar: keep both the `useSessionList` import + invalidation key
  and the new `ChatSearchModal` + Cmd/Ctrl-K keyboard shortcut effect.
- MobileDrawer: route `useChatSearch` through the paginated `sessions`
  array from `useSessionList` instead of the legacy single-page response.
- ChatSidebar tests: keep both the MSW `http` helpers added for
  pagination tests and the `userEvent` import added for the search flow.

Note: chat search now only scans loaded pages — older sessions become
searchable as the user clicks "Load older chats". Acceptable trade-off
for this round; a server-side search hookup is a follow-up.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot removed the conflicts Automatically applied to PRs with merge conflicts label May 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@0ubbe
0ubbe merged commit 1a4fecf into dev May 18, 2026
34 checks passed
@0ubbe
0ubbe deleted the feat/copilot-paginate-sessions branch May 18, 2026 09:43
@github-project-automation github-project-automation Bot moved this to Done in Frontend May 18, 2026
@github-project-automation github-project-automation Bot moved this from 🆕 Needs initial review to ✅ Done in AutoGPT development kanban May 18, 2026
psbuilds pushed a commit to psbuilds/AutoGPT that referenced this pull request May 28, 2026
…tay reachable (Significant-Gravitas#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>
itsababseh added a commit that referenced this pull request Jun 15, 2026
## AutoPilot Scheduling, New Design & Out of Beta

Changelog covering platform versions `v0.6.59` through `v0.6.63` (May 7
– June 10, 2026).

### Featured sections
- **AutoPilot major upgrades** — native scheduling (#13190),
self-distilled skills registry (#13195), message queuing (#12841)
- **New login & signup** — animated panel, aurora, integrations marquee
(#13169)
- **Subscriptions out of beta** — plans & payments fully live (#12935)
- **Settings rebuilt + profile dropdown** — cleaner layout, integrations
tab, quick-action menu (#13138, #12976)

### Improvements listed (not featured)
- Trigger On Anything (#12740)
- Export Chat as Markdown (#13070)
- Auto-open artifact panel (#12997)
- Slack block (#13008)
- Cost breakdown in briefing panel (#13129)
- Session sidebar pagination (#13128)
- Faster first response in AutoPilot (#12828)

### Files changed
- `docs/platform/changelog/may-7-june-10-2026.md` — new changelog page
- `docs/platform/.gitbook/assets/` — 5 new hero images
- `docs/platform/SUMMARY.md` — new entry at top
- `docs/platform/changelog/README.md` — new row at top of table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/frontend AutoGPT Platform - Front end size/l

Projects

Status: ✅ Done
Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant