GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: tighten selectionModel type and verify per-instance creation by redfish4ktc · Pull Request #1078 · maxGraph/maxGraph

Conversation

@redfish4ktc

@redfish4ktc redfish4ktc commented May 26, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Type changes:

  • selectionModel: any | null -> GraphSelectionModel on AbstractGraph (matches the model/view/stylesheet convention of typing collaborators as non-null since they are always set in initializeCollaborators)
  • Drop the obsolete cells: Cell[] declaration that duplicated GraphSelectionModel.cells
  • Widen GraphSelectionModel.setCell parameter to Cell | null (potential breaking change for subclasses that override setCell with the narrower type; callers passing a non-null Cell are unaffected)

Tests:

  • Add 'Expect no global state' test for selectionModel on both Graph and BaseGraph. Verifies that despite the prototype-level null, initializeCollaborators assigns a fresh GraphSelectionModel per instance.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed selection state isolation to ensure each graph instance maintains independent selection models without cross-contamination.
    • Improved type safety for selection model properties.
  • New Features

    • Selection can now be cleared by passing null to the selection API.
  • Tests

    • Added tests verifying selection state independence between graph instances.

Review Change Stack

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@redfish4ktc
refactor: tighten selectionModel type and verify per-instance creation
69f5d69
Type changes:
- selectionModel: any | null -> GraphSelectionModel on AbstractGraph (matches the model/view/stylesheet convention
  of typing collaborators as non-null since they are always set in initializeCollaborators)
- Drop the obsolete `cells: Cell[]` declaration that duplicated GraphSelectionModel.cells
- Widen GraphSelectionModel.setCell parameter to `Cell | null` (potential breaking change for subclasses that
  override setCell with the narrower type; callers passing a non-null Cell are unaffected)

Tests:
- Add 'Expect no global state' test for selectionModel on both Graph and BaseGraph. Verifies that despite the
  prototype-level null, initializeCollaborators assigns a fresh GraphSelectionModel per instance.
@redfish4ktc redfish4ktc added the chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) label May 26, 2026
@coderabbitai

coderabbitai Bot commented May 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7a74bf2-289e-4ced-a59e-68bf9aa5c006

📥 Commits

Reviewing files that changed from the base of the PR and between 0b08535 and 69f5d69.

📒 Files selected for processing (5)
  • packages/core/__tests__/view/BaseGraph.test.ts
  • packages/core/__tests__/view/Graph.test.ts
  • packages/core/src/view/GraphSelectionModel.ts
  • packages/core/src/view/mixin/SelectionMixin.ts
  • packages/core/src/view/mixin/SelectionMixin.type.ts

Walkthrough

PR narrows selectionModel type from any | null to GraphSelectionModel, adds comments clarifying runtime initialization, expands GraphSelectionModel.setCell to accept null, and adds tests verifying each BaseGraph/Graph instance maintains distinct selection state not shared via mixins.

Changes

Selection Model Instance Isolation and Type Clarification

Layer / File(s) Summary
Selection Model type contract and initialization
packages/core/src/view/mixin/SelectionMixin.type.ts, packages/core/src/view/mixin/SelectionMixin.ts
AbstractGraph.selectionModel type is narrowed from any | null to GraphSelectionModel (non-null). Implementation switches to null! assertion with comments explaining runtime initialization via AbstractGraph.initializeCollaborators.
Selection Model API enhancement for null values
packages/core/src/view/GraphSelectionModel.ts
setCell method parameter type expands to Cell | null, allowing callers to clear selection by passing null.
Isolation verification tests
packages/core/__tests__/view/BaseGraph.test.ts, packages/core/__tests__/view/Graph.test.ts
New test suites verify that mixin-declared selectionModel and cells properties are distinct per graph instance. Each test creates multiple instances, confirms selection model references differ, and validates that mutating one instance does not affect the other.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • maxGraph/maxGraph#1055: Modifies GraphSelectionModel nullability and selection semantics in parallel with this PR's API expansion.
  • maxGraph/maxGraph#879: Targets the same root issue of mixin-derived state incorrectly shared across BaseGraph instances, with overlapping test coverage.
  • maxGraph/maxGraph#776: Introduces the AbstractGraph/BaseGraph architecture that underpins selectionModel creation, foundational to this PR's type and initialization changes.

Suggested labels

refactor

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. While it explains the type changes and tests, it lacks required PR checklist items, issue reference, and discussion confirmation from maintainers as specified in the template. Complete the PR checklist, reference the issue being addressed (closes #xxxx), confirm maintainer discussion, and add details about breaking changes and testing approach.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: tightening the selectionModel type and adding tests to verify per-instance creation of the selection model.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sonarqubecloud

sonarqubecloud Bot commented May 26, 2026

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@redfish4ktc
redfish4ktc merged commit 04a8d34 into main May 27, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@redfish4ktc
redfish4ktc deleted the test/AbstractGraph_all_obj_properties_no_sharable_state branch May 27, 2026 08:20
@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
refactor(graph): group and test the properties that cannot move to a mixin #1131
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...)

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@redfish4ktc
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.