fix(frontend): paginate run history messages#3161
Open
LittleChenLiya wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes missing/misordered chat history in the frontend by correctly paginating messages within a single run. It aligns the frontend with the backend run-messages API contract (has_more + before_seq) so “load more” continues paging the same run until exhausted before moving to older runs.
Changes:
- Add run-internal pagination support via
before_seqcursor tracking perrun_id. - Correctly interpret backend pagination flag (
has_more), while keeping compatibility with the previoushasMore. - Add unit tests for
has_morehandling and next-page cursor computation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| frontend/src/core/threads/hooks.ts | Implements has_more detection and per-run before_seq cursor tracking to paginate run messages correctly. |
| frontend/src/core/threads/types.ts | Extends RunMessage with optional seq used for cursor pagination. |
| frontend/tests/unit/core/threads/message-merge.test.ts | Adds unit tests covering has_more compatibility and cursor (seq) selection logic. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题原因
聊天历史加载按 run 逐个请求消息,但前端每个 run 只读取默认第一页。后端返回的是该 run 最新一页消息,并通过
has_more表示还有更早消息;前端没有识别这个字段,也没有带before_seq继续加载同一个 run,导致长对话加载更多时会遗漏同一 run 内更早的消息,后续再拼接其他 run 时表现为历史缺失或顺序错位。修改内容
before_seq游标。has_more字段,只有当前 run 全部分页加载完成后才切换到更早的 run。has_more识别和下一页 cursor 计算。关联 issue
关联 #3052