Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

07 — Component Library (WS / Realtime Module)

Components the realtime layer introduces. Base primitives come from 00-shared/03; these are module-level compositions with the wire contract baked in. Shared design-system mapping lives in 11 and 00-shared/04.


1. AppRealtimeStatusDot

FieldDetail
PurposeOne-glance connection state, non-interactive by default
Propsstate: RealtimeState (idle/connecting/connected/reconnecting/offline/error-auth)
Anatomy8 dp circle + optional 12 dp label
Colorsfrom 00-shared/02 status tokens (success/amber-warning/danger/neutral)
Behaviorpulse animation while connecting/reconnecting (m-fast); tooltip "Live" when connected
a11ysemantic label from state text; never color-only (00-shared/09)
Wire-upconsumes RealtimeBloc state (13); no direct socket access

2. AppConnectionBanner

FieldDetail
PurposeNon-blocking offline/error surface under the app bar
Propsstate (offline / error-auth), onRetry (optional)
Anatomy1-line banner: icon + message + optional "Retry" text button
Statesoffline: "Live updates paused"; error-auth: "Session expired — reconnecting"
Motionslide-in m-fast; never blocks scroll content (fixed slot)
a11ylive-region announcement on show/hide
Rulesshown only in offline/error-auth; hidden otherwise (no persistent banner)

3. AppLiveList

FieldDetail
PurposeWrapper that merges socket events into an existing paginated list (06 §3.1)
Propsitems, eventStream (filtered), entityIdOf(item), onRowEvent(item, event), refetch
Behaviorrow-level in-place update + flash; miss → optional insert or bounded refetch; sort/aggregate locally
Limitsbounded refetch: 1 / 5 s / screen; never mutates during user edit (10 §2)
Reusewraps 00-shared/03 list + skeleton primitives
Testingpure Dart logic (match/insert/refetch) — unit-testable without socket

4. AppNotificationToast

FieldDetail
PurposeTransient high-priority notification surface
Propsevent (envelope), onTap
AnatomyAppSnackbar-based: icon + title + entity snippet; queueing; 5 s auto-dismiss
Dedupby eventType+entityId within 30 s window (multi-tab, 02)
Rulesnever steals focus; max 1 visible

5. AppEventLog (debug, proposed)

FieldDetail
PurposeMonospace stream of received envelopes for the admin debug view (06 §5)
Propsevents (last 500), filter
Anatomyrows: `HH:mm:ss.SSS
Behaviorpause render (not capture); clear; substring filter
Rulesdebug-only; guarded by admin route gate

6. RealtimeClient (non-visual core)

FieldDetail
PurposeOwns the socket lifecycle, handshake, room membership, event stream (13)
APIconnect(token), disconnect(), subscribe(room), unsubscribe(room), Stream<WsEnvelope> events, RealtimeState state
Contracthandshake token → auth.token or query.token (ws.gateway.ts:37-39); subscribe message = room string (ws.gateway.ts:63-68)
Securitytoken from secure store only; never logged (15 §8)
Reuseone instance per app run (singleton scope), injected via DI

Composition rules

  • Visual components never import the socket library; they consume RealtimeClient/ RealtimeBloc streams only.
  • AppLiveList is the only list component aware of events; plain lists stay REST-only.
  • All components work with zero server changes — they render the existing bridge envelope (ws-bridge.service.ts:17-21).