# Critical Fixes for Timeframe and Screenshot Issues ## Issues Identified from Screenshot: 1. **Interval Input Bug**: "4" was being entered instead of "240" for 4h timeframe 2. **Wrong Screenshot Area**: Captured DIY module instead of main chart 3. **Keyboard Mapping Error**: `'240': '4'` was causing 4h to be interpreted as 4min ## Fixes Applied: ### 1. Fixed Timeframe Input Logic **Problem**: The keyboard mapping had `'240': '4'` which made 4h requests press "4" key (interpreted as 4 minutes) **Solution**: - Removed problematic keyboard mappings for hour-based timeframes - Made custom interval input the PRIORITY fallback for hour timeframes - Only use keyboard shortcuts for simple minute timeframes (1, 5, 15, 30) ```typescript // OLD (problematic): const keyMap = { '240': '4', // This caused 4h → 4min! '60': '1' // This caused 1h → 1min! } // NEW (fixed): const keyMap = { '1': '1', '5': '5', '15': '1', '30': '3', '1D': 'D' // REMOVED hour mappings that caused confusion } ``` ### 2. Enhanced Custom Interval Input - Added comprehensive selectors for TradingView interval dialog - Improved input handling: select all → delete → type correct value - Added better error handling and logging **Key Improvement**: Now enters "240" for 4h instead of "4" ### 3. Fixed Screenshot Area Selection **Problem**: Screenshot captured random areas (DIY module) instead of chart **Solution**: - Added chart area detection with multiple selectors - Targets specific chart container elements - Falls back to full page if chart area not found ```typescript const chartSelectors = [ '#tv-chart-container', '.layout__area--center', '.chart-container-border', '.tv-chart-area-container' // ... more selectors ] ``` ## Expected Results: ✅ **4h request** → Enters "240" in interval dialog → 4-hour chart ✅ **Screenshot** → Captures main chart area, not random elements ✅ **Debugging** → Better logging to track what's happening ## Test Instructions: 1. Request 4h timeframe 2. Verify interval dialog shows "240" (not "4") 3. Confirm chart switches to 4-hour timeframe 4. Check screenshot captures main chart area