-
Notifications
You must be signed in to change notification settings - Fork 673
fix: preserve subgraph node size when editing or promoting widgets (FE-853) #14461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e7a309c
fix: preserve subgraph node size across widget promotion
claude 493b1de
test: settle resize before subgraph entry, align nested-promotion tes…
claude 58510e0
test: fit view before resizing subgraph nodes in resize-preservation …
claude 309bf96
fix: focus canvas instead of clicking to avoid topbar interception
claude 9226d33
fix: scale nodeSize to screen space in resizeNode helper
claude ce14f7a
fix: pan instead of zoom in subgraph resize preservation fitViewToNodes
claude 1a11486
test: demote nested promotion via context menu, not disabled toggle
claude 5ade094
test: use a smaller resize ratio to keep enterSubgraph button on-screen
claude 78e6996
fix: force right-click on disabled promoted widgets in unpromoteWidget
claude 5263b31
test: add failing regression test for subgraph resize loss (FE-853)
Glary-Bot 5aa98e8
test: move FE-853 resize arrangement into shared e2e fixtures
Glary-Bot cccc313
test: move growNodeByDrag to NodeOperationsHelper
Glary-Bot 21381df
test: assert promotion took effect before size checks
Glary-Bot daeffec
fix: dedupe promoted-widget rendering refresh, settle resizes in tests
Glary-Bot c74a4e9
test: address review feedback on fixtures and annotations
Glary-Bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
browser_tests/tests/subgraph/subgraphEditWidgetsResize.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { | ||
| comfyExpect as expect, | ||
| comfyPageFixture as test | ||
| } from '@e2e/fixtures/ComfyPage' | ||
|
|
||
| test.describe( | ||
| 'Subgraph node size across widget editing', | ||
| { | ||
| tag: ['@subgraph', '@node', '@widget', '@vue-nodes'], | ||
| annotation: { | ||
| type: 'issue', | ||
| description: | ||
| 'FE-853: widget editing collapsed a user-resized subgraph node to its minimum size' | ||
| } | ||
| }, | ||
| () => { | ||
| test.beforeEach(async ({ comfyPage }) => { | ||
| await comfyPage.settings.setSetting('Comfy.Canvas.SelectionToolbox', true) | ||
| await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph') | ||
| }) | ||
|
|
||
| test('retains a manual resize when Edit Subgraph Widgets is clicked', async ({ | ||
| comfyPage | ||
| }) => { | ||
| const { nodeRef, node, size } = await comfyPage.nodeOps.growNodeByDrag( | ||
| 'New Subgraph', | ||
| { x: 250, y: 250 } | ||
| ) | ||
|
|
||
| await comfyPage.subgraph.editor.openFromSelectionToolbox(node.root) | ||
| await comfyPage.nextFrame() | ||
|
|
||
| const sizeAfter = await nodeRef.getSize() | ||
| expect(sizeAfter.width).toBeCloseTo(size.width, 0) | ||
| expect(sizeAfter.height).toBeCloseTo(size.height, 0) | ||
| }) | ||
|
|
||
| test('retains a manual resize when an interior widget is promoted', async ({ | ||
| comfyPage | ||
| }) => { | ||
| const { nodeRef, size } = await comfyPage.nodeOps.growNodeByDrag( | ||
| 'New Subgraph', | ||
| { x: 250, y: 250 } | ||
| ) | ||
|
|
||
| await comfyPage.vueNodes.enterSubgraph(String(nodeRef.id)) | ||
| await comfyPage.subgraph.promoteWidget( | ||
| comfyPage.vueNodes.getNodeByTitle('KSampler'), | ||
| 'steps' | ||
| ) | ||
| await comfyPage.subgraph.exitViaBreadcrumb() | ||
|
|
||
| // Guards against a vacuous pass: if promotion silently became a no-op, | ||
| // the size assertions below would hold without exercising the bug. | ||
| await expect | ||
| .poll(() => | ||
| comfyPage.subgraph.getPromotedWidgetOrder(String(nodeRef.id)) | ||
| ) | ||
| .toContain('steps') | ||
|
|
||
| const sizeAfter = await nodeRef.getSize() | ||
| expect(sizeAfter.width).toBeCloseTo(size.width, 0) | ||
| // A newly promoted widget can legitimately raise the minimum height, so | ||
| // only a shrink below the user's size is a regression. | ||
| expect(sizeAfter.height).toBeGreaterThanOrEqual(size.height) | ||
| }) | ||
| } | ||
| ) |
229 changes: 229 additions & 0 deletions
229
browser_tests/tests/subgraph/subgraphResizePreservation.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,229 @@ | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| import type { ComfyPage } from '@e2e/fixtures/ComfyPage' | ||
| import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' | ||
|
|
||
| /** | ||
| * Regression coverage for FE-853: promoting/demoting a widget on a subgraph | ||
| * node — or merely opening the right-side properties panel for one — used to | ||
| * collapse the node back to its computed minimum size, discarding whatever | ||
| * size the user had explicitly set. | ||
| */ | ||
|
|
||
| /** | ||
| * These fixture workflows carry a saved pan/zoom that was not authored | ||
| * against the default 1280x720 Playwright viewport, so nodes can load | ||
| * partially below the fold. Panning the nodes into view keeps resize | ||
| * handles and the subgraph-enter footer button on-screen for subsequent | ||
| * screen-space clicks and drags. | ||
| * | ||
| * This deliberately pans rather than using the app's zoom-to-fit command: | ||
| * these tests compute drag targets and pixel-space size deltas directly | ||
| * from node.pos/node.size, which only line up with on-screen pixels when | ||
| * the canvas scale is 1. Panning leaves scale untouched, so it also avoids | ||
| * the 'Top' menu bar's workflow tab strip, which renders above the canvas | ||
| * and would intercept a click at a fixed coordinate. | ||
| */ | ||
| async function fitViewToNodes(comfyPage: ComfyPage): Promise<void> { | ||
| await comfyPage.page.evaluate(() => { | ||
| const canvas = window.app!.canvas | ||
| const nodes = canvas.graph?.nodes ?? [] | ||
| if (nodes.length === 0) return | ||
|
|
||
| const margin = 100 | ||
| const left = Math.min(...nodes.map((node) => node.pos[0])) | ||
| const top = Math.min(...nodes.map((node) => node.pos[1])) | ||
|
|
||
| canvas.ds.scale = 1 | ||
| canvas.ds.offset = [margin - left, margin - top] | ||
| canvas.setDirty(true, true) | ||
| }) | ||
| await comfyPage.nextFrame() | ||
| } | ||
|
|
||
| test.describe( | ||
| 'Subgraph node resize preservation', | ||
| { tag: ['@subgraph', '@widget', '@vue-nodes'] }, | ||
| () => { | ||
| test.beforeEach(async ({ comfyPage }) => { | ||
| await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top') | ||
| }) | ||
|
|
||
| test('Promoting a widget preserves a user-resized subgraph node', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph') | ||
| await fitViewToNodes(comfyPage) | ||
|
|
||
| const subgraphNode = | ||
| await comfyPage.vueNodes.getFixtureByTitle('New Subgraph') | ||
| await subgraphNode.resizeFromCorner('SE', 250, 200) | ||
| await comfyPage.nextFrame() | ||
| const resizedBox = (await subgraphNode.boundingBox())! | ||
|
|
||
| const ksampler = comfyPage.vueNodes.getNodeLocator('1') | ||
| await comfyPage.vueNodes.enterSubgraph('2') | ||
| await comfyPage.subgraph.promoteWidget(ksampler, 'steps') | ||
| await comfyPage.subgraph.exitViaBreadcrumb() | ||
|
|
||
| const box = await subgraphNode.boundingBox() | ||
| expect(box?.width).toBeCloseTo(resizedBox.width, 0) | ||
| expect(box?.height).toBeGreaterThanOrEqual(resizedBox.height - 1) | ||
| }) | ||
|
|
||
| test('Un-promoting a widget preserves a user-resized subgraph node', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph') | ||
| await fitViewToNodes(comfyPage) | ||
|
|
||
| const subgraphNode = | ||
| await comfyPage.vueNodes.getFixtureByTitle('New Subgraph') | ||
| const ksampler = comfyPage.vueNodes.getNodeLocator('1') | ||
| await comfyPage.vueNodes.enterSubgraph('2') | ||
| await comfyPage.subgraph.promoteWidget(ksampler, 'steps') | ||
| await comfyPage.subgraph.exitViaBreadcrumb() | ||
|
|
||
| await subgraphNode.resizeFromCorner('SE', 250, 200) | ||
| await comfyPage.nextFrame() | ||
| const resizedBox = (await subgraphNode.boundingBox())! | ||
|
|
||
| await comfyPage.vueNodes.enterSubgraph('2') | ||
| await comfyPage.subgraph.unpromoteWidget(ksampler, 'steps') | ||
| await comfyPage.subgraph.exitViaBreadcrumb() | ||
|
|
||
| const box = await subgraphNode.boundingBox() | ||
| expect(box?.width).toBeCloseTo(resizedBox.width, 0) | ||
| expect(box?.height).toBeCloseTo(resizedBox.height, 0) | ||
| }) | ||
|
|
||
| test('Opening the properties panel does not shrink a user-resized subgraph node', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph') | ||
| await fitViewToNodes(comfyPage) | ||
|
|
||
| const subgraphNode = | ||
| await comfyPage.vueNodes.getFixtureByTitle('New Subgraph') | ||
| await subgraphNode.resizeFromCorner('SE', 250, 200) | ||
| await comfyPage.nextFrame() | ||
| const resizedBox = (await subgraphNode.boundingBox())! | ||
|
|
||
| await subgraphNode.select() | ||
| await comfyPage.actionbar.propertiesButton.click() | ||
| await expect(comfyPage.menu.propertiesPanel.root).toBeVisible() | ||
|
|
||
| const box = await subgraphNode.boundingBox() | ||
| expect(box?.width).toBeCloseTo(resizedBox.width, 0) | ||
| expect(box?.height).toBeCloseTo(resizedBox.height, 0) | ||
| }) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| test('Promoting and demoting multiple widgets in sequence preserves the resized size', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph') | ||
| await fitViewToNodes(comfyPage) | ||
|
|
||
| const subgraphNode = | ||
| await comfyPage.vueNodes.getFixtureByTitle('New Subgraph') | ||
| await subgraphNode.resizeFromCorner('SE', 300, 250) | ||
| await comfyPage.nextFrame() | ||
| const resizedBox = (await subgraphNode.boundingBox())! | ||
| const ksampler = comfyPage.vueNodes.getNodeLocator('1') | ||
|
|
||
| await comfyPage.vueNodes.enterSubgraph('2') | ||
| await comfyPage.subgraph.promoteWidget(ksampler, 'steps') | ||
| await comfyPage.subgraph.promoteWidget(ksampler, 'cfg') | ||
| await comfyPage.subgraph.exitViaBreadcrumb() | ||
|
|
||
| await expect | ||
| .poll(async () => (await subgraphNode.boundingBox())?.width) | ||
| .toBeCloseTo(resizedBox.width, 0) | ||
|
|
||
| await comfyPage.vueNodes.enterSubgraph('2') | ||
| await comfyPage.subgraph.unpromoteWidget(ksampler, 'steps') | ||
| await comfyPage.subgraph.exitViaBreadcrumb() | ||
|
|
||
| await comfyPage.vueNodes.enterSubgraph('2') | ||
| await comfyPage.subgraph.unpromoteWidget(ksampler, 'cfg') | ||
| await comfyPage.subgraph.exitViaBreadcrumb() | ||
|
|
||
| const box = await subgraphNode.boundingBox() | ||
| expect(box?.width).toBeCloseTo(resizedBox.width, 0) | ||
| expect(box?.height).toBeCloseTo(resizedBox.height, 0) | ||
| }) | ||
|
|
||
| test('Manually resizing still works normally after a promotion', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await comfyPage.workflow.loadWorkflow('subgraphs/basic-subgraph') | ||
| await fitViewToNodes(comfyPage) | ||
|
|
||
| const subgraphNode = | ||
| await comfyPage.vueNodes.getFixtureByTitle('New Subgraph') | ||
| const ksampler = comfyPage.vueNodes.getNodeLocator('1') | ||
| await comfyPage.vueNodes.enterSubgraph('2') | ||
| await comfyPage.subgraph.promoteWidget(ksampler, 'steps') | ||
| await comfyPage.subgraph.exitViaBreadcrumb() | ||
|
|
||
| const boxBeforeResize = (await subgraphNode.boundingBox())! | ||
| await subgraphNode.resizeFromCorner('SE', 200, 150) | ||
| await comfyPage.nextFrame() | ||
|
|
||
| const box = await subgraphNode.boundingBox() | ||
| expect(box?.width).toBeGreaterThan(boxBeforeResize.width) | ||
| expect(box?.height).toBeGreaterThan(boxBeforeResize.height) | ||
| }) | ||
| } | ||
| ) | ||
|
|
||
| test.describe( | ||
| 'Subgraph node resize preservation — nested subgraphs', | ||
| { tag: ['@subgraph', '@widget', '@vue-nodes'] }, | ||
| () => { | ||
| test.beforeEach(async ({ comfyPage }) => { | ||
| await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top') | ||
| }) | ||
|
|
||
| test('Demoting a nested promotion does not shrink a user-resized outer host', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await comfyPage.workflow.loadWorkflow( | ||
| 'subgraphs/subgraph-nested-promotion' | ||
| ) | ||
| await fitViewToNodes(comfyPage) | ||
|
|
||
| const [outerHost] = await comfyPage.nodeOps.getNodeRefsByTitle('Sub 0') | ||
| expect(outerHost).toBeDefined() | ||
|
|
||
| const nodePos = await outerHost.getPosition() | ||
| const nodeSize = await outerHost.getSize() | ||
| // Keep the ratio modest: resizeNode scales the existing size (not an | ||
| // additive delta), and a larger ratio would push the resized node's | ||
| // bottom edge — and the subgraph-enter footer button below it — off | ||
| // the bottom of the viewport, since the top-left corner stays fixed | ||
| // during a resize-from-corner drag. | ||
| await comfyPage.nodeOps.resizeNode(nodePos, nodeSize, 1.4, 1.4) | ||
| const resizedSize = await outerHost.getSize() | ||
| expect(resizedSize.width).toBeGreaterThan(nodeSize.width) | ||
| expect(resizedSize.height).toBeGreaterThan(nodeSize.height) | ||
|
|
||
| // Node 6 ('Sub 1' instance) exposes a 'value_1' widget that is itself a | ||
| // promotion chain three subgraphs deep (Inner 3 -> Sub 2 -> Sub 1), | ||
| // which Sub 0 re-promotes onto `outerHost`. The per-row toggle in the | ||
| // properties panel is disabled for widgets promoted this way, so | ||
| // demoting has to go through the same context-menu action a user would | ||
| // use: entering the host and un-promoting from the widget's own node. | ||
| await comfyPage.vueNodes.enterSubgraph(String(outerHost.id)) | ||
| const sub1Instance = comfyPage.vueNodes.getNodeLocator('6') | ||
| await comfyPage.subgraph.unpromoteWidget(sub1Instance, 'value_1') | ||
| await comfyPage.subgraph.exitViaBreadcrumb() | ||
|
|
||
| await expect | ||
| .poll(async () => (await outerHost.getSize()).width) | ||
| .toBeCloseTo(resizedSize.width, 0) | ||
| const finalSize = await outerHost.getSize() | ||
| expect(finalSize.height).toBeCloseTo(resizedSize.height, 0) | ||
| }) | ||
| } | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be using expects or just throws?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throws — you're right, changed in c74a4e9.
Assertions in a fixture helper attribute failures to the fixture rather than the test, and blur the line between "the helper couldn't do its job" and "the behaviour under test is wrong". Both checks here are the former, so they're now throws:
Collapsed the two size
expects into a single throw that reports before and after, which is more useful than the two separate messages were. Also dropped the now-unusedexpectimport from the file.