MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / autoFetchAndIndex

Function autoFetchAndIndex

website/src/pages/Explore.tsx:324–415  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

322 if (!isGitlabRoute && owner?.toLowerCase() === "explore") return;
323
324 const autoFetchAndIndex = async () => {
325 setLoading(true);
326 setError(null);
327
328 try {
329 try {
330 const cached = await getCachedGraph(repoRef);
331 if (cached) {
332 setProgressText("Loading cached codebase graph...");
333 setProgressValue(90);
334 await new Promise((r) => setTimeout(r, 100));
335 setGraphData(cached);
336 setProgressText("Complete!");
337 setProgressValue(100);
338 setLoading(false);
339 console.log(`[Cache] Loaded repository graph for ${repoRef.fullPath} from IndexedDB cache.`);
340 return;
341 }
342 } catch (cacheErr) {
343 console.warn("[Cache] Error reading from cache:", cacheErr);
344 }
345
346 const { files, fileContents, latestCommitSha } = await fetchRepositoryFiles(repoRef, {
347 onProgressText: setProgressText,
348 onProgressValue: setProgressValue,
349 isPathIgnored,
350 fetchWithProgress,
351 fetchWithFallbackProxies,
352 });
353
354 // --- COMMON SEMANTIC INDEXING PHASE ---
355 setProgressText("Initializing WebAssembly semantic engine...");
356 setProgressValue(60);
357
358 // Load custom indexer settings from localStorage
359 let localConfig = { indexVariables: false, maxNodes: 100000, maxEdges: 50000 };
360 try {
361 const saved = localStorage.getItem('cgc_indexer_config');
362 if (saved) {
363 localConfig = { ...localConfig, ...JSON.parse(saved) };
364 }
365 } catch (e) {}
366
367 const graphData = await parseFilesIntoGraph(
368 files,
369 (msg, val, diagLog) => {
370 if (diagLog) {
371 setWorkerLogs(prev => [...prev, diagLog]);
372 } else {
373 setProgressText(msg);
374 setProgressValue(val);
375 }
376 },
377 {
378 indexVariables: localConfig.indexVariables,
379 maxNodes: localConfig.maxNodes,
380 maxEdges: localConfig.maxEdges
381 }

Callers 1

ExploreFunction · 0.85

Calls 7

fetchRepositoryFilesFunction · 0.90
parseFilesIntoGraphFunction · 0.90
getCachedGraphFunction · 0.85
cacheGraphFunction · 0.85
errorMethod · 0.80
logMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected