Skip to content

Self-improving AI Employees for everyone

fix(canvas): light skill edges for the phase the server actually sends

trohitg8e00a7316b52
diff --git a/client/src/Dashboard.tsx b/client/src/Dashboard.tsx
index f4687259..db09c1cc 100644
--- a/client/src/Dashboard.tsx
+++ b/client/src/Dashboard.tsx
@@ -15,6 +15,7 @@ import {
} from 'reactflow';
import { featureFlags } from './lib/featureFlags';
import { deriveCanvasLock } from './lib/canvasLock';
+import { AGENT_PHASE } from './lib/agentPhases';
import { prefetchAllNodeSpecs, listCachedNodeSpecs, cachedNodeSpecTypesKey } from './lib/nodeSpec';
import AIAgentNode from './components/AIAgentNode';
import SquareNode from './components/SquareNode';
@@ -487,7 +488,7 @@ const DashboardContent: React.FC = () => {
// Skill connection highlights during skill loading phase (Zeenie)
// Skills provide context to LLM, so highlight only when loading skills
else if (isSkillConnection) {
- if (phase === 'loading_skills') {
+ if (phase === AGENT_PHASE.loadingSkill) {
className = 'skill-active';
}
}
diff --git a/client/src/components/AIAgentNode.tsx b/client/src/components/AIAgentNode.tsx
index 0e9889ca..0a1c6b74 100644
--- a/client/src/components/AIAgentNode.tsx
+++ b/client/src/components/AIAgentNode.tsx
@@ -7,6 +7,7 @@ import { useAppStore } from '../store/useAppStore';
import { useAppTheme } from '../hooks/useAppTheme';
import { useNodeStatus } from '../contexts/WebSocketContext';
import { useNodeSpec } from '../lib/nodeSpec';
+import { AGENT_PHASE } from '../lib/agentPhases';
import { NodeIcon } from '../assets/icons';
import { Badge } from '@/components/ui/badge';
import EditableNodeLabel from './ui/EditableNodeLabel';
@@ -25,8 +26,8 @@ const PHASE_CONFIG: Record<string, { icon: string; label: string; color: string
retry_wait: { icon: '⏳', label: 'Retrying automatically…', color: 'var(--warning)' },
executing_tool: { icon: '⚡', label: 'Using Tool', color: 'var(--node-trigger)' },
tool_completed: { icon: '✓', label: 'Tool Done', color: 'var(--success)' },
- loading_skill: { icon: '📚', label: 'Loading Skill', color: 'var(--node-agent)' },
- skill_loaded: { icon: '✓', label: 'Skill Loaded', color: 'var(--success)' },
+ [AGENT_PHASE.loadingSkill]: { icon: '📚', label: 'Loading Skill', color: 'var(--node-agent)' },
+ [AGENT_PHASE.skillLoaded]: { icon: '✓', label: 'Skill Loaded', color: 'var(--success)' },
saving_memory: { icon: '💾', label: 'Saving Memory', color: 'var(--node-agent)' },
};
diff --git a/client/src/contexts/WebSocketContext.tsx b/client/src/contexts/WebSocketContext.tsx
index 84cf6d73..513f42e9 100644
--- a/client/src/contexts/WebSocketContext.tsx
+++ b/client/src/contexts/WebSocketContext.tsx
@@ -32,6 +32,7 @@ import {
import { WS_CLOSE, WS_RECONNECT } from '../lib/connectionConfig';
import { startWebSocketHeartbeat } from '../lib/webSocketHeartbeat';
import { todoQueryKeyFromEvent } from '../lib/todoQuery';
+import { AGENT_PHASE } from '../lib/agentPhases';
import { useCanvasDockStore } from '../stores/canvasDockStore';
// Cycle note: lib/nodeSpec imports useWebSocket from this module. Safe in
// both evaluation orders because neither side calls the other's binding at
@@ -1508,7 +1509,7 @@ export const WebSocketProvider: React.FC<{ children: React.ReactNode }> = ({ chi
];
nextData = {
...nextData,
- phase: payload.state === 'loading' ? 'loading_skill' : 'skill_loaded',
+ phase: payload.state === 'loading' ? AGENT_PHASE.loadingSkill : AGENT_PHASE.skillLoaded,
active_skills: nextSkills,
last_capability: {
kind: 'skill',
diff --git a/client/src/lib/agentPhases.ts b/client/src/lib/agentPhases.ts
new file mode 100644
index 00000000..586ed9dc
--- /dev/null
+++ b/client/src/lib/agentPhases.ts
@@ -0,0 +1,14 @@
+/**
+ * Skill phases an agent node's status carries in `data.phase`.
+ *
+ * The backend sends them in `node_status` (server/services/skill_runtime.py),
+ * and WebSocketContext writes the same words when an `agent_capability` event
+ * reports a skill loading or loaded. Read and write them through these
+ * constants: the canvas once checked `loading_skills` while both writers sent
+ * `loading_skill`, so the skill edge never lit up.
+ * server/tests/test_agent_phase_names.py keeps them equal to the backend's.
+ */
+export const AGENT_PHASE = {
+ loadingSkill: 'loading_skill',
+ skillLoaded: 'skill_loaded',
+} as const;
diff --git a/server/services/skill_runtime.py b/server/services/skill_runtime.py
index 26d9382f..b8a62e09 100644
--- a/server/services/skill_runtime.py
+++ b/server/services/skill_runtime.py
@@ -13,6 +13,11 @@ logger = get_logger(__name__)
MAX_RESOURCE_CHARS = 16_000
MAX_SEARCH_MATCHES = 50
+# The agent node's `data.phase` while a skill loads and once it has. The
+# canvas reads the same words from client/src/lib/agentPhases.ts;
+# tests/test_agent_phase_names.py keeps the two equal.
+SKILL_LOADING_PHASE = "loading_skill"
+SKILL_LOADED_PHASE = "skill_loaded"
_loaded: Dict[Tuple[str, str, str, str], str] = {}
_turn_activity: Dict[Tuple[str, str, str], Dict[str, Dict[str, Any]]] = {}
@@ -149,7 +154,7 @@ async def _event(config: Dict[str, Any], descriptor: Dict[str, Any], action: str
public = [{k: v for k, v in item.items() if k != "master_skill_node_id"} for item in activities.values()]
broadcaster = get_status_broadcaster()
payload = {
- "phase": "loading_skill" if state == "loading" else "skill_loaded",
+ "phase": SKILL_LOADING_PHASE if state == "loading" else SKILL_LOADED_PHASE,
"active_skills": public,
"last_capability": {"kind": "skill", "name": name, "state": state},
}
diff --git a/server/tests/test_agent_phase_names.py b/server/tests/test_agent_phase_names.py
new file mode 100644
index 00000000..f7311ca5
--- /dev/null
+++ b/server/tests/test_agent_phase_names.py
@@ -0,0 +1,35 @@
+"""The skill phases the backend sends must be the words the canvas reads.
+
+``services/skill_runtime.py`` puts the phase in an agent node's
+``node_status`` data, and ``client/src/lib/agentPhases.ts`` is what the
+canvas compares it with. They drifted once: the editor checked
+``loading_skills`` while the backend sent ``loading_skill``, so the skill
+edge never lit up while a skill loaded.
+
+Cross-language, so it cannot be a type. This test reads the client file.
+"""
+
+from __future__ import annotations
+
+import re
+from pathlib import Path
+
+import pytest
+
+from services.skill_runtime import SKILL_LOADED_PHASE, SKILL_LOADING_PHASE
+
+pytestmark = pytest.mark.unit
+
+REPO_ROOT = Path(__file__).resolve().parents[2]
+AGENT_PHASES = REPO_ROOT / "client" / "src" / "lib" / "agentPhases.ts"
+
+
+def _client_phases() -> dict[str, str]:
+ source = AGENT_PHASES.read_text(encoding="utf-8")
+ return dict(re.findall(r"(\w+):\s*'([^']+)'", source))
+
+
+def test_the_client_reads_the_skill_phases_the_backend_sends():
+ phases = _client_phases()
+ assert phases.get("loadingSkill") == SKILL_LOADING_PHASE
+ assert phases.get("skillLoaded") == SKILL_LOADED_PHASE