feat(layout): add --only-new incremental placement mode - #14
Open
tobsch wants to merge 1 commit into
Open
Conversation
`config layout` currently re-arranges the whole page (grid_layout). After `config add`, new blocks land without coordinates while the rest of the page is already laid out by hand — re-running the full layout throws that hand-work away. Add `--only-new`: position ONLY blocks that have no `Px`, leaving every already-positioned block byte-identical. New blocks are placed with a Sugiyama-style layered layout so they flow left→right along their wiring: - layer = longest path over the sub-DAG of new blocks (predecessors that are themselves new) - order within a layer by barycenter of predecessor rows (fewer crossings) - coordinates snapped to the 96-unit editor grid, anchored in the free area to the right of the page's existing content Motivation: clears the "missing canvas layout — Loxone Config will repair this block on first save and may drop wires" warning without disturbing the existing diagram. Verified on a real 500-block config: 9 added logic gates placed in clean layers, 498 positioned blocks unchanged, `config validate` 0 errors. Adds `incremental_layout()` + two unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1TT6BSmf3uXakmtfexfDt
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.
What
Adds an incremental mode to
config layout. Todayconfig layoutre-arranges the whole page (grid_layout). With this PR:--only-newpositions only blocks that have noPxyet and leaves every already-positioned block byte-identical.Why
After
config add, new blocks land at no coordinates while the rest of the page is already laid out by hand. Re-running the full layout throws that hand-work away. Un-positioned blocks also trip thecheckwarning:--only-newclears exactly those blocks without touching the existing diagram — so the editor won't "repair" (and possibly re-wire) them on first save.How
incremental_layout()does a small Sugiyama-style layered layout over just the new blocks:Px2+ gap)Existing blocks are never re-read for placement, so their coordinates are preserved exactly.
Verification
On a real ~500-block house config with 9 freshly-added logic gates (Or/And/Not chain):
config validate→ 0 errorsmissing canvas layoutwarnings clearedAdds two unit tests (
incremental_places_only_new_in_layers,incremental_noop_when_all_positioned). Full suite green (406 tests).Notes
--pageselects the page; default = first page).🤖 Generated with Claude Code