Skip to content
Open
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
4 changes: 3 additions & 1 deletion scripts/collect-i18n-node-defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {
Object.values(rawNodeDefs)
// Ignore DevTools nodes (used for internal testing)
.filter((def: ComfyNodeDef) => !def.name.startsWith('DevTools'))
.map((def: ComfyNodeDef) => new ComfyNodeDefImpl(def))
.map((def: ComfyNodeDef) =>
new ComfyNodeDefImpl(def).toSerializable()
)
)
}
)
Expand Down
46 changes: 46 additions & 0 deletions src/stores/nodeDefStore.serialization.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { beforeEach, describe, expect, it } from 'vitest'

import { setBackendNodeText } from '@/i18n'
import type { ComfyNodeDef as ComfyNodeDefV1 } from '@/schemas/nodeDefSchema'
import { ComfyNodeDefImpl } from '@/stores/nodeDefStore'

const backendDef: ComfyNodeDefV1 = {
name: 'SerializationProbe',
display_name: 'Live Display Name',
category: 'testing',
python_module: 'nodes',
description: 'Live description',
input: { required: {} },
output: [],
output_name: [],
output_node: false
}

/** Stands in for Playwright's `page.evaluate` return-value serialization. */
function crossEvaluateBoundary<T extends object>(
value: T
): Record<string, unknown> {
return structuredClone({ ...value }) as Record<string, unknown>
}

describe('ComfyNodeDefImpl.toSerializable', () => {
beforeEach(() => {
setBackendNodeText([backendDef])
})

it('carries resolved text across the evaluate boundary', () => {
const crossed = crossEvaluateBoundary(
new ComfyNodeDefImpl(backendDef).toSerializable()
)

expect(crossed.display_name).toBe('Live Display Name')
expect(crossed.description).toBe('Live description')
})

it('is required: a bare instance loses both to the boundary', () => {
const crossed = crossEvaluateBoundary(new ComfyNodeDefImpl(backendDef))

expect(crossed.display_name).toBeUndefined()
expect(crossed.description).toBeUndefined()
})
})
17 changes: 17 additions & 0 deletions src/stores/nodeDefStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,23 @@ export class ComfyNodeDefImpl
return resolveNodeDefText('description', this.name, this.backendDescription)
}

/**
* `display_name` and `description` are prototype accessors, and Playwright's
* `page.evaluate` serializes own enumerable properties only. Anything that
* carries a def out of the browser must materialize them or both silently
* arrive `undefined` — which is how the release locale collector would have
* written every node's `display_name` as its internal `name`.
*/
toSerializable(): ComfyNodeDefImpl & {
display_name: string
description: string
} {
return Object.assign({}, this, {
display_name: this.display_name,
description: this.description
})
}

get nodePath(): string {
return (this.category ? this.category + '/' : '') + this.name
}
Expand Down
Loading