agentgui 1.0.20 → 1.0.22

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/DEBUG_GUIDE.md ADDED
@@ -0,0 +1,136 @@
1
+ # Debug Guide - Conversation Display Issue
2
+
3
+ ## Problem
4
+ Imported Claude Code conversations (83 total) are not visible in the chat list when the application loads, despite being stored in the database and returned by the API.
5
+
6
+ ## API Status - ✅ VERIFIED
7
+ - Server is running on `http://localhost:9897`
8
+ - API endpoint `/api/conversations` returns 83 conversations
9
+ - Response structure is correct with proper ID, agentId, title, created_at, updated_at, status fields
10
+
11
+ ## Debug Logging Added
12
+ We've added comprehensive debug logging to trace the initialization flow. The logging will help identify where conversations are being lost.
13
+
14
+ ### Enhanced Logging Points:
15
+ 1. **Init sequence** - Logs each step of initialization
16
+ 2. **fetchConversations** - Logs API request, response status, data received
17
+ 3. **renderAll** - Logs conversation count before rendering
18
+ 4. **renderChatHistory** - Logs final conversation count and whether empty state is shown
19
+
20
+ ## How to Debug
21
+
22
+ ### Step 1: Open the Application
23
+ 1. Open your web browser
24
+ 2. Navigate to: `http://localhost:9897/gm/`
25
+ 3. Press **F12** to open Developer Tools
26
+ 4. Go to the **Console** tab
27
+
28
+ ### Step 2: Look for Debug Logs
29
+ Watch for logs starting with `[DEBUG]`. You should see:
30
+
31
+ ```
32
+ [DEBUG] Init: Starting initialization
33
+ [DEBUG] Init: Fetched home
34
+ [DEBUG] Init: Fetched agents, count: X
35
+ [DEBUG] Init: Auto-imported Claude Code conversations
36
+ [DEBUG] fetchConversations: Starting fetch from http://localhost:9897/gm/api/conversations
37
+ [DEBUG] fetchConversations: Response status: 200
38
+ [DEBUG] fetchConversations response count: 83
39
+ [DEBUG] fetchConversations response data: {...}
40
+ [DEBUG] fetchConversations: Cleared conversations map
41
+ [DEBUG] Loaded conversations, total: 83
42
+ [DEBUG] First few conversation IDs: [...]
43
+ [DEBUG] Init: Fetched conversations, count: 83
44
+ [DEBUG] Init: About to renderAll with 83 conversations
45
+ [DEBUG] renderAll: Called with 83 conversations
46
+ [DEBUG] renderChatHistory - conversations.size: 83
47
+ [DEBUG] renderChatHistory - sorted conversations count: 83
48
+ [DEBUG] Init: renderAll completed
49
+ ```
50
+
51
+ ### Step 3: Analyze the Logs
52
+
53
+ Check these specific values:
54
+
55
+ | Log | Expected | Issue If Different |
56
+ |-----|----------|-------------------|
57
+ | `response count: 83` | 83 | API not returning conversations |
58
+ | `Loaded conversations, total: 83` | 83 | Data not being added to map |
59
+ | `About to renderAll with 83 conversations` | 83 | Conversations lost between fetch and render |
60
+ | `renderChatHistory - conversations.size: 83` | 83 | Size changes between renderAll and renderChatHistory |
61
+ | `No conversations to display - showing empty state` | Should NOT appear | renderChatHistory shows empty when size > 0 |
62
+
63
+ ### Step 4: Check Browser State
64
+ In the Console, type:
65
+ ```javascript
66
+ // Check if conversations were loaded into the app
67
+ app.conversations.size
68
+
69
+ // Check the actual conversations
70
+ app.conversations
71
+
72
+ // Check first conversation
73
+ Array.from(app.conversations.values())[0]
74
+
75
+ // Check if BASE_URL is correct
76
+ BASE_URL
77
+ ```
78
+
79
+ ### Step 5: Check Network Tab
80
+ 1. Go to **Network** tab in DevTools
81
+ 2. Filter for `/api/conversations` request
82
+ 3. Check:
83
+ - Request Status: Should be 200
84
+ - Response body: Should contain array of 83 conversations
85
+ - Response headers: Should show correct content-type
86
+
87
+ ## Possible Issues and Solutions
88
+
89
+ ### Issue 1: API returns 0 conversations
90
+ **Symptom**: `response count: 0`
91
+ - Check: Is the database populated?
92
+ - Command: `sqlite3 /config/workspace/agentgui/data/gmgui.db "SELECT COUNT(*) FROM conversations;"`
93
+ - Fix: Import conversations or check database connection
94
+
95
+ ### Issue 2: API returns data but conversations.size is 0
96
+ **Symptom**: `response count: 83` but `Loaded conversations, total: 0`
97
+ - Likely cause: Data structure mismatch or forEach not working
98
+ - Fix: Check if data.conversations is an array
99
+ - Check: Are the conversation objects being created properly?
100
+
101
+ ### Issue 3: Conversations loaded but renderChatHistory shows empty
102
+ **Symptom**: `About to renderAll with 83 conversations` but `No conversations to display`
103
+ - Likely cause: Something clears conversations.map between renderAll and renderChatHistory
104
+ - Check: Look for any handleSyncEvent calls that might clear or reset conversations
105
+ - Fix: Add logging to sync event handlers
106
+
107
+ ### Issue 4: Conversations load but don't display in UI
108
+ **Symptom**: All debug logs show 83 conversations, but chat list still shows "No chats yet"
109
+ - Likely cause: CSS hiding, DOM structure issue, or rendering issue
110
+ - Check: Look at HTML element with id="chatList" - is it hidden?
111
+ - Check: Are chat items being created in the DOM?
112
+ - Solution: Open Elements tab and expand chatList to see if items exist
113
+
114
+ ## Next Steps After Debugging
115
+
116
+ 1. **Identify the root cause** using the logs above
117
+ 2. **Document which log shows the problem**
118
+ 3. **Implement the appropriate fix**:
119
+ - If API issue: Fix server endpoint
120
+ - If data structure issue: Fix response parsing
121
+ - If sync issue: Fix sync event handlers
122
+ - If UI issue: Fix CSS or rendering logic
123
+ 4. **Verify fix** with the debug logs
124
+ 5. **Commit changes** to git
125
+
126
+ ## File Locations
127
+ - Frontend code: `/config/workspace/agentgui/static/app.js`
128
+ - Server code: `/config/workspace/agentgui/server.js`
129
+ - Database: `/config/workspace/agentgui/data/gmgui.db`
130
+ - API responses return from: `/api/conversations` endpoint in server.js
131
+
132
+ ## Important Notes
133
+ - Hot reload is enabled for CSS/HTML/frontend JS
134
+ - Debug logs will auto-reload in browser when app.js changes
135
+ - Check DevTools console IMMEDIATELY after loading the page
136
+ - Some logs may scroll off - use DevTools console filter to search for `[DEBUG]`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
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
@@ -94,16 +94,26 @@ class GMGUIApp {
94
94
  }
95
95
 
96
96
  async init() {
97
+ console.log('[DEBUG] Init: Starting initialization');
98
+ console.log('[DEBUG] Init: BASE_URL =', BASE_URL);
97
99
  this.loadSettings();
98
100
  this.setupEventListeners();
99
101
  await this.fetchHome();
102
+ console.log('[DEBUG] Init: Fetched home');
100
103
  await this.fetchAgents();
104
+ console.log('[DEBUG] Init: Fetched agents, count:', this.agents.size);
101
105
  await this.autoImportClaudeCode();
106
+ console.log('[DEBUG] Init: Auto-imported Claude Code conversations');
102
107
  await this.fetchConversations();
108
+ console.log('[DEBUG] Init: Fetched conversations, count:', this.conversations.size);
109
+ console.log('[DEBUG] Init: Conversation details:', Array.from(this.conversations.values()).slice(0, 3));
103
110
  this.connectSyncWebSocket();
104
111
  this.setupCrossTabSync();
105
112
  this.startPeriodicSync();
113
+ console.log('[DEBUG] Init: About to renderAll with', this.conversations.size, 'conversations');
106
114
  this.renderAll();
115
+ console.log('[DEBUG] Init: renderAll completed');
116
+ console.log('[DEBUG] Init: chatList innerHTML length:', document.getElementById('chatList')?.innerHTML?.length || 0);
107
117
  }
108
118
 
109
119
  startPeriodicSync() {
@@ -317,14 +327,23 @@ class GMGUIApp {
317
327
 
318
328
  async fetchConversations() {
319
329
  try {
330
+ console.log('[DEBUG] fetchConversations: Starting fetch from', BASE_URL + '/api/conversations');
320
331
  const res = await fetch(BASE_URL + '/api/conversations');
332
+ console.log('[DEBUG] fetchConversations: Response status:', res.status);
321
333
  const data = await res.json();
334
+ console.log('[DEBUG] fetchConversations response count:', data.conversations?.length);
335
+ console.log('[DEBUG] fetchConversations response data:', data);
322
336
  if (data.conversations) {
323
337
  this.conversations.clear();
338
+ console.log('[DEBUG] fetchConversations: Cleared conversations map');
324
339
  data.conversations.forEach(c => this.conversations.set(c.id, c));
340
+ console.log('[DEBUG] Loaded conversations, total:', this.conversations.size);
341
+ console.log('[DEBUG] First few conversation IDs:', Array.from(this.conversations.keys()).slice(0, 5));
342
+ } else {
343
+ console.warn('[DEBUG] fetchConversations: data.conversations is undefined or null');
325
344
  }
326
345
  } catch (e) {
327
- console.error('fetchConversations:', e);
346
+ console.error('fetchConversations error:', e);
328
347
  }
329
348
  }
330
349
 
@@ -340,9 +359,11 @@ class GMGUIApp {
340
359
  }
341
360
 
342
361
  renderAll() {
362
+ console.log('[DEBUG] renderAll: Called with', this.conversations.size, 'conversations');
343
363
  this.renderAgentCards();
344
364
  this.renderChatHistory();
345
365
  if (this.currentConversation) {
366
+ console.log('[DEBUG] renderAll: Displaying current conversation', this.currentConversation);
346
367
  this.displayConversation(this.currentConversation);
347
368
  }
348
369
  }
@@ -387,15 +408,27 @@ class GMGUIApp {
387
408
 
388
409
  renderChatHistory() {
389
410
  const list = document.getElementById('chatList');
390
- if (!list) return;
411
+ if (!list) {
412
+ console.error('[DEBUG] chatList element not found!');
413
+ return;
414
+ }
391
415
  list.innerHTML = '';
416
+ console.log('[DEBUG] renderChatHistory - conversations.size:', this.conversations.size);
417
+
418
+ // Debug: Update page title with conversation count
419
+ document.title = `GMGUI (${this.conversations.size} chats)`;
420
+
392
421
  if (this.conversations.size === 0) {
422
+ console.warn('[DEBUG] No conversations to display - showing empty state');
423
+ console.warn('[DEBUG] conversations map contents:', this.conversations);
393
424
  list.innerHTML = '<p style="color: var(--text-tertiary); font-size: 0.875rem; padding: 0.5rem;">No chats yet</p>';
394
425
  return;
395
426
  }
396
427
  const sorted = Array.from(this.conversations.values()).sort(
397
428
  (a, b) => (b.updated_at || 0) - (a.updated_at || 0)
398
429
  );
430
+ console.log('[DEBUG] renderChatHistory - sorted conversations count:', sorted.length);
431
+ console.log('[DEBUG] renderChatHistory - rendering', sorted.length, 'conversations');
399
432
  sorted.forEach(conv => {
400
433
  const item = document.createElement('button');
401
434
  item.className = `chat-item ${this.currentConversation === conv.id ? 'active' : ''}`;
@@ -1249,3 +1282,13 @@ function confirmFolderSelection() {
1249
1282
 
1250
1283
  const app = new GMGUIApp();
1251
1284
  window._app = app;
1285
+
1286
+ // Debug: Log app state to window for inspection
1287
+ window._debug = {
1288
+ get conversations() { return Array.from(app.conversations.values()).map(c => ({ id: c.id, title: c.title })); },
1289
+ get conversationCount() { return app.conversations.size; },
1290
+ get selectedAgent() { return app.selectedAgent; },
1291
+ get currentConversation() { return app.currentConversation; },
1292
+ checkChatListElement() { return document.getElementById('chatList'); },
1293
+ checkChatListChildCount() { return document.getElementById('chatList')?.children?.length || 0; }
1294
+ };