Skip to content

Feat: add filter in chat and search page - #16707

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:feat/chat-search-memory-filter
Jul 8, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:feat/chat-search-memory-filter

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

Feat: add filter in chat and search page

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 7, 2026
@dcc123456
dcc123456 requested a review from wangq8 July 7, 2026 09:56
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Owner-based filtering is added to chat and search lists. Both use-chat-request.ts and next-searches/hooks.ts integrate useHandleFilterSubmit, include filterValue in query keys, send owner_ids in requests, and expose filterValue/handleFilterSubmit. Corresponding pages build owner options via buildOwnersFilter and wire them into ListFilterBar.

Changes

Owner filtering for chats and searches

Layer / File(s) Summary
Chat list hook owner filtering
web/src/hooks/use-chat-request.ts
Integrates useHandleFilterSubmit, adds filterValue to the query key, sends owner_ids in listChats params, and returns filterValue/handleFilterSubmit.
Chat list page owner filter UI
web/src/pages/next-chats/index.tsx
Builds owners filter via buildOwnersFilter from chats data and wires ListFilterBar filters, value, and onChange.
Search list hook owner filtering
web/src/pages/next-searches/hooks.ts
Integrates useHandleFilterSubmit, adds filterValue to the query key, sends owner_ids and paramsSerializer in getSearchList params, and returns filterValue/handleFilterSubmit.
Search list page owner filter UI
web/src/pages/next-searches/index.tsx
Builds owners filter via buildOwnersFilter from search_apps data and wires ListFilterBar controlled value, onChange, and search input handling.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ChatList
  participant useFetchChatList
  participant useHandleFilterSubmit
  participant chatService

  ChatList->>useFetchChatList: request chats
  useFetchChatList->>useHandleFilterSubmit: get filterValue, handleFilterSubmit
  useFetchChatList->>chatService: listChats(owner_ids, keywords, pagination)
  chatService-->>useFetchChatList: chats data
  useFetchChatList-->>ChatList: chats, filterValue, handleFilterSubmit
  ChatList->>ChatList: buildOwnersFilter(chats)
  ChatList->>ChatList: render ListFilterBar(filters=owners, value=filterValue, onChange=handleFilterSubmit)
Loading

Poem

A rabbit hops through lists so long,
Filtering owners, righting wrong. 🐇
With filterValue held so tight,
Each chat and search now feels just right.
Thump-thump-thump — the query key spins,
Owner filters, the review wins!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly matches the main change: adding filters to the chat and search pages.
Description check ✅ Passed The description includes the required Summary section and matches the PR's stated purpose.

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.

@dcc123456 dcc123456 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 7, 2026
@dcc123456
dcc123456 marked this pull request as draft July 7, 2026 09:56
@dcc123456
dcc123456 marked this pull request as ready for review July 7, 2026 09:56

@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: 2

Caution

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

⚠️ Outside diff range comments (2)
web/src/hooks/use-chat-request.ts (1)

76-83: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Raw queryKey array violates query key factory guideline.

The queryKey is written as an inline array literal rather than via a query key factory returning an as const tuple.

♻️ Suggested direction
+export const chatListQueryKeys = {
+  list: (params: { debouncedSearchString: string; filterValue: FilterValue } & Pagination) =>
+    [ChatApiAction.FetchChatList, params] as const,
+};
...
-    queryKey: [
-      ChatApiAction.FetchChatList,
-      {
-        debouncedSearchString,
-        filterValue,
-        ...pagination,
-      },
-    ],
+    queryKey: chatListQueryKeys.list({ debouncedSearchString, filterValue, ...pagination }),
As per coding guidelines, "Never write raw `queryKey` arrays inline; use a query key factory object that returns `as const` tuples for every `useQuery` and `invalidateQueries` call."
🤖 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/hooks/use-chat-request.ts` around lines 76 - 83, The `useQuery` call
in `use-chat-request` is using an inline raw `queryKey` array instead of the
required query key factory pattern. Replace the literal array with a dedicated
factory entry for `ChatApiAction.FetchChatList` that returns an `as const`
tuple, and then use that factory result here (and keep the same shape for any
related `invalidateQueries` usage) so the key is consistent and typed.

Source: Coding guidelines

web/src/pages/next-searches/hooks.ts (1)

59-67: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Align owner_ids with the request payload. filterValue.owner is a string[] here, and the serializer sends repeated owner_ids keys, so SearchListParams.owner_ids should be string[] to avoid the type drifting from actual usage.

🤖 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-searches/hooks.ts` around lines 59 - 67, The
SearchListParams owner_ids type is out of sync with how the request is actually
built, since filterValue.owner is a string[] and the serializer emits repeated
owner_ids entries. Update SearchListParams in hooks.ts so owner_ids is typed as
string[] and make sure any code using this interface matches the array-based
request payload, especially where the search list params are assembled.
🧹 Nitpick comments (1)
web/src/pages/next-chats/index.tsx (1)

31-33: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Memoize owners to avoid recomputation/new reference every render.

buildOwnersFilter and the wrapping array are recreated on every render, producing a new array reference passed to ListFilterBar/FilterPopover even when data.chats hasn't changed content-wise.

♻️ Suggested fix
-  const owners = [
-    buildOwnersFilter(data?.chats ?? [], undefined, tc('owner')),
-  ];
+  const owners = useMemo(
+    () => [buildOwnersFilter(data?.chats ?? [], undefined, tc('owner'))],
+    [data?.chats, tc],
+  );
🤖 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-chats/index.tsx` around lines 31 - 33, The owners filter
is being rebuilt on every render in the next-chats page, creating a new array
reference even when the chats data has not changed. Memoize the owners value in
the index component using the existing data dependency so `buildOwnersFilter`
and the wrapping array are only recomputed when `data.chats` or `tc('owner')`
changes, keeping the reference stable for `ListFilterBar` and `FilterPopover`.
🤖 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/pages/next-chats/index.tsx`:
- Around line 31-33: The owner filter options are being built from the already
filtered chat list, so the dropdown only shows the currently selected owner
after filtering. Update the `owners` computation in `index.tsx` to source data
from an unfiltered chat list instead of `data.chats`, while keeping
`buildOwnersFilter` as the helper used to derive the options.

In `@web/src/pages/next-searches/index.tsx`:
- Around line 29-34: The inline owners array passed to ListFilterBar is
recreated on every render, which causes FilterPopover to treat filters as
changed and reset its form. Memoize the owners value in next-searches index
using the existing list data and tc/buildOwnersFilter inputs so the reference
stays stable across pagination/search/refetch renders. Keep the change localized
around the owners definition before it is passed into ListFilterBar.

---

Outside diff comments:
In `@web/src/hooks/use-chat-request.ts`:
- Around line 76-83: The `useQuery` call in `use-chat-request` is using an
inline raw `queryKey` array instead of the required query key factory pattern.
Replace the literal array with a dedicated factory entry for
`ChatApiAction.FetchChatList` that returns an `as const` tuple, and then use
that factory result here (and keep the same shape for any related
`invalidateQueries` usage) so the key is consistent and typed.

In `@web/src/pages/next-searches/hooks.ts`:
- Around line 59-67: The SearchListParams owner_ids type is out of sync with how
the request is actually built, since filterValue.owner is a string[] and the
serializer emits repeated owner_ids entries. Update SearchListParams in hooks.ts
so owner_ids is typed as string[] and make sure any code using this interface
matches the array-based request payload, especially where the search list params
are assembled.

---

Nitpick comments:
In `@web/src/pages/next-chats/index.tsx`:
- Around line 31-33: The owners filter is being rebuilt on every render in the
next-chats page, creating a new array reference even when the chats data has not
changed. Memoize the owners value in the index component using the existing data
dependency so `buildOwnersFilter` and the wrapping array are only recomputed
when `data.chats` or `tc('owner')` changes, keeping the reference stable for
`ListFilterBar` and `FilterPopover`.
🪄 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: 04496376-27f3-4b8b-aed9-c0f6948ef3bb

📥 Commits

Reviewing files that changed from the base of the PR and between 7db3eea and 5e77b90.

📒 Files selected for processing (4)
  • web/src/hooks/use-chat-request.ts
  • web/src/pages/next-chats/index.tsx
  • web/src/pages/next-searches/hooks.ts
  • web/src/pages/next-searches/index.tsx

Comment on lines +31 to +33
const owners = [
buildOwnersFilter(data?.chats ?? [], undefined, tc('owner')),
];

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.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== file list ==\n'
git ls-files 'web/src/pages/next-chats/index.tsx' 'web/src/hooks/use-chat-request.ts' 'web/src/**/buildOwnersFilter*' 'web/src/**/owners*filter*' || true

printf '\n== outline next-chats index ==\n'
ast-grep outline web/src/pages/next-chats/index.tsx --view expanded || true

printf '\n== outline use-chat-request ==\n'
ast-grep outline web/src/hooks/use-chat-request.ts --view expanded || true

printf '\n== search buildOwnersFilter usages ==\n'
rg -n "buildOwnersFilter|owner_ids: filterValue\.owner|owner filter|owners filter" web/src -S || true

Repository: infiniflow/ragflow

Length of output: 3251


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== next-chats index slice ==\n'
sed -n '1,120p' web/src/pages/next-chats/index.tsx | cat -n

printf '\n== use-chat-request slice ==\n'
sed -n '65,115p' web/src/hooks/use-chat-request.ts | cat -n

printf '\n== list-filter-util slice ==\n'
sed -n '1,120p' web/src/utils/list-filter-util.ts | cat -n

printf '\n== related next-searches slice for comparison ==\n'
sed -n '1,80p' web/src/pages/next-searches/index.tsx | cat -n

Repository: infiniflow/ragflow

Length of output: 11162


Build owner filter options from an unfiltered source

owners is derived from data.chats, but useFetchChatList already filters that response with owner_ids: filterValue.owner. After selecting an owner, the dropdown will only include that owner, so switching to a different owner requires clearing the filter first. Pull the owner options from an unfiltered source instead.

🤖 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-chats/index.tsx` around lines 31 - 33, The owner filter
options are being built from the already filtered chat list, so the dropdown
only shows the currently selected owner after filtering. Update the `owners`
computation in `index.tsx` to source data from an unfiltered chat list instead
of `data.chats`, while keeping `buildOwnersFilter` as the helper used to derive
the options.

Comment on lines +29 to +34
filterValue,
handleFilterSubmit,
} = useFetchSearchList();

const owners = [
buildOwnersFilter(list?.data?.search_apps ?? [], undefined, tc('owner')),
];

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== index.tsx outline ==\n'
ast-grep outline web/src/pages/next-searches/index.tsx --view expanded || true

printf '\n== list filter related files ==\n'
fd -a "ListFilterBar.*" web/src || true
fd -a "FilterPopover.*" web/src || true
fd -a "CheckboxFormMultiple.*" web/src || true
fd -a "useFetchSearchList.*" web/src || true

Repository: infiniflow/ragflow

Length of output: 295


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== locate relevant files ==\n'
fd -a "ListFilterBar.*" web/src || true
fd -a "FilterPopover.*" web/src || true
fd -a "CheckboxFormMultiple.*" web/src || true
fd -a "next-searches" web/src/pages || true

printf '\n== outline next-searches index ==\n'
ast-grep outline web/src/pages/next-searches/index.tsx --view expanded || true

Repository: infiniflow/ragflow

Length of output: 349


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== search component symbols ==\n'
rg -n "ListFilterBar|FilterPopover|CheckboxFormMultiple|useFetchSearchList|buildOwnersFilter" web/src || true

printf '\n== search page source ==\n'
cat -n web/src/pages/next-searches/index.tsx | sed -n '1,220p'

Repository: infiniflow/ragflow

Length of output: 12183


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== list-filter-bar outline ==\n'
ast-grep outline web/src/components/list-filter-bar/index.tsx --view expanded || true

printf '\n== filter-popover outline ==\n'
ast-grep outline web/src/components/list-filter-bar/filter-popover.tsx --view expanded || true

printf '\n== list-filter-bar source ==\n'
cat -n web/src/components/list-filter-bar/index.tsx | sed -n '1,260p'

printf '\n== filter-popover source (1/2) ==\n'
cat -n web/src/components/list-filter-bar/filter-popover.tsx | sed -n '1,240p'

printf '\n== filter-popover source (2/2) ==\n'
cat -n web/src/components/list-filter-bar/filter-popover.tsx | sed -n '241,420p'

Repository: infiniflow/ragflow

Length of output: 18196


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== buildOwnersFilter ==\n'
cat -n web/src/utils/list-filter-util.ts | sed -n '1,180p'

printf '\n== useFetchSearchList ==\n'
cat -n web/src/pages/next-searches/hooks.ts | sed -n '1,180p'

printf '\n== any memoization in next-searches page ==\n'
rg -n "useMemo\\(|owners|filters=" web/src/pages/next-searches web/src/pages/next-chats web/src/pages/datasets/use-select-owners.ts web/src/pages/agents/hooks/use-select-filters.ts || true

Repository: infiniflow/ragflow

Length of output: 8861


Memoize owners before passing it to ListFilterBar
FilterPopover resets its form whenever filters changes, and this inline array creates a new reference on every render. That can clear unsaved selections while the popover is open during pagination/search/refetch updates. web/src/pages/next-searches/index.tsx:32-34

🤖 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-searches/index.tsx` around lines 29 - 34, The inline
owners array passed to ListFilterBar is recreated on every render, which causes
FilterPopover to treat filters as changed and reset its form. Memoize the owners
value in next-searches index using the existing list data and
tc/buildOwnersFilter inputs so the reference stays stable across
pagination/search/refetch renders. Keep the change localized around the owners
definition before it is passed into ListFilterBar.

@wangq8
wangq8 merged commit b9432bb into infiniflow:main Jul 8, 2026
12 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants