Conversation
Adds a complete Server-Sent Events (SSE) infrastructure for handling real-time updates and activity notifications. Includes: - SSEClient wrapper with automatic reconnection and event parsing - Singleton SSEService managing global state, cross-tab coordination, and cache invalidation - Vue composable useSSE for easy component integration - Session lifecycle integration to start/stop SSE based on auth state - Comprehensive unit tests for the client - Proxy configuration for the /events/stream endpoint
Remove duplicated BroadcastManager/TabCoordinator instances by merging SSEService into CacheSyncService. Extract CacheInvalidator for SRP. Fix proxy rewrite, duplicate listener, and sort bugs.
- only start SSE for client accounts (account.kind === 'client') - wire afterLogin into accountGuard to trigger SSE after session load - close existing EventSource before creating new connection - add 60s inactivity watchdog to detect silent connection deaths - add console.log for cache invalidation debugging
Remove client-side inactivity timeout mechanism from SSE client and implement reconnection logic in cache-sync-service when server closes the connection. This provides more reliable handling of server-initiated disconnects by responding to explicit close events rather than relying on inactivity detection. - Add scheduleReconnect and clearClosedReconnectTimeout methods - Remove inactivityTimeout option and related methods from SSE client - Add tests for ping and closed event handling
Update invalidate method to extract and validate structured fields (resourceType, activityType, resourceId) from SSE activity events. Add validation logging for missing required fields and improve log output with structured event information.
…ution Add parent-based cache invalidation that resolves query keys from SSE activity events using structured fields (resource.type, parent.type, parent.id). This enables targeted cache invalidation for nested resources. Changes: - Add getKeysForResource and getParentKeys functions for structured invalidation - Create factory functions for mapping configurations (simple, detail, multi-key) - Expand PARENT_TYPE_TO_QUERY_KEY mapping for 30+ parent resource types - Implement invalidation priority: parent-based > resource-based > description fallback - Add ping event handler to maintain SSE connection - Update tests for new invalidation strategies
Adds a comprehensive guide for the SSE (Server-Sent Events) implementation used for real-time synchronization and automatic cache invalidation. Covers core components (SSEClient, CacheSyncService, CacheInvalidator), multi-tab coordination, invalidation mapping strategies, the useSSE composable, and testing instructions.
Contributor
There was a problem hiding this comment.
Acho que subiu sem querer esse arquivo
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.
Jira Tasks
Description
Adds a complete Server-Sent Events (SSE) infrastructure for handling real-time updates and activity notifications in the Console.
ENG-36794: SSE Connection Implementation
Implements a real-time SSE connection with the endpoint:
Headers:
Connection Event:
Requirements Implemented:
ENG-36795: SSE Message Processing
Implements parsing and processing of SSE messages received by the Console.
Activity Event Payload:
{ "type": "activity", "data": { "user": { "email": "user@example.com", "name": "User Name" }, "activity_type": "created | edited | deleted", "resource": { "type": "edge_application", "name": "Application Name", "id": null }, "timestamp": "2026-03-03T19:58:56Z", "description": "Application Name was created", "metadata": { "id": 1772562194, "name": "Application Name", "last_editor": "user@example.com", "last_modified": "2026-03-03T19:58:55.548847Z", ... } } }Processing Capabilities:
event.datafrom received messagesactivitydata.resource.type- resource typedata.activity_type- action typedata.metadata.id- resource identifierENG-36796: TanStack Query Cache Integration
Integra eventos activity recebidos via SSE com o mecanismo de cache do TanStack Query, permitindo que o Console atualize automaticamente os dados exibidos.
A invalidação deve ocorrer com base nas informações do payload.
Campos utilizados:
data.resource.typedata.activity_typedata.metadata.idRegras de invalidação:
Isso garante atualização automática de:
Smart Cache Invalidation
Parent-Based Resolution Strategy
Implements intelligent cache invalidation that resolves Vue Query keys from SSE activity events using structured fields (
resource.type,parent.type,parent.id). This enables targeted cache invalidation for nested resources.Invalidation Priority:
parent.type+parent.id(most specific)resource.type+metadata.idKey Features:
getKeysForResource()- Maps resource types to query keysgetParentKeys()- Resolves parent-based cache keys for nested resourcesPARENT_TYPE_TO_QUERY_KEYmapping for 30+ parent resource typesExample Flow:
Supported Parent Types:
['edge-application', id]['edge-function', id]['database', id]['domain', id]Components Added
src/services/v2/base/sse/sse-client.jssrc/services/v2/base/sse/sse-service.jssrc/composables/useSSE.jssrc/services/v2/base/auth/sessionManager.jssrc/tests/services/v2/base/sse/sse-client.test.jsvite.config.js/events/streamendpointAcceptance Criteria
ENG-36794
connectedevent is received after connectionENG-36795
activityevents are correctly parsedresource.type)activity_type)metadata.id)ENG-36796
createdinvalida queries do recursoeditedinvalida queries do recursodeletedinvalida queries do recursoDefinition of Done
ENG-36794
ENG-36795
ENG-36796
Technical Details
How to Test
yarn dev/events/streamis establishedconnectedevent is received withclient_idyarn test:unit:headless --run src/tests/services/v2/base/sse/sse-client.test.js