From 021477e836367f0f09d2f4534191dfa5ced039c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=A4=A7=E7=8C=AB?= <16399091+binaricat@users.noreply.github.com> Date: Thu, 26 Nov 2026 18:43:06 +0800 Subject: [PATCH] fix(vault): keep Mosh/ET exclusive when restoring group transport --- components/HostDetailsAdvancedSections.tsx | 12 ++++++++- components/HostDetailsPanel.inherit.test.tsx | 27 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/components/HostDetailsAdvancedSections.tsx b/components/HostDetailsAdvancedSections.tsx index 96a49d8b0..cbc8b27ab 100644 --- a/components/HostDetailsAdvancedSections.tsx +++ b/components/HostDetailsAdvancedSections.tsx @@ -73,7 +73,17 @@ export const HostDetailsAdvancedSections: React.FC ) : ( - update(key, undefined)} /> + { + if ((key === "moshEnabled" || key === "etEnabled") && effectiveGroupDefaults[key] === true) { + setForm(prev => ({ + ...prev, + [key]: undefined, + [key === "moshEnabled" ? "etEnabled" : "moshEnabled"]: false, + })); + } else { + update(key, undefined); + } + }} /> ); }; const inheritedStartupCommandRunMode = effectiveGroupDefaults?.startupCommandRunMode ?? "paste"; diff --git a/components/HostDetailsPanel.inherit.test.tsx b/components/HostDetailsPanel.inherit.test.tsx index 4c8dc9c2b..810fd7e9f 100644 --- a/components/HostDetailsPanel.inherit.test.tsx +++ b/components/HostDetailsPanel.inherit.test.tsx @@ -5,6 +5,7 @@ import { act, create, type ReactTestInstance, type ReactTestRenderer } from "rea import { I18nProvider } from "../application/i18n/I18nProvider"; import { applyGroupDefaults } from "../domain/groupConfig"; import type { GroupConfig, Host } from "../domain/models"; +import { resolveEffectiveTerminalProtocol } from "../domain/terminalProtocol"; import HostDetailsPanel from "./HostDetailsPanel"; import { ChainPanel } from "./host-details/ChainPanel"; import { HostDetailsOverrideReset } from "./host-details/HostDetailsOverrideReset"; @@ -111,6 +112,32 @@ for (const [key, label] of [["moshEnabled", "Mosh"], ["etEnabled", "EternalTermi assertInherited(row()); }); }); + + test(`Host Details restores inherited ${label} and disables the competing transport`, async () => { + const competingKey = key === "moshEnabled" ? "etEnabled" : "moshEnabled"; + const competingLabel = key === "moshEnabled" ? "EternalTerminal" : "Mosh"; + const group = { [key]: true }; + await withPanel(group, async ({ root, save }) => { + const row = () => setting(root, label); + assert.equal(row().findByType(Switch).props.checked, false); + assert.equal(setting(root, competingLabel).findByType(Switch).props.checked, true); + + const reset = row().findByType(HostDetailsOverrideReset); + assert.equal(reset.props.label, "Use group"); + await act(async () => { reset.props.onClick(); }); + const inherited = await save(); + assert.equal(inherited[key], undefined); + assert.equal(inherited[competingKey], false); + assert.equal(row().findByType(Switch).props.checked, true); + assertInherited(row()); + assert.equal(setting(root, competingLabel).findByType(Switch).props.checked, false); + + const effective = applyGroupDefaults(inherited, group); + assert.equal(effective[key], true); + assert.equal(effective[competingKey], false); + assert.equal(resolveEffectiveTerminalProtocol(effective), key === "moshEnabled" ? "mosh" : "et"); + }, { ...host, [key]: false, [competingKey]: true }); + }); } test("Host Details device type override can return to the group", async () => {