- Implemented ComfyGenerateRequest type and associated functions for generating images using various architectures and modes. - Added functions for listing generation options and handling image uploads. - Created workflows for different generation modes including SDXL, Z-Image, Z-Image Turbo, and Anima. - Introduced GenerationJobStatus component to display the status of ongoing generation jobs. - Developed MaskControls for managing mask operations and displaying mask analysis. - Created palette items for tool selection, layer management, and generation settings.
27 lines
984 B
TypeScript
27 lines
984 B
TypeScript
import { commandIds } from "@commands/ids";
|
|
import type { GenerationJobKind } from "@editor/state";
|
|
import type { AppStore } from "@editor/store";
|
|
|
|
export async function runGenerationJob(options: {
|
|
kind: GenerationJobKind;
|
|
label: string;
|
|
dispatch: AppStore["dispatch"];
|
|
task: () => Promise<void>;
|
|
}): Promise<void> {
|
|
const jobId = crypto.randomUUID();
|
|
const startedAt = Date.now();
|
|
const nextState = options.dispatch(commandIds.generationStartJob, { jobId, kind: options.kind, label: options.label, startedAt });
|
|
if (!nextState.editor.generation.jobs.some((job) => job.id === jobId && job.status === "running")) return;
|
|
|
|
try {
|
|
await options.task();
|
|
options.dispatch(commandIds.generationSucceedJob, { jobId, finishedAt: Date.now() });
|
|
} catch (reason: unknown) {
|
|
options.dispatch(commandIds.generationFailJob, {
|
|
jobId,
|
|
finishedAt: Date.now(),
|
|
error: reason instanceof Error ? reason.message : `${options.label} failed`,
|
|
});
|
|
}
|
|
}
|