Skip to content

Conversation

tbouffard
Copy link
Member

@tbouffard tbouffard commented May 27, 2025

This eases the maintenance and allows to detect errors earlier.
Also, correctly display the crosses related to the connection constraints when hovering on a vertex.

Notes

Depends on #838
See also #840

Summary by CodeRabbit

  • New Features

    • Added a new "Fixed Points" example to the Storybook, demonstrating how to use fixed connection points for connecting edges to vertices.
  • Refactor

    • Improved type safety and modularity in the fixed points example, enhancing consistency and reliability of the graph setup and connection handlers.

@tbouffard tbouffard added the refactor Code refactoring label May 27, 2025
Copy link

coderabbitai bot commented May 27, 2025

Walkthrough

A new Storybook MDX documentation file for "Fixed Points" was added. The corresponding story implementation was refactored for improved type safety and modularity, introducing stricter TypeScript typings, enhanced handler overrides, and updated edge and vertex setup. The code now uses custom handlers and plugins for connection constraints and edge management.

Changes

File(s) Change Summary
packages/html/stories/FixedPoints.mdx Added Storybook MDX documentation for the "Fixed Points" example, importing metadata and providing description.
packages/html/stories/FixedPoints.stories.ts Refactored and extended the story: stricter TypeScript types, custom handler overrides, updated edge/vertex setup, and improved modularity.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Storybook
    participant Graph
    participant CustomConnectionHandler
    participant CustomConstraintHandler
    participant CustomElbowEdgeHandler

    User->>Storybook: Select "Fixed Points" story
    Storybook->>Graph: Instantiate with plugins (handlers)
    Graph->>CustomConnectionHandler: Use for connection logic
    CustomConnectionHandler->>CustomConstraintHandler: Create for constraint checks
    CustomConnectionHandler->>CustomElbowEdgeHandler: Create for edge handling
    Graph->>CustomElbowEdgeHandler: Delegate edge handling
    CustomElbowEdgeHandler->>CustomConstraintHandler: Use for constraint checks
    User->>Graph: Interact (e.g., connect edges)
    Graph->>CustomConnectionHandler: Handle connections (with fixed points)
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn config production Use --omit=dev instead.
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-05-27T09_33_42_515Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

This eases the maintenance and allows to detect errors earlier.
Also, correctly display the crosses related to the connection constraints when hovering on a vertex.
@tbouffard tbouffard force-pushed the refactor/story_fixedPoints_migrate_to_ts branch from 401cfa6 to 1024412 Compare May 27, 2025 09:24
Copy link

sonarqubecloud bot commented May 27, 2025

Quality Gate Passed Quality Gate passed

Issues
1 New issue
1 Accepted issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@tbouffard tbouffard marked this pull request as ready for review May 27, 2025 09:32
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 (3)
packages/html/stories/FixedPoints.stories.ts (3)

65-80: Enhanced type safety in constraint handler! ✅

Good improvements with proper type annotations and the override keyword. The null-safe check aligns with the parent class implementation.

Consider using a safer null check pattern if there's any possibility of icon.bounds being null:

-        mathUtils.intersects(icon.bounds!, rectangle)
+        (icon.bounds && mathUtils.intersects(icon.bounds, rectangle))

154-160: Implementation works but has acknowledged limitations.

The forced use of CustomElbowEdgeHandler for all edges might be restrictive. Good that this is documented for future improvement in PR #823.

Consider adding a TODO comment with more context about what specific improvements are planned.


246-303: Consider modernizing the commented alternative implementation.

The prototype modification approach in the commented code is outdated and could cause issues. When implementing this feature with Storybook args, consider using proper class extension or composition patterns instead of prototype modification.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3fec5d5 and 1024412.

📒 Files selected for processing (2)
  • packages/html/stories/FixedPoints.mdx (1 hunks)
  • packages/html/stories/FixedPoints.stories.ts (6 hunks)
🔇 Additional comments (8)
packages/html/stories/FixedPoints.stories.ts (7)

18-45: Well-structured imports with proper TypeScript types! 👍

The addition of type imports and the new configureImagesBasePath import enhances type safety and maintainability.


61-63: Good addition of type safety and configuration setup!

The type annotation for the args parameter and the call to configureImagesBasePath() ensure proper initialization.


141-152: Clean implementation of custom edge handler!

Well-structured class that properly extends ElbowEdgeHandler and maintains consistency by delegating isConnectableCell to the ConnectionHandler plugin.


161-179: Well-defined fixed connection points!

The implementation provides a comprehensive set of 8 connection points (corners and midpoints) for vertices, which perfectly demonstrates the "Fixed Points" concept.

🧰 Tools
🪛 Biome (1.9.4)

[error] 165-165: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


182-193: Excellent modular plugin configuration!

The plugins array pattern improves code organization and the conditional RubberBandHandler addition enables dynamic configuration through Storybook args.


216-244: Great improvements to edge configuration!

Using boolean values instead of numeric (0/1) for exitPerimeter, entryPerimeter, and orthogonal properties improves code readability and type safety.


82-102:

❓ Verification inconclusive

Type safety improvements look good, but verify the ignored parameter behavior.

The enhanced type annotations improve code maintainability. However, the comment about the ignored 2nd parameter in getAllConnectionConstraints suggests a potential API mismatch.

Verify that ignoring the 2nd parameter doesn't cause issues:


🏁 Script executed:

#!/bin/bash
# Check the getAllConnectionConstraints signature in the base class
ast-grep --pattern $'getAllConnectionConstraints($_,$_)'

Length of output: 57


Unable to locate getAllConnectionConstraints signature – please verify its API
We couldn’t find a definition for getAllConnectionConstraints in the repo, so it’s unclear whether the second (boolean) parameter can safely be ignored. Ensure that your custom handler’s assumption matches the actual Graph implementation you’re extending.

packages/html/stories/FixedPoints.mdx (1)

1-9: Clear and concise documentation!

The MDX file provides appropriate documentation for the Fixed Points story with a clear title and description.

@tbouffard tbouffard merged commit 22d8c9e into main May 27, 2025
7 checks passed
@tbouffard tbouffard deleted the refactor/story_fixedPoints_migrate_to_ts branch May 27, 2025 12:11
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