Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/assets/qa/small-screen/canvas-after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/qa/small-screen/canvas-before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/qa/small-screen/roles-after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/qa/small-screen/roles-before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions e2e/ui/05-small-screen.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {test,expect} from './fixtures.mjs';
import {createWorkflow,script} from '../lib/fixtures.mjs';
import {cleanup} from '../lib/api.mjs';

test.afterEach(cleanup);

for(const [width,lang] of [[320,'zh'],[375,'en']]){
test(`workbench controls fit a ${width}px ${lang} viewport`,async({page})=>{
await page.setViewportSize({width,height:780});
await page.addInitScript(value=>localStorage.setItem('loopforge.lang',value),lang);
const workflow=await createWorkflow(`small-screen-${width}`,[script('step','true')]);
await page.goto('/#/agents');
const search=page.locator('#agentSearch');
await expect(search).toBeVisible();
const input=await search.boundingBox();
expect(input.x+input.width).toBeLessThanOrEqual(width);
await search.fill('small-screen role');
await expect(search).toHaveValue('small-screen role');

await page.goto(`/#/flow/${encodeURIComponent(workflow)}`);
const toggle=page.locator('#flowPaletteCollapse');
await expect(toggle).toHaveAttribute('aria-expanded','false');
const stage=page.locator('#flowStageWrap');
expect((await stage.boundingBox()).width).toBeGreaterThan(140);
const node=page.locator('#canvas [data-id="step"]').first();
await expect.poll(async()=>{
const [box,canvas]=await Promise.all([node.boundingBox(),stage.boundingBox()]);
return !!box&&!!canvas&&box.x>=canvas.x&&box.x+box.width<=canvas.x+canvas.width+1;
}).toBe(true);
await toggle.click();
await expect(toggle).toHaveAttribute('aria-expanded','true');
expect((await stage.boundingBox()).width).toBeGreaterThan(140);
await toggle.click();
await page.locator('#canvasZoomIn').click();
const minimap=page.locator('#canvasMinimap');
await expect(minimap).toBeHidden();
await page.locator('#canvasMinimapToggle').click();
await expect(minimap).toBeVisible();
await page.setViewportSize({width:1280,height:860});
await expect(toggle).toHaveAttribute('aria-expanded','true');
});
}
7 changes: 7 additions & 0 deletions web/access.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions web/app/assets-harness.css
Original file line number Diff line number Diff line change
Expand Up @@ -614,3 +614,9 @@
#mcpView .mcp-catalog-suggest b{color:var(--hui-text);font-size:13px;font-weight:500}
#mcpView .mcp-catalog-suggest span{color:var(--hui-muted);font-size:12px}
#mcpView .mcp-catalog-actions{display:flex;gap:8px;flex-wrap:wrap}

@media(max-width:650px){
#assetsView #assetScopeToolbar{flex-direction:column;align-items:stretch;gap:8px}
#assetsView #assetScopeSwitch{flex-wrap:wrap!important;width:100%;max-width:100%;height:auto!important;box-sizing:border-box}
#assetsView #assetSearchBox{width:100%;max-width:none;box-sizing:border-box}
}
19 changes: 18 additions & 1 deletion web/app/flow-canvas.css
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ html[data-theme="dark"] #flowView .fd-toast button{background:rgba(0,0,0,.06);co
#flowView .fd-stagewrap.ai-open .properties.fd-drawer{display:none}
#flowView .fd-stagewrap.has-drawer .fd-tr{right:380px}
#flowView .fd-stagewrap.has-drawer .fd-minimap{right:380px}
#flowView .fd-stagewrap.tight .fd-minimap,#flowView .fd-stagewrap.tight .fd-legend,#flowView .fd-stagewrap.tight .fd-lg-sep{display:none}
#flowView .fd-stagewrap.tight .fd-legend,#flowView .fd-stagewrap.tight .fd-lg-sep{display:none}
#flowView .fd-dh{display:flex;align-items:center;gap:10px;padding:14px 12px 12px 16px;border-bottom:1px solid var(--fd-line);flex:none}
#flowView .fd-dh-t{flex:1;min-width:0}
#flowView .fd-dh-name{display:block;width:100%;height:28px;margin:-2px 0 0 -6px;padding:0 6px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--fd-ink);font:600 15px/1 inherit;outline:0;text-overflow:ellipsis;transition:border-color .15s,background .15s}
Expand Down Expand Up @@ -478,3 +478,20 @@ html[data-theme="dark"] #aiOrchestrator :is([data-cli="codex"],[data-cli="claude
@media (prefers-reduced-motion:reduce){
#flowView *,#flowView *::before,#flowView *::after{animation-duration:.01ms!important;transition-duration:.01ms!important}
}

/* Keep the canvas usable when the node library would occupy most of the designer. */
#flowView .fd-body.compact .fd-palette{position:absolute;inset:0 auto 0 0;z-index:24;max-width:calc(100% - 24px)}
#flowView .fd-body.compact .fd-palette:not(.collapsed){box-shadow:var(--fd-shadow-lg)}
#flowView .fd-body.compact .fd-stagewrap{margin-left:48px}
#flowView .fd-body.compact .fd-tr{left:6px;right:auto;top:6px;width:max-content;max-width:calc(100% - 12px);box-sizing:border-box;flex-wrap:wrap}
#flowView .fd-body.compact .fd-bl{left:6px;bottom:62px;max-width:calc(100% - 12px);width:max-content;box-sizing:border-box;flex-wrap:wrap}
#flowView .fd-body.compact .fd-bl .fd-sep{display:none}
#flowView .fd-stagewrap.tight .fd-minimap{width:min(118px,45%);height:72px;bottom:90px;right:6px}
#flowView .fd-body.compact .fd-stagewrap.tight .fd-minimap{bottom:146px}
@media(max-width:520px){
#flowView .fd-head{flex-wrap:wrap;padding:6px 8px;gap:3px}
#flowView .fd-ident{flex:1 0 100%;max-width:100%;box-sizing:border-box}
#flowView .fd-head-sp{display:none}
#flowView .fd-tools{margin-left:auto}
#flowView .fd-pop{left:4px;max-width:calc(100% - 8px);max-height:65vh}
}
10 changes: 6 additions & 4 deletions web/app/flow-palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ const flowPalette=(()=>{
function setCollapsed(on){
const pal=document.getElementById('flowPalette');if(!pal)return;
pal.classList.toggle('collapsed',on);
localStorage.setItem(COLLAPSE_KEY,on?'1':'0');
const btn=document.getElementById('flowPaletteCollapse');if(btn)btn.dataset.tip=on?'展开节点库':'收起节点库';
flowViewport.paletteToggled();
setTimeout(()=>flowViewport.layoutTight(),220);
const body=document.getElementById('flowBody');
if(body?.classList.contains('compact'))body.classList.toggle('palette-open',!on);
else localStorage.setItem(COLLAPSE_KEY,on?'1':'0');
flowViewport.layoutTight();
setTimeout(()=>{flowViewport.layoutTight();flowViewport.renderMinimap()},220);
}
function bindDrop(){
const c=document.getElementById('canvas');if(!c)return;
Expand All @@ -118,6 +119,7 @@ const flowPalette=(()=>{
if(e.target.closest('[data-pal-agents]')){switchView('agents');return}
const item=e.target.closest('.fd-pal-item');if(!item)return;
const p=payload(item);addNode(p.type,{agentId:p.agentId});
if(document.getElementById('flowBody')?.classList.contains('palette-open')&&!flowReadOnly())setCollapsed(true);
});
body.addEventListener('keydown',e=>{
if(e.key!=='Enter'&&e.key!==' ')return;
Expand Down
63 changes: 45 additions & 18 deletions web/app/flow-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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 vp={x:40,y:40,zoom:1};
let fittedId=null,autoCollapsed=false,animTimer=0,bound=false,onBlankClick=null,minimapRaf=0;
let fittedId=null,fittedCamera=null,animTimer=0,bound=false,onBlankClick=null,minimapRaf=0;
const byId=id=>document.getElementById(id);
const canvas=()=>byId('canvas');
const clamp=z=>Math.min(MAX,Math.max(MIN,z));
Expand Down Expand Up @@ -50,7 +50,9 @@ const flowViewport=(()=>{
return {x:x0,y:y0,w:x1-x0,h:y1-y0};
}
function fit(opts={}){
const smooth=opts.smooth!==false,pad=opts.padding??72,v=visible();
const smooth=opts.smooth!==false,v=visible();
const compact=byId('flowBody')?.classList.contains('compact');
const pad=opts.padding??(compact?Math.min(24,v.w*.08):72);
if(!v.w||!v.h)return;
const b=bounds();
if(!b){vp.zoom=1;vp.x=40;vp.y=40;apply(smooth);return}
Expand Down Expand Up @@ -87,20 +89,31 @@ const flowViewport=(()=>{
}
return {x:Math.round(c.x/10)*10,y:Math.round(c.y/10)*10};
}
// Collapse the palette and hide minimap/legend when an open drawer leaves
// too little canvas; restore whatever was collapsed automatically.
// A compact palette overlays the canvas. Desktop uses the saved width preference.
function layoutTight(){
const body=byId('flowBody'),pal=byId('flowPalette'),wrap=byId('flowStageWrap');if(!body||!pal||!wrap)return;
const drawer=drawerWidth(),total=body.clientWidth;if(!total)return;
const manual=localStorage.getItem('agentflow.flowPaletteCollapsed')==='1';
const need=drawer>0&&total-(manual?PAL_MINI:PAL_W)-drawer<480;
if(need&&!pal.classList.contains('collapsed')){pal.classList.add('collapsed');autoCollapsed=true}
else if(!need&&autoCollapsed){pal.classList.remove('collapsed');autoCollapsed=false}
const free=total-(pal.classList.contains('collapsed')?PAL_MINI:PAL_W)-drawer;
wrap.classList.toggle('tight',free<640);
const total=body.clientWidth;
if(total){
const drawer=drawerWidth(),compact=total<=540;
body.classList.toggle('compact',compact);
const manual=localStorage.getItem('agentflow.flowPaletteCollapsed')==='1';
const collapsed=compact?!body.classList.contains('palette-open'):manual||(drawer>0&&total-PAL_W-drawer<480);
pal.classList.toggle('collapsed',collapsed);
const free=total-(compact||collapsed?PAL_MINI:PAL_W)-drawer;
wrap.classList.toggle('tight',free<640);
}
const collapsed=pal.classList.contains('collapsed');
const toggle=byId('flowPaletteCollapse');
if(toggle){
toggle.setAttribute('aria-expanded',String(!collapsed));
const label=collapsed?'展开节点库':'收起节点库';
toggle.dataset.tip=label;toggle.setAttribute('aria-label',label);
}
}
function minimapOn(){
const value=localStorage.getItem(MINIMAP_KEY);
return value===null?!byId('flowStageWrap')?.classList.contains('tight'):value==='1';
}
function paletteToggled(){autoCollapsed=false}
function minimapOn(){return localStorage.getItem(MINIMAP_KEY)!=='0'}
// Pan and wheel fire faster than frames; redraw the minimap at most once per frame.
function scheduleMinimap(){
if(minimapRaf)return;
Expand All @@ -122,9 +135,14 @@ const flowViewport=(()=>{
function toggleMinimap(){localStorage.setItem(MINIMAP_KEY,minimapOn()?'0':'1');renderMinimap()}
// Called after every canvas render; fits once per opened workflow.
function afterRender(){
const id=state.workflow?.id||null,c=canvas();
if(id&&id!==fittedId&&c&&c.clientWidth){fittedId=id;requestAnimationFrame(()=>fit({smooth:false}))}
else renderMinimap();
const id=state.workflow?.id;
if(!id||id===fittedId){renderMinimap();return}
requestAnimationFrame(()=>{
if(id!==state.workflow?.id||id===fittedId)return;
layoutTight();
const area=visible();if(!area.w||!area.h)return;
fit({smooth:false});fittedId=id;fittedCamera={...vp,width:area.w};
});
}
function bind(opts={}){
onBlankClick=opts.onBlankClick||onBlankClick;
Expand Down Expand Up @@ -159,10 +177,19 @@ const flowViewport=(()=>{
mm.onpointerup=mm.onpointercancel=()=>{down=false};
}
const body=byId('flowBody');
if(body&&typeof ResizeObserver==='function')new ResizeObserver(()=>{layoutTight();renderMinimap()}).observe(body);
if(body&&typeof ResizeObserver==='function'){
const resize=new ResizeObserver(()=>{
layoutTight();
const width=visible().w;
if(body.classList.contains('compact')&&width&&fittedCamera&&width!==fittedCamera.width&&
vp.x===fittedCamera.x&&vp.y===fittedCamera.y&&vp.zoom===fittedCamera.zoom)fittedId=null;
afterRender();
});
resize.observe(body);resize.observe(byId('flowStageWrap'));
}
apply();
}
return {toWorld,zoomBy,setZoom,fit,centerOn,reveal,reset,apply,layoutTight,freeSpot,afterRender,bind,paletteToggled,renderMinimap,
return {toWorld,zoomBy,setZoom,fit,centerOn,reveal,reset,apply,layoutTight,freeSpot,afterRender,bind,renderMinimap,
get zoom(){return vp.zoom},get x(){return vp.x},get y(){return vp.y},
_set(next){Object.assign(vp,next)}};
})();
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ <h1>运行记录<span class="info-tip" tabindex="0" role="note" aria-label="并
<aside class="fd-palette" id="flowPalette" aria-label="节点库">
<div class="fd-pal-head">
<label class="fd-search"><span data-fd-ic="search" data-s="14"></span><input id="flowPaletteQ" type="search" placeholder="搜索角色或节点" autocomplete="off"></label>
<button type="button" class="fd-icon-btn bordered" id="flowPaletteCollapse" data-tip="收起节点库"><span data-fd-ic="panel"></span></button>
<button type="button" class="fd-icon-btn bordered" id="flowPaletteCollapse" aria-controls="flowPaletteBody" aria-expanded="true" aria-label="收起节点库" data-tip="收起节点库"><span data-fd-ic="panel"></span></button>
</div>
<div class="fd-pal-body" id="flowPaletteBody">
<div class="fd-pal-group" data-pal-group="role"><div class="fd-pal-gh">角色<em id="flowPaletteRoleCount"></em></div><div id="flowPaletteRoles"></div></div>
Expand Down
6 changes: 6 additions & 0 deletions web/product-v4.css
Original file line number Diff line number Diff line change
Expand Up @@ -3410,6 +3410,12 @@ html[data-theme="dark"] #runnersView .runner-runtime-icon:is(.codex,.claude-code
#agentsView .agent-search{width:180px}
}

@media(max-width:650px){
#agentsView .agent-toolbar{display:grid;grid-template-columns:minmax(0,1fr);gap:8px}
#agentsView .agent-tabs{max-width:100%;overflow-x:auto}
#agentsView .agent-search{width:100%;max-width:none;box-sizing:border-box}
}

/* --- 角色弹窗:外框、标题、导航、底栏 --- */
#agentModal .modal-card.agent-studio-v2{
width:min(max(72vw,880px),1320px,94vw);height:min(max(84vh,640px),1000px,92vh);border:1px solid var(--hu-border);border-radius:var(--hu-r-xl);
Expand Down
Loading