fix(web): recognize loop and approval node types in DAG builder (closes #1336)#1722
fix(web): recognize loop and approval node types in DAG builder (closes #1336)#1722nhiendohao wants to merge 2 commits into
Conversation
resolveNodeDisplay() fell through to the 'prompt' fallback for loop and approval nodes, giving them nodeType='prompt' with no promptText. useBuilderValidation then raised false-positive "prompt cannot be empty" errors for both node types. Changes: - dag-layout.ts: add loop and approval cases to resolveNodeDisplay() - DagNodeComponent.tsx: extend nodeType union; add TYPE_CONFIG entries and getContentPreview cases for loop and approval - index.css: add --node-loop (teal) and --node-approval (amber) tokens Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review SummaryVerdict: minor-fixes-needed Your PR adds UI support for two new workflow node types ( Blocking issuesNone — code is clean and ready to merge once tests are added. Suggested fixes
Minor / nice-to-haveNone. Compliments
Reviewed via maintainer-review-pr workflow (Pi/Minimax). Aspects run: code-review, test-coverage. |
…types Tests requested by Wirasm for PR coleam00#1722: - resolveNodeDisplay(): loop node → { label, nodeType, promptText }, approval → { label, nodeType } - dagNodesToReactFlow() integration: asserts loop and approval nodes have correct nodeType in output - getContentPreview(): loop multi-line prompt returns first line; approval returns empty string - Exports getContentPreview from DagNodeComponent.tsx to make it testable - Extends test script to cover src/components/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@Wirasm — tests added as requested. Three suites now cover the loop/approval changes:
|
|
Thanks for the fix @nhiendohao! Closing this so it can be reopened against the right base. This PR targets Easiest path: open a new PR from |
* fix(web): recognize loop and approval node types in DAG builder resolveNodeDisplay() fell through to the 'prompt' fallback for loop and approval nodes, giving them nodeType='prompt' with no promptText. useBuilderValidation then raised false-positive "prompt cannot be empty" errors for both node types. Changes: - dag-layout.ts: add loop and approval cases to resolveNodeDisplay() - DagNodeComponent.tsx: extend nodeType union; add TYPE_CONFIG entries and getContentPreview cases for loop and approval - index.css: add --node-loop (teal) and --node-approval (amber) tokens Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(web): add unit and integration tests for loop/approval DAG node types Tests requested by Wirasm for PR #1722: - resolveNodeDisplay(): loop node → { label, nodeType, promptText }, approval → { label, nodeType } - dagNodesToReactFlow() integration: asserts loop and approval nodes have correct nodeType in output - getContentPreview(): loop multi-line prompt returns first line; approval returns empty string - Exports getContentPreview from DagNodeComponent.tsx to make it testable - Extends test script to cover src/components/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: robby_kei <robby_kei@linecorp.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Problem
resolveNodeDisplay()indag-layout.tsonly handledbashandcommandnode types, falling through to apromptfallback for everything else. This meant loop and approval nodes were assignednodeType: 'prompt'with nopromptText, triggering a false-positive validation error inuseBuilderValidation.ts:The YAML is valid — these nodes correctly use
loop:andapproval:— but the web UI builder raised errors and rendered them incorrectly.Closes #1336.
Root Cause
useBuilderValidation.tsthen checkednodeType === 'prompt' && !promptText?.trim()and fired for both misclassified node types.Fix
dag-layout.tsAdded explicit
loopandapprovalcases toresolveNodeDisplay(). Loop nodes receivenodeType: 'loop'withpromptTextset toloop.prompt(used for content preview). Approval nodes receivenodeType: 'approval'.DagNodeComponent.tsxDagNodeData.nodeTypeunion:'command' | 'prompt' | 'bash' | 'loop' | 'approval'TYPE_CONFIGentries (teal badge for LOOP, amber for APPROVAL)getContentPreviewswitch to handle both new typesindex.cssAdded
--node-loop(teal,oklch(0.62 0.18 170)) and--node-approval(amber,oklch(0.72 0.17 40)) CSS custom properties and@theme inlinemappings.Before / After
Before: Any workflow with a
loop:orapproval:node showed errors in the Problems panel and rendered the node with a purple PROMPT badge and an empty prompt preview.After: Loop and approval nodes render with distinct colored badges (LOOP in teal, APPROVAL in amber), no validation errors, and the loop prompt text is shown as a content preview.
Testing
loop:orapproval:node in the builder