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
UI changes
Matheus Nogueirac9d4ba283ccc
diff --git a/frontend/src/components/v3/platform/SecretInput/InfisicalSecretInput.tsx b/frontend/src/components/v3/platform/SecretInput/InfisicalSecretInput.tsxindex 5fb756c625..4ef9d7826b 100644--- a/frontend/src/components/v3/platform/SecretInput/InfisicalSecretInput.tsx+++ b/frontend/src/components/v3/platform/SecretInput/InfisicalSecretInput.tsx@@ -1,17 +1,15 @@-import { forwardRef, TextareaHTMLAttributes, useCallback, useMemo, useRef, useState } from "react";+import { forwardRef, TextareaHTMLAttributes, useCallback, useRef } from "react";import * as PopoverPrimitive from "@radix-ui/react-popover";import { useNavigate } from "@tanstack/react-router";-import { FolderIcon, KeyRoundIcon, LayersIcon, SearchIcon } from "lucide-react";import { createNotification } from "@app/components/notifications";import { ROUTE_PATHS } from "@app/const/routes";import { useProject, useProjectPermission } from "@app/context";import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";import { useDebounce, useToggle } from "@app/hooks";-import { useGetProjectFolders, useGetProjectSecrets } from "@app/hooks/api";import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";-import { cn } from "../../utils";+import { SecretReferenceWizard } from "./SecretReferenceWizard";import { SecretInput } from "./SecretInput";const getIndexOfUnclosedRefToTheLeft = (value: string, pos: number) => {@@ -31,22 +29,6 @@ const getIndexOfUnclosedRefToTheRight = (value: string, pos: number) => {return -1;};-const getClosingSymbol = (isSelectedSecret: boolean, isClosed: boolean) => {- if (!isClosed) {- return isSelectedSecret ? "}" : ".";- }- if (!isSelectedSecret) return ".";- return "";-};--const mod = (n: number, m: number) => ((n % m) + m) % m;--export enum ReferenceType {- ENVIRONMENT = "environment",- FOLDER = "folder",- SECRET = "secret"-}-type Props = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange" | "value"> & {value?: string;onChange: (val: string) => void;@@ -62,12 +44,6 @@ type Props = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange" | "valisErrorLoadingValue?: boolean;};-type ReferenceItem = {- label: string;- type: ReferenceType;- slug: string;-};-export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(({@@ -88,230 +64,77 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(const [debouncedValue] = useDebounce(value, 100);- const [highlightedIndex, setHighlightedIndex] = useState(-1);-const inputRef = useRef<HTMLTextAreaElement>(null);- const popoverContentRef = useRef<HTMLDivElement>(null);const [isFocused, setIsFocused] = useToggle(false);const currentCursorPosition = inputRef.current?.selectionStart || 0;- const suggestionSource = useMemo(() => {+ const openRefLeft = (() => {const left = getIndexOfUnclosedRefToTheLeft(debouncedValue, currentCursorPosition - 1);- if (left === -1) return { left, value: "", predicate: "", isDeep: false };-- const suggestionSourceValue = debouncedValue.slice(left + 1, currentCursorPosition);- let suggestionSourceEnv: string | undefined = propEnvironment;- let suggestionSourceSecretPath: string | undefined = propSecretPath || "/";-- const isDeep = suggestionSourceValue.includes(".");- let predicate = suggestionSourceValue;- if (isDeep) {- const [envSlug, ...folderPaths] = suggestionSourceValue.split(".");- const isValidEnvSlug = currentProject?.environments.find((e) => e.slug === envSlug);- suggestionSourceEnv = isValidEnvSlug ? envSlug : undefined;- suggestionSourceSecretPath = `/${folderPaths.slice(0, -1)?.join("/")}`;- predicate = folderPaths[folderPaths.length - 1];- }-- return {- left: left + 1,- value: suggestionSourceValue,- predicate,- isOpen: left !== -1,- isDeep,- environment: suggestionSourceEnv,- secretPath: suggestionSourceSecretPath- };- }, [debouncedValue]);-- const isPopupOpen = Boolean(suggestionSource.isOpen) && isFocused;- const { data: secrets } = useGetProjectSecrets({- viewSecretValue: false,- environment: suggestionSource.environment || "",- secretPath: suggestionSource.secretPath || "",- projectId,- options: {- enabled: isPopupOpen- }- });- const { data: folders } = useGetProjectFolders({- environment: suggestionSource.environment || "",- path: suggestionSource.secretPath || "",- projectId,- options: {- enabled: isPopupOpen- }- });-- const suggestions = useMemo(() => {- if (!isPopupOpen) return [];- setHighlightedIndex(0);- const suggestionsArr: ReferenceItem[] = [];- const predicate = suggestionSource.predicate.toLowerCase();-- if (!suggestionSource.isDeep) {- (currentProject?.environments || []).forEach(({ name, slug }) => {- if (name.toLowerCase().startsWith(predicate))- suggestionsArr.push({- label: name,- slug,- type: ReferenceType.ENVIRONMENT- });- });- } else {- (folders || []).forEach(({ name }) => {- if (name.toLowerCase().startsWith(predicate))- suggestionsArr.push({- label: name,- slug: name,- type: ReferenceType.FOLDER- });- });- }- (secrets || []).forEach(({ key }) => {- if (key.toLowerCase().startsWith(predicate))- suggestionsArr.push({- label: key,- slug: key,- type: ReferenceType.SECRET- });- });-- if (suggestionsArr.length === 0 && suggestionSource.predicate.trim()) {- suggestionsArr.push({- label: "No matches found",- slug: "__no_match__",- type: ReferenceType.SECRET- });- }-- return suggestionsArr;- }, [- secrets,- folders,- currentProject?.environments,- isPopupOpen,- suggestionSource.value,- suggestionSource.predicate- ]);-- const handleSuggestionSelect = (selectIndex?: number) => {- const selectedSuggestion =- suggestions[typeof selectIndex !== "undefined" ? selectIndex : highlightedIndex];- if (!selectedSuggestion || selectedSuggestion.slug === "__no_match__") {- return;- }-- const rightBracketIndex = getIndexOfUnclosedRefToTheRight(value, suggestionSource.left);+ if (left === -1) return -1;+ // Only open the wizard when the cursor is right after ${ with no dots yet typed+ // (typing env.folder... is handled inline; wizard is for fresh ${)+ const partial = debouncedValue.slice(left + 1, currentCursorPosition);+ if (partial.includes(".")) return -1;+ return left;+ })();++ const isPopupOpen = openRefLeft !== -1 && isFocused;++ const handleWizardSelect = (referenceContent: string) => {+ const left = openRefLeft + 1; // position right after ${+ const rightBracketIndex = getIndexOfUnclosedRefToTheRight(value, left);const isEnclosed = rightBracketIndex !== -1;- const lhsValue = value.slice(0, suggestionSource.left);++ const lhsValue = value.slice(0, left);const rhsValue = value.slice(rightBracketIndex !== -1 ? rightBracketIndex + 1 : currentCursorPosition);- const mid = suggestionSource.isDeep- ? `${suggestionSource.value.slice(0, -suggestionSource.predicate.length || undefined)}${- selectedSuggestion.slug- }`- : selectedSuggestion.slug;- const closingSymbol = getClosingSymbol(- selectedSuggestion.type === ReferenceType.SECRET,- isEnclosed- );- const newValue = `${lhsValue}${mid}${closingSymbol}${rhsValue}`;+ const newValue = `${lhsValue}${referenceContent}${isEnclosed ? "" : "}"}${rhsValue}`;onChange?.(newValue);+const delay = setTimeout(() => {clearTimeout(delay);- if (inputRef.current)- inputRef.current.selectionEnd =- lhsValue.length +- mid.length +- closingSymbol.length +- (isEnclosed && selectedSuggestion.type === ReferenceType.SECRET ? 1 : 0);- }, 10);- setHighlightedIndex(-1);- };-- const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {- if (isPopupOpen) {- if (e.key === "ArrowDown" || (e.key === "Tab" && !e.shiftKey)) {- setHighlightedIndex((prevIndex) => {- let nextIndex = mod(prevIndex + 1, suggestions.length);- while (- nextIndex < suggestions.length &&- suggestions[nextIndex].slug === "__no_match__"- ) {- nextIndex = mod(nextIndex + 1, suggestions.length);- }- if (suggestions[nextIndex]?.slug === "__no_match__") {- return -1;- }- popoverContentRef.current?.children?.[nextIndex]?.scrollIntoView({- block: "nearest",- behavior: "smooth"- });- return nextIndex;- });- } else if (e.key === "ArrowUp" || (e.key === "Tab" && e.shiftKey)) {- setHighlightedIndex((prevIndex) => {- let prevIdx = mod(prevIndex - 1, suggestions.length);- while (prevIdx >= 0 && suggestions[prevIdx].slug === "__no_match__") {- prevIdx = mod(prevIdx - 1, suggestions.length);- }- if (suggestions[prevIdx]?.slug === "__no_match__") {- return -1;- }- popoverContentRef.current?.children?.[prevIdx]?.scrollIntoView({- block: "nearest",- behavior: "smooth"- });- return prevIdx;- });- } else if (e.key === "Enter" && highlightedIndex >= 0) {- e.preventDefault();- handleSuggestionSelect();- }- if (["ArrowDown", "ArrowUp", "Tab"].includes(e.key)) {- e.preventDefault();+ if (inputRef.current) {+ const cursorPos = lhsValue.length + referenceContent.length + 1; // +1 for }+ inputRef.current.selectionEnd = cursorPos;}- }- };+ }, 10);- const handlePopUpOpen = () => {- setHighlightedIndex(-1);+ setIsFocused.off();};- const handleRef = useCallback((el: HTMLTextAreaElement) => {- // @ts-expect-error this is for multiple ref single component- inputRef.current = el;- if (ref) {- if (typeof ref === "function") {- ref(el);- } else {- // eslint-disable-next-line- ref.current = el;+ const handleRef = useCallback(+ (el: HTMLTextAreaElement) => {+ // @ts-expect-error multiple refs+ inputRef.current = el;+ if (ref) {+ if (typeof ref === "function") {+ ref(el);+ } else {+ // eslint-disable-next-line+ ref.current = el;+ }}- }- }, []);+ },+ [ref]+ );const handleClickSegment = useCallback((segment: string, allSegments: string[]) => {if (!projectId) {- createNotification({- text: "Project ID is not set",- type: "error"- });+ createNotification({ text: "Project ID is not set", type: "error" });return;}if (allSegments.length === 0) {- createNotification({- text: "Invalid secret reference",- type: "error"- });+ createNotification({ text: "Invalid secret reference", type: "error" });return;}+ // Cross-project references (start with @) are not navigable yet+ if (allSegments[0]?.startsWith("@")) return;+if (allSegments.length === 1) {const canReadSecretValue = hasSecretReadValueOrDescribePermission(permission,@@ -351,13 +174,9 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(const pathSegments = allSegments.slice(1, -1);for (let i = 0; i < pathSegments.length; i += 1) {if (!pathSegments[i]) {- createNotification({- text: "Invalid secret reference",- type: "error"- });+ createNotification({ text: "Invalid secret reference", type: "error" });return;}-const pathSegment = pathSegments[i];folderPath += `${pathSegment}`;if (pathSegment === segment) {@@ -391,10 +210,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(navigate({to: ROUTE_PATHS.SecretManager.SecretDashboardPage.path,- params: {- projectId,- envSlug: environmentSlug- },+ params: { projectId, envSlug: environmentSlug },search: (prev) => ({...prev,secretPath: segment === environmentSlug ? "/" : folderPath,@@ -407,34 +223,13 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>([navigate, projectId, permission, propEnvironment, propSecretPath]);- const getEntryIcon = (item: ReferenceItem) => {- if (item.slug === "__no_match__") {- return <SearchIcon className="size-4 text-muted" />;- }- if (item.type === ReferenceType.SECRET) {- return <KeyRoundIcon className="size-4 text-muted" />;- }- if (item.type === ReferenceType.ENVIRONMENT) {- return <LayersIcon className="size-4 text-success" />;- }- return <FolderIcon className="size-4 text-warning" />;- };-- const getSubText = (item: ReferenceItem) => {- if (item.slug === "__no_match__") return "No results";- if (item.type === ReferenceType.SECRET) return "Secret";- if (item.type === ReferenceType.ENVIRONMENT) return "Environment";- return "Folder";- };-return (- <PopoverPrimitive.Root open={isPopupOpen} onOpenChange={handlePopUpOpen}>+ <PopoverPrimitive.Root open={isPopupOpen}><PopoverPrimitive.Trigger asChild><SecretInput{...props}canEditButNotView={canEditButNotView}ref={handleRef}- onKeyDown={handleKeyDown}value={value}onFocus={(evt) => {if (props.onFocus) props.onFocus(evt);@@ -443,7 +238,6 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(onBlur={(evt) => {if (!(evt.relatedTarget?.getAttribute("aria-label") === "suggestion-item"))setIsFocused.off();-if (props.onBlur) props.onBlur(evt);}}onChange={(e) => onChange?.(e.target.value)}@@ -455,72 +249,15 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(<PopoverPrimitive.Contentalign="start"onOpenAutoFocus={(e) => e.preventDefault()}- className="relative top-2 z-[100] max-h-64 thin-scrollbar overflow-auto rounded-md border border-border bg-popover text-foreground shadow-md"- style={{- width: "var(--radix-popover-trigger-width)"- }}+ onMouseDown={(e) => e.preventDefault()}+ className="relative top-2 z-[100] max-h-80 overflow-auto rounded-md border border-border bg-popover text-foreground shadow-md thin-scrollbar"+ style={{ width: "var(--radix-popover-trigger-width)", minWidth: "320px" }}>- <div- className="flex h-full w-full flex-col items-center justify-center rounded-md"- ref={popoverContentRef}- >- {suggestions.map((item, i) => {- const isNoMatchMessage = item.slug === "__no_match__";- const entryIcon = getEntryIcon(item);- const subText = getSubText(item);-- return isNoMatchMessage ? (- <div- role="status"- aria-label="no-match-message"- className="flex w-full items-center justify-between text-left"- key={`secret-reference-secret-${i + 1}`}- >- <div className="relative flex w-full cursor-default items-center justify-between px-2 py-2 text-sm opacity-75 outline-hidden transition-all select-none">- <div className="flex w-full items-start gap-2">- <div className="mt-0.5 flex items-center">{entryIcon}</div>- <div className="w-10/12 truncate text-left">- <span className="text-muted">{item.label}</span>- <div className="mb-[0.1rem] text-xs leading-3 text-muted">{subText}</div>- </div>- </div>- </div>- </div>- ) : (- <button- type="button"- onKeyDown={(e) => {- if (e.key === "Enter") handleSuggestionSelect(i);- }}- aria-label="suggestion-item"- onClick={(e) => {- inputRef.current?.focus();- e.preventDefault();- e.stopPropagation();- handleSuggestionSelect(i);- }}- onMouseEnter={() => setHighlightedIndex(i)}- className="flex w-full items-center justify-between border-none bg-transparent p-0 text-left"- key={`secret-reference-secret-${i + 1}`}- >- <div- className={cn(- "relative flex w-full cursor-pointer items-center justify-between px-2 py-2 text-sm outline-hidden transition-all select-none hover:bg-foreground/10",- highlightedIndex === i && "bg-foreground/5"- )}- >- <div className="flex w-full items-start gap-2">- <div className="mt-0.5 flex items-center">{entryIcon}</div>- <div className="w-10/12 truncate text-left">- <span>{item.label}</span>- <div className="mb-[0.1rem] text-xs leading-3 text-muted">{subText}</div>- </div>- </div>- </div>- </button>- );- })}- </div>+ <SecretReferenceWizard+ isEnabled={isPopupOpen}+ onSelect={handleWizardSelect}+ onFocusItem={() => inputRef.current?.focus()}+ /></PopoverPrimitive.Content></PopoverPrimitive.Portal></PopoverPrimitive.Root>diff --git a/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx b/frontend/src/components/v3/platform/SecretInput/SecretInput.tsxindex b6c2798671..f0dd79b112 100644--- a/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx+++ b/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx@@ -6,7 +6,7 @@ import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPaimport { cn } from "../../utils";-const REGEX = /(\${([a-zA-Z0-9-_. ]+)})/g;+const REGEX = /(\${([@a-zA-Z0-9-_. ]+)})/g;const syntaxHighlight = (content?: string | null,diff --git a/frontend/src/components/v3/platform/SecretInput/SecretReferenceWizard.tsx b/frontend/src/components/v3/platform/SecretInput/SecretReferenceWizard.tsxnew file mode 100644index 0000000000..0cf0c5a56f--- /dev/null+++ b/frontend/src/components/v3/platform/SecretInput/SecretReferenceWizard.tsx@@ -0,0 +1,396 @@+import { useMemo, useState } from "react";+import { ArrowLeftIcon, ChevronRightIcon, FolderIcon, KeyRoundIcon, LayersIcon } from "lucide-react";++import { useProject } from "@app/context";+import { useGetProjectFolders, useGetProjectSecrets, useGetWorkspaceById } from "@app/hooks/api";+import { useListProjectGrantsReceived } from "@app/hooks/api/projectGrants";+import { TProjectGrantReceived } from "@app/hooks/api/projectGrants/types";++import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../generic/Tabs";+import { cn } from "../../utils";++type WizardTab = "this-project" | "another-project";++type WizardState = {+ tab: WizardTab;+ step: "project" | "env" | "browse";+ selectedProjectGrant: TProjectGrantReceived | null;+ env: { slug: string; name: string } | null;+ secretPath: string;+};++type Props = {+ onSelect: (referenceContent: string) => void;+ isEnabled: boolean;+ onFocusItem: () => void;+};++const INITIAL_STATE: WizardState = {+ tab: "this-project",+ step: "env",+ selectedProjectGrant: null,+ env: null,+ secretPath: "/"+};++export const SecretReferenceWizard = ({ onSelect, isEnabled, onFocusItem }: Props) => {+ const { currentProject } = useProject();+ const projectId = currentProject?.id || "";++ const [state, setState] = useState<WizardState>(INITIAL_STATE);++ const { data: receivedGrants } = useListProjectGrantsReceived(projectId);++ const { data: selectedSourceProject } = useGetWorkspaceById(+ state.selectedProjectGrant?.sourceProjectId || ""+ );++ const browseProjectId =+ state.step === "browse" && state.selectedProjectGrant+ ? state.selectedProjectGrant.sourceProjectId+ : projectId;++ const { data: secrets } = useGetProjectSecrets({+ projectId: browseProjectId,+ environment: state.env?.slug || "",+ secretPath: state.secretPath,+ viewSecretValue: false,+ options: {+ enabled:+ isEnabled &&+ state.step === "browse" &&+ Boolean(browseProjectId) &&+ Boolean(state.env?.slug)+ }+ });++ const { data: folders } = useGetProjectFolders({+ projectId: browseProjectId,+ environment: state.env?.slug || "",+ path: state.secretPath,+ options: {+ enabled:+ isEnabled &&+ state.step === "browse" &&+ Boolean(browseProjectId) &&+ Boolean(state.env?.slug)+ }+ });++ const uniqueSourceProjects = useMemo(() => {+ if (!receivedGrants) return [];+ const seen = new Set<string>();+ return receivedGrants.filter((g) => {+ if (seen.has(g.sourceProjectId)) return false;+ seen.add(g.sourceProjectId);+ return true;+ });+ }, [receivedGrants]);++ const availableEnvs = useMemo(() => {+ if (state.tab === "this-project") {+ return (currentProject?.environments || []).map((e) => ({ name: e.name, slug: e.slug }));+ }+ if (!state.selectedProjectGrant) return [];+ const projectGrants =+ receivedGrants?.filter(+ (g) => g.sourceProjectId === state.selectedProjectGrant!.sourceProjectId+ ) || [];+ const seen = new Set<string>();+ return projectGrants+ .filter((g) => {+ if (seen.has(g.environmentSlug)) return false;+ seen.add(g.environmentSlug);+ return true;+ })+ .map((g) => ({ name: g.environmentName, slug: g.environmentSlug }));+ }, [state.tab, state.selectedProjectGrant, currentProject, receivedGrants]);++ const breadcrumbs = useMemo(() => {+ if (state.step !== "browse" || !state.env) return [];+ const pathParts = state.secretPath.split("/").filter(Boolean);+ return [state.env.name, ...pathParts];+ }, [state]);++ const handleTabChange = (tab: string) => {+ const newTab = tab as WizardTab;+ setState({+ ...INITIAL_STATE,+ tab: newTab,+ step: newTab === "another-project" ? "project" : "env"+ });+ };++ const handleSelectProject = (grant: TProjectGrantReceived) => {+ setState((prev) => ({ ...prev, step: "env", selectedProjectGrant: grant }));+ };++ const handleSelectEnv = (envSlug: string, envName: string) => {+ setState((prev) => ({+ ...prev,+ step: "browse",+ env: { slug: envSlug, name: envName },+ secretPath: "/"+ }));+ };++ const handleSelectFolder = (folderName: string) => {+ setState((prev) => {+ const currentPath = prev.secretPath;+ const newPath =+ currentPath === "/" ? `/${folderName}/` : `${currentPath}${folderName}/`;+ return { ...prev, secretPath: newPath };+ });+ };++ const handleSelectSecret = (secretKey: string) => {+ if (!state.env) return;+ const pathParts = state.secretPath.split("/").filter(Boolean);+ const segments = [state.env.slug, ...pathParts, secretKey];++ let reference: string;+ if (state.selectedProjectGrant && selectedSourceProject?.slug) {+ reference = `@${selectedSourceProject.slug}.${segments.join(".")}`;+ } else {+ reference = segments.join(".");+ }++ onSelect(reference);+ };++ const handleBreadcrumbClick = (index: number) => {+ if (index === -1) {+ setState((prev) => ({+ ...prev,+ step: "env",+ env: null,+ secretPath: "/"+ }));+ return;+ }+ const pathParts = state.secretPath.split("/").filter(Boolean);+ const newPath = "/" + pathParts.slice(0, index).join("/") + (index > 0 ? "/" : "");+ setState((prev) => ({ ...prev, secretPath: newPath }));+ };++ const renderProjectStep = () => (+ <div className="flex flex-col">+ {uniqueSourceProjects.length === 0 ? (+ <div className="flex flex-col items-center justify-center py-8 text-sm text-muted">+ No projects have shared secrets with you+ </div>+ ) : (+ <>+ <div className="px-2 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted">+ Projects that shared with you+ </div>+ {uniqueSourceProjects.map((grant) => (+ <button+ key={grant.sourceProjectId}+ type="button"+ aria-label="suggestion-item"+ onClick={() => {+ onFocusItem();+ handleSelectProject(grant);+ }}+ className="flex w-full cursor-pointer items-center justify-between px-2 py-2 text-left text-sm transition-colors hover:bg-foreground/10"+ >+ <div className="flex items-center gap-2">+ <div className="flex size-6 shrink-0 items-center justify-center rounded bg-project/20 text-xs font-semibold text-project">+ {grant.sourceProjectName[0]?.toUpperCase()}+ </div>+ <span className="truncate">{grant.sourceProjectName}</span>+ </div>+ <ChevronRightIcon className="size-3.5 shrink-0 text-muted" />+ </button>+ ))}+ </>+ )}+ </div>+ );++ const renderEnvStep = () => (+ <div className="flex flex-col">+ {state.selectedProjectGrant && (+ <button+ type="button"+ aria-label="suggestion-item"+ onClick={() => {+ onFocusItem();+ setState((prev) => ({ ...prev, step: "project", env: null }));+ }}+ className="flex items-center gap-1.5 border-b border-border px-2 py-1.5 text-xs text-muted transition-colors hover:text-foreground"+ >+ <ArrowLeftIcon className="size-3 shrink-0" />+ <span className="truncate">{state.selectedProjectGrant.sourceProjectName}</span>+ </button>+ )}+ <div className="px-2 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted">+ Environments+ </div>+ {availableEnvs.length === 0 ? (+ <div className="flex items-center justify-center py-6 text-sm text-muted">+ No environments available+ </div>+ ) : (+ availableEnvs.map((env) => (+ <button+ key={env.slug}+ type="button"+ aria-label="suggestion-item"+ onClick={() => {+ onFocusItem();+ handleSelectEnv(env.slug, env.name);+ }}+ className="flex w-full cursor-pointer items-center justify-between px-2 py-2 text-left text-sm transition-colors hover:bg-foreground/10"+ >+ <div className="flex items-center gap-2">+ <LayersIcon className="size-4 text-success" />+ <span>{env.name}</span>+ </div>+ <ChevronRightIcon className="size-3.5 shrink-0 text-muted" />+ </button>+ ))+ )}+ </div>+ );++ const renderBrowseStep = () => {+ const folderList = folders || [];+ const secretList = secrets || [];+ const isEmpty = folderList.length === 0 && secretList.length === 0;++ return (+ <div className="flex flex-col">+ <div className="flex min-w-0 items-center gap-0.5 overflow-x-auto border-b border-border px-2 py-1.5 text-xs text-muted no-scrollbar">+ <button+ type="button"+ aria-label="suggestion-item"+ onClick={() => {+ onFocusItem();+ handleBreadcrumbClick(-1);+ }}+ className="shrink-0 transition-colors hover:text-foreground"+ >+ Envs+ </button>+ {breadcrumbs.map((crumb, i) => (+ <span key={`crumb-${i + 1}`} className="flex shrink-0 items-center gap-0.5">+ <ChevronRightIcon className="size-3" />+ <button+ type="button"+ aria-label="suggestion-item"+ onClick={() => {+ onFocusItem();+ handleBreadcrumbClick(i);+ }}+ className={cn(+ "transition-colors hover:text-foreground",+ i === breadcrumbs.length - 1 && "font-medium text-foreground"+ )}+ >+ {crumb}+ </button>+ </span>+ ))}+ </div>++ {isEmpty && (+ <div className="flex items-center justify-center py-6 text-sm text-muted">+ No secrets found+ </div>+ )}++ {folderList.map((folder) => (+ <button+ key={folder.id}+ type="button"+ aria-label="suggestion-item"+ onClick={() => {+ onFocusItem();+ handleSelectFolder(folder.name);+ }}+ className="flex w-full cursor-pointer items-center justify-between px-2 py-2 text-left text-sm transition-colors hover:bg-foreground/10"+ >+ <div className="flex items-center gap-2">+ <FolderIcon className="size-4 text-warning" />+ <span>{folder.name}</span>+ </div>+ <ChevronRightIcon className="size-3.5 shrink-0 text-muted" />+ </button>+ ))}++ {folderList.length > 0 && secretList.length > 0 && (+ <div className="my-1 border-t border-border" />+ )}++ {secretList.length > 0 && (+ <div className="px-2 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted">+ Secrets in this {state.tab === "another-project" ? "project" : "environment"}+ </div>+ )}++ {secretList.map((secret) => (+ <button+ key={secret.id}+ type="button"+ aria-label="suggestion-item"+ onClick={() => {+ onFocusItem();+ handleSelectSecret(secret.key);+ }}+ className="group flex w-full cursor-pointer items-center justify-between px-2 py-2 text-left text-sm transition-colors hover:bg-foreground/10"+ >+ <div className="flex items-center gap-2">+ <KeyRoundIcon className="size-4 text-muted" />+ <span>{secret.key}</span>+ </div>+ <span className="text-xs text-muted opacity-0 transition-opacity group-hover:opacity-100">+ insert+ </span>+ </button>+ ))}+ </div>+ );+ };++ const renderStepContent = () => {+ switch (state.step) {+ case "project":+ return renderProjectStep();+ case "env":+ return renderEnvStep();+ case "browse":+ return renderBrowseStep();+ default:+ return null;+ }+ };++ return (+ <Tabs value={state.tab} onValueChange={handleTabChange} className="gap-0">+ <TabsList+ className="h-auto w-full rounded-none rounded-t-md border-0 border-b border-border bg-transparent p-0"+ >+ <TabsTrigger+ value="this-project"+ className="flex-1 rounded-none rounded-tl-md border-0 py-2 text-xs"+ >+ This project+ </TabsTrigger>+ <TabsTrigger+ value="another-project"+ className="flex-1 rounded-none rounded-tr-md border-0 py-2 text-xs"+ >+ Another project @+ </TabsTrigger>+ </TabsList>+ <TabsContent value="this-project" className="mt-0">+ {state.tab === "this-project" && renderStepContent()}+ </TabsContent>+ <TabsContent value="another-project" className="mt-0">+ {state.tab === "another-project" && renderStepContent()}+ </TabsContent>+ </Tabs>+ );+};