feat(sdk) Variable enhancement - #76
Conversation
…into feat/WB-139-variables
…into feat/WB-139-variables
| return ( | ||
| <ControlWrapper {...props}> | ||
| <DynamicTypedVariableOrInput | ||
| key={totalVariables} |
There was a problem hiding this comment.
key={totalVariables} now remounts a focused input: since suggestions refresh reactively, editing an ancestor while this input is focused changes the count and the remount drops focus, caret, and the open popup
'VariableTextreads suggestions from props each render, so the key looks unnecessary. Remove it here and atvariable-text-control.tsx:39anddependencies.tsx:32`; if the mentions lib truly needs a remount, key off content (join of suggestion ids), not a count, and never while focused.
There was a problem hiding this comment.
Changed total to key. I used total because that was enough in the current setup of the app.
editing an ancestor while this input is focused changes the count and the remount drops focus, caret, and the open popup
We can't change ancestors while the input is focused. The only way we can change ancestors without closing the node sidebar is by drawing an edge, which loses focus by definition.
In the future, when we have multiple people working on the workflow and synchronization that changes ancestors in the background with websockets, we can think about how to keep the focus then. It's just problematic.
The videos below show an artifact/error caused by changing ancestors for a string input in simple textarea, but dynamically typed inputs have {} shown conditionally if there are variables of the selected type. If we have a variable set there and someone removes the list of ancestors, we have another list of edge cases to solve, key just rerenders them again.
I'm open to tackling that, but I would handle it when it actually happens.
if the mentions lib truly needs a remount, key off content (join of suggestion ids), not a count, and never while focused.
One of the problems solved with a key:
Without it
https://github.com/user-attachments/assets/6606ec2f-5222-4c16-8ebe-ca0cb1c2e5b5
With it
https://github.com/user-attachments/assets/c68e03ef-4c49-4fe5-b951-c1942a15442b
Workflow Builder introduced variable support some time ago, allowing sidebar controls to use variables from previous nodes or global variables.
This PR enhances the feature with the missing logic to make variable usage more robust and flexible.
Main changes
Variables provided by nodes to downstream nodes can now depend on:
Nagranie.z.ekranu.2026-08-14.o.18.32.10.mov
Node variables store:
Previously, variables from previous nodes were calculated when the control was mounted. We traversed the graph and calculated their values at the same time - now we keep nodes variables in the store and only collect them:
New single variable control (previously used in conditions)
Nagranie.z.ekranu.2026-08-14.o.18.28.48.mov
It shows a date picker with
{}when date variables are available.Fixes
totalVariablesIt's worth noting that the majority of the changes are encapsulated in
packages/sdk/src/features/variables/. So while reviewing, we can identify what is used externally as a useful public API and note the core functions that could be valuable to expose.