agentgui 1.0.22 → 1.0.24
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/SIDEBAR_FIX_SUMMARY.md +111 -0
- package/package.json +1 -1
- package/static/app.js +65 -16
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Conversation Display Fix - Root Cause and Solution
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
Conversations were not visible in the AgentGUI on the remote server, even though:
|
|
5
|
+
- ✅ API was returning 83 conversations correctly
|
|
6
|
+
- ✅ Database had conversations stored
|
|
7
|
+
- ✅ App.js initialization logic was sound
|
|
8
|
+
|
|
9
|
+
## Root Cause
|
|
10
|
+
**The sidebar was hidden on narrow/mobile screens due to CSS responsive design.**
|
|
11
|
+
|
|
12
|
+
### CSS Behavior
|
|
13
|
+
The responsive CSS (at `styles.css` line 1181) applies at screens < 768px:
|
|
14
|
+
```css
|
|
15
|
+
@media (max-width: 768px) {
|
|
16
|
+
.sidebar {
|
|
17
|
+
transform: translateX(-100%); /* Hidden by default */
|
|
18
|
+
position: absolute;
|
|
19
|
+
}
|
|
20
|
+
.sidebar.open {
|
|
21
|
+
transform: translateX(0); /* Only visible with .open class */
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### What Was Happening
|
|
27
|
+
1. Page loads on narrow screen (or browser window narrower than 768px)
|
|
28
|
+
2. Conversations ARE fetched and loaded into the app ✅
|
|
29
|
+
3. renderChatHistory() IS called and renders conversation items ✅
|
|
30
|
+
4. BUT: The sidebar is hidden with `transform: translateX(-100%)` by default
|
|
31
|
+
5. Users can't see the conversation list because sidebar is off-screen
|
|
32
|
+
|
|
33
|
+
## Solution Implemented
|
|
34
|
+
Modified `init()` method in `static/app.js` to:
|
|
35
|
+
|
|
36
|
+
1. **Detect screen width** on page load
|
|
37
|
+
2. **On mobile/narrow screens (< 768px)**:
|
|
38
|
+
- Add the `open` class to sidebar
|
|
39
|
+
- This applies `transform: translateX(0)` which makes sidebar visible
|
|
40
|
+
3. **On desktop screens (≥ 768px)**:
|
|
41
|
+
- Ensure sidebar doesn't have `open` class
|
|
42
|
+
- Desktop CSS keeps sidebar visible without the class
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
const sidebar = document.getElementById('sidebar');
|
|
46
|
+
if (window.innerWidth >= 768 && sidebar) {
|
|
47
|
+
sidebar.classList.remove('open'); // Desktop: always visible
|
|
48
|
+
} else if (sidebar) {
|
|
49
|
+
sidebar.classList.add('open'); // Mobile: toggle visibility on
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Additional Improvements Made
|
|
54
|
+
|
|
55
|
+
### 1. Robust DOM Ready Check
|
|
56
|
+
Wrapped app instantiation in `initializeApp()` function that:
|
|
57
|
+
- Waits for `#chatList` element to be present
|
|
58
|
+
- Retries every 100ms if element not found
|
|
59
|
+
- Prevents errors if app loads before DOM
|
|
60
|
+
|
|
61
|
+
### 2. Enhanced Error Logging
|
|
62
|
+
Added detailed error checking in `fetchConversations()`:
|
|
63
|
+
- Check HTTP response status
|
|
64
|
+
- Log full error details and stack traces
|
|
65
|
+
- Warn if conversations size becomes 0
|
|
66
|
+
- Log response data for debugging
|
|
67
|
+
|
|
68
|
+
### 3. Window Width Logging
|
|
69
|
+
Added `[DEBUG] Init: Window width:` log to help diagnose screen size issues
|
|
70
|
+
|
|
71
|
+
## Testing Checklist
|
|
72
|
+
|
|
73
|
+
After deploying, verify:
|
|
74
|
+
|
|
75
|
+
- [ ] Open on desktop (> 768px width) - sidebar should be visible with conversations
|
|
76
|
+
- [ ] Open on mobile/narrow window (< 768px) - sidebar should be hidden but clickable via hamburger icon
|
|
77
|
+
- [ ] Check browser console - should see `[DEBUG]` logs showing:
|
|
78
|
+
- Window width
|
|
79
|
+
- Conversation count loaded
|
|
80
|
+
- chatList innerHTML length
|
|
81
|
+
- [ ] Page title should show "GMGUI (83 chats)" or similar
|
|
82
|
+
- [ ] Clicking conversation item should load it
|
|
83
|
+
- [ ] New conversations should appear immediately
|
|
84
|
+
|
|
85
|
+
## Files Modified
|
|
86
|
+
- `static/app.js` - Added sidebar visibility logic and improved initialization
|
|
87
|
+
|
|
88
|
+
## Commit
|
|
89
|
+
```
|
|
90
|
+
fix: Ensure sidebar is visible and conversations display on all screen sizes
|
|
91
|
+
|
|
92
|
+
- Made DOM ready check more robust with polling
|
|
93
|
+
- Moved app instantiation to safe initialization function
|
|
94
|
+
- Added window width logging to detect screen size issues
|
|
95
|
+
- Auto-open sidebar on mobile/narrow screens (< 768px)
|
|
96
|
+
- Ensure sidebar doesn't have 'open' class on desktop to prevent transform
|
|
97
|
+
- Enhanced fetchConversations error logging and checks
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Browser Compatibility
|
|
101
|
+
- Works on all screen sizes
|
|
102
|
+
- Responsive design preserved
|
|
103
|
+
- Mobile users can click hamburger icon to toggle sidebar
|
|
104
|
+
- Desktop users see full sidebar
|
|
105
|
+
|
|
106
|
+
## Next Steps if Issue Persists
|
|
107
|
+
1. Check browser console for `[DEBUG]` logs
|
|
108
|
+
2. Verify page title shows conversation count
|
|
109
|
+
3. Check window width log to confirm screen size detection
|
|
110
|
+
4. Verify `#chatList` element exists in DOM (F12 → Elements tab)
|
|
111
|
+
5. Check if any JavaScript errors prevent initialization
|
package/package.json
CHANGED
package/static/app.js
CHANGED
|
@@ -96,6 +96,18 @@ class GMGUIApp {
|
|
|
96
96
|
async init() {
|
|
97
97
|
console.log('[DEBUG] Init: Starting initialization');
|
|
98
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
|
+
|
|
99
111
|
this.loadSettings();
|
|
100
112
|
this.setupEventListeners();
|
|
101
113
|
await this.fetchHome();
|
|
@@ -330,20 +342,37 @@ class GMGUIApp {
|
|
|
330
342
|
console.log('[DEBUG] fetchConversations: Starting fetch from', BASE_URL + '/api/conversations');
|
|
331
343
|
const res = await fetch(BASE_URL + '/api/conversations');
|
|
332
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
|
+
|
|
333
351
|
const data = await res.json();
|
|
334
352
|
console.log('[DEBUG] fetchConversations response count:', data.conversations?.length);
|
|
335
|
-
|
|
353
|
+
|
|
336
354
|
if (data.conversations) {
|
|
355
|
+
console.log('[DEBUG] fetchConversations: About to clear and load conversations');
|
|
337
356
|
this.conversations.clear();
|
|
338
|
-
console.log('[DEBUG] fetchConversations: Cleared conversations map');
|
|
339
|
-
|
|
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
|
+
|
|
340
363
|
console.log('[DEBUG] Loaded conversations, total:', this.conversations.size);
|
|
341
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
|
+
}
|
|
342
369
|
} else {
|
|
343
370
|
console.warn('[DEBUG] fetchConversations: data.conversations is undefined or null');
|
|
371
|
+
console.warn('[DEBUG] fetchConversations: Full response:', data);
|
|
344
372
|
}
|
|
345
373
|
} catch (e) {
|
|
346
|
-
console.error('fetchConversations error:', e);
|
|
374
|
+
console.error('[DEBUG] fetchConversations error:', e);
|
|
375
|
+
console.error('[DEBUG] Error details:', e.message, e.stack);
|
|
347
376
|
}
|
|
348
377
|
}
|
|
349
378
|
|
|
@@ -1280,15 +1309,35 @@ function confirmFolderSelection() {
|
|
|
1280
1309
|
app.closeFolderBrowser();
|
|
1281
1310
|
}
|
|
1282
1311
|
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
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
|
+
}
|