@@ -16,6 +16,8 @@ import type {
1616 GraphConfig ,
1717 ForceApiResponse ,
1818 ViewType ,
19+ SymbolGraphResponse ,
20+ SymbolApiNode ,
1921} from "@/lib/types" ;
2022import {
2123 galaxyView ,
@@ -26,6 +28,8 @@ import {
2628 forcesView ,
2729 churnView ,
2830 coverageView ,
31+ symbolView ,
32+ typesView ,
2933 getModuleColor ,
3034} from "@/lib/views" ;
3135import { cloudGroup } from "@/src/cloud-group" ;
@@ -55,7 +59,9 @@ export function GraphCanvas({
5559 focusNodeId,
5660 forceData,
5761 circularDeps,
62+ symbolData,
5863 onNodeClick,
64+ onSymbolClick,
5965} : {
6066 nodes : GraphApiNode [ ] ;
6167 edges : GraphApiEdge [ ] ;
@@ -64,7 +70,9 @@ export function GraphCanvas({
6470 focusNodeId : string | null ;
6571 forceData : ForceApiResponse | undefined ;
6672 circularDeps : string [ ] [ ] ;
73+ symbolData : SymbolGraphResponse | undefined ;
6774 onNodeClick : ( node : GraphApiNode ) => void ;
75+ onSymbolClick : ( symbol : SymbolApiNode ) => void ;
6876} ) : React . ReactElement {
6977 const fgRef = useRef < ForceGraph3DInstance | undefined > ( undefined ) ;
7078 const cloudsRef = useRef ( new Map < string , CloudEntry > ( ) ) ;
@@ -99,10 +107,18 @@ export function GraphCanvas({
99107 return churnView ( nodes , edges , config ) ;
100108 case "coverage" :
101109 return coverageView ( nodes , edges , config ) ;
110+ case "symbols" :
111+ return symbolData
112+ ? symbolView ( symbolData . symbolNodes , symbolData . callEdges , config )
113+ : { nodes : [ ] , links : [ ] } ;
114+ case "types" :
115+ return symbolData
116+ ? typesView ( symbolData . symbolNodes , symbolData . callEdges , config )
117+ : { nodes : [ ] , links : [ ] } ;
102118 default :
103119 return galaxyView ( nodes , edges , config ) ;
104120 }
105- } , [ nodes , edges , config , currentView , focusNodeId , forceData , circularDeps , nodeById ] ) ;
121+ } , [ nodes , edges , config , currentView , focusNodeId , forceData , circularDeps , nodeById , symbolData ] ) ;
106122
107123 // Build stable node/link objects for ForceGraph3D — store refs for tick handler access
108124 const fgGraphData = useMemo ( ( ) => {
@@ -347,20 +363,48 @@ export function GraphCanvas({
347363 return ( ) => { window . removeEventListener ( "search-fly" , handleSearchFly ) ; } ;
348364 } , [ ] ) ;
349365
366+ const symbolById = useMemo (
367+ ( ) => new Map ( symbolData ?. symbolNodes . map ( ( s ) => [ s . id , s ] ) ?? [ ] ) ,
368+ [ symbolData ] ,
369+ ) ;
370+
371+ const isSymbolView = currentView === "symbols" || currentView === "types" ;
372+
350373 const handleNodeClick = useCallback (
351374 ( node : Record < string , unknown > ) => {
352- const apiNode = nodeById . get ( node . id as string ) ;
353- if ( apiNode ) onNodeClick ( apiNode ) ;
375+ const id = node . id as string ;
376+ if ( isSymbolView ) {
377+ const sym = symbolById . get ( id ) ;
378+ if ( sym ) onSymbolClick ( sym ) ;
379+ } else {
380+ const apiNode = nodeById . get ( id ) ;
381+ if ( apiNode ) onNodeClick ( apiNode ) ;
382+ }
354383 } ,
355- [ nodeById , onNodeClick ] ,
384+ [ nodeById , symbolById , onNodeClick , onSymbolClick , isSymbolView ] ,
356385 ) ;
357386
387+ const showEmptyPlaceholder =
388+ isSymbolView && symbolData ?. symbolNodes . length === 0 ;
389+
390+ if ( showEmptyPlaceholder ) {
391+ return (
392+ < div className = "w-screen h-screen flex items-center justify-center bg-[#0a0a0f]" >
393+ < div className = "text-[#888] text-lg" > No symbols found</ div >
394+ </ div >
395+ ) ;
396+ }
397+
358398 return (
359399 < div ref = { containerRef } className = "w-screen h-screen" data-cloud-count = "0" >
360400 < ForceGraph3D
361401 ref = { fgRef }
362402 graphData = { fgGraphData }
363- nodeLabel = { ( n : Record < string , unknown > ) => `${ n . path as string } (${ n . loc as number } LOC)` }
403+ nodeLabel = { ( n : Record < string , unknown > ) =>
404+ isSymbolView
405+ ? `${ n . label as string } (${ n . path as string } )`
406+ : `${ n . path as string } (${ n . loc as number } LOC)`
407+ }
364408 nodeColor = { ( n : Record < string , unknown > ) => n . color as string }
365409 nodeVal = { ( n : Record < string , unknown > ) => n . size as number }
366410 nodeOpacity = { config . nodeOpacity }
0 commit comments