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
improvement(agent-vault): keep reveal toggle, hide it only over the stored-value mask
Devin AI6fff3c013603
diff --git a/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx b/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsxindex 993139151d..ca76823da1 100644--- a/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx+++ b/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx@@ -1,6 +1,6 @@import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";import { Controller, ControllerRenderProps, useFormContext } from "react-hook-form";-import { XIcon } from "lucide-react";+import { EyeIcon, EyeOffIcon, XIcon } from "lucide-react";import {Alert,@@ -69,7 +69,7 @@ export const SecretInput = <TName extends SecretName>({storedKeys?: string[];}) => {const { setFocus } = useFormContext<TServiceForm>();- const [isFocused, setIsFocused] = useState(false);+ const [isVisible, setIsVisible] = useState(false);const [isCleared, setIsCleared] = useState(false);const descriptionId = useId();const inputRef = useRef<HTMLInputElement | null>(null);@@ -80,9 +80,8 @@ export const SecretInput = <TName extends SecretName>({const value = field.value ?? "";const isReferenceOnly = !isUntouched && isVariableReferenceOnly(value);- // The sentinel must never render as text, and a lone reference holds no secret. A stored value is- // never returned, so there is nothing to reveal: a typed value shows only while the field has focus.- const isShown = (isFocused && !isUntouched) || isReferenceOnly;+ // The sentinel must never render as text, and a lone reference holds no secret.+ const isShown = (isVisible && !isUntouched) || isReferenceOnly;const isHighlighted = isShown && value.includes("{{");// Focusing only empties the box: left empty, it gets the stored value back on blur.const isStoredValueKept = isUntouched || (hasStoredSecret && !value && !isCleared);@@ -94,6 +93,7 @@ export const SecretInput = <TName extends SecretName>({setIsCleared(false);field.onChange(next);caretRef.current = caret;+ setIsVisible(true);}});@@ -102,6 +102,11 @@ export const SecretInput = <TName extends SecretName>({if (isUntouched) setIsCleared(false);}, [isUntouched]);+ // A value that starts as a reference stays readable as text is typed around it.+ useEffect(() => {+ if (isReferenceOnly) setIsVisible(true);+ }, [isReferenceOnly]);+const syncOverlay = () => {if (overlayRef.current && inputRef.current) {overlayRef.current.scrollLeft = inputRef.current.scrollLeft;@@ -118,6 +123,7 @@ export const SecretInput = <TName extends SecretName>({});const lowerLabel = label.toLowerCase();+ const isClearable = canBeCleared && hasStoredSecret;return (<>@@ -154,6 +160,8 @@ export const SecretInput = <TName extends SecretName>({data-bwignoreonChange={(event) => {setIsCleared(false);+ // An emptied field masks again, since what is typed next may be a real secret.+ if (!event.target.value) setIsVisible(false);field.onChange(event);autocomplete.refresh();}}@@ -165,13 +173,11 @@ export const SecretInput = <TName extends SecretName>({onSelect={syncOverlay}onScroll={syncOverlay}onFocus={() => {- setIsFocused(true);if (isUntouched) field.onChange("");}}// Empty reads the same whether the secret was meant to go or the field was only clicked into,// so the clear button is made the one way to say it and passing through loses nothing.onBlur={() => {- setIsFocused(false);autocomplete.close();if (hasStoredSecret && !field.value && !isCleared) field.onChange(UNCHANGED_SECRET);field.onBlur();@@ -180,19 +186,31 @@ export const SecretInput = <TName extends SecretName>({isError={isError}/></div>- {canBeCleared && hasStoredSecret && (+ {(isClearable || !isUntouched) && (<InputGroupAddon align="inline-end">- <InputGroupButton- isDisabled={isCleared}- aria-label={`Clear ${lowerLabel}`}- onClick={() => {- setIsCleared(true);- field.onChange("");- setFocus(field.name);- }}- >- <XIcon />- </InputGroupButton>+ {isClearable && (+ <InputGroupButton+ isDisabled={isCleared}+ aria-label={`Clear ${lowerLabel}`}+ onClick={() => {+ setIsCleared(true);+ field.onChange("");+ setFocus(field.name);+ }}+ >+ <XIcon />+ </InputGroupButton>+ )}+ {/* A stored credential is never returned, so until it is replaced there is nothing to reveal. */}+ {!isUntouched && (+ <InputGroupButton+ isDisabled={!field.value || isReferenceOnly}+ aria-label={`${isVisible ? "Hide" : "Show"} ${lowerLabel}`}+ onClick={() => setIsVisible((prev) => !prev)}+ >+ {isVisible ? <EyeOffIcon /> : <EyeIcon />}+ </InputGroupButton>+ )}</InputGroupAddon>)}</InputGroup>