Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat: JSON allowlist to hide non-working nodes from Component Palette
trohitg8350c7fe7f89
diff --git a/client/src/components/ui/ComponentPalette.tsx b/client/src/components/ui/ComponentPalette.tsxindex 5b3d63b6..f471fe74 100644--- a/client/src/components/ui/ComponentPalette.tsx+++ b/client/src/components/ui/ComponentPalette.tsx@@ -1,5 +1,6 @@import React from 'react';import { useAppTheme } from '../../hooks/useAppTheme';+import { useNodeAllowlist } from '../../hooks/useNodeAllowlist';import { ComponentPaletteProps } from '../../types/ComponentTypes';import { INodeTypeDescription } from '../../types/INodeProperties';import ComponentItem from './ComponentItem';@@ -25,6 +26,7 @@ const ComponentPalette: React.FC<ComponentPaletteProps> = ({proMode = false, // Default to simple mode}) => {const theme = useAppTheme();+ const { isVisible } = useNodeAllowlist();// Backend-driven group metadata via the shared WS-in-queryFn hook.// `useNodeGroups` returns the full query result so we can render a@@ -47,6 +49,9 @@ const ComponentPalette: React.FC<ComponentPaletteProps> = ({const categories: Record<string, INodeTypeDescription[]> = {};const filteredDefinitions = Object.values(nodeDefinitions).filter((definition) => {+ // Filter by backend allowlist (server/config/node_allowlist.json)+ if (!isVisible(definition.name)) return false;+// Filter by search queryif (searchQuery.trim()) {try {@@ -87,7 +92,7 @@ const ComponentPalette: React.FC<ComponentPaletteProps> = ({});return categories;- }, [nodeDefinitions, searchQuery, proMode, groupIndex]);+ }, [nodeDefinitions, searchQuery, proMode, groupIndex, isVisible]);const totalComponents = Object.values(categorizedComponents).reduce((acc, components) => acc + components.length,diff --git a/client/src/hooks/useNodeAllowlist.ts b/client/src/hooks/useNodeAllowlist.tsnew file mode 100644index 00000000..0cfb8194--- /dev/null+++ b/client/src/hooks/useNodeAllowlist.ts@@ -0,0 +1,49 @@+import { useState, useEffect, useCallback, useRef } from 'react';+import { useWebSocket } from '../contexts/WebSocketContext';++interface NodeAllowlistResponse {+ show_all: boolean;+ enabled_nodes: string[];+}++/**+ * Fetches the node allowlist from the backend and exposes a membership check+ * for the Component Palette.+ *+ * The backend decides whether to filter (show_all flag); the frontend only+ * checks list membership. While the response is loading, all nodes are shown+ * to avoid a palette flash.+ */+export const useNodeAllowlist = () => {+ const { sendRequest, isConnected } = useWebSocket();+ const [config, setConfig] = useState<NodeAllowlistResponse | null>(null);+ const hasFetchedRef = useRef(false);++ useEffect(() => {+ if (!isConnected || hasFetchedRef.current) return;+ hasFetchedRef.current = true;++ sendRequest<NodeAllowlistResponse>('get_node_allowlist', {})+ .then((response) => {+ setConfig({+ show_all: response?.show_all ?? true,+ enabled_nodes: response?.enabled_nodes ?? [],+ });+ })+ .catch((error) => {+ console.error('[NodeAllowlist] Failed to fetch:', error);+ setConfig({ show_all: true, enabled_nodes: [] });+ });+ }, [isConnected, sendRequest]);++ const isVisible = useCallback(+ (nodeType: string): boolean => {+ if (!config) return true;+ if (config.show_all) return true;+ return config.enabled_nodes.includes(nodeType);+ },+ [config]+ );++ return { isVisible };+};diff --git a/server/config/node_allowlist.json b/server/config/node_allowlist.jsonnew file mode 100644index 00000000..824d9c36--- /dev/null+++ b/server/config/node_allowlist.json@@ -0,0 +1,4 @@+{+ "_comment": "List node types to show in the Component Palette. Empty list or missing file = all nodes shown (default-on). Node type identifiers must match the 'name' field in client/src/nodeDefinitions/*.ts definitions verbatim.",+ "enabled_nodes": []+}diff --git a/server/routers/websocket.py b/server/routers/websocket.pyindex 370764f5..9c0e35d9 100644--- a/server/routers/websocket.py+++ b/server/routers/websocket.py@@ -2974,6 +2974,13 @@ async def handle_save_pricing_config(data: Dict[str, Any], websocket: WebSocket)return {"success": success}+@ws_handler()+async def handle_get_node_allowlist(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:+ """Return the node allowlist that controls which nodes appear in the palette."""+ from services.node_allowlist import get_node_allowlist_service+ return get_node_allowlist_service().get_config()++@ws_handler()async def handle_get_api_usage_summary(data: Dict[str, Any], websocket: WebSocket) -> Dict[str, Any]:"""Get aggregated API usage and cost by service (Twitter, etc.)."""@@ -3383,6 +3390,9 @@ MESSAGE_HANDLERS: Dict[str, MessageHandler] = {"save_pricing_config": handle_save_pricing_config,"get_api_usage_summary": handle_get_api_usage_summary,+ # Node Allowlist (UI palette filter)+ "get_node_allowlist": handle_get_node_allowlist,+# Model Registry"get_model_constraints": handle_get_model_constraints,"refresh_model_registry": handle_refresh_model_registry,diff --git a/server/services/node_allowlist.py b/server/services/node_allowlist.pynew file mode 100644index 00000000..ec1d7bc8--- /dev/null+++ b/server/services/node_allowlist.py@@ -0,0 +1,68 @@+"""Node allowlist service.++Reads server/config/node_allowlist.json and decides whether the frontend+Component Palette should show all nodes or filter by an explicit list.++Default-on: if the file is missing, malformed, or has an empty list, all+nodes are shown.+"""++import json+from pathlib import Path+from typing import Any, Dict, List++from core.logging import get_logger++logger = get_logger(__name__)++CONFIG_PATH = Path(__file__).parent.parent / "config" / "node_allowlist.json"+++class NodeAllowlistService:+ """Resolves the palette visibility config from node_allowlist.json."""++ def __init__(self, config_path: Path = CONFIG_PATH) -> None:+ self._config_path = config_path++ def get_config(self) -> Dict[str, Any]:+ """Return the effective allowlist config.++ Response shape:+ show_all: bool+ true -> do not filter the palette; every node is visible.+ false -> show only node types listed in enabled_nodes.+ enabled_nodes: list[str]+ Only meaningful when show_all is false.+ """+ if not self._config_path.exists():+ return {"show_all": True, "enabled_nodes": []}++ try:+ with self._config_path.open("r", encoding="utf-8") as f:+ raw = json.load(f)+ except Exception as e:+ logger.warning("Failed to parse node_allowlist.json, falling back to show_all: %s", e)+ return {"show_all": True, "enabled_nodes": []}++ enabled_nodes = raw.get("enabled_nodes", [])+ if not isinstance(enabled_nodes, list):+ logger.warning("node_allowlist.json 'enabled_nodes' is not a list, falling back to show_all")+ return {"show_all": True, "enabled_nodes": []}++ enabled_nodes = [n for n in enabled_nodes if isinstance(n, str)]++ if len(enabled_nodes) == 0:+ return {"show_all": True, "enabled_nodes": []}++ return {"show_all": False, "enabled_nodes": enabled_nodes}+++_instance: NodeAllowlistService | None = None+++def get_node_allowlist_service() -> NodeAllowlistService:+ """Return the singleton NodeAllowlistService."""+ global _instance+ if _instance is None:+ _instance = NodeAllowlistService()+ return _instance