Skip to content

Commit b8bbf99

Browse files
committed
refactor: Remove redundant SSE event handling logic for improved performance
1 parent 2e41205 commit b8bbf99

1 file changed

Lines changed: 0 additions & 51 deletions

File tree

src/static/index.html

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -660,57 +660,6 @@
660660
// SSE
661661
// ==============================================================================================
662662
function startSSE() {
663-
const es = new EventSource('/events');
664-
es.onopen = () => setConnected(true);
665-
es.onerror = () => { setConnected(false); setTimeout(startSSE, 3000); es.close(); };
666-
667-
es.onmessage = async (e) => {
668-
const ev = JSON.parse(e.data);
669-
const p = ev.payload;
670-
671-
if (ev.type === 'msg.new') {
672-
if (p.thread_id === activeThreadId) await loadNewMessages();
673-
await refreshThreads(); // update sidebar counts
674-
}
675-
if (ev.type === 'msg.edit' && p.thread_id === activeThreadId) {
676-
// Update the bubble content in-place and show/refresh the "edited" indicator
677-
const row = document.querySelector(`[data-msg-id="${p.msg_id}"]`);
678-
if (row) {
679-
const bubbleEl = row.querySelector('.bubble-v2');
680-
if (bubbleEl) {
681-
bubbleEl.innerHTML = '';
682-
window.AcbMessageRenderer.renderMessageContent(bubbleEl, p.content, null);
683-
}
684-
let indicator = row.querySelector('.msg-edited-indicator');
685-
if (!indicator) {
686-
indicator = document.createElement('span');
687-
indicator.className = 'msg-edited-indicator';
688-
indicator.setAttribute('onclick', 'window.AcbMsgEditHistory(this)');
689-
indicator.setAttribute('data-msg-id', p.msg_id);
690-
const tail = row.querySelector('acb-message-tail-meta') || row.querySelector('.msg-reactions');
691-
if (tail) tail.before(indicator);
692-
}
693-
indicator.title = `Edited (v${p.version})`;
694-
indicator.textContent = 'edited';
695-
}
696-
}
697-
if (ev.type === 'thread.new' || ev.type === 'thread.state' || ev.type === 'thread.closed' || ev.type === 'thread.archived' || ev.type === 'thread.deleted') {
698-
await refreshThreads();
699-
if (ev.type === 'thread.deleted' && p.thread_id === activeThreadId) {
700-
activeThreadId = null;
701-
document.getElementById('msg-pane').innerHTML = '';
702-
const hdr = document.getElementById('thread-header');
703-
if (hdr) hdr.textContent = '';
704-
}
705-
}
706-
if (ev.type === 'agent.online' || ev.type === 'agent.offline') {
707-
await refreshAgents();
708-
}
709-
if (ev.type === 'agent.typing' && p.thread_id === activeThreadId) {
710-
if (p.is_typing) showTyping(p.agent_id);
711-
else hideTyping(p.agent_id);
712-
}
713-
};
714663
return window.AcbSSE.startSSE({
715664
getActiveThreadId: () => activeThreadId,
716665
onMsgNew: async () => loadNewMessages(),

0 commit comments

Comments
 (0)