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.

refactor(webv2): type notification categories as a closed union

joshistoast3bc37ab9280f
diff --git a/invokeai/frontend/webv2/src/workbench/projectContracts.ts b/invokeai/frontend/webv2/src/workbench/projectContracts.ts
index 0a45d4723f..cfd602f42e 100644
--- a/invokeai/frontend/webv2/src/workbench/projectContracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/projectContracts.ts
@@ -66,6 +66,9 @@ export interface BackendConnectionState {
export type WorkbenchNotificationKind = 'error' | 'success' | 'info';
+/** Machine categories for toast policy. Absent category = always toast. */
+export type WorkbenchNotificationCategory = 'enqueue';
+
export interface WorkbenchNotification {
id: string;
kind: WorkbenchNotificationKind;
@@ -74,8 +77,8 @@ export interface WorkbenchNotification {
createdAt: string;
projectId?: string;
isRead: boolean;
- /** Machine category for toast policy (e.g. 'enqueue'); absent = always toast. */
- category?: string;
+ /** Machine category for toast policy; absent = always toast. */
+ category?: WorkbenchNotificationCategory;
/** Coalesced repeat count (see addNotification); absent = 1. */
occurrenceCount?: number;
}
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index e57aabc178..940facd23d 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -32,6 +32,7 @@ import type {
ProjectUndoSnapshot,
PromptHistoryItem,
WorkbenchNotification,
+ WorkbenchNotificationCategory,
WorkbenchNotificationKind,
WorkbenchState,
} from '@workbench/projectContracts';
@@ -408,7 +409,7 @@ const createNotification = ({
projectId,
title,
}: {
- category?: string;
+ category?: WorkbenchNotificationCategory;
kind: WorkbenchNotificationKind;
message?: string;
projectId?: string;