@floless/app 0.137.4 → 0.138.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/dist/floless-server.cjs +48371 -27278
- package/dist/internal-workflows/floless-rfi-gmail-send/.floless-owner.json +1 -0
- package/dist/internal-workflows/floless-rfi-gmail-send/floless-rfi-gmail-send.flo +32 -0
- package/dist/schemas/steel.model.v2.schema.json +218 -27
- package/dist/skills/floless-app-knowledge/SKILL.md +5 -2
- package/dist/skills/floless-app-rfi/SKILL.md +410 -0
- package/dist/skills/floless-app-routines/SKILL.md +7 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -5
- package/dist/skills/floless-app-steel-model/SKILL.md +34 -32
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +498 -34
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +6 -6
- package/dist/skills/floless-app-tweak-contract/SKILL.md +6 -2
- package/dist/templates/floless-workspace-knowledge.flo +20 -4
- package/dist/templates/steel-model.flo +27 -15
- package/dist/web/app.css +559 -131
- package/dist/web/app.js +216 -54
- package/dist/web/aware.js +982 -128
- package/dist/web/checkpoint-standard.js +218 -0
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +237 -5
- package/dist/web/commands-steel.js +172 -47
- package/dist/web/connection-review-client.js +2 -2
- package/dist/web/display-units.js +243 -0
- package/dist/web/grid-core.js +470 -56
- package/dist/web/grid-display.js +344 -0
- package/dist/web/index.html +106 -66
- package/dist/web/instructor-reporter.js +5 -0
- package/dist/web/instructor.js +175 -33
- package/dist/web/json-schema-subset.js +145 -25
- package/dist/web/steel-3d-core.js +124 -140
- package/dist/web/steel-3d-view.js +352 -100
- package/dist/web/steel-catalog-picker.js +98 -15
- package/dist/web/steel-detail-refs.js +1 -1
- package/dist/web/steel-editor.html +6458 -915
- package/dist/web/steel-filter.html +404 -57
- package/dist/web/steel-model-adapter.js +1 -1
- package/dist/web/steel-model-commands.js +71 -64
- package/dist/web/steel-model-v2-client-validation.js +10 -3
- package/dist/web/steel-model-v2-commands.js +268 -76
- package/dist/web/steel-model-v2-projection.js +18 -17
- package/dist/web/steel-plan-transform.js +13 -13
- package/dist/web/steel-plan-view-id.js +1 -7
- package/dist/web/steel-read-confidence.js +454 -5
- package/dist/web/steel-units.js +17 -3
- package/dist/web/steel-view-generation.js +21 -7
- package/dist/web/workspaces.js +2178 -497
- package/package.json +4 -1
package/dist/web/workspaces.js
CHANGED
|
@@ -15,7 +15,11 @@
|
|
|
15
15
|
const bridge = window.flolessBridge || {};
|
|
16
16
|
const api = bridge.api || (async (path, opts) => {
|
|
17
17
|
const res = await fetch(path, { headers: { 'content-type': 'application/json' }, ...opts });
|
|
18
|
-
const body = await res.json().catch(() => ({
|
|
18
|
+
const body = await res.json().catch(() => ({
|
|
19
|
+
ok: false,
|
|
20
|
+
code: 'response-unreadable',
|
|
21
|
+
error: `FloLess received an unreadable response (HTTP ${res.status}).`,
|
|
22
|
+
}));
|
|
19
23
|
if (!res.ok || body.ok === false) { const e = new Error(body.error || `HTTP ${res.status}`); e.body = body; throw e; }
|
|
20
24
|
return body;
|
|
21
25
|
});
|
|
@@ -23,6 +27,245 @@
|
|
|
23
27
|
// itself already swallows errors, but guard the lookup too so a missing global never throws.
|
|
24
28
|
const track = (name, props) => { try { if (window.trackEvent) window.trackEvent(name, props || {}); } catch { /* analytics never breaks UX */ } };
|
|
25
29
|
|
|
30
|
+
// ── RFI transfer result trust boundary ───────────────────────────────────────────────────────
|
|
31
|
+
// This deliberately mirrors server/rfi-transfer.ts rather than trusting an HTTP-200-shaped
|
|
32
|
+
// object. Import and Duplicate are partial-success operations: classic browser JavaScript must
|
|
33
|
+
// never turn a missing key, a future discriminator, or impossible arithmetic into an ordinary
|
|
34
|
+
// green success toast.
|
|
35
|
+
const RFI_RECORD_OMISSION_REASONS = [
|
|
36
|
+
'version-unavailable', 'subjects-exhausted', 'targets-exhausted', 'duplicate-gap',
|
|
37
|
+
];
|
|
38
|
+
const RFI_SUBJECT_OMISSION_REASONS = ['model-member-missing', 'model-joint-missing'];
|
|
39
|
+
const RFI_TARGET_OMISSION_REASONS = [
|
|
40
|
+
'model-member-missing', 'model-joint-missing',
|
|
41
|
+
'drawing-source-missing', 'drawing-source-ambiguous', 'drawing-source-corrupt',
|
|
42
|
+
'drawing-extension-mismatch', 'drawing-source-unreadable',
|
|
43
|
+
'drawing-page-missing', 'drawing-page-identity-mismatch', 'drawing-region-invalid',
|
|
44
|
+
];
|
|
45
|
+
const RFI_INSPECTION_LIMITS = {
|
|
46
|
+
uniqueSources: 16,
|
|
47
|
+
claimedPages: 2000,
|
|
48
|
+
inspectedBytes: 256 * 1024 * 1024,
|
|
49
|
+
subprocesses: 16,
|
|
50
|
+
uniqueVersions: 512,
|
|
51
|
+
snapshotBytes: 64 * 1024 * 1024,
|
|
52
|
+
objectCount: 4096,
|
|
53
|
+
objectBytes: 256 * 1024 * 1024,
|
|
54
|
+
elapsedMs: 60000,
|
|
55
|
+
};
|
|
56
|
+
const RFI_INSPECTION_KEYS = Object.keys(RFI_INSPECTION_LIMITS);
|
|
57
|
+
const RFI_COMMON_FAILURE_KEYS = [
|
|
58
|
+
'outcome', 'operationId', 'stage', 'reason', 'sourceRecords', 'carried',
|
|
59
|
+
'recordsOmitted', 'subjectsOmitted', 'targetsOmitted', 'reasons', 'candidate', 'inspection',
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
function rfiWireObject(value) {
|
|
63
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function rfiWireCount(value) {
|
|
67
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function rfiWireExact(value, keys) {
|
|
71
|
+
if (!rfiWireObject(value)) return false;
|
|
72
|
+
const actual = Object.keys(value).sort();
|
|
73
|
+
const expected = [...keys].sort();
|
|
74
|
+
return actual.length === expected.length && actual.every((key, index) => key === expected[index]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function rfiWireHistogram(value, keys) {
|
|
78
|
+
return rfiWireExact(value, keys) && keys.every((key) => rfiWireCount(value[key]));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function rfiWireReasons(value) {
|
|
82
|
+
return rfiWireExact(value, ['records', 'subjects', 'targets'])
|
|
83
|
+
&& rfiWireHistogram(value.records, RFI_RECORD_OMISSION_REASONS)
|
|
84
|
+
&& rfiWireHistogram(value.subjects, RFI_SUBJECT_OMISSION_REASONS)
|
|
85
|
+
&& rfiWireHistogram(value.targets, RFI_TARGET_OMISSION_REASONS);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function rfiWireSum(value) {
|
|
89
|
+
return Object.values(value).reduce((total, count) => total + count, 0);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function rfiWireInspection(value) {
|
|
93
|
+
return rfiWireExact(value, RFI_INSPECTION_KEYS)
|
|
94
|
+
&& RFI_INSPECTION_KEYS.every((key) => rfiWireCount(value[key]) && value[key] <= RFI_INSPECTION_LIMITS[key]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function rfiWireCandidate(value) {
|
|
98
|
+
if (!rfiWireExact(value, [
|
|
99
|
+
'sourceRecords', 'candidateRecords', 'recordsOmitted', 'subjectsOmitted', 'targetsOmitted', 'reasons',
|
|
100
|
+
]) || !rfiWireReasons(value.reasons)) return false;
|
|
101
|
+
if (!rfiWireCount(value.sourceRecords) || !rfiWireCount(value.candidateRecords)
|
|
102
|
+
|| !rfiWireCount(value.recordsOmitted) || !rfiWireCount(value.subjectsOmitted)
|
|
103
|
+
|| !rfiWireCount(value.targetsOmitted)) return false;
|
|
104
|
+
return value.sourceRecords === value.candidateRecords + value.recordsOmitted
|
|
105
|
+
&& rfiWireSum(value.reasons.records) === value.recordsOmitted
|
|
106
|
+
&& rfiWireSum(value.reasons.subjects) === value.subjectsOmitted
|
|
107
|
+
&& rfiWireSum(value.reasons.targets) === value.targetsOmitted;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Parse the closed server union or throw. Never return a best-effort partial interpretation. */
|
|
111
|
+
function parseRfiTransferResult(value) {
|
|
112
|
+
const reject = () => { throw new TypeError('invalid RFI transfer result'); };
|
|
113
|
+
if (!rfiWireObject(value)
|
|
114
|
+
|| typeof value.operationId !== 'string'
|
|
115
|
+
|| !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value.operationId)
|
|
116
|
+
|| !rfiWireInspection(value.inspection)) reject();
|
|
117
|
+
|
|
118
|
+
if (['none-present', 'complete', 'partial'].includes(value.outcome)) {
|
|
119
|
+
if (!rfiWireExact(value, [
|
|
120
|
+
'outcome', 'operationId', 'inspection', 'sourceRecords', 'carried',
|
|
121
|
+
'recordsOmitted', 'subjectsOmitted', 'targetsOmitted', 'reasons',
|
|
122
|
+
]) || !rfiWireReasons(value.reasons)
|
|
123
|
+
|| !rfiWireCount(value.sourceRecords) || !rfiWireCount(value.carried)
|
|
124
|
+
|| !rfiWireCount(value.recordsOmitted) || !rfiWireCount(value.subjectsOmitted)
|
|
125
|
+
|| !rfiWireCount(value.targetsOmitted)
|
|
126
|
+
|| value.sourceRecords !== value.carried + value.recordsOmitted
|
|
127
|
+
|| rfiWireSum(value.reasons.records) !== value.recordsOmitted
|
|
128
|
+
|| rfiWireSum(value.reasons.subjects) !== value.subjectsOmitted
|
|
129
|
+
|| rfiWireSum(value.reasons.targets) !== value.targetsOmitted) reject();
|
|
130
|
+
if (value.outcome === 'none-present' && (value.sourceRecords !== 0 || value.carried !== 0
|
|
131
|
+
|| value.recordsOmitted !== 0 || value.subjectsOmitted !== 0 || value.targetsOmitted !== 0)) reject();
|
|
132
|
+
if (value.outcome === 'complete' && (value.carried === 0 || value.recordsOmitted !== 0
|
|
133
|
+
|| value.subjectsOmitted !== 0 || value.targetsOmitted !== 0)) reject();
|
|
134
|
+
if (value.outcome === 'partial' && (value.sourceRecords === 0
|
|
135
|
+
|| (value.recordsOmitted === 0 && value.subjectsOmitted === 0 && value.targetsOmitted === 0))) reject();
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (value.outcome === 'conflict') {
|
|
140
|
+
if (!rfiWireExact(value, [
|
|
141
|
+
'outcome', 'operationId', 'reason', 'sourceRecords', 'carried', 'recordsOmitted',
|
|
142
|
+
'subjectsOmitted', 'targetsOmitted', 'reasons', 'candidate', 'inspection',
|
|
143
|
+
]) || value.reason !== 'destination-occupied' || value.carried !== 0
|
|
144
|
+
|| value.recordsOmitted !== null || value.subjectsOmitted !== null
|
|
145
|
+
|| value.targetsOmitted !== null || value.reasons !== null
|
|
146
|
+
|| (value.sourceRecords !== null && !rfiWireCount(value.sourceRecords))
|
|
147
|
+
|| (value.candidate !== null && (!rfiWireCandidate(value.candidate)
|
|
148
|
+
|| value.candidate.sourceRecords !== value.sourceRecords))) reject();
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (!rfiWireExact(value, RFI_COMMON_FAILURE_KEYS) || value.carried !== 0
|
|
153
|
+
|| value.recordsOmitted !== null || value.subjectsOmitted !== null
|
|
154
|
+
|| value.targetsOmitted !== null || value.reasons !== null) reject();
|
|
155
|
+
if (value.outcome === 'refused' && value.stage === 'input'
|
|
156
|
+
&& value.sourceRecords === null && value.candidate === null
|
|
157
|
+
&& ['unreadable-input', 'too-large', 'source-store-unavailable', 'source-store-quarantined'].includes(value.reason)) return value;
|
|
158
|
+
if (value.outcome === 'refused' && value.stage === 'corroboration'
|
|
159
|
+
&& rfiWireCount(value.sourceRecords) && value.candidate === null
|
|
160
|
+
&& ['no-model-contract', 'contract-unavailable', 'inventory-budget-exceeded', 'inspection-unavailable'].includes(value.reason)) return value;
|
|
161
|
+
if (value.outcome === 'failed' && value.stage === 'input' && value.reason === 'internal-error'
|
|
162
|
+
&& value.sourceRecords === null && value.candidate === null) return value;
|
|
163
|
+
if (value.outcome === 'failed' && value.stage === 'corroboration' && value.reason === 'internal-error'
|
|
164
|
+
&& rfiWireCount(value.sourceRecords) && value.candidate === null) return value;
|
|
165
|
+
if (value.outcome === 'failed' && value.stage === 'rebuild' && value.reason === 'would-not-round-trip'
|
|
166
|
+
&& rfiWireCount(value.sourceRecords) && value.candidate === null) return value;
|
|
167
|
+
if (value.outcome === 'failed' && value.stage === 'publication' && value.reason === 'publication-failed'
|
|
168
|
+
&& rfiWireCount(value.sourceRecords) && rfiWireCandidate(value.candidate)
|
|
169
|
+
&& value.candidate.sourceRecords === value.sourceRecords) return value;
|
|
170
|
+
return reject();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function rfiCountPhrase(count, singular, plural) {
|
|
174
|
+
return `${count} ${count === 1 ? singular : plural}`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function rfiJoinPhrases(parts) {
|
|
178
|
+
if (parts.length < 2) return parts[0] || '';
|
|
179
|
+
if (parts.length === 2) return `${parts[0]} and ${parts[1]}`;
|
|
180
|
+
return `${parts.slice(0, -1).join(', ')}, and ${parts[parts.length - 1]}`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Turn one server result into the operation's ONE final live-region announcement.
|
|
185
|
+
* This function is pure and intentionally never includes raw server/sanitizer detail.
|
|
186
|
+
*/
|
|
187
|
+
function formatRfiTransferToast(rawResult, operationKind, projectName, appInstalled) {
|
|
188
|
+
const validContext = (operationKind === 'import' || operationKind === 'duplicate')
|
|
189
|
+
&& typeof projectName === 'string' && projectName.trim()
|
|
190
|
+
&& (operationKind !== 'import' || typeof appInstalled === 'boolean');
|
|
191
|
+
let result = null;
|
|
192
|
+
try { if (validContext) result = parseRfiTransferResult(rawResult); }
|
|
193
|
+
catch { /* the closed fallback below is the UI-visible internal error */ }
|
|
194
|
+
|
|
195
|
+
const noun = operationKind === 'duplicate' ? 'copy' : 'project';
|
|
196
|
+
const original = operationKind === 'duplicate' ? 'original project' : 'original archive';
|
|
197
|
+
const base = operationKind === 'duplicate'
|
|
198
|
+
? `Duplicated as “${projectName}”.`
|
|
199
|
+
: `Imported ✓ — “${projectName}” added.`;
|
|
200
|
+
const appendAppWarning = (message, tone) => ({
|
|
201
|
+
message: operationKind === 'import' && appInstalled === false
|
|
202
|
+
? `${message} Its app isn’t installed here — some tools may be missing until you install it.`
|
|
203
|
+
: message,
|
|
204
|
+
tone: operationKind === 'import' && appInstalled === false && tone === 'ok' ? 'warn' : tone,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
if (!result) {
|
|
208
|
+
return appendAppWarning(
|
|
209
|
+
`${base} An internal FloLess error prevented confirming what happened to its RFIs. Keep the ${original} and report this problem.`,
|
|
210
|
+
'err',
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
if (result.outcome === 'none-present') {
|
|
214
|
+
return appendAppWarning(`${base} No RFIs were present to carry.`, 'ok');
|
|
215
|
+
}
|
|
216
|
+
if (result.outcome === 'complete') {
|
|
217
|
+
return appendAppWarning(`${base} All ${result.carried} ${result.carried === 1 ? 'RFI' : 'RFIs'} carried.`, 'ok');
|
|
218
|
+
}
|
|
219
|
+
if (result.outcome === 'partial') {
|
|
220
|
+
const omitted = [];
|
|
221
|
+
if (result.recordsOmitted) omitted.push(rfiCountPhrase(result.recordsOmitted, 'RFI', 'RFIs'));
|
|
222
|
+
if (result.subjectsOmitted) omitted.push(rfiCountPhrase(result.subjectsOmitted, 'subject reference', 'subject references'));
|
|
223
|
+
if (result.targetsOmitted) omitted.push(rfiCountPhrase(result.targetsOmitted, 'target link', 'target links'));
|
|
224
|
+
const groups = [];
|
|
225
|
+
const records = result.reasons.records;
|
|
226
|
+
const subjects = result.reasons.subjects;
|
|
227
|
+
const targets = result.reasons.targets;
|
|
228
|
+
if (records['version-unavailable'] || records['subjects-exhausted'] || records['targets-exhausted']
|
|
229
|
+
|| subjects['model-member-missing'] || subjects['model-joint-missing']
|
|
230
|
+
|| targets['model-member-missing'] || targets['model-joint-missing']
|
|
231
|
+
|| targets['drawing-source-missing'] || targets['drawing-extension-mismatch']
|
|
232
|
+
|| targets['drawing-page-missing'] || targets['drawing-page-identity-mismatch']) {
|
|
233
|
+
groups.push('landing references were unavailable');
|
|
234
|
+
}
|
|
235
|
+
if (targets['drawing-source-ambiguous'] || targets['drawing-source-corrupt']
|
|
236
|
+
|| targets['drawing-source-unreadable']) groups.push('drawing data could not be safely read');
|
|
237
|
+
if (targets['drawing-region-invalid']) groups.push('an invalid drawing location was removed');
|
|
238
|
+
if (records['duplicate-gap']) groups.push('an older duplicate question was collapsed');
|
|
239
|
+
const carried = result.carried
|
|
240
|
+
? `${result.carried} ${result.carried === 1 ? 'RFI was' : 'RFIs were'} carried.`
|
|
241
|
+
: 'No RFIs were carried.';
|
|
242
|
+
return appendAppWarning(
|
|
243
|
+
`${base} ${carried} ${rfiJoinPhrases(omitted)} ${omitted.length === 1 ? 'was' : 'were'} left out. Reasons: ${groups.join('; ')}.`,
|
|
244
|
+
'warn',
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
if (result.outcome === 'refused') {
|
|
248
|
+
const reason = result.reason === 'inventory-budget-exceeded'
|
|
249
|
+
? 'the RFIs needed more validation work than FloLess safely allows'
|
|
250
|
+
: result.reason === 'inspection-unavailable'
|
|
251
|
+
? 'the PDF drawing inspector is not installed on this computer'
|
|
252
|
+
: result.reason === 'no-model-contract' || result.reason === 'contract-unavailable'
|
|
253
|
+
? 'the RFIs could not be checked against this project'
|
|
254
|
+
: 'the RFI data could not be safely read';
|
|
255
|
+
return appendAppWarning(`${base} The ${noun} was still created without those RFIs because ${reason}.`, 'warn');
|
|
256
|
+
}
|
|
257
|
+
if (result.outcome === 'conflict') {
|
|
258
|
+
return appendAppWarning(
|
|
259
|
+
`${base} Source RFIs were not overlaid because the ${noun} already received RFIs.`,
|
|
260
|
+
'warn',
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
return appendAppWarning(
|
|
264
|
+
`${base} An internal FloLess error stopped those RFIs from being carried. Keep the ${original} and report this problem.`,
|
|
265
|
+
'err',
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
26
269
|
const $app = document.getElementById('app');
|
|
27
270
|
const $switch = document.getElementById('mode-switch');
|
|
28
271
|
const $workflowTab = $switch.querySelector('button[data-mode="workflows"]');
|
|
@@ -30,8 +273,6 @@
|
|
|
30
273
|
const $project = document.getElementById('ws-project');
|
|
31
274
|
const $spine = document.getElementById('ws-spine');
|
|
32
275
|
const $projName = document.getElementById('ws-proj-name');
|
|
33
|
-
const $crumbName = document.getElementById('ws-crumb-name');
|
|
34
|
-
const $status = document.getElementById('ws-status');
|
|
35
276
|
const $stepTabs = document.getElementById('ws-step-tabs');
|
|
36
277
|
const $stageGuidance = document.getElementById('ws-stage-guidance');
|
|
37
278
|
const $projMenu = document.getElementById('ws-proj-menu');
|
|
@@ -52,7 +293,7 @@
|
|
|
52
293
|
model: document.getElementById('ws-frame-model'),
|
|
53
294
|
drawings: document.getElementById('ws-frame-drawings'),
|
|
54
295
|
};
|
|
55
|
-
const $
|
|
296
|
+
const $attachRevision = document.getElementById('ws-attach-revision');
|
|
56
297
|
const $revisionCard = document.getElementById('ws-revision-card');
|
|
57
298
|
const $revisionFile = document.getElementById('ws-revision-file');
|
|
58
299
|
const $sourcePlaceholder = document.getElementById('ws-source-placeholder'); // shown for a filter-less Source step
|
|
@@ -189,15 +430,39 @@
|
|
|
189
430
|
return blob;
|
|
190
431
|
}
|
|
191
432
|
|
|
433
|
+
/*
|
|
434
|
+
* WHICH EXPORTS RENDER IS ALLOWED TO SPEAK.
|
|
435
|
+
*
|
|
436
|
+
* `renderExports` awaits twice, and its final guard checked only the project id and the pane — so a
|
|
437
|
+
* render that started earlier, captured the OLD units, and finished after a newer one could still
|
|
438
|
+
* write its answer into module state. That is not hypothetical on this branch: the units event
|
|
439
|
+
* triggers a fresh render, and an in-flight older render landing after it would put the units back.
|
|
440
|
+
* `modelPresenceGen` could not be reused — it is bumped by the presence probe and by other panes,
|
|
441
|
+
* so it says "something newer happened", not "a newer EXPORTS render happened". (Review round 4.)
|
|
442
|
+
*/
|
|
443
|
+
let exportsRenderGen = 0;
|
|
192
444
|
let exportState = null; // kind → { path, exportedAt } after a successful list; null = unknown/failed
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
445
|
+
/*
|
|
446
|
+
* THE UNITS THE SERVER SAYS THIS PROJECT'S BILL IS IN — from the same response the card is built
|
|
447
|
+
* from, refreshed every time the card is. `null` until it has answered.
|
|
448
|
+
*
|
|
449
|
+
* NOT `current.displayUnits` as the primary. `current` is the project object as it was when the
|
|
450
|
+
* project was OPENED, and nothing updates its units: the PUT broadcasts `display-units-changed`,
|
|
451
|
+
* and the only listener for that in the whole tree is the editor. So a picker reading `current`
|
|
452
|
+
* offered `Length (ft)` / `lb/ft` after a switch to millimetres while the server wrote
|
|
453
|
+
* `Length (mm)`, directly beneath this card's own note saying the project now uses mm.
|
|
454
|
+
*
|
|
455
|
+
* BUT NOT INSTEAD OF IT EITHER, which the first version of this fix got wrong. Defaulting to a
|
|
456
|
+
* literal `'ft-in'` made two reachable windows answer imperial for a metric job: before the
|
|
457
|
+
* listing lands (the card paints, and its Export button is live, while the fetch is still behind
|
|
458
|
+
* two awaits) and after the listing FAILS (which leaves the default standing indefinitely). The
|
|
459
|
+
* second is strictly worse than the code this replaced, which was at least correct as of open.
|
|
460
|
+
* So `null` is "not told yet" and `bomUnits` falls back to the stale-but-usually-right client
|
|
461
|
+
* copy — the server's answer the moment it exists, never a guess dressed as one.
|
|
462
|
+
*/
|
|
463
|
+
let exportUnits = null;
|
|
464
|
+
// The destinations picked last time, per project. A convenience only; the server checks current
|
|
465
|
+
// readiness after the user reviews and authorizes each send.
|
|
201
466
|
const hostChoices = new Map();
|
|
202
467
|
// Same shape for the Render card. Rendering needs AWARE >= 0.103.0 AND Blender on the machine,
|
|
203
468
|
// neither of which floless can assume, so the card reports which one to fix rather than offering
|
|
@@ -508,6 +773,12 @@
|
|
|
508
773
|
*/
|
|
509
774
|
const LOCALLY_WORDED_REFUSALS = ['no-contract', 'filter-checkpoint'];
|
|
510
775
|
|
|
776
|
+
/* The History step's header band — the same 46px `.step-head` every other project step carries (see
|
|
777
|
+
the shared step-header rule in app.css). Held as one constant because this pane has THREE render
|
|
778
|
+
paths (loading, refused/empty, and the version table) and a band that appears on some of them
|
|
779
|
+
reads as a different pane rather than the same one in a different state. */
|
|
780
|
+
const HIST_HEAD = '<div class="step-head"><span>History</span></div>';
|
|
781
|
+
|
|
511
782
|
/**
|
|
512
783
|
* The server's own plain-English refusal for a project that cannot be signed off at all, or `''`
|
|
513
784
|
* when approval is merely unavailable for the moment (loading, a failed probe, nothing read yet).
|
|
@@ -657,6 +928,36 @@
|
|
|
657
928
|
if (!ws) return null;
|
|
658
929
|
return current ? current.name : 'Workspaces';
|
|
659
930
|
}
|
|
931
|
+
// Visibility belongs to this shell, not to whichever loaded child reports last.
|
|
932
|
+
// Re-entering an already-loaded tab has no new Ready event, so hand off its
|
|
933
|
+
// current snapshot explicitly after the DOM has reached its winning state.
|
|
934
|
+
function syncWorkspaceReporter() {
|
|
935
|
+
if (typeof window.__instructorReady !== 'function'
|
|
936
|
+
|| typeof window.__instructorReport !== 'function'
|
|
937
|
+
|| typeof window.__instructorReporterGone !== 'function') return;
|
|
938
|
+
const workspaceFrames = Object.values(frames);
|
|
939
|
+
const visible = workspaceFrames.find((frame) => !frame.hidden && frame.getClientRects().length);
|
|
940
|
+
// Retire the outgoing frame before adopting another, so focused guidance
|
|
941
|
+
// from its document is cleared while it is still the registered owner.
|
|
942
|
+
for (const frame of workspaceFrames) {
|
|
943
|
+
if (frame !== visible) window.__instructorReporterGone(frame.contentWindow);
|
|
944
|
+
}
|
|
945
|
+
if (!visible) return;
|
|
946
|
+
const child = visible.contentWindow;
|
|
947
|
+
try {
|
|
948
|
+
if (!visible.dataset.want || child.location.href !== new URL(visible.dataset.want, location.href).href
|
|
949
|
+
|| typeof child.__instructor?.getSnapshot !== 'function') {
|
|
950
|
+
window.__instructorReporterGone(child);
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
const snapshot = child.__instructor.getSnapshot();
|
|
954
|
+
window.__instructorReady(child);
|
|
955
|
+
window.__instructorReport(snapshot, child);
|
|
956
|
+
} catch {
|
|
957
|
+
// A loading, replaced or unreadable child cannot describe the new tab yet.
|
|
958
|
+
window.__instructorReporterGone(child);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
660
961
|
function applyMode() {
|
|
661
962
|
const ws = mode === 'workspaces';
|
|
662
963
|
$app.classList.toggle('mode-workspaces', ws);
|
|
@@ -696,6 +997,7 @@
|
|
|
696
997
|
// workflow beacon; in a Workspaces project it points at that project's lifecycle.
|
|
697
998
|
if (!ws || !current) { if (bridge.clearWorkspaceGuide) bridge.clearWorkspaceGuide(); }
|
|
698
999
|
else syncWorkspaceGuide();
|
|
1000
|
+
syncWorkspaceReporter();
|
|
699
1001
|
}
|
|
700
1002
|
let modeChangeSequence = 0;
|
|
701
1003
|
function showWorkflowOpening(opening) {
|
|
@@ -970,6 +1272,55 @@
|
|
|
970
1272
|
let retryTimer = null; // module-scoped ON PURPOSE — see reportUnverified
|
|
971
1273
|
let retriesLeft = 1; // …and so is the budget, which only a real event refills
|
|
972
1274
|
|
|
1275
|
+
/*
|
|
1276
|
+
* THE SHELL'S COPY OF `displayUnits`, KEPT TRUE.
|
|
1277
|
+
*
|
|
1278
|
+
* `current` is the project as it was when it was OPENED. Its units can change from three places —
|
|
1279
|
+
* this tab's editor, another tab, the terminal AI — and until this listener existed the shell heard
|
|
1280
|
+
* none of them. Everything downstream then had to guess when to re-read, and three review rounds of
|
|
1281
|
+
* guessing produced three different defects: a picker reading a value nothing refreshed, then a
|
|
1282
|
+
* fallback that defaulted to imperial, then a fallback that never went stale-checking again.
|
|
1283
|
+
*
|
|
1284
|
+
* The event was already being broadcast and already had one subscriber (the editor iframe). This is
|
|
1285
|
+
* the missing second one, not a new mechanism — which is why the fix is a listener rather than a
|
|
1286
|
+
* fourth patch at the reading end.
|
|
1287
|
+
*/
|
|
1288
|
+
window.addEventListener('floless:display-units-changed', (e) => {
|
|
1289
|
+
const m = (e && e.detail) || {};
|
|
1290
|
+
if (!m.project) return;
|
|
1291
|
+
const units = m.displayUnits === 'mm' ? 'mm' : 'ft-in';
|
|
1292
|
+
/*
|
|
1293
|
+
* THE CACHED ROW IS CORRECTED FOR EVERY PROJECT, not only the one that is open.
|
|
1294
|
+
*
|
|
1295
|
+
* `openProject` reads `projects.find(...)` and only re-fetches when the id is absent, so a row
|
|
1296
|
+
* left stale here is a row that is handed to `current` the next time that project is opened —
|
|
1297
|
+
* and `bomUnits()` leans on `current.displayUnits` for exactly the window before the export
|
|
1298
|
+
* listing lands. Ignoring events for projects that are merely not open now would poison the one
|
|
1299
|
+
* window the fallback exists to cover. (Review round 4.)
|
|
1300
|
+
*/
|
|
1301
|
+
// CAPTURED BEFORE THE WRITE BELOW. `openProject` does `current = projects.find(...)`, so the
|
|
1302
|
+
// cached row and `current` are usually the SAME OBJECT — correcting the row therefore mutates
|
|
1303
|
+
// `current` too, and a later `current.displayUnits === units` test would be asking a question it
|
|
1304
|
+
// had just answered itself. (Review round 5.)
|
|
1305
|
+
const wasUnits = current ? current.displayUnits : undefined;
|
|
1306
|
+
const cached = projects.find((x) => x && x.id === m.project);
|
|
1307
|
+
if (cached) cached.displayUnits = units;
|
|
1308
|
+
if (!current || m.project !== current.id) return;
|
|
1309
|
+
if (wasUnits === units && exportUnits === units) return;
|
|
1310
|
+
current.displayUnits = units;
|
|
1311
|
+
// The listing's answer is now known to be stale, and `null` is what says so — `bomUnits()` falls
|
|
1312
|
+
// back to `current.displayUnits`, which this handler has just made true. Overwriting it with the
|
|
1313
|
+
// new value instead would be a guess that happens to be right; this is the same value arrived at
|
|
1314
|
+
// honestly, and it stays right if the two ever disagree.
|
|
1315
|
+
exportUnits = null;
|
|
1316
|
+
// Re-read rather than re-label: the SERVER decides which exported bills are now in the other
|
|
1317
|
+
// system, and that is a different question from what the picker should offer next.
|
|
1318
|
+
// No `restoreKind`: that argument names the card whose button the USER just pressed, and nobody
|
|
1319
|
+
// pressed anything here — the switch happened in the editor, or in another tab. Passing a label
|
|
1320
|
+
// would ask the card to restore focus to a kind that does not exist.
|
|
1321
|
+
if (!$wsExports.hidden) safeRenderExports('after a units change');
|
|
1322
|
+
});
|
|
1323
|
+
|
|
973
1324
|
window.addEventListener('floless:projects-changed', (e) => {
|
|
974
1325
|
const m = (e && e.detail) || {};
|
|
975
1326
|
if (!current) {
|
|
@@ -1089,7 +1440,36 @@
|
|
|
1089
1440
|
// ONLY AN AUTHORITATIVE ANSWER COUNTS AS VALIDATION. With a newer event already pending this
|
|
1090
1441
|
// read predates it, so recording it would let the loop exit on a claim that was never true —
|
|
1091
1442
|
// and the trailing pass re-reads anyway. (Found by review round 3.)
|
|
1092
|
-
if (mine && mine.id === id) {
|
|
1443
|
+
if (mine && mine.id === id) {
|
|
1444
|
+
/*
|
|
1445
|
+
* "UNCHANGED" MEANS THE IDENTITY, NOT THE ROW. `mine` is a freshly read server row, and the
|
|
1446
|
+
* reconnect catch-up (`aware.js` `es.onopen`) re-announces `projects-changed` precisely
|
|
1447
|
+
* because these events are at-most-once: a units switch made during an SSE gap raises a
|
|
1448
|
+
* `display-units-changed` nobody was listening to. Falling through here on identity alone
|
|
1449
|
+
* left `current.displayUnits` frozen at whatever it was before the gap, so the export
|
|
1450
|
+
* picker offered the old system while the server wrote the new one — the original defect,
|
|
1451
|
+
* now hiding behind a dropped connection instead of behind every switch. The row in hand
|
|
1452
|
+
* already carries the answer. (Review round 4.)
|
|
1453
|
+
*/
|
|
1454
|
+
// NORMALIZED, like the two sibling adoption sites. `displayUnits` is optional on the wire
|
|
1455
|
+
// (`projects-store.ts` writes the key only when one was explicitly chosen), so a project
|
|
1456
|
+
// that never had a unit choice arrives as `undefined` — and assigning that raw made the
|
|
1457
|
+
// `!==` test true on every `projects-changed`, discarding the server's `exportUnits` and
|
|
1458
|
+
// repainting for nothing. (Review round 5.)
|
|
1459
|
+
const freshUnits = mine.displayUnits === 'mm' ? 'mm' : 'ft-in';
|
|
1460
|
+
if (current && current.id === id && current.displayUnits !== freshUnits) {
|
|
1461
|
+
current.displayUnits = freshUnits;
|
|
1462
|
+
// The cached row too, for the reason the listener above spells out: `projects` is only
|
|
1463
|
+
// replaced wholesale when this pass owns the load sequence, so on a superseded pass the
|
|
1464
|
+
// stale row would survive and be handed to `current` on the next open.
|
|
1465
|
+
const row = projects.find((x) => x && x.id === id);
|
|
1466
|
+
if (row) row.displayUnits = freshUnits;
|
|
1467
|
+
exportUnits = null; // the listing's answer predates the gap; `bomUnits` falls back to the line above
|
|
1468
|
+
if (!$wsExports.hidden) safeRenderExports('after another tab changed the units');
|
|
1469
|
+
}
|
|
1470
|
+
if (!reconcileAgain) validated = id;
|
|
1471
|
+
continue;
|
|
1472
|
+
}
|
|
1093
1473
|
if (!mine) {
|
|
1094
1474
|
closeProject(); // → applyMode() → loadProjects(), so the landing repaints without it
|
|
1095
1475
|
// 'warn', not 'ok', and the parallel wording is deliberate (design review): this file
|
|
@@ -1337,7 +1717,7 @@
|
|
|
1337
1717
|
function renderLanding() {
|
|
1338
1718
|
let html = `<div class="ws-head"><div class="ws-head-text"><h2>Workspaces</h2>` +
|
|
1339
1719
|
`<div class="ws-sub">Live projects — open a document to keep working. No Run here.</div></div>` +
|
|
1340
|
-
`<button type="button" class="ws-import-btn" id="ws-import-project" data-tip="Restore a project from an exported .zip file">↓ Import project…</button></div>`;
|
|
1720
|
+
`<button type="button" class="ws-import-btn" id="ws-import-project" data-command-id="shell.project-import" data-tip="Restore a project from an exported .zip file">↓ Import project…</button></div>`;
|
|
1341
1721
|
const createEntries = workspaceCreateEntries(wsAppEntries);
|
|
1342
1722
|
if (createEntries.length) {
|
|
1343
1723
|
html += `<div class="ws-create-grid">`;
|
|
@@ -1623,6 +2003,129 @@
|
|
|
1623
2003
|
return res && typeof res.name === 'string' && res.name.trim() ? res.name.trim() : null;
|
|
1624
2004
|
}
|
|
1625
2005
|
|
|
2006
|
+
/**
|
|
2007
|
+
* How a steel standard names itself to a person — `US · AISC/ASTM`, `UK · BS/EN`.
|
|
2008
|
+
*
|
|
2009
|
+
* READ FROM `web/checkpoint-standard.js`, never respelled here. That module owns the ONE table
|
|
2010
|
+
* (`STANDARD_LABEL`), and the Drawing Filter checkpoint already reads it; a second spelling in this
|
|
2011
|
+
* file is how the three screens that name this one fact drifted apart in the first place (#1189).
|
|
2012
|
+
*
|
|
2013
|
+
* DYNAMICALLY IMPORTED because `index.html` loads this file as a classic `<script src>`, which has
|
|
2014
|
+
* no static `import`. `web/steel-editor.html`'s boot uses the same idiom for its shared modules, and
|
|
2015
|
+
* for the same reason.
|
|
2016
|
+
*
|
|
2017
|
+
* DOWN ONLY, which is the constraint that decides how much of the option comes from there. What
|
|
2018
|
+
* comes back is used as an option LABEL and nothing else: the option VALUES stay written out below,
|
|
2019
|
+
* because `checkpoint-standard.js` states that its output may reach `textContent` and must never be
|
|
2020
|
+
* part of a path that commits a value — and this select's value is committed as the project's
|
|
2021
|
+
* environment, permanently. `checkpoint-standard.test.ts` already pins the table's KEYS to
|
|
2022
|
+
* `STEEL_ENVIRONMENTS`, and the prompt test below pins this field's values to the same table, so the
|
|
2023
|
+
* two halves stay in step without this file reaching upward for one of them.
|
|
2024
|
+
*
|
|
2025
|
+
* A FAILED READ IS NOT CACHED. The rejected promise is cleared so a later attempt in the same page
|
|
2026
|
+
* can retry — otherwise one flaky module fetch would refuse every new steel project until reload.
|
|
2027
|
+
*/
|
|
2028
|
+
let standardLabelsPromise = null;
|
|
2029
|
+
function loadStandardLabels() {
|
|
2030
|
+
if (!standardLabelsPromise) {
|
|
2031
|
+
standardLabelsPromise = import('./checkpoint-standard.js')
|
|
2032
|
+
.then((m) => m.STANDARD_LABEL)
|
|
2033
|
+
.catch((err) => { standardLabelsPromise = null; throw err; });
|
|
2034
|
+
}
|
|
2035
|
+
return standardLabelsPromise;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* The NEW-PROJECT prompt: a name and the steel standard this job is built to.
|
|
2040
|
+
*
|
|
2041
|
+
* Separate from `promptName` deliberately — that one is shared with Rename, and a rename dialog has
|
|
2042
|
+
* no business asking which standard a finished job uses.
|
|
2043
|
+
*
|
|
2044
|
+
* THE STANDARD IS ASKED HERE BECAUSE HERE IS THE ONLY PLACE IT CAN BE ASKED. It is fixed for the
|
|
2045
|
+
* life of the project: the two section catalogues behind it are mutually exclusive, so moving a
|
|
2046
|
+
* modelled job between them does not re-price it, it un-resolves every member — profile, thickness,
|
|
2047
|
+
* weight and default grade at once, and the profile string handed to IFC and Tekla with them.
|
|
2048
|
+
* Display units stay switchable at any time precisely because they are the opposite: harmless
|
|
2049
|
+
* either way.
|
|
2050
|
+
*
|
|
2051
|
+
* NO COUNTRY, NO REGION, NO FLAG. §4.6 of the UK epic settled the user-facing noun as "Standard",
|
|
2052
|
+
* with the standards body as the value — and this screen, the only one of the three where the choice
|
|
2053
|
+
* is actually MADE, was the last one still offering countries (`United States` / `United Kingdom`).
|
|
2054
|
+
* It is not stylistic: the reference job is British-standards work in Abu Dhabi, so a country list
|
|
2055
|
+
* asks that user to pick a place they are not building in. "Standard" is what varies; where the job
|
|
2056
|
+
* is does not appear, because it is not one of the two axes.
|
|
2057
|
+
*
|
|
2058
|
+
* NO PRESELECTED VALUE. A job is US or UK and neither is "the norm", so neither is offered as the
|
|
2059
|
+
* one the user gets by not looking — the same rule display units follow. Since this choice cannot be
|
|
2060
|
+
* revisited, a quietly-defaulted one would be the expensive kind of unnoticed.
|
|
2061
|
+
*/
|
|
2062
|
+
/**
|
|
2063
|
+
* Name a new project, and — ONLY for a steel one — the standard it resolves against forever.
|
|
2064
|
+
*
|
|
2065
|
+
* `askCatalogue` exists because this prompt is shared: `createFromDrawing` serves vectorize's Trace
|
|
2066
|
+
* projects too, and asking those for a steel standard makes a user answer an irrelevant question
|
|
2067
|
+
* with a permanent answer that nothing will ever read or be able to change. The option keeps the
|
|
2068
|
+
* mechanism's word: what a Trace project is spared is the SECTION CATALOGUE the answer selects, and
|
|
2069
|
+
* the stored field is `environment` on both sides of the wire.
|
|
2070
|
+
*/
|
|
2071
|
+
async function promptNewProject(title, { askCatalogue = true } = {}) {
|
|
2072
|
+
if (!bridge.formModal) return null;
|
|
2073
|
+
// REFUSE rather than respell. If the one label table cannot be read, a hard-coded fallback here
|
|
2074
|
+
// would be exactly the second spelling this field was pinned to that table to end — and it would
|
|
2075
|
+
// be baked into a choice that cannot be corrected once the project exists. The user is told, and
|
|
2076
|
+
// `loadStandardLabels` leaves itself retryable.
|
|
2077
|
+
let standards = null;
|
|
2078
|
+
if (askCatalogue) {
|
|
2079
|
+
try {
|
|
2080
|
+
standards = await loadStandardLabels();
|
|
2081
|
+
// An INCOMPLETE table is the same failure arriving quietly: `Map.get` answers a missing key
|
|
2082
|
+
// with `undefined`, which the modal would render as the literal string "undefined" and store
|
|
2083
|
+
// the value behind it forever. Checked here rather than trusted, because a browser holding a
|
|
2084
|
+
// stale copy of the module is the one way this survives the tests.
|
|
2085
|
+
for (const env of ['US', 'UK']) {
|
|
2086
|
+
if (!standards.get(env)) throw new Error(`the shared label table names no standard for ${env}`);
|
|
2087
|
+
}
|
|
2088
|
+
} catch (err) {
|
|
2089
|
+
console.warn('promptNewProject: could not read the steel standard labels', err);
|
|
2090
|
+
showToast('Couldn’t read the steel standards — reload the page and try again', 'warn');
|
|
2091
|
+
return null;
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
const res = await bridge.formModal({
|
|
2095
|
+
title,
|
|
2096
|
+
fields: [
|
|
2097
|
+
{ name: 'name', label: 'Name this project', value: '', placeholder: 'e.g. Westfield Retail — Ph2' },
|
|
2098
|
+
...(askCatalogue ? [{
|
|
2099
|
+
name: 'environment', type: 'select', label: 'Standard',
|
|
2100
|
+
placeholder: 'Choose a standard…',
|
|
2101
|
+
options: [
|
|
2102
|
+
// The label is the standards body; `meta` is the mechanism it selects — the section family
|
|
2103
|
+
// and the default grade — which is the detail a detailer actually recognises a standard by.
|
|
2104
|
+
{ value: 'US', label: standards.get('US'), meta: 'AISC sections · A992 / A36' },
|
|
2105
|
+
{ value: 'UK', label: standards.get('UK'), meta: 'BS EN sections · S355' },
|
|
2106
|
+
],
|
|
2107
|
+
}] : []),
|
|
2108
|
+
],
|
|
2109
|
+
okLabel: 'Create',
|
|
2110
|
+
// `footnote`, not a `note` FIELD: that field type renders a <pre> for preformatted text, which
|
|
2111
|
+
// sets a sentence of prose in a monospace block. The footnote slot is what this modal already
|
|
2112
|
+
// has for exactly this.
|
|
2113
|
+
...(askCatalogue ? { footnote: 'The standard is fixed for the life of the project — every member resolves against its section catalogue. Display units can be changed at any time.' } : {}),
|
|
2114
|
+
});
|
|
2115
|
+
if (!res) return null;
|
|
2116
|
+
const name = typeof res.name === 'string' ? res.name.trim() : '';
|
|
2117
|
+
if (!name) return null;
|
|
2118
|
+
// A project that was never asked carries NO environment — absent, not defaulted, so a vector
|
|
2119
|
+
// project's metadata never claims a steel choice its owner did not make.
|
|
2120
|
+
if (!askCatalogue) return { name, environment: undefined };
|
|
2121
|
+
// An unchosen standard is REFUSED rather than defaulted: it cannot be corrected afterwards.
|
|
2122
|
+
if (res.environment !== 'US' && res.environment !== 'UK') {
|
|
2123
|
+
showToast('Choose a standard — it cannot be changed once the project exists', 'warn');
|
|
2124
|
+
return null;
|
|
2125
|
+
}
|
|
2126
|
+
return { name, environment: res.environment };
|
|
2127
|
+
}
|
|
2128
|
+
|
|
1626
2129
|
// Drop-a-drawing create. No new server verb: create an EMPTY project, then fire the
|
|
1627
2130
|
// existing revision pipeline (attachRevision) with the dropped file so the terminal AI reads it into
|
|
1628
2131
|
// the native model. ROLLBACK on cancel/error — if the user cancels the name prompt, or the file can't be read,
|
|
@@ -1631,11 +2134,17 @@
|
|
|
1631
2134
|
async function createFromDrawing(appId, templateId, files) {
|
|
1632
2135
|
// Ask for the name FIRST (before creating a row) so the common "cancel the prompt" path never
|
|
1633
2136
|
// creates anything to roll back.
|
|
1634
|
-
|
|
1635
|
-
|
|
2137
|
+
// A STEEL STANDARD IS ASKED FOR ONLY ON A STEEL PROJECT. `createFromDrawing` is shared — vectorize
|
|
2138
|
+
// creates its Trace projects through this same path — so prompting unconditionally made every
|
|
2139
|
+
// vector drawing pick an immutable steel standard and stored that unrelated choice in its
|
|
2140
|
+
// metadata, where nothing would ever read it and nothing could ever change it.
|
|
2141
|
+
const created = await promptNewProject(`New ${descDisplayName(templateId)} project`,
|
|
2142
|
+
{ askCatalogue: appId === 'steel-model' });
|
|
2143
|
+
if (!created) return;
|
|
2144
|
+
const { name, environment } = created;
|
|
1636
2145
|
let project;
|
|
1637
2146
|
try {
|
|
1638
|
-
({ project } = await api('/api/projects', { method: 'POST', body: JSON.stringify({ name, app: appId }) }));
|
|
2147
|
+
({ project } = await api('/api/projects', { method: 'POST', body: JSON.stringify({ name, app: appId, environment }) }));
|
|
1639
2148
|
} catch (err) {
|
|
1640
2149
|
showToast('Couldn’t create the project: ' + (err && err.message || err), 'warn');
|
|
1641
2150
|
return;
|
|
@@ -1702,7 +2211,7 @@
|
|
|
1702
2211
|
if (pendingPresenceToast) pendingPresenceToast();
|
|
1703
2212
|
pendingPresenceToast = null;
|
|
1704
2213
|
exportState = null;
|
|
1705
|
-
|
|
2214
|
+
exportUnits = null; // a new project's units arrive with its export listing; never inherit the last one's
|
|
1706
2215
|
renderReadinessState = null;
|
|
1707
2216
|
track('workspace_project_opened', { app: p.app }); // a real open (card click or post-create landing)
|
|
1708
2217
|
resetRevisionState(); closeRevisionDiscard(false, false); closeRevReview(); // fresh project — drop any prior revision state and any open review
|
|
@@ -1712,8 +2221,6 @@
|
|
|
1712
2221
|
// file resets state to avoid — and the next path that renders rows would inherit it.
|
|
1713
2222
|
histDiffSupported = false;
|
|
1714
2223
|
$projName.textContent = p.name;
|
|
1715
|
-
$crumbName.textContent = p.name;
|
|
1716
|
-
$status.textContent = projectAppName(p);
|
|
1717
2224
|
// Lazily src the frames once per project; switching steps only toggles hidden so the
|
|
1718
2225
|
// editor's state survives a Source⇄Traced round-trip. Frame URLs come from the app descriptor:
|
|
1719
2226
|
// the 'model' frame loads the app's editor; the 'drawings' frame loads its filter (steel) OR is
|
|
@@ -1822,7 +2329,7 @@
|
|
|
1822
2329
|
exportSourcesState = { status: 'unavailable', data: null, selected: null, open: false };
|
|
1823
2330
|
closeApprovalReview();
|
|
1824
2331
|
exportState = null;
|
|
1825
|
-
|
|
2332
|
+
exportUnits = null; // a new project's units arrive with its export listing; never inherit the last one's
|
|
1826
2333
|
renderReadinessState = null;
|
|
1827
2334
|
resetRevisionState();
|
|
1828
2335
|
stopKnowledgePoll(); kbCloseConfirm(); kbResetViewer(); knowledgeState = null; // the KB pane is per-project — never carry it across
|
|
@@ -2034,7 +2541,11 @@
|
|
|
2034
2541
|
if (show && !f.dataset.loaded && f.dataset.want) { f.src = f.dataset.want; f.dataset.loaded = '1'; }
|
|
2035
2542
|
}
|
|
2036
2543
|
if ($sourcePlaceholder) $sourcePlaceholder.hidden = !(s === 'drawings' && !drawingsHasFrame);
|
|
2037
|
-
|
|
2544
|
+
// Queried here rather than through the module const, the way master's own call sites do: setStep is
|
|
2545
|
+
// extracted and evaluated on its own by workspace-instructor-handoff.test.ts, and a closure
|
|
2546
|
+
// variable it cannot see is a ReferenceError there. It sits at the end of the step-tabs row now
|
|
2547
|
+
// (the breadcrumb row that used to hold it is gone), and is a Drawings-step control either way.
|
|
2548
|
+
{ const a = document.getElementById('ws-attach-revision'); if (a) a.hidden = s !== 'drawings'; }
|
|
2038
2549
|
renderRevisionCard(); // reflect any pending/failed revision read (card shows only on the Drawings step)
|
|
2039
2550
|
// The conversion offer is Model-step scoped, and re-derived on every entry rather than cached:
|
|
2040
2551
|
// the project's contract can change under this shell (a revision read, another tab, the editor's
|
|
@@ -2042,7 +2553,7 @@
|
|
|
2042
2553
|
// Exports is a shell-rendered pane (not an iframe): show/hide + (re)paint on open.
|
|
2043
2554
|
const showExports = s === 'exports';
|
|
2044
2555
|
$wsExports.hidden = !showExports;
|
|
2045
|
-
if (showExports)
|
|
2556
|
+
if (showExports) safeRenderExports('when you opened the Exports step');
|
|
2046
2557
|
// History is likewise a shell-rendered pane: the project's version ledger.
|
|
2047
2558
|
const showHistory = s === 'history';
|
|
2048
2559
|
$wsHistory.hidden = !showHistory;
|
|
@@ -2057,6 +2568,7 @@
|
|
|
2057
2568
|
// flashing a stale column.
|
|
2058
2569
|
else { stopKnowledgePoll(); kbCloseConfirm(); kbResetViewer(); knowledgeState = null; }
|
|
2059
2570
|
applyStageGating();
|
|
2571
|
+
syncWorkspaceReporter();
|
|
2060
2572
|
}
|
|
2061
2573
|
$stepTabs.addEventListener('click', (e) => {
|
|
2062
2574
|
const b = e.target.closest('button[data-step]');
|
|
@@ -2221,7 +2733,7 @@
|
|
|
2221
2733
|
showToast(`Approved${Number.isInteger(n) ? ` as v${n}` : ''}. ${pending ? `${pending} change${pending === 1 ? '' : 's'} remain pending${saved ? ' in Saved work' : ''}; approved exports omit them unless you explicitly choose DRAFT.` : 'No changes remain pending.'}`, 'ok');
|
|
2222
2734
|
track('workspace_project_approved', { app: project.app });
|
|
2223
2735
|
if (bridge.markWorkspaceApproved && wsDescOf(project)?.docGuide) bridge.markWorkspaceApproved(project.app);
|
|
2224
|
-
if (!$wsExports.hidden)
|
|
2736
|
+
if (!$wsExports.hidden) safeRenderExports('after approving this version');
|
|
2225
2737
|
if (!$wsHistory.hidden) await renderHistory();
|
|
2226
2738
|
} catch (error) {
|
|
2227
2739
|
if (approvalDialogState && error && error.body && error.body.code === 'approval-review-stale') {
|
|
@@ -2354,7 +2866,16 @@
|
|
|
2354
2866
|
}
|
|
2355
2867
|
});
|
|
2356
2868
|
} catch { /* not-yet-loaded / cross-origin */ }
|
|
2869
|
+
syncWorkspaceReporter();
|
|
2870
|
+
retainTerminalRevisionReviewFocus();
|
|
2357
2871
|
});
|
|
2872
|
+
// An editor can claim focus later than its load event (for example after its own async boot).
|
|
2873
|
+
// A focus inside a child browsing context blurs this window and leaves the iframe as the parent
|
|
2874
|
+
// document's active element. Recover only that exact escape from the terminal result; focus in any
|
|
2875
|
+
// parent-document overlay is untouched.
|
|
2876
|
+
window.addEventListener('blur', () => {
|
|
2877
|
+
restoreTerminalRevisionReviewFocusFromModel(revReviewState?.stageId);
|
|
2878
|
+
}, true);
|
|
2358
2879
|
// (find methods are exposed on the canonical window.flolessWorkspaces export below — a separate
|
|
2359
2880
|
// assignment here would be clobbered by that later `= { setMode, … }`.)
|
|
2360
2881
|
|
|
@@ -2385,6 +2906,12 @@
|
|
|
2385
2906
|
let knowledgeRenderEpoch = 0; // invalidates in-flight /status loads (poll ticks race verbs)
|
|
2386
2907
|
let kbTextAbort = null; // AbortController for the in-flight preview fetch
|
|
2387
2908
|
let lastRefsHtml = null; // exact rendered HTML of the refs host, or null to force a repaint
|
|
2909
|
+
/* The graph's index page, stashed when the graph loads. The step header carries the ✦ Overview
|
|
2910
|
+
button, and the header is painted from knowledgeState — which does NOT hold the graph, because
|
|
2911
|
+
the graph is fetched separately and written straight into the view host. Without this the button
|
|
2912
|
+
could only live inside the graph, which is where it used to vanish from the moment a page opened. */
|
|
2913
|
+
let kbGraphIndex = null;
|
|
2914
|
+
let lastStepHeadHtml = null; // same repaint-iff-changed contract as lastRefsHtml
|
|
2388
2915
|
let lastViewKey = null; // identity of what the viewer host is currently showing
|
|
2389
2916
|
let kbFocusSourceId = null; // consumed once after a repaint, to restore focus to a filename button
|
|
2390
2917
|
let kbAdjustBusy = null; // project id of an in-flight Adjust submit (or null) — scoped to the
|
|
@@ -2445,6 +2972,12 @@
|
|
|
2445
2972
|
setViewer({ mode: 'graph', sourceId: null });
|
|
2446
2973
|
lastRefsHtml = null;
|
|
2447
2974
|
kbFocusSourceId = null;
|
|
2975
|
+
// The step header's ✦ Overview opens the index of the graph last LOADED, and this shell survives a
|
|
2976
|
+
// project switch — so without this the next project's header offered the previous project's
|
|
2977
|
+
// overview. The cached header goes too, or the repaint that drops the button is skipped as unchanged.
|
|
2978
|
+
kbGraphIndex = null;
|
|
2979
|
+
lastStepHeadHtml = null;
|
|
2980
|
+
$wsKnowledge.querySelector('.kb-g-overview')?.remove(); // and the button already on screen goes now
|
|
2448
2981
|
}
|
|
2449
2982
|
|
|
2450
2983
|
function stopKnowledgePoll() { if (knowledgePoll) { clearInterval(knowledgePoll); knowledgePoll = null; } }
|
|
@@ -2660,10 +3193,11 @@
|
|
|
2660
3193
|
const dots = graph.nodes.map((n, i) => { const p = pos[i];
|
|
2661
3194
|
return `<g class="kb-g-node kb-g-${escapeAttr(n.type)}" tabindex="0" role="button" aria-label="${escapeAttr(n.title + ', ' + n.type)}" data-kb-node="${escapeAttr(n.slug)}" data-tip="${escapeAttr(n.title + ' · ' + n.type)}" data-pos="${p.x.toFixed(1)},${p.y.toFixed(1)}" transform="translate(${p.x.toFixed(1)},${p.y.toFixed(1)})">` +
|
|
2662
3195
|
`<circle class="kb-g-hit" r="16"/><circle class="kb-g-dot" r="9"/><text x="13" y="4">${escapeHtml(n.title)}</text></g>`; }).join('');
|
|
2663
|
-
const overview = graph.index ? `<button type="button" class="kb-g-overview" data-kb-node="${escapeAttr(graph.index.slug)}" data-tip="Open the overview">✦ Overview</button>` : '';
|
|
2664
3196
|
const legend = '<div class="kb-g-legend"><span class="kb-gleg src">Source</span><span class="kb-gleg con">Concept</span><span class="kb-gleg per">Person</span></div>';
|
|
2665
3197
|
const note = graph.truncated ? `<div class="kb-view-note">Showing ${graph.nodes.length} — graph truncated (some pages omitted)</div>` : '';
|
|
2666
|
-
|
|
3198
|
+
// No header of its own: the step's single full-width band above the split names this pane, and
|
|
3199
|
+
// the Overview button moved there so it survives opening a page. See kbStepHeadHtml.
|
|
3200
|
+
return '<section class="kb-col kb-graph">' +
|
|
2667
3201
|
'<div class="kb-graph-sub">' + legend + '<span class="kb-g-hint">Click a node to open its page · scroll to zoom · drag to pan</span></div>' +
|
|
2668
3202
|
`<div class="kb-graph-body"><svg viewBox="0 0 ${W} ${H}" data-vb-base="0 0 ${W} ${H}" class="kb-graph-svg" role="group" aria-label="Knowledge graph">${lines}${dots}</svg>` +
|
|
2669
3203
|
`<button type="button" class="kb-g-fit" data-kb-fit hidden data-tip="Zoom to fit (Home)" aria-label="Zoom to fit">⤢ Fit</button></div>${note}</section>`;
|
|
@@ -2725,20 +3259,49 @@
|
|
|
2725
3259
|
// space would inject extra classes). Same discipline as KB_CHIP; an unknown type falls back to the
|
|
2726
3260
|
// bare muted chip.
|
|
2727
3261
|
const KB_PAGE_TYPE_CLASS = { source: 'kb-page-type-source', concept: 'kb-page-type-concept', person: 'kb-page-type-person', index: 'kb-page-type-index' };
|
|
2728
|
-
|
|
3262
|
+
/** `opts.cited` marks a page opened from a workflow citation whose generation is no longer the current
|
|
3263
|
+
* one. The click leaves Workflows mode, so the drift chip the user just saw beside the workflow is off
|
|
3264
|
+
* screen the moment the page appears, and an old page is otherwise pixel-identical to a current one —
|
|
3265
|
+
* so the same amber chip follows them here. Visible text stands alone because `data-tip` is visual-only. */
|
|
3266
|
+
function kbPageShell(pg, opts) {
|
|
2729
3267
|
// typeof guard, not `|| ''`: a prototype key (pg.type === "constructor"/"__proto__"/…) would
|
|
2730
3268
|
// otherwise resolve to an inherited truthy value and stringify into the class attribute. Only a
|
|
2731
3269
|
// real whitelisted string is a valid class token; anything else falls back to the bare muted chip.
|
|
2732
3270
|
const cls = KB_PAGE_TYPE_CLASS[pg.type];
|
|
2733
3271
|
const tint = typeof cls === 'string' ? cls : '';
|
|
2734
3272
|
const type = pg.type ? `<span class="kb-page-type ${tint}">${escapeHtml(pg.type)}</span>` : '';
|
|
3273
|
+
const cited = opts && opts.cited
|
|
3274
|
+
? '<span class="kb-drift-chip" role="status" data-tip="The Knowledge Base has changed since this page was read. You’re seeing it as it was when the workflow was built, not the current version. Close it (✕) to browse the Knowledge Base as it is now.">Version this workflow was built from</span>'
|
|
3275
|
+
: '';
|
|
2735
3276
|
return '<section class="kb-col kb-viewer kb-page"><div class="kb-view-head">' +
|
|
2736
|
-
`<span class="kb-view-name" data-tip="${escapeAttr(pg.title)}">${escapeHtml(pg.title)}</span>${type}` +
|
|
3277
|
+
`<span class="kb-view-name" data-tip="${escapeAttr(pg.title)}">${escapeHtml(pg.title)}</span>${type}${cited}` +
|
|
2737
3278
|
'<button type="button" class="kb-x" data-kb-close data-tip="Back to graph" aria-label="Back to graph">✕</button></div>' +
|
|
2738
3279
|
`<div class="kb-page-body"><div class="kb-page-body-measure">${escapeHtml(pg.body)}</div></div></section>`;
|
|
2739
3280
|
}
|
|
2740
3281
|
function kbPageLoading() { return '<section class="kb-col kb-viewer kb-page"><div class="kb-view-head"><span class="kb-view-name">Loading…</span></div><div class="kb-view-msg"><div class="kb-view-spin" role="status" aria-label="Loading page"></div></div></section>'; }
|
|
2741
|
-
|
|
3282
|
+
/** `opts.citedGone` — the read carried a pinned generation and the server does not have it.
|
|
3283
|
+
*
|
|
3284
|
+
* This is ordinary, not exotic: only the newest few generations are kept, so a citation from a
|
|
3285
|
+
* workflow built several Organize passes ago outlives its generation. The page must NOT quietly
|
|
3286
|
+
* serve today’s version instead — that is exactly the silent substitution this whole feature
|
|
3287
|
+
* removes — but "could not be loaded" alone leaves the user stuck with no cause and no next step.
|
|
3288
|
+
* So: say which version is gone, and offer the current one behind a button that names itself.
|
|
3289
|
+
* A fallback the user chooses, and can see they chose, is not the defect; an automatic one is. */
|
|
3290
|
+
function kbPageError(opts) {
|
|
3291
|
+
const gone = !!(opts && opts.citedGone);
|
|
3292
|
+
const title = gone
|
|
3293
|
+
? 'This page is not in the version this workflow was built from.'
|
|
3294
|
+
: 'This page could not be loaded.';
|
|
3295
|
+
const detail = gone
|
|
3296
|
+
? '<div class="kb-view-msg-sub">Usually that version is no longer stored — only the most recent few are kept, and this citation is older than those. The page may also have been removed from it.</div>'
|
|
3297
|
+
+ '<div class="kb-view-act"><button type="button" class="primary" data-kb-open-current'
|
|
3298
|
+
+ ' data-command-id="shell.kb-open-current" data-tip="Open this page as the Knowledge Base has it now">'
|
|
3299
|
+
+ 'Open the current version</button></div>'
|
|
3300
|
+
: '';
|
|
3301
|
+
return '<section class="kb-col kb-viewer kb-page"><div class="kb-view-head"><span class="kb-view-name">Couldn’t load page</span><button type="button" class="kb-x" data-kb-close data-tip="Back to graph" aria-label="Back to graph">✕</button></div>'
|
|
3302
|
+
+ '<div class="kb-view-msg"><span class="kb-view-ico err" aria-hidden="true">⚠</span>'
|
|
3303
|
+
+ `<div class="kb-view-msg-title">${title}</div>${detail}</div></section>`;
|
|
3304
|
+
}
|
|
2742
3305
|
|
|
2743
3306
|
// ── The file viewer ───────────────────────────────────────────────────────────
|
|
2744
3307
|
// SECURITY: `filename` is user-authored and every state below interpolates it — escapeHtml for text,
|
|
@@ -2849,26 +3412,48 @@
|
|
|
2849
3412
|
const body = await r.json();
|
|
2850
3413
|
if (!body || !body.graph || !Array.isArray(body.graph.nodes)) throw new Error('bad graph envelope');
|
|
2851
3414
|
if (!alive()) return;
|
|
3415
|
+
kbGraphIndex = body.graph.index || null; // feeds the step header's ✦ Overview button
|
|
2852
3416
|
const h = kbViewHost(); if (h) h.innerHTML = kbGraphSvg(body.graph);
|
|
3417
|
+
if (knowledgeState) kbPaintStepHead(knowledgeState);
|
|
2853
3418
|
} catch (err) {
|
|
2854
3419
|
if (err && err.name === 'AbortError') return;
|
|
2855
|
-
if (alive()) { const h = kbViewHost(); if (h) h.innerHTML = kbGraphError(); } // Retry re-keys via setViewer — matches the file-viewer idiom (no poll-flicker)
|
|
3420
|
+
if (alive()) { kbGraphIndex = null; const h = kbViewHost(); if (h) h.innerHTML = kbGraphError(); if (knowledgeState) kbPaintStepHead(knowledgeState); } // Retry re-keys via setViewer — matches the file-viewer idiom (no poll-flicker)
|
|
2856
3421
|
}
|
|
2857
3422
|
}
|
|
2858
|
-
|
|
3423
|
+
/** `generationId` (optional) pins the read to one published generation — a workflow citation opens
|
|
3424
|
+
* the page AS IT READ when the workflow was built. Without it the route serves the current generation,
|
|
3425
|
+
* which is right for a graph click and wrong for a citation on a knowledge base that has moved on. */
|
|
3426
|
+
async function kbLoadPage(proj, slug, generationId) {
|
|
2859
3427
|
const epoch = viewEpoch, key = lastViewKey;
|
|
2860
3428
|
const alive = () => epoch === viewEpoch && key === lastViewKey && current && current.id === proj.id && !$wsKnowledge.hidden;
|
|
2861
3429
|
const ac = new AbortController(); kbTextAbort = ac;
|
|
3430
|
+
const pinned = generationId ? `?generation=${encodeURIComponent(generationId)}` : '';
|
|
3431
|
+
let status = 0;
|
|
2862
3432
|
try {
|
|
2863
|
-
const r = await fetch(`/api/projects/${encodeURIComponent(proj.id)}/knowledge/page/${encodeURIComponent(slug)}`, { signal: ac.signal, cache: 'no-store' });
|
|
3433
|
+
const r = await fetch(`/api/projects/${encodeURIComponent(proj.id)}/knowledge/page/${encodeURIComponent(slug)}${pinned}`, { signal: ac.signal, cache: 'no-store' });
|
|
3434
|
+
status = r.status;
|
|
2864
3435
|
if (!r.ok) throw new Error(`page ${r.status}`);
|
|
2865
3436
|
const body = await r.json();
|
|
2866
3437
|
if (!body || !body.page || typeof body.page.body !== 'string') throw new Error('bad page envelope');
|
|
2867
3438
|
if (!alive()) return;
|
|
2868
|
-
|
|
3439
|
+
// Judged against the state on screen: a citation to a superseded generation gets the chip; a graph
|
|
3440
|
+
// click (no generation) or a citation to the generation that is still current does not.
|
|
3441
|
+
// No `!!cur` guard, deliberately. With no current generation on record nothing IS current, so a
|
|
3442
|
+
// pinned page cannot be the current one and the chip is the honest answer. Requiring `cur` made
|
|
3443
|
+
// "I don’t know what is current" render as "you are on the current one" — and the server’s own
|
|
3444
|
+
// drift flag says the opposite in that state, so the strip and the page would disagree.
|
|
3445
|
+
const cur = knowledgeState && knowledgeState.currentGeneration ? knowledgeState.currentGeneration.generationId : null;
|
|
3446
|
+
const cited = !!generationId && cur !== generationId;
|
|
3447
|
+
const h = kbViewHost(); if (h) h.innerHTML = kbPageShell(body.page, { cited });
|
|
2869
3448
|
} catch (err) {
|
|
2870
3449
|
if (err && err.name === 'AbortError') return;
|
|
2871
|
-
|
|
3450
|
+
// One sentence used to cover five causes with no record anywhere. The status separates the one
|
|
3451
|
+
// the user can act on — a pinned generation the server no longer keeps — from everything else,
|
|
3452
|
+
// and the rest goes to the log so "the citation is broken" starts from more than nothing.
|
|
3453
|
+
const citedGone = !!generationId && (status === 404 || status === 400);
|
|
3454
|
+
console.warn(`[workspaces] knowledge page ${slug}${generationId ? ` @ ${generationId}` : ''} failed`
|
|
3455
|
+
+ `${status ? ` (HTTP ${status})` : ''}:`, err instanceof Error ? err.message : err);
|
|
3456
|
+
if (alive()) { const h = kbViewHost(); if (h) h.innerHTML = kbPageError({ citedGone }); } // ✕ re-keys via setViewer; no poll-flicker
|
|
2872
3457
|
}
|
|
2873
3458
|
}
|
|
2874
3459
|
|
|
@@ -2997,7 +3582,6 @@
|
|
|
2997
3582
|
? st.sources.map(kbSourceRow).join('')
|
|
2998
3583
|
: '<div class="kb-empty">No references yet — drop files above, or ask your terminal AI to add them.</div>';
|
|
2999
3584
|
return '<section class="kb-col">' +
|
|
3000
|
-
`<div class="kb-head"><span>References</span><span class="h-end">${n ? `${n} source${n === 1 ? '' : 's'}` : ''}</span></div>` +
|
|
3001
3585
|
'<div class="kb-refs-body">' +
|
|
3002
3586
|
'<button type="button" class="kb-drop" id="kb-drop" data-command-id="shell.add-knowledge" data-tip="Drop files here, or click to pick them">' +
|
|
3003
3587
|
'<span class="di" aria-hidden="true">⤓</span><span class="dt">Drop references here</span>' +
|
|
@@ -3016,17 +3600,168 @@
|
|
|
3016
3600
|
/** The split is built ONCE; the refs column and the viewer then repaint independently. A wholesale
|
|
3017
3601
|
* innerHTML would destroy an open PDF <iframe> on every 3 s poll tick. Recreating the shell must
|
|
3018
3602
|
* drop both caches — they describe DOM nodes that no longer exist. */
|
|
3603
|
+
/* The step's ONE header, spanning the whole pane so References sits UNDER it rather than beside a
|
|
3604
|
+
header of its own — the shape the Drawing Filter already has, where the filter panel falls under
|
|
3605
|
+
the "Drawing Filter" band. Painted separately from the two columns because it outlives both:
|
|
3606
|
+
the columns repaint on every 3 s poll and swap wholesale between graph, page and file viewers. */
|
|
3607
|
+
function kbStepHeadHtml(st) {
|
|
3608
|
+
const n = (st && st.sources) ? st.sources.length : 0;
|
|
3609
|
+
const count = n ? `<span class="kb-step-count">${n} source${n === 1 ? '' : 's'}</span>` : '';
|
|
3610
|
+
// The Overview button lives here rather than in the graph, so it stays reachable while a page or
|
|
3611
|
+
// file is open — it used to vanish with the graph's own header the moment you opened a node.
|
|
3612
|
+
const ov = kbGraphIndex
|
|
3613
|
+
? `<button type="button" class="kb-g-overview" data-kb-node="${escapeAttr(kbGraphIndex.slug)}" data-tip="Open the overview">✦ Overview</button>`
|
|
3614
|
+
: '';
|
|
3615
|
+
return `<div class="step-head" id="kb-step-head"><span>Knowledge</span>${count}${ov}</div>`;
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3618
|
+
/* Repaint the band iff its rendered output changed — the same contract the refs column keeps, and
|
|
3619
|
+
for the same reason: this runs on every 3 s poll tick, and a wholesale innerHTML swap would move
|
|
3620
|
+
focus off the Overview button while someone is on it. */
|
|
3621
|
+
function kbPaintStepHead(st) {
|
|
3622
|
+
const head = $wsKnowledge.querySelector('#kb-step-head');
|
|
3623
|
+
if (!head) return;
|
|
3624
|
+
const html = kbStepHeadHtml(st);
|
|
3625
|
+
if (html === lastStepHeadHtml) return;
|
|
3626
|
+
head.outerHTML = html;
|
|
3627
|
+
lastStepHeadHtml = html;
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3019
3630
|
function kbEnsureShell() {
|
|
3020
3631
|
if ($wsKnowledge.querySelector('.kb-split')) return;
|
|
3021
|
-
|
|
3632
|
+
// The rail and the stub are SIBLINGS of .kb-refs-host, never children of it: the host's innerHTML
|
|
3633
|
+
// is replaced wholesale on every poll repaint, so anything inside it is destroyed 3 s later.
|
|
3634
|
+
$wsKnowledge.innerHTML = kbStepHeadHtml(knowledgeState) +
|
|
3635
|
+
'<div class="kb-split">' +
|
|
3636
|
+
'<div class="kb-refs-host" id="kb-refs-host"></div>' +
|
|
3637
|
+
'<div class="kb-refs-stub" aria-hidden="true"><span class="vertical-label">References</span></div>' +
|
|
3638
|
+
'<div class="pane-rail kb-rail">' +
|
|
3639
|
+
'<div class="resize-handle" data-kb-rail-resize role="separator" tabindex="0" aria-orientation="vertical" aria-controls="kb-refs-host" aria-label="Resize References panel" data-command-id="shell.knowledge-refs-resize" data-tip="Drag to resize · double-click to reset"></div>' +
|
|
3640
|
+
'<button type="button" class="panel-toggle" data-kb-rail-toggle data-command-id="shell.knowledge-refs-panel"' +
|
|
3641
|
+
' aria-controls="kb-refs-host" aria-expanded="true"' +
|
|
3642
|
+
' aria-label="Collapse References panel" data-tip="Collapse References panel"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m10 3-5 5 5 5"/></svg></button>' +
|
|
3643
|
+
'</div>' +
|
|
3644
|
+
'<div class="kb-view-host"></div></div>';
|
|
3645
|
+
kbWireRail();
|
|
3646
|
+
kbApplyRefsCollapse();
|
|
3022
3647
|
lastRefsHtml = null;
|
|
3648
|
+
lastStepHeadHtml = kbStepHeadHtml(knowledgeState); // the shell just emitted exactly this
|
|
3023
3649
|
lastViewKey = null;
|
|
3024
3650
|
}
|
|
3025
3651
|
|
|
3652
|
+
/* ── References rail: collapse + resize, mirroring the shell's panes ──────────────────────────
|
|
3653
|
+
Scoped to .kb-split rather than the window, which is the point — it belongs to the Knowledge
|
|
3654
|
+
step, under its tab, not to the app frame. */
|
|
3655
|
+
const KB_REFS_LS = 'floless:kb-refs';
|
|
3656
|
+
const KB_REFS_MIN = 200, KB_REFS_MAX = 520, KB_REFS_DEFAULT = 272;
|
|
3657
|
+
let kbRefsCollapsed = false, kbRefsWidth = null;
|
|
3658
|
+
try {
|
|
3659
|
+
const raw = JSON.parse(localStorage.getItem(KB_REFS_LS) || '{}');
|
|
3660
|
+
kbRefsCollapsed = !!raw.collapsed;
|
|
3661
|
+
if (typeof raw.width === 'number') kbRefsWidth = raw.width;
|
|
3662
|
+
} catch { /* private mode */ }
|
|
3663
|
+
const kbSaveRefs = () => {
|
|
3664
|
+
try { localStorage.setItem(KB_REFS_LS, JSON.stringify({ collapsed: kbRefsCollapsed, width: kbRefsWidth })); }
|
|
3665
|
+
catch { /* private mode */ }
|
|
3666
|
+
};
|
|
3667
|
+
|
|
3668
|
+
function kbApplyRefsCollapse() {
|
|
3669
|
+
const split = $wsKnowledge.querySelector('.kb-split');
|
|
3670
|
+
if (!split) return;
|
|
3671
|
+
split.classList.toggle('refs-collapsed', kbRefsCollapsed);
|
|
3672
|
+
if (kbRefsWidth != null) split.style.setProperty('--kb-refs-width', kbRefsWidth + 'px');
|
|
3673
|
+
const btn = split.querySelector('[data-kb-rail-toggle]');
|
|
3674
|
+
if (!btn) return;
|
|
3675
|
+
const label = (kbRefsCollapsed ? 'Expand' : 'Collapse') + ' References panel';
|
|
3676
|
+
// No textContent swap: the chevron is the shared SVG, rotated by CSS (.kb-split.refs-collapsed).
|
|
3677
|
+
btn.setAttribute('aria-label', label);
|
|
3678
|
+
btn.setAttribute('aria-expanded', String(!kbRefsCollapsed));
|
|
3679
|
+
btn.dataset.tip = label;
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
function kbWireRail() {
|
|
3683
|
+
const split = $wsKnowledge.querySelector('.kb-split');
|
|
3684
|
+
if (!split) return;
|
|
3685
|
+
split.querySelector('[data-kb-rail-toggle]').addEventListener('click', () => {
|
|
3686
|
+
kbRefsCollapsed = !kbRefsCollapsed;
|
|
3687
|
+
kbSaveRefs();
|
|
3688
|
+
kbApplyRefsCollapse();
|
|
3689
|
+
});
|
|
3690
|
+
const handle = split.querySelector('[data-kb-rail-resize]');
|
|
3691
|
+
// The shell's dividers report their width as a value (app.js syncValue). A separator the keyboard can
|
|
3692
|
+
// move has to, or a screen reader announces nothing when it moves.
|
|
3693
|
+
const syncRefsValue = () => {
|
|
3694
|
+
const w = Math.round(kbRefsWidth ?? KB_REFS_DEFAULT);
|
|
3695
|
+
handle.setAttribute('aria-valuemin', String(KB_REFS_MIN));
|
|
3696
|
+
handle.setAttribute('aria-valuemax', String(KB_REFS_MAX));
|
|
3697
|
+
handle.setAttribute('aria-valuenow', String(w));
|
|
3698
|
+
handle.setAttribute('aria-valuetext', `${w} pixels`);
|
|
3699
|
+
};
|
|
3700
|
+
syncRefsValue();
|
|
3701
|
+
handle.addEventListener('mousedown', (e) => {
|
|
3702
|
+
if (kbRefsCollapsed) return;
|
|
3703
|
+
e.preventDefault();
|
|
3704
|
+
const startX = e.clientX;
|
|
3705
|
+
const startW = split.querySelector('.kb-refs-host').getBoundingClientRect().width;
|
|
3706
|
+
handle.classList.add('dragging');
|
|
3707
|
+
split.classList.add('resizing'); // suppresses the ease so the drag tracks 1:1
|
|
3708
|
+
document.body.classList.add('resizing');
|
|
3709
|
+
const onMove = (ev) => {
|
|
3710
|
+
kbRefsWidth = Math.max(KB_REFS_MIN, Math.min(KB_REFS_MAX, startW + (ev.clientX - startX)));
|
|
3711
|
+
split.style.setProperty('--kb-refs-width', kbRefsWidth + 'px');
|
|
3712
|
+
};
|
|
3713
|
+
const onUp = () => {
|
|
3714
|
+
handle.classList.remove('dragging');
|
|
3715
|
+
split.classList.remove('resizing');
|
|
3716
|
+
document.body.classList.remove('resizing');
|
|
3717
|
+
document.removeEventListener('mousemove', onMove);
|
|
3718
|
+
document.removeEventListener('mouseup', onUp);
|
|
3719
|
+
kbSaveRefs();
|
|
3720
|
+
syncRefsValue();
|
|
3721
|
+
};
|
|
3722
|
+
document.addEventListener('mousemove', onMove);
|
|
3723
|
+
document.addEventListener('mouseup', onUp);
|
|
3724
|
+
});
|
|
3725
|
+
handle.addEventListener('dblclick', () => {
|
|
3726
|
+
kbRefsWidth = null;
|
|
3727
|
+
split.style.removeProperty('--kb-refs-width');
|
|
3728
|
+
kbSaveRefs();
|
|
3729
|
+
syncRefsValue();
|
|
3730
|
+
});
|
|
3731
|
+
// The keyboard path the shell's own dividers have (app.js): the arrows step the width, Shift steps
|
|
3732
|
+
// further, Enter restores the default. Folded, the column has no width to change.
|
|
3733
|
+
handle.addEventListener('keydown', (e) => {
|
|
3734
|
+
const isArrow = e.key === 'ArrowLeft' || e.key === 'ArrowRight';
|
|
3735
|
+
const isReset = e.key === 'Enter';
|
|
3736
|
+
if (!isArrow && !isReset) return;
|
|
3737
|
+
e.preventDefault();
|
|
3738
|
+
e.stopPropagation();
|
|
3739
|
+
if (kbRefsCollapsed) return;
|
|
3740
|
+
if (isReset) {
|
|
3741
|
+
kbRefsWidth = null;
|
|
3742
|
+
split.style.removeProperty('--kb-refs-width');
|
|
3743
|
+
} else {
|
|
3744
|
+
const from = kbRefsWidth ?? split.querySelector('.kb-refs-host').getBoundingClientRect().width;
|
|
3745
|
+
const step = (e.key === 'ArrowRight' ? 1 : -1) * (e.shiftKey ? 40 : 12);
|
|
3746
|
+
kbRefsWidth = Math.max(KB_REFS_MIN, Math.min(KB_REFS_MAX, from + step));
|
|
3747
|
+
split.style.setProperty('--kb-refs-width', kbRefsWidth + 'px');
|
|
3748
|
+
}
|
|
3749
|
+
kbSaveRefs();
|
|
3750
|
+
syncRefsValue();
|
|
3751
|
+
});
|
|
3752
|
+
}
|
|
3753
|
+
|
|
3026
3754
|
/** Identity of what the viewer host is showing. `blobSha256` is in the key because a hand-edited
|
|
3027
3755
|
* manifest (and, later, Stage D) can swap a row's bytes without changing its sourceId. */
|
|
3028
3756
|
function kbViewKey(st) {
|
|
3029
|
-
|
|
3757
|
+
// BOTH generations. The pinned one because a citation must reload as its own version rather than
|
|
3758
|
+
// inherit whichever is current; the current one because the chip is decided at read time, so a
|
|
3759
|
+
// publish landing while a cited page is open has to re-key and re-evaluate it. Keying on the
|
|
3760
|
+
// pinned id alone (the first cut) meant a page that BECAME superseded sat there unlabelled.
|
|
3761
|
+
if (viewer.mode === 'page') {
|
|
3762
|
+
const curGen = st.currentGeneration ? st.currentGeneration.generationId : '';
|
|
3763
|
+
return 'page:' + (viewer.generationId || curGen) + ':' + curGen + ':' + (viewer.slug || '');
|
|
3764
|
+
}
|
|
3030
3765
|
const row = viewer.mode === 'file' ? st.sources.find((s) => s.sourceId === viewer.sourceId) : null;
|
|
3031
3766
|
const gen = viewer.mode === 'graph' && st.currentGeneration ? st.currentGeneration.generationId : '';
|
|
3032
3767
|
return [current && current.id, viewer.mode, viewer.sourceId || '', row ? row.blobSha256 : '', gen].join('|');
|
|
@@ -3038,6 +3773,7 @@
|
|
|
3038
3773
|
setViewer({ mode: 'graph', sourceId: null });
|
|
3039
3774
|
}
|
|
3040
3775
|
kbEnsureShell();
|
|
3776
|
+
kbPaintStepHead(st); // the source count lives up there now, so it tracks the same state
|
|
3041
3777
|
const refsHost = $wsKnowledge.querySelector('.kb-refs-host');
|
|
3042
3778
|
const viewHost = kbViewHost();
|
|
3043
3779
|
|
|
@@ -3082,10 +3818,12 @@
|
|
|
3082
3818
|
}
|
|
3083
3819
|
} else if (viewer.mode === 'page') {
|
|
3084
3820
|
if (viewHost) viewHost.innerHTML = kbPageLoading();
|
|
3085
|
-
kbLoadPage(current, viewer.slug);
|
|
3821
|
+
kbLoadPage(current, viewer.slug, viewer.generationId || null);
|
|
3086
3822
|
} else if (viewHost) {
|
|
3087
3823
|
if (!st.currentGeneration) {
|
|
3824
|
+
kbGraphIndex = null; // nothing organized, so no overview to offer
|
|
3088
3825
|
viewHost.innerHTML = kbGraphEmpty(st);
|
|
3826
|
+
kbPaintStepHead(st);
|
|
3089
3827
|
} else {
|
|
3090
3828
|
viewHost.innerHTML = kbGraphLoading();
|
|
3091
3829
|
kbLoadGraph(current);
|
|
@@ -3101,7 +3839,7 @@
|
|
|
3101
3839
|
if (kbAdjustActive()) return; // a failed /status poll must not wipe an in-use Adjust box (draft/focus/in-flight)
|
|
3102
3840
|
kbEnsureShell();
|
|
3103
3841
|
const refsHost = $wsKnowledge.querySelector('.kb-refs-host');
|
|
3104
|
-
refsHost.innerHTML = '<section class="kb-col"
|
|
3842
|
+
refsHost.innerHTML = '<section class="kb-col">' +
|
|
3105
3843
|
`<div class="kb-refs-body">${inner}</div></section>`;
|
|
3106
3844
|
lastRefsHtml = null;
|
|
3107
3845
|
const host = kbViewHost();
|
|
@@ -3359,6 +4097,14 @@
|
|
|
3359
4097
|
const nodeEl = e.target.closest('[data-kb-node]');
|
|
3360
4098
|
if (nodeEl) { setViewer({ mode: 'page', slug: nodeEl.getAttribute('data-kb-node') }); if (knowledgeState) paintKnowledge(knowledgeState); return; }
|
|
3361
4099
|
if (e.target.closest('[data-kb-graph-retry]')) { setViewer({ mode: 'graph', sourceId: null }); if (knowledgeState) paintKnowledge(knowledgeState); return; }
|
|
4100
|
+
// The cited version is gone, and the user asked for today's instead. Re-open the SAME page with no
|
|
4101
|
+
// generation — the substitution this feature refuses to make silently is exactly the one it should
|
|
4102
|
+
// make when asked out loud.
|
|
4103
|
+
if (e.target.closest('[data-kb-open-current]')) {
|
|
4104
|
+
const slug = viewer.slug;
|
|
4105
|
+
if (slug) { setViewer({ mode: 'page', slug, sourceId: null, generationId: null }); if (knowledgeState) paintKnowledge(knowledgeState); }
|
|
4106
|
+
return;
|
|
4107
|
+
}
|
|
3362
4108
|
if (e.target.closest('[data-kb-close]')) {
|
|
3363
4109
|
const wasOpen = viewer.sourceId;
|
|
3364
4110
|
setViewer({ mode: 'graph', sourceId: null });
|
|
@@ -3692,15 +4438,29 @@
|
|
|
3692
4438
|
// Each label is EXACTLY the header the file will carry, so the picker is a preview of the bill
|
|
3693
4439
|
// rather than a glossary of it. What Grade and Type mean for the ROWS — that picking them
|
|
3694
4440
|
// subdivides the bill — is the dialog's `sub`, because that is the part a label cannot say.
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
{
|
|
3702
|
-
{
|
|
3703
|
-
|
|
4441
|
+
// The three MEASURE labels are per unit system, exactly as `server/bom-units.ts` spells them — the
|
|
4442
|
+
// picker promises to be a preview of the bill's header, and a preview in the wrong denomination is
|
|
4443
|
+
// worse than no preview. `value` is the WIRE id and does not move: `lbft` names the slot, not the
|
|
4444
|
+
// unit, and it travels in the export request and in a remembered column selection, so renaming it
|
|
4445
|
+
// would silently discard the picks of everyone who had chosen that column.
|
|
4446
|
+
const BOM_MEASURE_LABELS = {
|
|
4447
|
+
'ft-in': { length: 'Length (ft)', lbft: 'lb/ft', weight: 'Weight (lb)' },
|
|
4448
|
+
mm: { length: 'Length (mm)', lbft: 'kg/m', weight: 'Weight (kg)' },
|
|
4449
|
+
};
|
|
4450
|
+
const bomColumns = (units) => {
|
|
4451
|
+
const m = BOM_MEASURE_LABELS[units] || BOM_MEASURE_LABELS['ft-in'];
|
|
4452
|
+
return [
|
|
4453
|
+
{ value: 'profile', label: 'Profile' },
|
|
4454
|
+
{ value: 'grade', label: 'Grade' },
|
|
4455
|
+
{ value: 'type', label: 'Type' },
|
|
4456
|
+
{ value: 'qty', label: 'Qty' },
|
|
4457
|
+
{ value: 'length', label: m.length },
|
|
4458
|
+
{ value: 'lbft', label: m.lbft },
|
|
4459
|
+
{ value: 'weight', label: m.weight },
|
|
4460
|
+
];
|
|
4461
|
+
};
|
|
4462
|
+
/** The units this project's bill is written in: the server's answer, else the client's own copy. */
|
|
4463
|
+
const bomUnits = () => exportUnits ?? (current && current.displayUnits === 'mm' ? 'mm' : 'ft-in');
|
|
3704
4464
|
const BOM_DESCRIPTIVE = ['profile', 'grade', 'type'];
|
|
3705
4465
|
const DEFAULT_BOM_FORMATS = ['csv', 'xlsx'];
|
|
3706
4466
|
const DEFAULT_BOM_COLUMNS = ['profile', 'qty', 'length', 'lbft', 'weight'];
|
|
@@ -3723,7 +4483,13 @@
|
|
|
3723
4483
|
// and the descriptive rule, and only this message names the real conflict and both ways out —
|
|
3724
4484
|
// and adding Profile satisfies the other rule too, where adding Grade would earn a second refusal.
|
|
3725
4485
|
if (columns.includes('lbft') && !columns.includes('profile')) {
|
|
3726
|
-
|
|
4486
|
+
// The label the reader is looking at, taken from the same table the checkbox took it from —
|
|
4487
|
+
// never a literal. Telling someone with a `kg/m` column to reconsider their `lb/ft` is a
|
|
4488
|
+
// refusal about a column that is not on their screen, and the two strings drifting apart is
|
|
4489
|
+
// exactly what a hardcoded one guarantees. (Design review; the server's own copy of this rule
|
|
4490
|
+
// takes the same care.)
|
|
4491
|
+
const uw = bomColumns(bomUnits()).find((c) => c.value === 'lbft').label;
|
|
4492
|
+
return `${uw} is a property of the profile — pick Profile too, or drop ${uw}.`;
|
|
3727
4493
|
}
|
|
3728
4494
|
if (!columns.some((c) => BOM_DESCRIPTIVE.includes(c))) {
|
|
3729
4495
|
return 'Pick at least one of Profile, Grade or Type — a bill has to say what the material is.';
|
|
@@ -3796,7 +4562,7 @@
|
|
|
3796
4562
|
{
|
|
3797
4563
|
name: 'columns', label: 'Columns', type: 'checklist', compact: true,
|
|
3798
4564
|
value: (last.columns || DEFAULT_BOM_COLUMNS).join(','),
|
|
3799
|
-
options:
|
|
4565
|
+
options: bomColumns(bomUnits()),
|
|
3800
4566
|
},
|
|
3801
4567
|
],
|
|
3802
4568
|
});
|
|
@@ -3813,6 +4579,87 @@
|
|
|
3813
4579
|
return options;
|
|
3814
4580
|
}
|
|
3815
4581
|
|
|
4582
|
+
/**
|
|
4583
|
+
* How a unit system is NAMED in a sentence.
|
|
4584
|
+
*
|
|
4585
|
+
* The editor's own Units control offers "ft-in" and "mm", so those are the words a user has already
|
|
4586
|
+
* met for this setting. A card that invented a third vocabulary ("imperial", "metric") would be
|
|
4587
|
+
* describing the same switch in language the switch itself does not use.
|
|
4588
|
+
*/
|
|
4589
|
+
const unitsWord = (u) => (u === 'mm' ? 'mm' : 'ft-in');
|
|
4590
|
+
|
|
4591
|
+
/**
|
|
4592
|
+
* A file action — Open or Reveal — as the ONE place either is built (#1108).
|
|
4593
|
+
*
|
|
4594
|
+
* WHY A PRODUCER RATHER THAN A GUARD. These two buttons were hand-rolled in five places, nine copies
|
|
4595
|
+
* in all, and four of them had shipped without an Instructor carrier: the `?` list could neither
|
|
4596
|
+
* describe nor focus them. The obvious fix is to add the missing ids and write a check that hunts for
|
|
4597
|
+
* the next omission — and that check is a hunt through arbitrary source for markup, which four review
|
|
4598
|
+
* rounds showed can always be written in a shape the hunter does not recognise.
|
|
4599
|
+
*
|
|
4600
|
+
* So the shape is fixed here instead, and three defects stop being possible rather than detectable:
|
|
4601
|
+
*
|
|
4602
|
+
* OPEN AND REVEAL CANNOT BE SWAPPED. The command id is DERIVED from `action` along with the
|
|
4603
|
+
* attribute that makes the button do the thing; one argument decides both, so they cannot disagree.
|
|
4604
|
+
* A carrier naming the opposite capability is the worst version of this bug — perfectly registered,
|
|
4605
|
+
* and it narrates and activates the wrong thing.
|
|
4606
|
+
*
|
|
4607
|
+
* THE INSTANCE CANNOT BE EMPTY OR ABSENT. It throws. Every one of these buttons is accessibly named
|
|
4608
|
+
* just "Open" or "Reveal", so without an instance the `?` list offers one identical nameless
|
|
4609
|
+
* sentence per rendered file — present, registered, and useless.
|
|
4610
|
+
*
|
|
4611
|
+
* THE CARRIER CANNOT BE FORGOTTEN, because there is no longer a version of this markup without it.
|
|
4612
|
+
*
|
|
4613
|
+
* `instance` is what the USER would call the file — a bill's row label, a card's name and format —
|
|
4614
|
+
* never the glyph.
|
|
4615
|
+
*/
|
|
4616
|
+
function fileActionButton(action, { kind, instance, cls = 'e-link', tip, renderThumb = false }) {
|
|
4617
|
+
const open = action === 'open';
|
|
4618
|
+
if (action !== 'open' && action !== 'reveal') throw new Error(`workspaces: unknown file action "${action}"`);
|
|
4619
|
+
const name = String(instance == null ? '' : instance).trim();
|
|
4620
|
+
// A THROW, not a fallback. A file action with no instance is not a degraded button, it is an entry
|
|
4621
|
+
// the Instructor cannot tell apart from every other one — and a silent fallback would put exactly
|
|
4622
|
+
// that into the `?` list while looking like it worked.
|
|
4623
|
+
if (!name) throw new Error(`workspaces: a ${action} file action needs the file's name as its instance`);
|
|
4624
|
+
// ONE `open` STILL DECIDES BOTH HALVES — but each command id is now a LITERAL, because
|
|
4625
|
+
// `verify:carrier-escaping` forbids interpolation before the `#` and is right to: an id assembled
|
|
4626
|
+
// at runtime defeats `commands.js`'s charset validation, and `verify:command-registry` can no
|
|
4627
|
+
// longer resolve it back to a `def()`. The first cut wrote `shell.export-${open ? … }#` and turned
|
|
4628
|
+
// that guard red. Branching the whole fragment keeps the anti-swap property (the command and the
|
|
4629
|
+
// attribute that makes the button DO the thing are still chosen by the same expression, so they
|
|
4630
|
+
// cannot disagree) while leaving both ids static. (pr-review-toolkit.)
|
|
4631
|
+
const carrier = open
|
|
4632
|
+
? `data-command-id="shell.export-open#${escapeAttr(name)}" data-openfile="${escapeAttr(kind)}"`
|
|
4633
|
+
: `data-command-id="shell.export-reveal#${escapeAttr(name)}" data-reveal="${escapeAttr(kind)}"`;
|
|
4634
|
+
return `<button ${carrier}`
|
|
4635
|
+
+ ` data-command-instance-label="${escapeAttr(name)}"`
|
|
4636
|
+
+ ` type="button" class="${escapeAttr(cls)}"`
|
|
4637
|
+
+ (renderThumb ? ' data-render-thumb' : '')
|
|
4638
|
+
+ ` data-tip="${escapeAttr(tip || (open ? 'Open in its default app' : 'Show the file in its folder'))}">`
|
|
4639
|
+
// THE CONTENT IS CHOSEN HERE, never supplied. An earlier cut took a `body` string and appended
|
|
4640
|
+
// it raw, which handed every caller the whole tag back — close the button, open another, and
|
|
4641
|
+
// you have a second file action with no carrier, produced by the one function whose point is
|
|
4642
|
+
// that it cannot. Three fixed shapes cover every caller today, and a fourth needs a branch
|
|
4643
|
+
// here rather than an argument. (Review round 5 — Codex.)
|
|
4644
|
+
//
|
|
4645
|
+
// The attribute names are deliberately NOT spelled in this comment: the guard over this file
|
|
4646
|
+
// is a plain word count, and teaching it to skip comments would be the parsing this design
|
|
4647
|
+
// exists to stop needing.
|
|
4648
|
+
+ (renderThumb ? '<img alt="">' : (open ? '⧉ Open' : '▤ Reveal'))
|
|
4649
|
+
+ `</button>`;
|
|
4650
|
+
}
|
|
4651
|
+
|
|
4652
|
+
/**
|
|
4653
|
+
* Open + Reveal for one file, in that order — the pair every receipt row shows.
|
|
4654
|
+
*
|
|
4655
|
+
* A braced `function`, not an arrow: the tests lift this seam out of the real source and run it,
|
|
4656
|
+
* and the lifter brace-matches a declaration. An arrow assigned to a `const` lifts as a fragment
|
|
4657
|
+
* that does not parse, so the test would fall back to a stub of its own and prove nothing.
|
|
4658
|
+
*/
|
|
4659
|
+
function fileActionPair(kind, instance) {
|
|
4660
|
+
return fileActionButton('open', { kind, instance }) + fileActionButton('reveal', { kind, instance });
|
|
4661
|
+
}
|
|
4662
|
+
|
|
3816
4663
|
/**
|
|
3817
4664
|
* The BOM card's state — the same {meta, disabled, tip} shape as renderCardState, and for the same
|
|
3818
4665
|
* reason: it fronts several export kinds, so `exportState[c.kind]` cannot describe it.
|
|
@@ -3831,17 +4678,46 @@
|
|
|
3831
4678
|
const done = BOM_ROWS
|
|
3832
4679
|
.filter((row) => exportState[row.kind] && exportState[row.kind].exportedAt)
|
|
3833
4680
|
.map((row) => ({ ...row, exportedAt: exportState[row.kind].exportedAt }));
|
|
3834
|
-
|
|
4681
|
+
// A kind the server reports as exported in the OTHER unit system. It has no `exportedAt` — the
|
|
4682
|
+
// file is not current — so it is absent from `done` above and would otherwise vanish into "not
|
|
4683
|
+
// exported yet", which is the one thing this state must not read as. That file exists, it is a
|
|
4684
|
+
// valid export of this approved model, and it says "Weight (lb)" at the top: a card reporting it
|
|
4685
|
+
// as never-exported invites a second copy without ever explaining why the first was wrong.
|
|
4686
|
+
const stale = BOM_ROWS
|
|
4687
|
+
.filter((row) => exportState[row.kind] && exportState[row.kind].staleUnits && !exportState[row.kind].exportedAt)
|
|
4688
|
+
.map((row) => ({ ...row, was: exportState[row.kind].staleUnits, now: exportState[row.kind].units }));
|
|
4689
|
+
if (!done.length && !stale.length) {
|
|
3835
4690
|
return { meta: '<span class="e-status">not exported yet</span>', disabled: false, tip: '' };
|
|
3836
4691
|
}
|
|
4692
|
+
// PER ROW, not per card: the three BOM kinds export independently, so a detailer can re-export the
|
|
4693
|
+
// workbook after switching and leave the CSV behind. A single card-level banner could not describe
|
|
4694
|
+
// that; a note under each affected row describes every case. (Design review.)
|
|
4695
|
+
// Both rows' file actions are Instructor carriers. `data-command-instance-label` is not
|
|
4696
|
+
// decoration: every one of these buttons is accessibly named "⧉ Open" or "▤ Reveal", so without
|
|
4697
|
+
// it `?` fills {instance} with the glyph and offers three identical sentences for three
|
|
4698
|
+
// different files. The instance a user cares about is WHICH BILL, so the row label is the name.
|
|
4699
|
+
const staleRows = stale.map((row) =>
|
|
4700
|
+
`<div class="e-render-entry">` +
|
|
4701
|
+
`<div class="e-render-row">` +
|
|
4702
|
+
`<span class="e-done"><span class="chk">✓</span> ${escapeHtml(row.label)}</span>` +
|
|
4703
|
+
`<span class="e-links">` +
|
|
4704
|
+
fileActionPair(row.kind, row.label) +
|
|
4705
|
+
`</span>` +
|
|
4706
|
+
`</div>` +
|
|
4707
|
+
// A THIRD register, quieter than `.e-receipt.partial`'s amber. Amber says "this file has a
|
|
4708
|
+
// defect"; this one has none — it is a complete, correct export of a unit system the project
|
|
4709
|
+
// has stopped using. Currency and success are different questions, which is why the ✓ above
|
|
4710
|
+
// stays exactly as it is: the export DID succeed.
|
|
4711
|
+
`<div class="e-receipt stale"><span>Exported in ${escapeHtml(unitsWord(row.was))} — ` +
|
|
4712
|
+
`this project now uses ${escapeHtml(unitsWord(row.now))}. Re-export below to match.</span></div>` +
|
|
4713
|
+
`</div>`).join('');
|
|
3837
4714
|
const rows = done.map((row) =>
|
|
3838
4715
|
`<div class="e-render-row">` +
|
|
3839
4716
|
`<span class="e-done"><span class="chk">✓</span> ${escapeHtml(row.label)} <span class="t">${escapeHtml(hhmm(row.exportedAt))}</span></span>` +
|
|
3840
4717
|
`<span class="e-links">` +
|
|
3841
|
-
|
|
3842
|
-
`<button type="button" class="e-link" data-reveal="${escapeAttr(row.kind)}" data-tip="Show the file in its folder">▤ Reveal</button>` +
|
|
4718
|
+
fileActionPair(row.kind, row.label) +
|
|
3843
4719
|
`</span>` +
|
|
3844
|
-
`</div>`).join('');
|
|
4720
|
+
`</div>`).join('') + staleRows;
|
|
3845
4721
|
// At most three rows, so this never scrolls — but it reuses the render card's themed scroller
|
|
3846
4722
|
// verbatim rather than inventing a second way to list produced files.
|
|
3847
4723
|
return {
|
|
@@ -3894,6 +4770,92 @@
|
|
|
3894
4770
|
return receipt && receipt.approvedAt === current.approvedAt ? receipt : null;
|
|
3895
4771
|
}
|
|
3896
4772
|
|
|
4773
|
+
/**
|
|
4774
|
+
* The export kinds a CARD stands for.
|
|
4775
|
+
*
|
|
4776
|
+
* Usually itself, but not always, and the exceptions are why this is a lookup rather than an
|
|
4777
|
+
* assumption: the render card's id is `render` while the receipts it owns are keyed `render-png`
|
|
4778
|
+
* and `render-mp4`, and the BOM card's id is `bom` against `bom-csv`/`bom-xlsx`/`bom-html`. Only
|
|
4779
|
+
* the render mapping is listed, because only the IFC and render cards carry an omission line
|
|
4780
|
+
* today; a second multi-kind card needs its own entry here, not a guess.
|
|
4781
|
+
*
|
|
4782
|
+
* That mismatch is not cosmetic: it silently made `omittedHtml('render', …)` look up an export
|
|
4783
|
+
* state that never exists, so a render which left members out reported nothing at all, before OR
|
|
4784
|
+
* after a reload. Found in review. Written as a lookup rather than a special case at the call site
|
|
4785
|
+
* so the next reader sees the two names in one place.
|
|
4786
|
+
*/
|
|
4787
|
+
function omittedKindsFor(kind) {
|
|
4788
|
+
return kind === 'render' ? ['render-png', 'render-mp4'] : [kind];
|
|
4789
|
+
}
|
|
4790
|
+
|
|
4791
|
+
/**
|
|
4792
|
+
* What the exported artifact(s) for this card do NOT contain (#1156a).
|
|
4793
|
+
*
|
|
4794
|
+
* The export used to REFUSE a model with an unresolved endpoint elevation; now it writes the file
|
|
4795
|
+
* and leaves those members out. The toast that said so is gone on the next click, and the `.ifc`
|
|
4796
|
+
* travels on without it — so this card, which is what a user comes back to, has to say it. The
|
|
4797
|
+
* receipt is where it survives a reload.
|
|
4798
|
+
*
|
|
4799
|
+
* UNIONED BY MEMBER, never summed. A render publishes one receipt PER VIEWPOINT and every
|
|
4800
|
+
* viewpoint of one render omits the SAME members, because an omission is a fact about the
|
|
4801
|
+
* document rather than about the picture. Adding the counts would report three missing members
|
|
4802
|
+
* for one missing member rendered three ways.
|
|
4803
|
+
*
|
|
4804
|
+
* SILENT when a receipt records no omissions, and silent when it records NOTHING — `recorded:
|
|
4805
|
+
* false` means this receipt predates the field or carries a value the server could not read, which
|
|
4806
|
+
* is a question nobody can answer from here and not a clean bill. Printing "0 missing" for either
|
|
4807
|
+
* would be the confident-green-zero this epic has already shipped once.
|
|
4808
|
+
*
|
|
4809
|
+
* Amber, like `.e-receipt.partial`, because it is the same news: this file is not the whole model.
|
|
4810
|
+
*/
|
|
4811
|
+
function omittedHtml(kind, approved) {
|
|
4812
|
+
if (!approved || !exportState) return '';
|
|
4813
|
+
const byMember = new Map();
|
|
4814
|
+
let total = 0;
|
|
4815
|
+
for (const k of omittedKindsFor(kind)) {
|
|
4816
|
+
const entry = exportState[k];
|
|
4817
|
+
if (!entry) continue;
|
|
4818
|
+
const sources = Array.isArray(entry.variants) && entry.variants.length ? entry.variants : [entry];
|
|
4819
|
+
for (const source of sources) {
|
|
4820
|
+
const omitted = source && source.omitted;
|
|
4821
|
+
if (!omitted || !omitted.recorded) continue;
|
|
4822
|
+
for (const row of (omitted.rows || [])) if (row && row.memberId) byMember.set(row.memberId, row.reason);
|
|
4823
|
+
// The true count can exceed the rows the receipt stores (they are capped), so take the
|
|
4824
|
+
// largest any viewpoint reports rather than the size of the union.
|
|
4825
|
+
if (typeof omitted.total === 'number' && omitted.total > total) total = omitted.total;
|
|
4826
|
+
}
|
|
4827
|
+
}
|
|
4828
|
+
if (!total) return '';
|
|
4829
|
+
// Grouped by REASON, because they are answered in different places: a height is a question for
|
|
4830
|
+
// the drawings, a size is one for the engineer. One number would put them back together, which
|
|
4831
|
+
// is the conflation the reason codes exist to undo.
|
|
4832
|
+
const byReason = {};
|
|
4833
|
+
for (const reason of byMember.values()) if (reason) byReason[reason] = (byReason[reason] || 0) + 1;
|
|
4834
|
+
const WORDS = {
|
|
4835
|
+
'unknown-elevation': 'no known height',
|
|
4836
|
+
'unknown-profile': 'no resolved section size',
|
|
4837
|
+
// "cross-section", not "footprint": to a detailer a footprint is a building's plan outline, and
|
|
4838
|
+
// what is actually missing is a catalogued section shape. (Design review.)
|
|
4839
|
+
'no-footprint': 'no tabulated cross-section',
|
|
4840
|
+
unplaceable: 'geometry that could not be placed',
|
|
4841
|
+
'unregistered-view': 'a source view that is not registered to the model',
|
|
4842
|
+
'view-scale-invalid': 'a source view with no valid drawing scale',
|
|
4843
|
+
'cross-view-conflict': 'source views that disagree on placement',
|
|
4844
|
+
'placement-evidence-conflict': 'invalid scale and conflicting placement evidence',
|
|
4845
|
+
};
|
|
4846
|
+
const parts = Object.keys(byReason).sort().map((r) => `${byReason[r]} with ${WORDS[r] || r}`);
|
|
4847
|
+
// The stored rows are capped, so the parts can add up to less than the total. Say so rather than
|
|
4848
|
+
// letting them silently contradict the headline.
|
|
4849
|
+
const listed = byMember.size;
|
|
4850
|
+
const detail = parts.length
|
|
4851
|
+
? ` — ${parts.join(', ')}${listed < total ? `, of the ${listed} recorded` : ''}`
|
|
4852
|
+
: '';
|
|
4853
|
+
return `<div class="e-receipt partial">` +
|
|
4854
|
+
`<span role="status" aria-live="polite">` +
|
|
4855
|
+
`${total} member${total === 1 ? '' : 's'} not in this file${escapeHtml(detail)}` +
|
|
4856
|
+
`</span></div>`;
|
|
4857
|
+
}
|
|
4858
|
+
|
|
3897
4859
|
function receiptHtml(kind, approved) {
|
|
3898
4860
|
const receipt = approved ? currentReceipt(kind) : null;
|
|
3899
4861
|
if (!receipt) return '';
|
|
@@ -3916,30 +4878,9 @@
|
|
|
3916
4878
|
: `${base}/export-host/${encodeURIComponent(host)}${qs}`;
|
|
3917
4879
|
};
|
|
3918
4880
|
|
|
3919
|
-
/** One chooser row
|
|
4881
|
+
/** One chooser row. Readiness is deliberately checked only after the user reviews the send. */
|
|
3920
4882
|
function hostRowOption(host) {
|
|
3921
|
-
|
|
3922
|
-
const st = hostState(host);
|
|
3923
|
-
if (!st || st.state === 'checking') {
|
|
3924
|
-
return { value: host, label, pickable: false, status: { tone: 'checking', text: 'Checking…' } };
|
|
3925
|
-
}
|
|
3926
|
-
if (st.ok && st.state === 'ready') {
|
|
3927
|
-
const v = hostVersion(st);
|
|
3928
|
-
return { value: host, label, pickable: true, status: { tone: 'ready', text: `Ready${v ? ` · ${label} ${v}` : ''}` } };
|
|
3929
|
-
}
|
|
3930
|
-
const recovery = st.recovery || { action: 'retry', label: 'Check again' };
|
|
3931
|
-
// Only offer to DO something we can actually do. Opening an application, loading a model or
|
|
3932
|
-
// closing a duplicate window are the user's to perform — the button that helps there is the one
|
|
3933
|
-
// that re-checks once they have. A bridge install we can genuinely run, so that one keeps its
|
|
3934
|
-
// real label. Labelling a re-check "Open Revit" would be a button that lies about its effect.
|
|
3935
|
-
const installs = recovery.action === 'install-bridge' || recovery.action === 'install-addin';
|
|
3936
|
-
return {
|
|
3937
|
-
value: host,
|
|
3938
|
-
label,
|
|
3939
|
-
pickable: false,
|
|
3940
|
-
status: { tone: 'blocked', text: st.message || `${label} can’t receive this model right now.` },
|
|
3941
|
-
action: { label: installs ? recovery.label : 'Check again' },
|
|
3942
|
-
};
|
|
4883
|
+
return { value: host, label: hostLabel(host), pickable: true };
|
|
3943
4884
|
}
|
|
3944
4885
|
|
|
3945
4886
|
const hostRowOptions = () => SEND_HOSTS.map((h) => hostRowOption(h.host));
|
|
@@ -3954,21 +4895,17 @@
|
|
|
3954
4895
|
/**
|
|
3955
4896
|
* Ask which applications should receive this model. Resolves to an array of host ids, or null.
|
|
3956
4897
|
*
|
|
3957
|
-
* Every destination is listed
|
|
3958
|
-
*
|
|
3959
|
-
* rows that cannot be ticked carry the reason and, where we can actually perform it, the fix.
|
|
4898
|
+
* Every destination is listed without probing AWARE or the host. The omission review is the first
|
|
4899
|
+
* external step; readiness is checked only by the authorized continuation after that review.
|
|
3960
4900
|
*/
|
|
3961
4901
|
async function askSendDestinations(projectId) {
|
|
3962
4902
|
if (!bridge.formModal) {
|
|
3963
|
-
|
|
3964
|
-
return ready.length === 1 ? ready : null;
|
|
4903
|
+
return null;
|
|
3965
4904
|
}
|
|
3966
4905
|
const remembered = hostChoices.get(projectId) || [];
|
|
3967
|
-
// Pre-tick
|
|
3968
|
-
|
|
3969
|
-
const
|
|
3970
|
-
const preTicked = remembered.filter(hostIsReady);
|
|
3971
|
-
const initial = (preTicked.length ? preTicked : readyHosts.slice(0, 1)).join(',');
|
|
4906
|
+
// Pre-tick remembered picks, else Tekla. Readiness has intentionally not been asked yet.
|
|
4907
|
+
const preTicked = remembered.filter((host) => SEND_HOSTS.some((row) => row.host === host));
|
|
4908
|
+
const initial = (preTicked.length ? preTicked : SEND_HOSTS.slice(0, 1).map((row) => row.host)).join(',');
|
|
3972
4909
|
const chosen = await bridge.formModal({
|
|
3973
4910
|
title: 'Send to a CAD application',
|
|
3974
4911
|
// The deliberate opposite of the Render dialog's "nothing in your model changes". This one
|
|
@@ -3996,29 +4933,6 @@
|
|
|
3996
4933
|
type: 'checklist',
|
|
3997
4934
|
value: initial,
|
|
3998
4935
|
options: hostRowOptions(),
|
|
3999
|
-
onAction: async (host) => {
|
|
4000
|
-
const st = hostState(host);
|
|
4001
|
-
const action = st && st.recovery ? st.recovery.action : 'retry';
|
|
4002
|
-
if (action === 'install-bridge' || action === 'install-addin') {
|
|
4003
|
-
try {
|
|
4004
|
-
await api(host === 'tekla'
|
|
4005
|
-
? '/api/tekla-readiness/setup'
|
|
4006
|
-
: `/api/host-readiness/${encodeURIComponent(host)}/setup`, { method: 'POST' });
|
|
4007
|
-
} catch (err) {
|
|
4008
|
-
// Report it and still re-probe: the install may have partly succeeded, and the fresh
|
|
4009
|
-
// readiness is a truer answer than either the old row or this error alone.
|
|
4010
|
-
showToast(err && err.message ? err.message : `Couldn’t install the ${hostLabel(host)} bridge.`, 'warn');
|
|
4011
|
-
}
|
|
4012
|
-
}
|
|
4013
|
-
hostReadinessStates = { ...hostReadinessStates, [host]: { ok: false, state: 'checking' } };
|
|
4014
|
-
const fresh = await probeHost(host);
|
|
4015
|
-
hostReadinessStates = { ...hostReadinessStates, [host]: fresh };
|
|
4016
|
-
// Deliberately does NOT repaint the card behind the dialog. That repaint restores focus to
|
|
4017
|
-
// the card's own button (restoreExportFocus), which yanks it out of the open modal — the
|
|
4018
|
-
// user pressed a button INSIDE the dialog and focus landed behind it. The card is brought
|
|
4019
|
-
// up to date once the dialog closes instead; see chooseAndSend.
|
|
4020
|
-
return hostRowOptions();
|
|
4021
|
-
},
|
|
4022
4936
|
}],
|
|
4023
4937
|
});
|
|
4024
4938
|
if (!chosen) return null;
|
|
@@ -4030,6 +4944,155 @@
|
|
|
4030
4944
|
return picked;
|
|
4031
4945
|
}
|
|
4032
4946
|
|
|
4947
|
+
const activeProjectHostBakeConsents = new Map();
|
|
4948
|
+
|
|
4949
|
+
function releaseProjectHostBakeConsentsOnPageHide() {
|
|
4950
|
+
for (const [token, owner] of activeProjectHostBakeConsents) {
|
|
4951
|
+
fetch(`/api/projects/${encodeURIComponent(owner.projectId)}/host-bake-consent?appId=${encodeURIComponent(owner.appId)}`, {
|
|
4952
|
+
method: 'DELETE', keepalive: true,
|
|
4953
|
+
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
4954
|
+
}).catch(() => {});
|
|
4955
|
+
}
|
|
4956
|
+
activeProjectHostBakeConsents.clear();
|
|
4957
|
+
}
|
|
4958
|
+
|
|
4959
|
+
async function cancelProjectHostBakeConsent(projectId, appId, token) {
|
|
4960
|
+
if (!token) return;
|
|
4961
|
+
try {
|
|
4962
|
+
await api(`/api/projects/${encodeURIComponent(projectId)}/host-bake-consent?appId=${encodeURIComponent(appId)}`, {
|
|
4963
|
+
method: 'DELETE',
|
|
4964
|
+
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
4965
|
+
});
|
|
4966
|
+
} catch (_) { /* best effort; consent and its source lease also expire server-side */ }
|
|
4967
|
+
finally { activeProjectHostBakeConsents.delete(token); }
|
|
4968
|
+
}
|
|
4969
|
+
|
|
4970
|
+
async function acknowledgeProjectHostBakeConsent(projectId, appId, token) {
|
|
4971
|
+
if (!token) return;
|
|
4972
|
+
try {
|
|
4973
|
+
await fetch(`/api/projects/${encodeURIComponent(projectId)}/host-bake-consent/acknowledge?appId=${encodeURIComponent(appId)}`, {
|
|
4974
|
+
method: 'POST',
|
|
4975
|
+
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
4976
|
+
body: '{}',
|
|
4977
|
+
});
|
|
4978
|
+
} catch (_) { /* a lost acknowledgement deliberately leaves the replay tombstone in place */ }
|
|
4979
|
+
finally { activeProjectHostBakeConsents.delete(token); }
|
|
4980
|
+
}
|
|
4981
|
+
|
|
4982
|
+
async function releaseCapturedSources(projectId, handles) {
|
|
4983
|
+
await Promise.allSettled(handles.map((handleId) => api(
|
|
4984
|
+
`/api/projects/${encodeURIComponent(projectId)}/export-captures/${encodeURIComponent(handleId)}/release`,
|
|
4985
|
+
{ method: 'POST' },
|
|
4986
|
+
)));
|
|
4987
|
+
}
|
|
4988
|
+
|
|
4989
|
+
async function preflightHostSends(hosts, projectId, appId, sourceHandles) {
|
|
4990
|
+
const results = await Promise.allSettled(hosts.map((host, index) => api(
|
|
4991
|
+
hostSendUrl(host, projectId, appId, sourceHandles[index]),
|
|
4992
|
+
{ method: 'POST', body: JSON.stringify({ preflight: true }) },
|
|
4993
|
+
)));
|
|
4994
|
+
const reviews = results.filter((result) => result.status === 'fulfilled').map((result) => result.value);
|
|
4995
|
+
reviews.forEach((review) => activeProjectHostBakeConsents.set(review.consent, { projectId, appId }));
|
|
4996
|
+
if (reviews.length !== results.length) {
|
|
4997
|
+
await Promise.allSettled(reviews.map((review) => cancelProjectHostBakeConsent(projectId, appId, review.consent)));
|
|
4998
|
+
const failed = results.find((result) => result.status === 'rejected');
|
|
4999
|
+
const failure = failed && failed.reason;
|
|
5000
|
+
if (failure && failure.body && failure.body.code === 'host-bake-empty') {
|
|
5001
|
+
const error = new Error(failure.body.error || 'Nothing in this model can be sent.');
|
|
5002
|
+
error.hostBakeEmpty = failure.body;
|
|
5003
|
+
throw error;
|
|
5004
|
+
}
|
|
5005
|
+
throw failure || new Error('Couldn’t review every destination.');
|
|
5006
|
+
}
|
|
5007
|
+
const first = reviews[0];
|
|
5008
|
+
if (!first || reviews.some((review) => review.reviewDigest !== first.reviewDigest)) {
|
|
5009
|
+
await Promise.allSettled(reviews.map((review) => cancelProjectHostBakeConsent(projectId, appId, review && review.consent)));
|
|
5010
|
+
throw new Error('The destinations did not review the same model. Choose them again.');
|
|
5011
|
+
}
|
|
5012
|
+
return reviews;
|
|
5013
|
+
}
|
|
5014
|
+
|
|
5015
|
+
async function reserveProjectHostBakeConsents(projectId, appId, reviews) {
|
|
5016
|
+
return api(`/api/projects/${encodeURIComponent(projectId)}/host-bake-consents/reserve?appId=${encodeURIComponent(appId)}`, {
|
|
5017
|
+
method: 'POST',
|
|
5018
|
+
headers: {
|
|
5019
|
+
'content-type': 'application/json',
|
|
5020
|
+
'x-floless-host-bake-consents': reviews.map((review) => review.consent).join(','),
|
|
5021
|
+
},
|
|
5022
|
+
body: JSON.stringify({}),
|
|
5023
|
+
});
|
|
5024
|
+
}
|
|
5025
|
+
|
|
5026
|
+
async function confirmAggregateHostSend(hosts, review, changedClean = false) {
|
|
5027
|
+
const omitted = review.counts && Number(review.counts.omitted) || 0;
|
|
5028
|
+
if (!omitted && !changedClean) return true;
|
|
5029
|
+
const names = sequenceText(hosts);
|
|
5030
|
+
return (await bridge.formModal({
|
|
5031
|
+
title: changedClean ? 'Model changed — send the latest version?' : `Send with ${omitted} member${omitted === 1 ? '' : 's'} left out?`,
|
|
5032
|
+
sub: changedClean
|
|
5033
|
+
? `FloLess checked the latest approved model and found no omissions for ${names}.`
|
|
5034
|
+
: `The rest can be sent to ${names}. Previously baked parts for the members below may be removed from each open model.`,
|
|
5035
|
+
fields: omitted ? [{
|
|
5036
|
+
name: 'host-bake-omissions',
|
|
5037
|
+
type: 'omissions',
|
|
5038
|
+
label: 'Members left out',
|
|
5039
|
+
rows: review.skippedDetail || [],
|
|
5040
|
+
commandId: 'shell.host-bake-omissions',
|
|
5041
|
+
}] : [],
|
|
5042
|
+
okLabel: 'Continue',
|
|
5043
|
+
okCommandId: 'shell.host-send-continue',
|
|
5044
|
+
okCommandInstanceLabel: names,
|
|
5045
|
+
cancelCommandInstanceLabel: 'the CAD send review',
|
|
5046
|
+
danger: omitted > 0,
|
|
5047
|
+
safeDefault: true,
|
|
5048
|
+
modalState: changedClean ? 'stale' : 'review',
|
|
5049
|
+
modalMode: 'whole',
|
|
5050
|
+
returnFocusTo: $wsExports.querySelector('[data-export="send-host"]'),
|
|
5051
|
+
})) != null;
|
|
5052
|
+
}
|
|
5053
|
+
|
|
5054
|
+
async function showAggregateHostBakeEmpty(hosts, review) {
|
|
5055
|
+
await bridge.formModal({
|
|
5056
|
+
title: 'Nothing in this model can be sent',
|
|
5057
|
+
sub: `Every member is unresolved. Nothing was sent to ${sequenceText(hosts)}.`,
|
|
5058
|
+
fields: [{
|
|
5059
|
+
name: 'host-bake-omissions',
|
|
5060
|
+
type: 'omissions',
|
|
5061
|
+
label: 'Members left out',
|
|
5062
|
+
rows: review.skippedDetail || [],
|
|
5063
|
+
commandId: 'shell.host-bake-omissions',
|
|
5064
|
+
}],
|
|
5065
|
+
okLabel: 'Close',
|
|
5066
|
+
okCommandId: 'shell.dialog-close',
|
|
5067
|
+
okCommandInstanceLabel: 'the host-send review',
|
|
5068
|
+
cancelCommandInstanceLabel: 'the CAD send review',
|
|
5069
|
+
hideCancel: true,
|
|
5070
|
+
returnFocusTo: $wsExports.querySelector('[data-export="send-host"]'),
|
|
5071
|
+
modalState: 'review',
|
|
5072
|
+
modalMode: 'whole',
|
|
5073
|
+
});
|
|
5074
|
+
}
|
|
5075
|
+
|
|
5076
|
+
function hostBakeOmissionSummary(result) {
|
|
5077
|
+
const rows = Array.isArray(result && result.skippedDetail) ? result.skippedDetail : [];
|
|
5078
|
+
const counts = result && result.reviewCounts;
|
|
5079
|
+
if (!counts || !counts.omitted) return '';
|
|
5080
|
+
const words = {
|
|
5081
|
+
'unknown-elevation': 'no known height',
|
|
5082
|
+
'unknown-profile': 'no resolved section size',
|
|
5083
|
+
'no-footprint': 'no tabulated cross-section',
|
|
5084
|
+
unplaceable: 'geometry that could not be placed',
|
|
5085
|
+
'unregistered-view': 'an unregistered source view',
|
|
5086
|
+
'view-scale-invalid': 'no valid drawing scale',
|
|
5087
|
+
'cross-view-conflict': 'conflicting drawing views',
|
|
5088
|
+
'placement-evidence-conflict': 'conflicting placement evidence',
|
|
5089
|
+
};
|
|
5090
|
+
const grouped = {};
|
|
5091
|
+
rows.forEach((row) => { grouped[row.reason] = (grouped[row.reason] || 0) + 1; });
|
|
5092
|
+
const reasons = Object.entries(grouped).map(([reason, count]) => `${count} with ${words[reason] || 'an unresolved placement'}`);
|
|
5093
|
+
return `sent ${counts.buildable} of ${counts.requested} members; left out ${reasons.join(' and ') || counts.omitted + ' members'}`;
|
|
5094
|
+
}
|
|
5095
|
+
|
|
4033
5096
|
/**
|
|
4034
5097
|
* Send to each destination IN TURN.
|
|
4035
5098
|
*
|
|
@@ -4041,13 +5104,13 @@
|
|
|
4041
5104
|
* be minutes old by the time a third host's turn comes round, and an application closed since
|
|
4042
5105
|
* then must be reported rather than sent into.
|
|
4043
5106
|
*/
|
|
4044
|
-
async function sendToHosts(hosts, projectId, app, approvedAt, sourceHandles, sourceKind) {
|
|
4045
|
-
const busyKey = `${projectId}:send-host`;
|
|
4046
|
-
if (exportBusy.has(busyKey)) return;
|
|
4047
|
-
exportBusy.add(busyKey);
|
|
5107
|
+
async function sendToHosts(hosts, projectId, app, approvedAt, sourceHandles, sourceKind, reviews) {
|
|
4048
5108
|
const done = [];
|
|
4049
5109
|
const failed = [];
|
|
5110
|
+
const uncertain = [];
|
|
4050
5111
|
const aborted = [];
|
|
5112
|
+
let uncertainHost = null;
|
|
5113
|
+
let staleReview = false;
|
|
4051
5114
|
/** Has the sign-off this batch was aimed at moved on? Only answerable while it is still open. */
|
|
4052
5115
|
const approvalMoved = () => !!current && current.id === projectId && current.approvedAt !== approvedAt;
|
|
4053
5116
|
try {
|
|
@@ -4069,17 +5132,14 @@
|
|
|
4069
5132
|
if (approvalMoved()) { aborted.push(...hosts.slice(i)); break; }
|
|
4070
5133
|
sendProgress = { host, index: i + 1, total: hosts.length };
|
|
4071
5134
|
if (current && current.id === projectId && !$wsExports.hidden) paintExports(approvedAt);
|
|
4072
|
-
const fresh = await probeHost(host);
|
|
4073
|
-
hostReadinessStates = { ...hostReadinessStates, [host]: fresh };
|
|
4074
|
-
if (!fresh.ok) {
|
|
4075
|
-
failed.push({ host, error: fresh.message || `${hostLabel(host)} isn’t ready.` });
|
|
4076
|
-
continue;
|
|
4077
|
-
}
|
|
4078
|
-
// Again, immediately before dispatch: the probe above can take seconds against a cold
|
|
4079
|
-
// bridge, and that is the longest gap in this loop.
|
|
4080
5135
|
if (approvalMoved()) { aborted.push(...hosts.slice(i)); break; }
|
|
4081
5136
|
try {
|
|
4082
|
-
const res = await api(hostSendUrl(host, projectId, app, sourceHandles[i]), {
|
|
5137
|
+
const res = await api(hostSendUrl(host, projectId, app, sourceHandles[i]), {
|
|
5138
|
+
method: 'POST',
|
|
5139
|
+
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': reviews[i].consent },
|
|
5140
|
+
body: JSON.stringify({}),
|
|
5141
|
+
});
|
|
5142
|
+
await acknowledgeProjectHostBakeConsent(projectId, app, reviews[i].consent);
|
|
4083
5143
|
track('workspace_export', { app, kind: `send:${host}`, sourceKind });
|
|
4084
5144
|
let summary = null;
|
|
4085
5145
|
if (res.counts) {
|
|
@@ -4092,19 +5152,40 @@
|
|
|
4092
5152
|
summary = receiptSummary(exportReceipts.get(`${projectId}:send:${host}`), `send:${host}`);
|
|
4093
5153
|
}
|
|
4094
5154
|
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt });
|
|
4095
|
-
|
|
5155
|
+
const omissionText = hostBakeOmissionSummary(res);
|
|
5156
|
+
done.push({
|
|
5157
|
+
host,
|
|
5158
|
+
partial: !!omissionText || !!(summary && summary.partial),
|
|
5159
|
+
text: omissionText || (summary && summary.text),
|
|
5160
|
+
});
|
|
4096
5161
|
} catch (err) {
|
|
5162
|
+
if (err && err.body && ['host-bake-dispatch-uncertain', 'host-bake-result-unverified'].includes(err.body.code)) {
|
|
5163
|
+
const detail = err.body.error || (err && err.message) || String(err);
|
|
5164
|
+
uncertain.push({ host, error: detail });
|
|
5165
|
+
uncertainHost = host;
|
|
5166
|
+
aborted.push(...hosts.slice(i + 1));
|
|
5167
|
+
break;
|
|
5168
|
+
}
|
|
5169
|
+
if ((err instanceof TypeError && /failed to fetch|networkerror|load failed/i.test(err.message || ''))
|
|
5170
|
+
|| (err && err.body && err.body.code === 'response-unreadable')) {
|
|
5171
|
+
uncertain.push({ host, error: `FloLess lost the ${hostLabel(host)} response after dispatch. Check the open model before sending again.` });
|
|
5172
|
+
uncertainHost = host;
|
|
5173
|
+
aborted.push(...hosts.slice(i + 1));
|
|
5174
|
+
break;
|
|
5175
|
+
}
|
|
5176
|
+
if (err && err.body && ['host-bake-confirmation-stale', 'host-bake-preflight-required', 'stale-selection'].includes(err.body.code)) {
|
|
5177
|
+
staleReview = true;
|
|
5178
|
+
aborted.push(...hosts.slice(i));
|
|
5179
|
+
break;
|
|
5180
|
+
}
|
|
4097
5181
|
const detail = (err && err.body && err.body.error) || (err && err.message) || String(err);
|
|
4098
5182
|
failed.push({ host, error: detail });
|
|
4099
5183
|
}
|
|
4100
5184
|
}
|
|
4101
5185
|
} finally {
|
|
4102
|
-
await Promise.allSettled(
|
|
4103
|
-
|
|
4104
|
-
{ method: 'POST' },
|
|
4105
|
-
)));
|
|
5186
|
+
await Promise.allSettled(reviews.map((review) => cancelProjectHostBakeConsent(projectId, app, review.consent)));
|
|
5187
|
+
await releaseCapturedSources(projectId, sourceHandles);
|
|
4106
5188
|
sendProgress = null;
|
|
4107
|
-
exportBusy.delete(busyKey);
|
|
4108
5189
|
}
|
|
4109
5190
|
|
|
4110
5191
|
// One toast for the whole run, naming what landed and what did not. A per-host toast storm
|
|
@@ -4116,25 +5197,32 @@
|
|
|
4116
5197
|
// the first one's counts appeared, attached to no host at all.
|
|
4117
5198
|
const clean = done.filter((d) => !d.partial);
|
|
4118
5199
|
const partial = done.filter((d) => d.partial);
|
|
4119
|
-
if (done.length || failed.length || aborted.length) {
|
|
4120
|
-
if (done.length) exportSourcesState.selected = null;
|
|
5200
|
+
if (done.length || failed.length || uncertain.length || aborted.length) {
|
|
5201
|
+
if (done.length && !staleReview) exportSourcesState.selected = null;
|
|
4121
5202
|
const sentence = [
|
|
4122
5203
|
clean.length ? `Sent to ${sequenceText(clean.map((d) => d.host))}.` : '',
|
|
4123
5204
|
...partial.map((d) => `${hostLabel(d.host)} took it with gaps — ${d.text}.`),
|
|
5205
|
+
...uncertain.map((row) => row.error),
|
|
4124
5206
|
...failed.map((f) => `${hostLabel(f.host)} didn’t — ${reasonFragment(humanSendError(f.error))}.`),
|
|
4125
5207
|
// The abort rides in the SAME sentence rather than firing its own toast: two toasts about
|
|
4126
5208
|
// one action is exactly the storm this single-line report replaced.
|
|
4127
5209
|
aborted.length
|
|
4128
|
-
?
|
|
5210
|
+
? uncertainHost
|
|
5211
|
+
? `${sequenceText(aborted)} ${aborted.length === 1 ? 'wasn’t' : 'weren’t'} sent because ${hostLabel(uncertainHost)} may already have changed. Check that open model before starting another send.`
|
|
5212
|
+
: staleReview
|
|
5213
|
+
? `The reviewed model changed, so ${sequenceText(aborted)} ${aborted.length === 1 ? 'wasn’t' : 'weren’t'} sent. FloLess is checking the latest version now.`
|
|
5214
|
+
: `This version changed, so ${sequenceText(aborted)} ${aborted.length === 1 ? 'wasn’t' : 'weren’t'} sent — approve again and re-send.`
|
|
4129
5215
|
: '',
|
|
4130
5216
|
].filter(Boolean).join(' ');
|
|
4131
|
-
showToast(sentence, partial.length || failed.length || aborted.length ? 'warn' : 'ok');
|
|
5217
|
+
showToast(sentence, partial.length || failed.length || uncertain.length || aborted.length ? 'warn' : 'ok');
|
|
4132
5218
|
}
|
|
4133
5219
|
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
4134
5220
|
// Re-reads the listing AND re-probes every host, so the card reflects the machine as it is
|
|
4135
5221
|
// now — including a host that went down during the run.
|
|
4136
|
-
|
|
5222
|
+
await safeRenderExports('after that send finished', 'send-host',
|
|
5223
|
+
() => paintExports(approvedAt, 'send-host'));
|
|
4137
5224
|
}
|
|
5225
|
+
return { staleReview, remainingHosts: staleReview ? [...aborted] : [] };
|
|
4138
5226
|
}
|
|
4139
5227
|
|
|
4140
5228
|
/** The Send card's whole action: ask, then send. */
|
|
@@ -4146,29 +5234,78 @@
|
|
|
4146
5234
|
// combination through on purpose. Without this it opened the whole destination dialog on top of
|
|
4147
5235
|
// a running send, took the user's picks, and threw them away against the busy key below —
|
|
4148
5236
|
// a complete decision discarded in silence.
|
|
4149
|
-
|
|
5237
|
+
const busyKey = `${projectId}:send-host`;
|
|
5238
|
+
if (exportBusy.has(busyKey)) { showToast(sendBusyText(), 'info'); return; }
|
|
5239
|
+
exportBusy.add(busyKey);
|
|
5240
|
+
try {
|
|
4150
5241
|
const picked = await askSendDestinations(projectId);
|
|
4151
|
-
|
|
4152
|
-
// is open (focus). Bring it up to date now, on EVERY exit including cancel — otherwise a user
|
|
4153
|
-
// who re-checked, saw a host come up, then cancelled would be left looking at a stale card.
|
|
4154
|
-
//
|
|
4155
|
-
// A row's probe can still be in flight when the dialog is dismissed (Esc during "Checking…").
|
|
4156
|
-
// Its continuation is discarded — it would be writing into a dialog that no longer exists — so
|
|
4157
|
-
// painting the state as it stands leaves that host stuck on "Checking…" behind a natively
|
|
4158
|
-
// disabled button, with nothing left to move it. Re-probe in that case only: doing it on every
|
|
4159
|
-
// exit would cost four bridge round-trips on a plain Cancel, which this flow exists to avoid.
|
|
4160
|
-
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
4161
|
-
if (SEND_HOSTS.some((h) => (hostState(h.host) || {}).state === 'checking')) renderExports();
|
|
4162
|
-
else paintExports(current.approvedAt);
|
|
4163
|
-
}
|
|
5242
|
+
if (current && current.id === projectId && !$wsExports.hidden) paintExports(current.approvedAt);
|
|
4164
5243
|
if (!picked) return;
|
|
4165
5244
|
hostChoices.set(projectId, picked);
|
|
5245
|
+
const sourceOption = currentExportSourceOption();
|
|
5246
|
+
if (!sourceOption) { showToast('Choose an export source first.', 'warn'); return; }
|
|
5247
|
+
const sourceSelector = JSON.parse(JSON.stringify(sourceOption.selector));
|
|
5248
|
+
let remainingHosts = [...picked];
|
|
4166
5249
|
// The user may have switched projects while the dialog was open — the send must not land on
|
|
4167
|
-
// whatever is open NOW. Everything below is keyed to the captured project.
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
5250
|
+
// whatever is open NOW. Everything below is keyed to the captured project. One stale
|
|
5251
|
+
// continuation is rebuilt and re-reviewed; a second fails closed instead of looping forever.
|
|
5252
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
5253
|
+
let sources;
|
|
5254
|
+
try { sources = await captureSelectedExportSources(projectId, remainingHosts.length, sourceSelector); }
|
|
5255
|
+
catch (error) { showToast((error && error.message) || 'Couldn’t freeze the export source.', 'warn'); return; }
|
|
5256
|
+
const handles = sources.map((source) => source.handleId);
|
|
5257
|
+
let reviews;
|
|
5258
|
+
try {
|
|
5259
|
+
showToast(attempt ? 'Checking the latest approved model…' : 'Checking what will be sent…', 'info');
|
|
5260
|
+
reviews = await preflightHostSends(remainingHosts, projectId, app, handles);
|
|
5261
|
+
const confirmed = await confirmAggregateHostSend(remainingHosts, reviews[0], attempt > 0 && reviews[0].kind === 'clean');
|
|
5262
|
+
if (!confirmed) {
|
|
5263
|
+
await Promise.allSettled(reviews.map((review) => cancelProjectHostBakeConsent(projectId, app, review.consent)));
|
|
5264
|
+
await releaseCapturedSources(projectId, handles);
|
|
5265
|
+
// The Send card is deliberately aria-disabled while this action owns its busy claim, so
|
|
5266
|
+
// formModal cannot return focus to it when Cancel closes the review. Release the claim,
|
|
5267
|
+
// repaint the live card, and restore focus only after the consent/source cleanup finishes.
|
|
5268
|
+
// Without this, keyboard focus falls back to <body> after the highest-risk dialog in the
|
|
5269
|
+
// flow — reached by the real `?` → Tab → Cancel path in independent browser QA.
|
|
5270
|
+
exportBusy.delete(busyKey);
|
|
5271
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
5272
|
+
paintExports(current.approvedAt, 'send-host');
|
|
5273
|
+
const sendCard = $wsExports.querySelector('[data-export="send-host"]');
|
|
5274
|
+
if (sendCard instanceof HTMLElement && !sendCard.matches(':disabled,[aria-disabled="true"]')) sendCard.focus();
|
|
5275
|
+
}
|
|
5276
|
+
showToast('CAD send cancelled.', 'info');
|
|
5277
|
+
return;
|
|
5278
|
+
}
|
|
5279
|
+
await reserveProjectHostBakeConsents(projectId, app, reviews);
|
|
5280
|
+
} catch (error) {
|
|
5281
|
+
if (reviews) await Promise.allSettled(reviews.map((review) => cancelProjectHostBakeConsent(projectId, app, review.consent)));
|
|
5282
|
+
await releaseCapturedSources(projectId, handles);
|
|
5283
|
+
if (error && error.hostBakeEmpty) {
|
|
5284
|
+
await showAggregateHostBakeEmpty(remainingHosts, error.hostBakeEmpty);
|
|
5285
|
+
return;
|
|
5286
|
+
}
|
|
5287
|
+
if (attempt === 0 && error && error.body && ['host-bake-confirmation-stale', 'host-bake-preflight-required', 'stale-selection'].includes(error.body.code)) continue;
|
|
5288
|
+
showToast((error && error.message) || 'Couldn’t review the CAD send.', 'warn');
|
|
5289
|
+
return;
|
|
5290
|
+
}
|
|
5291
|
+
// A stale first continuation refreshes the open project's approval state before this retry.
|
|
5292
|
+
// Anchor the second pass to THAT newly reviewed approval, or `approvalMoved()` would compare it
|
|
5293
|
+
// with the action's original timestamp and abort the entire unsent suffix without issuing a POST.
|
|
5294
|
+
// When the user has navigated elsewhere there is no open-project signal to consult; the server's
|
|
5295
|
+
// consent binding remains the authority, exactly as on the first pass.
|
|
5296
|
+
const attemptApprovedAt = attempt > 0 && current && current.id === projectId
|
|
5297
|
+
? current.approvedAt
|
|
5298
|
+
: approvedAt;
|
|
5299
|
+
const result = await sendToHosts(remainingHosts, projectId, app, attemptApprovedAt, handles, sources[0].kind, reviews);
|
|
5300
|
+
if (attempt === 0 && result && result.staleReview && result.remainingHosts.length) {
|
|
5301
|
+
remainingHosts = result.remainingHosts;
|
|
5302
|
+
continue;
|
|
5303
|
+
}
|
|
5304
|
+
return;
|
|
5305
|
+
}
|
|
5306
|
+
} finally {
|
|
5307
|
+
exportBusy.delete(busyKey);
|
|
5308
|
+
}
|
|
4172
5309
|
}
|
|
4173
5310
|
|
|
4174
5311
|
// Links created this session, per project: `${projectId}:share-3d` -> { url, approvedAt }. Held in
|
|
@@ -4309,12 +5446,16 @@
|
|
|
4309
5446
|
// Unbounded, this is the only card whose height grows with use: a still per viewpoint plus
|
|
4310
5447
|
// turntables reached eight entries on the demo project, and since the grid stretches a row to
|
|
4311
5448
|
// its tallest item, that one card was dragging every sibling down the page with it.
|
|
5449
|
+
// Instructor carriers, exactly as the bill-of-materials rows are (#1108). The instance label is
|
|
5450
|
+
// not decoration: every one of these buttons is accessibly named "⧉ Open" or "▤ Reveal", so
|
|
5451
|
+
// without it `?` fills {instance} with the glyph and offers one identical sentence per rendered
|
|
5452
|
+
// file. What a user cares about is WHICH FILE, so the row label — "image", "turntable", or a
|
|
5453
|
+
// per-viewpoint variant of them — is the name.
|
|
4312
5454
|
const rows = done.map((row) =>
|
|
4313
5455
|
`<div class="e-render-row">` +
|
|
4314
5456
|
`<span class="e-done"><span class="chk">✓</span> ${escapeHtml(row.label)} <span class="t">${escapeHtml(hhmm(row.exportedAt))}</span></span>` +
|
|
4315
5457
|
`<span class="e-links">` +
|
|
4316
|
-
|
|
4317
|
-
`<button type="button" class="e-link" data-reveal="${escapeAttr(row.key)}" data-tip="Show the file in its folder">▤ Reveal</button>` +
|
|
5458
|
+
fileActionPair(row.key, row.label) +
|
|
4318
5459
|
`</span>` +
|
|
4319
5460
|
`</div>`).join('');
|
|
4320
5461
|
// The list is keyboard-reachable on its own (tabbing hits the buttons inside), but a scroller
|
|
@@ -4366,11 +5507,6 @@
|
|
|
4366
5507
|
{ host: 'rhino', label: 'Rhino' },
|
|
4367
5508
|
];
|
|
4368
5509
|
const hostLabel = (host) => (SEND_HOSTS.find((h) => h.host === host) || {}).label || host;
|
|
4369
|
-
// Tekla keeps its own probe: it can distinguish "open but no model loaded", which the generic
|
|
4370
|
-
// `list-instances` cannot. Same envelope out, so the row template does not care which answered.
|
|
4371
|
-
const hostReadinessUrl = (host) => (host === 'tekla'
|
|
4372
|
-
? '/api/tekla-readiness'
|
|
4373
|
-
: `/api/host-readiness/${encodeURIComponent(host)}`);
|
|
4374
5510
|
// Sends completed this browser session: `${projectId}:${host}` → { at, approvedAt }. In memory
|
|
4375
5511
|
// only, exactly like share links — the server keeps no record of which applications a project has
|
|
4376
5512
|
// been pushed into, and inventing a durable one here would imply a history that does not exist.
|
|
@@ -4379,84 +5515,6 @@
|
|
|
4379
5515
|
// send is several minutes of silence otherwise, and "Sending…" alone cannot say which one.
|
|
4380
5516
|
let sendProgress = null;
|
|
4381
5517
|
|
|
4382
|
-
/** The readiness of a host, or null when it has not been asked about yet. */
|
|
4383
|
-
const hostState = (host) => hostReadinessStates[host] || null;
|
|
4384
|
-
const hostIsReady = (host) => {
|
|
4385
|
-
const st = hostState(host);
|
|
4386
|
-
return !!(st && st.ok && st.state === 'ready');
|
|
4387
|
-
};
|
|
4388
|
-
/** The version to show beside a ready host — Tekla nests it under `host`, the others under `session`. */
|
|
4389
|
-
function hostVersion(st) {
|
|
4390
|
-
if (!st) return '';
|
|
4391
|
-
const v = (st.session && st.session.version) || (st.host && typeof st.host === 'object' && st.host.version) || '';
|
|
4392
|
-
return v ? String(v) : '';
|
|
4393
|
-
}
|
|
4394
|
-
|
|
4395
|
-
/**
|
|
4396
|
-
* Probe ONE destination. A probe that fails is recorded as "couldn't check" WITH a retry — never
|
|
4397
|
-
* as "not open", which would be a definite negative the server never gave us.
|
|
4398
|
-
*/
|
|
4399
|
-
async function probeHost(host) {
|
|
4400
|
-
try {
|
|
4401
|
-
return (await api(hostReadinessUrl(host))).readiness;
|
|
4402
|
-
} catch (err) {
|
|
4403
|
-
return {
|
|
4404
|
-
host,
|
|
4405
|
-
ok: false,
|
|
4406
|
-
state: 'error',
|
|
4407
|
-
message: err && err.message
|
|
4408
|
-
? err.message
|
|
4409
|
-
: `Couldn’t check whether ${hostLabel(host)} is ready.`,
|
|
4410
|
-
recovery: { action: 'retry', label: 'Check again' },
|
|
4411
|
-
};
|
|
4412
|
-
}
|
|
4413
|
-
}
|
|
4414
|
-
|
|
4415
|
-
/**
|
|
4416
|
-
* Refresh every destination: the cheap process scan first, then the expensive per-host probe for
|
|
4417
|
-
* only those it found.
|
|
4418
|
-
*
|
|
4419
|
-
* This ordering is what lets the chooser list all four applications without the Exports tab
|
|
4420
|
-
* paying four bridge round-trips every time it opens. The shortcut is sound in ONE direction
|
|
4421
|
-
* only: a host the scan did not see is painted closed **solely when the scan actually ran**. If
|
|
4422
|
-
* the scan could not run (`scanned:false` — not Windows, PowerShell unavailable) we know nothing,
|
|
4423
|
-
* so every host is probed rather than four applications being declared shut on the strength of a
|
|
4424
|
-
* look that never happened.
|
|
4425
|
-
*/
|
|
4426
|
-
async function refreshHostReadiness() {
|
|
4427
|
-
const hosts = SEND_HOSTS.map((h) => h.host);
|
|
4428
|
-
hostReadinessStates = Object.fromEntries(hosts.map((h) => [h, { ok: false, state: 'checking' }]));
|
|
4429
|
-
let scan = null;
|
|
4430
|
-
try {
|
|
4431
|
-
scan = await api('/api/hosts/running');
|
|
4432
|
-
} catch {
|
|
4433
|
-
scan = null; // unknown — fall through to probing everything
|
|
4434
|
-
}
|
|
4435
|
-
// Null is NOT "none running": it means the scan did not answer, and the difference decides
|
|
4436
|
-
// whether a row may claim an application is closed. Never assert a negative we did not observe.
|
|
4437
|
-
const runningHosts = scan && scan.scanned && Array.isArray(scan.hosts) ? scan.hosts : null;
|
|
4438
|
-
const probe = runningHosts ? hosts.filter((h) => runningHosts.includes(h)) : hosts;
|
|
4439
|
-
const closed = hosts.filter((h) => !probe.includes(h));
|
|
4440
|
-
const next = {};
|
|
4441
|
-
for (const host of closed) {
|
|
4442
|
-
next[host] = {
|
|
4443
|
-
host,
|
|
4444
|
-
ok: false,
|
|
4445
|
-
state: 'host-closed',
|
|
4446
|
-
// An OBSERVATION, not a verdict. The scan matches four exact process names, so an
|
|
4447
|
-
// application running under any other one is unseen rather than shut — and telling a user
|
|
4448
|
-
// with Tekla open on screen that Tekla is closed is precisely the failure this readiness
|
|
4449
|
-
// machinery exists to prevent. The chooser's own per-row "Check again" probes the bridge
|
|
4450
|
-
// directly, bypassing the scan, so the authoritative answer is always one click away.
|
|
4451
|
-
message: `We didn’t see ${hostLabel(host)} running. Start it, then check again.`,
|
|
4452
|
-
recovery: { action: 'retry', label: 'Check again' },
|
|
4453
|
-
};
|
|
4454
|
-
}
|
|
4455
|
-
const probed = await Promise.all(probe.map((host) => probeHost(host).then((r) => [host, r])));
|
|
4456
|
-
for (const [host, readiness] of probed) next[host] = readiness;
|
|
4457
|
-
return next;
|
|
4458
|
-
}
|
|
4459
|
-
|
|
4460
5518
|
/**
|
|
4461
5519
|
* A send failure in words a detailer can act on.
|
|
4462
5520
|
*
|
|
@@ -4524,14 +5582,6 @@
|
|
|
4524
5582
|
tip: sendBusyText(),
|
|
4525
5583
|
};
|
|
4526
5584
|
}
|
|
4527
|
-
const states = SEND_HOSTS.map((h) => hostState(h.host));
|
|
4528
|
-
if (states.some((st) => !st || st.state === 'checking')) return {
|
|
4529
|
-
meta: '<span class="e-readiness checking" role="status" aria-live="polite">' +
|
|
4530
|
-
'<span class="rtn-spinner" aria-hidden="true"></span> Checking which CAD apps are open…</span>',
|
|
4531
|
-
disabled: true,
|
|
4532
|
-
tip: 'Checking AWARE, the bridges, and the open applications',
|
|
4533
|
-
};
|
|
4534
|
-
|
|
4535
5585
|
// What was sent from THIS approved version — one row per destination, like the render card's
|
|
4536
5586
|
// per-artifact rows. A send under an older approval is not shown: it no longer describes what
|
|
4537
5587
|
// is in that model.
|
|
@@ -4540,41 +5590,7 @@
|
|
|
4540
5590
|
.filter((r) => r.rec && r.rec.approvedAt === current.approvedAt)
|
|
4541
5591
|
.sort((a, b) => String(b.rec.at).localeCompare(String(a.rec.at)));
|
|
4542
5592
|
|
|
4543
|
-
const
|
|
4544
|
-
let head;
|
|
4545
|
-
if (ready.length === 1) {
|
|
4546
|
-
const v = hostVersion(hostState(ready[0].host));
|
|
4547
|
-
head = `<span class="e-readiness ready" role="status" aria-live="polite">Ready · ${escapeHtml(hostLabel(ready[0].host))}${v ? ` ${escapeHtml(v)}` : ''}</span>`;
|
|
4548
|
-
} else if (ready.length > 1) {
|
|
4549
|
-
head = `<span class="e-readiness ready" role="status" aria-live="polite">${ready.length} apps ready</span>`;
|
|
4550
|
-
} else {
|
|
4551
|
-
// Deliberately NOT one arbitrary host's message: with four destinations out for four
|
|
4552
|
-
// different reasons, promoting one of them to the card would misrepresent the other three.
|
|
4553
|
-
// The count is honest and the chooser carries every reason, each with its own way out.
|
|
4554
|
-
//
|
|
4555
|
-
// One exception, because it is not one host's problem at all: an AWARE below the required
|
|
4556
|
-
// version blocks every destination for the SAME reason, and re-checking can never clear it.
|
|
4557
|
-
// That needs the updater, and the chooser cannot open it (it would stack a second modal over
|
|
4558
|
-
// itself), so the way out belongs here. Without it the user re-checks forever — which is what
|
|
4559
|
-
// the old Tekla card's `update-aware` route existed to prevent, and this card had lost.
|
|
4560
|
-
//
|
|
4561
|
-
// `some`, not `every`: only a host that was actually PROBED can report update-aware, and the
|
|
4562
|
-
// readiness refresh short-circuits any host the process scan did not see straight to "not
|
|
4563
|
-
// running" without asking the server. Requiring all four to say it meant the button appeared
|
|
4564
|
-
// only with all four applications open at once — never in the ordinary case of one. This
|
|
4565
|
-
// branch already knows nothing is ready, so one host reporting it is the whole story.
|
|
4566
|
-
const awareState = states.find((st) => st && st.recovery && st.recovery.action === 'update-aware');
|
|
4567
|
-
head = '<span class="e-readiness blocked" role="status" aria-live="polite">' +
|
|
4568
|
-
(awareState
|
|
4569
|
-
// That host's own words: the required floor differs per destination, so a message borrowed
|
|
4570
|
-
// from a different one would quote the wrong version.
|
|
4571
|
-
? escapeHtml(awareState.message || 'AWARE needs updating before any CAD app can receive this model.')
|
|
4572
|
-
: 'No CAD app is ready to receive this model.') +
|
|
4573
|
-
'</span>' +
|
|
4574
|
-
(awareState
|
|
4575
|
-
? '<button type="button" class="e-recovery" data-host-recovery="update-aware">Update AWARE</button>'
|
|
4576
|
-
: '<button type="button" class="e-recovery" data-host-recheck="1">Check again</button>');
|
|
4577
|
-
}
|
|
5593
|
+
const head = '<span class="e-readiness" role="status">Choose a destination to review this send.</span>';
|
|
4578
5594
|
|
|
4579
5595
|
// No row-count guess at whether this list needs a tab stop — markScrollable measures it after
|
|
4580
5596
|
// paint, because a destination reporting gaps is two or three lines depending on how its
|
|
@@ -4623,9 +5639,7 @@
|
|
|
4623
5639
|
return {
|
|
4624
5640
|
meta: head + rows,
|
|
4625
5641
|
disabled: false,
|
|
4626
|
-
tip:
|
|
4627
|
-
? `Create native objects in the open ${ready.length === 1 ? hostLabel(ready[0].host) : 'CAD'} model`
|
|
4628
|
-
: 'See which applications can receive this model, and what to fix',
|
|
5642
|
+
tip: 'Choose destinations and review what will be sent',
|
|
4629
5643
|
sent: sent.length > 0,
|
|
4630
5644
|
};
|
|
4631
5645
|
}
|
|
@@ -4649,9 +5663,15 @@
|
|
|
4649
5663
|
} else {
|
|
4650
5664
|
const st = exportState[c.kind];
|
|
4651
5665
|
if (st && st.exportedAt) {
|
|
5666
|
+
// The generic branch's own file actions, which were the last unregistered pair (#1108). Two
|
|
5667
|
+
// cards reach here and only here: the IFC model (reveal-only — `open:false`, because no OS
|
|
5668
|
+
// default app opens an IFC usefully) and a traced drawing's SVG (`open:true`). The instance is
|
|
5669
|
+
// the card's NAME AND FORMAT, which is exactly what the card shows above these buttons and is
|
|
5670
|
+
// what keeps two cards both called "Model" apart in the `?` list.
|
|
5671
|
+
const fileInstance = `${c.name} (${c.fmt})`;
|
|
4652
5672
|
const links = `<span class="e-links">` +
|
|
4653
|
-
(c.open ?
|
|
4654
|
-
|
|
5673
|
+
(c.open ? fileActionButton('open', { kind: c.kind, instance: fileInstance }) : '') +
|
|
5674
|
+
fileActionButton('reveal', { kind: c.kind, instance: fileInstance }) +
|
|
4655
5675
|
`</span>`;
|
|
4656
5676
|
meta = `<span class="e-done"><span class="chk">✓</span> exported <span class="t">${escapeHtml(hhmm(st.exportedAt))}</span></span>${links}`;
|
|
4657
5677
|
} else {
|
|
@@ -4711,6 +5731,9 @@
|
|
|
4711
5731
|
const dis = `${softBlock ? ` aria-disabled="true" aria-describedby="${escapeAttr(special.blockedBy)}"` : ''}` +
|
|
4712
5732
|
`${disabled && !busy && !softBlock ? ' disabled' : ''}` +
|
|
4713
5733
|
`${busy ? ' aria-disabled="true" aria-busy="true"' : ''}${tip ? ` data-tip="${escapeAttr(tip)}"` : ''}`;
|
|
5734
|
+
const commandCarrier = c.kind === 'send-host'
|
|
5735
|
+
? `data-command-id="shell.host-send-start#${escapeAttr(c.kind)}"`
|
|
5736
|
+
: `data-command-id="shell.export-run#${escapeAttr(c.kind)}"`;
|
|
4714
5737
|
return `<div class="ecard">` +
|
|
4715
5738
|
`<div class="e-top"><div class="e-ico">${escapeHtml(c.ico)}</div>` +
|
|
4716
5739
|
`<div><div class="e-name">${escapeHtml(c.name)}</div><div class="e-fmt">${escapeHtml(c.fmt)}</div></div></div>` +
|
|
@@ -4719,14 +5742,46 @@
|
|
|
4719
5742
|
// card is not a video player. Click opens it exactly like ⧉ Open — no lightbox.
|
|
4720
5743
|
(c.kind === 'render' && approved && exportState && exportState['render-png']
|
|
4721
5744
|
&& exportState['render-png'].exportedAt
|
|
4722
|
-
|
|
5745
|
+
// A SECOND carrier for the same file as the "image" row's ⧉ Open, and it needs its own
|
|
5746
|
+
// instance name rather than sharing that one: they are two different controls a user can be
|
|
5747
|
+
// sent to, and two entries reading "image" would be the identical-sentences problem the row
|
|
5748
|
+
// labels exist to avoid. Not in #1108's list — found while fixing it.
|
|
5749
|
+
//
|
|
5750
|
+
// "(thumbnail)", not "preview": the parenthetical qualifier matches what the generic card
|
|
5751
|
+
// branch does two cards down, and "image preview" reads as a SECOND exported artifact called
|
|
5752
|
+
// a preview. There is only one PNG; this is another way into it. (Design review.)
|
|
5753
|
+
? fileActionButton('open', { kind: 'render-png', instance: 'image (thumbnail)', cls: 'e-thumb',
|
|
5754
|
+
renderThumb: true, tip: 'Open the rendered image' })
|
|
4723
5755
|
: '') +
|
|
4724
5756
|
// The CAD card is deliberately NOT here: its receipts are per destination
|
|
4725
5757
|
// (`<project>:send:tekla`), so this card-kind lookup can only ever miss — and a call that
|
|
4726
5758
|
// silently returns '' is exactly what hid a missing receipt line once already. Each
|
|
4727
5759
|
// destination prints its own, in sendHostCardState.
|
|
4728
5760
|
(c.kind === 'send-host' ? '' : receiptHtml(c.kind, approved)) +
|
|
4729
|
-
|
|
5761
|
+
// A SEPARATE line from the receipt's, because they answer different questions: the receipt
|
|
5762
|
+
// says what the producer could not emit from what it was given, this says what was never
|
|
5763
|
+
// given to it. A model missing three heights and an AWARE weld failure are not one fact.
|
|
5764
|
+
(c.kind === 'send-host' ? '' : omittedHtml(c.kind, approved)) +
|
|
5765
|
+
// REGISTERED, because #1156a changed what this button DOES. It used to refuse an export outright
|
|
5766
|
+
// when any member's endpoint elevation was unresolved; now the file exports build what they can
|
|
5767
|
+
// and name what they left out, while a bake into a live host still refuses (and says why). A
|
|
5768
|
+
// capability whose behaviour and refusal both changed is one Instructor has to be able to
|
|
5769
|
+
// explain, and this carrier was reachable by `?` with nothing to say about it.
|
|
5770
|
+
//
|
|
5771
|
+
// The INSTANCE is the card's own verb - "Export IFC", "Render image", "Send to a CAD app" -
|
|
5772
|
+
// because that is the distinction a user cares about; five identical sentences for five
|
|
5773
|
+
// different deliverables is the failure `data-command-instance-label` exists to prevent. It is
|
|
5774
|
+
// escaped, like every other dynamic instance key in this file.
|
|
5775
|
+
// KEYED ON THE CARD KIND, NEVER THE LABEL. `label` is what the button READS, and it changes:
|
|
5776
|
+
// once a card has exported, every one of them says "Re-export" (or "Re-render"), so keying the
|
|
5777
|
+
// identity on it made IFC and BOM collide on `shell.export-run#Re-export`. Instructor
|
|
5778
|
+
// deduplicates identical identities and activates the first match, so the second card dropped
|
|
5779
|
+
// out of the inventory entirely and could not be targeted. Found in review, by executing the
|
|
5780
|
+
// real `cardHtml` rather than reading it.
|
|
5781
|
+
//
|
|
5782
|
+
// The instance LABEL is `c.verb` for the same reason: it is the card's stable name ("Export
|
|
5783
|
+
// IFC", "Render image"), so the narration reads the same before and after an export.
|
|
5784
|
+
`<div class="e-act"><button type="button" ${commandCarrier} data-command-instance-label="${escapeAttr(c.verb)}" data-export="${escapeAttr(c.kind)}"${dis}>↗ ${escapeHtml(label)}</button></div>` +
|
|
4730
5785
|
`</div>`;
|
|
4731
5786
|
}
|
|
4732
5787
|
|
|
@@ -4735,8 +5790,6 @@
|
|
|
4735
5790
|
'data-openfile',
|
|
4736
5791
|
'data-reveal',
|
|
4737
5792
|
'data-export-details',
|
|
4738
|
-
'data-host-recheck',
|
|
4739
|
-
'data-host-recovery',
|
|
4740
5793
|
'data-render-recovery',
|
|
4741
5794
|
'data-open-exports-folder', // the note's `exports` button — survives the repaint an export triggers
|
|
4742
5795
|
'data-copyshare', // the share-link Copy button — omitted here, a repaint mid-render steals its focus
|
|
@@ -4850,7 +5903,8 @@
|
|
|
4850
5903
|
// person deliberately chooses its DRAFT working copy/checkpoint.
|
|
4851
5904
|
const approved = projectContractLifecycle === 'model' && exportSourcesState.status === 'ready' && !!currentExportSourceOption();
|
|
4852
5905
|
const approvalRefusal = approvalRefusalNote();
|
|
4853
|
-
|
|
5906
|
+
// Same 46px band every other project step carries (see the shared step-header rule in app.css).
|
|
5907
|
+
let html = '<div class="step-head"><span>Exports</span></div>' + exportSourceHtml();
|
|
4854
5908
|
if (!approved) {
|
|
4855
5909
|
// Same split as History's empty state (#490): with a model, Approve is genuinely the unlocking
|
|
4856
5910
|
// action; with none, `POST …/approve` 404s, so pointing at it is a dead end and the real next
|
|
@@ -4989,118 +6043,271 @@
|
|
|
4989
6043
|
}
|
|
4990
6044
|
}
|
|
4991
6045
|
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
6046
|
+
/**
|
|
6047
|
+
* THE EXPORTS REPAINT AND ITS GUARD, IN ONE CLOSURE — so that bypassing the guard is not a thing
|
|
6048
|
+
* that can be written.
|
|
6049
|
+
*
|
|
6050
|
+
* `renderExports` used to be a sibling declaration, reachable by name from every one of this file's
|
|
6051
|
+
* six thousand lines. Thirteen call sites had to remember to go through `safeRenderExports`, eight of
|
|
6052
|
+
* them originally did not, and the failure was SILENT — an unhandled rejection and a half-painted
|
|
6053
|
+
* card. Four review rounds then went into a static check that hunts for the next call site to forget,
|
|
6054
|
+
* and each round found a source shape the hunt did not recognise. That search does not terminate:
|
|
6055
|
+
* judging arbitrary source for a reference has no fixed point, because the next spelling is always
|
|
6056
|
+
* writable.
|
|
6057
|
+
*
|
|
6058
|
+
* The name now exists only in here. A repaint that skips the guard is not a call this file's other
|
|
6059
|
+
* code can express — there is no identifier to write, and an attempt is a ReferenceError at the
|
|
6060
|
+
* moment it runs rather than a silent half-render. The same reasoning as `fileActionButton` above,
|
|
6061
|
+
* and the same reasoning as #1148's refusal to default a missing argument: a mistake that is loud
|
|
6062
|
+
* needs no detector.
|
|
6063
|
+
*/
|
|
6064
|
+
const safeRenderExports = (() => {
|
|
6065
|
+
/*
|
|
6066
|
+
* A REFRESH NOBODY ASKED FOR STILL SAYS WHEN IT FAILS. Many of these repaints are driven by an event
|
|
6067
|
+
* rather than a click, so there is no button to leave in an error state — but swallowing the
|
|
6068
|
+
* rejection entirely would leave the card showing the OLD state with nothing to explain why, which is
|
|
6069
|
+
* the class of silence this whole slice has been removing. The card's own load-failure toast already
|
|
6070
|
+
* covers the fetch; this is the outer throw.
|
|
6071
|
+
*
|
|
6072
|
+
* `reason` NAMES THE TRIGGER, because the same crash reaches this from every repaint site and "the
|
|
6073
|
+
* exports view failed to refresh" tells a user nothing about what they just did. It reads as a
|
|
6074
|
+
* fragment ("after a units change", "when you opened the Exports step") and is written by the call
|
|
6075
|
+
* site, which is the only thing that knows.
|
|
6076
|
+
*/
|
|
6077
|
+
function reportExportsRefreshFailure(err, reason) {
|
|
6078
|
+
/*
|
|
6079
|
+
* `console.error` FIRST, and that is the load-bearing half.
|
|
6080
|
+
*
|
|
6081
|
+
* Every operational failure inside `renderExports` is already handled where it happens — the
|
|
6082
|
+
* contract probe catches, `awaitApprovalVerdict` cannot reject, and `Promise.allSettled` never
|
|
6083
|
+
* rejects — so the only thing that reaches here is a PROGRAMMING error: a TypeError from a bad
|
|
6084
|
+
* `.find(...).label`, a renamed helper. Reporting one of those as a mild warn toast and nothing
|
|
6085
|
+
* else would consume the rejection, keep the stack off the console, and leave
|
|
6086
|
+
* `window.onunhandledrejection` silent — which would quietly satisfy both the standing
|
|
6087
|
+
* clean-console rule and this slice's own QA step while the card was crashing. (Review round 5.)
|
|
6088
|
+
*/
|
|
6089
|
+
console.error('[workspaces] exports refresh threw ' + (reason || '(no reason given)'), err);
|
|
6090
|
+
// `err`, NOT `warn`, and the reason is in `showToast`'s own table rather than in taste: a `warn`
|
|
6091
|
+
// auto-dismisses after 5 s while an `err` stays until it is closed. This message is long — the
|
|
6092
|
+
// trigger, the raw error, and a two-clause recovery instruction — and it reports a programming
|
|
6093
|
+
// error the reader can do nothing about except reopen the step. Five seconds is not enough to
|
|
6094
|
+
// read it, and losing it leaves them looking at the half-painted card the bug just produced with
|
|
6095
|
+
// no explanation at all, which is the silence this whole change removes. (Design review.)
|
|
6096
|
+
showToast(
|
|
6097
|
+
'Couldn’t refresh the exports view ' + (reason || 'just now') + ': ' + ((err && err.message) || err)
|
|
6098
|
+
+ ' — leave the Exports step and open it again to retry.',
|
|
6099
|
+
'err',
|
|
6100
|
+
);
|
|
6101
|
+
}
|
|
6102
|
+
|
|
6103
|
+
/*
|
|
6104
|
+
* THE ONE WAY THIS PAGE REPAINTS THE EXPORTS STEP (#1123).
|
|
6105
|
+
*
|
|
6106
|
+
* `renderExports` was called from THIRTEEN places before #1206 removed two pre-review host-probe
|
|
6107
|
+
* repaint paths. Of the original calls, five had a `.catch`, and only TWO of those told the
|
|
6108
|
+
* user anything — the rest degraded into a repaint or a `console.warn`. (Counted from the source,
|
|
6109
|
+
* comment-stripped, after a reviewer caught this paragraph claiming ten and three; the commit that
|
|
6110
|
+
* introduced it said twelve. Three different numbers for one countable fact, which is why the
|
|
6111
|
+
* assertions below count call SITES rather than trusting prose.)
|
|
6112
|
+
*
|
|
6113
|
+
* That is not a tidiness point: it produced two different experiences for the SAME crash. A units
|
|
6114
|
+
* change named it in a toast; clicking the Exports step — by far the most travelled of them — produced an unhandled
|
|
6115
|
+
* rejection, a half-painted card, and silence. Two of the bare ones were worse than bare: they were
|
|
6116
|
+
* awaited inside a `try` whose `catch` says "Raw export failed", so a repaint bug was reported to the
|
|
6117
|
+
* user as a failed export that had in fact succeeded.
|
|
6118
|
+
*
|
|
6119
|
+
* WHAT CAN ACTUALLY REACH THE CATCH is a PROGRAMMING error, and that is why `console.error` is not
|
|
6120
|
+
* optional. Every operational failure inside `renderExports` is handled where it happens — the
|
|
6121
|
+
* contract probe catches, the approval verdict promise is resolve-only, and `Promise.allSettled`
|
|
6122
|
+
* never rejects with every result handled — so what arrives here is a `TypeError` from something like
|
|
6123
|
+
* an unguarded `.find(...).label`. Reporting one of those as a mild toast and nothing else would
|
|
6124
|
+
* consume the rejection, keep the stack off the console, and leave `window.onunhandledrejection`
|
|
6125
|
+
* silent, quietly satisfying the standing clean-console gate while the card was crashing.
|
|
6126
|
+
*
|
|
6127
|
+
* NEVER REJECTS. Callers `await` it inside their own try/catch, and a wrapper that rethrew would put
|
|
6128
|
+
* the misreporting back exactly where this exists to remove it.
|
|
6129
|
+
*
|
|
6130
|
+
* @param {string} reason the trigger, as a fragment: "after approving", "when you opened Exports".
|
|
6131
|
+
* @param {string} [restoreKind] the card whose control should regain focus, passed straight through.
|
|
6132
|
+
* @param {() => void} [onFailure] a degraded repaint for callers that have one — run AFTER reporting,
|
|
6133
|
+
* and itself guarded, because a fallback that throws would resurrect the unhandled rejection.
|
|
6134
|
+
*/
|
|
6135
|
+
function safeRenderExports(reason, restoreKind, onFailure) {
|
|
6136
|
+
return renderExports(restoreKind).catch((error) => {
|
|
6137
|
+
// BOTH halves guarded, INDEPENDENTLY, and that is what makes "never rejects" true rather than
|
|
6138
|
+
// merely intended. The first cut guarded only the fallback, so a `showToast` that threw — a
|
|
6139
|
+
// restricted browser policy, a DOM the toast host had lost — rejected the promise straight back
|
|
6140
|
+
// to a caller awaiting it inside a `try` whose `catch` says "Raw export failed", which is the
|
|
6141
|
+
// exact misreporting this wrapper exists to remove. Independently, because a reporting failure
|
|
6142
|
+
// must not cost the degraded repaint: the card would then sit in its busy state forever.
|
|
6143
|
+
// (Review round 1 — Codex. The test only made the FALLBACK throw, so it could not see this.)
|
|
6144
|
+
// The console is the LAST resort, so it is guarded too. Round 2 pointed out that the recovery
|
|
6145
|
+
// path logged with a bare `console.error`: an instrumented or restricted console that throws
|
|
6146
|
+
// took the rejection straight back out through the handler AND skipped the degraded repaint —
|
|
6147
|
+
// the same two failures this wrapper exists to prevent, reintroduced by the code preventing them.
|
|
6148
|
+
const note = (what, cause) => { try { console.error('[workspaces] ' + what + ' ' + reason, cause); } catch (_) { /* nothing left to tell */ } };
|
|
6149
|
+
try { reportExportsRefreshFailure(error, reason); } catch (reportError) {
|
|
6150
|
+
note('exports failure REPORTING threw', reportError);
|
|
6151
|
+
}
|
|
6152
|
+
if (!onFailure) return;
|
|
6153
|
+
try { onFailure(); } catch (fallbackError) {
|
|
6154
|
+
note('exports fallback repaint threw', fallbackError);
|
|
6155
|
+
}
|
|
6156
|
+
});
|
|
6157
|
+
}
|
|
6158
|
+
|
|
6159
|
+
async function renderExports(restoreKind) {
|
|
6160
|
+
if (!current) return;
|
|
6161
|
+
const id = current.id, app = current.app;
|
|
6162
|
+
const renderGen = ++exportsRenderGen; // see the declaration: this render's claim on module state
|
|
6163
|
+
const cards = (wsApp() && wsApp().exports) || [];
|
|
6164
|
+
const hasRender = cards.some((card) => card.kind === 'render');
|
|
6165
|
+
renderReadinessState = hasRender ? { ok: false, state: 'checking' } : null;
|
|
6166
|
+
// WHAT WAS PAINTED, not what the flag says. The header's probe can settle between this paint and
|
|
6167
|
+
// ours and move the flag WITHOUT repainting this pane — comparing to the flag then finds them
|
|
6168
|
+
// equal, skips the repaint, and leaves the gate drawn with the old value. That is #490 reproduced
|
|
6169
|
+
// inside the pane this fix is for, reachable by opening an empty project and clicking Exports
|
|
6170
|
+
// while the open-time probe is still in flight.
|
|
6171
|
+
const paintedWith = exportsHasModel;
|
|
6172
|
+
exportSourcesState.status = 'loading';
|
|
6173
|
+
paintExports(current.approvedAt, restoreKind);
|
|
6174
|
+
const gen = ++modelPresenceGen;
|
|
6175
|
+
const modelPresent = await projectContractState(id, app);
|
|
6176
|
+
// `renderGen` is listed for symmetry with the guard below, and it decides NOTHING here: this
|
|
6177
|
+
// function bumps `exportsRenderGen` and then `modelPresenceGen` with no await between them, so a
|
|
6178
|
+
// newer render moves both at once and `gen !== modelPresenceGen` has already caught it. The
|
|
6179
|
+
// reason `modelPresenceGen` could not simply be reused is real but belongs to the LAST guard,
|
|
6180
|
+
// where it is not checked at all. (Review round 5.)
|
|
6181
|
+
if (renderGen !== exportsRenderGen || gen !== modelPresenceGen || !current || current.id !== id || $wsExports.hidden) return;
|
|
6182
|
+
applyModelPresence(modelPresent);
|
|
6183
|
+
if (exportsHasModel !== paintedWith) paintExports(current.approvedAt, restoreKind);
|
|
6184
|
+
let state = null;
|
|
6185
|
+
let units = null; // the server's answer, applied below the staleness guard with the others
|
|
6186
|
+
// SAYS THE THING THE GUARD MEANS. `if (units)` was correct only because the ternary above can
|
|
6187
|
+
// never produce a falsy value — so a later, entirely reasonable "report what the server actually
|
|
6188
|
+
// said, stop coercing" change to `units = r.units` would silently re-enable the resurrected-
|
|
6189
|
+
// approval bug against a server that omits the field, with nothing to notice. (Review round 4.)
|
|
6190
|
+
let answered = false;
|
|
6191
|
+
let approvedAt = current.approvedAt; // fallback if the fetch fails (best-known)
|
|
6192
|
+
// Don't ask a question whose answer we already hold. `/export-sources` refuses on exactly the
|
|
6193
|
+
// standing condition the approval probe has already reported, so the request can only come back
|
|
6194
|
+
// 409 — and Chromium prints "Failed to load resource" for EVERY non-2xx regardless of how
|
|
6195
|
+
// cleanly the page handles it. Not asking is the only way to keep the console quiet, and it is
|
|
6196
|
+
// the honest description of the state anyway: there is nothing to select, which is what
|
|
6197
|
+
// `unavailable` already means here. Unknown still asks, so a not-yet-settled probe cannot
|
|
6198
|
+
// suppress a listing that would have succeeded.
|
|
6199
|
+
await awaitApprovalVerdict();
|
|
6200
|
+
if (!current || current.id !== id || $wsExports.hidden) return; // switched away while it settled
|
|
6201
|
+
// EVERY request in this render starts BELOW the wait, and the four of them are followed
|
|
6202
|
+
// immediately by the `allSettled` that handles them — no await may separate the two.
|
|
6203
|
+
//
|
|
6204
|
+
// `exportPromise` used to be started above, which review caught: parking on the verdict left it
|
|
6205
|
+
// in flight with no handler attached, so a failure during the wait crossed a microtask
|
|
6206
|
+
// checkpoint unhandled and the browser logged it — the same defect this PR fixes for
|
|
6207
|
+
// `checkpointPromise`, reintroduced one line up by the wait itself. The `return` on the line
|
|
6208
|
+
// above made it worse: it abandoned the promise outright.
|
|
6209
|
+
const sourcesRefused = !!approvalRefusalNote();
|
|
6210
|
+
const exportPromise = api(`/api/contract/${encodeURIComponent(app)}/exports?project=${encodeURIComponent(id)}`);
|
|
6211
|
+
const sourcePromise = sourcesRefused ? null : api(`/api/projects/${encodeURIComponent(id)}/export-sources`);
|
|
6212
|
+
// Host readiness is intentionally not probed while painting Exports. A send preflight first
|
|
6213
|
+
// establishes what the reviewed model would omit; only an authorized continuation may contact
|
|
6214
|
+
// AWARE or a CAD bridge.
|
|
6215
|
+
const renderReadyPromise = hasRender ? api('/api/render/readiness') : Promise.resolve(null);
|
|
6216
|
+
const [exportResult, renderReadyResult, sourceResult] = await Promise.allSettled([
|
|
6217
|
+
exportPromise, renderReadyPromise, sourcePromise,
|
|
6218
|
+
]);
|
|
6219
|
+
/*
|
|
6220
|
+
* A SUPERSEDED RENDER WRITES NOTHING AT ALL — checked HERE, before the first assignment, not
|
|
6221
|
+
* after the last.
|
|
6222
|
+
*
|
|
6223
|
+
* The guard used to sit below, and that was worse than having none. `exportSourcesState`,
|
|
6224
|
+
* `renderReadinessState` was assigned above it, so an older render
|
|
6225
|
+
* overwrote a newer one's answers with its own stale values and then returned WITHOUT painting:
|
|
6226
|
+
* the card showed the new answer while module state held the old one, and the next repaint that
|
|
6227
|
+
* does not re-fetch — `chooseAndSend`'s exit path is one — rendered the stale values. A visibly
|
|
6228
|
+
* wrong card became an invisibly inconsistent one, which is strictly harder to notice.
|
|
6229
|
+
*
|
|
6230
|
+
* Round 3 knowingly left those three above the guard because the only concurrency then was
|
|
6231
|
+
* CROSS-project, caught by `current.id !== id`. This slice made same-project concurrency
|
|
6232
|
+
* ordinary: the units event starts a render at `floless:display-units-changed`, and the reconcile
|
|
6233
|
+
* starts another. That justification no longer holds, so the writes moved under the guard rather
|
|
6234
|
+
* than the comment being re-argued. (Review round 5, both reviewers.)
|
|
6235
|
+
*
|
|
6236
|
+
* The failure branch below is under it too: a superseded render must not toast "Couldn't load
|
|
6237
|
+
* export status" over a card that a newer render has already painted correctly.
|
|
6238
|
+
*/
|
|
6239
|
+
if (renderGen !== exportsRenderGen || !current || current.id !== id || $wsExports.hidden) return;
|
|
6240
|
+
if (!sourcesRefused && sourceResult.status === 'fulfilled') {
|
|
6241
|
+
exportSourcesState.status = 'ready';
|
|
6242
|
+
exportSourcesState.data = sourceResult.value;
|
|
6243
|
+
if (!currentExportSourceOption()) exportSourcesState.selected = null;
|
|
6244
|
+
} else {
|
|
6245
|
+
exportSourcesState = { status: 'unavailable', data: null, selected: null, open: false };
|
|
6246
|
+
}
|
|
6247
|
+
if (hasRender) {
|
|
6248
|
+
// A readiness probe that fails is reported as unknown-with-a-retry, never as ready — the
|
|
6249
|
+
// same honesty the export listing keeps ("Status unavailable", never a fake "not exported").
|
|
6250
|
+
renderReadinessState = renderReadyResult.status === 'fulfilled' && renderReadyResult.value && renderReadyResult.value.readiness
|
|
6251
|
+
? renderReadyResult.value.readiness
|
|
6252
|
+
: {
|
|
6253
|
+
ok: false,
|
|
6254
|
+
state: 'error',
|
|
6255
|
+
// Prefer the server's own words, as the Tekla branch below already does. The route-gate
|
|
6256
|
+
// 409s this endpoint while AWARE is still installing and says so actionably; replacing
|
|
6257
|
+
// that with the generic line threw away the only sentence that told the user to wait.
|
|
6258
|
+
message: (renderReadyResult.reason && renderReadyResult.reason.message)
|
|
6259
|
+
|| 'Could not check whether rendering is available.',
|
|
6260
|
+
recovery: { action: 'retry', label: 'Check again' },
|
|
6261
|
+
};
|
|
6262
|
+
}
|
|
6263
|
+
if (exportResult.status === 'fulfilled') {
|
|
6264
|
+
const r = exportResult.value;
|
|
6265
|
+
state = {};
|
|
6266
|
+
for (const e of r.exports || []) state[e.kind] = e;
|
|
6267
|
+
// Authoritative gate state: an in-session edit clears approvedAt server-side, so trust the
|
|
6268
|
+
// server, not the possibly-stale current.approvedAt. Both of these are the SERVER's answers
|
|
6269
|
+
// about THIS project, so both are applied below the staleness guard rather than here — see
|
|
6270
|
+
// there for why.
|
|
6271
|
+
answered = true;
|
|
6272
|
+
approvedAt = r.approvedAt || undefined;
|
|
6273
|
+
units = r.units === 'mm' ? 'mm' : 'ft-in';
|
|
6274
|
+
} else {
|
|
6275
|
+
const err = exportResult.reason;
|
|
6276
|
+
// Surface the load failure — don't let it read as "nothing exported yet" (a lie).
|
|
6277
|
+
showToast('Couldn’t load export status: ' + (err && err.message || err), 'warn');
|
|
6278
|
+
state = null;
|
|
6279
|
+
}
|
|
6280
|
+
/*
|
|
6281
|
+
* EVERY SERVER ANSWER IS APPLIED BELOW THE GUARD, and the guard is now the one immediately after
|
|
6282
|
+
* `Promise.allSettled` — there is no await between it and here, so nothing can have changed in
|
|
6283
|
+
* between and a second copy of the check would be dead code pretending to protect this.
|
|
6284
|
+
*
|
|
6285
|
+
* The history is worth keeping, because the shape came back twice. `exportState` was always
|
|
6286
|
+
* applied under a guard; `approvedAt` and the units were not, so a response for the project the
|
|
6287
|
+
* user had just navigated away from could land on the one they were now looking at (round 2).
|
|
6288
|
+
* `exportSourcesState` and `renderReadinessState` were then left above a
|
|
6289
|
+
* guard that had learned to return early, which is worse than no guard at all: the older render
|
|
6290
|
+
* wrote its stale answers and went silent, so the card and the module state disagreed with
|
|
6291
|
+
* nothing on screen to say so (round 5). Moving the check above the first assignment is what
|
|
6292
|
+
* makes "superseded" mean "wrote nothing".
|
|
6293
|
+
*/
|
|
6294
|
+
if (answered) exportUnits = units;
|
|
6295
|
+
// ONLY WHEN THE SERVER ACTUALLY ANSWERED. On the failure path `approvedAt` still holds the
|
|
6296
|
+
// snapshot taken before the awaits, so writing it back would resurrect a sign-off that another
|
|
6297
|
+
// tab (or a revision read, which sets it to undefined to re-lock exports) had since cleared —
|
|
6298
|
+
// and `currentReceipt()` would then treat an older receipt as current. The old code wrote nothing
|
|
6299
|
+
// on failure; moving this line below the guard dropped its `if` by accident. (Review round 3.)
|
|
6300
|
+
if (answered) current.approvedAt = approvedAt;
|
|
6301
|
+
exportState = state;
|
|
6302
|
+
syncWorkspaceGuide(); // fresh approve/export state → tick the Export (and re-sync Approve) guide rows
|
|
6303
|
+
paintExports(approvedAt, restoreKind);
|
|
6304
|
+
}
|
|
6305
|
+
|
|
6306
|
+
return safeRenderExports;
|
|
6307
|
+
})();
|
|
6308
|
+
|
|
6309
|
+
async function captureSelectedExportSources(projectId, copies = 1, selectedSelector = null) {
|
|
6310
|
+
const option = selectedSelector ? { selector: selectedSelector } : currentExportSourceOption();
|
|
5104
6311
|
if (!option) throw new Error('Choose an export source first.');
|
|
5105
6312
|
let selector = option.selector;
|
|
5106
6313
|
if (option.selector.kind === 'working') {
|
|
@@ -5132,7 +6339,10 @@
|
|
|
5132
6339
|
});
|
|
5133
6340
|
exportSourcesState.selected = null;
|
|
5134
6341
|
showToast(`Exported raw package — ${result.filename}`, 'ok');
|
|
5135
|
-
|
|
6342
|
+
// Through the wrapper, and that is the POINT here rather than tidiness: this `await` sits
|
|
6343
|
+
// inside a try whose catch says "Raw export failed", so a repaint bug used to be reported to
|
|
6344
|
+
// the user as a failed export that had in fact just succeeded. The wrapper never rejects.
|
|
6345
|
+
if (current && current.id === projectId) await safeRenderExports('after exporting the raw package');
|
|
5136
6346
|
} catch (error) {
|
|
5137
6347
|
showToast('Raw export failed: ' + ((error && error.message) || error), 'warn');
|
|
5138
6348
|
}
|
|
@@ -5276,10 +6486,8 @@
|
|
|
5276
6486
|
// while this refresh is still in flight and would otherwise paint the pre-refresh state over
|
|
5277
6487
|
// it — the card reading "not exported yet" for a second after a successful export.
|
|
5278
6488
|
refreshing = true;
|
|
5279
|
-
return
|
|
5280
|
-
|
|
5281
|
-
if (current && current.id === projectId) paintExports(current.approvedAt);
|
|
5282
|
-
});
|
|
6489
|
+
return safeRenderExports('after that bill of materials export', undefined,
|
|
6490
|
+
() => { if (current && current.id === projectId) paintExports(current.approvedAt); });
|
|
5283
6491
|
}
|
|
5284
6492
|
exportSourcesState.selected = null; // non-default sources are one-shot; a later export returns to latest approved
|
|
5285
6493
|
track('workspace_export', { app, kind, sourceKind: capturedSource.kind }); // a successful export/bake
|
|
@@ -5290,18 +6498,28 @@
|
|
|
5290
6498
|
approvedAt,
|
|
5291
6499
|
});
|
|
5292
6500
|
const summary = receiptSummary(exportReceipts.get(`${projectId}:${kind}`), kind);
|
|
5293
|
-
|
|
5294
|
-
|
|
6501
|
+
// #1156a: an export that LEFT MEMBERS OUT must not announce itself as clean. The two sources
|
|
6502
|
+
// are different questions - the receipt says what the producer could not emit from what it was
|
|
6503
|
+
// given, `skippedDetail` says what was never given to it - so BOTH are gathered before a single
|
|
6504
|
+
// toast is raised. `showToast` appends rather than replaces, so emitting a clean "Exported"
|
|
6505
|
+
// and then a warning would leave the user reading two contradictory messages at once.
|
|
6506
|
+
const omittedNow = Array.isArray(res.skippedDetail) ? res.skippedDetail.length : 0;
|
|
6507
|
+
const gaps = [
|
|
6508
|
+
summary && summary.partial ? summary.text : null,
|
|
6509
|
+
omittedNow ? `${omittedNow} member${omittedNow === 1 ? '' : 's'} left out — see the card for why` : null,
|
|
6510
|
+
].filter(Boolean);
|
|
6511
|
+
showToast(gaps.length
|
|
6512
|
+
? `Exported with gaps — ${gaps.join(' · ')}`
|
|
5295
6513
|
: `Exported — ${res.filename || kind}`,
|
|
5296
|
-
|
|
6514
|
+
gaps.length ? 'warn' : 'ok');
|
|
5297
6515
|
refreshing = true;
|
|
5298
6516
|
// The catch is what makes the finally's skip safe: if the refresh itself throws, nothing else
|
|
5299
6517
|
// would repaint and the card would sit in its busy state forever, with exportBusy already
|
|
5300
6518
|
// cleared underneath it. Fall back to the paint the finally would have done.
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
6519
|
+
// repaint status + the authoritative receipt summary; the fallback is what makes the finally's
|
|
6520
|
+
// skip safe, so the card cannot sit in its busy state forever with exportBusy already cleared.
|
|
6521
|
+
return safeRenderExports('after that export', undefined,
|
|
6522
|
+
() => { if (current && current.id === projectId) paintExports(current.approvedAt); });
|
|
5305
6523
|
} catch (err) {
|
|
5306
6524
|
// The durable export listing may still show the previously published file, but its in-session
|
|
5307
6525
|
// receipt must not masquerade as the result of this failed attempt.
|
|
@@ -5333,7 +6551,9 @@
|
|
|
5333
6551
|
// "↗ Render image", greyed out, on a render that had just succeeded.
|
|
5334
6552
|
if (!refreshing && current && current.id === projectId) paintExports(current.approvedAt);
|
|
5335
6553
|
// Authoritative re-read: only the server knows which viewpoints actually landed.
|
|
5336
|
-
|
|
6554
|
+
// Through the wrapper because this `await` is inside a `finally`: a throw here would replace
|
|
6555
|
+
// whatever outcome the block was in the middle of reporting.
|
|
6556
|
+
if (publishedDespiteFailure && current && current.id === projectId) await safeRenderExports('after that render');
|
|
5337
6557
|
}
|
|
5338
6558
|
}
|
|
5339
6559
|
|
|
@@ -5355,7 +6575,7 @@
|
|
|
5355
6575
|
? 'That send described an earlier version of this project — approve again to send it.'
|
|
5356
6576
|
: 'That export described an earlier version of this project — approve again to export it.',
|
|
5357
6577
|
'info');
|
|
5358
|
-
if (!$wsExports.hidden)
|
|
6578
|
+
if (!$wsExports.hidden) safeRenderExports('after checking that export version');
|
|
5359
6579
|
}
|
|
5360
6580
|
return;
|
|
5361
6581
|
}
|
|
@@ -5441,30 +6661,6 @@
|
|
|
5441
6661
|
if (current) paintExports(current.approvedAt);
|
|
5442
6662
|
}
|
|
5443
6663
|
|
|
5444
|
-
/**
|
|
5445
|
-
* The CAD card's "Check again" — re-probe every destination.
|
|
5446
|
-
*
|
|
5447
|
-
* There is deliberately no per-ACTION branch here as the Tekla card had: with four destinations
|
|
5448
|
-
* out for four different reasons the card refuses to promote one of them, so the only thing it
|
|
5449
|
-
* can honestly offer is a re-check. The per-host fixes live on their own rows in the chooser,
|
|
5450
|
-
* where each sits beside the reason it addresses.
|
|
5451
|
-
*/
|
|
5452
|
-
async function recheckHosts() {
|
|
5453
|
-
if (!current) return;
|
|
5454
|
-
hostReadinessStates = Object.fromEntries(SEND_HOSTS.map((h) => [h.host, { ok: false, state: 'checking' }]));
|
|
5455
|
-
paintExports(current.approvedAt);
|
|
5456
|
-
return renderExports();
|
|
5457
|
-
}
|
|
5458
|
-
|
|
5459
|
-
/** The card's own recovery — today only the AWARE updater, which no per-host row can open. */
|
|
5460
|
-
function recoverHosts(action) {
|
|
5461
|
-
if (action !== 'update-aware') return;
|
|
5462
|
-
// Workspaces opens the shared updater; it never starts an install itself. Same route the render
|
|
5463
|
-
// card and the old Tekla card use.
|
|
5464
|
-
if (bridge.openAwareUpdate) bridge.openAwareUpdate('', document.activeElement);
|
|
5465
|
-
else showToast('Could not open the AWARE update dialog.', 'warn');
|
|
5466
|
-
}
|
|
5467
|
-
|
|
5468
6664
|
/**
|
|
5469
6665
|
* `kind` may carry a variant as `kind:variant` (a render viewpoint), because a kind can now hold
|
|
5470
6666
|
* several artifacts and Open/Reveal has to reach the one whose row was clicked — not merely the
|
|
@@ -5527,10 +6723,6 @@
|
|
|
5527
6723
|
if (e.target.closest('[data-open-exports-folder]')) { openExportsFolder(); return; }
|
|
5528
6724
|
const details = e.target.closest('[data-export-details]');
|
|
5529
6725
|
if (details) { showExportReceiptDetails(details.dataset.exportDetails, details); return; }
|
|
5530
|
-
const recheck = e.target.closest('[data-host-recheck]');
|
|
5531
|
-
if (recheck) { recheckHosts(); return; }
|
|
5532
|
-
const hostFix = e.target.closest('[data-host-recovery]');
|
|
5533
|
-
if (hostFix) { recoverHosts(hostFix.dataset.hostRecovery); return; }
|
|
5534
6726
|
const renderFix = e.target.closest('[data-render-recovery]');
|
|
5535
6727
|
if (renderFix) { recoverRender(renderFix.dataset.renderRecovery); return; }
|
|
5536
6728
|
const exp = e.target.closest('[data-export]');
|
|
@@ -5610,7 +6802,10 @@
|
|
|
5610
6802
|
// error shape alone. Track the page lifecycle so the retired document does not emit a false console
|
|
5611
6803
|
// error; `pageshow` resets the flag when the same document returns from the back-forward cache.
|
|
5612
6804
|
let workspacePageUnloading = false;
|
|
5613
|
-
window.addEventListener('pagehide', () => {
|
|
6805
|
+
window.addEventListener('pagehide', () => {
|
|
6806
|
+
workspacePageUnloading = true;
|
|
6807
|
+
releaseProjectHostBakeConsentsOnPageHide();
|
|
6808
|
+
});
|
|
5614
6809
|
window.addEventListener('pageshow', () => { workspacePageUnloading = false; });
|
|
5615
6810
|
/**
|
|
5616
6811
|
* Every piece of revision state above is PER-PROJECT, so opening or closing one must clear all of
|
|
@@ -5902,8 +7097,8 @@
|
|
|
5902
7097
|
return;
|
|
5903
7098
|
}
|
|
5904
7099
|
// Superseded while the requests were in flight. Everything past here reads the project and paints
|
|
5905
|
-
// the ONE shared card, so resuming would either throw on a null `current` (the
|
|
5906
|
-
//
|
|
7100
|
+
// the ONE shared card, so resuming would either throw on a null `current` (the back-to-projects
|
|
7101
|
+
// button, mid-poll) or paint the old project's revision state over the newly opened one.
|
|
5907
7102
|
if (gen !== revisionGen || !current || current.id !== proj.id) return;
|
|
5908
7103
|
const mine = reqs.filter((r) => r && r.type === 'revision-read' && r.project === proj.id);
|
|
5909
7104
|
// One project can retain an old failed request after the user follows its recovery instruction and
|
|
@@ -5972,7 +7167,7 @@
|
|
|
5972
7167
|
// nothing repainted them: the pane kept its live buttons and its per-destination Details
|
|
5973
7168
|
// rows describing a version that had just been superseded. Clicking Details then resolved
|
|
5974
7169
|
// no receipt and did nothing at all — a control that answers a click with silence.
|
|
5975
|
-
if (!$wsExports.hidden)
|
|
7170
|
+
if (!$wsExports.hidden) safeRenderExports('after the revision read');
|
|
5976
7171
|
showToast('Revision read complete — a new version is on History', 'ok');
|
|
5977
7172
|
}
|
|
5978
7173
|
}
|
|
@@ -6092,7 +7287,10 @@
|
|
|
6092
7287
|
frame.src = frame.dataset.want;
|
|
6093
7288
|
}
|
|
6094
7289
|
frames.drawings.addEventListener('load', () => {
|
|
6095
|
-
requestAnimationFrame(
|
|
7290
|
+
requestAnimationFrame(() => {
|
|
7291
|
+
reconcileDrawingRevisionRequestAfterLoad();
|
|
7292
|
+
syncWorkspaceReporter();
|
|
7293
|
+
});
|
|
6096
7294
|
});
|
|
6097
7295
|
|
|
6098
7296
|
function focusDrawingFilterSave() {
|
|
@@ -6194,7 +7392,16 @@
|
|
|
6194
7392
|
let revReviewState = null; // { projectId, requestId, stageId, summary, request, stale, returnFocus }
|
|
6195
7393
|
let revDiscardState = null; // { projectId, requestId, stageId, request, returnFocus, reviewWasOpen, terminal, coveredRoots }
|
|
6196
7394
|
|
|
6197
|
-
|
|
7395
|
+
function setRevisionReviewBusy(busy) {
|
|
7396
|
+
if (busy) $revReview.setAttribute('aria-busy', 'true');
|
|
7397
|
+
else $revReview.removeAttribute('aria-busy');
|
|
7398
|
+
$revReviewConfirm.disabled = busy;
|
|
7399
|
+
$revReviewCancel.disabled = busy;
|
|
7400
|
+
$revReviewDiscard.disabled = busy;
|
|
7401
|
+
$revReviewBody.inert = busy;
|
|
7402
|
+
}
|
|
7403
|
+
|
|
7404
|
+
/** `elevation_mm` → `Elevation mm`. A fallback, not a dictionary — the keys are schema names. */
|
|
6198
7405
|
const prettyKey = (k) => String(k).replace(/_/g, ' ').replace(/^./, (c) => c.toUpperCase());
|
|
6199
7406
|
const shortVal = (v) => {
|
|
6200
7407
|
if (v === undefined) return '—';
|
|
@@ -6298,11 +7505,11 @@
|
|
|
6298
7505
|
}
|
|
6299
7506
|
|
|
6300
7507
|
const KIND_LABEL = {
|
|
6301
|
-
'member-added': 'Member added', 'member-removed': 'Member removed', 'member-changed': 'Member changed',
|
|
7508
|
+
'member-added': 'Member added', 'provisional-member-added': 'Source-view member', 'provisional-group-refreshed': 'Placement evidence refreshed', 'member-removed': 'Member removed', 'member-changed': 'Member changed',
|
|
6302
7509
|
'plan-added': 'Sheet added', 'plan-changed': 'Sheet changed',
|
|
6303
7510
|
};
|
|
6304
7511
|
const KIND_CLASS = {
|
|
6305
|
-
'member-added': 'k-added', 'member-removed': 'k-removed', 'member-changed': 'k-changed',
|
|
7512
|
+
'member-added': 'k-added', 'provisional-member-added': 'k-changed', 'provisional-group-refreshed': 'k-changed', 'member-removed': 'k-removed', 'member-changed': 'k-changed',
|
|
6306
7513
|
'plan-added': 'k-added', 'plan-changed': 'k-changed', 'model-changed': 'k-changed',
|
|
6307
7514
|
};
|
|
6308
7515
|
/**
|
|
@@ -6339,6 +7546,47 @@
|
|
|
6339
7546
|
const memberHeadline = (m) =>
|
|
6340
7547
|
MEMBER_HEADLINE.map((k) => m[k]).filter((v) => v != null && v !== '').map(shortVal).join(' · ');
|
|
6341
7548
|
|
|
7549
|
+
/** Disclose the other plan references one provisional checkbox applies, using the server's bounded labels. */
|
|
7550
|
+
const appendProvisionalPresentationNote = (desc, p) => {
|
|
7551
|
+
const occurrences = Number(p.presentationCount) || 0;
|
|
7552
|
+
const views = Number(p.presentationViewCount) || 0;
|
|
7553
|
+
if (occurrences > 0 && views > 0) {
|
|
7554
|
+
const note = revEl('div', 'rev-row-note');
|
|
7555
|
+
note.appendChild(document.createTextNode('Accepting also shows this same member '));
|
|
7556
|
+
const quantity = occurrences === 1
|
|
7557
|
+
? 'once on 1 view'
|
|
7558
|
+
: `${occurrences} times ${views === 1 ? 'on 1 view' : `across ${views} views`}`;
|
|
7559
|
+
note.appendChild(revEl('b', null, quantity));
|
|
7560
|
+
const labels = Array.isArray(p.presentationViewLabels) ? p.presentationViewLabels : [];
|
|
7561
|
+
const remaining = Number(p.omittedPresentationViewCount) || 0;
|
|
7562
|
+
const named = labels.join(', ');
|
|
7563
|
+
const tail = remaining > 0
|
|
7564
|
+
? `${named ? `${named}, and ` : ''}${remaining} more`
|
|
7565
|
+
: named;
|
|
7566
|
+
note.appendChild(document.createTextNode(`${tail ? `: ${tail}` : ''}.`));
|
|
7567
|
+
desc.push(note);
|
|
7568
|
+
}
|
|
7569
|
+
|
|
7570
|
+
const conditionalOccurrences = Number(p.conditionalPresentationCount) || 0;
|
|
7571
|
+
const conditionalViews = Number(p.conditionalPresentationViewCount) || 0;
|
|
7572
|
+
if (conditionalOccurrences < 1 || conditionalViews < 1) return;
|
|
7573
|
+
const conditionalNote = revEl('div', 'rev-row-note');
|
|
7574
|
+
conditionalNote.appendChild(document.createTextNode('On the new views you separately accept, this same member appears '));
|
|
7575
|
+
const conditionalQuantity = conditionalOccurrences === 1
|
|
7576
|
+
? 'once on 1 view'
|
|
7577
|
+
: `${conditionalOccurrences} times ${conditionalViews === 1 ? 'on 1 view' : `across ${conditionalViews} views`}`;
|
|
7578
|
+
conditionalNote.appendChild(revEl('b', null, conditionalQuantity));
|
|
7579
|
+
const conditionalLabels = Array.isArray(p.conditionalPresentationViewLabels)
|
|
7580
|
+
? p.conditionalPresentationViewLabels : [];
|
|
7581
|
+
const conditionalRemaining = Number(p.omittedConditionalPresentationViewCount) || 0;
|
|
7582
|
+
const conditionalNamed = conditionalLabels.join(', ');
|
|
7583
|
+
const conditionalTail = conditionalRemaining > 0
|
|
7584
|
+
? `${conditionalNamed ? `${conditionalNamed}, and ` : ''}${conditionalRemaining} more`
|
|
7585
|
+
: conditionalNamed;
|
|
7586
|
+
conditionalNote.appendChild(document.createTextNode(`${conditionalTail ? `: ${conditionalTail}` : ''}.`));
|
|
7587
|
+
desc.push(conditionalNote);
|
|
7588
|
+
};
|
|
7589
|
+
|
|
6342
7590
|
function proposalRow(p, idx, bucket) {
|
|
6343
7591
|
const row = revEl('div', 'rev-row ' + (KIND_CLASS[p.kind] || 'k-changed'));
|
|
6344
7592
|
const id = `rev-${bucket}-${idx}`;
|
|
@@ -6417,9 +7665,49 @@
|
|
|
6417
7665
|
note.appendChild(document.createTextNode(' is positioned against this grid. Accepting replaces the whole grid, not only the lines shown above.'));
|
|
6418
7666
|
desc.push(note);
|
|
6419
7667
|
}
|
|
7668
|
+
} else if ((p.kind === 'provisional-member-added' || p.kind === 'provisional-group-refreshed') && p.member) {
|
|
7669
|
+
const sub = memberHeadline(p.member);
|
|
7670
|
+
if (sub) desc.push(revEl('div', 'rev-row-sub', sub));
|
|
7671
|
+
const geometry = p.member.geometry || {};
|
|
7672
|
+
const views = geometry.kind === 'view-frame-group'
|
|
7673
|
+
? [...new Set((geometry.traces || []).map((trace) => trace.viewId))]
|
|
7674
|
+
: [geometry.viewId].filter(Boolean);
|
|
7675
|
+
const view = views.join(', ');
|
|
7676
|
+
const sourceNote = revEl('div', 'rev-row-note');
|
|
7677
|
+
sourceNote.appendChild(document.createTextNode(p.kind === 'provisional-group-refreshed'
|
|
7678
|
+
? 'This replaces the complete unresolved placement evidence from '
|
|
7679
|
+
: 'This is a source-view member from '));
|
|
7680
|
+
sourceNote.appendChild(revEl('b', null, view || 'its source view'));
|
|
7681
|
+
sourceNote.appendChild(document.createTextNode(geometry.kind === 'view-frame-group'
|
|
7682
|
+
? '. Its exact source traces remain visible, but no model length or world placement is accepted.'
|
|
7683
|
+
: `. Its world position stays unresolved until ${view || 'that view'} is registered.`));
|
|
7684
|
+
desc.push(sourceNote);
|
|
7685
|
+
appendProvisionalPresentationNote(desc, p);
|
|
7686
|
+
if ((p.observations || []).length) {
|
|
7687
|
+
desc.push(revEl('div', 'rev-row-sub', 'Accepting also files the exact drawing trace that supports it.'));
|
|
7688
|
+
}
|
|
6420
7689
|
} else if (p.kind === 'member-added' && p.member) {
|
|
6421
7690
|
const sub = memberHeadline(p.member);
|
|
6422
7691
|
if (sub) desc.push(revEl('div', 'rev-row-sub', sub));
|
|
7692
|
+
// ONE TICK, TWO ACTS (#1176). Accepting this row now also files the drawing evidence that
|
|
7693
|
+
// justifies the member — the two used to be separate decisions, which is why a re-read could
|
|
7694
|
+
// never be applied: the evidence was refused and the member arrived displayed by nothing.
|
|
7695
|
+
//
|
|
7696
|
+
// A note with its own verb, not a clause spliced into the headline's " · " run: that idiom means
|
|
7697
|
+
// peer scalar attributes of one subject, and a consequence is not a fourth attribute. Not a
|
|
7698
|
+
// `data-tip` either — a tooltip carries a caveat ON TOP OF a sufficient visible line (see the
|
|
7699
|
+
// sheets line below), never a fact the user has to weigh to decide. Said whatever the count is,
|
|
7700
|
+
// unlike the multiplicity note below: this is what ticking the box DOES, not an exception to it.
|
|
7701
|
+
if ((p.observations || []).length) {
|
|
7702
|
+
const n = p.observations.length;
|
|
7703
|
+
const note = revEl('div', 'rev-row-note');
|
|
7704
|
+
note.appendChild(document.createTextNode('Accepting this also files '));
|
|
7705
|
+
note.appendChild(revEl('b', null, String(n)));
|
|
7706
|
+
note.appendChild(document.createTextNode(n === 1
|
|
7707
|
+
? ' piece of drawing evidence that justifies this member.'
|
|
7708
|
+
: ' pieces of drawing evidence that justify this member.'));
|
|
7709
|
+
desc.push(note);
|
|
7710
|
+
}
|
|
6423
7711
|
} else if (p.kind === 'member-removed') {
|
|
6424
7712
|
// WHAT is being deleted, then WHERE it is on record — two lines, not one dot-run. " · " already
|
|
6425
7713
|
// means "peer scalar attributes of one subject" in the line above; a clause with its own verb is
|
|
@@ -6469,6 +7757,36 @@
|
|
|
6469
7757
|
on.setAttribute('data-tip', 'Sheets that list this member or supply its evidence. A column can also appear on other sheets whose level its span crosses.');
|
|
6470
7758
|
desc.push(on);
|
|
6471
7759
|
}
|
|
7760
|
+
// ONE TICK, TWO ACTS, the mirror of the `member-added` note above (#1176) — and LAST, because it
|
|
7761
|
+
// continues the "what is on record" thread the sheets line opened rather than competing with the
|
|
7762
|
+
// identity line for attention.
|
|
7763
|
+
//
|
|
7764
|
+
// INDEPENDENT of the `matches` chain above, deliberately: nesting it under `p.member` would
|
|
7765
|
+
// silently stop it firing on the multi-match row, which is the one where a removal does the most.
|
|
7766
|
+
// Suppressed on `matches === 0` because that row cannot be applied at all, and promising what
|
|
7767
|
+
// accepting it would archive is the same false-by-omission the note there exists to avoid.
|
|
7768
|
+
// ARCHIVES and NARROWS are different promises and are worded separately. The first draft counted
|
|
7769
|
+
// every trace that named the member and called them all archived; review reproduced a row saying
|
|
7770
|
+
// "archives 1" over an apply that archived none, because that trace also named a member the read
|
|
7771
|
+
// KEEPS. A consent screen may not over-name the act it is asking for.
|
|
7772
|
+
const retires = (p.retires || []).length, narrows = (p.narrows || []).length;
|
|
7773
|
+
if ((retires || narrows) && p.matches !== 0) {
|
|
7774
|
+
const note = revEl('div', 'rev-row-note');
|
|
7775
|
+
note.appendChild(document.createTextNode('Accepting this also retires '));
|
|
7776
|
+
note.appendChild(revEl('b', null, String(retires + narrows)));
|
|
7777
|
+
note.appendChild(document.createTextNode(retires + narrows === 1 ? ' piece of drawing evidence: ' : ' pieces of drawing evidence: '));
|
|
7778
|
+
const clauses = [];
|
|
7779
|
+
// "once the removals it names are taken" is load-bearing, not hedging: a trace can name two
|
|
7780
|
+
// members this read deletes, and taking only THIS row leaves it live and narrowed. Asserting
|
|
7781
|
+
// the archive flatly would be false for that selection.
|
|
7782
|
+
// NOT "archived": an ACTIVE trace this empties is archived, a superseded one is left superseded.
|
|
7783
|
+
// What is true of both, and what the human needs, is that it stops naming this member and stays on
|
|
7784
|
+
// record. Saying "archives" named traces that are never archived.
|
|
7785
|
+
if (retires) clauses.push(`${retires} ${retires === 1 ? 'stops' : 'stop'} naming this member and ${retires === 1 ? 'stays' : 'stay'} on record as audit provenance, once the removals ${retires === 1 ? 'it names are' : 'they name are'} taken`);
|
|
7786
|
+
if (narrows) clauses.push(`${narrows} ${narrows === 1 ? 'stops' : 'stop'} naming this member and ${narrows === 1 ? 'stays' : 'stay'} live, because ${narrows === 1 ? 'it also names' : 'they also name'} a member this read keeps`);
|
|
7787
|
+
note.appendChild(document.createTextNode(`${clauses.join('; ')}.`));
|
|
7788
|
+
desc.push(note);
|
|
7789
|
+
}
|
|
6472
7790
|
} else if (p.kind === 'plan-added') {
|
|
6473
7791
|
const keys = Object.keys(p.plan || {}).filter((k) => k !== 'sheet' && k !== 'id');
|
|
6474
7792
|
desc.push(revEl('div', 'rev-row-sub', keys.length ? `${keys.length} field${keys.length > 1 ? 's' : ''}: ${keys.slice(0, 6).map(prettyKey).join(', ')}${keys.length > 6 ? '…' : ''}` : 'a new sheet'));
|
|
@@ -6477,6 +7795,26 @@
|
|
|
6477
7795
|
if ((p.omitted || []).length) {
|
|
6478
7796
|
desc.push(revEl('div', 'rev-row-note', `The page image and traced linework come with this sheet (${p.omitted.map(prettyKey).join(', ')}).`));
|
|
6479
7797
|
}
|
|
7798
|
+
const bundled = p.provisionalMembers || [];
|
|
7799
|
+
if (bundled.length) {
|
|
7800
|
+
desc.push(revEl('div', 'rev-row-note', 'Accepting this sheet also adds the source-view members and files the drawing evidence listed below in the same step.'));
|
|
7801
|
+
for (const entry of bundled) {
|
|
7802
|
+
const member = entry.member || {};
|
|
7803
|
+
const view = (member.geometry && member.geometry.viewId) || p.viewId || 'its source view';
|
|
7804
|
+
desc.push(revEl('div', 'rev-row-sub', `${entry.memberId || member.id || 'Unidentified member'} · ${memberHeadline(member) || 'profile not recorded'} · source view ${view}`));
|
|
7805
|
+
appendProvisionalPresentationNote(desc, entry);
|
|
7806
|
+
const observations = entry.observations || [];
|
|
7807
|
+
if (!observations.length) {
|
|
7808
|
+
desc.push(revEl('div', 'rev-row-note', `World position unresolved until ${view} is registered. No supporting evidence was included.`));
|
|
7809
|
+
continue;
|
|
7810
|
+
}
|
|
7811
|
+
for (const carried of observations) {
|
|
7812
|
+
const observation = carried.observation || {};
|
|
7813
|
+
const source = (observation.evidence && observation.evidence.source) || {};
|
|
7814
|
+
desc.push(revEl('div', 'rev-row-note', `World position unresolved until ${view} is registered. Evidence: ${observation.id || 'unidentified'} · sheet ${source.sheet || 'not recorded'} · element ${source.elementId || 'not recorded'}.`));
|
|
7815
|
+
}
|
|
7816
|
+
}
|
|
7817
|
+
}
|
|
6480
7818
|
}
|
|
6481
7819
|
if (desc.length) {
|
|
6482
7820
|
desc.forEach((n, i) => { n.id = `${id}-desc-${i}`; main.appendChild(n); });
|
|
@@ -6561,6 +7899,7 @@
|
|
|
6561
7899
|
if (summary.accepted) bits.push([String(summary.accepted), ` change${summary.accepted > 1 ? 's' : ''} taken automatically`]);
|
|
6562
7900
|
if (summary.bindingUpdates) bits.push([String(summary.bindingUpdates), ` evidence link${summary.bindingUpdates > 1 ? 's' : ''} updated`]);
|
|
6563
7901
|
$revReviewCounts.replaceChildren();
|
|
7902
|
+
delete $revReviewCounts.dataset.revRfiSelection;
|
|
6564
7903
|
if (bits.length) {
|
|
6565
7904
|
bits.forEach(([n, rest], i) => {
|
|
6566
7905
|
if (i) $revReviewCounts.appendChild(document.createTextNode(' · '));
|
|
@@ -6571,7 +7910,21 @@
|
|
|
6571
7910
|
? ' — what this read was sure of when it was prepared.'
|
|
6572
7911
|
: ' — what the read was sure of, already taken.'));
|
|
6573
7912
|
$revReviewCounts.hidden = false;
|
|
6574
|
-
}
|
|
7913
|
+
}
|
|
7914
|
+
const rfiDecision = summary.rfiSelection;
|
|
7915
|
+
if (rfiDecision?.decision === 'decided') {
|
|
7916
|
+
if (bits.length) $revReviewCounts.appendChild(document.createTextNode(' · '));
|
|
7917
|
+
const count = rfiDecision.count;
|
|
7918
|
+
$revReviewCounts.appendChild(document.createTextNode(readOnly
|
|
7919
|
+
? count
|
|
7920
|
+
? `${count} unanswered question${count === 1 ? '' : 's'} were carried with this review.`
|
|
7921
|
+
: 'No unanswered questions were carried with this review.'
|
|
7922
|
+
: count
|
|
7923
|
+
? `${count} unanswered question${count === 1 ? '' : 's'} ${count === 1 ? 'is' : 'are'} carried with this review. Apply will create or reuse an RFI for each one that remains in the final report.`
|
|
7924
|
+
: 'No unanswered questions are carried with this review.'));
|
|
7925
|
+
$revReviewCounts.dataset.revRfiSelection = 'decided';
|
|
7926
|
+
}
|
|
7927
|
+
$revReviewCounts.hidden = !bits.length && rfiDecision?.decision !== 'decided';
|
|
6575
7928
|
|
|
6576
7929
|
const props = summary.proposals || [];
|
|
6577
7930
|
const binds = summary.bindingProposals || [];
|
|
@@ -6617,6 +7970,88 @@
|
|
|
6617
7970
|
$revReviewBody.replaceChildren(body);
|
|
6618
7971
|
}
|
|
6619
7972
|
|
|
7973
|
+
function showRequiredRfiSelection(summary, modelChanged = false) {
|
|
7974
|
+
const count = summary?.rfiSelection?.count ?? 0;
|
|
7975
|
+
$revReviewChanged.replaceChildren();
|
|
7976
|
+
$revReviewChanged.appendChild(revEl('b', null, modelChanged
|
|
7977
|
+
? 'The model changed while you were reviewing.'
|
|
7978
|
+
: 'This review needs a new unanswered-question choice.'));
|
|
7979
|
+
$revReviewChanged.appendChild(document.createTextNode(modelChanged
|
|
7980
|
+
? ` This is the current review, and your ticks were cleared. The earlier review also carried ${count} unanswered question${count === 1 ? '' : 's'}; ask the terminal AI to submit that choice again for this current review, including “none” if appropriate. Then close and reopen Review.`
|
|
7981
|
+
: ` The earlier stage carried ${count} unanswered question${count === 1 ? '' : 's'}, but that choice cannot be reused here. Ask the terminal AI to submit its choice for this current review, including “none” if appropriate. Then close and reopen Review.`));
|
|
7982
|
+
$revReviewChanged.dataset.kind = 'rfi-selection-required';
|
|
7983
|
+
$revReviewChanged.hidden = false;
|
|
7984
|
+
$revReviewConfirm.hidden = true;
|
|
7985
|
+
}
|
|
7986
|
+
|
|
7987
|
+
function renderRevisionRfiResult(result) {
|
|
7988
|
+
const outcomes = Array.isArray(result.rfis) ? result.rfis : [];
|
|
7989
|
+
const unasked = Array.isArray(result.unaskedRfis) ? result.unaskedRfis : [];
|
|
7990
|
+
const created = outcomes.filter((row) => ['created', 'successor'].includes(row.result));
|
|
7991
|
+
const existing = outcomes.filter((row) => ['reused', 'reopened', 'already-seeded'].includes(row.result));
|
|
7992
|
+
const removed = outcomes.filter((row) => row.result === 'not-in-report');
|
|
7993
|
+
const attention = outcomes.filter((row) => !['created', 'reused', 'reopened', 'successor', 'already-seeded', 'not-in-report'].includes(row.result));
|
|
7994
|
+
$revReviewCounts.replaceChildren(document.createTextNode(
|
|
7995
|
+
`RFI result: ${created.length} created · ${existing.length} existing record${existing.length === 1 ? '' : 's'} used · ${removed.length} selected question${removed.length === 1 ? '' : 's'} no longer in the final report · ${unasked.length} new question${unasked.length === 1 ? '' : 's'} appeared only at confirm and ${unasked.length === 1 ? 'was' : 'were'} not filed.${attention.length ? ` ${attention.length} other RFI result${attention.length === 1 ? '' : 's'} need attention.` : ''}`,
|
|
7996
|
+
));
|
|
7997
|
+
$revReviewCounts.dataset.revRfiSelection = 'result';
|
|
7998
|
+
$revReviewCounts.hidden = false;
|
|
7999
|
+
|
|
8000
|
+
const body = document.createDocumentFragment();
|
|
8001
|
+
const records = [...created, ...existing];
|
|
8002
|
+
const resultNote = {
|
|
8003
|
+
created: 'Created for this project version.',
|
|
8004
|
+
successor: 'Created as a successor to an earlier closed RFI.',
|
|
8005
|
+
reused: 'The existing open record was reused for this project version.',
|
|
8006
|
+
reopened: 'The existing record was reopened for this project version.',
|
|
8007
|
+
'already-seeded': 'Already linked to this project version; no duplicate was created.',
|
|
8008
|
+
};
|
|
8009
|
+
if (records.length) {
|
|
8010
|
+
const section = group('RFI records', records.length);
|
|
8011
|
+
for (const row of records) {
|
|
8012
|
+
const item = revEl('div', 'rev-row');
|
|
8013
|
+
item.appendChild(revEl('div', 'rev-row-title', `${row.rfiId || 'RFI'} — ${row.gapKey}`));
|
|
8014
|
+
item.appendChild(revEl('div', 'rev-row-note', resultNote[row.result] || `The RFI operation ended as ${row.result}.`));
|
|
8015
|
+
section.appendChild(item);
|
|
8016
|
+
}
|
|
8017
|
+
body.appendChild(section);
|
|
8018
|
+
}
|
|
8019
|
+
if (removed.length) {
|
|
8020
|
+
const section = group('Selected questions no longer in the report', removed.length);
|
|
8021
|
+
for (const row of removed) {
|
|
8022
|
+
const item = revEl('div', 'rev-row');
|
|
8023
|
+
item.appendChild(revEl('div', 'rev-row-title', `${row.rfiId ? `${row.rfiId} — ` : ''}${row.gapKey}`));
|
|
8024
|
+
item.appendChild(revEl('div', 'rev-row-note', 'Your accepted changes removed this question from the final report, so it was not filed.'));
|
|
8025
|
+
section.appendChild(item);
|
|
8026
|
+
}
|
|
8027
|
+
body.appendChild(section);
|
|
8028
|
+
}
|
|
8029
|
+
if (unasked.length) {
|
|
8030
|
+
const section = group('New questions that were not filed', unasked.length);
|
|
8031
|
+
for (const row of unasked) {
|
|
8032
|
+
const item = revEl('div', 'rev-row');
|
|
8033
|
+
item.appendChild(revEl('div', 'rev-row-title', row.question || row.gapKey || 'Unanswered question'));
|
|
8034
|
+
item.appendChild(revEl('div', 'rev-row-note', 'This appeared only after applying your choices. It was not asked and was not filed.'));
|
|
8035
|
+
section.appendChild(item);
|
|
8036
|
+
}
|
|
8037
|
+
body.appendChild(section);
|
|
8038
|
+
}
|
|
8039
|
+
if (attention.length) {
|
|
8040
|
+
const section = group('RFI results needing attention', attention.length);
|
|
8041
|
+
for (const row of attention) {
|
|
8042
|
+
const item = revEl('div', 'rev-row');
|
|
8043
|
+
item.appendChild(revEl('div', 'rev-row-title', `${row.rfiId ? `${row.rfiId} — ` : ''}${row.gapKey}`));
|
|
8044
|
+
item.appendChild(revEl('div', 'rev-row-note', row.why || `The RFI operation ended as ${row.result}.`));
|
|
8045
|
+
section.appendChild(item);
|
|
8046
|
+
}
|
|
8047
|
+
body.appendChild(section);
|
|
8048
|
+
}
|
|
8049
|
+
if (!records.length && !removed.length && !unasked.length && !attention.length) {
|
|
8050
|
+
body.appendChild(revEl('div', 'hd-empty', 'No RFI record changed with this revision.'));
|
|
8051
|
+
}
|
|
8052
|
+
$revReviewBody.replaceChildren(body);
|
|
8053
|
+
}
|
|
8054
|
+
|
|
6620
8055
|
/**
|
|
6621
8056
|
* Close the review and REPAINT THE CARD, on every path.
|
|
6622
8057
|
*
|
|
@@ -6636,18 +8071,28 @@
|
|
|
6636
8071
|
$revReview.classList.remove('show');
|
|
6637
8072
|
const st = revReviewState;
|
|
6638
8073
|
revReviewState = null;
|
|
8074
|
+
$revReviewCancel.dataset.commandId = 'shell.dialog-cancel#the revision review';
|
|
6639
8075
|
$revReviewTitle.textContent = 'Review this read';
|
|
6640
8076
|
$revReviewChanged.hidden = true;
|
|
8077
|
+
delete $revReviewChanged.dataset.kind;
|
|
6641
8078
|
$revReviewConfirm.disabled = false;
|
|
6642
8079
|
$revReviewConfirm.hidden = false;
|
|
6643
8080
|
$revReviewDiscard.hidden = true;
|
|
8081
|
+
setRevisionReviewBusy(false);
|
|
6644
8082
|
const back = st && st.returnFocus;
|
|
6645
|
-
if (restoreFocus) {
|
|
8083
|
+
if (restoreFocus && !st?.terminal) {
|
|
6646
8084
|
if (back instanceof HTMLElement && back.isConnected) back.focus();
|
|
6647
8085
|
else { const b = $revisionCard.querySelector('[data-revreview]'); if (b) b.focus(); }
|
|
6648
8086
|
}
|
|
6649
8087
|
// Only when something was actually open — otherwise every `closeProject` would fire a stray fetch.
|
|
6650
|
-
if (wasOpen)
|
|
8088
|
+
if (wasOpen) {
|
|
8089
|
+
const repaint = renderRevisionCard();
|
|
8090
|
+
if (restoreFocus && st?.terminal) Promise.resolve(repaint).catch(() => {}).finally(() => requestAnimationFrame(() => {
|
|
8091
|
+
const next = $revisionCard.querySelector('[data-revreview], [data-revdiscard]')
|
|
8092
|
+
|| document.querySelector('[data-step="history"]');
|
|
8093
|
+
if (next instanceof HTMLElement) next.focus();
|
|
8094
|
+
}));
|
|
8095
|
+
}
|
|
6651
8096
|
}
|
|
6652
8097
|
|
|
6653
8098
|
async function openRevisionReview(req) {
|
|
@@ -6710,13 +8155,15 @@
|
|
|
6710
8155
|
? `This read started from v${reviewRequest.baseVersion}, but the project is now at v${reviewRequest.headVersion}. It can’t be applied to the current model. The proposal below is for reference only.`
|
|
6711
8156
|
: 'Nothing is applied until you confirm. Everything starts unticked — tick what this read may change.';
|
|
6712
8157
|
$revReviewChanged.hidden = true;
|
|
8158
|
+
delete $revReviewChanged.dataset.kind;
|
|
6713
8159
|
renderReview(summary, { readOnly });
|
|
6714
8160
|
revReviewState = { projectId, requestId: req.id, stageId: summary.stageId, summary, request: reviewRequest, stale: readOnly, returnFocus };
|
|
6715
8161
|
$revReviewConfirm.hidden = readOnly;
|
|
8162
|
+
if (!readOnly && summary.rfiSelection?.decision === 'required') showRequiredRfiSelection(summary);
|
|
6716
8163
|
$revReviewDiscard.hidden = !canDiscardRevision(reviewRequest);
|
|
6717
8164
|
$revReview.classList.add('show');
|
|
6718
8165
|
const first = $revReviewBody.querySelector('input[type="checkbox"]');
|
|
6719
|
-
(first || $revReviewCancel).focus();
|
|
8166
|
+
(summary.rfiSelection?.decision === 'required' ? $revReviewCancel : (first || $revReviewCancel)).focus();
|
|
6720
8167
|
}
|
|
6721
8168
|
|
|
6722
8169
|
function openRevisionDiscard(req, returnFocus = document.activeElement) {
|
|
@@ -6837,7 +8284,7 @@
|
|
|
6837
8284
|
|
|
6838
8285
|
async function confirmRevisionReview() {
|
|
6839
8286
|
const st = revReviewState;
|
|
6840
|
-
if (!st || st.stale) return;
|
|
8287
|
+
if (!st || st.stale || $revReview.hasAttribute('aria-busy')) return;
|
|
6841
8288
|
const accept = { proposals: [], bindingProposals: [] };
|
|
6842
8289
|
for (const box of $revReviewBody.querySelectorAll('input[type="checkbox"]:checked')) {
|
|
6843
8290
|
const bucket = box.dataset.revbucket;
|
|
@@ -6853,7 +8300,7 @@
|
|
|
6853
8300
|
// reason to hand back a shuffled list.
|
|
6854
8301
|
accept.proposals.sort((a, b) => a - b);
|
|
6855
8302
|
accept.bindingProposals.sort((a, b) => a - b);
|
|
6856
|
-
|
|
8303
|
+
setRevisionReviewBusy(true); // busy state, NOT an empty-selection state
|
|
6857
8304
|
$revReviewConfirm.setAttribute('aria-busy', 'true');
|
|
6858
8305
|
// A busy LABEL too. Approve, the KB adjust and every export card swap their text while working; a
|
|
6859
8306
|
// button that only dims leaves the user unsure the click registered.
|
|
@@ -6863,6 +8310,7 @@
|
|
|
6863
8310
|
// could leave it latched: a throw inside `renderReview` skipped the two lines that restore it, and
|
|
6864
8311
|
// the user was left with a modal they could read and not act on. A `finally` cannot be forgotten by
|
|
6865
8312
|
// a path added later, which is the actual fix — restoring it in three places was the bug waiting.
|
|
8313
|
+
let focusCloseAfterBusy = false;
|
|
6866
8314
|
try {
|
|
6867
8315
|
let res;
|
|
6868
8316
|
try {
|
|
@@ -6873,6 +8321,37 @@
|
|
|
6873
8321
|
// THE MODEL MOVED WHILE THE USER WAS READING. The server has already re-staged and handed back the
|
|
6874
8322
|
// CURRENT review with a fresh stageId, so this re-renders in place rather than closing: closing
|
|
6875
8323
|
// would lose the user's place and make them re-open a card to see what changed.
|
|
8324
|
+
// THE SELECTION IS WRONG, NOT THE REVIEW (#1176). The server assembles what was ticked, finds it
|
|
8325
|
+
// would leave the model referring to a member it removes, and REFUSES WITHOUT DROPPING THE
|
|
8326
|
+
// STAGE — not because that is unique (other refusals keep it too), but because here
|
|
8327
|
+
// the next move is to untick one row and confirm again, so the modal must stay open, the ticks
|
|
8328
|
+
// must survive (no `renderReview` — it rebuilds them unticked), and the message must be
|
|
8329
|
+
// readable. A toast is the wrong channel twice over: it auto-dismisses, and this sentence is
|
|
8330
|
+
// long, because it names the member, what still uses it, and both ways forward.
|
|
8331
|
+
if (err && err.body && err.body.code === 'selection-not-applicable') {
|
|
8332
|
+
// KEYED ON THE CODE ALONE. Requiring `err.body.error` too made the modal's survival depend on
|
|
8333
|
+
// the message being present: a refusal that arrived without one fell through to the generic
|
|
8334
|
+
// path below, which closes the modal and destroys the ticks — on a stage the server
|
|
8335
|
+
// deliberately KEPT so the user could edit them. Unreachable today; the wrong way to be wrong.
|
|
8336
|
+
//
|
|
8337
|
+
// The server's sentence is used VERBATIM when it is there. It was authored as the whole
|
|
8338
|
+
// answer; rephrasing it here would drift from what the server actually decided.
|
|
8339
|
+
$revReviewChanged.replaceChildren();
|
|
8340
|
+
$revReviewChanged.appendChild(revEl('b', null, 'This selection can’t be applied.'));
|
|
8341
|
+
$revReviewChanged.appendChild(document.createTextNode(' ' + (err.body.error
|
|
8342
|
+
|| 'The changes you ticked cannot be applied together. Untick a removal and confirm again.')));
|
|
8343
|
+
$revReviewChanged.dataset.kind = 'blocked';
|
|
8344
|
+
$revReviewChanged.hidden = false;
|
|
8345
|
+
return;
|
|
8346
|
+
}
|
|
8347
|
+
if (err && err.body && err.body.code === 'rfi-selection-stage-superseded') {
|
|
8348
|
+
showRequiredRfiSelection({ rfiSelection: {
|
|
8349
|
+
decision: 'required',
|
|
8350
|
+
count: err.body.supersededSelection?.count ?? st.summary?.rfiSelection?.count ?? 0,
|
|
8351
|
+
} });
|
|
8352
|
+
focusCloseAfterBusy = true;
|
|
8353
|
+
return;
|
|
8354
|
+
}
|
|
6876
8355
|
const fresh = err && err.body && err.body.staged;
|
|
6877
8356
|
if (fresh) {
|
|
6878
8357
|
// RENDER FIRST, THEN adopt the new stage. The order matters on the failure path review found:
|
|
@@ -6882,17 +8361,20 @@
|
|
|
6882
8361
|
// stale-but-consistent pair, and the `finally` below still restores the button.
|
|
6883
8362
|
renderReview(fresh); // replaceChildren builds new, unticked inputs — no tick can survive it
|
|
6884
8363
|
revReviewState = { ...st, stageId: fresh.stageId, summary: fresh };
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
8364
|
+
if (fresh.rfiSelection?.decision === 'required') showRequiredRfiSelection(fresh, true);
|
|
8365
|
+
else {
|
|
8366
|
+
$revReviewChanged.replaceChildren();
|
|
8367
|
+
$revReviewChanged.appendChild(revEl('b', null, 'The model changed while you were reviewing.'));
|
|
8368
|
+
$revReviewChanged.appendChild(document.createTextNode(' This is the current review, and your ticks were cleared — the same change can mean something different against a model that moved, so each one needs deciding again.'));
|
|
8369
|
+
$revReviewChanged.dataset.kind = 'stale';
|
|
8370
|
+
$revReviewChanged.hidden = false;
|
|
8371
|
+
}
|
|
6889
8372
|
return;
|
|
6890
8373
|
}
|
|
6891
8374
|
showToast('Could not apply: ' + ((err && err.message) || err), 'warn');
|
|
6892
8375
|
closeRevReview(); // repaints the card itself
|
|
6893
8376
|
return;
|
|
6894
8377
|
}
|
|
6895
|
-
const n = accept.proposals.length + accept.bindingProposals.length;
|
|
6896
8378
|
// Settle the surrounding state BEFORE closing, because closing is what repaints the card now —
|
|
6897
8379
|
// `lastRevState` in particular, or the repaint would read the old value and re-run the
|
|
6898
8380
|
// completion check against a request confirm has already deleted.
|
|
@@ -6901,33 +8383,108 @@
|
|
|
6901
8383
|
current.approvedAt = undefined; // applying a read clears the sign-off; exports re-lock
|
|
6902
8384
|
if (!$wsHistory.hidden) renderHistory();
|
|
6903
8385
|
}
|
|
8386
|
+
$revReviewTitle.textContent = 'Revision applied';
|
|
8387
|
+
$revReviewSub.textContent = `Version v${res.version?.n ?? res.versionN ?? '—'} is now on History.`;
|
|
8388
|
+
$revReviewConfirm.hidden = true;
|
|
8389
|
+
$revReviewDiscard.hidden = true;
|
|
8390
|
+
if (res.rfiFailure) {
|
|
8391
|
+
$revReviewChanged.replaceChildren();
|
|
8392
|
+
$revReviewChanged.appendChild(revEl('b', null, 'The revision was applied, but its RFI records need attention.'));
|
|
8393
|
+
$revReviewChanged.appendChild(document.createTextNode(` ${res.rfiFailure.error || res.rfiFailure.code || 'The RFI record update did not complete.'}`));
|
|
8394
|
+
$revReviewChanged.dataset.kind = 'blocked';
|
|
8395
|
+
$revReviewChanged.hidden = false;
|
|
8396
|
+
} else {
|
|
8397
|
+
$revReviewChanged.hidden = true;
|
|
8398
|
+
delete $revReviewChanged.dataset.kind;
|
|
8399
|
+
}
|
|
8400
|
+
renderRevisionRfiResult(res);
|
|
8401
|
+
revReviewState = { ...st, terminal: true };
|
|
8402
|
+
$revReviewCancel.dataset.commandId = 'shell.dialog-close#the revision result';
|
|
8403
|
+
// Publish the terminal dialog identity before refreshing any surrounding client state. The
|
|
8404
|
+
// refresh can reload the model iframe, whose load boundary settles focus below.
|
|
6904
8405
|
if (bridge.loadRequests) bridge.loadRequests().catch(() => {});
|
|
6905
|
-
|
|
6906
|
-
closeRevReview(); // one close, one repaint
|
|
8406
|
+
focusCloseAfterBusy = true;
|
|
6907
8407
|
} finally {
|
|
6908
8408
|
// Always, on every path including a throw from the re-render above.
|
|
6909
|
-
|
|
8409
|
+
setRevisionReviewBusy(false);
|
|
6910
8410
|
$revReviewConfirm.removeAttribute('aria-busy');
|
|
6911
8411
|
$revReviewConfirm.textContent = confirmLabel;
|
|
8412
|
+
if (focusCloseAfterBusy) {
|
|
8413
|
+
$revReviewCancel.focus();
|
|
8414
|
+
// The iframe can finish the navigation that confirm triggered after this synchronous focus.
|
|
8415
|
+
// Arm the same bounded post-load check here too, so either event order ends on Close.
|
|
8416
|
+
retainTerminalRevisionReviewFocus();
|
|
8417
|
+
}
|
|
6912
8418
|
}
|
|
6913
8419
|
}
|
|
6914
8420
|
|
|
8421
|
+
/**
|
|
8422
|
+
* The blocked banner describes a SELECTION, so it stops being true the moment the selection changes.
|
|
8423
|
+
*
|
|
8424
|
+
* Scoped by `kind`, never unconditional: the "model changed" banner explains why the ticks were
|
|
8425
|
+
* cleared, and hiding it as the user re-ticks would delete the reason mid-way through acting on it.
|
|
8426
|
+
*/
|
|
8427
|
+
function clearBlockedBanner() {
|
|
8428
|
+
if ($revReviewChanged.dataset.kind !== 'blocked') return;
|
|
8429
|
+
$revReviewChanged.hidden = true;
|
|
8430
|
+
delete $revReviewChanged.dataset.kind;
|
|
8431
|
+
}
|
|
8432
|
+
|
|
8433
|
+
$revReviewBody.addEventListener('change', (e) => {
|
|
8434
|
+
if ($revReview.hasAttribute('aria-busy')) return;
|
|
8435
|
+
if (e.target.matches('input[type="checkbox"]')) clearBlockedBanner();
|
|
8436
|
+
});
|
|
8437
|
+
|
|
6915
8438
|
$revReviewBody.addEventListener('click', (e) => {
|
|
8439
|
+
if ($revReview.hasAttribute('aria-busy')) return;
|
|
6916
8440
|
const bulk = e.target.closest('[data-revbulk]');
|
|
6917
8441
|
if (!bulk) return;
|
|
6918
8442
|
const on = bulk.dataset.revbulkon === '1';
|
|
6919
8443
|
for (const box of $revReviewBody.querySelectorAll(`input[data-revbucket="${bulk.dataset.revbulk}"]`)) box.checked = on;
|
|
8444
|
+
// CALLED, not left to the `change` listener above: setting `.checked` from script fires no `change`
|
|
8445
|
+
// event, so bulk Accept-all / Clear-all would change the whole selection under a banner still
|
|
8446
|
+
// claiming the old one cannot be applied. The one route that alters every tick at once is exactly
|
|
8447
|
+
// the one where a stale explanation misleads most.
|
|
8448
|
+
clearBlockedBanner();
|
|
6920
8449
|
});
|
|
6921
8450
|
$revReviewDiscard.addEventListener('click', (e) => {
|
|
8451
|
+
if ($revReview.hasAttribute('aria-busy')) return;
|
|
6922
8452
|
const st = revReviewState;
|
|
6923
8453
|
if (st) openRevisionDiscard({ ...st.request, stageId: st.stageId }, e.currentTarget);
|
|
6924
8454
|
});
|
|
6925
8455
|
$revReviewConfirm.addEventListener('click', confirmRevisionReview);
|
|
6926
|
-
$revReviewCancel.addEventListener('click',
|
|
6927
|
-
|
|
8456
|
+
$revReviewCancel.addEventListener('click', () => {
|
|
8457
|
+
if (!$revReview.hasAttribute('aria-busy')) closeRevReview();
|
|
8458
|
+
});
|
|
8459
|
+
onBackdropDismiss($revReview, closeRevReview, () => !$revReview.hasAttribute('aria-busy'));
|
|
6928
8460
|
$revReview.addEventListener('keydown', (e) => {
|
|
6929
|
-
if (e.key === '
|
|
8461
|
+
if (e.key === 'Tab' && revReviewState?.terminal) {
|
|
8462
|
+
e.preventDefault();
|
|
8463
|
+
$revReviewCancel.focus();
|
|
8464
|
+
return;
|
|
8465
|
+
}
|
|
8466
|
+
if (e.key === 'Escape') { e.preventDefault(); if (!$revReview.hasAttribute('aria-busy')) closeRevReview(); }
|
|
6930
8467
|
});
|
|
8468
|
+
// A successful confirm refreshes the project/request state behind this still-open result dialog.
|
|
8469
|
+
// Chromium can move focus onto the refreshed workspace iframe after the synchronous Close.focus()
|
|
8470
|
+
// in the confirm finally block. The load boundary covers either event order, while the window-blur
|
|
8471
|
+
// boundary above catches an editor that claims focus later during its own async boot. Restore focus
|
|
8472
|
+
// only when that iframe owns it; a higher-priority overlay keeps its focus.
|
|
8473
|
+
function restoreTerminalRevisionReviewFocusFromModel(stageId) {
|
|
8474
|
+
if (stageId && $revReview.classList.contains('show') && revReviewState?.terminal
|
|
8475
|
+
&& revReviewState.stageId === stageId && document.activeElement === frames.model) {
|
|
8476
|
+
$revReviewCancel.focus();
|
|
8477
|
+
}
|
|
8478
|
+
}
|
|
8479
|
+
function retainTerminalRevisionReviewFocus() {
|
|
8480
|
+
const stageId = revReviewState?.stageId;
|
|
8481
|
+
if (!stageId) return;
|
|
8482
|
+
requestAnimationFrame(() => {
|
|
8483
|
+
requestAnimationFrame(() => {
|
|
8484
|
+
restoreTerminalRevisionReviewFocusFromModel(stageId);
|
|
8485
|
+
});
|
|
8486
|
+
});
|
|
8487
|
+
}
|
|
6931
8488
|
$revDiscardCancel.addEventListener('click', () => closeRevisionDiscard());
|
|
6932
8489
|
$revDiscardConfirm.addEventListener('click', confirmRevisionDiscard);
|
|
6933
8490
|
onBackdropDismiss($revDiscard, () => closeRevisionDiscard(), () => !$revDiscardDialog.hasAttribute('aria-busy'));
|
|
@@ -7201,7 +8758,7 @@
|
|
|
7201
8758
|
if (!current) return;
|
|
7202
8759
|
const id = current.id;
|
|
7203
8760
|
closeBaseMenu(); // this re-render replaces the History HTML — drop any open base-picker's listener first
|
|
7204
|
-
$wsHistory.innerHTML = '<div class="hist-note">Loading history…</div>';
|
|
8761
|
+
$wsHistory.innerHTML = HIST_HEAD + '<div class="hist-note">Loading history…</div>';
|
|
7205
8762
|
await awaitApprovalVerdict();
|
|
7206
8763
|
if (!current || current.id !== id || $wsHistory.hidden) return; // switched away while it settled
|
|
7207
8764
|
let rows = [];
|
|
@@ -7238,9 +8795,25 @@
|
|
|
7238
8795
|
approvedAt = r.approvedAt || undefined;
|
|
7239
8796
|
} catch (err) {
|
|
7240
8797
|
await checkpointPromise; // already settled to a tagged value — drained so it cannot outlive this render
|
|
8798
|
+
// "Try again" is right for a transient failure and WRONG when the server has REFUSED and said
|
|
8799
|
+
// why: /versions answers 409 "approved version N has no approval proof" for a project whose
|
|
8800
|
+
// approve rows predate the proof format, and it will answer that identically on every retry —
|
|
8801
|
+
// so the old line invited an action that cannot succeed and threw away the one sentence that
|
|
8802
|
+
// explains the pane. Exports already draws this distinction for the same refusal (see
|
|
8803
|
+
// exportSourceHtml) and prefers the server's own words; History now does too.
|
|
8804
|
+
//
|
|
8805
|
+
// The test is `err.body.error`, NOT approvalRefusalNote(): that helper reads approvalState,
|
|
8806
|
+
// which is '' for this project — the refusal reaches Exports through its own route's
|
|
8807
|
+
// `defaultUnavailable`, and reaches here through this throw. A bare network failure has no
|
|
8808
|
+
// body, so it still gets the retry line it deserves.
|
|
8809
|
+
const served = err && err.body && typeof err.body.error === 'string' ? err.body.error.trim() : '';
|
|
7241
8810
|
showToast('Couldn’t load history: ' + ((err && err.message) || err), 'warn');
|
|
7242
8811
|
if (current && current.id === id && !$wsHistory.hidden) {
|
|
7243
|
-
|
|
8812
|
+
// The header comes too. A step that keeps its band while loading and while listing but drops
|
|
8813
|
+
// it the moment it refuses looks like a different pane rather than the same one with bad news.
|
|
8814
|
+
$wsHistory.innerHTML = HIST_HEAD + (served
|
|
8815
|
+
? `<div class="hist-empty">${escapeHtml(served)}</div>`
|
|
8816
|
+
: '<div class="hist-empty">History unavailable — try again.</div>');
|
|
7244
8817
|
}
|
|
7245
8818
|
return;
|
|
7246
8819
|
}
|
|
@@ -7319,6 +8892,7 @@
|
|
|
7319
8892
|
`Use Review & approve in the project header. Exports keep using ${approvalState.headVersion ? `approved v${approvalState.headVersion}` : 'an explicitly selected DRAFT'}.</div>`)
|
|
7320
8893
|
: '';
|
|
7321
8894
|
$wsHistory.innerHTML =
|
|
8895
|
+
HIST_HEAD +
|
|
7322
8896
|
'<div class="hist-note"><b>Approved versions</b> are immutable. Starting from an older version creates a new working revision; it never rewrites history.</div>' +
|
|
7323
8897
|
working +
|
|
7324
8898
|
// Version/Gate/action are fixed-narrow; When/By auto-size to their nowrap content (fixing them
|
|
@@ -7452,6 +9026,7 @@
|
|
|
7452
9026
|
{ key: 'resized', label: 'Resized' },
|
|
7453
9027
|
{ key: 'moved', label: 'Moved' },
|
|
7454
9028
|
{ key: 'material', label: 'Material' },
|
|
9029
|
+
{ key: 'changed', label: 'Source questions' },
|
|
7455
9030
|
{ key: 'connections', label: 'Connections' },
|
|
7456
9031
|
];
|
|
7457
9032
|
const diffBase = new Map(); // "<projectId>\0<n>" → chosen baseline (undefined = compare to the previous version)
|
|
@@ -7483,6 +9058,7 @@
|
|
|
7483
9058
|
line.appendChild(el('span', 'hd-mark', ref.mark || ref.id));
|
|
7484
9059
|
if (ref.profile) line.appendChild(el('span', 'hd-prof', ref.profile));
|
|
7485
9060
|
if (ref.sheet) line.appendChild(el('span', 'hd-sheet', ref.sheet));
|
|
9061
|
+
if (ref.provisional) line.appendChild(el('span', 'hd-qual', 'source-only question'));
|
|
7486
9062
|
return line;
|
|
7487
9063
|
}
|
|
7488
9064
|
function diffMemberXform(ref, fromTxt, toTxt) {
|
|
@@ -7496,10 +9072,16 @@
|
|
|
7496
9072
|
if (ref.sheet) line.appendChild(el('span', 'hd-sheet', ref.sheet));
|
|
7497
9073
|
return line;
|
|
7498
9074
|
}
|
|
9075
|
+
// The distance comes RENDERED (`ContractDiff.moved[].text`) rather than converted here. This file is
|
|
9076
|
+
// a classic script with no imports, so converting millimetres to feet would mean writing its own
|
|
9077
|
+
// copy of 304.8 — and #951 consolidated 24 such copies across 18 files precisely because a file that
|
|
9078
|
+
// owns its own version of a shared number is a file that can be edited alone. `steel-diff.ts`
|
|
9079
|
+
// renders it once, on the side that can import the constant, for this row and for the change
|
|
9080
|
+
// sentence both.
|
|
7499
9081
|
function diffMemberMoved(it) {
|
|
7500
9082
|
const line = el('div', 'hd-item');
|
|
7501
9083
|
line.appendChild(el('span', 'hd-mark', it.ref.mark || it.ref.id));
|
|
7502
|
-
line.appendChild(el('span', 'hd-prof', `moved ~${it.
|
|
9084
|
+
line.appendChild(el('span', 'hd-prof', `moved ~${it.text}`));
|
|
7503
9085
|
if (it.scaleUnknown) line.appendChild(el('span', 'hd-qual', 'scale unknown'));
|
|
7504
9086
|
if (it.ref.sheet) line.appendChild(el('span', 'hd-sheet', it.ref.sheet));
|
|
7505
9087
|
return line;
|
|
@@ -7511,10 +9093,19 @@
|
|
|
7511
9093
|
if (it.ref.sheet) line.appendChild(el('span', 'hd-sheet', it.ref.sheet));
|
|
7512
9094
|
return line;
|
|
7513
9095
|
}
|
|
9096
|
+
function diffProvisionalChanged(it) {
|
|
9097
|
+
const line = el('div', 'hd-item');
|
|
9098
|
+
line.appendChild(el('span', 'hd-mark', it.ref.mark ? `${it.ref.mark} (${it.ref.id})` : it.ref.id));
|
|
9099
|
+
if (it.ref.profile) line.appendChild(el('span', 'hd-prof', it.ref.profile));
|
|
9100
|
+
if (it.ref.sheet) line.appendChild(el('span', 'hd-sheet', it.ref.sheet));
|
|
9101
|
+
line.appendChild(el('span', 'hd-qual', it.summary || 'source-only details changed'));
|
|
9102
|
+
return line;
|
|
9103
|
+
}
|
|
7514
9104
|
function diffRowFor(key, it) {
|
|
7515
9105
|
if (key === 'added' || key === 'removed') return diffMemberBasic(it);
|
|
7516
9106
|
if (key === 'resized' || key === 'material') return diffMemberXform(it.ref, it.from, it.to);
|
|
7517
9107
|
if (key === 'moved') return diffMemberMoved(it);
|
|
9108
|
+
if (key === 'changed') return diffProvisionalChanged(it);
|
|
7518
9109
|
return diffMemberConn(it);
|
|
7519
9110
|
}
|
|
7520
9111
|
function diffGroup(g, items) {
|
|
@@ -7528,13 +9119,21 @@
|
|
|
7528
9119
|
for (const it of items) box.appendChild(diffRowFor(g.key, it));
|
|
7529
9120
|
return box;
|
|
7530
9121
|
}
|
|
9122
|
+
// The two headline words, per unit system. `t` for tonnes is the SI symbol — `T` is the tesla — and
|
|
9123
|
+
// the server spells them the same way (`server/bom-units.ts`), so the pane and the sentence beneath
|
|
9124
|
+
// it cannot disagree about what a number is.
|
|
9125
|
+
const DIFF_TONNAGE_WORD = { 'ft-in': 'tons', mm: 't' };
|
|
7531
9126
|
function diffNetHeader(t) {
|
|
7532
9127
|
const wrap = el('div', 'hd-net');
|
|
7533
|
-
const net = t && typeof t.
|
|
9128
|
+
const net = t && typeof t.netTonnage === 'number' ? t.netTonnage : 0;
|
|
9129
|
+
// The units come off the comparison, never from a page-level preference: a panel showing an older
|
|
9130
|
+
// comparison must keep saying what THAT comparison measured. `wellFormedDiff` has already refused
|
|
9131
|
+
// anything whose `units` is not one of the two, so the fallback is unreachable rather than a guess.
|
|
9132
|
+
const word = DIFF_TONNAGE_WORD[t && t.units] || DIFF_TONNAGE_WORD['ft-in'];
|
|
7534
9133
|
if (net === 0) wrap.classList.add('flat');
|
|
7535
9134
|
wrap.appendChild(el('span', 'hd-net-label', 'Net steel:'));
|
|
7536
9135
|
wrap.appendChild(el('span', 'hd-net-arrow', net > 0 ? '▲' : net < 0 ? '▼' : '•'));
|
|
7537
|
-
wrap.appendChild(el('span', 'hd-net-val', `${net > 0 ? '+' : ''}${net}
|
|
9136
|
+
wrap.appendChild(el('span', 'hd-net-val', `${net > 0 ? '+' : ''}${net} ${word}`));
|
|
7538
9137
|
return wrap;
|
|
7539
9138
|
}
|
|
7540
9139
|
// The engine's four honest signals — each names its CONSEQUENCE so a withheld member/connection is
|
|
@@ -7599,37 +9198,97 @@
|
|
|
7599
9198
|
if (!diff || typeof diff !== 'object' || Array.isArray(diff)
|
|
7600
9199
|
|| !Number.isInteger(diff.from) || diff.from < 0 || !Number.isInteger(diff.to) || diff.to < 1
|
|
7601
9200
|
|| diff.from >= diff.to
|
|
7602
|
-
|| !diff.tonnage || typeof diff.tonnage !== 'object' || !Number.isFinite(diff.tonnage.
|
|
9201
|
+
|| !diff.tonnage || typeof diff.tonnage !== 'object' || !Number.isFinite(diff.tonnage.netTonnage)
|
|
9202
|
+
|| (diff.tonnage.units !== 'ft-in' && diff.tonnage.units !== 'mm')
|
|
7603
9203
|
|| !Number.isInteger(diff.unchanged) || diff.unchanged < 0
|
|
7604
9204
|
|| !diff.warnings || typeof diff.warnings !== 'object') return false;
|
|
7605
9205
|
const optionalString = (obj, key) => !Object.prototype.hasOwnProperty.call(obj, key)
|
|
7606
9206
|
|| typeof obj[key] === 'string';
|
|
7607
9207
|
const ref = (value) => !!value && typeof value === 'object' && !Array.isArray(value)
|
|
7608
9208
|
&& typeof value.id === 'string' && !!value.id
|
|
7609
|
-
&& ['key', 'sheet', 'mark', 'profile', 'role'].every((key) => optionalString(value, key))
|
|
9209
|
+
&& ['key', 'sheet', 'mark', 'profile', 'role'].every((key) => optionalString(value, key))
|
|
9210
|
+
&& (!Object.prototype.hasOwnProperty.call(value, 'provisional') || value.provisional === true);
|
|
7610
9211
|
const xform = (value) => !!value && typeof value === 'object' && !Array.isArray(value)
|
|
7611
9212
|
&& ref(value.ref) && typeof value.from === 'string' && typeof value.to === 'string';
|
|
7612
9213
|
const moved = (value) => !!value && typeof value === 'object' && !Array.isArray(value)
|
|
7613
|
-
&& ref(value.ref) && Number.isFinite(value.
|
|
9214
|
+
&& ref(value.ref) && Number.isFinite(value.mm) && typeof value.text === 'string' && !!value.text
|
|
7614
9215
|
&& (!Object.prototype.hasOwnProperty.call(value, 'scaleUnknown') || typeof value.scaleUnknown === 'boolean');
|
|
7615
9216
|
const connection = (value) => !!value && typeof value === 'object' && !Array.isArray(value)
|
|
7616
9217
|
&& ref(value.ref) && typeof value.summary === 'string';
|
|
7617
|
-
const validators = { added: ref, removed: ref, resized: xform, moved, material: xform, connections: connection };
|
|
9218
|
+
const validators = { added: ref, removed: ref, resized: xform, moved, material: xform, changed: connection, connections: connection };
|
|
7618
9219
|
if (!DIFF_GROUPS.every((group) =>
|
|
7619
9220
|
Array.isArray(diff[group.key]) && diff[group.key].every(validators[group.key]))) return false;
|
|
7620
9221
|
return ['duplicateKeys', 'ambiguousJoints', 'mergedAmbiguous'].every((key) =>
|
|
7621
9222
|
!Object.prototype.hasOwnProperty.call(diff.warnings, key)
|
|
7622
9223
|
|| (Array.isArray(diff.warnings[key]) && diff.warnings[key].every((value) => typeof value === 'string')));
|
|
7623
9224
|
}
|
|
9225
|
+
/*
|
|
9226
|
+
* IS THIS AN OLD SERVER SAYING "I COULD NOT READ THIS MODEL", or is it garbage?
|
|
9227
|
+
*
|
|
9228
|
+
* The compatibility branch discards the diff and reports `unavailable`, so nothing malformed can
|
|
9229
|
+
* reach the renderer either way — but the two are different ANSWERS and the user is told which one
|
|
9230
|
+
* happened. Recognising `{ warnings: { invalidModelV2: 'anything' } }` on its own would report a
|
|
9231
|
+
* garbage response as "the server could not read the model", which is a confident sentence about
|
|
9232
|
+
* the wrong failure. The first version of the reordering did exactly that: any truthy warning
|
|
9233
|
+
* bypassed every structural check. (Review round 2, second reviewer.)
|
|
9234
|
+
*
|
|
9235
|
+
* So this asks for the OLD contract — the shape a real old server sent — minus the two fields
|
|
9236
|
+
* slice 4 added, which are the only reason that server's response stopped validating. Nothing
|
|
9237
|
+
* looser, or the branch stops discriminating; nothing tighter, or it stops recognising the thing
|
|
9238
|
+
* it exists for.
|
|
9239
|
+
*/
|
|
9240
|
+
function legacyUnreadableDiff(diff) {
|
|
9241
|
+
if (!diff || typeof diff !== 'object' || Array.isArray(diff)) return false;
|
|
9242
|
+
// The three values the old server could send, from its own `unavailableDiff(from, to, side)` —
|
|
9243
|
+
// not "any string". `invalidModelV2: 'garbage'` is not something that server ever produced.
|
|
9244
|
+
const warnings = diff.warnings;
|
|
9245
|
+
if (!warnings || typeof warnings !== 'object') return false;
|
|
9246
|
+
if (warnings.invalidModelV2 !== 'from' && warnings.invalidModelV2 !== 'to' && warnings.invalidModelV2 !== 'both') return false;
|
|
9247
|
+
// Versions are non-negative integers and a comparison runs forwards. `from === 0` is the
|
|
9248
|
+
// first-version case that server spelled explicitly.
|
|
9249
|
+
if (!Number.isInteger(diff.from) || !Number.isInteger(diff.to)) return false;
|
|
9250
|
+
if (diff.from < 0 || diff.to <= diff.from) return false;
|
|
9251
|
+
// The OLD tonnage block, by its own field names — the strongest thing here, because those names
|
|
9252
|
+
// are exactly what slice 4 renamed. A payload carrying them is a payload from before the rename.
|
|
9253
|
+
const t = diff.tonnage;
|
|
9254
|
+
if (!t || typeof t !== 'object' || Array.isArray(t)) return false;
|
|
9255
|
+
for (const key of ['fromLb', 'toLb', 'netLb', 'fromTons', 'toTons', 'netTons']) {
|
|
9256
|
+
if (typeof t[key] !== 'number') return false;
|
|
9257
|
+
}
|
|
9258
|
+
if (typeof diff.unchanged !== 'number') return false;
|
|
9259
|
+
// An unreadable comparison was SUPPRESSED — the server said so rather than reporting no changes,
|
|
9260
|
+
// and its own comment explains why: "never 'no model changes detected' — that is a confident
|
|
9261
|
+
// claim of no change about a file that could not be read".
|
|
9262
|
+
if (diff.comparison !== 'suppressed') return false;
|
|
9263
|
+
// The group names are spelled here rather than read from `DIFF_GROUPS` on purpose: that table is
|
|
9264
|
+
// TODAY's, and this predicate describes a wire shape frozen in the past. Adding a seventh group
|
|
9265
|
+
// to the app must not silently narrow what an old server is allowed to have sent. An unreadable
|
|
9266
|
+
// comparison found nothing, so the arrays are not merely arrays — they are empty.
|
|
9267
|
+
return ['added', 'removed', 'resized', 'moved', 'material', 'connections']
|
|
9268
|
+
.every((key) => Array.isArray(diff[key]) && diff[key].length === 0);
|
|
9269
|
+
}
|
|
9270
|
+
|
|
7624
9271
|
function decodeDiffResponse(response) {
|
|
7625
9272
|
if (!response || typeof response !== 'object') throw new Error('invalid comparison response');
|
|
7626
9273
|
const hasStatus = hasOwnField(response, 'status');
|
|
7627
9274
|
if (hasStatus && response.status === 'unavailable') return { kind: 'unavailable' };
|
|
7628
9275
|
if (hasStatus && response.status !== 'available') throw new Error('invalid comparison response status');
|
|
9276
|
+
// OLD SERVER COMPATIBILITY, AND IT HAS TO COME FIRST. Its unreadable-v2 response was HTTP 200
|
|
9277
|
+
// with an inert diff, so the warning — not the zero buckets — is the only honest discriminator.
|
|
9278
|
+
//
|
|
9279
|
+
// This check used to sit BELOW the validation, which worked only while an old server's diff
|
|
9280
|
+
// still validated. Slice 4 made `wellFormedDiff` require `tonnage.units` and a `moved[].text`
|
|
9281
|
+
// that no old server sends, so the branch became unreachable: the one response it exists to
|
|
9282
|
+
// recognise now died one line above it as "invalid comparison response". Asking about the
|
|
9283
|
+
// warning before validating the shape restores it, and is the right order anyway — a server
|
|
9284
|
+
// saying "I could not read this model" is answering, not malforming.
|
|
9285
|
+
//
|
|
9286
|
+
// A HEALTHY old server is still refused below, deliberately: its diff has no `tonnage.units` and
|
|
9287
|
+
// no `moved[].text`, and waving it through would put `moved ~undefined` in front of a user as a
|
|
9288
|
+
// statement about real geometry. A refusal they can act on beats a sentence they cannot. Client
|
|
9289
|
+
// and server ship together, so that window is a half-finished upgrade, not a supported state.
|
|
9290
|
+
if (!hasStatus && legacyUnreadableDiff(response.diff)) return { kind: 'unavailable' };
|
|
7629
9291
|
if (!wellFormedDiff(response.diff)) throw new Error('invalid comparison response');
|
|
7630
|
-
// Old server compatibility. Its unreadable-v2 response was HTTP 200 with an inert diff, so the
|
|
7631
|
-
// warning—not the zero buckets—is the only honest discriminator.
|
|
7632
|
-
if (!hasStatus && response.diff.warnings.invalidModelV2) return { kind: 'unavailable' };
|
|
7633
9292
|
return { kind: 'available', diff: response.diff };
|
|
7634
9293
|
}
|
|
7635
9294
|
function restoreDiffFocus(panel, n) {
|
|
@@ -7870,7 +9529,8 @@
|
|
|
7870
9529
|
const hasThumb = !!(menuProj && menuProj.thumbnailTag);
|
|
7871
9530
|
const thumbItems = menuItem('thumbnail', hasThumb ? 'Replace thumbnail…' : 'Add thumbnail…')
|
|
7872
9531
|
+ (hasThumb ? menuItem('remove-thumbnail', 'Remove thumbnail') : '');
|
|
7873
|
-
|
|
9532
|
+
const duplicateItem = `<button class="menu-item" data-act="duplicate" data-command-id="shell.project-duplicate#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(menuProj && menuProj.name)}" role="menuitem"><span class="menu-label">Duplicate</span></button>`;
|
|
9533
|
+
$projMenu.innerHTML = menuItem('rename', 'Rename…') + thumbItems + duplicateItem +
|
|
7874
9534
|
menuItem('export', 'Export…') +
|
|
7875
9535
|
'<div class="menu-divider"></div>' + menuItem('archive', 'Archive');
|
|
7876
9536
|
// NO "Convert to the 3D model…" ITEM HERE, and its absence is a decision rather than an oversight.
|
|
@@ -8046,6 +9706,12 @@
|
|
|
8046
9706
|
if (projActionBusy) { showToast('Hold on — finishing the last action…', 'warn'); return; }
|
|
8047
9707
|
projActionBusy = true;
|
|
8048
9708
|
const proj = projects.find((p) => p.id === id);
|
|
9709
|
+
let dismissProgress = null;
|
|
9710
|
+
const finishProgress = () => {
|
|
9711
|
+
if (!dismissProgress) return;
|
|
9712
|
+
dismissProgress({ immediate: true });
|
|
9713
|
+
dismissProgress = null;
|
|
9714
|
+
};
|
|
8049
9715
|
try {
|
|
8050
9716
|
if (action === 'rename') {
|
|
8051
9717
|
const name = await promptName('Rename project', 'New name', proj ? proj.name : '');
|
|
@@ -8062,11 +9728,14 @@
|
|
|
8062
9728
|
if (wasCurrent) await openProject(project.id);
|
|
8063
9729
|
showToast(`Renamed to "${project.name}"`, 'ok');
|
|
8064
9730
|
} else if (action === 'duplicate') {
|
|
8065
|
-
|
|
9731
|
+
dismissProgress = showToast(`Duplicating “${proj ? proj.name : 'project'}”…`, 'progress');
|
|
9732
|
+
const { project, rfiTransfer } = await api(`/api/projects/${encodeURIComponent(id)}/duplicate`, { method: 'POST', body: '{}' });
|
|
8066
9733
|
projects.unshift(project); // newest → front, matching the server's newest-first list order
|
|
8067
9734
|
renderLanding();
|
|
8068
9735
|
flashCard(project.id, { scroll: true });
|
|
8069
|
-
|
|
9736
|
+
const resultToast = formatRfiTransferToast(rfiTransfer, 'duplicate', project.name, true);
|
|
9737
|
+
finishProgress();
|
|
9738
|
+
showToast(resultToast.message, resultToast.tone);
|
|
8070
9739
|
} else if (action === 'remove-thumbnail') {
|
|
8071
9740
|
// No confirm, deliberately. A thumbnail is decorative metadata with nothing downstream of it
|
|
8072
9741
|
// and is one menu item away from being re-added — unlike the archived-project Delete, which
|
|
@@ -8082,8 +9751,13 @@
|
|
|
8082
9751
|
showToast('Archived — recoverable from ~/.floless/projects/.archive', 'ok');
|
|
8083
9752
|
if (current && current.id === id) { closeProject(); return; }
|
|
8084
9753
|
}
|
|
8085
|
-
} catch (err) {
|
|
8086
|
-
|
|
9754
|
+
} catch (err) {
|
|
9755
|
+
finishProgress();
|
|
9756
|
+
showToast(action === 'duplicate'
|
|
9757
|
+
? 'Duplicate failed: ' + (err && err.message || err)
|
|
9758
|
+
: 'Action failed: ' + (err && err.message || err), 'warn');
|
|
9759
|
+
}
|
|
9760
|
+
finally { finishProgress(); projActionBusy = false; }
|
|
8087
9761
|
loadProjects();
|
|
8088
9762
|
}
|
|
8089
9763
|
|
|
@@ -8223,25 +9897,29 @@
|
|
|
8223
9897
|
try { file = await pickZipFile($importZip); }
|
|
8224
9898
|
catch { showToast('Couldn’t open the file picker', 'warn'); return; }
|
|
8225
9899
|
if (!file) return; // cancelled
|
|
8226
|
-
showToast(`Importing “${file.name}”…`, '
|
|
9900
|
+
let dismissProgress = showToast(`Importing “${file.name}”…`, 'progress');
|
|
9901
|
+
const finishProgress = () => {
|
|
9902
|
+
if (!dismissProgress) return;
|
|
9903
|
+
dismissProgress({ immediate: true });
|
|
9904
|
+
dismissProgress = null;
|
|
9905
|
+
};
|
|
8227
9906
|
try {
|
|
8228
9907
|
const buf = await file.arrayBuffer();
|
|
8229
|
-
const { project, appInstalled } = await api('/api/projects/import', {
|
|
9908
|
+
const { project, appInstalled, rfiTransfer } = await api('/api/projects/import', {
|
|
8230
9909
|
method: 'POST', headers: { 'content-type': 'application/zip' }, body: buf,
|
|
8231
9910
|
});
|
|
8232
9911
|
projects.unshift(project); // newest → front, matching duplicate/create
|
|
8233
9912
|
renderLanding();
|
|
8234
9913
|
flashCard(project.id, { scroll: true });
|
|
8235
9914
|
track('workspace_project_imported', { app: project.app });
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
showToast(`Imported ✓ — “${project.name}” added`, 'ok');
|
|
8240
|
-
}
|
|
9915
|
+
const resultToast = formatRfiTransferToast(rfiTransfer, 'import', project.name, appInstalled);
|
|
9916
|
+
finishProgress();
|
|
9917
|
+
showToast(resultToast.message, resultToast.tone);
|
|
8241
9918
|
loadProjects(); // background reconcile against the server truth (mirrors duplicate/rename/archive)
|
|
8242
9919
|
} catch (err) {
|
|
9920
|
+
finishProgress();
|
|
8243
9921
|
showToast('Import failed: ' + (err && err.message || err), 'warn');
|
|
8244
|
-
}
|
|
9922
|
+
} finally { finishProgress(); }
|
|
8245
9923
|
}
|
|
8246
9924
|
|
|
8247
9925
|
// Restore an archived project to the live grid (the inverse of Archive). Fully reversible — Archive
|
|
@@ -8407,18 +10085,21 @@
|
|
|
8407
10085
|
* wrong place. The `current` re-check afterwards is the ordinary stale-navigation guard — the user
|
|
8408
10086
|
* can pick a different project while the open is in flight.
|
|
8409
10087
|
*/
|
|
8410
|
-
async function openKnowledgePage(projectId, slug) {
|
|
10088
|
+
async function openKnowledgePage(projectId, slug, generationId) {
|
|
8411
10089
|
if (!projectId || !slug) return;
|
|
8412
10090
|
await setMode('workspaces');
|
|
8413
10091
|
await openProject(projectId, 'knowledge');
|
|
8414
10092
|
if (!current || current.id !== projectId) return; // navigated away mid-open
|
|
8415
|
-
|
|
10093
|
+
// A citation carries the generation the workflow READ; the viewer must show that page, not the
|
|
10094
|
+
// current one, or a drifted knowledge base quietly shows the user text the workflow never saw.
|
|
10095
|
+
setViewer({ mode: 'page', slug, sourceId: null, generationId: generationId || null });
|
|
8416
10096
|
renderKnowledge();
|
|
8417
10097
|
}
|
|
8418
10098
|
|
|
8419
10099
|
window.flolessWorkspaces = {
|
|
8420
10100
|
setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind,
|
|
8421
10101
|
openHistory: wsOpenHistory, openKnowledgePage, drawingFilterCheckpointSaved,
|
|
10102
|
+
syncWorkspaceReporter,
|
|
8422
10103
|
};
|
|
8423
10104
|
applyMode(); // restore persisted mode immediately (matches panels.js applyView timing)
|
|
8424
10105
|
})();
|