# RPA Service - Code Improvements
## Critical (Fix Now)
1. **JSON Repair** - AI sometimes returns malformed JSON
- Add cleanup function before parsing
- Remove markdown, fix quotes, extract array
2. **DISPLAY Environment** - Not set in ProcessBuilder
- Add pb.environment().put("DISPLAY", ":0") to all exec calls
3. **Error Screenshots** - No capture on failure
- Take screenshot in catch block
4. **Session Cleanup** - /tmp fills up
- Delete sessions older than 24 hours
5. **Vision AI Fix** - Returns empty
- Fix Ollama API call with proper base64 encoding
## Medium Priority
6. **Retry Logic** - Single failure stops workflow
- Add configurable retry attempts
7. **App Mapping** - AI treats apps as URLs
- Map "calculator" -> "gnome-calculator"
8. **Mouse Drag/Scroll** - Missing operations
- Add drag, scroll up/down, right-click
## Quick Wins (30 min each)
- JSON repair function
- DISPLAY in ProcessBuilder
- Error screenshot
- App name mapping
- Session cleanup cron
## Estimated Time
- Critical fixes: 2-3 hours
- Medium priority: 2-3 hours
- Total: 4-6 hours