@@ -40,6 +40,7 @@ const mockExtensionState: {
4040 apiConfiguration : ProviderSettings
4141 currentTaskItem : { id : string } | null
4242 clineMessages : any [ ]
43+ taskHistory : any [ ]
4344} = {
4445 apiConfiguration : {
4546 apiProvider : "anthropic" ,
@@ -48,6 +49,7 @@ const mockExtensionState: {
4849 } as ProviderSettings ,
4950 currentTaskItem : { id : "test-task-id" } ,
5051 clineMessages : [ ] ,
52+ taskHistory : [ ] ,
5153}
5254
5355// Mock the ExtensionStateContext
@@ -223,6 +225,58 @@ describe("TaskHeader", () => {
223225 } )
224226 } )
225227
228+ describe ( "Delegated parent waiting-on-subtask banner" , ( ) => {
229+ beforeEach ( ( ) => {
230+ mockPostMessage . mockClear ( )
231+ } )
232+
233+ afterEach ( ( ) => {
234+ mockExtensionState . currentTaskItem = { id : "test-task-id" }
235+ mockExtensionState . taskHistory = [ ]
236+ } )
237+
238+ it ( "does not show the banner when currentTaskItem is not delegated" , ( ) => {
239+ mockExtensionState . currentTaskItem = { id : "test-task-id" , status : "active" } as any
240+ renderTaskHeader ( )
241+ expect ( screen . queryByText ( "chat:task.waitingOnSubtask" ) ) . not . toBeInTheDocument ( )
242+ } )
243+
244+ it ( "shows the banner when currentTaskItem is delegated with an awaitingChildId" , ( ) => {
245+ mockExtensionState . currentTaskItem = {
246+ id : "parent-1" ,
247+ status : "delegated" ,
248+ awaitingChildId : "child-1" ,
249+ } as any
250+ renderTaskHeader ( )
251+ expect ( screen . getByText ( "chat:task.waitingOnSubtask" ) ) . toBeInTheDocument ( )
252+ } )
253+
254+ it ( "navigates to the awaited child when the banner is clicked" , ( ) => {
255+ mockExtensionState . currentTaskItem = {
256+ id : "parent-1" ,
257+ status : "delegated" ,
258+ awaitingChildId : "child-1" ,
259+ } as any
260+ renderTaskHeader ( )
261+
262+ fireEvent . click ( screen . getByText ( "chat:task.waitingOnSubtask" ) )
263+
264+ expect ( mockPostMessage ) . toHaveBeenCalledWith ( { type : "showTaskWithId" , text : "child-1" } )
265+ } )
266+
267+ it ( "does not show an Abandon button (removed: implicit sever on re-delegation)" , ( ) => {
268+ mockExtensionState . currentTaskItem = {
269+ id : "parent-1" ,
270+ status : "delegated" ,
271+ awaitingChildId : "child-1" ,
272+ } as any
273+ renderTaskHeader ( )
274+
275+ expect ( screen . getByText ( "chat:task.waitingOnSubtask" ) ) . toBeInTheDocument ( )
276+ expect ( screen . queryByText ( "history:abandonSubtask" ) ) . not . toBeInTheDocument ( )
277+ } )
278+ } )
279+
226280 describe ( "Context window percentage calculation" , ( ) => {
227281 // The percentage should be calculated as:
228282 // contextTokens / (contextWindow - reservedForOutput) * 100
0 commit comments