Join pre/prompt/post for Comfy, stop zero-size generates snapping to a small square, and give the phone library a real closeable preview.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+21
-5
@@ -15,6 +15,16 @@ export function composePromptParts(pre: string, prompt: string, post: string) {
|
||||
.join('\n\n')
|
||||
}
|
||||
|
||||
/** 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 || '', {
|
||||
pre: pre || '',
|
||||
prompt: mid || '',
|
||||
post: post || ''
|
||||
})
|
||||
return composePromptParts(parts.pre, parts.prompt, parts.post)
|
||||
}
|
||||
|
||||
export function applyPromptParts(parts: PromptParts, middle: string) {
|
||||
return composePromptParts(parts.pre, middle, parts.post)
|
||||
}
|
||||
@@ -45,7 +55,7 @@ function hasWrapperKey(item: object | null | undefined, key: 'promptPre' | 'prom
|
||||
return Boolean(item && Object.prototype.hasOwnProperty.call(item, key))
|
||||
}
|
||||
|
||||
/** First source that actually sent the key wins, including empty string. Omitted keys fall through. */
|
||||
/** First non-empty wrapper wins. Blank strings fall through so a shot can inherit family pre/post. */
|
||||
export function resolvePromptWrappers(
|
||||
...sources: Array<PromptWrapperFields | null | undefined>
|
||||
) {
|
||||
@@ -56,12 +66,18 @@ export function resolvePromptWrappers(
|
||||
for (const source of sources) {
|
||||
if (!source) continue
|
||||
if (!sawPre && hasWrapperKey(source, 'promptPre') && source.promptPre != null) {
|
||||
promptPre = sanitizePromptPart(source.promptPre)
|
||||
sawPre = true
|
||||
const value = sanitizePromptPart(source.promptPre)
|
||||
if (value.trim()) {
|
||||
promptPre = value
|
||||
sawPre = true
|
||||
}
|
||||
}
|
||||
if (!sawPost && hasWrapperKey(source, 'promptPost') && source.promptPost != null) {
|
||||
promptPost = sanitizePromptPart(source.promptPost)
|
||||
sawPost = true
|
||||
const value = sanitizePromptPart(source.promptPost)
|
||||
if (value.trim()) {
|
||||
promptPost = value
|
||||
sawPost = true
|
||||
}
|
||||
}
|
||||
if (sawPre && sawPost) break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user