@@ -13,7 +13,11 @@ import { useSnackbar } from "notistack";
1313
1414import { useASAuthorizationStatus } from "../../hooks/useIsAuthorized" ;
1515import { getMessageFromEvent } from "../../protobuf/protobuf" ;
16- import { eventStreamEnabledAtom , useEventStream } from "../../state/eventStream" ;
16+ import {
17+ eventStreamEnabledAtom ,
18+ useEventStream ,
19+ webSocketStatusAtom ,
20+ } from "../../state/eventStream" ;
1721import { useUnreadEventCount } from "../../state/notifications" ;
1822import { EventMessage } from "../eventMessages/EventMessage" ;
1923import { useIsEventStreamInstalled } from "./useIsEventStreamInstalled" ;
@@ -26,6 +30,10 @@ dayjs.extend(utc);
2630const buildWebSocketUrl = ( location : string ) : string => {
2731 const url = new URL ( location ) ;
2832 url . protocol = "wss:" ;
33+
34+ // Add ordinal parameter to get all historical messages
35+ url . searchParams . set ( "stream_from_ordinal" , "0" ) ;
36+
2937 return url . toString ( ) ;
3038} ;
3139
@@ -49,6 +57,7 @@ export const EventStream = () => {
4957 } ) ;
5058
5159 const [ eventStreamEnabled ] = useAtom ( eventStreamEnabledAtom ) ;
60+ const [ , setWebSocketStatus ] = useAtom ( webSocketStatusAtom ) ;
5261
5362 const handleWebSocketMessage = useCallback (
5463 ( event : MessageEvent ) => {
@@ -101,7 +110,7 @@ export const EventStream = () => {
101110 // Build WebSocket URL
102111 const wsUrl = eventStreamEnabled && asRole && location ? buildWebSocketUrl ( location ) : null ;
103112
104- useWebSocket ( wsUrl , {
113+ const { readyState } = useWebSocket ( wsUrl , {
105114 onOpen : handleWebSocketOpen ,
106115 onClose : handleWebSocketClose ,
107116 onError : handleWebSocketError ,
@@ -112,6 +121,11 @@ export const EventStream = () => {
112121 reconnectInterval : 3000 ,
113122 } ) ;
114123
124+ // Expose connection status for status indicator
125+ useEffect ( ( ) => {
126+ setWebSocketStatus ( readyState ) ;
127+ } , [ readyState , setWebSocketStatus ] ) ;
128+
115129 useEffect ( ( ) => {
116130 if ( asRole && data ) {
117131 setLocation ( data ) ;
0 commit comments