Commit Graph

23 Commits

Author SHA1 Message Date
MarkLo127 42b5b8dab8 Implement Plan C3: Cloud Sync Retry with Local Caching
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>
2026-03-12 21:35:29 +08:00
MarkLo127 4f219bd74e Fix: Resolve GraphRecursionError by passing config params to agents and increasing recursion_limit to 200
- Pass max_debate_rounds and max_risk_discuss_rounds from config to ConditionalLogic
- Pass max_recur_limit from config to Propagator
- Increase default recursion_limit from 100 to 200 in default_config.py
- Increase Propagator default max_recur_limit from 100 to 200

Also includes earlier fixes:
- Add 365-day minimum date range validation to get_stock_data tool
- Update market analyst prompt to specify 1-year data requirement
- Initialize all debate state fields (bull_history, bear_history, judge_decision, etc.)
- Add report completeness logging in trading_service.py
- Add debug logging in frontend results page

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-12 17:17:23 +08:00
MarkLo127 071c4bf5cf 2026-03-10 17:58:38 +08:00
MarkLo127 92c2a84b83 2026-03-10 17:00:32 +08:00
MarkLo127 d58e80a962 2026-01-27 13:22:52 +08:00
MarkLo 16e513a921 新增英文語系支援 2025-12-24 01:20:33 +08:00
MarkLo 4bbeaa8e18 2025-12-17 05:41:30 +08:00
MarkLo 47f04a6ff7 2025-12-16 00:45:07 +08:00
MarkLo cf4aaa09b1 feat: auto-save reports + fix PDF download from history
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
2025-12-14 03:21:59 +08:00
MarkLo 5d3751602e 2025-12-13 06:00:19 +08:00
MarkLo 4269fdec26 2025-12-12 19:01:49 +08:00
MarkLo c2b8706bf2 2025-12-07 17:13:57 +08:00
MarkLo 34dc5b0f87 2025-12-02 23:03:41 +08:00
MarkLo e1eaf964f6 2025-12-01 01:54:44 +08:00
MarkLo ba4cc41a5a 2025-11-29 00:19:17 +08:00
MarkLo e3a3d09cff 2025-11-25 02:33:08 +08:00
MarkLo 63ac0668ac 2025-11-25 02:13:52 +08:00
MarkLo 894b3e96e0 2025-11-24 02:28:19 +08:00
MarkLo e898ebb2b5 2025-11-21 05:12:02 +08:00
MarkLo 8ef63d715c 2025-11-21 04:43:46 +08:00
MarkLo cc47085cd4 2025-11-21 03:29:20 +08:00
MarkLo 44fd92850d 2025-11-20 23:19:22 +08:00
MarkLo 2872f18b47 2025-11-20 21:56:47 +08:00