66import _ from 'lodash'
77import { computed , onMounted , watch } from 'vue'
88
9+ import { useNodePricing } from '@/composables/node/useNodePricing'
910import { app } from '@/scripts/app'
1011import { useExtensionStore } from '@/stores/extensionStore'
1112import { ComfyNodeDefImpl , useNodeDefStore } from '@/stores/nodeDefStore'
@@ -42,9 +43,21 @@ export const useNodeBadge = () => {
4243 ) as NodeBadgeMode
4344 )
4445
45- watch ( [ nodeSourceBadgeMode , nodeIdBadgeMode , nodeLifeCycleBadgeMode ] , ( ) => {
46- app . graph ?. setDirtyCanvas ( true , true )
47- } )
46+ const showApiPricingBadge = computed ( ( ) =>
47+ settingStore . get ( 'Comfy.NodeBadge.ShowApiPricing' )
48+ )
49+
50+ watch (
51+ [
52+ nodeSourceBadgeMode ,
53+ nodeIdBadgeMode ,
54+ nodeLifeCycleBadgeMode ,
55+ showApiPricingBadge
56+ ] ,
57+ ( ) => {
58+ app . graph ?. setDirtyCanvas ( true , true )
59+ }
60+ )
4861
4962 const nodeDefStore = useNodeDefStore ( )
5063 function badgeTextVisible (
@@ -58,6 +71,8 @@ export const useNodeBadge = () => {
5871 }
5972
6073 onMounted ( ( ) => {
74+ const nodePricing = useNodePricing ( )
75+
6176 extensionStore . registerExtension ( {
6277 name : 'Comfy.NodeBadge' ,
6378 nodeCreated ( node : LGraphNode ) {
@@ -95,13 +110,15 @@ export const useNodeBadge = () => {
95110
96111 node . badges . push ( ( ) => badge . value )
97112
98- if ( node . constructor . nodeData ?. api_node ) {
113+ if ( node . constructor . nodeData ?. api_node && showApiPricingBadge . value ) {
114+ const price = nodePricing . getNodeDisplayPrice ( node )
115+ // Always add the badge for API nodes, with or without price text
99116 const creditsBadge = computed ( ( ) => {
100117 // Use dynamic background color based on the theme
101118 const isLightTheme =
102119 colorPaletteStore . completedActivePalette . light_theme
103120 return new LGraphBadge ( {
104- text : '' ,
121+ text : price ,
105122 iconOptions : {
106123 unicode : '\ue96b' ,
107124 fontFamily : 'PrimeIcons' ,
0 commit comments