Keep family pre/post text on shot queues and wrap the mid prompt at Comfy time.
Later shots were starting a new job without those wrappers, so only the first clip got them. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+15
-5
@@ -15,6 +15,11 @@ export function composePromptParts(pre: string, prompt: string, post: string) {
|
||||
.join('\n\n')
|
||||
}
|
||||
|
||||
export type PromptWrapperFields = {
|
||||
promptPre?: string
|
||||
promptPost?: string
|
||||
}
|
||||
|
||||
/** Combine wrappers for Comfy. If mid already includes pre/post, do not wrap twice. */
|
||||
export function joinPromptParts(pre?: string, mid?: string, post?: string) {
|
||||
const parts = restorePromptParts(mid || '', {
|
||||
@@ -25,6 +30,16 @@ export function joinPromptParts(pre?: string, mid?: string, post?: string) {
|
||||
return composePromptParts(parts.pre, parts.prompt, parts.post)
|
||||
}
|
||||
|
||||
/** Prefer stored mid so an already-joined prompt is not the source of truth. */
|
||||
export function wrappedPromptForComfy(
|
||||
wrappers?: PromptWrapperFields | null,
|
||||
mid?: string,
|
||||
fallback?: string
|
||||
) {
|
||||
const body = sanitizePromptPart(mid || '').trim() || sanitizePromptPart(fallback || '').trim()
|
||||
return joinPromptParts(wrappers?.promptPre, body, wrappers?.promptPost)
|
||||
}
|
||||
|
||||
export function applyPromptParts(parts: PromptParts, middle: string) {
|
||||
return composePromptParts(parts.pre, middle, parts.post)
|
||||
}
|
||||
@@ -46,11 +61,6 @@ export function restorePromptParts(saved: string, stored?: Partial<PromptParts>
|
||||
}
|
||||
}
|
||||
|
||||
export type PromptWrapperFields = {
|
||||
promptPre?: string
|
||||
promptPost?: string
|
||||
}
|
||||
|
||||
function hasWrapperKey(item: object | null | undefined, key: 'promptPre' | 'promptPost') {
|
||||
return Boolean(item && Object.prototype.hasOwnProperty.call(item, key))
|
||||
}
|
||||
|
||||
+8
-4
@@ -63,6 +63,7 @@ export type QueuedInspectPayload = {
|
||||
lyrics?: string
|
||||
instrumental?: boolean
|
||||
lyricsStrength?: number
|
||||
musicEngine?: string
|
||||
}
|
||||
|
||||
export type QueuedInspectJob = {
|
||||
@@ -128,9 +129,11 @@ export function applyQueuedShots(kind: string, shots: QueuedShotDraft[], payload
|
||||
}
|
||||
next.prompt = shots[0]?.prompt || ''
|
||||
next.duration = Number(shots[0]?.duration) || next.duration || 5
|
||||
next.extensions = shots.slice(1).map((item) => {
|
||||
const fields = persistLoraFields(item.loraStack || item.loraName)
|
||||
next.extensions = shots.slice(1).map((item, index) => {
|
||||
const prev = payload.extensions?.[index]
|
||||
const fields = persistLoraFields(item.loraStack || item.loraName || prev?.loraStack || prev?.loraName)
|
||||
return {
|
||||
...prev,
|
||||
prompt: item.prompt || '',
|
||||
duration: Number(item.duration) || 5,
|
||||
loraName: fields.loraName,
|
||||
@@ -182,7 +185,7 @@ export function queuedJobCopyText(job: QueuedInspectJob) {
|
||||
else lines.push(line('Lyrics', payload.lyrics))
|
||||
} else {
|
||||
if (payload.promptPre) lines.push(line('Prompt pre', payload.promptPre))
|
||||
lines.push(line('Prompt', payload.prompt || job.prompt))
|
||||
lines.push(line('Prompt', payload.promptMid || payload.prompt || job.prompt))
|
||||
if (payload.promptPost) lines.push(line('Prompt post', payload.promptPost))
|
||||
const shots = queuedJobShots(payload, job.kind)
|
||||
if (shots.length > 1) {
|
||||
@@ -220,7 +223,8 @@ export function queuedJobPresetBody(job: QueuedInspectJob, name: string) {
|
||||
duration: clampMusicDuration(payload.duration),
|
||||
steps: clampMusicSteps(payload.steps),
|
||||
seed: payload.seed,
|
||||
cfg: payload.cfg
|
||||
cfg: payload.cfg,
|
||||
engine: payload.musicEngine || payload.engine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user