Skip to content

feat: Realtime frontend using SSE#99

Merged
timokoessler merged 3 commits into
mainfrom
feature/live-events
Apr 19, 2026
Merged

feat: Realtime frontend using SSE#99
timokoessler merged 3 commits into
mainfrom
feature/live-events

Conversation

@timokoessler

@timokoessler timokoessler commented Apr 19, 2026

Copy link
Copy Markdown
Member

Type of change

  • 🐛 Bug fix
  • 🚀 New feature
  • ❓ Other (please specify)

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/events endpoint and wires it into route registration.
  • Adds frontend SSE client that triggers SWR revalidation on update events 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.

Comment thread backend/internal/hub/routes/sse.go
Comment thread backend/internal/hub/routes/repositories.go
Comment thread frontend/src/lib/sse.ts Outdated
Comment thread frontend/src/lib/sse.ts Outdated
Comment thread frontend/src/lib/auth.tsx
Comment thread frontend/src/lib/repsitories.ts
Comment thread backend/internal/hub/middleware/timeout.go
Comment thread backend/internal/hub/routes/sse.go
@codecov

codecov Bot commented Apr 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.08333% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/internal/hub/routes/sse.go 51.21% 15 Missing and 5 partials ⚠️
backend/internal/hub/sse/broker.go 94.44% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@timokoessler timokoessler marked this pull request as ready for review April 19, 2026 15:43
@timokoessler timokoessler enabled auto-merge (squash) April 19, 2026 15:44
@timokoessler timokoessler requested a review from alex289 April 19, 2026 15:44

@alex289 alex289 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool

@timokoessler timokoessler merged commit 87f4c7a into main Apr 19, 2026
8 checks passed
@timokoessler timokoessler deleted the feature/live-events branch April 19, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants