Line data Source code
1 : import { useCurrentUser } from '@/composables/auth/useCurrentUser'
2 : import { useAuthActions } from '@/composables/auth/useAuthActions'
3 : import { useSelectedLiteGraphItems } from '@/composables/canvas/useSelectedLiteGraphItems'
4 : import { visibleCanvasViewport } from '@/composables/canvas/visibleCanvasViewport'
5 : import { useSubgraphOperations } from '@/composables/graph/useSubgraphOperations'
6 : import { useExternalLink } from '@/composables/useExternalLink'
7 : import { useModelSelectorDialog } from '@/composables/useModelSelectorDialog'
8 : import { useRunButtonTelemetry } from '@/composables/useRunButtonTelemetry'
9 : import {
10 : DEFAULT_DARK_THEME_PRESET,
11 : DEFAULT_LIGHT_THEME_PRESET
12 : } from '@comfyorg/theme-core/builtInThemePresets'
13 :
14 : import { tryToggleWidgetPromotion } from '@/core/graph/subgraph/promotionUtils'
15 : import { t } from '@/i18n'
16 : import {
17 : LGraphEventMode,
18 : LGraphGroup,
19 : LGraphNode,
20 : LiteGraph
21 : } from '@/lib/litegraph/src/litegraph'
22 : import {
23 : deleteSelectedLinks,
24 : hideSelectedLinks,
25 : showSelectedLinks,
26 : toggleNodeLinks
27 : } from '@/lib/litegraph/src/canvas/linkSelection'
28 : import type { PointTuple as Point } from '@comfyorg/shared-frontend-utils/geometry'
29 : import { useBillingContext } from '@/platform/billing/composables/useBillingContext'
30 : import { useSubscriptionPaywall } from '@/platform/billing/composables/useSubscriptionPaywall'
31 : import { openModelLibraryBrowser } from '@/platform/assets/composables/openModelLibraryBrowser'
32 : import { isSalesManagedTier } from '@/platform/billing/subscription/constants/tierPricing'
33 : import { subscribeToRunDialogOptions } from '@/platform/billing/subscription/utils/subscribeToRunDialogOptions'
34 : import { isCloud } from '@/platform/distribution/types'
35 : import { useMissingModelStore } from '@/platform/workflowErrors/missingModel/missingModelStore'
36 : import { resetOnboardingState } from '@/platform/onboarding/onboardingReset'
37 : import { useSettingStore } from '@/platform/settings/settingStore'
38 : import { buildSupportUrl } from '@/platform/support/config'
39 : import { useTelemetry } from '@comfyorg/telemetry'
40 : import { reportError } from '@comfyorg/telemetry/reportError'
41 : import type { ExecutionTriggerSource } from '@comfyorg/telemetry/types'
42 : import { useToast } from '@/components/ui/toast/toastStore'
43 : import { useWorkflowService } from '@/platform/workflow/core/services/workflowService'
44 : import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
45 : import type { ComfyWorkflow } from '@/platform/workflow/management/stores/workflowStore'
46 : import {
47 : useCanvasStore,
48 : useTitleEditorStore
49 : } from '@/renderer/core/canvas/canvasStore'
50 : import { api } from '@/scripts/api'
51 : import { app } from '@/scripts/app'
52 : import { useSettingsDialog } from '@/platform/settings/composables/useSettingsDialog'
53 : import { useAuthDialogs } from '@/composables/auth/useAuthDialogs'
54 : import { useDialogService } from '@/services/dialogService'
55 : import { useLitegraphService } from '@/services/litegraphService'
56 : import { useAssetsStore } from '@/stores/assetsStore'
57 : import type { ComfyCommand } from '@comfyorg/keybindings/commandStore'
58 : import { useExecutionStore } from '@/stores/executionStore'
59 : import { useModelStore } from '@/stores/modelStore'
60 : import { useHelpCenterStore } from '@/stores/helpCenterStore'
61 : import { useQueueSettingsStore } from '@/stores/queueSettingsStore'
62 : import { useQueueStore, useQueueUIStore } from '@/stores/queueStore'
63 : import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore'
64 : import { useSubgraphStore } from '@/stores/subgraphStore'
65 : import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore'
66 : import { useThemeStore } from '@/platform/theme/themeStore'
67 : import { usePropertiesPanelStore } from '@/renderer/extensions/propertiesPanel/propertiesPanelStore'
68 : import { useSearchBoxStore } from '@/stores/workspace/searchBoxStore'
69 : import { useWorkspaceStore } from '@/stores/workspaceStore'
70 : import { ensureWorkflowSuffix, getWorkflowSuffix } from '@/utils/formatUtil'
71 : import {
72 : getAllNonIoNodesInSubgraph,
73 : getExecutionIdsForSelectedNodes
74 : } from '@/utils/graphTraversalUtil'
75 : import { filterOutputNodes } from '@/utils/nodeFilterUtil'
76 : import {
77 : ManagerUIState,
78 : useManagerState
79 : } from '@/platform/customNodes/manager/composables/useManagerState'
80 : import { useManagerDialog } from '@/platform/customNodes/manager/composables/dialogs/useManagerDialog'
81 : import { ManagerTab } from '@/platform/customNodes/manager/types/comfyManagerTypes'
82 :
83 : import { useWorkflowTemplateSelectorDialog } from '@/platform/workflow/templates/composables/useWorkflowTemplateSelectorDialog'
84 :
85 : import { useMaskEditorStore } from '@comfyorg/mask-editor/maskEditorStore'
86 : import { useDialogStore } from '@/stores/dialogStore'
87 :
88 2355 : const moveSelectedNodesVersionAdded = '1.22.2'
89 2355 : let onboardingReplayInProgress: Promise<void> | undefined
90 :
91 2355 : export function useCoreCommands(): ComfyCommand[] {
92 2355 : const {
93 : canAccessSubscriptionFeatures,
94 : subscription,
95 : subscriptionState,
96 : isInitialized,
97 : initialize,
98 : type: billingType
99 : } = useBillingContext()
100 2355 : const { showSubscriptionDialog } = useSubscriptionPaywall()
101 :
102 185 : async function blockRunWithoutSubscription(): Promise<boolean> {
103 185 : if (!isCloud) return false
104 : if (!isInitialized.value) await initialize().catch(() => undefined)
105 : if (billingType.value === 'unknown') return true
106 : if (canAccessSubscriptionFeatures.value) return false
107 : if (isSalesManagedTier(subscription.value?.tier)) {
108 : toast.warning(t('subscription.salesManagedRunBlockedTitle'), {
109 : description: t('subscription.salesManagedRunBlockedDetail'),
110 : duration: 5000
111 : })
112 : } else {
113 : showSubscriptionDialog(
114 : subscribeToRunDialogOptions({
115 : subscriptionState: subscriptionState.value,
116 : hasFunds: subscription.value?.hasFunds
117 : })
118 : )
119 : }
120 : return true
121 : }
122 2355 : const workflowService = useWorkflowService()
123 2355 : const workflowStore = useWorkflowStore()
124 2355 : const settingsDialog = useSettingsDialog()
125 2355 : const dialogService = useDialogService()
126 2355 : const { showSignInDialog } = useAuthDialogs()
127 2355 : const themeStore = useThemeStore()
128 2355 : const authActions = useAuthActions()
129 2355 : const toast = useToast()
130 2355 : const canvasStore = useCanvasStore()
131 2355 : const executionStore = useExecutionStore()
132 2355 : const modelStore = useModelStore()
133 2355 : const missingModelStore = useMissingModelStore()
134 2355 : const telemetry = useTelemetry()
135 2355 : const { trackRunButton } = useRunButtonTelemetry()
136 2355 : const { staticUrls, buildDocsUrl } = useExternalLink()
137 2355 : const settingStore = useSettingStore()
138 :
139 2355 : const bottomPanelStore = useBottomPanelStore()
140 :
141 2355 : const dialogStore = useDialogStore()
142 2355 : const maskEditorStore = useMaskEditorStore()
143 :
144 2355 : const { getSelectedNodes, getSelectedNodesShallow, toggleSelectedNodesMode } =
145 : useSelectedLiteGraphItems()
146 2355 : const getTracker = () => workflowStore.activeWorkflow?.changeTracker
147 :
148 0 : function isQueuePanelV2Enabled() {
149 0 : return settingStore.get('Comfy.Queue.QPOV2')
150 : }
151 :
152 0 : async function toggleQueuePanelV2() {
153 0 : await settingStore.set('Comfy.Queue.QPOV2', !isQueuePanelV2Enabled())
154 : }
155 :
156 2355 : const moveSelectedNodes = (
157 : positionUpdater: (pos: Point, gridSize: number) => Point
158 : ) => {
159 4 : const selectedNodes = getSelectedNodes()
160 4 : if (selectedNodes.length === 0) return
161 :
162 4 : const gridSize = useSettingStore().get('Comfy.SnapToGrid.GridSize')
163 4 : selectedNodes.forEach((node) => {
164 8 : node.pos = positionUpdater(node.pos, gridSize)
165 : })
166 4 : app.canvas.setDirty(true, true)
167 : }
168 :
169 : const commands = [
170 : {
171 : id: 'Comfy.NewBlankWorkflow',
172 : icon: 'icon-[lucide--plus]',
173 : label: 'New Blank Workflow',
174 : menubarLabel: 'New',
175 : category: 'essentials' as const,
176 : function: async () => {
177 151 : const previousWorkflowHadNodes = app.rootGraph._nodes.length > 0
178 151 : await workflowService.loadBlankWorkflow()
179 151 : telemetry?.trackWorkflowCreated({
180 : workflow_type: 'blank',
181 : previous_workflow_had_nodes: previousWorkflowHadNodes
182 : })
183 : }
184 : },
185 : {
186 : id: 'Comfy.OpenWorkflow',
187 : icon: 'icon-[lucide--folder-open]',
188 : label: 'Open Workflow',
189 : menubarLabel: 'Open',
190 : category: 'essentials' as const,
191 : function: () => {
192 1 : app.ui.loadFile()
193 : }
194 : },
195 : {
196 : id: 'Comfy.LoadDefaultWorkflow',
197 : icon: 'icon-[lucide--code]',
198 : label: 'Load Default Workflow',
199 : function: async () => {
200 1 : const previousWorkflowHadNodes = app.rootGraph._nodes.length > 0
201 1 : await workflowService.loadDefaultWorkflow()
202 1 : telemetry?.trackWorkflowCreated({
203 : workflow_type: 'default',
204 : previous_workflow_had_nodes: previousWorkflowHadNodes
205 : })
206 : }
207 : },
208 : {
209 : id: 'Comfy.SaveWorkflow',
210 : icon: 'icon-[lucide--save]',
211 : label: 'Save Workflow',
212 : menubarLabel: 'Save',
213 : category: 'essentials' as const,
214 : function: async () => {
215 82 : const workflow = useWorkflowStore().activeWorkflow as ComfyWorkflow
216 82 : await workflowService.saveWorkflow(workflow)
217 : }
218 : },
219 : {
220 : id: 'Comfy.PublishSubgraph',
221 : icon: 'icon-[lucide--save]',
222 : label: 'Publish Subgraph',
223 : menubarLabel: 'Publish',
224 : function: async (metadata?: Record<string, unknown>) => {
225 5 : const name = metadata?.name as string | undefined
226 5 : await useSubgraphStore().publishSubgraph(name)
227 : }
228 : },
229 : {
230 : id: 'Comfy.SaveWorkflowAs',
231 : icon: 'icon-[lucide--save]',
232 : label: 'Save Workflow As',
233 : menubarLabel: 'Save As',
234 : category: 'essentials' as const,
235 : function: async () => {
236 16 : const workflow = useWorkflowStore().activeWorkflow as ComfyWorkflow
237 16 : await workflowService.saveWorkflowAs(workflow)
238 : }
239 : },
240 : {
241 : id: 'Comfy.RenameWorkflow',
242 : icon: 'icon-[lucide--pencil]',
243 : label: 'Rename Workflow',
244 : menubarLabel: 'Rename',
245 : function: async () => {
246 0 : const workflow = workflowStore.activeWorkflow
247 0 : if (!workflow || !workflow.isPersisted) return
248 :
249 0 : const newName = await dialogService.prompt({
250 : title: t('g.rename'),
251 : message: t('workflowService.enterFilenamePrompt'),
252 : defaultValue: workflow.filename
253 : })
254 0 : if (!newName || newName === workflow.filename) return
255 :
256 0 : const suffix = getWorkflowSuffix(workflow.suffix)
257 0 : const newPath =
258 : workflow.directory + '/' + ensureWorkflowSuffix(newName, suffix)
259 0 : await workflowService.renameWorkflow(workflow, newPath)
260 : }
261 : },
262 : {
263 : id: 'Comfy.ExportWorkflow',
264 : icon: 'icon-[lucide--download]',
265 : label: 'Export Workflow',
266 : menubarLabel: 'Export',
267 : category: 'essentials' as const,
268 : function: async () => {
269 3 : await workflowService.exportWorkflow('workflow', 'workflow')
270 : }
271 : },
272 : {
273 : id: 'Comfy.ExportWorkflowAPI',
274 : icon: 'icon-[lucide--download]',
275 : label: 'Export Workflow (API Format)',
276 : menubarLabel: 'Export (API)',
277 : function: async () => {
278 1 : await workflowService.exportWorkflow('workflow_api', 'output')
279 : }
280 : },
281 : {
282 : id: 'Comfy.Undo',
283 : icon: 'icon-[lucide--undo-2]',
284 : label: 'Undo',
285 : category: 'essentials' as const,
286 : mutatesGraph: () => !dialogStore.isDialogOpen('global-mask-editor'),
287 : function: async () => {
288 6 : if (dialogStore.isDialogOpen('global-mask-editor')) {
289 0 : maskEditorStore.canvasHistory.undo()
290 0 : return
291 : }
292 6 : await getTracker()?.undo()
293 : }
294 : },
295 : {
296 : id: 'Comfy.Redo',
297 : icon: 'icon-[lucide--rotate-cw]',
298 : label: 'Redo',
299 : category: 'essentials' as const,
300 : mutatesGraph: () => !dialogStore.isDialogOpen('global-mask-editor'),
301 : function: async () => {
302 4 : if (dialogStore.isDialogOpen('global-mask-editor')) {
303 0 : maskEditorStore.canvasHistory.redo()
304 0 : return
305 : }
306 4 : await getTracker()?.redo()
307 : }
308 : },
309 : {
310 : id: 'Comfy.ClearWorkflow',
311 : icon: 'icon-[lucide--trash-2]',
312 : label: 'Clear Workflow',
313 : category: 'essentials' as const,
314 : mutatesGraph: true,
315 : function: () => {
316 : const settingStore = useSettingStore()
317 88 : if (
318 : !settingStore.get('Comfy.ConfirmClear') ||
319 : confirm('Clear workflow?')
320 : ) {
321 88 : if (app.canvas.subgraph) {
322 0 : const subgraph = app.canvas.subgraph
323 : const nonIoNodes = getAllNonIoNodesInSubgraph(subgraph)
324 0 : nonIoNodes.forEach((node) => subgraph.remove(node))
325 : } else {
326 88 : app.clean()
327 : }
328 88 : api.dispatchCustomEvent('graphCleared')
329 : }
330 : }
331 : },
332 : {
333 : id: 'Comfy.Canvas.ResetView',
334 : icon: 'icon-[lucide--expand]',
335 : label: 'Reset View',
336 : function: () => {
337 0 : useLitegraphService().resetView()
338 : }
339 : },
340 : {
341 : id: 'Comfy.OpenClipspace',
342 : icon: 'icon-[lucide--clipboard]',
343 : label: 'Clipspace',
344 : function: () => {
345 0 : app.openClipspace()
346 : }
347 : },
348 : {
349 : id: 'Comfy.RefreshNodeDefinitions',
350 : icon: 'icon-[lucide--rotate-cw]',
351 : label: 'Refresh Node Definitions',
352 : category: 'essentials' as const,
353 : function: async () => {
354 12 : await Promise.all([app.refreshComboInNodes(), modelStore.refresh()])
355 9 : await useAssetsStore().invalidateAll()
356 : if (!isCloud) {
357 9 : await missingModelStore.refreshMissingModels({ reloadDefs: false })
358 : }
359 : }
360 : },
361 : {
362 : id: 'Comfy.Interrupt',
363 : icon: 'icon-[lucide--square]',
364 : label: 'Interrupt',
365 : category: 'essentials' as const,
366 : function: async (metadata?: Record<string, unknown>) => {
367 4 : const requestedJobId = metadata?.jobId
368 4 : const jobId =
369 : typeof requestedJobId === 'string' && requestedJobId.length > 0
370 : ? requestedJobId
371 : : executionStore.activeJobId
372 4 : await api.interrupt(jobId)
373 3 : toast.info(t('g.interrupted'), {
374 : description: t('toastMessages.interrupted'),
375 : duration: 1000
376 : })
377 : }
378 : },
379 : {
380 : id: 'Comfy.ClearPendingTasks',
381 : icon: 'icon-[lucide--square]',
382 : label: 'Clear Pending Tasks',
383 : category: 'essentials' as const,
384 : function: async () => {
385 1 : await useQueueStore().clear(['queue'])
386 1 : toast.info(t('g.confirmed'), {
387 : description: t('toastMessages.pendingTasksDeleted'),
388 : duration: 3000
389 : })
390 : }
391 : },
392 : {
393 : id: 'Comfy.BrowseTemplates',
394 : icon: 'icon-[lucide--folder-open]',
395 : label: 'Browse Templates',
396 : function: () => {
397 24 : useWorkflowTemplateSelectorDialog().show()
398 : }
399 : },
400 : {
401 : id: 'Comfy.Canvas.ZoomIn',
402 : icon: 'icon-[lucide--plus]',
403 : label: 'Zoom In',
404 : category: 'view-controls' as const,
405 : function: () => {
406 6 : const ds = app.canvas.ds
407 6 : ds.changeScale(ds.scale * 1.1, [
408 : ds.element.width / 2,
409 : ds.element.height / 2
410 : ])
411 6 : app.canvas.setDirty(true, true)
412 : }
413 : },
414 : {
415 : id: 'Comfy.Canvas.ZoomOut',
416 : icon: 'icon-[lucide--minus]',
417 : label: 'Zoom Out',
418 : category: 'view-controls' as const,
419 : function: () => {
420 33 : const ds = app.canvas.ds
421 33 : ds.changeScale(ds.scale / 1.1, [
422 : ds.element.width / 2,
423 : ds.element.height / 2
424 : ])
425 33 : app.canvas.setDirty(true, true)
426 : }
427 : },
428 : {
429 : id: 'Experimental.ToggleVueNodes',
430 : label: () =>
431 : `Experimental: ${
432 : useSettingStore().get('Comfy.VueNodes.Enabled') ? 'Disable' : 'Enable'
433 : } Nodes 2.0`,
434 : function: async () => {
435 2 : const settingStore = useSettingStore()
436 2 : const current = settingStore.get('Comfy.VueNodes.Enabled')
437 2 : await settingStore.set('Comfy.VueNodes.Enabled', !current)
438 : }
439 : },
440 : {
441 : id: 'Comfy.Canvas.FitView',
442 : icon: 'icon-[lucide--expand]',
443 : label: 'Fit view to selected nodes',
444 : menubarLabel: 'Zoom to fit',
445 : category: 'view-controls' as const,
446 : function: () => {
447 17 : if (app.canvas.empty) {
448 0 : toast.error(t('toastMessages.emptyCanvas'))
449 0 : return
450 : }
451 17 : app.canvas.fitViewToSelectionAnimated({
452 : viewport: visibleCanvasViewport(app.canvas)
453 : })
454 : }
455 : },
456 : {
457 : id: 'Comfy.Canvas.ToggleLock',
458 : icon: 'icon-[lucide--lock]',
459 : label: 'Canvas Toggle Lock',
460 : category: 'view-controls' as const,
461 : function: () => {
462 0 : app.canvas.read_only = !app.canvas.read_only
463 : }
464 : },
465 : {
466 : id: 'Comfy.Canvas.Lock',
467 : icon: 'icon-[lucide--lock]',
468 : label: 'Lock Canvas',
469 : category: 'view-controls' as const,
470 : function: () => {
471 11 : app.canvas.read_only = true
472 : }
473 : },
474 : {
475 : id: 'Comfy.Canvas.Unlock',
476 : icon: 'icon-[lucide--lock-open]',
477 : label: 'Unlock Canvas',
478 : function: () => {
479 27 : app.canvas.read_only = false
480 : }
481 : },
482 : {
483 : id: 'Comfy.Canvas.ToggleLinkVisibility',
484 : icon: 'icon-[lucide--eye]',
485 : label: 'Canvas Toggle Link Visibility',
486 : menubarLabel: 'Node Links',
487 : versionAdded: '1.3.6',
488 :
489 : function: (() => {
490 2355 : const settingStore = useSettingStore()
491 2355 : let lastLinksRenderMode = LiteGraph.SPLINE_LINK
492 :
493 2355 : return async () => {
494 2 : const currentMode = settingStore.get('Comfy.LinkRenderMode')
495 :
496 2 : if (currentMode === LiteGraph.HIDDEN_LINK) {
497 : // If links are hidden, restore the last positive value or default to spline mode
498 1 : await settingStore.set('Comfy.LinkRenderMode', lastLinksRenderMode)
499 : } else {
500 : // If links are visible, store the current mode and hide links
501 1 : lastLinksRenderMode = currentMode
502 1 : await settingStore.set(
503 : 'Comfy.LinkRenderMode',
504 : LiteGraph.HIDDEN_LINK
505 : )
506 : }
507 : }
508 : })(),
509 : active: () =>
510 : useSettingStore().get('Comfy.LinkRenderMode') !== LiteGraph.HIDDEN_LINK
511 : },
512 : {
513 : id: 'Comfy.Canvas.ToggleMinimap',
514 : icon: 'icon-[lucide--map]',
515 : label: 'Canvas Toggle Minimap',
516 : menubarLabel: 'Minimap',
517 : versionAdded: '1.24.1',
518 : function: async () => {
519 9 : const settingStore = useSettingStore()
520 9 : await settingStore.set(
521 : 'Comfy.Minimap.Visible',
522 : !settingStore.get('Comfy.Minimap.Visible')
523 : )
524 : },
525 : active: () => useSettingStore().get('Comfy.Minimap.Visible')
526 : },
527 : {
528 : id: 'Comfy.Queue.ToggleOverlay',
529 : icon: 'icon-[lucide--history]',
530 : label: () => t('queue.toggleJobHistory'),
531 : menubarLabel: () => t('queue.jobHistory'),
532 : versionAdded: '1.37.0',
533 : category: 'view-controls' as const,
534 : function: () => {
535 22 : useQueueUIStore().toggleOverlay()
536 : },
537 : active: () => useQueueUIStore().isOverlayExpanded
538 : },
539 : {
540 : id: 'Comfy.QueuePrompt',
541 : icon: 'icon-[lucide--play]',
542 : label: 'Queue Prompt',
543 : versionAdded: '1.3.7',
544 : category: 'essentials' as const,
545 : function: async (metadata?: {
546 : subscribe_to_run?: boolean
547 : trigger_source?: ExecutionTriggerSource
548 : }) => {
549 182 : trackRunButton(metadata)
550 182 : if (await blockRunWithoutSubscription()) return
551 :
552 182 : const batchCount = useQueueSettingsStore().batchCount
553 :
554 182 : useTelemetry()?.trackWorkflowExecution()
555 :
556 182 : await app.queuePrompt(0, batchCount, { intent: metadata })
557 : }
558 : },
559 : {
560 : id: 'Comfy.QueuePromptFront',
561 : icon: 'icon-[lucide--play]',
562 : label: 'Queue Prompt (Front)',
563 : versionAdded: '1.3.7',
564 : category: 'essentials' as const,
565 : function: async (metadata?: {
566 : subscribe_to_run?: boolean
567 : trigger_source?: ExecutionTriggerSource
568 : }) => {
569 1 : trackRunButton(metadata)
570 1 : if (await blockRunWithoutSubscription()) return
571 :
572 1 : const batchCount = useQueueSettingsStore().batchCount
573 :
574 1 : useTelemetry()?.trackWorkflowExecution()
575 :
576 1 : await app.queuePrompt(-1, batchCount, { intent: metadata })
577 : }
578 : },
579 : {
580 : id: 'Comfy.QueueSelectedOutputNodes',
581 : icon: 'icon-[lucide--play]',
582 : label: 'Queue Selected Output Nodes',
583 : versionAdded: '1.19.6',
584 : function: async (metadata?: {
585 : subscribe_to_run?: boolean
586 : trigger_source?: ExecutionTriggerSource
587 : }) => {
588 2 : trackRunButton(metadata)
589 2 : if (await blockRunWithoutSubscription()) return
590 :
591 2 : const batchCount = useQueueSettingsStore().batchCount
592 2 : const selectedNodes = getSelectedNodes()
593 2 : const selectedOutputNodes = filterOutputNodes(selectedNodes)
594 :
595 2 : if (selectedOutputNodes.length === 0) {
596 0 : toast.error(t('toastMessages.nothingToQueue'), {
597 : description: t('toastMessages.pleaseSelectOutputNodes')
598 : })
599 0 : return
600 : }
601 :
602 : // Get execution IDs for all selected output nodes and their descendants
603 2 : const executionIds =
604 : getExecutionIdsForSelectedNodes(selectedOutputNodes)
605 :
606 2 : if (executionIds.length === 0) {
607 0 : toast.error(t('toastMessages.failedToQueue'), {
608 : description: t('toastMessages.failedExecutionPathResolution')
609 : })
610 0 : return
611 : }
612 2 : useTelemetry()?.trackWorkflowExecution()
613 2 : await app.queuePrompt(0, batchCount, {
614 : queueNodeIds: executionIds,
615 : intent: metadata
616 : })
617 : }
618 : },
619 : {
620 : id: 'Comfy.ShowSettingsDialog',
621 : icon: 'icon-[lucide--settings]',
622 : label: 'Show Settings Dialog',
623 : versionAdded: '1.3.7',
624 : category: 'view-controls' as const,
625 : function: () => {
626 104 : settingsDialog.show()
627 : }
628 : },
629 : {
630 : id: 'Comfy.Graph.GroupSelectedNodes',
631 : icon: 'icon-[lucide--network]',
632 : label: 'Group Selected Nodes',
633 : versionAdded: '1.3.7',
634 : category: 'essentials' as const,
635 : mutatesGraph: true,
636 : function: () => {
637 9 : const { canvas } = app
638 9 : if (!canvas.selectedItems.size) {
639 0 : toast.error(t('toastMessages.nothingToGroup'), {
640 : description: t('toastMessages.pleaseSelectNodesToGroup')
641 : })
642 0 : return
643 : }
644 9 : const group = new LGraphGroup()
645 9 : const padding = useSettingStore().get(
646 : 'Comfy.GroupSelectedNodes.Padding'
647 : )
648 9 : group.resizeTo(canvas.selectedItems, padding)
649 9 : canvas.graph?.add(group)
650 :
651 9 : group.recomputeInsideNodes()
652 :
653 9 : useTitleEditorStore().titleEditorTarget = group
654 : }
655 : },
656 : {
657 : id: 'Workspace.NextOpenedWorkflow',
658 : icon: 'icon-[lucide--skip-forward]',
659 : label: 'Next Opened Workflow',
660 : versionAdded: '1.3.9',
661 : function: async () => {
662 0 : await workflowService.loadNextOpenedWorkflow({ initiator: 'user' })
663 : }
664 : },
665 : {
666 : id: 'Workspace.PreviousOpenedWorkflow',
667 : icon: 'icon-[lucide--skip-back]',
668 : label: 'Previous Opened Workflow',
669 : versionAdded: '1.3.9',
670 : function: async () => {
671 0 : await workflowService.loadPreviousOpenedWorkflow({ initiator: 'user' })
672 : }
673 : },
674 : {
675 : id: 'Comfy.Canvas.ToggleSelectedNodes.Mute',
676 : icon: 'icon-[lucide--volume-x]',
677 : label: 'Mute/Unmute Selected Nodes',
678 : versionAdded: '1.3.11',
679 : category: 'essentials' as const,
680 : mutatesGraph: true,
681 : function: () => {
682 8 : toggleSelectedNodesMode(LGraphEventMode.NEVER)
683 8 : app.canvas.setDirty(true, true)
684 : }
685 : },
686 : {
687 : id: 'Comfy.Canvas.ToggleSelectedNodes.Bypass',
688 : icon: 'icon-[lucide--shield]',
689 : label: 'Bypass/Unbypass Selected Nodes',
690 : versionAdded: '1.3.11',
691 : category: 'essentials' as const,
692 : mutatesGraph: true,
693 : function: () => {
694 39 : toggleSelectedNodesMode(LGraphEventMode.BYPASS)
695 39 : app.canvas.setDirty(true, true)
696 : }
697 : },
698 : {
699 : id: 'Comfy.Canvas.ToggleSelectedNodes.Links',
700 : icon: 'icon-[lucide--eye-off]',
701 : label: 'Hide/Show Links on Selected Nodes',
702 : versionAdded: '1.61.0',
703 : mutatesGraph: true,
704 : function: () => {
705 0 : toggleNodeLinks(app.canvas, getSelectedNodesShallow())
706 : }
707 : },
708 : {
709 : id: 'Comfy.Canvas.ToggleSelectedNodes.Pin',
710 : icon: 'icon-[lucide--pin]',
711 : label: 'Pin/Unpin Selected Nodes',
712 : versionAdded: '1.3.11',
713 : category: 'essentials' as const,
714 : mutatesGraph: true,
715 : function: () => {
716 2 : getSelectedNodes().forEach((node) => {
717 4 : node.pin(!node.pinned)
718 : })
719 2 : app.canvas.setDirty(true, true)
720 : }
721 : },
722 : {
723 : id: 'Comfy.Canvas.ToggleSelected.Pin',
724 : icon: 'icon-[lucide--pin]',
725 : label: 'Pin/Unpin Selected Items',
726 : versionAdded: '1.3.33',
727 : mutatesGraph: true,
728 : function: () => {
729 9 : for (const item of app.canvas.selectedItems) {
730 21 : if (item instanceof LGraphNode || item instanceof LGraphGroup) {
731 21 : item.pin(!item.pinned)
732 : }
733 : }
734 9 : app.canvas.setDirty(true, true)
735 : }
736 : },
737 : {
738 : id: 'Comfy.Canvas.Resize',
739 : icon: 'icon-[lucide--minus]',
740 : label: 'Resize Selected Nodes',
741 : versionAdded: '',
742 : mutatesGraph: true,
743 : function: () => {
744 0 : getSelectedNodes().forEach((node) => {
745 0 : const optimalSize = node.computeSize()
746 0 : node.setSize([optimalSize[0], optimalSize[1]])
747 : })
748 0 : app.canvas.setDirty(true, true)
749 : }
750 : },
751 : {
752 : id: 'Comfy.Canvas.ToggleSelectedNodes.Collapse',
753 : icon: 'icon-[lucide--minus]',
754 : label: 'Collapse/Expand Selected Nodes',
755 : versionAdded: '1.3.11',
756 : mutatesGraph: true,
757 : function: () => {
758 3 : getSelectedNodes().forEach((node) => {
759 3 : node.collapse()
760 : })
761 3 : app.canvas.setDirty(true, true)
762 : }
763 : },
764 : {
765 : id: 'Comfy.ToggleTheme',
766 : icon: 'icon-[lucide--moon]',
767 : label: 'Toggle Theme (Dark/Light)',
768 : versionAdded: '1.3.12',
769 : function: (() => {
770 2355 : let previousDarkTheme: string = DEFAULT_DARK_THEME_PRESET.id
771 2355 : let previousLightTheme: string = DEFAULT_LIGHT_THEME_PRESET.id
772 :
773 2355 : return async () => {
774 0 : const settingStore = useSettingStore()
775 0 : const theme = themeStore.activeTheme
776 0 : if (theme.colorScheme === 'light') {
777 0 : previousLightTheme = theme.id
778 0 : await settingStore.set('Comfy.ColorPalette', previousDarkTheme)
779 : } else {
780 0 : previousDarkTheme = theme.id
781 0 : await settingStore.set('Comfy.ColorPalette', previousLightTheme)
782 : }
783 : }
784 : })()
785 : },
786 : {
787 : id: 'Workspace.ToggleBottomPanel',
788 : icon: 'icon-[lucide--list]',
789 : label: 'Toggle Bottom Panel',
790 : menubarLabel: 'Bottom Panel',
791 : versionAdded: '1.3.22',
792 : category: 'view-controls' as const,
793 : function: () => {
794 4 : bottomPanelStore.toggleBottomPanel()
795 : },
796 : active: () => bottomPanelStore.bottomPanelVisible
797 : },
798 : {
799 : id: 'Workspace.ToggleFocusMode',
800 : icon: 'icon-[lucide--eye]',
801 : label: 'Toggle Focus Mode',
802 : menubarLabel: 'Focus Mode',
803 : versionAdded: '1.3.27',
804 : category: 'view-controls' as const,
805 : function: () => {
806 3 : useWorkspaceStore().toggleFocusMode()
807 : },
808 : active: () => useWorkspaceStore().focusMode
809 : },
810 : {
811 : id: 'Comfy.Graph.FitGroupToContents',
812 : icon: 'icon-[lucide--expand]',
813 : label: 'Fit Group To Contents',
814 : versionAdded: '1.4.9',
815 : mutatesGraph: true,
816 : function: () => {
817 2 : for (const group of app.canvas.selectedItems) {
818 4 : if (group instanceof LGraphGroup) {
819 2 : group.recomputeInsideNodes()
820 2 : const padding = useSettingStore().get(
821 : 'Comfy.GroupSelectedNodes.Padding'
822 : )
823 2 : group.resizeTo(group.children, padding)
824 2 : app.canvas.setDirty(false, true)
825 : }
826 : }
827 : }
828 : },
829 : {
830 : id: 'Comfy.Help.OpenComfyUIIssues',
831 : icon: 'icon-[lucide--github]',
832 : label: 'Open ComfyUI Issues',
833 : menubarLabel: 'ComfyUI Issues',
834 : versionAdded: '1.5.5',
835 : function: () => {
836 0 : telemetry?.trackHelpResourceClicked({
837 : resource_type: 'github',
838 : is_external: true,
839 : source: 'menu'
840 : })
841 0 : window.open(staticUrls.githubIssues, '_blank')
842 : }
843 : },
844 : {
845 : id: 'Comfy.Help.OpenComfyUIDocs',
846 : icon: 'icon-[lucide--info]',
847 : label: 'Open ComfyUI Docs',
848 : menubarLabel: 'ComfyUI Docs',
849 : versionAdded: '1.5.5',
850 : function: () => {
851 0 : telemetry?.trackHelpResourceClicked({
852 : resource_type: 'docs',
853 : is_external: true,
854 : source: 'menu'
855 : })
856 0 : window.open(buildDocsUrl('/', { includeLocale: true }), '_blank')
857 : }
858 : },
859 : {
860 : id: 'Comfy.Help.OpenComfyOrgDiscord',
861 : icon: 'pi pi-discord',
862 : label: 'Open Comfy-Org Discord',
863 : menubarLabel: 'Comfy-Org Discord',
864 : versionAdded: '1.5.5',
865 : function: () => {
866 0 : telemetry?.trackHelpResourceClicked({
867 : resource_type: 'discord',
868 : is_external: true,
869 : source: 'menu'
870 : })
871 0 : window.open(staticUrls.discord, '_blank')
872 : }
873 : },
874 : {
875 : id: 'Workspace.SearchBox.Toggle',
876 : icon: 'icon-[lucide--search]',
877 : label: 'Toggle Search Box',
878 : versionAdded: '1.5.7',
879 : function: () => {
880 43 : useSearchBoxStore().toggleVisible()
881 : }
882 : },
883 : {
884 : id: 'Comfy.Help.AboutComfyUI',
885 : icon: 'icon-[lucide--info]',
886 : label: 'Open About ComfyUI',
887 : menubarLabel: 'About ComfyUI',
888 : versionAdded: '1.6.4',
889 : function: () => {
890 0 : settingsDialog.showAbout()
891 : }
892 : },
893 : {
894 : id: 'Comfy.DuplicateWorkflow',
895 : icon: 'icon-[lucide--copy]',
896 : label: 'Duplicate Current Workflow',
897 : versionAdded: '1.6.15',
898 : function: async () => {
899 5 : await workflowService.duplicateWorkflow(workflowStore.activeWorkflow!)
900 : }
901 : },
902 : {
903 : id: 'Workspace.CloseWorkflow',
904 : icon: 'icon-[lucide--x]',
905 : label: 'Close Current Workflow',
906 : versionAdded: '1.7.3',
907 : function: async () => {
908 1 : if (workflowStore.activeWorkflow)
909 1 : await workflowService.closeWorkflows([workflowStore.activeWorkflow], {
910 : warnIfUnsaved: true,
911 : initiator: 'user'
912 : })
913 : }
914 : },
915 : {
916 : id: 'Comfy.ContactSupport',
917 : icon: 'pi pi-question',
918 : label: 'Contact Support',
919 : versionAdded: '1.17.8',
920 : function: () => {
921 4 : const { userEmail, resolvedUserInfo } = useCurrentUser()
922 4 : const supportUrl = buildSupportUrl({
923 : userEmail: userEmail.value,
924 : userId: resolvedUserInfo.value?.id
925 : })
926 4 : window.open(supportUrl, '_blank', 'noopener,noreferrer')
927 : }
928 : },
929 : {
930 : id: 'Comfy.Onboarding.Replay',
931 : icon: 'icon-[lucide--rotate-cw]',
932 : label: 'Replay Onboarding',
933 : versionAdded: '1.55.10',
934 : function: async () => {
935 0 : if (!settingStore.get('Comfy.DevMode')) return
936 0 : const replay = (onboardingReplayInProgress ??= (async () => {
937 : const confirmed = await dialogService.confirm({
938 : title: t('onboardingReplay.confirmTitle'),
939 : message: t('onboardingReplay.confirmMessage'),
940 : type: 'default'
941 : })
942 0 : if (!confirmed) return
943 :
944 0 : const result = await resetOnboardingState()
945 0 : if (result.status === 'failed') {
946 0 : toast.error(t('onboardingReplay.failedSummary'), {
947 : description: t('onboardingReplay.failedDetail'),
948 : duration: 5000
949 : })
950 0 : reportError(result.cause, {
951 : surface: 'platform',
952 : errorType: 'error_resetting_onboarding_state'
953 : })
954 0 : return
955 : }
956 :
957 : if (isCloud) {
958 : globalThis.location.assign(import.meta.env.BASE_URL || '/')
959 : } else {
960 0 : globalThis.location.reload()
961 : }
962 : })())
963 0 : try {
964 0 : await replay
965 : } finally {
966 0 : if (onboardingReplayInProgress === replay) {
967 0 : onboardingReplayInProgress = undefined
968 : }
969 : }
970 : }
971 : },
972 : {
973 : id: 'Comfy.Help.OpenComfyUIForum',
974 : icon: 'icon-[lucide--messages-square]',
975 : label: 'Open ComfyUI Forum',
976 : menubarLabel: 'ComfyUI Forum',
977 : versionAdded: '1.8.2',
978 : function: () => {
979 0 : telemetry?.trackHelpResourceClicked({
980 : resource_type: 'help_feedback',
981 : is_external: true,
982 : source: 'menu'
983 : })
984 0 : window.open(staticUrls.forum, '_blank')
985 : }
986 : },
987 : {
988 : id: 'Comfy.Canvas.CopySelected',
989 : icon: 'icon-[lucide--copy]',
990 : label: 'Copy',
991 : function: () => {
992 1 : if (app.canvas.selectedItems.size) {
993 1 : app.canvas.copyToClipboard()
994 : }
995 : }
996 : },
997 : {
998 : id: 'Comfy.Canvas.PasteFromClipboard',
999 : icon: 'icon-[lucide--clipboard-paste]',
1000 : label: 'Paste',
1001 : mutatesGraph: true,
1002 : function: () => {
1003 1 : app.canvas.pasteFromClipboard()
1004 : }
1005 : },
1006 : {
1007 : id: 'Comfy.Canvas.PasteFromClipboardWithConnect',
1008 : icon: 'icon-[lucide--clipboard-paste]',
1009 : label: () => t('menuLabels.Paste with Connect'),
1010 : mutatesGraph: true,
1011 : function: () => {
1012 1 : app.canvas.pasteFromClipboard({ connectInputs: true })
1013 : }
1014 : },
1015 : {
1016 : id: 'Comfy.Canvas.SelectAll',
1017 : icon: 'icon-[lucide--lasso-select]',
1018 : label: 'Select All',
1019 : function: () => {
1020 57 : app.canvas.selectItems()
1021 : }
1022 : },
1023 : {
1024 : id: 'Comfy.Canvas.HideSelectedLinks',
1025 : icon: 'icon-[lucide--eye-off]',
1026 : label: 'Hide Selected Links',
1027 : versionAdded: '1.58.0',
1028 : mutatesGraph: true,
1029 : function: () => {
1030 3 : hideSelectedLinks(app.canvas)
1031 : }
1032 : },
1033 : {
1034 : id: 'Comfy.Canvas.ShowSelectedLinks',
1035 : icon: 'icon-[lucide--eye]',
1036 : label: 'Show Selected Links',
1037 : versionAdded: '1.58.0',
1038 : mutatesGraph: true,
1039 : function: () => {
1040 2 : showSelectedLinks(app.canvas)
1041 : }
1042 : },
1043 : {
1044 : id: 'Comfy.Canvas.DeleteSelectedLinks',
1045 : icon: 'icon-[lucide--trash-2]',
1046 : label: 'Delete Selected Links',
1047 : versionAdded: '1.58.0',
1048 : mutatesGraph: true,
1049 : function: () => {
1050 1 : deleteSelectedLinks(app.canvas)
1051 : }
1052 : },
1053 : {
1054 : id: 'Comfy.Canvas.DeleteSelectedItems',
1055 : icon: 'icon-[lucide--trash-2]',
1056 : label: 'Delete Selected Items',
1057 : versionAdded: '1.10.5',
1058 : mutatesGraph: true,
1059 : function: () => {
1060 35 : if (app.canvas.selectedItems.size === 0) {
1061 1 : if (deleteSelectedLinks(app.canvas)) return
1062 0 : app.canvas.canvas.dispatchEvent(
1063 : new CustomEvent('litegraph:no-items-selected', { bubbles: true })
1064 : )
1065 0 : return
1066 : }
1067 34 : app.canvas.deleteSelected()
1068 34 : app.canvas.setDirty(true, true)
1069 : }
1070 : },
1071 : {
1072 : id: 'Comfy.Manager.CustomNodesManager.ShowCustomNodesMenu',
1073 : icon: 'icon-[lucide--puzzle]',
1074 : label: 'Custom Nodes Manager',
1075 : versionAdded: '1.12.10',
1076 : function: async () => {
1077 0 : await useManagerDialog().openManager({
1078 : showToastOnLegacyError: true
1079 : })
1080 : }
1081 : },
1082 : {
1083 : id: 'Comfy.Manager.ShowUpdateAvailablePacks',
1084 : icon: 'icon-[lucide--refresh-cw]',
1085 : label: 'Check for Custom Node Updates',
1086 : versionAdded: '1.17.0',
1087 : function: async () => {
1088 : const state = useManagerState().managerUIState.value
1089 :
1090 : // For DISABLED state, show error toast instead of opening settings
1091 0 : if (state === ManagerUIState.DISABLED) {
1092 0 : toast.error(t('g.error'), {
1093 : description: t('manager.notAvailable')
1094 : })
1095 0 : return
1096 : }
1097 :
1098 0 : await useManagerDialog().openManager({
1099 : initialTab: ManagerTab.UpdateAvailable,
1100 : showToastOnLegacyError: false
1101 : })
1102 : }
1103 : },
1104 : {
1105 : id: 'Comfy.Manager.ShowMissingPacks',
1106 : icon: 'icon-[lucide--circle-alert]',
1107 : label: 'Install Missing Custom Nodes',
1108 : versionAdded: '1.17.0',
1109 : function: async () => {
1110 0 : await useManagerDialog().openManager({
1111 : initialTab: ManagerTab.Missing,
1112 : showToastOnLegacyError: false
1113 : })
1114 : }
1115 : },
1116 : {
1117 : id: 'Comfy.User.OpenSignInDialog',
1118 : icon: 'icon-[lucide--user]',
1119 : label: 'Open Sign In Dialog',
1120 : versionAdded: '1.17.6',
1121 : function: async () => {
1122 2 : await showSignInDialog()
1123 : }
1124 : },
1125 : {
1126 : id: 'Comfy.User.SignOut',
1127 : icon: 'icon-[lucide--log-out]',
1128 : label: 'Sign Out',
1129 : versionAdded: '1.18.1',
1130 : function: async () => {
1131 0 : await authActions.logout()
1132 : }
1133 : },
1134 : {
1135 : id: 'Comfy.Canvas.MoveSelectedNodes.Up',
1136 : icon: 'icon-[lucide--arrow-up]',
1137 : label: 'Move Selected Nodes Up',
1138 : versionAdded: moveSelectedNodesVersionAdded,
1139 : mutatesGraph: true,
1140 : function: () => moveSelectedNodes(([x, y], gridSize) => [x, y - gridSize])
1141 : },
1142 : {
1143 : id: 'Comfy.Canvas.MoveSelectedNodes.Down',
1144 : icon: 'icon-[lucide--arrow-down]',
1145 : label: 'Move Selected Nodes Down',
1146 : versionAdded: moveSelectedNodesVersionAdded,
1147 : mutatesGraph: true,
1148 : function: () => moveSelectedNodes(([x, y], gridSize) => [x, y + gridSize])
1149 : },
1150 : {
1151 : id: 'Comfy.Canvas.MoveSelectedNodes.Left',
1152 : icon: 'icon-[lucide--arrow-left]',
1153 : label: 'Move Selected Nodes Left',
1154 : versionAdded: moveSelectedNodesVersionAdded,
1155 : mutatesGraph: true,
1156 : function: () => moveSelectedNodes(([x, y], gridSize) => [x - gridSize, y])
1157 : },
1158 : {
1159 : id: 'Comfy.Canvas.MoveSelectedNodes.Right',
1160 : icon: 'icon-[lucide--arrow-right]',
1161 : label: 'Move Selected Nodes Right',
1162 : versionAdded: moveSelectedNodesVersionAdded,
1163 : mutatesGraph: true,
1164 : function: () => moveSelectedNodes(([x, y], gridSize) => [x + gridSize, y])
1165 : },
1166 : {
1167 : id: 'Comfy.Graph.ConvertToSubgraph',
1168 : icon: 'icon-[lucide--shrink]',
1169 : label: 'Convert Selection to Subgraph',
1170 : versionAdded: '1.20.1',
1171 : category: 'essentials' as const,
1172 : mutatesGraph: true,
1173 : function: () => {
1174 18 : const canvas = canvasStore.getCanvas()
1175 18 : const graph = canvas.subgraph ?? canvas.graph
1176 18 : if (!graph) throw new TypeError('Canvas has no graph or subgraph set.')
1177 :
1178 : const res = graph.convertToSubgraph(canvas.selectedItems)
1179 18 : const { node } = res
1180 18 : canvas.select(node)
1181 : }
1182 : },
1183 : {
1184 : id: 'Comfy.Graph.UnpackSubgraph',
1185 : icon: 'icon-[lucide--expand]',
1186 : label: 'Unpack the selected Subgraph',
1187 : versionAdded: '1.26.3',
1188 : mutatesGraph: true,
1189 : function: () => {
1190 0 : const { unpackSubgraph } = useSubgraphOperations()
1191 0 : unpackSubgraph()
1192 : }
1193 : },
1194 : {
1195 : id: 'Comfy.Graph.EditSubgraphWidgets',
1196 : label: 'Edit Subgraph Widgets',
1197 : icon: 'icon-[lucide--settings-2]',
1198 : versionAdded: '1.28.5',
1199 : function: () => {
1200 0 : usePropertiesPanelStore().openPanel('subgraph')
1201 : }
1202 : },
1203 : {
1204 : id: 'Comfy.Graph.ToggleWidgetPromotion',
1205 : icon: 'icon-[lucide--arrow-left-right]',
1206 : label: 'Toggle promotion of hovered widget',
1207 : versionAdded: '1.30.1',
1208 : mutatesGraph: true,
1209 : function: () => {
1210 0 : tryToggleWidgetPromotion()
1211 : }
1212 : },
1213 : {
1214 : id: 'Comfy.OpenManagerDialog',
1215 : icon: 'mdi mdi-puzzle-outline',
1216 : label: 'Manager',
1217 : function: async () => {
1218 15 : await useManagerDialog().openManager({
1219 : initialTab: ManagerTab.All,
1220 : showToastOnLegacyError: false
1221 : })
1222 : }
1223 : },
1224 : {
1225 : id: 'Comfy.ToggleHelpCenter',
1226 : icon: 'icon-[lucide--circle-question-mark]',
1227 : label: 'Help Center',
1228 : function: () => {
1229 0 : useHelpCenterStore().toggle()
1230 : },
1231 : active: () => useHelpCenterStore().isVisible
1232 : },
1233 : {
1234 : id: 'Comfy.ToggleCanvasInfo',
1235 : icon: 'icon-[lucide--info]',
1236 : label: 'Canvas Performance',
1237 : function: async () => {
1238 0 : const settingStore = useSettingStore()
1239 0 : const currentValue = settingStore.get('Comfy.Graph.CanvasInfo')
1240 0 : await settingStore.set('Comfy.Graph.CanvasInfo', !currentValue)
1241 : },
1242 : active: () => useSettingStore().get('Comfy.Graph.CanvasInfo')
1243 : },
1244 : {
1245 : id: 'Workspace.ToggleBottomPanel.Shortcuts',
1246 : icon: 'icon-[lucide--key]',
1247 : label: 'Show Keybindings Dialog',
1248 : versionAdded: '1.24.1',
1249 : category: 'view-controls' as const,
1250 : function: () => {
1251 1 : bottomPanelStore.togglePanel('shortcuts')
1252 : }
1253 : },
1254 : {
1255 : id: 'Comfy.Graph.ExitSubgraph',
1256 : icon: 'icon-[lucide--arrow-up]',
1257 : label: 'Exit Subgraph',
1258 : versionAdded: '1.20.1',
1259 : function: () => {
1260 23 : const canvas = useCanvasStore().getCanvas()
1261 23 : const navigationStore = useSubgraphNavigationStore()
1262 23 : if (!canvas.graph) return
1263 :
1264 23 : canvas.setGraph(
1265 : navigationStore.navigationStack.at(-2) ?? canvas.graph.rootGraph
1266 : )
1267 : }
1268 : },
1269 : {
1270 : id: 'Comfy.Subgraph.SetDescription',
1271 : icon: 'icon-[lucide--pencil]',
1272 : label: 'Set Subgraph Description',
1273 : versionAdded: '1.39.7',
1274 : mutatesGraph: true,
1275 : function: async (metadata?: Record<string, unknown>) => {
1276 : const canvas = canvasStore.getCanvas()
1277 1 : const subgraph = canvas.subgraph
1278 1 : if (!subgraph) return
1279 :
1280 1 : const extra = subgraph.extra as Record<string, unknown>
1281 1 : const currentDescription = extra.BlueprintDescription as string
1282 :
1283 1 : let description: string | null | undefined
1284 1 : const rawDescription = metadata?.description
1285 1 : if (rawDescription != null) {
1286 1 : description =
1287 : typeof rawDescription === 'string'
1288 : ? rawDescription
1289 : : String(rawDescription)
1290 : }
1291 1 : description ??= await dialogService.prompt({
1292 : title: t('g.description'),
1293 : message: t('subgraphStore.enterDescription'),
1294 : defaultValue: currentDescription
1295 : })
1296 0 : if (description === null) return
1297 :
1298 1 : extra.BlueprintDescription = description.trim() || undefined
1299 1 : workflowStore.activeWorkflow?.changeTracker.captureCanvasState()
1300 : }
1301 : },
1302 : {
1303 : id: 'Comfy.Subgraph.SetSearchAliases',
1304 : icon: 'icon-[lucide--search]',
1305 : label: 'Set Subgraph Search Aliases',
1306 : versionAdded: '1.39.7',
1307 : mutatesGraph: true,
1308 : function: async (metadata?: Record<string, unknown>) => {
1309 : const canvas = canvasStore.getCanvas()
1310 0 : const subgraph = canvas.subgraph
1311 0 : if (!subgraph) return
1312 :
1313 0 : const parseAliases = (value: unknown): string[] =>
1314 : (Array.isArray(value) ? value.map(String) : String(value).split(','))
1315 : .map((s) => s.trim())
1316 : .filter(Boolean)
1317 :
1318 0 : const extra = subgraph.extra as Record<string, unknown>
1319 :
1320 0 : let aliases: string[]
1321 0 : const rawAliases = metadata?.aliases
1322 0 : if (rawAliases == null) {
1323 0 : const input = await dialogService.prompt({
1324 : title: t('subgraphStore.searchAliases'),
1325 : message: t('subgraphStore.enterSearchAliases'),
1326 : defaultValue: parseAliases(extra.BlueprintSearchAliases ?? '').join(
1327 : ', '
1328 : )
1329 : })
1330 0 : if (input === null) return
1331 0 : aliases = parseAliases(input)
1332 : } else {
1333 0 : aliases = parseAliases(rawAliases)
1334 : }
1335 :
1336 0 : extra.BlueprintSearchAliases = aliases.length > 0 ? aliases : undefined
1337 0 : workflowStore.activeWorkflow?.changeTracker.captureCanvasState()
1338 : }
1339 : },
1340 : {
1341 : id: 'Comfy.Dev.ShowModelSelector',
1342 : icon: 'icon-[lucide--box]',
1343 : label: 'Show Model Selector (Dev)',
1344 : versionAdded: '1.26.2',
1345 : category: 'view-controls' as const,
1346 : function: () => {
1347 : const modelSelectorDialog = useModelSelectorDialog()
1348 0 : modelSelectorDialog.show()
1349 : }
1350 : },
1351 : {
1352 : id: 'Comfy.Manager.CustomNodesManager.ShowLegacyCustomNodesMenu',
1353 : icon: 'icon-[lucide--menu]',
1354 : label: 'Custom Nodes (Legacy)',
1355 : versionAdded: '1.16.4',
1356 : function: async () => {
1357 0 : await useManagerDialog().openManager({
1358 : legacyCommand: 'Comfy.Manager.CustomNodesManager.ToggleVisibility',
1359 : showToastOnLegacyError: true,
1360 : isLegacyOnly: true
1361 : })
1362 : }
1363 : },
1364 : {
1365 : id: 'Comfy.Manager.ShowLegacyManagerMenu',
1366 : icon: 'mdi mdi-puzzle',
1367 : label: 'Manager Menu (Legacy)',
1368 : versionAdded: '1.16.4',
1369 : function: async () => {
1370 0 : await useManagerDialog().openManager({
1371 : showToastOnLegacyError: true,
1372 : isLegacyOnly: true
1373 : })
1374 : }
1375 : },
1376 : {
1377 : id: 'Comfy.Memory.UnloadModels',
1378 : icon: 'mdi mdi-vacuum-outline',
1379 : label: 'Unload Models',
1380 : versionAdded: '1.16.4',
1381 : function: async () => {
1382 0 : if (!useSettingStore().get('Comfy.Memory.AllowManualUnload')) {
1383 0 : toast.error(t('g.error'), {
1384 : description: t('g.commandProhibited', {
1385 : command: 'Comfy.Memory.UnloadModels'
1386 : })
1387 : })
1388 0 : return
1389 : }
1390 0 : await api.freeMemory({ freeExecutionCache: false })
1391 : }
1392 : },
1393 : {
1394 : id: 'Comfy.Memory.UnloadModelsAndExecutionCache',
1395 : icon: 'mdi mdi-vacuum-outline',
1396 : label: 'Unload Models and Execution Cache',
1397 : versionAdded: '1.16.4',
1398 : function: async () => {
1399 0 : if (!useSettingStore().get('Comfy.Memory.AllowManualUnload')) {
1400 0 : toast.error(t('g.error'), {
1401 : description: t('g.commandProhibited', {
1402 : command: 'Comfy.Memory.UnloadModelsAndExecutionCache'
1403 : })
1404 : })
1405 0 : return
1406 : }
1407 0 : await api.freeMemory({ freeExecutionCache: true })
1408 : }
1409 : },
1410 : {
1411 : id: 'Comfy.BrowseModelAssets',
1412 : icon: 'icon-[lucide--folder-open]',
1413 : label: 'Experimental: Browse Model Assets',
1414 : versionAdded: '1.28.3',
1415 : function: async () => {
1416 0 : await openModelLibraryBrowser()
1417 : }
1418 : },
1419 : {
1420 : id: 'Comfy.ToggleQPOV2',
1421 : icon: 'icon-[lucide--list]',
1422 : label: 'Toggle Queue Panel V2',
1423 : function: toggleQueuePanelV2
1424 : },
1425 : {
1426 : id: 'Comfy.ToggleLinear',
1427 : icon: 'icon-[lucide--database]',
1428 : label: 'Toggle App Mode',
1429 : function: (metadata?: Record<string, unknown>) => {
1430 82 : const source =
1431 : typeof metadata?.source === 'string' ? metadata.source : 'keybind'
1432 82 : const newMode = !canvasStore.linearMode
1433 82 : if (newMode) useTelemetry()?.trackEnterLinear({ source })
1434 82 : canvasStore.linearMode = newMode
1435 : }
1436 : }
1437 : ]
1438 :
1439 2355 : return commands.map((command) => ({ ...command, source: 'System' }))
1440 : }
|