agentgui 1.0.151 → 1.0.152

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -544,12 +544,13 @@ class AgentGUIClient {
544
544
  }
545
545
 
546
546
  scrollToBottom() {
547
- const scrollContainer = document.getElementById('output-scroll');
548
- if (scrollContainer) {
549
- requestAnimationFrame(() => {
550
- scrollContainer.scrollTop = scrollContainer.scrollHeight;
551
- });
552
- }
547
+ if (this._scrollRafPending) return;
548
+ this._scrollRafPending = true;
549
+ requestAnimationFrame(() => {
550
+ this._scrollRafPending = false;
551
+ const scrollContainer = document.getElementById('output-scroll');
552
+ if (scrollContainer) scrollContainer.scrollTop = scrollContainer.scrollHeight;
553
+ });
553
554
  }
554
555
 
555
556
  handleStreamingError(data) {
@@ -137,26 +137,23 @@ class WebSocketManager {
137
137
  */
138
138
  onMessage(event) {
139
139
  try {
140
- const data = JSON.parse(event.data);
141
- this.stats.totalMessagesReceived++;
142
-
143
- // Handle pong response
144
- if (data.type === 'pong') {
145
- const requestId = data.requestId;
146
- if (requestId && this.requestMap.has(requestId)) {
147
- const request = this.requestMap.get(requestId);
148
- request.resolve({ latency: Date.now() - request.sentTime });
149
- this.requestMap.delete(requestId);
140
+ const parsed = JSON.parse(event.data);
141
+ const messages = Array.isArray(parsed) ? parsed : [parsed];
142
+ this.stats.totalMessagesReceived += messages.length;
143
+
144
+ for (const data of messages) {
145
+ if (data.type === 'pong') {
146
+ const requestId = data.requestId;
147
+ if (requestId && this.requestMap.has(requestId)) {
148
+ const request = this.requestMap.get(requestId);
149
+ request.resolve({ latency: Date.now() - request.sentTime });
150
+ this.requestMap.delete(requestId);
151
+ }
152
+ continue;
150
153
  }
151
- return;
152
- }
153
-
154
- // Route message to listeners
155
- this.emit('message', data);
156
154
 
157
- // Route by type
158
- if (data.type) {
159
- this.emit(`message:${data.type}`, data);
155
+ this.emit('message', data);
156
+ if (data.type) this.emit(`message:${data.type}`, data);
160
157
  }
161
158
  } catch (error) {
162
159
  console.error('WebSocket message parse error:', error);
@@ -234,15 +231,7 @@ class WebSocketManager {
234
231
  * Start heartbeat/keepalive
235
232
  */
236
233
  startHeartbeat() {
237
- if (this.heartbeatTimer) {
238
- clearTimeout(this.heartbeatTimer);
239
- }
240
-
241
- this.heartbeatTimer = setInterval(() => {
242
- if (this.isConnected) {
243
- this.ping();
244
- }
245
- }, this.config.heartbeatInterval);
234
+ if (this.heartbeatTimer) clearTimeout(this.heartbeatTimer);
246
235
  }
247
236
 
248
237
  /**