Features:
- Add cloud sync retry service for failed report uploads
- Automatic retry loop that runs every 30 seconds
- Exponential backoff: 1 attempt per 30s with max 5 retries per report
- Reports always saved locally (IndexedDB) - cloud sync failures don't block user
- SyncInitializer component starts retry loop on app startup
Changes:
- frontend/lib/sync-retry.ts: New service for managing cloud sync retries
- retryPendingSyncs(): Attempt to sync all pending reports
- markForRetry(): Mark a report for retry
- startRetryLoop(): Start automatic retry background task
- stopRetryLoop(): Clean up retry loop on app shutdown
- getPendingSyncCount(): Get number of reports awaiting sync
- frontend/components/providers/SyncInitializer.tsx: Client component that:
- Initializes retry loop only when user is authenticated
- Cleans up on component unmount
- Logs retry service startup/shutdown
- frontend/app/layout.tsx: Add SyncInitializer to root layout
- Ensure retry loop starts automatically for authenticated users
- frontend/app/analysis/page.tsx: Improve error handling
- Log warning when cloud sync fails
- Report remains safely in IndexedDB even if cloud save fails
Impact:
- Reports never get lost even if cloud save fails temporarily
- Automatic retry ensures eventual consistency with cloud
- User experience improved: no more "report deleted" after 1 hour
- Network issues no longer result in data loss
- Addresses original issue: reports now persists locally indefinitely
Technical Design:
- Retry tracking uses in-memory Map (resets on page refresh)
- Future enhancement: could persist retry state to localStorage
- Cloud sync becomes eventual consistency rather than immediate
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Features:
- Add analysis_mode parameter (fast/deep) to AnalysisRequest
- Fast mode (15-25 min): Disables investment and risk debates (max_debate_rounds=0)
- Deep mode (60 min): Default mode with debates enabled
- Update backend TradingService to handle analysis_mode
- Add analysis_mode form field to frontend with dropdown selector
- Update TypeScript interfaces to include analysis_mode
Changes:
- backend/app/models/schemas.py: Add analysis_mode field to AnalysisRequest
- backend/app/services/trading_service.py: Handle analysis_mode in create_config()
- backend/app/api/routes.py: Pass analysis_mode parameter to run_analysis()
- frontend/components/analysis/AnalysisForm.tsx: Add analysis_mode dropdown (fast/deep)
- frontend/lib/types.ts: Add analysis_mode to AnalysisRequest interface
When users select "fast mode", the system will:
1. Skip investment debate (max_debate_rounds = 0)
2. Skip risk debate (max_risk_discuss_rounds = 0)
3. Reduce analysis time from ~60 minutes to ~15-25 minutes
4. Still run all analyst reports with proper 500-1000 word counts
5. Provide initial decision without debate refinement
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
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