feat(dashboard): file double-click also navigates the graph

Double-clicking a file in the Files tab previously only opened the source
viewer; the graph stayed wherever it was. Now also calls navigateToNode
first (drills into the layer + selects the node), then re-opens the code
viewer so the source panel stays visible.

Order matters: navigateToNodeInLayer resets codeViewerOpen, so the
openCodeViewer call has to come after.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lum1104
2026-05-01 17:55:56 +08:00
co-authored by Claude Opus 4.7
parent c6f5409111
commit 7e58e97b5a
@@ -141,9 +141,17 @@ function FileTreeRow({
export default function FileExplorer() {
const graph = useDashboardStore((s) => s.graph);
const openCodeViewer = useDashboardStore((s) => s.openCodeViewer);
const navigateToNode = useDashboardStore((s) => s.navigateToNode);
const entries = useMemo(() => buildFileTree(graph?.nodes ?? []), [graph]);
const [expanded, setExpanded] = useState<Set<string>>(() => new Set());
// Navigate the graph first (drills into layer + selects node, which clears the
// code viewer), then re-open the viewer so the source panel stays visible.
const handleOpenFile = (nodeId: string) => {
navigateToNode(nodeId);
openCodeViewer(nodeId);
};
const toggleFolder = (folderPath: string) => {
setExpanded((current) => {
const next = new Set(current);
@@ -194,7 +202,7 @@ export default function FileExplorer() {
depth={0}
expanded={expanded}
toggleFolder={toggleFolder}
openFile={openCodeViewer}
openFile={handleOpenFile}
/>
))
)}