Repository navigation
fix(frontend): subscribe event stream directories after connecting instead of in the URL - #499
Merged
Merged
Conversation
…stead of in the URL
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
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.
User description
Summary
The browser's event stream no longer sends its subscribed directories in the URL. It opens
/api/sse/streamwithout a query and subscribes every directory throughPOST /api/sse/subscribeonce theconnectedevent provides a client id.Problem
buildUrl()added every subscribed directory to?directories=. With repos plus every linked server's project directories, the URL grew to about 16 KB (221 directories) and Cloudflare rejected it with 431. An open stream kept working, but every reconnect (focus, resize, network change) failed, so the session page stayed on "Reconnecting… live updates paused" and the backend had no browser clients.Change
buildUrl()returns the bare stream URL.connect()marks all current directories as pending, so the first connection and every reconnect (after an error, a stall, an explicit reconnect or a bfcache restore) resubscribe them through the existing subscribe request. The backend replays state for subscribed directories the same way it did for directories in the URL.disconnectConnectionOnly.?directories=for older clients.Tests
directoriesparameter and that the subscribe request carries every directory, including on a bfcache reconnect.PR Type
Bug fix
Description
Move directory subscriptions out of SSE stream URL
Subscribe all directories via
POST /api/sse/subscribeon connectResubscribe directories on every reconnect, including bfcache restores
Add tests covering bare URL and reconnect resubscription
Diagram Walkthrough
File Walkthrough
openCodeEventStream.ts
Strip directories from stream URL and resubscribe on connectfrontend/src/lib/opencode-event-stream/openCodeEventStream.ts
buildUrl()now returns the bare/api/sse/streamURL without adirectoriesquery parameter.connect()seedspendingDirectoriesfrom all currentdirectoryRefCountsso the first connection and every reconnect resubscribe through the
existing subscribe flow.
disconnectConnectionOnly.openCodeEventStream.test.ts
Update stream tests for post-connect directory subscriptionsfrontend/src/lib/opencode-event-stream/__tests__/openCodeEventStream.test.ts
directoriesparameter and that a subscribe request carries every directory.
followed by resubscription for the new client id.
all current directories.