Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Nov 19, 2025

refactor: introduce AbstractPathShape base class for shape hierarchy

Replace ActorShape as the base class for CloudShape, HexagonShape, and
TriangleShape. These classes had no functional relation with ActorShape -
the inheritance was only for technical convenience.

Introduce AbstractPathShape as a dedicated abstract base class to make
the hierarchy more explicit and semantically clear. ActorShape now extends
AbstractPathShape alongside the other shapes.

Changes:

  • Add new AbstractPathShape abstract class
  • Refactor ActorShape to extend AbstractPathShape
  • Update CloudShape, HexagonShape, and TriangleShape to extend AbstractPathShape

Summary by CodeRabbit

  • Refactor

    • Reorganized shape rendering system architecture for improved code structure and maintainability.
  • Documentation

    • Updated shape documentation with enhanced reference annotations.

✏️ Tip: You can customize this high-level summary in your review settings.

Replace ActorShape as the base class for CloudShape, HexagonShape, and
TriangleShape. These classes had no functional relation with ActorShape -
the inheritance was only for technical convenience.

Introduce AbstractPathShape as a dedicated abstract base class to make
the hierarchy more explicit and semantically clear. ActorShape now extends
AbstractPathShape alongside the other shapes.

Changes:
- Add new AbstractPathShape abstract class
- Refactor ActorShape to extend AbstractPathShape
- Update CloudShape, HexagonShape, and TriangleShape to extend AbstractPathShape
@tbouffard tbouffard added the refactor Code refactoring label Nov 19, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

Warning

Rate limit exceeded

@tbouffard has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8590896 and 59aaf02.

📒 Files selected for processing (2)
  • packages/core/src/view/shape/node/AbstractPathShape.ts (1 hunks)
  • packages/core/src/view/shape/node/CloudShape.ts (1 hunks)

Walkthrough

Introduces AbstractPathShape, a new abstract base class consolidating common painting and styling logic for path-based vertex shapes. Refactors ActorShape, CloudShape, HexagonShape, and TriangleShape to extend AbstractPathShape instead of previous base classes. Updates Shape.ts documentation to use {@link} style references.

Changes

Cohort / File(s) Summary
Documentation updates
packages/core/src/view/shape/Shape.ts
JSDoc references in updateBoundingBox method updated from angle-bracket style to {@link ...} style for boundingBox, createBoundingBox, and augmentBoundingBox.
New abstract infrastructure
packages/core/src/view/shape/node/AbstractPathShape.ts
New exported abstract class AbstractPathShape extending Shape. Provides concrete paintVertexShape workflow with canvas translation, path beginning, delegation to abstract redrawPath method, and fill/stroke operations.
Refactored shape hierarchy
packages/core/src/view/shape/node/ActorShape.ts, CloudShape.ts, HexagonShape.ts, TriangleShape.ts
Four shape classes updated to extend AbstractPathShape instead of ActorShape or Shape. Constructors removed (inherit from AbstractPathShape). paintVertexShape method removed (inherited from AbstractPathShape). redrawPath method updated with override modifier. Imports adjusted to reference AbstractPathShape.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • AbstractPathShape design verification: Confirm the new abstract class correctly consolidates common painting logic and properly defines the redrawPath contract.
  • Inheritance chain validation: Verify each of the four shape classes (ActorShape, CloudShape, HexagonShape, TriangleShape) correctly transition to the new base class without losing functionality.
  • Constructor removal: Ensure removal of explicit constructors does not break instantiation or property initialization across all four shape classes.
  • Import correctness: Confirm all import statements are updated consistently and type-only imports are properly designated.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description provides a clear overview of changes and reasoning, but the required PR checklist items are not addressed (issue reference, tests, screenshots, docs, conventional commits confirmation). Complete the PR checklist section to confirm whether tests were added, if documentation changes are needed, and verify issue reference and scope confirmation.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: introducing AbstractPathShape as a new base class for the shape hierarchy, which is the primary objective of this refactoring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/core/src/view/shape/node/CloudShape.ts (1)

19-38: Update CloudShape JSDoc to match new base class

The move to AbstractPathShape and the optional constructor are fine, but the JSDoc still claims this “Extends {@link ActorShape} to implement a cloud shape.”

To avoid confusion for readers, consider updating that line, for example:

-/**
- * Extends {@link ActorShape} to implement a cloud shape.
+/**
+ * Path-based cloud vertex shape built on {@link AbstractPathShape}.

The rest of the implementation can stay as-is.

🧹 Nitpick comments (1)
packages/core/src/view/shape/node/ActorShape.ts (1)

20-39: ActorShape refactor is sound; JSDoc can mention AbstractPathShape

The change to derive ActorShape from AbstractPathShape with an optional constructor that forwards all four arguments to super looks correct and consistent with the other path-based shapes. redrawPath continues to operate in the normalized 0..w/0..h space, which matches AbstractPathShape.paintVertexShape’s translate(x, y) behavior.

The class-level JSDoc still reads:

Extends {@link Shape} to implement an actor shape.

Given the new hierarchy, you might want to reference the path-specific base to make the design clearer, for example:

-/**
- * Extends {@link Shape} to implement an actor shape.
+/**
+ * Path-based actor vertex shape built on {@link AbstractPathShape}.

Functionality-wise, no changes are needed.

Also applies to: 44-52

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb16ce4 and 97cc2c2.

📒 Files selected for processing (6)
  • packages/core/src/view/shape/Shape.ts (1 hunks)
  • packages/core/src/view/shape/node/AbstractPathShape.ts (1 hunks)
  • packages/core/src/view/shape/node/ActorShape.ts (1 hunks)
  • packages/core/src/view/shape/node/CloudShape.ts (2 hunks)
  • packages/core/src/view/shape/node/HexagonShape.ts (2 hunks)
  • packages/core/src/view/shape/node/TriangleShape.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 776
File: packages/core/src/view/AbstractGraph.ts:492-495
Timestamp: 2025-04-24T12:34:56.726Z
Learning: PR #776 focuses on refactoring to introduce AbstractGraph as a base class and moving code from Graph to AbstractGraph. Type improvements and other refinements should be addressed in future PRs to keep this one focused on the core architectural change.
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 849
File: packages/html/stories/DragSource.stories.js:98-101
Timestamp: 2025-06-13T07:48:10.300Z
Learning: User tbouffard prefers answers in English; avoid switching to other languages in future replies.
📚 Learning: 2025-04-24T12:34:56.726Z
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 776
File: packages/core/src/view/AbstractGraph.ts:492-495
Timestamp: 2025-04-24T12:34:56.726Z
Learning: PR #776 focuses on refactoring to introduce AbstractGraph as a base class and moving code from Graph to AbstractGraph. Type improvements and other refinements should be addressed in future PRs to keep this one focused on the core architectural change.

Applied to files:

  • packages/core/src/view/shape/node/AbstractPathShape.ts
🧬 Code graph analysis (5)
packages/core/src/view/shape/node/TriangleShape.ts (1)
packages/core/src/types.ts (1)
  • ColorValue (909-909)
packages/core/src/view/shape/node/HexagonShape.ts (1)
packages/core/src/types.ts (1)
  • ColorValue (909-909)
packages/core/src/view/shape/node/CloudShape.ts (1)
packages/core/src/types.ts (1)
  • ColorValue (909-909)
packages/core/src/view/shape/node/AbstractPathShape.ts (2)
packages/core/src/types.ts (1)
  • ColorValue (909-909)
packages/core/src/util/Constants.ts (1)
  • NONE (378-378)
packages/core/src/view/shape/node/ActorShape.ts (3)
packages/core/src/view/canvas/XmlCanvas2D.ts (2)
  • fill (942-944)
  • stroke (935-937)
packages/core/src/view/canvas/SvgCanvas2D.ts (2)
  • fill (1807-1809)
  • stroke (1800-1802)
packages/core/src/types.ts (1)
  • ColorValue (909-909)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build
  • GitHub Check: build (windows-2022)
  • GitHub Check: build (ubuntu-24.04)
  • GitHub Check: build (macos-14)
🔇 Additional comments (3)
packages/core/src/view/shape/Shape.ts (1)

1019-1020: JSDoc link style change looks good

Using {@link ...} for boundingBox, createBoundingBox, and augmentBoundingBox is consistent with the rest of the file and doesn’t affect behavior.

packages/core/src/view/shape/node/HexagonShape.ts (1)

19-40: HexagonShape migration to AbstractPathShape is correct

Imports, inheritance, and the optional constructor forwarding to super(bounds, fill, stroke, strokeWidth) align with the new path-based base while preserving the expected instantiation contract.

packages/core/src/view/shape/node/TriangleShape.ts (1)

20-40: TriangleShape refactor to AbstractPathShape is consistent

The new inheritance and constructor delegation to AbstractPathShape are consistent with Hexagon/Cloud/Actor and keep the public instantiation pattern intact.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/core/src/view/shape/node/ActorShape.ts (1)

32-39: Constructor is redundant and can be safely omitted

The constructor just forwards parameters to super() without additional logic. Since TypeScript automatically inherits the base class constructor signature when a derived class doesn't declare its own, you can remove this constructor entirely and rely on the inherited constructor from AbstractPathShape. This reduces duplication while maintaining identical behavior and type safety.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6fc482 and fb497a6.

📒 Files selected for processing (1)
  • packages/core/src/view/shape/node/ActorShape.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 776
File: packages/core/src/view/AbstractGraph.ts:492-495
Timestamp: 2025-04-24T12:34:56.726Z
Learning: PR #776 focuses on refactoring to introduce AbstractGraph as a base class and moving code from Graph to AbstractGraph. Type improvements and other refinements should be addressed in future PRs to keep this one focused on the core architectural change.
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 849
File: packages/html/stories/DragSource.stories.js:98-101
Timestamp: 2025-06-13T07:48:10.300Z
Learning: User tbouffard prefers answers in English; avoid switching to other languages in future replies.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build
  • GitHub Check: build (ubuntu-24.04)
  • GitHub Check: build (windows-2022)
  • GitHub Check: build (macos-14)
🔇 Additional comments (3)
packages/core/src/view/shape/node/ActorShape.ts (3)

19-23: Imports now align with the new AbstractPathShape base

Switching to AbstractPathShape and using a type-only import for ColorValue is consistent with the new hierarchy and keeps types explicit without impacting runtime.


25-31: Doc and base class correctly reflect the refactored shape hierarchy

The updated description and extends AbstractPathShape cleanly express that ActorShape is a path-based vertex shape and decouple it from unrelated shapes, matching the PR’s architectural goal.


41-52: redrawPath override remains correct and benefits from the override keyword

Marking redrawPath with override keeps the existing path logic while adding compile-time checks against the abstract base, which is exactly what we want for this refactor.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/core/src/view/shape/node/CloudShape.ts (1)

19-42: CloudShape correctly migrated to AbstractPathShape, but JSDoc still mentions ActorShape.

The switch to AbstractPathShape and the type-only AbstractCanvas2D import look consistent with the new path-based hierarchy; CloudShape only customizes redrawPath, so behavior should remain unchanged.

The JSDoc still says “Extends {@link ActorShape}”, which is now inaccurate and could confuse readers. Consider updating it to reference AbstractPathShape or rephrasing without naming the base class.

Based on learnings, treating this as a non-blocking doc tweak aligned with the refactor’s scope.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb497a6 and 8590896.

📒 Files selected for processing (4)
  • packages/core/src/view/shape/node/ActorShape.ts (1 hunks)
  • packages/core/src/view/shape/node/CloudShape.ts (2 hunks)
  • packages/core/src/view/shape/node/HexagonShape.ts (2 hunks)
  • packages/core/src/view/shape/node/TriangleShape.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/view/shape/node/ActorShape.ts
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 776
File: packages/core/src/view/AbstractGraph.ts:492-495
Timestamp: 2025-04-24T12:34:56.726Z
Learning: PR #776 focuses on refactoring to introduce AbstractGraph as a base class and moving code from Graph to AbstractGraph. Type improvements and other refinements should be addressed in future PRs to keep this one focused on the core architectural change.
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 857
File: packages/core/src/view/plugins/SelectionHandler.ts:1081-1092
Timestamp: 2025-06-26T13:27:19.012Z
Learning: User tbouffard prefers to keep PRs focused on their main objective and defer implementation improvements or logic fixes to future dedicated PRs. For maxGraph, refactoring PRs like Dictionary→Map migration should not include unrelated logic improvements even when valid issues are identified in the migrated code.
Learnt from: tbouffard
Repo: maxGraph/maxGraph PR: 849
File: packages/html/stories/DragSource.stories.js:98-101
Timestamp: 2025-06-13T07:48:10.300Z
Learning: User tbouffard prefers answers in English; avoid switching to other languages in future replies.
🔇 Additional comments (2)
packages/core/src/view/shape/node/TriangleShape.ts (1)

20-52: TriangleShape migration to AbstractPathShape looks consistent and behavior-preserving.

Imports, the new extends AbstractPathShape, and the redrawPath override align with a path-based base class, and the use of getBaseArcSize/addPoints suggests shared rounding logic now lives in the base. No functional regressions are apparent in this class.

packages/core/src/view/shape/node/HexagonShape.ts (1)

19-51: HexagonShape is cleanly aligned with AbstractPathShape without changing behavior.

The new base class, imports, and redrawPath implementation are consistent with the other refactored shapes. Relying on the inherited constructor and using getBaseArcSize/addPoints centralizes path logic as intended, with no visible functional changes.

@sonarqubecloud
Copy link

@tbouffard tbouffard merged commit aaea98a into main Nov 24, 2025
4 checks passed
@tbouffard tbouffard deleted the refactor/ActorShape branch November 24, 2025 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant