Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat(icons): per-node-type icon resolution + whatsapp migration
trohitg1c0cd5761a52
diff --git a/server/nodes/_visuals.py b/server/nodes/_visuals.pyindex 842008d8..f3668d2e 100644--- a/server/nodes/_visuals.py+++ b/server/nodes/_visuals.py@@ -123,12 +123,24 @@ def get_plugin_meta(node_type: str, key: Optional[str] = None) -> Optional[dictdef get_plugin_icon_path(node_type: str, variant: str = "light") -> Optional[Path]:- """Return the on-disk path to a plugin's co-located ``icon.svg``.-- ``variant="dark"`` looks for ``icon.dark.svg`` first and falls back- to ``icon.svg`` if the dark variant is missing.-- Resolution:+ """Return the on-disk path to a plugin's co-located icon SVG.++ ``variant="dark"`` looks for the dark-mode SVG first and falls back+ to the light variant when no dark file exists.++ Resolution chain (first hit wins):+ 1. **Per-node-type icon** — ``<plugin_dir>/icon_<node_type>.svg``+ (or ``icon_<node_type>.dark.svg`` for ``variant="dark"``).+ Lets multi-node-per-plugin folders (whatsapp / telegram / stripe)+ serve distinct icons per node type WITHOUT splitting the folder.+ e.g. ``server/nodes/whatsapp/icon_whatsappSend.svg`` serves the+ ``whatsappSend`` node while sharing the folder with+ ``whatsappReceive`` and ``whatsappDb``.+ 2. **Shared plugin icon** — ``<plugin_dir>/icon.svg`` (or+ ``icon.dark.svg``). The original Phase 9 contract; one icon for+ the whole folder.++ Folder resolution itself:1. Look up the plugin class via :func:`services.node_registry.get_node_class`.2. Resolve the class's source file via ``inspect.getfile``.3. The plugin folder is the file's parent directory — equally@@ -136,9 +148,8 @@ def get_plugin_icon_path(node_type: str, variant: str = "light") -> Optional[Pat→ parent ``server/nodes/tool/``) and self-contained-folderplugins (``server/nodes/telegram/telegram_send.py`` → parent``server/nodes/telegram/``).- 4. Return ``<plugin_dir>/icon.svg`` (or dark variant) if it exists.- Returns ``None`` when the type is unknown or no ``icon.svg`` is+ Returns ``None`` when the type is unknown or no icon SVG ispresent — caller falls back to :func:`get_icon` (visuals.json)."""# Local import to avoid a top-level circular dep (node_registry@@ -153,12 +164,22 @@ def get_plugin_icon_path(node_type: str, variant: str = "light") -> Optional[Patexcept (TypeError, OSError):return None+ # Candidate filenames in resolution order. Per-node-type first so+ # multi-node folders can override the shared icon for specific+ # node types.+ candidates: list[str] = []+ if variant == "dark":+ candidates.append(f"icon_{node_type}.dark.svg")+ candidates.append(f"icon_{node_type}.svg")if variant == "dark":- dark = plugin_dir / "icon.dark.svg"- if dark.exists():- return dark- icon = plugin_dir / "icon.svg"- return icon if icon.exists() else None+ candidates.append("icon.dark.svg")+ candidates.append("icon.svg")++ for name in candidates:+ path = plugin_dir / name+ if path.exists():+ return path+ return Nonedef get_skill(node_type: str) -> str:diff --git a/server/nodes/visuals.json b/server/nodes/visuals.jsonindex 9549c1fb..af511252 100644--- a/server/nodes/visuals.json+++ b/server/nodes/visuals.json@@ -318,14 +318,9 @@"icon": "🪝"},"whatsappDb": {- "icon": "asset:whatsapp-db","skill": "whatsapp-db-skill"},- "whatsappReceive": {- "icon": "asset:whatsapp-receive"- },"whatsappSend": {- "icon": "asset:whatsapp-send","skill": "whatsapp-send-skill"},"wifiAutomation": {diff --git a/server/nodes/whatsapp/icon_whatsappDb.svg b/server/nodes/whatsapp/icon_whatsappDb.svgnew file mode 100644index 00000000..c6c08b9b--- /dev/null+++ b/server/nodes/whatsapp/icon_whatsappDb.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#25D366"><path d="M12 3C7.58 3 4 4.79 4 7v10c0 2.21 3.58 4 8 4s8-1.79 8-4V7c0-2.21-3.58-4-8-4zm0 2c3.87 0 6 1.5 6 2s-2.13 2-6 2-6-1.5-6-2 2.13-2 6-2zm6 12c0 .5-2.13 2-6 2s-6-1.5-6-2v-2.23c1.61.78 3.72 1.23 6 1.23s4.39-.45 6-1.23V17zm0-4c0 .5-2.13 2-6 2s-6-1.5-6-2v-2.23c1.61.78 3.72 1.23 6 1.23s4.39-.45 6-1.23V13zm0-4c0 .5-2.13 2-6 2s-6-1.5-6-2V6.77C7.61 7.55 9.72 8 12 8s4.39-.45 6-1.23V9z"/></svg>diff --git a/server/nodes/whatsapp/icon_whatsappReceive.svg b/server/nodes/whatsapp/icon_whatsappReceive.svgnew file mode 100644index 00000000..d35b0cdd--- /dev/null+++ b/server/nodes/whatsapp/icon_whatsappReceive.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#25D366"><path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-2 1H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6z"/><circle cx="18" cy="6" r="4"/></svg>diff --git a/server/nodes/whatsapp/icon_whatsappSend.svg b/server/nodes/whatsapp/icon_whatsappSend.svgnew file mode 100644index 00000000..42f8b042--- /dev/null+++ b/server/nodes/whatsapp/icon_whatsappSend.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#25D366"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>diff --git a/server/tests/temporal/test_dispatch.py b/server/tests/temporal/test_dispatch.pyindex 14d382b4..2c448e97 100644--- a/server/tests/temporal/test_dispatch.py+++ b/server/tests/temporal/test_dispatch.py@@ -169,6 +169,39 @@ class TestAgentWorkflowDispatch:)+class TestPerNodeTypeIconResolution:+ """``get_plugin_icon_path`` resolves per-node-type icons before the+ shared folder icon, so multi-node folders (whatsapp / telegram /+ stripe) can serve distinct icons per node type from one folder."""++ def test_whatsapp_send_resolves_per_node_icon(self):+ from nodes._visuals import get_plugin_icon_path+ path = get_plugin_icon_path("whatsappSend")+ assert path is not None+ assert path.name == "icon_whatsappSend.svg"++ def test_whatsapp_receive_resolves_per_node_icon(self):+ from nodes._visuals import get_plugin_icon_path+ path = get_plugin_icon_path("whatsappReceive")+ assert path is not None+ assert path.name == "icon_whatsappReceive.svg"++ def test_whatsapp_db_resolves_per_node_icon(self):+ from nodes._visuals import get_plugin_icon_path+ path = get_plugin_icon_path("whatsappDb")+ assert path is not None+ assert path.name == "icon_whatsappDb.svg"++ def test_telegram_falls_back_to_shared_icon(self):+ """telegram_send + telegram_receive share one icon.svg —+ per-node icons aren't required when the brand mark is the+ same for both."""+ from nodes._visuals import get_plugin_icon_path+ path = get_plugin_icon_path("telegramSend")+ assert path is not None+ assert path.name == "icon.svg"++class TestPerTypeActivityCollection:"""`collect_plugin_activities()` must return one callable per registeredplugin class — TemporalWorkerManager's per-type registration depends on