Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/composables/node/badgeRendererParity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('badge renderer parity (I2)', () => {
expect(legacyBadgeText(node)).toBe('#1 BETA my_pack')
})

it.fails('renders Vue badges in the same display order', () => {
it('renders Vue badges in the same display order', () => {
const node = setup(
NodeBadgeMode.ShowAll,
'CustomNode',
Expand All @@ -139,7 +139,7 @@ describe('badge renderer parity (I2)', () => {
expect(legacyBadgeText(node)).toBe('#1 BETA my_pack')
})

it.fails('renders Vue badges in the same display order', () => {
it('renders Vue badges in the same display order', () => {
const node = setup(
NodeBadgeMode.HideBuiltIn,
'CustomNode',
Expand All @@ -164,7 +164,7 @@ describe('badge renderer parity (I2)', () => {
expect(legacyBadgeText(node)).toBe(`#1 BETA ${CORE_SOURCE_BADGE}`)
})

it.fails('renders Vue badges in the same display order', () => {
it('renders Vue badges in the same display order', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKER — this promoted test asserts a display order the app doesn't produce.

vueBadgeText (line 81) appends the Comfy logo after the core chips:

...partitioned.core.map((b) => b.text),
...(partitioned.hasComfyBadge ? [CORE_SOURCE_BADGE] : [])

But NodeBadges.vue renders the logo pill before the core pill (v-if="hasComfyBadge" block precedes the v-if="core.length" block). So for a core node under ShowAll the real render is 🦊 #1 | BETA, while legacy draws #1 [BETA] 🦊. The test says #1 BETA 🦊 and passes only because the helper puts the logo where the template doesn't.

The other two promoted tests (custom node, ShowAll/HideBuiltIn) are genuine — this one isn't. Pick one:

  • keep it.fails here and note the logo position is the remaining gap, or
  • rename it to something that matches what it checks (e.g. orders core parts as id, lifecycle, source) and drop the logo from the helper, or
  • move the logo chip after the core chip in NodeBadges.vue so the assertion becomes true.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction: downgrading this from BLOCKER to SHOULD FIX.

The underlying observation is still accurate — I re-checked, and NodeBadges.vue does render the logo pill before the core pill in a plain flex row (no order-* / flex-row-reverse), while legacy puts 🦊 last inside the joined string.

But your PR description already says you're preserving the separate logo treatment for core nodes, so the helper's concatenation is reasonably read as a serialization of the core chip sequence rather than a spatial claim — and the core ordering it guards is genuinely fixed by this PR. Nothing here is broken at runtime.

So: not blocking. Worth renaming the test (or adding a line to vueBadgeText) so the next reader doesn't take #1 BETA 🦊 as the rendered left-to-right order, since it isn't.

const node = setup(NodeBadgeMode.ShowAll, 'CoreNode', 'nodes')

expect(vueBadgeText(node)).toBe(`#1 BETA ${CORE_SOURCE_BADGE}`)
Expand Down
23 changes: 23 additions & 0 deletions src/renderer/extensions/vueNodes/components/NodeBadges.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { render, screen } from '@testing-library/vue'
import { describe, expect, it } from 'vitest'

import NodeBadges from '@/renderer/extensions/vueNodes/components/NodeBadges.vue'

describe('NodeBadges', () => {
it('renders the Comfy badge after the core badges', () => {
render(NodeBadges, {
props: {
hasComfyBadge: true,
core: [{ text: '#1' }, { text: 'BETA' }],
extension: []
}
})

const coreBadge = screen.getByText('BETA')
const comfyBadge = screen.getByTestId('comfy-badge')
expect(
coreBadge.compareDocumentPosition(comfyBadge) &
Node.DOCUMENT_POSITION_FOLLOWING
).toBeTruthy()
})
})
13 changes: 7 additions & 6 deletions src/renderer/extensions/vueNodes/components/NodeBadges.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ defineProps<{
v-if="hasComfyBadge || core.length || extension.length"
class="flex h-5 w-full gap-2 px-2 text-muted-foreground"
>
<div
v-if="hasComfyBadge"
class="flex size-6 items-center justify-center rounded-full bg-component-node-widget-background"
>
<i class="icon-[comfy--comfy-c] size-3" />
</div>
<div
v-if="core.length"
class="flex h-6 items-center justify-center overflow-clip rounded-full bg-component-node-widget-background"
Expand All @@ -35,6 +29,13 @@ defineProps<{
/>
</template>
</div>
<div
v-if="hasComfyBadge"
data-testid="comfy-badge"
class="flex size-6 items-center justify-center rounded-full bg-component-node-widget-background"
>
<i class="icon-[comfy--comfy-c] size-3" />
</div>
<div
v-if="extension.length"
class="flex h-6 items-center justify-center overflow-clip rounded-full bg-component-node-widget-background"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('usePartitionedBadges', () => {

expect(partitioned.value).toEqual({
hasComfyBadge: false,
core: [{ text: 'BETA' }, { text: '#5' }, { text: 'testpack' }],
core: [{ text: '#5' }, { text: 'BETA' }, { text: 'testpack' }],
extension: [],
pricing: [{ required: '$0.05', rest: 'x 3 Runs' }]
})
Expand Down Expand Up @@ -157,8 +157,8 @@ describe('usePartitionedBadges', () => {
addNodeDef('CustomNode', 'custom_nodes.testpack')

expect(partitioned.value.core).toEqual([
{ text: 'BETA' },
{ text: '#5' },
{ text: 'BETA' },
{ text: 'testpack' }
])
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import type { NodeBadgeProps } from '@/renderer/extensions/vueNodes/components/N
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
import { useNodeDefStore } from '@/stores/nodeDefStore'
import { nodeBadges } from '@/systems/badgeSystem'
import { CORE_JOIN_ORDER } from '@/types/badgeData'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOULD FIX — naming/doc drift. CORE_JOIN_ORDER's doc says "Legacy canvas joins the core parts into a single badge in this order", and badgeData.ts justifies raw rows with "each renderer applies its own ordering". Both statements are now false: the Vue renderer uses the same constant for chip order. Rename to CORE_PART_ORDER and update both comments.

import type { CoreBadgePart } from '@/types/badgeData'
import { NodeBadgeMode } from '@/types/nodeSource'
import { resolveNode } from '@/utils/litegraphUtil'

Expand All @@ -33,7 +35,7 @@ export function usePartitionedBadges(nodeData: NodeState) {
settingStore.get('Comfy.NodeBadge.NodeSourceBadgeMode') ===
NodeBadgeMode.ShowAll

const core: NodeBadgeProps[] = []
const coreByPart = new Map<CoreBadgePart, NodeBadgeProps>()
const extension: NodeBadgeProps[] = []
const pricing: { required: string; rest?: string }[] = []

Expand All @@ -46,7 +48,7 @@ export function usePartitionedBadges(nodeData: NodeState) {
continue
}
if (nodeDef?.isCoreNode && row.part === 'source') continue
core.push({
coreByPart.set(row.part, {
text: row.part === 'lifecycle' ? trim(row.text, ['[', ']']) : row.text
})
}
Expand All @@ -58,7 +60,10 @@ export function usePartitionedBadges(nodeData: NodeState) {

return {
hasComfyBadge: showComfyLogo && pricing.length === 0,
core,
core: CORE_JOIN_ORDER.flatMap((part) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOULD FIX — both renderers now do the same Map-and-reorder dance. computeBadges emits core rows as lifecycle, id, source and nodeBadgeDraw.joinedCoreText re-sorts into id, lifecycle, source; this adds a second copy of that re-sort.

Emitting coreParts in CORE_JOIN_ORDER inside computeBadges would let both renderers consume rows in order and delete both Maps. I get that the intent was to keep ordering renderer-local, but there is now exactly one order — the indirection is buying nothing.

const badge = coreByPart.get(part)
return badge ? [badge] : []
}),
extension,
pricing
}
Expand Down
Loading