agentgui 1.0.376 → 1.0.377

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.376",
3
+ "version": "1.0.377",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
@@ -1944,9 +1944,8 @@ class AgentGUIClient {
1944
1944
  this.ui.agentSelector.disabled = true;
1945
1945
  }
1946
1946
  this.loadModelsForAgent(agentId).then(() => {
1947
- if (this.ui.modelSelector) {
1948
- if (model) this.ui.modelSelector.value = model;
1949
- this.ui.modelSelector.disabled = true;
1947
+ if (this.ui.modelSelector && model) {
1948
+ this.ui.modelSelector.value = model;
1950
1949
  }
1951
1950
  });
1952
1951
  }
@@ -1956,8 +1955,28 @@ class AgentGUIClient {
1956
1955
  if (this.ui.agentSelector) {
1957
1956
  this.ui.agentSelector.disabled = false;
1958
1957
  }
1959
- if (this.ui.modelSelector) {
1960
- this.ui.modelSelector.disabled = false;
1958
+ }
1959
+
1960
+ /**
1961
+ * Apply agent and model selection based on conversation state
1962
+ * Consolidates duplicate logic for cached and fresh conversation loads
1963
+ */
1964
+ applyAgentAndModelSelection(conversation, hasActivity) {
1965
+ const agentId = conversation.agentType || 'claude-code';
1966
+ const model = conversation.model || null;
1967
+
1968
+ if (hasActivity) {
1969
+ this.lockAgentAndModel(agentId, model);
1970
+ } else {
1971
+ this.unlockAgentAndModel();
1972
+ if (this.ui.agentSelector) {
1973
+ this.ui.agentSelector.value = agentId;
1974
+ }
1975
+ this.loadModelsForAgent(agentId).then(() => {
1976
+ if (model && this.ui.modelSelector) {
1977
+ this.ui.modelSelector.value = model;
1978
+ }
1979
+ });
1961
1980
  }
1962
1981
  }
1963
1982
 
@@ -2247,19 +2266,7 @@ class AgentGUIClient {
2247
2266
  }
2248
2267
  this.state.currentConversation = cached.conversation;
2249
2268
  const cachedHasActivity = cached.conversation.messageCount > 0 || this.state.streamingConversations.has(conversationId);
2250
- if (cachedHasActivity) {
2251
- this.lockAgentAndModel(cached.conversation.agentType || 'claude-code', cached.conversation.model || null);
2252
- } else {
2253
- this.unlockAgentAndModel();
2254
- if (this.ui.agentSelector && cached.conversation.agentType) this.ui.agentSelector.value = cached.conversation.agentType;
2255
- if (cached.conversation.agentType) {
2256
- this.loadModelsForAgent(cached.conversation.agentType).then(() => {
2257
- if (cached.conversation.model && this.ui.modelSelector) {
2258
- this.ui.modelSelector.value = cached.conversation.model;
2259
- }
2260
- });
2261
- }
2262
- }
2269
+ this.applyAgentAndModelSelection(cached.conversation, cachedHasActivity);
2263
2270
  this.conversationCache.delete(conversationId);
2264
2271
  this.restoreScrollPosition(conversationId);
2265
2272
  this.enableControls();
@@ -2288,19 +2295,7 @@ class AgentGUIClient {
2288
2295
 
2289
2296
  this.state.currentConversation = conversation;
2290
2297
  const hasActivity = (allMessages && allMessages.length > 0) || isActivelyStreaming || latestSession || this.state.streamingConversations.has(conversationId);
2291
- if (hasActivity) {
2292
- this.lockAgentAndModel(conversation.agentType || 'claude-code', conversation.model || null);
2293
- } else {
2294
- this.unlockAgentAndModel();
2295
- if (this.ui.agentSelector && conversation.agentType) this.ui.agentSelector.value = conversation.agentType;
2296
- if (conversation.agentType) {
2297
- this.loadModelsForAgent(conversation.agentType).then(() => {
2298
- if (conversation.model && this.ui.modelSelector) {
2299
- this.ui.modelSelector.value = conversation.model;
2300
- }
2301
- });
2302
- }
2303
- }
2298
+ this.applyAgentAndModelSelection(conversation, hasActivity);
2304
2299
 
2305
2300
  const chunks = (rawChunks || []).map(chunk => ({
2306
2301
  ...chunk,
@@ -423,7 +423,7 @@ class StreamingRenderer {
423
423
  }
424
424
 
425
425
  _getToolColorClass(toolName) {
426
- const n = (toolName || '').replace(/^mcp__[^_]+__/, '').toLowerCase();
426
+ const n = (toolName || '').replace(/^mcp__.*?__/, '').toLowerCase();
427
427
  const map = {
428
428
  read: 'read', write: 'write', edit: 'edit', bash: 'bash', glob: 'glob', grep: 'grep',
429
429
  webfetch: 'web', websearch: 'web', todowrite: 'todo', task: 'task', notebookedit: 'edit',
@@ -572,7 +572,7 @@ class StreamingRenderer {
572
572
  renderSmartParams(toolName, input) {
573
573
  if (!input || Object.keys(input).length === 0) return '';
574
574
 
575
- const normalizedName = toolName.replace(/^mcp__[^_]+__/, '');
575
+ const normalizedName = toolName.replace(/^mcp__.*?__/, '');
576
576
 
577
577
  switch (normalizedName) {
578
578
  case 'Read':
@@ -695,7 +695,7 @@ class StreamingRenderer {
695
695
  * Render tool use block with smart parameter display
696
696
  */
697
697
  getToolUseTitle(toolName, input) {
698
- const normalizedName = toolName.replace(/^mcp__[^_]+__/, '');
698
+ const normalizedName = toolName.replace(/^mcp__.*?__/, '');
699
699
  if (normalizedName === 'Edit' && input.file_path) {
700
700
  const parts = pathSplit(input.file_path);
701
701
  const fileName = parts.pop();
@@ -729,7 +729,7 @@ class StreamingRenderer {
729
729
  }
730
730
 
731
731
  getToolUseDisplayName(toolName) {
732
- const normalized = toolName.replace(/^mcp__[^_]+__/, '');
732
+ const normalized = toolName.replace(/^mcp__.*?__/, '');
733
733
  const knownTools = ['Read','Write','Edit','Bash','Glob','Grep','WebFetch','WebSearch','TodoWrite','Task','NotebookEdit'];
734
734
  if (knownTools.includes(normalized)) return normalized;
735
735
  if (toolName.startsWith('mcp__')) {
@@ -1135,7 +1135,7 @@ class StreamingRenderer {
1135
1135
  }
1136
1136
 
1137
1137
  static getToolDisplayName(toolName) {
1138
- const normalized = toolName.replace(/^mcp__[^_]+__/, '');
1138
+ const normalized = toolName.replace(/^mcp__.*?__/, '');
1139
1139
  const knownTools = ['Read','Write','Edit','Bash','Glob','Grep','WebFetch','WebSearch','TodoWrite','Task','NotebookEdit'];
1140
1140
  if (knownTools.includes(normalized)) return normalized;
1141
1141
  if (toolName.startsWith('mcp__')) {
@@ -1146,7 +1146,7 @@ class StreamingRenderer {
1146
1146
  }
1147
1147
 
1148
1148
  static getToolTitle(toolName, input) {
1149
- const n = toolName.replace(/^mcp__[^_]+__/, '');
1149
+ const n = toolName.replace(/^mcp__.*?__/, '');
1150
1150
  if (n === 'Edit' && input.file_path) { const p = pathSplit(input.file_path); const f = p.pop(); const d = p.slice(-2).join('/'); return d ? d+'/'+f : f; }
1151
1151
  if (n === 'Read' && input.file_path) return pathBasename(input.file_path);
1152
1152
  if (n === 'Write' && input.file_path) return pathBasename(input.file_path);