Skip to content

Commit 6782d04

Browse files
authored
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)
1 parent 4bb5c12 commit 6782d04

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/schemas/nodeDefSchema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const zBaseInputOptions = z
2727
.object({
2828
default: z.any().optional(),
2929
defaultInput: z.boolean().optional(),
30+
display_name: z.string().optional(),
3031
forceInput: z.boolean().optional(),
3132
tooltip: z.string().optional(),
3233
socketless: z.boolean().optional(),

src/services/litegraphService.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ export const useLitegraphService = () => {
9595
)
9696
if (widgetConstructor && !inputSpec.forceInput) return
9797

98-
node.addInput(inputName, inputSpec.type, {
98+
const input = node.addInput(inputName, inputSpec.type, {
9999
shape: inputSpec.isOptional ? RenderShape.HollowCircle : undefined,
100100
localized_name: st(nameKey, inputName)
101101
})
102+
input.label ??= inputSpec.display_name
102103
}
103104
/**
104105
* @internal Setup stroke styles for the node under various conditions.
@@ -164,7 +165,10 @@ export const useLitegraphService = () => {
164165
) ?? {}
165166

166167
if (widget) {
167-
widget.label = st(nameKey, widget.label ?? inputName)
168+
widget.label = st(
169+
nameKey,
170+
widget.label ?? widgetInputSpec.display_name ?? inputName
171+
)
168172
widget.options ??= {}
169173
Object.assign(widget.options, {
170174
advanced: inputSpec.advanced,

0 commit comments

Comments
 (0)