fix(sidebar): auto-expand parent node when navigating to subagent session (#893)

When a user navigates to a subagent (child) session, the parent session
node in the left sidebar was not automatically expanded, making the
child session invisible in the tree. This change adds a useEffect that
detects when the current session has a parentID and automatically adds
that parentID to expandedParents, ensuring the subagent session is
visible in the sidebar hierarchy.
This commit is contained in:
jwcrystal
2026-04-11 23:42:02 +03:00
committed by GitHub
parent 964c209ff6
commit 6425161bef
@@ -732,6 +732,23 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
});
}, [addProject, tauriIpcAvailable]);
// Auto-expand parent session when navigating to a subagent (child) session
React.useEffect(() => {
if (!currentSessionId) return;
const current = sessions.find((s) => s.id === currentSessionId);
const parentID = (current as Session & { parentID?: string | null })?.parentID;
if (!parentID) return;
setExpandedParents((prev) => {
if (prev.has(parentID)) return prev;
const next = new Set(prev);
next.add(parentID);
try {
safeStorage.setItem(SESSION_EXPANDED_STORAGE_KEY, JSON.stringify(Array.from(next)));
} catch { /* ignored */ }
return next;
});
}, [currentSessionId, sessions, safeStorage]);
const toggleParent = React.useCallback((sessionId: string) => {
setExpandedParents((prev) => {
const next = new Set(prev);