semblance-dev/backend/app/routes
Vadym Samoilenko 1b387daacf Migrate task result delivery from WebSocket to HTTP polling
Backend:
- task_manager.py: add result/error/completed_at storage, TTL sweeper (5min), store_task_result() helper
- tasks.py: add GET /<task_id> endpoint returning stored result; cancel route stores 'cancelled' status
- __init__.py: start TTL sweeper on app startup
- All 8 bg functions: store result before emitting lightweight WS hint (no payload data)

Frontend:
- src/lib/taskPolling.ts: waitForTaskResult() — polls GET /tasks/{id} every 2s, WS hint triggers immediate poll, 5min timeout
- src/hooks/useTaskPolling.ts: drop-in replacement for useCancellableGeneration using polling
- Migrate 6 Promise-based WS listeners → waitForTaskResult() in DiscussionPanel, FocusGroupSession (×2), PersonaProfile, PersonaModificationModal, useDiscussionGuideGeneration
- Migrate 3 hook-based consumers → useTaskPolling in AIRecruiter, SyntheticUsers, BulkExportProgressModal

Fixes WS Promise leak: polling survives disconnects, background tabs, page reloads.
WS events retained as zero-payload hints for near-zero latency when connected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 16:46:58 +00:00
..
ai_personas.py Migrate task result delivery from WebSocket to HTTP polling 2026-03-23 16:46:58 +00:00
auth.py Apply Jintech security audit remediation (sprint 3) — 87/92 findings fixed 2026-03-20 12:51:18 +00:00
focus_group_ai.py Migrate task result delivery from WebSocket to HTTP polling 2026-03-23 16:46:58 +00:00
focus_groups.py Migrate task result delivery from WebSocket to HTTP polling 2026-03-23 16:46:58 +00:00
folders.py Apply Jintech security audit remediation (sprint 3) — 87/92 findings fixed 2026-03-20 12:51:18 +00:00
personas.py Migrate task result delivery from WebSocket to HTTP polling 2026-03-23 16:46:58 +00:00
tasks.py Migrate task result delivery from WebSocket to HTTP polling 2026-03-23 16:46:58 +00:00