Skip to content

diagram: straight stock-to-stock flows cannot be offset (no Z-shape support) #819

Closed

Description

@bpowers

Problem

A straight 2-point flow between two stocks cannot be visually offset in the editor at all. Both existing reroute mechanisms exclude this case:

  1. Perpendicular valve-drag reroute (UpdateFlow in src/diagram/drawing/Flow.tsx) only converts a straight flow to an L-shape when at least one endpoint is a cloud (the segments.length === 1 && clouds.length > 0 guard). With stocks on both ends, dragging the valve perpendicular to the flow does nothing to the route.
  2. Segment dragging requires an interior segment: findClickedSegment refuses segments with attached endpoints, and a 2-point flow's only segment has both endpoints attached to the stocks.

So the user has no way to move the flow line off the direct stock-to-stock axis, e.g. to route around another element or reduce label overlap.

Why it matters

This is a UX capability gap (not a bug). Other SD tools (Stella, Vensim) support offsetting a stock-to-stock flow into a Z-shape: two corners so the middle segment runs parallel to the original axis but displaced. Users coming from those tools expect it, and diagrams with parallel flows between the same stocks are impossible to disambiguate without it.

Component

  • src/diagram/drawing/Flow.tsx (UpdateFlow, valve-drag routing)
  • src/diagram/drawing/flow-geometry helpers (findClickedSegment, moveSegment, normalizeFlowPoints)

Possible approach

Extend the valve-drag reroute: when both endpoints are attached stocks and the drag is perpendicular to a straight flow, insert two corner points to form a Z-shape instead of bailing out. Once the Z exists, the middle segment is interior, so the existing moveSegment / normalizeFlowPoints machinery already makes it draggable and keeps it orthogonal.

Context

Identified during the June 2026 flow-editing audit; listed in the "Deferred" section of docs/dev/flow-editing-audit-2026-06.md.

Related: #51 is the original broad "multi-part flows" request from before any bend support existed; this issue tracks the specific remaining gap now that L-shape reroute (cloud endpoints) and interior-segment dragging exist.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions