Skip to content

Commit 364c9ce

Browse files
committed
feat: add live preview method setting for prompt execution
Allow users to override the preview method (default/none/auto/latent2rgb/taesd) from frontend settings. 'default' uses the server CLI setting. - Add PreviewMethod type using zod schema in apiSchema.ts - Add Comfy.Execution.PreviewMethod setting with combo options - Read preview method setting inside queuePrompt() for centralized access - Send preview_method in extra_data when not 'default'
1 parent c88fc99 commit 364c9ce

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
lines changed

src/locales/en/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@
7979
"Comfy_EnableWorkflowViewRestore": {
8080
"name": "Save and restore canvas position and zoom level in workflows"
8181
},
82+
"Comfy_Execution_PreviewMethod": {
83+
"name": "Live preview method",
84+
"tooltip": "Live preview method during image generation. \"default\" uses the server CLI setting.",
85+
"options": {
86+
"default": "default",
87+
"none": "none",
88+
"auto": "auto",
89+
"latent2rgb": "latent2rgb",
90+
"taesd": "taesd"
91+
}
92+
},
8293
"Comfy_FloatRoundingPrecision": {
8394
"name": "Float widget rounding decimal places [0 = auto].",
8495
"tooltip": "(requires page reload)"

src/platform/settings/constants/coreSettings.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,17 @@ export const CORE_SETTINGS: SettingParams[] = [
807807
defaultValue: 64,
808808
versionAdded: '1.4.12'
809809
},
810+
{
811+
id: 'Comfy.Execution.PreviewMethod',
812+
category: ['Comfy', 'Execution', 'PreviewMethod'],
813+
name: 'Live preview method',
814+
tooltip:
815+
'Live preview method during image generation. "default" uses the server CLI setting.',
816+
type: 'combo',
817+
options: ['default', 'none', 'auto', 'latent2rgb', 'taesd'],
818+
defaultValue: 'default',
819+
versionAdded: '1.36.0'
820+
},
810821
{
811822
id: 'LiteGraph.Canvas.MaximumFps',
812823
name: 'Maximum FPS',

src/schemas/apiSchema.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@ const zNodeBadgeMode = z.enum(
372372
Object.values(NodeBadgeMode) as [string, ...string[]]
373373
)
374374

375+
const zPreviewMethod = z.enum([
376+
'default',
377+
'none',
378+
'auto',
379+
'latent2rgb',
380+
'taesd'
381+
])
382+
export type PreviewMethod = z.infer<typeof zPreviewMethod>
383+
375384
const zSettings = z.object({
376385
'Comfy.ColorPalette': z.string(),
377386
'Comfy.CustomColorPalettes': colorPalettesSchema,
@@ -433,6 +442,7 @@ const zSettings = z.object({
433442
'Comfy.TreeExplorer.ItemPadding': z.number(),
434443
'Comfy.Validation.Workflows': z.boolean(),
435444
'Comfy.Workflow.SortNodeIdOnSave': z.boolean(),
445+
'Comfy.Execution.PreviewMethod': zPreviewMethod,
436446
'Comfy.Workflow.WorkflowTabsPosition': z.enum(['Sidebar', 'Topbar']),
437447
'Comfy.Node.DoubleClickTitleToEdit': z.boolean(),
438448
'Comfy.WidgetControlMode': z.enum(['before', 'after']),

src/scripts/api.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ import type {
4242
StatusWsMessageStatus,
4343
SystemStats,
4444
User,
45-
UserDataFullInfo
45+
UserDataFullInfo,
46+
PreviewMethod
4647
} from '@/schemas/apiSchema'
4748
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
4849
import type { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
@@ -89,6 +90,11 @@ interface QueuePromptRequestBody {
8990
* ```
9091
*/
9192
api_key_comfy_org?: string
93+
/**
94+
* Override the preview method for this prompt execution.
95+
* 'default' uses the server's CLI setting.
96+
*/
97+
preview_method?: PreviewMethod
9298
}
9399
front?: boolean
94100
number?: number
@@ -104,6 +110,11 @@ interface QueuePromptOptions {
104110
* Format: Colon-separated path of node IDs (e.g., "123:456:789")
105111
*/
106112
partialExecutionTargets?: NodeExecutionId[]
113+
/**
114+
* Override the preview method for this prompt execution.
115+
* 'default' uses the server's CLI setting and is not sent to backend.
116+
*/
117+
previewMethod?: PreviewMethod
107118
}
108119

109120
/** Dictionary of Frontend-generated API calls */
@@ -773,7 +784,11 @@ export class ComfyApi extends EventTarget {
773784
extra_data: {
774785
auth_token_comfy_org: this.authToken,
775786
api_key_comfy_org: this.apiKey,
776-
extra_pnginfo: { workflow }
787+
extra_pnginfo: { workflow },
788+
...(options?.previewMethod &&
789+
options.previewMethod !== 'default' && {
790+
preview_method: options.previewMethod
791+
})
777792
}
778793
}
779794

src/scripts/app.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,9 @@ export class ComfyApp {
13441344
try {
13451345
while (this.queueItems.length) {
13461346
const { number, batchCount, queueNodeIds } = this.queueItems.pop()!
1347+
const previewMethod = useSettingStore().get(
1348+
'Comfy.Execution.PreviewMethod'
1349+
)
13471350

13481351
for (let i = 0; i < batchCount; i++) {
13491352
// Allow widgets to run callbacks before a prompt has been queued
@@ -1358,7 +1361,8 @@ export class ComfyApp {
13581361
api.authToken = comfyOrgAuthToken
13591362
api.apiKey = comfyOrgApiKey ?? undefined
13601363
const res = await api.queuePrompt(number, p, {
1361-
partialExecutionTargets: queueNodeIds
1364+
partialExecutionTargets: queueNodeIds,
1365+
previewMethod
13621366
})
13631367
delete api.authToken
13641368
delete api.apiKey

0 commit comments

Comments
 (0)