mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-07-14 03:07:57 +00:00
Fix output restoration
This commit is contained in:
@@ -9,6 +9,15 @@ import { app } from '@/scripts/app'
|
||||
import { type DOMWidget } from '@/scripts/domWidget'
|
||||
import { ComfyWidgets } from '@/scripts/widgets'
|
||||
import { useExtensionService } from '@/services/extensionService'
|
||||
import { getNodeByLocatorId } from '@/utils/graphTraversalUtil'
|
||||
|
||||
const applyValue = (node: LGraphNode, text: string | string[]) => {
|
||||
const previewWidgets =
|
||||
node.widgets?.filter((w) => w.name.startsWith('preview_')) ?? []
|
||||
|
||||
const value = Array.isArray(text) ? (text?.join('\n\n') ?? '') : text
|
||||
for (const previewWidget of previewWidgets) previewWidget.value = value
|
||||
}
|
||||
|
||||
useExtensionService().registerExtension({
|
||||
name: 'Comfy.PreviewAny',
|
||||
@@ -82,16 +91,14 @@ useExtensionService().registerExtension({
|
||||
? void 0
|
||||
: onExecuted.apply(this, [message])
|
||||
|
||||
const previewWidgets =
|
||||
this.widgets?.filter((w) => w.name.startsWith('preview_')) ?? []
|
||||
|
||||
for (const previewWidget of previewWidgets) {
|
||||
const text = message.text ?? ''
|
||||
previewWidget.value = Array.isArray(text)
|
||||
? (text?.join('\n\n') ?? '')
|
||||
: text
|
||||
}
|
||||
applyValue(this, message.text ?? '')
|
||||
}
|
||||
}
|
||||
},
|
||||
onNodeOutputsUpdated(nodeOutputs) {
|
||||
for (const [nodeLocatorId, output] of Object.entries(nodeOutputs)) {
|
||||
const node = getNodeByLocatorId(app.rootGraph, nodeLocatorId)
|
||||
if (node?.type === 'PreviewAny') applyValue(node, output.text ?? '')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -7,10 +7,12 @@ import type { NodeReplacement } from '@/platform/nodeReplacement/types'
|
||||
import type { SettingParams } from '@/platform/settings/types'
|
||||
import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema'
|
||||
import type { Keybinding } from '@/platform/keybindings/types'
|
||||
import type { NodeExecutionOutput } from '@/schemas/apiSchema'
|
||||
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
|
||||
import type { ComfyApp } from '@/scripts/app'
|
||||
import type { ComfyWidgetConstructor } from '@/scripts/widgets'
|
||||
import type { ComfyCommand } from '@/stores/commandStore'
|
||||
import type { NodeLocatorId } from '@/types/nodeIdentification'
|
||||
import type { AuthUserInfo } from '@/types/authTypes'
|
||||
import type { BottomPanelExtension } from '@/types/extensionTypes'
|
||||
|
||||
@@ -265,5 +267,9 @@ export interface ComfyExtension {
|
||||
*/
|
||||
onAuthUserLogout?(): Promise<void> | void
|
||||
|
||||
onNodeOutputsUpdated?(
|
||||
nodeOutputs: Record<NodeLocatorId, NodeExecutionOutput>
|
||||
): void
|
||||
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user