@@ -116,6 +116,97 @@ describe('resolveSubagentLabel', () => {
116116 expect ( label ! . endsWith ( '…' ) ) . toBe ( true ) ;
117117 } ) ;
118118
119+ test ( 'resolves labels for workflow (ultra mode) agent paths' , async ( ) => {
120+ const workflowDir = join ( projectDir , parentSessionId , 'subagents' , 'workflows' , 'wf_2ca7ddd8-324' ) ;
121+ await mkdir ( workflowDir , { recursive : true } ) ;
122+ const workflowAgentPath = join ( workflowDir , 'agent-a4f3fba033446cc4f.jsonl' ) ;
123+ await writeFile ( workflowAgentPath , jsonline ( {
124+ type : 'user' ,
125+ message : { role : 'user' , content : 'You are a senior engineer writing a plan. Read the spec first.' } ,
126+ } ) ) ;
127+
128+ const label = await resolveSubagentLabel ( workflowAgentPath ) ;
129+ expect ( label ) . toBe ( 'You are a senior engineer writing a plan' ) ;
130+ } ) ;
131+
132+ test ( 'workflow agents still match parent Agent invocations when present' , async ( ) => {
133+ const workflowDir = join ( projectDir , parentSessionId , 'subagents' , 'workflows' , 'wf_deadbeef-123' ) ;
134+ await mkdir ( workflowDir , { recursive : true } ) ;
135+ const workflowAgentPath = join ( workflowDir , 'agent-bb11cc22dd33ee44f.jsonl' ) ;
136+ await writeFile ( workflowAgentPath , jsonline ( {
137+ type : 'user' ,
138+ message : { role : 'user' , content : 'Audit module Y' } ,
139+ } ) ) ;
140+ await writeFile ( parentPath , jsonline ( {
141+ type : 'assistant' ,
142+ message : {
143+ role : 'assistant' ,
144+ content : [ {
145+ type : 'tool_use' ,
146+ name : 'Agent' ,
147+ input : { description : 'Audit Y' , prompt : 'Audit module Y' } ,
148+ } ] ,
149+ } ,
150+ } ) ) ;
151+
152+ const label = await resolveSubagentLabel ( workflowAgentPath ) ;
153+ expect ( label ) . toBe ( 'Audit Y' ) ;
154+ } ) ;
155+
156+ test ( 'prefers description from the sibling meta.json over everything' , async ( ) => {
157+ await writeFile ( subagentPath , jsonline ( {
158+ type : 'user' ,
159+ message : { role : 'user' , content : 'Run a thorough audit of X' } ,
160+ } ) ) ;
161+ await writeFile ( subagentPath . replace ( '.jsonl' , '.meta.json' ) , JSON . stringify ( {
162+ agentType : 'Explore' ,
163+ description : 'Verify Claude Code lifecycle hooks' ,
164+ toolUseId : 'toolu_123' ,
165+ } ) ) ;
166+ await writeFile ( parentPath , jsonline ( {
167+ type : 'assistant' ,
168+ message : {
169+ role : 'assistant' ,
170+ content : [ {
171+ type : 'tool_use' ,
172+ name : 'Agent' ,
173+ input : { description : 'Audit X for regressions' , prompt : 'Run a thorough audit of X' } ,
174+ } ] ,
175+ } ,
176+ } ) ) ;
177+
178+ const label = await resolveSubagentLabel ( subagentPath ) ;
179+ expect ( label ) . toBe ( 'Verify Claude Code lifecycle hooks' ) ;
180+ } ) ;
181+
182+ test ( 'combines meta agentType with the prompt first sentence for workflow agents' , async ( ) => {
183+ const workflowDir = join ( projectDir , parentSessionId , 'subagents' , 'workflows' , 'wf_0f3513d0-3cc' ) ;
184+ await mkdir ( workflowDir , { recursive : true } ) ;
185+ const workflowAgentPath = join ( workflowDir , 'agent-a2282a1d2c6a1932f.jsonl' ) ;
186+ await writeFile ( workflowAgentPath , jsonline ( {
187+ type : 'user' ,
188+ message : { role : 'user' , content : 'Esplora il backend Laravel. Rispondi con snippet.' } ,
189+ } ) ) ;
190+ await writeFile ( workflowAgentPath . replace ( '.jsonl' , '.meta.json' ) , JSON . stringify ( { agentType : 'Explore' } ) ) ;
191+
192+ const label = await resolveSubagentLabel ( workflowAgentPath ) ;
193+ expect ( label ) . toBe ( 'Explore: Esplora il backend Laravel' ) ;
194+ } ) ;
195+
196+ test ( 'drops the generic workflow-subagent agentType from meta.json' , async ( ) => {
197+ const workflowDir = join ( projectDir , parentSessionId , 'subagents' , 'workflows' , 'wf_2ca7ddd8-324' ) ;
198+ await mkdir ( workflowDir , { recursive : true } ) ;
199+ const workflowAgentPath = join ( workflowDir , 'agent-afa8678eb14a03831.jsonl' ) ;
200+ await writeFile ( workflowAgentPath , jsonline ( {
201+ type : 'user' ,
202+ message : { role : 'user' , content : 'Write the plan. Then stop.' } ,
203+ } ) ) ;
204+ await writeFile ( workflowAgentPath . replace ( '.jsonl' , '.meta.json' ) , JSON . stringify ( { agentType : 'workflow-subagent' } ) ) ;
205+
206+ const label = await resolveSubagentLabel ( workflowAgentPath ) ;
207+ expect ( label ) . toBe ( 'Write the plan' ) ;
208+ } ) ;
209+
119210 test ( 'ignores parent Agent invocations with non-matching prompt' , async ( ) => {
120211 await writeFile ( subagentPath , jsonline ( {
121212 type : 'user' ,
0 commit comments