Repository navigation
Fix: Accidentally deleted the previously selected chat. - #17710
Conversation
📝 WalkthroughWalkthroughSearch 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. ChangesSearch-aware conversation selection
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
web/src/hooks/logic-hooks/use-change-search.tsweb/src/hooks/use-chat-request.tsweb/src/pages/next-chats/chat/sessions.tsxweb/src/pages/next-chats/hooks/use-select-conversation-list.ts
| // 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) { |
There was a problem hiding this comment.
🎯 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.
| // 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.
Summary
Fix: Accidentally deleted the previously selected chat.