Skip to content

Self-improving AI Employees for everyone

fix(canvas): make the dock width truly draggable in all states

trohitgfb64ca123670
diff --git a/client/src/components/parameterPanel/canvas/CanvasContent.tsx b/client/src/components/parameterPanel/canvas/CanvasContent.tsx
index 2a52b239..162d7a59 100644
--- a/client/src/components/parameterPanel/canvas/CanvasContent.tsx
+++ b/client/src/components/parameterPanel/canvas/CanvasContent.tsx
@@ -339,4 +339,28 @@ const CanvasContent: React.FC<Props> = ({
);
};
-export default CanvasContent;
+/**
+ * `React.memo` equality for the board renderer — the `nodePropsEqual`
+ * pattern (nodeMemoEquality.ts): compare only the props that affect the
+ * rendered output. The dock re-renders on every drag tick (widthPx) and on
+ * every broadcast-driven parent render during workflow runs; without this
+ * the whole board (markdown parse, JSON tree, iframes) re-reconciled per
+ * mousemove, which is what made the drag stutter while a workflow ran.
+ *
+ * Callback props (`onRemove` / `onFollowLatestChange`) are deliberately
+ * skipped, like `xPos`/`yPos` there: they are fresh closures each render
+ * over stable stores/mutations, and any change that makes them target a
+ * different board also changes `items`. Items compare element-wise so the
+ * dock's ephemeral single-item array stays equal across renders.
+ */
+function canvasContentPropsEqual(prev: Props, next: Props): boolean {
+ return (
+ prev.workflowId === next.workflowId &&
+ prev.followLatestDefault === next.followLatestDefault &&
+ prev.emptyHint === next.emptyHint &&
+ prev.items.length === next.items.length &&
+ prev.items.every((item, index) => item === next.items[index])
+ );
+}
+
+export default React.memo(CanvasContent, canvasContentPropsEqual);
diff --git a/client/src/components/ui/CanvasDock.tsx b/client/src/components/ui/CanvasDock.tsx
index f45de86d..be4ba020 100644
--- a/client/src/components/ui/CanvasDock.tsx
+++ b/client/src/components/ui/CanvasDock.tsx
@@ -85,10 +85,10 @@ const CanvasDock: React.FC<CanvasDockProps> = ({ nodes }) => {
cursor: 'ew-resize',
onMove: (deltaPx, startValue) => {
// The handle sits on the dock's LEFT edge — dragging left widens.
- const viewportCap = Math.min(
- DOCK_MAX_WIDTH,
- Math.round(window.innerWidth * 0.6),
- );
+ // Ceiling is viewport-relative and deliberately generous: the dock may
+ // take nearly the whole window; the 160px remainder keeps the handle
+ // and a sliver of canvas reachable to drag it back.
+ const viewportCap = Math.min(DOCK_MAX_WIDTH, window.innerWidth - 160);
setWidth(
Math.min(viewportCap, Math.max(DOCK_MIN_WIDTH, startValue - deltaPx)),
);
@@ -105,14 +105,25 @@ const CanvasDock: React.FC<CanvasDockProps> = ({ nodes }) => {
aria-hidden={!open}
>
<div
- className="h-full w-1.5 shrink-0 cursor-ew-resize bg-transparent hover:bg-bg-hover"
+ className={`h-full w-1.5 shrink-0 cursor-ew-resize transition-colors ${
+ resize.isResizing
+ ? 'bg-node-agent transition-none'
+ : 'bg-border hover:bg-node-agent-soft'
+ }`}
onMouseDown={resize.start}
role="separator"
aria-orientation="vertical"
aria-label="Resize canvas panel"
/>
- <div className="flex min-h-0 min-w-0 flex-1 flex-col">
+ {/* pointer-events-none while dragging: an embedded iframe (web/PDF
+ items) would otherwise swallow the document mousemove and freeze
+ the resize the moment the cursor crosses it. */}
+ <div
+ className={`flex min-h-0 min-w-0 flex-1 flex-col ${
+ resize.isResizing ? 'pointer-events-none' : ''
+ }`}
+ >
<div className="flex shrink-0 items-center gap-2 border-b border-border-default px-3 py-2">
<Monitor className="h-4 w-4 shrink-0 text-fg-muted" />
<span className="shrink-0 text-sm font-semibold text-fg-default">Canvas</span>
diff --git a/client/src/stores/__tests__/canvasDockStore.test.ts b/client/src/stores/__tests__/canvasDockStore.test.ts
index ac3d881b..4ef42ae7 100644
--- a/client/src/stores/__tests__/canvasDockStore.test.ts
+++ b/client/src/stores/__tests__/canvasDockStore.test.ts
@@ -70,7 +70,7 @@ describe('canvasDockStore prefs', () => {
it('persists open/width/autoOpen/followMode and clamps width', () => {
useCanvasDockStore.getState().setWidth(5000);
- expect(useCanvasDockStore.getState().widthPx).toBe(1200);
+ expect(useCanvasDockStore.getState().widthPx).toBe(4000);
useCanvasDockStore.getState().setWidth(10);
expect(useCanvasDockStore.getState().widthPx).toBe(280);
diff --git a/client/src/stores/canvasDockStore.ts b/client/src/stores/canvasDockStore.ts
index cd3afab1..5f077907 100644
--- a/client/src/stores/canvasDockStore.ts
+++ b/client/src/stores/canvasDockStore.ts
@@ -19,7 +19,7 @@ import type { CanvasItem } from '../lib/canvasBoard';
const dockPrefsSchema = z.object({
open: z.boolean().default(false),
- widthPx: z.number().min(280).max(1200).default(380),
+ widthPx: z.number().min(280).max(4000).default(380),
autoOpen: z.boolean().default(true),
followMode: z.boolean().default(false),
});
@@ -27,7 +27,10 @@ type CanvasDockPrefs = z.infer<typeof dockPrefsSchema>;
const DOCK_PREFS_KEY = 'canvas_dock_prefs_v1';
export const DOCK_MIN_WIDTH = 280;
-export const DOCK_MAX_WIDTH = 1200;
+// Sanity bound for persisted/corrupt values only — NOT a UX limit. The live
+// ceiling while dragging is viewport-relative (CanvasDock's onMove), so the
+// dock can take nearly the whole window.
+export const DOCK_MAX_WIDTH = 4000;
function loadDockPrefs(): CanvasDockPrefs {
try {
diff --git a/docs-internal/canvas_node.md b/docs-internal/canvas_node.md
index 63242d93..1c599770 100644
--- a/docs-internal/canvas_node.md
+++ b/docs-internal/canvas_node.md
@@ -243,8 +243,10 @@ prefix `['canvasBoard']` for broadcast-driven invalidation.
- **[`CanvasDock.tsx`](../client/src/components/ui/CanvasDock.tsx)** — the
new docked surface, mounted as the last flex child of Dashboard's
main-content row (rightmost edge). Left-edge drag handle via the shared
- `usePanelResize` (dragging left widens; clamped 280–1200 px and ≤ 60 % of
- the viewport), `transition-[width]` disabled while dragging. Header: node
+ `usePanelResize` (dragging left widens; floor 280 px, ceiling nearly the
+ full window — `innerWidth - 160` so the handle stays reachable, with a
+ 4000 px sanity bound on persisted values), `transition-[width]` disabled
+ while dragging. Header: node
selector (a Select when the workflow has more than one Canvas node —
ConsolePanel's node-selector precedent; nodes are found by
`resolveNodeDescription(type)?.uiHints?.isCanvasPanel`, never by the type