@@ -1420,6 +1420,100 @@ it.effect("only the caller that prepared a pending upload can discard it", () =>
14201420 ) ,
14211421) ;
14221422
1423+ const sendTargetId = ThreadId . make ( "send-target-thread" ) ;
1424+ const sendCommand = {
1425+ commandId : CommandId . make ( "mcp-core-send" ) ,
1426+ commandType : "message.dispatch" ,
1427+ } ;
1428+
1429+ it . effect . each ( [
1430+ {
1431+ outcome : "says that the missing workspace could not be recreated" ,
1432+ refusal : new ThreadManagement . ThreadManagementWorktreeRestoreError ( {
1433+ threadId : sendTargetId ,
1434+ cause : new Error ( "The branch no longer exists." ) ,
1435+ } ) ,
1436+ reply : {
1437+ _tag : "OrchestratorMcpFailure" ,
1438+ code : "thread_not_sendable" ,
1439+ message :
1440+ "Couldn't recreate the missing workspace of thread send-target-thread, so the message was not sent. The branch no longer exists." ,
1441+ } ,
1442+ } ,
1443+ {
1444+ outcome : "passes on the text reason of an orchestrator rejection" ,
1445+ refusal : new OrchestratorCommandRejectedError ( {
1446+ ...sendCommand ,
1447+ cause : "Thread send-target-thread is deleted." ,
1448+ } ) ,
1449+ reply : {
1450+ _tag : "OrchestratorMcpFailure" ,
1451+ code : "orchestration_error" ,
1452+ message : "Thread send-target-thread is deleted." ,
1453+ } ,
1454+ } ,
1455+ {
1456+ outcome : "keeps an internal dispatch cause private" ,
1457+ refusal : new OrchestratorDispatchError ( {
1458+ ...sendCommand ,
1459+ cause : new Error ( "private-storage-path" ) ,
1460+ } ) ,
1461+ reply : {
1462+ _tag : "OrchestratorMcpFailure" ,
1463+ code : "orchestration_error" ,
1464+ message : "The operation could not be completed." ,
1465+ } ,
1466+ } ,
1467+ ] ) ( "t3_thread_send_attachments $outcome" , ( { refusal, reply } ) => {
1468+ const stored = ChatImageAttachment . make ( {
1469+ type : "image" ,
1470+ id : "owned-image" ,
1471+ name : "original.png" ,
1472+ mimeType : "image/png" ,
1473+ sizeBytes : 12 ,
1474+ } ) ;
1475+ return Effect . gen ( function * ( ) {
1476+ const server = yield * McpServer . McpServer ;
1477+ const result = yield * server
1478+ . callTool ( {
1479+ name : "t3_thread_send_attachments" ,
1480+ arguments : { threadId : sendTargetId , message : "See the file." , attachments : [ stored ] } ,
1481+ } )
1482+ . pipe (
1483+ Effect . provideService ( McpInvocationContext . McpInvocationContext , scope ) ,
1484+ Effect . provideService ( McpSchema . McpServerClient , client ) ,
1485+ ) ;
1486+ expect ( declaredFailure ( result ) ) . toEqual ( reply ) ;
1487+ } ) . pipe (
1488+ Effect . provide (
1489+ McpHttpServer . layerAttachmentToolkit . pipe (
1490+ Layer . provideMerge ( McpHttpServer . layerInProcessMcpServer ) ,
1491+ Layer . provide (
1492+ Layer . mock ( ThreadManagement . ThreadManagementService ) ( {
1493+ getThreadShell : ( id ) => Effect . succeed ( McpToolAccessTestkit . liveThreadShell ( id ) ) ,
1494+ getProjectThreadRecords : ( ) =>
1495+ Effect . succeed ( {
1496+ ...McpToolAccessTestkit . idleThreadProjection (
1497+ McpToolAccessTestkit . liveThreadShell ( sendTargetId ) ,
1498+ ) ,
1499+ messages : [ { attachments : [ stored ] } ] ,
1500+ } as never ) ,
1501+ sendToThread : ( ) => Effect . fail ( refusal ) ,
1502+ } ) ,
1503+ ) ,
1504+ Layer . provide ( AssetSigner . layer . pipe ( Layer . provideMerge ( ServerSecretStore . layer ) ) ) ,
1505+ Layer . provide ( ServerConfig . layerTest ( process . cwd ( ) , { prefix : "t3-mcp-attachment-" } ) ) ,
1506+ Layer . provide (
1507+ DocumentText . layer . pipe (
1508+ Layer . provideMerge ( Layer . mergeAll ( NodeServices . layer , NodeCrypto . layer ) ) ,
1509+ ) ,
1510+ ) ,
1511+ Layer . provide ( NodeCrypto . layer ) ,
1512+ ) ,
1513+ ) ,
1514+ ) ;
1515+ } ) ;
1516+
14231517it . effect (
14241518 "t3_thread_list settled:false with an empty statuses list lists the unsettled threads" ,
14251519 ( ) => {
0 commit comments