Skip to content

fix(web): recognize loop and approval node types in DAG builder#1744

Merged
Wirasm merged 2 commits into
coleam00:devfrom
nhiendohao:fix/web-loop-approval-node-type
May 25, 2026
Merged

fix(web): recognize loop and approval node types in DAG builder#1744
Wirasm merged 2 commits into
coleam00:devfrom
nhiendohao:fix/web-loop-approval-node-type

Conversation

@nhiendohao

@nhiendohao nhiendohao commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes false-positive "prompt cannot be empty" validation errors in the web DAG builder
  • loop and approval nodes were falling through to the prompt type in resolveNodeDisplay()
  • Adds explicit handling in dag-layout.ts, DagNodeComponent.tsx, and index.css

Closes #1336

Note

This is a retarget of #1722 which was closed because it targeted main instead of dev. Code and tests are unchanged — no rework was needed.

Test plan

  • Three test suites added covering resolveNodeDisplay() and DagNodeComponent (included in this branch)
  • Verify loop and approval nodes no longer trigger "prompt cannot be empty" errors in the web builder

Summary by CodeRabbit

  • New Features

    • Workflow diagrams now support two new node types: "loop" and "approval" with dedicated visual styling and content preview functionality.
  • Tests

    • Added test coverage for new node types and their content preview behavior.

Review Change Stack

robby_kei and others added 2 commits May 19, 2026 16:04
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>
…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>
@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f9801d82-3be6-4e43-8526-4d03fd022d87

📥 Commits

Reviewing files that changed from the base of the PR and between aa71520 and 642456f.

📒 Files selected for processing (6)
  • packages/web/package.json
  • packages/web/src/components/workflows/DagNodeComponent.test.ts
  • packages/web/src/components/workflows/DagNodeComponent.tsx
  • packages/web/src/index.css
  • packages/web/src/lib/dag-layout.test.ts
  • packages/web/src/lib/dag-layout.ts

📝 Walkthrough

Walkthrough

This PR adds support for two new DAG node types (loop and approval) by extending type unions, implementing detection and mapping logic in the node resolution layer, exporting a preview extraction function with styling configuration, and adding corresponding test coverage.

Changes

Loop and Approval Node Type Support

Layer / File(s) Summary
Node type definitions and resolution
packages/web/src/components/workflows/DagNodeComponent.tsx, packages/web/src/lib/dag-layout.ts, packages/web/src/lib/dag-layout.test.ts
DagNodeData.nodeType union and resolveNodeDisplay return type expanded to include loop and approval; resolveNodeDisplay now detects loop and approval nodes in the DAG and returns shaped objects with labels and extracted data (e.g., dn.loop.prompt becomes promptText for loop nodes). Tests verify correct mapping and end-to-end ReactFlow node conversion.
Content preview extraction and styling
packages/web/src/components/workflows/DagNodeComponent.tsx, packages/web/src/components/workflows/DagNodeComponent.test.ts, packages/web/src/index.css
getContentPreview is exported and handles loop (first line of promptText) and approval (empty string) preview text; TYPE_CONFIG adds styling configuration for the new node types; CSS theme adds --node-loop and --node-approval color variables.
Test runner configuration
packages/web/package.json
test script now includes Bun test runs for src/components/ directory.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Two nodes hop into the DAG today,
loop and approval find their way!
Prompts flow through, displayed with care,
Fresh colors sparkle—magic in the air! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing most required sections from the template (UX Journey, Architecture Diagrams, Label Snapshot, Validation Evidence, Security Impact, Compatibility, Human Verification, Side Effects, Rollback Plan, and Risks). Complete the PR description using the required template, including validation evidence (test results), security impact assessment, and rollback plan to meet repository standards.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding recognition of loop and approval node types in the DAG builder, which directly addresses the false-positive validation errors mentioned in the description.
Linked Issues check ✅ Passed The code changes directly address issue #1336 by adding explicit handling for loop and approval node types in dag-layout.ts, DagNodeComponent.tsx, and index.css to prevent false-positive 'prompt cannot be empty' validation errors.
Out of Scope Changes check ✅ Passed All changes are in-scope: test file additions for dag-layout and DagNodeComponent, styling additions for loop/approval nodes, and updates to node type handling all directly support fixing the validation issue in #1336.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Wirasm

Wirasm commented May 22, 2026

Copy link
Copy Markdown
Collaborator

@nhiendohao this PR appears to fully address #1336. Consider adding Closes #1336 to the PR body so the issue auto-closes on merge.

@Wirasm

Wirasm commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Review Summary

Verdict: ready-to-merge

Clean addition of loop and approval node types to the web DAG builder. TypeScript compiles clean, lint passes, and tests are included. No issues found.

Blocking issues

None.

Suggested fixes

None.

Minor / nice-to-have

None — this PR is clean.

Compliments

  • Minimal, targeted implementation that extends the existing node type pattern without over-engineering
  • Tests added for both dag-layout and DagNodeComponent covering the new node types
  • Typed imports used throughout (import type), no any leakage, proper return types on all functions

Reviewed via maintainer-review-pr workflow (Pi/Minimax). Aspects run: code-review.

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.

loop node validate failed

2 participants