Add: Unified job stream hooks for @perstack/react#463
Merged
Conversation
Add two streaming hooks to @perstack/react that encapsulate SSE connection lifecycle management with a framework-agnostic StreamConnector interface: - useJobStream: Single job streaming with full activity timeline via useRun() - useJobStreams: Multi-job dashboard streaming with per-job latest activity Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move connection lifecycle logic (async iteration, abort check, AbortError filtering) into utils/stream.ts so both hooks share a single implementation instead of duplicating the pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
useJobStreamhook for single-job streaming with full activity timeline (wrapsuseRun())useJobStreamshook for multi-job dashboard streaming with per-job latest activity trackingStreamConnectortype as a framework-agnostic interface for SSE connection injectionDesign
Both hooks share the
StreamConnectortype, which keeps@perstack/reactindependent of@perstack/api-client:useJobStream: ComposesuseRun()internally, manages a single SSE connection lifecycle (AbortController, error handling, connect/disconnect)useJobStreams: Manages dynamic concurrent SSE connections usingprocessRunEventToActivityfor lightweight per-job activity processingTest plan
useJobStream: 10 tests covering connection lifecycle, event processing, error handling, abort handling, and cleanupuseJobStreams: 10 tests covering dynamic add/remove, per-job activity tracking, error isolation, and unmount cleanup🤖 Generated with Claude Code