Skip to content

15283 workflow property editor - #15289

Draft
kriben wants to merge 3 commits into
devfrom
15283-workflow-property-editor
Draft

kriben wants to merge 3 commits into
devfrom
15283-workflow-property-editor

Conversation

@kriben

@kriben kriben commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes #15283.

@kriben

kriben commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

Merge after #15288.

Dicts with plain values, e.g. dict[str, Path] or dict[str, int], are now
configurable and edited as a table with Add Entry and per-row Remove
buttons. Dicts of models and optional values stay connectable ports.
@kriben
kriben force-pushed the 15283-workflow-property-editor branch from 07d7653 to aab3246 Compare December 4, 2026 11:25

@kriben kriben left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review (open-code-review, delegation mode). Coverage: 16/16 reviewable files reviewed (100%); docs/workflow-ui-design.md excluded by OCR but read for context.

No critical/high findings. 4 medium, 4 low; see inline comments.

Looks good: dict rows without a key are kept across syncs, round-trip through the project file works, item_enum is excluded for nullable items, dicts of models/optional values remain ports, deferred row removal via PdmPointer + singleShot is safe. Tests cover project-file round trip, sync, copy and not-a-choice values. Suggested additional tests: clearing an optional enum, explicit null, scalar default for a list field.

if ( resinsightType == "View" ) return RimWorkflowViewBinding::classKeywordStatic();
if ( resinsightType == "Vec3" ) return RimWorkflowVec3Binding::classKeywordStatic();
if ( fieldSchema.contains( "dict_value_type" ) ) return RimWorkflowDictBinding::classKeywordStatic();
if ( fieldSchema.contains( "enum" ) ) return RimWorkflowEnumBinding::classKeywordStatic();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] Saved values are lost in existing projects. Enum/Literal fields were RimWorkflowStringBinding, list[Literal] was RimWorkflowArrayBinding, and dict fields were ports. After this change the class keyword differs, so syncFromSchema creates a new binding. Detached values are keyed by field/classKeyword, so the user-entered value is never restored and the field silently falls back to input.yaml/model default. Consider falling back to a detached/removed value with the same field name but a different keyword, and converting it.

if ( fieldNeedingOptions != &m_value ) return options;

const QJsonValue value = toJsonValue();
if ( value.isNull() ) options.push_back( caf::PdmOptionItemInfo( "(not set)", QString() ) );

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] Optional Enum/Literal cannot be cleared. (not set) is only offered while the value is null, so once a choice is picked there is no way back to None, although the docs list Optional[...] as supported. An explicit null from input.yaml is also not preserved (no isExplicitNull() override), so when the model default is not None the null is dropped and the default is used. Suggest always offering (not set) for nullable / non-required fields and mapping it to unset / explicit null.

else
{
// Text that is not a JSON list is kept until a value is selected
m_value = value.isString() ? value.toString() : QString();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] Non-list scalar default becomes "". If input.yaml holds a number/bool for a list field (e.g. levels: 3), m_hasValue is true but m_value is empty, so toJsonValue() returns the string "" and the job silently gets "" instead of 3. Wrap scalars into a one-element list, or store the JSON text of any value.

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWorkflowDictBinding::removeEntryByUi( RimWorkflowDictEntry* entry )

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] A dict cannot return to unset. After removing all rows hasValue() stays true and {} is sent rather than omitting the field. For an optional dict, {} and absent may differ semantically.

if ( type == "path" || type == "directory-path" )
m_pathValue = value.toString();
else if ( type == "integer" )
m_intValue = value.toInt();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] value.toInt() silently yields 0 for non-integral doubles or strings, and values outside the int range overflow PdmField<int>. This also applies when the dict value type changes and rows are rebuilt from the old values.

QJsonObject values;
for ( const RimWorkflowDictEntry* entry : m_entries.childrenByType() )
{
if ( !entry->key().isEmpty() ) values.insert( entry->key(), entry->value() );

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] Duplicate keys are silently collapsed (last row wins). Consider flagging duplicates in the table/editor.

{
const QJsonValue value = RimWorkflowSchemaTools::literalFromText( text );
if ( selected.contains( value ) || selectedChoices.contains( value ) ) continue;
( choices().contains( value ) ? selectedChoices : selected ).append( value );

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] choices() parses JSON on every loop iteration here and in the loop below. Cache it in a local once.

//--------------------------------------------------------------------------------------------------
/// Strings are shown without quotes
//--------------------------------------------------------------------------------------------------
QString RimWorkflowEnumBinding::choiceLabel( const QJsonValue& choice )

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] The string "1" and the integer 1 get the same label 1. Only matters for mixed-type Literals.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workflow manager: Improve property editor for task

1 participant