HEL-731: 工作室、项目五阶段与搭景入口按确认样本落地 #10

Open
leefer wants to merge 6 commits from leefer/hel-731-studio-project AGit into fix/hel-771-theme-tile-details
5 changed files with 174 additions and 6 deletions
Showing only changes of commit f2ca010fcd - Show all commits
@@ -263,7 +263,6 @@
display: flex;
flex-direction: column;
gap: 6px;
font-size: 12.5px;
}
.studio-outputs {
display: grid;
@@ -826,6 +825,10 @@
--button-primary-radius: var(--project-button-radius);
--button-primary-weight: 700;
--button-primary-border-width: 0px;
--button-secondary-bg: rgb(var(--ink) / 0.03);
--button-secondary-bg: var(--bg-3);
--button-secondary-border: var(--line-2);
--button-secondary-hover-border: var(--line-3);
--button-secondary-padding: 12px;
--button-secondary-active-transform: translateY(1px);
--button-secondary-radius: var(--project-button-radius);
}
+9 -4
View File
@@ -69,7 +69,7 @@ code,
justify-content: center;
gap: var(--sp-2);
min-height: var(--button-height, 34px);
padding: 0 var(--sp-6);
padding: 0 var(--button-padding, var(--sp-6));
border-radius: var(--button-radius, var(--r-md));
border: 1px solid transparent;
font-family: inherit;
@@ -120,7 +120,12 @@ code,
.a-btn.secondary {
background: var(--button-secondary-bg, var(--surface));
border-radius: var(--button-secondary-radius, 8px);
border-color: var(--line);
border-color: var(--button-secondary-border, var(--line));
--button-padding: var(--button-secondary-padding, var(--sp-6));
--button-active-transform: var(
--button-secondary-active-transform,
scale(var(--press-scale))
);
color: var(--text);
}
.a-btn.ghost {
@@ -143,7 +148,7 @@ code,
box-shadow: var(--btn-glow-hover);
}
.a-btn.secondary:hover:not(:disabled) {
border-color: var(--line-2);
border-color: var(--button-secondary-hover-border, var(--line-2));
background: var(--bg-4);
}
.a-btn.ghost:hover:not(:disabled) {
@@ -160,7 +165,7 @@ code,
}
}
.a-btn:active:not(:disabled) {
transform: scale(var(--press-scale));
transform: var(--button-active-transform, scale(var(--press-scale)));
}
/* 禁用必须在旁边给出中文原因(§1.2),由调用方渲染。 */
.a-btn:disabled,
@@ -0,0 +1,12 @@
HEL-774 在 HEL-731 / PR #10 上按确认 HTML 样本定点返工,目标仍为 `fix/hel-771-theme-tile-details @ a1c01f1e90b0b1ce76300291eae51785604180d4`。
- `project.css` 两页作用域的次级按钮改回 `--bg-3`、`--line-2`、水平 12px;悬停边框为样本 `--line-3`,按下为样本 `translateY(1px)`。小按钮保留既有 9px,主按钮仍为 12px。
- `app.css` 仅为现有共享按钮增加带原值回退的 token 参数。尺寸规则仍由原 sm/lg/xs 定义负责,没有追加第二套组件样式,也未改动主题配色。
- 移除 `.confirm-item` 的 12.5px,按样本继承 13px。两页现有 `.a-tag` 均仅含文本;逐一实测将 gap 从 4px 改为 0px 后宽度不变,保留共享标签契约。
- `.sec-h`、日期内容/格式、后端、确认语义、B4/B5 均未改动。
复测使用 `e2e/run-hel774.py` 和 `e2e/hel774.cjs`,复用既有依赖与隔离假服务;四主题三尺寸两页共 24 组原始截图、次级按钮状态数值/局部图、空态和保存/跳转操作 trace 随 HEL-774 交付。测试中“禁用”包含显式标记的临时 DOM 状态夹具;未将样本项目、媒体或数字写入产品。原始页面截图和同文按钮数值分开保留。截图为施工员自测材料,仍需总工独立重拍复审与总管接续目检。
pytest 口径:本次只收集 `tests/test_workbench.py`(10项)与 `tests/test_playground_workbench_flowback.py`(8项),合计18项。原 HEL-731 的18项是工作台生命周期+来源回流的合计;HEL-773 单文件10项仅含前者。后端没有变更,不重复运行已通过的整套昂贵行为测试。lint、Svelte check(0错误0警告)、build、前端脚本和本次针对性浏览器验证日志交任务附件;构建的既有依赖导入/包大小提示保持如实记录。
未部署、未合并、无数据迁移或线上数据操作,无新增依赖。清理由 runner 的 finally 停止其启动的精确子进程组并移除隔离库;保留原始证据与校验清单供复审。
+93
View File
@@ -0,0 +1,93 @@
// HEL-774 focused repair verification. Uses only the runner's disposable real API records.
const {chromium}=require(process.env.PLAYWRIGHT_MODULE_PATH || 'playwright');
const fs=require('node:fs'),http=require('node:http'),assert=require('node:assert/strict');
const out='../evidence', WEB='http://127.0.0.1:5173', API='http://127.0.0.1:8247';
const resume=process.env.HEL774_ONLY_OPS==='1';
const previous=resume?JSON.parse(fs.readFileSync('../evidence/results.json')):{checks:[]};
const rows=resume?JSON.parse(fs.readFileSync('../evidence/measurements.json')):[],checks=previous.checks,errors=[],tags=resume?JSON.parse(fs.readFileSync('../evidence/tags.json')):[];
const ok=(name,value)=>{assert(value,name);checks.push(name);console.log('PASS',name)};
const api=async(path,body,method)=>{const r=await fetch(API+path,{method:method||(body?'POST':'GET'),headers:{'Content-Type':'application/json'},body:body?JSON.stringify(body):undefined,signal:AbortSignal.timeout(15000)});assert(r.ok,await r.clone().text());return r.json()};
const fingerprint=loc=>loc.evaluate(e=>{const s=getComputedStyle(e),r=e.getBoundingClientRect();return Object.fromEntries(['backgroundColor','borderTopColor','borderTopWidth','paddingLeft','paddingRight','fontSize','fontWeight','borderRadius','transform','opacity'].map(k=>[k,s[k]]).concat([['width',r.width],['height',r.height]]))});
const wait=ms=>new Promise(r=>setTimeout(r,ms));
(async()=>{
fs.mkdirSync(out+'/images',{recursive:true});fs.mkdirSync(out+'/closeups',{recursive:true});
const server=http.createServer((req,res)=>{res.setHeader('Content-Type','text/html;charset=utf-8');res.end(fs.readFileSync('../attachments/夜片场-多主题交互样本.html'))});
const browser=await chromium.launch({executablePath:process.env.CHROMIUM_EXECUTABLE_PATH,args:['--no-sandbox','--disable-dev-shm-usage']});
await new Promise(r=>server.listen(0,'127.0.0.1',r));
const ctx=await browser.newContext();await ctx.tracing.start({screenshots:true,snapshots:true,sources:true});
const p=await ctx.newPage(),sp=await ctx.newPage();p.on('pageerror',e=>errors.push(e.message));p.setDefaultTimeout(15000);
try{
const projects=await api('/api/projects'),proj=projects.find(x=>x.title==='隔离验证 · 海岸来信');assert(proj);
const projectPath='/workbench/'+proj.id+'?stage=storyboard';
if(!resume)for(const [width,height] of [[1440,900],[1366,768],[1280,720]])for(const theme of ['night','day','grade','bluehour']){
await p.setViewportSize({width,height});await sp.setViewportSize({width,height});
await sp.goto('http://127.0.0.1:'+server.address().port);await sp.evaluate(t=>{document.documentElement.dataset.theme=t;document.documentElement.classList.add('reduce')},theme);
await p.goto(WEB);await p.evaluate(t=>{localStorage.setItem('aigc-theme',t)},theme);
for(const page of ['studio','project']){
const name=`${page}-${theme}-${width}`;
await p.goto(WEB+(page==='studio'?'/':projectPath));await p.locator(page==='studio'?'.confirm-item':'.storyboard-card').first().waitFor();
await sp.evaluate(v=>document.querySelectorAll('.page').forEach(e=>e.classList.toggle('on',e.id==='p-'+v)),page);
await p.mouse.move(0,0);await sp.mouse.move(0,0);await wait(400);
await p.screenshot({path:`${out}/images/${name}-actual.png`});await sp.screenshot({path:`${out}/images/${name}-sample.png`});
const scope=page==='studio'?'.home':'.project-workspace';
const selectors=await p.locator(scope+' .a-btn.secondary').evaluateAll(els=>els.map((e,i)=>({i,text:e.textContent.trim(),classes:e.className,disabled:!!e.disabled,tag:e.tagName})));
ok(name+' secondary controls present',selectors.length>0);
for(const item of selectors){
const al=p.locator(scope+' .a-btn.secondary').nth(item.i);
// Same text on a sample control, preserving the original sample's class rules.
const id='hel774-reference';await sp.evaluate(({id,text,small})=>{document.getElementById(id)?.remove();const e=document.createElement('button');e.id=id;e.className='btn'+(small?' sm':'');e.textContent=text;e.style.position='fixed';e.style.left='100px';e.style.top='100px';document.querySelector('.page.on').append(e)}, {id,text:item.text,small:item.classes.split(' ').includes('sm')});
const sl=sp.locator('#'+id);
// Every actual secondary instance, including small controls. Disabled anchors are ARIA fixtures.
for(const state of ['normal','hover','active','disabled']){
await al.evaluate(e=>{e.removeAttribute('disabled');e.removeAttribute('aria-disabled')});await sl.evaluate(e=>e.disabled=false);
await p.mouse.move(0,0);await sp.mouse.move(0,0);
if(state==='disabled'){await al.evaluate(e=>e.tagName==='BUTTON'?e.disabled=true:e.setAttribute('aria-disabled','true'));await sl.evaluate(e=>e.disabled=true)}
if(state==='hover'||state==='active'){await al.hover();await sl.hover()}
if(state==='active'){await p.mouse.down();await sp.mouse.down()}
await wait(220);const actual=await fingerprint(al),sample=await fingerprint(sl);
rows.push({page,theme,width,text:item.text,classes:item.classes,state,syntheticDisabled:state==='disabled',sample,actual});
const props=['backgroundColor','borderTopColor','borderTopWidth','paddingLeft','paddingRight','fontSize','fontWeight'];
if(state==='active')props.push('transform');
for(const key of props)assert.equal(actual[key],sample[key],`${name} ${item.text} ${state} ${key}`);
if(!item.classes.includes('b3-grow'))assert(Math.abs(actual.width-sample.width)<0.05,`${name} ${item.text} ${state} width ${actual.width} vs ${sample.width}`);
if(item.i===0 && (state==='normal'||state==='hover'||state==='disabled')){await al.screenshot({path:`${out}/closeups/${name}-${state}-actual.png`});await sl.screenshot({path:`${out}/closeups/${name}-${state}-sample.png`})}
if(state==='active'){await p.mouse.move(0,0);await sp.mouse.move(0,0);await p.mouse.up();await sp.mouse.up()}
}
await al.evaluate((e,disabled)=>{e.removeAttribute('aria-disabled');if(disabled)e.setAttribute('disabled','');else e.removeAttribute('disabled')},item.disabled);await sl.evaluate(e=>e.remove());
}
await p.mouse.move(0,0);await sp.mouse.move(0,0);
if(page==='studio'){
const a=await fingerprint(p.locator('.confirm-item').first()),s=await fingerprint(sp.locator('.confirm-item').first());rows.push({page,theme,width,selector:'.confirm-item',actual:a,sample:s});ok(name+' confirmation font inherits sample 13px',a.fontSize===s.fontSize&&a.fontSize==='13px');
await p.locator('.confirm-item').first().screenshot({path:`${out}/closeups/${name}-confirm-actual.png`});await sp.locator('.confirm-item').first().screenshot({path:`${out}/closeups/${name}-confirm-sample.png`});
}
const tagRows=await p.locator(scope+' .a-tag').evaluateAll(els=>els.map(e=>{const before=e.getBoundingClientRect();const saved=e.style.columnGap;e.style.columnGap='0px';const after=e.getBoundingClientRect();e.style.columnGap=saved;return {text:e.textContent.trim(),elements:e.children.length,childNodes:[...e.childNodes].filter(n=>n.nodeType!==3||n.textContent.trim()).map(n=>n.nodeType),before:before.width,after:after.width,gap:getComputedStyle(e).columnGap}}));tags.push({page,theme,width,tags:tagRows});ok(name+' single-content tags unaffected by gap',tagRows.every(t=>t.elements===0&&t.before===t.after));
// Primary and small variants keep their own existing padding.
ok(name+' primary padding preserved',await p.locator(scope+' .a-btn.primary').first().evaluate(e=>getComputedStyle(e).paddingLeft==='12px'));
}
// Keep actual empty state evidence, without manufacturing demo projects or media.
await p.route('**/api/projects',r=>r.fulfill({json:[]}));await p.goto(WEB);await p.locator('.studio-hero').waitFor();await wait(100);await p.screenshot({path:`${out}/images/empty-${theme}-${width}.png`});ok(`empty ${theme} ${width}`,await p.locator('.studio-display').innerText().then(t=>t.includes('从一个想法开始')));await p.unroute('**/api/projects');
}
// Meaningful operation checks for the affected buttons, with actual API persistence.
await p.goto(WEB);await p.locator('.studio-hero .secondary').waitFor();const heroHref=await p.locator('.studio-hero .secondary').getAttribute('href');await p.locator('.studio-hero .secondary').click();ok('studio secondary opens real project stage',new URL(p.url()).pathname+new URL(p.url()).search===heroHref);
await p.goto(WEB+projectPath);await p.locator('.storyboard-card').first().waitFor();await p.getByRole('button',{name:'编辑',exact:true}).click();await p.locator('.shot-edit textarea').first().fill('HEL774 次级保存按钮实际操作');ok('editing prevents stale confirmation',await p.locator('[data-testid=stage-confirm-btn]').isDisabled());await p.route('**/stages/storyboard',async route=>{if(route.request().method()==='PATCH')await wait(1000);await route.continue()});await p.locator('[data-testid=stage-save-btn]').click();ok('save secondary disabled while request pending',await p.locator('[data-testid=stage-save-btn]').isDisabled());await p.screenshot({path:out+'/images/operation-save-pending.png'});for(let n=0;n<50;n++){if(JSON.stringify(await api('/api/workbench/projects/'+proj.id)).includes('HEL774 次级保存按钮实际操作'))break;await wait(100)}ok('secondary saves actual edited draft',JSON.stringify(await api('/api/workbench/projects/'+proj.id)).includes('HEL774 次级保存按钮实际操作'));await p.screenshot({path:out+'/images/operation-save.png'});await p.unroute('**/stages/storyboard');
await p.goto(WEB);await p.locator('.confirm-item .secondary').first().click();ok('pending secondary navigates to draft',p.url().includes('/workbench/'));
await p.goto(WEB);await p.locator('.studio-search').click();ok('search remains functional',await p.getByRole('dialog').isVisible());await p.keyboard.press('Escape');await p.keyboard.press('Control+k');ok('search shortcut preserved',await p.getByRole('dialog').isVisible());await p.keyboard.press('Escape');
// B1/B2: compare live shared controls with exact previous shared declarations applied via CSSOM.
const protections=[];
for(const route of ['/create','/workflows','/tasks','/settings']){
await p.goto(WEB+route);await wait(800);
ok(route+' sidebar retained',await p.locator('aside.sidebar').isVisible());
for(const theme of ['night','day','grade','bluehour']){
await p.evaluate(t=>document.documentElement.dataset.theme=t,theme);await wait(150);
const buttons=p.locator('.a-btn:visible');const count=await buttons.count();
const baseline=await buttons.evaluateAll(es=>es.map(e=>{const s=getComputedStyle(e),b=e.getBoundingClientRect();return {text:e.textContent.trim(),bg:s.backgroundColor,border:s.borderTopColor,pad:s.paddingLeft,width:b.width,height:b.height,font:s.fontSize}}));
await p.evaluate(()=>{window.hel774Rules=[];for(const sheet of document.styleSheets){let rules;try{rules=sheet.cssRules}catch{continue}for(const r of rules){if(!r.selectorText)continue;const sel=r.selectorText;if(sel==='.a-btn'){window.hel774Rules.push([r,r.style.cssText]);r.style.padding='0 var(--sp-6)'}if(sel==='.a-btn.secondary'){window.hel774Rules.push([r,r.style.cssText]);r.style.borderColor='var(--line)';r.style.removeProperty('--button-padding');r.style.removeProperty('--button-active-transform')}}}});
const previous=await buttons.evaluateAll(es=>es.map(e=>{const s=getComputedStyle(e),b=e.getBoundingClientRect();return {text:e.textContent.trim(),bg:s.backgroundColor,border:s.borderTopColor,pad:s.paddingLeft,width:b.width,height:b.height,font:s.fontSize}}));
await p.evaluate(()=>window.hel774Rules.forEach(([r,css])=>r.style.cssText=css));assert.deepEqual(baseline,previous,route+' default controls changed');protections.push({route,theme,count,baseline,previous});
await p.screenshot({path:`${out}/images/protect-${route.slice(1)}-${theme}.png`});
}
}
fs.writeFileSync(out+'/protections.json',JSON.stringify(protections,null,2));
ok('no browser errors',errors.length===0);
}finally{fs.writeFileSync(out+'/measurements.json',JSON.stringify(rows,null,2));fs.writeFileSync(out+'/tags.json',JSON.stringify(tags,null,2));fs.writeFileSync(out+'/results.json',JSON.stringify({checks,errors},null,2));await ctx.tracing.stop({path:out+'/interaction-trace.zip'});await browser.close();await new Promise(r=>server.close(r))}
})().catch(e=>{console.error(e);process.exitCode=1});
+55
View File
@@ -0,0 +1,55 @@
"""HEL-773: run the isolated stack, keep it alive for the audit script, then stop children."""
import os, signal, socket, subprocess, time, urllib.request
from pathlib import Path
root=Path(__file__).resolve().parents[1]
os.chdir(root)
(root/'e2e/shots/hel731').mkdir(parents=True,exist_ok=True)
py=os.environ.get('HEL731_PYTHON','python3')
env=os.environ.copy()
env['PYTHONPATH']=str(root/'calliope-backend/src')
for port in [8247,5173,18188,18189]:
with socket.socket() as probe:
assert probe.connect_ex(('127.0.0.1',port))!=0, f'Test port {port} is already in use'
reference=root/'e2e/shots/reference'
if reference.exists():reference.rename(reference.with_name('reference.previous-'+str(time.time_ns())))
processes=[];handles=[]
try:
for name,cmd in [('api',[py,'e2e/reference/server.py']),('comfy',[py,'e2e/fake_comfy.py']),('llm',[py,'e2e/reference/fake_llm.py']),('web',['npm','--prefix','calliope-web','run','dev'])]:
h=open(f'../evidence/checks/{name}.log','w');handles.append(h);processes.append(subprocess.Popen(cmd,stdout=h,stderr=subprocess.STDOUT,env=env,start_new_session=True))
for url in ['http://127.0.0.1:8247/api/health','http://127.0.0.1:5173']:
for i in range(100):
try:
urllib.request.urlopen(url,timeout=2);break
except Exception:
if any(p.poll() is not None for p in processes):raise RuntimeError('A test service failed')
if i==99:raise
time.sleep(.2)
for cmd in [[py,'e2e/seed.py'],[py,'e2e/reference/seed.py']]:subprocess.run(cmd,env=env,check=True)
# seed one project with storyboard content like hel731.cjs does
import json,urllib.request as u
def api(p,b=None,method=None):
req=u.Request('http://127.0.0.1:8247'+p,data=json.dumps(b).encode() if b is not None else None,method=method or ('POST' if b is not None else 'GET'),headers={'Content-Type':'application/json'})
return json.loads(u.urlopen(req, timeout=15).read())
proj=api('/api/projects',{'title':'隔离验证 · 海岸来信','idea':'纸船带回一片树叶'})
fixtures={'script':{'text':'第一场:清晨的海岸,女孩把一只纸船放入海水。她等候着父亲的归来。第二场:纸船带回一片树叶,女孩望向海平面,知道旅程才刚刚开始。'},
'style':{'directions':[{'id':'s1','name':'晨光','description':'暖光','prompt':'warm light'},{'id':'s2','name':'蓝调','description':'冷光','prompt':'blue hour'}]},
'storyboard':{'shots':[{'id':'board-'+str(i),'scene':'1','shot_size':'远景','camera':'固定','description':'女孩沿着海岸走向灯塔,纸船随海风起伏。','dialog':('你好' if i%2 else ''),'duration_sec':5} for i in range(12)]},
'assets':{'assets':[{'id':'asset-a','kind':'character','name':'海边女孩','description':'女孩','prompt':'girl on coast'}]},
'shot':{'shots':[{'id':'shot-a','shot_no':'S1','description':'女孩走向灯塔','prompt':'girl walks toward lighthouse','duration_sec':4}]}}
for stage,content in fixtures.items():
api(f"/api/workbench/projects/{proj['id']}/stages/{stage}",{'content':content},'PATCH')
if stage in ('script','style'):
api(f"/api/workbench/projects/{proj['id']}/stages/{stage}/confirm",({'chosen_style_id':'s1'} if stage=='style' else {}))
print('stack ready, project',proj['id'])
result=subprocess.run(['node','e2e/hel774.cjs'],env=env)
raise SystemExit(result.returncode)
finally:
for p in processes:
if p.poll() is None:os.killpg(p.pid,signal.SIGTERM)
for p in processes:
try:p.wait(timeout=10)
except subprocess.TimeoutExpired:os.killpg(p.pid,signal.SIGKILL);p.wait()
for h in handles:h.close()
import shutil
if reference.exists():shutil.rmtree(reference)
print('CLEANUP: all exact child process groups stopped; disposable reference DB removed',flush=True)