SY-4140: Schematic Type Reorganization and Diagram Optimizations#2281
Open
SY-4140: Schematic Type Reorganization and Diagram Optimizations#2281
Conversation
These pb.go and codec_gen_test.go changes were proto-descriptor reordering noise unrelated to the spatial-types work. Reverting to keep the PR diff focused.
These case "numeric" arms in constraintToGo, formatTypeParamsDecl, and the test-fixture concrete-type helpers can't fire: the analyzer requires every numeric-constrained type-param to have a numeric default, and every Go-emitting call site filters through NonDefaultedTypeParams before reaching these functions. The arms were added as completeness hedges; remove them to keep the codebase to live paths only.
…b generator A struct field declared with single "?" in oracle keeps its Go type as a value, but the proto field is nullable on the wire. The generator was calling the inner ToPB unconditionally, which errored on a zero-value struct that contained string-enum fields (e.g. spatial.StickyXY.Root, arc.ir.Function.Body). Route soft-optional struct fields through OptionalFields with a zero-value guard in ToPB and a proto-pointer nil-check in FromPB. The latent same-shape bug in ranger.Range.Color is fixed by the same path. Also fix the pluralize package so trailing acronym runs ending in Y (StickyXY, ClientXY) pluralize as "+s" rather than mangling to "ies". The previous all-uppercase shortcut only caught fully-acronym names.
… console-side edge wrapper
…e offPageReferenceTooltip
Schema fields whose names start with a lowercase letter are now used verbatim as the JSON / msgpack tag instead of being routed through SnakeCase. snake_case stays snake_case (data_type) and camelCase stays camelCase (clientX, signedWidth, targetKey), letting Go round-trip directly with the TypeScript zod schemas, which use the schema field name as the property key. Names that begin with an uppercase letter (PascalCase, screaming-case, single-letter caps) keep the existing lowercase-snake convention so WASM -> wasm and OutputMemoryBases -> output_memory_bases are unchanged. Only six fields across the codebase change tags (spatial.ClientXY, spatial.SignedDimensions, ir.Transition.TargetKey, ir.Member.NodeKey); none have shipped data to maintain compatibility with.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## rc #2281 +/- ##
==========================================
- Coverage 64.31% 64.20% -0.11%
==========================================
Files 2189 2187 -2
Lines 111097 110644 -453
Branches 8292 8357 +65
==========================================
- Hits 71455 71042 -413
+ Misses 33535 33497 -38
+ Partials 6107 6105 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…8-prepare-oracle-generated-spatial-primitives-for-strongly
…-strongly' of https://github.com/synnaxlabs/synnax into sy-4140-schematic-type-re-organization-and-diagram-optimizations
…-strongly' of https://github.com/synnaxlabs/synnax into sy-4140-schematic-type-re-organization-and-diagram-optimizations
…8-prepare-oracle-generated-spatial-primitives-for-strongly
…-strongly' of https://github.com/synnaxlabs/synnax into sy-4140-schematic-type-re-organization-and-diagram-optimizations
…8-prepare-oracle-generated-spatial-primitives-for-strongly
…-strongly' of https://github.com/synnaxlabs/synnax into sy-4140-schematic-type-re-organization-and-diagram-optimizations
Base automatically changed from
sy-4138-prepare-oracle-generated-spatial-primitives-for-strongly
to
rc
May 1, 2026 17:52
…0-schematic-type-re-organization-and-diagram-optimizations
sy-nico
requested changes
May 1, 2026
Contributor
sy-nico
left a comment
There was a problem hiding this comment.
While trying to test out the potential regression (see other comment), I noticed that keyboard shortcuts are broken (could not copy, paste, or undo) on both the Arc and Schematic editors.
I would attach a video, but there would be no activity...
…0-schematic-type-re-organization-and-diagram-optimizations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Pull Request
Linear Issue
SY-4140
Description
Reorganizes the schematic type system and lifts diagram rendering up into pluto, in service of strongly-typed schematics. The change is intentionally scoped to not depend on the planned shift of schematic state out of Redux into a flux store, or on the server-side schematic typing pipeline — both of which will land separately on top of this work.
Pluto —
Diagramfactory + typed change protocol.Diagram.create({ node, edge?, connectionLine? })replaces the runtime<NodeRenderer>/<EdgeRenderer>registration. Theuse()hook is removed; the diagram is now controlled-only.onNodesChange/onEdgesChangereceive typedNodeChange[]/EdgeChange[]mutations (position/remove/select/dimensions,add/remove/select) instead of whole arrays. Selection is promoted to a first-classselected/onSelectionChangecontrolled prop.Handle = { node, param }objects. Renderer contracts are tightened ({ edgeKey, source, target, sourceNode, targetNode, selected }for edges;{ source, target, status, style }for connection lines).Background,ToggleEdit,FitView,SelectViewportModemove into acontrols/namespace.Pluto —
Schematic.createfactory with hooks API.Schematic.create({ useNodeProps, useEdgeProps, useSetElementProps })returns aDiagram-backed FC. Pluto owns all rendering: it looks up symbols viaSymbol.REGISTRY[variant], renders the edge component (drag handles + path routing), and the connection line. Consumers only provide three small hooks for read/write of element props.Schematic.Provider/Schematic.useKeygive consumers a context channel for layout-key scoping.{ segments, color, variant, onSegmentsChange }as props (no flux dependency). New connector helpers (stitchEdge,extractMiddle,buildNewFromState,updateSegmentsForPositionChanges,resolveOrientation,connectPoints) handle the three-zone source-stump / middle-segments / target-stump routing.interactionWidth = 30for easier hit-testing.data: Pnamespacing (separates structural props from configuration),nodeKeyrename, andmemowrapping.Pluto —
Arc.createfactory.Arc.create(renderers)mirrors the newDiagram.create/Schematic.createpattern.Console — schematic slice + selectors adapted to new shape.
applyNodeChanges/applyEdgeChanges/setSelectedreducers consume the typed change protocol directly.setNodes/setEdgesretained for compatibility but no longer carry selection.state.selected: string[]replaces per-node / per-edgeselectedflags.propsmap now stores both node and edge props (keyed by element key); edge{ segments, color, variant }shifts out ofedge.datainto the props record.useSelectSelected,useSelectElementProps,useSelectEdgePropsselectors.Console — schematic v6 migration.
Diagram.nodeZ/edgeZreferences) so old persisted state still parses through the chain.Handle, edgedata→ entry inpropsmap,nodePropsZ.key→variant, top-levelselected: []added. Copy buffer migrates with the same transforms.Console — schematic / arc consumers.
Schematic.tsxshrinks dramatically: provides the three hooks, wraps<Schematic.Provider value={layoutKey}>, no longer hosts aSymbolRendereror React-flow integration.arc/editor/graph/Editor.tsxadoptsArc.create({ node }), the typed change reducers, andsetSelected. Arc state migrates to v1 (selection extracted).Properties.tsxrenamesprops.key→props.variant, adds an edge-properties block backed by the newuseSelectEdgeProps, and guards the Color.Swatch against non-hex (CSS-variable) colors carried from migration defaults.Test coverage.
key→variant, edge-handle reshape, edge-data→props extraction).Basic Readiness
Greptile Summary
This PR reorganizes the schematic and arc type systems:
Diagram.create/Schematic.create/Arc.createfactories replace runtime renderer registration, a typedNodeChange[]/EdgeChange[]protocol replaces whole-array updates, edge endpoints becomeHandleobjects, and selection is lifted to a first-class controlled prop. A v6 migration transforms all persisted state to the new shape. Several previously-flagged bugs are addressed in this PR (color reference-equality comparison,syncDispatchfor selection changes,color.equalsfor edge color sync).The remaining findings are all P2: a missing CSS-variable safeParse guard for edge colors in the multi-element properties panel (the single-element path was already fixed), a missing null guard in arc's
pasteSelection(present in the schematic's equivalent), and a stalethemeentry inhandleDrop's deps array.Confidence Score: 5/5
Safe to merge; all findings are P2 (style/defensive gaps), no blocking issues found.
Only P2 findings remain — a missed CSS-variable guard in multi-element properties, a defensive null check gap in arc paste, and a stale dep. All previously flagged P1s were addressed in this PR.
console/src/schematic/toolbar/Properties.tsx (missing edge color guard in multi-selection path)
Important Files Changed
themedep.Sequence Diagram
sequenceDiagram participant Consumer as Console (Schematic.tsx) participant Factory as Schematic.create() participant Diagram as Diagram.tsx participant Redux as Redux Slice Consumer->>Factory: create({ useNodeProps, useEdgeProps, useSetElementProps }) Factory-->>Consumer: SchematicComponent (FC) Consumer->>Diagram: SchematicComponent nodes edges selected onNodesChange onEdgesChange Diagram->>Redux: onNodesChange(NodeChange[]) applyNodeChanges Note over Diagram,Redux: dragging=true syncDispatch (no undo)<br/>other changes undoableDispatch Diagram->>Redux: onEdgesChange(EdgeChange[]) applyEdgeChanges Note over Diagram,Redux: add case calls syncEdgeColorFromEndpoints Diagram->>Redux: onSelectionChange(string[]) setSelected syncDispatch Factory->>Redux: useNodeProps(entryKey, nodeKey) REGISTRY[variant] Factory->>Redux: useEdgeProps(entryKey, edgeKey) segments color variant Factory->>Redux: useSetElementProps(entryKey) setElementProps dispatchComments Outside Diff (1)
console/src/arc/editor/graph/Editor.tsx, line 143-146 (link)handleNodesChangeroutes every node change — including intermediate drag positions (type: "position"withdragging: true) — throughundoableDispatch. The schematic counterpart correctly usessyncDispatchfor in-flight drag changes to avoid polluting the undo stack. A user dragging a single node across the canvas will generate dozens of undo entries, making Ctrl-Z nearly useless after any drag.The schematic's
handleNodesChange(inconsole/src/schematic/Schematic.tsx) uses adraggingcheck to route tosyncDispatch, and the same pattern should be applied here.Reviews (13): Last reviewed commit: "Merge branch 'rc' of https://github.com/..." | Re-trigger Greptile