fix: make widget.hidden reactive in Vue mode via WidgetValueStore

The PreviewAny toggle (Markdown/Plaintext) sets widget.hidden directly on the litegraph widget, but Vue mode read hidden from a non-reactive snapshot. Changed hidden from a plain property to a getter/setter backed by _state on BaseWidget, matching the pattern used by disabled and promoted.

Amp-Thread-ID: https://ampcode.com/threads/T-019c558b-3543-774c-90dc-5464d5dbf866
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Alexander Brown
2026-02-12 22:25:22 -08:00
parent 0885ce742a
commit a1c9e913a8
4 changed files with 12 additions and 3 deletions

View File

@@ -158,7 +158,7 @@ describe('BaseWidget store integration', () => {
expect(state?.promoted).toBe(false)
expect(state?.label).toBeUndefined()
expect(widget.hidden).toBeUndefined()
expect(widget.hidden).toBe(false)
expect(widget.advanced).toBeUndefined()
})

View File

@@ -93,7 +93,13 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget>
this._state.label = value
}
hidden?: boolean
get hidden(): boolean | undefined {
return this._state.hidden
}
set hidden(value: boolean | undefined) {
this._state.hidden = value ?? false
}
advanced?: boolean
get disabled(): boolean | undefined {
@@ -182,6 +188,7 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget>
displayValue,
// @ts-expect-error Prevent naming conflicts with custom nodes.
labelBaseline,
hidden,
label,
disabled,
promoted,
@@ -196,6 +203,7 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget>
name: this.name,
type: this.type as TWidgetType,
value,
hidden: hidden ?? false,
label,
disabled: disabled ?? false,
promoted: promoted ?? false,

View File

@@ -236,7 +236,7 @@ const processedWidgets = computed((): ProcessedWidget[] => {
nodeErrors?.errors?.some(
(error) => error.extra_info?.input_name === widget.name
) ?? false,
hidden: widget.options?.hidden ?? false,
hidden: widgetState?.hidden ?? widget.options?.hidden ?? false,
name: widget.name,
type: widget.type,
vueComponent,

View File

@@ -33,6 +33,7 @@ export interface WidgetState<
| 'type'
| 'value'
| 'options'
| 'hidden'
| 'label'
| 'serialize'
| 'disabled'