fix(workflow): reinitialize mounted ref on effect setup for StrictMode

In React StrictMode (dev mode), effects are run twice to help detect
side effects. The cleanup-only pattern left isMountedRef as false after
StrictMode's simulated unmount-remount cycle, causing stop/cancel
operations to be skipped even when the component was mounted.

Now the effect setup explicitly sets isMountedRef.current = true,
ensuring correct behavior in both development and production.
This commit is contained in:
yyh
2026-01-27 01:23:08 +08:00
parent b7f1eb9b7b
commit 8332f0de2b

View File

@@ -21,8 +21,11 @@ export function useChatFlowControl({
const invalidateRun = useStore(s => s.invalidateRun)
const isMountedRef = useRef(true)
useEffect(() => () => {
isMountedRef.current = false
useEffect(() => {
isMountedRef.current = true
return () => {
isMountedRef.current = false
}
}, [])
const { handleNodeCancelRunningStatus } = useNodesInteractionsWithoutSync(isMountedRef)