Skip to content

refactor: one entity-node renderer, one producer-id lookup - #125

Open
endrix wants to merge 2 commits into
mainfrom
refactor/client-views
Open

endrix wants to merge 2 commits into
mainfrom
refactor/client-views

Conversation

@endrix

@endrix endrix commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Phase 4d of the declutter plan, the webview side of the de-duplication. Cut from main; independent of the other open PRs (only CHANGELOG.md can conflict).

The three node views

ActorNodeView, ExternalActorNodeView and NetworkNodeView (views.ts) each computed isExecuting/isFinished/isErrored/isWarned, resolved the family, drew the sized rect, the run ring, the centre icon or image, the children and the type footer, in the same order with the same attributes. A diff of the three bodies showed they differ only in the root classes: actor-node; external-actor-node plus external-actor-default or external-actor-<family>; network-node.

renderEntityNode(node, context, rootClasses) draws the body once; each view keeps its class (chisel-ide extends ExternalActorNodeView), its isVisible check and a one-line rootClasses function. The tests that scan views.ts as text (run-ring.test.ts, header-badges-view.test.ts) look for renderRunRing and HeaderCompartmentView, both untouched.

Verification: scripts/render-svg/render.mjs on the toolkit's fixture graph, all three layouts, before and after: the SVG files are byte-identical.

The producer-id lookup

"Which diagram element does this producer id name" was written three times: findNodeIdByGraphId in hierarchy-outline.ts, elementIdFor in property-panel.ts, diagramIdOf in scripts/render-svg/headless-entry.ts, and they disagreed on precedence. One findNodeIdByGraphId in diagram-client/src/producer-ids.ts, with the rule the review settled: the producer id (wf:graphNodeId) wins, because a diagram id is the node's label and another node's producer id may equal it; a direct id hit must be a node, so a port, label or compartment carrying the id is never selected in its place; the first match in document order answers; the walk is a queue, no spread of a root's children. producer-ids.test.ts pins each rule. The property panel's link follow pays one tree walk instead of an index hit; a click, not a hot path.

The render script

build-schema.ts spelled the Layout menu's option table itself; it now calls tunedLayoutOptions('untangled' | 'free-ports') from layout-tuned-handler.ts. One deliberate difference: the editor's Untangled pins the declared port order and the script's copy did not, so a document that sets its own port order renders under Untangled as the editor shows it (stated in the changelog). Its createSchema stays: GLSP's DefaultGModelSerializer needs a DI-provided diagram configuration, which the script has no container for.

Not merged: the two test-only index() helpers in server tests (tests, not product code).

Typecheck 5/5, neutrality 5/5, client 361, server untouched.

https://claude.ai/code/session_01EToj6RJRMSSHQiqGNMU9wv

Phase 4d of the declutter plan. The actor, external-actor and network
views drew the same body three times over, differing only in the root
classes; renderEntityNode draws it once and each view names its
classes. The three classes keep their names: chisel-ide extends
ExternalActorNodeView. The headless renders of the fixture graph are
byte-identical to main's under all three layouts.

findNodeIdByGraphId, the lookup of a diagram element by a producer's
id, was written in the outline, the property panel and the headless
renderer; it is one function in producer-ids.ts. The renderer's layout
table is the Layout menu's own (tunedLayoutOptions).

Claude-Session: https://claude.ai/code/session_01EToj6RJRMSSHQiqGNMU9wv
The three producer-id lookups disagreed, and the merged one had locked
in the wrong order: a diagram id is a label, which another node's
producer id may equal, so the producer id wins; a direct hit must be a
node, never a port or compartment that carries the id; the first in
document order answers; and a very wide root is walked without a
spread. producer-ids.test.ts pins each rule. The renderer's Untangled
pins the declared port order as the editor's does, now said so.

Claude-Session: https://claude.ai/code/session_01EToj6RJRMSSHQiqGNMU9wv
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