Skip to content

feat!: use registry metadata for edge handle visibility#1040

Open
redfish4ktc wants to merge 4 commits intomainfrom
refactor/no_entityRelation_hard_coded
Open

feat!: use registry metadata for edge handle visibility#1040
redfish4ktc wants to merge 4 commits intomainfrom
refactor/no_entityRelation_hard_coded

Conversation

@redfish4ktc
Copy link
Copy Markdown

@redfish4ktc redfish4ktc commented Apr 3, 2026

Overview

The hard-coded reference to EdgeStyle.EntityRelation in EdgeHandler.isHandleVisible()
created a direct dependency on the EntityRelation function, preventing tree-shaking
when EntityRelation is not used in the application. It also meant only EntityRelation
could influence handle visibility — no other edge style (including custom ones) could
control whether intermediate bend handles are shown.

Replace this with an allowIntermediateHandles metadata property on EdgeStyleRegistry,
following the existing pattern of isOrthogonal and handlerKind.

Benefits:

  • Generic: any edge style can now control intermediate handle visibility via metadata
  • Configurable and extensible: custom edge styles can set allowIntermediateHandles: false
  • Tree-shakeable: EdgeHandler no longer imports EdgeStyle directly

BREAKING CHANGE:

  • EdgeStyleRegistryInterface has a new allowsIntermediateHandles() method
  • Custom registrations of EntityRelation (e.g. when using BaseGraph) must now include
    { allowIntermediateHandles: false } in the metadata to preserve the previous behavior

Notes

Closes #978

I did a search to check if EdgeStyle is referenced elsewhere in the code.
With the exception of the function that stores the default value “EdgeStyle” and the loop described in section #758, there are no other references.

Impact on the bundle size

When EntityRelation is not used by the application, the decrease is ~2kB.

Example 9f8381b now
js-example 467.65 kB 467.94 kB
js-example-selected-features 388.78 kB 386.69 kB
js-example-without-defaults 323.37 kB 321.28 kB
ts-example 433.53 kB 433.85 kB
ts-example-selected-features 367.64 kB 366.59 kB
ts-example-without-defaults 306.64 kB 304.04 kB

Note that the size increases in js-example and ts-example because EntityRelation is registered (in the list of default EdgeStyles loaded in this case), so the change made in this PR has no effect; this PR actually includes new code designed to manage the visibility of identifiers. It is this new code that is causing the increase.

Summary by CodeRabbit

  • Breaking Changes

    • Edge handle visibility now follows registry-based configuration instead of prior hardcoded logic.
  • New Features

    • Added a metadata option to control intermediate bend-handle visibility when registering edge styles.
    • Entity-relation edge styles now hide intermediate bend handles by default.
  • Documentation

    • Updated docs to explain the new handle-visibility option and migration guidance.
  • Tests

    • Added tests covering handle-visibility scenarios and registry behavior.
  • Chores

    • Updated commit message body wrapping guidance to 120 characters.

The hard-coded reference to EdgeStyle.EntityRelation in EdgeHandler.isHandleVisible()
created a direct dependency on the EntityRelation function, preventing tree-shaking
when EntityRelation is not used in the application. It also meant only EntityRelation
could influence handle visibility — no other edge style (including custom ones) could
control whether intermediate bend handles are shown.

Replace this with an allowIntermediateHandles metadata property on EdgeStyleRegistry,
following the existing pattern of isOrthogonal and handlerKind.

Benefits:
- Generic: any edge style can now control intermediate handle visibility via metadata
- Configurable and extensible: custom edge styles can set allowIntermediateHandles: false
- Tree-shakeable: EdgeHandler no longer imports EdgeStyle directly

BREAKING CHANGE:
- EdgeStyleRegistryInterface has a new allowsIntermediateHandles() method
- Custom registrations of EntityRelation (e.g. when using BaseGraph) must now include
  { allowIntermediateHandles: false } in the metadata to preserve the previous behavior
@redfish4ktc redfish4ktc added the enhancement New feature or request label Apr 3, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

Walkthrough

Replaces a hardcoded EdgeStyle.EntityRelation check with a registry-driven allowIntermediateHandles metadata flag and new EdgeStyleRegistry.allowsIntermediateHandles() API; updates types, registry, handler, default registration, tests, docs, changelog, and a couple of build config values.

Changes

Cohort / File(s) Summary
Type Definitions
packages/core/src/types.ts
Add allowIntermediateHandles?: boolean to EdgeStyleMetaData and allowsIntermediateHandles(edgeStyle?: EdgeStyleFunction | null): boolean to EdgeStyleRegistryInterface.
Registry Implementation
packages/core/src/view/style/edge/EdgeStyleRegistry.ts
Store per-style allowIntermediateHandles state, add allowsIntermediateHandles(...) (defaults to true), and clear the map on clear().
Default Registrations
packages/core/src/view/style/register.ts
Register entityRelationEdgeStyle with { allowIntermediateHandles: false } to preserve prior behavior.
Handler Implementation
packages/core/src/view/handler/EdgeHandler.ts
Replace enum-based EntityRelation check with EdgeStyleRegistry.allowsIntermediateHandles(edgeStyle) in isHandleVisible().
Tests
packages/core/__tests__/view/handler/EdgeHandler.test.ts, packages/core/__tests__/view/style/EdgeStyleRegistry.test.ts
Add tests covering EdgeHandler.isHandleVisible() across style/geometry scenarios and EdgeStyleRegistry.allowsIntermediateHandles() for registered/unregistered styles.
Documentation & Inline Docs
packages/website/docs/usage/edge-styles.md, packages/core/src/view/style/edge/EntityRelation.ts
Document new allowIntermediateHandles metadata (since 0.24.0) and guidance to register EntityRelation with allowIntermediateHandles: false.
Changelog & Commit Rules
CHANGELOG.md, .claude/rules/git/commit-conventions.md
Add unreleased breaking-change notes for edge-handle visibility; change commit message body wrap guidance from 72 to 120 chars.
Examples / Build Config
packages/ts-example-selected-features/vite.config.js, packages/ts-example-without-defaults/vite.config.js
Minor adjustments to Vite build.chunkSizeWarningLimit values.

Sequence Diagram(s)

mermaid
sequenceDiagram
rect rgba(40, 116, 240, 0.5)
participant Editor
end
rect rgba(34, 197, 94, 0.5)
participant EdgeHandler
end
rect rgba(219, 39, 119, 0.5)
participant EdgeStyleRegistry
end
Editor->>EdgeHandler: Request handle visibility (index, edgeStyle, geometry)
EdgeHandler->>EdgeStyleRegistry: allowsIntermediateHandles(edgeStyle)
EdgeStyleRegistry-->>EdgeHandler: boolean (true/false)
EdgeHandler-->>Editor: return visibility (first/last always visible; intermediate per registry)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

refactor

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: replacing hard-coded EdgeStyle.EntityRelation dependency with registry metadata for edge handle visibility control.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed PR description comprehensively covers the problem, solution, breaking changes, benefits, bundle impact analysis, and references the closed issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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
Copy Markdown

@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.

🧹 Nitpick comments (1)
.claude/rules/git/commit-conventions.md (1)

21-21: Please keep this docs-only convention change out of this feature PR (or justify it explicitly).

At Line 21, updating commit-body wrap width is unrelated to the edge-style registry/handle-visibility objective and makes the PR harder to review and release safely. Prefer a separate docs/chore PR for this change.

Based on learnings: User tbouffard prefers to keep PRs focused on their main objective and defer unrelated improvements to dedicated PRs.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3c26c5a9-5fac-4520-943b-0ee92208e167

📥 Commits

Reviewing files that changed from the base of the PR and between 9f8381b and e936acb.

📒 Files selected for processing (9)
  • .claude/rules/git/commit-conventions.md
  • CHANGELOG.md
  • packages/core/__tests__/view/handler/EdgeHandler.test.ts
  • packages/core/__tests__/view/style/EdgeStyleRegistry.test.ts
  • packages/core/src/types.ts
  • packages/core/src/view/handler/EdgeHandler.ts
  • packages/core/src/view/style/edge/EdgeStyleRegistry.ts
  • packages/core/src/view/style/register.ts
  • packages/website/docs/usage/edge-styles.md

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 3, 2026

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove EdgeHandler dependency on EdgeStyle.EntityRelation for better tree shaking

1 participant