Repository navigation
fix: The records in the dialogue log of the [agent] are displayed in chronological order, from newest to oldest - #7935
Merged
Conversation
…chronological order, from newest to oldest
shaohuzhang1
commented
Nov 16, 2026
| pageRecords: (cid, p, s) => props.chatLogApi.getChatRecordLog(props.applicationId || '', cid, { currentPage: p, pageSize: s }, true), | ||
| getChatId: () => props.chatId, | ||
| appInfo, | ||
| }) |
Contributor
Author
There was a problem hiding this comment.
No syntax-level irregularity is introduced by this diff. The changed argument appears intentional: if the backend really treats order_asc = true (or omitted) as descending, then passing true matches the comment “latest first”, and the store can reverse it internally for display.
Potential issues / suggestions:
-
Inverted boolean semantics are brittle
order_asc: truemeaning “descending” is highly misleading and easy to regress.- Verify this against backend/API docs or tests; do not rely only on a comment.
- Prefer a named constant or enum:
// Backend quirk: true/omitted = descending, false = ascending const CHAT_RECORD_ORDER_DESC = true pageRecords: (cid, p, s) => props.chatLogApi.getChatRecordLog( props.applicationId || '', cid, { currentPage: p, pageSize: s }, CHAT_RECORD_ORDER_DESC, ),
- Ideally, fix the API contract/name or expose an enum such as
{ order: 'asc' | 'desc' }.
-
props.applicationId || ''silently hides invalid state- If
applicationIdis required for this API call, failing early is safer than sending''. - Use a required prop / guard, or at least
?? ''if onlynull/undefinedshould fall back.
- If
-
Add a regression test
- Test that the initial page is latest-first, and that scrolling up loads older records correctly.
- This is especially important because the flag semantics are counterintuitive.
-
Minor optimization / readability
- Extracting the
pageRecordscallback avoids recreating it inline and makes it easier to test:const fetchChatRecordPage = (cid: string, p: number, s: number) => props.chatLogApi.getChatRecordLog( props.applicationId || '', cid, { currentPage: p, pageSize: s }, CHAT_RECORD_ORDER_DESC, ) const msgs = createLogMessageListStore({ pageRecords: fetchChatRecordPage, getChatId: () => props.chatId, appInfo, })
- This is not required for correctness unless the store re-subscribes or treats
pageRecordsreactively.
- Extracting the
Overall: the diff is probably correct if and only if the documented backend behavior is accurate. The main risk is the inverted, magic boolean value.
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.
fix: The records in the dialogue log of the [agent] are displayed in chronological order, from newest to oldest