Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ui/src/conversation-panel/view/log/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ const appInfo = computed(() => (props.application ? toLogAppInfo(props.applicati
// 只读日志:只读消息列表 + 执行详情,无会话列表、无输入框。
// 不注入 MESSAGE_LIST_KEY,表单等内容项拿不到发送能力即自动只读。
const msgs = createLogMessageListStore({
// 降序取(最新在前),store 页内 reverse 成正序、上滑加载更旧
pageRecords: (cid, p, s) => props.chatLogApi.getChatRecordLog(props.applicationId || '', cid, { currentPage: p, pageSize: s }, false),
// 降序取(最新在前),store 页内 reverse 成正序、上滑加载更旧。
// 后端分页接口的 order_asc 语义与名称相反:true 或不传为降序,false 为升序
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.

Expand Down
Loading