@@ -235,21 +235,21 @@ describe('server-v2 /api/v1/sessions/{sid}/tasks', () => {
235235 expect ( byId . get ( questionId ) ?. parent_tool_call_id ) . toBeUndefined ( ) ;
236236 } ) ;
237237
238- it ( 'reports run_in_background false for a foreground (non- detached) task ' , async ( ) => {
238+ it ( 'reports run_in_background from the task detached flag ' , async ( ) => {
239239 const id = await createSession ( ) ;
240240 const tasks = await mainAgentTasks ( id ) ;
241+ const backgroundId = tasks . registerTask ( fakeTask ( 'agent' ) ) ;
241242 const foregroundId = tasks . registerTask ( fakeTask ( 'agent' ) , { detached : false } ) ;
242243 await flush ( ) ;
243244
244- const listed = await getJson < ListWire > ( `/api/v1/sessions/${ id } /tasks` ) ;
245- expect ( listed . body . code ) . toBe ( 0 ) ;
246- const entry = listed . body . data . items . find ( ( t ) => t . id === foregroundId ) ;
247- expect ( entry ) . toMatchObject ( { kind : 'subagent' , status : 'running' } ) ;
248- expect ( entry ?. run_in_background ) . toBe ( false ) ;
245+ const { body } = await getJson < ListWire > ( `/api/v1/sessions/${ id } /tasks` ) ;
246+ expect ( body . code ) . toBe ( 0 ) ;
247+ const byId = new Map ( body . data . items . map ( ( t ) => [ t . id , t ] ) ) ;
248+ expect ( byId . get ( backgroundId ) ?. run_in_background ) . toBe ( true ) ;
249+ expect ( byId . get ( foregroundId ) ?. run_in_background ) . toBe ( false ) ;
249250
250- const got = await getJson < TaskWire > ( `/api/v1/sessions/${ id } /tasks/${ foregroundId } ` ) ;
251- expect ( got . body . code ) . toBe ( 0 ) ;
252- expect ( got . body . data . run_in_background ) . toBe ( false ) ;
251+ const single = await getJson < TaskWire > ( `/api/v1/sessions/${ id } /tasks/${ foregroundId } ` ) ;
252+ expect ( single . body . data . run_in_background ) . toBe ( false ) ;
253253 } ) ;
254254
255255 it ( 'filters the list by wire status' , async ( ) => {
0 commit comments