Skip to content

Conversation

@SaidTorres3
Copy link

🎉 Add Nested Groups Support

Overview

This PR implements nested groups functionality for File Focus, allowing users to organize their file groups in hierarchical structures. This addresses the long-standing feature request mentioned in the Known Issues section of the README.

✨ Features Added

🏗️ Hierarchical Group Structure

  • Groups can now contain other groups as children
  • Unlimited nesting depth supported
  • Maintains parent-child relationships
  • Backwards compatible with existing flat group structures

🖱️ Intuitive Drag & Drop

  • Drag groups onto other groups to create nested hierarchies
  • Drag groups to root area to move them back to top level
  • Drag files/folders between nested groups
  • Circular reference prevention - prevents moving groups into their own children
  • Visual feedback during drag operations

📋 Enhanced Context Menu

  • "Add Nested Group" - Create child groups within existing groups
  • "Move to Different Group" - Move groups between any level with clear hierarchy display
  • "Move to Root Level" - Quick action to move nested groups back to root

🔄 Recursive Operations

  • "Open Group" now recursively opens ALL files from nested child groups
  • Smart traversal of the entire group hierarchy
  • Maintains performance with large nested structures

🌳 Improved Tree View

  • Clear visual hierarchy with proper expand/collapse behavior
  • Groups show as expandable nodes containing both files and sub-groups
  • Consistent UI patterns for all nesting levels

🏗️ Technical Implementation

Core Changes

  • Group.ts: Added childGroups array and parent-child relationship methods
  • GroupManager.ts: Enhanced with hierarchical group management and move operations
  • GroupFacade.ts: Added recursive operations and nested group commands
  • FileFocusTreeProvider.ts: Implemented nested drag & drop and tree rendering

Storage Enhancements

  • StateStorage.ts: Updated to serialize/deserialize nested structures
  • FileStorage.ts: Enhanced .filefocus.json format to support hierarchy
  • Backwards compatibility: Existing configurations continue to work seamlessly

New Commands

  • fileFocus.addNestedGroup - Add child group to selected group
  • fileFocus.moveToRootLevel - Move group to root level
  • fileFocus.moveToParentGroup - Move group to different parent

🧪 Testing

  • All existing functionality remains intact
  • Nested operations work at any depth
  • Drag & drop handles edge cases properly
  • Storage maintains data integrity across sessions

🔄 Backwards Compatibility

  • Existing flat group structures continue to work without changes
  • .filefocus.json files from previous versions load correctly
  • No breaking changes to existing workflows

📸 Usage Examples

Creating Nested Structure

📁 Frontend
  📁 Components
    📄 Button.tsx
    📄 Modal.tsx
  📁 Utils
    📄 helpers.ts
📁 Backend
  📁 Controllers
  📁 Models

.filefocus.json:

{
  "store": [
    {
      "name": "Frontend",
      "path": [],
      "groups": [
        {
          "name": "Components",
          "path": [
            "Frontend/Components/Button.tsx",
            "Frontend/Components/Modal.tsx"
          ]
        },
        {
          "name": "Utils",
          "path": ["Frontend/Utils/helpers.ts"]
        }
      ]
    },
    {
      "name": "Backend",
      "path": [],
      "groups": [
        {
          "name": "Controllers",
          "path": []
        },
        {
          "name": "Models",
          "path": []
        }
      ]
    }
  ]
}

Drag & Drop Operations

  • Drag "Components" group onto "Frontend" group → nests inside
  • Drag "Frontend" group to root area → moves back to top level
  • Drag files between any nested groups → moves files seamlessly

🎯 Benefits

  • Better organization for large codebases with complex structures
  • Intuitive UX with familiar drag & drop interactions
  • Scalable for projects with hundreds of files across multiple modules
  • Maintains performance even with deep nesting

📝 Notes

  • Resolves the "Nested Groups" item from Known Issues
  • Maintains all existing File Focus functionality
  • Ready for immediate use with zero migration required

This PR transforms File Focus from a flat file organizer into a powerful hierarchical project management tool while maintaining the simplicity and performance users love! 🚀

@SaidTorres3
Copy link
Author

More testing is needed to ensure everything works as expected.

@SaidTorres3
Copy link
Author

There is a bug where if you have .filefocus.json folders and you drag and drop one of those folders over a normal folder, it will get stuck there because it will copy as the same id as the original, being that unable to be deleted easily.

I think the proper solution will be don't let people drag and drop folders from .filefocus.json

bugfilefocus1.mp4

@SaidTorres3
Copy link
Author

There is a bug where if you have .filefocus.json folders and you drag and drop one of those folders over a normal folder, it will get stuck there because it will copy as the same id as the original, being that unable to be deleted easily.

I think the proper solution will be don't let people drag and drop folders from .filefocus.json

bugfilefocus1.mp4

Bug fixed.

@SaidTorres3 SaidTorres3 marked this pull request as ready for review September 3, 2025 15:56
@SaidTorres3
Copy link
Author

If anyone want to test the extension changes right now, you install it from here:
file-focus-1.6.1-nested-folders-v001.zip

@SaidTorres3
Copy link
Author

I also fixed the bug that generated an annoying [object Object] every time you created a folder with the 'Add group' button (which is still present on current main extension) and not affecting the 'Add to focus group' behavior.

@SaidTorres3
Copy link
Author

@SaidTorres3 SaidTorres3 mentioned this pull request Sep 3, 2025
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