@@ -1153,7 +1153,7 @@ it.effect("starts a steer that missed the turn on the saved next-turn selection"
11531153 ) ,
11541154) ;
11551155
1156- it . effect . each ( [ "complete" , "stop-before-decline" , "stop-after-decline" ] as const ) (
1156+ it . effect . each ( [ "complete" , "stop-before-decline" , "stop-after-decline" , "queued-model" ] as const ) (
11571157 "persists a declined steer without blocking the worker: %s" ,
11581158 ( timing ) =>
11591159 Effect . scoped (
@@ -1194,6 +1194,21 @@ it.effect.each(["complete", "stop-before-decline", "stop-after-decline"] as cons
11941194 } )
11951195 . pipe ( Effect . asVoid , Effect . orDie ) ;
11961196 if ( timing === "stop-before-decline" ) beforeDecline = stop ;
1197+ const steerSelection = { ...runSelection , model : "steer-model" } ;
1198+ if ( timing === "queued-model" ) {
1199+ yield * orchestrator . dispatch ( {
1200+ type : "message.dispatch" ,
1201+ commandId : CommandId . make ( "queued-model" ) ,
1202+ threadId,
1203+ messageId : MessageId . make ( "message:queued-model" ) ,
1204+ text : "already queued" ,
1205+ attachments : [ ] ,
1206+ modelSelection : composerSelection ,
1207+ dispatchMode : { type : "queue_after_active" } ,
1208+ createdBy : "user" ,
1209+ creationSource : "web" ,
1210+ } ) ;
1211+ }
11971212 const messageId = MessageId . make ( "message:declined" ) ;
11981213 yield * orchestrator . dispatch ( {
11991214 type : "message.dispatch" ,
@@ -1202,13 +1217,16 @@ it.effect.each(["complete", "stop-before-decline", "stop-after-decline"] as cons
12021217 messageId,
12031218 text : "follow up" ,
12041219 attachments : [ ] ,
1220+ ...( timing === "queued-model" ? { modelSelection : steerSelection } : { } ) ,
12051221 dispatchMode : { type : "steer_active" , targetRunId : first . runId } ,
12061222 createdBy : "user" ,
12071223 creationSource : "web" ,
12081224 } ) ;
12091225 yield * worker . drain ( ) ;
12101226 const pending = yield * orchestrator . getThreadProjection ( threadId ) ;
1211- const queued = pending . runs . find ( ( run ) => run . id !== first . runId ) ;
1227+ const queued = pending . runs . find (
1228+ ( run ) => run . userMessageId === messageId && run . id !== first . runId ,
1229+ ) ;
12121230 const effects = yield * ( yield * EffectOutbox . EffectOutboxV2 ) . listByCommandId (
12131231 CommandId . make ( "steer" ) ,
12141232 ) ;
@@ -1223,6 +1241,10 @@ it.effect.each(["complete", "stop-before-decline", "stop-after-decline"] as cons
12231241 }
12241242 assert . equal ( queued ?. status , "queued" ) ;
12251243 assert . equal ( queued ?. userMessageId , messageId ) ;
1244+ if ( timing === "queued-model" ) {
1245+ assert . deepEqual ( queued ?. modelSelection , steerSelection ) ;
1246+ return ;
1247+ }
12261248 if ( timing === "stop-after-decline" ) {
12271249 yield * stop ;
12281250 yield * worker . drain ( ) ;
0 commit comments