feat(hooks): real-time task updates with SSE fallback polling (#233)#440
Open
Shikhar-404exe wants to merge 1 commit into
Open
feat(hooks): real-time task updates with SSE fallback polling (#233)#440Shikhar-404exe wants to merge 1 commit into
Shikhar-404exe wants to merge 1 commit into
Conversation
…#233) - useTaskSubscription hook with EventSource SSE, reconnect with exponential backoff, polling fallback after max retries - Deduplicates identical status values and output chunks - TaskDetails.tsx refactored to use the hook, removed inline SSE logic - 12 hook tests: SSE events, dedup, reconnect, polling, terminal stop, cleanup - reconnectAttemptRef reset only on successful open (not on reconnect call)
utksh1
requested changes
May 31, 2026
Owner
utksh1
left a comment
There was a problem hiding this comment.
Thanks for extracting the task subscription hook. This needs one correctness fix before merge: deduplicating output by identical chunk content can drop legitimate repeated scanner output lines. Please preserve output stream order exactly, only dedupe status/phase if needed, and add a regression where two identical output chunks are both appended.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary #233
Adds a reusable
useTaskSubscriptionhook that provides real-time task status and outputupdates via Server-Sent Events (SSE), with automatic polling fallback when the SSE connection
drops. Replaces the inline
EventSourcelogic inTaskDetails.tsx.Changes
New:
useTaskSubscriptionhook (frontend/src/hooks/useTaskSubscription.ts)GET /api/v1/task/{task_id}/streamviaEventSourcestatusandoutputevents, deduplicating identical valuesthen falls back to polling
getTaskStatus()at a configurable intervalcompleted/failed/cancelled): cleans up EventSource, timers, and polling{ isConnected, isPolling, error }for UI indicatorsRefactored:
TaskDetails.tsxEventSourcesetup removed; replaced withuseTaskSubscriptionloadTask()is called on mount and when terminal status arrivesTests (
useTaskSubscription.test.ts)Key design decisions
reconnectAttemptRefis only reset ononopen(successful connection), not insideconnectSSE(), so consecutive reconnect failures properly accumulate toward the max limitonStatusRef,onOutputRef) avoid stale closurescleanupRefgate prevents race conditions during teardownsetIntervalwith cleanup checks both before and after the async fetch