@rig-c/review 3.7.0 → 4.0.1
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/README.md +3 -3
- package/docs/DESIGN.md +145 -74
- package/docs/PANELS.md +20 -12
- package/docs/PARTS_VIEW.md +133 -76
- package/docs/REVIEW_PACKAGE.md +446 -100
- package/docs/STABILITY.md +132 -198
- package/docs/WORKFLOWS.md +41 -120
- package/package.json +4 -3
- package/skills/rig-review/SKILL.md +41 -27
- package/src/build.ts +10 -2
- package/src/cli.ts +17 -16
- package/src/comment-crops.ts +6 -1
- package/src/compare-html.ts +22 -24
- package/src/compare-server.ts +1 -1
- package/src/compare-session.ts +41 -3
- package/src/correction-handoff.ts +27 -4
- package/src/create-pin-gate.ts +3 -0
- package/src/direction-inspection.ts +6 -2
- package/src/feedback-export.ts +68 -1
- package/src/front.ts +5 -200
- package/src/handoff.ts +1 -1
- package/src/interview-routes.ts +1 -1
- package/src/interview-scene.ts +3 -3
- package/src/job-act.ts +77 -73
- package/src/job-api.ts +326 -13
- package/src/job-checkpoint-evidence.ts +113 -0
- package/src/job-cli.ts +27 -14
- package/src/job-contract.ts +284 -62
- package/src/job-front.ts +192 -61
- package/src/job-host.ts +23 -4
- package/src/job-session.ts +109 -24
- package/src/job-source.ts +227 -58
- package/src/job-store.ts +80 -6
- package/src/job-worker.ts +1 -47
- package/src/joined-project.ts +61 -4
- package/src/manifest.ts +32 -4
- package/src/open-workspace.ts +12 -12
- package/src/open.ts +19 -12
- package/src/parts-comment-crops.ts +126 -31
- package/src/parts-comment.ts +351 -28
- package/src/parts-server.ts +19 -7
- package/src/parts-view.ts +588 -109
- package/src/scene-inspection.ts +50 -0
- package/src/server.ts +31 -22
- package/src/session.ts +58 -0
- package/src/stage-comment.ts +48 -1
- package/src/stage-parts.ts +23 -11
- package/web/animation-inspection.ts +1 -1
- package/web/bones-panel.ts +1 -3
- package/web/catalog-en.ts +175 -39
- package/web/catalog-ko.ts +175 -39
- package/web/cloth-panel.ts +1 -2
- package/web/compare.css +3 -13
- package/web/compare.html +3 -3
- package/web/compare.ts +69 -64
- package/web/cuts-panel.ts +1 -3
- package/web/density-strip-panel.ts +1 -2
- package/web/direction-panel.ts +22 -6
- package/web/i18n.ts +13 -1
- package/web/idle-panel.ts +1 -2
- package/web/index.html +1 -5
- package/web/inspection-persistence.ts +2 -1
- package/web/inspector-blocks.ts +149 -40
- package/web/instance-access.ts +24 -5
- package/web/interview-panel.ts +224 -175
- package/web/job-rig-capture.ts +164 -21
- package/web/job-rig-screen.ts +344 -0
- package/web/job-session.ts +611 -1443
- package/web/main.ts +614 -151
- package/web/mesh-panel.ts +1 -2
- package/web/owner-workspace.ts +88 -109
- package/web/part-selection.ts +47 -6
- package/web/part-thumbnails.ts +20 -6
- package/web/parts-render.ts +26 -19
- package/web/parts-viewport-provider.ts +181 -7
- package/web/physics-panel.ts +1 -2
- package/web/readings-panel.ts +1 -2
- package/web/requirements-panel.ts +1 -3
- package/web/retained-frame-stage.ts +105 -0
- package/web/retarget-panel.ts +2 -3
- package/web/rig-fields-panel.ts +1 -2
- package/web/rig-host.ts +64 -0
- package/web/rig-viewport-provider.ts +65 -16
- package/web/scene-plates.ts +57 -4
- package/web/stage-comments.ts +103 -46
- package/web/styles.css +117 -63
- package/web/view-controls.ts +201 -12
- package/web/viewport-capture.ts +12 -2
- package/web/viewport-controller.ts +107 -27
- package/web/viewport-pair.ts +2 -1
- package/web/workspace-preferences.ts +5 -4
- package/web/workspace-ui.ts +151 -19
- package/src/front-worker.ts +0 -2
- package/src/interview-server.ts +0 -54
- package/src/job-hub.ts +0 -304
- package/src/job-image-set.ts +0 -50
- package/web/interview.css +0 -28
- package/web/interview.html +0 -17
- package/web/interview.ts +0 -40
- package/web/job-hub.css +0 -14
- package/web/job-hub.html +0 -5
- package/web/job-hub.ts +0 -179
- package/web/owner-workspace.css +0 -14
- package/web/owner-workspace.html +0 -5
- package/web/parts-flags.ts +0 -48
- package/web/parts.css +0 -104
- package/web/parts.html +0 -49
- package/web/parts.ts +0 -604
- package/web/stage-nav.ts +0 -136
package/web/interview-panel.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { HistoricalInterview, InterviewQuestion, InterviewDiagnostic } from '../src/interview-project.ts';
|
|
2
2
|
import type { Picks } from '../src/interview-picks.ts';
|
|
3
3
|
import { onLanguageChange, t } from './i18n.ts';
|
|
4
|
-
import
|
|
4
|
+
import { bindWorkspaceSeparator } from './workspace-layout.ts';
|
|
5
|
+
import { createViewControls } from './view-controls.ts';
|
|
6
|
+
import {WorkspacePreferenceStore,panelBounds} from './workspace-preferences.ts';
|
|
7
|
+
import { createPartsViewport } from './parts-viewport-provider.ts';
|
|
5
8
|
|
|
6
|
-
type
|
|
9
|
+
type Ask = InterviewQuestion['set']['asks'][number];
|
|
10
|
+
type Pick = Picks['picks'][number];
|
|
11
|
+
/** Element factory: the stage interview translates with `t`; the job page tags `data-job-text` for its own relocalize. */
|
|
12
|
+
export type InterviewText = <K extends keyof HTMLElementTagNameMap>(tag: K, key?: string) => HTMLElementTagNameMap[K];
|
|
7
13
|
export const interviewErrors: Readonly<Record<string,string>> = {
|
|
8
14
|
INTERVIEW_UNAVAILABLE:'INTERVIEW_UNAVAILABLE: No interview is attached to this inspection.',
|
|
9
15
|
INTERVIEW_SOURCE_MISMATCH:'interview.mismatch',
|
|
@@ -16,189 +22,232 @@ export const interviewErrors: Readonly<Record<string,string>> = {
|
|
|
16
22
|
INTERVIEW_OPTIONS_STALE:'interview.stale',
|
|
17
23
|
INTERVIEW_PICKS_OUTPUT:'interview.output',
|
|
18
24
|
};
|
|
19
|
-
function element<K extends keyof HTMLElementTagNameMap>(tag: K, content?: string): HTMLElementTagNameMap[K] {
|
|
20
|
-
const el = document.createElement(tag);
|
|
25
|
+
function element<K extends keyof HTMLElementTagNameMap>(tag: K, content?: string, factory?:InterviewText): HTMLElementTagNameMap[K] {
|
|
26
|
+
const el = factory?factory(tag):document.createElement(tag);
|
|
21
27
|
if (content !== undefined) el.textContent = content;
|
|
22
28
|
return el;
|
|
23
29
|
}
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
const translated: InterviewText = (tag, key) => element(tag, key === undefined ? undefined : t(key));
|
|
31
|
+
/** The `rig-review/interview-picks@1` record exactly as the stage interview has always posted it (key order is the file's bytes). */
|
|
32
|
+
export function interviewPicksRecord(ref: Picks['set'], picks: readonly Pick[], note: string | undefined, at: string): Picks {
|
|
33
|
+
return {schema:'rig-review/interview-picks@1', set:ref, picks:picks as Pick[], ...(note !== undefined ? {note} : {}), by:'user', at};
|
|
26
34
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
/** The job interview act value exactly as the job form has always submitted it. */
|
|
36
|
+
export function jobInterviewValue(questionId: string, asks: readonly Ask[], chosen: (ask: Ask) => {optionId: string; otherText: string},
|
|
37
|
+
note: string): {questionId: string; selections: {itemId: string; optionId: string; otherText: string | null}[]; note: string} {
|
|
38
|
+
return {questionId, selections:asks.map(ask => {
|
|
39
|
+
const {optionId, otherText} = chosen(ask);
|
|
40
|
+
return {itemId:ask.id, optionId, otherText:ask.options.find(option => option.id === optionId)?.kind === 'other' ? otherText : null};
|
|
41
|
+
}), note};
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
/** One prompt as radio cards: label, effect, AI recommended badge and reason, inline Other text and the pending line.
|
|
45
|
+
* Shared by the stage interview and the job interview; names let the job form keep its draft controls. */
|
|
46
|
+
export function interviewAskGroup(ask: Ask, options: {text?: InterviewText; name?: string; otherName?: string; pick?: Partial<Pick>;
|
|
47
|
+
pendingHidden?: boolean; onPick?: (pick: Pick) => void; onOther?: (text: string) => void}): {group: HTMLFieldSetElement; value(): {optionId: string; otherText: string}} {
|
|
48
|
+
const text = options.text ?? translated;
|
|
49
|
+
const make=<K extends keyof HTMLElementTagNameMap>(tag:K,content?:string)=>element(tag,content,options.text);
|
|
50
|
+
const group = make('fieldset');
|
|
51
|
+
group.className = 'interview-ask';
|
|
52
|
+
group.append(make('legend', ask.prompt));
|
|
53
|
+
const pick = options.pick;
|
|
54
|
+
const other = make('textarea');
|
|
55
|
+
if (options.otherName) other.name = options.otherName;
|
|
56
|
+
other.setAttribute('aria-label', t('interview.other'));
|
|
57
|
+
other.value = pick?.other_text ?? '';
|
|
58
|
+
const kind = ask.options.find(option => option.id === pick?.option_id)?.kind;
|
|
59
|
+
other.hidden = pick?.other_text === undefined && kind !== 'other';
|
|
60
|
+
other.required = kind === 'other';
|
|
61
|
+
other.oninput = () => options.onOther?.(other.value);
|
|
62
|
+
const pending = text('p', kind === 'other' ? 'interview.otherPending' : 'interview.autoPending');
|
|
63
|
+
pending.className = 'interview-pending';
|
|
64
|
+
pending.hidden = options.pendingHidden ?? !(kind === 'auto' || kind === 'other');
|
|
65
|
+
const radios = ask.options.map(option => {
|
|
66
|
+
const label = make('label'); label.className = 'interview-option';
|
|
67
|
+
const radio = make('input'); radio.type = 'radio'; radio.name = options.name ?? ask.id; radio.value = option.id;
|
|
68
|
+
radio.required = true; radio.checked = option.id === pick?.option_id;
|
|
69
|
+
radio.onchange = () => {
|
|
70
|
+
if (!radio.checked) return;
|
|
71
|
+
other.hidden = option.kind !== 'other';
|
|
72
|
+
other.required = option.kind === 'other';
|
|
73
|
+
pending.hidden = option.kind === 'value';
|
|
74
|
+
const key = option.kind === 'other' ? 'interview.otherPending' : 'interview.autoPending';
|
|
75
|
+
if (pending.dataset.jobText !== undefined) pending.dataset.jobText = key;
|
|
76
|
+
pending.textContent = t(key);
|
|
77
|
+
const next = {ask:ask.id, option_id:option.id};
|
|
78
|
+
options.onPick?.(option.kind === 'other' ? {...next, other_text:other.value} : next);
|
|
51
79
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (source) source.className = 'interview-binding';
|
|
59
|
-
const diagnostics = element('section');
|
|
60
|
-
diagnostics.className = 'interview-diagnostics';
|
|
61
|
-
diagnostics.setAttribute('role', 'status');
|
|
62
|
-
for (const diagnostic of data.diagnostics ?? []) {
|
|
63
|
-
const message = diagnostic.code === 'INTERVIEW_OPTIONS_STALE' ? 'interview.historicalIssue' : diagnostic.code;
|
|
64
|
-
diagnostics.append(element('p', t(message)),
|
|
65
|
-
element('code', [diagnostic.question, diagnostic.record, diagnostic.at, diagnostic.ref.path, diagnostic.ref.sha256].filter(Boolean).join(' · ')));
|
|
66
|
-
}
|
|
67
|
-
const archive = element('details');
|
|
68
|
-
archive.append(element('summary', t('interview.legacy')));
|
|
69
|
-
for (const answer of legacy) {
|
|
70
|
-
const item = element('section');
|
|
71
|
-
item.append(element('h3', answer.question), element('p', [answer.by,answer.at].filter(Boolean).join(' · ')),
|
|
72
|
-
element('pre', answer.verbatim));
|
|
73
|
-
if (answer.ref) item.append(element('code', answer.ref.path + ' · ' + answer.ref.sha256));
|
|
74
|
-
if (answer.answer) item.append(element('pre', [answer.answer.by, answer.answer.at, answer.answer.source].filter(value => typeof value === 'string').join(' · ')));
|
|
75
|
-
archive.append(item);
|
|
80
|
+
label.append(radio, make('strong', option.label), make('span', option.effect));
|
|
81
|
+
if(option.kind==='auto'){const badge=text('b','interview.delegate');badge.className='interview-delegate';label.append(badge);}
|
|
82
|
+
if (option.recommended) {
|
|
83
|
+
const badge = text('b', 'interview.recommended'); badge.className = 'interview-recommended';
|
|
84
|
+
label.dataset.recommended = '';
|
|
85
|
+
label.append(badge, make('span', option.reason));
|
|
76
86
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
const question = questions[selected]!;
|
|
85
|
-
const state = drafts[selected]!;
|
|
86
|
-
const picker = element('select');
|
|
87
|
-
picker.setAttribute('aria-label', t('interview.question'));
|
|
88
|
-
questions.forEach((item, index) => {
|
|
89
|
-
const entry = element('option', item.set.question + ' · ' + item.set.id + (item.editable ? '' : ' · ' + t('interview.history')));
|
|
90
|
-
entry.value = String(index); picker.append(entry);
|
|
91
|
-
});
|
|
92
|
-
picker.value = String(selected);
|
|
93
|
-
picker.disabled = busy;
|
|
94
|
-
picker.onchange = () => {selected = Number(picker.value); render();};
|
|
87
|
+
group.append(label);
|
|
88
|
+
return radio;
|
|
89
|
+
});
|
|
90
|
+
group.append(other, pending);
|
|
91
|
+
return {group, value:() => ({optionId:radios.find(radio => radio.checked)?.value ?? '', otherText:other.value})};
|
|
92
|
+
}
|
|
95
93
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
94
|
+
/** The modal's question list: "Answered n / total" and one button per question. */
|
|
95
|
+
export function interviewQuestionList(items: readonly {label: string; answered: boolean}[], selected: number,
|
|
96
|
+
onSelect: ((index: number) => void) | null, disabled = false, factory?:InterviewText): HTMLElement {
|
|
97
|
+
const make=<K extends keyof HTMLElementTagNameMap>(tag:K,content?:string)=>element(tag,content,factory);
|
|
98
|
+
const nav = make('nav');
|
|
99
|
+
nav.className = 'interview-questions';
|
|
100
|
+
nav.setAttribute('aria-label', t('interview.question'));
|
|
101
|
+
nav.append(make('p', t('interview.answered', [items.filter(item => item.answered).length, items.length])));
|
|
102
|
+
const list = make('ol');
|
|
103
|
+
items.forEach((item, index) => {
|
|
104
|
+
const row = make('li');
|
|
105
|
+
const button = make('button', item.label);
|
|
106
|
+
button.type = 'button';
|
|
107
|
+
button.className = 'interview-question';
|
|
108
|
+
if (item.answered) button.dataset.answered = '';
|
|
109
|
+
button.setAttribute('aria-current', String(index === selected));
|
|
110
|
+
button.disabled = disabled || !onSelect;
|
|
111
|
+
button.onclick = () => onSelect?.(index);
|
|
112
|
+
row.append(button); list.append(row);
|
|
113
|
+
});
|
|
114
|
+
nav.append(list);
|
|
115
|
+
return nav;
|
|
116
|
+
}
|
|
118
117
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
markUnsaved();
|
|
154
|
-
other.hidden = option.kind !== 'other';
|
|
155
|
-
other.required = option.kind === 'other';
|
|
156
|
-
pending.hidden = option.kind === 'value';
|
|
157
|
-
pending.textContent = t(option.kind === 'other' ? 'interview.otherPending' : 'interview.autoPending');
|
|
158
|
-
};
|
|
159
|
-
label.append(radio, element('strong', option.label), element('span', option.effect));
|
|
160
|
-
if (option.recommended) label.append(element('b', t('interview.recommended')), element('span', option.reason));
|
|
161
|
-
group.append(label);
|
|
162
|
-
}
|
|
163
|
-
const kind = ask.options.find(option => option.id === pick?.option_id)?.kind;
|
|
164
|
-
const autoResolved = !question.editable && Array.isArray((question.answer?.agent_decision as {fragments?:unknown}|undefined)?.fragments) &&
|
|
165
|
-
((question.answer!.agent_decision as {fragments:{ask:string}[]}).fragments).some(fragment => fragment.ask === ask.id);
|
|
166
|
-
const pending = element('p', t(kind === 'other' ? 'interview.otherPending' : 'interview.autoPending'));
|
|
167
|
-
pending.hidden = !(kind === 'auto' && !autoResolved || kind === 'other' && !(pick && 'other_fragment' in pick));
|
|
168
|
-
other.required = kind === 'other';
|
|
169
|
-
group.append(other, pending);
|
|
170
|
-
fields.append(group);
|
|
171
|
-
}
|
|
172
|
-
const noteLabel = element('label', t('interview.note'));
|
|
173
|
-
const note = element('textarea');
|
|
174
|
-
note.value = state.note ?? historical?.note ?? '';
|
|
175
|
-
note.oninput = () => {state.note = note.value; markUnsaved();};
|
|
176
|
-
noteLabel.append(note);
|
|
177
|
-
fields.append(noteLabel);
|
|
178
|
-
if (question.editable) {
|
|
179
|
-
const submit = element('button', t('interview.save')); submit.type = 'submit'; fields.append(submit);
|
|
118
|
+
/**
|
|
119
|
+
* The question's bound images in the shared native-image viewport (#708 return): the parts page's camera through
|
|
120
|
+
* createPartsViewport and the shared control set in its fixed order (Zoom in, Zoom out, Fit, 1:1, View switch), where the
|
|
121
|
+
* view switch picks the bound image. Control ids are dropped so the modal never shadows the page's own main view.
|
|
122
|
+
*/
|
|
123
|
+
export function interviewImageView(images: readonly {name: string; src: string}[], selected: number, onSelect: (index: number) => void, bottom?:HTMLElement) {
|
|
124
|
+
const image = images[selected]!;
|
|
125
|
+
const controls = createViewControls({layout:'rigStep1', viewSwitch:{currentMode:String(selected), groups:[{modes:images.map((asset, index) =>
|
|
126
|
+
({id:String(index), labelKey:asset.name, pressed:index === selected}))}], onChange:id => onSelect(Number(id))}});
|
|
127
|
+
const sync = controls.syncLabel.querySelector('input')!;
|
|
128
|
+
const named = new Map<string, HTMLElement>([['zoom-in', controls.zoomButtons[0]!], ['zoom-out', controls.zoomButtons[1]!],
|
|
129
|
+
['fit', controls.zoomButtons[2]!], ['native-one', controls.nativeOne!], ['zoom-value', controls.value], ['camera-sync', sync]]);
|
|
130
|
+
const toolbar = controls.zoomGroup!;
|
|
131
|
+
const viewport = element('div'); viewport.className = 'interview-viewport';
|
|
132
|
+
const root = element('div'); root.className = 'interview-view-root';
|
|
133
|
+
// A canvas starts at 300 x 150; the camera has no frame until the bound image has drawn.
|
|
134
|
+
const canvas = element('canvas'); root.append(canvas); viewport.append(root);
|
|
135
|
+
let loaded = false;
|
|
136
|
+
const reference = element('div'); reference.hidden = true;
|
|
137
|
+
for (const [id, node] of [['rig-viewport', viewport], ['rig-pane', viewport], ['stage-layout', viewport], ['rig-root', root],
|
|
138
|
+
['reference-viewport', reference], ['reference-pane', reference], ['reference-content', reference]] as const) named.set(id, node);
|
|
139
|
+
for (const node of [toolbar, ...toolbar.querySelectorAll('[id]'), sync]) node.removeAttribute('id');
|
|
140
|
+
const unavailable = element('p'); unavailable.setAttribute('role', 'status'); unavailable.hidden = true;
|
|
141
|
+
const view = element('div'); view.className = 'interview-view'; view.append(toolbar, viewport, unavailable);
|
|
142
|
+
const camera = createPartsViewport({el:<T extends HTMLElement>(id: string) => named.get(id) as T, canvas, message:() => {},
|
|
143
|
+
reference:() => null, frameSize:target => target === 'rig' && loaded ? {w:canvas.width, h:canvas.height} : null});
|
|
144
|
+
const localize = () => {
|
|
145
|
+
for (const button of toolbar.querySelectorAll<HTMLButtonElement>('[data-view]')) button.textContent = images[Number(button.dataset.view)]!.name;
|
|
146
|
+
const summary = toolbar.querySelector('.view-menu summary');
|
|
147
|
+
if (summary?.firstChild) summary.firstChild.textContent = t('View switch') + ' ';
|
|
148
|
+
summary?.setAttribute('aria-label', t('View layout'));
|
|
149
|
+
if (summary?.lastElementChild) summary.lastElementChild.textContent = image.name;
|
|
150
|
+
for (const [button, key] of [[controls.zoomButtons[0]!, 'Zoom in'], [controls.zoomButtons[1]!, 'Zoom out']] as const) {
|
|
151
|
+
button.textContent = t(key); button.setAttribute('aria-label', t(key));
|
|
180
152
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
153
|
+
unavailable.textContent = t('interview.imageUnavailable');
|
|
154
|
+
};
|
|
155
|
+
// Agent-authored part names stay verbatim; the controls' own words follow the shared catalogs.
|
|
156
|
+
const unlocalize = onLanguageChange(() => {camera.renderCameraControls(); localize();}); localize();
|
|
157
|
+
const disposers = [camera.bindControls(), camera.bindNavigation(), unlocalize];
|
|
158
|
+
controls.nativeOne!.onclick = () => camera.cameraAction(() => camera.updateCamera('rig', {zoom:1, pan:{x:0, y:0}}));
|
|
159
|
+
let fitted = false;
|
|
160
|
+
const fit = () => {if (!fitted && loaded && camera.paneFrame('rig')) {fitted = true; camera.fitActiveCamera('rig');} else camera.fitCamera();};
|
|
161
|
+
const resize = new ResizeObserver(fit); resize.observe(viewport);
|
|
162
|
+
if(bottom){
|
|
163
|
+
const preferences=new WorkspacePreferenceStore();let height:number=panelBounds.inspectorHeight.min;
|
|
164
|
+
const separator=element('div');separator.className='workspace-separator interview-bottom-resize';
|
|
165
|
+
view.append(separator,bottom);
|
|
166
|
+
const range=()=>({min:panelBounds.inspectorHeight.min,max:Math.max(panelBounds.inspectorHeight.min,view.clientHeight-200),value:bottom.getBoundingClientRect().height,enabled:true});
|
|
167
|
+
const apply=(value:number)=>{height=value;view.style.setProperty('--interview-answer-height',Math.min(range().max,Math.max(range().min,value))+'px');};
|
|
168
|
+
const binding=bindWorkspaceSeparator({element:separator,panel:'inspectorHeight',controls:bottom.id,label:t('Resize Inspector'),range,desired:()=>height,resize:apply,commit:value=>preferences.update({panels:{inspectorHeight:value}})});
|
|
169
|
+
const observer=new ResizeObserver(()=>{apply(height);binding.refresh();});observer.observe(view);
|
|
170
|
+
disposers.push(()=>{observer.disconnect();binding.dispose();});apply(height);
|
|
171
|
+
}
|
|
172
|
+
const source = new Image();
|
|
173
|
+
source.onload = () => {
|
|
174
|
+
canvas.width = source.naturalWidth; canvas.height = source.naturalHeight; loaded = true;
|
|
175
|
+
canvas.getContext('2d')?.drawImage(source, 0, 0); fit();
|
|
176
|
+
};
|
|
177
|
+
source.onerror = () => {viewport.hidden = true; unavailable.hidden = false;};
|
|
178
|
+
source.alt = image.name; source.src = image.src;
|
|
179
|
+
return {element:view, dispose() {source.onload=source.onerror=null;source.src='';resize.disconnect(); for (const dispose of disposers) dispose();}};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Real interview API rows shared by job publications and joined project inspection. */
|
|
183
|
+
export type InterviewDisplayQuestion = Omit<InterviewQuestion,'images'> & {images:{name:string;url:string}[];saved?:Picks|null};
|
|
184
|
+
|
|
185
|
+
/** Read-only diagnostics and verbatim historical records, independent of submission transport. */
|
|
186
|
+
export function interviewRecords(diagnostics:readonly InterviewDiagnostic[]=[],historical:readonly HistoricalInterview[]=[],factory?:InterviewText):HTMLElement {
|
|
187
|
+
const make=<K extends keyof HTMLElementTagNameMap>(tag:K,content?:string)=>element(tag,content,factory);
|
|
188
|
+
const records=make('div');records.className='interview-records';
|
|
189
|
+
const notices=make('section');notices.className='interview-diagnostics';notices.setAttribute('role','status');
|
|
190
|
+
for(const diagnostic of diagnostics){
|
|
191
|
+
notices.append(make('p',t(diagnostic.code==='INTERVIEW_OPTIONS_STALE'?'interview.historicalIssue':diagnostic.code)),
|
|
192
|
+
make('code',[diagnostic.question,diagnostic.record,diagnostic.at,diagnostic.ref.path,diagnostic.ref.sha256].filter(Boolean).join(' · ')));
|
|
193
|
+
}
|
|
194
|
+
records.append(notices);
|
|
195
|
+
if(historical.length){
|
|
196
|
+
const archive=make('details');archive.append(make('summary',t('interview.legacy')));
|
|
197
|
+
for(const answer of historical){const row=make('section');row.append(make('h3',answer.question),make('p',[answer.by,answer.at].filter(Boolean).join(' · ')),make('pre',answer.verbatim));if(answer.ref)row.append(make('code',answer.ref.path+' · '+answer.ref.sha256));if(answer.answer)row.append(make('pre',[answer.answer.by,answer.answer.at,answer.answer.source].filter(value=>typeof value==='string').join(' · ')));archive.append(row);}
|
|
198
|
+
records.append(archive);
|
|
199
|
+
}
|
|
200
|
+
return records;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** B's list | image | survey builder. Hosts supply genuine source data and their own submit transport. */
|
|
204
|
+
export function createInterviewForm(options:{question:InterviewDisplayQuestion;id:string;node?:InterviewText;form?:HTMLFormElement;fieldset?:HTMLFieldSetElement;source?:HTMLElement;
|
|
205
|
+
images:readonly {name:string;src:string}[];questions?:readonly {label:string;answered:boolean}[]|(()=>readonly {label:string;answered:boolean}[]);selected?:number;onSelect?:(index:number)=>void;answered?:boolean;
|
|
206
|
+
diagnostics?:readonly InterviewDiagnostic[];historical?:readonly HistoricalInterview[]}) {
|
|
207
|
+
const question=options.question,copy=new Map<HTMLElement,string>();
|
|
208
|
+
const make=<K extends keyof HTMLElementTagNameMap>(tag:K,content?:string)=>element(tag,content,options.node);
|
|
209
|
+
const node:InterviewText=(tag,key)=>{const result=options.node?options.node(tag,key):element(tag,key===undefined?undefined:t(key));if(key!==undefined)copy.set(result,key);return result;};
|
|
210
|
+
const form=options.form??make('form'),fields=options.fieldset??make('fieldset');
|
|
211
|
+
if(!options.fieldset)form.append(fields);
|
|
212
|
+
form.className='interview-answer interview-grid';form.dataset.interviewAnswered=String(options.answered??Boolean(question.saved||question.answer));
|
|
213
|
+
fields.className='interview-answer-fields';fields.id=options.id;fields.disabled=!question.editable;
|
|
214
|
+
const heading=make('h3',question.set.question);fields.append(heading);
|
|
215
|
+
const historical=question.answer?.choice as {picks?:Picks['picks'];note?:string}|undefined;
|
|
216
|
+
const retainedNote=question.saved?.note??historical?.note;
|
|
217
|
+
const answers=question.set.asks.map(item=>{
|
|
218
|
+
const pick=question.saved?.picks.find(value=>value.ask===item.id)??historical?.picks?.find(value=>value.ask===item.id);
|
|
219
|
+
const kind=item.options.find(option=>option.id===pick?.option_id)?.kind;
|
|
220
|
+
const fragments=(question.answer?.agent_decision as {fragments?:unknown}|undefined)?.fragments;
|
|
221
|
+
const autoResolved=!question.editable&&Array.isArray(fragments)&&fragments.some(fragment=>fragment?.ask===item.id);
|
|
222
|
+
const pendingHidden=!(kind==='auto'&&!autoResolved||kind==='other'&&!(pick&&'other_fragment' in pick));
|
|
223
|
+
const answer=interviewAskGroup(item,{text:node,name:'choice.'+item.id,otherName:'other.'+item.id,pick,pendingHidden});
|
|
224
|
+
fields.append(answer.group);return {item,answer};
|
|
225
|
+
});
|
|
226
|
+
if(retainedNote!==undefined){const note=make('pre',retainedNote);note.className='interview-note';fields.append(note);}
|
|
227
|
+
const context=make('div');context.id=options.id+'-source';context.className='interview-image-context';
|
|
228
|
+
if(options.source)context.append(options.source);
|
|
229
|
+
context.append(node('h2',question.hasParts?'interview.parts':'interview.source'));
|
|
230
|
+
if(!question.hasParts)context.append(node('p','interview.noParts'));
|
|
231
|
+
if(question.partsUnavailable)context.append(node('p','interview.partsUnavailable'));
|
|
232
|
+
const provenance=make('p'),binding=make('code',question.ref.path+' · '+question.ref.sha256);context.append(provenance,binding);
|
|
233
|
+
if(question.answer)context.append(make('pre',[question.answer.by,question.answer.at,question.answer.source].filter(value=>typeof value==='string').join(' · ')),make('pre',typeof question.answer.verbatim==='string'?question.answer.verbatim:''));
|
|
234
|
+
const art=make('aside');art.className='interview-art';form.prepend(art);
|
|
235
|
+
let view:ReturnType<typeof interviewImageView>|undefined,list:HTMLElement|undefined,records:HTMLElement|undefined;
|
|
236
|
+
const showImage=(index:number)=>{view?.dispose();view?.element.remove();view=interviewImageView(options.images,index,showImage,context);art.append(view.element);};
|
|
237
|
+
const refresh=()=>{
|
|
238
|
+
provenance.textContent=t('interview.provenance',[question.set.drafted_by,question.set.drafted_at]);
|
|
239
|
+
const questions=typeof options.questions==='function'?options.questions():options.questions;
|
|
240
|
+
const items=questions?.map((item,index)=>({...item,answered:index===(options.selected??0)?form.dataset.interviewAnswered==='true':item.answered}))??[{label:question.set.question+' · '+question.set.id,answered:form.dataset.interviewAnswered==='true'}];
|
|
241
|
+
const next=interviewQuestionList(items,options.selected??0,options.onSelect??(()=>{}),false,options.node);list?.remove();form.prepend(next);list=next;
|
|
242
|
+
records?.remove();records=interviewRecords(options.diagnostics,options.historical,options.node);context.append(records);
|
|
202
243
|
};
|
|
203
|
-
const
|
|
244
|
+
const submit=node('button','interview.save');submit.type='submit';submit.hidden=!question.editable;fields.append(submit);
|
|
245
|
+
const status=node('p',!question.editable?'interview.history':question.saved?'interview.saved':'interview.choose');status.setAttribute('role','status');form.append(status);
|
|
246
|
+
const localize=()=>{for(const [item,key]of copy)item.textContent=t(item.dataset.jobText??key);refresh();};
|
|
247
|
+
const dispose=()=>{view?.dispose();form.removeEventListener('input',refresh);form.removeEventListener('change',refresh);form.removeEventListener('job-form-language',localize);};
|
|
248
|
+
form.addEventListener('input',refresh);form.addEventListener('change',refresh);form.addEventListener('job-form-language',localize);
|
|
249
|
+
try{if(options.images.length)showImage(0);else art.append(context);refresh();}catch(error){dispose();throw error;}
|
|
250
|
+
return {form,fieldset:fields,submit,status,retainedNote,
|
|
251
|
+
read:()=>jobInterviewValue(question.set.question,question.set.asks,item=>answers.find(answer=>answer.item===item)!.answer.value(),retainedNote??''),
|
|
252
|
+
localize,dispose};
|
|
204
253
|
}
|