Skip to content

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

improvement(agent-vault): show one key and a +N badge under stored values

Scott Wilson61ee14586675
diff --git a/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx b/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx
index 6cf2cf53bc..4a1e2eef9a 100644
--- a/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx
@@ -23,7 +23,7 @@ import {
SelectValue
} from "@app/components/v3";
import { cn } from "@app/components/v3/utils";
-import { isVariableReferenceOnly, toVariableReference } from "@app/helpers/agentVaultVariables";
+import { isVariableReferenceOnly } from "@app/helpers/agentVaultVariables";
import { AgentVaultCredentialType } from "@app/hooks/api/agentVault";
import { SendsPreview } from "./SendsPreview";
@@ -32,7 +32,7 @@ import { useServiceVariables } from "./ServiceVariablesContext";
import {
ReferenceHighlights,
useVariableAutocomplete,
- VariableChip,
+ VariableKeyChips,
VariableSuggestions
} from "./VariableReferenceInput";
@@ -235,14 +235,7 @@ export const SecretInput = <TName extends SecretName>({
className="flex flex-wrap items-center gap-1"
>
Current value uses
- {storedKeys?.map((key) => (
- <VariableChip
- key={key}
- reference={toVariableReference(key)}
- isKnown
- className="font-mono"
- />
- ))}
+ <VariableKeyChips keys={storedKeys ?? []} />
</FieldDescription>
)}
</>
diff --git a/frontend/src/components/agent-vault/service-sheet/VariableReferenceInput.tsx b/frontend/src/components/agent-vault/service-sheet/VariableReferenceInput.tsx
index 282165e016..513b4486cd 100644
--- a/frontend/src/components/agent-vault/service-sheet/VariableReferenceInput.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/VariableReferenceInput.tsx
@@ -10,7 +10,14 @@ import {
} from "react";
import { LockIcon, PlusIcon } from "lucide-react";
-import { Popover, PopoverAnchor, PopoverContent } from "@app/components/v3";
+import {
+ HoverCard,
+ HoverCardContent,
+ HoverCardTrigger,
+ Popover,
+ PopoverAnchor,
+ PopoverContent
+} from "@app/components/v3";
import { cn } from "@app/components/v3/utils";
import {
findOpenVariableReference,
@@ -47,6 +54,47 @@ export const VariableChip = ({
className?: string;
}) => <span className={cn("rounded-[3px] px-1", chipTone(isKnown), className)}>{reference}</span>;
+// Only the first key shows, so a value using several keeps the hint under its field to one line.
+export const VariableKeyChips = ({ keys }: { keys: string[] }) => {
+ const [firstKey, ...otherKeys] = keys;
+ if (!firstKey) return null;
+
+ return (
+ <>
+ <VariableChip reference={toVariableReference(firstKey)} isKnown className="font-mono" />
+ {otherKeys.length > 0 && (
+ <HoverCard openDelay={150} closeDelay={100}>
+ <HoverCardTrigger asChild>
+ <button
+ type="button"
+ aria-label={`${otherKeys.length} more: ${otherKeys.join(", ")}`}
+ className={cn(
+ "rounded-[3px] px-1 font-mono outline-hidden focus-visible:ring-2 focus-visible:ring-ring/50",
+ chipTone(true)
+ )}
+ >
+ +{otherKeys.length}
+ </button>
+ </HoverCardTrigger>
+ <HoverCardContent
+ align="start"
+ className="flex w-auto max-w-sm flex-col items-start gap-1"
+ >
+ {otherKeys.map((key) => (
+ <VariableChip
+ key={key}
+ reference={toVariableReference(key)}
+ isKnown
+ className="font-mono text-xs break-all"
+ />
+ ))}
+ </HoverCardContent>
+ </HoverCard>
+ )}
+ </>
+ );
+};
+
/**
* The value drawn behind a transparent input, with each reference marked. Marks add colour but no
* padding, so every character sits exactly where the input's own would.