@floless/app 0.148.1 → 0.149.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 (43) hide show
  1. package/bin/floless.mjs +1 -1
  2. package/dist/floless-server.cjs +28663 -18914
  3. package/dist/schemas/drawing-check.profile.v1.schema.json +156 -0
  4. package/dist/schemas/steel.model.v2.schema.json +43 -1
  5. package/dist/schemas/tekla.model.v2.schema.json +6 -2
  6. package/dist/skills/floless-app-steel-model/SKILL.md +54 -11
  7. package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +9 -5
  8. package/dist/skills/floless-app-steel-takeoff/SKILL.md +128 -15
  9. package/dist/skills/floless-app-vectorize/SKILL.md +7 -4
  10. package/dist/templates/check-drawings.flo +46 -0
  11. package/dist/templates/drawing-check.flo +55 -0
  12. package/dist/templates/tekla-parser.flo +6 -2
  13. package/dist/web/app.css +143 -8
  14. package/dist/web/aware.js +444 -39
  15. package/dist/web/chat.css +171 -9
  16. package/dist/web/chat.js +2005 -759
  17. package/dist/web/commands-drawing-check.js +53 -0
  18. package/dist/web/commands-shell.js +275 -3
  19. package/dist/web/commands-steel.js +1 -0
  20. package/dist/web/commands-tekla-parser.js +3 -0
  21. package/dist/web/commands.js +1 -1
  22. package/dist/web/connections.js +382 -0
  23. package/dist/web/display-units.js +15 -1
  24. package/dist/web/drawing-check-editor.html +289 -0
  25. package/dist/web/drawing-check-editor.js +1242 -0
  26. package/dist/web/drawing-check-overlay.js +36 -0
  27. package/dist/web/filter-ai-proposal.js +32 -13
  28. package/dist/web/index.html +25 -3
  29. package/dist/web/instructor.js +2 -2
  30. package/dist/web/local-discovery.js +144 -2
  31. package/dist/web/model-display-units.js +23 -9
  32. package/dist/web/model-viewport-revit-adapter.js +12 -2
  33. package/dist/web/revit-editor.css +5 -0
  34. package/dist/web/revit-editor.js +141 -20
  35. package/dist/web/steel-editor.html +166 -27
  36. package/dist/web/steel-filter.html +60 -166
  37. package/dist/web/steel-model-v2-commands.js +13 -3
  38. package/dist/web/steel-model-v2-projection.js +20 -0
  39. package/dist/web/steel-units.js +3 -1
  40. package/dist/web/workspaces.js +306 -22
  41. package/launch.mjs +5 -5
  42. package/package.json +3 -1
  43. package/dist/web/filter-ai-context.js +0 -92
@@ -268,15 +268,42 @@ const TEKLA_AUDIT_COPY = Object.freeze({
268
268
  'weld-recipes-unevaluated': Object.freeze({ group: 'shape-not-evaluated', title: 'Shape detail not evaluated', detail: 'Some weld-shape instructions were preserved as database facts but were not evaluated into display geometry.' }),
269
269
  'grid-mapping-unevaluated': Object.freeze({ group: 'shape-not-evaluated', title: 'Grid not shown in 3D', detail: 'This grid is present in the Tekla database, but its display extents could not be mapped safely.' }),
270
270
  'unsupported-native-type': Object.freeze({ group: 'shape-not-evaluated', title: 'Shape detail not evaluated', detail: 'This native Tekla object type is recorded but is not yet interpreted by the parser.' }),
271
+ // #1836: the model was read without a Tekla catalogue file the person chose to continue without.
272
+ 'profile-catalogue-missing': Object.freeze({ group: 'shape-not-evaluated', title: 'Shown as a stand-in bar', detail: 'This part’s profile shape isn’t known because profdb.bin was missing, so it is drawn as a thin stand-in bar where it can be placed. Read the model again with that file for the real shape.' }),
273
+ 'bolt-catalogue-missing': Object.freeze({ group: 'not-shown', title: 'Bolt not drawn', detail: 'This bolt needs a catalogue file that was missing (screwdb.db or assdb.db), so it is not drawn. Read the model again with the file to see it.' }),
271
274
  });
272
275
 
276
+ // #1836: what a missing catalogue file affects, for the Audit tab's Missing source files group.
277
+ const TEKLA_MISSING_SOURCE_COPY = Object.freeze({
278
+ 'profdb.bin': Object.freeze({ affects: 'Beam and column shapes', objects: (count) => count
279
+ ? `${count.toLocaleString()} ${count === 1 ? 'part is' : 'parts are'} shown as stand-in bars or not shown.`
280
+ : 'Every part’s shape could be worked out from its profile name.' }),
281
+ 'matdb.bin': Object.freeze({ affects: 'Material grades', objects: () => 'Material grades are read from the model itself, so nothing is drawn differently.' }),
282
+ 'screwdb.db': Object.freeze({ affects: 'Bolt sizes', objects: (count, missing) => boltsNotDrawn(count, missing.has('assdb.db') ? 'assdb.db' : null) }),
283
+ 'assdb.db': Object.freeze({ affects: 'Bolt nuts and washers', objects: (count, missing) => boltsNotDrawn(count, missing.has('screwdb.db') ? 'screwdb.db' : null) }),
284
+ });
285
+ // A bolt that needs both bolt files is counted once, under screwdb.db. A row with no bolt of its
286
+ // own says where its bolts are counted, never "0 bolts are not drawn".
287
+ function boltsNotDrawn(count, otherMissing) {
288
+ if (count) return `${count.toLocaleString()} ${count === 1 ? 'bolt is' : 'bolts are'} not drawn.`;
289
+ return otherMissing ? `The bolts it affects are counted under ${otherMissing}.` : 'No bolt in this model needed it.';
290
+ }
291
+ const TEKLA_CATALOGUE_ROLES = Object.freeze({ 'profdb.bin': 'profdb', 'matdb.bin': 'matdb', 'screwdb.db': 'screwdb', 'assdb.db': 'assdb' });
292
+ const TEKLA_CATALOGUE_ORIGINS = Object.freeze(['model-local', 'user-supplied-package', 'user-added', 'registry-proven', 'user-selected-setup', 'installed-environment']);
293
+
294
+ // #1836: a part profdb.bin's absence left with no axis is not drawn at all, so it is never called a stand-in bar.
295
+ const TEKLA_UNPLACED_PROFILE_COPY = Object.freeze({ group: 'not-shown', title: 'Part not drawn', detail: 'This part’s profile shape isn’t known because profdb.bin was missing, and it has no usable start and end point, so it is not drawn. Read the model again with that file to see it.' });
296
+ function auditCopyFor(finding) {
297
+ return finding.code === 'profile-catalogue-missing' && finding.hasGeometry === false ? TEKLA_UNPLACED_PROFILE_COPY : TEKLA_AUDIT_COPY[finding.code];
298
+ }
299
+
273
300
  function auditFindingsFor(entityId) { return teklaAudit?.findings?.filter((finding) => finding.entityId === entityId) ?? []; }
274
301
 
275
302
  function auditInspectorSection(findings) {
276
303
  return { id: 'import-audit', heading: 'Import audit', editable: false, render(host) {
277
304
  if (!findings.length) { const ok = document.createElement('div'); ok.className = 'tekla-audit-inspector-ok'; ok.textContent = 'No open import findings for this object.'; host.append(ok); return; }
278
305
  for (const finding of findings) {
279
- const copy = TEKLA_AUDIT_COPY[finding.code];
306
+ const copy = auditCopyFor(finding);
280
307
  const item = document.createElement('article'); item.className = 'tekla-audit-inspector-item';
281
308
  const heading = document.createElement('strong'); heading.textContent = copy?.title ?? 'Import finding';
282
309
  const detail = document.createElement('p'); detail.textContent = copy?.detail ?? 'The import audit recorded an unsupported finding code.';
@@ -485,7 +512,11 @@ function renderTeklaTypes(host, values, ownProperties, memberships = teklaAssemb
485
512
  }
486
513
  }, { expanded: !!normalized, populated: !!normalized || grouped.some((entity) => entity.id === followedId) });
487
514
  }
488
- if (!browsable.length) { const empty = document.createElement('div'); empty.className = 'explorer-empty'; empty.textContent = normalized ? 'No objects match this search.' : 'No verified model objects are available.'; host.append(empty); }
515
+ if (!browsable.length) { const empty = document.createElement('div'); empty.className = 'explorer-empty'; empty.textContent = normalized && allBrowsable.length ? 'No objects match this search.'
516
+ // #1849: objects were read, but none has a shape to browse; say so instead of "none available" or
517
+ // "no match" (the search only ever looks through drawn objects).
518
+ : values.length ? 'None of this model’s objects could be drawn, so there is nothing to browse here. The Audit tab lists the missing files and the objects they affect.'
519
+ : 'No verified model objects are available.'; host.append(empty); }
489
520
  return { shown: browsable.length, total: allBrowsable.length };
490
521
  }
491
522
 
@@ -523,22 +554,46 @@ function validateTeklaAuditDocument(value, manifest, auditReceipt, snapshotEntit
523
554
  && Object.keys(candidate).sort().join('\0') === [...expected].sort().join('\0');
524
555
  const snapshotEntityIds = new Set(snapshotEntities.map((entity) => entity.id));
525
556
  const omissions = value?.summary?.decoderOmissions;
557
+ // v2 (#1836) adds the catalogue files the read went without, and where FloLess took the others.
558
+ const v2 = value?.schemaVersion === 'floless.tekla-import-audit/v2';
559
+ const sources = v2 ? value.sources : [];
526
560
  if (!value || typeof value !== 'object' || Array.isArray(value)
527
- || !exactKeys(value, ['schemaVersion', 'summary', 'sourcePropertyDigests', 'findings'])
528
- || value.schemaVersion !== 'floless.tekla-import-audit/v1'
529
- || !exactKeys(value.summary, ['findings', 'affectedObjects', 'open', 'legacyCounts', 'unsupportedNativeTypes', ...(omissions === undefined ? [] : ['decoderOmissions'])])
561
+ || !exactKeys(value, ['schemaVersion', 'summary', 'sourcePropertyDigests', 'findings', ...(v2 ? ['sources', 'provenance', 'provenanceDigest'] : [])])
562
+ || (value.schemaVersion !== 'floless.tekla-import-audit/v1' && !v2)
563
+ || !exactKeys(value.summary, ['findings', 'affectedObjects', 'open', 'legacyCounts', 'unsupportedNativeTypes', ...(v2 ? ['openSources'] : []), ...(omissions === undefined ? [] : ['decoderOmissions'])])
530
564
  || !Array.isArray(value.sourcePropertyDigests) || value.sourcePropertyDigests.some((digest) => !/^[0-9a-f]{64}$/.test(digest))
531
565
  || !Array.isArray(value.summary.legacyCounts) || value.summary.legacyCounts.length !== 6
532
566
  || value.summary.legacyCounts.some((count) => !Number.isSafeInteger(count) || count < 0)
533
567
  || !Number.isSafeInteger(value.summary.unsupportedNativeTypes) || value.summary.unsupportedNativeTypes < 0
534
568
  || !Array.isArray(value.findings)
535
- || value.findings.length !== auditReceipt.items || value.findings.length !== manifest.audit?.findings
536
- || value.summary.findings !== value.findings.length || value.summary.open !== value.findings.length
569
+ || !Array.isArray(sources) || (v2 && value.summary.openSources !== sources.length)
570
+ || value.findings.length + sources.length !== auditReceipt.items || value.findings.length + sources.length !== manifest.audit?.findings
571
+ || value.summary.findings !== value.findings.length + sources.length || value.summary.open !== value.findings.length + sources.length
537
572
  || !Number.isSafeInteger(value.summary.affectedObjects) || value.summary.affectedObjects < 0
538
573
  || value.summary.affectedObjects !== manifest.audit?.affectedObjects || value.summary.open !== manifest.audit?.open) failAudit();
539
574
  if (omissions !== undefined && (!exactKeys(omissions, ['staleOrphanUdaAssignments', 'staleOrphanAssemblyDefinitions', 'description'])
540
575
  || ![omissions.staleOrphanUdaAssignments, omissions.staleOrphanAssemblyDefinitions].every((count) => Number.isSafeInteger(count) && count >= 0 && count <= 0xffffffff)
541
576
  || omissions.description !== 'Ignored stale database records not attached to model objects')) failAudit();
577
+ if (v2) {
578
+ const files = Object.keys(TEKLA_CATALOGUE_ROLES);
579
+ if (!Array.isArray(value.provenance) || value.provenance.length !== files.length
580
+ || typeof value.provenanceDigest !== 'string' || !/^[0-9a-f]{64}$/.test(value.provenanceDigest)) failAudit();
581
+ value.provenance.forEach((entry, index) => {
582
+ const file = files[index];
583
+ if (entry?.file !== file || entry.role !== TEKLA_CATALOGUE_ROLES[file]) failAudit();
584
+ if (exactKeys(entry, ['role', 'file', 'absent'])) { if (entry.absent !== true) failAudit(); return; }
585
+ if (!exactKeys(entry, ['role', 'file', 'origin', 'sha256', 'bytes']) || !TEKLA_CATALOGUE_ORIGINS.includes(entry.origin)
586
+ || !/^[0-9a-f]{64}$/.test(entry.sha256) || !Number.isSafeInteger(entry.bytes) || entry.bytes < 0) failAudit();
587
+ });
588
+ const absent = value.provenance.filter((entry) => entry.absent).map((entry) => entry.file);
589
+ if (sources.length !== absent.length) failAudit();
590
+ sources.forEach((source, index) => {
591
+ if (!exactKeys(source, ['role', 'file', 'state', 'affects', 'affectedObjects']) || source.file !== absent[index]
592
+ || source.role !== TEKLA_CATALOGUE_ROLES[source.file] || source.state !== 'absent'
593
+ || !Array.isArray(source.affects) || !source.affects.length || source.affects.some((domain) => typeof domain !== 'string')
594
+ || !Number.isSafeInteger(source.affectedObjects) || source.affectedObjects < 0) failAudit();
595
+ });
596
+ }
542
597
  const ids = new Set(); const affected = new Set();
543
598
  for (const finding of value.findings) {
544
599
  if (!exactKeys(finding, ['issueId', 'entityId', 'objectGuid', 'objectKind', 'check', 'code', 'group', 'hasGeometry', 'evidence'])
@@ -547,7 +602,7 @@ function validateTeklaAuditDocument(value, manifest, auditReceipt, snapshotEntit
547
602
  || typeof finding.objectGuid !== 'string' || !/^[0-9a-f-]{36}$/.test(finding.objectGuid)
548
603
  || typeof finding.objectKind !== 'string' || typeof finding.check !== 'string'
549
604
  || typeof finding.code !== 'string' || !Object.hasOwn(TEKLA_AUDIT_COPY, finding.code)
550
- || TEKLA_AUDIT_COPY[finding.code].group !== finding.group || typeof finding.hasGeometry !== 'boolean'
605
+ || typeof finding.hasGeometry !== 'boolean' || auditCopyFor(finding).group !== finding.group
551
606
  || !finding.evidence || typeof finding.evidence !== 'object' || Array.isArray(finding.evidence)
552
607
  || JSON.stringify(finding.evidence).length > 4096) failAudit();
553
608
  ids.add(finding.issueId); affected.add(finding.entityId);
@@ -570,7 +625,9 @@ function selectAuditFinding(finding) {
570
625
  }
571
626
 
572
627
  function renderTeklaAudit() {
573
- const host = $('teklaAuditHost'); if (!host || !isTeklaParser) return;
628
+ // Held, not looked up: once the Audit tab is shown in the main window's panel frame, $() cannot find
629
+ // it, and a lookup here silently stopped every repaint after the first (a selected row never lit up).
630
+ const host = teklaAuditHost; if (!host || !isTeklaParser) return;
574
631
  host.replaceChildren();
575
632
  if (!teklaAudit) { const empty = document.createElement('div'); empty.className = 'tekla-audit-state'; empty.textContent = 'Import audit is not loaded.'; host.append(empty); return; }
576
633
  if (teklaAudit.legacy) {
@@ -589,6 +646,32 @@ function renderTeklaAudit() {
589
646
  note.textContent = `${omissions.description}: ${omissions.staleOrphanUdaAssignments} UDA assignments and ${omissions.staleOrphanAssemblyDefinitions} assembly definitions. These records are not selectable model objects.`;
590
647
  summary.append(note);
591
648
  }
649
+ const missingSources = teklaAudit.sources ?? [];
650
+ let sourcesSection = null;
651
+ if (missingSources.length) {
652
+ // #1836: the files this read went without come first; every object they affect is listed below.
653
+ sourcesSection = document.createElement('section'); sourcesSection.className = 'tekla-audit-summary tekla-audit-sources';
654
+ sourcesSection.setAttribute('aria-label', 'Missing source files');
655
+ const state = document.createElement('div'); state.className = 'tekla-audit-state';
656
+ const heading = document.createElement('strong'); heading.textContent = 'Missing source files';
657
+ const intro = document.createElement('span'); intro.textContent = 'These files were not in the copied model. Read the model again with them to clear these findings and the ones they cause below.';
658
+ state.append(heading, intro); sourcesSection.append(state);
659
+ const missingFiles = new Set(missingSources.map((source) => source.file));
660
+ for (const source of missingSources) {
661
+ const copy = TEKLA_MISSING_SOURCE_COPY[source.file];
662
+ const item = document.createElement('article'); item.className = 'tekla-audit-inspector-item';
663
+ const name = document.createElement('strong'); name.textContent = source.file;
664
+ const effect = document.createElement('p'); effect.textContent = `Affects: ${copy?.affects ?? 'model detail'}. ${copy?.objects(source.affectedObjects, missingFiles) ?? ''}`.trim();
665
+ item.append(name, effect); sourcesSection.append(item);
666
+ }
667
+ }
668
+ // #1836: catalogue files the installed-environment fallback took from this computer, not from the model.
669
+ const borrowed = (teklaAudit.provenance ?? []).filter((entry) => entry.origin === 'installed-environment').map((entry) => entry.file);
670
+ if (borrowed.length) {
671
+ const note = document.createElement('p'); note.className = 'tekla-audit-omissions';
672
+ note.textContent = `${borrowed.join(', ')} ${borrowed.length === 1 ? 'was' : 'were'} not in the model, so FloLess used ${borrowed.length === 1 ? 'the copy' : 'the copies'} in the model’s Tekla environment on this computer.`;
673
+ summary.append(note);
674
+ }
592
675
  const filters = document.createElement('div'); filters.className = 'tekla-audit-filters'; filters.setAttribute('role', 'group'); filters.setAttribute('aria-label', 'Filter import findings');
593
676
  const filterSpecs = [
594
677
  ['all', 'All'], ['not-shown', 'Not shown'], ['fit-not-confirmed', 'Fit not confirmed'], ['shape-not-evaluated', 'Shape detail not evaluated'],
@@ -600,13 +683,13 @@ function renderTeklaAudit() {
600
683
  const visible = teklaAudit.findings.filter((finding) => active === 'all' || finding.group === active);
601
684
  if (!visible.length) { const empty = document.createElement('div'); empty.className = 'tekla-audit-empty'; empty.textContent = 'No findings in this group.'; list.append(empty); return; }
602
685
  for (const finding of visible) {
603
- const copy = TEKLA_AUDIT_COPY[finding.code]; const entity = entityById.get(finding.entityId);
686
+ const copy = auditCopyFor(finding); const entity = entityById.get(finding.entityId);
604
687
  const button = document.createElement('button'); button.type = 'button'; button.className = 'tekla-audit-row'; button.setAttribute('role', 'option');
605
688
  button.setAttribute('aria-selected', String(selectedId === finding.entityId)); button.dataset.issueId = finding.issueId;
606
- const heading = document.createElement('strong'); heading.textContent = copy.title;
689
+ const heading = document.createElement('strong'); heading.textContent = copy?.title ?? 'Import finding';
607
690
  const name = document.createElement('span'); name.textContent = entity?.name || entity?.typeName || finding.entityId;
608
691
  const location = document.createElement('span'); location.className = finding.hasGeometry ? 'tekla-audit-location' : 'tekla-audit-location missing'; location.textContent = finding.hasGeometry ? 'Shown in 3D' : 'No 3D location';
609
- button.dataset.commandId = 'tekla-parser.audit-finding'; button.dataset.commandInstanceLabel = `${copy.title}: ${name.textContent}`;
692
+ button.dataset.commandId = 'tekla-parser.audit-finding'; button.dataset.commandInstanceLabel = `${copy?.title ?? 'Import finding'}: ${name.textContent}`;
610
693
  button.append(heading, name, location); button.addEventListener('click', () => { try { selectAuditFinding(finding); window.__instructor?.notifyChanged(); } catch (error) { toast(error.message); } }); list.append(button);
611
694
  }
612
695
  };
@@ -623,7 +706,7 @@ function renderTeklaAudit() {
623
706
  else if (event.key === 'Home') next = rows[0]; else if (event.key === 'End') next = rows.at(-1);
624
707
  if (next) { event.preventDefault(); next.focus(); }
625
708
  });
626
- paintRows(); host.append(summary, filters, list);
709
+ paintRows(); host.append(...(sourcesSection ? [sourcesSection] : []), summary, filters, list);
627
710
  }
628
711
 
629
712
  function updateSelectionActions() {
@@ -1031,11 +1114,36 @@ function wireToolbar() {
1031
1114
  return { destroy() { clipButton?.removeEventListener('click', cancelArmedClip, true); release?.(); lightingChrome.destroy(); chrome.destroy(); } };
1032
1115
  }
1033
1116
 
1117
+ /**
1118
+ * #1849: a degraded Tekla read can have nothing drawable. The model still opens: the explorer, the
1119
+ * Properties panel and the Audit list every object. The viewport says so instead of looking broken,
1120
+ * without a scrim, and lets clicks through to the grid and view tools underneath.
1121
+ */
1122
+ // The status overlay as shipped (spinner + "Opening verified model"), so a later load can put it back.
1123
+ let loadedNothingDrawn = null;
1124
+ const loadingStateTemplate = document.getElementById('loadingState')?.cloneNode(true) ?? null;
1125
+ function restoreLoadingState(host) {
1126
+ if (!loadingStateTemplate || !host.classList.contains('viewport-state-notice')) return;
1127
+ host.replaceChildren(...[...loadingStateTemplate.cloneNode(true).childNodes]);
1128
+ host.className = loadingStateTemplate.className; host.removeAttribute('role'); delete host.dataset.state;
1129
+ }
1130
+
1131
+ function renderTeklaNothingDrawnState(host, objectCount, gridDrawn) {
1132
+ const count = Number(objectCount) || 0;
1133
+ renderRevitNoModelState(host, {
1134
+ // A structural grid is drawn from its own record, so it can still show when no object can (#1849).
1135
+ kind: 'nothing-drawn', title: gridDrawn ? 'Only the grid could be drawn' : 'Nothing in this model could be drawn',
1136
+ body: `Tekla Parser read ${count.toLocaleString()} ${count === 1 ? 'object' : 'objects'}, but ${gridDrawn ? 'apart from the grid, none' : 'none'} of them could be drawn in 3D. This copy was read with some files missing, so it cannot be approved. Open the Audit tab in the left panel to see the missing files and the objects they affect.`,
1137
+ });
1138
+ host.classList.add('viewport-state-notice');
1139
+ }
1140
+
1034
1141
  async function loadRevision(state, authority, spatialCandidate) {
1035
1142
  revisionLoadController?.abort();
1036
1143
  const controller = new AbortController(); revisionLoadController = controller;
1037
1144
  const token = ++revisionLoadToken;
1038
1145
  const handle = state[authority]; if (!handle) throw new Error(`No ${authority} model revision is available.`);
1146
+ restoreLoadingState($('loadingState'));
1039
1147
  $('loadingState').style.display = 'flex';
1040
1148
  try {
1041
1149
  const base = `/api/editor/model/${encodeURIComponent(state.projectUuid)}/${encodeURIComponent(handle.revisionId)}`;
@@ -1049,13 +1157,17 @@ async function loadRevision(state, authority, spatialCandidate) {
1049
1157
  const propertyReceipt = receipt(manifest, 'properties-000000', 'aware-package:properties-000000');
1050
1158
  const relationshipReceipt = receipt(manifest, 'relationships-000000', 'aware-package:relationships-000000');
1051
1159
  const auditReceipt = manifest.schema === 'floless.model-cas-manifest/v3' ? receipt(manifest, 'tekla-audit-000000', 'floless.tekla-import-audit/v1') : null;
1052
- const tileId = manifest.tiles.ids[0];
1053
- const tileReceipt = manifest.receipts.find((item) => item.kind === 'tile' && item.digest === tileId);
1054
- if (!entityReceipt || !propertyReceipt || !relationshipReceipt || !tileId || !tileReceipt
1160
+ // A degraded Tekla read with nothing drawable is signed with NO geometry tile (#1849). Only that one
1161
+ // package shape may have none; a Revit model and every other Tekla snapshot still need their tile.
1162
+ const nothingDrawn = isTeklaParser && manifest.schema === 'floless.model-cas-manifest/v3' && manifest.tiles.ids.length === 0
1163
+ && !manifest.receipts.some((item) => item.kind === 'tile');
1164
+ const tileId = nothingDrawn ? null : manifest.tiles.ids[0];
1165
+ const tileReceipt = nothingDrawn ? null : manifest.receipts.find((item) => item.kind === 'tile' && item.digest === tileId);
1166
+ if (!entityReceipt || !propertyReceipt || !relationshipReceipt || (!nothingDrawn && (!tileId || !tileReceipt))
1055
1167
  || (isTeklaParser && manifest.schema === 'floless.model-cas-manifest/v3' && (!auditReceipt || auditReceipt.digest !== manifest.audit?.digest))) throw new Error('The verified snapshot package is incomplete.');
1056
1168
  preflightModelJsonReceipt(entityReceipt); preflightModelJsonReceipt(propertyReceipt); preflightModelJsonReceipt(relationshipReceipt);
1057
1169
  if (auditReceipt) preflightModelJsonReceipt(auditReceipt);
1058
- const aggregateBytes = entityReceipt.bytes + propertyReceipt.bytes + relationshipReceipt.bytes + tileReceipt.bytes + (auditReceipt?.bytes ?? 0);
1170
+ const aggregateBytes = entityReceipt.bytes + propertyReceipt.bytes + relationshipReceipt.bytes + (tileReceipt?.bytes ?? 0) + (auditReceipt?.bytes ?? 0);
1059
1171
  if (!Number.isSafeInteger(aggregateBytes) || aggregateBytes > MODEL_VIEWER_MAX_AGGREGATE_BYTES) throw new Error('This model exceeds the bounded viewer package limit.');
1060
1172
  // Read large artifacts sequentially so their authenticated byte buffers are released before the
1061
1173
  // next download starts. The parsed rows remain, but four simultaneous 100+ MiB buffers do not.
@@ -1063,11 +1175,12 @@ async function loadRevision(state, authority, spatialCandidate) {
1063
1175
  const propertyArtifact = await readModelJsonArtifact({ url: `${base}/entities/${propertyReceipt.digest}`, receipt: propertyReceipt, rowKey: 'properties', signal: controller.signal });
1064
1176
  const relationshipArtifact = await readModelJsonArtifact({ url: `${base}/entities/${relationshipReceipt.digest}`, receipt: relationshipReceipt, rowKey: 'relationships', signal: controller.signal });
1065
1177
  const auditArtifact = auditReceipt ? await readModelJsonDocument({ url: `${base}/entities/${auditReceipt.digest}`, receipt: auditReceipt, signal: controller.signal }) : null;
1066
- const tile = await readModelBinaryArtifact({ url: `${base}/tiles/${tileId}`, receipt: tileReceipt, maxBytes: MODEL_VIEWER_MAX_TILE_BYTES, signal: controller.signal });
1178
+ const tile = nothingDrawn ? null : await readModelBinaryArtifact({ url: `${base}/tiles/${tileId}`, receipt: tileReceipt, maxBytes: MODEL_VIEWER_MAX_TILE_BYTES, signal: controller.signal });
1067
1179
  if (token !== revisionLoadToken) return false;
1068
1180
  const nextEntities = entityArtifact.rows; const nextProperties = propertyArtifact.rows; const nextRelationships = relationshipArtifact.rows;
1069
1181
  const nextAudit = auditArtifact ? validateTeklaAuditDocument(auditArtifact.document, manifest, auditReceipt, nextEntities) : (isTeklaParser ? { legacy: true } : null);
1070
1182
  assertModelViewerRowBudget(nextEntities, nextProperties, nextRelationships);
1183
+ if (nothingDrawn && nextEntities.some((entity) => (entity.geometry || []).length)) throw new Error('The verified snapshot package is incomplete.');
1071
1184
  const nextEntityById = new Map(nextEntities.map((entity) => [entity.id, entity]));
1072
1185
  const nextPropertyByEntity = new Map();
1073
1186
  for (const item of nextProperties) { const values = nextPropertyByEntity.get(item.entityId) || []; values.push(item); nextPropertyByEntity.set(item.entityId, values); }
@@ -1087,6 +1200,9 @@ async function loadRevision(state, authority, spatialCandidate) {
1087
1200
  if (token !== revisionLoadToken) return false;
1088
1201
  commitSpatialForRevision(spatialCandidate);
1089
1202
  teklaAudit = null; selectedId = null; selectedIds = []; geometrySelectionIds = [];
1203
+ // The viewport shows this revision from here, so its notice is this revision's even if a later step
1204
+ // of the switch fails.
1205
+ loadedNothingDrawn = nothingDrawn ? { count: nextEntities.length, gridDrawn: !!nextStructuralGrid } : null;
1090
1206
  loadedRevisionId = handle.revisionId; loadedSourceDigest = handle.sourceSha256;
1091
1207
  entities = nextEntities; properties = nextProperties; relationships = nextRelationships; entityById = nextEntityById; propertyByEntity = nextPropertyByEntity; teklaAudit = nextAudit;
1092
1208
  teklaAssemblyMembers = isTeklaParser ? teklaAssemblyMembership(nextRelationships) : new Map();
@@ -1102,11 +1218,16 @@ async function loadRevision(state, authority, spatialCandidate) {
1102
1218
  inspect(null, true, false, 'tree');
1103
1219
  renderTeklaAudit();
1104
1220
  modelPanelBridge?.ready(handle.revisionId);
1105
- $('loadingState').style.display = 'none';
1221
+ if (loadedNothingDrawn) renderTeklaNothingDrawnState($('loadingState'), loadedNothingDrawn.count, loadedNothingDrawn.gridDrawn);
1222
+ else $('loadingState').style.display = 'none';
1106
1223
  return true;
1107
1224
  } catch (error) {
1108
1225
  if (token !== revisionLoadToken) return false;
1109
- if (viewport?.isReady?.()) $('loadingState').style.display = 'none';
1226
+ // A failed switch keeps the last good revision on screen, and with it that revision's own notice.
1227
+ if (viewport?.isReady?.()) {
1228
+ if (loadedNothingDrawn) renderTeklaNothingDrawnState($('loadingState'), loadedNothingDrawn.count, loadedNothingDrawn.gridDrawn);
1229
+ else $('loadingState').style.display = 'none';
1230
+ }
1110
1231
  throw error;
1111
1232
  }
1112
1233
  }