@floless/app 0.134.2 → 0.134.4

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.
@@ -254,7 +254,9 @@
254
254
  // provide a separate plain-English subject so `?` never reads implementation ids aloud.
255
255
  var narratedInstance = target.getAttribute('data-command-instance-label') || cmd.instance;
256
256
  return {
257
- label: cmd.meta.label || accessibleName(target),
257
+ label: cmd.meta.label
258
+ ? cmd.meta.label.replace(/\{instance\}/g, narratedInstance || 'the one you pick')
259
+ : accessibleName(target),
258
260
  acts: narratedInstance && cmd.meta.actsOn
259
261
  ? cmd.meta.actsOn.replace('{instance}', narratedInstance)
260
262
  : cmd.meta.actsOn || null,
@@ -507,10 +509,12 @@
507
509
  var parts = window.Commands.split ? window.Commands.split(raw) : null;
508
510
  if (!parts || parts.template !== cmd.id || !parts.instance || seen[raw]) return;
509
511
  seen[raw] = true;
512
+ var instanceLabel = el.getAttribute('data-command-instance-label') || accessibleName(el);
510
513
  found.push(Object.assign({}, cmd, {
511
514
  commandId: raw,
512
515
  instance: parts.instance,
513
- instanceLabel: el.getAttribute('data-command-instance-label') || accessibleName(el),
516
+ instanceLabel: instanceLabel,
517
+ label: cmd.label ? cmd.label.replace(/\{instance\}/g, parts.instance) : instanceLabel,
514
518
  originSurface: origin,
515
519
  }));
516
520
  });
@@ -578,14 +582,14 @@
578
582
  'In the Narrative panel', 'In the AI answers tab', 'In the node Inspect panel', 'In the Instructor strip',
579
583
  'In the ≡ menu', 'In the footer',
580
584
  'In the contract editor', 'In the report viewer', 'In the guide',
581
- 'In the agent library', 'In the requests list', 'In the run request dialog', 'In the Routines dialog',
585
+ 'In the agent library', 'In the requests list', 'In the revision review', 'In the run request dialog', 'In the Routines dialog',
582
586
  'In the Report an issue dialog', 'In the Build an agent dialog', 'In the Bake dialog',
583
587
  'In the FloLess dialogs',
584
588
  /* the steel editor — read top-left down, then the menus, then the dialogs.
585
589
  The ⋯ menu is six groups rather than one because it is six accordion
586
590
  sections on screen: a single 'In the ⋯ menu' would have been about thirty
587
591
  rows under one heading, which is a scroll rather than a list. */
588
- 'In the steel editor header', 'On the steel canvas', 'In the Copy panel', 'In the Copy array panel', 'On the 2D zoom bar',
592
+ 'In the steel editor header', 'On the steel canvas', 'On the drawing canvas', 'In the Copy panel', 'In the Copy array panel', 'On the 2D zoom bar',
589
593
  'In the 3D toolbar', 'In the 3D side panel', 'On the snap bar',
590
594
  'In the grid panel', 'In the Inspect panel',
591
595
  'In the Properties popup', 'In the snap override menu', 'In the dimension value popup', 'In the selection filter',
@@ -39,11 +39,86 @@
39
39
  const $centerName = document.getElementById('center-panel-name');
40
40
  const $centerRole = document.getElementById('center-panel-role');
41
41
  const $resetModal = document.getElementById('ext-reset-modal');
42
+ const $menuViewItem = document.getElementById('menu-view-switch'); // the ≡ view-switch row itself
42
43
  if (!$dashboard) return; // markup absent — nothing to wire
43
44
 
45
+ // ── Dashboard UI availability gate (#902) ───────────────────────────────────
46
+ // The Dashboard is TEMPORARILY hidden from Workflows: at this stage it adds more
47
+ // product noise than value. This is an exposure gate, not a removal — the
48
+ // descriptor, its store and API, the block renderers, and every user's saved
49
+ // panels and history are all still here and still working. Flipping this one flag
50
+ // back to true is the whole of re-enabling it, which is why every suppression
51
+ // below reads from it rather than deleting the code it guards.
52
+ const DASHBOARD_UI_ENABLED = false;
53
+
44
54
  const LS_VIEW = 'floless:view';
45
55
  let view = 'canvas';
46
- try { if (localStorage.getItem(LS_VIEW) === 'dashboard') view = 'dashboard'; } catch { /* private mode */ }
56
+ // The persisted preference is only honoured while the surface is exposed, so a user
57
+ // whose last session ended on the Dashboard opens on Canvas instead of landing on a
58
+ // view they can no longer leave. The stored value is deliberately NOT rewritten:
59
+ // re-enabling the feature restores each user's own last view.
60
+ try {
61
+ if (DASHBOARD_UI_ENABLED && localStorage.getItem(LS_VIEW) === 'dashboard') view = 'dashboard';
62
+ } catch { /* private mode */ }
63
+
64
+ // Hide the ≡ "Switch to Dashboard" row. Hidden, not removed: the markup and its
65
+ // data-command-id stay in index.html, so re-enabling needs no markup change.
66
+ if (!DASHBOARD_UI_ENABLED && $menuViewItem) $menuViewItem.hidden = true;
67
+
68
+ // Hiding the DOM is only half of it. The Instructor's `?` / "see all" sheet
69
+ // catalogues every REGISTERED command and synthesizes a row for one with no visible
70
+ // carrier — on purpose, so it can tell you what FloLess does on a screen you are not
71
+ // on. A gated-off feature is not that case: leaving those registrations in place
72
+ // keeps advertising controls nothing can reach.
73
+ //
74
+ // The set is DERIVED from the four containers that hold Dashboard-only controls
75
+ // rather than listed by hand, so a control added to the Customized menu later is
76
+ // retired with the rest instead of quietly reappearing in the sheet. It cannot
77
+ // over-reach either: it walks only these roots.
78
+ const DASHBOARD_COMMAND_ROOTS = [
79
+ '#menu-view-switch', // the ≡ Canvas|Dashboard switch
80
+ '#ext-badge', // the Customized badge
81
+ '#ext-menu', // …and its Undo · Redo · Reset menu
82
+ '#ext-reset-modal', // the Reset-to-default confirm
83
+ ];
84
+ // Deferred to DOMContentLoaded because commands-shell.js, which defines these,
85
+ // loads AFTER this file — retiring them now would find nothing and silently no-op.
86
+ if (!DASHBOARD_UI_ENABLED) {
87
+ const retireDashboardCommands = () => {
88
+ if (!window.Commands || !window.Commands.retire) return;
89
+ // A carrier may be `template#instance`; the registry is keyed by template.
90
+ const templateOf = (el) => {
91
+ const raw = el.getAttribute('data-command-id');
92
+ const parts = raw && window.Commands.split ? window.Commands.split(raw) : null;
93
+ return parts && parts.template ? parts.template : null;
94
+ };
95
+ const candidates = new Set();
96
+ for (const sel of DASHBOARD_COMMAND_ROOTS) {
97
+ const root = document.querySelector(sel);
98
+ if (!root) continue;
99
+ for (const el of [root, ...root.querySelectorAll('[data-command-id]')]) {
100
+ const t = templateOf(el);
101
+ if (t) candidates.add(t);
102
+ }
103
+ }
104
+ // A template that ALSO has a carrier outside these roots is shared, and stays.
105
+ // `shell.dialog-cancel` is the reason this pass exists: one registration serves the
106
+ // Cancel button of every dialog in FloLess, including the Reset-to-default confirm,
107
+ // so retiring it on the Dashboard's account would take Cancel guidance away from all
108
+ // of them. Only a command that lives NOWHERE else is Dashboard-only.
109
+ for (const el of document.querySelectorAll('[data-command-id]')) {
110
+ if (DASHBOARD_COMMAND_ROOTS.some((sel) => el.closest(sel))) continue;
111
+ const t = templateOf(el);
112
+ if (t) candidates.delete(t);
113
+ }
114
+ for (const t of candidates) window.Commands.retire(t);
115
+ };
116
+ if (document.readyState === 'loading') {
117
+ document.addEventListener('DOMContentLoaded', retireDashboardCommands, { once: true });
118
+ } else {
119
+ retireDashboardCommands();
120
+ }
121
+ }
47
122
 
48
123
  let booted = false; // flips in boot() — called by aware.js once licensed + AWARE-ready
49
124
  let ext = { descriptor: null, validation: null, data: {} };
@@ -61,7 +136,10 @@
61
136
  }
62
137
  // v1 honors two slots. Anything else lands on the Dashboard rather than
63
138
  // vanishing — a panel the user asked for must never silently disappear.
64
- const inspectPanels = () => allPanels().filter((p) => p.slot === 'inspect-tab');
139
+ // Gated at the accessor so BOTH consumers — the Inspector tab strip and the tab body
140
+ // renderer — go dark together (#902). A contributed tab is Dashboard content wearing
141
+ // an Inspector hat; it must not survive the surface it belongs to.
142
+ const inspectPanels = () => (DASHBOARD_UI_ENABLED ? allPanels().filter((p) => p.slot === 'inspect-tab') : []);
65
143
  const dashboardPanels = () => allPanels().filter((p) => p.slot !== 'inspect-tab');
66
144
  const descriptorInvalid = () => !!(ext.validation && ext.validation.valid === false);
67
145
 
@@ -70,6 +148,9 @@
70
148
  // the ≡ hamburger, so it's visible without opening the menu (#149 — the old toggle that
71
149
  // hosted the dot is gone).
72
150
  function setDashUpdated(on) {
151
+ // One choke point for both signals, so gating here covers every caller: while the
152
+ // Dashboard is hidden there is nowhere for "updated" to send anyone (#902).
153
+ if (!DASHBOARD_UI_ENABLED) on = false;
73
154
  if ($dashDot) $dashDot.hidden = !on;
74
155
  if ($menuBtn) $menuBtn.classList.toggle('has-dash-update', on);
75
156
  }
@@ -90,7 +171,13 @@
90
171
  applyView();
91
172
  if (view === 'dashboard') renderDashboard();
92
173
  }
93
- function toggleView() { setView(view === 'dashboard' ? 'canvas' : 'dashboard'); }
174
+ // The only caller of setView. Gated here rather than inside setView so a hidden
175
+ // Dashboard never REWRITES `floless:view` to 'canvas' — the user's stored preference
176
+ // has to survive the gate to be worth restoring when it lifts (#902).
177
+ function toggleView() {
178
+ if (!DASHBOARD_UI_ENABLED) return;
179
+ setView(view === 'dashboard' ? 'canvas' : 'dashboard');
180
+ }
94
181
  // The ≡ menu's "Switch to Dashboard/Canvas" item drives the view (the header toggle was
95
182
  // removed in #149). handleMenuAction lives in app.js and is already wrapped in aware.js
96
183
  // for graft/bake; wrap once more here for view-switch and fall through for everything else.
@@ -474,7 +561,10 @@
474
561
  // ── Customized badge + Undo / History / Reset menu ───────────────────────────
475
562
  function renderBadge() {
476
563
  if (!$extBadge) return;
477
- const has = allPanels().length > 0;
564
+ // The badge's whole menu (Undo · History · Reset) edits Dashboard panels, so it goes
565
+ // with the Dashboard — a populated descriptor must not light it up while the surface
566
+ // it describes is unreachable (#902).
567
+ const has = DASHBOARD_UI_ENABLED && allPanels().length > 0;
478
568
  $extBadge.hidden = !has;
479
569
  if (!has) closeExtMenu();
480
570
  }
@@ -27,6 +27,8 @@
27
27
  * exactly as the drawing prints it is also what lets a detailer match it against the sheet.
28
28
  */
29
29
 
30
+ import { normalizeCatalogText } from './steel-catalog-picker.js';
31
+
30
32
  const finite = (n) => Number.isFinite(typeof n === 'number' ? n : Number(n));
31
33
  /** A drawable position. The renderer coerces, so numeric strings are accepted — but not a NaN, which
32
34
  * would put an un-clickable rect at an undefined coordinate. */
@@ -102,6 +104,122 @@ export function planDetailRefs(plan) {
102
104
  return out;
103
105
  }
104
106
 
107
+ /**
108
+ * Every drawable profile label on the plan: `{text, disp}`, in source order, NOT deduplicated.
109
+ *
110
+ * These are `plan.labels[]` — the PDF-extracted `{text, disp}` strings the profile-pick overlay draws
111
+ * as clickable hot-zones ("click a profile label in the drawing to apply it"). Same shape rule as
112
+ * `planDetailRefs`: an entry needs BOTH a printable string AND a drawable point, because the hot-zone
113
+ * is sized from the text and positioned at `disp` — an empty string sizes a zero box and a missing/NaN
114
+ * `disp` puts a rect at an undefined coordinate. Dropping the malformed ones here keeps that validation
115
+ * (and its tests) out of the page closure, where #887 hid: the overlay drew a positioned box for every
116
+ * label but never the text inside it, so every hot-zone rendered empty and unlabelled.
117
+ */
118
+ export function planProfileLabels(plan) {
119
+ if (!plan || typeof plan !== 'object' || !Array.isArray(plan.labels)) return [];
120
+ const out = [];
121
+ for (const entry of plan.labels) {
122
+ if (!entry || typeof entry !== 'object') continue;
123
+ const name = text(entry.text);
124
+ if (!name || !point(entry.disp)) continue;
125
+ out.push({ text: name, disp: [Number(entry.disp[0]), Number(entry.disp[1])] });
126
+ }
127
+ return out;
128
+ }
129
+
130
+ const profileSheetIndex = new WeakMap();
131
+ const canonicalProfile = (value) => normalizeCatalogText(value);
132
+ // Drawing labels may legitimately name custom, built-up, foreign, or unresolved sections that are
133
+ // absent from the installed catalogue. Keep those pickable (the editor marks them RFI), while rejecting
134
+ // ordinary annotations. Catalogue membership is authoritative; outside it, accept only known structural
135
+ // section families plus the two explicit unresolved/custom conventions FloLess already authors.
136
+ const STRUCTURAL_PROFILE = /^(?:2L|HSS|PIPE|HP|MC|WT|MT|ST|W|M|S|C|L|IPE|IPN|HEA|HEB|HEM|HE|HL|HD|UB|UC|UKB|UKC|PFC|CHS|RHS|SHS|EA|UA)\d/;
137
+ const CUSTOM_PROFILE = /^(?:MF\d+|BG\d+-CUSTOM)$/;
138
+ const DRAWING_ANNOTATION = /^(?:NOTE|NOTES|GRID|LEVEL|ELEV|ELEVATION|DETAIL|SHEET)\d/;
139
+ const profileToken = (value) => {
140
+ const name = canonicalProfile(value);
141
+ return name.length >= 2 && name.length <= 64 && /[A-Z]/.test(name) && /\d/.test(name)
142
+ && /^[A-Z0-9][A-Z0-9X./+'"#-]*$/.test(name)
143
+ ? name : '';
144
+ };
145
+ const profileDesignation = (value, catalogue) => {
146
+ const name = profileToken(value);
147
+ return name && !DRAWING_ANNOTATION.test(name)
148
+ && (catalogue.has(name) || STRUCTURAL_PROFILE.test(name) || CUSTOM_PROFILE.test(name)) ? name : '';
149
+ };
150
+ const sheetKey = (value) => String(value == null ? '' : value).trim().replace(/\s+/g, ' ').toUpperCase();
151
+ const bbox = (value) => Array.isArray(value) && value.length >= 4 && value.slice(0, 4).every(finite)
152
+ && Number(value[2]) >= Number(value[0]) && Number(value[3]) >= Number(value[1]);
153
+ const intersects = (a, b) => !b || (a[2] >= b[0] && a[0] <= b[2] && a[3] >= b[1] && a[1] <= b[3]);
154
+
155
+ function indexedFilterLabels(sheet) {
156
+ const cached = profileSheetIndex.get(sheet);
157
+ if (cached) return cached;
158
+ const out = [];
159
+ for (const entry of Array.isArray(sheet?.elements) ? sheet.elements : []) {
160
+ if (!entry || entry.kind !== 'text' || !bbox(entry.bbox)) continue;
161
+ const name = profileToken(entry.text);
162
+ if (!name) continue;
163
+ const box = entry.bbox.slice(0, 4).map(Number);
164
+ out.push({ text: name, disp: [(box[0] + box[2]) / 2, (box[1] + box[3]) / 2], bbox: box });
165
+ }
166
+ profileSheetIndex.set(sheet, out);
167
+ return out;
168
+ }
169
+
170
+ /**
171
+ * The bounded data source for the profile-pick overlay.
172
+ *
173
+ * Authored plan labels win. Only when there are none does the caller receive a Filter-text fallback,
174
+ * and that fallback is available only for one exact, case-folded sheet match. The Filter sheet's raw
175
+ * text is indexed once by object identity; designation-shape validation, viewport intersection and the
176
+ * DOM cap keep a 40k-element drawing from becoming a 40k-node overlay without hiding unresolved profiles.
177
+ */
178
+ export function planProfileLabelOverlay(plan, filter, options = {}) {
179
+ const max = Number.isSafeInteger(options.max) && options.max > 0 ? options.max : 500;
180
+ const viewport = bbox(options.viewport) ? options.viewport.slice(0, 4).map(Number) : null;
181
+ const catalogue = new Set((Array.isArray(options.profiles) ? options.profiles : []).map(canonicalProfile).filter(Boolean));
182
+ const explicit = [];
183
+ const seen = new Set();
184
+ for (const entry of Array.isArray(plan?.labels) ? plan.labels : []) {
185
+ if (!entry || !point(entry.disp)) continue;
186
+ const name = profileDesignation(entry.text, catalogue);
187
+ if (!name) continue;
188
+ const x = Number(entry.disp[0]), y = Number(entry.disp[1]), key = `${name}\0${x}\0${y}`;
189
+ if (seen.has(key)) continue;
190
+ seen.add(key);
191
+ explicit.push({ text: name, disp: [x, y], bbox: [x, y, x, y] });
192
+ }
193
+ let source = 'plan', candidates = explicit, diagnostic = null;
194
+ if (!explicit.length) {
195
+ const wanted = sheetKey(plan?.sheet);
196
+ const matches = (Array.isArray(filter?.sheets) ? filter.sheets : []).filter((sheet) => sheetKey(sheet?.sheet) === wanted);
197
+ if (matches.length !== 1) {
198
+ const action = ' Save the matching sheet in Drawing Filter, or choose a profile with Browse.';
199
+ diagnostic = matches.length
200
+ ? `Profile picking is unavailable because more than one Filter sheet matches ${text(plan?.sheet) || 'this plan'}.${action}`
201
+ : `Profile picking is unavailable because no Filter sheet matches ${text(plan?.sheet) || 'this plan'}.${action}`;
202
+ return { labels: [], source: 'none', hidden: 0, message: null, diagnostic };
203
+ }
204
+ source = 'filter';
205
+ const fallbackSeen = new Set();
206
+ candidates = indexedFilterLabels(matches[0]).filter((entry) => {
207
+ if (!profileDesignation(entry.text, catalogue)) return false;
208
+ const key = `${entry.text}\0${entry.bbox.join('\0')}`;
209
+ if (fallbackSeen.has(key)) return false;
210
+ fallbackSeen.add(key);
211
+ return true;
212
+ });
213
+ }
214
+ const visible = candidates.filter((entry) => intersects(entry.bbox, viewport));
215
+ const labels = visible.slice(0, max);
216
+ const hidden = visible.length - labels.length;
217
+ return {
218
+ labels, source, hidden, diagnostic,
219
+ message: hidden > 0 ? 'Zoom in to reveal the remaining profile labels' : null,
220
+ };
221
+ }
222
+
105
223
  /**
106
224
  * Callout kinds that are NOT details for scoring purposes.
107
225
  *