Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 091c00b

Browse files
authored
fix: make preferred region the first in list (coder#9014)
1 parent 834ce41 commit 091c00b

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

site/src/components/Resources/AgentLatency.tsx

+4-10
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,9 @@ export const AgentLatency: FC<{ agent: WorkspaceAgent }> = ({ agent }) => {
6969

7070
<HelpTooltipText>
7171
<Stack direction="column" spacing={1} className={styles.regions}>
72-
{Object.keys(agent.latency).map((regionName) => {
73-
if (!agent.latency) {
74-
throw new Error("No latency found on agent")
75-
}
76-
77-
const region = agent.latency[regionName]
78-
79-
return (
72+
{Object.entries(agent.latency)
73+
.sort(([, a], [, b]) => (a.preferred ? -1 : b.preferred ? 1 : 0))
74+
.map(([regionName, region]) => (
8075
<Stack
8176
direction="row"
8277
key={regionName}
@@ -87,8 +82,7 @@ export const AgentLatency: FC<{ agent: WorkspaceAgent }> = ({ agent }) => {
8782
<strong>{regionName}</strong>
8883
{Math.round(region.latency_ms)}ms
8984
</Stack>
90-
)
91-
})}
85+
))}
9286
</Stack>
9387
</HelpTooltipText>
9488
</HelpPopover>

0 commit comments

Comments
 (0)