mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-11 08:20:53 +00:00
## Summary
Remove `life` (timeout) property from all error-severity toast calls so
they persist until manually dismissed, preventing users from missing
important error messages.
## Changes
- **What**: Removed `life` property from 86 error toast calls across 46
files. Error toasts now use PrimeVue's default behavior (no
auto-dismiss). Non-error toasts (success, warn, info) are unchanged.
- Also fixed a pre-existing lint issue in `TaskListPanel.vue` (`import {
t } from '@/i18n'` → `useI18n()`)
## Review Focus
- One conditional toast in `useMediaAssetActions.ts` intentionally keeps
`life` because its severity alternates between `warn` and `error`
Fixes
https://www.notion.so/comfy-org/Implement-Remove-timeouts-for-all-error-toasts-31b6d73d365081cead54fddc77ae7c3d
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9543-fix-remove-timeouts-from-error-toasts-so-they-persist-until-dismissed-31c6d73d365081fa8d30f6366e9bfe38)
by [Unito](https://www.unito.io)
309 lines
9.2 KiB
TypeScript
309 lines
9.2 KiB
TypeScript
import log from 'loglevel'
|
|
|
|
import { useExternalLink } from '@/composables/useExternalLink'
|
|
import { PYTHON_MIRROR } from '@/constants/uvMirrors'
|
|
import { t } from '@/i18n'
|
|
import { useToastStore } from '@/platform/updates/common/toastStore'
|
|
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
|
import { app } from '@/scripts/app'
|
|
import { useDialogService } from '@/services/dialogService'
|
|
import { checkMirrorReachable } from '@/utils/electronMirrorCheck'
|
|
import { isDesktop } from '@/platform/distribution/types'
|
|
import { electronAPI as getElectronAPI } from '@/utils/envUtil'
|
|
;(async () => {
|
|
if (!isDesktop) return
|
|
|
|
const electronAPI = getElectronAPI()
|
|
const desktopAppVersion = await electronAPI.getElectronVersion()
|
|
const workflowStore = useWorkflowStore()
|
|
const toastStore = useToastStore()
|
|
const { staticUrls, buildDocsUrl } = useExternalLink()
|
|
|
|
const onChangeRestartApp = (newValue: unknown, oldValue: unknown) => {
|
|
// Add a delay to allow changes to take effect before restarting.
|
|
if (oldValue !== undefined && newValue !== oldValue) {
|
|
electronAPI.restartApp('Restart ComfyUI to apply changes.', 1500)
|
|
}
|
|
}
|
|
|
|
app.registerExtension({
|
|
name: 'Comfy.ElectronAdapter',
|
|
settings: [
|
|
{
|
|
id: 'Comfy-Desktop.AutoUpdate',
|
|
category: ['Comfy-Desktop', 'General', 'AutoUpdate'],
|
|
name: 'Automatically check for updates',
|
|
type: 'boolean',
|
|
defaultValue: true,
|
|
onChange: onChangeRestartApp
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.SendStatistics',
|
|
category: ['Comfy-Desktop', 'General', 'Send Statistics'],
|
|
name: 'Send anonymous usage metrics',
|
|
type: 'boolean',
|
|
defaultValue: true,
|
|
onChange: onChangeRestartApp
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.WindowStyle',
|
|
category: ['Comfy-Desktop', 'General', 'Window Style'],
|
|
name: 'Window Style',
|
|
tooltip: "Custom: Replace the system title bar with ComfyUI's Top menu",
|
|
type: 'combo',
|
|
experimental: true,
|
|
defaultValue: 'default',
|
|
options: ['default', 'custom'],
|
|
onChange: (
|
|
newValue: 'default' | 'custom',
|
|
oldValue?: 'default' | 'custom'
|
|
) => {
|
|
if (!oldValue) return
|
|
|
|
electronAPI.Config.setWindowStyle(newValue)
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.UV.PythonInstallMirror',
|
|
name: 'Python Install Mirror',
|
|
tooltip: `Managed Python installations are downloaded from the Astral python-build-standalone project. This variable can be set to a mirror URL to use a different source for Python installations. The provided URL will replace https://github.com/astral-sh/python-build-standalone/releases/download in, e.g., https://github.com/astral-sh/python-build-standalone/releases/download/20240713/cpython-3.12.4%2B20240713-aarch64-apple-darwin-install_only.tar.gz. Distributions can be read from a local directory by using the file:// URL scheme.`,
|
|
type: 'url',
|
|
defaultValue: '',
|
|
attrs: {
|
|
validateUrlFn(mirror: string) {
|
|
return checkMirrorReachable(
|
|
mirror + PYTHON_MIRROR.validationPathSuffix
|
|
)
|
|
}
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.UV.PypiInstallMirror',
|
|
name: 'Pypi Install Mirror',
|
|
tooltip: `Default pip install mirror`,
|
|
type: 'url',
|
|
defaultValue: '',
|
|
attrs: {
|
|
validateUrlFn: checkMirrorReachable
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.UV.TorchInstallMirror',
|
|
name: 'Torch Install Mirror',
|
|
tooltip: `Pip install mirror for pytorch`,
|
|
type: 'url',
|
|
defaultValue: '',
|
|
attrs: {
|
|
validateUrlFn: checkMirrorReachable
|
|
}
|
|
}
|
|
],
|
|
|
|
commands: [
|
|
{
|
|
id: 'Comfy-Desktop.Folders.OpenLogsFolder',
|
|
label: 'Open Logs Folder',
|
|
icon: 'pi pi-folder-open',
|
|
function() {
|
|
electronAPI.openLogsFolder()
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.Folders.OpenModelsFolder',
|
|
label: 'Open Models Folder',
|
|
icon: 'pi pi-folder-open',
|
|
function() {
|
|
electronAPI.openModelsFolder()
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.Folders.OpenOutputsFolder',
|
|
label: 'Open Outputs Folder',
|
|
icon: 'pi pi-folder-open',
|
|
function() {
|
|
electronAPI.openOutputsFolder()
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.Folders.OpenInputsFolder',
|
|
label: 'Open Inputs Folder',
|
|
icon: 'pi pi-folder-open',
|
|
function() {
|
|
electronAPI.openInputsFolder()
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.Folders.OpenCustomNodesFolder',
|
|
label: 'Open Custom Nodes Folder',
|
|
icon: 'pi pi-folder-open',
|
|
function() {
|
|
electronAPI.openCustomNodesFolder()
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.Folders.OpenModelConfig',
|
|
label: 'Open extra_model_paths.yaml',
|
|
icon: 'pi pi-file',
|
|
function() {
|
|
electronAPI.openModelConfig()
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.OpenDevTools',
|
|
label: 'Open DevTools',
|
|
icon: 'pi pi-code',
|
|
function() {
|
|
electronAPI.openDevTools()
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.OpenUserGuide',
|
|
label: 'Desktop User Guide',
|
|
icon: 'pi pi-book',
|
|
function() {
|
|
window.open(
|
|
buildDocsUrl('/installation/desktop', {
|
|
includeLocale: true,
|
|
platform: true
|
|
}),
|
|
'_blank'
|
|
)
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.CheckForUpdates',
|
|
label: 'Check for Updates',
|
|
icon: 'pi pi-sync',
|
|
async function() {
|
|
try {
|
|
const updateInfo = await electronAPI.checkForUpdates({
|
|
disableUpdateReadyAction: true
|
|
})
|
|
|
|
if (!updateInfo.isUpdateAvailable) {
|
|
toastStore.add({
|
|
severity: 'info',
|
|
summary: t('desktopUpdate.noUpdateFound'),
|
|
life: 5_000
|
|
})
|
|
return
|
|
}
|
|
|
|
const proceed = await useDialogService().confirm({
|
|
title: t('desktopUpdate.updateFoundTitle', {
|
|
version: updateInfo.version
|
|
}),
|
|
message: t('desktopUpdate.updateAvailableMessage'),
|
|
type: 'default'
|
|
})
|
|
if (proceed) {
|
|
try {
|
|
electronAPI.restartAndInstall()
|
|
} catch (error) {
|
|
log.error('Error installing update:', error)
|
|
toastStore.add({
|
|
severity: 'error',
|
|
summary: t('g.error'),
|
|
detail: t('desktopUpdate.errorInstallingUpdate')
|
|
})
|
|
}
|
|
}
|
|
} catch (error) {
|
|
log.error('Error checking for updates:', error)
|
|
toastStore.add({
|
|
severity: 'error',
|
|
summary: t('g.error'),
|
|
detail: t('desktopUpdate.errorCheckingUpdate')
|
|
})
|
|
}
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.Reinstall',
|
|
label: 'Reinstall',
|
|
icon: 'pi pi-refresh',
|
|
async function() {
|
|
const proceed = await useDialogService().confirm({
|
|
message: t('desktopMenu.confirmReinstall'),
|
|
title: t('desktopMenu.reinstall'),
|
|
type: 'reinstall'
|
|
})
|
|
|
|
if (proceed) electronAPI.reinstall()
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.Restart',
|
|
label: 'Restart',
|
|
icon: 'pi pi-refresh',
|
|
function() {
|
|
electronAPI.restartApp()
|
|
}
|
|
},
|
|
{
|
|
id: 'Comfy-Desktop.Quit',
|
|
label: 'Quit',
|
|
icon: 'pi pi-sign-out',
|
|
async function() {
|
|
// Confirm if unsaved workflows are open
|
|
if (workflowStore.modifiedWorkflows.length > 0) {
|
|
const confirmed = await useDialogService().confirm({
|
|
message: t('desktopMenu.confirmQuit'),
|
|
title: t('desktopMenu.quit'),
|
|
type: 'default'
|
|
})
|
|
|
|
if (!confirmed) return
|
|
}
|
|
|
|
electronAPI.quit()
|
|
}
|
|
}
|
|
],
|
|
|
|
menuCommands: [
|
|
{
|
|
path: ['Help'],
|
|
commands: ['Comfy-Desktop.OpenUserGuide']
|
|
},
|
|
{
|
|
path: ['Help'],
|
|
commands: ['Comfy-Desktop.OpenDevTools']
|
|
},
|
|
{
|
|
path: ['Help', 'Open Folder'],
|
|
commands: [
|
|
'Comfy-Desktop.Folders.OpenLogsFolder',
|
|
'Comfy-Desktop.Folders.OpenModelsFolder',
|
|
'Comfy-Desktop.Folders.OpenOutputsFolder',
|
|
'Comfy-Desktop.Folders.OpenInputsFolder',
|
|
'Comfy-Desktop.Folders.OpenCustomNodesFolder',
|
|
'Comfy-Desktop.Folders.OpenModelConfig'
|
|
]
|
|
},
|
|
{
|
|
path: ['Help'],
|
|
commands: ['Comfy-Desktop.CheckForUpdates', 'Comfy-Desktop.Reinstall']
|
|
}
|
|
],
|
|
|
|
keybindings: [
|
|
{
|
|
commandId: 'Workspace.CloseWorkflow',
|
|
combo: {
|
|
key: 'w',
|
|
ctrl: true
|
|
}
|
|
}
|
|
],
|
|
|
|
aboutPageBadges: [
|
|
{
|
|
label: 'ComfyUI_desktop v' + desktopAppVersion,
|
|
url: staticUrls.githubElectron,
|
|
icon: 'pi pi-github'
|
|
}
|
|
]
|
|
})
|
|
})()
|