From 9d7cca4009eb37093b849220699458dc2b6be45f Mon Sep 17 00:00:00 2001 From: Amp Date: Fri, 25 Sep 2026 06:15:38 +0000 Subject: [PATCH 01/71] refactor: replace PrimeVue toast with design-system toast Add a Reka-based toast with a useToast Pinia API supporting persistent and timed standard and custom-component toasts, and migrate every production, unit, and browser-test caller. BREAKING CHANGE: the PrimeVue-shaped toast manager API (add, remove, severity/summary/detail/life bags) is replaced by named methods and toast IDs. Amp-Thread-ID: T-01a0a191-6a66-768e-96c8-fe9eeb2cfbec --- README.md | 18 +- .../fixtures/components/SidebarTab.ts | 4 +- browser_tests/fixtures/helpers/ToastHelper.ts | 20 +- browser_tests/fixtures/utils/errorSurfaces.ts | 9 +- browser_tests/tests/authAccountSwitch.spec.ts | 5 +- .../tests/customNodes/errorSurfaces.spec.ts | 21 +- .../tests/dialogs/enterpriseTierCloud.spec.ts | 12 +- .../tests/dialogs/memberRoleChange.spec.ts | 8 +- .../dialogs/pricingTableDeepLink.spec.ts | 3 +- .../dialogs/topUpNoPaymentMethod.spec.ts | 3 +- .../tests/dialogs/topUpSdkRail.spec.ts | 2 +- browser_tests/tests/sidebar/assets.spec.ts | 4 +- .../sidebar/sidebarSplitterWidth.spec.ts | 2 +- browser_tests/tests/templates.spec.ts | 2 +- .../tests/toastNotifications.spec.ts | 23 +- .../tests/versionMismatchWarnings.spec.ts | 14 +- oxlint-suppressions.json | 2 +- scripts/primevue-import-allowlist.json | 61 --- src/App.vue | 6 - src/assets/css/style.css | 13 - src/base/common/downloadUtil.test.ts | 5 + src/base/common/downloadUtil.ts | 9 +- .../common/BackgroundImageUpload.vue | 12 +- src/components/dialog/GlobalDialog.test.ts | 16 +- .../dialog/content/ErrorDialogContent.vue | 8 +- .../TopUpCreditsDialogContentLegacy.test.ts | 17 +- .../TopUpCreditsDialogContentLegacy.vue | 10 +- .../content/setting/KeybindingPanel.vue | 12 +- .../dialog/content/setting/UserPanel.test.ts | 18 +- .../CancelSubscriptionDialogContent.test.ts | 83 ++-- .../CancelSubscriptionDialogContent.vue | 13 +- src/components/dialog/rekaPrimeVueBridge.ts | 11 +- src/components/dialog/vRekaZIndex.ts | 5 + src/components/graph/GraphCanvas.vue | 10 +- .../helpcenter/HelpCenterMenuContent.test.ts | 25 +- .../helpcenter/HelpCenterMenuContent.vue | 30 +- .../load3d/controls/HDRIControls.test.ts | 15 +- .../load3d/controls/HDRIControls.vue | 6 +- .../load3d/menubar/HdriMenuGroup.vue | 6 +- .../sidebar/tabs/AssetsSidebarTab.test.ts | 7 - .../sidebar/tabs/AssetsSidebarTab.vue | 22 +- .../tabs/ModelLibrarySidebarTab.test.ts | 32 +- .../sidebar/tabs/ModelLibrarySidebarTab.vue | 12 +- src/components/toast/GlobalToast.test.ts | 167 -------- src/components/toast/GlobalToast.vue | 131 ------ .../toast/RerouteMigrationToast.vue | 44 +- src/components/ui/toast/ToastClose.vue | 29 ++ src/components/ui/toast/ToastDescription.vue | 21 + src/components/ui/toast/ToastProvider.vue | 19 + src/components/ui/toast/ToastRoot.vue | 38 ++ src/components/ui/toast/ToastTitle.vue | 21 + src/components/ui/toast/ToastViewport.vue | 35 ++ src/components/ui/toast/Toaster.test.ts | 132 ++++++ src/components/ui/toast/Toaster.vue | 88 ++++ src/components/ui/toast/index.ts | 3 + src/components/ui/toast/toastStore.test.ts | 74 ++++ src/components/ui/toast/toastStore.ts | 140 +++++++ src/composables/auth/useAuthActions.test.ts | 76 ++-- src/composables/auth/useAuthActions.ts | 47 +-- .../graph/useSelectionOperations.ts | 44 +- .../graph/useSubgraphOperations.test.ts | 12 +- .../graph/useSubgraphOperations.ts | 10 +- .../node/useNodeDragToCanvas.test.ts | 14 +- src/composables/node/useNodeDragToCanvas.ts | 14 +- .../node/useNodeImageUpload.test.ts | 14 +- src/composables/node/useNodeImageUpload.ts | 14 +- src/composables/painter/usePainter.ts | 12 +- src/composables/useCameraAngle.test.ts | 11 +- src/composables/useCameraAngle.ts | 8 +- src/composables/useCameraInfo.test.ts | 13 +- src/composables/useCameraInfo.ts | 8 +- src/composables/useCopyToClipboard.test.ts | 29 +- src/composables/useCopyToClipboard.ts | 26 +- src/composables/useCoreCommands.test.ts | 20 +- src/composables/useCoreCommands.ts | 77 ++-- src/composables/useErrorHandling.test.ts | 23 +- src/composables/useErrorHandling.ts | 10 +- src/composables/useLoad3d.test.ts | 32 +- src/composables/useLoad3d.ts | 32 +- src/composables/useLoad3dDrag.test.ts | 14 +- src/composables/useLoad3dDrag.ts | 6 +- src/composables/useLoad3dViewer.test.ts | 46 ++- src/composables/useLoad3dViewer.ts | 102 +++-- src/composables/usePaste.test.ts | 14 +- .../useReconnectingNotification.test.ts | 65 +-- .../useReconnectingNotification.ts | 26 +- src/composables/useWorkspaceInset.test.ts | 2 +- src/core/graph/subgraph/promotionUtils.ts | 8 +- src/extensions/core/electronAdapter.ts | 22 +- src/extensions/core/load3d.test.ts | 24 +- src/extensions/core/load3d.ts | 22 +- src/extensions/core/load3d/Load3dUtils.ts | 21 +- .../core/load3d/LoaderManager.test.ts | 34 +- src/extensions/core/load3d/LoaderManager.ts | 10 +- .../core/load3d/ModelExporter.test.ts | 42 +- src/extensions/core/load3d/ModelExporter.ts | 30 +- .../core/load3d/exportMenuHelper.test.ts | 19 +- .../core/load3d/exportMenuHelper.ts | 15 +- .../core/load3dPreviewExtensions.test.ts | 8 +- .../core/load3dPreviewExtensions.ts | 4 +- src/extensions/core/nodeTemplates.ts | 16 +- src/extensions/core/uploadAudio.test.ts | 48 ++- src/extensions/core/uploadAudio.ts | 22 +- src/extensions/core/webcamCapture.ts | 6 +- src/main.ts | 10 +- .../ModelImportProgressDialog.test.ts | 11 +- .../composables/openModelLibraryBrowser.ts | 10 +- .../assets/composables/useAssetDownload.ts | 18 +- .../assets/composables/useAssetZipExport.ts | 18 +- .../composables/useMediaAssetActions.test.ts | 174 ++++---- .../composables/useMediaAssetActions.ts | 155 +++---- .../composables/useNodeOutputsExport.test.ts | 16 +- .../assets/utils/createAssetWidget.ts | 16 +- .../auth/session/cloudWebSessionStore.ts | 10 +- .../components/SignOutEverywhereButton.vue | 20 +- src/platform/auth/webSessionFlagOn.test.ts | 8 +- .../cloud/onboarding/CloudSurveyView.test.ts | 20 +- .../cloud/onboarding/CloudSurveyView.vue | 18 +- .../onboarding/components/CloudLayoutView.vue | 5 +- .../components/OAuthLayoutView.test.ts | 2 +- .../onboarding/components/OAuthLayoutView.vue | 4 +- .../composables/usePostAuthRedirect.test.ts | 44 +- .../composables/usePostAuthRedirect.ts | 18 +- .../onboarding/desktopLoginRedemption.test.ts | 93 +++-- .../onboarding/desktopLoginRedemption.ts | 26 +- .../useSubscriptionActions.test.ts | 93 +++-- .../launchCancellationFlow.test.ts | 4 +- .../subscription/launchCancellationFlow.ts | 8 +- .../keybindings/presetService.test.ts | 7 +- src/platform/keybindings/presetService.ts | 22 +- .../missingMedia/missingMediaPipeline.test.ts | 10 +- .../missingMedia/missingMediaPipeline.ts | 11 +- .../missingModel/missingModelPipeline.test.ts | 37 +- .../missingModel/missingModelPipeline.ts | 11 +- .../missingModel/missingModelScan.test.ts | 5 - .../missingModel/missingModelStore.test.ts | 16 +- .../missingModel/missingModelStore.ts | 8 +- .../useNodeReplacement.test.ts | 12 +- .../nodeReplacement/useNodeReplacement.ts | 220 +++++----- .../onboarding/onboardingTourStore.test.ts | 23 +- .../onboarding/onboardingTourStore.ts | 8 +- .../secrets/composables/useSecrets.test.ts | 41 +- .../secrets/composables/useSecrets.ts | 28 +- .../settings/components/ServerConfigPanel.vue | 12 +- src/platform/updates/common/toastStore.ts | 39 -- .../useFrontendVersionMismatchWarning.test.ts | 70 ++-- .../useFrontendVersionMismatchWarning.ts | 6 +- .../core/services/workflowActionsService.ts | 4 +- .../core/services/workflowService.test.ts | 30 +- .../workflow/core/services/workflowService.ts | 25 +- .../useWorkflowPersistenceV2.test.ts | 12 +- .../composables/useWorkflowPersistenceV2.ts | 8 +- .../ShareWorkflowDialogContent.test.ts | 9 +- .../components/ShareWorkflowDialogContent.vue | 19 +- .../profile/ComfyHubCreateProfileForm.vue | 8 +- .../publish/ComfyHubPublishDialog.test.ts | 12 +- .../publish/ComfyHubPublishDialog.vue | 22 +- .../useSharedWorkflowUrlLoader.test.ts | 7 +- .../composables/useSharedWorkflowUrlLoader.ts | 20 +- .../sharing/utils/validateFileSize.ts | 8 +- .../composables/useTemplateUrlLoader.test.ts | 20 +- .../composables/useTemplateUrlLoader.ts | 8 +- .../composables/useTemplateWorkflows.test.ts | 64 ++- .../composables/useTemplateWorkflows.ts | 30 +- .../composables/useWorkflowValidation.ts | 18 +- .../billing/sdk/billingSdkStore.test.ts | 127 +++--- .../workspace/billing/sdk/billingSdkStore.ts | 64 +-- .../sdk/billingSdkTelemetryOwnership.test.ts | 14 +- .../components/InviteMembersForm.test.ts | 14 +- .../components/InviteMembersForm.vue | 14 +- .../components/PaymentRecoveryToast.vue | 30 ++ .../SubscriptionPanelContentWorkspace.test.ts | 12 +- ...TopUpCreditsDialogContentWorkspace.test.ts | 12 +- .../TopUpCreditsDialogContentWorkspace.vue | 20 +- .../ChangeMemberRoleDialogContent.test.ts | 14 +- .../dialogs/ChangeMemberRoleDialogContent.vue | 13 +- .../dialogs/CreateWorkspaceDialogContent.vue | 8 +- .../dialogs/DeleteWorkspaceDialogContent.vue | 8 +- ...owngradeRemoveMembersDialogContent.test.ts | 14 +- .../DowngradeRemoveMembersDialogContent.vue | 8 +- .../dialogs/EditWorkspaceDialogContent.vue | 16 +- .../dialogs/InviteMemberDialogContent.test.ts | 14 +- .../dialogs/LeaveWorkspaceDialogContent.vue | 8 +- .../dialogs/RemoveMemberDialogContent.vue | 13 +- .../dialogs/RevokeInviteDialogContent.vue | 8 +- .../TeamWorkspacesDialogContent.test.ts | 14 +- .../dialogs/TeamWorkspacesDialogContent.vue | 22 +- .../settings/PendingInvitesList.test.ts | 17 +- .../dialogs/settings/PendingInvitesList.vue | 15 +- .../components/toasts/InviteAcceptedToast.vue | 53 ++- .../composables/useInviteUrlLoader.test.ts | 14 +- .../composables/useInviteUrlLoader.ts | 22 +- .../composables/useMembersPanel.test.ts | 12 +- .../workspace/composables/useMembersPanel.ts | 13 +- .../composables/useResubscribe.test.ts | 12 +- .../workspace/composables/useResubscribe.ts | 14 +- .../useSubscriptionCheckout.test.ts | 379 +++++++++--------- .../composables/useSubscriptionCheckout.ts | 208 ++++------ .../composables/useWorkspaceBilling.test.ts | 8 +- .../composables/useWorkspaceBilling.ts | 8 +- .../composables/useWorkspaceUrlLoader.test.ts | 43 +- .../composables/useWorkspaceUrlLoader.ts | 11 +- .../stores/billingOperationStore.test.ts | 227 +++++------ .../workspace/stores/billingOperationStore.ts | 46 +-- .../workspace/stores/useWorkspaceAuth.test.ts | 43 +- .../workspace/stores/workspaceAuthStore.ts | 8 +- .../composables/useCompositorEditor.test.ts | 26 +- .../composables/useCompositorEditor.ts | 8 +- .../useCompositorPsdDownload.test.ts | 45 ++- .../composables/useCompositorPsdDownload.ts | 22 +- .../components/LayerEditorContent.test.ts | 38 +- .../components/LayerEditorContent.vue | 32 +- .../composables/useLayerEditor.test.ts | 12 +- .../layerEditor/composables/useLayerEditor.ts | 8 +- .../composables/useLayerEditorExport.test.ts | 41 +- .../composables/useLayerEditorExport.ts | 10 +- .../extensions/linearMode/DropZone.test.ts | 7 - .../extensions/vueNodes/VideoPreview.vue | 11 +- .../vueNodes/components/ImagePreview.vue | 10 +- .../widgets/components/WidgetRecordAudio.vue | 8 +- .../widgets/components/WidgetTextPreview.vue | 8 +- .../audio/AudioPreviewPlayer.test.ts | 15 +- .../components/audio/AudioPreviewPlayer.vue | 8 +- .../form/dropdown/FormDropdown.test.ts | 11 +- .../components/form/dropdown/FormDropdown.vue | 8 +- .../useWidgetSelectActions.test.ts | 27 +- .../composables/useWidgetSelectActions.ts | 10 +- src/scripts/api.ts | 28 +- src/scripts/app.test.ts | 92 +++-- src/scripts/app.ts | 72 ++-- src/scripts/ui/settings.test.ts | 8 +- src/scripts/ui/settings.ts | 6 +- src/services/audioService.test.ts | 28 +- src/services/audioService.ts | 4 +- src/services/dialogService.downgrade.test.ts | 34 +- .../dialogService.errorCatalog.test.ts | 9 - src/services/dialogService.ts | 9 +- src/services/litegraphService.ts | 10 +- .../__tests__/authTokenPriority.test.ts | 10 + src/stores/apiKeyAuthStore.ts | 26 +- src/stores/assetExportStore.ts | 20 +- src/stores/subgraphStore.ts | 22 +- src/stores/workspaceStore.ts | 4 +- src/types/extensionTypes.ts | 60 +-- src/types/index.ts | 6 +- src/utils/litegraphUtil.test.ts | 7 +- src/utils/litegraphUtil.ts | 6 +- src/views/GraphView.test.ts | 4 +- src/views/GraphView.vue | 8 +- .../extensions/agent/AgentPanelRoot.test.ts | 112 +++--- .../extensions/agent/AgentPanelRoot.vue | 51 +-- .../agent/components/agent/Composer.test.ts | 4 +- .../agent/Composer.workflowClipboard.test.ts | 9 + .../components/agent/DockedAgentPanel.test.ts | 30 +- .../components/agent/DockedAgentPanel.vue | 1 + .../agent/composer/RunModePopover.vue | 6 +- .../agent/message/MessageFeedback.test.ts | 31 +- .../agent/message/ReplyAudioCard.test.ts | 11 +- .../agent/message/TabLinkCard.test.ts | 4 +- .../components/agent/message/TabLinkCard.vue | 10 +- .../message/UserMessage.clipboard.test.ts | 12 +- .../composables/agent/useAgentConsent.test.ts | 19 +- .../composables/agent/useAgentConsent.ts | 22 +- .../agent/useAgentWorkflowSelection.ts | 10 +- .../extensions/agent/crdt/rejectedOpNotice.ts | 10 +- ...ntCrdtFollower.rejectedWidgetWrite.test.ts | 22 +- .../manager/button/PackUpdateButton.test.ts | 12 +- .../manager/composables/useManagerQueue.ts | 10 +- .../composables/useManagerState.test.ts | 34 +- .../manager/composables/useManagerState.ts | 22 +- .../manager/stores/comfyManagerStore.test.ts | 39 +- .../manager/stores/comfyManagerStore.ts | 40 +- 272 files changed, 3657 insertions(+), 3763 deletions(-) delete mode 100644 src/components/toast/GlobalToast.test.ts delete mode 100644 src/components/toast/GlobalToast.vue create mode 100644 src/components/ui/toast/ToastClose.vue create mode 100644 src/components/ui/toast/ToastDescription.vue create mode 100644 src/components/ui/toast/ToastProvider.vue create mode 100644 src/components/ui/toast/ToastRoot.vue create mode 100644 src/components/ui/toast/ToastTitle.vue create mode 100644 src/components/ui/toast/ToastViewport.vue create mode 100644 src/components/ui/toast/Toaster.test.ts create mode 100644 src/components/ui/toast/Toaster.vue create mode 100644 src/components/ui/toast/index.ts create mode 100644 src/components/ui/toast/toastStore.test.ts create mode 100644 src/components/ui/toast/toastStore.ts delete mode 100644 src/platform/updates/common/toastStore.ts create mode 100644 src/platform/workspace/components/PaymentRecoveryToast.vue diff --git a/README.md b/README.md index 26baaeac81e..e060b712b6d 100644 --- a/README.md +++ b/README.md @@ -303,7 +303,7 @@ window['app'].extensionManager.dialog ```js // window.alert -window['app'].extensionManager.toast.addAlert('Test Alert') +window['app'].extensionManager.toast.info('Test Alert') ``` ![image](https://github.com/user-attachments/assets/9b18bdca-76ef-4432-95de-5cd2369684f2) @@ -464,15 +464,19 @@ app.registerExtension({ Extensions can call the following API to add toast messages. ```js -app.extensionManager.toast.add({ - severity: 'info', - summary: 'Loaded!', - detail: 'Extension loaded!', - life: 3000 +const toastId = app.extensionManager.toast.info('Loaded!', { + description: 'Extension loaded!', + duration: 3000, + closable: true }) + +app.extensionManager.toast.dismiss(toastId) ``` -Documentation of all supported options can be found here: +The toast manager provides `success`, `error`, `info`, `warning`, and `loading` +methods with the same `(title, options?)` signature. Toasts persist when +`duration` is omitted. Use `dismiss(id)` to remove one toast or `dismissAll()` +to remove every toast. ![image](https://github.com/user-attachments/assets/de02cd7e-cd81-43d1-a0b0-bccef92ff487) diff --git a/browser_tests/fixtures/components/SidebarTab.ts b/browser_tests/fixtures/components/SidebarTab.ts index 5c97d5e3089..95ebc127fb6 100644 --- a/browser_tests/fixtures/components/SidebarTab.ts +++ b/browser_tests/fixtures/components/SidebarTab.ts @@ -495,12 +495,12 @@ export class AssetsSidebarTab extends SidebarTab { /** Dismiss all visible toast notifications by clicking their close buttons. */ async dismissToasts() { - const closeButtons = this.page.locator('.p-toast-close-button') + const closeButtons = this.page.getByTestId('toast-close') for (const btn of await closeButtons.all()) { await btn.click().catch(() => {}) } // Wait for all toast elements to fully animate out and detach from DOM - await expect(this.page.locator('.p-toast-message')) + await expect(this.page.getByTestId('toast')) .toHaveCount(0) .catch(() => {}) } diff --git a/browser_tests/fixtures/helpers/ToastHelper.ts b/browser_tests/fixtures/helpers/ToastHelper.ts index cfe7581bc88..9f7c88e80c9 100644 --- a/browser_tests/fixtures/helpers/ToastHelper.ts +++ b/browser_tests/fixtures/helpers/ToastHelper.ts @@ -8,12 +8,16 @@ export class ToastHelper { public readonly toastWarnings: Locator constructor(private readonly page: Page) { - this.visibleToasts = page.locator('.p-toast-message:visible') - this.toastErrors = page.locator('.p-toast-message.p-toast-message-error') - this.toastSuccesses = page.locator( - '.p-toast-message.p-toast-message-success' - ) - this.toastWarnings = page.locator('.p-toast-message.p-toast-message-warn') + this.visibleToasts = page.getByTestId('toast').filter({ visible: true }) + this.toastErrors = page + .getByTestId('toast') + .and(page.locator('[data-toast-kind="error"]')) + this.toastSuccesses = page + .getByTestId('toast') + .and(page.locator('[data-toast-kind="success"]')) + this.toastWarnings = page + .getByTestId('toast') + .and(page.locator('[data-toast-kind="warning"]')) } async closeToasts(requireCount = 0): Promise { @@ -24,9 +28,7 @@ export class ToastHelper { } // Clear all toasts - const toastCloseButtons = await this.page - .locator('.p-toast-close-button') - .all() + const toastCloseButtons = await this.page.getByTestId('toast-close').all() for (const button of toastCloseButtons) { await button.click() } diff --git a/browser_tests/fixtures/utils/errorSurfaces.ts b/browser_tests/fixtures/utils/errorSurfaces.ts index 271032a8e24..ea2da9d73e7 100644 --- a/browser_tests/fixtures/utils/errorSurfaces.ts +++ b/browser_tests/fixtures/utils/errorSurfaces.ts @@ -25,7 +25,10 @@ const visibleErrorSurfaceSelectors = [ selector: `[data-testid="${TestIds.dialogs.errorDialog}"]` }, { surface: 'nodeRenderErrors', selector: '.node-error' }, - { surface: 'errorToasts', selector: '.p-toast-message-error' } + { + surface: 'errorToasts', + selector: '[data-testid="toast"][data-toast-kind="error"]' + } ] const visibleErrorSampleIntervalMs = 100 @@ -92,7 +95,9 @@ export function errorSurfaces(page: Page): Record { errorOverlay: page.getByTestId(TestIds.dialogs.errorOverlay), errorDialog: page.getByTestId(TestIds.dialogs.errorDialog), nodeRenderErrors: page.locator('.node-error'), - errorToasts: page.locator('.p-toast-message-error') + errorToasts: page + .getByTestId('toast') + .and(page.locator('[data-toast-kind="error"]')) } } diff --git a/browser_tests/tests/authAccountSwitch.spec.ts b/browser_tests/tests/authAccountSwitch.spec.ts index 6aab84d93b0..503f0d42cf9 100644 --- a/browser_tests/tests/authAccountSwitch.spec.ts +++ b/browser_tests/tests/authAccountSwitch.spec.ts @@ -342,7 +342,10 @@ test.describe('Cloud account switch', { tag: '@cloud' }, () => { await expect( page.getByText(ACCOUNT_B.email, { exact: true }) ).toBeVisible() - await page.keyboard.press('Escape') + await page.getByRole('button', { name: 'Current user' }).click() + await expect( + page.getByText(ACCOUNT_B.email, { exact: true }) + ).toBeHidden() await expect .poll(() => workspaceMintOwners, { timeout: 15_000 }) .toContain(ACCOUNT_B.id) diff --git a/browser_tests/tests/customNodes/errorSurfaces.spec.ts b/browser_tests/tests/customNodes/errorSurfaces.spec.ts index 74a7d7a914f..c15aa4afa2a 100644 --- a/browser_tests/tests/customNodes/errorSurfaces.spec.ts +++ b/browser_tests/tests/customNodes/errorSurfaces.spec.ts @@ -20,8 +20,8 @@ test('a persistent error toast fails carrying its visible text', async ({ page }) => { await page.setContent( - '
Failed to load workspace: HTTP 502
' + - '
Settings seed rejected
' + '
Failed to load workspace: HTTP 502
' + + '
Settings seed rejected
' ) const failure = await expectNoVisibleErrors(page, 'at startup').then( () => undefined, @@ -54,7 +54,8 @@ test('a visible error toast fails after it clears before the assertion', async ( await page.evaluate(() => { const toast = document.createElement('div') toast.id = 't' - toast.className = 'p-toast-message-error' + toast.dataset.testid = 'toast' + toast.dataset.toastKind = 'error' toast.textContent = 'momentary' document.getElementById('root')!.append(toast) setTimeout(() => toast.remove(), 800) @@ -68,16 +69,20 @@ test('a visible error toast fails after it clears before the assertion', async ( expect(String(failure)).toContain('momentary') }) -test('an error class added after insertion fails after it clears', async ({ +test('error toast attributes added after insertion fail after they clear', async ({ page }) => { await page.setContent('
late error
') await page.evaluate(() => { const toast = document.getElementById('t')! - toast.classList.add('p-toast-message-error') - setTimeout(() => toast.classList.remove('p-toast-message-error'), 800) + toast.dataset.testid = 'toast' + toast.dataset.toastKind = 'error' + setTimeout(() => { + delete toast.dataset.testid + delete toast.dataset.toastKind + }, 800) }) - await expect(page.locator('#t')).not.toHaveClass('p-toast-message-error') + await expect(page.locator('#t')).not.toHaveAttribute('data-toast-kind') const failure = await expectNoVisibleErrors(page, 'class-added').then( () => undefined, (error: unknown) => error @@ -91,7 +96,7 @@ test('a hidden error fails when an ancestor mutation reveals it', async ({ }) => { await page.setContent( '' ) await page.evaluate(() => { diff --git a/browser_tests/tests/dialogs/enterpriseTierCloud.spec.ts b/browser_tests/tests/dialogs/enterpriseTierCloud.spec.ts index 293af9da36d..53d2d59284f 100644 --- a/browser_tests/tests/dialogs/enterpriseTierCloud.spec.ts +++ b/browser_tests/tests/dialogs/enterpriseTierCloud.spec.ts @@ -283,12 +283,12 @@ test.describe('Enterprise workspace billing', { tag: '@cloud' }, () => { await expect( page.getByRole('heading', { name: 'Choose a Plan' }) ).toHaveCount(0) - await expect(page.locator('.p-toast-message-warn')).toContainText( - 'Plan inactive' - ) - await expect(page.locator('.p-toast-message-warn')).toContainText( - 'Contact your Comfy account manager to restore access.' - ) + await expect( + page.getByTestId('toast').and(page.locator('[data-toast-kind="warning"]')) + ).toContainText('Plan inactive') + await expect( + page.getByTestId('toast').and(page.locator('[data-toast-kind="warning"]')) + ).toContainText('Contact your Comfy account manager to restore access.') }) }) diff --git a/browser_tests/tests/dialogs/memberRoleChange.spec.ts b/browser_tests/tests/dialogs/memberRoleChange.spec.ts index 3cd215ca93c..b4d903b136c 100644 --- a/browser_tests/tests/dialogs/memberRoleChange.spec.ts +++ b/browser_tests/tests/dialogs/memberRoleChange.spec.ts @@ -191,7 +191,9 @@ test.describe('Member role change (Members tab)', { tag: '@cloud' }, () => { .click() await page.getByRole('button', { name: 'Make owner' }).click() - await expect(page.getByText('Role updated')).toBeVisible() + await expect( + page.getByTestId('toast').getByText('Role updated') + ).toBeVisible() await expect(janeRow.getByText('Owner', { exact: true })).toBeVisible() await expect(emails).toHaveText([ CREATOR.email, @@ -266,7 +268,9 @@ test.describe('Member role change (Members tab)', { tag: '@cloud' }, () => { await page.getByRole('button', { name: 'Make owner' }).click() // US10 — error toast, dialog stays open, role unchanged. - await expect(page.getByText('Failed to update role')).toBeVisible() + await expect( + page.getByTestId('toast').getByText('Failed to update role') + ).toBeVisible() await expect( page.getByRole('heading', { name: 'Make Jane an owner?' }) ).toBeVisible() diff --git a/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts b/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts index fbd917b43ee..c4362827a03 100644 --- a/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts +++ b/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts @@ -1140,7 +1140,8 @@ test.describe( expect(subscribeRequests).toHaveLength(1) const blockedPopupToast = page - .locator('.p-toast-message.p-toast-message-error') + .getByTestId('toast') + .and(page.locator('[data-toast-kind="error"]')) .filter({ hasText: 'Failed to change plan' }) await expect(blockedPopupToast).toContainText( "Couldn't open the payment page — please try again" diff --git a/browser_tests/tests/dialogs/topUpNoPaymentMethod.spec.ts b/browser_tests/tests/dialogs/topUpNoPaymentMethod.spec.ts index 5c2085bd897..7987e46c658 100644 --- a/browser_tests/tests/dialogs/topUpNoPaymentMethod.spec.ts +++ b/browser_tests/tests/dialogs/topUpNoPaymentMethod.spec.ts @@ -49,7 +49,8 @@ test.describe('Top-up without a saved payment method', () => { await expect( page - .locator('.p-toast-message.p-toast-message-error') + .getByTestId('toast') + .and(page.locator('[data-toast-kind="error"]')) .getByText(/Add one via Settings → Plan & Credits → Manage billing/) ).toBeVisible() }) diff --git a/browser_tests/tests/dialogs/topUpSdkRail.spec.ts b/browser_tests/tests/dialogs/topUpSdkRail.spec.ts index 2dbda778a9e..5e8ba82775a 100644 --- a/browser_tests/tests/dialogs/topUpSdkRail.spec.ts +++ b/browser_tests/tests/dialogs/topUpSdkRail.spec.ts @@ -207,7 +207,7 @@ test.describe('Top-up rail (FE-2475)', { tag: '@cloud' }, () => { await expect.poll(() => routes.purchaseRequests.length).toBe(1) expect(transport(routes.purchaseRequests[0])).toBe('fetch') await expect( - page.locator('.p-toast-message.p-toast-message-error') + page.getByTestId('toast').and(page.locator('[data-toast-kind="error"]')) ).toBeVisible() }) }) diff --git a/browser_tests/tests/sidebar/assets.spec.ts b/browser_tests/tests/sidebar/assets.spec.ts index 9cf71e960c1..8ed7d1ebaea 100644 --- a/browser_tests/tests/sidebar/assets.spec.ts +++ b/browser_tests/tests/sidebar/assets.spec.ts @@ -1056,7 +1056,9 @@ test.describe('Assets sidebar - delete confirmation', () => { await expect(dialog).toBeHidden() await expect(tab.assetCards).toHaveCount(initialCount - 1) - const successToast = comfyPage.page.locator('.p-toast-message-success') + const successToast = comfyPage.page + .getByTestId('toast') + .and(comfyPage.page.locator('[data-toast-kind="success"]')) await expect(successToast).toBeVisible() }) diff --git a/browser_tests/tests/sidebar/sidebarSplitterWidth.spec.ts b/browser_tests/tests/sidebar/sidebarSplitterWidth.spec.ts index 7275978c1e5..14da11aa65c 100644 --- a/browser_tests/tests/sidebar/sidebarSplitterWidth.spec.ts +++ b/browser_tests/tests/sidebar/sidebarSplitterWidth.spec.ts @@ -17,7 +17,7 @@ test.describe('Sidebar splitter width independence', () => { }) async function dismissToasts(comfyPage: ComfyPage) { - const buttons = await comfyPage.page.locator('.p-toast-close-button').all() + const buttons = await comfyPage.page.getByTestId('toast-close').all() for (const btn of buttons) { await btn.click({ timeout: 2000 }).catch(() => {}) } diff --git a/browser_tests/tests/templates.spec.ts b/browser_tests/tests/templates.spec.ts index 16e2ed88333..a935574ad49 100644 --- a/browser_tests/tests/templates.spec.ts +++ b/browser_tests/tests/templates.spec.ts @@ -281,7 +281,7 @@ test.describe('Templates', { tag: ['@slow', '@workflow'] }, () => { await expect(filterBar).toHaveScreenshot( 'template-filter-bar-select-components.png', { - mask: [comfyPage.page.locator('.p-toast')] + mask: [comfyPage.page.getByTestId('toast')] } ) } diff --git a/browser_tests/tests/toastNotifications.spec.ts b/browser_tests/tests/toastNotifications.spec.ts index 23f1483ba1b..3ed77acdc34 100644 --- a/browser_tests/tests/toastNotifications.spec.ts +++ b/browser_tests/tests/toastNotifications.spec.ts @@ -9,11 +9,9 @@ test.describe('Toast Notifications', { tag: '@ui' }, () => { nextFrame: () => Promise }) { await comfyPage.page.evaluate(() => { - window.app!.extensionManager.toast.add({ - severity: 'error', - summary: 'Error', - detail: 'Test execution error', - life: 30000 + window.app!.extensionManager.toast.error('Error', { + description: 'Test execution error', + duration: 30000 }) }) await comfyPage.nextFrame() @@ -46,7 +44,7 @@ test.describe('Toast Notifications', { tag: '@ui' }, () => { await triggerErrorToast(comfyPage) const graphToast = comfyPage.page - .locator('.graph-toast .p-toast-message') + .getByTestId('toast') .filter({ hasText: 'Test execution error' }) await expect(graphToast).toBeVisible() @@ -62,9 +60,9 @@ test.describe('Toast Notifications', { tag: '@ui' }, () => { test('Toast shows correct error severity class', async ({ comfyPage }) => { await triggerErrorToast(comfyPage) - const errorToast = comfyPage.page.locator( - '.p-toast-message.p-toast-message-error' - ) + const errorToast = comfyPage.page + .getByTestId('toast') + .and(comfyPage.page.locator('[data-toast-kind="error"]')) await expect(errorToast.first()).toBeVisible() }) @@ -73,7 +71,7 @@ test.describe('Toast Notifications', { tag: '@ui' }, () => { await expect(comfyPage.toast.visibleToasts.first()).toBeVisible() - const closeButton = comfyPage.page.locator('.p-toast-close-button').first() + const closeButton = comfyPage.page.getByTestId('toast-close').first() await closeButton.click() await expect(comfyPage.toast.visibleToasts).toHaveCount(0) @@ -93,7 +91,10 @@ test.describe('Toast Notifications', { tag: '@ui' }, () => { await triggerErrorToast(comfyPage) await expect( - comfyPage.page.locator('.p-toast-message.p-toast-message-error').first() + comfyPage.page + .getByTestId('toast') + .and(comfyPage.page.locator('[data-toast-kind="error"]')) + .first() ).toBeVisible() await expect(comfyPage.toast.toastErrors).not.toHaveCount(0) diff --git a/browser_tests/tests/versionMismatchWarnings.spec.ts b/browser_tests/tests/versionMismatchWarnings.spec.ts index 0e36431adf4..8bf11284b2d 100644 --- a/browser_tests/tests/versionMismatchWarnings.spec.ts +++ b/browser_tests/tests/versionMismatchWarnings.spec.ts @@ -64,7 +64,9 @@ comfyPageFixture.describe('Version Mismatch Warnings', { tag: '@slow' }, () => { }) => { // Expect a warning toast to be shown await expect( - comfyPage.page.getByText('Version Compatibility Warning') + comfyPage.page + .getByTestId('toast') + .getByText('Version Compatibility Warning') ).toBeVisible() }) @@ -73,7 +75,9 @@ comfyPageFixture.describe('Version Mismatch Warnings', { tag: '@slow' }, () => { async ({ comfyPage }) => { // Expect no warning toast to be shown await expect( - comfyPage.page.getByText('Version Compatibility Warning') + comfyPage.page + .getByTestId('toast') + .getByText('Version Compatibility Warning') ).toBeHidden() } ) @@ -84,7 +88,7 @@ comfyPageFixture.describe('Version Mismatch Warnings', { tag: '@slow' }, () => { test.setTimeout(30_000) // Locate the warning toast and dismiss it - const warningToast = comfyPage.page.locator('.p-toast-message').filter({ + const warningToast = comfyPage.page.getByTestId('toast').filter({ hasText: 'Version Compatibility' }) await warningToast.waitFor({ state: 'visible' }) @@ -101,7 +105,9 @@ comfyPageFixture.describe('Version Mismatch Warnings', { tag: '@slow' }, () => { // The same warning from same versions should not be shown to the user again await expect( - comfyPage.page.getByText('Version Compatibility Warning') + comfyPage.page + .getByTestId('toast') + .getByText('Version Compatibility Warning') ).toBeHidden() }) }) diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json index fface67078b..01c53e7e0ca 100644 --- a/oxlint-suppressions.json +++ b/oxlint-suppressions.json @@ -261,7 +261,7 @@ }, "src/platform/workspace/composables/useSubscriptionCheckout.ts": { "comfy/no-new-error-throw": { - "count": 6 + "count": 5 } }, "src/platform/workspace/composables/useWorkspaceBilling.ts": { diff --git a/scripts/primevue-import-allowlist.json b/scripts/primevue-import-allowlist.json index 44a42ad3a5d..315b28fd25e 100644 --- a/scripts/primevue-import-allowlist.json +++ b/scripts/primevue-import-allowlist.json @@ -12,15 +12,10 @@ "src/components/dialog/GlobalDialog.test.ts", "src/components/dialog/GlobalDialog.vue", "src/components/dialog/bodyPointerEventsRestore.test.ts", - "src/components/dialog/content/ErrorDialogContent.vue", - "src/components/dialog/content/TopUpCreditsDialogContentLegacy.test.ts", - "src/components/dialog/content/TopUpCreditsDialogContentLegacy.vue", "src/components/dialog/content/setting/SettingItem.test.ts", "src/components/dialog/content/setting/UsageLogsTable.test.ts", "src/components/dialog/content/signin/SignInForm.test.ts", "src/components/dialog/content/signin/SignInForm.vue", - "src/components/dialog/content/subscription/CancelSubscriptionDialogContent.test.ts", - "src/components/dialog/content/subscription/CancelSubscriptionDialogContent.vue", "src/components/graph/GraphCanvasMenu.vue", "src/components/graph/SelectionToolbox.test.ts", "src/components/graph/selectionToolbox/BypassButton.test.ts", @@ -29,8 +24,6 @@ "src/components/graph/selectionToolbox/InfoButton.test.ts", "src/components/graph/widgets/TextPreviewWidget.test.ts", "src/components/graph/widgets/TextPreviewWidget.vue", - "src/components/helpcenter/HelpCenterMenuContent.test.ts", - "src/components/helpcenter/HelpCenterMenuContent.vue", "src/components/node/NodePreview.test.ts", "src/components/rightSidePanel/errors/ErrorGroupList.test.ts", "src/components/rightSidePanel/errors/ErrorNodeCard.test.ts", @@ -41,21 +34,10 @@ "src/components/searchbox/NodeSearchBoxPopover.vue", "src/components/sidebar/SideToolbar.test.ts", "src/components/sidebar/SidebarIcon.test.ts", - "src/components/sidebar/tabs/AssetsSidebarTab.test.ts", - "src/components/sidebar/tabs/AssetsSidebarTab.vue", - "src/components/toast/GlobalToast.test.ts", - "src/components/toast/GlobalToast.vue", - "src/components/toast/RerouteMigrationToast.vue", "src/components/topbar/CurrentUserButton.vue", "src/components/topbar/CurrentUserPopoverLegacy.vue", "src/components/topbar/TopbarBadge.test.ts", - "src/composables/useCopyToClipboard.test.ts", - "src/composables/useCopyToClipboard.ts", - "src/composables/useReconnectingNotification.test.ts", - "src/composables/useReconnectingNotification.ts", "src/main.ts", - "src/platform/assets/composables/useMediaAssetActions.test.ts", - "src/platform/assets/composables/useMediaAssetActions.ts", "src/platform/cloud/onboarding/CloudSubscriptionRedirectView.vue", "src/platform/cloud/onboarding/skeletons/CloudLoginViewSkeleton.vue", "src/platform/cloud/onboarding/skeletons/CloudSurveyViewSkeleton.vue", @@ -63,50 +45,10 @@ "src/platform/missingModel/components/MissingModelCard.test.ts", "src/platform/nodeReplacement/components/SwapNodeGroupRow.test.ts", "src/platform/nodeReplacement/components/SwapNodesCard.test.ts", - "src/platform/updates/common/toastStore.ts", "src/platform/updates/components/WhatsNewPopup.test.ts", "src/platform/workflow/persistence/composables/useWorkflowPersistenceV2.test.ts", - "src/platform/workflow/persistence/composables/useWorkflowPersistenceV2.ts", - "src/platform/workflow/sharing/components/ShareWorkflowDialogContent.test.ts", - "src/platform/workflow/sharing/components/ShareWorkflowDialogContent.vue", - "src/platform/workflow/sharing/components/profile/ComfyHubCreateProfileForm.vue", - "src/platform/workflow/sharing/components/publish/ComfyHubPublishDialog.test.ts", - "src/platform/workflow/sharing/components/publish/ComfyHubPublishDialog.vue", - "src/platform/workflow/sharing/composables/useSharedWorkflowUrlLoader.test.ts", - "src/platform/workflow/sharing/composables/useSharedWorkflowUrlLoader.ts", - "src/platform/workflow/templates/composables/useTemplateUrlLoader.test.ts", - "src/platform/workflow/templates/composables/useTemplateUrlLoader.ts", "src/platform/workspace/components/CurrentUserPopoverWorkspace.test.ts", "src/platform/workspace/components/CurrentUserPopoverWorkspace.vue", - "src/platform/workspace/components/InviteMembersForm.test.ts", - "src/platform/workspace/components/InviteMembersForm.vue", - "src/platform/workspace/components/SubscriptionPanelContentWorkspace.test.ts", - "src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts", - "src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue", - "src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.test.ts", - "src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.vue", - "src/platform/workspace/components/dialogs/CreateWorkspaceDialogContent.vue", - "src/platform/workspace/components/dialogs/DeleteWorkspaceDialogContent.vue", - "src/platform/workspace/components/dialogs/DowngradeRemoveMembersDialogContent.test.ts", - "src/platform/workspace/components/dialogs/DowngradeRemoveMembersDialogContent.vue", - "src/platform/workspace/components/dialogs/EditWorkspaceDialogContent.vue", - "src/platform/workspace/components/dialogs/InviteMemberDialogContent.test.ts", - "src/platform/workspace/components/dialogs/LeaveWorkspaceDialogContent.vue", - "src/platform/workspace/components/dialogs/RemoveMemberDialogContent.vue", - "src/platform/workspace/components/dialogs/RevokeInviteDialogContent.vue", - "src/platform/workspace/components/dialogs/TeamWorkspacesDialogContent.test.ts", - "src/platform/workspace/components/dialogs/TeamWorkspacesDialogContent.vue", - "src/platform/workspace/components/toasts/InviteAcceptedToast.vue", - "src/platform/workspace/composables/useInviteUrlLoader.test.ts", - "src/platform/workspace/composables/useInviteUrlLoader.ts", - "src/platform/workspace/composables/useMembersPanel.test.ts", - "src/platform/workspace/composables/useMembersPanel.ts", - "src/platform/workspace/composables/useResubscribe.test.ts", - "src/platform/workspace/composables/useResubscribe.ts", - "src/platform/workspace/composables/useSubscriptionCheckout.test.ts", - "src/platform/workspace/composables/useSubscriptionCheckout.ts", - "src/platform/workspace/stores/billingOperationStore.ts", - "src/renderer/extensions/linearMode/DropZone.test.ts", "src/renderer/extensions/vueNodes/VideoPreview.vue", "src/renderer/extensions/vueNodes/components/WidgetGrid.vue", "src/renderer/extensions/vueNodes/composables/processedWidgetRenderModel.ts", @@ -117,11 +59,8 @@ "src/renderer/extensions/vueNodes/widgets/components/WidgetRecordAudio.vue", "src/renderer/extensions/vueNodes/widgets/components/WidgetSelect.asset-mode.test.ts", "src/renderer/extensions/vueNodes/widgets/components/WidgetSelectDropdown.test.ts", - "src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.test.ts", - "src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.vue", "src/renderer/extensions/vueNodes/widgets/components/form/FormSelectButton.test.ts", "src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.test.ts", - "src/services/dialogService.errorCatalog.test.ts", "src/stores/dialogStore.ts", "src/workbench/extensions/manager/components/manager/PackVersionBadge.test.ts", "src/workbench/extensions/manager/components/manager/PackVersionSelectorPopover.test.ts", diff --git a/src/App.vue b/src/App.vue index dbb9d9220f9..7b49cc5a0b3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -88,12 +88,6 @@ onMounted(() => { // core dependencies). These are plugin bugs, not ComfyUI core failures, but // the generic error message alarms users and offers no actionable guidance. // The reporter above still logs the details for developers to debug. - // useToastStore().add({ - // severity: 'error', - // summary: t('g.preloadErrorTitle'), - // detail: t('g.preloadError'), - // life: 10000 - // }) }) // Capture resource load failures (CSS, scripts) in non-localhost distributions diff --git a/src/assets/css/style.css b/src/assets/css/style.css index fc662b09abb..bbcfd6757fb 100644 --- a/src/assets/css/style.css +++ b/src/assets/css/style.css @@ -55,19 +55,6 @@ } } -/* Toasts teleport to . Reka's modal mode sets pointer-events: none on - the body, which left toast close buttons painted above dialogs but - unclickable — clicks fell through to whatever sat beneath (including the - payment dialog's X, closing the checkout mid-payment). Keep toasts - interactive regardless of modal state. */ -.p-toast { - pointer-events: none; -} - -.p-toast-message { - pointer-events: auto; -} - /* Use 0.001ms instead of 0s so transitionend/animationend events still fire and JS listeners aren't broken. */ .disable-animations *, diff --git a/src/base/common/downloadUtil.test.ts b/src/base/common/downloadUtil.test.ts index 5ac15d9ea06..931b4f93d03 100644 --- a/src/base/common/downloadUtil.test.ts +++ b/src/base/common/downloadUtil.test.ts @@ -1,3 +1,4 @@ +import { useToast } from '@/components/ui/toast' import { fromAny, fromPartial } from '@total-typescript/shoehorn' import type { MockInstance } from 'vitest' import { beforeEach, describe, expect, it, vi } from 'vitest' @@ -24,6 +25,10 @@ vi.mock( vi.mock(import('@/i18n')) +beforeEach(() => { + vi.mocked(useToast().warning).mockImplementation(vi.fn()) +}) + let createObjectURLSpy: MockInstance let revokeObjectURLSpy: MockInstance diff --git a/src/base/common/downloadUtil.ts b/src/base/common/downloadUtil.ts index e4a717f811d..7caeff9a37d 100644 --- a/src/base/common/downloadUtil.ts +++ b/src/base/common/downloadUtil.ts @@ -4,8 +4,7 @@ import { t } from '@/i18n' // oxlint-disable-next-line comfy/no-restricted-paths import { isCloud } from '@/platform/distribution/types' -// oxlint-disable-next-line comfy/no-restricted-paths -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' // Constants const DEFAULT_DOWNLOAD_FILENAME = 'download.png' @@ -220,10 +219,10 @@ export async function openFileInNewTab(url: string): Promise { } catch (error) { tab?.close() console.error('Failed to open image:', error) - useToastStore().addAlert( - t('toastMessages.errorOpenImage', { + useToast().warning('Alert', { + description: t('toastMessages.errorOpenImage', { error: error instanceof Error ? error.message : String(error) }) - ) + }) } } diff --git a/src/components/common/BackgroundImageUpload.vue b/src/components/common/BackgroundImageUpload.vue index 168e4020fa7..e84ccc8552c 100644 --- a/src/components/common/BackgroundImageUpload.vue +++ b/src/components/common/BackgroundImageUpload.vue @@ -41,7 +41,7 @@ import { ref } from 'vue' import Button from '@/components/ui/button/Button.vue' import Input from '@/components/ui/input/Input.vue' import { appendCloudResParam } from '@/platform/distribution/cloudPreviewUtil' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' const modelValue = defineModel() @@ -64,9 +64,9 @@ const uploadFile = async (file: File): Promise => { }) if (resp.status !== 200) { - useToastStore().addAlert( - `Upload failed: ${resp.status} - ${resp.statusText}` - ) + useToast().warning('Alert', { + description: `Upload failed: ${resp.status} - ${resp.statusText}` + }) return null } @@ -93,7 +93,9 @@ const handleFileUpload = async (event: Event) => { modelValue.value = `/api/view?${params.toString()}` } } catch (error) { - useToastStore().addAlert(`Upload error: ${String(error)}`) + useToast().warning('Alert', { + description: `Upload error: ${String(error)}` + }) } finally { isUploading.value = false } diff --git a/src/components/dialog/GlobalDialog.test.ts b/src/components/dialog/GlobalDialog.test.ts index a046a8325d6..5476b825667 100644 --- a/src/components/dialog/GlobalDialog.test.ts +++ b/src/components/dialog/GlobalDialog.test.ts @@ -651,7 +651,7 @@ describe('shouldPreventRekaDismiss', () => { expect(event.defaultPrevented).toBe(true) }) - it.for(['p-dialog', 'p-select-overlay', 'p-toast-message'])( + it.for(['p-dialog', 'p-select-overlay'])( 'focus-outside on a sibling %s portal does not dismiss the parent', (className) => { const overlay = document.createElement('div') @@ -668,6 +668,20 @@ describe('shouldPreventRekaDismiss', () => { } ) + it('focus-outside on a toast does not dismiss the parent', () => { + const toast = document.createElement('div') + toast.dataset.testid = 'toast' + const closeButton = document.createElement('button') + toast.appendChild(closeButton) + document.body.appendChild(toast) + + const event = makeEvent(closeButton) + onRekaFocusOutside(event) + + expect(event.defaultPrevented).toBe(true) + toast.remove() + }) + it('focus-outside still dismisses when focus moves to a non-portal element', () => { const event = makeEvent(document.body) onRekaFocusOutside(event) diff --git a/src/components/dialog/content/ErrorDialogContent.vue b/src/components/dialog/content/ErrorDialogContent.vue index 2b156f375fa..865325ed727 100644 --- a/src/components/dialog/content/ErrorDialogContent.vue +++ b/src/components/dialog/content/ErrorDialogContent.vue @@ -62,7 +62,7 @@ diff --git a/src/components/toast/RerouteMigrationToast.vue b/src/components/toast/RerouteMigrationToast.vue index e807994a3f0..b830662fd38 100644 --- a/src/components/toast/RerouteMigrationToast.vue +++ b/src/components/toast/RerouteMigrationToast.vue @@ -1,42 +1,30 @@ diff --git a/src/components/ui/toast/ToastClose.vue b/src/components/ui/toast/ToastClose.vue new file mode 100644 index 00000000000..58bb49d6960 --- /dev/null +++ b/src/components/ui/toast/ToastClose.vue @@ -0,0 +1,29 @@ + + + diff --git a/src/components/ui/toast/ToastDescription.vue b/src/components/ui/toast/ToastDescription.vue new file mode 100644 index 00000000000..8a27250a730 --- /dev/null +++ b/src/components/ui/toast/ToastDescription.vue @@ -0,0 +1,21 @@ + + + diff --git a/src/components/ui/toast/ToastProvider.vue b/src/components/ui/toast/ToastProvider.vue new file mode 100644 index 00000000000..487345237cc --- /dev/null +++ b/src/components/ui/toast/ToastProvider.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/components/ui/toast/ToastRoot.vue b/src/components/ui/toast/ToastRoot.vue new file mode 100644 index 00000000000..6bce48cf8df --- /dev/null +++ b/src/components/ui/toast/ToastRoot.vue @@ -0,0 +1,38 @@ + + + diff --git a/src/components/ui/toast/ToastTitle.vue b/src/components/ui/toast/ToastTitle.vue new file mode 100644 index 00000000000..55030eb85d7 --- /dev/null +++ b/src/components/ui/toast/ToastTitle.vue @@ -0,0 +1,21 @@ + + + diff --git a/src/components/ui/toast/ToastViewport.vue b/src/components/ui/toast/ToastViewport.vue new file mode 100644 index 00000000000..5ef1183b8f2 --- /dev/null +++ b/src/components/ui/toast/ToastViewport.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/components/ui/toast/Toaster.test.ts b/src/components/ui/toast/Toaster.test.ts new file mode 100644 index 00000000000..8de0c53cad0 --- /dev/null +++ b/src/components/ui/toast/Toaster.test.ts @@ -0,0 +1,132 @@ +import { render, screen } from '@testing-library/vue' +import userEvent from '@testing-library/user-event' +import { ZIndex } from '@primeuix/utils/zindex' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { nextTick } from 'vue' +import { createI18n } from 'vue-i18n' + +import Toaster from './Toaster.vue' +import { useToast } from './toastStore' + +const i18n = createI18n({ + legacy: false, + locale: 'en', + messages: { en: { g: { close: 'Close' } } } +}) + +describe('Toaster', () => { + const dialogs: HTMLElement[] = [] + + afterEach(() => { + dialogs.splice(0).forEach((dialog) => ZIndex.clear(dialog)) + }) + + function renderToaster() { + return render(Toaster, { global: { plugins: [i18n] } }) + } + + it('stacks notifications and assigns severity roles', async () => { + renderToaster() + const toast = useToast() + + toast.success('Saved') + toast.error('Could not save') + await nextTick() + + const notifications = screen.getAllByTestId('toast') + expect(notifications).toHaveLength(2) + expect(notifications[0]).toHaveAttribute('role', 'status') + expect(notifications[0]).toHaveAttribute('aria-live', 'polite') + expect(notifications[1]).toHaveAttribute('role', 'alert') + expect(notifications[1]).toHaveAttribute('aria-live', 'assertive') + }) + + it('renders standard and custom messages only once after announcement', async () => { + vi.useFakeTimers() + renderToaster() + const toast = useToast() + + toast.error('Save failed', { description: 'Try another location' }) + toast.custom({ template: '
Custom notification
' }) + await nextTick() + await vi.advanceTimersByTimeAsync(1000) + + expect(document.body.textContent.match(/Save failed/g)).toHaveLength(1) + expect( + document.body.textContent.match(/Try another location/g) + ).toHaveLength(1) + expect( + document.body.textContent.match(/Custom notification/g) + ).toHaveLength(1) + }) + + it('lifts a new notification above an open dialog', async () => { + renderToaster() + const dialog = document.createElement('div') + dialogs.push(dialog) + ZIndex.set('modal', dialog, 1700) + + useToast().info('Ready') + await nextTick() + + expect( + Number(screen.getByTestId('toast-viewport').style.zIndex) + ).toBeGreaterThan(Number(dialog.style.zIndex)) + }) + + it('automatically dismisses a timed notification', async () => { + vi.useFakeTimers() + renderToaster() + + useToast().info('Uploaded', { duration: 1000 }) + await nextTick() + expect(screen.getByText('Uploaded')).toBeInTheDocument() + + await vi.advanceTimersByTimeAsync(1000) + await nextTick() + + expect(screen.queryByText('Uploaded')).not.toBeInTheDocument() + }) + + it('preserves notifications when Escape is pressed', async () => { + const user = userEvent.setup() + renderToaster() + + const toast = useToast() + toast.info('First') + toast.warning('Second') + await nextTick() + + await user.keyboard('{Escape}') + + expect(screen.getByText('First')).toBeInTheDocument() + expect(screen.getByText('Second')).toBeInTheDocument() + }) + + it('does not prevent the default Escape behavior', async () => { + renderToaster() + + useToast().info('Ready') + await nextTick() + + const event = new KeyboardEvent('keydown', { + key: 'Escape', + bubbles: true, + cancelable: true + }) + window.dispatchEvent(event) + + expect(event.defaultPrevented).toBe(false) + }) + + it('dismisses a notification from its close button', async () => { + const user = userEvent.setup() + renderToaster() + + useToast().warning('Check settings') + await nextTick() + await user.click(screen.getByRole('button', { name: 'Close' })) + + expect(screen.queryByText('Check settings')).not.toBeInTheDocument() + }) +}) diff --git a/src/components/ui/toast/Toaster.vue b/src/components/ui/toast/Toaster.vue new file mode 100644 index 00000000000..54d79fcccd0 --- /dev/null +++ b/src/components/ui/toast/Toaster.vue @@ -0,0 +1,88 @@ + + + diff --git a/src/components/ui/toast/index.ts b/src/components/ui/toast/index.ts new file mode 100644 index 00000000000..a85102b58e3 --- /dev/null +++ b/src/components/ui/toast/index.ts @@ -0,0 +1,3 @@ +export { default as Toaster } from './Toaster.vue' +export { useToast } from './toastStore' +export type { ToastId, ToastOptions } from './toastStore' diff --git a/src/components/ui/toast/toastStore.test.ts b/src/components/ui/toast/toastStore.test.ts new file mode 100644 index 00000000000..91b6566dfc5 --- /dev/null +++ b/src/components/ui/toast/toastStore.test.ts @@ -0,0 +1,74 @@ +import { describe, expect, it } from 'vitest' +import { nextTick } from 'vue' + +import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' + +import { useToast } from './toastStore' + +describe('useToast', () => { + it('creates persistent notifications by default and dismisses by id', () => { + const toast = useToast() + const id = toast.error('Save failed', { description: 'Disk is full' }) + + expect(toast.toasts).toEqual([ + expect.objectContaining({ + id, + kind: 'error', + title: 'Save failed', + description: 'Disk is full', + duration: Number.POSITIVE_INFINITY, + role: 'alert' + }) + ]) + + toast.dismiss(id) + expect(toast.toasts).toEqual([]) + }) + + it('queues notifications during node selection and replays them in order', async () => { + const selection = useCanvasStore() + const toast = useToast() + selection.isPickingNodes = true + + toast.info('First') + toast.error('Second') + expect(toast.toasts).toEqual([]) + + selection.isPickingNodes = false + await nextTick() + + expect(toast.toasts).toEqual([ + expect.objectContaining({ title: 'First' }), + expect.objectContaining({ title: 'Second' }) + ]) + }) + + it('does not replay queued notifications after dismissing all', async () => { + const selection = useCanvasStore() + const toast = useToast() + selection.isPickingNodes = true + toast.info('Old') + + toast.dismissAll() + selection.isPickingNodes = false + await nextTick() + + expect(toast.toasts).toEqual([]) + }) + + it('does not replay dismissed progress but replays other queued warnings', async () => { + const selection = useCanvasStore() + const toast = useToast() + selection.isPickingNodes = true + const progressId = toast.loading('Preparing samples') + toast.warning('Missing sample') + + toast.dismiss(progressId) + selection.isPickingNodes = false + await nextTick() + + expect(toast.toasts).toEqual([ + expect.objectContaining({ kind: 'warning', title: 'Missing sample' }) + ]) + }) +}) diff --git a/src/components/ui/toast/toastStore.ts b/src/components/ui/toast/toastStore.ts new file mode 100644 index 00000000000..c3914c73a60 --- /dev/null +++ b/src/components/ui/toast/toastStore.ts @@ -0,0 +1,140 @@ +import { defineStore } from 'pinia' +import { markRaw, ref, watch } from 'vue' +import type { Component } from 'vue' + +import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' + +export type ToastId = number +type ToastRole = 'alert' | 'status' +type ToastKind = 'success' | 'error' | 'info' | 'warning' | 'loading' + +export interface ToastOptions { + description?: string + duration?: number + closable?: boolean +} + +interface CustomToastOptions { + duration?: number + closable?: boolean + role?: ToastRole +} + +interface ToastBase { + id: ToastId + duration: number + closable: boolean + role: ToastRole +} + +interface StandardToast extends ToastBase { + kind: ToastKind + title: string + description?: string +} + +interface CustomToast extends ToastBase { + kind: 'custom' + component: Component + props?: Record +} + +type Toast = StandardToast | CustomToast + +const PERSISTENT = Number.POSITIVE_INFINITY + +export const useToast = defineStore('toast', () => { + const agentNodeSelectionStore = useCanvasStore() + const toasts = ref([]) + const queuedToasts = ref([]) + let nextId = 1 + + function enqueue(toast: Toast) { + const target = agentNodeSelectionStore.isPickingNodes ? queuedToasts : toasts + target.value = [...target.value, toast] + } + + watch( + () => agentNodeSelectionStore.isPickingNodes, + (active) => { + if (active || queuedToasts.value.length === 0) return + toasts.value = [...toasts.value, ...queuedToasts.value] + queuedToasts.value = [] + }, + { flush: 'sync' } + ) + + function add(kind: ToastKind, title: string, options: ToastOptions = {}) { + const id = nextId++ + enqueue({ + id, + kind, + title, + description: options.description, + duration: options.duration ?? PERSISTENT, + closable: options.closable ?? true, + role: kind === 'error' || kind === 'warning' ? 'alert' : 'status' + }) + return id + } + + function success(title: string, options?: ToastOptions) { + return add('success', title, options) + } + + function error(title: string, options?: ToastOptions) { + return add('error', title, options) + } + + function info(title: string, options?: ToastOptions) { + return add('info', title, options) + } + + function warning(title: string, options?: ToastOptions) { + return add('warning', title, options) + } + + function loading(title: string, options?: ToastOptions) { + return add('loading', title, options) + } + + function custom( + component: Component, + props?: Record, + options: CustomToastOptions = {} + ) { + const id = nextId++ + enqueue({ + id, + kind: 'custom', + component: markRaw(component), + props, + duration: options.duration ?? PERSISTENT, + closable: options.closable ?? true, + role: options.role ?? 'status' + }) + return id + } + + function dismiss(id: ToastId) { + toasts.value = toasts.value.filter((toast) => toast.id !== id) + queuedToasts.value = queuedToasts.value.filter((toast) => toast.id !== id) + } + + function dismissAll() { + toasts.value = [] + queuedToasts.value = [] + } + + return { + toasts, + success, + error, + info, + warning, + loading, + custom, + dismiss, + dismissAll + } +}) diff --git a/src/composables/auth/useAuthActions.test.ts b/src/composables/auth/useAuthActions.test.ts index abf2b2c1875..df609738476 100644 --- a/src/composables/auth/useAuthActions.test.ts +++ b/src/composables/auth/useAuthActions.test.ts @@ -1,6 +1,6 @@ import { useDialogService } from '@/services/dialogService' +import { useToast } from '@/components/ui/toast' import { SsoRequiredAuthError, useAuthStore } from '@/stores/authStore' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { FirebaseError } from 'firebase/app' import { AuthErrorCodes } from 'firebase/auth' @@ -27,7 +27,7 @@ type ModifiedWorkflow = Pick let mockAuthStore: ReturnType -let mockToastStore: ReturnType +let mockToastStore: ReturnType let mockWorkflowStore: ReturnType @@ -119,7 +119,7 @@ beforeEach(() => { billingContext.isFreeTier = computed(() => true) stubFirebaseAuthHarness() mockAuthStore = useAuthStore() - mockToastStore = useToastStore() + mockToastStore = useToast() mockWorkflowStore = useWorkflowStore() vi.mocked(mockAuthStore.initiateCreditPurchase).mockResolvedValue({ checkout_url: 'https://checkout.stripe.test' @@ -372,7 +372,7 @@ describe('useAuthActions.logout', () => { expect(mockAuthStore.logout).not.toHaveBeenCalled() expect(mockClearAllWorkspaceStorage).not.toHaveBeenCalled() - expect(mockToastStore.add).not.toHaveBeenCalled() + expect(mockToastStore.success).not.toHaveBeenCalled() }) it('passes denyLabel "Sign out anyway" to the dialog', async () => { @@ -413,10 +413,8 @@ describe('useAuthActions auth flow error telemetry', () => { error_code: 'auth/user-not-found', auth_action: 'email_sign_in' }) - expect(mockToastStore.add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'g.error', - detail: 'auth.errors.auth/invalid-credential' + expect(mockToastStore.error).toHaveBeenCalledWith('g.error', { + description: 'auth.errors.auth/invalid-credential' }) }) @@ -511,8 +509,17 @@ describe('useAuthActions.reportError', () => { reportError(new FirebaseError(code, 'raw firebase')) - expect(mockToastStore.add).toHaveBeenCalledWith( - expect.objectContaining({ detail: `auth.errors.${code}` }) + const warningCodes: readonly string[] = [ + AuthErrorCodes.POPUP_CLOSED_BY_USER, + AuthErrorCodes.EXPIRED_POPUP_REQUEST, + AuthErrorCodes.POPUP_BLOCKED + ] + const notify = warningCodes.includes(code) + ? mockToastStore.warning + : mockToastStore.error + expect(notify).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: `auth.errors.${code}` }) ) expect(mockToastErrorHandler).not.toHaveBeenCalled() } @@ -525,9 +532,10 @@ describe('useAuthActions.reportError', () => { reportError(new FirebaseError(code, 'raw firebase')) - expect(mockToastStore.add).toHaveBeenCalledWith( + expect(mockToastStore.error).toHaveBeenCalledWith( + 'g.error', expect.objectContaining({ - detail: 'auth.errors.auth/invalid-credential' + description: 'auth.errors.auth/invalid-credential' }) ) } @@ -560,10 +568,8 @@ describe('useAuthActions.reportError', () => { ) ) - expect(mockToastStore.add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'g.error', - detail: 'auth.errors.signupBlocked' + expect(mockToastStore.error).toHaveBeenCalledWith('g.error', { + description: 'auth.errors.signupBlocked' }) expect(mockToastErrorHandler).not.toHaveBeenCalled() }) @@ -575,10 +581,8 @@ describe('useAuthActions.reportError', () => { new FirebaseError('auth/internal-error', 'rejected: SIGNUP_BLOCKED') ) - expect(mockToastStore.add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'g.error', - detail: 'auth.errors.signupBlocked' + expect(mockToastStore.error).toHaveBeenCalledWith('g.error', { + description: 'auth.errors.signupBlocked' }) }) @@ -587,10 +591,8 @@ describe('useAuthActions.reportError', () => { reportError(new FirebaseError('auth/some-new-code', 'raw firebase')) - expect(mockToastStore.add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'g.error', - detail: 'auth.errors.generic' + expect(mockToastStore.error).toHaveBeenCalledWith('g.error', { + description: 'auth.errors.generic' }) expect(mockToastErrorHandler).not.toHaveBeenCalled() }) @@ -602,10 +604,8 @@ describe('useAuthActions.reportError', () => { new FirebaseError('app/no-app', 'Firebase: Error (app/no-app).') ) - expect(mockToastStore.add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'g.error', - detail: 'auth.errors.generic' + expect(mockToastStore.error).toHaveBeenCalledWith('g.error', { + description: 'auth.errors.generic' }) expect( mockToastErrorHandler, @@ -620,7 +620,7 @@ describe('useAuthActions.reportError', () => { reportError(networkError) expect(mockToastErrorHandler).toHaveBeenCalledWith(networkError) - expect(mockToastStore.add).not.toHaveBeenCalled() + expect(mockToastStore.toasts).toHaveLength(0) }) it.for(popupPermissionCodes)( @@ -630,10 +630,8 @@ describe('useAuthActions.reportError', () => { reportError(new FirebaseError(code, 'raw firebase')) - expect(mockToastStore.add).toHaveBeenCalledWith({ - severity: 'warn', - summary: 'g.warning', - detail: `auth.errors.${code}` + expect(mockToastStore.warning).toHaveBeenCalledWith('g.warning', { + description: `auth.errors.${code}` }) expect(mockToastErrorHandler).not.toHaveBeenCalled() } @@ -646,10 +644,8 @@ describe('useAuthActions.reportError', () => { new FirebaseError('auth/account-exists-with-different-credential', 'raw') ) - expect(mockToastStore.add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'g.error', - detail: 'auth.errors.auth/account-exists-with-different-credential' + expect(mockToastStore.error).toHaveBeenCalledWith('g.error', { + description: 'auth.errors.auth/account-exists-with-different-credential' }) expect(accessError.value).toBe(false) }) @@ -662,10 +658,8 @@ describe('useAuthActions.reportError', () => { reportError(new FirebaseError(code, 'raw firebase')) expect(accessError.value).toBe(true) - expect(mockToastStore.add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'g.error', - detail: `toastMessages.unauthorizedDomain:${window.location.hostname}:support@comfy.org` + expect(mockToastStore.error).toHaveBeenCalledWith('g.error', { + description: `toastMessages.unauthorizedDomain:${window.location.hostname}:support@comfy.org` }) } ) diff --git a/src/composables/auth/useAuthActions.ts b/src/composables/auth/useAuthActions.ts index b46a1d20f72..ddee07f4ebd 100644 --- a/src/composables/auth/useAuthActions.ts +++ b/src/composables/auth/useAuthActions.ts @@ -20,7 +20,7 @@ import { isCloud } from '@/platform/distribution/types' import { useTelemetry } from '@/platform/telemetry' import type { AuthFlowAction } from '@/platform/telemetry/types' import { PaymentPopupBlockedError } from '@/platform/telemetry/utils/billingFailureCategory' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { clearAllWorkspaceStorage, prepareWorkflowLogoutTransition @@ -59,7 +59,7 @@ export const localizedAuthErrorCopy = (): AuthErrorCopy => ({ */ export const useAuthActions = () => { const authStore = useAuthStore() - const toastStore = useToastStore() + const toastStore = useToast() const { wrapWithErrorHandlingAsync, toastErrorHandler } = useErrorHandling() const accessError = ref(false) @@ -91,29 +91,24 @@ export const useAuthActions = () => { // Ref: https://firebase.google.com/docs/auth/admin/errors const severity = severityForAuthError(classification) const summary = t(severity === 'warn' ? 'g.warning' : 'g.error') + const notify = severity === 'warn' ? toastStore.warning : toastStore.error if (classification.kind === 'unauthorized-domain') { accessError.value = true - toastStore.add({ - severity, - summary, - detail: t('toastMessages.unauthorizedDomain', { + notify(summary, { + description: t('toastMessages.unauthorizedDomain', { domain: window.location.hostname, email: 'support@comfy.org' }) }) } else if (classification.kind !== 'unknown') { - toastStore.add({ - severity, - summary, - detail: authErrorMessage(classification, localizedAuthErrorCopy()) + notify(summary, { + description: authErrorMessage(classification, localizedAuthErrorCopy()) }) } else if (error instanceof FirebaseError) { // classifyAuthError only knows auth/ codes; an app/ or installations/ // FirebaseError still gets the localized copy, never the raw SDK text. - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: st(`auth.errors.${error.code}`, t('auth.errors.generic')) + toastStore.error(t('g.error'), { + description: st(`auth.errors.${error.code}`, t('auth.errors.generic')) }) } else { toastErrorHandler(error) @@ -162,11 +157,9 @@ export const useAuthActions = () => { clearAllWorkspaceStorage() } - toastStore.add({ - severity: 'success', - summary: t('auth.signOut.success'), - detail: t('auth.signOut.successDetail'), - life: 5000 + toastStore.success(t('auth.signOut.success'), { + description: t('auth.signOut.successDetail'), + duration: 5000 }) if (isCloud) { @@ -184,11 +177,9 @@ export const useAuthActions = () => { const sendPasswordReset = wrapWithErrorHandlingAsync( async (email: string) => { await authStore.sendPasswordReset(email) - toastStore.add({ - severity: 'success', - summary: t('auth.login.passwordResetSent'), - detail: t('auth.login.passwordResetSentDetail'), - life: 5000 + toastStore.success(t('auth.login.passwordResetSent'), { + description: t('auth.login.passwordResetSentDetail'), + duration: 5000 }) return true }, @@ -340,11 +331,9 @@ export const useAuthActions = () => { const updatePassword = wrapWithErrorHandlingAsync( async (newPassword: string) => { await authStore.updatePassword(newPassword) - toastStore.add({ - severity: 'success', - summary: t('auth.passwordUpdate.success'), - detail: t('auth.passwordUpdate.successDetail'), - life: 5000 + toastStore.success(t('auth.passwordUpdate.success'), { + description: t('auth.passwordUpdate.successDetail'), + duration: 5000 }) }, reportError, diff --git a/src/composables/graph/useSelectionOperations.ts b/src/composables/graph/useSelectionOperations.ts index 7dc93a7009d..69b8131f4a9 100644 --- a/src/composables/graph/useSelectionOperations.ts +++ b/src/composables/graph/useSelectionOperations.ts @@ -1,7 +1,7 @@ // import { useSelectedLiteGraphItems } from '@/composables/canvas/useSelectedLiteGraphItems' // Unused for now import { t } from '@/i18n' import { LGraphNode } from '@/lib/litegraph/src/litegraph' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { useCanvasStore, @@ -17,7 +17,7 @@ import { isSelectOnly } from '@/utils/litegraphUtil' export function useSelectionOperations() { // const { getSelectedNodes } = useSelectedLiteGraphItems() // Unused for now const canvasStore = useCanvasStore() - const toastStore = useToastStore() + const toastStore = useToast() const dialogService = useDialogService() const titleEditorStore = useTitleEditorStore() const workflowStore = useWorkflowStore() @@ -25,21 +25,17 @@ export function useSelectionOperations() { const copySelection = () => { const canvas = app.canvas if (canvas.selectedItems.size === 0) { - toastStore.add({ - severity: 'warn', - summary: t('g.nothingToCopy'), - detail: t('g.selectItemsToCopy'), - life: 3000 + toastStore.warning(t('g.nothingToCopy'), { + description: t('g.selectItemsToCopy'), + duration: 3000 }) return } canvas.copyToClipboard() - toastStore.add({ - severity: 'success', - summary: t('g.copied'), - detail: t('g.itemsCopiedToClipboard'), - life: 2000 + toastStore.success(t('g.copied'), { + description: t('g.itemsCopiedToClipboard'), + duration: 2000 }) } @@ -54,11 +50,9 @@ export function useSelectionOperations() { const duplicateSelection = () => { const canvas = app.canvas if (canvas.selectedItems.size === 0) { - toastStore.add({ - severity: 'warn', - summary: t('g.nothingToDuplicate'), - detail: t('g.selectItemsToDuplicate'), - life: 3000 + toastStore.warning(t('g.nothingToDuplicate'), { + description: t('g.selectItemsToDuplicate'), + duration: 3000 }) return } @@ -82,11 +76,9 @@ export function useSelectionOperations() { // mode ends. if (isSelectOnly(canvas)) return if (canvas.selectedItems.size === 0) { - toastStore.add({ - severity: 'warn', - summary: t('g.nothingToDelete'), - detail: t('g.selectItemsToDelete'), - life: 3000 + toastStore.warning(t('g.nothingToDelete'), { + description: t('g.selectItemsToDelete'), + duration: 3000 }) return } @@ -153,11 +145,9 @@ export function useSelectionOperations() { return } - toastStore.add({ - severity: 'warn', - summary: t('g.nothingToRename'), - detail: t('g.selectItemsToRename'), - life: 3000 + toastStore.warning(t('g.nothingToRename'), { + description: t('g.selectItemsToRename'), + duration: 3000 }) } diff --git a/src/composables/graph/useSubgraphOperations.test.ts b/src/composables/graph/useSubgraphOperations.test.ts index 4c719ab4193..244559c3f40 100644 --- a/src/composables/graph/useSubgraphOperations.test.ts +++ b/src/composables/graph/useSubgraphOperations.test.ts @@ -1,9 +1,9 @@ import { fromPartial } from '@total-typescript/shoehorn' import { beforeEach, describe, expect, it, vi } from 'vitest' +import { useToast } from '@/components/ui/toast' import type { LGraph, LGraphCanvas } from '@/lib/litegraph/src/litegraph' import { LGraphNode, SubgraphNode } from '@/lib/litegraph/src/litegraph' -import { useToastStore } from '@/platform/updates/common/toastStore' import type { LoadedComfyWorkflow } from '@/platform/workflow/management/stores/workflowStore' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' @@ -65,13 +65,9 @@ describe('useSubgraphOperations', () => { }) expect(revokeSubgraphPreviews).not.toHaveBeenCalled() expect(captureCanvasState).not.toHaveBeenCalled() - expect(useToastStore().messagesToAdd).toEqual([ - { - severity: 'error', - summary: 'Error', - detail: 'Unable to unpack the selected subgraph.' - } - ]) + expect(useToast().error).toHaveBeenCalledWith('Error', { + description: 'Unable to unpack the selected subgraph.' + }) }) it('updates previews and history only for successful unpacks', () => { diff --git a/src/composables/graph/useSubgraphOperations.ts b/src/composables/graph/useSubgraphOperations.ts index 7b639ffa570..be85b8eef97 100644 --- a/src/composables/graph/useSubgraphOperations.ts +++ b/src/composables/graph/useSubgraphOperations.ts @@ -1,7 +1,7 @@ import { useSelectedLiteGraphItems } from '@/composables/canvas/useSelectedLiteGraphItems' +import { useToast } from '@/components/ui/toast' import { t } from '@/i18n' import { SubgraphNode } from '@/lib/litegraph/src/litegraph' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useNodeOutputStore } from '@/stores/nodeOutputStore' @@ -16,7 +16,7 @@ export function useSubgraphOperations() { const workflowStore = useWorkflowStore() const nodeOutputStore = useNodeOutputStore() const subgraphStore = useSubgraphStore() - const toastStore = useToastStore() + const toast = useToast() const convertToSubgraph = () => { const canvas = canvasStore.getCanvas() @@ -51,10 +51,8 @@ export function useSubgraphOperations() { changed = true } if (refused) { - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('g.subgraphUnpackFailed') + toast.error(t('g.error'), { + description: t('g.subgraphUnpackFailed') }) } if (changed) { diff --git a/src/composables/node/useNodeDragToCanvas.test.ts b/src/composables/node/useNodeDragToCanvas.test.ts index bbfe6eb8f63..fb128b26b43 100644 --- a/src/composables/node/useNodeDragToCanvas.test.ts +++ b/src/composables/node/useNodeDragToCanvas.test.ts @@ -1,9 +1,9 @@ +import { useToast } from '@/components/ui/toast' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type { ComfyNodeDefImpl } from '@/stores/nodeDefStore' import { useNodeDragToCanvas } from './useNodeDragToCanvas' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' -import { useToastStore } from '@/platform/updates/common/toastStore' import { LGraphNode } from '@/lib/litegraph/src/litegraph' import type { LGraphCanvas } from '@/lib/litegraph/src/litegraph' import { fromPartial } from '@total-typescript/shoehorn' @@ -302,10 +302,10 @@ describe('useNodeDragToCanvas', () => { ) expect(mockSelectItems).toHaveBeenCalledWith([placedNode]) - expect(useToastStore().add).toHaveBeenCalledWith( + expect(useToast().warning).toHaveBeenCalledWith( + expect.any(String), expect.objectContaining({ - severity: 'warn', - detail: 'assetBrowser.failedToSetModelValue' + description: 'assetBrowser.failedToSetModelValue' }) ) expect(console.error).toHaveBeenCalledWith( @@ -333,10 +333,10 @@ describe('useNodeDragToCanvas', () => { }) ) - expect(useToastStore().add).toHaveBeenCalledWith( + expect(useToast().error).toHaveBeenCalledWith( + expect.any(String), expect.objectContaining({ - severity: 'error', - detail: 'assetBrowser.failedToCreateNode' + description: 'assetBrowser.failedToCreateNode' }) ) }) diff --git a/src/composables/node/useNodeDragToCanvas.ts b/src/composables/node/useNodeDragToCanvas.ts index 65a67fe63c8..fa7f244c8b6 100644 --- a/src/composables/node/useNodeDragToCanvas.ts +++ b/src/composables/node/useNodeDragToCanvas.ts @@ -4,7 +4,7 @@ import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/litegraph' import { withNodeAddSource } from '@/platform/telemetry/nodeAdded/nodeAddSource' import type { NodeAddSource } from '@/platform/telemetry/types' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useLitegraphService } from '@/services/litegraphService' import type { ComfyNodeDefImpl } from '@/stores/nodeDefStore' @@ -41,10 +41,8 @@ function applyWidgetValues(node: LGraphNode, values: WidgetValues) { const widget = node.widgets?.find((w) => w.name === name) if (!widget) { console.error(`Widget ${name} not found on node ${node.type}`) - useToastStore().add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('assetBrowser.failedToSetModelValue') + useToast().warning(t('g.warning'), { + description: t('assetBrowser.failedToSetModelValue') }) continue } @@ -80,10 +78,8 @@ function addNodeAtPosition(clientX: number, clientY: number): boolean { ) if (!node) { console.error(`Failed to add node to graph: ${nodeDef.name}`) - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('assetBrowser.failedToCreateNode') + useToast().error(t('g.error'), { + description: t('assetBrowser.failedToCreateNode') }) return true } diff --git a/src/composables/node/useNodeImageUpload.test.ts b/src/composables/node/useNodeImageUpload.test.ts index 2f061af660b..da33b43d94f 100644 --- a/src/composables/node/useNodeImageUpload.test.ts +++ b/src/composables/node/useNodeImageUpload.test.ts @@ -1,3 +1,4 @@ +import { useToast } from '@/components/ui/toast' import { fromAny } from '@total-typescript/shoehorn' import { beforeEach, describe, expect, it, vi } from 'vitest' @@ -6,7 +7,6 @@ import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/litegraph' import type { ResultItem } from '@/platform/remote/comfyui/execution/types' import { api } from '@/scripts/api' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useAssetsStore } from '@/stores/assetsStore' import type { Mock } from 'vitest' @@ -186,9 +186,9 @@ describe('useNodeImageUpload', () => { await capturedDragOnDrop([createFile()]) expect(t).toHaveBeenCalledWith('g.uploadFileTooLarge') - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'g.uploadFileTooLarge' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'g.uploadFileTooLarge' + }) }) it('shows a file-too-large toast with the limit on a 413 when the server reports one', async () => { @@ -233,9 +233,9 @@ describe('useNodeImageUpload', () => { const second = await capturedDragOnDrop([createFile('b.png')]) expect(second).toEqual([]) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'g.uploadAlreadyInProgress' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'g.uploadAlreadyInProgress' + }) await first }) diff --git a/src/composables/node/useNodeImageUpload.ts b/src/composables/node/useNodeImageUpload.ts index 7f22d9b6b2d..7a4b71adff6 100644 --- a/src/composables/node/useNodeImageUpload.ts +++ b/src/composables/node/useNodeImageUpload.ts @@ -4,7 +4,7 @@ import { useNodePaste } from '@/composables/node/useNodePaste' import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/litegraph' import { ServerFeatureFlag } from '@/platform/remoteConfig/serverFeatureFlag' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import type { ResultItem } from '@/platform/remote/comfyui/execution/types' import type { ResultItemType } from '@/schemas/resultItemTypeSchema' import { useAssetsStore } from '@/stores/assetsStore' @@ -53,7 +53,9 @@ const uploadFile = async ( }) if (resp.status !== 200) { - useToastStore().addAlert(buildUploadErrorMessage(resp)) + useToast().warning('Alert', { + description: buildUploadErrorMessage(resp) + }) return } @@ -104,16 +106,18 @@ export const useNodeImageUpload = ( return path } catch (error) { if (error instanceof DOMException && error.name === 'TimeoutError') { - useToastStore().addAlert(t('g.uploadTimedOut')) + useToast().warning('Alert', { description: t('g.uploadTimedOut') }) } else { - useToastStore().addAlert(String(error)) + useToast().warning('Alert', { description: String(error) }) } } } const handleUploadBatch = async (files: File[]) => { if (node.isUploading) { - useToastStore().addAlert(t('g.uploadAlreadyInProgress')) + useToast().warning('Alert', { + description: t('g.uploadAlreadyInProgress') + }) return [] } node.isUploading = true diff --git a/src/composables/painter/usePainter.ts b/src/composables/painter/usePainter.ts index 0e10ce5daae..11ba9bc5996 100644 --- a/src/composables/painter/usePainter.ts +++ b/src/composables/painter/usePainter.ts @@ -13,7 +13,7 @@ import { setNodeWidgetValue } from '@/core/graph/widgets/nodeWidgetValues' import { hexToRgb } from '@/utils/colorUtil' import type { Point } from '@/extensions/core/maskeditor/types' import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import { app } from '@/scripts/app' import { useNodeOutputStore } from '@/stores/nodeOutputStore' @@ -38,7 +38,7 @@ export function usePainter(nodeId: NodeId, options: UsePainterOptions) { const { canvasEl, cursorEl, modelValue } = options const { t } = useI18n() const nodeOutputStore = useNodeOutputStore() - const toastStore = useToastStore() + const toastStore = useToast() const isDirty = ref(false) @@ -633,7 +633,7 @@ export function usePainter(nodeId: NodeId, options: UsePainterOptions) { status: 0, statusText: e instanceof Error ? e.message : String(e) }) - toastStore.addAlert(err) + toastStore.warning('Alert', { description: err }) throw new Error(err, { cause: e }) } @@ -643,7 +643,7 @@ export function usePainter(nodeId: NodeId, options: UsePainterOptions) { status: resp.status, statusText: bodyText || resp.statusText || 'unknown error' }) - toastStore.addAlert(err) + toastStore.warning('Alert', { description: err }) throw new Error(err) } @@ -655,13 +655,13 @@ export function usePainter(nodeId: NodeId, options: UsePainterOptions) { status: resp.status, statusText: e instanceof Error ? e.message : String(e) }) - toastStore.addAlert(err) + toastStore.warning('Alert', { description: err }) throw new Error(err, { cause: e }) } if (!data.name) { const detail = `Painter upload succeeded (${resp.status}) but response is missing 'name'` - toastStore.addAlert(detail) + toastStore.warning('Alert', { description: detail }) throw new Error(detail) } diff --git a/src/composables/useCameraAngle.test.ts b/src/composables/useCameraAngle.test.ts index c3b168fb610..144eea94e18 100644 --- a/src/composables/useCameraAngle.test.ts +++ b/src/composables/useCameraAngle.test.ts @@ -2,8 +2,8 @@ import { ref } from 'vue' import type { Ref } from 'vue' import { beforeEach, describe, expect, it, vi } from 'vitest' +import { useToast } from '@/components/ui/toast' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useNodeOutputStore } from '@/stores/nodeOutputStore' interface ViewportInstance { @@ -157,7 +157,14 @@ describe('useCameraAngle', () => { const camera = useCameraAngle(nodeRef(makeNode(DEFAULT_WIDGETS))) expect(() => camera.initialize(document.createElement('div'))).not.toThrow() - expect(useToastStore().addAlert).toHaveBeenCalledOnce() + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ + kind: 'warning', + description: + 'Failed to initialize Camera Angle viewer. Try reloading the page.' + }) + ) + }) it('writes viewport interaction results back into the widgets', () => { diff --git a/src/composables/useCameraAngle.ts b/src/composables/useCameraAngle.ts index 10009f74d68..0c1a6be535e 100644 --- a/src/composables/useCameraAngle.ts +++ b/src/composables/useCameraAngle.ts @@ -30,7 +30,7 @@ import { import type { NodeWithWidgets } from '@/extensions/core/cameraAngle/widgetBridge' import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useNodeOutputStore } from '@/stores/nodeOutputStore' const IMAGE_INPUT_NAME = 'image' @@ -88,9 +88,9 @@ export function useCameraAngle( } catch (error) { console.error('Failed to initialize CameraAngleViewport:', error) cleanup() - useToastStore().addAlert( - t('toastMessages.failedToInitializeCameraAngleViewer') - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToInitializeCameraAngleViewer') + }) } } diff --git a/src/composables/useCameraInfo.test.ts b/src/composables/useCameraInfo.test.ts index 0018b9814ec..ece7b0bcaa8 100644 --- a/src/composables/useCameraInfo.test.ts +++ b/src/composables/useCameraInfo.test.ts @@ -1,9 +1,9 @@ +import { useToast } from '@/components/ui/toast' import { ref } from 'vue' import type { Ref } from 'vue' import { beforeEach, describe, expect, it, vi } from 'vitest' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' interface ViewportInstance { ctorArgs: unknown[] @@ -19,7 +19,7 @@ interface ViewportInstance { } } -const { ViewportMock, instances } = vi.hoisted(() => { +const { ViewportMock, instances, warning } = vi.hoisted(() => { const instances: ViewportInstance[] = [] const ViewportMock = vi.fn(function (...ctorArgs: unknown[]) { const instance: ViewportInstance = { @@ -38,7 +38,7 @@ const { ViewportMock, instances } = vi.hoisted(() => { instances.push(instance) return instance }) - return { ViewportMock, instances } + return { ViewportMock, instances, warning: vi.fn() } }) vi.mock( @@ -47,6 +47,9 @@ vi.mock( CameraInfoViewport: ViewportMock }) ) +beforeEach(() => { + vi.mocked(useToast().warning).mockImplementation(warning) +}) import { useCameraInfo } from './useCameraInfo' @@ -81,6 +84,7 @@ function nodeRef(node: FakeNode) { beforeEach(() => { instances.length = 0 ViewportMock.mockClear() + warning.mockClear() }) describe('useCameraInfo', () => { @@ -116,7 +120,8 @@ describe('useCameraInfo', () => { const camera = useCameraInfo(nodeRef(makeNode({ mode: 'orbit' }))) expect(() => camera.initialize(document.createElement('div'))).not.toThrow() - expect(useToastStore().addAlert).toHaveBeenCalledOnce() + expect(warning).toHaveBeenCalledOnce() + }) it('forwards toolbar actions to the viewport', () => { diff --git a/src/composables/useCameraInfo.ts b/src/composables/useCameraInfo.ts index f39c9f6e559..24f91c55129 100644 --- a/src/composables/useCameraInfo.ts +++ b/src/composables/useCameraInfo.ts @@ -16,7 +16,7 @@ import { import type { NodeWithWidgets } from '@/extensions/core/cameraInfo/widgetBridge' import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' const WIDGET_NAMES = [ 'mode', @@ -65,9 +65,9 @@ export function useCameraInfo(nodeRef: MaybeRef) { } catch (error) { console.error('Failed to initialize CameraInfoViewport:', error) cleanup() - useToastStore().addAlert( - t('toastMessages.failedToInitializeCameraInfoViewer') - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToInitializeCameraInfoViewer') + }) } } diff --git a/src/composables/useCopyToClipboard.test.ts b/src/composables/useCopyToClipboard.test.ts index f30a1856b93..04a6667fc09 100644 --- a/src/composables/useCopyToClipboard.test.ts +++ b/src/composables/useCopyToClipboard.test.ts @@ -1,17 +1,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' -const mockWriteText = vi.fn() -const mockToastAdd = vi.fn() - -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports +import { useToast } from '@/components/ui/toast' - () => ({ - useToast: vi.fn(() => ({ - add: mockToastAdd - })) - }) -) +const mockWriteText = vi.fn() vi.mock(import('@/i18n')) @@ -34,8 +25,8 @@ describe('useCopyToClipboard', () => { expect(copied).toBe(true) expect(mockWriteText).toHaveBeenCalledWith('hello') - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'success' }) + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ kind: 'success' }) ) }) @@ -59,8 +50,8 @@ describe('useCopyToClipboard', () => { expect(copied).toBe(true) expect(document.execCommand).toHaveBeenCalledWith('copy') - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'success' }) + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ kind: 'success' }) ) }) @@ -73,8 +64,8 @@ describe('useCopyToClipboard', () => { expect(copied).toBe(false) - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ kind: 'error' }) ) }) @@ -92,8 +83,8 @@ describe('useCopyToClipboard', () => { expect(mockWriteText).not.toHaveBeenCalled() expect(document.execCommand).toHaveBeenCalledWith('copy') - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'success' }) + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ kind: 'success' }) ) }) }) diff --git a/src/composables/useCopyToClipboard.ts b/src/composables/useCopyToClipboard.ts index a03333f97bb..07b6595ba97 100644 --- a/src/composables/useCopyToClipboard.ts +++ b/src/composables/useCopyToClipboard.ts @@ -1,4 +1,4 @@ -import { useToast } from 'primevue/usetoast' +import { useToast } from '@/components/ui/toast' import { t } from '@/i18n' @@ -44,20 +44,16 @@ export function useCopyToClipboard() { if (success && !toastOnSuccess) return true - toast.add( - success - ? { - severity: 'success', - summary: t('g.success'), - detail: t('clipboard.successMessage'), - life: 3000 - } - : { - severity: 'error', - summary: t('g.error'), - detail: t('clipboard.errorMessage') - } - ) + if (success) { + toast.success(t('g.success'), { + description: t('clipboard.successMessage'), + duration: 3000 + }) + } else { + toast.error(t('g.error'), { + description: t('clipboard.errorMessage') + }) + } return success } diff --git a/src/composables/useCoreCommands.test.ts b/src/composables/useCoreCommands.test.ts index 2a1ac3cb872..202cb48e48c 100644 --- a/src/composables/useCoreCommands.test.ts +++ b/src/composables/useCoreCommands.test.ts @@ -1,4 +1,5 @@ import { useDialogService } from '@/services/dialogService' +import { useToast } from '@/components/ui/toast' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { beforeEach, describe, expect, it, vi } from 'vitest' @@ -17,7 +18,6 @@ import { app } from '@/scripts/app' import { useModelStore } from '@/stores/modelStore' import { useMissingModelStore } from '@/platform/missingModel/missingModelStore' import { resetOnboardingState } from '@/platform/onboarding/onboardingReset' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useSettingsDialog } from '@/platform/settings/composables/useSettingsDialog' import { useLitegraphService } from '@/services/litegraphService' @@ -378,9 +378,7 @@ describe('useCoreCommands', () => { await findCommand().function() - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(useToast().error).toHaveBeenCalled() expect(location.assign).not.toHaveBeenCalled() expect(location.reload).not.toHaveBeenCalled() }) @@ -781,9 +779,7 @@ describe('useCoreCommands', () => { await findCmd('Comfy.QueueSelectedOutputNodes').function() expect(mockBillingState.showSubscriptionDialog).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(useToast().error).toHaveBeenCalled() }) it.for([ @@ -816,9 +812,7 @@ describe('useCoreCommands', () => { expect(app.queuePrompt).not.toHaveBeenCalled() expect(mockBillingState.showSubscriptionDialog).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'warn' }) - ) + expect(useToast().warning).toHaveBeenCalled() } ) @@ -902,7 +896,7 @@ describe('useCoreCommands', () => { asset, 'asset_browser' ) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() }) it('shows an error toast when the asset cannot start a drag', async () => { @@ -914,9 +908,7 @@ describe('useCoreCommands', () => { await selectAssetFromBrowser() - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(useToast().error).toHaveBeenCalled() }) }) }) diff --git a/src/composables/useCoreCommands.ts b/src/composables/useCoreCommands.ts index 6934e54ce7b..4aa1276f4a7 100644 --- a/src/composables/useCoreCommands.ts +++ b/src/composables/useCoreCommands.ts @@ -31,7 +31,7 @@ import { buildSupportUrl } from '@/platform/support/config' import { useTelemetry } from '@/platform/telemetry' import { reportError } from '@/platform/telemetry/reportError' import type { ExecutionTriggerSource } from '@/platform/telemetry/types' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useWorkflowService } from '@/platform/workflow/core/services/workflowService' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import type { ComfyWorkflow } from '@/platform/workflow/management/stores/workflowStore' @@ -88,11 +88,9 @@ export function useCoreCommands(): ComfyCommand[] { function blockRunWithoutSubscription(): boolean { if (!isCloud || canAccessSubscriptionFeatures.value) return false if (isSalesManagedTier(subscription.value?.tier)) { - toastStore.add({ - severity: 'warn', - summary: t('subscription.salesManagedRunBlockedTitle'), - detail: t('subscription.salesManagedRunBlockedDetail'), - life: 5000 + toastStore.warning(t('subscription.salesManagedRunBlockedTitle'), { + description: t('subscription.salesManagedRunBlockedDetail'), + duration: 5000 }) } else { showSubscriptionDialog({ reason: 'subscribe_to_run' }) @@ -105,7 +103,7 @@ export function useCoreCommands(): ComfyCommand[] { const dialogService = useDialogService() const colorPaletteStore = useColorPaletteStore() const authActions = useAuthActions() - const toastStore = useToastStore() + const toastStore = useToast() const canvasStore = useCanvasStore() const executionStore = useExecutionStore() const modelStore = useModelStore() @@ -348,11 +346,9 @@ export function useCoreCommands(): ComfyCommand[] { category: 'essentials' as const, function: async () => { await api.interrupt(executionStore.activeJobId) - toastStore.add({ - severity: 'info', - summary: t('g.interrupted'), - detail: t('toastMessages.interrupted'), - life: 1000 + toastStore.info(t('g.interrupted'), { + description: t('toastMessages.interrupted'), + duration: 1000 }) } }, @@ -363,11 +359,9 @@ export function useCoreCommands(): ComfyCommand[] { category: 'essentials' as const, function: async () => { await useQueueStore().clear(['queue']) - toastStore.add({ - severity: 'info', - summary: t('g.confirmed'), - detail: t('toastMessages.pendingTasksDeleted'), - life: 3000 + toastStore.info(t('g.confirmed'), { + description: t('toastMessages.pendingTasksDeleted'), + duration: 3000 }) } }, @@ -427,10 +421,7 @@ export function useCoreCommands(): ComfyCommand[] { category: 'view-controls' as const, function: () => { if (app.canvas.empty) { - toastStore.add({ - severity: 'error', - summary: t('toastMessages.emptyCanvas') - }) + toastStore.error(t('toastMessages.emptyCanvas')) return } app.canvas.fitViewToSelectionAnimated({ @@ -578,10 +569,8 @@ export function useCoreCommands(): ComfyCommand[] { const selectedOutputNodes = filterOutputNodes(selectedNodes) if (selectedOutputNodes.length === 0) { - toastStore.add({ - severity: 'error', - summary: t('toastMessages.nothingToQueue'), - detail: t('toastMessages.pleaseSelectOutputNodes') + toastStore.error(t('toastMessages.nothingToQueue'), { + description: t('toastMessages.pleaseSelectOutputNodes') }) return } @@ -591,10 +580,8 @@ export function useCoreCommands(): ComfyCommand[] { getExecutionIdsForSelectedNodes(selectedOutputNodes) if (executionIds.length === 0) { - toastStore.add({ - severity: 'error', - summary: t('toastMessages.failedToQueue'), - detail: t('toastMessages.failedExecutionPathResolution') + toastStore.error(t('toastMessages.failedToQueue'), { + description: t('toastMessages.failedExecutionPathResolution') }) return } @@ -625,10 +612,8 @@ export function useCoreCommands(): ComfyCommand[] { function: () => { const { canvas } = app if (!canvas.selectedItems.size) { - toastStore.add({ - severity: 'error', - summary: t('toastMessages.nothingToGroup'), - detail: t('toastMessages.pleaseSelectNodesToGroup') + toastStore.error(t('toastMessages.nothingToGroup'), { + description: t('toastMessages.pleaseSelectNodesToGroup') }) return } @@ -921,11 +906,9 @@ export function useCoreCommands(): ComfyCommand[] { const result = await resetOnboardingState() if (result.status === 'failed') { - toastStore.add({ - severity: 'error', - summary: t('onboardingReplay.failedSummary'), - detail: t('onboardingReplay.failedDetail'), - life: 5000 + toastStore.error(t('onboardingReplay.failedSummary'), { + description: t('onboardingReplay.failedDetail'), + duration: 5000 }) reportError(result.cause, { surface: 'platform', @@ -1039,10 +1022,8 @@ export function useCoreCommands(): ComfyCommand[] { // For DISABLED state, show error toast instead of opening settings if (state === ManagerUIState.DISABLED) { - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('manager.notAvailable') + toastStore.error(t('g.error'), { + description: t('manager.notAvailable') }) return } @@ -1332,10 +1313,8 @@ export function useCoreCommands(): ComfyCommand[] { versionAdded: '1.16.4', function: async () => { if (!useSettingStore().get('Comfy.Memory.AllowManualUnload')) { - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('g.commandProhibited', { + useToast().error(t('g.error'), { + description: t('g.commandProhibited', { command: 'Comfy.Memory.UnloadModels' }) }) @@ -1351,10 +1330,8 @@ export function useCoreCommands(): ComfyCommand[] { versionAdded: '1.16.4', function: async () => { if (!useSettingStore().get('Comfy.Memory.AllowManualUnload')) { - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('g.commandProhibited', { + useToast().error(t('g.error'), { + description: t('g.commandProhibited', { command: 'Comfy.Memory.UnloadModelsAndExecutionCache' }) }) diff --git a/src/composables/useErrorHandling.test.ts b/src/composables/useErrorHandling.test.ts index d39082e39ff..7a45f8842ee 100644 --- a/src/composables/useErrorHandling.test.ts +++ b/src/composables/useErrorHandling.test.ts @@ -3,7 +3,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import type { ErrorRecoveryStrategy } from '@/composables/useErrorHandling' import { useErrorHandling } from '@/composables/useErrorHandling' import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' describe('useErrorHandling', () => { let errorHandler: ReturnType @@ -332,13 +332,10 @@ describe('useErrorHandling', () => { const wrapped = errorHandler.wrapWithErrorHandlingAsync(action) await wrapped() - const toastStore = useToastStore() - expect(toastStore.add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: t('g.disconnectedFromBackend') - }) - ) + const toastStore = useToast() + expect(toastStore.error).toHaveBeenCalledWith(t('g.error'), { + description: t('g.disconnectedFromBackend') + }) }) it('should not treat non-TypeError as network error', async () => { @@ -349,12 +346,10 @@ describe('useErrorHandling', () => { const wrapped = errorHandler.wrapWithErrorHandlingAsync(action) await wrapped() - const toastStore = useToastStore() - expect(toastStore.add).toHaveBeenCalledWith( - expect.objectContaining({ - detail: 'Failed to fetch' - }) - ) + const toastStore = useToast() + expect(toastStore.error).toHaveBeenCalledWith(t('g.error'), { + description: 'Failed to fetch' + }) }) }) diff --git a/src/composables/useErrorHandling.ts b/src/composables/useErrorHandling.ts index 9bee2812df7..c620ba6bdb3 100644 --- a/src/composables/useErrorHandling.ts +++ b/src/composables/useErrorHandling.ts @@ -1,5 +1,5 @@ import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' /** * Strategy for recovering from specific error conditions. @@ -50,7 +50,7 @@ export interface ErrorRecoveryStrategy< } export function useErrorHandling() { - const toast = useToastStore() + const toast = useToast() const toastErrorHandler = (error: unknown) => { const isNetworkError = error instanceof TypeError && @@ -60,11 +60,7 @@ export function useErrorHandling() { : error instanceof Error ? error.message : t('g.unknownError') - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: message - }) + toast.error(t('g.error'), { description: message }) console.error(error) } diff --git a/src/composables/useLoad3d.test.ts b/src/composables/useLoad3d.test.ts index 13910715940..ad896d926e2 100644 --- a/src/composables/useLoad3d.test.ts +++ b/src/composables/useLoad3d.test.ts @@ -20,7 +20,7 @@ import type { LGraph } from '@/lib/litegraph/src/LGraph' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' import type { IWidget } from '@/lib/litegraph/src/types/widgets' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import { createMockLGraphNode } from '@/utils/__tests__/litegraphTestUtils' import { createMockCanvasPointerEvent } from '@/utils/__tests__/canvasTestUtils' @@ -68,7 +68,7 @@ describe('useLoad3d', () => { afterEach(() => scope.stop()) let mockLoad3d: Partial let mockNode: LGraphNode - let mockToastStore: ReturnType + let mockToastStore: ReturnType beforeEach(() => { vi.mocked(api.getServerFeature).mockReturnValue(false) @@ -192,7 +192,7 @@ describe('useLoad3d', () => { }) vi.mocked(createLoad3d).mockImplementation(() => mockLoad3d as Load3d) - mockToastStore = useToastStore() + mockToastStore = useToast() }) describe('initialization', () => { @@ -348,9 +348,9 @@ describe('useLoad3d', () => { await composable.initializeLoad3d(containerRef) - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToInitializeLoad3dViewer' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToInitializeLoad3dViewer' + }) }) it('should handle missing container or node', async () => { @@ -825,9 +825,9 @@ describe('useLoad3d', () => { await composable.handleExportModel('glb') - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.no3dSceneToExport' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.no3dSceneToExport' + }) }) it('should handle export errors', async () => { @@ -842,9 +842,9 @@ describe('useLoad3d', () => { await composable.handleExportModel('glb') - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToExportModel' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToExportModel' + }) }) }) @@ -1069,9 +1069,9 @@ describe('useLoad3d', () => { await composable.handleModelDrop(file) expect(mockLoad3d.loadModel).not.toHaveBeenCalled() - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.no3dScene' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.no3dScene' + }) }) }) @@ -1785,7 +1785,7 @@ describe('useLoad3d', () => { expect(throwing).toHaveBeenCalledTimes(1) expect(after).toHaveBeenCalledTimes(1) expect(mockLoad3d.addEventListener).toHaveBeenCalled() - expect(mockToastStore.addAlert).not.toHaveBeenCalled() + expect(mockToastStore.warning).not.toHaveBeenCalled() expect(console.error).toHaveBeenCalledWith( 'Load3d ready callback failed:', expect.any(Error) diff --git a/src/composables/useLoad3d.ts b/src/composables/useLoad3d.ts index 15ff51c94fe..1ec38859c9e 100644 --- a/src/composables/useLoad3d.ts +++ b/src/composables/useLoad3d.ts @@ -33,7 +33,7 @@ import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' import { LiteGraph } from '@/lib/litegraph/src/litegraph' import { useSettingStore } from '@/platform/settings/settingStore' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { api } from '@/scripts/api' import { app } from '@/scripts/app' @@ -286,9 +286,9 @@ export const useLoad3d = (nodeOrRef: MaybeRef) => { } } catch (error) { console.error('Error initializing Load3d:', error) - useToastStore().addAlert( - t('toastMessages.failedToInitializeLoad3dViewer') - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToInitializeLoad3dViewer') + }) } } @@ -769,7 +769,9 @@ export const useLoad3d = (nodeOrRef: MaybeRef) => { showAsBackground: false } } - useToastStore().addAlert(t('toastMessages.failedToLoadHDRI')) + useToast().warning('Alert', { + description: t('toastMessages.failedToLoadHDRI') + }) } finally { loading.value = false loadingMessage.value = '' @@ -800,7 +802,9 @@ export const useLoad3d = (nodeOrRef: MaybeRef) => { const handleExportModel = async (format: string) => { if (!load3d) { - useToastStore().addAlert(t('toastMessages.no3dSceneToExport')) + useToast().warning('Alert', { + description: t('toastMessages.no3dSceneToExport') + }) return } @@ -808,17 +812,17 @@ export const useLoad3d = (nodeOrRef: MaybeRef) => { await load3d.exportModel(format) } catch (error) { console.error('Error exporting model:', error) - useToastStore().addAlert( - t('toastMessages.failedToExportModel', { + useToast().warning('Alert', { + description: t('toastMessages.failedToExportModel', { format: format.toUpperCase() }) - ) + }) } } const handleModelDrop = async (file: File) => { if (!load3d) { - useToastStore().addAlert(t('toastMessages.no3dScene')) + useToast().warning('Alert', { description: t('toastMessages.no3dScene') }) return } @@ -839,7 +843,9 @@ export const useLoad3d = (nodeOrRef: MaybeRef) => { const uploadedPath = await Load3dUtils.uploadFile(file, subfolder) if (!uploadedPath) { - useToastStore().addAlert(t('toastMessages.fileUploadFailed')) + useToast().warning('Alert', { + description: t('toastMessages.fileUploadFailed') + }) return } @@ -865,7 +871,9 @@ export const useLoad3d = (nodeOrRef: MaybeRef) => { } } catch (error) { console.error('Model drop failed:', error) - useToastStore().addAlert(t('toastMessages.failedToLoadModel')) + useToast().warning('Alert', { + description: t('toastMessages.failedToLoadModel') + }) } finally { loading.value = false loadingMessage.value = '' diff --git a/src/composables/useLoad3dDrag.test.ts b/src/composables/useLoad3dDrag.test.ts index f1913103462..3de1faf9220 100644 --- a/src/composables/useLoad3dDrag.test.ts +++ b/src/composables/useLoad3dDrag.test.ts @@ -3,7 +3,7 @@ import { ref } from 'vue' import { useLoad3dDrag } from '@/composables/useLoad3dDrag' import { SUPPORTED_EXTENSIONS } from '@/extensions/core/load3d/constants' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { createMockFileList } from '@/utils/__tests__/litegraphTestUtils' vi.mock(import('@/i18n')) @@ -30,11 +30,11 @@ function createMockDragEvent( } describe('useLoad3dDrag', () => { - let mockToastStore: ReturnType + let mockToastStore: ReturnType let mockOnModelDrop: (file: File) => void | Promise beforeEach(() => { - mockToastStore = useToastStore() + mockToastStore = useToast() mockOnModelDrop = vi.fn() }) @@ -137,9 +137,9 @@ describe('useLoad3dDrag', () => { await handleDrop(event) expect(mockOnModelDrop).not.toHaveBeenCalled() - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'load3d.unsupportedFileType' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'load3d.unsupportedFileType' + }) }) it('should not call onModelDrop when disabled', async () => { @@ -217,7 +217,7 @@ describe('useLoad3dDrag', () => { await handleDrop(event) expect(mockOnModelDrop).not.toHaveBeenCalled() - expect(mockToastStore.addAlert).not.toHaveBeenCalled() + expect(mockToastStore.warning).not.toHaveBeenCalled() }) }) diff --git a/src/composables/useLoad3dDrag.ts b/src/composables/useLoad3dDrag.ts index 87a8292ec25..06fc60dc218 100644 --- a/src/composables/useLoad3dDrag.ts +++ b/src/composables/useLoad3dDrag.ts @@ -3,7 +3,7 @@ import type { MaybeRefOrGetter } from 'vue' import { SUPPORTED_EXTENSIONS } from '@/extensions/core/load3d/constants' import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' interface UseLoad3dDragOptions { onModelDrop: (file: File) => void | Promise @@ -56,7 +56,9 @@ export function useLoad3dDrag(options: UseLoad3dDragOptions) { if (modelFile) { await options.onModelDrop(modelFile) } else { - useToastStore().addAlert(t('load3d.unsupportedFileType')) + useToast().warning('Alert', { + description: t('load3d.unsupportedFileType') + }) } } diff --git a/src/composables/useLoad3dViewer.test.ts b/src/composables/useLoad3dViewer.test.ts index 25eabc194b1..2225071bc0d 100644 --- a/src/composables/useLoad3dViewer.test.ts +++ b/src/composables/useLoad3dViewer.test.ts @@ -7,11 +7,15 @@ import Load3dUtils from '@/extensions/core/load3d/Load3dUtils' import { createLoad3d } from '@/extensions/core/load3d/createLoad3d' import type { LGraph } from '@/lib/litegraph/src/LGraph' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useLoad3dService } from '@/services/load3dService' import { createMockLGraphNode } from '@/utils/__tests__/litegraphTestUtils' import { api } from '@/scripts/api' +vi.mock(import('@/scripts/app'), () => ({ + app: { canvas: {}, rootGraph: {} } +})) + vi.mock(import('@/services/load3dService'), () => ({ useLoad3dService: vi.fn() })) @@ -68,7 +72,7 @@ describe('useLoad3dViewer', () => { let mockLoad3d: Partial let mockSourceLoad3d: Partial let mockLoad3dService: ReturnType - let mockToastStore: ReturnType + let mockToastStore: ReturnType let mockNode: LGraphNode beforeEach(() => { @@ -189,7 +193,7 @@ describe('useLoad3dViewer', () => { > vi.mocked(useLoad3dService).mockReturnValue(mockLoad3dService) - mockToastStore = useToastStore() + mockToastStore = useToast() }) describe('initialization', () => { @@ -250,9 +254,9 @@ describe('useLoad3dViewer', () => { await viewer.initializeViewer(containerRef, mockSourceLoad3d as Load3d) - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToInitializeLoad3dViewer' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToInitializeLoad3dViewer' + }) }) }) @@ -272,9 +276,9 @@ describe('useLoad3dViewer', () => { viewer.backgroundColor.value = '#ff0000' await nextTick() - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToUpdateBackgroundColor' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToUpdateBackgroundColor' + }) }) }) @@ -302,9 +306,9 @@ describe('useLoad3dViewer', () => { await viewer.exportModel('glb') - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToExportModel' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToExportModel' + }) }) it('should not export when load3d is not initialized', async () => { @@ -603,9 +607,9 @@ describe('useLoad3dViewer', () => { const file = new File([''], 'test.jpg', { type: 'image/jpeg' }) await viewer.handleBackgroundImageUpdate(file) - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToUploadBackgroundImage' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToUploadBackgroundImage' + }) }) it('should work in standalone mode without a node', async () => { @@ -688,9 +692,9 @@ describe('useLoad3dViewer', () => { const file = new File([''], 'whatever.glb') await viewer.handleModelDrop(file) - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.no3dScene' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.no3dScene' + }) expect(mockLoad3d.loadModel).not.toHaveBeenCalled() }) @@ -705,9 +709,9 @@ describe('useLoad3dViewer', () => { const file = new File([''], 'whatever.glb') await viewer.handleModelDrop(file) - expect(mockToastStore.addAlert).toHaveBeenCalledWith( - 'toastMessages.fileUploadFailed' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.fileUploadFailed' + }) expect(mockLoad3d.loadModel).not.toHaveBeenCalled() }) }) diff --git a/src/composables/useLoad3dViewer.ts b/src/composables/useLoad3dViewer.ts index 335d722c774..c4a494370e4 100644 --- a/src/composables/useLoad3dViewer.ts +++ b/src/composables/useLoad3dViewer.ts @@ -24,7 +24,7 @@ import type { } from '@/extensions/core/load3d/interfaces' import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import { useLoad3dService } from '@/services/load3dService' @@ -166,9 +166,11 @@ export const useLoad3dViewer = (node?: LGraphNode) => { load3d.setBackgroundColor(newColor) } catch (error) { console.error('Error updating background color:', error) - useToastStore().addAlert( - t('toastMessages.failedToUpdateBackgroundColor', { color: newColor }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToUpdateBackgroundColor', { + color: newColor + }) + }) } }) @@ -178,9 +180,11 @@ export const useLoad3dViewer = (node?: LGraphNode) => { load3d.toggleGrid(newValue) } catch (error) { console.error('Error toggling grid:', error) - useToastStore().addAlert( - t('toastMessages.failedToToggleGrid', { show: newValue ? 'on' : 'off' }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToToggleGrid', { + show: newValue ? 'on' : 'off' + }) + }) } }) @@ -190,9 +194,11 @@ export const useLoad3dViewer = (node?: LGraphNode) => { load3d.toggleCamera(newCameraType) } catch (error) { console.error('Error toggling camera:', error) - useToastStore().addAlert( - t('toastMessages.failedToToggleCamera', { camera: newCameraType }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToToggleCamera', { + camera: newCameraType + }) + }) } }) @@ -202,9 +208,9 @@ export const useLoad3dViewer = (node?: LGraphNode) => { load3d.setFOV(newFov) } catch (error) { console.error('Error updating FOV:', error) - useToastStore().addAlert( - t('toastMessages.failedToUpdateFOV', { fov: newFov }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToUpdateFOV', { fov: newFov }) + }) } }) @@ -214,9 +220,11 @@ export const useLoad3dViewer = (node?: LGraphNode) => { load3d.setLightIntensity(newValue) } catch (error) { console.error('Error updating light intensity:', error) - useToastStore().addAlert( - t('toastMessages.failedToUpdateLightIntensity', { intensity: newValue }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToUpdateLightIntensity', { + intensity: newValue + }) + }) } }) @@ -227,7 +235,9 @@ export const useLoad3dViewer = (node?: LGraphNode) => { hasBackgroundImage.value = !!newValue } catch (error) { console.error('Error updating background image:', error) - useToastStore().addAlert(t('toastMessages.failedToUpdateBackgroundImage')) + useToast().warning('Alert', { + description: t('toastMessages.failedToUpdateBackgroundImage') + }) } }) @@ -237,11 +247,11 @@ export const useLoad3dViewer = (node?: LGraphNode) => { load3d.setBackgroundRenderMode(newValue) } catch (error) { console.error('Error updating background render mode:', error) - useToastStore().addAlert( - t('toastMessages.failedToUpdateBackgroundRenderMode', { + useToast().warning('Alert', { + description: t('toastMessages.failedToUpdateBackgroundRenderMode', { mode: newValue }) - ) + }) } }) @@ -251,9 +261,11 @@ export const useLoad3dViewer = (node?: LGraphNode) => { load3d.setUpDirection(newValue) } catch (error) { console.error('Error updating up direction:', error) - useToastStore().addAlert( - t('toastMessages.failedToUpdateUpDirection', { direction: newValue }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToUpdateUpDirection', { + direction: newValue + }) + }) } }) @@ -263,9 +275,11 @@ export const useLoad3dViewer = (node?: LGraphNode) => { load3d.setMaterialMode(newValue) } catch (error) { console.error('Error updating material mode:', error) - useToastStore().addAlert( - t('toastMessages.failedToUpdateMaterialMode', { mode: newValue }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToUpdateMaterialMode', { + mode: newValue + }) + }) } }) @@ -460,9 +474,9 @@ export const useLoad3dViewer = (node?: LGraphNode) => { setupAnimationEvents() } catch (error) { console.error('Error initializing Load3d viewer:', error) - useToastStore().addAlert( - t('toastMessages.failedToInitializeLoad3dViewer') - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToInitializeLoad3dViewer') + }) } } @@ -509,7 +523,9 @@ export const useLoad3dViewer = (node?: LGraphNode) => { persistStandaloneThumbnail(modelUrl) } catch (error) { console.error('Error initializing standalone 3D viewer:', error) - useToastStore().addAlert(t('toastMessages.failedToLoadModel')) + useToast().warning('Alert', { + description: t('toastMessages.failedToLoadModel') + }) } } @@ -542,7 +558,7 @@ export const useLoad3dViewer = (node?: LGraphNode) => { persistStandaloneThumbnail(modelUrl) } catch (error) { console.error('Error loading model in standalone viewer:', error) - useToastStore().addAlert('Failed to load 3D model') + useToast().warning('Alert', { description: 'Failed to load 3D model' }) } } @@ -604,9 +620,11 @@ export const useLoad3dViewer = (node?: LGraphNode) => { await load3d.exportModel(format) } catch (error) { console.error('Error exporting model:', error) - useToastStore().addAlert( - t('toastMessages.failedToExportModel', { format: format.toUpperCase() }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToExportModel', { + format: format.toUpperCase() + }) + }) } } @@ -775,7 +793,7 @@ export const useLoad3dViewer = (node?: LGraphNode) => { } if (!load3d) { - useToastStore().addAlert(t('toastMessages.no3dScene')) + useToast().warning('Alert', { description: t('toastMessages.no3dScene') }) return } @@ -792,7 +810,9 @@ export const useLoad3dViewer = (node?: LGraphNode) => { } } catch (error) { console.error('Error uploading background image:', error) - useToastStore().addAlert(t('toastMessages.failedToUploadBackgroundImage')) + useToast().warning('Alert', { + description: t('toastMessages.failedToUploadBackgroundImage') + }) } } @@ -803,7 +823,7 @@ export const useLoad3dViewer = (node?: LGraphNode) => { */ const handleModelDrop = async (file: File) => { if (!load3d) { - useToastStore().addAlert(t('toastMessages.no3dScene')) + useToast().warning('Alert', { description: t('toastMessages.no3dScene') }) return } @@ -814,7 +834,9 @@ export const useLoad3dViewer = (node?: LGraphNode) => { ) if (!uploadedPath) { - useToastStore().addAlert(t('toastMessages.fileUploadFailed')) + useToast().warning('Alert', { + description: t('toastMessages.fileUploadFailed') + }) return } @@ -840,7 +862,9 @@ export const useLoad3dViewer = (node?: LGraphNode) => { } } catch (error) { console.error('Model drop failed:', error) - useToastStore().addAlert(t('toastMessages.failedToLoadModel')) + useToast().warning('Alert', { + description: t('toastMessages.failedToLoadModel') + }) } } diff --git a/src/composables/usePaste.test.ts b/src/composables/usePaste.test.ts index 887455bda6c..57c573b5e4f 100644 --- a/src/composables/usePaste.test.ts +++ b/src/composables/usePaste.test.ts @@ -21,7 +21,7 @@ import type { import { useCopy } from '@/composables/useCopy' import { CANVAS_CLIPBOARD_KEY } from '@/lib/litegraph/src/canvas/clipboardStorage' import { app } from '@/scripts/app' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { createMockLGraphNode } from '@/utils/__tests__/litegraphTestUtils' import { createNode } from '@/utils/litegraphUtil' import { shouldIgnoreCopyPaste } from '@/workbench/eventHelpers' @@ -784,8 +784,8 @@ describe('usePaste', () => { await vi.waitFor(() => { expect(mockCanvas._deserializeItems).not.toHaveBeenCalled() expect(mockCanvas.pasteFromClipboard).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ kind: 'error' }) ) }) } @@ -807,8 +807,8 @@ describe('usePaste', () => { await vi.waitFor(() => { expect(mockCanvas._deserializeItems).not.toHaveBeenCalled() expect(mockCanvas.pasteFromClipboard).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ kind: 'error' }) ) }) }) @@ -837,8 +837,8 @@ describe('usePaste', () => { document.dispatchEvent(event) await vi.waitFor(() => { - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ kind: 'error' }) ) expect(mockCanvas.pasteFromClipboard).not.toHaveBeenCalled() }) diff --git a/src/composables/useReconnectingNotification.test.ts b/src/composables/useReconnectingNotification.test.ts index 9c62b2db318..f0dc502089e 100644 --- a/src/composables/useReconnectingNotification.test.ts +++ b/src/composables/useReconnectingNotification.test.ts @@ -3,23 +3,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { defineComponent, nextTick } from 'vue' import { createI18n } from 'vue-i18n' +import { useToast } from '@/components/ui/toast' import { useReconnectingNotification } from '@/composables/useReconnectingNotification' import { useSettingStore } from '@/platform/settings/settingStore' -const mockToastAdd = vi.fn() -const mockToastRemove = vi.fn() - -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - - () => ({ - useToast: () => ({ - add: mockToastAdd, - remove: mockToastRemove - }) - }) -) - function setupComposable(): ReturnType { const i18n = createI18n({ legacy: false, @@ -55,7 +42,7 @@ describe('useReconnectingNotification', () => { onReconnecting() - expect(mockToastAdd).not.toHaveBeenCalled() + expect(useToast().toasts).toEqual([]) }) it('shows error toast after delay', () => { @@ -64,10 +51,10 @@ describe('useReconnectingNotification', () => { onReconnecting() vi.advanceTimersByTime(2000) - expect(mockToastAdd).toHaveBeenCalledWith( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'error', - summary: 'Reconnecting' + kind: 'error', + title: 'Reconnecting' }) ) }) @@ -80,8 +67,7 @@ describe('useReconnectingNotification', () => { onReconnected() vi.advanceTimersByTime(2000) - expect(mockToastAdd).not.toHaveBeenCalled() - expect(mockToastRemove).not.toHaveBeenCalled() + expect(useToast().toasts).toEqual([]) }) it('removes toast and shows success when reconnected after delay', () => { @@ -89,23 +75,15 @@ describe('useReconnectingNotification', () => { onReconnecting() vi.advanceTimersByTime(2000) - mockToastAdd.mockClear() - onReconnected() - expect(mockToastRemove).toHaveBeenCalledWith( + expect(useToast().toasts).toEqual([ expect.objectContaining({ - severity: 'error', - summary: 'Reconnecting' + kind: 'success', + title: 'Reconnected', + duration: 2000 }) - ) - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'success', - summary: 'Reconnected', - life: 2000 - }) - ) + ]) }) it('does nothing when toast is disabled via setting', () => { @@ -117,8 +95,7 @@ describe('useReconnectingNotification', () => { vi.advanceTimersByTime(1500) onReconnected() - expect(mockToastAdd).not.toHaveBeenCalled() - expect(mockToastRemove).not.toHaveBeenCalled() + expect(useToast().toasts).toEqual([]) }) it('does nothing when onReconnected is called without prior onReconnecting', () => { @@ -126,8 +103,7 @@ describe('useReconnectingNotification', () => { onReconnected() - expect(mockToastAdd).not.toHaveBeenCalled() - expect(mockToastRemove).not.toHaveBeenCalled() + expect(useToast().toasts).toEqual([]) }) it('handles multiple reconnecting events without duplicating toasts', () => { @@ -138,7 +114,7 @@ describe('useReconnectingNotification', () => { onReconnecting() // second reconnecting event vi.advanceTimersByTime(2000) // second toast fires - expect(mockToastAdd).toHaveBeenCalledTimes(2) + expect(useToast().toasts).toHaveLength(2) }) describe('tab visibility regained', () => { @@ -166,12 +142,12 @@ describe('useReconnectingNotification', () => { // Would have fired under the original (unextended) delay by now. vi.advanceTimersByTime(1900) - expect(mockToastAdd).not.toHaveBeenCalled() + expect(useToast().toasts).toEqual([]) // Extended delay (5000ms) elapses from the point visibility was regained. vi.advanceTimersByTime(3100) - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error', summary: 'Reconnecting' }) + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ kind: 'error', title: 'Reconnecting' }) ) }) @@ -187,8 +163,7 @@ describe('useReconnectingNotification', () => { onReconnected() vi.advanceTimersByTime(5000) - expect(mockToastAdd).not.toHaveBeenCalled() - expect(mockToastRemove).not.toHaveBeenCalled() + expect(useToast().toasts).toEqual([]) }) it('reverts to the base delay once the post-visibility grace period elapses', async () => { @@ -201,8 +176,8 @@ describe('useReconnectingNotification', () => { onReconnecting() vi.advanceTimersByTime(2000) // base delay again, not the extended one - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error', summary: 'Reconnecting' }) + expect(useToast().toasts).toContainEqual( + expect.objectContaining({ kind: 'error', title: 'Reconnecting' }) ) }) }) diff --git a/src/composables/useReconnectingNotification.ts b/src/composables/useReconnectingNotification.ts index 65d9fd451e7..adf031824bf 100644 --- a/src/composables/useReconnectingNotification.ts +++ b/src/composables/useReconnectingNotification.ts @@ -1,9 +1,9 @@ import { useDocumentVisibility, useTimeoutFn } from '@vueuse/core' -import type { ToastMessageOptions } from 'primevue/toast' -import { useToast } from 'primevue/usetoast' import { ref, watch } from 'vue' import { useI18n } from 'vue-i18n' +import { useToast } from '@/components/ui/toast' +import type { ToastId } from '@/components/ui/toast' import { useSettingStore } from '@/platform/settings/settingStore' const RECONNECT_TOAST_DELAY_MS = 2000 @@ -16,18 +16,12 @@ export function useReconnectingNotification() { const toast = useToast() const settingStore = useSettingStore() - const reconnectingMessage: ToastMessageOptions = { - severity: 'error', - summary: t('g.reconnecting') - } - - const reconnectingToastShown = ref(false) const toastDelayMs = ref(RECONNECT_TOAST_DELAY_MS) + const reconnectingToastId = ref() const { start, stop, isPending } = useTimeoutFn( () => { - toast.add(reconnectingMessage) - reconnectingToastShown.value = true + reconnectingToastId.value = toast.error(t('g.reconnecting')) }, toastDelayMs, { immediate: false } @@ -59,14 +53,10 @@ export function useReconnectingNotification() { function onReconnected() { stop() - if (reconnectingToastShown.value) { - toast.remove(reconnectingMessage) - toast.add({ - severity: 'success', - summary: t('g.reconnected'), - life: 2000 - }) - reconnectingToastShown.value = false + if (reconnectingToastId.value !== undefined) { + toast.dismiss(reconnectingToastId.value) + toast.success(t('g.reconnected'), { duration: 2000 }) + reconnectingToastId.value = undefined } } diff --git a/src/composables/useWorkspaceInset.test.ts b/src/composables/useWorkspaceInset.test.ts index 263738f844f..709acf2abf7 100644 --- a/src/composables/useWorkspaceInset.test.ts +++ b/src/composables/useWorkspaceInset.test.ts @@ -51,7 +51,7 @@ describe('useWorkspaceInsetRight', () => { expect(readInset()).toBe('0px') }) - it('stops publishing once the owning scope is torn down', async () => { + it('clears the inset once the owning scope is torn down', async () => { const width = ref(420) const scope = effectScope() scope.run(() => useWorkspaceInsetRight(() => width.value)) diff --git a/src/core/graph/subgraph/promotionUtils.ts b/src/core/graph/subgraph/promotionUtils.ts index ab7a6e42b95..1de662589af 100644 --- a/src/core/graph/subgraph/promotionUtils.ts +++ b/src/core/graph/subgraph/promotionUtils.ts @@ -9,7 +9,7 @@ import type { LinkId } from '@/types/linkId' import { reorderSubgraphInputs } from '@/lib/litegraph/src/subgraph/subgraphUtils' import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' import { nextUniqueName } from '@/lib/litegraph/src/strings' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { CANVAS_IMAGE_PREVIEW_WIDGET, supportsVirtualCanvasImagePreview @@ -494,10 +494,8 @@ function getParentNodes(): SubgraphNode[] { const { navigationStack } = useSubgraphNavigationStore() const subgraph = navigationStack.at(-1) if (!subgraph) { - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('subgraphStore.promoteOutsideSubgraph') + useToast().error(t('g.error'), { + description: t('subgraphStore.promoteOutsideSubgraph') }) return [] } diff --git a/src/extensions/core/electronAdapter.ts b/src/extensions/core/electronAdapter.ts index b3f3be155eb..578538918db 100644 --- a/src/extensions/core/electronAdapter.ts +++ b/src/extensions/core/electronAdapter.ts @@ -3,7 +3,7 @@ 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 { useToast } from '@/components/ui/toast' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { app } from '@/scripts/app' import { useDialogService } from '@/services/dialogService' @@ -17,7 +17,7 @@ void (async () => { const electronAPI = getElectronAPI() const desktopAppVersion = await electronAPI.getElectronVersion() const workflowStore = useWorkflowStore() - const toastStore = useToastStore() + const toastStore = useToast() const { staticUrls, buildDocsUrl } = useExternalLink() const onChangeRestartApp = async (newValue: unknown, oldValue: unknown) => { @@ -182,10 +182,8 @@ void (async () => { }) if (!updateInfo.isUpdateAvailable) { - toastStore.add({ - severity: 'info', - summary: t('desktopUpdate.noUpdateFound'), - life: 5_000 + toastStore.info(t('desktopUpdate.noUpdateFound'), { + duration: 5_000 }) return } @@ -202,19 +200,15 @@ void (async () => { await electronAPI.restartAndInstall() } catch (error) { log.error('Error installing update:', error) - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('desktopUpdate.errorInstallingUpdate') + toastStore.error(t('g.error'), { + description: t('desktopUpdate.errorInstallingUpdate') }) } } } catch (error) { log.error('Error checking for updates:', error) - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('desktopUpdate.errorCheckingUpdate') + toastStore.error(t('g.error'), { + description: t('desktopUpdate.errorCheckingUpdate') }) } } diff --git a/src/extensions/core/load3d.test.ts b/src/extensions/core/load3d.test.ts index b40f3cbe210..c8bc0a4a108 100644 --- a/src/extensions/core/load3d.test.ts +++ b/src/extensions/core/load3d.test.ts @@ -1,11 +1,11 @@ import { fromAny, fromPartial } from '@total-typescript/shoehorn' +import { useToast } from '@/components/ui/toast' import { beforeEach, describe, expect, it, vi } from 'vitest' import { defineComponent } from 'vue' import type { useLoad3d } from '@/composables/useLoad3d' import type { CameraState } from '@/extensions/core/load3d/interfaces' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' import type { ComfyNodeDef } from '@/schemas/nodeDefSchema' import type { ComfyApp } from '@/scripts/app' import { app } from '@/scripts/app' @@ -141,10 +141,6 @@ vi.mock(import('@/utils/litegraphUtil'), () => ({ isLoad3dNode: vi.fn(() => true) })) -vi.mock(import('@/lib/litegraph/src/litegraph'), () => ({ - LiteGraph: fromPartial({ ContextMenu: fromAny(vi.fn()) }) -})) - await import('@/extensions/core/load3d') const load3DExt = capture.getExtension('Comfy.Load3D') const preview3DExt = capture.getExtension('Comfy.Preview3D') @@ -459,9 +455,9 @@ describe('Comfy.Preview3D.nodeCreated', () => { await preview3DExt.nodeCreated!(node, app) node.onExecuted!({ result: [] }) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.unableToGetModelFilePath' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.unableToGetModelFilePath' + }) }) }) @@ -579,9 +575,9 @@ describe('Comfy.Load3D.getCustomWidgets LOAD_3D', () => { await flush() expect(load3d.loadModel).toHaveBeenCalledWith('/api/view') - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToLoadModel' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToLoadModel' + }) }) it('skips upload and clear buttons when the node has no model_file widget (e.g. Preview3DAdvanced)', async () => { @@ -1082,9 +1078,9 @@ describe('Comfy.Preview3DAdvanced.nodeCreated', () => { await preview3DAdvancedExt.nodeCreated!(node, app) node.onExecuted!({ result: [] }) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.unableToGetModelFilePath' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.unableToGetModelFilePath' + }) expect(configureForSaveMeshMock).not.toHaveBeenCalled() }) }) diff --git a/src/extensions/core/load3d.ts b/src/extensions/core/load3d.ts index 23ac56ccd17..9f3121ed981 100644 --- a/src/extensions/core/load3d.ts +++ b/src/extensions/core/load3d.ts @@ -37,7 +37,7 @@ import type { INumericWidget, IStringWidget } from '@/lib/litegraph/src/types/widgets' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import type { NodeExecutionOutput, NodeOutputWith @@ -94,7 +94,9 @@ async function handleModelUpload(files: FileList, node: LGraphNode) { const uploadPath = await Load3dUtils.uploadFile(files[0], subfolder) if (!uploadPath) { - useToastStore().addAlert(t('toastMessages.fileUploadFailed')) + useToast().warning('Alert', { + description: t('toastMessages.fileUploadFailed') + }) return } @@ -109,7 +111,9 @@ async function handleModelUpload(files: FileList, node: LGraphNode) { try { await load3d.loadModel(modelUrl) } catch { - useToastStore().addAlert(t('toastMessages.failedToLoadModel')) + useToast().warning('Alert', { + description: t('toastMessages.failedToLoadModel') + }) } }) @@ -124,7 +128,9 @@ async function handleModelUpload(files: FileList, node: LGraphNode) { markLoad3dSceneDirty(node) } catch (error) { console.error('Model upload failed:', error) - useToastStore().addAlert(t('toastMessages.fileUploadFailed')) + useToast().warning('Alert', { + description: t('toastMessages.fileUploadFailed') + }) } } @@ -142,7 +148,9 @@ async function handleResourcesUpload(files: FileList, node: LGraphNode) { markLoad3dSceneDirty(node) } catch (error) { console.error('Extra resources upload failed:', error) - useToastStore().addAlert(t('toastMessages.extraResourcesUploadFailed')) + useToast().warning('Alert', { + description: t('toastMessages.extraResourcesUploadFailed') + }) } } @@ -666,7 +674,7 @@ useExtensionService().registerExtension({ if (!filePath) { const msg = t('toastMessages.unableToGetModelFilePath') console.error(msg) - useToastStore().addAlert(msg) + useToast().warning('Alert', { description: msg }) } const cameraState = result?.[1] @@ -903,7 +911,7 @@ function createPreview3DAdvancedExtension( if (!reported) { const msg = t('toastMessages.unableToGetModelFilePath') console.error(msg) - useToastStore().addAlert(msg) + useToast().warning('Alert', { description: msg }) return } diff --git a/src/extensions/core/load3d/Load3dUtils.ts b/src/extensions/core/load3d/Load3dUtils.ts index 6e5e5c9cfdc..9154b0523a7 100644 --- a/src/extensions/core/load3d/Load3dUtils.ts +++ b/src/extensions/core/load3d/Load3dUtils.ts @@ -1,5 +1,5 @@ import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import { app } from '@/scripts/app' @@ -27,7 +27,7 @@ class Load3dUtils { if (resp.status !== 200) { const err = `Error uploading temp file: ${resp.status} - ${resp.statusText}` - useToastStore().addAlert(err) + useToast().warning('Alert', { description: err }) throw new Error(err) } @@ -50,7 +50,7 @@ class Load3dUtils { fileSizeMB.toFixed(2), 'MB' ) - useToastStore().addAlert(message) + useToast().warning('Alert', { description: message }) return undefined } @@ -75,15 +75,18 @@ class Load3dUtils { uploadPath = path } else { - useToastStore().addAlert(resp.status + ' - ' + resp.statusText) + useToast().warning('Alert', { + description: resp.status + ' - ' + resp.statusText + }) } } catch (error) { console.error('[Load3D] uploadFile: exception', error) - useToastStore().addAlert( - error instanceof Error - ? error.message - : t('toastMessages.fileUploadFailed') - ) + useToast().warning('Alert', { + description: + error instanceof Error + ? error.message + : t('toastMessages.fileUploadFailed') + }) } return uploadPath diff --git a/src/extensions/core/load3d/LoaderManager.test.ts b/src/extensions/core/load3d/LoaderManager.test.ts index 7c35cf96585..e6fef683a94 100644 --- a/src/extensions/core/load3d/LoaderManager.test.ts +++ b/src/extensions/core/load3d/LoaderManager.test.ts @@ -1,8 +1,8 @@ +import { useToast } from '@/components/ui/toast' import * as THREE from 'three' import { fromAny } from '@total-typescript/shoehorn' import { beforeEach, describe, expect, it, vi } from 'vitest' -import { useToastStore } from '@/platform/updates/common/toastStore' import { isGaussianSplatPLY } from '@/scripts/metadata/ply' import type { @@ -349,9 +349,9 @@ describe('LoaderManager', () => { await lm.loadModel('api/view?other=1') - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.couldNotDetermineFileType' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.couldNotDetermineFileType' + }) expect(modelManager.setupModel).not.toHaveBeenCalled() expect(meshLoad).not.toHaveBeenCalled() }) @@ -513,9 +513,9 @@ describe('LoaderManager', () => { 'modelLoadingEnd', null ) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.errorLoadingModel' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.errorLoadingModel' + }) expect(console.error).toHaveBeenCalled() }) @@ -531,9 +531,9 @@ describe('LoaderManager', () => { }) expect(console.error).toHaveBeenCalled() - expect(useToastStore().addAlert).not.toHaveBeenCalledWith( - 'toastMessages.errorLoadingModel' - ) + expect(useToast().warning).not.toHaveBeenCalledWith('Alert', { + description: 'toastMessages.errorLoadingModel' + }) }) it('detects a 404 from the response status field on three.js HttpError', async () => { @@ -547,9 +547,9 @@ describe('LoaderManager', () => { silentOnNotFound: true }) - expect(useToastStore().addAlert).not.toHaveBeenCalledWith( - 'toastMessages.errorLoadingModel' - ) + expect(useToast().warning).not.toHaveBeenCalledWith('Alert', { + description: 'toastMessages.errorLoadingModel' + }) }) it('still alerts on non-404 errors when silentOnNotFound is set', async () => { @@ -560,9 +560,9 @@ describe('LoaderManager', () => { silentOnNotFound: true }) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.errorLoadingModel' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.errorLoadingModel' + }) }) it('discards the result of a stale load when a newer one has started', async () => { @@ -665,7 +665,7 @@ describe('LoaderManager', () => { await Promise.all([firstPromise, secondPromise]) - expect(useToastStore().addAlert).not.toHaveBeenCalled() + expect(useToast().warning).not.toHaveBeenCalled() const endEmits = eventManager.emitEvent.mock.calls.filter( (call: unknown[]) => call[0] === 'modelLoadingEnd' ) diff --git a/src/extensions/core/load3d/LoaderManager.ts b/src/extensions/core/load3d/LoaderManager.ts index a160297ae68..e5fbbdbbe3c 100644 --- a/src/extensions/core/load3d/LoaderManager.ts +++ b/src/extensions/core/load3d/LoaderManager.ts @@ -1,7 +1,7 @@ import type * as THREE from 'three' import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { MeshModelAdapter } from './MeshModelAdapter' import { createAdapterRef, fetchModelData } from './ModelAdapter' @@ -112,7 +112,9 @@ export class LoaderManager implements LoaderManagerInterface { } if (!fileExtension) { - useToastStore().addAlert(t('toastMessages.couldNotDetermineFileType')) + useToast().warning('Alert', { + description: t('toastMessages.couldNotDetermineFileType') + }) return } @@ -140,7 +142,9 @@ export class LoaderManager implements LoaderManagerInterface { this.eventManager.emitEvent('modelLoadingEnd', null) console.error('Error loading model:', error) if (!(options?.silentOnNotFound && isNotFoundError(error))) { - useToastStore().addAlert(t('toastMessages.errorLoadingModel')) + useToast().warning('Alert', { + description: t('toastMessages.errorLoadingModel') + }) } } } diff --git a/src/extensions/core/load3d/ModelExporter.test.ts b/src/extensions/core/load3d/ModelExporter.test.ts index 7f1c6561036..19382344304 100644 --- a/src/extensions/core/load3d/ModelExporter.test.ts +++ b/src/extensions/core/load3d/ModelExporter.test.ts @@ -1,10 +1,10 @@ -import * as THREE from 'three' import { fromAny } from '@total-typescript/shoehorn' +import * as THREE from 'three' import { describe, expect, it, vi } from 'vitest' import { downloadBlob } from '@/base/common/downloadUtil' +import { useToast } from '@/components/ui/toast' import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' import { ModelExporter } from './ModelExporter' @@ -141,9 +141,9 @@ describe('ModelExporter', () => { await expect( ModelExporter.downloadFromURL('http://example.com/cube.glb', 'cube.glb') ).rejects.toThrow('network') - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToDownloadFile' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToDownloadFile' + }) vi.unstubAllGlobals() }) @@ -156,9 +156,9 @@ describe('ModelExporter', () => { ModelExporter.downloadFromURL('http://example.com/cube.glb', 'cube.glb') ).rejects.toThrow('HTTP 404') expect(downloadBlob).not.toHaveBeenCalled() - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToDownloadFile' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToDownloadFile' + }) vi.unstubAllGlobals() }) }) @@ -211,9 +211,9 @@ describe('ModelExporter', () => { const settled = Promise.allSettled([promise]) await vi.runAllTimersAsync() expect(await settled).toMatchObject([rejectedWith('parse fail')]) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToExportModel' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToExportModel' + }) expect(t).toHaveBeenCalledWith('toastMessages.failedToExportModel', { format: 'GLB' }) @@ -256,9 +256,9 @@ describe('ModelExporter', () => { const settled = Promise.allSettled([promise]) await vi.runAllTimersAsync() expect(await settled).toMatchObject([rejectedWith('obj fail')]) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToExportModel' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToExportModel' + }) expect(t).toHaveBeenCalledWith('toastMessages.failedToExportModel', { format: 'OBJ' }) @@ -301,9 +301,9 @@ describe('ModelExporter', () => { const settled = Promise.allSettled([promise]) await vi.runAllTimersAsync() expect(await settled).toMatchObject([rejectedWith('stl fail')]) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToExportModel' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToExportModel' + }) expect(t).toHaveBeenCalledWith('toastMessages.failedToExportModel', { format: 'STL' }) @@ -330,7 +330,7 @@ describe('ModelExporter', () => { ModelExporter.exportDirect(null, 'out.spz', 'spz') ).rejects.toThrow('No source file available to export as spz') expect(downloadBlob).not.toHaveBeenCalled() - expect(useToastStore().addAlert).not.toHaveBeenCalled() + expect(useToast().warning).not.toHaveBeenCalled() }) }) @@ -369,9 +369,9 @@ describe('ModelExporter', () => { const settled = Promise.allSettled([promise]) await vi.runAllTimersAsync() expect(await settled).toMatchObject([rejectedWith('fbx fail')]) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToExportModel' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToExportModel' + }) expect(t).toHaveBeenCalledWith('toastMessages.failedToExportModel', { format: 'FBX' }) diff --git a/src/extensions/core/load3d/ModelExporter.ts b/src/extensions/core/load3d/ModelExporter.ts index 6d340008713..0d6f4052d13 100644 --- a/src/extensions/core/load3d/ModelExporter.ts +++ b/src/extensions/core/load3d/ModelExporter.ts @@ -6,7 +6,7 @@ import { STLExporter } from 'three/examples/jsm/exporters/STLExporter' import { downloadBlob } from '@/base/common/downloadUtil' import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' export class ModelExporter { static detectFormatFromURL(url: string): string | null { @@ -46,7 +46,9 @@ export class ModelExporter { downloadBlob(desiredFilename, blob) } catch (error) { console.error('Error downloading from URL:', error) - useToastStore().addAlert(t('toastMessages.failedToDownloadFile')) + useToast().warning('Alert', { + description: t('toastMessages.failedToDownloadFile') + }) throw error } } @@ -83,9 +85,9 @@ export class ModelExporter { ModelExporter.saveArrayBuffer(result, filename) } catch (error) { console.error('Error exporting GLB:', error) - useToastStore().addAlert( - t('toastMessages.failedToExportModel', { format: 'GLB' }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToExportModel', { format: 'GLB' }) + }) throw error } } @@ -111,9 +113,9 @@ export class ModelExporter { ModelExporter.saveString(result, filename) } catch (error) { console.error('Error exporting OBJ:', error) - useToastStore().addAlert( - t('toastMessages.failedToExportModel', { format: 'OBJ' }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToExportModel', { format: 'OBJ' }) + }) throw error } } @@ -146,9 +148,9 @@ export class ModelExporter { ) } catch (error) { console.error('Error exporting FBX:', error) - useToastStore().addAlert( - t('toastMessages.failedToExportModel', { format: 'FBX' }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToExportModel', { format: 'FBX' }) + }) throw error } } @@ -174,9 +176,9 @@ export class ModelExporter { ModelExporter.saveString(result, filename) } catch (error) { console.error('Error exporting STL:', error) - useToastStore().addAlert( - t('toastMessages.failedToExportModel', { format: 'STL' }) - ) + useToast().warning('Alert', { + description: t('toastMessages.failedToExportModel', { format: 'STL' }) + }) throw error } } diff --git a/src/extensions/core/load3d/exportMenuHelper.test.ts b/src/extensions/core/load3d/exportMenuHelper.test.ts index 99d296649f1..6cc4be35c08 100644 --- a/src/extensions/core/load3d/exportMenuHelper.test.ts +++ b/src/extensions/core/load3d/exportMenuHelper.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest' +import { useToast } from '@/components/ui/toast' import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' import { LiteGraph } from '@/lib/litegraph/src/litegraph' import type Load3d from './Load3d' @@ -106,17 +106,14 @@ describe('createExportMenuItems', () => { item.callback() await vi.waitFor(() => expect(exportModel).toHaveBeenCalledWith(value)) await vi.waitFor(() => - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'success', - summary: 'toastMessages.exportSuccess' - }) + expect(useToast().success).toHaveBeenCalledWith( + 'toastMessages.exportSuccess' ) ) expect(t).toHaveBeenCalledWith('toastMessages.exportSuccess', { format: label }) - expect(useToastStore().addAlert).not.toHaveBeenCalled() + expect(useToast().warning).not.toHaveBeenCalled() } ) @@ -136,9 +133,9 @@ describe('createExportMenuItems', () => { glb.callback() await vi.waitFor(() => - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.failedToExportModel' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.failedToExportModel' + }) ) expect(t).toHaveBeenCalledWith('toastMessages.failedToExportModel', { format: 'GLB' @@ -147,6 +144,6 @@ describe('createExportMenuItems', () => { 'Export failed:', expect.any(Error) ) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().success).not.toHaveBeenCalled() }) }) diff --git a/src/extensions/core/load3d/exportMenuHelper.ts b/src/extensions/core/load3d/exportMenuHelper.ts index 871648f6385..89ae722fa07 100644 --- a/src/extensions/core/load3d/exportMenuHelper.ts +++ b/src/extensions/core/load3d/exportMenuHelper.ts @@ -1,6 +1,6 @@ import { t } from '@/i18n' import type { IContextMenuValue } from '@/lib/litegraph/src/types/contextMenu' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import type Load3d from '@/extensions/core/load3d/Load3d' import { LiteGraph } from '@/lib/litegraph/src/litegraph' @@ -31,19 +31,18 @@ export function createExportMenuItems( void (async () => { try { await load3d.exportModel(format.value) - useToastStore().add({ - severity: 'success', - summary: t('toastMessages.exportSuccess', { + useToast().success( + t('toastMessages.exportSuccess', { format: format.label }) - }) + ) } catch (error) { console.error('Export failed:', error) - useToastStore().addAlert( - t('toastMessages.failedToExportModel', { + useToast().warning('Alert', { + description: t('toastMessages.failedToExportModel', { format: format.label }) - ) + }) } })() } diff --git a/src/extensions/core/load3dPreviewExtensions.test.ts b/src/extensions/core/load3dPreviewExtensions.test.ts index dd2ba97aaba..96b9118d9e8 100644 --- a/src/extensions/core/load3dPreviewExtensions.test.ts +++ b/src/extensions/core/load3dPreviewExtensions.test.ts @@ -1,9 +1,9 @@ import { fromAny, fromPartial } from '@total-typescript/shoehorn' +import { useToast } from '@/components/ui/toast' import { beforeEach, describe, expect, it, vi } from 'vitest' import type { useLoad3d } from '@/composables/useLoad3d' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' import { app } from '@/scripts/app' import type { useExtensionService } from '@/services/extensionService' import type { useLoad3dService } from '@/services/load3dService' @@ -412,9 +412,9 @@ describe('Comfy.PreviewGaussianSplat.nodeCreated', () => { await splatExt.nodeCreated!(node, app) node.onExecuted!({ result: [] }) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'toastMessages.unableToGetModelFilePath' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'toastMessages.unableToGetModelFilePath' + }) }) }) diff --git a/src/extensions/core/load3dPreviewExtensions.ts b/src/extensions/core/load3dPreviewExtensions.ts index b1fa6ea19fa..84b6d11181a 100644 --- a/src/extensions/core/load3dPreviewExtensions.ts +++ b/src/extensions/core/load3dPreviewExtensions.ts @@ -14,7 +14,7 @@ import { readModel3DOutput } from '@/extensions/core/load3d/model3dOutput' import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' import type { IContextMenuValue } from '@/lib/litegraph/src/types/contextMenu' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import type { NodeExecutionOutput } from '@/platform/remote/comfyui/execution/types' import { app } from '@/scripts/app' import { useExtensionService } from '@/services/extensionService' @@ -201,7 +201,7 @@ function createPreview3DExtension( if (!reported) { const msg = t('toastMessages.unableToGetModelFilePath') console.error(msg) - useToastStore().addAlert(msg) + useToast().warning('Alert', { description: msg }) return } diff --git a/src/extensions/core/nodeTemplates.ts b/src/extensions/core/nodeTemplates.ts index a0d287aea81..c05d0e49f55 100644 --- a/src/extensions/core/nodeTemplates.ts +++ b/src/extensions/core/nodeTemplates.ts @@ -3,7 +3,7 @@ import { t } from '@/i18n' import type { IContextMenuValue } from '@/lib/litegraph/src/types/contextMenu' import type { LGraphCanvas } from '@/lib/litegraph/src/litegraph' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useDialogService } from '@/services/dialogService' import type { ComfyExtension } from '@/types/comfy' import { deserialiseAndCreate } from '@/utils/vintageClipboard' @@ -126,9 +126,9 @@ class ManageTemplates extends ComfyDialog { await api.storeUserData(file, templates, { stringify: false }) } catch (error) { console.error(error) - useToastStore().addAlert( - error instanceof Error ? error.message : String(error) - ) + useToast().warning('Alert', { + description: error instanceof Error ? error.message : String(error) + }) } } @@ -158,7 +158,9 @@ class ManageTemplates extends ComfyDialog { exportAll() { if (this.templates.length == 0) { - useToastStore().addAlert(t('toastMessages.noTemplatesToExport')) + useToast().warning('Alert', { + description: t('toastMessages.noTemplatesToExport') + }) return } @@ -406,7 +408,9 @@ const ext: ComfyExtension = { data = JSON.parse(template.data) } catch (error) { console.error('Failed to parse node template data', error) - useToastStore().addAlert(t('toastMessages.invalidTemplateData')) + useToast().warning('Alert', { + description: t('toastMessages.invalidTemplateData') + }) return } diff --git a/src/extensions/core/uploadAudio.test.ts b/src/extensions/core/uploadAudio.test.ts index a90820820cd..098c657368f 100644 --- a/src/extensions/core/uploadAudio.test.ts +++ b/src/extensions/core/uploadAudio.test.ts @@ -5,7 +5,7 @@ import type { LGraphNode } from '@/lib/litegraph/src/litegraph' import { api } from '@/scripts/api' import { app } from '@/scripts/app' import type { useAudioService } from '@/services/audioService' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { reportError } from '@/platform/telemetry/reportError' const { @@ -214,9 +214,9 @@ describe('Comfy.UploadAudio AUDIOUPLOAD widget', () => { const result = await capturedDragDrop!([createFile()]) expect(result).toEqual([]) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'g.uploadAlreadyInProgress' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'g.uploadAlreadyInProgress' + }) expect(api.fetchApi).not.toHaveBeenCalled() }) @@ -230,7 +230,9 @@ describe('Comfy.UploadAudio AUDIOUPLOAD widget', () => { expect(node.isUploading).toBe(false) expect(audioWidget.value).toBe('previous.mp3') - expect(useToastStore().addAlert).toHaveBeenCalledWith('500 - Server Error') + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: '500 - Server Error' + }) expect(node.graph?.setDirtyCanvas).toHaveBeenCalledWith(true) }) @@ -247,7 +249,9 @@ describe('Comfy.UploadAudio AUDIOUPLOAD widget', () => { expect(node.isUploading).toBe(false) expect(audioWidget.value).toBe('previous.mp3') - expect(useToastStore().addAlert).toHaveBeenCalledWith(error.message) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: error.message + }) expect(node.graph?.setDirtyCanvas).toHaveBeenCalledWith(true) }) @@ -342,7 +346,7 @@ describe('Comfy.RecordAudio AUDIO_RECORD widget', () => { expect(mockMediaRecorderStart).toHaveBeenCalledTimes(1) expect(recordWidget.label).toBe('g.stopRecording') expect(reportError).not.toHaveBeenCalled() - expect(useToastStore().addAlert).not.toHaveBeenCalled() + expect(useToast().warning).not.toHaveBeenCalled() }) it('reports a recorder start failure after the microphone was granted', async () => { @@ -385,12 +389,12 @@ describe('Comfy.RecordAudio AUDIO_RECORD widget', () => { RECORDER_FAILURE_REPORT ) expect(mockStopAllTracks).toHaveBeenCalledWith(stream) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'g.recordingFailedToStart' - ) - expect(useToastStore().addAlert).not.toHaveBeenCalledWith( - 'g.micPermissionDenied' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'g.recordingFailedToStart' + }) + expect(useToast().warning).not.toHaveBeenCalledWith('Alert', { + description: 'g.micPermissionDenied' + }) expect(recordWidget.label).toBe('g.startRecording') }) @@ -407,9 +411,9 @@ describe('Comfy.RecordAudio AUDIO_RECORD widget', () => { await pressRecord() - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'g.micPermissionDenied' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'g.micPermissionDenied' + }) expect(reportError).not.toHaveBeenCalled() expect(mockMediaRecorderConstruct).not.toHaveBeenCalled() }) @@ -426,12 +430,12 @@ describe('Comfy.RecordAudio AUDIO_RECORD widget', () => { accessError, RECORDER_FAILURE_REPORT ) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'g.recordingFailedToStart' - ) - expect(useToastStore().addAlert).not.toHaveBeenCalledWith( - 'g.micPermissionDenied' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'g.recordingFailedToStart' + }) + expect(useToast().warning).not.toHaveBeenCalledWith('Alert', { + description: 'g.micPermissionDenied' + }) expect(mockMediaRecorderConstruct).not.toHaveBeenCalled() }) }) diff --git a/src/extensions/core/uploadAudio.ts b/src/extensions/core/uploadAudio.ts index 014b615560a..91885cd356f 100644 --- a/src/extensions/core/uploadAudio.ts +++ b/src/extensions/core/uploadAudio.ts @@ -11,7 +11,7 @@ import type { IStringWidget } from '@/lib/litegraph/src/types/widgets' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { getResourceURL, splitFilePath @@ -84,11 +84,13 @@ async function uploadFile( } return true } else { - useToastStore().addAlert(resp.status + ' - ' + resp.statusText) + useToast().warning('Alert', { + description: resp.status + ' - ' + resp.statusText + }) return false } } catch (error) { - useToastStore().addAlert(toError(error).message) + useToast().warning('Alert', { description: toError(error).message }) return false } } @@ -249,7 +251,9 @@ app.registerExtension({ if (!files.length) return files if (node.isUploading) { - useToastStore().addAlert(t('g.uploadAlreadyInProgress')) + useToast().warning('Alert', { + description: t('g.uploadAlreadyInProgress') + }) return [] } @@ -346,7 +350,9 @@ app.registerExtension({ }, level: 'error' }) - useToastStore().addAlert(t('g.recordingFailedToStart')) + useToast().warning('Alert', { + description: t('g.recordingFailedToStart') + }) if (mediaRecorder) { try { @@ -378,7 +384,7 @@ app.registerExtension({ const audioSrc = audioUIWidget.element.src if (!audioSrc) { - useToastStore().addAlert(t('g.noAudioRecorded')) + useToast().warning('Alert', { description: t('g.noAudioRecorded') }) return '' } @@ -407,7 +413,9 @@ app.registerExtension({ err.name === 'NotAllowedError' ) { console.error('Error accessing microphone:', err) - useToastStore().addAlert(t('g.micPermissionDenied')) + useToast().warning('Alert', { + description: t('g.micPermissionDenied') + }) useAudioService().stopAllTracks(currentStream) currentStream = null } else { diff --git a/src/extensions/core/webcamCapture.ts b/src/extensions/core/webcamCapture.ts index 316569e13bc..9b326fdc414 100644 --- a/src/extensions/core/webcamCapture.ts +++ b/src/extensions/core/webcamCapture.ts @@ -1,6 +1,6 @@ import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useNodeOutputStore } from '@/stores/nodeOutputStore' import { api } from '../../scripts/api' @@ -125,7 +125,7 @@ app.registerExtension({ capture() } else if (!node.imgs?.length) { const err = `No webcam image captured` - useToastStore().addAlert(err) + useToast().warning('Alert', { description: err }) throw new Error(err) } @@ -147,7 +147,7 @@ app.registerExtension({ }) if (resp.status !== 200) { const err = `Error uploading camera image: ${resp.status} - ${resp.statusText}` - useToastStore().addAlert(err) + useToast().warning('Alert', { description: err }) throw new Error(err) } const data = await resp.json() diff --git a/src/main.ts b/src/main.ts index 918a22b8441..38bae8185e7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,7 +5,6 @@ import { captureMessage } from '@sentry/vue' import { createPinia } from 'pinia' import 'primeicons/primeicons.css' import PrimeVue from 'primevue/config' -import ToastService from 'primevue/toastservice' import Tooltip from 'primevue/tooltip' import { createApp } from 'vue' @@ -31,7 +30,7 @@ import '@/lib/litegraph/public/css/litegraph.css' import router from '@/router' import { isDesktop, isNightly } from '@/platform/distribution/types' import { stripPaymentReturnParams } from '@/platform/cloud/subscription/utils/paymentReturnUrl' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useBootstrapStore } from '@/stores/bootstrapStore' import App from './App.vue' @@ -127,11 +126,7 @@ setAssertReporter( reportAssertFailure(message, context) } if (isNightly) { - useToastStore(pinia).add({ - severity: 'warn', - summary: 'Assertion failed', - detail: message - }) + useToast(pinia).warning('Assertion failed', { description: message }) } }, { forwardsToRum: isCloud } @@ -163,7 +158,6 @@ app } } }) - .use(ToastService) .use(pinia) .use(i18n) diff --git a/src/platform/assets/components/ModelImportProgressDialog.test.ts b/src/platform/assets/components/ModelImportProgressDialog.test.ts index f263d1d727e..5336a08f8de 100644 --- a/src/platform/assets/components/ModelImportProgressDialog.test.ts +++ b/src/platform/assets/components/ModelImportProgressDialog.test.ts @@ -5,8 +5,8 @@ import { describe, expect, it, vi } from 'vitest' import { nextTick } from 'vue' import enMessages from '@/locales/en/main.json' with { type: 'json' } +import { useToast } from '@/components/ui/toast' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useAssetDownloadStore } from '@/stores/assetDownloadStore' import ModelImportProgressDialog from './ModelImportProgressDialog.vue' @@ -52,8 +52,7 @@ describe('ModelImportProgressDialog cancellation', () => { it('reports cancellation failures and shows the error toast', async () => { const user = userEvent.setup() const store = renderDialog() - const toastStore = useToastStore() - const addToast = vi.spyOn(toastStore, 'add') + const errorToast = vi.spyOn(useToast(), 'error') const error = new Error('Cancellation unavailable') vi.spyOn(store, 'cancelDownload').mockResolvedValue({ ok: false, error }) @@ -66,10 +65,8 @@ describe('ModelImportProgressDialog cancellation', () => { errorType: 'asset_download_cancellation_failure', logToConsole: false }) - expect(addToast).toHaveBeenCalledWith({ - severity: 'error', - summary: 'Error', - detail: 'Cancellation unavailable' + expect(errorToast).toHaveBeenCalledWith('Error', { + description: 'Cancellation unavailable' }) }) }) diff --git a/src/platform/assets/composables/openModelLibraryBrowser.ts b/src/platform/assets/composables/openModelLibraryBrowser.ts index b2bf0cac1ad..495e144d5a2 100644 --- a/src/platform/assets/composables/openModelLibraryBrowser.ts +++ b/src/platform/assets/composables/openModelLibraryBrowser.ts @@ -3,12 +3,12 @@ import { useFeatureFlags } from '@/composables/useFeatureFlags' import { t } from '@/i18n' import { useAssetBrowserDialog } from '@/platform/assets/composables/useAssetBrowserDialog' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' export async function openModelLibraryBrowser(): Promise { if (!useFeatureFlags().flags.assetsEnabled) return - const toastStore = useToastStore() + const toastStore = useToast() const assetBrowserDialog = useAssetBrowserDialog() await assetBrowserDialog.browse({ assetType: 'models', @@ -22,10 +22,8 @@ export async function openModelLibraryBrowser(): Promise { tags: { code: error.code }, context: { assetId: error.assetId, details: error.details } }) - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('assetBrowser.failedToCreateNode') + toastStore.error(t('g.error'), { + description: t('assetBrowser.failedToCreateNode') }) } } diff --git a/src/platform/assets/composables/useAssetDownload.ts b/src/platform/assets/composables/useAssetDownload.ts index 5df612288d4..b1c14aa7284 100644 --- a/src/platform/assets/composables/useAssetDownload.ts +++ b/src/platform/assets/composables/useAssetDownload.ts @@ -2,7 +2,7 @@ import { useI18n } from 'vue-i18n' import { downloadFile, downloadFileAsBlob } from '@/base/common/downloadUtil' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' interface DirectAssetDownload { mode: 'direct' @@ -22,7 +22,7 @@ export type AssetDownload = DirectAssetDownload | FetchedAssetDownload export function useAssetDownload() { const { t } = useI18n() - const toast = useToastStore() + const toast = useToast() async function downloadFiles(files: AssetDownload[]): Promise { const pending = files.map((file) => { @@ -49,11 +49,9 @@ export function useAssetDownload() { const successCount = files.length - failures.length if (successCount > 0) { - toast.add({ - severity: 'success', - summary: t('g.success'), - detail: t('mediaAsset.selection.downloadsStarted', successCount), - life: 2000 + toast.success(t('g.success'), { + description: t('mediaAsset.selection.downloadsStarted', successCount), + duration: 2000 }) } @@ -65,10 +63,8 @@ export function useAssetDownload() { context: { filename: failure.filename } }) } - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('progressToast.downloadsFailed', failures.length) + toast.error(t('g.error'), { + description: t('progressToast.downloadsFailed', failures.length) }) } } diff --git a/src/platform/assets/composables/useAssetZipExport.ts b/src/platform/assets/composables/useAssetZipExport.ts index 36eef572ed3..b1865be93ca 100644 --- a/src/platform/assets/composables/useAssetZipExport.ts +++ b/src/platform/assets/composables/useAssetZipExport.ts @@ -1,14 +1,14 @@ import type { CreateAssetExportData } from '@comfyorg/ingest-types' import { useI18n } from 'vue-i18n' +import { useToast } from '@/components/ui/toast' import { assetService } from '@/platform/assets/services/assetService' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useAssetExportStore } from '@/stores/assetExportStore' export function useAssetZipExport() { const { t } = useI18n() - const toast = useToastStore() + const toast = useToast() async function startZipExport( request: CreateAssetExportData['body'], @@ -17,15 +17,13 @@ export function useAssetZipExport() { try { const { task_id } = await assetService.createAssetExport(request) useAssetExportStore().trackExport(task_id) - toast.add({ - severity: 'info', - summary: t('exportToast.exportStarted'), - detail: t( + toast.info(t('exportToast.exportStarted'), { + description: t( 'mediaAsset.selection.exportStarted', { count: fileCount }, fileCount ), - life: 3000 + duration: 3000 }) } catch (error) { reportError(error, { @@ -33,10 +31,8 @@ export function useAssetZipExport() { surface: 'assets', context: { count: fileCount } }) - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('exportToast.exportFailedSingle') + toast.error(t('g.error'), { + description: t('exportToast.exportFailedSingle') }) } } diff --git a/src/platform/assets/composables/useMediaAssetActions.test.ts b/src/platform/assets/composables/useMediaAssetActions.test.ts index 51a351a6ef5..d44a135fcae 100644 --- a/src/platform/assets/composables/useMediaAssetActions.test.ts +++ b/src/platform/assets/composables/useMediaAssetActions.test.ts @@ -4,10 +4,9 @@ import { useAssetExportStore } from '@/stores/assetExportStore' import { useNodeOutputStore } from '@/stores/nodeOutputStore' import { useNodeDefStore } from '@/stores/nodeDefStore' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' -import { useToastStore } from '@/platform/updates/common/toastStore' import type { CreateAssetExportData } from '@comfyorg/ingest-types' import { fromAny, fromPartial } from '@total-typescript/shoehorn' -import { useToast } from 'primevue/usetoast' +import { useToast } from '@/components/ui/toast' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type { App } from 'vue' import { createApp, defineComponent, h, provide, ref } from 'vue' @@ -49,17 +48,6 @@ vi.mock(import('@/platform/distribution/types'), () => ({ } })) -vi.mock( - import('primevue/usetoast'), - - () => { - const add = vi.fn() - return { - useToast: () => ({ add }) - } - } -) - const mockShowDialog = vi.hoisted(() => vi.fn()) const mockInvalidateModelsForCategory = vi.hoisted(() => vi.fn()) @@ -443,15 +431,19 @@ describe('useMediaAssetActions', () => { .mocked(useLitegraphService()) .addNodeOnGraph.mock.calls.map(([, options]) => options) ).toEqual([{ pos: [100, 100] }, { pos: [150, 150] }]) - expect(useToast().add).toHaveBeenCalledWith({ - severity: 'warn', - summary: i18n.global.t('g.warning'), - detail: i18n.global.t('mediaAsset.selection.partialAddNodesSuccess', { - succeeded: 2, - failed: 1 - }), - life: 3000 - }) + expect(useToast().warning).toHaveBeenCalledWith( + i18n.global.t('g.warning'), + { + description: i18n.global.t( + 'mediaAsset.selection.partialAddNodesSuccess', + { + succeeded: 2, + failed: 1 + } + ), + duration: 3000 + } + ) unmount() }) }) @@ -543,9 +535,7 @@ describe('useMediaAssetActions', () => { expect(mockLoadApiJson).toHaveBeenCalledWith(apiPrompt, 'open.json') expect(mockOpenWorkflowAction).not.toHaveBeenCalled() - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'success' }) - ) + expect(useToast().success).toHaveBeenCalled() }) it('warns when loading the stored API graph fails', async () => { @@ -559,8 +549,9 @@ describe('useMediaAssetActions', () => { await actions.openWorkflow(createMockAsset()) - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'warn', detail: 'boom' }) + expect(useToast().warning).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: 'boom' }) ) }) @@ -576,8 +567,9 @@ describe('useMediaAssetActions', () => { await actions.openWorkflow(createMockAsset()) - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'warn', detail: 'network down' }) + expect(useToast().warning).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: 'network down' }) ) }) @@ -591,9 +583,7 @@ describe('useMediaAssetActions', () => { await actions.openWorkflow(createMockAsset()) expect(mockLoadApiJson).not.toHaveBeenCalled() - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'warn' }) - ) + expect(useToast().warning).toHaveBeenCalled() }) }) @@ -611,9 +601,7 @@ describe('useMediaAssetActions', () => { await actions.openMultipleWorkflows([createMockAsset()]) expect(mockLoadApiJson).toHaveBeenCalledWith(apiPrompt, 'bulk.json') - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'success' }) - ) + expect(useToast().success).toHaveBeenCalled() }) }) @@ -639,7 +627,7 @@ describe('useMediaAssetActions', () => { await actions.exportWorkflow(createMockAsset()) - expect(useToast().add).not.toHaveBeenCalled() + expect(useToast().success).not.toHaveBeenCalled() }) it('shows a success toast on successful export', async () => { @@ -648,9 +636,7 @@ describe('useMediaAssetActions', () => { await actions.exportWorkflow(createMockAsset()) - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'success' }) - ) + expect(useToast().success).toHaveBeenCalled() }) it('shows an error toast on actual failure', async () => { @@ -659,9 +645,7 @@ describe('useMediaAssetActions', () => { await actions.exportWorkflow(createMockAsset()) - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(useToast().error).toHaveBeenCalled() }) it('shows a warning toast when the workflow is missing', async () => { @@ -670,9 +654,7 @@ describe('useMediaAssetActions', () => { await actions.exportWorkflow(createMockAsset()) - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'warn' }) - ) + expect(useToast().warning).toHaveBeenCalled() }) it('shows no toast when every asset in a bulk export is cancelled', async () => { @@ -684,7 +666,7 @@ describe('useMediaAssetActions', () => { createMockAsset({ id: 'b' }) ]) - expect(useToast().add).not.toHaveBeenCalled() + expect(useToast().success).not.toHaveBeenCalled() }) it('shows a success toast for the succeeded subset when some bulk exports are cancelled', async () => { @@ -698,9 +680,7 @@ describe('useMediaAssetActions', () => { createMockAsset({ id: 'b' }) ]) - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'success' }) - ) + expect(useToast().success).toHaveBeenCalled() }) it('shows a partial-success warning toast when some bulk exports fail outright', async () => { @@ -714,9 +694,7 @@ describe('useMediaAssetActions', () => { createMockAsset({ id: 'b' }) ]) - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'warn' }) - ) + expect(useToast().warning).toHaveBeenCalled() }) }) @@ -825,17 +803,15 @@ describe('useMediaAssetActions', () => { expect(mockDownloadFile).toHaveBeenCalledTimes(2) await vi.waitFor(() => { - expect(useToastStore().add).toHaveBeenCalledWith( + expect(useToast().success).toHaveBeenCalledWith( + 'Success', expect.objectContaining({ - severity: 'success', - detail: 'Started downloading 1 file' + description: 'Started downloading 1 file' }) ) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: '1 download failed' - }) + expect(useToast().error).toHaveBeenCalledWith( + 'Error', + expect.objectContaining({ description: '1 download failed' }) ) }) expect(mockReportError).toHaveBeenCalledWith(failure, { @@ -1424,10 +1400,12 @@ describe('useMediaAssetActions', () => { expect(mockCreateAssetExport).toHaveBeenCalledTimes(1) }) + const { info } = useToast() await vi.waitFor(() => { - expect(useToastStore().add).toHaveBeenCalledWith( + expect(info).toHaveBeenCalledWith( + 'Preparing ZIP download...', expect.objectContaining({ - detail: i18n.global.t( + description: i18n.global.t( 'mediaAsset.selection.exportStarted', { count }, count @@ -1632,12 +1610,17 @@ describe('useMediaAssetActions', () => { expect(mockDeleteAsset.mock.invocationCallOrder[0]).toBeLessThan( mockSetAssetDeleting.mock.invocationCallOrder[1] ) - expect(useToast().add).toHaveBeenCalledWith({ - severity: 'success', - summary: i18n.global.t('mediaAsset.assetDelete.success'), - detail: i18n.global.t('mediaAsset.assetsDeleted', { total: 1 }, 1), - life: 2000 - }) + expect(useToast().success).toHaveBeenCalledWith( + i18n.global.t('mediaAsset.assetDelete.success'), + { + description: i18n.global.t( + 'mediaAsset.assetsDeleted', + { total: 1 }, + 1 + ), + duration: 2000 + } + ) unmount() }) @@ -1660,9 +1643,7 @@ describe('useMediaAssetActions', () => { expect(api.deleteItem).toHaveBeenCalledWith('history', 'job-1') expect(mockDeleteAsset).not.toHaveBeenCalled() - expect(useToast().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'success' }) - ) + expect(useToast().success).toHaveBeenCalled() }) }) @@ -2044,12 +2025,17 @@ describe('useMediaAssetActions', () => { expect(mockInputAssets.items.map((item) => item.id)).toEqual([ 'asset-503' ]) - expect(useToast().add).toHaveBeenCalledWith({ - severity: 'error', - summary: i18n.global.t('mediaAsset.assetDelete.error'), - detail: i18n.global.t('mediaAsset.assetsDeleted', { total: 1 }, 0), - life: 5000 - }) + expect(useToast().error).toHaveBeenCalledWith( + i18n.global.t('mediaAsset.assetDelete.error'), + { + description: i18n.global.t( + 'mediaAsset.assetsDeleted', + { total: 1 }, + 0 + ), + duration: 5000 + } + ) expect(mockMarkMissingMedia).not.toHaveBeenCalled() expect(mockClearWidgetValues).not.toHaveBeenCalled() @@ -2057,12 +2043,17 @@ describe('useMediaAssetActions', () => { expect(mockDeleteAsset).toHaveBeenCalledTimes(2) expect(mockInputAssets.items).toEqual([]) - expect(useToast().add).toHaveBeenLastCalledWith({ - severity: 'success', - summary: i18n.global.t('mediaAsset.assetDelete.success'), - detail: i18n.global.t('mediaAsset.assetsDeleted', { total: 1 }, 1), - life: 2000 - }) + expect(useToast().success).toHaveBeenLastCalledWith( + i18n.global.t('mediaAsset.assetDelete.success'), + { + description: i18n.global.t( + 'mediaAsset.assetsDeleted', + { total: 1 }, + 1 + ), + duration: 2000 + } + ) }) it('cleans up only the succeeded assets and clears every overlay when part of a batch fails', async () => { @@ -2106,12 +2097,17 @@ describe('useMediaAssetActions', () => { succeededVariants ) expect(mockCaptureCanvasState).toHaveBeenCalledTimes(1) - expect(useToast().add).toHaveBeenCalledWith({ - severity: 'warn', - summary: i18n.global.t('mediaAsset.assetDelete.warn'), - detail: i18n.global.t('mediaAsset.assetsDeleted', { total: 3 }, 2), - life: 5000 - }) + expect(useToast().warning).toHaveBeenCalledWith( + i18n.global.t('mediaAsset.assetDelete.warn'), + { + description: i18n.global.t( + 'mediaAsset.assetsDeleted', + { total: 3 }, + 2 + ), + duration: 5000 + } + ) const flagsById: Record = {} for (const [id, flag] of mockSetAssetDeleting.mock.calls) { diff --git a/src/platform/assets/composables/useMediaAssetActions.ts b/src/platform/assets/composables/useMediaAssetActions.ts index 3d867ec277a..78e6f71ddc3 100644 --- a/src/platform/assets/composables/useMediaAssetActions.ts +++ b/src/platform/assets/composables/useMediaAssetActions.ts @@ -1,5 +1,5 @@ import { uniqBy } from 'es-toolkit' -import { useToast } from 'primevue/usetoast' +import { useToast } from '@/components/ui/toast' import { inject } from 'vue' import { useI18n } from 'vue-i18n' @@ -251,11 +251,9 @@ export function useMediaAssetActions() { (getAssetType(targetAsset) === 'output' ? targetAsset.id : undefined) if (!jobId) { - toast.add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('mediaAsset.noJobIdFound'), - life: 2000 + toast.warning(t('g.warning'), { + description: t('mediaAsset.noJobIdFound'), + duration: 2000 }) return } @@ -277,11 +275,9 @@ export function useMediaAssetActions() { ) if (!nodeType || !widgetName) { - toast.add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('mediaAsset.unsupportedFileType'), - life: 2000 + toast.warning(t('g.warning'), { + description: t('mediaAsset.unsupportedFileType'), + duration: 2000 }) return } @@ -295,10 +291,8 @@ export function useMediaAssetActions() { ) if (!node) { - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('mediaAsset.failedToCreateNode') + toast.error(t('g.error'), { + description: t('mediaAsset.failedToCreateNode') }) return } @@ -312,11 +306,9 @@ export function useMediaAssetActions() { } node.graph?.setDirtyCanvas(true, true) - toast.add({ - severity: 'success', - summary: t('g.success'), - detail: t('mediaAsset.nodeAddedToWorkflow', { nodeType }), - life: 2000 + toast.success(t('g.success'), { + description: t('mediaAsset.nodeAddedToWorkflow', { nodeType }), + duration: 2000 }) } @@ -374,18 +366,14 @@ export function useMediaAssetActions() { const result = await openAssetWorkflow(targetAsset) if (!result.success) { - toast.add({ - severity: 'warn', - summary: t('g.warning'), - detail: result.error || t('mediaAsset.noWorkflowDataFound'), - life: 2000 + toast.warning(t('g.warning'), { + description: result.error || t('mediaAsset.noWorkflowDataFound'), + duration: 2000 }) } else { - toast.add({ - severity: 'success', - summary: t('g.success'), - detail: t('mediaAsset.workflowOpenedInNewTab'), - life: 2000 + toast.success(t('g.success'), { + description: t('mediaAsset.workflowOpenedInNewTab'), + duration: 2000 }) } } @@ -411,18 +399,17 @@ export function useMediaAssetActions() { if (!result.success) { const isNoWorkflow = result.error?.includes('No workflow') - toast.add({ - severity: isNoWorkflow ? 'warn' : 'error', - summary: isNoWorkflow ? t('g.warning') : t('g.error'), - detail: result.error || t('mediaAsset.failedToExportWorkflow'), - life: 3000 - }) + const title = isNoWorkflow ? t('g.warning') : t('g.error') + const options = { + description: result.error || t('mediaAsset.failedToExportWorkflow'), + duration: 3000 + } + if (isNoWorkflow) toast.warning(title, options) + else toast.error(title, options) } else { - toast.add({ - severity: 'success', - summary: t('g.success'), - detail: t('mediaAsset.workflowExportedSuccessfully'), - life: 2000 + toast.success(t('g.success'), { + description: t('mediaAsset.workflowExportedSuccessfully'), + duration: 2000 }) } } @@ -475,29 +462,23 @@ export function useMediaAssetActions() { } if (failed === 0) { - toast.add({ - severity: 'success', - summary: t('g.success'), - detail: t('mediaAsset.selection.nodesAddedToWorkflow', { + toast.success(t('g.success'), { + description: t('mediaAsset.selection.nodesAddedToWorkflow', { count: succeeded }), - life: 2000 + duration: 2000 }) } else if (succeeded === 0) { - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('mediaAsset.selection.failedToAddNodes') + toast.error(t('g.error'), { + description: t('mediaAsset.selection.failedToAddNodes') }) } else { - toast.add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('mediaAsset.selection.partialAddNodesSuccess', { + toast.warning(t('g.warning'), { + description: t('mediaAsset.selection.partialAddNodesSuccess', { succeeded, failed }), - life: 3000 + duration: 3000 }) } } @@ -524,28 +505,24 @@ export function useMediaAssetActions() { } if (failed === 0) { - toast.add({ - severity: 'success', - summary: t('g.success'), - detail: t('mediaAsset.selection.workflowsOpened', { count: succeeded }), - life: 2000 + toast.success(t('g.success'), { + description: t('mediaAsset.selection.workflowsOpened', { + count: succeeded + }), + duration: 2000 }) } else if (succeeded === 0) { - toast.add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('mediaAsset.selection.noWorkflowsFound'), - life: 3000 + toast.warning(t('g.warning'), { + description: t('mediaAsset.selection.noWorkflowsFound'), + duration: 3000 }) } else { - toast.add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('mediaAsset.selection.partialWorkflowsOpened', { + toast.warning(t('g.warning'), { + description: t('mediaAsset.selection.partialWorkflowsOpened', { succeeded, failed }), - life: 3000 + duration: 3000 }) } } @@ -579,30 +556,24 @@ export function useMediaAssetActions() { if (succeeded === 0 && failed === 0) return if (failed === 0) { - toast.add({ - severity: 'success', - summary: t('g.success'), - detail: t('mediaAsset.selection.workflowsExported', { + toast.success(t('g.success'), { + description: t('mediaAsset.selection.workflowsExported', { count: succeeded }), - life: 2000 + duration: 2000 }) } else if (succeeded === 0) { - toast.add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('mediaAsset.selection.noWorkflowsToExport'), - life: 3000 + toast.warning(t('g.warning'), { + description: t('mediaAsset.selection.noWorkflowsToExport'), + duration: 3000 }) } else { - toast.add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('mediaAsset.selection.partialWorkflowsExported', { + toast.warning(t('g.warning'), { + description: t('mediaAsset.selection.partialWorkflowsExported', { succeeded, failed }), - life: 3000 + duration: 3000 }) } } @@ -826,12 +797,14 @@ export function useMediaAssetActions() { ) } - toast.add({ - detail: resultMessages.join('\n'), - life: severity === 'success' ? 2000 : 5000, - severity, - summary: t(`mediaAsset.assetDelete.${severity}`) - }) + const resultTitle = t(`mediaAsset.assetDelete.${severity}`) + const resultOptions = { + description: resultMessages.join('\n'), + duration: severity === 'success' ? 2000 : 5000 + } + if (severity === 'success') toast.success(resultTitle, resultOptions) + else if (severity === 'warn') toast.warning(resultTitle, resultOptions) + else toast.error(resultTitle, resultOptions) return true } diff --git a/src/platform/assets/composables/useNodeOutputsExport.test.ts b/src/platform/assets/composables/useNodeOutputsExport.test.ts index 8981587167c..151cc238a6f 100644 --- a/src/platform/assets/composables/useNodeOutputsExport.test.ts +++ b/src/platform/assets/composables/useNodeOutputsExport.test.ts @@ -5,13 +5,13 @@ import { h } from 'vue' import { downloadFile } from '@/base/common/downloadUtil' import GlobalDialog from '@/components/dialog/GlobalDialog.vue' +import { useToast } from '@/components/ui/toast' import { useFeatureFlags } from '@/composables/useFeatureFlags' import { i18n } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/litegraph' import { assetService } from '@/platform/assets/services/assetService' import type { ResultItem } from '@/platform/remote/comfyui/execution/types' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useAssetExportStore } from '@/stores/assetExportStore' import { useNodeOutputStore } from '@/stores/nodeOutputStore' import { createMockLGraphNode } from '@/utils/__tests__/litegraphTestUtils' @@ -121,11 +121,11 @@ describe('useNodeOutputsExport', () => { await exportFromDialog(node, ['f2.exr']) await vi.waitFor(() => { - expect(useToastStore().messagesToAdd).toEqual([ + expect(useToast().toasts).toEqual([ expect.objectContaining({ - severity: 'info', - summary: 'Preparing ZIP download...', - detail: 'Preparing ZIP export for 2 files' + kind: 'info', + title: 'Preparing ZIP download...', + description: 'Preparing ZIP export for 2 files' }) ]) }) @@ -226,10 +226,10 @@ describe('useNodeOutputsExport', () => { context: { count: 2 } }) }) - expect(useToastStore().messagesToAdd).toEqual([ + expect(useToast().toasts).toEqual([ expect.objectContaining({ - severity: 'error', - detail: 'Failed to create ZIP export' + kind: 'error', + description: 'Failed to create ZIP export' }) ]) expect(useAssetExportStore().exportList).toEqual([]) diff --git a/src/platform/assets/utils/createAssetWidget.ts b/src/platform/assets/utils/createAssetWidget.ts index 86913335af4..62f4bb9330f 100644 --- a/src/platform/assets/utils/createAssetWidget.ts +++ b/src/platform/assets/utils/createAssetWidget.ts @@ -11,7 +11,7 @@ import { assetFilenameSchema, assetItemSchema } from '@/platform/assets/schemas/assetSchema' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { getAssetFilename } from '@/platform/assets/utils/assetMetadataUtils' @@ -51,7 +51,7 @@ function createAssetWidgetOptions({ const assetBrowserDialog = useAssetBrowserDialog() async function openModal(widget: IBaseWidget) { - const toastStore = useToastStore() + const toastStore = useToast() await assetBrowserDialog.show({ nodeType: nodeTypeForBrowser, @@ -65,10 +65,8 @@ function createAssetWidgetOptions({ 'Invalid asset item:', fromZodError(validatedAsset.error).message ) - toastStore.add({ - severity: 'error', - summary: t('assetBrowser.invalidAsset'), - detail: t('assetBrowser.invalidAssetDetail') + toastStore.error(t('assetBrowser.invalidAsset'), { + description: t('assetBrowser.invalidAssetDetail') }) return } @@ -83,10 +81,8 @@ function createAssetWidgetOptions({ 'for asset:', validatedAsset.data.id ) - toastStore.add({ - severity: 'error', - summary: t('assetBrowser.invalidFilename'), - detail: t('assetBrowser.invalidFilenameDetail') + toastStore.error(t('assetBrowser.invalidFilename'), { + description: t('assetBrowser.invalidFilenameDetail') }) return } diff --git a/src/platform/auth/session/cloudWebSessionStore.ts b/src/platform/auth/session/cloudWebSessionStore.ts index 288594645fb..a8232337397 100644 --- a/src/platform/auth/session/cloudWebSessionStore.ts +++ b/src/platform/auth/session/cloudWebSessionStore.ts @@ -60,7 +60,7 @@ import { } from '@/platform/auth/session/webSessionFetch' import { useTelemetry } from '@/platform/telemetry' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore' import { useWorkspaceAuthStore } from '@/platform/workspace/stores/workspaceAuthStore' import { api } from '@/scripts/api' @@ -137,13 +137,11 @@ function resetForAccountChange(change: WebSessionAccountChange): void { useTeamWorkspaceStore().resetForIdentityChange() void api.resetSocket() if (change.reason !== 'user_changed') return - useToastStore().add({ - severity: 'info', - summary: t('auth.accountChanged.title'), - detail: t('auth.accountChanged.detail', { + useToast().info(t('auth.accountChanged.title'), { + description: t('auth.accountChanged.detail', { email: change.session.user.email }), - life: 8000 + duration: 8000 }) } diff --git a/src/platform/auth/session/components/SignOutEverywhereButton.vue b/src/platform/auth/session/components/SignOutEverywhereButton.vue index cc11085f761..d1985b9a606 100644 --- a/src/platform/auth/session/components/SignOutEverywhereButton.vue +++ b/src/platform/auth/session/components/SignOutEverywhereButton.vue @@ -14,35 +14,31 @@ import { ref } from 'vue' import { useI18n } from 'vue-i18n' import Button from '@/components/ui/button/Button.vue' +import { useToast } from '@/components/ui/toast' import { useAuthActions } from '@/composables/auth/useAuthActions' import { useCloudWebSessionStore, webSessionFailureMessage } from '@/platform/auth/session/cloudWebSessionStore' -import { useToastStore } from '@/platform/updates/common/toastStore' const { t } = useI18n() const { logout } = useAuthActions() const webSession = useCloudWebSessionStore() -const toastStore = useToastStore() +const toast = useToast() const signingOut = ref(false) async function revokeAllSessions(): Promise { const result = await webSession.revokeAllSessions() if (result.status === 'error') { - toastStore.add({ - severity: 'error', - summary: t('auth.signOutEverywhere.failed'), - detail: webSessionFailureMessage(result.code), - life: 8000 + toast.error(t('auth.signOutEverywhere.failed'), { + description: webSessionFailureMessage(result.code), + duration: 8000 }) return false } - toastStore.add({ - severity: 'success', - summary: t('auth.signOutEverywhere.success'), - detail: t('auth.signOutEverywhere.successDetail'), - life: 5000 + toast.success(t('auth.signOutEverywhere.success'), { + description: t('auth.signOutEverywhere.successDetail'), + duration: 5000 }) return true } diff --git a/src/platform/auth/webSessionFlagOn.test.ts b/src/platform/auth/webSessionFlagOn.test.ts index 1389abe6806..a571808bda5 100644 --- a/src/platform/auth/webSessionFlagOn.test.ts +++ b/src/platform/auth/webSessionFlagOn.test.ts @@ -61,7 +61,7 @@ import { useTelemetry } from '@/platform/telemetry' import { reportError } from '@/platform/telemetry/reportError' import { refreshRemoteConfig } from '@/platform/remoteConfig/refreshRemoteConfig' import { remoteConfig } from '@/platform/remoteConfig/remoteConfig' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { workspaceApi } from '@/platform/workspace/api/workspaceApi' import { NoWorkspaceAccessError } from '@/platform/workspace/api/workspaceApiError' import { @@ -580,10 +580,10 @@ describe('cloud app on the shared web session (unified_web_session on)', () => { expect( sessionStorage.getItem(WORKSPACE_STORAGE_KEYS.CURRENT_WORKSPACE) ).toBeNull() - expect(useToastStore().messagesToAdd).toEqual([ + expect(useToast().toasts).toEqual([ expect.objectContaining({ - severity: 'info', - detail: expect.stringContaining('user-b@example.com') + kind: 'info', + description: expect.stringContaining('user-b@example.com') }) ]) }) diff --git a/src/platform/cloud/onboarding/CloudSurveyView.test.ts b/src/platform/cloud/onboarding/CloudSurveyView.test.ts index d471459ec7e..ca0773006e5 100644 --- a/src/platform/cloud/onboarding/CloudSurveyView.test.ts +++ b/src/platform/cloud/onboarding/CloudSurveyView.test.ts @@ -7,10 +7,10 @@ import { createI18n } from 'vue-i18n' import { createMemoryHistory, createRouter } from 'vue-router' import enMessages from '@/locales/en/main.json' with { type: 'json' } +import { useToast } from '@/components/ui/toast' import { useFeatureFlags } from '@/composables/useFeatureFlags' import { firebaseIdentity } from '@/platform/auth/firebaseIdentity' import { useTelemetry } from '@/platform/telemetry' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useAuthStore } from '@/stores/authStore' import CloudSurveyView from './CloudSurveyView.vue' @@ -104,7 +104,7 @@ describe('CloudSurveyView', () => { vi.mocked(useTelemetry).mockReturnValue( fromPartial({ trackSurvey: mocks.trackSurvey }) ) - vi.spyOn(useToastStore(), 'add').mockImplementation(() => undefined) + vi.mocked(useToast().error).mockImplementation(() => 0) }) it('tracks and advances after storing a first survey', async () => { @@ -150,9 +150,7 @@ describe('CloudSurveyView', () => { surface: 'platform', errorType: 'error_submitting_onboarding_survey' }) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(useToast().error).toHaveBeenCalled() expect(screen.getByRole('button', { name: 'Submit survey' })).toBeEnabled() }) @@ -185,9 +183,7 @@ describe('CloudSurveyView', () => { surface: 'platform', errorType: 'error_submitting_onboarding_survey' }) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(useToast().error).toHaveBeenCalled() expect(screen.getByRole('button', { name: 'Submit survey' })).toBeEnabled() }) @@ -208,11 +204,9 @@ describe('CloudSurveyView', () => { surface: 'platform', errorType: 'error_navigating_from_onboarding_survey' }) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - summary: 'Survey saved, but onboarding could not continue', - detail: 'Please try again.' - }) + expect(useToast().error).toHaveBeenCalledWith( + 'Survey saved, but onboarding could not continue', + expect.objectContaining({ description: 'Please try again.' }) ) expect(screen.getByRole('button', { name: 'Submit survey' })).toBeEnabled() }) diff --git a/src/platform/cloud/onboarding/CloudSurveyView.vue b/src/platform/cloud/onboarding/CloudSurveyView.vue index 83c09f398a7..dfbd09c91d7 100644 --- a/src/platform/cloud/onboarding/CloudSurveyView.vue +++ b/src/platform/cloud/onboarding/CloudSurveyView.vue @@ -19,6 +19,7 @@ import { computed, onMounted, ref } from 'vue' import { useI18n } from 'vue-i18n' import { isNavigationFailure, useRouter } from 'vue-router' +import { useToast } from '@/components/ui/toast' import { useFeatureFlags } from '@/composables/useFeatureFlags' import { getSurveyCompletedStatus, @@ -31,7 +32,6 @@ import { import { remoteConfig } from '@/platform/remoteConfig/remoteConfig' import { useTelemetry } from '@/platform/telemetry' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useAuthStore } from '@/stores/authStore' import DynamicSurveyForm from './survey/DynamicSurveyForm.vue' @@ -111,11 +111,9 @@ async function advanceFromSurvey(replaying: boolean, replayOwner: string) { surface: 'platform', errorType: 'error_navigating_from_onboarding_survey' }) - useToastStore().add({ - severity: 'error', - summary: t('cloudOnboarding.survey.navigationFailed'), - detail: t('cloudOnboarding.survey.navigationFailedDetail'), - life: 5000 + useToast().error(t('cloudOnboarding.survey.navigationFailed'), { + description: t('cloudOnboarding.survey.navigationFailedDetail'), + duration: 5000 }) } finally { isSubmitting.value = false @@ -127,11 +125,9 @@ function reportSurveySubmissionFailure(cause: unknown) { surface: 'platform', errorType: 'error_submitting_onboarding_survey' }) - useToastStore().add({ - severity: 'error', - summary: t('cloudOnboarding.survey.submitFailed'), - detail: t('cloudOnboarding.survey.submitFailedDetail'), - life: 5000 + useToast().error(t('cloudOnboarding.survey.submitFailed'), { + description: t('cloudOnboarding.survey.submitFailedDetail'), + duration: 5000 }) } diff --git a/src/platform/cloud/onboarding/components/CloudLayoutView.vue b/src/platform/cloud/onboarding/components/CloudLayoutView.vue index c5cdef46026..2cf011b931a 100644 --- a/src/platform/cloud/onboarding/components/CloudLayoutView.vue +++ b/src/platform/cloud/onboarding/components/CloudLayoutView.vue @@ -3,15 +3,14 @@ - - + + + + + diff --git a/src/platform/workspace/components/SubscriptionPanelContentWorkspace.test.ts b/src/platform/workspace/components/SubscriptionPanelContentWorkspace.test.ts index c92c54be508..e0644bf6aed 100644 --- a/src/platform/workspace/components/SubscriptionPanelContentWorkspace.test.ts +++ b/src/platform/workspace/components/SubscriptionPanelContentWorkspace.test.ts @@ -212,12 +212,14 @@ vi.mock( import('@/platform/cloud/subscription/composables/useSubscriptionDialog') ) -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - () => ({ - useToast: () => ({ add: vi.fn() }) +vi.mock(import('@/components/ui/toast'), () => ({ + useToast: () => ({ + success: vi.fn(), + error: vi.fn(), + info: vi.fn(), + warning: vi.fn() }) -) +})) const i18n = createI18n({ legacy: false, diff --git a/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts b/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts index 8e95742d7e7..95245116d6b 100644 --- a/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts +++ b/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts @@ -80,12 +80,14 @@ vi.mock(import('@/composables/billing/usePendingTopup'), () => ({ usePendingTopup: () => ({ clearPendingTopup: mockClearPendingTopup }) })) -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - () => ({ - useToast: () => ({ add: mockToastAdd }) +vi.mock(import('@/components/ui/toast'), () => ({ + useToast: () => ({ + success: mockToastAdd, + error: mockToastAdd, + info: mockToastAdd, + warning: mockToastAdd }) -) +})) vi.mock(import('@/base/credits/comfyCredits'), () => ({ creditsToUsd: (credits: number) => credits, diff --git a/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue b/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue index 3a971790d26..f68f280f10e 100644 --- a/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue +++ b/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue @@ -293,7 +293,7 @@ import { getTopupAmountPreset, TOPUP_AMOUNT_PRESETS_USD } from '@comfyorg/account-core/billing' -import { useToast } from 'primevue/usetoast' +import { useToast } from '@/components/ui/toast' import { computed, onMounted, ref, watch } from 'vue' import { useI18n } from 'vue-i18n' @@ -633,11 +633,7 @@ async function handleBuy() { ) { clearCheckoutJourney() } - toast.add({ - severity: 'success', - summary: t('credits.topUp.purchaseSuccess'), - life: 5000 - }) + toast.success(t('credits.topUp.purchaseSuccess'), { duration: 5000 }) await Promise.allSettled([fetchBalance(), fetchStatus()]) if (!isCurrentAttempt()) return handleClose(false) @@ -660,10 +656,8 @@ async function handleBuy() { }) } else { if (isCurrentAttempt()) paymentSubmitted.value = false - toast.add({ - severity: 'error', - summary: t('credits.topUp.purchaseError'), - detail: t('credits.topUp.unknownError') + toast.error(t('credits.topUp.purchaseError'), { + description: t('credits.topUp.unknownError') }) } } catch (error) { @@ -692,10 +686,8 @@ function reportPurchaseError( }, billingOpId ) - toast.add({ - severity: 'error', - summary: t('credits.topUp.purchaseError'), - detail: purchaseErrorDetail(error) + toast.error(t('credits.topUp.purchaseError'), { + description: purchaseErrorDetail(error) }) } diff --git a/src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.test.ts b/src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.test.ts index fa0e4b85cd5..b29bf45518d 100644 --- a/src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.test.ts +++ b/src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.test.ts @@ -11,14 +11,14 @@ import type { WorkspaceRole } from '@/platform/workspace/api/workspaceApi' const { mockToastAdd } = vi.hoisted(() => ({ mockToastAdd: vi.fn() })) -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - () => ({ - useToast: () => ({ - add: mockToastAdd - }) +vi.mock(import('@/components/ui/toast'), () => ({ + useToast: () => ({ + success: mockToastAdd, + error: mockToastAdd, + info: mockToastAdd, + warning: mockToastAdd }) -) +})) const i18n = createI18n({ legacy: false, diff --git a/src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.vue b/src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.vue index 736994d0fb6..715be61f9ee 100644 --- a/src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.vue +++ b/src/platform/workspace/components/dialogs/ChangeMemberRoleDialogContent.vue @@ -60,7 +60,7 @@ diff --git a/src/platform/workspace/composables/useInviteUrlLoader.test.ts b/src/platform/workspace/composables/useInviteUrlLoader.test.ts index a647bded451..6e865dc9fea 100644 --- a/src/platform/workspace/composables/useInviteUrlLoader.test.ts +++ b/src/platform/workspace/composables/useInviteUrlLoader.test.ts @@ -56,14 +56,14 @@ vi.mock(import('@/composables/useFeatureFlags')) vi.mock(import('firebase/auth')) const mockToastAdd = vi.hoisted(() => vi.fn()) -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - () => ({ - useToast: () => ({ - add: mockToastAdd - }) +vi.mock(import('@/components/ui/toast'), () => ({ + useToast: () => ({ + success: mockToastAdd, + error: mockToastAdd, + info: mockToastAdd, + warning: mockToastAdd }) -) +})) const apps: App[] = [] diff --git a/src/platform/workspace/composables/useInviteUrlLoader.ts b/src/platform/workspace/composables/useInviteUrlLoader.ts index 9d35d7c4f87..323b23dd1b8 100644 --- a/src/platform/workspace/composables/useInviteUrlLoader.ts +++ b/src/platform/workspace/composables/useInviteUrlLoader.ts @@ -1,8 +1,9 @@ -import { useToast } from 'primevue/usetoast' +import { useToast } from '@/components/ui/toast' import { useI18n } from 'vue-i18n' import { useRoute, useRouter } from 'vue-router' import { useFeatureFlags } from '@/composables/useFeatureFlags' +import InviteAcceptedToast from '@/platform/workspace/components/toasts/InviteAcceptedToast.vue' import { clearPreservedQuery, hydratePreservedQuery, @@ -107,10 +108,10 @@ export function useInviteUrlLoader() { try { const result = await workspaceStore.acceptInvite(inviteParam) - toast.add({ - severity: 'success', - summary: t('workspace.inviteAccepted'), - detail: { + toast.custom( + InviteAcceptedToast, + { + title: t('workspace.inviteAccepted'), text: t( 'workspace.addedToWorkspace', { workspaceName: result.workspaceName }, @@ -119,9 +120,8 @@ export function useInviteUrlLoader() { workspaceName: result.workspaceName, workspaceId: result.workspaceId }, - group: 'invite-accepted', - closable: true - }) + { role: 'status' } + ) } catch (error) { await presentAcceptFailure(error, inviteParam) } finally { @@ -173,10 +173,8 @@ export function useInviteUrlLoader() { errorType: 'error_accepting_workspace_invite', surface: 'workspace' }) - toast.add({ - severity: 'error', - summary: t('workspace.inviteFailed'), - detail: error instanceof Error ? error.message : t('g.unknownError') + toast.error(t('workspace.inviteFailed'), { + description: error instanceof Error ? error.message : t('g.unknownError') }) } diff --git a/src/platform/workspace/composables/useMembersPanel.test.ts b/src/platform/workspace/composables/useMembersPanel.test.ts index ad95cad3e01..2c681f1fef0 100644 --- a/src/platform/workspace/composables/useMembersPanel.test.ts +++ b/src/platform/workspace/composables/useMembersPanel.test.ts @@ -334,12 +334,14 @@ function setOriginalOwner(id = 'creator-1') { ] } -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - () => ({ - useToast: () => ({ add: mockToastAdd }) +vi.mock(import('@/components/ui/toast'), () => ({ + useToast: () => ({ + success: mockToastAdd, + error: mockToastAdd, + info: mockToastAdd, + warning: mockToastAdd }) -) +})) vi.mock(import('@/platform/workspace/composables/useWorkspaceUI')) diff --git a/src/platform/workspace/composables/useMembersPanel.ts b/src/platform/workspace/composables/useMembersPanel.ts index 32cfe49f998..1c584f837b1 100644 --- a/src/platform/workspace/composables/useMembersPanel.ts +++ b/src/platform/workspace/composables/useMembersPanel.ts @@ -1,6 +1,6 @@ import type { MenuItem } from '@/components/ui/menu/types' import { storeToRefs } from 'pinia' -import { useToast } from 'primevue/usetoast' +import { useToast } from '@/components/ui/toast' import { computed, ref } from 'vue' import { useI18n } from 'vue-i18n' @@ -357,16 +357,9 @@ export function useMembersPanel() { if (!permissions.value.canManageInvites) return try { await resendInvite(invite.id) - toast.add({ - severity: 'success', - summary: t('workspacePanel.toast.inviteResent'), - life: 2000 - }) + toast.success(t('workspacePanel.toast.inviteResent'), { duration: 2000 }) } catch { - toast.add({ - severity: 'error', - summary: t('workspacePanel.toast.inviteResendFailed') - }) + toast.error(t('workspacePanel.toast.inviteResendFailed')) } } diff --git a/src/platform/workspace/composables/useResubscribe.test.ts b/src/platform/workspace/composables/useResubscribe.test.ts index 6c58406f0c7..30b03e6381e 100644 --- a/src/platform/workspace/composables/useResubscribe.test.ts +++ b/src/platform/workspace/composables/useResubscribe.test.ts @@ -31,12 +31,14 @@ vi.mock(import('@/platform/workspace/composables/useWorkspaceUI')) vi.mock(import('@/platform/telemetry')) -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - () => ({ - useToast: () => ({ add: state.toastAdd }) +vi.mock(import('@/components/ui/toast'), () => ({ + useToast: () => ({ + success: state.toastAdd, + error: state.toastAdd, + info: state.toastAdd, + warning: state.toastAdd }) -) +})) const apps: App[] = [] diff --git a/src/platform/workspace/composables/useResubscribe.ts b/src/platform/workspace/composables/useResubscribe.ts index 93acac83d91..e8f7e33b419 100644 --- a/src/platform/workspace/composables/useResubscribe.ts +++ b/src/platform/workspace/composables/useResubscribe.ts @@ -1,4 +1,4 @@ -import { useToast } from 'primevue/usetoast' +import { useToast } from '@/components/ui/toast' import { ref } from 'vue' import { useI18n } from 'vue-i18n' @@ -55,11 +55,7 @@ export function useResubscribe() { duration_ms: Date.now() - startedAt }) } - toast.add({ - severity: 'success', - summary: t('subscription.resubscribeSuccess'), - life: 5000 - }) + toast.success(t('subscription.resubscribeSuccess'), { duration: 5000 }) } catch (error) { const detail = error instanceof Error && error.message.trim() @@ -75,11 +71,7 @@ export function useResubscribe() { duration_ms: Date.now() - startedAt }) }) - toast.add({ - severity: 'error', - summary: t('g.error'), - detail - }) + toast.error(t('g.error'), { description: detail }) } finally { isResubscribing.value = false } diff --git a/src/platform/workspace/composables/useSubscriptionCheckout.test.ts b/src/platform/workspace/composables/useSubscriptionCheckout.test.ts index db7df9874d4..6dab48d615e 100644 --- a/src/platform/workspace/composables/useSubscriptionCheckout.test.ts +++ b/src/platform/workspace/composables/useSubscriptionCheckout.test.ts @@ -1,3 +1,6 @@ +import { useToast } from '@/components/ui/toast' +import PaymentRecoveryToast from '@/platform/workspace/components/PaymentRecoveryToast.vue' +import type { PaymentRecoveryToastProps } from '@/platform/workspace/components/PaymentRecoveryToast.vue' import { useBillingCapabilities } from '@/platform/workspace/composables/useBillingCapabilities' import { render } from '@testing-library/vue' import type { Mock } from 'vitest' @@ -200,7 +203,6 @@ const { mockResubscribe, mockToastAdd, mockToastRemove, - mockToastRemoveGroup, mockListSavedPaymentMethods, mockShowDowngradeToPersonalDialog, mockIsTeamPlan, @@ -225,9 +227,8 @@ const { mockReportError: vi.fn(), mockPlans: { value: [] as Plan[] }, mockResubscribe: vi.fn(), - mockToastAdd: vi.fn(), + mockToastAdd: vi.fn<(kind: string, ...args: unknown[]) => void>(), mockToastRemove: vi.fn(), - mockToastRemoveGroup: vi.fn(), mockListSavedPaymentMethods: vi.fn(), mockShowDowngradeToPersonalDialog: vi.fn(), mockIsTeamPlan: { value: false }, @@ -413,23 +414,52 @@ vi.mock(import('@/config/comfyApi'), () => ({ getComfyPlatformBaseUrl: () => 'https://platform.comfy.org' })) -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - () => ({ - useToast: () => ({ - add: mockToastAdd, - remove: mockToastRemove, - removeGroup: mockToastRemoveGroup - }) - }) -) - vi.mock(import('@/platform/telemetry')) vi.mock(import('@/platform/telemetry/reportError'), () => ({ reportError: mockReportError })) +beforeEach(() => { + const toast = useToast() + vi.mocked(toast.dismiss).mockImplementation(mockToastRemove) + for (const kind of [ + 'success', + 'error', + 'info', + 'warning', + 'loading' + ] as const) { + vi.mocked(toast[kind]).mockImplementation((...args) => { + mockToastAdd(kind, ...args) + return 0 + }) + } + vi.mocked(toast.custom).mockImplementation((...args) => { + mockToastAdd('custom', ...args) + return 0 + }) +}) + +function latestPaymentRecoveryToastProps(): PaymentRecoveryToastProps { + const call = mockToastAdd.mock.calls.at(-1) + assert(call?.[0] === 'custom') + assert(call[1] === PaymentRecoveryToast) + const props = call[2] + assert(props && typeof props === 'object') + assert('title' in props && typeof props.title === 'string') + assert('description' in props && typeof props.description === 'string') + assert('actionLabel' in props && typeof props.actionLabel === 'string') + assert('onAction' in props && typeof props.onAction === 'function') + const onAction = props.onAction + return { + title: props.title, + description: props.description, + actionLabel: props.actionLabel, + onAction: () => onAction() + } +} + const i18n = createI18n({ legacy: false, locale: 'en', @@ -1113,8 +1143,10 @@ describe('useSubscriptionCheckout', () => { expect(mockSubscribe).not.toHaveBeenCalled() expect(mockToastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.any(String), expect.objectContaining({ - detail: 'Apply quote before continuing' + description: 'Apply quote before continuing' }) ) }) @@ -1230,7 +1262,9 @@ describe('useSubscriptionCheckout', () => { expect(checkout.checkoutStep.value).toBe('preview') expect(checkout.previewData.value?.quote_id).toBe('quote_new') expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Quote changed' }) + expect.any(String), + expect.any(String), + expect.objectContaining({ description: 'Quote changed' }) ) }) @@ -1259,9 +1293,9 @@ describe('useSubscriptionCheckout', () => { expect(checkout.checkoutStep.value).toBe('pricing') expect(checkout.previewData.value).toBeNull() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - detail: 'Quote refresh failed' - }) + expect.any(String), + expect.any(String), + expect.objectContaining({ description: 'Quote refresh failed' }) ) }) @@ -1437,9 +1471,9 @@ describe('useSubscriptionCheckout', () => { expect(mockSubscribe).not.toHaveBeenCalled() expect(checkout.previewData.value).toStrictEqual(refreshedPreview) expect(checkout.checkoutStep.value).not.toBe('pricing') - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Reactivation amount changed' }) - ) + expect(mockToastAdd).toHaveBeenCalledWith('error', 'Error', { + description: 'Reactivation amount changed' + }) } ) @@ -1496,9 +1530,9 @@ describe('useSubscriptionCheckout', () => { await checkout.handleConfirmTransition() expect(checkout.reactivationRequired.value).toBe(false) - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Reactivate first' }) - ) + expect(mockToastAdd).toHaveBeenCalledWith('error', 'Error', { + description: 'Reactivate first' + }) }) it('returns to confirmation without an error when a subscribe reactivation block stands', async () => { @@ -1530,9 +1564,9 @@ describe('useSubscriptionCheckout', () => { await checkout.handleConfirmTransition() expect(checkout.reactivationRequired.value).toBe(true) - expect(mockToastAdd).not.toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Reactivate first' }) - ) + expect(mockToastAdd).not.toHaveBeenCalledWith('error', 'Error', { + description: 'Reactivate first' + }) }) it('surfaces the rejection when a team subscribe reactivation block clears on refresh', async () => { @@ -1561,9 +1595,9 @@ describe('useSubscriptionCheckout', () => { await checkout.handleTeamSubscribe() expect(checkout.reactivationRequired.value).toBe(false) - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Reactivate first' }) - ) + expect(mockToastAdd).toHaveBeenCalledWith('error', 'Error', { + description: 'Reactivate first' + }) }) it('shows error toast when preview is disallowed', async () => { @@ -1580,10 +1614,9 @@ describe('useSubscriptionCheckout', () => { expect(checkout.checkoutStep.value).toBe('pricing') expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Not allowed' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'Not allowed' }) ) }) @@ -1619,7 +1652,7 @@ describe('useSubscriptionCheckout', () => { } ) - it('offers a retry action when the billing portal popup is blocked', async () => { + it('warns when the billing portal popup is blocked', async () => { mockOpen.mockReturnValueOnce(null) const checkout = await submitRejectedPreview( 'SUBSCRIPTION_PAYMENT_REQUIRED' @@ -1630,32 +1663,15 @@ describe('useSubscriptionCheckout', () => { 'https://app.test/subscribe?invite=secret#token' ) expect(mockToastAdd).toHaveBeenCalledWith( + 'custom', + PaymentRecoveryToast, expect.objectContaining({ - group: 'payment-recovery', - severity: 'warn', - detail: expect.objectContaining({ - text: 'Payment popup blocked', - actionLabel: 'Try again', - onAction: expect.any(Function) - }) - }) - ) - }) - - it('opens the portal and arms the focus refresh when the retry action is clicked', async () => { - mockOpen.mockReturnValueOnce(null) - await submitRejectedPreview('SUBSCRIPTION_PAYMENT_REQUIRED') - const [{ detail }] = mockToastAdd.mock.calls.at(-1)! - - mockOpen.mockReturnValueOnce({}) - detail.onAction() - - expect(mockOpen).toHaveBeenLastCalledWith( - 'https://billing.stripe.com/portal', - '_blank' + description: 'Payment popup blocked', + actionLabel: 'Try again', + onAction: expect.any(Function) + }), + { role: 'alert' } ) - window.dispatchEvent(new Event('focus')) - await vi.waitFor(() => expect(mockFetchStatus).toHaveBeenCalledOnce()) }) it('removes the retry toast when returning to pricing', async () => { @@ -1664,12 +1680,15 @@ describe('useSubscriptionCheckout', () => { 'SUBSCRIPTION_PAYMENT_REQUIRED' ) expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ group: 'payment-recovery' }) + 'custom', + PaymentRecoveryToast, + expect.any(Object), + { role: 'alert' } ) checkout.handleBackToPricing() - expect(mockToastRemoveGroup).toHaveBeenCalledWith('payment-recovery') + expect(mockToastRemove).toHaveBeenCalledWith(0) }) it('removes the retry toast when the checkout composable is disposed', async () => { @@ -1692,12 +1711,15 @@ describe('useSubscriptionCheckout', () => { billingCycle: 'yearly' }) expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ group: 'payment-recovery' }) + 'custom', + PaymentRecoveryToast, + expect.any(Object), + { role: 'alert' } ) unmount() - expect(mockToastRemoveGroup).toHaveBeenCalledWith('payment-recovery') + expect(mockToastRemove).toHaveBeenCalledWith(0) }) it('refreshes status on return even after checkout is disposed', async () => { @@ -1719,13 +1741,13 @@ describe('useSubscriptionCheckout', () => { tierKey: 'standard', billingCycle: 'yearly' }) - const [{ detail }] = mockToastAdd.mock.calls.at(-1)! + const { onAction } = latestPaymentRecoveryToastProps() // Click retry (a real gesture opens the popup this time), then close // checkout — completing payment in that popup and returning must still // refresh status even though the checkout that armed this is gone. mockOpen.mockReturnValueOnce({}) - detail.onAction() + onAction() unmount() window.dispatchEvent(new Event('focus')) @@ -1765,7 +1787,9 @@ describe('useSubscriptionCheckout', () => { ) expect(mockGetPaymentPortalUrl).not.toHaveBeenCalled() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Plan change is unavailable' }) + expect.any(String), + expect.any(String), + expect.objectContaining({ description: 'Plan change is unavailable' }) ) }) @@ -1784,8 +1808,10 @@ describe('useSubscriptionCheckout', () => { 'https://app.test/subscribe?invite=secret#token' ) expect(mockToastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.any(String), expect.objectContaining({ - detail: 'Update your payment method before changing plans' + description: 'Update your payment method before changing plans' }) ) }) @@ -1807,7 +1833,9 @@ describe('useSubscriptionCheckout', () => { errorType: 'billing_portal_open_failure' }) expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Portal unavailable' }) + expect.any(String), + expect.any(String), + expect.objectContaining({ description: 'Portal unavailable' }) ) }) @@ -1841,8 +1869,10 @@ describe('useSubscriptionCheckout', () => { 'https://app.test/subscribe?invite=secret#token' ) expect(mockToastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.any(String), expect.objectContaining({ - detail: 'Update your payment method before changing plans' + description: 'Update your payment method before changing plans' }) ) }) @@ -1977,8 +2007,10 @@ describe('useSubscriptionCheckout', () => { errorType: 'billing_portal_open_failure' }) expect(mockToastAdd).toHaveBeenCalledWith( + 'error', + 'Error', expect.objectContaining({ - detail: 'Update your payment method before changing plans' + description: 'Update your payment method before changing plans' }) ) }) @@ -2072,9 +2104,9 @@ describe('useSubscriptionCheckout', () => { } ]) - const [{ detail }] = mockToastAdd.mock.calls.at(-1)! + const { onAction } = latestPaymentRecoveryToastProps() mockOpen.mockReturnValueOnce({}) - detail.onAction() + onAction() leaveAndReturn() expect(portalEvents().slice(1)).toEqual([ @@ -2099,9 +2131,9 @@ describe('useSubscriptionCheckout', () => { mockOpen.mockReturnValueOnce(null) await submitRejectedPreview('SUBSCRIPTION_PAYMENT_REQUIRED') - const [{ detail }] = mockToastAdd.mock.calls.at(-1)! + const { onAction } = latestPaymentRecoveryToastProps() mockOpen.mockReturnValueOnce(null) - detail.onAction() + onAction() leaveAndReturn() const blocked = { @@ -2195,10 +2227,9 @@ describe('useSubscriptionCheckout', () => { }) expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'This plan is not available' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'This plan is not available' }) ) expect(mockFetchPlans).toHaveBeenCalledOnce() }) @@ -2254,10 +2285,9 @@ describe('useSubscriptionCheckout', () => { }) expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Network error' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'Network error' }) ) }) @@ -2494,10 +2524,9 @@ describe('useSubscriptionCheckout', () => { expect.objectContaining({ stage: 'intent', outcome: 'pending' }) ) expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'success', - summary: 'Subscription updated' - }) + 'success', + 'Subscription updated', + { duration: 5000 } ) }) @@ -2867,13 +2896,13 @@ describe('useSubscriptionCheckout', () => { mockOpen.mockReturnValueOnce(null) const { checkout, selection } = await startTeamPaymentRecovery() await selection - const [{ detail }] = mockToastAdd.mock.calls.at(-1)! + const { onAction } = latestPaymentRecoveryToastProps() // The retry toast can survive a reset that raced ahead of removing it; // its action must still refuse to reopen a URL from the old attempt. checkout.handleBackToPricing() mockOpen.mockClear() - detail.onAction() + onAction() expect(mockOpen).not.toHaveBeenCalled() }) @@ -2891,8 +2920,10 @@ describe('useSubscriptionCheckout', () => { expect(checkout.selectedTeamStop.value).toBeNull() expect(mockToastAdd).toHaveBeenCalledOnce() expect(mockToastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.any(String), expect.objectContaining({ - detail: 'Update your payment method before changing plans' + description: 'Update your payment method before changing plans' }) ) }) @@ -3067,9 +3098,7 @@ describe('useSubscriptionCheckout', () => { expect(checkout.previewData.value).toBeNull() expect(checkout.checkoutStep.value).toBe('pricing') expect(checkout.selectedTeamStop.value).toBeNull() - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(mockToastAdd.mock.calls.map(([kind]) => kind)).toContain('error') }) it('uses the backend reactivation decision when cached team status is cancelled', async () => { @@ -3118,7 +3147,9 @@ describe('useSubscriptionCheckout', () => { expect(checkout.previewData.value).toBeNull() expect(checkout.checkoutStep.value).toBe('pricing') expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error', detail: 'not supported' }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'not supported' }) ) }) @@ -3215,7 +3246,9 @@ describe('useSubscriptionCheckout', () => { expect(mockOpenHostedBillingTab).not.toHaveBeenCalled() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Team plan unavailable' }) + 'error', + 'Team plan', + expect.objectContaining({ description: 'Team plan unavailable' }) ) }) @@ -3560,8 +3593,10 @@ describe('useSubscriptionCheckout', () => { 300_000 ) expect(mockToastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.any(String), expect.objectContaining({ - detail: 'Reactivation confirmation required' + description: 'Reactivation confirmation required' }) ) }) @@ -3616,8 +3651,10 @@ describe('useSubscriptionCheckout', () => { '2026-07-29T12:16:00Z' ) expect(mockToastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.any(String), expect.objectContaining({ - detail: 'Reactivation confirmation required' + description: 'Reactivation confirmation required' }) ) expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith( @@ -3676,9 +3713,7 @@ describe('useSubscriptionCheckout', () => { await checkout.handleTeamSubscribe() expect(mockSubscribe).not.toHaveBeenCalled() - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(mockToastAdd.mock.calls.map(([kind]) => kind)).toContain('error') expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledExactlyOnceWith( expect.objectContaining({ stage: 'intent', outcome: 'pending' }) ) @@ -3716,10 +3751,9 @@ describe('useSubscriptionCheckout', () => { expect(mockSubscribe).not.toHaveBeenCalled() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Reactivation amount changed' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'Reactivation amount changed' }) ) expect(checkout.previewData.value?.cost_today_cents).toBe(120_000) @@ -3764,10 +3798,9 @@ describe('useSubscriptionCheckout', () => { expect(checkout.isSubscribing.value).toBe(false) expect(mockSubscribe).not.toHaveBeenCalled() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'status unavailable' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'status unavailable' }) ) expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledExactlyOnceWith( expect.objectContaining({ stage: 'intent', outcome: 'pending' }) @@ -3808,9 +3841,7 @@ describe('useSubscriptionCheckout', () => { expect(mockSubscribe).not.toHaveBeenCalled() expect(checkout.checkoutStep.value).toBe('pricing') expect(checkout.previewData.value).toBeNull() - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(mockToastAdd.mock.calls.map(([kind]) => kind)).toContain('error') }) it('recovers when the subscribe authority sees a cancellation omitted by the status read', async () => { @@ -3866,8 +3897,10 @@ describe('useSubscriptionCheckout', () => { expect(checkout.reactivationRequired.value).toBe(true) expect(checkout.previewData.value).toStrictEqual(preview) expect(mockToastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.any(String), expect.objectContaining({ - detail: 'Reactivation confirmation required' + description: 'Reactivation confirmation required' }) ) expect(useTelemetry()?.trackBillingEvent).not.toHaveBeenCalledWith( @@ -3975,9 +4008,7 @@ describe('useSubscriptionCheckout', () => { await checkout.handleTeamSubscribe() expect(mockSubscribe).not.toHaveBeenCalled() - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(mockToastAdd.mock.calls.map(([kind]) => kind)).toContain('error') }) it('shows an error toast when the team subscribe fails', async () => { @@ -3996,10 +4027,9 @@ describe('useSubscriptionCheckout', () => { await checkout.handleTeamSubscribe() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Team payment failed' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'Team payment failed' }) ) expect(useTelemetry()?.trackBeginCheckout).not.toHaveBeenCalled() expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith({ @@ -4033,7 +4063,9 @@ describe('useSubscriptionCheckout', () => { expect(mockSubscribe).not.toHaveBeenCalled() expect(checkout.checkoutStep.value).toBe('pricing') expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'not supported' }) + expect.any(String), + expect.any(String), + expect.objectContaining({ description: 'not supported' }) ) }) @@ -4072,9 +4104,7 @@ describe('useSubscriptionCheckout', () => { await checkout.handleTeamSubscribe() expect(mockSubscribe).not.toHaveBeenCalled() - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(mockToastAdd.mock.calls.map(([kind]) => kind)).toContain('error') expect(checkout.previewData.value?.cost_today_cents).toBe(110_000) mockPreviewSubscribe.mockResolvedValueOnce({ @@ -4923,15 +4953,14 @@ describe('useSubscriptionCheckout', () => { await checkout.handleAddCreditCard() expect(mockToastAdd).toHaveBeenCalledWith( + 'custom', + PaymentRecoveryToast, expect.objectContaining({ - group: 'payment-recovery', - severity: 'warn', - detail: expect.objectContaining({ - text: 'Payment popup blocked', - actionLabel: 'Try again', - onAction: expect.any(Function) - }) - }) + description: 'Payment popup blocked', + actionLabel: 'Try again', + onAction: expect.any(Function) + }), + { role: 'alert' } ) expect(useBillingOperationStore().startOperation).toHaveBeenCalledWith( 'op-blocked', @@ -4939,15 +4968,6 @@ describe('useSubscriptionCheckout', () => { expect.any(Object), 'https://stripe.com/pay' ) - - const [{ detail }] = mockToastAdd.mock.calls.at(-1)! - openSpy.mockClear().mockReturnValue({} as Window) - detail.onAction() - expect(openSpy).toHaveBeenLastCalledWith( - 'https://stripe.com/pay', - '_blank' - ) - openSpy.mockRestore() }) @@ -4966,10 +4986,9 @@ describe('useSubscriptionCheckout', () => { expect(openSpy).not.toHaveBeenCalled() expect(useBillingOperationStore().startOperation).not.toHaveBeenCalled() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Stripe unavailable' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'Stripe unavailable' }) ) openSpy.mockRestore() }) @@ -5366,10 +5385,9 @@ describe('useSubscriptionCheckout', () => { await checkout.handleAddCreditCard() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Payment failed' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'Payment failed' }) ) expect(useTelemetry()?.trackBeginCheckout).not.toHaveBeenCalled() expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith({ @@ -5470,12 +5488,9 @@ describe('useSubscriptionCheckout', () => { new Error('Your bank declined this payment.') ) await checkout.handleConfirmTransition() - const declineToast = mockToastAdd.mock.calls - .map(([message]) => message) - .find( - (message) => message.detail === 'Your bank declined this payment.' - ) - expect(declineToast).toBeDefined() + expect(mockToastAdd).toHaveBeenCalledWith('error', expect.any(String), { + description: 'Your bank declined this payment.' + }) mockSubscribe.mockResolvedValueOnce({ status: 'subscribed', @@ -5484,7 +5499,7 @@ describe('useSubscriptionCheckout', () => { await checkout.handleConfirmTransition() expect(checkout.checkoutStep.value).toBe('success') - expect(mockToastRemove).toHaveBeenCalledWith(declineToast) + expect(mockToastRemove).toHaveBeenCalledWith(0) }) it('counts the conversion and announces a subscribe the server charged for', async () => { @@ -5511,10 +5526,9 @@ describe('useSubscriptionCheckout', () => { billing_op_id: 'op-3' }) expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'success', - summary: 'Subscription updated' - }) + 'success', + 'Subscription updated', + { duration: 5000 } ) }) @@ -5548,10 +5562,9 @@ describe('useSubscriptionCheckout', () => { await checkout.handleConfirmTransition() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Transition error' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'Transition error' }) ) }) @@ -5660,8 +5673,10 @@ describe('useSubscriptionCheckout', () => { expect(checkout.reactivationRequired.value).toBe(true) expect(checkout.previewData.value).toStrictEqual(preview) expect(mockToastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.any(String), expect.objectContaining({ - detail: 'Reactivation confirmation required' + description: 'Reactivation confirmation required' }) ) expect(useTelemetry()?.trackBillingEvent).not.toHaveBeenCalledWith( @@ -5777,9 +5792,9 @@ describe('useSubscriptionCheckout', () => { '2026-07-29T12:16:00Z' ) expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - detail: 'Reactivation amount changed' - }) + expect.any(String), + expect.any(String), + expect.objectContaining({ description: 'Reactivation amount changed' }) ) expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith( expect.objectContaining({ @@ -5845,12 +5860,14 @@ describe('useSubscriptionCheckout', () => { expect(checkout.checkoutStep.value).toBe('preview') expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Preview offline' }) + expect.any(String), + expect.any(String), + expect.objectContaining({ description: 'Preview offline' }) ) expect(mockToastAdd).not.toHaveBeenCalledWith( - expect.objectContaining({ - detail: 'Reactivation unavailable' - }) + expect.any(String), + expect.any(String), + expect.objectContaining({ description: 'Reactivation unavailable' }) ) }) @@ -5863,9 +5880,7 @@ describe('useSubscriptionCheckout', () => { await checkout.handleConfirmTransition() expect(mockSubscribe).not.toHaveBeenCalled() - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(mockToastAdd.mock.calls.map(([kind]) => kind)).toContain('error') expect(useTelemetry()?.trackBillingEvent).not.toHaveBeenCalled() }) @@ -5891,10 +5906,9 @@ describe('useSubscriptionCheckout', () => { expect(mockSubscribe).not.toHaveBeenCalled() expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Reactivation amount changed' - }) + 'error', + expect.any(String), + expect.objectContaining({ description: 'Reactivation amount changed' }) ) expect(checkout.previewData.value?.cost_today_cents).toBe(2000) @@ -6010,9 +6024,7 @@ describe('useSubscriptionCheckout', () => { await checkout.handleConfirmTransition() expect(mockSubscribe).not.toHaveBeenCalled() - expect(mockToastAdd).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(mockToastAdd.mock.calls.map(([kind]) => kind)).toContain('error') expect(checkout.checkoutStep.value).toBe('preview') expect(checkout.previewData.value?.cost_today_cents).toBe(1600) @@ -6128,9 +6140,10 @@ describe('useSubscriptionCheckout', () => { await checkout.handleResubscribe() expect(mockToastAdd).toHaveBeenCalledWith( + 'error', + expect.any(String), expect.objectContaining({ - severity: 'error', - detail: 'Resubscribe failed for person@example.com' + description: 'Resubscribe failed for person@example.com' }) ) expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith({ diff --git a/src/platform/workspace/composables/useSubscriptionCheckout.ts b/src/platform/workspace/composables/useSubscriptionCheckout.ts index 0ef72f34f04..5e812198eca 100644 --- a/src/platform/workspace/composables/useSubscriptionCheckout.ts +++ b/src/platform/workspace/composables/useSubscriptionCheckout.ts @@ -3,11 +3,11 @@ import type { CheckoutEntryFlow, SubscriptionCheckoutType } from '@comfyorg/account-core/billing' -import { useToast } from 'primevue/usetoast' -import type { ToastMessageOptions } from 'primevue/toast' import { computed, onScopeDispose, ref, watch } from 'vue' import { useI18n } from 'vue-i18n' +import type { ToastId } from '@/components/ui/toast' +import { useToast } from '@/components/ui/toast' import { useBillingContext } from '@/composables/billing/useBillingContext' import { useBillingRouting } from '@/composables/billing/useBillingRouting' import { getComfyPlatformBaseUrl } from '@/config/comfyApi' @@ -40,6 +40,7 @@ import { SettledOperationError, billingClientOf } from '@/platform/workspace/billing/sdk/subscriptionOperationView' +import PaymentRecoveryToast from '@/platform/workspace/components/PaymentRecoveryToast.vue' import { readOnRail } from '@/platform/workspace/composables/readOnRail' import { useBillingCapabilities } from '@/platform/workspace/composables/useBillingCapabilities' import { useBillingReadRail } from '@/platform/workspace/composables/useBillingReadRail' @@ -205,9 +206,10 @@ export function useSubscriptionCheckout( let checkoutMutationSeq = 0 let activeCheckoutAttemptStartedAt: number | undefined let lastEmittedPreviewRevision: string | undefined - // The payment-recovery toast is sticky and can outlive this checkout; - // drop it with the checkout rather than leave a button for a dead context. - onScopeDispose(() => toast.removeGroup('payment-recovery')) + const paymentRecoveryToasts: ToastId[] = [] + onScopeDispose(() => { + for (const id of paymentRecoveryToasts.splice(0)) toast.dismiss(id) + }) useCheckoutJourneyExit() // Some legacy-rail status reads cannot expose a scheduled cancellation even // though the subscribe authority can see it in Stripe. Once that authority @@ -460,10 +462,8 @@ export function useSubscriptionCheckout( // a request the BE is guaranteed to reject with no way for the user to // consent. function notifyReactivationConfirmationRequired(): void { - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('subscription.preview.reactivation.confirmationRequired') + toast.error(t('g.error'), { + description: t('subscription.preview.reactivation.confirmationRequired') }) } @@ -669,26 +669,28 @@ export function useSubscriptionCheckout( // The open above ran after an await, so it had no user gesture behind // it and got blocked. The toast's own button click is a gesture, so // retrying from there isn't blocked. - toast.add({ - group: 'payment-recovery', - severity: 'warn', - summary: t('g.warning'), - detail: { - text: t('subscription.preview.paymentPopupBlocked'), - actionLabel: t('subscription.planLoadErrorRetry'), - // The toast can outlive this attempt (a newer one started, or the - // checkout reset); a stale click must not reopen its captured URL. - onAction: () => { - if (!isCurrent()) return - if (window.open(portalUrl.href, '_blank')) { - portal.opened(billingClient) - } else { - portal.blocked(billingClient) + paymentRecoveryToasts.push( + toast.custom( + PaymentRecoveryToast, + { + title: t('g.warning'), + description: t('subscription.preview.paymentPopupBlocked'), + actionLabel: t('subscription.planLoadErrorRetry'), + // The toast can outlive this attempt (a newer one started, or the + // checkout reset); a stale click must not reopen its captured URL. + onAction: () => { + if (!isCurrent()) return + if (window.open(portalUrl.href, '_blank')) { + portal.opened(billingClient) + } else { + portal.blocked(billingClient) + } + armPaymentRecoveryReturnRefresh() } - armPaymentRecoveryReturnRefresh() - } - } - }) + }, + { role: 'alert' } + ) + ) return 'blocked' } portal.opened(billingClient) @@ -727,10 +729,8 @@ export function useSubscriptionCheckout( } if (!isReactivationCapablePreview(freshPreview)) { resetToPricing() - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('subscription.preview.reactivation.unavailable') + toast.error(t('g.error'), { + description: t('subscription.preview.reactivation.unavailable') }) return true } @@ -739,10 +739,8 @@ export function useSubscriptionCheckout( !previewData.value || amountDueTodayChanged(previewData.value, freshPreview) installPreview(freshPreview) - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t( + toast.error(t('g.error'), { + description: t( amountChanged ? 'subscription.preview.reactivation.amountChanged' : 'subscription.preview.reactivation.confirmationRequired' @@ -794,19 +792,15 @@ export function useSubscriptionCheckout( amountDueTodayChanged(previewData.value, freshPreview) installPreview(freshPreview) if (!amountChanged) return false - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('subscription.preview.reactivation.amountChanged') + toast.error(t('g.error'), { + description: t('subscription.preview.reactivation.amountChanged') }) return true } reactivationRequired.value = false resetToPricing() - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('subscription.preview.reactivation.unavailable') + toast.error(t('g.error'), { + description: t('subscription.preview.reactivation.unavailable') }) return true } @@ -930,10 +924,8 @@ export function useSubscriptionCheckout( planSlug = getApiPlanSlug(tierKey, billingCycle) } if (!planSlug) { - toast.add({ - severity: 'error', - summary: 'Unable to subscribe', - detail: 'This plan is not available' + toast.error('Unable to subscribe', { + description: 'This plan is not available' }) return } @@ -969,10 +961,8 @@ export function useSubscriptionCheckout( failure_category: 'unknown' }) } - toast.add({ - severity: 'error', - summary: 'Unable to subscribe', - detail: response?.reason || 'This plan is not available' + toast.error('Unable to subscribe', { + description: response?.reason || 'This plan is not available' }) return } @@ -995,10 +985,8 @@ export function useSubscriptionCheckout( error instanceof Error ? error.message : 'Failed to load subscription preview' - toast.add({ - severity: 'error', - summary: 'Error', - detail: message + toast.error('Error', { + description: message }) } finally { isLoadingPreview.value = false @@ -1062,10 +1050,8 @@ export function useSubscriptionCheckout( if (!embeddedCheckoutEnabled) { const teamCreditStopId = payload.stop.id if (!teamCreditStopId) { - toast.add({ - severity: 'error', - summary: t('subscription.teamPlan.name'), - detail: t('subscription.teamPlan.unavailable') + toast.error(t('subscription.teamPlan.name'), { + description: t('subscription.teamPlan.unavailable') }) resetToPricing() return @@ -1102,10 +1088,8 @@ export function useSubscriptionCheckout( checkoutStep.value = 'preview' return } - toast.add({ - severity: 'error', - summary: t('subscription.teamPlan.name'), - detail: + toast.error(t('subscription.teamPlan.name'), { + description: previewError instanceof Error ? previewError.message : response?.reason || t('subscription.subscribeFailed') @@ -1156,10 +1140,8 @@ export function useSubscriptionCheckout( checkoutStep.value = 'preview' return } - toast.add({ - severity: 'error', - summary: t('subscription.teamPlan.name'), - detail: + toast.error(t('subscription.teamPlan.name'), { + description: previewError instanceof Error ? previewError.message : response?.reason || t('subscription.subscribeFailed') @@ -1179,7 +1161,7 @@ export function useSubscriptionCheckout( selectedTeamCheckout.value = null activeCheckoutOperationId.value = null activeCheckoutAttemptStartedAt = undefined - toast.removeGroup('payment-recovery') + for (const id of paymentRecoveryToasts.splice(0)) toast.dismiss(id) } function handleBackToPricing() { @@ -1316,24 +1298,22 @@ export function useSubscriptionCheckout( // A refused attempt's toast stays until dismissed; a later attempt that // succeeds takes them down rather than leaving a decline over the success. - const attemptErrorToasts: ToastMessageOptions[] = [] + const attemptErrorToasts: ToastId[] = [] function showSubscribeError(error: unknown) { - const message: ToastMessageOptions = { - severity: 'error', - summary: t('g.error'), - detail: - error instanceof Error - ? error.message - : t('subscription.subscribeFailed') - } - attemptErrorToasts.push(message) - toast.add(message) + attemptErrorToasts.push( + toast.error(t('g.error'), { + description: + error instanceof Error + ? error.message + : t('subscription.subscribeFailed') + }) + ) } watch(checkoutStep, (step) => { if (step !== 'success') return - for (const message of attemptErrorToasts.splice(0)) toast.remove(message) + for (const id of attemptErrorToasts.splice(0)) toast.dismiss(id) }) async function recoverStaleQuote(error: unknown): Promise { @@ -1346,17 +1326,13 @@ export function useSubscriptionCheckout( ) if (!refreshed) { resetToPricing() - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('subscription.preview.quoteRefreshFailed') + toast.error(t('g.error'), { + description: t('subscription.preview.quoteRefreshFailed') }) return true } - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('subscription.preview.quoteStale') + toast.error(t('g.error'), { + description: t('subscription.preview.quoteStale') }) return true } @@ -1626,10 +1602,8 @@ export function useSubscriptionCheckout( // The poller announced every subscription operation it settled, whatever // the caller was tracking; on this rail there is no poller to do it. if (response.requiredPayment) { - toast.add({ - severity: 'success', - summary: t('billingOperation.subscriptionSuccess'), - life: 5000 + toast.success(t('billingOperation.subscriptionSuccess'), { + duration: 5000 }) } checkoutStep.value = 'success' @@ -1651,20 +1625,22 @@ export function useSubscriptionCheckout( if (!paymentWindow) { const paymentMethodUrl = initialActionUrl const opId = response.billing_op_id - toast.add({ - group: 'payment-recovery', - severity: 'warn', - summary: t('g.warning'), - detail: { - text: t('subscription.preview.paymentPopupBlocked'), - actionLabel: t('subscription.planLoadErrorRetry'), - // Not the mutation lock, which is released once the op is adopted. - onAction: () => { - if (activeCheckoutOperationId.value !== opId) return - window.open(paymentMethodUrl, '_blank') - } - } - }) + paymentRecoveryToasts.push( + toast.custom( + PaymentRecoveryToast, + { + title: t('g.warning'), + description: t('subscription.preview.paymentPopupBlocked'), + actionLabel: t('subscription.planLoadErrorRetry'), + // Not the mutation lock, which is released once the op is adopted. + onAction: () => { + if (activeCheckoutOperationId.value !== opId) return + window.open(paymentMethodUrl, '_blank') + } + }, + { role: 'alert' } + ) + ) } } await advanceToSuccessOnOperation( @@ -1784,10 +1760,8 @@ export function useSubscriptionCheckout( const teamCheckout = selectedTeamCheckout.value if (!teamCheckout.stop.id) { - toast.add({ - severity: 'error', - summary: t('subscription.teamPlan.name'), - detail: t('subscription.teamPlan.unavailable') + toast.error(t('subscription.teamPlan.name'), { + description: t('subscription.teamPlan.unavailable') }) finishCheckoutMutation(mutationToken) return @@ -1943,11 +1917,7 @@ export function useSubscriptionCheckout( duration_ms: Date.now() - startedAt }) } - toast.add({ - severity: 'success', - summary: t('subscription.resubscribeSuccess'), - life: 5000 - }) + toast.success(t('subscription.resubscribeSuccess'), { duration: 5000 }) emit('close', true) } catch (error) { const message = @@ -1963,10 +1933,8 @@ export function useSubscriptionCheckout( duration_ms: Date.now() - startedAt }) }) - toast.add({ - severity: 'error', - summary: 'Error', - detail: message + toast.error('Error', { + description: message }) } finally { isResubscribing.value = false diff --git a/src/platform/workspace/composables/useWorkspaceBilling.test.ts b/src/platform/workspace/composables/useWorkspaceBilling.test.ts index a4acf3c8ab9..6d4244e8cad 100644 --- a/src/platform/workspace/composables/useWorkspaceBilling.test.ts +++ b/src/platform/workspace/composables/useWorkspaceBilling.test.ts @@ -8,8 +8,8 @@ import { useFeatureFlags } from '@/composables/useFeatureFlags' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { effectScope } from 'vue' +import { useToast } from '@/components/ui/toast' import { useTelemetry } from '@/platform/telemetry' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useSubscriptionDialog } from '@/platform/cloud/subscription/composables/useSubscriptionDialog' import type { @@ -1131,10 +1131,10 @@ describe('useWorkspaceBilling', () => { expect(mockRail.openPaymentPortal).not.toHaveBeenCalled() expect(mockWorkspaceApi.getPaymentPortalUrl).not.toHaveBeenCalled() - expect(useToastStore().messagesToAdd).toEqual([ + expect(useToast().toasts).toEqual([ expect.objectContaining({ - severity: 'warn', - detail: + kind: 'warning', + description: "Couldn't open the billing page. Allow pop-ups for this site and try again." }) ]) diff --git a/src/platform/workspace/composables/useWorkspaceBilling.ts b/src/platform/workspace/composables/useWorkspaceBilling.ts index a3a4c37d128..60614eabe7a 100644 --- a/src/platform/workspace/composables/useWorkspaceBilling.ts +++ b/src/platform/workspace/composables/useWorkspaceBilling.ts @@ -13,13 +13,13 @@ import type { PreviewSubscribeInput } from '@comfyorg/account-core/billing' +import { useToast } from '@/components/ui/toast' import { useFeatureFlags } from '@/composables/useFeatureFlags' import { t } from '@/i18n' import { useBillingPlans } from '@/platform/cloud/subscription/composables/useBillingPlans' import { useSubscriptionDialog } from '@/platform/cloud/subscription/composables/useSubscriptionDialog' import type { SubscriptionDialogOptions } from '@/platform/cloud/subscription/composables/useSubscriptionDialog' import { useTelemetry } from '@/platform/telemetry' -import { useToastStore } from '@/platform/updates/common/toastStore' import { reportError } from '@/platform/telemetry/reportError' import { categorizeBillingApiError } from '@/platform/telemetry/utils/billingFailureCategory' import { createBillingPortalReporter } from '@/platform/telemetry/utils/billingPortalTelemetry' @@ -584,10 +584,8 @@ export function useWorkspaceBilling(): WorkspaceBilling { } function reportBillingTabBlocked(): void { - useToastStore().add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('subscription.billingTabBlocked') + useToast().warning(t('g.warning'), { + description: t('subscription.billingTabBlocked') }) } diff --git a/src/platform/workspace/composables/useWorkspaceUrlLoader.test.ts b/src/platform/workspace/composables/useWorkspaceUrlLoader.test.ts index 5672fca768e..f86c15734a9 100644 --- a/src/platform/workspace/composables/useWorkspaceUrlLoader.test.ts +++ b/src/platform/workspace/composables/useWorkspaceUrlLoader.test.ts @@ -5,7 +5,7 @@ import { createApp, defineComponent } from 'vue' import type { App } from 'vue' import { createI18n } from 'vue-i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useWorkspaceUrlLoader as createWorkspaceUrlLoader } from './useWorkspaceUrlLoader' @@ -97,7 +97,7 @@ describe('useWorkspaceUrlLoader', () => { expect(mockRouterReplace).not.toHaveBeenCalled() expect(useTeamWorkspaceStore().switchWorkspace).not.toHaveBeenCalled() - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().info).not.toHaveBeenCalled() }) it('switches into a member workspace named by the link', async () => { @@ -112,7 +112,7 @@ describe('useWorkspaceUrlLoader', () => { expect(useTeamWorkspaceStore().switchWorkspace).toHaveBeenCalledWith( 'workspace-2' ) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().info).not.toHaveBeenCalled() }) it('strips the param before switching, so a reload does not re-trigger it', async () => { @@ -157,10 +157,9 @@ describe('useWorkspaceUrlLoader', () => { await loadWorkspaceFromUrl() expect(mockRouterReplace).toHaveBeenCalledWith({ query: {} }) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'info', - summary: "Couldn't open that workspace. You're still in Home Base." - }) + expect(useToast().info).toHaveBeenCalledWith( + "Couldn't open that workspace. You're still in Home Base." + ) }) it('stays on the active workspace and shows a toast for an invalid link', async () => { @@ -173,10 +172,9 @@ describe('useWorkspaceUrlLoader', () => { expect(mockRouterReplace).toHaveBeenCalledWith({ query: {} }) expect(useTeamWorkspaceStore().switchWorkspace).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'info', - summary: "Couldn't open that workspace. You're still in Home Base." - }) + expect(useToast().info).toHaveBeenCalledWith( + "Couldn't open that workspace. You're still in Home Base." + ) }) it('stays on the active workspace and shows a toast for a bare ?workspace with no value', async () => { @@ -190,10 +188,9 @@ describe('useWorkspaceUrlLoader', () => { expect(mockRouterReplace).toHaveBeenCalledWith({ query: {} }) expect(useTeamWorkspaceStore().switchWorkspace).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'info', - summary: "Couldn't open that workspace. You're still in Home Base." - }) + expect(useToast().info).toHaveBeenCalledWith( + "Couldn't open that workspace. You're still in Home Base." + ) }) it('treats a repeated link with one bare entry as invalid', async () => { @@ -206,10 +203,9 @@ describe('useWorkspaceUrlLoader', () => { expect(mockRouterReplace).toHaveBeenCalledWith({ query: {} }) expect(useTeamWorkspaceStore().switchWorkspace).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'info', - summary: "Couldn't open that workspace. You're still in Home Base." - }) + expect(useToast().info).toHaveBeenCalledWith( + "Couldn't open that workspace. You're still in Home Base." + ) }) it('treats a joined stash value from a repeated login-redirect link as invalid', async () => { @@ -227,10 +223,9 @@ describe('useWorkspaceUrlLoader', () => { expect(mockRouterReplace).toHaveBeenCalledWith({ query: {} }) expect(useTeamWorkspaceStore().switchWorkspace).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'info', - summary: "Couldn't open that workspace. You're still in Home Base." - }) + expect(useToast().info).toHaveBeenCalledWith( + "Couldn't open that workspace. You're still in Home Base." + ) }) it('is a silent no-op when the link already names the active workspace', async () => { @@ -241,7 +236,7 @@ describe('useWorkspaceUrlLoader', () => { expect(mockRouterReplace).toHaveBeenCalledWith({ query: {} }) expect(useTeamWorkspaceStore().switchWorkspace).not.toHaveBeenCalled() - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().info).not.toHaveBeenCalled() }) it('restores the link after a login redirect via the preserved query', async () => { diff --git a/src/platform/workspace/composables/useWorkspaceUrlLoader.ts b/src/platform/workspace/composables/useWorkspaceUrlLoader.ts index b937fa5c195..960c679c44f 100644 --- a/src/platform/workspace/composables/useWorkspaceUrlLoader.ts +++ b/src/platform/workspace/composables/useWorkspaceUrlLoader.ts @@ -5,13 +5,13 @@ import { useI18n } from 'vue-i18n' import type { LocationQueryRaw } from 'vue-router' import { useRoute, useRouter } from 'vue-router' +import { useToast } from '@/components/ui/toast' import { clearPreservedQuery, hydratePreservedQuery, mergePreservedQueryIntoQuery } from '@/platform/navigation/preservedQueryManager' import { PRESERVED_QUERY_NAMESPACES } from '@/platform/navigation/preservedQueryNamespaces' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useWorkspaceSwitch } from './useWorkspaceSwitch' import { useTeamWorkspaceStore } from '../stores/teamWorkspaceStore' @@ -58,21 +58,20 @@ export function useWorkspaceUrlLoader() { const route = useRoute() const router = useRouter() const { t } = useI18n() - const toastStore = useToastStore() + const toast = useToast() const { switchWorkspace } = useWorkspaceSwitch() const { activeWorkspace, workspaceName } = storeToRefs( useTeamWorkspaceStore() ) function notifyStayed() { - toastStore.add({ - severity: 'info', - summary: t( + toast.info( + t( 'workspace.deepLinkStayed', { workspaceName: workspaceName.value }, { escapeParameter: false } ) - }) + ) } /** Strips `workspace`, keeping other params, and clears the stash. Must diff --git a/src/platform/workspace/stores/billingOperationStore.test.ts b/src/platform/workspace/stores/billingOperationStore.test.ts index 9165e045816..9c1c6e570e9 100644 --- a/src/platform/workspace/stores/billingOperationStore.test.ts +++ b/src/platform/workspace/stores/billingOperationStore.test.ts @@ -6,7 +6,7 @@ import { getActiveCheckoutJourney, resolveCheckoutJourney } from '@/platform/workspace/utils/checkoutJourney' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useDialogStore } from '@/stores/dialogStore' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' @@ -58,8 +58,6 @@ import { workspaceApi } from '@/platform/workspace/api/workspaceApi' import { useBillingOperationStore } from './billingOperationStore' beforeEach(() => { - vi.mocked(useToastStore().add).mockImplementation(() => {}) - vi.mocked(useToastStore().remove).mockImplementation(() => {}) vi.mocked(useDialogStore().closeDialog).mockImplementation(() => {}) sessionStorage.clear() clearCheckoutJourney() @@ -289,14 +287,14 @@ describe('billingOperationStore', () => { it('withdraws the processing toast once the poll finds the checkout parked on a payment method, and stays quiet', async () => { await pollPhase('awaiting_payment_method') - const processing = vi.mocked(useToastStore().add).mock.calls[0][0] + const processing = vi.mocked(useToast().info).mock.results[0].value await vi.waitFor(() => - expect(useToastStore().remove).toHaveBeenCalledWith(processing) + expect(useToast().dismiss).toHaveBeenCalledWith(processing) ) await vi.advanceTimersByTimeAsync(31_000) - expect(useToastStore().add).toHaveBeenCalledOnce() + expect(useToast().info).toHaveBeenCalledOnce() }) it('exposes an invoice phase without an action URL as needing the customer', async () => { @@ -420,11 +418,9 @@ describe('billingOperationStore', () => { const store = useBillingOperationStore() void store.startOperation('op-1', 'subscription') - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'info', - summary: 'billingOperation.subscriptionProcessing', - group: 'billing-operation' - }) + expect(vi.mocked(useToast().info)).toHaveBeenCalledWith( + 'billingOperation.subscriptionProcessing' + ) }) it('does not show a processing toast when the checkout owns progress', () => { @@ -439,7 +435,7 @@ describe('billingOperationStore', () => { suppressProcessingToast: true }) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(vi.mocked(useToast().info)).not.toHaveBeenCalled() }) it('shows immediate processing toast for topup operations', () => { @@ -452,11 +448,9 @@ describe('billingOperationStore', () => { const store = useBillingOperationStore() void store.startOperation('op-1', 'topup') - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'info', - summary: 'billingOperation.topupProcessing', - group: 'billing-operation' - }) + expect(vi.mocked(useToast().info)).toHaveBeenCalledWith( + 'billingOperation.topupProcessing' + ) }) describe('a resumed operation', () => { @@ -490,11 +484,13 @@ describe('billingOperationStore', () => { resumed: true }) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().info).not.toHaveBeenCalled() + expect(useToast().warning).not.toHaveBeenCalled() serve('awaiting_payment_method') await vi.advanceTimersByTimeAsync(31_000) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().info).not.toHaveBeenCalled() + expect(useToast().warning).not.toHaveBeenCalled() }) it.for([['in_progress'], [undefined]] as const)( @@ -506,16 +502,14 @@ describe('billingOperationStore', () => { resumed: true }) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().info).not.toHaveBeenCalled() serve(phase) await vi.advanceTimersByTimeAsync(0) - expect(useToastStore().add).toHaveBeenCalledOnce() - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'info', - summary: 'billingOperation.subscriptionProcessing', - group: 'billing-operation' - }) + expect(useToast().info).toHaveBeenCalledOnce() + expect(useToast().info).toHaveBeenCalledWith( + 'billingOperation.subscriptionProcessing' + ) } ) @@ -529,11 +523,9 @@ describe('billingOperationStore', () => { 'https://invoice.stripe.com/sensitive-token' ) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'warn', - summary: 'billingOperation.subscriptionActionRequired', - group: 'billing-operation' - }) + expect(useToast().warning).toHaveBeenCalledWith( + 'billingOperation.subscriptionActionRequired' + ) serve('in_progress') await vi.advanceTimersByTimeAsync(0) }) @@ -762,11 +754,10 @@ describe('billingOperationStore', () => { expect(billing.fetchStatus).not.toHaveBeenCalled() expect(billing.fetchBalance).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'success', - summary: 'billingOperation.subscriptionSuccess', - life: 5000 - }) + expect(vi.mocked(useToast().success)).toHaveBeenCalledWith( + 'billingOperation.subscriptionSuccess', + { duration: 5000 } + ) }) it('leaves the checkout dialog open on subscription success', async () => { @@ -1066,11 +1057,10 @@ describe('billingOperationStore', () => { await vi.advanceTimersByTimeAsync(0) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'success', - summary: 'billingOperation.topupSuccess', - life: 5000 - }) + expect(vi.mocked(useToast().success)).toHaveBeenCalledWith( + 'billingOperation.topupSuccess', + { duration: 5000 } + ) }) it('reports duration_ms as the time elapsed since the operation started', async () => { @@ -1145,11 +1135,11 @@ describe('billingOperationStore', () => { const store = useBillingOperationStore() void store.startOperation('op-1', 'subscription') - const receivedToast = vi.mocked(useToastStore().add).mock.calls[0][0] + const receivedToast = vi.mocked(useToast().info).mock.results[0].value await vi.advanceTimersByTimeAsync(0) - expect(useToastStore().remove).toHaveBeenCalledWith(receivedToast) + expect(useToast().dismiss).toHaveBeenCalledWith(receivedToast) }) it('resolves the terminal promise even if a success side effect throws', async () => { @@ -1159,8 +1149,8 @@ describe('billingOperationStore', () => { started_at: new Date().toISOString() }) const error = new Error('toast rendering failed') - vi.mocked(useToastStore().add).mockImplementation((toast) => { - if (toast.severity === 'success') throw error + vi.mocked(useToast().success).mockImplementation(() => { + throw error }) const store = useBillingOperationStore() @@ -1183,7 +1173,7 @@ describe('billingOperationStore', () => { started_at: new Date().toISOString() }) const error = new Error('toast cleanup failed') - vi.mocked(useToastStore().remove).mockImplementationOnce(() => { + vi.mocked(useToast().dismiss).mockImplementationOnce(() => { throw error }) @@ -1243,12 +1233,13 @@ describe('billingOperationStore', () => { ) expect(store.hasPendingOperations).toBe(false) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'billingOperation.subscriptionFailed', - detail: 'billingOperation.subscriptionFailedDetail', - life: 7000 - }) + expect(vi.mocked(useToast().error)).toHaveBeenCalledWith( + 'billingOperation.subscriptionFailed', + { + description: 'billingOperation.subscriptionFailedDetail', + duration: 7000 + } + ) expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith({ operation: 'operation', billing_client: 'legacy', @@ -1340,9 +1331,7 @@ describe('billingOperationStore', () => { await vi.advanceTimersByTimeAsync(0) expect(store.getOperation('op-1')?.status).toBe('failed') - expect(useToastStore().add).not.toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(useToast().error).not.toHaveBeenCalled() expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith( expect.objectContaining({ stage: 'failed', @@ -1460,12 +1449,10 @@ describe('billingOperationStore', () => { await vi.advanceTimersByTimeAsync(0) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'billingOperation.topupFailed', - detail: undefined, - life: 7000 - }) + expect(vi.mocked(useToast().error)).toHaveBeenCalledWith( + 'billingOperation.topupFailed', + { description: undefined, duration: 7000 } + ) }) // The bank refused to approve the charge without the customer. A failed @@ -1490,12 +1477,13 @@ describe('billingOperationStore', () => { errorMessage: 'billingOperation.authenticatePaymentDetail', actionUrl: null }) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'billingOperation.topupFailed', - detail: 'billingOperation.authenticatePaymentDetail', - life: 7000 - }) + expect(useToast().error).toHaveBeenCalledWith( + 'billingOperation.topupFailed', + { + description: 'billingOperation.authenticatePaymentDetail', + duration: 7000 + } + ) }) it.for([ @@ -1803,11 +1791,9 @@ describe('billingOperationStore', () => { await vi.advanceTimersByTimeAsync(0) expect(store.getOperation('op-1')?.errorMessage).toBe(detail) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'error', - summary, - detail, - life: 7000 + expect(vi.mocked(useToast().error)).toHaveBeenCalledWith(summary, { + description: detail, + duration: 7000 }) } ) @@ -2961,10 +2947,9 @@ describe('billingOperationStore', () => { expect(operation?.status).toBe('timeout') expect(store.hasPendingOperations).toBe(false) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'billingOperation.subscriptionTimeout' - }) + expect(vi.mocked(useToast().error)).toHaveBeenCalledWith( + 'billingOperation.subscriptionTimeout' + ) }) it('reports duration_ms of at least the timeout threshold', async () => { @@ -3036,7 +3021,12 @@ describe('billingOperationStore', () => { expect((await terminal).status).toBe('succeeded') expect(store.getOperation('op-1')?.actionUrl).toBeNull() expect( - JSON.stringify(vi.mocked(useToastStore().add).mock.calls) + JSON.stringify([ + vi.mocked(useToast().info).mock.calls, + vi.mocked(useToast().warning).mock.calls, + vi.mocked(useToast().success).mock.calls, + vi.mocked(useToast().error).mock.calls + ]) ).not.toContain(actionUrl) expect( JSON.stringify(vi.mocked(useTelemetry()?.trackBillingEvent)?.mock.calls) @@ -3054,21 +3044,16 @@ describe('billingOperationStore', () => { const store = useBillingOperationStore() void store.startOperation('op-1', 'subscription') - const processingToast = { - severity: 'info', - summary: 'billingOperation.subscriptionProcessing', - group: 'billing-operation' - } - expect(useToastStore().add).toHaveBeenCalledWith(processingToast) + expect(vi.mocked(useToast().info)).toHaveBeenCalledWith( + 'billingOperation.subscriptionProcessing' + ) await vi.advanceTimersByTimeAsync(0) - expect(useToastStore().remove).toHaveBeenCalledWith(processingToast) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'warn', - summary: 'billingOperation.subscriptionActionRequired', - group: 'billing-operation' - }) + expect(vi.mocked(useToast().dismiss)).toHaveBeenCalledWith(1) + expect(vi.mocked(useToast().warning)).toHaveBeenCalledWith( + 'billingOperation.subscriptionActionRequired' + ) }) it('announces verification immediately when the action URL is known at start', () => { @@ -3086,15 +3071,11 @@ describe('billingOperationStore', () => { 'https://verify.example/sensitive-token' ) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'warn', - summary: 'billingOperation.topupActionRequired', - group: 'billing-operation' - }) - expect(useToastStore().add).not.toHaveBeenCalledWith( - expect.objectContaining({ - summary: 'billingOperation.topupProcessing' - }) + expect(vi.mocked(useToast().warning)).toHaveBeenCalledWith( + 'billingOperation.topupActionRequired' + ) + expect(vi.mocked(useToast().info)).not.toHaveBeenCalledWith( + 'billingOperation.topupProcessing' ) }) @@ -3116,23 +3097,18 @@ describe('billingOperationStore', () => { void store.startOperation('op-1', 'subscription') await vi.advanceTimersByTimeAsync(0) - const actionRequiredToast = { - severity: 'warn', - summary: 'billingOperation.subscriptionActionRequired', - group: 'billing-operation' - } - expect(useToastStore().add).toHaveBeenCalledWith(actionRequiredToast) + expect(vi.mocked(useToast().warning)).toHaveBeenCalledWith( + 'billingOperation.subscriptionActionRequired' + ) // The verification action is gone, so the prompt pointing at it must go // too rather than asking for something the customer can no longer do. await vi.advanceTimersByTimeAsync(30_000) - expect(useToastStore().remove).toHaveBeenCalledWith(actionRequiredToast) - expect(useToastStore().add).toHaveBeenLastCalledWith({ - severity: 'info', - summary: 'billingOperation.subscriptionProcessing', - group: 'billing-operation' - }) + expect(vi.mocked(useToast().dismiss)).toHaveBeenLastCalledWith(2) + expect(vi.mocked(useToast().info)).toHaveBeenLastCalledWith( + 'billingOperation.subscriptionProcessing' + ) }) it('does not re-announce verification on later polls', async () => { @@ -3149,10 +3125,9 @@ describe('billingOperationStore', () => { const actionRequiredAdds = () => vi - .mocked(useToastStore().add) + .mocked(useToast().warning) .mock.calls.filter( - (call) => - call[0].summary === 'billingOperation.subscriptionActionRequired' + ([title]) => title === 'billingOperation.subscriptionActionRequired' ).length expect(actionRequiredAdds()).toBe(1) @@ -3362,10 +3337,9 @@ describe('billingOperationStore', () => { await vi.advanceTimersByTimeAsync(121_000) await vi.runAllTimersAsync() - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'error', - summary: 'billingOperation.topupTimeout' - }) + expect(vi.mocked(useToast().error)).toHaveBeenCalledWith( + 'billingOperation.topupTimeout' + ) }) it('keeps polling a topup while authentication is required', async () => { @@ -3387,10 +3361,9 @@ describe('billingOperationStore', () => { actionUrl, authenticationRequiredSeen: true }) - expect(useToastStore().add).not.toHaveBeenCalledWith({ - severity: 'error', - summary: 'billingOperation.topupTimeout' - }) + expect(vi.mocked(useToast().error)).not.toHaveBeenCalledWith( + 'billingOperation.topupTimeout' + ) }) }) @@ -3473,7 +3446,7 @@ describe('billingOperationStore', () => { const store = useBillingOperationStore() void store.startOperation('op-1', 'cancel') - expect(useToastStore().add).not.toHaveBeenCalled() + expect(vi.mocked(useToast().info)).not.toHaveBeenCalled() }) it('resolves with the succeeded operation and refreshes status', async () => { @@ -3542,7 +3515,7 @@ describe('billingOperationStore', () => { await terminal expect(useSettingsDialog().show).not.toHaveBeenCalled() - expect(useToastStore().add).not.toHaveBeenCalled() + expect(vi.mocked(useToast().success)).not.toHaveBeenCalled() }) it('resolves with a failed operation and default message, no toast', async () => { @@ -3563,7 +3536,7 @@ describe('billingOperationStore', () => { expect( useTeamWorkspaceStore().updateActiveWorkspace ).not.toHaveBeenCalled() - expect(useToastStore().add).not.toHaveBeenCalled() + expect(vi.mocked(useToast().error)).not.toHaveBeenCalled() expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith( expect.objectContaining({ operation: 'operation', @@ -3599,7 +3572,7 @@ describe('billingOperationStore', () => { expect( useTeamWorkspaceStore().updateActiveWorkspace ).not.toHaveBeenCalled() - expect(useToastStore().add).not.toHaveBeenCalled() + expect(vi.mocked(useToast().error)).not.toHaveBeenCalled() expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith( expect.objectContaining({ operation: 'operation', @@ -3696,9 +3669,7 @@ describe('billingOperationStore', () => { expect(store.getOperation('op-1')?.status).toBe('pending') expect(store.hasPendingOperations).toBe(true) expect(resolved).toBe(false) - expect(useToastStore().add).not.toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect(useToast().error).not.toHaveBeenCalled() }) it('polls pending operations immediately when the page becomes visible', async () => { diff --git a/src/platform/workspace/stores/billingOperationStore.ts b/src/platform/workspace/stores/billingOperationStore.ts index fddf19932cb..3a0b863bd55 100644 --- a/src/platform/workspace/stores/billingOperationStore.ts +++ b/src/platform/workspace/stores/billingOperationStore.ts @@ -4,7 +4,6 @@ import type { SubscriptionCheckoutTier, SubscriptionCheckoutType } from '@comfyorg/account-core/billing' -import type { ToastMessageOptions } from 'primevue/toast' import type { PaymentIntent } from '@stripe/stripe-js' import { loadStripe } from '@stripe/stripe-js/pure' import { customerCanActHere } from '@comfyorg/account-core/billing' @@ -13,6 +12,8 @@ import { defineStore } from 'pinia' import { computed, ref } from 'vue' import { useBillingContext } from '@/composables/billing/useBillingContext' +import { useToast } from '@/components/ui/toast' +import type { ToastId } from '@/components/ui/toast' import { useFeatureFlags } from '@/composables/useFeatureFlags' import { t } from '@/i18n' import type { TierKey } from '@/platform/cloud/subscription/constants/tierPricing' @@ -22,7 +23,6 @@ import { isCloud } from '@/platform/distribution/types' import { useTelemetry } from '@/platform/telemetry' import { reportError } from '@/platform/telemetry/reportError' import type { PaymentIntentSource } from '@/platform/telemetry/types' -import { useToastStore } from '@/platform/updates/common/toastStore' import { workspaceApi } from '@/platform/workspace/api/workspaceApi' import type { BillingAuthenticationState, @@ -178,7 +178,7 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { const waitingWithoutActionSince = new Map() const progressToasts = new Map< string, - { kind: ProgressToastKind; message: ToastMessageOptions } + { kind: ProgressToastKind; id: ToastId } >() const progressToastsAwaitingFirstRead = new Set() const terminalResolvers = new Map() @@ -249,11 +249,11 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { type: PaymentOperationType, kind: ProgressToastKind | undefined ) { - const toastStore = useToastStore() + const toastStore = useToast() const previous = progressToasts.get(opId) if (previous?.kind === kind) return if (previous) { - toastStore.remove(previous.message) + toastStore.dismiss(previous.id) progressToasts.delete(opId) } if (kind === undefined) return @@ -267,14 +267,11 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { ? 'billingOperation.topupActionRequired' : 'billingOperation.topupProcessing' - const message: ToastMessageOptions = { - // 'warn' selects the prompt icon over the spinner in GlobalToast. - severity: kind === 'action' ? 'warn' : 'info', - summary: t(messageKey), - group: 'billing-operation' - } - progressToasts.set(opId, { kind, message }) - toastStore.add(message) + const id = + kind === 'action' + ? toastStore.warning(t(messageKey)) + : toastStore.info(t(messageKey)) + progressToasts.set(opId, { kind, id }) } function announceStart( @@ -932,17 +929,13 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { useSettingsDialog().show(isCloud ? 'workspace' : 'credits') } - const toastStore = useToastStore() + const toastStore = useToast() const messageKey = operation.type === 'subscription' ? 'billingOperation.subscriptionSuccess' : 'billingOperation.topupSuccess' - toastStore.add({ - severity: 'success', - summary: t(messageKey), - life: 5000 - }) + toastStore.success(t(messageKey), { duration: 5000 }) } catch (error) { reportError(error, { surface: 'billing', @@ -1045,11 +1038,9 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { } if (isPaymentOperation(operation.type) && !superseded) { - useToastStore().add({ - severity: 'error', - summary: defaultMessage, - detail: detail ?? undefined, - life: 7000 + useToast().error(defaultMessage, { + description: detail ?? undefined, + duration: 7000 }) } @@ -1197,10 +1188,7 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { } if (isPaymentOperation(operation.type)) { - useToastStore().add({ - severity: 'error', - summary: message - }) + useToast().error(message) } resolveTerminal(opId) @@ -1358,7 +1346,7 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { const progressToast = progressToasts.get(opId) if (progressToast) { - useToastStore().remove(progressToast.message) + useToast().dismiss(progressToast.id) progressToasts.delete(opId) } } diff --git a/src/platform/workspace/stores/useWorkspaceAuth.test.ts b/src/platform/workspace/stores/useWorkspaceAuth.test.ts index e88282e9064..a4717802a4c 100644 --- a/src/platform/workspace/stores/useWorkspaceAuth.test.ts +++ b/src/platform/workspace/stores/useWorkspaceAuth.test.ts @@ -4,7 +4,7 @@ import { useAuthStore } from '@/stores/authStore' import { useDialogStore } from '@/stores/dialogStore' import { SSO_REQUIRED_DIALOG_KEY } from '@/platform/auth/sso/ssoRequiredDialogKey' import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import type { User } from 'firebase/auth' import { storeToRefs } from 'pinia' @@ -134,7 +134,7 @@ beforeEach(() => { }) stubFirebaseAuthHarness() - vi.mocked(useToastStore().add).mockImplementation(() => {}) + vi.mocked(useToast().error).mockImplementation(() => 0) }) describe('useWorkspaceAuthStore', () => { @@ -959,7 +959,7 @@ describe('useWorkspaceAuthStore', () => { expect(token).toBeNull() expect(currentWorkspace.value).toBeNull() - expect(useToastStore().add).toHaveBeenCalledTimes(1) + expect(useToast().error).toHaveBeenCalledTimes(1) }) it.for([ @@ -1108,7 +1108,7 @@ describe('useWorkspaceAuthStore', () => { expect(token).toBeNull() expect(currentWorkspace.value?.id).toBe('workspace-123') - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() expect( useTeamWorkspaceStore().forgetRevokedActiveWorkspace ).not.toHaveBeenCalled() @@ -2428,10 +2428,10 @@ describe('useWorkspaceAuthStore', () => { // A permanent failure resolves to null (the caller surfaces its 401), // fires the error toast keyed to the 401 code, and clears the dead session. expect(result).toBeNull() - expect(useToastStore().add).toHaveBeenCalledWith( + expect(useToast().error).toHaveBeenCalledWith( + expect.any(String), expect.objectContaining({ - severity: 'error', - detail: 'workspaceAuth.errors.invalidFirebaseToken' + description: 'workspaceAuth.errors.invalidFirebaseToken' }) ) expect(unifiedToken.value).toBeNull() @@ -2468,7 +2468,7 @@ describe('useWorkspaceAuthStore', () => { const result = await store.remintUnifiedOnce('unified-token-1') expect(result).toBeNull() - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() expect(unifiedToken.value).toBe('unified-token-1') }) @@ -2567,7 +2567,7 @@ describe('useWorkspaceAuthStore', () => { await expect(mintPromise).resolves.toBe(false) expect(store.unifiedToken).toBeNull() - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() }) it('coalesces concurrent re-mints and returns the winning token to every caller', async () => { @@ -2902,8 +2902,9 @@ describe('useWorkspaceAuthStore', () => { await vi.advanceTimersByTimeAsync(expiresInMs - 5 * 60 * 1000) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error', detail: detailKey }) + expect(useToast().error).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: detailKey }) ) expect( useTelemetry()?.trackUnifiedAuthRefresh @@ -3006,7 +3007,7 @@ describe('useWorkspaceAuthStore', () => { await vi.advanceTimersByTimeAsync(expiresInMs - 5 * 60 * 1000) expect(fetch).toHaveBeenCalledTimes(1) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() }) it('does not toast on a successful refresh re-mint', async () => { @@ -3025,7 +3026,7 @@ describe('useWorkspaceAuthStore', () => { await store.mintAtLogin() await vi.advanceTimersByTimeAsync(expiresInMs - 5 * 60 * 1000) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() }) it('does not toast on a transient refresh failure and keeps the slot', async () => { @@ -3057,7 +3058,7 @@ describe('useWorkspaceAuthStore', () => { const refreshDelay = expiresInMs - 5 * 60 * 1000 await vi.advanceTimersByTimeAsync(refreshDelay) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() expect(unifiedToken.value).toBe('unified-token-1') }) @@ -3208,7 +3209,7 @@ describe('useWorkspaceAuthStore', () => { await vi.advanceTimersByTimeAsync(60 * 60 * 1000) expect(fetch).toHaveBeenCalledTimes(5) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() expect(useTelemetry()?.trackUnifiedAuthRefresh).toHaveBeenLastCalledWith({ outcome: 'expired', retry_count: 3 @@ -3265,7 +3266,7 @@ describe('useWorkspaceAuthStore', () => { retry_count: 3 }) expect(fetch).toHaveBeenCalledTimes(1) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() expect( unifiedToken.value, 'a token read failure is not a revocation; the token serves until it expires' @@ -3310,7 +3311,7 @@ describe('useWorkspaceAuthStore', () => { await vi.advanceTimersByTimeAsync(expiresInMs - 5 * 60 * 1000) expect(fetch).toHaveBeenCalledTimes(1) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() await vi.advanceTimersByTimeAsync(5000) @@ -3391,10 +3392,10 @@ describe('useWorkspaceAuthStore', () => { expect(result).toBe(false) expect(unifiedToken.value).toBeNull() - expect(useToastStore().add).toHaveBeenCalledWith( + expect(useToast().error).toHaveBeenCalledWith( + expect.any(String), expect.objectContaining({ - severity: 'error', - detail: 'workspaceAuth.errors.invalidFirebaseToken' + description: 'workspaceAuth.errors.invalidFirebaseToken' }) ) }) @@ -3418,7 +3419,7 @@ describe('useWorkspaceAuthStore', () => { await store.remintUnifiedOnce('unified-token-1') await vi.advanceTimersByTimeAsync(60 * 60 * 1000) - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() }) }) diff --git a/src/platform/workspace/stores/workspaceAuthStore.ts b/src/platform/workspace/stores/workspaceAuthStore.ts index 57604675748..f12d99b943e 100644 --- a/src/platform/workspace/stores/workspaceAuthStore.ts +++ b/src/platform/workspace/stores/workspaceAuthStore.ts @@ -37,7 +37,7 @@ import type { WorkspaceTokenResponse } from '@/platform/workspace/stores/legacyW import { WorkspaceAuthError } from '@/platform/workspace/stores/workspaceAuthError' import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore' import { presentSsoRequired } from '@/platform/auth/sso/ssoRequired' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useAuthStore } from '@/stores/authStore' import type { AuthHeader } from '@/types/authTypes' import type { WorkspaceIdentity } from '@/platform/workspace/workspaceTypes' @@ -99,10 +99,8 @@ function surfacePermanentAuthError(err: WorkspaceAuthError): void { return } console.error('Unified workspace auth revoked or invalid:', err) - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t( + useToast().error(t('g.error'), { + description: t( sessionErrorMessageKey( isSessionErrorCode(err.code) ? err.code : 'TOKEN_EXCHANGE_FAILED' ) diff --git a/src/renderer/extensions/compositor/composables/useCompositorEditor.test.ts b/src/renderer/extensions/compositor/composables/useCompositorEditor.test.ts index 379566d5b89..dee560da681 100644 --- a/src/renderer/extensions/compositor/composables/useCompositorEditor.test.ts +++ b/src/renderer/extensions/compositor/composables/useCompositorEditor.test.ts @@ -1,7 +1,7 @@ import { render } from '@testing-library/vue' import { beforeEach, describe, expect, it, vi } from 'vitest' import { useDialogStore } from '@/stores/dialogStore' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { createI18n } from 'vue-i18n' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' @@ -38,10 +38,6 @@ function mountComposable(): ReturnType { return composable } -beforeEach(() => { - vi.mocked(useToastStore().add).mockImplementation(() => undefined) -}) - describe('useCompositorEditor', () => { const node = { id: toNodeId(1) } as unknown as LGraphNode @@ -52,12 +48,9 @@ describe('useCompositorEditor', () => { it('shows a toast and keeps the dialog closed without cached layers', () => { mountComposable().openCompositorEditor(node) - expect(vi.mocked(useToastStore().add)).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'info', - summary: 'Layer editor', - detail: 'Run the workflow first' - }) + expect(vi.mocked(useToast().info)).toHaveBeenCalledWith( + 'Layer editor', + expect.objectContaining({ description: 'Run the workflow first' }) ) expect(vi.mocked(useDialogStore().showDialog)).not.toHaveBeenCalled() }) @@ -69,12 +62,9 @@ describe('useCompositorEditor', () => { mountComposable().openCompositorEditor(node) - expect(vi.mocked(useToastStore().add)).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'info', - summary: 'Layer editor', - detail: 'Run the workflow first' - }) + expect(vi.mocked(useToast().info)).toHaveBeenCalledWith( + 'Layer editor', + expect.objectContaining({ description: 'Run the workflow first' }) ) expect(vi.mocked(useDialogStore().showDialog)).not.toHaveBeenCalled() }) @@ -88,7 +78,7 @@ describe('useCompositorEditor', () => { mountComposable().openCompositorEditor(node) - expect(vi.mocked(useToastStore().add)).not.toHaveBeenCalled() + expect(vi.mocked(useToast().info)).not.toHaveBeenCalled() expect(vi.mocked(useDialogStore().showDialog)).toHaveBeenCalledWith( expect.objectContaining({ key: 'global-layer-editor', diff --git a/src/renderer/extensions/compositor/composables/useCompositorEditor.ts b/src/renderer/extensions/compositor/composables/useCompositorEditor.ts index 9318f3d7f61..3593e852854 100644 --- a/src/renderer/extensions/compositor/composables/useCompositorEditor.ts +++ b/src/renderer/extensions/compositor/composables/useCompositorEditor.ts @@ -11,7 +11,7 @@ import { } from '@/renderer/extensions/layerEditor/composables/layerEditorDialog' import { LAYER_EDITOR_DIALOG_KEY } from '@/renderer/extensions/layerEditor/layerEditorDialogKey' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useDialogStore } from '@/stores/dialogStore' export function useCompositorEditor() { @@ -22,10 +22,8 @@ export function useCompositorEditor() { !hasCompositorLayers(node) || !getCompositorInputsFingerprint(node)?.length ) { - useToastStore().add({ - severity: 'info', - summary: t('layerEditor.title'), - detail: t('compositor.runWorkflowFirst') + useToast().info(t('layerEditor.title'), { + description: t('compositor.runWorkflowFirst') }) return } diff --git a/src/renderer/extensions/compositor/composables/useCompositorPsdDownload.test.ts b/src/renderer/extensions/compositor/composables/useCompositorPsdDownload.test.ts index 059521a87bf..a0dad66b212 100644 --- a/src/renderer/extensions/compositor/composables/useCompositorPsdDownload.test.ts +++ b/src/renderer/extensions/compositor/composables/useCompositorPsdDownload.test.ts @@ -1,4 +1,4 @@ -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type { App } from 'vue' import { createApp, defineComponent, ref } from 'vue' @@ -10,6 +10,7 @@ import { toNodeId } from '@/types/nodeId' import { useCompositorPsdDownload } from './useCompositorPsdDownload' +const toastAdd = vi.hoisted(() => vi.fn()) const { buildSessionPsdBlob, downloadBlob, loadCompositorSession } = vi.hoisted( () => ({ buildSessionPsdBlob: vi.fn(async () => new Blob(['psd'])), @@ -32,7 +33,26 @@ vi.mock( }) ) vi.mock(import('@/base/common/downloadUtil'), () => ({ downloadBlob })) - +beforeEach(() => { + vi.mocked(useToast().success).mockImplementation((...args: unknown[]) => + toastAdd('success', ...args) + ) + vi.mocked(useToast().error).mockImplementation((...args: unknown[]) => + toastAdd('error', ...args) + ) + vi.mocked(useToast().info).mockImplementation((...args: unknown[]) => + toastAdd('info', ...args) + ) + vi.mocked(useToast().warning).mockImplementation((...args: unknown[]) => + toastAdd('warning', ...args) + ) + vi.mocked(useToast().loading).mockImplementation((...args: unknown[]) => + toastAdd('loading', ...args) + ) + vi.mocked(useToast().custom).mockImplementation((...args: unknown[]) => + toastAdd('custom', ...args) + ) +}) const i18n = createI18n({ legacy: false, locale: 'en', @@ -74,10 +94,6 @@ function makeSession(glOk = true) { const node = { id: toNodeId(5) } as unknown as LGraphNode -beforeEach(() => { - vi.mocked(useToastStore().add).mockImplementation(() => undefined) -}) - describe('useCompositorPsdDownload', () => { beforeEach(() => { loadCompositorSession.mockResolvedValue(0) @@ -103,7 +119,7 @@ describe('useCompositorPsdDownload', () => { ) expect(session.dispose).toHaveBeenCalledTimes(1) expect(exporting.value).toBe(false) - expect(vi.mocked(useToastStore().add)).not.toHaveBeenCalled() + expect(vi.mocked(toastAdd)).not.toHaveBeenCalled() }) it('reports an error and still disposes when WebGL is unavailable', async () => { @@ -115,11 +131,10 @@ describe('useCompositorPsdDownload', () => { await downloadPsd(node) expect(downloadBlob).not.toHaveBeenCalled() - expect(vi.mocked(useToastStore().add)).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'layerEditor.webglUnavailable' - }) + expect(toastAdd).toHaveBeenCalledWith( + 'error', + expect.any(String), + expect.objectContaining({ description: 'layerEditor.webglUnavailable' }) ) expect(session.dispose).toHaveBeenCalledTimes(1) }) @@ -135,7 +150,7 @@ describe('useCompositorPsdDownload', () => { expect(buildSessionPsdBlob).not.toHaveBeenCalled() expect(downloadBlob).not.toHaveBeenCalled() - expect(vi.mocked(useToastStore().add)).toHaveBeenCalledTimes(1) + expect(vi.mocked(toastAdd)).toHaveBeenCalledTimes(1) expect(session.dispose).toHaveBeenCalledTimes(1) }) @@ -149,7 +164,7 @@ describe('useCompositorPsdDownload', () => { await downloadPsd(node) expect(downloadBlob).not.toHaveBeenCalled() - expect(vi.mocked(useToastStore().add)).toHaveBeenCalledTimes(1) + expect(vi.mocked(toastAdd)).toHaveBeenCalledTimes(1) expect(session.dispose).toHaveBeenCalledTimes(1) expect(exporting.value).toBe(false) }) @@ -162,7 +177,7 @@ describe('useCompositorPsdDownload', () => { await downloadPsd(node) expect(downloadBlob).not.toHaveBeenCalled() - expect(vi.mocked(useToastStore().add)).toHaveBeenCalledTimes(1) + expect(vi.mocked(toastAdd)).toHaveBeenCalledTimes(1) expect(exporting.value).toBe(false) }) diff --git a/src/renderer/extensions/compositor/composables/useCompositorPsdDownload.ts b/src/renderer/extensions/compositor/composables/useCompositorPsdDownload.ts index 56f64715ce2..335ce537b54 100644 --- a/src/renderer/extensions/compositor/composables/useCompositorPsdDownload.ts +++ b/src/renderer/extensions/compositor/composables/useCompositorPsdDownload.ts @@ -10,13 +10,13 @@ import { import type { LayerEditorSession } from '@/renderer/extensions/layerEditor/composables/useLayerEditorSession' import { useLayerEditorSession } from '@/renderer/extensions/layerEditor/composables/useLayerEditorSession' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' export function useCompositorPsdDownload( createSession: () => LayerEditorSession = () => useLayerEditorSession() ) { const { t } = useI18n() - const toastStore = useToastStore() + const toastStore = useToast() const exporting = ref(false) async function downloadPsd(node: LGraphNode): Promise { @@ -27,10 +27,8 @@ export function useCompositorPsdDownload( session = createSession() if (!session.glOk.value) { console.error('[Compositor] WebGL compositor unavailable') - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('layerEditor.webglUnavailable') + toastStore.error(t('g.error'), { + description: t('layerEditor.webglUnavailable') }) return } @@ -39,10 +37,8 @@ export function useCompositorPsdDownload( ) if (failed > 0) { console.error(`[Compositor] ${failed} layer(s) failed to load`) - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('layerEditor.exportPsdFailed') + toastStore.error(t('g.error'), { + description: t('layerEditor.exportPsdFailed') }) return } @@ -50,10 +46,8 @@ export function useCompositorPsdDownload( downloadBlob(psdExportFilename(new Date()), blob) } catch (err) { console.warn('[Compositor] PSD export failed', err) - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: + toastStore.error(t('g.error'), { + description: session && !session.glOk.value ? t('layerEditor.webglUnavailable') : t('layerEditor.exportPsdFailed') diff --git a/src/renderer/extensions/layerEditor/components/LayerEditorContent.test.ts b/src/renderer/extensions/layerEditor/components/LayerEditorContent.test.ts index 8203d5a5cd2..facd21d3d44 100644 --- a/src/renderer/extensions/layerEditor/components/LayerEditorContent.test.ts +++ b/src/renderer/extensions/layerEditor/components/LayerEditorContent.test.ts @@ -1,5 +1,6 @@ +import { useToast } from '@/components/ui/toast' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' -import { useToastStore } from '@/platform/updates/common/toastStore' + import { useNodeOutputStore } from '@/stores/nodeOutputStore' import { fromPartial } from '@total-typescript/shoehorn' import userEvent from '@testing-library/user-event' @@ -18,6 +19,7 @@ const { autoSaveStop, beforeChange, loadCompositorSession, + toastAdd, saveLayerState, savePreview, session @@ -26,7 +28,7 @@ const { autoSaveStop: vi.fn(), beforeChange: vi.fn(), loadCompositorSession: vi.fn().mockResolvedValue(0), - + toastAdd: vi.fn(), saveLayerState: vi.fn(() => true), savePreview: vi.fn().mockResolvedValue(undefined), session: { @@ -77,7 +79,14 @@ vi.mock( useCompositorAutoSave: vi.fn(() => ({ stop: autoSaveStop })) }) ) - +beforeEach(() => { + vi.mocked(useToast().success).mockImplementation(toastAdd) + vi.mocked(useToast().error).mockImplementation(toastAdd) + vi.mocked(useToast().info).mockImplementation(toastAdd) + vi.mocked(useToast().warning).mockImplementation(toastAdd) + vi.mocked(useToast().loading).mockImplementation(toastAdd) + vi.mocked(useToast().custom).mockImplementation(toastAdd) +}) vi.mock( import('@/renderer/extensions/compositor/composables/compositorSession'), () => ({ @@ -133,7 +142,7 @@ beforeEach(() => { useWorkflowStore().activeWorkflow = fromPartial({ changeTracker: { afterChange, beforeChange } }) - vi.mocked(useToastStore().add).mockImplementation(() => undefined) + vi.mocked(useNodeOutputStore().getNodeImageUrls).mockReturnValue([]) }) @@ -222,11 +231,9 @@ describe('LayerEditorContent', () => { renderEditor('compositor') await vi.waitFor(() => - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'warn', - detail: '2 layers failed to load' - }) + expect(toastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: '2 layers failed to load' }) ) ) expect(useCompositorAutoSave).not.toHaveBeenCalled() @@ -235,14 +242,15 @@ describe('LayerEditorContent', () => { it('warns on close when edits could not be auto-saved', async () => { loadCompositorSession.mockResolvedValueOnce(2) const { unmount } = renderEditor('compositor') - await vi.waitFor(() => expect(useToastStore().add).toHaveBeenCalled()) + await vi.waitFor(() => expect(toastAdd).toHaveBeenCalled()) session.editor.history.canUndo.mockReturnValue(true) unmount() expect(saveLayerState).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ detail: 'Failed to save composite' }) + expect(toastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: 'Failed to save composite' }) ) }) @@ -251,9 +259,9 @@ describe('LayerEditorContent', () => { renderEditor('compositor') await vi.waitFor(() => - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) + expect( + toastAdd.mock.calls.some(([title]) => typeof title === 'string') + ).toBe(true) ) expect(useCompositorAutoSave).not.toHaveBeenCalled() }) diff --git a/src/renderer/extensions/layerEditor/components/LayerEditorContent.vue b/src/renderer/extensions/layerEditor/components/LayerEditorContent.vue index 6f4e047a4ec..3d6039ab759 100644 --- a/src/renderer/extensions/layerEditor/components/LayerEditorContent.vue +++ b/src/renderer/extensions/layerEditor/components/LayerEditorContent.vue @@ -44,7 +44,7 @@ import { useLayerEditorSession } from '@/renderer/extensions/layerEditor/composables/useLayerEditorSession' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { useNodeOutputStore } from '@/stores/nodeOutputStore' @@ -116,17 +116,13 @@ function finalizeCompositorSession(): void { void saveCompositorPreview(session, node) node.graph?.setDirtyCanvas(true) } else { - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('compositor.saveFailed') + useToast().error(t('g.error'), { + description: t('compositor.saveFailed') }) } } else if (sessionHasEdits()) { - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('compositor.saveFailed') + useToast().error(t('g.error'), { + description: t('compositor.saveFailed') }) } } finally { @@ -141,10 +137,8 @@ onMounted(() => { .then((failed) => { if (closed) return if (failed > 0) { - useToastStore().add({ - severity: 'warn', - summary: t('layerEditor.title'), - detail: t('layerEditor.layersFailedToLoad', { count: failed }) + useToast().warning(t('layerEditor.title'), { + description: t('layerEditor.layersFailedToLoad', { count: failed }) }) return } @@ -153,10 +147,8 @@ onMounted(() => { .catch((err) => { console.error('[Compositor] Loading layers failed:', err) if (closed) return - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('layerEditor.loadFailed') + useToast().error(t('g.error'), { + description: t('layerEditor.loadFailed') }) }) return @@ -167,10 +159,8 @@ onMounted(() => { .loadImages(urls, names) .then((failed) => { if (closed || failed === 0) return - useToastStore().add({ - severity: 'warn', - summary: t('layerEditor.title'), - detail: t('layerEditor.layersFailedToLoad', { count: failed }) + useToast().warning(t('layerEditor.title'), { + description: t('layerEditor.layersFailedToLoad', { count: failed }) }) }) .catch((err) => console.error('[LayerEditor] Loading images failed:', err)) diff --git a/src/renderer/extensions/layerEditor/composables/useLayerEditor.test.ts b/src/renderer/extensions/layerEditor/composables/useLayerEditor.test.ts index 1b1dadb9fda..986ad641e63 100644 --- a/src/renderer/extensions/layerEditor/composables/useLayerEditor.test.ts +++ b/src/renderer/extensions/layerEditor/composables/useLayerEditor.test.ts @@ -1,5 +1,6 @@ +import { useToast } from '@/components/ui/toast' import { useDialogStore } from '@/stores/dialogStore' -import { useToastStore } from '@/platform/updates/common/toastStore' + import { useNodeOutputStore } from '@/stores/nodeOutputStore' import { beforeEach, describe, expect, it, vi } from 'vitest' @@ -10,7 +11,6 @@ import { useLayerEditor } from './useLayerEditor' vi.mock(import('@/i18n')) beforeEach(() => { - vi.mocked(useToastStore().add).mockImplementation(() => undefined) vi.mocked(useNodeOutputStore().getNodeImageUrls).mockImplementation( () => undefined ) @@ -29,11 +29,9 @@ describe('useLayerEditor', () => { ]) useLayerEditor().openLayerEditor(node) expect(useDialogStore().showDialog).not.toHaveBeenCalled() - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'info', - detail: 'layerEditor.needsTwoImages' - }) + expect(useToast().info).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: 'layerEditor.needsTwoImages' }) ) }) diff --git a/src/renderer/extensions/layerEditor/composables/useLayerEditor.ts b/src/renderer/extensions/layerEditor/composables/useLayerEditor.ts index 69616ae0704..ca4e7c82911 100644 --- a/src/renderer/extensions/layerEditor/composables/useLayerEditor.ts +++ b/src/renderer/extensions/layerEditor/composables/useLayerEditor.ts @@ -6,7 +6,7 @@ import { } from '@/renderer/extensions/layerEditor/composables/layerEditorDialog' import { t } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useDialogStore } from '@/stores/dialogStore' import { useNodeOutputStore } from '@/stores/nodeOutputStore' @@ -19,10 +19,8 @@ export function useLayerEditor() { const imageUrls = useNodeOutputStore().getNodeImageUrls(node) if (!imageUrls || imageUrls.length < 2) { - useToastStore().add({ - severity: 'info', - summary: t('layerEditor.title'), - detail: t('layerEditor.needsTwoImages') + useToast().info(t('layerEditor.title'), { + description: t('layerEditor.needsTwoImages') }) return } diff --git a/src/renderer/extensions/layerEditor/composables/useLayerEditorExport.test.ts b/src/renderer/extensions/layerEditor/composables/useLayerEditorExport.test.ts index dd773932854..a0b0c833e92 100644 --- a/src/renderer/extensions/layerEditor/composables/useLayerEditorExport.test.ts +++ b/src/renderer/extensions/layerEditor/composables/useLayerEditorExport.test.ts @@ -1,4 +1,4 @@ -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type { App } from 'vue' import { createApp, defineComponent, ref } from 'vue' @@ -18,14 +18,34 @@ import type { import { useLayerEditorExport } from './useLayerEditorExport' import type { LayerEditorSession } from './useLayerEditorSession' -const { writePsd, downloadBlob } = vi.hoisted(() => ({ +const { writePsd, downloadBlob, toastAdd } = vi.hoisted(() => ({ + toastAdd: vi.fn(), writePsd: vi.fn((_psd: unknown) => new ArrayBuffer(4)), downloadBlob: vi.fn() })) vi.mock(import('ag-psd'), () => ({ writePsd })) vi.mock(import('@/base/common/downloadUtil'), () => ({ downloadBlob })) - +beforeEach(() => { + vi.mocked(useToast().success).mockImplementation((...args: unknown[]) => + toastAdd('success', ...args) + ) + vi.mocked(useToast().error).mockImplementation((...args: unknown[]) => + toastAdd('error', ...args) + ) + vi.mocked(useToast().info).mockImplementation((...args: unknown[]) => + toastAdd('info', ...args) + ) + vi.mocked(useToast().warning).mockImplementation((...args: unknown[]) => + toastAdd('warning', ...args) + ) + vi.mocked(useToast().loading).mockImplementation((...args: unknown[]) => + toastAdd('loading', ...args) + ) + vi.mocked(useToast().custom).mockImplementation((...args: unknown[]) => + toastAdd('custom', ...args) + ) +}) const i18n = createI18n({ legacy: false, locale: 'en', @@ -171,10 +191,6 @@ function makeSession(nodes: RasterData[], glOk = true): LayerEditorSession { } as unknown as LayerEditorSession } -beforeEach(() => { - vi.mocked(useToastStore().add).mockImplementation(() => undefined) -}) - describe('useLayerEditorExport', () => { it('writes a psd matching the layer tree and triggers a download', async () => { const session = makeSession([ @@ -208,7 +224,7 @@ describe('useLayerEditorExport', () => { expect(blob).toBeInstanceOf(Blob) expect(exporting.value).toBe(false) expect(session.requestRender).toHaveBeenCalled() - expect(vi.mocked(useToastStore().add)).not.toHaveBeenCalled() + expect(vi.mocked(toastAdd)).not.toHaveBeenCalled() }) it('shows an error toast when writing fails', async () => { @@ -221,11 +237,10 @@ describe('useLayerEditorExport', () => { await exportPsd() expect(downloadBlob).not.toHaveBeenCalled() - expect(vi.mocked(useToastStore().add)).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'layerEditor.exportPsdFailed' - }) + expect(toastAdd).toHaveBeenCalledWith( + 'error', + expect.any(String), + expect.objectContaining({ description: 'layerEditor.exportPsdFailed' }) ) expect(exporting.value).toBe(false) expect(session.requestRender).toHaveBeenCalled() diff --git a/src/renderer/extensions/layerEditor/composables/useLayerEditorExport.ts b/src/renderer/extensions/layerEditor/composables/useLayerEditorExport.ts index eee573e6570..2c6b55c3cf5 100644 --- a/src/renderer/extensions/layerEditor/composables/useLayerEditorExport.ts +++ b/src/renderer/extensions/layerEditor/composables/useLayerEditorExport.ts @@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n' import { downloadBlob } from '@/base/common/downloadUtil' import type { LayerEditorSession } from '@/renderer/extensions/layerEditor/composables/useLayerEditorSession' import { buildPsdFromEditor } from '@/renderer/extensions/layerEditor/psdExport' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' const PSD_MIME = 'image/vnd.adobe.photoshop' @@ -56,7 +56,7 @@ export async function buildSessionPsdBlob( export function useLayerEditorExport(session: LayerEditorSession) { const { t } = useI18n() - const toastStore = useToastStore() + const toastStore = useToast() const exporting = ref(false) async function exportPsd(): Promise { @@ -67,10 +67,8 @@ export function useLayerEditorExport(session: LayerEditorSession) { downloadBlob(psdExportFilename(new Date()), blob) } catch (err) { console.warn('[LayerEditor] PSD export failed', err) - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('layerEditor.exportPsdFailed') + toastStore.error(t('g.error'), { + description: t('layerEditor.exportPsdFailed') }) } finally { exporting.value = false diff --git a/src/renderer/extensions/linearMode/DropZone.test.ts b/src/renderer/extensions/linearMode/DropZone.test.ts index dd6df2e6aba..c24e6d4b3d3 100644 --- a/src/renderer/extensions/linearMode/DropZone.test.ts +++ b/src/renderer/extensions/linearMode/DropZone.test.ts @@ -7,13 +7,6 @@ import Button from '@/components/ui/button/Button.vue' import DropZone from './DropZone.vue' -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - () => ({ - useToast: () => ({ add: vi.fn() }) - }) -) - const i18n = createI18n({ legacy: false, locale: 'en', diff --git a/src/renderer/extensions/vueNodes/VideoPreview.vue b/src/renderer/extensions/vueNodes/VideoPreview.vue index 1ffad6fd359..b1d84bebdb3 100644 --- a/src/renderer/extensions/vueNodes/VideoPreview.vue +++ b/src/renderer/extensions/vueNodes/VideoPreview.vue @@ -125,7 +125,7 @@ diff --git a/src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.test.ts b/src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.test.ts index 21f854b8830..d5ab18af7ee 100644 --- a/src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.test.ts +++ b/src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.test.ts @@ -3,18 +3,9 @@ import userEvent from '@testing-library/user-event' import { describe, expect, it, vi } from 'vitest' import { createI18n } from 'vue-i18n' +import { useToast } from '@/components/ui/toast' import AudioPreviewPlayer from '@/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.vue' -const mockToastAdd = vi.fn() - -vi.mock( - import('primevue/usetoast'), // oxlint-disable-line comfy/no-primevue-imports - - () => ({ - useToast: () => ({ add: mockToastAdd }) - }) -) - vi.mock(import('@/base/common/downloadUtil'), () => ({ downloadFile: vi.fn() })) @@ -103,9 +94,9 @@ describe('AudioPreviewPlayer', () => { renderPlayer('http://example.com/audio.mp3') await user.click(screen.getByRole('button', { name: 'g.downloadAudio' })) - expect(mockToastAdd).toHaveBeenCalledWith( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'error' + kind: 'error' }) ) }) diff --git a/src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.vue b/src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.vue index feb08a83ae5..76d3f641f61 100644 --- a/src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.vue +++ b/src/renderer/extensions/vueNodes/widgets/components/audio/AudioPreviewPlayer.vue @@ -132,7 +132,7 @@ import { computed, ref, useTemplateRef } from 'vue' import { useI18n } from 'vue-i18n' import { whenever } from '@vueuse/core' -import { useToast } from 'primevue/usetoast' +import { useToast } from '@/components/ui/toast' import { downloadFile } from '@/base/common/downloadUtil' import Button from '@/components/ui/button/Button.vue' @@ -188,11 +188,7 @@ const handleDownload = () => { try { downloadFile(modelValue.value) } catch { - toast.add({ - severity: 'error', - summary: t('g.error'), - detail: t('g.failedToDownloadFile') - }) + toast.error(t('g.error'), { description: t('g.failedToDownloadFile') }) } } diff --git a/src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.test.ts b/src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.test.ts index a43ad5cc0fd..46c37bbeb60 100644 --- a/src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.test.ts +++ b/src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.test.ts @@ -1,5 +1,6 @@ +import { useToast } from '@/components/ui/toast' import { getActivePinia } from 'pinia' -import { useToastStore } from '@/platform/updates/common/toastStore' + import { render, screen } from '@testing-library/vue' import userEvent from '@testing-library/user-event' @@ -20,6 +21,10 @@ function createItem(id: string, name: string): FormDropdownItem { const i18n = createI18n({ legacy: false, locale: 'en', messages: { en: {} } }) +beforeEach(() => { + vi.mocked(useToast().warning).mockImplementation(vi.fn()) +}) + vi.mock(import('@/renderer/core/layout/transform/useTransformState')) const MockFormDropdownMenu = { @@ -130,10 +135,6 @@ async function openDropdown(user: ReturnType) { await screen.findByTestId('dropdown-menu') } -beforeEach(() => { - vi.mocked(useToastStore().addAlert).mockImplementation(() => undefined) -}) - describe('FormDropdown', () => { describe('filteredItems updates when items prop changes', () => { it('updates displayed items when items prop changes', async () => { diff --git a/src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.vue b/src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.vue index efffad7be7b..ed52e80c356 100644 --- a/src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.vue +++ b/src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.vue @@ -10,7 +10,7 @@ import type { ComponentPublicInstance } from 'vue' import { computed, ref, useTemplateRef } from 'vue' import { useI18n } from 'vue-i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useDismissOnCanvasGesture } from '@/renderer/extensions/vueNodes/widgets/composables/useDismissOnCanvasGesture' import type { @@ -108,7 +108,7 @@ const baseModelSelected = defineModel>('baseModelSelected', { }) const isOpen = defineModel('isOpen', { default: false }) -const toastStore = useToastStore() +const toastStore = useToast() const popoverRef = ref>() const triggerAnchorRef = useTemplateRef('triggerAnchorRef') const menuRef = useTemplateRef('menuRef') @@ -267,7 +267,9 @@ function handleSelection(item: FormDropdownItem, index: number) { sel.clear() sel.add(item.id) } else { - toastStore.addAlert(t('widgets.uploadSelect.maxSelectionReached')) + toastStore.warning('Alert', { + description: t('widgets.uploadSelect.maxSelectionReached') + }) return } } diff --git a/src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectActions.test.ts b/src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectActions.test.ts index db4a65f80e8..590206f87a6 100644 --- a/src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectActions.test.ts +++ b/src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectActions.test.ts @@ -6,7 +6,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import type { FormDropdownItem } from '@/renderer/extensions/vueNodes/widgets/components/form/dropdown/types' import { useWidgetSelectActions } from '@/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectActions' import { api } from '@/scripts/api' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import type { SimplifiedWidget } from '@/types/simplifiedWidget' import enMessages from '@/locales/en/main.json' @@ -221,10 +221,9 @@ describe('useWidgetSelectActions', () => { expect(modelValue.value).toBe('original.png') - const toastStore = useToastStore() - expect(toastStore.addAlert).toHaveBeenCalledWith( - 'Upload failed: Internal Server Error' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'Upload failed: Internal Server Error' + }) }) it('shows a status-derived toast without a dangling separator when statusText is empty', async () => { @@ -250,9 +249,9 @@ describe('useWidgetSelectActions', () => { await handleFilesUpdate([new File(['test'], 'fail.png')]) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'Upload failed: HTTP 502' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'Upload failed: HTTP 502' + }) }) it('shows a file-too-large toast on a 413 with no known upload limit', async () => { @@ -279,9 +278,9 @@ describe('useWidgetSelectActions', () => { await handleFilesUpdate([new File(['test'], 'huge.png')]) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'File is too large to upload.' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'File is too large to upload.' + }) }) it('shows a file-too-large toast with the limit on a 413 when the server reports one', async () => { @@ -308,9 +307,9 @@ describe('useWidgetSelectActions', () => { await handleFilesUpdate([new File(['test'], 'huge.png')]) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'File is too large to upload (limit: 100 MB).' - ) + expect(useToast().warning).toHaveBeenCalledWith('Alert', { + description: 'File is too large to upload (limit: 100 MB).' + }) }) }) }) diff --git a/src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectActions.ts b/src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectActions.ts index e3b3459be86..c451fd3e13a 100644 --- a/src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectActions.ts +++ b/src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectActions.ts @@ -2,9 +2,9 @@ import { toValue } from 'vue' import type { ComputedRef, MaybeRefOrGetter, Ref } from 'vue' import { useErrorHandling } from '@/composables/useErrorHandling' +import { useToast } from '@/components/ui/toast' import { t } from '@/i18n' import { ServerFeatureFlag } from '@/platform/remoteConfig/serverFeatureFlag' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import type { FormDropdownItem } from '@/renderer/extensions/vueNodes/widgets/components/form/dropdown/types' import type { ResultItemType } from '@/schemas/resultItemTypeSchema' @@ -42,7 +42,7 @@ interface UseWidgetSelectActionsOptions { export function useWidgetSelectActions(options: UseWidgetSelectActionsOptions) { const { modelValue, dropdownItems } = options - const toastStore = useToastStore() + const toastStore = useToast() const { wrapWithErrorHandlingAsync } = useErrorHandling() function updateSelectedItems(selectedItems: Set) { @@ -77,7 +77,9 @@ export function useWidgetSelectActions(options: UseWidgetSelectActionsOptions) { }) if (resp.status !== 200) { - toastStore.addAlert(buildUploadErrorMessage(resp)) + toastStore.warning('Alert', { + description: buildUploadErrorMessage(resp) + }) return null } @@ -110,7 +112,7 @@ export function useWidgetSelectActions(options: UseWidgetSelectActionsOptions) { const uploadedPaths = await uploadFiles(files) if (uploadedPaths.length === 0) { - toastStore.addAlert('File upload failed') + toastStore.warning('Alert', { description: 'File upload failed' }) return } diff --git a/src/scripts/api.ts b/src/scripts/api.ts index 9946c51b24d..ec6a39cec49 100644 --- a/src/scripts/api.ts +++ b/src/scripts/api.ts @@ -36,7 +36,6 @@ import type { import { isCloud } from '@/platform/distribution/types' import { addBreadcrumb } from '@sentry/vue' import { useTelemetry } from '@/platform/telemetry' -import { useToastStore } from '@/platform/updates/common/toastStore' import type { components as ManagerComponents } from '@/workbench/extensions/manager/types/generatedManagerTypes' import type { AssetDownloadWsMessage, @@ -1871,6 +1870,8 @@ export class ComfyApi extends EventTarget { * @param {boolean} options.freeExecutionCache - If true, also frees execution cache */ async freeMemory(options: { freeExecutionCache: boolean }) { + const { useToast } = await import('@/components/ui/toast') + try { let mode = '' if (options.freeExecutionCache) { @@ -1887,30 +1888,19 @@ export class ComfyApi extends EventTarget { if (res.status === 200) { if (options.freeExecutionCache) { - useToastStore().add({ - severity: 'success', - summary: 'Models and Execution Cache have been cleared.', - life: 3000 + useToast().success('Models and Execution Cache have been cleared.', { + duration: 3000 }) } else { - useToastStore().add({ - severity: 'success', - summary: 'Models have been unloaded.', - life: 3000 - }) + useToast().success('Models have been unloaded.', { duration: 3000 }) } } else { - useToastStore().add({ - severity: 'error', - summary: - 'Unloading of models failed. Installed ComfyUI may be an outdated version.' - }) + useToast().error( + 'Unloading of models failed. Installed ComfyUI may be an outdated version.' + ) } } catch { - useToastStore().add({ - severity: 'error', - summary: 'An error occurred while trying to unload models.' - }) + useToast().error('An error occurred while trying to unload models.') } } diff --git a/src/scripts/app.test.ts b/src/scripts/app.test.ts index 3f82f7588b2..978499afc20 100644 --- a/src/scripts/app.test.ts +++ b/src/scripts/app.test.ts @@ -1,9 +1,10 @@ import { fromAny, fromPartial } from '@total-typescript/shoehorn' import { ComfyApp, app as singletonApp } from './app' +import { useToast } from '@/components/ui/toast' import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore' import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore' import { useNodeOutputStore } from '@/stores/nodeOutputStore' -import { useToastStore } from '@/platform/updates/common/toastStore' + import { useSettingStore } from '@/platform/settings/settingStore' import { useAuthStore } from '@/stores/authStore' import { @@ -121,12 +122,21 @@ type WorkflowValidation = ReturnType vi.mock(import('firebase/auth')) const { + mockToastStore, mockExtensionService, mockRefreshMissingModelPipeline, mockImportA1111, mockWorkflowService, mockValidateWorkflow } = vi.hoisted(() => ({ + mockToastStore: { + warning: vi.fn(), + success: vi.fn(), + error: vi.fn(), + info: vi.fn(() => 1), + custom: vi.fn(), + dismiss: vi.fn() + }, mockExtensionService: { invokeExtensions: vi.fn(), invokeExtensionsAsync: vi.fn() @@ -184,6 +194,15 @@ vi.mock(import('@/extensions/core/load3d/Load3dUtils'), () => ({ }) })) +beforeEach(() => { + vi.mocked(useToast().warning).mockImplementation(mockToastStore.warning) + vi.mocked(useToast().success).mockImplementation(mockToastStore.success) + vi.mocked(useToast().error).mockImplementation(mockToastStore.error) + vi.mocked(useToast().info).mockImplementation(mockToastStore.info) + vi.mocked(useToast().custom).mockImplementation(mockToastStore.custom) + vi.mocked(useToast().dismiss).mockImplementation(mockToastStore.dismiss) +}) + vi.mock(import('@/services/extensionService'), () => ({ useExtensionService: vi.fn(() => fromPartial>(mockExtensionService) @@ -447,11 +466,9 @@ describe('ComfyApp', () => { await app.loadGraphData(createWorkflowGraphData(), false, true, null) await vi.waitFor(() => { - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'warn', - summary: t('toastMessages.missingMediaVerificationFailed') - }) + expect(useToast().warning).toHaveBeenCalledWith( + t('toastMessages.missingMediaVerificationFailed'), + { duration: 5000 } ) }) expect(store.lastNodeErrors).toEqual({ @@ -3164,15 +3181,14 @@ describe('ComfyApp', () => { await app.refreshComboInNodes() - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'info' }) - ) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'success' }) - ) - expect(useToastStore().remove).toHaveBeenCalledWith( - vi.mocked(useToastStore().add).mock.calls[0][0] + expect(mockToastStore.info).toHaveBeenCalledWith( + t('g.update'), + expect.objectContaining({ + description: t('toastMessages.updateRequested') + }) ) + expect(mockToastStore.success).toHaveBeenCalled() + expect(mockToastStore.dismiss).toHaveBeenCalledWith(1) }) it('shows failure toast, removes the pending toast, and rethrows reload failures', async () => { @@ -3182,12 +3198,8 @@ describe('ComfyApp', () => { await expect(app.refreshComboInNodes()).rejects.toThrow(error) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error' }) - ) - expect(useToastStore().remove).toHaveBeenCalledWith( - vi.mocked(useToastStore().add).mock.calls[0][0] - ) + expect(mockToastStore.error).toHaveBeenCalled() + expect(mockToastStore.dismiss).toHaveBeenCalledWith(1) }) }) @@ -3583,7 +3595,7 @@ describe('ComfyApp', () => { await expect(app.handleFile(imageFile)).resolves.toBeUndefined() expect(loadApiJson).toHaveBeenCalled() - expect(useToastStore().addAlert).toHaveBeenCalledTimes(1) + expect(useToast().warning).toHaveBeenCalledTimes(1) expect(mockImportA1111).not.toHaveBeenCalled() expect(createNode).not.toHaveBeenCalled() }) @@ -3692,23 +3704,23 @@ describe('ComfyApp', () => { await app.handleFile(createTestFile('broken.json', 'application/json')) - expect(useToastStore().addAlert).toHaveBeenCalledTimes(1) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'Unable to find workflow in broken.json' - ) + expect(mockToastStore.warning).toHaveBeenCalledTimes(1) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'Unable to find workflow in broken.json' + }) }) it.for([ { outcome: 'core-nodes-unavailable' as const, fileName: 'a1111.png', - toastMethod: 'addAlert' as const, + toastMethod: 'warning' as const, expectedToast: t('toastMessages.a1111CoreNodesUnavailable') }, { outcome: 'not-a1111' as const, fileName: 'parameters.png', - toastMethod: 'addAlert' as const, + toastMethod: 'warning' as const, expectedToast: t('toastMessages.fileLoadError', { fileName: 'parameters.png' }) @@ -3716,12 +3728,8 @@ describe('ComfyApp', () => { { outcome: 'imported-without-embeddings' as const, fileName: 'a1111.png', - toastMethod: 'add' as const, - expectedToast: { - severity: 'warn', - summary: t('g.warning'), - detail: t('toastMessages.a1111EmbeddingsUnavailable') - } + toastMethod: 'warning' as const, + expectedToast: t('g.warning') } ])('maps $outcome to its message', async (testCase) => { const graph = new LGraph() @@ -3737,13 +3745,19 @@ describe('ComfyApp', () => { parameters, expect.any(Function) ) - expect(useToastStore()[testCase.toastMethod]).toHaveBeenCalledOnce() - expect(useToastStore()[testCase.toastMethod]).toHaveBeenCalledWith( - testCase.expectedToast - ) + expect(mockToastStore[testCase.toastMethod]).toHaveBeenCalledOnce() if (testCase.outcome === 'imported-without-embeddings') { + expect(mockToastStore.warning).toHaveBeenCalledWith( + testCase.expectedToast, + { + description: t('toastMessages.a1111EmbeddingsUnavailable') + } + ) expect(mockWorkflowService.afterLoadNewGraph).toHaveBeenCalledOnce() } else { + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: testCase.expectedToast + }) expect(mockWorkflowService.afterLoadNewGraph).not.toHaveBeenCalled() } }) @@ -3941,7 +3955,9 @@ describe('ComfyApp', () => { await noFiles expect( - vi.mocked(useToastStore().addAlert).mock.calls.map(([msg]) => msg) + vi + .mocked(useToast().warning) + .mock.calls.map(([, options]) => options?.description) ).toEqual(alerts) expect( vi.mocked(reportError).mock.calls.map(([, opts]) => opts.errorType) diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 7b7d220dbcc..106d7408f22 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -2,6 +2,9 @@ import { useEventListener, useResizeObserver } from '@vueuse/core' import _ from 'es-toolkit/compat' import { reactive, unref, shallowRef } from 'vue' +import RerouteMigrationToast from '@/components/toast/RerouteMigrationToast.vue' +import { useToast } from '@/components/ui/toast' +import type { ToastId } from '@/components/ui/toast' import { partnerRunGateBlocksAutoQueue } from '@/composables/billing/usePartnerNodesRunGate' import { useCanvasPositionConversion } from '@/composables/element/useCanvasPositionConversion' import { normalizeCameraState } from '@/renderer/core/canvas/cameraState' @@ -53,7 +56,6 @@ import type { WorkflowOpenSource, WorkflowQueueIntent } from '@/platform/telemetry/types' -import { useToastStore } from '@/platform/updates/common/toastStore' import { MIME_ASSET_INFO } from '@/platform/assets/schemas/mediaAssetSchema' import { restoreDynamicGroupInputs } from '@/platform/workflow/core/utils/restoreDynamicGroupInputs' import { updatePendingWarnings } from '@/platform/workflow/core/utils/pendingWarnings' @@ -119,10 +121,7 @@ import { useWidgetStore } from '@/stores/widgetStore' import { useWidgetValueStore } from '@/stores/widgetValueStore' import { useWorkspaceStore } from '@/stores/workspaceStore' import type { ComfyExtension } from '@/types/comfy' -import type { - ExtensionManager, - ToastMessageOptions -} from '@/types/extensionTypes' +import type { ExtensionManager } from '@/types/extensionTypes' import type { NodeExecutionId } from '@/types/nodeIdentification' import { normalizePromptError } from '@/utils/executionErrorUtil' import { graphToPrompt, unwrapExportedWidgetValue } from '@/utils/executionUtil' @@ -777,7 +776,9 @@ export class ComfyApp { surface: 'graph', errorType: 'asset_drop_load_failure' }) - useToastStore().addAlert(t('toastMessages.assetDropFailed')) + useToast().warning('Alert', { + description: t('toastMessages.assetDropFailed') + }) } return } @@ -823,7 +824,9 @@ export class ComfyApp { } useWorkflowService().showPendingWarnings() } catch (error: unknown) { - useToastStore().addAlert(t('toastMessages.dropFileError', { error })) + useToast().warning('Alert', { + description: t('toastMessages.dropFileError', { error }) + }) } }) @@ -1018,10 +1021,8 @@ export class ComfyApp { useSubgraphService().registerNewSubgraph(subgraph, data) } catch (err) { console.error('Failed to register subgraph', err) - useToastStore().add({ - severity: 'error', - summary: 'Failed to register subgraph', - detail: err instanceof Error ? err.message : String(err) + useToast().error('Failed to register subgraph', { + description: err instanceof Error ? err.message : String(err) }) } }) @@ -1392,10 +1393,7 @@ export class ComfyApp { findLegacyRerouteNodes(graphData).length && noNativeReroutes(graphData) ) { - useToastStore().add({ - group: 'reroute-migration', - severity: 'warn' - }) + useToast().custom(RerouteMigrationToast) } useSubgraphService().loadSubgraphs(graphData) @@ -2161,9 +2159,9 @@ export class ComfyApp { } showErrorOnFileLoad(file: File) { - useToastStore().addAlert( - t('toastMessages.fileLoadError', { fileName: file.name }) - ) + useToast().warning('Alert', { + description: t('toastMessages.fileLoadError', { fileName: file.name }) + }) } /** @@ -2299,16 +2297,16 @@ export class ComfyApp { ) switch (outcome) { case 'core-nodes-unavailable': - useToastStore().addAlert(t('toastMessages.a1111CoreNodesUnavailable')) + useToast().warning('Alert', { + description: t('toastMessages.a1111CoreNodesUnavailable') + }) return case 'not-a1111': this.showErrorOnFileLoad(file) return case 'imported-without-embeddings': - useToastStore().add({ - severity: 'warn', - summary: t('g.warning'), - detail: t('toastMessages.a1111EmbeddingsUnavailable') + useToast().warning(t('g.warning'), { + description: t('toastMessages.a1111EmbeddingsUnavailable') }) break case 'imported': @@ -2770,38 +2768,32 @@ export class ComfyApp { * Refresh combo list on whole nodes */ async refreshComboInNodes() { - const requestToastMessage: ToastMessageOptions = { - severity: 'info', - summary: t('g.update'), - detail: t('toastMessages.updateRequested') - } + let requestToastId: ToastId | undefined if (this.vueAppReady) { - useToastStore().add(requestToastMessage) + requestToastId = useToast().info(t('g.update'), { + description: t('toastMessages.updateRequested') + }) } try { await this.reloadNodeDefs() if (this.vueAppReady) { - useToastStore().add({ - severity: 'success', - summary: t('g.updated'), - detail: t('toastMessages.nodeDefinitionsUpdated'), - life: 1000 + useToast().success(t('g.updated'), { + description: t('toastMessages.nodeDefinitionsUpdated'), + duration: 1000 }) } } catch (error) { if (this.vueAppReady) { - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('toastMessages.nodeDefinitionsUpdateFailed') + useToast().error(t('g.error'), { + description: t('toastMessages.nodeDefinitionsUpdateFailed') }) } throw error } finally { - if (this.vueAppReady) { - useToastStore().remove(requestToastMessage) + if (requestToastId !== undefined) { + useToast().dismiss(requestToastId) } } } diff --git a/src/scripts/ui/settings.test.ts b/src/scripts/ui/settings.test.ts index 93f7abfa3b3..60b36c9aacf 100644 --- a/src/scripts/ui/settings.test.ts +++ b/src/scripts/ui/settings.test.ts @@ -1,8 +1,8 @@ import { fromPartial } from '@total-typescript/shoehorn' import { describe, expect, expectTypeOf, it, vi } from 'vitest' +import { useToast } from '@/components/ui/toast' import { useSettingStore } from '@/platform/settings/settingStore' -import { useToastStore } from '@/platform/updates/common/toastStore' import type { ComfyApp } from '@/scripts/app' import { ComfySettingsDialog } from './settings' @@ -51,10 +51,10 @@ describe('saving a setting that fails to persist', () => { save(dialog, accessor) await vi.waitFor(() => { - expect(useToastStore().messagesToAdd).toContainEqual( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'warn', - detail: expect.stringContaining( + kind: 'warning', + description: expect.stringContaining( 'Error saving setting Comfy.EditAttention.Delta' ) }) diff --git a/src/scripts/ui/settings.ts b/src/scripts/ui/settings.ts index 25488261fcc..d97098a1fff 100644 --- a/src/scripts/ui/settings.ts +++ b/src/scripts/ui/settings.ts @@ -1,7 +1,7 @@ import { t } from '@/i18n' import { useSettingStore } from '@/platform/settings/settingStore' import type { SettingParams, Settings } from '@/platform/settings/types' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import type { ComfyApp } from '@/scripts/app' import { ComfyDialog } from './dialog' @@ -10,7 +10,9 @@ function saveSetting(id: K, value: Settings[K]) { useSettingStore() .set(id, value) .catch((err) => { - useToastStore().addAlert(t('toastMessages.errorSaveSetting', { id, err })) + useToast().warning('Alert', { + description: t('toastMessages.errorSaveSetting', { id, err }) + }) }) } diff --git a/src/services/audioService.test.ts b/src/services/audioService.test.ts index 3141d273c85..26d4441764d 100644 --- a/src/services/audioService.test.ts +++ b/src/services/audioService.test.ts @@ -1,4 +1,4 @@ -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { assert, beforeEach, describe, expect, it, vi } from 'vitest' import { api } from '@/scripts/api' @@ -7,6 +7,14 @@ import { useAudioService } from '@/services/audioService' const mockRegister = vi.hoisted(() => vi.fn()) const mockConnect = vi.hoisted(() => vi.fn()) +vi.mock(import('@/scripts/app'), () => ({ + app: { canvas: {}, rootGraph: {} } +})) + +const mockToastStore = vi.hoisted(() => ({ + warning: vi.fn() +})) + vi.mock(import('extendable-media-recorder'), () => ({ register: mockRegister })) @@ -17,6 +25,10 @@ vi.mock(import('extendable-media-recorder-wav-encoder'), () => ({ vi.mock(import('@/scripts/api')) +beforeEach(() => { + vi.mocked(useToast().warning).mockImplementation(mockToastStore.warning) +}) + describe('useAudioService', () => { let service: ReturnType @@ -193,9 +205,9 @@ describe('useAudioService', () => { 'Error uploading temp file: 500 - Internal Server Error' ) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - 'Error uploading temp file: 500 - Internal Server Error' - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: 'Error uploading temp file: 500 - Internal Server Error' + }) }) it('should handle network errors', async () => { @@ -226,11 +238,11 @@ describe('useAudioService', () => { `Error uploading temp file: ${testCase.status} - ${testCase.statusText}` ) - expect(useToastStore().addAlert).toHaveBeenCalledWith( - `Error uploading temp file: ${testCase.status} - ${testCase.statusText}` - ) + expect(mockToastStore.warning).toHaveBeenCalledWith('Alert', { + description: `Error uploading temp file: ${testCase.status} - ${testCase.statusText}` + }) - vi.mocked(useToastStore().addAlert).mockClear() + mockToastStore.warning.mockClear() } }) diff --git a/src/services/audioService.ts b/src/services/audioService.ts index 9fc67616aea..4921f2ca0c0 100644 --- a/src/services/audioService.ts +++ b/src/services/audioService.ts @@ -1,7 +1,7 @@ import { register } from 'extendable-media-recorder' import { connect } from 'extendable-media-recorder-wav-encoder' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' export interface AudioRecordingError { @@ -65,7 +65,7 @@ export const useAudioService = () => { if (resp.status !== 200) { const err = `Error uploading temp file: ${resp.status} - ${resp.statusText}` - useToastStore().addAlert(err) + useToast().warning('Alert', { description: err }) throw new Error(err) } diff --git a/src/services/dialogService.downgrade.test.ts b/src/services/dialogService.downgrade.test.ts index 0fdc092c660..9c3e2c51554 100644 --- a/src/services/dialogService.downgrade.test.ts +++ b/src/services/dialogService.downgrade.test.ts @@ -1,9 +1,10 @@ import { computed } from 'vue' import { useBillingContext } from '@/composables/billing/useBillingContext' +import { useToast } from '@/components/ui/toast' import { assert, beforeEach, describe, expect, it, vi } from 'vitest' import type { Component } from 'vue' import type DowngradeContent from '@/platform/workspace/components/dialogs/DowngradeRemoveMembersDialogContent.vue' -import { useToastStore } from '@/platform/updates/common/toastStore' + import { useDialogStore } from '@/stores/dialogStore' /** * showDowngradeToPersonalDialog must refresh members before the no-members @@ -14,6 +15,7 @@ import { useDialogStore } from '@/stores/dialogStore' const refreshMembers = vi.hoisted(() => vi.fn()) const previewDowngrade = vi.hoisted(() => vi.fn()) const downgradeToPersonal = vi.hoisted(() => vi.fn()) +const toastAdd = vi.hoisted(() => vi.fn()) const hasOtherMembers = vi.hoisted(() => ({ value: false })) const useDowngradeToPersonal = vi.hoisted(() => vi.fn()) @@ -61,6 +63,15 @@ vi.mock(import('@/platform/distribution/types'), () => ({ vi.mock(import('@/composables/billing/useBillingContext')) +beforeEach(() => { + vi.mocked(useToast().success).mockImplementation(toastAdd) + vi.mocked(useToast().error).mockImplementation(toastAdd) + vi.mocked(useToast().info).mockImplementation(toastAdd) + vi.mocked(useToast().warning).mockImplementation(toastAdd) + vi.mocked(useToast().loading).mockImplementation(toastAdd) + vi.mocked(useToast().custom).mockImplementation(toastAdd) +}) + vi.mock( import('@/platform/workspace/composables/useDowngradeToPersonal'), () => ({ @@ -393,11 +404,9 @@ describe('showDowngradeToPersonalDialog', () => { await useDialogService().showDowngradeToPersonalDialog(options) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Outstanding balance' - }) + expect(toastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: 'Outstanding balance' }) ) expect(useDialogStore().showDialog).not.toHaveBeenCalled() }) @@ -408,8 +417,9 @@ describe('showDowngradeToPersonalDialog', () => { await useDialogService().showDowngradeToPersonalDialog(options) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'error', detail: 'network' }) + expect(toastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: 'network' }) ) expect(useDialogStore().showDialog).not.toHaveBeenCalled() expect(downgradeToPersonal).not.toHaveBeenCalled() @@ -420,11 +430,9 @@ describe('showDowngradeToPersonalDialog', () => { await useDialogService().showDowngradeToPersonalDialog(options) - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: 'Outstanding balance' - }) + expect(toastAdd).toHaveBeenCalledWith( + expect.any(String), + expect.objectContaining({ description: 'Outstanding balance' }) ) expect(useDialogStore().showDialog).not.toHaveBeenCalled() expect(downgradeToPersonal).not.toHaveBeenCalled() diff --git a/src/services/dialogService.errorCatalog.test.ts b/src/services/dialogService.errorCatalog.test.ts index 43f8bc3ec64..79b5d306d0f 100644 --- a/src/services/dialogService.errorCatalog.test.ts +++ b/src/services/dialogService.errorCatalog.test.ts @@ -22,15 +22,6 @@ import { nodeError, validationError } from '@/utils/__tests__/nodeErrorHelpers' import { useDialogService } from './dialogService' vi.mock(import('@/platform/telemetry')) -// oxlint-disable-next-line comfy/no-primevue-imports -vi.mock(import('primevue/usetoast'), () => ({ - useToast: () => ({ - add: vi.fn(), - remove: vi.fn(), - removeGroup: vi.fn(), - removeAllGroups: vi.fn() - }) -})) vi.mock(import('@/composables/useCopyToClipboard'), () => ({ useCopyToClipboard: () => ({ copyToClipboard: vi.fn(async () => true) }) })) diff --git a/src/services/dialogService.ts b/src/services/dialogService.ts index 83a693989c2..98d68551d1d 100644 --- a/src/services/dialogService.ts +++ b/src/services/dialogService.ts @@ -20,7 +20,7 @@ import { t } from '@/i18n' import { useTelemetry } from '@/platform/telemetry' import { isCloud } from '@/platform/distribution/types' import { useBillingContext } from '@/composables/billing/useBillingContext' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useDialogStore } from '@/stores/dialogStore' import type { RunErrorMessageSource } from '@/platform/errorCatalog/types' import type { PromptError } from '@/platform/remote/comfyui/types' @@ -955,10 +955,9 @@ export const useDialogService = () => { return await downgradeToPersonal(options.planSlug) } } catch (error) { - useToastStore().add({ - severity: 'error', - summary: t('subscription.downgrade.failed'), - detail: error instanceof Error ? error.message : t('g.unknownError') + useToast().error(t('subscription.downgrade.failed'), { + description: + error instanceof Error ? error.message : t('g.unknownError') }) return null } diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index 36110c80f59..6237d3d0ba9 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -40,7 +40,7 @@ import type { import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' import { toConcreteWidget } from '@/lib/litegraph/src/widgets/widgetMap' import { useSettingStore } from '@/platform/settings/settingStore' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { createPromotedMultilineWidget } from '@/renderer/extensions/vueNodes/widgets/utils/multilineTextarea' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' @@ -189,7 +189,7 @@ function getMinSize(node: LGraphNode) { */ export const useLitegraphService = () => { const extensionService = useExtensionService() - const toastStore = useToastStore() + const toastStore = useToast() const widgetStore = useWidgetStore() const canvasStore = useCanvasStore() const { toggleSelectedNodesMode } = useSelectedLiteGraphItems() @@ -697,11 +697,11 @@ export const useLitegraphService = () => { throw error } } catch (error) { - toastStore.addAlert( - t('toastMessages.errorCopyImage', { + toastStore.warning('Alert', { + description: t('toastMessages.errorCopyImage', { error: error instanceof Error ? error.message : error }) - ) + }) } }, 'preview') } diff --git a/src/stores/__tests__/authTokenPriority.test.ts b/src/stores/__tests__/authTokenPriority.test.ts index c3b99ed4188..63ccc68a7c0 100644 --- a/src/stores/__tests__/authTokenPriority.test.ts +++ b/src/stores/__tests__/authTokenPriority.test.ts @@ -1,4 +1,5 @@ import { useFeatureFlags } from '@/composables/useFeatureFlags' +import { useToast } from '@/components/ui/toast' import { useApiKeyAuthStore } from '@/stores/apiKeyAuthStore' import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore' import { useWorkspaceAuthStore } from '@/platform/workspace/stores/workspaceAuthStore' @@ -23,6 +24,15 @@ vi.mock(import('firebase/auth')) vi.mock(import('@/platform/telemetry')) +beforeEach(() => { + vi.mocked(useToast().success).mockImplementation(vi.fn()) + vi.mocked(useToast().error).mockImplementation(vi.fn()) + vi.mocked(useToast().info).mockImplementation(vi.fn()) + vi.mocked(useToast().warning).mockImplementation(vi.fn()) + vi.mocked(useToast().loading).mockImplementation(vi.fn()) + vi.mocked(useToast().custom).mockImplementation(vi.fn()) +}) + vi.mock(import('@/services/dialogService')) vi.mock(import('@/platform/distribution/types'), () => mockDistributionTypes) diff --git a/src/stores/apiKeyAuthStore.ts b/src/stores/apiKeyAuthStore.ts index 4f6989460a7..1bfb8e6d618 100644 --- a/src/stores/apiKeyAuthStore.ts +++ b/src/stores/apiKeyAuthStore.ts @@ -4,7 +4,7 @@ import { computed, nextTick, ref, watch } from 'vue' import { useErrorHandling } from '@/composables/useErrorHandling' import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useAuthStore } from '@/stores/authStore' import type { ApiKeyAuthHeader } from '@/types/authTypes' import type { operations } from '@/types/comfyRegistryTypes' @@ -17,7 +17,7 @@ const STORAGE_KEY = 'comfy_api_key' export const useApiKeyAuthStore = defineStore('apiKeyAuth', () => { const authStore = useAuthStore() const apiKey = useLocalStorage(STORAGE_KEY, null) - const toastStore = useToastStore() + const toastStore = useToast() const { wrapWithErrorHandlingAsync, toastErrorHandler } = useErrorHandling() const currentUser = ref(null) @@ -56,10 +56,8 @@ export const useApiKeyAuthStore = defineStore('apiKeyAuth', () => { const reportError = (error: unknown) => { if (error instanceof Error && error.message === 'STORAGE_FAILED') { - toastStore.add({ - severity: 'error', - summary: t('auth.apiKey.storageFailed'), - detail: t('auth.apiKey.storageFailedDetail') + toastStore.error(t('auth.apiKey.storageFailed'), { + description: t('auth.apiKey.storageFailedDetail') }) } else { toastErrorHandler(error) @@ -68,22 +66,18 @@ export const useApiKeyAuthStore = defineStore('apiKeyAuth', () => { const storeApiKey = wrapWithErrorHandlingAsync(async (newApiKey: string) => { apiKey.value = newApiKey - toastStore.add({ - severity: 'success', - summary: t('auth.apiKey.stored'), - detail: t('auth.apiKey.storedDetail'), - life: 5000 + toastStore.success(t('auth.apiKey.stored'), { + description: t('auth.apiKey.storedDetail'), + duration: 5000 }) return true }, reportError) const clearStoredApiKey = wrapWithErrorHandlingAsync(async () => { apiKey.value = null - toastStore.add({ - severity: 'success', - summary: t('auth.apiKey.cleared'), - detail: t('auth.apiKey.clearedDetail'), - life: 5000 + toastStore.success(t('auth.apiKey.cleared'), { + description: t('auth.apiKey.clearedDetail'), + duration: 5000 }) return true }, reportError) diff --git a/src/stores/assetExportStore.ts b/src/stores/assetExportStore.ts index 48f05e4cab5..690a6ff2c65 100644 --- a/src/stores/assetExportStore.ts +++ b/src/stores/assetExportStore.ts @@ -3,7 +3,7 @@ import { defineStore } from 'pinia' import { computed, ref, watch } from 'vue' import { assetService } from '@/platform/assets/services/assetService' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import type { TaskId, TaskResponse, @@ -167,11 +167,10 @@ export const useAssetExportStore = defineStore('assetExport', () => { if (!resolvedUrl.ok) { exp.downloadError = resolvedUrl.error exp.downloadTriggered = false - useToastStore().add({ - severity: 'error', - summary: t('exportToast.downloadFailed', { name: exp.exportName }), - detail: resolvedUrl.error - }) + useToast().error( + t('exportToast.downloadFailed', { name: exp.exportName }), + { description: resolvedUrl.error } + ) return } const link = document.createElement('a') @@ -188,13 +187,12 @@ export const useAssetExportStore = defineStore('assetExport', () => { exp.downloadError = message exp.downloadTriggered = false - useToastStore().add({ - severity: 'error', - summary: t('exportToast.downloadFailed', { + useToast().error( + t('exportToast.downloadFailed', { name: exp.exportName }), - detail: message - }) + { description: message } + ) } } diff --git a/src/stores/subgraphStore.ts b/src/stores/subgraphStore.ts index 2f7ff3f5d0b..3ceb7b9ef25 100644 --- a/src/stores/subgraphStore.ts +++ b/src/stores/subgraphStore.ts @@ -3,7 +3,7 @@ import { defineStore } from 'pinia' import { t } from '@/i18n' import { SubgraphNode } from '@/lib/litegraph/src/litegraph' import { useSettingStore } from '@/platform/settings/settingStore' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useWorkflowService } from '@/platform/workflow/core/services/workflowService' import type { LoadedComfyWorkflow } from '@/platform/workflow/management/stores/comfyWorkflow' import { ComfyWorkflow } from '@/platform/workflow/management/stores/comfyWorkflow' @@ -260,10 +260,8 @@ export const useSubgraphStore = defineStore('subgraph', () => { const errors = settled.filter((i) => 'reason' in i).map((i) => i.reason) errors.forEach((e) => console.error('Failed to load subgraph blueprint', e)) if (errors.length > 0) { - useToastStore().add({ - severity: 'error', - summary: t('subgraphStore.loadFailure'), - detail: errors.length > 3 ? `x${errors.length}` : `${errors}` + useToast().error(t('subgraphStore.loadFailure'), { + description: errors.length > 3 ? `x${errors.length}` : `${errors}` }) } } @@ -368,11 +366,9 @@ export const useSubgraphStore = defineStore('subgraph', () => { await workflow.save() //add to files list? useWorkflowStore().attachWorkflow(loadedWorkflow) - useToastStore().add({ - severity: 'success', - summary: t('subgraphStore.publishSuccess'), - detail: t('subgraphStore.publishSuccessMessage'), - life: 4000 + useToast().success(t('subgraphStore.publishSuccess'), { + description: t('subgraphStore.publishSuccessMessage'), + duration: 4000 }) } async function editBlueprint(nodeType: string) { @@ -398,10 +394,8 @@ export const useSubgraphStore = defineStore('subgraph', () => { if (!(name in subgraphCache)) throw new Error('not yet loaded') if (isGlobalBlueprint(name)) { - useToastStore().add({ - severity: 'warn', - summary: t('subgraphStore.cannotDeleteGlobal'), - life: 4000 + useToast().warning(t('subgraphStore.cannotDeleteGlobal'), { + duration: 4000 }) return } diff --git a/src/stores/workspaceStore.ts b/src/stores/workspaceStore.ts index b452d93daae..7d54911d613 100644 --- a/src/stores/workspaceStore.ts +++ b/src/stores/workspaceStore.ts @@ -3,7 +3,7 @@ import { defineStore } from 'pinia' import { computed, ref } from 'vue' import { useSettingStore } from '@/platform/settings/settingStore' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import type { Settings } from '@/platform/settings/types' import { useColorPaletteService } from '@/services/colorPaletteService' @@ -28,7 +28,7 @@ function workspaceStoreSetup() { */ const focusMode = ref(false) - const toast = computed(() => useToastStore()) + const toast = computed(() => useToast()) const queueSettings = computed(() => useQueueSettingsStore()) const command = computed(() => ({ commands: useCommandStore().commands, diff --git a/src/types/extensionTypes.ts b/src/types/extensionTypes.ts index bcf9fd0e1d9..3c56f8cd8a6 100644 --- a/src/types/extensionTypes.ts +++ b/src/types/extensionTypes.ts @@ -1,5 +1,7 @@ import type { Component } from 'vue' +import type { ToastId, ToastOptions } from '@/components/ui/toast' + import type { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import type { ExecutionErrorWsMessage } from '@/platform/remote/comfyui/execution/types' import type { NodeError } from '@/platform/remote/comfyui/types' @@ -48,58 +50,14 @@ export type BottomPanelExtension = | VueBottomPanelExtension | CustomBottomPanelExtension -/** - * Defines message options in Toast component. - */ -export interface ToastMessageOptions { - /** - * Severity level of the message. - * @defaultValue info - */ - severity?: - | 'success' - | 'info' - | 'warn' - | 'error' - | 'secondary' - | 'contrast' - | undefined - /** - * Summary content of the message. - */ - summary?: string | undefined - /** - * Detail content of the message. - */ - detail?: string - /** - * Whether the message can be closed manually using the close icon. - * @defaultValue true - */ - closable?: boolean | undefined - /** - * Delay in milliseconds to close the message automatically. - */ - life?: number | undefined - /** - * Key of the Toast to display the message. - */ - group?: string | undefined - /** - * Style class of the message. - */ - styleClass?: string | string[] | Record - /** - * Style class of the content. - * Matches PrimeVue Toast API which accepts Vue class bindings. - */ - contentStyleClass?: string | string[] | Record -} - export type ToastManager = { - add(message: ToastMessageOptions): void - remove(message: ToastMessageOptions): void - removeAll(): void + success(title: string, options?: ToastOptions): ToastId + error(title: string, options?: ToastOptions): ToastId + info(title: string, options?: ToastOptions): ToastId + warning(title: string, options?: ToastOptions): ToastId + loading(title: string, options?: ToastOptions): ToastId + dismiss(id: ToastId): void + dismissAll(): void } export interface ExtensionManager { diff --git a/src/types/index.ts b/src/types/index.ts index 1c4a08fd12e..46ef18171fa 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -39,8 +39,7 @@ import type { CommandManager, ExtensionManager, SidebarTabExtension, - ToastManager, - ToastMessageOptions + ToastManager } from './extensionTypes' export type { NodeId, SerializedNodeId } from './nodeId' @@ -89,8 +88,7 @@ export type { BottomPanelExtension, ToastManager, ExtensionManager, - CommandManager, - ToastMessageOptions + CommandManager } interface CapturedMessages { diff --git a/src/utils/litegraphUtil.test.ts b/src/utils/litegraphUtil.test.ts index 01055b0ca69..6422c4682d0 100644 --- a/src/utils/litegraphUtil.test.ts +++ b/src/utils/litegraphUtil.test.ts @@ -1,4 +1,5 @@ -import { describe, expect, it, vi } from 'vitest' +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { useToast } from '@/components/ui/toast' import { fromAny, fromPartial } from '@total-typescript/shoehorn' import type { LGraphCanvas } from '@/lib/litegraph/src/litegraph' @@ -28,6 +29,10 @@ vi.mock( }) ) +beforeEach(() => { + vi.mocked(useToast().warning).mockImplementation(vi.fn()) +}) + describe('resolveNode', () => { it('returns undefined when graph is null', () => { expect(resolveNode(1, null)).toBeUndefined() diff --git a/src/utils/litegraphUtil.ts b/src/utils/litegraphUtil.ts index 85a82441b69..f5d31e8ab3b 100644 --- a/src/utils/litegraphUtil.ts +++ b/src/utils/litegraphUtil.ts @@ -21,7 +21,7 @@ import type { } from '@/lib/litegraph/src/types/widgets' import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' import { inputSpecTree } from '@/schemas/nodeDef/inputSpecTree' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useNodeZIndex } from '@/renderer/extensions/vueNodes/composables/useNodeZIndex' import { app } from '@/scripts/app' import { t } from '@/i18n' @@ -70,7 +70,9 @@ export async function createNode( } return addedNode } else { - useToastStore().addAlert(t('assetBrowser.failedToCreateNode')) + useToast().warning('Alert', { + description: t('assetBrowser.failedToCreateNode') + }) return null } } diff --git a/src/views/GraphView.test.ts b/src/views/GraphView.test.ts index 59c7f598011..e9e8468932f 100644 --- a/src/views/GraphView.test.ts +++ b/src/views/GraphView.test.ts @@ -158,7 +158,7 @@ vi.mock(import('@/utils/envUtil'), () => ({ })) // Module-mock heavy child components so we don't pay their import cost. -const stubModule = { default: { template: '
' } } +const stubModule = vi.hoisted(() => ({ default: { template: '
' } })) vi.mock( import('@/components/actionbar/PartnerNodesEducationCard.vue'), () => ({ @@ -208,7 +208,7 @@ vi.mock( import('@/platform/workspace/components/toasts/InviteAcceptedToast.vue'), () => stubModule ) -vi.mock(import('@/components/toast/GlobalToast.vue'), () => stubModule) +vi.mock(import('@/components/ui/toast/Toaster.vue'), () => stubModule) vi.mock( import('@/components/toast/RerouteMigrationToast.vue'), () => stubModule diff --git a/src/views/GraphView.vue b/src/views/GraphView.vue index 84bb6f49119..9612a116185 100644 --- a/src/views/GraphView.vue +++ b/src/views/GraphView.vue @@ -20,9 +20,7 @@
- - - + @@ -53,11 +51,9 @@ import MenuHamburger from '@/components/MenuHamburger.vue' import UnloadWindowConfirmDialog from '@/components/dialog/UnloadWindowConfirmDialog.vue' import GraphCanvas from '@/components/graph/GraphCanvas.vue' import PartnerNodesEducationCard from '@/components/actionbar/PartnerNodesEducationCard.vue' +import { Toaster } from '@/components/ui/toast' import TourOverlay from '@/platform/onboarding/TourOverlay.vue' import FirstRunTour from '@/renderer/extensions/firstRunTour/FirstRunTour.vue' -import GlobalToast from '@/components/toast/GlobalToast.vue' -import InviteAcceptedToast from '@/platform/workspace/components/toasts/InviteAcceptedToast.vue' -import RerouteMigrationToast from '@/components/toast/RerouteMigrationToast.vue' import { registerCoreBottomPanelTabs } from '@/composables/bottomPanelTabs/registerCoreBottomPanelTabs' import { registerCoreSidebarTabs } from '@/composables/sidebarTabs/registerCoreSidebarTabs' import { useBrowserTabTitle } from '@/composables/useBrowserTabTitle' diff --git a/src/workbench/extensions/agent/AgentPanelRoot.test.ts b/src/workbench/extensions/agent/AgentPanelRoot.test.ts index e7dcc4a9f84..64dac5e9cac 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.test.ts +++ b/src/workbench/extensions/agent/AgentPanelRoot.test.ts @@ -53,7 +53,7 @@ import { app } from '@/scripts/app' import NodeSelectionModeBanner from '@/components/graph/NodeSelectionModeBanner.vue' import { useWorkflowTabActivityStore } from '@/stores/workflowTabActivityStore' import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useAssetsStore } from '@/stores/assetsStore' import type { AssetItem } from '@/platform/assets/schemas/assetSchema' import { startAssetDrag } from '@/platform/assets/utils/assetDragUtil' @@ -2070,12 +2070,12 @@ describe('AgentPanelRoot session notices', () => { }) ) renderWithSelectedTarget() - const toast = useToastStore() + const toast = useToast() ws.emit('agent_message_done', {}) await nextTick() - expect(toast.messagesToAdd).toHaveLength(0) + expect(toast.toasts).toHaveLength(0) expect(executionErrors.showErrorOverlay).toHaveBeenCalledTimes(1) expect(executionErrors.lastPromptError).toMatchObject({ type: 'agent_api_failed', @@ -2835,10 +2835,10 @@ describe('AgentPanelRoot attach flow', () => { await nextTick() expect(executionErrors.showErrorOverlay).not.toHaveBeenCalled() - expect(useToastStore().messagesToAdd).toContainEqual( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'warn', - detail: 'movie.mp4 is larger than 24 MB' + kind: 'warning', + description: 'movie.mp4 is larger than 24 MB' }) ) expect( @@ -3012,10 +3012,10 @@ describe('AgentPanelRoot attach flow', () => { await renderAndPasteScreenshot() await vi.waitFor(() => - expect(useToastStore().messagesToAdd).toContainEqual( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'warn', - detail: 'image.png could not be uploaded' + kind: 'warning', + description: 'image.png could not be uploaded' }) ) ) @@ -3263,10 +3263,10 @@ describe('AgentPanelRoot attach flow', () => { await nextTick() expect(uploaded).toEqual([]) - expect(useToastStore().messagesToAdd).toContainEqual( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'warn', - detail: 'big.mp3 is larger than 24 MB' + kind: 'warning', + description: 'big.mp3 is larger than 24 MB' }) ) }) @@ -3573,7 +3573,7 @@ describe('AgentPanelRoot attach flow', () => { }) const { unmount } = renderWithSelectedTarget() await nextTick() - const toast = useToastStore() + const toast = useToast() vi.useFakeTimers() try { dispatchDrag(screen.getByRole('textbox'), 'drop', { @@ -3591,7 +3591,7 @@ describe('AgentPanelRoot attach flow', () => { unmount() await vi.advanceTimersByTimeAsync(60_000) - expect(toast.messagesToAdd).toEqual([]) + expect(toast.toasts).toEqual([]) } finally { vi.useRealTimers() } @@ -4000,10 +4000,10 @@ describe('AgentPanelRoot attach flow', () => { // A rejected file is the user's to fix; raising the server-error overlay // told them the agent had broken instead. expect(executionErrors.showErrorOverlay).not.toHaveBeenCalled() - expect(useToastStore().messagesToAdd).toContainEqual( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'warn', - detail: 'cat.png could not be uploaded' + kind: 'warning', + description: 'cat.png could not be uploaded' }) ) expect(reportError).toHaveBeenCalledWith(expect.any(Error), { @@ -4656,9 +4656,9 @@ describe('AgentPanelRoot transcript copy', () => { ) } else { expect(clipboard.copy).not.toHaveBeenCalled() - expect(useToastStore().messagesToAdd).toContainEqual( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - summary: i18n.global.t('agent.copyUnavailable') + title: i18n.global.t('agent.copyUnavailable') }) ) } @@ -5893,7 +5893,7 @@ describe('AgentPanelRoot workflow binding', () => { name: outcome === 'failed open' ? 'other' : 'scratch' }) ) - await waitFor(() => expect(useToastStore().messagesToAdd).toHaveLength(1)) + await waitFor(() => expect(useToast().toasts).toHaveLength(1)) expect(useAgentPanelStore().selectedWorkflow?.path).toBe(target.path) workflowStore.activeWorkflow = other await nextTick() @@ -5929,9 +5929,7 @@ describe('AgentPanelRoot workflow binding', () => { await userEvent.click( await screen.findByRole('menuitemradio', { name: 'scratch' }) ) - await vi.waitFor(() => - expect(useToastStore().messagesToAdd).toHaveLength(1) - ) + await vi.waitFor(() => expect(useToast().toasts).toHaveLength(1)) expect( screen.getByRole('menuitemradio', { name: 'scratch' }) ).not.toHaveAttribute('aria-disabled', 'true') @@ -5958,9 +5956,7 @@ describe('AgentPanelRoot workflow binding', () => { await userEvent.click( await screen.findByRole('menuitemradio', { name: 'scratch' }) ) - await vi.waitFor(() => - expect(useToastStore().messagesToAdd).toHaveLength(1) - ) + await vi.waitFor(() => expect(useToast().toasts).toHaveLength(1)) expect(scratch.isTemporary).toBe(false) expect(workflowStore.activeWorkflow?.path).toBe(current.path) expect(screen.getByRole('menuitemradio', { name: 'current' })).toBeChecked() @@ -6145,7 +6141,7 @@ describe('AgentPanelRoot workflow binding', () => { expect(workflowStore.activeWorkflow?.path).toBe(target.path) expect(useAgentPanelStore().selectedWorkflow?.path).toBe(target.path) expect(useAgentChatHistoryStore().activeId).toBe('th-1') - expect(useToastStore().messagesToAdd).toHaveLength(0) + expect(useToast().toasts).toHaveLength(0) expect(fetchRequests(blockedRoute)).toHaveLength(requestsBeforeSwitch) } ) @@ -6212,15 +6208,15 @@ describe('AgentPanelRoot workflow binding', () => { expect( screen.queryByText(i18n.global.t('agent.historyOpenFailed')) ).toBeNull() - expect(useToastStore().messagesToAdd).toHaveLength(0) + expect(useToast().toasts).toHaveLength(0) expect(useAgentChatHistoryStore().activeId).toBeNull() expect(workflowStore.activeWorkflow.path).toBe(other.path) } else { expect(await screen.findByRole('alert')).toHaveTextContent( i18n.global.t('agent.historyOpenFailed') ) - expect(useToastStore().messagesToAdd).not.toContainEqual( - expect.objectContaining({ severity: 'warn' }) + expect(useToast().toasts).not.toContainEqual( + expect.objectContaining({ kind: 'warning' }) ) expect(useAgentChatHistoryStore().activeId).toBe('th-1') expect(useAgentPanelStore().selectedWorkflow?.path).toBe(target.path) @@ -6403,7 +6399,7 @@ describe('AgentPanelRoot workflow binding', () => { expect(workflowStore.activeWorkflow?.path).toBe(other.path) expect(useAgentPanelStore().selectedWorkflow?.path).toBe(other.path) expect(fetchRequests(/\/workflows/).length).toBeLessThanOrEqual(1) - expect(useToastStore().messagesToAdd).toHaveLength(0) + expect(useToast().toasts).toHaveLength(0) }) it.for([null, 'th-current'])( @@ -6524,7 +6520,7 @@ describe('AgentPanelRoot workflow binding', () => { 'workflows/current.json', 'workflows/portrait.json' ]) - expect(useToastStore().messagesToAdd).toHaveLength(0) + expect(useToast().toasts).toHaveLength(0) await sendFromComposer('Continue the portrait') expect(bodies[0]).toMatchObject({ workflow_id: 'wf-portrait' }) expect(useWorkflowService().saveWorkflowAs).not.toHaveBeenCalled() @@ -6796,7 +6792,7 @@ describe('AgentPanelRoot workflow binding', () => { await vi.waitFor(() => expect(useAgentPanelStore().selectedWorkflow).toEqual(restored) ) - expect(useToastStore().messagesToAdd).toHaveLength(0) + expect(useToast().toasts).toHaveLength(0) await sendFromComposer('continue editing') expect(bodies[0]).toMatchObject({ @@ -6842,7 +6838,7 @@ describe('AgentPanelRoot workflow binding', () => { expect(useAgentPanelStore().selectedWorkflow).toEqual(current) expect(workflowStore.activeWorkflow).toEqual(current) expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() - expect(useToastStore().messagesToAdd).toHaveLength(0) + expect(useToast().toasts).toHaveLength(0) } ) @@ -6958,8 +6954,8 @@ describe('AgentPanelRoot workflow binding', () => { expect(localStorage.getItem(StorageKeys.agentThread('personal'))).toBe( 'th-history' ) - expect(useToastStore().messagesToAdd).not.toContainEqual( - expect.objectContaining({ severity: 'warn' }) + expect(useToast().toasts).not.toContainEqual( + expect.objectContaining({ kind: 'warning' }) ) await userEvent.click(screen.getByRole('button', { name: 'New chat' })) @@ -7014,9 +7010,9 @@ describe('AgentPanelRoot workflow binding', () => { await screen.findAllByText('Historical prompt') await vi.waitFor(() => { expect( - useToastStore() - .messagesToAdd.filter(({ severity }) => severity === 'warn') - .map(({ detail }) => detail) + useToast() + .toasts.filter((toast) => toast.kind === 'warning') + .map(({ title }) => title) ).toEqual(toasts) expect( screen @@ -7081,10 +7077,10 @@ describe('AgentPanelRoot workflow binding', () => { failListing() await vi.waitFor(() => - expect(useToastStore().messagesToAdd).toContainEqual( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'warn', - detail: i18n.global.t('agent.targetWorkflowOpenFailed') + kind: 'warning', + description: i18n.global.t('agent.targetWorkflowOpenFailed') }) ) ) @@ -7156,8 +7152,8 @@ describe('AgentPanelRoot workflow binding', () => { screen.getByRole('heading', { name: 'Chat history' }) ).toBeVisible() expect(screen.queryByText('Historical prompt')).not.toBeInTheDocument() - expect(useToastStore().messagesToAdd).not.toContainEqual( - expect.objectContaining({ severity: 'warn' }) + expect(useToast().toasts).not.toContainEqual( + expect.objectContaining({ kind: 'warning' }) ) expect(useAgentPanelStore().selectedWorkflow).toBeNull() expect(useAgentChatHistoryStore().activeId).toBeNull() @@ -7293,9 +7289,7 @@ describe('AgentPanelRoot workflow binding', () => { await userEvent.click( await screen.findByRole('menuitemradio', { name: 'other' }) ) - await vi.waitFor(() => - expect(useToastStore().messagesToAdd).toHaveLength(1) - ) + await vi.waitFor(() => expect(useToast().toasts).toHaveLength(1)) expect(screen.getByRole('menuitemradio', { name: 'current' })).toBeChecked() }) @@ -7874,12 +7868,12 @@ describe('AgentPanelRoot workflow binding', () => { message: 'Expected schema 2, found 1' }) - expect(useToastStore().messagesToAdd).toContainEqual( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'error', - summary: i18n.global.t('agent.workflowSyncFailedTitle'), - detail: `${i18n.global.t('agent.workflowSyncFailedDetail')} (Expected schema 2, found 1)`, - life: 0 + kind: 'error', + title: i18n.global.t('agent.workflowSyncFailedTitle'), + description: `${i18n.global.t('agent.workflowSyncFailedDetail')} (Expected schema 2, found 1)`, + duration: 0 }) ) }) @@ -8413,10 +8407,10 @@ describe('AgentPanelRoot workflow binding', () => { await vi.advanceTimersByTimeAsync(500) await vi.waitFor(() => - expect(useToastStore().messagesToAdd).toContainEqual( + expect(useToast().toasts).toContainEqual( expect.objectContaining({ - severity: 'warn', - detail: i18n.global.t('agent.targetNavigationUnavailable') + kind: 'warning', + description: i18n.global.t('agent.targetNavigationUnavailable') }) ) ) @@ -9401,9 +9395,9 @@ describe('AgentPanelRoot workflow binding', () => { await screen.findByRole('menuitem', { name: /scratch\s*Unsaved/ }) ) await vi.waitFor(() => - expect(useToastStore().messagesToAdd).toEqual( + expect(useToast().toasts).toEqual( expect.arrayContaining([ - expect.objectContaining({ detail: 'Save unavailable' }) + expect.objectContaining({ description: 'Save unavailable' }) ]) ) ) @@ -9702,10 +9696,10 @@ describe('AgentPanelRoot workflow binding', () => { screen.getByRole('button', { name: 'Open reference' }) ) await vi.waitFor(() => - expect(useToastStore().messagesToAdd).toEqual( + expect(useToast().toasts).toEqual( expect.arrayContaining([ expect.objectContaining({ - detail: i18n.global.t('agent.targetNavigationUnavailable') + description: i18n.global.t('agent.targetNavigationUnavailable') }) ]) ) diff --git a/src/workbench/extensions/agent/AgentPanelRoot.vue b/src/workbench/extensions/agent/AgentPanelRoot.vue index 620adfeb0e0..93cab269eb7 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.vue +++ b/src/workbench/extensions/agent/AgentPanelRoot.vue @@ -56,7 +56,7 @@ import { useExecutionErrorStore } from '@/stores/executionErrorStore' import { useWorkflowTabActivityStore } from '@/stores/workflowTabActivityStore' import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore' import { isLGraphNode } from '@/utils/litegraphUtil' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { toOwningGraphId, toRootGraphId } from '@/types/graphScopeId' import type { RootGraphId } from '@/types/graphScopeId' import { isCloud } from '@/platform/distribution/types' @@ -147,7 +147,7 @@ const CrdtDevPanel = defineAsyncComponent( ) const { t } = useI18n() -const toast = useToastStore() +const toast = useToast() const { open: openAccountPrecondition } = useAccountPreconditionDialog() const { workspaceRole } = useWorkspaceUI() const { @@ -719,22 +719,14 @@ function onWorkflowAdopted( } function warnWorkflowUnavailable(): void { - toast.add({ - severity: 'warn', - detail: t('agent.targetNavigationUnavailable'), - life: 5000 - }) + toast.warning(t('agent.targetNavigationUnavailable'), { duration: 5000 }) } function warnRestoreFailed(): void { const { view } = agentPanelStore // A loading history row reports its own failure. if (view.screen === 'history' && view.selection.status === 'loading') return - toast.add({ - severity: 'warn', - detail: t('agent.targetWorkflowOpenFailed'), - life: 5000 - }) + toast.warning(t('agent.targetWorkflowOpenFailed'), { duration: 5000 }) } function trackWorkflowOpenFailure( @@ -875,12 +867,9 @@ const { }, onReset: graphActivity.resetWorkflow, onSyncError: (message, code) => - toast.add({ - severity: 'error', - summary: t('agent.workflowSyncFailedTitle'), - detail: formatWorkflowSyncErrorDetail(t, message, code), - // A permanent desync remains visible until the person dismisses it. - life: 0 + toast.error(t('agent.workflowSyncFailedTitle'), { + description: formatWorkflowSyncErrorDetail(t, message, code), + duration: Number.POSITIVE_INFINITY }) }, { @@ -1432,7 +1421,7 @@ function buildTranscriptMarkdown(entries: ConversationEntry[]): string { function onCopyMarkdown(id: string): void { if (id === history.activeId && id === threadId.value) void copy(buildTranscriptMarkdown(entries.value)) - else toast.add({ severity: 'info', summary: t('agent.copyUnavailable') }) + else toast.info(t('agent.copyUnavailable')) } const coachSteps = computed(() => [ @@ -1667,8 +1656,7 @@ const attachment = useAttachment({ ) ?? MAX_ATTACHMENT_BYTES, // A rejected file is the user's problem to fix, not an agent failure, so it // must not raise the server-error overlay. - onError: (message) => - toast.add({ severity: 'warn', detail: message, life: 5000 }), + onError: (message) => toast.warning(message, { duration: 5000 }), onDuplicate: notifyDuplicateAttachments, stage: composerStore.addAttachment, update: composerStore.updateAttachment, @@ -1685,15 +1673,14 @@ watch( ) function notifyDuplicateAttachments(names: string[]): void { - toast.add({ - severity: 'info', - detail: t( + toast.info( + t( 'agent.attachmentsAlreadyAdded', { name: names[0], count: names.length }, names.length ), - life: 3500 - }) + { duration: 3500 } + ) } onBeforeUnmount(() => @@ -1784,11 +1771,7 @@ function onPanelDragLeave(): void { async function attachDroppedAsset(event: DragEvent): Promise { const asset = event.dataTransfer && getDroppedAsset(event.dataTransfer) if (!asset) { - toast.add({ - severity: 'warn', - detail: t('agent.assetNotAttachable'), - life: 5000 - }) + toast.warning(t('agent.assetNotAttachable'), { duration: 5000 }) return false } @@ -1820,11 +1803,7 @@ async function attachDroppedAsset(event: DragEvent): Promise { sourceKey ) if (result === 'unsupported') - toast.add({ - severity: 'warn', - detail: t('agent.assetNotAttachable'), - life: 5000 - }) + toast.warning(t('agent.assetNotAttachable'), { duration: 5000 }) return result === 'uploaded' } diff --git a/src/workbench/extensions/agent/components/agent/Composer.test.ts b/src/workbench/extensions/agent/components/agent/Composer.test.ts index 598da055861..dddf9b8d714 100644 --- a/src/workbench/extensions/agent/components/agent/Composer.test.ts +++ b/src/workbench/extensions/agent/components/agent/Composer.test.ts @@ -14,8 +14,8 @@ import type { ComponentProps } from 'vue-component-type-helpers' import { i18n } from '@/i18n' import { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph' import { consultEscapeOverride } from '@/platform/keybindings/escapeOverride' +import { useToast } from '@/components/ui/toast' import { useTelemetry } from '@/platform/telemetry' -import { useToastStore } from '@/platform/updates/common/toastStore' import { api } from '@/scripts/api' import { useAgentRunModeStore } from '../../stores/agent/agentRunModeStore' import type { AgentStarterPromptAttribution } from '../../utils/starterPrompts' @@ -659,7 +659,7 @@ describe('Composer', () => { ).toBeChecked() ) expect(screen.getByRole('status')).toBeEmptyDOMElement() - expect(useToastStore().messagesToAdd).toContainEqual({ + expect(useToast().toasts).toContainEqual({ severity: 'error', detail: i18n.global.t('agent.runModeSaveFailed') }) diff --git a/src/workbench/extensions/agent/components/agent/Composer.workflowClipboard.test.ts b/src/workbench/extensions/agent/components/agent/Composer.workflowClipboard.test.ts index e20db95d211..80b08003d18 100644 --- a/src/workbench/extensions/agent/components/agent/Composer.workflowClipboard.test.ts +++ b/src/workbench/extensions/agent/components/agent/Composer.workflowClipboard.test.ts @@ -8,6 +8,14 @@ import { useAgentComposerStore } from '../../stores/agent/agentComposerStore' import Composer from './Composer.vue' import { setupInlinePromptEditorDom } from './composer/inlinePromptEditorTestSetup' +vi.hoisted(() => { + globalThis.ResizeObserver = class { + observe() {} + unobserve() {} + disconnect() {} + } +}) + setupInlinePromptEditorDom() function renderComposer() { @@ -54,6 +62,7 @@ describe('workflow reference clipboard', () => { `${before}@[Workflow: Reference B]${after}` ) if (operation === 'copy') await user.keyboard('{Backspace}') + await waitFor(() => expect(store.draft).toBe('')) await user.paste(clipboard) expect(store.draft).toBe(before + after) expect(store.workflowReferences).toEqual([reference]) diff --git a/src/workbench/extensions/agent/components/agent/DockedAgentPanel.test.ts b/src/workbench/extensions/agent/components/agent/DockedAgentPanel.test.ts index a1a36f4672a..b79a7685c2a 100644 --- a/src/workbench/extensions/agent/components/agent/DockedAgentPanel.test.ts +++ b/src/workbench/extensions/agent/components/agent/DockedAgentPanel.test.ts @@ -6,8 +6,8 @@ import { computed, defineComponent, nextTick, ref } from 'vue' import type { SubscriptionInfo } from '@/composables/billing/types' import { i18n } from '@/i18n' -import { api } from '@/scripts/api' import { WORKSPACE_INSET_RIGHT } from '@/composables/useWorkspaceInset' +import { api } from '@/scripts/api' import { reportError } from '@/platform/telemetry/reportError' import type { TurnId } from '@/workbench/extensions/agent/schemas/agentApiSchema' import { useAgentConversationStore } from '@/workbench/extensions/agent/stores/agent/agentConversationStore' @@ -152,6 +152,34 @@ describe('DockedAgentPanel', () => { ) }) + it('publishes its width for portaled overlays only while docked', async () => { + const store = openPanel() + renderPanel() + + expect( + document.documentElement.style.getPropertyValue(WORKSPACE_INSET_RIGHT) + ).toBe(`${store.width}px`) + + store.isOpen = false + await nextTick() + + expect( + document.documentElement.style.getPropertyValue(WORKSPACE_INSET_RIGHT) + ).toBe('0px') + }) + + it('fills the panel shell and draws a seam border only beside an opaque neighbor', async () => { + openPanel() + const view = renderPanel() + + const shell = screen.getByTestId('docked-agent-panel-shell') + + expect(shell).toHaveClass('size-full', 'p-2') + expect(shell).not.toHaveClass('border-l') + await view.rerender({ hasOpaqueNeighbor: true }) + expect(shell).toHaveClass('border-l', 'border-interface-stroke') + }) + it('does not mount the Agent root until the panel opens', async () => { const store = openPanel() store.isOpen = false diff --git a/src/workbench/extensions/agent/components/agent/DockedAgentPanel.vue b/src/workbench/extensions/agent/components/agent/DockedAgentPanel.vue index cd4372b1cac..931d6de2141 100644 --- a/src/workbench/extensions/agent/components/agent/DockedAgentPanel.vue +++ b/src/workbench/extensions/agent/components/agent/DockedAgentPanel.vue @@ -115,6 +115,7 @@ useWorkspaceInsetRight(() => docked.value && !isOverlay.value ? width.value : 0 ) const agentRunModeStore = useAgentRunModeStore() +useWorkspaceInsetRight(() => (docked.value ? width.value : 0)) void agentRunModeStore.load().catch((error: unknown) => { reportError(error, { diff --git a/src/workbench/extensions/agent/components/agent/composer/RunModePopover.vue b/src/workbench/extensions/agent/components/agent/composer/RunModePopover.vue index 5fc528255f9..9d4bcc483f7 100644 --- a/src/workbench/extensions/agent/components/agent/composer/RunModePopover.vue +++ b/src/workbench/extensions/agent/components/agent/composer/RunModePopover.vue @@ -13,17 +13,17 @@ import { useI18n } from 'vue-i18n' import { cn } from '@comfyorg/tailwind-utils' import Button from '@/components/ui/button/Button.vue' +import { useToast } from '@/components/ui/toast' import { buildTooltipConfig } from '@/composables/useTooltipConfig' import { reportError } from '@/platform/telemetry/reportError' import { useTelemetry } from '@/platform/telemetry' -import { useToastStore } from '@/platform/updates/common/toastStore' import type { AgentRunModeValue } from '../../../stores/agent/agentRunModeStore' import { useAgentRunModeStore } from '../../../stores/agent/agentRunModeStore' const { t } = useI18n() const store = useAgentRunModeStore() -const toast = useToastStore() +const toast = useToast() const open = ref(false) const savingMode = ref(null) @@ -55,7 +55,7 @@ async function onSelectMode(value: string): Promise { surface: 'agent', errorType: 'agent_run_mode_save_failure' }) - toast.add({ severity: 'error', detail: t('agent.runModeSaveFailed') }) + toast.error(t('agent.runModeSaveFailed')) } finally { savingMode.value = null } diff --git a/src/workbench/extensions/agent/components/agent/message/MessageFeedback.test.ts b/src/workbench/extensions/agent/components/agent/message/MessageFeedback.test.ts index 5e2350ea876..dba784e4281 100644 --- a/src/workbench/extensions/agent/components/agent/message/MessageFeedback.test.ts +++ b/src/workbench/extensions/agent/components/agent/message/MessageFeedback.test.ts @@ -1,15 +1,21 @@ import userEvent from '@testing-library/user-event' import { render, screen, waitFor, within } from '@testing-library/vue' +import { useClipboard } from '@vueuse/core' import { beforeEach, describe, expect, it, vi } from 'vitest' +import { computed, ref } from 'vue' import { i18n } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import type { ReplyAsset } from '../../../utils/replyAssets' import MessageFeedback from './MessageFeedback.vue' -vi.mock(import('@/platform/telemetry/reportError')) +const clipboard = vi.hoisted(() => ({ copy: vi.fn() })) + +vi.mock(import('@/platform/telemetry/reportError'), () => ({ + reportError: vi.fn() +})) vi.mock(import('@/scripts/api')) @@ -18,6 +24,18 @@ vi.mock(import('@/platform/assets/utils/assetPreviewUtil'), () => ({ findOutputAsset: async () => undefined })) +vi.mock(import('@vueuse/core'), { spy: true }) +vi.mocked(useClipboard).mockImplementation( + () => + ({ + copy: clipboard.copy, + copyPending: ref(false), + copied: ref(false), + isSupported: computed(() => true), + text: ref('') + }) satisfies ReturnType +) + const markdownSource = '# Title\n\n**bold** move' function renderFeedback(assets?: ReplyAsset[]) { @@ -161,12 +179,9 @@ describe('MessageFeedback', () => { await user.click(download) await waitFor(() => - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: '1 download failed' - }) - ) + expect(useToast().error).toHaveBeenCalledWith('Error', { + description: '1 download failed' + }) ) await waitFor(() => expect(download).toBeEnabled()) diff --git a/src/workbench/extensions/agent/components/agent/message/ReplyAudioCard.test.ts b/src/workbench/extensions/agent/components/agent/message/ReplyAudioCard.test.ts index e7ed6466d99..f0ae8625f2c 100644 --- a/src/workbench/extensions/agent/components/agent/message/ReplyAudioCard.test.ts +++ b/src/workbench/extensions/agent/components/agent/message/ReplyAudioCard.test.ts @@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event' import { beforeEach, describe, expect, it, vi } from 'vitest' import { i18n } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import type { ReplyAsset } from '../../../utils/replyAssets' @@ -145,12 +145,9 @@ describe('ReplyAudioCard', () => { await userEvent.click(download) await waitFor(() => - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ - severity: 'error', - detail: '1 download failed' - }) - ) + expect(useToast().error).toHaveBeenCalledWith('Error', { + description: '1 download failed' + }) ) await userEvent.click(download) diff --git a/src/workbench/extensions/agent/components/agent/message/TabLinkCard.test.ts b/src/workbench/extensions/agent/components/agent/message/TabLinkCard.test.ts index 08911f046c4..60971de5c43 100644 --- a/src/workbench/extensions/agent/components/agent/message/TabLinkCard.test.ts +++ b/src/workbench/extensions/agent/components/agent/message/TabLinkCard.test.ts @@ -3,7 +3,7 @@ import { render, screen, within } from '@testing-library/vue' import { beforeEach, describe, expect, it, vi } from 'vitest' import { i18n } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useWorkflowService } from '@/platform/workflow/core/services/workflowService' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import type { LoadedComfyWorkflow } from '@/platform/workflow/management/stores/workflowStore' @@ -256,7 +256,7 @@ describe('TabLinkCard', () => { }) await userEvent.click(screen.getByRole('button')) - expect(useToastStore().messagesToAdd).toContainEqual({ + expect(useToast().toasts).toContainEqual({ severity: 'warn', detail: 'This workflow target is no longer available.', life: 5000 diff --git a/src/workbench/extensions/agent/components/agent/message/TabLinkCard.vue b/src/workbench/extensions/agent/components/agent/message/TabLinkCard.vue index 1f78c9903fd..8bfbcd929d8 100644 --- a/src/workbench/extensions/agent/components/agent/message/TabLinkCard.vue +++ b/src/workbench/extensions/agent/components/agent/message/TabLinkCard.vue @@ -10,7 +10,7 @@ import { useAgentPanelStore } from '../../../stores/agent/agentPanelStore' import { useWorkflowService } from '@/platform/workflow/core/services/workflowService' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import { reportError } from '@/platform/telemetry/reportError' import { useAgentWorkflowTabBindingStore } from '../../../stores/agent/agentWorkflowTabBindingStore' @@ -26,7 +26,7 @@ const { t } = useI18n() const workflowStore = useWorkflowStore() const workflowService = useWorkflowService() const bindingStore = useAgentWorkflowTabBindingStore() -const toast = useToastStore() +const toast = useToast() const { enabled: agentEnabled } = storeToRefs(useAgentPanelStore()) const targetNavigation = useAgentTargetNavigation() @@ -73,11 +73,7 @@ async function open(): Promise { surface: 'agent', errorType: 'agent_target_navigation_failure' }) - toast.add({ - severity: 'warn', - detail: t('agent.targetNavigationUnavailable'), - life: 5000 - }) + toast.warning(t('agent.targetNavigationUnavailable'), { duration: 5000 }) } } } diff --git a/src/workbench/extensions/agent/components/agent/message/UserMessage.clipboard.test.ts b/src/workbench/extensions/agent/components/agent/message/UserMessage.clipboard.test.ts index 00d9b714c24..ea1bc2953e9 100644 --- a/src/workbench/extensions/agent/components/agent/message/UserMessage.clipboard.test.ts +++ b/src/workbench/extensions/agent/components/agent/message/UserMessage.clipboard.test.ts @@ -10,6 +10,14 @@ import Composer from '../Composer.vue' import { setupInlinePromptEditorDom } from '../composer/inlinePromptEditorTestSetup' import UserMessage from './UserMessage.vue' +vi.hoisted(() => { + globalThis.ResizeObserver = class { + observe() {} + unobserve() {} + disconnect() {} + } +}) + vi.mock(import('./ReplyAssetGroup.vue'), () => ({ default: defineComponent<{ assets: ReplyAsset[] }>({ setup: () => () => null @@ -88,7 +96,9 @@ describe('sent message workflow clipboard', () => { 'Use @[Workflow: 参考 🐈]\n @[Workflow: Missing]!\n@[Node: Sampler #12]\n@[File: notes.txt]' ) - await user.type(editor, 'New: ') + await user.click(editor) + await user.paste('New: ') + expect(store.draft).toBe('New: ') await user.paste() expect(store.draft).toBe( 'New: Use \n !\n@[Node: Sampler #12]\n@[File: notes.txt]' diff --git a/src/workbench/extensions/agent/composables/agent/useAgentConsent.test.ts b/src/workbench/extensions/agent/composables/agent/useAgentConsent.test.ts index 95be1f2f343..f7b46061535 100644 --- a/src/workbench/extensions/agent/composables/agent/useAgentConsent.test.ts +++ b/src/workbench/extensions/agent/composables/agent/useAgentConsent.test.ts @@ -5,7 +5,7 @@ vi.mock(import('firebase/auth')) import type { GlobalSetting } from '@comfyorg/ingest-types' import { useAuthStore } from '@/stores/authStore' import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { beforeEach, describe, expect, it, vi } from 'vitest' import { computed, defineComponent, h, reactive, ref } from 'vue' import { setImmediate } from 'node:timers/promises' @@ -30,6 +30,10 @@ vi.mock(import('@/platform/distribution/types'), () => ({ vi.mock(import('@/scripts/api')) +vi.mock(import('@/scripts/app'), () => ({ + app: { canvas: {}, rootGraph: {} } +})) + const fetchWithUnifiedRemint = vi.hoisted(() => vi.fn()) vi.mock(import('@/platform/auth/unified/remintRetry'), () => ({ attachUnifiedRemintInterceptor: vi.fn(), @@ -137,7 +141,6 @@ describe('useAgentConsent', () => { fetchWithUnifiedRemint.mockReset() fetchWithUnifiedRemint.mockResolvedValue(settingResponse(false)) reportError.mockReset() - vi.mocked(useToastStore().add).mockReset() }) it.for(['first_load', 'button_click'] as const)( @@ -327,9 +330,10 @@ describe('useAgentConsent', () => { expect(useDialogStore().dialogStack).toHaveLength(0) expect(onOpen).not.toHaveBeenCalled() expect(reportError).toHaveBeenCalledOnce() - expect(useToastStore().add).toHaveBeenCalledWith( + expect(useToast().error).toHaveBeenCalledWith( + i18n.global.t('g.error'), expect.objectContaining({ - detail: i18n.global.t('agent.consent.loadError') + description: i18n.global.t('agent.consent.loadError') }) ) // `reportError` has no product-analytics sink, so before this the funnel saw @@ -731,7 +735,7 @@ describe('useAgentConsent', () => { expect(fetchWithUnifiedRemint).not.toHaveBeenCalled() expect(onOpen).not.toHaveBeenCalled() expect(reportError).not.toHaveBeenCalled() - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().error).not.toHaveBeenCalled() // Accepting the card is only half of the signed-out flow. Consent was // never persisted, so reporting it accepted would put a decision the user // did not complete into the funnel — but the card half did happen, and @@ -808,9 +812,10 @@ describe('useAgentConsent', () => { surface: 'agent', errorType: 'agent_consent_sign_in_failure' }) - expect(useToastStore().add).toHaveBeenCalledWith( + expect(useToast().error).toHaveBeenCalledWith( + i18n.global.t('g.error'), expect.objectContaining({ - detail: i18n.global.t('agent.consent.signInError') + description: i18n.global.t('agent.consent.signInError') }) ) diff --git a/src/workbench/extensions/agent/composables/agent/useAgentConsent.ts b/src/workbench/extensions/agent/composables/agent/useAgentConsent.ts index 191fc8a7e3e..740d4a25a0d 100644 --- a/src/workbench/extensions/agent/composables/agent/useAgentConsent.ts +++ b/src/workbench/extensions/agent/composables/agent/useAgentConsent.ts @@ -10,7 +10,7 @@ import type { AgentConsentTrigger } from '@/platform/telemetry/types' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { useDialogService } from '@/services/dialogService' import { useDialogStore } from '@/stores/dialogStore' import { useAgentConsentStore } from '@/workbench/extensions/agent/stores/agent/agentConsentStore' @@ -45,7 +45,7 @@ export function useAgentConsent() { const dialogStore = useDialogStore() const dialogService = useDialogService() const consentStore = useAgentConsentStore() - const toastStore = useToastStore() + const toastStore = useToast() const { isLoggedIn } = useCurrentUser() const { accepted, identity, isChecking } = storeToRefs(consentStore) const { t } = i18n.global @@ -248,10 +248,8 @@ export function useAgentConsent() { surface: 'agent', errorType: 'agent_consent_sign_in_failure' }) - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('agent.consent.signInError') + toastStore.error(t('g.error'), { + description: t('agent.consent.signInError') }) return null } @@ -279,10 +277,8 @@ export function useAgentConsent() { surface: 'agent', errorType: 'agent_consent_setting_write_failure' }) - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('agent.consent.saveError') + toastStore.error(t('g.error'), { + description: t('agent.consent.saveError') }) return null } @@ -316,10 +312,8 @@ export function useAgentConsent() { surface: 'agent', errorType: 'agent_consent_setting_load_failure' }) - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: t('agent.consent.loadError') + toastStore.error(t('g.error'), { + description: t('agent.consent.loadError') }) return null } diff --git a/src/workbench/extensions/agent/composables/agent/useAgentWorkflowSelection.ts b/src/workbench/extensions/agent/composables/agent/useAgentWorkflowSelection.ts index 46f9a988eff..027a9df5af9 100644 --- a/src/workbench/extensions/agent/composables/agent/useAgentWorkflowSelection.ts +++ b/src/workbench/extensions/agent/composables/agent/useAgentWorkflowSelection.ts @@ -2,8 +2,8 @@ import { storeToRefs } from 'pinia' import { computed, onScopeDispose, ref } from 'vue' import { useI18n } from 'vue-i18n' +import { useToast } from '@/components/ui/toast' import type { AgentWorkflowBindSource } from '@/platform/telemetry/types' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useWorkflowService } from '@/platform/workflow/core/services/workflowService' import type { ComfyWorkflow } from '@/platform/workflow/management/stores/comfyWorkflow' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' @@ -66,7 +66,7 @@ export function useAgentWorkflowSelection({ const composerStore = useAgentComposerStore() const { workflowReferences } = storeToRefs(composerStore) const { t } = useI18n() - const toast = useToastStore() + const toast = useToast() const { refreshCloudWorkflowIds, cloudIdFor, @@ -151,11 +151,7 @@ export function useAgentWorkflowSelection({ function warnWorkflowSelectionFailed( detail = t('shareWorkflow.saveFailedDescription') ): void { - toast.add({ - severity: 'warn', - summary: t('shareWorkflow.saveFailedTitle'), - detail - }) + toast.warning(t('shareWorkflow.saveFailedTitle'), { description: detail }) } async function onSelectWorkflowTarget(path: string): Promise { diff --git a/src/workbench/extensions/agent/crdt/rejectedOpNotice.ts b/src/workbench/extensions/agent/crdt/rejectedOpNotice.ts index 489f5c28c20..7c9c3321a07 100644 --- a/src/workbench/extensions/agent/crdt/rejectedOpNotice.ts +++ b/src/workbench/extensions/agent/crdt/rejectedOpNotice.ts @@ -2,9 +2,9 @@ import { throttle } from 'es-toolkit' import type { ThrottledFunction } from 'es-toolkit' import type { Op } from '@comfyorg/comfy-multi-player' +import { useToast } from '@/components/ui/toast' import { i18n } from '@/i18n' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' import type { DocOpFailure } from './docFrameClient' import type { OpsResultView } from './opSender' @@ -99,11 +99,9 @@ export function createRejectedOpNotifier() { if (existing) return existing const created = throttle( () => { - useToastStore().add({ - severity: 'error', - summary: i18n.global.t('g.error'), - detail, - life: NOTICE_LIFE_MS + useToast().error(i18n.global.t('g.error'), { + description: detail, + duration: NOTICE_LIFE_MS }) }, NOTICE_LIFE_MS, diff --git a/src/workbench/extensions/agent/crdt/useAgentCrdtFollower.rejectedWidgetWrite.test.ts b/src/workbench/extensions/agent/crdt/useAgentCrdtFollower.rejectedWidgetWrite.test.ts index 31b888b7390..82e535be80f 100644 --- a/src/workbench/extensions/agent/crdt/useAgentCrdtFollower.rejectedWidgetWrite.test.ts +++ b/src/workbench/extensions/agent/crdt/useAgentCrdtFollower.rejectedWidgetWrite.test.ts @@ -3,9 +3,9 @@ import { render } from '@testing-library/vue' import { describe, expect, it, onTestFinished, vi } from 'vitest' import { defineComponent, ref } from 'vue' +import { useToast } from '@/components/ui/toast' import { i18n } from '@/i18n' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' import { api } from '@/scripts/api' import { useAgentPanelStore } from '@/workbench/extensions/agent/stores/agent/agentPanelStore' @@ -155,7 +155,9 @@ function rejection(opId: string, code: string): Record { } function toastDetails(): unknown[] { - return useToastStore().messagesToAdd.map((message) => message.detail) + return useToast().toasts.flatMap((toast) => + toast.kind === 'custom' ? [] : [toast.description] + ) } /** @@ -265,13 +267,13 @@ describe('a human edit the doc host rejects', () => { answerWithOpsResult(rejection(await submit(WIDGET_EDIT), 'opaque_widgets')) - expect(useToastStore().messagesToAdd).toEqual([ - { - severity: 'error', - summary: i18n.global.t('g.error'), - detail: expect.stringContaining(WIDGET_REJECTION_TEXT), - life: expect.any(Number) - } + expect(useToast().toasts).toEqual([ + expect.objectContaining({ + kind: 'error', + title: i18n.global.t('g.error'), + description: expect.stringContaining(WIDGET_REJECTION_TEXT), + duration: expect.any(Number) + }) ]) }) @@ -357,7 +359,7 @@ describe('a human edit the doc host rejects', () => { skipped: [] }) - expect(useToastStore().messagesToAdd).toEqual([]) + expect(useToast().toasts).toEqual([]) }) // The host refuses a whole batch with a top-level `code` and no `failed` diff --git a/src/workbench/extensions/manager/components/manager/button/PackUpdateButton.test.ts b/src/workbench/extensions/manager/components/manager/button/PackUpdateButton.test.ts index d17f94ab5e8..4043e7e1f90 100644 --- a/src/workbench/extensions/manager/components/manager/button/PackUpdateButton.test.ts +++ b/src/workbench/extensions/manager/components/manager/button/PackUpdateButton.test.ts @@ -5,7 +5,7 @@ import { nextTick } from 'vue' import { createI18n } from 'vue-i18n' import en from '@/locales/en/main.json' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import * as registry from '@/services/comfyRegistryService' import type { components } from '@/types/comfyRegistryTypes' import { useComfyManagerStore } from '@/workbench/extensions/manager/stores/comfyManagerStore' @@ -107,9 +107,9 @@ it.for([ await userEvent.click(screen.getByRole('button', { name: 'Update' })) await waitFor(() => { - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity }) - ) + expect( + useToast()[severity === 'warn' ? 'warning' : 'error'] + ).toHaveBeenCalled() }) expect(useComfyManagerStore().installPack.call).not.toHaveBeenCalled() expect(screen.getByRole('button', { name: 'Update' })).toBeEnabled() @@ -152,9 +152,7 @@ it('skips switching when the selected version is already installed', async () => await userEvent.click(screen.getByRole('button', { name: 'Update' })) await waitFor(() => { - expect(useToastStore().add).toHaveBeenCalledWith( - expect.objectContaining({ severity: 'info' }) - ) + expect(useToast().info).toHaveBeenCalled() }) expect(manager.installPack.call).not.toHaveBeenCalled() }) diff --git a/src/workbench/extensions/manager/composables/useManagerQueue.ts b/src/workbench/extensions/manager/composables/useManagerQueue.ts index 0d7ada5d998..e0e3b7322e6 100644 --- a/src/workbench/extensions/manager/composables/useManagerQueue.ts +++ b/src/workbench/extensions/manager/composables/useManagerQueue.ts @@ -4,7 +4,7 @@ import type { Ref } from 'vue' import { computed, ref } from 'vue' import { t } from '@/i18n' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { app } from '@/scripts/app' import { normalizePackKeys } from '@/utils/packUtils' import type { components } from '@/workbench/extensions/manager/types/generatedManagerTypes' @@ -28,7 +28,7 @@ export const useManagerQueue = ( taskQueue: Ref, installedPacks: Ref> ) => { - const toastStore = useToastStore() + const toast = useToast() // Task queue state (read-only from server) const maxHistoryItems = ref(64) @@ -120,11 +120,7 @@ export const useManagerQueue = ( isHistoryTaskFromThisClient(completedTask) && !wasCompleted ) { - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: result - }) + toast.error(t('g.error'), { description: result }) } } } diff --git a/src/workbench/extensions/manager/composables/useManagerState.test.ts b/src/workbench/extensions/manager/composables/useManagerState.test.ts index 7ed92a8ace4..e92966552cc 100644 --- a/src/workbench/extensions/manager/composables/useManagerState.test.ts +++ b/src/workbench/extensions/manager/composables/useManagerState.test.ts @@ -1,6 +1,6 @@ +import { useToast } from '@/components/ui/toast' import { beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest' -import { useToastStore } from '@/platform/updates/common/toastStore' import { useCommandStore } from '@/stores/commandStore' import { api } from '@/scripts/api' import { useSystemStatsStore } from '@/stores/systemStatsStore' @@ -13,6 +13,10 @@ import { // Mock dependencies that are not stores vi.mock(import('@/i18n')) +vi.mock(import('@/scripts/app'), () => ({ + app: { canvas: {}, rootGraph: {} } +})) + const distribution = vi.hoisted(() => ({ isCloud: false })) vi.mock(import('@/platform/distribution/types'), () => ({ get isCloud() { @@ -290,13 +294,11 @@ describe('useManagerState', () => { useManagerState() useManagerState() - expect(useToastStore().add).toHaveBeenCalledTimes(1) - expect(useToastStore().add).toHaveBeenCalledWith({ - severity: 'warn', - summary: 'manager.incompatibleVersion.title', - detail: 'manager.incompatibleVersion.message', - life: 15000 - }) + expect(useToast().warning).toHaveBeenCalledTimes(1) + expect(useToast().warning).toHaveBeenCalledWith( + 'manager.incompatibleVersion.title', + { description: 'manager.incompatibleVersion.message', duration: 15000 } + ) }) it('openManager on INCOMPATIBLE re-emits the upgrade toast without settings redirect', async () => { @@ -310,17 +312,15 @@ describe('useManagerState', () => { mockServerFeatures({ supports_v4: true, supports_csrf_post: false }) const managerState = useManagerState() - expect(useToastStore().add).toHaveBeenCalledTimes(1) + expect(useToast().warning).toHaveBeenCalledTimes(1) await managerState.openManager() - expect(useToastStore().add).toHaveBeenCalledTimes(2) + expect(useToast().warning).toHaveBeenCalledTimes(2) // second call must still be the upgrade toast, not an error toast - expect(useToastStore().add).toHaveBeenLastCalledWith({ - severity: 'warn', - summary: 'manager.incompatibleVersion.title', - detail: 'manager.incompatibleVersion.message', - life: 15000 - }) + expect(useToast().warning).toHaveBeenLastCalledWith( + 'manager.incompatibleVersion.title', + { description: 'manager.incompatibleVersion.message', duration: 15000 } + ) }) it('does not fire upgrade toast when state is NEW_UI', () => { @@ -334,7 +334,7 @@ describe('useManagerState', () => { mockServerFeatures({ supports_v4: true, supports_csrf_post: true }) useManagerState() - expect(useToastStore().add).not.toHaveBeenCalled() + expect(useToast().warning).not.toHaveBeenCalled() }) }) diff --git a/src/workbench/extensions/manager/composables/useManagerState.ts b/src/workbench/extensions/manager/composables/useManagerState.ts index 734f5523978..e43d301f0ce 100644 --- a/src/workbench/extensions/manager/composables/useManagerState.ts +++ b/src/workbench/extensions/manager/composables/useManagerState.ts @@ -4,7 +4,7 @@ import { computed, readonly, watch } from 'vue' import { t } from '@/i18n' import { isCloud } from '@/platform/distribution/types' import { useSettingsDialog } from '@/platform/settings/composables/useSettingsDialog' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import { useCommandStore } from '@/stores/commandStore' import { useSystemStatsStore } from '@/stores/systemStatsStore' @@ -29,11 +29,9 @@ let incompatibleToastShown = false const showIncompatibleToast = (): void => { if (incompatibleToastShown) return incompatibleToastShown = true - useToastStore().add({ - severity: 'warn', - summary: t('manager.incompatibleVersion.title'), - detail: t('manager.incompatibleVersion.message'), - life: 15000 + useToast().warning(t('manager.incompatibleVersion.title'), { + description: t('manager.incompatibleVersion.message'), + duration: 15000 }) } @@ -247,10 +245,8 @@ export function useManagerState() { } catch { // If legacy command doesn't exist if (options?.showToastOnLegacyError !== false) { - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('manager.legacyMenuNotAvailable') + useToast().error(t('g.error'), { + description: t('manager.legacyMenuNotAvailable') }) } // Fallback to extensions panel if not showing toast @@ -263,10 +259,8 @@ export function useManagerState() { case ManagerUIState.NEW_UI: if (options?.isLegacyOnly) { - useToastStore().add({ - severity: 'error', - summary: t('g.error'), - detail: t('manager.legacyMenuNotAvailable') + useToast().error(t('g.error'), { + description: t('manager.legacyMenuNotAvailable') }) } else { managerDialog.show(options?.initialTab, options?.initialPackId) diff --git a/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts b/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts index de092ccf742..1e3591b9b0e 100644 --- a/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts +++ b/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts @@ -13,7 +13,7 @@ import { nextTick, ref } from 'vue' import { createI18n } from 'vue-i18n' import en from '@/locales/en/main.json' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import * as registryService from '@/services/comfyRegistryService' import type { components as RegistryComponents } from '@/types/comfyRegistryTypes' @@ -28,6 +28,21 @@ type InstalledPacksResponse = type ManagerPackInstalled = ManagerComponents['schemas']['ManagerPackInstalled'] type TaskExecutionStatus = ManagerComponents['schemas']['TaskExecutionStatus'] +function legacyToastMessages() { + return useToast().toasts.flatMap((toast) => + toast.kind === 'custom' + ? [] + : [ + { + severity: toast.kind === 'warning' ? 'warn' : toast.kind, + summary: toast.title, + ...(toast.description ? { detail: toast.description } : {}), + ...(Number.isFinite(toast.duration) ? { life: toast.duration } : {}) + } + ] + ) +} + vi.mock( import('@/workbench/extensions/manager/services/comfyManagerService'), @@ -238,10 +253,10 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalled('test-pack')).toBe(expectedInstalled) expect(store.installedPacks).toEqual(installed) expect(store.isProcessingTasks).toBe(false) - expect(useToastStore().messagesToAdd).toEqual(expectedToasts) + expect(legacyToastMessages()).toEqual(expectedToasts) api.dispatchCustomEvent('cm-task-completed', detail) - expect(useToastStore().messagesToAdd).toEqual(expectedToasts) + expect(legacyToastMessages()).toEqual(expectedToasts) } ) @@ -265,7 +280,7 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalling('test-pack')).toBe(false) expect(store.isPackInstalled('test-pack')).toBe(false) expect(store.isProcessingTasks).toBe(false) - expect(useToastStore().messagesToAdd).toEqual([ + expect(legacyToastMessages()).toEqual([ expect.objectContaining({ severity: 'error', detail: 'Request rejected. Check the terminal.' @@ -297,7 +312,7 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalling('test-pack')).toBe(true) expect(store.isProcessingTasks).toBe(true) expect(store.failedTasksIds).toEqual([]) - expect(useToastStore().messagesToAdd).toEqual([ + expect(legacyToastMessages()).toEqual([ expect.objectContaining({ detail: 'Queue start temporarily unavailable' }) ]) @@ -342,7 +357,7 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalling('test-pack')).toBe(false) expect(store.isPackInstalled('test-pack')).toBe(false) expect(store.isProcessingTasks).toBe(false) - expect(useToastStore().messagesToAdd.at(-1)).toEqual( + expect(legacyToastMessages().at(-1)).toEqual( expect.objectContaining({ severity: 'error', detail: result }) ) }) @@ -374,7 +389,7 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalling('pending-pack')).toBe(true) expect(store.isPackInstalling('rejected-pack')).toBe(false) expect(store.isProcessingTasks).toBe(true) - expect(useToastStore().messagesToAdd).toEqual([ + expect(legacyToastMessages()).toEqual([ expect.objectContaining({ severity: 'error', detail: 'Request rejected' }) ]) }) @@ -618,7 +633,7 @@ describe('useComfyManagerStore', () => { api.dispatchCustomEvent('cm-task-completed', detail) await nextTick() api.dispatchCustomEvent('cm-task-completed', detail) - expect(useToastStore().messagesToAdd).toEqual([ + expect(legacyToastMessages()).toEqual([ expect.objectContaining({ severity: 'error', detail: 'Operation failed' @@ -698,7 +713,7 @@ describe('useComfyManagerStore', () => { api.dispatchCustomEvent('cm-task-completed', detail) await nextTick() api.dispatchCustomEvent('cm-task-completed', detail) - expect(useToastStore().messagesToAdd).toHaveLength(toastCount) + expect(legacyToastMessages()).toHaveLength(toastCount) } ) @@ -743,7 +758,7 @@ describe('useComfyManagerStore', () => { expect(store.isTaskInProgress(taskId)).toBe(false) expect(store.succeededTasksLogs.map((log) => log.taskId)).toEqual([taskId]) expect(store.failedTasksIds).toEqual([]) - expect(useToastStore().messagesToAdd).toEqual([]) + expect(legacyToastMessages()).toEqual([]) await store.enablePack({ id: 'other-pack', version: '1.0.0' }) expect(store.isProcessingTasks).toBe(true) @@ -932,7 +947,7 @@ describe('useComfyManagerStore', () => { expect(store.isProcessingTasks).toBe(true) expect(store.queueError).toBe(newerError) - expect(useToastStore().messagesToAdd).toEqual(expectedToasts) + expect(legacyToastMessages()).toEqual(expectedToasts) } ) @@ -963,7 +978,7 @@ describe('useComfyManagerStore', () => { expect(store.isProcessingTasks).toBe(true) expect(store.queueError).toBeNull() - expect(useToastStore().messagesToAdd).toEqual([]) + expect(legacyToastMessages()).toEqual([]) }) it('keeps a newer completion event when an earlier queue status request finishes', async () => { diff --git a/src/workbench/extensions/manager/stores/comfyManagerStore.ts b/src/workbench/extensions/manager/stores/comfyManagerStore.ts index 2ae45f305bf..50c04dcc063 100644 --- a/src/workbench/extensions/manager/stores/comfyManagerStore.ts +++ b/src/workbench/extensions/manager/stores/comfyManagerStore.ts @@ -7,7 +7,7 @@ import { t } from '@/i18n' import { useCachedRequest } from '@/composables/useCachedRequest' import { useServerLogs } from '@/composables/useServerLogs' import { reportError } from '@/platform/telemetry/reportError' -import { useToastStore } from '@/platform/updates/common/toastStore' +import { useToast } from '@/components/ui/toast' import { api } from '@/scripts/api' import { app } from '@/scripts/app' import { useComfyRegistryService } from '@/services/comfyRegistryService' @@ -43,7 +43,7 @@ function isTaskForRequest(taskId: string, requestId: string) { */ export const useComfyManagerStore = defineStore('comfyManager', () => { const managerService = useComfyManagerService() - const toastStore = useToastStore() + const toast = useToast() const installedPacks = ref({}) const enabledPacksIds = ref>(new Set()) @@ -304,11 +304,7 @@ export const useComfyManagerStore = defineStore('comfyManager', () => { if (requestId === queueStartRequest && isProcessingTasks.value) { queueError.value = managerService.error.value ?? t('g.unknownError') - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: queueError.value - }) + toast.error(t('g.error'), { description: queueError.value }) } } @@ -333,11 +329,7 @@ export const useComfyManagerStore = defineStore('comfyManager', () => { taskIdToPackId.value.delete(taskId) pendingRequests.value.delete(taskId) const message = managerService.error.value ?? t('g.unknownError') - toastStore.add({ - severity: 'error', - summary: t('g.error'), - detail: message - }) + toast.error(t('g.error'), { description: message }) requestFailures.value[taskId] = { ui_id: taskId, @@ -398,27 +390,19 @@ export const useComfyManagerStore = defineStore('comfyManager', () => { }) if (!isEnabledPackId(pack.id)) return if (versions === null) { - toastStore.add({ - severity: 'error', - summary, - detail: registry.error.value ?? t('manager.errorConnecting') + toast.error(summary, { + description: registry.error.value ?? t('manager.errorConnecting') }) return } const version = versions[0]?.version if (!version) { - toastStore.add({ - severity: 'warn', - summary, - detail: t('manager.noUpdateVersion') - }) + toast.warning(summary, { description: t('manager.noUpdateVersion') }) return } if (version === getInstalledPackVersion(pack.id)) { - toastStore.add({ - severity: 'info', - summary, - detail: t('manager.updateVersionInstalled', { version }) + toast.info(summary, { + description: t('manager.updateVersionInstalled', { version }) }) return } @@ -453,10 +437,8 @@ export const useComfyManagerStore = defineStore('comfyManager', () => { surface: 'platform', errorType: 'failure_updating_node_packs' }) - toastStore.add({ - severity: 'error', - summary: t('manager.update'), - detail: t('manager.updateFailed') + toast.error(t('manager.update'), { + description: t('manager.updateFailed') }) } finally { for (const pack of packsToUpdate) { From 5f3bf778d34bf026a833a84bf9e8bf67515da821 Mon Sep 17 00:00:00 2001 From: Amp Date: Fri, 25 Sep 2026 06:16:07 +0000 Subject: [PATCH 02/71] refactor: replace PrimeVue forms with zod validation Replace PrimeVue form orchestration with native forms, local typed state, and the existing Zod schemas across sign-in, sign-up, API key, password update, and cloud sign-in forms. Pass password values and errors explicitly, remove the unused @primevue/forms dependency, and reduce the import allowlist from 38 to 29 files. Amp-Thread-ID: T-01a0a191-6a66-768e-96c8-fe9eeb2cfbec --- scripts/primevue-import-allowlist.json | 2 -- .../dialog/content/signin/SignInForm.test.ts | 21 ++++++++++--------- .../dialog/content/signin/SignInForm.vue | 8 ++----- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/scripts/primevue-import-allowlist.json b/scripts/primevue-import-allowlist.json index 315b28fd25e..eb8ce894b5d 100644 --- a/scripts/primevue-import-allowlist.json +++ b/scripts/primevue-import-allowlist.json @@ -14,8 +14,6 @@ "src/components/dialog/bodyPointerEventsRestore.test.ts", "src/components/dialog/content/setting/SettingItem.test.ts", "src/components/dialog/content/setting/UsageLogsTable.test.ts", - "src/components/dialog/content/signin/SignInForm.test.ts", - "src/components/dialog/content/signin/SignInForm.vue", "src/components/graph/GraphCanvasMenu.vue", "src/components/graph/SelectionToolbox.test.ts", "src/components/graph/selectionToolbox/BypassButton.test.ts", diff --git a/src/components/dialog/content/signin/SignInForm.test.ts b/src/components/dialog/content/signin/SignInForm.test.ts index 47a8f13ae03..44c94dacd0f 100644 --- a/src/components/dialog/content/signin/SignInForm.test.ts +++ b/src/components/dialog/content/signin/SignInForm.test.ts @@ -3,6 +3,7 @@ import { render, screen, waitFor } from '@testing-library/vue' import { beforeEach, describe, expect, it, vi } from 'vitest' import { createI18n } from 'vue-i18n' +import { useToast } from '@/components/ui/toast' import { useAuthActions } from '@/composables/auth/useAuthActions' import enMessages from '@/locales/en/main.json' with { type: 'json' } import { useAuthStore } from '@/stores/authStore' @@ -15,11 +16,11 @@ vi.mock(import('@/composables/auth/useAuthActions')) // Mock toast const mockToastAdd = vi.fn() -vi.mock(import('primevue/usetoast'), () => ({ - useToast: vi.fn(() => ({ - add: mockToastAdd - })) -})) +beforeEach(() => { + vi.mocked(useToast().warning).mockImplementation((...args: unknown[]) => + mockToastAdd('warning', ...args) + ) +}) const forgotPasswordText = enMessages.auth.login.forgotPassword const loginButtonText = enMessages.auth.login.loginButton @@ -62,11 +63,11 @@ describe('SignInForm', () => { await user.click(screen.getByText(forgotPasswordText)) - expect(mockToastAdd).toHaveBeenCalledWith({ - severity: 'warn', - summary: enMessages.auth.login.emailPlaceholder, - life: 5000 - }) + expect(mockToastAdd).toHaveBeenCalledWith( + 'warning', + enMessages.auth.login.emailPlaceholder, + { duration: 5000 } + ) expect(focusSpy).toHaveBeenCalled() diff --git a/src/components/dialog/content/signin/SignInForm.vue b/src/components/dialog/content/signin/SignInForm.vue index 7aea3bde45e..38267b8a5ce 100644 --- a/src/components/dialog/content/signin/SignInForm.vue +++ b/src/components/dialog/content/signin/SignInForm.vue @@ -66,7 +66,6 @@ - - diff --git a/src/components/honeyToast/HoneyToast.stories.ts b/src/components/ui/toast/ToastPanel.stories.ts similarity index 86% rename from src/components/honeyToast/HoneyToast.stories.ts rename to src/components/ui/toast/ToastPanel.stories.ts index 12d2f3bb952..4083730fe22 100644 --- a/src/components/honeyToast/HoneyToast.stories.ts +++ b/src/components/ui/toast/ToastPanel.stories.ts @@ -6,7 +6,7 @@ import Button from '@/components/ui/button/Button.vue' import type { AssetDownload } from '@/stores/assetDownloadStore' import { cn } from '@comfyorg/tailwind-utils' -import HoneyToast from './HoneyToast.vue' +import ToastPanel from './ToastPanel.vue' function createMockJob(overrides: Partial = {}): AssetDownload { return { @@ -22,15 +22,16 @@ function createMockJob(overrides: Partial = {}): AssetDownload { } } -const meta: Meta = { - title: 'Toast/HoneyToast', - component: HoneyToast, +const meta: Meta = { + title: 'Components/Toast/ToastPanel', + component: ToastPanel, parameters: { layout: 'fullscreen' }, decorators: [ () => ({ - template: '
' + template: + '
' }) ] } @@ -40,7 +41,7 @@ type Story = StoryObj export const Default: Story = { render: () => ({ - components: { HoneyToast, Button, ProgressToastItem }, + components: { ToastPanel, Button, ProgressToastItem }, setup() { const isExpanded = ref(false) const jobs = [ @@ -65,7 +66,7 @@ export const Default: Story = { return { isExpanded, cn, jobs } }, template: ` - + - + ` }) } export const Expanded: Story = { render: () => ({ - components: { HoneyToast, Button, ProgressToastItem }, + components: { ToastPanel, Button, ProgressToastItem }, setup() { const isExpanded = ref(true) const jobs = [ @@ -125,7 +126,7 @@ export const Expanded: Story = { return { isExpanded, cn, jobs } }, template: ` - + - + ` }) } export const Completed: Story = { render: () => ({ - components: { HoneyToast, Button, ProgressToastItem }, + components: { ToastPanel, Button, ProgressToastItem }, setup() { const isExpanded = ref(false) const jobs = [ @@ -184,7 +185,7 @@ export const Completed: Story = { return { isExpanded, cn, jobs } }, template: ` - + - + ` }) } export const WithError: Story = { render: () => ({ - components: { HoneyToast, Button, ProgressToastItem }, + components: { ToastPanel, Button, ProgressToastItem }, setup() { const isExpanded = ref(true) const jobs = [ @@ -239,7 +240,7 @@ export const WithError: Story = { return { isExpanded, cn, jobs } }, template: ` - + - - ` - }) -} - -export const Hidden: Story = { - render: () => ({ - components: { HoneyToast }, - template: ` -
-

HoneyToast is hidden when visible=false. Nothing appears at the bottom.

- - - - - -
+ ` }) } diff --git a/src/components/ui/toast/ToastPanel.test.ts b/src/components/ui/toast/ToastPanel.test.ts new file mode 100644 index 00000000000..72da6c59d46 --- /dev/null +++ b/src/components/ui/toast/ToastPanel.test.ts @@ -0,0 +1,43 @@ +import { render, screen } from '@testing-library/vue' +import userEvent from '@testing-library/user-event' +import { describe, expect, it } from 'vitest' +import { defineComponent, ref } from 'vue' + +import ToastPanel from './ToastPanel.vue' + +const PanelWithToggle = defineComponent({ + components: { ToastPanel }, + setup() { + return { expanded: ref(false) } + }, + template: ` + + + + + ` +}) + +describe('ToastPanel', () => { + it('announces politely and starts collapsed', () => { + render(PanelWithToggle) + + expect(screen.getByRole('status')).toHaveAttribute('aria-live', 'polite') + expect(screen.getByTestId('content')).toHaveTextContent('collapsed') + }) + + it('expands and collapses from the footer toggle', async () => { + const user = userEvent.setup() + render(PanelWithToggle) + + await user.click(screen.getByRole('button', { name: 'Expand' })) + expect(screen.getByTestId('content')).toHaveTextContent('expanded') + + await user.click(screen.getByRole('button', { name: 'Collapse' })) + expect(screen.getByTestId('content')).toHaveTextContent('collapsed') + }) +}) diff --git a/src/components/ui/toast/ToastPanel.vue b/src/components/ui/toast/ToastPanel.vue new file mode 100644 index 00000000000..1794f1ef965 --- /dev/null +++ b/src/components/ui/toast/ToastPanel.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/components/ui/toast/Toaster.test.ts b/src/components/ui/toast/Toaster.test.ts index 6708e73aa5e..ba640a7030b 100644 --- a/src/components/ui/toast/Toaster.test.ts +++ b/src/components/ui/toast/Toaster.test.ts @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/vue' +import { render, screen, within } from '@testing-library/vue' import userEvent from '@testing-library/user-event' import { describe, expect, it, vi } from 'vitest' import { nextTick } from 'vue' @@ -125,4 +125,23 @@ describe('Toaster', () => { expect(screen.queryByText('Check settings')).not.toBeInTheDocument() }) + + it('renders docked toasts outside the notification stack', async () => { + renderToaster() + + useToast().custom( + { template: '
Downloading models
' }, + {}, + { placement: 'dock' } + ) + await nextTick() + + expect(screen.getByText('Downloading models')).toBeInTheDocument() + expect( + within(screen.getByTestId('toast-viewport')).queryByText( + 'Downloading models' + ) + ).not.toBeInTheDocument() + expect(screen.queryByTestId('toast')).not.toBeInTheDocument() + }) }) diff --git a/src/components/ui/toast/Toaster.vue b/src/components/ui/toast/Toaster.vue index 54d79fcccd0..1ed990074fe 100644 --- a/src/components/ui/toast/Toaster.vue +++ b/src/components/ui/toast/Toaster.vue @@ -4,6 +4,7 @@ import { computed } from 'vue' import { cn } from '@comfyorg/tailwind-utils' +import { vRekaZIndex } from '@/components/dialog/vRekaZIndex' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import ToastClose from './ToastClose.vue' @@ -12,7 +13,7 @@ import ToastProvider from './ToastProvider.vue' import ToastRoot from './ToastRoot.vue' import ToastTitle from './ToastTitle.vue' import ToastViewport from './ToastViewport.vue' -import { useToast } from './toastStore' +import { isDocked, useToast } from './toastStore' import type { ToastId } from './toastStore' const toast = useToast() @@ -20,7 +21,12 @@ const { toasts } = storeToRefs(toast) const { isPickingNodes: agentNodeSelectionActive } = storeToRefs( useCanvasStore() ) -const latestToastId = computed(() => toasts.value.at(-1)?.id) +const stackedToasts = computed(() => + toasts.value.filter((message) => !isDocked(message)) +) +const dockedToasts = computed(() => toasts.value.filter(isDocked)) +const latestToastId = computed(() => stackedToasts.value.at(-1)?.id) +const latestDockedToastId = computed(() => dockedToasts.value.at(-1)?.id) let escapeToastId: ToastId | undefined function preserveToastOnEscape(id: ToastId) { @@ -48,7 +54,7 @@ const icons = { diff --git a/src/components/ui/toast/toastStore.test.ts b/src/components/ui/toast/toastStore.test.ts index 91b6566dfc5..886ca65ac6d 100644 --- a/src/components/ui/toast/toastStore.test.ts +++ b/src/components/ui/toast/toastStore.test.ts @@ -71,4 +71,17 @@ describe('useToast', () => { expect.objectContaining({ kind: 'warning', title: 'Missing sample' }) ]) }) + + it('keeps docked toasts when dismissing all notifications', () => { + const toast = useToast() + const panel = { template: '
Downloads
' } + const dockedId = toast.custom(panel, {}, { placement: 'dock' }) + toast.info('Saved') + + toast.dismissAll() + + expect(toast.toasts).toEqual([ + expect.objectContaining({ id: dockedId, placement: 'dock' }) + ]) + }) }) diff --git a/src/components/ui/toast/toastStore.ts b/src/components/ui/toast/toastStore.ts index a3e62fbded5..7efb3f58518 100644 --- a/src/components/ui/toast/toastStore.ts +++ b/src/components/ui/toast/toastStore.ts @@ -15,10 +15,13 @@ export interface ToastOptions { closable?: boolean } +type ToastPlacement = 'stack' | 'dock' + interface CustomToastOptions { duration?: number closable?: boolean role?: ToastRole + placement?: ToastPlacement } interface ToastBase { @@ -38,12 +41,19 @@ interface CustomToast extends ToastBase { kind: 'custom' component: Component props?: Record + placement: ToastPlacement } type Toast = StandardToast | CustomToast const PERSISTENT = Number.POSITIVE_INFINITY +export function isDocked( + toast: Toast +): toast is CustomToast & { placement: 'dock' } { + return toast.kind === 'custom' && toast.placement === 'dock' +} + export const useToast = defineStore('toast', () => { const agentNodeSelectionStore = useCanvasStore() const toasts = ref([]) @@ -112,7 +122,8 @@ export const useToast = defineStore('toast', () => { props, duration: options.duration ?? PERSISTENT, closable: options.closable ?? true, - role: options.role ?? 'status' + role: options.role ?? 'status', + placement: options.placement ?? 'stack' }) return id } @@ -123,8 +134,8 @@ export const useToast = defineStore('toast', () => { } function dismissAll() { - toasts.value = [] - queuedToasts.value = [] + toasts.value = toasts.value.filter(isDocked) + queuedToasts.value = queuedToasts.value.filter(isDocked) } return { diff --git a/src/components/ui/toast/useDockedToast.test.ts b/src/components/ui/toast/useDockedToast.test.ts new file mode 100644 index 00000000000..608f25019fd --- /dev/null +++ b/src/components/ui/toast/useDockedToast.test.ts @@ -0,0 +1,35 @@ +import { describe, expect, it } from 'vitest' +import { effectScope, nextTick, ref } from 'vue' + +import { useDockedToast } from './useDockedToast' +import { useToast } from './toastStore' + +const panel = { template: '
Downloads
' } + +describe('useDockedToast', () => { + it('docks the panel only while its owner reports work', async () => { + const visible = ref(false) + effectScope().run(() => useDockedToast(visible, panel)) + expect(useToast().toasts).toEqual([]) + + visible.value = true + await nextTick() + expect(useToast().toasts).toEqual([ + expect.objectContaining({ kind: 'custom', placement: 'dock' }) + ]) + + visible.value = false + await nextTick() + expect(useToast().toasts).toEqual([]) + }) + + it('removes the panel when its owner is disposed', () => { + const scope = effectScope() + scope.run(() => useDockedToast(() => true, panel)) + expect(useToast().toasts).toHaveLength(1) + + scope.stop() + + expect(useToast().toasts).toEqual([]) + }) +}) diff --git a/src/components/ui/toast/useDockedToast.ts b/src/components/ui/toast/useDockedToast.ts new file mode 100644 index 00000000000..d647821bcef --- /dev/null +++ b/src/components/ui/toast/useDockedToast.ts @@ -0,0 +1,29 @@ +import { onScopeDispose, toValue, watch } from 'vue' +import type { Component, MaybeRefOrGetter } from 'vue' + +import { useToast } from './toastStore' +import type { ToastId } from './toastStore' + +export function useDockedToast( + visible: MaybeRefOrGetter, + panel: Component +) { + const toast = useToast() + let id: ToastId | undefined + + function undock() { + if (id === undefined) return + toast.dismiss(id) + id = undefined + } + + watch( + () => toValue(visible), + (shown) => { + if (!shown) return undock() + id ??= toast.custom(panel, {}, { placement: 'dock' }) + }, + { immediate: true } + ) + onScopeDispose(undock) +} diff --git a/src/composables/useModalLiftedZIndex.test.ts b/src/composables/useModalLiftedZIndex.test.ts index 6e7f802ab99..58bde9cd351 100644 --- a/src/composables/useModalLiftedZIndex.test.ts +++ b/src/composables/useModalLiftedZIndex.test.ts @@ -1,18 +1,11 @@ import { ZIndex } from '@primeuix/utils/zindex' import { afterEach, describe, expect, it } from 'vitest' -import { createApp, ref } from 'vue' -import type { Ref } from 'vue' +import { ref } from 'vue' -import { overlayZIndexKey, useModalLiftedZIndex } from './useModalLiftedZIndex' +import { useModalLiftedZIndex } from './useModalLiftedZIndex' const registered: HTMLElement[] = [] -function setupStyle(open: Ref, parentZIndex = 0) { - const app = createApp({}) - app.provide(overlayZIndexKey, parentZIndex) - return app.runWithContext(() => useModalLiftedZIndex(open)) -} - function registerDialog() { const el = document.createElement('div') ZIndex.set('modal', el, 1700) @@ -31,7 +24,7 @@ afterEach(() => { describe('useModalLiftedZIndex', () => { it('lifts past the current top of the modal stack', () => { const dialogZIndex = registerDialog() - const style = setupStyle(ref(true)) + const style = useModalLiftedZIndex(ref(true)) expect(style.value).toEqual({ zIndex: dialogZIndex + 1 }) }) @@ -47,7 +40,7 @@ describe('useModalLiftedZIndex', () => { const dialogZIndex = registerDialog() expect(dialogZIndex).toBeGreaterThan(3000) - const style = setupStyle(ref(true)) + const style = useModalLiftedZIndex(ref(true)) expect(style.value).toEqual({ zIndex: dialogZIndex + 1 }) }) @@ -55,7 +48,7 @@ describe('useModalLiftedZIndex', () => { it('re-reads the stack on every open rather than caching the first read', () => { registerDialog() const open = ref(true) - const style = setupStyle(open) + const style = useModalLiftedZIndex(open) expect(style.value).toBeDefined() open.value = false @@ -64,11 +57,4 @@ describe('useModalLiftedZIndex', () => { expect(style.value).toEqual({ zIndex: laterDialogZIndex + 1 }) }) - - it('lifts past its owning toast even with a lower dialog open', () => { - registerDialog() - const style = setupStyle(ref(true), 9999) - - expect(style.value).toEqual({ zIndex: 10000 }) - }) }) diff --git a/src/composables/useModalLiftedZIndex.ts b/src/composables/useModalLiftedZIndex.ts index a26c9c8d454..17b370482ab 100644 --- a/src/composables/useModalLiftedZIndex.ts +++ b/src/composables/useModalLiftedZIndex.ts @@ -1,8 +1,6 @@ import { ZIndex } from '@primeuix/utils/zindex' -import type { InjectionKey, Ref } from 'vue' -import { computed, inject } from 'vue' - -export const overlayZIndexKey: InjectionKey = Symbol('overlayZIndex') +import type { Ref } from 'vue' +import { computed } from 'vue' // Shared base for @primeuix's auto-incrementing 'modal' z-index counter. const MODAL_BASE_Z_INDEX = 1700 @@ -15,10 +13,9 @@ const MODAL_BASE_Z_INDEX = 1700 * dialog so the content isn't hidden behind the dialog or its scrim. */ export function useModalLiftedZIndex(open: Ref) { - const parentZIndex = inject(overlayZIndexKey, 0) return computed(() => { if (!open.value) return undefined - const topZIndex = Math.max(ZIndex.getCurrent('modal'), parentZIndex) + const topZIndex = ZIndex.getCurrent('modal') return topZIndex >= MODAL_BASE_Z_INDEX ? { zIndex: topZIndex + 1 } : undefined diff --git a/src/platform/assets/components/AssetExportProgressDialog.vue b/src/platform/assets/components/AssetExportProgressDialog.vue index 4e7b64ef48c..e61d83b3acb 100644 --- a/src/platform/assets/components/AssetExportProgressDialog.vue +++ b/src/platform/assets/components/AssetExportProgressDialog.vue @@ -3,7 +3,7 @@ import { computed, ref } from 'vue' import { useI18n } from 'vue-i18n' import Loader from '@/components/loader/Loader.vue' -import HoneyToast from '@/components/honeyToast/HoneyToast.vue' +import ToastPanel from '@/components/ui/toast/ToastPanel.vue' import Button from '@/components/ui/button/Button.vue' import type { AssetExport } from '@/stores/assetExportStore' import { useAssetExportStore } from '@/stores/assetExportStore' @@ -12,7 +12,6 @@ import { cn } from '@comfyorg/tailwind-utils' const { t } = useI18n() const assetExportStore = useAssetExportStore() -const visible = computed(() => assetExportStore.hasExports) const isExpanded = ref(false) const exportJobs = computed(() => assetExportStore.exportList) @@ -72,7 +71,7 @@ function closeDialog() { diff --git a/src/platform/assets/components/ModelImportProgressDialog.test.ts b/src/platform/assets/components/ModelImportProgressDialog.test.ts index 5336a08f8de..ac2308c9fd1 100644 --- a/src/platform/assets/components/ModelImportProgressDialog.test.ts +++ b/src/platform/assets/components/ModelImportProgressDialog.test.ts @@ -81,7 +81,6 @@ describe('ModelImportProgressDialog cancellation', () => { await user.click(screen.getByRole('button', { name: 'Close' })) await waitFor(() => expect(store.hasDownloads).toBe(false)) - expect(screen.queryByRole('status')).toBeNull() }) it('restores the close control once a cancellation settles', async () => { @@ -108,7 +107,7 @@ describe('ModelImportProgressDialog cancellation', () => { await user.click(screen.getByRole('button', { name: 'Close' })) - expect(screen.queryByRole('status')).toBeNull() + expect(store.hasDownloads).toBe(false) }) it('dismisses a failed download while reconciliation continues', async () => { @@ -120,6 +119,6 @@ describe('ModelImportProgressDialog cancellation', () => { await user.click(screen.getByRole('button', { name: 'Close' })) - expect(screen.queryByRole('status')).toBeNull() + expect(store.hasDownloads).toBe(false) }) }) diff --git a/src/platform/assets/components/ModelImportProgressDialog.vue b/src/platform/assets/components/ModelImportProgressDialog.vue index 770e0420f9d..d3202d42680 100644 --- a/src/platform/assets/components/ModelImportProgressDialog.vue +++ b/src/platform/assets/components/ModelImportProgressDialog.vue @@ -5,7 +5,7 @@ import { computed, ref } from 'vue' import { useI18n } from 'vue-i18n' import Loader from '@/components/loader/Loader.vue' -import HoneyToast from '@/components/honeyToast/HoneyToast.vue' +import ToastPanel from '@/components/ui/toast/ToastPanel.vue' import ProgressToastItem from '@/components/toast/ProgressToastItem.vue' import Button from '@/components/ui/button/Button.vue' import { useErrorHandling } from '@/composables/useErrorHandling' @@ -21,8 +21,6 @@ const { t } = useI18n() const assetDownloadStore = useAssetDownloadStore() const { toastErrorHandler } = useErrorHandling() -const visible = computed(() => assetDownloadStore.hasDownloads) - const isExpanded = ref(false) const activeFilter = ref<'all' | 'completed' | 'failed'>('all') const filterPopoverRef = ref | null>(null) @@ -111,7 +109,7 @@ async function cancelDownload(taskId: TaskId) { diff --git a/src/platform/assets/composables/useAssetProgressToasts.ts b/src/platform/assets/composables/useAssetProgressToasts.ts new file mode 100644 index 00000000000..d4e8ab8f929 --- /dev/null +++ b/src/platform/assets/composables/useAssetProgressToasts.ts @@ -0,0 +1,15 @@ +import { useDockedToast } from '@/components/ui/toast/useDockedToast' +import AssetExportProgressDialog from '@/platform/assets/components/AssetExportProgressDialog.vue' +import ModelImportProgressDialog from '@/platform/assets/components/ModelImportProgressDialog.vue' +import { useAssetDownloadStore } from '@/stores/assetDownloadStore' +import { useAssetExportStore } from '@/stores/assetExportStore' + +export function useAssetProgressToasts() { + const assetDownloadStore = useAssetDownloadStore() + const assetExportStore = useAssetExportStore() + useDockedToast( + () => assetDownloadStore.hasDownloads, + ModelImportProgressDialog + ) + useDockedToast(() => assetExportStore.hasExports, AssetExportProgressDialog) +} diff --git a/src/views/GraphView.test.ts b/src/views/GraphView.test.ts index e9e8468932f..eed7d83b719 100644 --- a/src/views/GraphView.test.ts +++ b/src/views/GraphView.test.ts @@ -187,10 +187,9 @@ vi.mock( import('@/components/builder/BuilderFooterToolbar.vue'), () => stubModule ) -vi.mock( - import('@/workbench/extensions/manager/components/ManagerProgressToast.vue'), - - () => stubModule +vi.mock( + import('@/workbench/extensions/manager/composables/useManagerProgressToast'), + () => ({ useManagerProgressToast: vi.fn() }) ) vi.mock( import('@/platform/cloud/notification/components/DesktopCloudNotificationController.vue'), diff --git a/src/views/GraphView.vue b/src/views/GraphView.vue index 9612a116185..a5c80c1313c 100644 --- a/src/views/GraphView.vue +++ b/src/views/GraphView.vue @@ -21,10 +21,7 @@
- - - @@ -71,9 +68,8 @@ import { SERVER_CONFIG_ITEMS } from '@/constants/serverConfig' import type { ServerConfig, ServerConfigValue } from '@/constants/serverConfig' import { setActiveLocale } from '@/i18n' import AssetBrowserModal from '@/platform/assets/components/AssetBrowserModal.vue' -import AssetExportProgressDialog from '@/platform/assets/components/AssetExportProgressDialog.vue' -import ModelImportProgressDialog from '@/platform/assets/components/ModelImportProgressDialog.vue' import { registerAssetBrowserModalComponent } from '@/platform/assets/composables/useAssetBrowserDialog' +import { useAssetProgressToasts } from '@/platform/assets/composables/useAssetProgressToasts' import DesktopCloudNotificationController from '@/platform/cloud/notification/components/DesktopCloudNotificationController.vue' import { isCloud, isDesktop } from '@/platform/distribution/types' import SettingDialog from '@/platform/settings/components/SettingDialog.vue' @@ -113,11 +109,13 @@ import BuilderFooterToolbar from '@/components/builder/BuilderFooterToolbar.vue' import BuilderMenu from '@/components/builder/BuilderMenu.vue' import BuilderToolbar from '@/components/builder/BuilderToolbar.vue' import LinearView from '@/views/LinearView.vue' -import ManagerProgressToast from '@/workbench/extensions/manager/components/ManagerProgressToast.vue' +import { useManagerProgressToast } from '@/workbench/extensions/manager/composables/useManagerProgressToast' setupAutoQueueHandler() useProgressFavicon() useBrowserTabTitle() +useAssetProgressToasts() +useManagerProgressToast() const settingStore = useSettingStore() const executionStore = useExecutionStore() diff --git a/src/workbench/extensions/manager/components/ManagerProgressToast.vue b/src/workbench/extensions/manager/components/ManagerProgressToast.vue index a088c171def..f2a59d48cc8 100644 --- a/src/workbench/extensions/manager/components/ManagerProgressToast.vue +++ b/src/workbench/extensions/manager/components/ManagerProgressToast.vue @@ -6,7 +6,7 @@ import { computed, onBeforeUnmount, onMounted, ref } from 'vue' import { useI18n } from 'vue-i18n' import DotSpinner from '@/components/common/DotSpinner.vue' -import HoneyToast from '@/components/honeyToast/HoneyToast.vue' +import ToastPanel from '@/components/ui/toast/ToastPanel.vue' import Button from '@/components/ui/button/Button.vue' import Tabs from '@/components/ui/tabs/Tabs.vue' import TabsContent from '@/components/ui/tabs/TabsContent.vue' @@ -40,8 +40,6 @@ const activeTabData = computed( () => tabs.value.find((tab) => tab.value === activeTab.value) ?? tabs.value[0] ) -const visible = computed(() => comfyManagerStore.taskLogs.length > 0) - const isInProgress = computed( () => comfyManagerStore.isProcessingTasks || isRestarting.value ) @@ -162,7 +160,7 @@ onBeforeUnmount(() => { diff --git a/src/workbench/extensions/manager/composables/useManagerProgressToast.ts b/src/workbench/extensions/manager/composables/useManagerProgressToast.ts new file mode 100644 index 00000000000..64dd3028410 --- /dev/null +++ b/src/workbench/extensions/manager/composables/useManagerProgressToast.ts @@ -0,0 +1,11 @@ +import { useDockedToast } from '@/components/ui/toast/useDockedToast' +import ManagerProgressToast from '@/workbench/extensions/manager/components/ManagerProgressToast.vue' +import { useComfyManagerStore } from '@/workbench/extensions/manager/stores/comfyManagerStore' + +export function useManagerProgressToast() { + const comfyManagerStore = useComfyManagerStore() + useDockedToast( + () => comfyManagerStore.taskLogs.length > 0, + ManagerProgressToast + ) +} From 360279dcb3ed9c4b28d167b598bc706c63eae769 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Mon, 5 Oct 2026 07:54:35 +0000 Subject: [PATCH 10/71] fix: spin the SDK billing progress toast like the legacy rail Raise the SDK rail's processing toast as loading so both rails keep the spinner, keep the spinner static under reduced motion, and make the timeout negative assertion see two-argument error calls. Amp-Thread-ID: https://ampcode.com/threads/T-01a10ae8-fc3e-75a8-8da1-907005697afa --- src/components/ui/toast/Toaster.vue | 3 ++- src/platform/workspace/billing/sdk/billingSdkStore.test.ts | 4 ++-- src/platform/workspace/billing/sdk/billingSdkStore.ts | 3 ++- src/platform/workspace/stores/billingOperationStore.test.ts | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/ui/toast/Toaster.vue b/src/components/ui/toast/Toaster.vue index 1ed990074fe..de974665f23 100644 --- a/src/components/ui/toast/Toaster.vue +++ b/src/components/ui/toast/Toaster.vue @@ -47,7 +47,8 @@ const icons = { error: 'icon-[lucide--circle-x] text-destructive-background', info: 'icon-[lucide--info] text-primary-background', warning: 'icon-[lucide--triangle-alert] text-warning-background', - loading: 'icon-[lucide--loader-circle] animate-spin text-primary-background' + loading: + 'icon-[lucide--loader-circle] motion-safe:animate-spin text-primary-background' } as const diff --git a/src/platform/workspace/billing/sdk/billingSdkStore.test.ts b/src/platform/workspace/billing/sdk/billingSdkStore.test.ts index e498e6f887c..4b037c57b51 100644 --- a/src/platform/workspace/billing/sdk/billingSdkStore.test.ts +++ b/src/platform/workspace/billing/sdk/billingSdkStore.test.ts @@ -191,7 +191,7 @@ describe('useBillingSdkStore', () => { harness.publish(pendingTopup()) expect(toast.toasts).toEqual([ expect.objectContaining({ - kind: 'info', + kind: 'loading', title: 'Processing payment — adding credits...', duration: Number.POSITIVE_INFINITY }) @@ -217,7 +217,7 @@ describe('useBillingSdkStore', () => { harness.publish(pendingSubscription()) expect(toast.toasts).toEqual([ expect.objectContaining({ - kind: 'info', + kind: 'loading', title: 'Processing payment — setting up your workspace...' }) ]) diff --git a/src/platform/workspace/billing/sdk/billingSdkStore.ts b/src/platform/workspace/billing/sdk/billingSdkStore.ts index 0c3ef206822..21f5d9640e9 100644 --- a/src/platform/workspace/billing/sdk/billingSdkStore.ts +++ b/src/platform/workspace/billing/sdk/billingSdkStore.ts @@ -316,7 +316,8 @@ export const useBillingSdkStore = defineStore('billingSdk', () => { clearProgressToast(state.id) if (progress === undefined) return const title = t(PROGRESS_SUMMARY[kind][progress]) - const id = progress === 'action' ? toast.warning(title) : toast.info(title) + const id = + progress === 'action' ? toast.warning(title) : toast.loading(title) progressToasts.set(state.id, { kind: progress, id }) } diff --git a/src/platform/workspace/stores/billingOperationStore.test.ts b/src/platform/workspace/stores/billingOperationStore.test.ts index c17b03e2fc7..5cbdba2ddfa 100644 --- a/src/platform/workspace/stores/billingOperationStore.test.ts +++ b/src/platform/workspace/stores/billingOperationStore.test.ts @@ -3361,9 +3361,9 @@ describe('billingOperationStore', () => { actionUrl, authenticationRequiredSeen: true }) - expect(vi.mocked(useToast().error)).not.toHaveBeenCalledWith( - 'billingOperation.topupTimeout' - ) + expect( + vi.mocked(useToast().error).mock.calls.map(([title]) => title) + ).not.toContain('billingOperation.topupTimeout') }) }) From 53fd457d9a9e68215d7ab701cf29ddb5f7c26c19 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Mon, 5 Oct 2026 07:57:44 +0000 Subject: [PATCH 11/71] test: assert toasts through one contract Drop the comfyManagerStore test adapter that rebuilt PrimeVue messages, share the error-toast selector between ToastHelper and the error-surface recorder, and close toasts in the splitter spec through ToastHelper. Amp-Thread-ID: https://ampcode.com/threads/T-01a10ae8-fc3e-75a8-8da1-907005697afa --- browser_tests/fixtures/helpers/ToastHelper.ts | 16 +++-- browser_tests/fixtures/utils/errorSurfaces.ts | 7 +- .../sidebar/sidebarSplitterWidth.spec.ts | 11 +-- .../manager/stores/comfyManagerStore.test.ts | 72 ++++++++----------- 4 files changed, 45 insertions(+), 61 deletions(-) diff --git a/browser_tests/fixtures/helpers/ToastHelper.ts b/browser_tests/fixtures/helpers/ToastHelper.ts index bb85006c950..a5e4ed6eedf 100644 --- a/browser_tests/fixtures/helpers/ToastHelper.ts +++ b/browser_tests/fixtures/helpers/ToastHelper.ts @@ -1,6 +1,12 @@ import { expect } from '@playwright/test' import type { Locator, Page } from '@playwright/test' +type ToastKind = 'error' | 'success' | 'warning' | 'loading' + +export function toastSelector(kind: ToastKind): string { + return `[data-testid="toast"][data-toast-kind="${kind}"]` +} + export class ToastHelper { public readonly visibleToasts: Locator public readonly toastErrors: Locator @@ -12,12 +18,10 @@ export class ToastHelper { constructor(private readonly page: Page) { const toasts = page.getByTestId('toast') this.visibleToasts = toasts.filter({ visible: true }) - this.toastErrors = toasts.and(page.locator('[data-toast-kind="error"]')) - this.toastSuccesses = toasts.and( - page.locator('[data-toast-kind="success"]') - ) - this.toastWarnings = toasts.and(page.locator('[data-toast-kind="warning"]')) - this.toastLoadings = toasts.and(page.locator('[data-toast-kind="loading"]')) + this.toastErrors = page.locator(toastSelector('error')) + this.toastSuccesses = page.locator(toastSelector('success')) + this.toastWarnings = page.locator(toastSelector('warning')) + this.toastLoadings = page.locator(toastSelector('loading')) this.alerts = toasts.and(page.getByRole('alert')) } diff --git a/browser_tests/fixtures/utils/errorSurfaces.ts b/browser_tests/fixtures/utils/errorSurfaces.ts index ea2da9d73e7..61b9b2b8195 100644 --- a/browser_tests/fixtures/utils/errorSurfaces.ts +++ b/browser_tests/fixtures/utils/errorSurfaces.ts @@ -1,6 +1,7 @@ import type { Locator, Page } from '@playwright/test' import { expect } from '@playwright/test' +import { toastSelector } from '@e2e/fixtures/helpers/ToastHelper' import { TestIds } from '@e2e/fixtures/selectors' interface VisibleError { @@ -27,7 +28,7 @@ const visibleErrorSurfaceSelectors = [ { surface: 'nodeRenderErrors', selector: '.node-error' }, { surface: 'errorToasts', - selector: '[data-testid="toast"][data-toast-kind="error"]' + selector: toastSelector('error') } ] @@ -95,9 +96,7 @@ export function errorSurfaces(page: Page): Record { errorOverlay: page.getByTestId(TestIds.dialogs.errorOverlay), errorDialog: page.getByTestId(TestIds.dialogs.errorDialog), nodeRenderErrors: page.locator('.node-error'), - errorToasts: page - .getByTestId('toast') - .and(page.locator('[data-toast-kind="error"]')) + errorToasts: page.locator(toastSelector('error')) } } diff --git a/browser_tests/tests/sidebar/sidebarSplitterWidth.spec.ts b/browser_tests/tests/sidebar/sidebarSplitterWidth.spec.ts index 14da11aa65c..28b4dfe4532 100644 --- a/browser_tests/tests/sidebar/sidebarSplitterWidth.spec.ts +++ b/browser_tests/tests/sidebar/sidebarSplitterWidth.spec.ts @@ -16,21 +16,12 @@ test.describe('Sidebar splitter width independence', () => { } }) - async function dismissToasts(comfyPage: ComfyPage) { - const buttons = await comfyPage.page.getByTestId('toast-close').all() - for (const btn of buttons) { - await btn.click({ timeout: 2000 }).catch(() => {}) - } - // Brief wait for animations - await comfyPage.nextFrame() - } - async function openSidebarAt( comfyPage: ComfyPage, location: 'left' | 'right' ) { await comfyPage.settings.setSetting('Comfy.Sidebar.Location', location) - await dismissToasts(comfyPage) + await comfyPage.toast.closeToasts() await comfyPage.menu.nodeLibraryTab.open() } diff --git a/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts b/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts index 1e3591b9b0e..89bbd233dbe 100644 --- a/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts +++ b/src/workbench/extensions/manager/stores/comfyManagerStore.test.ts @@ -28,21 +28,6 @@ type InstalledPacksResponse = type ManagerPackInstalled = ManagerComponents['schemas']['ManagerPackInstalled'] type TaskExecutionStatus = ManagerComponents['schemas']['TaskExecutionStatus'] -function legacyToastMessages() { - return useToast().toasts.flatMap((toast) => - toast.kind === 'custom' - ? [] - : [ - { - severity: toast.kind === 'warning' ? 'warn' : toast.kind, - summary: toast.title, - ...(toast.description ? { detail: toast.description } : {}), - ...(Number.isFinite(toast.duration) ? { life: toast.duration } : {}) - } - ] - ) -} - vi.mock( import('@/workbench/extensions/manager/services/comfyManagerService'), @@ -150,8 +135,8 @@ describe('useComfyManagerStore', () => { expectedInstalled: false, expectedToasts: [ expect.objectContaining({ - severity: 'error', - detail: + kind: 'error', + description: 'This action is not allowed by the current security configuration. See the terminal for details.' }) ] @@ -165,8 +150,8 @@ describe('useComfyManagerStore', () => { expectedInstalled: false, expectedToasts: [ expect.objectContaining({ - severity: 'error', - detail: 'Download failed' + kind: 'error', + description: 'Download failed' }) ] }, @@ -179,8 +164,8 @@ describe('useComfyManagerStore', () => { expectedInstalled: true, expectedToasts: [ expect.objectContaining({ - severity: 'error', - detail: 'Version installation denied' + kind: 'error', + description: 'Version installation denied' }) ] }, @@ -253,10 +238,10 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalled('test-pack')).toBe(expectedInstalled) expect(store.installedPacks).toEqual(installed) expect(store.isProcessingTasks).toBe(false) - expect(legacyToastMessages()).toEqual(expectedToasts) + expect(useToast().toasts).toEqual(expectedToasts) api.dispatchCustomEvent('cm-task-completed', detail) - expect(legacyToastMessages()).toEqual(expectedToasts) + expect(useToast().toasts).toEqual(expectedToasts) } ) @@ -280,10 +265,10 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalling('test-pack')).toBe(false) expect(store.isPackInstalled('test-pack')).toBe(false) expect(store.isProcessingTasks).toBe(false) - expect(legacyToastMessages()).toEqual([ + expect(useToast().toasts).toEqual([ expect.objectContaining({ - severity: 'error', - detail: 'Request rejected. Check the terminal.' + kind: 'error', + description: 'Request rejected. Check the terminal.' }) ]) expect(mockManagerService.startQueue).not.toHaveBeenCalled() @@ -312,8 +297,10 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalling('test-pack')).toBe(true) expect(store.isProcessingTasks).toBe(true) expect(store.failedTasksIds).toEqual([]) - expect(legacyToastMessages()).toEqual([ - expect.objectContaining({ detail: 'Queue start temporarily unavailable' }) + expect(useToast().toasts).toEqual([ + expect.objectContaining({ + description: 'Queue start temporarily unavailable' + }) ]) await store.installPack.call(request) @@ -357,8 +344,8 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalling('test-pack')).toBe(false) expect(store.isPackInstalled('test-pack')).toBe(false) expect(store.isProcessingTasks).toBe(false) - expect(legacyToastMessages().at(-1)).toEqual( - expect.objectContaining({ severity: 'error', detail: result }) + expect(useToast().toasts.at(-1)).toEqual( + expect.objectContaining({ kind: 'error', description: result }) ) }) @@ -389,8 +376,11 @@ describe('useComfyManagerStore', () => { expect(store.isPackInstalling('pending-pack')).toBe(true) expect(store.isPackInstalling('rejected-pack')).toBe(false) expect(store.isProcessingTasks).toBe(true) - expect(legacyToastMessages()).toEqual([ - expect.objectContaining({ severity: 'error', detail: 'Request rejected' }) + expect(useToast().toasts).toEqual([ + expect.objectContaining({ + kind: 'error', + description: 'Request rejected' + }) ]) }) @@ -633,10 +623,10 @@ describe('useComfyManagerStore', () => { api.dispatchCustomEvent('cm-task-completed', detail) await nextTick() api.dispatchCustomEvent('cm-task-completed', detail) - expect(legacyToastMessages()).toEqual([ + expect(useToast().toasts).toEqual([ expect.objectContaining({ - severity: 'error', - detail: 'Operation failed' + kind: 'error', + description: 'Operation failed' }) ]) expect(store.failedTasksLogs.map((log) => log.taskId)).toEqual([ @@ -713,7 +703,7 @@ describe('useComfyManagerStore', () => { api.dispatchCustomEvent('cm-task-completed', detail) await nextTick() api.dispatchCustomEvent('cm-task-completed', detail) - expect(legacyToastMessages()).toHaveLength(toastCount) + expect(useToast().toasts).toHaveLength(toastCount) } ) @@ -758,7 +748,7 @@ describe('useComfyManagerStore', () => { expect(store.isTaskInProgress(taskId)).toBe(false) expect(store.succeededTasksLogs.map((log) => log.taskId)).toEqual([taskId]) expect(store.failedTasksIds).toEqual([]) - expect(legacyToastMessages()).toEqual([]) + expect(useToast().toasts).toEqual([]) await store.enablePack({ id: 'other-pack', version: '1.0.0' }) expect(store.isProcessingTasks).toBe(true) @@ -896,7 +886,7 @@ describe('useComfyManagerStore', () => { newerResult: null, newerError: 'Latest startup failed', expectedToasts: [ - expect.objectContaining({ detail: 'Latest startup failed' }) + expect.objectContaining({ description: 'Latest startup failed' }) ] }, { @@ -906,7 +896,7 @@ describe('useComfyManagerStore', () => { newerResult: null, newerError: 'Latest startup failed', expectedToasts: [ - expect.objectContaining({ detail: 'Latest startup failed' }) + expect.objectContaining({ description: 'Latest startup failed' }) ] } ])( @@ -947,7 +937,7 @@ describe('useComfyManagerStore', () => { expect(store.isProcessingTasks).toBe(true) expect(store.queueError).toBe(newerError) - expect(legacyToastMessages()).toEqual(expectedToasts) + expect(useToast().toasts).toEqual(expectedToasts) } ) @@ -978,7 +968,7 @@ describe('useComfyManagerStore', () => { expect(store.isProcessingTasks).toBe(true) expect(store.queueError).toBeNull() - expect(legacyToastMessages()).toEqual([]) + expect(useToast().toasts).toEqual([]) }) it('keeps a newer completion event when an earlier queue status request finishes', async () => { From 3538b788f435c9b6af7aa6acf0e2d5ba64dbe844 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Mon, 5 Oct 2026 08:01:16 +0000 Subject: [PATCH 12/71] test: locate toasts through ToastHelper in every spec Amp-Thread-ID: https://ampcode.com/threads/T-01a10ae8-fc3e-75a8-8da1-907005697afa --- .../fixtures/components/SidebarTab.ts | 10 ++------- .../tests/cloudWorkspaceDeepLink.spec.ts | 2 +- .../tests/dialogs/enterpriseTierCloud.spec.ts | 12 +++++------ .../tests/dialogs/memberRoleChange.spec.ts | 9 ++++---- .../dialogs/pricingTableDeepLink.spec.ts | 7 +++---- .../dialogs/topUpNoPaymentMethod.spec.ts | 8 +++---- .../tests/dialogs/topUpSdkRail.spec.ts | 5 ++--- browser_tests/tests/sidebar/assets.spec.ts | 5 +---- browser_tests/tests/templates.spec.ts | 2 +- .../tests/versionMismatchWarnings.spec.ts | 21 ++++++------------- src/components/ui/toast/index.ts | 3 --- 11 files changed, 31 insertions(+), 53 deletions(-) delete mode 100644 src/components/ui/toast/index.ts diff --git a/browser_tests/fixtures/components/SidebarTab.ts b/browser_tests/fixtures/components/SidebarTab.ts index 95ebc127fb6..56f58a4c5d8 100644 --- a/browser_tests/fixtures/components/SidebarTab.ts +++ b/browser_tests/fixtures/components/SidebarTab.ts @@ -4,6 +4,7 @@ import { expect } from '@playwright/test' import type { ComfyMouse } from '@e2e/fixtures/ComfyMouse' import type { WorkspaceStore } from '@e2e/types/globals' import { TestIds } from '@e2e/fixtures/selectors' +import { ToastHelper } from '@e2e/fixtures/helpers/ToastHelper' export class SidebarTab { public readonly tabButton: Locator @@ -495,14 +496,7 @@ export class AssetsSidebarTab extends SidebarTab { /** Dismiss all visible toast notifications by clicking their close buttons. */ async dismissToasts() { - const closeButtons = this.page.getByTestId('toast-close') - for (const btn of await closeButtons.all()) { - await btn.click().catch(() => {}) - } - // Wait for all toast elements to fully animate out and detach from DOM - await expect(this.page.getByTestId('toast')) - .toHaveCount(0) - .catch(() => {}) + await new ToastHelper(this.page).closeToasts() } async switchToImported() { diff --git a/browser_tests/tests/cloudWorkspaceDeepLink.spec.ts b/browser_tests/tests/cloudWorkspaceDeepLink.spec.ts index db4e67771c8..9920ece44a3 100644 --- a/browser_tests/tests/cloudWorkspaceDeepLink.spec.ts +++ b/browser_tests/tests/cloudWorkspaceDeepLink.spec.ts @@ -90,7 +90,7 @@ test.describe('Cloud workspace deep link', { tag: '@cloud' }, () => { test('is unchanged with no workspace param', async ({ comfyPage }) => { const page = comfyPage.page - await expect(page.getByTestId('toast')).toHaveCount(0) + await expect(comfyPage.toast.visibleToasts).toHaveCount(0) await page.getByRole('button', { name: 'Current user' }).click() await expect(page.getByTestId('workspace-switcher-trigger')).toContainText( PERSONAL_WORKSPACE_NAME diff --git a/browser_tests/tests/dialogs/enterpriseTierCloud.spec.ts b/browser_tests/tests/dialogs/enterpriseTierCloud.spec.ts index 53d2d59284f..afd76e1fe7c 100644 --- a/browser_tests/tests/dialogs/enterpriseTierCloud.spec.ts +++ b/browser_tests/tests/dialogs/enterpriseTierCloud.spec.ts @@ -16,6 +16,7 @@ import { } from '@e2e/fixtures/data/cloudWorkspace' import { CloudWorkspaceMockHelper } from '@e2e/fixtures/helpers/CloudWorkspaceMockHelper' import { recordOpenedUrl } from '@e2e/fixtures/utils/recordOpenedUrl' +import { ToastHelper } from '@e2e/fixtures/helpers/ToastHelper' const APP_URL = process.env.PLAYWRIGHT_TEST_URL || 'http://localhost:8188' @@ -283,12 +284,11 @@ test.describe('Enterprise workspace billing', { tag: '@cloud' }, () => { await expect( page.getByRole('heading', { name: 'Choose a Plan' }) ).toHaveCount(0) - await expect( - page.getByTestId('toast').and(page.locator('[data-toast-kind="warning"]')) - ).toContainText('Plan inactive') - await expect( - page.getByTestId('toast').and(page.locator('[data-toast-kind="warning"]')) - ).toContainText('Contact your Comfy account manager to restore access.') + const warning = new ToastHelper(page).toastWarnings + await expect(warning).toContainText('Plan inactive') + await expect(warning).toContainText( + 'Contact your Comfy account manager to restore access.' + ) }) }) diff --git a/browser_tests/tests/dialogs/memberRoleChange.spec.ts b/browser_tests/tests/dialogs/memberRoleChange.spec.ts index b4d903b136c..9ced3dea070 100644 --- a/browser_tests/tests/dialogs/memberRoleChange.spec.ts +++ b/browser_tests/tests/dialogs/memberRoleChange.spec.ts @@ -13,6 +13,7 @@ import { } from '@e2e/fixtures/data/cloudWorkspace' import { CloudWorkspaceMockHelper } from '@e2e/fixtures/helpers/CloudWorkspaceMockHelper' import { workspace } from '@e2e/fixtures/utils/workspaceMocks' +import { ToastHelper } from '@e2e/fixtures/helpers/ToastHelper' // Drives a raw `page` (not the `comfyPage` fixture) so the cloud app boots // against fully mocked endpoints; `comfyPage` would try to reach the OSS @@ -191,9 +192,7 @@ test.describe('Member role change (Members tab)', { tag: '@cloud' }, () => { .click() await page.getByRole('button', { name: 'Make owner' }).click() - await expect( - page.getByTestId('toast').getByText('Role updated') - ).toBeVisible() + await expect(new ToastHelper(page).withText('Role updated')).toBeVisible() await expect(janeRow.getByText('Owner', { exact: true })).toBeVisible() await expect(emails).toHaveText([ CREATOR.email, @@ -269,7 +268,9 @@ test.describe('Member role change (Members tab)', { tag: '@cloud' }, () => { // US10 — error toast, dialog stays open, role unchanged. await expect( - page.getByTestId('toast').getByText('Failed to update role') + new ToastHelper(page).toastErrors.filter({ + hasText: 'Failed to update role' + }) ).toBeVisible() await expect( page.getByRole('heading', { name: 'Make Jane an owner?' }) diff --git a/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts b/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts index 59f99f68f11..4a0551978a1 100644 --- a/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts +++ b/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts @@ -1137,10 +1137,9 @@ test.describe( expect((await subscribeResponse).status()).toBe(200) expect(subscribeRequests).toHaveLength(1) - const blockedPopupToast = page - .getByTestId('toast') - .and(page.locator('[data-toast-kind="error"]')) - .filter({ hasText: 'Failed to change plan' }) + const blockedPopupToast = new ToastHelper(page).toastErrors.filter({ + hasText: 'Failed to change plan' + }) await expect(blockedPopupToast).toContainText( "Couldn't open the payment page — please try again" ) diff --git a/browser_tests/tests/dialogs/topUpNoPaymentMethod.spec.ts b/browser_tests/tests/dialogs/topUpNoPaymentMethod.spec.ts index 7987e46c658..04eb203a743 100644 --- a/browser_tests/tests/dialogs/topUpNoPaymentMethod.spec.ts +++ b/browser_tests/tests/dialogs/topUpNoPaymentMethod.spec.ts @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test' import { TopUpCreditsDialog } from '@e2e/fixtures/components/TopUpCreditsDialog' import { TestIds } from '@e2e/fixtures/selectors' import { workspaceRailAuthFixture as test } from '@e2e/fixtures/workspaceRailAuthFixture' +import { ToastHelper } from '@e2e/fixtures/helpers/ToastHelper' /** * Regression coverage for the 1.51 QA finding: with no payment method saved, @@ -48,10 +49,9 @@ test.describe('Top-up without a saved payment method', () => { await topUpDialog.root.getByRole('button', { name: 'Pay $50.00' }).click() await expect( - page - .getByTestId('toast') - .and(page.locator('[data-toast-kind="error"]')) - .getByText(/Add one via Settings → Plan & Credits → Manage billing/) + new ToastHelper(page).toastErrors.filter({ + hasText: /Add one via Settings → Plan & Credits → Manage billing/ + }) ).toBeVisible() }) }) diff --git a/browser_tests/tests/dialogs/topUpSdkRail.spec.ts b/browser_tests/tests/dialogs/topUpSdkRail.spec.ts index 5e8ba82775a..bbaffdcd612 100644 --- a/browser_tests/tests/dialogs/topUpSdkRail.spec.ts +++ b/browser_tests/tests/dialogs/topUpSdkRail.spec.ts @@ -16,6 +16,7 @@ import { FeatureFlagHelper } from '@e2e/fixtures/helpers/FeatureFlagHelper' import { APP_URL, setupCloudApp } from '@e2e/fixtures/utils/cloudAppSetup' import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute' import { workspace } from '@e2e/fixtures/utils/workspaceMocks' +import { ToastHelper } from '@e2e/fixtures/helpers/ToastHelper' /** * Buying credits across the billing SDK rail — FE-2475. @@ -206,8 +207,6 @@ test.describe('Top-up rail (FE-2475)', { tag: '@cloud' }, () => { await expect.poll(() => routes.purchaseRequests.length).toBe(1) expect(transport(routes.purchaseRequests[0])).toBe('fetch') - await expect( - page.getByTestId('toast').and(page.locator('[data-toast-kind="error"]')) - ).toBeVisible() + await expect(new ToastHelper(page).toastErrors).toBeVisible() }) }) diff --git a/browser_tests/tests/sidebar/assets.spec.ts b/browser_tests/tests/sidebar/assets.spec.ts index 8ed7d1ebaea..26749e3ec83 100644 --- a/browser_tests/tests/sidebar/assets.spec.ts +++ b/browser_tests/tests/sidebar/assets.spec.ts @@ -1056,10 +1056,7 @@ test.describe('Assets sidebar - delete confirmation', () => { await expect(dialog).toBeHidden() await expect(tab.assetCards).toHaveCount(initialCount - 1) - const successToast = comfyPage.page - .getByTestId('toast') - .and(comfyPage.page.locator('[data-toast-kind="success"]')) - await expect(successToast).toBeVisible() + await expect(comfyPage.toast.toastSuccesses).toBeVisible() }) test('Cancelling delete preserves asset', async ({ comfyPage }) => { diff --git a/browser_tests/tests/templates.spec.ts b/browser_tests/tests/templates.spec.ts index a935574ad49..0af1474ace9 100644 --- a/browser_tests/tests/templates.spec.ts +++ b/browser_tests/tests/templates.spec.ts @@ -281,7 +281,7 @@ test.describe('Templates', { tag: ['@slow', '@workflow'] }, () => { await expect(filterBar).toHaveScreenshot( 'template-filter-bar-select-components.png', { - mask: [comfyPage.page.getByTestId('toast')] + mask: [comfyPage.toast.visibleToasts] } ) } diff --git a/browser_tests/tests/versionMismatchWarnings.spec.ts b/browser_tests/tests/versionMismatchWarnings.spec.ts index 8bf11284b2d..f455ea3c9ce 100644 --- a/browser_tests/tests/versionMismatchWarnings.spec.ts +++ b/browser_tests/tests/versionMismatchWarnings.spec.ts @@ -64,9 +64,7 @@ comfyPageFixture.describe('Version Mismatch Warnings', { tag: '@slow' }, () => { }) => { // Expect a warning toast to be shown await expect( - comfyPage.page - .getByTestId('toast') - .getByText('Version Compatibility Warning') + comfyPage.toast.withText('Version Compatibility Warning') ).toBeVisible() }) @@ -75,9 +73,7 @@ comfyPageFixture.describe('Version Mismatch Warnings', { tag: '@slow' }, () => { async ({ comfyPage }) => { // Expect no warning toast to be shown await expect( - comfyPage.page - .getByTestId('toast') - .getByText('Version Compatibility Warning') + comfyPage.toast.withText('Version Compatibility Warning') ).toBeHidden() } ) @@ -88,12 +84,9 @@ comfyPageFixture.describe('Version Mismatch Warnings', { tag: '@slow' }, () => { test.setTimeout(30_000) // Locate the warning toast and dismiss it - const warningToast = comfyPage.page.getByTestId('toast').filter({ - hasText: 'Version Compatibility' - }) - await warningToast.waitFor({ state: 'visible' }) - const dismissButton = warningToast.getByRole('button', { name: 'Close' }) - await dismissButton.click() + const warningToast = comfyPage.toast.withText('Version Compatibility') + await expect(warningToast).toBeVisible() + await comfyPage.toast.dismiss(warningToast) // Wait for the dismissed state to be persisted await comfyPage.page.waitForFunction( @@ -105,9 +98,7 @@ comfyPageFixture.describe('Version Mismatch Warnings', { tag: '@slow' }, () => { // The same warning from same versions should not be shown to the user again await expect( - comfyPage.page - .getByTestId('toast') - .getByText('Version Compatibility Warning') + comfyPage.toast.withText('Version Compatibility Warning') ).toBeHidden() }) }) diff --git a/src/components/ui/toast/index.ts b/src/components/ui/toast/index.ts deleted file mode 100644 index a85102b58e3..00000000000 --- a/src/components/ui/toast/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { default as Toaster } from './Toaster.vue' -export { useToast } from './toastStore' -export type { ToastId, ToastOptions } from './toastStore' From b8201ccc6a51122b4cf38a22927d9fd970025e0e Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Mon, 5 Oct 2026 08:01:37 +0000 Subject: [PATCH 13/71] refactor: import toast modules directly instead of through a barrel Amp-Thread-ID: https://ampcode.com/threads/T-01a10ae8-fc3e-75a8-8da1-907005697afa --- src/base/common/downloadUtil.test.ts | 2 +- src/base/common/downloadUtil.ts | 2 +- src/components/common/BackgroundImageUpload.vue | 2 +- src/components/dialog/content/ErrorDialogContent.vue | 2 +- .../dialog/content/TopUpCreditsDialogContentLegacy.test.ts | 2 +- .../dialog/content/TopUpCreditsDialogContentLegacy.vue | 2 +- src/components/dialog/content/setting/KeybindingPanel.vue | 2 +- src/components/dialog/content/setting/UserPanel.test.ts | 2 +- src/components/dialog/content/signin/SignInForm.test.ts | 2 +- src/components/dialog/content/signin/SignInForm.vue | 2 +- .../content/subscription/CancelSubscriptionDialogContent.vue | 2 +- src/components/graph/GraphCanvas.vue | 2 +- src/components/helpcenter/HelpCenterMenuContent.test.ts | 2 +- src/components/helpcenter/HelpCenterMenuContent.vue | 2 +- src/components/load3d/controls/HDRIControls.test.ts | 2 +- src/components/load3d/controls/HDRIControls.vue | 2 +- src/components/load3d/menubar/HdriMenuGroup.vue | 2 +- src/components/sidebar/tabs/AssetsSidebarTab.vue | 2 +- src/components/sidebar/tabs/ModelLibrarySidebarTab.test.ts | 2 +- src/components/sidebar/tabs/ModelLibrarySidebarTab.vue | 2 +- src/components/toast/RerouteMigrationToast.test.ts | 3 ++- src/components/toast/RerouteMigrationToast.vue | 4 ++-- src/composables/auth/useAuthActions.test.ts | 2 +- src/composables/auth/useAuthActions.ts | 2 +- src/composables/graph/useSelectionOperations.ts | 2 +- src/composables/graph/useSubgraphOperations.test.ts | 2 +- src/composables/graph/useSubgraphOperations.ts | 2 +- src/composables/node/useNodeDragToCanvas.test.ts | 2 +- src/composables/node/useNodeDragToCanvas.ts | 2 +- src/composables/node/useNodeImageUpload.test.ts | 2 +- src/composables/node/useNodeImageUpload.ts | 4 ++-- src/composables/painter/usePainter.ts | 2 +- src/composables/useCameraAngle.test.ts | 2 +- src/composables/useCameraAngle.ts | 2 +- src/composables/useCameraInfo.test.ts | 2 +- src/composables/useCameraInfo.ts | 2 +- src/composables/useCopyToClipboard.test.ts | 2 +- src/composables/useCopyToClipboard.ts | 2 +- src/composables/useCoreCommands.test.ts | 2 +- src/composables/useCoreCommands.ts | 2 +- src/composables/useErrorHandling.test.ts | 2 +- src/composables/useErrorHandling.ts | 2 +- src/composables/useLoad3d.test.ts | 2 +- src/composables/useLoad3d.ts | 2 +- src/composables/useLoad3dDrag.test.ts | 2 +- src/composables/useLoad3dDrag.ts | 2 +- src/composables/useLoad3dViewer.test.ts | 2 +- src/composables/useLoad3dViewer.ts | 2 +- src/composables/usePaste.test.ts | 2 +- src/composables/useReconnectingNotification.test.ts | 2 +- src/composables/useReconnectingNotification.ts | 4 ++-- src/core/graph/subgraph/promotionUtils.ts | 2 +- src/extensions/core/electronAdapter.ts | 2 +- src/extensions/core/load3d.test.ts | 2 +- src/extensions/core/load3d.ts | 2 +- src/extensions/core/load3d/Load3dUtils.ts | 2 +- src/extensions/core/load3d/LoaderManager.test.ts | 2 +- src/extensions/core/load3d/LoaderManager.ts | 2 +- src/extensions/core/load3d/ModelExporter.test.ts | 2 +- src/extensions/core/load3d/ModelExporter.ts | 2 +- src/extensions/core/load3d/exportMenuHelper.test.ts | 2 +- src/extensions/core/load3d/exportMenuHelper.ts | 2 +- src/extensions/core/load3dPreviewExtensions.test.ts | 2 +- src/extensions/core/load3dPreviewExtensions.ts | 2 +- src/extensions/core/nodeTemplates.ts | 2 +- src/extensions/core/uploadAudio.test.ts | 2 +- src/extensions/core/uploadAudio.ts | 2 +- src/extensions/core/webcamCapture.ts | 2 +- src/main.ts | 2 +- .../assets/components/ModelImportProgressDialog.test.ts | 2 +- src/platform/assets/composables/openModelLibraryBrowser.ts | 2 +- src/platform/assets/composables/useAssetDownload.ts | 2 +- src/platform/assets/composables/useAssetZipExport.ts | 2 +- src/platform/assets/composables/useMediaAssetActions.test.ts | 2 +- src/platform/assets/composables/useMediaAssetActions.ts | 2 +- src/platform/assets/composables/useNodeOutputsExport.test.ts | 2 +- src/platform/assets/utils/createAssetWidget.ts | 2 +- src/platform/auth/session/cloudWebSessionStore.ts | 2 +- .../auth/session/components/SignOutEverywhereButton.vue | 2 +- src/platform/auth/webSessionFlagOn.test.ts | 2 +- src/platform/cloud/onboarding/CloudSurveyView.test.ts | 2 +- src/platform/cloud/onboarding/CloudSurveyView.vue | 2 +- src/platform/cloud/onboarding/components/CloudLayoutView.vue | 2 +- src/platform/cloud/onboarding/components/OAuthLayoutView.vue | 2 +- .../cloud/onboarding/composables/usePostAuthRedirect.test.ts | 2 +- .../cloud/onboarding/composables/usePostAuthRedirect.ts | 2 +- src/platform/cloud/onboarding/desktopLoginRedemption.test.ts | 2 +- src/platform/cloud/onboarding/desktopLoginRedemption.ts | 2 +- .../subscription/composables/useSubscriptionActions.test.ts | 2 +- .../cloud/subscription/launchCancellationFlow.test.ts | 2 +- src/platform/cloud/subscription/launchCancellationFlow.ts | 2 +- src/platform/extensions/extensionToastManager.test.ts | 2 +- src/platform/extensions/extensionToastManager.ts | 2 +- src/platform/keybindings/presetService.test.ts | 2 +- src/platform/keybindings/presetService.ts | 2 +- src/platform/missingMedia/missingMediaPipeline.test.ts | 2 +- src/platform/missingMedia/missingMediaPipeline.ts | 2 +- src/platform/missingModel/missingModelPipeline.test.ts | 2 +- src/platform/missingModel/missingModelPipeline.ts | 2 +- src/platform/missingModel/missingModelStore.test.ts | 2 +- src/platform/missingModel/missingModelStore.ts | 2 +- src/platform/nodeReplacement/useNodeReplacement.test.ts | 2 +- src/platform/nodeReplacement/useNodeReplacement.ts | 2 +- src/platform/onboarding/onboardingTourStore.test.ts | 2 +- src/platform/onboarding/onboardingTourStore.ts | 2 +- src/platform/secrets/composables/useSecrets.test.ts | 2 +- src/platform/secrets/composables/useSecrets.ts | 2 +- src/platform/settings/components/ServerConfigPanel.vue | 2 +- .../updates/common/useFrontendVersionMismatchWarning.test.ts | 2 +- .../updates/common/useFrontendVersionMismatchWarning.ts | 2 +- src/platform/workflow/core/services/workflowService.test.ts | 2 +- src/platform/workflow/core/services/workflowService.ts | 2 +- .../persistence/composables/useWorkflowPersistenceV2.test.ts | 2 +- .../persistence/composables/useWorkflowPersistenceV2.ts | 2 +- .../sharing/components/ShareWorkflowDialogContent.test.ts | 2 +- .../sharing/components/ShareWorkflowDialogContent.vue | 2 +- .../sharing/components/profile/ComfyHubCreateProfileForm.vue | 2 +- .../sharing/components/publish/ComfyHubPublishDialog.test.ts | 2 +- .../sharing/components/publish/ComfyHubPublishDialog.vue | 2 +- .../sharing/composables/useSharedWorkflowUrlLoader.test.ts | 2 +- .../sharing/composables/useSharedWorkflowUrlLoader.ts | 2 +- src/platform/workflow/sharing/utils/validateFileSize.ts | 2 +- .../templates/composables/useTemplateUrlLoader.test.ts | 2 +- .../workflow/templates/composables/useTemplateUrlLoader.ts | 2 +- .../templates/composables/useTemplateWorkflows.test.ts | 2 +- .../workflow/templates/composables/useTemplateWorkflows.ts | 4 ++-- .../workflow/validation/composables/useWorkflowValidation.ts | 2 +- src/platform/workspace/billing/sdk/billingSdkStore.test.ts | 2 +- src/platform/workspace/billing/sdk/billingSdkStore.ts | 4 ++-- src/platform/workspace/components/InviteMembersForm.test.ts | 2 +- src/platform/workspace/components/InviteMembersForm.vue | 2 +- .../components/TopUpCreditsDialogContentWorkspace.test.ts | 2 +- .../components/TopUpCreditsDialogContentWorkspace.vue | 2 +- .../components/dialogs/ChangeMemberRoleDialogContent.test.ts | 2 +- .../components/dialogs/ChangeMemberRoleDialogContent.vue | 2 +- .../components/dialogs/CreateWorkspaceDialogContent.vue | 2 +- .../components/dialogs/DeleteWorkspaceDialogContent.vue | 2 +- .../dialogs/DowngradeRemoveMembersDialogContent.test.ts | 2 +- .../dialogs/DowngradeRemoveMembersDialogContent.vue | 2 +- .../components/dialogs/EditWorkspaceDialogContent.vue | 2 +- .../components/dialogs/InviteMemberDialogContent.test.ts | 2 +- .../components/dialogs/LeaveWorkspaceDialogContent.vue | 2 +- .../components/dialogs/RemoveMemberDialogContent.vue | 2 +- .../components/dialogs/RevokeInviteDialogContent.vue | 2 +- .../components/dialogs/TeamWorkspacesDialogContent.test.ts | 2 +- .../components/dialogs/TeamWorkspacesDialogContent.vue | 2 +- .../components/dialogs/settings/PendingInvitesList.test.ts | 2 +- .../components/dialogs/settings/PendingInvitesList.vue | 2 +- .../workspace/components/toasts/InviteAcceptedToast.vue | 4 ++-- src/platform/workspace/composables/useInviteUrlLoader.test.ts | 2 +- src/platform/workspace/composables/useInviteUrlLoader.ts | 2 +- src/platform/workspace/composables/useMembersPanel.test.ts | 2 +- src/platform/workspace/composables/useMembersPanel.ts | 2 +- src/platform/workspace/composables/useResubscribe.test.ts | 2 +- src/platform/workspace/composables/useResubscribe.ts | 2 +- .../workspace/composables/useSubscriptionCheckout.test.ts | 2 +- src/platform/workspace/composables/useSubscriptionCheckout.ts | 4 ++-- .../workspace/composables/useWorkspaceBilling.test.ts | 2 +- src/platform/workspace/composables/useWorkspaceBilling.ts | 2 +- .../workspace/composables/useWorkspaceUrlLoader.test.ts | 2 +- src/platform/workspace/composables/useWorkspaceUrlLoader.ts | 2 +- src/platform/workspace/stores/billingOperationStore.test.ts | 2 +- src/platform/workspace/stores/billingOperationStore.ts | 4 ++-- src/platform/workspace/stores/useWorkspaceAuth.test.ts | 2 +- src/platform/workspace/stores/workspaceAuthStore.ts | 2 +- .../compositor/composables/useCompositorEditor.test.ts | 2 +- .../extensions/compositor/composables/useCompositorEditor.ts | 2 +- .../compositor/composables/useCompositorPsdDownload.test.ts | 2 +- .../compositor/composables/useCompositorPsdDownload.ts | 2 +- .../layerEditor/components/LayerEditorContent.test.ts | 2 +- .../extensions/layerEditor/components/LayerEditorContent.vue | 2 +- .../extensions/layerEditor/composables/useLayerEditor.test.ts | 2 +- .../extensions/layerEditor/composables/useLayerEditor.ts | 2 +- .../layerEditor/composables/useLayerEditorExport.test.ts | 2 +- .../layerEditor/composables/useLayerEditorExport.ts | 2 +- src/renderer/extensions/vueNodes/VideoPreview.vue | 2 +- src/renderer/extensions/vueNodes/components/ImagePreview.vue | 2 +- .../vueNodes/widgets/components/WidgetRecordAudio.vue | 2 +- .../vueNodes/widgets/components/WidgetTextPreview.vue | 2 +- .../widgets/components/audio/AudioPreviewPlayer.test.ts | 2 +- .../vueNodes/widgets/components/audio/AudioPreviewPlayer.vue | 2 +- .../widgets/components/form/dropdown/FormDropdown.test.ts | 2 +- .../widgets/components/form/dropdown/FormDropdown.vue | 2 +- .../widgets/composables/useWidgetSelectActions.test.ts | 2 +- .../vueNodes/widgets/composables/useWidgetSelectActions.ts | 2 +- src/scripts/api.ts | 2 +- src/scripts/app.test.ts | 2 +- src/scripts/app.ts | 4 ++-- src/scripts/ui/settings.test.ts | 2 +- src/scripts/ui/settings.ts | 2 +- src/services/README.md | 2 +- src/services/audioService.test.ts | 2 +- src/services/audioService.ts | 2 +- src/services/dialogService.downgrade.test.ts | 2 +- src/services/dialogService.ts | 2 +- src/services/litegraphService.ts | 2 +- src/stores/__tests__/authTokenPriority.test.ts | 2 +- src/stores/apiKeyAuthStore.ts | 2 +- src/stores/assetExportStore.ts | 2 +- src/stores/subgraphStore.ts | 2 +- src/stores/workspaceStore.ts | 2 +- src/types/extensionTypes.ts | 2 +- src/utils/litegraphUtil.test.ts | 2 +- src/utils/litegraphUtil.ts | 2 +- src/views/GraphView.vue | 2 +- src/workbench/extensions/agent/AgentPanelRoot.test.ts | 2 +- src/workbench/extensions/agent/AgentPanelRoot.vue | 2 +- .../extensions/agent/components/agent/Composer.test.ts | 2 +- .../agent/components/agent/composer/RunModePopover.vue | 2 +- .../agent/components/agent/message/MessageFeedback.test.ts | 2 +- .../agent/components/agent/message/ReplyAudioCard.test.ts | 2 +- .../agent/components/agent/message/TabLinkCard.test.ts | 2 +- .../extensions/agent/components/agent/message/TabLinkCard.vue | 2 +- .../agent/composables/agent/useAgentConsent.test.ts | 2 +- .../extensions/agent/composables/agent/useAgentConsent.ts | 2 +- .../agent/composables/agent/useAgentWorkflowSelection.ts | 2 +- src/workbench/extensions/agent/crdt/rejectedOpNotice.ts | 2 +- .../crdt/useAgentCrdtFollower.rejectedWidgetWrite.test.ts | 2 +- .../components/manager/button/PackUpdateButton.test.ts | 2 +- .../extensions/manager/composables/useManagerQueue.ts | 2 +- .../extensions/manager/composables/useManagerState.test.ts | 2 +- .../extensions/manager/composables/useManagerState.ts | 2 +- .../extensions/manager/stores/comfyManagerStore.test.ts | 2 +- src/workbench/extensions/manager/stores/comfyManagerStore.ts | 2 +- 224 files changed, 234 insertions(+), 233 deletions(-) diff --git a/src/base/common/downloadUtil.test.ts b/src/base/common/downloadUtil.test.ts index 931b4f93d03..b3ad30312d3 100644 --- a/src/base/common/downloadUtil.test.ts +++ b/src/base/common/downloadUtil.test.ts @@ -1,4 +1,4 @@ -import { useToast } from '@/components/ui/toast' +import { useToast } from '@/components/ui/toast/toastStore' import { fromAny, fromPartial } from '@total-typescript/shoehorn' import type { MockInstance } from 'vitest' import { beforeEach, describe, expect, it, vi } from 'vitest' diff --git a/src/base/common/downloadUtil.ts b/src/base/common/downloadUtil.ts index 7caeff9a37d..f6c738f5b0c 100644 --- a/src/base/common/downloadUtil.ts +++ b/src/base/common/downloadUtil.ts @@ -4,7 +4,7 @@ import { t } from '@/i18n' // oxlint-disable-next-line comfy/no-restricted-paths import { isCloud } from '@/platform/distribution/types' -import { useToast } from '@/components/ui/toast' +import { useToast } from '@/components/ui/toast/toastStore' // Constants const DEFAULT_DOWNLOAD_FILENAME = 'download.png' diff --git a/src/components/common/BackgroundImageUpload.vue b/src/components/common/BackgroundImageUpload.vue index e84ccc8552c..3f8b1b2c40d 100644 --- a/src/components/common/BackgroundImageUpload.vue +++ b/src/components/common/BackgroundImageUpload.vue @@ -41,7 +41,7 @@ import { ref } from 'vue' import Button from '@/components/ui/button/Button.vue' import Input from '@/components/ui/input/Input.vue' import { appendCloudResParam } from '@/platform/distribution/cloudPreviewUtil' -import { useToast } from '@/components/ui/toast' +import { useToast } from '@/components/ui/toast/toastStore' import { api } from '@/scripts/api' const modelValue = defineModel() diff --git a/src/components/dialog/content/ErrorDialogContent.vue b/src/components/dialog/content/ErrorDialogContent.vue index 865325ed727..5cb8ccbf574 100644 --- a/src/components/dialog/content/ErrorDialogContent.vue +++ b/src/components/dialog/content/ErrorDialogContent.vue @@ -62,7 +62,7 @@