diff --git a/packages/ui/src/sync/sync-context.tsx b/packages/ui/src/sync/sync-context.tsx index 4eab7650..3e614210 100644 --- a/packages/ui/src/sync/sync-context.tsx +++ b/packages/ui/src/sync/sync-context.tsx @@ -248,6 +248,7 @@ async function materializeSessionFromServer( store: StoreApi, options?: SessionMaterializationRequest & { isStale?: () => boolean }, ) { + const statusBeforeMaterialization = store.getState().session_status?.[sessionID] syncDebug.recovery.materializing({ reason: options?.reason ?? "ensure-session-messages", directory, @@ -282,11 +283,15 @@ async function materializeSessionFromServer( info: stripMessageDiffSnapshots(record.info), parts: record.parts ?? [], })), - { skipPartTypes: RECONNECT_SKIP_PARTS }, - ) - return { message: materialized.message, part: materialized.part } - }) -} + { skipPartTypes: RECONNECT_SKIP_PARTS }, + ) + return { message: materialized.message, part: materialized.part } + }) + + if (statusBeforeMaterialization && statusBeforeMaterialization.type !== "idle" && !options?.isStale?.()) { + await resyncDirectorySessionStatuses(directory, store, [sessionID], "authoritative") + } +} // Module-level refs for notification viewed check. // Used to determine if user is currently viewing the session when a notification arrives.