Skip to content

Commit 8a26b7e

Browse files
[fix] Fix API URL prefix slash and add error handling
- Update comfyManagerService to use conditional API URL prefix based on manager v4 support - Fix manager UI state handling in command menubar and workflow warning dialog - Add proper manager state detection with fallback to settings panel - Remove unused imports and variables 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2415b97 commit 8a26b7e

File tree

4 files changed

+124
-37
lines changed

4 files changed

+124
-37
lines changed

src/components/dialog/content/LoadWorkflowWarning.vue

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,20 @@
5151
import Button from 'primevue/button'
5252
import ListBox from 'primevue/listbox'
5353
import { computed, onMounted, ref } from 'vue'
54+
import { useI18n } from 'vue-i18n'
5455
5556
import NoResultsPlaceholder from '@/components/common/NoResultsPlaceholder.vue'
5657
import MissingCoreNodesMessage from '@/components/dialog/content/MissingCoreNodesMessage.vue'
5758
import { useMissingNodes } from '@/composables/nodePack/useMissingNodes'
5859
import { useComfyManagerService } from '@/services/comfyManagerService'
5960
import { useDialogService } from '@/services/dialogService'
6061
import { useComfyManagerStore } from '@/stores/comfyManagerStore'
62+
import { useCommandStore } from '@/stores/commandStore'
63+
import {
64+
ManagerUIState,
65+
useManagerStateStore
66+
} from '@/stores/managerStateStore'
67+
import { useToastStore } from '@/stores/toastStore'
6168
import type { MissingNodeType } from '@/types/comfy'
6269
import { ManagerTab } from '@/types/comfyManagerTypes'
6370
@@ -103,10 +110,37 @@ const uniqueNodes = computed(() => {
103110
})
104111
})
105112
106-
const openManager = () => {
107-
useDialogService().showManagerDialog({
108-
initialTab: ManagerTab.Missing
109-
})
113+
const managerStateStore = useManagerStateStore()
114+
115+
const openManager = async () => {
116+
const state = managerStateStore.managerUIState
117+
118+
switch (state) {
119+
case ManagerUIState.DISABLED:
120+
useDialogService().showSettingsDialog('extension')
121+
break
122+
123+
case ManagerUIState.LEGACY_UI:
124+
try {
125+
await useCommandStore().execute('Comfy.Manager.Menu.ToggleVisibility')
126+
} catch {
127+
// If legacy command doesn't exist, show toast
128+
const { t } = useI18n()
129+
useToastStore().add({
130+
severity: 'error',
131+
summary: t('g.error'),
132+
detail: t('manager.legacyMenuNotAvailable'),
133+
life: 3000
134+
})
135+
}
136+
break
137+
138+
case ManagerUIState.NEW_UI:
139+
useDialogService().showManagerDialog({
140+
initialTab: ManagerTab.Missing
141+
})
142+
break
143+
}
110144
}
111145
112146
onMounted(async () => {

src/components/topbar/CommandMenubar.vue

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ import SubgraphBreadcrumb from '@/components/breadcrumb/SubgraphBreadcrumb.vue'
107107
import SettingDialogContent from '@/components/dialog/content/SettingDialogContent.vue'
108108
import SettingDialogHeader from '@/components/dialog/header/SettingDialogHeader.vue'
109109
import { useDialogService } from '@/services/dialogService'
110-
import { useAboutPanelStore } from '@/stores/aboutPanelStore'
111110
import { useCommandStore } from '@/stores/commandStore'
112111
import { useDialogStore } from '@/stores/dialogStore'
112+
import {
113+
ManagerUIState,
114+
useManagerStateStore
115+
} from '@/stores/managerStateStore'
113116
import { useMenuItemStore } from '@/stores/menuItemStore'
114117
import { useSettingStore } from '@/stores/settingStore'
115118
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
@@ -121,7 +124,6 @@ const colorPaletteStore = useColorPaletteStore()
121124
const menuItemsStore = useMenuItemStore()
122125
const commandStore = useCommandStore()
123126
const dialogStore = useDialogStore()
124-
const aboutPanelStore = useAboutPanelStore()
125127
const settingStore = useSettingStore()
126128
const { t } = useI18n()
127129
@@ -157,23 +159,28 @@ const showSettings = (defaultPanel?: string) => {
157159
})
158160
}
159161
160-
// Temporary duplicated from LoadWorkflowWarning.vue
161-
// Determines if ComfyUI-Manager is installed by checking for its badge in the about panel
162-
// This allows us to conditionally show the Manager button only when the extension is available
163-
// TODO: Remove this check when Manager functionality is fully migrated into core
164-
const isManagerInstalled = computed(() => {
165-
return aboutPanelStore.badges.some(
166-
(badge) =>
167-
badge.label.includes('ComfyUI-Manager') ||
168-
badge.url.includes('ComfyUI-Manager')
169-
)
170-
})
162+
const managerStateStore = useManagerStateStore()
163+
164+
const showManageExtensions = async () => {
165+
const state = managerStateStore.managerUIState
166+
167+
switch (state) {
168+
case ManagerUIState.DISABLED:
169+
showSettings('extension')
170+
break
171+
172+
case ManagerUIState.LEGACY_UI:
173+
try {
174+
await commandStore.execute('Comfy.Manager.Menu.ToggleVisibility')
175+
} catch {
176+
// If legacy command doesn't exist, fall back to extensions panel
177+
showSettings('extension')
178+
}
179+
break
171180
172-
const showManageExtensions = () => {
173-
if (isManagerInstalled.value) {
174-
useDialogService().showManagerDialog()
175-
} else {
176-
showSettings('extension')
181+
case ManagerUIState.NEW_UI:
182+
useDialogService().showManagerDialog()
183+
break
177184
}
178185
}
179186

src/composables/useCoreCommands.ts

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -760,12 +760,8 @@ export function useCoreCommands(): ComfyCommand[] {
760760
useCommandStore()
761761
.execute('Comfy.Manager.Menu.ToggleVisibility')
762762
.catch(() => {
763-
toastStore.add({
764-
severity: 'error',
765-
summary: t('g.error'),
766-
detail: t('manager.legacyMenuNotAvailable'),
767-
life: 3000
768-
})
763+
// If legacy command doesn't exist, fall back to extensions panel
764+
dialogService.showSettingsDialog('extension')
769765
})
770766
break
771767

@@ -780,21 +776,66 @@ export function useCoreCommands(): ComfyCommand[] {
780776
icon: 'pi pi-sync',
781777
label: 'Check for Custom Node Updates',
782778
versionAdded: '1.17.0',
783-
function: () => {
784-
dialogService.showManagerDialog({
785-
initialTab: ManagerTab.UpdateAvailable
786-
})
779+
function: async () => {
780+
const managerStore = useManagerStateStore()
781+
const state = managerStore.managerUIState
782+
783+
switch (state) {
784+
case ManagerUIState.DISABLED:
785+
dialogService.showSettingsDialog('extension')
786+
break
787+
788+
case ManagerUIState.LEGACY_UI:
789+
try {
790+
await useCommandStore().execute(
791+
'Comfy.Manager.Menu.ToggleVisibility'
792+
)
793+
} catch {
794+
// If legacy command doesn't exist, fall back to extensions panel
795+
dialogService.showSettingsDialog('extension')
796+
}
797+
break
798+
799+
case ManagerUIState.NEW_UI:
800+
dialogService.showManagerDialog({
801+
initialTab: ManagerTab.UpdateAvailable
802+
})
803+
break
804+
}
787805
}
788806
},
789807
{
790808
id: 'Comfy.Manager.ShowMissingPacks',
791809
icon: 'pi pi-exclamation-circle',
792810
label: 'Install Missing Custom Nodes',
793811
versionAdded: '1.17.0',
794-
function: () => {
795-
dialogService.showManagerDialog({
796-
initialTab: ManagerTab.Missing
797-
})
812+
function: async () => {
813+
const managerStore = useManagerStateStore()
814+
const state = managerStore.managerUIState
815+
816+
switch (state) {
817+
case ManagerUIState.DISABLED:
818+
// When manager is disabled, open the extensions panel in settings
819+
dialogService.showSettingsDialog('extension')
820+
break
821+
822+
case ManagerUIState.LEGACY_UI:
823+
try {
824+
await useCommandStore().execute(
825+
'Comfy.Manager.Menu.ToggleVisibility'
826+
)
827+
} catch {
828+
// If legacy command doesn't exist, fall back to extensions panel
829+
dialogService.showSettingsDialog('extension')
830+
}
831+
break
832+
833+
case ManagerUIState.NEW_UI:
834+
dialogService.showManagerDialog({
835+
initialTab: ManagerTab.Missing
836+
})
837+
break
838+
}
798839
}
799840
},
800841
{

src/services/comfyManagerService.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios, { AxiosError, AxiosResponse } from 'axios'
22
import { ref } from 'vue'
33

4+
import { ServerFeatureFlag } from '@/composables/useFeatureFlags'
45
import { api } from '@/scripts/api'
56
import {
67
type InstallPackParams,
@@ -35,8 +36,12 @@ enum ManagerRoute {
3536
IS_LEGACY_MANAGER_UI = 'manager/is_legacy_manager_ui'
3637
}
3738

39+
// Create axios client with conditional v2 prefix based on manager v4 support
40+
const supportsV4 = api.getServerFeature(ServerFeatureFlag.MANAGER_SUPPORTS_V4)
41+
const baseURL = supportsV4 ? api.apiURL('/v2/') : api.apiURL('/')
42+
3843
const managerApiClient = axios.create({
39-
baseURL: api.apiURL('/v2/'),
44+
baseURL,
4045
headers: {
4146
'Content-Type': 'application/json'
4247
}

0 commit comments

Comments
 (0)