Skip to content

Add experiment design graph editor prototype - #144

Draft
kevindetry-milaboratories wants to merge 16 commits into
mainfrom
experiment-design-graph-editor
Draft

kevindetry-milaboratories wants to merge 16 commits into
mainfrom
experiment-design-graph-editor

Conversation

@kevindetry-milaboratories

Copy link
Copy Markdown
Contributor

A prototype of the experiment design editor in Samples & Data: a graph of how samples were made from each other (selection rounds, sorts, splits, merges). It is a draft to share the current state; it is not ready to merge.

What it does

  • A "Designs" section in the block sidebar. Each design has its own page with a graph editor. Designs are stored in the block data as an optional designs field on the current data version, so older block versions keep working with it.
  • Samples come from the block's Metadata table. A design references samples by id; labels and metadata are read live, never copied. A sample removed from the table shows as an error on its node.
  • Samples are added from a side panel with a column:value filter. Unsequenced materials (starting materials, steps, splits, merges) are drawn as shadow nodes and come only from actions: Starting material, Add step, Insert step, Connect to….
  • Connections are drawn by dragging from a node's side circles, or created from the side panel. Each connection has a type: whole (solid), slice (dashed) or remade (dotted). Several samples taken from one parent as slices form one separation.
  • Multi-select (Cmd/Shift+click, Cmd/Shift+drag box) with bulk actions: merge, make one separation, insert a common step, connect several parents to several children, move under a new parent, set the connection type, delete.
  • Layout is our own pure function (ui/src/design-graph/layout.ts): columns are step distances from the root, rows follow tree order, and edges are curves. No graph library is used.

Not in this PR

  • The design doesn't reach the args, the workflow or the exports yet.
  • No table view and no wizard yet.
  • The editor lives in ui/src/design-graph/ and imports nothing from the rest of the block UI, so it can move to a shared package later.

Open design questions

  • Naming: "Starting material" vs "Unsequenced start".
  • Long edges into a merge pass behind other nodes; this needs routing or a layout library.
  • "Design N" placeholders renumber after a delete.

A first, graph-only prototype of the experiment-design editor on a new
"Design" page. State is local; block args and the workflow are not
changed.

- `ui/src/design-graph/` holds the editor. It uses plain Vue and
  `@milaboratories/uikit` only and imports nothing from the rest of the
  block UI, so it can move to a shared package later.
- `toGraph` converts the authored materials into nodes and edges. A
  material with several parents gets an inserted `<child>::pool` node.
- `withJunctions` adds a hidden junction for each separation with two
  or more partitions. Junctions are derived, not stored.
- `layout` is a pure function: columns are step positions (a `round`
  label pushes a material to its round), rows follow a tree order, and
  edges are right-angle lines.
- Nodes and edges have separate panels. Edits are immutable and keep an
  undo history.
- Four example designs: one follows a synthetic study, three are
  invented.
Replace the right-angle edges with horizontal S-curves.

- `layout` returns each edge's two ends and the x range of the column
  gap where it may change rows (`PlacedEdge`). The view draws straight
  leads up to that range and a cubic Bézier inside it, so a curve
  never crosses a node card. Edges between nodes on one row stay
  straight.
- A separation's line runs into its junction, and each partition
  leaves the junction on its own curve. Merges into a pool mirror this.
- Junctions of one parent share the gap center and differ by row, so
  the per-separation x offset is gone.
Every unsequenced node is now a shadow node: a faint dashed circle that
shows on hover. Starting materials, unsequenced steps, split points and
merges share one style.

- Shadow materials carry no labels, only an optional `name`. Their ids
  are generated (`shadow-N`); unnamed ones show a grey placeholder.
- Shadows are created only through actions: Start (toolbar), Add step
  (node panel), Insert step and Add partition (edge panel), and Add
  partition (split panel). "Add material" and the sequenced checkbox
  are gone.
- Split points and merges stay derived from the design.
Each material gets two ports: the right one adds children, the left
one adds parents. The node and edge properties move into a sidebar.

- Clicking a port opens a sample picker in the sidebar: a mock sample
  table filtered by a metadata column and its values. The picked
  samples are added with the chosen connection type; slices added
  together form one split, several parents form a merge.
- Dragging a port draws a connection. A drop on a node connects to it
  (a second parent makes a merge), a drop on an edge or split point
  joins that separation, a drop on empty space opens the picker. A
  drop that would make a cycle, drop other parents, or change nothing
  is refused while dragging.
- The ends of a selected edge can be dragged to another node, or to
  another edge to make a partition. A moved edge keeps its type.
- `connect.ts` holds the drop rules as pure functions; `edit.ts` gains
  the material-level edits.
- When the sidebar opens, the selected node or edge is panned out from
  under it.
A first version of acting on several nodes at once.

- Cmd/Ctrl+click (or Shift+click) toggles a node. Shift+drag on the
  background draws a selection box; a plain drag still pans.
- With two or more nodes selected, a bar at the bottom of the canvas
  shows the count and the actions: set the connection type, add a step
  to each, merge them into one new shadow node, make one split of
  siblings, and move them under a new parent (the next node clicked).
- The actions are pure edits in `edit.ts`: `setPartOf`, `addStepsTo`,
  `mergeInto`, `makeSplit` and `moveUnder`. Partitions of one split
  stay together when they move.
All actions now live in the right sidebar. With two or more nodes
selected, the sidebar shows the count and the bulk actions in the same
header layout as the node and edge panels. The floating bottom bar is
gone.

- "Cancel" takes the place of "Move under…" while picking a parent.
- The view pans so the selected nodes are not under the sidebar.
- Delete any node from the sidebar or with Delete/Backspace. A deleted
  material's children take its parents and keep how they were made;
  slices that shared a split stay together. A deleted sample is free to
  place again. Deleting a split point dissolves the split; deleting a
  merge keeps the child's first parent. Several selected nodes are
  deleted together.
- "Replace with sample" swaps a material for a sample from a
  single-choice picker and keeps every connection.
- "Start" opens a picker that adds samples as roots, or a shadow node.
- Escape cancels picking a parent, otherwise closes the sidebar.
- Label fields in the sidebar no longer overlap: uikit text fields have
  a 160px minimum width.
- The sample picker has one filter: pick "column: value" options in a
  single dropdown. Values of one column match any of them; different
  columns must all match. The rule lives in `filter.ts` with tests.
- Whole connections are solid and slices are dashed; remade stays
  dotted. The legend follows the new order.
- With several nodes selected, "Add children" opens the sample picker.
  The picked samples become children of one new shadow step made from
  all of the selected nodes (`of: [...]`, part `whole`); slices form
  one split. This replaces "Add step to each".
- Cmd+drag (or Ctrl+drag) on the background draws the selection box,
  as Shift+drag does.
- A merge refuses parents that are not in the design.
Columns now come only from the graph: one step per edge, half a step
for a pool. A `round` label no longer moves a material to that round's
column, so samples added to an empty canvas no longer form a
staircase.

Nodes with no parents and no children stack in the first column, in
design order, below the connected trees.
The Design page now reads samples from the block's own table and
keeps the design in the block data.

- The block data gets an optional `design`: materials with their id,
  name (shadow nodes only) and how each was made. A sequenced material
  references a sample by its sample id. No new data version: the field
  is optional, so older packs keep it untouched.
- Sample labels and metadata come live from the table and are never
  copied into the design. The sample panel shows them read-only.
- A sample deleted from the table stays in the design as "Removed
  sample" in an error state. Duplicate or empty column labels get
  unique names. A stored design that cannot be drawn shows an alert
  with "Clear design".
- The mock sample table and the example switcher are gone; the
  example designs remain as test fixtures.
- Args, workflow and exports are unchanged. Undo stays local.
A shadow node with several parents is itself the merge, and a shadow
node with one separation is itself the split, so the graph no longer
adds a pool or a junction around it. Merging two nodes now adds one
node, and adding children to several parents adds one node plus the
children. The stored design is unchanged.

- Only a whole merge without a step collapses; its parent edges are
  drawn as pooled edges. A slice or remade merge keeps its pool.
- A shadow node with two or more separations keeps its junctions, so
  the separations stay apart.
- Merge always stores a whole step.
- A selected connection can be deleted, from the panel or with
  Delete; this drops one parent of a merge.
- Selecting one edge into a merge no longer selects another, and
  "Add partition" shows only where it can act.
- The sidebar is uikit's PlSlideModal (non-modal), so its title, close
  button and spacing match the app. It starts below the canvas toolbar
  and pans the selection out from under it.
- The sample list fills the panel and the Add button stays at the
  bottom. Rows show only the sample label, cut with an ellipsis; the
  full metadata is in a hover tooltip.
- The filter picks a column, then its values; each filtered column
  shows as a chip. "Show in list" adds up to two columns as tags.
- Escape in a sidebar field or dropdown no longer closes the sidebar.
- No "shadow node" in the UI: the legend says "unsequenced", an
  unnamed one is "Unsequenced N", and the Start panel offers
  "Unsequenced start".
- Panel titles name what is selected; Delete sits with the other
  actions.
- The block data holds a list of designs, each with an id, a label
  and its materials, in place of the single unreleased `design`. It
  stays an optional field on the current data version, so older packs
  keep it untouched.
- The block sidebar lists the designs after a separator and ends
  with "New Design", like the dataset entries.
- Each design has its own page: rename it in the title, delete it
  with a confirmation. A new design starts empty, with a gray
  placeholder name ("Design N").
- Designs are independent; a sample can be in several.
- "Insert step" on a multi-selection adds one unsequenced step
  between the nodes and their old parents, with no duplicate links.
- "Connect to…" starts a pick mode: click or box-select children,
  then confirm. One unsequenced step joins all selected parents to
  all picked children; a single parent connects directly. Escape or
  Cancel ends the pick, and cycles are refused.
- A port drag from a multi-selection does the same join.
- Children left with one parent form one separation; a drop that
  changes nothing is refused.
…data into claude/design-graph-prototype-239b69

# Conflicts:
#	model/src/args.ts
#	pnpm-lock.yaml
#	pnpm-workspace.yaml
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