Skip to content
TypeScript

fix(web): Load balancing and PR sharing name the route in use (#26441)

Vladyslav Husakov4dd2f735f2d3
diff --git a/apps/web/src/components/settings/EnvironmentRow.tsx b/apps/web/src/components/settings/EnvironmentRow.tsx
index 3950a637ed8..b902ab01c1f 100644
--- a/apps/web/src/components/settings/EnvironmentRow.tsx
+++ b/apps/web/src/components/settings/EnvironmentRow.tsx
@@ -10,6 +10,7 @@ import type { ReactNode } from "react";
import { cn } from "~/lib/utils";
import type { EnvironmentPresentation } from "~/state/environments";
+import { usePreparedConnection } from "~/state/session";
import { isDesktopLocalConnectionTarget } from "~/connection/desktopLocal";
import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";
@@ -48,6 +49,22 @@ export function environmentTransportLabel(
return environment.displayUrl ?? "Remote link";
}
+export function useEnvironmentTransportLabel(environment: EnvironmentPresentation): string {
+ const prepared = usePreparedConnection(environment.environmentId);
+ return environmentTransportLabel(
+ environment,
+ environment.connection.phase === "connected" && prepared._tag === "Some"
+ ? prepared.value.target
+ : null,
+ );
+}
+
+export function EnvironmentTransportLabel(props: {
+ readonly environment: EnvironmentPresentation;
+}) {
+ return useEnvironmentTransportLabel(props.environment);
+}
+
export function EnvironmentRow({
kind,
label,
diff --git a/apps/web/src/components/settings/LoadBalancingSettings.tsx b/apps/web/src/components/settings/LoadBalancingSettings.tsx
index 84198c24a96..781516cf08f 100644
--- a/apps/web/src/components/settings/LoadBalancingSettings.tsx
+++ b/apps/web/src/components/settings/LoadBalancingSettings.tsx
@@ -8,7 +8,7 @@ import {
import type { EnvironmentPresentation } from "~/state/environments";
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
import { Switch } from "../ui/switch";
-import { EnvironmentRow, environmentTransportLabel } from "./EnvironmentRow";
+import { EnvironmentRow, EnvironmentTransportLabel } from "./EnvironmentRow";
import { FoldedSettingsSection } from "./FoldedSettingsSection";
import { searchableSetting } from "./settingsSearch";
@@ -85,7 +85,7 @@ export function LoadBalancingSettings({
key={environment.environmentId}
kind={resolveEnvironmentMachineKind(environment.serverConfig)}
label={environment.label}
- subtitle={environmentTransportLabel(environment)}
+ subtitle={<EnvironmentTransportLabel environment={environment} />}
>
<Select
items={preferences}
diff --git a/apps/web/src/components/settings/PullRequestRoutingSettings.tsx b/apps/web/src/components/settings/PullRequestRoutingSettings.tsx
index a6e3234ad7e..da9fd17617b 100644
--- a/apps/web/src/components/settings/PullRequestRoutingSettings.tsx
+++ b/apps/web/src/components/settings/PullRequestRoutingSettings.tsx
@@ -12,7 +12,7 @@ import type { EnvironmentPresentation } from "~/state/environments";
import { useAtomCommand } from "~/state/use-atom-command";
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
import { toastManager } from "../ui/toast";
-import { EnvironmentRow, environmentTransportLabel } from "./EnvironmentRow";
+import { EnvironmentRow, EnvironmentTransportLabel } from "./EnvironmentRow";
import { FoldedSettingsSection } from "./FoldedSettingsSection";
import { searchableSetting } from "./settingsSearch";
@@ -75,7 +75,7 @@ export function PullRequestRoutingSettings({
key={environment.environmentId}
kind={resolveEnvironmentMachineKind(environment.serverConfig)}
label={environment.label}
- subtitle={environmentTransportLabel(environment)}
+ subtitle={<EnvironmentTransportLabel environment={environment} />}
>
<Select
items={options}
diff --git a/apps/web/src/components/settings/ScheduledTasksSettings.tsx b/apps/web/src/components/settings/ScheduledTasksSettings.tsx
index e027438a6ab..03215833d3d 100644
--- a/apps/web/src/components/settings/ScheduledTasksSettings.tsx
+++ b/apps/web/src/components/settings/ScheduledTasksSettings.tsx
@@ -70,7 +70,7 @@ import { ConnectionStatusDot, connectionPhaseDotClassName } from "../ConnectionS
import { AuthOrchestrationOperateScope } from "@t3tools/contracts";
import { readEnvironmentScope } from "~/state/session";
import { useSettingsScope } from "./SettingsScopeContext";
-import { EnvironmentRow, environmentTransportLabel } from "./EnvironmentRow";
+import { EnvironmentRow, useEnvironmentTransportLabel } from "./EnvironmentRow";
import { SettingsGroup } from "./SettingsGroup";
import { settingsScopeEnvironmentLabel, settingsScopeEnvironmentLabels } from "./settingsScopeAxis";
import {
@@ -541,19 +541,13 @@ function ScheduledTaskEnvironmentList({
<SettingsGroup>
{populated.map(({ environment, tasks }) => {
const { primary, secondary } = settingsScopeEnvironmentLabels(environment, environments);
- const transport = environmentTransportLabel(environment);
return (
<div key={environment.environmentId} className="divide-y divide-border/50">
<EnvironmentRow
kind={resolveEnvironmentMachineKind(environment.serverConfig)}
label={primary}
subtitle={
- <>
- {secondary && secondary !== transport ? (
- <span className="block truncate">{secondary}</span>
- ) : null}
- <span className="block truncate">{transport}</span>
- </>
+ <ScheduledTaskEnvironmentSubtitle environment={environment} secondary={secondary} />
}
>
<ConnectionStatusDot
@@ -611,6 +605,24 @@ function ScheduledTaskEnvironmentList({
);
}
+function ScheduledTaskEnvironmentSubtitle({
+ environment,
+ secondary,
+}: {
+ readonly environment: EnvironmentPresentation;
+ readonly secondary: string;
+}) {
+ const transport = useEnvironmentTransportLabel(environment);
+ return (
+ <>
+ {secondary && secondary !== transport ? (
+ <span className="block truncate">{secondary}</span>
+ ) : null}
+ <span className="block truncate">{transport}</span>
+ </>
+ );
+}
+
function ScheduledTaskEnvironmentSection({
environment,
taskId,