Skip to content

feat: Add full field support to emitTask form generation - #433

Merged
lornakelly merged 6 commits into
open-workflow-specification:feature/node-editingfrom
handreyrc:emitTask-form
Sep 21, 2026
Merged

lornakelly merged 6 commits into
open-workflow-specification:feature/node-editingfrom
handreyrc:emitTask-form

Conversation

@handreyrc

@handreyrc handreyrc commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #401

This PR introduces full field support to emitTask form generation in both read-only and edit mode.

Not Addressed in This PR

  • Layered validation (field-level and task-level).

Changes

  • Added support for emitTask multi-level field rendering, including source, time, dataschema, and data variants.
  • Extended the generic schema-to-form-field walker to correctly handle structural patterns (all-string variant lists, empty schema variants, transparent wrapper elimination) that surface the correct fields and variants for emitTask and other task types.
  • Transparent intermediate object wrappers are eliminated when they are loose containers (additionalProperties: true) with exactly one child that is itself an object group — so that wrapper is skipped and the sole child is promoted directly. Strict structural wrappers (unevaluatedProperties: false) and multi-child containers are preserved.
  • Empty and unconstrained schema variants ({}) are now rendered as a structured YAML/JSON textarea (via StructuredValueField) instead of a plain string input or a key-value editor — ensuring that any JSON value type (object, array, number, boolean, null) is correctly preserved and displayed.

How to Test

  • Use the Examples / Workflows → Emit story in Storybook to validate emitTask in both read-only and edit mode.

@netlify

netlify Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for openworkflow-editor ready!

Name Link
🔨 Latest commit 67f5690
🔍 Latest deploy log https://app.netlify.com/projects/openworkflow-editor/deploys/6aad4f6f7ec28a0008d98780
😎 Deploy Preview https://deploy-preview-433--openworkflow-editor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Variant discrimination and unconstrained JSON handling currently produce incorrect form behavior for valid emit data.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds schema-driven emitTask form fields for read-only and edit modes.

Changes:

  • Adds emit event field variants and transparent wrapper handling.
  • Renders unconstrained variants as key-value maps.
  • Adds unit coverage and a minor changeset.
File summaries
File Description
schemaToFormFields.ts Extends variant mapping and wrapper elimination.
schemaToFormFields.test.ts Tests emit fields and endpoint variants.
.changeset/emitTask-form.md Records the feature release.
Review details

Suppressed comments (2)

packages/open-workflow-diagram-editor/src/core/schemaToFormFields.ts:815

  • Preserving every all-string variant leaves their discriminators indistinguishable: buildDiscriminator returns typeof data === "string" for each one, while OneOfFieldRow selects the first matching variant. Consequently one branch (for example URI versus Expression for source, dataschema, or time) can never be auto-selected correctly in read-only mode. These variants need mutually exclusive matching based on the runtime-expression syntax (and any other relevant schema constraints) before they are exposed separately.
  const allStrings = resolvedList.every((item) => item.kind === "string");
  if (allStrings && resolvedList.length > 1) {
    return resolvedList.map((item) => ({
      label: item.label,
      fields: item.fields,
      matchesData: item.matchesData,
    }));

packages/open-workflow-diagram-editor/src/core/schemaToFormFields.ts:763

  • ExpressionDataSchema is relabeled as “Expression” above, but it is not recognized here as a runtime expression (its ref/title is expressionDataSchema/ExpressionDataSchema, not runtimeExpression/RuntimeExpression). The dataschema Expression branch therefore gets isRuntimeExpression: false and loses the expression placeholder/styling. Include this schema in the runtime-expression detection.
        const isRe =
          (typeof c.$ref === "string" && c.$ref.includes("runtimeExpression")) ||
          resolved.title === "RuntimeExpression" ||
          RUNTIME_EXPRESSION_PATTERN.test(String(resolved.pattern ?? ""));
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/open-workflow-diagram-editor/src/core/schemaToFormFields.ts Outdated
@handreyrc
handreyrc force-pushed the emitTask-form branch 2 times, most recently from 7f18ab4 to a1ee806 Compare September 16, 2026 15:37

@lornakelly lornakelly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@handreyrc Still reviewing but have added some comments

Comment thread packages/open-workflow-diagram-editor/src/core/schemaToFormFields.ts Outdated
Comment thread packages/open-workflow-diagram-editor/src/side-panel/forms/FormField.tsx Outdated
Comment thread packages/open-workflow-diagram-editor/src/side-panel/EditFormFooter.tsx Outdated
Comment thread packages/open-workflow-diagram-editor/src/side-panel/EditFormFooter.tsx Outdated
Comment thread packages/open-workflow-diagram-editor/src/side-panel/EditFormFooter.tsx Outdated
Comment thread packages/open-workflow-diagram-editor/src/side-panel/EditFormFooter.tsx Outdated
Comment thread packages/open-workflow-diagram-editor/src/side-panel/EditFormFooter.tsx Outdated
Comment thread packages/open-workflow-diagram-editor/src/side-panel/forms/FormField.tsx Outdated
Comment thread packages/open-workflow-diagram-editor/src/core/schemaToFormFields.ts Outdated
Signed-off-by: Handrey Cunha <handrey.cunha@gmail.com>
Signed-off-by: Handrey Cunha <handrey.cunha@gmail.com>
Signed-off-by: Handrey Cunha <handrey.cunha@gmail.com>
Signed-off-by: Handrey Cunha <handrey.cunha@gmail.com>
Signed-off-by: Handrey Cunha <handrey.cunha@gmail.com>
Signed-off-by: Handrey Cunha <handrey.cunha@gmail.com>

@lornakelly lornakelly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lornakelly
lornakelly merged commit 55aea95 into open-workflow-specification:feature/node-editing Sep 21, 2026
10 checks passed

@fantonangeli fantonangeli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adding a few comments:

*/
export interface JsonField extends FieldBase {
kind: "json";
format: "json" | "yaml";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We already have ContentFormat = "json" | "yaml" defined in workflowSdk.ts and used elsewhere in the diagram editor. Could we reuse it here instead of repeating the "json" | "yaml" union?
The same applies to the other places introduced in this PR that use the same union.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Apologies, I merged before I saw these review comments! @handreyrc if you can address these as well and open another PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fantonangeli,

Addressed in a separate PR.
#444

}
}
setInputValue(typeof live === "string" ? live : "");
// eslint-disable-next-line react-hooks/exhaustive-deps

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is disabling react-hooks/exhaustive-deps necessary here?
Could we simply include getValues and getFieldState in the dependency array instead and avoid suppressing the rule?
If is necessary, I would suggest adding a comment about it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fantonangeli,

Addressed in a separate PR.
#444

return;
}
setText(valueToText(fromDefault, field.format));
// eslint-disable-next-line react-hooks/exhaustive-deps

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I noticed a few react-hooks/exhaustive-deps suppressions in this PR.

Could we check whether they are actually necessary and, where possible, include the missing dependencies instead of disabling the rule?

If a suppression is required for a specific reason, I would suggest adding a short comment explaining why.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fantonangeli,

Addressed in a separate PR.
#444

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.

5 participants