Support display_name on frontend (#6922)

The v3 schema allows defining a `display_name` on inputs, but this was
previously ignored on the frontend. It is now used to designate a
default value for the label of a widget or input.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6922-Support-display_name-on-frontend-2b66d73d365081d992cbea07abc27a0f)
by [Unito](https://www.unito.io)
This commit is contained in:
AustinMroz
2025-11-25 10:36:14 -08:00
committed by GitHub
parent 4bb5c12fac
commit 6782d04f00
2 changed files with 7 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ export const zBaseInputOptions = z
.object({
default: z.any().optional(),
defaultInput: z.boolean().optional(),
display_name: z.string().optional(),
forceInput: z.boolean().optional(),
tooltip: z.string().optional(),
socketless: z.boolean().optional(),

View File

@@ -95,10 +95,11 @@ export const useLitegraphService = () => {
)
if (widgetConstructor && !inputSpec.forceInput) return
node.addInput(inputName, inputSpec.type, {
const input = node.addInput(inputName, inputSpec.type, {
shape: inputSpec.isOptional ? RenderShape.HollowCircle : undefined,
localized_name: st(nameKey, inputName)
})
input.label ??= inputSpec.display_name
}
/**
* @internal Setup stroke styles for the node under various conditions.
@@ -164,7 +165,10 @@ export const useLitegraphService = () => {
) ?? {}
if (widget) {
widget.label = st(nameKey, widget.label ?? inputName)
widget.label = st(
nameKey,
widget.label ?? widgetInputSpec.display_name ?? inputName
)
widget.options ??= {}
Object.assign(widget.options, {
advanced: inputSpec.advanced,