@@ -800,6 +800,7 @@ CancellationToken ct
800800 Message = message ,
801801 SecondsSinceSent = 0 ,
802802 MessageId = sessionMsgId ,
803+ SentAtUtc = now ,
803804 }
804805 ) ;
805806
@@ -857,6 +858,7 @@ public async Task ReceiveMessageAsync(
857858 Message = messageText ,
858859 SecondsSinceSent = secondsSinceSent ,
859860 MessageId = sessionMsgId ,
861+ SentAtUtc = DateTime . UtcNow . AddSeconds ( - secondsSinceSent ) ,
860862 }
861863 ) ;
862864
@@ -911,7 +913,22 @@ CancellationToken ct
911913 }
912914
913915 // Return up to pageSize entries, newest first (reverse order from the end)
914- return Task . FromResult ( result . Reverse ( ) . Take ( pageSize ) . Reverse ( ) . ToList ( ) ) ;
916+ // Recompute SecondsSinceSent based on actual SentAtUtc so timestamps are accurate
917+ // when the client fetches history later (not frozen at the value from creation time).
918+ var now = DateTime . UtcNow ;
919+ return Task . FromResult (
920+ result
921+ . Reverse ( )
922+ . Take ( pageSize )
923+ . Reverse ( )
924+ . Select ( e =>
925+ e with
926+ {
927+ SecondsSinceSent = Math . Max ( 0 , ( int ) ( now - e . SentAtUtc ) . TotalSeconds ) ,
928+ }
929+ )
930+ . ToList ( )
931+ ) ;
915932 }
916933
917934 /// <summary>
@@ -952,6 +969,7 @@ public async Task DeliverOfflineMessagesAsync(CancellationToken ct)
952969 Message = msg . Message ,
953970 SecondsSinceSent = secondsSince ,
954971 MessageId = sessionMsgId ,
972+ SentAtUtc = msg . Timestamp ,
955973 }
956974 ) ;
957975
0 commit comments