@floless/app 0.169.0 → 0.170.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 +71580 -59849
- package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
- package/dist/schemas/steel.model.v2.schema.json +2 -1
- package/dist/skills/floless-app-knowledge/SKILL.md +43 -13
- package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
- package/dist/skills/floless-app-routines/SKILL.md +2 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +20 -8
- package/dist/skills/floless-app-steel-model/SKILL.md +8 -5
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
- package/dist/skills/floless-app-workflows/SKILL.md +22 -3
- package/dist/skills/floless-app-workflows/references/agent-steps.md +40 -6
- package/dist/skills/floless-app-workflows/references/exec-contract.md +27 -0
- package/dist/skills/floless-app-workflows/references/script-runner.md +105 -0
- package/dist/web/agent-steps.js +89 -18
- package/dist/web/agents.js +32 -22
- package/dist/web/app.css +223 -1
- package/dist/web/app.js +24 -3
- package/dist/web/aware.js +877 -189
- package/dist/web/chat.js +184 -95
- package/dist/web/checkpoint-standard.js +5 -3
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-shell.js +440 -11
- package/dist/web/commands-steel.js +60 -1
- package/dist/web/drawing-check-editor.js +352 -88
- package/dist/web/failure-copy.js +32 -2
- package/dist/web/filter-ai-proposal.js +11 -8
- package/dist/web/flo-3d.js +1 -1
- package/dist/web/guide.js +33 -26
- package/dist/web/index.html +69 -1
- package/dist/web/instructor.js +99 -15
- package/dist/web/left-pane.js +4 -1
- package/dist/web/local-discovery.js +8 -7
- package/dist/web/missed-routines.js +239 -0
- package/dist/web/model-measure.js +6 -0
- package/dist/web/model-spatial-panel.js +19 -4
- package/dist/web/model-spatial-tools.js +3 -3
- package/dist/web/model-viewport-revit-adapter.js +3 -3
- package/dist/web/origin-rule.js +155 -0
- package/dist/web/project-access.js +1 -1
- package/dist/web/project-modules.js +2 -2
- package/dist/web/project-rfis.js +6 -1
- package/dist/web/project-workflows.js +2 -2
- package/dist/web/revit-editor.js +22 -8
- package/dist/web/run-history.js +12 -1
- package/dist/web/steel-3d-core.js +39 -9
- package/dist/web/steel-3d-flo.js +26 -4
- package/dist/web/steel-3d-view.js +8 -3
- package/dist/web/steel-ai-marks.js +3 -1
- package/dist/web/steel-editor.html +455 -122
- package/dist/web/steel-environments.js +297 -0
- package/dist/web/steel-filter.html +3 -2
- package/dist/web/steel-model-v2-client-validation.js +8 -1
- package/dist/web/steel-model-v2-commands.js +23 -9
- package/dist/web/steel-model-v2-projection.js +1 -1
- package/dist/web/step-rename.js +3 -2
- package/dist/web/terminal-requests.js +1 -1
- package/dist/web/tool-updates.js +7 -6
- package/dist/web/workspaces.js +1714 -119
- package/package.json +4 -1
|
@@ -135,11 +135,17 @@ export function liveRefreshFor(frame, { app, project }) {
|
|
|
135
135
|
* they did not show before. '' when nothing a person would notice changed. `before`/`after` are { refs, designSet }
|
|
136
136
|
* (designSet null when it could not be read: a reference then shows "could not read", which is not news).
|
|
137
137
|
*/
|
|
138
|
-
|
|
138
|
+
/**
|
|
139
|
+
* What changed in the reference drawings, as the status line says it. `own` = { added, removed }: the drawings the
|
|
140
|
+
* page's own writes added and took out (#2504, #3297). An addition is skipped only when an own addition explains it,
|
|
141
|
+
* a removal only when an own removal does; recording where a drawing came from explains neither, and a new warning
|
|
142
|
+
* on any drawing, the page's own included, is always said.
|
|
143
|
+
*/
|
|
144
|
+
export function referencesChangeNote(before, after, own = { added: new Set(), removed: new Set() }) {
|
|
139
145
|
const had = new Map((before.refs || []).map((r) => [r.sha256, r]));
|
|
140
146
|
const has = new Set((after.refs || []).map((r) => r.sha256));
|
|
141
|
-
const added = (after.refs || []).filter((r) => !had.has(r.sha256));
|
|
142
|
-
const gone = (before.refs || []).filter((r) => !has.has(r.sha256));
|
|
147
|
+
const added = (after.refs || []).filter((r) => !had.has(r.sha256) && !own.added.has(r.sha256));
|
|
148
|
+
const gone = (before.refs || []).filter((r) => !has.has(r.sha256) && !own.removed.has(r.sha256));
|
|
143
149
|
const warned = after.designSet ? (after.refs || []).filter((r) => {
|
|
144
150
|
if (!had.has(r.sha256)) return false;
|
|
145
151
|
const now = referenceDriftText(r, after.designSet);
|
|
@@ -235,6 +241,41 @@ export function mainPartHtml(it, { touched = false, note = '', locatedOn = false
|
|
|
235
241
|
<p class="note">Normally the main part is the part-list row whose mark is the assembly mark in the drawing title. “Part list agrees with the title” and “Every part is located” both use it. Choose No only if this client lists the main part under a different mark.</p>
|
|
236
242
|
${unticked}${note ? `<p class="note" role="status">${esc(note)}</p>` : ''}</div>`;
|
|
237
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Whether this client writes inches without a mark on a dimension (`4`, `6 1/2`) (#2991): learned only when the
|
|
246
|
+
* references prove it, so the person may say so either way. Shown for an imperial checklist with no unit for every
|
|
247
|
+
* bare number (only then can it change a reading); '' otherwise. `bareInchSeen` says what the references showed.
|
|
248
|
+
* @param {any} lengths @param {{ touched?: boolean, note?: string }} [opts]
|
|
249
|
+
*/
|
|
250
|
+
export function bareInchHtml(lengths, { touched = false, note = '' } = {}) {
|
|
251
|
+
if (!lengths || lengths.system !== 'imperial' || lengths.unitless) {
|
|
252
|
+
// No control here, but a choice saved on such a checklist (applied again after it changed) still says what it did.
|
|
253
|
+
return note ? `<section class="tb" aria-labelledby="dim-h"><h3 id="dim-h">Dimensions</h3><p class="note" role="status">${esc(note)}</p></section>` : '';
|
|
254
|
+
}
|
|
255
|
+
const on = lengths.bareInchValues === true, seen = lengths.bareInchSeen;
|
|
256
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
257
|
+
// What the references showed is counted narrowly: values with no inch mark on a chain with a feet-and-inches value,
|
|
258
|
+
// so "none found" is said, never "none there" - and only of references that were counted: a profile proposed
|
|
259
|
+
// before the count was kept claims nothing about them.
|
|
260
|
+
const shown = seen && seen.values > 0 ? `${plural(seen.values, 'value', 'values')} with no inch mark in a chain with feet and inches, on ${plural(seen.sheets, 'sheet', 'sheets')}` : '';
|
|
261
|
+
const chip = touched ? 'set by you' : on ? 'learned from the references' : shown ? 'too few seen in the references' : seen ? 'none found in the references' : 'not counted yet';
|
|
262
|
+
// Three separate facts: what runs do now, who set it, and what the references showed.
|
|
263
|
+
const does = on ? 'FloLess reads a number written alone in a dimension, such as 4 or 6 1/2, as inches.'
|
|
264
|
+
: 'FloLess does not guess: a number written alone in a dimension is reported as couldn’t tell.';
|
|
265
|
+
const source = touched ? `You set this; proposing again keeps it.${shown ? ` Your references show ${shown}.` : ''}`
|
|
266
|
+
: on ? `Learned from your reference drawings${shown ? `, which show ${shown}` : ''}.`
|
|
267
|
+
: shown ? `Your references show ${shown}: too few for FloLess to be sure. Choose Yes if this client writes inches this way.`
|
|
268
|
+
: seen ? 'FloLess found no values with no inch mark in a chain with feet and inches on your references. Choose Yes only if this client writes inches this way.'
|
|
269
|
+
: 'FloLess has not counted these on your references yet: proposing again from the references counts them. Choose Yes if this client writes inches this way.';
|
|
270
|
+
const why = `${does} ${source}`;
|
|
271
|
+
const opt = (v, isOn, words) => `<button type="button" role="radio" aria-checked="${isOn}" tabindex="${isOn ? 0 : -1}" data-bare-inches="${esc(v)}" data-command-id="drawing-check.bare-inches#${esc(v)}" data-command-instance-label="${esc(words)}">${esc(words)}</button>`;
|
|
272
|
+
// A setting of the whole checklist, not of one item: a section of its own, as the title block and the part list.
|
|
273
|
+
return `<section class="tb" aria-labelledby="dim-h"><h3 id="dim-h">Dimensions</h3><div class="clear-panel">
|
|
274
|
+
<p class="clear-head"><span id="bare-inch-h">Does this client write inches without a mark, such as 4 or 6 1/2?</span> <span class="chip">${esc(chip)}</span></p>
|
|
275
|
+
<div class="seg" role="radiogroup" aria-labelledby="bare-inch-h" aria-describedby="bare-inch-note">${opt('yes', on, 'Yes, read them as inches')}${opt('no', !on, 'No, say couldn’t tell')}</div>
|
|
276
|
+
<p class="note" id="bare-inch-note">${esc(why)} It applies to dimension values only.</p>
|
|
277
|
+
${note ? `<p class="note" role="status">${esc(note)}</p>` : ''}</div></section>`;
|
|
278
|
+
}
|
|
238
279
|
/** The largest line break a checklist may set, pt (server `MAX_LINE_BREAK_PT`). */
|
|
239
280
|
export const MAX_LINE_BREAK_PT = 3;
|
|
240
281
|
/**
|
|
@@ -289,7 +330,7 @@ export function clientFieldHtml(client) {
|
|
|
289
330
|
// ── keeping keyboard focus across a re-render (pure, exported for server/drawing-check-ui.test.ts) ─
|
|
290
331
|
|
|
291
332
|
/** The attributes that name a control stably across re-renders, in the order they are tried. */
|
|
292
|
-
const FOCUS_KEYS = ['data-main-row', 'data-tb-label', 'data-tb-required', 'data-tb-remove', 'data-typed-label', 'data-typed-use', 'data-type-label', 'data-item', 'data-tab', 'data-act', 'id'];
|
|
333
|
+
const FOCUS_KEYS = ['data-main-row', 'data-bare-inches', 'data-tb-label', 'data-tb-required', 'data-tb-remove', 'data-typed-label', 'data-typed-use', 'data-type-label', 'data-item', 'data-tab', 'data-act', 'id'];
|
|
293
334
|
const attrEsc = (v) => String(v).replace(/["\\]/g, '\\$&');
|
|
294
335
|
/**
|
|
295
336
|
* A selector that finds "the same control" in freshly rendered markup, or null. A read-mode button is
|
|
@@ -424,6 +465,37 @@ export function fieldOrigin(f, pages) {
|
|
|
424
465
|
return { text: pages ? `filled in on ${Math.round(f.support * pages)} of ${pages}` : 'learned from the references' };
|
|
425
466
|
}
|
|
426
467
|
|
|
468
|
+
/**
|
|
469
|
+
* #2613: how a checklist item did on the reference sheets it was scored on, from its exact counts (`tally`). A rule that
|
|
470
|
+
* reads the drawing (slice 2, it carries `readability`) is scored only on the sheets it could read, so the line says so;
|
|
471
|
+
* a slice-1 item counts a sheet it could not read as not held, so the line names those. '' when there are no counts.
|
|
472
|
+
*/
|
|
473
|
+
export function tallyLine(it) {
|
|
474
|
+
const t = it && it.tally;
|
|
475
|
+
if (!t || !t.sheets) return '';
|
|
476
|
+
const sheets = (n) => `${n} sheet${n === 1 ? '' : 's'}`;
|
|
477
|
+
if (typeof it.readability === 'number') {
|
|
478
|
+
if (!t.decided) return `could not be read on any of the ${sheets(t.sheets)}`;
|
|
479
|
+
return t.decided === t.sheets ? `held on ${t.held} of ${sheets(t.sheets)}` : `held on ${t.held} of the ${sheets(t.decided)} it could read · ${t.sheets} checked`;
|
|
480
|
+
}
|
|
481
|
+
return `seen on ${t.held} of ${sheets(t.sheets)}${t.decided < t.sheets ? ` (${t.sheets - t.decided} could not be read)` : ''}`;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/** The share bar beside a checklist item, with what the share is of; a dash, not 0%, when the rule could read nothing. */
|
|
485
|
+
export function freqHtml(it) {
|
|
486
|
+
if (!it || typeof it.frequency !== 'number') return '<span></span>';
|
|
487
|
+
const t = it.tally;
|
|
488
|
+
const slice2 = typeof it.readability === 'number';
|
|
489
|
+
if (t && (!t.sheets || (slice2 && !t.decided))) {
|
|
490
|
+
const why = t.sheets ? 'This check could not read any of the reference sheets' : 'This item was not measured on any reference sheet';
|
|
491
|
+
return `<span class="freq" data-tip="${why}"><span class="bar"><i style="width:0%"></i></span>—</span>`;
|
|
492
|
+
}
|
|
493
|
+
const pct = Math.round(it.frequency * 100);
|
|
494
|
+
const tip = slice2 ? 'Share of the sheets this check could read where it held. Sheets it could not read are left out.'
|
|
495
|
+
: `How often this held on the reference drawings${t && t.decided < t.sheets ? '. Unreadable sheets count as not held.' : ''}`;
|
|
496
|
+
return `<span class="freq${pct < 50 ? ' rare' : ''}" data-tip="${esc(tip)}"><span class="bar"><i style="width:${pct}%"></i></span>${pct}%</span>`;
|
|
497
|
+
}
|
|
498
|
+
|
|
427
499
|
/** Where on the sheet a learned label sits, in words ("bottom right"), from its page-relative box. */
|
|
428
500
|
export function whereOnSheet(box) {
|
|
429
501
|
if (!box) return '';
|
|
@@ -715,7 +787,7 @@ export function partListHtml(pl, { proposed = false } = {}) {
|
|
|
715
787
|
const rows = layouts.map((l, i) => {
|
|
716
788
|
const share = `learned from ${Math.round((l.support || 0) * 100)}% of the references`;
|
|
717
789
|
const massWords = { 'line-mass': 'the row’s mass', 'unit-mass': 'each piece’s mass' };
|
|
718
|
-
const cols = l.columns.map((c) => `${esc(c.label)}${massWords[c.role] ? ` <span class="origin-inline">(${massWords[c.role]})</span>` : ''}`).join(' · ');
|
|
790
|
+
const cols = l.columns.map((c) => `${esc(c.label)}${massWords[c.role] ? ` <span class="origin-inline">(${massWords[c.role]})</span>` : ''}${c.optional ? ' <span class="origin-inline">(not on every list)</span>' : ''}`).join(' · ');
|
|
719
791
|
const shape = [l.turned ? 'Lettering turned a quarter, as on single-part sheets.' : '', l.rowsRun === 'up' ? 'A one-row strip, the values above their labels.' : ''].filter(Boolean).join(' ');
|
|
720
792
|
const t = l.total;
|
|
721
793
|
const ends = !t ? 'No total line was found.'
|
|
@@ -763,27 +835,75 @@ function boot() {
|
|
|
763
835
|
// What changed in the reference drawings since the page last showed them, when the change came from elsewhere
|
|
764
836
|
// (Knowledge, AI Chat, another window): said on the Reference drawings tab until the next such change (#2482).
|
|
765
837
|
liveNote: '',
|
|
838
|
+
// The latest reference drawings could not be read: said apart from liveNote, until a read succeeds (#3297).
|
|
839
|
+
refsReadNote: '',
|
|
766
840
|
};
|
|
767
841
|
|
|
768
842
|
// This page's own writes still waiting for their answer: a refresh waits for them (refreshNow), so what the page
|
|
769
843
|
// just did is never read back as a change made elsewhere. `ownWriteSeq` counts every write that started, so a
|
|
770
844
|
// refresh already reading when the person makes a change knows its answer may hold that change (QA E2E, #2482).
|
|
771
|
-
|
|
845
|
+
// A write that adds or takes out reference drawings says what it expects to change (`ownRefs`, a list of
|
|
846
|
+
// { sha256, kind }) before it is sent, held in `ownRefPending` while it is out; its answer's `refChanges`, what the
|
|
847
|
+
// server says it actually changed, then go into `ownRefLog`. Whatever else a list from the server differs by was
|
|
848
|
+
// changed elsewhere and is said (#2504, #3297). What is said never waits for these writes.
|
|
849
|
+
// A write that has not answered after OWN_WRITE_WAIT_MS stops holding reads (#3302): it is not abandoned, its caller
|
|
850
|
+
// still takes its answer, but `ownWrites` no longer counts it, so a write that never answers cannot stall every
|
|
851
|
+
// refresh. `ownSettleSeq` counts writes that answered or failed: a read during which one settled may predate what
|
|
852
|
+
// it did, so it is read again (loadDraft). A write that cannot change the draft (a run, a decision on one, the
|
|
853
|
+
// markup colours) says so with `draftWrite: false` and holds nothing at all.
|
|
854
|
+
let ownWrites = 0, ownWriteSeq = 0, ownSettleSeq = 0, ownRefSeq = 0, ownRefLog = [], ownRefPending = new Map();
|
|
855
|
+
const OWN_WRITE_WAIT_MS = 60000;
|
|
772
856
|
async function call(path, opts = {}) {
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
857
|
+
const { ownRefs, draftWrite = true, ...rest } = opts;
|
|
858
|
+
const write = draftWrite && !!rest.method && rest.method !== 'GET';
|
|
859
|
+
const seq = write ? ++ownWriteSeq : 0;
|
|
860
|
+
let counted = write;
|
|
861
|
+
const release = () => { if (counted) { counted = false; ownWrites--; } };
|
|
862
|
+
const overdue = write ? setTimeout(release, OWN_WRITE_WAIT_MS) : null;
|
|
863
|
+
if (write) ownWrites++;
|
|
864
|
+
if (write && ownRefs) ownRefPending.set(seq, ownRefs);
|
|
865
|
+
try {
|
|
866
|
+
const got = await callOnce(path, rest);
|
|
867
|
+
// The change is made: an answer that does not say what it changed costs only an announcement of the page's
|
|
868
|
+
// own change as made elsewhere, never the change itself.
|
|
869
|
+
if (write && ownRefs && got.body && Array.isArray(got.body.refChanges)) {
|
|
870
|
+
ownRefLog = [...ownRefLog, ...got.body.refChanges.map((c) => ({ seq: ++ownRefSeq, sha256: c.sha256, kind: c.kind }))];
|
|
871
|
+
}
|
|
872
|
+
return got;
|
|
873
|
+
} finally { if (write) { clearTimeout(overdue); release(); ownSettleSeq++; ownRefPending.delete(seq); } }
|
|
874
|
+
}
|
|
875
|
+
/** The drawings this page's own writes added and took out: logged after `seq`, and expected by those still out. */
|
|
876
|
+
function ownRefsAfter(seq) {
|
|
877
|
+
const own = { added: new Set(), removed: new Set() };
|
|
878
|
+
const put = (c) => { if (c.kind === 'added') own.added.add(c.sha256); else if (c.kind === 'removed') own.removed.add(c.sha256); };
|
|
879
|
+
for (const c of ownRefLog) if (c.seq > seq) put(c);
|
|
880
|
+
for (const list of ownRefPending.values()) for (const c of list) put(c);
|
|
881
|
+
return own;
|
|
882
|
+
}
|
|
883
|
+
// A read that never answers ends after READ_TIMEOUT_MS; a write only when its caller gives `deadlineMs` (a checklist
|
|
884
|
+
// save, which answers at once): a slow run or Propose is never cut off (#3302). A deadline that runs out, while
|
|
885
|
+
// waiting for the answer or while its body arrives, is said as such: the outcome of a write is then unknown.
|
|
886
|
+
async function callOnce(path, opts = {}) {
|
|
887
|
+
const { deadlineMs, ...rest } = opts;
|
|
888
|
+
const reads = /^(GET|HEAD)$/i.test(String(rest.method || 'GET'));
|
|
889
|
+
const own = rest.signal ? null : deadlineMs ? AbortSignal.timeout(deadlineMs) : reads ? AbortSignal.timeout(READ_TIMEOUT_MS) : null;
|
|
890
|
+
const timedOut = () => {
|
|
891
|
+
const e = new Error(reads ? 'FloLess didn’t answer in time. Try again in a moment.'
|
|
892
|
+
: 'FloLess didn’t answer in time, so it can’t tell whether your change was saved. The page reads the latest again.');
|
|
893
|
+
e.status = 0; e.forPerson = true; e.timedOut = true; return e;
|
|
894
|
+
};
|
|
895
|
+
const signal = own || rest.signal;
|
|
778
896
|
let res;
|
|
779
|
-
try { res = await fetch(path, { credentials: 'same-origin', ...
|
|
780
|
-
catch {
|
|
897
|
+
try { res = await fetch(path, { credentials: 'same-origin', ...rest, ...(own ? { signal: own } : {}) }); }
|
|
898
|
+
catch {
|
|
899
|
+
if (signal && signal.aborted) throw timedOut();
|
|
900
|
+
const e = new Error('FloLess could not be reached. Check that it is still running, then try again.'); e.status = 0; e.forPerson = true; throw e;
|
|
901
|
+
}
|
|
781
902
|
let body = null;
|
|
782
|
-
try { body = await res.json(); } catch { /* an empty or non-JSON body */ }
|
|
903
|
+
try { body = await res.json(); } catch { if (signal && signal.aborted) throw timedOut(); /* else an empty or non-JSON body */ }
|
|
783
904
|
if (!res.ok || (body && body.ok === false)) {
|
|
784
905
|
// #3097: the server's sentence only when it wrote one for the person (failure-copy.js), never raw exception text.
|
|
785
906
|
const said = typeof globalThis.personText === 'function' ? globalThis.personText(body) : '';
|
|
786
|
-
const reads = /^(GET|HEAD)$/i.test(String(opts?.method || 'GET'));
|
|
787
907
|
const e = new Error(said || (typeof globalThis.failureCopy === 'function'
|
|
788
908
|
? globalThis.failureCopy({ status: res.status, body }, { retrySafe: reads }).text
|
|
789
909
|
: 'That didn’t work. Try again.'));
|
|
@@ -809,7 +929,7 @@ function boot() {
|
|
|
809
929
|
let booted = false;
|
|
810
930
|
const syncState = () => (S.sync !== 'ok' ? S.sync : S.complete ? 'ok' : 'reading');
|
|
811
931
|
// An answer's draft parts replace the saved ones; an optional part the answer carries as null is deleted (Propose).
|
|
812
|
-
const OPTIONAL_PARTS = new Set(['titleBlock', 'partList']);
|
|
932
|
+
const OPTIONAL_PARTS = new Set(['titleBlock', 'partList', 'lengths']);
|
|
813
933
|
function rebuild() {
|
|
814
934
|
const d = S.saved.draft ? structuredClone(S.saved.draft) : null;
|
|
815
935
|
if (d) for (const c of S.pending) c.apply(d);
|
|
@@ -841,7 +961,7 @@ function boot() {
|
|
|
841
961
|
S.saved.etag = etag;
|
|
842
962
|
S.serial++;
|
|
843
963
|
if (!own && (etag !== before || completing)) S.gen++;
|
|
844
|
-
if (draft !== undefined) S.complete = true;
|
|
964
|
+
if (draft !== undefined) { S.complete = true; wholeDraftShown(); }
|
|
845
965
|
else if (!own) { S.complete = false; readAll(); }
|
|
846
966
|
rebuild();
|
|
847
967
|
paint();
|
|
@@ -861,29 +981,47 @@ function boot() {
|
|
|
861
981
|
function readAll() {
|
|
862
982
|
if (readQueued) return;
|
|
863
983
|
readQueued = true;
|
|
984
|
+
// Nothing is counted as said from the moment this read is queued until a whole draft is shown (by this read, or
|
|
985
|
+
// any other: Reload, a refresh), so an answer that was not taken on (it lost on serial) is not counted as said
|
|
986
|
+
// before the read shows what it did. What the whole draft brings is said once it is adopted, before the approval
|
|
987
|
+
// status is read, so a slow review read never holds the status line (#3297).
|
|
988
|
+
refsAwaitDraft = true;
|
|
864
989
|
void itemsQueue(async () => {
|
|
865
990
|
readQueued = false;
|
|
866
991
|
if (S.sync === 'behind' || S.sync === 'failed') S.sync = 'reading';
|
|
867
992
|
paint();
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
if (got !== 'stale') { S.sync = 'ok'; await loadReview(); paint(); return; }
|
|
874
|
-
if (ownWrites > 0) waits++; else tries++;
|
|
875
|
-
await new Promise((r) => setTimeout(r, 300)); // read again after it
|
|
876
|
-
}
|
|
993
|
+
const batch = refsBatchOpen();
|
|
994
|
+
try {
|
|
995
|
+
if (await readDraftSettled()) { S.sync = 'ok'; S.refsReadNote = ''; batch.close(); await loadReview(); paint(); return; }
|
|
996
|
+
} catch { /* not read: said as failed below */ }
|
|
997
|
+
batch.close();
|
|
877
998
|
S.sync = 'failed';
|
|
878
999
|
paint();
|
|
879
1000
|
});
|
|
880
1001
|
}
|
|
881
|
-
/**
|
|
882
|
-
*
|
|
1002
|
+
/**
|
|
1003
|
+
* Read the draft until a read is adopted: true when one is, false when every try came back stale. A read made while
|
|
1004
|
+
* this page's own write is out (an upload of several drawings) waits for it without using up a try: only reads with
|
|
1005
|
+
* nothing of ours out count, so the page does not call the latest version unreadable. Throws when a read fails.
|
|
1006
|
+
*/
|
|
1007
|
+
async function readDraftSettled() {
|
|
1008
|
+
for (let tries = 0, waits = 0; tries < 5 && waits < 200; ) {
|
|
1009
|
+
if (await loadDraft() !== 'stale') return true;
|
|
1010
|
+
if (ownWrites > 0) waits++; else tries++;
|
|
1011
|
+
await new Promise((r) => setTimeout(r, 300)); // read again after it
|
|
1012
|
+
}
|
|
1013
|
+
return false;
|
|
1014
|
+
}
|
|
1015
|
+
// A read the server never answers ends after this long, so it cannot hold the reference status line (#3297).
|
|
1016
|
+
const READ_TIMEOUT_MS = 30000;
|
|
1017
|
+
const timedRead = (url) => fetch(url, { credentials: 'same-origin', signal: AbortSignal.timeout(READ_TIMEOUT_MS) });
|
|
1018
|
+
/** Read the draft. 'adopted' or 'same' (what was read is shown), or 'stale': a write of this page's own was out,
|
|
1019
|
+
* started or answered while it read, or another adoption landed, so the answer may predate it and nothing is
|
|
1020
|
+
* adopted. */
|
|
883
1021
|
async function loadDraft() {
|
|
884
|
-
const token = { serial: S.serial, seq: ownWriteSeq, busy: ownWrites > 0 };
|
|
885
|
-
const stale = () => token.busy || token.seq !== ownWriteSeq || token.serial !== S.serial;
|
|
886
|
-
const res = await
|
|
1022
|
+
const token = { serial: S.serial, seq: ownWriteSeq, settled: ownSettleSeq, busy: ownWrites > 0 };
|
|
1023
|
+
const stale = () => token.busy || token.seq !== ownWriteSeq || token.settled !== ownSettleSeq || token.serial !== S.serial;
|
|
1024
|
+
const res = await timedRead(`/api/contract/${encodeURIComponent(APP)}?project=${encodeURIComponent(PROJECT)}&quietMissing=1`);
|
|
887
1025
|
if (res.status === 204) {
|
|
888
1026
|
if (stale()) return 'stale';
|
|
889
1027
|
const same = S.saved.etag === null && S.complete;
|
|
@@ -901,7 +1039,7 @@ function boot() {
|
|
|
901
1039
|
if (!res.ok) throw new Error('This profile could not be read. Reload to try again.');
|
|
902
1040
|
const draft = await res.json(), etag = res.headers.get('ETag');
|
|
903
1041
|
if (stale()) return 'stale';
|
|
904
|
-
S.clearNote = ''; S.mainNote = ''; S.breakNote = ''; S.breakError = ''; S.breakTyped = null; // a note about the last change says nothing true about a draft read afresh
|
|
1042
|
+
S.clearNote = ''; S.mainNote = ''; S.bareNote = ''; S.breakNote = ''; S.breakError = ''; S.breakTyped = null; // a note about the last change says nothing true about a draft read afresh
|
|
905
1043
|
const same = etag === S.saved.etag && S.complete;
|
|
906
1044
|
adopt({ draft, etag });
|
|
907
1045
|
return same ? 'same' : 'adopted';
|
|
@@ -932,6 +1070,8 @@ function boot() {
|
|
|
932
1070
|
const tbChanges = await changes;
|
|
933
1071
|
if (serial === S.serial) { S.review = review; S.reviewError = reviewError; S.tbChanges = tbChanges; return; }
|
|
934
1072
|
}
|
|
1073
|
+
// Every try was overtaken by a newer draft: what is shown may describe an earlier one, and the page says so (#3302).
|
|
1074
|
+
S.reviewError = 'The approval status may be out of date. Reload to see the latest.';
|
|
935
1075
|
}
|
|
936
1076
|
async function loadRuns() {
|
|
937
1077
|
S.runsError = '';
|
|
@@ -951,19 +1091,26 @@ function boot() {
|
|
|
951
1091
|
async function loadAll() {
|
|
952
1092
|
S.accessError = '';
|
|
953
1093
|
// allSettled, not all: every read must land before the page decides which failure to explain.
|
|
954
|
-
|
|
1094
|
+
// The draft and the design set are one reference batch, closed when both have landed: the runs, colours and review
|
|
1095
|
+
// reads never hold the reference status line (#3297).
|
|
1096
|
+
const batch = refsBatchOpen();
|
|
1097
|
+
const draftRead = loadDraft(), designSetRead = loadDesignSet();
|
|
1098
|
+
void Promise.allSettled([draftRead, designSetRead]).then(() => batch.close());
|
|
1099
|
+
const settled = await Promise.allSettled([draftRead, loadReview(), loadRuns(), loadColours(), designSetRead]);
|
|
955
1100
|
const failed = settled.find((r) => r.status === 'rejected');
|
|
956
1101
|
// The whole draft was read and shown: the page is current again. A read that crossed a write of this page's
|
|
957
1102
|
// own adopted nothing; it is read again once that write has answered.
|
|
958
1103
|
if (settled[0].status === 'fulfilled') {
|
|
959
1104
|
if (settled[0].value === 'stale') refreshSoon({ draft: true });
|
|
960
|
-
else if (S.sync !== 'reading') S.sync = 'ok';
|
|
1105
|
+
else { S.refsReadNote = ''; if (S.sync !== 'reading') S.sync = 'ok'; }
|
|
961
1106
|
}
|
|
962
1107
|
S.loadError = failed ? (failed.reason && failed.reason.message) || 'This profile could not be read. Reload to try again.' : '';
|
|
963
1108
|
// A module refusal (no Drawing Checker access) is the one answer that explains every other failure,
|
|
964
1109
|
// so its own copy is what the page says.
|
|
965
1110
|
if (S.accessError) S.loadError = S.accessError;
|
|
966
1111
|
if (!S.tab) S.tab = landingTab({ hasApproved: hasApproved(), referenceCount: references().length });
|
|
1112
|
+
// What the first load found is what the person is first shown: changes are counted from it. Reload compares.
|
|
1113
|
+
if (!refsTold) refsTold = { ...refsNow(), seq: ownRefSeq };
|
|
967
1114
|
booted = true;
|
|
968
1115
|
render();
|
|
969
1116
|
}
|
|
@@ -1009,8 +1156,48 @@ function boot() {
|
|
|
1009
1156
|
return S.run ? `<section ${attrs('runs', 'flush')}>${runViewHtml()}</section>` : `<section ${attrs('runs')}>${runsHtml()}</section>`;
|
|
1010
1157
|
}
|
|
1011
1158
|
|
|
1159
|
+
// ── the reference status line (#2482, #2504, #3297) ──
|
|
1160
|
+
// `refsTold` is what the person was last shown on Reference drawings, with the position in ownRefLog it accounts
|
|
1161
|
+
// for. A change is worked out against it only when no reference batch is reading (refsSyncing), and the baseline
|
|
1162
|
+
// moves only when Reference drawings is drawn with what was compared, so a change taken in on another tab, or in
|
|
1163
|
+
// several steps, is said once, all together, when the person is next shown the list.
|
|
1164
|
+
let refsTold = null, refsSyncing = 0, refsDrawnKey = '', refsAwaitDraft = false;
|
|
1165
|
+
/** A whole draft was adopted: whatever an answer that was not taken on did is now on screen (readAll). */
|
|
1166
|
+
function wholeDraftShown() { refsAwaitDraft = false; }
|
|
1167
|
+
const refsNow = () => ({ refs: references(), designSet: S.designSetError ? null : S.designSet });
|
|
1168
|
+
/** The rows as drawn: which drawings, where they came from and any warning on them. */
|
|
1169
|
+
const refsKey = () => JSON.stringify(references().map((r) => [r.sha256, r.designIssue ? r.designIssue.issueId : null, referenceDrift(r)]));
|
|
1170
|
+
/** What changed since the person was last shown the list ('' for nothing to say), or null while a batch reads. */
|
|
1171
|
+
function refsChangeNow() {
|
|
1172
|
+
if (!refsTold || refsSyncing || refsAwaitDraft) return null;
|
|
1173
|
+
return referencesChangeNote(refsTold, refsNow(), ownRefsAfter(refsTold.seq));
|
|
1174
|
+
}
|
|
1175
|
+
/** One unit of reading the references (a draft and a design-set read together); closing it says what it brought. */
|
|
1176
|
+
function refsBatchOpen() {
|
|
1177
|
+
refsSyncing++;
|
|
1178
|
+
let open = true;
|
|
1179
|
+
return { close() { if (!open) return false; open = false; refsSyncing--; return deliverRefs(); } };
|
|
1180
|
+
}
|
|
1181
|
+
/** Draw Reference drawings again when there is something to say, or its rows changed without a repaint. */
|
|
1182
|
+
function deliverRefs() {
|
|
1183
|
+
if (!booted || refsSyncing || S.tab !== 'references' || S.run) return false;
|
|
1184
|
+
if (!refsChangeNow() && refsKey() === refsDrawnKey) return false;
|
|
1185
|
+
renderKeepingScroll();
|
|
1186
|
+
return true;
|
|
1187
|
+
}
|
|
1188
|
+
/** Called while drawing Reference drawings: take what changed into the status line and count it as said. */
|
|
1189
|
+
function sayRefsChange() {
|
|
1190
|
+
const note = refsChangeNow();
|
|
1191
|
+
if (note === null) return;
|
|
1192
|
+
if (note) S.liveNote = note;
|
|
1193
|
+
refsTold = { ...refsNow(), seq: ownRefSeq };
|
|
1194
|
+
ownRefLog = ownRefLog.filter((c) => c.seq > refsTold.seq);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1012
1197
|
// ── references ──
|
|
1013
1198
|
function referencesHtml() {
|
|
1199
|
+
sayRefsChange();
|
|
1200
|
+
refsDrawnKey = refsKey();
|
|
1014
1201
|
const refs = references();
|
|
1015
1202
|
const drop = (compact) => `<button type="button" class="drop${compact ? ' compact' : ''}" data-act="pick-refs" data-command-id="drawing-check.add-references">
|
|
1016
1203
|
<b>${compact ? 'Add more reference drawings' : 'Drop the shop drawings this client already signed off'}</b>
|
|
@@ -1020,6 +1207,7 @@ function boot() {
|
|
|
1020
1207
|
${S.newSinceApproval && approvedVersion() !== null ? `<div class="band">${S.newSinceApproval} new drawing${S.newSinceApproval === 1 ? ' isn’t' : 's aren’t'} in version ${approvedVersion()}. Propose again on the Checklist to include ${S.newSinceApproval === 1 ? 'it' : 'them'}.</div>` : ''}
|
|
1021
1208
|
${S.uploadNote ? `<p class="note" role="status">${esc(S.uploadNote)}</p>` : ''}
|
|
1022
1209
|
${S.liveNote ? `<p class="note" role="status" id="refs-live-note">${esc(S.liveNote)}</p>` : ''}
|
|
1210
|
+
${S.refsReadNote ? `<p class="note" role="status" id="refs-read-note">${esc(S.refsReadNote)}</p>` : ''}
|
|
1023
1211
|
<div class="row-actions"><button type="button" data-act="use-design-set" data-command-id="drawing-check.use-design-set" data-tip="Add drawings from an issue in this project’s Knowledge">Use the design set…</button></div>
|
|
1024
1212
|
${refs.length ? `<div class="list" style="margin-bottom:14px">${refs.map(referenceRow).join('')}</div>${drop(true)}` : drop(false)}
|
|
1025
1213
|
<input type="file" id="ref-file" accept=".pdf,application/pdf" multiple hidden></div>`;
|
|
@@ -1029,9 +1217,12 @@ function boot() {
|
|
|
1029
1217
|
// A pull: the picker reads this profile's own design set (Knowledge) and the server copies the chosen files into the
|
|
1030
1218
|
// references, each recording the issue it came from. The design set is never written from here.
|
|
1031
1219
|
const dsUrl = `/api/projects/${encodeURIComponent(PROJECT)}/design-set`;
|
|
1220
|
+
let designSetSeq = 0;
|
|
1032
1221
|
async function loadDesignSet() {
|
|
1033
|
-
|
|
1034
|
-
|
|
1222
|
+
const my = ++designSetSeq;
|
|
1223
|
+
// Only the latest read is shown: an answer that a newer read has overtaken would put an older design set back.
|
|
1224
|
+
try { const { body } = await call(dsUrl, { signal: AbortSignal.timeout(READ_TIMEOUT_MS) }); if (my === designSetSeq) { S.designSet = body; S.designSetError = ''; } }
|
|
1225
|
+
catch (e) { if (my === designSetSeq) { S.designSet = null; S.designSetError = (e && e.message) || 'The design set could not be read.'; } }
|
|
1035
1226
|
}
|
|
1036
1227
|
/** "12 Oct 2026" from YYYY-MM-DD or an ISO time; the input as it is when it is neither. */
|
|
1037
1228
|
const shortDate = (d) => {
|
|
@@ -1072,19 +1263,23 @@ function boot() {
|
|
|
1072
1263
|
b.disabled = true;
|
|
1073
1264
|
try {
|
|
1074
1265
|
const sent = sending(); // conditional on the version shown: its answer is the person's own change
|
|
1075
|
-
const { body } = await call(`${base}/references/${encodeURIComponent(sha)}`, { method: 'DELETE', headers: sent.etag ? { 'if-match': sent.etag } : {} });
|
|
1266
|
+
const { body } = await call(`${base}/references/${encodeURIComponent(sha)}`, { method: 'DELETE', headers: sent.etag ? { 'if-match': sent.etag } : {}, ownRefs: [{ sha256: sha, kind: 'removed' }] });
|
|
1076
1267
|
adoptAnswer(sent, { references: body.references }, body.etag); S.kept.delete(sha);
|
|
1077
1268
|
S.uploadNote = `${ref.name} was taken out of the reference drawings. Propose again on the Checklist to update what was learned from it.`;
|
|
1078
1269
|
closeDialog(false);
|
|
1079
|
-
|
|
1270
|
+
const batch = refsBatchOpen();
|
|
1271
|
+
try { await Promise.all([loadDraft().finally(() => batch.close()), loadReview()]); }
|
|
1080
1272
|
catch { S.uploadNote += ' Saved, but the page could not refresh. Reload the profile to see the latest.'; }
|
|
1081
1273
|
render(); document.querySelector('[data-act="use-design-set"]')?.focus();
|
|
1082
1274
|
} catch (err) {
|
|
1083
1275
|
b.disabled = false;
|
|
1084
1276
|
const line = scrim.querySelector('#rr-err');
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1277
|
+
// Refused because the drawings changed elsewhere: the page reads them again itself, and says what changed.
|
|
1278
|
+
const stale = err.status === 412 || err.status === 428;
|
|
1279
|
+
if (stale) { S.complete = false; readAll(); }
|
|
1280
|
+
line.textContent = stale
|
|
1281
|
+
? 'The checklist changed in another window, so it was not taken out. The page now shows the latest; close this and look again.'
|
|
1282
|
+
: errorText(err, { action: 'take it out of the reference drawings', unsure: 'Reload the profile to see whether it was taken out.' });
|
|
1088
1283
|
line.hidden = false;
|
|
1089
1284
|
}
|
|
1090
1285
|
});
|
|
@@ -1184,9 +1379,10 @@ function boot() {
|
|
|
1184
1379
|
try {
|
|
1185
1380
|
// Conditional on the version the plan was read from: the person's own change only if that is the one shown.
|
|
1186
1381
|
const sent = { ...sending(p.draftEtag || null), cond: !!p.draftEtag };
|
|
1187
|
-
const { body } = await call(`${base}/references/design-issue`, jsonOpts('POST',
|
|
1382
|
+
const { body } = await call(`${base}/references/design-issue`, { ...jsonOpts('POST',
|
|
1188
1383
|
{ issueId: p.issueId, files: [...st.ticks].sort((a, b) => a - b), planKey: p.planKey, expected: p.expected },
|
|
1189
|
-
p.draftEtag ? { 'if-match': p.draftEtag } : {})
|
|
1384
|
+
p.draftEtag ? { 'if-match': p.draftEtag } : {}),
|
|
1385
|
+
ownRefs: p.files.filter((f) => st.ticks.has(f.index) && f.sha256).map((f) => ({ sha256: f.sha256, kind: 'added' })) });
|
|
1190
1386
|
if (body.etag) adoptAnswer(sent, { references: body.references }, body.etag);
|
|
1191
1387
|
if (body.added.length) S.newSinceApproval += body.added.length;
|
|
1192
1388
|
const parts = [];
|
|
@@ -1195,7 +1391,8 @@ function boot() {
|
|
|
1195
1391
|
if (!body.added.length && !body.recorded.length) parts.push(`Nothing changed: the chosen drawings are already references.`);
|
|
1196
1392
|
if (body.notAdded.length) parts.push(`${body.notAdded.length} not added: ${body.notAdded.map((n) => `${n.filename} (${n.reason})`).join('; ')}.`);
|
|
1197
1393
|
closeDialog(false);
|
|
1198
|
-
|
|
1394
|
+
const batch = refsBatchOpen();
|
|
1395
|
+
try { await Promise.all([Promise.all([loadDraft(), loadDesignSet()]).finally(() => batch.close()), loadReview()]); }
|
|
1199
1396
|
catch { parts.push('Saved, but the page could not refresh. Reload the profile to see the latest.'); }
|
|
1200
1397
|
S.uploadNote = parts.join(' ');
|
|
1201
1398
|
render(); document.querySelector('[data-act="use-design-set"]')?.focus();
|
|
@@ -1204,7 +1401,8 @@ function boot() {
|
|
|
1204
1401
|
const code = e.body && e.body.code;
|
|
1205
1402
|
if (code === 'design-set-changed' || e.status === 412 || e.status === 428) {
|
|
1206
1403
|
st.note = code === 'design-set-changed' ? 'The design set changed — check the files again.' : 'The checklist changed in another window — check the files again.';
|
|
1207
|
-
|
|
1404
|
+
const batch = refsBatchOpen();
|
|
1405
|
+
await Promise.all([loadDraft(), loadDesignSet()]).catch(() => {}).finally(() => batch.close());
|
|
1208
1406
|
if (code === 'design-set-changed' && e.body.plan) {
|
|
1209
1407
|
const prev = st.ticks; st.plan = e.body.plan;
|
|
1210
1408
|
st.ticks = new Set(st.plan.files.filter((f) => f.selectable && prev.has(f.index)).map((f) => f.index));
|
|
@@ -1248,6 +1446,14 @@ function boot() {
|
|
|
1248
1446
|
else paintIssues();
|
|
1249
1447
|
})();
|
|
1250
1448
|
}
|
|
1449
|
+
/** The SHA-256 of a file, as the server names a reference drawing; '' when this browser cannot work it out (its
|
|
1450
|
+
* answer still says what it changed, so only an overlap with a change made elsewhere is less exact). */
|
|
1451
|
+
async function pdfDigest(file) {
|
|
1452
|
+
try {
|
|
1453
|
+
const d = new Uint8Array(await crypto.subtle.digest('SHA-256', await file.arrayBuffer()));
|
|
1454
|
+
return [...d].map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
1455
|
+
} catch { return ''; }
|
|
1456
|
+
}
|
|
1251
1457
|
async function uploadReferences(files) {
|
|
1252
1458
|
const pdfs = [...files].filter((f) => /\.pdf$/i.test(f.name) || f.type === 'application/pdf');
|
|
1253
1459
|
const skipped = files.length - pdfs.length;
|
|
@@ -1257,7 +1463,9 @@ function boot() {
|
|
|
1257
1463
|
S.uploadNote = `Adding ${pdfs[i].name} (${i + 1} of ${pdfs.length})…`; render();
|
|
1258
1464
|
try {
|
|
1259
1465
|
const sent = { ...sending(), cond: false }; // unconditional, like Propose
|
|
1260
|
-
const
|
|
1466
|
+
const digest = await pdfDigest(pdfs[i]);
|
|
1467
|
+
const { body } = await call(`${base}/references?name=${encodeURIComponent(pdfs[i].name)}`, { method: 'POST', headers: { 'content-type': 'application/pdf' }, body: pdfs[i],
|
|
1468
|
+
ownRefs: digest ? [{ sha256: digest, kind: 'added' }] : [] });
|
|
1261
1469
|
// Adopted even on a profile with no draft yet: the first upload creates it, and the read that follows shows it.
|
|
1262
1470
|
adoptAnswer(sent, { references: body.references }, body.etag);
|
|
1263
1471
|
added++;
|
|
@@ -1286,13 +1494,12 @@ function boot() {
|
|
|
1286
1494
|
const anyTicked = list.some((i) => i.enabled);
|
|
1287
1495
|
const changed = !!(S.review && S.review.groups && S.review.groups.length);
|
|
1288
1496
|
const rows = list.map((it) => {
|
|
1289
|
-
const pct = typeof it.frequency === 'number' ? Math.round(it.frequency * 100) : null;
|
|
1290
1497
|
const origin = it.origin === 'client-standard'
|
|
1291
1498
|
? 'added from client standard'
|
|
1292
|
-
: it.origin === 'redline' ? 'added from a redline' :
|
|
1499
|
+
: it.origin === 'redline' ? 'added from a redline' : tallyLine(it) || 'proposed from the references';
|
|
1293
1500
|
return `<label class="check-row"><input type="checkbox" data-item="${esc(it.id)}" data-command-id="drawing-check.tick-item#${esc(it.id)}" data-command-instance-label="${esc(it.label)}"${it.enabled ? ' checked' : ''}>
|
|
1294
1501
|
<span class="lbl">${esc(it.label)}<span class="origin">${esc(origin)}</span></span>
|
|
1295
|
-
${
|
|
1502
|
+
${freqHtml(it)}
|
|
1296
1503
|
<span class="kind">by code</span></label>${it.rule && it.rule.type === 'hole-bolt' ? clearancesHtml(it, S.clearNote) : ''}${it.rule && it.rule.type === 'part-list-agrees' && mainRowItem(list) === it
|
|
1297
1504
|
? mainPartHtml(it, { touched: ((S.draft && S.draft.touched) || []).includes(`item:${it.id}.mainRow`), note: S.mainNote, locatedOn: list.some((x) => x.enabled && x.rule && x.rule.type === 'parts-located') }) : ''}${it.rule && it.rule.type === 'parts-located'
|
|
1298
1505
|
? lineBreakHtml(it, { touched: ((S.draft && S.draft.touched) || []).includes(`item:${it.id}.lineBreakPt`), note: S.breakNote, error: S.breakError, typed: S.breakTyped }) : ''}`;
|
|
@@ -1306,6 +1513,7 @@ function boot() {
|
|
|
1306
1513
|
${band}
|
|
1307
1514
|
${S.checklistError ? `<p class="err-line" role="alert">${esc(S.checklistError)}</p>` : ''}
|
|
1308
1515
|
${list.length ? `<div class="list">${rows}</div>` : '<p class="note">No items yet. Propose them from the reference drawings.</p>'}
|
|
1516
|
+
${bareInchHtml(S.draft && S.draft.lengths, { touched: ((S.draft && S.draft.touched) || []).includes('lengths.bareInchValues'), note: S.bareNote })}
|
|
1309
1517
|
${titleBlockHtml(S.draft && S.draft.titleBlock, { pages, note: S.titleNote, noteField: S.titleNoteField, saving: S.tbSaving, typed: S.typed })}
|
|
1310
1518
|
${partListHtml(S.draft && S.draft.partList, { proposed: list.length > 0 })}
|
|
1311
1519
|
${S.reviewError ? `<p class="note">${esc(S.reviewError)}</p>` : ''}
|
|
@@ -1343,14 +1551,16 @@ function boot() {
|
|
|
1343
1551
|
// the gen a choice carries is the one on screen when the person acted.
|
|
1344
1552
|
const itemsQueue = serialise();
|
|
1345
1553
|
let itemsInFlight = 0, choiceSeq = 0;
|
|
1554
|
+
// A checklist save answers at once; one that has not answered after this long frees the queue behind it (#3302).
|
|
1555
|
+
const CHOICE_DEADLINE_MS = 60000;
|
|
1346
1556
|
// The newest choice for each thing, and for each item or field the newest removal of it: an older choice that is
|
|
1347
1557
|
// held after a newer one was made is not offered back over it.
|
|
1348
1558
|
const latest = new Map(), removedAt = new Map();
|
|
1349
1559
|
/**
|
|
1350
1560
|
* Queue a choice. `key` names what it changes and `family` the item or field it belongs to (a removal, `removes`,
|
|
1351
1561
|
* takes the family's other choices with it). `apply(draft)` shows it on a draft and says whether its target is still
|
|
1352
|
-
* there; `url`/`body` send it; `parts(body)` are the draft parts its answer brings; `answered(body, newest)` sets its
|
|
1353
|
-
* note; `failed(e)` says a failure that is not a refusal; `held()` and `settled()` tidy up. `what` says it in the
|
|
1562
|
+
* there; `url`/`body` send it; `parts(body)` are the draft parts its answer brings; `answered(body, newest, fresh)` sets its
|
|
1563
|
+
* note (`fresh`: no newer version was taken on while it was out, so its answer is the one about to be shown); `failed(e)` says a failure that is not a refusal; `held()` and `settled()` tidy up. `what` says it in the
|
|
1354
1564
|
* band, `redo()` makes it again. `dialog`: kept in the dialog it came from when held, not listed.
|
|
1355
1565
|
* Resolves to the answer's body, null (failed) or 'held'.
|
|
1356
1566
|
*/
|
|
@@ -1369,7 +1579,7 @@ function boot() {
|
|
|
1369
1579
|
if (c.gen !== S.gen || S.sync !== 'ok') { hold(c); return 'held'; }
|
|
1370
1580
|
const sent = sending();
|
|
1371
1581
|
let body;
|
|
1372
|
-
try { ({ body } = await call(c.url, jsonOpts('PUT', c.body, sent.etag ? { 'if-match': sent.etag } : {}))); }
|
|
1582
|
+
try { ({ body } = await call(c.url, { ...jsonOpts('PUT', c.body, sent.etag ? { 'if-match': sent.etag } : {}), deadlineMs: CHOICE_DEADLINE_MS })); }
|
|
1373
1583
|
catch (e) {
|
|
1374
1584
|
if (e.status === 412 || e.status === 428) {
|
|
1375
1585
|
// The server holds a newer draft: everything queued behind this is held at its turn, and the draft is
|
|
@@ -1379,10 +1589,12 @@ function boot() {
|
|
|
1379
1589
|
}
|
|
1380
1590
|
S.pending = S.pending.filter((p) => p !== c); rebuild(); // its optimistic change goes; what is saved shows
|
|
1381
1591
|
if (c.failed) c.failed(e); else S.checklistError = e.message;
|
|
1592
|
+
// No answer in time: it may have been saved or not, so the whole draft is read to show what was (#3302).
|
|
1593
|
+
if (e.timedOut) { S.complete = false; readAll(); }
|
|
1382
1594
|
paint(); return null;
|
|
1383
1595
|
}
|
|
1384
1596
|
S.pending = S.pending.filter((p) => p !== c);
|
|
1385
|
-
if (c.answered) c.answered(body, latest.get(c.key) === c.seq);
|
|
1597
|
+
if (c.answered) c.answered(body, latest.get(c.key) === c.seq, S.serial === sent.serial);
|
|
1386
1598
|
if (adoptAnswer(sent, c.parts(body), body.etag) && itemsInFlight === 1) { await loadReview(); paint(); }
|
|
1387
1599
|
return body;
|
|
1388
1600
|
} finally {
|
|
@@ -1461,6 +1673,36 @@ function boot() {
|
|
|
1461
1673
|
redo: () => putMainPart(assemblyMark),
|
|
1462
1674
|
});
|
|
1463
1675
|
}
|
|
1676
|
+
// Whether this client writes inches without a mark (#2991). It is the person's from the click: the chip never credits
|
|
1677
|
+
// the references with their choice while it is out, and a choice held or failed takes that mark away with it.
|
|
1678
|
+
function putBareInches(bareInches) {
|
|
1679
|
+
S.checklistError = ''; S.bareNote = '';
|
|
1680
|
+
// What it was on the version the person chose on: choosing the answer already shown makes it theirs and changes no
|
|
1681
|
+
// reading, so its note never says that a reading changed (diff review r1).
|
|
1682
|
+
const was = !!(S.draft && S.draft.lengths && S.draft.lengths.bareInchValues === true);
|
|
1683
|
+
return choose({
|
|
1684
|
+
key: 'bare-inches', family: 'bare-inches',
|
|
1685
|
+
// In the control's own words, as the main part's line: "not inches" could be heard as "metric" (design review).
|
|
1686
|
+
what: `Set numbers without a mark to “${bareInches ? 'read them as inches' : 'say couldn’t tell'}”`,
|
|
1687
|
+
url: `${base}/bare-inches`, body: { bareInches },
|
|
1688
|
+
apply: (d) => {
|
|
1689
|
+
if (!d.lengths) return false;
|
|
1690
|
+
d.lengths.bareInchValues = bareInches;
|
|
1691
|
+
d.touched = [...new Set([...(d.touched || []), 'lengths.bareInchValues'])];
|
|
1692
|
+
return true;
|
|
1693
|
+
},
|
|
1694
|
+
parts: (b) => ({ lengths: b.lengths, touched: withTouched('lengths.bareInchValues') }),
|
|
1695
|
+
// Only the answer about to be shown says what was saved: one that lands after a newer version was taken on would
|
|
1696
|
+
// put its note (a metric warning, say) beside a setting it says nothing about (Codex plan review).
|
|
1697
|
+
answered: (b, newest, fresh) => {
|
|
1698
|
+
if (!newest || !fresh) return;
|
|
1699
|
+
const said = bareInches ? (was ? 'is still read as inches, now as your answer' : 'is now read as inches')
|
|
1700
|
+
: was ? 'is no longer read: it is reported as couldn’t tell' : 'is still reported as couldn’t tell, now as your answer';
|
|
1701
|
+
S.bareNote = b.warning ? b.warning : `A number without a mark on a dimension ${said}. The checklist has to be approved again.`;
|
|
1702
|
+
},
|
|
1703
|
+
redo: () => putBareInches(bareInches),
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1464
1706
|
/** One item edit: ticked or not, removed, or added (from the Add item dialog, which keeps it if it is held). */
|
|
1465
1707
|
function putItems(edits, { dialog = false } = {}) {
|
|
1466
1708
|
S.checklistError = '';
|
|
@@ -1548,8 +1790,8 @@ function boot() {
|
|
|
1548
1790
|
},
|
|
1549
1791
|
failed: (e) => {
|
|
1550
1792
|
// A typed answer the server refused stays in its field, with the reason beside it.
|
|
1551
|
-
if (change.answer && change.answer.label !== undefined) S.typed[change.answer.ask] = { value: change.answer.label, error: e
|
|
1552
|
-
else S.checklistError = e
|
|
1793
|
+
if (change.answer && change.answer.label !== undefined) S.typed[change.answer.ask] = { value: change.answer.label, error: errorText(e, { action: 'save that answer' }) };
|
|
1794
|
+
else S.checklistError = errorText(e, { action: 'save the checklist' });
|
|
1553
1795
|
},
|
|
1554
1796
|
// A held typed answer is listed with the other changes; its field closes rather than keep text that was not saved.
|
|
1555
1797
|
held: () => { if (change.answer) delete S.typed[change.answer.ask]; },
|
|
@@ -1612,8 +1854,9 @@ function boot() {
|
|
|
1612
1854
|
// and it carries only part of the draft: the whole draft is read after it (adopt).
|
|
1613
1855
|
const sent = { ...sending(), cond: false };
|
|
1614
1856
|
const { body } = await call(`${base}/propose`, { method: 'POST' });
|
|
1615
|
-
S.newSinceApproval = 0;
|
|
1616
|
-
|
|
1857
|
+
S.newSinceApproval = 0; S.bareNote = '';
|
|
1858
|
+
// The lengths it learned afresh, or none: the Dimensions section never shows the previous references' setting.
|
|
1859
|
+
adoptAnswer(sent, { items: body.items, titleBlock: body.titleBlock ?? null, partList: body.partList ?? null, lengths: body.lengths ?? null, ...(body.client ? { client: body.client } : {}) }, body.etag);
|
|
1617
1860
|
if (body.unreadable && body.unreadable.length) S.checklistError = `Couldn’t read ${body.unreadable.join(', ')}; the other drawings were used.`;
|
|
1618
1861
|
await loadReview();
|
|
1619
1862
|
} catch (e) { S.checklistError = e.message; }
|
|
@@ -1692,10 +1935,11 @@ function boot() {
|
|
|
1692
1935
|
if (!res) { e.target.disabled = false; e.target.textContent = 'Add and test on reference drawings'; err.hidden = false; err.textContent = S.checklistError || 'The item could not be added. Try again.'; return; }
|
|
1693
1936
|
const added = res.items.find((i) => !before.has(i.id));
|
|
1694
1937
|
scrim.dataset.added = added ? added.id : '';
|
|
1695
|
-
const
|
|
1938
|
+
const t = added && added.tally && added.tally.sheets ? added.tally : null;
|
|
1939
|
+
const unread = t ? t.sheets - t.decided : 0;
|
|
1696
1940
|
const out = scrim.querySelector('#ai-result'); out.hidden = false;
|
|
1697
|
-
out.textContent =
|
|
1698
|
-
: `Found on ${
|
|
1941
|
+
out.textContent = t === null ? 'Added. It could not be tested, because no reference drawing could be read.'
|
|
1942
|
+
: `Found on ${t.held} of ${t.sheets}${unread ? `, ${unread} could not be read` : ''} (${Math.round((t.held / t.sheets) * 100)}%). Rare is fine if the client requires it.`;
|
|
1699
1943
|
scrim.querySelector('.foot').innerHTML = '<button type="button" data-dlg="remove">Remove it</button><button type="button" class="primary" data-dlg="done">Keep item</button>';
|
|
1700
1944
|
scrim.querySelector('[data-dlg="done"]').focus();
|
|
1701
1945
|
});
|
|
@@ -1788,7 +2032,7 @@ function boot() {
|
|
|
1788
2032
|
const paths = [], names = [];
|
|
1789
2033
|
for (const f of files) {
|
|
1790
2034
|
const dataUrl = await new Promise((resolve, reject) => { const r = new FileReader(); r.onload = () => resolve(r.result); r.onerror = () => reject(new Error(`${f.name} could not be read.`)); r.readAsDataURL(f); });
|
|
1791
|
-
const { body } = await call('/api/visual-input', jsonOpts('POST', { appId: APP, name: 'drawings', dataUrl }));
|
|
2035
|
+
const { body } = await call('/api/visual-input', { ...jsonOpts('POST', { appId: APP, name: 'drawings', dataUrl }), draftWrite: false });
|
|
1792
2036
|
paths.push(body.path);
|
|
1793
2037
|
names.push(f.name);
|
|
1794
2038
|
}
|
|
@@ -1865,13 +2109,13 @@ function boot() {
|
|
|
1865
2109
|
catch (e) { S.running = null; S.runError = e.message; render(); return; }
|
|
1866
2110
|
let warnings = [];
|
|
1867
2111
|
let version; // undefined: the latest approved version; a number: the earlier one the person chose
|
|
1868
|
-
try { warnings = (await call(`${base}/preflight`, jsonOpts('POST', { drawings: paths, names }))).body.warnings || []; }
|
|
2112
|
+
try { warnings = (await call(`${base}/preflight`, { ...jsonOpts('POST', { drawings: paths, names }), draftWrite: false })).body.warnings || []; }
|
|
1869
2113
|
catch (e) {
|
|
1870
2114
|
S.running = null; render();
|
|
1871
2115
|
version = await fallbackDialog(e);
|
|
1872
2116
|
if (version === null) { S.runError = e.message; render(); return; }
|
|
1873
2117
|
S.running = `Checking ${pdfs.length} drawing${pdfs.length === 1 ? '' : 's'} against version ${version}…`; render();
|
|
1874
|
-
try { warnings = (await call(`${base}/preflight`, jsonOpts('POST', { drawings: paths, names, version }))).body.warnings || []; }
|
|
2118
|
+
try { warnings = (await call(`${base}/preflight`, { ...jsonOpts('POST', { drawings: paths, names, version }), draftWrite: false })).body.warnings || []; }
|
|
1875
2119
|
catch (e2) { S.running = null; S.runError = e2.message; render(); return; }
|
|
1876
2120
|
}
|
|
1877
2121
|
let decisions = {};
|
|
@@ -1892,7 +2136,7 @@ function boot() {
|
|
|
1892
2136
|
S.running = `Checking ${pdfs.length} drawing${pdfs.length === 1 ? '' : 's'}…`; render();
|
|
1893
2137
|
}
|
|
1894
2138
|
try {
|
|
1895
|
-
const { body } = await call(`${base}/runs`, jsonOpts('POST', { drawings: paths, names, decisions, ...(version !== undefined ? { version } : {}) }));
|
|
2139
|
+
const { body } = await call(`${base}/runs`, { ...jsonOpts('POST', { drawings: paths, names, decisions, ...(version !== undefined ? { version } : {}) }), draftWrite: false });
|
|
1896
2140
|
S.running = null;
|
|
1897
2141
|
await loadRuns();
|
|
1898
2142
|
await checkFinished(body.runId);
|
|
@@ -2091,7 +2335,7 @@ function boot() {
|
|
|
2091
2335
|
// What the run showed is taken BEFORE the save: stillPending compares the refresh with it.
|
|
2092
2336
|
const shownBefore = S.decisions.current[payload.findingId];
|
|
2093
2337
|
try {
|
|
2094
|
-
const { body } = await call(`${base}/runs/${encodeURIComponent(runId)}/decisions`, jsonOpts('POST', payload));
|
|
2338
|
+
const { body } = await call(`${base}/runs/${encodeURIComponent(runId)}/decisions`, { ...jsonOpts('POST', payload), draftWrite: false });
|
|
2095
2339
|
// The finding is pending from here until a refresh shows this decision (stillPending), never merely because
|
|
2096
2340
|
// the refresh worked: one whose decisions are unreadable, or that shows an earlier decision, confirms nothing.
|
|
2097
2341
|
S.pendingByRun[runId] = [...(S.pendingByRun[runId] || []).filter((p) => p.findingId !== payload.findingId),
|
|
@@ -2460,7 +2704,7 @@ function boot() {
|
|
|
2460
2704
|
return track(async () => {
|
|
2461
2705
|
const btn = root.querySelector('[data-act="mark"]'); if (btn) btn.disabled = true;
|
|
2462
2706
|
try {
|
|
2463
|
-
const { body } = await call(`${base}/runs/${encodeURIComponent(S.run.runId)}/checked`, jsonOpts('POST', { drawing: s.drawing, page: s.page }));
|
|
2707
|
+
const { body } = await call(`${base}/runs/${encodeURIComponent(S.run.runId)}/checked`, { ...jsonOpts('POST', { drawing: s.drawing, page: s.page }), draftWrite: false });
|
|
2464
2708
|
S.run.checkedBy = body.checkedBy || S.run.checkedBy;
|
|
2465
2709
|
// The record may have come back unsigned or unverified: the badge must say so now, not after a reload.
|
|
2466
2710
|
if (body.signature) S.run.signature = body.signature;
|
|
@@ -2476,7 +2720,7 @@ function boot() {
|
|
|
2476
2720
|
const btn = root.querySelector('[data-act="export"]'); if (btn) { btn.disabled = true; btn.textContent = 'Exporting…'; }
|
|
2477
2721
|
let failed = '';
|
|
2478
2722
|
try {
|
|
2479
|
-
const { body } = await call(`${base}/runs/${encodeURIComponent(S.run.runId)}/export`, jsonOpts('POST', { drawing: s.drawing }));
|
|
2723
|
+
const { body } = await call(`${base}/runs/${encodeURIComponent(S.run.runId)}/export`, { ...jsonOpts('POST', { drawing: s.drawing }), draftWrite: false });
|
|
2480
2724
|
const fails = body.tagFailures || [];
|
|
2481
2725
|
S.exportCard = `<div class="export-card" role="status"><b>${esc(body.filename)}</b> saved.
|
|
2482
2726
|
${fails.length ? `<details><summary>${fails.length} item number${fails.length === 1 ? '' : 's'} couldn’t be placed on the sheet. ${fails.length === 1 ? 'It is' : 'They’re'} listed on the cover page.</summary>${fails.map((f) => `<div class="note">${esc(tagFailureNote(f))}</div>`).join('')}</details>` : ''}
|
|
@@ -2525,10 +2769,10 @@ function boot() {
|
|
|
2525
2769
|
async function saveColours(next) {
|
|
2526
2770
|
const err = document.getElementById('colour-err');
|
|
2527
2771
|
try {
|
|
2528
|
-
const { body } = await call(`${base}/colours`, jsonOpts('PUT', next));
|
|
2772
|
+
const { body } = await call(`${base}/colours`, { ...jsonOpts('PUT', next), draftWrite: false });
|
|
2529
2773
|
S.colours = body.colours; S.colourWarning = body.warning; S.coloursUnread = false;
|
|
2530
2774
|
render();
|
|
2531
|
-
} catch (e) { if (err) { err.hidden = false; err.textContent = e
|
|
2775
|
+
} catch (e) { if (err) { err.hidden = false; err.textContent = errorText(e, { action: 'save the markup colours', retrySafe: true }); } }
|
|
2532
2776
|
}
|
|
2533
2777
|
|
|
2534
2778
|
// ── events ──
|
|
@@ -2541,7 +2785,7 @@ function boot() {
|
|
|
2541
2785
|
if (t.classList.contains('item')) { selectItem(Number(t.dataset.n)); return; }
|
|
2542
2786
|
if (t.dataset.zoom) { ({ fit: () => view.fit(), in: () => view.zoom(0.8), out: () => view.zoom(1.25) })[t.dataset.zoom](); return; }
|
|
2543
2787
|
if (t.dataset.file) {
|
|
2544
|
-
try { await call(t.dataset.file === 'open' ? '/api/open-file' : '/api/reveal', jsonOpts('POST', { path: t.dataset.path })); }
|
|
2788
|
+
try { await call(t.dataset.file === 'open' ? '/api/open-file' : '/api/reveal', { ...jsonOpts('POST', { path: t.dataset.path }), draftWrite: false }); }
|
|
2545
2789
|
catch { t.insertAdjacentHTML('afterend', '<span class="err-line"> That file could not be opened. It may have been moved.</span>'); }
|
|
2546
2790
|
return;
|
|
2547
2791
|
}
|
|
@@ -2588,6 +2832,19 @@ function boot() {
|
|
|
2588
2832
|
refocusIfLost(document, root, '[data-main-row][aria-checked="true"]');
|
|
2589
2833
|
return;
|
|
2590
2834
|
}
|
|
2835
|
+
if (t.dataset.bareInches) {
|
|
2836
|
+
const l = S.draft && S.draft.lengths, want = t.dataset.bareInches === 'yes';
|
|
2837
|
+
const mine = ((S.draft && S.draft.touched) || []).includes('lengths.bareInchValues');
|
|
2838
|
+
// As the main part: the choice shows at once; its answer settles it, or it is listed as not saved. Choosing the
|
|
2839
|
+
// answer already shown still records it as the person's, so proposing again keeps it.
|
|
2840
|
+
if (l && ((l.bareInchValues === true) !== want || !mine)) {
|
|
2841
|
+
const saving = putBareInches(want);
|
|
2842
|
+
root.querySelector('[data-bare-inches][aria-checked="true"]')?.focus();
|
|
2843
|
+
await saving;
|
|
2844
|
+
}
|
|
2845
|
+
refocusIfLost(document, root, '[data-bare-inches][aria-checked="true"]');
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2591
2848
|
if (t.dataset.tbRemove) { await putTitleBlock({ remove: t.dataset.tbRemove }); return; }
|
|
2592
2849
|
const act = t.dataset.act;
|
|
2593
2850
|
if (act === 'add-field') { addFieldDialog(); return; }
|
|
@@ -2746,7 +3003,7 @@ function boot() {
|
|
|
2746
3003
|
// AI Chat card, in another window. The page reads them again when the server says so (relayed by the workspace,
|
|
2747
3004
|
// liveRefreshFor), when the person comes back to the Checker step, and when they open Reference drawings — the last
|
|
2748
3005
|
// two also cover a missed event. Reads are coalesced and go out on the checklist queue, so they never interleave with a checklist PUT.
|
|
2749
|
-
let want = {}, refreshTimer = null, loaded = null;
|
|
3006
|
+
let want = {}, refreshTimer = null, loaded = null, refreshWaitSince = 0;
|
|
2750
3007
|
function refreshSoon(what) {
|
|
2751
3008
|
if (what.designSet) want.designSet = true;
|
|
2752
3009
|
if (what.draft) {
|
|
@@ -2757,34 +3014,41 @@ function boot() {
|
|
|
2757
3014
|
if (!what.etag || (want.etag && want.etag !== what.etag)) want.anyDraft = true;
|
|
2758
3015
|
else want.etag = what.etag;
|
|
2759
3016
|
}
|
|
2760
|
-
|
|
2761
|
-
refreshTimer = setTimeout(refreshNow, 200);
|
|
3017
|
+
// Coalesced into the timer already set, never restarted: events that keep coming cannot hold the read off (#3302).
|
|
3018
|
+
if (!refreshTimer) refreshTimer = setTimeout(refreshNow, 200);
|
|
2762
3019
|
}
|
|
2763
3020
|
function refreshNow() {
|
|
2764
|
-
|
|
2765
|
-
|
|
3021
|
+
refreshTimer = null;
|
|
3022
|
+
// Wait for this page's own writes: their answer brings the new etag, so their echo is not read as news. Not for
|
|
3023
|
+
// longer than OWN_WRITE_WAIT_MS from the first wait, however many writes follow (#3302): past it the refresh is
|
|
3024
|
+
// read, and a read a write of the page's own keeps stale ends in the "could not read the latest" line.
|
|
3025
|
+
if (ownWrites) {
|
|
3026
|
+
if (!refreshWaitSince) refreshWaitSince = Date.now();
|
|
3027
|
+
if (Date.now() - refreshWaitSince < OWN_WRITE_WAIT_MS) { refreshTimer = setTimeout(refreshNow, 300); return; }
|
|
3028
|
+
}
|
|
3029
|
+
refreshWaitSince = 0;
|
|
2766
3030
|
const w = want; want = {};
|
|
2767
3031
|
void itemsQueue(async () => {
|
|
2768
3032
|
if (loaded) await loaded; // what was read before the page first painted is not a change
|
|
2769
3033
|
if (S.loadError) return; // the page shows why it could not load, with Reload
|
|
2770
3034
|
const draft = !!w.draft && (!!w.anyDraft || w.etag !== S.etag);
|
|
2771
3035
|
if (!draft && !w.designSet) return;
|
|
2772
|
-
const
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
3036
|
+
const shown = () => JSON.stringify([S.draft, S.etag, S.designSet, S.designSetError, S.review, S.refsReadNote]);
|
|
3037
|
+
let drawn = shown();
|
|
3038
|
+
let failed = false;
|
|
3039
|
+
// The draft and the design set are read as one batch: what they bring is said once both have landed. A read
|
|
3040
|
+
// that crossed a write of this page's own adopted nothing (#3121) and is read again inside the batch, so the
|
|
3041
|
+
// batch never ends half-read (#3297).
|
|
3042
|
+
const batch = refsBatchOpen();
|
|
2776
3043
|
await Promise.all([
|
|
2777
3044
|
w.designSet ? loadDesignSet() : null,
|
|
2778
|
-
|
|
2779
|
-
draft ? loadDraft().then((got) => { if (got === 'stale') stale = true; else return loadReview(); }).catch(() => { failed = true; }) : null,
|
|
3045
|
+
draft ? readDraftSettled().then((read) => { if (!read) failed = true; }, () => { failed = true; }) : null,
|
|
2780
3046
|
]);
|
|
2781
|
-
|
|
2782
|
-
if (
|
|
2783
|
-
|
|
2784
|
-
if (failed)
|
|
2785
|
-
|
|
2786
|
-
// not announced as a change made elsewhere (the page says what its own changes did).
|
|
2787
|
-
else if (note && !ownWrites && ownWriteSeq === seq) S.liveNote = note;
|
|
3047
|
+
// Only a draft read settles this line: a design-set read alone says nothing about the reference list (PR #3308 review).
|
|
3048
|
+
if (draft) S.refsReadNote = failed ? 'This page could not read the latest reference drawings just now. Reload the profile to see them.' : '';
|
|
3049
|
+
if (batch.close()) drawn = shown(); // said, and drawn with it
|
|
3050
|
+
if (draft && !failed) await loadReview();
|
|
3051
|
+
if (drawn === shown()) return;
|
|
2788
3052
|
// The run on screen does not show the references or the design set: it is left alone, and the next paint shows
|
|
2789
3053
|
// what was read.
|
|
2790
3054
|
if (S.tab === 'runs' && S.run) return;
|