@floless/app 0.155.2 → 0.157.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 (64) hide show
  1. package/cli-actions.mjs +392 -0
  2. package/dist/floless-server.cjs +182734 -141519
  3. package/dist/schemas/drawing-check.profile.v1.schema.json +15 -2
  4. package/dist/schemas/steel.model.v2.schema.json +25 -1
  5. package/dist/skills/floless-app-actions/SKILL.md +199 -0
  6. package/dist/skills/floless-app-approval/SKILL.md +8 -5
  7. package/dist/skills/floless-app-bridge/SKILL.md +12 -9
  8. package/dist/skills/floless-app-knowledge/SKILL.md +50 -14
  9. package/dist/skills/floless-app-new-workflow/SKILL.md +26 -10
  10. package/dist/skills/floless-app-onboarding/SKILL.md +31 -1
  11. package/dist/skills/floless-app-onboarding/references/aware-runtime.md +4 -4
  12. package/dist/skills/floless-app-queue/SKILL.md +10 -6
  13. package/dist/skills/floless-app-report-issue/SKILL.md +15 -12
  14. package/dist/skills/floless-app-rfi/SKILL.md +98 -73
  15. package/dist/skills/floless-app-routines/SKILL.md +27 -15
  16. package/dist/skills/floless-app-routines/references/routines-api.md +8 -2
  17. package/dist/skills/floless-app-steel-model/SKILL.md +1 -1
  18. package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +4 -2
  19. package/dist/skills/floless-app-tweak-contract/SKILL.md +25 -5
  20. package/dist/skills/floless-app-workflows/SKILL.md +50 -13
  21. package/dist/skills/floless-app-workflows/references/agent-steps.md +119 -0
  22. package/dist/web/agent-steps.js +1750 -0
  23. package/dist/web/agents.js +33 -8
  24. package/dist/web/app.css +681 -4
  25. package/dist/web/app.js +111 -11
  26. package/dist/web/aware-update-client.js +1 -0
  27. package/dist/web/aware.js +1257 -202
  28. package/dist/web/chat-landing-scene.js +372 -0
  29. package/dist/web/chat.css +254 -1
  30. package/dist/web/chat.js +2657 -87
  31. package/dist/web/commands-drawing-check.js +17 -0
  32. package/dist/web/commands-shell.js +1108 -4
  33. package/dist/web/commands-steel.js +6 -0
  34. package/dist/web/connections.js +1 -0
  35. package/dist/web/drawing-check-editor.html +33 -5
  36. package/dist/web/drawing-check-editor.js +538 -22
  37. package/dist/web/drawing-check-overlay.js +13 -0
  38. package/dist/web/flo-avatar.js +28 -3
  39. package/dist/web/guide.js +7 -2
  40. package/dist/web/index.html +171 -7
  41. package/dist/web/instructor.js +6 -4
  42. package/dist/web/leave-guard.js +4 -2
  43. package/dist/web/left-pane.js +8 -3
  44. package/dist/web/model-revit-module.js +15 -0
  45. package/dist/web/model-view-query.js +12 -2
  46. package/dist/web/model-viewport-revit-adapter.js +3 -1
  47. package/dist/web/pages.js +891 -36
  48. package/dist/web/panels.js +8 -5
  49. package/dist/web/parser-setup-recovery.js +12 -4
  50. package/dist/web/project-access.js +549 -0
  51. package/dist/web/project-reconciliation.js +357 -0
  52. package/dist/web/report-files.js +50 -0
  53. package/dist/web/revit-editor.js +116 -27
  54. package/dist/web/startup-admission.js +132 -0
  55. package/dist/web/steel-3d-core.js +9 -0
  56. package/dist/web/steel-editor.html +642 -22
  57. package/dist/web/steel-model-v2-commands.js +63 -5
  58. package/dist/web/step-rename.js +287 -0
  59. package/dist/web/terminal-requests.js +590 -0
  60. package/dist/web/tool-updates.js +148 -13
  61. package/dist/web/workspace-root-management.js +39 -0
  62. package/dist/web/workspaces.js +1879 -74
  63. package/launch.mjs +82 -2
  64. package/package.json +3 -1
@@ -7,7 +7,7 @@ import {
7
7
  } from './model-editor-revit-adapter.js';
8
8
  import {
9
9
  buildRevitClassificationTree, filterRevitPropertyGroups, groupRevitProperties,
10
- renderRevitNoModelState, revitExplorerTabs, revitInitialAuthority, revitNoModelCopy, revitPropertyEncodingLabel,
10
+ modelFailureCopy, renderRevitNoModelState, revitExplorerTabs, revitInitialAuthority, revitNoModelCopy, revitPropertyEncodingLabel,
11
11
  teklaNoSnapshotCopy,
12
12
  } from './model-revit-module.js';
13
13
  import { createRevitViewport } from './model-viewport-revit-adapter.js';
@@ -76,6 +76,9 @@ let editorStateDirtyGeneration = 0;
76
76
  let editorStateSavedGeneration = 0;
77
77
  let editorStateSaveQueue = Promise.resolve();
78
78
  let editorStateDirtyPayload = null;
79
+ let editorStateAccessWarned = null; // the access-refusal sentence already shown for the opened model (#2361)
80
+ // The hidden grid elevations last saved or restored, as JSON; null while a revision loads (nothing is saved then).
81
+ let gridVisibilitySignature = null;
79
82
  let projectContract = null;
80
83
  let teklaAudit = null;
81
84
  let sharedTools = null;
@@ -201,8 +204,16 @@ function modelUnavailableCopy() {
201
204
  ? 'This verified Tekla snapshot could not be opened. Open Source to check the read, then choose the Tekla source again if needed.'
202
205
  : 'This verified Revit snapshot could not be opened. Open Source to check the import, then choose the Revit file again if needed.';
203
206
  }
204
- function fail() { const state = $('loadingState'); state.replaceChildren(); const strong = document.createElement('strong'); strong.textContent = 'Model unavailable'; const copy = document.createElement('span'); copy.textContent = modelUnavailableCopy(); state.append(strong, copy); }
205
- async function json(url, options) { const response = await fetch(url, { credentials: 'same-origin', ...options }); const value = await response.json().catch(() => ({})); if (!response.ok || value.ok === false) throw new Error(value.message || value.error || `Request failed (${response.status})`); return value; }
207
+ // `failure` is the server's own sentence for what went wrong (modelFailureCopy), shown instead of the snapshot copy.
208
+ function fail(failure = null) {
209
+ const state = $('loadingState');
210
+ // A boot that stopped before reading the project would leave the header saying it is still loading.
211
+ if ($('modelName').textContent === 'Loading model…') $('modelName').textContent = 'Model unavailable';
212
+ if (failure) { $('editorRoot').dataset.modelState = 'empty'; renderRevitNoModelState(state, failure); return; }
213
+ state.replaceChildren(); const strong = document.createElement('strong'); strong.textContent = 'Model unavailable'; const copy = document.createElement('span'); copy.textContent = modelUnavailableCopy(); state.append(strong, copy);
214
+ }
215
+ // Any answer that is not ok rides on the error (`status`, `body`), so a failure can say what the server wrote for a person.
216
+ async function json(url, options) { const response = await fetch(url, { credentials: 'same-origin', ...options }); const value = await response.json().catch(() => ({})); if (!response.ok || value.ok === false) throw Object.assign(new Error(value.message || value.error || `Request failed (${response.status})`), { status: response.status, body: value }); return value; }
206
217
 
207
218
  function propertySection(heading, rows) {
208
219
  return { id: heading.toLowerCase().replace(/\W+/g, '-'), heading, editable: false, render(host) {
@@ -339,6 +350,27 @@ function auditInspectorSection(findings) {
339
350
  } };
340
351
  }
341
352
 
353
+ // A Type branch builds its rows only when it is first opened, so an object picked in 3D inside a Type nobody has opened
354
+ // has no row, and the left panel's Follow selection has nothing to reveal. Build the rows of just the Type (and subtype)
355
+ // holding the picked object. Rebuilding the whole tree would also empty every other branch already built; the left panel
356
+ // then asks for those rows again, and they arrive above the picked row after it has been scrolled to.
357
+ // A row the branch already built still lacks (past its first 500) gets that one branch built again around the object.
358
+ function followTeklaPick(id) {
359
+ const host = $('revitExplorerTypes');
360
+ const hasRow = () => [...host.querySelectorAll('[data-entity-id]')].some((row) => row.dataset.entityId === id);
361
+ if (!host || hasRow()) return false;
362
+ let scope = host, holder = null;
363
+ for (;;) {
364
+ const trigger = [...scope.querySelectorAll(':scope > .revit-tree-branch > .revit-tree-trigger')].find((item) => item.__holdsEntity?.(id));
365
+ const children = trigger?.parentElement?.querySelector(':scope > .revit-tree-children');
366
+ if (!children) break;
367
+ trigger.__populateTreeItem?.(id);
368
+ holder = trigger; scope = children;
369
+ }
370
+ if (!hasRow() && holder?.__populateTreeItem) holder.__populateTreeItem(id, true);
371
+ return hasRow() || renderExplorerSearch('type', modelSearchQueries.get('type') || '', id);
372
+ }
373
+
342
374
  function inspect(id, syncViewport = true, publish = true, origin = 'tree') {
343
375
  propertyDisplayRefresh = new Set();
344
376
  selectedId = id;
@@ -364,6 +396,8 @@ function inspect(id, syncViewport = true, publish = true, origin = 'tree') {
364
396
  classificationFollowedId = nextFollowedId;
365
397
  if (publish) modelPanelBridge?.publishSnapshot();
366
398
  }
399
+ // Every 3D pick — the plain viewport pick and the hierarchy navigator's — so the panel has the row before it is told.
400
+ if (isTeklaParser && origin === 'viewport' && selectedIds.length === 1 && followTeklaPick(selectedIds[0]) && publish) modelPanelBridge?.publishSnapshot();
367
401
  if (!id) { inspector.render({ state: 'empty', after: [chatQuestionsSection] }); if (publish) modelPanelBridge?.publishSelection(selectionOrigin); return true; }
368
402
  const entity = entityById.get(id);
369
403
  if (!entity) { inspector.render({ state: 'unavailable', message: 'This object is not in the loaded revision.', after: [chatQuestionsSection] }); if (publish) modelPanelBridge?.publishSelection(selectionOrigin); return false; }
@@ -559,7 +593,7 @@ function applyModelView(command, target) {
559
593
  if (display?.visibility === 'isolate') { facade.dispatch('model.isolate'); applied.push('isolate'); }
560
594
  if (display?.visibility === 'hide-selected') { facade.dispatch('model.hide-selected'); applied.push('hide-selected'); }
561
595
  // The toolbar's Show all also brings back hidden grid levels (its click handler, below).
562
- if (display?.visibility === 'show-all') { facade.dispatch('model.show-all'); viewport.setGridHiddenLevels([]); syncGridVisibilityAction(); applied.push('show-all'); }
596
+ if (display?.visibility === 'show-all') { facade.dispatch('model.show-all'); viewport.setGridHiddenLevels([]); syncGridVisibilityAction(); noteGridVisibilityChange(); applied.push('show-all'); }
563
597
  if (display?.ghostUnselected != null) { facade.dispatch('model.ghost-unselected.set', display.ghostUnselected); applied.push('ghost'); }
564
598
  if (display?.mode) {
565
599
  if (VIEWER_DISPLAY_MODES.includes(display.mode)) { facade.dispatch('model.display-mode.set', display.mode); applied.push('mode'); }
@@ -819,6 +853,14 @@ function renderTeklaTypes(host, values, ownProperties, memberships = teklaAssemb
819
853
  trigger.setAttribute('aria-expanded', String(open)); children.hidden = !open;
820
854
  };
821
855
  trigger.__toggleTreeItem = toggle;
856
+ // What followTeklaPick needs to open only the branch that holds a picked object (and leave every other one as it is).
857
+ let ids = null;
858
+ trigger.__holdsEntity = (id) => (ids ??= new Set(values.map((entity) => entity.id))).has(id);
859
+ // `rebuild` builds an already-built branch again, around `followed` (a row past its first 500).
860
+ trigger.__populateTreeItem = (followed, rebuild = false) => {
861
+ if (hasChildren && !rebuild) return;
862
+ children.replaceChildren(); populate(children, followed); hasChildren = true;
863
+ };
822
864
  trigger.addEventListener('model-group-select', selectGroup);
823
865
  trigger.addEventListener('click', () => {
824
866
  toggle(); selectGroup();
@@ -842,11 +884,11 @@ function renderTeklaTypes(host, values, ownProperties, memberships = teklaAssemb
842
884
  }) : allBrowsable;
843
885
  for (const group of teklaTypeGroups(browsable)) {
844
886
  const grouped = [...group.values, ...group.subtypes.flatMap((subtype) => subtype.values)];
845
- branch(host, group.label, grouped, (children) => {
846
- if (group.values.length) renderEntityList(children, group.values, ownProperties, memberships, [], followedId);
887
+ branch(host, group.label, grouped, (children, followed = followedId) => {
888
+ if (group.values.length) renderEntityList(children, group.values, ownProperties, memberships, [], followed);
847
889
  for (const subtype of group.subtypes) {
848
- const containsFollowed = subtype.values.some((entity) => entity.id === followedId);
849
- branch(children, subtype.label, subtype.values, (body) => renderEntityList(body, subtype.values, ownProperties, memberships, [], followedId),
890
+ const containsFollowed = subtype.values.some((entity) => entity.id === followed);
891
+ branch(children, subtype.label, subtype.values, (body, inner = followed) => renderEntityList(body, subtype.values, ownProperties, memberships, [], inner),
850
892
  { expanded: !!normalized, populated: !!normalized || containsFollowed });
851
893
  }
852
894
  }, { expanded: !!normalized, populated: !!normalized || grouped.some((entity) => entity.id === followedId) });
@@ -1258,7 +1300,33 @@ function editorStatePayload() {
1258
1300
  state: view.state ?? { camera: view.camera ?? null, displayMode: view.displayMode ?? 'solid' } })),
1259
1301
  coordinateFrames: value.frames.filter((frame) => frame.id !== 'global').map((frame) => ({ schemaVersion: 'floless.model-frame/v1', frameId: frame.id,
1260
1302
  originMm: frame.origin, xAxis: frame.xAxis, yAxis: frame.yAxis, zAxis: frame.zAxis })),
1261
- sections: { clips: value.clips, workArea: value.workArea } };
1303
+ sections: { clips: value.clips, workArea: value.workArea },
1304
+ ...gridVisibilityPayload() };
1305
+ }
1306
+
1307
+ // The grid elevations turned off, saved with the model's view state so it opens with them still off. A model with no
1308
+ // grid sends nothing, which leaves whatever was saved as it was.
1309
+ function gridVisibilityPayload() {
1310
+ const levels = viewport?.gridLevels?.() || [];
1311
+ return levels.length ? { gridVisibility: { hiddenLevelsMm: [...new Set(levels.filter((level) => !level.visible).map((level) => level.mm))] } } : {};
1312
+ }
1313
+
1314
+ function restoreGridVisibility(state) {
1315
+ const hidden = state?.gridVisibility?.hiddenLevelsMm;
1316
+ const restored = Array.isArray(hidden) && (viewport?.gridLevels?.() || []).length > 0;
1317
+ if (restored) { viewport.setGridHiddenLevels(hidden.filter((mm) => typeof mm === 'number' && Number.isFinite(mm))); syncGridVisibilityAction(); }
1318
+ gridVisibilitySignature = JSON.stringify(gridVisibilityPayload().gridVisibility ?? null);
1319
+ return restored;
1320
+ }
1321
+
1322
+ // Saves the grid elevations whenever the set shown changes, whatever changed it: a left-panel switch, the toolbar or
1323
+ // AI Chat Show all, or anything else that resets the grid. Nothing is saved while a revision is still loading.
1324
+ function noteGridVisibilityChange() {
1325
+ if (gridVisibilitySignature === null) return false;
1326
+ const signature = JSON.stringify(gridVisibilityPayload().gridVisibility ?? null);
1327
+ if (signature === gridVisibilitySignature) return false;
1328
+ gridVisibilitySignature = signature; scheduleEditorStateSave('grid-visibility');
1329
+ return true;
1262
1330
  }
1263
1331
 
1264
1332
  function editorStateUrl(binding) {
@@ -1271,7 +1339,8 @@ function readEditorStateRecovery(binding, etag) {
1271
1339
 
1272
1340
  function retainEditorStateRecovery() {
1273
1341
  if (!editorStateBinding || !editorStateDirtyPayload || editorStateSavedGeneration >= editorStateDirtyGeneration) return;
1274
- const owned = { namedViews: editorStateDirtyPayload.namedViews, coordinateFrames: editorStateDirtyPayload.coordinateFrames, sections: editorStateDirtyPayload.sections };
1342
+ const owned = { namedViews: editorStateDirtyPayload.namedViews, coordinateFrames: editorStateDirtyPayload.coordinateFrames, sections: editorStateDirtyPayload.sections,
1343
+ ...(editorStateDirtyPayload.gridVisibility ? { gridVisibility: editorStateDirtyPayload.gridVisibility } : {}) };
1275
1344
  editorStateRecovery.retain(editorStateBinding, editorStateEtag, owned);
1276
1345
  }
1277
1346
 
@@ -1293,12 +1362,14 @@ async function putEditorState({ binding, token, payload, etag }) {
1293
1362
  const fresh = await fetch(editorStateUrl(binding), { credentials: 'same-origin' });
1294
1363
  if (!fresh.ok) throw new Error(`Editor state conflict reload failed (${fresh.status})`);
1295
1364
  const freshValue = await fresh.json(); const freshPayload = payloadOnly(freshValue.state) || {};
1296
- sentPayload = { ...freshPayload, namedViews: payload.namedViews, coordinateFrames: payload.coordinateFrames, sections: payload.sections };
1365
+ sentPayload = { ...freshPayload, namedViews: payload.namedViews, coordinateFrames: payload.coordinateFrames, sections: payload.sections,
1366
+ ...(payload.gridVisibility ? { gridVisibility: payload.gridVisibility } : {}) };
1297
1367
  response = await request(sentPayload, fresh.headers.get('etag') || freshValue.state?.etag || null);
1298
1368
  }
1299
1369
  const value = await response.json().catch(() => ({}));
1300
- if (!response.ok || value.ok === false) throw new Error(value.message || value.error || `Editor state save failed (${response.status})`);
1370
+ if (!response.ok || value.ok === false) throw Object.assign(new Error(value.message || value.error || `Editor state save failed (${response.status})`), { code: value.error });
1301
1371
  if (token !== editorStateBindingToken) return;
1372
+ editorStateAccessWarned = null;
1302
1373
  editorStateEtag = response.headers.get('etag') || value.state?.etag || editorStateEtag;
1303
1374
  editorStateLoaded = payloadOnly(value.state) || sentPayload;
1304
1375
  }
@@ -1319,11 +1390,26 @@ function drainEditorStateSaves() {
1319
1390
  return editorStateSaveQueue;
1320
1391
  }
1321
1392
 
1393
+ // #2361: view-only access refuses every save. Say so once per opened model and reason, not on every change. The last
1394
+ // change is kept in this browser (retainEditorStateRecovery) and retried on the next open, best-effort, so the copy
1395
+ // promises nothing. `state-access-unconfirmed` is the server failing to confirm access for this save at all.
1396
+ const editorStateAccessRefused = (error) => error?.code === 'model_module_unavailable' || error?.code === 'state-access-unconfirmed';
1397
+ function reportEditorStateSaveError(error, fallback) {
1398
+ const refused = editorStateAccessRefused(error);
1399
+ if (refused) { if (editorStateAccessWarned === error.message) return; editorStateAccessWarned = error.message; }
1400
+ toast(error?.message || fallback, refused ? 8000 : undefined);
1401
+ }
1402
+
1322
1403
  async function flushEditorStateSave() {
1323
1404
  clearTimeout(editorStateSaveTimer); editorStateSaveTimer = null;
1324
1405
  if (editorStateDirtyGeneration > editorStateSavedGeneration) await Promise.race([
1325
- drainEditorStateSaves(),
1326
- new Promise((_, reject) => setTimeout(() => reject(new Error('Saving this model view timed out. Try again before switching models.')), 8_000)),
1406
+ // A save refused for view-only access must not stop the switch: in view-only access nothing here is being saved.
1407
+ drainEditorStateSaves().catch((error) => { if (!editorStateAccessRefused(error)) throw error; reportEditorStateSaveError(error); }),
1408
+ // Each save first refreshes model access with the server (#2361): on a stalled network that alone may take the
1409
+ // server's DESKTOP_ACCESS_EXPECTED_MS (45 s), so the switch waits that long plus the write before giving up.
1410
+ // ponytail: covers ONE refresh. A retry queued behind a failed one on a stalled network can outlast it; the switch
1411
+ // then asks to try again, which works once the server answers. Budget the queued attempts if that becomes common.
1412
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Saving this model view timed out. Try again before switching models.')), 50_000)),
1327
1413
  ]);
1328
1414
  }
1329
1415
 
@@ -1332,7 +1418,7 @@ function scheduleEditorStateSave(reason) {
1332
1418
  editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration += 1;
1333
1419
  retainEditorStateRecovery();
1334
1420
  clearTimeout(editorStateSaveTimer);
1335
- editorStateSaveTimer = setTimeout(() => { editorStateSaveTimer = null; drainEditorStateSaves().catch((error) => toast(error.message || 'Could not save model view state.')); }, 350);
1421
+ editorStateSaveTimer = setTimeout(() => { editorStateSaveTimer = null; drainEditorStateSaves().catch((error) => reportEditorStateSaveError(error, 'Could not save model view state.')); }, 350);
1336
1422
  }
1337
1423
 
1338
1424
  async function prepareSpatialForRevision(state, handle) {
@@ -1374,7 +1460,9 @@ async function prepareSpatialForRevision(state, handle) {
1374
1460
  function commitSpatialForRevision(candidate) {
1375
1461
  editorStateBindingToken += 1; clearTimeout(editorStateSaveTimer); editorStateSaveTimer = null;
1376
1462
  editorStateBinding = candidate.binding; editorStateEtag = candidate.etag; editorStateLoaded = candidate.loaded;
1377
- editorStateDirtyPayload = null; editorStateDirtyGeneration = 0; editorStateSavedGeneration = 0;
1463
+ editorStateDirtyPayload = null; editorStateDirtyGeneration = 0; editorStateSavedGeneration = 0; editorStateAccessWarned = null;
1464
+ // The grid elevations last turned off go back first, before the recovery branch below captures what to save.
1465
+ restoreGridVisibility(candidate.loaded);
1378
1466
  clipList?.destroy(); clipList = null; releaseClipEditor?.(); releaseClipEditor = null; releaseClipViewport?.(); releaseClipViewport = null; clipSession?.dispose(); clipSession = null;
1379
1467
  spatialPanel?.destroy(); spatialPanel = null; releaseSpatialViewport?.(); releaseSpatialViewport = null; spatialTools?.dispose(); spatialTools = null;
1380
1468
  spatialTools = candidate.tools; clipSession = candidate.clip; candidate.committed = true;
@@ -1389,7 +1477,7 @@ function commitSpatialForRevision(candidate) {
1389
1477
  spatialPanel = mountModelSpatialPanel({ tools: spatialTools, trigger: $('modelFrameStatus'), onBeforeOpen: () => { closeSpatialDialog(); toolbarChrome?.closeMenus(); selectionFilterChrome?.close(); lightingPanel?.close({ restoreFocus: false }); },
1390
1478
  lengthDisplay: { format: (mm) => formatLength(mm, displayUnitControl.units()), parse: (text) => parseLengthMm(text, displayUnitControl.units()), unitLabel: () => displayUnitControl.units() },
1391
1479
  onError: (error) => toast(error.message || 'That spatial action is unavailable.') });
1392
- if (candidate.recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) => toast(error.message || 'Could not restore model view state.')), 0); }
1480
+ if (candidate.recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) => reportEditorStateSaveError(error, 'Could not restore model view state.')), 0); }
1393
1481
  }
1394
1482
 
1395
1483
  function positionDialog(panel, anchor) {
@@ -1539,7 +1627,6 @@ function wireToolbar() {
1539
1627
  else if (control.id === 'revitFitSelection') facade.dispatch('model.fit-selection');
1540
1628
  else if (control.id === 'revitSavedViews') facade.dispatch('model.saved-views');
1541
1629
  else if (control.dataset.spatial) handleSpatialAction(control.dataset.spatial, control);
1542
- if (control.dataset.vis === 'show-all') viewport.setGridHiddenLevels([]);
1543
1630
  for (const radio of control.parentElement?.querySelectorAll('[role="menuitemradio"]') || []) radio.setAttribute('aria-checked', String(radio === control));
1544
1631
  reflectToolbarState();
1545
1632
  modelPanelBridge?.publishSnapshot();
@@ -1548,7 +1635,9 @@ function wireToolbar() {
1548
1635
  });
1549
1636
  updateSelectionActions();
1550
1637
  reflectToolbarState();
1551
- const release = facade.subscribe(() => { try { syncGridVisibilityAction(); reflectToolbarState(); } catch (_) {} });
1638
+ // A grid change made here (the toolbar Show all runs in its menu, out of reach of the listener above) also repaints the
1639
+ // left panel's elevation switches.
1640
+ const release = facade.subscribe(() => { try { syncGridVisibilityAction(); reflectToolbarState(); if (noteGridVisibilityChange()) modelPanelBridge?.publishSnapshot(); } catch (_) {} });
1552
1641
  return { closeMenus: () => chrome.closeMenus(), destroy() { document.removeEventListener('mousedown', outsideDialog, true); clipButton?.removeEventListener('click', cancelArmedClip, true); release?.(); lightingChrome.destroy(); chrome.destroy(); } };
1553
1642
  }
1554
1643
 
@@ -1635,6 +1724,7 @@ async function loadRevision(state, authority, spatialCandidate) {
1635
1724
  else renderGroupList(staged.types, 'typeName', 'No type', nextEntities, nextPropertyByEntity);
1636
1725
  if (token !== revisionLoadToken) return false;
1637
1726
  const nextStructuralGrid = isTeklaParser ? findTeklaStructuralGrid(nextEntities) : null;
1727
+ gridVisibilitySignature = null;
1638
1728
  await viewport.load(tile, owners, { schema: manifest.schema, providerKind: manifest.provider.kind, geometryToRenderMatrix: manifest.geometryToRenderMatrix }, nextStructuralGrid);
1639
1729
  if (token !== revisionLoadToken) return false;
1640
1730
  commitSpatialForRevision(spatialCandidate);
@@ -1735,7 +1825,7 @@ function mountPanels() {
1735
1825
  ? (visible ? [] : levels.map((level) => level.mm))
1736
1826
  : levels.filter((level) => String(level.key) === levelKey ? !visible : !level.visible).map((level) => level.mm);
1737
1827
  viewport.setGridHiddenLevels(hidden);
1738
- syncGridVisibilityAction(); reflectToolbarState();
1828
+ syncGridVisibilityAction(); reflectToolbarState(); noteGridVisibilityChange();
1739
1829
  return true;
1740
1830
  },
1741
1831
  panel: (tab) => tab === null || revitPanelHost.show(tab),
@@ -1956,10 +2046,6 @@ async function boot() {
1956
2046
  onSelect: (ids) => {
1957
2047
  if (selectionOriginGuard.isProgrammatic()) return;
1958
2048
  selectedIds = [...ids]; geometrySelectionIds = [...ids]; if (ids.length) clipSession?.clearSelection?.();
1959
- if (isTeklaParser && ids.length === 1) {
1960
- renderExplorerSearch('type', modelSearchQueries.get('type') || '', ids[0]);
1961
- modelPanelBridge?.publishSnapshot();
1962
- }
1963
2049
  inspect(ids.at(-1) || null, false, true, 'viewport');
1964
2050
  if (isTeklaParser) synchronizeTeklaNavigatorSelection();
1965
2051
  } });
@@ -2028,10 +2114,13 @@ installTooltips(document);
2028
2114
 
2029
2115
  boot().catch((error) => {
2030
2116
  if (terminalDisposed) return;
2031
- console.error(error);
2032
- modelPanelBridge?.failed(modelUnavailableCopy());
2117
+ const failure = modelFailureCopy(error?.body);
2118
+ // A module refusal the server explained is a state the page shows, not a fault. Anything else stays an error for
2119
+ // diagnostics: a read failure (even one with its own sentence), and a refusal that came without one, a gap in copy.
2120
+ if (failure?.refused) console.warn('[model] the server refused this model:', error.message); else console.error(error);
2121
+ modelPanelBridge?.failed(failure?.body ?? modelUnavailableCopy());
2033
2122
  // A failed session fetch, project read, or first revision load is terminal for this editor instance.
2034
2123
  // Release the provider renderer and both shared mini-renderers instead of waiting for page navigation.
2035
2124
  disposeEditor();
2036
- fail();
2125
+ fail(failure);
2037
2126
  });
@@ -0,0 +1,132 @@
1
+ /* Keep startup reads in the page until the server has recovered their stores.
2
+ * Waiting here uses no HTTP connection. The server's own barrier still authorizes every request.
3
+ */
4
+ (() => {
5
+ function createStartupAdmission(options = {}) {
6
+ const fetchHealth = options.fetch || globalThis.fetch.bind(globalThis);
7
+ const origin = options.origin || globalThis.location.origin;
8
+ const setTimer = options.setTimeout || globalThis.setTimeout.bind(globalThis);
9
+ const clearTimer = options.clearTimeout || globalThis.clearTimeout.bind(globalThis);
10
+ const probeTimeoutMs = options.probeTimeoutMs ?? 45000;
11
+ const pollDelayMs = options.pollDelayMs ?? 1000;
12
+ let generation = 0, suspended = false, disposed = false, probe = null, delay = null;
13
+ const wakeups = new Set();
14
+ const reset = () => Object.assign(new Error('Startup observation was superseded.'), { code: 'startup-observation-superseded' });
15
+ const cancelled = () => new DOMException('The read was cancelled.', 'AbortError');
16
+
17
+ function wait(promise, signal) {
18
+ if (signal?.aborted) return Promise.reject(signal.reason || cancelled());
19
+ if (!signal) return promise;
20
+ return new Promise((resolve, reject) => {
21
+ const abort = () => { cleanup(); reject(signal.reason || cancelled()); };
22
+ const cleanup = () => signal.removeEventListener('abort', abort);
23
+ signal.addEventListener('abort', abort, { once: true });
24
+ promise.then(value => { cleanup(); resolve(value); }, error => { cleanup(); reject(error); });
25
+ });
26
+ }
27
+
28
+ function wake() { for (const resume of [...wakeups]) resume(); }
29
+ function invalidate() {
30
+ generation++;
31
+ const oldProbe = probe; probe = null;
32
+ if (oldProbe) { clearTimer(oldProbe.timer); oldProbe.controller.abort(); oldProbe.reject(reset()); }
33
+ const oldDelay = delay; delay = null;
34
+ if (oldDelay) { clearTimer(oldDelay.timer); oldDelay.reject(reset()); }
35
+ wake();
36
+ }
37
+ function suspend() { suspended = true; invalidate(); }
38
+ function resume() { suspended = false; invalidate(); }
39
+ function dispose() { disposed = true; suspended = false; invalidate(); }
40
+
41
+ async function active(signal) {
42
+ while (suspended) {
43
+ let resume;
44
+ try {
45
+ await wait(new Promise(resolve => {
46
+ resume = () => resolve();
47
+ wakeups.add(resume);
48
+ }), signal);
49
+ } finally { wakeups.delete(resume); }
50
+ }
51
+ if (disposed) throw cancelled();
52
+ if (signal?.aborted) throw signal.reason || cancelled();
53
+ }
54
+
55
+ function observation() {
56
+ if (probe) return probe.promise;
57
+ const owner = { generation, controller: new AbortController(), timer: null, promise: null, reject: null };
58
+ const superseded = new Promise((_, reject) => { owner.reject = reject; });
59
+ owner.timer = setTimer(() => owner.controller.abort(), probeTimeoutMs);
60
+ probe = owner;
61
+ owner.promise = Promise.race([Promise.resolve().then(async () => {
62
+ if (owner.generation !== generation) throw reset();
63
+ let response;
64
+ try { response = await fetchHealth('/api/health', { cache: 'no-store', signal: owner.controller.signal }); }
65
+ catch (cause) {
66
+ if (owner.generation !== generation) throw reset();
67
+ throw Object.assign(new Error('FloLess could not be reached. Make sure it is still running, then try again.'), { cause });
68
+ }
69
+ let body;
70
+ try { body = await response.json(); }
71
+ catch (cause) { throw Object.assign(new Error('FloLess could not check whether project recovery is finished. Try again in a moment.'), { cause }); }
72
+ if (owner.generation !== generation) throw reset();
73
+ if (!response.ok) throw Object.assign(new Error('FloLess could not be reached. Make sure it is still running, then try again.'), { status: response.status, body });
74
+ const admission = body?.startupAdmission;
75
+ if (!admission || typeof admission.ready !== 'boolean' || typeof admission.instanceId !== 'string' || !admission.instanceId
76
+ || !Array.isArray(admission.independentReadPaths) || !admission.independentReadPaths.every(path => typeof path === 'string')
77
+ || !Array.isArray(admission.independentReadPrefixes) || !admission.independentReadPrefixes.every(path => typeof path === 'string')) {
78
+ throw new Error('FloLess could not check whether project recovery is finished. Try again in a moment.');
79
+ }
80
+ return body;
81
+ }), superseded]).finally(() => {
82
+ clearTimer(owner.timer);
83
+ if (probe === owner) probe = null;
84
+ });
85
+ return owner.promise;
86
+ }
87
+
88
+ async function health({ signal } = {}) {
89
+ for (;;) {
90
+ await active(signal);
91
+ try { return await wait(observation(), signal); }
92
+ catch (error) { if (error?.code !== 'startup-observation-superseded') throw error; }
93
+ }
94
+ }
95
+
96
+ function pause() {
97
+ if (!delay) {
98
+ const owner = { timer: null, promise: null, reject: null };
99
+ owner.promise = new Promise((resolve, reject) => {
100
+ owner.reject = reject;
101
+ owner.timer = setTimer(resolve, pollDelayMs);
102
+ }).finally(() => { if (delay === owner) delay = null; });
103
+ delay = owner;
104
+ }
105
+ return delay.promise;
106
+ }
107
+
108
+ async function admit(path, { method = 'GET', signal } = {}) {
109
+ const url = new URL(path, origin);
110
+ if (url.origin !== origin || !['GET', 'HEAD'].includes(method.toUpperCase()) || !url.pathname.startsWith('/api/')) return;
111
+ const pathname = decodeURIComponent(url.pathname);
112
+ if (pathname === '/api/health') return;
113
+ for (;;) {
114
+ const body = await health({ signal });
115
+ const admission = body.startupAdmission;
116
+ if (admission.ready || admission.independentReadPaths.includes(pathname)
117
+ || admission.independentReadPrefixes.some(prefix => pathname === prefix || pathname.startsWith(`${prefix}/`))) return;
118
+ try { await wait(pause(), signal); }
119
+ catch (error) { if (error?.code !== 'startup-observation-superseded') throw error; }
120
+ }
121
+ }
122
+
123
+ return { admit, health, invalidate, suspend, resume, dispose };
124
+ }
125
+
126
+ globalThis.createStartupAdmission = createStartupAdmission;
127
+ if (typeof window !== 'undefined' && window.document) {
128
+ window.flolessStartupAdmission = createStartupAdmission();
129
+ window.addEventListener('pagehide', () => window.flolessStartupAdmission.suspend());
130
+ window.addEventListener('pageshow', event => { if (event.persisted) window.flolessStartupAdmission.resume(); });
131
+ }
132
+ })();
@@ -1063,6 +1063,15 @@ export function isUnknownElev(e) { return !!e && e.unknown === true; }
1063
1063
  export function isAssumedElev(e) { return !!e && e.assumed === true; }
1064
1064
  /** Either spelling of "nobody has confirmed this height". */
1065
1065
  export function isUnresolvedElev(e) { return isUnknownElev(e) || isAssumedElev(e); }
1066
+ /**
1067
+ * DECIDED BY THE AI in a Quick model build (#2521). Real geometry that a quick BOM counts, so it is NOT
1068
+ * unresolved (`isUnresolvedElev` stays false and the member is measured), but it is not evidence either:
1069
+ * never agreement, never an anchor, never the person's answer. Ask this wherever a decision rests on
1070
+ * whether a height is EVIDENCE.
1071
+ */
1072
+ export function isDecidedElev(e) { return !!e && !!e.decided && typeof e.decided === 'object' && typeof e.known === 'number'; }
1073
+ /** Is this height EVIDENCE: a number the drawings or the person gave? Not when unresolved or decided by the AI. */
1074
+ export function isEvidenceElev(e) { return knownZ(e) !== null && !isUnresolvedElev(e) && !isDecidedElev(e); }
1066
1075
  /** The known elevation in mm, or null when unknown/malformed. Never returns 0 for "unknown". */
1067
1076
  export function knownZ(e) { return e && typeof e.known === 'number' && Number.isFinite(e.known) ? e.known : null; }
1068
1077