mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-04 20:05:38 +08:00
refactor: optimize project auto-expand logic
This commit is contained in:
@@ -80,7 +80,7 @@ type UseSidebarControllerArgs = {
|
|||||||
export function useSidebarController({
|
export function useSidebarController({
|
||||||
projects,
|
projects,
|
||||||
selectedProject,
|
selectedProject,
|
||||||
selectedSession,
|
selectedSession: _selectedSession,
|
||||||
isLoading,
|
isLoading,
|
||||||
isMobile,
|
isMobile,
|
||||||
t,
|
t,
|
||||||
@@ -133,19 +133,23 @@ export function useSidebarController({
|
|||||||
}, [projects]);
|
}, [projects]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Expanded-project tracking is now keyed by the DB `projectId` so state
|
// Auto-expand only when the selected project identity changes.
|
||||||
// survives display-name edits and other mutations.
|
// Depending on the full `selectedProject` object (or `selectedSession`) causes
|
||||||
if (selectedProject) {
|
// websocket-driven list refreshes to re-open projects users manually collapsed.
|
||||||
setExpandedProjects((prev) => {
|
const selectedProjectId = selectedProject?.projectId;
|
||||||
if (prev.has(selectedProject.projectId)) {
|
if (!selectedProjectId) {
|
||||||
return prev;
|
return;
|
||||||
}
|
|
||||||
const next = new Set(prev);
|
|
||||||
next.add(selectedProject.projectId);
|
|
||||||
return next;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, [selectedSession, selectedProject]);
|
|
||||||
|
setExpandedProjects((prev) => {
|
||||||
|
if (prev.has(selectedProjectId)) {
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
const next = new Set(prev);
|
||||||
|
next.add(selectedProjectId);
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}, [selectedProject?.projectId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (projects.length > 0 && !isLoading) {
|
if (projects.length > 0 && !isLoading) {
|
||||||
|
|||||||
Reference in New Issue
Block a user