Compare commits

...
13 changed files with 350 additions and 32 deletions

No files matched your search

+1
View File
@@ -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',
+1
View File
@@ -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',
+1
View File
@@ -71,6 +71,7 @@ export const ruCoreMessages: Messages = {
'common.apply': 'Применить',
'common.use': 'Использовать',
'common.useGlobal': 'Использовать глобальное',
'common.useGroup': 'Использовать настройки группы',
'common.saveChanges': 'Сохранить изменения',
'common.advanced': 'Дополнительно',
'common.left': 'Слева',
+1
View File
@@ -89,6 +89,7 @@ export const zhCNCoreMessages: Messages = {
'common.apply': '应用',
'common.use': '使用',
'common.useGlobal': '跟随全局',
'common.useGroup': '跟随分组',
'common.left': '左侧',
'common.right': '右侧',
'common.more': '更多',
+1
View File
@@ -89,6 +89,7 @@ export const zhTWCoreMessages: Messages = {
'common.apply': '套用',
'common.use': '使用',
'common.useGlobal': '跟隨全域',
'common.useGroup': '跟隨群組',
'common.left': '左側',
'common.right': '右側',
'common.more': '更多',
+63 -24
View File
@@ -24,10 +24,13 @@ import {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type HostDetailsAdvancedSectionsProps = Record<string, any>;
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 (
<HostDetailsSettingRow label={label} hint={hint}>
<Switch checked={enabled} disabled={disabled} onCheckedChange={() => onToggle()} />
<div className="flex items-center gap-2">
{inheritance}
<Switch checked={enabled} disabled={disabled} onCheckedChange={() => onToggle()} />
</div>
</HostDetailsSettingRow>
);
};
@@ -49,6 +52,7 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
setShowAlgorithmOverrides,
chainedHosts,
hostChainInherited = false,
canRestoreHostChain = false,
setActiveSubPanel,
clearHostChain,
proxySummaryType,
@@ -59,6 +63,29 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
}) => {
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 ? (
<Badge variant="outline" className="text-xs text-muted-foreground">
{t("vault.groups.details.inherited")}
</Badge>
) : (
<HostDetailsOverrideReset size="sm" label={t("common.useGroup")} onClick={() => {
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";
const effectiveStartupCommandRunMode = form.startupCommandRunMode ?? inheritedStartupCommandRunMode;
const systemSshAgentSupported = effectiveAuthMethod === "auto" || effectiveAuthMethod === "key";
@@ -197,9 +224,10 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
>
<ToggleRow
label="Mosh"
enabled={!!form.moshEnabled}
enabled={!!effectiveMoshEnabled}
inheritance={groupSettingControl("moshEnabled")}
onToggle={() => {
const enabling = !form.moshEnabled;
const enabling = !effectiveMoshEnabled;
if (enabling) {
setForm(prev => ({
...prev,
@@ -220,9 +248,10 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
>
<ToggleRow
label="EternalTerminal"
enabled={!!form.etEnabled}
enabled={!!effectiveEtEnabled}
inheritance={groupSettingControl("etEnabled")}
onToggle={() => {
const enabling = !form.etEnabled;
const enabling = !effectiveEtEnabled;
if (enabling) {
setForm(prev => ({
...prev,
@@ -235,7 +264,7 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
}
}}
/>
{form.etEnabled && (
{effectiveEtEnabled && (
<>
<HostDetailsSettingRow label={t("hostDetails.et.port")} hint={t("hostDetails.et.port.desc")}>
<Input
@@ -367,11 +396,12 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
icon={<Router size={14} className="text-muted-foreground" />}
title={t("hostDetails.section.deviceType")}
>
{(!form.protocol || form.protocol === 'ssh') && !form.moshEnabled && !form.etEnabled && (<>
{(!form.protocol || form.protocol === 'ssh') && !effectiveMoshEnabled && !effectiveEtEnabled && (<>
<ToggleRow
label={t("hostDetails.deviceType")}
hint={t("hostDetails.deviceType.desc")}
enabled={effectiveDeviceType === 'network'}
inheritance={groupSettingControl("deviceType")}
onToggle={() => update("deviceType", effectiveDeviceType === 'network' ? 'general' : 'network')}
/>
{effectiveDeviceType === 'network' && (
@@ -485,7 +515,7 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
enabled={!!form.showLineTimestamps}
onToggle={() => update("showLineTimestamps", !form.showLineTimestamps)}
/>
{(form.protocol === undefined || form.protocol === "ssh") && !form.moshEnabled && !form.etEnabled && (
{(form.protocol === undefined || form.protocol === "ssh") && !effectiveMoshEnabled && !effectiveEtEnabled && (
<>
<ToggleRow
label={t("hostDetails.sshInputCompatibility")}
@@ -499,19 +529,23 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
</>
)}
<HostDetailsSettingRow label={t("hostDetails.backspaceBehavior")}>
<Select
value={form.backspaceBehavior ?? "default"}
onValueChange={(v) => update("backspaceBehavior", v === "default" ? undefined : v)}
>
<SelectTrigger className="h-8 w-36 text-xs">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="default">{t("hostDetails.backspaceBehavior.default")}</SelectItem>
<SelectItem value="ctrl-h">^H (0x08)</SelectItem>
</SelectContent>
</Select>
<div className="flex items-center gap-2">
{form.backspaceBehavior !== undefined && groupSettingControl("backspaceBehavior")}
<Select
value={form.backspaceBehavior ?? inheritedBackspaceBehavior ?? "default"}
onValueChange={(v) => update("backspaceBehavior", v === "default" && inheritedBackspaceBehavior === undefined ? undefined : v)}
>
<SelectTrigger className="h-8 w-36 text-xs">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="default">{inheritedBackspaceBehavior !== undefined ? t("serial.backspace.default") : t("hostDetails.backspaceBehavior.default")}</SelectItem>
<SelectItem value="ctrl-h">^H (0x08)</SelectItem>
</SelectContent>
</Select>
</div>
</HostDetailsSettingRow>
{form.backspaceBehavior === undefined && groupSettingControl("backspaceBehavior")}
</HostDetailsSection>
{/* Per-host keepalive override */}
@@ -634,9 +668,14 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
</Badge>
</div>
) : (
<Badge variant="outline" className="text-xs text-muted-foreground">
{t("hostDetails.jumpHosts.direct")}
</Badge>
<div className="flex items-center gap-1">
<Badge variant="outline" className="text-xs text-muted-foreground">
{t("hostDetails.jumpHosts.direct")}
</Badge>
{canRestoreHostChain && (
<HostDetailsOverrideReset size="sm" label={t("common.useGroup")} onClick={clearHostChain} />
)}
</div>
)
}
>
+1 -1
View File
@@ -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;
@@ -0,0 +1,222 @@
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 { resolveEffectiveTerminalProtocol } from "../domain/terminalProtocol";
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<GroupConfig>, 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<GroupConfig>,
run: (editor: { root: ReactTestInstance; save: () => Promise<Host> }) => Promise<void>,
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(<I18nProvider locale="en"><TooltipProvider>
<HostDetailsPanel {...panelProps(groupDefaults, initialData)} onSave={(value) => { saved = value; }} />
</TooltipProvider></I18nProvider>);
});
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 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 () => {
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"));
});
});
@@ -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", () => {
+6 -2
View File
@@ -378,7 +378,7 @@ const HostDetailsPanel: React.FC<HostDetailsPanelPropsWithResize> = ({
}, [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<HostDetailsPanelPropsWithResize> = ({
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<HostDetailsPanelPropsWithResize> = ({
[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<HostDetailsPanelPropsWithResize> = ({
setShowAlgorithmOverrides={setShowAlgorithmOverrides}
chainedHosts={chainedHosts}
hostChainInherited={hostChainInherited}
canRestoreHostChain={canRestoreHostChain}
setActiveSubPanel={setActiveSubPanel}
clearHostChain={clearHostChain}
proxySummaryType={proxySummaryType}
@@ -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");
});
+7
View File
@@ -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<GroupConfig> = { 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" });
+2 -2
View File
@@ -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.