Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat(canvas): migrate edges to the design-handoff step contract
trohitg68aa738663b6
diff --git a/client/src/Dashboard.tsx b/client/src/Dashboard.tsxindex 3dbd430e..8c9e4a66 100644--- a/client/src/Dashboard.tsx+++ b/client/src/Dashboard.tsx@@ -11,6 +11,7 @@ import {ConnectionMode,ConnectionLineType,SelectionMode,+ StepEdge,Node,Edge,} from 'reactflow';@@ -67,6 +68,11 @@ import { importWorkflowFromFile } from './utils/workflowExport';import type { ValidationIssue } from './hooks/useWorkflowValidation';import { buildCanvasStyles } from './styles/canvasAnimations';+// Static stylesheet: fully token-driven (var(--edge-*) + semantic+// tokens), so it is built once at module scope — theme switches restyle+// it via CSS variable resolution, never a rebuild.+const canvasCss = buildCanvasStyles();+/** Wire shape returned by the backend ``import_workflow`` WS handler.* Mirrors ``services.workflow_import.import_workflow`` — flat optional* fields rather than a discriminated union, since callers branch on@@ -146,6 +152,12 @@ const createNodeTypes = (): Record<string, React.ComponentType<any>> => {// canvas node when prefetch lands (the "canvas-wide snap" symptom).const moduleEdgeTypes = {conditional: ConditionalEdge,+ // Design-handoff edge contract: every default edge renders as the+ // orthogonal step edge. Persisted workflows (incl. the shipped example+ // seeds) carry `type: 'smoothstep'` from the pre-step era, so the+ // built-in name is remapped to React Flow's StepEdge renderer — no+ // data migration needed; stored graphs and exports stay byte-stable.+ smoothstep: StepEdge,};const initialNodes: Node[] = [];@@ -689,22 +701,15 @@ const DashboardContent: React.FC = () => {});}, [edges, nodeStatuses, isExecuting, isCurrentWorkflowDeployed, nodes]);- // Memoize ReactFlow options to prevent unnecessary re-renders+ // Memoize ReactFlow options to prevent unnecessary re-renders.+ // No inline `style` / connectionLineStyle: edge visuals (stroke,+ // width, dash) are owned entirely by the theme tokens in+ // themes/base.css via the static stylesheet from canvasAnimations.ts,+ // which also styles the in-progress .react-flow__connection-path.const defaultEdgeOptions = React.useMemo(() => ({- type: 'smoothstep',- animated: true,- style: { stroke: theme.dracula.cyan, strokeWidth: 3 },- }), [theme.dracula.cyan]);-- const connectionLineStyle = React.useMemo(() => ({- stroke: theme.dracula.cyan,- strokeWidth: 2- }), [theme.dracula.cyan]);-- // Memoize the injected canvas <style> so the stylesheet isn't- // regenerated + re-parsed (a full-document style recalc) on every- // Dashboard render — only when the theme palette actually changes.- const canvasCss = React.useMemo(() => buildCanvasStyles(theme.colors), [theme.colors]);+ type: 'step',+ animated: false,+ }), []);// `.react-flow` is intentionally transparent so the parent// `.canvas-host` / `.canvas` background-image (per-theme@@ -1373,7 +1378,7 @@ const DashboardContent: React.FC = () => {height: '100vh',display: 'flex',flexDirection: 'column',- fontFamily: 'system-ui, sans-serif',+ fontFamily: 'var(--font-body)',}}>{/* Top Toolbar */}<TopToolbar@@ -1495,8 +1500,7 @@ const DashboardContent: React.FC = () => {preventScrolling={true}proOptions={proOptions}defaultEdgeOptions={defaultEdgeOptions}- connectionLineStyle={connectionLineStyle}- connectionLineType={ConnectionLineType.SmoothStep}+ connectionLineType={ConnectionLineType.Step}snapToGrid={true}snapGrid={snapGrid}style={reactFlowStyle}diff --git a/client/src/components/ConditionalEdge.tsx b/client/src/components/ConditionalEdge.tsxindex c9aa4944..6711e4b4 100644--- a/client/src/components/ConditionalEdge.tsx+++ b/client/src/components/ConditionalEdge.tsx@@ -42,10 +42,12 @@ const ConditionalEdge: React.FC<ConditionalEdgeProps> = ({}) => {const [isEditorOpen, setIsEditorOpen] = useState(false);+ // borderRadius 0 = right-angle corners, matching the design-handoff+ // `step` contract the default edges follow via `type: 'step'`.const [edgePath, labelX, labelY] = getSmoothStepPath({sourceX, sourceY, sourcePosition,targetX, targetY, targetPosition,- borderRadius: 10,+ borderRadius: 0,});const hasCondition = !!data?.condition;@@ -67,7 +69,11 @@ const ConditionalEdge: React.FC<ConditionalEdgeProps> = ({return (<>- {/* BaseEdge stroke is the React Flow API contract — must be inline. */}+ {/* BaseEdge stroke is the React Flow API contract — must be inline.+ Values are theme tokens only (base.css --edge-* block): a+ condition-carrying edge highlights in the accent; without a+ condition every property stays undefined so the resting rule+ from canvasAnimations.ts applies. */}<BaseEdgeid={id}path={edgePath}@@ -75,8 +81,8 @@ const ConditionalEdge: React.FC<ConditionalEdgeProps> = ({style={{...style,stroke: hasCondition ? 'var(--accent)' : undefined,- strokeWidth: hasCondition ? 2 : undefined,- strokeDasharray: hasCondition ? '5 3' : undefined,+ strokeWidth: hasCondition ? 'var(--edge-stroke-width-done)' : undefined,+ strokeDasharray: hasCondition ? 'var(--edge-dash)' : undefined,}}/>diff --git a/client/src/hooks/useAppTheme.ts b/client/src/hooks/useAppTheme.tsindex 1eee789e..e3918855 100644--- a/client/src/hooks/useAppTheme.ts+++ b/client/src/hooks/useAppTheme.ts@@ -7,8 +7,11 @@* Renaissance / Greek / Edo / Steampunk / Atomic / Cyber / Wasteland* / Rot / Plague / Surveillance the base pack (light or dark, picked* by `DARK_FAMILY`) gets a small overlay of theme-specific accents- * (primary, edges, action colours) so canvas selection rings, edge- * strokes, and action button colours match the theme's identity.+ * (primary, action colours) so canvas selection rings and action+ * button colours match the theme's identity. Canvas EDGE strokes are+ * no longer part of this pack — the design-handoff edge migration+ * moved them to CSS tokens (--edge-stroke + semantic status recolors+ * in styles/canvasAnimations.ts); do not reintroduce edge* keys here.** This is the production realisation of MIGRATION_PLAYBOOK Wave 1 —* the upstream playbook proposes a full per-theme NodePack record;@@ -50,12 +53,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#b8893c', // goldactionStop: '#8a1410', // crimsonactionSave: '#d4a030', // gold leaf- edgeDefault: '#5a3a14', // ink brown- edgeSelected: '#d4a030', // gold- edgeCompleted: '#4a6818',- edgeError: '#8a1410',- edgeMemoryActive: '#b8893c',- edgeToolActive: '#c08020',},greek: {@@ -66,12 +63,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#284b82', // lapisactionStop: '#7a1a18', // oxbloodactionSave: '#c8a040', // gold- edgeDefault: '#4a3818', // dark stone- edgeSelected: '#284b82',- edgeCompleted: '#6a7a32',- edgeError: '#7a1a18',- edgeMemoryActive: '#284b82',- edgeToolActive: '#c8a040',},edo: {@@ -82,12 +73,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#b41e1e',actionStop: '#b41e1e',actionSave: '#1a1410', // sumi- edgeDefault: '#1a1410',- edgeSelected: '#b41e1e',- edgeCompleted: '#4a6a3a',- edgeError: '#b41e1e',- edgeMemoryActive: '#b41e1e',- edgeToolActive: '#c89832',},steampunk: {@@ -98,12 +83,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#d8a848',actionStop: '#8a3a1a', // rustactionSave: '#b8602a', // copper- edgeDefault: '#b88838',- edgeSelected: '#d8a848',- edgeCompleted: '#6a8a3a',- edgeError: '#8a3a1a',- edgeMemoryActive: '#b8602a',- edgeToolActive: '#d8a848',},atomic: {@@ -114,12 +93,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#e85a26',actionStop: '#e85a26',actionSave: '#3a9aa0', // turquoise- edgeDefault: '#2a3a4a', // slate- edgeSelected: '#e85a26',- edgeCompleted: '#5a8a5a',- edgeError: '#e85a26',- edgeMemoryActive: '#3a9aa0',- edgeToolActive: '#d8a838', // mustard},cyber: {@@ -130,12 +103,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#f51eb6',actionStop: '#ff2050',actionSave: '#1dd9e5',- edgeDefault: '#f51eb6',- edgeSelected: '#1dd9e5',- edgeCompleted: '#26d97a',- edgeError: '#ff2050',- edgeMemoryActive: '#f51eb6',- edgeToolActive: '#ffd028', // neon yellow},wasteland: {@@ -146,12 +113,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#e88a28',actionStop: '#b8281a', // rust redactionSave: '#c8d038', // radioactive- edgeDefault: '#8a3a18',- edgeSelected: '#e88a28',- edgeCompleted: '#8a9028',- edgeError: '#b8281a',- edgeMemoryActive: '#e88a28',- edgeToolActive: '#c8d038',},rot: {@@ -162,12 +123,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#e8a838', // candleflameactionStop: '#a83838',actionSave: '#e8a838',- edgeDefault: '#4a6a4a',- edgeSelected: '#78c878',- edgeCompleted: '#78c878',- edgeError: '#a83838',- edgeMemoryActive: '#e8a838',- edgeToolActive: '#5898b8',},plague: {@@ -178,12 +133,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#783c28',actionStop: '#783c28',actionSave: '#98a838', // bile- edgeDefault: '#2a1c14',- edgeSelected: '#783c28',- edgeCompleted: '#5a7028',- edgeError: '#783c28',- edgeMemoryActive: '#98a838',- edgeToolActive: '#4a5868',},surveillance: {@@ -194,12 +143,6 @@ const THEME_OVERRIDES: Partial<Record<ThemeName, ColorOverride>> = {actionDeploy: '#e82626',actionStop: '#e82626',actionSave: '#6acc6a',- edgeDefault: '#5a5e62',- edgeSelected: '#e82626',- edgeCompleted: '#6acc6a',- edgeError: '#e82626',- edgeMemoryActive: '#e82626',- edgeToolActive: '#5a8cc8',},};diff --git a/client/src/styles/canvasAnimations.ts b/client/src/styles/canvasAnimations.tsindex 6f690577..78b3cf62 100644--- a/client/src/styles/canvasAnimations.ts+++ b/client/src/styles/canvasAnimations.ts@@ -3,39 +3,33 @@* Dashboard. Split into named groups so a new status visual or keyframe* can be added without touching Dashboard.tsx.*- * KEYFRAMES -- @keyframes definitions for edges- * edgeStatusStyles(...) -- .react-flow__edge.{selected,executing,...}- * nodeStatusStyles(...) -- .react-flow__node.{...} (status-class colors only)- * buildCanvasStyles(...) -- composes the three for Dashboard+ * KEYFRAMES -- @keyframes definitions for edges+ * EDGE_STATUS_STYLES -- .react-flow__edge.{selected,executing,...}+ * buildCanvasStyles() -- composes the groups for Dashboard*- * Per-node inline animations (border pulse, etc.) live in their own- * components and read theme tokens directly; this module is for- * canvas-wide rules that need to match React Flow's wrapper classes.+ * Fully static since the design-handoff edge migration: every color,+ * width, and dash rhythm is a theme token (var(--edge-*) + semantic+ * color tokens, declared in themes/base.css), so this module knows+ * nothing about which theme is active and Dashboard injects it once at+ * module scope. The old CanvasStatusColors parameter object (per-theme+ * hex fed from useAppTheme) is gone -- do not reintroduce it; add a+ * token instead.*- * Node execution glow is owned by `client/src/themes/base.css` — see- * the `node-pulse` keyframe + `.react-flow__node.executing .node` /- * `.sq-node[data-executing] .sq-node-box` rules there. This file used- * to inject a competing `nodeGlow` keyframe targeting the React Flow- * wrapper; that was dead code (only the inner `.node` child animated)- * and has been removed in favour of base.css as the single source of- * truth.+ * Resting edges follow the design-handoff contract: one pale neutral+ * stroke (--edge-stroke), dashed (--edge-dash), thin+ * (--edge-stroke-width). Status classes recolor with SEMANTIC tokens so+ * execution feedback survives in every theme. No !important on the+ * resting rule (nothing competes once Dashboard stopped inlining a+ * stroke); status rules keep !important so they beat the resting rule+ * and ConditionalEdge's inline conditional-accent styling during runs.+ * The in-progress connection line (.react-flow__connection-path) is+ * styled here too -- Dashboard passes no connectionLineStyle prop.*- * The light vs dark distinction is encoded entirely in `colors` (the- * theme object provides different values per mode), so this file knows- * nothing about which theme is active.+ * Node execution glow is owned by `client/src/themes/base.css` -- see+ * the `node-pulse` keyframe + `.react-flow__node.executing .node` /+ * `.sq-node[data-executing] .sq-node-box` rules there.*/-export interface CanvasStatusColors {- edgeDefault: string;- edgeSelected: string;- edgeExecuting: string;- edgeCompleted: string;- edgeError: string;- edgePending: string;- edgeMemoryActive: string;- edgeToolActive: string;-}-const KEYFRAMES = `@keyframes dashFlow {0% { stroke-dashoffset: 24; }@@ -43,71 +37,67 @@ const KEYFRAMES = `}`;-function edgeStatusStyles(colors: CanvasStatusColors): string {- return `- .react-flow__edge path {- stroke: ${colors.edgeDefault} !important;- stroke-width: 2px;+const EDGE_STATUS_STYLES = `+ .react-flow__edge path,+ .react-flow__connection-path {+ stroke: var(--edge-stroke);+ stroke-width: var(--edge-stroke-width);+ stroke-dasharray: var(--edge-dash);+ stroke-linejoin: round;}.react-flow__edge.selected path {- stroke: ${colors.edgeSelected} !important;- stroke-width: 4px !important;+ stroke: var(--accent) !important;+ stroke-width: var(--edge-stroke-width-active) !important;}.react-flow__edge.executing path {- stroke: ${colors.edgeExecuting} !important;- stroke-width: 3px !important;- stroke-dasharray: 8 4;+ stroke: var(--node-pulse-color) !important;+ stroke-width: var(--edge-stroke-width-active) !important;+ stroke-dasharray: var(--edge-dash-active);animation: dashFlow 0.5s linear infinite;}.react-flow__edge.completed path {- stroke: ${colors.edgeCompleted} !important;- stroke-width: 2px !important;+ stroke: var(--success) !important;+ stroke-width: var(--edge-stroke-width-done) !important;}.react-flow__edge.error path {- stroke: ${colors.edgeError} !important;- stroke-width: 3px !important;+ stroke: var(--destructive) !important;+ stroke-width: var(--edge-stroke-width-active) !important;}.react-flow__edge.pending path {- stroke: ${colors.edgePending} !important;- stroke-width: 2px !important;- stroke-dasharray: 8 4;+ stroke: var(--fg-muted) !important;+ stroke-width: var(--edge-stroke-width-done) !important;+ stroke-dasharray: var(--edge-dash-active);animation: dashFlow 0.5s linear infinite;}.react-flow__edge.memory-active path {- stroke: ${colors.edgeMemoryActive} !important;- stroke-width: 3px !important;+ stroke: var(--node-agent) !important;+ stroke-width: var(--edge-stroke-width-active) !important;}.react-flow__edge.tool-active path {- stroke: ${colors.edgeToolActive} !important;- stroke-width: 3px !important;+ stroke: var(--node-tool) !important;+ stroke-width: var(--edge-stroke-width-active) !important;}-`;-}-function nodeStatusStyles(_colors: CanvasStatusColors): string {- // Node execution animation is owned by base.css (`node-pulse`- // keyframe + `.react-flow__node.executing .node` /- // `.sq-node[data-executing] .sq-node-box` rules). This function is- // retained as a hook for future canvas-wide status-class rules on- // the React Flow wrapper that don't fit per-component CSS.- //- // `_colors` is intentionally unused at the moment; the parameter is- // kept on the signature so callers (buildCanvasStyles) and the- // CanvasStatusColors contract stay stable for downstream consumers.- return '';-}+ .react-flow__edge.skill-active path {+ stroke: var(--node-skill) !important;+ stroke-width: var(--edge-stroke-width-active) !important;+ }++ @media (prefers-reduced-motion: reduce) {+ .react-flow__edge.executing path,+ .react-flow__edge.pending path {+ animation: none !important;+ }+ }+`;-export function buildCanvasStyles(colors: CanvasStatusColors): string {- return [- edgeStatusStyles(colors),- nodeStatusStyles(colors),- KEYFRAMES,- ].join('\n');+export function buildCanvasStyles(): string {+ return [EDGE_STATUS_STYLES, KEYFRAMES].join('\n');}diff --git a/client/src/styles/theme.ts b/client/src/styles/theme.tsindex e4d9546e..22d29906 100644--- a/client/src/styles/theme.ts+++ b/client/src/styles/theme.ts@@ -4,12 +4,16 @@// SCOPE (post-Wave-14):// - `lightColors` / `darkColors` are the two BASE PACKS. The 10-way// `THEME_OVERRIDES` map in `client/src/hooks/useAppTheme.ts` merges-// a per-theme overlay (primary, focus, action palette, edge stroke-// palette) on top of whichever base pack matches the active theme's-// dark / light family — see `theme_system.md` for the contract.+// a per-theme overlay (primary, focus, action palette) on top of+// whichever base pack matches the active theme's dark / light+// family — see `theme_system.md` for the contract. Canvas edge+// strokes are NOT part of the packs anymore: the design-handoff+// edge migration moved them to CSS tokens (--edge-stroke in+// themes/base.css + semantic status recolors in+// styles/canvasAnimations.ts).// - `dracula` / `solarized` raw palette constants stay for cases a-// Tailwind class can't express: SVG `fill=`, React Flow JS edge-// styles, prismjs token CSS strings, GoogleMaps SDK JS-side colors.+// Tailwind class can't express: SVG `fill=`, prismjs token CSS+// strings, GoogleMaps SDK JS-side colors.// - `spacing` / `fontSize` / `fontWeight` / `nodeSize` / `iconSize` /// `buttonSize` / `layout` / `transitions` / `constants` stay too —// these are not color tokens; they back the canvas-animation engine@@ -125,15 +129,6 @@ export const lightColors = {actionPalette: '#7c3aed', // VioletstatusSaved: '#059669', // Emerald-600statusModified: '#d97706', // Amber-600- // Edge colors for light mode - MUCH darker for visibility- edgeDefault: '#6b7280', // gray-500 - much more visible- edgeSelected: '#7c3aed', // Violet- edgeExecuting: '#2563eb', // Blue-600 (executing state pop)- edgeCompleted: '#16a34a', // Green-600- edgeError: '#dc2626', // Red-600- edgePending: '#6b7280', // gray-500 (same as default, dashed)- edgeMemoryActive: '#db2777', // Pink-600- edgeToolActive: '#ea580c', // Orange-600// Category colors for light mode (darker, more saturated)categoryWorkflow: '#ea580c', // Orange-600categoryTrigger: '#db2777', // Pink-600@@ -199,15 +194,6 @@ export const darkColors = {actionPalette: dracula.purple, // #bd93f9 - purplestatusSaved: dracula.green, // #50fa7b - greenstatusModified: dracula.orange, // #ffb86c - orange- // Edge colors for dark mode- edgeDefault: dracula.cyan, // Cyan- edgeSelected: dracula.purple, // Purple- edgeExecuting: dracula.purple, // Purple (executing state pop)- edgeCompleted: dracula.green, // Green- edgeError: dracula.red, // Red- edgePending: dracula.cyan, // Cyan (same as default, dashed)- edgeMemoryActive: dracula.pink, // Pink- edgeToolActive: dracula.orange, // Orange// Category colors for dark mode (Dracula - vibrant)categoryWorkflow: dracula.orange,categoryTrigger: dracula.pink,