Add support for search aliases on subgraphs (#8608)

## Summary

- add commands for setting search aliases and description when in
subgraph
- in future we can add these fields to the dialog when publishing a
subgraph
- map workflow extra metadata on save/load from from/to subgraph node to
allow access via `canvas.subgraph.extra`

## Changes

**What**: 
- new core commands for Comfy.Subgraph.SetSearchAliases &
Comfy.Subgraph.SetDescription to be called when in a subgraph context
- update Publish command to allow command metadata arg for name
- update test executeCommand to allow passing metadata arg

## Review Focus

- When saving a subgraph, the outer workflow "wrapper" is created at the
point of publishing. So unlike a normal workflow `extra` property that
is available at any point, for a subgraph this is not accessible.
To workaround this, the `extra` property that exists on the inner
subgraph node is copied to the top level on save, and restored on load
so extra properties can be set via `canvas.subgraph.extra`.
- I have kept the existing naming format matching `BlueprintDescription`
for `BlueprintSearchAliases` but i'm not sure if the description was
ever used before

## Screenshots


https://github.com/user-attachments/assets/4d4df9c1-2281-4589-aa56-ab07cdecd353

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8608-Add-support-for-search-aliases-on-subgraphs-2fd6d73d365081d083caebd6befcacdd)
by [Unito](https://www.unito.io)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Set subgraph search aliases (comma-separated) and descriptions;
aliases enable discovery by alternative names.
  * Publish subgraphs using a provided name.
* Node definitions now support search aliases so nodes can be found by
alternate names.
  * UI strings added for entering descriptions and search aliases.

* **Tests**
* Added end-to-end and unit tests covering aliases, descriptions, search
behavior, publishing, and persistence.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
pythongosssss
2026-02-04 12:52:30 -08:00
committed by GitHub
parent b8287f6c2f
commit 6feb2022a4
12 changed files with 668 additions and 25 deletions

View File

@@ -61,6 +61,54 @@ const EXAMPLE_NODE_DEFS: ComfyNodeDefImpl[] = (
return def
})
const NODE_DEFS_WITH_SEARCH_ALIASES: ComfyNodeDefImpl[] = (
[
{
input: { required: {} },
output: ['MODEL'],
output_is_list: [false],
output_name: ['MODEL'],
name: 'CheckpointLoaderSimple',
display_name: 'Load Checkpoint',
description: '',
python_module: 'nodes',
category: 'loaders',
output_node: false,
search_aliases: ['ckpt', 'model loader', 'checkpoint']
},
{
input: { required: {} },
output: ['IMAGE'],
output_is_list: [false],
output_name: ['IMAGE'],
name: 'LoadImage',
display_name: 'Load Image',
description: '',
python_module: 'nodes',
category: 'loaders',
output_node: false,
search_aliases: ['img', 'picture']
},
{
input: { required: {} },
output: ['LATENT'],
output_is_list: [false],
output_name: ['LATENT'],
name: 'VAEEncode',
display_name: 'VAE Encode',
description: '',
python_module: 'nodes',
category: 'latent',
output_node: false
// No search_aliases
}
] as ComfyNodeDef[]
).map((nodeDef: ComfyNodeDef) => {
const def = new ComfyNodeDefImpl(nodeDef)
def['postProcessSearchScores'] = (s) => s
return def
})
describe('nodeSearchService', () => {
it('searches with input filter', () => {
const service = new NodeSearchService(EXAMPLE_NODE_DEFS)
@@ -74,4 +122,52 @@ describe('nodeSearchService', () => {
).toHaveLength(2)
expect(service.searchNode('L')).toHaveLength(2)
})
describe('search_aliases', () => {
it('finds nodes by search_aliases', () => {
const service = new NodeSearchService(NODE_DEFS_WITH_SEARCH_ALIASES)
// Search by alias
const ckptResults = service.searchNode('ckpt')
expect(ckptResults).toHaveLength(1)
expect(ckptResults[0].name).toBe('CheckpointLoaderSimple')
})
it('finds nodes by partial alias match', () => {
const service = new NodeSearchService(NODE_DEFS_WITH_SEARCH_ALIASES)
// Search by partial alias "model" should match "model loader" alias
const modelResults = service.searchNode('model')
expect(modelResults.length).toBeGreaterThanOrEqual(1)
expect(
modelResults.some((r) => r.name === 'CheckpointLoaderSimple')
).toBe(true)
})
it('finds nodes by display_name when no alias matches', () => {
const service = new NodeSearchService(NODE_DEFS_WITH_SEARCH_ALIASES)
// "VAE" should match by display_name since there are no aliases
const vaeResults = service.searchNode('VAE')
expect(vaeResults).toHaveLength(1)
expect(vaeResults[0].name).toBe('VAEEncode')
})
it('finds nodes by both alias and display_name', () => {
const service = new NodeSearchService(NODE_DEFS_WITH_SEARCH_ALIASES)
// "img" should match LoadImage by alias
const imgResults = service.searchNode('img')
expect(imgResults).toHaveLength(1)
expect(imgResults[0].name).toBe('LoadImage')
// "Load" should match both checkpoint and image loaders by display_name
const loadResults = service.searchNode('Load')
expect(loadResults.length).toBeGreaterThanOrEqual(2)
})
it('handles nodes without search_aliases', () => {
const service = new NodeSearchService(NODE_DEFS_WITH_SEARCH_ALIASES)
// Ensure nodes without aliases are still searchable by name/display_name
const encodeResults = service.searchNode('Encode')
expect(encodeResults).toHaveLength(1)
expect(encodeResults[0].name).toBe('VAEEncode')
})
})
})