Skip to content

fix(conversation): keep older-history pagination reliable during running turns - #4233

Open
turingcat wants to merge 1 commit into
iOfficeAI:mainfrom
turingcat:fix/message-history-pagination-autoscroll
Open

fix(conversation): keep older-history pagination reliable during running turns#4233
turingcat wants to merge 1 commit into
iOfficeAI:mainfrom
turingcat:fix/message-history-pagination-autoscroll

Conversation

@turingcat

Copy link
Copy Markdown

Description

While a conversation turn is running, older message history can silently become unreachable, and the pagination/auto-scroll state around history loading can get corrupted:

  1. Pagination never triggers when content doesn't overflow the viewport. A running turn folds consecutive tool calls into a single summary card and drops hidden/plan rows, so a full DB page can render as just a few short cards — too short to produce a scrollbar. Since the older-page loader only runs on onScroll, it never fires even though more history exists. MessageList.tsx now proactively pulls older pages (capped at MAX_VIEWPORT_FILL_PAGES) after mount/prepend as long as content still fits without a scrollbar.
  2. Turn-completion reconciliation reset pagination progress. After a user scrolls up and loads older pages (oldestCursor/hasMoreBefore), a pending turn completing would reload the newest page and reset pagination as if it were a fresh mount, discarding that progress. loadMessages now accepts a preservePaginationBefore option, used by the turn-completion reconciliation path.
  3. useAutoScroll misidentified prepended history as a new message. It compared only messages.length to detect "a new message arrived," but a prepended older page also grows the list length. It now compares the tail message by id instead.

Related Issues

Type of Change

  • fix — Bug fix (non-breaking change which fixes an issue)

Atomic PR Checklist (Rule 1)

  • This PR contains exactly one feature or bug fix that cannot be further decomposed
  • The PR title follows Conventional Commit format: <type>(<scope>): <subject> (English)

Local Checks (Rule 3)

  • bun run format — formatting passes
  • bun run lint — no lint errors (skip if no .ts/.tsx changed)
  • bunx tsc --noEmit — no type errors (skip if no .ts/.tsx changed)
  • bunx vitest run — tests pass (520 files / 4984 tests passed)
  • i18n validated — N/A, no user-facing text changed
  • New/changed user-facing text uses i18n keys (no hardcoded strings) — N/A, no user-facing text changed

Runtime Verification

  • Verified on macOS
  • Verified on Windows
  • Verified on Linux
  • I have performed a self-review of my own code

Additional Context

Regression tests added in tests/unit/renderer/messageList.dom.test.tsx, tests/unit/renderer/messageMerging.dom.test.tsx, and tests/unit/renderer/useAutoScroll.dom.test.tsx.

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.

[Bug]: Older message history fails to load in long-running conversations

1 participant