@rig-c/review 4.9.1 → 4.11.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.
- package/docs/DESIGN.md +5 -5
- package/docs/PANELS.md +3 -1
- package/docs/REVIEW_PACKAGE.md +143 -30
- package/docs/STABILITY.md +110 -3
- package/package.json +2 -2
- package/src/chest-landmarks.ts +9 -4
- package/src/cloth-recipe.ts +27 -7
- package/src/compare-html.ts +1 -1
- package/src/feedback-export.ts +2 -2
- package/src/feedback-validation.ts +11 -6
- package/src/frame-clock.ts +20 -4
- package/src/job-act.ts +60 -71
- package/src/job-api.ts +302 -46
- package/src/job-checkpoint-evidence.ts +17 -0
- package/src/job-cli.ts +3 -2
- package/src/job-contract.ts +107 -7
- package/src/job-front.ts +48 -12
- package/src/job-host.ts +7 -1
- package/src/job-session.ts +136 -26
- package/src/job-source.ts +133 -21
- package/src/job-store.ts +7 -4
- package/src/manifest.ts +59 -7
- package/src/open-workspace-state.ts +6 -1
- package/src/open.ts +3 -3
- package/src/rebuild.ts +42 -10
- package/src/session.ts +9 -4
- package/src/stage-comment.ts +2 -1
- package/web/catalog-en.ts +31 -6
- package/web/catalog-ko.ts +79 -54
- package/web/chest-editor.ts +236 -31
- package/web/cloth-panel.ts +1 -1
- package/web/compare.css +2 -2
- package/web/environment-world.ts +9 -0
- package/web/i18n.ts +1 -3
- package/web/inspection-persistence.ts +19 -6
- package/web/interview-panel.ts +13 -80
- package/web/job-rig-screen.ts +65 -37
- package/web/job-session.ts +204 -64
- package/web/label-placement.ts +25 -8
- package/web/main.ts +350 -114
- package/web/part-selection.ts +2 -1
- package/web/parts-viewport-provider.ts +21 -8
- package/web/rebuild-client.ts +3 -5
- package/web/rig-host.ts +5 -4
- package/web/rig-overlays.ts +3 -2
- package/web/rig-viewport-provider.ts +10 -6
- package/web/stage-comments.ts +24 -21
- package/web/styles.css +23 -51
- package/web/viewport-controller.ts +4 -0
- package/web/workspace-layout.ts +4 -4
- package/web/workspace-ui.ts +8 -6
package/web/interview-panel.ts
CHANGED
|
@@ -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 {
|
|
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
|
-
/**
|
|
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
|
|
256
|
-
|
|
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=()=>{
|
|
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{
|
|
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
|
}
|
package/web/job-rig-screen.ts
CHANGED
|
@@ -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, jobJson, 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
|
|
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;
|
|
@@ -134,11 +143,12 @@ export function createJobRigScreen(options: {
|
|
|
134
143
|
try {
|
|
135
144
|
const {entry} = options.routes(display);
|
|
136
145
|
const {manifest, reviewedSource} = inspection.metadata;
|
|
137
|
-
|
|
146
|
+
// #983: a declared plan picture ranks first; the walk below runs only without it.
|
|
147
|
+
let picture: JobRigScreenPrepared | null = !inspection.planPicture && manifest?.model && reviewedSource?.rig
|
|
138
148
|
? {jobRigScreen:true, display, entry, checkpoints:new Set(), review:{...inspection.metadata, manifest, reviewedSource}}
|
|
139
149
|
: null;
|
|
140
|
-
const
|
|
141
|
-
let previous =
|
|
150
|
+
const missingBoundPicture = inspection.interview?.questions.some(question => question.missingPicture);
|
|
151
|
+
let previous = missingBoundPicture || inspection.planPicture ? null : display.publication.previousPublicationId;
|
|
142
152
|
const jobId=jobPublicationRoutes(display,location.origin).jobId;
|
|
143
153
|
const seen = new Set([display.publication.publicationId]);
|
|
144
154
|
let generation = display.publication.generation;
|
|
@@ -153,10 +163,10 @@ export function createJobRigScreen(options: {
|
|
|
153
163
|
if(jobPublicationRoutes(candidate,location.origin).jobId!==jobId)throw new Error('JOB_DISPLAY_MISMATCH');
|
|
154
164
|
if (candidate.publication.publicationId !== previous || candidate.publication.generation >= generation) throw new Error('JOB_DISPLAY_MISMATCH');
|
|
155
165
|
generation = candidate.publication.generation;
|
|
156
|
-
if (jobRigScreenSubject(candidate.publication.source)) {picture = await prepare(candidate, signal, true);break;}
|
|
166
|
+
if (jobRigScreenSubject(candidate.publication.source, candidate.rigDraftVerdict)) {picture = await prepare(candidate, signal, true);break;}
|
|
157
167
|
previous = candidate.publication.previousPublicationId;
|
|
158
168
|
}
|
|
159
|
-
if (!picture && !
|
|
169
|
+
if (!picture && !missingBoundPicture && !inspection.planPicture && inspection.interview?.questions.some(question => question.hasParts)) {
|
|
160
170
|
const response = await fetch(options.routes(display).api('stage-parts'), {signal});
|
|
161
171
|
if (!response.ok) throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
162
172
|
const parts = await response.json() as PartsSubjectData;
|
|
@@ -164,12 +174,12 @@ export function createJobRigScreen(options: {
|
|
|
164
174
|
picture = {jobRigScreen:true,display,entry,checkpoints:new Set(),parts};
|
|
165
175
|
}
|
|
166
176
|
if(signal.aborted)throw new Error('JOB_PRELOAD_CANCELLED');
|
|
167
|
-
const
|
|
168
|
-
const forms = prepareJobForms(display, options.window.state().pending, ask => formFor(ask, inspection,
|
|
169
|
-
return {jobRigScreen:true,display,entry,checkpoints
|
|
177
|
+
const checkpoints = new Set<string>();
|
|
178
|
+
const forms = prepareJobForms(display, options.window.state().pending.filter(ask => jobRigScreenAsk(display, ask, checkpoints)), ask => formFor(ask, inspection, options.formDependencies!),true);
|
|
179
|
+
return {jobRigScreen:true,display,entry,checkpoints,record:{inspection,forms,picture}};
|
|
170
180
|
} catch(error) {inspection.dispose();throw error;}
|
|
171
181
|
}
|
|
172
|
-
if (!jobRigScreenSubject(source)) {
|
|
182
|
+
if (!jobRigScreenSubject(source, display.rigDraftVerdict)) {
|
|
173
183
|
if(!options.formDependencies)throw new Error('JOB_ACT_KIND_DISABLED');
|
|
174
184
|
const inspection=await prepareJobInspection(display,signal,true);
|
|
175
185
|
try {
|
|
@@ -180,16 +190,17 @@ export function createJobRigScreen(options: {
|
|
|
180
190
|
}catch(error){inspection.dispose();throw error;}
|
|
181
191
|
}
|
|
182
192
|
const routes = options.routes(display);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
// #1050: the modal inspection below reads the same metadata; jobJson hands it this request.
|
|
194
|
+
const review = await jobJson<ReviewJson>(routes.api('review'), signal).catch((error: unknown) => {
|
|
195
|
+
throw error instanceof Error && error.message === 'JOB_PRELOAD_FAILED' ? new Error('JOB_VISUAL_UNAVAILABLE') : error;
|
|
196
|
+
});
|
|
186
197
|
if (!review.manifest || !review.reviewedSource || review.sourceHash !== source.sourceHash ||
|
|
187
198
|
review.manifest.id !== source.package.id || review.manifest.revision !== source.package.revision ||
|
|
188
199
|
(review.reviewedSource.rig?.sha256 ?? null) !== (source.model?.sha256 ?? null)) throw new Error('JOB_DISPLAY_MISMATCH');
|
|
189
200
|
const checkpoints = new Set(review.manifest.checkpoints.map(item => item.id));
|
|
190
201
|
const refusal=backdropOnly?null:jobRigScreenRefusal(display,options.window.state().pending,checkpoints);
|
|
191
202
|
let parts:PartsSubjectData|undefined;
|
|
192
|
-
if(source.selector?.kind==='draft'&&source.parts){
|
|
203
|
+
if(source.selector?.kind==='draft'&&source.parts&&!display.rigDraftVerdict){
|
|
193
204
|
const response=await fetch(routes.api('stage-parts'),{signal});if(!response.ok)throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
194
205
|
parts=await response.json() as PartsSubjectData;
|
|
195
206
|
if(parts.sourceHash!==source.sourceHash||parts.mode!=='parts')throw new Error('JOB_DISPLAY_MISMATCH');
|
|
@@ -223,6 +234,7 @@ export function createJobRigScreen(options: {
|
|
|
223
234
|
if(directionWords!==undefined)for(const decision of decisions)if(decision.kind==='review-verdict'&&decision.value.stage==='direction-review')decision.value.words=directionWords;
|
|
224
235
|
if (!decisions.length) throw new Error('JOB_ACT_NOTHING_TO_SUBMIT');
|
|
225
236
|
const rigChanges=decisions.find(decision=>decision.kind==='review-verdict'&&decision.value.stage==='rig-review'&&decision.value.verdict==='changes-requested');
|
|
237
|
+
const chestDraft=rigChanges?.kind==='review-verdict'?screen?.chestLandmarks?.():null;
|
|
226
238
|
const meshDraft=rigChanges?.kind==='review-verdict'?await screen?.meshEdits?.():null;
|
|
227
239
|
if(rigChanges?.kind==='review-verdict'){
|
|
228
240
|
if(meshDraft?.edits.length){
|
|
@@ -230,8 +242,10 @@ export function createJobRigScreen(options: {
|
|
|
230
242
|
edits.sort((a,b)=>a.key<b.key?-1:a.key>b.key?1:0);
|
|
231
243
|
rigChanges.value.meshEdits=await Promise.all(edits.map(async ({edit})=>({edit,sha256:await sha256Hex(canonicalJson(edit))})));
|
|
232
244
|
}
|
|
245
|
+
if(chestDraft?.edits.length)rigChanges.value.chestLandmarks=await Promise.all(chestDraft.edits.map(async edit=>({edit,sha256:await sha256Hex(canonicalJson(edit))})));
|
|
233
246
|
const latest=options.window.state();
|
|
234
247
|
if(mounted!==prepared||latest.preparing||latest.receipt?.displayedNonce!==state.receipt.displayedNonce)throw new Error('JOB_ACT_SOURCE_STALE');
|
|
248
|
+
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
249
|
}
|
|
236
250
|
for (const decision of decisions) {
|
|
237
251
|
const key = JSON.stringify(decision.value);
|
|
@@ -250,9 +264,15 @@ export function createJobRigScreen(options: {
|
|
|
250
264
|
if (!result.ok) throw new Error(result.error.code, {cause: (result.error as {cause?: unknown}).cause});
|
|
251
265
|
attempts.delete(ask.askId);
|
|
252
266
|
const act=result.value;
|
|
253
|
-
if(decision===rigChanges&&rigChanges.kind==='review-verdict'&&
|
|
254
|
-
|
|
255
|
-
|
|
267
|
+
if(decision===rigChanges&&rigChanges.kind==='review-verdict'&&act.kind==='review-verdict'){
|
|
268
|
+
if(meshDraft&&(act.schema===JOB_MESH_EDITS_ACT_SCHEMA||act.schema===JOB_CHEST_LANDMARKS_ACT_SCHEMA)&&act.value.meshEdits){
|
|
269
|
+
const accepted=new Set(act.value.meshEdits.map(row=>row.sha256));
|
|
270
|
+
meshDraft.clear(rigChanges.value.meshEdits?.filter(row=>accepted.has(row.sha256)).map(row=>row.edit)??[]);
|
|
271
|
+
}
|
|
272
|
+
if(chestDraft&&act.schema===JOB_CHEST_LANDMARKS_ACT_SCHEMA){
|
|
273
|
+
const accepted=new Set(act.value.chestLandmarks.map(row=>row.sha256));
|
|
274
|
+
chestDraft.clear(rigChanges.value.chestLandmarks?.filter(row=>accepted.has(row.sha256)).map(row=>row.edit)??[]);
|
|
275
|
+
}
|
|
256
276
|
}
|
|
257
277
|
await committed({...current.commit, at: result.value.at});
|
|
258
278
|
}
|
|
@@ -270,12 +290,15 @@ export function createJobRigScreen(options: {
|
|
|
270
290
|
...(general?.length?{general:[...general]}:{})},key=JSON.stringify(value);
|
|
271
291
|
let attempt=partsAttempts.get(ask.askId);if(!attempt||attempt.key!==key){attempt={key,submissionId:crypto.randomUUID()};partsAttempts.set(ask.askId,attempt);}
|
|
272
292
|
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);
|
|
293
|
+
if(!result.ok)throw new Error(result.error.code,{cause:(result.error as {cause?:unknown}).cause});
|
|
274
294
|
partsAttempts.delete(ask.askId);return options.translate('job.saved');
|
|
275
295
|
}
|
|
276
296
|
const pendingSubjects=()=>options.window.state().pending.filter(ask=>ask.publicationId===mounted?.display.publication.publicationId&&ask.status==='pending').map(ask=>ask.subject);
|
|
277
297
|
function host(prepared: JobRigScreenPrepared, ready: {resolve(): void; reject(error: unknown): void}, navigation?:RigHostNavigation): JobRigMeshHost {
|
|
278
298
|
const base = new URL(prepared.entry).pathname;
|
|
299
|
+
const jobId = /^\/jobs\/([^/]+)\//.exec(base)?.[1];
|
|
300
|
+
const draftId = jobSourceDraftId(prepared.display.publication.source);
|
|
301
|
+
const previousPublicationId = prepared.display.publication.previousPublicationId;
|
|
279
302
|
const access: InstanceAccess = {base, key: prepared.display.publication.instanceKey, capability: options.access.capability,
|
|
280
303
|
route: path => {if (!path.startsWith('/') || path.startsWith('//')) throw new Error('Instance route must be app-absolute'); return base + path.slice(1);},
|
|
281
304
|
headers: init => options.access.headers(init)};
|
|
@@ -286,18 +309,19 @@ export function createJobRigScreen(options: {
|
|
|
286
309
|
return {...(backdrop?.subject?{subject:backdrop.subject}:{}),access:{...(backdrop?.access??access),capability:null,
|
|
287
310
|
headers:init=>{const headers=options.access.headers(init);headers.delete('X-Review-Capability');return headers;}},
|
|
288
311
|
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,
|
|
312
|
+
record:{...(jobId?{jobId}:{}),draftId,publicationId:prepared.display.publication.publicationId,previousPublicationId,label:prepared.display.publication.label,sourceHash:prepared.display.publication.source.sourceHash,hasPicture:!!record.picture,...record.inspection.planPicture?{planPicture:record.inspection.planPicture}:{},missingPicture:question?.missingPicture,questionPicture:question?.scenePicture || (question?.missingPicture && question.images.length ? true : undefined)},...prepared.refusal?{unavailable:prepared.refusal}:{},pendingSubjects,
|
|
290
313
|
read:(path,method)=>method==='GET'&&backdrop?backdrop.read(path,method):Promise.reject(new Error('JOB_REVIEW_READ_ONLY')),
|
|
291
314
|
submit:async()=>{throw new Error('JOB_REVIEW_READ_ONLY');},
|
|
292
315
|
submitParts:async()=>{throw new Error('JOB_REVIEW_READ_ONLY');},
|
|
293
|
-
attach:value=>{screen=value;lastMessage=['',false];streamReport=null;screen.pendingSubjects?.(pendingSubjects());refreshRecordForms();},
|
|
316
|
+
attach:value=>{screen=value;lastMessage=['',false];streamReport=null;screen.pendingSubjects?.(pendingSubjects());screen.progress?.(latestProgress);refreshRecordForms();},
|
|
294
317
|
displayed:()=>ready.resolve(),failed:error=>ready.reject(error)};
|
|
295
318
|
}
|
|
296
319
|
if(!review&&!prepared.parts)throw new Error('JOB_DISPLAY_MISMATCH');
|
|
297
320
|
const {publicationId,source}=prepared.display.publication;
|
|
298
|
-
const binding={publicationId,sourceHash:source.sourceHash};
|
|
321
|
+
const binding={...(jobId?{jobId}:{}),draftId,publicationId,previousPublicationId,sourceHash:source.sourceHash};
|
|
299
322
|
return {access,pendingSubjects,navigation,...prepared.refusal?{unavailable:prepared.refusal}:{},
|
|
300
|
-
|
|
323
|
+
chestLandmarks:prepared.display.publication.chestLandmarks,
|
|
324
|
+
...(source.direction?{direction:binding}:jobRigScreenSubject(source, prepared.display.rigDraftVerdict)?{verdictComments:{...binding,rows:[],available:()=>pendingSubjects().some(subject=>
|
|
301
325
|
prepared.parts?subject.kind==='parts-verdict':subject.kind==='review-verdict'&&subject.stage==='rig-review')}}:{}),
|
|
302
326
|
reviewState(issues,sending) {
|
|
303
327
|
if(sending)return options.translate('job.parts.sending');
|
|
@@ -325,8 +349,8 @@ export function createJobRigScreen(options: {
|
|
|
325
349
|
return Promise.reject(new Error('JOB_REVIEW_READ_ONLY'));
|
|
326
350
|
},
|
|
327
351
|
submit,
|
|
328
|
-
canSubmitMeshEdits:()=>!!screen?.hasMeshEdits?.(),
|
|
329
|
-
attach: value => {screen = value;lastMessage=['',false];streamReport=null;screen.pendingSubjects?.(pendingSubjects());refreshRecordForms();},
|
|
352
|
+
canSubmitMeshEdits:()=>!!(screen?.hasMeshEdits?.()||screen?.chestLandmarks?.()?.edits.length),
|
|
353
|
+
attach: value => {screen = value;lastMessage=['',false];streamReport=null;screen.pendingSubjects?.(pendingSubjects());screen.progress?.(latestProgress);refreshRecordForms();},
|
|
330
354
|
displayed: () => ready.resolve(),
|
|
331
355
|
failed: error => ready.reject(error)};
|
|
332
356
|
}
|
|
@@ -334,8 +358,8 @@ export function createJobRigScreen(options: {
|
|
|
334
358
|
function refreshRecordForms():void {
|
|
335
359
|
const record=mounted?.record??mounted?.modals,deps=options.formDependencies;if(!record||!deps)return;
|
|
336
360
|
const state=options.window.state(),display=record.inspection.display;
|
|
337
|
-
const
|
|
338
|
-
const
|
|
361
|
+
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);
|
|
362
|
+
for(const [id,entry]of record.forms)if(!next.has(id)){entry.dispose?.();record.forms.delete(id);}
|
|
339
363
|
for(const [id,entry]of next)record.forms.set(id,entry);
|
|
340
364
|
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
365
|
screen?.recordForms?.([...record.forms.values()].map(entry=>entry.form));
|
|
@@ -348,12 +372,16 @@ export function createJobRigScreen(options: {
|
|
|
348
372
|
route:()=>{throw new Error('JOB_DISPLAY_MISMATCH');},headers:init=>options.access.headers(init)},
|
|
349
373
|
read:()=>Promise.reject(new Error('JOB_DISPLAY_MISMATCH')),
|
|
350
374
|
submit:async()=>{throw new Error('JOB_ACT_SOURCE_STALE');},
|
|
351
|
-
attach:value=>{screen=value;attached();},displayed:()=>{},failed});
|
|
375
|
+
attach:value=>{screen=value;showProgress();attached();},displayed:()=>{},failed});
|
|
352
376
|
await options.load();await ready;
|
|
353
377
|
}
|
|
354
378
|
return {
|
|
355
379
|
prepare,waiting,
|
|
356
380
|
mounted: () => mounted,
|
|
381
|
+
progress(value: JobProgressV3 | null): void {
|
|
382
|
+
latestProgress = value;
|
|
383
|
+
showProgress();
|
|
384
|
+
},
|
|
357
385
|
report(error:unknown,fallback?:string):void {
|
|
358
386
|
const text=options.refusal(error,fallback),title=jobSubmissionRefusal(error).title;
|
|
359
387
|
if(fallback!=='JOB_STREAM_FAILED'){say(text,true,title);return;}
|
|
@@ -395,7 +423,7 @@ export function createJobRigScreen(options: {
|
|
|
395
423
|
// Filling consumes the waiting screen's one-shot continuation. Recreate that same shared
|
|
396
424
|
// composition after disposing its mutated candidate, so the next transaction can fill it again.
|
|
397
425
|
if(filling){screen=null;recovery=waiting();}
|
|
398
|
-
else recovery=Promise.resolve(previous?.resume?.());
|
|
426
|
+
else {previous?.progress?.(latestProgress);recovery=Promise.resolve(previous?.resume?.());}
|
|
399
427
|
return recovery;
|
|
400
428
|
};
|
|
401
429
|
const filling=!!previousHost?.waiting&&!!previous?.publish;
|