fix: remove init constraint
This commit is contained in:
@@ -63,7 +63,6 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
|||||||
const runIdRef = useRef(0)
|
const runIdRef = useRef(0)
|
||||||
const loadingStartedAtRef = useRef<number | null>(null)
|
const loadingStartedAtRef = useRef<number | null>(null)
|
||||||
const minLoadingTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
const minLoadingTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||||
const isInitialRunRef = useRef(true)
|
|
||||||
const { nodes, edges, setNodes, setEdges, sourceIds, updateData } = useAbstractNode<RenderingNodeData>(id, data ?? {})
|
const { nodes, edges, setNodes, setEdges, sourceIds, updateData } = useAbstractNode<RenderingNodeData>(id, data ?? {})
|
||||||
const viewportWidth = data?.viewportWidth ?? DEFAULT_VIEWPORT_WIDTH
|
const viewportWidth = data?.viewportWidth ?? DEFAULT_VIEWPORT_WIDTH
|
||||||
const viewportHeight = data?.viewportHeight ?? DEFAULT_VIEWPORT_HEIGHT
|
const viewportHeight = data?.viewportHeight ?? DEFAULT_VIEWPORT_HEIGHT
|
||||||
@@ -198,8 +197,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
|||||||
message: isAgentSource ? 'Run the Agent node to generate output.' : 'No content on connected configuration node',
|
message: isAgentSource ? 'Run the Agent node to generate output.' : 'No content on connected configuration node',
|
||||||
})
|
})
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
if (!isInitialRunRef.current) endConnectionPathUpdate?.(id)
|
endConnectionPathUpdate?.(id)
|
||||||
isInitialRunRef.current = false
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (incomingIds.length === 0) {
|
if (incomingIds.length === 0) {
|
||||||
@@ -207,8 +205,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
|||||||
setResolvedContent(null)
|
setResolvedContent(null)
|
||||||
setError(null)
|
setError(null)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
if (!isInitialRunRef.current) endConnectionPathUpdate?.(id)
|
endConnectionPathUpdate?.(id)
|
||||||
isInitialRunRef.current = false
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +216,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
|||||||
const run = async () => {
|
const run = async () => {
|
||||||
loadingStartedAtRef.current = Date.now()
|
loadingStartedAtRef.current = Date.now()
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
if (!isInitialRunRef.current) startConnectionPathUpdate?.(id)
|
startConnectionPathUpdate?.(id)
|
||||||
setError(null)
|
setError(null)
|
||||||
try {
|
try {
|
||||||
if (srcNode?.type === 'agent') {
|
if (srcNode?.type === 'agent') {
|
||||||
@@ -231,8 +228,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
|||||||
setRenderedContent(html)
|
setRenderedContent(html)
|
||||||
setError(null)
|
setError(null)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
if (!isInitialRunRef.current) endConnectionPathUpdate?.(id)
|
endConnectionPathUpdate?.(id)
|
||||||
isInitialRunRef.current = false
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const configIdsUsed = new Set<string>()
|
const configIdsUsed = new Set<string>()
|
||||||
@@ -507,8 +503,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
|||||||
setResolvedContent(null)
|
setResolvedContent(null)
|
||||||
setError({ kind: 'render', message: `Nunjucks: ${nunjucksErr.message}` })
|
setError({ kind: 'render', message: `Nunjucks: ${nunjucksErr.message}` })
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
if (!isInitialRunRef.current) endConnectionPathUpdate?.(id)
|
endConnectionPathUpdate?.(id)
|
||||||
isInitialRunRef.current = false
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,14 +533,12 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
|||||||
minLoadingTimeoutRef.current = null
|
minLoadingTimeoutRef.current = null
|
||||||
if (!cancelled && thisRunId === runIdRef.current) {
|
if (!cancelled && thisRunId === runIdRef.current) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
if (!isInitialRunRef.current) endConnectionPathUpdate?.(id)
|
endConnectionPathUpdate?.(id)
|
||||||
isInitialRunRef.current = false
|
|
||||||
}
|
}
|
||||||
}, remaining)
|
}, remaining)
|
||||||
} else {
|
} else {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
if (!isInitialRunRef.current) endConnectionPathUpdate?.(id)
|
endConnectionPathUpdate?.(id)
|
||||||
isInitialRunRef.current = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -555,8 +548,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
|||||||
setRenderedContent(null)
|
setRenderedContent(null)
|
||||||
setError({ kind: 'render', message: err?.message ?? 'Render error' })
|
setError({ kind: 'render', message: err?.message ?? 'Render error' })
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
if (!isInitialRunRef.current) endConnectionPathUpdate?.(id)
|
endConnectionPathUpdate?.(id)
|
||||||
isInitialRunRef.current = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -569,8 +561,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) {
|
|||||||
clearTimeout(minLoadingTimeoutRef.current)
|
clearTimeout(minLoadingTimeoutRef.current)
|
||||||
minLoadingTimeoutRef.current = null
|
minLoadingTimeoutRef.current = null
|
||||||
}
|
}
|
||||||
if (!isInitialRunRef.current) endConnectionPathUpdate?.(id)
|
endConnectionPathUpdate?.(id)
|
||||||
isInitialRunRef.current = false
|
|
||||||
}
|
}
|
||||||
// Only re-run when inputs that affect the resolved output change (signatures + source). Debounced to avoid excessive re-renders while typing. retryCount triggers re-run on Retry.
|
// Only re-run when inputs that affect the resolved output change (signatures + source). Debounced to avoid excessive re-renders while typing. retryCount triggers re-run on Retry.
|
||||||
}, [id, sourceContent, configTypeId, configSignature, edgesSignature, variablesSignature, functionsSignature, dataSignature, viewportWidth, viewportHeight, retryCount, isAgentSource])
|
}, [id, sourceContent, configTypeId, configSignature, edgesSignature, variablesSignature, functionsSignature, dataSignature, viewportWidth, viewportHeight, retryCount, isAgentSource])
|
||||||
|
|||||||
Reference in New Issue
Block a user