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): give the Video panel its own prompt

Lincoln Stein232d6053de3f
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index a9dc3aa987..74bebc5af0 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -3090,7 +3090,6 @@
"selectModel": "Select a video model…",
"settingsAdjusted": "Settings adjusted",
"settingsAdjustedDescription": "Adjusted for the selected model: {{labels}}.",
- "sharedPromptDescription": "The prompt is shared with the Generate panel.",
"shuffleSeed": "New random seed",
"steps": "Steps",
"swapAspectRatio": "Swap orientation",
diff --git a/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx b/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx
index d865d804f3..f678f90540 100644
--- a/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx
+++ b/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx
@@ -2,18 +2,17 @@ import type { VideoUiAdapter } from '@features/video';
import type { ReactNode } from 'react';
import { invalidateGallery } from '@features/gallery/queries';
-import { areProjectPromptDraftsEqual, getPromptDraftFromValues } from '@features/generation/settings';
import { VideoUiProvider } from '@features/video';
import { useQueryClient } from '@tanstack/react-query';
import { useWorkbenchPreferenceSelector } from '@workbench/settings/store';
-import { getProjectWidgetValues } from '@workbench/widgetState';
import { useActiveProjectSelector, useWorkbenchCommands } from '@workbench/WorkbenchContext';
import { useCallback, useMemo } from 'react';
/**
- * Production binding of Video's UI port: maps the video widget instance and
- * the shared prompt draft out of the Workbench aggregate. No second adapter is
- * expected.
+ * Production binding of Video's UI port: maps the video widget instance out of
+ * the Workbench aggregate. No second adapter is expected. Video's prompt is one
+ * of those widget values — it is not the project draft Generate and Upscale
+ * share — so nothing but `rawValues` is joined here.
*/
export const VideoUiAdapterProvider = ({ children }: { children: ReactNode }) => {
const project = useActiveProjectSelector(
@@ -22,14 +21,10 @@ export const VideoUiAdapterProvider = ({ children }: { children: ReactNode }) =>
return {
projectId: activeProject.id,
- promptDraft: getPromptDraftFromValues(getProjectWidgetValues(activeProject, 'generate')),
rawValues: instance?.state.values ?? {},
};
},
- (left, right) =>
- left.projectId === right.projectId &&
- areProjectPromptDraftsEqual(left.promptDraft, right.promptDraft) &&
- left.rawValues === right.rawValues
+ (left, right) => left.projectId === right.projectId && left.rawValues === right.rawValues
);
// Syntax highlighting is a per-user preference, not a property of the
// project, so it is joined here rather than read off the document.
@@ -42,10 +37,6 @@ export const VideoUiAdapterProvider = ({ children }: { children: ReactNode }) =>
// them whenever `rawValues` changes would hand every consumer new function
// identities on each keystroke, re-rendering memoized fields that did not change.
const { projectId } = project;
- const patchPromptDraft = useCallback<VideoUiAdapter['patchPromptDraft']>(
- (values) => commands.generation.patchPromptDraft(values, 'video', projectId),
- [commands, projectId]
- );
const patchValues = useCallback<VideoUiAdapter['patchValues']>(
(values, origin) => commands.widgets.patchValues('video', values, projectId, origin),
[commands, projectId]
@@ -58,13 +49,12 @@ export const VideoUiAdapterProvider = ({ children }: { children: ReactNode }) =>
const adapter = useMemo<VideoUiAdapter>(
() => ({
...project,
- patchPromptDraft,
patchValues,
reportError,
showPromptSyntaxHighlighting,
touchGalleryImages,
}),
- [patchPromptDraft, patchValues, project, reportError, showPromptSyntaxHighlighting, touchGalleryImages]
+ [patchValues, project, reportError, showPromptSyntaxHighlighting, touchGalleryImages]
);
return <VideoUiProvider adapter={adapter}>{children}</VideoUiProvider>;
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoFormFields.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoFormFields.tsx
index c87ac7c61f..4b3fd613e2 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoFormFields.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoFormFields.tsx
@@ -1,69 +1,69 @@
import type { GenerateLora, MainModelConfig, PromptHistoryItem } from '@features/generation/contracts';
-import type { ProjectPromptDraft, ProjectPromptDraftPatch } from '@features/generation/settings';
import type { VideoWidgetValues } from '@features/video/core/types';
-import { Stack, Text } from '@chakra-ui/react';
+import { Stack } from '@chakra-ui/react';
import { NegativePromptField, PositivePromptField } from '@features/generation/components';
-import { areProjectPromptDraftsEqual } from '@features/generation/settings';
import { memo, useCallback } from 'react';
-import { useTranslation } from 'react-i18next';
import { areVideoLorasEquivalent, areVideoModelsEquivalent } from './videoComparators';
/**
- * The Video widget's prompt block. Shares the project-wide prompt draft with
- * Generate (upscale-style), so a prompt travels with the user between panels.
- * Memoised against content: the widget re-derives `values` on every patch and
- * the prompt editors carry autocomplete state a needless remount would disturb.
+ * The Video widget's prompt block. The prompt is Video's own widget value, not
+ * the project draft Generate and Upscale share: a video prompt describes motion
+ * over time and has nothing useful to say to an image model, so the two panels
+ * hold independent text. Memoised against content: the widget re-derives
+ * `values` on every patch and the prompt editors carry autocomplete state a
+ * needless remount would disturb.
*/
export const VideoPromptFields = memo(
function VideoPromptFields({
loras,
model,
negativeHelpText,
+ negativePrompt,
+ negativePromptEnabled,
negativePromptHeightPx,
negativeVisible,
- onPatchPromptDraft,
onPatchValues,
+ positivePrompt,
positivePromptHeightPx,
projectId,
- promptDraft,
showSyntaxHighlighting,
}: {
loras: GenerateLora[];
model: MainModelConfig | null;
negativeHelpText?: string;
+ negativePrompt: string;
+ negativePromptEnabled: boolean;
negativePromptHeightPx: number;
/** From the video prompt policy: MiniMax H3 has no negative conditioning at all. */
negativeVisible: boolean;
- onPatchPromptDraft: (patch: ProjectPromptDraftPatch) => void;
onPatchValues: (patch: Partial<VideoWidgetValues>) => void;
+ positivePrompt: string;
positivePromptHeightPx: number;
projectId: string;
- promptDraft: ProjectPromptDraft;
showSyntaxHighlighting: boolean;
}) {
- const { t } = useTranslation();
const handleUsePrompt = useCallback(
(prompt: PromptHistoryItem) =>
- onPatchPromptDraft({
+ onPatchValues({
negativePrompt: prompt.negativePrompt ?? '',
- negativePromptEnabled: prompt.negativePrompt ? true : promptDraft.negativePromptEnabled,
+ negativePromptEnabled: prompt.negativePrompt ? true : negativePromptEnabled,
positivePrompt: prompt.positivePrompt,
}),
- [onPatchPromptDraft, promptDraft.negativePromptEnabled]
+ [negativePromptEnabled, onPatchValues]
);
const handlePositiveChange = useCallback(
- (positivePrompt: string) => onPatchPromptDraft({ positivePrompt }),
- [onPatchPromptDraft]
+ (nextPositivePrompt: string) => onPatchValues({ positivePrompt: nextPositivePrompt }),
+ [onPatchValues]
);
const handleNegativeChange = useCallback(
- (negativePrompt: string) => onPatchPromptDraft({ negativePrompt }),
- [onPatchPromptDraft]
+ (nextNegativePrompt: string) => onPatchValues({ negativePrompt: nextNegativePrompt }),
+ [onPatchValues]
);
const handleNegativeEnabledChange = useCallback(
- (negativePromptEnabled: boolean) => onPatchPromptDraft({ negativePromptEnabled }),
- [onPatchPromptDraft]
+ (nextNegativePromptEnabled: boolean) => onPatchValues({ negativePromptEnabled: nextNegativePromptEnabled }),
+ [onPatchValues]
);
const handlePositiveResizeEnd = useCallback(
(positivePromptHeight: number) => onPatchValues({ positivePromptHeightPx: positivePromptHeight }),
@@ -76,16 +76,13 @@ export const VideoPromptFields = memo(
return (
<Stack gap="2" p="2">
- <Text color="fg.muted" fontSize="2xs" textWrap="pretty">
- {t('widgets.video.sharedPromptDescription')}
- </Text>
<PositivePromptField
heightPx={positivePromptHeightPx}
loras={loras}
projectId={projectId}
selectedModel={model ?? undefined}
showSyntaxHighlighting={showSyntaxHighlighting}
- value={promptDraft.positivePrompt}
+ value={positivePrompt}
onChange={handlePositiveChange}
onResizeEnd={handlePositiveResizeEnd}
onUsePrompt={handleUsePrompt}
@@ -94,12 +91,12 @@ export const VideoPromptFields = memo(
<NegativePromptField
heightPx={negativePromptHeightPx}
helpText={negativeHelpText}
- isEnabled={promptDraft.negativePromptEnabled}
+ isEnabled={negativePromptEnabled}
loras={loras}
projectId={projectId}
selectedModel={model ?? undefined}
showSyntaxHighlighting={showSyntaxHighlighting}
- value={promptDraft.negativePrompt}
+ value={negativePrompt}
onChange={handleNegativeChange}
onEnabledChange={handleNegativeEnabledChange}
onResizeEnd={handleNegativeResizeEnd}
@@ -109,14 +106,15 @@ export const VideoPromptFields = memo(
);
},
(previous, next) =>
+ previous.negativePrompt === next.negativePrompt &&
+ previous.negativePromptEnabled === next.negativePromptEnabled &&
previous.negativePromptHeightPx === next.negativePromptHeightPx &&
previous.negativeVisible === next.negativeVisible &&
previous.negativeHelpText === next.negativeHelpText &&
- previous.onPatchPromptDraft === next.onPatchPromptDraft &&
previous.onPatchValues === next.onPatchValues &&
+ previous.positivePrompt === next.positivePrompt &&
previous.positivePromptHeightPx === next.positivePromptHeightPx &&
previous.projectId === next.projectId &&
- areProjectPromptDraftsEqual(previous.promptDraft, next.promptDraft) &&
previous.showSyntaxHighlighting === next.showSyntaxHighlighting &&
areVideoModelsEquivalent(previous.model, next.model) &&
areVideoLorasEquivalent(previous.loras, next.loras)
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoUiContext.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoUiContext.tsx
index 337ca12ece..5064418e2d 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoUiContext.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoUiContext.tsx
@@ -1,4 +1,3 @@
-import type { ProjectPromptDraft, ProjectPromptDraftPatch } from '@features/generation/settings';
import type { VideoWidgetValues } from '@features/video/core/types';
import type { ReactNode } from 'react';
@@ -9,10 +8,8 @@ import { createContext, use, useMemo } from 'react';
* may not import workbench), not a test seam; no second adapter is expected.
*/
export interface VideoUiAdapter {
- patchPromptDraft(values: ProjectPromptDraftPatch): void;
patchValues(values: Partial<VideoWidgetValues>, origin?: 'user' | 'system'): void;
projectId: string;
- promptDraft: ProjectPromptDraft;
rawValues: Record<string, unknown>;
reportError(message: string): void;
showPromptSyntaxHighlighting: boolean;
@@ -20,10 +17,7 @@ export interface VideoUiAdapter {
}
/** The adapter's callbacks, which are stable for the lifetime of a project. */
-export type VideoUiActions = Pick<
- VideoUiAdapter,
- 'patchPromptDraft' | 'patchValues' | 'reportError' | 'touchGalleryImages'
->;
+export type VideoUiActions = Pick<VideoUiAdapter, 'patchValues' | 'reportError' | 'touchGalleryImages'>;
const VideoUiContext = createContext<VideoUiAdapter | null>(null);
/**
@@ -35,10 +29,10 @@ const VideoUiContext = createContext<VideoUiAdapter | null>(null);
const VideoUiActionsContext = createContext<VideoUiActions | null>(null);
export const VideoUiProvider = ({ adapter, children }: { adapter: VideoUiAdapter; children: ReactNode }) => {
- const { patchPromptDraft, patchValues, reportError, touchGalleryImages } = adapter;
+ const { patchValues, reportError, touchGalleryImages } = adapter;
const actions = useMemo<VideoUiActions>(
- () => ({ patchPromptDraft, patchValues, reportError, touchGalleryImages }),
- [patchPromptDraft, patchValues, reportError, touchGalleryImages]
+ () => ({ patchValues, reportError, touchGalleryImages }),
+ [patchValues, reportError, touchGalleryImages]
);
return (
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
index 1a585d66fe..e2ffa431e8 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
@@ -112,7 +112,7 @@ export const VideoWidgetView = () => {
const selection = useVideoUi();
const models = useModelsSelector((snapshot) => snapshot.models);
const modelsStatus = useModelsSelector((snapshot) => snapshot.status);
- const { patchPromptDraft: patchDraft, patchValues, projectId, promptDraft, rawValues } = selection;
+ const { patchValues, projectId, rawValues } = selection;
// Normalizing and reconciling against the model list is the widget's most
// expensive derivation; it must not run on unrelated re-renders, and a fresh
// `values` identity would re-render every section below.
@@ -353,13 +353,14 @@ export const VideoWidgetView = () => {
loras={values.loras}
model={values.model}
negativeHelpText={policy.prompt.negativeHelpText}
+ negativePrompt={values.negativePrompt}
+ negativePromptEnabled={values.negativePromptEnabled}
negativePromptHeightPx={values.negativePromptHeightPx}
negativeVisible={policy.prompt.negativeVisible}
+ positivePrompt={values.positivePrompt}
positivePromptHeightPx={values.positivePromptHeightPx}
projectId={projectId}
- promptDraft={promptDraft}
showSyntaxHighlighting={selection.showPromptSyntaxHighlighting}
- onPatchPromptDraft={patchDraft}
onPatchValues={patch}
/>
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.test.ts
new file mode 100644
index 0000000000..f304280eea
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.test.ts
@@ -0,0 +1,127 @@
+import type { GalleryVideoItem } from '@features/gallery';
+import type { ModelConfig } from '@features/models';
+import type { WorkbenchCommands } from '@workbench/workbenchStore';
+
+import { accountLifecycle } from '@platform/state/accountLifecycle';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+const galleryApi = vi.hoisted(() => ({
+ galleryImages: { metadata: vi.fn(), resolveMany: vi.fn() },
+ galleryItems: { resolve: vi.fn() },
+ galleryVideos: { metadata: vi.fn() },
+}));
+
+vi.mock('@features/gallery', () => galleryApi);
+
+import { createDefaultVideoWidgetValues } from '@features/video';
+
+import { executeVideoRecall } from './executeVideoRecall';
+
+const wanModel = {
+ base: 'wan',
+ file_size: 1,
+ format: 'diffusers',
+ hash: 'wan-hash',
+ key: 'wan-t2v',
+ name: 'Wan 2.2 t2v_a14b',
+ path: '/models/wan',
+ source: 'local',
+ source_type: 'path',
+ type: 'main',
+ variant: 't2v_a14b',
+} as ModelConfig;
+
+const item: GalleryVideoItem = {
+ boardId: 'none',
+ category: 'general',
+ createdAt: '2026-08-26T00:00:00.000Z',
+ durationSeconds: 5,
+ fullUrl: '/clip.mp4',
+ height: 720,
+ isIntermediate: false,
+ kind: 'video',
+ name: 'clip.mp4',
+ starred: false,
+ thumbnailUrl: '/clip-thumb.jpg',
+ width: 1280,
+};
+
+const metadata = {
+ cfg_scale: 5,
+ generation_mode: 'wan_t2v',
+ height: 720,
+ model: { base: 'wan', key: wanModel.key, name: wanModel.name, type: 'main' },
+ negative_prompt: 'blurry',
+ num_frames: 81,
+ positive_prompt: 'a fox running',
+ seed: 4321,
+ steps: 40,
+ width: 1280,
+};
+
+const createCommands = () => {
+ const patchValues = vi.fn();
+ const commands = {
+ notifications: { add: vi.fn(), reportError: vi.fn() } as unknown as WorkbenchCommands['notifications'],
+ widgets: { patchValues } as unknown as WorkbenchCommands['widgets'],
+ };
+
+ return { commands, patchValues };
+};
+
+describe('executeVideoRecall', () => {
+ beforeEach(() => {
+ accountLifecycle.activate('test-account');
+ galleryApi.galleryVideos.metadata.mockReset();
+ galleryApi.galleryImages.resolveMany.mockReset();
+ galleryApi.galleryItems.resolve.mockReset();
+ });
+
+ it('writes only the prompt keys for a prompts-only recall', async () => {
+ galleryApi.galleryVideos.metadata.mockResolvedValue(metadata);
+ const { commands, patchValues } = createCommands();
+ // A panel whose recorded main is NOT installed: `getCurrentVideoValues`
+ // re-snaps it onto another family, so a whole-values write here would push
+ // that transition into the store behind a "prompts" toast.
+ const videoValues = { ...createDefaultVideoWidgetValues([wanModel]), numFrames: 41, steps: 4 };
+
+ const didRecall = await executeVideoRecall({
+ commands,
+ getVideoValues: () => videoValues as unknown as Record<string, unknown>,
+ item,
+ kind: 'prompts',
+ models: [],
+ });
+
+ expect(didRecall).toBe(true);
+ expect(patchValues).toHaveBeenCalledTimes(1);
+ expect(patchValues).toHaveBeenCalledWith(
+ 'video',
+ { negativePrompt: 'blurry', negativePromptEnabled: true, positivePrompt: 'a fox running' },
+ undefined
+ );
+ });
+
+ it('writes the whole values object when the recall carries more than prompts', async () => {
+ galleryApi.galleryVideos.metadata.mockResolvedValue(metadata);
+ const { commands, patchValues } = createCommands();
+ const videoValues = createDefaultVideoWidgetValues([wanModel]);
+
+ const didRecall = await executeVideoRecall({
+ commands,
+ getVideoValues: () => videoValues as unknown as Record<string, unknown>,
+ item,
+ kind: 'all',
+ models: [wanModel],
+ });
+
+ expect(didRecall).toBe(true);
+ expect(patchValues).toHaveBeenCalledTimes(1);
+ // Prompts ride along with everything else — they are ordinary video values.
+ expect(patchValues.mock.calls[0]?.[1]).toMatchObject({
+ negativePrompt: 'blurry',
+ positivePrompt: 'a fox running',
+ seed: 4321,
+ });
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts
index c88ccdd4b6..325f498df3 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts
@@ -82,7 +82,7 @@ export const executeVideoRecall = async ({
owner: callerOwner,
projectId,
}: {
- commands: Pick<WorkbenchCommands, 'generation' | 'notifications' | 'widgets'>;
+ commands: Pick<WorkbenchCommands, 'notifications' | 'widgets'>;
getVideoValues: () => Record<string, unknown>;
item: GalleryVideoItem;
kind: VideoRecallKind;
@@ -233,15 +233,25 @@ export const executeVideoRecall = async ({
return false;
}
- // Prompts live in the shared project draft; everything else is widget values.
- if (result.promptPatch) {
- commands.generation.patchPromptDraft(result.promptPatch, 'video', projectId);
- }
- // A prompts-only recall changes no widget values — skip the whole-values
- // write (and the lost-update window it would widen). The builder always
- // returns a fresh copy, so the fields list, not object identity, is the
- // signal.
- if (result.fields.some((field) => field !== 'prompts')) {
+ // Prompts are Video's own widget values now, not the draft Generate and
+ // Upscale share — but a prompts-only recall must still write ONLY the prompt
+ // keys. `result.values` is the panel re-snapshotted through
+ // `syncVideoWidgetValuesWithModels`, so writing it wholesale would push an
+ // unrelated model-family transition into the store behind a toast that says
+ // "prompts" (uninstall the recorded main, recall prompts, and the panel's
+ // frames/fps/resolution/LoRAs all reset). It would also widen the
+ // lost-update window against a concurrent recall still awaiting its media.
+ if (result.fields.every((field) => field === 'prompts')) {
+ commands.widgets.patchValues(
+ 'video',
+ {
+ negativePrompt: result.values.negativePrompt,
+ negativePromptEnabled: result.values.negativePromptEnabled,
+ positivePrompt: result.values.positivePrompt,
+ },
+ projectId
+ );
+ } else {
commands.widgets.patchValues('video', { ...result.values }, projectId);
}
commands.notifications.add({
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
index 4b120b4a85..d75b55c739 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
@@ -154,7 +154,7 @@ describe('buildVideoRecallSettings', () => {
const catalog = [WAN_T2V, WAN_I2V, h3Model(), LIGHTNING_HIGH, LIGHTNING_LOW];
const currentValues = { ...createDefaultVideoWidgetValues([h3Model()]) };
- it('routes prompts into the shared draft patch, not the widget values', () => {
+ it('recalls prompts into the video widget values, leaving everything else alone', () => {
const result = buildVideoRecallSettings({
currentValues,
kind: 'prompts',
@@ -163,12 +163,12 @@ describe('buildVideoRecallSettings', () => {
});
expect(result?.fields).toEqual(['prompts']);
- expect(result?.promptPatch).toEqual({
+ expect(result?.values).toEqual({
+ ...currentValues,
negativePrompt: 'blurry',
negativePromptEnabled: true,
positivePrompt: 'a red fox running',
});
- expect(result?.values).toEqual(currentValues);
});
it('recalls only the seed for the seed verb', () => {
@@ -340,7 +340,7 @@ describe('buildVideoRecallSettings', () => {
models: catalog,
});
- expect(empty?.promptPatch).toEqual({ positivePrompt: 'a red fox running' });
+ expect(empty?.values).toEqual({ ...currentValues, positivePrompt: 'a red fox running' });
const explicitNull = buildVideoRecallSettings({
currentValues,
@@ -349,7 +349,7 @@ describe('buildVideoRecallSettings', () => {
models: catalog,
});
- expect(explicitNull?.promptPatch).toMatchObject({ negativePrompt: '', negativePromptEnabled: false });
+ expect(explicitNull?.values).toMatchObject({ negativePrompt: '', negativePromptEnabled: false });
});
it('clears current LoRAs when the recorded ones are no longer installed', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
index 14a503eb95..638083a74b 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
@@ -4,7 +4,6 @@ import type {
LoraModelConfig,
MainModelConfig,
} from '@features/generation/contracts';
-import type { ProjectPromptDraftPatch } from '@features/generation/settings';
import type { VideoAspectRatioId, VideoTargetResolution, VideoWidgetValues } from '@features/video';
import { isLoraCompatibleWithModel, isLoraModelConfig, SEED_MAX } from '@features/generation/settings';
@@ -75,8 +74,6 @@ export type VideoRecalledField =
export interface VideoRecallResult {
fields: VideoRecalledField[];
- /** Prompt fields live in the shared project draft, not the widget values. */
- promptPatch: ProjectPromptDraftPatch | null;
values: VideoWidgetValues;
}
@@ -361,7 +358,10 @@ export const buildVideoRecallSettings = ({
const fields: VideoRecalledField[] = [];
let values: VideoWidgetValues = { ...currentValues };
- let promptPatch: ProjectPromptDraftPatch | null = null;
+ // Held aside rather than folded into `values` where it is read: the model
+ // transition below rebuilds `values` from the recalled family's defaults, and
+ // recalled prompts must survive that. Merged in at each return instead.
+ let promptPatch: Partial<VideoWidgetValues> | null = null;
const mediaNames: VideoRecallMediaNames = {
firstFrameName: null,
lastFrameName: null,
@@ -389,7 +389,7 @@ export const buildVideoRecallSettings = ({
}
if (kind === 'prompts') {
- return fields.length > 0 ? { fields, mediaNames, promptPatch, values } : null;
+ return fields.length > 0 ? { fields, mediaNames, values: { ...values, ...promptPatch } } : null;
}
if (kind === 'all' || kind === 'seed') {
@@ -402,7 +402,7 @@ export const buildVideoRecallSettings = ({
}
if (kind === 'seed') {
- return fields.length > 0 ? { fields, mediaNames, promptPatch, values } : null;
+ return fields.length > 0 ? { fields, mediaNames, values: { ...values, ...promptPatch } } : null;
}
// all / remix from here on.
@@ -424,7 +424,7 @@ export const buildVideoRecallSettings = ({
if (!model) {
// Without any model, nothing below can validate; prompts/seed may still
// have been recalled.
- return fields.length > 0 ? { fields, mediaNames, promptPatch, values } : null;
+ return fields.length > 0 ? { fields, mediaNames, values: { ...values, ...promptPatch } } : null;
}
const numFrames = getInteger(metadata, 'num_frames');
@@ -551,7 +551,7 @@ export const buildVideoRecallSettings = ({
fields.push('media');
}
- return fields.length > 0 ? { fields, mediaNames, promptPatch, values } : null;
+ return fields.length > 0 ? { fields, mediaNames, values: { ...values, ...promptPatch } } : null;
};
const VIDEO_RECALL_TITLES: Record<VideoRecallKind, string> = {
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index b4fb06cf4a..af79fbcc22 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -2938,6 +2938,83 @@ describe('workbenchReducer Phase 5 generation flow', () => {
expect(getProjectWidgetValues(getActiveProject(nextState), 'upscale')).toBe(beforeUpscale);
});
+ it('keeps the Video prompt independent of the Generate prompt in both directions', () => {
+ let state = createInitialWorkbenchState();
+
+ state = workbenchReducer(state, {
+ sourceId: 'generate',
+ type: 'patchProjectPromptDraft',
+ values: { negativePrompt: 'blurry', negativePromptEnabled: true, positivePrompt: 'a still portrait' },
+ });
+ state = workbenchReducer(state, {
+ type: 'patchWidgetValues',
+ values: { negativePrompt: 'static camera', negativePromptEnabled: false, positivePrompt: 'a fox running' },
+ widgetId: 'video',
+ });
+
+ // Video writes its own widget values and leaves the shared draft alone...
+ expect(getProjectWidgetValues(getActiveProject(state), 'generate')).toMatchObject({
+ negativePrompt: 'blurry',
+ negativePromptEnabled: true,
+ positivePrompt: 'a still portrait',
+ });
+ expect(getProjectWidgetValues(getActiveProject(state), 'video')).toMatchObject({
+ negativePrompt: 'static camera',
+ negativePromptEnabled: false,
+ positivePrompt: 'a fox running',
+ });
+
+ // ...and a later Generate edit does not reach back into Video.
+ const beforeVideo = getProjectWidgetValues(getActiveProject(state), 'video');
+
+ state = workbenchReducer(state, {
+ sourceId: 'generate',
+ type: 'patchProjectPromptDraft',
+ values: { positivePrompt: 'a still landscape' },
+ });
+
+ expect(getProjectWidgetValues(getActiveProject(state), 'video')).toBe(beforeVideo);
+ });
+
+ it('submits the Video prompt, not the Generate prompt, on a video invocation', () => {
+ const wanModel: ModelConfig = {
+ base: 'wan',
+ file_size: 1,
+ format: 'diffusers',
+ hash: 'wan-t2v-hash',
+ key: 'wan-t2v_a14b-diffusers',
+ name: 'Wan 2.2 t2v_a14b',
+ path: 'wan-t2v_a14b-diffusers',
+ source: 'wan-t2v_a14b-diffusers',
+ source_type: 'path',
+ type: 'main',
+ variant: 't2v_a14b',
+ };
+ let state = createInitialWorkbenchState();
+
+ state = workbenchReducer(state, {
+ sourceId: 'generate',
+ type: 'patchProjectPromptDraft',
+ values: { negativePrompt: 'blurry', positivePrompt: 'a still portrait' },
+ });
+ state = workbenchReducer(state, {
+ type: 'patchWidgetValues',
+ values: { model: wanModel, negativePrompt: 'static camera', positivePrompt: 'a fox running' },
+ widgetId: 'video',
+ });
+ state = workbenchReducer(state, { sourceId: 'video', type: 'setInvocationSource' });
+ state = workbenchReducer(state, { destination: 'gallery', type: 'setInvocationDestination' });
+ state = workbenchReducer(state, {
+ backendSupportsCancellation: true,
+ models: [wanModel],
+ type: 'submitInvocationSnapshot',
+ });
+
+ const submission = getActiveProject(state).queue.items[0]?.snapshot.widgetStates.video.values;
+
+ expect(submission).toMatchObject({ negativePrompt: 'static camera', positivePrompt: 'a fox running' });
+ });
+
it('deduplicates prompt history by prompt pair and moves the newest submission to the top', () => {
let state = primeGenerate(undefined, { negativePrompt: 'low quality', positivePrompt: 'a cat' });
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index c02b28419d..ceb4e65c25 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -253,7 +253,7 @@ type WorkbenchReducerAction =
| {
type: 'patchProjectPromptDraft';
values: ProjectPromptDraftPatch;
- sourceId: 'generate' | 'upscale' | 'video';
+ sourceId: 'generate' | 'upscale';
projectId?: string;
origin?: WorkbenchActionOrigin;
}
@@ -2408,11 +2408,9 @@ const compileInvocationSnapshot = (
return null;
}
- const syncedValues = models ? syncVideoWidgetValuesWithModels(values, models) : values;
- const currentValues: VideoWidgetValues = {
- ...syncedValues,
- ...getPromptDraftFromValues(getProjectWidgetValues(project, 'generate')),
- };
+ // Video's prompt is its own widget value, deliberately independent of the
+ // draft Generate and Upscale share: no draft is merged in here.
+ const currentValues: VideoWidgetValues = models ? syncVideoWidgetValuesWithModels(values, models) : values;
if (!currentValues.model || getVideoWidgetValidationReasons(currentValues, models).length > 0) {
return null;