Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix: allow notifications outside workbench
joshistoast2e7c4aee8971
diff --git a/invokeai/frontend/webv2/src/workbench/useNotify.ts b/invokeai/frontend/webv2/src/workbench/useNotify.tsindex 5be3b140ce..d9899708d1 100644--- a/invokeai/frontend/webv2/src/workbench/useNotify.ts+++ b/invokeai/frontend/webv2/src/workbench/useNotify.ts@@ -1,11 +1,12 @@import { useMemo } from 'react';import type { WorkbenchNotificationKind } from './types';-import { useWorkbench } from './WorkbenchContext';+import { useOptionalWorkbench } from './WorkbenchContext';+import { toaster } from './components/ui/toaster';/**- * Shell notification helper: `recordNotice` dispatch wrapped in one hook so- * widgets never hand-roll the same notifyError/notifySuccess plumbing.+ * Notification helper: records into the workbench shell when present, and+ * falls back to global toasts for project-independent surfaces like Home.*/export interface Notify {success: (title: string, message?: string) => void;@@ -13,14 +14,25 @@ export interface Notify {info: (title: string, message?: string) => void;}+const notificationToastType: Record<WorkbenchNotificationKind, 'error' | 'info' | 'success'> = {+ error: 'error',+ info: 'info',+ success: 'success',+};+export const useNotify = (): Notify => {- const { dispatch } = useWorkbench();+ const workbench = useOptionalWorkbench();+ const dispatch = workbench?.dispatch;return useMemo(() => {const record =(kind: WorkbenchNotificationKind) =>(title: string, message?: string): void => {- dispatch({ kind, message, title, type: 'recordNotice' });+ if (dispatch) {+ dispatch({ kind, message, title, type: 'recordNotice' });+ } else {+ toaster.create({ description: message, title, type: notificationToastType[kind] });+ }};return { error: record('error'), info: record('info'), success: record('success') };