@@ -106,9 +106,11 @@ module.exports = (app) => {
106106assert ( ctx . request ) ;
107107console . log ( "ws message" , message . toString ( ) ) ;
108108try {
109- //TODO
110- let { command, action, options= { } } = JSON . parse ( message . toString ( ) ) ;
111- action && ( command = action ) ;
109+ const {
110+ command,
111+ options= { } ,
112+ data= { } ,
113+ } = JSON . parse ( message . toString ( ) ) ;
112114switch ( command ) {
113115case "join" :
114116console . log ( "join" , options . room ) ;
@@ -122,7 +124,33 @@ module.exports = (app) => {
122124}
123125producerMap . set ( ws , options . room ) ;
124126break ;
125- case "list" :
127+ case "list" :{
128+ const { error} = data ;
129+ const room = producerMap . get ( ws ) ;
130+ if ( room ) {
131+ const [ org_id , project_id , workspace_id , run_id ] =
132+ room . split ( "/" ) ;
133+ console . log (
134+ "list" ,
135+ org_id ,
136+ project_id ,
137+ workspace_id ,
138+ run_id ,
139+ ", error: " ,
140+ error
141+ ) ;
142+ models . run . update ( {
143+ where :{ org_id, project_id, workspace_id, run_id} ,
144+ data :{
145+ status :error ?"error" :"completed" ,
146+ updated_at :new Date ( ) . toUTCString ( ) ,
147+ } ,
148+ } ) ;
149+ } else {
150+ console . error ( "no room for list command" ) ;
151+ }
152+ }
153+ // fall through
126154case "logs" :
127155const room = producerMap . get ( ws ) ;
128156if ( room ) {