Bug
In packages/web/src/client/src/components/all-chats/AllChatsPage.tsx, the auto-expand useEffect includes expandedGroups in its dependency array. Since toggleAllChatsGroup in the Zustand store always creates a new Set instance, every toggle during an active search re-triggers the effect, which calls expandAllChatsGroups() — immediately re-expanding the group the user just collapsed.
Steps to Reproduce
- Open All Chats page
- Type a search query (groups auto-expand)
- Click a group header to collapse it
- Observe: the group immediately re-expands
Expected
Users should be able to collapse groups during a search to focus on relevant results.
Root Cause
useEffect(() => {
if (storeSearchQuery) {
if (!preSearchExpansionRef.current) {
preSearchExpansionRef.current = new Set(expandedGroups);
}
expandAllChatsGroups();
} else {
preSearchExpansionRef.current = null;
}
}, [storeSearchQuery, expandAllChatsGroups, expandedGroups]); // <-- expandedGroups causes re-runs
expandedGroups is only used once (to capture pre-search state), and that line is guarded by if (!preSearchExpansionRef.current). Removing expandedGroups from the deps array fixes the bug without breaking the capture logic.
File
packages/web/src/client/src/components/all-chats/AllChatsPage.tsx ~line 171-183
Origin
PR #144 CodeRabbit review
Bug
In
packages/web/src/client/src/components/all-chats/AllChatsPage.tsx, the auto-expand useEffect includesexpandedGroupsin its dependency array. SincetoggleAllChatsGroupin the Zustand store always creates a newSetinstance, every toggle during an active search re-triggers the effect, which callsexpandAllChatsGroups()— immediately re-expanding the group the user just collapsed.Steps to Reproduce
Expected
Users should be able to collapse groups during a search to focus on relevant results.
Root Cause
expandedGroupsis only used once (to capture pre-search state), and that line is guarded byif (!preSearchExpansionRef.current). RemovingexpandedGroupsfrom the deps array fixes the bug without breaking the capture logic.File
packages/web/src/client/src/components/all-chats/AllChatsPage.tsx~line 171-183Origin
PR #144 CodeRabbit review