Skip to content

Commit b772455

Browse files
Code2Collapseclaude
andcommitted
Graph Health: shrink the dead/cycle box with the node when collapsed
The dashed dead-node box (and cycle box) drew at node.size, but LiteGraph keeps node.size at the expanded size while a collapsed node renders only its title pill -- so the box stayed full-size on minimise. Use collapsed width + title height when node.flags.collapsed, and skip the dangling-slot dots (no visible slots when collapsed). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> (cherry picked from commit dadef39)
1 parent 5924b90 commit b772455

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

js/c2c_graph_health.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,31 @@ function patchDraw() {
200200
if (!isDead && !isCycle && !isDang) return r;
201201
ctx.save();
202202
ctx.lineWidth = 2.0;
203+
// Box must track the COLLAPSED pill, not the (still-full) node.size.
204+
// LiteGraph keeps node.size at the expanded size when collapsed and
205+
// renders only the title bar — so use the collapsed width + title
206+
// height, otherwise the dashed box stays full-size on minimise.
207+
const collapsed = !!node.flags?.collapsed;
208+
const TITLE_H = (window.LiteGraph?.NODE_TITLE_HEIGHT) || 30;
209+
const boxW = collapsed
210+
? (node._collapsed_width || (window.LiteGraph?.NODE_COLLAPSED_WIDTH) || 80)
211+
: node.size[0];
212+
// For a collapsed node the visible pill spans y = -TITLE_H .. 0;
213+
// expanded spans the body 0 .. size[1].
214+
const boxY = collapsed ? -TITLE_H - 3 : -3;
215+
const boxH = collapsed ? TITLE_H : node.size[1];
203216
if (isCycle) {
204217
ctx.strokeStyle = tok("--c2c-danger", 85);
205-
ctx.strokeRect(-3, -3, node.size[0] + 6, node.size[1] + 6);
218+
ctx.strokeRect(-3, boxY, boxW + 6, boxH + 6);
206219
ctx.fillStyle = tok("--c2c-danger", 85);
207220
ctx.font = "12px sans-serif";
208-
ctx.fillText("↻", node.size[0] - 14, -8);
221+
ctx.fillText("↻", boxW - 14, collapsed ? -TITLE_H + 8 : -8);
209222
} else if (isDead) {
210223
ctx.strokeStyle = tok("--c2c-warn", 65);
211224
ctx.setLineDash([6, 4]);
212-
ctx.strokeRect(-3, -3, node.size[0] + 6, node.size[1] + 6);
225+
ctx.strokeRect(-3, boxY, boxW + 6, boxH + 6);
213226
}
214-
if (isDang) {
227+
if (isDang && !collapsed) {
215228
const slots = _result.dangling.filter((d) => d.id === node.id);
216229
ctx.setLineDash([]);
217230
ctx.fillStyle = tok("--c2c-danger", 95);

0 commit comments

Comments
 (0)