Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

address a codex comment and remove folder searching

x03220555a43e6ec787
diff --git a/backend/src/ee/services/pam-account/pam-account-dal.ts b/backend/src/ee/services/pam-account/pam-account-dal.ts
index da7c5f3775..71c7df9b54 100644
--- a/backend/src/ee/services/pam-account/pam-account-dal.ts
+++ b/backend/src/ee/services/pam-account/pam-account-dal.ts
@@ -75,11 +75,7 @@ export const pamAccountDALFactory = (db: TDbClient) => {
}
if (filters?.search) {
const pattern = `%${sanitizeSqlLikeString(filters.search)}%`;
- void baseQuery.where((qb) => {
- void qb
- .whereILike(`${TableName.PamAccount}.name`, pattern)
- .orWhereILike(`${TableName.PamFolder}.name`, pattern);
- });
+ void baseQuery.whereILike(`${TableName.PamAccount}.name`, pattern);
}
const countQuery = baseQuery
diff --git a/frontend/src/pages/pam/PamAccessPage/components/FolderAccountGroup.tsx b/frontend/src/pages/pam/PamAccessPage/components/FolderAccountGroup.tsx
index 5797e76f82..c840f47629 100644
--- a/frontend/src/pages/pam/PamAccessPage/components/FolderAccountGroup.tsx
+++ b/frontend/src/pages/pam/PamAccessPage/components/FolderAccountGroup.tsx
@@ -1,7 +1,6 @@
import { useEffect, useMemo, useRef } from "react";
import { ChevronRight, Folder, FolderOpen, Loader2 } from "lucide-react";
-import { HighlightText } from "@app/components/v2/HighlightText";
import { TableCell, TableRow } from "@app/components/v3";
import { Skeleton } from "@app/components/v3/generic/Skeleton";
import {
@@ -9,6 +8,7 @@ import {
TAccessiblePamFolder,
useListAccessiblePamAccounts
} from "@app/hooks/api/pam";
+import { useDebounce } from "@app/hooks/useDebounce";
import { AccountRow } from "./AccountRow";
@@ -35,30 +35,31 @@ export const FolderAccountGroup = ({
onLaunch,
onResultCount
}: Props) => {
- // Only fetch this folder's accounts once it's open (lazy load per folder)
+ // Debounced term drives the server query; one request per open folder
+ const [debouncedSearch] = useDebounce(search);
+ const q = debouncedSearch.trim().toLowerCase();
+ const hasQuery = q.length > 0;
+
+ // Filter server-side so matches on later pages stay reachable
const { data, isLoading, hasNextPage, isFetchingNextPage, fetchNextPage } =
- useListAccessiblePamAccounts({ folderId: folder.id }, { enabled: isOpen });
+ useListAccessiblePamAccounts(
+ {
+ folderId: folder.id,
+ ...(accountType ? { accountType } : {}),
+ ...(hasQuery ? { search: q } : {})
+ },
+ { enabled: isOpen }
+ );
const accounts = data?.pages.flatMap((p) => p.accounts) ?? [];
const totalCount = data?.pages[0]?.totalCount ?? 0;
- const q = search.trim().toLowerCase();
- const hasQuery = q.length > 0;
- const folderNameMatches = hasQuery && folder.name.toLowerCase().includes(q);
-
- // Client-side filtering keeps search/type instant once a folder's accounts are loaded
+ // Narrow loaded rows on the raw term so non-matches hide instantly, ahead of the debounce
const accountsToShow = useMemo(() => {
- let list = accounts;
- if (accountType) list = list.filter((a) => a.accountType === accountType);
- if (hasQuery && !folderNameMatches) {
- list = list.filter((a) => `${a.name} ${a.description ?? ""}`.toLowerCase().includes(q));
- }
- return list;
- }, [accounts, accountType, q, hasQuery, folderNameMatches]);
-
- const effectiveCount = folderNameMatches
- ? Math.max(accountsToShow.length, 1)
- : accountsToShow.length;
+ const live = search.trim().toLowerCase();
+ if (!live) return accounts;
+ return accounts.filter((a) => `${a.name} ${a.description ?? ""}`.toLowerCase().includes(live));
+ }, [accounts, search]);
const sentinelRef = useRef<HTMLDivElement>(null);
useEffect(() => {
@@ -72,16 +73,16 @@ export const FolderAccountGroup = ({
}, [hasNextPage, isFetchingNextPage, fetchNextPage]);
useEffect(() => {
- if (isOpen && !isLoading) onResultCount(folder.id, effectiveCount);
- }, [isOpen, isLoading, effectiveCount, folder.id, onResultCount]);
+ if (isOpen && !isLoading) onResultCount(folder.id, totalCount);
+ }, [isOpen, isLoading, totalCount, folder.id, onResultCount]);
- // While filtering, hide folders with no name match and no matching accounts
- if (filterActive && isOpen && !isLoading && !folderNameMatches && accountsToShow.length === 0) {
+ // While filtering, hide folders with no matching accounts
+ if (filterActive && isOpen && !isLoading && totalCount === 0) {
return null;
}
let count = folder.accountCount;
- if (isOpen && !isLoading) count = filterActive ? accountsToShow.length : totalCount;
+ if (isOpen && !isLoading) count = search.trim() ? accountsToShow.length : totalCount;
return (
<>
@@ -96,9 +97,7 @@ export const FolderAccountGroup = ({
) : (
<Folder className="size-5 shrink-0 text-product-pam" />
)}
- <span className="font-medium text-foreground">
- <HighlightText text={folder.name} highlight={search} />
- </span>
+ <span className="font-medium text-foreground">{folder.name}</span>
<span className="text-xs text-muted">({count})</span>
</div>
</TableCell>
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx
index ebc18fb350..407a60268e 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx
@@ -59,29 +59,23 @@ export const FolderAccountRows = ({
const q = search.trim().toLowerCase();
const hasQuery = q.length > 0;
- const folderNameMatches =
- hasQuery && `${folder.name} ${folder.description ?? ""}`.toLowerCase().includes(q);
// Client-side filtering keeps search/template instant once a folder's accounts are loaded
const accountsToShow = useMemo(() => {
let list = accounts;
if (templateId) list = list.filter((a) => a.templateId === templateId);
- if (hasQuery && !folderNameMatches) {
+ if (hasQuery) {
list = list.filter((a) => `${a.name} ${a.description ?? ""}`.toLowerCase().includes(q));
}
return list;
- }, [accounts, templateId, q, hasQuery, folderNameMatches]);
-
- const effectiveCount = folderNameMatches
- ? Math.max(accountsToShow.length, 1)
- : accountsToShow.length;
+ }, [accounts, templateId, q, hasQuery]);
useEffect(() => {
- if (isOpen && !isLoading) onResultCount(folder.id, effectiveCount);
- }, [isOpen, isLoading, effectiveCount, folder.id, onResultCount]);
+ if (isOpen && !isLoading) onResultCount(folder.id, accountsToShow.length);
+ }, [isOpen, isLoading, accountsToShow.length, folder.id, onResultCount]);
- // While filtering, hide folders with no name match and no matching accounts
- if (filterActive && isOpen && !isLoading && !folderNameMatches && accountsToShow.length === 0) {
+ // While filtering, hide folders with no matching accounts
+ if (filterActive && isOpen && !isLoading && accountsToShow.length === 0) {
return null;
}
@@ -98,14 +92,8 @@ export const FolderAccountRows = ({
) : (
<Folder className="size-5 shrink-0 text-product-pam" />
)}
- <span className="font-medium text-foreground">
- <HighlightText text={folder.name} highlight={search} />
- </span>
- {folder.description && (
- <span className="text-muted">
- <HighlightText text={folder.description} highlight={search} />
- </span>
- )}
+ <span className="font-medium text-foreground">{folder.name}</span>
+ {folder.description && <span className="text-muted">{folder.description}</span>}
</div>
</TableCell>
<TableCell className="w-20">