feat: add feature provider to rag pipeline to reduce problem

This commit is contained in:
Joel 2026-01-30 14:15:33 +08:00
parent e9c2279b80
commit 0711af20f2
2 changed files with 22 additions and 5 deletions

View File

@ -64,6 +64,12 @@ vi.mock('@/app/components/workflow/context', () => ({
),
}))
vi.mock('@/app/components/workflow/store', () => ({
useStore: (selector: (state: { fileUploadConfig?: Record<string, unknown> }) => unknown) => {
return selector({ fileUploadConfig: undefined })
},
}))
// Type assertions for mocked functions
const mockUseDatasetDetailContextWithSelector = vi.mocked(useDatasetDetailContextWithSelector)
const mockUsePipelineInit = vi.mocked(usePipelineInit)

View File

@ -1,5 +1,7 @@
import type { Features as FeaturesData } from '@/app/components/base/features/types'
import type { InjectWorkflowStoreSliceFn } from '@/app/components/workflow/store'
import { useMemo } from 'react'
import { FeaturesProvider } from '@/app/components/base/features'
import Loading from '@/app/components/base/loading'
import WorkflowWithDefaultContext from '@/app/components/workflow'
import {
@ -34,6 +36,13 @@ const RagPipeline = () => {
return []
}, [data])
const initialFeatures: FeaturesData = useMemo(() => {
const features = data?.features || {}
return {
sandbox: features.sandbox || { enabled: false },
}
}, [data?.features])
if (!data || isLoading) {
return (
<div className="relative flex h-full w-full items-center justify-center">
@ -51,11 +60,13 @@ const RagPipeline = () => {
edges={edgesData}
nodes={processedNodes}
>
<RagPipelineMain
edges={edgesData}
nodes={processedNodes}
viewport={viewport}
/>
<FeaturesProvider features={initialFeatures}>
<RagPipelineMain
edges={edgesData}
nodes={processedNodes}
viewport={viewport}
/>
</FeaturesProvider>
</WorkflowWithDefaultContext>
)
}