diff --git a/frontend/src/components/nodes/RenderingNode.tsx b/frontend/src/components/nodes/RenderingNode.tsx index 2d04466..bf5d65a 100644 --- a/frontend/src/components/nodes/RenderingNode.tsx +++ b/frontend/src/components/nodes/RenderingNode.tsx @@ -63,7 +63,6 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) { const runIdRef = useRef(0) const loadingStartedAtRef = useRef(null) const minLoadingTimeoutRef = useRef | null>(null) - const isInitialRunRef = useRef(true) const { nodes, edges, setNodes, setEdges, sourceIds, updateData } = useAbstractNode(id, data ?? {}) const viewportWidth = data?.viewportWidth ?? DEFAULT_VIEWPORT_WIDTH 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', }) setLoading(false) - if (!isInitialRunRef.current) endConnectionPathUpdate?.(id) - isInitialRunRef.current = false + endConnectionPathUpdate?.(id) return } if (incomingIds.length === 0) { @@ -207,8 +205,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) { setResolvedContent(null) setError(null) setLoading(false) - if (!isInitialRunRef.current) endConnectionPathUpdate?.(id) - isInitialRunRef.current = false + endConnectionPathUpdate?.(id) return } @@ -219,7 +216,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) { const run = async () => { loadingStartedAtRef.current = Date.now() setLoading(true) - if (!isInitialRunRef.current) startConnectionPathUpdate?.(id) + startConnectionPathUpdate?.(id) setError(null) try { if (srcNode?.type === 'agent') { @@ -231,8 +228,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) { setRenderedContent(html) setError(null) setLoading(false) - if (!isInitialRunRef.current) endConnectionPathUpdate?.(id) - isInitialRunRef.current = false + endConnectionPathUpdate?.(id) return } const configIdsUsed = new Set() @@ -507,8 +503,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) { setResolvedContent(null) setError({ kind: 'render', message: `Nunjucks: ${nunjucksErr.message}` }) setLoading(false) - if (!isInitialRunRef.current) endConnectionPathUpdate?.(id) - isInitialRunRef.current = false + endConnectionPathUpdate?.(id) return } @@ -538,14 +533,12 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) { minLoadingTimeoutRef.current = null if (!cancelled && thisRunId === runIdRef.current) { setLoading(false) - if (!isInitialRunRef.current) endConnectionPathUpdate?.(id) - isInitialRunRef.current = false + endConnectionPathUpdate?.(id) } }, remaining) } else { setLoading(false) - if (!isInitialRunRef.current) endConnectionPathUpdate?.(id) - isInitialRunRef.current = false + endConnectionPathUpdate?.(id) } } } @@ -555,8 +548,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) { setRenderedContent(null) setError({ kind: 'render', message: err?.message ?? 'Render error' }) setLoading(false) - if (!isInitialRunRef.current) endConnectionPathUpdate?.(id) - isInitialRunRef.current = false + endConnectionPathUpdate?.(id) } } } @@ -569,8 +561,7 @@ function RenderingNodeComponent({ id, data, width, height, selected }: Props) { clearTimeout(minLoadingTimeoutRef.current) minLoadingTimeoutRef.current = null } - if (!isInitialRunRef.current) endConnectionPathUpdate?.(id) - isInitialRunRef.current = false + endConnectionPathUpdate?.(id) } // 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])