Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codersdk/workspaceresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type WorkspaceAgent struct {
Version string `json:"version"`
Apps []WorkspaceApp `json:"apps"`
// DERPLatency is mapped by region name (e.g. "New York City", "Seattle").
DERPLatency map[string]DERPRegion `json:"latency"`
DERPLatency map[string]DERPRegion `json:"latency,omitempty"`
}

type WorkspaceAgentResourceMetadata struct {
Expand Down
2 changes: 1 addition & 1 deletion site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ export interface WorkspaceAgent {
readonly directory?: string
readonly version: string
readonly apps: WorkspaceApp[]
readonly latency: Record<string, DERPRegion>
readonly latency?: Record<string, DERPRegion>
}

// From codersdk/workspaceagents.go
Expand Down
8 changes: 6 additions & 2 deletions site/src/components/Resources/ResourceAgentLatency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ export interface ResourceAgentLatencyProps {

export const ResourceAgentLatency: React.FC<ResourceAgentLatencyProps> = (props) => {
const styles = useStyles()
if (!props.latency) {
return null
}
if (Object.keys(props.latency).length === 0) {
return null
}
const latency = props.latency
return (
<div className={styles.root}>
<div className={styles.title}>
Expand All @@ -24,10 +28,10 @@ export const ResourceAgentLatency: React.FC<ResourceAgentLatencyProps> = (props)
</HelpTooltipText>
</HelpTooltip>
</div>
{Object.keys(props.latency)
{Object.keys(latency)
.sort()
.map((region) => {
const value = props.latency[region]
const value = latency[region]
return (
<div key={region} className={styles.region}>
<b>{region}:</b>&nbsp;{Math.round(value.latency_ms * 100) / 100} ms
Expand Down