diff --git a/apps/web/src/components/settings/ConnectionsSettings.logic.test.ts b/apps/web/src/components/settings/ConnectionsSettings.logic.test.ts index ffd59c5439bc8..b9d5476e21b59 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.logic.test.ts +++ b/apps/web/src/components/settings/ConnectionsSettings.logic.test.ts @@ -2,6 +2,7 @@ import { type DesktopWslState, EnvironmentId } from "@t3tools/contracts"; import { describe, expect, it, vi } from "vite-plus/test"; import { applyWslEnableSelection, + linkedEnvironmentsSectionLabel, resolveAccessEnvironmentId, resolveTailscaleServeBaseUrl, selectQrEndpointOption, @@ -201,3 +202,18 @@ describe("resolveAccessEnvironmentId", () => { ); }); }); + +describe("linkedEnvironmentsSectionLabel", () => { + it.each([ + { label: "leaves the only environment unnamed", environmentCount: 1, expected: null }, + { + label: "names the host when another known environment offers no links", + environmentCount: 2, + expected: "Laptop", + }, + ])("$label", ({ environmentCount, expected }) => { + expect(linkedEnvironmentsSectionLabel({ hostLabel: "Laptop", environmentCount })).toBe( + expected, + ); + }); +}); diff --git a/apps/web/src/components/settings/ConnectionsSettings.logic.ts b/apps/web/src/components/settings/ConnectionsSettings.logic.ts index e219694351b9b..2645af220cbd5 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.logic.ts +++ b/apps/web/src/components/settings/ConnectionsSettings.logic.ts @@ -438,6 +438,14 @@ export function endpointShareHint(endpoint: AdvertisedEndpoint, url: string): st } } +/** Counts every environment the client knows, not only link hosts, since the page lists them all. */ +export function linkedEnvironmentsSectionLabel(input: { + readonly hostLabel: string; + readonly environmentCount: number; +}): string | null { + return input.environmentCount > 1 ? input.hostLabel : null; +} + /** An explicit choice while it is listed, else the primary, else a connected environment. */ export function resolveAccessEnvironmentId(input: { readonly primaryEnvironmentId: EnvironmentId | null; diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx index 087f73589f329..00e8aa47a60c3 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.tsx +++ b/apps/web/src/components/settings/ConnectionsSettings.tsx @@ -29,6 +29,7 @@ import { isLocalEnvironmentDisabled } from "../../localEnvironment"; import { applyWslEnableSelection, isWslSettingsRowVisible, + linkedEnvironmentsSectionLabel, missingTailscaleEndpointDescription, resolveAccessEnvironmentId, resolveLocalVersionStatusLabel, @@ -1650,7 +1651,10 @@ function ConnectionsSettingsContent({ 1 ? environment.label : null} + environmentLabel={linkedEnvironmentsSectionLabel({ + hostLabel: environment.label, + environmentCount: environments.length, + })} isSearchTarget={index === 0} /> ))}