MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / fetchTree

Function fetchTree

web/src/components/agent/agent-dependency-tree.tsx:90–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88 const abortController = new AbortController()
89
90 const fetchTree = async () => {
91 try {
92 setIsLoading(true)
93 setError(null)
94
95 const response = await fetch(
96 `/api/agents/${publisherId}/${agentId}/${version}/dependencies`,
97 { signal: abortController.signal },
98 )
99
100 if (!response.ok) {
101 throw new Error(
102 `Failed to fetch dependencies: ${response.statusText}`,
103 )
104 }
105
106 const data: AgentTreeData = await response.json()
107 if (isMounted) {
108 setTreeData(data)
109 }
110 } catch (err) {
111 if (err instanceof Error && err.name === 'AbortError') return
112 if (isMounted) {
113 console.error('Error fetching agent tree:', err)
114 setError(
115 err instanceof Error ? err.message : 'Failed to load dependencies',
116 )
117 }
118 } finally {
119 if (isMounted) {
120 setIsLoading(false)
121 }
122 }
123 }
124
125 fetchTree()
126 return () => {

Callers 1

AgentDependencyTreeFunction · 0.85

Calls 2

setErrorFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected