@@ -144,7 +144,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
144144 }
145145 break
146146 }
147- case "session.updated" :
147+ case "session.updated" : {
148148 const result = Binary . search ( store . session , event . properties . info . id , ( s ) => s . id )
149149 if ( result . found ) {
150150 setStore ( "session" , result . index , reconcile ( event . properties . info ) )
@@ -157,6 +157,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
157157 } ) ,
158158 )
159159 break
160+ }
160161
161162 case "session.status" : {
162163 setStore ( "session_status" , event . properties . sessionID , event . properties . status )
@@ -288,6 +289,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
288289 bootstrap ( )
289290 } )
290291
292+ const fullSyncedSessions = new Set < string > ( )
291293 const result = {
292294 data : store ,
293295 set : setStore ,
@@ -314,16 +316,13 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
314316 return last . time . completed ? "idle" : "working"
315317 } ,
316318 async sync ( sessionID : string ) {
317- if ( store . message [ sessionID ] ) return
318- const now = Date . now ( )
319- console . log ( "syncing" , sessionID )
319+ if ( fullSyncedSessions . has ( sessionID ) ) return
320320 const [ session , messages , todo , diff ] = await Promise . all ( [
321321 sdk . client . session . get ( { path : { id : sessionID } , throwOnError : true } ) ,
322322 sdk . client . session . messages ( { path : { id : sessionID } , query : { limit : 100 } } ) ,
323323 sdk . client . session . todo ( { path : { id : sessionID } } ) ,
324324 sdk . client . session . diff ( { path : { id : sessionID } } ) ,
325325 ] )
326- console . log ( "fetched in " + ( Date . now ( ) - now ) , sessionID )
327326 setStore (
328327 produce ( ( draft ) => {
329328 const match = Binary . search ( draft . session , sessionID , ( s ) => s . id )
@@ -337,7 +336,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
337336 draft . session_diff [ sessionID ] = diff . data ?? [ ]
338337 } ) ,
339338 )
340- console . log ( "synced in " + ( Date . now ( ) - now ) , sessionID )
339+ fullSyncedSessions . add ( sessionID )
341340 } ,
342341 } ,
343342 bootstrap,
0 commit comments