Skip to content

fix(dashboard): restrict Path Finder "To" dropdown to reachable nodes#197

Open
ShresthSamyak wants to merge 1 commit into
Lum1104:mainfrom
ShresthSamyak:fix/path-finder-reachable-only
Open

fix(dashboard): restrict Path Finder "To" dropdown to reachable nodes#197
ShresthSamyak wants to merge 1 commit into
Lum1104:mainfrom
ShresthSamyak:fix/path-finder-reachable-only

Conversation

@ShresthSamyak
Copy link
Copy Markdown

Summary

  • Compute the set of nodes reachable from the chosen From node and filter the To dropdown to that set, so the user can't pick a destination with no path. Closes FEATURE Path filter #188.
  • Memoize the undirected adjacency on the graph so reachability and findPath agree and the work isn't redone on every render.
  • Polish: disable To until a source is selected, show the reachable count next to the To label, and clear a stale To selection if the user changes From to a source from which the previous target is unreachable.

Before

Both selects listed every node. Pairs with no connecting path only failed after clicking Find Path, requiring the user to manually scan edges to find working destinations.

After

Once From is picked, To only shows nodes actually reachable from it — N reachable is shown next to the label. Selecting To before From is disabled with a placeholder hinting at the order. If the source has no neighbors, To shows No reachable nodes from source instead of empty options.

Notes

  • Reachability uses the same bidirectional traversal as the existing findPath (treats graph edges as undirected) so the filter and the BFS result can never disagree.
  • The "No path found" branch in the result panel is now defensively unreachable for valid inputs but is left in place since it's cheap.

Test plan

  • pnpm install
  • pnpm --filter @understand-anything/dashboard exec tsc --noEmit — clean
  • pnpm --filter @understand-anything/dashboard build — succeeds
  • pnpm --filter @understand-anything/dashboard test — 42 passed
  • pnpm lint — clean
  • Manually verify in the dashboard demo: pick a From node, confirm To only lists reachable destinations and the count matches.
  • Verify To is disabled until From is picked, and that changing From to a node that can't reach the prior target clears the To selection.

The Dependency Path Finder modal listed every node in both the "From"
and "To" selects, so users could pick a destination that was not
reachable from the source and only learn "no path found" after clicking
Find Path.

Compute the reachable set from the chosen "From" node via the same
undirected adjacency used by findPath (memoized on the graph), and
filter the "To" dropdown to that set. Disable "To" until a source is
picked, surface the reachable count, and clear a stale "To" selection
when the source changes.

Closes Lum1104#188
Copilot AI review requested due to automatic review settings May 24, 2026 05:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates PathFinderModal to prevent users from selecting an unreachable destination node by precomputing reachability from the selected source and filtering the “To” dropdown accordingly.

Changes:

  • Memoized an undirected adjacency map derived from the graph edges.
  • Added a memoized BFS reachability set from the selected “From” node and filtered “To” candidates.
  • Disabled/annotated the “To” selector when no source is chosen or when no destinations are reachable, and auto-cleared stale “To” selections.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +51
const reachableFromSource = useMemo(() => {
if (!fromNodeId) return null;
const reachable = new Set<string>();
const queue: string[] = [fromNodeId];
reachable.add(fromNodeId);
while (queue.length > 0) {
const nodeId = queue.shift()!;
const neighbors = adjacency.get(nodeId) ?? [];
for (const n of neighbors) {
if (!reachable.has(n)) {
reachable.add(n);
queue.push(n);
}
}
}
reachable.delete(fromNodeId);
return reachable;
}, [fromNodeId, adjacency]);
Comment on lines +55 to +60
useEffect(() => {
if (toNodeId && reachableFromSource && !reachableFromSource.has(toNodeId)) {
setToNodeId("");
setPath(null);
}
}, [reachableFromSource, toNodeId]);
Comment on lines +38 to +40
reachable.add(fromNodeId);
while (queue.length > 0) {
const nodeId = queue.shift()!;
@Lum1104
Copy link
Copy Markdown
Owner

Lum1104 commented May 24, 2026

@codex review this

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

FEATURE Path filter

3 participants