From 900cd19cbb3fb4c98084192145c6f34cc754c990 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:25:38 +0800 Subject: [PATCH] fix(vault): restore Host Details inheritance (#4441) --- application/i18n/locales/en/core.ts | 1 + application/i18n/locales/es/core.ts | 1 + application/i18n/locales/ru/core.ts | 1 + application/i18n/locales/zh-CN/core.ts | 1 + application/i18n/locales/zh-TW/core.ts | 1 + components/HostDetailsAdvancedSections.tsx | 77 ++++--- components/HostDetailsPanel.helpers.ts | 2 +- components/HostDetailsPanel.inherit.test.tsx | 195 ++++++++++++++++++ .../HostDetailsPanel.proxyProfile.test.tsx | 46 ++++- components/HostDetailsPanel.tsx | 8 +- .../runtime/terminalBackspaceInput.test.ts | 1 + domain/groupConfig.test.ts | 7 + domain/models/connection.ts | 4 +- 13 files changed, 313 insertions(+), 32 deletions(-) create mode 100644 components/HostDetailsPanel.inherit.test.tsx diff --git a/application/i18n/locales/en/core.ts b/application/i18n/locales/en/core.ts index ba3368806..a9f786fd1 100644 --- a/application/i18n/locales/en/core.ts +++ b/application/i18n/locales/en/core.ts @@ -98,6 +98,7 @@ export const enCoreMessages: Messages = { 'common.apply': 'Apply', 'common.use': 'Use', 'common.useGlobal': 'Use global', + 'common.useGroup': 'Use group', 'common.saveChanges': 'Save Changes', 'common.advanced': 'Advanced', 'common.left': 'Left', diff --git a/application/i18n/locales/es/core.ts b/application/i18n/locales/es/core.ts index b9bd60953..1c7a985b9 100644 --- a/application/i18n/locales/es/core.ts +++ b/application/i18n/locales/es/core.ts @@ -98,6 +98,7 @@ export const esCoreMessages: Messages = { 'common.apply': 'Aplicar', 'common.use': 'Usar', 'common.useGlobal': 'Usar global', + 'common.useGroup': 'Usar grupo', 'common.saveChanges': 'Guardar cambios', 'common.advanced': 'Avanzado', 'common.left': 'Izquierda', diff --git a/application/i18n/locales/ru/core.ts b/application/i18n/locales/ru/core.ts index 400ad3d3b..56471acec 100644 --- a/application/i18n/locales/ru/core.ts +++ b/application/i18n/locales/ru/core.ts @@ -71,6 +71,7 @@ export const ruCoreMessages: Messages = { 'common.apply': 'Применить', 'common.use': 'Использовать', 'common.useGlobal': 'Использовать глобальное', + 'common.useGroup': 'Использовать настройки группы', 'common.saveChanges': 'Сохранить изменения', 'common.advanced': 'Дополнительно', 'common.left': 'Слева', diff --git a/application/i18n/locales/zh-CN/core.ts b/application/i18n/locales/zh-CN/core.ts index 669287bd5..518fcf5be 100644 --- a/application/i18n/locales/zh-CN/core.ts +++ b/application/i18n/locales/zh-CN/core.ts @@ -89,6 +89,7 @@ export const zhCNCoreMessages: Messages = { 'common.apply': '应用', 'common.use': '使用', 'common.useGlobal': '跟随全局', + 'common.useGroup': '跟随分组', 'common.left': '左侧', 'common.right': '右侧', 'common.more': '更多', diff --git a/application/i18n/locales/zh-TW/core.ts b/application/i18n/locales/zh-TW/core.ts index 14c61c3d9..2e2e510e7 100644 --- a/application/i18n/locales/zh-TW/core.ts +++ b/application/i18n/locales/zh-TW/core.ts @@ -89,6 +89,7 @@ export const zhTWCoreMessages: Messages = { 'common.apply': '套用', 'common.use': '使用', 'common.useGlobal': '跟隨全域', + 'common.useGroup': '跟隨群組', 'common.left': '左側', 'common.right': '右側', 'common.more': '更多', diff --git a/components/HostDetailsAdvancedSections.tsx b/components/HostDetailsAdvancedSections.tsx index 83f84d158..96a49d8b0 100644 --- a/components/HostDetailsAdvancedSections.tsx +++ b/components/HostDetailsAdvancedSections.tsx @@ -24,10 +24,13 @@ import { // eslint-disable-next-line @typescript-eslint/no-explicit-any type HostDetailsAdvancedSectionsProps = Record; -const ToggleRow: React.FC<{ label: string; hint?: React.ReactNode; enabled: boolean; disabled?: boolean; onToggle: () => void }> = ({ label, hint, enabled, disabled, onToggle }) => { +const ToggleRow: React.FC<{ label: string; hint?: React.ReactNode; enabled: boolean; disabled?: boolean; onToggle: () => void; inheritance?: React.ReactNode }> = ({ label, hint, enabled, disabled, onToggle, inheritance }) => { return ( - onToggle()} /> +
+ {inheritance} + onToggle()} /> +
); }; @@ -49,6 +52,7 @@ export const HostDetailsAdvancedSections: React.FC { const inheritedDeviceType = effectiveGroupDefaults?.deviceType; const effectiveDeviceType = form.deviceType ?? inheritedDeviceType; + const effectiveMoshEnabled = form.moshEnabled ?? effectiveGroupDefaults?.moshEnabled; + const effectiveEtEnabled = form.etEnabled ?? effectiveGroupDefaults?.etEnabled; + const inheritedBackspaceBehavior = effectiveGroupDefaults?.backspaceBehavior; + const groupSettingControl = (key: "moshEnabled" | "etEnabled" | "deviceType" | "backspaceBehavior") => { + if (effectiveGroupDefaults?.[key] === undefined) return null; + return form[key] === undefined ? ( + + {t("vault.groups.details.inherited")} + + ) : ( + update(key, undefined)} /> + ); + }; const inheritedStartupCommandRunMode = effectiveGroupDefaults?.startupCommandRunMode ?? "paste"; const effectiveStartupCommandRunMode = form.startupCommandRunMode ?? inheritedStartupCommandRunMode; const systemSshAgentSupported = effectiveAuthMethod === "auto" || effectiveAuthMethod === "key"; @@ -197,9 +214,10 @@ export const HostDetailsAdvancedSections: React.FC { - const enabling = !form.moshEnabled; + const enabling = !effectiveMoshEnabled; if (enabling) { setForm(prev => ({ ...prev, @@ -220,9 +238,10 @@ export const HostDetailsAdvancedSections: React.FC { - const enabling = !form.etEnabled; + const enabling = !effectiveEtEnabled; if (enabling) { setForm(prev => ({ ...prev, @@ -235,7 +254,7 @@ export const HostDetailsAdvancedSections: React.FC - {form.etEnabled && ( + {effectiveEtEnabled && ( <> } title={t("hostDetails.section.deviceType")} > - {(!form.protocol || form.protocol === 'ssh') && !form.moshEnabled && !form.etEnabled && (<> + {(!form.protocol || form.protocol === 'ssh') && !effectiveMoshEnabled && !effectiveEtEnabled && (<> update("deviceType", effectiveDeviceType === 'network' ? 'general' : 'network')} /> {effectiveDeviceType === 'network' && ( @@ -485,7 +505,7 @@ export const HostDetailsAdvancedSections: React.FC update("showLineTimestamps", !form.showLineTimestamps)} /> - {(form.protocol === undefined || form.protocol === "ssh") && !form.moshEnabled && !form.etEnabled && ( + {(form.protocol === undefined || form.protocol === "ssh") && !effectiveMoshEnabled && !effectiveEtEnabled && ( <> )} - +
+ {form.backspaceBehavior !== undefined && groupSettingControl("backspaceBehavior")} + +
+ {form.backspaceBehavior === undefined && groupSettingControl("backspaceBehavior")} {/* Per-host keepalive override */} @@ -634,9 +658,14 @@ export const HostDetailsAdvancedSections: React.FC ) : ( - - {t("hostDetails.jumpHosts.direct")} - +
+ + {t("hostDetails.jumpHosts.direct")} + + {canRestoreHostChain && ( + + )} +
) } > diff --git a/components/HostDetailsPanel.helpers.ts b/components/HostDetailsPanel.helpers.ts index 19f8acb6d..36c65902e 100644 --- a/components/HostDetailsPanel.helpers.ts +++ b/components/HostDetailsPanel.helpers.ts @@ -225,7 +225,7 @@ export const nextFormAfterClearHostChain = ( groupDefaults && applyGroupDefaults({ ...prev, hostChain: undefined }, groupDefaults).hostChain?.hostIds?.length, ); - if (prev.hostChain === undefined || groupWouldRestore) { + if (prev.hostChain === undefined || (groupWouldRestore && prev.hostChain.hostIds?.length)) { return { ...prev, hostChain: { hostIds: [] } }; } const { hostChain: _hostChain, ...rest } = prev; diff --git a/components/HostDetailsPanel.inherit.test.tsx b/components/HostDetailsPanel.inherit.test.tsx new file mode 100644 index 000000000..4c8dc9c2b --- /dev/null +++ b/components/HostDetailsPanel.inherit.test.tsx @@ -0,0 +1,195 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import React from "react"; +import { act, create, type ReactTestInstance, type ReactTestRenderer } from "react-test-renderer"; +import { I18nProvider } from "../application/i18n/I18nProvider"; +import { applyGroupDefaults } from "../domain/groupConfig"; +import type { GroupConfig, Host } from "../domain/models"; +import HostDetailsPanel from "./HostDetailsPanel"; +import { ChainPanel } from "./host-details/ChainPanel"; +import { HostDetailsOverrideReset } from "./host-details/HostDetailsOverrideReset"; +import { HostDetailsSection, HostDetailsSettingRow } from "./host-details/HostDetailsSection"; +import { mapTerminalBackspaceInput } from "./terminal/runtime/terminalBackspaceInput"; +import { installDomEnvironment } from "./test-support/renderReactDom"; +import { AsidePanelFooter } from "./ui/aside-panel"; +import { Badge } from "./ui/badge"; +import { Button } from "./ui/button"; +import { Select } from "./ui/select"; +import { Switch } from "./ui/switch"; +import { TooltipProvider } from "./ui/tooltip"; + +const host: Host = { + id: "host-1", label: "Host", hostname: "example.com", username: "root", + password: "password", authMethod: "password", tags: [], os: "linux", + protocol: "ssh", group: "network", +}; + +const panelProps = (groupDefaults: Partial, initialData = host) => ({ + initialData, availableKeys: [], identities: [], proxyProfiles: [], + groups: ["network"], groupConfigs: [{ path: "network", ...groupDefaults }], + allHosts: [{ ...host, id: "jump-1", label: "Jump", hostname: "jump.example.com" }], + terminalThemeId: "default", terminalFontSize: 14, layout: "inline" as const, + onSave: (_value: Host) => {}, onCancel: () => {}, +}); + +async function withPanel( + groupDefaults: Partial, + run: (editor: { root: ReactTestInstance; save: () => Promise }) => Promise, + initialData = host, +) { + const dom = installDomEnvironment(); + const previousRaf = globalThis.requestAnimationFrame; + const previousCancelRaf = globalThis.cancelAnimationFrame; + globalThis.requestAnimationFrame = (callback) => setTimeout(() => callback(0), 0) as unknown as number; + globalThis.cancelAnimationFrame = (id) => clearTimeout(id); + let renderer: ReactTestRenderer | undefined; + let saved: Host | undefined; + try { + await act(async () => { + renderer = create( + { saved = value; }} /> + ); + }); + await run({ + root: renderer!.root, + save: async () => { + saved = undefined; + await act(async () => { + const buttons = renderer!.root.findByType(AsidePanelFooter).findAllByType(Button); + await buttons[buttons.length - 1].props.onClick(); + }); + assert.ok(saved, "the actual panel save handler must emit a host"); + return saved; + }, + }); + } finally { + if (renderer) await act(async () => { renderer!.unmount(); }); + globalThis.requestAnimationFrame = previousRaf; + globalThis.cancelAnimationFrame = previousCancelRaf; + dom.cleanup(); + } +} + +function setting(root: ReactTestInstance, label: string) { + const row = root.findAllByType(HostDetailsSettingRow).find((node) => node.props.label === label); + assert.ok(row, `expected setting ${label}`); + return row; +} + +function assertInherited(row: ReactTestInstance) { + assert.ok(row.findAllByType(Badge).some((badge) => badge.props.children === "Inherited from group")); + assert.equal(row.findAllByType(HostDetailsOverrideReset).length, 0); +} + +for (const [key, label] of [["moshEnabled", "Mosh"], ["etEnabled", "EternalTerminal"]] as const) { + test(`Host Details shows inherited ${label}, saves Off, and resets to the group`, async () => { + const group = { [key]: true }; + await withPanel(group, async ({ root, save }) => { + const row = () => setting(root, label); + assert.equal(row().findByType(Switch).props.checked, true); + assertInherited(row()); + assert.equal(root.findAllByType(HostDetailsSettingRow).some((node) => node.props.label === "Network Device Mode"), false); + if (key === "etEnabled") setting(root, "ET server port"); + + await act(async () => { row().findByType(Switch).props.onCheckedChange(false); }); + const off = await save(); + assert.equal(off[key], false); + assert.equal(applyGroupDefaults(off, group)[key], false); + assert.equal(row().findByType(Switch).props.checked, false); + assert.equal(row().findAllByType(Badge).length, 0); + if (key === "etEnabled") { + assert.equal(root.findAllByType(HostDetailsSettingRow).some((node) => node.props.label === "ET server port"), false); + } + + 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(applyGroupDefaults(inherited, group)[key], true); + assert.equal(row().findByType(Switch).props.checked, true); + assertInherited(row()); + }); + }); +} + +test("Host Details device type override can return to the group", async () => { + const group = { deviceType: "network" as const }; + await withPanel(group, async ({ root, save }) => { + const row = () => setting(root, "Network Device Mode"); + assert.equal(row().findByType(Switch).props.checked, true); + assertInherited(row()); + await act(async () => { row().findByType(Switch).props.onCheckedChange(false); }); + assert.equal((await save()).deviceType, "general"); + assert.equal(row().findByType(Switch).props.checked, false); + await act(async () => { row().findByType(HostDetailsOverrideReset).props.onClick(); }); + const inherited = await save(); + assert.equal(inherited.deviceType, undefined); + assert.equal(applyGroupDefaults(inherited, group).deviceType, "network"); + assert.equal(row().findByType(Switch).props.checked, true); + assertInherited(row()); + }); +}); + +test("Host Details backspace shows inherited Ctrl-H and saves explicit DEL or Ctrl-H or inherit", async () => { + const group = { backspaceBehavior: "ctrl-h" as const }; + await withPanel(group, async ({ root, save }) => { + const select = () => setting(root, "Backspace Behavior").findByType(Select); + assert.equal(select().props.value, "ctrl-h"); + assert.ok(root.findAllByType(Badge).some((badge) => badge.props.children === "Inherited from group")); + await act(async () => { select().props.onValueChange("default"); }); + const del = await save(); + assert.equal(del.backspaceBehavior, "default"); + const reloaded: Host = JSON.parse(JSON.stringify(del)); + assert.equal(mapTerminalBackspaceInput("\x7f", applyGroupDefaults(reloaded, group).backspaceBehavior), "\x7f"); + assert.equal(select().props.value, "default"); + await act(async () => { select().props.onValueChange("ctrl-h"); }); + assert.equal((await save()).backspaceBehavior, "ctrl-h"); + await act(async () => { setting(root, "Backspace Behavior").findByType(HostDetailsOverrideReset).props.onClick(); }); + const inherited = await save(); + assert.equal(inherited.backspaceBehavior, undefined); + assert.equal(applyGroupDefaults(inherited, group).backspaceBehavior, "ctrl-h"); + assert.equal(select().props.value, "ctrl-h"); + assert.ok(root.findAllByType(Badge).some((badge) => badge.props.children === "Inherited from group")); + }); +}); + +test("Host Details keeps no-group toggle and Default backspace behavior", async () => { + await withPanel({}, async ({ root, save }) => { + const mosh = setting(root, "Mosh"); + assert.equal(mosh.findByType(Switch).props.checked, false); + assert.equal(mosh.findAllByType(HostDetailsOverrideReset).length, 0); + await act(async () => { mosh.findByType(Switch).props.onCheckedChange(true); }); + assert.equal((await save()).moshEnabled, true); + await act(async () => { setting(root, "Mosh").findByType(Switch).props.onCheckedChange(false); }); + assert.equal((await save()).moshEnabled, false); + assert.equal(setting(root, "Mosh").findAllByType(HostDetailsOverrideReset).length, 0); + const select = () => setting(root, "Backspace Behavior").findByType(Select); + await act(async () => { select().props.onValueChange("ctrl-h"); }); + assert.equal((await save()).backspaceBehavior, "ctrl-h"); + await act(async () => { select().props.onValueChange("default"); }); + assert.equal((await save()).backspaceBehavior, undefined); + }); +}); + +test("Host Details can restore group jump hosts from the empty-override Direct row", async () => { + const group = { hostChain: { hostIds: ["jump-1"] } }; + await withPanel(group, async ({ root, save }) => { + const section = () => root.findAllByType(HostDetailsSection).find((node) => node.props.title === "Proxy via Hosts")!; + await act(async () => { section().findAllByType("button").find((node) => node.props.className?.includes("cursor-pointer"))!.props.onClick(); }); + await act(async () => { root.findByType(ChainPanel).props.onClearChain(); }); + await act(async () => { root.findByType(ChainPanel).props.onBack(); }); + const direct = await save(); + assert.deepEqual(direct.hostChain, { hostIds: [] }); + assert.deepEqual(applyGroupDefaults(direct, group).hostChain, { hostIds: [] }); + assert.ok(section().findAllByType(Badge).some((badge) => badge.props.children === "Direct")); + + const reset = section().findByType(HostDetailsOverrideReset); + assert.equal(reset.props.label, "Use group"); + await act(async () => { reset.props.onClick(); }); + const inherited = await save(); + assert.equal(inherited.hostChain, undefined); + assert.deepEqual(applyGroupDefaults(inherited, group).hostChain, group.hostChain); + assert.ok(section().findAllByType(Badge).some((badge) => badge.props.children === "Inherited from group")); + }); +}); diff --git a/components/HostDetailsPanel.proxyProfile.test.tsx b/components/HostDetailsPanel.proxyProfile.test.tsx index 69cf8a5ab..9f38f5ccd 100644 --- a/components/HostDetailsPanel.proxyProfile.test.tsx +++ b/components/HostDetailsPanel.proxyProfile.test.tsx @@ -4,9 +4,10 @@ import React from "react"; import { renderToStaticMarkup } from "react-dom/server"; import { I18nProvider } from "../application/i18n/I18nProvider.tsx"; -import type { Host, Identity } from "../types.ts"; +import type { Host, Identity, ProxyProfile } from "../types.ts"; import HostDetailsPanel, { parseOptionalPortInput } from "./HostDetailsPanel.tsx"; import { applyGroupDefaults } from "../domain/groupConfig.ts"; +import { getActiveGlobalDefaultProxyProfileId, publishActiveGlobalDefaultProxyProfileId } from "../domain/globalDefaultProxy.ts"; import { mapProxySaveErrorKey, prepareProxyConfigForSave, @@ -37,7 +38,7 @@ const hostWithMissingProxyProfile: Host = { const renderHostDetails = ( initialData: Host = hostWithMissingProxyProfile, - options: { identities?: Identity[] } = {}, + options: { identities?: Identity[]; proxyProfiles?: ProxyProfile[] } = {}, ) => renderToStaticMarkup( React.createElement( @@ -50,7 +51,7 @@ const renderHostDetails = ( initialData, availableKeys: [], identities: options.identities ?? [], - proxyProfiles: [], + proxyProfiles: options.proxyProfiles ?? [], groups: [], managedSources: [], allTags: [], @@ -101,6 +102,31 @@ test("HostDetailsPanel labels command proxy summaries consistently", () => { assert.doesNotMatch(markup, /--token secret/); }); +test("HostDetailsPanel displays the inherited global default proxy without a group proxy", () => { + const previous = getActiveGlobalDefaultProxyProfileId(); + try { + publishActiveGlobalDefaultProxyProfileId("global-proxy"); + const markup = renderHostDetails({ ...hostWithMissingProxyProfile, proxyProfileId: undefined }, { + proxyProfiles: [{ + id: "global-proxy", + label: "Global Office Proxy", + config: { type: "http", host: "global-proxy.example.com", port: 8080 }, + createdAt: 1, + }], + }); + + assert.match(markup, /Global Office Proxy/); + assert.match(markup, /Inherited from group/); + assert.doesNotMatch(markup, /Configure proxy/); + + const direct = renderHostDetails({ ...hostWithMissingProxyProfile, proxyProfileId: undefined, directProxy: true }); + assert.match(direct, /Direct \(no proxy\)/); + assert.doesNotMatch(direct, /Global Office Proxy|Inherited from group/); + } finally { + publishActiveGlobalDefaultProxyProfileId(previous); + } +}); + test("HostDetailsPanel keeps explicitly cleared telnet credentials empty", () => { const markup = renderHostDetails({ ...hostWithMissingProxyProfile, @@ -698,6 +724,19 @@ test("clearing an inherited-only chain keeps an empty override instead of restor assert.deepEqual(applyGroupDefaults(cleared, group).hostChain, { hostIds: [] }); }); +test("clearing an empty host-chain override restores group hops on the second clear", () => { + const group = { hostChain: { hostIds: ["jump-1", "jump-host"] } }; + for (const hostChain of [undefined, { hostIds: ["jump-host"] }]) { + const cleared = nextFormAfterClearHostChain({ ...networkSshHost, hostChain }, group); + assert.deepEqual(cleared.hostChain, { hostIds: [] }); + + const restored = nextFormAfterClearHostChain(cleared, group); + assert.equal(restored.hostChain, undefined); + assert.equal(Object.hasOwn(restored, "hostChain"), false); + assert.deepEqual(applyGroupDefaults(restored, group).hostChain, group.hostChain); + } +}); + test("HostDetailsPanel custom proxy draft hides the inherited saved proxy", () => { const markup = renderToStaticMarkup( React.createElement( @@ -749,6 +788,7 @@ test("HostDetailsPanel empty jump-host override hides the inherited group chain" assert.doesNotMatch(markup, /bastion\.example\.com/); assert.doesNotMatch(markup, /edge\.example\.com/); assert.doesNotMatch(markup, /Inherited from group/); + assert.match(markup, /aria-label="Use group"/); }); test("mapProxySaveErrorKey maps every proxy save validation error to its i18n key", () => { diff --git a/components/HostDetailsPanel.tsx b/components/HostDetailsPanel.tsx index e09e6b401..be898498b 100644 --- a/components/HostDetailsPanel.tsx +++ b/components/HostDetailsPanel.tsx @@ -378,7 +378,7 @@ const HostDetailsPanel: React.FC = ({ }, [defaultGroup, form.group, groupConfigs, groupDefaults]); const effectiveAuthHost = useMemo( - () => effectiveGroupDefaults ? applyGroupDefaults(form, effectiveGroupDefaults) : form, + () => applyGroupDefaults(form, effectiveGroupDefaults ?? {}), [effectiveGroupDefaults, form], ); @@ -449,7 +449,7 @@ const HostDetailsPanel: React.FC = ({ const hasMissingProxyProfile = Boolean(displayProxyProfileId && !selectedProxyProfile); const proxyInherited = !hasHostProxyOverride && Boolean( displayProxyProfileId || displayProxyConfig?.host || displayProxyConfig?.command, - ) && Boolean(effectiveGroupDefaults?.proxyProfileId || effectiveGroupDefaults?.proxyConfig); + ); const proxySummaryType = hasMissingProxyProfile ? t("hostDetails.proxyPanel.missing") : formatProxyConfigType(selectedProxyProfile?.config || displayProxyConfig) || "HTTP"; @@ -794,6 +794,9 @@ const HostDetailsPanel: React.FC = ({ [effectiveAuthHost.hostChain?.hostIds, form.hostChain], ); const hostChainInherited = form.hostChain === undefined && displayHostChainIds.length > 0; + const canRestoreHostChain = form.hostChain !== undefined + && !form.hostChain.hostIds?.length + && resolveFormHostChainIds({ ...form, hostChain: undefined }, effectiveGroupDefaults).length > 0; const availableHostsForChain = useMemo(() => { const chainedIds = new Set(displayHostChainIds); @@ -1262,6 +1265,7 @@ const HostDetailsPanel: React.FC = ({ setShowAlgorithmOverrides={setShowAlgorithmOverrides} chainedHosts={chainedHosts} hostChainInherited={hostChainInherited} + canRestoreHostChain={canRestoreHostChain} setActiveSubPanel={setActiveSubPanel} clearHostChain={clearHostChain} proxySummaryType={proxySummaryType} diff --git a/components/terminal/runtime/terminalBackspaceInput.test.ts b/components/terminal/runtime/terminalBackspaceInput.test.ts index 5f1f1f37b..5de44b283 100644 --- a/components/terminal/runtime/terminalBackspaceInput.test.ts +++ b/components/terminal/runtime/terminalBackspaceInput.test.ts @@ -21,5 +21,6 @@ test("Ctrl-H mode makes Backspace delete on network-device serial consoles", () test("default mode preserves xterm Backspace and ordinary input", () => { assert.equal(mapTerminalBackspaceInput("\x7f", undefined), "\x7f"); + assert.equal(mapTerminalBackspaceInput("\x7f", "default"), "\x7f"); assert.equal(mapTerminalBackspaceInput("show version", "ctrl-h"), "show version"); }); diff --git a/domain/groupConfig.test.ts b/domain/groupConfig.test.ts index 1dd21974e..db4b5eb02 100644 --- a/domain/groupConfig.test.ts +++ b/domain/groupConfig.test.ts @@ -63,6 +63,13 @@ test("applyGroupDefaults lets host device type override group device type", () = assert.equal(result.deviceType, "general"); }); +test("applyGroupDefaults preserves explicit DEL over group Ctrl-H after persistence", () => { + const groupDefaults: Partial = { backspaceBehavior: "ctrl-h" }; + const saved: Host = JSON.parse(JSON.stringify(host({ backspaceBehavior: "default" }))); + assert.equal(applyGroupDefaults(saved, groupDefaults).backspaceBehavior, "default"); + assert.equal(applyGroupDefaults(host(), groupDefaults).backspaceBehavior, "ctrl-h"); +}); + test("applyGroupDefaults skips remote-only device type for local shell hosts", () => { const result = applyGroupDefaults(host({ protocol: "local" }), { deviceType: "network" }); diff --git a/domain/models/connection.ts b/domain/models/connection.ts index a9d23a4c5..b28f56028 100644 --- a/domain/models/connection.ts +++ b/domain/models/connection.ts @@ -314,8 +314,8 @@ export interface Host { // Show local timestamps for this host beside terminal output rows. // Kept per-host because timestamp visibility is usually a host/workflow preference. showLineTimestamps?: boolean; - // What the Backspace key sends: undefined = xterm default (no interception), 'ctrl-h' = ^H (0x08) - backspaceBehavior?: 'ctrl-h'; + // Undefined inherits; 'default' sends DEL (0x7F), 'ctrl-h' sends ^H (0x08). + backspaceBehavior?: 'default' | 'ctrl-h'; // When true, tab titles stay on the connection label instead of following the // shell-reported window title (OSC 0/2). Useful when many hosts share one // bastion profile name.