'use client' import type { FC } from 'react' import type { SandboxFileTreeNode } from '@/types/sandbox-file' import { RiArrowDownSLine, RiArrowRightSLine, RiLoader2Line } from '@remixicon/react' import * as React from 'react' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import FolderSpark from '@/app/components/base/icons/src/vender/workflow/FolderSpark' import { useAppContext } from '@/context/app-context' import { useDownloadSandboxFile, useSandboxFilesTree } from '@/service/use-sandbox-file' import { cn } from '@/utils/classnames' import ArtifactsTree from './artifacts-tree' type ArtifactsSectionProps = { className?: string } const ArtifactsSection: FC = ({ className }) => { const { t } = useTranslation('workflow') const { userProfile } = useAppContext() const sandboxId = userProfile?.id const [isExpanded, setIsExpanded] = useState(false) const { data: treeData, hasFiles, isLoading } = useSandboxFilesTree(sandboxId) const downloadMutation = useDownloadSandboxFile(sandboxId) const handleToggle = useCallback(() => { setIsExpanded(prev => !prev) }, []) const handleDownload = useCallback(async (node: SandboxFileTreeNode) => { try { const ticket = await downloadMutation.mutateAsync(node.path) window.open(ticket.download_url, '_blank') } catch (error) { console.error('Download failed:', error) } }, [downloadMutation]) const showBlueDot = !isExpanded && hasFiles const showSpinner = isLoading return (
{isExpanded && !isLoading && (
{hasFiles ? ( ) : (

{t('skillSidebar.artifacts.emptyState')}

)}
)}
) } export default React.memo(ArtifactsSection)