Skip to content

fix(Group): add resolver for groups selection bucket#281

Merged
draedful merged 2 commits intomainfrom
fix-resolve-group-seleciton
Apr 9, 2026
Merged

fix(Group): add resolver for groups selection bucket#281
draedful merged 2 commits intomainfrom
fix-resolve-group-seleciton

Conversation

@draedful
Copy link
Copy Markdown
Collaborator

@draedful draedful commented Apr 8, 2026

Summary by Sourcery

Track and expose the live view component associated with each group state and ensure group selection operates on mounted Group view instances.

Enhancements:

  • Add a dedicated signal and accessors on GroupState to store the associated Group view component instance.
  • Register and clear the Group view component on mount/unmount of the Group canvas component.
  • Extend the GroupsListStore selection bucket resolver to map group IDs to their mounted Group view components.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 8, 2026

Reviewer's Guide

Expose and manage a view component reference on GroupState, and plug it into the groups selection bucket so selected group IDs resolve to live Group view instances.

Sequence diagram for group selection bucket resolving to view components

sequenceDiagram
  participant User
  participant SelectionBucket
  participant GroupsListStore
  participant GroupState
  participant Group

  User->>SelectionBucket: select groups by ids
  SelectionBucket->>GroupsListStore: resolve(ids)
  GroupsListStore->>GroupsListStore: getGroupStates(ids)
  loop for each id
    GroupsListStore->>GroupState: access instance
    GroupState-->>GroupsListStore: return GroupState
  end
  GroupsListStore->>GroupsListStore: map GroupState to getViewComponent()
  loop for each GroupState
    GroupsListStore->>GroupState: getViewComponent()
    alt mounted
      GroupState-->>GroupsListStore: Group instance
    else unmounted
      GroupState-->>GroupsListStore: undefined
    end
  end
  GroupsListStore-->>SelectionBucket: list of Group instances
  SelectionBucket-->>User: selection with live Group components

  rect rgb(230,230,230)
    Note over Group,GroupState: During Group.mount
    Group->>GroupState: setViewComponent(this)
    Note over Group,GroupState: During Group.unmount
    Group->>GroupState: setViewComponent(undefined)
  end
Loading

Class diagram for updated GroupState, Group, and GroupsListStore

classDiagram
  class GroupState {
    <<class>>
    +readonly $state
    +readonly $viewComponent
    +setState(state)
    +setViewComponent(component)
    +getViewComponent()
  }

  class Group {
    <<class>>
    +groupState
    +mount()
    +unmount()
    +updateHitBox(rect)
  }

  class GroupsListStore {
    <<class>>
    +selectionBucket
    +getGroupStates(ids)
  }

  GroupState --> Group : holds viewComponent
  Group --> GroupState : uses
  GroupsListStore --> GroupState : resolves groupStates
  GroupsListStore --> Group : resolves view components
Loading

File-Level Changes

Change Details Files
Track the Group view component instance in GroupState and expose accessors.
  • Introduce a $viewComponent signal on GroupState initialized with undefined.
  • Add setViewComponent to update the $viewComponent signal with a Group instance or clear it.
  • Add getViewComponent to read the current Group instance from the signal.
src/store/group/Group.ts
Wire Group component lifecycle to keep GroupState.viewComponent in sync with the rendered instance.
  • On Group.mount, register the current Group instance on its GroupState via setViewComponent.
  • On Group.unmount, clear the GroupState view component reference and delegate to the base class unmount.
src/components/canvas/groups/Group.ts
Extend GroupsListStore selection bucket to resolve group IDs into concrete Group view components.
  • Add a resolver that maps selection bucket IDs to GroupState instances using getGroupStates.
  • Filter out missing GroupState entries and missing view components, returning only existing Group instances for the bucket.
src/store/group/GroupsList.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gravity-ui-bot
Copy link
Copy Markdown
Contributor

Preview is ready.

@draedful draedful marked this pull request as ready for review April 8, 2026 14:21
@draedful draedful requested a review from Antamansid as a code owner April 8, 2026 14:21
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@draedful draedful merged commit c5fce35 into main Apr 9, 2026
7 checks passed
@draedful draedful deleted the fix-resolve-group-seleciton branch April 9, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants