Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/minor fixes #156

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions frontend/src/store/flowSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,33 @@ const flowSlice = createSlice({
return nodeObj
})

let edges = links.map((link) => ({
id: uuidv4(),
key: uuidv4(),
selected: false,
source: link.source_id,
target: link.target_id,
sourceHandle: link.source_handle || link.source_id,
targetHandle: link.target_handle || link.source_id,
}))
let edges = links.map((link) => {
const sourceNode = nodes.find(node => node.id === link.source_id);
const isRouterNode = sourceNode?.node_type === 'RouterNode';

// For router nodes, ensure targetHandle matches the format node_id.handle_id
let targetHandle = link.target_handle || link.source_id;
if (isRouterNode) {
// If targetHandle contains a dot, take only what's after the dot
if (targetHandle.includes('.')) {
targetHandle = targetHandle.split('.').pop() || targetHandle;
}
// Ensure it has the correct prefix
if (!targetHandle.startsWith(link.source_id + '.')) {
targetHandle = `${link.source_id}.${targetHandle}`;
}
}

return {
id: uuidv4(),
key: uuidv4(),
selected: false,
source: link.source_id,
target: link.target_id,
sourceHandle: link.source_handle || link.source_id,
targetHandle,
}
})
// deduplicate edges
edges = edges.filter(
(edge, index, self) =>
Expand Down