feat(library): arrange diagrams automatically - #836
Draft
FelixTJDietrich wants to merge 1 commit into
Draft
Conversation
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.
Summary
Closes #128.
This PR adds a single Arrange diagram action to the default editor chrome, the composable React controls, and the imperative
ApollonEditorAPI. It supports every flat Apollon diagram type, including Use Case, Petri Net, and Syntax Tree diagrams whose relationships are rendered as straight connections.Arrange runs outside the main thread and judges deterministic placement candidates with Apollon's existing edge-routing and label geometry. It applies a result only when it is a material readability improvement, fits moved nodes into the usable viewport, and commits positions plus any approved routing resets as one undoable change.
Manual edge routes remain authoritative by default. If visible edges contain authored bends or pinned endpoints, Arrange asks for explicit confirmation once and then replaces all affected visible routes atomically; hidden routes are untouched.
Release note
Arrange flat diagrams of every type automatically, including diagrams with straight connections. The result now favors clear routing, readable labels, cycle-aware flow, and balanced UML inheritance groups, then fits moved elements into view. Larger diagrams use an adaptive performance budget, while cancellation, stale-result protection, manual-route confirmation, and one-step Undo keep the operation safe.
Implementation notes
Layout and quality model
UX, safety, and API
layoutControl()/<Apollon.Layout />andApollonEditor.arrangeDiagram()APIs.maxZoomof 1, and reduced-motion preferences; viewport state is local and is not part of Undo.unchangedfor an empty/single-node canvas instead of treating it as a failure.Performance and scope
«include»/«extend»text are rendered by specialized components and are not yet transported into the generic label objective. Their edges and explicit labels are still routed and scored.Steps for testing
Open the Class Diagram regression fixture in
standalone/webapp/tests/fixtures/automatic-layout-star.json.Select Arrange diagram. Confirm that the nodes form a compact star, relationships remain clear, and the result is fitted into view.
Add a manual bend or pin an endpoint, then select Arrange diagram. Cancel the confirmation and verify that nothing changes; repeat and confirm replacement.
Select Undo once and verify that both positions and manual routing are restored.
Repeat with flat Activity, Communication, Object, Flowchart, Reachability, Petri Net, SFC, and Syntax Tree fixtures.
Verify that a nested diagram explains why Arrange is unavailable and that read-only or active-drag states cannot mutate the model.
Run:
pnpm lint pnpm format:check pnpm build pnpm test pnpm --filter @tumaet/apollon run sizeRun the focused Chromium production-bundle suite:
Local validation:
Screenshots / screencasts
Draft follow-up: attach a before/after capture of the #128 regression fixture before marking this PR ready for review.
Checklist
pnpm changeset, how) — or this PR doesn't touch a Changesets-tracked package (@tumaet/apollon,@tumaet/webapp,@tumaet/server)feat/fix/…) matches the kind of change — it groups the release notepnpm lint && pnpm format:check && pnpm build && pnpm testlocally — green