Skip to content

Commit d7d01f7

Browse files
ltdrdataDrJKL
authored andcommitted
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.
1 parent b9f75b6 commit d7d01f7

File tree

7 files changed

+84
-10
lines changed

7 files changed

+84
-10
lines changed

src/composables/useCoreCommands.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,13 @@ export function useCoreCommands(): ComfyCommand[] {
480480
}
481481

482482
const batchCount = useQueueSettingsStore().batchCount
483+
const previewMethod = useSettingStore().get(
484+
'Comfy.Execution.PreviewMethod'
485+
)
483486

484487
useTelemetry()?.trackWorkflowExecution()
485488

486-
await app.queuePrompt(0, batchCount)
489+
await app.queuePrompt(0, batchCount, undefined, previewMethod)
487490
}
488491
},
489492
{
@@ -503,10 +506,13 @@ export function useCoreCommands(): ComfyCommand[] {
503506
}
504507

505508
const batchCount = useQueueSettingsStore().batchCount
509+
const previewMethod = useSettingStore().get(
510+
'Comfy.Execution.PreviewMethod'
511+
)
506512

507513
useTelemetry()?.trackWorkflowExecution()
508514

509-
await app.queuePrompt(-1, batchCount)
515+
await app.queuePrompt(-1, batchCount, undefined, previewMethod)
510516
}
511517
},
512518
{
@@ -525,6 +531,9 @@ export function useCoreCommands(): ComfyCommand[] {
525531
}
526532

527533
const batchCount = useQueueSettingsStore().batchCount
534+
const previewMethod = useSettingStore().get(
535+
'Comfy.Execution.PreviewMethod'
536+
)
528537
const selectedNodes = getSelectedNodes()
529538
const selectedOutputNodes = filterOutputNodes(selectedNodes)
530539

@@ -552,7 +561,7 @@ export function useCoreCommands(): ComfyCommand[] {
552561
return
553562
}
554563
useTelemetry()?.trackWorkflowExecution()
555-
await app.queuePrompt(0, batchCount, executionIds)
564+
await app.queuePrompt(0, batchCount, executionIds, previewMethod)
556565
}
557566
},
558567
{

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.35.3'
820+
},
810821
{
811822
id: 'LiteGraph.Canvas.MaximumFps',
812823
name: 'Maximum FPS',

src/schemas/apiSchema.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,13 @@ const zSettings = z.object({
433433
'Comfy.TreeExplorer.ItemPadding': z.number(),
434434
'Comfy.Validation.Workflows': z.boolean(),
435435
'Comfy.Workflow.SortNodeIdOnSave': z.boolean(),
436+
'Comfy.Execution.PreviewMethod': z.enum([
437+
'default',
438+
'none',
439+
'auto',
440+
'latent2rgb',
441+
'taesd'
442+
]),
436443
'Comfy.Workflow.WorkflowTabsPosition': z.enum(['Sidebar', 'Topbar']),
437444
'Comfy.Node.DoubleClickTitleToEdit': z.boolean(),
438445
'Comfy.WidgetControlMode': z.enum(['before', 'after']),

src/scripts/api.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ interface QueuePromptRequestBody {
8989
* ```
9090
*/
9191
api_key_comfy_org?: string
92+
/**
93+
* Override the preview method for this prompt execution.
94+
* Values: 'default' | 'none' | 'auto' | 'latent2rgb' | 'taesd'
95+
* 'default' uses the server's CLI setting.
96+
*/
97+
preview_method?: string
9298
}
9399
front?: boolean
94100
number?: number
@@ -104,6 +110,12 @@ 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+
* Values: 'default' | 'none' | 'auto' | 'latent2rgb' | 'taesd'
116+
* 'default' uses the server's CLI setting and is not sent to backend.
117+
*/
118+
previewMethod?: string
107119
}
108120

109121
/** Dictionary of Frontend-generated API calls */
@@ -773,7 +785,11 @@ export class ComfyApi extends EventTarget {
773785
extra_data: {
774786
auth_token_comfy_org: this.authToken,
775787
api_key_comfy_org: this.apiKey,
776-
extra_pnginfo: { workflow }
788+
extra_pnginfo: { workflow },
789+
...(options?.previewMethod &&
790+
options.previewMethod !== 'default' && {
791+
preview_method: options.previewMethod
792+
})
777793
}
778794
}
779795

src/scripts/app.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export class ComfyApp {
128128
number: number
129129
batchCount: number
130130
queueNodeIds?: NodeExecutionId[]
131+
previewMethod?: string
131132
}[] = []
132133
/**
133134
* If the queue is currently being processed
@@ -1325,9 +1326,10 @@ export class ComfyApp {
13251326
async queuePrompt(
13261327
number: number,
13271328
batchCount: number = 1,
1328-
queueNodeIds?: NodeExecutionId[]
1329+
queueNodeIds?: NodeExecutionId[],
1330+
previewMethod?: string
13291331
): Promise<boolean> {
1330-
this.queueItems.push({ number, batchCount, queueNodeIds })
1332+
this.queueItems.push({ number, batchCount, queueNodeIds, previewMethod })
13311333

13321334
// Only have one action process the items so each one gets a unique seed correctly
13331335
if (this.processingQueue) {
@@ -1343,7 +1345,8 @@ export class ComfyApp {
13431345

13441346
try {
13451347
while (this.queueItems.length) {
1346-
const { number, batchCount, queueNodeIds } = this.queueItems.pop()!
1348+
const { number, batchCount, queueNodeIds, previewMethod } =
1349+
this.queueItems.pop()!
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

src/services/autoQueueService.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import {
44
useQueuePendingTaskCountStore,
55
useQueueSettingsStore
66
} from '@/stores/queueStore'
7+
import { useSettingStore } from '@/platform/settings/settingStore'
78

89
export function setupAutoQueueHandler() {
910
const queueCountStore = useQueuePendingTaskCountStore()
1011
const queueSettingsStore = useQueueSettingsStore()
12+
const settingStore = useSettingStore()
1113

1214
let graphHasChanged = false
1315
let internalCount = 0 // Use an internal counter here so it is instantly updated when re-queuing
@@ -18,7 +20,13 @@ export function setupAutoQueueHandler() {
1820
} else {
1921
graphHasChanged = false
2022
// Queue the prompt in the background
21-
void app.queuePrompt(0, queueSettingsStore.batchCount)
23+
const previewMethod = settingStore.get('Comfy.Execution.PreviewMethod')
24+
void app.queuePrompt(
25+
0,
26+
queueSettingsStore.batchCount,
27+
undefined,
28+
previewMethod
29+
)
2230
internalCount++
2331
}
2432
}
@@ -33,7 +41,15 @@ export function setupAutoQueueHandler() {
3341
(queueSettingsStore.mode === 'change' && graphHasChanged)
3442
) {
3543
graphHasChanged = false
36-
await app.queuePrompt(0, queueSettingsStore.batchCount)
44+
const previewMethod = settingStore.get(
45+
'Comfy.Execution.PreviewMethod'
46+
)
47+
await app.queuePrompt(
48+
0,
49+
queueSettingsStore.batchCount,
50+
undefined,
51+
previewMethod
52+
)
3753
}
3854
}
3955
},

0 commit comments

Comments
 (0)