Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ const {
displayPacks,
isSortable,
isLoading: isTabLoading,
hasUpdateError,
workflowPacks
} = useManagerDisplayPacks(
selectedNavId,
Expand Down Expand Up @@ -511,7 +512,11 @@ const isManagerErrorRelevant = computed(() => {
})

const emptyStateTitle = computed(() => {
if (isManagerErrorRelevant.value || isSearchFailed.value)
if (
isManagerErrorRelevant.value ||
isSearchFailed.value ||
hasUpdateError.value
)
return t('manager.errorConnecting')
if (trimmedSearchQuery.value) return t('manager.noResultsFound')

Expand All @@ -524,7 +529,11 @@ const emptyStateTitle = computed(() => {
})

const emptyStateMessage = computed(() => {
if (isManagerErrorRelevant.value || isSearchFailed.value)
if (
isManagerErrorRelevant.value ||
isSearchFailed.value ||
hasUpdateError.value
)
return t('manager.tryAgainLater')
if (trimmedSearchQuery.value) return t('manager.tryDifferentSearch')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,29 @@ import {
} from '@/platform/customNodes/manager/composables/nodePack/packUpdateStatus'

type NodePack = components['schemas']['Node']
type ComfyManagerStore = ReturnType<typeof useComfyManagerStore>
type ComfyManagerStore = Pick<
ReturnType<typeof useComfyManagerStore>,
'isPackInstalled' | 'getInstalledPackVersion'
>

const createPack = (
id: string | undefined,
latestVersion?: string
): NodePack => ({
id,
name: `Pack ${id}`,
latest_version: latestVersion ? { version: latestVersion } : undefined
latest_version: latestVersion
? { version: latestVersion, status: 'NodeVersionStatusActive' }
: undefined
})

const createStore = (
installed: Record<string, string | undefined>
): ComfyManagerStore =>
({
isPackInstalled: (id: string | undefined) =>
id !== undefined && id in installed,
getInstalledPackVersion: (id: string) => installed[id]
}) as unknown as ComfyManagerStore
): ComfyManagerStore => ({
isPackInstalled: (id: string | undefined) =>
id !== undefined && id in installed,
getInstalledPackVersion: (id: string) => installed[id]
})

describe('isNightlyVersion', () => {
it('is true for a non-semver git hash version', () => {
Expand Down Expand Up @@ -103,4 +107,43 @@ describe('getPackUpdateStatus', () => {
expect(status.latestVersion).toBeUndefined()
expect(status.isUpdateAvailable).toBe(false)
})
it.for([
'NodeVersionStatusPending',
'NodeVersionStatusFlagged',
'NodeVersionStatusBanned'
] as const)(
'does not advertise a %s release as a default update',
(status) => {
const pack = createPack('pack-1', '3.0.0')
pack.latest_version = { version: '3.0.0', status }
expect(
getPackUpdateStatus(pack, createStore({ 'pack-1': '2.0.0' }))
.isUpdateAvailable
).toBe(false)
}
)

it.for([
['1.0.0', true],
['2.0.0', false],
['2.5.0', false]
] as const)(
'compares installed %s with the resolved Active release',
([installed, expected]) => {
const pack: NodePack = {
id: 'pack-1',
latest_version: { version: '3.0.0', status: 'NodeVersionStatusFlagged' }
}
const status = getPackUpdateStatus(
pack,
createStore({ 'pack-1': installed }),
{
version: '2.0.0',
status: 'NodeVersionStatusActive'
}
)
expect(status.latestVersion).toBe('2.0.0')
expect(status.isUpdateAvailable).toBe(expected)
}
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import type { components } from '@/types/comfyRegistryTypes'
import type { useComfyManagerStore } from '@/platform/customNodes/manager/stores/comfyManagerStore'

type NodePack = components['schemas']['Node']
type ComfyManagerStore = ReturnType<typeof useComfyManagerStore>
type ComfyManagerStore = Pick<
ReturnType<typeof useComfyManagerStore>,
'isPackInstalled' | 'getInstalledPackVersion'
>

interface PackUpdateStatus {
isInstalled: boolean
Expand All @@ -22,18 +25,17 @@ export function isNightlyVersion(version: string | undefined): boolean {
return !!version && !valid(version)
}

/**
* Derives the update status of a pack from its installed version and the
* latest release version advertised by the registry. A nightly build is never
* "outdated" since git hashes cannot be ordered.
*/
export function getPackUpdateStatus(
pack: NodePack | undefined,
managerStore: ComfyManagerStore
managerStore: ComfyManagerStore,
updateVersion = pack?.latest_version
): PackUpdateStatus {
const isInstalled = managerStore.isPackInstalled(pack?.id)
const installedVersion = managerStore.getInstalledPackVersion(pack?.id ?? '')
const latestVersion = pack?.latest_version?.version
const latestVersion =
updateVersion?.status === 'NodeVersionStatusActive'
? updateVersion.version
: undefined
const isNightly = isNightlyVersion(installedVersion)

const isUpdateAvailable =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function makePack(overrides: Partial<NodePack> = {}): NodePack {
return {
id: 'pack-1',
name: 'Pack',
latest_version: { version: '2.0.0' },
latest_version: { version: '2.0.0', status: 'NodeVersionStatusActive' },
...overrides
}
}
Expand Down Expand Up @@ -85,12 +85,18 @@ describe('usePackUpdateStatus', () => {
})

it('recomputes when the source pack changes', async () => {
const source = ref(makePack({ latest_version: { version: '1.0.0' } }))
const source = ref(
makePack({
latest_version: { version: '1.0.0', status: 'NodeVersionStatusActive' }
})
)
const { isUpdateAvailable } = usePackUpdateStatus(source)

expect(isUpdateAvailable.value).toBe(false)

source.value = makePack({ latest_version: { version: '3.0.0' } })
source.value = makePack({
latest_version: { version: '3.0.0', status: 'NodeVersionStatusActive' }
})
await nextTick()

expect(isUpdateAvailable.value).toBe(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ import { computed, toValue } from 'vue'

import type { components } from '@/types/comfyRegistryTypes'
import { useComfyManagerStore } from '@/platform/customNodes/manager/stores/comfyManagerStore'
import { getPackUpdateStatus } from '@/platform/customNodes/manager/composables/nodePack/packUpdateStatus'
import { usePackUpdateStatuses } from '@/platform/customNodes/manager/composables/nodePack/usePackUpdateStatuses'

export const usePackUpdateStatus = (
nodePackSource: MaybeRefOrGetter<components['schemas']['Node']>
) => {
const managerStore = useComfyManagerStore()

// Use toValue to unwrap the source reactively inside computeds
const nodePack = computed(() => toValue(nodePackSource))

const status = computed(() =>
getPackUpdateStatus(nodePack.value, managerStore)
)
const { getStatus } = usePackUpdateStatuses(() => [nodePack.value])
const status = computed(() => getStatus(nodePack.value))

const isInstalled = computed(() => status.value.isInstalled)
const isEnabled = computed(() =>
Expand All @@ -26,11 +24,6 @@ export const usePackUpdateStatus = (
const isNightlyPack = computed(() => status.value.isNightly)
const isUpdateAvailable = computed(() => status.value.isUpdateAvailable)

/**
* Nightly packs can always "try update" since we cannot compare git hashes
* to determine if an update is actually available. This allows users to
* pull the latest changes from the repository.
*/
const canTryNightlyUpdate = computed(
() => isInstalled.value && isEnabled.value && isNightlyPack.value
)
Expand Down
Loading
Loading