From 554bc3d2ab3c8467dcda2ccf8024514da0608f3f 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: Mon, 2 Feb 2026 01:56:07 +0800 Subject: [PATCH] Show connection details in host selector (#173) * Show user@host:port in host selector Replace the host selector subtitle with username, hostname, and port to surface the actual connection target details. Co-Authored-By: Claude Opus 4.5 * Filter serial hosts from selector Exclude serial protocol entries from SelectHostPanel results and counts to avoid offering non-SSH targets in selection flows. Co-Authored-By: Claude Opus 4.5 --------- Co-authored-by: Claude Opus 4.5 --- components/SelectHostPanel.tsx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/components/SelectHostPanel.tsx b/components/SelectHostPanel.tsx index afee921a2..950593834 100644 --- a/components/SelectHostPanel.tsx +++ b/components/SelectHostPanel.tsx @@ -66,21 +66,26 @@ const SelectHostPanel: React.FC = ({ const [selectedTags, setSelectedTags] = useState([]); const [showNewHostPanel, setShowNewHostPanel] = useState(false); + const selectableHosts = useMemo( + () => hosts.filter((host) => host.protocol !== "serial"), + [hosts] + ); + // Get all unique tags from hosts const allTags = useMemo(() => { const tagSet = new Set(); - hosts.forEach((h) => { + selectableHosts.forEach((h) => { if (h.tags) { h.tags.forEach((tag) => tagSet.add(tag)); } }); return Array.from(tagSet).sort(); - }, [hosts]); + }, [selectableHosts]); // Get unique group paths from both hosts and customGroups const allGroupPaths = useMemo(() => { const pathSet = new Set(); - hosts.forEach((h) => { + selectableHosts.forEach((h) => { if (h.group) { // Add all parent paths as well const parts = h.group.split("/"); @@ -91,7 +96,7 @@ const SelectHostPanel: React.FC = ({ }); customGroups.forEach((g) => pathSet.add(g)); return Array.from(pathSet).sort(); - }, [hosts, customGroups]); + }, [selectableHosts, customGroups]); // Get groups at current level const groupsWithCounts = useMemo(() => { @@ -105,7 +110,7 @@ const SelectHostPanel: React.FC = ({ const topLevel = path.split("/")[0]; if (!seen.has(topLevel)) { seen.add(topLevel); - const count = hosts.filter( + const count = selectableHosts.filter( (h) => h.group && (h.group === topLevel || h.group.startsWith(`${topLevel}/`)), @@ -119,7 +124,7 @@ const SelectHostPanel: React.FC = ({ const fullPath = `${prefix}${nextLevel}`; if (!seen.has(fullPath)) { seen.add(fullPath); - const count = hosts.filter( + const count = selectableHosts.filter( (h) => h.group && (h.group === fullPath || h.group.startsWith(`${fullPath}/`)), @@ -130,11 +135,11 @@ const SelectHostPanel: React.FC = ({ }); return groups; - }, [allGroupPaths, currentPath, hosts]); + }, [allGroupPaths, currentPath, selectableHosts]); // Get hosts at current level with filtering and sorting const filteredHosts = useMemo(() => { - let result = hosts; + let result = selectableHosts; // Filter by current path if (currentPath) { @@ -180,7 +185,7 @@ const SelectHostPanel: React.FC = ({ }); return result; - }, [hosts, currentPath, searchQuery, selectedTags, sortMode]); + }, [selectableHosts, currentPath, searchQuery, selectedTags, sortMode]); // Build breadcrumb from current path const breadcrumbs = useMemo(() => { @@ -359,7 +364,7 @@ const SelectHostPanel: React.FC = ({
{host.label}
- {host.protocol || "ssh"}, {host.username} + {host.username}@{host.hostname}:{host.port || 22}
{isSelected && ( @@ -390,7 +395,7 @@ const SelectHostPanel: React.FC = ({ if (onContinue) { onContinue(); } else { - const host = hosts.find((h) => selectedHostIds.includes(h.id)); + const host = selectableHosts.find((h) => selectedHostIds.includes(h.id)); if (host) { onSelect(host); }