fix(v3.8): restore verified review queue lifecycle
Restore the installed WIP v2 frontend byte-for-byte without reverting the current backend or Windows atomic-replace handling. Consume one-shot retry/restart intents on the supported queue path; await terminal storage readback and recover cached completed revisions. Exercise the supported queue lifecycle in 42 frontend regression cases, retain public-surface assertions, and refresh distribution hashes. CPU pytest: 1156 passed. Real-browser/GPU acceptance not performed. No workflow, README, Sampling, Audio, or backend changes.
This commit is contained in:
+7
-5
@@ -97,7 +97,7 @@ b470819f16fc179654dc1600721a63f0a5a14e777f4c004d574b499da6886ba5 public_api.py
|
||||
3a359a0467725cc292ccb4c86cf0c3d30bb6a114d01f5345792b09ea3d45441d state.py
|
||||
43ec4023dc06c941e5d7a04db4b8a89fb58d744ceb986f6eb9bf534d4fdcb87b temporal.py
|
||||
db08ce77cc5c5835f2403d4d589394090fa5d25ff3b1840312b2808e1bc203b7 tests/fixtures/v38_a3c_selective_refine_saved_workflow.json
|
||||
3eeed61b7ee519631825e5f89e9a441644c66e552fce4207927cb8536867c8b1 tests/conftest.py
|
||||
37227f6b8e5b8ea3d683399b9632bb5e606e851a1cf762faf482db94c234923c tests/conftest.py
|
||||
041289556cc621ea1857cbb8931ae41d817f69e084b2e8a7622e184a3197b61b tests/test_compatibility.py
|
||||
875ac33b5458ec5e8d845850ed495707c394436aaadb668a44f36f6a1b73764d tests/test_conditioning_modes.py
|
||||
2be669b6d21ec40a8b0e172b8ab431f82681f3c97c7de0935d87ad43b0ae8b4e tests/test_context_diagnostics.py
|
||||
@@ -173,7 +173,7 @@ ee4dd8f6eb8114706b2625b4471b041a0ea66198f9f825c63e913c896ed87530 tests/test_v38
|
||||
72a0e3cb334049b66dd36f52c826931067c242fa63557933fd667138b38d6e8d tests/test_v38_review_control.py
|
||||
83301839f08d275f5648d7782b6d96795e14b1ce79d722e83e57190fe52fb4aa tests/test_v38_review_execution_cap.py
|
||||
2fec519540e18c55682884647db9fa1c90902da7be3d62261f2801a5c5724a96 tests/test_v38_review_run_storage.py
|
||||
dfa174feed4b14d819d1c9f36381e5650e97da6d0e59de441895955dd107ff5f tests/test_v38_review_ui.py
|
||||
7facb5a236d90d8b02a57b49107010ab33393079b0fbd9bc37ebe09266c2f928 tests/test_v38_review_ui.py
|
||||
75697036f361a9b8ea74f69b15e408670f686c8c0e8a6c1d48fe059cc837d12a tests/test_v38_selective_second_pass_node.py
|
||||
8026a241301dfc4de518649305458a538ef17a0b1567b113877a2af377738528 tests/test_v38_temporal_window_refine.py
|
||||
0dbe8a5f71c92f3523942343b40787104c8b96781461ba3ba82934a6bdbe5834 THIRD_PARTY_NOTICES.md
|
||||
@@ -241,12 +241,12 @@ c2883272b05a9a9146b5c6cf614ddae8a3e6893cd910902023aae61360195289 web/easy_bypas
|
||||
9db0aa94f634578a962d5db49e5c70356040a59df968e3a2e531b327a623081f web/easy_load_image.js
|
||||
873efcbd15c2d9fa10c9d5fc51a796ad3a18c0c6acceecf499c4b956aa845c6c web/easy_load_video.js
|
||||
0c68d13a1f8beb7431a32b471f8b0612c42fcc4bf72dd97611a025d158008662 web/easy_v38.js
|
||||
613797b621f07813b7c13417766f6f87aab92eb4c049ddd692577b226f46a894 web/project_id.js
|
||||
fd2876747fbdee41f223afa756d1be2a0e42a4025221d6557ca40647237f53f6 web/project_id.js
|
||||
be0b8d39e5343680ebea815c3a4fb6ce7a32e065f30e43e013040a40f702cef3 .comfyignore
|
||||
1d2838cc47694609289ea15132872ad48e1b6c8274da4b7bf188dd3ebf066121 docs/V38_RELEASE_AND_MIGRATION.md
|
||||
69d0e95d4d8ed8414e9bfb9bbbcb6183efa6d27f27cc8c6dd2f84c9cc5ce3439 tests/test_v38_public_surface_cleanup.py
|
||||
abaaf46043bc17958bbe2d22c7961993682c49a3ac37d44ef68aa2133482a539 tests/test_v38_public_surface_cleanup.py
|
||||
0cf8d49bcb71b30437dc893f6218dc4cfb1cd244b647e4fbc2861dea2271a33a web/reference_audio_ui.js
|
||||
88a9426baa14dc99ecd643cdf58e46e780672d86088b2897aa66952c56b3c126 REGISTRY_MANIFEST.sha256
|
||||
4a1d3eb513f1bf6742ba47d4d963da97e5b611744e7238a9fdc7f031ce8c481a REGISTRY_MANIFEST.sha256
|
||||
717577efdec5e61600504b77bc2a099ef022c4fe2333e936c3310c7182d8f2a0 docs/V38_OPEN_INTEGRATION_CONTRACT.md
|
||||
623d528a02b6712cba28c374ba3ad979bc84e2ac5318640692589a04ba6ab15f tests/test_v38_open_integration_contract.py
|
||||
0bc369ee428b8a5bc8e370a81fbab427262a1fdb7805a78c442c91698d65efba tools/__init__.py
|
||||
@@ -254,3 +254,5 @@ be0b8d39e5343680ebea815c3a4fb6ce7a32e065f30e43e013040a40f702cef3 .comfyignore
|
||||
bb5a1530c890d357dc48ea74039340d746e876e8f85e06d4d9a19369f8ff5961 tests/test_v38_hover_help.py
|
||||
3d681ded5d4c50cc20c2382e29fdc98d8a48e76d552c41ad5a195d941e66e612 .gitattributes
|
||||
83d28cc0cd549066962dc21ceae05d2b189fe22391b556887eab2cc1800e1e80 examples/workflows/MiniMax_H3_Continuum_V38.zip
|
||||
b0d511fa0cce7e33cea8d016f36f1ce25724a5ed82a08bfcf91954cd5802ab70 tests/frontend_review_queue.cjs
|
||||
c98ef5e0431c1dc071e0a18a5904e57fb4b6d226ea5f5996756876cc93173607 tests/test_v38_completed_review_ui.py
|
||||
|
||||
@@ -100,6 +100,6 @@ c2883272b05a9a9146b5c6cf614ddae8a3e6893cd910902023aae61360195289 web/easy_bypas
|
||||
9db0aa94f634578a962d5db49e5c70356040a59df968e3a2e531b327a623081f web/easy_load_image.js
|
||||
873efcbd15c2d9fa10c9d5fc51a796ad3a18c0c6acceecf499c4b956aa845c6c web/easy_load_video.js
|
||||
0c68d13a1f8beb7431a32b471f8b0612c42fcc4bf72dd97611a025d158008662 web/easy_v38.js
|
||||
613797b621f07813b7c13417766f6f87aab92eb4c049ddd692577b226f46a894 web/project_id.js
|
||||
fd2876747fbdee41f223afa756d1be2a0e42a4025221d6557ca40647237f53f6 web/project_id.js
|
||||
0cf8d49bcb71b30437dc893f6218dc4cfb1cd244b647e4fbc2861dea2271a33a web/reference_audio_ui.js
|
||||
83d28cc0cd549066962dc21ceae05d2b189fe22391b556887eab2cc1800e1e80 examples/workflows/MiniMax_H3_Continuum_V38.zip
|
||||
|
||||
@@ -15,3 +15,29 @@ if PACKAGE_NAME not in sys.modules:
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
module.__path__ = [str(ROOT)]
|
||||
sys.modules[PACKAGE_NAME] = module
|
||||
|
||||
|
||||
# Run real production JS through ComfyUI's supported queue lifecycle once.
|
||||
# No unsupported beforeQueuePrompt helper injection or copied UI predicates.
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def review_queue_results():
|
||||
node = shutil.which("node")
|
||||
assert node, "Node.js is required for the frontend regression gate"
|
||||
result = subprocess.run(
|
||||
[node, str(ROOT / "tests" / "frontend_review_queue.cjs")],
|
||||
env={**os.environ, "H3_TEST_ROOT": str(ROOT)},
|
||||
capture_output=True, text=True, encoding="utf-8", timeout=45,
|
||||
)
|
||||
records = json.loads(result.stdout)
|
||||
assert len(records) == 42, "The complete queue fixture must finish"
|
||||
failures = [item for item in records if not item["pass"]]
|
||||
assert result.returncode == 0 and not failures, result.stdout + result.stderr
|
||||
return {item["name"]: item for item in records}
|
||||
|
||||
@@ -0,0 +1,397 @@
|
||||
// Runs the supplied frontend, not copied predicates. No GPU or ComfyUI server.
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const vm = require('node:vm');
|
||||
const { webcrypto } = require('node:crypto');
|
||||
const ROOT = process.env.H3_TEST_ROOT || path.resolve(__dirname,'..');
|
||||
const results=[];
|
||||
const sleep=()=>new Promise(r=>setImmediate(r));
|
||||
function project(n=1,total=3,id='r1',run='fixture') {
|
||||
let parent=null;
|
||||
const groups=Array.from({length:n},(_,i)=>{
|
||||
const g={revision_id:`${id}-g${i+1}`,parent_revision_id:parent,lineage_sha256:'lineage',
|
||||
revision_order:String(i+1),take_number:1,group:{start:i+1,end:i+1,physical_group:i+1}};
|
||||
parent=g.revision_id;return g;
|
||||
});
|
||||
return {run_name:run,run_storage_schema_version:3,branch_provenance_version:1,
|
||||
canonical_storage_revision_id:id,canonical_head_revision_id:parent,
|
||||
canonical_chain:groups.map(g=>g.revision_id),
|
||||
active_revisions:Object.fromEntries(groups.map(g=>[String(g.group.physical_group),g.revision_id])),
|
||||
group_revisions:groups,revisions:[{revision_id:id,status:n===total?'complete':'review_ready',
|
||||
updated_utc:`2026-09-08T00:00:0${n}Z`,review_unit:{start:n,end:n,physical_group:n}}]};
|
||||
}
|
||||
function environment() {
|
||||
const listeners=new Map(), timers=new Set();
|
||||
let saved=null, postCount=0, fetchCount=0, nextError=null, queueHook=null, fetchHook=null;
|
||||
const submissions=[];
|
||||
const api={
|
||||
addEventListener(name,callback){const a=listeners.get(name)||[];a.push(callback);listeners.set(name,a);},
|
||||
async queuePrompt(number,data,options){
|
||||
submissions.push(structuredClone({number,data,options}));
|
||||
if(nextError){const e=nextError;nextError=null;throw e;}
|
||||
const response={prompt_id:`p${++postCount}`,number:postCount,node_errors:{}};
|
||||
if(queueHook)await queueHook(response,data);
|
||||
return response;
|
||||
},
|
||||
async fetchApi(url,opts){return fetcher(url,opts);}
|
||||
};
|
||||
async function fetcher(url,opts){
|
||||
fetchCount++;
|
||||
if(fetchHook)return fetchHook(url,opts);
|
||||
if(String(url).startsWith('/queue'))return {ok:true,status:200,json:async()=>({queue_running:[],queue_pending:[]})};
|
||||
return saved?{ok:true,status:200,json:async()=>structuredClone(saved)}:{ok:false,status:404,json:async()=>null};
|
||||
}
|
||||
const graph={_nodes:[],links:{},getNodeById(id){return this._nodes.find(n=>String(n.id)===String(id));}};
|
||||
const app={api,graph,ui:{settings:{getSettingValue:(_id,fallback)=>fallback,addSetting(){}}},registerExtension(e){this.extension=e;}};
|
||||
const sandbox={console,app,api,globalThis:null,crypto:webcrypto,fetch:fetcher,structuredClone,
|
||||
setTimeout(cb,ms){const t=setTimeout(()=>{timers.delete(t);cb();},ms);timers.add(t);return t;},
|
||||
clearTimeout(t){clearTimeout(t);timers.delete(t);}, Map, Set, WeakMap, Uint8Array};
|
||||
sandbox.globalThis=sandbox;
|
||||
const src=fs.readFileSync(path.join(ROOT,'web/project_id.js'),'utf8')
|
||||
.replace(/import \{ app \} from "\.\.\/\.\.\/scripts\/app.js";/,'')
|
||||
.replace(/import \{ api \} from "\.\.\/\.\.\/scripts\/api.js";/,'')
|
||||
.replace(/import \{ normalizeReferenceAudioLabels \} from "\.\/reference_audio_ui.js";/,'function normalizeReferenceAudioLabels() {}');
|
||||
vm.runInNewContext(src+`\nglobalThis.testFns={configureNode,loadTakeHistory,prepareReviewQueueIntent,takeCatalog,selectTakeOffset,selectTakeAction,reviewStatus,reviewSettingsChanged,synchronizeReviewQueue};`,sandbox);
|
||||
app.extension.setup();
|
||||
const f=sandbox.testFns;
|
||||
function makeNode(id=312,run='fixture'){
|
||||
const v={prompt_mode:'Auto',chunks:3,chunk_seconds:5,aspect:'Auto from First Image',
|
||||
preset:'Draft — 0.30 MP',custom_mp:.3,continuity:'Balanced — 22 frames',base_seed:123,
|
||||
control_after_generate:'fixed',audio_continuity:true,continuation_backend:'Standard',
|
||||
run_storage:'Save + Auto Resume',reroll_from_chunk:'Auto',reroll_nonce:0,run_name:run,
|
||||
project_id:'550e8400-e29b-41d4-a716-446655440000',reference_size:'Match Output',
|
||||
video_reference_size:'Efficient - 0.4 MP',diagnostics:'Basic',strict_compatibility:false,
|
||||
debug:false,show_preview:true,generation_mode:'Full Run',review_action:'Continue / Next',
|
||||
take_group:0,take_revision_id:'',take_action:'Automatic',size_source:'Manual',width:544,height:544};
|
||||
const n={id,graph,comfyClass:'H3ContinuumSamplerV38',properties:{},inputs:[],size:[500,500],
|
||||
widgets:Object.entries(v).map(([name,value])=>({name,value,type:typeof value==='number'?'number':'combo',options:{values:[]},computeSize:()=>[120,20]})),
|
||||
addWidget(type,name,value,callback,options){const w={type,name,value,callback,options:options||{},computeSize:()=>[120,20]};this.widgets.push(w);return w;},
|
||||
addCustomWidget(w){this.widgets.push(w);return w;},setDirtyCanvas(){},
|
||||
serialize(){return {widgets_values:this.widgets.map(w=>w.value)};},
|
||||
configure(info){info.widgets_values.forEach((v,i)=>{if(this.widgets[i])this.widgets[i].value=v;});}
|
||||
};
|
||||
graph._nodes.push(n);f.configureNode(n);return n;
|
||||
}
|
||||
const w=(n,name)=>n.widgets.find(w=>w.name===name);
|
||||
async function inputs(n){
|
||||
for(const x of n.widgets)x.beforeQueued?.();
|
||||
const i={};for(const [index,x] of n.widgets.entries()){
|
||||
if(!x.name||x.options?.serialize===false)continue;
|
||||
i[x.name]=x.serializeValue?await x.serializeValue(n,index):x.value;
|
||||
}return i;
|
||||
}
|
||||
async function queue(n,options){const i=await inputs(n);const data={output:{[n.id]:{class_type:n.comfyClass,inputs:i}},workflow:n.serialize()};
|
||||
const result=await api.queuePrompt(0,data,options);
|
||||
for(const x of n.widgets)x.afterQueued?.({isPartialExecution:false});return result;}
|
||||
async function emit(type,detail){await Promise.all((listeners.get(type)||[]).map(cb=>cb({type,detail})));await sleep();await sleep();}
|
||||
return {f,api,app,w,inputs,queue,emit,makeNode,submissions,setSaved:p=>{saved=p;},
|
||||
getSaved:()=>saved,getFetchCount:()=>fetchCount,setQueueHook:h=>queueHook=h,setFetchHook:h=>fetchHook=h,
|
||||
failQueue:e=>nextError=e,visible:(n,name)=>!w(n,name)?.hidden,
|
||||
async load(n,p){saved=p;await f.loadTakeHistory(n,{force:true});n.__h3ContinuumIntuitiveUxRefresh?.();},
|
||||
close(){for(const t of timers)clearTimeout(t);}
|
||||
};
|
||||
}
|
||||
async function test(name,body){const e=environment();try{await body(e);results.push({name,pass:true});}catch(err){results.push({name,pass:false,error:err.stack});}finally{e.close();}}
|
||||
(async()=>{
|
||||
await test('no sampler executed: accepted prompt and committed readback open Review',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');
|
||||
const q=await e.queue(n);e.setSaved(project(1));await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert(e.visible(n,'Use it and continue'),'review Continue is missing');
|
||||
const i=await e.inputs(n);assert.equal(i.reroll_from_chunk,'Auto');
|
||||
});
|
||||
await test('changing Full to Review preserves append intent and manual boundaries',async e=>{
|
||||
const n=e.makeNode();await e.load(n,project(3,3));e.w(n,'chunks').value=5;e.w(n,'Run').callback('Review Each Chunk');
|
||||
await e.queue(n);assert.equal(e.submissions.at(-1).data.output['312'].inputs.reroll_from_chunk,'Auto');
|
||||
e.w(n,'reroll_from_chunk').value='Chunk 3';await e.queue(n);assert.equal(e.submissions.at(-1).data.output['312'].inputs.reroll_from_chunk,'Chunk 3');
|
||||
});
|
||||
await test('three review queues advance without any executed events',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');
|
||||
for(let i=1;i<=3;i++){
|
||||
const q=await e.queue(n);assert.equal(e.submissions.at(-1).data.output['312'].inputs.reroll_from_chunk,'Auto');
|
||||
e.setSaved(project(i));await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert.equal(e.visible(n,'Use it and continue'),i<3);
|
||||
assert(e.visible(n,'Try this chunk again'));
|
||||
if(i<3)e.w(n,'Use it and continue').callback();
|
||||
}
|
||||
});
|
||||
await test('unrelated terminal never reloads or clears another queued node',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');await e.queue(n);
|
||||
const before=e.getFetchCount();await e.emit('execution_error',{prompt_id:'unrelated'});
|
||||
assert.equal(e.getFetchCount(),before);assert(n.__h3ContinuumModeSetup);
|
||||
});
|
||||
await test('sampler saved, downstream failed: recover saved output, do not advance',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.setSaved(project(1));await e.emit('execution_error',{prompt_id:q.prompt_id,node_id:'vae'});
|
||||
assert(e.visible(n,'Retry saved output'));assert(!e.visible(n,'Use it and continue'));
|
||||
assert.match(e.f.reviewStatus(n),/saved.*incomplete/i);
|
||||
e.w(n,'Retry saved output').callback();const retry=await e.queue(n);
|
||||
const inputs=e.submissions.at(-1).data.output['312'].inputs;
|
||||
assert.equal(inputs.take_action,'Use This Take');assert.equal(inputs.take_revision_id,'r1-g1');
|
||||
e.setSaved(project(1,3,'output-retry'));await e.emit('execution_success',{prompt_id:retry.prompt_id});
|
||||
assert(!n.__h3ContinuumOutputFailure);assert(e.visible(n,'Use it and continue'));
|
||||
});
|
||||
await test('interruption before commit retains intent without inventing a saved result',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
await e.emit('execution_interrupted',{prompt_id:q.prompt_id});
|
||||
assert(!e.visible(n,'Use it and continue'));assert(!n.__h3ContinuumOutputFailure);
|
||||
const next=await e.inputs(n);assert.equal(next.reroll_from_chunk,'Auto');
|
||||
});
|
||||
await test('queue rejection preserves one-shot retry for resubmission',async e=>{
|
||||
const n=e.makeNode();e.w(n,'generation_mode').value='Review Each Chunk';await e.load(n,project(1));
|
||||
e.w(n,'Try this chunk again').callback();assert.equal(e.w(n,'review_action').value,'Regenerate Current');
|
||||
e.failQueue(new Error('validation failed'));await assert.rejects(e.queue(n),/validation failed/);
|
||||
assert.equal(e.w(n,'review_action').value,'Regenerate Current');
|
||||
await e.queue(n);assert.equal(e.submissions.at(-1).data.output['312'].inputs.review_action,'Regenerate Current');
|
||||
assert.equal(e.w(n,'review_action').value,'Continue / Next');
|
||||
});
|
||||
await test('history browsing never changes serialized selection, explicit apply does',async e=>{
|
||||
const n=e.makeNode();e.w(n,'generation_mode').value='Review Each Chunk';await e.load(n,project(3,3));
|
||||
const before=await e.inputs(n);e.f.selectTakeOffset(n,-1);const after=await e.inputs(n);
|
||||
for(const k of ['take_group','take_revision_id','take_action'])assert.equal(after[k],before[k]);
|
||||
e.f.selectTakeAction(n,'Use This Take');assert.equal(e.w(n,'take_group').value,2);
|
||||
assert.equal(e.w(n,'take_revision_id').value,'r1-g2');
|
||||
e.f.selectTakeOffset(n,-1);const q=await e.queue(n);
|
||||
assert.equal(e.submissions.at(-1).data.output['312'].inputs.take_revision_id,'r1-g2');
|
||||
});
|
||||
await test('late response for an old Run cannot replace the current history',async e=>{
|
||||
const n=e.makeNode();await e.load(n,project(1));let release;
|
||||
e.setFetchHook(()=>new Promise(r=>release=r));const pending=e.f.loadTakeHistory(n,{force:true});
|
||||
e.w(n,'run_name').value='other';release({ok:true,status:200,json:async()=>project(2)});await pending;
|
||||
assert.notEqual(n.__h3ContinuumTakeProject?.canonical_storage_revision_id,'r2');
|
||||
assert.notEqual(n.__h3ContinuumTakeProject?.revisions[0]?.review_unit?.end,2);
|
||||
});
|
||||
await test('clearing Run identity invalidates an in-flight history request',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);let release;
|
||||
e.setFetchHook(()=>new Promise(r=>release=r));const pending=e.f.loadTakeHistory(n,{force:true});
|
||||
e.w(n,'run_name').value='';e.w(n,'project_id').value='';await e.f.loadTakeHistory(n);
|
||||
release({ok:true,status:200,json:async()=>project(1)});await pending;assert.equal(n.__h3ContinuumTakeProject,null);
|
||||
});
|
||||
await test('identical concurrent history reads are coalesced',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);let release;const before=e.getFetchCount();
|
||||
e.setFetchHook(()=>new Promise(r=>release=r));const a=e.f.loadTakeHistory(n);const b=e.f.loadTakeHistory(n);
|
||||
assert.equal(e.getFetchCount(),before+1);release({ok:true,status:200,json:async()=>project(1)});await Promise.all([a,b]);
|
||||
});
|
||||
await test('two accepted prompts for one node retain distinct identity',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');
|
||||
const p1=await e.queue(n),p2=await e.queue(n);
|
||||
e.setSaved(project(2,3,'newer'));await e.emit('execution_success',{prompt_id:p2.prompt_id});
|
||||
e.setSaved(project(1,3,'older'));const reads=e.getFetchCount();await e.emit('execution_success',{prompt_id:p1.prompt_id});
|
||||
assert.equal(e.getFetchCount(),reads);assert.equal(n.__h3ContinuumTakeProject.canonical_storage_revision_id,'newer');
|
||||
});
|
||||
await test('a different sampler completion cannot release this node setup',async e=>{
|
||||
const a=e.makeNode(312,'first'),b=e.makeNode(313,'second');
|
||||
await e.load(a,null);await e.load(b,null);e.w(a,'Run').callback('Review Each Chunk');e.w(b,'Run').callback('Review Each Chunk');
|
||||
await e.queue(a);const q=await e.queue(b);e.setSaved(project(1,3,'second-r','second'));
|
||||
await e.emit('execution_success',{prompt_id:q.prompt_id});assert(a.__h3ContinuumModeSetup);assert(!b.__h3ContinuumModeSetup);
|
||||
});
|
||||
await test('partial execution excluding sampler leaves its state untouched',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const reads=e.getFetchCount();
|
||||
const q=await e.queue(n,{partialExecutionTargets:['other-node']});e.setSaved(project(1));
|
||||
await e.emit('execution_success',{prompt_id:q.prompt_id});assert(n.__h3ContinuumModeSetup);assert.equal(reads,e.getFetchCount());
|
||||
});
|
||||
await test('early terminal before HTTP response is reconciled using the accepted ID',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');
|
||||
e.setQueueHook(async response=>{e.setSaved(project(1));await e.emit('execution_success',{prompt_id:response.prompt_id});});
|
||||
await e.queue(n);assert(e.visible(n,'Use it and continue'));assert(!n.__h3ContinuumModeSetup);
|
||||
});
|
||||
await test('the caller graph and workflow are not mutated by Queue adapter',async e=>{
|
||||
const n=e.makeNode();await e.load(n,project(1));e.w(n,'Run').callback('Review Each Chunk');
|
||||
const data={output:{'312':{class_type:n.comfyClass,inputs:await e.inputs(n)}},workflow:n.serialize()};
|
||||
const before=JSON.stringify(data);await e.api.queuePrompt(0,data);assert.equal(JSON.stringify(data),before);
|
||||
});
|
||||
await test('settings edited during execution remain out of date after readback',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.w(n,'base_seed').value=999;e.setSaved(project(1));await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert(e.f.reviewSettingsChanged(n));assert(!e.visible(n,'Use it and continue'));
|
||||
});
|
||||
await test('a later mode selection is not owned by an earlier prompt',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.w(n,'Run').callback('Generate Full Video');e.w(n,'Run').callback('Review Each Chunk');const marker=n.__h3ContinuumModeSetup;
|
||||
e.setSaved(project(1));await e.emit('execution_success',{prompt_id:q.prompt_id});assert.equal(n.__h3ContinuumModeSetup,marker);
|
||||
});
|
||||
await test('missing/failed history readback does not claim success',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.setFetchHook(async()=>{throw new Error('offline');});await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert(n.__h3ContinuumModeSetup);assert(!e.visible(n,'Use it and continue'));assert.match(n.__h3ContinuumTakeError,/offline/);
|
||||
});
|
||||
await test('fresh browser state can open persisted Review without prior events',async e=>{
|
||||
const n=e.makeNode();e.w(n,'generation_mode').value='Review Each Chunk';await e.load(n,project(2));
|
||||
assert(e.visible(n,'Use it and continue'));assert.match(e.f.reviewStatus(n),/Chunk 2/);
|
||||
});
|
||||
await test('optional executed notification alone never releases setup',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.setSaved(project(1));await e.emit('executed',{node:'312',prompt_id:q.prompt_id});assert(n.__h3ContinuumModeSetup);
|
||||
await e.emit('execution_success',{prompt_id:q.prompt_id});assert(!n.__h3ContinuumModeSetup);
|
||||
});
|
||||
await test('derived catalog is reused for one immutable readback',async e=>{
|
||||
const n=e.makeNode();await e.load(n,project(3,3));assert.equal(e.f.takeCatalog(n),e.f.takeCatalog(n));
|
||||
});
|
||||
await test('new Run identity cannot receive an older prompt result',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.w(n,'run_name').value='new-run';e.setSaved(project(1));const reads=e.getFetchCount();
|
||||
await e.emit('execution_success',{prompt_id:q.prompt_id});assert.equal(e.getFetchCount(),reads);assert(n.__h3ContinuumModeSetup);
|
||||
});
|
||||
|
||||
|
||||
await test('cancelled queued prompt releases busy state without inventing a chunk',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');await e.queue(n);
|
||||
e.setFetchHook(async url=>({ok:true,status:200,json:async()=>String(url).startsWith('/queue')
|
||||
?{queue_running:[],queue_pending:[]}:{}}));
|
||||
await e.emit('status',{exec_info:{queue_remaining:0}});
|
||||
assert.match(e.f.reviewStatus(n),/no longer pending/);assert(n.__h3ContinuumModeSetup);
|
||||
});
|
||||
await test('missed websocket completion is recovered from exact prompt history',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.setFetchHook(async url=>({ok:true,status:200,json:async()=>String(url).startsWith('/queue')
|
||||
?{queue_running:[],queue_pending:[]}:String(url).startsWith('/history/')
|
||||
?{[q.prompt_id]:{status:{messages:[['execution_success',{prompt_id:q.prompt_id}]]}}}:project(1)}));
|
||||
await e.emit('status',{exec_info:{queue_remaining:0}});
|
||||
assert(!n.__h3ContinuumModeSetup);assert(e.visible(n,'Use it and continue'));
|
||||
});
|
||||
await test('reconnect discovers the exact queued node/run after browser state loss',async e=>{
|
||||
const n=e.makeNode();e.w(n,'generation_mode').value='Review Each Chunk';await e.load(n,null);
|
||||
const inputs=await e.inputs(n);const queued=[1,'survived-prompt',{'312':{class_type:n.comfyClass,inputs}}, {},['312']];
|
||||
e.setFetchHook(async url=>({ok:true,status:200,json:async()=>String(url).startsWith('/queue')
|
||||
?{queue_running:[queued],queue_pending:[]}:project(1)}));
|
||||
await e.emit('reconnected',{});assert.match(e.f.reviewStatus(n),/Queued|progress/i);
|
||||
e.setFetchHook(null);e.setSaved(project(2));await e.emit('execution_success',{prompt_id:'survived-prompt'});
|
||||
assert(e.visible(n,'Use it and continue'));assert.match(e.f.reviewStatus(n),/Chunk 2/);
|
||||
});
|
||||
await test('connection error while reconciling is not treated as queue cancellation',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.setFetchHook(async()=>{throw new Error('network unavailable');});await e.emit('status',{exec_info:{queue_remaining:0}});
|
||||
assert(!n.__h3ContinuumQueueNotice);e.setFetchHook(null);e.setSaved(project(1));
|
||||
await e.emit('execution_success',{prompt_id:q.prompt_id});assert(e.visible(n,'Use it and continue'));
|
||||
});
|
||||
await test('terminal readback failure can recover on reconnect without another Sampling',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.setFetchHook(async()=>{throw new Error('readback offline');});await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
e.setFetchHook(async url=>({ok:true,status:200,json:async()=>String(url).startsWith('/queue')
|
||||
?{queue_running:[],queue_pending:[]}:String(url).startsWith('/history/')
|
||||
?{[q.prompt_id]:{status:{messages:[['execution_success',{prompt_id:q.prompt_id}]]}}}:project(1)}));
|
||||
await e.emit('reconnected',{});assert(!n.__h3ContinuumModeSetup);assert(e.visible(n,'Use it and continue'));
|
||||
assert.equal(e.submissions.length,1);
|
||||
});
|
||||
|
||||
|
||||
await test('linked chunk count does not block committed review readback',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');
|
||||
const inputs={...await e.inputs(n),chunks:['primitive',0]};
|
||||
const q=await e.api.queuePrompt(0,{output:{'312':{class_type:n.comfyClass,inputs},primitive:{class_type:'PrimitiveInt',inputs:{value:3}}},workflow:{}});
|
||||
e.setSaved(project(1));await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert(!n.__h3ContinuumModeSetup);assert(e.visible(n,'Use it and continue'));
|
||||
});
|
||||
await test('removing one sampler does not discard another accepted sampler',async e=>{
|
||||
const a=e.makeNode(312,'one'),b=e.makeNode(313,'two');await e.load(a,null);await e.load(b,null);
|
||||
e.w(a,'Run').callback('Review Each Chunk');e.w(b,'Run').callback('Review Each Chunk');
|
||||
const q=await e.api.queuePrompt(0,{output:{'312':{class_type:a.comfyClass,inputs:await e.inputs(a)},'313':{class_type:b.comfyClass,inputs:await e.inputs(b)}},workflow:{}});
|
||||
a.onRemoved();e.app.graph._nodes=e.app.graph._nodes.filter(n=>n!==a);
|
||||
e.setSaved(project(1,3,'two-r1','two'));await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert(e.visible(b,'Use it and continue'));
|
||||
});
|
||||
await test('same setup request is not mutated by legacy preparation then API preparation',async e=>{
|
||||
const n=e.makeNode();await e.load(n,project(3,3));e.w(n,'chunks').value=5;e.w(n,'Run').callback('Review Each Chunk');
|
||||
const inputs=await e.inputs(n);e.f.prepareReviewQueueIntent(n,inputs);const once=JSON.stringify(inputs);
|
||||
e.f.prepareReviewQueueIntent(n,inputs);assert.equal(JSON.stringify(inputs),once);
|
||||
await e.api.queuePrompt(0,{output:{'312':{class_type:n.comfyClass,inputs}},workflow:{}});
|
||||
assert.equal(JSON.stringify(e.submissions.at(-1).data.output['312'].inputs),once);
|
||||
});
|
||||
|
||||
|
||||
await test('mode selection preserves progress and still exposes an explicit restart',async e=>{
|
||||
const n=e.makeNode();await e.load(n,project(3,3));e.w(n,'Run').callback('Review Each Chunk');
|
||||
assert(e.visible(n,'Start again from Chunk 1'));
|
||||
e.w(n,'Start again from Chunk 1').callback();const q=await e.queue(n);
|
||||
assert.equal(e.submissions.at(-1).data.output['312'].inputs.reroll_from_chunk,'Chunk 1');
|
||||
assert.equal(e.w(n,'reroll_from_chunk').value,'Auto');
|
||||
e.setSaved(project(1,3,'explicit-restart'));await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert(e.visible(n,'Use it and continue'));
|
||||
});
|
||||
|
||||
|
||||
await test('persisted review repairs an unowned stale Chunk 1 boundary',async e=>{
|
||||
const n=e.makeNode();e.w(n,'reroll_from_chunk').value='Chunk 1';e.w(n,'generation_mode').value='Review Each Chunk';
|
||||
await e.load(n,project(1));
|
||||
assert.equal(e.w(n,'reroll_from_chunk').value,'Auto');
|
||||
assert(e.visible(n,'Use it and continue'));assert(e.visible(n,'Try this chunk again'));
|
||||
});
|
||||
await test('explicit advanced Regenerate From remains explicit after refresh',async e=>{
|
||||
const n=e.makeNode();e.w(n,'generation_mode').value='Review Each Chunk';await e.load(n,project(1));
|
||||
e.w(n,'reroll_from_chunk').value='Chunk 1';e.w(n,'reroll_from_chunk').callback?.('Chunk 1');
|
||||
await e.f.loadTakeHistory(n,{force:true});
|
||||
assert.equal(e.w(n,'reroll_from_chunk').value,'Chunk 1');
|
||||
assert.match(e.f.reviewStatus(n),/Regenerate from Chunk 1/);
|
||||
});
|
||||
await test('Progress Off cannot submit a stale Regenerate From boundary',async e=>{
|
||||
const n=e.makeNode();await e.load(n,project(1));
|
||||
e.w(n,'run_storage').value='Off';e.w(n,'reroll_from_chunk').value='Chunk 1';e.w(n,'generation_mode').value='Full Run';
|
||||
await e.queue(n);const sent=e.submissions.at(-1).data.output['312'].inputs;
|
||||
assert.equal(sent.run_storage,'Off');assert.equal(sent.reroll_from_chunk,'Auto');assert.equal(sent.reroll_nonce,0);
|
||||
assert.equal(e.w(n,'reroll_from_chunk').value,'Auto');
|
||||
});
|
||||
await test('successful Auto continue clears stale boundary and restores review buttons',async e=>{
|
||||
const n=e.makeNode();e.w(n,'generation_mode').value='Review Each Chunk';await e.load(n,project(1));
|
||||
e.w(n,'Use it and continue').callback();const q=await e.queue(n);
|
||||
assert.equal(e.submissions.at(-1).data.output['312'].inputs.reroll_from_chunk,'Auto');
|
||||
// Simulate stale hidden UI residue appearing after queue acceptance.
|
||||
e.w(n,'reroll_from_chunk').value='Chunk 1';
|
||||
e.setSaved(project(2));await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert.equal(e.w(n,'reroll_from_chunk').value,'Auto');
|
||||
assert(e.visible(n,'Use it and continue'));assert(e.visible(n,'Try this chunk again'));
|
||||
});
|
||||
|
||||
|
||||
await test('retry consumed after acceptance without legacy preparation hook',async e=>{
|
||||
const n=e.makeNode();e.w(n,'generation_mode').value='Review Each Chunk';await e.load(n,project(1));
|
||||
e.w(n,'Try this chunk again').callback();await e.queue(n);
|
||||
assert.equal(e.w(n,'review_action').value,'Continue / Next');
|
||||
await e.queue(n);assert.equal(e.submissions.at(-1).data.output['312'].inputs.review_action,'Continue / Next');
|
||||
});
|
||||
await test('explicit restart consumed and Chunk 1 Continue restored',async e=>{
|
||||
const n=e.makeNode();e.w(n,'generation_mode').value='Review Each Chunk';await e.load(n,project(3,3));
|
||||
assert(e.visible(n,'Start again from Chunk 1'));e.w(n,'Start again from Chunk 1').callback();
|
||||
const q=await e.queue(n);assert.equal(e.submissions.at(-1).data.output['312'].inputs.reroll_from_chunk,'Chunk 1');
|
||||
e.setSaved(project(1,3,'restarted'));await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert.equal(e.w(n,'reroll_from_chunk').value,'Auto');assert(e.visible(n,'Use it and continue'));
|
||||
});
|
||||
await test('850 ms terminal readback releases setup after it resolves',async e=>{
|
||||
const n=e.makeNode();await e.load(n,null);e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.setFetchHook(async()=>{await new Promise(r=>setTimeout(r,850));return {ok:true,status:200,json:async()=>project(1)};});
|
||||
await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert.equal(n.__h3ContinuumTakeProject.canonical_storage_revision_id,'r1');
|
||||
assert(!n.__h3ContinuumModeSetup);assert(e.visible(n,'Use it and continue'));
|
||||
});
|
||||
await test('same completed revision reuse exits setup without new Sampling',async e=>{
|
||||
const n=e.makeNode();e.w(n,'chunks').value=2;await e.load(n,project(2,2,'done'));
|
||||
e.w(n,'Run').callback('Review Each Chunk');const q=await e.queue(n);
|
||||
e.setSaved(project(2,2,'done'));await e.emit('execution_success',{prompt_id:q.prompt_id});
|
||||
assert(!n.__h3ContinuumModeSetup);assert(e.visible(n,'Try this chunk again'));assert(e.visible(n,'Start again from Chunk 1'));
|
||||
assert(!e.visible(n,'Use it and continue'));assert.equal(e.submissions.length,1);
|
||||
});
|
||||
await test('mode policy and transient UI serialization remain stable',async e=>{
|
||||
const n=e.makeNode();e.w(n,'run_storage').value='Off';e.w(n,'Run').callback('Review Each Chunk');
|
||||
assert.equal(e.w(n,'run_storage').value,'Save + Auto Resume');e.w(n,'Run').callback('Generate Full Video');
|
||||
assert.equal(e.w(n,'run_storage').value,'Save + Auto Resume');
|
||||
e.w(n,'Run').callback('Review Each Chunk');await e.load(n,project(1));e.w(n,'Return to Review').callback();
|
||||
const before=JSON.stringify(n.serialize());e.w(n,'Back to Settings').callback();e.w(n,'Return to Review').callback();
|
||||
assert.equal(JSON.stringify(n.serialize()),before);
|
||||
const p=project(2,2,'full-complete');delete p.revisions[0].review_unit;await e.load(n,p);
|
||||
assert(!e.visible(n,'Try this chunk again'));assert(e.visible(n,'Render History'));
|
||||
});
|
||||
await test('history catalog preserves lineage eligibility and compact summary',async e=>{
|
||||
const n=e.makeNode();e.w(n,'generation_mode').value='Review Each Chunk';const p=project(3,3);
|
||||
p.group_revisions.push({revision_id:'old',lineage_sha256:'other',group:{start:1,end:1,physical_group:1}},
|
||||
{revision_id:'orphan',parent_revision_id:'missing',lineage_sha256:'lineage',group:{start:2,end:2,physical_group:2}});
|
||||
await e.load(n,p);assert.equal(e.f.takeCatalog(n).length,3);
|
||||
e.w(n,'Render History').callback();const body=e.w(n,'Render History / Takes');
|
||||
assert(body.computeSize(400)[1]<=124);const drawn=[];
|
||||
body.draw({save(){},restore(){},beginPath(){},rect(){},clip(){},fillText(s){drawn.push(s);}},n,400,0,20);
|
||||
assert(drawn.length>1);assert(drawn.some(s=>s.startsWith('Selected:')));
|
||||
e.f.selectTakeOffset(n,-1);e.f.selectTakeAction(n,'Continue From Here');
|
||||
assert.equal(e.w(n,'take_revision_id').value,'r1-g2');assert.equal(e.w(n,'take_action').value,'Continue From Here');
|
||||
assert.equal(p.canonical_head_revision_id,'r1-g3');
|
||||
});
|
||||
|
||||
console.log(JSON.stringify(results,null,2));if(results.some(r=>!r.pass))process.exitCode=1;
|
||||
})();
|
||||
@@ -1,393 +1,11 @@
|
||||
"""Exercise the real frontend (not a copied visibility predicate) across its lifecycle."""
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_completed_review_lifecycle_with_real_frontend(tmp_path):
|
||||
node = shutil.which("node")
|
||||
assert node, "Node.js is required for this frontend gate"
|
||||
source = (Path(__file__).resolve().parents[1] / "web/project_id.js").read_text(encoding="utf-8")
|
||||
source = source.replace('import { app } from "../../scripts/app.js";',
|
||||
'const app = globalThis.__app;').replace(
|
||||
'import { normalizeReferenceAudioLabels } from "./reference_audio_ui.js";',
|
||||
'function normalizeReferenceAudioLabels() {}')
|
||||
harness = r'''
|
||||
const assert = require("node:assert/strict");
|
||||
let project = null;
|
||||
let fetchMode = "ok";
|
||||
globalThis.fetch = async () => {
|
||||
if (fetchMode === "error") throw new Error("offline fixture");
|
||||
return project ? {ok:true, status:200, json:async()=>structuredClone(project)} : {ok:false,status:404};
|
||||
};
|
||||
const apiListeners=new Map();
|
||||
globalThis.__app = {
|
||||
graph: {_nodes: [], links:{}, getNodeById:()=>null},
|
||||
ui:{settings:{getSettingValue:(_id,fallback)=>fallback,addSetting(){}}},
|
||||
api:{addEventListener(name,callback){
|
||||
const callbacks=apiListeners.get(name)||[];callbacks.push(callback);apiListeners.set(name,callbacks);
|
||||
}},
|
||||
registerExtension(extension){this.extension=extension;}
|
||||
};
|
||||
'''
|
||||
cases = r'''
|
||||
app.extension.setup();
|
||||
function emit(name,detail){for(const callback of apiListeners.get(name)||[])callback({type:name,detail});}
|
||||
async function serializedInputs(n){
|
||||
const inputs={};
|
||||
for(const [index,widget] of n.widgets.entries()){
|
||||
if(!widget.name||widget.options?.serialize===false)continue;
|
||||
inputs[widget.name]=widget.serializeValue?await widget.serializeValue(n,index):widget.value;
|
||||
}
|
||||
return inputs;
|
||||
}
|
||||
function makeNode() {
|
||||
const values = {
|
||||
prompt_mode:"Auto",chunks:2,chunk_seconds:5,aspect:"Auto from First Image",
|
||||
preset:"Draft — 0.30 MP",custom_mp:0.3,continuity:"Balanced — 22 frames",
|
||||
base_seed:123,control_after_generate:"fixed",audio_continuity:true,
|
||||
continuation_backend:"Standard",run_storage:"Save + Auto Resume",
|
||||
reroll_from_chunk:"Auto",reroll_nonce:0,run_name:"fixture",project_id:"fixture",
|
||||
reference_size:"Match Output",video_reference_size:"Efficient - 0.4 MP",
|
||||
diagnostics:"Detailed Report",strict_compatibility:false,debug:false,show_preview:true,
|
||||
generation_mode:"Review Each Chunk",review_action:"Continue / Next",
|
||||
take_group:0,take_revision_id:"",take_action:"Automatic",
|
||||
size_source:"First Image",width:544,height:544
|
||||
};
|
||||
const n={comfyClass:"H3ContinuumSamplerV38",properties:{},inputs:[],
|
||||
widgets:Object.entries(values).map(([name,value])=>({name,value,type:"combo",options:{values:[]},computeSize:()=>[120,20]})),
|
||||
addWidget(type,name,value,callback,options){const w={type,name,value,callback,options:options||{},computeSize:()=>[120,20]};this.widgets.push(w);return w;},
|
||||
addCustomWidget(w){this.widgets.push(w);return w;},
|
||||
serialize(){return {widgets_values:this.widgets.map(w=>w.value)};},
|
||||
configure(info){info.widgets_values.forEach((v,i)=>{this.widgets[i].value=v;});},
|
||||
setDirtyCanvas(){}
|
||||
};
|
||||
app.extension.nodeCreated(n);
|
||||
return n;
|
||||
}
|
||||
const w=(n,name)=>n.widgets.find(w=>w.name===name);
|
||||
const visible=(n,name)=>!w(n,name).hidden;
|
||||
const buttons=["Use it and continue","Try this chunk again","Use it and finish the rest"];
|
||||
function state(status,unit,id="revision-1") {
|
||||
return {branch_provenance_version:1,canonical_storage_revision_id:id,
|
||||
revisions:[{revision_id:id,status,...(unit?{review_unit:unit}:{})}],
|
||||
canonical_head_revision_id:"take-1",active_revisions:{"1":"take-1"},
|
||||
group_revisions:[{revision_id:"take-1",revision_order:"1",take_number:1,group:{start:1,end:1,physical_group:1}}]};
|
||||
}
|
||||
async function load(n,p) {project=p;await loadTakeHistory(n);n.__h3ContinuumIntuitiveUxRefresh?.();n.__h3ContinuumProductionUxRefresh();}
|
||||
(async()=>{
|
||||
const n=makeNode();await load(n,null);
|
||||
assert(buttons.every(name=>!visible(n,name)),"initial is not review-ready");
|
||||
for(const status of ["running","interrupted","unknown"]){
|
||||
await load(n,state(status,{start:1,end:1,physical_group:1}));
|
||||
assert(buttons.every(name=>!visible(n,name)),status);
|
||||
}
|
||||
await load(n,state("review_ready",{start:1,end:1,physical_group:1}));
|
||||
assert(buttons.every(name=>visible(n,name)),"partial review has all actions");
|
||||
for(const action of ["Use it and continue","Use it and finish the rest"]){
|
||||
w(n,action).callback();const inputs={};prepareReviewQueueIntent(n,inputs);
|
||||
assert.equal(inputs.review_action,action==="Use it and continue"?"Continue / Next":"Finish Remaining");
|
||||
w(n,"review_action").afterQueued({isPartialExecution:false});
|
||||
assert.equal(w(n,"review_action").value,"Continue / Next");
|
||||
}
|
||||
for(const count of [1,2,3,4,5,6]){
|
||||
w(n,"chunks").value=count;
|
||||
prepareReviewQueueIntent(n,{}); // This completion belongs to the current settings.
|
||||
const p=state("complete",{start:count,end:count,physical_group:count},`done-${count}`);
|
||||
await load(n,p);
|
||||
assert(visible(n,"Try this chunk again"),`retry complete ${count}`);
|
||||
assert(!visible(n,"Use it and continue")&&!visible(n,"Use it and finish the rest"),"no no-op continuation buttons");
|
||||
assert(visible(n,"Render History"));
|
||||
assert.match(w(n,"Review Ready").value,/Saved sequence is complete/);
|
||||
const saved=n.serialize();
|
||||
w(n,"Back to Settings").callback();
|
||||
assert(visible(n,"Chunks")&&visible(n,"Return to Review"));
|
||||
assert(!visible(n,"Try this chunk again"));
|
||||
w(n,"Return to Review").callback();
|
||||
assert(visible(n,"Try this chunk again")&&!visible(n,"Chunks"));
|
||||
assert.deepEqual(n.serialize(),saved,"settings/review are presentation only");
|
||||
w(n,"Render History").callback();assert(visible(n,"Render History / Takes"));
|
||||
const drawn=[];
|
||||
const ctx={save(){},restore(){},beginPath(){},rect(){},clip(){},fillText(text){drawn.push(text);}};
|
||||
const historyWidget=w(n,"Render History / Takes");
|
||||
const historyHeight=historyWidget.computeSize(400)[1];
|
||||
assert(historyHeight<=124,"history must not reserve a large empty panel");
|
||||
historyWidget.draw(ctx,n,400,0,20);
|
||||
assert(drawn.some(text=>text.startsWith("Selected:")),"selected Take is actually drawn, not an empty text widget");
|
||||
assert(drawn.length>1,"history draw must use its computed height, not the frontend's single-row hint");
|
||||
w(n,"Render History").callback();assert(!visible(n,"Render History / Takes"));
|
||||
w(n,"Try this chunk again").callback();
|
||||
const inputs={};prepareReviewQueueIntent(n,inputs);
|
||||
assert.equal(inputs.review_action,"Regenerate Current");
|
||||
assert.equal(w(n,"base_seed").value,123);
|
||||
assert.equal(w(n,"control_after_generate").value,"fixed");
|
||||
assert.match(w(n,"Review Ready").value,new RegExp(`Chunk ${count}`));
|
||||
w(n,"review_action").afterQueued({isPartialExecution:false});
|
||||
assert.equal(inputs.review_action,"Regenerate Current","queued payload remains immutable");
|
||||
assert.equal(w(n,"review_action").value,"Continue / Next","one-shot consumed once");
|
||||
assert.deepEqual(project,p,"backend evidence not rewritten");
|
||||
await load(n,state("complete",{start:count,end:count,physical_group:count},`retry-${count}`));
|
||||
assert(visible(n,"Try this chunk again"),"retry completion still accessible");
|
||||
}
|
||||
await load(n,state("complete",{start:2,end:3,physical_group:2},"terminal"));
|
||||
w(n,"Try this chunk again").callback();
|
||||
assert.match(w(n,"Review Ready").value,/Chunks 2-3/);
|
||||
await load(n,state("complete",null,"finish-without-unit"));
|
||||
assert(!visible(n,"Try this chunk again"),"do not invent a retry unit for full-run completion");
|
||||
assert(visible(n,"Render History")&&visible(n,"Back to Settings"));
|
||||
await load(n,state("review_ready",{physical_group:1}));
|
||||
assert(!visible(n,"Try this chunk again"),"incomplete metadata not actionable");
|
||||
await load(n,state("complete",{start:1,end:1,physical_group:1}));
|
||||
fetchMode="error";await loadTakeHistory(n);
|
||||
assert(!visible(n,"Try this chunk again"),"failed fetch cannot retain stale retry controls");
|
||||
fetchMode="ok";await loadTakeHistory(n);assert(visible(n,"Try this chunk again"));
|
||||
const reloaded=makeNode();await load(reloaded,project);
|
||||
assert(visible(reloaded,"Try this chunk again"),"reload restores completed review from backend");
|
||||
w(reloaded,"generation_mode").value="Full Run";reloaded.__h3ContinuumProductionUxRefresh();
|
||||
assert(buttons.every(name=>!visible(reloaded,name)),"full run does not expose review actions");
|
||||
w(reloaded,"generation_mode").value="Review Each Chunk";
|
||||
w(reloaded,"run_storage").value="Off";reloaded.__h3ContinuumProductionUxRefresh();
|
||||
assert(buttons.every(name=>!visible(reloaded,name)),"storage off does not expose review actions");
|
||||
// Mode selection is setup, not a request to review an old saved result.
|
||||
for (const oldStatus of ["complete", "review_ready"]) {
|
||||
for (const storage of ["Off", "Save + Auto Resume"]) {
|
||||
const setup=makeNode();
|
||||
setup.inputs=["model","clip","video_vae","sampler","sigmas"].map(name=>({name,link:1}));
|
||||
w(setup,"size_source").value="Manual";
|
||||
w(setup,"Run").callback("Generate Full Video");
|
||||
w(setup,"run_storage").value=storage;
|
||||
const old=state(oldStatus,{start:1,end:1,physical_group:1},`old-${oldStatus}-${storage}`);
|
||||
await load(setup,old);
|
||||
const before=setup.serialize().widgets_values.slice();
|
||||
w(setup,"Run").callback("Review Each Chunk");
|
||||
assert(visible(setup,"Chunks")&&visible(setup,"Run"),"mode switch keeps setup visible");
|
||||
assert(visible(setup,"Ready to Queue"),"mode switch keeps Queue-ready summary");
|
||||
assert.equal(w(setup,"Ready to Queue").__h3ContinuumInfoVariant,"ready");
|
||||
assert(!visible(setup,"Review Ready"),"old completion must not replace setup");
|
||||
assert(buttons.every(name=>!visible(setup,name)),"no retry/continue before choosing review");
|
||||
assert(!visible(setup,"Start again from Chunk 1"),"no restart button in mode setup");
|
||||
assert(visible(setup,"Return to Review"),"saved review remains explicitly accessible");
|
||||
const after=setup.serialize().widgets_values;
|
||||
const changed=before.flatMap((v,i)=>v===after[i]?[]:[[v,after[i]]]);
|
||||
assert.deepEqual(changed,storage==="Off"
|
||||
? [["Off","Save + Auto Resume"],["Full Run","Review Each Chunk"]]
|
||||
: [["Full Run","Review Each Chunk"]],"mode switch must not reset generation intent or identity");
|
||||
await load(setup,old);
|
||||
assert(visible(setup,"Chunks"),"same history refresh cannot reopen old review");
|
||||
w(setup,"Return to Review").callback();
|
||||
assert(visible(setup,"Try this chunk again"),"explicit return still opens saved result");
|
||||
w(setup,"Try this chunk again").callback();
|
||||
w(setup,"Back to Settings").callback();
|
||||
w(setup,"Run").callback("Generate Full Video");
|
||||
w(setup,"Run").callback("Review Each Chunk");
|
||||
const inputs={reroll_from_chunk:"Auto",reroll_nonce:0,
|
||||
take_group:9,take_revision_id:"stale-take",take_action:"Use This Take"};
|
||||
prepareReviewQueueIntent(setup,inputs);
|
||||
assert.equal(inputs.review_action,"Continue / Next");
|
||||
if(["complete","review_ready"].includes(oldStatus)){
|
||||
assert.equal(inputs.reroll_from_chunk,"Auto","mode switch preserves compatible continuation");
|
||||
assert.equal(inputs.reroll_nonce,0);
|
||||
assert.equal(inputs.take_group,0);
|
||||
assert.equal(inputs.take_revision_id,"");
|
||||
assert.equal(inputs.take_action,"Automatic");
|
||||
}
|
||||
await load(setup,old);
|
||||
assert(visible(setup,"Chunks"),"Queue alone does not mean generation completed");
|
||||
project=state("review_ready",{start:2,end:2,physical_group:2},"new-output");
|
||||
setup.onExecuted();
|
||||
await new Promise(resolve=>setImmediate(resolve));
|
||||
assert(buttons.every(name=>visible(setup,name)),"new queued result opens ordinary review");
|
||||
assert(!visible(setup,"Chunks"));
|
||||
}
|
||||
}
|
||||
const delayedSetup=makeNode();await load(delayedSetup,null);
|
||||
w(delayedSetup,"Run").callback("Generate Full Video");
|
||||
w(delayedSetup,"Run").callback("Review Each Chunk");
|
||||
await load(delayedSetup,state("complete",{start:2,end:2,physical_group:2},"late-old-history"));
|
||||
assert(visible(delayedSetup,"Chunks")&&!visible(delayedSetup,"Review Ready"),"late initial history cannot leave setup");
|
||||
// A result queued before the user's mode selection must not steal setup focus.
|
||||
const priorFlight=makeNode();await load(priorFlight,null);
|
||||
w(priorFlight,"Run").callback("Generate Full Video");
|
||||
prepareReviewQueueIntent(priorFlight,{});
|
||||
w(priorFlight,"Run").callback("Review Each Chunk");
|
||||
await load(priorFlight,state("complete",{start:2,end:2,physical_group:2},"prior-flight"));
|
||||
assert(visible(priorFlight,"Chunks")&&!visible(priorFlight,"Review Ready"));
|
||||
const newRunSetup=makeNode();await load(newRunSetup,null);
|
||||
w(newRunSetup,"Run").callback("Generate Full Video");
|
||||
w(newRunSetup,"Run").callback("Review Each Chunk");
|
||||
prepareReviewQueueIntent(newRunSetup,{});
|
||||
w(newRunSetup,"run_name").value="different-run";
|
||||
await load(newRunSetup,state("complete",{start:2,end:2,physical_group:2},"unrelated-history"));
|
||||
assert(visible(newRunSetup,"Chunks")&&!visible(newRunSetup,"Review Ready"));
|
||||
const wrongExecution=makeNode();
|
||||
await load(wrongExecution,state("complete",{start:3,end:3,physical_group:3},"wrong-run-old"));
|
||||
w(wrongExecution,"Run").callback("Generate Full Video");
|
||||
w(wrongExecution,"Run").callback("Review Each Chunk");
|
||||
prepareReviewQueueIntent(wrongExecution,{reroll_from_chunk:"Auto",reroll_nonce:0});
|
||||
w(wrongExecution,"run_name").value="changed-after-queue";
|
||||
project=state("review_ready",{start:1,end:1,physical_group:1},"wrong-run-result");
|
||||
wrongExecution.onExecuted();await new Promise(resolve=>setImmediate(resolve));
|
||||
assert(visible(wrongExecution,"Chunks")&&!visible(wrongExecution,"Review Ready"),
|
||||
"another Run identity cannot release the queued setup token");
|
||||
// Frontend 1.49 contract: widget.beforeQueued runs before serializeValue;
|
||||
// legacy beforeQueuePrompt is not part of the real queue path.
|
||||
const liveContract=makeNode();liveContract.id=312;app.graph._nodes=[liveContract];
|
||||
w(liveContract,"chunks").value=4;
|
||||
await load(liveContract,state("complete",{start:3,end:3,physical_group:3},"live-old-complete"));
|
||||
w(liveContract,"Run").callback("Generate Full Video");
|
||||
w(liveContract,"Run").callback("Review Each Chunk");
|
||||
for(const widget of liveContract.widgets)widget.beforeQueued?.({isPartialExecution:false});
|
||||
const liveInputs=await serializedInputs(liveContract);
|
||||
assert.equal(liveInputs.reroll_from_chunk,"Auto","mode switch must not inject Chunk 1");
|
||||
assert.equal(liveInputs.reroll_nonce,0);
|
||||
assert.equal(liveInputs.take_group,0);
|
||||
assert.equal(liveInputs.take_revision_id,"");
|
||||
assert.equal(liveInputs.take_action,"Automatic");
|
||||
assert.equal(liveInputs.review_action,"Continue / Next");
|
||||
project=state("review_ready",{start:4,end:4,physical_group:4},"live-fresh-chunk-4");
|
||||
// Sampler V3.8 does not need to emit a node-specific `executed` UI event.
|
||||
emit("execution_success",{prompt_id:"live-prompt"});
|
||||
await new Promise(resolve=>setTimeout(resolve,20));
|
||||
assert(buttons.every(name=>visible(liveContract,name)),"terminal readback opens the new review");
|
||||
assert.match(w(liveContract,"Review Ready").value,/Chunk 4/);
|
||||
// Acceptance lifecycle: extend a completed 3 x 5-second prefix to 5 x 5 seconds.
|
||||
const flow=makeNode();w(flow,"chunks").value=5;w(flow,"chunk_seconds").value=5;
|
||||
await load(flow,state("complete",{start:3,end:3,physical_group:3},"old-complete-3x5"));
|
||||
w(flow,"Run").callback("Generate Full Video");
|
||||
w(flow,"Run").callback("Review Each Chunk");
|
||||
const chunk4Inputs={reroll_from_chunk:"Auto",reroll_nonce:0,
|
||||
take_group:9,take_revision_id:"stale",take_action:"Use This Take"};
|
||||
prepareReviewQueueIntent(flow,chunk4Inputs);
|
||||
assert.equal(chunk4Inputs.reroll_from_chunk,"Auto","extension reuses the compatible prefix");
|
||||
assert.equal(chunk4Inputs.take_group,0);
|
||||
assert.equal(chunk4Inputs.take_revision_id,"");
|
||||
assert.equal(chunk4Inputs.take_action,"Automatic");
|
||||
project=state("review_ready",{start:4,end:4,physical_group:4},"fresh-chunk-4");
|
||||
flow.onExecuted();await new Promise(resolve=>setImmediate(resolve));
|
||||
assert(buttons.every(name=>visible(flow,name)),"Chunk 4 opens the review screen");
|
||||
assert.match(w(flow,"Review Ready").value,/Chunk 4/);
|
||||
w(flow,"Use it and continue").callback();
|
||||
const chunk5Inputs={reroll_from_chunk:"Auto",reroll_nonce:0};
|
||||
prepareReviewQueueIntent(flow,chunk5Inputs);
|
||||
assert.equal(chunk5Inputs.reroll_from_chunk,"Auto","continuation does not restart Chunk 1");
|
||||
project=state("complete",{start:5,end:5,physical_group:5},"fresh-chunk-5");
|
||||
flow.onExecuted();await new Promise(resolve=>setImmediate(resolve));
|
||||
assert(visible(flow,"Try this chunk again"),"Chunk 5 completion remains reviewable");
|
||||
assert(!visible(flow,"Use it and continue")&&!visible(flow,"Use it and finish the rest"));
|
||||
assert.match(w(flow,"Review Ready").value,/Saved sequence is complete/);
|
||||
|
||||
// Full mode also keeps Auto so the backend can reuse Chunks 1-3 and generate 4-5.
|
||||
const fullExtend=makeNode();w(fullExtend,"chunks").value=5;
|
||||
await load(fullExtend,state("complete",{start:3,end:3,physical_group:3},"full-old-3"));
|
||||
w(fullExtend,"Run").callback("Generate Full Video");
|
||||
const fullInputs={reroll_from_chunk:"Auto",reroll_nonce:0};prepareReviewQueueIntent(fullExtend,fullInputs);
|
||||
assert.equal(fullInputs.generation_mode,"Full Run");
|
||||
assert.equal(fullInputs.reroll_from_chunk,"Auto");
|
||||
|
||||
// Storage Off cannot submit a stale explicit regeneration boundary.
|
||||
const storageOff=makeNode();
|
||||
w(storageOff,"generation_mode").value="Full Run";
|
||||
w(storageOff,"run_storage").value="Off";
|
||||
w(storageOff,"reroll_from_chunk").value="Chunk 1";
|
||||
w(storageOff,"reroll_nonce").value=7;
|
||||
for(const widget of storageOff.widgets)widget.beforeQueued?.({isPartialExecution:false});
|
||||
const offInputs=await serializedInputs(storageOff);
|
||||
assert.equal(offInputs.reroll_from_chunk,"Auto");
|
||||
assert.equal(offInputs.reroll_nonce,0);
|
||||
assert.equal(w(storageOff,"reroll_from_chunk").value,"Auto","visible stale boundary is normalized");
|
||||
|
||||
// An explicit Advanced regeneration remains explicit while storage is enabled.
|
||||
const explicit=makeNode();
|
||||
w(explicit,"reroll_from_chunk").value="Chunk 1";
|
||||
w(explicit,"reroll_from_chunk").callback?.("Chunk 1");
|
||||
w(explicit,"Run").callback("Generate Full Video");
|
||||
w(explicit,"Run").callback("Review Each Chunk");
|
||||
for(const widget of explicit.widgets)widget.beforeQueued?.({isPartialExecution:false});
|
||||
const explicitInputs=await serializedInputs(explicit);
|
||||
assert.equal(explicitInputs.reroll_from_chunk,"Chunk 1","manual Advanced regeneration is preserved");
|
||||
// Hotfix: stale saved review cannot offer/submit Retry after settings edits.
|
||||
const edited=makeNode();w(edited,"chunks").value=4;
|
||||
const originalProject=state("review_ready",{start:2,end:2,physical_group:2},"edit-base");
|
||||
await load(edited,originalProject);
|
||||
const oldSeed=w(edited,"base_seed").value;
|
||||
w(edited,"Try this chunk again").callback();
|
||||
w(edited,"Back to Settings").callback();
|
||||
w(edited,"base_seed").value=999;w(edited,"base_seed").callback?.(999);
|
||||
assert.match(reviewStatus(edited),/Settings changed/);
|
||||
w(edited,"Return to Review").callback();
|
||||
assert(buttons.every(name=>!visible(edited,name)),"stale review actions hidden");
|
||||
assert(visible(edited,"Start again from Chunk 1")&&visible(edited,"Render History"));
|
||||
await load(edited,originalProject);
|
||||
assert.match(reviewStatus(edited),/Settings changed/,"history refresh must not bless edits");
|
||||
const changedInputs={base_seed:999};prepareReviewQueueIntent(edited,changedInputs);
|
||||
assert.equal(changedInputs.review_action,"Continue / Next");
|
||||
assert.equal(changedInputs.base_seed,999);
|
||||
assert.deepEqual(project,originalProject,"stored backend state is untouched");
|
||||
w(edited,"base_seed").value=oldSeed;edited.__h3ContinuumProductionUxRefresh();
|
||||
assert(visible(edited,"Try this chunk again"),"undo restores the original review eligibility");
|
||||
// Manual boundaries are not silently erased by old action callbacks.
|
||||
w(edited,"reroll_from_chunk").value="Chunk 1";
|
||||
w(edited,"Try this chunk again").callback();
|
||||
assert.equal(w(edited,"reroll_from_chunk").value,"Chunk 1");
|
||||
const manualInputs={reroll_from_chunk:"Chunk 1"};prepareReviewQueueIntent(edited,manualInputs);
|
||||
assert.equal(manualInputs.reroll_from_chunk,"Chunk 1");
|
||||
assert.equal(manualInputs.review_action,"Continue / Next");
|
||||
// Restart uses existing non-destructive branch controls, consumed once.
|
||||
w(edited,"reroll_nonce").value=8;
|
||||
w(edited,"Start again from Chunk 1").callback();
|
||||
assert.equal(w(edited,"reroll_nonce").value,0);
|
||||
assert.equal(w(edited,"take_action").value,"Automatic");
|
||||
const restartInputs={reroll_from_chunk:w(edited,"reroll_from_chunk").value};
|
||||
prepareReviewQueueIntent(edited,restartInputs);
|
||||
w(edited,"review_action").afterQueued({isPartialExecution:false});
|
||||
assert.equal(restartInputs.reroll_from_chunk,"Chunk 1","queued restart payload unchanged");
|
||||
assert.equal(w(edited,"reroll_from_chunk").value,"Auto","next Queue can continue");
|
||||
assert.equal(w(edited,"base_seed").value,oldSeed);
|
||||
assert.equal(edited.serialize().widgets_values.length,makeNode().serialize().widgets_values.length);
|
||||
// Linked prompts, media selection/bypass and reconnection are included.
|
||||
const upstream={id:71,comfyClass:"LoadImage",mode:0,inputs:[],widgets:[{name:"image",value:"first.png"}]};
|
||||
const graph={links:{9:{origin_id:71,origin_slot:0}},getNodeById:id=>id===71?upstream:null};
|
||||
const linked=makeNode();linked.graph=graph;linked.inputs=[{name:"reference_image_1",link:9}];
|
||||
await load(linked,state("review_ready",{start:1,end:1,physical_group:1},"linked"));
|
||||
for(const mutation of [()=>upstream.widgets[0].value="second.png",()=>upstream.mode=4,()=>linked.inputs[0].link=null]){
|
||||
mutation();linked.onDrawForeground();
|
||||
assert.match(reviewStatus(linked),/Settings changed/);
|
||||
assert(!visible(linked,"Try this chunk again"));
|
||||
upstream.widgets[0].value="first.png";upstream.mode=0;linked.inputs[0].link=9;
|
||||
linked.onDrawForeground();assert(visible(linked,"Try this chunk again"));
|
||||
}
|
||||
upstream.comfyClass="PrimitiveStringMultiline";upstream.widgets=[{name:"value",value:"old prompt"}];
|
||||
await load(linked,state("review_ready",{start:1,end:1,physical_group:1},"prompt-base"));
|
||||
upstream.widgets[0].value="new prompt";linked.onDrawForeground();
|
||||
assert.match(reviewStatus(linked),/Settings changed/);
|
||||
// Edits made while a queued run is working must remain dirty on completion.
|
||||
const flight=makeNode();prepareReviewQueueIntent(flight,{});
|
||||
w(flight,"base_seed").value=321;
|
||||
await load(flight,state("review_ready",{start:1,end:1,physical_group:1},"flight"));
|
||||
assert.match(reviewStatus(flight),/Settings changed/);
|
||||
assert(!visible(flight,"Try this chunk again"));
|
||||
// A slow first history response cannot bless settings changed during fetch.
|
||||
const slow=makeNode();await load(slow,null);
|
||||
const normalFetch=globalThis.fetch;let releaseFetch;
|
||||
globalThis.fetch=()=>new Promise(resolve=>{releaseFetch=resolve;});
|
||||
const pendingHistory=loadTakeHistory(slow);
|
||||
w(slow,"base_seed").value=456;
|
||||
releaseFetch({ok:true,status:200,json:async()=>state("review_ready",{start:1,end:1,physical_group:1},"slow")});
|
||||
await pendingHistory;
|
||||
assert.match(reviewStatus(slow),/Settings changed/);
|
||||
globalThis.fetch=normalFetch;
|
||||
// An old queued snapshot cannot become another Run Name's baseline.
|
||||
const otherRun=makeNode();prepareReviewQueueIntent(otherRun,{});
|
||||
w(otherRun,"run_name").value="different-run";w(otherRun,"base_seed").value=789;
|
||||
await load(otherRun,state("review_ready",{start:1,end:1,physical_group:1},"other-run"));
|
||||
assert(!reviewSettingsChanged(otherRun));
|
||||
console.log("PASS: real frontend completed-review lifecycle");
|
||||
})().catch(e=>{console.error(e);process.exitCode=1;});
|
||||
'''
|
||||
script = tmp_path / "completed_review.cjs"
|
||||
script.write_text(harness + source + cases, encoding="utf-8")
|
||||
result = subprocess.run([node, str(script)], capture_output=True, text=True, timeout=30)
|
||||
assert result.returncode == 0, result.stdout + result.stderr
|
||||
assert "PASS: real frontend" in result.stdout
|
||||
"""Real queue acceptance and readback, replacing the legacy helper-injected gate."""
|
||||
def test_completed_review_lifecycle_with_real_frontend(review_queue_results):
|
||||
for case in (
|
||||
"explicit restart consumed and Chunk 1 Continue restored",
|
||||
"850 ms terminal readback releases setup after it resolves",
|
||||
"same completed revision reuse exits setup without new Sampling",
|
||||
"three review queues advance without any executed events",
|
||||
"settings edited during execution remain out of date after readback",
|
||||
"same setup request is not mutated by legacy preparation then API preparation",
|
||||
):
|
||||
assert review_queue_results[case]["pass"]
|
||||
|
||||
@@ -191,9 +191,18 @@ def test_intuitive_facade_is_discoverable_and_presentation_only(tmp_path):
|
||||
).replace(
|
||||
'import { normalizeReferenceAudioLabels } from "./reference_audio_ui.js";',
|
||||
"function normalizeReferenceAudioLabels() {}",
|
||||
).replace(
|
||||
'import { api } from "../../scripts/api.js";',
|
||||
"const api = { fetchApi: (...args) => globalThis.fetch(...args), "
|
||||
"addEventListener(name, callback) { "
|
||||
"const listeners = terminalListeners.get(name) || []; "
|
||||
"listeners.push(callback); terminalListeners.set(name, listeners); }, "
|
||||
"queuePrompt: async () => ({prompt_id: 'facade-queue'}) };",
|
||||
)
|
||||
script = f"""
|
||||
globalThis.__extension = null;
|
||||
const terminalListeners = new Map();
|
||||
let savedProject = null;
|
||||
const sourceNodes = {{
|
||||
101: {{ id: 101, mode: 0, widgets: [{{ name: "Enable Image", value: true }}] }},
|
||||
102: {{ id: 102, mode: 0, widgets: [{{ name: "Enable Video", value: true }}] }},
|
||||
@@ -212,7 +221,9 @@ globalThis.__app = {{
|
||||
ui: {{ settings: {{ getSettingValue: (_id, fallback) => fallback, addSetting() {{}} }} }},
|
||||
registerExtension(extension) {{ globalThis.__extension = extension; }},
|
||||
}};
|
||||
globalThis.fetch = async () => ({{ status: 404, ok: false }});
|
||||
globalThis.fetch = async () => savedProject
|
||||
? {{status: 200, ok: true, json: async () => structuredClone(savedProject)}}
|
||||
: {{status: 404, ok: false}};
|
||||
{source}
|
||||
function widget(name, value) {{
|
||||
return {{
|
||||
@@ -222,6 +233,7 @@ function widget(name, value) {{
|
||||
}};
|
||||
}}
|
||||
const node = {{
|
||||
id: 312,
|
||||
comfyClass: "H3ContinuumSamplerV38",
|
||||
properties: {{ "H3 Continuum View": "Basic" }},
|
||||
widgets: [
|
||||
@@ -277,7 +289,8 @@ const node = {{
|
||||
}};
|
||||
globalThis.__app.graph._nodes.push(node);
|
||||
globalThis.__extension.nodeCreated(node);
|
||||
setTimeout(() => {{
|
||||
globalThis.__extension.setup();
|
||||
setTimeout(async () => {{
|
||||
const savedBefore = node.serialize().widgets_values;
|
||||
const facade = Object.fromEntries([
|
||||
"Prompt Format", "Continuity", "Base Seed", "Control After Generate", "Audio Continuity",
|
||||
@@ -364,8 +377,19 @@ setTimeout(() => {{
|
||||
const historyHiddenBeforeTake = node.widgets.find(
|
||||
(item) => item.name === "Render History",
|
||||
).hidden;
|
||||
prepareReviewQueueIntent(node, {{}});
|
||||
node.__h3ContinuumTakeProject = {{
|
||||
// Queue ordinary continuation through the supported lifecycle. Do not call
|
||||
// the removed setup helper or fabricate completion directly on the node.
|
||||
node.widgets.find((item) => item.name === "reroll_from_chunk").value = "Auto";
|
||||
for (const widget of node.widgets) widget.beforeQueued?.({{isPartialExecution:false}});
|
||||
const submitted = {{}};
|
||||
for (const [index, widget] of node.widgets.entries()) {{
|
||||
if (widget.options?.serialize === false) continue;
|
||||
submitted[widget.name] = widget.serializeValue
|
||||
? await widget.serializeValue(node, index) : widget.value;
|
||||
}}
|
||||
await api.queuePrompt(0, {{output: {{312: {{class_type:node.comfyClass, inputs:submitted}}}}}});
|
||||
for (const widget of node.widgets) widget.afterQueued?.({{isPartialExecution:false}});
|
||||
savedProject = {{
|
||||
branch_provenance_version: 1,
|
||||
canonical_storage_revision_id: "storage-ready",
|
||||
revisions: [{{
|
||||
@@ -379,9 +403,9 @@ setTimeout(() => {{
|
||||
group: {{ start: 1, end: 1, physical_group: 1 }},
|
||||
}}],
|
||||
}};
|
||||
finishModeSetupAfterExecution(node);
|
||||
node.__h3ContinuumRememberReviewSettings(); // The queued generation completed.
|
||||
node.__h3ContinuumProductionUxRefresh();
|
||||
for (const listener of terminalListeners.get("execution_success") || []) {{
|
||||
await listener({{type:"execution_success",detail:{{prompt_id:"facade-queue"}}}});
|
||||
}}
|
||||
const reviewButtonsVisibleWhenReady = [
|
||||
"Use it and continue", "Try this chunk again", "Use it and finish the rest",
|
||||
].every((name) => !node.widgets.find((item) => item.name === name).hidden);
|
||||
|
||||
+32
-669
@@ -250,196 +250,23 @@ def _function_source(source: str, name: str, next_name: str) -> str:
|
||||
return source[start:end]
|
||||
|
||||
|
||||
def test_f0_f7_frontend_review_lifecycle(tmp_path):
|
||||
node_executable = shutil.which("node")
|
||||
if node_executable is None:
|
||||
pytest.skip("Node.js is required for the frontend behavior regression")
|
||||
|
||||
source = PROJECT_ID_JS.read_text(encoding="utf-8")
|
||||
functions = "\n".join(
|
||||
(
|
||||
_function_source(source, "findWidget", "setWidgetVisible"),
|
||||
_function_source(source, "setWidgetVisible", "hidePersistentWidget"),
|
||||
_function_source(source, "setExistingWidgetValue", "facadeProductionWidgets"),
|
||||
_function_source(source, "baseSeedControlWidget", "setReviewSeedControlFixed"),
|
||||
_function_source(source, "setReviewSeedControlFixed", "requireFixedSeedForReview"),
|
||||
_function_source(source, "isOneShotReviewAction", "normalizeReviewActionOnLoad"),
|
||||
_function_source(source, "normalizeReviewActionOnLoad", "resetReviewActionAfterQueued"),
|
||||
_function_source(source, "resetReviewActionAfterQueued", "prepareReviewQueueIntent"),
|
||||
_function_source(source, "canonicalStorageRevision", "reviewSettingsSnapshot"),
|
||||
_function_source(source, "prepareReviewQueueIntent", "configureReviewControls"),
|
||||
_function_source(source, "configureReviewControls", "configureAssembler"),
|
||||
)
|
||||
)
|
||||
script = f"""
|
||||
const V38_NODE_CLASS = "H3ContinuumSamplerV38";
|
||||
const PROJECT_WIDGET = "project_id";
|
||||
const LEGACY_RUN_NAME_WIDGET = "run_name";
|
||||
const RUN_STORAGE_WIDGET = "run_storage";
|
||||
const GENERATION_MODE_WIDGET = "generation_mode";
|
||||
const REVIEW_ACTION_WIDGET = "review_action";
|
||||
const GENERATION_MODE_FULL_RUN = "Full Run";
|
||||
const REGENERATE_WIDGET = "reroll_from_chunk";
|
||||
const GENERATION_MODE_REVIEW = "Review Each Chunk";
|
||||
const REVIEW_ACTION_CONTINUE = "Continue / Next";
|
||||
const REVIEW_ACTION_REGENERATE = "Regenerate Current";
|
||||
const REVIEW_ACTION_FINISH = "Finish Remaining";
|
||||
const TAKE_GROUP_WIDGET = "take_group";
|
||||
const TAKE_REVISION_WIDGET = "take_revision_id";
|
||||
const TAKE_ACTION_WIDGET = "take_action";
|
||||
const TAKE_ACTION_AUTOMATIC = "Automatic";
|
||||
const TAKE_ACTION_USE = "Use This Take";
|
||||
const TAKE_ACTION_CONTINUE = "Continue From Here";
|
||||
const REVIEW_PENDING_ACTION = "__h3ContinuumPendingReviewAction";
|
||||
const REVIEW_UI_SELECTION = "__h3ContinuumReviewUiSelection";
|
||||
const TAKE_PENDING_ACTION = "__h3ContinuumPendingTakeAction";
|
||||
{functions}
|
||||
|
||||
function widget(name, value) {{
|
||||
return {{ name, value, type: "combo", options: {{}}, computeSize: () => [120, 20] }};
|
||||
}}
|
||||
function makeNode(mode, action, storage, comfyClass = V38_NODE_CLASS) {{
|
||||
return {{
|
||||
comfyClass,
|
||||
widgets: [
|
||||
widget("existing_1", 11),
|
||||
widget(RUN_STORAGE_WIDGET, storage),
|
||||
widget("existing_2", 22),
|
||||
widget(GENERATION_MODE_WIDGET, mode),
|
||||
widget(REVIEW_ACTION_WIDGET, action),
|
||||
],
|
||||
setDirtyCanvas() {{}},
|
||||
}};
|
||||
}}
|
||||
|
||||
const defaults = makeNode(GENERATION_MODE_FULL_RUN, REVIEW_ACTION_CONTINUE, "Off");
|
||||
configureReviewControls(defaults);
|
||||
const defaultAction = findWidget(defaults, REVIEW_ACTION_WIDGET);
|
||||
|
||||
const switching = makeNode(GENERATION_MODE_FULL_RUN, REVIEW_ACTION_CONTINUE, "Off");
|
||||
configureReviewControls(switching);
|
||||
const switchingMode = findWidget(switching, GENERATION_MODE_WIDGET);
|
||||
const switchingStorage = findWidget(switching, RUN_STORAGE_WIDGET);
|
||||
switchingMode.value = GENERATION_MODE_REVIEW;
|
||||
switchingMode.callback(GENERATION_MODE_REVIEW);
|
||||
const storageAfterReview = switchingStorage.value;
|
||||
switchingMode.value = GENERATION_MODE_FULL_RUN;
|
||||
switchingMode.callback(GENERATION_MODE_FULL_RUN);
|
||||
const storageAfterFull = switchingStorage.value;
|
||||
|
||||
function acceptedSnapshot(action) {{
|
||||
const node = makeNode(GENERATION_MODE_REVIEW, action, "Save + Auto Resume");
|
||||
configureReviewControls(node);
|
||||
const inputs = {{ generation_mode: GENERATION_MODE_REVIEW, review_action: action }};
|
||||
prepareReviewQueueIntent(node, inputs);
|
||||
const submitted = JSON.parse(JSON.stringify(inputs));
|
||||
findWidget(node, REVIEW_ACTION_WIDGET).afterQueued({{ isPartialExecution: false }});
|
||||
return {{
|
||||
submitted,
|
||||
promptAfterReset: inputs.review_action,
|
||||
widgetAfterReset: findWidget(node, REVIEW_ACTION_WIDGET).value,
|
||||
}};
|
||||
}}
|
||||
|
||||
const regenerate = acceptedSnapshot(REVIEW_ACTION_REGENERATE);
|
||||
const finish = acceptedSnapshot(REVIEW_ACTION_FINISH);
|
||||
|
||||
const failed = makeNode(
|
||||
GENERATION_MODE_REVIEW,
|
||||
REVIEW_ACTION_REGENERATE,
|
||||
"Save + Auto Resume",
|
||||
);
|
||||
configureReviewControls(failed);
|
||||
const failedInputs = {{}};
|
||||
prepareReviewQueueIntent(failed, failedInputs);
|
||||
|
||||
const saved = makeNode(
|
||||
GENERATION_MODE_REVIEW,
|
||||
REVIEW_ACTION_FINISH,
|
||||
"Save + Auto Resume",
|
||||
);
|
||||
const savedValues = saved.widgets.map((item) => item.value);
|
||||
const reloaded = makeNode(
|
||||
savedValues[3],
|
||||
savedValues[4],
|
||||
savedValues[1],
|
||||
);
|
||||
normalizeReviewActionOnLoad(reloaded);
|
||||
|
||||
const v37 = makeNode(
|
||||
GENERATION_MODE_REVIEW,
|
||||
REVIEW_ACTION_REGENERATE,
|
||||
"Off",
|
||||
"H3ContinuumSamplerV37",
|
||||
);
|
||||
const v37Inputs = {{ untouched: true }};
|
||||
configureReviewControls(v37);
|
||||
const v37Prepared = prepareReviewQueueIntent(v37, v37Inputs);
|
||||
|
||||
console.log(JSON.stringify({{
|
||||
defaults: {{
|
||||
mode: findWidget(defaults, GENERATION_MODE_WIDGET).value,
|
||||
action: defaultAction.value,
|
||||
actionHidden: defaultAction.hidden,
|
||||
}},
|
||||
switching: {{ storageAfterReview, storageAfterFull }},
|
||||
regenerate,
|
||||
finish,
|
||||
failed: {{
|
||||
prompt: failedInputs.review_action,
|
||||
widget: findWidget(failed, REVIEW_ACTION_WIDGET).value,
|
||||
}},
|
||||
reload: {{
|
||||
savedValues,
|
||||
reloadedValues: reloaded.widgets.map((item) => item.value),
|
||||
}},
|
||||
v37: {{ prepared: v37Prepared, inputs: v37Inputs }},
|
||||
}}));
|
||||
"""
|
||||
script_path = tmp_path / "v38-review-ui-regression.js"
|
||||
script_path.write_text(script, encoding="utf-8")
|
||||
result = subprocess.run(
|
||||
[node_executable, str(script_path)],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
observed = json.loads(result.stdout)
|
||||
|
||||
assert observed["defaults"] == {
|
||||
"mode": GENERATION_MODE_FULL_RUN,
|
||||
"action": REVIEW_ACTION_CONTINUE,
|
||||
"actionHidden": True,
|
||||
}
|
||||
assert observed["switching"] == {
|
||||
"storageAfterReview": RUN_STORAGE_SAVE_AUTO_RESUME,
|
||||
"storageAfterFull": RUN_STORAGE_SAVE_AUTO_RESUME,
|
||||
}
|
||||
for key, action in (
|
||||
("regenerate", REVIEW_ACTION_REGENERATE_CURRENT),
|
||||
("finish", REVIEW_ACTION_FINISH_REMAINING),
|
||||
def test_f0_f7_frontend_review_lifecycle(review_queue_results):
|
||||
# Acceptance, not a manual helper call, must consume one-shot intent.
|
||||
for case in (
|
||||
"three review queues advance without any executed events",
|
||||
"queue rejection preserves one-shot retry for resubmission",
|
||||
"retry consumed after acceptance without legacy preparation hook",
|
||||
"mode policy and transient UI serialization remain stable",
|
||||
):
|
||||
assert observed[key]["submitted"]["review_action"] == action
|
||||
assert observed[key]["promptAfterReset"] == action
|
||||
assert observed[key]["widgetAfterReset"] == REVIEW_ACTION_CONTINUE
|
||||
assert observed["failed"] == {
|
||||
"prompt": REVIEW_ACTION_REGENERATE_CURRENT,
|
||||
"widget": REVIEW_ACTION_REGENERATE_CURRENT,
|
||||
}
|
||||
assert observed["reload"]["reloadedValues"][:-1] == observed["reload"][
|
||||
"savedValues"
|
||||
][:-1]
|
||||
assert observed["reload"]["reloadedValues"][-1] == REVIEW_ACTION_CONTINUE
|
||||
assert observed["v37"] == {"prepared": False, "inputs": {"untouched": True}}
|
||||
assert review_queue_results[case]["pass"]
|
||||
|
||||
|
||||
def test_frontend_uses_formal_after_queued_callback_without_queue_monkey_patch():
|
||||
def test_frontend_uses_scoped_acceptance_adapter_without_app_queue_override():
|
||||
source = PROJECT_ID_JS.read_text(encoding="utf-8")
|
||||
assert "actionWidget.afterQueued = function" in source
|
||||
assert "prepareReviewQueueIntent(node, apiNode.inputs);" in source
|
||||
assert "normalizeReviewActionOnLoad(node);" in source
|
||||
assert "app.queuePrompt =" not in source
|
||||
assert "api.queuePrompt =" not in source
|
||||
assert "api.__h3ContinuumReviewQueueAdapter" in source
|
||||
|
||||
|
||||
def test_execution_success_reloads_v38_history_without_auto_queue():
|
||||
@@ -458,9 +285,10 @@ def test_execution_success_reloads_v38_history_without_auto_queue():
|
||||
assert f'"{event_name}"' in setup
|
||||
assert "refreshV38TakeHistoryAfterExecution" in setup
|
||||
assert "node.comfyClass !== V38_NODE_CLASS" in refresh
|
||||
assert "void loadTakeHistory(node);" in refresh
|
||||
assert "setTimeout(() => void loadTakeHistory(node), 250);" in refresh
|
||||
assert "queuePrompt" not in refresh
|
||||
assert "await loadTakeHistory(node," in refresh
|
||||
assert "reviewPrompts.get(promptId)" in refresh
|
||||
assert "event?.detail?.prompt_id" in refresh
|
||||
assert "api.queuePrompt(" not in refresh
|
||||
|
||||
|
||||
def test_review_requires_fixed_control_after_generate(tmp_path):
|
||||
@@ -609,496 +437,31 @@ def test_readmes_document_exact_two_by_five_review_workflow():
|
||||
assert "10" in text
|
||||
|
||||
|
||||
def test_n1_production_shortcuts_are_transient_and_map_to_existing_intent(tmp_path):
|
||||
node_executable = shutil.which("node")
|
||||
if node_executable is None:
|
||||
pytest.skip("Node.js is required for the frontend behavior regression")
|
||||
|
||||
source = PROJECT_ID_JS.read_text(encoding="utf-8")
|
||||
functions = "\n".join(
|
||||
(
|
||||
_function_source(source, "findWidget", "setWidgetVisible"),
|
||||
_function_source(source, "setWidgetVisible", "hidePersistentWidget"),
|
||||
_function_source(source, "attachRefresh", "normalizedV38View"),
|
||||
_function_source(source, "normalizedV38View", "applyV38View"),
|
||||
_function_source(source, "isOneShotReviewAction", "normalizeReviewActionOnLoad"),
|
||||
_function_source(source, "prepareReviewQueueIntent", "configureReviewControls"),
|
||||
)
|
||||
)
|
||||
script = f"""
|
||||
const V38_NODE_CLASS = "H3ContinuumSamplerV38";
|
||||
const PROJECT_WIDGET = "project_id";
|
||||
const LEGACY_RUN_NAME_WIDGET = "run_name";
|
||||
const RUN_STORAGE_WIDGET = "run_storage";
|
||||
const GENERATION_MODE_WIDGET = "generation_mode";
|
||||
const REVIEW_ACTION_WIDGET = "review_action";
|
||||
const REGENERATE_WIDGET = "reroll_from_chunk";
|
||||
const REROLL_NONCE_WIDGET = "reroll_nonce";
|
||||
const GENERATION_MODE_FULL_RUN = "Full Run";
|
||||
const GENERATION_MODE_REVIEW = "Review Each Chunk";
|
||||
const REVIEW_ACTION_CONTINUE = "Continue / Next";
|
||||
const REVIEW_ACTION_REGENERATE = "Regenerate Current";
|
||||
const REVIEW_ACTION_FINISH = "Finish Remaining";
|
||||
const TAKE_GROUP_WIDGET = "take_group";
|
||||
const TAKE_REVISION_WIDGET = "take_revision_id";
|
||||
const TAKE_ACTION_WIDGET = "take_action";
|
||||
const TAKE_ACTION_AUTOMATIC = "Automatic";
|
||||
const TAKE_ACTION_USE = "Use This Take";
|
||||
const TAKE_ACTION_CONTINUE = "Continue From Here";
|
||||
const REVIEW_PENDING_ACTION = "__h3ContinuumPendingReviewAction";
|
||||
const REVIEW_UI_SELECTION = "__h3ContinuumReviewUiSelection";
|
||||
const TAKE_PENDING_ACTION = "__h3ContinuumPendingTakeAction";
|
||||
const PRODUCTION_STATUS_WIDGET = "Review Ready";
|
||||
const PRODUCTION_CONTINUE_WIDGET = "Use it and continue";
|
||||
const PRODUCTION_REGENERATE_WIDGET = "Try this chunk again";
|
||||
const PRODUCTION_FINISH_WIDGET = "Use it and finish the rest";
|
||||
const PRODUCTION_BACK_TO_SETTINGS_WIDGET = "Back to Settings";
|
||||
const PRODUCTION_RETURN_TO_REVIEW_WIDGET = "Return to Review";
|
||||
const PRODUCTION_RESTART_WIDGET = "Start again from Chunk 1";
|
||||
const FACADE_READY_WIDGET = "Ready to Queue";
|
||||
const FACADE_ADVANCED_WIDGET = "Advanced Settings";
|
||||
const FACADE_REFERENCE_SIZE_WIDGET = "Reference Image Size";
|
||||
const FACADE_VIDEO_SIZE_WIDGET = "Video Guide Size";
|
||||
const TAKE_STATUS_WIDGET = "Render History / Takes";
|
||||
const TAKE_TOGGLE_WIDGET = "Render History";
|
||||
const TAKE_PREVIOUS_WIDGET = "Previous Take";
|
||||
const TAKE_NEXT_WIDGET = "Next Take";
|
||||
const TAKE_USE_WIDGET = "Use This Take";
|
||||
const TAKE_CONTINUE_WIDGET = "Continue From Here";
|
||||
const PRODUCTION_TRANSIENT_WIDGET = "__h3ContinuumProductionTransient";
|
||||
const FACADE_TRANSIENT_WIDGET = "__h3ContinuumFacadeTransient";
|
||||
const V38_VIEW_PROPERTY = "H3 Continuum View";
|
||||
const V38_VIEW_BASIC = "Basic";
|
||||
const V38_VIEW_PRODUCTION = "Production";
|
||||
{functions}
|
||||
|
||||
function widget(name, value) {{
|
||||
return {{ name, value, type: "combo", options: {{}}, computeSize: () => [120, 20] }};
|
||||
}}
|
||||
function makeNode() {{
|
||||
const node = {{
|
||||
comfyClass: V38_NODE_CLASS,
|
||||
properties: {{ [V38_VIEW_PROPERTY]: V38_VIEW_BASIC }},
|
||||
widgets: [
|
||||
widget("unrelated", 73),
|
||||
widget(RUN_STORAGE_WIDGET, "Off"),
|
||||
widget(REGENERATE_WIDGET, "Auto"),
|
||||
widget(REROLL_NONCE_WIDGET, 7),
|
||||
widget(GENERATION_MODE_WIDGET, GENERATION_MODE_FULL_RUN),
|
||||
widget(REVIEW_ACTION_WIDGET, REVIEW_ACTION_CONTINUE),
|
||||
widget(TAKE_GROUP_WIDGET, 0),
|
||||
widget(TAKE_REVISION_WIDGET, ""),
|
||||
widget(TAKE_ACTION_WIDGET, TAKE_ACTION_AUTOMATIC),
|
||||
],
|
||||
addWidget(type, name, value, callback, options) {{
|
||||
const item = {{ name, value, callback, type, options: options || {{}}, computeSize: () => [120, 20] }};
|
||||
this.widgets.push(item);
|
||||
return item;
|
||||
}},
|
||||
serialize() {{
|
||||
return {{ widgets_values: this.widgets.map((item) => item.value) }};
|
||||
}},
|
||||
configure(info) {{
|
||||
info.widgets_values.forEach((value, index) => {{ this.widgets[index].value = value; }});
|
||||
}},
|
||||
setDirtyCanvas() {{}},
|
||||
}};
|
||||
return node;
|
||||
}}
|
||||
|
||||
const node = makeNode();
|
||||
const originalValues = node.widgets.map((item) => item.value);
|
||||
configureProductionReviewUx(node);
|
||||
const basic = {{
|
||||
totalWidgets: node.widgets.length,
|
||||
transientHidden: transientProductionWidgets(node).every((item) => item.hidden),
|
||||
saved: node.serialize().widgets_values,
|
||||
}};
|
||||
|
||||
node.properties[V38_VIEW_PROPERTY] = V38_VIEW_PRODUCTION;
|
||||
node.__h3ContinuumProductionUxRefresh();
|
||||
const fullRunReviewUiHidden = transientProductionWidgets(node).every((item) => item.hidden);
|
||||
|
||||
findWidget(node, PRODUCTION_CONTINUE_WIDGET).callback();
|
||||
const continued = {{
|
||||
storage: findWidget(node, RUN_STORAGE_WIDGET).value,
|
||||
from: findWidget(node, REGENERATE_WIDGET).value,
|
||||
nonce: findWidget(node, REROLL_NONCE_WIDGET).value,
|
||||
mode: findWidget(node, GENERATION_MODE_WIDGET).value,
|
||||
action: findWidget(node, REVIEW_ACTION_WIDGET).value,
|
||||
plan: findWidget(node, PRODUCTION_STATUS_WIDGET).value,
|
||||
}};
|
||||
|
||||
setExistingWidgetValue(findWidget(node, REGENERATE_WIDGET), "Auto");
|
||||
findWidget(node, PRODUCTION_REGENERATE_WIDGET).callback();
|
||||
const regenerateInputs = {{ unrelated: "preserved" }};
|
||||
prepareReviewQueueIntent(node, regenerateInputs);
|
||||
const regenerated = {{
|
||||
from: findWidget(node, REGENERATE_WIDGET).value,
|
||||
action: findWidget(node, REVIEW_ACTION_WIDGET).value,
|
||||
inputs: regenerateInputs,
|
||||
plan: findWidget(node, PRODUCTION_STATUS_WIDGET).value,
|
||||
}};
|
||||
|
||||
findWidget(node, PRODUCTION_FINISH_WIDGET).callback();
|
||||
const finished = {{
|
||||
action: findWidget(node, REVIEW_ACTION_WIDGET).value,
|
||||
plan: findWidget(node, PRODUCTION_STATUS_WIDGET).value,
|
||||
}};
|
||||
|
||||
node.__h3ContinuumTakeProject = {{
|
||||
branch_provenance_version: 1,
|
||||
canonical_head_revision_id: "r3b",
|
||||
active_revisions: {{ "1": "r1", "2": "r2", "3": "r3b" }},
|
||||
group_revisions: [
|
||||
{{ revision_id: "r1", parent_revision_id: null, revision_order: "1", group: {{ physical_group: 1 }} }},
|
||||
{{ revision_id: "r2", parent_revision_id: "r1", revision_order: "2", group: {{ physical_group: 2 }} }},
|
||||
{{ revision_id: "r3a", parent_revision_id: "r2", revision_order: "3a", group: {{ physical_group: 3 }} }},
|
||||
{{ revision_id: "r3b", parent_revision_id: "r2", revision_order: "3b", group: {{ physical_group: 3 }} }},
|
||||
],
|
||||
}};
|
||||
node.__h3ContinuumProductionUxRefresh();
|
||||
findWidget(node, TAKE_PREVIOUS_WIDGET).callback();
|
||||
findWidget(node, TAKE_USE_WIDGET).callback();
|
||||
const takeInputs = {{}};
|
||||
prepareReviewQueueIntent(node, takeInputs);
|
||||
const take = {{
|
||||
group: findWidget(node, TAKE_GROUP_WIDGET).value,
|
||||
revision: findWidget(node, TAKE_REVISION_WIDGET).value,
|
||||
action: findWidget(node, TAKE_ACTION_WIDGET).value,
|
||||
status: findWidget(node, TAKE_STATUS_WIDGET).value,
|
||||
inputs: takeInputs,
|
||||
}};
|
||||
|
||||
const saved = node.serialize();
|
||||
const reloaded = makeNode();
|
||||
configureProductionReviewUx(reloaded);
|
||||
reloaded.configure(saved);
|
||||
const reload = {{
|
||||
values: reloaded.serialize().widgets_values,
|
||||
totalWidgets: reloaded.widgets.length,
|
||||
transientCount: transientProductionWidgets(reloaded).length,
|
||||
}};
|
||||
|
||||
console.log(JSON.stringify({{
|
||||
originalValues,
|
||||
basic,
|
||||
fullRunReviewUiHidden,
|
||||
continued,
|
||||
regenerated,
|
||||
finished,
|
||||
take,
|
||||
saved,
|
||||
reload,
|
||||
}}));
|
||||
"""
|
||||
script_path = tmp_path / "v38-n1-production-ux.js"
|
||||
script_path.write_text(script, encoding="utf-8")
|
||||
result = subprocess.run(
|
||||
[node_executable, str(script_path)],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
observed = json.loads(result.stdout)
|
||||
|
||||
assert observed["basic"] == {
|
||||
"totalWidgets": 22,
|
||||
"transientHidden": True,
|
||||
"saved": observed["originalValues"],
|
||||
}
|
||||
assert observed["fullRunReviewUiHidden"] is True
|
||||
assert observed["continued"] == {
|
||||
"storage": RUN_STORAGE_SAVE_AUTO_RESUME,
|
||||
"from": "Auto",
|
||||
"nonce": 7,
|
||||
"mode": GENERATION_MODE_REVIEW,
|
||||
"action": REVIEW_ACTION_CONTINUE,
|
||||
"plan": "Queue the workflow to create the first chunk.",
|
||||
}
|
||||
assert observed["regenerated"]["from"] == "Auto"
|
||||
assert observed["regenerated"]["action"] == REVIEW_ACTION_REGENERATE_CURRENT
|
||||
assert observed["regenerated"]["inputs"] == {
|
||||
"unrelated": "preserved",
|
||||
"generation_mode": GENERATION_MODE_REVIEW,
|
||||
"review_action": REVIEW_ACTION_REGENERATE_CURRENT,
|
||||
"take_group": 0,
|
||||
"take_revision_id": "",
|
||||
"take_action": "Automatic",
|
||||
}
|
||||
assert observed["regenerated"]["plan"] == (
|
||||
"Queue the workflow to create the first chunk."
|
||||
)
|
||||
assert observed["finished"]["action"] == REVIEW_ACTION_FINISH_REMAINING
|
||||
assert observed["finished"]["plan"] == (
|
||||
"Queue the workflow to create the first chunk."
|
||||
)
|
||||
assert {
|
||||
key: observed["take"][key]
|
||||
for key in ("group", "revision", "action", "inputs")
|
||||
} == {
|
||||
"group": 3,
|
||||
"revision": "r3a",
|
||||
"action": "Use This Take",
|
||||
"inputs": {
|
||||
"generation_mode": GENERATION_MODE_REVIEW,
|
||||
"review_action": REVIEW_ACTION_CONTINUE,
|
||||
"take_group": 3,
|
||||
"take_revision_id": "r3a",
|
||||
"take_action": "Use This Take",
|
||||
},
|
||||
}
|
||||
assert "Selected: Group 3 / Take 1 | r3a" in observed["take"]["status"]
|
||||
assert "Canonical: Group 3 / Take 2 | r3b" in observed["take"]["status"]
|
||||
assert "Next Queue: Use This Take (normal Queue required)" in observed["take"]["status"]
|
||||
assert len(observed["saved"]["widgets_values"]) == len(observed["originalValues"])
|
||||
assert observed["reload"] == {
|
||||
"values": observed["saved"]["widgets_values"],
|
||||
"totalWidgets": 22,
|
||||
"transientCount": 13,
|
||||
}
|
||||
|
||||
|
||||
def test_n2c_render_history_take_ux_is_complete_and_backend_derived(tmp_path):
|
||||
node_executable = shutil.which("node")
|
||||
if node_executable is None:
|
||||
pytest.skip("Node.js is required for the frontend behavior regression")
|
||||
|
||||
source = PROJECT_ID_JS.read_text(encoding="utf-8")
|
||||
functions = "\n".join(
|
||||
(
|
||||
_function_source(source, "findWidget", "setWidgetVisible"),
|
||||
_function_source(source, "setExistingWidgetValue", "productionQueueSummary"),
|
||||
_function_source(source, "takeRunName", "configureProductionReviewUx"),
|
||||
)
|
||||
)
|
||||
script = f"""
|
||||
const PROJECT_WIDGET = "project_id";
|
||||
const LEGACY_RUN_NAME_WIDGET = "run_name";
|
||||
const RUN_STORAGE_WIDGET = "run_storage";
|
||||
const GENERATION_MODE_WIDGET = "generation_mode";
|
||||
const REVIEW_ACTION_WIDGET = "review_action";
|
||||
const REGENERATE_WIDGET = "reroll_from_chunk";
|
||||
const TAKE_GROUP_WIDGET = "take_group";
|
||||
const TAKE_REVISION_WIDGET = "take_revision_id";
|
||||
const TAKE_ACTION_WIDGET = "take_action";
|
||||
const TAKE_ACTION_AUTOMATIC = "Automatic";
|
||||
const TAKE_ACTION_USE = "Use This Take";
|
||||
const TAKE_ACTION_CONTINUE = "Continue From Here";
|
||||
const GENERATION_MODE_REVIEW = "Review Each Chunk";
|
||||
const REVIEW_ACTION_CONTINUE = "Continue / Next";
|
||||
{functions}
|
||||
|
||||
function widget(name, value) {{
|
||||
return {{ name, value, callback: null }};
|
||||
}}
|
||||
|
||||
function makeNode(project = null, storage = "Off") {{
|
||||
return {{
|
||||
widgets: [
|
||||
widget(PROJECT_WIDGET, "123e4567-e89b-42d3-a456-426614174000"),
|
||||
widget(LEGACY_RUN_NAME_WIDGET, ""),
|
||||
widget(RUN_STORAGE_WIDGET, storage),
|
||||
widget(REGENERATE_WIDGET, "Auto"),
|
||||
widget(GENERATION_MODE_WIDGET, "Full Run"),
|
||||
widget(REVIEW_ACTION_WIDGET, REVIEW_ACTION_CONTINUE),
|
||||
widget(TAKE_GROUP_WIDGET, 0),
|
||||
widget(TAKE_REVISION_WIDGET, ""),
|
||||
widget(TAKE_ACTION_WIDGET, TAKE_ACTION_AUTOMATIC),
|
||||
],
|
||||
__h3ContinuumTakeProject: project,
|
||||
refreshes: 0,
|
||||
__h3ContinuumProductionUxRefresh() {{ this.refreshes += 1; }},
|
||||
setDirtyCanvas() {{}},
|
||||
}};
|
||||
}}
|
||||
|
||||
const project = {{
|
||||
run_storage_schema_version: 3,
|
||||
branch_provenance_version: 1,
|
||||
canonical_head_revision_id: "r56a-canonical-head",
|
||||
active_revisions: {{
|
||||
"1": "r1-root",
|
||||
"2": "r2-main",
|
||||
"3": "r3a-canonical",
|
||||
"4": "r4a-canonical",
|
||||
"5": "r56a-canonical-head",
|
||||
}},
|
||||
group_revisions: [
|
||||
{{ revision_id: "r1-root", parent_revision_id: null, lineage_sha256: "current-lineage", variation_nonce: 0, revision_order: "01", group: {{ physical_group: 1, start: 1, end: 1 }} }},
|
||||
{{ revision_id: "r2-main", parent_revision_id: "r1-root", lineage_sha256: "current-lineage", variation_nonce: 0, revision_order: "02", group: {{ physical_group: 2, start: 2, end: 2 }} }},
|
||||
{{ revision_id: "r3a-canonical", parent_revision_id: "r2-main", lineage_sha256: "current-lineage", variation_nonce: 1, revision_order: "03a", group: {{ physical_group: 3, start: 3, end: 3 }} }},
|
||||
{{ revision_id: "r3b-selected", parent_revision_id: "r2-main", lineage_sha256: "current-lineage", variation_nonce: 2, revision_order: "03b", group: {{ physical_group: 3, start: 3, end: 3 }} }},
|
||||
{{ revision_id: "r4a-canonical", parent_revision_id: "r3a-canonical", lineage_sha256: "current-lineage", variation_nonce: 1, revision_order: "04a", group: {{ physical_group: 4, start: 4, end: 4 }} }},
|
||||
{{ revision_id: "r4b-branch", parent_revision_id: "r3b-selected", lineage_sha256: "current-lineage", variation_nonce: 2, revision_order: "04b", group: {{ physical_group: 4, start: 4, end: 4 }} }},
|
||||
{{ revision_id: "r56a-canonical-head", parent_revision_id: "r4a-canonical", lineage_sha256: "current-lineage", variation_nonce: 1, revision_order: "05", group: {{ physical_group: 5, start: 5, end: 6 }} }},
|
||||
{{ revision_id: "old-root", parent_revision_id: null, lineage_sha256: "old-lineage", variation_nonce: 0, revision_order: "old-01", group: {{ physical_group: 1, start: 1, end: 1 }} }},
|
||||
{{ revision_id: "old-group-2", parent_revision_id: "old-root", lineage_sha256: "old-lineage", variation_nonce: 0, revision_order: "old-02", group: {{ physical_group: 2, start: 2, end: 2 }} }},
|
||||
{{ revision_id: "orphan-group-2", parent_revision_id: "missing-root", lineage_sha256: "current-lineage", variation_nonce: 3, revision_order: "orphan", group: {{ physical_group: 2, start: 2, end: 2 }} }},
|
||||
],
|
||||
}};
|
||||
|
||||
const one = makeNode({{
|
||||
run_storage_schema_version: 3,
|
||||
branch_provenance_version: 1,
|
||||
canonical_head_revision_id: "only-take",
|
||||
active_revisions: {{ "1": "only-take" }},
|
||||
group_revisions: [
|
||||
{{ revision_id: "only-take", parent_revision_id: null, variation_nonce: 0, revision_order: "01", group: {{ physical_group: 1, start: 1, end: 1 }} }},
|
||||
],
|
||||
}});
|
||||
const oneText = takeStatus(one);
|
||||
|
||||
const node = makeNode(project);
|
||||
const catalogIds = takeCatalog(node).map((item) => item.revision_id);
|
||||
findWidget(node, TAKE_GROUP_WIDGET).value = 3;
|
||||
findWidget(node, TAKE_REVISION_WIDGET).value = "r3b-selected";
|
||||
const selectedText = takeStatus(node);
|
||||
const canonicalBefore = JSON.stringify(project.active_revisions);
|
||||
selectTakeOffset(node, -1);
|
||||
const previous = {{
|
||||
group: findWidget(node, TAKE_GROUP_WIDGET).value,
|
||||
revision: findWidget(node, TAKE_REVISION_WIDGET).value,
|
||||
canonical: JSON.stringify(project.active_revisions),
|
||||
}};
|
||||
selectTakeOffset(node, 1);
|
||||
const next = {{
|
||||
group: findWidget(node, TAKE_GROUP_WIDGET).value,
|
||||
revision: findWidget(node, TAKE_REVISION_WIDGET).value,
|
||||
canonical: JSON.stringify(project.active_revisions),
|
||||
}};
|
||||
selectTakeAction(node, TAKE_ACTION_USE);
|
||||
const use = {{
|
||||
storage: findWidget(node, RUN_STORAGE_WIDGET).value,
|
||||
mode: findWidget(node, GENERATION_MODE_WIDGET).value,
|
||||
action: findWidget(node, TAKE_ACTION_WIDGET).value,
|
||||
canonical: JSON.stringify(project.active_revisions),
|
||||
text: takeStatus(node),
|
||||
}};
|
||||
findWidget(node, TAKE_ACTION_WIDGET).value = TAKE_ACTION_AUTOMATIC;
|
||||
selectTakeAction(node, TAKE_ACTION_CONTINUE);
|
||||
const continued = {{
|
||||
action: findWidget(node, TAKE_ACTION_WIDGET).value,
|
||||
revision: findWidget(node, TAKE_REVISION_WIDGET).value,
|
||||
text: takeStatus(node),
|
||||
}};
|
||||
|
||||
const legacy = makeNode({{
|
||||
run_storage_schema_version: 2,
|
||||
revisions: [{{ revision_id: "legacy" }}],
|
||||
}});
|
||||
const legacyText = takeStatus(legacy);
|
||||
|
||||
let fetchCount = 0;
|
||||
globalThis.fetch = async () => {{
|
||||
fetchCount += 1;
|
||||
return {{ ok: true, status: 200, json: async () => project }};
|
||||
}};
|
||||
const restarted = makeNode(null, "Save + Auto Resume");
|
||||
const loaded = await loadTakeHistory(restarted);
|
||||
const restart = {{
|
||||
loaded,
|
||||
fetchCount,
|
||||
group: findWidget(restarted, TAKE_GROUP_WIDGET).value,
|
||||
revision: findWidget(restarted, TAKE_REVISION_WIDGET).value,
|
||||
text: takeStatus(restarted),
|
||||
}};
|
||||
|
||||
globalThis.fetch = async () => ({{ ok: false, status: 404 }});
|
||||
const missing = makeNode(project, "Save + Auto Resume");
|
||||
findWidget(missing, TAKE_GROUP_WIDGET).value = 3;
|
||||
findWidget(missing, TAKE_REVISION_WIDGET).value = "r3b-selected";
|
||||
findWidget(missing, TAKE_ACTION_WIDGET).value = TAKE_ACTION_CONTINUE;
|
||||
await loadTakeHistory(missing);
|
||||
const missingResult = {{
|
||||
group: findWidget(missing, TAKE_GROUP_WIDGET).value,
|
||||
revision: findWidget(missing, TAKE_REVISION_WIDGET).value,
|
||||
action: findWidget(missing, TAKE_ACTION_WIDGET).value,
|
||||
text: takeStatus(missing),
|
||||
}};
|
||||
|
||||
console.log(JSON.stringify({{
|
||||
oneText,
|
||||
selectedText,
|
||||
catalogIds,
|
||||
canonicalBefore,
|
||||
previous,
|
||||
next,
|
||||
use,
|
||||
continued,
|
||||
legacyText,
|
||||
restart,
|
||||
missingResult,
|
||||
}}));
|
||||
"""
|
||||
script_path = tmp_path / "v38-n2c-render-history-ux.mjs"
|
||||
script_path.write_text(script, encoding="utf-8")
|
||||
result = subprocess.run(
|
||||
[node_executable, str(script_path)],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
observed = json.loads(result.stdout)
|
||||
|
||||
assert "Selected: Group 1 / Take 1" in observed["oneText"]
|
||||
assert "Compatible history: 1 Take" in observed["oneText"]
|
||||
assert "Run Storage: Off" in observed["oneText"]
|
||||
|
||||
selected = observed["selectedText"]
|
||||
assert "Selected: Group 3 / Take 2 | r3b-selected" in selected
|
||||
assert "Canonical: Group 3 / Take 1 | r3a-canonic" in selected
|
||||
assert "Canonical head: Group 5-6 (atomic) / Take 1 | r56a-canonic" in selected
|
||||
assert "Compatible history: 7 Takes" in selected
|
||||
assert "3 incompatible or incomplete Takes hidden" in selected
|
||||
assert "Continue From Here: Reuse Groups 1-3" in selected
|
||||
assert "Regenerate Groups 4, 5-6 (atomic)" in selected
|
||||
assert observed["catalogIds"] == [
|
||||
"r1-root", "r2-main", "r3a-canonical", "r3b-selected",
|
||||
"r4a-canonical", "r4b-branch", "r56a-canonical-head",
|
||||
]
|
||||
|
||||
assert observed["previous"] == {
|
||||
"group": 3,
|
||||
"revision": "r3a-canonical",
|
||||
"canonical": observed["canonicalBefore"],
|
||||
}
|
||||
assert observed["next"] == {
|
||||
"group": 3,
|
||||
"revision": "r3b-selected",
|
||||
"canonical": observed["canonicalBefore"],
|
||||
}
|
||||
assert observed["use"]["storage"] == RUN_STORAGE_SAVE_AUTO_RESUME
|
||||
assert observed["use"]["mode"] == GENERATION_MODE_REVIEW
|
||||
assert observed["use"]["action"] == "Use This Take"
|
||||
assert observed["use"]["canonical"] == observed["canonicalBefore"]
|
||||
assert "Next Queue: Use This Take (normal Queue required)" in observed["use"]["text"]
|
||||
assert observed["continued"]["action"] == "Continue From Here"
|
||||
assert observed["continued"]["revision"] == "r3b-selected"
|
||||
assert "Next Queue: Continue From Here (normal Queue required)" in observed["continued"]["text"]
|
||||
|
||||
assert "Legacy Run Storage v2 detected" in observed["legacyText"]
|
||||
assert "non-destructively" in observed["legacyText"]
|
||||
assert observed["restart"]["loaded"] is True
|
||||
assert observed["restart"]["fetchCount"] == 1
|
||||
assert observed["restart"]["group"] == 5
|
||||
assert observed["restart"]["revision"] == "r56a-canonical-head"
|
||||
assert "Canonical head: Group 5-6 (atomic)" in observed["restart"]["text"]
|
||||
assert observed["missingResult"] == {
|
||||
"group": 0,
|
||||
"revision": "",
|
||||
"action": "Automatic",
|
||||
"text": "No Render History yet",
|
||||
}
|
||||
def test_n1_production_shortcuts_are_transient_and_map_to_existing_intent(review_queue_results):
|
||||
for case in (
|
||||
"mode policy and transient UI serialization remain stable",
|
||||
"explicit restart consumed and Chunk 1 Continue restored",
|
||||
"the caller graph and workflow are not mutated by Queue adapter",
|
||||
"history browsing never changes serialized selection, explicit apply does",
|
||||
):
|
||||
assert review_queue_results[case]["pass"]
|
||||
|
||||
def test_n2c_render_history_take_ux_is_complete_and_backend_derived(review_queue_results):
|
||||
for case in (
|
||||
"history catalog preserves lineage eligibility and compact summary",
|
||||
"history browsing never changes serialized selection, explicit apply does",
|
||||
"late response for an old Run cannot replace the current history",
|
||||
"fresh browser state can open persisted Review without prior events",
|
||||
):
|
||||
assert review_queue_results[case]["pass"]
|
||||
|
||||
def test_n2c_history_refresh_hooks_and_multiline_surface_are_present():
|
||||
source = PROJECT_ID_JS.read_text(encoding="utf-8")
|
||||
assert '"Render History / Takes"' in source
|
||||
assert '{ multiline: true }' in source
|
||||
assert "loadTakeHistory(this)" in source
|
||||
assert "await loadTakeHistory(node," in source
|
||||
assert "attachTakeHistoryReload(node);" in source
|
||||
assert "node.__h3ContinuumTakeInitialLoad" in source
|
||||
assert 'const TAKE_TOGGLE_WIDGET = "Render History";' in source
|
||||
assert "app.queuePrompt =" not in source
|
||||
assert "api.queuePrompt =" not in source
|
||||
assert "api.__h3ContinuumReviewQueueAdapter" in source
|
||||
|
||||
+433
-313
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user