Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(agent-vault): address review on the Manage Access sheet
Scott Wilsone006c143653c
diff --git a/backend/e2e-test/routes/v1/agent-vault.spec.ts b/backend/e2e-test/routes/v1/agent-vault.spec.tsindex 4571bf3382..9959425e57 100644--- a/backend/e2e-test/routes/v1/agent-vault.spec.ts+++ b/backend/e2e-test/routes/v1/agent-vault.spec.ts@@ -7632,7 +7632,7 @@ describe("Agent Vault V1 Router", async () => {expect(byType.group).toMatchObject({ type: "group", id: group.id, name: "av-arms-group" });expect(byType.machineIdentity).toMatchObject({ type: "machineIdentity", id: identity.id });- expect(byType.user).toMatchObject({ type: "user", id: seedData1.id });+ expect(byType.user).toMatchObject({ type: "user", id: seedData1.id, isOrgMembershipPending: false });expect(byType.user.username).toBeTruthy();members.forEach((member) => {@@ -7653,6 +7653,62 @@ describe("Agent Vault V1 Router", async () => {}});+ test("the bundle member and candidate lists filter by actor type on the server", async () => {+ const projectId = await getProjectId();+ const bundle = await createAccessBundle("member-type-filter");+ const group = await createProjectGroup(projectId, "av-type-filter-group", ProjectMembershipRole.Member);+ const identity = await createOrgIdentity(`av-type-filter-identity-${Date.now()}`);+ const membersUrl = `/api/v1/agent-vault/access-bundles/${bundle.id}/members`;+ const list = async (url: string, query: string) => {+ const res = await inject("GET", `${url}?limit=100&${query}`);+ expect(res.statusCode).toBe(200);+ return JSON.parse(res.payload) as { members: { type: string; id: string }[]; totalCount: number };+ };+ const idsOf = (listed: { members: { id: string }[] }) => listed.members.map((member) => member.id);++ try {+ expect(+ (await inject("POST", "/api/v1/agent-vault/members", { machineIdentityIds: [identity.id], role: "member" }))+ .statusCode+ ).toBe(200);++ const groupCandidates = await list(`${membersUrl}/available`, "actorType=group");+ expect(groupCandidates.members.every((member) => member.type === "group")).toBe(true);+ expect(idsOf(groupCandidates)).toContain(group.id);+ expect(groupCandidates.totalCount).toBe(groupCandidates.members.length);++ const userCandidates = await list(`${membersUrl}/available`, "actorType=user");+ expect(userCandidates.members.every((member) => member.type === "user")).toBe(true);+ expect(idsOf(userCandidates)).not.toContain(group.id);++ expect(+ (await inject("POST", membersUrl, { groupIds: [group.id], machineIdentityIds: [identity.id] })).statusCode+ ).toBe(200);++ const groups = await list(membersUrl, "actorType=group");+ expect(idsOf(groups)).toEqual([group.id]);+ expect(groups.totalCount).toBe(1);++ const identities = await list(membersUrl, "actorType=machineIdentity");+ expect(idsOf(identities)).toEqual([identity.id]);+ expect(identities.totalCount).toBe(1);++ // The creator's own grant is the only user on the bundle.+ const users = await list(membersUrl, "actorType=user");+ expect(idsOf(users)).toEqual([seedData1.id]);+ expect(users.totalCount).toBe(1);++ expect(idsOf(await list(`${membersUrl}/available`, "actorType=group"))).not.toContain(group.id);+ expect(idsOf(await list(`${membersUrl}/available`, "actorType=machineIdentity"))).not.toContain(identity.id);++ expect((await inject("GET", `${membersUrl}?actorType=nonsense`)).statusCode).toBe(422);+ expect((await inject("GET", `${membersUrl}/available?actorType=nonsense`)).statusCode).toBe(422);+ } finally {+ await deleteOrgIdentity(identity.id);+ await group.cleanup();+ }+ });+test("one call grants several actors, dedupes repeats and skips the already granted", async () => {const projectId = await getProjectId();const bundle = await createAccessBundle("member-batch");diff --git a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.tsindex 3d09eed03c..60a062609c 100644--- a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts+++ b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts@@ -784,7 +784,10 @@ export const AgentVaultSkippedActorSchema = z.discriminatedUnion("type", [const grantedAtSchema = z.date().describe(AGENT_VAULT.MEMBER.grantedAt);export const AgentVaultMemberSchema = z.discriminatedUnion("type", [- memberActorSchemas.user.extend({ grantedAt: grantedAtSchema }),+ memberActorSchemas.user.extend({+ isOrgMembershipPending: z.boolean().describe(AGENT_VAULT.MEMBER.isOrgMembershipPending),+ grantedAt: grantedAtSchema+ }),memberActorSchemas.machineIdentity.extend({ grantedAt: grantedAtSchema }),groupActorSchema.extend({ grantedAt: grantedAtSchema })]);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.tsindex e4ad471e9c..b30ce6306a 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@@ -1,9 +1,15 @@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 {+ AccessScope,+ OrgMembershipStatus,+ RESOURCE_SCOPE,+ ResourceType,+ TableName,+ TAgentVaultAccessBundles+} from "@app/db/schemas";+import { AGENT_VAULT_ACTOR_COLUMN, AgentVaultMemberType } from "@app/ee/services/agent-vault/agent-vault-enums";import { DatabaseError } from "@app/lib/errors";import { sanitizeSqlLikeString } from "@app/lib/fn/string";import { ormify } from "@app/lib/knex";@@ -38,7 +44,10 @@ export type TAgentVaultAccessBundleActor =| { type: AgentVaultMemberType.MachineIdentity; id: string; name: string }| { type: AgentVaultMemberType.Group; id: string; name: string };-export type TAgentVaultAccessBundleMemberDetail = TAgentVaultAccessBundleActor & { grantedAt: Date };+export type TAgentVaultAccessBundleMemberDetail = (+ | (Extract<TAgentVaultAccessBundleActor, { type: AgentVaultMemberType.User }> & { isOrgMembershipPending: boolean })+ | Exclude<TAgentVaultAccessBundleActor, { type: AgentVaultMemberType.User }>+) & { grantedAt: Date };export type TAgentVaultAccessBundleOrderBy = "name" | "serviceCount" | "createdAt";@@ -226,6 +235,7 @@ export const agentVaultAccessBundleDALFactory = (db: TDbClient) => {const findMembers = async ({projectId,+ orgId,accessBundleId,actorType,search,@@ -233,6 +243,7 @@ export const agentVaultAccessBundleDALFactory = (db: TDbClient) => {offset}: {projectId: string;+ orgId: string;accessBundleId: string;actorType?: AgentVaultMemberType;search?: string;@@ -252,7 +263,7 @@ export const agentVaultAccessBundleDALFactory = (db: TDbClient) => {.leftJoin(TableName.Groups, `${TableName.Membership}.actorGroupId`, `${TableName.Groups}.id`);if (actorType) {- void query.whereNotNull(`${TableName.Membership}.${ACTOR_COLUMN[actorType]}`);+ void query.whereNotNull(`${TableName.Membership}.${AGENT_VAULT_ACTOR_COLUMN[actorType]}`);}if (search) {@@ -289,7 +300,13 @@ export const agentVaultAccessBundleDALFactory = (db: TDbClient) => {db.ref("lastName").withSchema(TableName.Users).as("userLastName"),db.ref("email").withSchema(TableName.Users).as("userEmail"),db.ref("name").withSchema(TableName.Identity).as("identityName"),- db.ref("name").withSchema(TableName.Groups).as("groupName")+ db.ref("name").withSchema(TableName.Groups).as("groupName"),+ // Pinned to this org: membership is unique per (org, actor), and a user can hold several in a sub-org family.+ db.raw(+ `EXISTS (SELECT 1 FROM ?? om WHERE om."scope" = ? AND om."scopeOrgId" = ?+ AND om."actorUserId" = ??."actorUserId" AND om."status" = ?) as "isOrgMembershipPending"`,+ [TableName.Membership, AccessScope.Organization, orgId, TableName.Membership, OrgMembershipStatus.Invited]+ ))// The id breaks ties: createdAt is the transaction's start time, so a bulk grant leaves a hundred rows// sharing one, and offset paging would show some twice and others never.@@ -307,14 +324,21 @@ export const agentVaultAccessBundleDALFactory = (db: TDbClient) => {userEmail: string | null;identityName: string | null;groupName: string | null;+ isOrgMembershipPending: boolean;}[];- const actorOf = (row: (typeof rows)[number]): TAgentVaultAccessBundleActor => {+ const memberOf = (row: (typeof rows)[number]): TAgentVaultAccessBundleMemberDetail => {+ const grantedAt = row.createdAt;if (row.identityId) {- return { type: AgentVaultMemberType.MachineIdentity, id: row.identityId, name: row.identityName ?? "" };+ return {+ type: AgentVaultMemberType.MachineIdentity,+ id: row.identityId,+ name: row.identityName ?? "",+ grantedAt+ };}if (row.groupId) {- return { type: AgentVaultMemberType.Group, id: row.groupId, name: row.groupName ?? "" };+ return { type: AgentVaultMemberType.Group, id: row.groupId, name: row.groupName ?? "", grantedAt };}return {type: AgentVaultMemberType.User,@@ -322,12 +346,14 @@ export const agentVaultAccessBundleDALFactory = (db: TDbClient) => {username: row.userUsername ?? "",email: row.userEmail,firstName: row.userFirstName,- lastName: row.userLastName+ lastName: row.userLastName,+ isOrgMembershipPending: row.isOrgMembershipPending,+ grantedAt};};return {- members: rows.map((row) => ({ ...actorOf(row), grantedAt: row.createdAt })),+ members: rows.map(memberOf),totalCount};} catch (error) {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.tsindex 9f2fe31940..e09acb6218 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@@ -1723,6 +1723,7 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund);return agentVaultAccessBundleDAL.findMembers({projectId: rest.projectId,+ orgId: rest.ctx.actorOrgId,accessBundleId: bundle.id,actorType,search,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.tsindex be2c7278b3..f2d0aa7812 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@@ -9,7 +9,11 @@ import {ResourceType,TableName} from "@app/db/schemas";-import { AgentVaultMemberType } from "@app/ee/services/agent-vault/agent-vault-enums";+import {+ AGENT_VAULT_ACTOR_COLUMN,+ AgentVaultMemberType,+ TAgentVaultActorColumn+} from "@app/ee/services/agent-vault/agent-vault-enums";import { DatabaseError } from "@app/lib/errors";import { sanitizeSqlLikeString } from "@app/lib/fn/string";@@ -41,12 +45,6 @@ export type TAgentVaultProductMember = TAgentVaultProductActor & {addedAt: Date;};-export const ACTOR_COLUMN: Record<AgentVaultMemberType, "actorUserId" | "actorIdentityId" | "actorGroupId"> = {- [AgentVaultMemberType.User]: "actorUserId",- [AgentVaultMemberType.MachineIdentity]: "actorIdentityId",- [AgentVaultMemberType.Group]: "actorGroupId"-};-type TActorRow = {userId: string | null;machineIdentityId: string | null;@@ -120,7 +118,7 @@ export const agentVaultMemberDALFactory = (db: TDbClient) => {try {const conn = tx || db.replicaNode();- const alreadyGranted = (column: (typeof ACTOR_COLUMN)[AgentVaultMemberType]) =>+ const alreadyGranted = (column: TAgentVaultActorColumn) =>conn(TableName.Membership).where(`${TableName.Membership}.scope`, RESOURCE_SCOPE).where(`${TableName.Membership}.scopeProjectId`, projectId)@@ -141,7 +139,7 @@ export const agentVaultMemberDALFactory = (db: TDbClient) => {void query.where((qb) => {actorTypes.forEach((type) => {- const column = ACTOR_COLUMN[type];+ const column = AGENT_VAULT_ACTOR_COLUMN[type];void qb.orWhere((typeQb) => {void typeQb.whereNotNull(`${TableName.Membership}.${column}`);// Inside the block, where the column is known non-null: a bare whereNotIn would read@@ -268,7 +266,7 @@ export const agentVaultMemberDALFactory = (db: TDbClient) => {try {const conn = tx || db.replicaNode();- const alreadyMembers = (column: (typeof ACTOR_COLUMN)[AgentVaultMemberType]) =>+ const alreadyMembers = (column: TAgentVaultActorColumn) =>conn(TableName.Membership).where(`${TableName.Membership}.scope`, AccessScope.Project).where(`${TableName.Membership}.scopeProjectId`, projectId)@@ -345,7 +343,7 @@ export const agentVaultMemberDALFactory = (db: TDbClient) => {void query.where((qb) => {actorTypes.forEach((type) => {void qb.orWhere((typeQb) => {- const column = ACTOR_COLUMN[type];+ const column = AGENT_VAULT_ACTOR_COLUMN[type];void typeQb.whereNotNull(`${TableName.Membership}.${column}`).whereNotIn(`${TableName.Membership}.${column}`, alreadyMembers(column));diff --git a/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.ts b/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.tsindex 384f14b1b4..a46b00d852 100644--- a/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.ts+++ b/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.ts@@ -39,7 +39,11 @@ import {TClearPersonalValuesDeps} from "../agent-vault-personal-value/agent-vault-personal-value-fns";import { resolveAgentVaultActorNames, TAgentVaultActorName } from "../agent-vault/agent-vault-actor-name-fns";-import { AgentVaultMemberType } from "../agent-vault/agent-vault-enums";+import {+ AGENT_VAULT_ACTOR_COLUMN,+ AgentVaultMemberType,+ TAgentVaultActorColumn+} from "../agent-vault/agent-vault-enums";import { TAgentVaultMemberDALFactory } from "./agent-vault-member-dal";type TAgentVaultMembershipServiceFactoryDep = {@@ -117,14 +121,6 @@ const VALID_PRODUCT_ROLES: string[] = [ProjectMembershipRole.Admin, ProjectMembeconst ALL_ACTOR_TYPES = [AgentVaultMemberType.User, AgentVaultMemberType.Group, AgentVaultMemberType.MachineIdentity];-type TActorColumn = "actorUserId" | "actorIdentityId" | "actorGroupId";--const ACTOR_COLUMN: Record<AgentVaultMemberType, TActorColumn> = {- [AgentVaultMemberType.User]: "actorUserId",- [AgentVaultMemberType.MachineIdentity]: "actorIdentityId",- [AgentVaultMemberType.Group]: "actorGroupId"-};-const isSelf = (actor: TAgentVaultActorRef, ctx: TGenericPermission) =>(actor.type === AgentVaultMemberType.User && ctx.actor === ActorType.USER && actor.id === ctx.actorId) ||(actor.type === AgentVaultMemberType.MachineIdentity && ctx.actor === ActorType.IDENTITY && actor.id === ctx.actorId);@@ -323,7 +319,7 @@ export const agentVaultMembershipServiceFactory = ({// An org reaches a group or an identity through an org-scope membership row, not by owning the row:// that is how a sub-org is given one of its parent's, and how the generic project membership path// decides the same question. Reading orgId off the group or identity refuses every linked one.- const orgScoped = (column: TActorColumn, ids: string[]) =>+ const orgScoped = (column: TAgentVaultActorColumn, ids: string[]) =>ids.length? membershipDAL.find({ scope: AccessScope.Organization, scopeOrgId: orgId, $in: { [column]: ids } }): [];@@ -338,7 +334,7 @@ export const agentVaultMembershipServiceFactory = ({]);- const activeIds = (memberships: TMemberships[], column: TActorColumn) =>+ const activeIds = (memberships: TMemberships[], column: TAgentVaultActorColumn) =>new Set(memberships.filter((membership) => membership.isActive).map((membership) => membership[column]));const userMemberIds = withActiveOrgAccess.userIds;@@ -438,12 +434,12 @@ export const agentVaultMembershipServiceFactory = ({{scope: AccessScope.Project,scopeProjectId: projectId,- $in: { [ACTOR_COLUMN[type]]: ids }+ $in: { [AGENT_VAULT_ACTOR_COLUMN[type]]: ids }},{ tx });rows.forEach((row) => {- const id = row[ACTOR_COLUMN[type]];+ const id = row[AGENT_VAULT_ACTOR_COLUMN[type]];if (id) byActor.set(`${type}:${id}`, row);});})@@ -488,7 +484,7 @@ export const agentVaultMembershipServiceFactory = ({scope: AccessScope.Project,scopeOrgId: ctx.actorOrgId,scopeProjectId: projectId,- [ACTOR_COLUMN[actor.type]]: actor.id,+ [AGENT_VAULT_ACTOR_COLUMN[actor.type]]: actor.id,isActive: true})),tx@@ -506,8 +502,8 @@ export const agentVaultMembershipServiceFactory = ({const membershipByActor = new Map(memberships.map((membership) => {- const type = ALL_ACTOR_TYPES.find((el) => membership[ACTOR_COLUMN[el]])!;- return [`${type}:${membership[ACTOR_COLUMN[type]]!}`, membership];+ const type = ALL_ACTOR_TYPES.find((el) => membership[AGENT_VAULT_ACTOR_COLUMN[el]])!;+ return [`${type}:${membership[AGENT_VAULT_ACTOR_COLUMN[type]]!}`, membership];}));@@ -682,7 +678,7 @@ export const agentVaultMembershipServiceFactory = ({scope: RESOURCE_SCOPE,scopeProjectId: projectId,scopeResourceType: ResourceType.AgentVaultAccessBundle,- $in: { [ACTOR_COLUMN[type]]: typeIds }+ $in: { [AGENT_VAULT_ACTOR_COLUMN[type]]: typeIds }},tx);diff --git a/backend/src/ee/services/agent-vault/agent-vault-enums.ts b/backend/src/ee/services/agent-vault/agent-vault-enums.tsindex 2a3f84902c..20dac6e414 100644--- a/backend/src/ee/services/agent-vault/agent-vault-enums.ts+++ b/backend/src/ee/services/agent-vault/agent-vault-enums.ts@@ -33,6 +33,15 @@ export enum AgentVaultMemberType {Group = "group"}+export type TAgentVaultActorColumn = "actorUserId" | "actorIdentityId" | "actorGroupId";++// The `memberships` column that holds each member type's actor id.+export const AGENT_VAULT_ACTOR_COLUMN: Record<AgentVaultMemberType, TAgentVaultActorColumn> = {+ [AgentVaultMemberType.User]: "actorUserId",+ [AgentVaultMemberType.MachineIdentity]: "actorIdentityId",+ [AgentVaultMemberType.Group]: "actorGroupId"+};+export enum AgentVaultResourceRole {Consumer = "consumer"}diff --git a/frontend/src/components/agent-vault/AccessBundleMemberRow.tsx b/frontend/src/components/agent-vault/AccessBundleMemberRow.tsxindex 548840cb3b..44020bf4e6 100644--- a/frontend/src/components/agent-vault/AccessBundleMemberRow.tsx+++ b/frontend/src/components/agent-vault/AccessBundleMemberRow.tsx@@ -10,42 +10,35 @@ import {DropdownMenuSeparator,DropdownMenuTrigger} from "@app/components/v3";+import { getInitials } from "@app/helpers/string";import { AgentVaultMemberType } from "@app/hooks/api/agentVault/enums";-import { TAgentVaultActor, TAgentVaultProductActor } from "@app/hooks/api/agentVault/types";+import { TAgentVaultMember, TAgentVaultProductActor } from "@app/hooks/api/agentVault/types";import { MEMBER_KIND, memberDisplayName, memberSubtitle } from "./MemberName";import { PendingInvitationBadge } from "./PendingInvitationBadge";const ROW_CLASS_NAME = "flex items-center gap-3 py-3";-const initialsOf = (value: string) =>- value- .split(/[\s@._-]+/)- .filter(Boolean)- .slice(0, 2)- .map((part) => part[0]?.toUpperCase() ?? "")- .join("") || "?";--const MemberIdentity = ({- member,- badge-}: {- member: TAgentVaultActor;- badge?: React.ReactNode;-}) => {+const MemberIdentity = ({ member }: { member: TAgentVaultMember | TAgentVaultProductActor }) => {const name = memberDisplayName(member);const { label, icon: Icon } = MEMBER_KIND[member.type];return (<><div className="flex size-8 shrink-0 items-center justify-center rounded-lg border border-border bg-neutral/10 text-xs font-semibold text-accent">- {member.type === AgentVaultMemberType.User ? initialsOf(name) : <Icon className="size-4" />}+ {member.type === AgentVaultMemberType.User ? (+ getInitials(name)+ ) : (+ <Icon className="size-4" />+ )}<span className="sr-only">{label}</span></div><div className="min-w-0 flex-1"><div className="flex min-w-0 items-center gap-2"><p className="truncate text-sm font-medium text-foreground">{name}</p>- {badge}+ <PendingInvitationBadge+ isPending={member.type === AgentVaultMemberType.User && member.isOrgMembershipPending}+ /></div><p className="truncate text-xs text-muted">{memberSubtitle(member)}</p></div>@@ -54,7 +47,7 @@ const MemberIdentity = ({};type MemberRowProps = {- member: TAgentVaultActor & { grantedAt: string };+ member: TAgentVaultMember;isDisabled?: boolean;onRevoke: () => void;};@@ -97,14 +90,7 @@ type GrantRowProps = {export const AccessBundleGrantRow = ({ member, isDisabled, onGrant }: GrantRowProps) => (<div className={ROW_CLASS_NAME}>- <MemberIdentity- member={member}- badge={- <PendingInvitationBadge- isPending={member.type === AgentVaultMemberType.User && member.isOrgMembershipPending}- />- }- />+ <MemberIdentity member={member} /><Buttonvariant="av"size="sm"diff --git a/frontend/src/components/agent-vault/ManageAccessSheet.tsx b/frontend/src/components/agent-vault/ManageAccessSheet.tsxindex 5b536f6682..910546d6de 100644--- a/frontend/src/components/agent-vault/ManageAccessSheet.tsx+++ b/frontend/src/components/agent-vault/ManageAccessSheet.tsx@@ -1,5 +1,5 @@import { useEffect, useRef, useState } from "react";-import { FilterIcon, PackageIcon, SearchIcon, UsersIcon, XIcon } from "lucide-react";+import { FilterIcon, SearchIcon, UsersIcon, XIcon } from "lucide-react";import { createNotification } from "@app/components/notifications";import {@@ -36,6 +36,7 @@ import {Separator,Sheet,SheetContent,+ SheetDescription,SheetFooter,SheetHeader,SheetTitle,@@ -135,7 +136,9 @@ const ManageAccessContent = ({const {data,isPending: isMembersPending,- isPlaceholderData: isMembersPlaceholder+ isPlaceholderData: isMembersPlaceholder,+ isError: isMembersError,+ isFetching: isMembersFetching} = useListAgentVaultAccessBundleMembers(accessBundle.id, {actorType,search: searchParam,@@ -157,42 +160,59 @@ const ManageAccessContent = ({const revokeMembers = useRevokeAgentVaultAccessBundleMembers();// Both lists keep the previous result while a new filter loads, so rows of the previous type are hidden- // here, and a list that hides everything reads as loading rather than empty.+ // here. Only a list whose rows that hid entirely reads as loading: an empty previous result keeps+ // showing, as it would for any other refetch.const matchesType = (type: AgentVaultMemberType) => !typeFilter || type === typeFilter;- const members = (data?.members ?? []).filter((member) => matchesType(member.type));+ const shownMembers = data?.members ?? [];+ const members = shownMembers.filter((member) => matchesType(member.type));const totalCount = data?.totalCount ?? 0;- const candidates = (available?.members ?? []).filter((member) => matchesType(member.type));+ const shownCandidates = available?.members ?? [];+ const candidates = shownCandidates.filter((member) => matchesType(member.type));const candidateCount = available?.totalCount ?? 0;- const isPending = isMembersPending || (isMembersPlaceholder && !members.length);- const isAvailableLoading = isAvailablePending || (isAvailablePlaceholder && !candidates.length);+ const isMembersLoading =+ isMembersPending || (isMembersPlaceholder && shownMembers.length > 0 && !members.length);+ const isAvailableLoading =+ isAvailablePending ||+ (isAvailablePlaceholder && shownCandidates.length > 0 && !candidates.length);useResetPageHelper({ totalCount, offset: (page - 1) * PER_PAGE, setPage });// 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 || hasPickedInitialSection.current) return;+ if (isMembersPending || isMembersError || hasPickedInitialSection.current) return;hasPickedInitialSection.current = true;if (!totalCount) setNoAccessSection(NO_ACCESS_SECTION);- }, [isPending, totalCount]);+ }, [isMembersPending, isMembersError, totalCount]);- const isFiltered = Boolean(searchParam || typeFilter);+ const typeLabel = TYPE_OPTIONS.find((option) => option.value === typeFilter)?.label.toLowerCase();const isAvailableSettled = !isAvailableLoading && !isAvailableError;+ // Until the candidates load, assume there are some, so the copy does not change under the reader.+ const canGrantSomeone = !isAvailableSettled || candidateCount > 0;const isSearchMiss = Boolean(searchParam) && !totalCount && isAvailableSettled && !candidateCount;// a granted candidate stays in this list until the refetch landsconst isGrantLocked = addMembers.isPending || isAvailableFetching;const memberToRemoveName = memberToRemove ? memberDisplayName(memberToRemove) : "";- const emptyState = typeFilter+ const emptyState = typeLabel? {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.`+ description: canGrantSomeone+ ? `No ${typeLabel} have access to this bundle. Clear the filter, or grant access from the No Access section.`+ : `No ${typeLabel} have access to this bundle. Clear the filter to see everyone with access.`}: {title: "No one has access yet",- description:- "Grant access from the No Access section to let members create sessions with this bundle."+ description: canGrantSomeone+ ? "Grant access from the No Access section to let members create sessions with this bundle."+ : "Add members to Agent Vault first, then grant them this bundle."};+ const noCandidatesText = (() => {+ if (searchParam) return `No ${typeLabel ?? "members"} without access match your search.`;+ if (typeLabel) return `No ${typeLabel} without access.`;+ return "Everyone in Agent Vault already has this bundle.";+ })();+const changeFilter = (next: AgentVaultMemberType | null) => {setTypeFilter(next);setPage(1);@@ -252,13 +272,7 @@ const ManageAccessContent = ({}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 <p className="py-2.5 text-xs text-muted">{noCandidatesText}</p>;}return (<>@@ -272,7 +286,7 @@ const ManageAccessContent = ({/>))}</section>- {candidateCount > candidates.length && (+ {candidateCount > candidates.length && !isAvailablePlaceholder && (<p className="py-2.5 text-xs text-muted">Showing the first {AVAILABLE_PREVIEW_LIMIT} of {candidateCount}. Search to find someoneelse.@@ -289,10 +303,9 @@ const ManageAccessContent = ({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>+ <SheetDescription className="sr-only">+ Manage who can create sessions with {accessBundle.name}.+ </SheetDescription></SheetHeader><div className="thin-scrollbar flex-1 space-y-4 overflow-y-auto p-4">@@ -327,7 +340,13 @@ const ManageAccessContent = ({<MemberTypeFilter value={typeFilter} onChange={changeFilter} /></div>- {isPending && (+ {isMembersError && (+ <p className="text-sm text-danger">+ Could not load the members with access. Close this panel and open it again to retry.+ </p>+ )}++ {isMembersLoading && !isMembersError && (<div className="space-y-2"><Skeleton className="h-14 w-full" /><Skeleton className="h-14 w-full" />@@ -335,7 +354,7 @@ const ManageAccessContent = ({</div>)}- {!isPending && !members.length && !searchParam && (+ {!isMembersLoading && !isMembersError && !members.length && !searchParam && (<Empty className="border"><EmptyHeader><EmptyMedia variant="icon">@@ -347,23 +366,36 @@ const ManageAccessContent = ({</Empty>)}- {!isPending && isSearchMiss && (- <p className="text-sm text-muted">No members match your search and filters.</p>+ {!isMembersLoading && isSearchMiss && (+ <p className="text-sm text-muted">No {typeLabel ?? "members"} match your search.</p>)}- {!isPending && Boolean(members.length) && (+ {!isMembersLoading && Boolean(members.length) && (<section className="flex flex-col">{members.map((member) => (<AccessBundleMemberRowkey={`${member.type}:${member.id}`}member={member}+ isDisabled={revokeMembers.isPending || isMembersFetching}onRevoke={() => setMemberToRemove(member)}/>))}</section>)}- {!isPending && (+ {!isMembersPending && 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>}+ />+ )}++ {!isMembersPending && (<Accordiontype="single"collapsible@@ -382,18 +414,6 @@ const ManageAccessContent = ({</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><SheetFooter className="border-t">diff --git a/frontend/src/components/agent-vault/ManageDelegationSheet.tsx b/frontend/src/components/agent-vault/ManageDelegationSheet.tsxindex 12a601f7b3..b6ff9c261e 100644--- a/frontend/src/components/agent-vault/ManageDelegationSheet.tsx+++ b/frontend/src/components/agent-vault/ManageDelegationSheet.tsx@@ -60,6 +60,7 @@ import {TooltipContent,TooltipTrigger} from "@app/components/v3";+import { getInitials } from "@app/helpers/string";import { useDebounce } from "@app/hooks";import {useAddAgentVaultDelegationSubjects,@@ -99,14 +100,6 @@ export type TDelegationSubjectRow = TAgentVaultActor & {missingAccessBundles: TAgentVaultMissingAccessBundle[];};-const initialsOf = (value: string) =>- value- .split(/[\s@._-]+/)- .filter(Boolean)- .slice(0, 2)- .map((part) => part[0]?.toUpperCase() ?? "")- .join("") || "?";-const SubjectIdentity = ({member,badge@@ -120,7 +113,11 @@ const SubjectIdentity = ({return (<><div className="flex size-8 shrink-0 items-center justify-center rounded-lg border border-border bg-neutral/10 text-xs font-semibold text-accent">- {member.type === AgentVaultMemberType.User ? initialsOf(name) : <Icon className="size-4" />}+ {member.type === AgentVaultMemberType.User ? (+ getInitials(name)+ ) : (+ <Icon className="size-4" />+ )}<span className="sr-only">{label}</span></div><div className="min-w-0 flex-1">diff --git a/frontend/src/helpers/string.test.ts b/frontend/src/helpers/string.test.tsindex 0b529e70f1..759b5630e5 100644--- a/frontend/src/helpers/string.test.ts+++ b/frontend/src/helpers/string.test.ts@@ -1,6 +1,6 @@import { describe, expect, test } from "vitest";-import { nameList } from "./string";+import { getInitials, nameList } from "./string";describe("nameList", () => {test.each([@@ -12,3 +12,16 @@ describe("nameList", () => {expect(nameList(names)).toBe(expected);});});++describe("getInitials", () => {+ test.each([+ ["Jane Doe", "JD"],+ ["Mary Jane Watson", "MJ"],+ ["[email protected]", "JD"],+ ["[email protected]", "U"],+ ["support-triage", "ST"],+ ["", "?"]+ ])("%j", (value, expected) => {+ expect(getInitials(value)).toBe(expected);+ });+});diff --git a/frontend/src/helpers/string.ts b/frontend/src/helpers/string.tsindex e7af4d39f0..a5f80f6304 100644--- a/frontend/src/helpers/string.ts+++ b/frontend/src/helpers/string.ts@@ -28,3 +28,13 @@ export const nameList = (names: string[]) => {if (shown.length <= 2) return shown.join(" and ");return `${shown.slice(0, -1).join(", ")} and ${shown[shown.length - 1]}`;};++// Only the part of an email before the @ counts, so "[email protected]" gives "JD", not "JE".+export const getInitials = (value: string) =>+ value+ .split("@")[0]+ .split(/[\s._-]+/)+ .filter(Boolean)+ .slice(0, 2)+ .map((part) => part[0].toUpperCase())+ .join("") || "?";diff --git a/frontend/src/hooks/api/agentVault/types.ts b/frontend/src/hooks/api/agentVault/types.tsindex 75fbb64bf4..cefce410c1 100644--- a/frontend/src/hooks/api/agentVault/types.ts+++ b/frontend/src/hooks/api/agentVault/types.ts@@ -148,7 +148,12 @@ export type TAgentVaultActor =export type TAgentVaultActorRef = { type: AgentVaultMemberType; id: string };-export type TAgentVaultMember = TAgentVaultActor & { grantedAt: string };+export type TAgentVaultMember = (+ | (Extract<TAgentVaultActor, { type: AgentVaultMemberType.User }> & {+ isOrgMembershipPending: boolean;+ })+ | Exclude<TAgentVaultActor, { type: AgentVaultMemberType.User }>+) & { grantedAt: string };export type TAgentVaultProductActor =| (Extract<TAgentVaultActor, { type: AgentVaultMemberType.User }> & {diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/FolderAccessSheet/folder-access.utils.ts b/frontend/src/pages/secret-manager/OverviewPage/components/FolderAccessSheet/folder-access.utils.tsindex 720d5339ea..7067b74d98 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/FolderAccessSheet/folder-access.utils.ts+++ b/frontend/src/pages/secret-manager/OverviewPage/components/FolderAccessSheet/folder-access.utils.ts@@ -1,5 +1,6 @@import { format } from "date-fns";+import { getInitials } from "@app/helpers/string";import {TFolderAccess,TFolderAccessIdentity,@@ -25,14 +26,6 @@ export type TFolderAccessActor = {const sortRoles = (roles: TFolderAccessRole[]) =>[...roles].sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: "base" }));-const initialsOf = (value: string) =>- value- .split(/[\s@._-]+/)- .filter(Boolean)- .slice(0, 2)- .map((part) => part[0]?.toUpperCase() ?? "")- .join("") || "?";-export const toUserActor = (user: TFolderAccessUser): TFolderAccessActor => {const fullName = [user.firstName, user.lastName].filter(Boolean).join(" ").trim();const name = fullName || user.username;@@ -42,7 +35,7 @@ export const toUserActor = (user: TFolderAccessUser): TFolderAccessActor => {membershipId: user.membership.id,name,subtitle: user.email ?? user.username,- initials: initialsOf(name),+ initials: getInitials(name),isProjectAdmin: user.membership.isProjectAdmin,roles: sortRoles(user.membership.roles),access: user.folderRBACAccess@@ -55,7 +48,7 @@ export const toIdentityActor = (identity: TFolderAccessIdentity): TFolderAccessAmembershipId: identity.membership.id,name: identity.name,subtitle: "Machine identity",- initials: initialsOf(identity.name),+ initials: getInitials(identity.name),isProjectAdmin: identity.membership.isProjectAdmin,roles: sortRoles(identity.membership.roles),access: identity.folderRBACAccess@@ -72,7 +65,7 @@ export const toOrgUserActor = ({ user, inviteEmail, status }: OrgUser): TFolderAmembershipId: null,name,subtitle: status === "invited" ? "Invite pending" : email,- initials: initialsOf(name),+ initials: getInitials(name),isProjectAdmin: false,roles: [],access: null@@ -91,7 +84,7 @@ export const toOrgIdentityActor = ({membershipId: null,name,subtitle: "Machine identity",- initials: initialsOf(name),+ initials: getInitials(name),isProjectAdmin: false,roles: [],access: null