Inserting a branching step wires all of its outputs to the same next step, and edges can't be re-routed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39.9k
- Forks
- 3.4k
- Avg merge
- 6h 51m
- Merged PRs (30d)
- 232
Description
Bug Description
When I insert a branching step (Conditional branch, or Wait until condition) between two
existing steps, every output of the new step, each branch edge and the continue edge, is
wired to the same immediate downstream step. A conditional branch therefore arrives with
all of its paths going to the identical next step, which is never the intent; the point of
a branch is that the paths differ.
I then can't correct it, because edges can't be re-pointed. resetFlowFromHogFlow in
products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx builds every edge
with reconnectable: false (along with deletable, selectable and focusable false),
node handles are isConnectable={false}, and React Flow's onReconnect isn't wired up
anywhere. So the wiring produced at insert time is permanent.
The cause looks like the insert path in the same file: the edge being replaced is spread
into each newly created edge, so its original to target is inherited by all of them
rather than being set per branch.
https://github.com/user-attachments/assets/2b341fe4-d357-4db2-80ed-cc8eb25fd9c1
How to reproduce
- Build a workflow several steps deep.
- Drag a Conditional branch from the Build panel onto an edge between two existing steps.
- Observe that both branch outputs point at the same downstream step.
- Try to drag either edge to a different target. Nothing happens.
Additional context
Expected: either the branch outputs are left unconnected to be wired up manually, or one
path continues and the others terminate. In either case it should be possible to re-point
an edge afterwards.
Two independently useful fixes: don't default every branch output to the replaced edge's
target, and make edges reconnectable with an onReconnect handler that rewrites the edge
target in the stored graph.
Happy to open a PR if you'd point me at the preferred approach.
Debug info
- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables or https://eu.posthog.com/settings/project-details#variables]
- [ ] PostHog Hobby self-hosted with `docker compose`, version/commit: [please provide]
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx, especially resetFlowFromHogFlow and the insert path that creates replacement edges. Review how React Flow edge reconnecting and node handle connectability are configured, then ensure branch outputs do not all inherit the replaced edge's target and can be re-pointed in the stored graph.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100