feat(skill-editor): render flat search result list in file tree

Replace the tree-filtered search with a flat list that shows icon + name
on the left and parent path on the right, matching the Figma design.
Clicking a file opens its tab; clicking a folder clears the search and
reveals the folder in the tree.
This commit is contained in:
yyh
2026-02-06 15:31:17 +08:00
parent ad3a5ad473
commit f1100b82f9
3 changed files with 123 additions and 0 deletions

View File

@ -199,6 +199,37 @@ function insertDraftNodeAtParent(
return { nodes: inserted ? nextNodes : nodes, inserted }
}
export type FlatSearchResult = {
node: AppAssetTreeView
parentPath: string
}
export function flattenMatchingNodes(
nodes: AppAssetTreeView[],
searchTerm: string,
): FlatSearchResult[] {
if (!searchTerm)
return []
const results: FlatSearchResult[] = []
const lowerTerm = searchTerm.toLowerCase()
function traverse(nodeList: AppAssetTreeView[]): void {
for (const node of nodeList) {
if (node.name.toLowerCase().includes(lowerTerm)) {
const lastSlash = node.path.lastIndexOf('/')
const parentPath = lastSlash > 0 ? node.path.slice(1, lastSlash) : ''
results.push({ node, parentPath })
}
if (node.children && node.children.length > 0)
traverse(node.children)
}
}
traverse(nodes)
return results
}
export function insertDraftTreeNode(
nodes: AppAssetTreeView[],
parentId: string | null,