Skip to content

render-svg: --states, node states drawn through the client's own painter - #105

Merged
endrix merged 2 commits into
mainfrom
feat/render-svg-states
Oct 24, 2026
Merged

endrix merged 2 commits into
mainfrom
feat/render-svg-states

Conversation

@endrix

@endrix endrix commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

What

scripts/render-svg/render.mjs --states <file.json> draws node states (a status source's answer, [{ nodeId, status }]) in the headless render. They reach the client the way the webview receives them: through the overlay bridge's painter and GLSP feedback, so the render shows what the editor draws (except a running state, whose ring the SVG export already draws wrong, in the editor's own Export as SVG too; that is a separate fix in svg-export.ts).

It needs both the renderer (#91) and the status overlay (#101), so it waited until both were on main. ndf-ide's npm run render -- --coverage uses it.

Three files under scripts/render-svg (README, headless-entry.ts, render.mjs), 15 lines; no platform package changes.

Review fixes

A states file that is not an array is refused, naming the file. Malformed JSON in --states or --families names the file. Inline JSON escapes <. The README says how ids match, that unknown ids are skipped, and that idle draws nothing.

https://claude.ai/code/session_01E8WfqKknDNN6xpNVcJL5K8

For looking at a status source's answer without VS Code: `--states
<file.json>` hands node states to the client as the webview would get
them, through the overlay bridge's painter and GLSP feedback, so what is
drawn is what the editor draws. It needs both the renderer (#91) and the
status overlay (#101), so it waited for both to be on main.

Claude-Session: https://claude.ai/code/session_01E8WfqKknDNN6xpNVcJL5K8
… inline JSON safely

Review of #105:

- A states file holding an object (`{"states": [...]}`) was dropped
  silently and the render drew no states; it is now refused, naming the
  file and what it holds. Malformed JSON in `--states` or `--families`
  now names the file too.
- The schema, the client behaviour and the states were written raw into
  an inline `<script>`, so a `</script>` in a node id ended the script
  and the render failed with "nothing rendered". Every `<` is escaped.
- The README and the usage block say a node id may be the producer's or
  the diagram's, that ids the view does not have are skipped, and that
  `idle` draws nothing.

Without `--states` the output is byte-identical to before.

Claude-Session: https://claude.ai/code/session_01E8WfqKknDNN6xpNVcJL5K8
@endrix
endrix merged commit 588bff1 into main Oct 24, 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