agentgui 1.0.587 → 1.0.588
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/package.json +1 -1
- package/static/js/conversations.js +45 -8
package/package.json
CHANGED
|
@@ -24,6 +24,10 @@ class ConversationManager {
|
|
|
24
24
|
this.streamingConversations = new Set();
|
|
25
25
|
this.agents = new Map();
|
|
26
26
|
|
|
27
|
+
this._conversationVersion = 0;
|
|
28
|
+
this._lastMutationSource = null;
|
|
29
|
+
this._lastMutationTime = 0;
|
|
30
|
+
|
|
27
31
|
this.folderBrowser = {
|
|
28
32
|
modal: null,
|
|
29
33
|
listEl: null,
|
|
@@ -72,6 +76,29 @@ class ConversationManager {
|
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
|
|
79
|
+
_updateConversations(newArray, source, context = {}) {
|
|
80
|
+
const oldLen = this.conversations.length;
|
|
81
|
+
const newLen = Array.isArray(newArray) ? newArray.length : 0;
|
|
82
|
+
const mutationId = ++this._conversationVersion;
|
|
83
|
+
const timestamp = Date.now();
|
|
84
|
+
|
|
85
|
+
this.conversations = Array.isArray(newArray) ? newArray : [];
|
|
86
|
+
this._lastMutationSource = source;
|
|
87
|
+
this._lastMutationTime = timestamp;
|
|
88
|
+
|
|
89
|
+
window._conversationCacheVersion = mutationId;
|
|
90
|
+
|
|
91
|
+
if (context.verbose) {
|
|
92
|
+
console.log(`[ConvMgr] mutation #${mutationId} (${source}): ${oldLen} → ${newLen} items, ts=${timestamp}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return { version: mutationId, timestamp, oldLen, newLen };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getConversationCacheVersion() {
|
|
99
|
+
return this._conversationVersion;
|
|
100
|
+
}
|
|
101
|
+
|
|
75
102
|
getAgentDisplayName(agentId) {
|
|
76
103
|
if (!agentId) return 'Unknown';
|
|
77
104
|
const agent = this.agents.get(agentId);
|
|
@@ -273,7 +300,7 @@ class ConversationManager {
|
|
|
273
300
|
this.deleteAllBtn.disabled = true;
|
|
274
301
|
await window.wsClient.rpc('conv.del.all', {});
|
|
275
302
|
console.log('[ConversationManager] Deleted all conversations');
|
|
276
|
-
this.
|
|
303
|
+
this._updateConversations([], 'clear_all');
|
|
277
304
|
this.activeId = null;
|
|
278
305
|
window.dispatchEvent(new CustomEvent('conversation-deselected'));
|
|
279
306
|
this.render();
|
|
@@ -374,7 +401,9 @@ class ConversationManager {
|
|
|
374
401
|
async loadConversations() {
|
|
375
402
|
try {
|
|
376
403
|
const data = await window.wsClient.rpc('conv.ls');
|
|
377
|
-
|
|
404
|
+
const convList = data.conversations || [];
|
|
405
|
+
|
|
406
|
+
this._updateConversations(convList, 'poll');
|
|
378
407
|
|
|
379
408
|
for (const conv of this.conversations) {
|
|
380
409
|
if (conv.isStreaming === 1 || conv.isStreaming === true) {
|
|
@@ -536,21 +565,29 @@ class ConversationManager {
|
|
|
536
565
|
if (this.conversations.some(c => c.id === conv.id)) {
|
|
537
566
|
return;
|
|
538
567
|
}
|
|
539
|
-
this.conversations
|
|
568
|
+
const newConvs = [conv, ...this.conversations];
|
|
569
|
+
this._updateConversations(newConvs, 'add', { convId: conv.id });
|
|
540
570
|
this.render();
|
|
541
571
|
}
|
|
542
572
|
|
|
543
573
|
updateConversation(convId, updates) {
|
|
544
|
-
const
|
|
545
|
-
if (
|
|
546
|
-
Object.assign(
|
|
574
|
+
const idx = this.conversations.findIndex(c => c.id === convId);
|
|
575
|
+
if (idx >= 0) {
|
|
576
|
+
const updated = Object.assign({}, this.conversations[idx], updates);
|
|
577
|
+
const newConvs = [
|
|
578
|
+
...this.conversations.slice(0, idx),
|
|
579
|
+
updated,
|
|
580
|
+
...this.conversations.slice(idx + 1)
|
|
581
|
+
];
|
|
582
|
+
this._updateConversations(newConvs, 'update', { convId });
|
|
547
583
|
this.render();
|
|
548
584
|
}
|
|
549
585
|
}
|
|
550
586
|
|
|
551
587
|
deleteConversation(convId) {
|
|
552
588
|
const wasActive = this.activeId === convId;
|
|
553
|
-
|
|
589
|
+
const newConvs = this.conversations.filter(c => c.id !== convId);
|
|
590
|
+
this._updateConversations(newConvs, 'delete', { convId });
|
|
554
591
|
if (wasActive) {
|
|
555
592
|
this.activeId = null;
|
|
556
593
|
window.dispatchEvent(new CustomEvent('conversation-deselected'));
|
|
@@ -569,7 +606,7 @@ class ConversationManager {
|
|
|
569
606
|
} else if (msg.type === 'conversation_deleted') {
|
|
570
607
|
this.deleteConversation(msg.conversationId);
|
|
571
608
|
} else if (msg.type === 'all_conversations_deleted') {
|
|
572
|
-
this.
|
|
609
|
+
this._updateConversations([], 'ws_clear_all');
|
|
573
610
|
this.activeId = null;
|
|
574
611
|
this.streamingConversations.clear();
|
|
575
612
|
this.showEmpty('No conversations yet');
|