Refactor app menu items (#4665)

* Restructures the application menu
- rename Workflow to File
- move new & template items to top level
- add View menu and related sub items

Commands
- add "active" state getter shown as checkmark in the menu

Node side panel
- add refresh node defs
- change reset view icon

Help center
- change to use store for visibility

Fixes
- Fix bug with mouse down where if you drag mouse out, mouse up wasn't caught
- Fix issue with canvas info setting not triggering a redraw on change

* Fix missing translation warnings

* Add separator under new

* tidy

* Update locales [skip ci]

* fix some tests

* fix

* Hide icon if there is an active state within the menu item group

* Update locales [skip ci]

* Fix tests

* Implement feedback
- Remove queue, node lib, model lib, workflows, manager, help center
- Add minimap, link visibility

* Update locales [skip ci]

* Add plus icon on "New" menu item

* Update locales [skip ci]

* Fix test

* Fix translations

* Update locales [skip ci]

* Update locales [skip ci]

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
pythongosssss
2025-08-14 22:53:46 +01:00
committed by GitHub
parent 1e41c6dc45
commit 4ca6220adf
35 changed files with 451 additions and 139 deletions

View File

@@ -17,6 +17,7 @@ export interface ComfyCommand {
versionAdded?: string
confirmation?: string // If non-nullish, this command will prompt for confirmation
source?: string
active?: () => boolean // Getter to check if the command is active/toggled on
category?: 'essentials' | 'view-controls' // For shortcuts panel organization
}
@@ -30,6 +31,7 @@ export class ComfyCommandImpl implements ComfyCommand {
versionAdded?: string
confirmation?: string
source?: string
active?: () => boolean
category?: 'essentials' | 'view-controls'
constructor(command: ComfyCommand) {
@@ -42,6 +44,7 @@ export class ComfyCommandImpl implements ComfyCommand {
this.versionAdded = command.versionAdded
this.confirmation = command.confirmation
this.source = command.source
this.active = command.active
this.category = command.category
}

View File

@@ -0,0 +1,25 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useHelpCenterStore = defineStore('helpCenter', () => {
const isVisible = ref(false)
const toggle = () => {
isVisible.value = !isVisible.value
}
const show = () => {
isVisible.value = true
}
const hide = () => {
isVisible.value = false
}
return {
isVisible,
toggle,
show,
hide
}
})

View File

@@ -10,6 +10,7 @@ import { useCommandStore } from './commandStore'
export const useMenuItemStore = defineStore('menuItem', () => {
const commandStore = useCommandStore()
const menuItems = ref<MenuItem[]>([])
const menuItemHasActiveStateChildren = ref<Record<string, boolean>>({})
const registerMenuGroup = (path: string[], items: MenuItem[]) => {
let currentLevel = menuItems.value
@@ -45,6 +46,14 @@ export const useMenuItemStore = defineStore('menuItem', () => {
}
// Add the new items to the last level
currentLevel.push(...items)
// Store if any of the children have active state as we will hide the icon if they do
const parentPath = path.join('.')
if (!menuItemHasActiveStateChildren.value[parentPath]) {
menuItemHasActiveStateChildren.value[parentPath] = items.some(
(item) => item.comfyCommand?.active
)
}
}
const registerCommands = (path: string[], commandIds: string[]) => {
@@ -57,7 +66,8 @@ export const useMenuItemStore = defineStore('menuItem', () => {
label: command.menubarLabel,
icon: command.icon,
tooltip: command.tooltip,
comfyCommand: command
comfyCommand: command,
parentPath: path.join('.')
}) as MenuItem
)
registerMenuGroup(path, items)
@@ -92,6 +102,7 @@ export const useMenuItemStore = defineStore('menuItem', () => {
registerMenuGroup,
registerCommands,
loadExtensionMenuCommands,
registerCoreMenuCommands
registerCoreMenuCommands,
menuItemHasActiveStateChildren
}
})

View File

@@ -7,6 +7,7 @@ import { useQueueSidebarTab } from '@/composables/sidebarTabs/useQueueSidebarTab
import { useWorkflowsSidebarTab } from '@/composables/sidebarTabs/useWorkflowsSidebarTab'
import { t, te } from '@/i18n'
import { useCommandStore } from '@/stores/commandStore'
import { useMenuItemStore } from '@/stores/menuItemStore'
import { SidebarTabExtension } from '@/types/extensionTypes'
export const useSidebarTabStore = defineStore('sidebarTab', () => {
@@ -38,16 +39,34 @@ export const useSidebarTabStore = defineStore('sidebarTab', () => {
: String(tab.tooltip)
: undefined
const menubarLabelFunction = () => {
const menubarLabelKeys: Record<string, string> = {
queue: 'menu.queue',
'node-library': 'sideToolbar.nodeLibrary',
'model-library': 'sideToolbar.modelLibrary',
workflows: 'sideToolbar.workflows'
}
const key = menubarLabelKeys[tab.id]
if (key && te(key)) {
return t(key)
}
return tab.title
}
useCommandStore().registerCommand({
id: `Workspace.ToggleSidebarTab.${tab.id}`,
icon: typeof tab.icon === 'string' ? tab.icon : undefined,
label: labelFunction,
menubarLabel: menubarLabelFunction,
tooltip: tooltipFunction,
versionAdded: '1.3.9',
category: 'view-controls' as const,
function: () => {
toggleSidebarTab(tab.id)
},
active: () => activeSidebarTab.value?.id === tab.id,
source: 'System'
})
}
@@ -73,6 +92,25 @@ export const useSidebarTabStore = defineStore('sidebarTab', () => {
registerSidebarTab(useNodeLibrarySidebarTab())
registerSidebarTab(useModelLibrarySidebarTab())
registerSidebarTab(useWorkflowsSidebarTab())
const menuStore = useMenuItemStore()
menuStore.registerCommands(
['View'],
[
'Workspace.ToggleBottomPanel',
'Comfy.BrowseTemplates',
'Workspace.ToggleFocusMode',
'Comfy.ToggleCanvasInfo',
'Comfy.Canvas.ToggleMinimap',
'Comfy.Canvas.ToggleLinkVisibility'
]
)
menuStore.registerCommands(
['View'],
['Comfy.Canvas.ZoomIn', 'Comfy.Canvas.ZoomOut', 'Comfy.Canvas.FitView']
)
}
return {