diff --git a/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-node-chromium-linux.png b/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-node-chromium-linux.png index cffe23ed1..67190e335 100644 Binary files a/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-node-chromium-linux.png and b/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-node-chromium-linux.png differ diff --git a/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-pinned-node-chromium-linux.png b/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-pinned-node-chromium-linux.png index 5cd2eacc4..54b98eaec 100644 Binary files a/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-pinned-node-chromium-linux.png and b/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-pinned-node-chromium-linux.png differ diff --git a/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-unpinned-node-chromium-linux.png b/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-unpinned-node-chromium-linux.png index cffe23ed1..67190e335 100644 Binary files a/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-unpinned-node-chromium-linux.png and b/browser_tests/tests/rightClickMenu.spec.ts-snapshots/right-click-unpinned-node-chromium-linux.png differ diff --git a/src/lib/litegraph/src/LGraphNode.ts b/src/lib/litegraph/src/LGraphNode.ts index 94c0310b1..666aa04eb 100644 --- a/src/lib/litegraph/src/LGraphNode.ts +++ b/src/lib/litegraph/src/LGraphNode.ts @@ -835,6 +835,9 @@ export class LGraphNode for (const w of this.widgets) { if (!w) continue + const input = this.inputs.find((i) => i.widget?.name === w.name) + if (input?.label) w.label = input.label + if ( w.options?.property && this.properties[w.options.property] != undefined diff --git a/src/locales/en/main.json b/src/locales/en/main.json index a32ebb503..4e634ed51 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -402,6 +402,7 @@ "Copy Image": "Copy Image", "Save Image": "Save Image", "Rename": "Rename", + "RenameWidget": "Rename Widget", "Copy": "Copy", "Duplicate": "Duplicate", "Paste": "Paste", diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index 35562533b..0fcbb57da 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -33,6 +33,7 @@ import { useToastStore } from '@/platform/updates/common/toastStore' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import type { NodeId } from '@/platform/workflow/validation/schemas/workflowSchema' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' +import { useDialogService } from '@/services/dialogService' import { transformInputSpecV2ToV1 } from '@/schemas/nodeDef/migration' import type { ComfyNodeDef as ComfyNodeDefV2, @@ -822,14 +823,31 @@ export const useLitegraphService = () => { } ) } - if (this.graph && !this.graph.isRootGraph) { - const [x, y] = canvas.graph_mouse - const overWidget = this.getWidgetOnPos(x, y, true) - if (overWidget) { + const [x, y] = canvas.graph_mouse + const overWidget = this.getWidgetOnPos(x, y, true) + if (overWidget) { + const input = this.inputs.find( + (inp) => inp.widget?.name === overWidget.name + ) + if (input) + options.unshift({ + content: `${t('contextMenu.RenameWidget')}: ${overWidget.label ?? overWidget.name}`, + callback: async () => { + const newLabel = await useDialogService().prompt({ + title: t('g.rename'), + message: t('g.enterNewName') + ':', + defaultValue: overWidget.label ?? overWidget.name + }) + if (!newLabel) return + overWidget.label = newLabel + input.label = newLabel + useCanvasStore().canvas?.setDirty(true) + } + }) + if (this.graph && !this.graph.isRootGraph) { addWidgetPromotionOptions(options, overWidget, this) } } - return [] } } diff --git a/src/utils/litegraphUtil.ts b/src/utils/litegraphUtil.ts index 29a597dc8..898b3ef23 100644 --- a/src/utils/litegraphUtil.ts +++ b/src/utils/litegraphUtil.ts @@ -204,7 +204,7 @@ export function compressWidgetInputSlots(graph: ISerialisedGraph) { } function matchesLegacyApi(input: ISerialisableNodeInput) { - return !(input.widget && input.link === null) + return !(input.widget && input.link === null && !input.label) } /**