@@ -449,6 +449,54 @@ describe("useChatTitleGenerator", () => {
449449 expect ( mockGenerateTitle ) . toHaveBeenCalledTimes ( 1 ) ;
450450 } ) ;
451451
452+ it ( "does not rewrite an unlocked real title from later prompts, but still refreshes the summary" , async ( ) => {
453+ // Auto-generated at creation: real title, title_manually_set false.
454+ const unlockedTask = createTask ( {
455+ title : "Fix login bug" ,
456+ description : "the login page 500s for SSO users" ,
457+ } ) ;
458+ cacheTask ( unlockedTask ) ;
459+ mockGenerateTitle . mockResolvedValue ( {
460+ title : "Discuss deploy schedule" ,
461+ summary : "User is coordinating a deploy" ,
462+ } ) ;
463+ mockPrompts . value = Array . from ( { length : 8 } , ( _ , i ) => `prompt ${ i } ` ) ;
464+
465+ renderHook ( ( ) => useChatTitleGenerator ( unlockedTask ) ) ;
466+
467+ await waitFor ( ( ) => {
468+ expect ( mockGenerateTitle ) . toHaveBeenCalledTimes ( 1 ) ;
469+ } ) ;
470+ await waitFor ( ( ) => {
471+ expect ( mockSessionStoreSetters . updateSession ) . toHaveBeenCalledWith (
472+ "run-1" ,
473+ { conversationSummary : "User is coordinating a deploy" } ,
474+ ) ;
475+ } ) ;
476+ expect ( mockUpdateTask ) . not . toHaveBeenCalled ( ) ;
477+ } ) ;
478+
479+ it ( "replaces a placeholder title from later prompts" , async ( ) => {
480+ const placeholderTask = createTask ( {
481+ title : "Attached files: pasted-text.txt" ,
482+ description : "Attached files: pasted-text.txt" ,
483+ } ) ;
484+ cacheTask ( placeholderTask ) ;
485+ mockGenerateTitle . mockResolvedValue ( {
486+ title : "Refactor auth flow" ,
487+ summary : "" ,
488+ } ) ;
489+ mockPrompts . value = Array . from ( { length : 8 } , ( _ , i ) => `prompt ${ i } ` ) ;
490+
491+ renderHook ( ( ) => useChatTitleGenerator ( placeholderTask ) ) ;
492+
493+ await waitFor ( ( ) => {
494+ expect ( mockUpdateTask ) . toHaveBeenCalledWith ( TASK_ID , {
495+ title : "Refactor auth flow" ,
496+ } ) ;
497+ } ) ;
498+ } ) ;
499+
452500 it ( "skips catch-up generation when the title is locked and a summary exists" , async ( ) => {
453501 const lockedTask = createTask ( {
454502 title : "Custom auth title" ,
0 commit comments