-
Notifications
You must be signed in to change notification settings - Fork 0
fix: presence badge shows ONLINE when agent is offline #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ced916a
a9ad63b
9606a79
f6f7d73
fb09fb5
08ceb73
1e98286
7dd8808
43ec541
1a071ca
8c66acc
8612261
a4679a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ const HEARTBEAT_RETRY_MAX_MS = 30_000 | |
| const WRAP_UP_SYNC_EVENT = 'agent-wrap-up-ends-at' | ||
| const PRESENCE_RESTORE_KEY = 'agent-presence:last-status' | ||
| const PRESENCE_RESTORE_MAX_AGE_MS = 15_000 | ||
| const HEARTBEAT_RECENCY_MS = 60_000 | ||
| const PRESENCE_LEADER_KEY = 'presence-leader' | ||
| const PRESENCE_LEADER_FRESH_MS = 5_000 | ||
| const BC_LEADER_HEARTBEAT_INTERVAL_MS = 3_000 // Leader broadcasts heartbeat every 3s | ||
|
|
@@ -602,12 +603,16 @@ export function usePresence() { | |
| if (raw) { | ||
| const parsed = JSON.parse(raw) as { status?: AgentStatus; at?: number } | ||
| const ageMs = Date.now() - Number(parsed?.at ?? 0) | ||
| const heartbeatAgeMs = lastHeartbeatIso ? Date.now() - new Date(lastHeartbeatIso).getTime() : Number.POSITIVE_INFINITY | ||
| const heartbeatAgeMs = lastHeartbeatIso | ||
| ? Date.now() - new Date(lastHeartbeatIso).getTime() | ||
| : Number.POSITIVE_INFINITY | ||
|
|
||
| // Only restore when this was a near-immediate refresh while actively working. | ||
| // If heartbeat is older than 60s, default to offline and require manual re-available. | ||
| if ( | ||
| parsed?.status && | ||
| parsed.status !== 'offline' && | ||
| parsed?.status === 'available' && | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Restricting session restore to Useful? React with 👍 / 👎. |
||
| ageMs <= PRESENCE_RESTORE_MAX_AGE_MS && | ||
| heartbeatAgeMs <= PRESENCE_RESTORE_MAX_AGE_MS | ||
| heartbeatAgeMs <= HEARTBEAT_RECENCY_MS | ||
| ) { | ||
| await updateStatus(parsed.status) | ||
| return | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new badge mapping only treats
availableas online/degraded, sobusyandawaynow always render as🔴 OFFLINEeven when the connection is healthy. This misreports presence state and conflicts with the status selector (which still shows Busy/Away), making operators look disconnected when they are intentionally in a non-available state.Useful? React with 👍 / 👎.