@@ -822,24 +822,36 @@ describe("tryDispatchAcpReply", () => {
822822 path : "/tmp/recent-2.png" ,
823823 contentType : "image/png" ,
824824 sender : "Recent 2" ,
825+ sentAtMs : 1_699_999_997_000 ,
826+ messagePosition : 6 ,
827+ messageCount : 9 ,
825828 messageId : "recent-2" ,
826829 } ,
827830 {
828831 path : "/tmp/recent-3.png" ,
829832 contentType : "image/png" ,
830833 sender : "Recent 3" ,
834+ sentAtMs : 1_699_999_998_000 ,
835+ messagePosition : 7 ,
836+ messageCount : 9 ,
831837 messageId : "recent-3" ,
832838 } ,
833839 {
834840 path : "/tmp/recent-4.png" ,
835841 contentType : "image/png" ,
836842 sender : "Recent 4" ,
843+ sentAtMs : 1_699_999_999_000 ,
844+ messagePosition : 8 ,
845+ messageCount : 9 ,
837846 messageId : "recent-4" ,
838847 } ,
839848 {
840849 path : "C:\\Users\\Alice\\Pictures\\recent.png" ,
841850 contentType : "image/png" ,
842851 sender : "Windows" ,
852+ sentAtMs : 1_699_999_999_500 ,
853+ messagePosition : 9 ,
854+ messageCount : 9 ,
843855 messageId : "windows" ,
844856 } ,
845857 ] ) ;
@@ -853,13 +865,18 @@ describe("tryDispatchAcpReply", () => {
853865 path : "/tmp/secret.png" ,
854866 contentType : "image/png" ,
855867 sender : "@alice" ,
868+ sentAtMs : 1_700_000_000_000 ,
869+ messagePosition : 2 ,
870+ messageCount : 5 ,
856871 messageId : "msg-1" ,
857872 } ,
858873 ] ,
859874 } ) ;
860875
861876 expect ( text ) . toContain ( "what is this?" ) ;
862877 expect ( text ) . toContain ( "Recent image 1 from @alice, message msg-1" ) ;
878+ expect ( text ) . toContain ( "sent at 2023-11-14T22:13:20.000Z" ) ;
879+ expect ( text ) . toContain ( "thread message 2 of 5" ) ;
863880 expect ( text ) . not . toContain ( "/tmp/secret.png" ) ;
864881 } ) ;
865882
@@ -915,6 +932,9 @@ describe("tryDispatchAcpReply", () => {
915932 path : imagePath ,
916933 contentType : "image/png" ,
917934 sender : "@alice" ,
935+ sentAtMs : 1_700_000_000_000 ,
936+ messagePosition : 1 ,
937+ messageCount : 1 ,
918938 messageId : "msg-1" ,
919939 } ,
920940 ] ) ;
@@ -1159,6 +1179,9 @@ describe("tryDispatchAcpReply", () => {
11591179 path : historyPath ,
11601180 contentType : "image/png" ,
11611181 sender : "@alice" ,
1182+ sentAtMs : 1_700_000_000_000 ,
1183+ messagePosition : 1 ,
1184+ messageCount : 1 ,
11621185 messageId : "msg-history" ,
11631186 } ,
11641187 ] ) ;
@@ -1195,6 +1218,54 @@ describe("tryDispatchAcpReply", () => {
11951218 ] ) ;
11961219 } ) ;
11971220
1221+ it ( "annotates recent history images with sent time and thread position in ACP turns" , async ( ) => {
1222+ setReadyAcpResolution ( ) ;
1223+ const historyPath = "/tmp/openclaw-history-metadata.png" ;
1224+ const historyImage = Buffer . from ( "history-image" ) ;
1225+ acpAttachmentBuffers . set ( historyPath , historyImage ) ;
1226+
1227+ await runDispatch ( {
1228+ bodyForAgent : "describe current state" ,
1229+ ctxOverrides : {
1230+ Timestamp : 1_700_000_060_000 ,
1231+ InboundHistory : [
1232+ {
1233+ sender : "@alice" ,
1234+ body : "bug report" ,
1235+ timestamp : 1_699_999_980_000 ,
1236+ messageId : "msg-before" ,
1237+ } ,
1238+ {
1239+ sender : "@bob" ,
1240+ body : "<media:image>" ,
1241+ timestamp : 1_700_000_000_000 ,
1242+ messageId : "msg-history" ,
1243+ media : [ { path : historyPath , contentType : "image/png" , kind : "image" } ] ,
1244+ } ,
1245+ {
1246+ sender : "@alice" ,
1247+ body : "fixed after refresh" ,
1248+ timestamp : 1_700_000_060_000 ,
1249+ messageId : "msg-after" ,
1250+ } ,
1251+ ] ,
1252+ } ,
1253+ } ) ;
1254+
1255+ const text = String ( runTurnCall ( ) . text ) ;
1256+ expect ( text ) . toContain ( "describe current state" ) ;
1257+ expect ( text ) . toContain ( "Recent image 1 from @bob, message msg-history" ) ;
1258+ expect ( text ) . toContain ( "sent at 2023-11-14T22:13:20.000Z" ) ;
1259+ expect ( text ) . toContain ( "thread message 2 of 3" ) ;
1260+ expect ( text ) . not . toContain ( historyPath ) ;
1261+ expect ( runTurnCall ( ) . attachments ) . toEqual ( [
1262+ {
1263+ mediaType : "image/png" ,
1264+ data : historyImage . toString ( "base64" ) ,
1265+ } ,
1266+ ] ) ;
1267+ } ) ;
1268+
11981269 it ( "forwards media-understanding PDF page images alongside current image attachments" , async ( ) => {
11991270 setReadyAcpResolution ( ) ;
12001271 const currentPath = "/tmp/openclaw-current-image.png" ;
0 commit comments