@@ -125,6 +125,7 @@ describe("thread workflows", () => {
125125 it ( "sorts queued messages and gates promotion from capabilities" , ( ) => {
126126 const state = deriveThreadQueueWorkflowState ( {
127127 thread : { id : "thread" , activeProviderThreadId : "provider-thread" } ,
128+ turnItems : [ ] ,
128129 runs : [
129130 {
130131 id : "active" ,
@@ -194,11 +195,49 @@ describe("thread workflows", () => {
194195 expect ( state . canSendNow ) . toBe ( false ) ;
195196 } ) ;
196197
198+ it . each ( [
199+ [ "a message before Stop" , "Follow up" , false , false ] ,
200+ [ "a message once Stop reaches the run" , "Follow up" , true , true ] ,
201+ [ "a command once Stop reaches the run" , "/review" , true , false ] ,
202+ ] as const ) ( "gates promoting %s" , ( _ , text , stopped , blocked ) => {
203+ const state = deriveThreadQueueWorkflowState ( {
204+ thread : { id : "thread" , activeProviderThreadId : "provider-thread" } ,
205+ runs : [
206+ {
207+ id : "active" ,
208+ ordinal : 1 ,
209+ status : "running" ,
210+ userMessageId : "first" ,
211+ activeAttemptId : "attempt" ,
212+ } ,
213+ { id : "queued" , ordinal : 2 , status : "queued" , userMessageId : "second" } ,
214+ ] ,
215+ messages : [
216+ { id : "first" , text : "First" } ,
217+ { id : "second" , text, attachments : [ ] } ,
218+ ] ,
219+ providerThreads : [
220+ { id : "provider-thread" , appThreadId : "thread" , providerSessionId : "session" } ,
221+ ] ,
222+ providerSessions : [
223+ { id : "session" , status : "running" , capabilities : capabilities ( { steer : true } ) } ,
224+ ] ,
225+ providerTurns : [ { runAttemptId : "attempt" , status : "running" } ] ,
226+ turnItems : stopped ? [ { runId : "active" , type : "run_interrupt_request" } ] : [ ] ,
227+ } as never ) ;
228+
229+ expect ( state . canPromoteToSteer ) . toBe ( true ) ;
230+ expect (
231+ state . queuedRuns . map ( ( { run, stopBlocksPromotion } ) => [ run . id , stopBlocksPromotion ] ) ,
232+ ) . toEqual ( [ [ "queued" , blocked ] ] ) ;
233+ } ) ;
234+
197235 it . each ( [ "completed" , "interrupted" , "cancelled" , "failed" ] ) (
198236 "allows sending a held message after a %s turn without a live session" ,
199237 ( status ) => {
200238 const state = deriveThreadQueueWorkflowState ( {
201239 thread : { id : "thread" , activeProviderThreadId : null } ,
240+ turnItems : [ ] ,
202241 runs : [
203242 { id : "previous" , status, ordinal : 1 } ,
204243 { id : "queued" , status : "queued" , userMessageId : "message" , ordinal : 2 , queueHeld : true } ,
@@ -220,6 +259,7 @@ describe("thread workflows", () => {
220259 ( status ) => {
221260 const state = deriveThreadQueueWorkflowState ( {
222261 thread : { id : "thread" , activeProviderThreadId : null } ,
262+ turnItems : [ ] ,
223263 runs : [ { id : "active" , status, ordinal : 1 } ] ,
224264 messages : [ ] ,
225265 providerThreads : [ ] ,
@@ -234,6 +274,7 @@ describe("thread workflows", () => {
234274 it ( "offers to skip a running compaction even when the provider cannot steer" , ( ) => {
235275 const state = deriveThreadQueueWorkflowState ( {
236276 thread : { id : "thread" , activeProviderThreadId : null } ,
277+ turnItems : [ ] ,
237278 runs : [
238279 { id : "compact" , status : "running" , userMessageId : "message-compact" , ordinal : 1 } ,
239280 { id : "queued" , status : "queued" , userMessageId : "message-queued" , ordinal : 2 } ,
@@ -255,6 +296,7 @@ describe("thread workflows", () => {
255296 for ( const status of [ "queued" , "cancelled" , "starting" ] as const ) {
256297 const state = deriveThreadQueueWorkflowState ( {
257298 thread : { id : "thread" , activeProviderThreadId : null } ,
299+ turnItems : [ ] ,
258300 runs : [ { id : "held" , status, userMessageId : "message" , ordinal : 1 , queueHeld : true } ] ,
259301 messages : [ { id : "message" , text : "Saved message" } ] ,
260302 providerThreads : [ ] ,
@@ -271,6 +313,7 @@ describe("thread workflows", () => {
271313 it ( "hides automatic completion delivery from the visible queue" , ( ) => {
272314 const state = deriveThreadQueueWorkflowState ( {
273315 thread : { id : "thread" , activeProviderThreadId : null } ,
316+ turnItems : [ ] ,
274317 runs : [
275318 {
276319 id : "provider-wake" ,
@@ -328,6 +371,7 @@ describe("thread workflows", () => {
328371 it ( "removes only the promoted head from the visible queue" , ( ) => {
329372 const state = deriveThreadQueueWorkflowState ( {
330373 thread : { id : "thread" , activeProviderThreadId : "provider-thread" } ,
374+ turnItems : [ ] ,
331375 runs : [
332376 {
333377 id : "promoted" ,
@@ -366,6 +410,7 @@ describe("thread workflows", () => {
366410 ( status ) => {
367411 const state = deriveThreadQueueWorkflowState ( {
368412 thread : { id : "thread" , activeProviderThreadId : "provider-thread" } ,
413+ turnItems : [ ] ,
369414 runs : [
370415 {
371416 id : "active" ,
0 commit comments