Skip to content

feat(sidebar): optimize multi-select drag state logic - #9202

Merged
sachin-thakur-bruno merged 2 commits into
usebruno:mainfrom
Gopi-bruno:feat/optimize-multi-select-drag-state-logic
Sep 8, 2026
Merged

sachin-thakur-bruno merged 2 commits into
usebruno:mainfrom
Gopi-bruno:feat/optimize-multi-select-drag-state-logic

Conversation

@Gopi-bruno

@Gopi-bruno Gopi-bruno commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Moves multi-select drag-state computation out of being recomputed independently by every selected sidebar row, into one shared computation passed down via props. Also fixes a couple of Redux selector and drag-and-drop lookup inefficiencies this surfaced along the way.

Problem

Shift-selecting many sidebar rows and dragging them scaled quadratically, since every selected row independently re-walked the entire collection tree to compute its own drag state. A selector meant to cut unrelated re-renders was also silently defeated by a leftover broad subscription right next to it.

Fix

Compute the shared drag-state once in Sidebar/Collections and thread it down through Collection/CollectionItem via props instead of per-row hooks. Scoped the collection selector properly, deduped a redundant directory lookup in handleMultipleCollectionItemsDrop, and removed the now-unused hook.

Screenshots

Before After

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.
  • I've run the claude code review skill locally.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • Bug Fixes
    • Improved multi-item drag-and-drop behavior in the collections sidebar.
    • Selection state is now handled consistently when dragging collections and nested items.
    • Mixed selections that cannot be moved together are correctly prevented from being dragged.
    • Improved handling when dropping multiple items into collections or folders.
    • Improved reliability when moving multiple items between nested collections and folders.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7689d141-30b9-4a24-af9d-100209f8f81f

📥 Commits

Reviewing files that changed from the base of the PR and between 680b1da and fa2f800.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


Walkthrough

The sidebar now derives multi-select drag state in Collections, passes it through Collection and CollectionItem, and forwards it to recursive children. Drop handling now passes a pre-resolved directory to the cached helper.

Changes

Sidebar multi-select drag state

Layer / File(s) Summary
Selection drag-state derivation
packages/bruno-app/src/components/Sidebar/Collections/index.js
Collections reads selectedSidebarUids, derives selection information, computes drag restrictions, and passes collection and item drag data to Collection.
Collection item drag-state propagation
packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js, packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js
Collection and CollectionItem consume parent-provided drag state. Recursive child renders forward the same props. CollectionItem reads the current collections state during drop handling.
Drop directory resolution
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
getDirectoryItems now accepts a resolved directory. The drop handler resolves the directory before calling the helper.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to fa2f8

This refactor centralizes sidebar multi-select drag state and uses current collection state during drops. No concrete current-head merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4…
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: optimizing multi-select drag state logic in the sidebar.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Drag state flows from the sidebar bright,
Through collections in a steady flight.
Children receive the same clear cue,
Drop directories resolve anew.
Cached paths keep the work in sight.

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

… prevent unnecessary re-renders in CollectionItem
@Gopi-bruno Gopi-bruno changed the title refactor: migrate multi-select drag state logic from hook to parent c… feat(sidebar): optimize multi-select drag state logic Sep 8, 2026

@sachin-thakur-bruno sachin-thakur-bruno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@sachin-thakur-bruno
sachin-thakur-bruno merged commit ede28dd into usebruno:main Sep 8, 2026
16 of 19 checks passed
sid-bruno pushed a commit that referenced this pull request Sep 10, 2026
* refactor: migrate multi-select drag state logic from hook to parent component and pass down via props

* refactor: replace allCollections selector with direct store access to prevent unnecessary re-renders in CollectionItem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants