@@ -10,6 +10,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
1010import {
1111 CommandId ,
1212 EnvironmentOrchestrationHttpApi ,
13+ EventId ,
1314 ProviderDriverKind ,
1415 ProviderInstanceId ,
1516 type ServerProvider ,
@@ -1071,3 +1072,96 @@ it.layer(NodeServices.layer)("thread start", (it) => {
10711072 ) ,
10721073 ) ;
10731074} ) ;
1075+
1076+ it . layer ( NodeServices . layer ) ( "thread send" , ( it ) => {
1077+ it . effect ( "sends a prompt to an existing thread and keeps its modes" , ( ) =>
1078+ withThreadStartFixture ( ( { baseDir, workspaceRoot } ) =>
1079+ Effect . gen ( function * ( ) {
1080+ yield * runCliWithRuntime ( [
1081+ "thread" ,
1082+ "start" ,
1083+ workspaceRoot ,
1084+ "Fix the flaky test" ,
1085+ "--base-dir" ,
1086+ baseDir ,
1087+ ] ) ;
1088+ const [ created ] = yield * readProjectThreads ( workspaceRoot ) ;
1089+ const engine = yield * OrchestrationEngine . OrchestrationEngineService ;
1090+ yield * engine . dispatch ( {
1091+ type : "thread.runtime-mode.set" ,
1092+ commandId : CommandId . make ( "cmd-cli-send-runtime-mode" ) ,
1093+ threadId : created ! . id ,
1094+ runtimeMode : "auto-accept-edits" ,
1095+ createdAt : DateTime . formatIso ( yield * DateTime . now ) ,
1096+ } ) ;
1097+
1098+ const { output } = yield * captureStdout (
1099+ runCli ( [
1100+ "thread" ,
1101+ "send" ,
1102+ created ! . id ,
1103+ "Now add a regression test" ,
1104+ "--json" ,
1105+ "--base-dir" ,
1106+ baseDir ,
1107+ ] ) ,
1108+ ) ;
1109+
1110+ const [ thread ] = yield * readProjectThreads ( workspaceRoot ) ;
1111+ assert . equal ( thread ! . runtimeMode , "auto-accept-edits" ) ;
1112+ assert . deepEqual ( thread ! . modelSelection , created ! . modelSelection ) ;
1113+ assert . sameMembers (
1114+ thread ! . messages . map ( ( message ) => message . text ) ,
1115+ [ "Fix the flaky test" , "Now add a regression test" ] ,
1116+ ) ;
1117+ assert . include ( output , `"threadId":"${ created ! . id } "` ) ;
1118+ } ) ,
1119+ ) ,
1120+ ) ;
1121+
1122+ it . effect ( "refuses threads awaiting approval and unknown threads" , ( ) =>
1123+ withThreadStartFixture ( ( { baseDir, workspaceRoot } ) =>
1124+ Effect . gen ( function * ( ) {
1125+ yield * runCliWithRuntime ( [
1126+ "thread" ,
1127+ "start" ,
1128+ workspaceRoot ,
1129+ "Fix the flaky test" ,
1130+ "--base-dir" ,
1131+ baseDir ,
1132+ ] ) ;
1133+ const [ created ] = yield * readProjectThreads ( workspaceRoot ) ;
1134+ const engine = yield * OrchestrationEngine . OrchestrationEngineService ;
1135+ const now = DateTime . formatIso ( yield * DateTime . now ) ;
1136+ yield * engine . dispatch ( {
1137+ type : "thread.activity.append" ,
1138+ commandId : CommandId . make ( "cmd-cli-send-approval" ) ,
1139+ threadId : created ! . id ,
1140+ activity : {
1141+ id : EventId . make ( "activity-cli-send-approval" ) ,
1142+ tone : "approval" ,
1143+ kind : "approval.requested" ,
1144+ summary : "Run command" ,
1145+ payload : { requestId : "req-cli-send" } ,
1146+ turnId : null ,
1147+ createdAt : now ,
1148+ } ,
1149+ createdAt : now ,
1150+ } ) ;
1151+
1152+ const send = ( threadId : string ) =>
1153+ runCliWithRuntime ( [ "thread" , "send" , threadId , "Keep going" , "--base-dir" , baseDir ] ) . pipe (
1154+ Effect . flip ,
1155+ ) ;
1156+
1157+ assert . equal (
1158+ ( yield * send ( created ! . id ) ) . message ,
1159+ "Thread awaits approval or answer. Resolve in T3 Code." ,
1160+ ) ;
1161+ assert . equal ( ( yield * send ( "thread-missing" ) ) . message , "Thread 'thread-missing' not found." ) ;
1162+ const [ thread ] = yield * readProjectThreads ( workspaceRoot ) ;
1163+ assert . lengthOf ( thread ! . messages , 1 ) ;
1164+ } ) ,
1165+ ) ,
1166+ ) ;
1167+ } ) ;
0 commit comments