mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 01:25:53 +08:00
fix: use last run call api timing
This commit is contained in:
parent
bbfdab53dd
commit
c1bc464e9e
@ -148,6 +148,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
||||
getInputVars,
|
||||
toVarInputs,
|
||||
tabType,
|
||||
isRunAfterSingleRun,
|
||||
setTabType,
|
||||
singleRunParams,
|
||||
nodeInfo,
|
||||
@ -326,6 +327,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
||||
nodeId={id}
|
||||
canSingleRun={isSupportSingleRun}
|
||||
runningStatus={runningStatus}
|
||||
isRunAfterSingleRun={isRunAfterSingleRun}
|
||||
onSingleRunClicked={handleSingleRun}
|
||||
nodeInfo={nodeInfo}
|
||||
singleRunResult={runResult!}
|
||||
|
@ -13,6 +13,7 @@ type Props = {
|
||||
appId: string
|
||||
nodeId: string
|
||||
canSingleRun: boolean
|
||||
isRunAfterSingleRun: boolean
|
||||
nodeInfo?: NodeTracing
|
||||
runningStatus?: NodeRunningStatus
|
||||
onSingleRunClicked: () => void
|
||||
@ -23,6 +24,7 @@ const LastRun: FC<Props> = ({
|
||||
appId,
|
||||
nodeId,
|
||||
canSingleRun,
|
||||
isRunAfterSingleRun,
|
||||
nodeInfo,
|
||||
runningStatus: oneStepRunRunningStatus,
|
||||
onSingleRunClicked,
|
||||
@ -30,10 +32,11 @@ const LastRun: FC<Props> = ({
|
||||
...otherResultPanelProps
|
||||
}) => {
|
||||
const isRunning = oneStepRunRunningStatus === NodeRunningStatus.Running
|
||||
const isOneStepRunFailed = oneStepRunRunningStatus === NodeRunningStatus.Failed
|
||||
const { data: lastRunResult, isFetching, error } = useLastRun(appId, nodeId, !isOneStepRunFailed)
|
||||
const isOneStepRunSucceed = oneStepRunRunningStatus === NodeRunningStatus.Succeeded
|
||||
const canRunLastRun = !isRunAfterSingleRun || isOneStepRunSucceed
|
||||
const { data: lastRunResult, isFetching, error } = useLastRun(appId, nodeId, canRunLastRun)
|
||||
const noLastRun = (error as any)?.status === 404
|
||||
const runResult = (isOneStepRunFailed ? singleRunResult : lastRunResult) || {}
|
||||
const runResult = (canRunLastRun ? lastRunResult : singleRunResult) || {}
|
||||
|
||||
if (isFetching) {
|
||||
return (
|
||||
|
@ -154,13 +154,16 @@ const useLastRun = <T>({
|
||||
}
|
||||
|
||||
const [tabType, setTabType] = useState<TabType>(TabType.settings)
|
||||
const [isRunAfterSingleRun, setIsRunAfterSingleRun] = useState(false)
|
||||
const handleRunWithParams = async (data: Record<string, any>) => {
|
||||
setIsRunAfterSingleRun(true)
|
||||
setTabType(TabType.lastRun)
|
||||
callRunApi(data)
|
||||
hideSingleRun()
|
||||
}
|
||||
|
||||
const handleTabClicked = useCallback((type: TabType) => {
|
||||
setIsRunAfterSingleRun(false)
|
||||
setTabType(type)
|
||||
}, [])
|
||||
|
||||
@ -219,6 +222,7 @@ const useLastRun = <T>({
|
||||
// no need to input params
|
||||
if (isAllVarsHasValue(singleRunParams?.getDependentVars?.())) {
|
||||
callRunApi({})
|
||||
setIsRunAfterSingleRun(true)
|
||||
setTabType(TabType.lastRun)
|
||||
}
|
||||
else {
|
||||
@ -229,6 +233,7 @@ const useLastRun = <T>({
|
||||
return {
|
||||
...oneStepRunRes,
|
||||
tabType,
|
||||
isRunAfterSingleRun,
|
||||
setTabType: handleTabClicked,
|
||||
singleRunParams,
|
||||
nodeInfo,
|
||||
|
Loading…
x
Reference in New Issue
Block a user