Skip to content

Commit 4f01333

Browse files
authored
fix: feature flags and manager state handling (#5317) - merge conflict resolve (#5410)
1 parent 2bb158c commit 4f01333

23 files changed

+743
-554
lines changed

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import ProgressSpinner from 'primevue/progressspinner'
1515
import { computed, onMounted } from 'vue'
1616
1717
import GlobalDialog from '@/components/dialog/GlobalDialog.vue'
18-
import { useConflictDetection } from '@/composables/useConflictDetection'
1918
import config from '@/config'
2019
import { useWorkspaceStore } from '@/stores/workspaceStore'
2120
21+
import { useConflictDetection } from './composables/useConflictDetection'
2222
import { electronAPI, isElectron } from './utils/envUtil'
2323
2424
const workspaceStore = useWorkspaceStore()

src/components/dialog/content/ErrorDialogContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const showContactSupport = async () => {
105105
106106
onMounted(async () => {
107107
if (!systemStatsStore.systemStats) {
108-
await systemStatsStore.fetchSystemStats()
108+
await systemStatsStore.refetchSystemStats()
109109
}
110110
111111
try {

src/components/dialog/content/LoadWorkflowWarning.vue

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,12 @@
5454
import Button from 'primevue/button'
5555
import ListBox from 'primevue/listbox'
5656
import { computed } from 'vue'
57-
import { useI18n } from 'vue-i18n'
5857
5958
import NoResultsPlaceholder from '@/components/common/NoResultsPlaceholder.vue'
6059
import MissingCoreNodesMessage from '@/components/dialog/content/MissingCoreNodesMessage.vue'
6160
import { useMissingNodes } from '@/composables/nodePack/useMissingNodes'
62-
import { useDialogService } from '@/services/dialogService'
61+
import { useManagerState } from '@/composables/useManagerState'
6362
import { useComfyManagerStore } from '@/stores/comfyManagerStore'
64-
import { useCommandStore } from '@/stores/commandStore'
65-
import {
66-
ManagerUIState,
67-
useManagerStateStore
68-
} from '@/stores/managerStateStore'
69-
import { useToastStore } from '@/stores/toastStore'
7063
import type { MissingNodeType } from '@/types/comfy'
7164
import { ManagerTab } from '@/types/comfyManagerTypes'
7265
@@ -81,6 +74,7 @@ const { missingNodePacks, isLoading, error, missingCoreNodes } =
8174
useMissingNodes()
8275
8376
const comfyManagerStore = useComfyManagerStore()
77+
const managerState = useManagerState()
8478
8579
// Check if any of the missing packs are currently being installed
8680
const isInstalling = computed(() => {
@@ -111,47 +105,21 @@ const uniqueNodes = computed(() => {
111105
})
112106
})
113107
114-
const managerStateStore = useManagerStateStore()
115-
116108
// Show manager buttons unless manager is disabled
117109
const showManagerButtons = computed(() => {
118-
return managerStateStore.managerUIState !== ManagerUIState.DISABLED
110+
return managerState.shouldShowManagerButtons.value
119111
})
120112
121113
// Only show Install All button for NEW_UI (new manager with v4 support)
122114
const showInstallAllButton = computed(() => {
123-
return managerStateStore.managerUIState === ManagerUIState.NEW_UI
115+
return managerState.shouldShowInstallButton.value
124116
})
125117
126118
const openManager = async () => {
127-
const state = managerStateStore.managerUIState
128-
129-
switch (state) {
130-
case ManagerUIState.DISABLED:
131-
useDialogService().showSettingsDialog('extension')
132-
break
133-
134-
case ManagerUIState.LEGACY_UI:
135-
try {
136-
await useCommandStore().execute('Comfy.Manager.Menu.ToggleVisibility')
137-
} catch {
138-
// If legacy command doesn't exist, show toast
139-
const { t } = useI18n()
140-
useToastStore().add({
141-
severity: 'error',
142-
summary: t('g.error'),
143-
detail: t('manager.legacyMenuNotAvailable'),
144-
life: 3000
145-
})
146-
}
147-
break
148-
149-
case ManagerUIState.NEW_UI:
150-
useDialogService().showManagerDialog({
151-
initialTab: ManagerTab.Missing
152-
})
153-
break
154-
}
119+
await managerState.openManager({
120+
initialTab: ManagerTab.Missing,
121+
showToastOnLegacyError: true
122+
})
155123
}
156124
</script>
157125

src/components/dialog/content/MissingCoreNodesMessage.vue

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
</template>
4343

4444
<script setup lang="ts">
45-
import { whenever } from '@vueuse/core'
4645
import Message from 'primevue/message'
47-
import { computed, ref } from 'vue'
46+
import { computed } from 'vue'
4847
4948
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
5049
import { useSystemStatsStore } from '@/stores/systemStatsStore'
@@ -60,20 +59,11 @@ const hasMissingCoreNodes = computed(() => {
6059
return Object.keys(props.missingCoreNodes).length > 0
6160
})
6261
63-
const currentComfyUIVersion = ref<string | null>(null)
64-
whenever(
65-
hasMissingCoreNodes,
66-
async () => {
67-
if (!systemStatsStore.systemStats) {
68-
await systemStatsStore.fetchSystemStats()
69-
}
70-
currentComfyUIVersion.value =
71-
systemStatsStore.systemStats?.system?.comfyui_version ?? null
72-
},
73-
{
74-
immediate: true
75-
}
76-
)
62+
// Use computed for reactive version tracking
63+
const currentComfyUIVersion = computed<string | null>(() => {
64+
if (!hasMissingCoreNodes.value) return null
65+
return systemStatsStore.systemStats?.system?.comfyui_version ?? null
66+
})
7767
7868
const sortedMissingCoreNodes = computed(() => {
7969
return Object.entries(props.missingCoreNodes).sort(([a], [b]) => {

src/components/dialog/content/setting/AboutPanel.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
<script setup lang="ts">
3535
import Divider from 'primevue/divider'
3636
import Tag from 'primevue/tag'
37-
import { onMounted } from 'vue'
3837
3938
import SystemStatsPanel from '@/components/common/SystemStatsPanel.vue'
4039
import { useAboutPanelStore } from '@/stores/aboutPanelStore'
@@ -44,10 +43,4 @@ import PanelTemplate from './PanelTemplate.vue'
4443
4544
const systemStatsStore = useSystemStatsStore()
4645
const aboutPanelStore = useAboutPanelStore()
47-
48-
onMounted(async () => {
49-
if (!systemStatsStore.systemStats) {
50-
await systemStatsStore.fetchSystemStats()
51-
}
52-
})
5346
</script>

src/components/helpcenter/HelpCenterMenuContent.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ import { useI18n } from 'vue-i18n'
142142
143143
import PuzzleIcon from '@/components/icons/PuzzleIcon.vue'
144144
import { useConflictAcknowledgment } from '@/composables/useConflictAcknowledgment'
145-
import { useDialogService } from '@/services/dialogService'
145+
import { useManagerState } from '@/composables/useManagerState'
146146
import { type ReleaseNote } from '@/services/releaseService'
147147
import { useCommandStore } from '@/stores/commandStore'
148148
import { useReleaseStore } from '@/stores/releaseStore'
149149
import { useSettingStore } from '@/stores/settingStore'
150+
import { ManagerTab } from '@/types/comfyManagerTypes'
150151
import { electronAPI, isElectron } from '@/utils/envUtil'
151152
import { formatVersionAnchor } from '@/utils/formatUtil'
152153
@@ -191,7 +192,6 @@ const { t, locale } = useI18n()
191192
const releaseStore = useReleaseStore()
192193
const commandStore = useCommandStore()
193194
const settingStore = useSettingStore()
194-
const dialogService = useDialogService()
195195
196196
// Emits
197197
const emit = defineEmits<{
@@ -313,8 +313,11 @@ const menuItems = computed<MenuItem[]>(() => {
313313
icon: PuzzleIcon,
314314
label: t('helpCenter.managerExtension'),
315315
showRedDot: shouldShowManagerRedDot.value,
316-
action: () => {
317-
dialogService.showManagerDialog()
316+
action: async () => {
317+
await useManagerState().openManager({
318+
initialTab: ManagerTab.All,
319+
showToastOnLegacyError: false
320+
})
318321
emit('close')
319322
}
320323
},

src/components/topbar/CommandMenubar.vue

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,13 @@ import { useI18n } from 'vue-i18n'
106106
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'
109-
import { useDialogService } from '@/services/dialogService'
109+
import { useManagerState } from '@/composables/useManagerState'
110110
import { useCommandStore } from '@/stores/commandStore'
111111
import { useDialogStore } from '@/stores/dialogStore'
112-
import {
113-
ManagerUIState,
114-
useManagerStateStore
115-
} from '@/stores/managerStateStore'
116112
import { useMenuItemStore } from '@/stores/menuItemStore'
117113
import { useSettingStore } from '@/stores/settingStore'
118114
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
115+
import { ManagerTab } from '@/types/comfyManagerTypes'
119116
import { showNativeSystemMenu } from '@/utils/envUtil'
120117
import { normalizeI18nKey } from '@/utils/formatUtil'
121118
import { whileMouseDown } from '@/utils/mouseDownUtil'
@@ -127,6 +124,8 @@ const dialogStore = useDialogStore()
127124
const settingStore = useSettingStore()
128125
const { t } = useI18n()
129126
127+
const managerState = useManagerState()
128+
130129
const menuRef = ref<
131130
({ dirty: boolean } & TieredMenuMethods & TieredMenuState) | null
132131
>(null)
@@ -159,29 +158,11 @@ const showSettings = (defaultPanel?: string) => {
159158
})
160159
}
161160
162-
const managerStateStore = useManagerStateStore()
163-
164161
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
180-
181-
case ManagerUIState.NEW_UI:
182-
useDialogService().showManagerDialog()
183-
break
184-
}
162+
await managerState.openManager({
163+
initialTab: ManagerTab.All,
164+
showToastOnLegacyError: false
165+
})
185166
}
186167
187168
const extraMenuItems = computed<MenuItem[]>(() => [

src/composables/nodePack/useWorkflowPacks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const useWorkflowPacks = (options: UseNodePacksOptions = {}) => {
6161
const nodeDef = nodeDefStore.nodeDefsByName[nodeName]
6262
if (nodeDef?.nodeSource.type === 'core') {
6363
if (!systemStatsStore.systemStats) {
64-
await systemStatsStore.fetchSystemStats()
64+
await systemStatsStore.refetchSystemStats()
6565
}
6666
return {
6767
id: CORE_NODES_PACK_NAME,

src/composables/useConflictDetection.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { until } from '@vueuse/core'
12
import { uniqBy } from 'es-toolkit/compat'
23
import { computed, getCurrentInstance, onUnmounted, readonly, ref } from 'vue'
34

@@ -78,9 +79,8 @@ export function useConflictDetection() {
7879
try {
7980
// Get system stats from store (primary source of system information)
8081
const systemStatsStore = useSystemStatsStore()
81-
if (!systemStatsStore.systemStats) {
82-
await systemStatsStore.fetchSystemStats()
83-
}
82+
// Wait for systemStats to be initialized if not already
83+
await until(systemStatsStore.isInitialized)
8484

8585
// Fetch version information from backend (with error resilience)
8686
const [frontendVersion] = await Promise.allSettled([
@@ -127,7 +127,7 @@ export function useConflictDetection() {
127127
}
128128

129129
systemEnvironment.value = environment
130-
console.log(
130+
console.debug(
131131
'[ConflictDetection] System environment detection completed:',
132132
environment
133133
)
@@ -427,7 +427,7 @@ export function useConflictDetection() {
427427
Object.entries(bulkResult).forEach(([packageId, failInfo]) => {
428428
if (failInfo !== null) {
429429
importFailures[packageId] = failInfo
430-
console.log(
430+
console.debug(
431431
`[ConflictDetection] Import failure found for ${packageId}:`,
432432
failInfo
433433
)
@@ -500,7 +500,7 @@ export function useConflictDetection() {
500500
*/
501501
async function performConflictDetection(): Promise<ConflictDetectionResponse> {
502502
if (isDetecting.value) {
503-
console.log('[ConflictDetection] Already detecting, skipping')
503+
console.debug('[ConflictDetection] Already detecting, skipping')
504504
return {
505505
success: false,
506506
error_message: 'Already detecting conflicts',
@@ -556,7 +556,10 @@ export function useConflictDetection() {
556556
detectionSummary.value = summary
557557
lastDetectionTime.value = new Date().toISOString()
558558

559-
console.log('[ConflictDetection] Conflict detection completed:', summary)
559+
console.debug(
560+
'[ConflictDetection] Conflict detection completed:',
561+
summary
562+
)
560563

561564
// Store conflict results for later UI display
562565
// Dialog will be shown based on specific events, not on app mount
@@ -568,7 +571,7 @@ export function useConflictDetection() {
568571
// Merge conflicts for packages with the same name
569572
const mergedConflicts = mergeConflictsByPackageName(conflictedResults)
570573

571-
console.log(
574+
console.debug(
572575
'[ConflictDetection] Conflicts detected (stored for UI):',
573576
mergedConflicts
574577
)
@@ -632,11 +635,22 @@ export function useConflictDetection() {
632635
/**
633636
* Error-resilient initialization (called on app mount).
634637
* Async function that doesn't block UI setup.
635-
* Ensures proper order: installed -> system_stats -> versions bulk -> import_fail_info_bulk
638+
* Ensures proper order: system_stats -> manager state -> installed -> versions bulk -> import_fail_info_bulk
636639
*/
637640
async function initializeConflictDetection(): Promise<void> {
638641
try {
639-
// Simply perform conflict detection
642+
// Check if manager is new Manager before proceeding
643+
const { useManagerState } = await import('@/composables/useManagerState')
644+
const managerState = useManagerState()
645+
646+
if (!managerState.isNewManagerUI.value) {
647+
console.debug(
648+
'[ConflictDetection] Manager is not new Manager, skipping conflict detection'
649+
)
650+
return
651+
}
652+
653+
// Manager is new Manager, perform conflict detection
640654
// The useInstalledPacks will handle fetching installed list if needed
641655
await performConflictDetection()
642656
} catch (error) {
@@ -671,13 +685,13 @@ export function useConflictDetection() {
671685
* Check if conflicts should trigger modal display after "What's New" dismissal
672686
*/
673687
async function shouldShowConflictModalAfterUpdate(): Promise<boolean> {
674-
console.log(
688+
console.debug(
675689
'[ConflictDetection] Checking if conflict modal should show after update...'
676690
)
677691

678692
// Ensure conflict detection has run
679693
if (detectionResults.value.length === 0) {
680-
console.log(
694+
console.debug(
681695
'[ConflictDetection] No detection results, running conflict detection...'
682696
)
683697
await performConflictDetection()
@@ -689,7 +703,7 @@ export function useConflictDetection() {
689703
const hasActualConflicts = hasConflicts.value
690704
const canShowModal = acknowledgment.shouldShowConflictModal.value
691705

692-
console.log('[ConflictDetection] Modal check:', {
706+
console.debug('[ConflictDetection] Modal check:', {
693707
hasConflicts: hasActualConflicts,
694708
canShowModal: canShowModal,
695709
conflictedPackagesCount: conflictedPackages.value.length

0 commit comments

Comments
 (0)