@rig-c/review 4.6.0 → 4.8.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.
@@ -37,6 +37,7 @@ export function jobWindowRefusal(error: unknown, fallback = 'JOB_WINDOW_FAILED')
37
37
  Object.hasOwn(enCatalog, message) && Object.hasOwn(koCatalog, message)) {
38
38
  return t(message);
39
39
  }
40
+ console.error('[job-window]', fallback, error);
40
41
  return t(fallback);
41
42
  }
42
43
  /** Submission copy and its diagnostic title share the existing catalog refusal registry. */
@@ -91,6 +92,7 @@ export interface JobWindowState {
91
92
  readonly closed: boolean;
92
93
  readonly error: string | null;
93
94
  readonly errorOrigin?: string;
95
+ readonly failure?: unknown;
94
96
  readonly previousLabel: string | null;
95
97
  readonly pending: readonly JobWindowAsk[];
96
98
  readonly retainedDrafts: readonly JobRetainedDraft[];
@@ -202,6 +204,7 @@ export function createJobWindow<Prepared>(options: {
202
204
  let closed = false;
203
205
  let error: string | null;
204
206
  let errorOrigin: string | undefined;
207
+ let failure: unknown;
205
208
  error = null;
206
209
  let previousLabel: string | null = null;
207
210
  let intent = 0;
@@ -210,7 +213,7 @@ export function createJobWindow<Prepared>(options: {
210
213
  let queue = Promise.resolve();
211
214
  function state(): JobWindowState {
212
215
  return {
213
- generation, displayed, receipt, preparing, closed, error, previousLabel, ...(errorOrigin ? {errorOrigin} : {}),
216
+ generation, displayed, receipt, preparing, closed, error, previousLabel, ...(errorOrigin ? {errorOrigin} : {}), ...(failure !== undefined ? {failure} : {}),
214
217
  pending: [...pending.values()], retainedDrafts: [...retainedDrafts],
215
218
  };
216
219
  }
@@ -225,6 +228,7 @@ export function createJobWindow<Prepared>(options: {
225
228
  preparing = true;
226
229
  error = null;
227
230
  errorOrigin = undefined;
231
+ failure = undefined;
228
232
  changed();
229
233
  queue = queue.then(async () => {
230
234
  if (revision !== intent || stopped)
@@ -311,10 +315,11 @@ export function createJobWindow<Prepared>(options: {
311
315
  error = 'JOB_WINDOW_CLEANUP_FAILED';
312
316
  }
313
317
  }
314
- catch (failure) {
318
+ catch (caught) {
315
319
  if (revision === intent && !stopped) {
316
- error = failure instanceof Error ? failure.message : 'JOB_DISPLAY_MISMATCH';
317
- errorOrigin = failure instanceof Error && typeof failure.cause === 'string' ? failure.cause : undefined;
320
+ error = caught instanceof Error ? caught.message : 'JOB_DISPLAY_MISMATCH';
321
+ failure = caught instanceof Error ? caught : undefined;
322
+ errorOrigin = caught instanceof Error && typeof caught.cause === 'string' ? caught.cause : undefined;
318
323
  }
319
324
  }
320
325
  finally {
@@ -651,6 +656,7 @@ import type { ModelAssets, RigPlayer } from '@rig-c/play';
651
656
  import type { PartInspection } from './part-selection.ts';
652
657
  import type { Checkpoint, ReviewManifest, ReviewedSource } from '../src/manifest.ts';
653
658
  import type { DirectionInspection } from '../src/direction-inspection.ts';
659
+ import type { SceneInspection } from '../src/scene-inspection.ts';
654
660
  import type { FeedbackCatalog } from '../src/feedback-validation.ts';
655
661
  import type { InterviewQuestion } from '../src/interview-project.ts';
656
662
  type JobCheckpointEvidenceMetadata = Omit<JobCheckpointEvidence, 'tiles' | 'table'> & {
@@ -664,9 +670,11 @@ export interface JobInspectionMetadata {
664
670
  recordSource?: undefined;
665
671
  sourceHash: string;
666
672
  reviewedSource: ReviewedSource;
673
+ assetsBase?: string;
667
674
  setsHash?: string;
668
675
  initialAnimation?: string | null;
669
676
  direction?: DirectionInspection;
677
+ scene?: SceneInspection;
670
678
  referenceHashes?: Record<string, string>;
671
679
  sourcePainting?: {
672
680
  id: string;
@@ -681,28 +689,15 @@ export interface JobInspectionMetadata {
681
689
  };
682
690
  feedbackCatalog: Pick<FeedbackCatalog, 'slots'> & Partial<Pick<FeedbackCatalog, 'bones'>>;
683
691
  }
684
- export interface JobRecordInspectionMetadata {
685
- checkpointEvidence?: readonly JobCheckpointEvidenceMetadata[];
686
- planText?: JobPlanTextProjection;
687
- manifest?: undefined;
692
+ export interface JobRecordInspectionMetadata extends Omit<JobInspectionMetadata, 'recordSource' | 'manifest' | 'reviewedSource'> {
688
693
  recordSource: RecordSource;
689
- sourceHash: string;
690
- reviewedSource?: undefined;
691
- setsHash?: undefined;
692
- initialAnimation?: null;
693
- direction?: undefined;
694
- referenceHashes?: undefined;
695
- sourcePainting?: undefined;
696
- capabilities: {
697
- interview?: boolean;
698
- preRig?: boolean;
699
- playback: boolean;
700
- };
701
- feedbackCatalog: Pick<FeedbackCatalog, 'slots'> & Partial<Pick<FeedbackCatalog, 'bones'>>;
694
+ manifest?: ReviewManifest;
695
+ reviewedSource?: ReviewedSource;
702
696
  }
703
697
  export type JobInspectionMetadataV3 = JobInspectionMetadata | JobRecordInspectionMetadata;
704
698
  type JobInterview = {
705
- questions: (Omit<InterviewQuestion, 'images'> & {
699
+ questions: (Omit<InterviewQuestion, 'images' | 'set'> & {
700
+ set: InterviewQuestion['set'] & {context?: {kind?: unknown; rig_version?: unknown}};
706
701
  images: {
707
702
  name: string;
708
703
  url: string;
@@ -883,8 +878,10 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
883
878
  const routes = jobPublicationRoutes(display, location.origin);
884
879
  const metadata = await jobJson<JobInspectionMetadataV3>(routes.api('review'), signal);
885
880
  const publishedSource = display.publication.source;
886
- if (isRecordSource(publishedSource)) {
887
- if (!metadata.recordSource || metadata.manifest !== undefined || metadata.reviewedSource !== undefined ||
881
+ const record = isRecordSource(publishedSource);
882
+ const recordRig = record && (metadata.manifest !== undefined || metadata.reviewedSource !== undefined);
883
+ if (record) {
884
+ if (!metadata.recordSource || !metadata.capabilities || (!recordRig && metadata.capabilities.playback) ||
888
885
  metadata.sourceHash !== publishedSource.sourceHash ||
889
886
  sourceSnapshot(metadata.recordSource) !== sourceSnapshot(publishedSource)) {
890
887
  throw new Error('JOB_DISPLAY_MISMATCH');
@@ -964,6 +961,34 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
964
961
  }
965
962
  try {
966
963
  const interview = metadata.capabilities.interview ? await jobJson<JobInterview>(routes.api('interview'), signal) : null;
964
+ if (recordRig) {
965
+ const {manifest, reviewedSource} = metadata;
966
+ const model = reviewedSource?.rig;
967
+ if (publishedSource.subject !== 'option-set' || metadata.assetsBase !== display.routes.assetsBase ||
968
+ metadata.capabilities.playback !== true || metadata.capabilities.interview !== true || metadata.capabilities.preRig ||
969
+ !manifest || manifest.schema !== 'rig-review/1' || !reviewedSource || !model || model.path !== 'build/skeleton.model.json' ||
970
+ manifest.model !== model.path || reviewedSource.packageRevision !== manifest.revision ||
971
+ reviewedSource.motion !== null || reviewedSource.handoff !== undefined || metadata.initialAnimation != null ||
972
+ metadata.direction || metadata.scene || metadata.sourcePainting || metadata.setsHash ||
973
+ manifest.motion || manifest.sets || manifest.direction || manifest.scene || manifest.producer ||
974
+ [manifest.references, manifest.checkpoints, manifest.authoring, manifest.axes, manifest.audio?.clips, manifest.audio?.cues]
975
+ .some(rows => !Array.isArray(rows) || rows.length !== 0) ||
976
+ !Array.isArray(interview?.questions) || interview.questions.length !== 1) {
977
+ throw new Error('JOB_DISPLAY_MISMATCH');
978
+ }
979
+ const [question] = interview.questions;
980
+ const context = question?.set?.context;
981
+ if (!question?.set || question.set.stage !== 'post-interview' || question.editable !== true ||
982
+ question.set.id !== publishedSource.selection.setId || question.set.question !== publishedSource.selection.questionId ||
983
+ sourceSnapshot(question.ref) !== sourceSnapshot(publishedSource.optionSetFile) || question.missingPicture !== undefined ||
984
+ question.hasParts || question.scenePicture || !Array.isArray(question.images) || question.images.length ||
985
+ !context || context.kind !== 'rig' || typeof context.rig_version !== 'number' ||
986
+ !Number.isSafeInteger(context.rig_version) || context.rig_version < 1 ||
987
+ !publishedSource.files.some(file =>
988
+ file.path === `derived/review/v${context.rig_version}/out/check/${model.path}` && file.sha256 === model.sha256)) {
989
+ throw new Error('JOB_DISPLAY_MISMATCH');
990
+ }
991
+ }
967
992
  if (interview?.interview !== undefined && display.publication.interview !== undefined &&
968
993
  sourceSnapshot(interview.interview) !== sourceSnapshot(display.publication.interview)) {
969
994
  throw new Error('JOB_DISPLAY_MISMATCH');
@@ -1137,7 +1162,8 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
1137
1162
  const failed = preloaded.find(result => result.status === 'rejected');
1138
1163
  if (failed?.status === 'rejected')
1139
1164
  throw failed.reason;
1140
- if (!formsOnly && metadata.manifest?.model) {
1165
+ // A record's bound rig is drawn by the shared workspace. This inspection prepares its forms.
1166
+ if (!formsOnly && !recordRig && metadata.manifest?.model) {
1141
1167
  const runtime = await import('@rig-c/play');
1142
1168
  const modelUrl = routes.asset(metadata.manifest.model);
1143
1169
  const modelHash = metadata.reviewedSource!.rig!.sha256;
@@ -1413,6 +1439,8 @@ export interface JobFormDependencies {
1413
1439
  }
1414
1440
  interviewForm=createInterviewForm({question,id:'interview-answer-'+ask.askId,node,form,fieldset:fields,source,mainView:deps.interviewMainView,
1415
1441
  images:question.images.map(image=>({name:image.name,src:jobPublicationRoutes(prepared.display,location.origin).instance(image.url)})),answered:ask.status==='answered'});
1442
+ if (deps.interviewMainView && prepared.metadata.recordSource && prepared.metadata.manifest?.model)
1443
+ interviewForm.form.dataset.interviewMain = '';
1416
1444
  disposeInterview=interviewForm.dispose;read=interviewForm.read;
1417
1445
  submitKey = 'interview.save';
1418
1446
  }
@@ -1662,7 +1690,7 @@ export async function mountJobScreen(host:HTMLElement):Promise<()=>void> {
1662
1690
  commit:prepared=>prepared?rigScreen.commit(prepared):{rollback(){},finalize(){}},
1663
1691
  async painted(prepared,signal){if(stopped||signal.aborted)return;if(prepared)await rigScreen.painted(prepared,signal);},
1664
1692
  discard:prepared=>{const modal=prepared?.record??prepared?.modals;for(const entry of modal?.forms.values()??[])entry.dispose?.();modal?.inspection.dispose();},
1665
- changed(state){rigScreen.changed(state);if(!state.error&&rigScreen.mounted())bootstrapPrior=null;if(state.error&&(!rigScreen.mounted()||rigScreen.mounted()?.record))report(state.error);},
1693
+ changed(state){rigScreen.changed(state);if(!state.error&&rigScreen.mounted())bootstrapPrior=null;if(state.error&&(!rigScreen.mounted()||rigScreen.mounted()?.record))report(state.failure??state.error);},
1666
1694
  }});
1667
1695
  const localize=i18n.onLanguageChange(()=>{for(const element of host.querySelectorAll<HTMLElement>('[data-job-text]'))element.textContent=t(element.dataset.jobText!);for(const form of host.querySelectorAll('form.interview-answer'))form.dispatchEvent(new Event('job-form-language'));});
1668
1696
  await rigScreen.waiting();