@rig-c/review 4.9.1 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,6 @@
1
1
  import type { HistoricalInterview, InterviewQuestion, InterviewDiagnostic } from '../src/interview-project.ts';
2
2
  import type { Picks } from '../src/interview-picks.ts';
3
- import { onLanguageChange, t } from './i18n.ts';
4
- import { bindWorkspaceSeparator } from './workspace-layout.ts';
5
- import { createViewControls } from './view-controls.ts';
6
- import {WorkspacePreferenceStore,panelBounds} from './workspace-preferences.ts';
7
- import { createPartsViewport } from './parts-viewport-provider.ts';
3
+ import { t } from './i18n.ts';
8
4
 
9
5
  /** The active image-question form is mounted only while it owns the main reference pane. */
10
6
  export function hasTransientQuestionImage(root:{querySelector(selector:string):Element|null}=document):boolean {
@@ -128,70 +124,6 @@ export function interviewQuestionList(items: readonly {label: string; answered:
128
124
  return nav;
129
125
  }
130
126
 
131
- /**
132
- * The question's bound images in the shared native-image viewport (#708 return): the parts page's camera through
133
- * createPartsViewport and the shared control set in its fixed order (Zoom in, Zoom out, Fit, 1:1, View switch), where the
134
- * view switch picks the bound image. Control ids are dropped so the modal never shadows the page's own main view.
135
- */
136
- export function interviewImageView(images: readonly {name: string; src: string}[], selected: number, onSelect: (index: number) => void, bottom?:HTMLElement) {
137
- const image = images[selected]!;
138
- const controls = createViewControls({layout:'rigStep1', viewSwitch:{currentMode:String(selected), groups:[{modes:images.map((asset, index) =>
139
- ({id:String(index), labelKey:asset.name, pressed:index === selected}))}], onChange:id => onSelect(Number(id))}});
140
- const sync = controls.syncLabel.querySelector('input')!;
141
- const named = new Map<string, HTMLElement>([['zoom-in', controls.zoomButtons[0]!], ['zoom-out', controls.zoomButtons[1]!],
142
- ['fit', controls.zoomButtons[2]!], ['native-one', controls.nativeOne!], ['zoom-value', controls.value], ['camera-sync', sync]]);
143
- const toolbar = controls.zoomGroup!;
144
- const viewport = element('div'); viewport.className = 'interview-viewport';
145
- const root = element('div'); root.className = 'interview-view-root';
146
- // A canvas starts at 300 x 150; the camera has no frame until the bound image has drawn.
147
- const canvas = element('canvas'); root.append(canvas); viewport.append(root);
148
- let loaded = false;
149
- const reference = element('div'); reference.hidden = true;
150
- for (const [id, node] of [['rig-viewport', viewport], ['rig-pane', viewport], ['stage-layout', viewport], ['rig-root', root],
151
- ['reference-viewport', reference], ['reference-pane', reference], ['reference-content', reference]] as const) named.set(id, node);
152
- for (const node of [toolbar, ...toolbar.querySelectorAll('[id]'), sync]) node.removeAttribute('id');
153
- const unavailable = element('p'); unavailable.setAttribute('role', 'status'); unavailable.hidden = true;
154
- const view = element('div'); view.className = 'interview-view'; view.append(toolbar, viewport, unavailable);
155
- const camera = createPartsViewport({el:<T extends HTMLElement>(id: string) => named.get(id) as T, canvas, message:() => {},
156
- reference:() => null, frameSize:target => target === 'rig' && loaded ? {w:canvas.width, h:canvas.height} : null});
157
- const localize = () => {
158
- for (const button of toolbar.querySelectorAll<HTMLButtonElement>('[data-view]')) button.textContent = images[Number(button.dataset.view)]!.name;
159
- const summary = toolbar.querySelector('.view-menu summary');
160
- if (summary?.firstChild) summary.firstChild.textContent = t('View switch') + ' ';
161
- summary?.setAttribute('aria-label', t('View layout'));
162
- if (summary?.lastElementChild) summary.lastElementChild.textContent = image.name;
163
- for (const [button, key] of [[controls.zoomButtons[0]!, 'Zoom in'], [controls.zoomButtons[1]!, 'Zoom out']] as const) {
164
- button.textContent = t(key); button.setAttribute('aria-label', t(key));
165
- }
166
- unavailable.textContent = t('interview.imageUnavailable');
167
- };
168
- // Agent-authored part names stay verbatim; the controls' own words follow the shared catalogs.
169
- const unlocalize = onLanguageChange(() => {camera.renderCameraControls(); localize();}); localize();
170
- const disposers = [camera.bindControls(), camera.bindNavigation(), unlocalize];
171
- controls.nativeOne!.onclick = () => camera.cameraAction(() => camera.updateCamera('rig', {zoom:1, pan:{x:0, y:0}}));
172
- let fitted = false;
173
- const fit = () => {if (!fitted && loaded && camera.paneFrame('rig')) {fitted = true; camera.fitActiveCamera('rig');} else camera.fitCamera();};
174
- const resize = new ResizeObserver(fit); resize.observe(viewport);
175
- if(bottom){
176
- const preferences=new WorkspacePreferenceStore();let height:number=panelBounds.inspectorHeight.min;
177
- const separator=element('div');separator.className='workspace-separator interview-bottom-resize';
178
- view.append(separator,bottom);
179
- const range=()=>({min:panelBounds.inspectorHeight.min,max:Math.max(panelBounds.inspectorHeight.min,view.clientHeight-200),value:bottom.getBoundingClientRect().height,enabled:true});
180
- const apply=(value:number)=>{height=value;view.style.setProperty('--interview-answer-height',Math.min(range().max,Math.max(range().min,value))+'px');};
181
- const binding=bindWorkspaceSeparator({element:separator,panel:'inspectorHeight',controls:bottom.id,label:t('Resize Inspector'),range,desired:()=>height,resize:apply,commit:value=>preferences.update({panels:{inspectorHeight:value}})});
182
- const observer=new ResizeObserver(()=>{apply(height);binding.refresh();});observer.observe(view);
183
- disposers.push(()=>{observer.disconnect();binding.dispose();});apply(height);
184
- }
185
- const source = new Image();
186
- source.onload = () => {
187
- canvas.width = source.naturalWidth; canvas.height = source.naturalHeight; loaded = true;
188
- canvas.getContext('2d')?.drawImage(source, 0, 0); fit();
189
- };
190
- source.onerror = () => {viewport.hidden = true; unavailable.hidden = false;};
191
- source.alt = image.name; source.src = image.src;
192
- return {element:view, dispose() {source.onload=source.onerror=null;source.src='';resize.disconnect(); for (const dispose of disposers) dispose();}};
193
- }
194
-
195
127
  /** Real interview API rows shared by job publications and joined project inspection. */
196
128
  export type InterviewDisplayQuestion = Omit<InterviewQuestion,'images'> & {images:{name:string;url:string}[];saved?:Picks|null};
197
129
 
@@ -213,16 +145,19 @@ export function interviewRecords(diagnostics:readonly InterviewDiagnostic[]=[],h
213
145
  return records;
214
146
  }
215
147
 
216
- /** B's list | image | survey builder. Hosts supply genuine source data and their own submit transport. */
148
+ /** The question list and survey form. Hosts supply source data and submit transport. */
217
149
  export function createInterviewForm(options:{question:InterviewDisplayQuestion;id:string;node?:InterviewText;form?:HTMLFormElement;fieldset?:HTMLFieldSetElement;source?:HTMLElement;
218
150
  mainView?:boolean;images:readonly {name:string;src:string}[];questions?:readonly {label:string;answered:boolean}[]|(()=>readonly {label:string;answered:boolean}[]);selected?:number;onSelect?:(index:number)=>void;answered?:boolean;
219
- diagnostics?:readonly InterviewDiagnostic[];historical?:readonly HistoricalInterview[]}) {
151
+ diagnostics?:readonly InterviewDiagnostic[];historical?:readonly HistoricalInterview[];
152
+ /** #1004: a control kept at the top of the question list (the job page's one submit for several sets). */
153
+ listAction?:HTMLElement}) {
220
154
  const question=options.question,copy=new Map<HTMLElement,string>();
221
155
  const make=<K extends keyof HTMLElementTagNameMap>(tag:K,content?:string)=>element(tag,content,options.node);
222
156
  const node:InterviewText=(tag,key)=>{const result=options.node?options.node(tag,key):element(tag,key===undefined?undefined:t(key));if(key!==undefined)copy.set(result,key);return result;};
223
157
  const form=options.form??make('form'),fields=options.fieldset??make('fieldset');
224
158
  if(!options.fieldset)form.append(fields);
225
159
  const joined=options.id.startsWith('joined-interview-');
160
+ form.setAttribute('translate','no');
226
161
  form.className='interview-answer interview-grid';form.dataset.interviewAnswered=String(options.answered??Boolean((joined&&question.saved)||question.answer));
227
162
  fields.className='interview-answer-fields';fields.id=options.id;fields.disabled=!question.editable;
228
163
  const heading=make('h3',question.set.question);fields.append(heading);
@@ -252,10 +187,8 @@ export function createInterviewForm(options:{question:InterviewDisplayQuestion;i
252
187
  if(question.partsUnavailable)context.append(node('p','interview.partsUnavailable'));
253
188
  const provenance=make('p'),binding=make('code',question.ref.path+' · '+question.ref.sha256);context.append(provenance,binding);
254
189
  if(question.answer)context.append(make('pre',[question.answer.by,question.answer.at,question.answer.source].filter(value=>typeof value==='string').join(' · ')),make('pre',typeof question.answer.verbatim==='string'?question.answer.verbatim:''));
255
- if(options.mainView&&options.images.length){form.dataset.interviewMain='';Object.assign(form,{interviewImages:options.images});}
256
- const art=make('aside');art.className='interview-art';form.prepend(art);
257
- let view:ReturnType<typeof interviewImageView>|undefined,list:HTMLElement|undefined,records:HTMLElement|undefined;
258
- const showImage=(index:number)=>{view?.dispose();view?.element.remove();view=interviewImageView(options.images,index,showImage,context);art.append(view.element);};
190
+ if(options.mainView){form.dataset.interviewMain='';Object.assign(form,{interviewImages:options.images});}
191
+ let list:HTMLElement|undefined,records:HTMLElement|undefined;
259
192
  const refresh=()=>preserveScrollAndFocus(fields,()=>{
260
193
  submit.hidden=!question.editable||form.dataset.interviewAnswered==='true';
261
194
  noteInput.placeholder=t('interview.notePlaceholder');noteInput.setAttribute('placeholder',noteInput.placeholder);
@@ -266,18 +199,18 @@ export function createInterviewForm(options:{question:InterviewDisplayQuestion;i
266
199
  }
267
200
  provenance.textContent=t('interview.provenance',[question.set.drafted_by,question.set.drafted_at]);
268
201
  const questions=typeof options.questions==='function'?options.questions():options.questions;
269
- const items=questions?.map((item,index)=>({...item,answered:index===(options.selected??0)?form.dataset.interviewAnswered==='true':item.answered}))??[{label:question.set.question+' · '+question.set.id,answered:form.dataset.interviewAnswered==='true'}];
202
+ const items=questions?.map((item,index)=>({...item,answered:index===(options.selected??0)&&!options.listAction?form.dataset.interviewAnswered==='true':item.answered}))??[{label:question.set.question+' · '+question.set.id,answered:form.dataset.interviewAnswered==='true'}];
270
203
  const listTop=list?.scrollTop??0,listLeft=list?.scrollLeft??0;
271
- const next=interviewQuestionList(items,options.selected??0,options.onSelect??(()=>{}),false,options.node);list?.remove();form.prepend(next);next.scrollTop=listTop;next.scrollLeft=listLeft;list=next;
204
+ const next=interviewQuestionList(items,options.selected??0,options.onSelect??(()=>{}),false,options.node);if(options.listAction)next.prepend(options.listAction);list?.remove();form.prepend(next);next.scrollTop=listTop;next.scrollLeft=listLeft;list=next;
272
205
  records?.remove();records=interviewRecords(options.diagnostics,options.historical,options.node);context.append(records);
273
206
  });
274
207
  const submit=node('button','interview.save');submit.type='submit';submit.hidden=!question.editable;
275
208
  const status=node('p',!question.editable?'interview.history':question.saved?'interview.saved':'interview.choose');status.setAttribute('role','status');form.append(status);
276
209
  const localize=()=>{for(const [item,key]of copy)item.textContent=t(item.dataset.jobText??key);refresh();};
277
- const dispose=()=>{view?.dispose();form.removeEventListener('input',refresh);form.removeEventListener('change',refresh);form.removeEventListener('job-form-language',localize);};
210
+ const dispose=()=>{form.removeEventListener('input',refresh);form.removeEventListener('change',refresh);form.removeEventListener('job-form-language',localize);};
278
211
  form.addEventListener('input',refresh);form.addEventListener('change',refresh);form.addEventListener('job-form-language',localize);
279
- try{if(!options.mainView&&options.images.length)showImage(0);else{art.hidden=true;fields.append(context);}fields.append(submit);refresh();}catch(error){dispose();throw error;}
212
+ try{fields.append(context,submit);refresh();}catch(error){dispose();throw error;}
280
213
  return {form,fieldset:fields,submit,status,retainedNote,
281
214
  read:()=>jobInterviewValue(question.set.question,question.set.asks,item=>answers.find(answer=>answer.item===item)!.answer.value(),editableOnInit?noteInput.value:(retainedNote??'')),
282
- localize,dispose};
215
+ localize,dispose,refresh};
283
216
  }
@@ -1,10 +1,10 @@
1
- import {formFor, jobCheckpointContext, jobPublicationRoutes, prepareJobForms, prepareJobInspection, jobSubmissionRefusal, type JobForm, type JobFormDependencies, type JobPreparedInspection} from './job-session.ts';
1
+ import {formFor, jobCheckpointContext, jobPublicationRoutes, jobSourceDraftId, prepareJobForms, prepareJobInspection, jobSubmissionRefusal, type JobForm, type JobFormDependencies, type JobPreparedInspection} from './job-session.ts';
2
2
  import {commentPartsIssues,type PartsIssue} from '../src/parts-comment.ts';
3
3
  import type {PartsSubjectData} from './parts-viewport-provider.ts';
4
4
  /** Card I (#709): a rig publication of a live job opens the one review screen (`main.ts`) instead of the job
5
5
  * window. The job stays the transport: same asks, act kinds, still, displayed-ack and submission idempotency.
6
- * Rig verdicts use the act bar; supported approval and interview asks use the shared ask dialog. */
7
- import {JOB_MESH_EDITS_ACT_SCHEMA,type ActV3,type DisplayPublicationV3,type JobMeshEdit,type JobResult,type JobUISubmission,type PendingAskV3,type SourceV3,type UISubmissionV3} from '../src/job-contract.ts';
6
+ * Rig verdicts use the act bar, interviews use the Question tab, and text approvals use the shared ask dialog. */
7
+ import {JOB_CHEST_LANDMARKS_ACT_SCHEMA,JOB_MESH_EDITS_ACT_SCHEMA,type ActV3,type DisplayPublicationV3,type JobChestLandmarkEdit,type JobMeshEdit,type JobProgressV3,type JobPublishedChestLandmark,type JobResult,type JobUISubmission,type PendingAskV3,type SourceV3,type UISubmissionV3} from '../src/job-contract.ts';
8
8
  import {canonicalJson} from '../src/canonical-json.ts';
9
9
  import {draftKey} from '../src/mesh-edit.ts';
10
10
  import type {Feedback, ReviewSession} from '../src/session.ts';
@@ -12,15 +12,16 @@ import type {ReviewManifest, ReviewedSource} from '../src/manifest.ts';
12
12
  import {checkpointNoteComments, feedbackItemComments, projectComments} from '../src/stage-comment.ts';
13
13
  import {createJobRigSubmission, freezeJobRigStage} from './job-rig-capture.ts';
14
14
  import {sha256Hex,type JobMeshDraftSubmission} from './mesh-editor.ts';
15
+ import type {JobChestDraftSubmission} from './chest-editor.ts';
15
16
  import {setRigHost, rigHost, type RigHost, type RigHostScreen, type RigHostCommit, type RigHostNavigation} from './rig-host.ts';
16
17
  import {setSourceAttribute, setSourceText, sourceAttribute, sourceTextContent} from './i18n.ts';
17
18
  import type {InstanceAccess} from './instance-access.ts';
18
19
 
19
20
  /** The shared screen hosts model packages and parts drafts; records have their own shared host seam. */
20
- export function jobRigScreenSubject(source: SourceV3): boolean {
21
+ export function jobRigScreenSubject(source: SourceV3, rigDraftVerdict = false): boolean {
21
22
  if ('record' in source) return false;
22
23
  if(source.selector?.kind==='draft'&&source.parts)return true;
23
- return !!source.model && (source.direction ? source.selector?.kind === 'post' : source.selector === null || source.selector.kind === 'rig');
24
+ return !!source.model && (source.direction ? source.selector?.kind === 'post' : source.selector === null || source.selector.kind === 'rig' || (source.selector.kind === 'draft' && rigDraftVerdict));
24
25
  }
25
26
  /** The asks the rig screen's act bar answers: the rig verdict and checkpoints the package declares. */
26
27
  export function jobRigScreenAnswers(ask: Pick<PendingAskV3, 'subject'>, checkpoints: ReadonlySet<string>): boolean {
@@ -35,7 +36,6 @@ export function jobRigScreenAsk(display:DisplayPublicationV3,ask:PendingAskV3,ch
35
36
  try {prepareJobForms(display,[ask],()=>jobCheckpointContext(ask,[]));return true;}catch{return false;}
36
37
  }
37
38
  if(ask.subject.kind==='signoff'||ask.subject.kind==='interview-picks')return true;
38
- if('record' in source)return ask.subject.kind==='reopen';
39
39
  return !!source.model&&jobRigScreenAnswers(ask,checkpoints)&&
40
40
  (ask.subject.kind!=='review-verdict'||ask.subject.stage===(source.direction?'direction-review':'rig-review'));
41
41
  }
@@ -43,8 +43,8 @@ export function jobRigScreenRoute(display: DisplayPublicationV3, pending: readon
43
43
  checkpoints: ReadonlySet<string>): boolean {
44
44
  const source=display.publication.source,id=display.publication.publicationId;
45
45
  if('record' in source)return false;
46
- if(source.selector?.kind==='draft'&&source.parts)return true;
47
- return (jobRigScreenSubject(source)||!source.model&&!source.parts)&&pending.every(ask=>
46
+ if(source.selector?.kind==='draft'&&source.parts&&!display.rigDraftVerdict)return true;
47
+ return (jobRigScreenSubject(source, display.rigDraftVerdict)||!source.model&&!source.parts)&&pending.every(ask=>
48
48
  ask.publicationId!==id||ask.status!=='pending'||jobRigScreenAsk(display,ask,checkpoints));
49
49
  }
50
50
 
@@ -54,7 +54,7 @@ export function jobRigScreenRefusal(display:DisplayPublicationV3,pending:readonl
54
54
  if('record' in source)return null;
55
55
  {
56
56
  if(source.selector?.kind==='post'&&!source.direction)return 'JOB_DIRECTION_MISSING';
57
- if(source.selector?.kind==='draft'&&!source.parts)return 'JOB_PARTS_MISSING';
57
+ if(source.selector?.kind==='draft'&&!source.parts&&!display.rigDraftVerdict)return 'JOB_PARTS_MISSING';
58
58
  if(!source.model&&!source.parts&&!hasPicture&&!pending.some(ask=>ask.publicationId===display.publication.publicationId&&ask.status==='pending'&&ask.subject.kind!=='review-verdict'&&jobRigScreenAsk(display,ask,checkpoints)))return 'JOB_MODEL_MISSING';
59
59
  }
60
60
  return jobRigScreenRoute(display,pending,checkpoints)?null:'JOB_ASK_UNSUPPORTED';
@@ -62,7 +62,7 @@ export function jobRigScreenRefusal(display:DisplayPublicationV3,pending:readonl
62
62
 
63
63
  export type JobRigScreenDecision =
64
64
  | {readonly ask: PendingAskV3; readonly kind: 'checkpoint'; readonly value: Extract<JobUISubmission, {kind: 'checkpoint'}>['value']}
65
- | {readonly ask: PendingAskV3; readonly kind: 'review-verdict'; readonly value: {stage: 'rig-review' | 'direction-review'; verdict: 'approved' | 'changes-requested'; words: string; feedback?: readonly Feedback[]; general?: readonly string[]; meshEdits?: readonly JobMeshEdit[]}};
65
+ | {readonly ask: PendingAskV3; readonly kind: 'review-verdict'; readonly value: {stage: 'rig-review' | 'direction-review'; verdict: 'approved' | 'changes-requested'; words: string; feedback?: readonly Feedback[]; general?: readonly string[]; meshEdits?: readonly JobMeshEdit[]; chestLandmarks?: readonly JobChestLandmarkEdit[]}};
66
66
  /** The act bar's decisions as the pending asks' values. `words` is the comments' projection (act@6's), or empty;
67
67
  * a decision still pending is not sent, so a pending ask is never answered with "pending". Checkpoints go first. */
68
68
  export function jobRigScreenDecisions(session: Pick<ReviewSession, 'status' | 'checkpoints' | 'feedback'>,
@@ -91,9 +91,11 @@ interface ReviewJson {manifest: ReviewManifest; reviewedSource: ReviewedSource;
91
91
  export interface JobRigMeshScreen extends RigHostScreen {
92
92
  hasMeshEdits?(): boolean;
93
93
  meshEdits?(): Promise<JobMeshDraftSubmission|null>;
94
+ chestLandmarks?(): JobChestDraftSubmission|null;
94
95
  }
95
96
  export interface JobRigMeshHost extends RigHost {
96
97
  canSubmitMeshEdits?(): boolean;
98
+ readonly chestLandmarks?: readonly JobPublishedChestLandmark[];
97
99
  }
98
100
  export interface JobRigScreenPrepared {readonly jobRigScreen: true; readonly display: DisplayPublicationV3; readonly entry: string;
99
101
  readonly refusal?:string; readonly modals?: {inspection:JobPreparedInspection;forms:Map<string,JobForm>}; readonly review?: ReviewJson; readonly record?: {inspection:JobPreparedInspection;forms:Map<string,JobForm>;picture:JobRigScreenPrepared|null}; readonly parts?:PartsSubjectData; readonly checkpoints: ReadonlySet<string>}
@@ -112,10 +114,17 @@ export function createJobRigScreen(options: {
112
114
  formDependencies?:JobFormDependencies;
113
115
  refusal(error: unknown, fallback?: string): string;
114
116
  translate(key: string,values?:readonly (string|number)[]): string;
117
+ confirm?(text: string): boolean;
115
118
  /** Imports the rig composition once the host is set. */
116
119
  load(): Promise<unknown>;
117
120
  }) {
118
121
  let mounted: JobRigScreenPrepared | null = null, screen: JobRigMeshScreen | null = null, drawGeneration = 0;
122
+ let latestProgress: JobProgressV3 | null = null;
123
+ const showProgress=()=>{
124
+ if(!screen?.progress)return;
125
+ const awaitingAsk=screen.publish&&options.window.state().pending.some(ask=>ask.status==='pending');
126
+ screen.progress(awaitingAsk?null:latestProgress);
127
+ };
119
128
  let lastMessage: [text: string, error?: boolean, diagnostic?: string] = ['', false];
120
129
  let streamReport: {message: [text: string, error?: boolean, diagnostic?: string]; footer: {source: string; title: string; sourceTitle: string | null; error: boolean} | null; header: {source: string; error: boolean} | null; applied: string} | null = null;
121
130
  let transition:{rollback():Promise<void>;finalize():void}|null=null;
@@ -137,8 +146,8 @@ export function createJobRigScreen(options: {
137
146
  let picture: JobRigScreenPrepared | null = manifest?.model && reviewedSource?.rig
138
147
  ? {jobRigScreen:true, display, entry, checkpoints:new Set(), review:{...inspection.metadata, manifest, reviewedSource}}
139
148
  : null;
140
- const missingBoundRig = inspection.interview?.questions.some(question => question.missingPicture === 'rig');
141
- let previous = missingBoundRig ? null : display.publication.previousPublicationId;
149
+ const missingBoundPicture = inspection.interview?.questions.some(question => question.missingPicture);
150
+ let previous = missingBoundPicture ? null : display.publication.previousPublicationId;
142
151
  const jobId=jobPublicationRoutes(display,location.origin).jobId;
143
152
  const seen = new Set([display.publication.publicationId]);
144
153
  let generation = display.publication.generation;
@@ -153,10 +162,10 @@ export function createJobRigScreen(options: {
153
162
  if(jobPublicationRoutes(candidate,location.origin).jobId!==jobId)throw new Error('JOB_DISPLAY_MISMATCH');
154
163
  if (candidate.publication.publicationId !== previous || candidate.publication.generation >= generation) throw new Error('JOB_DISPLAY_MISMATCH');
155
164
  generation = candidate.publication.generation;
156
- if (jobRigScreenSubject(candidate.publication.source)) {picture = await prepare(candidate, signal, true);break;}
165
+ if (jobRigScreenSubject(candidate.publication.source, candidate.rigDraftVerdict)) {picture = await prepare(candidate, signal, true);break;}
157
166
  previous = candidate.publication.previousPublicationId;
158
167
  }
159
- if (!picture && !missingBoundRig && inspection.interview?.questions.some(question => question.hasParts)) {
168
+ if (!picture && !missingBoundPicture && inspection.interview?.questions.some(question => question.hasParts)) {
160
169
  const response = await fetch(options.routes(display).api('stage-parts'), {signal});
161
170
  if (!response.ok) throw new Error('JOB_VISUAL_UNAVAILABLE');
162
171
  const parts = await response.json() as PartsSubjectData;
@@ -164,12 +173,12 @@ export function createJobRigScreen(options: {
164
173
  picture = {jobRigScreen:true,display,entry,checkpoints:new Set(),parts};
165
174
  }
166
175
  if(signal.aborted)throw new Error('JOB_PRELOAD_CANCELLED');
167
- const questionMainView = !!picture || !!inspection.interview?.questions.some(question => question.scenePicture);
168
- const forms = prepareJobForms(display, options.window.state().pending, ask => formFor(ask, inspection, {...options.formDependencies!,interviewMainView:questionMainView}),questionMainView);
169
- return {jobRigScreen:true,display,entry,checkpoints:new Set(),record:{inspection,forms,picture}};
176
+ const checkpoints = new Set<string>();
177
+ const forms = prepareJobForms(display, options.window.state().pending.filter(ask => jobRigScreenAsk(display, ask, checkpoints)), ask => formFor(ask, inspection, options.formDependencies!),true);
178
+ return {jobRigScreen:true,display,entry,checkpoints,record:{inspection,forms,picture}};
170
179
  } catch(error) {inspection.dispose();throw error;}
171
180
  }
172
- if (!jobRigScreenSubject(source)) {
181
+ if (!jobRigScreenSubject(source, display.rigDraftVerdict)) {
173
182
  if(!options.formDependencies)throw new Error('JOB_ACT_KIND_DISABLED');
174
183
  const inspection=await prepareJobInspection(display,signal,true);
175
184
  try {
@@ -189,7 +198,7 @@ export function createJobRigScreen(options: {
189
198
  const checkpoints = new Set(review.manifest.checkpoints.map(item => item.id));
190
199
  const refusal=backdropOnly?null:jobRigScreenRefusal(display,options.window.state().pending,checkpoints);
191
200
  let parts:PartsSubjectData|undefined;
192
- if(source.selector?.kind==='draft'&&source.parts){
201
+ if(source.selector?.kind==='draft'&&source.parts&&!display.rigDraftVerdict){
193
202
  const response=await fetch(routes.api('stage-parts'),{signal});if(!response.ok)throw new Error('JOB_VISUAL_UNAVAILABLE');
194
203
  parts=await response.json() as PartsSubjectData;
195
204
  if(parts.sourceHash!==source.sourceHash||parts.mode!=='parts')throw new Error('JOB_DISPLAY_MISMATCH');
@@ -223,6 +232,7 @@ export function createJobRigScreen(options: {
223
232
  if(directionWords!==undefined)for(const decision of decisions)if(decision.kind==='review-verdict'&&decision.value.stage==='direction-review')decision.value.words=directionWords;
224
233
  if (!decisions.length) throw new Error('JOB_ACT_NOTHING_TO_SUBMIT');
225
234
  const rigChanges=decisions.find(decision=>decision.kind==='review-verdict'&&decision.value.stage==='rig-review'&&decision.value.verdict==='changes-requested');
235
+ const chestDraft=rigChanges?.kind==='review-verdict'?screen?.chestLandmarks?.():null;
226
236
  const meshDraft=rigChanges?.kind==='review-verdict'?await screen?.meshEdits?.():null;
227
237
  if(rigChanges?.kind==='review-verdict'){
228
238
  if(meshDraft?.edits.length){
@@ -230,8 +240,10 @@ export function createJobRigScreen(options: {
230
240
  edits.sort((a,b)=>a.key<b.key?-1:a.key>b.key?1:0);
231
241
  rigChanges.value.meshEdits=await Promise.all(edits.map(async ({edit})=>({edit,sha256:await sha256Hex(canonicalJson(edit))})));
232
242
  }
243
+ if(chestDraft?.edits.length)rigChanges.value.chestLandmarks=await Promise.all(chestDraft.edits.map(async edit=>({edit,sha256:await sha256Hex(canonicalJson(edit))})));
233
244
  const latest=options.window.state();
234
245
  if(mounted!==prepared||latest.preparing||latest.receipt?.displayedNonce!==state.receipt.displayedNonce)throw new Error('JOB_ACT_SOURCE_STALE');
246
+ if(rigChanges.value.meshEdits?.length&&options.confirm&&!options.confirm(options.translate('Send this Request changes with {0} mesh edit(s) to the producer?',[rigChanges.value.meshEdits.length])))return '';
235
247
  }
236
248
  for (const decision of decisions) {
237
249
  const key = JSON.stringify(decision.value);
@@ -250,9 +262,15 @@ export function createJobRigScreen(options: {
250
262
  if (!result.ok) throw new Error(result.error.code, {cause: (result.error as {cause?: unknown}).cause});
251
263
  attempts.delete(ask.askId);
252
264
  const act=result.value;
253
- if(decision===rigChanges&&rigChanges.kind==='review-verdict'&&meshDraft&&act.schema===JOB_MESH_EDITS_ACT_SCHEMA&&act.kind==='review-verdict'&&act.value.meshEdits){
254
- const accepted=new Set(act.value.meshEdits.map(row=>row.sha256));
255
- meshDraft.clear(rigChanges.value.meshEdits?.filter(row=>accepted.has(row.sha256)).map(row=>row.edit)??[]);
265
+ if(decision===rigChanges&&rigChanges.kind==='review-verdict'&&act.kind==='review-verdict'){
266
+ if(meshDraft&&(act.schema===JOB_MESH_EDITS_ACT_SCHEMA||act.schema===JOB_CHEST_LANDMARKS_ACT_SCHEMA)&&act.value.meshEdits){
267
+ const accepted=new Set(act.value.meshEdits.map(row=>row.sha256));
268
+ meshDraft.clear(rigChanges.value.meshEdits?.filter(row=>accepted.has(row.sha256)).map(row=>row.edit)??[]);
269
+ }
270
+ if(chestDraft&&act.schema===JOB_CHEST_LANDMARKS_ACT_SCHEMA){
271
+ const accepted=new Set(act.value.chestLandmarks.map(row=>row.sha256));
272
+ chestDraft.clear(rigChanges.value.chestLandmarks?.filter(row=>accepted.has(row.sha256)).map(row=>row.edit)??[]);
273
+ }
256
274
  }
257
275
  await committed({...current.commit, at: result.value.at});
258
276
  }
@@ -270,12 +288,15 @@ export function createJobRigScreen(options: {
270
288
  ...(general?.length?{general:[...general]}:{})},key=JSON.stringify(value);
271
289
  let attempt=partsAttempts.get(ask.askId);if(!attempt||attempt.key!==key){attempt={key,submissionId:crypto.randomUUID()};partsAttempts.set(ask.askId,attempt);}
272
290
  const result=await options.window.submit({kind:'parts-verdict',publicationId:ask.publicationId,askId:ask.askId,pageId:options.pageId,displayedNonce:state.receipt.displayedNonce,expectedGeneration:state.generation,submissionId:attempt.submissionId,value});
273
- if(!result.ok)throw new Error(result.error.code);
291
+ if(!result.ok)throw new Error(result.error.code,{cause:(result.error as {cause?:unknown}).cause});
274
292
  partsAttempts.delete(ask.askId);return options.translate('job.saved');
275
293
  }
276
294
  const pendingSubjects=()=>options.window.state().pending.filter(ask=>ask.publicationId===mounted?.display.publication.publicationId&&ask.status==='pending').map(ask=>ask.subject);
277
295
  function host(prepared: JobRigScreenPrepared, ready: {resolve(): void; reject(error: unknown): void}, navigation?:RigHostNavigation): JobRigMeshHost {
278
296
  const base = new URL(prepared.entry).pathname;
297
+ const jobId = /^\/jobs\/([^/]+)\//.exec(base)?.[1];
298
+ const draftId = jobSourceDraftId(prepared.display.publication.source);
299
+ const previousPublicationId = prepared.display.publication.previousPublicationId;
279
300
  const access: InstanceAccess = {base, key: prepared.display.publication.instanceKey, capability: options.access.capability,
280
301
  route: path => {if (!path.startsWith('/') || path.startsWith('//')) throw new Error('Instance route must be app-absolute'); return base + path.slice(1);},
281
302
  headers: init => options.access.headers(init)};
@@ -286,18 +307,19 @@ export function createJobRigScreen(options: {
286
307
  return {...(backdrop?.subject?{subject:backdrop.subject}:{}),access:{...(backdrop?.access??access),capability:null,
287
308
  headers:init=>{const headers=options.access.headers(init);headers.delete('X-Review-Capability');return headers;}},
288
309
  ownerActAccess:{capability:options.access.capability},
289
- record:{publicationId:prepared.display.publication.publicationId,label:prepared.display.publication.label,sourceHash:prepared.display.publication.source.sourceHash,hasPicture:!!record.picture,missingPicture:question?.missingPicture,scenePicture:question?.scenePicture},...prepared.refusal?{unavailable:prepared.refusal}:{},pendingSubjects,
310
+ record:{...(jobId?{jobId}:{}),draftId,publicationId:prepared.display.publication.publicationId,previousPublicationId,label:prepared.display.publication.label,sourceHash:prepared.display.publication.source.sourceHash,hasPicture:!!record.picture,missingPicture:question?.missingPicture,questionPicture:question?.scenePicture || (question?.missingPicture && question.images.length ? true : undefined)},...prepared.refusal?{unavailable:prepared.refusal}:{},pendingSubjects,
290
311
  read:(path,method)=>method==='GET'&&backdrop?backdrop.read(path,method):Promise.reject(new Error('JOB_REVIEW_READ_ONLY')),
291
312
  submit:async()=>{throw new Error('JOB_REVIEW_READ_ONLY');},
292
313
  submitParts:async()=>{throw new Error('JOB_REVIEW_READ_ONLY');},
293
- attach:value=>{screen=value;lastMessage=['',false];streamReport=null;screen.pendingSubjects?.(pendingSubjects());refreshRecordForms();},
314
+ attach:value=>{screen=value;lastMessage=['',false];streamReport=null;screen.pendingSubjects?.(pendingSubjects());screen.progress?.(latestProgress);refreshRecordForms();},
294
315
  displayed:()=>ready.resolve(),failed:error=>ready.reject(error)};
295
316
  }
296
317
  if(!review&&!prepared.parts)throw new Error('JOB_DISPLAY_MISMATCH');
297
318
  const {publicationId,source}=prepared.display.publication;
298
- const binding={publicationId,sourceHash:source.sourceHash};
319
+ const binding={...(jobId?{jobId}:{}),draftId,publicationId,previousPublicationId,sourceHash:source.sourceHash};
299
320
  return {access,pendingSubjects,navigation,...prepared.refusal?{unavailable:prepared.refusal}:{},
300
- ...(source.direction?{direction:binding}:jobRigScreenSubject(source)?{verdictComments:{...binding,rows:[],available:()=>pendingSubjects().some(subject=>
321
+ chestLandmarks:prepared.display.publication.chestLandmarks,
322
+ ...(source.direction?{direction:binding}:jobRigScreenSubject(source, prepared.display.rigDraftVerdict)?{verdictComments:{...binding,rows:[],available:()=>pendingSubjects().some(subject=>
301
323
  prepared.parts?subject.kind==='parts-verdict':subject.kind==='review-verdict'&&subject.stage==='rig-review')}}:{}),
302
324
  reviewState(issues,sending) {
303
325
  if(sending)return options.translate('job.parts.sending');
@@ -325,8 +347,8 @@ export function createJobRigScreen(options: {
325
347
  return Promise.reject(new Error('JOB_REVIEW_READ_ONLY'));
326
348
  },
327
349
  submit,
328
- canSubmitMeshEdits:()=>!!screen?.hasMeshEdits?.(),
329
- attach: value => {screen = value;lastMessage=['',false];streamReport=null;screen.pendingSubjects?.(pendingSubjects());refreshRecordForms();},
350
+ canSubmitMeshEdits:()=>!!(screen?.hasMeshEdits?.()||screen?.chestLandmarks?.()?.edits.length),
351
+ attach: value => {screen = value;lastMessage=['',false];streamReport=null;screen.pendingSubjects?.(pendingSubjects());screen.progress?.(latestProgress);refreshRecordForms();},
330
352
  displayed: () => ready.resolve(),
331
353
  failed: error => ready.reject(error)};
332
354
  }
@@ -334,8 +356,8 @@ export function createJobRigScreen(options: {
334
356
  function refreshRecordForms():void {
335
357
  const record=mounted?.record??mounted?.modals,deps=options.formDependencies;if(!record||!deps)return;
336
358
  const state=options.window.state(),display=record.inspection.display;
337
- const questionMainView = !!mounted?.record?.picture || !!record.inspection.interview?.questions.some(question => question.scenePicture);
338
- const next=prepareJobForms(display,state.pending.filter(ask=>ask.subject.kind!=='parts-verdict'&&ask.subject.kind!=='review-verdict'&&jobRigScreenAsk(display,ask,mounted!.checkpoints)),ask=>{const previous=record.forms.get(ask.askId),saved=state.pending.find(item=>item.askId===ask.askId);if(previous&&saved?.act?.kind==='interview-picks'&&ask.status==='answered'&&!previous.submitting&&previous.form.dataset.interviewAnswered!=='true'){previous.dispose?.();return formFor(saved,record.inspection,{...deps,interviewMainView:questionMainView});}return previous??formFor(saved??ask,record.inspection,{...deps,interviewMainView:questionMainView});},questionMainView);
359
+ const next=prepareJobForms(display,state.pending.filter(ask=>ask.subject.kind!=='parts-verdict'&&ask.subject.kind!=='review-verdict'&&jobRigScreenAsk(display,ask,mounted!.checkpoints)),ask=>{const previous=record.forms.get(ask.askId),saved=state.pending.find(item=>item.askId===ask.askId);if(previous&&saved?.act?.kind==='interview-picks'&&ask.status==='answered'&&!previous.submitting&&previous.form.dataset.interviewAnswered!=='true'){previous.dispose?.();return formFor(saved,record.inspection,deps);}return previous??formFor(saved??ask,record.inspection,deps);},true);
360
+ for(const [id,entry]of record.forms)if(!next.has(id)){entry.dispose?.();record.forms.delete(id);}
339
361
  for(const [id,entry]of next)record.forms.set(id,entry);
340
362
  for(const [id,entry]of record.forms){const ask=state.pending.find(ask=>ask.askId===id);entry.fieldset.disabled=entry.submitting||ask?.status!=='pending'||state.preparing||state.closed||!state.receipt||!options.access.capability;}
341
363
  screen?.recordForms?.([...record.forms.values()].map(entry=>entry.form));
@@ -348,12 +370,16 @@ export function createJobRigScreen(options: {
348
370
  route:()=>{throw new Error('JOB_DISPLAY_MISMATCH');},headers:init=>options.access.headers(init)},
349
371
  read:()=>Promise.reject(new Error('JOB_DISPLAY_MISMATCH')),
350
372
  submit:async()=>{throw new Error('JOB_ACT_SOURCE_STALE');},
351
- attach:value=>{screen=value;attached();},displayed:()=>{},failed});
373
+ attach:value=>{screen=value;showProgress();attached();},displayed:()=>{},failed});
352
374
  await options.load();await ready;
353
375
  }
354
376
  return {
355
377
  prepare,waiting,
356
378
  mounted: () => mounted,
379
+ progress(value: JobProgressV3 | null): void {
380
+ latestProgress = value;
381
+ showProgress();
382
+ },
357
383
  report(error:unknown,fallback?:string):void {
358
384
  const text=options.refusal(error,fallback),title=jobSubmissionRefusal(error).title;
359
385
  if(fallback!=='JOB_STREAM_FAILED'){say(text,true,title);return;}
@@ -395,7 +421,7 @@ export function createJobRigScreen(options: {
395
421
  // Filling consumes the waiting screen's one-shot continuation. Recreate that same shared
396
422
  // composition after disposing its mutated candidate, so the next transaction can fill it again.
397
423
  if(filling){screen=null;recovery=waiting();}
398
- else recovery=Promise.resolve(previous?.resume?.());
424
+ else {previous?.progress?.(latestProgress);recovery=Promise.resolve(previous?.resume?.());}
399
425
  return recovery;
400
426
  };
401
427
  const filling=!!previousHost?.waiting&&!!previous?.publish;