Add clickable keep-prompt snippets for video and image.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-08-31 20:39:08 -05:00
co-authored by Cursor
parent 529598cef2
commit a3380870ad
7 changed files with 407 additions and 12 deletions
+23 -3
View File
@@ -10,6 +10,13 @@ import { normalizePermanenceRefs, type PermanenceRef } from '~/utils/globalLocks
import { normalizeStillSettings, type StillGenerationSettings } from '~/utils/libraryGeneration'
import { buildOutputBaseName, nextUniqueName, normalizeLoraAliases, sanitizeLoraAlias } from '~/utils/outputNames'
import { loraIdentityKey, normalizeLoraTriggers, sanitizeLoraTrigger, type LoraStackItem } from '~/utils/loras'
import {
emptyKeepPrompts,
normalizeKeepPromptList,
normalizeKeepPrompts,
type KeepPromptKind,
type KeepPromptLists
} from '~/utils/keepPrompts'
const scryptAsync = promisify(scrypt)
@@ -132,6 +139,7 @@ interface Catalog {
drafts: RetryDraft[]
loraAliases: Record<string, string>
loraTriggers: Record<string, string>
keepPrompts: KeepPromptLists
}
const writeChains = new Map<string, Promise<unknown>>()
@@ -172,7 +180,8 @@ function emptyCatalog(): Catalog {
stills: [],
drafts: [],
loraAliases: {},
loraTriggers: {}
loraTriggers: {},
keepPrompts: emptyKeepPrompts()
}
}
@@ -233,7 +242,8 @@ function normalizeCatalog(parsed: Partial<Catalog> & { passwordHash?: string | n
stills: Array.isArray(parsed.stills) ? parsed.stills.map(normalizeStill) : [],
drafts: Array.isArray(parsed.drafts) ? parsed.drafts : [],
loraAliases: normalizeLoraAliases(parsed.loraAliases),
loraTriggers: normalizeLoraTriggers(parsed.loraTriggers)
loraTriggers: normalizeLoraTriggers(parsed.loraTriggers),
keepPrompts: normalizeKeepPrompts(parsed.keepPrompts)
}
}
@@ -390,6 +400,15 @@ export function getLoraTriggers(owner: string) {
return { ...(readCatalog(owner).loraTriggers || {}) }
}
export async function setKeepPrompts(owner: string, kind: KeepPromptKind, items: unknown) {
const list = normalizeKeepPromptList(items)
return mutate(owner, (catalog) => {
if (!catalog.keepPrompts) catalog.keepPrompts = emptyKeepPrompts()
catalog.keepPrompts[kind] = list
return { ...catalog.keepPrompts }
})
}
export async function setLoraTrigger(owner: string, identity: string, trigger: string) {
const key = loraIdentityKey(identity) || String(identity || '').trim().toLowerCase()
if (!key) throw createError({ statusCode: 400, statusMessage: 'A LoRA file is required' })
@@ -506,7 +525,8 @@ export function publicLibrary(event: H3Event, opts?: { light?: boolean }) {
.map(still => ({ ...still, role: stillRole(still) })),
drafts: catalog.drafts,
loraAliases: catalog.loraAliases || {},
loraTriggers: catalog.loraTriggers || {}
loraTriggers: catalog.loraTriggers || {},
keepPrompts: catalog.keepPrompts || emptyKeepPrompts()
}
}