'use client' import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip' import { RiClipboardFill, RiClipboardLine, } from '@remixicon/react' import { useCallback } from 'react' import { useTranslation } from 'react-i18next' import ActionButton from '@/app/components/base/action-button' import { useClipboard } from '@/hooks/use-clipboard' import copyStyle from './style.module.css' type Props = { content: string className?: string } const prefixEmbedded = 'overview.appInfo.embedded' const CopyFeedback = ({ content }: Props) => { const { t } = useTranslation() // Rely on useClipboard's own timer to flip `copied` back to false so the // "Copied" tooltip stays visible long enough to be read, matching the // KeyValueItem pattern. Do NOT reset on mouse leave. const { copied, copy } = useClipboard({ timeout: 2000 }) const tooltipText = copied ? t(`${prefixEmbedded}.copied`, { ns: 'appOverview' }) : t(`${prefixEmbedded}.copy`, { ns: 'appOverview' }) /* v8 ignore next -- i18n test mock always returns a non-empty string; runtime fallback is defensive. -- @preserve */ const safeText = tooltipText || '' const handleCopy = useCallback(() => { copy(content) }, [copy, content]) return ( {copied && } {!copied && } )} /> {safeText} ) } export default CopyFeedback export const CopyFeedbackNew = ({ content, className }: Pick) => { const { t } = useTranslation() const { copied, copy } = useClipboard({ timeout: 2000 }) const tooltipText = copied ? t(`${prefixEmbedded}.copied`, { ns: 'appOverview' }) : t(`${prefixEmbedded}.copy`, { ns: 'appOverview' }) /* v8 ignore next -- i18n test mock always returns a non-empty string; runtime fallback is defensive. -- @preserve */ const safeText = tooltipText || '' const handleCopy = useCallback(() => { copy(content) }, [copy, content]) return ( )} /> {safeText} ) }