Move price badges to python nodes (#7816)

## Summary

Backend part: https://github.com/Comfy-Org/ComfyUI/pull/11582

- Move API node pricing definitions from hardcoded frontend functions to
backend-defined JSONata expressions
- Add `price_badge` field to node definition schema containing JSONata
expression and dependency declarations
- Implement async JSONata evaluation with signature-based caching for
efficient reactive updates
- Show one decimal in credit badges when meaningful (e.g., 1.5 credits
instead of 2 credits)

## Screenshots (if applicable)

<!-- Add screenshots or video recording to help explain your changes -->

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7816-Move-price-badges-to-python-nodes-2da6d73d365081ec815ef61f7e3c65f7)
by [Unito](https://www.unito.io)
This commit is contained in:
Alexander Piskun
2026-01-22 19:17:07 +02:00
committed by GitHub
parent 4a5e7c8bcb
commit 5c142275ad
9 changed files with 1546 additions and 4969 deletions

View File

@@ -14,7 +14,8 @@ import type {
import type {
ComfyInputsSpec as ComfyInputSpecV1,
ComfyNodeDef as ComfyNodeDefV1,
ComfyOutputTypesSpec as ComfyOutputSpecV1
ComfyOutputTypesSpec as ComfyOutputSpecV1,
PriceBadge
} from '@/schemas/nodeDefSchema'
import { NodeSearchService } from '@/services/nodeSearchService'
import { useSubgraphStore } from '@/stores/subgraphStore'
@@ -66,6 +67,12 @@ export class ComfyNodeDefImpl
* Order of inputs for each category (required, optional, hidden)
*/
readonly input_order?: Record<string, string[]>
/**
* Price badge definition for API nodes.
* Contains a JSONata expression to calculate pricing based on widget values
* and input connectivity.
*/
readonly price_badge?: PriceBadge
// V2 fields
readonly inputs: Record<string, InputSpecV2>
@@ -134,6 +141,7 @@ export class ComfyNodeDefImpl
this.output_name = obj.output_name
this.output_tooltips = obj.output_tooltips
this.input_order = obj.input_order
this.price_badge = obj.price_badge
// Initialize V2 fields
const defV2 = transformNodeDefV1ToV2(obj)