MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / buildStepsModel

Function buildStepsModel

ui/src/lib/steps-model.ts:389–526  ·  view source on GitHub ↗
(payload: WireStepsPayload)

Source from the content-addressed store, hash-verified

387/* ---------------------------------------------------------------- build -- */
388
389export function buildStepsModel(payload: WireStepsPayload): StepsModel {
390 const nodes = new Map<string, StepNodeInfo>();
391 const modules: WireMapModule[] = [];
392 const counts: Record<WireStep['kind'], number> = {
393 anchor: 0,
394 screen: 0,
395 trigger: 0,
396 bridge: 0,
397 event: 0,
398 store: 0,
399 effect: 0,
400 };
401 const degree = new Map<string, number>();
402 for (const link of payload.links) {
403 degree.set(link.from, (degree.get(link.from) ?? 0) + 1);
404 degree.set(link.to, (degree.get(link.to) ?? 0) + 1);
405 }
406 for (const step of payload.steps) {
407 counts[step.kind]++;
408 const info: StepNodeInfo = { id: step.id, step, label: stepLabel(step), sub: stepSub(step, payload.project) };
409 nodes.set(step.id, info);
410 modules.push({
411 id: step.id,
412 label: info.label,
413 files: 1,
414 symbols: degree.get(step.id) ?? 0,
415 languages: [],
416 test: false,
417 generated: 0,
418 generatedFiles: [],
419 facade: false,
420 fileList: { total: 1, shown: 1, truncated: false, items: [step.node?.file ?? step.sub] },
421 // Not the Map: a step has no dependent count and draws no weight bar.
422 dependents: { files: 0, modules: 0 },
423 });
424 }
425
426 // One layout link per (from, to); the links behind it stay listed.
427 const byPair = new Map<string, WireStepLink[]>();
428 for (const link of payload.links) {
429 if (!nodes.has(link.from) || !nodes.has(link.to) || link.from === link.to) continue;
430 const key = linkId({ source: link.from, target: link.to });
431 const list = byPair.get(key) ?? [];
432 list.push(link);
433 byPair.set(key, list);
434 }
435 const links: WireMapLink[] = [];
436 const edges = new Map<string, StepEdgeInfo>();
437 for (const [key, group] of byPair) {
438 const first = group[0]!;
439 links.push({
440 source: first.from,
441 target: first.to,
442 count: group.length,
443 declared: group.length,
444 byKind: [{ kind: 'calls', count: group.length }],
445 topPairs: [],
446 });

Callers 1

Calls 15

linkIdFunction · 0.90
edgeLabelFunction · 0.90
buildMapLayoutFunction · 0.90
trackedCurvesFunction · 0.90
samplePolylineFunction · 0.90
stepLabelFunction · 0.85
stepSubFunction · 0.85
triggerWordsFunction · 0.85
packRegionsFunction · 0.85
packStubsFunction · 0.85
markDecisionsFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected