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

Function buildScreensModel

ui/src/lib/screens-model.ts:280–387  ·  view source on GitHub ↗
(payload: WireScreensPayload)

Source from the content-addressed store, hash-verified

278/* ---------------------------------------------------------------- build -- */
279
280export function buildScreensModel(payload: WireScreensPayload): ScreensModel {
281 const nodes = new Map<string, ScreenNodeInfo>();
282 const modules: WireMapModule[] = [];
283
284 for (const screen of payload.screens) {
285 const info: ScreenNodeInfo = {
286 id: screen.id,
287 label: screen.path,
288 sub: screen.component?.name ?? screen.file,
289 screen,
290 origin: false,
291 entry: payload.entry === screen.id,
292 unreached: false,
293 };
294 nodes.set(screen.id, info);
295 modules.push(moduleFor(info, screen.incoming + screen.outgoing));
296 }
297 for (const origin of payload.origins) {
298 const info: ScreenNodeInfo = {
299 id: origin.id,
300 label: origin.node.kind === 'component' ? `<${origin.node.name}>` : `${origin.node.name}()`,
301 sub: origin.sharedBy ? `on ${origin.sharedBy} screens` : origin.node.file,
302 screen: null,
303 origin: true,
304 entry: false,
305 unreached: false,
306 };
307 nodes.set(origin.id, info);
308 modules.push(moduleFor(info, origin.outgoing));
309 }
310
311 // One layout link per (from, to); the transitions behind it stay listed.
312 const byPair = new Map<string, WireScreenLink[]>();
313 for (const link of payload.links) {
314 const key = linkId({ source: link.from, target: link.to });
315 const list = byPair.get(key) ?? [];
316 list.push(link);
317 byPair.set(key, list);
318 }
319 const links: WireMapLink[] = [];
320 const edges = new Map<string, ScreenEdgeInfo>();
321 for (const [key, group] of byPair) {
322 const first = group[0]!;
323 if (!nodes.has(first.from) || !nodes.has(first.to)) continue;
324 // A screen that reopens itself (a retry) is a fact for the panel, not an
325 // arrow the layout can draw.
326 if (first.from === first.to) continue;
327 links.push({
328 source: first.from,
329 target: first.to,
330 count: group.length,
331 declared: group.length,
332 byKind: [{ kind: 'navigates', count: group.length }],
333 topPairs: [],
334 });
335 edges.set(key, {
336 id: key,
337 from: first.from,

Callers 2

fanFunction · 0.90

Calls 13

linkIdFunction · 0.90
buildMapLayoutFunction · 0.90
moduleForFunction · 0.85
edgeLabelFunction · 0.85
entryLayeringFunction · 0.85
trackedCurvesFunction · 0.85
samplePolylineFunction · 0.85
pushMethod · 0.80
hasMethod · 0.80
mapMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by 1

fanFunction · 0.72