@@ -223,6 +223,23 @@ describe('InstructionRunner command mode UI', () => {
223223 expect ( host . scheduleTurnMemoryReflection ) . toHaveBeenCalledWith ( { status : 'succeeded' } ) ;
224224 } ) ;
225225
226+ it ( 'clears sticky activity after a successful turn reaches final completion' , async ( ) => {
227+ const host = createHost ( ) ;
228+ const completeTodoActivityForSuccessfulTurn = vi . fn ( async ( ) => true ) ;
229+ const clearActivityForCompletedTurn = vi . fn ( ) ;
230+ const activityHost = host as AgentInstructionHost & {
231+ completeTodoActivityForSuccessfulTurn : ( ) => Promise < boolean > ;
232+ clearActivityForCompletedTurn : ( ) => void ;
233+ } ;
234+ activityHost . completeTodoActivityForSuccessfulTurn = completeTodoActivityForSuccessfulTurn ;
235+ activityHost . clearActivityForCompletedTurn = clearActivityForCompletedTurn ;
236+
237+ await expect ( new InstructionRunner ( activityHost ) . run ( 'finish the active task' ) ) . resolves . toBe ( true ) ;
238+
239+ expect ( completeTodoActivityForSuccessfulTurn ) . toHaveBeenCalledOnce ( ) ;
240+ expect ( clearActivityForCompletedTurn ) . toHaveBeenCalledOnce ( ) ;
241+ } ) ;
242+
226243 it ( 'keeps the Ink renderer mounted while running quality checks after an implementation turn' , async ( ) => {
227244 const host = createHost ( ) ;
228245 const inkRenderer = {
@@ -253,6 +270,10 @@ describe('InstructionRunner command mode UI', () => {
253270
254271 it ( 'marks the turn failed when project quality checks fail' , async ( ) => {
255272 const host = createHost ( ) ;
273+ const clearActivityForCompletedTurn = vi . fn ( ) ;
274+ ( host as AgentInstructionHost & {
275+ clearActivityForCompletedTurn : ( ) => void ;
276+ } ) . clearActivityForCompletedTurn = clearActivityForCompletedTurn ;
256277 host . runtime = {
257278 ...host . runtime ,
258279 options : { } ,
@@ -270,6 +291,7 @@ describe('InstructionRunner command mode UI', () => {
270291
271292 expect ( result ) . toBe ( false ) ;
272293 expect ( host . stopUI ) . toHaveBeenCalledWith ( true , 'Quality checks failed' ) ;
294+ expect ( clearActivityForCompletedTurn ) . not . toHaveBeenCalled ( ) ;
273295 expect ( host . printCompletionSummary ) . toHaveBeenCalledWith ( false , false ) ;
274296 expect ( host . scheduleTurnMemoryReflection ) . toHaveBeenCalledWith ( {
275297 status : 'failed' ,
0 commit comments