Skip to content

Conversation

@betterclever
Copy link
Contributor

Summary

Fixes ENG-114: Entry node issue

This PR fixes multiple issues with the Entry Point node's dynamic ports (runtime inputs):

Issues Fixed

Issue 1: Edge connections from wrong output port

When dragging from Input 2 on an Entry Point node, it would incorrectly connect from Input 1.

Root Cause: ReactFlow caches handle positions and wasn't being notified when dynamic ports changed.

Fix: Added `useEffect` in `WorkflowNode.tsx` that calls `updateNodeInternals()` whenever `effectiveOutputs` or `componentInputs` change, forcing ReactFlow to recalculate handle positions.

Issue 2: Entry Point shows 'Triggered' instead of actual inputs

When loading a workflow, the Entry Point would show the fallback 'Triggered' output instead of the configured runtime inputs (Input 1, Input 2, etc.). Opening the config panel would magically fix it.

Root Cause: Two bugs in `workflows.service.ts`:

  1. The `parse()` method was passing the wrong object to `resolvePorts`:

    • Before: `nodeData.config` → `{params: {...}, inputOverrides: {...}}`
    • After: `nodeData.config.params` → `{runtimeInputs: [...]}`
  2. Dynamic ports were only resolved when saving workflows, not when fetching.

Fix:

  • Fixed param extraction to use `nodeData.config.params`
  • Added `resolveGraphPorts()` method that resolves dynamic ports when fetching workflows
  • `buildWorkflowResponse()` now applies port resolution before returning to frontend

Technical Details

The dynamic ports system now correctly:

  • ✅ Resolves ports when creating/updating workflows (via `parse`)
  • ✅ Resolves ports when fetching workflows (via `resolveGraphPorts`)
  • ✅ Updates ReactFlow handle positions when ports change (via `updateNodeInternals`)
  • ✅ Properly types the graph using `WorkflowGraph` instead of `any`

Files Changed

  • `frontend/src/components/workflow/WorkflowNode.tsx` - Added `updateNodeInternals` effect
  • `backend/src/workflows/workflows.service.ts` - Fixed param extraction + added `resolveGraphPorts`

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 122b2228ea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 410 to 411
// Get parameters from node data (stored in config.params)
const params = nodeData.config?.params || {};

Choose a reason for hiding this comment

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

P2 Badge Include legacy param locations in port resolution

The new resolveGraphPorts only reads nodeData.config?.params, so workflows saved before the config.params migration (where params live under node.data.parameters or directly on node.data.config) will resolve ports with {} and still show the fallback outputs (e.g., Entry Point stays on “Triggered”) when fetched. You already handle legacy locations in parse(), but fetch-time resolution doesn’t, so older workflows won’t get the fix until they’re re-saved. Consider using the same fallback chain as parse() to avoid leaving legacy graphs unresolved.

Useful? React with 👍 / 👎.

@betterclever betterclever force-pushed the betterclever/fix-runtime-input-mapping branch 2 times, most recently from d01fb2d to 06a7685 Compare January 20, 2026 05:57
This fixes a bug where dragging from Input 2 on an Entry Point node would
incorrectly connect from Input 1. The issue was that ReactFlow caches
handle positions, and without calling updateNodeInternals when dynamic
outputs/inputs change, it would use stale positions.

Added a useEffect that triggers updateNodeInternals whenever the output
or input port IDs change, ensuring ReactFlow recalculates handle positions.

Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Fixes ENG-114: Entry node issue

When dragging from Input 2 on an Entry Point node, it would incorrectly
connect from Input 1. This was because ReactFlow caches handle positions
and wasn't being notified when dynamic ports changed.

**Fix**: Added useEffect in WorkflowNode.tsx that calls updateNodeInternals
whenever effectiveOutputs or componentInputs change, forcing ReactFlow to
recalculate handle positions.

When loading a workflow, the Entry Point would show the fallback 'Triggered'
output instead of the configured runtime inputs (Input 1, Input 2, etc.).
Opening the config panel would fix it by calling resolvePorts.

**Root Cause**: Two bugs in workflows.service.ts
1. The parse() method was passing the wrong object to resolvePorts:
   - Before: nodeData.config (contains {params: {...}, inputOverrides: {...}})
   - After: nodeData.config.params (contains {runtimeInputs: [...]})

2. Dynamic ports were only resolved when saving workflows, not when fetching.

**Fix**:
- Fixed param extraction: nodeData.config.params instead of nodeData.config
- Added resolveGraphPorts() that resolves dynamic ports when fetching workflows
- buildWorkflowResponse now applies port resolution before returning to frontend

The dynamic ports system now correctly:
- Resolves ports when creating/updating workflows (via parse)
- Resolves ports when fetching workflows (via resolveGraphPorts)
- Updates ReactFlow handle positions when ports change (via updateNodeInternals)
- Properly types the graph using WorkflowGraph instead of 'any'

Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
…esolution

- Added extractNodeParams() to handle legacy config schema migrations:
  - Current: nodeData.config.params
  - Legacy: nodeData.parameters
  - Legacy: nodeData.config (when config was params directly)

- Added extractComponentId() to handle frontend node extensions

- Added resolveNodePorts() as single-node resolution helper

- Refactored parse() to use shared resolveGraphPorts()

This ensures both save and fetch operations use the same logic,
fixing the issue where legacy workflows wouldn't have ports resolved
correctly when fetched until re-saved.

Types:
- Uses z.infer<WorkflowNodeSchema> and z.infer<WorkflowNodeDataSchema>
- No more 'as any' casts for node data (except for extended properties)

Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
@betterclever betterclever force-pushed the betterclever/fix-runtime-input-mapping branch from 06a7685 to f5d496b Compare January 20, 2026 13:12
@betterclever betterclever merged commit 6349f06 into main Jan 20, 2026
3 checks passed
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