Skip to content

Fix: Accidentally deleted the previously selected chat. - #17710

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
cike8899:fix-search-required
Aug 3, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
cike8899:fix-search-required

Conversation

@cike8899

@cike8899 cike8899 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix: Accidentally deleted the previously selected chat.

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 3, 2026
@cike8899 cike8899 added the ci Continue Integration label Aug 3, 2026
@cike8899
cike8899 marked this pull request as draft August 3, 2026 04:04
@cike8899
cike8899 marked this pull request as ready for review August 3, 2026 04:04
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Search state now exposes a setter to session-list consumers. Conversation selection and deletion operate only on filtered conversations. Temporary conversation creation clears the active search string.

Changes

Search-aware conversation selection

Layer / File(s) Summary
Expose session search setter
web/src/hooks/logic-hooks/use-change-search.ts, web/src/hooks/use-chat-request.ts
The hooks now return setSearchString with the existing search state and handlers.
Scope selection actions to visible conversations
web/src/pages/next-chats/chat/sessions.tsx
Select-all, batch deletion, callback dependencies, and selected counts now use conversations visible under the active filter.
Reset search for temporary conversations
web/src/pages/next-chats/hooks/use-select-conversation-list.ts
Temporary conversation creation clears the session search string before adding the conversation.

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

Suggested labels: 🐞 bug, 🧰 typescript

Suggested reviewers: dcc123456

Poem

A rabbit checks the filtered row,
Selects the chats that browsers show.
Search resets when new sessions start,
Hidden chats stay safe apart.
Hop, hop—clean state wins the day!

🚥 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 describes the primary fix for accidental deletion of the previously selected chat.
Description check ✅ Passed The description includes the required Summary section and clearly states the issue that this pull request fixes.

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.

@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

🤖 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/chat/sessions.tsx`:
- Around line 95-101: Update toggleSelectAll in the selectedIds state updater so
it only adds or removes IDs present in conversationList, preserving selections
for hidden conversations in both branches and when the visible list is empty.
Add a regression test covering one hidden and one visible selected conversation.
🪄 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 Plus

Run ID: f9b4c8b8-5ec8-40b9-b269-d7189a5a1881

📥 Commits

Reviewing files that changed from the base of the PR and between 5aa60cb and 8d54b52.

📒 Files selected for processing (4)
  • web/src/hooks/logic-hooks/use-change-search.ts
  • web/src/hooks/use-chat-request.ts
  • web/src/pages/next-chats/chat/sessions.tsx
  • web/src/pages/next-chats/hooks/use-select-conversation-list.ts

Comment on lines 95 to +101
// Toggle select all
const toggleSelectAll = useCallback(() => {
setSelectedIds((prev) => {
if (prev.size === conversationList.length) {
const allVisibleSelected =
conversationList.length > 0 &&
conversationList.every((x) => prev.has(x.id));
if (allVisibleSelected) {

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 | 🟡 Minor | ⚡ Quick win

Keep select-all changes scoped to visible IDs.

allVisibleSelected checks only conversationList, but the return new Set() branch clears every ID in prev. Selecting all visible conversations can therefore remove selections hidden by the search. The other branch also replaces prev, and an empty visible list can clear hidden selections.

Update only the IDs in conversationList, or explicitly clear selection when the filter changes. Add a regression test for one hidden and one visible selected conversation.

Proposed fix
     if (allVisibleSelected) {
-      return new Set();
+      const next = new Set(prev);
+      conversationList.forEach((x) => next.delete(x.id));
+      return next;
     }
-    return new Set(conversationList.map((x) => x.id));
+    return new Set([
+      ...prev,
+      ...conversationList.map((x) => x.id),
+    ]);
📝 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
// Toggle select all
const toggleSelectAll = useCallback(() => {
setSelectedIds((prev) => {
if (prev.size === conversationList.length) {
const allVisibleSelected =
conversationList.length > 0 &&
conversationList.every((x) => prev.has(x.id));
if (allVisibleSelected) {
// Toggle select all
const toggleSelectAll = useCallback(() => {
setSelectedIds((prev) => {
const allVisibleSelected =
conversationList.length > 0 &&
conversationList.every((x) => prev.has(x.id));
if (allVisibleSelected) {
const next = new Set(prev);
conversationList.forEach((x) => next.delete(x.id));
return next;
}
return new Set([
...prev,
...conversationList.map((x) => x.id),
]);
🤖 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/chat/sessions.tsx` around lines 95 - 101, Update
toggleSelectAll in the selectedIds state updater so it only adds or removes IDs
present in conversationList, preserving selections for hidden conversations in
both branches and when the visible list is empty. Add a regression test covering
one hidden and one visible selected conversation.

@wangq8
wangq8 self-requested a review August 3, 2026 05:39
@wangq8
wangq8 merged commit 6245707 into infiniflow:main Aug 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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