@@ -73,9 +73,9 @@ describe("handoff endpoints shared by web and mobile", () => {
7373 } ) ;
7474} ) ;
7575
76- const startedAt = "2026-10-11T00:00:00Z" ;
7776const projection = {
78- runs : [ { ...run ( "source" , 1 , from , "source" ) , startedAt, status : "completed" } ] ,
77+ runs : [ { ...run ( "source" , 1 , from , "source" ) , startedAt : "2026-10-11T00:00:00Z" } ] ,
78+ visibleTurnItems : [ { item : { type : "user_message" } } ] ,
7979} as unknown as OrchestrationV2ThreadProjection ;
8080
8181describe ( "pending context handoff" , ( ) => {
@@ -90,65 +90,10 @@ describe("pending context handoff", () => {
9090 expect ( resolvePendingHandoff ( projection , { instanceId : from , model : "source" } , [ ] ) ) . toBeNull ( ) ;
9191 expect ( resolvePendingHandoff ( projection , { instanceId : from , model : "other" } , [ ] ) ) . toBeNull ( ) ;
9292 } ) ;
93- it ( "stays hidden until a run has history to hand off" , ( ) => {
94- const firstRun = ( status : string ) =>
95- ( {
96- runs : [ { ...run ( "source" , 1 , from , "source" ) , startedAt, status } ] ,
97- } ) as unknown as OrchestrationV2ThreadProjection ;
98- for ( const status of [ "running" , "cancelled" , "rolled_back" ] ) {
99- expect (
100- resolvePendingHandoff ( firstRun ( status ) , { instanceId : to , model : "first" } , [ ] ) ,
101- ) . toBeNull ( ) ;
102- }
103- } ) ;
104- it ( "treats a later run as history when earlier runs are outside the loaded window" , ( ) => {
105- const windowed = {
106- runs : [ { ...run ( "current" , 5 , from , "source" ) , startedAt, status : "running" } ] ,
107- } as unknown as OrchestrationV2ThreadProjection ;
108- expect ( resolvePendingHandoff ( windowed , { instanceId : to , model : "next" } , [ ] ) ?. from ) . toEqual ( [
109- { instanceId : from , model : "source" } ,
110- ] ) ;
111- // Every earlier run is loaded and none produced conversation.
112- const afterFailedStart = {
113- runs : [
114- { ...run ( "failed" , 1 , from , "source" ) , startedAt : null , status : "failed" } ,
115- { ...run ( "current" , 2 , from , "source" ) , startedAt, status : "running" } ,
116- ] ,
117- } as unknown as OrchestrationV2ThreadProjection ;
118- expect (
119- resolvePendingHandoff ( afterFailedStart , { instanceId : to , model : "next" } , [ ] ) ,
120- ) . toBeNull ( ) ;
121- } ) ;
122- it ( "hands off from the latest started run, not the latest finished one" , ( ) => {
123- const withLaterRun = ( status : string , laterStartedAt : string | null ) =>
124- ( {
125- runs : [
126- ...projection . runs ,
127- { ...run ( "later" , 2 , to , "later" ) , startedAt : laterStartedAt , status } ,
128- ] ,
129- } ) as unknown as OrchestrationV2ThreadProjection ;
130- // A running handoff on the new provider is the source for the next send.
131- expect (
132- resolvePendingHandoff (
133- withLaterRun ( "running" , startedAt ) ,
134- { instanceId : to , model : "later" } ,
135- [ ] ,
136- ) ,
137- ) . toBeNull ( ) ;
138- expect (
139- resolvePendingHandoff (
140- withLaterRun ( "running" , startedAt ) ,
141- { instanceId : from , model : "source" } ,
142- [ ] ,
143- ) ?. from ,
144- ) . toEqual ( [ { instanceId : to , model : "later" } ] ) ;
145- // A handoff that failed before starting never reached the new provider.
93+ it ( "stays hidden until the thread shows a sent message" , ( ) => {
94+ const withoutMessages = { ...projection , visibleTurnItems : [ ] } ;
14695 expect (
147- resolvePendingHandoff (
148- withLaterRun ( "failed" , null ) ,
149- { instanceId : from , model : "source" } ,
150- [ ] ,
151- ) ,
96+ resolvePendingHandoff ( withoutMessages , { instanceId : to , model : "first" } , [ ] ) ,
15297 ) . toBeNull ( ) ;
15398 } ) ;
15499 it ( "only previews a same-provider model change when it needs a fresh native thread" , ( ) => {
0 commit comments