Add support for values factory function in widget select combo#8775
Add support for values factory function in widget select combo#8775pythongosssss merged 5 commits intomainfrom
Conversation
🎨 Storybook: ✅ Built — View Storybook |
🎭 Playwright: ✅ 551 passed, 0 failed · 5 flaky📊 Browser Reports
|
📝 WalkthroughWalkthroughThis PR introduces comprehensive unit tests for the WidgetSelectDefault component and modifies the component to support dynamic option re-evaluation. Event handlers ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📦 Bundle: 4.61 MB gzip 🔴 +156 BDetailsSummary
Category Glance App Entry Points — 17.8 kB (baseline 17.8 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 1.01 MB (baseline 1.01 MB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 72.5 kB (baseline 72.5 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 9 added / 9 removed Panels & Settings — 441 kB (baseline 441 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 10 added / 10 removed User & Accounts — 16.1 kB (baseline 16.1 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 5 added / 5 removed Editors & Dialogs — 78.3 kB (baseline 78.3 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 2 added / 2 removed UI Components — 56.7 kB (baseline 56.7 kB) • ⚪ 0 BReusable component library chunks
Status: 5 added / 5 removed Data & Services — 2.79 MB (baseline 2.79 MB) • ⚪ 0 BStores, services, APIs, and repositories
Status: 15 added / 15 removed Utilities & Hooks — 61.5 kB (baseline 61.5 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 11 added / 11 removed Vendor & Third-Party — 8.9 MB (baseline 8.9 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Other — 8.16 MB (baseline 8.16 MB) • 🔴 +319 BBundles that do not match a named category
Status: 50 added / 50 removed |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.vue`:
- Around line 62-68: The default for the defineModel `modelValue` re-implements
value resolution; replace the manual logic with a call to the existing
`resolveValues` helper to avoid duplication: call
`resolveValues(props.widget.options?.values)`, then return the first element of
the resulting array (or '' when empty/undefined) so `modelValue` uses the same
resolution logic as the rest of the component.
🧹 Nitpick comments (1)
src/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.vue (1)
56-60:resolveValuestrusts the factory return type without validation.Line 57 returns whatever the function produces, assuming it's
string[]. If a caller passes a factory that returns something else (e.g.,number[]ornull), there's no runtime guard—just a misleading return type annotation.Consider at least an
Array.isArraycheck on the function result, consistent with the array branch on line 58:Proposed fix
function resolveValues(values: unknown): string[] { - if (typeof values === 'function') return values() + if (typeof values === 'function') { + const result: unknown = values() + return Array.isArray(result) ? result : [] + } if (Array.isArray(values)) return values return [] }
src/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.vue
Show resolved
Hide resolved
src/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.vue
Outdated
Show resolved
Hide resolved
|
|
||
| return [] | ||
| }) | ||
| const selectOptions = ref(resolveValues(props.widget.options?.values)) |
src/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.vue
Show resolved
Hide resolved
src/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.vue
Show resolved
Hide resolved
src/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.test.ts
Show resolved
Hide resolved
test: add coverage for other values + reactivity
⚡ Performance Report
Raw data{
"timestamp": "2026-03-13T11:38:45.598Z",
"gitSha": "9f46f051f73a01f97e0d8d7171ffc42938809c78",
"branch": "pysssss/widget-select-factory-values",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 2027.7900000000102,
"styleRecalcs": 13,
"styleRecalcDurationMs": 10.594000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 348.947,
"heapDeltaBytes": 1087488
},
{
"name": "canvas-idle",
"durationMs": 2029.1050000000155,
"styleRecalcs": 11,
"styleRecalcDurationMs": 11.369,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 348.254,
"heapDeltaBytes": 784108
},
{
"name": "canvas-idle",
"durationMs": 2025.6469999999922,
"styleRecalcs": 12,
"styleRecalcDurationMs": 10.438,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 347.01000000000005,
"heapDeltaBytes": 1533240
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1965.514000000013,
"styleRecalcs": 78,
"styleRecalcDurationMs": 44.591,
"layouts": 12,
"layoutDurationMs": 4.005,
"taskDurationMs": 851.665,
"heapDeltaBytes": 1101688
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1959.7909999999956,
"styleRecalcs": 82,
"styleRecalcDurationMs": 44.752,
"layouts": 13,
"layoutDurationMs": 3.599,
"taskDurationMs": 945.95,
"heapDeltaBytes": 1888012
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1802.507999999989,
"styleRecalcs": 75,
"styleRecalcDurationMs": 34.912,
"layouts": 12,
"layoutDurationMs": 3.324,
"taskDurationMs": 730.68,
"heapDeltaBytes": 1131684
},
{
"name": "dom-widget-clipping",
"durationMs": 558.5379999999986,
"styleRecalcs": 15,
"styleRecalcDurationMs": 10.066000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 354.696,
"heapDeltaBytes": 6960084
},
{
"name": "dom-widget-clipping",
"durationMs": 567.8310000000124,
"styleRecalcs": 16,
"styleRecalcDurationMs": 13.180000000000001,
"layouts": 1,
"layoutDurationMs": 0.232,
"taskDurationMs": 359.35200000000003,
"heapDeltaBytes": 13239672
},
{
"name": "dom-widget-clipping",
"durationMs": 599.5240000000308,
"styleRecalcs": 13,
"styleRecalcDurationMs": 8.839,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 352.77599999999995,
"heapDeltaBytes": 13222776
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 591.7750000000126,
"styleRecalcs": 49,
"styleRecalcDurationMs": 11.899999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 381.94700000000006,
"heapDeltaBytes": -3419036
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 560.9409999999571,
"styleRecalcs": 50,
"styleRecalcDurationMs": 12.600999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 384.57800000000003,
"heapDeltaBytes": 14682856
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 581.0950000000048,
"styleRecalcs": 48,
"styleRecalcDurationMs": 11.604,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 386.55999999999995,
"heapDeltaBytes": 18959636
},
{
"name": "subgraph-idle",
"durationMs": 2031.4300000000003,
"styleRecalcs": 14,
"styleRecalcDurationMs": 13.946999999999997,
"layouts": 1,
"layoutDurationMs": 0.31100000000000005,
"taskDurationMs": 353.50399999999996,
"heapDeltaBytes": 1296308
},
{
"name": "subgraph-idle",
"durationMs": 1993.1150000000457,
"styleRecalcs": 12,
"styleRecalcDurationMs": 9.832999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 333.694,
"heapDeltaBytes": 1261808
},
{
"name": "subgraph-idle",
"durationMs": 2009.0289999999982,
"styleRecalcs": 11,
"styleRecalcDurationMs": 8.674,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 330.63300000000004,
"heapDeltaBytes": 637596
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1691.2809999999752,
"styleRecalcs": 77,
"styleRecalcDurationMs": 35.418,
"layouts": 16,
"layoutDurationMs": 4.1,
"taskDurationMs": 661.826,
"heapDeltaBytes": -1127304
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 2009.116000000006,
"styleRecalcs": 91,
"styleRecalcDurationMs": 50.497,
"layouts": 17,
"layoutDurationMs": 4.836,
"taskDurationMs": 943.1759999999999,
"heapDeltaBytes": 161140
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1744.3230000000085,
"styleRecalcs": 79,
"styleRecalcDurationMs": 39.965,
"layouts": 16,
"layoutDurationMs": 4.583,
"taskDurationMs": 688.01,
"heapDeltaBytes": -1099264
}
]
} |
|
note (non-blocking): type ComboWidgetValues =
| string[]
| Record<string, string>
| ((widget?: IComboWidget, node?: LGraphNode) => string[])But this type information is lost during the simplification step, meaning Ideally, Relevant files:
@coderabbitai Make an Issue to improve |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 57
The issue captures:
🧠 Learnings used |
## Summary
Adds support for values factory functions, e.g.
```
this.addWidget(
"combo",
"Dynamic",
"",
(e) => { },
{
values: () => {
return getSomeValuesHere()
}
}
)
```
Specifically for fixing KJNodes get/set
## Changes
- **What**: Check if object is a function, if so, calls it.
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8775-Add-support-for-values-factory-function-in-widget-select-combo-3036d73d3650819bb4e4f9181445cb1d)
by [Unito](https://www.unito.io)
## Summary
Adds support for values factory functions, e.g.
```
this.addWidget(
"combo",
"Dynamic",
"",
(e) => { },
{
values: () => {
return getSomeValuesHere()
}
}
)
```
Specifically for fixing KJNodes get/set
## Changes
- **What**: Check if object is a function, if so, calls it.
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8775-Add-support-for-values-factory-function-in-widget-select-combo-3036d73d3650819bb4e4f9181445cb1d)
by [Unito](https://www.unito.io)
|
@pythongosssss Successfully backported to #9882 |
|
@pythongosssss Successfully backported to #9883 |
…et select combo (#9883) Backport of #8775 to `cloud/1.41` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9883-backport-cloud-1-41-Add-support-for-values-factory-function-in-widget-select-combo-3226d73d3650817186b8c8827b123140) by [Unito](https://www.unito.io) Co-authored-by: pythongosssss <125205205+pythongosssss@users.noreply.github.com>
…t select combo (#9882) Backport of #8775 to `core/1.41` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9882-backport-core-1-41-Add-support-for-values-factory-function-in-widget-select-combo-3226d73d3650812ca13ac9755d33901b) by [Unito](https://www.unito.io) Co-authored-by: pythongosssss <125205205+pythongosssss@users.noreply.github.com>
Summary
Adds support for values factory functions, e.g.
Specifically for fixing KJNodes get/set
Changes
┆Issue is synchronized with this Notion page by Unito