Skip to content

fix: The records in the dialogue log of the [agent] are displayed in chronological order, from newest to oldest - #7935

Merged
shaohuzhang1 merged 1 commit into
v3from
pr@v3@fix_application_log
Nov 16, 2026
Merged

shaohuzhang1 merged 1 commit into
v3from
pr@v3@fix_application_log

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: The records in the dialogue log of the [agent] are displayed in chronological order, from newest to oldest

pageRecords: (cid, p, s) => props.chatLogApi.getChatRecordLog(props.applicationId || '', cid, { currentPage: p, pageSize: s }, true),
getChatId: () => props.chatId,
appInfo,
})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Inverted boolean semantics are brittle

    • order_asc: true meaning “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' }.
  2. props.applicationId || '' silently hides invalid state

    • If applicationId is required for this API call, failing early is safer than sending ''.
    • Use a required prop / guard, or at least ?? '' if only null/undefined should fall back.
  3. 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.
  4. Minor optimization / readability

    • Extracting the pageRecords callback 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 pageRecords reactively.

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.

@shaohuzhang1
shaohuzhang1 merged commit 1488c60 into v3 Nov 16, 2026
3 of 4 checks passed
@shaohuzhang1
shaohuzhang1 deleted the pr@v3@fix_application_log branch November 16, 2026 07:42
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