Output attributes : Keep saved template value instead of node description#3132
Output attributes : Keep saved template value instead of node description#3132servantftransperfect wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request preserves output expression templates when loading nodes from saved project files, ensuring that node type description changes only affect new nodes. It also corrects the parameter order in validateIncomingConnection and removes a list-connection restriction in AttributePin.qml. Feedback suggests moving the _expressionTemplate assignment logic to Attribute._setValue to support nested attributes inside a GroupAttribute, and removing the corresponding asymmetrical list-connection restriction in outputDropArea within AttributePin.qml for consistent drag-and-drop behavior.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| attr._setValue(value) | ||
| # For output expression attributes loaded from a file, store the expression template | ||
| # so that description changes on the node type only affect new nodes. | ||
| if isOutput and description.isExpression and isinstance(value, str): | ||
| attr._expressionTemplate = value |
There was a problem hiding this comment.
The current implementation of storing the _expressionTemplate in attributeFactory does not work for nested attributes inside a GroupAttribute.
When a GroupAttribute is loaded from a file, attributeFactory is called for the group itself with the serialized dictionary. The child attributes are initialized with value=None in GroupAttribute._initValue (so their _expressionTemplate remains None), and then their values are updated later via _setValue inside GroupAttribute._setValue. Since _setValue does not update _expressionTemplate, any nested output expression attributes will lose their templates.
Suggestion
Move this logic into Attribute._setValue so that it automatically captures the expression template whenever an output expression attribute is set with a template string (which can be identified by checking if the string contains '{'). This fixes the issue for both flat and nested attributes, and simplifies attributeFactory.
For example, in Attribute._setValue (around line 209):
if self.isOutput and self._desc.isExpression and isinstance(value, str) and "{" in value:
self._expressionTemplate = value| attr._setValue(value) | |
| # For output expression attributes loaded from a file, store the expression template | |
| # so that description changes on the node type only affect new nodes. | |
| if isOutput and description.isExpression and isinstance(value, str): | |
| attr._expressionTemplate = value | |
| attr._setValue(value) |
| || !validIncomingConnection // Connection is not allowed | ||
| || drag.source.nodeItem === inputDragTarget.nodeItem // Connection between attributes of the same node | ||
| || drag.source.isList && childrenRepeater.count // Source/target are lists but target already has children | ||
| || drag.source.connectorType === "input" // Refuse to connect an "input pin" on another one (input attr can be connected to input attr, but not the graphical pin) |
There was a problem hiding this comment.
Removing the restriction drag.source.isList && childrenRepeater.count from inputDropArea is a good improvement, as it allows connecting list attributes even if the target list already has children (which are properly cleared during connection anyway).
However, there is an asymmetrical check in outputDropArea (around line 375 in the codebase, currently outside this diff) that was not updated:
|| (drag.source.isList && childrenRepeater.count) // Source/target are lists but target already has children
In outputDropArea (on the output pin), drag.source is the input pin (target of the connection) and childrenRepeater belongs to root (the output pin / source of the connection). This means the check incorrectly blocks connecting a list input to a list output if the source output list already has children (which is the normal state for computed outputs!).
To ensure consistent behavior regardless of the drag-and-drop direction, this restriction should also be removed from outputDropArea in a follow-up or as part of this PR.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3132 +/- ##
===========================================
- Coverage 85.33% 85.32% -0.01%
===========================================
Files 73 73
Lines 11414 11430 +16
===========================================
+ Hits 9740 9753 +13
- Misses 1674 1677 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d1c0cad to
61294dc
Compare
| child_attr = attr._value.get(key) | ||
| if child_attr is not None: | ||
| _captureExpressionTemplates(child_attr, child_value) | ||
| except (KeyError, AttributeError): |
No description provided.