Skip to content

M3: Client-side safety fixes for pagination edge cases#21565

Merged
Jasonnnz merged 2 commits into
feature/msg-paginationfrom
swarm/msg-pagination/task-3
Mar 25, 2026
Merged

M3: Client-side safety fixes for pagination edge cases#21565
Jasonnnz merged 2 commits into
feature/msg-paginationfrom
swarm/msg-pagination/task-3

Conversation

@Jasonnnz
Copy link
Copy Markdown
Contributor

@Jasonnnz Jasonnnz commented Mar 25, 2026

Summary

  • Removed trimOldMessagesIfNeeded() from the pagination prepend branch in populateFromHistory() to prevent an infinite fetch-trim loop (trim removes just-fetched messages, resetting cursor, causing re-fetch)
  • Added a second-stage 60s hard timeout in loadPreviousMessagePage() that calls resetMessagePagination() to prevent permanently stuck loading spinners when the daemon is unresponsive

Test plan

  • Verify pagination loading still works normally (loads older messages on scroll up)
  • Verify that if daemon is unresponsive for 60s, the loading state resets cleanly
  • Verify that loading many pages of history (exceeding 150 message trim threshold) no longer causes an infinite fetch loop

Part of #21550.

🤖 Generated with Claude Code


Open with Devin

…k loading state

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Jasonnnz Jasonnnz self-assigned this Mar 25, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@Jasonnnz
Copy link
Copy Markdown
Contributor Author

@codex review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…imeout

Replace resetMessagePagination() in the 60s timeout handler with a
targeted clear of isLoadingMoreMessages + loadMoreTimeoutTask. This
preserves the user's scroll position, historyCursor, and hasMoreHistory
so they can retry by scrolling up, rather than collapsing the visible
window.

Also update doc comments to reflect the 30s/60s two-stage timeout
behavior and the accepted misclassification tradeoff.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Jasonnnz
Copy link
Copy Markdown
Contributor Author

Addressed review feedback in 319dbb5 (pushed to swarm/msg-pagination/task-3):

  • Replaced resetMessagePagination() with minimal state clear in the 60s timeout handler. Now only clears isLoadingMoreMessages and loadMoreTimeoutTask, preserving the user's scroll position, historyCursor, and hasMoreHistory so they can retry by scrolling up.
  • Updated doc comment for loadMoreTimeoutTask to accurately describe the 30s/60s two-stage timeout behavior.
  • Added inline comment noting the 60s hard clear and its accepted misclassification tradeoff.

Resolved 3 threads (P1 cursor clearing, P1 window collapse, and stale doc comment). The trimming threads (P2) are out of scope for this fix.

@Jasonnnz
Copy link
Copy Markdown
Contributor Author

@codex review this PR again — the previous issues have been fixed in commit 319dbb5

@Jasonnnz
Copy link
Copy Markdown
Contributor Author

@devin review this PR again — the previous issues have been fixed in commit 319dbb5

@Jasonnnz Jasonnnz merged commit 3c86cf7 into feature/msg-pagination Mar 25, 2026
4 checks passed
@Jasonnnz Jasonnnz deleted the swarm/msg-pagination/task-3 branch March 25, 2026 18:38
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Jasonnnz added a commit that referenced this pull request Mar 25, 2026
* feat: add composite DB index and getMessagesPaginated() for message history pagination (#21562)

Co-authored-by: Vellum Assistant <assistant@vellum.ai>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* M2: Wire pagination into handleListMessages HTTP endpoint (#21569)

* feat: wire server-side pagination into handleListMessages HTTP endpoint

Part of #21550

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

* fix: gate pagination fields behind isPaginated and regenerate openapi spec

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

---------

Co-authored-by: Vellum Assistant <assistant@vellum.ai>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* M3: Client-side safety fixes for pagination edge cases (#21565)

* fix: remove trim-after-pagination and add 60s safety timeout for stuck loading state

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

* fix: use minimal state clear instead of resetMessagePagination() on timeout

Replace resetMessagePagination() in the 60s timeout handler with a
targeted clear of isLoadingMoreMessages + loadMoreTimeoutTask. This
preserves the user's scroll position, historyCursor, and hasMoreHistory
so they can retry by scrolling up, rather than collapsing the visible
window.

Also update doc comments to reflect the 30s/60s two-stage timeout
behavior and the accepted misclassification tradeoff.

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

---------

Co-authored-by: Vellum Assistant <assistant@vellum.ai>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add pagination test suite for handleListMessages (#21578)

Part of #21550. Adds 9 test cases covering backward compatibility, cursor
pagination, strict exclusivity, hasMore logic, metadata correctness, empty
conversations, and input validation.

Co-authored-by: Vellum Assistant <assistant@vellum.ai>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: remove duplicate guard let self in timeout closure (non-optional after first unwrap)

---------

Co-authored-by: Vellum Assistant <assistant@vellum.ai>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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