chore(web): pre-align HITL frontend from build/feat/hitl

This commit is contained in:
yyh
2026-02-09 15:34:15 +08:00
parent b289e6a2b6
commit ca243d7efc
261 changed files with 14122 additions and 1328 deletions

View File

@ -295,6 +295,8 @@ vi.mock('@/utils/var', () => ({
// Mock provider context
vi.mock('@/context/provider-context', () => ({
useProviderContext: () => createMockProviderContextValue(),
useProviderContextSelector: <T,>(selector: (state: ReturnType<typeof createMockProviderContextValue>) => T): T =>
selector(createMockProviderContextValue()),
}))
// Mock WorkflowWithInnerContext

View File

@ -141,6 +141,8 @@ vi.mock('@/context/modal-context', () => ({
let mockProviderContextValue = createMockProviderContextValue()
vi.mock('@/context/provider-context', () => ({
useProviderContext: () => mockProviderContextValue,
useProviderContextSelector: <T,>(selector: (s: ReturnType<typeof createMockProviderContextValue>) => T): T =>
selector(mockProviderContextValue),
}))
// Mock event emitter context

View File

@ -131,6 +131,8 @@ vi.mock('@/context/provider-context', () => ({
useProviderContext: () => ({
isAllowPublishAsCustomKnowledgePipelineTemplate: mockIsAllowPublishAsCustomKnowledgePipelineTemplate(),
}),
useProviderContextSelector: <T,>(selector: (s: { isAllowPublishAsCustomKnowledgePipelineTemplate: boolean }) => T): T =>
selector({ isAllowPublishAsCustomKnowledgePipelineTemplate: mockIsAllowPublishAsCustomKnowledgePipelineTemplate() }),
}))
// Mock toast context

View File

@ -37,7 +37,7 @@ import { getKeyboardKeyCodeBySystem } from '@/app/components/workflow/utils'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
import { useDocLink } from '@/context/i18n'
import { useModalContextSelector } from '@/context/modal-context'
import { useProviderContext } from '@/context/provider-context'
import { useProviderContextSelector } from '@/context/provider-context'
import { useDatasetApiAccessUrl } from '@/hooks/use-api-access-url'
import { useFormatTimeFromNow } from '@/hooks/use-format-time-from-now'
import { useInvalidDatasetList } from '@/service/knowledge/use-dataset'
@ -68,7 +68,7 @@ const Popup = () => {
const { mutateAsync: publishWorkflow } = usePublishWorkflow()
const { notify } = useToastContext()
const workflowStore = useWorkflowStore()
const { isAllowPublishAsCustomKnowledgePipelineTemplate } = useProviderContext()
const isAllowPublishAsCustomKnowledgePipelineTemplate = useProviderContextSelector(s => s.isAllowPublishAsCustomKnowledgePipelineTemplate)
const setShowPricingModal = useModalContextSelector(s => s.setShowPricingModal)
const apiReferenceUrl = useDatasetApiAccessUrl()
@ -152,7 +152,7 @@ const Popup = () => {
if (confirmVisible)
hideConfirm()
}
}, [handleCheckBeforePublish, publishWorkflow, pipelineId, notify, t, workflowStore, mutateDatasetRes, invalidPublishedPipelineInfo, showConfirm, publishedAt, confirmVisible, hidePublishing, showPublishing, hideConfirm, publishing])
}, [publishing, handleCheckBeforePublish, publishedAt, confirmVisible, showPublishing, publishWorkflow, pipelineId, datasetId, showConfirm, notify, t, workflowStore, mutateDatasetRes, invalidPublishedPipelineInfo, invalidDatasetList, hidePublishing, hideConfirm])
useKeyPress(`${getKeyboardKeyCodeBySystem('ctrl')}.shift.p`, (e) => {
e.preventDefault()
@ -207,15 +207,7 @@ const Popup = () => {
hidePublishingAsCustomizedPipeline()
hidePublishAsKnowledgePipelineModal()
}
}, [
pipelineId,
publishAsCustomizedPipeline,
showPublishingAsCustomizedPipeline,
hidePublishingAsCustomizedPipeline,
hidePublishAsKnowledgePipelineModal,
notify,
t,
])
}, [showPublishingAsCustomizedPipeline, publishAsCustomizedPipeline, pipelineId, notify, t, invalidCustomizedTemplateList, hidePublishingAsCustomizedPipeline, hidePublishAsKnowledgePipelineModal])
const handleClickPublishAsKnowledgePipeline = useCallback(() => {
if (!isAllowPublishAsCustomKnowledgePipelineTemplate)

View File

@ -70,11 +70,15 @@ vi.mock('@/context/i18n', () => ({
}))
// Mock workflow constants
vi.mock('@/app/components/workflow/constants', () => ({
DSL_EXPORT_CHECK: 'DSL_EXPORT_CHECK',
WORKFLOW_DATA_UPDATE: 'WORKFLOW_DATA_UPDATE',
START_INITIAL_POSITION: { x: 100, y: 100 },
}))
vi.mock('@/app/components/workflow/constants', async (importOriginal) => {
const actual = await importOriginal() as Record<string, unknown>
return {
...actual,
DSL_EXPORT_CHECK: 'DSL_EXPORT_CHECK',
WORKFLOW_DATA_UPDATE: 'WORKFLOW_DATA_UPDATE',
START_INITIAL_POSITION: { x: 100, y: 100 },
}
})
// Mock workflow constants/node
vi.mock('@/app/components/workflow/constants/node', () => ({

View File

@ -14,7 +14,8 @@ export const useAvailableNodesMetaData = () => {
const docLink = useDocLink()
const mergedNodesMetaData = useMemo(() => [
...WORKFLOW_COMMON_NODES,
// RAG pipeline doesn't support human-input node temporarily
...WORKFLOW_COMMON_NODES.filter(node => node.metaData.type !== BlockEnum.HumanInput),
{
...dataSourceDefault,
defaultValue: {

View File

@ -20,5 +20,5 @@ export const useConfigsMap = () => {
fileUploadConfig,
},
}
}, [pipelineId])
}, [fileUploadConfig, pipelineId])
}

View File

@ -1,7 +1,7 @@
import type { IOtherOptions } from '@/service/base'
import type { VersionHistory } from '@/types/workflow'
import { produce } from 'immer'
import { useCallback } from 'react'
import { useCallback, useRef } from 'react'
import {
useReactFlow,
useStoreApi,
@ -42,6 +42,8 @@ export const usePipelineRun = () => {
handleWorkflowTextReplace,
} = useWorkflowRunEvent()
const abortControllerRef = useRef<AbortController | null>(null)
const handleBackupDraft = useCallback(() => {
const {
getNodes,
@ -154,12 +156,18 @@ export const usePipelineRun = () => {
resultText: '',
})
abortControllerRef.current?.abort()
abortControllerRef.current = null
ssePost(
url,
{
body: params,
},
{
getAbortController: (controller: AbortController) => {
abortControllerRef.current = controller
},
onWorkflowStarted: (params) => {
handleWorkflowStarted(params)
@ -267,31 +275,17 @@ export const usePipelineRun = () => {
...restCallback,
},
)
}, [
store,
workflowStore,
doSyncWorkflowDraft,
handleWorkflowStarted,
handleWorkflowFinished,
handleWorkflowFailed,
handleWorkflowNodeStarted,
handleWorkflowNodeFinished,
handleWorkflowNodeIterationStarted,
handleWorkflowNodeIterationNext,
handleWorkflowNodeIterationFinished,
handleWorkflowNodeLoopStarted,
handleWorkflowNodeLoopNext,
handleWorkflowNodeLoopFinished,
handleWorkflowNodeRetry,
handleWorkflowTextChunk,
handleWorkflowTextReplace,
handleWorkflowAgentLog,
])
}, [store, doSyncWorkflowDraft, workflowStore, handleWorkflowStarted, handleWorkflowFinished, fetchInspectVars, invalidAllLastRun, handleWorkflowFailed, handleWorkflowNodeStarted, handleWorkflowNodeFinished, handleWorkflowNodeIterationStarted, handleWorkflowNodeIterationNext, handleWorkflowNodeIterationFinished, handleWorkflowNodeLoopStarted, handleWorkflowNodeLoopNext, handleWorkflowNodeLoopFinished, handleWorkflowNodeRetry, handleWorkflowAgentLog, handleWorkflowTextChunk, handleWorkflowTextReplace])
const handleStopRun = useCallback((taskId: string) => {
const { pipelineId } = workflowStore.getState()
stopWorkflowRun(`/rag/pipelines/${pipelineId}/workflow-runs/tasks/${taskId}/stop`)
if (abortControllerRef.current)
abortControllerRef.current.abort()
abortControllerRef.current = null
}, [workflowStore])
const handleRestoreFromPublishedWorkflow = useCallback((publishedWorkflow: VersionHistory) => {