@floless/app 0.146.0 → 0.147.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.
@@ -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.61.0
10
+ version: 0.63.0
11
11
  ---
12
12
 
13
13
  # Steel Takeoff — read drawings into `steel.model/v2`
@@ -93,7 +93,9 @@ Do not read members before the user saves the Drawing Filter.
93
93
  Never build, rename, or replace server-owned Filter geometry yourself.
94
94
  2. Stop and ask the user to open **Drawing Filter**. Explain that a steel read may need more than
95
95
  steel lines: member/profile marks, grid labels, location or scale dimensions, and relevant
96
- detail/section callouts may be needed too. Tell them that while the Drawing Filter is open they
96
+ detail/section callouts may be needed too. Rows marked **not read** stay dimmed and cannot be
97
+ ticked; that is expected and the user has nothing to do about them. The read works from whatever
98
+ text FloLess did extract and, after Save, from the page picture where one is available (see below). Tell them that while the Drawing Filter is open they
97
99
  can ask FloLess's **AI Chat** on the left about any layer or the selection, or tell it what to
98
100
  change. When it proposes ticks, they appear as a card to review, apply with **Apply selection**,
99
101
  and Undo; nothing changes before that, and it never presses **Save filter**. Ask the user to review the
@@ -117,6 +119,34 @@ Each Filter sheet must carry:
117
119
  Reject duplicate sheet labels across the request. Never invent an id after the Filter is saved and never
118
120
  identify evidence by array position or geometry alone. The saved Filter is the evidence catalogue.
119
121
 
122
+ ### A layer marked "not read" is not a gap in the Filter
123
+
124
+ A Filter layer row carrying `notRead: true` was **withheld by FloLess's extraction, not switched off by
125
+ the user.** Every line such a layer draws — typically grid lines and bubbles, dimension lines, section
126
+ and callout marks on standard annotation layers — is left out of the elements, and the Drawing Filter
127
+ shows the row dimmed with a disabled tick box. On a CAD set with standard layer names that is often a
128
+ third of the layers. Nobody can tick one, and saving the Filter again changes nothing.
129
+
130
+ - **Never ask the user to include, tick or re-save for a `notRead` layer**, and never read one being off
131
+ in the saved Filter as a selection the user got wrong. A question whose only possible answer is
132
+ "carry on" must not be asked.
133
+ - **Get the content another way.** Live text is not withheld: grid labels, dimension strings and callout
134
+ text that the PDF holds as text arrive as `kind: "text"` elements (usually under layer `TEXT`, never
135
+ under the `notRead` layer itself) with positions in the page's point frame, so look there first.
136
+ Lettering DRAWN as linework on a `notRead` layer was withheld with the rest of it, so a label missing
137
+ from the text elements is not proof the sheet lacks it. Once the Filter is saved, read it and the
138
+ withheld linework off the page picture (`GET …/steel-manifest/pages/<pageId>/picture`, `part=0` for
139
+ the whole sheet, `1..9` for enlarged tiles; a `404` names its own fallback, so follow it). The
140
+ picture is context for grids, dimensions and annotation only: members still come from elements the
141
+ saved selection keeps.
142
+ - A `scaleProposals` refusal saying the sheet names **no grid family** is usually this same withholding,
143
+ and it is computed from the extracted elements, not from what the Filter selects, so no Filter change
144
+ can alter it. Handle that row as the scale section below describes, never by asking for a Filter
145
+ change.
146
+ - **Where a `notRead` layer genuinely limits the read, say so as a statement in your report** — name the
147
+ layer and what it stopped you reading — and carry on with everything else. Ask the user only a
148
+ question they can actually answer.
149
+
120
150
  ## Closed completion ledger
121
151
 
122
152
  Create one request-scoped ledger from the server manifest and keep it through every user correction.
@@ -577,7 +607,8 @@ A read often needs a throwaway script — a `.ps1` to probe pages, a `.mjs` to f
577
607
  one of them in the scratch directory the request instruction names** (`request-work/<requestId>/` under
578
608
  the FloLess home). FloLess creates that directory when the drawing set is attached and deletes it when
579
609
  the request settles or is discarded, so nothing there needs tidying up afterwards — and nothing you want
580
- to keep belongs there.
610
+ to keep belongs there. It may also be cleared while the read sits idle, so treat what is in it as
611
+ disposable between turns.
581
612
 
582
613
  **Never write a helper into the project folder or beside the drawings.** That folder is the user's own
583
614
  document, not a workspace: a `.ps1` left in it outlives the request that needed it, and the user has no
@@ -586,7 +617,30 @@ way to tell your scratch file apart from something of theirs.
586
617
  If the instruction names **no** scratch directory, use your own temporary location — still never the
587
618
  project, and do not go looking for a `request-work` path to create yourself. The server names that
588
619
  directory only when it created one and checked it, so its absence means the server deliberately declined
589
- to send you there.
620
+ to send you there. The same holds when a named directory has gone missing: do not re-create it, use your
621
+ own temporary location.
622
+
623
+ ### Stay inside this project and this request
624
+
625
+ A read works for **one** project and **one** request, and uses only what belongs to them: this project's
626
+ attached drawings, the server's responses for this request, and this request's scratch directory.
627
+
628
+ - **When the request instruction gives you an `X-FloLess-Read-Request` value, send that header on every
629
+ FloLess API call** for the request, the first queue fetch included. (A drawing read's instruction gives
630
+ one; a request that does not — a rebake, for example — has no read scope, so send none.) The server then
631
+ refuses any call that reaches another project, another request, or a route that is not part of a
632
+ drawing read. A refusal is the boundary, not a puzzle: do not retry without the header, and do not look
633
+ for the same data another way.
634
+ - **Never open, list or search** another project's folder or data under the FloLess home, another
635
+ request's scratch directory, another project's contract, chats or requests, the installed FloLess
636
+ application, or any FloLess source code — not over the API, not from disk. Another job's drawings,
637
+ sheet list, grid or model are another client's work: they say nothing reliable about this set, and
638
+ using them leaks one client's job into another's.
639
+ - If you cannot finish without something outside this boundary, **stop and say what you need**.
640
+ - **Disclose what you borrowed.** If anything in your answer did not come from this project's drawings or
641
+ this request's responses, say so plainly and name where it came from. Never write "I identified" or
642
+ "I read" for something you took from elsewhere.
643
+
590
644
 
591
645
  ## Read the drawings
592
646
 
@@ -2,7 +2,7 @@
2
2
  name: floless-app-vectorize
3
3
  description: Vectorize a drawing into an editable drawing.vector/v1 contract in floless.app — the "Vectorize" reader. Triggers on a pending floless `rebake` request for the `vectorize` app (queued from its "Re-read & re-bake ▸" button), or asks like "vectorize this PDF", "turn my sketch into clean CAD linework", "read this detail into vectors", "trace this photo", "make this drawing 3D". Teaches the host AI to read a drawing at COMPOSE time — a vector PDF via ONE deterministic PyMuPDF pass (no LLM), a scan/photo/hand sketch by MEASURING its ink with a deterministic OpenCV centerline tracer for geometry plus AWARE's fenced vision.extract for the text (schema-bound, cached) — emit the drawing.vector/v1 contract, PUT it to the contract store, and hand the 2D vector editor to the user; and, for a multi-view set (plan + elevation), to classify views, read datums, and declare entities so the server reconstructs a viewable 3D model.
4
4
  metadata:
5
- version: 0.8.1
5
+ version: 0.8.2
6
6
  ---
7
7
 
8
8
  # Vectorize — read a drawing into a drawing.vector/v1 contract
@@ -68,7 +68,30 @@ deliberately declined to send you there.
68
68
 
69
69
  Every helper, intermediate file, and generated `contract.json` stays under `<scratch>`. The user's project
70
70
  is their document, not this reader's workspace. FloLess removes a server-provided request directory when
71
- the request settles or is discarded; remove an OS-temporary fallback when this read finishes.
71
+ the request settles or is discarded, and clears it while the read sits idle; if a named directory has gone
72
+ missing, do not re-create it — use your own temporary location. Remove an OS-temporary fallback when this
73
+ read finishes.
74
+
75
+ ### Stay inside this project and this request
76
+
77
+ A read works for **one** project and **one** request, and uses only what belongs to them: this project's
78
+ attached drawings, the server's responses for this request, and this request's scratch directory.
79
+
80
+ - **When the request instruction gives you an `X-FloLess-Read-Request` value, send that header on every
81
+ FloLess API call** for the request, the first queue fetch included. (A drawing read's instruction gives
82
+ one; a request that does not — a rebake, for example — has no read scope, so send none.) The server then
83
+ refuses any call that reaches another project, another request, or a route that is not part of a
84
+ drawing read. A refusal is the boundary, not a puzzle: do not retry without the header, and do not look
85
+ for the same data another way.
86
+ - **Never open, list or search** another project's folder or data under the FloLess home, another
87
+ request's scratch directory, another project's contract, chats or requests, the installed FloLess
88
+ application, or any FloLess source code — not over the API, not from disk. Another job's drawings,
89
+ sheet list, grid or model are another client's work: they say nothing reliable about this set, and
90
+ using them leaks one client's job into another's.
91
+ - If you cannot finish without something outside this boundary, **stop and say what you need**.
92
+ - **Disclose what you borrowed.** If anything in your answer did not come from this project's drawings or
93
+ this request's responses, say so plainly and name where it came from. Never write "I identified" or
94
+ "I read" for something you took from elsewhere.
72
95
 
73
96
  ### 2. Pick the path — vector or raster?
74
97
 
@@ -218,6 +218,17 @@
218
218
  why: 'Clearing every value in a criterion you are matching on leaves nothing to match, so the drawing goes empty until you tick something back.',
219
219
  });
220
220
 
221
+ def('filter.size-switch-off', {
222
+ label: 'Switch off a value the read cannot fit',
223
+ actsOn: 'Unticks the one value the size notice names, exactly as unticking its own checkbox would',
224
+ group: 'In the Drawing Filter panel',
225
+ persistence: 'local',
226
+ interaction: 'instant',
227
+ risk: [],
228
+ guidance: 'on-demand',
229
+ why: 'Every selected line on a detail, notes or schedule sheet has to be named in the read’s proof, which is capped at 8 MB. The notice offers the one value that is enough on its own while taking the fewest lines off the sheets the read models from, or, when no single value is enough, the values carrying the most of those lines. Switching a value off also removes its lines from the sheets the read models from, so check none of them are steel.',
230
+ });
231
+
221
232
  /* ── the canvas ─────────────────────────────────────────────────────────── */
222
233
 
223
234
  def('filter.fit', {
@@ -860,3 +860,91 @@ export function coarseCurveNote(coarse, canIdentify) {
860
860
  : 'Find the value in the Filters panel instead.';
861
861
  return { title, body: `${why} ${next}` };
862
862
  }
863
+
864
+ /**
865
+ * What the Drawing Filter says, BEFORE Save, about whether the current selection can be read at all
866
+ * (#1780), or null when there is nothing to say.
867
+ *
868
+ * `payload` is the `exclusion-preview` reply for the selection on screen. Every selected line on a
869
+ * sheet the read does not model from (details, notes, schedules) has to be NAMED in the read's proof,
870
+ * and the proof has a byte cap, so a selection that ticks every line weight can be one no read can
871
+ * finish. Before this the person learned that only after Save, when the reader had already done its
872
+ * work and stopped to ask them to switch a weight off. On the real set it happened on, the reader
873
+ * named 0.4 pt, which is exactly the `suggestedOff` the server now computes from the same figures.
874
+ *
875
+ * Two levels, and the copy keeps them apart: `impossible` is a proof that no proof fits; `strained`
876
+ * only says the fit depends on the reader finding enough savings, which on that set it did not. So
877
+ * one says "is", the other "may be". Neither refuses anything: Save stays the person's call.
878
+ *
879
+ * `labelOf(dim, value)` renders a value exactly as its facet row does, so the notice and the checkbox
880
+ * it points at name the same thing the same way.
881
+ *
882
+ * Pure, so the wording, both levels and both suggestion shapes are table-tested without a page.
883
+ */
884
+ /**
885
+ * Whether a failed size check may be dropped SILENTLY (#1780). Only when there is no longer anything
886
+ * to check: the request is gone (404) or no longer waiting for a Filter save. Every other failure — a
887
+ * server error, a network drop, an unreadable reply, a scan the server cannot fold — leaves the
888
+ * question unanswered, and hiding the notice then reads as "this selection fits", which is the exact
889
+ * false negative the notice exists to prevent. Those show `SIZE_CHECK_FAILED_NOTICE` instead.
890
+ */
891
+ export function sizeCheckFailureIsQuiet(status, code) {
892
+ return status === 404 || code === 'steel-preview-not-pending';
893
+ }
894
+
895
+ /** What the Filter says when it could not find out whether the selection fits (see above). */
896
+ export const SIZE_CHECK_FAILED_NOTICE = Object.freeze({
897
+ level: 'unknown',
898
+ title: 'Couldn’t check whether this selection can be read',
899
+ lead: 'FloLess couldn’t work out how large this read’s proof would be. You can still save; if the selection is too large, the read will stop and ask you to switch a line weight off.',
900
+ suggestion: null,
901
+ alternatives: Object.freeze([]),
902
+ alternativesIntro: '',
903
+ });
904
+
905
+ export function proofSizeNotice(payload, labelOf) {
906
+ const budget = payload && payload.proofBudget;
907
+ if (!budget || typeof budget !== 'object') return null;
908
+ const impossible = budget.impossible === true;
909
+ if (!impossible && budget.strained !== true) return null;
910
+ const level = impossible ? 'impossible' : 'strained';
911
+ const count = (n) => (Number.isFinite(n) ? n : 0).toLocaleString('en-US');
912
+ const forced = payload.forcedRows && Number.isFinite(payload.forcedRows.total) ? payload.forcedRows.total : null;
913
+ const capMb = Number.isFinite(budget.capBytes) ? Math.round(budget.capBytes / (1024 * 1024)) : 8;
914
+ const title = impossible ? 'This selection is too large to read' : 'This selection may be too large to read';
915
+ const lead = `Every selected line on a sheet the read doesn’t model from (details, notes, schedules) has to be named in its proof, and a proof can hold ${capMb} MB.`
916
+ + (forced === null ? '' : ` This selection puts ${count(forced)} ${forced === 1 ? 'line' : 'lines'} there.`);
917
+ const relief = Array.isArray(payload.proofRelief) ? payload.proofRelief.filter((row) => row && typeof row === 'object'
918
+ && typeof row.dim === 'string' && Number.isFinite(row.forcedLines) && Number.isFinite(row.modelableLines)) : [];
919
+ const named = (row) => ({ dim: row.dim, value: row.value, label: labelOf(row.dim, row.value), forcedLines: row.forcedLines, modelableLines: row.modelableLines });
920
+ const cost = (row) => (row.modelableLines > 0
921
+ ? ` It also takes ${count(row.modelableLines)} ${row.modelableLines === 1 ? 'line' : 'lines'} of ${row.label} off the sheets the read models from, so check none of them are steel.`
922
+ : ' No lines on the sheets the read models from use it.');
923
+ const pick = payload.suggestedOff && typeof payload.suggestedOff === 'object'
924
+ ? relief.find((row) => row.dim === payload.suggestedOff.dim && row.value === payload.suggestedOff.value) : undefined;
925
+ if (pick) {
926
+ const row = named(pick);
927
+ return {
928
+ level, title, lead,
929
+ suggestion: { ...row, text: `Switching off ${row.label} takes out ${count(row.forcedLines)} of them.${cost(row)}`, action: `Switch off ${row.label}` },
930
+ alternatives: [], alternativesIntro: '',
931
+ };
932
+ }
933
+ // No single value is enough on its own: offer the ones carrying the most lines there, each as its
934
+ // own action. Never one button for all of them: which values to give up is the person's decision.
935
+ const alternatives = relief.filter((row) => row.forcedLines > 0)
936
+ .sort((a, b) => b.forcedLines - a.forcedLines || a.modelableLines - b.modelableLines)
937
+ .slice(0, 3)
938
+ .map((row) => {
939
+ const r = named(row);
940
+ return { ...r, text: `${r.label}: ${count(r.forcedLines)} there, ${count(r.modelableLines)} on sheets the read models from`, action: `Switch off ${r.label}` };
941
+ });
942
+ return {
943
+ level, title, lead,
944
+ suggestion: null,
945
+ alternatives,
946
+ alternativesIntro: alternatives.length
947
+ ? 'No single value is enough on its own. These carry the most lines there:'
948
+ : 'No single value the Filter can switch off is enough. Narrow the selection further before saving.',
949
+ };
950
+ }
@@ -209,6 +209,21 @@ button:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
209
209
  .signoff-notice[hidden]{display:none}
210
210
  .signoff-notice b{display:block;color:var(--warn);margin-bottom:2px}
211
211
  .signoff-notice p{margin:0;color:var(--text)}
212
+ /* #1780: the same amber rail, reused in the Filters panel to say BEFORE Save that the selection may be
213
+ too large for the read's proof. The panel's own 18px flex gap spaces it, so its bottom margin goes.
214
+ "Impossible" is a proven failure, not a risk, so it takes the page's existing --err on the same
215
+ shape; "strained" keeps --warn. No new colour either way. (The class keeps its `signoff` name: one
216
+ extra consumer does not earn a rename.) */
217
+ #filterSizeNotice{margin:0}
218
+ #filterSizeNotice p + p{margin-top:6px}
219
+ #filterSizeNotice.is-impossible{border-left-color:var(--err)}
220
+ #filterSizeNotice.is-impossible b{color:var(--err)}
221
+ #filterSizeNotice .size-suggest-action{margin-top:8px;font-size:12px;padding:4px 10px}
222
+ #filterSizeNotice ul{list-style:none;margin:6px 0 0;padding:0;display:grid;gap:6px}
223
+ #filterSizeNotice li{display:flex;align-items:center;gap:8px;justify-content:space-between;color:var(--text)}
224
+ #filterSizeNotice li span{min-width:0}
225
+ #filterSizeNotice .acts button{flex:none}
226
+ #filterSizeNotice .size-checking{color:var(--mut)}
212
227
  /* The magnitude. It sits ABOVE the list deliberately: the two sentences explain what a wholesale
213
228
  dismissal IS, and then this says how big it is — which is the decision. `<b>` for the number is
214
229
  the same bold-figure-in-a-muted-sentence idiom #count and .stat already use, so no new treatment.
@@ -679,6 +694,9 @@ body.publication-blocked #empty{position:static;flex:1}
679
694
  <p class="scope" id="filterScope"></p>
680
695
  <p id="filterCanvasRule"></p>
681
696
  </section>
697
+ <!-- #1780: whether the selection on screen can be read at all, checked by the server BEFORE Save.
698
+ Hidden while there is nothing to say or the check cannot run. A callout, not a titled section. -->
699
+ <div id="filterSizeNotice" class="signoff-notice" role="status" aria-live="polite" aria-atomic="true" hidden></div>
682
700
  <section id="modes">
683
701
  <h2>Match on</h2>
684
702
  <!-- The id sits on the INPUT, not on the wrapping <label>. Instructor's `activate()` (the `?`
@@ -870,7 +888,7 @@ body.publication-blocked #empty{position:static;flex:1}
870
888
  <script>window.OverlayEscape.mount({ idle: function () { var o = document.getElementById('signoffOverlay'); return !o || o.hidden; } });</script>
871
889
 
872
890
  <script type="module">
873
- import { matchesActive, modeDims, canonicalMode, selFromFilter, eyedropperAdd, eyedropperHas, eyedropperRemove, countShown, liveOverlayElements, bgRect, textBox, textDraw, textString, applySelToFilter, hasUnsupportedSingleSheetFilter, normalizeFilter, liveUpdateAction, statChip, newMutationId, sheetLabel, dismissibleFacetValues, switchOffBlockers, FACET_DIMS, FACET_DIM_BY_CONTROL, MODE_ORDER, facetKey, facetRowIndicesFor, NOTE_TEXT, coarseCurveNote } from './steel-filter-core.js';
891
+ import { matchesActive, modeDims, canonicalMode, selFromFilter, eyedropperAdd, eyedropperHas, eyedropperRemove, countShown, liveOverlayElements, bgRect, textBox, textDraw, textString, applySelToFilter, hasUnsupportedSingleSheetFilter, normalizeFilter, liveUpdateAction, statChip, newMutationId, sheetLabel, dismissibleFacetValues, switchOffBlockers, FACET_DIMS, FACET_DIM_BY_CONTROL, MODE_ORDER, facetKey, facetRowIndicesFor, NOTE_TEXT, coarseCurveNote, proofSizeNotice, sizeCheckFailureIsQuiet, SIZE_CHECK_FAILED_NOTICE } from './steel-filter-core.js';
874
892
  import { checkpointStandard } from './checkpoint-standard.js';
875
893
  import { filterAiBlockedLayerKeys, filterAiTouchesUnreadLayer, parseFilterAiProposal } from './filter-ai-proposal.js';
876
894
  import { readOnlyFilterContext, rankFilterControls, filterViewFingerprint } from './filter-ai-context.js';
@@ -1637,6 +1655,9 @@ window.__floRevisionCheckpoint = {
1637
1655
  history.replaceState(null, '', url.pathname + url.search);
1638
1656
  if(!dirty) setSaved(revisionRequest && revisionFilterSavedEtag === serverEtag ? 'saved' : '');
1639
1657
  syncRequiredSaveCue();
1658
+ // The size notice belongs to the checkpoint it was checked against (#1780): a new request voids
1659
+ // any answer in flight and anything on screen, and asks again for the new one.
1660
+ if(requestChanged) resetSizeCheck();
1640
1661
  return true;
1641
1662
  },
1642
1663
  };
@@ -2675,6 +2696,216 @@ function apply(){
2675
2696
  // cleared the halo and rows, and this puts them back on the pick. No re-scroll: the user may be working
2676
2697
  // in the very list it would move.
2677
2698
  if(eyeEl) openEyedropper(eyeAt.x, eyeAt.y, eyeEl, { rescroll: false });
2699
+ scheduleSizeCheck();
2700
+ }
2701
+
2702
+ /* ── can this selection be read at all? (#1780) ──────────────────────────────────────────────────
2703
+ Every selected line on a sheet the read does not model from has to be named in the read's proof,
2704
+ and the proof has an 8 MB cap. The default selection ticks every line weight, and on a real set
2705
+ that was a selection no read could finish; the person found out only after Save, when the reader
2706
+ stopped and asked them to switch a weight off. So the Filter asks the server's own preflight about
2707
+ the selection ON SCREEN (the same `exclusion-preview` fold the dismissal sign-off uses, and cached
2708
+ with it), and says so here, next to the controls that fix it.
2709
+
2710
+ Advisory: it never disables Save and never changes a tick by itself. Its one action is the click the
2711
+ person would make on the checkbox, offered by name, with what it also takes off the model sheets. */
2712
+ const sizeNoticeEl = document.getElementById('filterSizeNotice');
2713
+ const SIZE_CHECK_DEBOUNCE_MS = 600;
2714
+ let sizeCheckTimer = 0;
2715
+ let sizeCheckSeq = 0; // bumped when the page stops being a checkpoint: an answer in flight is then void
2716
+ let sizeCheckKey = ''; // the selection most recently asked about, so a repaint does not re-ask
2717
+ let sizeCheckWanted = null; // { key, request, body } — the latest selection still owed an answer
2718
+ // At most ONE check in flight. The server's fold is synchronous and cannot be cancelled, so a person
2719
+ // ticking down a list would otherwise queue fold after fold and hold up every other request the page
2720
+ // makes. While one runs, later edits only replace `sizeCheckWanted`; when it lands, the newest
2721
+ // selection is asked about once, and the answer for a superseded one is never painted.
2722
+ let sizeCheckInFlight = false;
2723
+
2724
+ /** The preview body for the selection on screen, without touching `F` (that is Save's job). */
2725
+ function proposedControlsBody(){
2726
+ const proposed = { mode };
2727
+ for(const dim of MODE_ORDER){
2728
+ const control = FACET_DIMS[dim].control;
2729
+ proposed[control] = ((F && F[control]) || []).map(row => ({ ...row }));
2730
+ }
2731
+ applySelToFilter(proposed, sel, mode);
2732
+ const body = { mode, layers: [], thicknesses: [], colors: [] };
2733
+ for(const dim of MODE_ORDER){
2734
+ const d = FACET_DIMS[dim];
2735
+ body[d.control] = proposed[d.control].map(row => ({ [d.rowKey]: row[d.rowKey], on: row.on === true }));
2736
+ }
2737
+ return body;
2738
+ }
2739
+
2740
+ function hideSizeNotice(){
2741
+ sizeNoticeEl.hidden = true;
2742
+ sizeNoticeEl.classList.remove('is-impossible');
2743
+ sizeNoticeEl.replaceChildren();
2744
+ }
2745
+
2746
+ /** Void everything about the previous checkpoint's size check, then ask about this one. */
2747
+ function resetSizeCheck(){
2748
+ clearTimeout(sizeCheckTimer);
2749
+ sizeCheckSeq++; sizeCheckKey = ''; sizeCheckWanted = null;
2750
+ hideSizeNotice();
2751
+ scheduleSizeCheck();
2752
+ }
2753
+
2754
+ function scheduleSizeCheck(){
2755
+ if(!revisionRequest || !C || !F || !sel){
2756
+ clearTimeout(sizeCheckTimer); sizeCheckSeq++; sizeCheckKey = ''; sizeCheckWanted = null; hideSizeNotice(); return;
2757
+ }
2758
+ const body = proposedControlsBody();
2759
+ const key = revisionRequest + '\n' + JSON.stringify(body);
2760
+ if(key === sizeCheckKey) return;
2761
+ sizeCheckKey = key;
2762
+ sizeCheckWanted = { key, request: revisionRequest, body };
2763
+ clearTimeout(sizeCheckTimer);
2764
+ // Replacing a notice that is already up: its figures describe the PREVIOUS selection, so they go now,
2765
+ // not when the answer lands. No digits while checking — a stale count read as current is worse than
2766
+ // none (the sign-off total's rule). A first check shows nothing until it has something to say.
2767
+ if(!sizeNoticeEl.hidden){
2768
+ sizeNoticeEl.classList.remove('is-impossible');
2769
+ const p = document.createElement('p'); p.className = 'size-checking';
2770
+ const spinner = document.createElement('span'); spinner.className = 'signoff-spinner'; spinner.setAttribute('aria-hidden', 'true');
2771
+ p.append(spinner, document.createTextNode('Checking whether this selection can be read…'));
2772
+ sizeNoticeEl.replaceChildren(p);
2773
+ }
2774
+ sizeCheckTimer = setTimeout(pumpSizeCheck, SIZE_CHECK_DEBOUNCE_MS);
2775
+ }
2776
+
2777
+ async function pumpSizeCheck(){
2778
+ if(sizeCheckInFlight || !sizeCheckWanted) return;
2779
+ const job = sizeCheckWanted;
2780
+ const seq = sizeCheckSeq;
2781
+ sizeCheckInFlight = true;
2782
+ let notice;
2783
+ try {
2784
+ notice = await runSizeCheck(job);
2785
+ } finally {
2786
+ sizeCheckInFlight = false;
2787
+ }
2788
+ // This page stopped being a checkpoint meanwhile: the answer is void, but a selection asked about
2789
+ // since (the checkpoint came back) is still owed one.
2790
+ if(seq !== sizeCheckSeq){ if(sizeCheckWanted) void pumpSizeCheck(); return; }
2791
+ if(sizeCheckWanted && sizeCheckWanted.key !== job.key){ void pumpSizeCheck(); return; } // superseded
2792
+ sizeCheckWanted = null;
2793
+ // A check that could not answer is not an answer: forget the key so the next repaint of this same
2794
+ // selection asks again, rather than leaving "couldn't check" up until the selection changes.
2795
+ if(notice === SIZE_CHECK_FAILED_NOTICE) sizeCheckKey = '';
2796
+ renderSizeNotice(notice);
2797
+ }
2798
+
2799
+ /** One check. Returns the notice to show, or null when there is nothing to say. Never throws. */
2800
+ async function runSizeCheck(job){
2801
+ let res;
2802
+ try {
2803
+ res = await fetch(`/api/projects/${encodeURIComponent(PROJECT)}/revision-requests/${encodeURIComponent(job.request)}/exclusion-preview`, {
2804
+ method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(job.body),
2805
+ });
2806
+ } catch(error){
2807
+ console.warn('steel-filter: the selection size check could not reach FloLess', error);
2808
+ return SIZE_CHECK_FAILED_NOTICE;
2809
+ }
2810
+ if(!res.ok){
2811
+ let code = null; try { code = (await res.json()).code || null; } catch(_){ code = null; }
2812
+ // Nothing left to check (the read moved on, or is gone): say nothing. Anything else leaves the
2813
+ // question open, and a hidden notice would read as "this fits" — so it says it could not check.
2814
+ if(sizeCheckFailureIsQuiet(res.status, code)) return null;
2815
+ console.warn('steel-filter: the selection size check was refused', res.status, code || '(no code)');
2816
+ return SIZE_CHECK_FAILED_NOTICE;
2817
+ }
2818
+ let payload = null;
2819
+ try { payload = await res.json(); } catch(_){ payload = null; }
2820
+ if(!payload || !payload.proofBudget || typeof payload.proofBudget !== 'object'){
2821
+ console.warn('steel-filter: the selection size check returned no proof budget');
2822
+ return SIZE_CHECK_FAILED_NOTICE;
2823
+ }
2824
+ return proofSizeNotice(payload, sizeValueLabel);
2825
+ }
2826
+
2827
+ /**
2828
+ * A value exactly as its facet row names it — the notice and the checkbox must say the same thing.
2829
+ * The row's own label function, over the row itself: a colour row shows its stored hex, which may be
2830
+ * upper-case while the server's canonical value is lower-case.
2831
+ */
2832
+ function sizeValueLabel(dim, value){
2833
+ if(dim === 'thickness') return thicknessLabel(value);
2834
+ const control = FACET_DIMS[dim].control;
2835
+ const row = ((F && F[control]) || []).find(r => facetKey(dim, r[FACET_DIMS[dim].rowKey]) === value);
2836
+ return row ? String(row[FACET_DIMS[dim].rowKey]) : String(value);
2837
+ }
2838
+
2839
+ function renderSizeNotice(notice){
2840
+ if(!notice){ hideSizeNotice(); return; }
2841
+ sizeNoticeEl.classList.toggle('is-impossible', notice.level === 'impossible');
2842
+ sizeNoticeEl.dataset.level = notice.level;
2843
+ const title = document.createElement('b'); title.textContent = notice.title;
2844
+ const lead = document.createElement('p'); lead.textContent = notice.lead;
2845
+ const parts = [title, lead];
2846
+ if(notice.suggestion){
2847
+ const s = notice.suggestion;
2848
+ const p = document.createElement('p'); p.textContent = s.text;
2849
+ const act = document.createElement('button');
2850
+ act.type = 'button'; act.className = 'size-suggest-action';
2851
+ act.setAttribute('data-command-id', 'filter.size-switch-off');
2852
+ act.dataset.dim = s.dim; act.dataset.value = String(s.value);
2853
+ act.textContent = s.action;
2854
+ act.onclick = () => switchOffFromNotice(s.dim, s.value);
2855
+ parts.push(p, act);
2856
+ } else {
2857
+ if(notice.alternativesIntro){
2858
+ const intro = document.createElement('p'); intro.textContent = notice.alternativesIntro;
2859
+ parts.push(intro);
2860
+ }
2861
+ if(notice.alternatives.length){
2862
+ const list = document.createElement('ul');
2863
+ for(const alt of notice.alternatives){
2864
+ const li = document.createElement('li');
2865
+ const text = document.createElement('span'); text.textContent = alt.text;
2866
+ const acts = document.createElement('span'); acts.className = 'acts';
2867
+ const act = document.createElement('button');
2868
+ act.type = 'button';
2869
+ act.setAttribute('data-command-id', 'filter.size-switch-off');
2870
+ act.dataset.dim = alt.dim; act.dataset.value = String(alt.value);
2871
+ act.setAttribute('aria-label', alt.action);
2872
+ act.textContent = 'switch off';
2873
+ act.onclick = () => switchOffFromNotice(alt.dim, alt.value);
2874
+ acts.appendChild(act);
2875
+ li.append(text, acts);
2876
+ list.appendChild(li);
2877
+ }
2878
+ parts.push(list);
2879
+ }
2880
+ }
2881
+ sizeNoticeEl.replaceChildren(...parts);
2882
+ sizeNoticeEl.hidden = false;
2883
+ }
2884
+
2885
+ /** The same edit as unticking the value's own checkbox, then focus lands ON that checkbox. */
2886
+ function switchOffFromNotice(dim, value){
2887
+ if(saveInFlight || !sel || !F) return;
2888
+ const facet = FACET_DIMS[dim] && FACET_DIMS[dim].control;
2889
+ if(!facet) return;
2890
+ const key = facetKey(dim, value);
2891
+ if(key === undefined || !setOf(facet).has(key)) return;
2892
+ setOf(facet).delete(key);
2893
+ syncFacetChecks(); markDirty(); apply();
2894
+ // The button that was clicked has just been replaced, so focus must land somewhere real: the value's
2895
+ // own checkbox, or — when a search in that list hides its row — the first visible control of that
2896
+ // list's search box (the only way a row is hidden is a search in that list), never <body> and never
2897
+ // the list's bulk all/none buttons, which would put a single-value edit's focus on a bulk action.
2898
+ const items = F[facet] || [];
2899
+ const boxes = document.querySelectorAll(`#facet-${facet} .opts input[type=checkbox]`);
2900
+ let target = null;
2901
+ for(let i = 0; i < items.length; i++){
2902
+ if(boxes[i] && facetRowKey(facet, items[i]) === key){ target = boxes[i]; break; }
2903
+ }
2904
+ if(!target || !target.offsetParent){
2905
+ const search = document.querySelector(`#facet-${facet} .facet-search-input`);
2906
+ if(search && search.offsetParent) target = search;
2907
+ }
2908
+ if(target){ target.focus(); target.scrollIntoView({ block: 'nearest' }); }
2678
2909
  }
2679
2910
 
2680
2911
  // --- modes + all/none ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.146.0",
3
+ "version": "0.147.0",
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": {