@@ -1549,6 +1549,66 @@ it.effect("shared intake preserves durable attachment bytes after a lost launch
15491549 } ) ;
15501550 yield * dispatch ;
15511551 yield * dispatch ;
1552+ const queuedProjection = yield * threads . getThreadProjection ( input . threadId ) ;
1553+ const queuedRun = queuedProjection . runs . find (
1554+ ( run ) => run . userMessageId === MessageId . make ( "intake-second" ) ,
1555+ ) ;
1556+ assert . isDefined ( queuedRun ) ;
1557+ assert . equal ( queuedRun . status , "queued" ) ;
1558+ const queuedMessage = queuedProjection . messages . find (
1559+ ( message ) => message . id === queuedRun . userMessageId ,
1560+ ) ;
1561+ assert . isDefined ( queuedMessage ) ;
1562+ const file : ChatAttachment = {
1563+ type : "file" ,
1564+ id : ChatAttachmentId . make ( createPendingAttachmentId ( "pdf" ) ) ,
1565+ name : "queued.pdf" ,
1566+ mimeType : "application/pdf" ,
1567+ sizeBytes : 4 ,
1568+ } ;
1569+ const filePath = resolveAttachmentPath ( {
1570+ attachmentsDir : config . attachmentsDir ,
1571+ attachment : file ,
1572+ } ) ;
1573+ assert . isNotNull ( filePath ) ;
1574+ yield * fs . writeFile ( filePath , new Uint8Array ( [ 5 , 6 , 7 , 8 ] ) ) ;
1575+ const edit = ThreadMessageIntake . dispatchCommand ( {
1576+ type : "queued-run.edit" ,
1577+ commandId : CommandId . make ( "intake-edit" ) ,
1578+ threadId : input . threadId ,
1579+ runId : queuedRun . id ,
1580+ text : "Edited with a file" ,
1581+ attachments : [ ...queuedMessage . attachments , file ] ,
1582+ } ) ;
1583+ yield * edit ;
1584+ yield * edit ;
1585+ const editedProjection = yield * threads . getThreadProjection ( input . threadId ) ;
1586+ const editedMessage = editedProjection . messages . find (
1587+ ( message ) => message . id === queuedRun . userMessageId ,
1588+ ) ;
1589+ assert . isDefined ( editedMessage ) ;
1590+ assert . equal ( editedMessage . attachments . length , 2 ) ;
1591+ assert . deepEqual ( editedMessage . attachments [ 0 ] , queuedMessage . attachments [ 0 ] ) ;
1592+ assert . notEqual ( editedMessage . attachments [ 1 ] ?. id , file . id ) ;
1593+ const durableFilePath = resolveAttachmentPath ( {
1594+ attachmentsDir : config . attachmentsDir ,
1595+ attachment : editedMessage . attachments [ 1 ] ! ,
1596+ } ) ;
1597+ assert . isNotNull ( durableFilePath ) ;
1598+ assert . deepEqual ( yield * fs . readFile ( durableFilePath ) , new Uint8Array ( [ 5 , 6 , 7 , 8 ] ) ) ;
1599+ assert . deepEqual ( yield * fs . readFile ( filePath ) , new Uint8Array ( [ 5 , 6 , 7 , 8 ] ) ) ;
1600+ const beforeRejectedEdit = ( yield * claimedFiles ) . length ;
1601+ const rejectedEdit = yield * ThreadMessageIntake . dispatchCommand ( {
1602+ type : "queued-run.edit" ,
1603+ commandId : CommandId . make ( "intake-edit-rejected" ) ,
1604+ threadId : input . threadId ,
1605+ runId : queuedRun . id ,
1606+ text : "" ,
1607+ attachments : [ file ] ,
1608+ } ) . pipe ( Effect . flip ) ;
1609+ assert . equal ( rejectedEdit . _tag , "OrchestratorCommandRejectedError" ) ;
1610+ assert . equal ( ( yield * claimedFiles ) . length , beforeRejectedEdit ) ;
1611+ assert . deepEqual ( yield * fs . readFile ( filePath ) , new Uint8Array ( [ 5 , 6 , 7 , 8 ] ) ) ;
15521612 const send = ThreadMessageIntake . sendToThread ( {
15531613 commandId : CommandId . make ( "intake-send" ) ,
15541614 projectId,
@@ -1562,7 +1622,7 @@ it.effect("shared intake preserves durable attachment bytes after a lost launch
15621622 } ) ;
15631623 yield * send ;
15641624 yield * send ;
1565- assert . equal ( ( yield * claimedFiles ) . length , 3 ) ;
1625+ assert . equal ( ( yield * claimedFiles ) . length , 4 ) ;
15661626 const final = yield * threads . getThreadProjection ( input . threadId ) ;
15671627 assert . equal ( final . messages . length , 3 ) ;
15681628 for ( const message of final . messages ) {
0 commit comments