@@ -96,6 +96,10 @@ class APIServer {
9696 if ( pathname . startsWith ( '/clients/' ) && pathname . endsWith ( '/evaluations' ) ) {
9797 const clientId = pathname . split ( '/' ) [ 2 ] ;
9898 result = this . getClientEvaluations ( clientId ) ;
99+ } else if ( pathname . startsWith ( '/clients/' ) && pathname . endsWith ( '/tabs' ) ) {
100+ // Handle dynamic client tabs route
101+ const clientId = pathname . split ( '/' ) [ 2 ] ;
102+ result = this . getClientTabsById ( clientId ) ;
99103 } else {
100104 switch ( pathname ) {
101105 case '/status' :
@@ -153,23 +157,23 @@ class APIServer {
153157
154158 getClients ( ) {
155159 const clients = this . evaluationServer . getClientManager ( ) . getAllClients ( ) ;
160+ const connectedClients = this . evaluationServer . connectedClients ;
156161
157162 return clients . map ( client => {
158- const evaluations = this . evaluationServer . getClientManager ( ) . getClientEvaluations ( client . id ) ;
159- const connection = this . evaluationServer . connectedClients . get ( client . id ) ;
163+ const tabs = this . evaluationServer . getClientManager ( ) . getClientTabs ( client . id ) ;
160164
161165 return {
162166 id : client . id ,
163167 name : client . name ,
164168 description : client . description ,
165- connected : ! ! connection ,
166- ready : connection ?. ready || false ,
167- evaluations : evaluations . map ( evaluation => ( {
168- id : evaluation . id ,
169- name : evaluation . name ,
170- tool : evaluation . tool ,
171- status : evaluation . status || 'pending' ,
172- enabled : evaluation . enabled !== false
169+ tabCount : tabs . length ,
170+ tabs : tabs . map ( tab => ( {
171+ tabId : tab . tabId ,
172+ compositeClientId : tab . compositeClientId ,
173+ connected : connectedClients . has ( tab . compositeClientId ) ,
174+ ready : connectedClients . get ( tab . compositeClientId ) ?. ready || false ,
175+ connectedAt : tab . connectedAt ,
176+ remoteAddress : tab . connection ?. remoteAddress || 'unknown'
173177 } ) )
174178 } ;
175179 } ) ;
@@ -196,6 +200,34 @@ class APIServer {
196200 } ;
197201 }
198202
203+ getClientTabsById ( clientId ) {
204+ if ( ! clientId ) {
205+ throw new Error ( 'Client ID is required' ) ;
206+ }
207+
208+ const tabs = this . evaluationServer . getClientManager ( ) . getClientTabs ( clientId ) ;
209+ const connectedClients = this . evaluationServer . connectedClients ;
210+ const client = this . evaluationServer . getClientManager ( ) . getClient ( clientId ) ;
211+
212+ if ( ! client ) {
213+ throw new Error ( `Client '${ clientId } ' not found` ) ;
214+ }
215+
216+ return {
217+ baseClientId : clientId ,
218+ clientName : client . name ,
219+ tabCount : tabs . length ,
220+ tabs : tabs . map ( tab => ( {
221+ tabId : tab . tabId ,
222+ compositeClientId : tab . compositeClientId ,
223+ connected : connectedClients . has ( tab . compositeClientId ) ,
224+ ready : connectedClients . get ( tab . compositeClientId ) ?. ready || false ,
225+ connectedAt : tab . connectedAt ,
226+ remoteAddress : tab . connection ?. remoteAddress || 'unknown'
227+ } ) )
228+ } ;
229+ }
230+
199231 async triggerEvaluation ( payload ) {
200232 const { clientId, evaluationId, runAll = false } = payload ;
201233
0 commit comments