|
| 1 | +# PRD: Fix EditModal MediaType Switching and Extras Conversion Flow |
| 2 | + |
| 3 | +## Introduction/Overview |
| 4 | + |
| 5 | +This feature fixes two related issues with the EditModal and Extras conversion workflow: |
| 6 | + |
| 7 | +1. **EditModal MediaType Dropdown Issue**: Currently, switching the MediaType dropdown in EditModal re-fetches files from the API with a filter, causing files to disappear. It should instead switch between editing UI modes while keeping the same files visible. |
| 8 | + |
| 9 | +2. **Extras Conversion Issue**: When converting Extras to Movies/TV Shows, files get stuck in "Processing" status because no TMDb metadata is assigned. The conversion should open EditModal to allow metadata assignment. |
| 10 | + |
| 11 | +**Problem Solved**: Users cannot effectively convert Extras to Movies/TV Shows because there's no way to assign TMDb metadata during conversion. Additionally, the EditModal's MediaType dropdown doesn't work as expected when users want to change a file's type. |
| 12 | + |
| 13 | +**Goal**: Enable seamless conversion from Extras to Movies/TV Shows with immediate metadata assignment, and fix EditModal MediaType switching to clear metadata and change UI modes without losing files. |
| 14 | + |
| 15 | +## Goals |
| 16 | + |
| 17 | +1. Allow users to convert Extras to Movies/TV Shows via EditModal with metadata assignment |
| 18 | +2. Fix EditModal MediaType dropdown to switch UI modes instead of filtering files |
| 19 | +3. Show warning when switching MediaType to inform users metadata will be cleared |
| 20 | +4. Provide visual feedback when metadata is cleared after MediaType switch |
| 21 | +5. Ensure converted files don't get stuck in Processing status |
| 22 | + |
| 23 | +## User Stories |
| 24 | + |
| 25 | +1. **As a user**, I want to convert an Extra file to a Movie by clicking "Convert to Movie", immediately see the EditModal, search for the correct title, assign the TMDb ID, and save so the file processes correctly. |
| 26 | + |
| 27 | +2. **As a user**, I want to convert multiple Extra files to a TV Show, assign them all to the same series, set season/episode numbers, and save so they all process as TV episodes. |
| 28 | + |
| 29 | +3. **As a user**, I want to change a file's MediaType in the EditModal from Movie to TV Show, be warned that metadata will be cleared, confirm the change, and see the TV Show editing interface so I can assign new metadata. |
| 30 | + |
| 31 | +4. **As a user**, I want to see a clear indication when metadata has been cleared after switching MediaType so I know I need to assign new metadata. |
| 32 | + |
| 33 | +5. **As a user**, I want files to remain visible in EditModal when I switch MediaType so I don't lose my selection. |
| 34 | + |
| 35 | +## Functional Requirements |
| 36 | + |
| 37 | +### 1. EditModal: Fix MediaType Dropdown Behavior |
| 38 | + |
| 39 | +1.1. Remove the API re-fetch when MediaType dropdown changes |
| 40 | + - Remove `selectedMediaType` from the useEffect dependency array (line 82 in edit-modal.tsx) |
| 41 | + - Files should only be fetched once when modal opens, not when dropdown changes |
| 42 | + |
| 43 | +1.2. Modify `handleMediaTypeChange` to show confirmation dialog before switching: |
| 44 | + - Dialog title: "Switch Media Type?" |
| 45 | + - Dialog message: "Switching media type will clear all metadata (TMDb ID, season, episode numbers). This action cannot be undone. Continue?" |
| 46 | + - Actions: "Cancel" and "Continue" |
| 47 | + |
| 48 | +1.3. On confirmation, clear metadata for all files in `editableRows`: |
| 49 | + - Set `tmdbId` to `0` |
| 50 | + - Set `seasonNumber` to `undefined` |
| 51 | + - Set `episodeNumber` to `undefined` |
| 52 | + - Set `episodeNumber2` to `undefined` |
| 53 | + - Update `mediaType` to the new selected type |
| 54 | + |
| 55 | +1.4. Show visual indicator after metadata is cleared: |
| 56 | + - Display toast notification: "Media type changed. All metadata has been cleared." |
| 57 | + - OR show a banner at the top of the modal: "⚠️ Metadata cleared - please assign new TMDb information" |
| 58 | + |
| 59 | +1.5. UI should switch between MovieEditTable and TvShowEditTable based on selected MediaType |
| 60 | + |
| 61 | +1.6. Files should remain in the modal and visible after MediaType switch |
| 62 | + |
| 63 | +### 2. Extras Conversion: Open EditModal Instead of AlertDialog |
| 64 | + |
| 65 | +2.1. Modify "Convert to Movie" button behavior: |
| 66 | + - Remove AlertDialog confirmation |
| 67 | + - Open EditModal directly |
| 68 | + - Set `initialMediaType` to `MediaType.Movies` |
| 69 | + - Pass selected Extra files to EditModal |
| 70 | + |
| 71 | +2.2. Modify "Convert to TV Show" button behavior: |
| 72 | + - Remove AlertDialog confirmation |
| 73 | + - Open EditModal directly |
| 74 | + - Set `initialMediaType` to `MediaType.TvShows` |
| 75 | + - Pass selected Extra files to EditModal |
| 76 | + |
| 77 | +2.3. Keep "Mark as Extra" button with existing AlertDialog behavior (no changes) |
| 78 | + |
| 79 | +### 3. Update Save Logic to Include MediaType Change |
| 80 | + |
| 81 | +3.1. Modify `handleSaveEdits` in `index.tsx`: |
| 82 | + - When calling `mediaApi.updateScannedFile`, include `mediaType` in the request |
| 83 | + - Pass `mediaType: row.mediaType` from the editableRows |
| 84 | + - This ensures both MediaType change and TMDb metadata are updated together |
| 85 | + |
| 86 | +3.2. After saving, trigger existing symlink recreation (`mediaApi.recreateAllSymlinks()`) |
| 87 | + |
| 88 | +3.3. After successful save, refresh the table data and clear selection |
| 89 | + |
| 90 | +### 4. User Feedback and State Management |
| 91 | + |
| 92 | +4.1. Add state to track if EditModal was opened for Extras conversion: |
| 93 | + - This helps differentiate between editing existing files vs. converting Extras |
| 94 | + - Could add a banner: "Converting from Extras - please assign metadata" |
| 95 | + |
| 96 | +4.2. When user cancels EditModal during Extras conversion: |
| 97 | + - Files remain as Extras (no MediaType change) |
| 98 | + - Selection is cleared |
| 99 | + - No API calls are made |
| 100 | + |
| 101 | +4.3. Toast notifications: |
| 102 | + - Success: "Converted {count} file(s) to {MediaType} and assigned metadata" |
| 103 | + - Error: "Failed to convert files. Please try again." |
| 104 | + |
| 105 | +## Non-Goals (Out of Scope) |
| 106 | + |
| 107 | +1. Changing EditModal's overall UI/UX design |
| 108 | +2. Adding new metadata fields beyond what exists |
| 109 | +3. Bulk TMDb search across multiple files |
| 110 | +4. Auto-detecting MediaType based on file properties |
| 111 | +5. Undo/redo functionality for MediaType switches |
| 112 | +6. Validation of season/episode number ranges |
| 113 | +7. Integration with external metadata sources beyond TMDb |
| 114 | + |
| 115 | +## Design Considerations |
| 116 | + |
| 117 | +### UI/UX |
| 118 | + |
| 119 | +**MediaType Switch Confirmation Dialog:** |
| 120 | +``` |
| 121 | +┌─────────────────────────────────────┐ |
| 122 | +│ Switch Media Type? │ |
| 123 | +├─────────────────────────────────────┤ |
| 124 | +│ Switching media type will clear all │ |
| 125 | +│ metadata (TMDb ID, season, episode │ |
| 126 | +│ numbers). This action cannot be │ |
| 127 | +│ undone. Continue? │ |
| 128 | +│ │ |
| 129 | +│ [Cancel] [Continue] │ |
| 130 | +└─────────────────────────────────────┘ |
| 131 | +``` |
| 132 | + |
| 133 | +**Metadata Cleared Indicator (Toast):** |
| 134 | +``` |
| 135 | +┌─────────────────────────────────────┐ |
| 136 | +│ ℹ️ Media type changed. All metadata │ |
| 137 | +│ has been cleared. │ |
| 138 | +└─────────────────────────────────────┘ |
| 139 | +``` |
| 140 | + |
| 141 | +**Conversion Flow:** |
| 142 | +- User clicks "Convert to Movie" → EditModal opens immediately |
| 143 | +- No intermediate confirmation dialog |
| 144 | +- Modal shows Movie editing interface with empty metadata |
| 145 | +- User searches, assigns TMDb ID, clicks Save |
| 146 | +- Files convert from Extras to Movies with metadata |
| 147 | + |
| 148 | +### Technical Architecture |
| 149 | + |
| 150 | +**State Flow for MediaType Switch:** |
| 151 | +``` |
| 152 | +User changes dropdown |
| 153 | + ↓ |
| 154 | +Show confirmation dialog |
| 155 | + ↓ |
| 156 | +User clicks "Continue" |
| 157 | + ↓ |
| 158 | +Clear all metadata in editableRows |
| 159 | + ↓ |
| 160 | +Update selectedMediaType state |
| 161 | + ↓ |
| 162 | +UI switches to Movie/TV table |
| 163 | + ↓ |
| 164 | +Show toast notification |
| 165 | +``` |
| 166 | + |
| 167 | +**State Flow for Extras Conversion:** |
| 168 | +``` |
| 169 | +User selects Extras files |
| 170 | + ↓ |
| 171 | +User clicks "Convert to Movie/TV Show" |
| 172 | + ↓ |
| 173 | +EditModal opens with initialMediaType |
| 174 | + ↓ |
| 175 | +User assigns metadata |
| 176 | + ↓ |
| 177 | +User clicks Save |
| 178 | + ↓ |
| 179 | +API call: updateScannedFile with mediaType + TMDb data |
| 180 | + ↓ |
| 181 | +Backend changes MediaType, sets Processing status |
| 182 | + ↓ |
| 183 | +Backend re-detection triggered |
| 184 | + ↓ |
| 185 | +Symlinks created |
| 186 | + ↓ |
| 187 | +Status → Success |
| 188 | +``` |
| 189 | + |
| 190 | +## Technical Considerations |
| 191 | + |
| 192 | +### Frontend Changes |
| 193 | + |
| 194 | +**File: `frontend/src/components/scanned-files-table/edit-modal.tsx`** |
| 195 | +- Add state for MediaType switch confirmation dialog: `showMediaTypeWarning` |
| 196 | +- Remove `selectedMediaType` from line 82 useEffect dependencies |
| 197 | +- Add `handleConfirmMediaTypeChange` function to clear metadata |
| 198 | +- Import and add AlertDialog component for MediaType switch warning |
| 199 | +- Add toast hook for metadata cleared notification |
| 200 | + |
| 201 | +**File: `frontend/src/components/scanned-files-table/index.tsx`** |
| 202 | +- Remove AlertDialog for Movie/TV Show conversions (keep for Extras) |
| 203 | +- Modify `handleConvertToMovie` and `handleConvertToTvShow` to call `setIsEditModalOpen(true)` |
| 204 | +- Update `handleSaveEdits` to include `mediaType: editableRow.mediaType` in API calls |
| 205 | +- Optionally add state to track "conversion mode" for additional UI hints |
| 206 | + |
| 207 | +### Backend (No Changes Required) |
| 208 | +- Backend already supports `mediaType` in `UpdateScannedFileRequest` |
| 209 | +- Backend already handles MediaType changes correctly |
| 210 | +- Backend already triggers re-detection when status → Processing |
| 211 | +- No new endpoints or modifications needed |
| 212 | + |
| 213 | +### Dependencies |
| 214 | +- Existing: EditModal, AlertDialog, Toast hook, mediaApi |
| 215 | +- New: None (use existing components) |
| 216 | + |
| 217 | +## Success Metrics |
| 218 | + |
| 219 | +1. **Conversion Success Rate**: > 95% of Extras conversions result in Success status (not stuck in Processing) |
| 220 | +2. **User Completion Rate**: > 90% of users who click "Convert to Movie/TV Show" complete the metadata assignment |
| 221 | +3. **MediaType Switch Usage**: Track how often users switch MediaType in EditModal |
| 222 | +4. **Error Rate**: < 2% of metadata assignments fail |
| 223 | +5. **User Feedback**: Positive reception to warning dialog and metadata clearing behavior |
| 224 | + |
| 225 | +## Open Questions |
| 226 | + |
| 227 | +1. Should there be a "quick convert" option that skips EditModal for users who want to batch-convert Extras and assign metadata later? (Out of scope for now) |
| 228 | +2. Should the warning dialog remember user's choice ("Don't show this again")? (Probably not - it's an important warning) |
| 229 | +3. Should there be a keyboard shortcut to switch MediaType in EditModal? (Nice to have, not critical) |
| 230 | +4. Should the metadata cleared toast be dismissible or auto-dismiss? (Auto-dismiss after 3-5 seconds) |
| 231 | + |
| 232 | +--- |
| 233 | + |
| 234 | +**Document Version**: 1.0 |
| 235 | +**Created**: 2025-10-14 |
| 236 | +**Target Implementation**: Frontend only (Next.js 15 + React 19) |
| 237 | +**Estimated Complexity**: Low-Medium (1-2 days) |
| 238 | +**Related PRD**: 0001-prd-extras-categorization.md |
0 commit comments