MCPcopy Create free account
hub / github.com/coder/coder / getDisplayLatency

Function getDisplayLatency

site/src/modules/resources/AgentLatency.tsx:13–30  ·  view source on GitHub ↗
(agent: WorkspaceAgent)

Source from the content-addressed store, hash-verified

11import { getLatencyColor } from "#/utils/latency";
12
13const 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
32interface AgentLatencyProps {
33 agent: WorkspaceAgent;

Callers 1

AgentLatencyFunction · 0.85

Calls 2

getLatencyColorFunction · 0.90
findMethod · 0.80

Tested by

no test coverage detected