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:
+1
-1
@@ -126,7 +126,7 @@ export function clampImageV2Denoise(raw: unknown, fallback = IMAGE_V2_DENOISE_DE
|
||||
|
||||
export function snapImageV2Side(raw: unknown, fallback = IMAGE_V2_GENERATE_WIDTH) {
|
||||
const value = Number(raw)
|
||||
if (!Number.isFinite(value)) return fallback
|
||||
if (!Number.isFinite(value) || value <= 0) return fallback
|
||||
return IMAGE_V2_SIZE_SIDES.reduce((best, side) => (
|
||||
Math.abs(side - value) < Math.abs(best - value) ? side : best
|
||||
), IMAGE_V2_SIZE_SIDES[0])
|
||||
|
||||
+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