(agent: WorkspaceAgent)
| 11 | import { getLatencyColor } from "#/utils/latency"; |
| 12 | |
| 13 | const getDisplayLatency = (agent: WorkspaceAgent) => { |
| 14 | // Find the right latency to display |
| 15 | const latencyValues = Object.values(agent.latency ?? {}); |
| 16 | const latency = |
| 17 | latencyValues.find((derp) => derp.preferred) ?? |
| 18 | // Accessing an array index can return undefined as well |
| 19 | // for some reason TS does not handle that |
| 20 | (latencyValues[0] as DERPRegion | undefined); |
| 21 | |
| 22 | if (!latency) { |
| 23 | return undefined; |
| 24 | } |
| 25 | |
| 26 | return { |
| 27 | ...latency, |
| 28 | color: getLatencyColor(latency.latency_ms), |
| 29 | }; |
| 30 | }; |
| 31 | |
| 32 | interface AgentLatencyProps { |
| 33 | agent: WorkspaceAgent; |
no test coverage detected