Skip to content
Merged
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
58 changes: 58 additions & 0 deletions src/components/helpcenter/HelpCenterMenuContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
</template>

<script setup lang="ts">
import { useToast } from 'primevue/usetoast'
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
import type { CSSProperties, Component } from 'vue'
import { useI18n } from 'vue-i18n'
Expand All @@ -168,6 +169,7 @@ import { electronAPI, isElectron } from '@/utils/envUtil'
import { formatVersionAnchor } from '@/utils/formatUtil'
import { useConflictAcknowledgment } from '@/workbench/extensions/manager/composables/useConflictAcknowledgment'
import { useManagerState } from '@/workbench/extensions/manager/composables/useManagerState'
import { useComfyManagerService } from '@/workbench/extensions/manager/services/comfyManagerService'
import { ManagerTab } from '@/workbench/extensions/manager/types/comfyManagerTypes'

// Types
Expand Down Expand Up @@ -201,6 +203,7 @@ const SUBMENU_CONFIG = {

// Composables
const { t } = useI18n()
const toast = useToast()
const { staticUrls, buildDocsUrl } = useExternalLink()
const releaseStore = useReleaseStore()
const commandStore = useCommandStore()
Expand Down Expand Up @@ -230,6 +233,7 @@ const showVersionUpdates = computed(() =>
// Use conflict acknowledgment state from composable
const { shouldShowRedDot: shouldShowManagerRedDot } =
useConflictAcknowledgment()
const { isNewManagerUI } = useManagerState()

const moreItems = computed<MenuItem[]>(() => {
const allMoreItems: MenuItem[] = [
Expand Down Expand Up @@ -369,6 +373,19 @@ const menuItems = computed<MenuItem[]>(() => {
}
})
}
// Update ComfyUI - only for non-desktop, non-cloud with new manager UI
if (!isElectron() && !isCloud && isNewManagerUI.value) {
items.push({
key: 'update-comfyui',
type: 'item',
icon: 'icon-[lucide--download]',
label: t('helpCenter.updateComfyUI'),
action: () => {
onUpdateComfyUI()
emit('close')
}
})
}

items.push({
key: 'more',
Expand Down Expand Up @@ -545,6 +562,47 @@ const onReinstall = (): void => {
}
}

const onUpdateComfyUI = async (): Promise<void> => {
const { updateComfyUI, rebootComfyUI, error } = useComfyManagerService()

toast.add({
severity: 'info',
summary: t('helpCenter.updateComfyUIStarted'),
detail: t('helpCenter.updateComfyUIStartedDetail'),
life: 3000
})

try {
const result = await updateComfyUI({ is_stable: true })

if (result === null || error.value) {
toast.add({
severity: 'error',
summary: t('g.error'),
detail: error.value || t('helpCenter.updateComfyUIFailed'),
life: 5000
})
return
}

toast.add({
severity: 'success',
summary: t('helpCenter.updateComfyUISuccess'),
detail: t('helpCenter.updateComfyUISuccessDetail'),
life: 3000
})

await rebootComfyUI()
} catch (err) {
toast.add({
severity: 'error',
summary: t('g.error'),
detail: err instanceof Error ? err.message : t('g.unknownError'),
life: 5000
})
}
}

const onReleaseClick = (release: ReleaseNote): void => {
trackResourceClick('release_notes', true)
void releaseStore.handleShowChangelog(release.version)
Expand Down
8 changes: 7 additions & 1 deletion src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,13 @@
"updateAvailable": "Update",
"desktopUserGuide": "Desktop User Guide",
"openDevTools": "Open Dev Tools",
"reinstall": "Re-Install"
"reinstall": "Re-Install",
"updateComfyUI": "Update ComfyUI",
"updateComfyUIStarted": "Update Started",
"updateComfyUIStartedDetail": "ComfyUI update has been queued. Please wait...",
"updateComfyUISuccess": "Update Complete",
"updateComfyUISuccessDetail": "ComfyUI has been updated. Rebooting...",
"updateComfyUIFailed": "Failed to update ComfyUI. Please try again."
},
"releaseToast": {
"newVersionAvailable": "New update is out!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type ManagerQueueStatus = components['schemas']['QueueStatus']
type InstallPackParams = components['schemas']['InstallPackParams']
type InstalledPacksResponse = components['schemas']['InstalledPacksResponse']
type UpdateAllPacksParams = components['schemas']['UpdateAllPacksParams']
type UpdateComfyUIParams = components['schemas']['UpdateComfyUIParams']
type ManagerTaskHistory = components['schemas']['HistoryResponse']
type QueueTaskItem = components['schemas']['QueueTaskItem']

Expand All @@ -26,6 +27,7 @@ enum ManagerRoute {
RESET_QUEUE = 'manager/queue/reset',
QUEUE_STATUS = 'manager/queue/status',
UPDATE_ALL = 'manager/queue/update_all',
UPDATE_COMFYUI = 'manager/queue/update_comfyui',
LIST_INSTALLED = 'customnode/installed',
GET_NODES = 'customnode/getmappings',
IMPORT_FAIL_INFO = 'customnode/import_fail_info',
Expand Down Expand Up @@ -271,6 +273,33 @@ export const useComfyManagerService = () => {
)
}

const updateComfyUI = async (
params: UpdateComfyUIParams = { is_stable: true },
ui_id?: string,
signal?: AbortSignal
) => {
const errorContext = 'Updating ComfyUI'
const routeSpecificErrors = {
400: 'Bad Request: Missing required parameters',
403: 'Forbidden: To use this action, a security_level of `middle or below` is required'
}

const queryParams = {
client_id: api.clientId ?? api.initialClientId ?? 'unknown',
ui_id: ui_id || uuidv4(),
...params
}

return executeRequest<null>(
() =>
managerApiClient.get(ManagerRoute.UPDATE_COMFYUI, {
params: queryParams,
signal
}),
{ errorContext, routeSpecificErrors, isQueueOperation: true }
)
}

const rebootComfyUI = async (signal?: AbortSignal) => {
const errorContext = 'Rebooting ComfyUI'
const routeSpecificErrors = {
Expand Down Expand Up @@ -335,6 +364,7 @@ export const useComfyManagerService = () => {
updateAllPacks,

// System operations
updateComfyUI,
rebootComfyUI,
isLegacyManagerUI
}
Expand Down
1 change: 1 addition & 0 deletions tests-ui/tests/store/comfyManagerStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('useComfyManagerStore', () => {
disablePack: vi.fn().mockResolvedValue(null),
updatePack: vi.fn().mockResolvedValue(null),
updateAllPacks: vi.fn().mockResolvedValue(null),
updateComfyUI: vi.fn().mockResolvedValue(null),
rebootComfyUI: vi.fn().mockResolvedValue(null),
isLegacyManagerUI: vi.fn().mockResolvedValue(false)
}
Expand Down