A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
fix(frontend): resolve react-hooks/static-components
dextmorgn135c81a03772
diff --git a/flowsint-app/src/components/analyses/editor/extensions/mention/mention-list.tsx b/flowsint-app/src/components/analyses/editor/extensions/mention/mention-list.tsxindex 47c6e1dc..40d75b04 100644--- a/flowsint-app/src/components/analyses/editor/extensions/mention/mention-list.tsx+++ b/flowsint-app/src/components/analyses/editor/extensions/mention/mention-list.tsx@@ -109,7 +109,7 @@ const MentionListItem = ({ item, index, selectedIndex, selectItem }: MentionItemonClick={() => selectItem(index)}type="button">- {SourceIcon && <SourceIcon size={14} />}+ {SourceIcon && SourceIcon({ size: 14 })}<span className="flex-1 text-left truncate text-ellipsis">{item.nodeLabel}</span></button>)diff --git a/flowsint-app/src/components/flows/flow-sheet.tsx b/flowsint-app/src/components/flows/flow-sheet.tsxindex b1ef5f2b..7902bc67 100644--- a/flowsint-app/src/components/flows/flow-sheet.tsx+++ b/flowsint-app/src/components/flows/flow-sheet.tsx@@ -198,7 +198,7 @@ const EnricherItem = memo(({ enricher, onClick }: { enricher: Enricher; onClick:<div className="flex items-start gap-2 grow truncate text-ellipsis"><div className="space-y-1 truncate text-left"><div className="flex items-center gap-2 truncate text-ellipsis">- {Icon && <Icon size={24} />}+ {Icon && Icon({ size: 24 })}<h3 className="text-sm font-medium truncate text-ellipsis">{enricher.class_name}</h3>diff --git a/flowsint-app/src/components/investigations/new-investigation.tsx b/flowsint-app/src/components/investigations/new-investigation.tsxindex 6ee43be8..45b84e66 100644--- a/flowsint-app/src/components/investigations/new-investigation.tsx+++ b/flowsint-app/src/components/investigations/new-investigation.tsx@@ -1,5 +1,5 @@import { useState, type ReactNode } from 'react'-import { useForm } from 'react-hook-form'+import { useForm, type UseFormReturn } from 'react-hook-form'import { zodResolver } from '@hookform/resolvers/zod'import { useRouter } from '@tanstack/react-router'import { toast } from 'sonner'@@ -45,6 +45,76 @@ const investigationSchema = z.object({type InvestigationFormData = z.infer<typeof investigationSchema>+// Hoisted to module scope — defining this inside NewInvestigation's render+// made it a new component type every render, which unmounts/remounts the+// whole form (losing focus, resetting any in-progress typing) any time the+// parent re-renders while the dialog is open.+function InvestigationForm({+ form,+ isSubmitting,+ onSubmit,+ onCancel+}: {+ form: UseFormReturn<InvestigationFormData>+ isSubmitting: boolean+ onSubmit: (data: InvestigationFormData) => void+ onCancel: () => void+}) {+ return (+ <Form {...form}>+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">+ <div className="grid gap-4 py-4">+ <FormField+ control={form.control}+ name="name"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Investigation name</FormLabel>+ <FormControl>+ <Input+ required+ placeholder="Fraud suspicion"+ disabled={isSubmitting}+ {...field}+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />++ <FormField+ control={form.control}+ name="description"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Description</FormLabel>+ <FormControl>+ <Input+ placeholder="Investigation into a phishing campaign via LinkedIn."+ disabled={isSubmitting}+ {...field}+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>++ <DialogFooter>+ <Button type="button" variant="outline" onClick={onCancel} disabled={isSubmitting}>+ Cancel+ </Button>+ <Button type="submit" disabled={isSubmitting}>+ {isSubmitting ? 'Creating...' : 'Create Investigation'}+ </Button>+ </DialogFooter>+ </form>+ </Form>+ )+}+interface NewInvestigationProps {children: ReactNodenoDropDown?: boolean@@ -64,7 +134,6 @@ export default function NewInvestigation({ children, noDropDown = false }: NewIn})const {- handleSubmit,formState: { isSubmitting },reset} = form@@ -102,60 +171,6 @@ export default function NewInvestigation({ children, noDropDown = false }: NewInreset() // Reset du formulaire avec React Hook Form}- const InvestigationForm = () => (- <Form {...form}>- <form onSubmit={handleSubmit(onSubmit)} className="space-y-4">- <div className="grid gap-4 py-4">- <FormField- control={form.control}- name="name"- render={({ field }) => (- <FormItem>- <FormLabel>Investigation name</FormLabel>- <FormControl>- <Input- required- placeholder="Fraud suspicion"- disabled={isSubmitting}- {...field}- />- </FormControl>- <FormMessage />- </FormItem>- )}- />-- <FormField- control={form.control}- name="description"- render={({ field }) => (- <FormItem>- <FormLabel>Description</FormLabel>- <FormControl>- <Input- placeholder="Investigation into a phishing campaign via LinkedIn."- disabled={isSubmitting}- {...field}- />- </FormControl>- <FormMessage />- </FormItem>- )}- />- </div>-- <DialogFooter>- <Button type="button" variant="outline" onClick={handleClose} disabled={isSubmitting}>- Cancel- </Button>- <Button type="submit" disabled={isSubmitting}>- {isSubmitting ? 'Creating...' : 'Create Investigation'}- </Button>- </DialogFooter>- </form>- </Form>- )-if (noDropDown) {return (<Dialog open={open} onOpenChange={setOpen}>@@ -167,7 +182,12 @@ export default function NewInvestigation({ children, noDropDown = false }: NewIn<DialogTitle>New investigation</DialogTitle><DialogDescription>Create a new blank investigation.</DialogDescription></DialogHeader>- <InvestigationForm />+ <InvestigationForm+ form={form}+ isSubmitting={isSubmitting}+ onSubmit={onSubmit}+ onCancel={handleClose}+ /></DialogContent></Dialog>)@@ -190,7 +210,12 @@ export default function NewInvestigation({ children, noDropDown = false }: NewIn<DialogTitle>New investigation</DialogTitle><DialogDescription>Create a new blank investigation.</DialogDescription></DialogHeader>- <InvestigationForm />+ <InvestigationForm+ form={form}+ isSubmitting={isSubmitting}+ onSubmit={onSubmit}+ onCancel={handleClose}+ /></DialogContent></Dialog></>diff --git a/flowsint-app/src/components/shared/icon-picker/trigger.tsx b/flowsint-app/src/components/shared/icon-picker/trigger.tsxindex 383dd4d3..61dd593f 100644--- a/flowsint-app/src/components/shared/icon-picker/trigger.tsx+++ b/flowsint-app/src/components/shared/icon-picker/trigger.tsx@@ -14,7 +14,7 @@ export const NodeIconTrigger = ({ type, onClick }: NodeIconTriggerProps) => {variant={'ghost'}size={'icon'}>- <Icon size={24} />+ {Icon({ size: 24 })}</Button>)}diff --git a/flowsint-app/src/components/sketches/add-item-dialog.tsx b/flowsint-app/src/components/sketches/add-item-dialog.tsxindex 07b433e8..5446d21b 100644--- a/flowsint-app/src/components/sketches/add-item-dialog.tsx+++ b/flowsint-app/src/components/sketches/add-item-dialog.tsx@@ -325,7 +325,7 @@ function ActionCard({ item, onSelect }: ActionCardProps) {><CardContent className="p-2 relative flex flex-col items-center text-center h-full"><div className="w-8 h-8 rounded-full flex items-center justify-center mb-3 mt-2">- <IconComponent />+ {IconComponent({})}</div><div className="font-medium text-sm">{item.label}</div>{!item.children && <div className="text-sm mt-2 opacity-60">{item.description}</div>}diff --git a/flowsint-app/src/components/sketches/create-relation.tsx b/flowsint-app/src/components/sketches/create-relation.tsxindex ff885109..a0e55ab0 100644--- a/flowsint-app/src/components/sketches/create-relation.tsx+++ b/flowsint-app/src/components/sketches/create-relation.tsx@@ -196,7 +196,7 @@ export function NodeDisplayCard({return (<div className="flex min-w-[170px] items-center gap-2 min-w-0"><div className="flex items-center justify-center w-6 h-6 rounded-full bg-muted">- <NodeIcon size={20} />+ {NodeIcon({ size: 20 })}</div><span className="text-xs text-muted-foreground max-w-[200px] truncate">{node.nodeLabel}@@ -214,7 +214,7 @@ export function NodeDisplayCard({<RadioGroupItem id={id} value={radioValue || ''} className="mt-0.5" /><div className="flex items-center gap-2 min-w-0"><div className="flex items-center justify-center w-5 h-5 rounded-full bg-muted">- <NodeIcon size={16} />+ {NodeIcon({ size: 16 })}</div><span className="text-sm max-w-[200px] truncate">{node.nodeLabel}</span></div>@@ -225,7 +225,7 @@ export function NodeDisplayCard({return (<div className="flex min-w-[170px] items-center gap-2 px-3 py-2 rounded-md border bg-muted/30 hover:bg-muted/50 transition-colors min-w-0"><div className="flex items-center justify-center w-5 h-5 rounded-full bg-muted">- <NodeIcon size={16} />+ {NodeIcon({ size: 16 })}</div><span className="text-sm max-w-[200px] truncate">{node.nodeLabel}</span></div>diff --git a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx b/flowsint-app/src/components/sketches/details-panel/details-panel.tsxindex 73c2bdd2..5bd9567e 100644--- a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx+++ b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx@@ -484,12 +484,10 @@ const DetailsPanel = memo(() => {onClick={() => setOpenIconPicker(true)}className="shrink-0 mt-1.5 hover:opacity-70 transition-opacity">- <IconComponent size={24} />+ {IconComponent({ size: 24 })}</button>) : (- <div className="shrink-0 mt-1.5">- <IconComponent size={24} />- </div>+ <div className="shrink-0 mt-1.5">{IconComponent({ size: 24 })}</div>)}{canEdit ? (<TitleInput value={formData.nodeLabel} onChange={handleLabelCommit} />diff --git a/flowsint-app/src/components/sketches/dynamic-form.tsx b/flowsint-app/src/components/sketches/dynamic-form.tsxindex 00a1ad4c..34d31f2c 100644--- a/flowsint-app/src/components/sketches/dynamic-form.tsx+++ b/flowsint-app/src/components/sketches/dynamic-form.tsx@@ -319,7 +319,7 @@ export function DynamicForm({<Controllercontrol={control}name={field.name}- render={({ field: { onChange, value } }) => (+ render={({ field: { onChange, value, ref } }) => (<Select onValueChange={onChange} value={value || ''} defaultValue={value || ''}><SelectTriggerref={ref}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.tsindex 09872cd8..7669828d 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@@ -32,7 +32,7 @@ export function useCreateOnPaste(sketchId: string) {}await createNode(nodeWithTempId, sketchId, addNode, replaceNode)- } catch {+ } catch (e) {toast.error(e.message)}},@@ -62,7 +62,7 @@ export function useCreateOnPaste(sketchId: string) {nodeMetadata: {}}await createNode(nodeWithTempId, sketchId, addNode, replaceNode)- } catch {+ } catch (e) {toast.error(e.message)}},diff --git a/flowsint-app/src/components/table/columns.tsx b/flowsint-app/src/components/table/columns.tsxindex 3ec0fbe6..19286f02 100644--- a/flowsint-app/src/components/table/columns.tsx+++ b/flowsint-app/src/components/table/columns.tsx@@ -19,7 +19,7 @@ import { GraphNode } from '@/types'// Memoized icon component to prevent unnecessary re-rendersconst MemoizedIcon = memo(({ type, size = 16 }: { type: string; size?: number }) => {const IconComponent = useIcon(type)- return <IconComponent size={size} />+ return IconComponent({ size })})MemoizedIcon.displayName = 'MemoizedIcon'diff --git a/flowsint-app/src/components/table/nodes-view.tsx b/flowsint-app/src/components/table/nodes-view.tsxindex 45c7e3f6..aa452dfa 100644--- a/flowsint-app/src/components/table/nodes-view.tsx+++ b/flowsint-app/src/components/table/nodes-view.tsx@@ -95,7 +95,7 @@ const NodeItem = memo(function NodeItem({{/* Icon */}<div className="flex items-center justify-center"><div className="flex items-center justify-center w-7 h-7 rounded-full bg-muted">- <SourceIcon size={16} />+ {SourceIcon({ size: 16 })}</div></div>diff --git a/flowsint-app/src/components/table/relationships-view.tsx b/flowsint-app/src/components/table/relationships-view.tsxindex aad04176..85576513 100644--- a/flowsint-app/src/components/table/relationships-view.tsx+++ b/flowsint-app/src/components/table/relationships-view.tsx@@ -85,7 +85,7 @@ function RelationshipItem({{/* Source Node */}<div className="flex items-center gap-2 flex-1 min-w-0 max-w-[35%]"><div className="flex items-center justify-center w-7 h-7 rounded-full bg-muted shrink-0">- <SourceIcon size={16} />+ {SourceIcon({ size: 16 })}</div><buttononClick={handleNodeClickSource}@@ -125,7 +125,7 @@ function RelationshipItem({</span></button><div className="flex items-center justify-center w-7 h-7 rounded-full bg-muted shrink-0">- <TargetIcon size={16} />+ {TargetIcon({ size: 16 })}</div></div></CardContent>