Added task recovery system that allows users to recover and save
analysis results even if they accidentally close the page:
1. New pending-task.ts utility:
- Saves task info to localStorage when analysis starts
- Clears after task completes/fails
- 24-hour expiry for old tasks
2. PendingTaskRecovery component:
- Shows on history page if pending task found
- Polls API for task status
- Saves result to IndexedDB + cloud upon completion
3. Updated useAnalysis hook:
- Tracks pending tasks in localStorage
- Clears on completion/failure
Now users visiting /history after closing the page during analysis
will see a prompt to recover and save their completed report.
1. Auto-save reports when page closes:
- Added beforeunload handler to auto-save analysis to history
- Saves to local IndexedDB and cloud (if authenticated)
- Prevents data loss if user accidentally closes the page
2. Fix PDF download from history page:
- Made taskId optional in DownloadReports component
- Added direct mode: can pass reports data directly
- Updated backend to support both task-based and direct-data modes
- History reports now have download PDF option available
- Add matplotlib for chart generation
- Implement _calculate_heikin_ashi() for HA OHLC calculation
- Implement _generate_price_chart() to create candlestick + volume charts
- Charts are generated as PNG images and embedded in PDF
- Fallback to text summary if chart generation fails
- First page now shows visual charts like the web interface
- Page 1 now shows price statistics (growth rate, duration, start/end prices)
- Page 1 also includes last 5 trading days data
- Page 2+ contains the original analyst insights
- Updates pdf_generator.py, download_service.py, and routes.py