Split prompts into pre/prompt/post and tidy the AIGen video form.

Keep wrappers off the library mid-prompt so Use as input and Extend restore the same split, send stills to xAIGen as hidden inputs, and stop the two-column library from growing with the list.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-01 18:39:02 -05:00
co-authored by Cursor
parent ed04dcfee3
commit f788fd4bb4
22 changed files with 753 additions and 199 deletions
+7 -3
View File
@@ -8,6 +8,7 @@ import { imageDimensions } from '~/server/utils/resolution'
import { emitChainJob } from '~/server/utils/watch'
import { saveStill, stillChainName } from '~/server/utils/library'
import { comfyJobPrefix } from '~/utils/outputNames'
import { composePromptParts } from '~/utils/promptParts'
export type EditImageFile = { filename: string; data: Buffer; type?: string }
@@ -66,7 +67,8 @@ export async function runEdit(job: Job, params: EditRunParams) {
for (let index = 0; index < prompts.length; index++) {
if (job.status === 'cancelled') throw new Error('Job interrupted.')
if (index > 0 && library.stopAfterCurrent === true) break
const prompt = (batch || index === 0) ? composeFillPrompt(prompts[index], filled.padded) : prompts[index]
const mid = (batch || index === 0) ? composeFillPrompt(prompts[index], filled.padded) : prompts[index]
const prompt = composePromptParts(library.promptPre || '', mid, library.promptPost || '')
const last = index === prompts.length - 1
if (index > 0) {
await ensureComfyReady((status) => {
@@ -79,7 +81,7 @@ export async function runEdit(job: Job, params: EditRunParams) {
}, { skipBusyWait: true })
}
const seed = index === 0 ? params.seed : Math.floor(Math.random() * 2_147_483_647)
library.prompt = prompt
library.prompt = mid
library.seed = seed
library.chainIndex = index
library.chainStep = index + 1
@@ -164,7 +166,9 @@ export async function runEdit(job: Job, params: EditRunParams) {
hideInput: job.hideThumbnail === true,
role: 'output',
name: passName || undefined,
prompt,
prompt: mid,
promptPre: library.promptPre,
promptPost: library.promptPost,
familyId: library.familyId,
parentStillId: batch ? library.stillId : parentStillId,
chainIndex: index,
+4 -1
View File
@@ -8,6 +8,7 @@ import { imageDimensions } from '~/server/utils/resolution'
import { emitChainJob } from '~/server/utils/watch'
import { saveStill, stillChainName } from '~/server/utils/library'
import { comfyJobPrefix } from '~/utils/outputNames'
import { composePromptParts } from '~/utils/promptParts'
import { parseImageV2Engine, type ImageV2Engine, type ImageV2Mode, type ImageV2Task } from '~/utils/imageV2'
import type { EditImageFile } from '~/server/utils/imageChain'
@@ -194,7 +195,7 @@ export async function runEditV2(job: Job, params: EditV2RunParams) {
mode: params.mode,
engine,
task: params.task,
prompt,
prompt: composePromptParts(library.promptPre || '', prompt, library.promptPost || ''),
negative: params.negative,
imageAName: uploaded?.name,
imageBName: uploadedRef?.name,
@@ -264,6 +265,8 @@ export async function runEditV2(job: Job, params: EditV2RunParams) {
role: 'output',
name: passName || undefined,
prompt,
promptPre: library.promptPre,
promptPost: library.promptPost,
familyId: library.familyId,
parentStillId: batch ? (params.sourceStillId || library.stillId) : parentStillId,
chainIndex: index,
+3
View File
@@ -53,6 +53,9 @@ export interface Job {
folderLocked?: boolean
name?: string
prompt: string
promptMid?: string
promptPre?: string
promptPost?: string
aspect: string
width: number
height: number
+19 -1
View File
@@ -58,6 +58,8 @@ export interface LibraryClip {
permanenceRefs?: PermanenceRef[]
loraName?: string
loraStack?: import('~/utils/loras').LoraStackItem[]
promptPre?: string
promptPost?: string
}
export type StillRole = 'input' | 'output'
@@ -74,6 +76,8 @@ export interface LibraryStill {
role: StillRole
name?: string
prompt?: string
promptPre?: string
promptPost?: string
familyId?: string
parentStillId?: string
chainIndex?: number
@@ -220,6 +224,8 @@ function normalizeStill(still: LibraryStill): LibraryStill {
role: stillRole(still),
name: still.name,
prompt: still.prompt,
promptPre: still.promptPre,
promptPost: still.promptPost,
familyId: still.familyId,
parentStillId: still.parentStillId,
chainIndex: still.chainIndex,
@@ -1210,6 +1216,8 @@ export async function saveStill(params: {
role?: StillRole
name?: string
prompt?: string
promptPre?: string
promptPost?: string
familyId?: string
parentStillId?: string
chainIndex?: number
@@ -1238,6 +1246,8 @@ export async function saveStill(params: {
item.role = role
if (name) item.name = name
if (prompt) item.prompt = prompt
if (params.promptPre != null) item.promptPre = params.promptPre || undefined
if (params.promptPost != null) item.promptPost = params.promptPost || undefined
if (params.familyId) item.familyId = params.familyId
if (params.parentStillId) item.parentStillId = params.parentStillId
if (typeof params.chainIndex === 'number') item.chainIndex = params.chainIndex
@@ -1247,6 +1257,8 @@ export async function saveStill(params: {
existing.role = role
if (name) existing.name = name
if (prompt) existing.prompt = prompt
if (params.promptPre != null) existing.promptPre = params.promptPre || undefined
if (params.promptPost != null) existing.promptPost = params.promptPost || undefined
if (nextSettings) existing.settings = nextSettings
}
return existing
@@ -1266,6 +1278,8 @@ export async function saveStill(params: {
role,
name: params.name?.trim().slice(0, 80) || undefined,
prompt: params.prompt || undefined,
promptPre: params.promptPre || undefined,
promptPost: params.promptPost || undefined,
familyId: params.familyId,
parentStillId: params.parentStillId,
chainIndex: params.chainIndex,
@@ -1554,6 +1568,8 @@ export async function saveClip(params: {
permanenceRefs?: PermanenceRef[]
loraName?: string
loraStack?: import('~/utils/loras').LoraStackItem[]
promptPre?: string
promptPost?: string
segmentFirstFrame?: Buffer
}) {
const catalog = readCatalog(params.ownerKey)
@@ -1587,7 +1603,9 @@ export async function saveClip(params: {
globalLocks: params.globalLocks,
permanenceRefs: params.permanenceRefs?.length ? normalizePermanenceRefs(params.permanenceRefs) : undefined,
loraName: params.loraName || undefined,
loraStack: params.loraStack?.length ? params.loraStack : undefined
loraStack: params.loraStack?.length ? params.loraStack : undefined,
promptPre: params.promptPre || undefined,
promptPost: params.promptPost || undefined
}
mkdirSync(clipDir(params.ownerKey, clip.id), { recursive: true })
const videoPath = clipVideoPath(params.ownerKey, clip.id)
+8
View File
@@ -14,6 +14,8 @@ export interface PendingJob {
folderLocked?: boolean
name?: string
prompt: string
promptPre?: string
promptPost?: string
aspect: string
width: number
height: number
@@ -107,6 +109,8 @@ export function pendingFromJob(job: Job, overrides: Partial<PendingJob> = {}): P
folderLocked: library.folderLocked,
name: library.name,
prompt: library.prompt,
promptPre: library.promptPre,
promptPost: library.promptPost,
aspect: library.aspect,
width: library.width,
height: library.height,
@@ -164,6 +168,8 @@ export function libraryFromPending(pending: PendingJob): NonNullable<Job['librar
folderLocked: pending.folderLocked,
name: pending.name,
prompt: pending.prompt,
promptPre: pending.promptPre,
promptPost: pending.promptPost,
aspect: pending.aspect,
width: pending.width,
height: pending.height,
@@ -313,6 +319,8 @@ export async function completePendingIfReady(pending: PendingJob) {
folderId: pending.folderId,
name: pending.name,
prompt: pending.prompt,
promptPre: pending.promptPre,
promptPost: pending.promptPost,
aspect: pending.aspect,
width: pending.width,
height: pending.height,
+6
View File
@@ -14,6 +14,9 @@ export type StudioJobKind = 'video' | 'edit'
export interface StudioJobPayload {
prompt: string
promptMid?: string
promptPre?: string
promptPost?: string
name: string
folderId: string
aspect: string
@@ -942,6 +945,9 @@ export async function startStudioJob(item: StudioJob) {
folderLocked: payload.folderLocked,
name: payload.name,
prompt: payload.prompt,
promptMid: payload.promptMid,
promptPre: payload.promptPre,
promptPost: payload.promptPost,
aspect: payload.aspect,
width: payload.width,
height: payload.height,
+2 -1
View File
@@ -22,6 +22,7 @@ import {
updateShotQueue
} from '~/server/utils/shotQueue'
import { composeShotPrompt, allowIdentityRefs, type PermanenceRef } from '~/utils/globalLocks'
import { composePromptParts } from '~/utils/promptParts'
import { persistLoraFields, ensureComfyLoraNames } from '~/server/utils/loras'
import { readLoraStack, resolveLoraStack } from '~/utils/loras'
import type { LoraStackItem } from '~/utils/loras'
@@ -186,7 +187,7 @@ export async function queueMiniMax(
const shotIndex = job.library?.chainIndex || 0
const composedPrompt = composeShotPrompt({
globalLocks: job.library?.globalLocks || params.globalLocks,
prompt: params.prompt,
prompt: composePromptParts(job.library?.promptPre || '', params.prompt, job.library?.promptPost || ''),
shotIndex,
familyRefs: job.library?.permanenceRefs || params.permanenceRefs,
shotRefs: job.library?.shotPermanenceRefs?.[shotIndex] || params.shotPermanenceRefs?.[shotIndex]
+3 -1
View File
@@ -216,7 +216,9 @@ export function watchComfyJob(job: Job, options: { persist?: boolean } = {}): Pr
ownerKey: job.library.ownerKey,
folderId: job.library.folderId,
name: job.library.name,
prompt: job.library.prompt,
prompt: job.library.promptMid || job.library.prompt,
promptPre: job.library.promptPre,
promptPost: job.library.promptPost,
aspect: job.library.aspect,
width: job.library.width,
height: job.library.height,