@floless/app 0.134.4 → 0.135.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.
@@ -567,7 +567,7 @@
567
567
  "description": "The model grid: one grid in world millimetres, displayed on every sheet. Authoring notation uses relative X/Y spacing strings and absolute Z levels; every stored coordinate here is world millimetres.",
568
568
  "properties": {
569
569
  "on": { "type": "boolean", "description": "Grid visible (2D + 3D). Default true." },
570
- "origin": { "$ref": "#/$defs/point2", "description": "The grid origin in world millimetres." },
570
+ "origin": { "$ref": "#/$defs/point2", "description": "The grid origin in world millimetres: the point where the first x and y axes cross. REQUIRED for every registered plan view — control2_ref is mandatory for a plan to be registered at all, and every control label resolves relative to this origin, so without it that plan has no usable registration." },
571
571
  "x": { "type": "string", "description": "Relative spacings along +X, comma-separated, e.g. \"0'-0\\\", 3*25'-0\\\"\"." },
572
572
  "y": { "type": "string", "description": "Relative spacings along +Y, comma-separated." },
573
573
  "z": { "type": "string", "description": "Absolute level elevations, comma-separated." },
@@ -7,7 +7,7 @@ description: >-
7
7
  two-phase Drawing Filter process: first prepare and save the deterministic Filter, then read only the
8
8
  selected evidence into model-global members, registered plan views, observations, and revision history.
9
9
  metadata:
10
- version: 0.29.1
10
+ version: 0.30.0
11
11
  ---
12
12
 
13
13
  # Steel Takeoff — read drawings into `steel.model/v2`
@@ -119,7 +119,7 @@ The ledger must close all of these inventories:
119
119
  - building massing and coordinate frames were stated before members were interpreted;
120
120
  - every Filter layer was classified, and every human-excluded line weight and colour was classified;
121
121
  - every manifest line is either supported by an active observation or has a reviewed `lineDisposition`;
122
- - every reference marker resolves through the drawing graph to a reviewed page, or names the missing sheet;
122
+ - every `referenceCandidates` row the manifest GET publishes (never a candidate `kind` filter) resolves through the drawing graph to a reviewed page, or names the missing sheet;
123
123
  - every detail/connection marker maps to a real joint/connection, an explicit non-model disposition, or RFI;
124
124
  - every new or changed joint has a dependency review tied to the exact members, recipe, parameters, and details;
125
125
  - every built connection has measured bearing, head/nut contact, grip, bolt length, clash clearance,
@@ -139,11 +139,10 @@ The manifest GET returns derived fields you cannot compute yourself. Copy them e
139
139
  recompute, or omit them.
140
140
 
141
141
  - **`pageShards`** — one `{ pageId, candidateShardHash, candidateCount }` per manifest page. Give every
142
- page **exactly one** review: `{ pageId, kind: "whole", candidateShardHash, note }`. There is no
143
- second review per page, no `bbox`, and no `elementIds` — the server binds the page's own bounds and
144
- its whole candidate set into the shard, so echoing candidate ids proves nothing and the fields are
145
- gone. A missing page, a duplicate `pageId`, a foreign `pageId`, or a hash from another page or an
146
- older manifest blocks `visual-coverage`.
142
+ page **exactly one** review: `{ pageId, kind: "whole", candidateShardHash, note }`. No second review
143
+ per page, no `bbox`, no `elementIds` — the shard already binds the page's bounds and its whole
144
+ candidate set. A missing page, a duplicate `pageId`, a foreign `pageId`, or a hash from another page
145
+ or an older manifest blocks `visual-coverage`.
147
146
  - **`layerLineCounts`** — each `layers[]` row carries `lineCounts: { model, evidence }`, the number of
148
147
  ledger lines that layer holds on model pages and on evidence-only pages. The server recomputes both
149
148
  and `layer-census` blocks on any mismatch. A layer with non-zero counts on **both** roles means one
@@ -164,14 +163,12 @@ recompute, or omit them.
164
163
  When **`strained`** is `true`, writing one explicit row for every line would not fit: this set only
165
164
  works if observations, the wholesale shorthand and grouping between them save enough bytes. Model
166
165
  what is genuinely a member, dismiss wholesale what the Filter authorises, group the rest by shared
167
- reason — and tell the human up front if none of those will be enough. `impossible` is a sound
168
- refusal, not a complete detector: a set can pass it and still admit no proof that fits, and
169
- `strained` is the signal for exactly that case. The remaining figures are advisory and refuse
170
- nothing.
171
-
172
- `facetExclusions[]` is the thickness/colour sibling of `layers[]`, and it exists because a dismissal is
173
- now decided on a dimension with no semantic name attached — `0.2 pt` says nothing about whether it is
174
- steel, where `A-ANNO-TEXT` at least claims to. Each row is
166
+ reason — and tell the human up front if none of those will be enough. `impossible` is sound but not
167
+ complete: a set can pass it and still admit no proof that fits, which is what `strained` catches.
168
+ The remaining figures are advisory and refuse nothing.
169
+
170
+ `facetExclusions[]` is the thickness/colour sibling of `layers[]`: a dismissal decided on a dimension
171
+ with no semantic name — `0.2 pt` says nothing about whether it is steel. Each row is
175
172
  `{ dim, value, disposition, note, lineCounts }`, with the same five dispositions `layers[]` uses.
176
173
  Attest `member` or `mixed` when a band really does carry steel: that is not a failure, it is the
177
174
  mechanism, and every line failing that dimension on that value then needs its own row.
@@ -29,14 +29,31 @@
29
29
  return state;
30
30
  };
31
31
 
32
+ /**
33
+ * The stored job, as `{ transaction, operation }`.
34
+ *
35
+ * It held a bare transaction id, which meant resume() came back after a reload knowing WHICH
36
+ * job to follow but not WHAT it was — so the footer read "↑ Upgrading AWARE…" over a recovery
37
+ * until the first authoritative poll answered, and went on reading it for as long as that poll
38
+ * kept failing. A reload during a recovery is the likeliest reload there is: the marker exists
39
+ * because something was interrupted. A bare string is still accepted — it is what every
40
+ * already-running browser has in localStorage right now.
41
+ */
32
42
  const readStored = () => {
33
43
  try {
34
44
  const value = storage.getItem(STORAGE_KEY);
35
- return value && value.trim() ? value.trim() : null;
45
+ if (!value || !value.trim()) return null;
46
+ const raw = value.trim();
47
+ if (raw.charAt(0) !== '{') return { transaction: raw, operation: null };
48
+ const parsed = JSON.parse(raw);
49
+ const transaction = transactionOf(parsed);
50
+ return transaction ? { transaction, operation: OPERATIONS.has(parsed.operation) ? parsed.operation : null } : null;
36
51
  } catch { return null; }
37
52
  };
38
- const store = (transaction) => {
39
- try { storage.setItem(STORAGE_KEY, transaction); } catch { /* reload recovery unavailable */ }
53
+ const store = (transaction, operation) => {
54
+ try {
55
+ storage.setItem(STORAGE_KEY, JSON.stringify({ transaction, operation: operation || null }));
56
+ } catch { /* reload recovery unavailable */ }
40
57
  };
41
58
  const clearStored = () => {
42
59
  try { storage.removeItem(STORAGE_KEY); } catch { /* best effort */ }
@@ -77,6 +94,33 @@
77
94
  return Array.isArray(rows) ? rows.map(String) : [];
78
95
  };
79
96
 
97
+ function fallbackFailureMessage(operation) {
98
+ if (operation === 'bridge-repair') return "AWARE's installed bridges could not be refreshed.";
99
+ if (operation === 'maintenance-recovery') return 'The interrupted AWARE update could not be sorted out.';
100
+ return 'AWARE could not be upgraded.';
101
+ }
102
+
103
+ const OPERATIONS = new Set(['runtime-update', 'bridge-repair', 'maintenance-recovery']);
104
+ function parseOperation(value) {
105
+ // Absent is the legacy shape and means the historical default; present-but-unknown is a
106
+ // server this build does not understand, which is a different thing and must not be hidden.
107
+ if (value === undefined || value === null || value === '') return 'runtime-update';
108
+ if (!OPERATIONS.has(value)) {
109
+ // Coded, so poll() can report WHAT it could not describe. Without it the throw surfaced as
110
+ // `transaction-mismatch`, which names the one thing that had not gone wrong.
111
+ throw Object.assign(new Error('The AWARE updater returned an unknown operation.'),
112
+ { code: 'unknown-operation' });
113
+ }
114
+ return value;
115
+ }
116
+
117
+ /**
118
+ * The operation the CALLER is about to start — our own value, not the server's, so an
119
+ * unrecognised one is a bug in this build rather than news about the server. Nulled instead of
120
+ * thrown: a start must not be blocked by a label.
121
+ */
122
+ const intendedOperation = (value) => (OPERATIONS.has(value) ? value : null);
123
+
80
124
  function normalize(body, expectedTransaction) {
81
125
  const payload = payloadOf(body);
82
126
  const transaction = transactionOf(payload) || transactionOf(body);
@@ -90,7 +134,13 @@
90
134
  // from each status response, so a field applied only when the job was adopted would be lost
91
135
  // on the very first poll — restoring "Upgrading AWARE…" over a bridge repair, and
92
136
  // re-enabling the modal hijack for a failure the user never initiated.
93
- const operation = payload.operation === 'bridge-repair' ? 'bridge-repair' : 'runtime-update';
137
+ //
138
+ // EXHAUSTIVE, and it THROWS — it does not fall back. The old `=== 'bridge-repair' ? … :
139
+ // 'runtime-update'` coerced everything unknown into "upgrade", so the day the server gained a
140
+ // third operation an older client would have rendered a maintenance recovery as an ordinary
141
+ // AWARE upgrade — announcing work it is not doing. Same posture as the unknown-status throw
142
+ // below: a state this build cannot describe is reported, never guessed at.
143
+ const operation = parseOperation(payload.operation);
94
144
  const origin = payload.origin === 'auto' ? 'auto' : 'user';
95
145
  const base = { transaction, target, observedVersion, operation, origin };
96
146
  if (status === 'running') {
@@ -120,10 +170,7 @@
120
170
  ...base, status: 'runtime-failed',
121
171
  error: {
122
172
  code: String(error.code || payload.code || 'runtime-update-failed'),
123
- message: String(error.message || payload.message
124
- || (operation === 'bridge-repair'
125
- ? "AWARE's installed bridges could not be refreshed."
126
- : 'AWARE could not be upgraded.')),
173
+ message: String(error.message || payload.message || fallbackFailureMessage(operation)),
127
174
  },
128
175
  };
129
176
  }
@@ -145,7 +192,8 @@
145
192
  emit({
146
193
  ...state, status: state.status === 'retrying' ? 'retrying' : 'running',
147
194
  transaction, connectionMessage: error && error.name === 'AbortError'
148
- ? 'Still upgrading. Reconnecting to progress…'
195
+ // Operation-neutral: during a recovery "still upgrading" is simply false.
196
+ ? 'Still working. Reconnecting to progress…'
149
197
  : 'Connection interrupted. Reconnecting to progress…',
150
198
  });
151
199
  await wait();
@@ -182,9 +230,15 @@
182
230
  let next;
183
231
  try { next = normalize(result.body, transaction); }
184
232
  catch (error) {
185
- return emit({ status: 'runtime-failed', transaction, target: state.target, observedVersion: null,
186
- operation: state.operation || 'runtime-update', origin: state.origin || 'user',
187
- error: { code: 'transaction-mismatch', message: error.message } });
233
+ const code = (error && error.code) || 'transaction-mismatch';
234
+ // An operation this build cannot name must not be narrated as the last one it could. The
235
+ // status just reported something else entirely; keeping `state.operation` announced a
236
+ // failed interrupted-update recovery for a job that is neither.
237
+ const identity = code === 'unknown-operation'
238
+ ? {} : { operation: state.operation || 'runtime-update' };
239
+ return emit({ ...identity, status: 'runtime-failed', transaction, target: state.target,
240
+ observedVersion: null, origin: state.origin || 'user',
241
+ error: { code, message: error.message } });
188
242
  }
189
243
  emit(next);
190
244
  if (awaitingRetry && next.status === 'partial') {
@@ -195,7 +249,7 @@
195
249
  if (unchangedFailure) {
196
250
  emit({
197
251
  ...next,
198
- connectionMessage: `Waiting to retry the ${awaitingRetry.host} bridge…`,
252
+ connectionMessage: `Waiting to retry the ${awaitingRetry.host} bridge…`,
199
253
  });
200
254
  await wait();
201
255
  continue;
@@ -210,11 +264,20 @@
210
264
  return state;
211
265
  }
212
266
 
213
- async function start(target) {
267
+ async function start(target, operation) {
214
268
  generation += 1;
215
269
  const myGeneration = generation;
216
270
  const requestId = randomId();
217
- emit({ status: 'starting', transaction: null, target: target || null });
271
+ // THE IDENTITY OF THIS START, carried from the click. Without it `starting` had no operation
272
+ // at all, so every refusal below fell back to 'runtime-update': a refused RECOVERY was
273
+ // titled "Upgrade AWARE", read "AWARE could not be upgraded.", offered "Try upgrade again",
274
+ // and dropped off the attention pill entirely — leaving no route back to the one action that
275
+ // unblocks the machine. Omitted rather than defaulted when the caller names nothing, so the
276
+ // painters' own `|| awareUpgradeOperation` fallback is not shadowed by a wrong guess.
277
+ const intended = intendedOperation(operation);
278
+ const identity = { transaction: null, target: target || null };
279
+ if (intended) identity.operation = intended;
280
+ emit({ ...identity, status: 'starting' });
218
281
  let result;
219
282
  while (myGeneration === generation) {
220
283
  try {
@@ -227,38 +290,82 @@
227
290
  } catch {
228
291
  if (myGeneration !== generation) return state;
229
292
  emit({
230
- status: 'starting', transaction: null, target: target || null,
231
- connectionMessage: 'Connection interrupted. Recovering the accepted AWARE upgrade…',
293
+ ...identity, status: 'starting',
294
+ connectionMessage: 'Connection interrupted. Reconnecting to the accepted AWARE job…',
232
295
  });
233
296
  await wait();
234
297
  }
235
298
  }
236
299
  if (!result) return state;
237
300
  if (!result.response.ok) {
238
- return emit({ status: 'runtime-failed', transaction: null, target: target || null,
301
+ // Spread from `identity`, not from `state`: emit() replaces state wholesale, so a refused
302
+ // RECOVERY that reported no operation was indistinguishable from a refused upgrade — and a
303
+ // hard-coded 'runtime-update' was worse still, because it SHADOWED the painters' fallback.
304
+ return emit({ ...identity, status: 'runtime-failed', origin: 'user',
239
305
  error: { code: String(result.body.code || 'start-refused'),
240
- message: String(result.body.error || result.body.message || `AWARE upgrade was refused (HTTP ${result.response.status}).`) } });
306
+ message: String(result.body.error || result.body.message || `AWARE could not start (HTTP ${result.response.status}).`) } });
241
307
  }
242
308
  const transaction = transactionOf(result.body) || transactionOf(payloadOf(result.body));
243
309
  if (!transaction) {
244
- return emit({ status: 'runtime-failed', transaction: null, target: target || null,
310
+ return emit({ ...identity, status: 'runtime-failed', origin: 'user',
245
311
  error: { code: 'missing-transaction', message: 'The AWARE updater did not return a transaction.' } });
246
312
  }
247
313
  // Persistence deliberately precedes the first GET. A reload at any point after
248
314
  // the accepted POST resumes this exact server job instead of starting another.
249
315
  store(transaction);
250
- emit({ status: 'running', transaction, target: target || result.body.target || null,
316
+ // The 202 carries the job the server ACTUALLY started, which is not always the one the offer
317
+ // was for: a click on "Upgrade now" starts a maintenance-recovery when an interrupted update
318
+ // is outstanding. Keeping the stale offer target and defaulting the operation meant the modal
319
+ // announced "Upgrading AWARE…" for a whole poll cycle before flipping — and named the wrong
320
+ // version while it did. Server first, offer only as the fallback.
321
+ //
322
+ // CONTAINED. parseOperation throws on an operation this build cannot describe, and thrown
323
+ // here — after the POST was accepted — it escaped an uncaught `start()` call, leaving the
324
+ // modal stuck at `starting` with aria-busy set, no buttons, and a real server job running
325
+ // behind it. The transaction is already stored, so a newer build resumes it on reload.
326
+ // Read through payloadOf, exactly like the transaction two lines up. Reading `result.body`
327
+ // directly meant a nested `{ job: { … } }` 202 — the shape the transaction line already
328
+ // tolerates — silently produced the DEFAULT operation and no target: the same "announced the
329
+ // wrong job for a whole poll cycle" defect, reached through the door next to the one closed.
330
+ const accepted = payloadOf(result.body);
331
+ const acceptedTarget = accepted.target || result.body.target || target || null;
332
+ let acceptedOperation;
333
+ try {
334
+ acceptedOperation = parseOperation(accepted.operation ?? result.body.operation);
335
+ } catch {
336
+ // The transaction stays STORED. /active only reports a job while it is still running, so
337
+ // clearing here threw away the one durable handle to a job that may terminalise before
338
+ // FloLess is updated — and a build that CAN name the operation resumes it from exactly
339
+ // this id. Resuming it in THIS build is harmless: poll() reports one terminal
340
+ // `unknown-operation` and stops, which is what it says on screen.
341
+ //
342
+ // No operation claimed at all. Naming one would be a guess, and the painters' own fallback
343
+ // at least keeps the attention pill — the route back — where the user last saw it.
344
+ return emit({ status: 'runtime-failed', transaction, target: acceptedTarget, origin: 'user',
345
+ error: { code: 'unknown-operation',
346
+ message: 'AWARE started work this version of FloLess does not recognise. It is still running — update FloLess to follow it.' } });
347
+ }
348
+ // Re-stored WITH the operation now that the 202 has named it, so a reload renders the job
349
+ // that is actually running rather than the default.
350
+ store(transaction, acceptedOperation);
351
+ emit({ status: 'running', transaction, target: acceptedTarget,
352
+ operation: acceptedOperation, origin: 'user',
251
353
  stage: 'queued', completed: 0, total: 0 });
252
354
  return poll(transaction, myGeneration);
253
355
  }
254
356
 
255
357
  async function resume() {
256
- const transaction = readStored();
257
- if (!transaction) return state;
358
+ const stored = readStored();
359
+ if (!stored) return state;
360
+ const { transaction } = stored;
258
361
  generation += 1;
259
362
  const myGeneration = generation;
260
- emit({ status: 'running', transaction, target: null, stage: 'resuming',
261
- completed: 0, total: 0, connectionMessage: 'Resuming AWARE upgrade progress…' });
363
+ const resuming = { status: 'running', transaction, target: null, stage: 'resuming',
364
+ completed: 0, total: 0, connectionMessage: 'Resuming the AWARE job in progress…' };
365
+ // Only when it is actually known. A browser that stored the legacy bare id has nothing to
366
+ // say here, and the painters' own fallback is a better answer than a guess.
367
+ if (stored.operation) resuming.operation = stored.operation;
368
+ emit(resuming);
262
369
  return poll(transaction, myGeneration);
263
370
  }
264
371
 
@@ -277,12 +384,17 @@
277
384
  async function adopt() {
278
385
  if (adopting) return adopting;
279
386
  adopting = (async () => {
387
+ // Captured BEFORE the request. The user can start a job while /active is in flight, and the
388
+ // stale response then bumped the generation again and emitted the OLD transaction — killing
389
+ // the newer job's poll and leaving the controller permanently on a job the user replaced.
390
+ const generationAtRequest = generation;
280
391
  let result;
281
392
  try {
282
393
  result = await request('/api/aware/update/active');
283
394
  } catch {
284
395
  return state; // discovery is best-effort; the pill's own poll remains the fallback
285
396
  }
397
+ if (generation !== generationAtRequest) return state; // superseded while we asked
286
398
  if (!result.response.ok) return state;
287
399
  const job = result.body && result.body.job;
288
400
  const transaction = transactionOf(job);