Skip to content

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

fix(agent-vault): filter bundle members by type on the server

Scott Wilsonefe8ab5dfc2a
diff --git a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-access-bundle-router.ts b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-access-bundle-router.ts
index e305b0a408..412c9b820f 100644
--- a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-access-bundle-router.ts
+++ b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-access-bundle-router.ts
@@ -6,7 +6,7 @@ import {
AGENT_VAULT_NO_CONTROL_CHARS_MESSAGE,
AGENT_VAULT_NO_CONTROL_CHARS_RE
} from "@app/ee/services/agent-vault/agent-vault-credential-schemas";
-import { AgentVaultCredentialType } from "@app/ee/services/agent-vault/agent-vault-enums";
+import { AgentVaultCredentialType, AgentVaultMemberType } from "@app/ee/services/agent-vault/agent-vault-enums";
import { parseHostPatterns } from "@app/ee/services/agent-vault/agent-vault-host-pattern-fns";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { AGENT_VAULT } from "@app/lib/api-docs";
@@ -648,7 +648,10 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
params: z.object({
accessBundleId: z.string().uuid().describe(AGENT_VAULT.ACCESS_BUNDLE.accessBundleId)
}),
- querystring: z.object(agentVaultListQuery(AGENT_VAULT.MEMBER)),
+ querystring: z.object({
+ actorType: z.nativeEnum(AgentVaultMemberType).optional().describe(AGENT_VAULT.MEMBER.actorTypeFilter),
+ ...agentVaultListQuery(AGENT_VAULT.MEMBER)
+ }),
response: { 200: z.object({ members: AgentVaultMemberSchema.array(), totalCount: z.number() }) }
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
@@ -673,7 +676,13 @@ export const registerAgentVaultAccessBundleRouter = async (server: FastifyZodPro
params: z.object({
accessBundleId: z.string().uuid().describe(AGENT_VAULT.ACCESS_BUNDLE.accessBundleId)
}),
- querystring: z.object(agentVaultListQuery(AGENT_VAULT.AVAILABLE_GRANTEE)),
+ querystring: z.object({
+ actorType: z
+ .nativeEnum(AgentVaultMemberType)
+ .optional()
+ .describe(AGENT_VAULT.AVAILABLE_GRANTEE.actorTypeFilter),
+ ...agentVaultListQuery(AGENT_VAULT.AVAILABLE_GRANTEE)
+ }),
response: {
200: z.object({ members: AgentVaultProductMemberSchema.array(), totalCount: z.number() })
}
diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-dal.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-dal.ts
index 2f9997c350..e4ad471e9c 100644
--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-dal.ts
+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-dal.ts
@@ -3,6 +3,7 @@ import { Knex } from "knex";
import { TDbClient } from "@app/db";
import { RESOURCE_SCOPE, ResourceType, TableName, TAgentVaultAccessBundles } from "@app/db/schemas";
import { AgentVaultMemberType } from "@app/ee/services/agent-vault/agent-vault-enums";
+import { ACTOR_COLUMN } from "@app/ee/services/agent-vault-member/agent-vault-member-dal";
import { DatabaseError } from "@app/lib/errors";
import { sanitizeSqlLikeString } from "@app/lib/fn/string";
import { ormify } from "@app/lib/knex";
@@ -226,10 +227,18 @@ export const agentVaultAccessBundleDALFactory = (db: TDbClient) => {
{
projectId,
accessBundleId,
+ actorType,
search,
limit,
offset
- }: { projectId: string; accessBundleId: string; search?: string; limit: number; offset: number },
+ }: {
+ projectId: string;
+ accessBundleId: string;
+ actorType?: AgentVaultMemberType;
+ search?: string;
+ limit: number;
+ offset: number;
+ },
tx?: Knex
): Promise<{ members: TAgentVaultAccessBundleMemberDetail[]; totalCount: number }> => {
try {
@@ -242,6 +251,10 @@ export const agentVaultAccessBundleDALFactory = (db: TDbClient) => {
.leftJoin(TableName.Identity, `${TableName.Membership}.actorIdentityId`, `${TableName.Identity}.id`)
.leftJoin(TableName.Groups, `${TableName.Membership}.actorGroupId`, `${TableName.Groups}.id`);
+ if (actorType) {
+ void query.whereNotNull(`${TableName.Membership}.${ACTOR_COLUMN[actorType]}`);
+ }
+
if (search) {
const term = `%${sanitizeSqlLikeString(search)}%`;
void query.where((qb) => {
diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts
index 4b625dfe0d..dab1a4170b 100644
--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts
+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts
@@ -1661,7 +1661,7 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
};
};
- const listMembers = async ({ accessBundleId, search, limit, offset, ...rest }: TListMembersDTO) => {
+ const listMembers = async ({ accessBundleId, actorType, search, limit, offset, ...rest }: TListMembersDTO) => {
const { bundle, permission } = await resolveReachableBundle({ ...rest, accessBundleId });
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionAgentVaultAccessBundleActions.ManageMembers,
@@ -1670,6 +1670,7 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
return agentVaultAccessBundleDAL.findMembers({
projectId: rest.projectId,
accessBundleId: bundle.id,
+ actorType,
search,
limit,
offset
@@ -1679,7 +1680,14 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
// The candidates for a grant are the product's own members, since addMembers refuses anyone else, minus
// whoever already holds this bundle. A member reaching it only through a granted group stays a
// candidate: an individual grant is a different thing, and it outlives the group membership.
- const listAvailableMembers = async ({ accessBundleId, search, limit, offset, ...rest }: TListMembersDTO) => {
+ const listAvailableMembers = async ({
+ accessBundleId,
+ actorType,
+ search,
+ limit,
+ offset,
+ ...rest
+ }: TListMembersDTO) => {
const { bundle, permission } = await resolveReachableBundle({ ...rest, accessBundleId });
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionAgentVaultAccessBundleActions.ManageMembers,
@@ -1688,7 +1696,7 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund
return agentVaultMemberDAL.findProductMembers({
projectId: rest.projectId,
orgId: rest.ctx.actorOrgId,
- actorTypes: ALL_GRANTEE_ACTOR_TYPES,
+ actorTypes: actorType ? [actorType] : ALL_GRANTEE_ACTOR_TYPES,
search,
limit,
offset,
diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts
index dba68e7432..6df845ce02 100644
--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts
+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts
@@ -4,6 +4,7 @@ import {
AgentVaultCredentialType,
AgentVaultHttpMethod,
AgentVaultMcpTransport,
+ AgentVaultMemberType,
AgentVaultOauthStatus,
AgentVaultServiceType,
AgentVaultSubstitutionSurface,
@@ -151,6 +152,7 @@ export type TDeleteServiceDTO = TAgentVaultProjectScoped & {
export type TListMembersDTO = TAgentVaultProjectScoped & {
accessBundleId: string;
+ actorType?: AgentVaultMemberType;
search?: string;
limit: number;
offset: number;
diff --git a/backend/src/ee/services/agent-vault-member/agent-vault-member-dal.ts b/backend/src/ee/services/agent-vault-member/agent-vault-member-dal.ts
index dad38d8366..864089dfaa 100644
--- a/backend/src/ee/services/agent-vault-member/agent-vault-member-dal.ts
+++ b/backend/src/ee/services/agent-vault-member/agent-vault-member-dal.ts
@@ -41,7 +41,7 @@ export type TAgentVaultProductMember = TAgentVaultProductActor & {
addedAt: Date;
};
-const ACTOR_COLUMN: Record<AgentVaultMemberType, "actorUserId" | "actorIdentityId" | "actorGroupId"> = {
+export const ACTOR_COLUMN: Record<AgentVaultMemberType, "actorUserId" | "actorIdentityId" | "actorGroupId"> = {
[AgentVaultMemberType.User]: "actorUserId",
[AgentVaultMemberType.MachineIdentity]: "actorIdentityId",
[AgentVaultMemberType.Group]: "actorGroupId"
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 289677e455..28288baf25 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -4702,6 +4702,7 @@ export const AGENT_VAULT = {
revokeGroupIds: "The IDs of the groups to revoke the access bundle from.",
skipped: "The requested grantees who already had the access bundle and were left as they were.",
revokeSkipped: "The requested grantees who did not have the access bundle, so nothing was revoked.",
+ actorTypeFilter: "List only users, only groups or only machine identities.",
search: "Match members by name, username or email address.",
limit: "The maximum number of members to return.",
offset: "How many members to skip."
@@ -4731,6 +4732,7 @@ export const AGENT_VAULT = {
offset: "How many candidates to skip."
},
AVAILABLE_GRANTEE: {
+ actorTypeFilter: "List only users, only groups or only machine identities.",
search: "Match candidates by name, username or email address.",
limit: "The maximum number of candidates to return.",
offset: "How many candidates to skip."
diff --git a/frontend/src/components/agent-vault/AccessBundleMemberRow.tsx b/frontend/src/components/agent-vault/AccessBundleMemberRow.tsx
index e72606d373..548840cb3b 100644
--- a/frontend/src/components/agent-vault/AccessBundleMemberRow.tsx
+++ b/frontend/src/components/agent-vault/AccessBundleMemberRow.tsx
@@ -64,7 +64,13 @@ export const AccessBundleMemberRow = ({ member, isDisabled, onRevoke }: MemberRo
<MemberIdentity member={member} />
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="ghost" size="sm" className="shrink-0" isDisabled={isDisabled}>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="shrink-0"
+ isDisabled={isDisabled}
+ aria-label={`Has Access: ${memberDisplayName(member)}`}
+ >
Has Access
<ChevronDownIcon />
</Button>
@@ -99,7 +105,14 @@ export const AccessBundleGrantRow = ({ member, isDisabled, onGrant }: GrantRowPr
/>
}
/>
- <Button variant="av" size="sm" className="shrink-0" isDisabled={isDisabled} onClick={onGrant}>
+ <Button
+ variant="av"
+ size="sm"
+ className="shrink-0"
+ isDisabled={isDisabled}
+ aria-label={`Grant Access to ${memberDisplayName(member)}`}
+ onClick={onGrant}
+ >
Grant Access
</Button>
</div>
diff --git a/frontend/src/components/agent-vault/ManageAccessSheet.tsx b/frontend/src/components/agent-vault/ManageAccessSheet.tsx
index 54f561a334..5f9f30d0d0 100644
--- a/frontend/src/components/agent-vault/ManageAccessSheet.tsx
+++ b/frontend/src/components/agent-vault/ManageAccessSheet.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { FilterIcon, PackageIcon, SearchIcon, UsersIcon, XIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
@@ -17,11 +17,10 @@ import {
AlertDialogTitle,
DocumentationLinkBadge,
DropdownMenu,
- DropdownMenuCheckboxItem,
DropdownMenuContent,
- DropdownMenuItem,
DropdownMenuLabel,
- DropdownMenuSeparator,
+ DropdownMenuRadioGroup,
+ DropdownMenuRadioItem,
DropdownMenuTrigger,
Empty,
EmptyDescription,
@@ -64,6 +63,7 @@ const PER_PAGE = 20;
// members without access are not paged, so the list is capped and search narrows it
const AVAILABLE_PREVIEW_LIMIT = 20;
const NO_ACCESS_SECTION = "no-access";
+const ALL_TYPES = "all";
const TYPE_OPTIONS = [
{ value: AgentVaultMemberType.User, label: "Users" },
@@ -75,18 +75,14 @@ const MemberTypeFilter = ({
value,
onChange
}: {
- value: AgentVaultMemberType[];
- onChange: (value: AgentVaultMemberType[]) => void;
+ value: AgentVaultMemberType | null;
+ onChange: (value: AgentVaultMemberType | null) => void;
}) => (
<DropdownMenu>
<Tooltip>
<TooltipTrigger asChild>
<DropdownMenuTrigger asChild>
- <IconButton
- aria-label="Filter members"
- size="md"
- variant={value.length ? "av" : "outline"}
- >
+ <IconButton aria-label="Filter members" size="md" variant={value ? "av" : "outline"}>
<FilterIcon />
</IconButton>
</DropdownMenuTrigger>
@@ -95,106 +91,104 @@ const MemberTypeFilter = ({
</Tooltip>
<DropdownMenuContent align="end" className="w-60">
<DropdownMenuLabel>Type</DropdownMenuLabel>
- {TYPE_OPTIONS.map((option) => (
- <DropdownMenuCheckboxItem
- key={option.value}
- checked={value.includes(option.value)}
- onClick={(e) => {
- e.preventDefault();
- onChange(
- value.includes(option.value)
- ? value.filter((type) => type !== option.value)
- : [...value, option.value]
- );
- }}
- >
- <option.icon />
- {option.label}
- </DropdownMenuCheckboxItem>
- ))}
- {Boolean(value.length) && (
- <>
- <DropdownMenuSeparator />
- <DropdownMenuItem onClick={() => onChange([])}>Clear Filters</DropdownMenuItem>
- </>
- )}
+ <DropdownMenuRadioGroup
+ value={value ?? ALL_TYPES}
+ onValueChange={(next) =>
+ onChange(next === ALL_TYPES ? null : (next as AgentVaultMemberType))
+ }
+ >
+ <DropdownMenuRadioItem value={ALL_TYPES}>
+ <UsersIcon />
+ All Types
+ </DropdownMenuRadioItem>
+ {TYPE_OPTIONS.map((option) => (
+ <DropdownMenuRadioItem key={option.value} value={option.value}>
+ <option.icon />
+ {option.label}
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
);
-type Props = {
- accessBundle: { id: string; name: string } | null;
- onOpenChange: (isOpen: boolean) => void;
-};
+type TAccessBundle = { id: string; name: string };
-export const ManageAccessSheet = ({ accessBundle, onOpenChange }: Props) => {
+const ManageAccessContent = ({
+ accessBundle,
+ isOpen
+}: {
+ accessBundle: TAccessBundle;
+ isOpen: boolean;
+}) => {
const [memberToRemove, setMemberToRemove] = useState<TAgentVaultMember | null>(null);
const [search, setSearch] = useState("");
const [debouncedSearch] = useDebounce(search);
const [page, setPage] = useState(1);
- const [typeFilter, setTypeFilter] = useState<AgentVaultMemberType[]>([]);
+ const [typeFilter, setTypeFilter] = useState<AgentVaultMemberType | null>(null);
const [noAccessSection, setNoAccessSection] = useState("");
+ const hasPickedInitialSection = useRef(false);
- const accessBundleId = accessBundle?.id ?? "";
const searchParam = debouncedSearch.trim() || undefined;
+ const actorType = typeFilter ?? undefined;
- const { data, isPending } = useListAgentVaultAccessBundleMembers(accessBundleId, {
+ const { data, isPending } = useListAgentVaultAccessBundleMembers(accessBundle.id, {
+ actorType,
search: searchParam,
limit: PER_PAGE,
offset: (page - 1) * PER_PAGE
});
- const { data: available, isFetching: isAvailableFetching } =
- useListAvailableAgentVaultAccessBundleMembers(
- accessBundleId,
- { search: searchParam, limit: AVAILABLE_PREVIEW_LIMIT },
- Boolean(accessBundle)
- );
+ const {
+ data: available,
+ isPending: isAvailablePending,
+ isError: isAvailableError,
+ isFetching: isAvailableFetching
+ } = useListAvailableAgentVaultAccessBundleMembers(
+ accessBundle.id,
+ { actorType, search: searchParam, limit: AVAILABLE_PREVIEW_LIMIT },
+ isOpen
+ );
const addMembers = useAddAgentVaultAccessBundleMembers();
const revokeMembers = useRevokeAgentVaultAccessBundleMembers();
+ const members = data?.members ?? [];
const totalCount = data?.totalCount ?? 0;
+ const candidates = available?.members ?? [];
+ const candidateCount = available?.totalCount ?? 0;
useResetPageHelper({ totalCount, offset: (page - 1) * PER_PAGE, setPage });
- // The sheet stays mounted between opens, so a second bundle would inherit the first one's state.
- useEffect(() => {
- setSearch("");
- setPage(1);
- setTypeFilter([]);
- setNoAccessSection("");
- }, [accessBundleId]);
-
- // A bundle no one holds yet has nothing above the fold, so the grant list starts open.
+ // A bundle no one holds yet has nothing above the fold, so the grant list starts open. This content
+ // remounts per bundle, so the first settled result is always this bundle's own.
useEffect(() => {
- if (!isPending && !totalCount && !searchParam) setNoAccessSection(NO_ACCESS_SECTION);
- }, [accessBundleId, isPending]);
+ if (isPending || hasPickedInitialSection.current) return;
+ hasPickedInitialSection.current = true;
+ if (!totalCount) setNoAccessSection(NO_ACCESS_SECTION);
+ }, [isPending, totalCount]);
- const matchesType = (type: AgentVaultMemberType) =>
- !typeFilter.length || typeFilter.includes(type);
- const members = (data?.members ?? []).filter((member) => matchesType(member.type));
- const candidates = (available?.members ?? []).filter((member) => matchesType(member.type));
- const hasMoreCandidates = (available?.totalCount ?? 0) > (available?.members.length ?? 0);
-
- const isSearching = Boolean(searchParam);
- const isSearchMiss = isSearching && !members.length && !candidates.length;
+ const isFiltered = Boolean(searchParam || typeFilter);
+ const isAvailableSettled = !isAvailablePending && !isAvailableError;
+ const isSearchMiss = Boolean(searchParam) && !totalCount && isAvailableSettled && !candidateCount;
// a granted candidate stays in this list until the refetch lands
const isGrantLocked = addMembers.isPending || isAvailableFetching;
const memberToRemoveName = memberToRemove ? memberDisplayName(memberToRemove) : "";
- const emptyState =
- typeFilter.length && totalCount > 0
- ? {
- title: "No matching access",
- description:
- "No one on this page matches these filters. Clear a filter, or check another page."
- }
- : {
- title: "No one has access yet",
- description:
- "Grant access from the No Access section to let members create sessions with this bundle."
- };
+ const emptyState = typeFilter
+ ? {
+ title: "No matching access",
+ description: `No ${TYPE_OPTIONS.find((option) => option.value === typeFilter)?.label.toLowerCase()} have access to this bundle. Clear the filter, or grant access from the No Access section.`
+ }
+ : {
+ title: "No one has access yet",
+ description:
+ "Grant access from the No Access section to let members create sessions with this bundle."
+ };
+
+ const changeFilter = (next: AgentVaultMemberType | null) => {
+ setTypeFilter(next);
+ setPage(1);
+ };
const handleGrant = async (member: TAgentVaultProductActor) => {
- if (!accessBundle) return;
const name = memberDisplayName(member);
try {
@@ -214,7 +208,7 @@ export const ManageAccessSheet = ({ accessBundle, onOpenChange }: Props) => {
const handleRemove = async () => {
try {
- if (!accessBundle || !memberToRemove) return;
+ if (!memberToRemove) return;
await revokeMembers.mutateAsync({
accessBundleId: accessBundle.id,
@@ -230,179 +224,232 @@ export const ManageAccessSheet = ({ accessBundle, onOpenChange }: Props) => {
}
};
+ const renderCandidates = () => {
+ if (isAvailablePending) {
+ return (
+ <div className="space-y-2 py-2">
+ <Skeleton className="h-14 w-full" />
+ <Skeleton className="h-14 w-full" />
+ </div>
+ );
+ }
+ if (isAvailableError) {
+ return (
+ <p className="py-2.5 text-xs text-danger">
+ Could not load the members without access. Close this panel and open it again to retry.
+ </p>
+ );
+ }
+ if (!candidates.length) {
+ if (isSearchMiss) return null;
+ return (
+ <p className="py-2.5 text-xs text-muted">
+ {isFiltered
+ ? "No members without access match your search and filters."
+ : "Everyone in Agent Vault already has this bundle."}
+ </p>
+ );
+ }
+ return (
+ <>
+ <section className="flex flex-col">
+ {candidates.map((member) => (
+ <AccessBundleGrantRow
+ key={`${member.type}:${member.id}`}
+ member={member}
+ isDisabled={isGrantLocked}
+ onGrant={() => handleGrant(member)}
+ />
+ ))}
+ </section>
+ {candidateCount > candidates.length && (
+ <p className="py-2.5 text-xs text-muted">
+ Showing the first {AVAILABLE_PREVIEW_LIMIT} of {candidateCount}. Search to find someone
+ else.
+ </p>
+ )}
+ </>
+ );
+ };
+
return (
- <Sheet open={Boolean(accessBundle)} onOpenChange={onOpenChange}>
- <SheetContent className="gap-y-0 sm:max-w-[640px]">
- <SheetHeader>
- <SheetTitle className="flex items-center gap-2">
- Manage Access
- <DocumentationLinkBadge href={AgentVaultDocsUrls.accessBundles} />
- </SheetTitle>
- <div className="flex min-w-0 items-center gap-2 rounded-md border border-border bg-neutral/5 px-3 py-2 text-xs">
- <PackageIcon className="size-3.5 shrink-0 text-muted" />
- <span className="truncate text-foreground">{accessBundle?.name}</span>
- </div>
- </SheetHeader>
+ <>
+ <SheetHeader>
+ <SheetTitle className="flex items-center gap-2">
+ Manage Access
+ <DocumentationLinkBadge href={AgentVaultDocsUrls.accessBundles} />
+ </SheetTitle>
+ <div className="flex min-w-0 items-center gap-2 rounded-md border border-border bg-neutral/5 px-3 py-2 text-xs">
+ <PackageIcon className="size-3.5 shrink-0 text-muted" />
+ <span className="truncate text-foreground">{accessBundle.name}</span>
+ </div>
+ </SheetHeader>
- <div className="thin-scrollbar flex-1 space-y-4 overflow-y-auto p-4">
- <div className="flex items-center gap-2">
- <InputGroup className="flex-1">
- <InputGroupAddon>
- <SearchIcon />
+ <div className="thin-scrollbar flex-1 space-y-4 overflow-y-auto p-4">
+ <div className="flex items-center gap-2">
+ <InputGroup className="flex-1">
+ <InputGroupAddon>
+ <SearchIcon />
+ </InputGroupAddon>
+ <InputGroupInput
+ value={search}
+ onChange={(e) => {
+ setSearch(e.target.value);
+ setPage(1);
+ if (e.target.value.trim()) setNoAccessSection(NO_ACCESS_SECTION);
+ }}
+ placeholder="Search users, groups, and machine identities..."
+ />
+ {search && (
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ aria-label="Clear search"
+ onClick={() => {
+ setSearch("");
+ setPage(1);
+ }}
+ >
+ <XIcon />
+ </InputGroupButton>
</InputGroupAddon>
- <InputGroupInput
- value={search}
- onChange={(e) => {
- setSearch(e.target.value);
- setPage(1);
- if (e.target.value.trim()) setNoAccessSection(NO_ACCESS_SECTION);
- }}
- placeholder="Search users, groups, and machine identities..."
- />
- {search && (
- <InputGroupAddon align="inline-end">
- <InputGroupButton
- aria-label="Clear search"
- onClick={() => {
- setSearch("");
- setPage(1);
- }}
- >
- <XIcon />
- </InputGroupButton>
- </InputGroupAddon>
- )}
- </InputGroup>
- <MemberTypeFilter value={typeFilter} onChange={setTypeFilter} />
+ )}
+ </InputGroup>
+ <MemberTypeFilter value={typeFilter} onChange={changeFilter} />
+ </div>
+
+ {isPending && (
+ <div className="space-y-2">
+ <Skeleton className="h-14 w-full" />
+ <Skeleton className="h-14 w-full" />
+ <Skeleton className="h-14 w-full" />
</div>
+ )}
+
+ {!isPending && !members.length && !searchParam && (
+ <Empty className="border">
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <UsersIcon />
+ </EmptyMedia>
+ <EmptyTitle>{emptyState.title}</EmptyTitle>
+ <EmptyDescription>{emptyState.description}</EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ )}
+
+ {!isPending && isSearchMiss && (
+ <p className="text-sm text-muted">No members match your search and filters.</p>
+ )}
+
+ {!isPending && Boolean(members.length) && (
+ <section className="flex flex-col">
+ {members.map((member) => (
+ <AccessBundleMemberRow
+ key={`${member.type}:${member.id}`}
+ member={member}
+ onRevoke={() => setMemberToRemove(member)}
+ />
+ ))}
+ </section>
+ )}
+
+ {!isPending && (
+ <Accordion
+ type="single"
+ collapsible
+ variant="ghost"
+ value={noAccessSection}
+ onValueChange={setNoAccessSection}
+ >
+ <AccordionItem value={NO_ACCESS_SECTION}>
+ <AccordionTrigger>
+ <span className="shrink-0">No Access</span>
+ <span className="flex-1">
+ <Separator />
+ </span>
+ </AccordionTrigger>
+ <AccordionContent>{renderCandidates()}</AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ )}
+
+ {!isPending && totalCount > PER_PAGE && (
+ <Pagination
+ count={totalCount}
+ page={page}
+ perPage={PER_PAGE}
+ onChangePage={setPage}
+ onChangePerPage={() => {}}
+ perPageList={[PER_PAGE]}
+ startAdornment={<span className="text-xs text-muted">Members with access</span>}
+ />
+ )}
+ </div>
- {isPending && (
- <div className="space-y-2">
- <Skeleton className="h-14 w-full" />
- <Skeleton className="h-14 w-full" />
- <Skeleton className="h-14 w-full" />
- </div>
- )}
-
- {!isPending && !members.length && !isSearching && (
- <Empty className="border">
- <EmptyHeader>
- <EmptyMedia variant="icon">
- <UsersIcon />
- </EmptyMedia>
- <EmptyTitle>{emptyState.title}</EmptyTitle>
- <EmptyDescription>{emptyState.description}</EmptyDescription>
- </EmptyHeader>
- </Empty>
- )}
-
- {!isPending && isSearchMiss && (
- <p className="text-sm text-muted">No members match your search and filters.</p>
- )}
-
- {!isPending && Boolean(members.length) && (
- <section className="flex flex-col">
- {members.map((member) => (
- <AccessBundleMemberRow
- key={`${member.type}:${member.id}`}
- member={member}
- onRevoke={() => setMemberToRemove(member)}
- />
- ))}
- </section>
- )}
-
- {!isPending && (
- <Accordion
- type="single"
- collapsible
- variant="ghost"
- value={noAccessSection}
- onValueChange={setNoAccessSection}
+ <SheetFooter className="border-t">
+ <span className="text-xs text-muted">Changes save automatically</span>
+ </SheetFooter>
+
+ <AlertDialog
+ open={Boolean(memberToRemove)}
+ onOpenChange={(open) => {
+ if (!open && !revokeMembers.isPending) setMemberToRemove(null);
+ }}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Revoke Access for &quot;{memberToRemoveName}&quot;</AlertDialogTitle>
+ <AlertDialogDescription>
+ They lose this access bundle. Any active session they hold stops reaching its hosts at
+ the next proxy poll.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel isDisabled={revokeMembers.isPending}>Cancel</AlertDialogCancel>
+ <AlertDialogAction
+ variant="danger"
+ isPending={revokeMembers.isPending}
+ onClick={async (event) => {
+ event.preventDefault();
+ await handleRemove();
+ }}
>
- <AccordionItem value={NO_ACCESS_SECTION}>
- <AccordionTrigger>
- <span className="shrink-0">No Access</span>
- <span className="flex-1">
- <Separator />
- </span>
- </AccordionTrigger>
- <AccordionContent>
- {!candidates.length && !isSearchMiss && (
- <p className="py-2.5 text-xs text-muted">
- {isSearching || typeFilter.length
- ? "No members without access match your search and filters."
- : "Everyone in Agent Vault already has this bundle."}
- </p>
- )}
- <section className="flex flex-col">
- {candidates.map((member) => (
- <AccessBundleGrantRow
- key={`${member.type}:${member.id}`}
- member={member}
- isDisabled={isGrantLocked}
- onGrant={() => handleGrant(member)}
- />
- ))}
- </section>
- {hasMoreCandidates && (
- <p className="py-2.5 text-xs text-muted">
- Showing the first {AVAILABLE_PREVIEW_LIMIT}. Search to find someone else.
- </p>
- )}
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- )}
-
- {!isPending && totalCount > PER_PAGE && (
- <Pagination
- count={totalCount}
- page={page}
- perPage={PER_PAGE}
- onChangePage={setPage}
- onChangePerPage={() => {}}
- perPageList={[PER_PAGE]}
- startAdornment={<span className="text-xs text-muted">Members with access</span>}
- />
- )}
- </div>
+ Revoke Access
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ </>
+ );
+};
+
+type Props = {
+ accessBundle: TAccessBundle | null;
+ onOpenChange: (isOpen: boolean) => void;
+};
+
+export const ManageAccessSheet = ({ accessBundle, onOpenChange }: Props) => {
+ // Holds the last bundle so the content stays on screen while the sheet animates closed.
+ const [shownBundle, setShownBundle] = useState(accessBundle);
+ if (
+ accessBundle &&
+ (accessBundle.id !== shownBundle?.id || accessBundle.name !== shownBundle?.name)
+ ) {
+ setShownBundle(accessBundle);
+ }
- <SheetFooter className="border-t">
- <span className="text-xs text-muted">Changes save automatically</span>
- </SheetFooter>
-
- <AlertDialog
- open={Boolean(memberToRemove)}
- onOpenChange={(isOpen) => {
- if (!isOpen && !revokeMembers.isPending) setMemberToRemove(null);
- }}
- >
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>
- Revoke Access for &quot;{memberToRemoveName}&quot;
- </AlertDialogTitle>
- <AlertDialogDescription>
- They lose this access bundle. Any active session they hold stops reaching its hosts
- at the next proxy poll.
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancel isDisabled={revokeMembers.isPending}>Cancel</AlertDialogCancel>
- <AlertDialogAction
- variant="danger"
- isPending={revokeMembers.isPending}
- onClick={async (event) => {
- event.preventDefault();
- await handleRemove();
- }}
- >
- Revoke Access
- </AlertDialogAction>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
+ // Keyed per bundle so a second bundle starts with fresh state and queries, rather than showing the
+ // previous bundle's results while its own load.
+ return (
+ <Sheet open={Boolean(accessBundle)} onOpenChange={onOpenChange}>
+ <SheetContent className="gap-y-0 sm:max-w-[640px]">
+ {shownBundle && (
+ <ManageAccessContent
+ key={shownBundle.id}
+ accessBundle={shownBundle}
+ isOpen={Boolean(accessBundle)}
+ />
+ )}
</SheetContent>
</Sheet>
);
diff --git a/frontend/src/hooks/api/agentVault/queries.tsx b/frontend/src/hooks/api/agentVault/queries.tsx
index 01fd6fa746..d41cc3c4a0 100644
--- a/frontend/src/hooks/api/agentVault/queries.tsx
+++ b/frontend/src/hooks/api/agentVault/queries.tsx
@@ -106,13 +106,13 @@ export const agentVaultKeys = {
accessBundleMemberList: (
orgId: string,
accessBundleId: string,
- params?: Omit<TListAgentVaultMembersDTO, "actorType">
+ params?: TListAgentVaultMembersDTO
) => [...agentVaultKeys.accessBundleMembers(orgId, accessBundleId), params] as const,
// Nested under accessBundleMembers() so a grant invalidates the candidate list too.
availableAccessBundleMemberList: (
orgId: string,
accessBundleId: string,
- params?: Omit<TListAgentVaultMembersDTO, "actorType">
+ params?: TListAgentVaultMembersDTO
) => [...agentVaultKeys.accessBundleMembers(orgId, accessBundleId), "available", params] as const,
variables: (orgId: string) => [...agentVaultKeys.all(orgId), "variables"] as const,
variableList: (orgId: string, params: TListAgentVaultVariablesDTO) =>
@@ -193,7 +193,7 @@ const AVAILABLE_MEMBER_LIMIT = 50;
export const useListAvailableAgentVaultAccessBundleMembers = (
accessBundleId: string,
- { limit = AVAILABLE_MEMBER_LIMIT, ...rest }: Omit<TListAgentVaultMembersDTO, "actorType"> = {},
+ { limit = AVAILABLE_MEMBER_LIMIT, ...rest }: TListAgentVaultMembersDTO = {},
enabled = true
) => {
const { currentOrg } = useOrganization();
@@ -238,7 +238,7 @@ export const useListAvailableAgentVaultMembers = <
export const useListAgentVaultAccessBundleMembers = (
accessBundleId: string,
- params: Omit<TListAgentVaultMembersDTO, "actorType"> = {}
+ params: TListAgentVaultMembersDTO = {}
) => {
const { currentOrg } = useOrganization();