@floless/app 0.169.0 → 0.171.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/floless-server.cjs +65531 -43728
  2. package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
  3. package/dist/schemas/steel.model.v2.schema.json +196 -4
  4. package/dist/skills/floless-app-bridge/SKILL.md +3 -3
  5. package/dist/skills/floless-app-knowledge/SKILL.md +46 -15
  6. package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
  7. package/dist/skills/floless-app-onboarding/SKILL.md +5 -4
  8. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +0 -3
  9. package/dist/skills/floless-app-queue/SKILL.md +2 -3
  10. package/dist/skills/floless-app-report-issue/SKILL.md +2 -2
  11. package/dist/skills/floless-app-routines/SKILL.md +2 -2
  12. package/dist/skills/floless-app-routines/references/routines-api.md +20 -8
  13. package/dist/skills/floless-app-steel-model/SKILL.md +42 -39
  14. package/dist/skills/floless-app-steel-model/references/custom-connections.md +47 -0
  15. package/dist/skills/floless-app-steel-model/references/custom-sections.md +32 -0
  16. package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
  17. package/dist/skills/floless-app-ui/SKILL.md +71 -126
  18. package/dist/skills/floless-app-workflows/SKILL.md +22 -3
  19. package/dist/skills/floless-app-workflows/references/agent-steps.md +40 -6
  20. package/dist/skills/floless-app-workflows/references/exec-contract.md +27 -0
  21. package/dist/skills/floless-app-workflows/references/script-runner.md +105 -0
  22. package/dist/web/add-ons.js +407 -0
  23. package/dist/web/agent-steps.js +89 -18
  24. package/dist/web/agents.js +32 -22
  25. package/dist/web/analytics.js +1 -1
  26. package/dist/web/app.css +331 -190
  27. package/dist/web/app.js +33 -13
  28. package/dist/web/aware.js +926 -218
  29. package/dist/web/chat.css +6 -1
  30. package/dist/web/chat.js +316 -112
  31. package/dist/web/checkpoint-standard.js +5 -3
  32. package/dist/web/commands-drawing-check.js +1 -0
  33. package/dist/web/commands-filter.js +23 -0
  34. package/dist/web/commands-shell.js +479 -78
  35. package/dist/web/commands-steel.js +69 -2
  36. package/dist/web/commands-tekla-parser.js +23 -0
  37. package/dist/web/connections.js +14 -3
  38. package/dist/web/drawing-check-editor.js +352 -88
  39. package/dist/web/failure-copy.js +33 -2
  40. package/dist/web/filter-ai-proposal.js +11 -8
  41. package/dist/web/flo-3d.js +1 -1
  42. package/dist/web/guide.js +36 -29
  43. package/dist/web/index.html +98 -57
  44. package/dist/web/instructor.js +101 -17
  45. package/dist/web/kb-categories.js +64 -7
  46. package/dist/web/left-pane.js +4 -1
  47. package/dist/web/local-discovery.js +8 -7
  48. package/dist/web/missed-routines.js +239 -0
  49. package/dist/web/model-change-findings.js +430 -0
  50. package/dist/web/model-change-review.js +414 -0
  51. package/dist/web/model-editor-steel-adapter.js +2 -2
  52. package/dist/web/model-measure.js +6 -0
  53. package/dist/web/model-spatial-panel.js +19 -4
  54. package/dist/web/model-spatial-tools.js +3 -3
  55. package/dist/web/model-viewport-revit-adapter.js +3 -3
  56. package/dist/web/origin-rule.js +155 -0
  57. package/dist/web/project-access.js +1 -1
  58. package/dist/web/project-history.js +7 -1
  59. package/dist/web/project-modules.js +2 -2
  60. package/dist/web/project-rfis.js +6 -1
  61. package/dist/web/project-workflows.js +2 -2
  62. package/dist/web/revit-editor.css +85 -0
  63. package/dist/web/revit-editor.js +58 -9
  64. package/dist/web/run-history.js +12 -1
  65. package/dist/web/sha256-sync.js +62 -0
  66. package/dist/web/steel-3d-core.js +46 -9
  67. package/dist/web/steel-3d-flo.js +153 -7
  68. package/dist/web/steel-3d-view.js +33 -5
  69. package/dist/web/steel-ai-marks.js +3 -1
  70. package/dist/web/steel-custom-connection.js +161 -0
  71. package/dist/web/steel-custom-sections.js +1796 -0
  72. package/dist/web/steel-editor.html +732 -161
  73. package/dist/web/steel-environments.js +297 -0
  74. package/dist/web/steel-filter-usage.js +299 -0
  75. package/dist/web/steel-filter.html +104 -6
  76. package/dist/web/steel-model-v2-client-validation.js +11 -1
  77. package/dist/web/steel-model-v2-commands.js +116 -13
  78. package/dist/web/steel-model-v2-projection.js +1 -1
  79. package/dist/web/steel-read-confidence.js +1 -56
  80. package/dist/web/step-rename.js +3 -2
  81. package/dist/web/tekla-editor.html +1 -0
  82. package/dist/web/terminal-requests.js +1 -1
  83. package/dist/web/tool-updates.js +7 -6
  84. package/dist/web/workspaces.js +1968 -138
  85. package/launch.mjs +87 -9
  86. package/package.json +4 -1
  87. package/dist/web/panels.js +0 -831
@@ -0,0 +1,414 @@
1
+ /**
2
+ * Change review S1 (#3352): the Tekla model page's "Changes" tab. Compare two saved states of the model and read what
3
+ * changed, honestly labelled (plan §3). Presentation only: the comparison runs on the server (in AWARE), and this never
4
+ * changes the model or a review. "Show in 3D" asks the page to open the row's saved state and select the object.
5
+ *
6
+ * Copy follows the UX review: plain English for detailers ("saved state", "matched"), never GUID, identity or parser.
7
+ */
8
+
9
+ import { createFindings } from './model-change-findings.js';
10
+
11
+ const STATE_LABEL = {
12
+ 'no-inconsistency-detected': 'No inconsistency detected',
13
+ 'consistency-unknown': 'Consistency unknown',
14
+ 'not-recorded': 'Consistency not recorded',
15
+ };
16
+ const KIND_LABEL = { 'shape-fields': 'Shape fields', placement: 'Placement', properties: 'Properties', relationships: 'Relationships' };
17
+ const STATUS_HEADING = { removed: 'Removed', added: 'Added', changed: 'Changed' };
18
+
19
+ function el(doc, tag, attrs = {}, ...children) {
20
+ const node = doc.createElement(tag);
21
+ for (const [key, value] of Object.entries(attrs)) {
22
+ if (value === undefined || value === null || value === false) continue;
23
+ if (key === 'class') node.className = value;
24
+ else if (key === 'text') node.textContent = value;
25
+ else if (key.startsWith('on')) node.addEventListener(key.slice(2), value);
26
+ else node.setAttribute(key, value === true ? '' : String(value));
27
+ }
28
+ for (const child of children.flat()) if (child) node.append(child);
29
+ return node;
30
+ }
31
+
32
+ const when = (iso) => {
33
+ if (!iso) return 'save time not known';
34
+ try { return new Date(iso).toLocaleString(undefined, { day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit' }); }
35
+ catch { return iso; }
36
+ };
37
+ const plural = (n, one, many = `${one}s`) => `${Number(n).toLocaleString()} ${n === 1 ? one : many}`;
38
+ const shown = (value) => {
39
+ if (value === null || value === undefined) return '—';
40
+ if (Array.isArray(value)) return value.map((item) => (typeof item === 'number' ? Math.round(item * 10) / 10 : item)).join(', ');
41
+ return typeof value === 'object' ? JSON.stringify(value) : String(value);
42
+ };
43
+ const fieldName = (key) => {
44
+ if (key === 'geometry.bounds') return 'Bounding box (mm)';
45
+ if (key === 'entity.name') return 'Object name';
46
+ if (key === 'entity.type') return 'Object type';
47
+ if (key.startsWith('relationship:')) return 'Connected to';
48
+ const uda = /^uda:(?:text|number):name:(.+)$/.exec(key);
49
+ if (uda) return `UDA ${uda[1]}`;
50
+ // Any other key (native or not) reads as its last part in words, never as the raw comparison key.
51
+ const last = key.split(/[:.]/).filter(Boolean).pop() || key;
52
+ return last.replace(/[-_]+/g, ' ').trim().replace(/^./, (c) => c.toUpperCase());
53
+ };
54
+
55
+ /**
56
+ * A themed single-choice picker (no native <select>): a button that opens a listbox of saved states.
57
+ */
58
+ function statePicker(doc, { id, label, states, value, onChange }) {
59
+ const wrap = el(doc, 'div', { class: 'tekla-changes-picker' });
60
+ const labelEl = el(doc, 'span', { class: 'tekla-changes-picker-label', id: `${id}-label`, text: label });
61
+ const current = () => states.find((state) => state.key === value) || null;
62
+ const trigger = el(doc, 'button', { type: 'button', class: 'tekla-changes-trigger', id, 'aria-haspopup': 'listbox', 'aria-expanded': 'false',
63
+ 'aria-labelledby': `${id}-label ${id}`, 'data-command-id': 'tekla-parser.change-review-state' });
64
+ const list = el(doc, 'div', { class: 'tekla-changes-options', role: 'listbox', 'aria-labelledby': `${id}-label`, hidden: true });
65
+ const paint = () => {
66
+ const state = current();
67
+ trigger.replaceChildren(el(doc, 'strong', { text: state ? state.label : 'Choose a saved state' }),
68
+ el(doc, 'span', { text: state ? `${when(state.savedAt)} · ${STATE_LABEL[state.capture]}` : '' }));
69
+ };
70
+ const close = () => { list.hidden = true; trigger.setAttribute('aria-expanded', 'false'); };
71
+ for (const state of states) {
72
+ const option = el(doc, 'div', { role: 'option', tabindex: '-1', class: 'tekla-changes-option', 'aria-selected': String(state.key === value),
73
+ 'aria-disabled': state.comparable ? null : 'true', 'data-key': state.key },
74
+ el(doc, 'strong', { text: state.label }), el(doc, 'span', { text: `${when(state.savedAt)} · ${STATE_LABEL[state.capture]}` }),
75
+ state.comparable ? null : el(doc, 'span', { class: 'tekla-changes-option-note', text: state.notComparable }));
76
+ const pick = () => {
77
+ if (!state.comparable) return;
78
+ value = state.key; paint(); close();
79
+ list.querySelectorAll('[role=option]').forEach((item) => item.setAttribute('aria-selected', String(item.dataset.key === value)));
80
+ trigger.focus(); onChange(value);
81
+ };
82
+ option.addEventListener('click', pick);
83
+ option.addEventListener('keydown', (event) => {
84
+ if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); pick(); }
85
+ else if (event.key === 'Escape') { close(); trigger.focus(); }
86
+ else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
87
+ event.preventDefault();
88
+ const options = [...list.querySelectorAll('[role=option]')];
89
+ options[(options.indexOf(option) + (event.key === 'ArrowDown' ? 1 : -1) + options.length) % options.length]?.focus();
90
+ }
91
+ });
92
+ list.append(option);
93
+ }
94
+ trigger.addEventListener('click', () => {
95
+ const opening = list.hidden;
96
+ list.hidden = !opening; trigger.setAttribute('aria-expanded', String(opening));
97
+ if (!opening) return;
98
+ // The list hangs below the trigger inside the panel's scroll area; near the bottom of a short panel it
99
+ // would open out of sight. Scroll only that panel, by just the hidden part (never the page around it).
100
+ const panel = wrap.closest('.tekla-changes-host');
101
+ if (panel) {
102
+ const box = list.getBoundingClientRect();
103
+ const view = panel.getBoundingClientRect();
104
+ if (box.bottom > view.bottom) panel.scrollTop += Math.min(box.bottom - view.bottom, box.top - view.top);
105
+ else if (box.top < view.top) panel.scrollTop -= view.top - box.top;
106
+ }
107
+ const chosen = list.querySelector('[aria-selected=true]') || list.querySelector('[role=option]');
108
+ if (!chosen) return;
109
+ // Keep the current choice visible inside the list itself, then focus it without scrolling anything else.
110
+ if (chosen.offsetTop < list.scrollTop) list.scrollTop = chosen.offsetTop;
111
+ else if (chosen.offsetTop + chosen.offsetHeight > list.scrollTop + list.clientHeight) list.scrollTop = chosen.offsetTop + chosen.offsetHeight - list.clientHeight;
112
+ chosen.focus({ preventScroll: true });
113
+ });
114
+ trigger.addEventListener('keydown', (event) => { if (event.key === 'ArrowDown' && list.hidden) { event.preventDefault(); trigger.click(); } });
115
+ doc.addEventListener('pointerdown', (event) => { if (!wrap.contains(event.target)) close(); });
116
+ paint();
117
+ wrap.append(labelEl, trigger, list);
118
+ return { node: wrap, value: () => value };
119
+ }
120
+
121
+ /** A history row's word on the checks: how many findings, never a claim that a review is clean. */
122
+ function checksNote(item) {
123
+ const c = item.checks;
124
+ if (!c) return '';
125
+ if (c.state !== 'ran') return ' · checks not run';
126
+ const n = c.summary?.findings ?? 0;
127
+ return n ? ` · ${n.toLocaleString()} ${n === 1 ? 'finding' : 'findings'}${c.complete ? '' : ' (not all listed)'}` : ' · no findings in what was checked';
128
+ }
129
+
130
+ export function mountChangeReview({ host, doc = document, projectId, fetchJson, locate, onStateChanged = () => {}, clipboard = null }) {
131
+ let states = [];
132
+ let reviews = [];
133
+ let review = null;
134
+ let rows = [];
135
+ let unpaired = null;
136
+ let busy = false;
137
+ let picks = { base: null, revised: null };
138
+ let refusal = null;
139
+ let message = null;
140
+ const live = el(doc, 'div', { class: 'tekla-changes-live', role: 'status', 'aria-live': 'polite' });
141
+ // S2 (#3461): what the checks found, and the person's decisions on it.
142
+ const findings = createFindings({ doc, el, api: (path, options) => fetchJson(path, options), projectId, live, locate, clipboard,
143
+ sideState: (side) => sideState(side), rerender: () => render(), focusCompare: () => host.querySelector('.tekla-changes-compare')?.focus() });
144
+
145
+ const api = (path, options) => fetchJson(path, options);
146
+
147
+ async function load() {
148
+ refusal = null; message = null;
149
+ try {
150
+ const listed = await api(`/api/change-review/tekla/${encodeURIComponent(projectId)}/states`);
151
+ if (listed.access && listed.access.allowed === false) {
152
+ refusal = { module: listed.access.module, code: listed.access.code, text: listed.access.userMessage }; states = []; reviews = []; render(); return;
153
+ }
154
+ states = listed.states || [];
155
+ reviews = (await api(`/api/change-review/${encodeURIComponent(projectId)}/reviews`)).reviews || [];
156
+ const comparable = states.filter((state) => state.comparable);
157
+ if (!picks.revised || !comparable.some((state) => state.key === picks.revised)) picks.revised = comparable.at(-1)?.key ?? null;
158
+ if (!picks.base || !comparable.some((state) => state.key === picks.base) || picks.base === picks.revised) {
159
+ picks.base = comparable.filter((state) => state.key !== picks.revised).at(-1)?.key ?? null;
160
+ }
161
+ } catch (error) {
162
+ if (error?.status === 403) refusal = { module: error.body?.module ?? null, code: error.body?.code ?? null, text: error.body?.userMessage || error.message };
163
+ else message = { kind: 'error', text: error?.body?.userMessage || 'The saved states could not be listed. Open the model again, then try once more.' };
164
+ }
165
+ render();
166
+ }
167
+
168
+ let pick = 0;
169
+ let opening = false;
170
+
171
+ async function compare() {
172
+ if (busy || !picks.base || !picks.revised) return;
173
+ busy = true; message = null; render();
174
+ // If the person picks a review before this finishes, the comparison is listed but neither opened, announced nor
175
+ // reported over that review. Only opening a review moves the pick, so nothing is ever left half open.
176
+ const token = pick;
177
+ let focusResult = false;
178
+ live.textContent = 'Comparing the two saved states…';
179
+ try {
180
+ const reply = await api(`/api/change-review/tekla/${encodeURIComponent(projectId)}/compare`, {
181
+ method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ base: picks.base, revised: picks.revised,
182
+ // The revisions the pickers show: a newer copy imported since is refused, never compared in their place.
183
+ baseRevisionId: states.find((state) => state.key === picks.base)?.revisionId,
184
+ revisedRevisionId: states.find((state) => state.key === picks.revised)?.revisionId }),
185
+ });
186
+ reviews = [reply.review, ...reviews.filter((item) => item.reviewId !== reply.review.reviewId)];
187
+ if (token !== pick || !(await openReview(reply.review))) return;
188
+ focusResult = true;
189
+ const s = reply.review.summary;
190
+ live.textContent = !s ? 'Compared.' : reply.review.parserParity === 'differs'
191
+ ? `Compared, read by different versions of FloLess: ${s.added} only in the later state, ${s.removed} only in the earlier, ${s.changed} may differ.`
192
+ : `Compared: ${s.added} added, ${s.removed} removed, ${s.changed} changed.`;
193
+ } catch (error) {
194
+ if (token !== pick) return;
195
+ focusResult = true;
196
+ if (error?.status === 403) refusal = { module: error.body?.module ?? null, code: error.body?.code ?? null, text: error.body?.userMessage || error.message };
197
+ else if (error?.body?.code === 'state-changed') { await load(); if (token === pick) message = { kind: 'warning', text: error.body.userMessage }; }
198
+ else message = { kind: 'error', text: error?.body?.userMessage || 'The comparison could not be finished. Try again; if it keeps happening, use Report an issue.' };
199
+ live.textContent = '';
200
+ } finally {
201
+ busy = false; render(); onStateChanged();
202
+ if (focusResult) host.querySelector('.tekla-changes-result-title')?.focus();
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Open a review. Every opening takes the next pick number; only the pick numbered last may fill the panel, and until
208
+ * it does the panel says it is opening, so nothing from the earlier review can be clicked. A later opening always
209
+ * finishes or is itself overtaken, so 'opening' is never left on. Resolves true when this pick is the one on screen.
210
+ */
211
+ async function openReview(next) {
212
+ const token = ++pick;
213
+ // Nothing said or reported about what was on screen before carries over to this opening, even of the same review.
214
+ live.textContent = ''; message = null;
215
+ review = next; rows = []; unpaired = null; opening = true;
216
+ const findingsLoaded = findings.load(next);
217
+ render();
218
+ let got = []; let gotUnpaired = null; let failedRows = false;
219
+ try {
220
+ const page = await api(`/api/change-review/${encodeURIComponent(projectId)}/reviews/${next.reviewId}/changes?limit=500`);
221
+ got = page.rows || []; gotUnpaired = page.unpaired || null;
222
+ if (page.total > got.length) {
223
+ for (let offset = got.length; offset < Math.min(page.total, 5000); offset += 500) {
224
+ if (token !== pick) return false;
225
+ const more = await api(`/api/change-review/${encodeURIComponent(projectId)}/reviews/${next.reviewId}/changes?limit=500&offset=${offset}`);
226
+ got.push(...(more.rows || []));
227
+ }
228
+ }
229
+ } catch { failedRows = true; }
230
+ await findingsLoaded;
231
+ if (token !== pick) return false;
232
+ opening = false; rows = got; unpaired = gotUnpaired;
233
+ if (failedRows) message = { kind: 'error', text: 'The list of changes for this review could not be opened. Compare the saved states again.' };
234
+ render();
235
+ return true;
236
+ }
237
+
238
+ function sideState(side) { return states.find((state) => state.revisionId === review?.[side]?.revisionId) || null; }
239
+
240
+ function renderRow(row) {
241
+ const shownPick = pick;
242
+ const detailId = `tekla-change-${row.status}-${row.identity.replace(/[^A-Za-z0-9_-]/g, '_')}`;
243
+ const kinds = (row.kinds || []).map((kind) => el(doc, 'span', { class: 'tekla-changes-chip', text: KIND_LABEL[kind] || kind }));
244
+ const toggle = el(doc, 'button', { type: 'button', class: 'tekla-audit-row tekla-changes-row', 'aria-expanded': 'false', 'aria-controls': detailId,
245
+ 'data-command-id': 'tekla-parser.change-review-row' },
246
+ el(doc, 'strong', { text: row.name || row.type || 'Object', 'data-tip': `${row.type} · ${row.name}` }),
247
+ el(doc, 'span', { text: row.type }),
248
+ kinds.length ? el(doc, 'span', { class: 'tekla-changes-chips' }, kinds) : null);
249
+ const side = row.status === 'removed' ? 'base' : 'revised';
250
+ const target = sideState(side);
251
+ const entityId = side === 'base' ? row.entityIdBase : row.entityIdRevised;
252
+ const show = el(doc, 'button', { type: 'button', class: 'tekla-changes-locate', 'data-command-id': 'tekla-parser.change-review-locate',
253
+ 'aria-label': `Show ${row.name || row.type} in 3D${row.status === 'removed' ? ' in the earlier saved state' : ''}`,
254
+ text: row.status === 'removed' ? 'Show in earlier state' : 'Show in 3D',
255
+ onclick: async () => {
256
+ if (shownPick !== pick) return;
257
+ if (!target || !entityId) {
258
+ message = { kind: 'error', text: 'That saved state is no longer part of this project, so this object cannot be shown in 3D.' }; render(); return;
259
+ }
260
+ show.disabled = true;
261
+ try { await locate({ state: target, entityId }); }
262
+ catch (error) { if (shownPick === pick) { message = { kind: 'error', text: error?.message || 'That saved state could not be opened in 3D.' }; render(); } }
263
+ finally { show.disabled = false; }
264
+ } });
265
+ const detail = el(doc, 'div', { class: 'tekla-changes-detail', id: detailId, hidden: true });
266
+ if (row.status === 'changed' && Array.isArray(row.fields)) {
267
+ for (const field of row.fields) {
268
+ detail.append(el(doc, 'div', { class: 'tekla-changes-field' },
269
+ el(doc, 'span', { class: 'tekla-changes-field-name', text: `${fieldName(field.key)} · ${KIND_LABEL[field.kind] || field.kind}` }),
270
+ el(doc, 'span', { class: 'tekla-changes-before', text: `Before: ${shown(field.before)}` }),
271
+ el(doc, 'span', { class: 'tekla-changes-after', text: `After: ${shown(field.after)}` })));
272
+ }
273
+ if (row.truncatedFields) detail.append(el(doc, 'p', { class: 'tekla-audit-omissions', text: `${plural(row.truncatedFields, 'more field')} changed and are not listed.` }));
274
+ } else {
275
+ detail.append(el(doc, 'p', { class: 'tekla-audit-omissions', text: row.status === 'added' ? 'This object is in the later saved state only.' : 'This object is in the earlier saved state only.' }));
276
+ }
277
+ detail.append(show);
278
+ toggle.addEventListener('click', () => {
279
+ const open = toggle.getAttribute('aria-expanded') !== 'true';
280
+ toggle.setAttribute('aria-expanded', String(open)); detail.hidden = !open;
281
+ });
282
+ return el(doc, 'div', { class: 'tekla-changes-item' }, toggle, detail);
283
+ }
284
+
285
+ function renderResult() {
286
+ const out = [];
287
+ const s = review.summary || {};
288
+ const title = el(doc, 'h3', { class: 'tekla-changes-result-title', tabindex: '-1', text: `Compared ${review.base.label} with ${review.revised.label}.` });
289
+ out.push(title);
290
+ const metrics = el(doc, 'section', { class: 'tekla-audit-summary tekla-changes-metrics', 'aria-label': 'Change counts' });
291
+ // Read by two parser versions, a changed field may be the reading, not the model (plan §2.4): never call it a change.
292
+ const parserDiffers = review.parserParity === 'differs';
293
+ for (const [value, label] of parserDiffers
294
+ ? [[s.added, 'Only in later (may be the reading)'], [s.removed, 'Only in earlier (may be the reading)'], [s.changed, 'May differ']]
295
+ : [[s.added, 'Added'], [s.removed, 'Removed'], [s.changed, 'Changed']]) {
296
+ metrics.append(el(doc, 'div', {}, el(doc, 'strong', { text: Number(value || 0).toLocaleString() }), el(doc, 'span', { text: label })));
297
+ }
298
+ out.push(metrics);
299
+ out.push(el(doc, 'p', { class: 'tekla-audit-omissions', text: 'Whose changes: not known. FloLess compares what was saved, not who changed it.' }));
300
+ out.push(el(doc, 'p', { class: 'tekla-audit-omissions',
301
+ text: `${review.base.label}: ${STATE_LABEL[review.base.capture?.label] || STATE_LABEL['not-recorded']}. ${review.revised.label}: ${STATE_LABEL[review.revised.capture?.label] || STATE_LABEL['not-recorded']}.` }));
302
+ const banner = (tone, heading, text) => el(doc, 'section', { class: `tekla-changes-banner ${tone}`, role: 'note', 'aria-label': heading },
303
+ el(doc, 'strong', { text: `⚠ ${heading}` }), el(doc, 'span', { text }));
304
+ if (review.diagnosticReasons?.includes('capture')) {
305
+ out.push(banner('warn', 'Check these results', 'One or both saved states may not have been copied from one clean save, so some differences could be missing or false. Save in Tekla, import the folder again and compare to be sure.'));
306
+ }
307
+ if (review.parserParity === 'differs') {
308
+ out.push(banner('warn', 'Read by different versions', 'These two saved states were read by different versions of FloLess, so small differences may come from the reading, not the model. Import the earlier saved state again to compare them on one version.'));
309
+ }
310
+ if (s.discontinuity) {
311
+ out.push(banner('warn', 'Most objects could not be matched',
312
+ `Only ${Number(s.paired).toLocaleString()} of ${Number(s.base).toLocaleString()} objects could be matched between these saved states. The model may have been rebuilt or its components regenerated, so the lists below are not a list of edits. Compare two saved states that are closer together.`));
313
+ }
314
+ const w = review.witness;
315
+ if (w) out.push(el(doc, 'p', { class: 'tekla-audit-omissions',
316
+ text: w.state === 'agrees' ? 'Tekla’s own save history agrees with these changes.' : w.state === 'disagrees' ? `Tekla’s own save history does not agree: ${w.detail}` : w.detail }));
317
+ const notChecked = el(doc, 'section', { class: 'tekla-changes-unchecked', 'aria-label': 'What was not checked' },
318
+ el(doc, 'strong', { text: 'What was not checked' }), ...(review.unchecked || []).map((line) => el(doc, 'p', { class: 'tekla-audit-omissions', text: line })));
319
+ out.push(...findings.nodes());
320
+ out.push(notChecked);
321
+ const list = el(doc, 'div', { class: 'tekla-audit-list tekla-changes-list', 'aria-label': 'Changes' });
322
+ for (const status of ['changed', 'added', 'removed']) {
323
+ const group = rows.filter((row) => row.status === status);
324
+ const total = s[status] || 0;
325
+ const section = el(doc, 'details', { class: 'tekla-changes-group', open: status === 'changed' ? true : null },
326
+ el(doc, 'summary', { text: !parserDiffers ? `${STATUS_HEADING[status]} (${Number(total).toLocaleString()})`
327
+ : status === 'changed' ? `Differences that may come from the reading, not the model (${Number(total).toLocaleString()})`
328
+ : `Only in the ${status === 'added' ? 'later' : 'earlier'} saved state, which may be the reading (${Number(total).toLocaleString()})` }));
329
+ if (!group.length) {
330
+ const none = !parserDiffers ? `Nothing ${STATUS_HEADING[status].toLowerCase()}.`
331
+ : status === 'changed' ? 'No differences.' : `Nothing only in the ${status === 'added' ? 'later' : 'earlier'} saved state.`;
332
+ section.append(el(doc, 'p', { class: 'tekla-audit-omissions', text: total ? `Not listed: the list is limited to 5,000 ${parserDiffers ? 'differences' : 'changes'}.` : none }));
333
+ }
334
+ for (const row of group) section.append(renderRow(row));
335
+ list.append(section);
336
+ }
337
+ // Added and removed objects grouped by type and name, so a regenerated component reads as one group. A group is
338
+ // a way of showing what could not be matched, never a match.
339
+ const groups = Array.isArray(unpaired?.groups) ? unpaired.groups : [];
340
+ if (groups.length) {
341
+ const section = el(doc, 'details', { class: 'tekla-changes-group' },
342
+ el(doc, 'summary', { text: `Could not be matched, by type and name (${Number(unpaired.groupCount ?? groups.length).toLocaleString()})` }),
343
+ el(doc, 'p', { class: 'tekla-audit-omissions', text: 'Objects only in one saved state, grouped by type and name. A group is not a match: FloLess does not guess which object became which.'
344
+ + (parserDiffers ? ' These saved states were read by different versions of FloLess, so some of these may come from the reading, not the model.' : '') }));
345
+ for (const g of groups) {
346
+ const removedN = g.removed?.count ?? 0; const addedN = g.added?.count ?? 0;
347
+ section.append(el(doc, 'div', { class: 'tekla-changes-unpaired' },
348
+ el(doc, 'strong', { text: `${g.type || 'Object'} · ${g.name || 'unnamed'}` }),
349
+ el(doc, 'span', { text: `${removedN.toLocaleString()} only in the earlier state, ${addedN.toLocaleString()} only in the later state` })));
350
+ }
351
+ if ((unpaired.groupCount ?? groups.length) > groups.length) section.append(el(doc, 'p', { class: 'tekla-audit-omissions', text: `${(unpaired.groupCount - groups.length).toLocaleString()} more groups are not listed.` }));
352
+ list.append(section);
353
+ }
354
+ const omitted = review.summary?.truncated ? (s.added + s.removed + s.changed) - rows.length : 0;
355
+ const noun = parserDiffers ? 'differences' : 'changes';
356
+ if (omitted > 0) list.append(el(doc, 'p', { class: 'tekla-audit-omissions', text: `${rows.length.toLocaleString()} ${noun} are shown. ${omitted.toLocaleString()} more are not listed.` }));
357
+ out.push(list);
358
+ return out;
359
+ }
360
+
361
+ function render() {
362
+ host.replaceChildren();
363
+ host.classList.add('tekla-changes-host');
364
+ if (refusal) {
365
+ // Only a plan without Change Review gets the team-plan panel; any other refusal (Tekla access, a sign-in that
366
+ // needs renewing) is said in its own words, without promising that a plan change fixes it.
367
+ const notInPlan = refusal.module === 'change_review' && refusal.code === 'module-inactive';
368
+ host.append(el(doc, 'div', { class: 'tekla-audit-state tekla-changes-locked' },
369
+ el(doc, 'strong', { text: notInPlan ? 'Change Review is part of the team plan' : 'Change Review can’t be used right now' }),
370
+ notInPlan ? el(doc, 'span', { text: 'It compares two saved states of a model and lists what was added, removed or changed, so you can review changes before they go out.' }) : null,
371
+ notInPlan ? el(doc, 'span', { text: 'It is not in the signed-in FloLess account’s plan.' }) : el(doc, 'span', { text: refusal.text }),
372
+ notInPlan ? el(doc, 'a', { href: 'https://floless.io/contact', target: '_blank', rel: 'noopener', class: 'tekla-changes-contact', 'data-command-id': 'tekla-parser.change-review-contact', text: 'Contact FloLess' }) : null));
373
+ host.append(live);
374
+ return;
375
+ }
376
+ const comparable = states.filter((state) => state.comparable);
377
+ const controls = el(doc, 'section', { class: 'tekla-changes-controls', 'aria-label': 'Choose saved states' });
378
+ if (comparable.length < 2) {
379
+ controls.append(el(doc, 'div', { class: 'tekla-audit-state' },
380
+ el(doc, 'strong', { text: 'You need two saved states to compare' }),
381
+ el(doc, 'span', { text: 'Save your model in Tekla, then import the model folder again. Each import adds a saved state.' }),
382
+ ...states.filter((state) => !state.comparable).map((state) => el(doc, 'span', { text: `${state.label}: ${state.notComparable}` }))));
383
+ } else {
384
+ controls.append(
385
+ statePicker(doc, { id: 'teklaChangesBase', label: 'Earlier saved state', states, value: picks.base, onChange: (key) => { picks.base = key; render(); } }).node,
386
+ statePicker(doc, { id: 'teklaChangesRevised', label: 'Later saved state', states, value: picks.revised, onChange: (key) => { picks.revised = key; render(); } }).node,
387
+ el(doc, 'button', { type: 'button', class: 'tekla-changes-compare primary', 'data-command-id': 'tekla-parser.change-review-compare',
388
+ 'aria-busy': busy ? 'true' : null, disabled: busy || picks.base === picks.revised ? true : null,
389
+ 'aria-label': picks.base === picks.revised ? 'Compare (choose two different saved states)' : 'Compare the two saved states',
390
+ text: busy ? 'Comparing…' : 'Compare', onclick: compare }));
391
+ if (picks.base === picks.revised) controls.append(el(doc, 'p', { class: 'tekla-audit-omissions', text: 'Choose two different saved states to compare.' }));
392
+ }
393
+ host.append(controls, live);
394
+ if (message) host.append(el(doc, 'p', { class: `tekla-changes-message ${message.kind}`, role: message.kind === 'info' ? 'status' : 'alert', text: message.text }));
395
+ if (review) host.append(...(opening ? [el(doc, 'p', { class: 'tekla-audit-omissions tekla-changes-opening', role: 'status', text: 'Opening review…' })] : renderResult()));
396
+ findings.restoreFocus(host);
397
+ if (reviews.length) {
398
+ const history = el(doc, 'details', { class: 'tekla-changes-history' }, el(doc, 'summary', { text: `Earlier reviews (${reviews.length})` }));
399
+ for (const item of reviews) {
400
+ const s = item.summary || {};
401
+ history.append(el(doc, 'button', { type: 'button', class: 'tekla-changes-history-row', 'data-command-id': 'tekla-parser.change-review-history',
402
+ 'aria-current': review?.reviewId === item.reviewId ? 'true' : null, onclick: () => openReview(item) },
403
+ el(doc, 'strong', { text: `${item.base.label} → ${item.revised.label}` }),
404
+ el(doc, 'span', { text: item.parserParity === 'differs'
405
+ ? `${when(item.createdAt)} · read by different versions of FloLess · ${s.added ?? 0} only in later, ${s.removed ?? 0} only in earlier, ${s.changed ?? 0} may differ`
406
+ : `${when(item.createdAt)} · ${s.added ?? 0} added, ${s.removed ?? 0} removed, ${s.changed ?? 0} changed${item.diagnostic ? ' · check these results' : ''}${checksNote(item)}` })));
407
+ }
408
+ host.append(history);
409
+ }
410
+ }
411
+
412
+ render();
413
+ return { load, refresh: load, state: () => ({ states: states.length, review: review?.reviewId ?? null, rows: rows.length, refusal: !!refusal, ...findings.state() }) };
414
+ }
@@ -411,8 +411,8 @@ const CONTRIBUTIONS = Object.freeze({
411
411
  { kind: 'disclosure', cmd: 'steel.flo-card-settings', el: 'floCardDisc', class: 'pl-disclosure', controls: 'floCardScope', label: 'Flo', tip: 'Choose what Flo’s card says about the member Flo hops onto' },
412
412
  ],
413
413
  },
414
- // How big Flo and its card are drawn, like Grid label size for the grid bubbles: one setting for both.
415
- { kind: 'range', cmd: 'steel.flo-size', el: 'floSize', valueEl: 'floSizeV', label: 'Flo size', min: 60, max: 200, step: 10, value: 100, ariaLabel: 'Flo size in percent', tip: 'How big Flo and Flo’s card are drawn in 3D. They keep this size on screen however far you zoom.' },
414
+ // How big Flo and its card are drawn: one setting for both. Flo follows the zoom from this size (#3380); the card keeps it.
415
+ { kind: 'range', cmd: 'steel.flo-size', el: 'floSize', valueEl: 'floSizeV', label: 'Flo size', min: 60, max: 200, step: 10, value: 100, ariaLabel: 'Flo size in percent', tip: 'How big Flo and Flo’s card are drawn in 3D. Flo gets smaller as you zoom in close and bigger as you zoom out, starting from this size.' },
416
416
  {
417
417
  kind: 'scope', el: 'floCardScope', class: 'pl-scope', revealBy: 'floCardDisc', hidden: true, items: [
418
418
  { kind: 'note', el: 'floCardNote', class: 'pl-note' },
@@ -401,6 +401,12 @@ export function mountModelMeasureTool({
401
401
  const onKey = (event) => {
402
402
  const key = String(event.key || '').toLowerCase();
403
403
  if (editor && event.key === 'Escape') { event.preventDefault(); closeEditor(); return; }
404
+ // D, F, X, Y and Z are toggles: a held key's auto-repeat would flip them on and off and leave the
405
+ // tool or lock in whatever state the last repeat landed on (#3145). Only the first press counts;
406
+ // the repeats are still consumed so nothing behind the tool acts on them.
407
+ if (event.repeat && ['d', 'f', 'x', 'y', 'z'].includes(key) && !event.ctrlKey && !event.metaKey && !event.altKey) {
408
+ if (key === 'd' || armed) { event.preventDefault(); return; }
409
+ }
404
410
  if (key === 'd' && !event.ctrlKey && !event.metaKey && !event.altKey) { event.preventDefault(); api.toggle(); return; }
405
411
  if (!armed) {
406
412
  if (event.key === 'Delete' && selectedIndex !== null) { event.preventDefault(); session.remove(selectedIndex); syncSession(); render(); notify(); }
@@ -9,7 +9,7 @@
9
9
  let panelSequence = 0;
10
10
  const finite = (value, label) => {
11
11
  const next = Number(value);
12
- if (!Number.isFinite(next)) throw new TypeError(`${label} must be a finite number.`);
12
+ if (!Number.isFinite(next)) throw Object.assign(new TypeError(`${label} must be a finite number.`), { forPerson: true });
13
13
  return next;
14
14
  };
15
15
  const degrees = (radians) => radians * 180 / Math.PI;
@@ -69,6 +69,17 @@ function note(doc, text) { const value = doc.createElement('div'); value.classNa
69
69
 
70
70
  function actionRow(doc) { const row = doc.createElement('div'); row.className = 'model-spatial-panel-actions'; return row; }
71
71
 
72
+ // The shared spatial tools word their checks for a developer ("clip.min must have positive extents"), so the checks a
73
+ // person can trip from this panel's own controls are answered here by code, each saying what to change. Each sentence
74
+ // must hold for every call that raises its code: the range check covers points and directions alike.
75
+ const SPATIAL_GUIDANCE = Object.freeze({
76
+ E_MODEL_SPATIAL_EXTENTS: 'Each minimum must be smaller than its maximum. Change the box corners, then update the clip again.',
77
+ E_MODEL_SPATIAL_DEGENERATE: 'That direction has no length: its values are all zero, or the points picked lie on one line. Change them, then try again.',
78
+ E_MODEL_SPATIAL_RANGE: 'That value is larger than FloLess can place. Use a smaller number, then try again.',
79
+ E_MODEL_WORK_PLANE_UNAVAILABLE: 'There is no working plane yet. Set one first, then try again.',
80
+ E_MODEL_FRAME_LIMIT: 'This view already has as many saved frames as it can hold. Remove one, then try again.',
81
+ });
82
+
72
83
  /**
73
84
  * @param {{tools:any, trigger:HTMLElement, ports?:Record<string,Function>, documentRef?:Document,
74
85
  * windowRef?:Window, onBeforeOpen?:()=>void, onError?:(error:Error)=>void,
@@ -95,7 +106,7 @@ export function mountModelSpatialPanel({
95
106
  // quantity, so clicking Apply to change another field must not move this one by the rounding gap.
96
107
  if (typeof source !== 'string' && source?.dataset?.displayText === text) return Number(source.dataset.originalMm);
97
108
  const mm = lengthDisplay.parse(text);
98
- if (typeof mm !== 'number' || !Number.isFinite(mm)) throw new TypeError(`${label} must be a finite length.`);
109
+ if (typeof mm !== 'number' || !Number.isFinite(mm)) throw Object.assign(new TypeError(`${label} must be a finite length.`), { forPerson: true });
99
110
  return mm;
100
111
  };
101
112
  const lengthValuesFrom = (host, prefix, label) => [0, 1, 2].map((index) =>
@@ -105,7 +116,11 @@ export function mountModelSpatialPanel({
105
116
 
106
117
  const report = (error) => {
107
118
  const value = error instanceof Error ? error : new Error(String(error));
108
- if (status) { status.textContent = value.message; status.dataset.tone = 'error'; }
119
+ // #3097 3b: the panel's own input checks are said as written (forPerson), and a shared-tool check a person can
120
+ // trip with typed values is answered by its code; anything else that threw gets the shared sentence and stays in
121
+ // the console.
122
+ const guidance = SPATIAL_GUIDANCE[value.code];
123
+ if (status) { status.textContent = guidance || errorText(value, { action: 'use that spatial tool', retrySafe: true }); status.dataset.tone = 'error'; }
109
124
  try { onError(value); } catch (_) { /* reporting cannot break the spatial interaction */ }
110
125
  };
111
126
  const run = (operation, success = '') => {
@@ -169,7 +184,7 @@ export function mountModelSpatialPanel({
169
184
  if (lengthDisplay) {
170
185
  const raw = text.trim(), relative = raw.startsWith('@');
171
186
  const parts = (relative ? raw.slice(1) : raw).split(',').map((part) => part.trim());
172
- if (parts.length !== 3) throw new TypeError('Enter X, Y, Z as three finite lengths.');
187
+ if (parts.length !== 3) throw Object.assign(new TypeError('Enter X, Y, Z as three finite lengths.'), { forPerson: true });
173
188
  text = `${relative ? '@' : ''}${parts.map((part, axis) => readLength(part, `Coordinate ${'XYZ'[axis]}`)).join(',')}`;
174
189
  }
175
190
  const point = tools.parseCoordinates(text, basePoint);
@@ -27,7 +27,7 @@ const finite = (value, label) => {
27
27
  const vec3 = (value, label) => {
28
28
  if (!Array.isArray(value) || value.length !== 3) throw new TypeError(`${label} must be a 3D point.`);
29
29
  const next = value.map((item, index) => finite(item, `${label}[${index}]`));
30
- if (next.some((item) => Math.abs(item) > MAX_COORDINATE_MM)) throw new TypeError(`${label} exceeds the supported coordinate range.`);
30
+ if (next.some((item) => Math.abs(item) > MAX_COORDINATE_MM)) throw Object.assign(new TypeError(`${label} exceeds the supported coordinate range.`), { code: 'E_MODEL_SPATIAL_RANGE' });
31
31
  return next;
32
32
  };
33
33
  const canonicalText = (value, label, maximum) => {
@@ -42,7 +42,7 @@ const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a
42
42
  const length = (value) => Math.hypot(...value);
43
43
  const unit = (value, label) => {
44
44
  const magnitude = length(value);
45
- if (!(magnitude > EPS)) throw new TypeError(`${label} is degenerate.`);
45
+ if (!(magnitude > EPS)) throw Object.assign(new TypeError(`${label} is degenerate.`), { code: 'E_MODEL_SPATIAL_DEGENERATE' });
46
46
  return scale(value, 1 / magnitude);
47
47
  };
48
48
 
@@ -96,7 +96,7 @@ function validatePlane(value, label = 'plane') {
96
96
 
97
97
  function validateBox(value, label = 'box') {
98
98
  const min = vec3(value?.min, `${label}.min`); const max = vec3(value?.max, `${label}.max`);
99
- if (min.some((item, index) => item >= max[index])) throw new TypeError(`${label} must have positive extents.`);
99
+ if (min.some((item, index) => item >= max[index])) throw Object.assign(new TypeError(`${label} must have positive extents.`), { code: 'E_MODEL_SPATIAL_EXTENTS' });
100
100
  return snapshot({ min, max });
101
101
  }
102
102
 
@@ -1323,9 +1323,9 @@ export function createRevitViewport({ canvas, onSelect = () => {}, onOutlineBuil
1323
1323
  setWorkPlaneVisible: (value) => needSpatial().setWorkPlaneVisible(value),
1324
1324
  clearWorkPlane() { const tools = needSpatial(); const state = tools.state(); if (state.workPlane?.visible) tools.setWorkPlaneVisible(false); return tools.resetGlobal(); },
1325
1325
  workPlaneInfo: () => spatialState?.workPlane ?? null,
1326
- setWorkArea(from) { const box = canonicalBounds(from === 'selection' ? selectedMeshes() : ownedMeshes); if (!box) throw new Error(from === 'selection' ? 'Select model objects first.' : 'No visible model bounds are available.'); return needSpatial().setWorkArea({ ...box, wholeParts: true }); },
1327
- toggleWorkArea() { const tools = needSpatial(); const area = tools.state().workArea; if (!area) throw new Error('Set a work area first.'); return tools.setWorkAreaVisible(!area.visible); },
1328
- toggleWorkAreaWhole() { const tools = needSpatial(); const area = tools.state().workArea; if (!area) throw new Error('Set a work area first.'); return tools.setWorkAreaWhole(!area.wholeParts); },
1326
+ setWorkArea(from) { const box = canonicalBounds(from === 'selection' ? selectedMeshes() : ownedMeshes); if (!box) throw Object.assign(new Error(from === 'selection' ? 'Select model objects first.' : 'Nothing in this model is shown, so there is no work area to set.'), { forPerson: true }); return needSpatial().setWorkArea({ ...box, wholeParts: true }); },
1327
+ toggleWorkArea() { const tools = needSpatial(); const area = tools.state().workArea; if (!area) throw Object.assign(new Error('Set a work area first.'), { forPerson: true }); return tools.setWorkAreaVisible(!area.visible); },
1328
+ toggleWorkAreaWhole() { const tools = needSpatial(); const area = tools.state().workArea; if (!area) throw Object.assign(new Error('Set a work area first.'), { forPerson: true }); return tools.setWorkAreaWhole(!area.wholeParts); },
1329
1329
  workAreaState: () => spatialState?.workArea ?? null,
1330
1330
  projection: () => controller.cameraState().projection, displayMode: () => controller.displayMode(),
1331
1331
  lightingState: () => ({ ...lighting }), setLighting: (value) => ({ ...applyLighting(value) }),