mirror of
https://github.com/langgenius/dify.git
synced 2026-02-13 07:01:23 -05:00
Simpler approach: disable the view picker toggle when preview is running, preventing users from switching views during active runs. This replaces the previous mounted ref guard approach (commitsa0188bd9b5,b7f1eb9b7b,8332f0de2b) which added complexity to handle post-unmount operations. Disabling the toggle is more direct and follows KISS principle. Changes: - Add disabled prop to ViewPicker based on isResponding state - Revert mounted ref guards in use-chat-flow-control.ts - Revert isMountedRef parameter in use-nodes/edges-interactions-without-sync.ts - Revert defensive type check in markdown-utils.ts (no longer needed)
28 lines
649 B
TypeScript
28 lines
649 B
TypeScript
import { produce } from 'immer'
|
|
import { useCallback } from 'react'
|
|
import { useStoreApi } from 'reactflow'
|
|
|
|
export const useEdgesInteractionsWithoutSync = () => {
|
|
const store = useStoreApi()
|
|
|
|
const handleEdgeCancelRunningStatus = useCallback(() => {
|
|
const {
|
|
edges,
|
|
setEdges,
|
|
} = store.getState()
|
|
|
|
const newEdges = produce(edges, (draft) => {
|
|
draft.forEach((edge) => {
|
|
edge.data._sourceRunningStatus = undefined
|
|
edge.data._targetRunningStatus = undefined
|
|
edge.data._waitingRun = false
|
|
})
|
|
})
|
|
setEdges(newEdges)
|
|
}, [store])
|
|
|
|
return {
|
|
handleEdgeCancelRunningStatus,
|
|
}
|
|
}
|