Skip to content

Add: Unified job stream hooks for @perstack/react#463

Merged
FL4TLiN3 merged 6 commits intomainfrom
feat/unified-job-stream-hooks
Feb 9, 2026
Merged

Add: Unified job stream hooks for @perstack/react#463
FL4TLiN3 merged 6 commits intomainfrom
feat/unified-job-stream-hooks

Conversation

@FL4TLiN3
Copy link
Contributor

@FL4TLiN3 FL4TLiN3 commented Feb 9, 2026

Summary

  • Add useJobStream hook for single-job streaming with full activity timeline (wraps useRun())
  • Add useJobStreams hook for multi-job dashboard streaming with per-job latest activity tracking
  • Introduce StreamConnector type as a framework-agnostic interface for SSE connection injection
  • Export all new hooks and types from package index

Design

Both hooks share the StreamConnector type, which keeps @perstack/react independent of @perstack/api-client:

type StreamConnector = (jobId: string, signal: AbortSignal) => Promise<AsyncIterable<PerstackEvent>>
  • useJobStream: Composes useRun() internally, manages a single SSE connection lifecycle (AbortController, error handling, connect/disconnect)
  • useJobStreams: Manages dynamic concurrent SSE connections using processRunEventToActivity for lightweight per-job activity processing

Test plan

  • useJobStream: 10 tests covering connection lifecycle, event processing, error handling, abort handling, and cleanup
  • useJobStreams: 10 tests covering dynamic add/remove, per-job activity tracking, error isolation, and unmount cleanup
  • All 78 existing tests continue to pass
  • Typecheck passes
  • Build succeeds

🤖 Generated with Claude Code

FL4TLiN3 and others added 6 commits February 9, 2026 03:34
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>
@FL4TLiN3 FL4TLiN3 enabled auto-merge (squash) February 9, 2026 06:10
@FL4TLiN3 FL4TLiN3 merged commit b3c234e into main Feb 9, 2026
9 checks passed
@FL4TLiN3 FL4TLiN3 mentioned this pull request Feb 9, 2026
@FL4TLiN3 FL4TLiN3 deleted the feat/unified-job-stream-hooks branch February 25, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant