Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(canvas): auto-hide default SquareNode handles for tool-oriented nodes
trohitgfa8344eadea4
diff --git a/client/src/adapters/nodeSpecToDescription.ts b/client/src/adapters/nodeSpecToDescription.tsindex 0459fb6c..5a99f4a6 100644--- a/client/src/adapters/nodeSpecToDescription.ts+++ b/client/src/adapters/nodeSpecToDescription.ts@@ -51,6 +51,7 @@ export interface NodeSpec {componentKind?: 'square' | 'circle' | 'trigger' | 'start' | 'agent' | 'chat' | 'tool' | 'model' | 'generic';handles?: NodeSpecHandle[];hideOutputHandle?: boolean;+ hideInputHandle?: boolean;visibility?: 'all' | 'normal' | 'dev';}diff --git a/client/src/components/SquareNode.tsx b/client/src/components/SquareNode.tsxindex 8bf1830c..47fa4d09 100644--- a/client/src/components/SquareNode.tsx+++ b/client/src/components/SquareNode.tsx@@ -383,26 +383,30 @@ const SquareNode: React.FC<NodeProps<NodeData>> = ({ id, type, data, isConnectabtitle={getStatusTitle()}/>- {/* Square Input Handle */}- <Handle- id="input-main"- type="target"- position={Position.Left}- isConnectable={isConnectable}- style={{- position: 'absolute',- left: '-6px',- top: '50%',- transform: 'translateY(-50%)',- width: theme.nodeSize.handle,- height: theme.nodeSize.handle,- backgroundColor: theme.isDarkMode ? theme.colors.background : '#ffffff',- border: `2px solid ${theme.isDarkMode ? theme.colors.textSecondary : '#6b7280'}`,- borderRadius: '50%',- zIndex: 20- }}- title="Service Input"- />+ {/* Square Input Handle (gated by spec.hideInputHandle, mirrors+ the hideOutputHandle pattern below — auto-derived True for+ usable_as_tool=True nodes via BaseNode.__init_subclass__). */}+ {!getCachedNodeSpec(type || '')?.hideInputHandle && (+ <Handle+ id="input-main"+ type="target"+ position={Position.Left}+ isConnectable={isConnectable}+ style={{+ position: 'absolute',+ left: '-6px',+ top: '50%',+ transform: 'translateY(-50%)',+ width: theme.nodeSize.handle,+ height: theme.nodeSize.handle,+ backgroundColor: theme.isDarkMode ? theme.colors.background : '#ffffff',+ border: `2px solid ${theme.isDarkMode ? theme.colors.textSecondary : '#6b7280'}`,+ borderRadius: '50%',+ zIndex: 20+ }}+ title="Service Input"+ />+ )}{/* Square Output Handle (Wave 10.E: spec.hideOutputHandle replaces thelocal NO_OUTPUT_NODE_TYPES list) */}diff --git a/server/models/node_metadata.py b/server/models/node_metadata.pyindex 62b6db95..ecbc7489 100644--- a/server/models/node_metadata.py+++ b/server/models/node_metadata.py@@ -49,6 +49,7 @@ class NodeMetadata(TypedDict, total=False):handles: list[NodeHandle] # replaces AGENT_CONFIGS topologycredentials: list[str] # provider keyshideOutputHandle: bool # replaces NO_OUTPUT_NODE_TYPES+ hideInputHandle: bool # auto-derived for usable_as_tool=True nodesvisibility: Literal["all", "normal", "dev"] # replaces SIMPLE_MODE_CATEGORIESdiff --git a/server/services/node_spec.py b/server/services/node_spec.pyindex ef25ef9d..cbdb0d5f 100644--- a/server/services/node_spec.py+++ b/server/services/node_spec.py@@ -85,7 +85,7 @@ def get_node_spec(node_type: str) -> Optional[dict[str, Any]]:# Wave 10.A — full visual contract. Only emit fields when seeded so the# wire format stays compact and unseeded types keep the pre-10 shape.for key in ("color", "componentKind", "handles", "credentials",- "hideOutputHandle", "visibility"):+ "hideOutputHandle", "hideInputHandle", "visibility"):if key in meta:spec[key] = meta[key]diff --git a/server/services/plugin/base.py b/server/services/plugin/base.pyindex 11a04533..a62acf1d 100644--- a/server/services/plugin/base.py+++ b/server/services/plugin/base.py@@ -127,6 +127,7 @@ class BaseNode:handles: ClassVar[Sequence[Dict[str, Any]]] = ()visibility: ClassVar[str] = "all"hide_output_handle: ClassVar[bool] = False+ hide_input_handle: ClassVar[bool] = Falseui_hints: ClassVar[Dict[str, Any]] = {}annotations: ClassVar[Dict[str, Any]] = {}@@ -156,6 +157,27 @@ class BaseNode:cls._operations = collect_operations(cls)if abstract or not cls.type:return+ # Auto-hide default canvas input/output handles for nodes whose+ # primary surface area is the LLM-tool call path. Two cases:+ # * Pure ToolNodes (component_kind="tool" -- calculator,+ # duckduckgoSearch, writeTodos, agentBuilder, ...). They+ # wire through their own output-tool handle; the hardcoded+ # SquareNode input-main + output-main are visual clutter.+ # * Dual-purpose ActionNodes with usable_as_tool=True (gmail,+ # twitter*, brave_search, all 16 android nodes via cascade,+ # code executors via cascade, ...). Same reasoning: the+ # LLM-tool path is the dominant use; default handles confuse+ # the canvas.+ # Subclasses opt out by explicitly setting either flag to False+ # on the class.+ is_tool_oriented = (+ cls.usable_as_tool or cls.component_kind == "tool"+ )+ if is_tool_oriented:+ if "hide_input_handle" not in cls.__dict__:+ cls.hide_input_handle = True+ if "hide_output_handle" not in cls.__dict__:+ cls.hide_output_handle = True# Eager registry write — same four registries as @register_node.from services.node_registry import register_node, register_node_classregister_node(@@ -201,6 +223,8 @@ class BaseNode:meta["credentials"] = [c.id for c in cls.credentials]if cls.hide_output_handle:meta["hideOutputHandle"] = True+ if cls.hide_input_handle:+ meta["hideInputHandle"] = Trueif cls.visibility != "all":meta["visibility"] = cls.visibilityui_hints = _derive_auto_ui_hints(cls.group)diff --git a/server/tests/test_node_spec.py b/server/tests/test_node_spec.pyindex 31ccc151..c793894a 100644--- a/server/tests/test_node_spec.py+++ b/server/tests/test_node_spec.py@@ -906,10 +906,26 @@ class TestPluginContractInvariants:def test_hide_output_handle_nodes_really_have_no_output(self):# If a node advertises hideOutputHandle=True, it shouldn't also# declare an output in its handles list — inconsistent.+ # Exception: tool-oriented nodes (component_kind="tool" pure+ # ToolNodes, or ActionNode + usable_as_tool=True dual-use nodes)+ # have hide_output_handle auto-derived True via+ # BaseNode.__init_subclass__. Their declared handles tuple still+ # carries output-tool / output-main for backend awareness, but+ # the SquareNode frontend suppresses the default render. The+ # invariant's original intent was "explicit author intent should+ # be consistent" — auto-derived is not author intent, so skip+ # those nodes.+ from services.node_registry import get_node_classfor t in self._plugin_types():spec = get_node_spec(t)if not spec.get("hideOutputHandle"):continue+ cls = get_node_class(t)+ if cls is not None and (+ getattr(cls, "usable_as_tool", False)+ or getattr(cls, "component_kind", "") == "tool"+ ):+ continueouts = [h for h in spec.get("handles") or [] if h.get("kind") == "output"]assert not outs, (f"{t}: hideOutputHandle=True but handles declares output(s) {outs}"