From 7324982f4750dc705938a31f51e10735b9e7f961 Mon Sep 17 00:00:00 2001 From: LukeGus Date: Thu, 15 Oct 2026 21:06:47 -0500 Subject: [PATCH] feat: option to hide the sidebar after opening a host (#1652) --- CHANGELOG.md | 4 ++++ src/types/host-sidebar-preferences.ts | 7 +++++++ src/ui/AppShell.tsx | 1 + src/ui/locales/en.json | 2 ++ src/ui/sidebar/CustomizeSidebarPanel.tsx | 14 ++++++++++++++ src/ui/sidebar/HostsPanel.tsx | 7 ++++++- .../tests/types/host-sidebar-preferences.test.ts | 2 ++ 7 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f24872d3..057c73bf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 26.10.2 +### Added + +- Hide sidebar after opening, in Customize Sidebar, closes the host list once you open a host + ### Fixed - Picking a section lower down in the host editor, like Warpgate, stuttered on the way and sometimes stopped before it got there diff --git a/src/types/host-sidebar-preferences.ts b/src/types/host-sidebar-preferences.ts index bcc90f7c8..56ea4bc1a 100644 --- a/src/types/host-sidebar-preferences.ts +++ b/src/types/host-sidebar-preferences.ts @@ -88,6 +88,8 @@ export interface HostSidebarDisplayPreferences extends HostRowFields { /** When false, nested folders hide the parent-path breadcrumb before their name. */ showFolderPaths: boolean; hostClickBehavior: HostClickBehavior; + /** When true, the sidebar closes after a host is opened from it. */ + closeOnOpen: boolean; /** * Host action id to whether it shows in the row's connect bar. An action * missing here follows its own default. Every action stays in the menu. @@ -163,6 +165,7 @@ export function defaultHostSidebarPreferences(): HostSidebarPreferences { openOnDoubleClick: false, showFolderPaths: true, hostClickBehavior: "newTab", + closeOnOpen: false, barActions: {}, ...defaultHostRowFields(), }, @@ -274,6 +277,10 @@ export function sanitizeHostSidebarPreferences( ) ? (displayObj.hostClickBehavior as HostClickBehavior) : defaults.display.hostClickBehavior, + closeOnOpen: + typeof displayObj.closeOnOpen === "boolean" + ? displayObj.closeOnOpen + : defaults.display.closeOnOpen, barActions: sanitizeBarActions(displayObj.barActions), }; diff --git a/src/ui/AppShell.tsx b/src/ui/AppShell.tsx index aa7793bbb..2a2f0075d 100644 --- a/src/ui/AppShell.tsx +++ b/src/ui/AppShell.tsx @@ -2698,6 +2698,7 @@ export function AppShell({ if (isMobile) setSidebarOpen(false); }} onEditHost={editHostInManager} + onCloseSidebar={() => setSidebarOpen(false)} hostTree={realHostTree ?? undefined} loading={hostsLoading} onEditingChange={panelEditingSetter("hosts")} diff --git a/src/ui/locales/en.json b/src/ui/locales/en.json index 182747207..5d604369e 100644 --- a/src/ui/locales/en.json +++ b/src/ui/locales/en.json @@ -644,6 +644,8 @@ "actionsClick": "Click to expand/collapse", "openOnDoubleClick": "Open on double click", "openOnDoubleClickDesc": "Require a double click to open a host session instead of a single click", + "closeOnOpen": "Hide sidebar after opening", + "closeOnOpenDesc": "Close the sidebar after you open a host from it", "showFolderPaths": "Show folder paths", "showFolderPathsDesc": "Show the parent folder path above nested subfolder names. Subfolders stay indented either way.", "rowDetailsTitle": "Row details", diff --git a/src/ui/sidebar/CustomizeSidebarPanel.tsx b/src/ui/sidebar/CustomizeSidebarPanel.tsx index 64014aaac..b2eca9270 100644 --- a/src/ui/sidebar/CustomizeSidebarPanel.tsx +++ b/src/ui/sidebar/CustomizeSidebarPanel.tsx @@ -223,6 +223,20 @@ export function CustomizeSidebarPanel({ } /> + + + update((prev) => ({ + ...prev, + display: { ...prev.display, closeOnOpen: v }, + })) + } + /> + void; active?: boolean; + onCloseSidebar?: () => void; }) { const { t } = useTranslation(); const { statuses, getStatus } = useServerStatus(); @@ -1044,7 +1046,10 @@ export function HostsPanel({ ).children : [] } - onOpenTab={onOpenTab} + onOpenTab={(host, type, options) => { + onOpenTab(host, type, options); + if (sidebarPrefs.display.closeOnOpen) onCloseSidebar?.(); + }} onEditHost={onEditHost} onShareHost={(host) => setShareModalHost(host)} query={hostSearch.trim().toLowerCase()} diff --git a/src/ui/tests/types/host-sidebar-preferences.test.ts b/src/ui/tests/types/host-sidebar-preferences.test.ts index 470ab4c95..1491446fa 100644 --- a/src/ui/tests/types/host-sidebar-preferences.test.ts +++ b/src/ui/tests/types/host-sidebar-preferences.test.ts @@ -28,6 +28,7 @@ describe("defaultHostSidebarPreferences", () => { openOnDoubleClick: false, showFolderPaths: true, hostClickBehavior: "newTab", + closeOnOpen: false, barActions: {}, showAddress: true, showUsername: true, @@ -74,6 +75,7 @@ describe("sanitizeHostSidebarPreferences", () => { openOnDoubleClick: true, showFolderPaths: false, hostClickBehavior: "focusExistingDoubleClickNew", + closeOnOpen: true, barActions: { maintenance: true }, showAddress: false, showUsername: false,