Skip to content

A product's node and frame with their ports on the top and the bottom when the flow runs down - #287

Merged
endrix merged 2 commits into
mainfrom
feat/ports-down
Dec 4, 2026
Merged

endrix merged 2 commits into
mainfrom
feat/ports-down

Conversation

@endrix

@endrix endrix commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

mlir-viewer draws top to bottom (DOWN) as well as left to right, and since 8.9 its operations are Dialogram's stock node, whose ports stayed on the left and the right under DOWN. This puts them on the top and the bottom, as mlir drew them before 8.9.

Server

  • stockNode takes direction: 'DOWN' (transform(doc, { oneNode, flowDown }), taken only with oneNode). The inputs sit on the top edge and the outputs on the bottom edge of the body, each in a column as wide as its name, with the columns of an edge centred.
  • The names sit in rows inside the body (NODE_PORT_ROWS): the inputs' under the header, the outputs' over the bottom edge. What the node says and its lines are drawn between the two rows.
  • A symbol, a frame and a state are drawn as before, and so is a node with no port.
  • framePin(..., 'DOWN') puts an input on the top of the frame and an output on the bottom, each named beside its wire. settleFrames keeps a row for these names under the band or over the bottom line, spaces the pins on an edge at least the widest name apart, and lets the layout place them whether or not an edge reaches them.

Client

  • A top or bottom port's name is centred in its column, and a press on the port lands inward from its edge.
  • A node's lines end above the row of its outputs' names, with the last band square.
  • The type under the node moves to the bottom right corner, out of the way of the edges that leave from the middle (inline text-anchor, since the stock text rule centres every text).
  • A frame pin on the top is named under the band, and one on the bottom over the bottom line, both to the right of the wire.
  • verticalPortSide reads the side. Anchors and routers still take such a port by its direction, as normalizePortSide does not name it.

Cost. Left to right is unchanged. On 8,000 operations drawn top to bottom in mlir-viewer, the first build is about 50 ms slower (best of 8: about 600 → 655 ms in a benchmark of the bundled build). That is the new geometry, mostly mkPort and the column widths. A redraw from mlir's cache costs the same as before.

Also read by the platform: placing the port names again on a submit (placePortLabel), the layout's port side (portOptions), a frame that grows (growGroupsToFit) and a frame opened again (restoreGroupGeometry) keep a top or bottom port where it is.

Known limits.

  • A frame's top pins are placed by the layout inside the frame, so a wire can cross the frame's title when its pin lands under it. portsSurrounding does not reach those pins; it was tried.
  • The anchors and rerouters (avoid overlaps, libavoid after a drag, saved routes) route across, and take a top or bottom port by its direction. A product that draws such ports routes with the layout, as mlir-viewer does. Teaching the routers to go down is a change of its own.

Tests: stock-node.test.ts (sides, columns, rows, width, unchanged left to right, a whole graph not drawn so, frame pins and their room, names placed again, the layout's sides, no bottom row without an output, a frame grown and opened again), ports-down.test.ts (the client's hit area, names, frame pin names, lines and type rendered through the views). npm test, npm run typecheck and scripts/check-neutrality.sh pass.

https://claude.ai/code/session_011UYzzShRuBLgefHUrAbqya

…bottom when the flow runs down

`stockNode` takes `direction: 'DOWN'`: the node's inputs are on its top
edge and its outputs on the bottom edge of its body, each in a column as
wide as its name, the columns of an edge centred. The names are in rows
in the body (`NODE_PORT_ROWS`), the inputs' under the header and the
outputs' over the bottom edge, and the lines between the two. The type
under the node goes to its end, clear of the edges that leave from its
middle. `framePin` takes the direction too: an input on the top of the
frame and an output on the bottom, named beside its wire, in a row
`settleFrames` keeps under the band or over the bottom line, the pins of
an edge as far apart as the widest name.

The client centres a top or bottom port's name in its column, takes a
press on it inward from its edge, and draws a node's lines above the row
of its outputs' names. `verticalPortSide` reads the side; anchors and
routers still take such a port by its direction.

Claude-Session: https://claude.ai/code/session_011UYzzShRuBLgefHUrAbqya
- A port name in its column stays there when the server places the
  labels again (`placePortLabel`): centred on its dot, an input's under
  the header, an output's over the bottom edge.
- The layout keeps a top or bottom port's side (`portOptions`).
- A frame that grows keeps its bottom pins on its bottom line
  (`growGroupsToFit`), and a frame opened again puts each top or bottom
  pin on its line where its route crossed it (`restoreGroupGeometry`).
- A node with no output keeps no row at its bottom, so its lines and its
  type sit where any node has them.
- `PortLabelEstimate` has its comment back.
- The anchors and rerouters still route across: written down where the
  side is read (`verticalPortSide`).

Claude-Session: https://claude.ai/code/session_011UYzzShRuBLgefHUrAbqya
@endrix
endrix merged commit 95cecc8 into main Dec 4, 2026
1 check passed
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