Панель и сеть читают сохранённое наблюдение и прогресс deploy. Качество и свежесть сессии видны на спикерах и пирах, без подмены статуса неопрошенным Established. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.9 KiB
TypeScript
40 lines
1.9 KiB
TypeScript
import { StatusBadge } from '@/components/status-badge'
|
|
import { observationHint, observationQuality, peerSessionCurrent, speakerAgentKnown } from '@/lib/live-observation'
|
|
import { bgpSessionStateRu, speakerOnlineLabel } from '@/lib/ui-labels'
|
|
import type { PeerRow, SpeakerRow } from '@/types/api'
|
|
|
|
export function PeerObservationBadge({ peer }: { peer: PeerRow }) {
|
|
const current = peerSessionCurrent(peer)
|
|
const state = current ? peer.session_state : null
|
|
const quality = peer.live_observation && observationQuality(peer.live_observation)
|
|
const lastKnown = peer.last_known_session_state
|
|
const hint = [
|
|
observationHint(peer.live_observation),
|
|
!current && lastKnown ? `последнее: ${bgpSessionStateRu(lastKnown)}` : undefined,
|
|
].filter(Boolean).join(' · ')
|
|
return (
|
|
<StatusBadge
|
|
status={current && state ? state : quality === 'stale' ? 'stale' : 'unknown'}
|
|
label={state ? bgpSessionStateRu(state) : quality === 'stale' ? 'Устарело' : 'Нет данных'}
|
|
hint={hint || undefined}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export function AgentObservationBadge({ speaker }: { speaker: SpeakerRow }) {
|
|
const observation = speaker.live?.agent_observation
|
|
const quality = observation && observationQuality(observation)
|
|
const ok = speaker.live?.agent_ok
|
|
const reportedUnhealthy = observation?.error_code === 'reported_unhealthy' && ok === false && speakerAgentKnown(speaker)
|
|
const current = !observation || quality === 'ok' || reportedUnhealthy
|
|
const label = reportedUnhealthy
|
|
? 'Агент сообщил об ошибке'
|
|
: !current
|
|
? quality === 'stale' ? 'Устарело' : 'Нет данных'
|
|
: ok == null ? 'Нет данных' : speakerOnlineLabel(ok)
|
|
const status = !current
|
|
? quality === 'stale' ? 'stale' : 'unknown'
|
|
: ok == null ? 'unknown' : ok ? 'ok' : 'error'
|
|
return <StatusBadge status={status} label={label} hint={observationHint(observation)} />
|
|
}
|