Skip to content

fix(mothership): block subflow re-parenting in embedded workflow view#5418

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/embedded-workflow-drag
Jul 4, 2026
Merged

fix(mothership): block subflow re-parenting in embedded workflow view#5418
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/embedded-workflow-drag

Conversation

@TheodoreSpeaks

@TheodoreSpeaks TheodoreSpeaks commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • In the mship chat panel's embedded workflow view, dragging a block over a loop/parallel highlighted it and dropped the block INTO the subflow as a persistent collaborative op — with no way to undo it from the panel. Dragging itself is fine; the insertion is the bug.
  • Fix: in embedded mode, onNodeDrag skips container-intersection detection entirely, so a drag over a subflow never highlights it and never arms potentialParentId. Both drag-stop paths already bail when potentialParentId equals the drag-start parent, so block positions still move normally but a block can never be inserted into (or pulled out of) a subflow from the embedded view.
  • Standalone editor untouched (the skip is embedded-only).

Type of Change

  • Bug fix

Testing

Tested manually in the embedded panel with a loop workflow: dragging a block still works, dragging it directly onto the loop shows no drop-target highlight, and after dropping on the loop the block's parentId is unchanged (verified via API). Standalone editor drag/reparent behavior unchanged. bun run lint, bun run check:api-validation:strict pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 4, 2026 8:58pm

Request Review

@cursor

cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Scoped to the embedded workflow canvas path; standalone editor drag behavior is unchanged aside from shared callback dependencies.

Overview
Embedded mothership workflow previews were still running full drag lifecycle hooks when the user could edit, which could persist re-parenting (dropping blocks into loop/parallel subflows) as collaborative updates even though the panel is meant to stay read-only for structure changes.

This change aligns drag behavior with other embedded gates (onConnect, nodesDraggable, etc.): onNodeDragStart and onNodeDragStop are only wired when !embedded && canEdit, so drag-start state and drag-stop collaborative parent/position commits do not run in the embedded view.

During drag in embedded mode, onNodeDrag returns early after optional in-container resize logic, skipping subflow hit-testing, highlight, and potentialParentId updates so blocks cannot be armed for insert/remove from subflows from the panel canvas.

Reviewed by Cursor Bugbot for commit b00a661. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where nodes in the embedded (mothership chat panel) workflow view could still be dragged despite the surface being intended as read-only. The root cause was that per-node draggable properties override ReactFlow's global nodesDraggable={false}, and the onNodeDrag* handlers were not gated on !embedded.

  • Adds !embedded to both per-node draggable computation sites (lines ~2472 and ~2517) so the override can no longer bypass the global lock.
  • Adds !embedded to onNodeDrag, onNodeDragStop, and onNodeDragStart handler bindings, matching the convention already used by the connect/edges handlers.

Confidence Score: 4/5

Safe to merge; the root cause (per-node draggable overriding the global lock) is correctly addressed at both call sites, and the handler bindings now match the pattern used elsewhere in the file.

The core fix is tight and well-targeted. One minor gap remains: the three selection-drag handlers (onSelectionDragStart, onSelectionDrag, onSelectionDragStop) still lack !embedded, leaving them inconsistent with the node-drag handlers that were just patched. In practice they cannot fire in embedded mode because ReactFlow's global nodesDraggable and elementsSelectable props already block selection. But this is the same class of inconsistency that caused the original bug, so it is worth closing before a future refactor reintroduces the issue.

Only workflow.tsx is changed; the selection drag handler bindings (lines 4115–4121) warrant a second look for the inconsistency described above.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Adds !embedded guard to per-node draggable props and onNodeDrag* handlers; selection drag handlers (onSelectionDragStart/Drag/Stop) are not updated but remain protected by global nodesDraggable and elementsSelectable props

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User initiates node drag] --> B{Is embedded?}
    B -- Yes --> C[per-node draggable = false
✅ FIXED: !embedded added]
    B -- No --> D{workflowReadOnly OR
isBlockProtected?}
    D -- Yes --> E[per-node draggable = false]
    D -- No --> F[per-node draggable = true]
    F --> G[ReactFlow global nodesDraggable]
    G --> H[nodesDraggable = !embedded && canEdit]
    H --> I[Drag permitted]
    I --> J{onNodeDrag handler}
    J -- embedded --> K[handler = undefined
✅ FIXED: !embedded added]
    J -- not embedded + canEdit --> L[onNodeDrag fires]
    L --> M[onNodeDragStop fires]
    M --> N[Collaborative op emitted]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[User initiates node drag] --> B{Is embedded?}
    B -- Yes --> C[per-node draggable = false
✅ FIXED: !embedded added]
    B -- No --> D{workflowReadOnly OR
isBlockProtected?}
    D -- Yes --> E[per-node draggable = false]
    D -- No --> F[per-node draggable = true]
    F --> G[ReactFlow global nodesDraggable]
    G --> H[nodesDraggable = !embedded && canEdit]
    H --> I[Drag permitted]
    I --> J{onNodeDrag handler}
    J -- embedded --> K[handler = undefined
✅ FIXED: !embedded added]
    J -- not embedded + canEdit --> L[onNodeDrag fires]
    L --> M[onNodeDragStop fires]
    M --> N[Collaborative op emitted]
Loading

Reviews (1): Last reviewed commit: "fix(mothership): disable node dragging i..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx
@TheodoreSpeaks TheodoreSpeaks force-pushed the fix/embedded-workflow-drag branch from 03546b6 to b00a661 Compare July 4, 2026 20:58
@TheodoreSpeaks TheodoreSpeaks changed the title fix(mothership): disable node dragging in embedded workflow view fix(mothership): block subflow re-parenting in embedded workflow view Jul 4, 2026
@TheodoreSpeaks TheodoreSpeaks merged commit acf4afb into staging Jul 4, 2026
19 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the fix/embedded-workflow-drag branch July 4, 2026 22:18
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.

1 participant