Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
import React from 'react';
import { InfoIcon } from 'lucide-react';
import type { CodeBarProps } from '~/common';
import useDownloadCode from '~/components/Messages/Content/useDownloadCode';
import DownloadButton from '~/components/Messages/Content/DownloadButton';
import useCopyCode from '~/components/Messages/Content/useCopyCode';
import CopyButton from '~/components/Messages/Content/CopyButton';
import RunCode from '~/components/Messages/Content/RunCode';
import cn from '~/utils/cn';
interface FloatingCodeBarProps extends CodeBarProps {
isVisible: boolean;
}
const FloatingCodeBar: React.FC<FloatingCodeBarProps> = React.memo(
({ lang, error, codeRef, blockIndex, plugin = null, allowExecution = true, isVisible }) => {
const { isCopied, buttonRef, handleCopy } = useCopyCode(codeRef);
const {
isDownloaded,
buttonRef: downloadButtonRef,
handleDownload,
} = useDownloadCode(codeRef, lang);
return (
<div
className={cn(
'text-text-secondary absolute inset-e-2 bottom-2 flex items-center gap-2 font-sans text-xs transition-opacity duration-150',
isVisible ? 'opacity-100' : 'pointer-events-none opacity-0',
)}
>
{plugin === true ? (
<InfoIcon className="text-text-secondary flex h-4 w-4 gap-2" />
) : (
<>
{allowExecution === true && (
<RunCode lang={lang} codeRef={codeRef} blockIndex={blockIndex} iconOnly />
)}
{error !== true && (
<DownloadButton
ref={downloadButtonRef}
isDownloaded={isDownloaded}
iconOnly
tabIndex={isVisible ? 0 : -1}
onClick={handleDownload}
/>
)}
<CopyButton
ref={buttonRef}
isCopied={isCopied}
iconOnly
tabIndex={isVisible ? 0 : -1}
onClick={handleCopy}
/>
</>
)}
</div>
);
},
);
export default FloatingCodeBar;