agentgui 1.0.24 → 1.0.26
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/01-initial-load.png +0 -0
- package/REMOTE_DEBUG_GUIDE.md +225 -0
- package/package.json +1 -1
- package/server.js +23 -9
- package/static/app.js +40 -7
|
Binary file
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Remote Server Debugging Guide
|
|
2
|
+
|
|
3
|
+
## Issue
|
|
4
|
+
Conversations are not displaying in AgentGUI on remote server (https://buildesk.acc.l-inc.co.za/gm/), even though:
|
|
5
|
+
- ✅ The application loads
|
|
6
|
+
- ✅ The layout works
|
|
7
|
+
- ✅ The sidebar is visible
|
|
8
|
+
|
|
9
|
+
## Root Cause Analysis
|
|
10
|
+
|
|
11
|
+
### On Local Server ✅
|
|
12
|
+
- 83 conversations stored in `~/.gmgui/data.db`
|
|
13
|
+
- 68 Claude Code conversations discovered in `~/.claude/projects/`
|
|
14
|
+
- All 68 imported successfully
|
|
15
|
+
- API returns conversations correctly
|
|
16
|
+
- Frontend fetches and displays them
|
|
17
|
+
|
|
18
|
+
### On Remote Server ❓
|
|
19
|
+
- Unknown database state
|
|
20
|
+
- Unknown Claude Code availability
|
|
21
|
+
- Conversations showing as empty
|
|
22
|
+
|
|
23
|
+
## Diagnostic Checklist
|
|
24
|
+
|
|
25
|
+
### 1. Check if API is returning conversations
|
|
26
|
+
|
|
27
|
+
In browser console:
|
|
28
|
+
```javascript
|
|
29
|
+
fetch('/gm/api/conversations')
|
|
30
|
+
.then(r => r.json())
|
|
31
|
+
.then(d => console.log('Conversations from API:', d.conversations?.length || 0))
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If this returns 0: **Database is empty or API is failing**
|
|
35
|
+
If this returns > 0: **API is working, issue is in frontend**
|
|
36
|
+
|
|
37
|
+
### 2. Check frontend state
|
|
38
|
+
|
|
39
|
+
In browser console:
|
|
40
|
+
```javascript
|
|
41
|
+
// Check if app was initialized
|
|
42
|
+
console.log('app.conversations.size:', app.conversations.size);
|
|
43
|
+
|
|
44
|
+
// If size is 0, check if fetchConversations was called
|
|
45
|
+
console.log('API returned data:', app.conversations);
|
|
46
|
+
|
|
47
|
+
// Force a refetch
|
|
48
|
+
await app.fetchConversations();
|
|
49
|
+
console.log('After refetch:', app.conversations.size);
|
|
50
|
+
|
|
51
|
+
// If still 0, render to see debug info
|
|
52
|
+
app.renderChatHistory();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 3. Manually trigger import
|
|
56
|
+
|
|
57
|
+
In browser console:
|
|
58
|
+
```javascript
|
|
59
|
+
// Try to import Claude Code conversations
|
|
60
|
+
await fetch('/gm/api/import/claude-code')
|
|
61
|
+
.then(r => r.json())
|
|
62
|
+
.then(d => console.log('Import result:', d));
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Then refetch:
|
|
66
|
+
```javascript
|
|
67
|
+
await app.fetchConversations();
|
|
68
|
+
app.renderChatHistory();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 4. Check Claude Code projects
|
|
72
|
+
|
|
73
|
+
In terminal on remote server:
|
|
74
|
+
```bash
|
|
75
|
+
# Check if Claude Code directory exists
|
|
76
|
+
ls -la ~/.claude/projects/
|
|
77
|
+
|
|
78
|
+
# List all projects
|
|
79
|
+
find ~/.claude/projects -name "sessions-index.json" 2>/dev/null | wc -l
|
|
80
|
+
|
|
81
|
+
# Check first project
|
|
82
|
+
ls -la ~/.claude/projects/ | head
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
If directory doesn't exist or is empty: **Claude Code hasn't been used on this server**
|
|
86
|
+
|
|
87
|
+
### 5. Check database directly
|
|
88
|
+
|
|
89
|
+
In terminal on remote server:
|
|
90
|
+
```bash
|
|
91
|
+
# Check database location (should be ~/.gmgui/data.db)
|
|
92
|
+
ls -lh ~/.gmgui/data.db
|
|
93
|
+
|
|
94
|
+
# Get conversation count (if Node/better-sqlite3 available)
|
|
95
|
+
node -e "
|
|
96
|
+
const DB = require('better-sqlite3');
|
|
97
|
+
const db = new DB(process.env.HOME + '/.gmgui/data.db');
|
|
98
|
+
const count = db.prepare('SELECT COUNT(*) as c FROM conversations').get();
|
|
99
|
+
console.log('DB Conversations:', count.c);
|
|
100
|
+
db.close();
|
|
101
|
+
"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
If file doesn't exist: **Database not initialized**
|
|
105
|
+
If count is 0: **No conversations in database**
|
|
106
|
+
|
|
107
|
+
## Solutions by Scenario
|
|
108
|
+
|
|
109
|
+
### Scenario A: API returns 0, Database is empty
|
|
110
|
+
**Problem:** No conversations to display (first time setup)
|
|
111
|
+
**Solution:**
|
|
112
|
+
1. Import Claude Code conversations (if available)
|
|
113
|
+
2. Or create new conversations
|
|
114
|
+
3. Or import from JSON
|
|
115
|
+
|
|
116
|
+
### Scenario B: API returns conversations, Frontend shows 0
|
|
117
|
+
**Problem:** Frontend not fetching/displaying properly
|
|
118
|
+
**Solution:**
|
|
119
|
+
1. Check browser console for errors
|
|
120
|
+
2. Check [DEBUG] logs
|
|
121
|
+
3. Try `_debug.forceRefetch()` in console
|
|
122
|
+
4. Check if BASE_URL is set correctly
|
|
123
|
+
|
|
124
|
+
### Scenario C: Claude Code projects exist but no conversations
|
|
125
|
+
**Problem:** Discovered conversations but not imported
|
|
126
|
+
**Solution:**
|
|
127
|
+
1. Open browser console
|
|
128
|
+
2. Call import endpoint
|
|
129
|
+
3. Call `app.fetchConversations()`
|
|
130
|
+
4. Call `app.renderChatHistory()`
|
|
131
|
+
|
|
132
|
+
### Scenario D: Conversations exist but frontend won't display
|
|
133
|
+
**Problem:** Rendering issue
|
|
134
|
+
**Solution:**
|
|
135
|
+
1. Check HTML element `#chatList` exists
|
|
136
|
+
2. Check CSS isn't hiding it
|
|
137
|
+
3. Check for JavaScript errors
|
|
138
|
+
4. Test `_debug.forceRefetch()`
|
|
139
|
+
|
|
140
|
+
## What to Look For in Console
|
|
141
|
+
|
|
142
|
+
When page loads, should see these logs:
|
|
143
|
+
```
|
|
144
|
+
[DEBUG] Init: Starting initialization
|
|
145
|
+
[DEBUG] Init: BASE_URL = /gm
|
|
146
|
+
[DEBUG] Init: Window width: XXXX
|
|
147
|
+
[DEBUG] Init: Fetched agents, count: X
|
|
148
|
+
[DEBUG] Init: Auto-imported Claude Code conversations
|
|
149
|
+
[DEBUG] fetchConversations: Starting fetch from /gm/api/conversations
|
|
150
|
+
[DEBUG] fetchConversations response count: X
|
|
151
|
+
[DEBUG] Init: Fetched conversations, count: X
|
|
152
|
+
[DEBUG] renderChatHistory - conversations.size: X
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
If you see `conversations.size: 0` anywhere, that's the issue.
|
|
156
|
+
|
|
157
|
+
## Commands to Run in Browser Console
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
// 1. Comprehensive status check
|
|
161
|
+
{
|
|
162
|
+
api: await fetch('/gm/api/conversations').then(r => r.json()).then(d => d.conversations?.length),
|
|
163
|
+
app: app.conversations.size,
|
|
164
|
+
baseUrl: BASE_URL,
|
|
165
|
+
windowWidth: window.innerWidth,
|
|
166
|
+
chatList: !!document.getElementById('chatList'),
|
|
167
|
+
agents: app.agents.size
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// 2. Force refetch and render
|
|
171
|
+
await app.fetchConversations();
|
|
172
|
+
app.renderChatHistory();
|
|
173
|
+
window.app.conversations.size
|
|
174
|
+
|
|
175
|
+
// 3. Check Claude Code availability
|
|
176
|
+
await fetch('/gm/api/discover/claude-code').then(r => r.json()).then(d => console.log('Claude Code available:', d.discovered?.length))
|
|
177
|
+
|
|
178
|
+
// 4. Manual import
|
|
179
|
+
await fetch('/gm/api/import/claude-code').then(r => r.json()).then(d => console.log('Import:', d))
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Expected Behavior
|
|
183
|
+
|
|
184
|
+
**After Fix:**
|
|
185
|
+
1. Page loads
|
|
186
|
+
2. Console shows [DEBUG] logs
|
|
187
|
+
3. Page title shows "GMGUI (XX chats)"
|
|
188
|
+
4. Sidebar shows conversation list
|
|
189
|
+
5. Can click conversation to view it
|
|
190
|
+
6. Can create new conversations
|
|
191
|
+
7. Can import Claude Code conversations
|
|
192
|
+
|
|
193
|
+
## If Still Stuck
|
|
194
|
+
|
|
195
|
+
1. **Collect information:**
|
|
196
|
+
- Output of all console commands above
|
|
197
|
+
- Screenshot of browser console showing all [DEBUG] logs
|
|
198
|
+
- Output of `echo $HOME` on remote server
|
|
199
|
+
- Output of `ls -la ~/.claude/projects/` on remote server
|
|
200
|
+
- Output of `ls -la ~/.gmgui/` on remote server
|
|
201
|
+
|
|
202
|
+
2. **Share these logs** for remote debugging
|
|
203
|
+
|
|
204
|
+
3. **Try manual steps:**
|
|
205
|
+
- In console: `await _debug.forceRefetch()`
|
|
206
|
+
- Then: `app.renderChatHistory()`
|
|
207
|
+
- Screenshot result
|
|
208
|
+
|
|
209
|
+
## Important Notes
|
|
210
|
+
|
|
211
|
+
- `~/.gmgui/data.db` - AgentGUI database (stores conversations)
|
|
212
|
+
- `~/.claude/projects/` - Claude Code storage (where conversations come from)
|
|
213
|
+
- `/gm/api/conversations` - Endpoint to get all conversations
|
|
214
|
+
- `/gm/api/discover/claude-code` - Find available Claude Code conversations
|
|
215
|
+
- `/gm/api/import/claude-code` - Import Claude Code conversations to AgentGUI
|
|
216
|
+
|
|
217
|
+
## Performance Tip
|
|
218
|
+
|
|
219
|
+
If you have lots of conversations (100+), they might load slowly. You can paginate by checking:
|
|
220
|
+
```javascript
|
|
221
|
+
// Check how many are in the list element
|
|
222
|
+
document.getElementById('chatList').children.length
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
If this is less than the API count, pagination is needed (future enhancement).
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -454,16 +454,30 @@ function onServerReady() {
|
|
|
454
454
|
console.log(`GMGUI running on http://localhost:${PORT}${BASE_URL}/`);
|
|
455
455
|
console.log(`Agents: ${discoveredAgents.map(a => a.name).join(', ') || 'none'}`);
|
|
456
456
|
console.log(`Hot reload: ${watch ? 'on' : 'off'}`);
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
457
|
+
|
|
458
|
+
// Run auto-import immediately
|
|
459
|
+
performAutoImport();
|
|
460
|
+
|
|
461
|
+
// Then run it every 30 seconds (constant automatic importing)
|
|
462
|
+
setInterval(performAutoImport, 30000);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function performAutoImport() {
|
|
466
|
+
try {
|
|
467
|
+
const imported = queries.importClaudeCodeConversations();
|
|
468
|
+
if (imported.length > 0) {
|
|
469
|
+
const importedCount = imported.filter(i => i.status === 'imported').length;
|
|
470
|
+
const skippedCount = imported.filter(i => i.status === 'skipped').length;
|
|
471
|
+
if (importedCount > 0) {
|
|
472
|
+
console.log(`[AUTO-IMPORT] Imported ${importedCount} new Claude Code conversations (${skippedCount} already exist)`);
|
|
473
|
+
// Broadcast to all connected clients that conversations were updated
|
|
474
|
+
broadcastSync({ type: 'conversations_updated', count: importedCount });
|
|
475
|
+
} else if (skippedCount > 0) {
|
|
476
|
+
// All conversations already imported, don't spam logs
|
|
477
|
+
}
|
|
466
478
|
}
|
|
479
|
+
} catch (err) {
|
|
480
|
+
console.error('[AUTO-IMPORT] Error:', err.message);
|
|
467
481
|
}
|
|
468
482
|
}
|
|
469
483
|
|
package/static/app.js
CHANGED
|
@@ -226,11 +226,20 @@ class GMGUIApp {
|
|
|
226
226
|
}
|
|
227
227
|
break;
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
case 'conversations_updated':
|
|
230
|
+
// Server notified us that new conversations were imported
|
|
231
|
+
console.log('[SYNC] Server imported', event.count, 'new conversations, refreshing...');
|
|
232
|
+
this.fetchConversations().then(() => this.renderChatHistory());
|
|
233
|
+
if (!fromBroadcast && this.broadcastChannel) {
|
|
234
|
+
this.broadcastChannel.postMessage(event);
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
|
|
238
|
+
case 'message_created':
|
|
239
|
+
if (!fromBroadcast && this.broadcastChannel) {
|
|
240
|
+
this.broadcastChannel.postMessage(event);
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
234
243
|
|
|
235
244
|
case 'session_updated':
|
|
236
245
|
if (event.status === 'completed' && event.message) {
|
|
@@ -450,7 +459,23 @@ class GMGUIApp {
|
|
|
450
459
|
if (this.conversations.size === 0) {
|
|
451
460
|
console.warn('[DEBUG] No conversations to display - showing empty state');
|
|
452
461
|
console.warn('[DEBUG] conversations map contents:', this.conversations);
|
|
453
|
-
|
|
462
|
+
|
|
463
|
+
// VISUAL DEBUG: Show debug info on page
|
|
464
|
+
const debugInfo = `
|
|
465
|
+
<div style="background: #fee; padding: 1rem; border: 1px solid #f99; border-radius: 0.5rem; margin-bottom: 1rem; font-family: monospace; font-size: 0.75rem;">
|
|
466
|
+
<strong style="color: #c00;">🔍 DEBUG INFO</strong><br>
|
|
467
|
+
Conversations: ${this.conversations.size}<br>
|
|
468
|
+
BASE_URL: ${BASE_URL}<br>
|
|
469
|
+
Width: ${window.innerWidth}px<br>
|
|
470
|
+
Sidebar: ${document.getElementById('sidebar')?.offsetHeight > 0 ? 'visible' : 'hidden'}<br>
|
|
471
|
+
<br>
|
|
472
|
+
<strong>To debug (F12 console):</strong><br>
|
|
473
|
+
• app.conversations.size<br>
|
|
474
|
+
• Array.from(app.conversations.keys()).slice(0,5)
|
|
475
|
+
</div>
|
|
476
|
+
`;
|
|
477
|
+
|
|
478
|
+
list.innerHTML = debugInfo + '<p style="color: var(--text-tertiary); font-size: 0.875rem; padding: 0.5rem;">No chats yet</p>';
|
|
454
479
|
return;
|
|
455
480
|
}
|
|
456
481
|
const sorted = Array.from(this.conversations.values()).sort(
|
|
@@ -1330,7 +1355,15 @@ function initializeApp() {
|
|
|
1330
1355
|
get selectedAgent() { return window.app.selectedAgent; },
|
|
1331
1356
|
get currentConversation() { return window.app.currentConversation; },
|
|
1332
1357
|
checkChatListElement() { return document.getElementById('chatList'); },
|
|
1333
|
-
checkChatListChildCount() { return document.getElementById('chatList')?.children?.length || 0; }
|
|
1358
|
+
checkChatListChildCount() { return document.getElementById('chatList')?.children?.length || 0; },
|
|
1359
|
+
async forceRefetch() {
|
|
1360
|
+
console.log('[FORCE] Forcing fetchConversations...');
|
|
1361
|
+
await window.app.fetchConversations();
|
|
1362
|
+
console.log('[FORCE] Conversations loaded:', window.app.conversations.size);
|
|
1363
|
+
window.app.renderChatHistory();
|
|
1364
|
+
console.log('[FORCE] renderChatHistory called');
|
|
1365
|
+
return window.app.conversations.size;
|
|
1366
|
+
}
|
|
1334
1367
|
};
|
|
1335
1368
|
|
|
1336
1369
|
console.log('[DEBUG] initializeApp: GMGUIApp created successfully');
|