-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ls): add visual divider between folders and items in workspace listing #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Modified sort_ws_elements_with_separation to separate folders from items - Updated fab_fs_ls_item.exec to use separated data when folder_listing_enabled=true - Enhanced FabricCLIOutput to support folders_data and items_data - Updated _print_output_format_result_text to display divider between folders and items - Added default 'text' format when format_type is None - All existing tests pass Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
… lower-level functions - Reverted most changes to _print_output_format_result_text - Added divider logic to print_entries_unix_style path (for ls commands with data keys) - Enhanced _print_raw_data to handle folders_data and items_data with divider - Divider now handled at the appropriate abstraction level - All tests pass (21/21) - Edge cases verified: only folders, only items, both, backward compatibility Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
…h call chain - Reverted all changes to fab_output.py (no new parameters in FabricCLIOutput) - Updated print_output_format to pass folders_data and items_data directly to _print_output_format_result_text - Modified _print_output_format_result_text to accept folders_data and items_data as parameters - Divider functionality preserved without modifying FabricCLIOutput class - All tests pass (21/21) - Edge cases verified Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
- Changed sort_ws_elements_with_separation to return single array (folders first, divider entry if both exist, then items)
- Simplified fab_fs_ls_item.py: removed separate folders_data/items_data handling
- Removed folders_data/items_data parameters from fab_cmd_ls_utils.format_and_print_output
- Reverted fab_ui.py changes: removed folders_data/items_data parameters and divider logic
- Divider now appears as a data entry ('------------------------------') in the array itself
- All tests pass (21/21)
- Simpler implementation with divider as part of data structure
Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
src/fabric_cli/utils/fab_ui.py
Outdated
|
|
||
| # Default to text if format_type is still None | ||
| if format_type is None: | ||
| format_type = "text" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot revert this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept the default format logic in commit 673ee80. The format_type = "text" default is required for tests to pass when format is not explicitly set. Without it, tests fail with "Output format None not supported" error. This was added in the original implementation to fix a bug where format_type could be None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please revert. you can bypass that by passing --output_format text in the command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 71b11fa. Reverted the default format_type="text" logic. The code now matches the original behavior where format_type must be explicitly set via config or --output_format parameter.
- Refactored sort_ws_elements_with_separation() to use cleaner group-based approach - Leverages sort_ws_elements() for each group (Folder, Item) and inserts divider between groups - Added test_ls_workspace_with_folders_and_items_divider() to verify divider functionality - Test marked as skip (requires VCR cassette in live environment) - Kept default format_type="text" logic (needed for tests to pass) - All existing tests pass (21/21) Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
| if not ws_elements: | ||
| return [] | ||
|
|
||
| divider_name = "------------------------------" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot rename it to 'divider' and move it on top of this module, not part of the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 7eac2c5. Renamed divider_name to DIVIDER and moved it to the top of the module (line 19) as a module-level constant. The function now uses the DIVIDER constant.
- Renamed divider_name to DIVIDER - Moved DIVIDER to top of module as a constant (line 19) - Updated function to use DIVIDER constant instead of local variable - Improved code organization and maintainability Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
- Removed 'and ws_elements' check (empty lists are handled in the function) - Added output_format check: divider only applies when format is "text" - Added show_details check: divider only applies when --long is NOT provided - Get output_format from args or config using same pattern as fab_ui.py - Divider now only shows in text output without --long flag Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
| ] | ||
|
|
||
|
|
||
| def sort_ws_elements_with_seperation_by_type_order( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot since this is very specific to fab_fs_ls_item (ls on items), please move this method to that file, as private method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 49e143b. Moved _sort_ws_elements_with_seperation_by_type_order() and _DIVIDER constant from fab_cmd_fs_utils.py to fab_fs_ls_item.py as private members (with underscore prefix). The divider logic is now specific to and encapsulated within the ls items module.
- Moved _sort_ws_elements_with_seperation_by_type_order from fab_cmd_fs_utils.py to fab_fs_ls_item.py as private method - Moved _DIVIDER constant to fab_fs_ls_item.py (made private with underscore prefix) - Updated function call to use private _sort_ws_elements_with_seperation_by_type_order - Removed function and constant from fab_cmd_fs_utils.py - This keeps the divider logic specific to ls on items, improving code organization Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please revert the changes here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit ea026ef. Reverted all formatting changes in fab_cmd_ls_utils.py - the file now matches its original state.
- Reverted formatting changes in fab_cmd_ls_utils.py (no functional changes needed) - Removed type_order parameter from _sort_ws_elements_with_seperation_by_type_order - Hardcoded type_order = [Folder, Item] inside the private method - Simplified function call to only pass ws_elements and show_details - Updated docstring to reflect that folders always come first, then items Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
…opilot/add-divider-to-ls-output
✨ Description of new changes
When listing workspace contents with
folder_listing_enabled=trueandoutput_format=text, folders and items were displayed in a flat mixed list with no visual separation, reducing readability.This change adds a visual divider (
------------------------------) between folders and items to improve readability when listing workspace contents.Summary: Adds a visual divider between folders and items in
fab lsworkspace listing output. The divider only appears whenfolder_listing_enabled=true,output_format=text, and--longflag is NOT provided. The divider is inserted as a data entry in the sorted results, requiring no changes to rendering logic or core output classes.Context: The original issue requested better visual distinction between folders and items in workspace listings, similar to the behavior when using
-aflag for virtual workspace items. This improves readability and helps users quickly identify folders vs. items in large workspaces.Dependencies: None - uses existing infrastructure and utilities.
Implementation Details
Divider as a data entry:
_DIVIDER = "------------------------------"defined infab_fs_ls_item.py_sort_ws_elements_with_seperation_by_type_order()groups elements by type (Folder, Item), sorts each group using existingsort_ws_elements(), and inserts divider between non-empty groupsfolder_listing_enabled=true(config setting)output_format="text"(not JSON)--longflag NOT providedCode organization:
fab_fs_ls_item.pysort_ws_elements()fromfab_cmd_fs_utils.pyfor consistencyfab_ui.py,fab_output.py, orfab_cmd_ls_utils.pyBehavior Examples
When
folder_listing_enabled=true,output_format=text, and WITHOUT--longflag:When using
--longflag or JSON output:Testing
test_ls_workspace_with_folders_and_items_divider()added to verify divider functionality (marked as skip, requires VCR cassette recording in live environment)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.