* Vault global search spans all groups/packages (#777) Search was scoped to the current group (hosts page) or the current package (snippets page), so a host or snippet the user wanted to find could stay hidden unless they first navigated into the right group — especially confusing with the "root only shows ungrouped hosts" setting enabled. When the search box is non-empty: - hosts: skip the selectedGroupPath / showOnlyUngroupedHostsInRoot filters entirely. Each matching card shows a small outline badge with the host's group so cross-group origin is visible. - snippets: skip the current-package filter. Hide the sub-package grid (would be redundant alongside a flat cross-package match list). Each snippet card shows the package path as a small badge. Tree view already followed this "search crosses groups" shape — see `treeViewHosts` — so this aligns the flat grid/list views with it. * Show no-results feedback when snippet search is empty (#777) Addresses Codex P2 review on PR #785. With the package tile grid hidden during search and no matching snippets, the content area was blank and the global empty state did not render (it requires snippets.length === 0). Add a dedicated no-results panel for the "user is searching and nothing matched but there are other snippets" case, with i18n for en and zh-CN. * Drop group/package badges on search results (#777) Search is itself a filter, so decorating each result card with the group/package it came from added visual noise without adding information. Only difference vs. pre-search rendering now is that the result set spans all groups/packages. * Fix snippet no-results empty state with packages present (#777) Addresses Codex P2 on 4a778e63. The empty-state gate was displayedPackages.length === 0, but package tiles are hidden during search regardless of count. Any workspace that had packages was rendering a blank content area on zero-match queries because that guard never passed. Drop the package-count condition — the flat snippet list is the only visible surface while searching. * Cover package-only workspaces in snippet search no-results (#777) Addresses Codex P2 on ccdf6afc. snippets.length > 0 also excluded workspaces where the user has only created packages (no snippets yet). The correct gate is the inverse of the global empty state's condition, so we fall back whenever the workspace isn't completely empty.
This commit is contained in:
@@ -1682,6 +1682,8 @@ const en: Messages = {
|
||||
'snippets.breadcrumb.separator': '›',
|
||||
'snippets.empty.title': 'Create snippet',
|
||||
'snippets.empty.desc': 'Save your most used commands as snippets to reuse them in one click.',
|
||||
'snippets.search.noResults.title': 'No matches',
|
||||
'snippets.search.noResults.desc': 'No snippets or packages match "{query}". Try a different search term or clear the search to browse.',
|
||||
'snippets.section.packages': 'Packages',
|
||||
'snippets.section.snippets': 'Snippets',
|
||||
'snippets.package.count': '{count} snippet(s)',
|
||||
|
||||
@@ -1690,6 +1690,8 @@ const zhCN: Messages = {
|
||||
'snippets.breadcrumb.separator': '›',
|
||||
'snippets.empty.title': '创建代码片段',
|
||||
'snippets.empty.desc': '将常用命令保存为代码片段,一键复用。',
|
||||
'snippets.search.noResults.title': '无匹配结果',
|
||||
'snippets.search.noResults.desc': '没有代码片段或代码包与"{query}"匹配。换一个关键字,或清除搜索进行浏览。',
|
||||
'snippets.section.packages': '代码包',
|
||||
'snippets.section.snippets': '代码片段',
|
||||
'snippets.package.count': '{count} 个代码片段',
|
||||
|
||||
@@ -402,9 +402,15 @@ const SnippetsManager: React.FC<SnippetsManagerProps> = ({
|
||||
}, [packages, selectedPackage, snippets]);
|
||||
|
||||
const displayedSnippets = useMemo(() => {
|
||||
let result = snippets.filter((s) => (s.package || '') === (selectedPackage || ''));
|
||||
// Apply search filter
|
||||
if (search.trim()) {
|
||||
// Search spans all packages (#777): when the user types in the search
|
||||
// box we drop the current-package scoping so cross-package matches are
|
||||
// reachable without navigating into each one. Otherwise the user is
|
||||
// browsing and we keep the package scope.
|
||||
const hasSearch = search.trim().length > 0;
|
||||
let result = hasSearch
|
||||
? snippets
|
||||
: snippets.filter((s) => (s.package || '') === (selectedPackage || ''));
|
||||
if (hasSearch) {
|
||||
const s = search.toLowerCase();
|
||||
result = result.filter(sn =>
|
||||
sn.label.toLowerCase().includes(s) ||
|
||||
@@ -1068,7 +1074,10 @@ const SnippetsManager: React.FC<SnippetsManagerProps> = ({
|
||||
)}
|
||||
|
||||
<div className="flex-1 space-y-3 overflow-y-auto px-4 pb-4">
|
||||
{displayedPackages.length > 0 && (
|
||||
{/* Hide the sub-package grid while searching (#777) — search spans
|
||||
all packages, so showing the package tiles alongside a flat
|
||||
cross-package snippet list is noisy. */}
|
||||
{displayedPackages.length > 0 && !search.trim() && (
|
||||
<>
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold text-muted-foreground">{t('snippets.section.packages')}</h3>
|
||||
@@ -1215,6 +1224,29 @@ const SnippetsManager: React.FC<SnippetsManagerProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Search-with-no-results feedback (#777 codex follow-up). Package
|
||||
tiles are already hidden during search, so the only visible
|
||||
surface is the flat snippet list — if that's empty the content
|
||||
area would be blank without this fallback. The gate intentionally
|
||||
excludes the fully-empty workspace (snippets.length === 0 AND
|
||||
displayedPackages.length === 0), which the global "Create
|
||||
snippet" empty state renders instead — avoids stacking two
|
||||
empty states. Package-only workspaces (no snippets yet) still
|
||||
get this feedback when searching. */}
|
||||
{search.trim() && displayedSnippets.length === 0 && (snippets.length > 0 || displayedPackages.length > 0) && (
|
||||
<div className="flex flex-col items-center justify-center py-16 text-muted-foreground">
|
||||
<div className="h-14 w-14 rounded-2xl bg-secondary/80 flex items-center justify-center mb-3">
|
||||
<Search size={24} className="opacity-60" />
|
||||
</div>
|
||||
<h3 className="text-base font-semibold text-foreground mb-1">
|
||||
{t('snippets.search.noResults.title')}
|
||||
</h3>
|
||||
<p className="text-xs text-center max-w-sm">
|
||||
{t('snippets.search.noResults.desc', { query: search.trim() })}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -867,23 +867,30 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
|
||||
|
||||
const displayedHosts = useMemo(() => {
|
||||
let filtered = hosts;
|
||||
if (selectedGroupPath) {
|
||||
// Match hosts whose group equals the selected path
|
||||
// For "General" group, also match hosts with empty/undefined group
|
||||
filtered = filtered.filter((h) => {
|
||||
const hostGroup = h.group || "";
|
||||
if (selectedGroupPath === "General") {
|
||||
return hostGroup === "" || hostGroup === "General";
|
||||
}
|
||||
return hostGroup === selectedGroupPath;
|
||||
});
|
||||
} else if (showOnlyUngroupedHostsInRoot) {
|
||||
filtered = filtered.filter((h) => {
|
||||
const hostGroup = (h.group || "").trim();
|
||||
return hostGroup === "";
|
||||
});
|
||||
// Search spans all groups (#777): when the user types in the search box
|
||||
// we skip group/ungrouped-root scoping, so a matching host in another
|
||||
// group is still reachable without having to navigate into it first.
|
||||
// The tree view already uses this shape — see `treeViewHosts` below.
|
||||
const hasSearch = search.trim().length > 0;
|
||||
if (!hasSearch) {
|
||||
if (selectedGroupPath) {
|
||||
// Match hosts whose group equals the selected path
|
||||
// For "General" group, also match hosts with empty/undefined group
|
||||
filtered = filtered.filter((h) => {
|
||||
const hostGroup = h.group || "";
|
||||
if (selectedGroupPath === "General") {
|
||||
return hostGroup === "" || hostGroup === "General";
|
||||
}
|
||||
return hostGroup === selectedGroupPath;
|
||||
});
|
||||
} else if (showOnlyUngroupedHostsInRoot) {
|
||||
filtered = filtered.filter((h) => {
|
||||
const hostGroup = (h.group || "").trim();
|
||||
return hostGroup === "";
|
||||
});
|
||||
}
|
||||
}
|
||||
if (search.trim()) {
|
||||
if (hasSearch) {
|
||||
const s = search.toLowerCase();
|
||||
filtered = filtered.filter(
|
||||
(h) =>
|
||||
|
||||
Reference in New Issue
Block a user