Skip to content

[cleanup] Simplify child node position computation#6208

Open
frouene wants to merge 1 commit intomasterfrom
fro/fix/layout-border-width
Open

[cleanup] Simplify child node position computation#6208
frouene wants to merge 1 commit intomasterfrom
fro/fix/layout-border-width

Conversation

@frouene
Copy link
Contributor

@frouene frouene commented Feb 19, 2026

Pull request template

General purpose

What is the main goal of this pull request?

  • Bug fixes
  • New features
  • Documentation
  • Cleanup
  • Tests
  • Build / releng

Project management

  • Has the pull request been added to the relevant project and milestone? (Only if you know that your work is part of a specific iteration such as the current one)
  • Have the priority: and pr: labels been added to the pull request? (In case of doubt, start with the labels priority: low and pr: to review later)
  • Have the relevant issues been added to the pull request?
  • Have the relevant labels been added to the issues? (area:, difficulty:, type:)
  • Have the relevant issues been added to the same project and milestone as the pull request?
  • Has the CHANGELOG.adoc been updated to reference the relevant issues?
  • Have the relevant API breaks been described in the CHANGELOG.adoc? (Including changes in the GraphQL API)
  • In case of a change with a visual impact, are there any screenshots in the CHANGELOG.adoc? For example in doc/screenshots/2022.5.0-my-new-feature.png

Architectural decision records (ADR)

  • Does the title of the commit contributing the ADR start with [doc]?
  • Are the ADRs mentioned in the relevant section of the CHANGELOG.adoc?

Dependencies

  • Are the new / upgraded dependencies mentioned in the relevant section of the CHANGELOG.adoc?
  • Are the new dependencies justified in the CHANGELOG.adoc?

Frontend

This section is not relevant if your contribution does not come with changes to the frontend.

General purpose

  • Is the code properly tested? (Plain old JavaScript tests for business code and tests based on React Testing Library for the components)

Typing

We need to improve the typing of our code, as such, we require every contribution to come with proper TypeScript typing for both changes contributing new files and those modifying existing files.
Please ensure that the following statements are true for each file created or modified (this may require you to improve code outside of your contribution).

  • Variables have a proper type
  • Functions’ arguments have a proper type
  • Functions’ return type are specified
  • Hooks are properly typed:
    • useMutation<DATA_TYPE, VARIABLE_TYPE>(…)
    • useQuery<DATA_TYPE, VARIABLE_TYPE>(…)
    • useSubscription<DATA_TYPE, VARIABLE_TYPE>(…)
    • useMachine<CONTEXT_TYPE, EVENTS_TYPE>(…)
    • useState<STATE_TYPE>(…)
  • All components have a proper typing for their props
  • No useless optional chaining with ?. (if the GraphQL API specifies that a field cannot be null, do not treat it has potentially null for example)
  • Nullable values have a proper type (for example let diagram: Diagram | null = null;)

Backend

This section is not relevant if your contribution does not come with changes to the backend.

General purpose

  • Are all the event handlers tested?
  • Are the event processor tested?
  • Is the business code (services) tested?
  • Are diagram layout changes tested?

Architecture

  • Are data structure classes properly separated from behavioral classes?
  • Are all the relevant fields final?
  • Is any data structure mutable? If so, please write a comment indicating why
  • Are behavioral classes either stateless or side effect free?

Review

How to test this PR?

Please describe here the various use cases to test this pull request

  • Has the Kiwi TCMS test suite been updated with tests for this contribution?

Signed-off-by: Florian ROUËNÉ <florian.rouene@obeosoft.com>
@frouene frouene force-pushed the fro/fix/layout-border-width branch from 46da775 to 99b4751 Compare February 26, 2026 08:06
Copy link
Member

@sbegaudeau sbegaudeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code seems fine, I've re-triggered the build because of some test failures to see if those were caused by flakky tests or real errors. I'll perform some tests manually.

@sbegaudeau
Copy link
Member

Quick automatic review (please ignore this message)

Pull Request Status: The pull request #6208 "[cleanup] Simplify child node position computation" is currently open and behind the master branch. The size is manageable (79 additions, 100 deletions across 12 files). However, the Continuous Integration (CI) build is still pending, and one check has been skipped.

Summary: This PR aims to simplify the calculation of child node positions by moving the logic for border node footprints directly into the layout handlers. It also performs some minor cleanup, such as renaming variables for better clarity and updating type predicates. While the intention to centralize layout constraints is good, the current implementation introduces a regression in sibling spacing and misses some constraints for ellipse nodes.

🚨 Critical & Architectural Issues
  • Sibling Spacing Regression in getChildNodePosition: The simplification of getChildNodePosition in layoutNode.ts has removed the maxWestBorderNodeWidth of the current child from the calculation of its relative horizontal position to the previous sibling. While the layout handlers now enforce a minimum x relative to the parent's border, they no longer ensure a sufficient gap between siblings when the current child has west border nodes. This will likely lead to overlaps between a child's west border nodes and its previous sibling (or its east border nodes).

    • Rule: [React Architecture] Ensure that logic refactoring does not break established layout contracts or introduce visual regressions.
    • Required Fix: Re-introduce the current child's west border node footprint into the spacing calculation for siblings in getChildNodePosition, or handle sibling-to-sibling spacing constraints explicitly in the handlers.
  • Inconsistent Layout Logic for Ellipse Nodes: The EllipseNodeLayoutHandler (in both sirius-web and the VS Code extension) was updated to use the new getChildNodePosition signature but does not implement the childMaxWestBorderNodeWidth and childMaxNorthBorderNodeHeight constraints that were added to FreeFormNodeLayoutHandler. If an ellipse node contains children with border nodes, their footprint will be ignored in the initial positioning, causing them to overlap with the ellipse's boundary.

    • Rule: [React Architecture] Maintain consistency across similar layout handlers to ensure uniform behavior for all container types.
    • Action: Update EllipseNodeLayoutHandler to calculate and enforce constraints for children's border node footprints, similar to FreeFormNodeLayoutHandler.
  • Potential Over-simplification of getChildNodePosition: By returning { x: 0, y: 0 } for the first child and relying on the caller to "fix" it, the code becomes more brittle. If a handler forgets to apply the constraints (as seen with EllipseNodeLayoutHandler), the layout breaks completely.

⚠️ Standard & Stylistic Feedback
  • Unexplained Test Constant Changes: In node-creation.spec.ts, headerHeight was changed from 24 to 34 without explanation. While this might be a fix to match the new layout logic (including rectangularNodePadding), such changes should be documented in the commit message or PR description to ensure they don't hide unintended side effects.
  • Redundant Handler Implementations: EllipseNodeLayoutHandler is duplicated in packages/sirius-web/... and vscode-extension/.... While this might be a pre-existing structural issue, this PR's changes highlight the need for a common base or utility if these handlers are intended to remain synchronized.
  • Type Predicate Cleanup: The rename from isRectangularNode to isFreeFormNode in layout.tsx is a positive change for consistency, but ensure that the "rectangular" terminology is phased out globally if "freeForm" is the new standard (e.g., in RectangleNodeConverter).
✅ What Went Well
  • Variable Naming Cleanup: The consistent renaming of previouseNode (sic) to prevNode across multiple files is a welcome cleanup that improves code readability.
  • Centralization of Constraints: Moving the "minimum position" logic out of a black-box utility like getChildNodePosition and into the handler's constraint checks is a good architectural step towards more transparent layout logic, even if the initial implementation missed some edge cases.
  • Changelog Documentation: The PR includes a clear entry in CHANGELOG.adoc describing the breaking change in the getChildNodePosition signature, which is essential for maintainability.

@sbegaudeau
Copy link
Member

sbegaudeau commented Feb 26, 2026

@frouene what do you think about the "Critical & Architectural Issues" identified in the automatic review? Especially the first one. Could you also rebase the PR please :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants