diff --git a/web/app/components/workflow/skill/hooks/use-fetch-text-content.ts b/web/app/components/workflow/skill/hooks/use-fetch-text-content.ts index 9b950fd1eb..156e8a69c5 100644 --- a/web/app/components/workflow/skill/hooks/use-fetch-text-content.ts +++ b/web/app/components/workflow/skill/hooks/use-fetch-text-content.ts @@ -1,10 +1,11 @@ -import { useQuery } from '@tanstack/react-query' +import { skipToken, useQuery } from '@tanstack/react-query' export function useFetchTextContent(downloadUrl: string | undefined) { return useQuery({ queryKey: ['fileTextContent', downloadUrl], - queryFn: () => fetch(downloadUrl!).then(r => r.text()), - enabled: !!downloadUrl, + queryFn: downloadUrl + ? () => fetch(downloadUrl).then(r => r.text()) + : skipToken, staleTime: Infinity, }) } diff --git a/web/service/use-sandbox-file.ts b/web/service/use-sandbox-file.ts index 51773879bf..4a1fcbb4cd 100644 --- a/web/service/use-sandbox-file.ts +++ b/web/service/use-sandbox-file.ts @@ -95,11 +95,14 @@ export function useSandboxFilesTree( appId: string | undefined, options?: UseSandboxFilesTreeOptions, ) { + const input = appId && (options?.enabled ?? true) + ? { params: { appId }, query: { recursive: true } } + : skipToken + const { data, isLoading, error, refetch } = useQuery({ ...consoleQuery.sandboxFile.listFiles.queryOptions({ - input: { params: { appId: appId! }, query: { recursive: true } }, + input, }), - enabled: !!appId && (options?.enabled ?? true), refetchInterval: options?.refetchInterval, })