@floless/app 0.102.0 → 0.103.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web/app.css CHANGED
@@ -1312,6 +1312,19 @@
1312
1312
  the body between the pinned title and actions, mirroring .modal.routines. */
1313
1313
  #form-modal .modal { max-height: 86vh; display: flex; flex-direction: column; }
1314
1314
  #form-modal-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
1315
+ .fm-note-label {
1316
+ margin-bottom:6px; color:var(--text-dim); font:600 10px/1.3 var(--ui);
1317
+ letter-spacing:.07em; text-transform:uppercase;
1318
+ }
1319
+ .fm-note {
1320
+ max-height:280px; margin:0; padding:10px 11px; overflow:auto; white-space:pre-wrap;
1321
+ border:1px solid var(--border-strong); border-radius:5px; background:var(--surface-2);
1322
+ color:var(--text-muted); font:500 11px/1.55 var(--mono);
1323
+ scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent;
1324
+ }
1325
+ .fm-note::-webkit-scrollbar { width:9px; height:9px; }
1326
+ .fm-note::-webkit-scrollbar-thumb { background:var(--border-strong); border-radius:5px; }
1327
+ .fm-note::-webkit-scrollbar-track { background:transparent; }
1315
1328
  .modal.library {
1316
1329
  width: 720px;
1317
1330
  max-height: 82vh;
@@ -2788,11 +2801,46 @@ body {
2788
2801
  background: color-mix(in srgb, var(--accent) 22%, transparent);
2789
2802
  border-color: var(--accent); color: var(--text);
2790
2803
  }
2804
+ .agent-card .node-action:disabled,
2805
+ .agent-card .node-action[aria-disabled="true"] {
2806
+ opacity: 0.55; cursor: not-allowed;
2807
+ background: var(--surface-2); border-color: var(--border-strong); color: var(--text-dim);
2808
+ }
2809
+ .agent-card .node-action:disabled:hover,
2810
+ .agent-card .node-action[aria-disabled="true"]:hover {
2811
+ background: var(--surface-2); border-color: var(--border-strong); color: var(--text-dim);
2812
+ }
2791
2813
  /* Hairline separator between node-action groups (view/edit vs export/write). */
2792
2814
  .agent-card .node-action-sep {
2793
2815
  height: 0; margin: 8px 2px 0;
2794
2816
  border-top: 1px solid var(--border-strong);
2795
2817
  }
2818
+ .agent-card .node-action-state {
2819
+ display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-top:6px;
2820
+ color:var(--text-dim); font:500 10px/1.4 var(--ui);
2821
+ }
2822
+ .agent-card .node-action-state.ready { color:var(--ok); }
2823
+ .agent-card .node-action-state.blocked { color:var(--warn); }
2824
+ .agent-card .node-action-state .rtn-spinner { width:9px; height:9px; flex:none; }
2825
+ .agent-card .node-action-recovery {
2826
+ padding:2px 6px; border-radius:4px; cursor:pointer;
2827
+ background:transparent; border:1px solid var(--border-strong); color:var(--text-muted);
2828
+ font:500 10px/1.3 var(--ui);
2829
+ }
2830
+ .agent-card .node-action-recovery:hover {
2831
+ color:var(--text); border-color:var(--accent-dim); background:var(--surface-2);
2832
+ }
2833
+ .agent-card .node-export-receipt {
2834
+ display:flex; align-items:center; gap:6px; flex-wrap:wrap;
2835
+ margin-top:5px; color:var(--ok); font:500 10px/1.4 var(--mono);
2836
+ }
2837
+ .agent-card .node-export-receipt.partial { color:var(--warn); }
2838
+ .agent-card .node-export-details {
2839
+ padding:1px 5px; border-radius:3px; cursor:pointer;
2840
+ background:transparent; border:1px solid currentColor; color:inherit;
2841
+ font:500 9.5px/1.3 var(--ui);
2842
+ }
2843
+ .agent-card .node-export-details:hover { color:var(--text); }
2796
2844
  /* Input node: current values at a glance ("phase = 2"), so the user knows what
2797
2845
  the next run uses without opening the dialog. */
2798
2846
  .agent-card .node-inputs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
@@ -3573,7 +3621,27 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
3573
3621
  .ecard .e-fmt { font-size:10.5px; color:var(--text-dim); font-family:var(--mono); }
3574
3622
  .ecard .e-meta { font-size:11px; color:var(--text-muted); display:flex; align-items:center;
3575
3623
  justify-content:space-between; gap:8px; min-height:16px; }
3624
+ .ecard .e-meta.e-meta-tekla { align-items:flex-start; flex-direction:column; justify-content:flex-start; }
3576
3625
  .ecard .e-status { color:var(--text-dim); }
3626
+ .ecard .e-readiness { display:inline-flex; align-items:center; gap:6px; line-height:1.45; }
3627
+ .ecard .e-readiness.ready { color:var(--ok); }
3628
+ .ecard .e-readiness.blocked { color:var(--warn); }
3629
+ .ecard .e-readiness .rtn-spinner { width:10px; height:10px; flex:none; }
3630
+ .ecard .e-recovery {
3631
+ padding:3px 7px; border-radius:4px; cursor:pointer;
3632
+ background:transparent; border:1px solid var(--border-strong); color:var(--text-muted);
3633
+ font:500 10.5px/1.3 var(--ui);
3634
+ }
3635
+ .ecard .e-recovery:hover { color:var(--text); border-color:var(--accent-dim); background:var(--surface-2); }
3636
+ .ecard .e-receipt { display:flex; align-items:center; gap:7px; flex-wrap:wrap;
3637
+ color:var(--ok); font:500 10.5px/1.45 var(--mono); }
3638
+ .ecard .e-receipt.partial { color:var(--warn); }
3639
+ .ecard .e-receipt-details {
3640
+ padding:2px 6px; border-radius:4px; cursor:pointer;
3641
+ background:transparent; border:1px solid currentColor; color:inherit;
3642
+ font:500 10px/1.3 var(--ui);
3643
+ }
3644
+ .ecard .e-receipt-details:hover { color:var(--text); }
3577
3645
  .ecard .e-done .chk { color:var(--ok); } /* the ✓ */
3578
3646
  .ecard .e-done .t { color:var(--text-muted); font-family:var(--mono); } /* HH:MM — the scannable datum */
3579
3647
  .ecard .e-links { display:flex; align-items:center; gap:8px; flex:none; }
@@ -3583,8 +3651,9 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
3583
3651
  .ecard .e-act { margin-top:auto; }
3584
3652
  .ecard .e-act button { width:100%; padding:7px 10px; font-size:12px; border-radius:5px; font-family:var(--ui);
3585
3653
  background:var(--surface-2); border:1px solid var(--border-strong); color:var(--text-muted); cursor:pointer; transition:all .15s; }
3586
- .ecard .e-act button:hover:not(:disabled) { color:var(--text); border-color:var(--accent-dim); background:var(--surface); }
3587
- .ecard .e-act button:disabled { opacity:0.6; cursor:not-allowed; }
3654
+ .ecard .e-act button:hover:not(:disabled):not([aria-disabled="true"]) { color:var(--text); border-color:var(--accent-dim); background:var(--surface); }
3655
+ .ecard .e-act button:disabled,
3656
+ .ecard .e-act button[aria-disabled="true"] { opacity:0.6; cursor:not-allowed; }
3588
3657
 
3589
3658
  /* ── Workspaces ▸ History step (shell-rendered pane; the project's version ledger). Ports the
3590
3659
  mockup's table.hist into app tokens. `position:relative` anchors the rollback confirm popover. */
package/dist/web/app.js CHANGED
@@ -1612,6 +1612,17 @@ document.addEventListener('keydown', (e) => {
1612
1612
  }
1613
1613
  function hide() { anchor = null; tip.hidden = true; }
1614
1614
 
1615
+ // A delegated mouseout never fires when a repaint removes the hovered control
1616
+ // (for example, an export button changing from busy to complete). Observe DOM
1617
+ // replacement and data-tip changes so the shared box can never retain stale help.
1618
+ new MutationObserver(() => {
1619
+ if (!anchor) return;
1620
+ if (!anchor.isConnected) { hide(); return; }
1621
+ const text = anchor.getAttribute('data-tip');
1622
+ if (!text) { hide(); return; }
1623
+ if (tip.textContent !== text) { tip.textContent = text; place(); }
1624
+ }).observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['data-tip'] });
1625
+
1615
1626
  document.addEventListener('mouseover', (e) => {
1616
1627
  const el = e.target.closest('[data-tip]');
1617
1628
  if (!el || (e.relatedTarget && el.contains(e.relatedTarget))) return; // ignore moves within the same element
package/dist/web/aware.js CHANGED
@@ -47,6 +47,10 @@
47
47
  // Latest normalized app payload, keyed by id, so handlers can read mode/gate.
48
48
  const apps = new Map();
49
49
  let currentId = null;
50
+ let teklaReadinessState = null;
51
+ let teklaReadinessPromise = null;
52
+ const exportReceiptsByApp = new Map(); // appId:kind → latest reconciled receipt counts
53
+ const exportBusyByApp = new Set(); // appId:kind → one in-flight host/export mutation
50
54
 
51
55
  // Local UI-state persistence (per origin; never touches the .flo or lock).
52
56
  // The last-opened app is restored on refresh; per-app input values are saved
@@ -1405,6 +1409,241 @@
1405
1409
  card.appendChild(sep);
1406
1410
  }
1407
1411
 
1412
+ const exportReceiptKey = (appId, kind) => `${appId}:${kind}`;
1413
+
1414
+ function clearExportReceiptsForApp(appId) {
1415
+ const active = document.activeElement;
1416
+ const focusKind = active instanceof HTMLElement && active.dataset.exportApp === appId
1417
+ ? active.dataset.exportKind
1418
+ : null;
1419
+ const ifcChanged = exportReceiptsByApp.delete(exportReceiptKey(appId, 'ifc'));
1420
+ const teklaChanged = exportReceiptsByApp.delete(exportReceiptKey(appId, 'tekla'));
1421
+ if ((ifcChanged || teklaChanged) && currentId === appId) {
1422
+ markSpecialNodes();
1423
+ if (focusKind) {
1424
+ const replacement = Array.from(document.querySelectorAll('.node-action'))
1425
+ .find((button) => button.dataset.exportApp === appId && button.dataset.exportKind === focusKind);
1426
+ if (replacement instanceof HTMLElement && !replacement.matches(':disabled')) replacement.focus();
1427
+ }
1428
+ }
1429
+ }
1430
+
1431
+ function receiptItemText(prefix, value) {
1432
+ if (typeof value === 'string') return `${prefix}: ${value}`;
1433
+ if (!value || typeof value !== 'object') return `${prefix}: ${String(value)}`;
1434
+ const parts = [value.id, value.code, value.message].filter((part) => typeof part === 'string' && part.trim());
1435
+ if (parts.length) return `${prefix}: ${parts.join(' · ')}`;
1436
+ try { return `${prefix}: ${JSON.stringify(value)}`; }
1437
+ catch { return `${prefix}: detail unavailable`; }
1438
+ }
1439
+
1440
+ function exportReceiptDetails(receipt) {
1441
+ if (!receipt) return '';
1442
+ return [
1443
+ ...(Array.isArray(receipt.unsupported) ? receipt.unsupported.map((row) => receiptItemText('Unsupported', row)) : []),
1444
+ ...(Array.isArray(receipt.warnings) ? receipt.warnings.map((warning) => receiptItemText('Warning', warning)) : []),
1445
+ ].join('\n');
1446
+ }
1447
+
1448
+ function exportReceiptText(appId, kind) {
1449
+ const receipt = exportReceiptsByApp.get(exportReceiptKey(appId, kind));
1450
+ if (!receipt || !receipt.counts) return null;
1451
+ const c = receipt.counts;
1452
+ const parts = [`${Number(c.emitted) || 0} emitted`];
1453
+ if (kind === 'tekla' && Number.isFinite(Number(c.native))) parts.push(`${Number(c.native)} native`);
1454
+ if (Number(c.unsupported)) parts.push(`${Number(c.unsupported)} unsupported`);
1455
+ if (Number(c.warnings)) parts.push(`${Number(c.warnings)} warning${Number(c.warnings) === 1 ? '' : 's'}`);
1456
+ return {
1457
+ text: parts.join(' · '),
1458
+ partial: Number(c.unsupported) > 0 || Number(c.warnings) > 0,
1459
+ details: exportReceiptDetails(receipt),
1460
+ };
1461
+ }
1462
+
1463
+ function openExportReceiptDetails(appId, kind, returnFocusTo) {
1464
+ const summary = exportReceiptText(appId, kind);
1465
+ if (!summary || !summary.details) return;
1466
+ formModal({
1467
+ title: `${kind === 'tekla' ? 'Tekla' : 'IFC'} export details`,
1468
+ sub: 'Details from the last successful export in this session.',
1469
+ fields: [{ name: 'details', label: 'Receipt details', type: 'note', value: summary.details }],
1470
+ okLabel: 'Close',
1471
+ hideCancel: true,
1472
+ returnFocusTo,
1473
+ returnFocusFallback: () => Array.from(document.querySelectorAll('.node-export-details'))
1474
+ .find((button) => button.dataset.exportApp === appId && button.dataset.exportKind === kind) ||
1475
+ Array.from(document.querySelectorAll('.node-action'))
1476
+ .find((button) => button.dataset.exportApp === appId && button.dataset.exportKind === kind) || null,
1477
+ });
1478
+ }
1479
+
1480
+ function addExportReceipt(card, appId, kind) {
1481
+ const summary = exportReceiptText(appId, kind);
1482
+ if (!summary) return;
1483
+ const el = document.createElement('div');
1484
+ el.className = 'node-export-receipt' + (summary.partial ? ' partial' : '');
1485
+ const text = document.createElement('span');
1486
+ text.textContent = `Last export${summary.partial ? ' with gaps' : ''} · ${summary.text}`;
1487
+ text.setAttribute('role', 'status');
1488
+ text.setAttribute('aria-live', 'polite');
1489
+ el.appendChild(text);
1490
+ if (summary.details) {
1491
+ const details = document.createElement('button');
1492
+ details.type = 'button';
1493
+ details.className = 'node-export-details';
1494
+ details.textContent = 'View details';
1495
+ details.dataset.exportApp = appId;
1496
+ details.dataset.exportKind = kind;
1497
+ details.addEventListener('click', (event) => {
1498
+ event.stopPropagation();
1499
+ event.preventDefault();
1500
+ openExportReceiptDetails(appId, kind, details);
1501
+ });
1502
+ el.appendChild(details);
1503
+ }
1504
+ card.appendChild(el);
1505
+ }
1506
+
1507
+ function exportActionBusy(appId, kind) {
1508
+ return exportBusyByApp.has(exportReceiptKey(appId, kind));
1509
+ }
1510
+
1511
+ function setExportActionBusy(appId, kind, busy) {
1512
+ const active = document.activeElement;
1513
+ const restoreFocus = active instanceof HTMLElement &&
1514
+ active.classList.contains('node-action') &&
1515
+ active.dataset.exportApp === appId &&
1516
+ active.dataset.exportKind === kind;
1517
+ const key = exportReceiptKey(appId, kind);
1518
+ if (busy) exportBusyByApp.add(key);
1519
+ else exportBusyByApp.delete(key);
1520
+ if (currentId === appId) {
1521
+ markSpecialNodes();
1522
+ if (restoreFocus) {
1523
+ const replacement = Array.from(document.querySelectorAll('.node-action'))
1524
+ .find((button) => button.dataset.exportApp === appId && button.dataset.exportKind === kind);
1525
+ if (replacement instanceof HTMLElement && !replacement.matches(':disabled')) {
1526
+ replacement.focus();
1527
+ } else if (kind === 'tekla') {
1528
+ replacement?.closest('.agent-card')?.querySelector('.node-action-recovery')?.focus();
1529
+ }
1530
+ }
1531
+ }
1532
+ }
1533
+
1534
+ function addHostExportAction(card, appId, kind, label, busyLabel, onClick) {
1535
+ const busy = exportActionBusy(appId, kind);
1536
+ const btn = addNodeAction(card, busy ? busyLabel : label, onClick);
1537
+ btn.dataset.exportApp = appId;
1538
+ btn.dataset.exportKind = kind;
1539
+ if (busy) {
1540
+ // Keep the in-flight control focusable so the aria-busy/text change is announced. The
1541
+ // in-flight guard still makes repeated click/double-click events a no-op.
1542
+ btn.setAttribute('aria-disabled', 'true');
1543
+ btn.setAttribute('aria-busy', 'true');
1544
+ }
1545
+ return btn;
1546
+ }
1547
+
1548
+ function teklaActionState() {
1549
+ const readiness = teklaReadinessState;
1550
+ if (!readiness || readiness.state === 'checking') return {
1551
+ ready: false,
1552
+ message: 'Checking Tekla readiness…',
1553
+ className: 'checking',
1554
+ recovery: null,
1555
+ };
1556
+ if (readiness.ok && readiness.state === 'ready') {
1557
+ return {
1558
+ ready: true,
1559
+ message: readiness.host && readiness.host.version ? `Ready · Tekla ${readiness.host.version}` : 'Ready for Tekla',
1560
+ className: 'ready',
1561
+ recovery: null,
1562
+ };
1563
+ }
1564
+ return {
1565
+ ready: false,
1566
+ message: readiness.message || 'Tekla readiness could not be verified.',
1567
+ className: 'blocked',
1568
+ recovery: readiness.recovery || { action: 'retry', label: 'Check again' },
1569
+ };
1570
+ }
1571
+
1572
+ function addTeklaActionState(card) {
1573
+ const state = teklaActionState();
1574
+ const wrap = document.createElement('div');
1575
+ wrap.className = `node-action-state ${state.className}`;
1576
+ const text = document.createElement('span');
1577
+ text.setAttribute('role', 'status');
1578
+ text.setAttribute('aria-live', 'polite');
1579
+ if (state.className === 'checking') {
1580
+ const spinner = document.createElement('span');
1581
+ spinner.className = 'rtn-spinner';
1582
+ spinner.setAttribute('aria-hidden', 'true');
1583
+ wrap.appendChild(spinner);
1584
+ }
1585
+ text.textContent = state.message;
1586
+ wrap.appendChild(text);
1587
+ if (state.recovery) {
1588
+ const btn = document.createElement('button');
1589
+ btn.type = 'button';
1590
+ btn.className = 'node-action-recovery';
1591
+ btn.textContent = ['open-tekla', 'open-model', 'retry'].includes(state.recovery.action)
1592
+ ? 'Check again'
1593
+ : state.recovery.label;
1594
+ btn.addEventListener('click', (event) => {
1595
+ event.stopPropagation();
1596
+ event.preventDefault();
1597
+ recoverTeklaReadiness(state.recovery.action);
1598
+ });
1599
+ wrap.appendChild(btn);
1600
+ }
1601
+ card.appendChild(wrap);
1602
+ return state;
1603
+ }
1604
+
1605
+ async function refreshTeklaReadiness(force = false) {
1606
+ if (teklaReadinessPromise) return teklaReadinessPromise;
1607
+ if (!force && teklaReadinessState && teklaReadinessState.state !== 'checking') return teklaReadinessState;
1608
+ teklaReadinessState = { ok: false, state: 'checking' };
1609
+ teklaReadinessPromise = api('/api/tekla-readiness')
1610
+ .then((result) => {
1611
+ teklaReadinessState = result.readiness;
1612
+ return teklaReadinessState;
1613
+ })
1614
+ .catch((error) => {
1615
+ teklaReadinessState = {
1616
+ ok: false,
1617
+ state: 'error',
1618
+ message: error && error.message ? error.message : 'Could not verify Tekla readiness.',
1619
+ recovery: { action: 'retry', label: 'Check again' },
1620
+ };
1621
+ return teklaReadinessState;
1622
+ })
1623
+ .finally(() => {
1624
+ teklaReadinessPromise = null;
1625
+ if (currentId) markSpecialNodes();
1626
+ });
1627
+ return teklaReadinessPromise;
1628
+ }
1629
+
1630
+ async function recoverTeklaReadiness(action) {
1631
+ if (action === 'update-aware') {
1632
+ await applyAwareUpdate(teklaReadinessState && teklaReadinessState.aware && teklaReadinessState.aware.floor);
1633
+ } else if (action === 'install-bridge') {
1634
+ showToast('Installing the Tekla bridge…', 'info');
1635
+ try {
1636
+ await api('/api/tekla-readiness/setup', { method: 'POST' });
1637
+ showToast('Tekla bridge installed.', 'ok');
1638
+ } catch (error) {
1639
+ showToast(error && error.message ? error.message : 'Could not install the Tekla bridge.', 'warn');
1640
+ }
1641
+ }
1642
+ teklaReadinessState = { ok: false, state: 'checking' };
1643
+ markSpecialNodes();
1644
+ await refreshTeklaReadiness(true);
1645
+ }
1646
+
1408
1647
  // Show the input node's current values inline ("phase = 2"), so the user sees
1409
1648
  // what the next run will use without opening the dialog. Reads live
1410
1649
  // appInputValues (declared defaults + any saved/overridden value); refreshed on
@@ -1448,6 +1687,7 @@
1448
1687
  const rebakeInput = app && app.rebakeInput ? app.rebakeInput : null;
1449
1688
  const cards = document.querySelectorAll('.agent-card');
1450
1689
  const firstId = cards.length ? cards[0].dataset.agentId : null;
1690
+ let hasTeklaAction = false;
1451
1691
  cards.forEach((card) => {
1452
1692
  const id = card.dataset.agentId;
1453
1693
  const isReport = !!rid && id === rid;
@@ -1457,7 +1697,7 @@
1457
1697
  card.classList.toggle('input-node', isInput);
1458
1698
  card.classList.toggle('rebake-node', isRebake);
1459
1699
  // clear anything we injected last render, so re-renders never stack
1460
- card.querySelectorAll('.node-action, .node-inputs').forEach((b) => b.remove());
1700
+ card.querySelectorAll('.node-action, .node-action-sep, .node-action-state, .node-export-receipt, .node-inputs').forEach((b) => b.remove());
1461
1701
  if (isInput) addNodeInputs(card); // current values, above the button
1462
1702
  if (isReport) {
1463
1703
  const rNode = app && app.nodes.find((n) => n.id === rid);
@@ -1478,7 +1718,8 @@
1478
1718
  addNodeAction(card, 'View 3D ▸', () => openLocalViewer(currentId, contractType));
1479
1719
  // A reconstructed model's MEMBER geometry exports to IFC through the same companion as
1480
1720
  // steel (extruded bodies are view-only for now — the server says so if there's nothing).
1481
- addNodeAction(card, 'Export IFC ▸', () => exportContractIfc(currentId, true)); // isVector → "unplaced" skip wording
1721
+ addHostExportAction(card, currentId, 'ifc', 'Export IFC ▸', 'Exporting IFC…', () => exportContractIfc(currentId, true)); // isVector → "unplaced" skip wording
1722
+ addExportReceipt(card, currentId, 'ifc');
1482
1723
  }
1483
1724
  // The 3D/IFC/BOM/Tekla chain derives a scene from the contract — only contract types that
1484
1725
  // declare `scene` support it (a drawing.vector node would 4xx on these endpoints).
@@ -1486,11 +1727,21 @@
1486
1727
  addNodeAction(card, 'View 3D ▸', () => exportContract3d(currentId));
1487
1728
  // Export/write group — visually separated from the look-and-read actions above.
1488
1729
  addNodeActionDivider(card);
1489
- addNodeAction(card, 'Export IFC ▸', () => exportContractIfc(currentId));
1730
+ addHostExportAction(card, currentId, 'ifc', 'Export IFC ▸', 'Exporting IFC…', () => exportContractIfc(currentId));
1731
+ addExportReceipt(card, currentId, 'ifc');
1490
1732
  addNodeAction(card, 'Export BOM (CSV) ▸', () => exportContractBom(currentId, 'csv'));
1491
1733
  addNodeAction(card, 'Export BOM (Excel) ▸', () => exportContractBom(currentId, 'xlsx'));
1492
- const teklaBtn = addNodeAction(card, 'Send to Tekla ▸', () => exportContractTekla(currentId));
1493
- teklaBtn.dataset.tip = 'Tekla must be open with a model loaded. Click to create native parts in it.';
1734
+ const teklaBtn = addHostExportAction(card, currentId, 'tekla', 'Send to Tekla ▸', 'Sending to Tekla…', () => exportContractTekla(currentId));
1735
+ hasTeklaAction = true;
1736
+ const teklaState = addTeklaActionState(card);
1737
+ const teklaBusy = exportActionBusy(currentId, 'tekla');
1738
+ teklaBtn.disabled = !teklaBusy && !teklaState.ready;
1739
+ teklaBtn.dataset.tip = teklaBusy
1740
+ ? 'Sending the approved model to Tekla'
1741
+ : teklaState.ready
1742
+ ? 'Create native parts in the open Tekla model'
1743
+ : teklaState.message;
1744
+ addExportReceipt(card, currentId, 'tekla');
1494
1745
  }
1495
1746
  card.dataset.tip = 'Double-click to open the contract editor';
1496
1747
  }
@@ -1500,6 +1751,7 @@
1500
1751
  if (!card.dataset.tip) card.dataset.tip = 'Double-click to open the steel filter';
1501
1752
  }
1502
1753
  });
1754
+ if (hasTeklaAction && !teklaReadinessState) refreshTeklaReadiness();
1503
1755
  }
1504
1756
 
1505
1757
  // B3 "swap re-bakes": pick a new source drawing for a baked app and queue a
@@ -2032,12 +2284,19 @@
2032
2284
  }
2033
2285
 
2034
2286
  // Export IFC ▸ — write the approved model OUT to a universal .ifc and download it. The server
2035
- // builds a model-free ifc companion, runs it, and returns the .ifc text (res.content); the browser
2036
- // turns it into a download. api() throws on any failure (no contract, all-RFI, compile/write error).
2287
+ // invokes AWARE's IFC builtin, reconciles its exhaustive receipt, and returns the durably promoted
2288
+ // .ifc text (res.content); the browser turns it into a download. api() throws on any failure.
2037
2289
  async function exportContractIfc(appId, isVector) {
2290
+ if (exportActionBusy(appId, 'ifc')) return;
2291
+ setExportActionBusy(appId, 'ifc', true);
2038
2292
  showToast('Generating IFC…', 'info');
2039
2293
  try {
2040
2294
  const res = await api('/api/contract/' + encodeURIComponent(appId) + '/export-ifc', { method: 'POST' });
2295
+ if (res.counts) exportReceiptsByApp.set(exportReceiptKey(appId, 'ifc'), {
2296
+ counts: res.counts,
2297
+ warnings: res.warnings || [],
2298
+ unsupported: res.receipt && Array.isArray(res.receipt.unsupported) ? res.receipt.unsupported : [],
2299
+ });
2041
2300
  const blob = new Blob([res.content || ''], { type: 'application/x-step' });
2042
2301
  const url = URL.createObjectURL(blob);
2043
2302
  const a = document.createElement('a');
@@ -2051,9 +2310,18 @@
2051
2310
  const notes = [];
2052
2311
  if (dropped) notes.push(isVector ? `${dropped} unplaced` : `${dropped} RFI member${dropped === 1 ? '' : 's'}`);
2053
2312
  if (res.extrusionsSkipped) notes.push(`${res.extrusionsSkipped} extruded ${res.extrusionsSkipped === 1 ? 'body' : 'bodies'} (view-only)`);
2054
- showToast(`IFC downloaded — ${res.filename || appId + '.ifc'}${notes.length ? ' · ' + notes.join(', ') + ' skipped' : ''}`, 'ok');
2313
+ const summary = exportReceiptText(appId, 'ifc');
2314
+ showToast(summary && summary.partial
2315
+ ? `IFC exported with gaps — ${summary.text}`
2316
+ : `IFC downloaded — ${res.filename || appId + '.ifc'}${notes.length ? ' · ' + notes.join(', ') + ' skipped' : ''}`,
2317
+ summary && summary.partial ? 'warn' : 'ok');
2055
2318
  } catch (e) {
2319
+ // A receipt describes the attempt the user just made. Keeping the prior session receipt here
2320
+ // would make a failed re-export look successful, even though the durable file stays untouched.
2321
+ exportReceiptsByApp.delete(exportReceiptKey(appId, 'ifc'));
2056
2322
  showToast('IFC export failed: ' + (e && e.message ? e.message : String(e)), 'warn');
2323
+ } finally {
2324
+ setExportActionBusy(appId, 'ifc', false);
2057
2325
  }
2058
2326
  }
2059
2327
 
@@ -2095,14 +2363,31 @@
2095
2363
  // Tekla running with a model; when it's not, the server returns a clear needsTekla state (api()
2096
2364
  // throws with err.body.needsTekla) — surfaced as an informational nudge, not a hard error.
2097
2365
  async function exportContractTekla(appId) {
2366
+ if (exportActionBusy(appId, 'tekla')) return;
2367
+ setExportActionBusy(appId, 'tekla', true);
2098
2368
  showToast('Baking into Tekla…', 'info');
2099
2369
  try {
2100
2370
  const res = await api('/api/contract/' + encodeURIComponent(appId) + '/export-tekla', { method: 'POST' });
2101
- const dropped = Array.isArray(res.skipped) ? res.skipped.length : 0;
2102
- showToast((res.message || 'Baked into the Tekla model.') + (dropped ? ` · ${dropped} RFI member(s) skipped` : ''), 'ok');
2371
+ if (res.counts) exportReceiptsByApp.set(exportReceiptKey(appId, 'tekla'), {
2372
+ counts: res.counts,
2373
+ warnings: res.warnings || [],
2374
+ unsupported: res.receipt && Array.isArray(res.receipt.unsupported) ? res.receipt.unsupported : [],
2375
+ });
2376
+ const summary = exportReceiptText(appId, 'tekla');
2377
+ showToast(summary && summary.partial
2378
+ ? `Sent to Tekla with gaps — ${summary.text}`
2379
+ : (res.message || 'Baked into the Tekla model.'),
2380
+ summary && summary.partial ? 'warn' : 'ok');
2103
2381
  } catch (e) {
2382
+ // Do not leave counts from an earlier successful send attached to this failed attempt.
2383
+ exportReceiptsByApp.delete(exportReceiptKey(appId, 'tekla'));
2104
2384
  const needsTekla = e && e.body && e.body.needsTekla;
2385
+ if (e && e.body && e.body.readiness) {
2386
+ teklaReadinessState = e.body.readiness;
2387
+ }
2105
2388
  showToast(e && e.message ? e.message : String(e), needsTekla ? 'info' : 'warn');
2389
+ } finally {
2390
+ setExportActionBusy(appId, 'tekla', false);
2106
2391
  }
2107
2392
  }
2108
2393
 
@@ -2453,9 +2738,12 @@
2453
2738
  // END of setup (not here) so a synchronous setup error can't latch it shut for the whole
2454
2739
  // session; done() clears it on every close.
2455
2740
  let _formModalOpen = false;
2456
- function formModal({ title, sub = '', fields, okLabel = 'Save', danger = false }) {
2741
+ function formModal({ title, sub = '', fields, okLabel = 'Save', danger = false, hideCancel = false, returnFocusTo = null, returnFocusFallback = null }) {
2457
2742
  return new Promise((resolve) => {
2458
2743
  if (_formModalOpen) { console.warn('formModal: a modal is already open — refusing re-entry'); resolve(null); return; }
2744
+ const returnFocus = returnFocusTo instanceof HTMLElement
2745
+ ? returnFocusTo
2746
+ : document.activeElement instanceof HTMLElement ? document.activeElement : null;
2459
2747
  const $title = document.getElementById('form-modal-title');
2460
2748
  const $sub = document.getElementById('form-modal-sub');
2461
2749
  const $body = document.getElementById('form-modal-body');
@@ -2464,6 +2752,8 @@
2464
2752
  $title.textContent = title;
2465
2753
  $sub.textContent = sub || '';
2466
2754
  $sub.hidden = !sub;
2755
+ if (sub) $formModal.setAttribute('aria-describedby', 'form-modal-sub');
2756
+ else $formModal.removeAttribute('aria-describedby');
2467
2757
  $body.innerHTML = fields.map((f) => {
2468
2758
  const id = `fm-${f.name}`;
2469
2759
  const val = f.value != null ? String(f.value) : '';
@@ -2473,6 +2763,9 @@
2473
2763
  if (f.type === 'checkbox') {
2474
2764
  return `<label class="modal-check" for="${id}"><input type="checkbox" id="${id}" data-fm-check="${escapeHtml(f.name)}"${f.value ? ' checked' : ''}><span>${escapeHtml(f.label || f.name)}</span></label>`;
2475
2765
  }
2766
+ if (f.type === 'note') {
2767
+ return `<div class="modal-field"><div class="fm-note-label" id="${id}-label">${escapeHtml(f.label || f.name)}</div><pre class="fm-note" id="${id}" role="region" tabindex="0" aria-labelledby="${id}-label">${escapeHtml(val)}</pre></div>`;
2768
+ }
2476
2769
  // Read-only "what's currently loaded" context row (e.g. the source drawing already
2477
2770
  // baked into a re-bake app). Inert — a muted label + glyph + filename, not a field.
2478
2771
  if (f.type === 'current') {
@@ -2544,13 +2837,14 @@
2544
2837
  $ok.classList.toggle('danger', !!danger);
2545
2838
  $ok.classList.toggle('primary', !danger);
2546
2839
  $cancel.classList.toggle('primary', !!danger);
2840
+ $cancel.hidden = !!hideCancel;
2547
2841
  showModal($formModal);
2548
2842
  // Prefer a real text input; else a file drop zone (so keyboard users land somewhere
2549
2843
  // actionable rather than a possibly-disabled OK button).
2550
2844
  const first = $body.querySelector('input:not(.fm-file-input),textarea')
2551
2845
  || $body.querySelector('.fm-files .fm-drop, .fm-file .fm-drop, .fm-images .fm-drop');
2552
2846
  if (first) { first.focus(); if (first.select) first.select(); }
2553
- else if (danger) $cancel.focus();
2847
+ else if (danger && !hideCancel) $cancel.focus();
2554
2848
  else $ok.focus();
2555
2849
  // OK-gate probes: required consent checks (below) AND required multi-file fields must be
2556
2850
  // satisfied. Declared here so the fm-files setup can re-run the gate; wired after all setups.
@@ -2860,7 +3154,12 @@
2860
3154
  modalClosed = true;
2861
3155
  hideModal($formModal);
2862
3156
  $ok.onclick = null; $cancel.onclick = null; $formModal.onclick = null; $formModal.onkeydown = null; $body.onpaste = null; $body.onclick = null; $body.ondragover = null; $body.ondrop = null;
2863
- $ok.classList.remove('danger'); $ok.classList.add('primary'); $cancel.classList.remove('primary'); $ok.disabled = false; // reset chrome for the next caller
3157
+ $ok.classList.remove('danger'); $ok.classList.add('primary'); $cancel.classList.remove('primary'); $cancel.hidden = false; $ok.disabled = false; // reset chrome for the next caller
3158
+ let focusTarget = returnFocus;
3159
+ if ((!focusTarget || !focusTarget.isConnected) && typeof returnFocusFallback === 'function') {
3160
+ focusTarget = returnFocusFallback();
3161
+ }
3162
+ if (focusTarget instanceof HTMLElement && focusTarget.isConnected && !focusTarget.matches(':disabled,[aria-disabled="true"]')) focusTarget.focus();
2864
3163
  resolve(result);
2865
3164
  };
2866
3165
  $ok.onclick = () => done(collect());
@@ -2871,6 +3170,18 @@
2871
3170
  // commits only for a normal form (never a danger confirm; never inside a textarea).
2872
3171
  $formModal.onkeydown = (e) => {
2873
3172
  if (e.key === 'Escape') { e.preventDefault(); done(null); }
3173
+ else if (e.key === 'Tab') {
3174
+ const focusable = Array.from($formModal.querySelectorAll('button:not([disabled]):not([hidden]), input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'))
3175
+ .filter((el) => el instanceof HTMLElement && !el.hidden && el.getClientRects().length);
3176
+ if (!focusable.length) { e.preventDefault(); return; }
3177
+ const firstFocusable = focusable[0];
3178
+ const lastFocusable = focusable[focusable.length - 1];
3179
+ if (e.shiftKey && (document.activeElement === firstFocusable || !$formModal.contains(document.activeElement))) {
3180
+ e.preventDefault(); lastFocusable.focus();
3181
+ } else if (!e.shiftKey && (document.activeElement === lastFocusable || !$formModal.contains(document.activeElement))) {
3182
+ e.preventDefault(); firstFocusable.focus();
3183
+ }
3184
+ }
2874
3185
  else if (e.key === 'Enter' && !danger && e.target.tagName !== 'TEXTAREA' && !$ok.disabled) { e.preventDefault(); done(collect()); }
2875
3186
  };
2876
3187
  // Setup succeeded and the modal is shown — mark it open now. Setting it here (not
@@ -4587,6 +4898,10 @@
4587
4898
  // (installing only) → dim ticker; `status`/`reason` drive the card state.
4588
4899
  if (m.line != null) setBootstrapLogLine(m.line);
4589
4900
  if (m.status) updateBootstrap({ status: m.status, reason: m.reason ?? null, remediation: m.remediation ?? null });
4901
+ } else if (m.type === 'contract-changed' && typeof m.appId === 'string' && !m.project) {
4902
+ // A receipt belongs to the exact scene that was exported. Once its contract changes, remove
4903
+ // the session summary immediately so an earlier model cannot masquerade as the current one.
4904
+ clearExportReceiptsForApp(m.appId);
4590
4905
  } else if (m.type === 'trace' && m.id === currentId) {
4591
4906
  pushTrace(m.event);
4592
4907
  if (state.currentTab === 'execution') renderInspect();
@@ -518,7 +518,7 @@
518
518
  <!-- Reusable styled prompt/form modal — used for node inputs (double-click an
519
519
  input node) and Tweak. Replaces native window.prompt so dialogs match the
520
520
  app's style and scale. Fields are injected into #form-modal-body. -->
521
- <div class="modal-backdrop" id="form-modal">
521
+ <div class="modal-backdrop" id="form-modal" role="dialog" aria-modal="true" aria-labelledby="form-modal-title">
522
522
  <div class="modal">
523
523
  <div class="modal-title" id="form-modal-title">Edit</div>
524
524
  <div class="modal-sub" id="form-modal-sub"></div>