Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

fix(frontend): resolve react-hooks/exhaustive-deps across live code

dextmorgn73f258f3b105
diff --git a/flowsint-app/src/components/analyses/analysis-editor.tsx b/flowsint-app/src/components/analyses/analysis-editor.tsx
index c57be4d7..53b37bf0 100644
--- a/flowsint-app/src/components/analyses/analysis-editor.tsx
+++ b/flowsint-app/src/components/analyses/analysis-editor.tsx
@@ -96,41 +96,6 @@ export const AnalysisEditor = ({
const createMutation = useCreateAnalysis(routeInvestigationId, onAnalysisCreate)
- const debouncedSave = useCallback(
- debounce(() => {
- if (analysis) {
- setSaveStatus('saving')
- saveMutation.mutate({})
- }
- }, 1000), // 1 second delay
- [analysis?.id]
- )
-
- // Handle editor content changes
- const handleEditorChange = useCallback(
- (value: any) => {
- editorContentRef.current = value
- if (analysis) {
- setSaveStatus('unsaved')
- debouncedSave()
- }
- },
- [analysis?.id, debouncedSave]
- )
-
- // Debounce function
- function debounce(func: Function, wait: number) {
- let timeout: NodeJS.Timeout
- return function executedFunction(...args: any[]) {
- const later = () => {
- clearTimeout(timeout)
- func(...args)
- }
- clearTimeout(timeout)
- timeout = setTimeout(later, wait)
- }
- }
-
const saveMutation = useMutation({
mutationFn: async (updated: Partial<Analysis>) => {
if (!analysis) return
@@ -163,6 +128,33 @@ export const AnalysisEditor = ({
}
})
+ // Debounced save — ref-based timer so useCallback gets a plain inline
+ // function (react-hooks requires it; a wrapped debounce() call defeated
+ // its own dependency tracking).
+ const saveDebounceRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
+
+ const debouncedSave = useCallback(() => {
+ if (saveDebounceRef.current) clearTimeout(saveDebounceRef.current)
+ saveDebounceRef.current = setTimeout(() => {
+ if (analysis) {
+ setSaveStatus('saving')
+ saveMutation.mutate({})
+ }
+ }, 1000)
+ }, [analysis, saveMutation])
+
+ // Handle editor content changes
+ const handleEditorChange = useCallback(
+ (value: any) => {
+ editorContentRef.current = value
+ if (analysis) {
+ setSaveStatus('unsaved')
+ debouncedSave()
+ }
+ },
+ [analysis, debouncedSave]
+ )
+
const deleteMutation = useMutation({
mutationFn: async (id: string) => {
return analysisService.delete(id)
@@ -251,7 +243,7 @@ export const AnalysisEditor = ({
editor.commands.setContent('')
}
}
- }, [analysis?.id, analysis?.title, editor])
+ }, [analysis, editor])
useKeyboardShortcut({
key: 's',
diff --git a/flowsint-app/src/components/chat/chat-history.tsx b/flowsint-app/src/components/chat/chat-history.tsx
index 3c0ae813..46ff9f06 100644
--- a/flowsint-app/src/components/chat/chat-history.tsx
+++ b/flowsint-app/src/components/chat/chat-history.tsx
@@ -108,17 +108,20 @@ const ChatItem = ({
deleteChatMutation: any
switchToChat: any
}) => {
- const handleDeleteChat = useCallback(async (e: { stopPropagation: () => void }) => {
- e.stopPropagation()
- if (
- await confirm({
- title: 'Are you sure you want to delete this chat?',
- message: 'This action is irreversible.'
- })
- ) {
- await deleteChatMutation.mutateAsync(chat.id)
- }
- }, [])
+ const handleDeleteChat = useCallback(
+ async (e: { stopPropagation: () => void }) => {
+ e.stopPropagation()
+ if (
+ await confirm({
+ title: 'Are you sure you want to delete this chat?',
+ message: 'This action is irreversible.'
+ })
+ ) {
+ await deleteChatMutation.mutateAsync(chat.id)
+ }
+ },
+ [chat.id, confirm, deleteChatMutation]
+ )
return (
<button
onClick={() => switchToChat(chat.id)}
diff --git a/flowsint-app/src/components/flows/editor.tsx b/flowsint-app/src/components/flows/editor.tsx
index 5c953ebc..9ba70ee5 100644
--- a/flowsint-app/src/components/flows/editor.tsx
+++ b/flowsint-app/src/components/flows/editor.tsx
@@ -284,7 +284,7 @@ const FlowEditor = memo(({ initialEdges, initialNodes, theme, flow }: FlowEditor
zoom: 1.5
})
},
- [reactFlowInstance, nodes, setNodes, setCenter]
+ [reactFlowInstance, nodes, setNodes, setCenter, colors]
)
// #### Node Interaction Handlers ####
@@ -299,7 +299,7 @@ const FlowEditor = memo(({ initialEdges, initialNodes, theme, flow }: FlowEditor
// zoom: 1.5,
// })
},
- [setCenter, setSelectedNode]
+ [setSelectedNode]
)
const onPaneClick = useCallback(() => {
@@ -409,7 +409,7 @@ const FlowEditor = memo(({ initialEdges, initialNodes, theme, flow }: FlowEditor
} finally {
setLoading(false)
}
- }, [flowId, nodes, edges, computeFlowMutation, setLoading])
+ }, [flowId, nodes, edges, computeFlowMutation, setLoading, handleSaveFlow])
// #### Simulation State Management ####
// Update the updateNodeState function with proper types
@@ -438,6 +438,35 @@ const FlowEditor = memo(({ initialEdges, initialNodes, theme, flow }: FlowEditor
[setCenter]
)
+ const resetSimulation = useCallback(() => {
+ setIsSimulating(false)
+ setCurrentStepIndex(0)
+
+ // Reset all nodes
+ setNodes((nds: FlowNode[]) =>
+ nds.map((node) => ({
+ ...node,
+ data: {
+ ...node.data,
+ computationState: undefined
+ }
+ }))
+ )
+
+ // Reset all edges
+ setEdges((eds: FlowEdge[]) =>
+ eds.map((edge) => ({
+ ...edge,
+ style: {
+ ...edge.style,
+ stroke: '#64748b',
+ strokeWidth: 1
+ },
+ animated: false
+ }))
+ )
+ }, [setIsSimulating, setCurrentStepIndex, setNodes, setEdges])
+
// #### Simulation Effect ####
useEffect(() => {
if (!isSimulating || loading) return
@@ -507,7 +536,11 @@ const FlowEditor = memo(({ initialEdges, initialNodes, theme, flow }: FlowEditor
loading,
flowBranches,
updateNodeState,
- setCurrentStepIndex
+ setCurrentStepIndex,
+ setNodes,
+ setEdges,
+ fitView,
+ resetSimulation
])
// #### Simulation Control Functions ####
@@ -575,35 +608,6 @@ const FlowEditor = memo(({ initialEdges, initialNodes, theme, flow }: FlowEditor
setCurrentStepIndex(totalSteps)
}
- const resetSimulation = () => {
- setIsSimulating(false)
- setCurrentStepIndex(0)
-
- // Reset all nodes
- setNodes((nds: FlowNode[]) =>
- nds.map((node) => ({
- ...node,
- data: {
- ...node.data,
- computationState: undefined
- }
- }))
- )
-
- // Reset all edges
- setEdges((eds: FlowEdge[]) =>
- eds.map((edge) => ({
- ...edge,
- style: {
- ...edge.style,
- stroke: '#64748b',
- strokeWidth: 1
- },
- animated: false
- }))
- )
- }
-
// #### Render ####
return (
<>
@@ -689,7 +693,7 @@ const FlowEditor = memo(({ initialEdges, initialNodes, theme, flow }: FlowEditor
<MiniMap className="bg-background" position="bottom-left" pannable zoomable />
</ReactFlow>
</div>
- <FlowSheet onLayout={onLayout} />
+ <FlowSheet />
<SaveModal
open={showModal}
onOpenChange={setShowModal}
diff --git a/flowsint-app/src/components/flows/flow-sheet.tsx b/flowsint-app/src/components/flows/flow-sheet.tsx
index 930adfd1..b1ef5f2b 100644
--- a/flowsint-app/src/components/flows/flow-sheet.tsx
+++ b/flowsint-app/src/components/flows/flow-sheet.tsx
@@ -17,7 +17,7 @@ import { Alert, AlertDescription } from '../ui/alert'
import { useIcon } from '@/hooks/use-icon'
import { flowService } from '@/api/flow-service'
-const FlowSheet = ({ onLayout }: { onLayout: () => void }) => {
+const FlowSheet = () => {
const openFlowSheet = useFlowStore((state) => state.openFlowSheet)
const setOpenFlowSheet = useFlowStore((state) => state.setOpenFlowSheet)
const selectedNode = useFlowStore((state) => state.selectedNode)
@@ -95,7 +95,7 @@ const FlowSheet = ({ onLayout }: { onLayout: () => void }) => {
// onLayout && onLayout()
setOpenFlowSheet(false)
},
- [selectedNode, setNodes, setEdges, onLayout, setOpenFlowSheet]
+ [selectedNode, setNodes, setEdges, setOpenFlowSheet, colors]
)
return (
diff --git a/flowsint-app/src/components/flows/params-dialog.tsx b/flowsint-app/src/components/flows/params-dialog.tsx
index 6702f02c..473ecd86 100644
--- a/flowsint-app/src/components/flows/params-dialog.tsx
+++ b/flowsint-app/src/components/flows/params-dialog.tsx
@@ -32,7 +32,7 @@ const ParamsDialog = () => {
setParams(selectedNode.data.params)
}
if (selectedNode?.data.settings) {
- setSettings({ ...settings, ...selectedNode.data.settings })
+ setSettings((prev) => ({ ...prev, ...selectedNode.data.settings }))
}
}, [selectedNode])
diff --git a/flowsint-app/src/components/layout/root.layout.tsx b/flowsint-app/src/components/layout/root.layout.tsx
index 6441e6d7..3a37cfbd 100644
--- a/flowsint-app/src/components/layout/root.layout.tsx
+++ b/flowsint-app/src/components/layout/root.layout.tsx
@@ -22,7 +22,6 @@ export default function RootLayout({ children }: LayoutProps) {
const toggleConsole = useLayoutStore((s) => s.toggleConsole)
const isOpenPanel = useLayoutStore((s) => s.isOpenPanel)
const isOpenAnalysis = useLayoutStore((s) => s.isOpenAnalysis)
- const isOpenDetails = useLayoutStore((s) => s.isOpenDetails)
const toggleAnalysis = useLayoutStore((s) => s.toggleAnalysis)
const togglePanel = useLayoutStore((s) => s.togglePanel)
const closePanel = useLayoutStore((s) => s.closePanel)
@@ -119,7 +118,7 @@ export default function RootLayout({ children }: LayoutProps) {
// No panel should be shown
return null
- }, [id, currentNode?.id, currentNode?.data, currentEdge?.id, isOpenAnalysis, closeDetails])
+ }, [id, type, currentNode, currentEdge, isOpenAnalysis, closeDetails])
// Memoize the entire layout content to prevent unnecessary re-renders
const layoutContent = useMemo(
@@ -185,18 +184,7 @@ export default function RootLayout({ children }: LayoutProps) {
</div>
</div>
),
- [
- isOpenConsole,
- isOpenPanel,
- isOpenAnalysis,
- isOpenDetails,
- id,
- children,
- detailsPanelSection,
- closePanel,
- openPanel,
- closeDetails
- ]
+ [isOpenConsole, isOpenPanel, children, detailsPanelSection, closePanel, openPanel]
)
return <ConfirmContextProvider>{layoutContent}</ConfirmContextProvider>
diff --git a/flowsint-app/src/components/map/map.tsx b/flowsint-app/src/components/map/map.tsx
index 0ad1fad0..a9f5a9e8 100644
--- a/flowsint-app/src/components/map/map.tsx
+++ b/flowsint-app/src/components/map/map.tsx
@@ -156,36 +156,40 @@ export const MapFromAddress: React.FC<MapFromAddressProps> = ({
})
// Combine all locations with their coordinates
- const processedLocations = locations.map((location) => {
- if (location.lat !== undefined && location.lon !== undefined) {
- return {
- ...location,
- coordinates: { lat: location.lat, lon: location.lon },
- isLoading: false,
- isError: false
- }
- }
- const geocodeIndex = locationsToGeocode.findIndex((loc) => loc.address === location.address)
- if (geocodeIndex !== -1 && geocodeQuery.data) {
- const geocoded = geocodeQuery.data[geocodeIndex]
- return {
- ...location,
- coordinates: geocoded,
- isLoading: geocodeQuery.isLoading,
- isError: geocodeQuery.isError
- }
- }
- return {
- ...location,
- coordinates: null,
- isLoading: geocodeQuery.isLoading,
- isError: geocodeQuery.isError
- }
- })
+ const processedLocations = useMemo(
+ () =>
+ locations.map((location) => {
+ if (location.lat !== undefined && location.lon !== undefined) {
+ return {
+ ...location,
+ coordinates: { lat: location.lat, lon: location.lon },
+ isLoading: false,
+ isError: false
+ }
+ }
+ const geocodeIndex = locationsToGeocode.findIndex((loc) => loc.address === location.address)
+ if (geocodeIndex !== -1 && geocodeQuery.data) {
+ const geocoded = geocodeQuery.data[geocodeIndex]
+ return {
+ ...location,
+ coordinates: geocoded,
+ isLoading: geocodeQuery.isLoading,
+ isError: geocodeQuery.isError
+ }
+ }
+ return {
+ ...location,
+ coordinates: null,
+ isLoading: geocodeQuery.isLoading,
+ isError: geocodeQuery.isError
+ }
+ }),
+ [locations, locationsToGeocode, geocodeQuery.data, geocodeQuery.isLoading, geocodeQuery.isError]
+ )
const validLocations = useMemo(
() => processedLocations.filter((l) => l.coordinates),
- [JSON.stringify(processedLocations)]
+ [processedLocations]
)
const DEFAULT_MARKER_COLOR = '#6366f1'
diff --git a/flowsint-app/src/components/nav-user.tsx b/flowsint-app/src/components/nav-user.tsx
index 077800ca..aa40f71f 100644
--- a/flowsint-app/src/components/nav-user.tsx
+++ b/flowsint-app/src/components/nav-user.tsx
@@ -24,7 +24,7 @@ export function NavUser() {
const logout = useCallback(() => {
authService.logout()
navigate({ to: '/login' })
- }, [])
+ }, [navigate])
return (
<DropdownMenu>
diff --git a/flowsint-app/src/components/sketches/details-panel/neighbors.tsx b/flowsint-app/src/components/sketches/details-panel/neighbors.tsx
index 3658a225..c4583818 100644
--- a/flowsint-app/src/components/sketches/details-panel/neighbors.tsx
+++ b/flowsint-app/src/components/sketches/details-panel/neighbors.tsx
@@ -47,7 +47,7 @@ const NeighborsGraph = memo(
)
const handleRefetch = useCallback(() => {
refetch()
- }, [])
+ }, [refetch])
if (error)
return (
diff --git a/flowsint-app/src/components/sketches/graph/background/index.tsx b/flowsint-app/src/components/sketches/graph/background/index.tsx
index d60eba38..de502198 100644
--- a/flowsint-app/src/components/sketches/graph/background/index.tsx
+++ b/flowsint-app/src/components/sketches/graph/background/index.tsx
@@ -148,7 +148,13 @@ function BackgroundComponent({
cancelAnimationFrame(rafRef.current)
}
}
- }, [graphRef, canvasWidth, canvasHeight, isVisible])
+ // gapXY/offsetXY are new array literals every render — depending on
+ // them directly would restart the rAF loop every render regardless of
+ // whether the pattern actually changed. Depend on the primitives they're
+ // derived from instead; the closure still picks up fresh gapXY/offsetXY
+ // whenever the effect re-runs.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [graphRef, canvasWidth, canvasHeight, isVisible, gap, offset, patternSize, isCross, isDots])
return (
<svg
diff --git a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx b/flowsint-app/src/components/sketches/graph/components/graph-main.tsx
index 9c69cd86..8ccd944f 100644
--- a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx
+++ b/flowsint-app/src/components/sketches/graph/components/graph-main.tsx
@@ -121,7 +121,8 @@ const GraphMain = () => {
setCurrentNodeId,
clearSelectedNodes,
clearSelectedEdges,
- setCurrentEdgeId
+ setCurrentEdgeId,
+ canCreate
]
)
@@ -163,7 +164,7 @@ const GraphMain = () => {
onClick: stableBackgroundClick
})
},
- [selectedNodes]
+ [selectedNodes, stableBackgroundClick]
)
const onEdgeContextMenu = useCallback(
@@ -198,25 +199,28 @@ const GraphMain = () => {
setNodeMenu(null)
setBackgroundMenu(null)
},
- [selectedEdges, handleBackgroundClick]
+ [selectedEdges, stableBackgroundClick]
)
- const onBackgroundContextMenu = useCallback((event: MouseEvent) => {
- if (!containerRef.current) return
- const pane = containerRef.current.getBoundingClientRect()
- const relativeX = event.clientX - pane.left
- const relativeY = event.clientY - pane.top
+ const onBackgroundContextMenu = useCallback(
+ (event: MouseEvent) => {
+ if (!containerRef.current) return
+ const pane = containerRef.current.getBoundingClientRect()
+ const relativeX = event.clientX - pane.left
+ const relativeY = event.clientY - pane.top
- setBackgroundMenu({
- nodes: selectedNodes,
- rawTop: relativeY,
- rawLeft: relativeX,
- wrapperWidth: pane.width,
- wrapperHeight: pane.height,
- setMenu: setBackgroundMenu,
- onClick: stableBackgroundClick
- })
- }, [])
+ setBackgroundMenu({
+ nodes: selectedNodes,
+ rawTop: relativeY,
+ rawLeft: relativeX,
+ wrapperWidth: pane.width,
+ wrapperHeight: pane.height,
+ setMenu: setBackgroundMenu,
+ onClick: stableBackgroundClick
+ })
+ },
+ [selectedNodes, stableBackgroundClick]
+ )
// On link creation complete: create edge in store, then open edge context menu
const handleCompleteLinking = useCallback(
@@ -238,7 +242,7 @@ const GraphMain = () => {
onDismissNew: dismissNewEdge
})
},
- [completeLinking, handleBackgroundClick, submitNewEdge, dismissNewEdge]
+ [completeLinking, stableBackgroundClick, submitNewEdge, dismissNewEdge]
)
const linkCreationProp = useMemo(
diff --git a/flowsint-app/src/components/sketches/graph/hooks/use-create-on-paste.ts b/flowsint-app/src/components/sketches/graph/hooks/use-create-on-paste.ts
index c2c3e112..4655f606 100644
--- a/flowsint-app/src/components/sketches/graph/hooks/use-create-on-paste.ts
+++ b/flowsint-app/src/components/sketches/graph/hooks/use-create-on-paste.ts
@@ -36,7 +36,7 @@ export function useCreateOnPaste(sketchId: string) {
toast.error(e.message)
}
},
- [sketchId]
+ [sketchId, addNode, replaceNode]
)
const onImage = useCallback(
@@ -66,7 +66,7 @@ export function useCreateOnPaste(sketchId: string) {
toast.error(e.message)
}
},
- [sketchId]
+ [sketchId, addNode, replaceNode]
)
return usePasteListener(
{
diff --git a/flowsint-app/src/components/sketches/graph/index.tsx b/flowsint-app/src/components/sketches/graph/index.tsx
index ec012812..77bfb4c5 100644
--- a/flowsint-app/src/components/sketches/graph/index.tsx
+++ b/flowsint-app/src/components/sketches/graph/index.tsx
@@ -346,7 +346,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
graphRef.current.zoomToFit(400)
}
}
- }, [sketchId])
+ }, [])
// reset hasPerformedInitialZoom on sketch change
useEffect(() => {
diff --git a/flowsint-app/src/components/sketches/graph/node/actions/flag.tsx b/flowsint-app/src/components/sketches/graph/node/actions/flag.tsx
index 5f3b9054..0b69c082 100644
--- a/flowsint-app/src/components/sketches/graph/node/actions/flag.tsx
+++ b/flowsint-app/src/components/sketches/graph/node/actions/flag.tsx
@@ -52,7 +52,7 @@ export function NodeFlag({ sketchId, node }: { sketchId: string; node: GraphNode
// toast.error(e.message)
}
},
- [nodeId, flagValue, updateNode]
+ [nodeId, flagValue, updateNode, node, sketchId]
)
return (
diff --git a/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsx b/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsx
index 153ad777..40f0c778 100644
--- a/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsx
+++ b/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsx
@@ -55,7 +55,7 @@ const NodeActions = memo(
setRelatedNodeToAdd(node)
setOpenMainDialog(true)
setMenu?.(null)
- }, [setOpenMainDialog, setMenu, node])
+ }, [setOpenMainDialog, setMenu, node, setRelatedNodeToAdd])
const handleAskAI = useCallback(
(e: React.MouseEvent) => {
@@ -105,7 +105,7 @@ const NodeActions = memo(
console.log(e)
}
},
- [node.id, flagValue, updateNode, sketchId]
+ [node, flagValue, updateNode, sketchId]
)
if (!canEdit) return null
diff --git a/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx b/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx
index 8b675c68..bd436944 100644
--- a/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx
+++ b/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx
@@ -221,7 +221,7 @@ const NodesPanel = memo(({ nodes, isLoading }: { nodes: GraphNode[]; isLoading?:
setSelectedNodes(filteredNodes)
} else setSelectedNodes(nodes)
},
- [nodes, filteredNodes, filters, searchQuery, selectedNodes, setSelectedNodes]
+ [nodes, filteredNodes, filters, searchQuery, setSelectedNodes]
)
const handleCheckboxChange = useCallback(
diff --git a/flowsint-app/src/components/sketches/import-preview.tsx b/flowsint-app/src/components/sketches/import-preview.tsx
index ea836f3f..b5e371dd 100644
--- a/flowsint-app/src/components/sketches/import-preview.tsx
+++ b/flowsint-app/src/components/sketches/import-preview.tsx
@@ -561,7 +561,7 @@ export function ImportPreview({
setIsImporting(false)
toast.error(error?.message)
}
- }, [mappingsById, sketchId, onSuccess, refetchGraph])
+ }, [mappingsById, sketchId, onSuccess, refetchGraph, edges, regenerateLayout, currentLayoutType])
const typeNames = useMemo(() => Object.keys(mappingIdsByType), [mappingIdsByType])
const [activeTab, setActiveTab] = useState('')
diff --git a/flowsint-app/src/components/sketches/index.tsx b/flowsint-app/src/components/sketches/index.tsx
index 65366d88..0b1b701c 100644
--- a/flowsint-app/src/components/sketches/index.tsx
+++ b/flowsint-app/src/components/sketches/index.tsx
@@ -49,7 +49,6 @@ const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {
const view = useGraphControls((s) => s.view)
const updateGraphData = useGraphStore((s) => s.updateGraphData)
const setFilters = useGraphStore((s) => s.setFilters)
- const filters = useGraphStore((s) => s.filters)
const { actionItems, isLoading: isLoadingActionItems } = useActionItems()
const { params, sketch } = useLoaderData({
@@ -64,15 +63,17 @@ const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {
if (graphData?.nds && graphData?.rls) {
updateGraphData(graphData.nds, graphData.rls)
const types = new Set(graphData.nds.map((n) => n.nodeType))
+ // Read current filters via getState() rather than subscribing — this
+ // effect shouldn't re-run just because filters changed.
setFilters({
- ...filters,
+ ...useGraphStore.getState().filters,
types: Array.from(types).map((t) => ({
type: t,
checked: true
}))
})
}
- }, [graphData?.nds, graphData?.rls, setFilters])
+ }, [graphData?.nds, graphData?.rls, setFilters, updateGraphData])
const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault()
diff --git a/flowsint-app/src/components/sketches/launch-enricher.tsx b/flowsint-app/src/components/sketches/launch-enricher.tsx
index 77b8bd97..9a22b318 100644
--- a/flowsint-app/src/components/sketches/launch-enricher.tsx
+++ b/flowsint-app/src/components/sketches/launch-enricher.tsx
@@ -94,7 +94,15 @@ const LaunchEnricherOrFlowPanel = memo(
}
handleCloseModal()
}
- }, [selectedEnricher, activeTab, launchEnricher, launchFlow, values, sketch_id])
+ }, [
+ selectedEnricher,
+ activeTab,
+ launchEnricher,
+ launchFlow,
+ values,
+ sketch_id,
+ handleCloseModal
+ ])
if (disabled) return <>{children}</>
return (
diff --git a/flowsint-app/src/components/sketches/settings/settings.tsx b/flowsint-app/src/components/sketches/settings/settings.tsx
index ae339245..3ba1cd22 100644
--- a/flowsint-app/src/components/sketches/settings/settings.tsx
+++ b/flowsint-app/src/components/sketches/settings/settings.tsx
@@ -247,7 +247,7 @@ function NodeColorsSection() {
const handleRandomizeColors = useCallback(() => {
randomizeColors()
- }, [])
+ }, [randomizeColors])
const handleIconSelect = (iconType: string, iconName: string) => {
// @ts-ignore
@@ -265,9 +265,10 @@ function NodeColorsSection() {
// Cleanup timers on unmount
useEffect(() => {
+ const timers = debounceTimers.current
return () => {
- debounceTimers.current.forEach((timer) => clearTimeout(timer))
- debounceTimers.current.clear()
+ timers.forEach((timer) => clearTimeout(timer))
+ timers.clear()
}
}, [])
diff --git a/flowsint-app/src/components/sketches/toolbar.tsx b/flowsint-app/src/components/sketches/toolbar.tsx
index bfea3c94..54443128 100644
--- a/flowsint-app/src/components/sketches/toolbar.tsx
+++ b/flowsint-app/src/components/sketches/toolbar.tsx
@@ -217,7 +217,7 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean
)
}
},
- [sketchId, exportToPNG]
+ [sketchId]
)
const areExactlyTwoSelected = selectedNodes.length === 2
diff --git a/flowsint-app/src/components/table/relationships-view.tsx b/flowsint-app/src/components/table/relationships-view.tsx
index c136afa7..0af70cdf 100644
--- a/flowsint-app/src/components/table/relationships-view.tsx
+++ b/flowsint-app/src/components/table/relationships-view.tsx
@@ -59,10 +59,10 @@ function RelationshipItem({
const handleNodeClickSource = useCallback(() => {
onNodeClick(relationship.source)
- }, [])
+ }, [onNodeClick, relationship.source])
const handleNodeClickTarget = useCallback(() => {
onNodeClick(relationship.target)
- }, [])
+ }, [onNodeClick, relationship.target])
const handleCheckboxChange = useCallback(
(checked: boolean) => {
diff --git a/flowsint-app/src/components/templates/template-editor.tsx b/flowsint-app/src/components/templates/template-editor.tsx
index 8e852e19..4a4175c4 100644
--- a/flowsint-app/src/components/templates/template-editor.tsx
+++ b/flowsint-app/src/components/templates/template-editor.tsx
@@ -110,7 +110,10 @@ export function TemplateEditor({ templateId, initialContent, importedYaml }: Tem
const hasChanges = content !== savedContent
const hasErrors = !validationResult.valid || editorErrors.some((e) => e.severity >= 8)
const templateName = validationResult.data?.name || 'Untitled'
- const templateParams = validationResult.data?.request?.params || {}
+ const templateParams = useMemo(
+ () => validationResult.data?.request?.params || {},
+ [validationResult.data]
+ )
const paramKeys = Object.keys(templateParams)
const stateRef = useRef({ hasErrors, hasChanges, data: validationResult.data, content })
diff --git a/flowsint-app/src/hooks/use-keyboard-shortcut.ts b/flowsint-app/src/hooks/use-keyboard-shortcut.ts
index ba2bbb00..b59a9dca 100644
--- a/flowsint-app/src/hooks/use-keyboard-shortcut.ts
+++ b/flowsint-app/src/hooks/use-keyboard-shortcut.ts
@@ -29,6 +29,6 @@ export function useKeyboardShortcut(options: ShortcutOptions) {
return () => {
window.removeEventListener('keydown', handleKeyDown)
}
- }, [options, isMac])
+ }, [options])
return { isMac }
}
diff --git a/flowsint-app/src/hooks/use-save-node-positions.ts b/flowsint-app/src/hooks/use-save-node-positions.ts
index 3c8c4d28..54ce1c22 100644
--- a/flowsint-app/src/hooks/use-save-node-positions.ts
+++ b/flowsint-app/src/hooks/use-save-node-positions.ts
@@ -77,7 +77,7 @@ export function useSaveNodePositions(sketchId?: string) {
setSaveStatus('pending')
}
},
- [sketchId]
+ [sketchId, setNodes, setSaveStatus]
)
/**
diff --git a/flowsint-app/src/routes/_auth.dashboard.custom-types.$typeId.tsx b/flowsint-app/src/routes/_auth.dashboard.custom-types.$typeId.tsx
index 16186937..986a5734 100644
--- a/flowsint-app/src/routes/_auth.dashboard.custom-types.$typeId.tsx
+++ b/flowsint-app/src/routes/_auth.dashboard.custom-types.$typeId.tsx
@@ -1,6 +1,6 @@
import { createFileRoute, useNavigate } from '@tanstack/react-router'
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
-import { useState, useEffect } from 'react'
+import { useState, useEffect, useCallback } from 'react'
import { Button } from '@/components/ui/button'
import { customTypeService, CustomType } from '@/api/custom-type-service'
import { toast } from 'sonner'
@@ -57,6 +57,22 @@ function CustomTypeEditor() {
enabled: !isNew
})
+ // Stable (functional state update, no closure over `fields`) so it's
+ // safe to depend on below without re-running this effect after every
+ // field it adds.
+ const addField = useCallback(() => {
+ setFields((prev) => [
+ ...prev,
+ {
+ id: Math.random().toString(36).substr(2, 9),
+ key: '',
+ title: '',
+ type: 'string',
+ required: false
+ }
+ ])
+ }, [])
+
useEffect(() => {
if (existingType) {
setName(existingType.name)
@@ -69,7 +85,7 @@ function CustomTypeEditor() {
} else if (isNew) {
addField()
}
- }, [existingType, isNew])
+ }, [existingType, isNew, addField])
useEffect(() => {
setName(name.replaceAll(' ', ''))
@@ -106,19 +122,6 @@ function CustomTypeEditor() {
return { title: name || 'MyCustomType', type: 'object', properties, required }
}
- const addField = () => {
- setFields([
- ...fields,
- {
- id: Math.random().toString(36).substr(2, 9),
- key: '',
- title: '',
- type: 'string',
- required: false
- }
- ])
- }
-
const updateField = (id: string, updates: Partial<SchemaField>) => {
setFields(fields.map((f) => (f.id === id ? { ...f, ...updates } : f)))
}