Skip to content

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.

fix(webv2): warn when queued workflow metadata is omitted

JPPhoto44e90fde08e6
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index cc11437f89..e05cab17b2 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -3993,6 +3993,8 @@
"loadingMore": "Loading more…",
"multipleWorkflowReturnNodes": "The workflow must contain exactly one workflow return node before it can be saved.",
"multipleWorkflowReturnNodesForTransfer": "The workflow must contain exactly one workflow return node before it can be exported or copied.",
+ "workflowMetadataOmitted": "Workflow metadata omitted",
+ "workflowMetadataOmittedBody": "Workflow metadata was omitted because the workflow contains multiple workflow_return nodes.",
"moreActions": "More actions",
"nodeCount_one": "{{count}} node",
"nodeCount_other": "{{count}} nodes",
diff --git a/invokeai/frontend/webv2/src/workbench/projectContracts.ts b/invokeai/frontend/webv2/src/workbench/projectContracts.ts
index ba0d7d3579..78fe45e599 100644
--- a/invokeai/frontend/webv2/src/workbench/projectContracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/projectContracts.ts
@@ -100,7 +100,9 @@ export interface WorkbenchNotification {
id: string;
kind: WorkbenchNotificationKind;
title: string;
+ titleKey?: string;
message?: string;
+ messageKey?: string;
createdAt: string;
projectId?: string;
isRead: boolean;
diff --git a/invokeai/frontend/webv2/src/workbench/shell/notifications/WorkbenchNotificationToaster.tsx b/invokeai/frontend/webv2/src/workbench/shell/notifications/WorkbenchNotificationToaster.tsx
index 3b0f2de7bc..ba315f3ec7 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/notifications/WorkbenchNotificationToaster.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/notifications/WorkbenchNotificationToaster.tsx
@@ -4,6 +4,7 @@ import { toaster } from '@platform/ui';
import { useWorkbenchPreferenceSelector } from '@workbench/settings/store';
import { useWorkbenchSelector } from '@workbench/WorkbenchContext';
import { useEffect, useRef } from 'react';
+import { useTranslation } from 'react-i18next';
import { getToastKey, shouldToastNotification } from './toastPolicy';
@@ -14,6 +15,7 @@ const notificationToastType: Record<WorkbenchNotificationKind, 'error' | 'info'
};
export const WorkbenchNotificationToaster = () => {
+ const { t } = useTranslation();
const notifications = useWorkbenchSelector((snapshot) => snapshot.notifications);
const notifyOnEnqueue = useWorkbenchPreferenceSelector((prefs) => prefs.notifyOnEnqueue);
const toastedNotificationIdsRef = useRef<Set<string> | null>(null);
@@ -39,13 +41,13 @@ export const WorkbenchNotificationToaster = () => {
queueMicrotask(() => {
toaster.create({
- description: notification.message,
- title: notification.title,
+ description: notification.messageKey ? t(notification.messageKey) : notification.message,
+ title: notification.titleKey ? t(notification.titleKey) : notification.title,
type: notificationToastType[notification.kind],
});
});
}
- }, [notifications, notifyOnEnqueue]);
+ }, [notifications, notifyOnEnqueue, t]);
return null;
};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsWidgetView.tsx
index fffedef3bc..0f85799a6b 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsWidgetView.tsx
@@ -89,16 +89,16 @@ const NotificationsPanel = () => {
<HStack gap="2" minW="0">
<Icon as={IconComponent} color={`${kindColorPalette[notification.kind]}.300`} boxSize="3.5" />
<Text fontSize="2xs" fontWeight="700">
- {notification.title}
+ {notification.titleKey ? t(notification.titleKey) : notification.title}
</Text>
</HStack>
<Badge colorPalette={kindColorPalette[notification.kind]} size="xs">
{t(`notifications.kind.${notification.kind}`)}
</Badge>
</HStack>
- {notification.message ? (
+ {notification.message || notification.messageKey ? (
<Text color="fg.subtle" fontSize="2xs">
- {notification.message}
+ {notification.messageKey ? t(notification.messageKey) : notification.message}
</Text>
) : null}
<Text color="fg.subtle" fontSize="2xs">
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 88930f3459..67a3859501 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -3437,7 +3437,7 @@ describe('workbenchReducer Phase 5 generation flow', () => {
expect(readNodeSeed(state)).toBe(48);
});
- it('omits the embedded workflow when the backend would reject it', () => {
+ it('notifies when the queued workflow omits metadata the backend would reject', () => {
// `WorkflowWithoutID` rejects more than one `workflow_return` node, and
// the batch is validated before the enqueue route body, so attaching
// such a workflow turns the whole run into a 422. Legacy validates first
@@ -3489,13 +3489,27 @@ describe('workbenchReducer Phase 5 generation flow', () => {
});
}
- const submission = readSubmission(submitWorkflow(state));
+ const nextState = submitWorkflow(state);
+ const submission = readSubmission(nextState);
// `kind` guards the assertion below: a graph that fails to compile also
// yields an object with no `workflow` key, which would pass for the
// wrong reason.
expect(submission).toMatchObject({ kind: 'workflow' });
expect(submission).not.toHaveProperty('workflow');
+ expect(nextState.notifications[0]).toMatchObject({
+ kind: 'info',
+ message: 'Workflow metadata was omitted because the workflow contains multiple workflow_return nodes.',
+ messageKey: 'workflowLibrary.workflowMetadataOmittedBody',
+ title: 'Workflow metadata omitted',
+ titleKey: 'workflowLibrary.workflowMetadataOmitted',
+ });
+
+ const repeatedState = submitWorkflow(nextState);
+
+ expect(
+ repeatedState.notifications.filter((notification) => notification.title === 'Workflow metadata omitted')
+ ).toHaveLength(2);
});
it('holds a fixed seed as a graph constant and repeats the graph for every run', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index 46cf69d4d8..531d130284 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -522,14 +522,18 @@ const createNotification = ({
category,
kind,
message,
+ messageKey,
projectId,
title,
+ titleKey,
}: {
category?: WorkbenchNotificationCategory;
kind: WorkbenchNotificationKind;
message?: string;
+ messageKey?: string;
projectId?: string;
title: string;
+ titleKey?: string;
}): WorkbenchNotification => ({
category,
createdAt: now(),
@@ -537,8 +541,10 @@ const createNotification = ({
isRead: false,
kind,
message,
+ messageKey,
projectId,
title,
+ titleKey,
});
const addNotification = (state: WorkbenchState, notification: WorkbenchNotification): WorkbenchState => {
@@ -589,6 +595,24 @@ const withEnqueueNotification = (
const queueItem = after.queue.items[0];
+ if (
+ queueItem?.snapshot.sourceId === 'workflow' &&
+ queueItem.snapshot.backendSubmission.kind === 'workflow' &&
+ !queueItem.snapshot.backendSubmission.workflow
+ ) {
+ return addNotification(
+ nextState,
+ createNotification({
+ kind: 'info',
+ message: 'Workflow metadata was omitted because the workflow contains multiple workflow_return nodes.',
+ messageKey: 'workflowLibrary.workflowMetadataOmittedBody',
+ projectId: after.id,
+ title: 'Workflow metadata omitted',
+ titleKey: 'workflowLibrary.workflowMetadataOmitted',
+ })
+ );
+ }
+
return addNotification(
nextState,
createNotification({