Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .changeset/6331-flow-node-label-producer-census.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
---

Pins the flow-node `label` at the PRODUCER, where a cast cannot bypass it
(objectui#6331), and records why the reader-side type stays optional so the
question is not re-opened a third time.

`FlowNodeSchema` requires `label`; the designer's `FlowDesignerNode` makes it
optional, and that is a deliberate layer difference — a canvas holds nodes the
user has dropped but not finished. Both hold only if something guarantees a node
ACQUIRES a label before save. A census of every construction path (canvas
palette/append, insert-on-edge, the one-click revision loop, the empty-flow
seed, the Studio "New flow" skeleton, plus the nested-region and drag writers,
which re-spread an existing node) found six node literals across five producer
call sites and every one already writing a label — but three of the five were
enforced only by accident. Measured on `origin/main` by deleting the `label`
line from `insertOnEdge` and from `FlowPreview.handleAddNode`: vitest green
(58/58), `tsc` exit 0, `eslint` exit 0 with zero errors.

`flow-node-producers.label.test.tsx` closes that in two halves — each producer
driven through its real affordance with the EMITTED node `safeParse`d whole
against the spec (never a hand-composed node, which is what let the existing
seed test stay green through the ablation), plus a source census that refuses a
node literal writing no label, so a producer added later lands red there instead
of at the author's save.

No runtime behaviour changes; the published types are untouched.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ export interface LegacyFlowNodeUI {
export interface FlowDesignerNode {
id: string;
type: string;
/**
* Optional HERE and required by `FlowNodeSchema` — the layer difference this
* interface's own doc comment describes, and the settled answer to a question
* that has now been asked twice (objectui#6287, objectui#6331).
*
* ⛔ Making it required here catches nothing. Measured on `origin/main` in
* #6287: `tsc` exit 0, ZERO errors, because every node reaches the reader
* types through `as FlowNodeLike[]` / `as FlowDesignerNode[]` casts out of
* `Record<string, unknown>`, and **a cast bypasses a required member**. It is
* also mildly harmful — `node.label ?? ''` and `node.label || node.id` are
* guards the OPTIONAL type forces, while a required `label` would let
* `node.label.trim()` compile against a value that genuinely is absent (a
* stored flow, or a node mid-edit, can have none).
*
* What guarantees a node ACQUIRES one is therefore at the PRODUCER, where a
* cast cannot get in front of it: `flow-node-producers.label.test.tsx`
* censuses every construction site and refuses one that writes no label.
* ⛔ If that pin ever fails, write the label at the producer — do not narrow
* this member.
*/
label?: string;
config?: Record<string, unknown>;
/**
Expand Down
Loading
Loading