diff --git a/app/components/CodeFileTree.vue b/app/components/CodeFileTree.vue index 7e736c7507..89a2866b21 100644 --- a/app/components/CodeFileTree.vue +++ b/app/components/CodeFileTree.vue @@ -18,33 +18,18 @@ function isNodeActive(node: PackageFileTree): boolean { return false } -// State for expanded directories -const expandedDirs = ref>(new Set()) +const { toggleDir, isExpanded, autoExpandAncestors } = useFileTreeState(props.baseUrl) // Auto-expand directories in the current path watch( () => props.currentPath, path => { - if (!path) return - const parts = path.split('/') - for (let i = 1; i <= parts.length; i++) { - expandedDirs.value.add(parts.slice(0, i).join('/')) + if (path) { + autoExpandAncestors(path) } }, { immediate: true }, ) - -function toggleDir(path: string) { - if (expandedDirs.value.has(path)) { - expandedDirs.value.delete(path) - } else { - expandedDirs.value.add(path) - } -} - -function isExpanded(path: string): boolean { - return expandedDirs.value.has(path) -}