diff --git a/src/ui/sidebar/HostManagerData.ts b/src/ui/sidebar/HostManagerData.ts index e4235f205..3fa07c728 100644 --- a/src/ui/sidebar/HostManagerData.ts +++ b/src/ui/sidebar/HostManagerData.ts @@ -91,6 +91,7 @@ export function sshHostToHost(h: SSHHostWithStatus): Host { statusCheckEnabled: h.statusCheckEnabled !== false, statusCheckInterval: h.statusCheckInterval ?? null, forceKeyboardInteractive: h.forceKeyboardInteractive ?? false, + pluginSettings: h.pluginSettings, useSocks5: h.useSocks5, socks5Host: h.socks5Host, socks5Port: h.socks5Port, diff --git a/src/ui/tests/sidebar/host-sharing-settings.test.tsx b/src/ui/tests/sidebar/host-sharing-settings.test.tsx new file mode 100644 index 000000000..7a0fca96f --- /dev/null +++ b/src/ui/tests/sidebar/host-sharing-settings.test.tsx @@ -0,0 +1,61 @@ +import { afterEach, describe, expect, it, vi } from "vitest"; +import { cleanup, fireEvent, render, screen } from "@testing-library/react"; +import type { PluginSummary } from "@/api/plugins-api"; +import { sshHostToHost } from "@/sidebar/HostManagerData"; +import { createHostEditorForm } from "@/sidebar/HostEditorData"; +import { HostPluginSections } from "@/settings/HostPluginSections"; +import manifest from "../../../../plugins/session-sharing/manifest.json"; + +vi.mock("react-i18next", () => ({ + useTranslation: () => ({ t: (key: string) => key }), +})); + +afterEach(cleanup); + +describe("host sharing settings on reopening the editor", () => { + it.each([false, true])("retains the saved sharing value %s", (saved) => { + const pluginSettings = { + "session-sharing": { allowSessionSharing: saved }, + "ssh-terminal": { enableCommandHistory: false }, + }; + const host = sshHostToHost({ + id: 1, + name: "server", + ip: "192.0.2.1", + port: 22, + username: "alice", + folder: "", + tags: [], + pin: false, + authType: "password", + status: "online", + createdAt: "2026-09-29T00:00:00Z", + updatedAt: "2026-09-29T00:00:00Z", + pluginSettings, + }); + const form = createHostEditorForm(host); + const setValue = vi.fn(); + render( + , + ); + + // The toggle starts from the server value, including false despite its true default. + fireEvent.click(screen.getByRole("button")); + expect(setValue).toHaveBeenCalledWith( + "session-sharing", + "allowSessionSharing", + !saved, + ); + expect(form.pluginSettings).toEqual(pluginSettings); + }); +});