From 02eb6aa14d84756328863e1defda63bc53a6a741 Mon Sep 17 00:00:00 2001 From: Victor Vogel Date: Sat, 7 Nov 2026 18:02:10 +0000 Subject: [PATCH] fix(web): Linked environments names its environment when several are connected Settings > Environments added the environment's name to a Linked environments heading only when more than one connected environment offered links. With several environments but only one offering links, the heading was a bare "Linked environments" sitting under another environment's row, so it read as that environment's links. Name the section whenever the client knows more than one environment. With a single environment the heading stays unchanged. Co-Authored-By: Claude Opus 5.5 --- .../settings/ConnectionsSettings.logic.test.ts | 16 ++++++++++++++++ .../settings/ConnectionsSettings.logic.ts | 8 ++++++++ .../components/settings/ConnectionsSettings.tsx | 6 +++++- 3 files changed, 29 insertions(+), 1 deletion(-) 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} /> ))}