@floless/app 0.121.0 → 0.123.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.
@@ -86,7 +86,13 @@
86
86
  const status = String(payload.status || payload.state || payload.kind || '').toLowerCase();
87
87
  const target = payload.target || payload.targetVersion || null;
88
88
  const observedVersion = payload.observedVersion || payload.version || payload.runtimeVersion || null;
89
- const base = { transaction, target, observedVersion };
89
+ // Carried on EVERY normalized state, not set once at adoption. normalize() rebuilds state
90
+ // from each status response, so a field applied only when the job was adopted would be lost
91
+ // on the very first poll — restoring "Upgrading AWARE…" over a bridge repair, and
92
+ // re-enabling the modal hijack for a failure the user never initiated.
93
+ const operation = payload.operation === 'bridge-repair' ? 'bridge-repair' : 'runtime-update';
94
+ const origin = payload.origin === 'auto' ? 'auto' : 'user';
95
+ const base = { transaction, target, observedVersion, operation, origin };
90
96
  if (status === 'running') {
91
97
  return {
92
98
  ...base, status, stage: payload.stage || 'preparing',
@@ -114,7 +120,10 @@
114
120
  ...base, status: 'runtime-failed',
115
121
  error: {
116
122
  code: String(error.code || payload.code || 'runtime-update-failed'),
117
- message: String(error.message || payload.message || 'AWARE could not be upgraded.'),
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.')),
118
127
  },
119
128
  };
120
129
  }
@@ -152,7 +161,10 @@
152
161
  check = probed.response.ok ? probed.body : null;
153
162
  } catch { /* current readiness remains unknown */ }
154
163
  return emit({
155
- status: 'expired', transaction: null, check,
164
+ // origin carried through so a terminal state the user never initiated is still
165
+ // recognisable as such. Belt and braces alongside adopt() no longer storing: every
166
+ // state the subscriber may act on has to say where it came from.
167
+ status: 'expired', transaction: null, check, origin: state.origin || 'user',
156
168
  message: wasLostAfterRestart
157
169
  ? 'The previous upgrade could not be recovered after the server restarted. Current AWARE status was checked again.'
158
170
  : 'The previous upgrade result expired. Current AWARE status was checked again.',
@@ -161,12 +173,17 @@
161
173
  if (!result.response.ok) {
162
174
  const message = result.body.error || `Could not read AWARE upgrade status (HTTP ${result.response.status}).`;
163
175
  return emit({ status: 'runtime-failed', transaction, target: state.target, observedVersion: null,
176
+ // Identity is immutable, and DEFAULTED because start()/resume() emit before any poll
177
+ // has supplied it — copying a bare `state.operation` there copies undefined, which
178
+ // renders as a runtime upgrade anyway. The defaults match normalize()'s own.
179
+ operation: state.operation || 'runtime-update', origin: state.origin || 'user',
164
180
  error: { code: 'status-request-failed', message: String(message) } });
165
181
  }
166
182
  let next;
167
183
  try { next = normalize(result.body, transaction); }
168
184
  catch (error) {
169
185
  return emit({ status: 'runtime-failed', transaction, target: state.target, observedVersion: null,
186
+ operation: state.operation || 'runtime-update', origin: state.origin || 'user',
170
187
  error: { code: 'transaction-mismatch', message: error.message } });
171
188
  }
172
189
  emit(next);
@@ -245,6 +262,62 @@
245
262
  return poll(transaction, myGeneration);
246
263
  }
247
264
 
265
+ /**
266
+ * Adopt a job the SERVER started — an automatic bridge repair this browser has no stored
267
+ * transaction for, or an automatic failure that happened before it connected.
268
+ *
269
+ * Deliberately hits /active rather than the ordinary check route: the repair holds AWARE's
270
+ * exclusive lease, and the check route takes a shared one, so polling it to discover the repair
271
+ * would block on the very thing being discovered.
272
+ *
273
+ * Single-flight and idempotent — it is called at init AND on the aware-update SSE event, and
274
+ * both can land together.
275
+ */
276
+ let adopting = null;
277
+ async function adopt() {
278
+ if (adopting) return adopting;
279
+ adopting = (async () => {
280
+ let result;
281
+ try {
282
+ result = await request('/api/aware/update/active');
283
+ } catch {
284
+ return state; // discovery is best-effort; the pill's own poll remains the fallback
285
+ }
286
+ if (!result.response.ok) return state;
287
+ const job = result.body && result.body.job;
288
+ const transaction = transactionOf(job);
289
+ if (!transaction) return state;
290
+ // Already following this one (resume() got there first, or a duplicate SSE event).
291
+ if (state.transaction === transaction && state.status !== 'idle') return state;
292
+ generation += 1;
293
+ const myGeneration = generation;
294
+ // Deliberately NOT stored, unlike start(). Storage exists so a reload can resume a job the
295
+ // USER began; an adopted job is rediscovered from /active, which is the server's own
296
+ // authority and needs no client memory. Storing it caused a real regression: after a
297
+ // server restart the stored id 404s, poll() emits `expired` — a state with no origin, and
298
+ // one the subscriber treats as worth interrupting for — so a repair the user never started
299
+ // threw a modal over the workspace on the next load. Not storing removes the path entirely.
300
+ let next;
301
+ try { next = normalize({ ...job, transaction }, transaction); }
302
+ catch { return state; }
303
+ emit({ ...next, adopted: true });
304
+ if (terminal(next)) return next;
305
+ return poll(transaction, myGeneration);
306
+ })().finally(() => { adopting = null; });
307
+ return adopting;
308
+ }
309
+
310
+ /** Retire a terminal automatic result the user has now seen. Best-effort. */
311
+ async function acknowledge(transaction) {
312
+ const id = transaction || state.transaction;
313
+ if (!id) return state;
314
+ try {
315
+ await request(`/api/aware/update/status/${encodeURIComponent(id)}/acknowledge`, { method: 'POST' });
316
+ clearStored();
317
+ } catch { /* the server retires it on its own retention timer regardless */ }
318
+ return state;
319
+ }
320
+
248
321
  async function check() {
249
322
  const result = await request('/api/aware/update');
250
323
  if (!result.response.ok) throw new Error(result.body.error || `Could not check AWARE updates (HTTP ${result.response.status}).`);
@@ -289,7 +362,7 @@
289
362
  }
290
363
 
291
364
  return {
292
- start, resume, retryFailed, check,
365
+ start, resume, adopt, acknowledge, retryFailed, check,
293
366
  getState: () => state,
294
367
  getStoredTransaction: readStored,
295
368
  subscribe(listener) {
package/dist/web/aware.js CHANGED
@@ -146,6 +146,10 @@
146
146
  $messages.scrollTop = $messages.scrollHeight;
147
147
  };
148
148
 
149
+ // Declared here, above its first use in api(), rather than beside the recovery helper that reads
150
+ // it — a `let` referenced before its declaration executes is a TDZ crash, not a false.
151
+ let awareMaintenanceRefused = false;
152
+
149
153
  async function api(path, opts) {
150
154
  const res = await fetch(path, {
151
155
  headers: { 'content-type': 'application/json' },
@@ -153,7 +157,19 @@
153
157
  });
154
158
  const body = await res.json().catch(() => ({ ok: false, error: `HTTP ${res.status}` }));
155
159
  if (!res.ok || body.ok === false) {
156
- const err = new Error(body.error || `HTTP ${res.status}`);
160
+ // Centralised so EVERY caller that spawns `aware` reports the refusal honestly rather than
161
+ // showing the raw `aware_maintenance_busy` code. The server refuses instead of queuing
162
+ // because the wait would start before any child exists — invisible to every timeout and
163
+ // uncancellable by Stop — so what reaches the user has to explain itself and say how far
164
+ // along the repair is.
165
+ if (body.code === 'maintenance-busy') {
166
+ // Remembered so the terminal transition can re-run whatever was turned away. Set here
167
+ // rather than at each call site: every `aware`-spawning route funnels through api().
168
+ awareMaintenanceRefused = true;
169
+ }
170
+ const err = new Error(
171
+ (body.code === 'maintenance-busy' && body.message) || body.error || `HTTP ${res.status}`,
172
+ );
157
173
  err.body = body; // preserve the in-band payload (e.g. credentialIssue) for callers
158
174
  throw err;
159
175
  }
@@ -5192,21 +5208,56 @@
5192
5208
  let awareUpgradeFloor = null, awareUpgradeFloorUntil = 0;
5193
5209
  let awareUpdateCheck = null;
5194
5210
  let applyAwareUpdate = null;
5211
+ /**
5212
+ * The one place the "needs attention" pill is painted, so its four properties cannot drift apart
5213
+ * across the three call sites that reach this state. The tooltip matters more than it looks: the
5214
+ * static markup default says an AWARE *upgrade* is available, so a pill that reaches this state
5215
+ * without passing through an offer branch would otherwise hover-explain the wrong thing entirely.
5216
+ */
5217
+ function paintAwareAttentionPill() {
5218
+ if (!$awareUpdate) return;
5219
+ $awareUpdate.hidden = false;
5220
+ $awareUpdate.disabled = false;
5221
+ $awareUpdate.textContent = 'Installed bridges need attention';
5222
+ $awareUpdate.dataset.tip = 'A bridge repair did not finish — open it to see which bridge and try again';
5223
+ $awareUpdate.setAttribute('aria-haspopup', 'dialog');
5224
+ }
5225
+
5226
+ /**
5227
+ * Terminal states whose remaining problem is BRIDGES, whoever started the job.
5228
+ *
5229
+ * Scoped to the operation on purpose: `partial` always means some bridges failed, but a
5230
+ * `runtime-failed` on a runtime UPGRADE is the upgrade failing — labelling that "Installed
5231
+ * bridges need attention" would be the same class of lie this change set out to remove, and the
5232
+ * ordinary re-check below correctly re-offers the upgrade instead.
5233
+ */
5234
+ const awareNeedsAttention = (s) => !!s && (s.status === 'partial'
5235
+ || (s.status === 'runtime-failed' && (s.operation || awareUpgradeOperation) === 'bridge-repair'));
5236
+
5237
+ /**
5238
+ * True when the live job state owns the pill and this generic re-check must keep its hands off.
5239
+ *
5240
+ * Checked BOTH before the fetch and again after it. Before-only was not enough and the gap was
5241
+ * observed, not theorised: at page load this runs while the controller is still `idle`, sails
5242
+ * past the guard, and by the time the response lands `adopt()` has discovered a failed automatic
5243
+ * repair and painted the attention pill — which the stale in-flight answer then overwrote with a
5244
+ * cheerful "Repair 1 installed bridge", erasing the only sign anything had gone wrong.
5245
+ */
5246
+ function awareJobOwnsPill() {
5247
+ const s = window.awareUpdateController && window.awareUpdateController.getState();
5248
+ if (!s) return false;
5249
+ if (s.status === 'starting' || s.status === 'running' || s.status === 'retrying') return true;
5250
+ if (awareNeedsAttention(s)) { paintAwareAttentionPill(); return true; }
5251
+ return false;
5252
+ }
5253
+
5195
5254
  async function refreshAwareUpdate() {
5196
5255
  if (!$awareUpdate) return;
5197
- if (window.awareUpdateController) {
5198
- const updateState = window.awareUpdateController.getState();
5199
- if (updateState.status === 'starting' || updateState.status === 'running' || updateState.status === 'retrying') return;
5200
- if (updateState.status === 'partial') {
5201
- $awareUpdate.hidden = false;
5202
- $awareUpdate.disabled = false;
5203
- $awareUpdate.textContent = 'Installed bridges need attention';
5204
- return;
5205
- }
5206
- }
5256
+ if (awareJobOwnsPill()) return;
5207
5257
  try {
5208
5258
  const r = await fetch('/api/aware/update');
5209
5259
  const d = await r.json();
5260
+ if (awareJobOwnsPill()) return; // the job resolved while this request was in flight
5210
5261
  awareUpdateCheck = r.ok ? d : null;
5211
5262
  if (r.ok && d.updateAvailable && d.targetVersion && d.operation === 'bridge-repair') {
5212
5263
  const count = Array.isArray(d.bridges) ? d.bridges.filter((row) => row.status !== 'current').length : 0;
@@ -5263,6 +5314,16 @@
5263
5314
 
5264
5315
  function closeAwareUpgradeModal() {
5265
5316
  if (!$awareUpgradeModal) return;
5317
+ // Retire an AUTOMATIC terminal result the user has now seen, or /active keeps handing it back
5318
+ // on every page load for the whole retention window. Scoped to this transaction and refused
5319
+ // server-side while it is still running, so closing the modal mid-repair cannot retire a job
5320
+ // that has not failed yet.
5321
+ if (awareUpdateClient) {
5322
+ const s = awareUpdateClient.getState();
5323
+ if (s.origin === 'auto' && (s.status === 'partial' || s.status === 'runtime-failed')) {
5324
+ awareUpdateClient.acknowledge(s.transaction).catch(() => {});
5325
+ }
5326
+ }
5266
5327
  hideModal($awareUpgradeModal);
5267
5328
  const restore = awareUpgradeReturnFocus;
5268
5329
  awareUpgradeReturnFocus = null;
@@ -5328,7 +5389,12 @@
5328
5389
  $awareUpgradeResults.insertAdjacentHTML('afterbegin', `<div class="aware-update-summary">${escapeHtml(s.retryError)}</div>`);
5329
5390
  }
5330
5391
  } else if (status === 'runtime-failed') {
5331
- $awareUpgradeLive.textContent = 'AWARE could not be upgraded.';
5392
+ // A bridge repair can terminalize here too (a failed preflight, smoke, or a runtime that
5393
+ // moved underneath it) — and it never set out to upgrade anything, so the generic wording
5394
+ // would be simply untrue.
5395
+ $awareUpgradeLive.textContent = operation === 'bridge-repair'
5396
+ ? "AWARE's installed bridges could not be refreshed."
5397
+ : 'AWARE could not be upgraded.';
5332
5398
  const reason = s.error && s.error.message ? s.error.message : 'Check your connection and try again.';
5333
5399
  $awareUpgradeResults.innerHTML = `<div class="aware-update-summary">${escapeHtml(reason)}</div>`;
5334
5400
  } else if (status === 'expired') {
@@ -5337,6 +5403,21 @@
5337
5403
  }
5338
5404
  }
5339
5405
 
5406
+ /**
5407
+ * Re-run the loads that unattended maintenance refused while it held the writer.
5408
+ *
5409
+ * The gate answers `maintenance-busy` rather than queuing — the wait it would otherwise impose
5410
+ * starts before any child exists, so nothing times it out and Stop cannot cancel it. But that
5411
+ * refusal also lands on ordinary reads like loadApps(), which have no reason to know about
5412
+ * bridges: without this the workflow list would simply stay empty until something else happened
5413
+ * to reload it. Only for `auto` work; a user-initiated upgrade already owns its own modal flow.
5414
+ */
5415
+ function awareMaintenanceRecover(s) {
5416
+ if (s.origin !== 'auto' || !awareMaintenanceRefused) return;
5417
+ awareMaintenanceRefused = false;
5418
+ loadApps().catch(() => { /* the picker keeps its own empty/error state */ });
5419
+ }
5420
+
5340
5421
  async function openAwareUpgrade(version, returnFocusTo) {
5341
5422
  if (!$awareUpgradeModal || !awareUpdateClient) {
5342
5423
  showToast('Could not open the AWARE update dialog.', 'warn');
@@ -5348,7 +5429,10 @@
5348
5429
  }
5349
5430
  const current = awareUpdateClient.getState();
5350
5431
  let target = version || awareUpgradeTarget || ($awareUpdate && $awareUpdate.dataset.target) || '';
5351
- if (!target && !awareBusy(current.status) && current.status !== 'partial') {
5432
+ // A registry hiccup must not swallow a terminal state we already hold: without widening this
5433
+ // to every attention state, a runtime-failed repair returns early with a toast and the modal
5434
+ // explaining the failure never opens.
5435
+ if (!target && !awareBusy(current.status) && !awareNeedsAttention(current)) {
5352
5436
  try {
5353
5437
  const check = await awareUpdateClient.check();
5354
5438
  awareUpdateCheck = check;
@@ -5363,7 +5447,11 @@
5363
5447
  awareUpgradeInventory = Array.isArray(check.bridges) ? check.bridges : [];
5364
5448
  awareUpgradeTarget = target;
5365
5449
  awareUpgradeReturnFocus = returnFocusTo || document.activeElement;
5366
- paintAwareUpgrade(awareBusy(current.status) || current.status === 'partial'
5450
+ // `runtime-failed` belongs here alongside `partial`. Without it, clicking the attention pill
5451
+ // synthesized a fresh IDLE offer — whose paint clears the results panel and empties the live
5452
+ // region — so the operation-specific explanation ("AWARE's installed bridges could not be
5453
+ // refreshed.") was composed and then never shown to anyone.
5454
+ paintAwareUpgrade(awareBusy(current.status) || awareNeedsAttention(current)
5367
5455
  ? current : { status: 'idle', transaction: null, target: awareUpgradeTarget });
5368
5456
  showModal($awareUpgradeModal);
5369
5457
  setTimeout(() => {
@@ -5379,30 +5467,51 @@
5379
5467
  if (awareUpdateClient && $awareUpgradeModal) {
5380
5468
  awareUpdateClient.subscribe((s) => {
5381
5469
  const busy = awareBusy(s.status);
5470
+ // The job's OWN operation, not the module variable openAwareUpgrade sets. A repair the
5471
+ // server started never opened the modal, so the variable still says 'runtime-update' and the
5472
+ // pill would announce "Upgrading AWARE…" while it is in fact refreshing bridges.
5473
+ const operation = s.operation || awareUpgradeOperation;
5382
5474
  if ($awareUpdate) {
5383
5475
  $awareUpdate.disabled = busy;
5384
5476
  $awareUpdate.setAttribute('aria-busy', busy ? 'true' : 'false');
5385
5477
  if (busy) {
5386
5478
  $awareUpdate.hidden = false;
5479
+ // The ↑ glyph means "a runtime upgrade is on offer" everywhere else in this footer;
5480
+ // every bridge-repair label deliberately goes without it, and a retry is bridge work.
5387
5481
  $awareUpdate.textContent = s.status === 'retrying'
5388
- ? '↑ Retrying bridge…'
5389
- : awareUpgradeOperation === 'bridge-repair' ? 'Repairing installed bridges…' : '↑ Upgrading AWARE…';
5390
- } else if (s.status === 'partial') {
5391
- $awareUpdate.hidden = false;
5392
- $awareUpdate.textContent = 'Installed bridges need attention';
5482
+ ? 'Retrying bridge…'
5483
+ : operation === 'bridge-repair' ? 'Repairing installed bridges…' : '↑ Upgrading AWARE…';
5484
+ } else if (awareNeedsAttention(s)) {
5485
+ // Every suppressed automatic failure must land on an ENABLED attention pill. Without the
5486
+ // runtime-failed arm the pill stays frozen on "Repairing installed bridges…" forever,
5487
+ // because the modal that would otherwise have explained it never opened.
5488
+ paintAwareAttentionPill();
5393
5489
  }
5394
5490
  }
5395
5491
  _updateApplying = busy ? 'aware' : (_updateApplying === 'aware' ? null : _updateApplying);
5396
5492
  paintAwareUpgrade(s);
5397
5493
  if (s.status === 'partial' || s.status === 'runtime-failed' || s.status === 'expired') {
5398
- if (!$awareUpgradeModal.classList.contains('show')) {
5494
+ // Stealing focus is right for a repair the user CLICKED — they are watching and it carries
5495
+ // recovery actions. It is wrong for one the server started: a modal thrown over the
5496
+ // workspace on launch is precisely the interruption "run it in the background" was chosen
5497
+ // to avoid. The attention pill above carries it instead, and opens this on demand.
5498
+ awareMaintenanceRecover(s);
5499
+ const hijack = s.origin !== 'auto';
5500
+ if (hijack && !$awareUpgradeModal.classList.contains('show')) {
5399
5501
  awareUpgradeReturnFocus = document.activeElement;
5400
5502
  showModal($awareUpgradeModal);
5401
5503
  setTimeout(() => (!$awareUpgradeRetry.hidden ? $awareUpgradeRetry : $awareUpgradeCancel).focus(), 0);
5504
+ } else if (!hijack && awareNeedsAttention(s)) {
5505
+ // Suppressing the modal must not mean suppressing the NEWS. Without this the quieter
5506
+ // outcome was louder than the urgent one: an automatic success toasted, while an
5507
+ // automatic failure — drag-out still broken — changed a footer label nobody was told to
5508
+ // look at. paintAwareUpgrade(s) ran just above, so this copy is already the right one.
5509
+ showToast($awareUpgradeLive.textContent, 'warn');
5402
5510
  }
5403
5511
  refreshAwareUpdate();
5404
5512
  } else if (s.status === 'success') {
5405
5513
  const version = s.observedVersion || s.target;
5514
+ awareMaintenanceRecover(s);
5406
5515
  const wv = document.getElementById('aware-version');
5407
5516
  if (wv && version) {
5408
5517
  wv.textContent = 'AWARE ' + version;
@@ -5443,12 +5552,29 @@
5443
5552
  if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
5444
5553
  else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
5445
5554
  };
5446
- awareUpdateClient.resume();
5555
+ // SERIALIZED, not fired together. A stored transaction lost across a server restart makes
5556
+ // resume() 404, clear storage, and fall through to the LEASED check route — which blocks
5557
+ // behind a running repair. Awaiting resume() first means adopt() then finds the live job
5558
+ // instead of the browser never learning about it.
5559
+ (async () => {
5560
+ // resume() is allowed to FAIL here — a transaction lost across a server restart is the
5561
+ // ordinary case — and adopt() must still run. Awaiting it unguarded meant one rejected
5562
+ // resume skipped discovery entirely, which is precisely the situation adopt() exists for.
5563
+ try { await awareUpdateClient.resume(); } catch { /* stale transaction; discovery continues */ }
5564
+ await awareUpdateClient.adopt();
5565
+ })().catch(() => {});
5447
5566
  }
5448
5567
 
5449
5568
  if ($awareUpdate) {
5450
5569
  $awareUpdate.onclick = () => {
5451
- if (awareUpdateClient && awareUpdateClient.getState().status === 'partial') {
5570
+ // Both attention states, not just `partial`. A runtime-failed automatic repair paints the
5571
+ // same pill but has no `dataset.operation` (paintAwareAttentionPill does not set it, and the
5572
+ // offer branches that would are now unreachable because awareJobOwnsPill bails first), so it
5573
+ // fell through to the release-notes popover with an empty version — the pill whose tooltip
5574
+ // says "open it to see which bridge" opened the changelog. It also made the failure
5575
+ // unacknowledgeable, since acknowledge only fires when this modal closes, so the warn toast
5576
+ // returned on every load for the full retention window.
5577
+ if (awareUpdateClient && awareNeedsAttention(awareUpdateClient.getState())) {
5452
5578
  openAwareUpgrade('', $awareUpdate);
5453
5579
  return;
5454
5580
  }
@@ -6232,6 +6358,11 @@
6232
6358
  // (installing only) → dim ticker; `status`/`reason` drive the card state.
6233
6359
  if (m.line != null) setBootstrapLogLine(m.line);
6234
6360
  if (m.status) updateBootstrap({ status: m.status, reason: m.reason ?? null, remediation: m.remediation ?? null });
6361
+ } else if (m.type === 'aware-update') {
6362
+ // The server started an automatic bridge repair. Adopt it now so an ALREADY-OPEN tab shows
6363
+ // it immediately; the init-time adopt() only covers tabs opened after it began. adopt() is
6364
+ // single-flight and idempotent, so the two racing is fine.
6365
+ if (window.awareUpdateController) window.awareUpdateController.adopt().catch(() => {});
6235
6366
  } else if (m.type === 'render-progress') {
6236
6367
  // Relayed as a DOM event rather than widening the bridge: workspaces.js owns the Exports
6237
6368
  // card and is the only listener, and a render can outlive several repaints of it.
@@ -39,7 +39,17 @@ const parseInches = (raw) => {
39
39
  return NaN;
40
40
  };
41
41
 
42
- /** mm per display px for a plan scale (matches steel-3d-core kOf). */
42
+ /**
43
+ * mm per display px for a plan scale — THE one implementation of the plan display scale.
44
+ *
45
+ * It lives in this leaf module because five copies of `FT_MM / (ptPerFt > 0 ? ptPerFt : 1)` had grown
46
+ * (here, steel-3d-core's `kOf`, steel-model-adapter's and steel-model-commands' `scaleOf`, and inline
47
+ * in steel-plan-transform and server/contract-to-scene), each carrying a comment telling the next
48
+ * reader to keep it in lock-step with the others by hand. They all import this now.
49
+ *
50
+ * A missing, zero or negative `pt_per_ft` reads as 1 pt/ft rather than dividing by it, so an
51
+ * unscaled sheet degrades to a 1:1 map instead of putting Infinity or a mirrored scale into geometry.
52
+ */
43
53
  export const mmPerPx = (ptPerFt) => FT_MM / (ptPerFt > 0 ? ptPerFt : 1);
44
54
 
45
55
  /** One length token → mm, or NaN. Accepts 25' | 25'-6 1/2" | 6 1/2" | 1/2" | 7.5m | 6096 (mm) | 6096mm; leading '-' negates. */
@@ -578,7 +578,10 @@
578
578
  </div>
579
579
  </div>
580
580
 
581
- <div class="toast-container" id="toast-container"></div>
581
+ <!-- polite live region: toasts are the only channel for a few system conditions the user did not
582
+ trigger (the maintenance-busy refusal above all), and without this a screen-reader user gets
583
+ silence where a sighted user gets an explanation. -->
584
+ <div class="toast-container" id="toast-container" role="status" aria-live="polite"></div>
582
585
 
583
586
  <!-- Reusable styled prompt/form modal — used for node inputs (double-click an
584
587
  input node) and Tweak. Replaces native window.prompt so dialogs match the
@@ -11,6 +11,8 @@
11
11
  * needs it).
12
12
  */
13
13
 
14
+ import { mmPerPx } from './grid-core.js';
15
+
14
16
  export const FT_TO_MM = 304.8;
15
17
  export const IN_TO_MM = 25.4;
16
18
 
@@ -124,15 +126,17 @@ export function projectedFootprintHitsRect2d(points, rect, windowMode) {
124
126
  return true;
125
127
  }
126
128
 
127
- const kOf = (ptPerFt) => FT_TO_MM / (ptPerFt > 0 ? ptPerFt : 1);
128
-
129
129
  const nz = (n) => n + 0; // normalize -0 → 0 (negating 0 yields -0, which surprises equality checks)
130
130
 
131
- /** display-space wp point → scene mm [x,y] (Y flipped, matching contractToScene.dispToMm). */
132
- export function dispToMm(pt, ptPerFt) { const k = kOf(ptPerFt); return [nz(pt[0] * k), nz(-pt[1] * k)]; }
131
+ /**
132
+ * display-space wp point → scene mm [x,y] (Y flipped). THE one display→mm conversion: the adapter and
133
+ * server/contract-to-scene each used to carry their own copy of `[x·k, -y·k]`, with a comment on each
134
+ * naming the others as mirrors to keep by hand.
135
+ */
136
+ export function dispToMm(pt, ptPerFt) { const k = mmPerPx(ptPerFt); return [nz(pt[0] * k), nz(-pt[1] * k)]; }
133
137
 
134
138
  /** scene mm point [x,y,…] → display-space wp [px,py] (inverse of dispToMm). */
135
- export function planPointToWp(p, ptPerFt) { const k = kOf(ptPerFt); return [nz(p[0] / k), nz(-p[1] / k)]; }
139
+ export function planPointToWp(p, ptPerFt) { const k = mmPerPx(ptPerFt); return [nz(p[0] / k), nz(-p[1] / k)]; }
136
140
 
137
141
  /**
138
142
  * The px→ft scale and default T.O.S of the plan that OWNS a member, resolved from the SAME per-plan
@@ -878,7 +882,7 @@ export function selectedLengthLabelAnchors(labels, members, geometryOf) {
878
882
  * Snap targets from v2 members — the v2 sibling of `snapCandidates`, emitting the identical record shapes
879
883
  * so `snapPoint`'s precedence table and `candidatePoint` need no v2 case.
880
884
  *
881
- * WHY THIS IS NOT `snapCandidates(members, 304.8, 0, excludeId)`. That nearly works — `kOf(304.8)` is 1 —
885
+ * WHY THIS IS NOT `snapCandidates(members, 304.8, 0, excludeId)`. That nearly works — `mmPerPx(304.8)` is 1 —
882
886
  * and is wrong twice: it would still negate Y (v2 coordinates are already world), and it would still read
883
887
  * `m.wp`/`m.col`/`m.ends`, which a v2 member does not have. A v2 member routed through the v1 function
884
888
  * does not throw; it yields NaN candidates that snap silently to nowhere. Silence is the failure mode.