Skip to content

Commit a977d74

Browse files
committed
Schema improvement and output typing fix
None of the changes are ideal, but they fix bugs and prevent us from being locked into a bad format in the future
1 parent 518484e commit a977d74

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/core/graph/widgets/dynamicWidgets.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export function applyDynamicInputs(
166166
inputSpec: InputSpecV2
167167
): boolean {
168168
if (!(inputSpec.type in dynamicInputs)) return false
169+
//TODO: perform parsing/validation of inputSpec here?
169170
dynamicInputs[inputSpec.type](node, inputSpec)
170171
return true
171172
}
@@ -233,7 +234,9 @@ export function applyMatchType(node: LGraphNode, inputSpec: InputSpecV2) {
233234
const { addNodeInput } = useLitegraphService()
234235
const name = inputSpec.name
235236
const { allowed_types, template_id } = (
236-
inputSpec as { template: { allowed_types: string; template_id: string } }
237+
inputSpec as InputSpecV2 & {
238+
template: { allowed_types: string; template_id: string }
239+
}
237240
).template
238241
const typedSpec = { ...inputSpec, type: allowed_types }
239242
addNodeInput(node, typedSpec)
@@ -259,6 +262,8 @@ export function applyMatchType(node: LGraphNode, inputSpec: InputSpecV2) {
259262
if (!matchGroup) return
260263
if (iscon && linf) {
261264
const { output, subgraphInput } = linf.resolve(this.graph)
265+
//TODO: fix this bug globally. A link type (and therefore color)
266+
//should be the combinedType of origin and target type
262267
const connectingType = (output ?? subgraphInput)?.type
263268
if (connectingType) linf.type = connectingType
264269
}
@@ -302,6 +307,22 @@ export function applyMatchType(node: LGraphNode, inputSpec: InputSpecV2) {
302307
}
303308
augmentedNode.comfyMatchType[template_id] ??= {}
304309
augmentedNode.comfyMatchType[template_id][name] = allowed_types
310+
311+
//TODO: instead apply on output add?
312+
//ensure outputs get updated
313+
const index = node.inputs.length - 1
314+
const input = node.inputs.at(-1)!
315+
setTimeout(
316+
() =>
317+
node.onConnectionsChange!(
318+
LiteGraph.INPUT,
319+
index,
320+
false,
321+
undefined,
322+
input
323+
),
324+
50
325+
)
305326
}
306327

307328
export function applyAutoGrow(node: LGraphNode, inputSpec: InputSpecV2) {

src/schemas/nodeDefSchema.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ const zRemoteWidgetConfig = z.object({
1414
timeout: z.number().gte(0).optional(),
1515
max_retries: z.number().gte(0).optional()
1616
})
17-
const zWidgetTemplate = z.object({
18-
template_id: z.string(),
19-
allowed_types: z.string().optional()
20-
})
2117
const zMultiSelectOption = z.object({
2218
placeholder: z.string().optional(),
2319
chip: z.boolean().optional()
@@ -32,7 +28,6 @@ export const zBaseInputOptions = z
3228
hidden: z.boolean().optional(),
3329
advanced: z.boolean().optional(),
3430
widgetType: z.string().optional(),
35-
template: zWidgetTemplate.optional(),
3631
/** Backend-only properties. */
3732
rawLink: z.boolean().optional(),
3833
lazy: z.boolean().optional()

0 commit comments

Comments
 (0)