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

Function resolveGraph

website/src/pages/Explore.tsx:488–519  ·  view source on GitHub ↗
(targetRepo: string)

Source from the content-addressed store, hash-verified

486
487 // Helper to resolve the correct graph data: active graph or read dynamically from IndexedDB cache!
488 const resolveGraph = async (targetRepo: string): Promise<any | null> => {
489 const cleanTarget = targetRepo?.trim().toLowerCase();
490 const cleanActive = activeRepoPath.trim().toLowerCase();
491
492 // Enforce strict local resolution: if the requested repository is NOT active and NOT in IndexedDB cache, return null.
493 // This strictly prevents fallback leaks where one user receives a completely different user's active codebase.
494 if (cleanTarget === cleanActive) {
495 return graphData;
496 }
497
498 console.log(`[Explore Tunnel] Dynamically fetching cached graph for ${cleanTarget} from IndexedDB...`);
499 try {
500 const db = await openDB();
501 const cachedGraph = await new Promise<any | null>((resolveDB, rejectDB) => {
502 const tx = db.transaction("graphs", "readonly");
503 const store = tx.objectStore("graphs");
504 const request = store.get(cleanTarget);
505 request.onsuccess = () => resolveDB(request.result || null);
506 request.onerror = () => rejectDB(request.error);
507 });
508
509 if (cachedGraph) {
510 console.log(`[Explore Tunnel] Successfully found cached graph for ${cleanTarget} in IndexedDB.`);
511 return cachedGraph;
512 }
513 } catch (e) {
514 console.warn(`[Explore Tunnel] Failed to load cached graph for ${cleanTarget} from DB:`, e);
515 }
516
517 console.warn(`[Explore Tunnel] Access denied: Target repository ${cleanTarget} is offline or not cached.`);
518 return null;
519 };
520
521 // 5. Execute query callback from Supabase Realtime Tunnel
522 const executeQueryCallback = async (queryType: string, target: string, params: any) => {

Callers 2

executeQueryCallbackFunction · 0.85
executeToolCallbackFunction · 0.85

Calls 3

openDBFunction · 0.85
getMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected