@floless/app 0.146.0 → 0.148.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.
- package/dist/floless-server.cjs +1860 -1084
- package/dist/schemas/steel.model.v2.schema.json +1 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +96 -6
- package/dist/skills/floless-app-vectorize/SKILL.md +25 -2
- package/dist/web/app.css +22 -14
- package/dist/web/aware.js +90 -21
- package/dist/web/chat.css +63 -5
- package/dist/web/chat.js +218 -15
- package/dist/web/commands-filter.js +11 -0
- package/dist/web/commands-shell.js +27 -4
- package/dist/web/instructor.js +45 -19
- package/dist/web/model-chat-questions.js +45 -24
- package/dist/web/steel-filter-core.js +88 -0
- package/dist/web/steel-filter.html +254 -2
- package/dist/web/workspaces.js +165 -4
- package/package.json +1 -1
|
@@ -20,12 +20,19 @@ export function subjectLabelText(text) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* An object of a
|
|
23
|
+
* An object of a model as AI Chat names it. Revit: what it is, then its id (`Basic Wall · element:382`) -
|
|
24
24
|
* many elements share a type and some rows carry none, so a name without the id reads as a duplicate. Tekla Parser:
|
|
25
|
-
* the name, profile and Tekla ID the viewer shows, with the entity id added when the read had no Tekla ID.
|
|
26
|
-
* `rows` are the entity's property rows (Tekla reads its name and
|
|
25
|
+
* the name, profile and Tekla ID the viewer shows, with the entity id added when the read had no Tekla ID. Live
|
|
26
|
+
* Tekla: the mark (else the name) · profile. `rows` are the entity's property rows (Tekla Parser reads its name and
|
|
27
|
+
* profile from them).
|
|
27
28
|
*/
|
|
28
29
|
export function modelSubjectLabel(source, entity, rows = []) {
|
|
30
|
+
// A part of the live Tekla model, as its selection read lists it: the mark (else the name) and the profile. Marks
|
|
31
|
+
// repeat and change on renumbering, which is why the link itself is the part's GUID and never this label.
|
|
32
|
+
if (source === 'tekla') {
|
|
33
|
+
const what = entity?.mark || entity?.name || 'Tekla part';
|
|
34
|
+
return entity?.profile ? `${what} · ${entity.profile}` : what;
|
|
35
|
+
}
|
|
29
36
|
const id = String(entity?.id ?? '');
|
|
30
37
|
if (source === 'tekla-parser') {
|
|
31
38
|
const fields = teklaObjectFields(entity || {}, rows);
|
|
@@ -66,7 +73,8 @@ export function chatQuestionDate(iso) {
|
|
|
66
73
|
|
|
67
74
|
/**
|
|
68
75
|
* One row per question: the links of one message collapse into it, naming the objects it was about. A link is the
|
|
69
|
-
* person's selection, the chat model's note on it, or its answer naming
|
|
76
|
+
* person's selection (or a live Tekla read made for the question), the chat model's note on it, or its answer naming
|
|
77
|
+
* the object. What a row says never depends on
|
|
70
78
|
* which link arrived first: every link of a question carries the same question line and time, the newest note wins,
|
|
71
79
|
* and "named in the answer" is a fact of the set. Newest question first.
|
|
72
80
|
*/
|
|
@@ -115,7 +123,9 @@ function chatQuestionRow(doc, row, opts) {
|
|
|
115
123
|
if (was) { const who = doc.createElement('div'); who.className = 'chat-q-about'; who.textContent = `When asked: ${was}`; li.append(who); }
|
|
116
124
|
}
|
|
117
125
|
const show = doc.createElement('button'); show.type = 'button'; show.className = 'ghost chat-q-show'; show.textContent = 'Show in chat';
|
|
118
|
-
|
|
126
|
+
// One question can sit in both lists of a combined card (one part still there, one missing): each button its own id.
|
|
127
|
+
show.dataset.commandId = `${commandPrefix}.chat-question-show#${link.messageEventId}${opts.instanceSuffix || ''}`;
|
|
128
|
+
show.dataset.commandInstanceLabel = link.note;
|
|
119
129
|
show.setAttribute('aria-label', `Show in chat: ${link.note}`);
|
|
120
130
|
show.style.gridRow = `1/span ${li.children.length}`; // spans every line this row has, and no empty ones
|
|
121
131
|
show.onclick = () => { if (!onShow(link)) toast(CHAT_NOT_OPEN_COPY); };
|
|
@@ -126,10 +136,12 @@ function chatQuestionList(doc, host, rows, opts) {
|
|
|
126
136
|
const shown = rows.slice(0, 3), rest = rows.slice(3);
|
|
127
137
|
for (const row of shown) host.append(chatQuestionRow(doc, row, opts));
|
|
128
138
|
if (!rest.length) return;
|
|
129
|
-
|
|
130
|
-
const
|
|
139
|
+
// One card may hold two lists (the combined card): each "more" has its own command and its own open state.
|
|
140
|
+
const moreId = opts.moreId || 'chat-questions-more', moreKey = opts.moreKey || 'moreOpen';
|
|
141
|
+
const more = doc.createElement('details'); more.className = 'chat-q-more'; more.open = opts.ui[moreKey] === true;
|
|
142
|
+
const sum = doc.createElement('summary'); sum.dataset.commandId = `${opts.commandPrefix}.${moreId}`; more.append(sum);
|
|
131
143
|
const say = () => { sum.textContent = more.open ? 'Show fewer' : `Show ${rest.length} more`; }; say();
|
|
132
|
-
more.addEventListener('toggle', () => { opts.ui
|
|
144
|
+
more.addEventListener('toggle', () => { opts.ui[moreKey] = more.open; say(); }); // stays open across repaints
|
|
133
145
|
for (const row of rest) more.append(chatQuestionRow(doc, row, opts));
|
|
134
146
|
host.append(more);
|
|
135
147
|
}
|
|
@@ -138,15 +150,19 @@ function chatQuestionList(doc, host, rows, opts) {
|
|
|
138
150
|
* The "Questions in chat" card, or null when there is nothing to say.
|
|
139
151
|
* chatLinks {state: 'idle'|'ready'|'failed', links, partial}
|
|
140
152
|
* selected the selected objects as [{kind, id}]; empty when nothing is selected, and then the questions about
|
|
141
|
-
* objects not in the model are offered instead
|
|
153
|
+
* objects not in the model are offered instead (with `orphans: 'also'`, as well)
|
|
142
154
|
* resolves(link) the link's object is in the model shown now
|
|
143
155
|
* currentLabel(link) the object's label now, '' when unknown
|
|
144
|
-
* commandPrefix the page's Instructor namespace ('steel', 'revit', 'tekla-parser')
|
|
156
|
+
* commandPrefix the page's Instructor namespace ('steel', 'revit', 'tekla-parser', 'shell')
|
|
145
157
|
* onShow(link) open AI Chat at that question; false when AI Chat cannot be reached
|
|
146
158
|
* onRetry(), toast(text)
|
|
147
|
-
* ui {moreOpen, orphansOpen}, kept by the page so an open list stays open across repaints
|
|
159
|
+
* ui {moreOpen, orphansOpen, orphansMoreOpen}, kept by the page so an open list stays open across repaints
|
|
160
|
+
* orphans 'when-nothing-selected' (a model viewer: the list replaces the selection's) or 'also' (one card lists
|
|
161
|
+
* both, as a live Tekla read does: the parts it read, then the linked parts it did not find)
|
|
162
|
+
* orphanTitle(count) the missing section's title; `count` may read "at least N"
|
|
148
163
|
*/
|
|
149
|
-
export function renderChatQuestions({ doc, chatLinks, selected, resolves, currentLabel, commandPrefix, onShow, onRetry, toast, ui
|
|
164
|
+
export function renderChatQuestions({ doc, chatLinks, selected, resolves, currentLabel, commandPrefix, onShow, onRetry, toast, ui,
|
|
165
|
+
orphans: orphanMode = 'when-nothing-selected', orphanTitle = (count) => `Questions about objects not in the model (${count})` }) {
|
|
150
166
|
if (!chatLinks || chatLinks.state === 'idle') return null;
|
|
151
167
|
const box = doc.createElement('section'); box.className = 'chat-questions'; box.setAttribute('aria-label', 'Questions in chat');
|
|
152
168
|
if (chatLinks.state === 'failed') {
|
|
@@ -161,18 +177,23 @@ export function renderChatQuestions({ doc, chatLinks, selected, resolves, curren
|
|
|
161
177
|
if (selected.length) {
|
|
162
178
|
const keys = new Set(selected.map((item) => `${item.kind}\0${item.id}`));
|
|
163
179
|
const rows = chatQuestionRows(chatLinks.links.filter((link) => keys.has(`${link.kind}\0${link.id}`) && resolves(link)));
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
180
|
+
if (rows.length) {
|
|
181
|
+
const title = doc.createElement('div'); title.className = 'sect chat-q-title'; title.textContent = `Questions in chat (${atLeast}${rows.length})`;
|
|
182
|
+
box.append(title); chatQuestionList(doc, box, rows, { ...opts, about: selected.length > 1, unresolved: false });
|
|
183
|
+
}
|
|
184
|
+
if (orphanMode !== 'also') return rows.length ? box : null;
|
|
168
185
|
}
|
|
169
186
|
const orphans = chatQuestionRows(chatLinks.links.filter((link) => !resolves(link)));
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
187
|
+
if (orphans.length) {
|
|
188
|
+
const det = doc.createElement('details'); det.className = 'chat-q-orphans'; det.open = ui.orphansOpen === true;
|
|
189
|
+
det.addEventListener('toggle', () => { ui.orphansOpen = det.open; });
|
|
190
|
+
const sum = doc.createElement('summary'); sum.dataset.commandId = `${commandPrefix}.chat-questions-orphans`;
|
|
191
|
+
// Removed, never there, or read from another source file: an answer can name an id the model lacks. Live Tekla:
|
|
192
|
+
// a linked part the read did not find when checked.
|
|
193
|
+
sum.textContent = orphanTitle(`${atLeast}${orphans.length}`); det.append(sum);
|
|
194
|
+
const own = orphanMode === 'also' ? { moreId: 'chat-questions-orphans-more', moreKey: 'orphansMoreOpen', instanceSuffix: ':missing' } : {};
|
|
195
|
+
chatQuestionList(doc, det, orphans, { ...opts, ...own, about: true, unresolved: true });
|
|
196
|
+
box.append(det);
|
|
197
|
+
}
|
|
198
|
+
return box.childElementCount ? box : null;
|
|
178
199
|
}
|
|
@@ -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';
|
|
@@ -1528,7 +1546,10 @@ savedEl.addEventListener('keydown', e => {
|
|
|
1528
1546
|
function markDirty(retireAiUndo=true,preserveOnUndo=false){
|
|
1529
1547
|
if(retireAiUndo && filterAiUndo) retireFilterAiUndo(FILTER_AI_EDITED);
|
|
1530
1548
|
if(!retireAiUndo && preserveOnUndo && filterAiUndo) filterAiUndo.preserveDirtyOnUndo = true;
|
|
1531
|
-
|
|
1549
|
+
// An approval refused after the save committed leaves Save off until a reload, and the latched chip is
|
|
1550
|
+
// the only thing that reopens why (#1781). An edit must not trade it for a plain "Unsaved" label.
|
|
1551
|
+
dirty = true; saveBtn.disabled = checkpointSaveBlocked;
|
|
1552
|
+
setSaved(checkpointSaveBlocked && savedState === 'signoff-blocked' ? 'signoff-blocked' : 'dirty');
|
|
1532
1553
|
if(revisionRequest) syncRequiredSaveCue();
|
|
1533
1554
|
}
|
|
1534
1555
|
|
|
@@ -1637,6 +1658,9 @@ window.__floRevisionCheckpoint = {
|
|
|
1637
1658
|
history.replaceState(null, '', url.pathname + url.search);
|
|
1638
1659
|
if(!dirty) setSaved(revisionRequest && revisionFilterSavedEtag === serverEtag ? 'saved' : '');
|
|
1639
1660
|
syncRequiredSaveCue();
|
|
1661
|
+
// The size notice belongs to the checkpoint it was checked against (#1780): a new request voids
|
|
1662
|
+
// any answer in flight and anything on screen, and asks again for the new one.
|
|
1663
|
+
if(requestChanged) resetSizeCheck();
|
|
1640
1664
|
return true;
|
|
1641
1665
|
},
|
|
1642
1666
|
};
|
|
@@ -2675,6 +2699,216 @@ function apply(){
|
|
|
2675
2699
|
// cleared the halo and rows, and this puts them back on the pick. No re-scroll: the user may be working
|
|
2676
2700
|
// in the very list it would move.
|
|
2677
2701
|
if(eyeEl) openEyedropper(eyeAt.x, eyeAt.y, eyeEl, { rescroll: false });
|
|
2702
|
+
scheduleSizeCheck();
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
/* ── can this selection be read at all? (#1780) ──────────────────────────────────────────────────
|
|
2706
|
+
Every selected line on a sheet the read does not model from has to be named in the read's proof,
|
|
2707
|
+
and the proof has an 8 MB cap. The default selection ticks every line weight, and on a real set
|
|
2708
|
+
that was a selection no read could finish; the person found out only after Save, when the reader
|
|
2709
|
+
stopped and asked them to switch a weight off. So the Filter asks the server's own preflight about
|
|
2710
|
+
the selection ON SCREEN (the same `exclusion-preview` fold the dismissal sign-off uses, and cached
|
|
2711
|
+
with it), and says so here, next to the controls that fix it.
|
|
2712
|
+
|
|
2713
|
+
Advisory: it never disables Save and never changes a tick by itself. Its one action is the click the
|
|
2714
|
+
person would make on the checkbox, offered by name, with what it also takes off the model sheets. */
|
|
2715
|
+
const sizeNoticeEl = document.getElementById('filterSizeNotice');
|
|
2716
|
+
const SIZE_CHECK_DEBOUNCE_MS = 600;
|
|
2717
|
+
let sizeCheckTimer = 0;
|
|
2718
|
+
let sizeCheckSeq = 0; // bumped when the page stops being a checkpoint: an answer in flight is then void
|
|
2719
|
+
let sizeCheckKey = ''; // the selection most recently asked about, so a repaint does not re-ask
|
|
2720
|
+
let sizeCheckWanted = null; // { key, request, body } — the latest selection still owed an answer
|
|
2721
|
+
// At most ONE check in flight. The server's fold is synchronous and cannot be cancelled, so a person
|
|
2722
|
+
// ticking down a list would otherwise queue fold after fold and hold up every other request the page
|
|
2723
|
+
// makes. While one runs, later edits only replace `sizeCheckWanted`; when it lands, the newest
|
|
2724
|
+
// selection is asked about once, and the answer for a superseded one is never painted.
|
|
2725
|
+
let sizeCheckInFlight = false;
|
|
2726
|
+
|
|
2727
|
+
/** The preview body for the selection on screen, without touching `F` (that is Save's job). */
|
|
2728
|
+
function proposedControlsBody(){
|
|
2729
|
+
const proposed = { mode };
|
|
2730
|
+
for(const dim of MODE_ORDER){
|
|
2731
|
+
const control = FACET_DIMS[dim].control;
|
|
2732
|
+
proposed[control] = ((F && F[control]) || []).map(row => ({ ...row }));
|
|
2733
|
+
}
|
|
2734
|
+
applySelToFilter(proposed, sel, mode);
|
|
2735
|
+
const body = { mode, layers: [], thicknesses: [], colors: [] };
|
|
2736
|
+
for(const dim of MODE_ORDER){
|
|
2737
|
+
const d = FACET_DIMS[dim];
|
|
2738
|
+
body[d.control] = proposed[d.control].map(row => ({ [d.rowKey]: row[d.rowKey], on: row.on === true }));
|
|
2739
|
+
}
|
|
2740
|
+
return body;
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
function hideSizeNotice(){
|
|
2744
|
+
sizeNoticeEl.hidden = true;
|
|
2745
|
+
sizeNoticeEl.classList.remove('is-impossible');
|
|
2746
|
+
sizeNoticeEl.replaceChildren();
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
/** Void everything about the previous checkpoint's size check, then ask about this one. */
|
|
2750
|
+
function resetSizeCheck(){
|
|
2751
|
+
clearTimeout(sizeCheckTimer);
|
|
2752
|
+
sizeCheckSeq++; sizeCheckKey = ''; sizeCheckWanted = null;
|
|
2753
|
+
hideSizeNotice();
|
|
2754
|
+
scheduleSizeCheck();
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
|
+
function scheduleSizeCheck(){
|
|
2758
|
+
if(!revisionRequest || !C || !F || !sel){
|
|
2759
|
+
clearTimeout(sizeCheckTimer); sizeCheckSeq++; sizeCheckKey = ''; sizeCheckWanted = null; hideSizeNotice(); return;
|
|
2760
|
+
}
|
|
2761
|
+
const body = proposedControlsBody();
|
|
2762
|
+
const key = revisionRequest + '\n' + JSON.stringify(body);
|
|
2763
|
+
if(key === sizeCheckKey) return;
|
|
2764
|
+
sizeCheckKey = key;
|
|
2765
|
+
sizeCheckWanted = { key, request: revisionRequest, body };
|
|
2766
|
+
clearTimeout(sizeCheckTimer);
|
|
2767
|
+
// Replacing a notice that is already up: its figures describe the PREVIOUS selection, so they go now,
|
|
2768
|
+
// not when the answer lands. No digits while checking — a stale count read as current is worse than
|
|
2769
|
+
// none (the sign-off total's rule). A first check shows nothing until it has something to say.
|
|
2770
|
+
if(!sizeNoticeEl.hidden){
|
|
2771
|
+
sizeNoticeEl.classList.remove('is-impossible');
|
|
2772
|
+
const p = document.createElement('p'); p.className = 'size-checking';
|
|
2773
|
+
const spinner = document.createElement('span'); spinner.className = 'signoff-spinner'; spinner.setAttribute('aria-hidden', 'true');
|
|
2774
|
+
p.append(spinner, document.createTextNode('Checking whether this selection can be read…'));
|
|
2775
|
+
sizeNoticeEl.replaceChildren(p);
|
|
2776
|
+
}
|
|
2777
|
+
sizeCheckTimer = setTimeout(pumpSizeCheck, SIZE_CHECK_DEBOUNCE_MS);
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
async function pumpSizeCheck(){
|
|
2781
|
+
if(sizeCheckInFlight || !sizeCheckWanted) return;
|
|
2782
|
+
const job = sizeCheckWanted;
|
|
2783
|
+
const seq = sizeCheckSeq;
|
|
2784
|
+
sizeCheckInFlight = true;
|
|
2785
|
+
let notice;
|
|
2786
|
+
try {
|
|
2787
|
+
notice = await runSizeCheck(job);
|
|
2788
|
+
} finally {
|
|
2789
|
+
sizeCheckInFlight = false;
|
|
2790
|
+
}
|
|
2791
|
+
// This page stopped being a checkpoint meanwhile: the answer is void, but a selection asked about
|
|
2792
|
+
// since (the checkpoint came back) is still owed one.
|
|
2793
|
+
if(seq !== sizeCheckSeq){ if(sizeCheckWanted) void pumpSizeCheck(); return; }
|
|
2794
|
+
if(sizeCheckWanted && sizeCheckWanted.key !== job.key){ void pumpSizeCheck(); return; } // superseded
|
|
2795
|
+
sizeCheckWanted = null;
|
|
2796
|
+
// A check that could not answer is not an answer: forget the key so the next repaint of this same
|
|
2797
|
+
// selection asks again, rather than leaving "couldn't check" up until the selection changes.
|
|
2798
|
+
if(notice === SIZE_CHECK_FAILED_NOTICE) sizeCheckKey = '';
|
|
2799
|
+
renderSizeNotice(notice);
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2802
|
+
/** One check. Returns the notice to show, or null when there is nothing to say. Never throws. */
|
|
2803
|
+
async function runSizeCheck(job){
|
|
2804
|
+
let res;
|
|
2805
|
+
try {
|
|
2806
|
+
res = await fetch(`/api/projects/${encodeURIComponent(PROJECT)}/revision-requests/${encodeURIComponent(job.request)}/exclusion-preview`, {
|
|
2807
|
+
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(job.body),
|
|
2808
|
+
});
|
|
2809
|
+
} catch(error){
|
|
2810
|
+
console.warn('steel-filter: the selection size check could not reach FloLess', error);
|
|
2811
|
+
return SIZE_CHECK_FAILED_NOTICE;
|
|
2812
|
+
}
|
|
2813
|
+
if(!res.ok){
|
|
2814
|
+
let code = null; try { code = (await res.json()).code || null; } catch(_){ code = null; }
|
|
2815
|
+
// Nothing left to check (the read moved on, or is gone): say nothing. Anything else leaves the
|
|
2816
|
+
// question open, and a hidden notice would read as "this fits" — so it says it could not check.
|
|
2817
|
+
if(sizeCheckFailureIsQuiet(res.status, code)) return null;
|
|
2818
|
+
console.warn('steel-filter: the selection size check was refused', res.status, code || '(no code)');
|
|
2819
|
+
return SIZE_CHECK_FAILED_NOTICE;
|
|
2820
|
+
}
|
|
2821
|
+
let payload = null;
|
|
2822
|
+
try { payload = await res.json(); } catch(_){ payload = null; }
|
|
2823
|
+
if(!payload || !payload.proofBudget || typeof payload.proofBudget !== 'object'){
|
|
2824
|
+
console.warn('steel-filter: the selection size check returned no proof budget');
|
|
2825
|
+
return SIZE_CHECK_FAILED_NOTICE;
|
|
2826
|
+
}
|
|
2827
|
+
return proofSizeNotice(payload, sizeValueLabel);
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
/**
|
|
2831
|
+
* A value exactly as its facet row names it — the notice and the checkbox must say the same thing.
|
|
2832
|
+
* The row's own label function, over the row itself: a colour row shows its stored hex, which may be
|
|
2833
|
+
* upper-case while the server's canonical value is lower-case.
|
|
2834
|
+
*/
|
|
2835
|
+
function sizeValueLabel(dim, value){
|
|
2836
|
+
if(dim === 'thickness') return thicknessLabel(value);
|
|
2837
|
+
const control = FACET_DIMS[dim].control;
|
|
2838
|
+
const row = ((F && F[control]) || []).find(r => facetKey(dim, r[FACET_DIMS[dim].rowKey]) === value);
|
|
2839
|
+
return row ? String(row[FACET_DIMS[dim].rowKey]) : String(value);
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
function renderSizeNotice(notice){
|
|
2843
|
+
if(!notice){ hideSizeNotice(); return; }
|
|
2844
|
+
sizeNoticeEl.classList.toggle('is-impossible', notice.level === 'impossible');
|
|
2845
|
+
sizeNoticeEl.dataset.level = notice.level;
|
|
2846
|
+
const title = document.createElement('b'); title.textContent = notice.title;
|
|
2847
|
+
const lead = document.createElement('p'); lead.textContent = notice.lead;
|
|
2848
|
+
const parts = [title, lead];
|
|
2849
|
+
if(notice.suggestion){
|
|
2850
|
+
const s = notice.suggestion;
|
|
2851
|
+
const p = document.createElement('p'); p.textContent = s.text;
|
|
2852
|
+
const act = document.createElement('button');
|
|
2853
|
+
act.type = 'button'; act.className = 'size-suggest-action';
|
|
2854
|
+
act.setAttribute('data-command-id', 'filter.size-switch-off');
|
|
2855
|
+
act.dataset.dim = s.dim; act.dataset.value = String(s.value);
|
|
2856
|
+
act.textContent = s.action;
|
|
2857
|
+
act.onclick = () => switchOffFromNotice(s.dim, s.value);
|
|
2858
|
+
parts.push(p, act);
|
|
2859
|
+
} else {
|
|
2860
|
+
if(notice.alternativesIntro){
|
|
2861
|
+
const intro = document.createElement('p'); intro.textContent = notice.alternativesIntro;
|
|
2862
|
+
parts.push(intro);
|
|
2863
|
+
}
|
|
2864
|
+
if(notice.alternatives.length){
|
|
2865
|
+
const list = document.createElement('ul');
|
|
2866
|
+
for(const alt of notice.alternatives){
|
|
2867
|
+
const li = document.createElement('li');
|
|
2868
|
+
const text = document.createElement('span'); text.textContent = alt.text;
|
|
2869
|
+
const acts = document.createElement('span'); acts.className = 'acts';
|
|
2870
|
+
const act = document.createElement('button');
|
|
2871
|
+
act.type = 'button';
|
|
2872
|
+
act.setAttribute('data-command-id', 'filter.size-switch-off');
|
|
2873
|
+
act.dataset.dim = alt.dim; act.dataset.value = String(alt.value);
|
|
2874
|
+
act.setAttribute('aria-label', alt.action);
|
|
2875
|
+
act.textContent = 'switch off';
|
|
2876
|
+
act.onclick = () => switchOffFromNotice(alt.dim, alt.value);
|
|
2877
|
+
acts.appendChild(act);
|
|
2878
|
+
li.append(text, acts);
|
|
2879
|
+
list.appendChild(li);
|
|
2880
|
+
}
|
|
2881
|
+
parts.push(list);
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
sizeNoticeEl.replaceChildren(...parts);
|
|
2885
|
+
sizeNoticeEl.hidden = false;
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
/** The same edit as unticking the value's own checkbox, then focus lands ON that checkbox. */
|
|
2889
|
+
function switchOffFromNotice(dim, value){
|
|
2890
|
+
if(saveInFlight || !sel || !F) return;
|
|
2891
|
+
const facet = FACET_DIMS[dim] && FACET_DIMS[dim].control;
|
|
2892
|
+
if(!facet) return;
|
|
2893
|
+
const key = facetKey(dim, value);
|
|
2894
|
+
if(key === undefined || !setOf(facet).has(key)) return;
|
|
2895
|
+
setOf(facet).delete(key);
|
|
2896
|
+
syncFacetChecks(); markDirty(); apply();
|
|
2897
|
+
// The button that was clicked has just been replaced, so focus must land somewhere real: the value's
|
|
2898
|
+
// own checkbox, or — when a search in that list hides its row — the first visible control of that
|
|
2899
|
+
// list's search box (the only way a row is hidden is a search in that list), never <body> and never
|
|
2900
|
+
// the list's bulk all/none buttons, which would put a single-value edit's focus on a bulk action.
|
|
2901
|
+
const items = F[facet] || [];
|
|
2902
|
+
const boxes = document.querySelectorAll(`#facet-${facet} .opts input[type=checkbox]`);
|
|
2903
|
+
let target = null;
|
|
2904
|
+
for(let i = 0; i < items.length; i++){
|
|
2905
|
+
if(boxes[i] && facetRowKey(facet, items[i]) === key){ target = boxes[i]; break; }
|
|
2906
|
+
}
|
|
2907
|
+
if(!target || !target.offsetParent){
|
|
2908
|
+
const search = document.querySelector(`#facet-${facet} .facet-search-input`);
|
|
2909
|
+
if(search && search.offsetParent) target = search;
|
|
2910
|
+
}
|
|
2911
|
+
if(target){ target.focus(); target.scrollIntoView({ block: 'nearest' }); }
|
|
2678
2912
|
}
|
|
2679
2913
|
|
|
2680
2914
|
// --- modes + all/none ---
|
|
@@ -3943,6 +4177,8 @@ function failSignoffPreview(seq, error){
|
|
|
3943
4177
|
// offer the actions that can actually help, instead of an Approve the server would refuse.
|
|
3944
4178
|
signoffOutcome = (error && error.signoffCode) || 'steel-exclusion-preview-unavailable';
|
|
3945
4179
|
setSignoffMode(signoffOutcome);
|
|
4180
|
+
// The dialog is already open, so nothing else tells the shell it now explains a refusal (#1781).
|
|
4181
|
+
notifyFilterAi();
|
|
3946
4182
|
}
|
|
3947
4183
|
|
|
3948
4184
|
function openSignOff(values){
|
|
@@ -4361,6 +4597,22 @@ window.__floGuard = {
|
|
|
4361
4597
|
isDirty: () => dirty,
|
|
4362
4598
|
save: async () => { await beginSave(); return !dirty; },
|
|
4363
4599
|
discard: () => { dirty = false; },
|
|
4600
|
+
// #1781: what the workspace must say OUTSIDE this frame, so the tab strip and the progress strip never
|
|
4601
|
+
// call the Drawing Filter saved while a save here is unfinished. The first match wins:
|
|
4602
|
+
// 'saving' the writes are in flight (a required first save too, whose `dirty` is false);
|
|
4603
|
+
// 'blocked' the save or its approval was refused. The dialog, or the status chip that reopens it,
|
|
4604
|
+
// explains why; Approve and Cancel are gone, so nothing may tell the person to press them.
|
|
4605
|
+
// Only while one of those two is actually there: with neither, "the Filter explains why"
|
|
4606
|
+
// would send the person to nothing (markDirty keeps the chip latched for that reason);
|
|
4607
|
+
// 'confirm' the dismissal confirmation is open and waiting for Approve or Cancel;
|
|
4608
|
+
// 'reload' a required save failed and Save stays disabled until the Drawing Filter is reloaded;
|
|
4609
|
+
// 'unsaved' edits nobody has pressed Save on; '' nothing is pending.
|
|
4610
|
+
// Every change reaches the parent via notifyFilterAi.
|
|
4611
|
+
pendingSave: () => saveInFlight ? 'saving'
|
|
4612
|
+
: signoffOutcome && (!signoffOverlay.hidden || savedState === 'signoff-blocked') ? 'blocked'
|
|
4613
|
+
: !signoffOverlay.hidden ? 'confirm'
|
|
4614
|
+
: checkpointSaveBlocked ? 'reload'
|
|
4615
|
+
: dirty ? 'unsaved' : '',
|
|
4364
4616
|
};
|
|
4365
4617
|
|
|
4366
4618
|
// Test seam (mirrors steel-3d-view's debug()/probe()) — lets a headless E2E drive the eyedropper
|