agentgui 1.0.821 → 1.0.823
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/CHANGELOG.md +17 -0
- package/package.json +1 -1
- package/static/index.html +4 -1
- package/static/js/conv-list-renderer.js +197 -0
- package/static/js/conv-sidebar-clone.js +91 -0
- package/static/js/conversations.js +1 -0
- package/static/js/ui-components-rendering.js +61 -182
- package/static/js/ui-components.js +88 -187
- package/static/js/websocket-manager.js +107 -642
- package/static/js/ws-core.js +162 -0
- package/static/js/ws-latency.js +88 -0
- package/.prd +0 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
### Refactor
|
|
4
|
+
- Split `conversations.js` (737L) into 4 files: conversations.js (117L), conv-sidebar-actions.js (185L), conv-sidebar-clone.js (92L), conv-list-renderer.js (198L)
|
|
5
|
+
- Split `websocket-manager.js` (643L) into 3 files: ws-core.js (163L), ws-latency.js (89L), websocket-manager.js (108L)
|
|
6
|
+
- Split `ui-components.js` (370L) into 2 files: ui-components.js (89L), ui-components-rendering.js (63L)
|
|
7
|
+
- Split `agent-auth.js` into agent-auth.js (147L) and agent-auth-oauth.js (160L)
|
|
8
|
+
- Deleted dead code: event-filter.js (zero external references)
|
|
9
|
+
- Updated index.html script load order for all new split files
|
|
10
|
+
|
|
11
|
+
## 2026-04-11
|
|
12
|
+
- refactor: split conversations.js (742L→116L) into conv-sidebar-actions.js (prototype extension: drag/drop, bulk actions, folder browser), conv-list-renderer.js (loadConversations, render, vnode), conv-sidebar-clone.js (clone UI, delete-all); all ≤200 lines
|
|
13
|
+
- refactor: split websocket-manager.js (643L) into ws-core.js (class constructor, connect, onOpen, onMessage, reconnect), websocket-manager.js (sendMessage, subscriptions, state); ws-latency/connection/heartbeat empty stubs deleted
|
|
14
|
+
- refactor: split event-filter.js into event-filter.js + event-filter-config.js (window export/CSV/Markdown helpers)
|
|
15
|
+
- refactor: split agent-auth.js into agent-auth.js + agent-auth-oauth.js (IIFE, OAuth modal flows)
|
|
16
|
+
- refactor: fix index.html script load order — ws-core.js before websocket-manager.js; remove empty stub script tags (ws-connection, ws-latency, ws-heartbeat)
|
|
17
|
+
|
|
1
18
|
## 2026-04-11
|
|
2
19
|
- refactor: split jsonl-watcher.js parse/event logic into jsonl-parser.js; watcher retains file watching/polling only
|
|
3
20
|
- refactor: split tool-version.js into tool-version-check.js (sync) and tool-version-fetch.js (async/network)
|
package/package.json
CHANGED
package/static/index.html
CHANGED
|
@@ -294,7 +294,11 @@
|
|
|
294
294
|
<script defer src="/gm/js/terminal-machine.js"></script>
|
|
295
295
|
<script defer src="/gm/js/conversations.js"></script>
|
|
296
296
|
<script defer src="/gm/js/conv-sidebar-actions.js"></script>
|
|
297
|
+
<script defer src="/gm/js/conv-list-renderer.js"></script>
|
|
298
|
+
<script defer src="/gm/js/conv-sidebar-clone.js"></script>
|
|
297
299
|
<script defer src="/gm/lib/msgpackr.min.js"></script>
|
|
300
|
+
<script defer src="/gm/js/ws-core.js"></script>
|
|
301
|
+
<script defer src="/gm/js/ws-latency.js"></script>
|
|
298
302
|
<script defer src="/gm/js/websocket-manager.js"></script>
|
|
299
303
|
<script defer src="/gm/js/ws-client.js"></script>
|
|
300
304
|
<script defer src="/gm/js/syntax-highlighter.js"></script>
|
|
@@ -310,7 +314,6 @@
|
|
|
310
314
|
<script defer src="/gm/js/voice.js"></script>
|
|
311
315
|
<script defer src="/gm/js/pm2-monitor.js"></script>
|
|
312
316
|
<script defer src="/gm/js/event-filter-config.js"></script>
|
|
313
|
-
<script defer src="/gm/js/event-filter.js"></script>
|
|
314
317
|
<script defer src="/gm/js/client.js"></script>
|
|
315
318
|
<script defer src="/gm/js/features.js"></script>
|
|
316
319
|
<script defer src="/gm/js/agent-auth.js"></script>
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Object.assign(ConversationManager.prototype, {
|
|
2
|
+
async loadConversations() {
|
|
3
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'LOAD_START' });
|
|
4
|
+
try {
|
|
5
|
+
const base = window.__BASE_URL || '/gm';
|
|
6
|
+
const res = await fetch(base + '/api/conversations');
|
|
7
|
+
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
8
|
+
const data = await res.json();
|
|
9
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'LOAD_DONE', conversations: data.conversations || [] });
|
|
10
|
+
const cliStreaming = window.agentGuiClient?.state?.streamingConversations;
|
|
11
|
+
for (const conv of this.conversations) {
|
|
12
|
+
const streaming = conv.isStreaming === 1 || conv.isStreaming === true || (cliStreaming ? cliStreaming.has(conv.id) : false);
|
|
13
|
+
window.convListMachineAPI?.send({ type: streaming ? 'SET_STREAMING' : 'CLEAR_STREAMING', id: conv.id });
|
|
14
|
+
}
|
|
15
|
+
this.render();
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error('Failed to load conversations:', err);
|
|
18
|
+
window.convListMachineAPI?.send({ type: 'LOAD_ERROR' });
|
|
19
|
+
if (this.conversations.length === 0) this.showEmpty('Failed to load conversations');
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
_convVnode(conv) {
|
|
24
|
+
const h = window.webjsx?.createElement;
|
|
25
|
+
if (!h) return null;
|
|
26
|
+
const isActive = conv.id === this.activeId;
|
|
27
|
+
const isStreaming = this.streamingConversations.has(conv.id);
|
|
28
|
+
const title = conv.title || `Conversation ${conv.id.slice(0, 8)}`;
|
|
29
|
+
const timestamp = conv.created_at ? new Date(conv.created_at).toLocaleDateString() : 'Unknown';
|
|
30
|
+
const agent = this.getAgentDisplayName(conv.agentId || conv.agentType);
|
|
31
|
+
const modelLabel = this.formatModelLabel(conv.model);
|
|
32
|
+
const wd = conv.workingDirectory ? pathBasename(conv.workingDirectory) : '';
|
|
33
|
+
const metaParts = [agent + modelLabel, timestamp];
|
|
34
|
+
if (wd) metaParts.push(wd);
|
|
35
|
+
const badge = isStreaming ? h('span', { class: 'conversation-streaming-badge', title: 'Streaming in progress' }, h('span', { class: 'streaming-dot' })) : null;
|
|
36
|
+
const dragAttrs = conv.pinned ? { draggable: 'true', 'data-drag-conv': conv.id } : {};
|
|
37
|
+
return h('li', { class: 'conversation-item' + (isActive ? ' active' : '') + (conv.pinned ? ' pinned' : ''), 'data-conv-id': conv.id, ...dragAttrs },
|
|
38
|
+
h('div', { class: 'conversation-item-content' },
|
|
39
|
+
h('div', { class: 'conversation-item-title' }, ...(badge ? [badge, title] : [title])),
|
|
40
|
+
h('div', { class: 'conversation-item-meta' }, metaParts.join(' • '))
|
|
41
|
+
),
|
|
42
|
+
h('input', { type: 'checkbox', class: 'conversation-item-checkbox', 'data-bulk-check': conv.id, title: 'Select for bulk action', onclick: 'event.stopPropagation()' }),
|
|
43
|
+
h('button', { class: 'conversation-item-export', title: 'Export as markdown', 'data-export-conv': conv.id },
|
|
44
|
+
h('svg', { width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', 'stroke-width': '2' },
|
|
45
|
+
h('path', { d: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4' }),
|
|
46
|
+
h('polyline', { points: '7 10 12 15 17 10' }),
|
|
47
|
+
h('line', { x1: '12', y1: '15', x2: '12', y2: '3' }))),
|
|
48
|
+
h('button', { class: 'conversation-item-archive', title: 'Archive conversation', 'data-archive-conv': conv.id },
|
|
49
|
+
h('svg', { width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', 'stroke-width': '2' },
|
|
50
|
+
h('path', { d: 'M21 8v13H3V8' }), h('path', { d: 'M1 3h22v5H1z' }), h('path', { d: 'M10 12h4' }))),
|
|
51
|
+
h('button', { class: 'conversation-item-delete', title: 'Delete conversation', 'data-delete-conv': conv.id },
|
|
52
|
+
h('svg', { width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', 'stroke-width': '2' },
|
|
53
|
+
h('polyline', { points: '3 6 5 6 21 6' }),
|
|
54
|
+
h('path', { d: 'M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2' })))
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
render() {
|
|
59
|
+
if (!this.listEl) return;
|
|
60
|
+
if (this.conversations.length === 0) { this.showEmpty(); return; }
|
|
61
|
+
this.emptyEl.style.display = 'none';
|
|
62
|
+
const sorted = [...this.conversations].sort((a, b) => new Date(b.createdAt || 0) - new Date(a.createdAt || 0));
|
|
63
|
+
if (window.webjsx?.applyDiff) {
|
|
64
|
+
window.webjsx.applyDiff(this.listEl, sorted.map(conv => this._convVnode(conv)).filter(Boolean));
|
|
65
|
+
} else {
|
|
66
|
+
this._renderFallback(sorted);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
_renderFallback(sorted) {
|
|
71
|
+
const existingMap = {};
|
|
72
|
+
for (const child of Array.from(this.listEl.children)) {
|
|
73
|
+
if (child.dataset.convId) existingMap[child.dataset.convId] = child;
|
|
74
|
+
}
|
|
75
|
+
const frag = document.createDocumentFragment();
|
|
76
|
+
for (const conv of sorted) {
|
|
77
|
+
const el = existingMap[conv.id] || document.createElement('li');
|
|
78
|
+
el.className = 'conversation-item' + (conv.id === this.activeId ? ' active' : '');
|
|
79
|
+
el.dataset.convId = conv.id;
|
|
80
|
+
delete existingMap[conv.id];
|
|
81
|
+
frag.appendChild(el);
|
|
82
|
+
}
|
|
83
|
+
for (const orphan of Object.values(existingMap)) orphan.remove();
|
|
84
|
+
this.listEl.appendChild(frag);
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
async confirmDelete(convId, title) {
|
|
88
|
+
const confirmed = await window.UIDialog.confirm(`Delete conversation "${title || 'Untitled'}"?\n\nThis will also delete any associated Claude Code session data. This action cannot be undone.`, 'Delete Conversation');
|
|
89
|
+
if (!confirmed) return;
|
|
90
|
+
try {
|
|
91
|
+
await window.wsClient.rpc('conv.del', { id: convId });
|
|
92
|
+
this.deleteConversation(convId);
|
|
93
|
+
} catch (err) {
|
|
94
|
+
window.UIDialog.alert('Failed to delete conversation: ' + (err.message || 'Unknown error'), 'Error');
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
select(convId) {
|
|
99
|
+
const result = window.ConversationState?.selectConversation(convId, 'user_click', 1) || { success: false };
|
|
100
|
+
if (!result.success && result.reason !== 'already_selected') { console.error('[ConvMgr] activeId mutation rejected:', result.reason); return; }
|
|
101
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'SELECT', id: convId });
|
|
102
|
+
document.querySelectorAll('.conversation-item').forEach(item => item.classList.remove('active'));
|
|
103
|
+
const active = document.querySelector(`[data-conv-id="${convId}"]`);
|
|
104
|
+
if (active) active.classList.add('active');
|
|
105
|
+
window.dispatchEvent(new CustomEvent('conversation-selected', { detail: { conversationId: convId } }));
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
createNew() {
|
|
109
|
+
window.dispatchEvent(new CustomEvent('preparing-new-conversation'));
|
|
110
|
+
window.dispatchEvent(new CustomEvent('create-new-conversation'));
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
showEmpty(message = 'No conversations yet') {
|
|
114
|
+
if (!this.listEl) return;
|
|
115
|
+
this.listEl.innerHTML = '';
|
|
116
|
+
this.emptyEl.textContent = message;
|
|
117
|
+
this.emptyEl.style.display = 'block';
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
addConversation(conv) {
|
|
121
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'ADD', conversation: conv });
|
|
122
|
+
this.render();
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
updateConversation(convId, updates) {
|
|
126
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'UPDATE', conversation: Object.assign({ id: convId }, updates) });
|
|
127
|
+
this.render();
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
deleteConversation(convId) {
|
|
131
|
+
const wasActive = this.activeId === convId;
|
|
132
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'DELETE', id: convId });
|
|
133
|
+
if (wasActive) { window.ConversationState?.deleteConversation(convId, 1); window.dispatchEvent(new CustomEvent('conversation-deselected')); }
|
|
134
|
+
this.render();
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
getSelectedIds() {
|
|
138
|
+
return [...this.listEl.querySelectorAll('.conversation-item-checkbox:checked')].map(cb => cb.dataset.bulkCheck);
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
async bulkArchive() {
|
|
142
|
+
const ids = this.getSelectedIds();
|
|
143
|
+
if (ids.length === 0) return;
|
|
144
|
+
if (!await window.UIDialog?.confirm(`Archive ${ids.length} conversation(s)?`, 'Bulk Archive')) return;
|
|
145
|
+
const base = window.__BASE_URL || '';
|
|
146
|
+
for (const id of ids) {
|
|
147
|
+
try { await fetch(`${base}/api/conversations/${id}/archive`, { method: 'POST' }); } catch (_) {}
|
|
148
|
+
this.deleteConversation(id);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
async bulkDelete() {
|
|
153
|
+
const ids = this.getSelectedIds();
|
|
154
|
+
if (ids.length === 0) return;
|
|
155
|
+
if (!await window.UIDialog?.confirm(`Permanently delete ${ids.length} conversation(s)?`, 'Bulk Delete')) return;
|
|
156
|
+
for (const id of ids) this.confirmDelete(id, '');
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
async exportConversation(convId) {
|
|
160
|
+
try {
|
|
161
|
+
const result = await window.wsClient.rpc('conv.export', { id: convId, format: 'markdown' });
|
|
162
|
+
const blob = new Blob([result.markdown], { type: 'text/markdown' });
|
|
163
|
+
const url = URL.createObjectURL(blob);
|
|
164
|
+
const a = document.createElement('a');
|
|
165
|
+
a.href = url; a.download = (result.title || 'conversation').replace(/[^a-zA-Z0-9_-]/g, '_') + '.md';
|
|
166
|
+
a.click(); URL.revokeObjectURL(url);
|
|
167
|
+
} catch (e) { console.error('[export] Failed:', e.message); }
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
async archiveConversation(convId) {
|
|
171
|
+
try {
|
|
172
|
+
const resp = await fetch(`${window.__BASE_URL || ''}/api/conversations/${convId}/archive`, { method: 'POST' });
|
|
173
|
+
if (!resp.ok) return;
|
|
174
|
+
this.deleteConversation(convId);
|
|
175
|
+
} catch (e) { console.error('[archive] Failed:', e.message); }
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
setupWebSocketListener() {
|
|
179
|
+
window.addEventListener('ws-message', (event) => {
|
|
180
|
+
const msg = event.detail;
|
|
181
|
+
if (msg.type === 'conversation_created') { this.addConversation(msg.conversation); }
|
|
182
|
+
else if (msg.type === 'conversation_updated') { this.updateConversation(msg.conversation.id, msg.conversation); }
|
|
183
|
+
else if (msg.type === 'conversation_deleted') { this.deleteConversation(msg.conversationId); }
|
|
184
|
+
else if (msg.type === 'all_conversations_deleted') {
|
|
185
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'CLEAR_ALL' });
|
|
186
|
+
window.ConversationState?.clear('all_deleted');
|
|
187
|
+
this.showEmpty('No conversations yet');
|
|
188
|
+
} else if (msg.type === 'streaming_start' && msg.conversationId) {
|
|
189
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'SET_STREAMING', id: msg.conversationId });
|
|
190
|
+
this.render();
|
|
191
|
+
} else if ((msg.type === 'streaming_complete' || msg.type === 'streaming_error') && msg.conversationId) {
|
|
192
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'CLEAR_STREAMING', id: msg.conversationId });
|
|
193
|
+
this.render();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Object.assign(ConversationManager.prototype, {
|
|
2
|
+
setupDeleteAllButton() {
|
|
3
|
+
this.deleteAllBtn = document.getElementById('deleteAllConversationsBtn');
|
|
4
|
+
if (!this.deleteAllBtn) return;
|
|
5
|
+
this.deleteAllBtn.addEventListener('click', () => this.confirmDeleteAll());
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
async confirmDeleteAll() {
|
|
9
|
+
if (this.conversations.length === 0) { window.UIDialog.alert('No conversations to delete', 'Information'); return; }
|
|
10
|
+
const confirmed = await window.UIDialog.confirm(`Delete all ${this.conversations.length} conversation(s) and associated Claude Code artifacts?\n\nThis action cannot be undone.`, 'Delete All Conversations');
|
|
11
|
+
if (!confirmed) return;
|
|
12
|
+
try {
|
|
13
|
+
this.deleteAllBtn.disabled = true;
|
|
14
|
+
await window.wsClient.rpc('conv.del.all', {});
|
|
15
|
+
if (window.convListMachineAPI) window.convListMachineAPI.send({ type: 'CLEAR_ALL' });
|
|
16
|
+
window.ConversationState?.clear('delete_all');
|
|
17
|
+
window.dispatchEvent(new CustomEvent('conversation-deselected'));
|
|
18
|
+
this.render();
|
|
19
|
+
} catch (err) {
|
|
20
|
+
console.error('[ConversationManager] Delete all error:', err);
|
|
21
|
+
window.UIDialog.alert('Failed to delete all conversations: ' + (err.message || 'Unknown error'), 'Error');
|
|
22
|
+
} finally { this.deleteAllBtn.disabled = false; }
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
setupCloneUI() {
|
|
26
|
+
this.cloneBtn = document.getElementById('cloneRepoBtn');
|
|
27
|
+
this.cloneBar = document.getElementById('cloneInputBar');
|
|
28
|
+
this.cloneInput = document.getElementById('cloneRepoInput');
|
|
29
|
+
this.cloneGoBtn = document.getElementById('cloneGoBtn');
|
|
30
|
+
this.cloneCancelBtn = document.getElementById('cloneCancelBtn');
|
|
31
|
+
if (!this.cloneBtn || !this.cloneBar) return;
|
|
32
|
+
this.cloneBtn.addEventListener('click', () => this.toggleCloneBar());
|
|
33
|
+
this.cloneCancelBtn?.addEventListener('click', () => this.hideCloneBar());
|
|
34
|
+
this.cloneGoBtn?.addEventListener('click', () => this.performClone());
|
|
35
|
+
this.cloneInput?.addEventListener('keydown', (e) => { if (e.key === 'Enter') this.performClone(); if (e.key === 'Escape') this.hideCloneBar(); });
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
toggleCloneBar() {
|
|
39
|
+
if (!this.cloneBar) return;
|
|
40
|
+
if (this.cloneBar.style.display !== 'none') { this.hideCloneBar(); return; }
|
|
41
|
+
this.cloneBar.style.display = 'flex';
|
|
42
|
+
this.cloneInput.value = '';
|
|
43
|
+
this.cloneInput.focus();
|
|
44
|
+
this.removeCloneStatus();
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
hideCloneBar() {
|
|
48
|
+
if (this.cloneBar) this.cloneBar.style.display = 'none';
|
|
49
|
+
this.removeCloneStatus();
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
removeCloneStatus() {
|
|
53
|
+
const existing = this.sidebarEl?.querySelector('.clone-status');
|
|
54
|
+
if (existing) existing.remove();
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
showCloneStatus(message, type) {
|
|
58
|
+
this.removeCloneStatus();
|
|
59
|
+
const statusEl = document.createElement('div');
|
|
60
|
+
statusEl.className = `clone-status ${type}`;
|
|
61
|
+
statusEl.textContent = message;
|
|
62
|
+
if (this.cloneBar && this.cloneBar.parentNode) this.cloneBar.parentNode.insertBefore(statusEl, this.cloneBar.nextSibling);
|
|
63
|
+
if (type === 'clone-success' || type === 'clone-error') setTimeout(() => statusEl.remove(), 5000);
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
async performClone() {
|
|
67
|
+
const repo = (this.cloneInput?.value || '').trim();
|
|
68
|
+
if (!repo) return;
|
|
69
|
+
if (!/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(repo)) { this.showCloneStatus('Invalid format. Use org/repo', 'clone-error'); return; }
|
|
70
|
+
this.cloneGoBtn.disabled = true;
|
|
71
|
+
this.cloneInput.disabled = true;
|
|
72
|
+
this.showCloneStatus(`Cloning ${repo}...`, 'cloning');
|
|
73
|
+
try {
|
|
74
|
+
const data = await window.wsClient.rpc('clone', { repo });
|
|
75
|
+
this.showCloneStatus(`Cloned ${data.name}`, 'clone-success');
|
|
76
|
+
this.hideCloneBar();
|
|
77
|
+
window.dispatchEvent(new CustomEvent('create-new-conversation', { detail: { workingDirectory: data.path, title: data.name } }));
|
|
78
|
+
} catch (err) {
|
|
79
|
+
this.showCloneStatus(err.message || 'Clone failed', 'clone-error');
|
|
80
|
+
} finally {
|
|
81
|
+
if (this.cloneGoBtn) this.cloneGoBtn.disabled = false;
|
|
82
|
+
if (this.cloneInput) this.cloneInput.disabled = false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (document.readyState === 'loading') {
|
|
88
|
+
document.addEventListener('DOMContentLoaded', () => { window.conversationManager = new ConversationManager(); });
|
|
89
|
+
} else {
|
|
90
|
+
window.conversationManager = new ConversationManager();
|
|
91
|
+
}
|
|
@@ -1,183 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
html += `<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
</div>
|
|
62
|
-
</details>
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
return container;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
UIComponents.createInput = function(config = {}) {
|
|
69
|
-
const {
|
|
70
|
-
type = 'text',
|
|
71
|
-
name = '',
|
|
72
|
-
label = '',
|
|
73
|
-
placeholder = '',
|
|
74
|
-
value = '',
|
|
75
|
-
required = false
|
|
76
|
-
} = config;
|
|
77
|
-
|
|
78
|
-
const container = document.createElement('div');
|
|
79
|
-
container.className = 'form-group mb-4';
|
|
80
|
-
|
|
81
|
-
let html = '';
|
|
82
|
-
if (label) {
|
|
83
|
-
html += `<label class="block text-sm font-medium mb-2">${UIComponents.escapeHtml(label)}</label>`;
|
|
1
|
+
Object.assign(UIComponents, {
|
|
2
|
+
escapeHtml(text) { return window._escHtml ? window._escHtml(String(text)) : String(text).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); },
|
|
3
|
+
|
|
4
|
+
copyToClipboard(text) {
|
|
5
|
+
return navigator.clipboard.writeText(text).catch(() => false);
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
downloadFile(data, filename, mimeType = 'text/plain') {
|
|
9
|
+
const blob = new Blob([data], { type: mimeType });
|
|
10
|
+
const url = URL.createObjectURL(blob);
|
|
11
|
+
const link = document.createElement('a');
|
|
12
|
+
link.href = url; link.download = filename;
|
|
13
|
+
document.body.appendChild(link); link.click(); document.body.removeChild(link);
|
|
14
|
+
URL.revokeObjectURL(url);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
createInput(config = {}) {
|
|
18
|
+
const { type = 'text', name = '', label = '', placeholder = '', value = '', required = false } = config;
|
|
19
|
+
const container = document.createElement('div');
|
|
20
|
+
container.className = 'form-group mb-4';
|
|
21
|
+
let html = '';
|
|
22
|
+
if (label) html += `<label class="block text-sm font-medium mb-2">${UIComponents.escapeHtml(label)}</label>`;
|
|
23
|
+
html += `<input type="${type}" name="${name}" placeholder="${UIComponents.escapeHtml(placeholder)}" value="${UIComponents.escapeHtml(value)}" ${required ? 'required' : ''} class="input input-block input-solid" />`;
|
|
24
|
+
container.innerHTML = html;
|
|
25
|
+
return container;
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
createSelect(config = {}) {
|
|
29
|
+
const { name = '', label = '', options = [], value = '', required = false } = config;
|
|
30
|
+
const container = document.createElement('div');
|
|
31
|
+
container.className = 'form-group mb-4';
|
|
32
|
+
let html = '';
|
|
33
|
+
if (label) html += `<label class="block text-sm font-medium mb-2">${UIComponents.escapeHtml(label)}</label>`;
|
|
34
|
+
html += `<select name="${name}" ${required ? 'required' : ''} class="select select-block select-solid">${options.map(opt => `<option value="${opt.value}" ${opt.value === value ? 'selected' : ''}>${UIComponents.escapeHtml(opt.label)}</option>`).join('')}</select>`;
|
|
35
|
+
container.innerHTML = html;
|
|
36
|
+
return container;
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
createButtonGroup(config = {}) {
|
|
40
|
+
const { buttons = [], vertical = false } = config;
|
|
41
|
+
const container = document.createElement('div');
|
|
42
|
+
container.className = `button-group flex gap-2 ${vertical ? 'flex-col' : 'flex-row'}`;
|
|
43
|
+
buttons.forEach(btn => {
|
|
44
|
+
const button = document.createElement('button');
|
|
45
|
+
button.className = `btn btn-${btn.variant || 'secondary'} flex-${vertical ? '1' : 'none'}`;
|
|
46
|
+
button.textContent = btn.label;
|
|
47
|
+
if (btn.onClick) button.addEventListener('click', btn.onClick);
|
|
48
|
+
container.appendChild(button);
|
|
49
|
+
});
|
|
50
|
+
return container;
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
createBadge(config = {}) {
|
|
54
|
+
const { label = '', variant = 'default', size = 'medium' } = config;
|
|
55
|
+
const sizeClasses = { small: 'badge-sm', medium: 'badge-md', large: 'badge-lg' };
|
|
56
|
+
const variantClasses = { default: 'badge-flat', primary: 'badge-flat-primary', success: 'badge-flat-success', warning: 'badge-flat-warning', error: 'badge-flat-error' };
|
|
57
|
+
const badge = document.createElement('span');
|
|
58
|
+
badge.className = `badge ${sizeClasses[size] || sizeClasses.medium} ${variantClasses[variant] || variantClasses.default}`;
|
|
59
|
+
badge.textContent = label;
|
|
60
|
+
return badge;
|
|
84
61
|
}
|
|
85
|
-
|
|
86
|
-
html += `
|
|
87
|
-
<input
|
|
88
|
-
type="${type}"
|
|
89
|
-
name="${name}"
|
|
90
|
-
placeholder="${UIComponents.escapeHtml(placeholder)}"
|
|
91
|
-
value="${UIComponents.escapeHtml(value)}"
|
|
92
|
-
${required ? 'required' : ''}
|
|
93
|
-
class="input input-block input-solid"
|
|
94
|
-
/>
|
|
95
|
-
`;
|
|
96
|
-
|
|
97
|
-
container.innerHTML = html;
|
|
98
|
-
return container;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
UIComponents.createSelect = function(config = {}) {
|
|
102
|
-
const {
|
|
103
|
-
name = '',
|
|
104
|
-
label = '',
|
|
105
|
-
options = [],
|
|
106
|
-
value = '',
|
|
107
|
-
required = false
|
|
108
|
-
} = config;
|
|
109
|
-
|
|
110
|
-
const container = document.createElement('div');
|
|
111
|
-
container.className = 'form-group mb-4';
|
|
112
|
-
|
|
113
|
-
let html = '';
|
|
114
|
-
if (label) {
|
|
115
|
-
html += `<label class="block text-sm font-medium mb-2">${UIComponents.escapeHtml(label)}</label>`;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
html += `
|
|
119
|
-
<select
|
|
120
|
-
name="${name}"
|
|
121
|
-
${required ? 'required' : ''}
|
|
122
|
-
class="select select-block select-solid"
|
|
123
|
-
>
|
|
124
|
-
${options.map(opt => `
|
|
125
|
-
<option value="${opt.value}" ${opt.value === value ? 'selected' : ''}>
|
|
126
|
-
${UIComponents.escapeHtml(opt.label)}
|
|
127
|
-
</option>
|
|
128
|
-
`).join('')}
|
|
129
|
-
</select>
|
|
130
|
-
`;
|
|
131
|
-
|
|
132
|
-
container.innerHTML = html;
|
|
133
|
-
return container;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
UIComponents.createButtonGroup = function(config = {}) {
|
|
137
|
-
const {
|
|
138
|
-
buttons = [],
|
|
139
|
-
vertical = false
|
|
140
|
-
} = config;
|
|
141
|
-
|
|
142
|
-
const container = document.createElement('div');
|
|
143
|
-
container.className = `button-group flex gap-2 ${vertical ? 'flex-col' : 'flex-row'}`;
|
|
144
|
-
|
|
145
|
-
buttons.forEach(btn => {
|
|
146
|
-
const button = document.createElement('button');
|
|
147
|
-
button.className = `btn btn-${btn.variant || 'secondary'} flex-${vertical ? '1' : 'none'}`;
|
|
148
|
-
button.textContent = btn.label;
|
|
149
|
-
if (btn.onClick) {
|
|
150
|
-
button.addEventListener('click', btn.onClick);
|
|
151
|
-
}
|
|
152
|
-
container.appendChild(button);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
return container;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
UIComponents.createBadge = function(config = {}) {
|
|
159
|
-
const {
|
|
160
|
-
label = '',
|
|
161
|
-
variant = 'default',
|
|
162
|
-
size = 'medium'
|
|
163
|
-
} = config;
|
|
164
|
-
|
|
165
|
-
const sizeClasses = {
|
|
166
|
-
'small': 'badge-sm',
|
|
167
|
-
'medium': 'badge-md',
|
|
168
|
-
'large': 'badge-lg'
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const variantClasses = {
|
|
172
|
-
'default': 'badge-flat',
|
|
173
|
-
'primary': 'badge-flat-primary',
|
|
174
|
-
'success': 'badge-flat-success',
|
|
175
|
-
'warning': 'badge-flat-warning',
|
|
176
|
-
'error': 'badge-flat-error'
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const badge = document.createElement('span');
|
|
180
|
-
badge.className = `badge ${sizeClasses[size] || sizeClasses['medium']} ${variantClasses[variant] || variantClasses['default']}`;
|
|
181
|
-
badge.textContent = label;
|
|
182
|
-
return badge;
|
|
183
|
-
};
|
|
62
|
+
});
|