MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / useGraphData

Function useGraphData

graph-ui/src/hooks/useGraphData.ts:79–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77const NO_PROGRESS: LoadProgress = { receivedBytes: 0, totalBytes: null };
78
79export function useGraphData(): UseGraphDataResult {
80 const [data, setData] = useState<GraphData | null>(null);
81 const [loading, setLoading] = useState(false);
82 const [error, setError] = useState<string | null>(null);
83 const [progress, setProgress] = useState<LoadProgress>(NO_PROGRESS);
84
85 const fetchOverview = useCallback(
86 async (project: string, maxNodes?: number) => {
87 setLoading(true);
88 setError(null);
89 setProgress(NO_PROGRESS);
90 try {
91 const result = await fetchLayout(project, maxNodes, setProgress);
92 setData(result);
93 } catch (e) {
94 setError(e instanceof Error ? e.message : "Failed to fetch layout");
95 } finally {
96 setLoading(false);
97 }
98 },
99 [],
100 );
101
102 const fetchDetail = useCallback(
103 async (project: string, _centerNode: string) => {
104 setLoading(true);
105 setError(null);
106 setProgress(NO_PROGRESS);
107 try {
108 /* TODO: detail level with center_node filtering */
109 const result = await fetchLayout(project, undefined, setProgress);
110 setData(result);
111 } catch (e) {
112 setError(e instanceof Error ? e.message : "Failed to fetch layout");
113 } finally {
114 setLoading(false);
115 }
116 },
117 [],
118 );
119
120 return { data, loading, error, progress, fetchOverview, fetchDetail };
121}

Callers 1

GraphTabFunction · 0.90

Calls 1

fetchLayoutFunction · 0.85

Tested by

no test coverage detected