Add front end support for type matching (#6582)

This PR implements front end logic to handle MatchType inputs and
outputs.
See  comfyanonymous/ComfyUI#10644

This allows for the implementation of nodes such as a "switch node"
where input types change based on the connections made.

![switch-node](https://github.com/user-attachments/assets/090515ba-484c-4295-b7b3-204b0c72fc4a)

As part of this implementation, significant cleanup is being performed
in the reroute code. Extra testing will be required to make sure these
changes don't introduce regressions.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6582-Add-front-end-support-for-type-matching-2a16d73d36508189b042cd23f82a332e)
by [Unito](https://www.unito.io)
This commit is contained in:
AustinMroz
2025-11-12 12:30:58 -08:00
committed by GitHub
parent cfbd5361d3
commit 23b0d2eb7f
9 changed files with 393 additions and 245 deletions

View File

@@ -14,6 +14,10 @@ const zRemoteWidgetConfig = z.object({
timeout: z.number().gte(0).optional(),
max_retries: z.number().gte(0).optional()
})
const zWidgetTemplate = z.object({
template_id: z.string(),
allowed_types: z.string().optional()
})
const zMultiSelectOption = z.object({
placeholder: z.string().optional(),
chip: z.boolean().optional()
@@ -28,6 +32,7 @@ export const zBaseInputOptions = z
hidden: z.boolean().optional(),
advanced: z.boolean().optional(),
widgetType: z.string().optional(),
template: zWidgetTemplate.optional(),
/** Backend-only properties. */
rawLink: z.boolean().optional(),
lazy: z.boolean().optional()
@@ -201,6 +206,7 @@ export const zComfyNodeDef = z.object({
output_is_list: z.array(z.boolean()).optional(),
output_name: z.array(z.string()).optional(),
output_tooltips: z.array(z.string()).optional(),
output_matchtypes: z.array(z.string().optional()).optional(),
name: z.string(),
display_name: z.string(),
description: z.string(),