fix(sidebar): search the managed chats along with project sessions (#3212)
* fix(sidebar): search the managed chats along with project sessions The sidebar builds search data per group, and every group renders `filteredNodes ?? []` while a query is active. Only project groups were ever given that data, so the managed chats — which render outside any project section — collapsed to an empty list as soon as anything was typed, however well a title matched. The header count ignored them for the same reason. Pass the chats group to the sections hook as a standalone group so it takes the same search pass and joins the match count. Building it before the hook runs keeps search-data ownership in one place instead of registering entries from the rendering component. No CHANGELOG entry: it is left out deliberately to keep this branch free of conflicts with other open PRs, and is to be written at release time. fixes #3200 * fix(sidebar): report the real search match count to the header The header rendered whatever `SessionSidebar` passed it, and that was a literal `0` — so "0 matches" was shown no matter how many sessions matched. The count exists: the sections hook already computes it, but only the session list can see it, and the header renders above the list. Report it upwards from the list instead of recomputing it in the header, so the number and the visible rows cannot disagree, and reset it to 0 when the list unmounts. fixes #3200 * fix(sidebar): keep chat-only search results on screen The chats render inside the scroller's top content, and the branch that handles "no project section matched" replaced the whole list with the empty state. A query matching only a chat therefore showed "No matching sessions" while the header — now reporting the real count — said one match, and the chat itself stayed hidden. That is the exact reproduction in the issue; the earlier manual check missed it because the query used also matched a project session. Tell the scroller when its top content holds results, and keep it on screen in that branch. The decision moves to `sessionProjectRender` next to the other render-selection helpers, where it can be tested without mounting the Vite-only component graph. fixes #3200
This commit is contained in:
@@ -77,6 +77,8 @@ const SessionSidebarComponent: React.FC<SessionSidebarProps> = ({
|
||||
const { t } = useI18n();
|
||||
const [isSessionSearchOpen, setIsSessionSearchOpen] = React.useState(false);
|
||||
const [sessionSearchQuery, setSessionSearchQuery] = React.useState('');
|
||||
// Reported by the session list below: the header cannot see what matched.
|
||||
const [searchMatchCount, setSearchMatchCount] = React.useState(0);
|
||||
const sessionSearchContainerRef = React.useRef<HTMLDivElement | null>(null);
|
||||
const sessionSearchInputRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const [editingProjectDialogId, setEditingProjectDialogId] = React.useState<string | null>(null);
|
||||
@@ -631,7 +633,7 @@ const SessionSidebarComponent: React.FC<SessionSidebarProps> = ({
|
||||
sessionSearchQuery={sessionSearchQuery}
|
||||
setSessionSearchQuery={setSessionSearchQuery}
|
||||
hasSessionSearchQuery={hasSessionSearchQuery}
|
||||
searchMatchCount={0}
|
||||
searchMatchCount={searchMatchCount}
|
||||
collapseAllProjects={projectView.actions.collapseAllProjects}
|
||||
expandAllProjects={projectView.actions.expandAllProjects}
|
||||
/>
|
||||
@@ -668,6 +670,7 @@ const SessionSidebarComponent: React.FC<SessionSidebarProps> = ({
|
||||
isWorktreeTopologyLoading,
|
||||
unresolvedWorktreeProjectPaths,
|
||||
projectView: projectView.state,
|
||||
onSearchMatchCountChange: setSearchMatchCount,
|
||||
}}
|
||||
actions={{
|
||||
rowActions: {
|
||||
|
||||
Reference in New Issue
Block a user