Skip to content

Commit 6904029

Browse files
[backport] Restore group node conversion menu with deprecated label (cherry-pick #4967) (#4987)
* [feat] Restore group node conversion menu with deprecated label (#4967) * Fix screenshot conflicts - use core/1.25 baseline versions * Revert screenshots to PR version with deprecated menu item
1 parent 263f52f commit 6904029

10 files changed

+65
-11
lines changed

browser_tests/tests/groupNode.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ test.describe('Group Node', () => {
1717
await libraryTab.open()
1818
})
1919

20-
test.skip('Is added to node library sidebar', async ({ comfyPage }) => {
20+
test('Is added to node library sidebar', async ({ comfyPage }) => {
2121
expect(await libraryTab.getFolder('group nodes').count()).toBe(1)
2222
})
2323

24-
test.skip('Can be added to canvas using node library sidebar', async ({
24+
test('Can be added to canvas using node library sidebar', async ({
2525
comfyPage
2626
}) => {
2727
const initialNodeCount = await comfyPage.getGraphNodesCount()
@@ -34,7 +34,7 @@ test.describe('Group Node', () => {
3434
expect(await comfyPage.getGraphNodesCount()).toBe(initialNodeCount + 1)
3535
})
3636

37-
test.skip('Can be bookmarked and unbookmarked', async ({ comfyPage }) => {
37+
test('Can be bookmarked and unbookmarked', async ({ comfyPage }) => {
3838
await libraryTab.getFolder(groupNodeCategory).click()
3939
await libraryTab
4040
.getNode(groupNodeName)
@@ -61,7 +61,7 @@ test.describe('Group Node', () => {
6161
).toHaveLength(0)
6262
})
6363

64-
test.skip('Displays preview on bookmark hover', async ({ comfyPage }) => {
64+
test('Displays preview on bookmark hover', async ({ comfyPage }) => {
6565
await libraryTab.getFolder(groupNodeCategory).click()
6666
await libraryTab
6767
.getNode(groupNodeName)
@@ -95,7 +95,7 @@ test.describe('Group Node', () => {
9595
)
9696
})
9797

98-
test.skip('Displays tooltip on title hover', async ({ comfyPage }) => {
98+
test('Displays tooltip on title hover', async ({ comfyPage }) => {
9999
await comfyPage.setSetting('Comfy.EnableTooltips', true)
100100
await comfyPage.convertAllNodesToGroupNode('Group Node')
101101
await comfyPage.page.mouse.move(47, 173)
@@ -104,7 +104,7 @@ test.describe('Group Node', () => {
104104
await expect(comfyPage.page.locator('.node-tooltip')).toBeVisible()
105105
})
106106

107-
test.skip('Manage group opens with the correct group selected', async ({
107+
test('Manage group opens with the correct group selected', async ({
108108
comfyPage
109109
}) => {
110110
const makeGroup = async (name, type1, type2) => {
@@ -165,7 +165,7 @@ test.describe('Group Node', () => {
165165
expect(visibleInputCount).toBe(2)
166166
})
167167

168-
test.skip('Reconnects inputs after configuration changed via manage dialog save', async ({
168+
test('Reconnects inputs after configuration changed via manage dialog save', async ({
169169
comfyPage
170170
}) => {
171171
const expectSingleNode = async (type: string) => {

browser_tests/tests/rightClickMenu.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ test.describe('Canvas Right Click Menu', () => {
2424
await expect(comfyPage.canvas).toHaveScreenshot('add-group-group-added.png')
2525
})
2626

27-
test.skip('Can convert to group node', async ({ comfyPage }) => {
27+
test('Can convert to group node', async ({ comfyPage }) => {
2828
await comfyPage.select2Nodes()
2929
await expect(comfyPage.canvas).toHaveScreenshot('selected-2-nodes.png')
3030
await comfyPage.rightClickCanvas()
31-
await comfyPage.clickContextMenuItem('Convert to Group Node')
31+
await comfyPage.clickContextMenuItem('Convert to Group Node (Deprecated)')
3232
await comfyPage.promptDialogInput.fill('GroupNode2CLIP')
3333
await comfyPage.page.keyboard.press('Enter')
3434
await comfyPage.promptDialogInput.waitFor({ state: 'hidden' })
76 Bytes
Loading
4.5 KB
Loading
-2.18 KB
Loading
-1.74 KB
Loading
-794 Bytes
Loading
-2.18 KB
Loading
-1.67 KB
Loading

src/extensions/core/groupNode.ts

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type NodeId } from '@/lib/litegraph/src/LGraphNode'
33
import {
44
type ExecutableLGraphNode,
55
type ExecutionId,
6+
LGraphCanvas,
67
LGraphNode,
78
LiteGraph,
89
SubgraphNode
@@ -1172,8 +1173,7 @@ export class GroupNodeHandler {
11721173
// @ts-expect-error fixme ts strict error
11731174
getExtraMenuOptions?.apply(this, arguments)
11741175

1175-
// @ts-expect-error fixme ts strict error
1176-
let optionIndex = options.findIndex((o) => o.content === 'Outputs')
1176+
let optionIndex = options.findIndex((o) => o?.content === 'Outputs')
11771177
if (optionIndex === -1) optionIndex = options.length
11781178
else optionIndex++
11791179
options.splice(
@@ -1634,6 +1634,57 @@ export class GroupNodeHandler {
16341634
}
16351635
}
16361636

1637+
function addConvertToGroupOptions() {
1638+
// @ts-expect-error fixme ts strict error
1639+
function addConvertOption(options, index) {
1640+
const selected = Object.values(app.canvas.selected_nodes ?? {})
1641+
const disabled =
1642+
selected.length < 2 ||
1643+
selected.find((n) => GroupNodeHandler.isGroupNode(n))
1644+
options.splice(index, null, {
1645+
content: `Convert to Group Node (Deprecated)`,
1646+
disabled,
1647+
callback: convertSelectedNodesToGroupNode
1648+
})
1649+
}
1650+
1651+
// @ts-expect-error fixme ts strict error
1652+
function addManageOption(options, index) {
1653+
const groups = app.graph.extra?.groupNodes
1654+
const disabled = !groups || !Object.keys(groups).length
1655+
options.splice(index, null, {
1656+
content: `Manage Group Nodes`,
1657+
disabled,
1658+
callback: () => manageGroupNodes()
1659+
})
1660+
}
1661+
1662+
// Add to canvas
1663+
const getCanvasMenuOptions = LGraphCanvas.prototype.getCanvasMenuOptions
1664+
LGraphCanvas.prototype.getCanvasMenuOptions = function () {
1665+
// @ts-expect-error fixme ts strict error
1666+
const options = getCanvasMenuOptions.apply(this, arguments)
1667+
const index = options.findIndex((o) => o?.content === 'Add Group')
1668+
const insertAt = index === -1 ? options.length - 1 : index + 2
1669+
addConvertOption(options, insertAt)
1670+
addManageOption(options, insertAt + 1)
1671+
return options
1672+
}
1673+
1674+
// Add to nodes
1675+
const getNodeMenuOptions = LGraphCanvas.prototype.getNodeMenuOptions
1676+
LGraphCanvas.prototype.getNodeMenuOptions = function (node) {
1677+
// @ts-expect-error fixme ts strict error
1678+
const options = getNodeMenuOptions.apply(this, arguments)
1679+
if (!GroupNodeHandler.isGroupNode(node)) {
1680+
const index = options.findIndex((o) => o?.content === 'Properties')
1681+
const insertAt = index === -1 ? options.length - 1 : index
1682+
addConvertOption(options, insertAt)
1683+
}
1684+
return options
1685+
}
1686+
}
1687+
16371688
const replaceLegacySeparators = (nodes: ComfyNode[]): void => {
16381689
for (const node of nodes) {
16391690
if (typeof node.type === 'string' && node.type.startsWith('workflow/')) {
@@ -1729,6 +1780,9 @@ const ext: ComfyExtension = {
17291780
}
17301781
}
17311782
],
1783+
setup() {
1784+
addConvertToGroupOptions()
1785+
},
17321786
async beforeConfigureGraph(
17331787
graphData: ComfyWorkflowJSON,
17341788
missingNodeTypes: string[]

0 commit comments

Comments
 (0)