'use client' import * as React from 'react' import { useTranslation } from 'react-i18next' import Loading from '@/app/components/base/loading' import { useStore } from '@/app/components/workflow/store' import { useSandboxFileDownloadUrl } from '@/service/use-sandbox-file' import { getArtifactPath } from './constants' import { getFileExtension } from './utils/file-utils' import ReadOnlyFilePreview from './viewer/read-only-file-preview' const ArtifactContentPanel = () => { const { t } = useTranslation('workflow') const activeTabId = useStore(s => s.activeTabId) const appId = useStore(s => s.appId) const path = activeTabId ? getArtifactPath(activeTabId) : undefined const fileName = path?.split('/').pop() ?? '' const extension = getFileExtension(fileName) const { data: ticket, isLoading } = useSandboxFileDownloadUrl(appId, path) if (isLoading) { return (
) } if (!ticket?.download_url) { return (
{t('skillSidebar.loadError')}
) } return (
) } export default React.memo(ArtifactContentPanel)