Skip to content

Flow endpoint detach off a stock has no live preview (only valve moves) #830

Description

@bpowers

Problem

In src/diagram/drawing/Canvas.tsx deriveRenderState, dragging a flow endpoint (arrowhead/source) that is currently attached to a stock does not live-update the flow path. Only the flow valve moves during the drag; the flow line and arrowhead stay pinned to the stock until pointer-up, at which point the geometry snaps to a newly-created cloud at the release position (created by flow-attach.ts reattachEndpoint's newCloud branch).

This is the same class of bug as the recently-fixed cloud-endpoint case: for an along-axis (parallel) drag, the endpoint drag routes through applyGroupMovement -> UpdateFlow (drawing/Flow.tsx), which treats the drag as a valve slide rather than a reroute, so the path preview is stale.

Scope / why it wasn't fixed with the cloud case

The just-landed fix added a branch in deriveRenderState (Canvas.tsx around line 924-961) that calls growEndpointDrag (from src/diagram/flow-attach.ts) -> UpdateCloudAndFlow so the flow line, arrowhead, and valve all track the dragged endpoint. That branch is gated on endpointEl?.type === 'cloud'; a stock endpoint deliberately falls back to the old applyGroupMovement/UpdateFlow behavior. A live detach preview needs to synthesize a cloud that follows the cursor, which was out of scope for the reported cloud-only bug.

Why it matters

UX polish / consistency in the diagram editor. Detaching a flow endpoint off a stock feels broken relative to dragging a cloud endpoint: the user drags but the flow path doesn't follow, then it jumps on release. Low-to-medium priority.

Component(s) affected

  • src/diagram/drawing/Canvas.tsx (deriveRenderState, the cloud-only endpoint-drag branch)
  • src/diagram/flow-attach.ts (growEndpointDrag, reattachEndpoint)

Possible approach

Extend the growEndpointDrag/UpdateCloudAndFlow-based live-preview path to stock endpoints by synthesizing a transient cloud at the dragged endpoint (mirroring reattachEndpoint's newCloud branch) so the flow line tracks the cursor during a detach drag, matching the committed geometry and the cloud-drag feel.

Discovered

While fixing the cloud-endpoint live-update bug (the fix that added the growEndpointDrag branch in deriveRenderState).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions