Skip to content

fix: Folder Sequencing When we try to move any folder at the bottom of the folders list#8722

Open
ravindra-bruno wants to merge 4 commits into
usebruno:mainfrom
ravindra-bruno:fix/BRU-1112
Open

fix: Folder Sequencing When we try to move any folder at the bottom of the folders list#8722
ravindra-bruno wants to merge 4 commits into
usebruno:mainfrom
ravindra-bruno:fix/BRU-1112

Conversation

@ravindra-bruno

@ravindra-bruno ravindra-bruno commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

JIRA: BRU-1112

Description

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.

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

  • New Features

    • Improved collection drag-and-drop placement with clear above, inside, and below drop targets.
    • Added more accurate collection reordering, including moves across folders and mixed content.
    • Prevented invalid moves into an item itself or its descendants.
  • Bug Fixes

    • Fixed path handling for similarly named folders and cross-collection moves.
    • Preserved correct ordering when moving folders around files and other collections.
  • Tests

    • Added comprehensive coverage for drop positioning, validation, path updates, and reordering scenarios.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Collection drag-and-drop now uses shared utilities for drop-position resolution, pathname validation, and sequence reordering. UI handlers, Redux actions, styling, and tests were updated to use above, inside, and below drop types.

Changes

Collection drag-and-drop

Layer / File(s) Summary
Shared drop resolution and reorder utilities
packages/bruno-app/src/utils/collections/index.js, packages/bruno-app/src/utils/tests/collections/drag-and-drop.spec.js
Shared helpers determine drop placement, validate path relationships, calculate target paths, and normalize reordered sequences; tests cover placement, validation, and mixed folder/file ordering.
Redux collection move and reorder integration
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
Move and same-location reorder actions pass dropType through sequence recalculation and use separator-aware descendant checks.
Drop monitor and visual state wiring
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js, packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js
DnD handlers resolve and validate drop types from monitor state, dispatch resolved drops, reset stale state, and apply matching visual classes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: naman-bruno, helloanoop, lohit-bruno

Poem

Above, below, or nestled inside,
Collections now know where to glide.
Paths guard the tree,
Sequences agree,
And drop lines sparkle with pride. ✨

Sequence Diagram(s)

sequenceDiagram
  participant DragMonitor
  participant CollectionItem
  participant CollectionUtilities
  participant CollectionsActions
  DragMonitor->>CollectionItem: provide hover geometry and client offset
  CollectionItem->>CollectionUtilities: resolve dropType and validate item
  CollectionUtilities-->>CollectionItem: above, inside, or below
  CollectionItem->>CollectionsActions: dispatch collection item drop
  CollectionsActions->>CollectionUtilities: reorder target directory with dropType
  CollectionUtilities-->>CollectionsActions: normalized sequence values
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: fixing folder sequencing when moving a folder to the bottom of the list.
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.
✨ 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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js`:
- Around line 1270-1271: Update the stale comments in
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js:1270-1271
and
packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js:272-273
to use the current dropType terminology, referring to above/below in the
sequence-update comment and above in the collection line-indicator comment; make
no code changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fb1bc5d4-0d98-46d3-ada0-34c56913cc46

📥 Commits

Reviewing files that changed from the base of the PR and between eaf62ee and 256f0cb.

📒 Files selected for processing (5)
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
  • packages/bruno-app/src/utils/collections/index.js
  • packages/bruno-app/src/utils/tests/collections/drag-and-drop.spec.js

Comment on lines 1270 to +1271
// Update sequences in the target directory (if dropping adjacent)
if (dropType === 'adjacent') {
if (dropType === 'above' || dropType === 'below') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Stale "adjacent" comments left over from the dropType rename. Both comments describe the exact lines this PR rewrote to use 'above'/'below' instead of the old 'adjacent' dropType, but still reference the removed term.

  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js#L1270-L1271: update the comment // Update sequences in the target directory (if dropping adjacent) to reference 'above'/'below' instead of "adjacent".
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js#L272-L273: update the comment // For collections, show line indicator (adjacent drop) to reference the new 'above' dropType instead of "adjacent drop".
📍 Affects 2 files
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js#L1270-L1271 (this comment)
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js#L272-L273
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js`
around lines 1270 - 1271, Update the stale comments in
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js:1270-1271
and
packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js:272-273
to use the current dropType terminology, referring to above/below in the
sequence-update comment and above in the collection line-indicator comment; make
no code changes.

@@ -1267,7 +1268,7 @@ export const handleCollectionItemDrop
}

// Update sequences in the target directory (if dropping adjacent)

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.

If the droptype is removed from adjacent and is now above or below, then change the comments to reflect the same

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants