feat: move terminal settings, look and ssh tools into ssh-terminal plugin

This commit is contained in:
LukeGus committed 2026-09-29 02:38:37 -05:00
1 parent ffa872ebd3
commit d9bba10612
242 files changed
+25071 -7207

No files matched your search

@@ -0,0 +1,72 @@
import { describe, expect, it } from "vitest";
import {
hasSshOptions,
parseSshOptions,
sshOptionsForWrite,
} from "../../hosts/ssh-options.js";
describe("parseSshOptions", () => {
it("keeps the connection options, typed, and drops everything else", () => {
expect(
parseSshOptions(
JSON.stringify({
keepaliveInterval: "30",
keepaliveCountMax: 3,
allowLegacyAlgorithms: false,
agentSocketPath: "/run/agent",
agentIdentity: null,
agentForwarding: true,
environmentVariables: [{ key: "A", value: 1 }, null],
theme: "nord",
cfAccessClientId: "gone",
}),
),
).toEqual({
keepaliveInterval: 30,
keepaliveCountMax: 3,
allowLegacyAlgorithms: false,
agentSocketPath: "/run/agent",
agentIdentity: null,
agentForwarding: true,
environmentVariables: [{ key: "A", value: "1" }],
});
});
it("reads twice-stringified rows and ignores garbage", () => {
expect(
parseSshOptions(JSON.stringify(JSON.stringify({ keepaliveInterval: 5 }))),
).toEqual({ keepaliveInterval: 5 });
expect(parseSshOptions("nope")).toEqual({});
expect(parseSshOptions(null)).toEqual({});
expect(parseSshOptions([1])).toEqual({});
});
it("says whether a value carries any option", () => {
expect(hasSshOptions({ theme: "nord" })).toBe(false);
expect(hasSshOptions({ agentForwarding: false })).toBe(true);
});
});
describe("sshOptionsForWrite", () => {
it("stores the payload's own options", () => {
expect(
sshOptionsForWrite({ sshOptions: { keepaliveInterval: 9, junk: 1 } }),
).toBe(JSON.stringify({ keepaliveInterval: 9 }));
expect(sshOptionsForWrite({ sshOptions: null })).toBeNull();
});
it("takes them from a 2.8 terminalConfig when the payload has none", () => {
expect(
sshOptionsForWrite({
terminalConfig: { keepaliveCountMax: 2, theme: "nord" },
}),
).toBe(JSON.stringify({ keepaliveCountMax: 2 }));
});
it("leaves the column alone when neither carries any", () => {
expect(sshOptionsForWrite({ terminalConfig: { theme: "nord" } })).toBe(
undefined,
);
expect(sshOptionsForWrite({})).toBeUndefined();
});
});