diff --git a/calliope-web/src/lib/components/ToastHost.svelte b/calliope-web/src/lib/components/ToastHost.svelte index bb9cd6b2..7a17ef97 100644 --- a/calliope-web/src/lib/components/ToastHost.svelte +++ b/calliope-web/src/lib/components/ToastHost.svelte @@ -8,18 +8,11 @@ type Toast, } from '$lib/toast'; import Icon from '$lib/components/ui/Icon.svelte'; - import type { IconName } from '$lib/components/ui/icons'; import { t } from '$lib/i18n.svelte'; let items = $state([]); onMount(() => subscribeToasts((next) => (items = next))); - - const kindIcon: Record = { - success: 'check', - error: 'alert', - info: 'info', - }; {#if items.length} @@ -27,6 +20,7 @@ {#each items as toast (toast.id)}
pauseToast(toast.id)} onmouseleave={() => resumeToast(toast.id)} @@ -35,15 +29,18 @@ > - {toast.message} - {#if toast.action} - - {/if} - + {/if} +
{/if}
-
-
+
+
{#if selectedJob} void; const DEFAULT_DURATION = 3200; +const EXIT_DURATION = 300; let seq = 0; let toasts: Toast[] = []; @@ -27,6 +29,7 @@ type TimerState = { remaining: number; startedAt: number; handle: ReturnType; + paused?: boolean; }; const timers = new Map(); @@ -56,7 +59,18 @@ function schedule(id: number, delay: number) { timers.set(id, { remaining: delay, startedAt: Date.now(), - handle: setTimeout(() => dismissToast(id), delay), + handle: setTimeout(() => expireToast(id), delay), + }); +} + +function expireToast(id: number) { + timers.delete(id); + toasts = toasts.map((t) => (t.id === id ? { ...t, leaving: true } : t)); + emit(); + timers.set(id, { + remaining: 0, + startedAt: Date.now(), + handle: setTimeout(() => dismissToast(id), EXIT_DURATION), }); } @@ -76,24 +90,27 @@ export function showToast( /** Pause auto-dismiss (e.g. while the pointer or focus is on the toast). */ export function pauseToast(id: number) { const timer = timers.get(id); - if (!timer) return; + if (!timer || timer.paused || toasts.find((t) => t.id === id)?.leaving) + return; clearTimeout(timer.handle); timer.remaining = Math.max( 0, timer.remaining - (Date.now() - timer.startedAt), ); timer.startedAt = Date.now(); + timer.paused = true; } /** Resume auto-dismiss after a pause. */ export function resumeToast(id: number) { const timer = timers.get(id); - if (!timer) return; + if (!timer?.paused) return; clearTimeout(timer.handle); const delay = Math.max(0, timer.remaining); timer.remaining = delay; timer.startedAt = Date.now(); - timer.handle = setTimeout(() => dismissToast(id), delay); + timer.paused = false; + timer.handle = setTimeout(() => expireToast(id), delay); } export const toast = { diff --git a/calliope-web/static/themes.css b/calliope-web/static/themes.css index 9fb6872b..23e5c8af 100644 --- a/calliope-web/static/themes.css +++ b/calliope-web/static/themes.css @@ -245,6 +245,9 @@ --desk-player-offset: -50%; --desk-media-bg: #000; --desk-media-radius: 8px; + --desk-stage-padding: 12px 16px 8px; + --desk-layout-gap: 0px; + --desk-action-height: 40px; --desk-history-padding: 8px; --desk-history-gap: 8px; --desk-history-label-bg: rgba(0, 0, 0, 0.6); @@ -511,6 +514,7 @@ } [data-theme="grade"] { + --desk-media-radius: 4px; --result-develop: a-develop-grade; --project-card-radius: 4px; --project-hero-radius: 4px; @@ -620,6 +624,7 @@ } [data-theme="bluehour"] { + --desk-media-radius: 14px; --rail-background: linear-gradient(180deg, #101a40, #1a1440); --project-shot-radius: 14px; --project-button-radius: 10px; @@ -744,6 +749,11 @@ --hist: 84px; } } +@media (max-height: 800px) { + :root { + --desk-stage-padding: 8px 16px 8px; + } +} @media (max-width: 1280px) { :root { --rail: 60px; @@ -762,7 +772,23 @@ --composer-bg: var(--desk-dock-bg); --composer-focus: var(--bg-2); --float-bg: var(--bg-2); - --toast-bottom: 24px; + --toast-right: 18px; + --toast-bottom: 18px; + --toast-min-width: 260px; + --toast-max-width: 380px; + --toast-padding: 10px 14px; + --toast-radius: 10px; + --toast-bg: color-mix(in srgb, var(--bg-3) 97%, transparent); + --toast-border: var(--line-2); + --toast-shadow: var(--sh-2); + --toast-font: 12.5px; + --toast-line-height: 1.55; + --toast-enter: 320ms; + --toast-ease: cubic-bezier(0.34, 1.56, 0.64, 1); + --toast-enter-y: 10px; + --toast-enter-scale: 0.96; + --toast-exit: 300ms; + --toast-dot-top: 6px; --on-media: #fff; --on-media-line: #ffffff66; --sel-shadow: 0 0 0 1px var(--gold); @@ -920,7 +946,7 @@ html.theme-anim *::after { } } -/* Keep transient feedback clear of the project’s fixed primary actions. */ +/* Preserve the existing clearance for the fixed project actions. */ :root:has(.project-workspace) { --toast-bottom: calc(var(--project-footer-height) + 24px); } diff --git a/docs/changelogs/2026-10-23-hel806-same-state-audit.md b/docs/changelogs/2026-10-23-hel806-same-state-audit.md new file mode 100644 index 00000000..ae208739 --- /dev/null +++ b/docs/changelogs/2026-10-23-hel806-same-state-audit.md @@ -0,0 +1,17 @@ +HEL-806 continues draft PR #12 on `agent/agent/8ec6e532b3ac`, from `1f6c2d2a6b8da29ef29a874709d90da138123216`; target remains `leefer/hel-731-studio-project@2952af42b6232483640f1f27803980367cd62dd0`. All B4 and HEL-733 changes are retained. No merge or deployment. + +The approved HTML remains read-only, SHA256 `0473d80d22b90194375f3566c1b8ca30dbd7433581b18f60956eabca252242a4`. The architectural boundaries follow HEL-727 and the existing B1–B4 components. No dependency, backend, schema, API, cloud generation integration or production configuration is changed. + +- `themes.css`, `ToastHost.svelte`, `toast.ts`: use the sample's 18px placement, surface, border, 10px radius, 12.5px text, dot, 320ms spring entry and 3200ms display followed by 300ms fade. Repeated pause no longer consumes remaining time twice. Existing undo/manual dismissal/sticky feedback and the project's fixed-action clearance remain. Those real controls and clearance are recorded as specific sample conflicts, not silently removed or presented as approved. +- `StudioDesk.svelte`, `Artboard.svelte`: replace the extra 12px gap with the original stage padding (12px 16px 8px, top 8px when height <=800), keep the 40px action row for empty as well as populated states, and clip media to its theme radius (8px night/day, 4px grade, 14px bluehour). Values have one source in tokens; no overlay stylesheet or duplicate component. +- `e2e/hel806.cjs`: real disposable HTTP data, fake ComfyUI/model only, four themes × three viewports. Original reference, runtime content map and actual screenshots are distinct. Reference changes use existing templates/content/state; no reference CSS/layout changes. Missing empty states, non-storyboard stage content, real edit/compare/validation dialogs and organization-only pages are explicitly marked. The sample's static parameter list is not substituted for actual workflow declarations. +- `e2e/hel806-toast.mjs`, `hel806-toast-browser.cjs`: deterministic expiry/pause/sticky/cleanup regression plus full/reduced motion, project footer clearance and real explicit confirmation. +- `scripts/report-hel806.py`: measured values, self-contained themed galleries and parallel images. Screenshot delivery uses lossless WebP; decoded RGB equality is checked against source PNGs. Manifests retain both hashes. Screenshot counts and DOM measurements are evidence, never automatic visual approval. + +Reproduce from a frozen build: install the repository's existing dependencies, run frontend lint/check/test/build, then set existing `PLAYWRIGHT_MODULE_PATH`, browser library path and `HEL732_PYTHON` for this machine. `HEL733_TESTS=e2e/hel732.cjs,e2e/hel729.cjs,e2e/hel742.cjs,e2e/hel733-live.cjs,e2e/hel732-visual.cjs,e2e/hel806.cjs,e2e/hel806-toast-browser.cjs HEL733_SKIP_SHOTS=1 python3 e2e/run-hel733.py`. The original HTML is downloaded through the CLI to `../materials` and the B4 reference copy to `../evidence/reference`. All required results are collected before exit; the runner closes its exact child processes and removes the disposable database. Run `node e2e/hel806-toast.mjs` separately. The report script reads `../evidence/hel806-final/results.json`. + +The attached coverage report owns the per-page findings and exact run results. The six approved business differences, small-window hero exception, text-to-image without image slots, honest unknown connection metrics and manual video playback remain. Restrained motion, final navigation slot purpose and canvas/scene visual samples still await the design decision already routed by the coordinator. No claim that HEL-733 or the whole site is complete; final independent review and deployment belong to the responsible reviewer. + +Rollback only these commits, keeping `1f6c2d2` and B4. No database rollback is needed. + +Validation completed: full frontend lint/check (0 errors / 0 warnings), guard scripts and production build pass. Relevant backend regressions: 24 pass, one existing Starlette deprecation warning. B1 browser checks: 42; no-image guards: 7; B4 functional: 31; shared motion/storage checks: 43, all pass with no page errors. B4 same-state 24 groups / 156 measured selector pairs have no differences, plus four interactions. The audit delivers 34 states × 12 viewports/themes = 408 groups and 12 dedicated Toast style/clearance checks. Image frame geometry/radius and empty-ring geometry each match the reference in their 12 measured groups; these local findings do not imply whole-page approval. diff --git a/e2e/hel806-toast-browser.cjs b/e2e/hel806-toast-browser.cjs new file mode 100644 index 00000000..79dacdc6 --- /dev/null +++ b/e2e/hel806-toast-browser.cjs @@ -0,0 +1,17 @@ +// Shared feedback on the real fixed project footer, using only disposable state. +const {chromium}=require(process.env.PLAYWRIGHT_MODULE_PATH||'playwright'); +const fs=require('node:fs'),http=require('node:http'),assert=require('node:assert/strict'); +(async()=>{const out='../evidence/hel806-toast';fs.mkdirSync(out,{recursive:true});const api=async(p,b,method)=>{const r=await fetch('http://127.0.0.1:8247'+p,{method:method||(b?'POST':'GET'),headers:{'Content-Type':'application/json'},body:b?JSON.stringify(b):undefined});assert(r.ok,await r.clone().text());return r.json()}; +const settings=await api('/api/settings');assert(settings.data_dir.includes('e2e/shots/reference')); +const project=await api('/api/projects',{title:'HEL806 Toast clearance'});await api(`/api/workbench/projects/${project.id}/stages/storyboard`,{content:{shots:[{id:'s1',scene:'1',shot_size:'远景',description:'隔离的海岸镜头,纸船驶向灯塔。',duration_sec:5}]}},'PATCH'); +const server=http.createServer((req,res)=>{res.setHeader('Content-Type','text/html;charset=utf-8');res.end(fs.readFileSync('../materials/夜片场-多主题交互样本.html'))});await new Promise(r=>server.listen(0,'127.0.0.1',r));const browser=await chromium.launch({args:['--no-sandbox']});const rows=[],errors=[]; +try{const c=await browser.newContext();await c.addInitScript(()=>{localStorage.setItem('aigc-lang','zh');localStorage.setItem('aigc-reduce-motion','0')});const p=await c.newPage(),s=await c.newPage();p.on('pageerror',e=>errors.push(e.message));await p.goto('http://127.0.0.1:5173/workbench/'+project.id+'?stage=storyboard');await p.getByRole('button',{name:'编辑',exact:true}).click();await p.locator('.shot-edit textarea').first().fill('HEL806 Toast 验证:在隔离海岸镜头加入新的纸船描述');await p.locator('[data-testid=stage-save-btn]').click();await p.locator('.toast').last().hover();await p.mouse.move(0,0);await p.locator('.toast .dismiss').last().focus(); +const message=await p.locator('.toast .msg').last().innerText(); +const style=loc=>loc.evaluate(e=>{const r=e.getBoundingClientRect(),s=getComputedStyle(e);return {x:r.x,y:r.y,width:r.width,height:r.height,...Object.fromEntries(['padding','borderRadius','backgroundColor','borderTopColor','boxShadow','fontSize','lineHeight','animationDuration','animationTimingFunction','transitionDuration'].map(k=>[k,s[k]]))}}); +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 s.setViewportSize({width,height});await p.evaluate(t=>document.documentElement.dataset.theme=t,theme);await s.goto('http://127.0.0.1:'+server.address().port);await s.evaluate(({theme,message})=>{go('project');document.documentElement.dataset.theme=theme;toast(message)}, {theme,message});await p.waitForTimeout(350); + const actual=await style(p.locator('.toast').last()),reference=await style(s.locator('.toast').last()),footer=await p.locator('.project-footer').boundingBox();assert(actual.y+actual.height<=footer.y,'toast clears fixed actions');assert.equal(actual.animationDuration,reference.animationDuration);assert.equal(actual.animationTimingFunction,reference.animationTimingFunction); + await p.screenshot({path:`${out}/project-${theme}-${width}.png`});await p.locator('.toast').last().screenshot({path:`${out}/toast-${theme}-${width}-actual.png`});await s.locator('.toast').last().screenshot({path:`${out}/toast-${theme}-${width}-reference.png`}); + await p.evaluate(()=>document.documentElement.dataset.reduce='1');assert.equal(await p.locator('.toast').last().evaluate(e=>getComputedStyle(e).animationName),'none');await p.evaluate(()=>document.documentElement.dataset.reduce='0');rows.push({theme,width,height,message,actual,reference,footer,gap:footer.y-actual.y-actual.height});} +await p.locator('.toast .dismiss').last().evaluate(e=>e.blur());await p.mouse.move(0,0);await p.locator('.toast').last().waitFor({state:'detached',timeout:5000});await p.locator('[data-testid=stage-confirm-btn]').click();assert.equal((await api(`/api/workbench/projects/${project.id}`)).stages.find(x=>x.stage_key==='storyboard').status,'confirmed');assert.equal(errors.length,0);console.log('PASS 12 toast style/timing pairs, reduce, footer clearance and real confirmation'); +}finally{fs.writeFileSync(out+'/results.json',JSON.stringify({rows,errors},null,2));await browser.close();await new Promise(r=>server.close(r))}})().catch(e=>{console.error(e);process.exitCode=1}); diff --git a/e2e/hel806-toast.mjs b/e2e/hel806-toast.mjs new file mode 100644 index 00000000..3733524e --- /dev/null +++ b/e2e/hel806-toast.mjs @@ -0,0 +1,16 @@ +// Deterministic timing regression: expiry, fade, repeated pause, resume, sticky and dismissal. +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import {createRequire} from 'node:module'; +const ts=createRequire(import.meta.url)('../calliope-web/node_modules/typescript'); +let time=0,seq=0;const pending=new Map(); +const saved={now:Date.now,setTimeout:globalThis.setTimeout,clearTimeout:globalThis.clearTimeout}; +Date.now=()=>time;globalThis.setTimeout=(fn,delay)=>{pending.set(++seq,{at:time+delay,fn});return seq};globalThis.clearTimeout=id=>pending.delete(id); +const tick=ms=>{const end=time+ms;for(;;){const next=[...pending].sort((a,b)=>a[1].at-b[1].at)[0];if(!next||next[1].at>end)break;time=next[1].at;pending.delete(next[0]);next[1].fn()}time=end}; +try{ + const {showToast,subscribeToasts,pauseToast,resumeToast,dismissToast}=await import('data:text/javascript;base64,'+Buffer.from(ts.transpileModule(fs.readFileSync(new URL('../calliope-web/src/lib/toast.ts',import.meta.url),'utf8'),{compilerOptions:{module:ts.ModuleKind.ESNext,target:ts.ScriptTarget.ES2022}}).outputText).toString('base64'));let items=[];const unsub=subscribeToasts(x=>items=x); + const first=showToast('one');tick(3199);assert.equal(items[0].leaving,undefined);tick(1);assert.equal(items[0].leaving,true);tick(299);assert.equal(items.length,1);tick(1);assert.equal(items.length,0); + const paused=showToast('paused');tick(1000);pauseToast(paused);tick(1000);pauseToast(paused);tick(5000);assert.equal(items[0].leaving,undefined);resumeToast(paused);tick(2199);assert.equal(items[0].leaving,undefined);tick(1);assert.equal(items[0].leaving,true);pauseToast(paused);resumeToast(paused);tick(300);assert.equal(items.length,0); + const sticky=showToast('sticky','info',0);tick(9000);assert.equal(items.length,1);dismissToast(sticky);assert.equal(items.length,0); + const closed=showToast('manual');dismissToast(closed);tick(4000);assert.equal(items.length,0);assert.equal(pending.size,0);unsub();console.log('PASS toast: 3200ms visible + 300ms fade, idempotent pause, remaining time, sticky/manual cleanup'); +}finally{Date.now=saved.now;globalThis.setTimeout=saved.setTimeout;globalThis.clearTimeout=saved.clearTimeout} diff --git a/e2e/hel806.cjs b/e2e/hel806.cjs new file mode 100644 index 00000000..9b6504fe --- /dev/null +++ b/e2e/hel806.cjs @@ -0,0 +1,135 @@ +// Foreground real isolated API audit. Reference DOM changes only content, never CSS. +const {chromium}=require(process.env.PLAYWRIGHT_MODULE_PATH||'playwright'); +const fs=require('node:fs'),http=require('node:http'),path=require('node:path'),assert=require('node:assert/strict'); +const OUT=process.env.HEL806_OUT||'../evidence/hel806-final',WEB='http://127.0.0.1:5173',API='http://127.0.0.1:8247'; +const result={rows:[],checks:[],errors:[],blocked:[],requests:[]}; +const api=async(p,body,method)=>{const r=await fetch(API+p,{method:method||(body?'POST':'GET'),headers:{'Content-Type':'application/json'},body:body?JSON.stringify(body):undefined});if(!r.ok)throw Error(p+' '+await r.text());return r.json()}; +const ok=(name,value)=>{assert(value,name);result.checks.push(name);console.log('PASS',name)}; +const wait=ms=>new Promise(r=>setTimeout(r,ms)); +const metrics=(p,sels)=>p.evaluate(sels=>Object.fromEntries(Object.entries(sels).map(([key,sel])=>{const e=document.querySelector(sel);if(!e)return[key,null];const r=e.getBoundingClientRect(),s=getComputedStyle(e);return[key,{x:r.x,y:r.y,width:r.width,height:r.height,...Object.fromEntries(['fontSize','fontWeight','lineHeight','borderRadius','borderTopWidth','borderTopColor','backgroundColor','backgroundImage','color','padding','boxShadow','animationDuration','animationTimingFunction'].map(k=>[k,s[k]]))}]})),sels); +(async()=>{ + fs.mkdirSync(OUT+'/shots',{recursive:true}); + const f=JSON.parse(fs.readFileSync('e2e/shots/reference/fixtures.json')); + const settings=await api('/api/settings');ok('database is disposable',settings.data_dir.includes('e2e/shots/reference')); + const base=(await api('/api/workflows/'+f.dual)).workflow_json; + const img={'class_type':'LoadImage',inputs:{image:''},_meta:{title:'(Input:image) 输入图'}}; + const wf=async(name,kind,extra)=>api('/api/workflows',{name,kind,workflow_json:{...base,...extra}}); + const edit=await wf('HEL806 · 图生图真实输入','image',{'5':img}); + const mask=await wf('HEL806 · 遮罩真实输入','image',{'5':img,'6':{class_type:'LoadImageMask',inputs:{image:'',channel:'red'},_meta:{title:'(Input:mask) 遮罩'}}}); + const ref=await wf('HEL806 · 视频参考真实输入','video',{'5':img,'9':{class_type:'VHS_VideoCombine',inputs:{},_meta:{title:'(Output:video) 视频输出'}}}); + const long=await wf('HEL806 · 真实长文件名 · Qwen_Image_2_1_局部重绘_批量蒙版_参数映射_最终审核版本_20261023.json','image',{}); + await api('/api/workflows/'+long.id,{is_enabled:false},'PATCH');await api('/api/workflows/'+ref.id,{usage:'ref2video',usage_source:'user',is_enabled:true},'PATCH'); + await new Promise((resolve,reject)=>{const socket=require('node:net').connect(18187,'127.0.0.1');socket.on('connect',()=>{socket.destroy();reject(Error('Failure fixture port must be unused'))});socket.on('error',e=>e.code==='ECONNREFUSED'?resolve():reject(e));socket.setTimeout(1000,()=>{socket.destroy();reject(Error('Failure fixture probe timeout'))})}); + await api('/api/comfyui/endpoints',{name:'HEL806 · 故意不可达的隔离连接',base_url:'http://127.0.0.1:18187',auth_type:'none'}); + const sourceFile='4-视频生成/Minimax-h3/MiniMax_H3_音频MV_多参长视频分段_Selflift双采潜放大_Qwen3.8官方Skills自动提示词.json'; + const sourceBytes=fs.readFileSync(path.join('example_ComfyUI_workflows',sourceFile)); + const imported=await api('/api/workflows/import-batch',{files:[{source_path:sourceFile,workflow_json:JSON.parse(sourceBytes.toString('utf8').replace(/^\uFEFF/,''))}]}); + ok('real long repository filename imported without generation',imported.imported===1); + await api('/api/workflows/'+imported.imported_ids[0],{name:'HEL806 · 真文件 · '+path.basename(sourceFile)},'PATCH'); + fs.writeFileSync(OUT+'/import-report.json',JSON.stringify({sourceFile,source_sha256:require('node:crypto').createHash('sha256').update(sourceBytes).digest('hex'),imported,workflow:await api('/api/workflows/'+imported.imported_ids[0])},null,2)); + const project=await api('/api/projects',{title:'HEL806 · 海岸来信',idea:'纸船带回一片树叶'}); + const stages={script:{text:'第一场:清晨的海岸,女孩把一只纸船放入海水。她等候着父亲的归来。第二场:纸船带回一片树叶,女孩望向海平面,知道旅程才刚刚开始。'},style:{directions:[{id:'s1',name:'晨光',description:'柔和暖光',prompt:'warm'},{id:'s2',name:'蓝调',description:'冷光',prompt:'blue'}]},storyboard:{shots:Array.from({length:12},(_,i)=>({id:'b'+i,scene:'1',shot_size:'远景',camera:'固定',description:'女孩沿着海岸走向灯塔,纸船随海风起伏。',duration_sec:5,dialog:''}))},assets:{assets:[{id:'a1',kind:'character',name:'海边女孩',description:'隔离角色',prompt:'girl'}]},shot:{shots:[{id:'s1',shot_no:'S1',description:'女孩走向灯塔',prompt:'girl on coast',duration_sec:5}]}}; + const stagePath=s=>`/api/workbench/projects/${project.id}/stages/${s}`; + for(const [s,content]of Object.entries(stages))await api(stagePath(s),{content},'PATCH'); + await api(stagePath('storyboard')+'/confirm',{}); + await api(stagePath('storyboard'),{content:{shots:stages.storyboard.shots.map((x,i)=>i?x:{...x,description:'等待确认的新草稿'})}},'PATCH'); + fs.writeFileSync(OUT+'/inputs.json',JSON.stringify({f,edit:await api('/api/workflows/'+edit.id),mask:await api('/api/workflows/'+mask.id),ref:await api('/api/workflows/'+ref.id),long:await api('/api/workflows/'+long.id),project,stages},null,2)); + if(process.env.HEL806_SEED_TASKS==='1'){ + const seeded=[];for(const mode of ['ok','fail']){fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode,delay_sec:0,unique_filename:true,image_file:path.resolve('calliope-web/static/refract/coast.jpg')}));const created=await api('/api/playground/generate',{workflow_id:f.dual,source:'studio-image',input_values:{'1':'HEL806 isolated '+mode,'2':'模糊','3':42}});let job;for(let i=0;i<200;i++){job=await api('/api/jobs/'+created.job.id);if(!['running','pending'].includes(job.status))break;await wait(150)}assert.equal(job.status,mode==='ok'?'done':'failed');seeded.push(job)}fs.writeFileSync(OUT+'/seed-jobs.json',JSON.stringify(seeded,null,2)); + } + const sample=http.createServer((req,res)=>{res.setHeader('Content-Type','text/html;charset=utf-8');res.end(fs.readFileSync('../materials/夜片场-多主题交互样本.html'))});await new Promise(r=>sample.listen(0,'127.0.0.1',r)); + const browser=await chromium.launch({args:['--no-sandbox','--disable-dev-shm-usage']}); + try{ + const c=await browser.newContext({viewport:{width:1440,height:900},recordVideo:{dir:OUT+'/recordings'}}); + await c.addInitScript(()=>{localStorage.setItem('aigc-lang','zh');localStorage.setItem('aigc-reduce-motion','1')}); + await c.route('**/*',route=>{const u=new URL(route.request().url());if(['data:','blob:'].includes(u.protocol)||['127.0.0.1','localhost'].includes(u.hostname)){if(u.pathname.startsWith('/api/'))result.requests.push([route.request().method(),u.pathname]);return route.continue()}result.blocked.push(u.origin);return route.abort()}); + const p=await c.newPage(),s=await c.newPage();p.setDefaultTimeout(12000);p.on('pageerror',e=>result.errors.push(e.message));p.on('dialog',d=>d.accept()); + const goto=async route=>{await p.goto(WEB+route);await p.locator('aside.sidebar').first().waitFor();await wait(220)}; + const upload=async()=>{await p.getByRole('button',{name:'管理素材',exact:true}).click();const inputs=p.locator('.a-slot input[type=file]');for(let i=0;i{await goto('/create?kind='+kind+'&wf='+id);await p.locator('#desk-prompt').waitFor();const w=await api('/api/workflows/'+id);await p.locator('.rail-search input').fill(w.name);await wait(150)}; + const emptyRoute=async(route,pattern,json)=>{await p.route(pattern,r=>r.fulfill({json}));await goto(route)}; + const generate=async(id,kind)=>{fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode:'ok',delay_sec:0,unique_filename:true,videos:kind==='video',image_file:path.resolve('calliope-web/static/refract/coast.jpg')}));await creative(id,kind);await p.locator('#desk-prompt').fill('HEL806 successful isolated output');const before=Math.max(0,...(await api('/api/playground/jobs')).map(j=>j.id));await p.locator('.gen').click();let job;for(let i=0;i<200;i++){job=(await api('/api/playground/jobs')).find(j=>j.id>before&&j.workflow_id===id&&j.status==='done');if(job)break;await wait(150)}assert(job,'new successful isolated job');await p.locator('.result-title').filter({hasText:'第 '+job.id+' 次生成'}).waitFor();await p.locator(kind==='video'?'.print video':'.print img').waitFor({timeout:45000});await wait(800)}; + const videoWf=(await api('/api/workflows')).find(x=>x.name==='文生视频·回归'); + const cases=[ + {name:'image-output',ref:'create',run:()=>generate(f.dual,'image'),creative:true}, + {name:'video-output',ref:'create',run:()=>generate(videoWf.id,'video'),creative:true}, + {name:'image-failed',ref:'create',run:async()=>{await creative(f.dual);await p.locator('#desk-prompt').fill('HEL806 fake failure');fs.writeFileSync('e2e/fake_mode.json',JSON.stringify({mode:'fail',delay_sec:0}));await p.locator('.gen').click();await p.locator('.stage-empty').filter({hasText:'失败'}).waitFor({timeout:45000})},creative:true}, + {name:'studio-real',ref:'studio',run:()=>goto('/'),basis:'approved-cover-exception'}, + {name:'studio-empty',ref:'studio',run:()=>emptyRoute('/','**/api/projects',[]),missing:'原件没有无项目空态'}, + {name:'image-text-empty',ref:'create',run:async()=>{await p.route('**/api/playground/jobs',r=>r.fulfill({json:[]}));await creative(f.dual)},creative:true}, + {name:'image-long-prompt',ref:'create',run:async()=>{await creative(f.dual);await p.locator('#desk-prompt').fill('海边女孩、晨光、纸船与灯塔,保持人物和空间连续。'.repeat(70));const btn=p.getByRole('button',{name:'展开提示词',exact:true});if(await btn.count())await btn.click()},creative:true}, + {name:'image-edit-upload',ref:'create',run:async()=>{await creative(edit.id);await upload()},creative:true}, + {name:'image-mask-upload',ref:'create',run:async()=>{await creative(mask.id);await upload()},creative:true}, + {name:'video-first-last',ref:'create',run:async()=>{await creative(f.h3,'video');await upload()},creative:true}, + {name:'video-reference',ref:'create',run:async()=>{await creative(ref.id,'video');await upload()},creative:true}, + {name:'video-parameters',ref:'create',run:async()=>{await creative(f.h3,'video');await p.getByRole('button',{name:'创作设置⌄',exact:true}).first().click()},missing:'真实声明参数与原件固定参数内容不同;弹层公共框可比较'}, + ...Object.keys(stages).map(stage=>({name:'project-'+stage,ref:'project',run:async()=>{await goto('/workbench/'+project.id+'?stage='+stage);await p.locator('[data-testid=workbench-page]').waitFor()},projectStage:stage,...(stage==='storyboard'?{}:{missing:'原件renderProject切阶段后仍渲染同一分镜网格,无此阶段内容样本'})})), + {name:'project-compare',ref:'project',run:async()=>{await goto('/workbench/'+project.id+'?stage=storyboard');await p.getByRole('button',{name:'对比已确认版',exact:true}).click()},missing:'原件比较按钮没有比较弹窗实现'}, + {name:'project-confirmed',ref:'project',run:async()=>{await api(stagePath('storyboard')+'/confirm',{});await goto('/workbench/'+project.id+'?stage=storyboard')},projectStage:'storyboard'}, + {name:'workflows-long-disabled',ref:'workflows',run:async()=>{await goto('/workflows');await p.getByRole('textbox',{name:'搜索名称、文件名、模型…',exact:true}).fill('HEL806');await wait(100)},basis:'content-mapped-table'}, + {name:'connections-probed',ref:'models',run:async()=>{await goto('/connections');await p.getByText('连接测试通过',{exact:false}).first().waitFor()},basis:'content-mapped-cards'}, + {name:'connections-empty',ref:'models',run:()=>emptyRoute('/connections','**/api/settings',{...settings,comfyui_endpoints:[],comfyui_active_id:null}),missing:'原件没有无本地连接状态'}, + {name:'connections-edit',ref:'models',run:async()=>{await goto('/connections');await p.getByRole('button',{name:'编辑',exact:true}).first().click()},missing:'原件编辑按钮没有编辑表单实现'}, + {name:'models-llm',ref:'models',run:()=>goto('/connections?tab=llm'),missing:'原件大语言模型页签没有内容实现'}, + {name:'models-cloud-image',ref:'models',run:()=>goto('/connections?tab=image'),basis:'cloud-card-subset'}, + {name:'models-cloud-video',ref:'models',run:()=>goto('/connections?tab=video'),basis:'cloud-card-subset'}, + {name:'tasks-real',ref:'tasks',run:()=>goto('/tasks'),basis:'content-mapped-table'}, + {name:'tasks-empty',ref:'tasks',run:()=>emptyRoute('/tasks','**/api/jobs',[]),missing:'原件没有零任务空态'}, + {name:'library-real',ref:'library',run:()=>goto('/library'),basis:'content-mapped-media'}, + {name:'library-empty',ref:'library',run:()=>emptyRoute('/library','**/api/library/media',[]),missing:'原件没有零素材空态'}, + {name:'settings',ref:'settings',run:()=>goto('/settings'),basis:'approved-real-settings'}, + {name:'settings-invalid',ref:'settings',run:async()=>{await goto('/settings');await p.locator('input[type=number]').first().fill('0')},missing:'原件无数值校验提示的实现,保留真实字段校验界面'}, + {name:'canvas-current',ref:'canvas',run:()=>goto('/canvas'),missing:'原件仅组织说明页,待总管另补样本'}, + {name:'scene-current',ref:'canvas',run:async()=>{await goto('/build-scene');await p.locator('canvas').first().waitFor();await wait(1500)},missing:'原件仅组织说明页,待总管另补样本'} + ]; + for(const item of cases.filter(x=>!process.env.HEL806_CASES||process.env.HEL806_CASES==='*'||process.env.HEL806_CASES.split(',').includes(x.name))){ + await p.unrouteAll({behavior:'wait'});await item.run(); + 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 s.setViewportSize({width,height}); + await p.evaluate(t=>{document.documentElement.dataset.theme=t;window.dispatchEvent(new StorageEvent('storage',{key:'aigc-theme',newValue:t}))},theme); + await s.goto('http://127.0.0.1:'+sample.address().port);await s.evaluate(({ref,theme})=>{go(ref);document.documentElement.dataset.theme=theme;document.documentElement.classList.add('reduce');document.querySelector('#toasts').replaceChildren()}, {ref:item.ref,theme}); + const prefix=OUT+'/shots/'+item.name+'-'+theme+'-'+width; + await s.screenshot({path:prefix+'-original.png',animations:'disabled'}); + let mapping={}; + if(item.name==='studio-real'){ + const data=await p.evaluate(()=>({eye:document.querySelector('.studio-eyebrow').textContent,title:document.querySelector('.studio-display').innerText,em:document.querySelector('.studio-display em').textContent,description:document.querySelector('.hero-description').textContent,stages:[...document.querySelectorAll('.studio-stages>div')].map(e=>({text:e.textContent,done:e.classList.contains('done'),cur:e.classList.contains('cur')})),cards:[...document.querySelectorAll('.a-card')].map(e=>({title:e.querySelector('.title')?.textContent,status:e.querySelector('.status-tag')?.textContent,meta:e.querySelector('.meta')?.innerText,cover:e.querySelector('img')?.src})),confirm:[...document.querySelectorAll('.studio-side .confirm-item')].map(e=>e.innerText)}));mapping=data; + await s.evaluate(data=>{const hero=document.querySelector('#p-studio .hero');hero.querySelector('.eyebrow').textContent=data.eye;const d=hero.querySelector('.display'),em=document.createElement('em');em.textContent=data.em;d.replaceChildren(data.title.split('\n')[0],document.createElement('br'),em,' '+data.title.split('\n').slice(1).join(' ').replace(data.em,''));hero.querySelector('.copy p').textContent=data.description;hero.querySelector('.art').style.backgroundImage='none';hero.querySelector('.copy .row .btn:last-child').textContent='查看阶段草稿';hero.querySelectorAll('.stagebar>div').forEach((e,i)=>{e.classList.toggle('done',data.stages[i].done);e.classList.toggle('cur',data.stages[i].cur)});document.querySelectorAll('#p-studio .quick p')[1].textContent='粘贴剧本文本';const list=document.querySelector('#projGrid'),template=list.firstElementChild.cloneNode(true),add=list.lastElementChild.cloneNode(true);list.replaceChildren();for(const card of data.cards){const el=template.cloneNode(true);el.querySelector('.cv').style.backgroundImage=card.cover?`url("${card.cover}")`:'none';el.querySelector('.pb b').textContent=card.title;el.querySelector('.tag').textContent=card.status;el.querySelector('.pb>.row').textContent=card.meta;list.append(el)}list.append(add);document.querySelector('#p-studio .sec-h .tag').textContent=data.cards.length;},data); + } + if(item.creative){ + const id=+new URL(p.url()).searchParams.get('wf'),w=await api('/api/workflows/'+id); + const data=await p.evaluate(()=>({prompt:document.querySelector('#desk-prompt')?.value||'',negative:document.querySelector('#desk-negative')?.value||'',uploads:[...document.querySelectorAll('.media-token img')].map(e=>e.src),file:document.querySelector('.workflow-file')?.textContent,connection:document.querySelector('.studio-heading .conn')?.textContent,media:document.querySelector('.print img,.print video')?.src,ratio:(()=>{const e=document.querySelector('.print img,.print video');return e?((e.naturalWidth||e.videoWidth)/(e.naturalHeight||e.videoHeight)):null})(),failed:document.querySelector('.stage-empty')?.innerText?.includes('失败')})); + mapping={workflow:w.name,...data}; + await s.evaluate(({w,data,kind})=>{st.kind=kind;const slots=w.input_schema.filter(x=>['image','mask'].includes(x.kind)).map(x=>[x.role==='mask'?'mask':x.role==='first_frame'?'first':x.role==='last_frame'?'last':'input',1,1,true]);const mapped={...WF.find(x=>x.k===kind),id:w.id,k:kind,name:w.name,file:data.file||w.name,slots,neg:!!data.negative||w.input_schema.some(x=>x.role==='negative'),ready:true,pending:false};WF.splice(0,WF.length,mapped);st.sel[kind]=w.id;st.q=w.name;document.querySelector('#wfSearch').value=w.name;st.hist[kind]=data.media?[{n:1,k:kind,wf:w.id,ratio:data.ratio||1,seed:42,img:data.media}]:data.failed?[{n:1,k:kind,wf:w.id,fail:true}]:[];st.fills[w.id]={};slots.forEach((x,i)=>{if(data.uploads[i])st.fills[w.id][x[0]+i]=data.uploads[i]});renderCreate();document.querySelector('#posTa').value=data.prompt;document.querySelector('#negTa').value=data.negative;count();if(data.prompt.length>1000)document.querySelector('#dock').classList.add('tall')},{w,data,kind:new URL(p.url()).searchParams.get('kind')||'image'}); + } + if(item.projectStage==='storyboard'){ + const texts=await p.locator('.storyboard-card').allTextContents();mapping={project:project.title,shots:stages.storyboard.shots,texts}; + await s.evaluate(({title,shots,texts})=>{document.querySelector('#p-project .crumb b').textContent=title;document.querySelectorAll('#projShots .scard').forEach((e,i)=>{e.querySelector('.im').style.backgroundImage='none';e.querySelector('.bd p').textContent=i?'女孩沿着海岸走向灯塔,纸船随海风起伏。':(texts[0]?.includes('等待确认')?'等待确认的新草稿':'女孩沿着海岸走向灯塔,纸船随海风起伏。');e.querySelector('.bd b').textContent='远景';e.querySelector('.tc').textContent=String(i+1).padStart(2,'0')+' · 5s';e.querySelector('.st .tag').textContent='待画'});document.querySelector('#projTasks').replaceChildren();document.querySelector('#draftbar').classList.toggle('hide',!texts[0]?.includes('等待确认'))},{title:project.title,shots:stages.storyboard.shots,texts}); + } + if(item.name==='tasks-real'){ + const cells=await p.locator('.task-table tbody tr').evaluateAll(es=>es.map(e=>[...e.cells].map(c=>c.innerText))); + const thumbnails=await p.locator('.task-table tbody tr').evaluateAll(es=>es.map(e=>e.cells[0].querySelector('img')?.src||''));mapping={cells,thumbnails}; + await s.evaluate(({cells,thumbnails})=>{const tbody=document.querySelector('#taskTable'),template=tbody.firstElementChild.cloneNode(true),button=template.querySelector('button').cloneNode(true);tbody.replaceChildren();for(const [idx,cellsRow] of cells.entries()){const row=template.cloneNode(true);[...row.cells].forEach((e,i)=>{if(i===0)e.firstElementChild.style.backgroundImage=thumbnails[idx]?`url("${thumbnails[idx]}")`:'none';else if(i===1)e.querySelector('b').textContent=cellsRow[i];else if(i===5){const tag=e.querySelector('.tag');tag.textContent=cellsRow[i];tag.className='tag'+(cellsRow[i].includes('失败')?' err':cellsRow[i].includes('完成')?' ok':'');e.querySelector('.bar')?.remove()}else if(i===7){const b=button.cloneNode(true);b.textContent=cellsRow[i];b.className='btn sm'+(cellsRow[i].includes('重试')?'':' ghost');e.querySelector('.row').replaceChildren(b)}else e.textContent=cellsRow[i]||''});tbody.append(row)}},{cells,thumbnails}); + } + if(item.name==='workflows-long-disabled'){ + const cells=await p.locator('.mg-table tbody tr').evaluateAll(es=>es.map(e=>[...e.cells].map(c=>c.innerText)));mapping={cells}; + await s.evaluate(cells=>{const body=document.querySelector('#wfTable'),template=body.firstElementChild.cloneNode(true);body.replaceChildren();for(const vals of cells){const row=template.cloneNode(true);[...row.cells].forEach((e,i)=>{if(i===0){e.querySelector('b').textContent=vals[i].split('\n')[0];e.querySelector('small').textContent=vals[i].split('\n').slice(1).join(' ')}else if(i<5){const child=e.querySelector('.tag,.dim');if(child)child.textContent=vals[i];else e.textContent=vals[i]}});body.append(row)}},cells); + } + if(item.name==='library-real'){ + const media=await p.locator('.asset-preview img,.asset-preview video').evaluateAll(es=>es.map(e=>({src:e.src,kind:e.tagName})));for(const [i,m]of media.entries())if(m.kind==='VIDEO'){const video=p.locator('.asset-preview video').nth(media.slice(0,i).filter(x=>x.kind==='VIDEO').length);m.src='data:image/png;base64,'+(await video.screenshot()).toString('base64')};mapping={media}; + await s.evaluate(media=>{const grid=document.querySelector('#libGrid'),template=grid.firstElementChild.cloneNode(true);grid.replaceChildren();for(const m of media){const el=template.cloneNode(true);el.querySelector('img').src=m.src;el.querySelector('.tag')?.remove();grid.append(el)}},media); + } + if(item.name.startsWith('models-cloud'))await s.evaluate(kind=>{const cards=document.querySelector('#modelCards');[...cards.children].forEach((e,i)=>{if(kind==='image'?![2].includes(i):![3,4].includes(i))e.remove()});document.querySelectorAll('#p-models .seg button').forEach((e,i)=>e.classList.toggle('on',i===(kind==='image'?2:3)))},item.name.endsWith('image')?'image':'video'); + if(item.name==='connections-probed'){ + const cards=await p.locator('.mg-card').evaluateAll(es=>es.map(e=>e.innerText));mapping={cards};await s.evaluate(cards=>{const c=document.querySelector('#modelCards');const template=c.firstElementChild.cloneNode(true);const add=c.lastElementChild.cloneNode(true);const clouds=[...c.children].slice(2,5);c.replaceChildren();for(const text of cards.filter(x=>x.includes('http://'))){const e=template.cloneNode(true),lines=text.split('\n').filter(Boolean);e.querySelector('b').textContent=lines[0];e.querySelector('.mono').textContent=lines.find(x=>x.includes('http://'));e.querySelector('.muted').textContent=lines.find(x=>x.includes('队列未知'));e.querySelector('.lat').textContent=lines.find(x=>/^\d+ms$/.test(x))||'—';c.append(e)}c.append(...clouds,add)},cards); + } + if(item.creative)await s.evaluate(()=>renderViewport()); + await wait(80);await p.screenshot({path:prefix+'-actual.png',animations:'disabled'});await s.screenshot({path:prefix+'-mapped.png',animations:'disabled'}); + const actual=await metrics(p,{rail:'aside.sidebar',header:'.management-header,.studio-header,.studio-heading,.project-header',content:'.mg-main,.studio-hero,.reference-desk,.project-content,.mg-media',primary:'.dock .gen,[data-testid=stage-confirm-btn]',footer:'.project-footer',card:'.mg-card,.storyboard-card,.asset-card',input:'#desk-prompt',modal:'.modal-panel',frame:'.print',ring:'.desk-emblem'}); + const sampleValues=await metrics(s,{rail:'.rail',header:'#p-'+item.ref+' .ph',content:'#p-'+item.ref+' .mg-main,#p-'+item.ref+' .hero,#p-'+item.ref+' .create,#p-'+item.ref+' .proj-main,#libGrid',primary:'#genBtn,#confirmStage',footer:'#p-project .proj-foot',card:'#p-'+item.ref+' .mcard,#p-'+item.ref+' .scard,#libGrid>div',input:'#posTa',modal:'.pop.on',frame:'.frame,.player',ring:'.empty-stage .ring'}); + result.rows.push({name:item.name,theme,width,height,basis:item.missing?'missing-reference':item.basis||'content-map-partial',missing:item.missing,mapping,actual,sample:sampleValues}); + } + console.log('CAPTURED',item.name,12);fs.writeFileSync(OUT+'/results.json',JSON.stringify(result,null,2)); + } + await c.close();ok('no pageerror',result.errors.length===0); + }finally{fs.writeFileSync(OUT+'/results.json',JSON.stringify(result,null,2));await browser.close();await new Promise(r=>sample.close(r))} +})().catch(e=>{console.error(e);process.exitCode=1}); diff --git a/scripts/report-hel806.py b/scripts/report-hel806.py new file mode 100644 index 00000000..aaf71631 --- /dev/null +++ b/scripts/report-hel806.py @@ -0,0 +1,61 @@ +"""Package lossless original/content-mapped/actual captures; never infer visual approval.""" +from pathlib import Path +import concurrent.futures, hashlib, html, json, zipfile, csv +from PIL import Image, ImageDraw, ImageFont +ROOT=Path(__file__).resolve().parents[1] +OUT=ROOT.parent/'evidence/hel806-final' +REPORT=ROOT.parent/'evidence/hel806/report' +REPORT.mkdir(parents=True,exist_ok=True) +data=json.loads((OUT/'results.json').read_text()) +rows=[r for r in data['rows'] if r['name']!='toast'] +assert len(rows)==408, f'Expected 34 states x 12, got {len(rows)}' +assert len(rows)==len({(r['name'],r['theme'],r['width']) for r in rows}) +font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf',14) +manifest=[] +def convert(p): + im=Image.open(p).convert('RGB');q=p.with_suffix('.webp') + if not q.exists() or Image.open(q).convert('RGB').tobytes()!=im.tobytes():im.save(q,lossless=True,method=3) + assert Image.open(q).convert('RGB').tobytes()==im.tobytes() + return {'source':p.name,'sha256':hashlib.sha256(p.read_bytes()).hexdigest(),'delivered':q.name,'sha256_webp':hashlib.sha256(q.read_bytes()).hexdigest(),'pixels_identical':True} +with concurrent.futures.ThreadPoolExecutor(max_workers=4) as pool: + manifest=list(pool.map(convert, sorted((OUT/'shots').glob('*.png')))) +for r in rows: + stem=f"{r['name']}-{r['theme']}-{r['width']}" + pair_path=OUT/'shots'/(stem+'-pair.webp') + if pair_path.exists() and pair_path.stat().st_mtime>=max((OUT/'shots'/(stem+'-actual.webp')).stat().st_mtime,(OUT/'shots'/(stem+'-mapped.webp')).stat().st_mtime):continue + a=Image.open(OUT/'shots'/(stem+'-actual.webp')).convert('RGB');s=Image.open(OUT/'shots'/(stem+'-mapped.webp')).convert('RGB') + pair=Image.new('RGB',(a.width*2,a.height+32),'#181818');d=ImageDraw.Draw(pair) + d.text((10,8),'REFERENCE CONTENT MAPPED / '+r['basis'],font=font,fill='white');d.text((a.width+10,8),'ACTUAL ISOLATED API / '+stem,font=font,fill='white');pair.paste(s,(0,32));pair.paste(a,(a.width,32));pair.save(OUT/'shots'/(stem+'-pair.webp'),lossless=True,method=3) +# Twelve actual viewports per state, for layout inspection; native pairs remain available. +contacts=REPORT/'contacts';contacts.mkdir(exist_ok=True) +for name in sorted({r['name'] for r in rows}): + sheet=Image.new('RGB',(1920,3*302),'#202020');d=ImageDraw.Draw(sheet) + for r in [r for r in rows if r['name']==name]: + col=['night','day','grade','bluehour'].index(r['theme']);line=[1440,1366,1280].index(r['width']) + im=Image.open(OUT/'shots'/f"{name}-{r['theme']}-{r['width']}-actual.webp").convert('RGB');im.thumbnail((480,270));sheet.paste(im,(col*480,line*302+28));d.text((col*480+6,line*302+6),f"{name} / {r['theme']} / {r['width']}",font=font,fill='white') + sheet.save(contacts/(name+'.webp'),lossless=True) +# Source values, with no tolerance-based pass flag. A hidden region is not comparable. +with (REPORT/'key-values.csv').open('w') as f: + w=csv.writer(f);w.writerow(['state','theme','viewport','region','actual_xywh','reference_xywh','delta_xywh','basis']) + for r in rows: + for key,a in r['actual'].items(): + b=r['sample'].get(key) + if not a or not b or a['width']<=0 or b['width']<=0:continue + values=lambda o:[round(o[k],4) for k in ['x','y','width','height']] + av,bv=values(a),values(b);w.writerow([r['name'],r['theme'],f"{r['width']}x{r['height']}",key,av,bv,[round(x-y,4)for x,y in zip(av,bv)],r['basis']]) +(REPORT/'capture-manifest.json').write_text(json.dumps({'source_png_to_lossless_webp':manifest,'states':len({r['name']for r in rows}),'groups':len(rows),'errors':data['errors'],'blocked_external_origins':sorted(set(data['blocked']))},indent=2)) +# A theme archive is self-contained and opens without a running server. +for theme in ['night','day','grade','bluehour']: + theme_rows=[r for r in rows if r['theme']==theme] + intro='HEL806 '+theme+'

HEL806 '+theme+'

原图只读。mapped只映射内容;missing-reference 表示原件缺此状态。并排图左为映射参考,右为隔离实图,不代表全页通过。原始数值在results.json。

' + chunks=[intro] + for r in theme_rows: + stem=f"{r['name']}-{theme}-{r['width']}" + chunks.append('
'+html.escape(stem+' · '+r['basis']+' · '+str(r.get('missing','')))+''+f'未改原图 · 内容映射参考 · 实图
') + with zipfile.ZipFile(REPORT/f'HEL806-{theme}.zip','w',zipfile.ZIP_DEFLATED,compresslevel=3) as z: + z.writestr('index.html','\n'.join(chunks));z.writestr('results.json',json.dumps(theme_rows,ensure_ascii=False,indent=2)) + for r in theme_rows: + stem=f"{r['name']}-{theme}-{r['width']}" + for suffix in ['original','mapped','actual','pair']: + p=OUT/'shots'/f'{stem}-{suffix}.webp';z.write(p,'shots/'+p.name) +print(json.dumps({'groups':len(rows),'states':len({r['name']for r in rows}),'archives':{p.name:p.stat().st_size for p in REPORT.glob('*.zip')}},indent=2))