diff --git a/site/src/components/Navbar/NavbarView.tsx b/site/src/components/Navbar/NavbarView.tsx index e7d9b4a906..6bc5777b95 100644 --- a/site/src/components/Navbar/NavbarView.tsx +++ b/site/src/components/Navbar/NavbarView.tsx @@ -300,7 +300,7 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({ theme.palette.text.secondary, lineHeight: "inherit", marginTop: 0.5, @@ -311,43 +311,49 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({ theme.palette.divider }} /> - {proxyContextValue.proxies?.map((proxy) => ( - { - if (!proxy.healthy) { - displayError("Please select a healthy workspace proxy.") - closeMenu() - return - } + {proxyContextValue.proxies + ?.sort((a, b) => { + const latencyA = latencies?.[a.id]?.latencyMS ?? Infinity + const latencyB = latencies?.[b.id]?.latencyMS ?? Infinity + return latencyA - latencyB + }) + .map((proxy) => ( + { + if (!proxy.healthy) { + displayError("Please select a healthy workspace proxy.") + closeMenu() + return + } - proxyContextValue.setProxy(proxy) - closeMenu() - }} - key={proxy.id} - selected={proxy.id === selectedProxy?.id} - sx={{ - fontSize: 14, - }} - > - - - + + + + + {proxy.display_name} + - {proxy.display_name} - - - - ))} + + ))} theme.palette.divider }} /> {Boolean(permissions.editWorkspaceProxies) && (