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
import type { SocketHub } from '@platform/transport/socketHub';
import type { WorkbenchCommands, WorkbenchQueries } from '@workbench/workbenchStore';
import type { TFunction } from 'i18next';
import { getProjectWidgetValues } from '@workbench/widgetState';
import type { PendingRecallEvent, RecallRevealContext, RecallRuntime } from './recallEventRuntime';
import { executeRecallParameters } from './executeRecallParameters';
import { bringRecallWidgetToFront, createRecallEventRuntime } from './recallEventRuntime';
import { isRecallParametersUpdatedEvent } from './recallParameters';
/** Apply `recall_parameters_updated` events to their arrival-time project's Generate panel. */
export const createRecallParametersRuntime = ({
commands,
getSessionUserId,
hub,
queries,
replay,
reveal,
t,
}: {
commands: Pick<WorkbenchCommands, 'generation' | 'notifications' | 'widgets' | 'canvas'>;
getSessionUserId?: () => string | null;
hub: Pick<SocketHub, 'on'>;
queries: Pick<WorkbenchQueries, 'getProject' | 'getSnapshot'>;
replay?: readonly PendingRecallEvent[];
reveal: RecallRevealContext;
/** Resolves against the current language at call time; captured once, at attach. */
t: TFunction;
}): RecallRuntime =>
createRecallEventRuntime({
apply: async ({ parameters }, { models, owner, projectId }) => {
const applied = await executeRecallParameters({
commands,
canvasTarget: { commands, projectId, getProject: () => queries.getProject(projectId) ?? null },
t,
getGenerateValues: () => {
const project = queries.getProject(projectId);
return project ? getProjectWidgetValues(project, 'generate') : null;
},
models,
owner,
parameters,
projectId,
});
if (applied) {
bringRecallWidgetToFront({ commands, owner, projectId, queries, reveal, typeId: 'generate' });
}
},
area: 'recall-parameters',
commands,
eventName: 'recall_parameters_updated',
getSessionUserId,
hub,
isEvent: isRecallParametersUpdatedEvent,
queries,
replay,
});