/** * Ultra-simple, single-line SVG designs for reliable rendering */ const iconSVGs: Record = { Bot: ``, User: ``, Wrench: ``, FileText: ``, Upload: ``, Download: ``, Users: ``, Circle: ``, }; /** * Convert an icon name to an SVG data URI for use in Cytoscape */ function createIconDataUri(iconName: string, size: number = 48): string { const iconContent = iconSVGs[iconName] || iconSVGs.Circle; // Create compact SVG without extra whitespace const svg = `${iconContent}`; // Use URL encoding instead of base64 for better compatibility const dataUri = `data:image/svg+xml,${encodeURIComponent(svg)}`; // Debug logging to help diagnose issues console.log(`🎨 Icon ${iconName}:`, { svgLength: svg.length, dataUriLength: dataUri.length, dataUriPreview: dataUri.substring(0, 80) + "...", }); return dataUri; } /** * Get the appropriate icon for a node type */ export function getNodeIcon(type?: string): string { const iconMap: Record = { // Primary types Agent: "Bot", Human: "User", Tool: "Wrench", // Task/IO types Task: "FileText", Input: "Upload", Output: "Download", // Group types Entity: "Circle", Person: "User", Organization: "Users", // Fallback Unknown: "Circle", }; const iconName = iconMap[type || "Unknown"] || "Circle"; return createIconDataUri(iconName, 48); } /** * Get node icon with custom size */ export function getNodeIconWithSize(type?: string, size: number = 48): string { const iconMap: Record = { Agent: "Bot", Human: "User", Tool: "Wrench", Task: "FileText", Input: "Upload", Output: "Download", Entity: "Circle", Person: "User", Organization: "Users", Unknown: "Circle", }; const iconName = iconMap[type || "Unknown"] || "Circle"; return createIconDataUri(iconName, size); }