feat: Add full field support to emitTask form generation - #433
lornakelly merged 6 commits into
Conversation
✅ Deploy Preview for openworkflow-editor ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
🟡 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:
buildDiscriminatorreturnstypeof data === "string"for each one, whileOneOfFieldRowselects the first matching variant. Consequently one branch (for example URI versus Expression forsource,dataschema, ortime) 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
ExpressionDataSchemais relabeled as “Expression” above, but it is not recognized here as a runtime expression (its ref/title isexpressionDataSchema/ExpressionDataSchema, notruntimeExpression/RuntimeExpression). ThedataschemaExpression branch therefore getsisRuntimeExpression: falseand 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.
7f18ab4 to
a1ee806
Compare
lornakelly
left a comment
There was a problem hiding this comment.
@handreyrc Still reviewing but have added some comments
69a99d8 to
b48f0c0
Compare
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>
d0c0173 to
67f5690
Compare
55aea95
into
open-workflow-specification:feature/node-editing
| */ | ||
| export interface JsonField extends FieldBase { | ||
| kind: "json"; | ||
| format: "json" | "yaml"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Apologies, I merged before I saw these review comments! @handreyrc if you can address these as well and open another PR?
| } | ||
| } | ||
| setInputValue(typeof live === "string" ? live : ""); | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
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.
| return; | ||
| } | ||
| setText(valueToText(fromDefault, field.format)); | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
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.
Closes #401
This PR introduces full field support to
emitTaskform generation in both read-only and edit mode.Not Addressed in This PR
Changes
source,time,dataschema, anddatavariants.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.{}) are now rendered as a structured YAML/JSON textarea (viaStructuredValueField) 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
emitTaskin both read-only and edit mode.