This commit is contained in:
Bryce
2025-08-06 21:30:33 -07:00
parent 3387867561
commit d021f045ae
14 changed files with 426 additions and 375 deletions

View File

@@ -0,0 +1,143 @@
# Folder Types Implementation Plan: Adding Ignore Type
## Overview
This plan outlines the implementation of a third folder type called "Ignore" which will be stored in the database but neither scanned for tidying nor used as destination folders. When a folder is set to ignore, it will be hidden by default in the user interface.
## System Architecture Changes
### Current Folder Types
1. **Tidy**: Folders scanned and processed by AI, sorting them into Destination folders
2. **Destination**: Folders that are targets for email organization based on rules
### New Folder Types
1. **Tidy**: Folders scanned and processed by AI, sorting them into Destination folders
2. **Destination**: Folders that are targets for email organization based on rules
3. **Ignore**: Folders stored in database but not processed by AI and hidden by default
## Implementation Steps
### 1. Update Design Documentation
- Update [`docs/design/data-model.md`](docs/design/data-model.md) to include the new "ignore" folder type
- Update [`docs/design/folder-types-ui.md`](docs/design/folder-types-ui.md) to include UI changes for the new type
- Add documentation for folder type behavior and business rules
### 2. Update Database Model
- The [`folder_type`](app/models.py:43) field in the Folder model already supports string values and can accommodate the new "ignore" type
- No database migration is needed as the field is already a string with a default value
- Update any business logic in the application to handle the new folder type
### 3. Update IMAP Synchronization Flow
- Modify the IMAP sync process to include a second step with a folder type selection modal
- The modal should display a table of folders with:
- Folder name column
- Folder type selection column (Tidy, Destination, Ignore)
- Default folder types:
- Inbox: Tidy
- Archive/Spam/Drafts: Ignore
- Create a new template for the folder selection modal
### 4. Update User Interface
- Add a checkbox (unchecked by default) for "show hidden" folders
- When checked, it should reveal folders with folder_type="ignore"
- Modify folder card components to handle the new folder type:
- Hide ignore folders by default
- Show appropriate UI elements based on folder type
- Replace the "organize this folder" toggle with a folder type selector for tidy and destination folders
### 5. Update Folder Management
- Modify the folder creation and editing forms to include folder type selection
- Update the folder card templates to handle the new type
- Add logic to reset known emails count when changing to ignore type
- Update the delete functionality to handle all folder types
### 6. Update API Endpoints
- Modify the folder toggle endpoint to handle folder type changes instead of just organize_enabled
- Add new endpoint for updating folder type specifically
- Update existing endpoints to handle the new folder type in their logic
### 7. Update Tests
- Add tests for the new folder type functionality
- Test that ignore folders are hidden by default
- Test that they can be shown when the "show hidden" checkbox is checked
- Test folder type changes through the API
- Test the IMAP sync flow with the new folder selection modal
## Implementation Details
### Folder Type Business Logic
```
Tidy Folders:
- Scanned and processed by AI
- Have pending/processed email counts
- Can have organization rules enabled/disabled
- Example: Inbox
Destination Folders:
- Not processed by AI
- Display count of emails moved to this folder
- Focus on folder management and viewing contents
- Example: "Projects", "Finance", "Personal"
Ignore Folders:
- Stored in database but not processed by AI
- Hidden by default in UI
- No organization rules
- Known emails count reset to 0 when changed to ignore
- Example: Archive, Spam, Drafts
```
### UI Changes
1. **Main Page**:
- Add "Show Hidden" checkbox in the search/filter section
- When checked, display ignore folders with appropriate styling
2. **Folder Cards**:
- For tidy folders: Show pending/processed counts and organize toggle
- For destination folders: Show emails count
- For ignore folders: Show minimal information when visible
3. **IMAP Sync Modal**:
- First step: Connection testing (existing)
- Second step: Folder type selection (new)
- Table with folder names and type selection dropdowns
### API Changes
1. **Folder Creation/Update**:
- Include folder_type in form data
- Default to "destination" for manually created folders
2. **Folder Toggle**:
- Change from organize_enabled toggle to folder_type selector
- Handle resetting emails_count when changing to ignore
### Database Schema
- No changes needed as the existing [`folder_type`](app/models.py:43) field can accommodate the new value
- Current field: `folder_type = db.Column(db.String(20), default='destination', nullable=False)`
## Testing Strategy
### Unit Tests
- Test folder type validation
- Test folder type change logic (resetting emails count)
- Test UI rendering for different folder types
### Integration Tests
- Test IMAP sync flow with folder type selection
- Test "show hidden" functionality
- Test folder CRUD operations with all types
### End-to-End Tests
- Test complete user workflow for creating folders with different types
- Test IMAP setup and folder type selection
- Test showing/hiding ignore folders
## Migration Plan
- No database migration needed as the field already supports string values
- Existing folders will maintain their current types
- New folders will default to "destination" type
## Rollback Plan
- If issues arise, the system can be rolled back by:
- Limiting folder_type values to only 'tidy' and 'destination'
- Reverting UI changes to the previous two-type system
- Disabling the "show hidden" functionality