@floless/app 0.134.1 → 0.134.2

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.
@@ -6,6 +6,12 @@
6
6
  */
7
7
 
8
8
  import { validateSchemaSubset } from './json-schema-subset.js';
9
+ /**
10
+ * Validate ONE value against a schema node — the same subset interpreter, re-exported so a caller can ask
11
+ * the schema about a single row instead of restating its rules in JavaScript. Pass a node that carries
12
+ * `$defs` (e.g. `{...schema.$defs.dim3, $defs: schema.$defs}`) so local `$ref`s still resolve.
13
+ */
14
+ export { validateSchemaSubset };
9
15
  import { axisLabelsFor, parseSpacings } from './grid-core.js';
10
16
  import { positionBasisIssue,POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
11
17
  export const POSITION_BASIS_CLIENT_VALIDATION_VERSION=POSITION_BASIS_CAPABILITY_VERSION;
@@ -429,19 +429,26 @@
429
429
  * `openProject` assigns it and sits earlier in the file — a `let` further down works only as long as
430
430
  * nothing calls that function during module init, which is not a property worth depending on.
431
431
  *
432
- * Unknown fails closed. Approval and export capability must come from the lifecycle response, never
433
- * from a successful presence request or stale state carried from another project.
432
+ * Unknown still fails closed for actions that require a model. It is not, however, presented as a
433
+ * confirmed stage lock: a project-open probe is routine loading, not evidence that the project is
434
+ * still preliminary.
434
435
  */
435
436
  let projectContractLifecycle = 'unknown';
436
437
  let exportsHasModel = false;
437
438
  // A project may open on Model/Exports/History while its lifecycle probe is still in flight. Keep
438
- // that requested destination only until the probe settles; an explicit tab click cancels it.
439
+ // the most recently requested destination until the probe settles so the latest click counts.
439
440
  let pendingPresenceStep = null;
441
+ // Dismiss handle for the one user-initiated checking toast. A later tab click replaces it rather
442
+ // than stacking another copy while both clicks attach to the same lifecycle request.
443
+ let pendingPresenceToast = null;
440
444
 
441
445
  /** Sequence number for model-presence probes. A project-id check is NOT a staleness guard: two
442
446
  * probes can be in flight for the SAME project, and an older "absent" answer landing last would
443
447
  * re-disable Approve on a project that now has a model. Every writer bumps it; older results drop. */
444
448
  let modelPresenceGen = 0;
449
+ // One lifecycle request per open project. Tab clicks attach to this promise instead of starting
450
+ // competing four-second probes whose generation guards make all but the last answer disappear.
451
+ let modelPresenceProbe = null;
445
452
 
446
453
  /** The header's AUTHORED tooltip, captured from the static markup so the has-a-model state restores
447
454
  * it verbatim. The first cut substituted "exports unlock after it", which is a FALSE description of
@@ -1690,7 +1697,10 @@
1690
1697
  projectContractLifecycle = 'unknown';
1691
1698
  exportsHasModel = false;
1692
1699
  modelPresenceGen++;
1700
+ modelPresenceProbe = null;
1693
1701
  pendingPresenceStep = null;
1702
+ if (pendingPresenceToast) pendingPresenceToast();
1703
+ pendingPresenceToast = null;
1694
1704
  exportState = null;
1695
1705
  hostReadinessStates = {};
1696
1706
  renderReadinessState = null;
@@ -1720,6 +1730,13 @@
1720
1730
  renderStepTabs(); // paint the tab labels for THIS app before the first step shows
1721
1731
  frames.model.src = 'about:blank'; frames.drawings.src = 'about:blank'; // reset any previous project
1722
1732
  frames.model.dataset.loaded = ''; frames.drawings.dataset.loaded = '';
1733
+ // Start the small lifecycle envelope BEFORE the heavier approval review request. Both hit the
1734
+ // same localhost event loop; sending approval first could keep the lifecycle request queued until
1735
+ // its four-second client deadline, falsely leaving an existing model in the checking state. This
1736
+ // promise also owns every tab activation until it settles (refreshModelPresence deduplicates it).
1737
+ refreshModelPresence(p.id, p.app).catch((e) => {
1738
+ console.error('[workspaces] could not resolve model presence', e);
1739
+ });
1723
1740
  // BEFORE the first step renders, and that order is the fix rather than a tidy-up.
1724
1741
  //
1725
1742
  // `initialStep` is not always 'model' — a project re-opened from the picker keeps `currentStep`,
@@ -1739,12 +1756,6 @@
1739
1756
  setStep(pendingPresenceStep ? 'drawings' : initialStep);
1740
1757
  applyMode();
1741
1758
  syncWorkspaceGuide(); // point the shared beacon at THIS project's document lifecycle
1742
- // Detached, but never silent: the lifecycle probe cannot reject, yet the code after its await can
1743
- // (stepLabel -> wsApp on a descriptor without steps), and an unhandled rejection would leave the
1744
- // header un-updated with nothing said.
1745
- refreshModelPresence(p.id, p.app).catch((e) => { // gate the header CHECK Approve for THIS project (#490)
1746
- console.error('[workspaces] could not resolve model presence', e);
1747
- });
1748
1759
  }
1749
1760
 
1750
1761
  /**
@@ -1758,18 +1769,43 @@
1758
1769
  * person who needs it — and `approveProject` re-checks the same flag rather than trusting the
1759
1770
  * attribute.
1760
1771
  */
1761
- async function refreshModelPresence(projectId, appId) {
1772
+ async function refreshModelPresence(projectId, appId, supersede = false) {
1773
+ // A caller may attach to a probe that a model-creating mutation supersedes a moment later. Follow
1774
+ // same-project successors until one actually applies, so that caller cannot mistake the stale
1775
+ // probe's completion for an authoritative timeout and show a false retry warning.
1776
+ const awaitAuthoritative = async (initialPromise) => {
1777
+ let observed = initialPromise;
1778
+ let applied = await observed;
1779
+ while (!applied) {
1780
+ const successor = modelPresenceProbe;
1781
+ if (!successor || successor.projectId !== projectId || successor.promise === observed) return false;
1782
+ observed = successor.promise;
1783
+ applied = await observed;
1784
+ }
1785
+ return true;
1786
+ };
1787
+ if (!supersede && modelPresenceProbe?.projectId === projectId) {
1788
+ return awaitAuthoritative(modelPresenceProbe.promise);
1789
+ }
1762
1790
  const gen = ++modelPresenceGen;
1763
- const present = await projectContractState(projectId, appId);
1764
- if (gen !== modelPresenceGen || !current || current.id !== projectId) return; // superseded
1765
- const restore = pendingPresenceStep?.projectId === projectId ? pendingPresenceStep.step : '';
1766
- // A timeout/network error is not evidence that this project has no model. Keep the requested
1767
- // destination so activating the locked tab can retry the probe and restore it after recovery.
1768
- if (present !== 'unknown') pendingPresenceStep = null;
1769
- applyModelPresence(present);
1770
- // `unknown` deliberately fails closed and may have redirected the requested destination to the
1771
- // Drawing Filter. Restore it only when this same project's authoritative answer says a model exists.
1772
- if (present === 'model' && restore && currentStep === 'drawings') setStep(restore);
1791
+ const promise = (async () => {
1792
+ const present = await projectContractState(projectId, appId);
1793
+ if (gen !== modelPresenceGen || !current || current.id !== projectId) return false; // superseded
1794
+ const restore = pendingPresenceStep?.projectId === projectId ? pendingPresenceStep.step : '';
1795
+ // A timeout/network error is not evidence that this project has no model. Keep the requested
1796
+ // destination so its next activation can retry the probe and restore it after recovery.
1797
+ if (present !== 'unknown') pendingPresenceStep = null;
1798
+ applyModelPresence(present);
1799
+ // Restore only when this same project's authoritative answer says a model exists. A confirmed
1800
+ // preliminary lifecycle remains on Drawing Filter and gets the real prerequisite gate below.
1801
+ if (present === 'model' && restore && currentStep === 'drawings') setStep(restore);
1802
+ return true;
1803
+ })();
1804
+ modelPresenceProbe = { projectId, promise };
1805
+ try { return await awaitAuthoritative(promise); }
1806
+ finally {
1807
+ if (modelPresenceProbe?.promise === promise) modelPresenceProbe = null;
1808
+ }
1773
1809
  }
1774
1810
 
1775
1811
  /** Push the answer to the flag AND the header together, so no two surfaces can disagree. */
@@ -1803,7 +1839,9 @@
1803
1839
  // was already per-project, the two variables behind it were not.)
1804
1840
  // Reset with the rest of the per-project state — this file resets `histDiffSupported` for exactly
1805
1841
  // this reason. Bumping the generation also voids any probe still in flight for the closing project.
1806
- projectContractLifecycle = 'unknown'; exportsHasModel = false; modelPresenceGen++; pendingPresenceStep = null;
1842
+ projectContractLifecycle = 'unknown'; exportsHasModel = false; modelPresenceGen++; modelPresenceProbe = null; pendingPresenceStep = null;
1843
+ if (pendingPresenceToast) pendingPresenceToast();
1844
+ pendingPresenceToast = null;
1807
1845
  closeProjMenu(); applyMode(); syncWorkspaceGuide(); // revision state cleared by resetRevisionState() above
1808
1846
  }
1809
1847
  document.getElementById('ws-back').addEventListener('click', closeProject);
@@ -1843,7 +1881,9 @@
1843
1881
  return `${revCardReq?.clearWhy || 'FloLess cannot safely release this drawing read yet.'} Open Requests for the available recovery.`;
1844
1882
  }
1845
1883
  if (unavailableInitial) return 'This drawing read uses a status this version of FloLess does not recognize. Open Requests for details and update FloLess before continuing.';
1846
- if (projectContractLifecycle === 'unknown') return 'Checking which project stages are ready. Select this tab again to retry if the check does not finish.';
1884
+ // Loading is not a prerequisite failure. setStep keeps the safety boundary by queueing later
1885
+ // stages until this probe produces a real lifecycle answer.
1886
+ if (projectContractLifecycle === 'unknown') return '';
1847
1887
  if (step === 'model') {
1848
1888
  if (waitingForInitial && revCardReq?.filterSaved) return 'The Drawing Filter is saved. Return to the same terminal AI session that prepared it and tell it to continue the drawing read.';
1849
1889
  if (waitingForInitial && revCardReq?.prepassReady) return 'Review the selected lines, then press Save filter. After Save, return to the terminal AI that prepared it and tell it to continue.';
@@ -1921,8 +1961,6 @@
1921
1961
  : `The drawing read failed · ${revCardReq?.clearWhy || 'FloLess cannot safely release this drawing read yet.'} Open Requests for the available recovery.`)
1922
1962
  : unavailableInitial
1923
1963
  ? 'This drawing read uses a status this version of FloLess does not recognize · Open Requests for details and update FloLess before continuing.'
1924
- : projectContractLifecycle === 'unknown'
1925
- ? 'Checking which project stages are ready… You can keep working in Drawing Filter. Select Model, Exports, or History to retry the check.'
1926
1964
  : waitingForInitial && revCardReq?.filterSaved
1927
1965
  ? 'Stage 1 of 4 complete · The Drawing Filter is saved. Return to the same terminal AI session that prepared it and tell it to continue the drawing read. Model, Exports, and History unlock when it finishes.'
1928
1966
  : waitingForInitial && revCardReq?.prepassReady
@@ -1934,7 +1972,45 @@
1934
1972
  : 'Start in Drawing Filter by attaching a PDF or image. The Model, Exports, and History stages unlock after the first steel model is created.';
1935
1973
  }
1936
1974
 
1975
+ function deferStageUntilLifecycle(s) {
1976
+ const d = wsApp();
1977
+ if (!current || !d?.filter || projectContractLifecycle !== 'unknown'
1978
+ || !['model', 'exports', 'history'].includes(s)) return false;
1979
+ pendingPresenceStep = { projectId: current.id, step: s };
1980
+ const projectId = current.id;
1981
+ if (pendingPresenceToast) pendingPresenceToast();
1982
+ const intentToast = showToast(`Checking project stages… ${stepLabel(s)} will open when ready.`, 'info');
1983
+ pendingPresenceToast = intentToast;
1984
+ refreshModelPresence(projectId, current.app).then(() => {
1985
+ // A later click owns the shared probe's feedback and destination.
1986
+ if (pendingPresenceToast !== intentToast) return;
1987
+ intentToast();
1988
+ pendingPresenceToast = null;
1989
+ // The request's four-second deadline is a recovery boundary, not a silent discarded click.
1990
+ if (current?.id !== projectId) return;
1991
+ if (projectContractLifecycle === 'unknown') {
1992
+ showToast(`Couldn’t check project stages. Select ${stepLabel(s)} again to retry.`, 'warn');
1993
+ return;
1994
+ }
1995
+ // A confirmed preliminary answer turns the apparent availability into the real prerequisite
1996
+ // gate. Reuse that specific explanation instead of replacing it with generic readiness copy.
1997
+ const reason = stageGateFor(s);
1998
+ if (reason) showToast(reason, 'warn');
1999
+ }).catch((err) => {
2000
+ if (pendingPresenceToast === intentToast) {
2001
+ intentToast();
2002
+ pendingPresenceToast = null;
2003
+ }
2004
+ console.error('[workspaces] tab lifecycle check failed', err);
2005
+ });
2006
+ return true;
2007
+ }
2008
+
1937
2009
  function setStep(s) {
2010
+ // Keep the tab visually available while the routine open-project check runs, but do not cross
2011
+ // the model boundary speculatively. The existing request is reused and this destination opens
2012
+ // automatically if it reports a model; the most recent click wins.
2013
+ if (deferStageUntilLifecycle(s)) return;
1938
2014
  const lockedReason = stageGateFor(s);
1939
2015
  if (lockedReason) {
1940
2016
  if (currentStep !== 'drawings') setStep('drawings');
@@ -1986,17 +2062,10 @@
1986
2062
  if (b?.getAttribute('aria-disabled') === 'true') {
1987
2063
  e.preventDefault();
1988
2064
  const reason = stageGateFor(b.dataset.step);
1989
- if (projectContractLifecycle === 'unknown' && current) {
1990
- pendingPresenceStep = { projectId: current.id, step: b.dataset.step };
1991
- refreshModelPresence(current.id, current.app).catch((err) => console.error('[workspaces] could not retry model presence', err));
1992
- }
1993
2065
  if (reason) showToast(reason, 'warn');
1994
2066
  return;
1995
2067
  }
1996
- if (b) {
1997
- pendingPresenceStep = null;
1998
- setStep(b.dataset.step);
1999
- }
2068
+ if (b) setStep(b.dataset.step);
2000
2069
  });
2001
2070
 
2002
2071
  // ── Approve (per-project) ───────────────────────────────────────────────────
@@ -5815,7 +5884,13 @@
5815
5884
  // pane — which on the drop-a-drawing flow is Drawings, neither of them. Without this the header
5816
5885
  // stays gated, telling the user to read a drawing they just finished reading. (approveProject
5817
5886
  // re-probes so the ACTION is never blocked; this stops the chrome lying in the meantime.)
5818
- refreshModelPresence(proj.id, proj.app).catch(() => { /* header stays as-is */ });
5887
+ // The read may have CREATED the first model. Do not attach this refresh to the older
5888
+ // pre-read lifecycle request: that answer describes the checkpoint before the mutation and
5889
+ // could re-lock the tabs after the model exists. Superseding bumps the generation so the old
5890
+ // answer is ignored and this post-mutation request becomes authoritative.
5891
+ refreshModelPresence(proj.id, proj.app, true).catch((e) => {
5892
+ console.error('[workspaces] post-read model presence did not refresh', e);
5893
+ });
5819
5894
  // AND the approval state, which model presence alone no longer covers. Before "not reviewable"
5820
5895
  // was told apart from "the probe failed", an empty project sat in the ERROR state here and the
5821
5896
  // header's click-to-retry quietly repaired it on the next click. That retry is gone by design —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.134.1",
3
+ "version": "0.134.2",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {
@@ -47,6 +47,7 @@
47
47
  "verify:change-reasons": "node build/verify-change-reasons.mjs",
48
48
  "verify:contract-publication": "node build/verify-contract-publication.mjs",
49
49
  "verify:no-agent-trailer": "node build/verify-no-agent-trailer.mjs",
50
+ "verify:no-license-bypass": "node build/verify-no-license-bypass.mjs",
50
51
  "verify:app-publication": "node build/verify-app-publication-writers.mjs",
51
52
  "verify:guards-wired": "node build/verify-guards-wired.mjs",
52
53
  "verify:command-registry": "node build/verify-command-registry.mjs",