@@ -296,7 +296,7 @@ describe('TeamBuilderPage', () => {
296296 await userEvent . click ( screen . getByText ( '+ Add Sub-Agent' ) ) ;
297297
298298 // Sub-agent should show structured fields
299- expect ( screen . getByPlaceholderText ( 'What does this sub-agent do? The leader uses this to decide when to invoke it. ' ) ) . toBeInTheDocument ( ) ;
299+ expect ( screen . getByPlaceholderText ( 'Short one-liner: what does this sub-agent do?' ) ) . toBeInTheDocument ( ) ;
300300 // Both leader and sub-agent have repo/skill inputs now
301301 const repoInputs = screen . getAllByPlaceholderText ( 'https://github.com/owner/repo' ) ;
302302 expect ( repoInputs . length ) . toBe ( 2 ) ; // leader + sub-agent
@@ -369,7 +369,7 @@ describe('TeamBuilderPage', () => {
369369 const allNameInputs = screen . getAllByPlaceholderText ( 'Agent name' ) ;
370370 await userEvent . type ( allNameInputs [ 1 ] , 'worker-1' ) ;
371371 await userEvent . type (
372- screen . getByPlaceholderText ( 'What does this sub-agent do? The leader uses this to decide when to invoke it. ' ) ,
372+ screen . getByPlaceholderText ( 'Short one-liner: what does this sub-agent do?' ) ,
373373 'Handles backend API tasks' ,
374374 ) ;
375375 // Use the sub-agent's repo/skill inputs (index 1, leader is index 0)
@@ -447,7 +447,7 @@ describe('TeamBuilderPage', () => {
447447 const allNameInputs = screen . getAllByPlaceholderText ( 'Agent name' ) ;
448448 await userEvent . type ( allNameInputs [ 1 ] , 'worker-1' ) ;
449449 await userEvent . type (
450- screen . getByPlaceholderText ( 'What does this sub-agent do? The leader uses this to decide when to invoke it. ' ) ,
450+ screen . getByPlaceholderText ( 'Short one-liner: what does this sub-agent do?' ) ,
451451 'A sub-agent' ,
452452 ) ;
453453 // Leave model as inherit and permission as default
@@ -494,7 +494,7 @@ describe('TeamBuilderPage', () => {
494494 const allNameInputs = screen . getAllByPlaceholderText ( 'Agent name' ) ;
495495 await userEvent . type ( allNameInputs [ 1 ] , 'my-worker' ) ;
496496 await userEvent . type (
497- screen . getByPlaceholderText ( 'What does this sub-agent do? The leader uses this to decide when to invoke it. ' ) ,
497+ screen . getByPlaceholderText ( 'Short one-liner: what does this sub-agent do?' ) ,
498498 'Builds frontend components' ,
499499 ) ;
500500 // Use sub-agent inputs (index 1, leader is index 0)
@@ -531,6 +531,94 @@ describe('TeamBuilderPage', () => {
531531 expect ( preview . textContent ) . toContain ( ' - skill_name: write' ) ;
532532 } ) ;
533533
534+ it ( 'shows sub-agent instructions as body after frontmatter in preview' , async ( ) => {
535+ renderPage ( ) ;
536+ await userEvent . type ( screen . getByPlaceholderText ( 'My Agent Team' ) , 'my-team' ) ;
537+ await userEvent . click ( screen . getByText ( 'Next' ) ) ;
538+
539+ const nameInputs = screen . getAllByPlaceholderText ( 'Agent name' ) ;
540+ await userEvent . type ( nameInputs [ 0 ] , 'leader' ) ;
541+
542+ await userEvent . click ( screen . getByText ( '+ Add Sub-Agent' ) ) ;
543+ const allNameInputs = screen . getAllByPlaceholderText ( 'Agent name' ) ;
544+ await userEvent . type ( allNameInputs [ 1 ] , 'my-worker' ) ;
545+ await userEvent . type (
546+ screen . getByPlaceholderText ( 'Short one-liner: what does this sub-agent do?' ) ,
547+ 'Runs tests' ,
548+ ) ;
549+ await userEvent . type (
550+ screen . getByPlaceholderText ( 'Detailed instructions for the sub-agent (supports Markdown)' ) ,
551+ 'You must run all unit tests before reporting results.' ,
552+ ) ;
553+
554+ await userEvent . click ( screen . getByText ( 'Next' ) ) ;
555+
556+ const preview = screen . getByTestId ( 'sub-agent-preview-my-worker' ) ;
557+ const text = preview . textContent || '' ;
558+ // Instructions should appear as body after the closing ---
559+ const lastFrontmatterClose = text . lastIndexOf ( '---' ) ;
560+ const instructionsText = text . slice ( lastFrontmatterClose + 3 ) ;
561+ expect ( instructionsText ) . toContain ( 'You must run all unit tests before reporting results.' ) ;
562+ // Description stays in frontmatter
563+ expect ( text ) . toContain ( 'description: Runs tests' ) ;
564+ } ) ;
565+
566+ it ( 'omits instructions body from preview when instructions is empty' , async ( ) => {
567+ renderPage ( ) ;
568+ await userEvent . type ( screen . getByPlaceholderText ( 'My Agent Team' ) , 'my-team' ) ;
569+ await userEvent . click ( screen . getByText ( 'Next' ) ) ;
570+
571+ const nameInputs = screen . getAllByPlaceholderText ( 'Agent name' ) ;
572+ await userEvent . type ( nameInputs [ 0 ] , 'leader' ) ;
573+
574+ await userEvent . click ( screen . getByText ( '+ Add Sub-Agent' ) ) ;
575+ const allNameInputs = screen . getAllByPlaceholderText ( 'Agent name' ) ;
576+ await userEvent . type ( allNameInputs [ 1 ] , 'my-worker' ) ;
577+ await userEvent . type (
578+ screen . getByPlaceholderText ( 'Short one-liner: what does this sub-agent do?' ) ,
579+ 'Runs tests' ,
580+ ) ;
581+ // Leave instructions empty
582+
583+ await userEvent . click ( screen . getByText ( 'Next' ) ) ;
584+
585+ const preview = screen . getByTestId ( 'sub-agent-preview-my-worker' ) ;
586+ const text = preview . textContent || '' ;
587+ // Should end with the closing --- (no body content after it)
588+ const parts = text . split ( '---' ) ;
589+ // frontmatter has opening and closing ---, so parts[2] (after second ---) should be empty or not exist
590+ const afterFrontmatter = ( parts [ 2 ] || '' ) . trim ( ) ;
591+ expect ( afterFrontmatter ) . toBe ( '' ) ;
592+ } ) ;
593+
594+ it ( 'includes sub_agent_instructions in JSON preview for workers' , async ( ) => {
595+ renderPage ( ) ;
596+ await userEvent . type ( screen . getByPlaceholderText ( 'My Agent Team' ) , 'my-team' ) ;
597+ await userEvent . click ( screen . getByText ( 'Next' ) ) ;
598+
599+ const nameInputs = screen . getAllByPlaceholderText ( 'Agent name' ) ;
600+ await userEvent . type ( nameInputs [ 0 ] , 'leader' ) ;
601+
602+ await userEvent . click ( screen . getByText ( '+ Add Sub-Agent' ) ) ;
603+ const allNameInputs = screen . getAllByPlaceholderText ( 'Agent name' ) ;
604+ await userEvent . type ( allNameInputs [ 1 ] , 'my-worker' ) ;
605+ await userEvent . type (
606+ screen . getByPlaceholderText ( 'Short one-liner: what does this sub-agent do?' ) ,
607+ 'Runs tests' ,
608+ ) ;
609+ await userEvent . type (
610+ screen . getByPlaceholderText ( 'Detailed instructions for the sub-agent (supports Markdown)' ) ,
611+ 'Run pytest with coverage.' ,
612+ ) ;
613+
614+ await userEvent . click ( screen . getByText ( 'Next' ) ) ;
615+
616+ // The JSON preview should contain sub_agent_instructions
617+ const pre = screen . getByText ( / \" n a m e \" : \" m y - t e a m \" / ) ;
618+ expect ( pre . textContent ) . toContain ( 'sub_agent_instructions' ) ;
619+ expect ( pre . textContent ) . toContain ( 'Run pytest with coverage.' ) ;
620+ } ) ;
621+
534622 it ( 'shows JSON preview in step 3 with instructions_md field' , async ( ) => {
535623 renderPage ( ) ;
536624 await userEvent . type ( screen . getByPlaceholderText ( 'My Agent Team' ) , 'my-team' ) ;
0 commit comments