@floless/app 0.165.0 → 0.167.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 +30794 -25371
- package/dist/schemas/drawing-check.profile.v1.schema.json +4 -2
- package/dist/schemas/steel.model.v2.schema.json +2 -1
- package/dist/skills/floless-app-knowledge/SKILL.md +8 -1
- package/dist/skills/floless-app-rfi/SKILL.md +7 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +4 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -17
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +15 -1
- package/dist/templates/college-phase-exporter.flo +41 -49
- package/dist/templates/screenshot-to-saved-settings.flo +12 -2
- package/dist/web/app.css +120 -1
- package/dist/web/aware.js +385 -88
- package/dist/web/chat-question-card.js +3 -1
- package/dist/web/chat.css +32 -0
- package/dist/web/chat.js +1021 -88
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +231 -19
- package/dist/web/commands-steel.js +22 -2
- package/dist/web/drawing-check-editor.html +4 -0
- package/dist/web/drawing-check-editor.js +82 -2
- package/dist/web/index.html +14 -6
- package/dist/web/project-history.js +163 -19
- package/dist/web/project-modules.js +5 -0
- package/dist/web/project-rfis.js +206 -20
- package/dist/web/steel-ai-marks.js +173 -2
- package/dist/web/steel-editor.html +770 -49
- package/dist/web/steel-filter-flo.js +171 -7
- package/dist/web/steel-filter.html +36 -10
- package/dist/web/steel-model-v2-projection.js +26 -20
- package/dist/web/terminal-requests.js +5 -0
- package/dist/web/tool-updates.js +65 -20
- package/dist/web/workspaces.js +632 -85
- package/package.json +3 -2
package/dist/web/project-rfis.js
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
const bridge = () => window.flolessBridge || {};
|
|
14
14
|
/** Only a General project links other projects (its Modules step), so only it can cite their sheets (#2470 R6.6d). */
|
|
15
15
|
const linksProjects = (project) => !!project && (project.templateId || project.app) === 'floless-general';
|
|
16
|
+
/** #2470 R6.6d: a Trace or Drawing Checker project's RFIs can also cite the project's own sheets (by its lineage root). */
|
|
17
|
+
const ownSheetsCitable = (project) => !!project && ['vectorize', 'drawing-check'].includes(project.templateId || project.app);
|
|
16
18
|
const api = (path, init) => {
|
|
17
19
|
if (typeof bridge().api === 'function') return bridge().api(path, init);
|
|
18
20
|
return fetch(path, { headers: { 'Content-Type': 'application/json' }, ...init }).then(async (res) => {
|
|
@@ -88,6 +90,83 @@
|
|
|
88
90
|
];
|
|
89
91
|
const dispositionLabel = (key) => DISPOSITIONS.find((d) => d.key === key)?.label || key;
|
|
90
92
|
|
|
93
|
+
/* ── Earlier rounds (#2470 R6.6d carve-out) ──────────────────────────────────────────────────────────────────────
|
|
94
|
+
A reopened RFI keeps every earlier round. The list carries only how many; the rounds load when the person opens
|
|
95
|
+
them, oldest first, each as what happened in order. Cached per RFI and revision, never the failure. */
|
|
96
|
+
const shortDay = (iso) => {
|
|
97
|
+
const t = Date.parse(iso); if (!Number.isFinite(t)) return '';
|
|
98
|
+
const at = new Date(t);
|
|
99
|
+
return at.toLocaleDateString(undefined, at.getFullYear() === new Date().getFullYear() ? { day: 'numeric', month: 'short' } : { day: 'numeric', month: 'short', year: 'numeric' });
|
|
100
|
+
};
|
|
101
|
+
/** A short date to read, the exact one to point at and for a screen reader. */
|
|
102
|
+
const dated = (iso) => `<time datetime="${esc(iso)}" data-tip="${esc(exact(iso))}"><span aria-hidden="true">${esc(shortDay(iso))}</span><span class="sr-only">${esc(exact(iso))}</span></time>`;
|
|
103
|
+
function roundEntryHtml(e) {
|
|
104
|
+
const line = (text) => `<li>${dated(e.at)} · ${text}</li>`;
|
|
105
|
+
switch (e.t) {
|
|
106
|
+
case 'raised': return line(`Filed${e.by === 'ai' ? ' by AI Chat' : ''}: ${esc(e.question)}`);
|
|
107
|
+
case 'reopened': return line(`Reopened: ${esc(e.why)}`);
|
|
108
|
+
case 'sent': return line(`${e.via === 'gmail' ? 'Sent with Gmail to' : e.via === 'other' ? `Sent another way (${esc(e.how || '')}) to` : 'Marked sent to'} ${esc(e.to)}`);
|
|
109
|
+
case 'answered': return line(`Answer: ${esc(e.text)}`);
|
|
110
|
+
case 'closed': return line(`Closed: ${esc(dispositionLabel(e.disposition))}${e.note ? `. ${esc(e.note)}` : '.'}`);
|
|
111
|
+
default: return '';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function roundsHtml(rfi) {
|
|
115
|
+
if (!rfi.earlierRounds) return '';
|
|
116
|
+
const id = esc(rfi.id);
|
|
117
|
+
const open = state.roundsOpen?.has(rfi.id);
|
|
118
|
+
const toggle = `<button type="button" class="ghost" data-pr-rounds="${id}" aria-expanded="${open ? 'true' : 'false'}" aria-controls="pr-rounds-${id}"
|
|
119
|
+
data-command-id="shell.project-rfi-earlier-rounds#${esc(rfi.id)}" data-command-instance-label="${id}" data-tip="What was asked, sent, answered and closed before this RFI was reopened">Earlier rounds (${rfi.earlierRounds})</button>`;
|
|
120
|
+
let body = '';
|
|
121
|
+
const got = state.rounds?.get(rfi.id);
|
|
122
|
+
// A record's revision only rises, so rounds read at or after the list's revision are current for it.
|
|
123
|
+
const fresh = got && got.revision >= rfi.recordRevision ? got : null;
|
|
124
|
+
const busy = open && (!fresh || fresh.status === 'loading');
|
|
125
|
+
if (open) {
|
|
126
|
+
if (!fresh || fresh.status === 'loading') body = '<p class="pg-row-meta" role="status">Loading earlier rounds…</p>';
|
|
127
|
+
else if (fresh.status === 'error') body = `<p class="pg-row-meta" role="status">${esc(fresh.error)}</p>
|
|
128
|
+
<div class="pm-strip-acts"><button type="button" class="ghost" data-pr-rounds-again="${id}" data-command-id="shell.project-rfi-earlier-rounds-again#${esc(rfi.id)}" data-command-instance-label="${id}">Try again</button></div>`;
|
|
129
|
+
else if (!fresh.rounds.length) body = '<p class="pg-row-meta" role="status">No earlier rounds were found for this RFI.</p>';
|
|
130
|
+
else body = `<ol class="pr-rounds" aria-label="${esc(`Earlier rounds of ${rfi.id}`)}">${fresh.rounds.map((r) => {
|
|
131
|
+
const first = r.entries[0];
|
|
132
|
+
const head = first ? `${first.t === 'reopened' ? 'Reopened' : 'Filed'} ${dated(first.at)}` : '';
|
|
133
|
+
return `<li><p class="pr-round-head">Round ${r.round}${head ? ` · ${head}` : ''}</p><ul class="pg-row-meta pr-settled">${r.entries.map(roundEntryHtml).join('')}</ul></li>`;
|
|
134
|
+
}).join('')}</ol>`;
|
|
135
|
+
}
|
|
136
|
+
return `<div class="pm-strip-acts">${toggle}</div><div id="pr-rounds-${id}" class="pr-rounds-body"${busy ? ' aria-busy="true"' : ''}>${body}</div>`;
|
|
137
|
+
}
|
|
138
|
+
async function loadRounds(rfiId, revision) {
|
|
139
|
+
const mine = state;
|
|
140
|
+
mine.rounds ??= new Map();
|
|
141
|
+
mine.rounds.set(rfiId, { status: 'loading', revision });
|
|
142
|
+
try {
|
|
143
|
+
const res = await api(`/api/projects/${encodeURIComponent(target().projectId)}/correspondence-rfis/${encodeURIComponent(rfiId)}/rounds`);
|
|
144
|
+
if (state !== mine) return;
|
|
145
|
+
// Never below the revision asked for: an answer behind the list cannot start the reads over (Codex review).
|
|
146
|
+
const read = Math.max(res.recordRevision ?? revision, revision);
|
|
147
|
+
mine.rounds.set(rfiId, { status: 'ready', revision: read, rounds: res.rounds || [] });
|
|
148
|
+
const now = mine.view?.data?.rfis?.find((r) => r.id === rfiId);
|
|
149
|
+
if (now && mine.roundsOpen?.has(rfiId)) {
|
|
150
|
+
// The list moved on while this read was out: read the rounds it has now (the server answers at or past it).
|
|
151
|
+
if (now.recordRevision > read) { void loadRounds(rfiId, now.recordRevision); return; }
|
|
152
|
+
// The rounds are newer than the list (changed elsewhere): read the list once, never the rounds again.
|
|
153
|
+
// Not while a form is open: the list's repaint would drop what is being typed (refresh() holds the same line).
|
|
154
|
+
if (now.recordRevision < read && !mine.form) { mine.quietLoad = true; void load(); }
|
|
155
|
+
}
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (state !== mine) return;
|
|
158
|
+
mine.rounds.set(rfiId, { status: 'error', revision, error: said(error, 'FloLess couldn’t load the earlier rounds just now.') });
|
|
159
|
+
}
|
|
160
|
+
readDraft();
|
|
161
|
+
// Back to the toggle only if the person is still there (or on its Try again, gone while loading): never pull them
|
|
162
|
+
// out of a form or another pane when the rounds land.
|
|
163
|
+
const at = document.activeElement;
|
|
164
|
+
if (!at || at === document.body || at.getAttribute?.('data-pr-rounds') === rfiId || at.getAttribute?.('data-pr-rounds-again') === rfiId) {
|
|
165
|
+
state.focusAfter = `[data-pr-rounds="${CSS.escape(rfiId)}"]`;
|
|
166
|
+
}
|
|
167
|
+
paint();
|
|
168
|
+
}
|
|
169
|
+
|
|
91
170
|
/** How a citation's state reads on its chip and in its tip (the server's reason first, when it gave one). */
|
|
92
171
|
const CITE_STATE = {
|
|
93
172
|
current: { word: '', tip: 'Still matches what was cited.' },
|
|
@@ -100,10 +179,18 @@
|
|
|
100
179
|
'sheet-unusable': { word: 'sheet unreadable', tip: 'FloLess couldn’t read this sheet just now.' },
|
|
101
180
|
detached: { word: 'from a copy', tip: 'This came with a copy of the project and is not checked against the current links. File it again to cite a sheet here.' },
|
|
102
181
|
'not-checked': { word: 'not checked', tip: 'Not looked at from this chat.' },
|
|
182
|
+
// #2470 R6.6d: a project's own sheets (the server's reason is the tip; these are the fallbacks).
|
|
183
|
+
'sheet-changed': { word: 'sheet changed', tip: 'This sheet changed since it was cited. The RFI keeps what it cited.' },
|
|
184
|
+
'not-in-latest': { word: 'not in latest check', tip: 'The latest check did not include this drawing. The check it was cited from is kept.' },
|
|
103
185
|
};
|
|
104
|
-
const
|
|
186
|
+
const OWN_PREFIX = { trace: 'Sheet', 'checker-reference': 'Reference', 'checker-run': 'Checked' };
|
|
187
|
+
// Two pages of one drawing can share a drawing number, so a page the label doesn't already say is added to it.
|
|
188
|
+
const ownPage = (c) => (c.pageNumber && !String(c.sheet).endsWith(`page ${c.pageNumber}`) ? `page ${c.pageNumber}` : '');
|
|
189
|
+
const citeLabel = (c) => (c.kind === 'knowledge-page' ? `Knowledge · ${c.title}`
|
|
190
|
+
: c.kind === 'own-sheet' ? `${OWN_PREFIX[c.source] || 'Sheet'} · ${c.sheet}${ownPage(c) ? ` · ${ownPage(c)}` : ''}` : `Drawing · ${c.sheet} · ${c.linkedProjectName}`);
|
|
105
191
|
function chipHtml(c) {
|
|
106
|
-
|
|
192
|
+
// A state this page doesn't know is never shown as fine: it reads as not checked.
|
|
193
|
+
const st = CITE_STATE[c.state] || CITE_STATE['not-checked'];
|
|
107
194
|
const word = st.word ? ` · ${st.word}` : '';
|
|
108
195
|
return `<span class="pw-chip pr-cite${st.word ? ' is-muted' : ''}" role="listitem" tabindex="0" data-tip="${esc(c.reason || st.tip)}">${esc(citeLabel(c))}${esc(word)}</span>`;
|
|
109
196
|
}
|
|
@@ -265,6 +352,8 @@
|
|
|
265
352
|
if (rfi.sent) meta.push(`<span data-tip="${esc(exact(rfi.sent.at))}">${rfi.sent.via === 'gmail' ? 'Sent with Gmail to' : rfi.sent.via === 'other' ? `Sent another way (${esc(rfi.sent.how || '')}) to` : 'Marked sent to'} ${esc(rfi.sent.to)} · ${esc(ago(rfi.sent.at, now))}</span>`);
|
|
266
353
|
else meta.push(`<span data-tip="${esc(exact(rfi.raisedAt))}">Filed ${esc(ago(rfi.raisedAt, now))}${rfi.raisedBy === 'ai' ? ' by AI Chat' : ''}</span>`);
|
|
267
354
|
if (rfi.reopens) meta.push(`Reopened ${rfi.reopens === 1 ? 'once' : `${rfi.reopens} times`}`);
|
|
355
|
+
// #2470 R6.6d: why the current round is open again, under the question it reopens.
|
|
356
|
+
const reopenedNote = rfi.reopened ? `<p class="pm-note pr-reopened">Reopened ${dated(rfi.reopened.at)}: ${esc(rfi.reopened.why)}</p>` : '';
|
|
268
357
|
const answer = rfi.answer ? `<blockquote class="pr-answer"><span class="pr-answer-label">Answer</span> ${esc(rfi.answer.text)}</blockquote>` : '';
|
|
269
358
|
const closed = rfi.closed ? `<p class="pg-row-meta">Closed: ${esc(dispositionLabel(rfi.closed.disposition))}${rfi.closed.note ? `. ${esc(rfi.closed.note)}` : '.'}</p>` : '';
|
|
270
359
|
const provenance = rfi.provenance ? `<p class="pm-note">${esc(rfi.provenance)}</p>` : '';
|
|
@@ -337,7 +426,7 @@
|
|
|
337
426
|
<div class="pg-row-line"><span class="pg-row-title" tabindex="-1" data-pr-title="${id}">${id} · ${esc(rfi.title)}</span>
|
|
338
427
|
<span class="pw-chip${rfi.status === 'closed' ? ' is-muted' : ''}">${esc(STATUS[rfi.status] || rfi.status)}</span>${pending ? `<span class="pw-chip is-muted">${d.status === 'prepared' ? 'Unfinished' : 'Not confirmed'}</span>` : ''}</div>
|
|
339
428
|
<span class="pg-row-meta">${meta.join(' · ')}</span>
|
|
340
|
-
<p class="pr-question">${esc(rfi.question)}</p>${answer}${closed}${provenance}${cites}${driftNote}${deliveryNote}
|
|
429
|
+
<p class="pr-question">${esc(rfi.question)}</p>${reopenedNote}${answer}${closed}${provenance}${cites}${driftNote}${deliveryNote}${roundsHtml(rfi)}
|
|
341
430
|
${form || `<div class="pm-strip-acts pr-acts">${verbButtons}</div>`}
|
|
342
431
|
${state.copied?.rfiId === rfi.id ? `<textarea class="pr-input pr-text pr-copied" data-pr-copied="1" readonly rows="6" data-command-id="shell.project-rfi-copied-text#${esc(rfi.id)}" data-command-instance-label="${id}" aria-label="${esc(`Email text of ${rfi.id}`)}">${esc(state.copied.text)}</textarea>` : ''}</div>`;
|
|
343
432
|
}
|
|
@@ -412,7 +501,15 @@
|
|
|
412
501
|
const data = await api(`/api/projects/${encodeURIComponent(mine.project.id)}/correspondence-rfis`);
|
|
413
502
|
if (state !== mine || mine.generation !== generation) return;
|
|
414
503
|
mine.view = { status: 'ready', data, error: null };
|
|
504
|
+
// An open Earlier rounds whose RFI changed since it loaded reads again (#2470 R6.6d).
|
|
505
|
+
for (const rfi of data.rfis) {
|
|
506
|
+
if (!mine.roundsOpen?.has(rfi.id) || !rfi.earlierRounds) continue;
|
|
507
|
+
const got = mine.rounds?.get(rfi.id);
|
|
508
|
+
if (!got || (got.revision < rfi.recordRevision && got.status !== 'loading')) void loadRounds(rfi.id, rfi.recordRevision);
|
|
509
|
+
}
|
|
415
510
|
if (mine.form && !data.rfis.some((r) => r.id === mine.form.rfiId)) mine.form = null;
|
|
511
|
+
// A form opened while this read was out keeps what was typed across the repaint (Codex review, #2470 R6.6d).
|
|
512
|
+
readDraft();
|
|
416
513
|
paint();
|
|
417
514
|
settleWant();
|
|
418
515
|
if (data.store === 'ok') {
|
|
@@ -883,7 +980,13 @@
|
|
|
883
980
|
if (!sheet || sheet.mode !== 'form' || sheet.uncertain) return;
|
|
884
981
|
for (const el of $body.querySelectorAll('[data-pr-field]')) sheet[el.getAttribute('data-pr-field')] = el.value;
|
|
885
982
|
}
|
|
886
|
-
|
|
983
|
+
// An own sheet's key carries its run, so the same file in a newer check is another option (plan R6.6d, Codex round 2 item 16).
|
|
984
|
+
const citeKey = (c) => (c.kind === 'knowledge-page' ? `k:${c.slug}`
|
|
985
|
+
: c.kind === 'own-sheet' ? `o:${c.source}:${c.ref}:${c.pageNumber ?? '-'}:${c.digest}:${c.runId || '-'}` : `d:${c.linkedProjectUuid}:${c.pageId}:${c.sourceHash}`);
|
|
986
|
+
/** What filing sends for one cited item: its identity only — the server takes every label from what it reads. */
|
|
987
|
+
const citationBody = (c) => (c.kind === 'knowledge-page' ? { kind: c.kind, generationId: c.generationId, slug: c.slug }
|
|
988
|
+
: c.kind === 'own-sheet' ? { kind: c.kind, source: c.source, ref: c.ref, pageNumber: c.pageNumber, digest: c.digest, ...(c.runId ? { runId: c.runId } : {}) }
|
|
989
|
+
: { kind: c.kind, linkedProjectUuid: c.linkedProjectUuid, pageId: c.pageId, sourceHash: c.sourceHash });
|
|
887
990
|
|
|
888
991
|
/** Try Gmail again asks first, in a dialog with a tick the person must give (owner ruling, #2470 R6.6e). */
|
|
889
992
|
function openAgain(f) {
|
|
@@ -927,6 +1030,20 @@
|
|
|
927
1030
|
void sendSettle(mine, f, f.sent);
|
|
928
1031
|
}
|
|
929
1032
|
|
|
1033
|
+
/**
|
|
1034
|
+
* #2470 R6.6d: filing found that one cited item no longer matches. Nothing was filed; the person chooses: cite it
|
|
1035
|
+
* again, or file without it. Bound to that item's key (not its position), so an edit since can't aim it elsewhere.
|
|
1036
|
+
*/
|
|
1037
|
+
function recoveryHtml(mine) {
|
|
1038
|
+
const c = mine.cites.find((x) => citeKey(x) === mine.recovery.key);
|
|
1039
|
+
if (!c) return `<div class="pm-note pr-alert" role="alert">${esc(mine.error)}</div>`;
|
|
1040
|
+
const alone = mine.cites.length === 1;
|
|
1041
|
+
return `<div class="pm-note pr-alert" role="alert"><p>${esc(citeLabel(c))}: ${esc(mine.error)}${alone ? ' Filed without it, the RFI cites nothing.' : ''}</p>
|
|
1042
|
+
<p><button type="button" class="ghost" data-pr-recover="again" data-command-id="shell.project-rfi-cite-again">Choose it again</button>
|
|
1043
|
+
<button type="button" class="ghost" data-pr-recover="without" data-command-id="shell.project-rfi-file-without"
|
|
1044
|
+
data-tip="Takes ${esc(citeLabel(c))} out of what this RFI cites, then files it">File without it</button></p></div>`;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
930
1047
|
function paintSheet() {
|
|
931
1048
|
const t = target();
|
|
932
1049
|
if (!sheet || !t) return;
|
|
@@ -935,12 +1052,13 @@
|
|
|
935
1052
|
$title.textContent = 'New RFI';
|
|
936
1053
|
$sub.textContent = `A question from “${t.name}”. FloLess keeps it; after filing you can send it with Gmail or copy its email text.`;
|
|
937
1054
|
const ro = sheet.uncertain || sheet.busy ? ' readonly' : '';
|
|
938
|
-
const chips = sheet.cites.map((c, i) => `<span class="pw-chip pr-cite${c.changed ? ' is-muted' : ''}" role="listitem">${esc(citeLabel(c))}${c.changed ? ' · changed' : ''}
|
|
1055
|
+
const chips = sheet.cites.map((c, i) => `<span class="pw-chip pr-cite${c.changed ? ' is-muted' : ''}" role="listitem">${esc(citeLabel(c))}${c.changed ? (c.changed === 'citation-project-unavailable' ? ' · can’t be read now' : c.kind === 'own-sheet' ? ' · sheet changed' : ' · changed') : ''}
|
|
939
1056
|
<button type="button" class="pr-chip-x" data-pr-uncite="${i}" aria-label="${esc(`Remove ${citeLabel(c)}`)}" data-command-id="shell.project-rfi-cite-remove#${esc(citeKey(c))}"
|
|
940
|
-
data-command-instance-label="${esc(citeLabel(c))}"${sheet.uncertain ? ' disabled' : ''}>✕</button></span>`).join('');
|
|
1057
|
+
data-command-instance-label="${esc(citeLabel(c))}"${sheet.uncertain || sheet.busy ? ' disabled' : ''}>✕</button></span>`).join('');
|
|
941
1058
|
const full = sheet.cites.length >= MAX_CITES;
|
|
942
1059
|
const banner = sheet.uncertain
|
|
943
1060
|
? `<div class="pm-note pr-alert" role="alert">FloLess couldn’t confirm it was filed. It may already be in the list. To change something, choose Edit; FloLess will treat it as a new RFI.</div>`
|
|
1061
|
+
: sheet.recovery && sheet.error ? recoveryHtml(sheet)
|
|
944
1062
|
: sheet.error ? `<div class="pm-note pr-alert" role="alert">${esc(sheet.error)}</div>` : '';
|
|
945
1063
|
$body.innerHTML = `${banner}
|
|
946
1064
|
<label class="pr-field">Title<input class="pr-input" data-pr-field="title" maxlength="120" value="${esc(sheet.title)}" data-command-id="shell.project-rfi-title"${ro}></label>
|
|
@@ -948,7 +1066,7 @@
|
|
|
948
1066
|
<div class="pr-field"><span>Cited</span>
|
|
949
1067
|
<div class="pr-cites" role="list" aria-label="Cited items">${chips || '<span class="pg-row-meta">Nothing cited yet. You can cite up to 5 items.</span>'}</div>
|
|
950
1068
|
<p><button type="button" class="ghost" data-pr-cite="1" aria-haspopup="listbox" data-command-id="shell.project-rfi-cite"
|
|
951
|
-
data-tip="${full ? 'You can cite up to 5 items. Remove one to cite another.' : linksProjects(state?.project) ? 'Cite a page of this project’s Knowledge or a saved sheet of a linked project' : 'Cite a page of this project’s Knowledge'}"${full || sheet.uncertain ? ' aria-disabled="true"' : ''}>Cite…</button></p></div>
|
|
1069
|
+
data-tip="${full ? 'You can cite up to 5 items. Remove one to cite another.' : linksProjects(state?.project) ? 'Cite a page of this project’s Knowledge or a saved sheet of a linked project' : ownSheetsCitable(state?.project) ? 'Cite a Knowledge page or one of this project’s sheets' : 'Cite a page of this project’s Knowledge'}"${full || sheet.uncertain || sheet.busy ? ' aria-disabled="true"' : ''}>Cite…</button></p></div>
|
|
952
1070
|
<label class="pr-field">To (optional)<input type="email" class="pr-input" data-pr-field="to" value="${esc(sheet.to)}" autocomplete="email" data-command-id="shell.project-rfi-to"${ro}>
|
|
953
1071
|
<span class="pg-row-meta">Only needed to record who you sent it to.</span></label>`;
|
|
954
1072
|
$foot.innerHTML = sheet.uncertain
|
|
@@ -983,13 +1101,35 @@
|
|
|
983
1101
|
return `<button type="button" class="pr-option" role="option" aria-selected="${picked}" data-pr-option="${esc(k)}"
|
|
984
1102
|
data-command-id="shell.project-rfi-cite-option#${esc(k)}" data-command-instance-label="${esc(citeLabel(c))}">
|
|
985
1103
|
<span class="pr-check" aria-hidden="true">${picked ? '✓' : ''}</span><span class="pg-row-title">${esc(c.kind === 'knowledge-page' ? c.title : c.sheet)}</span>
|
|
986
|
-
${c.kind === 'linked-drawing' && c.pageNumber ? `<span class="pg-row-meta">page ${esc(c.pageNumber)}</span>` : ''}
|
|
1104
|
+
${c.kind === 'linked-drawing' && c.pageNumber ? `<span class="pg-row-meta">page ${esc(c.pageNumber)}</span>` : ''}
|
|
1105
|
+
${c.kind === 'own-sheet' && ((c.drawing && !c.sheet.includes(c.drawing)) || ownPage(c)) ? `<span class="pg-row-meta">${esc([c.drawing && !c.sheet.includes(c.drawing) ? c.drawing : '', ownPage(c)].filter(Boolean).join(' · '))}</span>` : ''}</button>`;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
const ownOption = (r) => ({ kind: 'own-sheet', source: r.source, ref: r.ref, pageNumber: r.pageNumber, digest: r.digest, sheet: r.sheet, drawing: r.drawing, ...(r.runId ? { runId: r.runId } : {}) });
|
|
1109
|
+
const dayOf = (iso) => { const d = new Date(iso); return Number.isNaN(d.getTime()) ? '' : d.toLocaleDateString(undefined, { day: 'numeric', month: 'short', year: 'numeric' }); };
|
|
1110
|
+
/** #2470 R6.6d: one group of this project's own sheets — a Trace's traced sheets, a Drawing Checker's references or its latest check. */
|
|
1111
|
+
function ownGroupHtml(g, i, picks) {
|
|
1112
|
+
const title = g.source === 'trace' ? 'Traced sheets' : g.source === 'checker-reference' ? 'Reference drawings'
|
|
1113
|
+
: g.ranAt ? (g.unreadableRuns ? `Last check FloLess could read · ${dayOf(g.ranAt)}` : `Latest check · ${dayOf(g.ranAt)}`) : 'Latest check';
|
|
1114
|
+
const empty = g.source === 'trace' ? 'No traced sheets yet. Trace the drawing on its Traced step, then cite its sheets here.'
|
|
1115
|
+
: g.source === 'checker-reference' ? 'No reference drawings yet. Add them to the checklist, then cite them here.'
|
|
1116
|
+
: g.ranAt ? `The latest check (${dayOf(g.ranAt)}) has no drawings FloLess can cite.` : 'No check run yet. Run a check, then cite its drawings here.';
|
|
1117
|
+
const options = (g.sheets || []).map(ownOption);
|
|
1118
|
+
const omitted = g.omitted ? `<p class="pm-note">${g.omitted === 1 ? 'One traced sheet shares' : `${g.omitted} traced sheets share`} an id with another, so FloLess can’t cite ${g.omitted === 1 ? 'it' : 'them'}. Trace the drawing again to fix it.</p>` : '';
|
|
1119
|
+
const note = omitted + (g.unreadableRuns ? `<p class="pm-note">${g.unreadableRuns === 1 ? 'One check result couldn’t be read' : `${g.unreadableRuns} check results couldn’t be read`}, so a newer check may exist.</p>` : '');
|
|
1120
|
+
const body = g.state === 'ok' ? (options.length ? options.map((c) => optionHtml(c, picks.has(citeKey(c)))).join('') : g.omitted ? '' : '<p class="pm-note">No sheet matches.</p>')
|
|
1121
|
+
+ (g.truncated ? '<p class="pg-row-meta">Showing the first 200. Type in Filter to narrow it.</p>' : '')
|
|
1122
|
+
: g.state === 'empty' ? `<p class="pm-note">${empty}</p>`
|
|
1123
|
+
: `<p class="pm-note">${esc(g.reason || 'These sheets can’t be read just now.')}</p><p><button type="button" class="ghost" data-pr-cite-retry="1"
|
|
1124
|
+
data-command-id="shell.project-rfi-cite-retry#own-${esc(g.source)}" data-command-instance-label="this project">Try again</button></p>`;
|
|
1125
|
+
return `<div role="group" aria-labelledby="pr-g-o${i}"><p class="pr-group" id="pr-g-o${i}">${esc(title)}</p>${note}${body}</div>`;
|
|
987
1126
|
}
|
|
988
1127
|
|
|
989
1128
|
function paintPicker() {
|
|
990
1129
|
const mine = sheet;
|
|
991
1130
|
$title.textContent = 'Cite';
|
|
992
1131
|
$sub.textContent = linksProjects(state?.project) ? 'A page of this project’s Knowledge, or a saved sheet of a project linked on its Modules step.'
|
|
1132
|
+
: ownSheetsCitable(state?.project) ? 'A page of this project’s Knowledge, or one of this project’s own sheets.'
|
|
993
1133
|
: 'A page of this project’s Knowledge.';
|
|
994
1134
|
const picks = mine.picks;
|
|
995
1135
|
const search = `<input type="search" class="ws-landing-search pr-search" data-pr-search="1" placeholder="Filter" aria-label="Filter what can be cited" value="${esc(mine.query)}" data-command-id="shell.project-rfi-cite-search">`;
|
|
@@ -1006,7 +1146,9 @@
|
|
|
1006
1146
|
: k.state === 'none' ? '<p class="pm-note">This project has no Knowledge pages yet. Add references on the Knowledge step and choose Organize, then cite them here.</p>'
|
|
1007
1147
|
: '<p class="pm-note">FloLess couldn’t list this project’s Knowledge just now.</p>';
|
|
1008
1148
|
groups = `<div role="group" aria-labelledby="pr-g-k"><p class="pr-group" id="pr-g-k">This project’s Knowledge</p>${kBody}</div>`;
|
|
1009
|
-
|
|
1149
|
+
const own = mine.citable.own || [];
|
|
1150
|
+
filterable = k.state !== 'none' || mine.citable.linked.length > 0 || own.some((g) => g.state === 'ok') || !!mine.query;
|
|
1151
|
+
own.forEach((g, i) => { groups += ownGroupHtml(g, i, picks); });
|
|
1010
1152
|
mine.citable.linked.forEach((l, i) => {
|
|
1011
1153
|
const options = (l.sheets || []).map((s) => ({ kind: 'linked-drawing', linkedProjectUuid: l.projectUuid, linkedProjectName: l.name, pageId: s.pageId, sourceHash: s.sourceHash, sheet: s.sheet, pageNumber: s.pageNumber }));
|
|
1012
1154
|
const body = l.state === 'ok' ? (options.length ? options.map((c) => optionHtml(c, picks.has(citeKey(c)))).join('') : '<p class="pm-note">No sheet matches.</p>')
|
|
@@ -1015,7 +1157,7 @@
|
|
|
1015
1157
|
data-command-id="shell.project-rfi-cite-retry#${esc(l.projectUuid)}" data-command-instance-label="${esc(l.name)}">Try again</button></p>` : ''}`;
|
|
1016
1158
|
groups += `<div role="group" aria-labelledby="pr-g-${i}"><p class="pr-group" id="pr-g-${i}">Saved sheets in ${esc(l.name)}</p>${body}</div>`;
|
|
1017
1159
|
});
|
|
1018
|
-
mine.options = new Map([...kOptions, ...mine.citable.linked.flatMap((l) => (l.sheets || []).map((s) => ({ kind: 'linked-drawing', linkedProjectUuid: l.projectUuid, linkedProjectName: l.name, pageId: s.pageId, sourceHash: s.sourceHash, sheet: s.sheet, pageNumber: s.pageNumber })))].map((c) => [citeKey(c), c]));
|
|
1160
|
+
mine.options = new Map([...kOptions, ...own.flatMap((g) => (g.sheets || []).map(ownOption)), ...mine.citable.linked.flatMap((l) => (l.sheets || []).map((s) => ({ kind: 'linked-drawing', linkedProjectUuid: l.projectUuid, linkedProjectName: l.name, pageId: s.pageId, sourceHash: s.sourceHash, sheet: s.sheet, pageNumber: s.pageNumber })))].map((c) => [citeKey(c), c]));
|
|
1019
1161
|
}
|
|
1020
1162
|
const hadFocus = document.activeElement?.hasAttribute?.('data-pr-search');
|
|
1021
1163
|
$body.innerHTML = `${filterable ? search : ''}<p class="sr-only pr-pick-live" role="status" aria-live="polite"></p><div class="pr-options" role="listbox" aria-multiselectable="true" aria-label="What can be cited">${groups}</div>`;
|
|
@@ -1033,7 +1175,7 @@
|
|
|
1033
1175
|
void loadCitable();
|
|
1034
1176
|
}
|
|
1035
1177
|
function closePicker(apply) {
|
|
1036
|
-
if (apply) sheet.cites = [...sheet.picks.values()].map((c) => ({ ...c, changed: false }));
|
|
1178
|
+
if (apply) { sheet.cites = [...sheet.picks.values()].map((c) => ({ ...c, changed: false })); sheet.recovery = null; }
|
|
1037
1179
|
sheet.mode = 'form';
|
|
1038
1180
|
paintSheet();
|
|
1039
1181
|
requestAnimationFrame(() => $body.querySelector('[data-pr-cite]')?.focus());
|
|
@@ -1054,10 +1196,11 @@
|
|
|
1054
1196
|
return;
|
|
1055
1197
|
}
|
|
1056
1198
|
if (!mine.uncertain) mine.payload = { ...identity(), operationKey: mine.key, title, question,
|
|
1057
|
-
citations: mine.cites.map(
|
|
1058
|
-
: { kind: c.kind, linkedProjectUuid: c.linkedProjectUuid, pageId: c.pageId, sourceHash: c.sourceHash })),
|
|
1199
|
+
citations: mine.cites.map(citationBody),
|
|
1059
1200
|
...(markSent ? { markSentTo: to } : {}) };
|
|
1060
|
-
|
|
1201
|
+
// What was submitted, in order: a refusal's citationIndex names one of THESE (the cites can't change while busy).
|
|
1202
|
+
const submitted = mine.cites.slice();
|
|
1203
|
+
mine.busy = true; mine.error = null; mine.recovery = null; paintSheet();
|
|
1061
1204
|
try {
|
|
1062
1205
|
const res = await api(`/api/projects/${encodeURIComponent(t.projectId)}/correspondence-rfis`, { method: 'POST', body: JSON.stringify(mine.payload) });
|
|
1063
1206
|
if (sheet !== mine) return;
|
|
@@ -1078,12 +1221,20 @@
|
|
|
1078
1221
|
mine.error = said(error, 'FloLess couldn’t file it just now. Try again.');
|
|
1079
1222
|
mine.uncertain = false;
|
|
1080
1223
|
mine.key = newKey(); // the next send after a refusal is a new intent
|
|
1081
|
-
if (/^citation-/.test(error.body.code || ''))
|
|
1224
|
+
if (/^citation-/.test(error.body.code || '')) {
|
|
1225
|
+
const refused = Number.isInteger(error.body.citationIndex) ? submitted[error.body.citationIndex] : null;
|
|
1226
|
+
if (refused) {
|
|
1227
|
+
const key = citeKey(refused);
|
|
1228
|
+
// The chip says why: a sheet that changed, or one that can't be read just now (a lapsed module, an unreadable file).
|
|
1229
|
+
mine.cites = mine.cites.map((c) => (citeKey(c) === key ? { ...c, changed: error.body.code } : c));
|
|
1230
|
+
mine.recovery = { key };
|
|
1231
|
+
} else mine.cites = mine.cites.map((c) => ({ ...c, changed: error.body.code }));
|
|
1232
|
+
}
|
|
1082
1233
|
} else {
|
|
1083
1234
|
mine.uncertain = true; // same key, same payload on Try again
|
|
1084
1235
|
}
|
|
1085
1236
|
paintSheet();
|
|
1086
|
-
($foot.querySelector(mine.uncertain ? '[data-pr-sheet-retry]' : '[data-pr-sheet-file="file"]'))?.focus();
|
|
1237
|
+
(mine.recovery ? $body.querySelector('[data-pr-recover="again"]') : $foot.querySelector(mine.uncertain ? '[data-pr-sheet-retry]' : '[data-pr-sheet-file="file"]'))?.focus();
|
|
1087
1238
|
}
|
|
1088
1239
|
}
|
|
1089
1240
|
|
|
@@ -1100,16 +1251,29 @@
|
|
|
1100
1251
|
if (t.closest('[data-pr-sheet-retry]')) { void fileRfi(!!sheet.payload?.markSentTo); return; }
|
|
1101
1252
|
if (t.closest('[data-pr-sheet-edit]')) { sheet.uncertain = false; sheet.key = newKey(); paintSheet(); $body.querySelector('[data-pr-field="title"]')?.focus(); return; }
|
|
1102
1253
|
if (t.closest('[data-pr-sheet-check]')) { closeSheet(); if (state) void load(); return; }
|
|
1254
|
+
const recover = t.closest('[data-pr-recover]');
|
|
1255
|
+
if (recover && sheet.recovery && !sheet.busy) {
|
|
1256
|
+
const key = sheet.recovery.key;
|
|
1257
|
+
if (recover.getAttribute('data-pr-recover') === 'again') { sheet.recovery = null; sheet.error = null; sheet.cites = sheet.cites.filter((c) => citeKey(c) !== key); openPicker(); return; }
|
|
1258
|
+
readSheet(); sheet.cites = sheet.cites.filter((c) => citeKey(c) !== key); sheet.recovery = null; void fileRfi(!!sheet.payload?.markSentTo); return;
|
|
1259
|
+
}
|
|
1260
|
+
// While a filing is in flight its citations are fixed: a refusal names one of what was sent.
|
|
1261
|
+
if (sheet.busy && (t.closest('[data-pr-cite]') || t.closest('[data-pr-uncite]') || t.closest('[data-pr-option]'))) return;
|
|
1103
1262
|
const cite = t.closest('[data-pr-cite]');
|
|
1104
1263
|
if (cite) { if (cite.getAttribute('aria-disabled') === 'true') { toast('You can cite up to 5 items. Remove one to cite another.', 'info'); return; } openPicker(); return; }
|
|
1105
1264
|
const uncite = t.closest('[data-pr-uncite]');
|
|
1106
|
-
if (uncite) { readSheet(); sheet.cites.splice(Number(uncite.getAttribute('data-pr-uncite')), 1); paintSheet(); $body.querySelector('[data-pr-cite]')?.focus(); return; }
|
|
1265
|
+
if (uncite) { readSheet(); sheet.cites.splice(Number(uncite.getAttribute('data-pr-uncite')), 1); sheet.recovery = null; paintSheet(); $body.querySelector('[data-pr-cite]')?.focus(); return; }
|
|
1107
1266
|
const option = t.closest('[data-pr-option]');
|
|
1108
1267
|
if (option) {
|
|
1109
1268
|
const k = option.getAttribute('data-pr-option');
|
|
1269
|
+
// A newer read of a sheet already picked (it changed since) replaces the older one, so one sheet is never cited twice.
|
|
1270
|
+
const picked = sheet.options.get(k);
|
|
1271
|
+
if (!sheet.picks.has(k) && picked?.kind === 'own-sheet') {
|
|
1272
|
+
for (const [key, c] of sheet.picks) if (c.kind === 'own-sheet' && citeKey({ ...c, digest: '' }) === citeKey({ ...picked, digest: '' })) sheet.picks.delete(key);
|
|
1273
|
+
}
|
|
1110
1274
|
if (sheet.picks.has(k)) sheet.picks.delete(k);
|
|
1111
1275
|
else if (sheet.picks.size >= MAX_CITES) { const live = $body.querySelector('.pr-pick-live'); if (live) live.textContent = 'You can cite up to 5 items.'; return; }
|
|
1112
|
-
else sheet.picks.set(k,
|
|
1276
|
+
else sheet.picks.set(k, picked);
|
|
1113
1277
|
paintPicker();
|
|
1114
1278
|
$body.querySelector(`[data-pr-option="${CSS.escape(k)}"]`)?.focus();
|
|
1115
1279
|
return;
|
|
@@ -1140,6 +1304,26 @@
|
|
|
1140
1304
|
if (t.closest('[data-pr-gmail-check]')) { state.form = null; state.quietLoad = true; void load(); return; }
|
|
1141
1305
|
const settle = t.closest('[data-pr-settle]');
|
|
1142
1306
|
if (settle) { openSettle(settle.getAttribute('data-pr-settle'), settle.getAttribute('data-pr-attempt')); return; }
|
|
1307
|
+
const rounds = t.closest('[data-pr-rounds]');
|
|
1308
|
+
if (rounds) {
|
|
1309
|
+
const rfiId = rounds.getAttribute('data-pr-rounds');
|
|
1310
|
+
state.roundsOpen ??= new Set();
|
|
1311
|
+
if (state.roundsOpen.has(rfiId)) state.roundsOpen.delete(rfiId);
|
|
1312
|
+
else {
|
|
1313
|
+
state.roundsOpen.add(rfiId);
|
|
1314
|
+
const rfi = state.view?.data?.rfis?.find((r) => r.id === rfiId);
|
|
1315
|
+
const got = state.rounds?.get(rfiId);
|
|
1316
|
+
if (rfi && !(got && got.revision >= rfi.recordRevision && got.status !== 'error')) void loadRounds(rfiId, rfi.recordRevision);
|
|
1317
|
+
}
|
|
1318
|
+
readDraft(); state.focusAfter = `[data-pr-rounds="${CSS.escape(rfiId)}"]`; paint(); return;
|
|
1319
|
+
}
|
|
1320
|
+
const roundsAgain = t.closest('[data-pr-rounds-again]');
|
|
1321
|
+
if (roundsAgain) {
|
|
1322
|
+
const rfiId = roundsAgain.getAttribute('data-pr-rounds-again');
|
|
1323
|
+
const rfi = state.view?.data?.rfis?.find((r) => r.id === rfiId);
|
|
1324
|
+
if (rfi) void loadRounds(rfiId, rfi.recordRevision);
|
|
1325
|
+
readDraft(); state.focusAfter = `[data-pr-rounds="${CSS.escape(rfiId)}"]`; paint(); return;
|
|
1326
|
+
}
|
|
1143
1327
|
const history = t.closest('[data-pr-history]');
|
|
1144
1328
|
if (history) {
|
|
1145
1329
|
const rfiId = history.getAttribute('data-pr-history');
|
|
@@ -1176,8 +1360,10 @@
|
|
|
1176
1360
|
const rfi = state.view.data.rfis.find((r) => r.id === again.getAttribute('data-pr-again'));
|
|
1177
1361
|
if (rfi) openSheet(again, { title: rfi.title, question: rfi.question,
|
|
1178
1362
|
// A page that reads current in a newer Knowledge version is cited there: a filing names the version published now.
|
|
1179
|
-
|
|
1180
|
-
|
|
1363
|
+
// A traced sheet re-numbered by a re-read is cited under its new id (same content: still current).
|
|
1364
|
+
cites: rfi.citations.filter((c) => c.state === 'current').map(({ state: _s, reason: _r, refileGenerationId, refileRef, ...c }) => (
|
|
1365
|
+
c.kind === 'knowledge-page' && refileGenerationId ? { ...c, generationId: refileGenerationId }
|
|
1366
|
+
: c.kind === 'own-sheet' && refileRef ? { ...c, ref: refileRef } : c)) });
|
|
1181
1367
|
return;
|
|
1182
1368
|
}
|
|
1183
1369
|
if (t.closest('[data-pr-retry]')) { state.view = { status: 'loading', data: null }; paint(); void load(); return; }
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { planViewId } from './steel-plan-view-id.js';
|
|
32
32
|
import { createMemberPresenceIndex, memberPresence } from './steel-model-v2-projection.js';
|
|
33
|
+
import { FT_IN, formatElevation, normalizeDisplayUnits, parseElevationMm } from './display-units.js';
|
|
33
34
|
|
|
34
35
|
const AI_ID = /^[0-9a-f]{12}$/;
|
|
35
36
|
const DIGEST = /^[0-9a-f]{64}$/;
|
|
@@ -67,6 +68,7 @@ export function subjectOk(v) {
|
|
|
67
68
|
case 'connection': return only(v, ['channel', 'jointId', 'covers']) && str(v.jointId, ID_MAX) && coversOk(v.covers);
|
|
68
69
|
case 'unmodelled-detail': return only(v, ['channel', 'sheetId', 'detailRef']) && str(v.sheetId, ID_MAX) && str(v.detailRef, ID_MAX);
|
|
69
70
|
case 'filter': return only(v, ['channel', 'checkpointDigest']) && typeof v.checkpointDigest === 'string' && DIGEST.test(v.checkpointDigest);
|
|
71
|
+
case 'scope': return only(v, ['channel', 'keptDigest']) && typeof v.keptDigest === 'string' && DIGEST.test(v.keptDigest);
|
|
70
72
|
default: return false;
|
|
71
73
|
}
|
|
72
74
|
}
|
|
@@ -83,6 +85,15 @@ export function valueOk(subject, v) {
|
|
|
83
85
|
if (v.exclusionDigest !== null && (typeof v.exclusionDigest !== 'string' || !DIGEST.test(v.exclusionDigest))) return false;
|
|
84
86
|
return nonNegInt(v.valueCount) && !(v.exclusionDigest === null && v.valueCount !== 0);
|
|
85
87
|
}
|
|
88
|
+
case 'scope': {
|
|
89
|
+
// `parseScopeDecisionValue`'s shape (#2554 kind 2); the server alone wrote it.
|
|
90
|
+
if (!isObj(v) || !only(v, ['keptDigest', 'kept', 'attached', 'leaveOut']) || v.keptDigest !== subject.keptDigest) return false;
|
|
91
|
+
if (!nonNegInt(v.kept) || !nonNegInt(v.attached) || v.kept < 1 || !Array.isArray(v.leaveOut) || v.leaveOut.length < 1) return false;
|
|
92
|
+
return v.kept + v.leaveOut.length === v.attached && new Set(v.leaveOut.map((f) => isObj(f) && f.sha256)).size === v.leaveOut.length
|
|
93
|
+
&& v.leaveOut.every((f) => isObj(f) && only(f, ['sha256', 'ext', 'bytes', 'names'])
|
|
94
|
+
&& typeof f.sha256 === 'string' && DIGEST.test(f.sha256) && typeof f.ext === 'string' && /^[a-z0-9]{1,8}$/.test(f.ext)
|
|
95
|
+
&& Number.isSafeInteger(f.bytes) && f.bytes > 0 && Array.isArray(f.names) && f.names.length > 0 && f.names.every((n) => str(n, 260)));
|
|
96
|
+
}
|
|
86
97
|
case 'setup':
|
|
87
98
|
if (!isObj(v)) return false;
|
|
88
99
|
if (subject.row === 'scale') return only(v, ['mmPerPx']) && finite(v.mmPerPx) && v.mmPerPx > 0;
|
|
@@ -99,6 +110,39 @@ function entryOk(entry) {
|
|
|
99
110
|
&& subjectOk(entry.subject) && entry.subject.channel === entry.channel && valueOk(entry.subject, entry.value);
|
|
100
111
|
}
|
|
101
112
|
|
|
113
|
+
// A length that names its own unit, at the very start of the AI's text: `8359.5 mm`, `8.36 m`, `27'-5 1/8"`, `28'`. It
|
|
114
|
+
// must END there (end of text, a space or punctuation): `28'-0 (top)` is not the length `28'` followed by "-0".
|
|
115
|
+
const LEAD_END = String.raw`(?=$|[\s,.;:()])`;
|
|
116
|
+
const LEAD_METRIC = new RegExp(String.raw`^[+-]?\d+(?:\.\d+)?\s*(?:mm|m)` + LEAD_END, 'i');
|
|
117
|
+
const LEAD_FT_IN = new RegExp(String.raw`^[+-]?\d+(?:\.\d+)?\s*'(?:\s*-?\s*(?:\d+\s+)?\d+(?:\.\d+|\/\d+)?\s*")?` + LEAD_END);
|
|
118
|
+
/** How far a written length may sit from the recorded value and still be that value: 0.5 mm, or 1/16". */
|
|
119
|
+
const LEAD_TOLERANCE_MM = { metric: 0.5, imperial: 1.6 };
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* #2998: an AI decision's `chosen` as the person reads it. The AI writes `chosen` in its own words and may give a height
|
|
123
|
+
* in millimetres in a ft-in project ("8359.5 mm, interpolated between the callouts either side"), while the decision
|
|
124
|
+
* also records the exact value (`value.mm`). When the text STARTS with a length in the other unit system that equals
|
|
125
|
+
* that value, the length is shown in the project's units ("27'-5 1/8", interpolated …") and the original is returned
|
|
126
|
+
* as `wrote` for a tooltip. Anything else — no recorded value, a length that does not match it, a length already in the
|
|
127
|
+
* project's units, a length later in the text — is returned exactly as the AI wrote it: only the unit changes, never a
|
|
128
|
+
* number. Display only; the recorded text is untouched.
|
|
129
|
+
*
|
|
130
|
+
* @param {unknown} chosen @param {unknown} value the decision's `value` @param {unknown} units the project's display units
|
|
131
|
+
* @returns {{ text: string, wrote?: string }}
|
|
132
|
+
*/
|
|
133
|
+
export function decisionChoiceInUnits(chosen, value, units) {
|
|
134
|
+
const text = typeof chosen === 'string' ? chosen : '';
|
|
135
|
+
if (!isObj(value) || !finite(value.mm)) return { text };
|
|
136
|
+
const shown = normalizeDisplayUnits(units);
|
|
137
|
+
const metric = LEAD_METRIC.exec(text), imperial = metric ? null : LEAD_FT_IN.exec(text);
|
|
138
|
+
const lead = metric || imperial;
|
|
139
|
+
if (!lead || (metric ? shown !== FT_IN : shown === FT_IN)) return { text };
|
|
140
|
+
const mm = parseElevationMm(lead[0], shown);
|
|
141
|
+
if (mm == null || Math.abs(mm - value.mm) > LEAD_TOLERANCE_MM[metric ? 'metric' : 'imperial']) return { text };
|
|
142
|
+
const wrote = lead[0].trim();
|
|
143
|
+
return { text: formatElevation(value.mm, shown) + text.slice(lead[0].length), wrote };
|
|
144
|
+
}
|
|
145
|
+
|
|
102
146
|
/**
|
|
103
147
|
* @param {unknown} model a steel.model/v2 document (the editor's `C`)
|
|
104
148
|
*/
|
|
@@ -194,7 +238,7 @@ export function aiDecisionMarksOf(model) {
|
|
|
194
238
|
}
|
|
195
239
|
break;
|
|
196
240
|
}
|
|
197
|
-
default: // filter, audit-gap, unmodelled-detail: they bear on the whole model
|
|
241
|
+
default: // filter, scope, audit-gap, unmodelled-detail: they bear on the whole model
|
|
198
242
|
note.push({ decisionId: id, channel: entry.channel, reason: 'model' });
|
|
199
243
|
}
|
|
200
244
|
}
|
|
@@ -202,7 +246,47 @@ export function aiDecisionMarksOf(model) {
|
|
|
202
246
|
return {
|
|
203
247
|
state: !readable ? 'unknown' : dependencies.size ? 'marks' : 'none',
|
|
204
248
|
members, ends, joints: [...jointsById.values()], views, model: note, entries,
|
|
205
|
-
decisionCount: dependencies.size,
|
|
249
|
+
decisionCount: dependencies.size, dependencyIds: [...dependencies],
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The marks of the decisions nobody has reviewed yet (#2521 row 8a): what the canvas, 3D and the strip show. A decision a
|
|
255
|
+
* person confirmed in Make precise stops being marked; Inspect keeps the full analysis and says who reviewed it. A mark
|
|
256
|
+
* resting on several decisions stays while any of them is unreviewed, naming only those. An unreadable reading stays
|
|
257
|
+
* unknown: a review never vouches for what FloLess could not read.
|
|
258
|
+
* @param {ReturnType<typeof aiDecisionMarksOf>} marks
|
|
259
|
+
* @param {{ has(id: string): boolean } | null | undefined} reviewed the reviewed decision ids
|
|
260
|
+
*/
|
|
261
|
+
export function unreviewedMarksOf(marks, reviewed) {
|
|
262
|
+
if (!reviewed || !marks.dependencyIds.some((id) => reviewed.has(id))) return marks;
|
|
263
|
+
const open = (id) => !reviewed.has(id);
|
|
264
|
+
const members = new Map();
|
|
265
|
+
for (const [memberId, list] of marks.members) {
|
|
266
|
+
const kept = [];
|
|
267
|
+
for (const mark of list) {
|
|
268
|
+
if (mark.kind === 'height') {
|
|
269
|
+
const decisionIds = mark.decisionIds.filter(open);
|
|
270
|
+
if (decisionIds.length) kept.push({ ...mark, decisionIds });
|
|
271
|
+
} else if (open(mark.decisionId)) kept.push(mark);
|
|
272
|
+
}
|
|
273
|
+
if (kept.length) members.set(memberId, kept);
|
|
274
|
+
}
|
|
275
|
+
const views = new Map();
|
|
276
|
+
for (const [viewId, rows] of marks.views) {
|
|
277
|
+
const kept = rows.filter((row) => open(row.decisionId));
|
|
278
|
+
if (kept.length) views.set(viewId, kept);
|
|
279
|
+
}
|
|
280
|
+
const dependencyIds = marks.dependencyIds.filter(open);
|
|
281
|
+
return {
|
|
282
|
+
state: marks.state === 'unknown' ? 'unknown' : dependencyIds.length ? 'marks' : 'none',
|
|
283
|
+
members,
|
|
284
|
+
ends: marks.ends.flatMap((e) => { const decisionIds = e.decisionIds.filter(open); return decisionIds.length ? [{ ...e, decisionIds }] : []; }),
|
|
285
|
+
joints: marks.joints.flatMap((j) => { const decisionIds = j.decisionIds.filter(open); return decisionIds.length ? [{ ...j, decisionIds }] : []; }),
|
|
286
|
+
views,
|
|
287
|
+
model: marks.model.filter((item) => item.decisionId === null || open(item.decisionId)),
|
|
288
|
+
entries: marks.entries,
|
|
289
|
+
decisionCount: dependencyIds.length, dependencyIds,
|
|
206
290
|
};
|
|
207
291
|
}
|
|
208
292
|
|
|
@@ -231,3 +315,90 @@ export function canvasMarksOf(marks) {
|
|
|
231
315
|
...(j.mainEnd !== undefined ? { mainEnd: j.mainEnd } : {}), ...(j.place ? { place: j.place } : {}) })),
|
|
232
316
|
};
|
|
233
317
|
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* What a Make precise Confirm or Confirm all says it did (#2521 row 8a). It words only what THIS confirm did, from the
|
|
321
|
+
* server's answers to it: another window may review the same decisions at any moment, so of the rest it says only that
|
|
322
|
+
* this confirm did not record them, never that they are unreviewed.
|
|
323
|
+
* @param {{ byYou: number, already: number, unsettled: number, left?: number | null,
|
|
324
|
+
* failure?: 'changed' | 'error' | 'unknown', refusal?: string, changed?: boolean }} o
|
|
325
|
+
* byYou: recorded as reviewed by this confirm; already: in what it settled, those someone had already reviewed;
|
|
326
|
+
* unsettled: those it did not record; left: what is still to review after it, when the server said; failure: why the
|
|
327
|
+
* unsettled were not recorded ('unknown': the answer was lost, so they may have been); refusal: FloLess's own sentence
|
|
328
|
+
* for a refusal, used only when nothing was settled; changed (#2521 row 8b): the person marked it changed, so what
|
|
329
|
+
* was recorded is said as a change.
|
|
330
|
+
*/
|
|
331
|
+
export function makePreciseOutcome(o) {
|
|
332
|
+
const was = (n) => (n === 1 ? 'was' : 'were');
|
|
333
|
+
const settled = o.byYou + o.already;
|
|
334
|
+
if (!o.unsettled) {
|
|
335
|
+
const left = Number.isSafeInteger(o.left) && o.left > 0 ? ` ${o.left} to review.` : '';
|
|
336
|
+
if (!o.byYou) return `${o.already} ${was(o.already)} already reviewed, so nothing new was recorded.${left}`;
|
|
337
|
+
const as = o.changed ? 'changed' : 'reviewed';
|
|
338
|
+
const mine = o.byYou === 1 && !o.already ? `Recorded as ${as} by you.` : `Recorded ${o.byYou} as ${as} by you.`;
|
|
339
|
+
return mine + (o.already ? ` ${o.already} ${was(o.already)} already reviewed.` : '') + left;
|
|
340
|
+
}
|
|
341
|
+
const changed = o.failure === 'changed', lost = o.failure === 'unknown';
|
|
342
|
+
if (!settled) {
|
|
343
|
+
if (lost) return 'FloLess did not get an answer, so it cannot tell whether this was recorded. The list now shows what is still to review.';
|
|
344
|
+
if (changed) {
|
|
345
|
+
return o.unsettled === 1
|
|
346
|
+
? 'Nothing was recorded: it changed since the list was shown. Check it and confirm again.'
|
|
347
|
+
: 'Nothing was recorded: some of these changed since the list was shown. Check them and confirm again.';
|
|
348
|
+
}
|
|
349
|
+
return o.refusal || 'FloLess could not record this just now, so nothing was recorded. Your model is unchanged. Try again in a moment.';
|
|
350
|
+
}
|
|
351
|
+
const done = !o.byYou
|
|
352
|
+
? `${o.already} ${was(o.already)} already reviewed, so this confirm recorded nothing new.`
|
|
353
|
+
: `This confirm recorded ${o.byYou} as reviewed by you${o.already ? `; ${o.already} ${was(o.already)} already reviewed` : ''}.`;
|
|
354
|
+
if (lost) {
|
|
355
|
+
const them = o.unsettled === 1 ? 'the other one, FloLess did not get an answer, so it cannot tell whether it was'
|
|
356
|
+
: `the other ${o.unsettled}, FloLess did not get an answer, so it cannot tell whether they were`;
|
|
357
|
+
return `${done} For ${them} recorded. The list now shows what is still to review.`;
|
|
358
|
+
}
|
|
359
|
+
const why = changed
|
|
360
|
+
? (o.unsettled === 1 ? 'it changed since the list was shown. Check it and confirm again.' : 'some changed since the list was shown. Check them and confirm again.')
|
|
361
|
+
: `FloLess could not record ${o.unsettled === 1 ? 'it' : 'them'} just now. Try again in a moment.`;
|
|
362
|
+
return `${done} ${o.unsettled} ${was(o.unsettled)} not recorded by it: ${why}`;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Send a Make precise confirm a batch at a time (#2521 row 8a). One request may carry only so many decisions, and each
|
|
367
|
+
* is all or nothing, so a later batch that fails leaves the earlier ones recorded; it stops at the first batch that did
|
|
368
|
+
* not settle and says what the settled ones were.
|
|
369
|
+
* @template {{ decisionId: string }} T
|
|
370
|
+
* @param {T[]} items
|
|
371
|
+
* @param {number} size what one request may carry
|
|
372
|
+
* @param {(batch: T[]) => Promise<{ ok: boolean, status: number, json(): Promise<any> }>} send throws an error with
|
|
373
|
+
* `notSent: true` when the request never left (nothing can have been recorded)
|
|
374
|
+
* @param {(settled: number) => void} [onBatch] called before each batch after the first, with how many settled so far
|
|
375
|
+
* @returns {Promise<{ settled: number, byYou: number, already: number, reviewedIds: string[], quick: unknown,
|
|
376
|
+
* res: { ok: boolean, status: number } | null, d: any, unknown: boolean, error?: unknown }>}
|
|
377
|
+
* settled: how many of `items` the server settled; byYou / already: of those, recorded by this confirm / reviewed
|
|
378
|
+
* before it; reviewedIds: both, as the server named them; quick: the label of the last answer that settled
|
|
379
|
+
* (undefined when none did); res, d: the last answer and its body (null when there was none); unknown: the last
|
|
380
|
+
* request may have been recorded but its answer was lost (no answer, or an OK one that could not be read).
|
|
381
|
+
*/
|
|
382
|
+
export async function confirmInBatches(items, size, send, onBatch) {
|
|
383
|
+
const out = { settled: 0, byYou: 0, already: 0, reviewedIds: [], quick: undefined, res: null, d: null, unknown: false };
|
|
384
|
+
for (let i = 0; i < items.length; i += size) {
|
|
385
|
+
const batch = items.slice(i, i + size);
|
|
386
|
+
if (i && onBatch) onBatch(out.settled);
|
|
387
|
+
out.res = null; out.d = null;
|
|
388
|
+
try {
|
|
389
|
+
out.res = await send(batch);
|
|
390
|
+
out.d = await out.res.json().catch(() => null);
|
|
391
|
+
} catch (error) {
|
|
392
|
+
out.res = null; out.d = null; out.error = error;
|
|
393
|
+
out.unknown = !(error && error.notSent);
|
|
394
|
+
}
|
|
395
|
+
if (out.res && out.res.ok && !out.d) out.unknown = true;
|
|
396
|
+
if (!(out.res && out.res.ok && out.d)) break;
|
|
397
|
+
const mine = Array.isArray(out.d.confirmed) ? out.d.confirmed : [];
|
|
398
|
+
const before = Array.isArray(out.d.alreadyReviewed) ? out.d.alreadyReviewed : [];
|
|
399
|
+
out.reviewedIds.push(...mine, ...before);
|
|
400
|
+
out.quick = out.d.quick ?? null;
|
|
401
|
+
out.settled += batch.length; out.byYou += mine.length; out.already += before.length;
|
|
402
|
+
}
|
|
403
|
+
return out;
|
|
404
|
+
}
|