Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Storyboards: wire the panel maker recipe on a desktop canvas (#12922)
[._.]/eabe623244eb
diff --git a/client/src/components/graphCanvas/GraphCanvas.jsx b/client/src/components/graphCanvas/GraphCanvas.jsxindex eaa91dda06..f8e1ec5068 100644--- a/client/src/components/graphCanvas/GraphCanvas.jsx+++ b/client/src/components/graphCanvas/GraphCanvas.jsx@@ -18,6 +18,12 @@* The SVG keeps its canvas-unit `viewBox` and scales its pixel size, so* positions and `onMove` coordinates stay in canvas units at any zoom.*+ * Wiring (`onConnect`): a card element marked `data-port-out` starts a wire+ * drag (any pointer, since it begins on an explicit handle); releasing over an+ * element marked `data-port-in="<port>"` inside another card calls+ * `onConnect(fromId, toId, port)`. The draft wire is drawn by `renderWireDraft`+ * (canvas-unit start and end points) so the caller keeps its edge styling.+ ** Touch never drags a card (it would fight scrolling), and `canDragNodes={false}`* turns card drags off entirely — a stacked phone layout's coordinates must* not persist as desktop positions; its cards are pannable surface instead.@@ -61,7 +67,7 @@ export default function GraphCanvas({renderDefs, renderEdges, renderNode, renderNodeHtml, htmlInset,nodeLabel, nodeClassName,ariaLabel, surfaceProps = {}, surfaceClassName = '',- zoomControls = true, children,+ zoomControls = true, children, onConnect, renderWireDraft,}) {const dragRef = useRef(null);const draggedRef = useRef(false);@@ -74,6 +80,7 @@ export default function GraphCanvas({const htmlRefs = useRef(new Map());const measureRef = useRef(null);const [zoom, setZoom] = useState(1);+ const [wire, setWire] = useState(null);const zoomRef = useRef(zoom);zoomRef.current = zoom;@@ -129,8 +136,42 @@ export default function GraphCanvas({return () => surface.removeEventListener('wheel', onWheel);});+ // Client px → canvas units, through the surface's scroll and the zoom.+ const toCanvas = (event) => {+ const surface = measureRef.current;+ const rect = surface.getBoundingClientRect();+ const z = zoomRef.current;+ return { x: (event.clientX - rect.left + surface.scrollLeft) / z, y: (event.clientY - rect.top + surface.scrollTop) / z };+ };++ const startWire = (event, node) => {+ event.stopPropagation();+ event.preventDefault();+ const from = toCanvas(event);+ setWire({ fromId: node.id, from, to: from });+ const onMoveWire = (e) => setWire((w) => (w ? { ...w, to: toCanvas(e) } : w));+ const onUpWire = (e) => {+ window.removeEventListener('pointermove', onMoveWire);+ window.removeEventListener('pointerup', onUpWire);+ window.removeEventListener('pointercancel', onUpWire);+ setWire(null);+ draggedRef.current = true;+ if (e.type !== 'pointerup') return;+ const target = document.elementFromPoint?.(e.clientX, e.clientY)?.closest?.('[data-port-in]');+ const toId = target?.closest('[data-node-id]')?.getAttribute('data-node-id');+ if (toId && toId !== node.id) onConnect(node.id, toId, target.getAttribute('data-port-in'));+ };+ window.addEventListener('pointermove', onMoveWire);+ window.addEventListener('pointerup', onUpWire);+ window.addEventListener('pointercancel', onUpWire);+ };+const handlePointerDown = (event, node) => {if (event.button !== 0) return;+ if (onConnect && event.target?.closest?.('[data-port-out]')) {+ startWire(event, node);+ return;+ }if (event.pointerType !== 'mouse' || !canDragNodes || !onMove) return;event.currentTarget.setPointerCapture(event.pointerId);const origin = positions[node.id] || { x: 0, y: 0 };@@ -212,6 +253,7 @@ export default function GraphCanvas({>{renderDefs && <defs>{renderDefs()}</defs>}<g>{renderEdges?.()}</g>+ {wire && renderWireDraft && <g pointerEvents="none">{renderWireDraft(wire.from, wire.to)}</g>}<g>{nodes.map((node) => {const pos = positions[node.id];diff --git a/client/src/components/graphCanvas/GraphCanvas.test.jsx b/client/src/components/graphCanvas/GraphCanvas.test.jsxindex 1da8d98d2b..89421df7cc 100644--- a/client/src/components/graphCanvas/GraphCanvas.test.jsx+++ b/client/src/components/graphCanvas/GraphCanvas.test.jsx@@ -86,4 +86,38 @@ describe('GraphCanvas', () => {fireEvent.pointerUp(card, { pointerId: 2, pointerType: 'mouse' });expect(onMove).not.toHaveBeenCalled();});++ it('wires an output dot to another card\'s input when the drag is released over it', () => {+ const onConnect = vi.fn();+ const onSelect = vi.fn();+ renderCanvas({+ onConnect,+ onSelect,+ renderNode: (node) => (+ <>+ <rect width={160} height={80} />+ <circle data-port-out="true" data-testid={`out-${node.id}`} cx={160} cy={20} r={8} />+ <g data-port-in="prompt"><circle data-testid={`in-${node.id}`} cx={0} cy={50} r={7} /></g>+ </>+ ),+ renderWireDraft: () => <path data-testid="wire-draft" />,+ });+ fireEvent.pointerDown(screen.getByTestId('out-a'), { button: 0, pointerId: 1, pointerType: 'mouse', clientX: 180, clientY: 40 });+ fireEvent.pointerMove(window, { clientX: 250, clientY: 60 });+ expect(screen.getByTestId('wire-draft')).toBeInTheDocument();++ const target = screen.getByTestId('in-b');+ const original = document.elementFromPoint;+ document.elementFromPoint = () => target;+ try {+ fireEvent.pointerUp(window, { clientX: 300, clientY: 70 });+ } finally {+ document.elementFromPoint = original;+ }+ expect(onConnect).toHaveBeenCalledWith('a', 'b', 'prompt');+ expect(screen.queryByTestId('wire-draft')).toBeNull();+ // The click that ends the wire drag doesn't also select the card.+ fireEvent.click(screen.getByLabelText('Node: Alpha'));+ expect(onSelect).not.toHaveBeenCalled();+ });});diff --git a/client/src/components/storyboards/PanelDrawer.jsx b/client/src/components/storyboards/PanelDrawer.jsxindex 6049e9fb8f..853bda6a35 100644--- a/client/src/components/storyboards/PanelDrawer.jsx+++ b/client/src/components/storyboards/PanelDrawer.jsx@@ -1,4 +1,5 @@import { useEffect, useMemo, useState } from 'react';+import { useSearchParams } from 'react-router';import {ChevronLeft, ChevronRight, Clapperboard, Drama, ImagePlus, Loader2, Mountain, Package, Palette, PenLine, Plus,StickyNote, Trash2, Users, Wand2, X,@@ -283,6 +284,9 @@ function CastTab({ panel, onPatch }) {*/export default function PanelDrawer({ open, board, found, panelNumber, sketchNonce, busy, onClose, handlers }) {const [activeTab, setActiveTab] = useDrawerTab('panelTab', 'shot', TAB_IDS);+ const [searchParams] = useSearchParams();+ // The recipe canvas (desktop) needs the room; every other tab stays a column.+ const wide = activeTab === 'make' && searchParams.get('makeView') === 'canvas';return (<Drawer@@ -290,7 +294,7 @@ export default function PanelDrawer({ open, board, found, panelNumber, sketchNononClose={onClose}title={found ? `Panel ${panelNumber}` : 'Panel'}subtitle={found ? (found.beat.title || `Beat ${found.beatIndex + 1}`) : undefined}- size="md"+ size={wide ? 'xl' : 'md'}tabs={found ? TABS : null}activeTab={activeTab}onTabChange={setActiveTab}diff --git a/client/src/components/storyboards/PanelMakeTab.jsx b/client/src/components/storyboards/PanelMakeTab.jsxindex 939bfae162..d49673fcc4 100644--- a/client/src/components/storyboards/PanelMakeTab.jsx+++ b/client/src/components/storyboards/PanelMakeTab.jsx@@ -12,7 +12,10 @@ import {effectiveRecipe, nodeInputValue, panelNodeState, RECIPE_LIMITS, RECIPE_NODE_PORTS, RECIPE_PORT_LABELS, RECIPE_TYPE_TITLES,recipeRunOrder, textNodeValue, upstreamNode,} from '../../../../server/lib/storyboardRecipe.js';+import TabPills from '../ui/TabPills';+import useUrlParams from '../../hooks/useUrlParams';import CommitField from './CommitField';+import RecipeCanvas from './RecipeCanvas';import RecipeNodeCard, { NODE_ICONS } from './RecipeNodeCard';import { takeSrc } from './storyboardArt';@@ -29,6 +32,7 @@ const ADDABLE = [{ type: 'panel', title: 'Panel' },];const RUNNABLE = new Set(['llm', 'image']);+const VIEW_TABS = [{ id: 'chain', label: 'Chain' }, { id: 'canvas', label: 'Canvas' }];const reaches = (edges, start, target) => {const stack = [start];@@ -99,6 +103,9 @@ export default function PanelMakeTab({ board, found, sketchNonce, handlers }) {const [pickingRefsFor, setPickingRefsFor] = useState(null);const [adding, setAdding] = useState(false);const [confirmReset, setConfirmReset] = useState(false);+ const [searchParams, updateParams] = useUrlParams();+ const canvas = searchParams.get('makeView') === 'canvas';+ const selectedNode = recipe.nodes.find((n) => n.id === searchParams.get('node')) || null;const linkKey = [...panel.castIds, ...panel.environmentIds, ...panel.objectIds].join(',');useEffect(() => {@@ -123,6 +130,15 @@ export default function PanelMakeTab({ board, found, sketchNonce, handlers }) {...recipe,edges: [...recipe.edges.filter((e) => !(e.to === node.id && e.toPort === port)), ...(fromId ? [{ from: fromId, to: node.id, toPort: port }] : [])],});+ // A canvas wire: the dropped-on input must take the output's kind, and a+ // wire that would close a cycle is refused so the input keeps its old wire.+ const connect = (fromId, toId, port) => {+ const from = recipe.nodes.find((n) => n.id === fromId);+ const to = recipe.nodes.find((n) => n.id === toId);+ if (!from || !to || RECIPE_NODE_PORTS[to.type].inputs[port] !== RECIPE_NODE_PORTS[from.type].output) return;+ if (reaches(recipe.edges.filter((e) => !(e.to === toId && e.toPort === port)), toId, fromId)) return;+ wire(to)(port, fromId);+ };const duplicate = (node) => {const copy = { ...structuredClone(node), id: newStoryboardEntityId('node'), title: `${node.title} copy`.slice(0, RECIPE_LIMITS.title), x: node.x + 40, y: node.y + 40 };const inbound = recipe.edges.filter((e) => e.to === node.id).map((e) => ({ ...e, to: copy.id }));@@ -316,6 +332,26 @@ export default function PanelMakeTab({ board, found, sketchNonce, handlers }) {return title;};+ const nodeCard = (node) => {+ const state = panelNodeState(panel, node.id);+ return (+ <RecipeNodeCard+ key={node.id}+ node={node}+ status={state.status}+ running={runningId === node.id}+ canRun={RUNNABLE.has(node.type)}+ runLabel={node.type === 'image' ? `Make ${node.settings.count} frame${node.settings.count === 1 ? '' : 's'}` : 'Run'}+ onRun={() => run(node)}+ onDuplicate={() => duplicate(node)}+ onDelete={() => remove(node)}+ settings={settingsFor(node)}+ >+ {bodyFor(node)}+ </RecipeNodeCard>+ );+ };+return (<div className="space-y-3"><div className="flex flex-wrap items-center gap-2">@@ -334,25 +370,25 @@ export default function PanelMakeTab({ board, found, sketchNonce, handlers }) {onConfirm={() => { setConfirmReset(false); saveRecipe(null); }} onCancel={() => setConfirmReset(false)} />)}<p className="text-[11px] text-gray-500">The recipe is shared by every panel on this board. Each node runs only when you tap it.</p>- {order.map((node) => {- const state = panelNodeState(panel, node.id);- return (- <RecipeNodeCard- key={node.id}- node={node}- status={state.status}- running={runningId === node.id}- canRun={RUNNABLE.has(node.type)}- runLabel={node.type === 'image' ? `Make ${node.settings.count} frame${node.settings.count === 1 ? '' : 's'}` : 'Run'}- onRun={() => run(node)}- onDuplicate={() => duplicate(node)}- onDelete={() => remove(node)}- settings={settingsFor(node)}- >- {bodyFor(node)}- </RecipeNodeCard>- );- })}+ <div className="hidden lg:block">+ <TabPills tabs={VIEW_TABS} activeTab={canvas ? 'canvas' : 'chain'} variant="pills" size="sm" ariaLabel="Recipe view"+ onChange={(next) => updateParams({ makeView: next === 'canvas' ? 'canvas' : null }, { replace: true })} />+ </div>+ {canvas ? (+ <>+ <div className="h-[420px]">+ <RecipeCanvas+ recipe={recipe}+ statusOf={(nodeId) => panelNodeState(panel, nodeId).status}+ selectedId={selectedNode?.id || null}+ onSelect={(nodeId) => updateParams({ node: nodeId }, { replace: true })}+ onMove={(nodeId, pos) => editNode(nodeId, pos)}+ onConnect={connect}+ />+ </div>+ {selectedNode ? nodeCard(selectedNode) : <p className="text-xs text-gray-500">Tap a node to open it here. Drag from a node's blue dot to an input to wire it.</p>}+ </>+ ) : order.map(nodeCard)}{adding ? (<div className="rounded-xl border border-dashed border-port-border p-2"><p className="text-[11px] text-gray-500 mb-1">Add a node</p>diff --git a/client/src/components/storyboards/RecipeCanvas.jsx b/client/src/components/storyboards/RecipeCanvas.jsxnew file mode 100644index 0000000000..6e42c2364b--- /dev/null+++ b/client/src/components/storyboards/RecipeCanvas.jsx@@ -0,0 +1,84 @@+import GraphCanvas from '../graphCanvas/GraphCanvas';+import { RECIPE_NODE_PORTS, RECIPE_PORT_LABELS } from '../../../../server/lib/storyboardRecipe.js';++export const RECIPE_NODE_W = 200;+const HEADER_H = 40;+const PORT_GAP = 24;+const nodeHeight = (node) => HEADER_H + Math.max(1, Object.keys(RECIPE_NODE_PORTS[node.type].inputs).length) * PORT_GAP + 12;+const inputY = (index) => HEADER_H + index * PORT_GAP + PORT_GAP / 2;+const NODE_H = Math.max(...Object.keys(RECIPE_NODE_PORTS).map((type) => nodeHeight({ type })));++const STATUS_FILL = { running: 'fill-port-warning', queued: 'fill-port-warning', done: 'fill-port-success', failed: 'fill-port-error' };++const curve = (a, b) => {+ const dx = Math.max(40, Math.abs(b.x - a.x) / 2);+ return `M ${a.x} ${a.y} C ${a.x + dx} ${a.y}, ${b.x - dx} ${b.y}, ${b.x} ${b.y}`;+};++/**+ * The desktop recipe canvas: nodes where the recipe placed them, wires as+ * curves from an output (right edge) to an input (left edge). Drag a card to+ * move it, drag from an output dot to an input dot to wire it, tap a card to+ * open it below. Selection is the caller's (`?node=` in the URL).+ */+export default function RecipeCanvas({ recipe, statusOf, selectedId, onSelect, onMove, onConnect }) {+ const positions = Object.fromEntries(recipe.nodes.map((n) => [n.id, { x: n.x, y: n.y }]));+ const width = Math.max(800, ...recipe.nodes.map((n) => n.x + RECIPE_NODE_W + 80));+ const height = Math.max(420, ...recipe.nodes.map((n) => n.y + NODE_H + 80));+ const byId = new Map(recipe.nodes.map((n) => [n.id, n]));++ const outPoint = (node) => ({ x: node.x + RECIPE_NODE_W, y: node.y + HEADER_H / 2 });+ const inPoint = (node, port) => {+ const index = Object.keys(RECIPE_NODE_PORTS[node.type].inputs).indexOf(port);+ return { x: node.x, y: node.y + inputY(Math.max(0, index)) };+ };++ return (+ <GraphCanvas+ width={width}+ height={height}+ nodes={recipe.nodes}+ positions={positions}+ nodeW={RECIPE_NODE_W}+ nodeH={NODE_H}+ selectedId={selectedId}+ onSelect={onSelect}+ onMove={onMove}+ onConnect={onConnect}+ ariaLabel="Recipe canvas"+ nodeLabel={(node) => `${node.title} (${node.type})`}+ surfaceClassName="rounded-lg border border-port-border bg-port-bg"+ renderEdges={() => recipe.edges.map((edge) => {+ const from = byId.get(edge.from);+ const to = byId.get(edge.to);+ if (!from || !to) return null;+ return <path key={`${edge.from}-${edge.to}-${edge.toPort}`} d={curve(outPoint(from), inPoint(to, edge.toPort))} fill="none" strokeWidth={2} className="stroke-port-border" />;+ })}+ renderWireDraft={(a, b) => <path d={curve(a, b)} fill="none" strokeWidth={2} strokeDasharray="6 4" className="stroke-port-accent" />}+ renderNode={(node, { selected }) => {+ const inputs = Object.keys(RECIPE_NODE_PORTS[node.type].inputs);+ const h = nodeHeight(node);+ const fill = STATUS_FILL[statusOf(node.id)];+ return (+ <>+ <rect width={RECIPE_NODE_W} height={h} rx={10} strokeWidth={selected ? 2 : 1} className={`fill-port-card ${selected ? 'stroke-port-accent' : 'stroke-port-border'}`} />+ <text x={12} y={25} fontSize={13} fontWeight={600} className="fill-port-text">{node.title.length > 22 ? `${node.title.slice(0, 21)}…` : node.title}</text>+ {fill && <circle cx={RECIPE_NODE_W - 24} cy={HEADER_H / 2} r={4} className={fill} />}+ {inputs.map((port, index) => (+ <g key={port} data-port-in={port}>+ <circle cx={0} cy={inputY(index)} r={7} strokeWidth={1.5} className="fill-port-bg stroke-port-text-muted" />+ <text x={14} y={inputY(index) + 4} fontSize={11} className="fill-port-text-muted">{RECIPE_PORT_LABELS[port]}</text>+ </g>+ ))}+ {!inputs.length && <text x={12} y={inputY(0) + 4} fontSize={11} className="fill-port-text-muted">{node.type === 'references' ? 'Images' : 'Text'}</text>}+ {RECIPE_NODE_PORTS[node.type].output && (+ <circle data-port-out="true" cx={RECIPE_NODE_W} cy={HEADER_H / 2} r={8} strokeWidth={1.5} className="fill-port-accent stroke-port-bg cursor-crosshair">+ <title>Drag to an input to wire it</title>+ </circle>+ )}+ </>+ );+ }}+ />+ );+}diff --git a/client/src/pages/StoryboardDetail.test.jsx b/client/src/pages/StoryboardDetail.test.jsxindex 0f575d320d..d3f62c9014 100644--- a/client/src/pages/StoryboardDetail.test.jsx+++ b/client/src/pages/StoryboardDetail.test.jsx@@ -150,4 +150,54 @@ describe('StoryboardDetail', () => {// The copy keeps the original's inputs.expect(recipe.edges.filter((e) => e.to === copy.id).map((e) => e.toPort).sort()).toEqual(['images', 'prompt']);});++ it('opens the recipe canvas at its deep link and selects a node into the URL', async () => {+ api.getStoryboard.mockResolvedValue(board());+ renderAt('/storyboards/sb-1/panel/panel-1?panelTab=make&makeView=canvas&node=node-image');+ expect(await screen.findByRole('region', { name: 'Image node' })).toBeInTheDocument();+ expect(screen.queryByRole('region', { name: 'Prompt writer node' })).toBeNull();++ fireEvent.click(screen.getByRole('button', { name: 'Prompt writer (llm)' }));+ await waitFor(() => expect(screen.getByTestId('location').textContent).toContain('node=node-writer'));+ expect(await screen.findByRole('region', { name: 'Prompt writer node' })).toBeInTheDocument();+ });++ it('refuses a canvas wire that would close a cycle, keeping the input wired', async () => {+ const recipe = {+ nodes: [+ { id: 'node-a', type: 'text', title: 'Words', settings: { source: 'custom' }, text: 'Rain', x: 0, y: 0 },+ { id: 'node-b', type: 'llm', title: 'First', settings: {}, x: 260, y: 0 },+ { id: 'node-c', type: 'llm', title: 'Second', settings: {}, x: 520, y: 0 },+ ],+ edges: [{ from: 'node-a', to: 'node-b', toPort: 'prompt' }, { from: 'node-b', to: 'node-c', toPort: 'prompt' }],+ };+ api.getStoryboard.mockResolvedValue(board({ recipe }));+ api.updateStoryboardRecipe.mockImplementation(async (_id, next) => board({ recipe: next, updatedAt: '2026-10-22T00:00:03.000Z' }));+ renderAt('/storyboards/sb-1/panel/panel-1?panelTab=make&makeView=canvas');+ await screen.findByRole('button', { name: 'Second (llm)' });++ const dropWire = (fromId, toId, port) => {+ const out = document.querySelector(`[data-node-id="${fromId}"] [data-port-out]`);+ const input = document.querySelector(`[data-node-id="${toId}"] [data-port-in="${port}"] circle`);+ fireEvent.pointerDown(out, { button: 0, pointerId: 1, pointerType: 'mouse', clientX: 10, clientY: 10 });+ fireEvent.pointerMove(window, { clientX: 40, clientY: 40 });+ const original = document.elementFromPoint;+ document.elementFromPoint = () => input;+ try {+ fireEvent.pointerUp(window, { clientX: 50, clientY: 50 });+ } finally {+ document.elementFromPoint = original;+ }+ };++ dropWire('node-c', 'node-b', 'prompt');+ expect(api.updateStoryboardRecipe).not.toHaveBeenCalled();++ dropWire('node-a', 'node-c', 'prompt');+ await waitFor(() => expect(api.updateStoryboardRecipe).toHaveBeenCalledTimes(1));+ expect(api.updateStoryboardRecipe.mock.calls[0][1].edges).toEqual([+ { from: 'node-a', to: 'node-b', toPort: 'prompt' },+ { from: 'node-a', to: 'node-c', toPort: 'prompt' },+ ]);+ });});