feat: add multi-destination pathfinding with drag-and-drop reordering#2954
feat: add multi-destination pathfinding with drag-and-drop reordering#2954julian1j wants to merge 5 commits into
Conversation
Enables chaining up to 4 nodes (1 source + 3 destinations) in pathfinding queries. Each consecutive pair fires a parallel shortest-path API call and results are merged client-side. Includes drag-and-drop reordering, node removal, and URL persistence via tertiarySearch/quaternarySearch params.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR extends pathfinding search from two fixed endpoints to up to four ordered waypoints, adding URL parameter support, multi-leg graph querying, dynamic hook state, and draggable UI updates. It also adds a ChangesMulti-node pathfinding
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/javascript/bh-shared-ui/src/hooks/useExploreGraph/queries/pathfindingSearch.ts`:
- Around line 48-49: The waypoint list in pathfindingSearch is compacting sparse
inputs with filter(Boolean), which can change the intended slot order for
persisted URL destinations. Update the waypoints construction in
useExploreGraph/pathfindingSearch to preserve positional gaps or explicitly
reject/normalize sparse chains before calling the path query, so primarySearch,
secondarySearch, tertiarySearch, and quaternarySearch are interpreted in their
original order.
In
`@packages/javascript/bh-shared-ui/src/hooks/useExploreGraph/usePathfindingSearch.ts`:
- Around line 59-71: The `usePathfindingSearch` effects only increase
`extraNodeCount`, so clearing `tertiarySearch` or `quaternarySearch` leaves
`totalNodeCount` stale and keeps empty waypoint rows rendered. Update the
`useEffect` blocks around `syncNodeFromParam` to also recalculate or reset
`extraNodeCount` based on the current URL params instead of only using
`Math.max`, so removed waypoints reduce the count when appropriate. Make sure
the logic handles both the tertiary and quaternary cases consistently and keeps
`setExtraNodeCount` in sync with `tertiarySearch`, `quaternarySearch`, `data2`,
and `data3`.
In
`@packages/javascript/bh-shared-ui/src/views/Explore/ExploreSearch/PathfindingSearch.tsx`:
- Around line 138-151: Add a keyboard-accessible way to reorder destinations in
PathfindingSearch: the current draggable-only flow in the item wrapper and grip
icon is not reachable by keyboard users. Update the reorder UI around the
draggable row and grip control to expose focusable move controls or keyboard
event handling (for example in the same render path that uses handleDragStart,
handleDragEnter, handleDrop, and the faGripVertical grip) so users can move
items up/down without a mouse.
🪄 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: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 73ecc1f1-2444-4b27-a40a-cee68850e4bf
📒 Files selected for processing (6)
.gitignorecmd/ui/src/views/Explore/ExploreSearch/ExploreSearch.tsxpackages/javascript/bh-shared-ui/src/hooks/useExploreGraph/queries/pathfindingSearch.tspackages/javascript/bh-shared-ui/src/hooks/useExploreGraph/usePathfindingSearch.tspackages/javascript/bh-shared-ui/src/hooks/useExploreParams/useExploreParams.tsxpackages/javascript/bh-shared-ui/src/views/Explore/ExploreSearch/PathfindingSearch.tsx
| // Build ordered list of waypoints | ||
| const waypoints = [primarySearch, secondarySearch, tertiarySearch, quaternarySearch].filter(Boolean) as string[]; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Don’t compact sparse waypoint params.
filter(Boolean) turns [primary, secondary, null, quaternary] into [primary, secondary, quaternary], so a sparse URL can query a different ordered path than the persisted node slots indicate. Since this PR adds URL persistence for extra destinations, disable or normalize sparse chains before querying.
Proposed guard
- const waypoints = [primarySearch, secondarySearch, tertiarySearch, quaternarySearch].filter(Boolean) as string[];
+ if (!tertiarySearch && quaternarySearch) {
+ return { enabled: false };
+ }
+
+ const waypoints = [primarySearch, secondarySearch, tertiarySearch, quaternarySearch].filter(
+ (waypoint): waypoint is string => !!waypoint
+ );🤖 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/javascript/bh-shared-ui/src/hooks/useExploreGraph/queries/pathfindingSearch.ts`
around lines 48 - 49, The waypoint list in pathfindingSearch is compacting
sparse inputs with filter(Boolean), which can change the intended slot order for
persisted URL destinations. Update the waypoints construction in
useExploreGraph/pathfindingSearch to preserve positional gaps or explicitly
reject/normalize sparse chains before calling the path query, so primarySearch,
secondarySearch, tertiarySearch, and quaternarySearch are interpreted in their
original order.
- Sync extraNodeCount bidirectionally with URL params so removing waypoints properly reduces the visible node count - Add keyboard accessibility to drag-and-drop reorder (arrow keys on the grip handle)
Wrap updateNode and syncNodeFromParam in useCallback to satisfy react-hooks/exhaustive-deps lint rule.
Use getByRole('textbox') to target inputs specifically, avoiding
ambiguity with the reorder grip handle aria-labels.
Enables chaining up to 4 nodes (1 source + 3 destinations) in pathfinding queries. Each consecutive pair fires a parallel shortestpath API call and results are merged client-side. Includes drag-and-drop reordering, node removal, and URL persistence via tertiarySearch/quaternarySearch params.
Description
Enables chaining up to 4 nodes (1 source + 3 destinations) in pathfinding queries, similar to Google Maps multi-stop routing
Motivation and Context
Resolves BED-8075
Why is this change required? What problem does it solve?
How Has This Been Tested?
Tested locally on CE with standard example dataset.
Screenshots (optional):
Types of changes
Checklist:
Summary by CodeRabbit
.claude/directory.