- Create organized logging system with subfolders - Add dedicated crash log (logs/crashes.log) - Add specific log paths for different components - Implement panic recovery with stack traces - Add crash-safe logging functions - Update UnifiedPlayer with better error handling and recovery - Special handling for test video file - Add comprehensive testing checklist for Phase A This makes crashes much easier to diagnose and debug when testing the UnifiedPlayer implementation. Files: - internal/logging/logging.go (enhanced) - internal/player/unified_ffmpeg_player.go (crash-safe) - TESTING_CHECKLIST.md (comprehensive checklist) - CONVERSION_MODULARIZATION_PLAN.md (dev25 preparation)
3.4 KiB
3.4 KiB
Convert Panel Modularization Plan (Dev24/25)
🎯 Goal
Move Advanced Convert UI logic out of main.go into modular UI components, keeping main.go as glue only.
📁 File Structure
internal/ui/
├── convert_advanced.go # Advanced panel UI builder
├── convert_state.go # State manager + callbacks
├── convert_simple.go # Simple panel UI builder (future)
└── convert_types.go # Shared types and constants
main.go (cleanup)
├── Keep encoding/FFmpeg logic in existing helpers
├── Import internal/ui package only
└── Replace UI blocks with module calls
🔧 What to Extract from main.go
1. UI Builders (buildConvertView -> convert_advanced.go)
- Advanced panel dropdowns, sliders, toggles
- Layout containers and responsive sizing
- Quality presets and format selection
- Hardware acceleration controls
- Two-pass encoding interface
- Progress preview and command display
2. State Management (convertUIState -> convert_state.go)
type ConvertState struct {
// Current settings
Format formatOption
Quality string
Preset string
TwoPass bool
HardwareAccel bool
// UI bindings
FormatList *widget.Select
QualitySelect *widget.Select
// ... etc
}
type ConvertUIBindings struct {
// Controls accessible to main.go
StartConversion func()
StopConversion func()
ShowPreview func()
// ... etc
}
3. Callback Functions (applyQuality, setQuality, updateEncodingControls -> convert_state.go)
- State change management
- Validation and sanitization
- Settings persistence
- Progress update handling
🔄 Integration Pattern
main.go Changes:
import "git.leaktechnologies.dev/stu/VideoTools/internal/ui"
// Replace giant UI block with:
if useAdvanced {
panel := ui.BuildConvertAdvancedPanel(state, src)
mainContent := container.NewVBox(panel)
} else {
panel := ui.BuildConvertSimplePanel(state, src)
mainContent := container.NewVBox(panel)
}
Module Interface:
func BuildConvertAdvancedPanel(state *appState, src *videoSource) (fyne.CanvasObject, *ConvertUIBindings)
func BuildConvertSimplePanel(state *appState, src *videoSource) (fyne.CanvasObject, *ConvertUIBindings)
func InitConvertState(state *appState, src *videoSource) *ConvertState
🎨 Benefits
- Maintainable: UI logic separated from core logic
- Testable: UI components can be unit tested independently
- Reusability: Simple/Advanced panels reused in other modules
- Clean Code: main.go becomes readable and focused
- Future-Proof: Easy to add new UI features without bloating main.go
📋 Implementation Order
- Phase 1: Create convert_types.go with shared types
- Phase 2: Extract state management into convert_state.go
- Phase 3: Build convert_advanced.go with UI logic
- Phase 4: Update main.go to use new modules
- Phase 5: Test and iterate on modular interface
🎯 Success Metrics
✅ main.go reduced by 2000+ lines
✅ UI logic properly separated and testable
✅ Clean module boundaries with no circular deps
✅ Maintain existing functionality and user experience
✅ Foundation for future UI improvements in other modules
This modularization will make the codebase much more maintainable and prepare us for advanced features in dev25.