@@ -678,11 +678,24 @@ describe("ProviderCommandReactor", () => {
678678 } ) ,
679679 ) ;
680680
681- it ( "generates a thread title on the first turn " , async ( ) => {
681+ it ( "retries thread title generation after a transient failure " , async ( ) => {
682682 const harness = await createHarness ( ) ;
683683 const now = "2026-01-01T00:00:00.000Z" ;
684684 const seededTitle = "Please investigate reconnect failures after restar..." ;
685- harness . generateThreadTitle . mockReturnValue ( Effect . succeed ( { title : "Generated title" } ) ) ;
685+ let attempts = 0 ;
686+ harness . generateThreadTitle . mockReturnValue (
687+ Effect . suspend ( ( ) => {
688+ attempts += 1 ;
689+ return attempts === 1
690+ ? Effect . fail (
691+ new TextGenerationError ( {
692+ operation : "generateThreadTitle" ,
693+ detail : "Claude CLI request timed out." ,
694+ } ) ,
695+ )
696+ : Effect . succeed ( { title : "Generated title" } ) ;
697+ } ) ,
698+ ) ;
686699
687700 await Effect . runPromise (
688701 harness . engine . dispatch ( {
@@ -726,64 +739,9 @@ describe("ProviderCommandReactor", () => {
726739 const readModel = await harness . readModel ( ) ;
727740 const thread = readModel . threads . find ( ( entry ) => entry . id === ThreadId . make ( "thread-1" ) ) ;
728741 expect ( thread ?. title ) . toBe ( "Generated title" ) ;
742+ expect ( attempts ) . toBe ( 2 ) ;
729743 } ) ;
730744
731- effectIt . effect ( "retries thread title generation after a transient failure" , ( ) =>
732- Effect . gen ( function * ( ) {
733- const harness = yield * Effect . promise ( ( ) => createHarness ( ) ) ;
734- const now = "2026-01-01T00:00:00.000Z" ;
735- const seededTitle = "Please investigate reconnect failures after restar..." ;
736- let attempts = 0 ;
737- harness . generateThreadTitle . mockReturnValue (
738- Effect . suspend ( ( ) => {
739- attempts += 1 ;
740- return attempts === 1
741- ? Effect . fail (
742- new TextGenerationError ( {
743- operation : "generateThreadTitle" ,
744- detail : "Claude CLI request timed out." ,
745- } ) ,
746- )
747- : Effect . succeed ( { title : "Generated title" } ) ;
748- } ) ,
749- ) ;
750-
751- yield * harness . engine . dispatch ( {
752- type : "thread.meta.update" ,
753- commandId : CommandId . make ( "cmd-thread-title-retry-seed" ) ,
754- threadId : ThreadId . make ( "thread-1" ) ,
755- title : seededTitle ,
756- } ) ;
757-
758- yield * harness . engine . dispatch ( {
759- type : "thread.turn.start" ,
760- commandId : CommandId . make ( "cmd-turn-start-title-retry" ) ,
761- threadId : ThreadId . make ( "thread-1" ) ,
762- message : {
763- messageId : asMessageId ( "user-message-title-retry" ) ,
764- role : "user" ,
765- text : "Please investigate reconnect failures after restarting the session." ,
766- attachments : [ ] ,
767- } ,
768- titleSeed : seededTitle ,
769- interactionMode : DEFAULT_PROVIDER_INTERACTION_MODE ,
770- runtimeMode : "approval-required" ,
771- createdAt : now ,
772- } ) ;
773-
774- yield * Effect . promise ( ( ) =>
775- waitFor ( async ( ) => {
776- const readModel = await harness . readModel ( ) ;
777- return (
778- readModel . threads . find ( ( entry ) => entry . id === ThreadId . make ( "thread-1" ) ) ?. title ===
779- "Generated title"
780- ) ;
781- } ) ,
782- ) ;
783- expect ( attempts ) . toBe ( 2 ) ;
784- } ) ,
785- ) ;
786-
787745 it ( "regenerates a thread title from the current conversation" , async ( ) => {
788746 const harness = await createHarness ( ) ;
789747 const now = "2026-01-01T00:00:00.000Z" ;
0 commit comments