memos/server/router/api/v1/test
Cursor Agent 8c743c72ba feat: add live memo refresh via Server-Sent Events (SSE)
Implement real-time memo synchronization across all open browser instances
using Server-Sent Events (SSE). When a memo is created, updated, or
deleted on one device, all other connected clients receive the change
notification and automatically refresh their data.

Backend changes:
- Add SSEHub (pub/sub) for broadcasting memo change events to connected clients
- Add SSE HTTP endpoint at /api/v1/sse with Bearer token authentication
  (supports both Authorization header and query parameter for EventSource)
- Broadcast memo.created, memo.updated, and memo.deleted events from
  the memo service after successful operations
- Include SSEHub in APIV1Service and wire it into server initialization
- Update test helper to include SSEHub to prevent nil pointer panics

Frontend changes:
- Add useLiveMemoRefresh hook that connects to SSE endpoint using fetch
  ReadableStream (supports custom auth headers unlike native EventSource)
- Automatically invalidate React Query caches on received events:
  - memo.created: invalidate memo lists + user stats
  - memo.updated: invalidate specific memo detail + memo lists
  - memo.deleted: remove memo from cache + invalidate lists + user stats
- Exponential backoff reconnection (1s to 30s) on connection failures
- Integrate hook in AppInitializer for app-wide live refresh
- Add SSE-specific Vite dev proxy config with no timeout for streaming

Co-authored-by: milvasic <milvasic@users.noreply.github.com>
2026-02-06 21:18:21 +00:00
..
attachment_service_test.go fix: resolve golangci-lint issues 2026-01-06 20:41:24 +08:00
auth_test.go refactor: user auth improvements (#5360) 2025-12-18 18:15:51 +08:00
idp_service_test.go fix: return Unauthenticated instead of PermissionDenied on token expiration (#5454) 2026-01-08 23:21:33 +08:00
instance_admin_cache_test.go feat: update instance profile to use admin user instead of initialized flag 2026-01-28 23:27:53 +08:00
instance_service_test.go feat: update instance profile to use admin user instead of initialized flag 2026-01-28 23:27:53 +08:00
memo_attachment_service_test.go fix(security): implement security review recommendations (#5228) 2025-11-06 23:32:27 +08:00
memo_relation_service_test.go fix(security): implement security review recommendations (#5228) 2025-11-06 23:32:27 +08:00
memo_service_test.go feat: allow setting custom timestamps when creating memos and comments 2026-01-17 12:56:03 +08:00
reaction_service_test.go refactor: nest reaction resource names under memos 2025-12-30 23:29:54 +08:00
shortcut_service_test.go refactor: remove unused constants 2025-10-16 20:40:46 +08:00
test_helper.go feat: add live memo refresh via Server-Sent Events (SSE) 2026-02-06 21:18:21 +00:00
user_service_registration_test.go fix(api): correct user registration logic and first-user detection 2025-11-06 23:41:47 +08:00
user_service_stats_test.go refactor: remove unused constants 2025-10-16 20:40:46 +08:00