From 71805d4a7b9549290edd089c9d1563c343368a3a Mon Sep 17 00:00:00 2001
From: zheng1114567
Date: Thu, 19 Nov 2026 18:12:19 +0800
Subject: [PATCH] feat(flow): resize designer cards with a MiniMax-style
eight-handle frame
Cards were fixed at 244px wide, so a 100% canvas only fit a handful of
steps. Cards now default to 200px and a selected card shows the same
resize frame MiniMax Design uses (React Flow's NodeResizer): four round
corner handles plus four edge strips, sized in screen pixels so they stay
constant while the canvas zooms. Corners move both edges, sides move one,
clamping to 180-480px wide and 96-640px tall while pinning the opposite
edge. Tall cards spend the extra room on the node's own detail (role
brief, script body, nested steps, approval ask) instead of whitespace;
untouched cards keep their content-driven height and the footprint
persists with the workflow. Layout heuristics and drop/AI camera centering
use the new default width.
---
internal/domain/workflow.go | 9 +++
web/app/flow-canvas.css | 32 +++++++--
web/app/flow-palette.js | 2 +-
web/app/flow-viewport.js | 3 +-
web/app/flows.js | 93 +++++++++++++++++++++++--
web/orchestrate.js | 2 +-
webtest/tests/flow-node-resize.test.mjs | 62 +++++++++++++++++
7 files changed, 188 insertions(+), 15 deletions(-)
create mode 100644 webtest/tests/flow-node-resize.test.mjs
diff --git a/internal/domain/workflow.go b/internal/domain/workflow.go
index 59175e633..cbef998c3 100644
--- a/internal/domain/workflow.go
+++ b/internal/domain/workflow.go
@@ -77,6 +77,15 @@ type WorkflowNode struct {
MaxReworks int `json:"maxReworks"`
Notifications []NodeNotification `json:"notifications,omitempty"`
Position Position `json:"position"`
+ // Size is the canvas card footprint chosen by the designer. Height is
+ // omitted until the designer fixes it; width falls back to the default.
+ Size *NodeSize `json:"size,omitempty"`
+}
+
+// NodeSize is the designer-adjusted card footprint.
+type NodeSize struct {
+ W float64 `json:"w"`
+ H float64 `json:"h,omitempty"`
}
// ValidateWorkflowMetricStages prevents silently dropping a mistyped stage.
diff --git a/web/app/flow-canvas.css b/web/app/flow-canvas.css
index 32ba62c74..bfade7649 100644
--- a/web/app/flow-canvas.css
+++ b/web/app/flow-canvas.css
@@ -196,15 +196,15 @@ html[data-theme="dark"] #flowView{
#flowView .fd-canvas.check-hidden{display:none}
/* nodes */
-#flowView .flow-node.fd-node{--tint:var(--fd-accent);position:absolute;width:244px;min-height:0;padding:0;border:1px solid var(--fd-line-2);border-radius:12px;background:var(--fd-surface);box-shadow:var(--fd-shadow-sm);color:var(--fd-ink);cursor:grab;user-select:none;transition:box-shadow .15s,border-color .15s}
+#flowView .flow-node.fd-node{--tint:var(--fd-accent);position:absolute;display:flex;flex-direction:column;width:200px;min-height:0;padding:0;border:1px solid var(--fd-line-2);border-radius:12px;background:var(--fd-surface);box-shadow:var(--fd-shadow-sm);color:var(--fd-ink);cursor:grab;user-select:none;transition:box-shadow .15s,border-color .15s}
#flowView .flow-node.fd-node:hover{border-color:rgb(var(--tint) / .55);box-shadow:var(--fd-shadow)}
-#flowView .flow-node.fd-node.sel{border-color:rgb(var(--fd-accent));box-shadow:0 0 0 3px rgb(var(--fd-accent) / .16),var(--fd-shadow)}
+#flowView .flow-node.fd-node.sel{border-color:rgb(var(--fd-accent));box-shadow:0 0 0 1px rgb(var(--fd-accent) / .3),var(--fd-shadow)}
#flowView .flow-node.fd-node.dragging{cursor:grabbing;box-shadow:var(--fd-shadow-lg);z-index:30!important}
#flowView .flow-node.fd-node.connecting{border-color:rgb(var(--fd-accent))}
#flowView .flow-node.fd-node.drop-ok{border-color:rgb(var(--fd-ok));box-shadow:0 0 0 3px rgb(var(--fd-ok) / .2)}
#flowView .flow-node.fd-node.drop-bad{border-color:rgb(var(--fd-rj));box-shadow:0 0 0 3px rgb(var(--fd-rj) / .16);cursor:not-allowed}
#flowView .flow-node.fd-node::before{content:"";position:absolute;left:-1px;top:12px;bottom:12px;width:3px;border-radius:0 3px 3px 0;background:rgb(var(--tint))}
-#flowView .fd-nh{display:flex;align-items:center;gap:10px;padding:11px 10px 8px 13px}
+#flowView .fd-nh{display:flex;align-items:center;gap:10px;padding:11px 10px 8px 13px;flex:none}
#flowView .fd-nt{flex:1;min-width:0}
#flowView .fd-node .node-title{font-size:13.5px;font-weight:600;color:var(--fd-ink);line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#flowView .fd-node .node-subtitle{margin-top:2px;font-size:11.5px;color:var(--fd-ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@@ -212,6 +212,20 @@ html[data-theme="dark"] #flowView{
#flowView .fd-more{display:grid;place-items:center;width:24px;height:24px;padding:0;border:0;border-radius:6px;background:none;color:var(--fd-ink-4);cursor:pointer;opacity:0;transition:opacity .12s,background .12s}
#flowView .fd-node:hover .fd-more,#flowView .fd-node.sel .fd-more{opacity:1}
#flowView .fd-more:hover{background:var(--fd-hover);color:var(--fd-ink)}
+/* Resize frame, modelled on MiniMax Design's canvas: a selected card shows
+ four round corner handles and four edge hit strips. Sizes divide by the
+ canvas zoom so the handles keep a constant on-screen size. */
+#flowView .fd-rz{position:absolute;z-index:5;background:transparent}
+#flowView .fd-rz.corner{width:calc(10px / var(--fd-zoom,1));height:calc(10px / var(--fd-zoom,1));border-radius:50%;background:var(--fd-surface);border:calc(1.5px / var(--fd-zoom,1)) solid rgb(var(--fd-accent));box-shadow:0 1px 2px rgba(15,23,42,.18)}
+#flowView .fd-rz.corner.nw{left:0;top:0;transform:translate(-50%,-50%);cursor:nwse-resize}
+#flowView .fd-rz.corner.ne{left:100%;top:0;transform:translate(-50%,-50%);cursor:nesw-resize}
+#flowView .fd-rz.corner.sw{left:0;top:100%;transform:translate(-50%,-50%);cursor:nesw-resize}
+#flowView .fd-rz.corner.se{left:100%;top:100%;transform:translate(-50%,-50%);cursor:nwse-resize}
+#flowView .fd-rz.edge.n{left:calc(12px / var(--fd-zoom,1));right:calc(12px / var(--fd-zoom,1));top:calc(-4px / var(--fd-zoom,1));height:calc(8px / var(--fd-zoom,1));cursor:ns-resize}
+#flowView .fd-rz.edge.s{left:calc(12px / var(--fd-zoom,1));right:calc(12px / var(--fd-zoom,1));bottom:calc(-4px / var(--fd-zoom,1));height:calc(8px / var(--fd-zoom,1));cursor:ns-resize}
+#flowView .fd-rz.edge.w{top:calc(12px / var(--fd-zoom,1));bottom:calc(12px / var(--fd-zoom,1));left:calc(-4px / var(--fd-zoom,1));width:calc(8px / var(--fd-zoom,1));cursor:ew-resize}
+#flowView .fd-rz.edge.e{top:calc(12px / var(--fd-zoom,1));bottom:calc(12px / var(--fd-zoom,1));right:calc(-4px / var(--fd-zoom,1));width:calc(8px / var(--fd-zoom,1));cursor:ew-resize}
+#flowView .flow-node.fd-node.resizing{transition:none}
#flowView .fd-status{flex:none;padding:2px 6px;border-radius:5px;font-size:10.5px;font-weight:600;background:var(--fd-soft);color:var(--fd-ink-3)}
#flowView .fd-status.s-running{background:rgb(var(--fd-accent) / .12);color:rgb(var(--fd-accent))}
#flowView .fd-status.s-succeeded{background:rgb(var(--fd-ok) / .12);color:rgb(var(--fd-ok))}
@@ -219,12 +233,20 @@ html[data-theme="dark"] #flowView{
#flowView .fd-status.s-waiting_approval{background:rgb(var(--fd-warn) / .14);color:rgb(var(--fd-warn))}
#flowView .fd-node.s-running{border-color:rgb(var(--fd-accent) / .7)}
#flowView .fd-node.s-failed{border-color:rgb(var(--fd-rj) / .7)}
-#flowView .fd-nbody{display:flex;flex-wrap:wrap;gap:4px;padding:0 12px 9px 13px}
+#flowView .fd-nbody{display:flex;flex-direction:column;gap:6px;padding:0 12px 9px 13px;flex:1 1 auto;min-height:0;overflow:auto}
+#flowView .fd-tags{display:flex;flex-wrap:wrap;gap:4px;flex:none}
+#flowView .fd-detail{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;gap:6px;color:var(--fd-ink-3);font-size:11.5px;line-height:1.5}
+#flowView .fd-detail-text{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}
+#flowView .fd-detail-script{margin:0;padding:6px 8px;border-radius:8px;background:var(--fd-soft);color:var(--fd-ink-2);font:10.5px/1.55 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere}
+#flowView .fd-detail-line{display:flex;align-items:baseline;gap:6px;flex-wrap:wrap}
+#flowView .fd-detail-line b{font-weight:600;color:var(--fd-ink-3);flex:none}
+#flowView .fd-detail-line code{font:10.5px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;padding:1px 5px;border-radius:4px;background:var(--fd-soft);color:var(--fd-ink-2);overflow-wrap:anywhere}
+#flowView .fd-detail-steps{margin:0;padding-left:16px;display:flex;flex-direction:column;gap:2px}
#flowView .fd-tag{display:inline-block;max-width:100%;height:20px;padding:0 7px;border-radius:5px;background:var(--fd-soft);color:var(--fd-ink-3);font-size:11px;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#flowView .fd-tag.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px}
#flowView .fd-tag.warn{background:rgb(var(--fd-warn) / .12);color:rgb(var(--fd-warn))}
#flowView .fd-tag.soft{background:transparent;border:1px solid var(--fd-line)}
-#flowView .fd-outs{display:flex;flex-direction:column;border-top:1px solid var(--fd-line)}
+#flowView .fd-outs{display:flex;flex-direction:column;border-top:1px solid var(--fd-line);flex:none;margin-top:auto}
#flowView .fd-out{position:relative;display:flex;align-items:center;justify-content:flex-end;height:24px;padding:0 16px 0 12px;font-size:11px;color:var(--fd-ink-4)}
#flowView .fd-out+.fd-out{border-top:1px dashed var(--fd-line)}
#flowView .fd-out.ok::before,#flowView .fd-out.rj::before{content:"";width:6px;height:6px;border-radius:50%;margin-right:6px}
diff --git a/web/app/flow-palette.js b/web/app/flow-palette.js
index 631a915e0..ab73ddf73 100644
--- a/web/app/flow-palette.js
+++ b/web/app/flow-palette.js
@@ -104,7 +104,7 @@ const flowPalette=(()=>{
e.preventDefault();
let item;try{item=JSON.parse(raw)}catch{return}
const w=flowViewport.toWorld(e.clientX,e.clientY);
- addNode(item.type,{agentId:item.agentId,at:{x:w.x-122,y:w.y-28}});
+ addNode(item.type,{agentId:item.agentId,at:{x:w.x-100,y:w.y-28}});
});
}
function bind(){
diff --git a/web/app/flow-viewport.js b/web/app/flow-viewport.js
index 2be96fef0..8439e89c5 100644
--- a/web/app/flow-viewport.js
+++ b/web/app/flow-viewport.js
@@ -1,7 +1,7 @@
// Pan/zoom viewport for the flow designer canvas. Node positions stay in
// logical canvas coordinates; only #canvasStage is transformed.
const flowViewport=(()=>{
- const MIN=.25,MAX=2,GRID=18,NODE_W=244,NODE_H=132,PAL_W=256,PAL_MINI=48,MINIMAP_KEY='agentflow.flowMinimap';
+ const MIN=.25,MAX=2,GRID=18,NODE_W=200,NODE_H=132,PAL_W=256,PAL_MINI=48,MINIMAP_KEY='agentflow.flowMinimap';
const vp={x:40,y:40,zoom:1};
let fittedId=null,autoCollapsed=false,animTimer=0,bound=false,onBlankClick=null,minimapRaf=0;
const byId=id=>document.getElementById(id);
@@ -12,6 +12,7 @@ const flowViewport=(()=>{
const stage=byId('canvasStage'),c=canvas();if(!stage||!c)return;
stage.classList.toggle('anim',!!anim);
stage.style.transform=`translate(${vp.x}px,${vp.y}px) scale(${vp.zoom})`;
+ c.style.setProperty('--fd-zoom',vp.zoom);
const g=GRID*vp.zoom;c.style.backgroundSize=`${g}px ${g}px`;c.style.backgroundPosition=`${vp.x}px ${vp.y}px`;
const zv=byId('canvasZoomValue');if(zv)zv.textContent=Math.round(vp.zoom*100)+'%';
scheduleMinimap();
diff --git a/web/app/flows.js b/web/app/flows.js
index a52efd57c..db8162af8 100644
--- a/web/app/flows.js
+++ b/web/app/flows.js
@@ -254,17 +254,18 @@ function arrange(){
flowToast('已按依赖层级整理画布',{undo:true});
}
// Layouts saved for the narrower legacy node, or templates on a 240px column
-// pitch, overlap the 244px node: the overlap hides the ports, so no reject
+// pitch, overlap the 200px node: the overlap hides the ports, so no reject
// route can be drawn. Rows/columns that are that crowded are widened
// proportionally in memory; a later save keeps it. Diagonal or far-off
// overlaps are left to the user (and "整理").
-const FLOW_SPREAD={w:244,h:132,pitchW:280,pitchH:160,maxFactor:1.6};
+const FLOW_NODE_W=200,FLOW_NODE_H=132,FLOW_RESIZE_MIN_W=180,FLOW_RESIZE_MAX_W=480,FLOW_RESIZE_MIN_H=96,FLOW_RESIZE_MAX_H=640,FLOW_DETAIL_MIN_H=200;
+const FLOW_SPREAD={w:FLOW_NODE_W,h:FLOW_NODE_H,pitchW:280,pitchH:160,maxFactor:1.6};
function spreadCrowdedNodes(wf){
const nodes=(wf?.nodes||[]).filter(n=>n.position&&Number.isFinite(n.position.x)&&Number.isFinite(n.position.y));
let minDx=Infinity,minDy=Infinity;
for(let i=0;i=1&&dx=1&&dx=1&&dy${escapeHTML(brief)}
`);
+ const arts=effectiveNodeArtifacts(n,agent).filter(a=>a.name||a.path);
+ if(arts.length)rows.push(`产物${arts.map(a=>`${escapeHTML(a.path||a.name)}`).join('')}
`);
+ if(agent?.loop?.enabled)rows.push(`循环${agent.loop.maxIterations||1} 轮
`);
+ return rows.join('');
+ }
+ if(kind==='script'){
+ const code=String(n.script||'').trim();
+ return code?`${escapeHTML(code)}`:'';
+ }
+ if(kind==='sop'){
+ const wf=sopWorkflowChoices().find(w=>w.id===n.sopWorkflowId)||(state.data.workflows||[]).find(w=>w.id===n.sopWorkflowId);
+ const steps=(wf?.nodes||[]).map(step=>step.name||step.id).filter(Boolean);
+ return steps.length?`${steps.map(step=>`- ${escapeHTML(step)}
`).join('')}
`:'';
+ }
+ if(kind==='approval'){const ask=String(n.taskPrompt||'').trim();return ask?`${escapeHTML(ask)}
`:''}
+ return '';
+}
function flowNodeHTML(n,run,ro){
- const m=nodeMeta(n),kind=m.kind,status=run?.nodes?.[n.id]?.status||'';
+ const m=nodeMeta(n),kind=m.kind,status=run?.nodes?.[n.id]?.status||'',size=flowNodeSize(n);
const agent=kind==='agent'?workflowAgent(n.agentId):null;
const tile=agent?escapeHTML(flowPalette.initial(agent.name)):flowPalette.icon(FLOW_NODE_TYPES[kind].icon,16);
const title=state.renamingNode===n.id?``:escapeHTML(n.name);
const cls=['flow-node','fd-node','t-'+kind,state.selectedNode===n.id?'sel':'',state.connectFrom===n.id?'connecting':'',status?'s-'+status:'',kind==='preview'?'preview-build':''].filter(Boolean).join(' ');
const tags=m.tags.map(t=>`${escapeHTML(t.text)}`).join('');
+ const detail=size.h&&size.h>=FLOW_DETAIL_MIN_H?flowNodeDetailHTML(n,kind,agent):'';
const outs=`成功
`+(kind==='preview'?'':`失败打回
`);
- return `${tile}${title}
${escapeHTML(m.subtitle)}
${status?`
${statusText(status)||escapeHTML(status)}`:''}${ro?'':`
`}
${tags}
${outs}
`;
+ const rz=ro||state.selectedNode!==n.id?'':['nw','ne','sw','se','n','s','w','e'].map(d=>``).join('');
+ return `${tile}${title}
${escapeHTML(m.subtitle)}
${status?`
${statusText(status)||escapeHTML(status)}`:''}${ro?'':`
`}
${tags}
${detail?`
${detail}
`:''}
${outs}
${rz}
`;
}
function renderCanvas(){
const nodes=$('#nodes');if(!nodes)return;
@@ -339,7 +388,7 @@ function renderCanvas(){
function bindFlowNode(el){
const n=state.workflow.nodes.find(x=>x.id===el.dataset.id);if(!n)return;
el.addEventListener('pointerdown',e=>{
- if(e.button!==0||e.target.closest('.fd-port,.fd-more,input'))return;
+ if(e.button!==0||e.target.closest('.fd-port,.fd-more,.fd-rz,input'))return;
e.stopPropagation();closeNodeMenu();
if(state.connectFrom&&state.connectFrom!==n.id){completeFlowConnect(n);return}
const sx=e.clientX,sy=e.clientY,start={x:n.position.x,y:n.position.y},ro=flowReadOnly();
@@ -361,10 +410,40 @@ function bindFlowNode(el){
el.addEventListener('pointermove',move);el.addEventListener('pointerup',up);el.addEventListener('pointercancel',up);
});
el.addEventListener('dblclick',e=>{if(!e.target.closest('input'))openNodeDrawer(n.id)});
+ el.querySelectorAll('[data-resize]').forEach(handle=>handle.addEventListener('pointerdown',e=>resizeFlowNode(e,el,n,handle.dataset.resize)));
el.querySelector('[data-node-menu]')?.addEventListener('click',e=>{e.stopPropagation();openNodeMenu(n.id,e.currentTarget)});
el.querySelectorAll('.fd-port.out').forEach(port=>port.addEventListener('pointerdown',e=>startFlowConnect(e,n,port.dataset.outlet)));
el.querySelector('.fd-port.in')?.addEventListener('pointerdown',e=>{if(state.connectFrom&&state.connectFrom!==n.id){e.stopPropagation();completeFlowConnect(n)}});
}
+// Eight-handle resize frame (MiniMax-style): corners move both edges, sides
+// move one. The opposite edge stays put when a size hits its limits.
+function resizeFlowNode(e,el,n,dir){
+ if(e.button!==0||flowReadOnly())return;
+ e.stopPropagation();e.preventDefault();
+ const size=flowNodeSize(n),start={w:size.w,h:size.h??el.offsetHeight,x:n.position.x,y:n.position.y};
+ const sx=e.clientX,sy=e.clientY,cursor=getComputedStyle(e.currentTarget).cursor;let resized=false;
+ flowHistory.record();
+ el.setPointerCapture(e.pointerId);
+ const move=ev=>{
+ const dx=(ev.clientX-sx)/flowViewport.zoom,dy=(ev.clientY-sy)/flowViewport.zoom;
+ if(!resized&&Math.abs(dx)<1&&Math.abs(dy)<1)return;
+ if(!resized){resized=true;el.classList.add('resizing');document.body.style.cursor=cursor}
+ const movesW=dir.includes('w'),movesE=dir.includes('e'),movesN=dir.includes('n'),movesS=dir.includes('s');
+ let w=start.w+(movesE?dx:0)-(movesW?dx:0);
+ let h=start.h+(movesS?dy:0)-(movesN?dy:0);
+ w=Math.min(FLOW_RESIZE_MAX_W,Math.max(FLOW_RESIZE_MIN_W,w));
+ h=Math.min(FLOW_RESIZE_MAX_H,Math.max(FLOW_RESIZE_MIN_H,h));
+ n.position={x:Math.round(movesW?start.x+start.w-w:start.x),y:Math.round(movesN?start.y+start.h-h:start.y)};
+ el.style.left=n.position.x+'px';el.style.top=n.position.y+'px';
+ setFlowNodeSize(n,w,movesN||movesS?h:undefined);
+ };
+ const up=()=>{
+ el.removeEventListener('pointermove',move);el.removeEventListener('pointerup',up);el.removeEventListener('pointercancel',up);
+ document.body.style.cursor='';el.classList.remove('resizing');
+ if(resized){renderEdges();dirty()}
+ };
+ el.addEventListener('pointermove',move);el.addEventListener('pointerup',up);el.addEventListener('pointercancel',up);
+}
function startNodeRename(id){
if(flowReadOnly()||!state.workflow?.nodes.some(n=>n.id===id))return;
state.renamingNode=id;renderCanvas();
@@ -495,7 +574,7 @@ function flowNodeMetrics(id){
cache.set(id,m);return m;
}
function nodeBox(n){
- const m=flowNodeMetrics(n.id),w=m?.w||244,h=m?.h||132;
+ const m=flowNodeMetrics(n.id),w=m?.w||FLOW_NODE_W,h=m?.h||FLOW_NODE_H;
return {x:n.position.x,y:n.position.y,w,h,cx:n.position.x+w/2,cy:n.position.y+h/2,right:n.position.x+w,left:n.position.x,top:n.position.y,bottom:n.position.y+h};
}
function flowPortPoint(n,kind){
diff --git a/web/orchestrate.js b/web/orchestrate.js
index 4cbab4177..965f40b77 100644
--- a/web/orchestrate.js
+++ b/web/orchestrate.js
@@ -478,7 +478,7 @@ function aiSleep(ms) {
}
function aiCanvasFollow(x, y) {
- flowViewport.centerOn(x + 122, y + 60, {smooth: true});
+ flowViewport.centerOn(x + 100, y + 60, {smooth: true});
}
function aiProvisionalPosition(index) {
diff --git a/webtest/tests/flow-node-resize.test.mjs b/webtest/tests/flow-node-resize.test.mjs
new file mode 100644
index 000000000..e8a8f6ddc
--- /dev/null
+++ b/webtest/tests/flow-node-resize.test.mjs
@@ -0,0 +1,62 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { loadApp } from '../lib/load-app.mjs';
+
+async function flowApp(t) {
+ const app = await loadApp();
+ t.after(app.close);
+ app.evaluate(`
+ switchView('flow');
+ state.workflow={...clone(state.data.workflows[0]),id:'resize-flow',projectId:state.projectFilter,
+ nodes:[
+ {id:'a',name:'A',type:'script',script:'echo a',position:{x:80,y:80},artifactOutputs:[],onFailure:'fail'},
+ {id:'b',name:'B',type:'script',script:'echo b',position:{x:360,y:80},artifactOutputs:[],onFailure:'fail'}
+ ],edges:[{id:'e',source:'a',target:'b',when:'success'}],
+ sandboxProfileId:state.data.sandboxes[0]?.id||'local'};
+ state.workflowDirty=false;renderCanvas();
+ `);
+ return app;
+}
+
+test('cards default to the compact width and render a stored footprint', async (t) => {
+ const app = await flowApp(t);
+ assert.equal(app.evaluate(`flowNodeEl('a').style.width`), '200px');
+ assert.equal(app.evaluate(`flowNodeEl('a').style.height`), '');
+ app.evaluate(`state.workflow.nodes[0].size={w:320,h:260};renderCanvas()`);
+ assert.equal(app.evaluate(`flowNodeEl('a').style.width`), '320px');
+ assert.equal(app.evaluate(`flowNodeEl('a').style.height`), '260px');
+ assert.equal(app.evaluate(`JSON.stringify(flowNodeSize(state.workflow.nodes[0]))`), '{"w":320,"h":260}');
+});
+
+test('free resizing clamps both axes and survives a re-render', async (t) => {
+ const app = await flowApp(t);
+ app.evaluate(`setFlowNodeSize(state.workflow.nodes[0],500,900)`);
+ assert.equal(app.evaluate(`JSON.stringify(state.workflow.nodes[0].size)`), '{"w":480,"h":640}');
+ app.evaluate(`setFlowNodeSize(state.workflow.nodes[0],60,40)`);
+ assert.equal(app.evaluate(`JSON.stringify(state.workflow.nodes[0].size)`), '{"w":180,"h":96}');
+ app.evaluate(`renderCanvas()`);
+ assert.equal(app.evaluate(`flowNodeEl('a').style.width`), '180px');
+ assert.equal(app.evaluate(`flowNodeEl('a').style.height`), '96px');
+ assert.equal(app.evaluate(`flowNodeWidth(state.workflow.nodes[0])`), 180);
+});
+
+test('tall cards expand the node detail instead of showing whitespace', async (t) => {
+ const app = await flowApp(t);
+ app.evaluate(`state.workflow.nodes[0].script='echo one\\necho two';renderCanvas()`);
+ assert.equal(app.evaluate(`!!flowNodeEl('a').querySelector('.fd-detail')`), false);
+ app.evaluate(`setFlowNodeSize(state.workflow.nodes[0],260,280);renderCanvas()`);
+ assert.equal(app.evaluate(`!!flowNodeEl('a').querySelector('.fd-detail')`), true);
+ assert.match(app.evaluate(`flowNodeEl('a').querySelector('.fd-detail').textContent`), /echo one/);
+ app.evaluate(`setFlowNodeSize(state.workflow.nodes[0],260,120);renderCanvas()`);
+ assert.equal(app.evaluate(`!!flowNodeEl('a').querySelector('.fd-detail')`), false);
+});
+
+test('only the selected card shows the eight-handle resize frame', async (t) => {
+ const app = await flowApp(t);
+ assert.equal(app.evaluate(`document.querySelectorAll('#nodes .flow-node [data-resize]').length`), 0);
+ app.evaluate(`openNodeDrawer('a')`);
+ assert.equal(app.evaluate(`document.querySelectorAll('#nodes .flow-node[data-id="a"] [data-resize]').length`), 8);
+ assert.equal(app.evaluate(`[...document.querySelectorAll('#nodes .flow-node[data-id="a"] [data-resize]')].every(h=>h.classList.contains('fd-rz'))`), true);
+ app.evaluate(`closeNodeDrawer();state.workflow.projectId='someone-else';state.selectedNode='a';renderCanvas()`);
+ assert.equal(app.evaluate(`!state.workflow.nodes.length||document.querySelectorAll('#nodes .flow-node [data-resize]').length`), 0);
+});