rig-review 2.13.0 → 4.0.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.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/docs/PARTS_VIEW.md +1 -1
  3. package/docs/REVIEW_PACKAGE.md +32 -91
  4. package/docs/STABILITY.md +27 -194
  5. package/docs/WORKFLOWS.md +0 -107
  6. package/package.json +1 -1
  7. package/skills/rig-review/SKILL.md +11 -25
  8. package/src/build.ts +2 -2
  9. package/src/direction-inspection.ts +6 -2
  10. package/src/front.ts +4 -193
  11. package/src/interview-scene.ts +3 -3
  12. package/src/job-act.ts +1 -35
  13. package/src/job-api.ts +27 -19
  14. package/src/job-cli.ts +3 -3
  15. package/src/job-contract.ts +14 -50
  16. package/src/job-front.ts +17 -44
  17. package/src/job-host.ts +1 -4
  18. package/src/job-session.ts +22 -10
  19. package/src/job-source.ts +3 -17
  20. package/src/job-store.ts +80 -6
  21. package/src/job-worker.ts +1 -47
  22. package/src/manifest.ts +23 -4
  23. package/src/open.ts +2 -3
  24. package/src/scene-inspection.ts +50 -0
  25. package/src/server.ts +1 -1
  26. package/web/catalog-en.ts +37 -27
  27. package/web/catalog-ko.ts +37 -27
  28. package/web/compare.css +0 -4
  29. package/web/direction-panel.ts +22 -6
  30. package/web/inspector-blocks.ts +8 -4
  31. package/web/job-rig-capture.ts +62 -12
  32. package/web/job-rig-screen.ts +75 -55
  33. package/web/job-session.ts +89 -1091
  34. package/web/main.ts +113 -56
  35. package/web/parts-viewport-provider.ts +8 -3
  36. package/web/retained-frame-stage.ts +7 -7
  37. package/web/rig-host.ts +5 -3
  38. package/web/rig-viewport-provider.ts +2 -0
  39. package/web/scene-plates.ts +57 -4
  40. package/web/styles.css +12 -82
  41. package/web/viewport-capture.ts +12 -2
  42. package/web/workspace-ui.ts +5 -6
  43. package/src/front-worker.ts +0 -2
  44. package/src/job-hub.ts +0 -304
  45. package/src/job-image-set.ts +0 -73
  46. package/web/job-hub.ts +0 -160
package/web/catalog-ko.ts CHANGED
@@ -1,4 +1,14 @@
1
1
  export const koCatalog: Readonly<Record<string, string>> = {
2
+ "JOB_DIRECTION_MISSING": "JOB_DIRECTION_MISSING",
3
+ "job.refusal.JOB_DIRECTION_MISSING": "이 게시물에는 디렉션이 없습니다. 제작 도구에서 모델과 함께 디렉션 데이터를 게시해야 합니다.",
4
+ "JOB_PARTS_MISSING": "JOB_PARTS_MISSING",
5
+ "job.refusal.JOB_PARTS_MISSING": "이 초안에는 파츠가 없습니다. 제작 도구에서 초안 파츠를 게시한 후 파츠 검토를 요청해야 합니다.",
6
+ "JOB_MODEL_MISSING": "JOB_MODEL_MISSING",
7
+ "job.refusal.JOB_MODEL_MISSING": "이 요청에는 컴파일된 모델이 없습니다. 제작 도구에서 컴파일된 모델을 게시한 후 리그 판정을 요청해야 합니다.",
8
+ "JOB_ASK_UNSUPPORTED": "JOB_ASK_UNSUPPORTED",
9
+ "job.refusal.JOB_ASK_UNSUPPORTED": "이 요청에 맞는 소스 또는 체크포인트 연결 정보가 없습니다. 제작 도구에서 해당 소스와 계획 연결 정보를 게시한 후 다시 요청해야 합니다.",
10
+ "Comment · C": "코멘트 · C",
11
+
2
12
  "project.json": "project.json",
3
13
  'job.commentsFromWorkspace': '작업 공간의 코멘트를 함께 제출해요. 코멘트를 추가하거나 고치려면 이 요청을 닫으세요.',
4
14
  'Add general comment': '일반 코멘트 추가',
@@ -29,8 +39,6 @@ export const koCatalog: Readonly<Record<string, string>> = {
29
39
  "PARTS_MESH_GENERATED": "PARTS_MESH_GENERATED",
30
40
  "PARTS_MESH_GENERATED: No mesh geometry is available for this part.": "PARTS_MESH_GENERATED: 이 파츠에는 표시할 메시 형상이 없습니다.",
31
41
  "JOB_STILL_CAPTURE_FAILED": "JOB_STILL_CAPTURE_FAILED · 표시된 리그 프레임을 캡처하지 못했습니다. 정상적으로 그려진 뒤 다시 시도하세요.",
32
- "JOB_STILL_CAMERA_NOT_FIXED": "JOB_STILL_CAMERA_NOT_FIXED · 판정을 제출하기 전에 리그를 기본 화면 구도로 되돌리세요.",
33
- "JOB_STILL_VIEW_UNSUPPORTED": "JOB_STILL_VIEW_UNSUPPORTED · 단독 표시·강조·비교 레이어를 해제하고 전체 리그를 표시한 뒤 제출하세요.",
34
42
  "JOB_STILL_BINDING_MISMATCH": "JOB_STILL_BINDING_MISMATCH · 표시된 소스·페이지·그려진 프레임이 바뀌었습니다. 새 판정 시도를 시작하세요.",
35
43
  "JOB_REVIEW_READ_ONLY": "JOB_REVIEW_READ_ONLY · 이 작업 대상은 여기서 읽기 전용입니다. 프로듀서 도구와 다시 빌드는 사용할 수 없습니다.",
36
44
  "JOB_ACT_NOTHING_TO_SUBMIT": "JOB_ACT_NOTHING_TO_SUBMIT · 제출하기 전에 승인, 변경 요청 또는 체크포인트 결과를 고르세요.",
@@ -193,6 +201,20 @@ export const koCatalog: Readonly<Record<string, string>> = {
193
201
  "DIRECTION_SOURCE_CHANGED: undeclared playback input": "DIRECTION_SOURCE_CHANGED: 선언되지 않은 재생 입력입니다.",
194
202
  "DIRECTION_SOURCE_CHANGED: playback bytes differ from the bound SHA-256": "DIRECTION_SOURCE_CHANGED: 재생 입력의 SHA-256이 기록된 값과 다릅니다.",
195
203
  "direction.title": "연출 검사",
204
+ 'direction.planes': '합성 레이어: {0}',
205
+ 'direction.threePlanes': '배경 → 인물 → 전경',
206
+ 'direction.twoPlanes': '배경 → 인물',
207
+ 'direction.noScene': '인물만 표시: 이 게시본에는 장면이 선언되지 않았습니다.',
208
+ 'direction.legacyTake': '인물만 표시: direction@1에는 장면 합성이 없습니다.',
209
+ "scene.required": "SCENE_REQUIRED: {0}",
210
+ "scene.plateChanged": "SCENE_PLATE_CHANGED: {0}",
211
+ "scene.plateDimensions": "SCENE_PLATE_DIMENSIONS: {0}",
212
+ "scene.canvasRequired": "SCENE_REQUIRED: 캔버스 렌더러가 필요합니다.",
213
+ "direction.summary": "연출{0} · {1}초 · {2} · {3}",
214
+ "direction.loop": "반복",
215
+ "direction.once": "한 번",
216
+ "direction.fixedCamera": "카메라 고정",
217
+ "direction.movingCamera": "카메라 이동",
196
218
  "direction.inspected": "검사 모델 · {0} · SHA-256 {1}",
197
219
  "direction.scratch": "임시 빌드 모델 · {0} · SHA-256 {1}",
198
220
  "direction.modelUnavailable": "MODEL_UNAVAILABLE · 불러온 컴파일 모델이 없습니다.",
@@ -3447,27 +3469,30 @@ export const koCatalog: Readonly<Record<string, string>> = {
3447
3469
  "CHECKPOINT_EVIDENCE_HASH_MISMATCH": "CHECKPOINT_EVIDENCE_HASH_MISMATCH",
3448
3470
  "CHECKPOINT_EVIDENCE_PNG_INVALID": "CHECKPOINT_EVIDENCE_PNG_INVALID",
3449
3471
  "CHECKPOINT_EVIDENCE_TABLE_INVALID": "CHECKPOINT_EVIDENCE_TABLE_INVALID",
3450
- "job.imageSetTitle": "이미지 비교",
3451
- "job.imageSetDigest": "이미지 세트 SHA-256",
3452
3472
  "job.imageNote": "이미지 메모 (선택)",
3453
3473
  "job.imageRole.source": "원본",
3454
3474
  "job.imageRole.candidate": "후보",
3455
3475
  "job.imageRole.reference": "참조",
3456
3476
  "job.identicalImages": "이 세트에 같은 바이트의 이미지가 있어요.",
3457
- "image-set": "image-set",
3458
3477
  "plate-adoption": "plate-adoption",
3459
3478
  "image-review": "image-review",
3460
- "rig-review-job-image-set/1": "rig-review-job-image-set/1",
3461
- "JOB_IMAGE_SET_UNSUPPORTED": "JOB_IMAGE_SET_UNSUPPORTED",
3462
- "JOB_IMAGE_SET_INVALID": "JOB_IMAGE_SET_INVALID",
3463
- "JOB_IMAGE_SET_DUPLICATE_NAME": "JOB_IMAGE_SET_DUPLICATE_NAME",
3464
- "JOB_IMAGE_SET_DUPLICATE_PATH": "JOB_IMAGE_SET_DUPLICATE_PATH",
3465
- "JOB_IMAGE_SET_ROLE_INVALID": "JOB_IMAGE_SET_ROLE_INVALID",
3466
- "JOB_IMAGE_SET_PATH_REFUSED": "JOB_IMAGE_SET_PATH_REFUSED",
3467
3479
  "JOB_ASK_INVALID": "JOB_ASK_INVALID",
3468
3480
  "JOB_ASK_SUPERSEDED": "JOB_ASK_SUPERSEDED",
3469
3481
  "JOB_AUTHORITY_REFUSED": "JOB_AUTHORITY_REFUSED",
3470
3482
  "JOB_BODY_LIMIT": "JOB_BODY_LIMIT",
3483
+ "client: submission": "client: submission",
3484
+ "client: event stream": "client: event stream",
3485
+ "client: preload": "client: preload",
3486
+ "{0} {1} \u00b7 {2} bytes \u00b7 HTTP {3}": "{0} {1} \u00b7 {2} bytes \u00b7 HTTP {3}",
3487
+ "job.submit.refused": "요청이 거절됐어요 — 리뷰를 새로고침하고 대기 중인 요청을 확인한 뒤 다시 제출해 주세요.",
3488
+ "job.submit.JOB_ACT_NOTHING_TO_SUBMIT": "판정이 선택되지 않았어요 — 승인, 수정 요청 또는 체크포인트 결과를 선택해 주세요.",
3489
+ "job.submit.JOB_STILL_CAPTURE_FAILED": "리그 이미지를 캡처하지 못했어요 — 리그가 다 그려질 때까지 기다린 뒤 다시 제출해 주세요.",
3490
+ "job.submit.JOB_STILL_BINDING_MISMATCH": "표시된 프레임이나 원본이 바뀌었어요 — 현재 리그가 로드될 때까지 기다린 뒤 다시 제출해 주세요.",
3491
+ "job.submit.JOB_BODY_LIMIT": "댓글에 첨부된 이미지나 리그 캡처 때문에 리뷰 제출 데이터가 너무 커요 — 이미지 댓글을 일부 삭제하거나, 수정될 때까지 초안을 보존해 주세요.",
3492
+ "job.submit.JOB_ACT_SOURCE_STALE": "리뷰 원본이 바뀌었어요 — 리뷰를 새로고침하고 현재 원본을 확인한 뒤 제출해 주세요.",
3493
+ "job.submit.JOB_STILL_UNAVAILABLE": "보존된 리그 이미지를 사용할 수 없어요 — 현재 리그 리뷰를 다시 열고 제출해 주세요.",
3494
+ "job.submit.JOB_STILL_OUTPUT_FAILED": "리그 이미지를 저장하지 못했어요 — 호스트 담당자에게 출력 위치 확인을 요청해 주세요.",
3495
+ "Review was not submitted: {0}": "리뷰가 제출되지 않았어요: {0}",
3471
3496
  "JOB_CAPABILITY_REQUIRED": "JOB_CAPABILITY_REQUIRED",
3472
3497
  "JOB_CLOSED": "JOB_CLOSED",
3473
3498
  "JOB_CURSOR_INVALID": "JOB_CURSOR_INVALID",
@@ -3513,21 +3538,6 @@ export const koCatalog: Readonly<Record<string, string>> = {
3513
3538
  "JOB_SOURCE_MISMATCH": "JOB_SOURCE_MISMATCH",
3514
3539
  "JOB_SOURCE_UNRETAINABLE": "JOB_SOURCE_UNRETAINABLE",
3515
3540
  "JOB_STORAGE_FAILED": "JOB_STORAGE_FAILED",
3516
- "rig-review-job-hub/1": "rig-review-job-hub/1",
3517
- "JOB_HUB_ALREADY_RUNNING": "JOB_HUB_ALREADY_RUNNING",
3518
- "JOB_HUB_EXTERNAL_HOST": "JOB_HUB_EXTERNAL_HOST",
3519
- "JOB_HUB_HOST_UNRESPONSIVE": "JOB_HUB_HOST_UNRESPONSIVE",
3520
- "JOB_HUB_CLOSED": "JOB_HUB_CLOSED",
3521
- "JOB_HUB_LIMIT": "JOB_HUB_LIMIT",
3522
- "JOB_HUB_STATE_INVALID": "JOB_HUB_STATE_INVALID",
3523
- "JOB_HUB_REQUEST_REFUSED": "JOB_HUB_REQUEST_REFUSED",
3524
- "rig-review-job-hub-ready/1": "rig-review-job-hub-ready/1",
3525
- "rig-review-job-hub-visibility/1": "rig-review-job-hub-visibility/1",
3526
- "job.hubTitle": "리뷰 작업",
3527
- "job.hubJobs": "리뷰 작업",
3528
- "job.hubHint": "작업을 선택해. 초안은 원래 소스에 보관돼.",
3529
- "job.hubClosed": "명시적으로 종료됨",
3530
- "job.hubPending": "진행 중 · 대기 요청 {0}개",
3531
3541
  "JOB_STREAM_FAILED": "JOB_STREAM_FAILED",
3532
3542
  "JOB_STREAM_INCOMPLETE": "JOB_STREAM_INCOMPLETE",
3533
3543
  "JOB_UNKNOWN": "JOB_UNKNOWN",
package/web/compare.css CHANGED
@@ -277,10 +277,6 @@ main{position:relative}.viewbar,.toolbar{anchor-name:--stage-comment-bar}#stage-
277
277
  .settings-toggle[aria-expanded=true]::before{content:"▴"}
278
278
  :root:lang(ko){word-break:keep-all;overflow-wrap:break-word}
279
279
 
280
- /* Stage navigation retains mounted inspection tools and their state. */
281
- .review-stage-nav{display:flex;gap:4px;flex-wrap:wrap;align-items:center}
282
- .review-stage-nav button{font:inherit;white-space:nowrap;padding:5px 8px}
283
- .review-stage-nav [aria-current="step"]{font-weight:700;text-decoration:underline;text-underline-offset:4px}
284
280
  .topbar,.pv-top{flex-wrap:wrap}
285
281
 
286
282
  /* Stage chips open Setup and Animate on this screen; a refused rig hides the mode switch (#726). */
@@ -1,3 +1,4 @@
1
+ import type {SceneInspection} from '../src/scene-inspection.ts';
1
2
  import type { DirectionInspection } from '../src/direction-inspection.ts';
2
3
  import type { TurnDial } from '../src/turn-pad.ts';
3
4
  import { onLanguageChange, t } from './i18n.ts';
@@ -11,6 +12,7 @@ export interface DirectionView {
11
12
  sets: readonly string[];
12
13
  activeSet?: string;
13
14
  authored?: DirectionInspection;
15
+ scene?: SceneInspection;
14
16
  }
15
17
 
16
18
  export function directionRows(view: DirectionView): { key: string; values?: string[] }[] {
@@ -29,16 +31,30 @@ export function directionRows(view: DirectionView): { key: string; values?: stri
29
31
  : { key: 'direction.authoredUnavailable' },
30
32
  ...(joined ? [{ key: 'direction.joined', values: [String(joined.postVersion), joined.projectModel.path,
31
33
  joined.packageRoot, joined.projectHash, joined.packageSourceHash] }] : []),
32
- { key: 'direction.runtimeCameraUnavailable' },
34
+ ...(model?.inspected&&view.scene?[{key:'direction.planes',values:[t(view.scene.plates.length===2?'direction.threePlanes':'direction.twoPlanes')]}]:[{ key: 'direction.runtimeCameraUnavailable' }]),
33
35
  { key: 'direction.cameraApplyUnavailable' },
34
36
  ];
35
37
  }
36
38
 
39
+ /** Summarize only authored fields bound to the model currently on stage. */
40
+ export function directionSummary(view: DirectionView, language?: 'en' | 'ko'): string {
41
+ const authored = view.model?.inspected ? view.authored : undefined;
42
+ if (!authored) return t('direction.title', undefined, language);
43
+ const first = authored.camera.keys[0]!.box;
44
+ const fixed = authored.camera.keys.every(({ box }) =>
45
+ box.x === first.x && box.y === first.y && box.width === first.width && box.height === first.height);
46
+ const post=authored.joined?.postVersion??authored.postVersion;
47
+ const version = post ? ` v${post}` : '';
48
+ return t('direction.summary', [version, String(authored.take.duration),
49
+ t(authored.take.loop ? 'direction.loop' : 'direction.once', undefined, language),
50
+ t(fixed ? 'direction.fixedCamera' : 'direction.movingCamera', undefined, language)], language);
51
+ }
52
+
37
53
  /** The adjacent viewport, reference picker and Turn Pad keep their normal input and rendering paths. */
38
54
  export function bindDirectionPanel(before: HTMLElement, read: () => DirectionView, set: (name: string) => void) {
39
55
  const host = document.createElement('details');
40
56
  host.id = 'direction-panel';
41
- host.open = true;
57
+ host.open = false;
42
58
  host.hidden = true;
43
59
  const title = document.createElement('summary');
44
60
  const body = document.createElement('div');
@@ -57,8 +73,8 @@ export function bindDirectionPanel(before: HTMLElement, read: () => DirectionVie
57
73
  function refresh() {
58
74
  if (host.hidden) return;
59
75
  const view = read();
60
- title.textContent = t('direction.title');
61
- const rows = directionRows(view).map(({ key, values }) => {
76
+ title.textContent = directionSummary(view);
77
+ const rows = [...directionRows(view),...(!view.scene&&view.authored?[{key:view.authored.scene?'direction.noScene':'direction.legacyTake'}]:[])].map(({ key, values }) => {
62
78
  const row = document.createElement('li');
63
79
  row.textContent = t(key, values);
64
80
  return row;
@@ -84,8 +100,8 @@ export function bindDirectionPanel(before: HTMLElement, read: () => DirectionVie
84
100
  if (view.model?.inspected && view.authored) {
85
101
  const { camera, timing, take } = view.authored;
86
102
  summary.textContent = t('direction.keys');
87
- keys.textContent = JSON.stringify({ camera, timing, take }, null, 2);
88
- details.hidden = false;
103
+ keys.textContent = directionSummary(view);
104
+ details.hidden = true;
89
105
  } else {
90
106
  details.hidden = true;
91
107
  keys.textContent = '';
@@ -28,6 +28,8 @@ export function restoreActiveBlocksUI(ui:DraftUI):ActiveBlocks {return parseActi
28
28
  export interface InspectorBlocksOptions {
29
29
  /** Sections carrying `data-inspector-panel`, each with a `.block-row` first child (or a child panel that has one). */
30
30
  sections:HTMLElement[];
31
+ /** Subject capabilities hide inapplicable existing tabs before binding keyboard navigation. */
32
+ available?:readonly string[];
31
33
  /** Called when a click or a key changes a section's active tab. */
32
34
  changed?:()=>void;
33
35
  /** The rig reuses its block rows in the heading, with one shared Comments tab. */
@@ -57,11 +59,12 @@ export function bindInspectorBlocks(options:InspectorBlocksOptions):InspectorBlo
57
59
  for(const button of row.querySelectorAll<HTMLButtonElement>('button[data-block-target]')){
58
60
  const id=button.dataset.blockTarget??'',panel=inside(id);if(!panel)continue;
59
61
  const included=(button.dataset.blockIncludes??'').split(' ').map(inside).filter((node):node is HTMLElement=>!!node);
62
+ if(options.available&&!options.available.includes(id)){button.hidden=true;button.disabled=true;panel.hidden=true;for(const node of included)node.toggleAttribute('data-block-hidden',true);continue;}
60
63
  tabs.push({button,id,panel,included});
61
64
  }
62
- if(!tabs.length)continue;
65
+ if(!tabs.length&&!options.bottom)continue;
63
66
  if(options.bottom){
64
- definitions.set(name,{section,row,scrollRoot,tabs});saved[name]=tabs.find(tab=>tab.button.getAttribute('aria-selected')==='true')?.id??tabs[0]!.id;
67
+ definitions.set(name,{section,row,scrollRoot,tabs});saved[name]=tabs.find(tab=>tab.button.getAttribute('aria-selected')==='true')?.id??tabs[0]?.id??'feedback';
65
68
  row.hidden=true;options.bottom.strip.append(row);continue;
66
69
  }
67
70
  ids.set(name,new Set(tabs.map(tab=>tab.id)));
@@ -152,7 +155,7 @@ export interface ActBarOptions {
152
155
  }
153
156
  /** C10 save state: one model for every screen. `text` and the retry label are English source text the caller owns. */
154
157
  export type ActSaveKind='saved'|'unsaved'|'saving'|'failed'|'read-only';
155
- export interface ActSaveState {kind:ActSaveKind;text:string;retry?:{label:string;run:()=>void}}
158
+ export interface ActSaveState {kind:ActSaveKind;text:string;retry?:{label:string;run:()=>void};/** Diagnostic hover (a refusal code and its origin), untranslated. */title?:string}
156
159
  export interface ActBar {element:HTMLElement;refresh():void;dispose():void;setSaveState(state:ActSaveState):void;saveState():ActSaveState|null}
157
160
  /** C10: screen-owned decision, submit and save state, with an optional shared action menu. */
158
161
  export function mountActBar(options:ActBarOptions):ActBar {
@@ -189,7 +192,8 @@ export function mountActBar(options:ActBarOptions):ActBar {
189
192
  let current:ActSaveState|null=null,retry:HTMLButtonElement|null=null;
190
193
  /** The one renderer: kind as data, the same text in the act node and its copies, a retry action only when failed. */
191
194
  const setSaveState=(state:ActSaveState)=>{
192
- current={...state};options.saveState.dataset.saveState=state.kind;setSourceText(options.saveState,state.text);
195
+ const titled=current?.title;current={...state};options.saveState.dataset.saveState=state.kind;setSourceText(options.saveState,state.text);
196
+ if(state.title)options.saveState.setAttribute('title',state.title);else if(titled)options.saveState.removeAttribute('title');
193
197
  for(const copy of options.saveStateCopies??[]){copy.node.dataset.saveState=state.kind;setSourceText(copy.node,state.text);if(copy.title)setSourceAttribute(copy.node,'title',state.text);}
194
198
  const action=state.kind==='failed'?state.retry:undefined;
195
199
  if(action&&!retry){retry=actionButton('',()=>{const run=current?.kind==='failed'?current.retry?.run:undefined;run?.();});retry.className='act-save-retry';options.saveState.after(retry);}
@@ -1,8 +1,10 @@
1
1
  import {CanvasRenderer, RigPlayer, type ModelAssets, type PosedFrame} from '@rig-c/play';
2
2
  import {assertOriginalPaintingSize} from '../src/parts-comparison.ts';
3
3
  import {jobStillByteLimit, type JobRigCapture, type JobUISubmission} from '../src/job-contract.ts';
4
+ import {cameraFrame} from './camera-view.ts';
5
+ import {partBounds} from './part-selection.ts';
4
6
  import type {ControlNumericCamera} from '../src/control.ts';
5
- import {presentJobRigViewport, type JobRigPresentation} from './viewport-capture.ts';
7
+ import {paintPosedViewport, presentJobRigViewport, type JobRigPresentation} from './viewport-capture.ts';
6
8
 
7
9
  type DrawSource = Pick<JobRigCapture['binding'], 'publicationId' | 'instanceKey' | 'sourceHash' | 'pageId'>;
8
10
  export interface JobRigDrawState {
@@ -155,8 +157,8 @@ export function recordJobRigDraw(state: JobRigDrawState, drawGeneration: number)
155
157
  /** copy() runs synchronously. The returned encoder owns an already copied bitmap. */
156
158
  export function freezeJobRigCapture(draw: JobRigDraw | undefined, state: JobRigDrawState, askId: string,
157
159
  copy: () => JobRigPixels): FrozenJobRigCapture {
158
- if (!state.defaultCamera) throw new Error('JOB_STILL_CAMERA_NOT_FIXED');
159
- if (!state.wholeRig || state.player.slots !== null) throw new Error('JOB_STILL_VIEW_UNSUPPORTED');
160
+ if (!state.defaultCamera) throw new Error('JOB_STILL_CAPTURE_FAILED');
161
+ if (!state.wholeRig) throw new Error('JOB_STILL_CAPTURE_FAILED');
160
162
  if (!draw || typeof state.player.entry !== 'function') throw new Error('JOB_STILL_CAPTURE_FAILED');
161
163
  if (draw.animation !== null && !draw.animation) throw new Error('JOB_STILL_CAPTURE_FAILED');
162
164
  if (!matchesDrawState(draw, state)) {
@@ -185,6 +187,62 @@ export function freezeJobRigCapture(draw: JobRigDraw | undefined, state: JobRigD
185
187
  }};
186
188
  }
187
189
 
190
+ /** Conservative PNG budget includes raw RGBA, row filters and deflate overhead. */
191
+ export function jobRigStillSize(requestedWidth:number,requestedHeight:number) {
192
+ if(![requestedWidth,requestedHeight].every(n=>Number.isFinite(n)&&n>0))throw new Error('JOB_STILL_CAPTURE_FAILED');
193
+ const scale=Math.min(1,16384/requestedWidth,16384/requestedHeight,
194
+ Math.sqrt((jobStillByteLimit-65536)/5/(requestedWidth*requestedHeight)));
195
+ return {width:Math.max(1,Math.floor(requestedWidth*scale)),height:Math.max(1,Math.floor(requestedHeight*scale)),scale};
196
+ }
197
+
198
+ /** Fixed whole-rig evidence from the held public pose; never mutates the inspection player or DOM. */
199
+ export function freezeJobRigStage(stage: Pick<JobRigStage, 'pane'|'player'|'playing'|'source'> &
200
+ {readonly assets:ModelAssets|null}, askId:string, drawGeneration:number):FrozenJobRigCapture {
201
+ const {player,assets}=stage;
202
+ if(!assets)throw new Error('JOB_STILL_CAPTURE_FAILED');
203
+ const posed=player.posedFrame(null),bounds=posed.order.map(row=>partBounds(posed,row.slot)).filter(box=>box!==null);
204
+ const declared=assets.stage;
205
+ if(declared&&declared.width>0&&declared.height>0)bounds.push(declared);
206
+ if(!bounds.length)throw new Error('JOB_STILL_CAPTURE_FAILED');
207
+ const x=Math.min(...bounds.map(b=>b.x)),y=Math.min(...bounds.map(b=>b.y));
208
+ const box={x,y,width:Math.max(...bounds.map(b=>b.x+b.width))-x,height:Math.max(...bounds.map(b=>b.y+b.height))-y};
209
+ const ratio=globalThis.devicePixelRatio||1;
210
+ const requestedWidth=Math.max(1,stage.pane.clientWidth||stage.pane.parentElement?.clientWidth||800)*ratio;
211
+ const requestedHeight=Math.max(1,stage.pane.clientHeight||stage.pane.parentElement?.clientHeight||800)*ratio;
212
+ // RGBA plus PNG scanline/deflate overhead fits the unchanged byte cap even for incompressible pixels.
213
+ const {width,height,scale}=jobRigStillSize(requestedWidth,requestedHeight);
214
+ const frame=cameraFrame('world',box,width,height,28*ratio*scale,58*ratio*scale);
215
+ if(!frame)throw new Error('JOB_STILL_CAPTURE_FAILED');
216
+ const visible={x:frame.center.x-width/frame.baseScale/2,y:frame.center.y-height/frame.baseScale/2,
217
+ width:width/frame.baseScale,height:height/frame.baseScale};
218
+ const camera:ControlNumericCamera={space:'world',center:frame.center,zoom:1,viewport:{width,height},visible};
219
+ const canvas=document.createElement('canvas');canvas.width=width;canvas.height=height;
220
+ const context=canvas.getContext('2d');if(!context)throw new Error('JOB_STILL_CAPTURE_FAILED');
221
+ const renderer=player.renderer;
222
+ const backend=renderer instanceof CanvasRenderer?renderer.backendActive:renderer.meshBackendActive;
223
+ const presentation={canvas,width,height,ratio:1,area:{x:0,y:0,width,height}};
224
+ const state:JobRigDrawState={player,presentation,frameGeneration:posed.generation,source:stage.source,
225
+ layout:JSON.stringify(camera),defaultCamera:true,wholeRig:true,playing:stage.playing};
226
+ const draw=recordJobRigDraw(state,drawGeneration);
227
+ return freezeJobRigCapture(draw,state,askId,()=>{
228
+ paintPosedViewport(context,posed,assets,camera,backend);
229
+ if(scale<1)console.info({evidenceStillScale:scale,width,height});
230
+ return encodeJobRigBitmap(canvas);
231
+ });
232
+ }
233
+
234
+ /** The owned bitmap is encoded after the synchronous pose and binding checks. */
235
+ function encodeJobRigBitmap(canvas:HTMLCanvasElement):JobRigPixels {
236
+ return {width:canvas.width,height:canvas.height,encode:()=>new Promise<string>((resolve,reject)=>{
237
+ canvas.toBlob(blob=>{
238
+ if(!blob||blob.size>jobStillByteLimit){reject(new Error('JOB_STILL_CAPTURE_FAILED'));return;}
239
+ const reader=new FileReader();
240
+ reader.onload=()=>typeof reader.result==='string'?resolve(reader.result):reject(new Error('JOB_STILL_CAPTURE_FAILED'));
241
+ reader.onerror=()=>reject(new Error('JOB_STILL_CAPTURE_FAILED'));reader.readAsDataURL(blob);
242
+ },'image/png');
243
+ })};
244
+ }
245
+
188
246
  /** One lossless bitmap-copy implementation for job evidence and standalone native rest inspection. */
189
247
  function copyRigBitmap(displayed: HTMLCanvasElement, width: number, height: number): HTMLCanvasElement {
190
248
  const canvas = document.createElement('canvas');
@@ -208,15 +266,7 @@ export function copyJobRigViewport(presentation: JobRigPresentation): JobRigPixe
208
266
  throw new Error('JOB_STILL_CAPTURE_FAILED');
209
267
  }
210
268
  const canvas = copyRigBitmap(displayed, width, height);
211
- return {width, height, encode: () => new Promise<string>((resolve, reject) => {
212
- canvas.toBlob(blob => {
213
- if (!blob || blob.size > jobStillByteLimit) {reject(new Error('JOB_STILL_CAPTURE_FAILED')); return;}
214
- const reader = new FileReader();
215
- reader.onload = () => typeof reader.result === 'string' ? resolve(reader.result) : reject(new Error('JOB_STILL_CAPTURE_FAILED'));
216
- reader.onerror = () => reject(new Error('JOB_STILL_CAPTURE_FAILED'));
217
- reader.readAsDataURL(blob);
218
- }, 'image/png');
219
- }).catch(() => {throw new Error('JOB_STILL_CAPTURE_FAILED');})};
269
+ return encodeJobRigBitmap(canvas);
220
270
  }
221
271
 
222
272
  /** Per-form first attempt, including human words and observed generation, survives a lost reply. */
@@ -1,4 +1,4 @@
1
- import {formFor, jobCheckpointContext, jobPublicationRoutes, prepareJobForms, prepareJobInspection, type JobForm, type JobFormDependencies, type JobPreparedInspection} from './job-session.ts';
1
+ import {formFor, jobCheckpointContext, jobPublicationRoutes, prepareJobForms, prepareJobInspection, jobSubmissionRefusal, type JobForm, type JobFormDependencies, type JobPreparedInspection} from './job-session.ts';
2
2
  import {commentPartsIssues,type PartsIssue} from '../src/parts-comment.ts';
3
3
  import type {PartsSubjectData} from './parts-viewport-provider.ts';
4
4
  /** Card I (#709): a rig publication of a live job opens the one review screen (`main.ts`) instead of the job
@@ -8,41 +8,57 @@ import type {ActV3, DisplayPublicationV3, JobResult, JobUISubmission, PendingAsk
8
8
  import type {Feedback, ReviewSession} from '../src/session.ts';
9
9
  import type {ReviewManifest, ReviewedSource} from '../src/manifest.ts';
10
10
  import {checkpointNoteComments, feedbackItemComments, projectComments} from '../src/stage-comment.ts';
11
- import {copyJobRigViewport, createJobRigSubmission, freezeJobRigCapture, jobRigDrawState, presentJobRigStage, recordJobRigDraw} from './job-rig-capture.ts';
11
+ import {createJobRigSubmission, freezeJobRigStage} from './job-rig-capture.ts';
12
12
  import {setRigHost, rigHost, type RigHost, type RigHostScreen, type RigHostCommit, type RigHostNavigation} from './rig-host.ts';
13
13
  import type {InstanceAccess} from './instance-access.ts';
14
14
 
15
- /** A model publication of a rig version or a package: not a draft, direction, image set or record. */
15
+ /** The shared screen hosts model packages and parts drafts; records have their own shared host seam. */
16
16
  export function jobRigScreenSubject(source: SourceV3): boolean {
17
- if ('record' in source || source.subject === 'image-set') return false;
17
+ if ('record' in source) return false;
18
18
  if(source.selector?.kind==='draft'&&source.parts)return true;
19
- return !!source.model && !source.direction && (source.selector === null || source.selector.kind === 'rig');
19
+ return !!source.model && (source.direction ? source.selector?.kind === 'post' : source.selector === null || source.selector.kind === 'rig');
20
20
  }
21
21
  /** The asks the rig screen's act bar answers: the rig verdict and checkpoints the package declares. */
22
22
  export function jobRigScreenAnswers(ask: Pick<PendingAskV3, 'subject'>, checkpoints: ReadonlySet<string>): boolean {
23
23
  const subject = ask.subject;
24
- return subject.kind === 'review-verdict' ? subject.stage === 'rig-review' :
24
+ return subject.kind === 'review-verdict' ? (subject.stage === 'rig-review' || subject.stage === 'direction-review') :
25
25
  subject.kind === 'checkpoint' && checkpoints.has(subject.checkpointId);
26
26
  }
27
+ /** One ask-availability check for both the route and its retained modal forms. */
28
+ export function jobRigScreenAsk(display:DisplayPublicationV3,ask:PendingAskV3,checkpoints:ReadonlySet<string>):boolean {
29
+ const source=display.publication.source;
30
+ if(ask.subject.kind==='checkpoint'){
31
+ try {prepareJobForms(display,[ask],()=>jobCheckpointContext(ask,[]));return true;}catch{return false;}
32
+ }
33
+ if(ask.subject.kind==='signoff'||ask.subject.kind==='interview-picks')return true;
34
+ if('record' in source)return ask.subject.kind==='reopen';
35
+ return !!source.model&&jobRigScreenAnswers(ask,checkpoints)&&
36
+ (ask.subject.kind!=='review-verdict'||ask.subject.stage===(source.direction?'direction-review':'rig-review'));
37
+ }
27
38
  export function jobRigScreenRoute(display: DisplayPublicationV3, pending: readonly PendingAskV3[],
28
39
  checkpoints: ReadonlySet<string>): boolean {
29
- const id = display.publication.publicationId;
30
- if('selector' in display.publication.source&&display.publication.source.selector?.kind==='draft'&&display.publication.source.parts)return true;
31
- return jobRigScreenSubject(display.publication.source) && pending.every(ask => {
32
- if (ask.publicationId !== id || ask.status !== 'pending') return true;
33
- if (ask.subject.kind === 'checkpoint') {
34
- try {
35
- prepareJobForms(display, [ask], () => jobCheckpointContext(ask, []));
36
- return true;
37
- } catch {return false;}
38
- }
39
- return jobRigScreenAnswers(ask, checkpoints) || ask.subject.kind === 'signoff' || ask.subject.kind === 'interview-picks';
40
- });
40
+ const source=display.publication.source,id=display.publication.publicationId;
41
+ if('record' in source)return false;
42
+ if(source.selector?.kind==='draft'&&source.parts)return true;
43
+ return (jobRigScreenSubject(source)||!source.model&&!source.parts)&&pending.every(ask=>
44
+ ask.publicationId!==id||ask.status!=='pending'||jobRigScreenAsk(display,ask,checkpoints));
45
+ }
46
+
47
+ /** Refusals describe missing producer inputs without granting a new act authority. */
48
+ export function jobRigScreenRefusal(display:DisplayPublicationV3,pending:readonly PendingAskV3[],checkpoints:ReadonlySet<string>,hasPicture=false):string|null {
49
+ const source=display.publication.source;
50
+ if('record' in source)return null;
51
+ {
52
+ if(source.selector?.kind==='post'&&!source.direction)return 'JOB_DIRECTION_MISSING';
53
+ if(source.selector?.kind==='draft'&&!source.parts)return 'JOB_PARTS_MISSING';
54
+ if(!source.model&&!source.parts&&!hasPicture&&!pending.some(ask=>ask.publicationId===display.publication.publicationId&&ask.status==='pending'&&ask.subject.kind!=='review-verdict'&&jobRigScreenAsk(display,ask,checkpoints)))return 'JOB_MODEL_MISSING';
55
+ }
56
+ return jobRigScreenRoute(display,pending,checkpoints)?null:'JOB_ASK_UNSUPPORTED';
41
57
  }
42
58
 
43
59
  export type JobRigScreenDecision =
44
60
  | {readonly ask: PendingAskV3; readonly kind: 'checkpoint'; readonly value: Extract<JobUISubmission, {kind: 'checkpoint'}>['value']}
45
- | {readonly ask: PendingAskV3; readonly kind: 'review-verdict'; readonly value: {stage: 'rig-review'; verdict: 'approved' | 'changes-requested'; words: string; feedback?: readonly Feedback[]}};
61
+ | {readonly ask: PendingAskV3; readonly kind: 'review-verdict'; readonly value: {stage: 'rig-review' | 'direction-review'; verdict: 'approved' | 'changes-requested'; words: string; feedback?: readonly Feedback[]}};
46
62
  /** The act bar's decisions as the pending asks' values. `words` is the comments' projection (act@6's), or empty;
47
63
  * a decision still pending is not sent, so a pending ask is never answered with "pending". Checkpoints go first. */
48
64
  export function jobRigScreenDecisions(session: Pick<ReviewSession, 'status' | 'checkpoints' | 'feedback'>,
@@ -57,18 +73,18 @@ export function jobRigScreenDecisions(session: Pick<ReviewSession, 'status' | 'c
57
73
  decisions.push({ask, kind: 'checkpoint', value: {checkpointId, outcome: entry.outcome,
58
74
  words: entry.note.trim() ? projectComments(checkpointNoteComments({checkpointId, planStepId, note: entry.note})) : ''}});
59
75
  }
60
- const verdict = open.find(ask => ask.subject.kind === 'review-verdict' && ask.subject.stage === 'rig-review');
61
- if (verdict && session.status !== 'pending') {
62
- decisions.push({ask: verdict, kind: 'review-verdict', value: {stage: 'rig-review', verdict: session.status,
76
+ const verdict = open.find(ask => ask.subject.kind === 'review-verdict' && (ask.subject.stage === 'rig-review' || ask.subject.stage === 'direction-review'));
77
+ if (verdict?.subject.kind === 'review-verdict' && verdict.subject.stage !== 'image-review' && session.status !== 'pending') {
78
+ decisions.push({ask: verdict, kind: 'review-verdict', value: {stage: verdict.subject.stage, verdict: session.status,
63
79
  words: session.feedback.length ? projectComments(feedbackItemComments(session.feedback)) : '',
64
- ...(session.feedback.length ? {feedback: structuredClone(session.feedback)} : {})}});
80
+ ...(verdict.subject.kind === 'review-verdict' && verdict.subject.stage === 'rig-review' && session.feedback.length ? {feedback: structuredClone(session.feedback)} : {})}});
65
81
  }
66
82
  return decisions;
67
83
  }
68
84
 
69
85
  interface ReviewJson {manifest: ReviewManifest; reviewedSource: ReviewedSource; sourceHash: string}
70
86
  export interface JobRigScreenPrepared {readonly jobRigScreen: true; readonly display: DisplayPublicationV3; readonly entry: string;
71
- readonly modals?: {inspection:JobPreparedInspection;forms:Map<string,JobForm>}; readonly review?: ReviewJson; readonly record?: {inspection:JobPreparedInspection;forms:Map<string,JobForm>;picture:JobRigScreenPrepared|null}; readonly parts?:PartsSubjectData; readonly checkpoints: ReadonlySet<string>}
87
+ readonly refusal?:string; readonly modals?: {inspection:JobPreparedInspection;forms:Map<string,JobForm>}; readonly review?: ReviewJson; readonly record?: {inspection:JobPreparedInspection;forms:Map<string,JobForm>;picture:JobRigScreenPrepared|null}; readonly parts?:PartsSubjectData; readonly checkpoints: ReadonlySet<string>}
72
88
  export function isJobRigScreen(value: unknown): value is JobRigScreenPrepared {
73
89
  return !!value && typeof value === 'object' && (value as {jobRigScreen?: unknown}).jobRigScreen === true;
74
90
  }
@@ -94,7 +110,7 @@ export function createJobRigScreen(options: {
94
110
  if(signal.aborted)throw new Error('JOB_PRELOAD_CANCELLED');
95
111
  const source = display.publication.source;
96
112
  if ('record' in source) {
97
- if (!options.formDependencies) throw new Error('JOB_PANEL_UNAVAILABLE');
113
+ if (!options.formDependencies) throw new Error('JOB_ACT_KIND_DISABLED');
98
114
  const inspection = await prepareJobInspection(display, signal);
99
115
  try {
100
116
  const forms = prepareJobForms(display, options.window.state().pending, ask => formFor(ask, inspection, options.formDependencies!));
@@ -120,7 +136,16 @@ export function createJobRigScreen(options: {
120
136
  return {jobRigScreen:true,display,entry:options.routes(display).entry,checkpoints:new Set(),record:{inspection,forms,picture}};
121
137
  } catch(error) {inspection.dispose();throw error;}
122
138
  }
123
- if (!jobRigScreenSubject(source) || source.subject === 'image-set') return null;
139
+ if (!jobRigScreenSubject(source)) {
140
+ if(!options.formDependencies)throw new Error('JOB_ACT_KIND_DISABLED');
141
+ const inspection=await prepareJobInspection(display,signal,true);
142
+ try {
143
+ const pending=options.window.state().pending,checkpoints=new Set(inspection.metadata.manifest?.checkpoints.map(item=>item.id)??[]);
144
+ const forms=prepareJobForms(display,pending.filter(ask=>ask.subject.kind!=='review-verdict'&&jobRigScreenAsk(display,ask,checkpoints)),ask=>formFor(ask,inspection,options.formDependencies!));
145
+ const picture:JobRigScreenPrepared|null=!source.model&&inspection.references.length?{jobRigScreen:true,display,entry:options.routes(display).entry,checkpoints,review:inspection.metadata as ReviewJson}:null;
146
+ return {jobRigScreen:true,display,entry:options.routes(display).entry,checkpoints,record:{inspection,forms,picture},refusal:jobRigScreenRefusal(display,pending,checkpoints,!!picture)??undefined};
147
+ }catch(error){inspection.dispose();throw error;}
148
+ }
124
149
  const routes = options.routes(display);
125
150
  const response = await fetch(routes.api('review'), {signal});
126
151
  if (!response.ok) throw new Error('JOB_VISUAL_UNAVAILABLE');
@@ -129,7 +154,7 @@ export function createJobRigScreen(options: {
129
154
  review.manifest.id !== source.package.id || review.manifest.revision !== source.package.revision ||
130
155
  (review.reviewedSource.rig?.sha256 ?? null) !== (source.model?.sha256 ?? null)) throw new Error('JOB_DISPLAY_MISMATCH');
131
156
  const checkpoints = new Set(review.manifest.checkpoints.map(item => item.id));
132
- if (!backdropOnly && !jobRigScreenRoute(display, options.window.state().pending, checkpoints)) return null;
157
+ const refusal=backdropOnly?null:jobRigScreenRefusal(display,options.window.state().pending,checkpoints);
133
158
  let parts:PartsSubjectData|undefined;
134
159
  if(source.selector?.kind==='draft'&&source.parts){
135
160
  const response=await fetch(routes.api('stage-parts'),{signal});if(!response.ok)throw new Error('JOB_VISUAL_UNAVAILABLE');
@@ -137,37 +162,31 @@ export function createJobRigScreen(options: {
137
162
  if(parts.sourceHash!==source.sourceHash||parts.mode!=='parts')throw new Error('JOB_DISPLAY_MISMATCH');
138
163
  }
139
164
  let modals:JobRigScreenPrepared['modals'];
140
- const asks=options.window.state().pending.filter(ask=>ask.publicationId===display.publication.publicationId&&ask.subject.kind!=='parts-verdict'&&!(ask.subject.kind==='review-verdict'&&ask.subject.stage==='rig-review'));
165
+ const asks=options.window.state().pending.filter(ask=>ask.publicationId===display.publication.publicationId&&ask.subject.kind!=='review-verdict'&&ask.subject.kind!=='parts-verdict'&&jobRigScreenAsk(display,ask,checkpoints));
141
166
  if(!backdropOnly&&options.formDependencies){
142
167
  const inspection=await prepareJobInspection(display,signal,true);
143
168
  try{modals={inspection,forms:prepareJobForms(display,asks,ask=>formFor(ask,inspection,options.formDependencies!))};}
144
169
  catch(error){inspection.dispose();throw error;}
145
170
  }
146
- return {jobRigScreen: true, display, entry: routes.entry, review, checkpoints,...parts?{parts}:{},...modals?{modals}:{}};
171
+ return {jobRigScreen: true, display, entry: routes.entry, review, checkpoints,...refusal?{refusal}:{},...parts?{parts}:{},...modals?{modals}:{}};
147
172
  }
148
173
  function still(ask: PendingAskV3, prepared: JobRigScreenPrepared) {
149
- screen?.redraw();
150
174
  const stage = screen?.stage();
151
175
  if (!stage) throw new Error('JOB_STILL_CAPTURE_FAILED');
152
176
  const publication = prepared.display.publication;
153
177
  const source = {pageId: options.pageId, publicationId: publication.publicationId, instanceKey: publication.instanceKey,
154
178
  sourceHash: publication.source.sourceHash};
155
- // The canonical pixels are on the pane only while the still is bound and copied, then the screen's own view returns.
156
- const presentation = presentJobRigStage(stage);
157
- try {
158
- presentation.canvas.style.position = 'absolute';
159
- presentation.canvas.style.pointerEvents = 'none';
160
- const bound = {...stage, source, presentation};
161
- const draw = recordJobRigDraw(jobRigDrawState(bound), ++drawGeneration);
162
- return freezeJobRigCapture(draw, jobRigDrawState(bound), ask.askId, () => copyJobRigViewport(presentation));
163
- } finally {presentation.canvas.remove();}
179
+ return freezeJobRigStage({...stage,source},ask.askId,++drawGeneration);
164
180
  }
165
- async function submit(session: ReviewSession, committed: (commit: RigHostCommit) => void | Promise<void>): Promise<string> {
181
+
182
+ async function submit(session: ReviewSession, committed: (commit: RigHostCommit) => void | Promise<void>, directionWords?:string): Promise<string> {
166
183
  const prepared = mounted, state = options.window.state();
167
184
  if (!prepared || !state.receipt || state.preparing) throw new Error('JOB_ACT_SOURCE_STALE');
168
185
  if (state.closed) throw new Error('JOB_CLOSED');
186
+ const refusal=jobRigScreenRefusal(prepared.display,state.pending,prepared.checkpoints);if(refusal)throw new Error(options.translate('job.refusal.'+refusal));
169
187
  if (!options.access.capability) throw new Error('JOB_CAPABILITY_REQUIRED');
170
- const decisions = jobRigScreenDecisions(session, state.pending.filter(ask=>!prepared.modals?.forms.has(ask.askId)), prepared.display.publication.publicationId);
188
+ const decisions=jobRigScreenDecisions(session, state.pending.filter(ask=>!prepared.modals?.forms.has(ask.askId)), prepared.display.publication.publicationId);
189
+ if(directionWords!==undefined)for(const decision of decisions)if(decision.kind==='review-verdict'&&decision.value.stage==='direction-review')decision.value.words=directionWords;
171
190
  if (!decisions.length) throw new Error('JOB_ACT_NOTHING_TO_SUBMIT');
172
191
  for (const decision of decisions) {
173
192
  const key = JSON.stringify(decision.value);
@@ -181,9 +200,9 @@ export function createJobRigScreen(options: {
181
200
  displayedNonce: latest.receipt.displayedNonce, expectedGeneration: latest.generation, submissionId: attempt.submissionId,
182
201
  value: decision.value} as JobUISubmission;
183
202
  const ask = decision.ask, current = attempt;
184
- const frozen = decision.kind === 'review-verdict' ? await current.rig.prepare(input, () => still(ask, prepared)) : input;
203
+ const frozen = decision.kind === 'review-verdict' && decision.value.stage === 'rig-review' ? await current.rig.prepare(input, () => still(ask, prepared)) : input;
185
204
  const result = await options.window.submit(frozen);
186
- if (!result.ok) throw new Error(result.error.code);
205
+ if (!result.ok) throw new Error(result.error.code, {cause: (result.error as {cause?: unknown}).cause});
187
206
  attempts.delete(ask.askId);
188
207
  await committed({...current.commit, at: result.value.at});
189
208
  }
@@ -215,7 +234,7 @@ export function createJobRigScreen(options: {
215
234
  return {...(backdrop?.subject?{subject:backdrop.subject}:{}),access:{...(backdrop?.access??access),capability:null,
216
235
  headers:init=>{const headers=options.access.headers(init);headers.delete('X-Review-Capability');return headers;}},
217
236
  ownerActAccess:{capability:options.access.capability},
218
- record:{label:prepared.display.publication.label,sourceHash:prepared.display.publication.source.sourceHash,hasPicture:!!record.picture},pendingSubjects,
237
+ record:{publicationId:prepared.display.publication.publicationId,label:prepared.display.publication.label,sourceHash:prepared.display.publication.source.sourceHash,hasPicture:!!record.picture},...prepared.refusal?{unavailable:prepared.refusal}:{},pendingSubjects,
219
238
  read:(path,method)=>method==='GET'&&backdrop?backdrop.read(path,method):Promise.reject(new Error('JOB_REVIEW_READ_ONLY')),
220
239
  submit:async()=>{throw new Error('JOB_REVIEW_READ_ONLY');},
221
240
  submitParts:async()=>{throw new Error('JOB_REVIEW_READ_ONLY');},
@@ -223,12 +242,12 @@ export function createJobRigScreen(options: {
223
242
  displayed:()=>ready.resolve(),failed:error=>ready.reject(error)};
224
243
  }
225
244
  if(!review)throw new Error('JOB_DISPLAY_MISMATCH');
226
- return {access,pendingSubjects,navigation,
245
+ return {access,pendingSubjects,navigation,...prepared.refusal?{unavailable:prepared.refusal}:{},...prepared.display.publication.source.direction?{direction:{publicationId:prepared.display.publication.publicationId,sourceHash:prepared.display.publication.source.sourceHash}}:{},
227
246
  reviewState(issues,sending) {
228
247
  if(sending)return options.translate('job.parts.sending');
229
248
  const kind=prepared.parts?'parts-verdict':'review-verdict';
230
249
  const ask=options.window.state().pending.filter(ask=>ask.publicationId===prepared.display.publication.publicationId&&
231
- ask.subject.kind===kind&&(ask.subject.kind!=='review-verdict'||ask.subject.stage==='rig-review')).at(-1);
250
+ ask.subject.kind===kind&&(ask.subject.kind!=='review-verdict'||(ask.subject.stage==='rig-review'||ask.subject.stage==='direction-review'))).at(-1);
232
251
  const act=ask?.status==='answered'?ask.act:undefined;
233
252
  const verdict=act?.kind===kind&&(act.kind==='parts-verdict'||act.kind==='review-verdict')?act.value.verdict:null;
234
253
  return verdict==='changes-requested'?options.translate('job.parts.sent'):verdict==='approved'?options.translate('job.review.approved'):
@@ -249,7 +268,7 @@ export function createJobRigScreen(options: {
249
268
  feedbackWarnings: [], updatedAt: null} satisfies ReviewSession);
250
269
  return Promise.reject(new Error('JOB_REVIEW_READ_ONLY'));
251
270
  },
252
- submit: (session, committed) => submit(session, committed).catch(error => {throw new Error(options.refusal(error, 'JOB_ACT_INVALID'));}),
271
+ submit,
253
272
  attach: value => {screen = value;screen.pendingSubjects?.(pendingSubjects());refreshRecordForms();},
254
273
  displayed: () => ready.resolve(),
255
274
  failed: error => ready.reject(error)};
@@ -258,7 +277,7 @@ export function createJobRigScreen(options: {
258
277
  function refreshRecordForms():void {
259
278
  const record=mounted?.record??mounted?.modals,deps=options.formDependencies;if(!record||!deps)return;
260
279
  const state=options.window.state(),display=record.inspection.display;
261
- const next=prepareJobForms(display,state.pending.filter(ask=>ask.subject.kind!=='parts-verdict'&&!(ask.subject.kind==='review-verdict'&&ask.subject.stage==='rig-review')),ask=>record.forms.get(ask.askId)??formFor(ask,record.inspection,deps));
280
+ const next=prepareJobForms(display,state.pending.filter(ask=>ask.subject.kind!=='parts-verdict'&&ask.subject.kind!=='review-verdict'&&jobRigScreenAsk(display,ask,mounted!.checkpoints)),ask=>record.forms.get(ask.askId)??formFor(ask,record.inspection,deps));
262
281
  for(const [id,entry]of next)record.forms.set(id,entry);
263
282
  for(const [id,entry]of record.forms){const ask=state.pending.find(ask=>ask.askId===id);entry.fieldset.disabled=entry.submitting||ask?.status!=='pending'||state.preparing||state.closed||!state.receipt||!options.access.capability;}
264
283
  screen?.recordForms?.([...record.forms.values()].map(entry=>entry.form));
@@ -266,7 +285,7 @@ export function createJobRigScreen(options: {
266
285
  return {
267
286
  prepare,
268
287
  mounted: () => mounted,
269
- report:(error:unknown,fallback?:string)=>screen?.message(options.refusal(error,fallback),true),
288
+ report:(error:unknown,fallback?:string)=>screen?.message(options.refusal(error,fallback),true,jobSubmissionRefusal(error).title),
270
289
  commit(prepared: JobRigScreenPrepared) {
271
290
  const previous=mounted;mounted=prepared;
272
291
  return {async rollback(){try{await transition?.rollback();}finally{transition=null;mounted=previous;}},finalize(){try{transition?.finalize();}finally{transition=null;if(previous!==prepared){const modal=previous?.record??previous?.modals;for(const entry of modal?.forms.values()??[])entry.dispose?.();modal?.inspection.dispose();}}}};
@@ -292,21 +311,22 @@ export function createJobRigScreen(options: {
292
311
  try {
293
312
  setRigHost(host(prepared, ready,navigation));
294
313
  const app = document.createElement('div');app.id = 'app';
295
- options.host.classList.remove('job-window');options.host.replaceChildren(app);document.body?.removeAttribute('data-ready');
314
+ options.host.replaceChildren(app);document.body?.removeAttribute('data-ready');
296
315
  const loaded=await options.load();
297
316
  if(loaded&&typeof loaded==='object')candidate=loaded as {dispose?():void};
298
317
  await shown;
299
318
  if (signal.aborted) throw new Error('JOB_PRELOAD_CANCELLED');
300
319
  }catch(error){await rollback();throw error;}
301
320
  },
302
- /** A newly pending ask the screen cannot answer, or a later publication, reloads into the job window's route. */
303
- changed(state: {readonly pending: readonly PendingAskV3[]; readonly closed: boolean; readonly preparing?:boolean; readonly error?:string|null; readonly previousLabel?:string|null; readonly displayed?:DisplayPublicationV3|null}): void {
321
+ /** Unsupported asks stay on the shared screen with a named explanation. */
322
+ changed(state: {readonly pending: readonly PendingAskV3[]; readonly closed: boolean; readonly preparing?:boolean; readonly error?:string|null; readonly errorOrigin?:string; readonly previousLabel?:string|null; readonly displayed?:DisplayPublicationV3|null}): void {
304
323
  if (!mounted) return;
305
- if(mounted.record){refreshRecordForms();if(state.closed)screen?.message(options.translate('job.closed'),true);return;}
306
- if (!jobRigScreenRoute(mounted.display, state.pending, mounted.checkpoints)) {location.reload(); return;}
324
+ if(mounted.record){refreshRecordForms();if(mounted.refusal){screen?.message(options.translate('job.refusal.'+mounted.refusal),true);const notice=document.getElementById('message');if(notice)notice.title=mounted.refusal;}if(state.closed)screen?.message(options.translate('job.closed'),true);return;}
325
+ const refusal=jobRigScreenRefusal(mounted.display,state.pending,mounted.checkpoints);
326
+ if(refusal){screen?.message(options.translate('job.refusal.'+refusal),true);const notice=document.getElementById('message');if(notice)notice.title=refusal;return;}
307
327
  screen?.pendingSubjects?.(pendingSubjects());
308
328
  refreshRecordForms();
309
- if(state.error)screen?.message(options.translate('job.failed')+' · '+options.refusal(state.error),true);
329
+ if(state.error)screen?.message(options.translate('job.failed')+' · '+options.refusal(state.error),true,jobSubmissionRefusal(new Error(state.error,{cause:state.errorOrigin})).title);
310
330
  else if (state.closed) screen?.message(options.translate('job.closed'), true);
311
331
  else if(!state.preparing&&state.displayed?.publication.publicationId===mounted.display.publication.publicationId){
312
332
  const label=state.previousLabel?options.translate('job.updated',[state.previousLabel,mounted.display.publication.label]):mounted.display.publication.label;