Skip to content

Self-improving AI Employees for everyone

perf(ui): cut universal canvas paint/recalc cost

trohitg2e1825d31401
diff --git a/client/src/Dashboard.tsx b/client/src/Dashboard.tsx
index 15859dad..9f6f0432 100644
--- a/client/src/Dashboard.tsx
+++ b/client/src/Dashboard.tsx
@@ -594,6 +594,11 @@ const DashboardContent: React.FC = () => {
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]);
+
// `.react-flow` is intentionally transparent so the parent
// `.canvas-host` / `.canvas` background-image (per-theme
// `--canvas-grid` + multi-layer gradient stack from
@@ -1197,7 +1202,7 @@ const DashboardContent: React.FC = () => {
return (
<>
- <style>{buildCanvasStyles(theme.colors)}</style>
+ <style>{canvasCss}</style>
{/* `app-frame` is the decorative-layer hook from the design handoff —
per-theme CSS files target this class for outer ornaments
(gilded corners under Renaissance, scanline overlay + corner
@@ -1319,6 +1324,7 @@ const DashboardContent: React.FC = () => {
nodesFocusable={!isCurrentWorkflowLocked}
elementsSelectable={!isCurrentWorkflowLocked}
selectNodesOnDrag={false}
+ onlyRenderVisibleElements={true}
selectionOnDrag={true}
selectionMode={SelectionMode.Partial}
selectionKeyCode="Control"
diff --git a/client/src/components/AIAgentNode.tsx b/client/src/components/AIAgentNode.tsx
index 3460f800..5a4032ed 100644
--- a/client/src/components/AIAgentNode.tsx
+++ b/client/src/components/AIAgentNode.tsx
@@ -127,7 +127,7 @@ const AIAgentNode: React.FC<NodeProps<NodeData>> = ({ id, type, data, isConnecta
fontWeight: theme.fontWeight.medium,
textAlign: 'center',
cursor: 'pointer',
- transition: 'all 0.3s ease',
+ transition: 'transform 0.3s ease, border-color 0.3s ease, opacity 0.3s ease',
overflow: 'visible',
display: 'flex',
flexDirection: 'column',
diff --git a/client/src/components/GenericNode.tsx b/client/src/components/GenericNode.tsx
index 97fc88c2..79788e2f 100644
--- a/client/src/components/GenericNode.tsx
+++ b/client/src/components/GenericNode.tsx
@@ -120,7 +120,7 @@ const GenericNode: React.FC<NodeProps<NodeData>> = ({ id, type, data, isConnecta
fontWeight: '600',
textAlign: 'center',
cursor: 'pointer',
- transition: 'all 0.2s ease',
+ transition: 'transform 0.2s ease, border-color 0.2s ease, opacity 0.2s ease',
overflow: 'visible',
opacity: isDisabled ? 0.5 : 1,
} as NodeStyle}
diff --git a/client/src/components/SquareNode.tsx b/client/src/components/SquareNode.tsx
index 582dd0b5..77af2aa6 100644
--- a/client/src/components/SquareNode.tsx
+++ b/client/src/components/SquareNode.tsx
@@ -285,7 +285,7 @@ const SquareNode: React.FC<NodeProps<NodeData>> = ({ id, type, data, isConnectab
color: theme.colors.text,
fontSize: theme.nodeSize.squareIcon,
fontWeight: '600',
- transition: 'all 0.2s ease',
+ transition: 'transform 0.2s ease, border-color 0.2s ease, opacity 0.2s ease',
opacity: isDisabled ? 0.5 : 1,
} as NodeStyle}
>
diff --git a/client/src/themes/base.css b/client/src/themes/base.css
index 3b50667c..79dec426 100644
--- a/client/src/themes/base.css
+++ b/client/src/themes/base.css
@@ -228,8 +228,7 @@ html[data-page-hidden] *::after {
box-shadow: 0 2px 8px color-mix(in srgb, var(--node-color, var(--node-shadow-base)) var(--tint-shadow), transparent);
transition:
transform var(--dur-fast) ease,
- border-color var(--dur-fast) ease,
- box-shadow var(--dur-fast) ease;
+ border-color var(--dur-fast) ease;
}
.node:hover {
@@ -281,8 +280,7 @@ html[data-page-hidden] *::after {
box-shadow: 0 2px 8px color-mix(in srgb, var(--node-color, var(--node-shadow-base)) var(--tint-shadow), transparent);
transition:
transform var(--dur-fast) ease,
- border-color var(--dur-fast) ease,
- box-shadow var(--dur-fast) ease;
+ border-color var(--dur-fast) ease;
}
.sq-node-box:hover {