Repository navigation
Conversation
Fix two bugs in _build_folder_tree_from_paths():
1. has_children logic: The condition f.split('/')[0] == folder_name
incorrectly matched paths that START with the folder name, causing
leaf folders to be marked as having children.
2. Recursive path filtering: When recursively building tree for
subfolders, the full paths array was passed without filtering,
causing wrong folder names and nested structure detection.
The fix filters paths to only include those under the current
folder before recursive calls, and simplifies has_children to only
check for actual nested folders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the Explorer UI not displaying folder contents by correcting two bugs in the
_build_folder_tree_from_paths()function inapi/routes/explorer.py.Root Cause
Two bugs were causing the Explorer tree hierarchy to be incorrectly built:
Bug 1: Incorrect
has_childrenlogicThe condition
f.split('/')[0] == folder_nameincorrectly matched paths that START with the folder name, causing leaf folders to be marked as having children even when they had no subfolders.Bug 2: Recursive path filtering missing
When recursively building the tree for subfolders, the full paths array was passed without filtering, causing wrong folder names and nested structure detection.
Fix
Simplified
has_childrenlogic to only check for actual nested folders:Added path filtering before recursive calls:
Testing
Verified with simulated data:
Files Changed
api/routes/explorer.py: Fixed_build_folder_tree_from_paths()andget_folder_tree()functionsThis PR was created by an AI agent (OpenHands) on behalf of the user.
@tamzrod can click here to continue refining the PR