agentgui 1.0.21 → 1.0.23

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.
@@ -0,0 +1,125 @@
1
+ # Conversation Display Issue
2
+
3
+ ## Problem
4
+ Imported Claude Code conversations are not visible in the UI when opening the application, even though they exist in the database (83 conversations found).
5
+
6
+ ## Root Cause Analysis
7
+
8
+ Possible issues:
9
+ 1. **Conversations not loading on page load** - fetchConversations() may fail silently
10
+ 2. **Rendering issue** - chatList element may not be rendering properly
11
+ 3. **CSS hiding** - Conversations may be present but hidden (display:none, opacity:0)
12
+ 4. **Empty state** - renderChatHistory() shows "No chats yet" because this.conversations is empty
13
+ 5. **Filter/agent selection** - Conversations filtered by agent selection not matching
14
+
15
+ ## Investigation Steps
16
+
17
+ ### Check 1: Network Request
18
+ - Open browser DevTools (F12)
19
+ - Network tab: Look for `/api/conversations` request
20
+ - Should return 83 conversations with agent IDs
21
+
22
+ ### Check 2: Console Errors
23
+ - Console tab: Look for any JavaScript errors
24
+ - Look for "fetchConversations:" logs
25
+
26
+ ### Check 3: DOM Elements
27
+ - Elements tab: Inspect #chatList
28
+ - Check if it has children
29
+ - Check CSS display property (should be visible)
30
+
31
+ ### Check 4: Data Binding
32
+ - Console: `app.conversations.size` - should show 83
33
+ - Console: `app.conversations` - should contain conversation objects
34
+
35
+ ## Solution Areas
36
+
37
+ ### Frontend (static/app.js)
38
+
39
+ 1. **Add logging to fetchConversations()**
40
+ - Log when fetch starts/completes
41
+ - Log number of conversations received
42
+ - Log any errors
43
+
44
+ 2. **Add logging to renderChatHistory()**
45
+ - Log conversations.size
46
+ - Log if condition triggers "No chats yet"
47
+
48
+ 3. **Force initial render**
49
+ - Ensure renderChatHistory() is called after fetchConversations()
50
+ - Add retry logic if conversations empty on first load
51
+
52
+ ### Server (server.js)
53
+
54
+ 1. **Verify /api/conversations endpoint**
55
+ - Check it returns all conversations
56
+ - Verify no filtering happening
57
+ - Check response format
58
+
59
+ 2. **Verify import endpoint**
60
+ - Check /api/import/claude-code works
61
+ - Ensure conversations are created with proper agentId
62
+
63
+ ## Implementation
64
+
65
+ Add debug logging to identify where conversations are lost:
66
+
67
+ ```javascript
68
+ async fetchConversations() {
69
+ try {
70
+ const res = await fetch(BASE_URL + '/api/conversations');
71
+ const data = await res.json();
72
+ console.log('fetchConversations response:', data);
73
+ console.log('Conversations count:', data.conversations?.length);
74
+
75
+ if (data.conversations) {
76
+ this.conversations.clear();
77
+ data.conversations.forEach(c => {
78
+ console.log('Adding conversation:', c.id, c.title);
79
+ this.conversations.set(c.id, c);
80
+ });
81
+ console.log('Final conversations.size:', this.conversations.size);
82
+ }
83
+ } catch (e) {
84
+ console.error('fetchConversations error:', e);
85
+ }
86
+ }
87
+
88
+ renderChatHistory() {
89
+ const list = document.getElementById('chatList');
90
+ if (!list) {
91
+ console.error('chatList element not found!');
92
+ return;
93
+ }
94
+
95
+ console.log('renderChatHistory - conversations.size:', this.conversations.size);
96
+
97
+ if (this.conversations.size === 0) {
98
+ console.warn('No conversations to display');
99
+ list.innerHTML = '<p>No chats yet</p>';
100
+ return;
101
+ }
102
+
103
+ // ... rest of rendering
104
+ }
105
+ ```
106
+
107
+ ## Expected Behavior
108
+
109
+ 1. Page loads
110
+ 2. fetchConversations() retrieves 83 conversations from API
111
+ 3. conversations Map populated with all 83 items
112
+ 4. renderChatHistory() iterates over conversations
113
+ 5. Chat list displays 83 conversation items
114
+ 6. User can click to view any conversation
115
+
116
+ ## Testing
117
+
118
+ ```bash
119
+ # Verify conversations in database
120
+ curl http://localhost:9897/gm/api/conversations | python3 -m json.tool | grep -c '"id"'
121
+
122
+ # Verify a conversation has messages (pick one)
123
+ curl http://localhost:9897/gm/api/conversations/CONV_ID/messages
124
+ ```
125
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/static/app.js CHANGED
@@ -95,6 +95,19 @@ class GMGUIApp {
95
95
 
96
96
  async init() {
97
97
  console.log('[DEBUG] Init: Starting initialization');
98
+ console.log('[DEBUG] Init: BASE_URL =', BASE_URL);
99
+ console.log('[DEBUG] Init: Window width:', window.innerWidth);
100
+
101
+ // Ensure sidebar is visible on desktop (open on wide screens)
102
+ const sidebar = document.getElementById('sidebar');
103
+ if (window.innerWidth >= 768 && sidebar) {
104
+ console.log('[DEBUG] Init: Wide screen detected, ensuring sidebar is visible');
105
+ sidebar.classList.remove('open'); // On desktop, sidebar is always visible, no need for 'open' class
106
+ } else if (sidebar) {
107
+ console.log('[DEBUG] Init: Mobile/narrow screen detected, opening sidebar');
108
+ sidebar.classList.add('open');
109
+ }
110
+
98
111
  this.loadSettings();
99
112
  this.setupEventListeners();
100
113
  await this.fetchHome();
@@ -105,12 +118,14 @@ class GMGUIApp {
105
118
  console.log('[DEBUG] Init: Auto-imported Claude Code conversations');
106
119
  await this.fetchConversations();
107
120
  console.log('[DEBUG] Init: Fetched conversations, count:', this.conversations.size);
121
+ console.log('[DEBUG] Init: Conversation details:', Array.from(this.conversations.values()).slice(0, 3));
108
122
  this.connectSyncWebSocket();
109
123
  this.setupCrossTabSync();
110
124
  this.startPeriodicSync();
111
125
  console.log('[DEBUG] Init: About to renderAll with', this.conversations.size, 'conversations');
112
126
  this.renderAll();
113
127
  console.log('[DEBUG] Init: renderAll completed');
128
+ console.log('[DEBUG] Init: chatList innerHTML length:', document.getElementById('chatList')?.innerHTML?.length || 0);
114
129
  }
115
130
 
116
131
  startPeriodicSync() {
@@ -327,20 +342,37 @@ class GMGUIApp {
327
342
  console.log('[DEBUG] fetchConversations: Starting fetch from', BASE_URL + '/api/conversations');
328
343
  const res = await fetch(BASE_URL + '/api/conversations');
329
344
  console.log('[DEBUG] fetchConversations: Response status:', res.status);
345
+
346
+ if (!res.ok) {
347
+ console.error('[DEBUG] fetchConversations: Response not OK, status:', res.status);
348
+ return;
349
+ }
350
+
330
351
  const data = await res.json();
331
352
  console.log('[DEBUG] fetchConversations response count:', data.conversations?.length);
332
- console.log('[DEBUG] fetchConversations response data:', data);
353
+
333
354
  if (data.conversations) {
355
+ console.log('[DEBUG] fetchConversations: About to clear and load conversations');
334
356
  this.conversations.clear();
335
- console.log('[DEBUG] fetchConversations: Cleared conversations map');
336
- data.conversations.forEach(c => this.conversations.set(c.id, c));
357
+ console.log('[DEBUG] fetchConversations: Cleared conversations map, size now:', this.conversations.size);
358
+
359
+ data.conversations.forEach(c => {
360
+ this.conversations.set(c.id, c);
361
+ });
362
+
337
363
  console.log('[DEBUG] Loaded conversations, total:', this.conversations.size);
338
364
  console.log('[DEBUG] First few conversation IDs:', Array.from(this.conversations.keys()).slice(0, 5));
365
+
366
+ if (this.conversations.size === 0) {
367
+ console.error('[DEBUG] ERROR: conversations.size is 0 after loading!');
368
+ }
339
369
  } else {
340
370
  console.warn('[DEBUG] fetchConversations: data.conversations is undefined or null');
371
+ console.warn('[DEBUG] fetchConversations: Full response:', data);
341
372
  }
342
373
  } catch (e) {
343
- console.error('fetchConversations error:', e);
374
+ console.error('[DEBUG] fetchConversations error:', e);
375
+ console.error('[DEBUG] Error details:', e.message, e.stack);
344
376
  }
345
377
  }
346
378
 
@@ -411,6 +443,10 @@ class GMGUIApp {
411
443
  }
412
444
  list.innerHTML = '';
413
445
  console.log('[DEBUG] renderChatHistory - conversations.size:', this.conversations.size);
446
+
447
+ // Debug: Update page title with conversation count
448
+ document.title = `GMGUI (${this.conversations.size} chats)`;
449
+
414
450
  if (this.conversations.size === 0) {
415
451
  console.warn('[DEBUG] No conversations to display - showing empty state');
416
452
  console.warn('[DEBUG] conversations map contents:', this.conversations);
@@ -421,6 +457,7 @@ class GMGUIApp {
421
457
  (a, b) => (b.updated_at || 0) - (a.updated_at || 0)
422
458
  );
423
459
  console.log('[DEBUG] renderChatHistory - sorted conversations count:', sorted.length);
460
+ console.log('[DEBUG] renderChatHistory - rendering', sorted.length, 'conversations');
424
461
  sorted.forEach(conv => {
425
462
  const item = document.createElement('button');
426
463
  item.className = `chat-item ${this.currentConversation === conv.id ? 'active' : ''}`;
@@ -1272,5 +1309,35 @@ function confirmFolderSelection() {
1272
1309
  app.closeFolderBrowser();
1273
1310
  }
1274
1311
 
1275
- const app = new GMGUIApp();
1276
- window._app = app;
1312
+ // Wait for DOM to be fully ready before initializing
1313
+ function initializeApp() {
1314
+ console.log('[DEBUG] initializeApp: Checking if DOM is ready');
1315
+ const chatList = document.getElementById('chatList');
1316
+ if (!chatList) {
1317
+ console.warn('[DEBUG] initializeApp: chatList not found, waiting 100ms');
1318
+ setTimeout(initializeApp, 100);
1319
+ return;
1320
+ }
1321
+
1322
+ console.log('[DEBUG] initializeApp: DOM is ready, creating GMGUIApp');
1323
+ window.app = new GMGUIApp();
1324
+ window._app = window.app;
1325
+
1326
+ // Debug: Log app state to window for inspection
1327
+ window._debug = {
1328
+ get conversations() { return Array.from(window.app.conversations.values()).map(c => ({ id: c.id, title: c.title })); },
1329
+ get conversationCount() { return window.app.conversations.size; },
1330
+ get selectedAgent() { return window.app.selectedAgent; },
1331
+ get currentConversation() { return window.app.currentConversation; },
1332
+ checkChatListElement() { return document.getElementById('chatList'); },
1333
+ checkChatListChildCount() { return document.getElementById('chatList')?.children?.length || 0; }
1334
+ };
1335
+
1336
+ console.log('[DEBUG] initializeApp: GMGUIApp created successfully');
1337
+ }
1338
+
1339
+ if (document.readyState === 'loading') {
1340
+ document.addEventListener('DOMContentLoaded', initializeApp);
1341
+ } else {
1342
+ initializeApp();
1343
+ }