Skip to content

Conversation

@oodmumc3
Copy link

@oodmumc3 oodmumc3 commented Mar 12, 2025

✨ Major Changes

1️⃣ Added support for .gitignore

  • Implemented automatic recognition of .gitignore files and pattern processing
  • Support for various .gitignore patterns:
    • Wildcard pattern (*.log)
    • Directory-specific pattern (ignored_dir/)
    • Exclusion pattern (!important.log)
  • Integrate .gitignore patterns into existing hardcoded ignore lists

2️⃣ File filtering improvements

  • Improved file path comparison algorithm
  • Supports pattern matching on both full paths and base names
  • Improved filtering accuracy for files in subdirectories

3️⃣ Code structure improvements and modularisation

  • Split selector.py module into 3 modules to improve readability and maintainability
    • selector_actions.py: functions for file selection, search, and expand/shrink behaviour
    • selector_ui.py: UI related FileSelector classes
    • selector.py: interactive_selection function as an external interface
  • Benefits
    • Separation of concerns makes code more readable and maintainable
    • Modules can be unit tested
    • Designed for extensibility

4️⃣ Added Vim-style search and navigation

  • Enabled search mode with / key (supports regular expressions)
  • Toggle case sensitivity with ^ key
  • Keep tree structure in search results and restore list with ESC key
  • Added j/k keys to navigate and h/l keys to open/close folders

5️⃣ UI and performance improvements

  • Improved search result status display (currently displayed files/total files)
  • Change status bar in search mode and add no results notification
  • Optimised status management on search cancellation/completion

6️⃣ Code refactoring and modularisation

  • Split existing codeselect.py into multi-module structure:
    • utils.py: common utility functions
    • filetree.py: file tree management
    • selector.py: file selection UI
    • output.py`: output format management
    • dependency.py: Project dependency analysis
    • cli.py: CLI functionality
    • codeselect.py: entry point script

7️⃣ Testing and documentation

  • Added .gitignore related unit tests
  • Add module-specific unit tests and ensure compatibility with existing functionality
  • Updated project structure documentation and incorporated design overview documentation
  • Progressed detailed documentation for each module

How to review and test PR content.

  1. Verify that the .gitignore function works properly
  2. verify that file filtering works as intended
  3. Verify that the selector.py module works as intended after its removal
  4. test that Vim-style search and navigation works properly
  5. verify that compatibility with existing functionality is maintained after a full code refactoring
  6. verify that all unit tests pass

🎯 This PR solves the following:

  • Add .gitignore based file filtering
  • Improve code structure for better maintainability
  • Improved search and navigation
  • Increased stability through testing and documentation

Purpose: Practice AI coding and improve codeselect functionality

jin.bak and others added 23 commits March 10, 2025 17:26
- Extract common utility functions into separate modules
 - get_language_name: Extension-language mapping
 - try_copy_to_clipboard: Clipboard copy function
 - generate_output_filename: Generate filename
 - should_ignore_path: Path filtering

- Add test code (test/test_utils.py)
- Separating versioning constants

Completed the first step in modularising the codebase
- Implemented Node class (file/directory representation)
- Implemented build_file_tree() function (organises the file structure of a directory into a tree)
- Implemented flatten_tree() function (generates a list of nodes for UI display)
- Implement count_selected_files() function (counts the number of selected files)
- Implement collect_selected_content() function (collect selected file contents)
- Implement collect_all_content() function (collect all file contents)
- Implement _should_ignore() function (determine which files/directories to ignore)
- Write and test unit test code
- Language mapping function (get_language_name)
- Clipboard copy function (try_copy_to_clipboard)
- Generate output filename (generate_output_filename)
- Check path to ignore (should_ignore_path)
- Add test code (test_utils.py)
- Implement Node class (file/directory node representation)
- Implemented build_file_tree function (to create a file structure tree)
- Implemented flatten_tree function (flatten node list for UI display)
- Implement count_selected_files function (counts the number of selected files)
- Implement collect_selected_content function (collect selected file contents)
- Implemented collect_all_content function (collect all file contents)
- Added test code (test_filetree.py)
- Implement FileSelector class (curses-based interactive file selection UI)
- Implement interactive_selection function (UI starting point)
- Add test code (test_selector.py)
- Split a single codebase into seven specialised modules
 - utils.py: Common utility functions
 - filetree.py: File tree structure management
 - selector.py: File selection UI
 - output.py: Manage output formats
 - dependency.py: dependency analysis
 - cli.py: Command line interface
 - codeselect.py: Simplified entry point

- Added test code for each module
- Updated documentation (project_structure.md, change_log.md)
- Improved code readability and maintainability
- Clarified dependencies between modules

No functional changes, only structural improvements
- Implemented search mode using `/` keys (regular expression support)
- Added ability to preserve tree structure in search results
- Added support for Vim-style navigation using `j`, `k`, `h`, and `l` keys
- Added ability to restore full list with ESC in search results
- Fix to allow file selection/deselection even after searching
- Updated related documentation (README.md, changelog, design brief)
Splitting the `selector.py` file into three modules based on the principle of separation of concerns:
- selector.py: external interface (interactive_selection function)
- selector_ui.py: UI-related code (FileSelector class)
- selector_actions.py: functions related to file selection behaviour

Changes:
- Maintained all existing functionality, only improved code structure
- Added test cases for each module
- Updated documentation (change_log.md, design_overview.md, project_structure.md)

Benefits:
- Improved readability and maintainability
- Compliance with the principle of single responsibility for each module
- Possibility of independent testing
- Improved scalability
- Implement .gitignore pattern matching
- Add test cases for .gitignore filtering
- Enhance should_ignore_path function
- Improve file path handling for gitignore patterns
…xpected file counts

- Updated test cases (`test_flatten_tree`, `test_count_selected_files`, `test_collect_selected_content`, `test_collect_all_content`) to include `important.log`, which is not filtered by `.gitignore`
- Adjusted expected file counts in various test cases based on actual results
- Fixed `level_0_nodes` expected count (8 → 7) and `level_1_nodes` expected count (3 → 4) in `test_flatten_tree`
- Add .gitignore support details to change_log.md
- Added .gitignore support details to design_overview.md
- Added .gitignore-related utility function descriptions to project_structure.md
- Mark .gitignore support items complete in TODO.md
- Add .gitignore support completed items to TODO.md priority list
- Added .gitignore support related content to the TODO.md Completed tasks section
- Write detailed technical documentation on implementing gitignore support features
…rectories, improve .gitignore handling, and enhance removal messages

- Added fish shell support
- Improved removal messages for clarity
- Added functionality to remove module directories
- Enhanced .gitignore handling with additional information
- Included selector_ui.py and selector_actions.py in module list
This commit introduces a multi-pattern search capability to the file selector UI. You can now input multiple file name patterns, separated by commas or spaces, to filter the file tree using an OR condition.

Key changes:

- Modified `selector_actions.py`:
    - `apply_search_filter` now accepts a list of search patterns.
    - Filtering logic updated to match files against any of the provided patterns.
    - Handles case sensitivity and invalid regular expressions for multiple patterns.
    - Ensures parent directories of matched files are included and marked as expanded.

- Modified `selector_ui.py`:
    - Search input now parses comma or space-separated strings into a list of patterns.
    - UI updated to display the full multi-pattern search query.
    - "No matching files" message is displayed when no results are found for the given patterns.
    - ESC key behavior refined for clearing filters and exiting search mode.
    - You can now edit your previous multi-pattern search query.

- Added comprehensive unit tests in `test/test_selector_actions.py` for the new multi-pattern logic in `apply_search_filter`.
- Conducted manual testing to verify various scenarios, including different pattern combinations, case sensitivity, wildcard usage, and UI interactions.

This feature enhances the usability of the file selector by allowing more flexible and powerful file filtering.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
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.

1 participant