@floless/app 0.127.6 → 0.128.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.
@@ -214,7 +214,6 @@
214
214
  deliberately not a card like #ws-revision-card above: that one is Drawings-scoped and
215
215
  revision-shaped, and borrowing its weight for a one-time act would both misstate the
216
216
  frequency and compete with an actual pending read on the same project. Model-step only. -->
217
- <div class="ws-exports-gate ws-migrate-gate" id="ws-migrate-gate" hidden></div>
218
217
  <!-- Two lazily-srced iframes so switching steps never reloads the editor's 3D state.
219
218
  Same-origin like #contract-editor-frame (they call /api/contract directly). -->
220
219
  <iframe id="ws-frame-model" class="ws-frame" title="Project model editor" hidden></iframe>
@@ -651,32 +650,6 @@
651
650
  </div>
652
651
  </div>
653
652
 
654
- <!-- Convert to the model (steel.takeoff/v1 → steel.model/v2, unit 5, P7e).
655
- A SEPARATE element from #revreview-modal rather than a reuse of it: the two have different
656
- titles, different sub-copy and materially different Confirm semantics — that one applies a
657
- SELECTION and is legitimately clickable with nothing ticked, this one is all-or-nothing. Sharing
658
- the element would mean one Confirm handler with two meanings. It carries `revreview` so it
659
- inherits the whole .rev-* vocabulary (width, scroll, rows, themed checkboxes) for free, and
660
- `migreview` carries only the genuine deltas. -->
661
- <div class="modal-backdrop" id="migrate-modal" role="dialog" aria-modal="true" aria-labelledby="migrate-title">
662
- <div class="modal revreview migreview">
663
- <div class="modal-title" id="migrate-title">Convert to the 3D model</div>
664
- <div class="modal-sub" id="migrate-sub"></div>
665
- <div class="rev-changed" id="migrate-changed" role="status" aria-live="polite" hidden></div>
666
- <div class="rev-counts" id="migrate-counts"></div>
667
- <div class="revreview-body" id="migrate-body"></div>
668
- <!-- The tick progress, separate from the counts line above it: that one says what you GET, this
669
- one says what is left to do. Live region so the count reaches a screen reader as it moves. -->
670
- <div class="rev-counts mig-progress" id="migrate-progress" role="status" aria-live="polite" hidden></div>
671
- <div class="modal-actions">
672
- <button id="migrate-cancel">Cancel</button>
673
- <!-- Hidden outright when the conversion is refused, never shown disabled: a blocked migration
674
- is not something you can tick past, so an inert primary button would be an invitation. -->
675
- <button id="migrate-confirm" class="primary">Convert</button>
676
- </div>
677
- </div>
678
- </div>
679
-
680
653
  <!-- Save-on-switch confirmation — shown when switching workflows with unsaved
681
654
  input changes. Reuses the shared modal styling; no new backdrop look. -->
682
655
  <div class="modal-backdrop" id="confirm-modal" role="dialog" aria-modal="true"
@@ -13,17 +13,8 @@
13
13
  // node-card View 3D / Export IFC / Export BOM / Send to Tekla chain; other contract types would
14
14
  // 4xx or produce nonsense on those endpoints, so the shell hides the whole group.
15
15
  window.CONTRACT_RENDERERS = {
16
- 'steel.takeoff/v1': {
17
- editorUrl: (appId) => '/steel-editor.html?app=' + encodeURIComponent(appId),
18
- scene: true,
19
- },
20
- // The SAME editor page, deliberately — a migrated project is the same project, and sending its owner
21
- // to a different URL would say otherwise. What the editor then offers is narrower (P7d opens v2 for
22
- // viewing plus the model-grid edit); that is the editor's business, not the registry's.
23
- //
24
- // `scene: true` because the whole export chain reads v2: `contractToScene`, `contractToAwareScene` and
25
- // `contractToBom` all have v2 arms, and P7b wired the routes behind View 3D / Export IFC / Export BOM /
26
- // Send to Tekla to accept an activated store's v2. Marking it false would hide a group that works.
16
+ // Steel Model has one native editor and one native contract type. `scene: true` exposes its viewer
17
+ // and export chain.
27
18
  'steel.model/v2': {
28
19
  editorUrl: (appId) => '/steel-editor.html?app=' + encodeURIComponent(appId),
29
20
  scene: true,
@@ -40,7 +31,5 @@ window.CONTRACT_RENDERERS = {
40
31
  // A node "emits" a contract type when its config carries a `contract` field,
41
32
  // or when its agent is the known steel-takeoff agent.
42
33
  window.contractTypeOf = function contractTypeOf(node) {
43
- return (node && node.config && node.config.contract) ||
44
- // TODO: drop this agent-name fallback once every steel-takeoff node carries config.contract.
45
- (node && node.agent === 'steel-takeoff-us' ? 'steel.takeoff/v1' : null);
34
+ return (node && node.config && node.config.contract) || null;
46
35
  };
@@ -4065,7 +4065,7 @@ const memberById = (id) => { const all = (api && api.allMembers && api.allMember
4065
4065
  * ADAPTER boundary, not scattered `if (v2)` branches through the editor closure" — a branch per geometry
4066
4066
  * site is the shape this epic has rejected three times.
4067
4067
  *
4068
- * The host supplies BOTH arms. steel.takeoff/v1's is today's computation, moved verbatim — the per-plan
4068
+ * The host supplies the native steel.model/v2 computation — the per-plan
4069
4069
  * scale index, `planScaleOf`, `memberGeometryInOwnPlan` — so v1 stays byte-identical by construction
4070
4070
  * rather than by test. steel.model/v2's answers from world-mm members and needs none of it.
4071
4071
  *
@@ -1763,22 +1763,19 @@ const PROJECT_QS = PROJECT ? ('?project=' + encodeURIComponent(PROJECT)) : '';
1763
1763
  // the empty states below branch on, and never on the PUT — a write wants the ordinary refusal.
1764
1764
  const CONTRACT_QS = PROJECT ? (PROJECT_QS + '&quietMissing=1') : PROJECT_QS;
1765
1765
  // ── The browser draft's identity, and the contract type this page can render (unit 5, P1c-3) ──
1766
- // The one contract type this editor renders. A contract with NO `type` is legacy steel v1 — the server's
1766
+ // The one contract type this editor renders. A contract with no `type` is invalid — the server's
1767
1767
  // own validator says so and falls back to exactly this (contract-schema.ts, validateContract), so
1768
1768
  // diverging here would refuse documents this app itself wrote.
1769
- const EDITOR_TYPE = 'steel.takeoff/v1';
1770
1769
  // The canonical model format. New and migrated projects edit this shape through validated,
1771
1770
  // transactional commands; the v1 branch remains as a compatibility reader during the rollout.
1772
1771
  const MODEL_V2_TYPE = 'steel.model/v2';
1773
1772
  // P3's single activation switch. Reads and writes consult this same constant; there is no half-v2 mode.
1774
- const MODEL_V2_LIVE = true;
1775
1773
  // Every type this page will open. A type NOT in here is refused before anything mutates the document; the
1776
1774
  // refusal copy below still tells a newer STEEL model apart from "you opened the wrong workflow".
1777
- const OPENABLE_TYPES = [EDITOR_TYPE, MODEL_V2_TYPE];
1778
1775
  // The type the draft key is built from. Captured ONCE, right after boot() validates it, and never re-read
1779
1776
  // from `C` afterwards: `C` is mutable, and a key that can change identity mid-session would orphan the
1780
1777
  // draft it was writing (persist and restoreSaved would address different rows).
1781
- let DRAFT_TYPE = EDITOR_TYPE;
1778
+ let DRAFT_TYPE = MODEL_V2_TYPE;
1782
1779
  /**
1783
1780
  * Is the open document READ-ONLY to this editor?
1784
1781
  *
@@ -1793,7 +1790,7 @@ let DRAFT_TYPE = EDITOR_TYPE;
1793
1790
  * they never made. See docs/superpowers/specs/2026-07-26-steel-v2-p7d-design.md §8.4.
1794
1791
  *
1795
1792
  * This preserves the pre-activation safety gate without creating a half-live mode:
1796
- * MODEL_V2_LIVE enables both reads and canonical writes together.
1793
+ * v2 reads and canonical writes are always enabled together.
1797
1794
  */
1798
1795
  let MODEL_V2 = false;
1799
1796
  let MODEL_RO = false;
@@ -2214,10 +2211,10 @@ async function boot() {
2214
2211
  return;
2215
2212
  }
2216
2213
  const loadedType = loaded.type;
2217
- // A missing type is legacy steel v1 (see EDITOR_TYPE). Anything OPENABLE_TYPES does not name is refused
2214
+ // A missing or non-v2 type is refused
2218
2215
  // HERE, before the normalisation below starts mutating the document and before main() runs restoreSaved()
2219
2216
  // — which would otherwise overlay a steel draft onto a document of a different type entirely.
2220
- if (loadedType != null && !OPENABLE_TYPES.includes(loadedType)) {
2217
+ if (loadedType !== MODEL_V2_TYPE) {
2221
2218
  // Two different situations, and one message for both would be false in one of them. A newer
2222
2219
  // steel.model/* IS a Steel Model — just a format this build cannot draw yet — so telling that user
2223
2220
  // "this is not a Steel Model" would be plainly wrong. Anything else means they opened the wrong
@@ -2234,14 +2231,12 @@ async function boot() {
2234
2231
  }
2235
2232
  // Pin the draft identity for the rest of the session. Read once, from the validated value, never from
2236
2233
  // the mutable `C` — see draftKey().
2237
- DRAFT_TYPE = loadedType == null ? EDITOR_TYPE : loadedType;
2238
- MODEL_V2 = DRAFT_TYPE === MODEL_V2_TYPE;
2239
- MODEL_RO = MODEL_V2 && !MODEL_V2_LIVE; // reads and writes activate together; inactive means both refuse
2240
- if (MODEL_V2) {
2241
- const schemaRes = await fetch('/api/schema/steel-model-v2');
2242
- if (!schemaRes.ok) throw new Error('steel.model/v2 schema unavailable');
2243
- V2_SCHEMA = await schemaRes.json();
2244
- }
2234
+ DRAFT_TYPE = MODEL_V2_TYPE;
2235
+ MODEL_V2 = true;
2236
+ MODEL_RO = false;
2237
+ const schemaRes = await fetch('/api/schema/steel-model-v2');
2238
+ if (!schemaRes.ok) throw new Error('steel.model/v2 schema unavailable');
2239
+ V2_SCHEMA = await schemaRes.json();
2245
2240
  try {
2246
2241
  const hr = await fetch('/api/health');
2247
2242
  if (hr.ok) DEV_MODE = (await hr.json()).appChannel === 'dev';
@@ -2469,7 +2464,6 @@ const CHANGE_LEAD = Object.assign(Object.create(null), {
2469
2464
  //
2470
2465
  // The row above inherits this trade rather than re-deciding it: same phrase, one decision.
2471
2466
  'revision-read': 'The AI read a revised drawing set into this model',
2472
- 'migration': 'This project was converted to the 3D model',
2473
2467
  });
2474
2468
 
2475
2469
  /**
@@ -3548,7 +3542,7 @@ function v2DraftFits(d){
3548
3542
  // JSON compare: both sides descend from the same object graph (C → persist → JSON.parse), so key
3549
3543
  // order matches whenever the values do. A false "differs" would only cost a no-op offer; a false
3550
3544
  // "same" would drop the user's edit, so the comparison errs in the safe direction by construction.
3551
- if(MODEL_V2_LIVE){
3545
+ {
3552
3546
  const rootKeys=['members','grid','custom_details','profile_colors','member_styles','member_types','target_confidence','dims3d','dim_overlays','dim_style','prop_labels','joints','connections','detail_placements','views'];
3553
3547
  if(rootKeys.some(k=>k in d&&JSON.stringify(d[k])!==JSON.stringify(C&&C[k])))return true;
3554
3548
  // Asked through the SAME reconciliation the restore performs, or the two disagree: a draft that is
@@ -3559,7 +3553,7 @@ function v2DraftFits(d){
3559
3553
  // SAID PLAINLY: this whole function is UNREACHABLE today, so this arm has never executed. Its two
3560
3554
  // callers are `draftFits` — which short-circuits on `canWriteModel()` — and `applyDraftReadOnlyFields`,
3561
3555
  // which is itself behind `if(!canWriteModel())`. `canWriteModel()` is `!MODEL_RO`,
3562
- // `MODEL_RO = MODEL_V2 && !MODEL_V2_LIVE`, and `MODEL_V2_LIVE` is the constant `true`. It is kept
3556
+ // MODEL_RO is false for the canonical v2 editor. This compatibility logic is kept
3563
3557
  // aligned rather than left behind because the read-only mode is the thing that would resurrect it,
3564
3558
  // and a half-updated pair is how the original defect got in — but nothing exercises it, and a comment
3565
3559
  // claiming otherwise would be the same kind of lie this pass has been removing.
@@ -5108,7 +5102,7 @@ function stats(){
5108
5102
  // THE PREDICATE IS `NO_PLAN_VIEW`, AND IT USED TO BE `MODEL_RO` (#515). That was written when v2 was
5109
5103
  // read-only and had no plan projection at all, so "a v2 document" and "no per-sheet members" were the
5110
5104
  // same statement. They stopped being the same when v2 went live, and the guard did not follow:
5111
- // `MODEL_RO = MODEL_V2 && !MODEL_V2_LIVE` with `MODEL_V2_LIVE` the constant `true` makes it permanently
5105
+ // MODEL_RO is false for the canonical v2 editor, which makes it permanently
5112
5106
  // FALSE, so this branch was dead and a v2 model with no plan view printed exactly the zeros it exists to
5113
5107
  // prevent. A v2 model that DOES have a plan view is NOT the case being excluded: its `P.members` is the
5114
5108
  // real projection for that sheet, so its numbers are as honest as v1's and it keeps every one of them.
@@ -6314,7 +6308,7 @@ function _len3dFt(m,ppf,dTos){
6314
6308
  * Two traps met here, and both produced a confidently wrong number rather than an error:
6315
6309
  *
6316
6310
  * 1. THE PREDICATE IS THE FORMAT, NOT WRITABILITY. This shipped as `MODEL_RO ? …`, which was
6317
- * indistinguishable from MODEL_V2 while v2 was read-only. The moment MODEL_V2_LIVE turned on, MODEL_RO
6311
+ * indistinguishable from MODEL_V2 while v2 was read-only. Once canonical writes turned on, MODEL_RO
6318
6312
  * became permanently false and every v2 length fell back to the v1 plan path.
6319
6313
  * 2. ON v2 THE CALLER HANDS US A PROJECTED MEMBER. `selArr()`/`byId()` resolve through
6320
6314
  * `v2ProjectedMember`, which returns the plan-space twin (it carries `wp`, not `from`/`to`) because the
@@ -4,19 +4,19 @@
4
4
  *
5
5
  * The filter pre-stage isolates the real steel linework on a drawing before the takeoff reader binds
6
6
  * profile labels to it. The host AI runs ONE PyMuPDF pass at compose time and writes a `filter` block
7
- * onto the steel.takeoff/v1 contract; this module is the pure match/selection logic the view and the
7
+ * onto the steel.model/v2 contract; this module is the pure match/selection logic the view and the
8
8
  * reader both reason about. Lifted from the steel-parts-from-pdf.flo spike (`matchesActive`), extended
9
9
  * with persistence (`on` flags) and the eyedropper add.
10
10
  *
11
11
  * Shapes:
12
12
  * element : { kind:'line'|'text', layer:string, w:number, color:string, d?:string, text?:string, bbox?:number[], dashed?:boolean }
13
13
  * mode : any '+'-joined combo of 'layer'/'thickness'/'color', AND-ed (e.g. 'thickness+layer').
14
- * '' = match nothing. Canonical order = MODE_ORDER (keeps legacy 'thickness+…' strings).
14
+ * '' = match nothing. Canonical order = MODE_ORDER.
15
15
  * sel : { layers:Set<string>, thicknesses:Set<number>, colors:Set<string> }
16
16
  * filter : { mode, layers:[{name,count,steel?,drawable?,on?}], thicknesses:[{w,count,on?}], colors:[{hex,count,on?}], elements:[…] }
17
17
  */
18
18
 
19
- /** Canonical dimension order for a mode string — keeps legacy 'thickness+layer'/'thickness+color'. */
19
+ /** Canonical dimension order for a mode string. */
20
20
  const MODE_ORDER = ['thickness', 'layer', 'color'];
21
21
 
22
22
  /** The dimensions a mode activates, order-agnostic: 'thickness+layer' -> ['thickness','layer']. */
@@ -182,31 +182,11 @@ export function applySelToFilter(filter, sel, mode) {
182
182
  }
183
183
 
184
184
  /**
185
- * Multi-sheet normalizer. The shipped single-sheet filter carries `page`/`steelBbox`/`elements`
186
- * at the top level; the multi-sheet shape carries `sheets:[{sheet,title?,page,steelBbox,elements}]`
187
- * + `active`. This returns `{ sheets, active }` for both, wrapping a legacy filter into one sheet so
188
- * the view has a single code path. Facets (layers/thicknesses/colors) are GLOBAL and stay on the
189
- * filter object — they are not touched here.
190
- *
191
- * ponytail: back-compat bridge for pre-multisheet contracts. Upgrade path: drop the legacy branch
192
- * once no single-sheet contracts remain in the wild (the view migrates them forward on Save).
185
+ * Normalize the native multi-sheet Drawing Filter shape. Facets remain global on the filter object.
193
186
  */
194
187
  export function normalizeFilter(filter) {
195
188
  if (!filter || typeof filter !== 'object') return { sheets: [], active: 0 };
196
- let sheets;
197
- if (Array.isArray(filter.sheets)) {
198
- sheets = filter.sheets;
199
- } else if (Array.isArray(filter.elements) && filter.elements.length) {
200
- sheets = [{
201
- sheet: filter.sheet || '',
202
- title: filter.title,
203
- page: filter.page,
204
- steelBbox: filter.steelBbox,
205
- elements: filter.elements,
206
- }];
207
- } else {
208
- sheets = [];
209
- }
189
+ const sheets = Array.isArray(filter.sheets) ? filter.sheets : [];
210
190
  const n = sheets.length;
211
191
  const a = Number.isInteger(filter.active) ? filter.active : 0;
212
192
  const active = (n === 0 || a < 0 || a >= n) ? 0 : a;
@@ -254,7 +234,8 @@ export const NOTE_TEXT = 'Updated externally';
254
234
  export function statChip(state) {
255
235
  switch (state) {
256
236
  case 'dirty': return { cls: 'dirty', text: 'Unsaved ', badge: '●' };
257
- case 'saved': return { cls: 'saved', text: 'Saved ', badge: '✓' };
237
+ case 'saving': return { cls: '', text: 'Saving filter…', badge: null };
238
+ case 'saved': return { cls: 'saved', text: 'Filter saved ', badge: '✓' };
258
239
  case 'err': return { cls: 'err', text: 'Save failed ', badge: '✕' };
259
240
  // Not an error: the user's selection is fine, the model simply moved under them.
260
241
  case 'conflict': return { cls: 'conflict', text: 'Save conflict', badge: null };
@@ -190,7 +190,7 @@ body.publication-blocked #empty{position:static;flex:1}
190
190
  </head>
191
191
  <body>
192
192
  <header>
193
- <b>Steel filter</b>
193
+ <b>Drawing Filter</b>
194
194
  <!-- Ships hidden: a single-sheet set is not a choice, and buildSheetSwitcher() reveals it only when
195
195
  there is more than one sheet. See the .sheet-* rules for why this is not a <select>. -->
196
196
  <div class="sheet-combo" id="sheetCombo" hidden>
@@ -215,7 +215,7 @@ body.publication-blocked #empty{position:static;flex:1}
215
215
  <span id="src" class="stat"></span>
216
216
  <span class="sp"></span>
217
217
  <span id="saved" class="stat"></span>
218
- <button id="save" class="primary" disabled>Save</button>
218
+ <button id="save" class="primary" disabled>Save filter</button>
219
219
  </header>
220
220
  <div id="app">
221
221
  <aside id="panel">
@@ -256,7 +256,7 @@ body.publication-blocked #empty{position:static;flex:1}
256
256
  </svg>
257
257
  <div id="empty" role="status" aria-live="polite">
258
258
  <div>
259
- <h1>No filter data yet.</h1>
259
+ <h1>Drawing Filter isn’t ready yet.</h1>
260
260
  <p class="empty-body" hidden></p>
261
261
  <!-- "then reload" is GONE, and #441 is what earned that: until it landed, the pre-read verb
262
262
  (server/steel-prepass-route.ts) broadcast nothing at all, so this hint could only tell the user
@@ -271,7 +271,7 @@ body.publication-blocked #empty{position:static;flex:1}
271
271
  which broadcast) — that failure is the AI's to report, in the terminal where the user asked
272
272
  for it — and a re-bake whose result is canonically equal to what is already stored, where
273
273
  there is nothing new to show. -->
274
- <p class="hint" style="margin-top:8px;max-width:340px">Your terminal AI reads the drawing once (PyMuPDF) and bakes its layers, thicknesses and colours here. Use <b>Re-read &amp; re-bake ▸</b> on the canvas — this view updates on its own once it’s done.</p>
274
+ <p class="hint" style="margin-top:8px;max-width:340px">Ask your terminal AI to prepare the Drawing Filter. Its layers, line weights and colours will appear here automatically when ready.</p>
275
275
  </div>
276
276
  </div>
277
277
  <!-- The ONLY fit/zoom controls. Labels stay terse so both stay fully legible before the bar's
@@ -292,7 +292,7 @@ body.publication-blocked #empty{position:static;flex:1}
292
292
  import { matchesActive, modeDims, canonicalMode, selFromFilter, eyedropperAdd, countShown, liveOverlayElements, bgRect, textFontSize, applySelToFilter, normalizeFilter, liveUpdateAction, statChip, newMutationId, sheetLabel, NOTE_TEXT } from './steel-filter-core.js';
293
293
 
294
294
  const APP_ID = new URLSearchParams(location.search).get('app') || '';
295
- // Workspaces: project-keyed contract (see steel-editor.html). Empty = legacy app-keyed URLs.
295
+ // Workspaces use a project-keyed contract; an empty project id is the app-keyed workflow surface.
296
296
  const PROJECT = new URLSearchParams(location.search).get('project') || '';
297
297
  let revisionRequest = new URLSearchParams(location.search).get('revisionRequest') || '';
298
298
  const PROJECT_QS = PROJECT ? ('?project=' + encodeURIComponent(PROJECT)) : '';
@@ -500,7 +500,6 @@ const CHANGE_LEAD = Object.assign(Object.create(null), {
500
500
  // flattering "one small block" description this comment previously repeated.
501
501
  'pre-read': 'The AI started reading a drawing set into this model',
502
502
  'revision-read': 'The AI read a revised drawing set into this model',
503
- 'migration': 'This project was converted to the 3D model',
504
503
  });
505
504
 
506
505
  // A one-shot note handed to the NEXT load, so a populated view repainting under the user is explained
@@ -1102,7 +1101,7 @@ async function saveNow(){
1102
1101
  // A second click while already conflicted must NOT silently re-fire a request we know will fail —
1103
1102
  // just re-surface the explanation.
1104
1103
  if(conflicted){ showChangedBanner(); return; }
1105
- saveBtn.disabled = true; setSaved('');
1104
+ saveBtn.disabled = true; setSaved('saving');
1106
1105
  // Name this write BEFORE sending it, deliberately: the server broadcasts before it replies, so the echo
1107
1106
  // can reach our own listener while this `await` is still pending — and an id we did not yet know would
1108
1107
  // read as somebody else's write. NOT a self-reload, as an earlier version of this comment claimed: save()
@@ -1115,6 +1114,7 @@ async function saveNow(){
1115
1114
  // BAKED fallback (the GET tags only store-backed documents) — this app has no draft yet — so the
1116
1115
  // honest precondition is `If-None-Match: *`, "I believe this store is empty".
1117
1116
  if(serverEtag) headers['if-match'] = serverEtag; else headers['if-none-match'] = '*';
1117
+ if(revisionRequest) headers['x-floless-filter-request'] = revisionRequest;
1118
1118
  const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS, { method: 'PUT', headers, body: JSON.stringify(C) });
1119
1119
  if(res.status === 428){ // a writer here sent no precondition — a bug in our code, not a user error.
1120
1120
  // NOT the conflict copy: nothing else wrote, so "changed somewhere else" would be a lie. This bar