Skip to content

Fix: Remove the pagination from the search and retrieval pages. - #15942

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
cike8899:fix-search-required
Jun 11, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
cike8899:fix-search-required

Conversation

@cike8899

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Fix: Remove the pagination from the search and retrieval pages.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 11, 2026
@cike8899 cike8899 added the ci Continue Integration label Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR replaces pagination-based result browsing with a fixed top-N selector (10/20/50/100 results) across dataset testing and search workflows. The backend now explicitly surfaces total chunk counts, the new TopSelect component standardizes the UI, hooks manage page size locally, and pagination UI is removed throughout.

Changes

Top-N Result Selection

Layer / File(s) Summary
Backend API total count support
api/apps/services/dataset_api_service.py
Backend dataset service explicitly includes total chunk count in search response after expanding retrieval results.
TopSelect component creation
web/src/components/top-select.tsx
New searchable select component renders localized options (10/20/50/100) and wraps in a form item with field name "size".
Internationalization for top feature
web/src/locales/en.ts, web/src/locales/zh.ts
Adds parameterized and fixed top translation entries in English and Chinese for top-N display labels.
Dataset testing hook refactor to fixed page 1
web/src/hooks/use-knowledge-request.ts
useTestRetrieval removes local pagination state, always uses page 1, and no longer exposes pagination-related returns (onPaginationChange, page, pageSize).
Dataset testing UI update for top-N selection
web/src/pages/dataset/testing/index.tsx, web/src/pages/dataset/testing/testing-form.tsx, web/src/pages/dataset/testing/testing-result.tsx
Testing form adds TopSelectFormItem for size field; testing-result removes pagination component and displays total count instead; hook integration simplified to exclude pagination props.
Search hooks refactor for local page-size state
web/src/pages/next-search/hooks.ts
Chunk retrieval hooks reordered; useSendQuestion and useSearching refactored to manage pageSize locally instead of router pagination, exposing pageSize state and handleTopChange callback for top-N updates.
Search page UI update for top-N selection
web/src/pages/next-search/search-view.tsx
SearchingView imports TopSelect, accepts pageSize and handleTopChange props, and replaces pagination UI with top-select control and total count display in retrieval documents section.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • infiniflow/ragflow#15901: The main PR's search_datasets change explicitly sets ranks["total"] after expanding chunks, which directly conflicts with the retrieved PR that stops setting ranks["total"] in the same code path.

Suggested labels

size:S

Suggested reviewers

  • wangq8

Poem

🐰 A selector springs forth, no pages to turn,
Top ten, twenty, fifty—the results we discern,
Hooks refactored clean, state lives locally bright,
Pagination vanished, top-N shines right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing pagination from search and retrieval pages, which aligns with the primary modifications across multiple UI components and hooks.
Description check ✅ Passed The description addresses the required template with a clear problem statement and appropriate type classification, though it lacks detailed context about the solution approach and affected components.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cike8899
cike8899 marked this pull request as draft June 11, 2026 08:15
@cike8899
cike8899 marked this pull request as ready for review June 11, 2026 08:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/pages/next-search/hooks.ts (1)

390-392: ⚠️ Potential issue | 🟠 Major

Top-N can be overridden to 10 when document selection triggers testing.

RetrievalDocuments’ onTesting prop is onTesting(documentIds: string[]) and it calls onTesting(value) without providing size (web/src/pages/next-search/retrieval-documents/index.tsx, interface at lines 27-32 and call at lines ~85-90). Meanwhile useSearching’s handleTestChunk defaults size: number = 10 (web/src/pages/next-search/hooks.ts, lines 390-392), so any onTesting(documentIds) path (doc select/clear) will fetch 10 results even if TopSelect was set. handleTopChange passes size correctly (lines 540-546), but it doesn’t cover this callback path.

Suggested fix
-  const handleTestChunk = useCallback(
-    (documentIds: string[], page: number = 1, size: number = 10) => {
+  const handleTestChunk = useCallback(
+    (documentIds: string[], page: number = 1, size: number = pageSize) => {
       const q = trim(searchStr);
       if (sendingLoading || isEmpty(q)) return;
@@
-    [
+    [
       searchStr,
       sendingLoading,
       testChunk,
       kbIds,
       selectedDocumentIds,
       testChunkAll,
       searchId,
+      pageSize,
     ],
   );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/pages/next-search/hooks.ts` around lines 390 - 392, handleTestChunk
currently defaults size to 10 causing document-selection testing to ignore the
TopSelect value; update the flow so handleTestChunk uses the current top
selection instead of a hard default and ensure RetrievalDocuments' onTesting
path calls it with that value. Concretely, remove the hard default in
handleTestChunk(size: number = 10) and have the function read the current top N
state (the same state updated by handleTopChange), or change RetrievalDocuments'
onTesting to pass the current top value through to handleTestChunk when invoking
onTesting(documentIds). Reference: handleTestChunk, onTesting
(RetrievalDocuments), and handleTopChange so the same top N state is used for
both code paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/locales/zh.ts`:
- Line 830: The label literal "前n条" is awkward as a standalone form label;
update the locale entry for the key "top" (used as knowledgeConfiguration.top)
in web/src/locales/zh.ts to a neutral, generic term such as "数量" or "Top" so it
reads naturally in forms; replace the value for the "top" key with the chosen
neutral label and ensure any usages rendering this label still make sense in
context.

---

Outside diff comments:
In `@web/src/pages/next-search/hooks.ts`:
- Around line 390-392: handleTestChunk currently defaults size to 10 causing
document-selection testing to ignore the TopSelect value; update the flow so
handleTestChunk uses the current top selection instead of a hard default and
ensure RetrievalDocuments' onTesting path calls it with that value. Concretely,
remove the hard default in handleTestChunk(size: number = 10) and have the
function read the current top N state (the same state updated by
handleTopChange), or change RetrievalDocuments' onTesting to pass the current
top value through to handleTestChunk when invoking onTesting(documentIds).
Reference: handleTestChunk, onTesting (RetrievalDocuments), and handleTopChange
so the same top N state is used for both code paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e9b26d48-69b0-48ff-8849-dad9b9af7251

📥 Commits

Reviewing files that changed from the base of the PR and between 381091d and 5363da7.

📒 Files selected for processing (10)
  • api/apps/services/dataset_api_service.py
  • web/src/components/top-select.tsx
  • web/src/hooks/use-knowledge-request.ts
  • web/src/locales/en.ts
  • web/src/locales/zh.ts
  • web/src/pages/dataset/testing/index.tsx
  • web/src/pages/dataset/testing/testing-form.tsx
  • web/src/pages/dataset/testing/testing-result.tsx
  • web/src/pages/next-search/hooks.ts
  • web/src/pages/next-search/search-view.tsx

Comment thread web/src/locales/zh.ts
community: '社区报告生成',
communityTip:
'区块被聚集成层次化的社区,实体和关系通过更高抽象层次将每个部分连接起来。然后,我们使用 LLM 生成每个社区的摘要,称为社区报告。更多信息:https://www.microsoft.com/en-us/research/blog/graphrag-improving-global-search-via-dynamic-community-selection/',
top: '前n条',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use a neutral label for the field key.

Line 830 uses '前n条', which renders awkwardly as a form label. This key is used as the standalone label (knowledgeConfiguration.top), so it should be generic (e.g., Top/数量) instead of embedding a literal n.

Suggested change
-      top: '前n条',
+      top: 'Top',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
top: '前n条',
top: 'Top',
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/locales/zh.ts` at line 830, The label literal "前n条" is awkward as a
standalone form label; update the locale entry for the key "top" (used as
knowledgeConfiguration.top) in web/src/locales/zh.ts to a neutral, generic term
such as "数量" or "Top" so it reads naturally in forms; replace the value for the
"top" key with the chosen neutral label and ensure any usages rendering this
label still make sense in context.

@wangq8
wangq8 merged commit 70ae25f into infiniflow:main Jun 11, 2026
1 check passed
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (47fb462) to head (5363da7).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15942   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants