agentgui 1.0.798 → 1.0.799

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/static/js/client.js +12 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.798",
3
+ "version": "1.0.799",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "electron/main.js",
@@ -2173,16 +2173,17 @@ class AgentGUIClient {
2173
2173
  blockFrag.appendChild(el);
2174
2174
  }
2175
2175
  blocksEl.appendChild(blockFrag);
2176
+ // Build tool-use element index once for O(1) lookups instead of O(n) querySelectorAll per chunk
2177
+ const toolUseIndex = new Map();
2178
+ blocksEl.querySelectorAll('.block-tool-use[data-tool-use-id]').forEach(el => toolUseIndex.set(el.dataset.toolUseId, el));
2176
2179
  for (const chunk of deferred) {
2177
2180
  const b = chunk.block;
2178
2181
  if (b.type === 'tool_result') {
2179
- const tid = b.tool_use_id;
2180
- const toolUseEl = (tid ? blocksEl.querySelector(`.block-tool-use[data-tool-use-id="${tid}"]`) : null)
2182
+ const toolUseEl = (b.tool_use_id && toolUseIndex.get(b.tool_use_id))
2181
2183
  || (blocksEl.lastElementChild?.classList.contains('block-tool-use') ? blocksEl.lastElementChild : null);
2182
2184
  if (toolUseEl) this.renderer.mergeResultIntoToolUse(toolUseEl, b);
2183
2185
  } else if (b.type === 'tool_status') {
2184
- const tid = b.tool_use_id;
2185
- const toolUseEl = tid && blocksEl.querySelector(`.block-tool-use[data-tool-use-id="${tid}"]`);
2186
+ const toolUseEl = b.tool_use_id && toolUseIndex.get(b.tool_use_id);
2186
2187
  if (toolUseEl) {
2187
2188
  const isError = b.status === 'failed';
2188
2189
  const isDone = b.status === 'completed';
@@ -2845,10 +2846,9 @@ class AgentGUIClient {
2845
2846
  if (cached && (Date.now() - cached.timestamp) < 300000) {
2846
2847
  const outputEl = document.getElementById('output');
2847
2848
  if (outputEl) {
2848
- outputEl.innerHTML = '';
2849
- while (cached.dom.firstChild) {
2850
- outputEl.appendChild(cached.dom.firstChild);
2851
- }
2849
+ const children = [];
2850
+ while (cached.dom.firstChild) children.push(cached.dom.firstChild);
2851
+ outputEl.replaceChildren(...children);
2852
2852
  window.ConversationState?.selectConversation(conversationId, 'dom_cache_load', 1);
2853
2853
  this.state.currentConversation = cached.conversation;
2854
2854
  window.dispatchEvent(new CustomEvent('conversation-changed', { detail: { conversationId, conversation: cached.conversation } }));
@@ -2921,23 +2921,15 @@ class AgentGUIClient {
2921
2921
  const hasActivity = (allMessages && allMessages.length > 0) || isActivelyStreaming || latestSession || this._convIsStreaming(conversationId);
2922
2922
  this.applyAgentAndModelSelection(conversation, hasActivity);
2923
2923
 
2924
+ // Parse chunk data and fetch queue in parallel
2925
+ const queuePromise = window.wsClient.rpc('q.ls', { id: conversationId }).catch(() => ({ queue: [] }));
2924
2926
  const chunks = (rawChunks || []).map(chunk => ({
2925
2927
  ...chunk,
2926
2928
  block: typeof chunk.data === 'string' ? JSON.parse(chunk.data) : chunk.data
2927
2929
  }));
2928
2930
 
2929
- // Fetch queue to exclude queued messages from being rendered as regular user messages
2930
- let queuedMessageIds = new Set();
2931
- try {
2932
- const { queue } = await window.wsClient.rpc('q.ls', { id: conversationId });
2933
- if (queue && queue.length > 0) {
2934
- queuedMessageIds = new Set(queue.map(q => q.messageId));
2935
- }
2936
- } catch (e) {
2937
- console.warn('Failed to fetch queue:', e.message);
2938
- }
2939
-
2940
- // Filter out queued messages from user messages - they'll be rendered in queue indicator instead
2931
+ const { queue: queueResult } = await queuePromise;
2932
+ const queuedMessageIds = new Set((queueResult || []).map(q => q.messageId));
2941
2933
  const userMessages = (allMessages || []).filter(m => m.role === 'user' && !queuedMessageIds.has(m.id));
2942
2934
  const hasMoreChunks = totalChunks && chunks.length < totalChunks;
2943
2935