@rig-c/review 4.9.0 → 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.
- package/docs/DESIGN.md +4 -4
- package/docs/REVIEW_PACKAGE.md +90 -16
- package/docs/STABILITY.md +100 -3
- package/package.json +2 -2
- package/src/chest-landmarks.ts +9 -4
- 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 +286 -40
- package/src/job-cli.ts +3 -2
- package/src/job-contract.ts +92 -5
- package/src/job-front.ts +19 -8
- package/src/job-host.ts +7 -1
- package/src/job-session.ts +136 -26
- package/src/job-source.ts +109 -14
- package/src/job-store.ts +7 -4
- package/src/manifest.ts +59 -7
- package/src/rebuild.ts +1 -1
- package/src/session.ts +9 -4
- package/src/stage-comment.ts +2 -1
- package/web/catalog-en.ts +26 -6
- package/web/catalog-ko.ts +49 -29
- package/web/chest-editor.ts +236 -31
- package/web/compare.css +2 -2
- 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 +59 -33
- package/web/job-session.ts +175 -40
- package/web/label-placement.ts +25 -8
- package/web/main.ts +314 -89
- package/web/part-selection.ts +2 -1
- package/web/parts-viewport-provider.ts +19 -6
- package/web/rebuild-client.ts +2 -4
- package/web/rig-host.ts +5 -4
- package/web/rig-overlays.ts +3 -2
- package/web/rig-viewport-provider.ts +6 -1
- package/web/stage-comments.ts +22 -21
- package/web/styles.css +21 -49
- package/web/workspace-layout.ts +4 -4
- package/web/workspace-ui.ts +5 -3
package/web/main.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {hasTransientQuestionImage} from './interview-panel.ts';
|
|
2
2
|
import {advanceTake,bindScenePlates,loadScenePlates,takeSample} from './scene-plates.ts';
|
|
3
3
|
import type {SceneInspection} from '../src/scene-inspection.ts';
|
|
4
|
-
import type {RecordSource} from '../src/job-contract.ts';
|
|
4
|
+
import type {JobProgressV3,RecordSource} from '../src/job-contract.ts';
|
|
5
5
|
import type {InterviewSubjectEntry} from '../src/joined-project.ts';
|
|
6
6
|
import {mountJobScreen,joinedInterviewForms,mediaReady,jobSubmissionRefusal} from './job-session.ts';
|
|
7
7
|
import {partsIssueComments,parsePartsIssue,assertPartsIssueBinding} from '../src/parts-comment.ts';
|
|
@@ -151,10 +151,13 @@ for(const event of ['click','change'])secondaryToolbar.addEventListener(event,()
|
|
|
151
151
|
const rigInspector=mountRigInspector(document,shell.actRow??undefined);
|
|
152
152
|
if(host)rigInspector.act.hidden=true;
|
|
153
153
|
const rigAsk=panelMake('button',{className:'workspace-act-ask',id:'workspace-pending-ask',hidden:true});rigAsk.type='button';
|
|
154
|
+
const recordAsk=panelMake('button',{className:'workspace-act-ask',id:'workspace-pending-record-ask',hidden:true,type:'button'});
|
|
154
155
|
const askHeadline=panelMake('span',{id:'workspace-ask-headline',className:'workspace-act-ask',hidden:true});
|
|
155
156
|
const requestChanges=panelMake('button',{id:'request-changes',type:'button',hidden:true});
|
|
156
|
-
rigInspector.act.prepend(askHeadline,rigAsk);button('save').after(requestChanges);
|
|
157
|
+
rigInspector.act.prepend(askHeadline,rigAsk,recordAsk);button('save').after(requestChanges);
|
|
157
158
|
let pendingAnswers:readonly {kind:string;stage?:string}[]=[],answerSaved=false;
|
|
159
|
+
let jobProgress:JobProgressV3|null=null,progressTimer:ReturnType<typeof setInterval>|undefined;
|
|
160
|
+
let askSentence='';
|
|
158
161
|
let partsAnswerBlocked:()=>boolean=()=>false;
|
|
159
162
|
mountViewportPair(el('stage-layout'));
|
|
160
163
|
const viewportState=createViewportState();
|
|
@@ -163,7 +166,11 @@ let partsSubject:ReturnType<typeof bindPartsSubject>|null=null;
|
|
|
163
166
|
let setupPartsPersistence:(()=>Promise<void>)|null=null;
|
|
164
167
|
let rigDifference:{assets:ModelAssets;painting:HTMLImageElement;camera:ReturnType<typeof createViewportState>;hidden:Map<HTMLElement,boolean>;label:string;bookmark:InspectionBookmark}|null=null;
|
|
165
168
|
let rigDifferenceFailure:string|null=null;
|
|
166
|
-
const rigRaster={el,canvas:partsCanvas,message,reference:()=>null,
|
|
169
|
+
const rigRaster={el,canvas:partsCanvas,message,reference:()=>null,
|
|
170
|
+
frameSize:(target:CameraTarget)=>activeInterviewImage
|
|
171
|
+
?target==='reference'&&referenceSize?{w:referenceSize.width,h:referenceSize.height}:null
|
|
172
|
+
:{w:partsCanvas.width,h:partsCanvas.height},
|
|
173
|
+
active:()=>!!rigDifference||!!activeInterviewImage};
|
|
167
174
|
if(partsOnly){partsCanvas.id='parts-canvas';el('rig-root').append(partsCanvas);el('reference-content').append(partsReference);}
|
|
168
175
|
let sceneComposite:ReturnType<typeof bindScenePlates>|undefined;
|
|
169
176
|
const activeScene=()=>sceneComposite&&data.direction&&(!stageSource||stageSource.url===inspectedModel?.url)?data.direction:undefined;
|
|
@@ -235,6 +242,7 @@ let idleHeld=false;
|
|
|
235
242
|
let suspendedPreview=false;
|
|
236
243
|
let controlDispose:(()=>void)|null=null;
|
|
237
244
|
const viewDisposers:(()=>void)[]=[];
|
|
245
|
+
if(host)viewDisposers.push(onLanguageChange(()=>{if(jobProgress&&!pendingAnswers.length)renderAskHeadline();}));
|
|
238
246
|
const layers={images:true,mesh:false,bones:false,meshOpacity:.65};
|
|
239
247
|
let chestMapping:CropWorldMapping={available:false,reason:'CHEST_REGION_MAPPING_UNAVAILABLE: no compiled model drawn'};
|
|
240
248
|
let setupChestWorld:{x:number;y:number}|null=null;
|
|
@@ -332,7 +340,7 @@ function renderDraftState(): void {
|
|
|
332
340
|
const live=host?.reviewState?.(liveIssueCount(),saving);
|
|
333
341
|
renderAnswerControls();
|
|
334
342
|
if (draftStatus === null && !live && !answerSaved) return;
|
|
335
|
-
rigInspector.actBar.setSaveState({ kind: actReadOnly ? 'read-only' : saving ? 'saving' : draftConflict ? 'failed' : dirty ? 'unsaved' : 'saved', text: draftConflict ? 'Saved draft could not be restored. Your draft has not been deleted. Download or discard it before submitting.' : answerSaved ? 'Answer saved' : draftStatus&&/^(
|
|
343
|
+
rigInspector.actBar.setSaveState({ kind: actReadOnly ? 'read-only' : saving ? 'saving' : draftConflict ? 'failed' : dirty ? 'unsaved' : 'saved', text: draftConflict ? 'Saved draft could not be restored. Your draft has not been deleted. Download or discard it before submitting.' : answerSaved ? 'Answer saved' : draftStatus&&/^(The source changed, so |Local draft could not be saved|Local draft storage unavailable|Local draft needs explicit recovery)/.test(draftStatus)?draftStatus:actReadOnly??live??draftStatus! });
|
|
336
344
|
if(answerSaved&&!saving&&!draftConflict&&!dirty&&!actReadOnly&&(host?.record||!host)&&
|
|
337
345
|
(host?.pendingSubjects?.()??pendingAnswers).every(subject=>subject.kind==='interview-picks')&&!el('message').classList.contains('error'))message(sourceTextContent(el('dirty')),false,true);
|
|
338
346
|
}
|
|
@@ -541,6 +549,7 @@ async function showReference(id: string, bound?:{name:string;src:string}): Promi
|
|
|
541
549
|
const content = el('reference-content'); content.replaceChildren();
|
|
542
550
|
const reference = bound?{id:'',label:bound.name,type:'image' as const,path:''}:data.manifest.references.find(item => item.id === id);
|
|
543
551
|
el('reference-empty').hidden = false;setReferenceInput(reference?{state:'pending'}:{state:'absent'});
|
|
552
|
+
if(bound)viewport.requestFit();
|
|
544
553
|
if (!reference) { text('reference-empty', 'No reference supplied.'); text('reference-info', 'Add image, video or input-pose references to the package.'); return; }
|
|
545
554
|
text('reference-label', reference.label + (reference.type === 'pose' ? ' · Static input pose' : ' · Reference'));
|
|
546
555
|
text('reference-empty', 'Loading reference…');
|
|
@@ -643,7 +652,7 @@ function renderFrameTransport(): void {
|
|
|
643
652
|
function activeTransportClock() {
|
|
644
653
|
if(activeScene())return null;
|
|
645
654
|
const active = player && player.current !== animation ? '' : animation;
|
|
646
|
-
return transportClock({ clock: data.report?.clock, animation: data.report?.animation }, active, !!player, stageClock, stageModelHash);
|
|
655
|
+
return transportClock({ clock: data.report?.clock, animation: data.report?.animation, frameClocks: data.feedbackCatalog?.frameClocks }, active, !!player, stageClock, stageModelHash);
|
|
647
656
|
}
|
|
648
657
|
function activeFrameClock() { return activeScene()?null:activeTransportClock()?.clock ?? null; }
|
|
649
658
|
|
|
@@ -659,7 +668,7 @@ function seekFrame(frame: number): void {
|
|
|
659
668
|
function drawRig(action:()=>void):void {
|
|
660
669
|
if(rigDifference&&rigDifference.assets!==assets){leaveRigDifference();renderLayout();}
|
|
661
670
|
inDrawRig=true;
|
|
662
|
-
try{const box=sceneBox();if(box&&player?.renderer instanceof CanvasRenderer)player.renderer.viewport=box;action();if(box&&player){sceneComposite?.draw(player,box);}parts?.present('single');if(box)viewport.fitCamera();if(player&&inspectionSourceState==='ready')animationPanel?.capture(player,parts?.frame('single'));else animationPanel?.capture(null,undefined);text('renderer-state',rendererStatus(player?.renderer??null,'succeeded').label);redrawOverlay(true);}
|
|
671
|
+
try{const box=sceneBox();if(box&&player?.renderer instanceof CanvasRenderer)player.renderer.viewport=box;action();if(box&&player){sceneComposite?.draw(player,box);}parts?.present('single');chestEditor?.syncJobTarget();if(box)viewport.fitCamera();if(player&&inspectionSourceState==='ready')animationPanel?.capture(player,parts?.frame('single'));else animationPanel?.capture(null,undefined);text('renderer-state',rendererStatus(player?.renderer??null,'succeeded').label);redrawOverlay(true);}
|
|
663
672
|
catch(error){animationPanel?.capture(null,undefined);overlays?.clear();text('renderer-state',rendererStatus(null,'failed').label);throw error;}
|
|
664
673
|
finally{inDrawRig=false;}
|
|
665
674
|
}
|
|
@@ -916,6 +925,7 @@ async function initPlayer(initialCheckpoint?:Checkpoint): Promise<void> {
|
|
|
916
925
|
const animations = select('animation-select'); animations.replaceChildren();
|
|
917
926
|
for (const item of assets.animations) animations.append(option(item.name, data.manifest.animations.find(a => a.id === item.name)?.label ?? item.name));
|
|
918
927
|
animations.disabled = assets.animations.length === 0 || !!data.scene;
|
|
928
|
+
if(host?.chestLandmarks?.length)updateChestMapping();
|
|
919
929
|
const names=assets.animations.map(clip=>clip.name),initial=data.scene?.animation??initialIdleAnimation(names,initialPlayerAnimation(names,data.initialAnimation??undefined,initialCheckpoint),!!data.initialAnimation||!!initialCheckpoint?.animation||!!initialCheckpoint?.axis);
|
|
920
930
|
if(initial)chooseAnimation(initial);else drawRig(()=>player!.draw());
|
|
921
931
|
el('rig-empty').hidden = true; text('player-state', '@rig-c/play · Actual rig');
|
|
@@ -1208,7 +1218,7 @@ function bind(): void {
|
|
|
1208
1218
|
await persistence?.submitted(submittedBaseline);
|
|
1209
1219
|
comments?.refresh(); renderProposals();
|
|
1210
1220
|
},host.direction?recordCommentWords():undefined,general);
|
|
1211
|
-
message(sent);
|
|
1221
|
+
if (sent) message(sent);
|
|
1212
1222
|
} catch (error) {
|
|
1213
1223
|
submissionFailure = jobSubmissionRefusal(error);
|
|
1214
1224
|
message(submissionFailure.text, true);
|
|
@@ -1242,7 +1252,13 @@ function bind(): void {
|
|
|
1242
1252
|
bindWorkspace(!!data.manifest.model);
|
|
1243
1253
|
overlays=new RigOverlays({canvas:el<HTMLCanvasElement>('rig-overlay'),rigRoot:el('rig-root')});
|
|
1244
1254
|
verdictSubmit=button('save').onclick as ((event:MouseEvent)=>unknown)|null;
|
|
1245
|
-
chestEditor=bindChestEditor({pane:el('rig-pane'),canvas:el('rig-overlay'),project:()=>player?rigProject():null,mapping:()=>activeChestMapping(),
|
|
1255
|
+
chestEditor=bindChestEditor({pane:el('rig-pane'),canvas:el('rig-overlay'),project:()=>player?rigProject():null,mapping:()=>activeChestMapping(),
|
|
1256
|
+
job:host?(readOnly||host.direction?'read-only':{
|
|
1257
|
+
seeds:()=>inspectionSourceState==='ready'&&stageModelHash===data.reviewedSource.rig?.sha256&&chestMapping.available?host?.chestLandmarks??[]:[],
|
|
1258
|
+
selection:()=>{const part=parts?.value();return part?{slot:part.slot,skin:part.identity?.skin??null,attachment:part.identity?.attachment??null}:null;},
|
|
1259
|
+
download:edit=>download('chest-landmarks.json',JSON.stringify(edit,null,2)+'\n','application/json'),
|
|
1260
|
+
}):undefined,
|
|
1261
|
+
changed:()=>{renderChest();if(host)renderAnswerControls();},download:()=>{void exportChest();},apply:()=>{void applyRebuild();},reset:()=>{void resetRebuild();},message,inspector:()=>selectedInspector()});viewDisposers.push(()=>chestEditor?.dispose());
|
|
1246
1262
|
const editRefusal=sealedRecordRigReadOnly();
|
|
1247
1263
|
if(editRefusal)chestEditor.unavailable(editRefusal);
|
|
1248
1264
|
meshEditor=bindMeshEditor({pane:el('rig-pane'),canvas:el('rig-overlay'),project:()=>player?rigProject():null,mapping:()=>chestMapping,inspector:()=>selectedInspector(),readOnly:!!editRefusal,source:meshSource,pause,
|
|
@@ -1327,12 +1343,12 @@ async function start(): Promise<void> {
|
|
|
1327
1343
|
.filter(control=>control.id!=='settings-language').map(control=>({control,disabled:control.disabled}));
|
|
1328
1344
|
for(const {control}of controls)control.disabled=true;
|
|
1329
1345
|
for(const control of [button('save'),requestChanges,select('review-status'),screenRoot.querySelector<HTMLElement>('label[for="review-status"]')!])control.hidden=true;
|
|
1330
|
-
|
|
1346
|
+
renderAskHeadline(t('job.waiting',undefined,'en'));syncJobActRow();
|
|
1331
1347
|
await workspace?.settle();if(disposed)return;
|
|
1332
1348
|
const next=await new Promise<RigHost>((resolve,reject)=>{
|
|
1333
1349
|
lifecycle.signal.addEventListener('abort',()=>reject(new Error('JOB_PRELOAD_CANCELLED')),{once:true});
|
|
1334
1350
|
host!.attach({publish:resolve,stage:()=>null,redraw:()=>{},
|
|
1335
|
-
message:(value,error,diagnostic)=>message(value,error,false,diagnostic),suspend:()=>{},dispose:disposeScreen});
|
|
1351
|
+
message:(value,error,diagnostic)=>message(value,error,false,diagnostic),progress:setJobProgress,suspend:()=>{},dispose:disposeScreen});
|
|
1336
1352
|
});
|
|
1337
1353
|
if(disposed)return;
|
|
1338
1354
|
host=next;access=next.access;partsOnly=next.subject==='parts';
|
|
@@ -1365,7 +1381,7 @@ async function start(): Promise<void> {
|
|
|
1365
1381
|
// Checkpoints and reference fold away when the package supplies neither.
|
|
1366
1382
|
(el('package-context') as HTMLDetailsElement).open = data.manifest.checkpoints.length > 0 || data.manifest.references.length > 0;
|
|
1367
1383
|
const sourceFiles = el('source-files'); for (const file of data.manifest.authoring) { const a = document.createElement('a'); a.href = assetUrl(file.path); a.textContent = file.label; a.className = 'source-link'; a.target = '_blank'; a.rel = 'noopener'; sourceFiles.append(a); } if (!data.manifest.authoring.length) sourceFiles.textContent = 'No source files supplied';sourceFiles.parentElement!.hidden=!data.manifest.authoring.length;
|
|
1368
|
-
populateChestBones(); bind(); parts=new PartExplorer(el('workspace-left'),el('selected-part'),previous=>{if(rigDifference){leaveRigDifference();renderLayout();}const part=parts?.value();if(!stageCorrectionRebinding&&(previous?.side!==part?.side||previous?.slot!==part?.slot||previous?.mode!==part?.mode))stageDraftRequestToken++;if(player&&inspectionSourceState==='ready')animationPanel?.capture(player,parts?.frame('single'));else animationPanel?.capture(null,undefined);weightsView?.refresh();redrawOverlay(true);meshEditor?.selectionChanged();if(stageCorrectionPart&&!stageCorrectionRebinding&&(part?.slot??null)!==stageCorrectionPart){stageCorrectionPart=null;document.getElementById('stage-draft-label')?.remove();}animationPanel?.fromParts(part?.slot??null);meshPanel?.select(part?.slot??null);if(part&&!stageCorrectionRebinding)void openStageCorrection({part:part.slot,instrument:'selection'});requirementsPanel?.selectionChanged();renderDropNotices();if(part){viewport.state.activeCamera='rig';if(view==='reference')setView('rig');if(selectedInspector(document)!=='playback')showInspector('rig');renderCameraControls();}if(!viewport.state.cameraRestoring&&(previous?.side!==part?.side||previous?.slot!==part?.slot))cameraAction(()=>fitActiveCamera(part?'rig':availableCamera()));persistence?.save();},part=>{select('feedback-target-kind').value='slot';renderFeedbackTargets(true);input('feedback-target-name').value=part.slot;showInspector('feedback');}); animationPanel=new AnimationInspectionPanel({hideGateBanner:!!host?.direction,readOnlyReason:sealedRecordRigReadOnly,host:el('animation-inspection'),stage:el('rig-viewport'),project:(x,y)=>rigProject()(x,y),enabled:()=>inspectionSourceState==='ready'&&selectedInspector(document)==='playback',pause,preview:fn=>{animAdjust=fn;if(!player)return;player.adjust=composeAdjust(composeAdjust(composeAdjust(idleAdjust,dialAdjust),turnAdjust),animAdjust);if(!inDrawRig&&player.current&&!playing){if(activeScene())seek(time);else{player.seek(time);drawRig(()=>player!.draw());}}},apply:ops=>applyAnimation(ops),reset:()=>resetAnimationBuild(),seek:exact=>{if(!Number.isFinite(exact)||exact<0||exact>duration){message('KEY_TIME_OUT_OF_DOMAIN: no substitute time was used.',true);return;}seekMarker(animation,exact,'Stored key');},select:value=>{const slot=value?.kind==='slot'?value.name:null;if((parts?.value()?.slot??null)!==slot)parts?.select(slot?{side:'single',slot,mode:parts?.value()?.mode??'context'}:null);parts?.highlightBone(value?.kind==='bone'?value.name:null);redrawOverlay(false);}});viewDisposers.push(()=>animationPanel?.dispose()); updateStripControls(); stripStatus('Choose the entered start–end frames or all feedback ranges to download. Unsubmitted feedback is included; exporting does not submit the review.'); renderFeedbackTargets(true); renderFeedbackRange(); renderCheckpoints(); renderProposals(); renderProvenance(); updateSavedState(); renderCues(); initReport();
|
|
1384
|
+
populateChestBones(); bind(); parts=new PartExplorer(el('workspace-left'),el('selected-part'),previous=>{if(rigDifference){leaveRigDifference();renderLayout();}const part=parts?.value();if(!stageCorrectionRebinding&&(previous?.side!==part?.side||previous?.slot!==part?.slot||previous?.mode!==part?.mode))stageDraftRequestToken++;if(player&&inspectionSourceState==='ready')animationPanel?.capture(player,parts?.frame('single'));else animationPanel?.capture(null,undefined);weightsView?.refresh();redrawOverlay(true);meshEditor?.selectionChanged();if(stageCorrectionPart&&!stageCorrectionRebinding&&(part?.slot??null)!==stageCorrectionPart){stageCorrectionPart=null;document.getElementById('stage-draft-label')?.remove();}animationPanel?.fromParts(part?.slot??null);meshPanel?.select(part?.slot??null);if(host)chestEditor?.sync();else if(part&&!stageCorrectionRebinding)void openStageCorrection({part:part.slot,instrument:'selection'});requirementsPanel?.selectionChanged();renderDropNotices();if(part){viewport.state.activeCamera='rig';if(view==='reference')setView('rig');if(selectedInspector(document)!=='playback')showInspector('rig');renderCameraControls();}if(!viewport.state.cameraRestoring&&(previous?.side!==part?.side||previous?.slot!==part?.slot))cameraAction(()=>fitActiveCamera(part?'rig':availableCamera()));persistence?.save();},part=>{select('feedback-target-kind').value='slot';renderFeedbackTargets(true);input('feedback-target-name').value=part.slot;showInspector('feedback');}); animationPanel=new AnimationInspectionPanel({hideGateBanner:!!host?.direction,readOnlyReason:sealedRecordRigReadOnly,host:el('animation-inspection'),stage:el('rig-viewport'),project:(x,y)=>rigProject()(x,y),enabled:()=>inspectionSourceState==='ready'&&selectedInspector(document)==='playback',pause,preview:fn=>{animAdjust=fn;if(!player)return;player.adjust=composeAdjust(composeAdjust(composeAdjust(idleAdjust,dialAdjust),turnAdjust),animAdjust);if(!inDrawRig&&player.current&&!playing){if(activeScene())seek(time);else{player.seek(time);drawRig(()=>player!.draw());}}},apply:ops=>applyAnimation(ops),reset:()=>resetAnimationBuild(),seek:exact=>{if(!Number.isFinite(exact)||exact<0||exact>duration){message('KEY_TIME_OUT_OF_DOMAIN: no substitute time was used.',true);return;}seekMarker(animation,exact,'Stored key');},select:value=>{const slot=value?.kind==='slot'?value.name:null;if((parts?.value()?.slot??null)!==slot)parts?.select(slot?{side:'single',slot,mode:parts?.value()?.mode??'context'}:null);parts?.highlightBone(value?.kind==='bone'?value.name:null);redrawOverlay(false);}});viewDisposers.push(()=>animationPanel?.dispose()); updateStripControls(); stripStatus('Choose the entered start–end frames or all feedback ranges to download. Unsubmitted feedback is included; exporting does not submit the review.'); renderFeedbackTargets(true); renderFeedbackRange(); renderCheckpoints(); renderProposals(); renderProvenance(); updateSavedState(); renderCues(); initReport();
|
|
1369
1385
|
const requestedId = new URLSearchParams(location.search).get('checkpoint'),initial=initialReviewSelection(data.manifest,requestedId,data.explicitReference?.id,data.initialAnimation??undefined),first=initial.checkpoint;
|
|
1370
1386
|
rigInput=data.manifest.model?{state:'pending'}:{state:'absent'};renderLayout();
|
|
1371
1387
|
// A job rig subject lands in Animate before the model finishes loading (#709).
|
|
@@ -1373,7 +1389,7 @@ async function start(): Promise<void> {
|
|
|
1373
1389
|
if(initial.referenceId){select('reference-select').value=initial.referenceId;await showReference(initial.referenceId);}
|
|
1374
1390
|
await initPlayer(first);
|
|
1375
1391
|
// initPlayer keeps `player` only after its first draw succeeded; a declared model path alone never counts.
|
|
1376
|
-
updateChestMapping();
|
|
1392
|
+
if(!host?.chestLandmarks?.length)updateChestMapping();
|
|
1377
1393
|
rigInput=player?{state:'loaded'}:data.manifest.model?{state:'failed',reason:el('rig-empty').textContent||'compiled player unavailable'}:{state:'absent'};renderLayout();
|
|
1378
1394
|
if (first) await chooseCheckpoint(first,initial); else renderCheckpoint();
|
|
1379
1395
|
viewport.state.activeCamera=player?'rig':'reference';if(viewport.state.cameraSync)alignCameras();renderTransport();fitCamera();
|
|
@@ -1395,8 +1411,8 @@ async function start(): Promise<void> {
|
|
|
1395
1411
|
}
|
|
1396
1412
|
if(!player&&(data.manifest.model||referenceInput.state!=='loaded'))throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
1397
1413
|
await restorePublicationNavigation();document.body.dataset.ready='true';
|
|
1398
|
-
const screen:JobRigMeshScreen={recordForms:renderRecordForms,pendingSubjects:renderPendingSubjects,stage:hostStage,redraw:()=>{if(player&&!playing)drawRig(()=>player!.draw());},message:(value,error,diagnostic)=>message(value,error,false,diagnostic),...host.record?{}:{incompatible:()=>navigationMissing,navigation:()=>({subject:'rig' as const,bookmark:inspectionBookmark()})},suspend:suspendScreen,resume:resumeScreen,dispose:disposeScreen,
|
|
1399
|
-
hasMeshEdits:()=>!!meshEditor?.hasJobEdits(),meshEdits:async()=>meshEditor?.jobEdits()??null};
|
|
1414
|
+
const screen:JobRigMeshScreen={recordForms:renderRecordForms,pendingSubjects:renderPendingSubjects,progress:setJobProgress,stage:hostStage,redraw:()=>{if(player&&!playing)drawRig(()=>player!.draw());},message:(value,error,diagnostic)=>message(value,error,false,diagnostic),...host.record?{}:{incompatible:()=>navigationMissing,navigation:()=>({subject:'rig' as const,bookmark:inspectionBookmark()})},suspend:suspendScreen,resume:resumeScreen,dispose:disposeScreen,
|
|
1415
|
+
hasMeshEdits:()=>!!meshEditor?.hasJobEdits(),meshEdits:async()=>meshEditor?.jobEdits()??null,chestLandmarks:()=>chestEditor?.jobEdits()??null};
|
|
1400
1416
|
host.attach(screen);showInspector(data.manifest.model?'playback':'rig');host.displayed();
|
|
1401
1417
|
}
|
|
1402
1418
|
} catch (error) { if(disposed)return;message(`Could not open review package: ${errorText(error)}`, true); text('dirty', 'Load failed'); host?.failed(error); }
|
|
@@ -1417,17 +1433,17 @@ async function startParts(opened:PartsSubjectEntry,saved:PartsSubjectSession,wri
|
|
|
1417
1433
|
if(!response.ok){const body=await response.json();throw new Error(typeof body.error==='string'?body.error:body.error?.code??'PARTS_PAINT_FAILED');}return response;
|
|
1418
1434
|
};
|
|
1419
1435
|
const showCommentCount=()=>setSourceText(rigInspector.comments.button,`Comments (${issues.length+(generalRows?.length??0)})`);
|
|
1420
|
-
const changed=()=>{dirty=true;text('dirty','Unsubmitted changes');el('dirty').classList.add('dirty');parts?.refreshImages();rigInspector.actBar.setSaveState({kind:'unsaved',text:'Unsubmitted changes'});renderDraftState();showCommentCount();return persistence?.save();};
|
|
1436
|
+
const changed=()=>{if(/^The source changed, so /.test(draftStatus??''))draftStatus=null;dirty=true;text('dirty','Unsubmitted changes');el('dirty').classList.add('dirty');parts?.refreshImages();rigInspector.actBar.setSaveState({kind:'unsaved',text:'Unsubmitted changes'});renderDraftState();showCommentCount();return persistence?.save();};
|
|
1421
1437
|
// A parts verdict is saved only over a drawn subject: until the first paint, or after a failed one, Save stays off.
|
|
1422
1438
|
const saveBlocked=()=>!!readOnly||!!subject.legacyVerdict?.readOnly||rigInput.state!=='loaded'||draftConflict||!!persistence?.restoring();
|
|
1423
1439
|
partsAnswerBlocked=saveBlocked;
|
|
1424
1440
|
text('rig-empty','Loading package…');
|
|
1425
|
-
if(generalRows)restoreRecordComments();
|
|
1441
|
+
if(generalRows||host?.record)restoreRecordComments();
|
|
1426
1442
|
partsSubject=bindPartsSubject({data:subject,canvas:partsCanvas,referenceCanvas:partsReference,viewport,el,toolbar:primaryToolbar,commentsHost:el('comments-list-host'),openComments:openReview,hasPicture:()=>!hasTransientQuestionImage(screenRoot),issues,
|
|
1427
1443
|
...(host?.record?{recordComments}:host?.verdictComments?{generalComments:host.verdictComments,submitting:()=>saving}:{}),
|
|
1428
1444
|
request,base,paintingPath:host?'/review-painting':'/api/parts/painting',mesh:()=>layers.mesh,restoreMesh:on=>{layers.mesh=on;input('layer-mesh').checked=on;},images:()=>layers.images,
|
|
1429
1445
|
changed:()=>{if(host?.record){recordCommentsChanged();return;}if(generalRows)persistRecordComments();return changed();},
|
|
1430
|
-
selectionChanged:()=>parts?.refreshImages(),locked:id=>submittedIssues.has(id),refusal:()=>readOnly,drawn:state=>{rigInput=state;button('save').disabled=saveBlocked();renderAnswerControls();if(state.state==='failed')text('rig-empty',state.reason);text('renderer-state',state.state==='loaded'?'Parts raster drawn · Canvas2D':'Rendering failed');text('player-state',state.state==='loaded'?'Parts images · no compiled rig loaded':'Rig load failed');renderLayout();},message});
|
|
1446
|
+
selectionChanged:()=>{parts?.refreshImages();renderAnswerControls();},locked:id=>submittedIssues.has(id),refusal:()=>readOnly,drawn:state=>{rigInput=state;button('save').disabled=saveBlocked();renderAnswerControls();if(state.state==='failed')text('rig-empty',state.reason);text('renderer-state',state.state==='loaded'?'Parts raster drawn · Canvas2D':'Rendering failed');text('player-state',state.state==='loaded'?'Parts images · no compiled rig loaded':'Rig load failed');renderLayout();},message});
|
|
1431
1447
|
parts=new PartExplorer(el('workspace-left'),el('selected-part'),()=>{},()=>openReview());
|
|
1432
1448
|
const thumbnails=new PartThumbnails();viewDisposers.push(()=>thumbnails.dispose());
|
|
1433
1449
|
parts.registerImages({thumbnail:(icon,item,glyph)=>thumbnails.showOriginal(icon,item,()=>partsSubject!.image(item.index),glyph),items:subject.items,selected:partsSubject.selected,solo:partsSubject.solo,visible:partsSubject.visible,select:partsSubject.select,isolate:partsSubject.isolate,show:partsSubject.show});
|
|
@@ -1458,7 +1474,7 @@ async function startParts(opened:PartsSubjectEntry,saved:PartsSubjectSession,wri
|
|
|
1458
1474
|
const label=panelMake('label',{id:'parts-difference-operand-label',hidden:true},tr('Compare with'),operand);
|
|
1459
1475
|
const localizeOptions=()=>{
|
|
1460
1476
|
paintingOption.textContent=t('Original painting');
|
|
1461
|
-
previousOption.textContent=t('Previous accepted draft · {0}
|
|
1477
|
+
previousOption.textContent=t('Previous accepted draft · {0}',[previousDraft.id]);
|
|
1462
1478
|
};
|
|
1463
1479
|
localizeOptions();viewDisposers.push(onLanguageChange(localizeOptions));
|
|
1464
1480
|
operand.onchange=()=>{
|
|
@@ -1478,8 +1494,12 @@ async function startParts(opened:PartsSubjectEntry,saved:PartsSubjectSession,wri
|
|
|
1478
1494
|
select('review-status').hidden=true;document.querySelector<HTMLLabelElement>('label[for="review-status"]')!.hidden=true;
|
|
1479
1495
|
button('save').disabled=saveBlocked();
|
|
1480
1496
|
button('save').onclick=async()=>{
|
|
1481
|
-
if(saving||saveBlocked())return;
|
|
1497
|
+
if(saving||saveBlocked())return;
|
|
1498
|
+
if(partsSubject?.hasPendingComment()){if(!await partsSubject.commitDraft())return;}
|
|
1499
|
+
if(saving||saveBlocked())return;
|
|
1500
|
+
saving=true;button('save').disabled=true;state.setSaveState({kind:'saving',text:'Saving…'});renderDraftState();
|
|
1482
1501
|
const frozen=structuredClone(issues),general=generalRows?.map(row=>row.summary);
|
|
1502
|
+
let submissionFailure:ReturnType<typeof jobSubmissionRefusal>|null=null,saveFailed=false;
|
|
1483
1503
|
try{
|
|
1484
1504
|
if(host?.submitParts)message(await host.submitParts(frozen,general));
|
|
1485
1505
|
else await request(base+'/verdict',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({status:frozen.length?'changes-requested':'approved',issues:frozen})});
|
|
@@ -1488,8 +1508,8 @@ async function startParts(opened:PartsSubjectEntry,saved:PartsSubjectSession,wri
|
|
|
1488
1508
|
if(host)for(const issue of frozen)submittedIssues.add(issue.id);
|
|
1489
1509
|
if(general?.length){partsSubject?.refreshComments();showCommentCount();}
|
|
1490
1510
|
dirty=JSON.stringify(issues)!==JSON.stringify(frozen);partsBaseline={subject:'parts',issues:frozen};await persistence?.submitted(partsBaseline);if(disposed)return;state.setSaveState({kind:dirty?'unsaved':'saved',text:dirty?'Unsubmitted changes':'Submitted'});text('dirty',dirty?'Unsubmitted changes':'Submitted');el('dirty').classList.toggle('dirty',dirty);
|
|
1491
|
-
}catch(error){message(errorText(error),true);state.setSaveState({kind:'failed',text:'Save failed.'});}
|
|
1492
|
-
finally{saving=false;button('save').disabled=saveBlocked();renderDraftState();}
|
|
1511
|
+
}catch(error){saveFailed=true;if(host){submissionFailure=jobSubmissionRefusal(error);message(submissionFailure.text,true);}else{message(errorText(error),true);state.setSaveState({kind:'failed',text:'Save failed.'});}}
|
|
1512
|
+
finally{saving=false;button('save').disabled=saveBlocked();renderDraftState();if(submissionFailure){state.setSaveState({kind:'failed',text:submissionFailure.text,title:submissionFailure.title});el('message').title=submissionFailure.title;}else if(saveFailed)state.setSaveState({kind:'failed',text:'Save failed.'});}
|
|
1493
1513
|
};
|
|
1494
1514
|
viewDisposers.push(viewport.bindControls(unitScaleMessage),viewport.bindNavigation(undefined,()=>!el('stage-layout').getAttribute('aria-busy')?.includes('true')),bindLayerShortcuts(document));
|
|
1495
1515
|
const resize=viewport.observeResize();viewDisposers.push(()=>resize.disconnect());
|
|
@@ -1497,7 +1517,10 @@ async function startParts(opened:PartsSubjectEntry,saved:PartsSubjectSession,wri
|
|
|
1497
1517
|
setupPartsPersistence=async()=>{
|
|
1498
1518
|
if(host?.record)return;
|
|
1499
1519
|
const binding:InspectionBinding={mode:'single',sourceHash:subject.sourceHash,rigs:[null]};
|
|
1500
|
-
const
|
|
1520
|
+
const legacyPartsScope='parts:'+access.key+':'+access.base+':'+subject.sourceHash;
|
|
1521
|
+
const partsDraftScope=host?.verdictComments?.jobId&&host?.verdictComments?.draftId?host.verdictComments.jobId+':'+host.verdictComments.draftId:access.key+':'+access.base;
|
|
1522
|
+
const partsScope='parts:'+partsDraftScope+':'+subject.sourceHash;
|
|
1523
|
+
const connection=await connectInspectionPersistence({scope:partsScope,legacyScopes:partsScope!==legacyPartsScope?[legacyPartsScope]:[],binding,baseline:partsBaseline,session:()=>({subject:'parts' as const,issues}),reviewDirty:()=>dirty,
|
|
1501
1524
|
recover:value=>{try{if(!value||typeof value!=='object')return null;const row=value as PartsSubjectSession;if(row.subject!=='parts'||!Array.isArray(row.issues)||row.issues.length>1000||Object.keys(row).some(key=>!['subject','issues'].includes(key)))return null;const items=new Map(subject.items.map(item=>[item.name,{...item,imageHash:item.imageHash!}]));const restored=row.issues.map(issue=>{const parsed=parsePartsIssue(issue,false,true,false);assertPartsIssueBinding(parsed,items,subject.sourceHash);return parsed;});if(new Set(restored.map(issue=>issue.id)).size!==restored.length)return null;return {subject:'parts' as const,issues:restored};}catch{return null;}},
|
|
1502
1525
|
restoreSession:(value,isDirty)=>{issues.splice(0,issues.length,...value.issues);dirty=isDirty;partsSubject?.refreshComments();showCommentCount();text('dirty',isDirty?'Unsubmitted changes':'Submitted');el('dirty').classList.toggle('dirty',isDirty);state.setSaveState({kind:isDirty?'unsaved':'saved',text:isDirty?'Unsubmitted changes':'Submitted'});},
|
|
1503
1526
|
bookmark:()=>({schema:'rig-review-inspection/1',binding,animation:null,time:null,theme:appearance?.get()??'system',layers:{images:layers.images,meshes:layers.mesh,bones:false},view:{schema:'rig-review-view/1',cameras:{rig:null,a:null,b:null,reference:null}},selection:{}}),
|
|
@@ -1509,7 +1532,7 @@ async function startParts(opened:PartsSubjectEntry,saved:PartsSubjectSession,wri
|
|
|
1509
1532
|
await setupPartsPersistence();if(disposed)return;
|
|
1510
1533
|
if(generalRows?.length)changed();
|
|
1511
1534
|
renderPendingSubjects(host?.pendingSubjects?.()??[{kind:'parts-verdict'}]);
|
|
1512
|
-
if(host){await restorePublicationNavigation();host.attach({recordForms:renderRecordForms,stage:()=>null,redraw:()=>partsSubject?.redraw(),message:(value,error,diagnostic)=>message(value,error,false,diagnostic),pendingSubjects:renderPendingSubjects,...host.record?{}:{incompatible:()=>navigationMissing,navigation:()=>({subject:'parts' as const,part:partsSubject!.selected(),solo:partsSubject!.solo(),view,camera:numericView()})},suspend:suspendScreen,resume:resumeScreen,dispose:disposeScreen});host.displayed();}
|
|
1535
|
+
if(host){await restorePublicationNavigation();host.attach({recordForms:renderRecordForms,stage:()=>null,redraw:()=>partsSubject?.redraw(),message:(value,error,diagnostic)=>message(value,error,false,diagnostic),pendingSubjects:renderPendingSubjects,progress:setJobProgress,...host.record?{}:{incompatible:()=>navigationMissing,navigation:()=>({subject:'parts' as const,part:partsSubject!.selected(),solo:partsSubject!.solo(),view,camera:numericView()})},suspend:suspendScreen,resume:resumeScreen,dispose:disposeScreen});host.displayed();}
|
|
1513
1536
|
|
|
1514
1537
|
document.body.dataset.ready='true';
|
|
1515
1538
|
}
|
|
@@ -1532,44 +1555,73 @@ async function startRecord(interview?:InterviewSubjectEntry):Promise<void> {
|
|
|
1532
1555
|
readOnly=tr(interview?'MODEL_UNAVAILABLE':'JOB_REVIEW_READ_ONLY');
|
|
1533
1556
|
if(!interview)actReadOnly=readOnlyReason(access,true,host?.ownerActAccess);
|
|
1534
1557
|
bindWorkspace();bindInspector(true);rigInput={state:'absent'};referenceInput={state:'absent'};renderLayout();
|
|
1535
|
-
parts=new PartExplorer(el('workspace-left'),el('selected-part'),()=>{},()=>{});text('checkpoints','No checkpoints supplied.');text('dirty','Not submitted');if(interview)message(unavailable);else message(actReadOnly??(host?.record?.
|
|
1558
|
+
parts=new PartExplorer(el('workspace-left'),el('selected-part'),()=>{},()=>{});text('checkpoints','No checkpoints supplied.');text('dirty','Not submitted');if(interview)message(unavailable);else message(actReadOnly??(host?.record?.questionPicture?'':unavailable),!!actReadOnly);
|
|
1536
1559
|
text('package-title',interview?.label??host!.record!.label);text('revision','');text('source-hash',`source ${(interview?.sourceHash??host!.record!.sourceHash).slice(0,12)}`);
|
|
1537
1560
|
el('rig-pane').hidden=false;el('rig-empty').hidden=false;text('rig-empty',unavailable);
|
|
1538
|
-
for(const region of document.querySelectorAll('.inspector,.workspace-secondary-toolbar'))for(const control of region.querySelectorAll<HTMLInputElement|HTMLSelectElement|HTMLButtonElement>('input,select,textarea,button')){
|
|
1561
|
+
for(const region of document.querySelectorAll('.inspector,.workspace-secondary-toolbar'))for(const control of region.querySelectorAll<HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement|HTMLButtonElement>('input,select,textarea,button')){
|
|
1562
|
+
if(control===rigInspector.collapse||(!interview&&control===rigInspector.comments.button))continue;
|
|
1563
|
+
control.disabled=true;control.removeAttribute('title');
|
|
1564
|
+
const toggleLabel=control.closest('label.layer-toggle');if(toggleLabel)toggleLabel.removeAttribute('title');
|
|
1565
|
+
if(!control.hasAttribute('aria-label')&&!control.hasAttribute('aria-labelledby')&&control.getAttribute('aria-hidden')!=='true'){
|
|
1566
|
+
const wrappingLabel=control.closest('label'),explicitLabel=control.id?document.querySelector<HTMLLabelElement>(`label[for="${control.id}"]`):null;
|
|
1567
|
+
const labelNode=control instanceof HTMLButtonElement?(control.childElementCount?control.childNodes[0]??null:control):wrappingLabel?(wrappingLabel.querySelector('span')??[...wrappingLabel.childNodes].find(node=>node.nodeType===3&&node.nodeValue?.trim())??null):explicitLabel;
|
|
1568
|
+
const labelText=sourceTextContent(labelNode).trim();
|
|
1569
|
+
if(labelText)setSourceAttribute(control,'aria-label',labelText);
|
|
1570
|
+
}
|
|
1571
|
+
setSourceAttribute(control,'aria-description',unavailable);
|
|
1572
|
+
}
|
|
1539
1573
|
if(interview){
|
|
1540
1574
|
button('stage-comment').hidden=true;
|
|
1541
|
-
button('save').disabled=true;setSourceAttribute(button('save'),'
|
|
1542
|
-
|
|
1543
|
-
label();viewDisposers.push(onLanguageChange(label));
|
|
1544
|
-
viewDisposers.push(await joinedInterviewForms(access,forms=>renderRecordForms(forms,t('interview.title'),true)));
|
|
1575
|
+
button('save').disabled=true;setSourceAttribute(button('save'),'aria-description',unavailable);
|
|
1576
|
+
viewDisposers.push(await joinedInterviewForms(access,forms=>renderRecordForms(forms,'job.pending',true)));
|
|
1545
1577
|
text('provenance-rig',unavailable);text('provenance-motion',unavailable);text('source-files','project.json');
|
|
1546
1578
|
}else{restoreRecordComments();setupComments();showRecordComments();rigInspector.comments.button.disabled=false;button('stage-comment').disabled=false;}
|
|
1547
1579
|
const resize=viewport.observeResize();viewDisposers.push(()=>resize.disconnect());
|
|
1548
1580
|
await workspace?.settle();if(disposed)return;
|
|
1549
1581
|
if(host?.unavailable){message(t('job.refusal.'+host.unavailable),true);el('message').title=host.unavailable;button('save').disabled=true;button('save').title=host.unavailable;}
|
|
1550
1582
|
document.body.dataset.ready='true';
|
|
1551
|
-
if(!interview){host!.attach({recordForms:renderRecordForms,pendingSubjects:renderPendingSubjects,stage:()=>null,redraw:()=>{},message:(value,error,diagnostic)=>message(value,error,false,diagnostic),suspend:suspendScreen,resume:resumeScreen,dispose:disposeScreen});host!.displayed();}
|
|
1583
|
+
if(!interview){host!.attach({recordForms:renderRecordForms,pendingSubjects:renderPendingSubjects,progress:setJobProgress,stage:()=>null,redraw:()=>{},message:(value,error,diagnostic)=>message(value,error,false,diagnostic),suspend:suspendScreen,resume:resumeScreen,dispose:disposeScreen});host!.displayed();}
|
|
1552
1584
|
}
|
|
1553
1585
|
let recordDialog:HTMLDialogElement|null=null;
|
|
1586
|
+
let releaseRecordDrawer:(()=>void)|null=null;
|
|
1587
|
+
viewDisposers.push(()=>{releaseRecordDrawer?.();releaseRecordDrawer=null;recordDialog?.remove();recordDialog=null;});
|
|
1588
|
+
let recordDrawerTrigger:HTMLButtonElement|null=null;
|
|
1589
|
+
let unregisterQuestion:(()=>void)|null=null;
|
|
1554
1590
|
let activeInterviewImages:readonly {name:string;src:string}[]|null=null;
|
|
1555
1591
|
let activeInterviewImage:{name:string;src:string}|null=null;
|
|
1556
1592
|
let releaseInterview:(()=>void)|null=null;
|
|
1557
1593
|
const questionPanel=panelMake('section',{id:'workspace-interview-answer',className:'workspace-interview-panel',hidden:true});
|
|
1558
1594
|
let questionForms:readonly HTMLElement[]=[];
|
|
1595
|
+
/** #1004: several question forms share the Question tab; the list shows one at a time. */
|
|
1596
|
+
let selectedQuestionAsk:string|undefined;
|
|
1597
|
+
questionPanel.addEventListener('job-question-select',event=>{selectedQuestionAsk=(event.target as HTMLElement).dataset.jobAsk;showQuestionForm();});
|
|
1598
|
+
function showQuestionForm():void {
|
|
1599
|
+
const shown=questionForms.find(form=>form.dataset.jobAsk!==undefined&&form.dataset.jobAsk===selectedQuestionAsk)??questionForms.find(form=>form.dataset.interviewAnswered!=='true')??questionForms[0];
|
|
1600
|
+
for(const form of questionForms)form.hidden=form!==shown;
|
|
1601
|
+
syncQuestionImage();
|
|
1602
|
+
}
|
|
1559
1603
|
let questionFormBindings=new WeakSet<HTMLElement>();
|
|
1560
1604
|
|
|
1561
1605
|
/** Publication and source bind native comment drafts independently of inspection navigation. */
|
|
1562
1606
|
function restoreRecordComments(form?:HTMLFormElement):void {
|
|
1563
1607
|
const binding=host?.direction??host?.verdictComments??host?.record;
|
|
1564
1608
|
if(!binding||recordCommentKey)return;
|
|
1565
|
-
const
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1609
|
+
const route=typeof access!=='undefined'?/^\/jobs\/([^/]+)\/publications\/([^/]+)\//.exec(access?.base??''):null;
|
|
1610
|
+
const publicationId=binding.publicationId??form?.dataset.jobPublication??route?.[2],sourceHash=binding.sourceHash;
|
|
1611
|
+
const jobId=binding.jobId??route?.[1],draftId=binding.draftId;
|
|
1612
|
+
if(!publicationId&&(!jobId||!draftId))throw new Error('JOB_DISPLAY_MISMATCH');
|
|
1613
|
+
const prefix=host?.verdictComments?'rig-review-verdict-comments/1:':'rig-review-record-comments/1:';
|
|
1614
|
+
const scopePrefix=jobId&&draftId?`${prefix}${jobId}:${draftId}:`:null;
|
|
1615
|
+
recordCommentKey=(scopePrefix??`${prefix}${publicationId}:`)+sourceHash;
|
|
1616
|
+
const fallbackKey=publicationId?`${prefix}${publicationId}:${sourceHash}`:'';
|
|
1617
|
+
const previousKey=binding.previousPublicationId?`${prefix}${binding.previousPublicationId}:${sourceHash}`:'';
|
|
1618
|
+
const target=(host?.verdictComments?.rows??recordComments) as CommentRow[]&{knownIds?:Set<string>;storageBound?:boolean};
|
|
1619
|
+
const knownIds=(target.knownIds??=new Set<string>());
|
|
1620
|
+
const parseRows=(raw:string|null,expectedPub?:string):CommentRow[]|null=>{
|
|
1621
|
+
const saved=JSON.parse(raw??'null');
|
|
1622
|
+
if(!saved||saved.sourceHash!==sourceHash||!Array.isArray(saved.comments)||saved.comments.length>1000)return null;
|
|
1623
|
+
if(expectedPub!==undefined?saved.publicationId!==expectedPub:(typeof saved.publicationId!=='string'||!saved.publicationId))return null;
|
|
1624
|
+
const ids=new Set<string>(),rows=saved.comments as CommentRow[];
|
|
1573
1625
|
for(const row of rows){
|
|
1574
1626
|
if(!row||typeof row.id!=='string'||!row.id||ids.has(row.id)||typeof row.summary!=='string'||!row.summary.trim()||row.summary.length>1000)throw new Error('JOB_ACT_INVALID');
|
|
1575
1627
|
ids.add(row.id);
|
|
@@ -1579,7 +1631,72 @@ function restoreRecordComments(form?:HTMLFormElement):void {
|
|
|
1579
1631
|
else if(Object.keys(row).some(key=>key!=='id'&&key!=='summary'))throw new Error('JOB_ACT_INVALID');
|
|
1580
1632
|
}
|
|
1581
1633
|
if(!host?.verdictComments)projectComments(rows.map(row=>'schema' in row?partsIssueComments([row as import('../src/parts-comment.ts').PartsIssue])[0]!:'target' in row?feedbackItemComments([row as Feedback])[0]!:{text:row.summary}));
|
|
1582
|
-
|
|
1634
|
+
return rows;
|
|
1635
|
+
};
|
|
1636
|
+
if(!target.storageBound&&typeof window!=='undefined'&&typeof window.addEventListener==='function'){
|
|
1637
|
+
target.storageBound=true;
|
|
1638
|
+
const onStorage=(event:Pick<StorageEvent,'key'|'newValue'>)=>{
|
|
1639
|
+
if(!recordCommentKey||event.key!==recordCommentKey)return;
|
|
1640
|
+
try{
|
|
1641
|
+
const currentRaw=typeof localStorage.getItem==='function'?localStorage.getItem(recordCommentKey):event.newValue;
|
|
1642
|
+
const incoming=currentRaw===null?[]:parseRows(currentRaw,scopePrefix?undefined:publicationId);
|
|
1643
|
+
if(!incoming)return;
|
|
1644
|
+
const incomingIds=new Set(incoming.map(row=>row.id));
|
|
1645
|
+
const localUnsaved=target.filter(row=>!knownIds.has(row.id)&&!incomingIds.has(row.id));
|
|
1646
|
+
target.splice(0,target.length,...incoming,...localUnsaved);
|
|
1647
|
+
knownIds.clear();for(const row of incoming)knownIds.add(row.id);
|
|
1648
|
+
if(typeof rigInspector!=='undefined'&&typeof setSourceText==='function'){
|
|
1649
|
+
const count=host?.verdictComments?(typeof partsOnly!=='undefined'&&partsOnly?(partsSubject?.issues().length??0)+target.length:target.length):recordComments.length;
|
|
1650
|
+
setSourceText(rigInspector.comments.button,`Comments (${count})`);
|
|
1651
|
+
}
|
|
1652
|
+
if(typeof comments!=='undefined')comments?.refresh();
|
|
1653
|
+
if(typeof partsSubject!=='undefined')partsSubject?.refreshComments();
|
|
1654
|
+
if(typeof renderProposals==='function'&&host?.verdictComments)renderProposals();
|
|
1655
|
+
if(typeof renderAnswerControls==='function')renderAnswerControls();
|
|
1656
|
+
}catch{/* Ignore malformed cross-tab storage payloads. */}
|
|
1657
|
+
};
|
|
1658
|
+
window.addEventListener('storage',onStorage,typeof lifecycle!=='undefined'?{signal:lifecycle.signal}:undefined);
|
|
1659
|
+
}
|
|
1660
|
+
try {
|
|
1661
|
+
const primaryRaw=localStorage.getItem(recordCommentKey);
|
|
1662
|
+
const fallbackRaw=primaryRaw===null&&fallbackKey&&fallbackKey!==recordCommentKey?localStorage.getItem(fallbackKey):null;
|
|
1663
|
+
const previousRaw=primaryRaw===null&&fallbackRaw===null&&previousKey&&previousKey!==recordCommentKey?localStorage.getItem(previousKey):null;
|
|
1664
|
+
const rows=primaryRaw!==null?parseRows(primaryRaw,scopePrefix?undefined:publicationId):
|
|
1665
|
+
fallbackRaw!==null?parseRows(fallbackRaw,publicationId):
|
|
1666
|
+
previousRaw!==null?parseRows(previousRaw,binding.previousPublicationId??undefined):null;
|
|
1667
|
+
if(rows){
|
|
1668
|
+
for(const row of rows){knownIds.add(row.id);if(!target.some(existing=>existing.id===row.id))target.push(row);}
|
|
1669
|
+
if(primaryRaw===null&&typeof localStorage.removeItem==='function'){
|
|
1670
|
+
persistRecordComments();
|
|
1671
|
+
if(fallbackKey&&fallbackKey!==recordCommentKey)localStorage.removeItem(fallbackKey);
|
|
1672
|
+
if(previousKey&&previousKey!==recordCommentKey)localStorage.removeItem(previousKey);
|
|
1673
|
+
}
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
if((scopePrefix||binding.previousPublicationId)&&typeof localStorage.length==='number'&&typeof localStorage.key==='function'){
|
|
1677
|
+
const partsScopePrefix=jobId&&draftId?`rig-review-draft/1:parts:${jobId}:${draftId}:`:null;
|
|
1678
|
+
let unsentCount=0;
|
|
1679
|
+
for(let i=0;i<localStorage.length;i++){
|
|
1680
|
+
const key=localStorage.key(i);
|
|
1681
|
+
if(!key||key===recordCommentKey)continue;
|
|
1682
|
+
if((scopePrefix&&key.startsWith(scopePrefix))||(binding.previousPublicationId&&key.startsWith(`${prefix}${binding.previousPublicationId}:`))){
|
|
1683
|
+
const prior=JSON.parse(localStorage.getItem(key)??'null');
|
|
1684
|
+
if(prior&&typeof prior.sourceHash==='string'&&prior.sourceHash!==sourceHash&&Array.isArray(prior.comments)&&prior.comments.length>0){
|
|
1685
|
+
unsentCount+=prior.comments.length;
|
|
1686
|
+
}
|
|
1687
|
+
}else if(partsScopePrefix&&key.startsWith(partsScopePrefix)&&!key.endsWith(':'+sourceHash)){
|
|
1688
|
+
const prior=JSON.parse(localStorage.getItem(key)??'null');
|
|
1689
|
+
if(prior&&typeof prior.sourceHash==='string'&&prior.sourceHash!==sourceHash&&prior.reviewDirty&&Array.isArray(prior.session?.issues)&&prior.session.issues.length>0){
|
|
1690
|
+
unsentCount+=prior.session.issues.length;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
if(unsentCount>0){
|
|
1695
|
+
const notice=`The source changed, so ${unsentCount} unsent comment(s) could not be carried over. Please add them again.`;
|
|
1696
|
+
if(typeof draftStatus!=='undefined')draftStatus=notice;
|
|
1697
|
+
if(typeof renderDraftState==='function')renderDraftState();
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1583
1700
|
}catch{/* A mismatched or invalid local draft has no authority. */}
|
|
1584
1701
|
}
|
|
1585
1702
|
/** Comments remain native rows locally; the old act field carries their scalar projection only. */
|
|
@@ -1589,26 +1706,52 @@ function recordCommentWords():string {
|
|
|
1589
1706
|
function persistRecordComments():void {
|
|
1590
1707
|
const binding=host?.direction??host?.verdictComments??host?.record;
|
|
1591
1708
|
if(!binding||!recordCommentKey)return;
|
|
1592
|
-
const comments=host?.verdictComments?.rows??recordComments;
|
|
1709
|
+
const comments=(host?.verdictComments?.rows??recordComments) as CommentRow[]&{knownIds?:Set<string>};
|
|
1710
|
+
const knownIds=(comments.knownIds??=new Set<string>());
|
|
1593
1711
|
try{
|
|
1712
|
+
const raw=typeof localStorage.getItem==='function'?localStorage.getItem(recordCommentKey):null;
|
|
1713
|
+
if(raw!==null){
|
|
1714
|
+
const existing=JSON.parse(raw);
|
|
1715
|
+
const storedRows:CommentRow[]=existing?.sourceHash===binding.sourceHash&&Array.isArray(existing.comments)
|
|
1716
|
+
?existing.comments.filter((row:CommentRow)=>row&&typeof row.id==='string'&&row.id&&typeof row.summary==='string'&&row.summary.trim()&&row.summary.length<=1000):[];
|
|
1717
|
+
const storedIds=new Set(storedRows.map(row=>row.id));
|
|
1718
|
+
const survivingLocal=comments.filter(row=>!knownIds.has(row.id)||storedIds.has(row.id));
|
|
1719
|
+
const survivingIds=new Set(survivingLocal.map(row=>row.id));
|
|
1720
|
+
const addedFromOther=storedRows.filter(row=>!knownIds.has(row.id)&&!survivingIds.has(row.id));
|
|
1721
|
+
const kept=survivingLocal.filter(row=>knownIds.has(row.id));
|
|
1722
|
+
const localNew=survivingLocal.filter(row=>!knownIds.has(row.id));
|
|
1723
|
+
comments.splice(0,comments.length,...kept,...addedFromOther,...localNew);
|
|
1724
|
+
}
|
|
1725
|
+
knownIds.clear();for(const row of comments)knownIds.add(row.id);
|
|
1726
|
+
const dialogPublication=typeof recordDialog!=='undefined'?recordDialog?.querySelector<HTMLFormElement>('form[data-job-ask]')?.dataset.jobPublication:undefined;
|
|
1727
|
+
const activePub=binding.publicationId??dialogPublication;
|
|
1728
|
+
const prefix=host?.verdictComments?'rig-review-verdict-comments/1:':'rig-review-record-comments/1:';
|
|
1729
|
+
if(typeof localStorage.removeItem==='function'){
|
|
1730
|
+
if(activePub&&`${prefix}${activePub}:${binding.sourceHash}`!==recordCommentKey)localStorage.removeItem(`${prefix}${activePub}:${binding.sourceHash}`);
|
|
1731
|
+
if(binding.previousPublicationId&&`${prefix}${binding.previousPublicationId}:${binding.sourceHash}`!==recordCommentKey)localStorage.removeItem(`${prefix}${binding.previousPublicationId}:${binding.sourceHash}`);
|
|
1732
|
+
}
|
|
1594
1733
|
if(host?.verdictComments&&!comments.length)localStorage.removeItem(recordCommentKey);
|
|
1595
|
-
else localStorage.setItem(recordCommentKey,JSON.stringify({status:select('review-status').value,publicationId:
|
|
1734
|
+
else localStorage.setItem(recordCommentKey,JSON.stringify({status:select('review-status').value,publicationId:activePub,sourceHash:binding.sourceHash,comments}));
|
|
1596
1735
|
}catch{/* In-memory comments remain bound to this host. */}
|
|
1597
1736
|
}
|
|
1598
1737
|
function recordCommentsChanged():void {
|
|
1599
1738
|
if(!host?.record&&!host?.direction)return;
|
|
1739
|
+
if(/^The source changed, so /.test(draftStatus??''))draftStatus=null;
|
|
1600
1740
|
persistRecordComments();
|
|
1601
1741
|
setSourceText(rigInspector.comments.button,`Comments (${recordComments.length})`);
|
|
1602
|
-
|
|
1742
|
+
renderDraftState();
|
|
1603
1743
|
for(const form of recordDialog?.querySelectorAll('form[data-job-ask]')??[])form.dispatchEvent(new Event('input',{bubbles:true}));
|
|
1604
1744
|
}
|
|
1605
|
-
/**
|
|
1745
|
+
/** Keep the shared reference viewport bound while the interview form is mounted. */
|
|
1606
1746
|
function syncQuestionImage():void {
|
|
1607
1747
|
if(disposed){releaseInterview?.();releaseInterview=null;return;}
|
|
1608
|
-
const
|
|
1609
|
-
|
|
1610
|
-
if(
|
|
1611
|
-
|
|
1748
|
+
const form=(questionForms.find(item=>!item.hidden)??questionForms[0]) as (HTMLElement&{interviewImages?:readonly {name:string;src:string}[]})|undefined;
|
|
1749
|
+
const images=form?.interviewImages;
|
|
1750
|
+
if(activeInterviewImages&&images?.length===activeInterviewImages.length&&images.every((image,index)=>{
|
|
1751
|
+
const previous=activeInterviewImages![index]!;
|
|
1752
|
+
return previous.name===image.name&&previous.src===image.src;
|
|
1753
|
+
}))return;
|
|
1754
|
+
releaseInterview?.();releaseInterview=null;
|
|
1612
1755
|
if(!images?.length)return;
|
|
1613
1756
|
const previousView=view,previousCamera=structuredClone(viewport.state);viewport.cancelFit();
|
|
1614
1757
|
const previousReferenceNodes=[...el('reference-content').childNodes],previousReferenceInput=referenceInput,previousReferenceSize=referenceSize;
|
|
@@ -1631,102 +1774,176 @@ function syncQuestionImage():void {
|
|
|
1631
1774
|
if(!disposed){renderLayout();workspace?.refresh();}
|
|
1632
1775
|
Object.assign(viewport.state,previousCamera);if(!disposed)fitCamera();
|
|
1633
1776
|
};
|
|
1777
|
+
if(sourceTextContent(el('message'))==='This request has no picture.')message(sourceTextContent(el('dirty')),false,true);
|
|
1634
1778
|
void showReference('',activeInterviewImage);
|
|
1635
1779
|
}
|
|
1636
|
-
/**
|
|
1780
|
+
/** Survey forms use the shared bottom tab. Pending text-only record forms use the drawer. */
|
|
1637
1781
|
function renderRecordForms(forms:readonly HTMLElement[],label='job.pending',standalone=false):void {
|
|
1638
1782
|
if(standalone){pendingAnswers=[{kind:'interview-picks'}];}
|
|
1639
1783
|
for(const form of forms){
|
|
1640
1784
|
if(questionFormBindings.has(form))continue;questionFormBindings.add(form);
|
|
1641
1785
|
form.addEventListener('submit',event=>{if(draftConflict||pendingAnswers.some(subject=>subject.kind.endsWith('verdict'))){event.preventDefault();event.stopImmediatePropagation();}},true);
|
|
1642
|
-
form.addEventListener('job-answer-saved',()=>{answerSaved=true;recordDialog?.close();renderDraftState();},{once:true});
|
|
1786
|
+
form.addEventListener('job-answer-saved',()=>{answerSaved=true;if(recordDialog?.contains(form))recordDialog.close();renderDraftState();},{once:true});
|
|
1643
1787
|
}
|
|
1644
1788
|
const questionTabForms=forms.filter(form=>form.dataset.interviewMain!==undefined);
|
|
1645
|
-
if(questionTabForms.
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
for(const form of questionForms)if(
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
if(
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1789
|
+
for(const form of questionForms)if(!questionTabForms.includes(form)){form.dispatchEvent(new Event('job-form-dispose'));form.remove();}
|
|
1790
|
+
questionForms=questionTabForms;
|
|
1791
|
+
if(questionForms.length){
|
|
1792
|
+
for(const form of questionForms)if(form.parentElement!==questionPanel)questionPanel.append(form);
|
|
1793
|
+
const reveal=()=>{inspectorBlocks?.select(selectedInspector()??'rig','question');workspace?.revealInspector();};
|
|
1794
|
+
rigAsk.onclick=()=>{if(!draftConflict)reveal();};
|
|
1795
|
+
if(!unregisterQuestion){
|
|
1796
|
+
unregisterQuestion=inspectorBlocks!.register({id:'question',panel:questionPanel,label:'Question',position:'first'});
|
|
1797
|
+
inspectorBlocks!.restore({rig:'question',playback:'question'});reveal();
|
|
1798
|
+
}
|
|
1799
|
+
if(questionForms.every(form=>form.dataset.interviewAnswered==='true')){answerSaved=true;firstPublicationPrompt=false;}
|
|
1800
|
+
}else{
|
|
1801
|
+
unregisterQuestion?.();unregisterQuestion=null;rigAsk.onclick=null;
|
|
1655
1802
|
}
|
|
1803
|
+
showQuestionForm();
|
|
1656
1804
|
forms=forms.filter(form=>!questionTabForms.includes(form));
|
|
1657
|
-
if(!forms.length
|
|
1805
|
+
if(!forms.length){
|
|
1806
|
+
releaseRecordDrawer?.();releaseRecordDrawer=null;recordDrawerTrigger=null;
|
|
1807
|
+
recordDialog?.remove();recordDialog=null;
|
|
1808
|
+
renderDraftState();return;
|
|
1809
|
+
}
|
|
1658
1810
|
if(!recordDialog){
|
|
1659
1811
|
recordDialog=panelMake('dialog',{id:'job-record-asks',className:'workspace-drawer'});recordDialog.setAttribute('aria-label',tr(label));
|
|
1660
|
-
|
|
1661
|
-
viewDisposers.push(bindWorkspaceDrawer({trigger:rigAsk,drawer:recordDialog,label:tr(label),close}));
|
|
1662
|
-
viewDisposers.push(()=>{recordDialog?.close();recordDialog?.remove();recordDialog=null;});
|
|
1812
|
+
recordDialog.append(panelMake('button',{className:'workspace-drawer-close',type:'button'},tr('Close')));app.append(recordDialog);
|
|
1663
1813
|
}
|
|
1664
|
-
|
|
1665
|
-
|
|
1814
|
+
const trigger=questionForms.length?recordAsk:rigAsk;
|
|
1815
|
+
if(recordDrawerTrigger!==trigger){
|
|
1816
|
+
releaseRecordDrawer?.();recordDrawerTrigger=trigger;
|
|
1817
|
+
releaseRecordDrawer=bindWorkspaceDrawer({trigger,drawer:recordDialog,label:tr(label),close:recordDialog.querySelector('button')!});
|
|
1818
|
+
}
|
|
1819
|
+
for(const form of recordDialog.querySelectorAll<HTMLFormElement>('form[data-job-ask]'))if(!forms.includes(form)){form.dispatchEvent(new Event('job-form-dispose'));form.remove();}
|
|
1666
1820
|
if(!standalone&&forms[0])restoreRecordComments(forms[0] as HTMLFormElement);
|
|
1667
|
-
const added=forms.filter(form=>!recordDialog!.contains(form));
|
|
1668
1821
|
for(const form of forms){
|
|
1669
1822
|
if(!standalone)(form as JobForm['form']).commentWords=()=>host?.record||host?.direction?recordCommentWords():partsOnly?projectComments(partsIssueComments(partsSubject?.issues()??[])):projectComments(feedbackItemComments(session.feedback));
|
|
1670
|
-
if(!recordDialog.contains(form)){
|
|
1823
|
+
if(!recordDialog.contains(form)){form.style.overflow='auto';form.style.minHeight='0';recordDialog.append(form);}
|
|
1671
1824
|
}
|
|
1672
1825
|
if(host?.record){
|
|
1673
1826
|
for(const child of el('proposal-panel').children)if(child.id!=='comments-list-host')(child as HTMLElement).hidden=true;
|
|
1674
1827
|
setSourceText(rigInspector.comments.button,`Comments (${recordComments.length})`);comments?.refresh();partsSubject?.refreshComments();
|
|
1675
|
-
button('save').onclick=()=>
|
|
1828
|
+
button('save').onclick=()=>trigger.click();
|
|
1676
1829
|
}
|
|
1677
1830
|
renderAnswerControls();
|
|
1678
|
-
if((standalone?added.length>0:added.some(form=>form.classList.contains('interview-answer')))&&!recordDialog.open)rigAsk.click();
|
|
1679
1831
|
}
|
|
1680
1832
|
/** The ask heading reads only already-pending subjects. It never synthesizes an agent request. */
|
|
1681
1833
|
function renderPendingSubjects(subjects:readonly {kind:string;stage?:string}[]):void {
|
|
1682
|
-
const requests:Record<string,string>={'parts-verdict':partsSubject?.items().some(item=>item.mesh)?'Check the parts and meshes.':'Check the parts.','interview-picks':'Answer these questions.','review-verdict:rig-review':'Check the rig and motion.','review-verdict:direction-review':'Check the direction.','review-verdict:image-review':'Check these images.','checkpoint':'Review this checkpoint.','signoff':'Approve this stage.'
|
|
1683
|
-
|
|
1834
|
+
const requests:Record<string,string>={'parts-verdict':partsSubject?.items().some(item=>item.mesh)?'Check the parts and meshes.':'Check the parts.','interview-picks':'Answer these questions.','review-verdict:rig-review':'Check the rig and motion.','review-verdict:direction-review':'Check the direction.','review-verdict:image-review':'Check these images.','checkpoint':'Review this checkpoint.','signoff':'Approve this stage.'};
|
|
1835
|
+
// #1004: several pending asks of one kind say their sentence once.
|
|
1836
|
+
const labels=[...new Set(subjects.map(subject=>requests[subject.kind+':'+subject.stage]??requests[subject.kind]).filter((label):label is string=>!!label))];
|
|
1684
1837
|
const liveVerdict=(subject:{kind:string;stage?:string})=>
|
|
1685
1838
|
partsOnly?subject.kind==='parts-verdict':subject.kind==='review-verdict'&&subject.stage==='rig-review';
|
|
1686
1839
|
const refreshVerdictComments=host?.verdictComments&&pendingAnswers.some(liveVerdict)!==subjects.some(liveVerdict);
|
|
1687
1840
|
pendingAnswers=subjects;
|
|
1688
1841
|
if(refreshVerdictComments){comments?.refresh();partsSubject?.refreshComments();}
|
|
1689
|
-
|
|
1842
|
+
renderAskHeadline(labels.join(' · ')||(firstPublicationPrompt?t('job.waiting',undefined,'en'):'Nothing is waiting for your answer.'));
|
|
1690
1843
|
if(subjects.length)firstPublicationPrompt=false;
|
|
1691
1844
|
renderDraftState();
|
|
1692
1845
|
}
|
|
1846
|
+
function syncJobActRow(subjects=pendingAnswers):void {
|
|
1847
|
+
rigInspector.act.hidden=!subjects.length&&!firstPublicationPrompt&&!jobProgress;
|
|
1848
|
+
rigInspector.syncActRow?.();
|
|
1849
|
+
}
|
|
1850
|
+
function setJobProgress(value:JobProgressV3|null):void {
|
|
1851
|
+
if(disposed||jobProgress===value)return;
|
|
1852
|
+
jobProgress=value;
|
|
1853
|
+
if(pendingAnswers.length)return;
|
|
1854
|
+
renderAskHeadline();
|
|
1855
|
+
syncJobActRow();
|
|
1856
|
+
}
|
|
1857
|
+
function stopProgressTimer():void {
|
|
1858
|
+
clearInterval(progressTimer);
|
|
1859
|
+
progressTimer=undefined;
|
|
1860
|
+
}
|
|
1861
|
+
/** Render the existing sentence. The timer writes only its age node until the quiet threshold. */
|
|
1862
|
+
function renderAskHeadline(sentence=askSentence):void {
|
|
1863
|
+
askSentence=sentence;
|
|
1864
|
+
stopProgressTimer();
|
|
1865
|
+
askHeadline.hidden=false;
|
|
1866
|
+
const progress=pendingAnswers.length ? null : jobProgress;
|
|
1867
|
+
if(!progress){
|
|
1868
|
+
askHeadline.removeAttribute('translate');
|
|
1869
|
+
askHeadline.style?.removeProperty('white-space');
|
|
1870
|
+
setSourceText(askHeadline,sentence);
|
|
1871
|
+
return;
|
|
1872
|
+
}
|
|
1873
|
+
const at=Date.parse(progress.at),age=()=>Math.max(0,Math.floor((Date.now()-at)/1000));
|
|
1874
|
+
const initialAge=age(),quiet=initialAge>=60;
|
|
1875
|
+
const phase=t('job.progress.phase.'+progress.phase);
|
|
1876
|
+
const phaseAndStep=progress.step ? phase+' · '+t('job.progress.step',[progress.step.i,progress.step.n]) : phase;
|
|
1877
|
+
const ageValue=(seconds:number)=>quiet ? String(Math.floor(seconds/60)) : seconds ? t('job.progress.seconds',[seconds]) : t('job.progress.now');
|
|
1878
|
+
const ageText=document.createTextNode(ageValue(initialAge));
|
|
1879
|
+
// Catalog fragments are already localized. Keep the agent's text as a literal across locale changes.
|
|
1880
|
+
askHeadline.setAttribute('translate','no');
|
|
1881
|
+
askHeadline.style?.setProperty('white-space','pre-wrap');
|
|
1882
|
+
if(quiet){
|
|
1883
|
+
const [before,after]=t('job.progress.quiet',['{0}',phaseAndStep]).split('{0}');
|
|
1884
|
+
askHeadline.replaceChildren(before!,ageText,after!);
|
|
1885
|
+
}else{
|
|
1886
|
+
const prefix=progress.text?phaseAndStep+' · '+progress.text:phaseAndStep;
|
|
1887
|
+
askHeadline.replaceChildren(prefix+' · ',ageText);
|
|
1888
|
+
}
|
|
1889
|
+
const tickAge=()=>{
|
|
1890
|
+
const seconds=age();
|
|
1891
|
+
if((seconds>=60)!==quiet){renderAskHeadline();return;}
|
|
1892
|
+
const value=ageValue(seconds);
|
|
1893
|
+
if(ageText.data!==value)ageText.data=value;
|
|
1894
|
+
};
|
|
1895
|
+
if(!suspended&&!disposed)progressTimer=setInterval(tickAge,1000);
|
|
1896
|
+
}
|
|
1693
1897
|
/** Answer controls compose the existing act bar and submit handlers. */
|
|
1694
1898
|
function renderAnswerControls():void {
|
|
1695
1899
|
const subjects=host?.pendingSubjects?.()??pendingAnswers;
|
|
1696
1900
|
const parts=subjects.some(subject=>subject.kind==='parts-verdict');
|
|
1697
1901
|
const verdict=parts||subjects.some(subject=>subject.kind==='review-verdict');
|
|
1698
1902
|
const dialog=subjects.some(subject=>!subject.kind.endsWith('verdict'))&&!verdict;
|
|
1699
|
-
const readable=questionForms.some(form=>form.dataset.interviewAnswered==='true')
|
|
1700
|
-
const
|
|
1903
|
+
const readable=questionForms.some(form=>form.dataset.interviewAnswered==='true');
|
|
1904
|
+
const questionEnabled=questionForms.some(form=>form.querySelector('fieldset:not(:disabled)'));
|
|
1905
|
+
const recordEnabled=!!recordDialog?.querySelector('fieldset:not(:disabled)');
|
|
1701
1906
|
const blocked=saving||draftConflict||!!actReadOnly||!!host?.unavailable;
|
|
1702
1907
|
const save=button('save');
|
|
1703
|
-
const
|
|
1908
|
+
const pendingPartComment=parts&&typeof partsSubject!=='undefined'&&!!partsSubject?.hasPendingComment?.();
|
|
1909
|
+
const pendingStageComment=!parts&&typeof comments!=='undefined'&&!!comments?.hasPendingComment?.();
|
|
1910
|
+
const hasPinnedPart=parts&&(liveIssueCount()>0||pendingPartComment);
|
|
1704
1911
|
const needsPinnedPart=parts&&!!host?.verdictComments?.rows.length&&!hasPinnedPart;
|
|
1705
1912
|
const pinRefusal='Request changes needs at least one comment pinned to a part.';
|
|
1706
1913
|
if((host||subjects.some(subject=>subject.kind==='interview-picks'))&&subjects.length&&!rigInspector.actBar.saveState())rigInspector.actBar.setSaveState({kind:'unsaved',text:'Not submitted'});
|
|
1707
1914
|
select('review-status').hidden=true;document.querySelector<HTMLLabelElement>('label[for="review-status"]')!.hidden=true;
|
|
1708
1915
|
save.classList.toggle('primary',verdict&&!hasPinnedPart);
|
|
1709
1916
|
requestChanges.classList.toggle('primary',hasPinnedPart);
|
|
1710
|
-
|
|
1711
|
-
const
|
|
1712
|
-
|
|
1713
|
-
|
|
1917
|
+
const questionPending=subjects.some(subject=>subject.kind==='interview-picks');
|
|
1918
|
+
const recordKind=subjects.find(subject=>!subject.kind.endsWith('verdict')&&subject.kind!=='interview-picks')?.kind;
|
|
1919
|
+
const recordTrigger=questionForms.length?recordAsk:rigAsk;
|
|
1920
|
+
if(!questionPending||recordTrigger!==rigAsk){
|
|
1921
|
+
setSourceText(recordTrigger,recordKind==='signoff'?'Approve…':'Review…');
|
|
1922
|
+
recordTrigger.disabled=!recordEnabled||blocked;
|
|
1923
|
+
}
|
|
1924
|
+
if(questionPending||questionForms.length){
|
|
1925
|
+
setSourceText(rigAsk,'Answer…');
|
|
1926
|
+
rigAsk.disabled=(!questionEnabled&&!readable)||(questionEnabled&&blocked);
|
|
1927
|
+
}
|
|
1928
|
+
rigAsk.classList.toggle('primary',dialog&&(questionPending||recordTrigger===rigAsk));
|
|
1929
|
+
recordAsk.classList.toggle('primary',dialog&&!questionPending&&!!recordKind);
|
|
1714
1930
|
if(verdict){
|
|
1715
|
-
const count=host?.direction?recordComments.length:liveIssueCount();
|
|
1931
|
+
const count=(host?.direction?recordComments.length:liveIssueCount())+(pendingPartComment||pendingStageComment?1:0);
|
|
1716
1932
|
const hasChanges=count>0||!!host?.canSubmitMeshEdits?.()&&subjects.some(subject=>subject.kind==='review-verdict'&&subject.stage==='rig-review');
|
|
1717
1933
|
setSourceText(save,'Approve');setSourceText(requestChanges,'Request changes');
|
|
1718
1934
|
save.disabled=blocked||!!readOnly||!!session?.feedbackWarnings?.length||(parts&&(partsAnswerBlocked()||count>0));
|
|
1719
1935
|
requestChanges.disabled=blocked||!!readOnly||!!session?.feedbackWarnings?.length||!hasChanges||(parts&&partsAnswerBlocked());
|
|
1720
1936
|
setSourceAttribute(save,'title',parts&&count>0?'Remove the flagged parts comments before approving.':'');
|
|
1721
|
-
setSourceAttribute(requestChanges,'title',needsPinnedPart?pinRefusal:hasChanges?'':'Add a comment where changes are needed.');
|
|
1937
|
+
setSourceAttribute(requestChanges,'title',needsPinnedPart?pinRefusal:hasChanges?'':host?.verdictComments&&!parts?'Add a comment or an edit where changes are needed.':'Add a comment where changes are needed.');
|
|
1722
1938
|
if(!parts){
|
|
1723
1939
|
save.onclick=event=>{session.status='approved';select('review-status').value=session.status;return verdictSubmit?.(event);};
|
|
1724
1940
|
}
|
|
1725
|
-
requestChanges.onclick=()=>{if(requestChanges.disabled)return;if(parts){if(liveIssueCount()===0)return;void save.onclick?.call(save,new PointerEvent('click'));}else{session.status='changes-requested';select('review-status').value=session.status;void verdictSubmit?.(new MouseEvent('click'));}};
|
|
1941
|
+
requestChanges.onclick=async()=>{if(requestChanges.disabled)return;if(parts){if(typeof partsSubject!=='undefined'&&partsSubject?.hasPendingComment?.()&&!await partsSubject.commitDraft())return;if(liveIssueCount()===0)return;void save.onclick?.call(save,new PointerEvent('click'));}else{if(typeof comments!=='undefined'&&comments?.hasPendingComment?.()&&!await comments.commitDraft())return;session.status='changes-requested';select('review-status').value=session.status;void verdictSubmit?.(new MouseEvent('click'));}};
|
|
1726
1942
|
}
|
|
1727
1943
|
for(const root of [recordDialog,...questionForms])for(const control of root?.querySelectorAll<HTMLButtonElement>('button[type="submit"]')??[])control.disabled=blocked||verdict;
|
|
1728
1944
|
// The waiting row is already visible: finish labels, state and handlers before revealing any answer.
|
|
1729
|
-
save.hidden=!verdict||firstPublicationPrompt;requestChanges.hidden=save.hidden;rigAsk.hidden=!dialog||firstPublicationPrompt;
|
|
1945
|
+
save.hidden=!verdict||firstPublicationPrompt;requestChanges.hidden=save.hidden;rigAsk.hidden=!dialog||firstPublicationPrompt||!questionPending&&recordTrigger!==rigAsk;
|
|
1946
|
+
recordAsk.hidden=!dialog||firstPublicationPrompt||recordTrigger!==recordAsk||!recordKind;
|
|
1730
1947
|
if(host?.verdictComments){
|
|
1731
1948
|
const notice=el('review-message');
|
|
1732
1949
|
if(needsPinnedPart&&!save.hidden&&!save.disabled){
|
|
@@ -1741,7 +1958,7 @@ function renderAnswerControls():void {
|
|
|
1741
1958
|
notice.classList.remove('error');
|
|
1742
1959
|
}
|
|
1743
1960
|
}
|
|
1744
|
-
if(host){rigInspector.answersRendered=true;
|
|
1961
|
+
if(host){rigInspector.answersRendered=true;syncJobActRow(subjects);}
|
|
1745
1962
|
}
|
|
1746
1963
|
let verdictSubmit:((event:MouseEvent)=>unknown)|null=null;
|
|
1747
1964
|
/** The rig pane for a live job's still (#709): the job binds and copies it, this screen keeps its view. */
|
|
@@ -1788,6 +2005,7 @@ async function restorePublicationNavigation():Promise<void> {
|
|
|
1788
2005
|
}
|
|
1789
2006
|
function suspendScreen():void {
|
|
1790
2007
|
if(suspended||disposed)return;
|
|
2008
|
+
stopProgressTimer();
|
|
1791
2009
|
if(!partsOnly&&(!host?.record||host.record.hasPicture))pause();
|
|
1792
2010
|
persistence?.dispose();persistence=null;suspended=true;cancelAnimationFrame(frameHandle);
|
|
1793
2011
|
}
|
|
@@ -1800,7 +2018,8 @@ async function resumeScreen():Promise<void> {
|
|
|
1800
2018
|
if(disposed)return;
|
|
1801
2019
|
if(partsOnly){await setupPartsPersistence?.();if(disposed)return;}
|
|
1802
2020
|
else if(!host?.record||host.record.hasPicture)await setupPersistence(true);
|
|
1803
|
-
suspended=false;if(
|
|
2021
|
+
suspended=false;if(jobProgress)renderAskHeadline();
|
|
2022
|
+
if(!partsOnly&&(!host?.record||host.record.hasPicture))frameHandle=requestAnimationFrame(tick);ready=true;
|
|
1804
2023
|
}finally{screenRoot.inert=ready?wasInert:true;if(ready&&!disposed)document.body.dataset.ready='true';}
|
|
1805
2024
|
}
|
|
1806
2025
|
function disposeScreen():void {releaseInterview?.();releaseInterview=null;
|
|
@@ -2002,7 +2221,12 @@ async function setupPersistence(keepCameraOnResume=false):Promise<boolean> {
|
|
|
2002
2221
|
let restoredChestFormPart:string|null=null;
|
|
2003
2222
|
inspectionOpening=true;try{
|
|
2004
2223
|
persistence=await connectInspectionPersistence({scope:'single:'+data.manifest.id+':'+data.sourceHash,binding:inspectionBinding(),baseline:submittedBaseline!,session:()=>session,reviewDirty:()=>dirty,restoreSession:(value,isDirty)=>{session=value;dirty=isDirty;select('review-status').value=session.status;renderProposals();renderCheckpoint();renderCheckpoints();renderProvenance();updateSavedState();},bookmark:inspectionBookmark,restoreBookmark:(b,s)=>restoreInspection(b,s,session.feedback.some(f=>isTimeOnlyFeedback(f)&&JSON.stringify((f.context as any).comment.bookmark)===JSON.stringify(b)),keepCameraOnResume||bookmarkCameraKept(inspectionOpening,!!host)),
|
|
2005
|
-
ui:()=>({chestFormPart,inspectorScroll:workspace?.scroll()??'{}',...(inspectorBlocks?activeBlocksUI(inspectorBlocks.state()):{}),reportCategory:select('report-category').value,reportPage,reportEvent:selectedReportEvent?.id??null,reportTime:selectedReportTime??null,reportTarget:selectedReportTarget??null}),restoreUI:value=>{restoredChestFormPart=typeof value.chestFormPart==='string'?value.chestFormPart:null;if(typeof value.reportCategory==='string'&&[...select('report-category').options].some(o=>o.value===value.reportCategory))select('report-category').value=value.reportCategory;if(typeof value.reportPage==='number'&&Number.isSafeInteger(value.reportPage)&&value.reportPage>=0)reportPage=value.reportPage;selectedReportEvent=typeof value.reportEvent==='string'?data.report?.categories.flatMap(c=>c.events).find(e=>e.id===value.reportEvent)??null:null;selectedReportTime=typeof value.reportTime==='number'?value.reportTime:undefined;selectedReportTarget=typeof value.reportTarget==='number'?value.reportTarget:undefined;renderReportEvents();renderReportSelection();inspectorBlocks?.restore(restoreActiveBlocksUI(value));workspace?.restoreScroll(value.inspectorScroll);},afterInputs:
|
|
2224
|
+
ui:()=>({chestFormPart,...(host?{chestLandmarkDraft:chestEditor?.jobDraftText()??null}:{}),inspectorScroll:workspace?.scroll()??'{}',...(inspectorBlocks?activeBlocksUI(inspectorBlocks.state()):{}),reportCategory:select('report-category').value,reportPage,reportEvent:selectedReportEvent?.id??null,reportTime:selectedReportTime??null,reportTarget:selectedReportTarget??null}),restoreUI:value=>{restoredChestFormPart=typeof value.chestFormPart==='string'?value.chestFormPart:null;if(typeof value.reportCategory==='string'&&[...select('report-category').options].some(o=>o.value===value.reportCategory))select('report-category').value=value.reportCategory;if(typeof value.reportPage==='number'&&Number.isSafeInteger(value.reportPage)&&value.reportPage>=0)reportPage=value.reportPage;selectedReportEvent=typeof value.reportEvent==='string'?data.report?.categories.flatMap(c=>c.events).find(e=>e.id===value.reportEvent)??null:null;selectedReportTime=typeof value.reportTime==='number'?value.reportTime:undefined;selectedReportTarget=typeof value.reportTarget==='number'?value.reportTarget:undefined;renderReportEvents();renderReportSelection();inspectorBlocks?.restore(restoreActiveBlocksUI(value));workspace?.restoreScroll(value.inspectorScroll);},afterInputs:draft=>{
|
|
2225
|
+
if(host){
|
|
2226
|
+
const saved=draft?.ui.chestLandmarkDraft;
|
|
2227
|
+
chestEditor?.restoreJobDraft(typeof saved==='string'?saved:null);
|
|
2228
|
+
}
|
|
2229
|
+
chestFormPart=restoredChestFormPart??parts?.value()?.slot??null;const selected=parts?.value()?.slot;if(rebuildStatus&&selected)void openStageCorrection({part:selected,instrument:'selection'});const target=input('feedback-target-name').value;renderFeedbackTargets(true);if(select('feedback-target-kind').value!=='rig')input('feedback-target-name').value=target;renderFeedbackRange();text('audio-volume-label',`${Math.round(Number(input('audio-volume').value)*100)}%`);},onConflict:value=>{draftConflict=value;updateSavedState();},onStatus:value=>{draftStatus=value;renderDraftState();}});
|
|
2006
2230
|
}finally{inspectionOpening=false;}
|
|
2007
2231
|
return persistence.restored;
|
|
2008
2232
|
}
|
|
@@ -2011,7 +2235,8 @@ function chestField(id:string){const node=document.getElementById(id) as HTMLInp
|
|
|
2011
2235
|
function chestEvaluation(){return evaluateChestForm(chestField,chestMapping,activeSetupBones());}
|
|
2012
2236
|
function chestRegions():OverlayRegion[]{
|
|
2013
2237
|
// #345: the chest overlay is drawn only while the Chest regions toggle is on.
|
|
2014
|
-
|
|
2238
|
+
// Jobs draw the landmark derivation through chestCircles, separately from manual region rows.
|
|
2239
|
+
if(host||!chestEditor?.active())return [];
|
|
2015
2240
|
const style=getComputedStyle(document.documentElement),token=(name:string)=>style.getPropertyValue(name).trim();
|
|
2016
2241
|
return chestOverlayPolygons(chestEvaluation(),activeChestMapping()).map((region,i)=>({...region,stroke:token(i?'--rv-region-b':'--rv-region-a'),fill:token(i?'--rv-region-b-fill':'--rv-region-a-fill')}));
|
|
2017
2242
|
}
|
|
@@ -2322,7 +2547,7 @@ function rebindChestPart(status:RebuildStatusView,part:string):void {
|
|
|
2322
2547
|
}
|
|
2323
2548
|
/** `GET /api/rebuild`: whether Apply can run, and the producer config's regions to start an untouched editor from. */
|
|
2324
2549
|
async function loadRebuildStatus():Promise<RebuildStatusView|null> {
|
|
2325
|
-
try{rebuildStatus=await api<RebuildStatusView>('/api/rebuild');}catch(error){rebuildStatus=null;const reason=`REBUILD_STATUS_UNAVAILABLE: ${errorText(error)}`;chestEditor?.notify(reason,true);animationPanel?.loadSource(null,reason);return null;}
|
|
2550
|
+
try{rebuildStatus=await api<RebuildStatusView>('/api/rebuild');}catch(error){rebuildStatus=null;const reason=`REBUILD_STATUS_UNAVAILABLE: ${errorText(error)}`;if(!host)chestEditor?.notify(reason,true);animationPanel?.loadSource(null,reason);return null;}
|
|
2326
2551
|
// Restore the form owner before seeding either mode or caching a selection switch.
|
|
2327
2552
|
chestFormPart??=chestSeed(rebuildStatus).part;
|
|
2328
2553
|
const scoped=chestStatusForPart(rebuildStatus,chestFormPart);
|
|
@@ -3228,7 +3453,7 @@ function setupComments():void {
|
|
|
3228
3453
|
return {mode:workspaceMode==='playback'?'animate':'setup',capture:{pane,root:view==='rig'?el('rig-root'):undefined,images:view==='reference'||layers.images,canvas:view==='rig'&&renderer instanceof CanvasRenderer?renderer.canvas:undefined,backend:renderer instanceof CanvasRenderer?renderer.backendActive:renderer?.meshBackendActive??'canvas2d'},camera,frame:index===null?null:{index,basis:'producer'},...(index===null?{timeBasis:timeOnlyBasis}:{}),time:current,animation:animation||null,turn:turnPad?.snapshot()??null,sourceHash:data.sourceHash,modelHash:view==='reference'?null:stageModelHash,referenceHash,referenceId,rig:data.manifest.id,...(view==='reference'?{media:video??el('reference-content').querySelector('img')??undefined}:{posed:parts?.frame('single'),assets:assets??undefined})} as CommentPose;
|
|
3229
3454
|
},
|
|
3230
3455
|
pause:async()=>{const running=playing||!!video&&!video.paused;pause();if(running&&video&&video.readyState>=1){seekingControl=true;try{await inspectControlTime(time,new AbortController().signal);}finally{seekingControl=false;}}if(turnPad)turnPad.restore({...turnPad.snapshot(),held:true},false);},bookmark:inspectionBookmark,restore:(b,timed)=>restoreInspection(parseBookmark(b,inspectionBinding()),new AbortController().signal,!!timed),feedback:()=>host?.record||host?.direction?recordComments:session.feedback,
|
|
3231
|
-
locked:host?.record?()=>false:host?.direction?id=>submittedDirectionComments.has(id):isSubmittedFeedback,add:f=>{if(host?.record||host?.direction)recordComments.push(f);else session.feedback.push(f as Feedback);},changed:()=>{if(host?.record||host?.direction){recordCommentsChanged();if(host?.direction){markDirty();comments?.refresh();}return;}if(host?.verdictComments)persistRecordComments();markDirty();renderProposals();return persistence?.save();},error:value=>message(value,true),
|
|
3456
|
+
locked:host?.record?()=>false:host?.direction?id=>submittedDirectionComments.has(id):isSubmittedFeedback,add:f=>{if(host?.record||host?.direction)recordComments.push(f);else session.feedback.push(f as Feedback);},changed:()=>{if(/^The source changed, so /.test(draftStatus??''))draftStatus=null;if(host?.record||host?.direction){recordCommentsChanged();if(host?.direction){markDirty();comments?.refresh();}return;}if(host?.verdictComments)persistRecordComments();markDirty();renderProposals();return persistence?.save();},draftChanged:()=>{if(typeof renderAnswerControls==='function')renderAnswerControls();},error:value=>message(value,true),
|
|
3232
3457
|
refusal:()=>host?.record&&!host.record.hasPicture?null:commentCaptureRefusal(),blocked:()=>saving||!!persistence?.restoring()||seekingControl||!!video?.seeking||!!rebuildBusy||!!appliedOnStage,shortcutBlocked:()=>!!meshEditor?.active()
|
|
3233
3458
|
});
|
|
3234
3459
|
if(host?.verdictComments)renderProposals();
|