Skip to content

fix: keep sidebar conversations loaded by scrolling in the conversations store - #2771

Open
burrows99 wants to merge 3 commits into
huggingface:mainfrom
burrows99:fix/sidebar-paginated-conversations-in-store
Open

burrows99 wants to merge 3 commits into
huggingface:mainfrom
burrows99:fix/sidebar-paginated-conversations-in-store

Conversation

@burrows99

@burrows99 burrows99 commented Nov 15, 2026 •

Copy link
Copy Markdown

Problem

The sidebar loads older conversations as you scroll down (pages of 30). Those older pages were kept in a local copy of the conversations prop inside NavMenu, not in the shared conversations store. That copy goes out of sync with the store:

  • Renaming a conversation after scrolling saves on the server, but the sidebar row keeps the old title until a reload. This happens for older conversations, which are not in the store at all, and also for recent ones, because the copy holds the old object.
  • Deleting any conversation, or sending a message (which reloads the first page), replaces the store list. The local copy is dropped and every older conversation disappears from the sidebar. If you had already scrolled to the end, hasMore is still false, so scrolling down does not load them again. Only a page reload brings them back.

To reproduce: have more than 30 conversations, scroll the sidebar to the end, then rename one of the oldest conversations or delete any conversation.

I did not find an existing issue or pull request for this.

Fix

  • ConversationsStore.append() adds a page of older conversations to the store and skips ids already listed. Pages can overlap after a conversation is created, and the mobile and desktop sidebars paginate separately.
  • NavMenu appends loaded pages to the store instead of assigning its prop, so rename and delete (which already go through the store) apply to them. The prop is no longer $bindable; nothing binds it.
  • When the list is reset to the first page, hasMore is reset to true together with p, so scrolling loads the older pages again.
flowchart TD
    A[Scroll the sidebar to load older chats] --> B{Rename or delete a chat}
    B -->|Before| C[Old title stays and older chats vanish]
    B -->|After| D[New title shows and older chats stay]
Loading

Narrated recording, before then after (sound on):

evidence.mp4

Edge cases and unchanged behaviour checked

Checked in the running app (local dev server from main at a84f52c2, then this branch, 65 conversations) and shown in the recording:

  • Before: after scrolling to the end, renaming Chat 02 to Budget notes leaves the row as Chat 02; deleting Chat 03 leaves 30 rows, and scrolling down loads nothing more.
  • After: the same rename shows Budget notes at once; after deleting Chat 03, 64 rows are still listed.
  • Edge case: a recent conversation renamed after scrolling also updates in place.
  • Edge case: after sending a message (the list goes back to the first page), scrolling down loads the older conversations again.
  • Unchanged: cancelling the rename dialog keeps the title.
  • Unchanged: after a reload, the sidebar loads older conversations on scroll as before.

Checked by the new store test only (conversations.svelte.test.ts):

  • append keeps appended pages so update and remove apply to them.
  • append skips ids that are already in the list.

Tests run

$ npx vitest run --project=client src/lib/stores/conversations.svelte.test.ts
 ✓ |client (chromium)| src/lib/stores/conversations.svelte.test.ts (2 tests)
 Test Files  1 passed (1)
      Tests  2 passed (2)

With the store change reverted and the test kept, both tests fail (store.append is not a function). The NavMenu wiring is covered by the recording, not by a component test.

prettier --check and eslint pass on the three changed files. npm run check (svelte-check) reports 0 errors and 0 warnings.

Follow-up (6b934b37, for the review note on offset paging): the next page is requested from the rows already loaded (ConversationsStore.nextPage) and scrolling stops on the API's hasMore, so deleting a conversation from a loaded page no longer skips the one that moves up. A third store test covers it (passes; fails with a page counter), and in the app with 65 chats, deleting Chat 20 from page 2 and scrolling to the end now lists 64 rows (before: 63, Chat 05 missing).

Not run: the rest of the test suites and a production build.

AI tools (Claude Code) assisted with this change; the bug was reproduced and the fix verified manually in the running app.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T13:22:24.698536Z 979b96c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 979b96c8ae

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/lib/stores/conversations.svelte.ts Resolved
The conversations API pages by offset, so after a delete a page counter
skips the conversation that moved up into the page already loaded.
Compute the next page from the loaded row count (append() drops rows
already listed) and stop on the API's hasMore flag.

This branch has not been deployed

No deployments
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.

1 participant