From 9d91da0106f27168d5b1fb98ef1727a9890653e5 Mon Sep 17 00:00:00 2001 From: Kenny Date: Wed, 22 Apr 2026 23:54:01 -0400 Subject: [PATCH] fix: preserve parent tag expanded state on child create/delete (#142) - Persist expandedTagIds in localStorage so expansion state survives reloads - Call expandTagPath after creating child tag to ensure parent stays expanded --- src/components/tags/TagTree.tsx | 7 ++++++- src/stores/ui.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/tags/TagTree.tsx b/src/components/tags/TagTree.tsx index 06e299fe..01c4a886 100644 --- a/src/components/tags/TagTree.tsx +++ b/src/components/tags/TagTree.tsx @@ -60,6 +60,7 @@ export function TagTree({ onOpenTagSettings }: TagTreeProps = {}) { const setSelectedTag = useUIStore(s => s.setSelectedTag); const openSearchPalette = useUIStore(s => s.openSearchPalette); const expandedTagIds = useUIStore(s => s.expandedTagIds); + const expandTagPath = useUIStore(s => s.expandTagPath); const fetchAtoms = useAtomsStore(s => s.fetchAtoms); const fetchAtomsByTag = useAtomsStore(s => s.fetchAtomsByTag); @@ -155,7 +156,11 @@ export function TagTree({ onOpenTagSettings }: TagTreeProps = {}) { const handleCreateTag = async () => { if (newTagModal.name.trim()) { - await createTag(newTagModal.name.trim(), newTagModal.parentId || undefined); + const parentId = newTagModal.parentId; + await createTag(newTagModal.name.trim(), parentId || undefined); + if (parentId) { + expandTagPath([parentId]); + } setNewTagModal({ isOpen: false, parentId: null, name: '' }); } }; diff --git a/src/stores/ui.ts b/src/stores/ui.ts index 3ac54d1f..166bff84 100644 --- a/src/stores/ui.ts +++ b/src/stores/ui.ts @@ -519,6 +519,7 @@ export const useUIStore = create()( chatSidebarOpen: state.chatSidebarOpen, chatSidebarWidth: state.chatSidebarWidth, chatSidebarConversationId: state.chatSidebarConversationId, + expandedTagIds: state.expandedTagIds, }), // v0 → v1: 'grid' and 'list' were top-level ViewMode values. They're now // collapsed into a single 'atoms' view with a separate atomsLayout field.