Skip to content

fix(nodes): preserve Vue node size across collapse - #14107

Closed
r-vage wants to merge 5 commits into
Comfy-Org:mainfrom
r-vage:fix/vue-node-size-preservation
Closed

r-vage wants to merge 5 commits into
Comfy-Org:mainfrom
r-vage:fix/vue-node-size-preservation

Conversation

@r-vage

@r-vage r-vage commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve a Vue node's expanded workflow size while it is collapsed, so compact custom-node widths survive collapse/expand and save/load without extension-side size workarounds.

Changes

  • What: Separates persisted node size from transient rendered bounds in the layout store. Collapsed Vue DOM measurements update hit testing, links, dragging, and minimap geometry without replacing the serialized expanded size.
  • What: Caps collapsed rendering to the node's expanded width and caches the measured collapsed geometry for LiteGraph bounds calculations.
  • What: Restores expanded dimensions from the model when a node is expanded and keeps compact widths below the standard Vue-node minimum.
  • What: Keeps LiteGraph graph order synchronized when Vue nodes are brought to front, so save/load preserves the visible stacking order.
  • Breaking: None. Workflow schema and serialized node size remain unchanged.

Review Focus

  • The size/bounds separation in layout mutations and DOM resize tracking.
  • Collapsed node link endpoints, dragging, minimap geometry, and subgraph entry.
  • Compact widths across collapse/expand and serialized workflow output.

Testing

  • Focused Vitest coverage for layout mutations, DOM resize tracking, LiteGraph bounds, node dragging, z-order, and minimap data.
  • Playwright coverage for compact width persistence across collapse/expand;
    the focused Chromium regression passed twice on the validated combined tip.
  • Existing collapsed-link and bring-to-front Playwright suites, including updated intentional geometry snapshots.
  • pnpm typecheck
  • pnpm typecheck:browser
  • pnpm format:check
  • Stylelint, type-aware Oxlint, ESLint, Knip, and git diff --check

Screenshots (if applicable)

The updated Playwright snapshots show collapsed nodes constrained to their persisted expanded width and the resulting fit-to-view geometry.

@r-vage
r-vage requested a review from a team July 25, 2026 17:27
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 25, 2026
@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: 🚧 Building...

🎭 Playwright: ⏳ Running...

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Vue node sizing now separates model size from rendered bounds during collapse, resize, movement, slot positioning, and minimap projection. Layout operations carry preservation flags, collapsed measurements update cached widths, canvas z-order synchronizes graph state, and browser/unit tests cover the behavior.

Changes

Vue node geometry and interactions

Layer / File(s) Summary
Layout preservation contracts and handlers
src/renderer/core/layout/types.ts, src/renderer/core/layout/operations/*, src/renderer/core/layout/store/layoutStore.ts, src/renderer/core/layout/operations/layoutMutations.test.ts
Layout operations support preserveSize and preserveBounds during resize, movement, and batch updates.
Collapsed Vue sizing and resize tracking
src/lib/litegraph/src/LGraphNode*, src/renderer/extensions/vueNodes/components/LGraphNode.vue, src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking*, browser_tests/tests/vueNodes/nodeSizePreservation.spec.ts
Collapsed measurement, CSS sizing, and resize tracking distinguish rendered bounds from expanded model size.
Collapsed slot geometry and invalidation
src/renderer/core/canvas/litegraph/slotCalculations*, src/renderer/extensions/vueNodes/composables/useSlotElementTracking*, src/renderer/extensions/vueNodes/components/LGraphNode.test.ts
Collapsed slot positions use measured bounds and cached widths; slot layout invalidation and canvas redraw behavior are tested.
Layout consumers and minimap dimensions
src/renderer/extensions/vueNodes/layout/useNodeDrag*, src/renderer/extensions/minimap/data/*
Snapping preserves rendered bounds, and minimap dimensions come from layout bounds.
Canvas z-order and graph consistency
src/renderer/extensions/vueNodes/composables/useNodeZIndex*, browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts, browser_tests/tests/collapsedNodeLinks.spec.ts
Front-ordering updates canvas and layout state, while browser tests verify graph ordering and link alignment.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ResizeObserver
  participant ResizeTracking
  participant GraphNode
  participant LayoutStore
  ResizeObserver->>ResizeTracking: report collapsed element bounds
  ResizeTracking->>GraphNode: update _collapsed_width
  ResizeTracking->>LayoutStore: batchUpdateNodeBounds(bounds, preserveSize)
  LayoutStore->>GraphNode: update rendered bounds
  LayoutStore-->>GraphNode: retain model size
Loading

Possibly related PRs

Suggested reviewers: drjkl

🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
End-To-End Regression Coverage For Fixes ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Adr Compliance For Entity/Litegraph Changes ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preserving Vue node size across collapse and expand.
Description check ✅ Passed The description covers the summary, changes, review focus, testing, screenshots, and breaking-change status well enough for this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts`:
- Around line 94-101: Update the order evaluation in the bring-to-front test to
retain the node IDs from graph._nodes and graph.serialize().nodes without String
coercion. Assert that both last-node IDs are defined before comparing them,
preserving the existing equality check only after setup validity is confirmed.

In `@src/lib/litegraph/src/LGraphNode.test.ts`:
- Around line 681-697: Add coverage in the existing measure() tests for the
registered-layout branch: use real LiteGraph/layout-store instances to register
the node with layout.bounds.height differing from layout.size.height, then
assert out[3] equals the cached bounds height plus LiteGraph.NODE_TITLE_HEIGHT
while preserving the existing width and model-size expectations.

In
`@src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.test.ts`:
- Around line 302-305: Reuse the existing named graph-node fixture type declared
for testState.graphNodes in the graphNode declaration near the resize-tracking
test setup. Remove the duplicate inline type and use the shared fixture type, or
the real LiteGraph node type if already available, so both test fixtures stay
consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9b190938-b3ec-4be6-9abf-c7812559742b

📥 Commits

Reviewing files that changed from the base of the PR and between 1039660 and 928cacd.

⛔ Files ignored due to path filters (5)
  • browser_tests/tests/collapsedNodeLinks.spec.ts-snapshots/subgraph-entry-collapsed-node-links-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-overlapped-after-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-overlapped-before-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-widget-overlapped-after-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-widget-overlapped-before-chromium-linux.png is excluded by !**/*.png
📒 Files selected for processing (17)
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts
  • browser_tests/tests/vueNodes/nodeSizePreservation.spec.ts
  • src/lib/litegraph/src/LGraphNode.test.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/renderer/core/layout/operations/layoutMutations.test.ts
  • src/renderer/core/layout/operations/layoutMutations.ts
  • src/renderer/core/layout/store/layoutStore.ts
  • src/renderer/core/layout/types.ts
  • src/renderer/extensions/minimap/data/LayoutStoreDataSource.ts
  • src/renderer/extensions/minimap/data/MinimapDataSource.test.ts
  • src/renderer/extensions/vueNodes/components/LGraphNode.vue
  • src/renderer/extensions/vueNodes/composables/useNodeZIndex.test.ts
  • src/renderer/extensions/vueNodes/composables/useNodeZIndex.ts
  • src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.test.ts
  • src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.ts
  • src/renderer/extensions/vueNodes/layout/useNodeDrag.test.ts
  • src/renderer/extensions/vueNodes/layout/useNodeDrag.ts

@r-vage

r-vage commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai rate limit

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Your plan includes PR reviews subject to rate limits. Reviews are available now.

@r-vage

r-vage commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts`:
- Around line 94-103: The bring-to-front test currently only verifies agreement
between graph and serialized node order, not that the intended node is last.
Update the evaluate/assertion flow around graph._nodes and graph.serialize() to
resolve the CLIP Text Encode node’s ID and assert both lastNodeId and
serialisedLastNodeId equal that ID, preserving the existing definedness checks.

In `@src/renderer/extensions/vueNodes/composables/useNodeZIndex.test.ts`:
- Around line 23-30: Add edge-case tests in useNodeZIndex for a missing canvas
and an unresolved getNodeById result, configuring the canvasStore mock state per
case. Verify layoutMutations still executes and canvas.bringToFront is not
called when either guard condition is absent, while preserving the existing
happy-path coverage.

In `@src/renderer/extensions/vueNodes/layout/useNodeDrag.ts`:
- Around line 264-270: Add an endDrag Vitest case for a selected secondary node
whose rendered nodeLayout.bounds differ from its model size, then assert the
snapping update uses nodeLayout.bounds width and height with preserveSize: true.
Keep the existing position assertions and ensure the fixture distinguishes
bounds from size so reverting to nodeLayout.size fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 378f2e4a-15dd-46c5-9c35-3f14c5ad09ff

📥 Commits

Reviewing files that changed from the base of the PR and between 1039660 and 278c324.

⛔ Files ignored due to path filters (5)
  • browser_tests/tests/collapsedNodeLinks.spec.ts-snapshots/subgraph-entry-collapsed-node-links-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-overlapped-after-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-overlapped-before-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-widget-overlapped-after-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-widget-overlapped-before-chromium-linux.png is excluded by !**/*.png
📒 Files selected for processing (17)
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts
  • browser_tests/tests/vueNodes/nodeSizePreservation.spec.ts
  • src/lib/litegraph/src/LGraphNode.test.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/renderer/core/layout/operations/layoutMutations.test.ts
  • src/renderer/core/layout/operations/layoutMutations.ts
  • src/renderer/core/layout/store/layoutStore.ts
  • src/renderer/core/layout/types.ts
  • src/renderer/extensions/minimap/data/LayoutStoreDataSource.ts
  • src/renderer/extensions/minimap/data/MinimapDataSource.test.ts
  • src/renderer/extensions/vueNodes/components/LGraphNode.vue
  • src/renderer/extensions/vueNodes/composables/useNodeZIndex.test.ts
  • src/renderer/extensions/vueNodes/composables/useNodeZIndex.ts
  • src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.test.ts
  • src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.ts
  • src/renderer/extensions/vueNodes/layout/useNodeDrag.test.ts
  • src/renderer/extensions/vueNodes/layout/useNodeDrag.ts

@r-vage

r-vage commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai rate limit

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Your plan includes PR reviews subject to rate limits. Reviews are available now.

@r-vage

r-vage commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@browser_tests/tests/collapsedNodeLinks.spec.ts`:
- Around line 32-58: Extract the repeated node lookup used by the page.evaluate
closures in collapsedNodeLinks.spec.ts into a shared helper, such as findNode or
getNodeGeometry, and update all five call sites to use it. Centralize the
existing ID comparison and missing-node handling so future lookup or
error-message changes require updating only one implementation.
- Around line 59-61: Update the geometry assertions in the collapsed-node tests,
including the checks around endpoint.outputX/outputY and the corresponding
assertions near the later collapsed-node case, to pass an explicit numDigits
value to every toBeCloseTo call. Use precision appropriate for the one-decimal
geometry values, such as 1, while preserving the existing alignment comparisons.

In `@src/lib/litegraph/src/LGraphNode.ts`:
- Around line 2144-2155: Replace the new public LGraphNode.measureCollapsedWidth
method with a standalone collapsed-width utility accepting the drawing context,
title, font style, and maximum width. Update LGraphNode.measure() and
LGraphNode.vue’s syncCollapseState to import and use the utility, preserving the
existing legacy title formula and width cap while keeping LGraphNode’s public
API unchanged.

In `@src/renderer/extensions/vueNodes/components/LGraphNode.test.ts`:
- Line 2: Add a test variant for syncCollapseState that mocks
canvasStore.canvas.ctx as available and graphNode.measureCollapsedWidth(ctx) to
return a known width, then assert --node-width and _collapsed_width use that
returned value. Keep the existing no-ctx fallback test unchanged so both
branches are covered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5a49719f-9d89-4527-b855-92260b42a869

📥 Commits

Reviewing files that changed from the base of the PR and between aac16ea and cd03b1a.

📒 Files selected for processing (9)
  • browser_tests/tests/collapsedNodeLinks.spec.ts
  • src/lib/litegraph/src/LGraphNode.test.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/renderer/core/canvas/litegraph/slotCalculations.test.ts
  • src/renderer/core/canvas/litegraph/slotCalculations.ts
  • src/renderer/extensions/vueNodes/components/LGraphNode.test.ts
  • src/renderer/extensions/vueNodes/components/LGraphNode.vue
  • src/renderer/extensions/vueNodes/composables/useSlotElementTracking.test.ts
  • src/renderer/extensions/vueNodes/composables/useSlotElementTracking.ts

Comment on lines +32 to +58
const node = window.app!.canvas.graph!._nodes.find(
(candidate) => String(candidate.id) === nodeId
)
return node?._collapsed_width ?? 0
}, NODE_ID)
)
.toBeGreaterThan(0)
const endpoint = await comfyPage.page.evaluate((nodeId) => {
const node = window.app!.canvas.graph!._nodes.find(
(candidate) => String(candidate.id) === nodeId
)
if (!node) throw new Error(`Node ${nodeId} not found`)
const nodeElement = document.querySelector<HTMLElement>(
`[data-node-id="${nodeId}"]`
)
if (!nodeElement) throw new Error(`Node element ${nodeId} not found`)
node.updateArea()
const bounds = node.getBounding()
const output = node.getOutputPos(0)
return {
boundsRight: bounds[0] + bounds[2],
boundsCenterY: bounds[1] + bounds[3] / 2,
domRight: node.pos[0] + nodeElement.offsetWidth,
outputX: output[0],
outputY: output[1]
}
}, NODE_ID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated node-lookup logic across five page.evaluate closures.

The pattern window.app!.canvas.graph!._nodes.find(candidate => String(candidate.id) === nodeId) is re-implemented inline at lines 32-34, 40-42, 103-105, 121-123, and 136-138. Consider extracting a small self-contained helper (e.g. inline a findNode function inside each evaluate body, or a getNodeGeometry(page, nodeId) fixture/util that both this file and similar specs can reuse) to reduce duplication and keep future changes to the lookup logic (e.g. error message wording) in one place.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@browser_tests/tests/collapsedNodeLinks.spec.ts` around lines 32 - 58, Extract
the repeated node lookup used by the page.evaluate closures in
collapsedNodeLinks.spec.ts into a shared helper, such as findNode or
getNodeGeometry, and update all five call sites to use it. Centralize the
existing ID comparison and missing-node handling so future lookup or
error-message changes require updating only one implementation.

Comment on lines +59 to +61
expect(endpoint.outputX).toBeCloseTo(endpoint.domRight)
expect(endpoint.outputX).toBeCloseTo(endpoint.boundsRight)
expect(endpoint.outputY).toBeCloseTo(endpoint.boundsCenterY)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate file =="
git ls-files | grep -F 'browser_tests/tests/collapsedNodeLinks.spec.ts' || true

echo "== relevant lines =="
if [ -f browser_tests/tests/collapsedNodeLinks.spec.ts ]; then
  sed -n '1,180p' browser_tests/tests/collapsedNodeLinks.spec.ts | cat -n
fi

echo "== toBeCloseTo occurrences in browser_tests =="
rg -n "toBeCloseTo\(" browser_tests || true

echo "== package/test framework references =="
for f in package.json browser_tests/README.md docs/guidance/playwright.md docs/testing/README.md .agents/checks/test-quality.md .agents/checks/playwright-e2e.md; do
  [ -f "$f" ] && echo "--- $f ---" && sed -n '1,240p' "$f"
done

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 49097


🌐 Web query:

Playwright expect toBeCloseTo default numDigits documentation

💡 Result:

In Playwright, the toBeCloseTo assertion used for comparing floating-point numbers has an optional numDigits parameter [1][2]. According to the standard behavior of this assertion, if numDigits is not provided, it defaults to 2 [3]. This means the assertion checks if the numbers are approximately equal with a precision of 2 decimal places [3]. The technical tolerance for this comparison is ±0.5 × 10^-numDigits [3]. If you require higher precision, you can specify a larger integer for the numDigits argument [3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== search Node.updateArea definitions =="
rg -n "updateArea\s*\(|updateArea\s*:" -S . --glob '!node_modules' --glob '!dist' --glob '!build' | head -100 || true

echo "== search measureCollapsedWidth/getBounding/getOutputPos definitions =="
rg -n "measureCollapsedWidth|function getBounding|getBounding\s*\(|getOutputPos|getConnectionPos" -S src packages browser_tests --glob '!node_modules' | head -200 || true

echo "== deterministic tolerance probe =="
node - <<'JS'
function toBeCloseTo(actual, expected, numDigits = 2) {
  const precision = Math.pow(10, -numDigits)
  const tolerance = precision / 2
  return Math.abs(actual - expected) < tolerance
}
for (const actual of [100.004, 100.005, 100.006, 100.01]) {
  console.log(JSON.stringify({ actual, defaultClose: toBeCloseTo(actual, 100.0), zeroClose: toBeCloseTo(actual, 100.0, 0) }))
}
JS

Repository: Comfy-Org/ComfyUI_frontend

Length of output: 6500


Use explicit toBeCloseTo precision for geometry assertions.

Without numDigits, toBeCloseTo defaults to 2 decimal places (0.005 tolerance). The collapsed-node geometry checks use DOM bounds/collapsed-width values rounded to one decimal place, so this can fail even when the alignment intent is correct. Add an explicit precision such as 1 or 0 to lines 59-61 and 117-118.

Also applies to lines 117-118.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@browser_tests/tests/collapsedNodeLinks.spec.ts` around lines 59 - 61, Update
the geometry assertions in the collapsed-node tests, including the checks around
endpoint.outputX/outputY and the corresponding assertions near the later
collapsed-node case, to pass an explicit numDigits value to every toBeCloseTo
call. Use precision appropriate for the one-decimal geometry values, such as 1,
while preserving the existing alignment comparisons.

Source: Path instructions

Comment on lines +2144 to +2155
/**
* Measures the collapsed node width using the legacy canvas title formula.
*/
measureCollapsedWidth(ctx: CanvasRenderingContext2D): number {
ctx.font = this.innerFontStyle
return Math.min(
this.size[0],
cachedMeasureText(ctx, this.getTitle() ?? '') +
LiteGraph.NODE_TITLE_HEIGHT * 2
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

New public method on LGraphNode increases its responsibility surface (ADR 0008).

measureCollapsedWidth is extracted as a public method on LGraphNode specifically so LGraphNode.vue can call it externally (node.measureCollapsedWidth(ctx)), rather than being extracted/migrated out of the class. Per the repo's litegraph guideline, this pattern should be avoided — prefer a standalone utility function (e.g. taking { ctx, title, fontStyle, maxWidth }) that both measure() here and LGraphNode.vue's syncCollapseState can call, keeping the class's public surface from growing.

♻️ Suggested direction
-  measureCollapsedWidth(ctx: CanvasRenderingContext2D): number {
-    ctx.font = this.innerFontStyle
-    return Math.min(
-      this.size[0],
-      cachedMeasureText(ctx, this.getTitle() ?? '') +
-        LiteGraph.NODE_TITLE_HEIGHT * 2
-    )
-  }
+  // moved to a standalone util, e.g. src/lib/litegraph/src/utils/measureCollapsedWidth.ts
+  // export function measureCollapsedWidth(ctx, { title, fontStyle, maxWidth }): number { ... }

Then measure() and LGraphNode.vue both import and call the free function.

Based on learnings, litegraph files should avoid adding new methods/properties to LGraphNode, LGraphCanvas, LGraph, or Subgraph that increase responsibilities instead of extracting/migrating behavior (ADR 0008).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Measures the collapsed node width using the legacy canvas title formula.
*/
measureCollapsedWidth(ctx: CanvasRenderingContext2D): number {
ctx.font = this.innerFontStyle
return Math.min(
this.size[0],
cachedMeasureText(ctx, this.getTitle() ?? '') +
LiteGraph.NODE_TITLE_HEIGHT * 2
)
}
// moved to a standalone util, e.g. src/lib/litegraph/src/utils/measureCollapsedWidth.ts
// export function measureCollapsedWidth(ctx, { title, fontStyle, maxWidth }): number { ... }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/litegraph/src/LGraphNode.ts` around lines 2144 - 2155, Replace the
new public LGraphNode.measureCollapsedWidth method with a standalone
collapsed-width utility accepting the drawing context, title, font style, and
maximum width. Update LGraphNode.measure() and LGraphNode.vue’s
syncCollapseState to import and use the utility, preserving the existing legacy
title formula and width cap while keeping LGraphNode’s public API unchanged.

Source: Coding guidelines

@@ -1,5 +1,5 @@
import { createTestingPinia } from '@pinia/testing'
import { render, screen } from '@testing-library/vue'
import { render, screen, waitFor } from '@testing-library/vue'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing coverage for the ctx-based measureCollapsedWidth path.

The new test only exercises the no-ctx fallback (Math.min(element.offsetWidth, node.size[0])); it never mocks canvasStore.canvas?.ctx + graphNode.measureCollapsedWidth, so the primary production branch (ctx ? node.measureCollapsedWidth(ctx) : ...) in syncCollapseState is untested. Since this is the common-case path (a canvas context is normally available), add a variant asserting --node-width/_collapsed_width reflect measureCollapsedWidth's return value when ctx is present.

Based on learnings, .agents/checks/test-quality.md calls for coverage of new/changed behavior rather than only the less-common fallback branch.

Also applies to: 21-33, 273-322

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/renderer/extensions/vueNodes/components/LGraphNode.test.ts` at line 2,
Add a test variant for syncCollapseState that mocks canvasStore.canvas.ctx as
available and graphNode.measureCollapsedWidth(ctx) to return a known width, then
assert --node-width and _collapsed_width use that returned value. Keep the
existing no-ctx fallback test unchanged so both branches are covered.

Source: Path instructions

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
browser_tests/tests/collapsedNodeLinks.spec.ts (2)

59-61: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Add explicit toBeCloseTo precision for geometry assertions.

These toBeCloseTo calls (lines 59-61, 117-118) still use the default 2-decimal precision (±0.005 tolerance) against DOM-measured pixel values, which can produce flaky failures even when alignment is correct. This was flagged on a previous commit and remains unresolved.

🐛 Proposed fix
-      expect(endpoint.outputX).toBeCloseTo(endpoint.domRight)
-      expect(endpoint.outputX).toBeCloseTo(endpoint.boundsRight)
-      expect(endpoint.outputY).toBeCloseTo(endpoint.boundsCenterY)
+      expect(endpoint.outputX).toBeCloseTo(endpoint.domRight, 1)
+      expect(endpoint.outputX).toBeCloseTo(endpoint.boundsRight, 1)
+      expect(endpoint.outputY).toBeCloseTo(endpoint.boundsCenterY, 1)
-      expect(collapsedWidths.cached).toBeCloseTo(collapsedWidths.expected)
-      expect(collapsedWidths.rendered).toBeCloseTo(collapsedWidths.expected)
+      expect(collapsedWidths.cached).toBeCloseTo(collapsedWidths.expected, 1)
+      expect(collapsedWidths.rendered).toBeCloseTo(collapsedWidths.expected, 1)

Also applies to: 117-118

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@browser_tests/tests/collapsedNodeLinks.spec.ts` around lines 59 - 61, Update
the geometry assertions in the collapsed-node link tests, including the checks
around endpoint.outputX, endpoint.domRight, endpoint.boundsRight, and
endpoint.outputY at both referenced locations, to pass an explicit precision to
every toBeCloseTo call. Use the precision appropriate for DOM-measured pixel
comparisons to avoid relying on the default two-decimal tolerance while
preserving the existing alignment expectations.

32-58: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicated node-lookup closure across five page.evaluate calls.

The window.app!.canvas.graph!._nodes.find((candidate) => String(candidate.id) === nodeId) pattern (lines 32-34, 40-42, 103-105, 121-123, 136-138) is still repeated verbatim. This was flagged on a previous commit and remains unresolved.

Also applies to: 90-171

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@browser_tests/tests/collapsedNodeLinks.spec.ts` around lines 32 - 58, Extract
the repeated node lookup used by the page.evaluate calls in the collapsed-node
link test into a reusable helper, then reuse it across all five evaluations,
including the locations around the endpoint and later checks. Preserve the
existing nodeId matching behavior and missing-node handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@browser_tests/tests/collapsedNodeLinks.spec.ts`:
- Around line 59-61: Update the geometry assertions in the collapsed-node link
tests, including the checks around endpoint.outputX, endpoint.domRight,
endpoint.boundsRight, and endpoint.outputY at both referenced locations, to pass
an explicit precision to every toBeCloseTo call. Use the precision appropriate
for DOM-measured pixel comparisons to avoid relying on the default two-decimal
tolerance while preserving the existing alignment expectations.
- Around line 32-58: Extract the repeated node lookup used by the page.evaluate
calls in the collapsed-node link test into a reusable helper, then reuse it
across all five evaluations, including the locations around the endpoint and
later checks. Preserve the existing nodeId matching behavior and missing-node
handling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 067432ba-ef09-43b6-b003-317223b41b25

📥 Commits

Reviewing files that changed from the base of the PR and between 1039660 and cd03b1a.

⛔ Files ignored due to path filters (5)
  • browser_tests/tests/collapsedNodeLinks.spec.ts-snapshots/subgraph-entry-collapsed-node-links-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-overlapped-after-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-overlapped-before-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-widget-overlapped-after-chromium-linux.png is excluded by !**/*.png
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts-snapshots/bring-to-front-widget-overlapped-before-chromium-linux.png is excluded by !**/*.png
📒 Files selected for processing (23)
  • browser_tests/tests/collapsedNodeLinks.spec.ts
  • browser_tests/tests/vueNodes/interactions/node/bringToFront.spec.ts
  • browser_tests/tests/vueNodes/nodeSizePreservation.spec.ts
  • src/lib/litegraph/src/LGraphNode.test.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/renderer/core/canvas/litegraph/slotCalculations.test.ts
  • src/renderer/core/canvas/litegraph/slotCalculations.ts
  • src/renderer/core/layout/operations/layoutMutations.test.ts
  • src/renderer/core/layout/operations/layoutMutations.ts
  • src/renderer/core/layout/store/layoutStore.ts
  • src/renderer/core/layout/types.ts
  • src/renderer/extensions/minimap/data/LayoutStoreDataSource.ts
  • src/renderer/extensions/minimap/data/MinimapDataSource.test.ts
  • src/renderer/extensions/vueNodes/components/LGraphNode.test.ts
  • src/renderer/extensions/vueNodes/components/LGraphNode.vue
  • src/renderer/extensions/vueNodes/composables/useNodeZIndex.test.ts
  • src/renderer/extensions/vueNodes/composables/useNodeZIndex.ts
  • src/renderer/extensions/vueNodes/composables/useSlotElementTracking.test.ts
  • src/renderer/extensions/vueNodes/composables/useSlotElementTracking.ts
  • src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.test.ts
  • src/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking.ts
  • src/renderer/extensions/vueNodes/layout/useNodeDrag.test.ts
  • src/renderer/extensions/vueNodes/layout/useNodeDrag.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant