feat: Realtime frontend using SSE#99
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an SSE-based realtime update channel from the backend to the frontend, so SWR caches can be invalidated when changes occur (including changes triggered by agents/other users).
Changes:
- Introduces backend SSE broker +
/api/v1/eventsendpoint and wires it into route registration. - Adds frontend SSE client that triggers SWR revalidation on
updateevents and connects/disconnects based on auth state. - Publishes SSE “update” events on repository create/update/delete and updates backend/frontend tests accordingly.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/lib/sse.ts | New SSE client that listens for update/unauthorized events and mutates SWR caches. |
| frontend/src/lib/repsitories.ts | Removes post-write SWR mutate calls for repositories (intended to rely on SSE updates). |
| frontend/src/lib/auth.tsx | Connects/disconnects SSE stream based on authentication state. |
| backend/internal/hub/sse/broker.go | New in-memory SSE broker with subscribe/unsubscribe/publish + DefaultBroker. |
| backend/internal/hub/sse/broker_test.go | Tests broker subscribe/unsubscribe/publish behavior and PublishUpdate helper. |
| backend/internal/hub/routes/sse.go | New SSE handler streaming broker events and emitting an unauthorized event at JWT expiry. |
| backend/internal/hub/routes/sse_test.go | Tests SSE headers, initial comment, and event delivery format. |
| backend/internal/hub/routes/repositories.go | Publishes SSE update events after repository mutations. |
| backend/internal/hub/routes/repositories_test.go | Verifies repository handlers publish SSE updates. |
| backend/internal/hub/middleware/timeout.go | Skips request timeout for SSE requests (currently based on Accept header). |
| backend/internal/hub/middleware/timeout_test.go | Adds test ensuring SSE requests skip the timeout middleware. |
| backend/internal/hub/handlers.go | Registers /events route and initializes the default SSE broker. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Type of change
Description
Makes the frontend Realtime using SSE. Has the advantage that it not only updates the data for the current user. It is also important for all changes triggered by agent and not by the user. Also SWR does not periodically refetches data by default.