diff --git a/web/app/components/workflow/skill/artifact-content-panel.tsx b/web/app/components/workflow/skill/artifact-content-panel.tsx index c3badc89a0..16e8bd1770 100644 --- a/web/app/components/workflow/skill/artifact-content-panel.tsx +++ b/web/app/components/workflow/skill/artifact-content-panel.tsx @@ -4,7 +4,6 @@ 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 { useAppContext } from '@/context/app-context' import { useSandboxFileDownloadUrl } from '@/service/use-sandbox-file' import { getArtifactPath } from './constants' import { getFileExtension } from './utils/file-utils' @@ -13,14 +12,13 @@ import ReadOnlyFilePreview from './viewer/read-only-file-preview' const ArtifactContentPanel = () => { const { t } = useTranslation('workflow') const activeTabId = useStore(s => s.activeTabId) - const { userProfile } = useAppContext() - const sandboxId = userProfile?.id + 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(sandboxId, path) + const { data: ticket, isLoading } = useSandboxFileDownloadUrl(appId, path) if (isLoading) { return ( diff --git a/web/app/components/workflow/skill/file-tree/artifacts-section.tsx b/web/app/components/workflow/skill/file-tree/artifacts-section.tsx index bd1f651d3f..a9a93f1013 100644 --- a/web/app/components/workflow/skill/file-tree/artifacts-section.tsx +++ b/web/app/components/workflow/skill/file-tree/artifacts-section.tsx @@ -7,7 +7,6 @@ import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import FolderSpark from '@/app/components/base/icons/src/vender/workflow/FolderSpark' import { useStore, useWorkflowStore } from '@/app/components/workflow/store' -import { useAppContext } from '@/context/app-context' import { useDownloadSandboxFile, useSandboxFilesTree } from '@/service/use-sandbox-file' import { cn } from '@/utils/classnames' import { downloadUrl } from '@/utils/download' @@ -19,14 +18,13 @@ type ArtifactsSectionProps = { const ArtifactsSection = ({ className }: ArtifactsSectionProps) => { const { t } = useTranslation('workflow') - const { userProfile } = useAppContext() - const sandboxId = userProfile?.id + const appId = useStore(s => s.appId) const [isExpanded, setIsExpanded] = useState(false) - const { data: treeData, hasFiles, isLoading } = useSandboxFilesTree(sandboxId) + const { data: treeData, hasFiles, isLoading } = useSandboxFilesTree(appId) - const { mutateAsync: fetchDownloadUrl, isPending: isDownloading } = useDownloadSandboxFile(sandboxId) + const { mutateAsync: fetchDownloadUrl, isPending: isDownloading } = useDownloadSandboxFile(appId) const storeApi = useWorkflowStore() const selectedArtifactPath = useStore(s => s.selectedArtifactPath) diff --git a/web/app/components/workflow/variable-inspect/artifacts-tab.tsx b/web/app/components/workflow/variable-inspect/artifacts-tab.tsx index 9f92b7b421..ed71171b5f 100644 --- a/web/app/components/workflow/variable-inspect/artifacts-tab.tsx +++ b/web/app/components/workflow/variable-inspect/artifacts-tab.tsx @@ -12,11 +12,11 @@ import { FileDownload01 } from '@/app/components/base/icons/src/vender/line/file import Loading from '@/app/components/base/loading' import ArtifactsTree from '@/app/components/workflow/skill/file-tree/artifacts-tree' import ReadOnlyFilePreview from '@/app/components/workflow/skill/viewer/read-only-file-preview' -import { useAppContext } from '@/context/app-context' import { useDocLink } from '@/context/i18n' import { useDownloadSandboxFile, useSandboxFileDownloadUrl, useSandboxFilesTree } from '@/service/use-sandbox-file' import { cn } from '@/utils/classnames' import { downloadUrl } from '@/utils/download' +import { useStore } from '../store' import InspectLayout from './inspect-layout' import SplitPanel from './split-panel' @@ -55,16 +55,15 @@ const formatFileSize = (bytes: number | null): string => { const ArtifactsTab = (headerProps: InspectHeaderProps) => { const { t } = useTranslation('workflow') - const { userProfile } = useAppContext() - const sandboxId = userProfile?.id + const appId = useStore(s => s.appId) - const { data: treeData, hasFiles, isLoading } = useSandboxFilesTree(sandboxId, { - enabled: !!sandboxId, + const { data: treeData, hasFiles, isLoading } = useSandboxFilesTree(appId, { + enabled: !!appId, }) - const { mutateAsync: fetchDownloadUrl, isPending: isDownloading } = useDownloadSandboxFile(sandboxId) + const { mutateAsync: fetchDownloadUrl, isPending: isDownloading } = useDownloadSandboxFile(appId) const [selectedFile, setSelectedFile] = useState(null) const { data: downloadUrlData, isLoading: isDownloadUrlLoading } = useSandboxFileDownloadUrl( - sandboxId, + appId, selectedFile?.path, )