MCPcopy Create free account
hub / github.com/codag-megalith/codag-visualizer / updateMetadata

Method updateMetadata

frontend/src/cache.ts:1462–1499  ·  view source on GitHub ↗

* Update metadata for nodes in a cached file

(filePath: string, metadata: CachedMetadata)

Source from the content-addressed store, hash-verified

1460 * Update metadata for nodes in a cached file
1461 */
1462 updateMetadata(filePath: string, metadata: CachedMetadata) {
1463 const normalizedPath = this.toRelativePath(filePath);
1464 const fileCache = this.files[normalizedPath];
1465 if (!fileCache) return;
1466
1467 let updated = false;
1468 for (const node of fileCache.nodes) {
1469 const funcName = node.source?.function;
1470 if (!funcName) continue;
1471
1472 // Update label if provided
1473 if (metadata.labels[funcName] && metadata.labels[funcName] !== node.label) {
1474 node.label = metadata.labels[funcName];
1475 updated = true;
1476 }
1477
1478 // Update description if provided
1479 if (metadata.descriptions?.[funcName]) {
1480 node.description = metadata.descriptions[funcName];
1481 updated = true;
1482 }
1483 }
1484
1485 // Update edge labels
1486 if (metadata.edgeLabels && Object.keys(metadata.edgeLabels).length > 0) {
1487 for (const edge of fileCache.internalEdges) {
1488 const edgeKey = `${edge.source}->${edge.target}`;
1489 if (metadata.edgeLabels[edgeKey]) {
1490 edge.label = metadata.edgeLabels[edgeKey];
1491 updated = true;
1492 }
1493 }
1494 }
1495
1496 if (updated) {
1497 this.scheduleSave();
1498 }
1499 }
1500
1501 /**
1502 * Prune stale entries for files that no longer exist

Callers 2

activateFunction · 0.95
flushMethod · 0.80

Calls 2

toRelativePathMethod · 0.95
scheduleSaveMethod · 0.95

Tested by

no test coverage detected