66 */
77
88import { beforeEach , describe , expect , it } from "vitest" ;
9+ import { reduce } from "../../core/session-state-reducer.js" ;
910import { TeamToolCorrelationBuffer } from "../../core/team-tool-correlation.js" ;
1011import { createUnifiedMessage } from "../../core/types/unified-message.js" ;
1112import {
@@ -14,7 +15,6 @@ import {
1415 makeToolUseMessage ,
1516} from "../../testing/fixtures.js" ;
1617import type { SessionState } from "../../types/session-state.js" ;
17- import { reduce } from "./state-reducer.js" ;
1818
1919// ---------------------------------------------------------------------------
2020// Tests
@@ -85,26 +85,8 @@ describe("state-reducer team integration", () => {
8585 } ) ;
8686 } ) ;
8787
88- describe ( "backward compatibility" , ( ) => {
89- it ( "populates agents[] from team.members" , ( ) => {
90- const state : SessionState = {
91- ...makeDefaultSessionState ( ) ,
92- team : { name : "my-team" , role : "lead" , members : [ ] , tasks : [ ] } ,
93- } ;
94-
95- const s1 = reduce (
96- state ,
97- makeToolUseMessage ( "Task" , "tu-2" , { team_name : "my-team" , name : "worker-1" } ) ,
98- buffer ,
99- ) ;
100- const s2 = reduce ( s1 , makeToolResultMessage ( "tu-2" , "{}" ) , buffer ) ;
101-
102- expect ( s2 . agents ) . toEqual ( [ "worker-1" ] ) ;
103- } ) ;
104- } ) ;
105-
10688 describe ( "TeamDelete" , ( ) => {
107- it ( "removes team and resets agents to [] " , ( ) => {
89+ it ( "removes team state " , ( ) => {
10890 const state : SessionState = {
10991 ...makeDefaultSessionState ( ) ,
11092 team : {
@@ -115,14 +97,12 @@ describe("state-reducer team integration", () => {
11597 ] ,
11698 tasks : [ ] ,
11799 } ,
118- agents : [ "worker-1" ] ,
119100 } ;
120101
121102 const s1 = reduce ( state , makeToolUseMessage ( "TeamDelete" , "tu-del" , { } ) , buffer ) ;
122103 const s2 = reduce ( s1 , makeToolResultMessage ( "tu-del" , '{"success": true}' ) , buffer ) ;
123104
124105 expect ( s2 . team ) . toBeUndefined ( ) ;
125- expect ( s2 . agents ) . toEqual ( [ ] ) ;
126106 } ) ;
127107 } ) ;
128108
@@ -183,7 +163,7 @@ describe("state-reducer team integration", () => {
183163 buffer ,
184164 ) ;
185165 expect ( state . team ?. members ) . toHaveLength ( 1 ) ;
186- expect ( state . agents ) . toEqual ( [ "dev-1" ] ) ;
166+ expect ( state . team ! . members [ 0 ] ! . name ) . toBe ( "dev-1" ) ;
187167
188168 // Create task — optimistic with synthetic ID
189169 state = reduce (
@@ -206,7 +186,7 @@ describe("state-reducer team integration", () => {
206186 // Delete team — optimistic
207187 state = reduce ( state , makeToolUseMessage ( "TeamDelete" , "tu-5" , { } ) , buffer ) ;
208188 expect ( state . team ) . toBeUndefined ( ) ;
209- expect ( state . agents ) . toEqual ( [ ] ) ;
189+ expect ( state . team ) . toBeUndefined ( ) ;
210190 } ) ;
211191
212192 it ( "dual-path: tool_use + tool_result — synthetic replaced by real ID" , ( ) => {
@@ -268,7 +248,8 @@ describe("state-reducer team integration", () => {
268248 ) ;
269249 expect ( state . team ! . members ) . toHaveLength ( 1 ) ;
270250 expect ( state . team ! . members [ 0 ] ! . name ) . toBe ( "researcher" ) ;
271- expect ( state . agents ) . toEqual ( [ "researcher" ] ) ;
251+ expect ( state . team ! . members ) . toHaveLength ( 1 ) ;
252+ expect ( state . team ! . members [ 0 ] ! . name ) . toBe ( "researcher" ) ;
272253
273254 // Second member
274255 state = reduce (
@@ -277,7 +258,8 @@ describe("state-reducer team integration", () => {
277258 buffer ,
278259 ) ;
279260 expect ( state . team ! . members ) . toHaveLength ( 2 ) ;
280- expect ( state . agents ) . toEqual ( [ "researcher" , "implementer" ] ) ;
261+ expect ( state . team ! . members ) . toHaveLength ( 2 ) ;
262+ expect ( state . team ! . members . map ( ( m ) => m . name ) ) . toEqual ( [ "researcher" , "implementer" ] ) ;
281263
282264 // TaskCreate — uses synthetic ID since no tool_result
283265 state = reduce (
0 commit comments