feat(chat): client + react entries — session client, reconnecting stream, useChatSession
Chunk B of plans/chat-v3-pane-mount.md. ./client: reconnecting WS consumer (envelope-parsed frames, cursor resume, reset-keeps-connection, injectable backoff) + sessionClient over a structural ChatTransport typed via type-only ChatRouterInputs/Outputs — no runtime dep on chat-runtime (tsconfig-paths type bridge; avoids the turbo package cycle) and no @trpc/server in the client package. ./react: useChatSession (seed→reduce→live tail, outbox clientId-echo clearing, one commit per frame with RN-safe scheduler fallback, loadOlder with older-merges-under semantics, auto-resync on reset) + useTimeline/useApprovals. 32 tests incl. hook-level reconnect parity against a real runtime over an in-memory socket pair.
https://claude.ai/code/session_01XRFCEPsfmJHu2SenDKYJ2h
Summary by cubic
Adds a reconnecting session stream, a typed session client, and React hooks for chat sessions. This delivers reliable live updates with resume, pagination, and a simple API for apps.
-
New Features
@superset/chatclientsubscribeToSession: reconnecting stream with since-cursor resume, reset handling, and configurable exponential backoff.createSessionClient: typed transport overChatRouterInputs/Outputs(no runtime dep), prompt dedupe bycommandId, item pagination, approvals/mode/turn controls, and multiple managed streams.
@superset/chatReactuseChatSession: seeds viagetSession+getItems, batches live frames into one commit per animation frame (RN-safe timeout fallback), clears outbox on clientId echo, loads older pages, and auto-resyncs on stream reset.useTimelineanduseApprovals: memoized derived views of the session snapshot.
- Testing utilities
- In-memory stream server with drop/reconnect controls, manual wait scheduler, and DOM registrator for hook tests. 32 tests cover reconnect, pagination, and hook parity.
-
Refactors
@superset/chat-runtime: adds./testingexport for cross-package tests and exposesChatRouterInputs/Outputsfor client typing.@superset/chat: adds./clientand./reactentry points; uses a tsconfig type-only bridge to avoid a package cycle; no@trpc/serverin the client.
Summary by CodeRabbit
-
New Features
- Added a typed chat session client for creating sessions, sending prompts, pagination, approvals, mode changes, and lifecycle management.
- Added reliable live session subscriptions with reconnect support and stream recovery.
- Added React hooks for managing chat sessions, pending approvals, and conversation timelines.
- Added public package entry points for client and React integrations.
- Added reusable testing utilities and public runtime testing exports.
-
Tests
- Added comprehensive coverage for streaming, reconnection, pagination, approvals, timelines, and session workflows.