Skip to content

fix(web): kb document chunk total size#1299

Merged
shuqinzhao merged 1 commit into
release/v0.3.6from
fix/v0.3.6_zy
Jun 2, 2026
Merged

fix(web): kb document chunk total size#1299
shuqinzhao merged 1 commit into
release/v0.3.6from
fix/v0.3.6_zy

Conversation

@shuqinzhao
Copy link
Copy Markdown
Collaborator

@shuqinzhao shuqinzhao commented Jun 2, 2026

Summary by Sourcery

在知识库文档详情和召回测试结果中,跟踪并展示后端返回的文档分片(chunks)总数。

New Features:

  • 为召回测试结果暴露一个总数属性,用于显示与当前已加载列表无关的整体分片数量。

Bug Fixes:

  • 确保召回结果计数反映的是后端报告的文档分片总数,而不仅仅是当前已加载页的数量。

Enhancements:

  • 将分页元数据(总数)从文档详情中存储并传递到召回测试结果视图。
Original summary in English

Summary by Sourcery

Track and display the total number of document chunks returned by the backend in knowledge base document details and recall test results.

New Features:

  • Expose a total count prop for recall test results to show the overall number of chunks independent of the currently loaded list.

Bug Fixes:

  • Ensure the recall result count reflects the backend-reported total number of document chunks instead of just the currently loaded page.

Enhancements:

  • Store and propagate pagination metadata (total count) from document details to the recall test results view.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 2, 2026

审阅者指南(在较小的 PR 上默认折叠)

审阅者指南

将后端返回的知识库文档分块总数传递到 RecallTestResult 视图中,这样结果数量就能反映完整总数,而不仅仅是当前已加载页面的数量。

将分块总数传递到 RecallTestResult 的流程图

flowchart LR
  subgraph DocumentDetails
    loadMoreChunks[loadMoreChunks]
    totalState[total state]
  end

  Backend[Backend API
  get_document_chunks]

  subgraph RecallTestResult
    totalProp[total prop]
    resultsDisplay["display (total || data.length)"]
  end

  loadMoreChunks --> Backend
  Backend -->|response.page.total| totalState
  totalState -->|pass as prop| totalProp
  totalProp --> resultsDisplay
Loading

按文件划分的改动

变更 详情 文件
在召回测试结果中增加一个可选的总数并从文档详情的分块分页响应中串联传递。
  • 扩展 RecallTestResult 的 props,增加一个可选的 total 字段,并在组件签名中默认设为 0。
  • 更新 RecallTestResult 中的结果计数显示逻辑,当提供 total 时优先使用 total,否则回退到 data.length。
  • 在 DocumentDetails 中增加 total state,用于跟踪来自分页元数据的分块总数。
  • 在获取文档详情时,从 response.page.total 设置 total,当该字段缺失时默认设为 0。
  • 将追踪到的 total 从 DocumentDetails 传递到 RecallTestResult,使 UI 显示完整的分块总数。
web/src/views/KnowledgeBase/components/RecallTestResult.tsx
web/src/views/KnowledgeBase/[knowledgeBaseId]/DocumentDetails.tsx

技巧与命令

与 Sourcery 交互

  • 触发一次新的审阅: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub issue: 通过回复审阅评论让 Sourcery 从该评论创建一个 issue。你也可以回复审阅评论内容为 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成一个标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文的任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审阅者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这个功能非常有用。
  • 清除所有 Sourcery 审阅: 在 pull request 中评论 @sourcery-ai dismiss,即可清除所有现有的 Sourcery 审阅。特别适用于你想从头开始新的审阅 —— 别忘了再评论 @sourcery-ai review 来触发新的审阅!

自定义你的使用体验

访问你的 控制面板 以:

  • 启用或禁用审阅功能,例如 Sourcery 生成的 pull request 摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、移除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Propagate the backend-reported total number of knowledge base document chunks into the RecallTestResult view so the result count reflects the full total instead of just the currently loaded page.

Flow diagram for propagating total chunk count to RecallTestResult

flowchart LR
  subgraph DocumentDetails
    loadMoreChunks[loadMoreChunks]
    totalState[total state]
  end

  Backend[Backend API
  get_document_chunks]

  subgraph RecallTestResult
    totalProp[total prop]
    resultsDisplay["display (total || data.length)"]
  end

  loadMoreChunks --> Backend
  Backend -->|response.page.total| totalState
  totalState -->|pass as prop| totalProp
  totalProp --> resultsDisplay
Loading

File-Level Changes

Change Details Files
Add an optional total count to recall test results and wire it from the document details chunk pagination response.
  • Extend RecallTestResult props with an optional total field and default it to 0 in the component signature.
  • Update the result count display in RecallTestResult to prefer the total value when provided, falling back to data.length.
  • Add total state in DocumentDetails to track the total number of chunks from the page metadata.
  • Set total from response.page.total when fetching document details, defaulting to 0 when missing.
  • Pass the tracked total down from DocumentDetails to RecallTestResult so the UI shows the full chunk count.
web/src/views/KnowledgeBase/components/RecallTestResult.tsx
web/src/views/KnowledgeBase/[knowledgeBaseId]/DocumentDetails.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@shuqinzhao shuqinzhao merged commit 93b3fb3 into release/v0.3.6 Jun 2, 2026
2 checks passed
@shuqinzhao shuqinzhao deleted the fix/v0.3.6_zy branch June 2, 2026 03:53
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - 我在这里给出一些整体反馈:

  • RecallTestResult 中,建议使用空值合并运算符(total ?? data.length)来代替 total || data.length,这样在 total 合法地为 0 时,就不会被 data.length 覆盖。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- In `RecallTestResult`, consider using nullish coalescing (`total ?? data.length`) instead of `total || data.length` so that a legitimate total of `0` is not overridden by `data.length`.

Sourcery 对开源项目是免费的——如果你觉得我们的 Review 有帮助,请考虑分享给更多人 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的 Review。
Original comment in English

Hey - I've left some high level feedback:

  • In RecallTestResult, consider using nullish coalescing (total ?? data.length) instead of total || data.length so that a legitimate total of 0 is not overridden by data.length.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `RecallTestResult`, consider using nullish coalescing (`total ?? data.length`) instead of `total || data.length` so that a legitimate total of `0` is not overridden by `data.length`.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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