|
1694 | 1694 | applySavedTheme(); |
1695 | 1695 | await refreshThreads(); |
1696 | 1696 | await refreshAgents(); |
1697 | | - await updateStatusBar(); |
1698 | 1697 | updateOnlinePresence(); |
1699 | 1698 | startSSE(); |
1700 | 1699 | // Temporarily disable periodic agent polling to avoid showing many offline agents |
1701 | 1700 | // setInterval(refreshAgents, 12000); |
1702 | | - setInterval(updateStatusBar, 5000); // Update status bar every 5 seconds |
| 1701 | + setInterval(refreshAgents, 5000); // Update status bar every 5 seconds |
1703 | 1702 |
|
1704 | 1703 | const tip = window.AcbTooltip.getTooltipElement(); |
1705 | 1704 | if (tip) { |
|
2051 | 2050 | rebuildActiveThreadParticipants(msgs); |
2052 | 2051 | msgs.forEach(appendBubble); |
2053 | 2052 | updateOnlinePresence(); |
2054 | | - await updateStatusBar(); |
| 2053 | + await refreshAgents(); |
2055 | 2054 | if (msgs.length) lastSeq = msgs[msgs.length - 1].seq; |
2056 | 2055 | scrollBottom(false); |
2057 | 2056 | } |
|
2066 | 2065 | }); |
2067 | 2066 | msgs.forEach(appendBubble); |
2068 | 2067 | updateOnlinePresence(); |
2069 | | - await updateStatusBar(); |
| 2068 | + await refreshAgents(); |
2070 | 2069 | msgs.forEach(m => { lastSeq = Math.max(lastSeq, m.seq); }); |
2071 | 2070 | if (msgs.length) scrollBottom(true); |
2072 | 2071 | } |
|
2444 | 2443 | // Agents |
2445 | 2444 | // ============================================================================================== |
2446 | 2445 | async function refreshAgents() { |
2447 | | - // Delegate to updateStatusBar() for consistency |
2448 | | - await updateStatusBar(); |
| 2446 | + // Delegate to window.AcbAgents.updateStatusBar() for consistency |
| 2447 | + await window.AcbAgents.updateStatusBar({ |
| 2448 | + api, |
| 2449 | + setCurrentAgents: (agents) => { currentAgents = agents; }, |
| 2450 | + getActiveThreadId: () => activeThreadId, |
| 2451 | + getAgentState, |
| 2452 | + getStateEmoji, |
| 2453 | + getOfflineTime, |
| 2454 | + isOfflineMoreThanHour, |
| 2455 | + getCompressedOfflineChar, |
| 2456 | + escapeHtml, |
| 2457 | + bindAgentTooltipEvents, |
| 2458 | + }); |
2449 | 2459 | } |
2450 | 2460 |
|
2451 | 2461 | // ============================================================================================== |
|
2536 | 2546 | const offlineDisplay = offlineTime ? ` (${offlineTime})` : ''; |
2537 | 2547 | const isLongOffline = isOfflineMoreThanHour(a); |
2538 | 2548 |
|
2539 | | - const item = document.createElement('div'); |
2540 | | - item.className = 'agent-status-item'; |
| 2549 | + const compressedChar = getCompressedOfflineChar(offlineTime); |
| 2550 | + const item = document.createElement('acb-agent-status-item'); |
| 2551 | + item.setData({ |
| 2552 | + emoji, |
| 2553 | + label, |
| 2554 | + state, |
| 2555 | + offlineDisplay, |
| 2556 | + isLongOffline, |
| 2557 | + compressedChar, |
| 2558 | + escapeHtml, |
| 2559 | + }); |
2541 | 2560 |
|
2542 | 2561 | // Set data-agent-id for click-to-mention functionality |
2543 | 2562 | if (a && a.id) { |
2544 | 2563 | item.dataset.agentId = a.id; |
| 2564 | + bindAgentTooltipEvents(item, a); |
2545 | 2565 | } else if (a && a.agent_id) { |
2546 | 2566 | item.dataset.agentId = a.agent_id; |
2547 | 2567 | } |
2548 | | - |
2549 | | - // Compress display if offline > 1 hour: just emoji + single char |
2550 | | - if (isLongOffline) { |
2551 | | - const compressedChar = getCompressedOfflineChar(offlineTime); |
2552 | | - item.innerHTML = ` |
2553 | | - <div class="agent-status-emoji">${emoji}</div> |
2554 | | - <div class="agent-status-text-compact">${compressedChar}</div> |
2555 | | - `; |
2556 | | - } else { |
2557 | | - // Remove thread info display to keep agent list clean |
2558 | | - item.innerHTML = ` |
2559 | | - <div class="agent-status-emoji">${emoji}</div> |
2560 | | - <div class="agent-status-text"> |
2561 | | - <div class="agent-alias">${escapeHtml(label)}</div> |
2562 | | - <div class="agent-state">${state}${offlineDisplay}</div> |
2563 | | - </div> |
2564 | | - `; |
2565 | | - } |
2566 | | - |
2567 | | - // 绑定agent tooltip交互 |
2568 | | - if (a && a.id) { |
2569 | | - bindAgentTooltipEvents(item, a); |
2570 | | - } |
2571 | 2568 | container.appendChild(item); |
2572 | 2569 | }); |
2573 | 2570 | } |
|
0 commit comments