agentgui 1.0.570 → 1.0.571

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 +21 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.570",
3
+ "version": "1.0.571",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
@@ -272,7 +272,15 @@ class AgentGUIClient {
272
272
  if (window.conversationManager) {
273
273
  window.conversationManager.select(conversationId);
274
274
  } else {
275
- this.loadConversationMessages(conversationId).finally(() => {
275
+ this.loadConversationMessages(conversationId).catch((err) => {
276
+ console.warn('Failed to restore conversation from URL, loading latest instead:', err);
277
+ // If the URL conversation doesn't exist, try loading the most recent conversation
278
+ if (this.state.conversations && this.state.conversations.length > 0) {
279
+ const latestConv = this.state.conversations[0];
280
+ console.log('Loading latest conversation instead:', latestConv.id);
281
+ return this.loadConversationMessages(latestConv.id);
282
+ }
283
+ }).finally(() => {
276
284
  this._isLoadingConversation = false;
277
285
  });
278
286
  }
@@ -2489,6 +2497,7 @@ class AgentGUIClient {
2489
2497
  const convSignal = this._previousConvAbort.signal;
2490
2498
 
2491
2499
  const prevConversationId = this.state.currentConversation?.id;
2500
+ const availableFallback = this.state.conversations?.find(c => c.id !== conversationId) || null;
2492
2501
  this.cacheCurrentConversation();
2493
2502
  this.stopChunkPolling();
2494
2503
  this.removeScrollUpDetection();
@@ -2559,11 +2568,12 @@ class AgentGUIClient {
2559
2568
  console.warn('Conversation no longer exists:', conversationId);
2560
2569
  this.state.currentConversation = null;
2561
2570
  if (window.conversationManager) window.conversationManager.loadConversations();
2562
- // Resume from last successful conversation if available
2563
- if (prevConversationId && prevConversationId !== conversationId) {
2564
- console.log('Resuming from previous conversation:', prevConversationId);
2571
+ // Resume from last successful conversation if available, or fall back to any available conversation
2572
+ const fallbackConv = prevConversationId ? prevConversationId : availableFallback?.id;
2573
+ if (fallbackConv && fallbackConv !== conversationId) {
2574
+ console.log('Resuming from fallback conversation:', fallbackConv);
2565
2575
  this.showError('Conversation not found. Resuming previous conversation.');
2566
- await this.loadConversationMessages(prevConversationId);
2576
+ await this.loadConversationMessages(fallbackConv);
2567
2577
  } else {
2568
2578
  const outputEl = document.getElementById('output');
2569
2579
  if (outputEl) outputEl.innerHTML = '<p class="text-secondary" style="padding:2rem;text-align:center">Conversation not found. It may have been lost during a server restart.</p>';
@@ -2787,14 +2797,15 @@ class AgentGUIClient {
2787
2797
  } catch (error) {
2788
2798
  if (error.name === 'AbortError') return;
2789
2799
  console.error('Failed to load conversation messages:', error);
2790
- // Resume from last successful conversation if available
2791
- if (prevConversationId && prevConversationId !== conversationId) {
2792
- console.log('Resuming from previous conversation due to error:', prevConversationId);
2800
+ // Resume from last successful conversation if available, or fall back to any available conversation
2801
+ const fallbackConv = prevConversationId ? prevConversationId : availableFallback?.id;
2802
+ if (fallbackConv && fallbackConv !== conversationId) {
2803
+ console.log('Resuming from fallback conversation due to error:', fallbackConv);
2793
2804
  this.showError('Failed to load conversation. Resuming previous conversation.');
2794
2805
  try {
2795
- await this.loadConversationMessages(prevConversationId);
2806
+ await this.loadConversationMessages(fallbackConv);
2796
2807
  } catch (fallbackError) {
2797
- console.error('Failed to resume previous conversation:', fallbackError);
2808
+ console.error('Failed to resume fallback conversation:', fallbackError);
2798
2809
  this.showError('Failed to load conversation: ' + error.message);
2799
2810
  }
2800
2811
  } else {