@floless/app 0.134.1 → 0.134.2
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.
- package/dist/floless-server.cjs +1240 -136
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +244 -30
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +18 -1
- package/dist/web/commands-filter.js +16 -13
- package/dist/web/commands-steel.js +32 -4
- package/dist/web/commands.js +4 -0
- package/dist/web/connection-review-client.js +120 -0
- package/dist/web/index.html +6 -1
- package/dist/web/instructor.js +21 -7
- package/dist/web/steel-3d-core.js +101 -7
- package/dist/web/steel-3d-view.js +757 -242
- package/dist/web/steel-canvas-guidance.js +9 -1
- package/dist/web/steel-editor.html +1198 -77
- package/dist/web/steel-filter-core.js +53 -22
- package/dist/web/steel-filter.html +469 -77
- package/dist/web/steel-model-v2-client-validation.js +6 -0
- package/dist/web/workspaces.js +108 -33
- package/package.json +2 -1
|
@@ -162,14 +162,40 @@ button:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
|
|
|
162
162
|
.signoff-notice[hidden]{display:none}
|
|
163
163
|
.signoff-notice b{display:block;color:var(--warn);margin-bottom:2px}
|
|
164
164
|
.signoff-notice p{margin:0;color:var(--text)}
|
|
165
|
+
/* The magnitude. It sits ABOVE the list deliberately: the two sentences explain what a wholesale
|
|
166
|
+
dismissal IS, and then this says how big it is — which is the decision. `<b>` for the number is
|
|
167
|
+
the same bold-figure-in-a-muted-sentence idiom #count and .stat already use, so no new treatment.
|
|
168
|
+
The pending and failed states carry NO DIGITS AT ALL: a wrong magnitude on this screen is worse
|
|
169
|
+
than none, and a sentence with no number in it cannot be misread as one. */
|
|
170
|
+
.signoff-total{margin:0 0 12px;color:var(--mut);font-size:12.5px;line-height:1.5}
|
|
171
|
+
.signoff-total b{color:var(--text);font-weight:600}
|
|
165
172
|
/* A scroll container — themed by the global `*` scrollbar rules at the top of this sheet, exactly as
|
|
166
|
-
.sheet-list is, so no native white bar can appear inside the modal.
|
|
167
|
-
.
|
|
173
|
+
.sheet-list is, so no native white bar can appear inside the modal.
|
|
174
|
+
NO padding here, unlike .sheet-list: `position:sticky` on the group headings computes against the
|
|
175
|
+
scrollport's padding edge, so a padded container lets a scrolling row peek above its own heading. */
|
|
176
|
+
.signoff-list{margin:0;padding:0;overflow-y:auto;flex:1;min-height:0;border:1px solid var(--line);border-radius:6px;background:var(--bg)}
|
|
168
177
|
.signoff-list[hidden]{display:none}
|
|
178
|
+
.signoff-group{padding:0 0 4px}
|
|
179
|
+
/* Sticky, because a real set is 17 line-weight rows plus 8 colour rows plus every off layer inside a
|
|
180
|
+
560px box: scrolled halfway down it, a human otherwise cannot tell WHICH dimension they are
|
|
181
|
+
approving. Same background as the list so there is no seam, and no new token. */
|
|
182
|
+
.signoff-group-heading{position:sticky;top:0;z-index:1;margin:0;padding:6px 8px;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--mut);background:var(--bg);border-bottom:1px solid var(--line)}
|
|
183
|
+
.signoff-rows{list-style:none;margin:0;padding:4px}
|
|
169
184
|
.signoff-row{display:flex;align-items:baseline;gap:10px;padding:6px 8px;font-size:12.5px;border-bottom:1px solid var(--line)}
|
|
170
185
|
.signoff-row:last-child{border-bottom:none}
|
|
186
|
+
/* The one place a NON-BASELINE colour legitimately appears on this surface: it renders drawing data,
|
|
187
|
+
not chrome. The 1px --ctrl-border ring is what keeps a white or near-white swatch visible against
|
|
188
|
+
the dark ground — the swatch square IS the chip. A third scope of the same 12px declaration the
|
|
189
|
+
panel and the eyedropper already carry; `align-self` corrects for the row's baseline alignment,
|
|
190
|
+
which would otherwise hang the square off the text baseline. */
|
|
191
|
+
.signoff-row .sw{width:12px;height:12px;border-radius:3px;border:1px solid var(--ctrl-border);flex:none;align-self:center}
|
|
171
192
|
.signoff-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)}
|
|
172
193
|
.signoff-count{flex:none;color:var(--mut);font-size:11px;cursor:default}
|
|
194
|
+
/* Always visible, never tooltip-gated. Two different populations are on screen at once — per-row
|
|
195
|
+
ELEMENT counts and a ledger-LINE total — and a human who adds the rows up will not get the total.
|
|
196
|
+
A hover-only disclaimer is optimistic that anyone finds it. */
|
|
197
|
+
.signoff-caption{margin:8px 0 14px;color:var(--mut);font-size:11px;line-height:1.4}
|
|
198
|
+
.signoff-caption[hidden]{display:none}
|
|
173
199
|
.signoff-actions{display:flex;justify-content:flex-end;gap:8px;flex:none}
|
|
174
200
|
.signoff-actions button[hidden]{display:none}
|
|
175
201
|
/* Themed tooltip — replaces native title= so no light OS tooltip leaks onto the dark theme. */
|
|
@@ -350,9 +376,15 @@ body.publication-blocked #empty{position:static;flex:1}
|
|
|
350
376
|
<aside id="panel">
|
|
351
377
|
<section id="modes">
|
|
352
378
|
<h2>Match on</h2>
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
379
|
+
<!-- The id sits on the INPUT, not on the wrapping <label>. Instructor's `activate()` (the `?`
|
|
380
|
+
sheet's Enter) queries for the carrier and then calls `.focus()` on it — and a <label> is
|
|
381
|
+
not focusable, so a label carrier silently failed to take the user to the control and fell
|
|
382
|
+
back to describing it. `accessibleNameOf` reads a wrapping label for an input, so the
|
|
383
|
+
control still announces "Layer"; nothing is lost by moving the id inward, and the hover
|
|
384
|
+
path is unchanged because `Commands.resolve` walks UP from whatever is hovered. -->
|
|
385
|
+
<label><input type="checkbox" name="dim" value="layer" data-command-id="filter.match-on" checked /> Layer</label>
|
|
386
|
+
<label><input type="checkbox" name="dim" value="thickness" data-command-id="filter.match-on" /> Thickness</label>
|
|
387
|
+
<label><input type="checkbox" name="dim" value="color" data-command-id="filter.match-on" /> Color</label>
|
|
356
388
|
<p class="hint">Checked criteria must all match (AND).</p>
|
|
357
389
|
</section>
|
|
358
390
|
<section class="facet" id="facet-layers">
|
|
@@ -417,20 +449,24 @@ body.publication-blocked #empty{position:static;flex:1}
|
|
|
417
449
|
<button class="eall primary" id="eyeAddAll" data-command-id="filter.eyedropper-add">Add all to filter</button>
|
|
418
450
|
</div>
|
|
419
451
|
|
|
420
|
-
<!-- The
|
|
421
|
-
OFF
|
|
422
|
-
so this is where a human takes that decision
|
|
423
|
-
to change the list, Cancel and re-tick in the
|
|
452
|
+
<!-- The exclusion sign-off confirm step. Only ever opened for a revision read that has something
|
|
453
|
+
switched OFF on a dimension it is matching on: those are the values whose every matching element
|
|
454
|
+
the completion proof may later dismiss as a group, so this is where a human takes that decision
|
|
455
|
+
on the record. Nothing in the list is interactive — to change the list, Cancel and re-tick in the
|
|
456
|
+
panel, which is the one place selection is edited.
|
|
457
|
+
The list is GROUPED by dimension with a visible heading per group, which is why the old sr-only
|
|
458
|
+
list label is gone: each group's <ul> is labelled by its own <h3>, which says more, not less. -->
|
|
424
459
|
<div id="signoffOverlay" hidden>
|
|
425
460
|
<div id="signoffPanel" role="dialog" aria-modal="true" aria-labelledby="signoffTitle" aria-describedby="signoffDesc">
|
|
426
|
-
<h2 id="signoffTitle">Confirm
|
|
427
|
-
<p class="signoff-desc" id="signoffDesc">These
|
|
461
|
+
<h2 id="signoffTitle">Confirm what this read will dismiss</h2>
|
|
462
|
+
<p class="signoff-desc" id="signoffDesc">These values are switched off in your filter, so this read treats every element matching them as not steel — dismissed as a group, with no line-by-line reason. Values left on can’t be dismissed this way.</p>
|
|
463
|
+
<p class="signoff-total" id="signoffTotal" role="status"></p>
|
|
428
464
|
<div class="signoff-notice" id="signoffNotice" role="status" hidden></div>
|
|
429
|
-
<
|
|
430
|
-
<
|
|
465
|
+
<div class="signoff-list" id="signoffList"></div>
|
|
466
|
+
<p class="signoff-caption" id="signoffCaption">Row counts are elements, not split by page role. The total above is lines this read may dismiss.</p>
|
|
431
467
|
<div class="signoff-actions">
|
|
432
468
|
<button id="signoffCancel" data-command-id="filter.signoff-cancel">Cancel</button>
|
|
433
|
-
<button id="signoffApprove" class="primary" data-command-id="filter.signoff-approve">Approve these
|
|
469
|
+
<button id="signoffApprove" class="primary" data-command-id="filter.signoff-approve">Approve these exclusions</button>
|
|
434
470
|
<button id="signoffClose" data-command-id="filter.signoff-close" hidden>Close</button>
|
|
435
471
|
<button id="signoffReload" class="primary" data-command-id="filter.signoff-reload" hidden>Reload page</button>
|
|
436
472
|
</div>
|
|
@@ -449,7 +485,7 @@ body.publication-blocked #empty{position:static;flex:1}
|
|
|
449
485
|
<script>window.InstructorReporter.mount({ surface: 'steel-filter' });</script>
|
|
450
486
|
|
|
451
487
|
<script type="module">
|
|
452
|
-
import { matchesActive, modeDims, canonicalMode, selFromFilter, eyedropperAdd, countShown, liveOverlayElements, bgRect, textFontSize, applySelToFilter, hasUnsupportedSingleSheetFilter, normalizeFilter, liveUpdateAction, statChip, newMutationId, sheetLabel,
|
|
488
|
+
import { matchesActive, modeDims, canonicalMode, selFromFilter, eyedropperAdd, countShown, liveOverlayElements, bgRect, textFontSize, applySelToFilter, hasUnsupportedSingleSheetFilter, normalizeFilter, liveUpdateAction, statChip, newMutationId, sheetLabel, dismissibleFacetValues, FACET_DIMS, FACET_DIM_BY_CONTROL, MODE_ORDER, facetKey, NOTE_TEXT } from './steel-filter-core.js';
|
|
453
489
|
|
|
454
490
|
const APP_ID = new URLSearchParams(location.search).get('app') || '';
|
|
455
491
|
// Workspaces use a project-keyed contract; an empty project id is the app-keyed workflow surface.
|
|
@@ -1403,7 +1439,6 @@ function buildFacet(facet, items, label){
|
|
|
1403
1439
|
const key = facetRowKey(facet, it);
|
|
1404
1440
|
const isText = facet === 'layers' && it.drawable === false;
|
|
1405
1441
|
const wrap = document.createElement('label');
|
|
1406
|
-
wrap.setAttribute('data-command-id', 'filter.facet-toggle');
|
|
1407
1442
|
// The no-value case is tested BEFORE `isText` on purpose: a layer row can be both undrawable and
|
|
1408
1443
|
// wrong-typed, and if .textlayer won it would render as an ordinary muted row with a checkbox that
|
|
1409
1444
|
// silently refuses to stay ticked and no explanation — this slice's own defect, relocated.
|
|
@@ -1416,6 +1451,17 @@ function buildFacet(facet, items, label){
|
|
|
1416
1451
|
} else if(isText) wrap.className = 'textlayer';
|
|
1417
1452
|
const cb = document.createElement('input');
|
|
1418
1453
|
cb.type = 'checkbox';
|
|
1454
|
+
// The id sits on the CHECKBOX, not on the <label> wrapping the row, and the difference is
|
|
1455
|
+
// reachability rather than pedantry. Instructor's `activate()` finds the carrier by selector and
|
|
1456
|
+
// calls `.focus()` on it; a <label> is not focusable, so from the `?` sheet "Include a value"
|
|
1457
|
+
// could never take the user to the control and fell back to merely describing it. On the input it
|
|
1458
|
+
// focuses, and `focusFor` — which resolves upward through `closest('… input …')` — then reads the
|
|
1459
|
+
// very state this row goes out of its way to expose: `aria-disabled` and `data-blocked-reason`.
|
|
1460
|
+
// The row still announces its layer/width/colour, because `accessibleNameOf` names a form control
|
|
1461
|
+
// from its wrapping label. Hovering is unaffected: `Commands.resolve` walks up from the hovered
|
|
1462
|
+
// node, and the checkbox is what a pointer lands on. (`vector.show-kind` keeps the label carrier
|
|
1463
|
+
// for now — a different surface, and not this slice's to change.)
|
|
1464
|
+
cb.setAttribute('data-command-id', 'filter.facet-toggle');
|
|
1419
1465
|
cb.checked = key !== undefined && setOf(facet).has(key);
|
|
1420
1466
|
cb.value = String(val);
|
|
1421
1467
|
// syncFacetChecks(), not just this one box: two rows whose values canonicalise the same (a
|
|
@@ -1693,71 +1739,192 @@ function blockRequiredCheckpointSave(message){
|
|
|
1693
1739
|
showChangedBanner(message, { dismissible:false, requiredRecovery:true });
|
|
1694
1740
|
}
|
|
1695
1741
|
|
|
1696
|
-
/* ── the
|
|
1697
|
-
A
|
|
1698
|
-
no line-by-line reason. So for a revision read, Save
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1742
|
+
/* ── the exclusion sign-off confirm step ────────────────────────────────────────────
|
|
1743
|
+
A value switched OFF on a dimension the filter matches on is one whose every matching element the
|
|
1744
|
+
completion proof may dismiss as a group, with no line-by-line reason. So for a revision read, Save
|
|
1745
|
+
first shows the human exactly that list — grouped by dimension — and asks them to approve it; the
|
|
1746
|
+
ordered {dim, value} pairs ride out with the Save and the server records the approval against them.
|
|
1747
|
+
Nothing dismissible means nothing is being dismissed wholesale, so there is no decision to record
|
|
1748
|
+
and the step is skipped entirely rather than shown empty.
|
|
1749
|
+
|
|
1750
|
+
Generalised from layers alone in #805 Phase D. On a FLATTENED drawing set — no optional-content
|
|
1751
|
+
groups, every element on one synthetic layer name — the layer facet carries no information at all
|
|
1752
|
+
and this step could dismiss nothing, which is why line weight is now here too. */
|
|
1753
|
+
let signoffValues = []; // the ordered [{dim, value}] currently displayed and about to be submitted
|
|
1703
1754
|
let pendingSignOff = null; // handed to saveNow for exactly one checkpoint POST
|
|
1704
|
-
let signoffOutcome = null; // a
|
|
1755
|
+
let signoffOutcome = null; // a refusal code, for the notice below
|
|
1705
1756
|
let signoffBusy = false; // a write is in flight: dismissal is locked
|
|
1757
|
+
let signoffPreview = null; // the server's reply: { manifestHash, controlsHash, potentialLines }
|
|
1758
|
+
let signoffPreviewState = 'idle'; // 'idle' | 'pending' | 'ok' | 'failed'
|
|
1759
|
+
let signoffPreviewSeq = 0; // ONE in-flight preview; a stale reply is ignored, never rendered
|
|
1706
1760
|
const signoffOverlay = document.getElementById('signoffOverlay');
|
|
1707
1761
|
const signoffPanel = document.getElementById('signoffPanel');
|
|
1708
1762
|
const signoffList = document.getElementById('signoffList');
|
|
1763
|
+
const signoffTotal = document.getElementById('signoffTotal');
|
|
1764
|
+
const signoffCaption = document.getElementById('signoffCaption');
|
|
1709
1765
|
const signoffNotice = document.getElementById('signoffNotice');
|
|
1710
1766
|
const signoffCancel = document.getElementById('signoffCancel');
|
|
1711
1767
|
const signoffApprove = document.getElementById('signoffApprove');
|
|
1712
1768
|
const signoffCloseBtn = document.getElementById('signoffClose');
|
|
1713
1769
|
const signoffReload = document.getElementById('signoffReload');
|
|
1714
|
-
const SIGNOFF_APPROVE_LABEL = 'Approve these
|
|
1770
|
+
const SIGNOFF_APPROVE_LABEL = 'Approve these exclusions';
|
|
1771
|
+
/* Long enough that a slow fold on a 120,000-element set still lands, short enough that a hung request
|
|
1772
|
+
does not leave the modal waiting forever — §4.3b requires the modal not to block on one. A timeout
|
|
1773
|
+
resolves to the FAILED state, which is a real state with a way out, not a spinner nobody can leave. */
|
|
1774
|
+
const SIGNOFF_PREVIEW_TIMEOUT_MS = 30_000;
|
|
1775
|
+
|
|
1776
|
+
/** The visible heading for each dimension's group, in MODE_ORDER.
|
|
1777
|
+
* "Line weight", not "Thickness": this is a structural-steel product, where "thickness" reads as
|
|
1778
|
+
* PLATE thickness. On the one screen where a human authorises dismissing elements, the drawn-line
|
|
1779
|
+
* meaning has to be unambiguous. (The panel's own checkbox still says "Thickness"; flagged.) */
|
|
1780
|
+
const SIGNOFF_GROUP_LABEL = { thickness: 'Line weight', layer: 'Layer', color: 'Color' };
|
|
1781
|
+
|
|
1782
|
+
/** What each row's count actually counts — per dimension, because they are not the same population.
|
|
1783
|
+
* The extractor never counts a text span into `width_counts`, so a line-weight count is drawn
|
|
1784
|
+
* geometry only, while a layer or colour count includes text and circles. Every one of them ends by
|
|
1785
|
+
* pointing at the total, because the two numbers are not reconcilable by arithmetic and a human who
|
|
1786
|
+
* adds the rows up must not read the difference as a bug. */
|
|
1787
|
+
const SIGNOFF_COUNT_TIP = {
|
|
1788
|
+
thickness: 'Every line and circle drawn at this weight across the whole drawing set — text is not counted here, and this is not the same population as the total above.',
|
|
1789
|
+
layer: 'Every element on this layer across the whole drawing set — lines, text and circles included — not the same population as the total above.',
|
|
1790
|
+
color: 'Every element in this colour across the whole drawing set — lines, text and circles included — not the same population as the total above.',
|
|
1791
|
+
};
|
|
1715
1792
|
|
|
1716
|
-
/** What the human is told when
|
|
1717
|
-
*
|
|
1718
|
-
*
|
|
1793
|
+
/** What the human is told when an approval cannot proceed.
|
|
1794
|
+
*
|
|
1795
|
+
* `saved` is load-bearing and is why this is a table rather than two strings. The three server
|
|
1796
|
+
* refusals arrive AFTER the contract PUT has committed — that is what the checkpoint route is for —
|
|
1797
|
+
* so their copy truthfully opens by saying the filter edit is safe. The preview failure happens
|
|
1798
|
+
* BEFORE the PUT, where the opposite is true, and telling that human their changes were saved would
|
|
1799
|
+
* be a plain lie on the one screen that cannot afford one. */
|
|
1719
1800
|
const SIGNOFF_PROBLEMS = {
|
|
1720
|
-
'steel-
|
|
1721
|
-
|
|
1722
|
-
|
|
1801
|
+
'steel-exclusion-signoff-stale': {
|
|
1802
|
+
saved: true,
|
|
1803
|
+
title: 'The exclusion list changed since you approved it',
|
|
1804
|
+
body: 'Your filter changes were saved. This page is now showing an out-of-date list, so approving it again would be refused for the same reason — reload to see what this read would really dismiss and approve that.',
|
|
1805
|
+
},
|
|
1806
|
+
'steel-exclusion-preview-stale': {
|
|
1807
|
+
saved: true,
|
|
1808
|
+
title: 'This drawing set was re-scanned while you were reviewing',
|
|
1809
|
+
body: 'Your filter changes were saved. The counts you were shown describe an older scan of this drawing set, so the approval was refused rather than recorded against evidence you did not see — reload and approve what the current scan shows.',
|
|
1723
1810
|
},
|
|
1724
1811
|
'steel-census-scope-missing': {
|
|
1725
|
-
|
|
1726
|
-
|
|
1812
|
+
saved: true,
|
|
1813
|
+
title: 'This read can’t record an approval yet',
|
|
1814
|
+
body: 'Your filter changes were saved. This request’s drawing scan was made before whole-set approval existed and covers only the model sheets — ask your terminal AI to re-read this revision, then reload and approve the list.',
|
|
1815
|
+
},
|
|
1816
|
+
// ── the PREVIEW's refusals. Every one of these happens BEFORE the contract PUT, so every one says
|
|
1817
|
+
// the changes are not saved — which is why they cannot simply reuse the entries above even where
|
|
1818
|
+
// the server code is the same word. `steel-census-scope-missing` is the case that forced this
|
|
1819
|
+
// table into existence: collapsing every preview failure into the generic entry below told the
|
|
1820
|
+
// human to "press Save again", which re-previews, fails identically, and loops forever, while the
|
|
1821
|
+
// sentence that would actually help was already written three entries up and unreachable.
|
|
1822
|
+
'preview:steel-census-scope-missing': {
|
|
1823
|
+
saved: false,
|
|
1824
|
+
title: 'This read can’t work out what it would dismiss yet',
|
|
1825
|
+
body: 'Your filter changes have NOT been saved. This request’s drawing scan was made before whole-set approval existed and covers only the model sheets — ask your terminal AI to re-read this revision, then reload.',
|
|
1826
|
+
},
|
|
1827
|
+
'preview:steel-manifest-missing': {
|
|
1828
|
+
saved: false,
|
|
1829
|
+
title: 'This read’s drawing scan is missing',
|
|
1830
|
+
body: 'Your filter changes have NOT been saved. The server no longer holds a coherent scan of this drawing set — ask your terminal AI to re-scan this revision, then reload.',
|
|
1831
|
+
},
|
|
1832
|
+
'preview:steel-manifest-unrepresentable': {
|
|
1833
|
+
saved: false,
|
|
1834
|
+
title: 'This read’s drawing scan is incomplete',
|
|
1835
|
+
body: 'Your filter changes have NOT been saved. One sheet in this scan does not record what it contains, so nothing can say what excluding a value would dismiss — ask your terminal AI to re-scan this revision, then reload.',
|
|
1836
|
+
},
|
|
1837
|
+
'preview:steel-manifest-ledger-unbound': {
|
|
1838
|
+
saved: false,
|
|
1839
|
+
title: 'This scan and this filter describe different drawing sets',
|
|
1840
|
+
body: 'Your filter changes have NOT been saved. The scan on the server no longer matches the filter on this page, so no count of what would be dismissed can be trusted — ask your terminal AI to re-scan this revision, then reload.',
|
|
1841
|
+
},
|
|
1842
|
+
'preview:steel-preview-controls-stale': {
|
|
1843
|
+
saved: false,
|
|
1844
|
+
title: 'This page is showing an out-of-date filter',
|
|
1845
|
+
body: 'Your filter changes have NOT been saved. The controls on this page are not the ones the current scan published, so approving them would approve a different list — reload to see what is really there.',
|
|
1846
|
+
},
|
|
1847
|
+
'preview:steel-preview-not-pending': {
|
|
1848
|
+
saved: false,
|
|
1849
|
+
title: 'This read is no longer waiting for a filter',
|
|
1850
|
+
body: 'Your filter changes have NOT been saved. This read has moved on or been closed, so there is nothing here to approve — reload to see where it got to.',
|
|
1851
|
+
},
|
|
1852
|
+
'steel-exclusion-preview-unavailable': {
|
|
1853
|
+
// The ONLY refusal that happens BEFORE the contract PUT. Everything about how it is presented
|
|
1854
|
+
// follows from that: its copy says the changes were not saved, and closing it must not latch the
|
|
1855
|
+
// "Approval needed" chip, because there is nothing approved-or-not yet — the edit is simply
|
|
1856
|
+
// still unsaved, and the chip that says so is the one the user needs.
|
|
1857
|
+
saved: false,
|
|
1858
|
+
title: 'FloLess couldn’t work out what this read would dismiss',
|
|
1859
|
+
body: 'Your filter changes have NOT been saved. Approving without those figures would record a decision against evidence nobody was shown, so nothing was written — close this and press Save again.',
|
|
1727
1860
|
},
|
|
1728
1861
|
};
|
|
1729
1862
|
|
|
1730
1863
|
/**
|
|
1731
|
-
*
|
|
1732
|
-
*
|
|
1733
|
-
*
|
|
1864
|
+
* A refusal the SERVER named and this page has no authored copy for, held beside the table rather than
|
|
1865
|
+
* written into it (see the checkpoint arm in `saveNow` for why). At most one at a time: it belongs to
|
|
1866
|
+
* the attempt that produced it, and the next attempt clears it with everything else.
|
|
1867
|
+
*/
|
|
1868
|
+
let relayedRefusal = null;
|
|
1869
|
+
|
|
1870
|
+
/** The copy for one refusal — authored where this page has it, relayed from the server where not. */
|
|
1871
|
+
function signoffProblem(code){
|
|
1872
|
+
return (code && Object.prototype.hasOwnProperty.call(SIGNOFF_PROBLEMS, code)) ? SIGNOFF_PROBLEMS[code] : relayedRefusal;
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
/**
|
|
1876
|
+
* The count shown beside one dismissible value: `filter.<facet>[].count`.
|
|
1877
|
+
*
|
|
1878
|
+
* Every element carrying that value across the drawing set, NOT split by page role, and NOT the same
|
|
1879
|
+
* population as the ledger lines the total above counts. Labelled and tooltipped for exactly that,
|
|
1880
|
+
* because the honest number is the one the human is deciding against.
|
|
1734
1881
|
*
|
|
1735
|
-
* Takes the count ONCE per
|
|
1736
|
-
* its own partial tally, and became wrong the moment `mergeWholeSetLayerCensus` started
|
|
1737
|
-
* GROUP's whole-set count onto every row of a canonical group: two rows for one
|
|
1738
|
-
* reported the whole population, and adding them doubled it. That number is what a human
|
|
1739
|
-
*
|
|
1740
|
-
*
|
|
1741
|
-
*
|
|
1882
|
+
* Takes the count ONCE per canonical value, never a sum across rows. Summing was right while each row
|
|
1883
|
+
* carried its own partial tally, and became wrong the moment `mergeWholeSetLayerCensus` started
|
|
1884
|
+
* stamping the GROUP's whole-set count onto every row of a canonical group: two rows for one value
|
|
1885
|
+
* then each reported the whole population, and adding them doubled it. That number is what a human
|
|
1886
|
+
* reads at the moment they authorise a wholesale dismissal, so an inflated one is exactly the kind of
|
|
1887
|
+
* wrong this surface cannot afford.
|
|
1888
|
+
*
|
|
1889
|
+
* Matched on the CANONICAL key, not the raw row value — the same fold `dismissibleFacetValues` used
|
|
1890
|
+
* to decide the row is dismissible at all. Matching raw would silently find no count for a
|
|
1891
|
+
* hand-edited `#ABC123` row whose approved value is `#abc123`, and render "element count unknown"
|
|
1892
|
+
* over a value carrying thousands of elements.
|
|
1742
1893
|
*
|
|
1743
1894
|
* `Number.isFinite` still gates: a junk count is not a count, and `null` renders as "element count
|
|
1744
1895
|
* unknown" rather than a number nobody can trust.
|
|
1745
1896
|
*/
|
|
1746
|
-
function
|
|
1747
|
-
|
|
1897
|
+
function facetElementCount(dim, value){
|
|
1898
|
+
const control = FACET_DIMS[dim].control, key = FACET_DIMS[dim].rowKey;
|
|
1899
|
+
for(const row of (F && F[control]) || []){
|
|
1900
|
+
if(row && facetKey(dim, row[key]) === value && Number.isFinite(row.count)) return row.count;
|
|
1901
|
+
}
|
|
1748
1902
|
return null;
|
|
1749
1903
|
}
|
|
1750
1904
|
|
|
1905
|
+
/** How one dismissible value reads on its row. Thickness through the same `thicknessLabel` the panel
|
|
1906
|
+
* uses, so the modal and the checkbox name the same value the same way. */
|
|
1907
|
+
function signoffValueLabel(dim, value){
|
|
1908
|
+
return dim === 'thickness' ? thicknessLabel(value) : String(value);
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1751
1911
|
function setSignoffMode(problem){
|
|
1752
1912
|
const failed = !!problem;
|
|
1753
1913
|
signoffNotice.hidden = !failed;
|
|
1754
1914
|
signoffList.hidden = failed;
|
|
1915
|
+
signoffTotal.hidden = failed;
|
|
1916
|
+
signoffCaption.hidden = failed;
|
|
1755
1917
|
signoffCancel.hidden = failed; signoffApprove.hidden = failed;
|
|
1756
|
-
signoffCloseBtn.hidden = !failed;
|
|
1918
|
+
signoffCloseBtn.hidden = !failed;
|
|
1919
|
+
// Reload is offered only where the work is already SAVED. On a pre-PUT refusal the human still has
|
|
1920
|
+
// unsaved ticks, and reloading throws them away — the `beforeunload` guard would fire, but inside the
|
|
1921
|
+
// shell's iframe that is the native browser prompt `__floGuard` exists to avoid. Close, then Save
|
|
1922
|
+
// again, is the recovery that cannot lose anything, and it is what that copy already says.
|
|
1923
|
+
signoffReload.hidden = !failed || !(signoffProblem(problem) && signoffProblem(problem).saved);
|
|
1757
1924
|
if(!failed) return;
|
|
1758
1925
|
// Neither refusal can be cleared by pressing Approve again, so the approve pair is REPLACED rather
|
|
1759
1926
|
// than left on screen as a false affordance.
|
|
1760
|
-
const copy =
|
|
1927
|
+
const copy = signoffProblem(problem);
|
|
1761
1928
|
signoffNotice.textContent = '';
|
|
1762
1929
|
const heading = document.createElement('b'); heading.textContent = copy.title;
|
|
1763
1930
|
const body = document.createElement('p'); body.textContent = copy.body;
|
|
@@ -1793,24 +1960,172 @@ function restoreSignoffBackground(){
|
|
|
1793
1960
|
signoffCoveredSurfaces = [];
|
|
1794
1961
|
}
|
|
1795
1962
|
|
|
1796
|
-
|
|
1797
|
-
|
|
1963
|
+
/**
|
|
1964
|
+
* The magnitude, and its three states.
|
|
1965
|
+
*
|
|
1966
|
+
* A CEILING, never a promise — "up to", never "will". Before the proof exists the server cannot know
|
|
1967
|
+
* how many lines will actually be dismissed: a later `member` or `mixed` attestation, or simply an
|
|
1968
|
+
* absent one, reduces it under the ALL rule. What it can compute exactly is the maximum this approval
|
|
1969
|
+
* authorises.
|
|
1970
|
+
*
|
|
1971
|
+
* The pending and failed sentences carry no digits at all, which is what "render no total" protects:
|
|
1972
|
+
* a wrong magnitude here is worse than none, because the magnitude IS the decision being taken.
|
|
1973
|
+
*/
|
|
1974
|
+
function renderSignoffTotal(){
|
|
1975
|
+
if(signoffPreviewState === 'ok' && signoffPreview){
|
|
1976
|
+
const lines = (signoffPreview.potentialLines.model || 0) + (signoffPreview.potentialLines.evidence || 0);
|
|
1977
|
+
signoffTotal.textContent = '';
|
|
1978
|
+
const strong = document.createElement('b');
|
|
1979
|
+
strong.textContent = 'Up to ' + lines.toLocaleString();
|
|
1980
|
+
signoffTotal.append(strong, document.createTextNode(' lines may be dismissed as a group.'));
|
|
1981
|
+
return;
|
|
1982
|
+
}
|
|
1983
|
+
signoffTotal.textContent = signoffPreviewState === 'pending'
|
|
1984
|
+
? 'Working out how many lines this may dismiss…'
|
|
1985
|
+
: '';
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
/** Approve is inert while the figure it is approving against has not arrived.
|
|
1989
|
+
*
|
|
1990
|
+
* `aria-disabled`, never the native `disabled` property — this page already uses that distinction
|
|
1991
|
+
* twice (the All/None controls, the eyedropper's Add buttons) so a refused control stays hoverable
|
|
1992
|
+
* and tabbable for the `data-tip` that explains WHY. A natively disabled button silently swallows
|
|
1993
|
+
* both. The focus trap keys off the `.disabled` property, so an aria-disabled Approve correctly
|
|
1994
|
+
* stays inside it. */
|
|
1995
|
+
function setSignoffApproveGate(){
|
|
1996
|
+
const waiting = signoffPreviewState === 'pending';
|
|
1997
|
+
if(waiting){
|
|
1998
|
+
signoffApprove.setAttribute('aria-disabled', 'true');
|
|
1999
|
+
signoffApprove.setAttribute('data-tip', 'Waiting for the count of what this read may dismiss.');
|
|
2000
|
+
} else {
|
|
2001
|
+
signoffApprove.removeAttribute('aria-disabled');
|
|
2002
|
+
signoffApprove.removeAttribute('data-tip');
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
/**
|
|
2007
|
+
* Ask the server what the PROPOSED ticks would dismiss.
|
|
2008
|
+
*
|
|
2009
|
+
* It has to be a preview rather than a figure off the manifest GET, because this modal opens BEFORE
|
|
2010
|
+
* the contract PUT: at this moment the proposed ticks exist only in browser memory and the server's
|
|
2011
|
+
* authoritative filter still describes the PREVIOUS selection. A number derived from that would be
|
|
2012
|
+
* about a different decision.
|
|
2013
|
+
*
|
|
2014
|
+
* The reply also carries the two hashes the approval is BOUND to — the manifest it was taken against
|
|
2015
|
+
* and the controls the human was shown a magnitude for — so a failed preview is not merely a missing
|
|
2016
|
+
* number: there is no approval to submit at all. That is why the failure state replaces the approve
|
|
2017
|
+
* pair rather than leaving an Approve button that would be refused.
|
|
2018
|
+
*/
|
|
2019
|
+
async function runSignoffPreview(){
|
|
2020
|
+
const seq = ++signoffPreviewSeq;
|
|
2021
|
+
let previewRefusal = 'steel-exclusion-preview-unavailable';
|
|
2022
|
+
signoffPreview = null;
|
|
2023
|
+
signoffPreviewState = 'pending';
|
|
2024
|
+
renderSignoffTotal();
|
|
2025
|
+
setSignoffApproveGate();
|
|
2026
|
+
const body = { mode: F.mode, layers: [], thicknesses: [], colors: [] };
|
|
2027
|
+
for(const dim of MODE_ORDER){
|
|
2028
|
+
const d = FACET_DIMS[dim];
|
|
2029
|
+
body[d.control] = ((F && F[d.control]) || []).map(row => ({ [d.rowKey]: row[d.rowKey], on: row.on === true }));
|
|
2030
|
+
}
|
|
2031
|
+
const controller = new AbortController();
|
|
2032
|
+
const timer = setTimeout(() => controller.abort(), SIGNOFF_PREVIEW_TIMEOUT_MS);
|
|
2033
|
+
try {
|
|
2034
|
+
const res = await fetch(`/api/projects/${encodeURIComponent(PROJECT)}/revision-requests/${encodeURIComponent(revisionRequest)}/exclusion-preview`, {
|
|
2035
|
+
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
2036
|
+
body: JSON.stringify(body), signal: controller.signal,
|
|
2037
|
+
});
|
|
2038
|
+
if(!res.ok){
|
|
2039
|
+
// The server's own CODE, not just its status. Each preview refusal has a different recovery and
|
|
2040
|
+
// the server already chose the right one; collapsing them into the generic failure below threw
|
|
2041
|
+
// that away — and for a model-pages-only census it produced a loop, telling the human to press
|
|
2042
|
+
// Save again when only their terminal AI can fix it.
|
|
2043
|
+
let refusal = null; try { refusal = await res.json(); } catch(_){ refusal = null; }
|
|
2044
|
+
const named = refusal && refusal.code && SIGNOFF_PROBLEMS['preview:' + refusal.code] ? 'preview:' + refusal.code : null;
|
|
2045
|
+
throw Object.assign(new Error('exclusion preview refused: ' + res.status), { signoffCode: named });
|
|
2046
|
+
}
|
|
2047
|
+
const payload = await res.json();
|
|
2048
|
+
if(seq !== signoffPreviewSeq) return; // a newer open superseded this one
|
|
2049
|
+
// The reply is CHECKED, not assumed, and the check is here rather than at the point of use.
|
|
2050
|
+
// `renderSignoffTotal` runs after this function's try/catch, so a missing `potentialLines` threw
|
|
2051
|
+
// out of the async function as an unhandled rejection: state stayed 'ok', the total kept reading
|
|
2052
|
+
// "Working out…", the approve gate was never released, and the dialog became a dead end escapable
|
|
2053
|
+
// only by Cancel. Fail-closed, but SILENTLY — which is the one thing the fail-closed rule forbids.
|
|
2054
|
+
// A malformed reply is a failed preview, and the failed state already says what to do about it.
|
|
2055
|
+
const counts = payload && payload.potentialLines;
|
|
2056
|
+
const usable = !!payload && typeof payload.manifestHash === 'string' && typeof payload.controlsHash === 'string'
|
|
2057
|
+
&& !!counts && Number.isFinite(counts.model) && Number.isFinite(counts.evidence);
|
|
2058
|
+
if(!usable) throw new Error('exclusion preview reply is missing the figures the approval binds to');
|
|
2059
|
+
signoffPreview = payload;
|
|
2060
|
+
signoffPreviewState = 'ok';
|
|
2061
|
+
} catch(e){
|
|
2062
|
+
if(seq !== signoffPreviewSeq) return;
|
|
2063
|
+
console.error('exclusion preview failed', e);
|
|
2064
|
+
signoffPreviewState = 'failed';
|
|
2065
|
+
// A named refusal keeps its own sentence; a network drop, a timeout or an unrecognised code falls
|
|
2066
|
+
// to the generic one, which is the honest answer for "we do not know why".
|
|
2067
|
+
previewRefusal = (e && e.signoffCode) || 'steel-exclusion-preview-unavailable';
|
|
2068
|
+
} finally {
|
|
2069
|
+
clearTimeout(timer);
|
|
2070
|
+
}
|
|
2071
|
+
if(seq !== signoffPreviewSeq) return;
|
|
2072
|
+
renderSignoffTotal();
|
|
2073
|
+
setSignoffApproveGate();
|
|
2074
|
+
// No figures means no approval to submit — the two binding hashes come from this reply. Say so, and
|
|
2075
|
+
// offer the actions that can actually help, instead of an Approve the server would refuse.
|
|
2076
|
+
if(signoffPreviewState === 'failed'){ signoffOutcome = previewRefusal; setSignoffMode(signoffOutcome); }
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
function openSignOff(values){
|
|
2080
|
+
signoffValues = values;
|
|
2081
|
+
// A NEW Save attempt starts clean. Without this a refusal from a previous attempt outlived it:
|
|
2082
|
+
// `setSignoffMode(null)` only hides the notice, so `closeSignOff` would latch "Approval needed" for
|
|
2083
|
+
// a refusal that no longer existed, and the header chip would re-open copy describing a failure the
|
|
2084
|
+
// user had already recovered from.
|
|
2085
|
+
signoffOutcome = null;
|
|
2086
|
+
relayedRefusal = null;
|
|
1798
2087
|
signoffList.textContent = '';
|
|
1799
|
-
for(const
|
|
1800
|
-
const
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
2088
|
+
for(const dim of MODE_ORDER){
|
|
2089
|
+
const rows = values.filter(row => row.dim === dim);
|
|
2090
|
+
// Never rendered empty — the same rule that skips the whole modal when nothing is dismissible.
|
|
2091
|
+
if(!rows.length) continue;
|
|
2092
|
+
const section = document.createElement('section');
|
|
2093
|
+
section.className = 'signoff-group'; section.setAttribute('data-dim', dim);
|
|
2094
|
+
const heading = document.createElement('h3');
|
|
2095
|
+
heading.className = 'signoff-group-heading';
|
|
2096
|
+
heading.id = 'signoffGroup-' + dim;
|
|
2097
|
+
heading.textContent = SIGNOFF_GROUP_LABEL[dim];
|
|
2098
|
+
const list = document.createElement('ul');
|
|
2099
|
+
list.className = 'signoff-rows';
|
|
2100
|
+
list.setAttribute('aria-labelledby', heading.id);
|
|
2101
|
+
for(const entry of rows){
|
|
2102
|
+
const label = signoffValueLabel(dim, entry.value);
|
|
2103
|
+
const count = facetElementCount(dim, entry.value);
|
|
2104
|
+
const row = document.createElement('li'); row.className = 'signoff-row';
|
|
2105
|
+
row.setAttribute('data-dim', dim); row.setAttribute('data-value', String(entry.value));
|
|
2106
|
+
if(dim === 'color'){
|
|
2107
|
+
// The swatch renders DRAWING DATA, not chrome — the one non-baseline colour on this surface,
|
|
2108
|
+
// inside a bordered chip so a white or near-white value is still visible on the dark ground.
|
|
2109
|
+
const sw = document.createElement('span'); sw.className = 'sw';
|
|
2110
|
+
sw.style.background = safeColor(entry.value);
|
|
2111
|
+
row.appendChild(sw);
|
|
2112
|
+
}
|
|
2113
|
+
const name = document.createElement('span'); name.className = 'signoff-name';
|
|
2114
|
+
// data-tip, never title=: .signoff-name ellipsizes, so a long layer name needs the themed tooltip.
|
|
2115
|
+
name.textContent = label; name.setAttribute('data-tip', label);
|
|
2116
|
+
const shown = document.createElement('span'); shown.className = 'signoff-count';
|
|
2117
|
+
shown.textContent = count === null ? 'element count unknown' : count.toLocaleString() + ' element' + (count === 1 ? '' : 's');
|
|
2118
|
+
shown.setAttribute('data-tip', SIGNOFF_COUNT_TIP[dim]);
|
|
2119
|
+
row.append(name, shown);
|
|
2120
|
+
list.appendChild(row);
|
|
2121
|
+
}
|
|
2122
|
+
section.append(heading, list);
|
|
2123
|
+
signoffList.appendChild(section);
|
|
1810
2124
|
}
|
|
1811
2125
|
setSignoffMode(null);
|
|
1812
2126
|
coverSignoffBackground();
|
|
1813
2127
|
signoffOverlay.hidden = false;
|
|
2128
|
+
void runSignoffPreview();
|
|
1814
2129
|
// Cancel takes focus, not Approve: a stray Enter must not fire the consequential action before the
|
|
1815
2130
|
// list has been read.
|
|
1816
2131
|
signoffCancel.focus();
|
|
@@ -1820,11 +2135,31 @@ function closeSignOff(){
|
|
|
1820
2135
|
if(signoffOverlay.hidden) return;
|
|
1821
2136
|
signoffOverlay.hidden = true;
|
|
1822
2137
|
restoreSignoffBackground();
|
|
1823
|
-
|
|
2138
|
+
signoffValues = [];
|
|
2139
|
+
// Abandon any preview still in flight, so its reply cannot repaint a closed dialog or re-arm a
|
|
2140
|
+
// refusal the user has already dismissed.
|
|
2141
|
+
signoffPreviewSeq += 1;
|
|
2142
|
+
signoffPreviewState = 'idle';
|
|
2143
|
+
signoffPreview = null;
|
|
2144
|
+
setSignoffApproveGate();
|
|
1824
2145
|
// A refusal is not resolved by dismissing its explanation. Leave the header carrying the state, as
|
|
1825
2146
|
// a control that brings the explanation back — the same cyan "non-default, click to act" chip the
|
|
1826
2147
|
// page already uses for a write conflict.
|
|
1827
|
-
|
|
2148
|
+
//
|
|
2149
|
+
// ONLY for a refusal that happened after the contract PUT committed. The pre-PUT preview failure
|
|
2150
|
+
// wrote nothing at all: the edit is still unsaved, Save is still enabled, and the modal's own copy
|
|
2151
|
+
// says to press it again — so replacing the "Unsaved" chip with "Approval needed" would hide from
|
|
2152
|
+
// the user that they still have unsaved work, which is the opposite of what that chip is for.
|
|
2153
|
+
//
|
|
2154
|
+
// …and a refusal that does NOT latch the chip is DISCHARGED here, not merely un-latched. Leaving it
|
|
2155
|
+
// set made the header's re-open route a dead click: `reopenChipExplanation` routes on
|
|
2156
|
+
// `signoffOutcome` being truthy, so the chip would say "Unsaved", the click would resolve to a
|
|
2157
|
+
// refusal, and nothing would appear. (Found by re-reviewing the fix that introduced it — the guard
|
|
2158
|
+
// and the router have to agree about what "there is a refusal" means, and one place is where that
|
|
2159
|
+
// agreement lives.) Discharging is also simply true: nothing was written, so there is no state to
|
|
2160
|
+
// come back to, and the user's next action is Save again, which opens a fresh modal anyway.
|
|
2161
|
+
const latchesChip = !!(signoffOutcome && signoffProblem(signoffOutcome) && signoffProblem(signoffOutcome).saved);
|
|
2162
|
+
if(latchesChip) setSaved('signoff-blocked'); else signoffOutcome = null;
|
|
1828
2163
|
// Focus must never be dropped on <body>. Save is DISABLED the instant a save succeeds and a
|
|
1829
2164
|
// disabled control cannot take focus, so the fallback is the layer list the user came from — which
|
|
1830
2165
|
// is also where they would go next to change what is ticked. (A real browser pass caught this:
|
|
@@ -1848,9 +2183,19 @@ function retireSignOffForCheckpointChange(){
|
|
|
1848
2183
|
const wasVisible = !signoffOverlay.hidden;
|
|
1849
2184
|
signoffOverlay.hidden = true;
|
|
1850
2185
|
restoreSignoffBackground();
|
|
1851
|
-
|
|
2186
|
+
signoffValues = [];
|
|
1852
2187
|
pendingSignOff = null;
|
|
1853
2188
|
signoffOutcome = null;
|
|
2189
|
+
// The SAME preview teardown `closeSignOff` performs, and for a sharper reason here: a retired
|
|
2190
|
+
// checkpoint's preview is answering a question about a manifest that is no longer this request's.
|
|
2191
|
+
// Without the sequence bump its reply would repaint a dialog that has been retired, and could
|
|
2192
|
+
// re-arm an approve gate for figures nobody will be shown. `relayedRefusal` goes with it — it
|
|
2193
|
+
// belongs to the attempt being retired.
|
|
2194
|
+
signoffPreviewSeq += 1;
|
|
2195
|
+
signoffPreviewState = 'idle';
|
|
2196
|
+
signoffPreview = null;
|
|
2197
|
+
relayedRefusal = null;
|
|
2198
|
+
setSignoffApproveGate();
|
|
1854
2199
|
// A dismissed refusal is hidden but still checkpoint-owned: closeSignOff deliberately preserves
|
|
1855
2200
|
// signoffOutcome so its status chip can reopen the explanation. A replacement must retire that state
|
|
1856
2201
|
// too, without moving focus when no dialog is currently on screen.
|
|
@@ -1871,8 +2216,22 @@ function setSignoffBusy(busy){
|
|
|
1871
2216
|
|
|
1872
2217
|
async function approveSignOff(){
|
|
1873
2218
|
if(signoffBusy) return;
|
|
2219
|
+
// The gate the `aria-disabled` attribute advertises, enforced. An attribute alone is a claim; this
|
|
2220
|
+
// is the refusal, and it exists because `aria-disabled` deliberately leaves the control clickable
|
|
2221
|
+
// so its tooltip can explain itself.
|
|
2222
|
+
if(signoffApprove.getAttribute('aria-disabled') === 'true') return;
|
|
2223
|
+
if(signoffPreviewState !== 'ok' || !signoffPreview) return;
|
|
1874
2224
|
setSignoffBusy(true);
|
|
1875
|
-
|
|
2225
|
+
// The ordered pairs the confirm step displayed, the mode they were computed under, and the two
|
|
2226
|
+
// hashes binding them to the manifest and the controls this human was shown a magnitude for —
|
|
2227
|
+
// never a hash of the list itself, so the browser does not have to reproduce the server's canonical
|
|
2228
|
+
// JSON, and never the full control list, so the assertion stays specific to what was shown.
|
|
2229
|
+
pendingSignOff = {
|
|
2230
|
+
mode: F.mode,
|
|
2231
|
+
dismissed: signoffValues.map(row => ({ dim: row.dim, value: row.value })),
|
|
2232
|
+
manifestHash: signoffPreview.manifestHash,
|
|
2233
|
+
controlsHash: signoffPreview.controlsHash,
|
|
2234
|
+
};
|
|
1876
2235
|
signoffOutcome = null;
|
|
1877
2236
|
try { await save(); } finally { setSignoffBusy(false); pendingSignOff = null; }
|
|
1878
2237
|
// A checkpoint refusal keeps the modal open and explains itself. Anything else (a 412 conflict, a
|
|
@@ -1881,7 +2240,9 @@ async function approveSignOff(){
|
|
|
1881
2240
|
if(signoffOutcome) setSignoffMode(signoffOutcome); else closeSignOff();
|
|
1882
2241
|
}
|
|
1883
2242
|
|
|
1884
|
-
/** Bring the refusal explanation back — the chip is the only route once the dialog is dismissed.
|
|
2243
|
+
/** Bring the refusal explanation back — the chip is the only route once the dialog is dismissed.
|
|
2244
|
+
* No `saved` guard is needed here, deliberately: `closeSignOff` discharges any refusal that did not
|
|
2245
|
+
* latch the chip, so a still-set `signoffOutcome` IS one the chip is carrying. One rule, one place. */
|
|
1885
2246
|
function reopenSignOffProblem(){
|
|
1886
2247
|
if(!signoffOutcome) return;
|
|
1887
2248
|
coverSignoffBackground();
|
|
@@ -1896,7 +2257,8 @@ signoffOverlay.addEventListener('pointerdown', (e) => { if(e.target === signoffO
|
|
|
1896
2257
|
signoffPanel.addEventListener('keydown', (e) => {
|
|
1897
2258
|
if(e.key === 'Escape' && !signoffBusy){ e.preventDefault(); closeSignOff(); return; }
|
|
1898
2259
|
if(e.key !== 'Tab') return;
|
|
1899
|
-
// A real trap over the VISIBLE actions — the two hidden ones belong to the other state.
|
|
2260
|
+
// A real trap over the VISIBLE actions — the two hidden ones belong to the other state. An
|
|
2261
|
+
// aria-disabled Approve deliberately stays IN the trap: it is reachable so its tooltip can be read.
|
|
1900
2262
|
const stops = [signoffCancel, signoffApprove, signoffCloseBtn, signoffReload].filter((b) => !b.hidden && !b.disabled);
|
|
1901
2263
|
if(!stops.length) return;
|
|
1902
2264
|
const first = stops[0], last = stops[stops.length - 1];
|
|
@@ -1912,9 +2274,11 @@ async function beginSave(){
|
|
|
1912
2274
|
if(conflicted){ showChangedBanner(); return; }
|
|
1913
2275
|
applySelToFilter(F, sel, mode);
|
|
1914
2276
|
// Only a revision read records an approval, and only when something is actually being dismissed.
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
2277
|
+
// THE shared definition, never a second one: the same function the server's digest, the audit's
|
|
2278
|
+
// shorthand predicate and the `facet-census` coverage check all read.
|
|
2279
|
+
const values = revisionRequest ? dismissibleFacetValues(F) : [];
|
|
2280
|
+
if(!values.length){ pendingSignOff = null; await save(); return; }
|
|
2281
|
+
openSignOff(values);
|
|
1918
2282
|
}
|
|
1919
2283
|
|
|
1920
2284
|
async function saveNow(){
|
|
@@ -1982,17 +2346,36 @@ async function saveNow(){
|
|
|
1982
2346
|
const t = res.headers.get('ETag'); if(t) serverEtag = t;
|
|
1983
2347
|
if(checkpointRequest && PROJECT && serverEtag){
|
|
1984
2348
|
const body = { etag: serverEtag };
|
|
1985
|
-
//
|
|
1986
|
-
//
|
|
1987
|
-
//
|
|
1988
|
-
if(pendingSignOff) body.
|
|
2349
|
+
// Built in `approveSignOff` from what the confirm step actually displayed and what the preview
|
|
2350
|
+
// actually returned — assembled there rather than here so this write cannot invent an approval
|
|
2351
|
+
// the human never saw.
|
|
2352
|
+
if(pendingSignOff) body.exclusionSignOff = pendingSignOff;
|
|
1989
2353
|
const checkpoint = await fetch(`/api/projects/${encodeURIComponent(PROJECT)}/revision-requests/${encodeURIComponent(checkpointRequest)}/filter-saved`, {
|
|
1990
2354
|
method:'POST', headers:{'content-type':'application/json'}, body:JSON.stringify(body),
|
|
1991
2355
|
});
|
|
1992
2356
|
if(!checkpoint.ok){
|
|
1993
2357
|
let payload = null; try { payload = await checkpoint.json(); } catch(_){ payload = null; }
|
|
1994
2358
|
const code = payload && payload.code;
|
|
1995
|
-
|
|
2359
|
+
// Keyed on the CODE, at ANY status, with a default arm — not on `409 && a code we authored`.
|
|
2360
|
+
// `/filter-saved` can refuse twelve ways and only three had authored copy, so the other nine
|
|
2361
|
+
// fell through to a bare `throw`: the modal closed exactly as it does on success while the
|
|
2362
|
+
// contract PUT had already committed, and the server's own recovery sentence — including the
|
|
2363
|
+
// one the design wrote for an over-cap approval, "leave more values switched on" — was
|
|
2364
|
+
// delivered to the console and nobody else. The default arm is the load-bearing half: a code
|
|
2365
|
+
// added server-side later must not silently rejoin that path. (pr-review-toolkit, finding 1.)
|
|
2366
|
+
//
|
|
2367
|
+
// The relayed copy is held BESIDE the table, never written into it. `code` comes off the wire,
|
|
2368
|
+
// and `table[code] = …` with a key of `__proto__` sets the object's PROTOTYPE rather than an
|
|
2369
|
+
// own property — the same hazard `canonicalJson` carries a null-prototype guard for. A
|
|
2370
|
+
// separate slot also keeps the authored table what it says it is: the copy this page wrote.
|
|
2371
|
+
if(code && !SIGNOFF_PROBLEMS[code] && payload && typeof payload.error === 'string'){
|
|
2372
|
+
relayedRefusal = {
|
|
2373
|
+
saved: true,
|
|
2374
|
+
title: 'This approval could not be recorded',
|
|
2375
|
+
body: 'Your filter changes were saved. ' + payload.error,
|
|
2376
|
+
};
|
|
2377
|
+
}
|
|
2378
|
+
if(SIGNOFF_PROBLEMS[code] || relayedRefusal){
|
|
1996
2379
|
// The contract PUT has ALREADY committed by the time this route is called — that is what
|
|
1997
2380
|
// it is for. So the user's edit is not lost and no rollback is attempted (one would be an
|
|
1998
2381
|
// unsafe write against a document they may have edited further); only the checkpoint and
|
|
@@ -2085,11 +2468,20 @@ window.__filterTest = {
|
|
|
2085
2468
|
sheetOptionTexts: () => sheetOptions().map(o => o.textContent),
|
|
2086
2469
|
pick: (i) => { const el = nodes[i].el; openEyedropper(Math.round(window.innerWidth / 2), 200, el); return el; },
|
|
2087
2470
|
addAll: () => document.getElementById('eyeAddAll').click(),
|
|
2088
|
-
//
|
|
2089
|
-
// only that a modal appeared.
|
|
2471
|
+
// Exclusion sign-off state, so a real browser pass can assert the control and the {dim, value} list
|
|
2472
|
+
// it SUBMITS, not only that a modal appeared. `signoffValues` is the submitted list itself — names
|
|
2473
|
+
// alone stopped being enough the moment a line weight could authorise a dismissal.
|
|
2090
2474
|
signoffOpen: () => !signoffOverlay.hidden,
|
|
2091
|
-
|
|
2475
|
+
signoffValues: () => signoffValues.map(row => ({ dim: row.dim, value: row.value })),
|
|
2476
|
+
signoffGroups: () => [...signoffList.querySelectorAll('.signoff-group')].map(group => ({
|
|
2477
|
+
dim: group.getAttribute('data-dim'),
|
|
2478
|
+
heading: group.querySelector('.signoff-group-heading').textContent,
|
|
2479
|
+
rows: [...group.querySelectorAll('.signoff-row')].map(row => row.textContent),
|
|
2480
|
+
})),
|
|
2092
2481
|
signoffRows: () => [...signoffList.querySelectorAll('.signoff-row')].map(row => row.textContent),
|
|
2482
|
+
signoffTotal: () => signoffTotal.textContent,
|
|
2483
|
+
signoffPreviewState: () => signoffPreviewState,
|
|
2484
|
+
signoffApproveGated: () => signoffApprove.getAttribute('aria-disabled') === 'true',
|
|
2093
2485
|
signoffNotice: () => (signoffNotice.hidden ? null : signoffNotice.textContent),
|
|
2094
2486
|
signoffActions: () => [...document.querySelectorAll('.signoff-actions button')].filter(b => !b.hidden).map(b => b.textContent),
|
|
2095
2487
|
};
|