|
20 | 20 | .sort((a, b) => a.localeCompare(b)); |
21 | 21 |
|
22 | 22 | const nowMs = Date.now(); |
23 | | - const threadOnlineKeys = Array.from(activeThreadLastSeenMs.entries()) |
24 | | - .filter( |
25 | | - ([key, lastSeenMs]) => |
26 | | - onlineAgentKeys.has(key) || nowMs - lastSeenMs <= threadActivityWindowMs |
27 | | - ) |
28 | | - .map(([key]) => key); |
| 23 | + // All participant keys for the active thread (both online and offline) |
| 24 | + const threadAllKeys = Array.from(activeThreadLabelsByKey.keys()); |
| 25 | + |
| 26 | + // Determine which of the thread participants are considered online/recent |
| 27 | + const threadOnlineKeys = threadAllKeys.filter((key) => { |
| 28 | + if (onlineAgentKeys.has(key)) return true; |
| 29 | + const lastSeenMs = activeThreadLastSeenMs.get(key); |
| 30 | + return typeof lastSeenMs === "number" && nowMs - lastSeenMs <= threadActivityWindowMs; |
| 31 | + }); |
| 32 | + |
| 33 | + const threadAllAgents = threadAllKeys |
| 34 | + .map((key) => String(activeThreadLabelsByKey.get(key) || onlineAgentLabelsByKey.get(key) || key)) |
| 35 | + .sort((a, b) => a.localeCompare(b)); |
29 | 36 |
|
30 | 37 | const threadOnlineAgents = threadOnlineKeys |
31 | 38 | .map((key) => String(activeThreadLabelsByKey.get(key) || onlineAgentLabelsByKey.get(key) || key)) |
32 | 39 | .sort((a, b) => a.localeCompare(b)); |
33 | 40 |
|
34 | 41 | const showingThreadScoped = Boolean(activeThreadId); |
35 | | - const total = showingThreadScoped ? threadOnlineKeys.length : onlineAgentEntries.length; |
| 42 | + const total = showingThreadScoped ? threadAllKeys.length : onlineAgentEntries.length; |
36 | 43 |
|
37 | | - countEl.textContent = showingThreadScoped ? `Thread online ${total}` : `Online agents ${total}`; |
| 44 | + countEl.textContent = showingThreadScoped ? `Thread agents ${total}` : `Online agents ${total}`; |
38 | 45 |
|
39 | 46 | const tooltip = showingThreadScoped |
40 | | - ? `Thread online: ${threadOnlineAgents.length ? threadOnlineAgents.join(", ") : "(none)"} | Global online: ${onlineAgents.length ? onlineAgents.join(", ") : "(none)"}` |
| 47 | + ? `Thread participants: ${threadAllAgents.length ? threadAllAgents.join(", ") : "(none)"} | Thread online: ${threadOnlineAgents.length ? threadOnlineAgents.join(", ") : "(none)"} | Global online: ${onlineAgents.length ? onlineAgents.join(", ") : "(none)"}` |
41 | 48 | : `Agents: ${onlineAgents.length ? onlineAgents.join(", ") : "(none)"}`; |
42 | 49 | if (window.AcbTooltip && window.AcbTooltip.setTooltip) { |
43 | 50 | window.AcbTooltip.setTooltip(badgeEl, tooltip); |
|
0 commit comments