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 { createGenerateWidgetSyncRuntime, type GenerateWidgetSyncProjectSnapshot } from '@features/generation/runtime';
import { ensureModelsLoaded, getModelsSnapshot, subscribeModels } from '@features/models';
import {
ensureArchitectureCapabilitiesLoaded,
getArchitectureCapabilitiesSnapshot,
subscribeArchitectureCapabilities,
} from '@features/models/architecturesStore';
import { useMountEffect } from '@platform/react/useMountEffect';
import { createProjectedExternalStore } from '@platform/state/projectedExternalStore';
import { useQueryClient } from '@tanstack/react-query';
import { getProjectWidgetValues } from '@workbench/widgetState';
import { useWorkbenchInternalStore } from '@workbench/WorkbenchContext';
/** App-owned production composition of Generation, Models, Query, and Workbench. */
export const GenerateWidgetSyncRuntime = () => {
const store = useWorkbenchInternalStore();
const queryClient = useQueryClient();
useMountEffect(() => {
const project = createProjectedExternalStore({
isEqual: (left: GenerateWidgetSyncProjectSnapshot, right: GenerateWidgetSyncProjectSnapshot) =>
left.id === right.id && left.values === right.values,
select: (snapshot) => ({
id: snapshot.activeProject.id,
values: getProjectWidgetValues(snapshot.activeProject, 'generate'),
}),
source: { getSnapshot: store.getSnapshot, subscribe: store.subscribe },
});
const models = createProjectedExternalStore({
select: (snapshot) => snapshot.models,
source: { getSnapshot: getModelsSnapshot, subscribe: subscribeModels },
});
const capabilitiesLoaded = createProjectedExternalStore({
select: (snapshot) => snapshot.status === 'loaded',
source: { getSnapshot: getArchitectureCapabilitiesSnapshot, subscribe: subscribeArchitectureCapabilities },
});
const runtime = createGenerateWidgetSyncRuntime({
capabilitiesLoaded,
models,
patchValues: store.commands.generation.patchSettings,
project,
queryClient,
});
// Fetch capabilities at boot so generation does not wait for the panel's first mount.
void ensureArchitectureCapabilitiesLoaded();
void ensureModelsLoaded();
return () => runtime.dispose();
});
return null;
};