Skip to content

Commit 7faa2fd

Browse files
committed
debug: add logging to graph layout
1 parent c44f5b5 commit 7faa2fd

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

apps/registry/app/[username]/jobs-graph/utils/graphLayout.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ export const getLayoutedElements = (nodes, edges) => {
1616
const resumeNode = nodes.find((n) => n.data?.isResume);
1717
const resumeId = resumeNode?.id;
1818

19+
// DEBUG: Log what we're working with
20+
console.log('[LAYOUT] Nodes:', nodes.length, 'Edges:', edges.length);
21+
console.log('[LAYOUT] Resume ID:', resumeId);
22+
1923
if (!resumeId) {
20-
// Fallback: stack vertically
24+
console.log('[LAYOUT] No resume found, using fallback');
2125
return {
2226
nodes: nodes.map((node, i) => ({
2327
...node,
@@ -40,12 +44,19 @@ export const getLayoutedElements = (nodes, edges) => {
4044
}
4145
});
4246

47+
// DEBUG: How many children does resume have?
48+
const resumeChildren = childrenOf.get(resumeId) || [];
49+
console.log('[LAYOUT] Resume direct children:', resumeChildren.length);
50+
4351
// Attach orphans (nodes with no parent) to resume
52+
let orphanCount = 0;
4453
nodes.forEach((n) => {
4554
if (n.id !== resumeId && !hasParent.has(n.id)) {
4655
childrenOf.get(resumeId).push(n.id);
56+
orphanCount++;
4757
}
4858
});
59+
console.log('[LAYOUT] Orphans attached to resume:', orphanCount);
4960

5061
// Calculate width needed for each subtree
5162
const widthOf = new Map();
@@ -72,6 +83,7 @@ export const getLayoutedElements = (nodes, edges) => {
7283
};
7384

7485
calcWidth(resumeId);
86+
console.log('[LAYOUT] Total tree width:', widthOf.get(resumeId));
7587

7688
// Position nodes
7789
const positions = new Map();
@@ -116,13 +128,21 @@ export const getLayoutedElements = (nodes, edges) => {
116128
bottomY += NODE_HEIGHT + V_GAP;
117129

118130
let unplacedX = 0;
131+
let unplacedCount = 0;
119132
nodes.forEach((n) => {
120133
if (!positions.has(n.id)) {
121134
positions.set(n.id, { x: unplacedX, y: bottomY });
122135
unplacedX += NODE_WIDTH + H_GAP;
136+
unplacedCount++;
123137
}
124138
});
125139

140+
console.log('[LAYOUT] Placed:', placed.size, 'Unplaced:', unplacedCount);
141+
142+
// DEBUG: Show first few positions
143+
const resumePos = positions.get(resumeId);
144+
console.log('[LAYOUT] Resume position:', resumePos);
145+
126146
const layoutedNodes = nodes.map((node) => ({
127147
...node,
128148
position: positions.get(node.id) || { x: 0, y: 0 },

0 commit comments

Comments
 (0)