This commit is contained in:
2026-03-13 00:19:14 +01:00
parent 2ff7e1f5f2
commit 2d8f13aebb
5 changed files with 58 additions and 39 deletions

View File

@@ -190,7 +190,16 @@ export function useRenderingNodeState(
const manualRunTriggerSyncedRef = useRef(false)
const pathCtx = useContext(ConnectionPathContext)
const pathCtxRef = useRef(pathCtx)
pathCtxRef.current = pathCtx
const triggerNodeIds = pathCtx?.connectionPathTriggerNodeIds ?? []
const updateDataRef = useRef(updateData)
updateDataRef.current = updateData
const setNodesRef = useRef(setNodes)
setNodesRef.current = setNodes
const aiConnectionRef = useRef(aiConnection)
aiConnectionRef.current = aiConnection
const hasPendingInputs =
effectiveUpdateMode === 'manual' &&
!loading &&
@@ -256,6 +265,7 @@ export function useRenderingNodeState(
let cancelled = false
const run = async () => {
pathCtxRef.current?.addConnectionPathTrigger?.(id)
loadingStartedAtRef.current = Date.now()
setLoading(true)
setError(null)
@@ -263,7 +273,7 @@ export function useRenderingNodeState(
setResolvedContent(null)
setStreamingMarkdown(null)
setReasoningContent('')
updateData({
updateDataRef.current({
cachedRenderedContent: undefined,
cachedResolvedContent: undefined,
cachedReasoningContent: undefined,
@@ -278,8 +288,8 @@ export function useRenderingNodeState(
renderNodeId: id,
viewportWidth,
viewportHeight,
setNodes: setNodes ?? undefined,
aiConnection,
setNodes: setNodesRef.current ?? undefined,
aiConnection: aiConnectionRef.current,
...(isAgentSource && {
onStreamingStart: () => setStreamingMarkdown(''),
onStreamingChunk: (chunk: string) =>
@@ -297,7 +307,7 @@ export function useRenderingNodeState(
if (thisRunId !== runIdRef.current) return
setRenderedContent(htmlOrSvg)
setError(null)
updateData({
updateDataRef.current({
cachedRenderedContent: htmlOrSvg,
cachedResolvedContent: resolved,
cachedReasoningContent: reasoning ?? '',
@@ -351,26 +361,18 @@ export function useRenderingNodeState(
minLoadingTimeoutRef.current = null
}
}
// Content updates only when connected-node data changes (sourceSignature) or explicit run/viewport.
// React Flow updates (position, selection, context ref churn) do not trigger re-runs.
}, [
id,
srcId,
srcNode?.type,
effectiveUpdateMode,
runTrigger,
sourceContent,
sourceSignature,
configSignature,
edgesSignature,
variablesSignature,
functionsSignature,
dataSignature,
viewportWidth,
viewportHeight,
retryCount,
updateData,
setNodes,
aiConnection,
isAgentSource,
incomingIds.length,
])