🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(web): Add hint about secrets when copying .env in api key settings (#13001)
Ben Bachemb1ac9304628f
diff --git a/web/src/components/ui/CodeJsonViewer.tsx b/web/src/components/ui/CodeJsonViewer.tsxindex 04c741fd15..303430d3fd 100644--- a/web/src/components/ui/CodeJsonViewer.tsx+++ b/web/src/components/ui/CodeJsonViewer.tsx@@ -1,4 +1,4 @@-import { useMemo, useState } from "react";+import { useMemo, useRef, useState } from "react";import { Button } from "@/src/components/ui/button";import {Check,@@ -217,10 +217,18 @@ export function CodeView(props: {defaultCollapsed?: boolean;title?: string;scrollable?: boolean;+ copiedToClipboardMessage?: string;}) {+ const { copiedToClipboardMessage } = props;+const [isCopied, setIsCopied] = useState(false);const [isCollapsed, setCollapsed] = useState(props.defaultCollapsed);+ const copySuccessStateDuration = copiedToClipboardMessage ? 3_000 : 1_000;+ const copySuccessTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(+ null,+ );+const handleCopy = (event: React.MouseEvent<HTMLButtonElement>) => {event.preventDefault();setIsCopied(true);@@ -230,7 +238,12 @@ export function CodeView(props: {? props.content: (props.content?.join("\n") ?? ""));void copyTextToClipboard(content);- setTimeout(() => setIsCopied(false), 1000);+ if (copySuccessTimeoutRef.current)+ clearTimeout(copySuccessTimeoutRef.current);+ copySuccessTimeoutRef.current = setTimeout(+ () => setIsCopied(false),+ copySuccessStateDuration,+ );// Keep focus on the copy button to prevent focus shiftingevent.currentTarget.focus();@@ -238,6 +251,19 @@ export function CodeView(props: {const handleShowAll = () => setCollapsed(!isCollapsed);+ const CopySuccessIcon = useMemo(() => {+ return (+ <div className="animate-appear relative h-3">+ <Check className="h-3 w-3" />+ {copiedToClipboardMessage && (+ <div className="text-secondary-foreground absolute top-0 right-0 mr-6 h-full max-w-[60vw] transform truncate overflow-hidden text-right text-sm leading-none whitespace-nowrap">+ {copiedToClipboardMessage}+ </div>+ )}+ </div>+ );+ }, [copiedToClipboardMessage]);+return (<divclassName={cn(@@ -256,11 +282,7 @@ export function CodeView(props: {onClick={handleCopy}className="">- {isCopied ? (- <Check className="h-3 w-3" />- ) : (- <Copy className="h-3 w-3" />- )}+ {isCopied ? CopySuccessIcon : <Copy className="h-3 w-3" />}</Button></div>) : undefined}@@ -278,11 +300,7 @@ export function CodeView(props: {onClick={handleCopy}className="absolute top-2 right-2 z-10">- {isCopied ? (- <Check className="h-3 w-3" />- ) : (- <Copy className="h-3 w-3" />- )}+ {isCopied ? CopySuccessIcon : <Copy className="h-3 w-3" />}</Button>)}<codediff --git a/web/src/features/public-api/components/ApiKeyList.tsx b/web/src/features/public-api/components/ApiKeyList.tsxindex 1f1dd728c6..aed93f63c5 100644--- a/web/src/features/public-api/components/ApiKeyList.tsx+++ b/web/src/features/public-api/components/ApiKeyList.tsx@@ -95,7 +95,11 @@ export function ApiKeyList(props: { entityId: string; scope: ApiKeyScope }) {}}actionButtons={<CreateApiKeyButton entityId={entityId} scope={scope} />}/>- <CodeView content={envCode} title=".env" />+ <CodeView+ content={envCode}+ title=".env"+ copiedToClipboardMessage="Secrets are not included, create a new key to copy them."+ /><Card className="mb-4 overflow-hidden"><Table><TableHeader>diff --git a/web/src/styles/globals.css b/web/src/styles/globals.cssindex e8ccfd4730..2f2198cf7e 100644--- a/web/src/styles/globals.css+++ b/web/src/styles/globals.css@@ -77,6 +77,7 @@--animate-rainbow: rainbow var(--speed, 2s) infinite linear;--animate-accordion-down: accordion-down 0.2s ease-out;--animate-accordion-up: accordion-up 0.2s ease-out;+ --animate-appear: appear 0.2s ease-out forwards;@keyframes rainbow {0% {@@ -107,6 +108,16 @@height: 0;}}++ @keyframes appear {+ from {+ opacity: 0;+ }++ to {+ opacity: 1;+ }+ }}/*