agentgui 1.0.92 → 1.0.94
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/.prd +1 -0
- package/database.js +7 -5
- package/package.json +5 -3
- package/server.js +82 -4
- package/static/index.html +527 -75
- package/static/js/client.js +17 -10
- package/static/js/conversations.js +165 -9
- package/static/js/features.js +243 -0
- package/static/styles.css +46 -4
package/static/js/client.js
CHANGED
|
@@ -168,8 +168,10 @@ class AgentGUIClient {
|
|
|
168
168
|
themeToggle.addEventListener('click', () => this.toggleTheme());
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
window.addEventListener('create-new-conversation', (event) => {
|
|
172
|
+
const detail = event.detail || {};
|
|
173
|
+
this.createNewConversation(detail.workingDirectory, detail.title);
|
|
174
|
+
});
|
|
173
175
|
|
|
174
176
|
// Listen for conversation selection
|
|
175
177
|
window.addEventListener('conversation-selected', (event) => {
|
|
@@ -636,16 +638,17 @@ class AgentGUIClient {
|
|
|
636
638
|
/**
|
|
637
639
|
* Create a new empty conversation
|
|
638
640
|
*/
|
|
639
|
-
async createNewConversation() {
|
|
641
|
+
async createNewConversation(workingDirectory, title) {
|
|
640
642
|
try {
|
|
641
643
|
const agentId = this.ui.agentSelector?.value || 'claude-code';
|
|
644
|
+
const convTitle = title || 'New Conversation';
|
|
645
|
+
const body = { agentId, title: convTitle };
|
|
646
|
+
if (workingDirectory) body.workingDirectory = workingDirectory;
|
|
647
|
+
|
|
642
648
|
const response = await fetch(window.__BASE_URL + '/api/conversations', {
|
|
643
649
|
method: 'POST',
|
|
644
650
|
headers: { 'Content-Type': 'application/json' },
|
|
645
|
-
body: JSON.stringify(
|
|
646
|
-
agentId,
|
|
647
|
-
title: 'New Conversation'
|
|
648
|
-
})
|
|
651
|
+
body: JSON.stringify(body)
|
|
649
652
|
});
|
|
650
653
|
|
|
651
654
|
if (!response.ok) {
|
|
@@ -655,10 +658,13 @@ class AgentGUIClient {
|
|
|
655
658
|
const { conversation } = await response.json();
|
|
656
659
|
this.state.currentConversation = conversation;
|
|
657
660
|
|
|
658
|
-
// Refresh conversation list
|
|
659
661
|
await this.loadConversations();
|
|
660
662
|
|
|
661
|
-
|
|
663
|
+
if (window.conversationManager) {
|
|
664
|
+
window.conversationManager.loadConversations();
|
|
665
|
+
window.conversationManager.select(conversation.id);
|
|
666
|
+
}
|
|
667
|
+
|
|
662
668
|
if (this.ui.messageInput) {
|
|
663
669
|
this.ui.messageInput.value = '';
|
|
664
670
|
this.ui.messageInput.focus();
|
|
@@ -690,10 +696,11 @@ class AgentGUIClient {
|
|
|
690
696
|
// Clear output and display conversation header
|
|
691
697
|
const outputEl = document.getElementById('output');
|
|
692
698
|
if (outputEl) {
|
|
699
|
+
const wdInfo = conversation.workingDirectory ? ` • ${this.escapeHtml(conversation.workingDirectory)}` : '';
|
|
693
700
|
outputEl.innerHTML = `
|
|
694
701
|
<div class="conversation-header">
|
|
695
702
|
<h2>${this.escapeHtml(conversation.title || 'Conversation')}</h2>
|
|
696
|
-
<p class="text-secondary">${conversation.agentType || 'unknown'} • ${new Date(conversation.created_at).toLocaleDateString()}</p>
|
|
703
|
+
<p class="text-secondary">${conversation.agentType || 'unknown'} • ${new Date(conversation.created_at).toLocaleDateString()}${wdInfo}</p>
|
|
697
704
|
</div>
|
|
698
705
|
<div class="conversation-messages">
|
|
699
706
|
${this.renderMessages(messagesData.messages || [])}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Conversations Module
|
|
3
3
|
* Manages conversation list sidebar with real-time updates
|
|
4
|
+
* Includes folder browser for selecting working directory on new conversation
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
class ConversationManager {
|
|
@@ -12,23 +13,180 @@ class ConversationManager {
|
|
|
12
13
|
this.newBtn = document.querySelector('[data-new-conversation]');
|
|
13
14
|
this.sidebarEl = document.querySelector('[data-sidebar]');
|
|
14
15
|
|
|
16
|
+
this.folderBrowser = {
|
|
17
|
+
modal: null,
|
|
18
|
+
listEl: null,
|
|
19
|
+
breadcrumbEl: null,
|
|
20
|
+
currentPath: '~',
|
|
21
|
+
homePath: '~'
|
|
22
|
+
};
|
|
23
|
+
|
|
15
24
|
if (!this.listEl) return;
|
|
16
25
|
|
|
17
26
|
this.init();
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
async init() {
|
|
21
|
-
this.newBtn?.addEventListener('click', () => this.
|
|
30
|
+
this.newBtn?.addEventListener('click', () => this.openFolderBrowser());
|
|
22
31
|
this.loadConversations();
|
|
23
32
|
this.setupWebSocketListener();
|
|
33
|
+
this.setupFolderBrowser();
|
|
24
34
|
|
|
25
|
-
// Auto-refresh every 30 seconds
|
|
26
35
|
setInterval(() => this.loadConversations(), 30000);
|
|
27
36
|
}
|
|
28
37
|
|
|
38
|
+
setupFolderBrowser() {
|
|
39
|
+
this.folderBrowser.modal = document.getElementById('folderBrowserModal');
|
|
40
|
+
this.folderBrowser.listEl = document.getElementById('folderList');
|
|
41
|
+
this.folderBrowser.breadcrumbEl = document.getElementById('folderBreadcrumb');
|
|
42
|
+
|
|
43
|
+
if (!this.folderBrowser.modal) return;
|
|
44
|
+
|
|
45
|
+
const closeBtn = this.folderBrowser.modal.querySelector('[data-folder-close]');
|
|
46
|
+
const cancelBtn = this.folderBrowser.modal.querySelector('[data-folder-cancel]');
|
|
47
|
+
const selectBtn = this.folderBrowser.modal.querySelector('[data-folder-select]');
|
|
48
|
+
|
|
49
|
+
closeBtn?.addEventListener('click', () => this.closeFolderBrowser());
|
|
50
|
+
cancelBtn?.addEventListener('click', () => this.closeFolderBrowser());
|
|
51
|
+
selectBtn?.addEventListener('click', () => this.confirmFolderSelection());
|
|
52
|
+
|
|
53
|
+
this.folderBrowser.modal.addEventListener('click', (e) => {
|
|
54
|
+
if (e.target === this.folderBrowser.modal) this.closeFolderBrowser();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
this.fetchHomePath();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async fetchHomePath() {
|
|
61
|
+
try {
|
|
62
|
+
const res = await fetch((window.__BASE_URL || '') + '/api/home');
|
|
63
|
+
if (res.ok) {
|
|
64
|
+
const data = await res.json();
|
|
65
|
+
this.folderBrowser.homePath = data.home || '~';
|
|
66
|
+
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
console.error('Failed to fetch home path:', e);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
openFolderBrowser() {
|
|
73
|
+
if (!this.folderBrowser.modal) {
|
|
74
|
+
this.createNew();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.folderBrowser.currentPath = '~';
|
|
78
|
+
this.folderBrowser.modal.classList.add('visible');
|
|
79
|
+
this.loadFolders('~');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
closeFolderBrowser() {
|
|
83
|
+
this.folderBrowser.modal?.classList.remove('visible');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async loadFolders(dirPath) {
|
|
87
|
+
this.folderBrowser.currentPath = dirPath;
|
|
88
|
+
this.renderBreadcrumb(dirPath);
|
|
89
|
+
|
|
90
|
+
if (!this.folderBrowser.listEl) return;
|
|
91
|
+
this.folderBrowser.listEl.innerHTML = '<li class="folder-list-loading">Loading...</li>';
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
const res = await fetch((window.__BASE_URL || '') + '/api/folders', {
|
|
95
|
+
method: 'POST',
|
|
96
|
+
headers: { 'Content-Type': 'application/json' },
|
|
97
|
+
body: JSON.stringify({ path: dirPath })
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (!res.ok) {
|
|
101
|
+
const errData = await res.json().catch(() => ({}));
|
|
102
|
+
throw new Error(errData.error || `HTTP ${res.status}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const data = await res.json();
|
|
106
|
+
const folders = data.folders || [];
|
|
107
|
+
|
|
108
|
+
this.folderBrowser.listEl.innerHTML = '';
|
|
109
|
+
|
|
110
|
+
if (dirPath !== '~' && dirPath !== '/' && dirPath !== this.folderBrowser.homePath) {
|
|
111
|
+
const parentPath = this.getParentPath(dirPath);
|
|
112
|
+
const upItem = document.createElement('li');
|
|
113
|
+
upItem.className = 'folder-list-item';
|
|
114
|
+
upItem.innerHTML = '<span class="folder-list-item-icon">..</span><span class="folder-list-item-name">Parent Directory</span>';
|
|
115
|
+
upItem.addEventListener('click', () => this.loadFolders(parentPath));
|
|
116
|
+
this.folderBrowser.listEl.appendChild(upItem);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (folders.length === 0 && this.folderBrowser.listEl.children.length === 0) {
|
|
120
|
+
this.folderBrowser.listEl.innerHTML = '<li class="folder-list-empty">No subdirectories</li>';
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
for (const folder of folders) {
|
|
125
|
+
const li = document.createElement('li');
|
|
126
|
+
li.className = 'folder-list-item';
|
|
127
|
+
li.innerHTML = `<span class="folder-list-item-icon">📁</span><span class="folder-list-item-name">${this.escapeHtml(folder.name)}</span>`;
|
|
128
|
+
li.addEventListener('click', () => {
|
|
129
|
+
const expandedBase = dirPath === '~' ? this.folderBrowser.homePath : dirPath;
|
|
130
|
+
const newPath = expandedBase + '/' + folder.name;
|
|
131
|
+
this.loadFolders(newPath);
|
|
132
|
+
});
|
|
133
|
+
this.folderBrowser.listEl.appendChild(li);
|
|
134
|
+
}
|
|
135
|
+
} catch (err) {
|
|
136
|
+
console.error('Failed to load folders:', err);
|
|
137
|
+
this.folderBrowser.listEl.innerHTML = `<li class="folder-list-error">Error: ${this.escapeHtml(err.message)}</li>`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
getParentPath(dirPath) {
|
|
142
|
+
const expanded = dirPath === '~' ? this.folderBrowser.homePath : dirPath;
|
|
143
|
+
const parts = expanded.split('/').filter(Boolean);
|
|
144
|
+
if (parts.length <= 1) return '/';
|
|
145
|
+
parts.pop();
|
|
146
|
+
return '/' + parts.join('/');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
renderBreadcrumb(dirPath) {
|
|
150
|
+
if (!this.folderBrowser.breadcrumbEl) return;
|
|
151
|
+
|
|
152
|
+
const expanded = dirPath === '~' ? this.folderBrowser.homePath : dirPath;
|
|
153
|
+
const parts = expanded.split('/').filter(Boolean);
|
|
154
|
+
|
|
155
|
+
let html = '';
|
|
156
|
+
html += '<span class="folder-breadcrumb-segment" data-path="/">/ </span>';
|
|
157
|
+
|
|
158
|
+
let accumulated = '';
|
|
159
|
+
for (let i = 0; i < parts.length; i++) {
|
|
160
|
+
accumulated += '/' + parts[i];
|
|
161
|
+
const isLast = i === parts.length - 1;
|
|
162
|
+
html += '<span class="folder-breadcrumb-separator">/</span>';
|
|
163
|
+
html += `<span class="folder-breadcrumb-segment${isLast ? '' : ''}" data-path="${this.escapeHtml(accumulated)}">${this.escapeHtml(parts[i])}</span>`;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this.folderBrowser.breadcrumbEl.innerHTML = html;
|
|
167
|
+
|
|
168
|
+
this.folderBrowser.breadcrumbEl.querySelectorAll('.folder-breadcrumb-segment').forEach(seg => {
|
|
169
|
+
seg.addEventListener('click', () => {
|
|
170
|
+
const p = seg.dataset.path;
|
|
171
|
+
if (p) this.loadFolders(p);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
confirmFolderSelection() {
|
|
177
|
+
const currentPath = this.folderBrowser.currentPath;
|
|
178
|
+
const expanded = currentPath === '~' ? this.folderBrowser.homePath : currentPath;
|
|
179
|
+
this.closeFolderBrowser();
|
|
180
|
+
|
|
181
|
+
const dirName = expanded.split('/').filter(Boolean).pop() || 'root';
|
|
182
|
+
window.dispatchEvent(new CustomEvent('create-new-conversation', {
|
|
183
|
+
detail: { workingDirectory: expanded, title: dirName }
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
|
|
29
187
|
async loadConversations() {
|
|
30
188
|
try {
|
|
31
|
-
const res = await fetch('/
|
|
189
|
+
const res = await fetch((window.__BASE_URL || '') + '/api/conversations');
|
|
32
190
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
33
191
|
|
|
34
192
|
const data = await res.json();
|
|
@@ -51,7 +209,6 @@ class ConversationManager {
|
|
|
51
209
|
this.listEl.innerHTML = '';
|
|
52
210
|
this.emptyEl.style.display = 'none';
|
|
53
211
|
|
|
54
|
-
// Sort by most recent first
|
|
55
212
|
const sorted = [...this.conversations].sort((a, b) =>
|
|
56
213
|
new Date(b.createdAt || 0) - new Date(a.createdAt || 0)
|
|
57
214
|
);
|
|
@@ -71,10 +228,13 @@ class ConversationManager {
|
|
|
71
228
|
const title = conv.title || `Conversation ${conv.id.slice(0, 8)}`;
|
|
72
229
|
const timestamp = conv.created_at ? new Date(conv.created_at).toLocaleDateString() : 'Unknown';
|
|
73
230
|
const agent = conv.agentType || 'unknown';
|
|
231
|
+
const wd = conv.workingDirectory ? conv.workingDirectory.split('/').pop() : '';
|
|
232
|
+
const metaParts = [agent, timestamp];
|
|
233
|
+
if (wd) metaParts.push(wd);
|
|
74
234
|
|
|
75
235
|
li.innerHTML = `
|
|
76
236
|
<div class="conversation-item-title">${this.escapeHtml(title)}</div>
|
|
77
|
-
<div class="conversation-item-meta">${
|
|
237
|
+
<div class="conversation-item-meta">${metaParts.join(' \u2022 ')}</div>
|
|
78
238
|
`;
|
|
79
239
|
|
|
80
240
|
li.addEventListener('click', () => this.select(conv.id));
|
|
@@ -84,7 +244,6 @@ class ConversationManager {
|
|
|
84
244
|
select(convId) {
|
|
85
245
|
this.activeId = convId;
|
|
86
246
|
|
|
87
|
-
// Update active indicator
|
|
88
247
|
document.querySelectorAll('.conversation-item').forEach(item => {
|
|
89
248
|
item.classList.remove('active');
|
|
90
249
|
});
|
|
@@ -92,7 +251,6 @@ class ConversationManager {
|
|
|
92
251
|
const active = document.querySelector(`[data-conv-id="${convId}"]`);
|
|
93
252
|
if (active) active.classList.add('active');
|
|
94
253
|
|
|
95
|
-
// Emit event for client.js to handle
|
|
96
254
|
window.dispatchEvent(new CustomEvent('conversation-selected', {
|
|
97
255
|
detail: { conversationId: convId }
|
|
98
256
|
}));
|
|
@@ -110,7 +268,6 @@ class ConversationManager {
|
|
|
110
268
|
}
|
|
111
269
|
|
|
112
270
|
addConversation(conv) {
|
|
113
|
-
// Add to beginning (most recent)
|
|
114
271
|
this.conversations.unshift(conv);
|
|
115
272
|
this.render();
|
|
116
273
|
}
|
|
@@ -149,7 +306,6 @@ class ConversationManager {
|
|
|
149
306
|
}
|
|
150
307
|
}
|
|
151
308
|
|
|
152
|
-
// Initialize when DOM is ready
|
|
153
309
|
if (document.readyState === 'loading') {
|
|
154
310
|
document.addEventListener('DOMContentLoaded', () => {
|
|
155
311
|
window.conversationManager = new ConversationManager();
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Features Module
|
|
3
|
+
* Drag-and-drop file upload, fsbrowse file browser toggle, mobile sidebar
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
(function() {
|
|
7
|
+
const BASE = window.__BASE_URL || '';
|
|
8
|
+
let currentConversation = null;
|
|
9
|
+
let currentView = 'chat';
|
|
10
|
+
let dragCounter = 0;
|
|
11
|
+
|
|
12
|
+
function init() {
|
|
13
|
+
setupHamburgerMenu();
|
|
14
|
+
setupDragAndDrop();
|
|
15
|
+
setupViewToggle();
|
|
16
|
+
setupConversationListener();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// --- Hamburger Menu & Mobile Sidebar ---
|
|
20
|
+
function setupHamburgerMenu() {
|
|
21
|
+
const hamburger = document.querySelector('[data-hamburger]');
|
|
22
|
+
const sidebar = document.querySelector('[data-sidebar]');
|
|
23
|
+
const overlay = document.querySelector('[data-sidebar-overlay]');
|
|
24
|
+
|
|
25
|
+
if (!hamburger || !sidebar) return;
|
|
26
|
+
|
|
27
|
+
hamburger.addEventListener('click', function(e) {
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
const isOpen = sidebar.classList.contains('mobile-visible');
|
|
30
|
+
if (isOpen) {
|
|
31
|
+
closeSidebar();
|
|
32
|
+
} else {
|
|
33
|
+
openSidebar();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (overlay) {
|
|
38
|
+
overlay.addEventListener('click', closeSidebar);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function openSidebar() {
|
|
42
|
+
sidebar.classList.add('mobile-visible');
|
|
43
|
+
if (overlay) overlay.classList.add('visible');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function closeSidebar() {
|
|
47
|
+
sidebar.classList.remove('mobile-visible');
|
|
48
|
+
if (overlay) overlay.classList.remove('visible');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Close sidebar when conversation is selected (mobile)
|
|
52
|
+
window.addEventListener('conversation-selected', function() {
|
|
53
|
+
if (window.innerWidth <= 768) {
|
|
54
|
+
closeSidebar();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Close sidebar on window resize to desktop
|
|
59
|
+
window.addEventListener('resize', function() {
|
|
60
|
+
if (window.innerWidth > 768) {
|
|
61
|
+
closeSidebar();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// --- Drag and Drop File Upload ---
|
|
67
|
+
function setupDragAndDrop() {
|
|
68
|
+
const dropZone = document.querySelector('[data-drop-zone]');
|
|
69
|
+
const overlay = document.getElementById('dropZoneOverlay');
|
|
70
|
+
|
|
71
|
+
if (!dropZone || !overlay) return;
|
|
72
|
+
|
|
73
|
+
dropZone.addEventListener('dragenter', function(e) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
dragCounter++;
|
|
77
|
+
if (dragCounter === 1) {
|
|
78
|
+
overlay.classList.add('visible');
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
dropZone.addEventListener('dragover', function(e) {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
e.stopPropagation();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
dropZone.addEventListener('dragleave', function(e) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
e.stopPropagation();
|
|
90
|
+
dragCounter--;
|
|
91
|
+
if (dragCounter <= 0) {
|
|
92
|
+
dragCounter = 0;
|
|
93
|
+
overlay.classList.remove('visible');
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
dropZone.addEventListener('drop', function(e) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
e.stopPropagation();
|
|
100
|
+
dragCounter = 0;
|
|
101
|
+
overlay.classList.remove('visible');
|
|
102
|
+
|
|
103
|
+
if (!currentConversation) {
|
|
104
|
+
showToast('Select a conversation first', 'error');
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const files = e.dataTransfer.files;
|
|
109
|
+
if (!files || files.length === 0) return;
|
|
110
|
+
|
|
111
|
+
uploadFiles(files);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function uploadFiles(files) {
|
|
116
|
+
if (!currentConversation) {
|
|
117
|
+
showToast('No conversation selected', 'error');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const formData = new FormData();
|
|
122
|
+
for (let i = 0; i < files.length; i++) {
|
|
123
|
+
formData.append('file', files[i]);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
showToast('Uploading ' + files.length + ' file(s)...', 'info');
|
|
127
|
+
|
|
128
|
+
fetch(BASE + '/api/upload/' + currentConversation, {
|
|
129
|
+
method: 'POST',
|
|
130
|
+
body: formData
|
|
131
|
+
})
|
|
132
|
+
.then(function(res) { return res.json(); })
|
|
133
|
+
.then(function(data) {
|
|
134
|
+
if (data.ok) {
|
|
135
|
+
showToast(data.count + ' file(s) uploaded', 'success');
|
|
136
|
+
} else {
|
|
137
|
+
showToast('Upload failed: ' + (data.error || 'Unknown error'), 'error');
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
.catch(function(err) {
|
|
141
|
+
showToast('Upload failed: ' + err.message, 'error');
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function showToast(message, type) {
|
|
146
|
+
var existing = document.querySelector('.upload-toast');
|
|
147
|
+
if (existing) existing.remove();
|
|
148
|
+
|
|
149
|
+
var toast = document.createElement('div');
|
|
150
|
+
toast.className = 'upload-toast ' + (type || 'info');
|
|
151
|
+
toast.textContent = message;
|
|
152
|
+
document.body.appendChild(toast);
|
|
153
|
+
|
|
154
|
+
setTimeout(function() {
|
|
155
|
+
toast.style.opacity = '0';
|
|
156
|
+
setTimeout(function() { toast.remove(); }, 300);
|
|
157
|
+
}, 3000);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// --- View Toggle (Chat / Files) ---
|
|
161
|
+
function setupViewToggle() {
|
|
162
|
+
var bar = document.getElementById('viewToggleBar');
|
|
163
|
+
if (!bar) return;
|
|
164
|
+
|
|
165
|
+
var buttons = bar.querySelectorAll('.view-toggle-btn');
|
|
166
|
+
buttons.forEach(function(btn) {
|
|
167
|
+
btn.addEventListener('click', function() {
|
|
168
|
+
var view = btn.dataset.view;
|
|
169
|
+
switchView(view);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function switchView(view) {
|
|
175
|
+
currentView = view;
|
|
176
|
+
var bar = document.getElementById('viewToggleBar');
|
|
177
|
+
var chatArea = document.getElementById('output-scroll');
|
|
178
|
+
var execPanel = document.querySelector('.execution-panel');
|
|
179
|
+
var fileBrowser = document.getElementById('fileBrowserContainer');
|
|
180
|
+
var iframe = document.getElementById('fileBrowserIframe');
|
|
181
|
+
|
|
182
|
+
if (!bar) return;
|
|
183
|
+
|
|
184
|
+
// Update active button
|
|
185
|
+
bar.querySelectorAll('.view-toggle-btn').forEach(function(btn) {
|
|
186
|
+
btn.classList.toggle('active', btn.dataset.view === view);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
if (view === 'files') {
|
|
190
|
+
if (chatArea) chatArea.style.display = 'none';
|
|
191
|
+
if (execPanel) execPanel.style.display = 'none';
|
|
192
|
+
if (fileBrowser) {
|
|
193
|
+
fileBrowser.style.display = 'flex';
|
|
194
|
+
if (iframe && currentConversation) {
|
|
195
|
+
var src = BASE + '/files/' + currentConversation + '/';
|
|
196
|
+
if (iframe.src !== location.origin + src) {
|
|
197
|
+
iframe.src = src;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
if (chatArea) chatArea.style.display = '';
|
|
203
|
+
if (execPanel) execPanel.style.display = '';
|
|
204
|
+
if (fileBrowser) fileBrowser.style.display = 'none';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function updateViewToggleVisibility() {
|
|
209
|
+
var bar = document.getElementById('viewToggleBar');
|
|
210
|
+
if (!bar) return;
|
|
211
|
+
|
|
212
|
+
// Show toggle bar only when a conversation is selected
|
|
213
|
+
if (currentConversation) {
|
|
214
|
+
bar.style.display = 'flex';
|
|
215
|
+
} else {
|
|
216
|
+
bar.style.display = 'none';
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// --- Conversation Listener ---
|
|
221
|
+
function setupConversationListener() {
|
|
222
|
+
window.addEventListener('conversation-selected', function(e) {
|
|
223
|
+
currentConversation = e.detail.conversationId;
|
|
224
|
+
updateViewToggleVisibility();
|
|
225
|
+
// If currently in files view, reload the iframe
|
|
226
|
+
if (currentView === 'files') {
|
|
227
|
+
switchView('files');
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// Also listen for conversation created
|
|
232
|
+
window.addEventListener('create-new-conversation', function() {
|
|
233
|
+
// Will be updated when conversation-selected fires
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Initialize when DOM is ready
|
|
238
|
+
if (document.readyState === 'loading') {
|
|
239
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
240
|
+
} else {
|
|
241
|
+
init();
|
|
242
|
+
}
|
|
243
|
+
})();
|
package/static/styles.css
CHANGED
|
@@ -1201,18 +1201,21 @@ html, body {
|
|
|
1201
1201
|
/* Responsive design */
|
|
1202
1202
|
@media (max-width: 768px) {
|
|
1203
1203
|
.sidebar {
|
|
1204
|
-
position:
|
|
1204
|
+
position: fixed;
|
|
1205
1205
|
left: 0;
|
|
1206
1206
|
top: 0;
|
|
1207
1207
|
bottom: 0;
|
|
1208
|
-
z-index:
|
|
1208
|
+
z-index: 1000;
|
|
1209
1209
|
width: 280px;
|
|
1210
1210
|
transform: translateX(-100%);
|
|
1211
|
-
box-shadow:
|
|
1211
|
+
box-shadow: none;
|
|
1212
|
+
transition: transform 0.3s ease;
|
|
1212
1213
|
}
|
|
1213
1214
|
|
|
1214
|
-
.sidebar.open
|
|
1215
|
+
.sidebar.open,
|
|
1216
|
+
.sidebar.mobile-visible {
|
|
1215
1217
|
transform: translateX(0);
|
|
1218
|
+
box-shadow: var(--shadow-lg);
|
|
1216
1219
|
}
|
|
1217
1220
|
|
|
1218
1221
|
.sidebar-toggle {
|
|
@@ -1229,6 +1232,7 @@ html, body {
|
|
|
1229
1232
|
|
|
1230
1233
|
.chat-input-section {
|
|
1231
1234
|
padding: 1rem 1.5rem;
|
|
1235
|
+
padding-bottom: calc(1rem + env(safe-area-inset-bottom));
|
|
1232
1236
|
}
|
|
1233
1237
|
|
|
1234
1238
|
.chat-footer {
|
|
@@ -1846,3 +1850,41 @@ p code {
|
|
|
1846
1850
|
word-wrap: break-word;
|
|
1847
1851
|
line-height: 1.5;
|
|
1848
1852
|
}
|
|
1853
|
+
|
|
1854
|
+
/* Touch-friendly interactive elements */
|
|
1855
|
+
@media (pointer: coarse) {
|
|
1856
|
+
.chat-item,
|
|
1857
|
+
.new-chat-btn,
|
|
1858
|
+
.settings-btn,
|
|
1859
|
+
.action-btn,
|
|
1860
|
+
.gm-btn,
|
|
1861
|
+
.chat-option-btn,
|
|
1862
|
+
.close-btn {
|
|
1863
|
+
min-height: 44px;
|
|
1864
|
+
min-width: 44px;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
.chat-input {
|
|
1868
|
+
font-size: 16px;
|
|
1869
|
+
min-height: 44px;
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
.chat-messages {
|
|
1873
|
+
-webkit-overflow-scrolling: touch;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
/* Safe area padding for notched phones */
|
|
1878
|
+
@supports (padding-top: env(safe-area-inset-top)) {
|
|
1879
|
+
#app {
|
|
1880
|
+
padding-top: env(safe-area-inset-top);
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
.chat-input-section {
|
|
1884
|
+
padding-bottom: calc(1rem + env(safe-area-inset-bottom));
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
.chat-footer {
|
|
1888
|
+
padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
|
|
1889
|
+
}
|
|
1890
|
+
}
|