SSE client cleanup: layered abstractions + tests#9260
Draft
ericpgreen2 wants to merge 2 commits intoericgreen/cloud-editing-mvpfrom
Draft
SSE client cleanup: layered abstractions + tests#9260ericpgreen2 wants to merge 2 commits intoericgreen/cloud-editing-mvpfrom
ericpgreen2 wants to merge 2 commits intoericgreen/cloud-editing-mvpfrom
Conversation
Layered abstractions, per-mount watcher instances, and JWT-refresh hook for long-lived streams in the cloud editor.
New `web-common/src/runtime-client/sse/` directory with one concern per module: - `sse-protocol.ts` — pure SSE parser (`readSSEStream`). - `sse-fetch-client.ts` — fetch + abort transport, delegates parsing. - `sse-connection.ts` — reconnect, backoff, stable-threshold, status store. Renamed from `SSEConnectionManager`. Auto-close methods kept as thin deprecation shims (removed once consumers migrate). - `sse-lifecycle.ts` — new, optional. Visibility/focus + idle pausing via an injectable signal source. Ships `LIFECYCLE_PRESETS`. - `sse-subscriber.ts` — new, typed decoder registry over an `SSEConnection`. Normalizes untagged frames to `"message"` per the SSE spec. Adds an `onBeforeReconnect` hook on `SSEConnection` so long-lived streams can refresh auth before each retry; hook rejections count as failed attempts and walk status to CLOSED. `createEventBinding` helper unifies the event-emitter boilerplate both `SSEFetchClient` and `SSEConnection` were duplicating. Old-path files (`sse-fetch-client.ts`, `sse-connection-manager.ts`) remain as re-export shims so existing consumers compile unchanged. 45 new unit tests cover the parser, fetch client, reconnect logic, lifecycle, and subscriber.
8 tasks
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.
Refactors the SSE client stack in
web-common/src/runtime-client/into discrete layers so JSON parsing, reconnect, lifecycle policy, and typed event routing each live in one place. MigratesFileAndResourceWatcher,Conversation, andProjectLogsPageonto the new layers, drops thefileAndResourceWatchersingleton in favor of per-mount instances, and adds anonBeforeReconnecthook so the cloud editor can refresh its JWT before long-lived stream reconnects..claude/plans/i-want-to-create-lovely-rabbit.mdericgreen/cloud-editing-mvpChecklist:
Developed in collaboration with Claude Code