Skip to content

Fix Flow Engine schema validation and improve Human Approval UX#229

Draft
esafwan wants to merge 1 commit into
feature/flow-backend-integrationfrom
claude/test-user-flows-ORf0E
Draft

Fix Flow Engine schema validation and improve Human Approval UX#229
esafwan wants to merge 1 commit into
feature/flow-backend-integrationfrom
claude/test-user-flows-ORf0E

Conversation

@esafwan
Copy link
Copy Markdown
Contributor

@esafwan esafwan commented Mar 29, 2026

Summary

This PR addresses critical schema validation gaps in the Flow Engine and significantly improves the Human Approval node's user experience and functionality. The changes ensure that all node types supported by the backend execution engine are properly validated, and add missing UI controls and context-linking features to the Human Approval workflow.

Key Changes

Schema & Validation Fixes

  • Added missing node types to ALLOWED_NODE_TYPES in flow_definition.py: condition, http_request, transform, and loop are now properly recognized during flow validation (previously would fail validation despite being fully supported by the engine)

Human Approval Node Enhancements

  • Added Approval Type selector (role-based vs. user-based approval) with conditional UI rendering
  • Replaced plain text approver role input with Combobox that auto-fetches and suggests available Frappe roles via new getRoles() API
  • Added Approver Users field for user-based approval workflows (comma-separated email list)
  • Added Context Summary field with VariablePicker support to provide approvers with contextual information about what they're approving
  • Added Reference DocType and Reference Name fields to link approvals to specific documents (e.g., "Approve Sales Invoice #INV-001"), with variable interpolation support for dynamic references
  • Backend context interpolation for context_summary and reference_name fields so approvers see resolved values

UI/UX Improvements

  • Fixed NodeSelectionModal trigger mode: Actions tab now hidden when editing trigger nodes (mode='trigger'), reducing confusion
  • Cleaned up trigger sub-tabs: Removed empty "Apps" and "Utility" tabs, keeping only "Explore" (4 standard triggers) and "AI & Agents"
  • Fixed tool-call config structure: Normalized save_result_to_context to use nested output object structure for consistency with sidebar expectations

API & Type Updates

  • New getRoles() function in agentApi.ts to fetch disabled=0 roles from Frappe
  • Updated TypeScript types in flow.types.ts to include optional output object in ToolCallActionConfig
  • Extended node schema in flow_api.py to include new Human Approval fields in config schema

Implementation Details

The Human Approval node now supports a complete approval workflow with:

  • Role-based or user-based approval routing
  • Contextual information display (context_summary with variable interpolation)
  • Document linking for approval context (reference_doctype + reference_name)
  • Auto-suggest for approver roles via Frappe API

The backend properly interpolates variables in context_summary and reference_name before storing in waiting_data, ensuring approvers see resolved values rather than template syntax.

All changes maintain backward compatibility—existing flows without the new fields will continue to work with sensible defaults.

https://claude.ai/code/session_01VUxzR94VDLiL2Haj5ovyun

… trigger modal

- Add condition, http_request, transform, loop to ALLOWED_NODE_TYPES in
  flow_definition.py (flows using these 4 node types were rejected on save)
- Remove Actions tab from trigger NodeSelectionModal (only triggers shown
  when editing start node); remove empty Apps/Utility sub-tabs
- Human Approval: replace plain text approver_role with Combobox that
  auto-suggests Frappe roles; add approval_type selector (role/user),
  approver_users field, context_summary with VariablePicker, reference
  doctype/name fields for linked document context
- Backend: update _exec_human_approval to interpolate and pass
  context_summary, reference_doctype, reference_name in waiting data
- Fix tool-call config: NodeSelectionModal now uses nested output
  structure matching RightSidebar expectations
- Update flow_api.py node schemas for human.approval with new fields
- Update TypeScript types (HumanInLoopActionConfig, ToolCallActionConfig)
- Add getRoles() API service for role auto-suggest
- Add comprehensive test/workflow/FLOW_ANALYSIS.md with findings

https://claude.ai/code/session_01VUxzR94VDLiL2Haj5ovyun
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.

2 participants