A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat(app): node display features + new nodeLabel
dextmorgnd0343cba50a6
diff --git a/flowsint-app/src/api/sketch-service.ts b/flowsint-app/src/api/sketch-service.tsindex ac62b893..0196d0ed 100644--- a/flowsint-app/src/api/sketch-service.ts+++ b/flowsint-app/src/api/sketch-service.ts@@ -100,7 +100,7 @@ export const sketchService = {id: stringentity_type: stringinclude: boolean- label: string+ nodeLabel: stringnode_id?: stringdata: Record<string, any>}>,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 e3f15e74..db721b33 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@@ -5,13 +5,16 @@ import { useIcon } from '@/hooks/use-icon'export interface MentionItem {value: string- type: ItemType+ nodeType: ItemType+ nodeImage: string | null+ nodeIcon: string | any | null+ nodeColor: string | nullnodeId: string}export interface MentionListProps {items: MentionItem[]- command: (item: { label: string; type: ItemType; nodeId: string }) => void+ command: (item: MentionItem) => void}export interface MentionListRef {@@ -25,7 +28,7 @@ const MentionList = forwardRef<MentionListRef, MentionListProps>((props, ref) =>const item = props.items[index]if (item) {- props.command({ label: item.value, type: item.type, nodeId: item.nodeId })+ props.command(item)}}@@ -91,7 +94,12 @@ type MentionItemProps = {selectItem: (index: number) => void}const MentionListItem = ({ item, index, selectedIndex, selectItem }: MentionItemProps) => {- const Icon = useIcon(item.type, null) ?? null+ const SourceIcon = useIcon(item.nodeType, {+ nodeColor: item.nodeColor,+ // @ts-ignore+ nodeIcon: item.nodeIcon,+ nodeImage: item.nodeImage+ })return (<buttonclassName={cn(@@ -104,9 +112,8 @@ const MentionListItem = ({ item, index, selectedIndex, selectItem }: MentionItemonClick={() => selectItem(index)}type="button">- {Icon && <Icon size={14} />}+ {SourceIcon && <SourceIcon size={14} />}<span className="flex-1 text-left truncate text-ellipsis">{item.value}</span>- <span className="text-xs text-muted-foreground capitalize">{item.type}</span></button>)}diff --git a/flowsint-app/src/components/analyses/editor/extensions/mention/mention.tsx b/flowsint-app/src/components/analyses/editor/extensions/mention/mention.tsxindex 1591b40a..b5c8eecd 100644--- a/flowsint-app/src/components/analyses/editor/extensions/mention/mention.tsx+++ b/flowsint-app/src/components/analyses/editor/extensions/mention/mention.tsx@@ -10,11 +10,12 @@ import MentionList from './mention-list'import type { MentionListRef, MentionItem } from './mention-list'import { memo, useCallback } from 'react'import { useIcon } from '@/hooks/use-icon'-import { useNodesDisplaySettings, type ItemType } from '@/stores/node-display-settings'+import { useNodesDisplaySettings } from '@/stores/node-display-settings'import { Button } from '@/components/ui/button'import { GRAPH_COLORS } from '@/components/sketches/graph'import { useGraphStore } from '@/stores/graph-store'import { useGraphControls } from '@/stores/graph-controls-store'+import { GraphNode } from '@/types'function hexWithOpacity(hex: string, opacity: number) {hex = hex.replace('#', '')@@ -38,16 +39,12 @@ const getMentionItemsFromNodes = (): MentionItem[] => {const nodes = useGraphStore.getState().nodesreturn nodes.map((node) => {- const label = node.data?.label || node.data?.username || node.id- const type = node.data?.type as ItemType- const nodeId = node.data?.id || node.id-- if (!type) return null-return {- value: label,- type: type,- nodeId: nodeId+ value: node.nodeLabel,+ nodeType: node.nodeType,+ nodeId: node.id,+ nodeImage: node.nodeImage,+ nodeIcon: node.nodeIcon}}).filter((item): item is MentionItem => item !== null)@@ -74,10 +71,19 @@ const updatePosition = (editor: Editor, element: HTMLElement) => {// Composant React custom pour le rendu de la mentionconst MentionComponent = memo((props: any) => {const nodeId = props.node.attrs.nodeId- const type = props.node.attrs.type as ItemType | null- const Icon = type ? (useIcon(type, null) ?? null) : null+ const node = props.node as GraphNode++ const SourceIcon = useIcon(node.nodeType, {+ nodeColor: node.nodeColor,+ nodeIcon: node.nodeIcon,+ nodeImage: node.nodeImage+ })const colors = useNodesDisplaySettings((s) => s.colors)- const color = type ? (colors[type] ?? GRAPH_COLORS.NODE_DEFAULT) : GRAPH_COLORS.NODE_DEFAULT+ const color =+ (node.nodeColor ?? node.nodeType)+ ? // @ts-ignore+ (colors[node.nodeType] ?? GRAPH_COLORS.NODE_DEFAULT)+ : GRAPH_COLORS.NODE_DEFAULTconst centerOnNode = useGraphControls((state) => state.centerOnNode)const setCurrentNodeFromId = useGraphStore((state) => state.setCurrentNodeFromId)@@ -108,8 +114,8 @@ const MentionComponent = memo((props: any) => {border: `solid 1px ${hexWithOpacity(color, 0.5)}`}}>- {Icon && <Icon size={19} iconOnly className="opacity-60" style={{ color }} />}- {props.node.attrs.label}+ {SourceIcon && <SourceIcon size={12} className="opacity-60" />}+ {props.node.nodeLabel}</Button></NodeViewWrapper>)diff --git a/flowsint-app/src/components/chat/chat-history.tsx b/flowsint-app/src/components/chat/chat-history.tsxindex 0a582f61..8327cabe 100644--- a/flowsint-app/src/components/chat/chat-history.tsx+++ b/flowsint-app/src/components/chat/chat-history.tsx@@ -130,7 +130,7 @@ const ChatItem = ({{formatDistanceToNow(chat.last_updated_at, { addSuffix: true })}</span></div>- <div className="flex items-center justify-between flex-shrink-0 ml-2">+ <div className="flex items-center justify-between shrink-0 ml-2"><Button variant="ghost" size="icon" className="h-6 w-6" onClick={handleDeleteChat}><Trash className="h-3 w-3" /></Button>diff --git a/flowsint-app/src/components/flows/context-menu.tsx b/flowsint-app/src/components/flows/context-menu.tsxindex 4367e8aa..ef1669ed 100644--- a/flowsint-app/src/components/flows/context-menu.tsx+++ b/flowsint-app/src/components/flows/context-menu.tsx@@ -1,11 +1,10 @@-import { useCallback } from 'react'+import { JSX, useCallback } from 'react'import { Pencil, Trash } from 'lucide-react'-import { GraphNode } from '@/types/graph'import BaseContextMenu from '@/components/xyflow/context-menu'import { FlowNode, useFlowStore } from '@/stores/flow-store'interface GraphContextMenuProps {- node: GraphNode | FlowNode+ node: FlowNodetop?: numberleft?: numberright?: numberdiff --git a/flowsint-app/src/components/flows/editor.tsx b/flowsint-app/src/components/flows/editor.tsxindex ec65011c..c644ec77 100644--- a/flowsint-app/src/components/flows/editor.tsx+++ b/flowsint-app/src/components/flows/editor.tsx@@ -608,7 +608,11 @@ const FlowEditor = memo(({ initialEdges, initialNodes, theme, flow }: FlowEditor// #### Render ####return (<>- <div ref={reactFlowWrapper} className="w-full h-full bg-background" data-tour-id="flow-canvas">+ <div+ ref={reactFlowWrapper}+ className="w-full h-full bg-background"+ data-tour-id="flow-canvas"+ ><ReactFlownodes={nodes}edges={edges}@@ -627,13 +631,23 @@ const FlowEditor = memo(({ initialEdges, initialNodes, theme, flow }: FlowEditorcolorMode={theme}>{flowId && (- <Panel position="top-right" className="space-x-2 mt-14 mr-2 z-50 flex items-center" data-tour-id="simulation-controls">+ <Panel+ position="top-right"+ className="space-x-2 mt-14 mr-2 z-50 flex items-center"+ data-tour-id="simulation-controls"+ >{isSimulating ? (<Button size="sm" variant="outline" className="h-7" onClick={pauseSimulation}><Pause className="h-4 w-4 mr-1" /> Pause</Button>) : (- <Button size="sm" variant="default" className="h-7" onClick={handleComputeFlow} data-tour-id="compute-button">+ <Button+ size="sm"+ variant="default"+ className="h-7"+ onClick={handleComputeFlow}+ data-tour-id="compute-button"+ ><Play className="h-4 w-4 mr-1" /> Compute</Button>)}diff --git a/flowsint-app/src/components/flows/enricher-list-item.tsx b/flowsint-app/src/components/flows/enricher-list-item.tsxindex 0de40fa2..37facf27 100644--- a/flowsint-app/src/components/flows/enricher-list-item.tsx+++ b/flowsint-app/src/components/flows/enricher-list-item.tsx@@ -34,9 +34,9 @@ const EnricherItem = memo(({ enricher, category }: EnricherItemProps) => {const borderOutputColor = colors[enricher.outputs.type.toLowerCase()]const Icon =enricher.type === 'type'- ? useIcon(enricher.outputs.type.toLowerCase() as string, null)+ ? useIcon(enricher.outputs.type.toLowerCase() as string): enricher.icon- ? useIcon(enricher.icon, null)+ ? useIcon(enricher.icon): nullconst [isDialogOpen, setIsDialogOpen] = useState(false)diff --git a/flowsint-app/src/components/flows/enricher-node.tsx b/flowsint-app/src/components/flows/enricher-node.tsxindex 496d7825..67febc4b 100644--- a/flowsint-app/src/components/flows/enricher-node.tsx+++ b/flowsint-app/src/components/flows/enricher-node.tsx@@ -53,9 +53,9 @@ const EnricherNode = memo(({ data, isConnectable }: EnricherNodeProps) => {const setOpenFlowSheet = useFlowStore((state) => state.setOpenFlowSheet)const Icon =data.type === 'type'- ? useIcon(data.outputs.type.toLowerCase() as string, null)+ ? useIcon(data.outputs.type.toLowerCase() as string): data.icon- ? useIcon(data.icon, null)+ ? useIcon(data.icon): nullconst handleAddConnector = useCallback(() => {diff --git a/flowsint-app/src/components/flows/flow-navigation.tsx b/flowsint-app/src/components/flows/flow-navigation.tsxindex b335e120..fdbb152b 100644--- a/flowsint-app/src/components/flows/flow-navigation.tsx+++ b/flowsint-app/src/components/flows/flow-navigation.tsx@@ -23,7 +23,7 @@ const FlowNavigation = () => {defaultValue="flows"className="w-full h-full flex flex-col gap-0 min-h-0">- <TabsList className="w-full p-0 rounded-none my-0 border-b flex-shrink-0">+ <TabsList className="w-full p-0 rounded-none my-0 border-b shrink-0"><TabsTrigger value="flows"><Users className="h-3 w-3 opacity-60" /> Flows</TabsTrigger>diff --git a/flowsint-app/src/components/flows/flow-sheet.tsx b/flowsint-app/src/components/flows/flow-sheet.tsxindex 304f280a..55b42ed6 100644--- a/flowsint-app/src/components/flows/flow-sheet.tsx+++ b/flowsint-app/src/components/flows/flow-sheet.tsx@@ -176,9 +176,9 @@ const EnricherItem = memo(const borderOutputColor = colors[enricher.outputs.type.toLowerCase()]const Icon =enricher.type === 'type'- ? useIcon(enricher.outputs.type.toLowerCase() as string, null)+ ? useIcon(enricher.outputs.type.toLowerCase() as string): enricher.icon- ? useIcon(enricher.icon, null)+ ? useIcon(enricher.icon): nullreturn (diff --git a/flowsint-app/src/components/flows/raw-material.tsx b/flowsint-app/src/components/flows/raw-material.tsxindex 8a8fd671..f37243b2 100644--- a/flowsint-app/src/components/flows/raw-material.tsx+++ b/flowsint-app/src/components/flows/raw-material.tsx@@ -53,7 +53,7 @@ export default function RawMaterial() {)return (<div className="flex flex-col w-full h-full min-h-0 bg-card overflow-y-auto p-4">- <div className="relative mb-4 flex-shrink-0">+ <div className="relative mb-4 shrink-0"><Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" /><Inputtype="text"diff --git a/flowsint-app/src/components/flows/type-node.tsx b/flowsint-app/src/components/flows/type-node.tsxindex 045dcfbb..f28a8443 100644--- a/flowsint-app/src/components/flows/type-node.tsx+++ b/flowsint-app/src/components/flows/type-node.tsx@@ -29,7 +29,7 @@ function areEqual(prevProps: EnricherNodeProps, nextProps: EnricherNodeProps) {const TypeNode = memo(({ data }: EnricherNodeProps) => {const colors = useNodesDisplaySettings((s) => s.colors)const outputColor = colors[data.outputs.type.toLowerCase()]- const Icon = useIcon(data.outputs.type.toLowerCase() as string, null)+ const Icon = useIcon(data.outputs.type.toLowerCase() as string)const setOpenFlowSheet = useFlowStore((state) => state.setOpenFlowSheet)const key = data.outputs.properties[0].namediff --git a/flowsint-app/src/components/layout/breadcrumb.tsx b/flowsint-app/src/components/layout/breadcrumb.tsxindex 8aeea6c0..9fa8898d 100644--- a/flowsint-app/src/components/layout/breadcrumb.tsx+++ b/flowsint-app/src/components/layout/breadcrumb.tsx@@ -43,7 +43,7 @@ export function PathBreadcrumb() {<div className="w-full overflow-hidden"><Breadcrumb className="w-full"><BreadcrumbList className="flex items-center justify-start gap-1 min-w-0">- <BreadcrumbItem className="flex-shrink-0">+ <BreadcrumbItem className="shrink-0"><BreadcrumbLink asChild><Link to="/dashboard" className="truncate font-medium"><Home className="h-4 w-4 opacity-60" strokeWidth={1.4} />@@ -52,7 +52,7 @@ export function PathBreadcrumb() {</BreadcrumbItem>{isFlowPage ? (<>- <BreadcrumbSeparator className="flex-shrink-0" />+ <BreadcrumbSeparator className="shrink-0" /><BreadcrumbItem className="min-w-0"><BreadcrumbLink asChild><Link to="/dashboard/flows" className="truncate block font-medium">@@ -62,7 +62,7 @@ export function PathBreadcrumb() {</BreadcrumbItem>{flowId && (<>- <BreadcrumbSeparator className="flex-shrink-0" />+ <BreadcrumbSeparator className="shrink-0" /><BreadcrumbItem className="min-w-0 flex-1"><BreadcrumbPage className="truncate block text-muted-foreground">{isFlowLoading ? (@@ -78,7 +78,7 @@ export function PathBreadcrumb() {) : (investigationId && (<>- <BreadcrumbSeparator className="flex-shrink-0" />+ <BreadcrumbSeparator className="shrink-0" /><BreadcrumbItem className="min-w-0"><BreadcrumbLink asChild><Link@@ -96,7 +96,7 @@ export function PathBreadcrumb() {</BreadcrumbItem>{type && id && (<>- <BreadcrumbSeparator className="flex-shrink-0" />+ <BreadcrumbSeparator className="shrink-0" /><BreadcrumbItem className="min-w-0 flex-1"><BreadcrumbPage className="truncate block text-muted-foreground">{type === 'graph' ? (diff --git a/flowsint-app/src/components/map/map-panel.tsx b/flowsint-app/src/components/map/map-panel.tsxindex 051eb6ff..237b2a49 100644--- a/flowsint-app/src/components/map/map-panel.tsx+++ b/flowsint-app/src/components/map/map-panel.tsx@@ -4,12 +4,12 @@ import { LocationPoint } from './map'const MapPanel = () => {const nodes = useGraphStore((state) => state.nodes)const locationNodes = nodes- .filter((node) => node.data.type === 'location' || (node.data.latitude && node.data.longitude))+ .filter((node) => node.nodeType === 'location' || (node.nodeProperties.latitude && node.nodeProperties.longitude)).map((node) => ({- lat: node.data.latitude || 0,- lon: node.data.longitude || 0,- address: node.data.address || '',- label: node.data.label || ''+ lat: node.nodeProperties.latitude || 0,+ lon: node.nodeProperties.longitude || 0,+ address: node.nodeProperties.address || '',+ label: node.nodeProperties.label || ''}))return (<div className="w-full grow h-full">diff --git a/flowsint-app/src/components/shared/icon-picker/index.tsx b/flowsint-app/src/components/shared/icon-picker/index.tsxnew file mode 100644index 00000000..9dba655f--- /dev/null+++ b/flowsint-app/src/components/shared/icon-picker/index.tsx@@ -0,0 +1,2 @@+export { default } from './popup'+export { NodeIconTrigger } from './trigger'diff --git a/flowsint-app/src/components/sketches/settings/icon-picker/popup.tsx b/flowsint-app/src/components/shared/icon-picker/popup.tsxsimilarity index 93%rename from flowsint-app/src/components/sketches/settings/icon-picker/popup.tsxrename to flowsint-app/src/components/shared/icon-picker/popup.tsxindex 1247bbd7..3049fb15 100644--- a/flowsint-app/src/components/sketches/settings/icon-picker/popup.tsx+++ b/flowsint-app/src/components/shared/icon-picker/popup.tsx@@ -9,8 +9,6 @@ import {import { Input } from '@/components/ui/input'import { useVirtualizer } from '@tanstack/react-virtual'import * as LucideIcons from 'lucide-react'-import { useNodesDisplaySettings } from '@/stores/node-display-settings'-import { clearIconTypeCache } from '../../graph/utils/image-cache'import { cn } from '@/lib/utils'// Curated list of popular and useful Lucide icons@@ -237,12 +235,15 @@ type IconPopoverProps = {iconType: string | nullopen: booleansetOpen: Dispatch<SetStateAction<boolean>>+ onIconChange: (+ iconType: IconPopoverProps['iconType'],+ iconName: keyof typeof AVAILABLE_ICONS+ ) => void}-export default function IconPicker({ iconType, open, setOpen }: IconPopoverProps) {+export default function IconPicker({ iconType, open, setOpen, onIconChange }: IconPopoverProps) {const [search, setSearch] = useState('')const [isReady, setIsReady] = useState(false)- const { setIcon } = useNodesDisplaySettings()const parentRef = useRef<HTMLDivElement>(null)const filteredIcons = useMemo(() => {@@ -262,6 +263,14 @@ export default function IconPicker({ iconType, open, setOpen }: IconPopoverPropsoverscan: 5})+ const handleClick = (+ iconType: IconPopoverProps['iconType'],+ iconName: keyof typeof AVAILABLE_ICONS+ ) => {+ onIconChange(iconType, iconName)+ setOpen(false)+ }+// Reset and initialize when dialog opensuseEffect(() => {if (open) {@@ -278,13 +287,6 @@ export default function IconPicker({ iconType, open, setOpen }: IconPopoverProps}}, [open, virtualizer])- const handleIconSelect = (iconName: string) => {- if (!iconType) return- setIcon(iconType, iconName as keyof typeof LucideIcons)- clearIconTypeCache(iconType)- setOpen(false)- }-return (<Dialog open={open} onOpenChange={setOpen}><DialogContent className="max-w-2xl">@@ -355,7 +357,7 @@ export default function IconPicker({ iconType, open, setOpen }: IconPopoverPropsreturn (<buttonkey={iconName}- onClick={() => handleIconSelect(iconName)}+ onClick={() => handleClick(iconType, iconName)}className={cn('flex h-12 w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-2 transition-colors hover:bg-accent hover:text-accent-foreground','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring'diff --git a/flowsint-app/src/components/sketches/settings/icon-picker/trigger.tsx b/flowsint-app/src/components/shared/icon-picker/trigger.tsxsimilarity index 100%rename from flowsint-app/src/components/sketches/settings/icon-picker/trigger.tsxrename to flowsint-app/src/components/shared/icon-picker/trigger.tsxdiff --git a/flowsint-app/src/components/sketches/add-item-dialog.tsx b/flowsint-app/src/components/sketches/add-item-dialog.tsxindex 21d896bf..01096ac1 100644--- a/flowsint-app/src/components/sketches/add-item-dialog.tsx+++ b/flowsint-app/src/components/sketches/add-item-dialog.tsx@@ -75,41 +75,34 @@ export default function AddItemDialog() {const label_key =currentNodeType.fields.find((f: FormField) => f.name === currentNodeType.label_key)?.name ||currentNodeType.fields[0].name+const type = currentNodeType.type- const label = data[label_key as keyof typeof data]+ let label = data[label_key as keyof typeof data]+ // if no value, fallback to fist key+ if (!label) label = data[Object.keys(data)[0] as keyof typeof data]// Get viewport center for positioning new nodeconst center = getViewportCenter()const nodeX = center?.x ?? 0const nodeY = center?.y ?? 0+ const tempId = generateTempId()// Node data for API (with correct structure)- const newNode = {- type: type.toLowerCase(), // Required at root level for API validation- label: label,- data: {- ...flattenObj(data),- label,- type: type.toLowerCase(),- x: nodeX, // Position at viewport center- y: nodeY- }- }-- // Generate temporary ID for optimistic update- const tempId = generateTempId()- // Optimistically add the node to local state with temporary ID and position fieldsconst nodeWithTempId: GraphNode = {id: tempId,- data: {- ...newNode.data,- id: tempId,- created_at: new Date().toISOString()- },- // Position fields for client-side graph rendering (at viewport center)- x: nodeX,- y: nodeY+ nodeType: type.toLowerCase(), // Required at root level for API validation+ nodeLabel: label,+ x: nodeX, // Position at viewport center+ y: nodeY,+ nodeSize: 4,+ nodeColor: null,+ nodeFlag: null,+ nodeIcon: null,+ nodeImage: null,+ nodeProperties: flattenObj(data),+ nodeMetadata: {}}+if (addNode) {addNode(nodeWithTempId)}@@ -118,7 +111,7 @@ export default function AddItemDialog() {if (relatedNodeToAdd) {const tempEdgePayload = {type: 'custom',- label: `HAS_${newNode.data.type.toUpperCase()}`,+ label: `HAS_${nodeWithTempId.nodeType.toUpperCase()}`,source: relatedNodeToAdd.id,target: tempId}@@ -138,7 +131,7 @@ export default function AddItemDialog() {// Show optimistic success messagetoast(`New ${type.toLowerCase()} added to sketch.`, {description: relatedNodeToAdd- ? `A new ${type.toLowerCase()} "${label}" was added to relation ${relatedNodeToAdd.data.label}.`+ ? `A new ${type.toLowerCase()} "${label}" was added to relation ${relatedNodeToAdd.nodeLabel}.`: `A new ${type.toLowerCase()} "${label}" was added.`,action: {label: 'Beautify layout',@@ -150,16 +143,17 @@ export default function AddItemDialog() {// Create the node via API to get the real database IDconst newNodeResponse = await sketchService.addNode(sketch_id as string,- JSON.stringify(newNode)+ JSON.stringify(nodeWithTempId))- if (newNodeResponse.node && replaceNode) {- replaceNode(tempId, newNodeResponse.node.data)+ const newNode: GraphNode = newNodeResponse.node+ if (newNode && replaceNode) {+ replaceNode(tempId, newNode.id, newNode.nodeProperties)if (relatedNodeToAdd && tempEdgeId) {const relationPayload = {source: relatedNodeToAdd.id,- target: newNodeResponse.node.id,+ target: newNode.id,type: 'one-way',- label: `HAS_${newNode.data.type.toUpperCase()}`+ label: `HAS_${nodeWithTempId.nodeType.toUpperCase()}`}// Make API call to persist the edgeawait sketchService.addEdge(sketch_id as string, JSON.stringify(relationPayload))@@ -247,7 +241,7 @@ export default function AddItemDialog() {: 'Select an item to insert'}{relatedNodeToAdd && (<span className="text-primary truncate max-w-[50%] text-ellipsis font-semibold ml-1">- {relatedNodeToAdd.data.label}+ {relatedNodeToAdd.nodeLabel}</span>)}</div>diff --git a/flowsint-app/src/components/sketches/create-relation.tsx b/flowsint-app/src/components/sketches/create-relation.tsxindex 0d3b781f..5ef04e1f 100644--- a/flowsint-app/src/components/sketches/create-relation.tsx+++ b/flowsint-app/src/components/sketches/create-relation.tsx@@ -16,6 +16,7 @@ import { sketchService } from '@/api/sketch-service'import { useParams } from '@tanstack/react-router'import { useIcon } from '@/hooks/use-icon'import { RadioGroupItem } from '@/components/ui/radio-group'+import { type GraphNode } from '@/types'export function CreateRelationDialog() {const { id: sketchId } = useParams({ strict: false })@@ -63,7 +64,7 @@ export function CreateRelationDialog() {return (<Dialog open={openAddRelationDialog} onOpenChange={setOpenAddRelationDialog}>- <DialogContent className="!w-full !max-w-[600px]">+ <DialogContent className="w-full! max-w-[600px]!"><DialogHeader><DialogTitle className="flex items-center gap-2"><GitPullRequestArrow className="h-4 w-4" />@@ -131,7 +132,7 @@ export function CreateRelationDialog() {))}</div>- <div className="flex items-center truncate justify-center px-2 flex-shrink-0 min-w-0 grow">+ <div className="flex items-center truncate justify-center px-2 shrink-0 min-w-0 grow"><div className="flex items-center gap-1 text-xs text-muted-foreground"><div className="h-px bg-muted-foreground/30 flex-1"></div><span className="px-2 py-1 bg-muted/50 rounded-sm truncate">@@ -172,7 +173,7 @@ export function CreateRelationDialog() {}interface NodeDisplayCardProps {- node: any+ node: GraphNodevariant?: 'default' | 'preview'asRadio?: booleanradioValue?: string@@ -186,19 +187,20 @@ export function NodeDisplayCard({radioValue,id}: NodeDisplayCardProps) {- const NodeIcon = useIcon(node.data?.type, node.data?.src)-- const getNodeDisplayName = (node: any) => {- return node.data?.label || node.data?.username || node.id- }-+ const NodeIcon = useIcon(node.nodeType, {+ nodeColor: node.nodeColor,+ nodeIcon: node.nodeIcon,+ nodeImage: node.nodeImage+ })if (variant === 'preview') {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} /></div>- <span className="text-xs text-muted-foreground max-w-[200px] truncate">{getNodeDisplayName(node)}</span>+ <span className="text-xs text-muted-foreground max-w-[200px] truncate">+ {node.nodeLabel}+ </span></div>)}@@ -214,7 +216,7 @@ export function NodeDisplayCard({<div className="flex items-center justify-center w-5 h-5 rounded-full bg-muted"><NodeIcon size={16} /></div>- <span className="text-sm max-w-[200px] truncate">{getNodeDisplayName(node)}</span>+ <span className="text-sm max-w-[200px] truncate">{node.nodeLabel}</span></div></label>)@@ -225,7 +227,7 @@ export function NodeDisplayCard({<div className="flex items-center justify-center w-5 h-5 rounded-full bg-muted"><NodeIcon size={16} /></div>- <span className="text-sm max-w-[200px] truncate">{getNodeDisplayName(node)}</span>+ <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 6eeb96ef..2835633d 100644--- a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx+++ b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx@@ -1,252 +1,552 @@-import { memo, useCallback } from 'react'+'use client'++import type React from 'react'++import { memo, useState, useEffect, useCallback } from 'react'import { cn } from '@/lib/utils'import { CopyButton } from '@/components/copy'-import { Check, Rocket, X, MousePointer, Link2 } from 'lucide-react'+import { X, Loader2, Rocket, Link2, MousePointer } from 'lucide-react'import LaunchFlow from '../launch-enricher'-import NodeActions from '../graph/actions/node-actions'-import { Button } from '../../ui/button'+import NodeActions from '../graph/node/actions/node-actions'import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/tooltip'import { useParams } from '@tanstack/react-router'-import NeighborsGraph from './neighbors'-import Relationships from './relationships'-import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '../../ui/resizable'import { useGraphStore } from '@/stores/graph-store'-import { Badge } from '@/components/ui/badge'import DOMPurify from 'dompurify'import { useIcon } from '@/hooks/use-icon'+import { Switch } from '@/components/ui/switch'+import type { GraphNode, NodeProperties, NodeMetadata } from '@/types'+import { sketchService } from '@/api/sketch-service'+import { toast } from 'sonner'+import { useMutation, useQueryClient } from '@tanstack/react-query'+import { queryKeys } from '@/api/query-keys'+import IconPicker from '@/components/shared/icon-picker'+import { ResizableDetailsPanel, Row } from './resizable-details-panels'+import Relationships from './relationships'+import NeighborsGraph from './neighbors'+// Types+type FormData = {+ nodeLabel: string+ nodeColor: string | null+ nodeIcon: string | null+ nodeImage: string | null+ nodeFlag: string | null+ nodeProperties: NodeProperties+ nodeMetadata: NodeMetadata+ notes: string+}++// Constants+const COLORS = [+ { name: 'default', value: null },+ { name: 'red', value: '#ef4444' },+ { name: 'orange', value: '#f97316' },+ { name: 'yellow', value: '#eab308' },+ { name: 'green', value: '#22c55e' },+ { name: 'blue', value: '#3b82f6' },+ { name: 'purple', value: '#a855f7' },+ { name: 'pink', value: '#ec4899' }+]++// Extended Row Component with copy support+const RowWithCopy = memo(+ ({+ label,+ copyValue,+ children+ }: {+ label: string+ copyValue?: string+ children: React.ReactNode+ }) => (+ <div className="flex items-center justify-between py-1.5 group hover:bg-muted/20 -mx-2 px-2 rounded-sm transition-colors">+ <span className="text-[13px] text-muted-foreground">{label.replace(/_/g, ' ')}</span>+ <div className="text-[13px] text-foreground flex items-center gap-1">+ {copyValue && (+ <CopyButton+ content={copyValue}+ className="h-4 w-4 opacity-0 group-hover:opacity-60 transition-opacity"+ />+ )}+ {children}+ </div>+ </div>+ )+)+RowWithCopy.displayName = 'RowWithCopy'+// Status Code Badge+const StatusCodeBadge = memo(({ statusCode }: { statusCode: number }) => {+ const category = Math.floor(statusCode / 100)+ const colors: Record<number, string> = {+ 1: 'text-blue-600',+ 2: 'text-green-600',+ 3: 'text-purple-600',+ 4: 'text-orange-600',+ 5: 'text-red-600'+ }+ return <span className={cn('font-medium', colors[category])}>{statusCode}</span>+})++// Helpers+const formatValue = (value: any): string => {+ if (value === null || value === undefined) return '—'+ if (typeof value === 'boolean') return value ? 'Yes' : 'No'+ if (typeof value === 'object') return JSON.stringify(value)+ return String(value)+}++const formatDate = (value: any): string => {+ if (!value) return '—'+ try {+ return new Date(value).toLocaleDateString('en-US', {+ month: 'short',+ day: 'numeric',+ year: 'numeric',+ hour: '2-digit',+ minute: '2-digit'+ })+ } catch {+ return String(value)+ }+}++// Main Componentconst DetailsPanel = memo(() => {const { id: sketchId } = useParams({ strict: false })const nodesLength = useGraphStore((s) => s.nodesLength)const node = useGraphStore((s) => s.getCurrentNode())- const NodeIcon = useIcon(node?.data?.type || 'default')const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)+ const updateNode = useGraphStore((s) => s.updateNode)++ const [openIconPicker, setOpenIconPicker] = useState(false)+ const [isSaving, setIsSaving] = useState(false)+ const [hasChanges, setHasChanges] = useState(false)++ const [formData, setFormData] = useState<FormData>({+ nodeLabel: '',+ nodeColor: null,+ nodeIcon: null,+ nodeImage: null,+ nodeFlag: null,+ nodeProperties: {},+ nodeMetadata: {},+ notes: ''+ })++ const IconComponent = useIcon(node?.nodeType as string, {+ nodeColor: node?.nodeColor,+ nodeIcon: node?.nodeIcon,+ nodeImage: node?.nodeImage+ })++ // Sync form data when node changes+ useEffect(() => {+ if (node) {+ const { nodeLabel, nodeImage, nodeIcon, nodeFlag, nodeColor, nodeMetadata, nodeProperties } =+ node+ setFormData({+ nodeLabel: nodeLabel || '',+ nodeProperties: nodeProperties || {},+ nodeMetadata: nodeMetadata || {},+ nodeColor,+ nodeIcon,+ nodeImage,+ nodeFlag,+ notes: (nodeMetadata?.notes as string) || ''+ })+ setHasChanges(false)+ }+ }, [node])++ const queryClient = useQueryClient()++ // Mutation+ const updateNodeMutation = useMutation({+ mutationFn: async ({+ sketchId,+ body+ }: {+ sketchId: string+ body: { nodeId: string; updates: Partial<GraphNode> }+ }) => {+ return sketchService.updateNode(sketchId, JSON.stringify(body))+ },+ onSuccess: (result) => {+ if (result.status === 'node updated' && node) {+ const { notes, ...rest } = formData+ const updates = { ...rest, nodeMetadata: { ...rest.nodeMetadata, notes } }+ updateNode(node.id, updates as Partial<GraphNode>)+ if (sketchId) {+ queryClient.invalidateQueries({ queryKey: queryKeys.sketches.detail(sketchId) })+ queryClient.invalidateQueries({ queryKey: queryKeys.sketches.graph(sketchId, sketchId) })+ }+ toast.success('Saved')+ setHasChanges(false)+ } else {+ toast.error('Failed to update')+ }+ },+ onError: (error) => {+ console.log(error)+ toast.error('Failed to save')+ }+ })++ const handleSave = useCallback(async () => {+ if (!node || !sketchId) return+ setIsSaving(true)+ try {+ const { notes, ...rest } = formData+ const updateData = {+ nodeId: node.id,+ updates: {+ ...rest,+ nodeType: node.nodeType,+ nodeMetadata: { ...rest.nodeMetadata, notes }+ } as Partial<GraphNode>+ }+ await updateNodeMutation.mutateAsync({ sketchId, body: updateData })+ } catch (error) {+ console.error('Error updating node:', error)+ } finally {+ setIsSaving(false)+ }+ }, [node, sketchId, formData, updateNodeMutation])const handleClose = useCallback(() => {setCurrentNodeId(null)+ }, [setCurrentNodeId])++ const handleChange = useCallback(<K extends keyof FormData>(key: K, value: FormData[K]) => {+ setFormData((prev) => ({ ...prev, [key]: value }))+ setHasChanges(true)+ }, [])++ const handlePropertyChange = useCallback((key: string, value: string | boolean) => {+ setFormData((prev) => ({+ ...prev,+ nodeProperties: { ...prev.nodeProperties, [key]: value }+ }))+ setHasChanges(true)}, [])+ const handleIconSelect = useCallback(+ (_iconType: string, iconName: string | null) => {+ handleChange('nodeIcon', iconName)+ },+ [handleChange]+ )++ // Empty stateif (!node) {return (- <div className="flex flex-col items-center justify-center h-full text-center p-8">- <div className="w-16 h-16 bg-muted rounded-full flex items-center justify-center mb-4">- <MousePointer className="h-8 w-8 text-muted-foreground" />- </div>- <h3 className="text-lg font-semibold text-foreground mb-2">No Node Selected</h3>- <p className="text-sm text-muted-foreground max-w-xs">- Click on any node in the graph to view its details and properties- </p>+ <div className="flex flex-col items-center justify-center h-full p-8">+ <MousePointer className="h-5 w-5 text-muted-foreground/40 mb-3" />+ <p className="text-[13px] text-muted-foreground/60">Select a node</p></div>)}+ const propertiesFields = Object.entries(formData.nodeProperties)+ const metadataFields = Object.entries(formData.nodeMetadata).filter(([key]) => key !== 'notes')+ const description = node.nodeProperties?.description as string | undefined+return (- <div className="flex flex-col h-full overflow-hidden bg-card">- <div className="flex items-center sticky w-full top-0 border-b justify-start pr-4 pl-2 py-2 h-10 gap-2 bg-card/90 backdrop-blur-md ">- <Button- onClick={handleClose}- size={'icon'}- variant={'ghost'}- className="h-7 w-7 hover:bg-accent rounded-full"- >- <X />- </Button>- <div className="grow" />- <div className="flex items-center">- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <div>- <LaunchFlow values={[node.id]} type={node.data?.type}>- <Button- variant="ghost"- size="sm"- className="h-6 w-6 p-0 hover:bg-muted opacity-70 hover:opacity-100"- >- <Rocket className="h-3 w-3" strokeWidth={2} />- </Button>- </LaunchFlow>- </div>- </TooltipTrigger>- <TooltipContent>- <p>Launch enricher</p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- {node && <NodeActions node={node} />}- </div>- </div>- <div className="px-4 pt-4 pb-4 border-b">- <div className="flex items-start gap-3">- {/* Icon */}- <div className="shrink-0">- <NodeIcon size={38} />- </div>+ <div className="flex flex-col h-full bg-card border-border">+ {/* Header - Minimal */}+ <div className="h-10 border-b flex w-full bg-red-5 items-center justify-between">+ <div className="px-4 flex items-start w-full justify-between gap-3">+ <div className="flex items-start gap-2.5 flex-1 min-w-0">+ <button+ onClick={() => setOpenIconPicker(true)}+ className="shrink-0 hover:opacity-70 transition-opacity"+ >+ <IconComponent size={18} />+ </button>- {/* Content */}- <div className="flex-1 min-w-0 space-y-2">- <div className="flex items-center gap-2 flex-wrap">- <h2 className="text-xl font-bold truncate">{node.data?.label}</h2>- <CopyButton className="h-4 w-4" content={node.data.label} />+ <div className="flex-1 min-w-0">+ <input+ type="text"+ value={formData.nodeLabel}+ onChange={(e) => handleChange('nodeLabel', e.target.value)}+ className="w-full text-md font-medium bg-transparent outline-none placeholder:text-muted-foreground/40 focus:bg-muted/20 -ml-1 px-1 rounded transition-colors"+ placeholder="Untitled"+ />+ {/*<span className="text-[11px] text-muted-foreground/60 ml-0.5">{node.nodeType}</span>*/}</div>- {node.data?.type && (- <Badge variant="secondary" className="text-xs">- {node.data.type}- </Badge>- )}+ </div>++ <div className="flex items-center gap-0.5 shrink-0">+ <TooltipProvider delayDuration={300}>+ <Tooltip>+ <TooltipTrigger asChild>+ <div>+ <LaunchFlow values={[node.id]} type={node.nodeType}>+ <button className="p-1.5 text-muted-foreground/50 hover:text-muted-foreground rounded transition-colors">+ <Rocket className="h-3.5 w-3.5" />+ </button>+ </LaunchFlow>+ </div>+ </TooltipTrigger>+ <TooltipContent side="bottom">+ <p className="text-xs">Enrich</p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <NodeActions node={node} />+ <button+ onClick={handleClose}+ className="p-1.5 text-muted-foreground/50 hover:text-muted-foreground rounded transition-colors"+ >+ <X className="h-3.5 w-3.5" />+ </button></div></div></div>- <div className="flex-1 min-h-0">- <ResizablePanelGroup direction="vertical" className="h-full">- <ResizablePanel defaultSize={30} minSize={20}>- <div className="h-full overflow-auto">- {node.data?.description && (- <div className="px-4 py-3 border-b border-border">- <div- className="text-sm text-muted-foreground prose dark:prose-invert prose-sm max-w-none"- dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(node.data.description) }}- />- </div>- )}- <MemoizedKeyValueDisplay data={node.data} />- </div>- </ResizablePanel>- <ResizableHandle />- <ResizablePanel defaultSize={40} minSize={25}>- <div className="h-full w-full p-3">- <NeighborsGraph- nodeLength={nodesLength}- sketchId={sketchId as string}- nodeId={node.id}- />- </div>- </ResizablePanel>- <ResizableHandle />- <ResizablePanel defaultSize={30} minSize={20}>- <Relationships- nodeLength={nodesLength}- sketchId={sketchId as string}- nodeId={node.id}- />- </ResizablePanel>- </ResizablePanelGroup>- </div>- </div>- )-})-export default DetailsPanel--interface KeyValueDisplayProps {- data: Record<string, any>- className?: string-}+ {/* Description */}+ {description && (+ <div className="py-2 px-4 border-b border-border/50 shrink-0">+ <div+ className="text-[13px] text-muted-foreground leading-relaxed"+ dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(description) }}+ />+ </div>+ )}-function KeyValueDisplay({ data, className }: KeyValueDisplayProps) {- return (- <div className={cn('w-full border-collapse', className)}>- {data &&- Object.entries(data)- .filter(- ([key]) =>- !['id', 'sketch_id', 'caption', 'size', 'color', 'description', 'x', 'y'].includes(- key- )- )- .map(([key, value], index) => {- let val: string | null = null- let display: React.ReactNode = null- if (typeof value === 'number') {- val = value.toString()- display = <StatusCodeBadge statusCode={value} />- } else if (typeof value === 'boolean') {- val = value.toString()- display = value ? (- <Check className="h-4 w-4 text-green-600" />- ) : (- <X className="h-4 w-4 text-red-600" />- )- } else if (typeof value === 'object') {- val = value?.['label'] ?? 'N/A'- display = val- } else if (Array.isArray(value)) {- val = `${value.length} items`- display = val- } else {- val = value?.toString() || null- display =- typeof val === 'string' && val.startsWith('https://') ? (- <a- href={val}- className="underline text-primary truncate"- target="_blank"- rel="noopener noreferrer"- >- {val}- </a>+ {/* Content - Resizable Panels */}+ <ResizableDetailsPanel+ className="flex-1 min-h-0"+ sections={[+ {+ id: 'properties',+ label: 'Properties',+ defaultOpen: true,+ defaultSize: 25,+ minSize: 10,+ content: (+ <div className="p-3">+ {propertiesFields.length > 0 ? (+ propertiesFields.map(([key, value]) => (+ <RowWithCopy+ key={key}+ label={key}+ copyValue={typeof value === 'string' ? value : undefined}+ >+ {typeof value === 'boolean' ? (+ <Switch+ checked={value}+ onCheckedChange={(checked) => handlePropertyChange(key, checked)}+ className="scale-75"+ />+ ) : typeof value === 'number' ? (+ <StatusCodeBadge statusCode={value} />+ ) : typeof value === 'string' && value.startsWith('https://') ? (+ <a+ href={value}+ target="_blank"+ rel="noopener noreferrer"+ className="text-muted-foreground hover:text-foreground flex items-center gap-1 text-[12px] transition-colors"+ >+ <Link2 className="h-3 w-3" />+ <span className="truncate max-w-[100px]">{new URL(value).hostname}</span>+ </a>+ ) : (+ <input+ type="text"+ value={String(value || '')}+ onChange={(e) => handlePropertyChange(key, e.target.value)}+ className="w-28 text-right text-[12px] bg-transparent outline-none placeholder:text-muted-foreground/30 focus:bg-muted/20 px-1 rounded transition-colors truncate"+ placeholder="Empty"+ />+ )}+ </RowWithCopy>+ ))) : (- val- )- }-- return (- <div- key={index}- className="flex w-full bg-card items-center divide-x divide-border border-b border-border p-0"- >- <div className="w-1/2 px-4 p-2 text-sm text-muted-foreground font-normal truncate">- {key}- </div>- <div className="w-1/2 px-4 p-2 text-sm font-medium flex items-center justify-between min-w-0">- <div className="truncate font-semibold">- {display || <span className="italic text-muted-foreground">N/A</span>}+ <p className="text-[12px] text-muted-foreground/40 py-1">No properties</p>+ )}+ </div>+ )+ },+ {+ id: 'neighbors',+ label: 'Neighbors',+ defaultOpen: true,+ defaultSize: 40,+ minSize: 25,+ content: (+ <div className="h-full overflow-hidden">+ <NeighborsGraph+ sketchId={sketchId as string}+ currentNode={node}+ nodeLength={nodesLength}+ />+ </div>+ )+ },+ {+ id: 'relations',+ label: 'Relations',+ defaultOpen: true,+ defaultSize: 20,+ minSize: 15,+ content: (+ <div className="h-full p-3">+ <Relationships+ sketchId={sketchId as string}+ nodeId={node.id}+ nodeLength={nodesLength}+ />+ </div>+ )+ },+ {+ id: 'appearance',+ label: 'Appearance',+ defaultOpen: false,+ fixedSize: 12,+ minSize: 10,+ content: (+ <div className="p-3">+ <Row label="Color">+ <div className="flex items-center gap-1">+ {COLORS.map((color) => (+ <button+ key={color.name}+ onClick={() => handleChange('nodeColor', color.value)}+ className={cn(+ 'w-3 h-3 rounded-full transition-all',+ color.value ? '' : 'bg-muted-foreground/20',+ formData.nodeColor === color.value &&+ 'ring-1 ring-offset-1 ring-offset-background ring-foreground/30'+ )}+ style={color.value ? { backgroundColor: color.value } : undefined}+ />+ ))}</div>- {display && val && typeof value !== 'boolean' && (- <CopyButton className="h-6 w-6 shrink-0" content={val} />- )}- </div>+ </Row>+ <Row label="Icon">+ <button+ onClick={() => setOpenIconPicker(true)}+ className="text-[12px] text-muted-foreground hover:text-foreground transition-colors"+ >+ {formData.nodeIcon || 'Default'}+ </button>+ </Row>+ <Row label="Image">+ <input+ type="text"+ value={formData.nodeImage || ''}+ onChange={(e) => handleChange('nodeImage', e.target.value || null)}+ className="w-24 text-right text-[12px] bg-transparent outline-none placeholder:text-muted-foreground/30 focus:bg-muted/20 px-1 rounded transition-colors"+ placeholder="URL..."+ />+ </Row></div>)- })}- </div>- )-}--export const MemoizedKeyValueDisplay = memo(KeyValueDisplay)--interface StatusCodeBadgeProps {- statusCode: number-}-export function StatusCodeBadge({ statusCode }: StatusCodeBadgeProps) {- const category = Math.floor(statusCode / 100)-- const variants = {- 1: 'bg-blue-100 text-blue-800 border-blue-300',- 2: 'bg-green-100 text-green-800 border-green-300',- 3: 'bg-purple-100 text-purple-800 border-purple-300',- 4: 'bg-orange-100 text-orange-800 border-orange-300',- 5: 'bg-red-100 text-red-800 border-red-300'- }-- const labels = {- 1: 'Informational',- 2: 'Success',- 3: 'Redirect',- 4: 'Client Error',- 5: 'Server Error'- }+ },+ {+ id: 'metadata',+ label: 'Metadata',+ defaultOpen: false,+ defaultSize: 20,+ minSize: 10,+ content: (+ <div className="p-3">+ {metadataFields.length > 0 ? (+ metadataFields.map(([key, value]) => (+ <RowWithCopy+ key={key}+ label={key}+ copyValue={typeof value === 'string' ? value : undefined}+ >+ {key.includes('_at') || key.includes('date')+ ? formatDate(value)+ : formatValue(value)}+ </RowWithCopy>+ ))+ ) : (+ <p className="text-[12px] text-muted-foreground/40 py-1">No metadata</p>+ )}+ </div>+ )+ }+ // {+ // id: 'notes',+ // label: 'Notes',+ // defaultOpen: false,+ // defaultSize: 15,+ // minSize: 10,+ // content: (+ // <textarea+ // value={formData.notes}+ // onChange={(e) => handleChange('notes', e.target.value)}+ // placeholder="Add notes..."+ // className="w-full h-full text-[13px] bg-transparent outline-none resize-none placeholder:text-muted-foreground/30 leading-relaxed"+ // />+ // )+ // },+ ]}+ />- return (- <Badge- variant="outline"- className={cn(- 'text-xs',- variants[category as keyof typeof variants] || 'bg-gray-100 text-gray-800'+ {/* Footer - Save bar */}+ {hasChanges && (+ <div className="px-4 py-2.5 border-t border-border">+ <div className="flex items-center justify-between">+ <span className="text-[11px] text-muted-foreground/60">Unsaved changes</span>+ <div className="flex items-center gap-2">+ <button+ onClick={() => {+ if (node) {+ const {+ nodeLabel,+ nodeImage,+ nodeIcon,+ nodeFlag,+ nodeColor,+ nodeMetadata,+ nodeProperties+ } = node+ setFormData({+ nodeLabel: nodeLabel || '',+ nodeProperties: nodeProperties || {},+ nodeMetadata: nodeMetadata || {},+ nodeColor,+ nodeIcon,+ nodeImage,+ nodeFlag,+ notes: (nodeMetadata?.notes as string) || ''+ })+ setHasChanges(false)+ }+ }}+ className="text-[11px] text-muted-foreground/60 hover:text-muted-foreground transition-colors"+ >+ Discard+ </button>+ <button+ onClick={handleSave}+ disabled={isSaving}+ className="text-[11px] bg-foreground text-background px-2.5 py-1 rounded hover:opacity-80 transition-opacity flex items-center gap-1"+ >+ {isSaving && <Loader2 className="h-3 w-3 animate-spin" />}+ {isSaving ? 'Saving' : 'Save'}+ </button>+ </div>+ </div>+ </div>)}- >- {statusCode}- {/* {labels[category as keyof typeof labels]} */}- </Badge>++ <IconPicker+ // @ts-ignore+ onIconChange={handleIconSelect}+ open={openIconPicker}+ setOpen={setOpenIconPicker}+ iconType={null}+ />+ </div>)-}+})++export default DetailsPanel+export { StatusCodeBadge }diff --git a/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx b/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsxindex 4f33382c..96506631 100644--- a/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx+++ b/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx@@ -28,8 +28,16 @@ const EdgeDetailsPanel = memo(() => {const sourceNode = edge ? nodes.find((n) => n.id === edge.source) : nullconst targetNode = edge ? nodes.find((n) => n.id === edge.target) : null- const SourceIcon = useIcon(sourceNode?.data?.type ?? 'default', sourceNode?.data?.src)- const TargetIcon = useIcon(targetNode?.data?.type ?? 'default', targetNode?.data?.src)+ const SourceIcon = useIcon(sourceNode?.nodeType ?? 'default', {+ nodeColor: sourceNode?.nodeColor,+ nodeIcon: sourceNode?.nodeIcon,+ nodeImage: sourceNode?.nodeImage+ })+ const TargetIcon = useIcon(targetNode?.nodeType ?? 'default', {+ nodeColor: targetNode?.nodeColor,+ nodeIcon: targetNode?.nodeIcon,+ nodeImage: targetNode?.nodeImage+ })const handleInputChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {e.stopPropagation()@@ -173,31 +181,31 @@ const EdgeDetailsPanel = memo(() => {onClick={handleJumpToSource}className="flex-1 flex items-center gap-2 p-2 rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors group min-w-0">- <div className="flex items-center justify-center w-6 h-6 rounded-full bg-background flex-shrink-0">+ <div className="flex items-center justify-center w-6 h-6 rounded-full bg-background shrink-0"><SourceIcon className="h-3 w-3" /></div><div className="flex-1 min-w-0 text-left"><p className="text-[10px] text-muted-foreground mb-0.5">Source</p><p className="text-xs font-medium truncate group-hover:text-primary transition-colors">- {sourceNode?.data?.label || 'Unknown'}+ {sourceNode?.nodeLabel || 'Unknown'}</p></div></button>- <ArrowRight className="h-4 w-4 text-muted-foreground flex-shrink-0" />+ <ArrowRight className="h-4 w-4 text-muted-foreground shrink-0" />{/* Target Node */}<buttononClick={handleJumpToTarget}className="flex-1 flex items-center gap-2 p-2 rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors group min-w-0">- <div className="flex items-center justify-center w-6 h-6 rounded-full bg-background flex-shrink-0">+ <div className="flex items-center justify-center w-6 h-6 rounded-full bg-background shrink-0"><TargetIcon className="h-3 w-3" /></div><div className="flex-1 min-w-0 text-left"><p className="text-[10px] text-muted-foreground mb-0.5">Target</p><p className="text-xs font-medium truncate group-hover:text-primary transition-colors">- {targetNode?.data?.label || 'Unknown'}+ {targetNode?.nodeLabel || 'Unknown'}</p></div></button>@@ -267,7 +275,7 @@ const EdgeDetailsPanel = memo(() => {</div><div className="w-1/2 px-3 py-1.5 text-xs font-medium flex items-center justify-between min-w-0 gap-1"><div className="flex items-center gap-1.5 min-w-0">- <div className="h-1.5 flex-1 min-w-[40px] max-w-[60px] bg-muted rounded-full overflow-hidden">+ <div className="h-1.5 flex-1 min-w-10 max-w-[60px] bg-muted rounded-full overflow-hidden"><divclassName={cn('h-full rounded-full transition-all',diff --git a/flowsint-app/src/components/sketches/details-panel/neighbors.tsx b/flowsint-app/src/components/sketches/details-panel/neighbors.tsxindex af02f3c8..83878a51 100644--- a/flowsint-app/src/components/sketches/details-panel/neighbors.tsx+++ b/flowsint-app/src/components/sketches/details-panel/neighbors.tsx@@ -1,22 +1,61 @@+import { memo, useRef, useMemo, useCallback } from 'react'import { sketchService } from '@/api/sketch-service'import { useQuery } from '@tanstack/react-query'import ForceGraphViewer from '../graph-viewer'import Loader from '@/components/loader'-import { memo, useRef } from 'react'+import { GraphNode } from '@/types'+import { RotateCcw } from 'lucide-react'+import { Button } from '@/components/ui/button'const NeighborsGraph = memo(- ({ sketchId, nodeId, nodeLength }: { sketchId: string; nodeId: string; nodeLength: number }) => {+ ({+ sketchId,+ currentNode,+ nodeLength+ }: {+ sketchId: string+ currentNode: GraphNode+ nodeLength: number+ }) => {const containerRef = useRef<HTMLDivElement>(null)- const { data: neighborsData, isLoading } = useQuery({- queryKey: ['neighbors', sketchId, nodeId, nodeLength],- queryFn: () => sketchService.getNodeNeighbors(sketchId, nodeId)+ const {+ data: neighborsData,+ isLoading,+ error,+ refetch+ } = useQuery({+ queryKey: ['neighbors', sketchId, currentNode.id, nodeLength],+ queryFn: () => sketchService.getNodeNeighbors(sketchId, currentNode.id)})++ // omit x and y positions to let the GraphViewer manange the forces+ const nodes = useMemo(+ () =>+ neighborsData?.nds.map(+ ({ id, nodeType, nodeColor, nodeIcon, nodeLabel, nodeImage }: GraphNode) => ({+ id,+ nodeType,+ nodeColor,+ nodeIcon,+ nodeLabel,+ nodeImage+ })+ ),+ [neighborsData?.nds]+ )+ const handleRefetch = useCallback(() => {+ refetch()+ }, [])++ if (error)+ return (+ <div className="flex items-center justify-center h-full text-muted-foreground text-sm">+ Could not load neighbors.+ </div>+ )return (- <div- ref={containerRef}- className="overflow-hidden bg-background border relative h-full w-full"- >+ <div ref={containerRef} className="overflow-hidden bg-background relative h-full w-full">{isLoading ? (<div className="flex items-center justify-center grow h-full"><Loader />@@ -27,8 +66,14 @@ const NeighborsGraph = memo(<span className="font-semibold">{neighborsData.nds.length - 1}</span><span className="opacity-70">neighbor(s)</span></div>++ <div className="top-.5 p-1 right-8 bg-card/60 backdrop-blur z-10 rounded-br-lg absolute text-sm flex gap-1">+ <Button onClick={handleRefetch} variant={'ghost'} size={'icon'} className="h-6 w-6">+ <RotateCcw className="h-3.5 w-3.5 opacity-70" />+ </Button>+ </div><ForceGraphViewer- nodes={neighborsData.nds}+ nodes={nodes}edges={neighborsData.rls}onNodeClick={() => {}}onNodeRightClick={() => {}}diff --git a/flowsint-app/src/components/sketches/details-panel/node-editor-modal.tsx b/flowsint-app/src/components/sketches/details-panel/node-editor-modal.tsxdeleted file mode 100644index 22937a92..00000000--- a/flowsint-app/src/components/sketches/details-panel/node-editor-modal.tsx+++ /dev/null@@ -1,348 +0,0 @@-import React, { useState, useEffect } from 'react'-import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetFooter } from '@/components/ui/sheet'-import { Button } from '@/components/ui/button'-import { Input } from '@/components/ui/input'-import { Label } from '@/components/ui/label'-import { Textarea } from '@/components/ui/textarea'-import { Badge } from '@/components/ui/badge'-import { Edit3, Save, X, Type, FileText, Check, Loader2 } from 'lucide-react'-import type { NodeData } from '@/types'-import { useGraphStore } from '@/stores/graph-store'-import { MapFromAddress } from '../../map/map'-import { sketchService } from '@/api/sketch-service'-import { useParams } from '@tanstack/react-router'-import { toast } from 'sonner'-import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'-import { useIcon } from '@/hooks/use-icon'-import { useMutation, useQueryClient } from '@tanstack/react-query'-import { queryKeys } from '@/api/query-keys'--export const NodeEditorModal: React.FC = () => {- const currentNode = useGraphStore((state) => state.getCurrentNode())- const openNodeEditorModal = useGraphStore((state) => state.openNodeEditorModal)- const setOpenNodeEditorModal = useGraphStore((state) => state.setOpenNodeEditorModal)- const updateNode = useGraphStore((state) => state.updateNode)- const { id: sketchId } = useParams({ strict: false })- const IconComponent = useIcon(- currentNode?.data.type as string,- currentNode?.data?.src as string | null- )-- const [formData, setFormData] = useState<Partial<NodeData>>({- label: '',- caption: '',- type: ''- })-- const [isSaving, setIsSaving] = useState(false)-- // Update form data when currentNode changes- useEffect(() => {- if (currentNode) {- setFormData({- ...currentNode.data,- label: currentNode.data.label || '',- caption: currentNode.data.caption || '',- type: currentNode.data.type || ''- })- }- }, [currentNode])-- const queryClient = useQueryClient()-- // Update node mutation- const updateNodeMutation = useMutation({- mutationFn: async ({ sketchId, updateData }: { sketchId: string; updateData: any }) => {- return sketchService.updateNode(sketchId, JSON.stringify(updateData))- },- onSuccess: (result, variables) => {- if (result.status === 'node updated' && currentNode) {- // Update the local store (this also updates the hashmap)- updateNode(currentNode.id, formData)- // Invalidate related queries- if (sketchId) {- queryClient.invalidateQueries({- queryKey: queryKeys.sketches.detail(sketchId)- })- queryClient.invalidateQueries({- queryKey: queryKeys.sketches.graph(sketchId, sketchId)- })- // Also invalidate investigation queries that might show sketch data- queryClient.invalidateQueries({- queryKey: queryKeys.investigations.list- })- queryClient.invalidateQueries({- queryKey: queryKeys.investigations.dashboard- })- }-- toast.success('Node updated successfully')- setOpenNodeEditorModal(false)- } else {- toast.error('Failed to update node')- }- },- onError: (error) => {- console.error('Error updating node:', error)- toast.error('Failed to update node. Please try again.')- }- })-- const handleSave = async () => {- if (!currentNode || !sketchId) return- setIsSaving(true)-- try {- // Prepare the data for the API- const updateData = {- nodeId: currentNode.id,- data: formData- }-- // Call the mutation- await updateNodeMutation.mutateAsync({ sketchId, updateData })- } catch (error) {- console.error('Error updating node:', error)- } finally {- setIsSaving(false)- }- }-- const handleCancel = () => {- setOpenNodeEditorModal(false)- }-- const handleInputChange = (field: keyof NodeData, value: string) => {- setFormData((prev) => ({- ...prev,- [field]: value- }))- }-- const isLocation =- currentNode?.data.type === 'location' ||- (currentNode?.data.latitude && currentNode?.data.longitude)-- if (!currentNode) return null-- // Separate core fields from additional properties- const coreFields = ['label', 'caption', 'type', 'id']- const additionalFields = Object.entries(currentNode.data).filter(- ([key]) => !coreFields.includes(key) && key !== 'ID'- )-- return (- <Sheet open={openNodeEditorModal} onOpenChange={setOpenNodeEditorModal}>- <SheetContent className="!w-full !max-w-2xl h-full !duration-100 p-0 flex flex-col h-full">- <div className="flex flex-col h-full">- {/* Header */}- <SheetHeader className="px-6 py-4 border-b bg-muted/30 flex-shrink-0">- <div className="flex items-center gap-3">- <div className="p-2 rounded-lg bg-primary/10">- <Edit3 className="h-5 w-5 text-primary" />- </div>- <div className="flex gap-3">- <SheetTitle className="text-lg font-semibold">Edit Node Properties</SheetTitle>- <p className="text-sm text-muted-foreground mt-1">- {currentNode.data.label || currentNode.id}- </p>- <Badge variant="outline" className="text-xs">- {currentNode.data.type || 'Unknown Type'}- </Badge>- </div>- </div>- </SheetHeader>-- {/* Content */}- <div className="flex-1 px-6 py-6 grow overflow-y-auto">- <div className="space-y-6">- {/* Preview Section */}- <div className="p-4 rounded-lg bg-background border">- <div className="flex items-center gap-4">- <div className="relative flex-shrink-0">- {currentNode.data.src ? (- <Avatar className="rounded-lg h-16 w-16 border-2 border-muted">- <AvatarImage- className="rounded-lg object-cover"- src={currentNode.data.src}- />- <AvatarFallback className="text-lg font-semibold rounded-lg">- {formData.label?.[0]?.toUpperCase() || '?'}- </AvatarFallback>- </Avatar>- ) : (- <div className="h-16 w-16 rounded-lg border-2 border-muted bg-muted/30 flex items-center justify-center">- <IconComponent className="h-8 w-8 text-muted-foreground" />- </div>- )}- </div>- <div className="flex-1 min-w-0">- <h3 className="text-lg font-semibold text-foreground mb-1">- {formData.label || 'No label'}- </h3>- <p className="text-sm font-medium text-primary">{formData.type || 'No type'}</p>- </div>- </div>- </div>-- {/* Core Properties */}- <div className="space-y-4">- <h3 className="text-sm font-medium text-muted-foreground">Core Properties</h3>- <div className="grid grid-cols-1 gap-4">- <div className="space-y-2">- <Label htmlFor="label" className="text-sm font-medium flex items-center gap-2">- <FileText className="h-3 w-3" />- Label- </Label>- <Input- id="label"- value={formData.label || ''}- onChange={(e) => handleInputChange('label', e.target.value)}- placeholder="Enter node label"- className="h-9"- />- </div>- <div className="space-y-2">- <Label htmlFor="type" className="text-sm font-medium flex items-center gap-2">- <Type className="h-3 w-3" />- Type- </Label>- <Input- id="type"- value={formData.type || ''}- onChange={(e) => handleInputChange('type', e.target.value)}- placeholder="Enter node type"- className="h-9"- />- </div>- <div className="space-y-2">- <Label- htmlFor="caption"- className="text-sm font-medium flex items-center gap-2"- >- <FileText className="h-3 w-3" />- Caption- </Label>- <Input- id="caption"- value={formData.caption || ''}- onChange={(e) => handleInputChange('caption', e.target.value)}- placeholder="Enter node caption"- className="h-9"- />- </div>- </div>- </div>-- {/* Additional Properties */}- {additionalFields.length > 0 && (- <div className="space-y-4">- <h3 className="text-sm font-medium text-muted-foreground">- Additional Properties- </h3>- <div className="space-y-4">- {additionalFields.map(([key, value]) => (- <div key={key} className="space-y-2">- <Label htmlFor={key} className="text-sm font-medium capitalize">- {key.replace(/_/g, ' ')}- </Label>- {typeof value === 'boolean' ? (- <div className="flex items-center gap-2">- <Button- type="button"- variant={formData[key as keyof NodeData] ? 'default' : 'outline'}- size="sm"- onClick={() =>- handleInputChange(- key as keyof NodeData,- (!formData[key as keyof NodeData]).toString()- )- }- className="gap-2"- >- {formData[key as keyof NodeData] ? (- <>- <Check className="h-3 w-3" />- True- </>- ) : (- 'False'- )}- </Button>- </div>- ) : typeof value === 'string' && value.length > 100 ? (- <Textarea- id={key}- value={(formData[key as keyof NodeData] as string) || ''}- onChange={(e) =>- handleInputChange(key as keyof NodeData, e.target.value)- }- placeholder={`Enter ${key.replace(/_/g, ' ').toLowerCase()}`}- className="min-h-[80px] resize-none"- rows={3}- />- ) : (- <Input- id={key}- value={(formData[key as keyof NodeData] as string) || ''}- onChange={(e) =>- handleInputChange(key as keyof NodeData, e.target.value)- }- placeholder={`Enter ${key.replace(/_/g, ' ').toLowerCase()}`}- className="h-9"- />- )}- </div>- ))}- </div>- </div>- )}-- {/* Location Map */}- {isLocation && (- <div className="space-y-4">- <h3 className="text-sm font-medium text-muted-foreground">Location</h3>- <div className="overflow-hidden rounded-lg bg-background border">- <MapFromAddress- locations={[- {- lat: formData.latitude,- lon: formData.longitude,- address: formData.label as string,- label: formData.label as string- }- ]}- />- </div>- </div>- )}- </div>- </div>-- {/* Footer */}- <SheetFooter className="px-6 py-4 border-t bg-muted/30 flex-shrink-0">- <div className="flex justify-between items-center w-full">- <div className="text-sm text-muted-foreground">- {additionalFields.length} additional properties- </div>- <div className="flex gap-2">- <Button variant="outline" onClick={handleCancel} className="gap-2">- <X className="h-4 w-4" />- Cancel- </Button>- <Button onClick={handleSave} disabled={isSaving} className="gap-2">- {isSaving ? (- <Loader2 className="h-4 w-4 animate-spin" />- ) : (- <Save className="h-4 w-4" />- )}- {isSaving ? 'Saving...' : 'Save changes'}- </Button>- </div>- </div>- </SheetFooter>- </div>- </SheetContent>- </Sheet>- )-}diff --git a/flowsint-app/src/components/sketches/details-panel/relationships.tsx b/flowsint-app/src/components/sketches/details-panel/relationships.tsxindex 73f83158..350b4f8b 100644--- a/flowsint-app/src/components/sketches/details-panel/relationships.tsx+++ b/flowsint-app/src/components/sketches/details-panel/relationships.tsx@@ -110,11 +110,11 @@ const VirtualizedList = memo(({ relationships }: { relationships: Relation[] })<div className="min-w-0 flex-1 flex items-center"><RelationshipItem node={rel.source} /></div>- <ArrowRight className="flex-shrink-0 opacity-60 h-4 w-4" />+ <ArrowRight className="shrink-0 opacity-60 h-4 w-4" /><div className="min-w-0 flex-1 flex items-center justify-center"><span className="opacity-60 text-xs truncate block">{rel.edge.label}</span></div>- <ArrowRight className="flex-shrink-0 opacity-60 h-4 w-4" />+ <ArrowRight className="shrink-0 opacity-60 h-4 w-4" /><div className="min-w-0 flex-1 flex items-center justify-end"><RelationshipItem node={rel.target} /></div>@@ -140,8 +140,8 @@ const RelationshipItem = memo(({ node }: { node: GraphNode }) => {className="w-full h-full text-left hover:underline cursor-pointer flex items-center"onClick={handleClick}>- <TypeBadge className="w-full truncate block text-center" type={node.data.type}>- {node.data.label}+ <TypeBadge className="w-full truncate block text-center" type={node.nodeType}>+ {node.nodeLabel}</TypeBadge></button>)diff --git a/flowsint-app/src/components/sketches/details-panel/resizable-details-panels.tsx b/flowsint-app/src/components/sketches/details-panel/resizable-details-panels.tsxnew file mode 100644index 00000000..e47f654f--- /dev/null+++ b/flowsint-app/src/components/sketches/details-panel/resizable-details-panels.tsx@@ -0,0 +1,185 @@+'use client'++import React, { memo, useState, useCallback, useMemo } from 'react'+import { PanelGroup, Panel, PanelResizeHandle } from 'react-resizable-panels'+import { cn } from '@/lib/utils'+import { ChevronRight, GripHorizontal } from 'lucide-react'++// Section Header Component+const SectionHeader = memo(+ ({+ label,+ isOpen,+ onToggle,+ count+ }: {+ label: string+ isOpen: boolean+ onToggle: () => void+ count?: number+ }) => (+ <button+ onClick={onToggle}+ className="flex items-center gap-1 w-full px-3 py-2 text-left border-b border-border bg-muted/30 hover:bg-muted/50 transition-colors shrink-0"+ >+ <ChevronRight+ className={cn(+ 'h-3 w-3 text-muted-foreground/50 transition-transform duration-150',+ isOpen && 'rotate-90'+ )}+ />+ <span className="text-[11px] uppercase tracking-wide text-muted-foreground font-medium">+ {label}+ </span>+ {count !== undefined && count > 0 && (+ <span className="text-[10px] text-muted-foreground/40 ml-1">{count}</span>+ )}+ </button>+ )+)+SectionHeader.displayName = 'SectionHeader'++// Resize Handle Component+const ResizeHandle = memo(({ id }: { id: string }) => (+ <PanelResizeHandle+ id={`resize-handle-${id}`}+ className="h-2 flex items-center justify-center bg-border/30 hover:bg-border/60 transition-colors group relative"+ >+ <GripHorizontal className="h-3 w-3 text-muted-foreground/30 group-hover:text-muted-foreground/60 transition-colors" />+ </PanelResizeHandle>+))+ResizeHandle.displayName = 'ResizeHandle'++// Panel Section Props+export type PanelSectionConfig = {+ id: string+ label: string+ content: React.ReactNode+ defaultOpen?: boolean+ fixedSize?: number // percentage - makes section non-resizable+ defaultSize?: number // percentage+ minSize?: number // percentage+}++// Main Resizable Details Panel+export function ResizableDetailsPanel({+ sections,+ className+}: {+ sections: PanelSectionConfig[]+ className?: string+}) {+ const [openSections, setOpenSections] = useState<Record<string, boolean>>(() =>+ sections.reduce(+ (acc, section) => ({+ ...acc,+ [section.id]: section.defaultOpen ?? true+ }),+ {}+ )+ )++ const toggleSection = useCallback((id: string) => {+ setOpenSections((prev) => ({ ...prev, [id]: !prev[id] }))+ }, [])++ // Get open sections while maintaining original order+ const openSectionsList = useMemo(+ () => sections.filter((s) => openSections[s.id]),+ [sections, openSections]+ )++ // Calculate default sizes for open sections+ const getDefaultSize = useCallback(+ (section: PanelSectionConfig) => {+ if (section.fixedSize) return section.fixedSize+ if (section.defaultSize) return section.defaultSize+ // Distribute remaining space equally+ const fixedTotal = openSectionsList+ .filter((s) => s.fixedSize)+ .reduce((sum, s) => sum + (s.fixedSize || 0), 0)+ const flexibleCount = openSectionsList.filter((s) => !s.fixedSize).length+ return flexibleCount > 0 ? (100 - fixedTotal) / flexibleCount : 100 / openSectionsList.length+ },+ [openSectionsList]+ )++ // Build the render structure: interleave collapsed headers with resizable panel group+ // We render collapsed sections inline, in their original position+ const buildRenderGroups = () => {+ const result: React.ReactNode[] = []+ let currentOpenGroup: PanelSectionConfig[] = []++ const flushOpenGroup = () => {+ if (currentOpenGroup.length > 0) {+ const groupKey = currentOpenGroup.map((s) => s.id).join('-')+ result.push(+ <PanelGroup key={groupKey} direction="vertical" className="flex-1 min-h-0">+ {currentOpenGroup.map((section, index) => {+ const isLast = index === currentOpenGroup.length - 1+ return (+ <React.Fragment key={section.id}>+ <Panel+ id={section.id}+ defaultSize={getDefaultSize(section)}+ minSize={section.minSize ?? 8}+ className="flex flex-col min-h-0"+ >+ <SectionHeader+ label={section.label}+ isOpen={true}+ onToggle={() => toggleSection(section.id)}+ />+ <div className="flex-1 overflow-y-auto min-h-0">{section.content}</div>+ </Panel>+ {!isLast && <ResizeHandle id={section.id} />}+ </React.Fragment>+ )+ })}+ </PanelGroup>+ )+ currentOpenGroup = []+ }+ }++ sections.forEach((section) => {+ const isOpen = openSections[section.id]++ if (isOpen) {+ currentOpenGroup.push(section)+ } else {+ // Flush any accumulated open sections first+ flushOpenGroup()+ // Then render the collapsed header+ result.push(+ <SectionHeader+ key={`collapsed-${section.id}`}+ label={section.label}+ isOpen={false}+ onToggle={() => toggleSection(section.id)}+ />+ )+ }+ })++ // Flush any remaining open sections+ flushOpenGroup()++ return result+ }++ return (+ <div className={cn('flex flex-col h-full bg-card overflow-hidden', className)}>+ {buildRenderGroups()}+ </div>+ )+}++// Row Component for displaying key-value pairs+export const Row = memo(({ label, children }: { label: string; children: React.ReactNode }) => (+ <div className="flex items-center justify-between py-1.5 group hover:bg-muted/20 -mx-2 px-2 rounded-sm transition-colors">+ <span className="text-[13px] text-muted-foreground">{label.replace(/_/g, ' ')}</span>+ <div className="text-[13px] text-foreground flex items-center gap-1">{children}</div>+ </div>+))+Row.displayName = 'Row'diff --git a/flowsint-app/src/components/sketches/graph/actions/merge-nodes.tsx b/flowsint-app/src/components/sketches/graph/actions/merge-nodes.tsxindex 5936ddf5..d92a6172 100644--- a/flowsint-app/src/components/sketches/graph/actions/merge-nodes.tsx+++ b/flowsint-app/src/components/sketches/graph/actions/merge-nodes.tsx@@ -53,7 +53,7 @@ export function MergeDialog() {const handleSubmit = async (e: { preventDefault: () => void }) => {e.preventDefault()if (!preview) return toast.error('No preview available.')- if (!selectedNodes.every((n) => n.data.type === selectedNodes[0].data.type))+ if (!selectedNodes.every((n) => n.nodeType === selectedNodes[0].nodeType))return toast.error('Cannot merge entities of different types.')const entitiesToMerge = selectedNodes.map((node) => node.id)// Extract only id and data to avoid circular references from neighbors/links@@ -82,7 +82,7 @@ export function MergeDialog() {return (<Dialog open={openMergeDialog} onOpenChange={setOpenMergeDialog}>- <DialogContent className="!w-full !max-w-[700px] max-h-[90vh] overflow-y-auto overflow-x-hidden">+ <DialogContent className="w-full! max-w-[700px]! max-h-[90vh] overflow-y-auto overflow-x-hidden"><DialogHeader><DialogTitle className="flex items-center gap-2"><Merge className="h-4 w-4" />@@ -135,7 +135,10 @@ export function MergeDialog() {<div className="space-y-2 text-sm"><p>Merged attributes</p><div className="rounded-md border overflow-hidden">- <KeyValueDisplayDiff oldRecord={old.data} newRecord={preview.data} />+ <KeyValueDisplayDiff+ oldRecord={old.nodeProperties}+ newRecord={preview.nodeProperties}+ /></div></div>)}diff --git a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx b/flowsint-app/src/components/sketches/graph/components/graph-main.tsxindex 44f1bdba..5631cd4a 100644--- a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx+++ b/flowsint-app/src/components/sketches/graph/components/graph-main.tsx@@ -1,11 +1,36 @@import { useGraphStore } from '@/stores/graph-store'-import React, { useRef, useCallback } from 'react'+import React, { useRef, useCallback, SetStateAction, Dispatch } from 'react'import GraphViewer from '../index'// import WebGLGraphViewer from './webgl'import NodeContextMenu from '../context-menu/node-context-menu'import BackgroundContextMenu from '../context-menu/background-context-menu'import EdgeContextMenu from '../context-menu/edge-context-menu'import { useParams } from '@tanstack/react-router'+import { type GraphNode, GraphEdge } from '@/types'++type BaseContextMenuProps = {+ rawTop: number+ rawLeft: number+ wrapperWidth: number+ wrapperHeight: number+ onClick: () => void+}++type NodeContextMenuProps = BaseContextMenuProps & {+ node: GraphNode+ setMenu: Dispatch<SetStateAction<NodeContextMenuProps | null>>+}++type EdgeContextMenuProps = BaseContextMenuProps & {+ edge?: GraphEdge+ edges?: GraphEdge[]+ setMenu: Dispatch<SetStateAction<EdgeContextMenuProps | null>>+}++type BackgroundContextMenuProps = BaseContextMenuProps & {+ nodes: GraphNode[]+ setMenu: Dispatch<SetStateAction<BackgroundContextMenuProps | null>>+}const GraphMain = () => {const { id: sketchId } = useParams({ strict: false })@@ -16,14 +41,14 @@ const GraphMain = () => {const clearSelectedNodes = useGraphStore((s) => s.clearSelectedNodes)const clearSelectedEdges = useGraphStore((s) => s.clearSelectedEdges)const setCurrentEdgeId = useGraphStore((s) => s.setCurrentEdgeId)- const selectedNodes = useGraphStore(s => s.selectedNodes)- const selectedEdges = useGraphStore(s => s.selectedEdges)+ const selectedNodes = useGraphStore((s) => s.selectedNodes)+ const selectedEdges = useGraphStore((s) => s.selectedEdges)const graphRef = useRef<any>(null)const containerRef = useRef<HTMLDivElement>(null)- const [nodeMenu, setNodeMenu] = React.useState<any>(null)- const [edgeMenu, setEdgeMenu] = React.useState<any>(null)- const [background, setBackgroundMenu] = React.useState<any>(null)+ const [nodeMenu, setNodeMenu] = React.useState<NodeContextMenuProps | null>(null)+ const [edgeMenu, setEdgeMenu] = React.useState<EdgeContextMenuProps | null>(null)+ const [background, setBackgroundMenu] = React.useState<BackgroundContextMenuProps | null>(null)const handleNodeClick = useCallback((node: any, event: MouseEvent) => {@@ -48,80 +73,78 @@ const GraphMain = () => {setBackgroundMenu(null)}, [setCurrentNodeId, clearSelectedNodes, clearSelectedEdges, setCurrentEdgeId])- const onNodeContextMenu = useCallback((node: any, event: MouseEvent) => {- if (!containerRef.current || !node) return+ const onNodeContextMenu = useCallback(+ (node: any, event: MouseEvent) => {+ if (!containerRef.current || !node) return- const pane = containerRef.current.getBoundingClientRect()- const relativeX = event.clientX - pane.left- const relativeY = event.clientY - pane.top+ const pane = containerRef.current.getBoundingClientRect()+ const relativeX = event.clientX - pane.left+ const relativeY = event.clientY - pane.top- // If multiple selected nodes → background menu- if (selectedNodes.length > 0) {- setBackgroundMenu({- nodes: selectedNodes,+ // If multiple selected nodes → background menu+ if (selectedNodes.length > 0) {+ setBackgroundMenu({+ nodes: selectedNodes,+ rawTop: relativeY,+ rawLeft: relativeX,+ wrapperWidth: pane.width,+ wrapperHeight: pane.height,+ setMenu: setBackgroundMenu,+ onClick: handleBackgroundClick+ })+ setNodeMenu(null)+ return+ }+ // Otherwise normal menu+ setNodeMenu({+ node,rawTop: relativeY,rawLeft: relativeX,wrapperWidth: pane.width,wrapperHeight: pane.height,- setMenu: setBackgroundMenu,- onClick: handleBackgroundClick,+ setMenu: setNodeMenu,+ onClick: handleBackgroundClick})- setNodeMenu(null)- return- }- // Otherwise normal menu- setNodeMenu({- node: {- data: node.data || {},- id: node.id || '',- label: node.label || node.nodeLabel || '',- position: node.position || { x: node.x || 0, y: node.y || 0 }- },- rawTop: relativeY,- rawLeft: relativeX,- wrapperWidth: pane.width,- wrapperHeight: pane.height,- setMenu: setNodeMenu,- onClick: handleBackgroundClick- })- }, [selectedNodes])+ },+ [selectedNodes]+ )- const onEdgeContextMenu = useCallback((edge: any, event: MouseEvent) => {- if (!containerRef.current || !edge) return+ const onEdgeContextMenu = useCallback(+ (edge: any, event: MouseEvent) => {+ if (!containerRef.current || !edge) return- const pane = containerRef.current.getBoundingClientRect()- const relativeX = event.clientX - pane.left- const relativeY = event.clientY - pane.top+ const pane = containerRef.current.getBoundingClientRect()+ const relativeX = event.clientX - pane.left+ const relativeY = event.clientY - pane.top- // If multiple edges are selected, show multi-select menu- if (selectedEdges.length > 0) {- setEdgeMenu({- edges: selectedEdges,- rawTop: relativeY,- rawLeft: relativeX,- wrapperWidth: pane.width,- wrapperHeight: pane.height,- setMenu: setEdgeMenu,- onClick: handleBackgroundClick- })- } else {- // Otherwise show single edge menu- setEdgeMenu({- edge: {- id: edge.id || '',- label: edge.label || edge.edgeLabel || ''- },- rawTop: relativeY,- rawLeft: relativeX,- wrapperWidth: pane.width,- wrapperHeight: pane.height,- setMenu: setEdgeMenu,- onClick: handleBackgroundClick- })- }- setNodeMenu(null)- setBackgroundMenu(null)- }, [selectedEdges, handleBackgroundClick])+ // If multiple edges are selected, show multi-select menu+ if (selectedEdges.length > 0) {+ setEdgeMenu({+ edges: selectedEdges,+ rawTop: relativeY,+ rawLeft: relativeX,+ wrapperWidth: pane.width,+ wrapperHeight: pane.height,+ setMenu: setEdgeMenu,+ onClick: handleBackgroundClick+ })+ } else {+ // Otherwise show single edge menu+ setEdgeMenu({+ edge,+ rawTop: relativeY,+ rawLeft: relativeX,+ wrapperWidth: pane.width,+ wrapperHeight: pane.height,+ setMenu: setEdgeMenu,+ onClick: handleBackgroundClick+ })+ }+ setNodeMenu(null)+ setBackgroundMenu(null)+ },+ [selectedEdges, handleBackgroundClick]+ )const onBackgroundContextMenu = useCallback((event: MouseEvent) => {if (!containerRef.current) return@@ -167,25 +190,11 @@ const GraphMain = () => {allowLassosketchId={sketchId}/>- {nodeMenu && selectedNodes.length === 0 && (- <NodeContextMenu- onClick={handleBackgroundClick}- {...nodeMenu}- />- )}- {edgeMenu && (- <EdgeContextMenu- onClick={handleBackgroundClick}- {...edgeMenu}- />- )}+ {nodeMenu && selectedNodes.length === 0 && <NodeContextMenu {...nodeMenu} />}+ {edgeMenu && <EdgeContextMenu {...edgeMenu} />}{(background || (nodeMenu && selectedNodes.length > 0)) && (- <BackgroundContextMenu- onClick={handleBackgroundClick}- {...background}- />+ <BackgroundContextMenu {...background} />)}-</div>)}diff --git a/flowsint-app/src/components/sketches/graph/components/graph-tooltip.tsx b/flowsint-app/src/components/sketches/graph/components/graph-tooltip.tsxindex 5673c3ef..59ec0a12 100644--- a/flowsint-app/src/components/sketches/graph/components/graph-tooltip.tsx+++ b/flowsint-app/src/components/sketches/graph/components/graph-tooltip.tsx@@ -1,5 +1,5 @@import { Type, Share2 } from 'lucide-react'-import { TooltipState } from './utils/types'+import { TooltipState } from '../utils/types'interface GraphTooltipProps {tooltip: TooltipStatediff --git a/flowsint-app/src/components/sketches/graph/context-menu/background-context-menu.tsx b/flowsint-app/src/components/sketches/graph/context-menu/background-context-menu.tsxindex 20ce3841..9ac1d9f7 100644--- a/flowsint-app/src/components/sketches/graph/context-menu/background-context-menu.tsx+++ b/flowsint-app/src/components/sketches/graph/context-menu/background-context-menu.tsx@@ -7,7 +7,17 @@ import { Button } from '@/components/ui/button'import { Input } from '@/components/ui/input'import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'-import { FileCode2, Search, Info, Zap, BadgeCheck, BadgeAlert, Plus, Download, Trash2 } from 'lucide-react'+import {+ FileCode2,+ Search,+ Info,+ Zap,+ BadgeCheck,+ BadgeAlert,+ Plus,+ Download,+ Trash2+} from 'lucide-react'import { Enricher, Flow, GraphNode } from '@/types'import { useLaunchFlow } from '@/hooks/use-launch-flow'import { useLaunchEnricher } from '@/hooks/use-launch-enricher'@@ -56,15 +66,15 @@ export default function BackgroundContextMenu({const [flowsSearchQuery, setFlowsSearchQuery] = useState('')const { launchFlow } = useLaunchFlow(false)const { launchEnricher } = useLaunchEnricher(false)- const selectedNodes = useGraphStore(s => s.selectedNodes)+ const selectedNodes = useGraphStore((s) => s.selectedNodes)const selectedNodeIds = selectedNodes.map((n) => n.id)const { confirm } = useConfirm()const removeNodes = useGraphStore((s) => s.removeNodes)const clearSelectedNodes = useGraphStore((s) => s.clearSelectedNodes)- let sharedType = selectedNodes?.[0]?.data?.type- const isSameType = selectedNodes.every((n) => n.data.type === sharedType)- sharedType = isSameType ? sharedType : ""+ let sharedType = selectedNodes?.[0]?.nodeType+ const isSameType = selectedNodes.every((n) => n.nodeType === sharedType)+ sharedType = isSameType ? sharedType : ''const hasAny = isSameType && selectedNodeIds.length > 0const { data: enrichers, isLoading: isLoadingEnrichers } = useQuery({@@ -146,16 +156,17 @@ export default function BackgroundContextMenu({wrapperHeight={wrapperHeight}{...props}>- {selectedNodeIds.length === 0 ?- <DefaultBackgroundMenu /> :+ {selectedNodeIds.length === 0 ? (+ <DefaultBackgroundMenu />+ ) : (<>{/* Header with title and action buttons */}- <div className="px-3 py-2 border-b gap-1 border-border flex items-center justify-between flex-shrink-0">+ <div className="px-3 py-2 border-b gap-1 border-border flex items-center justify-between shrink-0"><div className="flex text-xs items-center gap-1 truncate"><span className="block truncate">{selectedNodes.length} selected</span>- {isSameType && <span className="block">-{' '}{sharedType}</span>}+ {isSameType && <span className="block">- {sharedType}</span>}</div>- <div className='grow' />+ <div className="grow" /><div><Tooltip><TooltipTrigger asChild>@@ -166,7 +177,8 @@ export default function BackgroundContextMenu({className="h-6 p-0 hover:bg-muted opacity-70 hover:opacity-100 text-destructive hover:text-destructive"onClick={handleDeleteNodes}>- <Trash2 className="h-3 w-3" strokeWidth={1.5} /> Delete {selectedNodeIds.length}+ <Trash2 className="h-3 w-3" strokeWidth={1.5} /> Delete{' '}+ {selectedNodeIds.length}</Button></div></TooltipTrigger>@@ -178,10 +190,14 @@ export default function BackgroundContextMenu({</div>{/* Tabs */}- <div className="px-3 py-2 border-b border-border flex-shrink-0">+ <div className="px-3 py-2 border-b border-border shrink-0"><Tabs value={activeTab} onValueChange={setActiveTab} className="w-full"><TabsList className="w-full h-9">- <TabsTrigger value="enrichers" className="flex-1" onClick={(e) => e.stopPropagation()}>+ <TabsTrigger+ value="enrichers"+ className="flex-1"+ onClick={(e) => e.stopPropagation()}+ ><Zap className="h-3 w-3 mr-1" />Enrichers</TabsTrigger>@@ -198,7 +214,7 @@ export default function BackgroundContextMenu({{/* Enrichers Tab */}<TabsContent value="enrichers" className="flex-1 flex flex-col min-h-0 mt-0">{/* Enrichers Search */}- <div className="px-3 py-2 border-b border-border flex-shrink-0">+ <div className="px-3 py-2 border-b border-border shrink-0"><div className="relative"><Search className="absolute left-2 top-1/2 transform -translate-y-1/2 h-3 w-3 text-muted-foreground" /><Input@@ -237,10 +253,17 @@ export default function BackgroundContextMenu({className="w-full flex items-center gap-2 p-2 rounded-md hover:bg-muted text-left transition-colors"onClick={(e) => handleEnricherClick(e, enricher.name)}>- <Zap className="h-4 w-4 text-muted-foreground flex-shrink-0" />+ <Zap className="h-4 w-4 text-muted-foreground shrink-0" /><div className="flex-1 min-w-0"><p className="text-sm font-medium flex gap-1 items-center truncate">- <span>{enricher.wobblyType ? <BadgeAlert className='h-3 w-3 text-orange-400' /> : <BadgeCheck className='h-3 w-3 text-green-400' />} </span> {enricher.name || '(Unnamed enricher)'}+ <span>+ {enricher.wobblyType ? (+ <BadgeAlert className="h-3 w-3 text-orange-400" />+ ) : (+ <BadgeCheck className="h-3 w-3 text-green-400" />+ )}{' '}+ </span>{' '}+ {enricher.name || '(Unnamed enricher)'}</p>{enricher.description && (<p className="text-xs text-muted-foreground truncate">@@ -268,7 +291,7 @@ export default function BackgroundContextMenu({{/* Flows Tab */}<TabsContent value="flows" className="flex-1 flex flex-col min-h-0 mt-0">{/* Flows Search */}- <div className="px-3 py-2 border-b border-border flex-shrink-0">+ <div className="px-3 py-2 border-b border-border shrink-0"><div className="relative"><Search className="absolute left-2 top-1/2 transform -translate-y-1/2 h-3 w-3 text-muted-foreground" /><Input@@ -307,13 +330,22 @@ export default function BackgroundContextMenu({className="w-full flex items-center gap-2 p-2 rounded-md hover:bg-muted text-left transition-colors"onClick={(e) => handleFlowClick(e, flow.id)}>- <FileCode2 className="h-4 w-4 text-muted-foreground flex-shrink-0" />+ <FileCode2 className="h-4 w-4 text-muted-foreground shrink-0" /><div className="flex-1 min-w-0"><p className="flex items-center gap-1 text-sm font-medium truncate">- <span>{flow.wobblyType ? <BadgeAlert className='h-3 w-3 text-orange-400' /> : <BadgeCheck className='h-3 w-3 text-green-400' />} </span> {flow.name || '(Unnamed flow)'}+ <span>+ {flow.wobblyType ? (+ <BadgeAlert className="h-3 w-3 text-orange-400" />+ ) : (+ <BadgeCheck className="h-3 w-3 text-green-400" />+ )}{' '}+ </span>{' '}+ {flow.name || '(Unnamed flow)'}</p>{flow.description && (- <p className="text-xs text-muted-foreground truncate">{flow.description}</p>+ <p className="text-xs text-muted-foreground truncate">+ {flow.description}+ </p>)}</div><div className="flex items-center gap-1">@@ -333,11 +365,13 @@ export default function BackgroundContextMenu({</div></TabsContent></Tabs>- {selectedNodes.length > 0 &&- <div className='border-t p-1'>+ {selectedNodes.length > 0 && (+ <div className="border-t p-1"><SubActions selectedNodes={selectedNodes} />- </div>}- </>}+ </div>+ )}+ </>+ )}</BaseContextMenu>)}@@ -360,13 +394,13 @@ const DefaultBackgroundMenu = memo(() => {className="w-full rounded-t-md flex items-center gap-2 p-2 hover:bg-muted text-left transition-colors"onClick={handleOpenNewAddItemDialog}>- <Plus className='h-4 w-4 opacity-60' /> Add a new entity+ <Plus className="h-4 w-4 opacity-60" /> Add a new entity</button><buttonclassName="w-full rounded-b-md flex items-center gap-2 p-2 hover:bg-muted text-left transition-colors"onClick={handleOpenImportDialog}>- <Download className='h-4 w-4 opacity-60' /> Import entities+ <Download className="h-4 w-4 opacity-60" /> Import entities</button></div>)@@ -376,14 +410,13 @@ type SubActionsProps = {selectedNodes: GraphNode[]}const SubActions = memo(({ selectedNodes }: SubActionsProps) => {-- const contentToCopy = useMemo(() => selectedNodes.map((node) => node.data.label).join("\n"), [])+ const contentToCopy = useMemo(() => selectedNodes.map((node) => node.nodeLabel).join('\n'), [])return (<div><CopyButton label={`Copy ${selectedNodes.length} items as txt`} content={contentToCopy} />- </div>)-}-)+ </div>+ )+})const InfoButton = ({ description }: { description?: string }) => {if (!description) return nulldiff --git a/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsx b/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsxindex 1eb0181b..12f87ccc 100644--- a/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsx+++ b/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsx@@ -21,7 +21,7 @@ import { useLaunchFlow } from '@/hooks/use-launch-flow'import { useLaunchEnricher } from '@/hooks/use-launch-enricher'import { useParams } from '@tanstack/react-router'import { capitalizeFirstLetter } from '@/lib/utils'-import NodeActions from '../actions/node-actions'+import NodeActions from '../node/actions/node-actions'import BaseContextMenu from '@/components/xyflow/context-menu'import { useGraphStore } from '@/stores/graph-store'import { CopyButton } from '@/components/copy'@@ -64,13 +64,13 @@ export default function ContextMenu({const toggleNodeSelection = useGraphStore((s) => s.toggleNodeSelection)const { data: enrichers, isLoading: isLoadingEnrichers } = useQuery({- queryKey: ['enrichers', node.data.type],- queryFn: () => enricherService.get(capitalizeFirstLetter(node.data.type))+ queryKey: ['enrichers', node.nodeType],+ queryFn: () => enricherService.get(capitalizeFirstLetter(node.nodeType))})const { data: flows, isLoading: isLoadingFlows } = useQuery({- queryKey: ['flows', node.data.type],- queryFn: () => flowService.get(capitalizeFirstLetter(node.data.type))+ queryKey: ['flows', node.nodeType],+ queryFn: () => flowService.get(capitalizeFirstLetter(node.nodeType))})const filteredEnrichers =@@ -124,9 +124,10 @@ export default function ContextMenu({{/* Header with title and action buttons */}<div className="px-3 py-2 border-b gap-1 border-border flex items-center justify-between shrink-0"><div className="flex text-xs items-center gap-1 truncate">- <span className="block truncate">{node.data.label}</span> -{' '}- <span className="block">{node.data.type}</span>+ <span className="block truncate">{node.nodeLabel}</span> -{' '}+ <span className="block">{node.nodeType}</span></div>+ <SubActions node={node} handleOpenNodeDetails={handleOpenNodeDetails} /><NodeActions node={node} setMenu={setMenu} /></div>@@ -190,7 +191,7 @@ export default function ContextMenu({className="w-full flex items-center gap-2 p-2 rounded-md hover:bg-muted text-left transition-colors"onClick={(e) => handleEnricherClick(e, enricher.name)}>- <Zap className="h-4 w-4 text-muted-foreground flex-shrink-0" />+ <Zap className="h-4 w-4 text-muted-foreground shrink-0" /><div className="flex-1 min-w-0"><p className="text-sm font-medium flex gap-1 items-center truncate"><span>@@ -228,7 +229,7 @@ export default function ContextMenu({{/* Flows Tab */}<TabsContent value="flows" className="flex-1 flex flex-col min-h-0 mt-0">{/* Flows Search */}- <div className="px-3 py-2 border-b border-border flex-shrink-0">+ <div className="px-3 py-2 border-b border-border shrink-0"><div className="relative"><Search className="absolute left-2 top-1/2 transform -translate-y-1/2 h-3 w-3 text-muted-foreground" /><Input@@ -267,7 +268,7 @@ export default function ContextMenu({className="w-full flex items-center gap-2 p-2 rounded-md hover:bg-muted text-left transition-colors"onClick={(e) => handleFlowClick(e, flow.id)}>- <FileCode2 className="h-4 w-4 text-muted-foreground flex-shrink-0" />+ <FileCode2 className="h-4 w-4 text-muted-foreground shrink-0" /><div className="flex-1 min-w-0"><p className="flex items-center gap-1 text-sm font-medium truncate"><span>@@ -300,10 +301,6 @@ export default function ContextMenu({</div></TabsContent></Tabs>-- <div className="border-t p-1">- <SubActions node={node} handleOpenNodeDetails={handleOpenNodeDetails} />- </div></BaseContextMenu>)}@@ -315,9 +312,9 @@ type SubActionsProps = {const SubActions = memo(({ node, handleOpenNodeDetails }: SubActionsProps) => {return (<div className="flex">- <CopyButton size={'icon'} content={node?.data?.label} />+ <CopyButton size={'icon'} content={node.nodeLabel} /><Button onClick={handleOpenNodeDetails} size={'icon'} className="h-7 w-7" variant="ghost">- <SquareArrowOutUpRight className="!h-3.5 !w-3.5 opacity-50" />+ <SquareArrowOutUpRight className="h-3.5! w-3.5! opacity-50" /></Button></div>)diff --git a/flowsint-app/src/components/sketches/graph/hooks/use-tooltip.ts b/flowsint-app/src/components/sketches/graph/hooks/use-tooltip.tsindex 8f6779ac..b580f011 100644--- a/flowsint-app/src/components/sketches/graph/hooks/use-tooltip.ts+++ b/flowsint-app/src/components/sketches/graph/hooks/use-tooltip.ts@@ -9,47 +9,50 @@ export const useTooltip = (graphRef: React.RefObject<any>) => {visible: false})- const showTooltip = useCallback((node: any) => {- if (!node || !graphRef.current) {- setTooltip((prev) => ({ ...prev, visible: false }))- return- }+ const showTooltip = useCallback(+ (node: any) => {+ if (!node || !graphRef.current) {+ setTooltip((prev) => ({ ...prev, visible: false }))+ return+ }- const weight = node.neighbors?.length || 0- const label = node.nodeLabel || node.label || node.id+ const weight = node.neighbors?.length || 0+ const label = node.nodeLabel || node.label || node.id- try {- const screenCoords = graphRef.current.graph2ScreenCoords(node.x, node.y)- const tooltipWidth = 120- const tooltipHeight = 60+ try {+ const screenCoords = graphRef.current.graph2ScreenCoords(node.x, node.y)+ const tooltipWidth = 120+ const tooltipHeight = 60- let x = screenCoords.x- let y = screenCoords.y - 30+ let x = screenCoords.x+ let y = screenCoords.y - 30- if (x + tooltipWidth > window.innerWidth) {- x = window.innerWidth - tooltipWidth - 10- }- if (x < 10) {- x = 10- }- if (y < tooltipHeight + 10) {- y = screenCoords.y + 100- }+ if (x + tooltipWidth > window.innerWidth) {+ x = window.innerWidth - tooltipWidth - 10+ }+ if (x < 10) {+ x = 10+ }+ if (y < tooltipHeight + 10) {+ y = screenCoords.y + 100+ }- setTooltip({- x,- y,- data: {- label,- type: node.data?.type || 'unknown',- connections: weight.toString()- },- visible: true- })- } catch (error) {- setTooltip((prev) => ({ ...prev, visible: false }))- }- }, [graphRef])+ setTooltip({+ x,+ y,+ data: {+ label,+ type: node.nodeType || 'unknown',+ connections: weight.toString()+ },+ visible: true+ })+ } catch (error) {+ setTooltip((prev) => ({ ...prev, visible: false }))+ }+ },+ [graphRef]+ )const hideTooltip = useCallback(() => {setTooltip((prev) => ({ ...prev, visible: false }))diff --git a/flowsint-app/src/components/sketches/graph/index.tsx b/flowsint-app/src/components/sketches/graph/index.tsxindex af89d611..798a9a2e 100644--- a/flowsint-app/src/components/sketches/graph/index.tsx+++ b/flowsint-app/src/components/sketches/graph/index.tsx@@ -4,12 +4,17 @@ import ForceGraph2D from 'react-force-graph-2d'import { useGraphControls } from '@/stores/graph-controls-store'import { useGraphSettingsStore } from '@/stores/graph-settings-store'import { useGraphStore } from '@/stores/graph-store'-import { ItemType, useNodesDisplaySettings } from '@/stores/node-display-settings'+import { useNodesDisplaySettings } from '@/stores/node-display-settings'import { useTheme } from '@/components/theme-provider'import { useSaveNodePositions } from '@/hooks/use-save-node-positions'import { CONSTANTS } from './utils/constants'import { GraphViewerProps } from './utils/types'-import { preloadImage } from './utils/image-cache'+import {+ preloadImage,+ preloadIconByName,+ preloadExternalImage,+ preloadFlagImage+} from './utils/image-cache'import { renderNode } from './node/node-renderer'import { renderLink } from './edge/link-renderer'import { useHighlightState } from './hooks/use-highlight-state'@@ -120,27 +125,59 @@ const GraphViewer: React.FC<GraphViewerProps> = ({return graphRef.current.graph2ScreenCoords(node.x, node.y)}, [])- // Preload icons+ // Preload icons and imagesuseEffect(() => {- if (showIcons) {- const isOutlined = forceSettings.nodeOutlined?.value ?? false- const iconTypes = new Set(nodes.map((node) => node.data?.type as ItemType).filter(Boolean))-- if (isOutlined) {- // In outlined mode, preload icons in both white and black- iconTypes.forEach((type) => {- preloadImage(type, '#FFFFFF').catch(console.warn) // for dark theme- preloadImage(type, '#000000').catch(console.warn) // for light theme- })- } else {- // In filled mode, preload icons with white color only- iconTypes.forEach((type) => {- preloadImage(type, '#FFFFFF').catch(console.warn)- })- }- }+ if (!showIcons) return++ const isOutlined = forceSettings.nodeOutlined?.value ?? false+ const colors = isOutlined ? ['#FFFFFF', '#000000'] : ['#FFFFFF']++ // Collect unique values+ const nodeTypes = new Set<string>()+ const nodeIcons = new Set<string>()+ const nodeImages = new Set<string>()++ nodes.forEach((node) => {+ if (node.nodeImage) nodeImages.add(node.nodeImage)+ else if (node.nodeIcon) nodeIcons.add(node.nodeIcon)+ else if (node.nodeType) nodeTypes.add(node.nodeType)+ })++ // Preload external images+ nodeImages.forEach((url) => {+ preloadExternalImage(url).catch(console.warn)+ })++ // Preload custom icons by name+ nodeIcons.forEach((iconName) => {+ colors.forEach((color) => {+ preloadIconByName(iconName, color).catch(console.warn)+ })+ })++ // Preload type-based icons+ nodeTypes.forEach((type) => {+ colors.forEach((color) => {+ preloadImage(type, color).catch(console.warn)+ })+ })}, [nodes, showIcons, forceSettings.nodeOutlined?.value, customIcons])+ useEffect(() => {+ const flagColors = [+ { stroke: '#f87171', fill: '#fecaca' }, // red+ { stroke: '#fb923c', fill: '#fed7aa' }, // orange+ { stroke: '#60a5fa', fill: '#bfdbfe' }, // blue+ { stroke: '#4ade80', fill: '#bbf7d0' }, // green+ { stroke: '#facc15', fill: '#fef08a' } // yellow+ ]+ flagColors.forEach(({ stroke, fill }) => {+ preloadFlagImage(stroke, fill).catch((err) => {+ console.warn('[Graph] Failed to preload flag image:', stroke, fill, err)+ })+ })+ }, [])+// Container size managementuseEffect(() => {const updateSize = () => {@@ -263,36 +300,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({}}, [])- const exportToPNG = useCallback(async () => {- if (!graphRef.current) {- throw new Error('Graph ref not available')- }- // Get the canvas element from the ForceGraph2D component- const canvas = containerRef.current?.querySelector('canvas')- if (!canvas) {- throw new Error('Canvas element not found')- }- return new Promise<void>((resolve, reject) => {- canvas.toBlob((blob) => {- if (!blob) {- reject(new Error('Failed to create image blob'))- return- }- // Create download link- const url = URL.createObjectURL(blob)- const a = document.createElement('a')- a.href = url- a.download = `sketch-${sketchId || 'export'}-${Date.now()}.png`- document.body.appendChild(a)- a.click()- // Cleanup- URL.revokeObjectURL(url)- document.body.removeChild(a)- resolve()- }, 'image/png')- })- }, [sketchId])-useGraphInitialization({graphRef,instanceId,@@ -302,14 +309,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({regenerateLayout: wrappedRegenerateLayout})- // Expose export function to global store- useEffect(() => {- setActions({ exportToPNG })- return () => {- setActions({ exportToPNG: async () => {} })- }- }, [exportToPNG, setActions])-// Clear highlights when graph data changesuseEffect(() => {clearHighlights()diff --git a/flowsint-app/src/components/sketches/graph/node/actions/flag.tsx b/flowsint-app/src/components/sketches/graph/node/actions/flag.tsxnew file mode 100644index 00000000..4042bcdc--- /dev/null+++ b/flowsint-app/src/components/sketches/graph/node/actions/flag.tsx@@ -0,0 +1,90 @@+import { useCallback, useState, useEffect } from 'react'+import { Button } from '@/components/ui/button'+import { toast } from 'sonner'+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuRadioGroup,+ DropdownMenuRadioItem,+ DropdownMenuTrigger+} from '@/components/ui/dropdown-menu'+import { Flag } from 'lucide-react'+import { useGraphStore } from '@/stores/graph-store'+import { cn } from '@/lib/utils'+import { sketchService } from '@/api/sketch-service'+import { GraphNode } from '@/types'++const flagColors = {+ red: 'text-red-400 fill-red-200',+ orange: 'text-orange-400 fill-orange-200',+ blue: 'text-blue-400 fill-blue-200',+ green: 'text-green-400 fill-green-200',+ yellow: 'text-yellow-400 fill-yellow-200'+} as const++type flagColor = keyof typeof flagColors++export function NodeFlag({ sketchId, node }: { sketchId: string; node: GraphNode }) {+ const updateNode = useGraphStore((s) => s.updateNode)+ const nodeId = node.id+ const [flagValue, setFlagValue] = useState<flagColor | null>(node.nodeFlag)++ // Synchronize local state when props change (new node selected)+ useEffect(() => {+ setFlagValue(node.nodeFlag)+ }, [nodeId, node.nodeFlag])++ const handleUpdateFlag = useCallback(+ async (value: string) => {+ // Click the same color and it removes it+ const val = value === flagValue ? null : (value as flagColor)+ node.nodeFlag = flagValue+ setFlagValue(val)+ try {+ updateNode(nodeId, { nodeFlag: val })+ const body = JSON.stringify({+ nodeId: node.id,+ updates: { nodeFlag: val } as Partial<GraphNode>+ })+ await sketchService.updateNode(sketchId, body)+ } catch (e) {+ console.log(e)+ // toast.error(e.message)+ }+ },+ [nodeId, flagValue, updateNode]+ )++ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <div>+ <Button+ variant="ghost"+ size="sm"+ className="h-6 w-6 p-0 hover:bg-muted opacity-70 hover:opacity-100"+ >+ <Flag className={cn(flagValue && flagColors[flagValue])} strokeWidth={2} />+ </Button>+ </div>+ </DropdownMenuTrigger>+ <DropdownMenuContent className="bg-background" side="top" align="center">+ <DropdownMenuRadioGroup+ className="flex gap-1"+ value={flagValue || undefined}+ onValueChange={handleUpdateFlag}+ >+ {(Object.keys(flagColors) as flagColor[]).map((key) => (+ <DropdownMenuRadioItem+ onClick={(e) => e.stopPropagation()}+ className="w-7 flex items-center justify-center gap-1"+ value={key}+ >+ <Flag className={flagColors[key]} />+ </DropdownMenuRadioItem>+ ))}+ </DropdownMenuRadioGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ )+}diff --git a/flowsint-app/src/components/sketches/graph/actions/node-actions.tsx b/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsxsimilarity index 89%rename from flowsint-app/src/components/sketches/graph/actions/node-actions.tsxrename to flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsxindex 61c5030a..ae13fdfe 100644--- a/flowsint-app/src/components/sketches/graph/actions/node-actions.tsx+++ b/flowsint-app/src/components/sketches/graph/node/actions/node-actions.tsx@@ -1,6 +1,6 @@import React, { memo, useCallback } from 'react'import { Button } from '@/components/ui/button'-import { Pencil, Trash2, Sparkles, Plus } from 'lucide-react'+import { Trash2, Sparkles, Plus } from 'lucide-react'import { useGraphStore } from '@/stores/graph-store'import { useParams } from '@tanstack/react-router'import { useConfirm } from '@/components/use-confirm-dialog'@@ -10,6 +10,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/compimport { useLayoutStore } from '@/stores/layout-store'import { GraphNode } from '@/types'import { useGraphSettingsStore } from '@/stores/graph-settings-store'+import { NodeFlag } from './flag'const NodeActions = memo(({ node, setMenu }: { node: GraphNode; setMenu?: (menu: any | null) => void }) => {@@ -20,8 +21,6 @@ const NodeActions = memo(const removeNodes = useGraphStore((s) => s.removeNodes)const toggleNodeSelection = useGraphStore((s) => s.toggleNodeSelection)const openChat = useLayoutStore((s) => s.openChat)- const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)- const setOpenNodeEditorModal = useGraphStore((s) => s.setOpenNodeEditorModal)const settings = useGraphSettingsStore((s) => s.settings)// Add relation dialog@@ -42,17 +41,6 @@ const NodeActions = memo([node, toggleNodeSelection, openChat, setMenu])- // Edit node dialog- const handleEditNode = useCallback(- (e: React.MouseEvent) => {- e.stopPropagation()- setCurrentNodeId(node.id)- setOpenNodeEditorModal(true)- setMenu?.(null)- },- [node, setCurrentNodeId, setOpenNodeEditorModal]- )-// Delete nodeconst handleDeleteNode = async () => {if (!node.id || !sketchId) return@@ -69,7 +57,7 @@ const NodeActions = memo(return sketchService.deleteNodes(sketchId, JSON.stringify({ nodeIds: [node.id] }))})(),{- loading: `Deleting ${node.data.label}...`,+ loading: `Deleting ${node.nodeProperties.label}...`,success: 'Node deleted successfully.',error: 'Failed to delete node.'}@@ -78,6 +66,7 @@ const NodeActions = memo(return (<div className="flex items-center gap-1"><TooltipProvider>+ <NodeFlag node={node} sketchId={sketchId as string} /><Tooltip><TooltipTrigger asChild><div>@@ -114,7 +103,7 @@ const NodeActions = memo(</TooltipContent></Tooltip>)}- <Tooltip>+ {/*<Tooltip><TooltipTrigger asChild><div><Button@@ -130,7 +119,7 @@ const NodeActions = memo(<TooltipContent><p>Edit node</p></TooltipContent>- </Tooltip>+ </Tooltip>*/}<Tooltip><TooltipTrigger asChild><div>diff --git a/flowsint-app/src/components/sketches/graph/node/node-renderer.ts b/flowsint-app/src/components/sketches/graph/node/node-renderer.tsindex 4230283a..2e24ec83 100644--- a/flowsint-app/src/components/sketches/graph/node/node-renderer.ts+++ b/flowsint-app/src/components/sketches/graph/node/node-renderer.ts@@ -1,9 +1,72 @@+import { GraphNode } from '@/types'import { CONSTANTS, GRAPH_COLORS } from '../utils/constants'-import { getCachedImage, getCachedFlagImage } from '../utils/image-cache'+import {+ getCachedImage,+ getCachedFlagImage,+ getCachedIconByName,+ getCachedExternalImage+} from '../utils/image-cache'import { truncateText, calculateNodeSize } from '../utils/utils'+type NodeVisual = {+ image: HTMLImageElement+ isExternal: boolean+} | null++// Draws an image with object-cover behavior inside a circular clip+const drawCircularImage = (+ ctx: CanvasRenderingContext2D,+ img: HTMLImageElement,+ x: number,+ y: number,+ radius: number+) => {+ const diameter = radius * 2+ const imgAspect = img.naturalWidth / img.naturalHeight++ // Calculate cover dimensions (fill the circle, crop excess)+ let drawWidth: number, drawHeight: number+ if (imgAspect > 1) {+ // Landscape: height fills, width overflows+ drawHeight = diameter+ drawWidth = diameter * imgAspect+ } else {+ // Portrait or square: width fills, height overflows+ drawWidth = diameter+ drawHeight = diameter / imgAspect+ }++ ctx.beginPath()+ ctx.arc(x, y, radius, 0, 2 * Math.PI)+ ctx.clip()+ ctx.drawImage(img, x - drawWidth / 2, y - drawHeight / 2, drawWidth, drawHeight)+}++// Resolves the visual for a node with priority: nodeImage -> nodeIcon -> nodeType+const getNodeVisual = (node: GraphNode, iconColor: string): NodeVisual => {+ // Priority 1: External image (nodeImage URL)+ if (node.nodeImage) {+ const img = getCachedExternalImage(node.nodeImage)+ if (img?.complete) return { image: img, isExternal: true }+ }++ // Priority 2: Custom icon by name (nodeIcon)+ if (node.nodeIcon) {+ const img = getCachedIconByName(node.nodeIcon, iconColor)+ if (img?.complete) return { image: img, isExternal: false }+ }++ // Priority 3: Type-based icon (nodeType)+ if (node.nodeType) {+ const img = getCachedImage(node.nodeType, iconColor)+ if (img?.complete) return { image: img, isExternal: false }+ }++ return null+}+interface NodeRenderParams {- node: any+ node: GraphNodectx: CanvasRenderingContext2DglobalScale: numberforceSettings: any@@ -55,7 +118,12 @@ export const renderNode = ({if (!inViewport) returnconst shouldRenderDetails = globalScale > CONSTANTS.ZOOM_NODE_DETAIL_THRESHOLD- const size = calculateNodeSize(node, forceSettings, shouldRenderDetails, CONSTANTS.ZOOMED_OUT_SIZE_MULTIPLIER)+ const size = calculateNodeSize(+ node,+ forceSettings,+ shouldRenderDetails,+ CONSTANTS.ZOOMED_OUT_SIZE_MULTIPLIER+ )const isHighlighted = highlightNodes.has(node.id) || isSelected(node.id) || isCurrent(node.id)const hasAnyHighlight = highlightNodes.size > 0 || highlightLinks.size > 0@@ -105,10 +173,53 @@ export const renderNode = ({}// Only render details if zoomed in enough- if (!shouldRenderDetails) return+ if (!shouldRenderDetails) {+ // render flag+ if (node.nodeFlag) {+ const flagColors: Record<string, { stroke: string; fill: string }> = {+ red: { stroke: '#f87171', fill: '#fecaca' },+ orange: { stroke: '#fb923c', fill: '#fed7aa' },+ blue: { stroke: '#60a5fa', fill: '#bfdbfe' },+ green: { stroke: '#4ade80', fill: '#bbf7d0' },+ yellow: { stroke: '#facc15', fill: '#fef08a' }+ }++ const flagColor = flagColors[node.nodeFlag]+ if (flagColor) {+ const cachedFlag = getCachedFlagImage(flagColor.stroke, flagColor.fill)+ if (cachedFlag && cachedFlag.complete) {+ try {+ const flagSize = size * 0.8+ const flagX = node.x + 0.8 + size * 0.5 - flagSize / 2+ const flagY = node.y - 1.4 - size * 0.5 - flagSize / 2++ ctx.save()+ ctx.globalAlpha = 1+ ctx.drawImage(cachedFlag, flagX, flagY, flagSize, flagSize)+ ctx.restore()+ } catch (error) {+ console.warn('[node-renderer] Failed to draw flag:', error)+ }+ }+ }+ }++ // Draw a small rectangle to mock a label under the node+ const mockLabelWidth = 15+ const mockLabelHeight = 3+ const mockLabelY = node.y + size + mockLabelHeight * 0.5+ const mockLabelX = node.x - mockLabelWidth / 2+ const borderRadius = mockLabelHeight * 0.3++ ctx.beginPath()+ ctx.roundRect(mockLabelX, mockLabelY, mockLabelWidth, mockLabelHeight, borderRadius)+ ctx.fillStyle = theme === 'light' ? 'rgba(0, 0, 0, 0.15)' : 'rgba(255, 255, 255, 0.15)'+ ctx.fill()+ return+ }// Draw flag if present- if (node.data?.flag) {+ if (node.nodeFlag) {const flagColors: Record<string, { stroke: string; fill: string }> = {red: { stroke: '#f87171', fill: '#fecaca' },orange: { stroke: '#fb923c', fill: '#fed7aa' },@@ -117,7 +228,7 @@ export const renderNode = ({yellow: { stroke: '#facc15', fill: '#fef08a' }}- const flagColor = flagColors[node.data.flag]+ const flagColor = flagColors[node.nodeFlag]if (flagColor) {const cachedFlag = getCachedFlagImage(flagColor.stroke, flagColor.fill)if (cachedFlag && cachedFlag.complete) {@@ -137,38 +248,42 @@ export const renderNode = ({}}- // Render icons- if (showIcons && node.nodeType) {- // In outlined mode: white for dark theme, black for light theme- // In filled mode: always white+ // Render icons/images+ if (showIcons) {const iconColor = isOutlined ? (theme === 'dark' ? '#FFFFFF' : '#000000') : '#FFFFFF'- const cachedImage = getCachedImage(node.nodeType, iconColor)- if (cachedImage && cachedImage.complete) {+ const visual = getNodeVisual(node, iconColor)++ if (visual) {try {- // Dessiner l'icône au centre du node- const iconSize = size * 1.2- ctx.save()- // Apply transparency if node is not highlightedconst iconAlpha = hasAnyHighlight && !isHighlighted ? 0.5 : 0.9+ ctx.save()ctx.globalAlpha = iconAlpha- ctx.drawImage(cachedImage, node.x - iconSize / 2, node.y - iconSize / 2, iconSize, iconSize)++ if (visual.isExternal) {+ // External image: circular, 90% of node size, object-cover+ const imgRadius = size * 0.9+ drawCircularImage(ctx, visual.image, node.x, node.y, imgRadius)+ } else {+ // Icon: draw normally+ const iconSize = size * 1.2+ ctx.drawImage(+ visual.image,+ node.x - iconSize / 2,+ node.y - iconSize / 2,+ iconSize,+ iconSize+ )+ }+ctx.restore()} catch (error) {}- } else {- console.warn(- '[node-renderer] No cached image for type:',- node.nodeType,- 'color:',- iconColor,- 'complete:',- cachedImage?.complete- )}}// Render labelsif (showLabels) {- const label = truncateText(node.nodeLabel || node.label || node.id, 58)+ const anonymise = false // TODO+ const label = anonymise ? '**************' : truncateText(node.nodeLabel || node.id, 58)if (label) {const baseFontSize = Math.max(CONSTANTS.MIN_FONT_SIZE,@@ -210,7 +325,6 @@ export const renderNode = ({const metrics = ctx.measureText(label)const textY = bgY + paddingY + metrics.actualBoundingBoxAscent-ctx.fillText(label, node.x, textY)}}diff --git a/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx b/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsxindex b227dfae..a7b04293 100644--- a/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx+++ b/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx@@ -33,7 +33,7 @@ const NodeRenderer = memo(centerOnNode,autoZoomOnCurrentNode}: {- node: any+ node: GraphNodesetCurrentNodeId: (nodeId: string | null) => voidonCheckboxChange: (node: GraphNode, checked: boolean) => voidisNodeChecked: (nodeId: string) => boolean@@ -78,8 +78,8 @@ const NodeRenderer = memo()}onClick={handleClick}>- <div className="grow truncate text-ellipsis">{node?.data?.label}</div>- <TypeBadge className="ml-1" type={node?.data?.type} />+ <div className="grow truncate text-ellipsis">{node?.nodeLabel}</div>+ <TypeBadge className="ml-1" type={node?.nodeType} /></button></div>)@@ -126,31 +126,34 @@ const NodesPanel = memo(({ nodes, isLoading }: { nodes: GraphNode[]; isLoading?:const setSelectedNodes = useGraphStore((state) => state.setSelectedNodes)const selectedNodes = useGraphStore((state) => state.selectedNodes || [])const centerOnNode = useGraphControls((state) => state.centerOnNode)- const autoZoomOnCurrentNode = useGraphSettingsStore((s) => s.getSettingValue('general', 'autoZoomOnCurrentNode'))+ const autoZoomOnCurrentNode = useGraphSettingsStore((s) =>+ s.getSettingValue('general', 'autoZoomOnCurrentNode')+ )const [searchQuery, setSearchQuery] = useState<string>('')const [filters, setFilters] = useState<string[] | null>(null)- const types = useMemo(() => Array.from(new Set(nodes.map((n) => n.data.type))), [nodes])+ const types = useMemo(() => Array.from(new Set(nodes.map((n) => n.nodeType))), [nodes])// Ref pour le conteneur parent du virtualizerconst parentRef = useRef<HTMLDivElement>(null)const filteredNodes = useMemo(() => {const searchText = searchQuery.toLowerCase()- return nodes?.filter((node) => {- const matchesSearch =- //@ts-ignore- node?.data?.label?.toLowerCase().includes(searchText) ||- node?.id?.toLowerCase().includes(searchText)+ return nodes+ ?.filter((node) => {+ const matchesSearch =+ node?.nodeLabel?.toLowerCase().includes(searchText) ||+ node?.id?.toLowerCase().includes(searchText)- const matchesFilter =- !filters ||- filters.some(- (filter) => filter.toLowerCase() === (node?.data?.type as string)?.toLowerCase()- )+ const matchesFilter =+ !filters ||+ filters.some(+ (filter) => filter.toLowerCase() === (node.nodeType as string)?.toLowerCase()+ )- return matchesSearch && matchesFilter- }).sort((a, b) => a.data.type.localeCompare(b.data.type));+ return matchesSearch && matchesFilter+ })+ .sort((a, b) => a.nodeType.localeCompare(b.nodeType))}, [nodes, searchQuery, filters])// Configuration du virtualizer@@ -226,7 +229,7 @@ const NodesPanel = memo(({ nodes, isLoading }: { nodes: GraphNode[]; isLoading?:return (<div className="overflow-hidden bg-card h-full flex flex-col w-full !p-0 !m-0">{/* Header fixe */}- <div className="sticky border-b top-0 p-2 bg-card z-10 flex-shrink-0">+ <div className="sticky border-b top-0 p-2 bg-card z-10 shrink-0"><div className="flex items-center gap-2"><div><Checkbox onCheckedChange={handleCheckAll} className="mr-1" />diff --git a/flowsint-app/src/components/sketches/graph/panels/selected-items-panel.tsx b/flowsint-app/src/components/sketches/graph/panels/selected-items-panel.tsxindex affb833c..5c322b33 100644--- a/flowsint-app/src/components/sketches/graph/panels/selected-items-panel.tsx+++ b/flowsint-app/src/components/sketches/graph/panels/selected-items-panel.tsx@@ -42,9 +42,9 @@ const SelectedNodeItem = memo(({ node }: { node: GraphNode; color: string }) =>className="flex w-full items-center justify-between text-left border border-border gap-1.5 text-xs p-2 py-1.5"><span className="inline-flex items-center gap-2 truncate text-ellipsis">- <span className="truncate text-ellipsis">{node.data?.label || 'Unknown'}</span>+ <span className="truncate text-ellipsis">{node.nodeLabel || 'Unknown'}</span></span>- <TypeBadge type={node?.data?.type} />+ <TypeBadge type={node?.nodeType} /></Badge>)})@@ -57,7 +57,7 @@ export const SelectedList = () => {return (<div className="flex flex-col gap-1.5 p-1">{displayItems.map((item: GraphNode, index: number) => {- const color = colors[item.data.type as ItemType] ?? '#999999'+ const color = colors[item.nodeType as ItemType] ?? '#999999'return <SelectedNodeItem key={index} node={item} color={color} />})}{remainingCount > 0 && (@@ -121,8 +121,8 @@ const ActionBar = () => {)}, [selectedNodes, confirm, removeNodes, clearSelectedNodes, sketchId])- const type = selectedNodes[0].data.type- const isSametype = (node: GraphNode) => node.data.type === type+ const type = selectedNodes[0].nodeType+ const isSametype = (node: GraphNode) => node.nodeType === typeconst shareSameType = selectedNodes.every(isSametype)const values = !shareSameType ? [] : selectedNodes.map((node: GraphNode) => node.id)diff --git a/flowsint-app/src/components/sketches/graph/utils/constants.ts b/flowsint-app/src/components/sketches/graph/utils/constants.tsindex 6fddc813..66ef584f 100644--- a/flowsint-app/src/components/sketches/graph/utils/constants.ts+++ b/flowsint-app/src/components/sketches/graph/utils/constants.ts@@ -35,7 +35,7 @@ export const CONSTANTS = {MAX_ZOOM: 12,ZOOM_NODE_DETAIL_THRESHOLD: 2,ZOOM_EDGE_DETAIL_THRESHOLD: 1,- ZOOMED_OUT_SIZE_MULTIPLIER: 3+ ZOOMED_OUT_SIZE_MULTIPLIER: 2.5}// Reusable objects to avoid allocationsdiff --git a/flowsint-app/src/components/sketches/graph/utils/export-to-png.ts b/flowsint-app/src/components/sketches/graph/utils/export-to-png.tsnew file mode 100644index 00000000..d07219f2--- /dev/null+++ b/flowsint-app/src/components/sketches/graph/utils/export-to-png.ts@@ -0,0 +1,29 @@+export const exportToPNG = async (canvaId: string, sketchId: string) => {+ if (!canvaId) {+ throw new Error('Graph ref not available')+ }+ // Get the canvas element from the ForceGraph2D component+ const canvas = document.getElementById(canvaId) as HTMLCanvasElement+ if (!canvas) {+ throw new Error('Canvas element not found')+ }+ return new Promise<void>((resolve, reject) => {+ canvas.toBlob((blob) => {+ if (!blob) {+ reject(new Error('Failed to create image blob'))+ return+ }+ // Create download link+ const url = URL.createObjectURL(blob)+ const a = document.createElement('a')+ a.href = url+ a.download = `sketch-${sketchId || 'export'}-${Date.now()}.png`+ document.body.appendChild(a)+ a.click()+ // Cleanup+ URL.revokeObjectURL(url)+ document.body.removeChild(a)+ resolve()+ }, 'image/png')+ })+}\ No newline at end of filediff --git a/flowsint-app/src/components/sketches/graph/utils/graph-data-transformer.ts b/flowsint-app/src/components/sketches/graph/utils/graph-data-transformer.tsindex c2c98414..e173aac4 100644--- a/flowsint-app/src/components/sketches/graph/utils/graph-data-transformer.ts+++ b/flowsint-app/src/components/sketches/graph/utils/graph-data-transformer.ts@@ -15,16 +15,15 @@ export const transformGraphData = ({nodeColors}: TransformGraphDataParams): GraphData => {const transformedNodes = nodes.map((node) => {- const type = node.data?.type as ItemType+ const type = node.nodeType as ItemTypeconst baseNodeSize = CONSTANTS.NODE_DEFAULT_SIZE-+ const nodeSize = node.nodeSize || baseNodeSizeconst transformed = {...node,- nodeLabel: node.data?.label || node.id,- nodeColor: nodeColors[type] || GRAPH_COLORS.NODE_DEFAULT,- nodeSize: baseNodeSize,- nodeType: type,- val: (baseNodeSize * CONSTANTS.ZOOMED_OUT_SIZE_MULTIPLIER) / 5,+ nodeLabel: node.nodeLabel || node.id,+ nodeColor: node.nodeColor || nodeColors[type] || GRAPH_COLORS.NODE_DEFAULT,+ nodeSize: nodeSize,+ val: (nodeSize * CONSTANTS.ZOOMED_OUT_SIZE_MULTIPLIER) / 5,neighbors: [] as any[],links: [] as any[]} as anydiff --git a/flowsint-app/src/components/sketches/graph/utils/image-cache.tsx b/flowsint-app/src/components/sketches/graph/utils/image-cache.tsxindex 46648ef8..1bc17920 100644--- a/flowsint-app/src/components/sketches/graph/utils/image-cache.tsx+++ b/flowsint-app/src/components/sketches/graph/utils/image-cache.tsx@@ -6,24 +6,23 @@ import { renderToStaticMarkup } from 'react-dom/server'const imageCache = new Map<string, HTMLImageElement>()const imageLoadPromises = new Map<string, Promise<HTMLImageElement>>()-const createSvgDataUrl = (iconType: string, color: string = '#FFFFFF'): string => {- // Check custom icons first, then fall back to default mapping- const customIcons = useNodesDisplaySettings.getState().customIcons- const iconName = customIcons[iconType] || TYPE_TO_ICON[iconType] || TYPE_TO_ICON.default+const FALLBACK_SVG = (color: string) =>+ `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="${color}" stroke-width="2"><circle cx="12" cy="12" r="10"/></svg>`++const createSvgFromIconName = (iconName: string, color: string): string => {const IconComponent = (lucideIcons as any)[iconName]let svgString: string-if (IconComponent) {try {svgString = renderToStaticMarkup(<IconComponent color={color} />)} catch (err) {- console.warn('[icon] Failed to render icon, fallback used for', iconType)- svgString = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="${color}" stroke-width="2"><circle cx="12" cy="12" r="10"/></svg>`+ console.warn('[icon] Failed to render icon:', iconName)+ svgString = FALLBACK_SVG(color)}} else {- console.warn('[icon] Icon not found, fallback used for', iconType, iconName)- svgString = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="${color}" stroke-width="2"><circle cx="12" cy="12" r="10"/></svg>`+ console.warn('[icon] Icon not found:', iconName)+ svgString = FALLBACK_SVG(color)}const utf8 = encodeURIComponent(svgString).replace(/%([0-9A-F]{2})/g, (_, p1) =>@@ -33,6 +32,12 @@ const createSvgDataUrl = (iconType: string, color: string = '#FFFFFF'): string =return `data:image/svg+xml;base64,${btoa(utf8)}`}+const createSvgDataUrl = (iconType: string, color: string = '#FFFFFF'): string => {+ const customIcons = useNodesDisplaySettings.getState().customIcons+ const iconName = customIcons[iconType] || TYPE_TO_ICON[iconType] || TYPE_TO_ICON.default+ return createSvgFromIconName(iconName, color)+}+export const preloadImage = (iconType: string,color: string = '#FFFFFF'@@ -73,6 +78,83 @@ export const getCachedImage = (return imageCache.get(`${iconType}-${color}`)}+// Direct icon name lookup (bypasses type→icon mapping)+export const preloadIconByName = (+ iconName: string,+ color: string = '#FFFFFF'+): Promise<HTMLImageElement> => {+ const cacheKey = `icon-${iconName}-${color}`++ if (imageCache.has(cacheKey)) {+ return Promise.resolve(imageCache.get(cacheKey)!)+ }++ if (imageLoadPromises.has(cacheKey)) {+ return imageLoadPromises.get(cacheKey)!+ }++ const promise = new Promise<HTMLImageElement>((resolve, reject) => {+ const img = new Image()+ img.onload = () => {+ imageCache.set(cacheKey, img)+ imageLoadPromises.delete(cacheKey)+ resolve(img)+ }+ img.onerror = () => {+ imageLoadPromises.delete(cacheKey)+ reject(new Error(`Failed to load icon: ${iconName}`))+ }++ img.src = createSvgFromIconName(iconName, color)+ })++ imageLoadPromises.set(cacheKey, promise)+ return promise+}++export const getCachedIconByName = (+ iconName: string,+ color: string = '#FFFFFF'+): HTMLImageElement | undefined => {+ return imageCache.get(`icon-${iconName}-${color}`)+}++// External image caching (for nodeImage URLs)+export const preloadExternalImage = (url: string): Promise<HTMLImageElement> => {+ const cacheKey = `ext-${url}`++ if (imageCache.has(cacheKey)) {+ return Promise.resolve(imageCache.get(cacheKey)!)+ }++ if (imageLoadPromises.has(cacheKey)) {+ return imageLoadPromises.get(cacheKey)!+ }++ const promise = new Promise<HTMLImageElement>((resolve, reject) => {+ const img = new Image()+ img.crossOrigin = 'anonymous'+ img.onload = () => {+ imageCache.set(cacheKey, img)+ imageLoadPromises.delete(cacheKey)+ resolve(img)+ }+ img.onerror = () => {+ imageLoadPromises.delete(cacheKey)+ reject(new Error(`Failed to load external image: ${url}`))+ }++ img.src = url+ })++ imageLoadPromises.set(cacheKey, promise)+ return promise+}++export const getCachedExternalImage = (url: string): HTMLImageElement | undefined => {+ return imageCache.get(`ext-${url}`)+}+const createFlagSvgDataUrl = (strokeColor: string, fillColor: string): string => {const svgString = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z" fill="${fillColor}" stroke="${strokeColor}"/>diff --git a/flowsint-app/src/components/sketches/import-preview.tsx b/flowsint-app/src/components/sketches/import-preview.tsxindex bc846b39..ea836f3f 100644--- a/flowsint-app/src/components/sketches/import-preview.tsx+++ b/flowsint-app/src/components/sketches/import-preview.tsx@@ -23,7 +23,7 @@ interface EntityMapping {id: stringentity_type: stringinclude: boolean- label: string+ nodeLabel: stringnode_id?: stringdata: Record<string, any>}@@ -167,7 +167,7 @@ const EntityRow = memo(<div className="px-3 py-2 border-r w-[200px] shrink-0"><DebouncedInputclassName="h-8 w-full text-xs"- value={mapping.label}+ value={mapping.nodeLabel}onChange={handleLabel}disabled={!mapping.include}placeholder="Label..."@@ -399,7 +399,7 @@ export function ImportPreview({typeFields.forEach((field) => {data[field] = entity.obj[field] ?? ''})- data.label = entity.obj.label+ data.nodeLabel = entity.obj.nodeLabelconst id = uuidv4()ids.push(id)@@ -408,7 +408,7 @@ export function ImportPreview({id,entity_type: entity.detected_type,include: true,- label: entity.obj.label,+ nodeLabel: entity.obj.nodeLabel,node_id: entity?.node_id?.toString(),data})@@ -487,7 +487,7 @@ export function ImportPreview({newFields.forEach((field) => {newData[field] = mapping.data[field] ?? ''})- newData.label = mapping.label+ newData.nodeLabel = mapping.nodeLabelconst newMap = new Map(prev)newMap.set(id, { ...mapping, entity_type: newType, data: newData })@@ -502,7 +502,7 @@ export function ImportPreview({const mapping = prev.get(id)if (!mapping) return prevconst newMap = new Map(prev)- newMap.set(id, { ...mapping, label })+ newMap.set(id, { ...mapping, nodeLabel: label })return newMap})}, [])diff --git a/flowsint-app/src/components/sketches/index.tsx b/flowsint-app/src/components/sketches/index.tsxindex 755ae021..a884aac6 100644--- a/flowsint-app/src/components/sketches/index.tsx+++ b/flowsint-app/src/components/sketches/index.tsx@@ -8,7 +8,6 @@ import { CreateRelationDialog } from './create-relation'import GraphLoader from './graph/components/graph-loader'import Loader from '../loader'import { useGraphControls } from '@/stores/graph-controls-store'-import { NodeEditorModal } from './details-panel/node-editor-modal'import NodesTable from '../table'import { findActionItemByKey } from '@/lib/action-items'import { useActionItems } from '@/hooks/use-action-items'@@ -62,7 +61,7 @@ const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {useEffect(() => {if (graphData?.nds && graphData?.rls) {updateGraphData(graphData.nds, graphData.rls)- const types = new Set(graphData.nds.map((n) => n.data.type))+ const types = new Set(graphData.nds.map((n) => n.nodeType))setFilters({...filters,types: Array.from(types).map((t) => ({@@ -148,7 +147,6 @@ const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {<NewActions /><CreateRelationDialog /><MergeDialog />- <NodeEditorModal /><Settings /><KeyboardShortcuts /></div>diff --git a/flowsint-app/src/components/sketches/settings/settings.tsx b/flowsint-app/src/components/sketches/settings/settings.tsxindex 30c54692..5b80ecf8 100644--- a/flowsint-app/src/components/sketches/settings/settings.tsx+++ b/flowsint-app/src/components/sketches/settings/settings.tsx@@ -21,7 +21,7 @@ import { Skeleton } from '@/components/ui/skeleton'import { Switch } from '@/components/ui/switch'import { Slider } from '@/components/ui/slider'import { toast } from 'sonner'-+import { clearIconTypeCache } from '@/components/sketches/graph/utils/image-cache'import { useGraphSettingsStore } from '@/stores/graph-settings-store'import { isMacOS } from '@/components/analyses/editor/utils'import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'@@ -32,8 +32,7 @@ import { useState, useEffect, useCallback, useRef } from 'react'import { queryKeys } from '@/api/query-keys'import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'import { useNodesDisplaySettings, ITEM_TYPES, ItemType } from '@/stores/node-display-settings'-import { NodeIconTrigger } from './icon-picker/trigger'-import IconPicker from './icon-picker/popup'+import IconPicker, { NodeIconTrigger } from '@/components/shared/icon-picker'// SettingItem Componentsinterface SettingItemProps {@@ -216,6 +215,8 @@ function NodeColorsSection() {const randomizeColors = useNodesDisplaySettings((s) => s.randomizeColors)const [openIconPicker, setOpenIconPicker] = useState(false)const [currentType, setCurrentType] = useState<string | null>(null)+ const { setIcon } = useNodesDisplaySettings()+const handleOpenIconPicker = useCallback((type: string) => {setOpenIconPicker(true)setCurrentType(type)@@ -260,6 +261,12 @@ function NodeColorsSection() {randomizeColors()}, [])+ const handleIconSelect = (iconType: string, iconName: string) => {+ // @ts-ignore+ setIcon(iconType, iconName)+ clearIconTypeCache(iconType)+ }+const handleReset = useCallback(() => {// Clear all pending timersdebounceTimers.current.forEach((timer) => clearTimeout(timer))@@ -284,7 +291,6 @@ function NodeColorsSection() {Customize the node styles for each type in the graph visualization.</p></div>-<div className="border-b flex items-center gap-2 pb-4"><Button variant="outline" size="sm" onClick={handleReset} className="grow shadow-none">Reset to default@@ -298,7 +304,6 @@ function NodeColorsSection() {Randomize</Button></div>-<div className="pr-4"><div className="space-y-4 pb-6">{ITEM_TYPES.map((itemType) => (@@ -332,7 +337,13 @@ function NodeColorsSection() {))}</div></div>- <IconPicker open={openIconPicker} setOpen={setOpenIconPicker} iconType={currentType} />+ <IconPicker+ // @ts-ignore+ onIconChange={handleIconSelect}+ open={openIconPicker}+ setOpen={setOpenIconPicker}+ iconType={currentType}+ /></div>)}diff --git a/flowsint-app/src/components/sketches/toolbar.tsx b/flowsint-app/src/components/sketches/toolbar.tsxindex 1b97228c..5bf6ad90 100644--- a/flowsint-app/src/components/sketches/toolbar.tsx+++ b/flowsint-app/src/components/sketches/toolbar.tsx@@ -36,6 +36,7 @@ import {} from '@/components/ui/dropdown-menu'import { sketchService } from '@/api/sketch-service'import { useParams } from '@tanstack/react-router'+import { exportToPNG } from './graph/utils/export-to-png'// Tooltip wrapper component to avoid repetitionexport const ToolbarButton = memo(function ToolbarButton({@@ -68,7 +69,7 @@ export const ToolbarButton = memo(function ToolbarButton({'h-7 relative items-center shadow-none',!showLabel && 'w-7',toggled &&- 'bg-primary/30 border-primary/40 text-primary hover:bg-primary/40 hover:text-primary'+ 'bg-primary/30 border-primary/40 text-primary hover:bg-primary/40 hover:text-primary')}>{icon} {showLabel && <span className="hidden md:block">{tooltip}</span>}@@ -95,7 +96,6 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: booleanconst zoomOut = useGraphControls((s) => s.zoomOut)const regenerateLayout = useGraphControls((s) => s.regenerateLayout)const refetchGraph = useGraphControls((s) => s.refetchGraph)- const exportToPNG = useGraphControls((s) => s.exportToPNG)const isSelectorModeActive = useGraphControls((s) => s.isSelectorModeActive)const setIsSelectorModeActive = useGraphControls((s) => s.setIsSelectorModeActive)const selectionMode = useGraphControls((s) => s.selectionMode)@@ -187,7 +187,7 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: booleanif (!sketchId) returntry {if (format === 'png') {- await exportToPNG()+ await exportToPNG("null", "null")} else {await sketchService.exportSketch(sketchId, format)}@@ -204,7 +204,7 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: booleanconst areExactlyTwoSelected = selectedNodes.length === 2const areMergeable =selectedNodes.length > 1 &&- selectedNodes.every((n) => n.data.type === selectedNodes[0].data.type)+ selectedNodes.every((n) => n.nodeType === selectedNodes[0].nodeType)const hasFilters = !(filters.types.every((t) => t.checked) || filters.types.every((t) => !t.checked))@@ -267,7 +267,7 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: booleanclassName={cn('h-7 w-7 rounded relative items-center shadow-none',isSelectorModeActive &&- 'bg-primary/30 border-primary/40 text-primary hover:bg-primary/40 hover:text-primary'+ 'bg-primary/30 border-primary/40 text-primary hover:bg-primary/40 hover:text-primary')}>{selectionMode === 'lasso' ? (@@ -292,7 +292,7 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: booleanclassName={cn('h-7 w-5 px-0 rounded relative items-center shadow-none',isSelectorModeActive &&- 'bg-primary/30 border-primary/40 text-primary hover:bg-primary/40 hover:text-primary'+ 'bg-primary/30 border-primary/40 text-primary hover:bg-primary/40 hover:text-primary')}><ChevronDown className="h-3 w-3 opacity-50" />@@ -384,7 +384,7 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: booleanicon={<RotateCw className={cn('h-4 w-4 opacity-70', isLoading && 'animate-spin')} />}tooltip="Refresh"/>- <SaveStatusIndicator status={saveStatus} />+ <SaveStatusIndicator /></div></div>)diff --git a/flowsint-app/src/components/table/columns.tsx b/flowsint-app/src/components/table/columns.tsxindex 866d1bda..61e58299 100644--- a/flowsint-app/src/components/table/columns.tsx+++ b/flowsint-app/src/components/table/columns.tsx@@ -141,7 +141,7 @@ export const columns: ColumnDef<GraphNode>[] = [size: 200,minSize: 120,maxSize: 500,- accessorKey: 'data.label',+ accessorKey: 'nodeLabel',header: ({ column }) => {return (<Button@@ -156,7 +156,7 @@ export const columns: ColumnDef<GraphNode>[] = [},cell: ({ row }) => {const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)- // const IconComponent = useIcon(row.original.data.type)+ // const IconComponent = useIcon(row.original.nodeType)const setOpenNodeEditorModal = useGraphStore((s) => s.setOpenNodeEditorModal)const openEdit = useCallback((e: React.MouseEvent) => {@@ -172,7 +172,7 @@ export const columns: ColumnDef<GraphNode>[] = [onClick={openEdit}className="text-left font-medium flex items-center gap-2 h-full truncate text-ellipsis w-full rounded-md p-2 transition-colors duration-500">- {/* <div className="flex-shrink-0">+ {/* <div className="shrink-0"><IconComponent size={16} /></div> */}<span className="hover:text-primary truncate text-[.9rem] block font-medium transition-colors duration-500">@@ -199,9 +199,9 @@ export const columns: ColumnDef<GraphNode>[] = [size: 120,minSize: 80,maxSize: 200,- accessorKey: 'data.type',+ accessorKey: 'nodeType',cell: ({ row }) => {- const type = row.original.data.type+ const type = row.original.nodeTypereturn (<div className="text-center flex justify-center w-full font-medium flex items-center gap-2"><TypeBadge className="w-full" type={type} />diff --git a/flowsint-app/src/components/table/nodes-view.tsx b/flowsint-app/src/components/table/nodes-view.tsxindex c6e0eb42..e672faf2 100644--- a/flowsint-app/src/components/table/nodes-view.tsx+++ b/flowsint-app/src/components/table/nodes-view.tsx@@ -39,7 +39,11 @@ const NodeItem = memo(function NodeItem({isSelected,onSelectionChange}: NodeItemProps) {- const SourceIcon = useIcon(node.data?.type, node.data?.src)+ const SourceIcon = useIcon(node.nodeType, {+ nodeColor: node.nodeColor,+ nodeIcon: node.nodeIcon,+ nodeImage: node.nodeImage+ })const handleNodeClick = useCallback(() => {onNodeClick(node)@@ -62,10 +66,8 @@ const NodeItem = memo(function NodeItem({const formatNodeData = useCallback((data: any) => {if (!data) return ''- const omitKeys = ['id', 'sketch_id', 'caption', 'size', 'color', 'description', 'x', 'y']const entries = Object.entries(data)- .filter(([key]) => !omitKeys.includes(key))- .map(([key, value]) => `${key}:${Boolean(value) ? value : "N/A"}`)+ .map(([key, value]) => `${key}:${Boolean(value) ? value : 'N/A'}`).join(', ')return entries}, [])@@ -73,7 +75,7 @@ const NodeItem = memo(function NodeItem({return (<div className="px-4"><div- className="grid items-center h-[56px] gap-3 text-sm border-b last:border-b-0"+ className="grid items-center h-14 gap-3 text-sm border-b last:border-b-0"style={{gridTemplateColumns: '24px 32px auto 1fr 140px 160px 32px'}}@@ -96,21 +98,21 @@ const NodeItem = memo(function NodeItem({onClick={handleNodeClick}className="font-medium hover:text-primary hover:underline cursor-pointer truncate p-0">- <span className="block truncate">{node.data?.label ?? node.id}</span>+ <span className="block truncate">{node.nodeLabel ?? node.id}</span></button></div>{/* Data */}<div className="min-w-0"><span className="text-xs text-muted-foreground truncate block">- {formatNodeData(node.data)}+ {formatNodeData(node.nodeProperties)}</span></div>{/* Type */}<div><Badge variant="outline" className="text-xs">- {node.data?.type || 'Unknown'}+ {node.nodeType || 'Unknown'}</Badge></div>@@ -118,13 +120,15 @@ const NodeItem = memo(function NodeItem({<div className="flex items-center gap-1 text-xs text-muted-foreground min-w-0"><Calendar className="h-3 w-3" /><span className="truncate">- {node.data?.created_at ? formatCreatedAt(node.data.created_at) : 'Unknown'}+ {node.nodeMetadata?.created_at+ ? formatCreatedAt(node.nodeMetadata?.created_at)+ : 'Unknown'}</span></div>{/* Copy Button */}<div className="flex justify-end">- <CopyButton content={node.data?.label ?? node.id} />+ <CopyButton content={node.nodeLabel ?? node.id} /></div></div></div>@@ -155,11 +159,11 @@ export default function NodesTable({ nodes }: NodesTableProps) {return nodes.filter((node: GraphNode) => {const lower = searchQuery.toLowerCase()- const label = node.data?.label?.toLowerCase() ?? ''- const type = node.data?.type?.toLowerCase() ?? ''+ const label = node.nodeLabel?.toLowerCase() ?? ''+ const type = node.nodeType?.toLowerCase() ?? ''const matchesSearch = lower === '' || label.includes(lower) || type.includes(lower)- const matchesType = selectedType === 'all' || node.data?.type === selectedType+ const matchesType = selectedType === 'all' || node.nodeType === selectedTypereturn matchesSearch && matchesType})@@ -209,7 +213,7 @@ export default function NodesTable({ nodes }: NodesTableProps) {if (!nodes) return []const types = new Set<string>()nodes.forEach((node: GraphNode) => {- if (node.data?.type) types.add(node.data.type)+ if (node.nodeType) types.add(node.nodeType)})return Array.from(types).sort()}, [nodes])@@ -279,7 +283,7 @@ export default function NodesTable({ nodes }: NodesTableProps) {</div>{/* Table Header */}<div- className="grid items-center h-[44px] px-4 bg-muted/50 p-2 rounded-t-md border text-sm font-medium text-muted-foreground"+ className="grid items-center h-11 px-4 bg-muted/50 p-2 rounded-t-md border text-sm font-medium text-muted-foreground"style={{ gridTemplateColumns: '24px 32px auto 1fr 140px 160px 32px' }}><div className="flex items-center">@@ -287,7 +291,7 @@ export default function NodesTable({ nodes }: NodesTableProps) {checked={isAllSelected}ref={(el) => {if (el && 'indeterminate' in el) {- ; (el as HTMLInputElement).indeterminate = isIndeterminate+ ;(el as HTMLInputElement).indeterminate = isIndeterminate}}}onCheckedChange={handleSelectAll}diff --git a/flowsint-app/src/components/table/relationships-view.tsx b/flowsint-app/src/components/table/relationships-view.tsxindex 26255626..8493d1ce 100644--- a/flowsint-app/src/components/table/relationships-view.tsx+++ b/flowsint-app/src/components/table/relationships-view.tsx@@ -36,9 +36,23 @@ interface RelationshipItemProps {onSelectionChange: (edge: GraphEdge, checked: boolean) => void}-function RelationshipItem({ relationship, style, onNodeClick, isSelected, onSelectionChange }: RelationshipItemProps) {- const SourceIcon = useIcon(relationship.source.data?.type, relationship.source.data?.src)- const TargetIcon = useIcon(relationship.target.data?.type, relationship.target.data?.src)+function RelationshipItem({+ relationship,+ style,+ onNodeClick,+ isSelected,+ onSelectionChange+}: RelationshipItemProps) {+ const SourceIcon = useIcon(relationship.source.nodeType, {+ nodeColor: relationship.source.nodeColor,+ nodeIcon: relationship.source.nodeIcon,+ nodeImage: relationship.source.nodeImage+ })+ const TargetIcon = useIcon(relationship.target.nodeType, {+ nodeColor: relationship.target.nodeColor,+ nodeIcon: relationship.target.nodeIcon,+ nodeImage: relationship.target.nodeImage+ })const handleNodeClickSource = useCallback(() => {onNodeClick(relationship.source)@@ -59,13 +73,13 @@ function RelationshipItem({ relationship, style, onNodeClick, isSelected, onSele<Card className="h-[55px] p-0 rounded-md"><CardContent className="p-3 h-[55px] flex items-center gap-3 min-w-0">{/* Checkbox */}- <div className="flex items-center flex-shrink-0">+ <div className="flex items-center shrink-0"><Checkbox checked={isSelected} onCheckedChange={handleCheckboxChange} /></div>{/* 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 flex-shrink-0">+ <div className="flex items-center justify-center w-7 h-7 rounded-full bg-muted shrink-0"><SourceIcon size={16} /></div><button@@ -73,39 +87,39 @@ function RelationshipItem({ relationship, style, onNodeClick, isSelected, onSeleclassName="font-medium text-sm hover:text-primary hover:underline cursor-pointer text-left min-w-0 flex-1"><span className="block truncate">- {relationship.source.data?.label ?? relationship.source.id}+ {relationship.source.nodeLabel ?? relationship.source.id}</span></button>- <div className="flex-shrink-0">- <CopyButton content={relationship.source.data?.label ?? relationship.source.id} />+ <div className="shrink-0">+ <CopyButton content={relationship.source.nodeLabel ?? relationship.source.id} /></div></div>{/* Relationship Arrow */}- <div className="flex items-center grow justify-center px-2 flex-shrink-0 min-w-[120px] max-w-[30%]">+ <div className="flex items-center grow justify-center px-2 shrink-0 min-w-[120px] max-w-[30%]"><div className="flex items-center justify-center gap-1.5 text-xs text-muted-foreground w-full"><div className="h-px bg-muted-foreground/30 w-[8px]"></div><span className="px-2 py-1 bg-muted/50 rounded-sm truncate max-w-full">{relationship.edge.label}</span>- <ArrowRight className="h-3.5 w-3.5 text-muted-foreground/50 flex-shrink-0" />+ <ArrowRight className="h-3.5 w-3.5 text-muted-foreground/50 shrink-0" /></div></div>{/* Target Node */}<div className="flex items-center gap-2 flex-1 justify-end min-w-0 max-w-[35%]">- <div className="flex-shrink-0">- <CopyButton content={relationship.target.data?.label ?? relationship.target.id} />+ <div className="shrink-0">+ <CopyButton content={relationship.target.nodeLabel ?? relationship.target.id} /></div><buttononClick={handleNodeClickTarget}className="font-medium text-sm hover:text-primary hover:underline cursor-pointer text-right min-w-0 flex-1"><span className="block truncate">- {relationship.target.data?.label || relationship.target.id}+ {relationship.target.nodeLabel || relationship.target.id}</span></button>- <div className="flex items-center justify-center w-7 h-7 rounded-full bg-muted flex-shrink-0">+ <div className="flex items-center justify-center w-7 h-7 rounded-full bg-muted shrink-0"><TargetIcon size={16} /></div></div>@@ -119,7 +133,11 @@ export default function RelationshipsTable() {const { id: sketchId } = useParams({from: '/_auth/dashboard/investigations/$investigationId/$type/$id'})- const { data: relationships, isLoading } = useQuery({+ const {+ data: relationships,+ isLoading,+ refetch+ } = useQuery({queryKey: ['graph', 'relationships_view', sketchId],enabled: Boolean(sketchId),queryFn: () => sketchService.getGraphDataById(sketchId as string, true)@@ -154,14 +172,14 @@ export default function RelationshipsTable() {return relationships.filter((rel: RelationshipType) => {const matchesSearch =searchQuery === '' ||- rel.source.data?.label?.toLowerCase().includes(searchQuery.toLowerCase()) ||- rel.target.data?.label?.toLowerCase().includes(searchQuery.toLowerCase()) ||+ rel.source.nodeLabel?.toLowerCase().includes(searchQuery.toLowerCase()) ||+ rel.target.nodeLabel?.toLowerCase().includes(searchQuery.toLowerCase()) ||rel.edge.label?.toLowerCase().includes(searchQuery.toLowerCase())const matchesType =selectedType === 'all' ||- rel.source.data?.type === selectedType ||- rel.target.data?.type === selectedType+ rel.source.nodeType === selectedType ||+ rel.target.nodeType === selectedTypereturn matchesSearch && matchesType})@@ -172,8 +190,8 @@ export default function RelationshipsTable() {if (!relationships) return []const types = new Set<string>()relationships.forEach((rel: RelationshipType) => {- if (rel.source.data?.type) types.add(rel.source.data.type)- if (rel.target.data?.type) types.add(rel.target.data.type)+ if (rel.source.nodeType) types.add(rel.source.nodeType)+ if (rel.target.nodeType) types.add(rel.target.nodeType)})return Array.from(types).sort()}, [relationships])@@ -209,11 +227,16 @@ export default function RelationshipsTable() {)const isAllSelected = useMemo(() => {- return filteredRelationships.length > 0 && filteredRelationships.every((rel: RelationshipType) => isEdgeSelected(rel.edge.id))+ return (+ filteredRelationships.length > 0 &&+ filteredRelationships.every((rel: RelationshipType) => isEdgeSelected(rel.edge.id))+ )}, [filteredRelationships, isEdgeSelected])const isIndeterminate = useMemo(() => {- const selectedCount = filteredRelationships.filter((rel: RelationshipType) => isEdgeSelected(rel.edge.id)).length+ const selectedCount = filteredRelationships.filter((rel: RelationshipType) =>+ isEdgeSelected(rel.edge.id)+ ).lengthreturn selectedCount > 0 && selectedCount < filteredRelationships.length}, [filteredRelationships, isEdgeSelected])@@ -235,10 +258,11 @@ export default function RelationshipsTable() {const edgeIds = selectedEdges.map((e) => e.id)removeEdges(edgeIds)clearSelectedEdges()- return sketchService.deleteEdges(+ await sketchService.deleteEdges(sketchId as string,JSON.stringify({ relationshipIds: edgeIds }))+ refetch()})(),{loading: `Deleting ${count} relationship${count > 1 ? 's' : ''}...`,@@ -246,7 +270,7 @@ export default function RelationshipsTable() {error: 'Failed to delete relationships.'})- }, [selectedEdges, sketchId, confirm, removeEdges, clearSelectedEdges])+ }, [selectedEdges, sketchId, confirm, removeEdges, clearSelectedEdges, refetch])const virtualizer = useVirtualizer({count: filteredRelationships.length,@@ -372,24 +396,17 @@ export default function RelationshipsTable() {checked={isAllSelected}ref={(el) => {if (el && 'indeterminate' in el) {- (el as HTMLInputElement).indeterminate = isIndeterminate+ ;(el as HTMLInputElement).indeterminate = isIndeterminate}}}onCheckedChange={handleSelectAll}/><span className="text-sm text-muted-foreground">- {selectedEdges.length > 0- ? `${selectedEdges.length} selected`- : 'Select all'}+ {selectedEdges.length > 0 ? `${selectedEdges.length} selected` : 'Select all'}</span></div>{selectedEdges.length > 0 && (- <Button- onClick={handleDeleteSelected}- variant="destructive"- size="sm"- className="h-8"- >+ <Button onClick={handleDeleteSelected} variant="destructive" size="sm" className="h-8"><Trash2 className="h-3.5 w-3.5 mr-1" />Delete {selectedEdges.length}</Button>diff --git a/flowsint-app/src/components/ui/dropdown-menu.tsx b/flowsint-app/src/components/ui/dropdown-menu.tsxindex b0425dad..84161c1b 100644--- a/flowsint-app/src/components/ui/dropdown-menu.tsx+++ b/flowsint-app/src/components/ui/dropdown-menu.tsx@@ -108,7 +108,7 @@ function DropdownMenuRadioItem({<DropdownMenuPrimitive.RadioItemdata-slot="dropdown-menu-radio-item"className={cn(- "focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}{...props}diff --git a/flowsint-app/src/hooks/use-icon.tsx b/flowsint-app/src/hooks/use-icon.tsxindex 18e59951..74440028 100644--- a/flowsint-app/src/hooks/use-icon.tsx+++ b/flowsint-app/src/hooks/use-icon.tsx@@ -5,6 +5,12 @@ import { cn } from '@/lib/utils'export type IconType = string+export type UseIconOptions = {+ nodeColor?: string | null+ nodeIcon?: keyof typeof LucideIcons | null+ nodeImage?: string | null+}+interface IconProps {className?: stringsize?: number@@ -12,7 +18,6 @@ interface IconProps {showBorder?: booleancolor?: stringtype?: string- iconOnly?: boolean}const DEFAULT_SIZE = 24@@ -21,13 +26,15 @@ const BORDER_RATIO = 8const CONTAINER_PADDING = 16const BACKGROUND_PADDING = 8-export const useIcon = (type: IconType, src?: string | null) => {+export const useIcon = (type: IconType, options?: UseIconOptions) => {+ const { nodeColor, nodeIcon, nodeImage } = options ?? {}+// Subscribe to store changesconst colors = useNodesDisplaySettings((s) => s.colors)const customIcons = useNodesDisplaySettings((s) => s.customIcons)- // Get icon name, checking custom icons first- const iconName = customIcons[type] || TYPE_TO_ICON[type] || TYPE_TO_ICON.default+ // Priority: nodeIcon -> customIcons[type] -> TYPE_TO_ICON[type] -> default+ const iconName = nodeIcon || customIcons[type] || TYPE_TO_ICON[type] || TYPE_TO_ICON.defaultreturn useCallback(({@@ -35,36 +42,93 @@ export const useIcon = (type: IconType, src?: string | null) => {size = DEFAULT_SIZE,style,showBorder = false,- color,- iconOnly = false+ color}: IconProps): JSX.Element => {- const resolvedColor = color || colors[type as keyof typeof colors] || DEFAULT_COLOR+ // Priority for color: color prop -> nodeColor -> colors[type] -> default+ const resolvedColor =+ color || nodeColor || colors[type as keyof typeof colors] || DEFAULT_COLOR- // Use full size for src images, scaled size for icons- const actualIconSize = src ? size : size * 0.7+ // Priority: nodeImage first - images are returned directly (no background)+ if (nodeImage) {+ const containerSize = size + BACKGROUND_PADDING+ const imageSize = containerSize * 0.9- // Si src est fourni, utiliser une image- if (src) {const imageElement = (<img- src={src}- width={actualIconSize}- height={actualIconSize}- className={`object-contain flex-shrink-0 rounded-full ${className} p-0`}+ src={nodeImage}+ width={imageSize}+ height={imageSize}+ className={`object-cover shrink-0 rounded-full ${className} p-0`}style={{- minWidth: actualIconSize,- minHeight: actualIconSize,- maxWidth: actualIconSize,- maxHeight: actualIconSize,- ...(showBorder ? undefined : style)+ minWidth: imageSize,+ minHeight: imageSize,+ maxWidth: imageSize,+ maxHeight: imageSize}}alt={`${type} icon`}/>)- if (iconOnly) return imageElement++ if (showBorder) {+ const borderedContainerSize = size + CONTAINER_PADDING+ const borderedImageSize = borderedContainerSize * 0.9+ const borderWidth = Math.max(1, size / BORDER_RATIO)++ const borderedImageElement = (+ <img+ src={nodeImage}+ width={borderedImageSize}+ height={borderedImageSize}+ className={`object-cover shrink-0 rounded-full ${className} p-0`}+ style={{+ minWidth: borderedImageSize,+ minHeight: borderedImageSize,+ maxWidth: borderedImageSize,+ maxHeight: borderedImageSize+ }}+ alt={`${type} icon`}+ />+ )++ return (+ <div+ className="flex bg-card items-center justify-center rounded-full overflow-hidden shrink-0"+ style={{+ border: `${borderWidth}px solid ${resolvedColor}`,+ width: borderedContainerSize,+ height: borderedContainerSize,+ minWidth: borderedContainerSize,+ minHeight: borderedContainerSize,+ maxWidth: borderedContainerSize,+ maxHeight: borderedContainerSize,+ ...style+ }}+ >+ {borderedImageElement}+ </div>+ )+ }++ return (+ <div+ className="rounded-full flex items-center justify-center overflow-hidden shrink-0"+ style={{+ width: containerSize,+ height: containerSize,+ minWidth: containerSize,+ minHeight: containerSize,+ maxWidth: containerSize,+ maxHeight: containerSize,+ ...style+ }}+ >+ {imageElement}+ </div>+ )}- // Utiliser une icône Lucide (PERFORMANT - pas de requête HTTP)+ // Fallback to Lucide icon - icons need colored background+ const actualIconSize = size * 0.7const LucideIcon = (LucideIcons as any)[iconName] as React.ComponentType<{size?: numberfontSize?: number@@ -76,22 +140,20 @@ export const useIcon = (type: IconType, src?: string | null) => {<LucideIconsize={actualIconSize}fontSize={1}- className={cn(`flex-shrink-0`, !iconOnly && !showBorder && 'text-white', className)}+ className={cn('shrink-0', !showBorder && 'text-white', className)}style={{...(showBorder ? undefined : style)}}/>)- if (iconOnly) return iconElement-if (showBorder) {const containerSize = size + CONTAINER_PADDINGconst borderWidth = Math.max(1, size / BORDER_RATIO)return (<div- className="flex bg-card items-center justify-center rounded-full overflow-hidden flex-shrink-0"+ className="flex bg-card items-center justify-center rounded-full overflow-hidden shrink-0"style={{border: `${borderWidth}px solid ${resolvedColor}`,width: containerSize,@@ -111,7 +173,7 @@ export const useIcon = (type: IconType, src?: string | null) => {const containerSize = size + BACKGROUND_PADDINGreturn (<div- className="rounded-full flex items-center justify-center overflow-hidden flex-shrink-0"+ className="rounded-full flex items-center justify-center overflow-hidden shrink-0"style={{background: resolvedColor,width: containerSize,@@ -126,6 +188,6 @@ export const useIcon = (type: IconType, src?: string | null) => {</div>)},- [type, src, colors, iconName]+ [type, nodeImage, nodeColor, colors, iconName])}diff --git a/flowsint-app/src/routes/_auth.dashboard.custom-types.$id.tsx b/flowsint-app/src/routes/_auth.dashboard.custom-types.$id.tsxindex 6eb5468d..eeccb5dd 100644--- a/flowsint-app/src/routes/_auth.dashboard.custom-types.$id.tsx+++ b/flowsint-app/src/routes/_auth.dashboard.custom-types.$id.tsx@@ -10,7 +10,13 @@ import { customTypeService, CustomType } from '@/api/custom-type-service'import { toast } from 'sonner'import { ArrowLeft, Save, Plus, Trash2, AlertCircle, ChevronDown, ChevronRight } from 'lucide-react'import { Badge } from '@/components/ui/badge'-import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue+} from '@/components/ui/select'import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'import { Switch } from '@/components/ui/switch'import {@@ -19,13 +25,9 @@ import {TableCell,TableHead,TableHeader,- TableRow,+ TableRow} from '@/components/ui/table'-import {- Collapsible,- CollapsibleContent,- CollapsibleTrigger,-} from '@/components/ui/collapsible'+import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'export const Route = createFileRoute('/_auth/dashboard/custom-types/$id')({component: CustomTypeEditor@@ -77,15 +79,17 @@ function CustomTypeEditor() {const parseSchemaToFields = (schema: any) => {const properties = schema.properties || {}const required = schema.required || []- const parsedFields: SchemaField[] = Object.entries(properties).map(([key, value]: [string, any]) => ({- id: Math.random().toString(36).substr(2, 9),- key,- title: value.title || key,- type: value.type || 'string',- format: value.format,- description: value.description,- required: required.includes(key)- }))+ const parsedFields: SchemaField[] = Object.entries(properties).map(+ ([key, value]: [string, any]) => ({+ id: Math.random().toString(36).substr(2, 9),+ key,+ title: value.title || key,+ type: value.type || 'string',+ format: value.format,+ description: value.description,+ required: required.includes(key)+ })+ )setFields(parsedFields)}@@ -99,7 +103,7 @@ function CustomTypeEditor() {const prop: any = {type: field.type,- title: field.title || field.key,+ title: field.title || field.key}if (field.description) prop.description = field.descriptionif (field.format && field.format !== 'none') prop.format = field.format@@ -133,12 +137,12 @@ function CustomTypeEditor() {// Update fieldconst updateField = (id: string, updates: Partial<SchemaField>) => {- setFields(fields.map(f => f.id === id ? { ...f, ...updates } : f))+ setFields(fields.map((f) => (f.id === id ? { ...f, ...updates } : f)))}// Delete fieldconst deleteField = (id: string) => {- setFields(fields.filter(f => f.id !== id))+ setFields(fields.filter((f) => f.id !== id))}// Toggle field expansion@@ -185,14 +189,14 @@ function CustomTypeEditor() {}// Check for duplicate or empty keys- const keys = fields.map(f => f.key.trim()).filter(k => k)+ const keys = fields.map((f) => f.key.trim()).filter((k) => k)const uniqueKeys = new Set(keys)if (keys.length !== uniqueKeys.size) {toast.error('Field keys must be unique')return}- if (fields.length === 0 || fields.every(f => !f.key.trim())) {+ if (fields.length === 0 || fields.every((f) => !f.key.trim())) {toast.error('Please add at least one field')return}@@ -241,7 +245,9 @@ function CustomTypeEditor() {{isNew ? 'New custom type' : name || 'Edit custom type'}</h1><p className="text-sm text-muted-foreground">- {isNew ? 'Define your custom data structure' : 'Update your custom type definition'}+ {isNew+ ? 'Define your custom data structure'+ : 'Update your custom type definition'}</p></div></div>@@ -262,9 +268,10 @@ function CustomTypeEditor() {<TabsList className="mb-6"><TabsTrigger value="basic">Basic Information</TabsTrigger><TabsTrigger value="fields">- Fields {fields.filter(f => f.key.trim()).length > 0 && (+ Fields{' '}+ {fields.filter((f) => f.key.trim()).length > 0 && (<Badge variant="secondary" className="ml-2">- {fields.filter(f => f.key.trim()).length}+ {fields.filter((f) => f.key.trim()).length}</Badge>)}</TabsTrigger>@@ -333,9 +340,7 @@ function CustomTypeEditor() {<div className="flex items-center justify-between"><div><CardTitle>Field Definitions</CardTitle>- <CardDescription>- Define the properties that make up this type- </CardDescription>+ <CardDescription>Define the properties that make up this type</CardDescription></div><Button onClick={addField} size="sm"><Plus className="w-4 h-4 mr-2" />@@ -404,7 +409,9 @@ function CustomTypeEditor() {</Select><Selectvalue={field.format || 'none'}- onValueChange={(v) => updateField(field.id, { format: v === 'none' ? undefined : v })}+ onValueChange={(v) =>+ updateField(field.id, { format: v === 'none' ? undefined : v })+ }><SelectTrigger className="h-9"><SelectValue />@@ -422,7 +429,9 @@ function CustomTypeEditor() {<div className="flex items-center gap-2"><Switchchecked={field.required}- onCheckedChange={(checked) => updateField(field.id, { required: checked })}+ onCheckedChange={(checked) =>+ updateField(field.id, { required: checked })+ }/><span className="text-xs text-muted-foreground">Required</span></div>@@ -448,7 +457,9 @@ function CustomTypeEditor() {<Textareaid={`desc-${field.id}`}value={field.description || ''}- onChange={(e) => updateField(field.id, { description: e.target.value })}+ onChange={(e) =>+ updateField(field.id, { description: e.target.value })+ }placeholder="Describe this field's purpose and expected values..."rows={3}className="text-sm"@@ -473,13 +484,15 @@ function CustomTypeEditor() {<Card className="border-blue-200 bg-blue-50/50 dark:bg-blue-950/20 dark:border-blue-900"><CardContent className="pt-6"><div className="flex gap-3">- <AlertCircle className="w-5 h-5 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5" />+ <AlertCircle className="w-5 h-5 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5" /><div className="space-y-1"><p className="text-sm font-medium text-blue-900 dark:text-blue-100">Tips for defining fields</p><ul className="text-xs text-blue-700 dark:text-blue-300 space-y-1">- <li>• Field keys should be lowercase with underscores (e.g., email_address)</li>+ <li>+ • Field keys should be lowercase with underscores (e.g., email_address)+ </li><li>• Display names are shown to users in forms and tables</li><li>• Use formats to enable validation (e.g., email, date, ipv4)</li><li>• Mark critical fields as required to ensure data quality</li>@@ -496,9 +509,7 @@ function CustomTypeEditor() {<Card><CardHeader><CardTitle>Schema Preview</CardTitle>- <CardDescription>- JSON Schema representation of your custom type- </CardDescription>+ <CardDescription>JSON Schema representation of your custom type</CardDescription></CardHeader><CardContent><pre className="p-4 bg-muted rounded-lg text-sm overflow-x-auto">@@ -510,41 +521,48 @@ function CustomTypeEditor() {<Card><CardHeader><CardTitle>Field Summary</CardTitle>- <CardDescription>- Overview of all defined fields- </CardDescription>+ <CardDescription>Overview of all defined fields</CardDescription></CardHeader><CardContent>- {fields.filter(f => f.key.trim()).length === 0 ? (+ {fields.filter((f) => f.key.trim()).length === 0 ? (<p className="text-sm text-muted-foreground">No fields defined yet</p>) : (<div className="space-y-3">- {fields.filter(f => f.key.trim()).map((field) => (- <div key={field.id} className="flex items-start justify-between p-3 border rounded-lg">- <div className="space-y-1">- <div className="flex items-center gap-2">- <span className="font-medium text-sm">{field.title || field.key}</span>- {field.required && (- <Badge variant="outline" className="text-xs">Required</Badge>+ {fields+ .filter((f) => f.key.trim())+ .map((field) => (+ <div+ key={field.id}+ className="flex items-start justify-between p-3 border rounded-lg"+ >+ <div className="space-y-1">+ <div className="flex items-center gap-2">+ <span className="font-medium text-sm">+ {field.title || field.key}+ </span>+ {field.required && (+ <Badge variant="outline" className="text-xs">+ Required+ </Badge>+ )}+ </div>+ <p className="text-xs text-muted-foreground">Key: {field.key}</p>+ {field.description && (+ <p className="text-xs text-muted-foreground">{field.description}</p>)}</div>- <p className="text-xs text-muted-foreground">Key: {field.key}</p>- {field.description && (- <p className="text-xs text-muted-foreground">{field.description}</p>- )}- </div>- <div className="flex flex-col items-end gap-1">- <Badge variant="secondary" className="text-xs">- {field.type}- </Badge>- {field.format && (- <Badge variant="outline" className="text-xs">- {field.format}+ <div className="flex flex-col items-end gap-1">+ <Badge variant="secondary" className="text-xs">+ {field.type}</Badge>- )}+ {field.format && (+ <Badge variant="outline" className="text-xs">+ {field.format}+ </Badge>+ )}+ </div></div>- </div>- ))}+ ))}</div>)}</CardContent>diff --git a/flowsint-app/src/stores/graph-controls-store.ts b/flowsint-app/src/stores/graph-controls-store.tsindex 29e08006..3c539d57 100644--- a/flowsint-app/src/stores/graph-controls-store.ts+++ b/flowsint-app/src/stores/graph-controls-store.ts@@ -24,7 +24,6 @@ type GraphControlsStore = {setView: (view: 'graph' | 'table' | 'map' | 'relationships') => voidsetIsSelectorModeActive: (active: boolean) => voidsetSelectionMode: (mode: SelectionMode) => void- exportToPNG: () => Promise<void>}export const useGraphControls = create<GraphControlsStore>()(@@ -48,7 +47,6 @@ export const useGraphControls = create<GraphControlsStore>()(setView: (view) => set({ view }),setIsSelectorModeActive: (active) => set({ isSelectorModeActive: active }),setSelectionMode: (mode) => set({ selectionMode: mode }),- exportToPNG: async () => {}}),{name: 'graph-controls-storage',diff --git a/flowsint-app/src/stores/graph-settings-store.ts b/flowsint-app/src/stores/graph-settings-store.tsindex ab77136b..b30082b0 100644--- a/flowsint-app/src/stores/graph-settings-store.ts+++ b/flowsint-app/src/stores/graph-settings-store.ts@@ -46,9 +46,9 @@ const DEFAULT_SETTINGS = {nodeSize: {name: 'Node Size',type: 'number',- value: 6,+ value: 30,min: 0.2,- max: 20,+ max: 100,step: 0.1,description: 'Defines the width of the link between two nodes.'},diff --git a/flowsint-app/src/stores/graph-store.ts b/flowsint-app/src/stores/graph-store.tsindex fae4b226..76eb6d77 100644--- a/flowsint-app/src/stores/graph-store.ts+++ b/flowsint-app/src/stores/graph-store.ts@@ -1,6 +1,6 @@import { create } from 'zustand'import { persist } from 'zustand/middleware'-import type { GraphNode, GraphEdge, NodeData } from '@/types'+import type { GraphNode, GraphEdge, NodeProperties } from '@/types'import { type ActionItem } from '@/lib/action-items'import { Filters, TypeFilter } from '@/types/filter'@@ -19,9 +19,9 @@ interface GraphState {removeNodes: (nodeIds: string[]) => voidremoveEdges: (edgeIds: string[]) => voidupdateGraphData: (nodes: GraphNode[], edges: GraphEdge[]) => void- updateNode: (nodeId: string, updates: Partial<NodeData>) => void+ updateNode: (nodeId: string, updates: Partial<GraphNode>) => voidupdateEdge: (edgeId: string, updates: Partial<GraphEdge>) => void- replaceNode: (oldId: string, newData: NodeData) => void+ replaceNode: (oldId: string, newId: string, newProperties: NodeProperties) => voidreset: () => void// === Selection & Current ===@@ -71,9 +71,6 @@ interface GraphState {setFilters: (filters: Filters) => voidtoggleTypeFilter: (filter: TypeFilter) => void- // === Collapse/Expand logic ===- toggleCollapse: (nodeId: string) => void-// === Utils ===nodesLength: numberedgesLength: number@@ -88,7 +85,7 @@ const computeFilteredNodes = (nodes: GraphNode[], filters: Filters): GraphNode[]const areNoneToggled = filters.types.every((t) => !t.checked)if (areNoneToggled || areAllToggled) return nodesconst types = filters.types.filter((t) => !t.checked).map((t) => t.type)- return nodes.filter((node) => !types.includes(node.data.type))+ return nodes.filter((node) => !types.includes(node.nodeType))}const computeFilteredEdges = (edges: GraphEdge[], filteredNodes: GraphNode[]): GraphEdge[] => {@@ -193,16 +190,32 @@ export const useGraphStore = create<GraphState>()(set({ nodes, edges, filteredNodes, filteredEdges, nodesMapping, edgesMapping })},- updateNode: (nodeId, updates) => {+ updateNode: (nodeId: string, updates: Partial<GraphNode>) => {const { nodes, edges, filters, nodesMapping } = get()+const updatedNodes = nodes.map((node) =>- node.id === nodeId ? { ...node, data: { ...node.data, ...updates } } : node+ node.id === nodeId ? { ...node, ...updates } : node)+const filteredNodes = computeFilteredNodes(updatedNodes, filters)const filteredEdges = computeFilteredEdges(edges, filteredNodes)- const node = nodesMapping.get(nodeId)- if (node) nodesMapping.set(nodeId, { ...node, data: { ...node.data, ...updates } })- set({ nodes: updatedNodes, filteredNodes, filteredEdges, nodesMapping })++ const newNodesMapping = new Map(nodesMapping)+ const node = newNodesMapping.get(nodeId)++ if (node) {+ newNodesMapping.set(nodeId, {+ ...node,+ ...updates+ })+ }++ set({+ nodes: updatedNodes,+ filteredNodes,+ filteredEdges,+ nodesMapping: newNodesMapping+ })},updateEdge: (edgeId, updates) => {@@ -217,19 +230,19 @@ export const useGraphStore = create<GraphState>()(set({ edges: updatedEdges, filteredNodes, filteredEdges, edgesMapping })},- replaceNode: (oldId, newData) => {+ replaceNode: (oldId, newId, nodeProperties) => {const { nodes, edges, filters, nodesMapping, setCurrentNodeId } = get()// Update the node's ID and data.idconst updatedNodes = nodes.map((node) =>- node.id === oldId ? { ...node, id: newData.id, data: newData } : node+ node.id === oldId ? { ...node, id: newId, nodeProperties: nodeProperties } : node)// Update all edges that reference this nodeconst updatedEdges = edges.map((edge) => {if (edge.source === oldId) {- return { ...edge, source: newData.id }+ return { ...edge, source: newId }}if (edge.target === oldId) {- return { ...edge, target: newData.id }+ return { ...edge, target: newId }}return edge})@@ -237,11 +250,11 @@ export const useGraphStore = create<GraphState>()(const filteredEdges = computeFilteredEdges(updatedEdges, filteredNodes)// Update nodesMappingnodesMapping.delete(oldId)- const newNode = updatedNodes.find((n) => n.id === newData.id)- if (newNode) nodesMapping.set(newData.id, newNode)+ const newNode = updatedNodes.find((n) => n.id === newId)+ if (newNode) nodesMapping.set(newId, newNode)// Update edgesMappingconst newEdgesMapping = new Map(updatedEdges.map((edge) => [edge.id, edge]))- setCurrentNodeId(newData.id)+ setCurrentNodeId(newId)set({nodes: updatedNodes,edges: updatedEdges,@@ -409,43 +422,6 @@ export const useGraphStore = create<GraphState>()(set({ filters: newFilters, filteredNodes, filteredEdges })},- // === Collapse/Expand logic ===- toggleCollapse: (nodeId) => {- const { nodes, edges, filters } = get()- const node = nodes.find((n) => n.id === nodeId)- if (!node) return- const isCollapsing = !node.collapsed-- const getDescendants = (parentId: string, accNodes: Set<string>, accEdges: Set<string>) => {- edges.forEach((edge) => {- if (edge.source === parentId) {- accEdges.add(edge.id)- accNodes.add(edge.target)- getDescendants(edge.target, accNodes, accEdges)- }- })- }-- const descendantNodeIds = new Set<string>()- const descendantEdgeIds = new Set<string>()- getDescendants(nodeId, descendantNodeIds, descendantEdgeIds)-- const newNodes = nodes.map((n) =>- n.id === nodeId- ? { ...n, collapsed: isCollapsing }- : descendantNodeIds.has(n.id)- ? { ...n, hidden: isCollapsing }- : n- )- const newEdges = edges.map((e) =>- descendantEdgeIds.has(e.id) ? { ...e, hidden: isCollapsing } : e- )-- const filteredNodes = computeFilteredNodes(newNodes, filters)- const filteredEdges = computeFilteredEdges(newEdges, filteredNodes)- set({ nodes: newNodes, edges: newEdges, filteredNodes, filteredEdges })- },-reset: () => {set({currentNodeId: null,diff --git a/flowsint-app/src/types/graph.ts b/flowsint-app/src/types/graph.tsindex 40802df7..038c057d 100644--- a/flowsint-app/src/types/graph.ts+++ b/flowsint-app/src/types/graph.ts@@ -1,36 +1,50 @@-export type NodeData = {- id: string- type: string- label: string- created_at: string- // Allow any other properties+import type * as LucideIcons from 'lucide-react'++export type NodeProperties = {+ [key: string]: any+}++export const flagColors = {+ red: 'text-red-400 fill-red-200',+ orange: 'text-orange-400 fill-orange-200',+ blue: 'text-blue-400 fill-blue-200',+ green: 'text-green-400 fill-green-200',+ yellow: 'text-yellow-400 fill-yellow-200'+} as const++type flagColor = keyof typeof flagColors++export type NodeMetadata = {[key: string]: any}export type GraphNode = {- collapsed?: boolean- hidden?: boolean- x?: number- y?: number- nodeLabel?: string- nodeColor?: string- nodeSize?: number- nodeType?: string+ id: string+ nodeType: string+ nodeLabel: string+ nodeProperties: NodeProperties+ nodeSize: number+ nodeColor: string | null+ nodeIcon: keyof typeof LucideIcons | null+ nodeImage: string | null+ nodeFlag: flagColor | null+ nodeMetadata: NodeMetadata+ x: number+ y: numberval?: numberneighbors?: any[]links?: any[]- id: string- data: NodeData}export type GraphEdge = {- source: string- target: string+ source: GraphNode['id']+ target: GraphNode['id']date?: stringid: stringlabel: stringcaption?: stringtype?: string+ weight?: numberconfidence_level?: number | string}