Files
pbakaus_impeccable/ui/component-review/entry.ts
T
Paul Bakaus 6a93a35293 Add human component review and prepare Impeccable 4.4.0
Carry native comp capture and completion integrity fixes into the reviewed component workflow. Bump the skill to 4.4.0 and engine/platform pins to 0.1.6; keep publication separate from this release candidate.

AI assistance: implemented and validated with OpenAI Codex.
2026-09-13 20:41:09 -07:00

22 lines
1.2 KiB
TypeScript

import { mountComponentReview } from './review';
import type { Draft, ReviewPacket, ReviewHistory } from './model';
async function start() {
const host=document.getElementById('review')!;
const response=await fetch('/packet',{cache:'no-store'});
if(!response.ok)throw new Error('The review packet could not be loaded. Reload to retry.');
const state=await response.json() as {packet:ReviewPacket;draft:Draft;receipt:unknown;history:ReviewHistory|null;sourceStatus:string|null};
if(state.sourceStatus){const notice=document.createElement('p');notice.textContent=state.sourceStatus;host.before(notice);}
mountComponentReview(host,state.packet,{
initialDraft:state.draft,
history:state.history,
completed:!!state.receipt,
onSubmit:async(value)=>{
const response=await fetch('/decision',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(value)});
const result=await response.json();
if(!response.ok)throw new Error(result.error??'The review could not be saved. Try again.');
},
});
}
start().catch(error=>{const p=document.createElement('p');p.textContent=error instanceof Error?error.message:String(error);document.getElementById('review')?.replaceChildren(p);});