Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

perf(canvas): memoise the wallpaper style object

iceclatterWTdd4bf6585537
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 0b769d498..ef971a6d3 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -1037,6 +1037,20 @@ export function Canvas() {
// Desktop wallpaper (Settings → Appearance): painted on the React Flow root, which is
// viewport-sized and never transformed, so it stays fixed while the canvas pans and zooms.
const wallpaperBg = useWallpaperBackground()
+ // Memoised: Canvas re-renders on every drag frame, and a fresh style object would make React
+ // re-diff (and a multi-MB data: URL re-compare) the root's style each time.
+ const wallpaperStyle = useMemo<React.CSSProperties | undefined>(
+ () =>
+ wallpaperBg
+ ? {
+ backgroundImage: wallpaperBg,
+ backgroundSize: 'cover',
+ backgroundPosition: 'center',
+ backgroundRepeat: 'no-repeat'
+ }
+ : undefined,
+ [wallpaperBg]
+ )
const [nodes, setNodes, onNodesChange] = useNodesState<CanvasNode>([])
// Persistent context links between Claude nodes (separate from ephemeral subagent/loop edges).
const [linkEdges, setLinkEdges, onLinkEdgesChange] = useEdgesState<Edge>([])
@@ -14801,16 +14815,7 @@ export function Canvas() {
<SessionProvider session={sessionForProject(activeProjectId || '')} key={sessionForProject(activeProjectId || '').id}>
<ReactFlow
className={wallpaperBg ? 'has-wallpaper' : undefined}
- style={
- wallpaperBg
- ? {
- backgroundImage: wallpaperBg,
- backgroundSize: 'cover',
- backgroundPosition: 'center',
- backgroundRepeat: 'no-repeat'
- }
- : undefined
- }
+ style={wallpaperStyle}
nodes={allNodes}
edges={displayEdges}
nodeTypes={nodeTypes}