Skip to content

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

feat(app): graph improvement + new toolbar

dextmorgnb482e9f2149f
diff --git a/flowsint-app/src/components/copy.tsx b/flowsint-app/src/components/copy.tsx
index e8190918..9088e5fa 100644
--- a/flowsint-app/src/components/copy.tsx
+++ b/flowsint-app/src/components/copy.tsx
@@ -9,9 +9,11 @@ interface CopyButtonProps {
content: string
delay?: number
className?: string
+ size?: "icon" | "default" | "sm" | "lg" | null | undefined
+ label?: string
}
-export function CopyButton({ content, className, delay = 2000 }: CopyButtonProps) {
+export function CopyButton({ content, className, label, delay = 2000, size = "icon" }: CopyButtonProps) {
const [isCopied, setIsCopied] = useState(false)
const handleCopy = useCallback(
@@ -37,8 +39,8 @@ export function CopyButton({ content, className, delay = 2000 }: CopyButtonProps
<Tooltip open={isCopied}>
<TooltipTrigger asChild>
<Button
- className={cn('h-7 w-7', className)}
- size={'icon'}
+ className={cn('h-7', className)}
+ size={label ? "default" : size}
variant="ghost"
onClick={handleCopy}
aria-label="Copy content"
@@ -47,7 +49,7 @@ export function CopyButton({ content, className, delay = 2000 }: CopyButtonProps
<CheckIcon className="!h-3.5 !w-3.5 text-primary" />
) : (
<CopyIcon className="!h-3.5 !w-3.5 opacity-50" />
- )}
+ )}{label && <span className='text-xs'>{label}</span>}
</Button>
</TooltipTrigger>
<TooltipContent>Copied !</TooltipContent>
diff --git a/flowsint-app/src/components/graphs/details-panel/details-panel.tsx b/flowsint-app/src/components/graphs/details-panel/details-panel.tsx
index 9b6a2470..ca748706 100644
--- a/flowsint-app/src/components/graphs/details-panel/details-panel.tsx
+++ b/flowsint-app/src/components/graphs/details-panel/details-panel.tsx
@@ -34,8 +34,8 @@ const DetailsPanel = memo(({ node }: { node: GraphNode | null }) => {
return (
<div className="flex flex-col h-full overflow-hidden bg-card">
{/* <ItemHero node={node} /> */}
- <div className="flex items-center bg-card sticky w-full top-0 border-b justify-start px-4 py-2 gap-2 z-1">
- <p className="text-md font-semibold truncate">{node.data?.label}</p>
+ <div className="flex items-center bg-card h-10 sticky w-full top-0 border-b justify-start px-4 gap-2 z-1">
+ <p className="text-sm font-semibold truncate">{node.data?.label}</p>
<div className="grow" />
<div className="flex items-center">
<TooltipProvider>
diff --git a/flowsint-app/src/components/graphs/draggable-item.tsx b/flowsint-app/src/components/graphs/draggable-item.tsx
index d4b1c202..7f791830 100644
--- a/flowsint-app/src/components/graphs/draggable-item.tsx
+++ b/flowsint-app/src/components/graphs/draggable-item.tsx
@@ -30,6 +30,7 @@ export const DraggableItem = memo(function DraggableItem({
const { actionItems } = useActionItems()
const [isDragging, setIsDragging] = useState(false)
const colors = useNodesDisplaySettings((s) => s.colors)
+ // @ts-ignore
const colorStr = colors[icon as string] || color
const IconComponent = useIcon(icon)
diff --git a/flowsint-app/src/components/graphs/graph-main.tsx b/flowsint-app/src/components/graphs/graph-main.tsx
index 4e5e96ba..ed0d4317 100644
--- a/flowsint-app/src/components/graphs/graph-main.tsx
+++ b/flowsint-app/src/components/graphs/graph-main.tsx
@@ -2,7 +2,8 @@ import { useGraphStore } from '@/stores/graph-store'
import React, { useRef, useCallback } from 'react'
import GraphViewer from './graph-viewer'
// import WebGLGraphViewer from './webgl'
-import ContextMenu from './context-menu'
+import NodeContextMenu from './node-context-menu'
+import BackgroundContextMenu from './background-context-menu'
import { useParams } from '@tanstack/react-router'
const GraphMain = () => {
@@ -11,10 +12,12 @@ const GraphMain = () => {
const filteredEdges = useGraphStore((s) => s.filteredEdges)
const toggleNodeSelection = useGraphStore((s) => s.toggleNodeSelection)
const clearSelectedNodes = useGraphStore((s) => s.clearSelectedNodes)
+ const selectedNodes = useGraphStore(s => s.selectedNodes)
const graphRef = useRef<any>(null)
const containerRef = useRef<HTMLDivElement>(null)
- const [menu, setMenu] = React.useState<any>(null)
+ const [nodeMenu, setNodeMenu] = React.useState<any>(null)
+ const [background, setBackgroundMenu] = React.useState<any>(null)
const handleNodeClick = useCallback(
(node: any, event: MouseEvent) => {
@@ -26,7 +29,8 @@ const GraphMain = () => {
const handleBackgroundClick = useCallback(() => {
clearSelectedNodes()
- setMenu(null)
+ setNodeMenu(null)
+ setBackgroundMenu(null)
}, [clearSelectedNodes])
const onNodeContextMenu = useCallback((node: any, event: MouseEvent) => {
@@ -36,7 +40,22 @@ const GraphMain = () => {
const relativeX = event.clientX - pane.left
const relativeY = event.clientY - pane.top
- setMenu({
+ // 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: {
data: node.data || {},
id: node.id || '',
@@ -47,7 +66,26 @@ const GraphMain = () => {
rawLeft: relativeX,
wrapperWidth: pane.width,
wrapperHeight: pane.height,
- setMenu: setMenu
+ setMenu: setNodeMenu,
+ onClick: handleBackgroundClick
+ })
+ }, [selectedNodes])
+
+
+ const onBackgroundContextMenu = useCallback((event: MouseEvent) => {
+ if (!containerRef.current) return
+ const pane = containerRef.current.getBoundingClientRect()
+ const relativeX = event.clientX - pane.left
+ const relativeY = event.clientY - pane.top
+
+ setBackgroundMenu({
+ nodes: selectedNodes,
+ rawTop: relativeY,
+ rawLeft: relativeX,
+ wrapperWidth: pane.width,
+ wrapperHeight: pane.height,
+ setMenu: setBackgroundMenu,
+ onClick: handleBackgroundClick
})
}, [])
@@ -69,6 +107,7 @@ const GraphMain = () => {
edges={filteredEdges}
onNodeClick={handleNodeClick}
onNodeRightClick={onNodeContextMenu}
+ onBackgroundRightClick={onBackgroundContextMenu}
onBackgroundClick={handleBackgroundClick}
showLabels={true}
showIcons={true}
@@ -76,8 +115,19 @@ const GraphMain = () => {
allowLasso
sketchId={sketchId}
/>
+ {nodeMenu && selectedNodes.length === 0 && (
+ <NodeContextMenu
+ onClick={handleBackgroundClick}
+ {...nodeMenu}
+ />
+ )}
+ {(background || (nodeMenu && selectedNodes.length > 0)) && (
+ <BackgroundContextMenu
+ onClick={handleBackgroundClick}
+ {...background}
+ />
+ )}
- {menu && <ContextMenu onClick={handleBackgroundClick} {...menu} />}
</div>
)
}
diff --git a/flowsint-app/src/components/graphs/graph-navigation.tsx b/flowsint-app/src/components/graphs/graph-navigation.tsx
index 4198a412..6aba99d1 100644
--- a/flowsint-app/src/components/graphs/graph-navigation.tsx
+++ b/flowsint-app/src/components/graphs/graph-navigation.tsx
@@ -14,7 +14,7 @@ const GraphNavigation = () => {
const selectedNodes = useGraphStore((s) => s.selectedNodes)
const selectedNodesSome = selectedNodes.length > 0
return (
- <div className="h-full w-full min-h-0">
+ <div className="h-full h-10 w-full min-h-0">
<Tabs
value={activeTab}
onValueChange={setActiveTab}
diff --git a/flowsint-app/src/components/graphs/graph-viewer.tsx b/flowsint-app/src/components/graphs/graph-viewer.tsx
index 35a023e2..69f3ea98 100644
--- a/flowsint-app/src/components/graphs/graph-viewer.tsx
+++ b/flowsint-app/src/components/graphs/graph-viewer.tsx
@@ -20,12 +20,10 @@ function truncateText(text: string, limit: number = 16) {
interface GraphViewerProps {
nodes: GraphNode[]
edges: GraphEdge[]
- // Remove width and height props - component will handle its own sizing
- nodeColors?: Record<string, string>
- nodeSizes?: Record<string, number>
onNodeClick?: (node: GraphNode, event: MouseEvent) => void
onNodeRightClick?: (node: GraphNode, event: MouseEvent) => void
onBackgroundClick?: () => void
+ onBackgroundRightClick: (event: MouseEvent) => void
showLabels?: boolean
showIcons?: boolean
backgroundColor?: string
@@ -45,56 +43,39 @@ export const GRAPH_COLORS = {
LINK_DIMMED: 'rgba(133, 133, 133, 0.23)',
LINK_LABEL_HIGHLIGHTED: 'rgba(255, 115, 0, 0.9)',
LINK_LABEL_DEFAULT: 'rgba(180, 180, 180, 0.75)',
-
// Node highlight colors
NODE_HIGHLIGHT_HOVER: 'rgba(255, 0, 0, 0.3)',
NODE_HIGHLIGHT_DEFAULT: 'rgba(255, 165, 0, 0.3)',
-
LASSO_FILL: 'rgba(255, 115, 0, 0.07)',
LASSO_STROKE: 'rgba(255, 115, 0, 0.56)',
-
// Text colors
TEXT_LIGHT: '#161616',
TEXT_DARK: '#FFFFFF',
-
// Background colors
BACKGROUND_LIGHT: '#FFFFFF',
BACKGROUND_DARK: '#161616',
-
// Transparent colors
TRANSPARENT: '#00000000',
-
// Default node color
NODE_DEFAULT: '#0074D9'
} as const
const CONSTANTS = {
- NODE_COUNT_THRESHOLD: 400,
NODE_DEFAULT_SIZE: 10,
- NODE_LABEL_FONT_SIZE: 3.5,
LABEL_FONT_SIZE: 2.5,
NODE_FONT_SIZE: 3.5,
- LABEL_NODE_MARGIN: 18,
PADDING_RATIO: 0.2,
HALF_PI: Math.PI / 2,
PI: Math.PI,
- MEASURE_FONT: '1px Sans-Serif',
MIN_FONT_SIZE: 0.5,
LINK_WIDTH: 1,
- ARROW_SIZE: 8,
- ARROW_ANGLE: Math.PI / 6,
MIN_ZOOM: 0.1,
MAX_ZOOM: 8,
- // Dynamic label thresholds based on zoom
- MIN_VISIBLE_LABELS: 5,
- MAX_VISIBLE_LABELS_PER_ZOOM: 15
-}
-
-interface LabelRenderingCompound {
- weightList: Map<string, number>
- constants: {
- nodesLength: number
- }
+ // LOD threshold (same for labels, icons, and links)
+ ZOOM_NODE_DETAIL_THRESHOLD: 2,
+ ZOOM_EDGE_DETAIL_THRESHOLD: 1,
+ // Size multiplier for nodes when zoomed out (to make them visible from afar)
+ ZOOMED_OUT_SIZE_MULTIPLIER: 3
}
// Reusable objects to avoid allocations
@@ -137,10 +118,10 @@ const preloadImage = (iconType: string): Promise<HTMLImageElement> => {
const GraphViewer: React.FC<GraphViewerProps> = ({
nodes,
edges,
- // Remove width and height from destructuring
onNodeClick,
onNodeRightClick,
onBackgroundClick,
+ onBackgroundRightClick,
showLabels = true,
showIcons = true,
backgroundColor = 'transparent',
@@ -157,8 +138,8 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
const [highlightNodes, setHighlightNodes] = useState<Set<string>>(new Set())
const [highlightLinks, setHighlightLinks] = useState<Set<string>>(new Set())
const [hoverNode, setHoverNode] = useState<string | null>(null)
- const [currentZoom, setCurrentZoom] = useState<number>(1)
- const zoomRef = useRef({ k: 1, x: 0, y: 0 })
+ // const [currentZoom, setCurrentZoom] = useState<number>(1)
+ // const zoomRef = useRef({ k: 1, x: 0, y: 0 })
const hoverFrameRef = useRef<number | null>(null)
const [isRegeneratingLayout, setIsRegeneratingLayout] = useState(false)
@@ -175,13 +156,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
saveAllNodePositions,
})
- // The ref for the node weighlist.
- const labelRenderingCompound = useRef<LabelRenderingCompound>({
- weightList: new Map(),
- constants: {
- nodesLength: 0
- }
- })
// Store references
const graphRef = useRef<any>(null)
const containerRef = useRef<HTMLDivElement>(null)
@@ -189,7 +163,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
// Store selectors
const nodeColors = useNodesDisplaySettings((s) => s.colors)
- const getSize = useNodesDisplaySettings((s) => s.getSize)
const setActions = useGraphControls((s) => s.setActions)
const currentNode = useGraphStore((s) => s.currentNode)
const selectedNodes = useGraphStore((s) => s.selectedNodes)
@@ -197,38 +170,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
const setOpenMainDialog = useGraphStore((state) => state.setOpenMainDialog)
const setImportModalOpen = useGraphSettingsStore((s) => s.setImportModalOpen)
- // Pre-compute visible labels based on zoom and node weight (O(n) once per zoom change)
- const visibleLabels = useMemo(() => {
- if (!showLabels || labelRenderingCompound.current.weightList.size === 0) {
- return new Set<string>()
- }
-
- const totalNodes = labelRenderingCompound.current.constants.nodesLength
- if (totalNodes === 0) return new Set<string>()
-
- // Calculate how many labels to show based on zoom
- // More zoom = more labels (progressive disclosure)
- const zoomFactor = Math.max(CONSTANTS.MIN_ZOOM, Math.min(CONSTANTS.MAX_ZOOM, currentZoom))
- const zoomRatio = (zoomFactor - CONSTANTS.MIN_ZOOM) / (CONSTANTS.MAX_ZOOM - CONSTANTS.MIN_ZOOM)
-
- // Scale from MIN_VISIBLE_LABELS to a percentage of total nodes
- const maxLabelsAtZoom = Math.floor(
- CONSTANTS.MIN_VISIBLE_LABELS +
- zoomRatio * Math.min(totalNodes * 0.5, CONSTANTS.MAX_VISIBLE_LABELS_PER_ZOOM * zoomFactor)
- )
-
- // Take the top N nodes by weight (connection count)
- const visibleSet = new Set<string>()
- let count = 0
- for (const [nodeId] of labelRenderingCompound.current.weightList) {
- if (count >= maxLabelsAtZoom) break
- visibleSet.add(nodeId)
- count++
- }
-
- return visibleSet
- }, [currentZoom, showLabels, labelRenderingCompound.current.weightList.size, labelRenderingCompound.current.constants.nodesLength])
-
// Add state for tooltip
const [tooltip, setTooltip] = useState<{
x: number
@@ -278,14 +219,15 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
}
}, [nodes, showIcons])
- const handleZoom = useCallback((zoom: any) => {
- zoomRef.current = zoom
- // Only update state if zoom changed significantly (reduces re-renders)
- const newZoom = zoom.k
- if (Math.abs(newZoom - currentZoom) > 0.1) {
- setCurrentZoom(newZoom)
- }
- }, [currentZoom])
+ // const handleZoom = useCallback((zoom: any) => {
+ // const prevZoom = zoomRef.current.k
+ // zoomRef.current = zoom
+ // // Only update state if zoom changed significantly (reduces re-renders)
+ // const newZoom = zoom.k
+ // if (Math.abs(newZoom - prevZoom) > 0.1) {
+ // setCurrentZoom(newZoom)
+ // }
+ // }, [])
// Handle container size changes
useEffect(() => {
@@ -318,13 +260,19 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
// Transform nodes
const transformedNodes = nodes.map((node) => {
const type = node.data?.type as ItemType
+
+ // Calculate base node size (used for rendering calculations)
+ const baseNodeSize = CONSTANTS.NODE_DEFAULT_SIZE
+
const transformed = {
...node,
nodeLabel: node.data?.label || node.id,
nodeColor: nodeColors[type] || GRAPH_COLORS.NODE_DEFAULT,
- nodeSize: CONSTANTS.NODE_DEFAULT_SIZE,
+ nodeSize: baseNodeSize,
nodeType: type,
- val: CONSTANTS.NODE_DEFAULT_SIZE,
+ // val is used by ForceGraph2D for collision detection and forces
+ // Set it to the "zoomed out" size to ensure proper spacing
+ val: baseNodeSize * CONSTANTS.ZOOMED_OUT_SIZE_MULTIPLIER / 5,
neighbors: [] as any[],
links: [] as any[]
} as GraphNode & { neighbors: any[]; links: any[] }
@@ -381,20 +329,13 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
targetNode.links.push(link)
}
})
- // feed the labelRenderingCompound
- labelRenderingCompound.current.weightList = new Map(
- transformedNodes
- .sort((a, b) => b.neighbors.length - a.neighbors.length)
- .map((node) => [node.id, node.neighbors.length])
- )
- labelRenderingCompound.current.constants = { nodesLength: transformedNodes.length }
// Always use force layout - positions are preserved if they exist (fx/fy set above)
return {
nodes: transformedNodes,
links: transformedEdges
}
- }, [nodes, edges, nodeColors, getSize])
+ }, [nodes, edges, nodeColors])
// Regenerate layout by removing fixed positions and reheating simulation
const regenerateLayout = useCallback((layoutType: 'force' | 'hierarchy') => {
@@ -533,6 +474,10 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
onBackgroundClick?.()
}, [onBackgroundClick])
+ const handleBackgroundRightClick = useCallback((event: MouseEvent) => {
+ onBackgroundRightClick?.(event)
+ }, [onBackgroundRightClick])
+
const handleOpenNewAddItemDialog = useCallback(() => {
setOpenMainDialog(true)
}, [setOpenMainDialog])
@@ -665,39 +610,56 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
})
}, [])
- // Optimized node rendering with proper icon caching
+ // Optimized node rendering with zoom-based LOD
const renderNode = useCallback(
(node: any, ctx: CanvasRenderingContext2D, globalScale: number) => {
- const shouldUseSimpleRendering =
- nodes.length > CONSTANTS.NODE_COUNT_THRESHOLD || globalScale < 1.5
- const size =
- Math.min(node.nodeSize + node.neighbors.length / 5, 20) *
- (forceSettings.nodeSize.value / 100 + 0.4)
- node.val = size / 5
+ // Calculate render size based on node properties and settings
+ // Note: node.val is already set in graphData and should not be modified here
+ const sizeMultiplier = forceSettings.nodeSize.value / 100 + 0.2
+ const neighborBonus = Math.min(node.neighbors.length / 5, 5)
+ const baseSize = (node.nodeSize + neighborBonus) * sizeMultiplier
+
+ // LOD: Check if we should render details (labels, icons)
+ const shouldRenderDetails = globalScale > CONSTANTS.ZOOM_NODE_DETAIL_THRESHOLD
+
+ // For rendering: when zoomed out, make nodes bigger (more visible from afar)
+ // When zoomed in, keep them smaller to make room for labels
+ const size = shouldRenderDetails
+ ? baseSize
+ : baseSize * CONSTANTS.ZOOMED_OUT_SIZE_MULTIPLIER
+
const isHighlighted = highlightNodes.has(node.id) || isSelected(node.id)
const hasAnyHighlight = highlightNodes.size > 0 || highlightLinks.size > 0
const isHovered = hoverNode === node.id || isCurrent(node.id)
- // Draw highlight ring for highlighted nodes
+
+ // Draw highlight ring for highlighted nodes with constant border width
if (isHighlighted) {
+ // Border width adapts to zoom level for consistent visual appearance
+ const borderWidth = 3 / globalScale
ctx.beginPath()
- ctx.arc(node.x, node.y, size * 1.2, 0, 2 * Math.PI)
+ ctx.arc(node.x, node.y, size + borderWidth, 0, 2 * Math.PI)
ctx.fillStyle = isHovered
? GRAPH_COLORS.NODE_HIGHLIGHT_HOVER
: GRAPH_COLORS.NODE_HIGHLIGHT_DEFAULT
ctx.fill()
}
+
// Set node color based on highlight state
if (hasAnyHighlight) {
ctx.fillStyle = isHighlighted ? node.nodeColor : `${node.nodeColor}7D`
} else {
ctx.fillStyle = node.nodeColor
}
+
+ // Draw node circle
ctx.beginPath()
ctx.arc(node.x, node.y, size, 0, 2 * Math.PI)
ctx.fill()
- // Early exit for simple rendering
- if (shouldUseSimpleRendering && !isHovered) return
- // Optimized icon rendering with cached images
+
+ // Early exit if not zoomed in enough for details
+ if (!shouldRenderDetails) return
+
+ // Render icons when zoomed in
if (showIcons && node.nodeType) {
const cachedImage = imageCache.get(node.nodeType)
if (cachedImage && cachedImage.complete) {
@@ -708,16 +670,11 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
}
}
}
- // Optimized label rendering with layered display
+
+ // Render labels when zoomed in
if (showLabels) {
const label = truncateText(node.nodeLabel || node.label || node.id, 58)
if (label) {
- // Check if this node's label should be visible (O(1) lookup)
- const shouldShowLabel = visibleLabels.has(node.id)
- // Always show labels for highlighted nodes
- if (!shouldShowLabel && !isHighlighted) {
- return
- }
const baseFontSize = Math.max(
CONSTANTS.MIN_FONT_SIZE,
(CONSTANTS.NODE_FONT_SIZE * (size / 2)) / globalScale + 2
@@ -756,7 +713,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
ctx.strokeStyle = theme === 'light'
? 'rgba(0, 0, 0, 0.1)'
: 'rgba(255, 255, 255, 0.1)'
- ctx.lineWidth = 0.5
+ ctx.lineWidth = 0.1
ctx.stroke()
// Draw text
@@ -777,14 +734,15 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
theme,
highlightNodes,
highlightLinks,
- hoverNode,
- visibleLabels,
- nodes.length
+ hoverNode
]
)
const renderLink = useCallback(
(link: any, ctx: CanvasRenderingContext2D, globalScale: number) => {
+ // LOD: Skip rendering links entirely when zoomed out (performance optimization)
+ if (globalScale < CONSTANTS.ZOOM_EDGE_DETAIL_THRESHOLD) return
+
const { source: start, target: end } = link
if (typeof start !== 'object' || typeof end !== 'object') return
const linkKey = `${start.id}-${end.id}`
@@ -860,9 +818,13 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
if (arrowRelPos === 1) {
const tan = bezierTangent(0.99)
const tanLen = Math.hypot(tan.x, tan.y) || 1
- const targetNodeSize =
- (end.nodeSize || CONSTANTS.NODE_DEFAULT_SIZE) *
- (nodeSize / 100 + 0.4)
+ // Calculate target node size consistently with renderNode logic
+ const sizeMultiplier = nodeSize / 100 + 0.2
+ const neighborBonus = Math.min(end.neighbors?.length / 5 || 0, 5)
+ const baseTargetSize = (end.nodeSize + neighborBonus) * sizeMultiplier
+ const targetNodeSize = globalScale > CONSTANTS.ZOOM_NODE_DETAIL_THRESHOLD
+ ? baseTargetSize
+ : baseTargetSize * CONSTANTS.ZOOMED_OUT_SIZE_MULTIPLIER
arrowX = end.x - (tan.x / tanLen) * targetNodeSize
arrowY = end.y - (tan.y / tanLen) * targetNodeSize
}
@@ -883,8 +845,8 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
}
// Early exit if no label
if (!link.label) return
- // Always show labels for highlighted links (even in simple rendering mode for better UX)
- if (isHighlighted) {
+ // LOD: Only show labels for highlighted links when zoomed in enough
+ if (isHighlighted && globalScale > CONSTANTS.ZOOM_EDGE_DETAIL_THRESHOLD) {
// Calculate label position and angle along straight/curved link
let textAngle: number
if ((link.curvature || 0) !== 0) {
@@ -948,7 +910,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
ctx.restore()
}
},
- [forceSettings, theme, highlightLinks, highlightNodes, nodes.length]
+ [forceSettings, theme, highlightLinks, highlightNodes]
)
// Clear highlights when graph data changes
@@ -1004,7 +966,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
<strong>Explore:</strong> Try searching for domains, emails, or other entities
</p>
<p>
- <strong>Labels:</strong> Zoom in to see node labels progressively by connection weight
+ <strong>Labels:</strong> Zoom in (over 2x) to see all labels, icons, and edges
</p>
</div>
<div className='flex flex-col justify-center gap-1'>
@@ -1071,10 +1033,11 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
minZoom={CONSTANTS.MIN_ZOOM}
nodeLabel={() => ''}
// nodeColor={node => shouldUseSimpleRendering ? node.nodeColor : GRAPH_COLORS.TRANSPARENT}
- nodeRelSize={6}
+ nodeRelSize={3}
onNodeRightClick={handleNodeRightClick}
onNodeClick={handleNodeClick}
onBackgroundClick={handleBackgroundClick}
+ onBackgroundRightClick={handleBackgroundRightClick}
linkCurvature={(link) => link.curvature || 0}
nodeCanvasObject={renderNode}
onNodeDragEnd={handleNodeDragEnd}
@@ -1086,8 +1049,8 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
warmupTicks={forceSettings?.warmupTicks?.value ?? 0}
dagLevelDistance={forceSettings.dagLevelDistance.value}
backgroundColor={backgroundColor}
- onZoom={handleZoom}
- onZoomEnd={handleZoom}
+ // onZoom={handleZoom}
+ // onZoomEnd={handleZoom}
linkCanvasObject={renderLink}
enableNodeDrag={true}
autoPauseRedraw={true}
@@ -1097,7 +1060,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
{allowLasso && isLassoActive && (
<>
<div
- className="absolute z-20 top-14 flex items-center gap-1 left-3 bg-primary/20 text-primary border border-primary/40 rounded-lg p-1 px-2 text-xs pointer-events-none"
+ className="absolute z-20 top-3 flex items-center gap-1 left-3 bg-primary/20 text-primary border border-primary/40 rounded-lg p-1 px-2 text-xs pointer-events-none"
><Info className='h-3 w-3 ' /> Lasso is active</div>
<Lasso
nodes={graphData.nodes}
diff --git a/flowsint-app/src/components/graphs/index.tsx b/flowsint-app/src/components/graphs/index.tsx
index 82ce788e..54cf6a4b 100644
--- a/flowsint-app/src/components/graphs/index.tsx
+++ b/flowsint-app/src/components/graphs/index.tsx
@@ -116,13 +116,12 @@ const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {
}
return (
- <div
- className="h-full w-full flex relative outline-2 outline-transparent bg-background"
- onDragOver={handleDragOver}
+ <div onDragOver={handleDragOver}
onDragEnter={handleDragEnter}
onDragLeave={handleDragLeave}
onDrop={handleDrop}
- >
+ className="h-full w-full flex flex-col relative outline-2 outline-transparent bg-background">
+ <Toolbar isLoading={isLoading} />
<Suspense
fallback={
<div className="h-full w-full flex items-center justify-center">
@@ -132,17 +131,14 @@ const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {
</div>
}
>
- <>
+ <div className="flex-1 min-h-0">
{view === 'graph' && <GraphMain />}
{view === 'table' && <NodesTable />}
{view === 'map' && <MapPanel />}
{view === 'relationships' && <RelationshipsTable />}
- </>
+ </div>
</Suspense>
<DragOverlay isDragging={isDraggingOver} />
- <div className="absolute z-21 left-3 top-3 right-3">
- <Toolbar isLoading={isLoading} />
- </div>
<NewActions />
<CreateRelationDialog />
<MergeDialog />
@@ -150,6 +146,7 @@ const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {
<Settings />
<KeyboardShortcuts />
</div>
+
)
}
diff --git a/flowsint-app/src/components/graphs/items-panel.tsx b/flowsint-app/src/components/graphs/items-panel.tsx
index 99c93ee4..abc331c3 100644
--- a/flowsint-app/src/components/graphs/items-panel.tsx
+++ b/flowsint-app/src/components/graphs/items-panel.tsx
@@ -1,5 +1,5 @@
import { Button } from '@/components/ui/button'
-import { PlusIcon, Search } from 'lucide-react'
+import { Download, PlusIcon, Search } from 'lucide-react'
import { memo, useCallback, useMemo, useState } from 'react'
import { type ActionItem } from '@/lib/action-items'
import { DraggableItem } from './draggable-item'
@@ -7,10 +7,12 @@ import { Input } from '@/components/ui/input'
import { useActionItems } from '@/hooks/use-action-items'
import { SkeletonList } from '../shared/skeleton-list'
import { useGraphStore } from '@/stores/graph-store'
+import { useGraphSettingsStore } from '@/stores/graph-settings-store'
export const ItemsPanel = memo(function LeftPanel() {
const [searchQuery, setSearchQuery] = useState<string>('')
const setOpenMainDialog = useGraphStore((state) => state.setOpenMainDialog)
+ const setImportModalOpen = useGraphSettingsStore((s) => s.setImportModalOpen)
const handleSearchChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
setSearchQuery(e.target.value)
@@ -20,6 +22,10 @@ export const ItemsPanel = memo(function LeftPanel() {
setOpenMainDialog(true)
}, [setOpenMainDialog])
+ const handleOpenImportModal = useCallback(() => {
+ setImportModalOpen(true)
+ }, [setImportModalOpen])
+
const { actionItems, isLoading } = useActionItems()
const filteredItems = useMemo(() => {
@@ -30,7 +36,6 @@ export const ItemsPanel = memo(function LeftPanel() {
return actionItems
.map((item) => {
const parentMatches = item.label.toLowerCase().includes(query)
-
if (item.children && item.children.length > 0) {
const filteredChildren = item.children.filter((child) => {
const childMatchesLabel = child.label.toLowerCase().includes(query)
@@ -44,7 +49,6 @@ export const ItemsPanel = memo(function LeftPanel() {
}
return null
}
-
const itemMatchesFields = (item.fields || []).some(
(f) => f.label.toLowerCase().includes(query) || f.name.toLowerCase().includes(query)
)
@@ -77,6 +81,9 @@ export const ItemsPanel = memo(function LeftPanel() {
/>
</div>
</div>
+ <div className='my-1'>
+ <Button onClick={handleOpenImportModal} className="w-full" variant={"outline"}><Download /> Import entities</Button>
+ </div>
<div className="flex flex-col gap-3">
{isLoading ? (
<SkeletonList rowCount={8} />
diff --git a/flowsint-app/src/components/graphs/node-context-menu.tsx b/flowsint-app/src/components/graphs/node-context-menu.tsx
new file mode 100644
index 00000000..90a8b380
--- /dev/null
+++ b/flowsint-app/src/components/graphs/node-context-menu.tsx
@@ -0,0 +1,321 @@
+import React, { memo, useCallback, useMemo, useState } from 'react'
+import { transformService } from '@/api/transform-service'
+import { flowService } from '@/api/flow-service'
+import { useQuery } from '@tanstack/react-query'
+import { Skeleton } from '@/components/ui/skeleton'
+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, SquareArrowOutUpRight } from 'lucide-react'
+import { Transform, Flow, GraphNode } from '@/types'
+import { useLaunchFlow } from '@/hooks/use-launch-flow'
+import { useLaunchTransform } from '@/hooks/use-launch-transform'
+import { useParams } from '@tanstack/react-router'
+import { capitalizeFirstLetter } from '@/lib/utils'
+import NodeActions from '@/components/graphs/node-actions'
+import BaseContextMenu from '@/components/xyflow/context-menu'
+import { useGraphStore } from '@/stores/graph-store'
+import { CopyButton } from '../copy'
+
+interface GraphContextMenuProps {
+ node: GraphNode
+ top?: number
+ left?: number
+ right?: number
+ bottom?: number
+ rawTop?: number
+ rawLeft?: number
+ wrapperWidth: number
+ wrapperHeight: number
+ onEdit?: () => void
+ onDelete?: () => void
+ setMenu: (menu: any | null) => void
+ [key: string]: any
+}
+
+export default function ContextMenu({
+ node,
+ top,
+ left,
+ right,
+ bottom,
+ wrapperWidth,
+ wrapperHeight,
+ onEdit,
+ onDelete,
+ setMenu,
+ ...props
+}: GraphContextMenuProps) {
+ const { id: sketchId } = useParams({ strict: false })
+ const [activeTab, setActiveTab] = useState('transforms')
+ const [transformsSearchQuery, setTransformsSearchQuery] = useState('')
+ const [flowsSearchQuery, setFlowsSearchQuery] = useState('')
+ const { launchFlow } = useLaunchFlow(false)
+ const { launchTransform } = useLaunchTransform(false)
+ const toggleNodeSelection = useGraphStore((s) => s.toggleNodeSelection)
+
+ const { data: transforms, isLoading: isLoadingTransforms } = useQuery({
+ queryKey: ['transforms', node.data.type],
+ queryFn: () => transformService.get(capitalizeFirstLetter(node.data.type))
+ })
+
+ const { data: flows, isLoading: isLoadingFlows } = useQuery({
+ queryKey: ['flows', node.data.type],
+ queryFn: () => flowService.get(capitalizeFirstLetter(node.data.type))
+ })
+
+ const filteredTransforms =
+ transforms?.filter((transform: Transform) => {
+ if (!transformsSearchQuery.trim()) return true
+ const query = transformsSearchQuery.toLowerCase().trim()
+ const matchesName = transform.name?.toLowerCase().includes(query)
+ const matchesDescription = transform.description?.toLowerCase().includes(query)
+ return matchesName || matchesDescription
+ }) || []
+
+ const filteredFlows =
+ flows?.filter((flow: Flow) => {
+ if (!flowsSearchQuery.trim()) return true
+ const query = flowsSearchQuery.toLowerCase().trim()
+ const matchesName = flow.name?.toLowerCase().includes(query)
+ const matchesDescription = flow.description?.toLowerCase().includes(query)
+ return matchesName || matchesDescription
+ }) || []
+
+ const handleFlowClick = (e: React.MouseEvent, flowId: string) => {
+ e.stopPropagation()
+ launchFlow([node.id], flowId, sketchId)
+ setMenu(null)
+ }
+
+ const handleTransformClick = (e: React.MouseEvent, transformName: string) => {
+ e.stopPropagation()
+ launchTransform([node.id], transformName, sketchId)
+ setMenu(null)
+ }
+
+ const handleOpenNodeDetails = useCallback((e: React.MouseEvent) => {
+ e.stopPropagation()
+ toggleNodeSelection(node, false)
+ }, [toggleNodeSelection, node])
+
+ return (
+ <BaseContextMenu
+ top={top}
+ left={left}
+ right={right}
+ bottom={bottom}
+ wrapperWidth={wrapperWidth}
+ wrapperHeight={wrapperHeight}
+ {...props}
+ >
+ {/* 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="flex text-xs items-center gap-1 truncate">
+ <span className="block truncate">{node.data.label}</span> -{' '}
+ <span className="block">{node.data.type}</span>
+ </div>
+ <NodeActions node={node} setMenu={setMenu} />
+ </div>
+
+ {/* Tabs */}
+ <div className="px-3 py-2 border-b border-border flex-shrink-0">
+ <Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">
+ <TabsList className="w-full h-9">
+ <TabsTrigger value="transforms" className="flex-1" onClick={(e) => e.stopPropagation()}>
+ <Zap className="h-3 w-3 mr-1" />
+ Transforms
+ </TabsTrigger>
+ <TabsTrigger value="flows" className="flex-1" onClick={(e) => e.stopPropagation()}>
+ <FileCode2 className="h-3 w-3 mr-1" />
+ Flows
+ </TabsTrigger>
+ </TabsList>
+ </Tabs>
+ </div>
+
+ {/* Tab Content */}
+ <Tabs value={activeTab} className="flex-1 flex flex-col min-h-0">
+ {/* Transforms Tab */}
+ <TabsContent value="transforms" className="flex-1 flex flex-col min-h-0 mt-0">
+ {/* Transforms Search */}
+ <div className="px-3 py-2 border-b border-border flex-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
+ type="search"
+ placeholder="Search transforms..."
+ value={transformsSearchQuery}
+ onChange={(e) => {
+ e.stopPropagation()
+ setTransformsSearchQuery(e.target.value)
+ }}
+ onClick={(e) => e.stopPropagation()}
+ className="h-7 pl-7 text-xs"
+ />
+ </div>
+ </div>
+
+ {/* Transforms List */}
+ <div className="flex-1 grow overflow-auto min-h-0">
+ {isLoadingTransforms ? (
+ <div className="p-2 space-y-2">
+ {[...Array(3)].map((_, i) => (
+ <div key={i} className="flex items-center gap-2 p-2 rounded-md">
+ <Skeleton className="h-4 w-4" />
+ <div className="flex-1 space-y-1">
+ <Skeleton className="h-3 w-3/4" />
+ <Skeleton className="h-2 w-1/2" />
+ </div>
+ </div>
+ ))}
+ </div>
+ ) : filteredTransforms.length > 0 ? (
+ <div className="p-1">
+ {filteredTransforms.map((transform: Transform) => (
+ <button
+ key={transform.id}
+ className="w-full flex items-center gap-2 p-2 rounded-md hover:bg-muted text-left transition-colors"
+ onClick={(e) => handleTransformClick(e, transform.name)}
+ >
+ <Zap className="h-4 w-4 text-muted-foreground flex-shrink-0" />
+ <div className="flex-1 min-w-0">
+ <p className="text-sm font-medium flex gap-1 items-center truncate">
+ <span>{transform.wobblyType ? <BadgeAlert className='h-3 w-3 text-orange-400' /> : <BadgeCheck className='h-3 w-3 text-green-400' />} </span> {transform.name || '(Unnamed transform)'}
+ </p>
+ {transform.description && (
+ <p className="text-xs text-muted-foreground truncate">
+ {transform.description}
+ </p>
+ )}
+ </div>
+ <div className="flex items-center gap-1">
+ {/* <FavoriteButton isFavorite={false} /> */}
+ <InfoButton description={transform.description ?? ''} />
+ </div>
+ </button>
+ ))}
+ </div>
+ ) : (
+ <div className="p-4 text-center">
+ <p className="text-sm text-muted-foreground">
+ {transformsSearchQuery ? 'No transforms found' : 'No transforms available'}
+ </p>
+ </div>
+ )}
+ </div>
+ </TabsContent>
+
+ {/* 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="relative">
+ <Search className="absolute left-2 top-1/2 transform -translate-y-1/2 h-3 w-3 text-muted-foreground" />
+ <Input
+ type="search"
+ placeholder="Search flows..."
+ value={flowsSearchQuery}
+ onChange={(e) => {
+ e.stopPropagation()
+ setFlowsSearchQuery(e.target.value)
+ }}
+ onClick={(e) => e.stopPropagation()}
+ className="h-7 pl-7 text-xs"
+ />
+ </div>
+ </div>
+
+ {/* Flows List */}
+ <div className="flex-1 grow overflow-auto min-h-0">
+ {isLoadingFlows ? (
+ <div className="p-2 space-y-2">
+ {[...Array(3)].map((_, i) => (
+ <div key={i} className="flex items-center gap-2 p-2 rounded-md">
+ <Skeleton className="h-4 w-4" />
+ <div className="flex-1 space-y-1">
+ <Skeleton className="h-3 w-3/4" />
+ <Skeleton className="h-2 w-1/2" />
+ </div>
+ </div>
+ ))}
+ </div>
+ ) : filteredFlows.length > 0 ? (
+ <div className="p-1">
+ {filteredFlows.map((flow: Flow) => (
+ <button
+ key={flow.id}
+ 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" />
+ <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)'}
+ </p>
+ {flow.description && (
+ <p className="text-xs text-muted-foreground truncate">{flow.description}</p>
+ )}
+ </div>
+ <div className="flex items-center gap-1">
+ {/* <FavoriteButton isFavorite={false} /> */}
+ <InfoButton description={flow.description} />
+ </div>
+ </button>
+ ))}
+ </div>
+ ) : (
+ <div className="p-4 text-center">
+ <p className="text-sm text-muted-foreground">
+ {flowsSearchQuery ? 'No flows found' : 'No flows available'}
+ </p>
+ </div>
+ )}
+ </div>
+ </TabsContent>
+ </Tabs>
+
+ <div className='border-t p-1'>
+ <SubActions node={node} handleOpenNodeDetails={handleOpenNodeDetails} />
+ </div>
+ </BaseContextMenu>
+ )
+}
+
+type SubActionsProps = {
+ node: GraphNode
+ handleOpenNodeDetails: (e: React.MouseEvent) => void
+}
+const SubActions = memo(({ node, handleOpenNodeDetails }: SubActionsProps) => {
+ return (
+ <div className='flex gap-1'>
+ <CopyButton size={"icon"} content={node?.data?.label} />
+ <Button onClick={handleOpenNodeDetails} size={'icon'} className='h-7 w-7' variant="ghost"><SquareArrowOutUpRight className='!h-3.5 !w-3.5 opacity-50' /></Button>
+ </div>)
+}
+)
+
+const InfoButton = ({ description }: { description?: string }) => {
+ if (!description) return null
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <div>
+ <Button
+ onClick={(e) => e.stopPropagation()}
+ className="w-5 h-5"
+ variant="ghost"
+ size={'icon'}
+ >
+ <Info className="w-4 h-4 opacity-50" strokeWidth={1.5} />
+ </Button>
+ </div>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p className="whitespace-pre-wrap">{description}</p>
+ </TooltipContent>
+ </Tooltip>
+ )
+}
diff --git a/flowsint-app/src/components/graphs/save-status-indicator.tsx b/flowsint-app/src/components/graphs/save-status-indicator.tsx
index af4ccb11..e177e1d4 100644
--- a/flowsint-app/src/components/graphs/save-status-indicator.tsx
+++ b/flowsint-app/src/components/graphs/save-status-indicator.tsx
@@ -2,6 +2,7 @@ import { memo } from 'react'
import { Cloud, CloudOff, Loader2, Check, AlertCircle } from 'lucide-react'
import { SaveStatus } from '@/hooks/use-save-node-positions'
import { cn } from '@/lib/utils'
+import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'
interface SaveStatusIndicatorProps {
status: SaveStatus
@@ -54,18 +55,23 @@ export const SaveStatusIndicator = memo(({ status }: SaveStatusIndicatorProps) =
const Icon = config.icon
return (
- <div
- className={cn(
- 'flex items-center h-8 gap-1.5 px-2.5 py-1.5',
- 'rounded-md border',
- 'text-xs font-medium',
- 'transition-all duration-200',
- config.className
- )}
- >
- <Icon className={cn('h-3.5 w-3.5', config.iconClassName)} />
- {/* <span>{config.text}</span> */}
- </div>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <div
+ className={cn(
+ 'flex items-center h-8 gap-1.5 px-2.5 py-1.5',
+ 'rounded-md border',
+ 'text-xs font-medium',
+ 'transition-all duration-200',
+ config.className
+ )}
+ >
+ <Icon className={cn('h-3.5 w-3.5', config.iconClassName)} />
+ {/* <span>{config.text}</span> */}
+ </div>
+ </TooltipTrigger>
+ <TooltipContent>{"All nodes aved"}</TooltipContent>
+ </Tooltip>
)
})
diff --git a/flowsint-app/src/components/graphs/toolbar.tsx b/flowsint-app/src/components/graphs/toolbar.tsx
index 97daf4fc..fdef1431 100644
--- a/flowsint-app/src/components/graphs/toolbar.tsx
+++ b/flowsint-app/src/components/graphs/toolbar.tsx
@@ -1,30 +1,30 @@
import { Button } from '@/components/ui/button'
-import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
+import { useConfirm } from '@/components/use-confirm-dialog'
+import { cn } from '@/lib/utils'
import { useGraphControls } from '@/stores/graph-controls-store'
+import { useGraphSaveStatus } from '@/stores/graph-save-status-store'
+import { useGraphStore } from '@/stores/graph-store'
import {
- Maximize,
- Minus,
- ZoomIn,
- RotateCw,
- Waypoints,
- MapPin,
- List,
- GitFork,
- ArrowRightLeft,
FunnelPlus,
+ GitFork,
GitPullRequestArrow,
LassoSelect,
+ Maximize,
Merge,
- Network
+ Minus,
+ RotateCw,
+ ZoomIn
} from 'lucide-react'
import { memo, useCallback } from 'react'
import { toast } from 'sonner'
-import { cn } from '@/lib/utils'
import Filters from './filters'
-import { useGraphStore } from '@/stores/graph-store'
-import { useConfirm } from '@/components/use-confirm-dialog'
-import { useGraphSaveStatus } from '@/stores/graph-save-status-store'
import { SaveStatusIndicator } from './save-status-indicator'
+import { Separator } from '../ui/separator'
+import { ViewToggle } from './view-toggle'
+import { NetworkIcon } from '../icons/network'
+import { useKeyboard } from '@/hooks/use-keyboard'
+import { isMac } from '@/lib/utils'
// Tooltip wrapper component to avoid repetition
export const ToolbarButton = memo(function ToolbarButton({
@@ -33,7 +33,8 @@ export const ToolbarButton = memo(function ToolbarButton({
onClick,
disabled = false,
badge = null,
- toggled = false
+ toggled = false,
+ showLabel = false
}: {
icon: React.ReactNode
tooltip: string | React.ReactNode
@@ -41,6 +42,7 @@ export const ToolbarButton = memo(function ToolbarButton({
disabled?: boolean
badge?: number | null
toggled?: boolean | null
+ showLabel?: boolean
}) {
return (
<Tooltip>
@@ -49,17 +51,18 @@ export const ToolbarButton = memo(function ToolbarButton({
<Button
onClick={onClick}
disabled={disabled}
- variant="outline"
- size="icon"
+ variant="ghost"
+ size={showLabel ? "sm" : "icon"}
className={cn(
- 'h-8 w-8 relative shadow-none',
+ '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'
)}
>
- {icon}
+ {icon} {showLabel && <span className='hidden md:block'>{tooltip}</span>}
{badge && (
- <span className="absolute -top-2 -right-2 z-50 bg-primary text-white text-[10px] rounded-full w-auto min-w-4.5 h-4.5 p-1 flex items-center justify-center">
+ <span className="absolute -top-1 -right-2 !z-[500] bg-primary text-white text-[10px] rounded-full w-auto min-w-4.5 h-4.5 p-1 flex items-center justify-center">
{badge}
</span>
)}
@@ -87,6 +90,12 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean
const filters = useGraphStore((s) => s.filters)
const saveStatus = useGraphSaveStatus((s) => s.saveStatus)
+ useKeyboard(
+ "s",
+ () => setIsLassoActive(true),
+ () => setIsLassoActive(false),
+ );
+
const handleRefresh = useCallback(() => {
try {
refetchGraph()
@@ -115,25 +124,18 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean
}, [confirm, regenerateLayout])
const handleApplyHierarchyLayout = useCallback(async () => {
- console.log('[Toolbar] handleApplyHierarchyLayout called')
-
const confirmed = await confirm({
title: 'Apply hierarchy layout?',
message: 'This will reset all node positions and regenerate them using the hierarchical layout algorithm. Current positions will be lost.'
})
if (!confirmed) {
- console.log('[Toolbar] User cancelled layout change')
return
}
-
- console.log('[Toolbar] Calling regenerateLayout with hierarchy')
try {
regenerateLayout('hierarchy')
- console.log('[Toolbar] Hierarchy layout applied successfully')
toast.success('Hierarchy layout applied successfully')
} catch (error) {
- console.error('[Toolbar] Failed to apply layout:', error)
toast.error(`Failed to apply layout: ${error instanceof Error ? error.message : 'Unknown error'}`)
}
}, [confirm, regenerateLayout])
@@ -159,9 +161,9 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean
)
return (
- <div className='flex absolute top-0 left-1 right-1 justify-between items-center gap-6 w-full'>
- <div className='flex gap-2 left-2 top-2'>
- <TooltipProvider>
+ <div className='flex justify-between h-10 z-50 items-center gap-6 w-full border-b bg-card p-1 px-2'>
+ <div className='flex h-full items-center gap-2'>
+ <div className='flex gap-1'>
<ToolbarButton
icon={<GitPullRequestArrow className="h-4 w-4 opacity-70" />}
tooltip="Connect"
@@ -176,6 +178,9 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean
disabled={!areMergeable}
badge={areMergeable ? selectedNodes.length : null}
/>
+ </div>
+ <Separator decorative orientation="vertical" />
+ <div className='flex gap-1'>
<ToolbarButton
icon={<ZoomIn className="h-4 w-4 opacity-70" />}
tooltip="Zoom In"
@@ -194,9 +199,12 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean
onClick={zoomToFit}
disabled={view !== 'graph' || isLassoActive}
/>
+ </div>
+ <Separator decorative orientation="vertical" />
+ <div className='flex gap-1'>
<ToolbarButton
icon={<LassoSelect className="h-4 w-4 opacity-70" />}
- tooltip={'Lasso select'}
+ tooltip={'Lasso select (hold S)'}
onClick={handleLassoSelect}
toggled={isLassoActive}
disabled={view !== 'graph'}
@@ -206,119 +214,41 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: boolean
disabled={isLoading}
icon={<FunnelPlus className={cn('h-4 w-4 opacity-70')} />}
tooltip="Filters"
+ showLabel
toggled={hasFilters}
/>
</Filters>
- <ToolbarButton
- onClick={handleRefresh}
- disabled={isLoading}
- icon={<RotateCw className={cn('h-4 w-4 opacity-70', isLoading && 'animate-spin')} />}
- tooltip="Refresh"
- />
- </TooltipProvider>
- </div >
-
- {/* Center: View Toggle Group */}
- <div className="flex border rounded-md justify-center" >
- <div className="flex items-center bg-muted/40 p-1 gap-0.5 rounded-md">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="sm"
- onClick={() => setView('graph')}
- className={cn(
- 'h-6 px-2 rounded-sm',
- view === 'graph'
- ? 'bg-background text-foreground border'
- : 'text-muted-foreground hover:text-foreground hover:bg-background/50'
- )}
- >
- <Network className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>Graph view</TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="sm"
- onClick={() => setView('table')}
- className={cn(
- 'h-6 px-2 rounded-sm',
- view === 'table'
- ? 'bg-background text-foreground border'
- : 'text-muted-foreground hover:text-foreground hover:bg-background/50'
- )}
- >
- <List className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>Table view</TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="sm"
- onClick={() => setView('relationships')}
- className={cn(
- 'h-6 px-2 rounded-sm',
- view === 'relationships'
- ? 'bg-background text-foreground border'
- : 'text-muted-foreground hover:text-foreground hover:bg-background/50'
- )}
- >
- <ArrowRightLeft className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>Relationships view</TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="sm"
- onClick={() => setView('map')}
- className={cn(
- 'h-6 px-2 rounded-sm',
- view === 'map'
- ? 'bg-background text-foreground border'
- : 'text-muted-foreground hover:text-foreground hover:bg-background/50'
- )}
- >
- <MapPin className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>Map view</TooltipContent>
- </Tooltip>
- </TooltipProvider>
</div>
+ <Separator orientation="vertical" />
+ <div className="flex items-center gap-1" >
+ <>
+ <ToolbarButton
+ icon={<NetworkIcon className="h-4 w-4 opacity-70" />}
+ tooltip={'Force layout'}
+ onClick={handleApplyForceLayout}
+ disabled={isLoading || view !== 'graph'}
+ />
+ <ToolbarButton
+ icon={<GitFork strokeWidth={1.4} className="h-4 w-4 opacity-70 rotate-180" />}
+ tooltip={'Hierarchy layout'}
+ onClick={handleApplyHierarchyLayout}
+ disabled={isLoading || view !== 'graph'}
+ />
+ </>
+ </div>
+ <Separator decorative orientation="vertical" />
+ {/* Center: View Toggle Group */}
+ <ViewToggle view={view} setView={setView} />
</div>
-
- <div className="flex items-center gap-2" >
- <TooltipProvider>
- {view === 'graph' && (
- <>
- <ToolbarButton
- icon={<Waypoints className="h-4 w-4 opacity-70" />}
- tooltip={'Force layout'}
- onClick={handleApplyForceLayout}
- disabled={isLoading}
- />
- <ToolbarButton
- icon={<GitFork className="h-4 w-4 opacity-70 rotate-180" />}
- tooltip={'Hierarchy layout'}
- onClick={handleApplyHierarchyLayout}
- disabled={isLoading}
- />
- </>
- )}
- </TooltipProvider>
+ <div className='flex item-center gap-2'>
+ <ToolbarButton
+ onClick={handleRefresh}
+ disabled={isLoading}
+ icon={<RotateCw className={cn('h-4 w-4 opacity-70', isLoading && 'animate-spin')} />}
+ tooltip="Refresh"
+ />
<SaveStatusIndicator status={saveStatus} />
</div>
- </div>
+ </div >
)
})
\ No newline at end of file
diff --git a/flowsint-app/src/components/graphs/view-toggle.tsx b/flowsint-app/src/components/graphs/view-toggle.tsx
new file mode 100644
index 00000000..ee1bf067
--- /dev/null
+++ b/flowsint-app/src/components/graphs/view-toggle.tsx
@@ -0,0 +1,50 @@
+"use client"
+
+import { List, ArrowRightLeft, MapPin, ChevronDown } from "lucide-react"
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuRadioGroup,
+ DropdownMenuRadioItem,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu"
+import { Button } from "@/components/ui/button"
+import { NetworkIcon } from "../icons/network"
+
+interface ViewToggleProps {
+ view: "graph" | "table" | "relationships" | "map"
+ setView: (view: "graph" | "table" | "relationships" | "map") => void
+}
+
+export function ViewToggle({ view, setView }: ViewToggleProps) {
+ const views = [
+ { value: "graph", icon: NetworkIcon, label: "Graph" },
+ { value: "table", icon: List, label: "Table" },
+ { value: "relationships", icon: ArrowRightLeft, label: "Relationships" },
+ { value: "map", icon: MapPin, label: "Map" },
+ ] as const
+
+ const currentView = views.find((v) => v.value === view)
+ const CurrentIcon = currentView?.icon || NetworkIcon
+
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" size="sm" className="gap-2 bg-transparent">
+ <CurrentIcon strokeWidth={1.6} className="h-4 w-4 opacity-70" />
+ {currentView?.label} <ChevronDown />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuRadioGroup value={view} onValueChange={(value) => setView(value as typeof view)}>
+ {views.map(({ value, icon: Icon, label }) => (
+ <DropdownMenuRadioItem key={value} value={value}>
+ <Icon strokeWidth={1.4} className="h-4 w-4 opacity-70" />
+ {label}
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )
+}
\ No newline at end of file
diff --git a/flowsint-app/src/components/icons/network.tsx b/flowsint-app/src/components/icons/network.tsx
new file mode 100644
index 00000000..7542a7d0
--- /dev/null
+++ b/flowsint-app/src/components/icons/network.tsx
@@ -0,0 +1,11 @@
+export const NetworkIcon = (props: any) => (
+ <svg
+ {...props}
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 60 60"
+ className="stroke-foreground opacity-70 fill-none"
+ >
+ <path stroke="currentColor"
+ strokeWidth="1.7" d="M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17 s-3.542,0.634-4.898,1.688l-7.669-7.669C16.785,10.424,17,9.74,17,9c0-2.206-1.794-4-4-4S9,6.794,9,9s1.794,4,4,4 c0.74,0,1.424-0.215,2.019-0.567l7.669,7.669C21.634,21.458,21,23.154,21,25s0.634,3.542,1.688,4.897L10.024,42.562 C8.958,41.595,7.549,41,6,41c-3.309,0-6,2.691-6,6s2.691,6,6,6s6-2.691,6-6c0-1.035-0.263-2.009-0.726-2.86l12.829-12.829 c1.106,0.86,2.44,1.436,3.898,1.619v10.16c-2.833,0.478-5,2.942-5,5.91c0,3.309,2.691,6,6,6s6-2.691,6-6c0-2.967-2.167-5.431-5-5.91 v-10.16c1.458-0.183,2.792-0.759,3.898-1.619l7.669,7.669C41.215,39.576,41,40.26,41,41c0,2.206,1.794,4,4,4s4-1.794,4-4 s-1.794-4-4-4c-0.74,0-1.424,0.215-2.019,0.567l-7.669-7.669C36.366,28.542,37,26.846,37,25s-0.634-3.542-1.688-4.897l9.665-9.665 C46.042,11.405,47.451,12,49,12c3.309,0,6-2.691,6-6S52.309,0,49,0z M11,9c0-1.103,0.897-2,2-2s2,0.897,2,2s-0.897,2-2,2 S11,10.103,11,9z M6,51c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S8.206,51,6,51z M33,49c0,2.206-1.794,4-4,4s-4-1.794-4-4 s1.794-4,4-4S33,46.794,33,49z M29,31c-3.309,0-6-2.691-6-6s2.691-6,6-6s6,2.691,6,6S32.309,31,29,31z M47,41c0,1.103-0.897,2-2,2 s-2-0.897-2-2s0.897-2,2-2S47,39.897,47,41z M49,10c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S51.206,10,49,10z" />
+ </svg>
+)
diff --git a/flowsint-app/src/components/layout/top-navbar.tsx b/flowsint-app/src/components/layout/top-navbar.tsx
index 4283d9a4..b16c1793 100644
--- a/flowsint-app/src/components/layout/top-navbar.tsx
+++ b/flowsint-app/src/components/layout/top-navbar.tsx
@@ -36,7 +36,7 @@ export const TopNavbar = memo(() => {
return (
<header
- className="flex items-center bg-card h-12 border-b shrink-0 px-4"
+ className="flex items-center bg-card h-11 border-b shrink-0 px-4"
data-tour-id="navigation"
>
<div className="flex items-center gap-4">
diff --git a/flowsint-app/src/components/table/nodes-view.tsx b/flowsint-app/src/components/table/nodes-view.tsx
index 25ddaa77..89c02218 100644
--- a/flowsint-app/src/components/table/nodes-view.tsx
+++ b/flowsint-app/src/components/table/nodes-view.tsx
@@ -65,7 +65,7 @@ const NodeItem = memo(function NodeItem({
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}:${value}`)
+ .map(([key, value]) => `${key}:${Boolean(value) ? value : "N/A"}`)
.join(', ')
return entries
}, [])
@@ -141,7 +141,6 @@ export default function NodesTable({ nodes }: NodesTableProps) {
const setCurrentNode = useGraphStore((s) => s.setCurrentNode)
const selectedNodes = useGraphStore((s) => s.selectedNodes)
const setSelectedNodes = useGraphStore((s) => s.setSelectedNodes)
- const toggleNodeSelection = useGraphStore((s) => s.toggleNodeSelection)
const onNodeClick = useCallback(
(node: GraphNode) => {
@@ -224,7 +223,7 @@ export default function NodesTable({ nodes }: NodesTableProps) {
if (!nodes || nodes.length === 0) {
return (
- <div className="w-full pt-18 flex items-center justify-center h-full">
+ <div className="w-full flex items-center justify-center h-full">
<div className="text-center space-y-4">
<Link className="mx-auto h-12 w-12 text-muted-foreground" />
<div>
@@ -237,7 +236,7 @@ export default function NodesTable({ nodes }: NodesTableProps) {
}
return (
- <div className="w-full grow flex flex-col pt-18 p-4 px-6">
+ <div className="w-full grow h-full flex flex-col p-4 px-6">
{/* Header with stats */}
<div className="flex items-center justify-between">
<div className="space-y-1">
@@ -280,7 +279,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-lg border text-sm font-medium text-muted-foreground"
+ className="grid items-center h-[44px] 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">
@@ -288,7 +287,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}
@@ -303,7 +302,7 @@ export default function NodesTable({ nodes }: NodesTableProps) {
</div>
{/* Virtualized List */}
- <div ref={parentRef} className="grow overflow-auto rounded-b-lg border border-t-0">
+ <div ref={parentRef} className="grow overflow-auto rounded-b-md border border-t-0">
<div
style={{
height: `${virtualizer.getTotalSize()}px`,
diff --git a/flowsint-app/src/components/table/relationships-view.tsx b/flowsint-app/src/components/table/relationships-view.tsx
index 7d7d66f3..923e91ca 100644
--- a/flowsint-app/src/components/table/relationships-view.tsx
+++ b/flowsint-app/src/components/table/relationships-view.tsx
@@ -164,7 +164,7 @@ export default function RelationshipsTable() {
if (isLoading) {
return (
- <div className="w-full p-4 px-6 space-y-4 pt-18">
+ <div className="w-full grow h-full flex flex-col pt-18 p-4 px-6">
{/* Header with stats */}
<div className="flex items-center justify-between">
<div className="space-y-1">
@@ -216,7 +216,7 @@ export default function RelationshipsTable() {
if (!relationships || relationships.length === 0) {
return (
- <div className="w-full pt-18 flex items-center justify-center h-full">
+ <div className="w-full flex items-center justify-center h-full">
<div className="text-center space-y-4">
<Link className="mx-auto h-12 w-12 text-muted-foreground" />
<div>
@@ -229,7 +229,7 @@ export default function RelationshipsTable() {
}
return (
- <div className="w-full grow flex flex-col pt-18 space-y-4 p-4 px-6">
+ <div className="w-full grow h-full flex flex-col p-4 px-6">
{/* Header with stats */}
<div className="flex items-center justify-between">
<div className="space-y-1">
@@ -245,7 +245,7 @@ export default function RelationshipsTable() {
</div>
{/* Search and Filter */}
- <div className="flex gap-4">
+ <div className="flex gap-4 my-4">
<div className="relative flex-1">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
<Input
diff --git a/flowsint-app/src/components/ui/tabs.tsx b/flowsint-app/src/components/ui/tabs.tsx
index eb0906cf..b2a35efa 100644
--- a/flowsint-app/src/components/ui/tabs.tsx
+++ b/flowsint-app/src/components/ui/tabs.tsx
@@ -18,7 +18,7 @@ function TabsList({ className, ...props }: React.ComponentProps<typeof TabsPrimi
<TabsPrimitive.List
data-slot="tabs-list"
className={cn(
- 'bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg !p-1',
+ 'bg-muted text-muted-foreground inline-flex h-10 w-fit items-center justify-center rounded-lg !p-1',
className
)}
{...props}
diff --git a/flowsint-app/src/hooks/use-keyboard.ts b/flowsint-app/src/hooks/use-keyboard.ts
new file mode 100644
index 00000000..e526e15a
--- /dev/null
+++ b/flowsint-app/src/hooks/use-keyboard.ts
@@ -0,0 +1,31 @@
+import { useEffect } from "react";
+
+type Callback = (event: KeyboardEvent) => void;
+
+export function useKeyboard(
+ targetKey?: string,
+ onKeyDown?: Callback,
+ onKeyUp?: Callback
+) {
+ useEffect(() => {
+ function handleKeyDown(e: KeyboardEvent) {
+ if (!targetKey || e.key === targetKey) {
+ onKeyDown?.(e);
+ }
+ }
+
+ function handleKeyUp(e: KeyboardEvent) {
+ if (!targetKey || e.key === targetKey) {
+ onKeyUp?.(e);
+ }
+ }
+
+ window.addEventListener("keydown", handleKeyDown);
+ window.addEventListener("keyup", handleKeyUp);
+
+ return () => {
+ window.removeEventListener("keydown", handleKeyDown);
+ window.removeEventListener("keyup", handleKeyUp);
+ };
+ }, [targetKey, onKeyDown, onKeyUp]);
+}
diff --git a/flowsint-app/src/lib/utils.ts b/flowsint-app/src/lib/utils.ts
index e62cb3e4..1ec76cab 100644
--- a/flowsint-app/src/lib/utils.ts
+++ b/flowsint-app/src/lib/utils.ts
@@ -124,7 +124,9 @@ export const getForceLayoutedElements = (
// Create simulation links
const simLinks = edges.map((edge) => ({
+ // @ts-ignore
source: typeof edge.source === 'object' ? edge.source.id : edge.source,
+ // @ts-ignore
target: typeof edge.target === 'object' ? edge.target.id : edge.target,
}));
diff --git a/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.index.tsx b/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.index.tsx
index 0b2d0f23..d2fefb7e 100644
--- a/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.index.tsx
+++ b/flowsint-app/src/routes/_auth.dashboard.investigations.$investigationId.index.tsx
@@ -2,7 +2,7 @@ import { createFileRoute, useNavigate } from '@tanstack/react-router'
import { investigationService } from '@/api/investigation-service'
import { analysisService } from '@/api/analysis-service'
import { Button } from '@/components/ui/button'
-import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
+import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Separator } from '@/components/ui/separator'
import {
@@ -177,7 +177,7 @@ function InvestigationPage() {
<span>
{investigation.owner
? `${investigation.owner.first_name || ''} ${investigation.owner.last_name || ''}`.trim() ||
- 'Unknown'
+ 'Unknown'
: 'Unknown'}
</span>
</div>
@@ -266,33 +266,21 @@ function InvestigationPage() {
}
className="hover:shadow-lg py-4 transition-all duration-200 cursor-pointer group border hover:border-primary/20"
>
- <CardContent className="h-full flex flex-col">
- {/* Header with title and count */}
- <div className="flex items-start justify-between mb-3">
- <div className="flex items-center gap-3 flex-1 min-w-0">
- <div className="w-8 h-8 bg-primary/10 rounded-lg flex items-center justify-center flex-shrink-0">
- <Waypoints className="w-4 h-4 text-primary" />
- </div>
- <div className="flex-1 min-w-0">
- <h3 className="font-semibold text-sm truncate group-hover:text-primary transition-colors">
- {sketch.title}
- </h3>
- </div>
- </div>
+ <CardHeader>
+ <CardTitle>{sketch.title}</CardTitle>
+ <CardDescription className='mt-2'>{Boolean(sketch.description) ? sketch.description : <span>No description provided</span>}</CardDescription>
+ </CardHeader>
+ <CardFooter>
+ <div className="flex items-center gap-2 text-xs text-muted-foreground">
+ <Clock className="w-3 h-3" />
+ <span>
+ Updated{' '}
+ {formatDistanceToNow(new Date(sketch.last_updated_at), {
+ addSuffix: true
+ })}
+ </span>
</div>
- {/* Footer with timestamp */}
- <div className="mt-auto">
- <div className="flex items-center gap-2 text-xs text-muted-foreground">
- <Clock className="w-3 h-3" />
- <span>
- Updated{' '}
- {formatDistanceToNow(new Date(sketch.last_updated_at), {
- addSuffix: true
- })}
- </span>
- </div>
- </div>
- </CardContent>
+ </CardFooter>
</Card>
))}
</div>
diff --git a/flowsint-app/src/stores/node-display-settings.ts b/flowsint-app/src/stores/node-display-settings.ts
index 509a4529..78ad092a 100644
--- a/flowsint-app/src/stores/node-display-settings.ts
+++ b/flowsint-app/src/stores/node-display-settings.ts
@@ -8,7 +8,7 @@ export type ItemType =
| 'email'
| 'ip'
| 'port'
- | 'social_account'
+ | 'socialaccount'
| 'organization'
| 'vehicle'
| 'car'
@@ -65,7 +65,7 @@ export const ITEM_TYPES: ItemType[] = [
'email',
'ip',
'port',
- 'social_account',
+ 'socialaccount',
'organization',
'vehicle',
'car',
@@ -122,7 +122,7 @@ const DEFAULT_COLORS: Record<ItemType, string> = {
email: '#8E7CC3', // violet pastel
ip: '#5AA1C8', // orange chaud
port: '#4CB5DA', // cyan clair
- social_account: '#A76DAA', // mauve
+ socialaccount: '#A76DAA', // mauve
organization: '#BCA18A', // taupe clair
vehicle: '#E1B84D', // jaune doux
car: '#BFAF7A', // olive beige
@@ -180,7 +180,7 @@ const DEFAULT_ICONS: Record<ItemType, string> = {
email: '✉️',
ip: '🌐',
port: '🔌',
- social_account: '📱',
+ socialaccount: '📱',
organization: '🏢',
vehicle: '🚗',
car: '🚗',
@@ -237,7 +237,7 @@ const DEFAULT_SIZES: Record<ItemType, number> = {
email: 14, // Medium
ip: 16, // Medium-large
port: 14, // Medium
- social_account: 14, // Medium
+ socialaccount: 14, // Medium
organization: 28, // Very large - important entities
vehicle: 12, // Small-medium
car: 12, // Small-medium
diff --git a/flowsint-app/src/workers/layout.worker.ts b/flowsint-app/src/workers/layout.worker.ts
index a5e76e9d..d5a9632f 100644
--- a/flowsint-app/src/workers/layout.worker.ts
+++ b/flowsint-app/src/workers/layout.worker.ts
@@ -55,25 +55,20 @@ function computeDagreLayout(
edges: GraphEdge[],
options: DagreLayoutOptions = {}
) {
- const {
- direction = 'TB',
- dagLevelDistance = 50,
- } = options
const g = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}))
// Configure dagre with proper spacing
g.setGraph({
- rankdir: direction,
- nodesep: dagLevelDistance,
- ranksep: dagLevelDistance,
- marginx: 10,
- marginy: 10,
+ rankdir: "TB",
+ ranker: "tight-tree", // 🔥 plus compact
+ nodesep: 20,
+ ranksep: 40,
})
// Set node dimensions
- const nodeWidth = 50
- const nodeHeight = 50
+ const nodeWidth = 10
+ const nodeHeight = 20
nodes.forEach((node) =>
g.setNode(node.id, {