From b7c43707d30ea51e7aa460791fb8be209485459b Mon Sep 17 00:00:00 2001 From: Jin Yi Date: Tue, 29 Jul 2025 17:30:47 +0900 Subject: [PATCH] [debug] Conflict detection debugging (#4577) --- .../content/manager/ManagerDialogContent.vue | 53 ++----------------- src/composables/useManagerQueue.ts | 12 ++++- src/stores/comfyManagerStore.ts | 10 +++- 3 files changed, 22 insertions(+), 53 deletions(-) diff --git a/src/components/dialog/content/manager/ManagerDialogContent.vue b/src/components/dialog/content/manager/ManagerDialogContent.vue index b84a8c9eb..989e6d8e9 100644 --- a/src/components/dialog/content/manager/ManagerDialogContent.vue +++ b/src/components/dialog/content/manager/ManagerDialogContent.vue @@ -146,7 +146,6 @@ import { usePackUpdateStatus } from '@/composables/nodePack/usePackUpdateStatus' import { useWorkflowPacks } from '@/composables/nodePack/useWorkflowPacks' import { useConflictBannerState } from '@/composables/useConflictBannerState' import { useRegistrySearch } from '@/composables/useRegistrySearch' -import { useComfyRegistryService } from '@/services/comfyRegistryService' import { useComfyManagerStore } from '@/stores/comfyManagerStore' import { useComfyRegistryStore } from '@/stores/comfyRegistryStore' import type { TabItem } from '@/types/comfyManagerTypes' @@ -160,7 +159,6 @@ const { initialTab } = defineProps<{ const { t } = useI18n() const comfyManagerStore = useComfyManagerStore() const { getPackById } = useComfyRegistryStore() -const registryService = useComfyRegistryService() const conflictBannerState = useConflictBannerState() const persistedState = useManagerStatePersistence() const initialState = persistedState.loadStoredState() @@ -480,56 +478,11 @@ whenever(selectedNodePack, async () => { // Only fetch if we haven't already for this pack if (lastFetchedPackId.value === pack.id) return - let data = null - - // For installed nodes only, fetch version-specific information - if (comfyManagerStore.isPackInstalled(pack.id)) { - const installedPack = comfyManagerStore.getInstalledPackByCnrId(pack.id) - if (installedPack?.ver) { - // Fetch information for the installed version - data = await registryService.getPackByVersion(pack.id, installedPack.ver) - - // Race condition check: ensure selected pack hasn't changed during async operation - if (selectedNodePack.value?.id !== pack.id) { - return - } - } - } - - // For uninstalled nodes or if version-specific data fetch failed, use default API - if (!data) { - data = await getPackById.call(pack.id) - } - - // Race condition check: ensure selected pack hasn't changed during async operations - if (selectedNodePack.value?.id !== pack.id) { - return - } - + const data = await getPackById.call(pack.id) // If selected node hasn't changed since request, merge registry & Algolia data - const isNodeData = data && 'id' in data && data.id === pack.id - const isVersionData = data && 'node_id' in data && data.node_id === pack.id - - if (isNodeData || isVersionData) { + if (data?.id === pack.id) { lastFetchedPackId.value = pack.id - - // Merge API data first, then pack data (API data takes priority) - const mergedPack = merge({}, data, pack) - - // Ensure compatibility fields from API data take priority - if (data?.supported_os !== undefined) { - mergedPack.supported_os = data.supported_os - } - if (data?.supported_accelerators !== undefined) { - mergedPack.supported_accelerators = data.supported_accelerators - } - if (data?.supported_comfyui_version !== undefined) { - mergedPack.supported_comfyui_version = data.supported_comfyui_version - } - if (data?.supported_comfyui_frontend_version !== undefined) { - mergedPack.supported_comfyui_frontend_version = - data.supported_comfyui_frontend_version - } + const mergedPack = merge({}, pack, data) // Update the pack in current selection without changing selection state const packIndex = selectedNodePacks.value.findIndex( (p) => p.id === mergedPack.id diff --git a/src/composables/useManagerQueue.ts b/src/composables/useManagerQueue.ts index 7759c250d..7defd36ad 100644 --- a/src/composables/useManagerQueue.ts +++ b/src/composables/useManagerQueue.ts @@ -1,5 +1,5 @@ import { useEventListener, whenever } from '@vueuse/core' -import { pickBy } from 'lodash' +import { mapKeys, pickBy } from 'lodash' import { Ref, computed, ref } from 'vue' import { app } from '@/scripts/app' @@ -90,7 +90,15 @@ export const useManagerQueue = ( taskHistory.value = filterHistoryByClientId(state.history) if (state.installed_packs) { - installedPacks.value = state.installed_packs + // The keys are 'cleaned' by stripping the version suffix. + // The pack object itself (the value) still contains the version info. + const packsWithCleanedKeys = mapKeys( + state.installed_packs, + (_value, key) => { + return key.split('@')[0] + } + ) + installedPacks.value = packsWithCleanedKeys } updateProcessingState() } diff --git a/src/stores/comfyManagerStore.ts b/src/stores/comfyManagerStore.ts index 18113d3af..97990ad0a 100644 --- a/src/stores/comfyManagerStore.ts +++ b/src/stores/comfyManagerStore.ts @@ -1,4 +1,5 @@ import { whenever } from '@vueuse/core' +import { mapKeys } from 'lodash' import { defineStore } from 'pinia' import { v4 as uuidv4 } from 'uuid' import { ref, watch } from 'vue' @@ -167,7 +168,14 @@ export const useComfyManagerStore = defineStore('comfyManager', () => { const refreshInstalledList = async () => { const packs = await managerService.listInstalledPacks() - if (packs) installedPacks.value = packs + if (packs) { + // The keys are 'cleaned' by stripping the version suffix. + // The pack object itself (the value) still contains the version info. + const packsWithCleanedKeys = mapKeys(packs, (_value, key) => { + return key.split('@')[0] + }) + installedPacks.value = packsWithCleanedKeys + } isStale.value = false }