@floless/app 0.168.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/cli-actions.mjs +8 -1
- package/dist/floless-server.cjs +125533 -99597
- 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-rfi/SKILL.md +4 -2
- 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/templates/college-phase-exporter.flo +7 -2
- package/dist/templates/trimble-list-projects.flo +10 -2
- package/dist/web/agent-steps.js +90 -19
- package/dist/web/agents.js +77 -31
- package/dist/web/app.css +267 -4
- package/dist/web/app.js +71 -7
- package/dist/web/aware-update-client.js +4 -4
- package/dist/web/aware.js +1277 -219
- package/dist/web/chat.css +10 -0
- package/dist/web/chat.js +407 -117
- package/dist/web/checkpoint-standard.js +5 -3
- package/dist/web/commands-drawing-check.js +4 -0
- package/dist/web/commands-shell.js +551 -15
- package/dist/web/commands-steel.js +68 -2
- package/dist/web/commands-vector.js +69 -0
- package/dist/web/drawing-check-editor.html +10 -0
- package/dist/web/drawing-check-editor.js +821 -237
- package/dist/web/failure-copy.js +50 -2
- package/dist/web/filter-ai-proposal.js +11 -8
- package/dist/web/flo-3d.js +310 -0
- package/dist/web/flo-card.js +72 -0
- package/dist/web/guide.js +33 -24
- package/dist/web/index.html +95 -5
- package/dist/web/instructor.js +102 -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-editor-steel-adapter.js +41 -1
- 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/model-viewport-toolbar.js +11 -0
- package/dist/web/origin-rule.js +155 -0
- package/dist/web/pages.js +17 -14
- package/dist/web/panels.js +1 -1
- package/dist/web/project-access.js +1 -1
- package/dist/web/project-history.js +2 -2
- package/dist/web/project-modules.js +5 -5
- package/dist/web/project-reconciliation.js +1 -1
- package/dist/web/project-rfis.js +8 -3
- package/dist/web/project-workflows.js +8 -6
- package/dist/web/renderers.js +6 -0
- package/dist/web/report-csp.js +68 -0
- package/dist/web/revit-editor.js +22 -8
- package/dist/web/run-history.js +14 -4
- package/dist/web/steel-3d-core.js +39 -9
- package/dist/web/steel-3d-flo.js +331 -0
- package/dist/web/steel-3d-view.js +164 -0
- package/dist/web/steel-ai-marks.js +3 -1
- package/dist/web/steel-editor.html +583 -129
- 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 +79 -1
- package/dist/web/tool-updates.js +9 -7
- package/dist/web/vector-3d.html +1 -1
- package/dist/web/vector-editor.html +50 -8
- package/dist/web/workspace-root-management.js +1 -1
- package/dist/web/workspaces.js +2334 -253
- package/launch.mjs +5 -0
- package/package.json +11 -8
package/dist/web/workspaces.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
if (!res.ok || body.ok === false) {
|
|
24
24
|
// #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
|
|
25
25
|
const readOnly = /^(GET|HEAD)$/.test(String(requestOptions.method || 'GET').toUpperCase());
|
|
26
|
-
const e = new Error(body
|
|
26
|
+
const e = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text);
|
|
27
27
|
e.body = body;
|
|
28
28
|
e.status = res.status;
|
|
29
29
|
throw e;
|
|
@@ -306,6 +306,7 @@
|
|
|
306
306
|
const $companyKnowledgeList = document.getElementById('company-knowledge-list');
|
|
307
307
|
const $companyKnowledgeConfirm = document.getElementById('company-knowledge-confirm');
|
|
308
308
|
const $companyKnowledgeError = document.getElementById('company-knowledge-error');
|
|
309
|
+
const $companyKnowledgeStatus = document.getElementById('company-knowledge-status');
|
|
309
310
|
const $companyKnowledgeClose = document.getElementById('company-knowledge-close');
|
|
310
311
|
const $companyKnowledgeCancel = document.getElementById('company-knowledge-cancel');
|
|
311
312
|
const $companyKnowledgeAction = document.getElementById('company-knowledge-action');
|
|
@@ -517,21 +518,21 @@
|
|
|
517
518
|
|
|
518
519
|
const TEKLA_PICK_LIMITS = Object.freeze({ files: 10_000, fileBytes: 512 * 1024 * 1024, totalBytes: 1.5 * 1024 * 1024 * 1024, depth: 32, pathBytes: 512 });
|
|
519
520
|
function validateTeklaPickedEntries(entries) {
|
|
520
|
-
if (!entries.length) throw
|
|
521
|
-
if (entries.length > TEKLA_PICK_LIMITS.files) throw
|
|
521
|
+
if (!entries.length) throw personError('The selected folder is empty.');
|
|
522
|
+
if (entries.length > TEKLA_PICK_LIMITS.files) throw personError('The selected folder contains more than 10,000 files.');
|
|
522
523
|
let total = 0;
|
|
523
524
|
for (const entry of entries) {
|
|
524
525
|
const path = String(entry.path || '').replaceAll('\\', '/').replace(/^\/+/, '');
|
|
525
526
|
const parts = path.split('/');
|
|
526
527
|
if (!path || path.includes(':') || parts.length > TEKLA_PICK_LIMITS.depth || parts.some((part) => !part || part === '.' || part === '..')) {
|
|
527
|
-
throw
|
|
528
|
+
throw personError('The selected folder contains an unsafe file path.');
|
|
528
529
|
}
|
|
529
530
|
if (new TextEncoder().encode(path).byteLength > TEKLA_PICK_LIMITS.pathBytes) {
|
|
530
|
-
throw
|
|
531
|
+
throw personError('The selected folder contains a file path longer than 512 bytes.');
|
|
531
532
|
}
|
|
532
|
-
if (entry.file.size > TEKLA_PICK_LIMITS.fileBytes) throw
|
|
533
|
+
if (entry.file.size > TEKLA_PICK_LIMITS.fileBytes) throw personError(`${entry.file.name} is larger than 512 MB.`);
|
|
533
534
|
total += entry.file.size;
|
|
534
|
-
if (!Number.isSafeInteger(total) || total > TEKLA_PICK_LIMITS.totalBytes) throw
|
|
535
|
+
if (!Number.isSafeInteger(total) || total > TEKLA_PICK_LIMITS.totalBytes) throw personError('The selected folder is larger than 1.5 GB.');
|
|
535
536
|
entry.path = path;
|
|
536
537
|
}
|
|
537
538
|
entries.sort((left, right) => left.path.localeCompare(right.path));
|
|
@@ -541,7 +542,7 @@
|
|
|
541
542
|
async function filesFromDirectoryHandle(root) {
|
|
542
543
|
const entries = [];
|
|
543
544
|
async function visit(directory, prefix, depth) {
|
|
544
|
-
if (depth > TEKLA_PICK_LIMITS.depth) throw
|
|
545
|
+
if (depth > TEKLA_PICK_LIMITS.depth) throw personError('The selected folder is nested too deeply.');
|
|
545
546
|
const children = [];
|
|
546
547
|
for await (const pair of directory.entries()) children.push(pair);
|
|
547
548
|
children.sort(([left], [right]) => left.localeCompare(right));
|
|
@@ -549,7 +550,7 @@
|
|
|
549
550
|
const logicalPath = prefix ? `${prefix}/${name}` : name;
|
|
550
551
|
if (handle.kind === 'file') entries.push({ path: logicalPath, file: await handle.getFile() });
|
|
551
552
|
else if (handle.kind === 'directory') await visit(handle, logicalPath, depth + 1);
|
|
552
|
-
if (entries.length > TEKLA_PICK_LIMITS.files) throw
|
|
553
|
+
if (entries.length > TEKLA_PICK_LIMITS.files) throw personError('The selected folder contains more than 10,000 files.');
|
|
553
554
|
}
|
|
554
555
|
}
|
|
555
556
|
await visit(root, '', 1);
|
|
@@ -581,7 +582,7 @@
|
|
|
581
582
|
|
|
582
583
|
// One ZIP of a Tekla model as a source — shared by the ZIP picker and a ZIP dropped on the card.
|
|
583
584
|
function teklaZipSource(file) {
|
|
584
|
-
if (!/\.zip$/i.test(file.name) || file.size > 1024 * 1024 * 1024) throw
|
|
585
|
+
if (!/\.zip$/i.test(file.name) || file.size > 1024 * 1024 * 1024) throw personError('Choose one Tekla model ZIP up to 1 GB.');
|
|
585
586
|
return { label: file.name, kind: 'zip', entries: [{ path: file.name, file }] };
|
|
586
587
|
}
|
|
587
588
|
async function pickTeklaZip(fallbackInput) {
|
|
@@ -667,6 +668,15 @@
|
|
|
667
668
|
* so it says "something newer happened", not "a newer EXPORTS render happened". (Review round 4.)
|
|
668
669
|
*/
|
|
669
670
|
let exportsRenderGen = 0;
|
|
671
|
+
// #3139: the latest Exports render's lifecycle check ran out of time, so the gate says it could not check (with a
|
|
672
|
+
// retry) instead of "Checking…" or a "Nothing to export yet" that FloLess never confirmed.
|
|
673
|
+
let exportsLifecycleUnanswered = false;
|
|
674
|
+
// Which lifecycle answer the Exports gate was last painted with, and the Exports render waiting on its lifecycle
|
|
675
|
+
// check (0 when none) — see syncExportsLifecycleGate.
|
|
676
|
+
let exportsPaintedGate = '';
|
|
677
|
+
let exportsLifecycleWait = 0;
|
|
678
|
+
// #3139: an answer handed to the render syncExportsLifecycleGate redoes ({ gen, present }), so it is not asked again.
|
|
679
|
+
let exportsLifecycleHanded = null;
|
|
670
680
|
let exportState = null; // kind → { path, exportedAt } after a successful list; null = unknown/failed
|
|
671
681
|
// #2449: { version, hash } of the approved version exportState's files came from, from the SAME listing; null = unknown.
|
|
672
682
|
let exportStateFrom = null;
|
|
@@ -711,6 +721,14 @@
|
|
|
711
721
|
let renderTicker = null;
|
|
712
722
|
const exportReceipts = new Map(); // projectId:kind → reconciled receipt counts for this browser session
|
|
713
723
|
const exportBusy = new Set(); // projectId:kind → one in-flight export
|
|
724
|
+
// #3273: how long a send's consent and source cleanup may take before its busy claim is released anyway. The server
|
|
725
|
+
// expires both on its own, so giving up on the request loses nothing; waiting on it forever left "Sending…" up.
|
|
726
|
+
const SEND_CLEANUP_MS = 15_000;
|
|
727
|
+
// #3273: how long one Exports refresh waits on each of its answers (the approval review, the listing, the export
|
|
728
|
+
// sources, render readiness). Generous, the same 90 s as the #1604 polls, because a loaded PC answers these slowly
|
|
729
|
+
// (#3139: a CPU-starved server took 44 s for the export sources); past it the pane says what it could not load
|
|
730
|
+
// instead of waiting for good.
|
|
731
|
+
const EXPORTS_REFRESH_MS = 90_000;
|
|
714
732
|
if (!$switch || !$landing || !$app) return; // markup absent — nothing to wire
|
|
715
733
|
|
|
716
734
|
// The picker menu is a `.menu` (display:none by default; `.menu.show` → display:block, which
|
|
@@ -1225,9 +1243,10 @@
|
|
|
1225
1243
|
*/
|
|
1226
1244
|
let projectContractLifecycle = 'unknown';
|
|
1227
1245
|
// A General project (#2470) has no Model, Exports or History step, so nothing the person clicks would
|
|
1228
|
-
// ever re-ask a lifecycle check that timed out or failed. It re-asks by itself
|
|
1229
|
-
//
|
|
1230
|
-
|
|
1246
|
+
// ever re-ask a lifecycle check that timed out or failed. It re-asks by itself once more; then the header says it
|
|
1247
|
+
// could not check rather than "Checking…" forever. Once, because each check already keeps trying for its own 45 s
|
|
1248
|
+
// budget (#3139): three re-asks made a hung server read "Checking project…" for over three minutes.
|
|
1249
|
+
const SOURCELESS_PRESENCE_RETRIES = 1;
|
|
1231
1250
|
let sourcelessPresence = { projectId: null, openSeq: 0, tries: 0, gaveUp: false, timer: null };
|
|
1232
1251
|
let exportsHasModel = false;
|
|
1233
1252
|
// A project may open on Model/Exports/History while its lifecycle probe is still in flight. Keep
|
|
@@ -1242,7 +1261,7 @@
|
|
|
1242
1261
|
* re-disable Approve on a project that now has a model. Every writer bumps it; older results drop. */
|
|
1243
1262
|
let modelPresenceGen = 0;
|
|
1244
1263
|
// One lifecycle request per open project. Tab clicks attach to this promise instead of starting
|
|
1245
|
-
// competing
|
|
1264
|
+
// competing probes (each keeps trying for up to 45 s) whose generation guards make all but the last answer disappear.
|
|
1246
1265
|
let modelPresenceProbe = null;
|
|
1247
1266
|
|
|
1248
1267
|
/** The header's AUTHORED tooltip, captured from the static markup so the has-a-model state restores
|
|
@@ -1438,7 +1457,9 @@
|
|
|
1438
1457
|
renderApprovalHeader();
|
|
1439
1458
|
return null;
|
|
1440
1459
|
}
|
|
1441
|
-
|
|
1460
|
+
// #3273: with a deadline, because every surface that waits for this verdict (the Exports listing among them) waits
|
|
1461
|
+
// on this request, and one that never answers is not an error: it would hold them all on "Loading…" for good.
|
|
1462
|
+
const review = await api(`/api/projects/${encodeURIComponent(projectId)}/approval-review`, { timeoutMs: EXPORTS_REFRESH_MS });
|
|
1442
1463
|
if (gen !== approvalStateGen || !current || current.id !== projectId) return null;
|
|
1443
1464
|
// NOT an error, and kept apart from one on purpose: the route answers this 200 for a project
|
|
1444
1465
|
// that legitimately has nothing to review (no model read in yet, or too old to carry the
|
|
@@ -1466,8 +1487,9 @@
|
|
|
1466
1487
|
return review;
|
|
1467
1488
|
} catch (error) {
|
|
1468
1489
|
if (gen !== approvalStateGen || !current || current.id !== projectId) return null;
|
|
1490
|
+
// A deadline that ran out has no sentence for a person, so it takes the generic one.
|
|
1469
1491
|
approvalState = { status: 'error', review: null, pendingCount: 0, headVersion: null,
|
|
1470
|
-
error: (error && error.message) || 'Approval status is unavailable — try again.' };
|
|
1492
|
+
error: (error && error.name !== 'TimeoutError' && error.message) || 'Approval status is unavailable — try again.' };
|
|
1471
1493
|
renderApprovalHeader();
|
|
1472
1494
|
if (!$wsExports.hidden) paintExports(current.approvedAt);
|
|
1473
1495
|
return null;
|
|
@@ -2083,6 +2105,7 @@
|
|
|
2083
2105
|
// A save invalidates exactly one registered display row. The event grants no authority:
|
|
2084
2106
|
// the keyed route checks the physical target and returns its current registration view.
|
|
2085
2107
|
async function refreshRegisteredProject(event) {
|
|
2108
|
+
await loadSteelEnvironments(); // units below are inferred from the project's standard; awaited BEFORE anything is captured
|
|
2086
2109
|
const root = window.flolessWorkspaceRoot?.current()?.root;
|
|
2087
2110
|
if (!root || event.rootId !== root.rootId || event.generation !== root.generation) return;
|
|
2088
2111
|
const registrationId = event.registrationId;
|
|
@@ -2110,11 +2133,11 @@
|
|
|
2110
2133
|
|| !['available', 'unavailable'].includes(registration.status)) {
|
|
2111
2134
|
throw new Error('The project view no longer matches this registration.');
|
|
2112
2135
|
}
|
|
2113
|
-
const wasUnits = (cached
|
|
2136
|
+
const wasUnits = shownUnits(cached);
|
|
2114
2137
|
const wasApproved = cached.approvedAt;
|
|
2115
2138
|
const wasSortKeys = { name: cached.name, createdAt: cached.createdAt, updatedAt: cached.updatedAt };
|
|
2116
2139
|
Object.assign(cached, fresh, {
|
|
2117
|
-
displayUnits: (fresh
|
|
2140
|
+
displayUnits: shownUnits(fresh),
|
|
2118
2141
|
registrationState: registration.status,
|
|
2119
2142
|
registrationRevision: registration.entryRevision,
|
|
2120
2143
|
registrationReason: registration.reason,
|
|
@@ -2226,6 +2249,8 @@
|
|
|
2226
2249
|
async function reconcileOpenProject() {
|
|
2227
2250
|
if (reconciling) { reconcileAgain = true; return; } // fold in, never drop — see above
|
|
2228
2251
|
reconciling = true;
|
|
2252
|
+
// Awaited BEFORE the open project is captured: waiting afterwards would act on a read that predates a project switch.
|
|
2253
|
+
await loadSteelEnvironments();
|
|
2229
2254
|
// The id this run has actually CHECKED against the server. The loop keeps going while it does not
|
|
2230
2255
|
// name the open project, so "the user switched project while we were reading" re-runs instead of
|
|
2231
2256
|
// exiting — a trailing pass conditioned only on a new EVENT arriving would leave the project they
|
|
@@ -2306,7 +2331,7 @@
|
|
|
2306
2331
|
// that never had a unit choice arrives as `undefined` — and assigning that raw made the
|
|
2307
2332
|
// `!==` test true on every `projects-changed`, discarding the server's `exportUnits` and
|
|
2308
2333
|
// repainting for nothing. (Review round 5.)
|
|
2309
|
-
const freshUnits = (mine
|
|
2334
|
+
const freshUnits = shownUnits(mine);
|
|
2310
2335
|
const freshName = typeof mine.name === 'string' ? mine.name : current.name;
|
|
2311
2336
|
if (current && current.id === id && current.name !== freshName) {
|
|
2312
2337
|
current.name = freshName;
|
|
@@ -2852,7 +2877,9 @@
|
|
|
2852
2877
|
`<span class="ws-body"><span><span class="ws-name">${escapeHtml(p.name)}</span>` +
|
|
2853
2878
|
(projectCapability ? `<span class="ws-meta">${escapeHtml(projectCapability)}</span>` : '') +
|
|
2854
2879
|
// #2521 row 5: the card speaks for the WORKING COPY only, and says so in its tip.
|
|
2855
|
-
(p.quick && quickPillHtml(p.quick) ? `<span class="ws-meta ws-quick">${quickPillHtml(p.quick, { scope: 'Working copy', focusable: false })}</span>` : '') +
|
|
2880
|
+
(p.quick && quickPillHtml(p.quick) ? `<span class="ws-meta ws-quick">${quickPillHtml(p.quick, { scope: 'Working copy', focusable: false })}${coveragePillHtml(p.coverage, { scope: 'Working copy', focusable: false, besides: p.quick })}</span>` : '') +
|
|
2881
|
+
// #2554 slice 2: a model that left drawing files unread says so beside its label, or on its own when precise.
|
|
2882
|
+
(!(p.quick && quickPillHtml(p.quick)) && p.coverage && coveragePillHtml(p.coverage) ? `<span class="ws-meta ws-quick">${coveragePillHtml(p.coverage, { scope: 'Working copy', focusable: false })}</span>` : '') +
|
|
2856
2883
|
(p.importedMidSave ? `<span class="ws-meta ws-unverified" data-tip="${escapeAttr(UNVERIFIED_IMPORT_TIP)}">Imported mid-save · not verified. Export again on the source computer.</span>` : '') +
|
|
2857
2884
|
`<span class="ws-meta ws-registration-status"${p.registrationState === 'unavailable' ? '' : ' hidden'}>${escapeHtml(p.registrationReason || 'Project folder unavailable. Locate or restore it.')}</span>` +
|
|
2858
2885
|
`<span class="ws-meta ws-registration-location-note"${p.registrationState !== 'unavailable' && p.registrationLocationWarning ? '' : ' hidden'}>${escapeHtml(p.registrationLocationWarning || '')}</span>` +
|
|
@@ -3470,12 +3497,21 @@
|
|
|
3470
3497
|
const $teklaSourceStatus = document.getElementById('tekla-source-status');
|
|
3471
3498
|
let teklaSourceChoice = null;
|
|
3472
3499
|
let teklaSourcePicking = false;
|
|
3500
|
+
const TEKLA_SOURCE_BUSY_REASON = 'FloLess is still reading that model. This window updates when it is done.';
|
|
3473
3501
|
function setTeklaSourcePicking(busy, message = '') {
|
|
3474
3502
|
teklaSourcePicking = busy;
|
|
3475
3503
|
$teklaSourceModal?.setAttribute('aria-busy', String(busy));
|
|
3476
3504
|
if ($teklaSourceFolder) $teklaSourceFolder.disabled = busy;
|
|
3477
3505
|
if ($teklaSourceZip) $teklaSourceZip.disabled = busy;
|
|
3478
|
-
if ($teklaSourceCancel)
|
|
3506
|
+
if ($teklaSourceCancel) {
|
|
3507
|
+
$teklaSourceCancel.disabled = busy;
|
|
3508
|
+
if (busy) $teklaSourceCancel.dataset.blockedReason = TEKLA_SOURCE_BUSY_REASON;
|
|
3509
|
+
else delete $teklaSourceCancel.dataset.blockedReason;
|
|
3510
|
+
}
|
|
3511
|
+
// A disabled button drops focus to the page; keep it in the dialog so Escape and Tab still land here.
|
|
3512
|
+
if (busy && document.activeElement?.disabled && $teklaSourceModal?.contains(document.activeElement)) {
|
|
3513
|
+
$teklaSourceDialog?.focus();
|
|
3514
|
+
}
|
|
3479
3515
|
if ($teklaSourceStatus) {
|
|
3480
3516
|
$teklaSourceStatus.textContent = message;
|
|
3481
3517
|
$teklaSourceStatus.hidden = !message;
|
|
@@ -3494,6 +3530,11 @@
|
|
|
3494
3530
|
$teklaSourceModal?.classList.remove('show');
|
|
3495
3531
|
if (restoreFocus && state?.returnFocus?.isConnected) state.returnFocus.focus();
|
|
3496
3532
|
}
|
|
3533
|
+
/** #3151: Cancel, Escape and the backdrop agree — none of them closes the window while a source is read. */
|
|
3534
|
+
function dismissTeklaSourceChoice() {
|
|
3535
|
+
if (teklaSourcePicking) { setTeklaSourcePicking(true, TEKLA_SOURCE_BUSY_REASON); return; }
|
|
3536
|
+
closeTeklaSourceChoice();
|
|
3537
|
+
}
|
|
3497
3538
|
async function chooseTeklaSource(kind) {
|
|
3498
3539
|
const choice = teklaSourceChoice;
|
|
3499
3540
|
if (!choice || teklaSourcePicking) return;
|
|
@@ -3514,16 +3555,19 @@
|
|
|
3514
3555
|
else if (teklaSourceChoice === choice) setTeklaSourcePicking(false,
|
|
3515
3556
|
'FloLess could not open project setup. Close any other setup window, then choose the source again.');
|
|
3516
3557
|
} catch (error) {
|
|
3517
|
-
|
|
3518
|
-
|
|
3558
|
+
// #3097: the pick checks throw a sentence for the person (personError); a browser read error or a refusal is said
|
|
3559
|
+
// through errorText, never as its own message.
|
|
3560
|
+
const said = errorText(error, { action: 'read that Tekla source', retrySafe: true });
|
|
3561
|
+
if (teklaSourceChoice === choice) setTeklaSourcePicking(false, said);
|
|
3562
|
+
showToast(said, 'warn');
|
|
3519
3563
|
}
|
|
3520
3564
|
}
|
|
3521
3565
|
$teklaSourceFolder?.addEventListener('click', () => { void chooseTeklaSource('folder'); });
|
|
3522
3566
|
$teklaSourceZip?.addEventListener('click', () => { void chooseTeklaSource('zip'); });
|
|
3523
|
-
$teklaSourceCancel?.addEventListener('click', () =>
|
|
3524
|
-
$teklaSourceModal?.addEventListener('click', (event) => { if (event.target === $teklaSourceModal)
|
|
3567
|
+
$teklaSourceCancel?.addEventListener('click', () => dismissTeklaSourceChoice());
|
|
3568
|
+
$teklaSourceModal?.addEventListener('click', (event) => { if (event.target === $teklaSourceModal) dismissTeklaSourceChoice(); });
|
|
3525
3569
|
$teklaSourceModal?.addEventListener('keydown', (event) => {
|
|
3526
|
-
if (event.key === 'Escape') { event.preventDefault();
|
|
3570
|
+
if (event.key === 'Escape') { event.preventDefault(); dismissTeklaSourceChoice(); return; }
|
|
3527
3571
|
if (event.key !== 'Tab') return;
|
|
3528
3572
|
const controls = [...$teklaSourceModal.querySelectorAll('button:not([disabled])')];
|
|
3529
3573
|
if (!controls.length) return;
|
|
@@ -3758,19 +3802,19 @@
|
|
|
3758
3802
|
if (!folderCount) source = teklaZipSource(files[0]);
|
|
3759
3803
|
else {
|
|
3760
3804
|
const handle = await folder;
|
|
3761
|
-
if (handle?.kind !== 'directory') throw
|
|
3805
|
+
if (handle?.kind !== 'directory') throw personError('FloLess couldn’t read the dropped folder, so nothing was opened. Click the card to choose the Tekla model folder instead.');
|
|
3762
3806
|
source = await filesFromDirectoryHandle(handle);
|
|
3763
3807
|
}
|
|
3764
3808
|
// The read may have outlasted the moment: never open setup over another window or a project.
|
|
3765
3809
|
if (projectSetupState || teklaSourceChoice || $landing.hidden) {
|
|
3766
|
-
throw
|
|
3810
|
+
throw personError(`FloLess finished reading ${label}, but something else is open now, so nothing was opened. Drop the model on Tekla Parser again when you are ready.`);
|
|
3767
3811
|
}
|
|
3768
3812
|
await createFromTeklaSource(appId, templateId, source, zone.isConnected ? zone : null);
|
|
3769
3813
|
} catch (error) {
|
|
3770
|
-
// Our own checks throw a
|
|
3771
|
-
// failing to read a file (moved, locked, unreadable), whose message is not written for people.
|
|
3772
|
-
if (error?.
|
|
3773
|
-
showToast(error?.
|
|
3814
|
+
// Our own checks throw a sentence for the person (personError) that already says what to do. Anything else is the
|
|
3815
|
+
// browser failing to read a file (moved, locked, unreadable), whose message is not written for people.
|
|
3816
|
+
if (error?.forPerson !== true) console.warn('[workspaces] could not read a dropped Tekla model', error);
|
|
3817
|
+
showToast(error?.forPerson === true ? errorText(error)
|
|
3774
3818
|
: 'FloLess couldn’t read every file of that Tekla model, so nothing was opened. Check it is still there and not open in another program, then drop it again or click the card to choose it.', 'warn');
|
|
3775
3819
|
} finally {
|
|
3776
3820
|
teklaDropReading = false;
|
|
@@ -3835,6 +3879,45 @@
|
|
|
3835
3879
|
return res && typeof res.name === 'string' && res.name.trim() ? res.name.trim() : null;
|
|
3836
3880
|
}
|
|
3837
3881
|
|
|
3882
|
+
/**
|
|
3883
|
+
* The steel-environment TRAIT registry (`web/steel-environments.js`), loaded the same way and for the
|
|
3884
|
+
* same reason as the label table below (`index.html` loads this file as a classic script). Started
|
|
3885
|
+
* HERE, at script evaluation, so it has long settled before a project list has been fetched and
|
|
3886
|
+
* rendered; `loadSteelEnvironments()` is what the two paths that ADOPT units from a fetched row await
|
|
3887
|
+
* (project-metadata refresh and the open-project reconcile), so an inferred unit is never written from
|
|
3888
|
+
* a registry that has not loaded. Until it has, a read answers the imperial default and claims nothing
|
|
3889
|
+
* else. A failed load is logged, not swallowed: it leaves a legacy UK project showing feet-inches.
|
|
3890
|
+
*/
|
|
3891
|
+
let steelEnvironments = null;
|
|
3892
|
+
let steelEnvironmentsPromise = null;
|
|
3893
|
+
function loadSteelEnvironments() {
|
|
3894
|
+
if (!steelEnvironmentsPromise) {
|
|
3895
|
+
steelEnvironmentsPromise = import('./steel-environments.js').then(
|
|
3896
|
+
(m) => { steelEnvironments = m; return m; },
|
|
3897
|
+
(error) => {
|
|
3898
|
+
// Not cached: a transient failure must not bar every later attempt. The caller carries on with the imperial default.
|
|
3899
|
+
steelEnvironmentsPromise = null;
|
|
3900
|
+
console.error('[workspaces] the steel-environment registry could not be loaded; units inferred from a project\u2019s standard fall back to feet-inches', error);
|
|
3901
|
+
return null;
|
|
3902
|
+
},
|
|
3903
|
+
);
|
|
3904
|
+
}
|
|
3905
|
+
return steelEnvironmentsPromise;
|
|
3906
|
+
}
|
|
3907
|
+
loadSteelEnvironments();
|
|
3908
|
+
const isRegisteredEnvironment = (id) => !!steelEnvironments?.traitsOf(id);
|
|
3909
|
+
const registeredEnvironmentIds = () => (steelEnvironments ? [...steelEnvironments.STEEL_ENVIRONMENT_IDS] : []);
|
|
3910
|
+
/**
|
|
3911
|
+
* The units a project row is shown in: its own `displayUnits`, or, where its owner never chose, what
|
|
3912
|
+
* its environment implies (the client mirror of the server's `shownUnitsOfProject`; one trait, read in
|
|
3913
|
+
* both places).
|
|
3914
|
+
*/
|
|
3915
|
+
function shownUnits(project) {
|
|
3916
|
+
return project?.displayUnits === 'mm' || project?.displayUnits === 'ft-in'
|
|
3917
|
+
? project.displayUnits
|
|
3918
|
+
: (steelEnvironments ? steelEnvironments.traitsFor(project?.environment).defaultDisplayUnits : 'ft-in');
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3838
3921
|
/**
|
|
3839
3922
|
* How a steel standard names itself to a person — `US · AISC/ASTM`, `UK · BS/EN`.
|
|
3840
3923
|
*
|
|
@@ -3860,8 +3943,13 @@
|
|
|
3860
3943
|
let standardLabelsPromise = null;
|
|
3861
3944
|
function loadStandardLabels() {
|
|
3862
3945
|
if (!standardLabelsPromise) {
|
|
3863
|
-
|
|
3864
|
-
|
|
3946
|
+
// The registry rides along: the setup dialog's readiness and its button loop both read it, and
|
|
3947
|
+
// `sourceReady` is only set after this resolves.
|
|
3948
|
+
standardLabelsPromise = Promise.all([import('./checkpoint-standard.js'), loadSteelEnvironments()])
|
|
3949
|
+
.then(([m, envs]) => {
|
|
3950
|
+
if (!envs) throw new Error('the steel-environment registry did not load');
|
|
3951
|
+
return m.STANDARD_LABEL;
|
|
3952
|
+
})
|
|
3865
3953
|
.catch((err) => { standardLabelsPromise = null; throw err; });
|
|
3866
3954
|
}
|
|
3867
3955
|
return standardLabelsPromise;
|
|
@@ -3888,6 +3976,7 @@
|
|
|
3888
3976
|
const $projectSetupQuickTermsTail = document.getElementById('project-setup-quick-terms-tail');
|
|
3889
3977
|
const $projectSetupFilter = document.getElementById('project-setup-filter');
|
|
3890
3978
|
const $projectSetupExclusions = document.getElementById('project-setup-exclusions');
|
|
3979
|
+
const $projectSetupOrigin = document.getElementById('project-setup-origin');
|
|
3891
3980
|
const $projectSetupBuildLocked = document.getElementById('project-setup-build-locked');
|
|
3892
3981
|
const $projectSetupCancel = document.getElementById('project-setup-cancel');
|
|
3893
3982
|
const $projectSetupCreateOnly = document.getElementById('project-setup-create-only');
|
|
@@ -4000,7 +4089,7 @@
|
|
|
4000
4089
|
|
|
4001
4090
|
function projectSetupReady(state = projectSetupState) {
|
|
4002
4091
|
return !!state && state.sourceReady && !!state.directory && !!state.name.trim()
|
|
4003
|
-
&& (!state.askCatalogue || state.environment
|
|
4092
|
+
&& (!state.askCatalogue || isRegisteredEnvironment(state.environment));
|
|
4004
4093
|
}
|
|
4005
4094
|
|
|
4006
4095
|
function setProjectSetupBusy(busy, label) {
|
|
@@ -4197,7 +4286,19 @@
|
|
|
4197
4286
|
}
|
|
4198
4287
|
}
|
|
4199
4288
|
if ($projectSetupQuickTermsTail) {
|
|
4200
|
-
|
|
4289
|
+
// #2909 (code review): the terms say what the person keeps, so a person-picked origin is said here too.
|
|
4290
|
+
$projectSetupQuickTermsTail.textContent = PROJECT_SETUP_TERMS_TAIL[filter === 'ai' && exclusions === 'person' ? 'aiKeep' : filter]
|
|
4291
|
+
+ (mode === 'quick' && projectSetupOriginChoice(state) === 'person' ? ' ' + PROJECT_SETUP_TERMS_ORIGIN : '');
|
|
4292
|
+
}
|
|
4293
|
+
// #2909: who chooses the model origin, asked only with Quick (Precise always asks it on the read's setup card).
|
|
4294
|
+
const origin = projectSetupOriginChoice(state);
|
|
4295
|
+
if ($projectSetupOrigin) {
|
|
4296
|
+
$projectSetupOrigin.hidden = mode !== 'quick';
|
|
4297
|
+
for (const button of $projectSetupOrigin.querySelectorAll('[data-origin-choice]')) {
|
|
4298
|
+
button.setAttribute('aria-pressed', String(button.dataset.originChoice === origin));
|
|
4299
|
+
if (locked) button.setAttribute('aria-disabled', 'true');
|
|
4300
|
+
else button.removeAttribute('aria-disabled');
|
|
4301
|
+
}
|
|
4201
4302
|
}
|
|
4202
4303
|
$projectSetupBuildLocked.hidden = !locked;
|
|
4203
4304
|
if (shown && mode === 'quick') $projectSetupCreateOnly.setAttribute('aria-describedby', 'project-setup-quick-create-only');
|
|
@@ -4227,6 +4328,20 @@
|
|
|
4227
4328
|
ai: 'The AI chooses the Drawing Filter, including what the read leaves out, recorded and labelled as its own; you still decide on the review.',
|
|
4228
4329
|
aiKeep: 'The AI chooses the Drawing Filter, recorded and labelled as its own; you approve what the read leaves out, and you still decide on the review.',
|
|
4229
4330
|
};
|
|
4331
|
+
const PROJECT_SETUP_TERMS_ORIGIN = 'You also choose the model origin, on the read’s setup card.';
|
|
4332
|
+
/**
|
|
4333
|
+
* #2909: who chooses the model origin with Quick: 'person' only when the person pressed "I'll choose it myself", else
|
|
4334
|
+
* the AI (the default, owner ruling 2026-11-08). Once sent it is the sent one, as for the Model choice.
|
|
4335
|
+
*/
|
|
4336
|
+
function projectSetupOriginChoice(state) {
|
|
4337
|
+
const value = state.submissionId ? state.sentOriginChoice : state.originChoice;
|
|
4338
|
+
return value === 'person' ? 'person' : 'ai';
|
|
4339
|
+
}
|
|
4340
|
+
function chooseProjectSetupOrigin(button) {
|
|
4341
|
+
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4342
|
+
projectSetupState.originChoice = button.dataset.originChoice === 'person' ? 'person' : 'ai';
|
|
4343
|
+
renderProjectSetup();
|
|
4344
|
+
}
|
|
4230
4345
|
function chooseProjectSetupFilter(button) {
|
|
4231
4346
|
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4232
4347
|
projectSetupState.filterChoice = button.dataset.filterChoice === 'ai' ? 'ai' : 'person';
|
|
@@ -4244,7 +4359,8 @@
|
|
|
4244
4359
|
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4245
4360
|
projectSetupState.buildMode = button.dataset.buildMode === 'quick' ? 'quick' : 'precise';
|
|
4246
4361
|
// #2521 row 2c: the Filter choice belongs to Quick: Precise drops it, and Quick again starts from the person's Save.
|
|
4247
|
-
|
|
4362
|
+
// #2909: likewise the origin choice: Precise drops it, and Quick again starts from the AI's choice.
|
|
4363
|
+
if (projectSetupState.buildMode === 'precise') { projectSetupState.filterChoice = 'person'; projectSetupState.exclusionsChoice = 'ai'; projectSetupState.originChoice = 'ai'; }
|
|
4248
4364
|
renderProjectSetup();
|
|
4249
4365
|
if (projectSetupState.buildMode === 'quick') $projectSetupQuickTerms.scrollIntoView?.({ block: 'nearest' });
|
|
4250
4366
|
}
|
|
@@ -4442,6 +4558,8 @@
|
|
|
4442
4558
|
// #2521 row 2c: the Filter choice is sent only with Quick, and fixed with the first send like the Model choice.
|
|
4443
4559
|
if (!state.submissionId) state.sentFilterChoice = state.sentBuildMode === 'quick' && state.filterChoice === 'ai' ? 'ai' : null;
|
|
4444
4560
|
if (!state.submissionId) state.sentExclusionsChoice = state.sentFilterChoice === 'ai' ? (state.exclusionsChoice === 'person' ? 'person' : 'ai') : null;
|
|
4561
|
+
// #2909: the origin choice likewise, sent only with Quick and only when the person keeps it.
|
|
4562
|
+
if (!state.submissionId) state.sentOriginChoice = state.sentBuildMode === 'quick' && state.originChoice === 'person' ? 'person' : null;
|
|
4445
4563
|
const submissionId = state.submissionId || crypto.randomUUID();
|
|
4446
4564
|
state.submissionId = submissionId;
|
|
4447
4565
|
rememberProjectChatIntake(submissionId);
|
|
@@ -4455,6 +4573,7 @@
|
|
|
4455
4573
|
...(state.sentBuildMode === 'quick' ? { buildMode: 'quick' } : {}),
|
|
4456
4574
|
...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' ? { quickFilterByAi: true } : {}),
|
|
4457
4575
|
...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' && state.sentExclusionsChoice === 'ai' ? { quickFilterExclusionsByAi: true } : {}),
|
|
4576
|
+
...(state.sentBuildMode === 'quick' && state.sentOriginChoice === 'person' ? { quickOriginByPerson: true } : {}),
|
|
4458
4577
|
// #2470 R6.7b: added from a General project's Modules step, the project is made already linked there.
|
|
4459
4578
|
...(state.linkFrom ? { linkFrom: { projectId: state.linkFrom.projectId, sourceUuid: state.linkFrom.sourceUuid, rootId: state.linkFrom.rootId } } : {}),
|
|
4460
4579
|
...(state.linkFrom && state.withoutLink ? { withoutLink: true } : {}),
|
|
@@ -4485,7 +4604,7 @@
|
|
|
4485
4604
|
const outsideWorkspace = code === 'project-directory-outside-root';
|
|
4486
4605
|
// #2470 R6.7b: the server's own sentence on why the link can't be made, and the choice to go on without it.
|
|
4487
4606
|
const linkChoice = startChat && state.linkFrom && error?.linkChoice === true;
|
|
4488
|
-
setProjectSetupError(linkChoice ? projectSetupLinkChoiceMessage(state, code, error
|
|
4607
|
+
setProjectSetupError(linkChoice ? projectSetupLinkChoiceMessage(state, code, personText(error?.body)) : projectSetupErrorMessage(error), {
|
|
4489
4608
|
workspaceAction: outsideWorkspace,
|
|
4490
4609
|
withoutLinkAction: linkChoice ? () => { state.withoutLink = true; void createProjectFromSetup(true); } : null,
|
|
4491
4610
|
});
|
|
@@ -4544,7 +4663,7 @@
|
|
|
4544
4663
|
// It stays until the person acts on it; a choice that fails is offered again.
|
|
4545
4664
|
if (!projectChatIntakeLinkChoiceShown.has(submissionId)) {
|
|
4546
4665
|
projectChatIntakeLinkChoiceShown.add(submissionId);
|
|
4547
|
-
showToast(`A project you started from a General project wasn’t created yet. ${projectSetupLinkChoiceMessage({}, code, error
|
|
4666
|
+
showToast(`A project you started from a General project wasn’t created yet. ${projectSetupLinkChoiceMessage({}, code, personText(error?.body))}`, 'warn', {
|
|
4548
4667
|
persistent: true,
|
|
4549
4668
|
action: { label: 'Create without linking', commandId: 'shell.project-setup-recover-without-link',
|
|
4550
4669
|
onClick: () => recoverProjectChatIntake(submissionId, { withoutLink: true }).catch((retryError) => {
|
|
@@ -4604,6 +4723,8 @@
|
|
|
4604
4723
|
filterChoice: 'person',
|
|
4605
4724
|
// Revision 3: with "Let the AI choose", the AI also approves what the read leaves out unless the person keeps it.
|
|
4606
4725
|
exclusionsChoice: 'ai',
|
|
4726
|
+
// #2909: the AI chooses the model origin unless the person presses "I'll choose it myself" (with Quick only).
|
|
4727
|
+
originChoice: 'ai',
|
|
4607
4728
|
directory: null,
|
|
4608
4729
|
name: '',
|
|
4609
4730
|
nameDirty: false,
|
|
@@ -4627,7 +4748,7 @@
|
|
|
4627
4748
|
if (state.askCatalogue) {
|
|
4628
4749
|
const standards = await loadStandardLabels();
|
|
4629
4750
|
if (projectSetupState !== state) return;
|
|
4630
|
-
for (const env of
|
|
4751
|
+
for (const env of registeredEnvironmentIds()) {
|
|
4631
4752
|
const label = standards.get(env);
|
|
4632
4753
|
if (!label) throw new Error(`the shared label table names no standard for ${env}`);
|
|
4633
4754
|
$projectSetupStandard.querySelector(`[data-standard-label="${env}"]`).textContent = label;
|
|
@@ -4663,6 +4784,8 @@
|
|
|
4663
4784
|
$projectSetupBuild?.addEventListener('click', (event) => {
|
|
4664
4785
|
const exclusionsButton = event.target.closest('[data-exclusions-choice]');
|
|
4665
4786
|
if (exclusionsButton) { chooseProjectSetupExclusions(exclusionsButton); return; }
|
|
4787
|
+
const originButton = event.target.closest('[data-origin-choice]');
|
|
4788
|
+
if (originButton) { chooseProjectSetupOrigin(originButton); return; }
|
|
4666
4789
|
const filterButton = event.target.closest('[data-filter-choice]');
|
|
4667
4790
|
if (filterButton) chooseProjectSetupFilter(filterButton);
|
|
4668
4791
|
else chooseProjectSetupBuildMode(event.target.closest('[data-build-mode]'));
|
|
@@ -4835,8 +4958,20 @@
|
|
|
4835
4958
|
if (detailNode) detailNode.textContent = detail;
|
|
4836
4959
|
}
|
|
4837
4960
|
|
|
4961
|
+
/**
|
|
4962
|
+
* #3097: the server's own text for a Tekla source refusal. A ModelSnapshotError reply says diagnostic: true, so the
|
|
4963
|
+
* shared request helper does not put its `error` in the Error's message; it is matched below against reviewed
|
|
4964
|
+
* patterns only, and shown as written only by the branches that say so.
|
|
4965
|
+
*/
|
|
4966
|
+
function teklaRefusalText(error) {
|
|
4967
|
+
const raw = error?.body?.error;
|
|
4968
|
+
return typeof raw === 'string' && raw.trim() ? raw.trim() : error?.message || String(error || '');
|
|
4969
|
+
}
|
|
4838
4970
|
function teklaAdmissionMessage(error) {
|
|
4839
|
-
|
|
4971
|
+
// A sentence the server proved was written for the person (ModelSnapshotError.userMessage) is said as written.
|
|
4972
|
+
const written = error?.body?.userMessage;
|
|
4973
|
+
if (typeof written === 'string' && written.trim()) return written.trim();
|
|
4974
|
+
const message = teklaRefusalText(error);
|
|
4840
4975
|
// The server's copy-limit refusals (tekla-source-upload.ts / tekla-source-package.ts): sizes and counts.
|
|
4841
4976
|
const TEKLA_COPY_LIMIT = /^Tekla (?:ZIP|folder upload|source package)\b[^.]*\bexceeds? (?:its|their) (?:limit|compressed byte limit|total byte limit)$/;
|
|
4842
4977
|
// #1849: reading without some catalogue files needs a newer AWARE; the server names the version.
|
|
@@ -4862,7 +4997,7 @@
|
|
|
4862
4997
|
return 'FloLess could not read this Tekla source. Choose the model folder or ZIP again. The source model was not changed.';
|
|
4863
4998
|
}
|
|
4864
4999
|
function teklaAdmissionTitle(error) {
|
|
4865
|
-
const message =
|
|
5000
|
+
const message = teklaRefusalText(error);
|
|
4866
5001
|
const TEKLA_COPY_LIMIT = /^Tekla (?:ZIP|folder upload|source package)\b[^.]*\bexceeds? (?:its|their) (?:limit|compressed byte limit|total byte limit)$/; // as in teklaAdmissionMessage
|
|
4867
5002
|
if (TEKLA_COPY_LIMIT.test(message)) return 'This Tekla source is too large for one read';
|
|
4868
5003
|
const tooLarge = /^This Tekla model is too large for Tekla Parser to read\. .* Tekla Parser reads up to (\d+(?:\.\d)? [MG]B)\./.exec(message);
|
|
@@ -5059,9 +5194,12 @@
|
|
|
5059
5194
|
// #3097: the server's own sentence when it wrote one, else the shared one; never "(<status>)".
|
|
5060
5195
|
if (!upload.ok || uploaded.ok === false) {
|
|
5061
5196
|
console.warn('[rvt] upload refused', upload.status, uploaded);
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
{
|
|
5197
|
+
// #3097: this route's `error` is a machine code and its `message` a developer's sentence; only `userMessage` is
|
|
5198
|
+
// written for the person. Marking the reply diagnostic lets personText / errorText read exactly that.
|
|
5199
|
+
const body = { ...uploaded, diagnostic: true };
|
|
5200
|
+
throw Object.assign(new Error(personText(body)
|
|
5201
|
+
|| failureCopy({ status: upload.status, body }, { action: 'copy the RVT file to FloLess', unsure: 'Choose the RVT file again.' }).text),
|
|
5202
|
+
{ status: upload.status, body });
|
|
5065
5203
|
}
|
|
5066
5204
|
const receipt = uploaded.receipt;
|
|
5067
5205
|
const started = await api('/api/model-imports', { method: 'POST', body: JSON.stringify({
|
|
@@ -5089,7 +5227,7 @@
|
|
|
5089
5227
|
headers: { 'content-type': 'application/octet-stream', 'x-floless-upload-offset': String(offset),
|
|
5090
5228
|
'x-floless-upload-total': String(file.size) } });
|
|
5091
5229
|
const body = await response.json().catch(() => ({}));
|
|
5092
|
-
if (!response.ok || body.ok === false) throw new Error(body.message || body.error || `source copy failed (${response.status})`);
|
|
5230
|
+
if (!response.ok || body.ok === false) throw Object.assign(new Error(body.message || body.error || `source copy failed (${response.status})`), { body, status: response.status });
|
|
5093
5231
|
onProgress(Math.min(file.size, offset + blob.size), file.size);
|
|
5094
5232
|
return body;
|
|
5095
5233
|
} catch (error) {
|
|
@@ -5143,7 +5281,7 @@
|
|
|
5143
5281
|
try { return JSON.parse(xhr.responseText || '{}'); } catch { return {}; }
|
|
5144
5282
|
})();
|
|
5145
5283
|
if (xhr.status < 200 || xhr.status >= 300 || body.ok === false) {
|
|
5146
|
-
finish(new Error(body.message || body.error || `source copy failed (${xhr.status})`));
|
|
5284
|
+
finish(Object.assign(new Error(body.message || body.error || `source copy failed (${xhr.status})`), { body, status: xhr.status }));
|
|
5147
5285
|
return;
|
|
5148
5286
|
}
|
|
5149
5287
|
finish(null, body);
|
|
@@ -5389,10 +5527,15 @@
|
|
|
5389
5527
|
} catch (err) {
|
|
5390
5528
|
const removed = await archiveEmptyProject(project.id);
|
|
5391
5529
|
// #2470 R6.7: the empty project is not kept linked either; the Modules step says what happened (spec §6.3).
|
|
5392
|
-
|
|
5530
|
+
// #3097: why, from the server's own sentence for the person, else the shared sentence's why-and-what-to-do (its
|
|
5531
|
+
// "Couldn’t …" lead is already said below); never the error's own text, which goes to the console.
|
|
5532
|
+
const said = err && err.body && typeof err.body === 'object' ? personText(err.body) : '';
|
|
5533
|
+
if (!said) console.warn('[rvt] import failed', err);
|
|
5534
|
+
const why = said || failureParts(err, { action: 'import the RVT', unsure: 'Choose the RVT file again.' }).detail;
|
|
5535
|
+
if (link) { await globalThis.flolessProjectModules?.afterCreate?.({ project, ...link, outcome: removed ? 'archived-empty' : 'left-empty', error: why }); return; }
|
|
5393
5536
|
showToast(removed
|
|
5394
|
-
? `Couldn’t import the RVT — the empty project was removed. ${
|
|
5395
|
-
: `Couldn’t import the RVT. An empty project was left behind; archive it from the ⋯ menu. ${
|
|
5537
|
+
? `Couldn’t import the RVT — the empty project was removed. ${why}`
|
|
5538
|
+
: `Couldn’t import the RVT. An empty project was left behind; archive it from the ⋯ menu. ${why}`, 'warn');
|
|
5396
5539
|
}
|
|
5397
5540
|
}
|
|
5398
5541
|
|
|
@@ -5567,7 +5710,7 @@
|
|
|
5567
5710
|
frames.model.dataset.loaded = ''; frames.drawings.dataset.loaded = '';
|
|
5568
5711
|
// Start the small lifecycle envelope BEFORE the heavier approval review request. Both hit the
|
|
5569
5712
|
// same localhost event loop; sending approval first could keep the lifecycle request queued until
|
|
5570
|
-
// its
|
|
5713
|
+
// its client deadline, falsely leaving an existing model in the checking state. This
|
|
5571
5714
|
// promise also owns every tab activation until it settles (refreshModelPresence deduplicates it).
|
|
5572
5715
|
refreshModelPresence(p.id, p.app).catch((e) => {
|
|
5573
5716
|
console.error('[workspaces] could not resolve model presence', e);
|
|
@@ -5625,18 +5768,20 @@
|
|
|
5625
5768
|
}
|
|
5626
5769
|
const gen = ++modelPresenceGen;
|
|
5627
5770
|
const promise = (async () => {
|
|
5628
|
-
const present = await projectContractState(projectId, appId);
|
|
5771
|
+
const present = await projectContractState(projectId, appId, () => gen === modelPresenceGen && current?.id === projectId);
|
|
5629
5772
|
if (gen !== modelPresenceGen || !current || current.id !== projectId) return false; // superseded
|
|
5630
|
-
|
|
5773
|
+
// A step the person clicked is settled by applyModelPresence (settleAskedStep), whichever check answers it;
|
|
5774
|
+
// this restores only the step a project was opened on.
|
|
5775
|
+
const held = pendingPresenceStep?.projectId === projectId && !pendingPresenceStep.asked ? pendingPresenceStep.step : '';
|
|
5631
5776
|
// A timeout/network error is not evidence that this project has no model. Keep the requested
|
|
5632
5777
|
// destination so its next activation can retry the probe and restore it after recovery.
|
|
5633
|
-
if (present !== 'unknown') pendingPresenceStep = null;
|
|
5778
|
+
if (present !== 'unknown' && held) pendingPresenceStep = null;
|
|
5634
5779
|
applyModelPresence(present);
|
|
5635
5780
|
// Restore only when this same project's authoritative answer says a model exists. A confirmed
|
|
5636
5781
|
// preliminary lifecycle remains on Drawing Filter and gets the real prerequisite gate below.
|
|
5637
5782
|
// #2470 R6.5b: History on a kind with two views is never gated (its Activity view needs no model), so it is
|
|
5638
5783
|
// restored on any known answer too, and opens on Activity when Approvals still has to wait.
|
|
5639
|
-
if (
|
|
5784
|
+
if (held && currentStep === 'drawings' && (present === 'model' || (present !== 'unknown' && held === 'history' && !stageGateFor(held)))) setStep(held);
|
|
5640
5785
|
return true;
|
|
5641
5786
|
})();
|
|
5642
5787
|
modelPresenceProbe = { projectId, promise };
|
|
@@ -5648,15 +5793,98 @@
|
|
|
5648
5793
|
|
|
5649
5794
|
/** Push the answer to the flag AND the header together, so no two surfaces can disagree. */
|
|
5650
5795
|
function applyModelPresence(present) {
|
|
5796
|
+
// #3139: which Exports render was already waiting on its check before this answer. Opening the clicked step below
|
|
5797
|
+
// can start a new render, which waits on its own check and must not be redone by the answer that opened it.
|
|
5798
|
+
const exportsWaiting = typeof exportsLifecycleWait === 'number' ? exportsLifecycleWait : 0;
|
|
5651
5799
|
projectContractLifecycle = present;
|
|
5652
5800
|
exportsHasModel = present === 'model';
|
|
5653
5801
|
retrySourcelessPresence(present);
|
|
5654
5802
|
renderApprovalHeader();
|
|
5803
|
+
// #3139, through `typeof` because harnesses lift this function alone. The clicked step first: before the gate
|
|
5804
|
+
// repaint, which may move the person off a tab the answer locked; and before the panes, because opening the step
|
|
5805
|
+
// hides the pane it was clicked from, so that pane is not redone behind it.
|
|
5806
|
+
if (typeof settleAskedStep === 'function') settleAskedStep(present);
|
|
5655
5807
|
applyStageGating();
|
|
5656
5808
|
// A lifecycle probe may resolve after the saved-filter card already painted under `unknown`.
|
|
5657
5809
|
// Retire it in the same turn that reveals the replacement strip; waiting for the request poll
|
|
5658
5810
|
// would briefly recreate the two competing status bands this hand-off exists to remove.
|
|
5659
5811
|
if (currentStep === 'drawings' && lastRevState === 'pending') retireRevisionCardForStrip(revCardReq);
|
|
5812
|
+
if (typeof syncExportsLifecycleGate === 'function') syncExportsLifecycleGate(present, exportsWaiting);
|
|
5813
|
+
if (typeof syncHistoryLifecycleWait === 'function') syncHistoryLifecycleWait();
|
|
5814
|
+
}
|
|
5815
|
+
|
|
5816
|
+
/**
|
|
5817
|
+
* #3139: the step the person clicked while the lifecycle was unknown (deferStageUntilLifecycle marks it `asked`) is
|
|
5818
|
+
* settled by whichever check applies an answer — its own, or an Exports or History render's that overtook it, which
|
|
5819
|
+
* used to drop the click. A real answer opens it from wherever the person is (any later step choice would already
|
|
5820
|
+
* have dropped it, see dropAskedStep) or says which earlier stage it waits for; no answer says so once and offers
|
|
5821
|
+
* Try again, then lets the step go, so a much later check can never move the person (#1669).
|
|
5822
|
+
*/
|
|
5823
|
+
function settleAskedStep(present) {
|
|
5824
|
+
const held = pendingPresenceStep;
|
|
5825
|
+
if (!held?.asked || !current || held.projectId !== current.id) return;
|
|
5826
|
+
pendingPresenceStep = null;
|
|
5827
|
+
if (pendingPresenceToast) pendingPresenceToast();
|
|
5828
|
+
pendingPresenceToast = null;
|
|
5829
|
+
const s = held.step;
|
|
5830
|
+
if (present === 'unknown') {
|
|
5831
|
+
const projectId = held.projectId;
|
|
5832
|
+
// Held as the pending toast, so a click on another step or another project closes it like the checking one.
|
|
5833
|
+
pendingPresenceToast = showToast(`Couldn’t check project stages, so ${stepLabel(s)} hasn’t opened yet. Your project is unchanged.`, 'warn', {
|
|
5834
|
+
persistent: true,
|
|
5835
|
+
action: { label: 'Try again', commandId: `shell.workspace-stage-recheck#${stepLabel(s)}`, onClick: () => { if (current?.id === projectId) chooseStep(s); } },
|
|
5836
|
+
});
|
|
5837
|
+
return;
|
|
5838
|
+
}
|
|
5839
|
+
// A confirmed preliminary answer turns the apparent availability into the real prerequisite gate. Reuse that
|
|
5840
|
+
// specific explanation instead of replacing it with generic readiness copy. History opens on its Activity view.
|
|
5841
|
+
const reason = stageGateFor(s);
|
|
5842
|
+
if (present === 'model' || (s === 'history' && !reason)) setStep(s);
|
|
5843
|
+
else if (reason) showToast(reason, 'warn');
|
|
5844
|
+
}
|
|
5845
|
+
|
|
5846
|
+
/** #3139: moves off a tab that just became locked. FloLess's move, not the person's, so a step they clicked stays held. */
|
|
5847
|
+
let stepRedirecting = false;
|
|
5848
|
+
function redirectStep(s) {
|
|
5849
|
+
stepRedirecting = true;
|
|
5850
|
+
try { setStep(s); } finally { stepRedirecting = false; }
|
|
5851
|
+
}
|
|
5852
|
+
|
|
5853
|
+
/**
|
|
5854
|
+
* #3139: the person (or the chat, or a "View" link) moved to another step by a route other than chooseStep, so a
|
|
5855
|
+
* step they clicked earlier is no longer what they want: drop it and its checking toast. Reached from setStep
|
|
5856
|
+
* through `typeof` (harnesses lift setStep alone). An open-time hold is not `asked` and is left alone, and so is a
|
|
5857
|
+
* move FloLess makes itself (redirectStep): that is not the person's choice.
|
|
5858
|
+
*/
|
|
5859
|
+
function dropAskedStep() {
|
|
5860
|
+
if (stepRedirecting || !pendingPresenceStep?.asked) return;
|
|
5861
|
+
pendingPresenceStep = null;
|
|
5862
|
+
if (pendingPresenceToast) pendingPresenceToast();
|
|
5863
|
+
pendingPresenceToast = null;
|
|
5864
|
+
}
|
|
5865
|
+
|
|
5866
|
+
/**
|
|
5867
|
+
* #3139: whichever check settles — the Exports render's own, or another that overtook it (a General project's
|
|
5868
|
+
* re-check, a model-creating read, a step click) — a visible Exports pane shows that answer. An overtaken render
|
|
5869
|
+
* returned before loading the export sources, so it is redone in full, with this answer handed to it so it does not
|
|
5870
|
+
* ask the server again (after a check that gave up, that would put "Checking…" back beside "Couldn’t check");
|
|
5871
|
+
* otherwise the gate is repainted when its answer changed. `waitingBefore` is the render that was waiting before this
|
|
5872
|
+
* answer: one this answer itself started (by opening the clicked step) waits on its own check and is left to it.
|
|
5873
|
+
* Without this "Checking what this project holds…" or "Loading export sources…" outlived every check.
|
|
5874
|
+
*/
|
|
5875
|
+
function syncExportsLifecycleGate(present, waitingBefore) {
|
|
5876
|
+
exportsLifecycleUnanswered = present === 'unknown';
|
|
5877
|
+
if (!current || $wsExports.hidden) return;
|
|
5878
|
+
if (exportsLifecycleWait && exportsLifecycleWait === exportsRenderGen && exportsLifecycleWait === waitingBefore) {
|
|
5879
|
+
exportsLifecycleWait = 0;
|
|
5880
|
+
exportsLifecycleHanded = { gen: exportsRenderGen + 1, present };
|
|
5881
|
+
safeRenderExports('after the project check finished');
|
|
5882
|
+
return;
|
|
5883
|
+
}
|
|
5884
|
+
if (exportsLifecycleGateKey() !== exportsPaintedGate) paintExports(current.approvedAt);
|
|
5885
|
+
}
|
|
5886
|
+
function exportsLifecycleGateKey() {
|
|
5887
|
+
return projectContractLifecycle + (exportsLifecycleUnanswered ? ':unanswered' : '');
|
|
5660
5888
|
}
|
|
5661
5889
|
|
|
5662
5890
|
/** Re-ask a General project's lifecycle after a check that settled `unknown` (see SOURCELESS_PRESENCE_RETRIES). */
|
|
@@ -6425,13 +6653,13 @@
|
|
|
6425
6653
|
if (action === 'chat') {
|
|
6426
6654
|
Promise.resolve().then(() => {
|
|
6427
6655
|
if (typeof window.flolessChat?.startNewChat !== 'function') {
|
|
6428
|
-
throw
|
|
6656
|
+
throw personError('AI Chat is still loading. Try Start new chat again in a moment.');
|
|
6429
6657
|
}
|
|
6430
6658
|
return window.flolessChat.startNewChat(notice.projectId);
|
|
6431
6659
|
}).catch((err) => {
|
|
6432
6660
|
// A reason AI Chat wrote for the person is shown as it is; anything else is an unexpected failure. Opening a
|
|
6433
6661
|
// new chat changes nothing, so it is always safe to try again.
|
|
6434
|
-
if (err?.
|
|
6662
|
+
if (err?.forPerson === true) showToast(`Couldn’t start a new chat. ${errorText(err)}`, 'warn');
|
|
6435
6663
|
else showFailureToast(err, { action: 'start a new chat', retrySafe: true });
|
|
6436
6664
|
});
|
|
6437
6665
|
return;
|
|
@@ -6735,7 +6963,7 @@
|
|
|
6735
6963
|
if (typeof syncHistoryViews === 'function' && typeof currentStep !== 'undefined') {
|
|
6736
6964
|
const activity = syncHistoryViews(currentStep, d);
|
|
6737
6965
|
// A gate that appears under the open ledger moves the step to Activity (once: setStep leaves the panes matching).
|
|
6738
|
-
if (currentStep === 'history' && activity && !$wsHistory.hidden) setStep('history');
|
|
6966
|
+
if (currentStep === 'history' && activity && !$wsHistory.hidden) (typeof redirectStep === 'function' ? redirectStep : setStep)('history');
|
|
6739
6967
|
}
|
|
6740
6968
|
if (!d || !d.filter) {
|
|
6741
6969
|
// The tab strip is shared across projects. Remove every steel-only gate when switching to an
|
|
@@ -6781,7 +7009,7 @@
|
|
|
6781
7009
|
// A project opened on the old default Model step can become gated when the lifecycle probe
|
|
6782
7010
|
// returns. Move it to the first actionable stage instead of leaving a locked tab selected.
|
|
6783
7011
|
if (currentStep !== 'drawings' && stageGateFor(currentStep)) {
|
|
6784
|
-
setStep('drawings');
|
|
7012
|
+
(typeof redirectStep === 'function' ? redirectStep : setStep)('drawings');
|
|
6785
7013
|
return;
|
|
6786
7014
|
}
|
|
6787
7015
|
// The strip always speaks for a save waiting on the person (confirm), refused (blocked) or needing a
|
|
@@ -6905,30 +7133,31 @@
|
|
|
6905
7133
|
const d = wsApp();
|
|
6906
7134
|
if (!current || !d?.filter || projectContractLifecycle !== 'unknown'
|
|
6907
7135
|
|| !['model', 'rfis', 'exports', 'history'].includes(s)) return false;
|
|
6908
|
-
|
|
7136
|
+
// FloLess's own redirect (redirectStep) only repaints the step the person is on; it must not replace their click.
|
|
7137
|
+
if (typeof stepRedirecting !== 'undefined' && stepRedirecting) return false;
|
|
7138
|
+
pendingPresenceStep = { projectId: current.id, step: s, asked: true };
|
|
6909
7139
|
const projectId = current.id;
|
|
6910
7140
|
if (pendingPresenceToast) pendingPresenceToast();
|
|
6911
|
-
|
|
7141
|
+
// Persistent while the check runs (#3139): it retries by itself for up to its budget, so the promise stays on
|
|
7142
|
+
// screen until the answer opens the step. Past a few seconds it says the wait is longer than usual, swapped in
|
|
7143
|
+
// place so the toast does not flicker.
|
|
7144
|
+
let dismissShown = showToast(`Checking project stages… ${stepLabel(s)} will open when ready.`, 'info', { persistent: true });
|
|
7145
|
+
let slowTimer = null;
|
|
7146
|
+
const intentToast = () => { clearTimeout(slowTimer); dismissShown(); };
|
|
7147
|
+
slowTimer = setTimeout(() => {
|
|
7148
|
+
if (pendingPresenceToast !== intentToast) return;
|
|
7149
|
+
dismissShown(true);
|
|
7150
|
+
dismissShown = showToast(`Still checking project stages. This is taking longer than usual. ${stepLabel(s)} will open when ready.`, 'info', { persistent: true });
|
|
7151
|
+
}, 6000);
|
|
6912
7152
|
pendingPresenceToast = intentToast;
|
|
6913
|
-
|
|
7153
|
+
// Whichever check applies an answer settles this click (settleAskedStep, from applyModelPresence): this one, or an
|
|
7154
|
+
// Exports or History render's that overtook it. Until then the step stays held and its toast stays up.
|
|
7155
|
+
refreshModelPresence(projectId, current.app).catch((err) => {
|
|
6914
7156
|
// A later click owns the shared probe's feedback and destination.
|
|
6915
|
-
if (pendingPresenceToast !== intentToast) return;
|
|
6916
|
-
intentToast();
|
|
6917
|
-
pendingPresenceToast = null;
|
|
6918
|
-
// The request's four-second deadline is a recovery boundary, not a silent discarded click.
|
|
6919
|
-
if (current?.id !== projectId) return;
|
|
6920
|
-
if (projectContractLifecycle === 'unknown') {
|
|
6921
|
-
showToast(`Couldn’t check project stages. Select ${stepLabel(s)} again to retry.`, 'warn');
|
|
6922
|
-
return;
|
|
6923
|
-
}
|
|
6924
|
-
// A confirmed preliminary answer turns the apparent availability into the real prerequisite
|
|
6925
|
-
// gate. Reuse that specific explanation instead of replacing it with generic readiness copy.
|
|
6926
|
-
const reason = stageGateFor(s);
|
|
6927
|
-
if (reason) showToast(reason, 'warn');
|
|
6928
|
-
}).catch((err) => {
|
|
6929
7157
|
if (pendingPresenceToast === intentToast) {
|
|
6930
7158
|
intentToast();
|
|
6931
7159
|
pendingPresenceToast = null;
|
|
7160
|
+
if (pendingPresenceStep?.asked && pendingPresenceStep.projectId === projectId) pendingPresenceStep = null;
|
|
6932
7161
|
}
|
|
6933
7162
|
console.error('[workspaces] tab lifecycle check failed', err);
|
|
6934
7163
|
});
|
|
@@ -7011,6 +7240,7 @@
|
|
|
7011
7240
|
// the model boundary speculatively. The existing request is reused and this destination opens
|
|
7012
7241
|
// automatically if it reports a model; the most recent click wins.
|
|
7013
7242
|
if (deferStageUntilLifecycle(s)) return;
|
|
7243
|
+
if (typeof dropAskedStep === 'function') dropAskedStep();
|
|
7014
7244
|
const lockedReason = stageGateFor(s);
|
|
7015
7245
|
if (lockedReason) {
|
|
7016
7246
|
if (currentStep !== 'drawings') setStep('drawings');
|
|
@@ -7516,7 +7746,8 @@
|
|
|
7516
7746
|
const APPROVAL_REASON_CODES = ['tekla-approval-refused', 'grant-unavailable', 'approval-nothing-exportable', ...IMPORT_FINDINGS_REFUSAL_CODES];
|
|
7517
7747
|
function knownApprovalFailureReason(error) {
|
|
7518
7748
|
const body = error && error.body;
|
|
7519
|
-
|
|
7749
|
+
// #3097: a `diagnostic` reply's `error` is what was thrown, not a sentence for the person, whatever its code.
|
|
7750
|
+
if (!body || body.diagnostic || typeof body.error !== 'string' || !body.error.trim()) return '';
|
|
7520
7751
|
return APPROVAL_REASON_CODES.includes(body.code) ? body.error.trim() : '';
|
|
7521
7752
|
}
|
|
7522
7753
|
/** The raw error, for the Technical details disclosure only: never the headline of a notice. */
|
|
@@ -7581,11 +7812,15 @@
|
|
|
7581
7812
|
/** The answer to "what does approving do": which version this becomes and what it replaces. */
|
|
7582
7813
|
function approvalVersionCardHtml(review) {
|
|
7583
7814
|
const mf = review.moveForward;
|
|
7815
|
+
// #3223 rank 7: a first approval that lands above versions already in History names its number and, when everything
|
|
7816
|
+
// below is an AI drawing read, says so, so "the first approved version" and the "v2" it becomes agree.
|
|
7817
|
+
const first = review.firstApproval && !mf && !review.base ? firstApprovalWords(review.firstApproval) : null;
|
|
7584
7818
|
const lead = mf ? (mf.replacesLatest ? `This replaces approved v${mf.toVersion}.` : `Your changes go on top of approved v${mf.toVersion} as the next approved version.`)
|
|
7585
7819
|
: review.base ? `This becomes the next approved version, after approved v${review.base.version}.`
|
|
7586
|
-
:
|
|
7820
|
+
: first ? `This becomes v${first.version}, the first approved version of this model.`
|
|
7821
|
+
: 'This becomes the first approved version of this model.';
|
|
7587
7822
|
return `<div class="approval-version-card"><b>${escapeHtml(lead)}</b>`
|
|
7588
|
-
+ '
|
|
7823
|
+
+ `<p>${first && first.card ? `${escapeHtml(first.card)} ` : ''}Approved exports and the compiled workflow use the approved version. You can keep editing the working copy afterwards.</p></div>`;
|
|
7589
7824
|
}
|
|
7590
7825
|
|
|
7591
7826
|
const review = approvalDialogState.review;
|
|
@@ -7859,6 +8094,24 @@
|
|
|
7859
8094
|
return `<span class="quick-pill${q.state === 'unknown' ? ' is-unknown' : ''}"${carrier} data-tip="${escapeAttr(tip)}">${escapeHtml((opts.showScope ? scope : '') + q.short)}</span>${spoken}`;
|
|
7860
8095
|
}
|
|
7861
8096
|
|
|
8097
|
+
/**
|
|
8098
|
+
* #2554 slice 2: which drawing files a model did NOT read, beside its Quick label and never inside it (a fully
|
|
8099
|
+
* reviewed precise model can still be part of its set). Neutral, because the amber is the Quick label's; dashed when
|
|
8100
|
+
* FloLess could not tell. A model that read its whole set shows none. `besides` is the Quick label of the same
|
|
8101
|
+
* document: when FloLess could not read that document at all, its dashed Quick pill already says so, and a second
|
|
8102
|
+
* dashed pill naming no file would add nothing.
|
|
8103
|
+
*/
|
|
8104
|
+
function coveragePillHtml(c, opts = {}) {
|
|
8105
|
+
if (!c || (c.state !== 'part' && c.state !== 'unknown') || typeof c.short !== 'string' || !c.short) return '';
|
|
8106
|
+
if (opts.besides && opts.besides.state === 'unknown' && c.state === 'unknown' && !c.count && quickPillHtml(opts.besides)) return '';
|
|
8107
|
+
const scope = opts.scope ? `${opts.scope}: ` : '';
|
|
8108
|
+
const tip = `${scope}${c.text || c.short}`;
|
|
8109
|
+
const nested = opts.focusable === false;
|
|
8110
|
+
const carrier = nested ? '' : ' data-command-id="shell.read-coverage-note" tabindex="0"';
|
|
8111
|
+
const spoken = nested ? `<span class="sr-only"> (${escapeHtml(tip)})</span>` : '';
|
|
8112
|
+
return `<span class="coverage-pill${c.state === 'unknown' ? ' is-unknown' : ''}"${carrier} data-tip="${escapeAttr(tip)}">${escapeHtml((opts.showScope ? scope : '') + c.short)}</span>${spoken}`;
|
|
8113
|
+
}
|
|
8114
|
+
|
|
7862
8115
|
/**
|
|
7863
8116
|
* The header chip: ONE compact chip for the approved head and, whenever it differs from the head, the working copy.
|
|
7864
8117
|
* Its tooltip names each document and says what it rests on, so the header never grows a second chip that pushes
|
|
@@ -7873,14 +8126,33 @@
|
|
|
7873
8126
|
const parts = [];
|
|
7874
8127
|
if (q && s.headVersion && quickPillHtml(q.head)) parts.push([`v${s.headVersion}`, q.head]);
|
|
7875
8128
|
if (q && (s.pendingCount > 0 || !s.headVersion) && quickPillHtml(q.draft)) parts.push(['Working copy', q.draft]);
|
|
8129
|
+
// #2554 slice 2: which drawing files each document did not read, scoped the same way, folded into the same chip.
|
|
8130
|
+
const c = s.status === 'ready' && s.review && s.review.coverage ? s.review.coverage : null;
|
|
8131
|
+
const covered = [];
|
|
8132
|
+
if (c && s.headVersion && coveragePillHtml(c.head, { besides: q && q.head })) covered.push([`v${s.headVersion}`, c.head]);
|
|
8133
|
+
if (c && (s.pendingCount > 0 || !s.headVersion) && coveragePillHtml(c.draft, { besides: q && q.draft })) covered.push(['Working copy', c.draft]);
|
|
8134
|
+
const coverageTip = covered.map(([scope, note]) => `${scope}: ${note.text || note.short}`).join(' ');
|
|
8135
|
+
const coverageShort = covered.some(([, note]) => note.state === 'part') ? 'Part of the set' : 'Part of the set?';
|
|
8136
|
+
if (!parts.length && covered.length) {
|
|
8137
|
+
$quick.innerHTML = `<span class="coverage-pill${covered.every(([, note]) => note.state === 'unknown') ? ' is-unknown' : ''}" data-command-id="shell.read-coverage-note" tabindex="0" data-tip="${escapeAttr(coverageTip)}">${escapeHtml(coverageShort)}</span>`;
|
|
8138
|
+
$quick.hidden = false;
|
|
8139
|
+
return;
|
|
8140
|
+
}
|
|
7876
8141
|
if (!parts.length) { $quick.innerHTML = ''; $quick.hidden = true; return; }
|
|
7877
8142
|
// "Quick model" when any document it speaks for is readably Quick; "Possibly Quick model" when none is; dashed
|
|
7878
8143
|
// whenever one of them could not be read.
|
|
7879
8144
|
const anyQuick = parts.some(([, label]) => label.state === 'quick');
|
|
7880
8145
|
const anyUnknown = parts.some(([, label]) => label.state === 'unknown');
|
|
8146
|
+
// The Quick document's explanation, then why each unreadable one could not be read (#2673); with two, each names
|
|
8147
|
+
// the document it explains, so a busy working copy is never read as a damaged version.
|
|
8148
|
+
const quickPart = parts.find(([, label]) => label.state === 'quick');
|
|
8149
|
+
const explained = [...(quickPart ? [quickPart] : []), ...parts.filter(([, label]) => label.state === 'unknown')]
|
|
8150
|
+
.filter(([, label]) => label.tip);
|
|
7881
8151
|
const tip = parts.map(([scope, label]) => `${scope}: ${label.label}.`).join(' ')
|
|
7882
|
-
+ ` ${
|
|
7883
|
-
|
|
8152
|
+
+ ` ${explained.map(([scope, label]) => (explained.length > 1 ? `${scope}: ${label.tip}` : label.tip)).join(' ')}`;
|
|
8153
|
+
const suffix = covered.length ? ` · ${coverageShort}` : '';
|
|
8154
|
+
const fullTip = covered.length ? `${tip.trim()} ${coverageTip}` : tip.trim();
|
|
8155
|
+
$quick.innerHTML = `<span class="quick-pill${anyUnknown ? ' is-unknown' : ''}" data-command-id="shell.quick-model-label" tabindex="0" data-tip="${escapeAttr(fullTip)}">${escapeHtml((anyQuick ? 'Quick model' : 'Possibly Quick model') + suffix)}</span>`;
|
|
7884
8156
|
$quick.hidden = false;
|
|
7885
8157
|
}
|
|
7886
8158
|
|
|
@@ -7896,7 +8168,7 @@
|
|
|
7896
8168
|
const ownsDialog = () => !!dialog && approvalDialogState === dialog && onProject();
|
|
7897
8169
|
if (ownsDialog() && $approvalRevisionNoteText) $approvalRevisionNoteText.value = '';
|
|
7898
8170
|
if (res && res.approvedAt) project.approvedAt = res.approvedAt;
|
|
7899
|
-
const { version: n, accepted, headline, assumed, quick } = approvalOutcomeWords(res);
|
|
8171
|
+
const { version: n, accepted, headline, reads, readsShort, assumed, quick, coverage } = approvalOutcomeWords(res);
|
|
7900
8172
|
if (n) expandDiffOnce = { projectId: project.id, n };
|
|
7901
8173
|
// An outcome can land while the person is editing this project again: a background check, or a dialog
|
|
7902
8174
|
// closed while the note above was saving. Reloading the editor then would discard edits not yet saved, so
|
|
@@ -7926,7 +8198,7 @@
|
|
|
7926
8198
|
// Edits still unsaved in the editor are not in any count FloLess read, so with them on screen no pending
|
|
7927
8199
|
// count is claimed at all: the sentence says what is known instead.
|
|
7928
8200
|
const keptEditsNote = 'Your newer edits stay in the editor and were not reloaded; once they are saved, reopen the model to see the approved version and what is still pending.';
|
|
7929
|
-
showToast(`${headline} ${quick}${assumed ? `${assumed} ` : ''}${keptEdits ? keptEditsNote : pending === null ? pendingUnknown : pending ? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}; approved exports omit them unless you explicitly choose DRAFT.` : 'No changes remain pending.'}`, 'ok');
|
|
8201
|
+
showToast(`${headline} ${reads ? `${reads} ` : ''}${quick}${coverage}${assumed ? `${assumed} ` : ''}${keptEdits ? keptEditsNote : pending === null ? pendingUnknown : pending ? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}; approved exports omit them unless you explicitly choose DRAFT.` : 'No changes remain pending.'}`, 'ok');
|
|
7930
8202
|
track('workspace_project_approved', { app: project.app });
|
|
7931
8203
|
if (onProject() && !$wsExports.hidden) safeRenderExports('after approving this version');
|
|
7932
8204
|
if (onProject() && !$wsHistory.hidden) await renderHistory();
|
|
@@ -7936,8 +8208,10 @@
|
|
|
7936
8208
|
: 'No changes remain pending.';
|
|
7937
8209
|
// The footer described the decision ("…will be approved…"); the decision has happened.
|
|
7938
8210
|
$approvalCounts.textContent = '';
|
|
7939
|
-
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> ${quick ? `${escapeHtml(quick)}` : ''}The approved model and compiled workflow are ready.${assumed ? ' ' + escapeHtml(assumed) : ''}${revisionNoteStatus ? ' ' + escapeHtml(revisionNoteStatus) : ''}${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
|
|
7940
|
-
|
|
8211
|
+
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> ${reads ? `${escapeHtml(reads)} ` : ''}${quick ? `${escapeHtml(quick)}` : ''}${coverage ? escapeHtml(coverage) : ''}The approved model and compiled workflow are ready.${assumed ? ' ' + escapeHtml(assumed) : ''}${revisionNoteStatus ? ' ' + escapeHtml(revisionNoteStatus) : ''}${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
|
|
8212
|
+
// The subtitle doubles as what a screen reader hears, so it carries the short form of the same sentence.
|
|
8213
|
+
const approvedPhase = accepted ? headline : `Approved${n ? ` as v${n}` : ''}`;
|
|
8214
|
+
setApprovalPhase('approved', readsShort ? `${accepted ? approvedPhase : `${approvedPhase}.`} ${readsShort}` : approvedPhase);
|
|
7941
8215
|
$approvalClose.focus();
|
|
7942
8216
|
}
|
|
7943
8217
|
|
|
@@ -7952,13 +8226,53 @@
|
|
|
7952
8226
|
// #1840: an approval that accepted open import findings is never announced as a plain "Approved".
|
|
7953
8227
|
const accepted = res && res.version && res.version.approval && res.version.approval.acceptedImportFindings;
|
|
7954
8228
|
const headline = accepted ? importFindingsCopy(accepted).approved(version) : `Approved${version ? ` as v${version}` : ''}.`;
|
|
8229
|
+
// #3223 rank 7: a first approval above the AI's drawing read says what the versions below it are, right after the
|
|
8230
|
+
// headline. Only for the version this result actually became.
|
|
8231
|
+
const first = version && res.firstApproval && Number(res.firstApproval.version) === version ? firstApprovalWords(res.firstApproval) : null;
|
|
8232
|
+
const reads = first ? first.result : '', readsShort = first ? first.short : '';
|
|
7955
8233
|
// #2449: an approval resting on connection assumptions (or one whose record could not be read) is never
|
|
7956
8234
|
// announced as a plain approval either; the server's own sentence, the same one History shows.
|
|
7957
8235
|
const assumed = res && res.connectionAssumptions && typeof res.connectionAssumptions.note === 'string' ? res.connectionAssumptions.note : '';
|
|
7958
8236
|
// #2521 row 5: an approved Quick model says so in the same breath, read from the approved version itself.
|
|
7959
8237
|
const quick = res && res.quick && (res.quick.state === 'quick' || res.quick.state === 'unknown') && typeof res.quick.label === 'string'
|
|
7960
8238
|
? `${res.quick.label}. ` : '';
|
|
7961
|
-
|
|
8239
|
+
// #2554 slice 2: and when it left drawing files unread, what that means for the approval and what covers them.
|
|
8240
|
+
// Unknown is never announced as a partial approval: it says FloLess could not tell. And when the version itself could
|
|
8241
|
+
// not be read (its Quick label is unknown too, with no file known unread) it is folded into that label, as the pills are.
|
|
8242
|
+
const c = res && res.coverage;
|
|
8243
|
+
const folded = c && c.state === 'unknown' && !c.count && res.quick && res.quick.state === 'unknown';
|
|
8244
|
+
const coverage = !c || folded || typeof c.brief !== 'string' ? ''
|
|
8245
|
+
: c.state === 'part' ? `${c.brief} This approval covers only the drawing files that were read; a later read of the others covers them. `
|
|
8246
|
+
: c.state === 'unknown' ? `${c.brief} FloLess could not tell whether this version read every drawing file; History shows what is known. `
|
|
8247
|
+
: '';
|
|
8248
|
+
return { version, accepted, headline, reads, readsShort, assumed, quick, coverage, sentence: `${headline} ${reads ? `${reads} ` : ''}${quick}${coverage}${assumed}`.trim() };
|
|
8249
|
+
}
|
|
8250
|
+
|
|
8251
|
+
/**
|
|
8252
|
+
* #3223 rank 7: why a first approval is not v1, in words. A model read from drawings keeps the AI's read in History
|
|
8253
|
+
* first (v1), so a person's first approval becomes v2, and "Approved as v2" beside "the first approved version" read
|
|
8254
|
+
* as a bug or a double approval. Said from the server's `firstApproval` facts, never guessed: `card` for the review
|
|
8255
|
+
* dialog's version card, `result` for the outcome notice and toasts, `short` for the subtitle a screen reader hears.
|
|
8256
|
+
* Null when there is nothing below to explain (a model approved as v1) or the facts are unreadable; empty sentences
|
|
8257
|
+
* when what sits below is not all drawing reads, so only the number is named.
|
|
8258
|
+
*/
|
|
8259
|
+
function firstApprovalWords(facts) {
|
|
8260
|
+
const version = facts && Number(facts.version);
|
|
8261
|
+
const before = facts && facts.before;
|
|
8262
|
+
if (!Number.isSafeInteger(version) || version < 1 || !before || typeof before !== 'object') return null;
|
|
8263
|
+
const count = Number(before.count), first = Number(before.first), last = Number(before.last);
|
|
8264
|
+
if (![count, first, last].every((value) => Number.isSafeInteger(value) && value >= 1) || first > last || last >= version) return null;
|
|
8265
|
+
if (before.drawingReads !== true) return { version, card: '', result: '', short: '' };
|
|
8266
|
+
const one = count === 1;
|
|
8267
|
+
// "v1 and v2", "v1 to v3"; a range with a gap in it is not named as one.
|
|
8268
|
+
const subject = one ? `v${first}` : count === last - first + 1 ? `v${first}${count === 2 ? ' and ' : ' to '}v${last}` : 'The earlier versions';
|
|
8269
|
+
const what = one ? 'is the AI read' : 'are AI reads';
|
|
8270
|
+
return {
|
|
8271
|
+
version,
|
|
8272
|
+
card: `${subject} in History ${what} of your drawings, not ${one ? 'an approved version' : 'approved versions'}.`,
|
|
8273
|
+
result: `${subject} ${what} of your drawings.`,
|
|
8274
|
+
short: `${subject} ${what}.`,
|
|
8275
|
+
};
|
|
7962
8276
|
}
|
|
7963
8277
|
|
|
7964
8278
|
// One receipt read. The server answers under the project's approval locks, which on a large model
|
|
@@ -8334,7 +8648,7 @@
|
|
|
8334
8648
|
$approvalSub.textContent = 'FloLess could not open this review';
|
|
8335
8649
|
} else {
|
|
8336
8650
|
$approvalSub.textContent = 'Approval status unavailable';
|
|
8337
|
-
$approvalImpact.textContent = (error
|
|
8651
|
+
$approvalImpact.textContent = errorText(error, { action: 'load the comparison', retrySafe: true });
|
|
8338
8652
|
$approvalBody.innerHTML = '<div class="approval-notice approval-notice-error"><b>Nothing was approved.</b> Try again when the model can be saved and compared.</div>';
|
|
8339
8653
|
setApprovalPhase('failed', 'Nothing was approved. Try again.');
|
|
8340
8654
|
}
|
|
@@ -8381,8 +8695,10 @@
|
|
|
8381
8695
|
const approved = Object.values(st.decisions || {}).filter((value) => value === 'approve').length;
|
|
8382
8696
|
const pending = groups.length - approved;
|
|
8383
8697
|
if (review.selective === false) {
|
|
8698
|
+
// #3223 rank 7: the same number the version card named, when versions already sit below it in History.
|
|
8699
|
+
const first = review.firstApproval && !review.base && !review.moveForward ? firstApprovalWords(review.firstApproval) : null;
|
|
8384
8700
|
return review.wholeVersionReason === 'first-approval' || !review.base
|
|
8385
|
-
? 'Approving the whole model as its first approved version.'
|
|
8701
|
+
? first ? `Approving the whole model as v${first.version}, its first approved version.` : 'Approving the whole model as its first approved version.'
|
|
8386
8702
|
: `Approving the whole model as the next approved version after v${review.base.version}.`;
|
|
8387
8703
|
}
|
|
8388
8704
|
return `Approving ${approved} change${approved === 1 ? '' : 's'}${pending > 0 ? ` · ${pending} stay${pending === 1 ? 's' : ''} pending` : ''}.`;
|
|
@@ -8487,7 +8803,8 @@
|
|
|
8487
8803
|
approvalDialogState.conflicts = decisionSnapshot.conflicts;
|
|
8488
8804
|
approvalDialogState.retryAction = 'approve';
|
|
8489
8805
|
renderApprovalReview();
|
|
8490
|
-
|
|
8806
|
+
// The recorded outcome was checked first, so nothing was approved and the same decisions can be tried again.
|
|
8807
|
+
$approvalImpact.textContent = errorText(error, { action: 'approve these changes', retrySafe: true });
|
|
8491
8808
|
$approvalBody.insertAdjacentHTML('afterbegin', '<div class="approval-notice approval-notice-error"><b>Nothing was approved.</b> Try again with the same decisions.</div>');
|
|
8492
8809
|
setApprovalPhase('failed', 'Nothing was approved. Try again.');
|
|
8493
8810
|
$approvalRetry.focus();
|
|
@@ -8513,7 +8830,7 @@
|
|
|
8513
8830
|
setApprovalPhase('ready');
|
|
8514
8831
|
($approvalBody.querySelector('[data-approval-decision]:not([disabled])') || $approvalConfirm).focus();
|
|
8515
8832
|
} catch (error) {
|
|
8516
|
-
$approvalImpact.textContent = (error
|
|
8833
|
+
$approvalImpact.textContent = errorText(error, { action: 'reload the current review', retrySafe: true });
|
|
8517
8834
|
setApprovalPhase('stale', 'The current review could not be loaded.');
|
|
8518
8835
|
$approvalReload.focus();
|
|
8519
8836
|
}
|
|
@@ -8574,7 +8891,7 @@
|
|
|
8574
8891
|
if (event.target.closest('[data-approval-workflow-update]') && approvalDialogState && approvalDismissible(approvalDialogState.phase)) {
|
|
8575
8892
|
const appId = current?.app;
|
|
8576
8893
|
closeApprovalReview();
|
|
8577
|
-
if (appId) bridge.reviewWorkflowUpdate(appId).catch((error) => showToast(error
|
|
8894
|
+
if (appId) bridge.reviewWorkflowUpdate(appId).catch((error) => showToast(errorText(error, { action: 'open the workflow update', retrySafe: true }), 'warn'));
|
|
8578
8895
|
return;
|
|
8579
8896
|
}
|
|
8580
8897
|
const openAudit = event.target.closest('[data-approval-open-audit]');
|
|
@@ -8697,10 +9014,9 @@
|
|
|
8697
9014
|
frames.model.addEventListener('load', () => {
|
|
8698
9015
|
try {
|
|
8699
9016
|
frames.model.contentWindow.addEventListener('keydown', (e) => {
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
}
|
|
9017
|
+
// Only take the key when Find actually opened (#3142); otherwise the browser's own Find still works.
|
|
9018
|
+
if ((e.ctrlKey || e.metaKey) && !e.shiftKey && (e.key === 'f' || e.key === 'F')
|
|
9019
|
+
&& typeof window.openFind === 'function' && window.openFind()) e.preventDefault();
|
|
8704
9020
|
});
|
|
8705
9021
|
} catch { /* not-yet-loaded / cross-origin */ }
|
|
8706
9022
|
// Chromium can make the iframe the parent's active element during navigation without a reliable
|
|
@@ -8877,7 +9193,7 @@
|
|
|
8877
9193
|
// Each read is bounded (#1604): the 3-second poll skips its ticks while a render is out, so a
|
|
8878
9194
|
// request that never answered would stop the column refreshing for good.
|
|
8879
9195
|
const bounded = () => ({ timeoutMs: 90_000 });
|
|
8880
|
-
const [status, reqs, company, designSet] = await Promise.all([
|
|
9196
|
+
const [status, reqs, company, designSet, connected] = await Promise.all([
|
|
8881
9197
|
api(kbUrl(proj.id, '/status'), bounded()),
|
|
8882
9198
|
api('/api/requests', bounded()).catch(() => []),
|
|
8883
9199
|
api(`/api/company-knowledge?projectId=${encodeURIComponent(proj.id)}`, bounded())
|
|
@@ -8885,6 +9201,8 @@
|
|
|
8885
9201
|
// #2399 slice 0b: a design set that cannot be read is said as such, never as "none".
|
|
8886
9202
|
api(`/api/projects/${encodeURIComponent(proj.id)}/design-set`, bounded())
|
|
8887
9203
|
.catch(() => ({ status: 'unknown', revision: 0, warnings: [{ code: 'unreadable', message: 'FloLess could not read the design set just now.' }] })),
|
|
9204
|
+
// #2470 R6.8: connected sources; a project without any answers with empty lists. One that cannot be read says so.
|
|
9205
|
+
api(kbUrl(proj.id, '/connected'), bounded()).catch(() => ({ unreadable: true, sources: [], removed: [] })),
|
|
8888
9206
|
]);
|
|
8889
9207
|
const list = Array.isArray(reqs) ? reqs : (reqs.requests || []);
|
|
8890
9208
|
const manifest = status.manifest || { revision: 0, currentGeneration: null, sources: [] };
|
|
@@ -8899,6 +9217,7 @@
|
|
|
8899
9217
|
queued: status.pendingRequests || list.filter((r) => r && r.type === 'knowledge-organize' && r.project === proj.id),
|
|
8900
9218
|
company,
|
|
8901
9219
|
designSet,
|
|
9220
|
+
connected,
|
|
8902
9221
|
};
|
|
8903
9222
|
}
|
|
8904
9223
|
|
|
@@ -9259,6 +9578,7 @@
|
|
|
9259
9578
|
}
|
|
9260
9579
|
|
|
9261
9580
|
function kbSourceRow(s, st, depth) {
|
|
9581
|
+
if (s.kind === 'connected') return kbConnRowHtml(s, st, depth);
|
|
9262
9582
|
const on = !!s.useAsKb;
|
|
9263
9583
|
const sel = kbSel.selected.has(s.sourceId);
|
|
9264
9584
|
const ico = kbIcon(s.mime);
|
|
@@ -10868,6 +11188,992 @@
|
|
|
10868
11188
|
if (pre) pre.textContent = text; // THE escaping guarantee — `<img src=x onerror=…>` stays literal
|
|
10869
11189
|
}
|
|
10870
11190
|
|
|
11191
|
+
// ── #2470 R6.8: connected sources ──────────────────────────────────────────────────────────────────────
|
|
11192
|
+
// A Teams chat synced into Knowledge through the Microsoft 365 account chosen in Integrations. Its row sits in the
|
|
11193
|
+
// reference list like any other (categories, the use-as-knowledge switch); what differs is drawn from
|
|
11194
|
+
// /knowledge/connected. Connect, Sync now and Erase are the person's own click (the server checks); each carries the
|
|
11195
|
+
// source revision this screen drew, so a source that synced meanwhile is shown again instead of acted on.
|
|
11196
|
+
const kbConnStops = new Map(); // sourceId → { message, choices, target, opts }: a sync that stopped and asks
|
|
11197
|
+
const kbConnSyncing = new Set(); // syncs this window has out
|
|
11198
|
+
const kbConnChanging = new Map(); // sourceId → a settings change still out: resolves to the revision it left (Sync now waits)
|
|
11199
|
+
const kbConnGapsOpen = new Set(); // gap disclosures the person opened (kept across the 3 s repaint)
|
|
11200
|
+
const KB_CONN_CHOICES = {
|
|
11201
|
+
'sync-with-current': 'Sync with the account I’m signed in with', 'confirm-target': 'Use this account', 'resume-and-sync': 'Resume and sync',
|
|
11202
|
+
'sync-anyway': 'Sync anyway', retry: 'Try again', reload: 'Refresh', pause: 'Pause', remove: 'Remove…',
|
|
11203
|
+
'open-integrations': 'Open Integrations', 'open-tools': 'Open Tools', cancel: 'Leave it for now', 'sync-now': 'Sync now',
|
|
11204
|
+
keep: 'Keep the copy',
|
|
11205
|
+
rebuild: 'Rebuild the copy',
|
|
11206
|
+
};
|
|
11207
|
+
// #2470 R6.8 slice 1b: an Outlook mail folder is the second kind. Its row adds the window, the coverage of the last listing,
|
|
11208
|
+
// what waits to be read and what was left out, all from the last sync (no message text), and asks the ceiling question.
|
|
11209
|
+
const kbConnIsMail = (c) => !!(c && c.scope === 'outlook-folder');
|
|
11210
|
+
// #2470 R6.8 slice 2: a Trimble Connect project is the third kind: its topics (coordination issues), their comments and
|
|
11211
|
+
// its ToDos. It has no window; its row says how the copy is kept up to date, from the last sync.
|
|
11212
|
+
const kbConnIsTrimble = (c) => !!(c && c.scope === 'trimble-project');
|
|
11213
|
+
const kbConnKindName = (c) => (kbConnIsTrimble(c) ? 'Trimble Connect project' : kbConnIsMail(c) ? 'Outlook folder' : 'Teams chat');
|
|
11214
|
+
const kbConnService = (c) => (kbConnIsTrimble(c) ? 'Trimble Connect' : 'Microsoft 365');
|
|
11215
|
+
const kbConnThing = (c) => (kbConnIsTrimble(c) ? 'project' : kbConnIsMail(c) ? 'folder' : 'chat');
|
|
11216
|
+
const kbConnGlyph = (kind) => (kind === 'trimble-project' ? '⚑︎' : kind === 'outlook-folder' ? '✉︎' : '◫');
|
|
11217
|
+
const KB_CONN_REGIONS = [['northAmerica', 'North America'], ['europe', 'Europe'], ['unitedKingdom', 'United Kingdom'], ['asia', 'Asia'], ['australia', 'Australia']];
|
|
11218
|
+
const kbConnRegionName = (r) => (KB_CONN_REGIONS.find(([v]) => v === r) || [r, r])[1];
|
|
11219
|
+
// The plan §17 #13 disclosure, word for word as the page and the action card say it.
|
|
11220
|
+
const KB_CONN_TRIMBLE_NOT_INCLUDED = 'Not included: viewpoints and their snapshots, files, document references, BCF documents, related-topic links, and ToDo comments and attachments (ToDos show their own fields only).';
|
|
11221
|
+
const kbConnDate = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? new Date(t).toLocaleDateString() : ''; };
|
|
11222
|
+
const kbConnWhen = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? new Date(t).toLocaleString() : ''; };
|
|
11223
|
+
const kbConnPlural = (n, one, many) => `${n.toLocaleString()} ${n === 1 ? one : many}`;
|
|
11224
|
+
|
|
11225
|
+
/** The Trimble lines under a row's meta line (slice 2 plan §18 #8, §19): only what needs saying shows on the row; how the
|
|
11226
|
+
* copy is kept up to date sits in one disclosure. Everything comes from the last sync; no topic text. */
|
|
11227
|
+
function kbConnTrimbleHtml(sourceId, c, name) {
|
|
11228
|
+
const t = c.trimble || {};
|
|
11229
|
+
const lines = [];
|
|
11230
|
+
const cov = t.coverage;
|
|
11231
|
+
const kindWord = (k) => (k === 'topics' ? 'topics' : 'ToDos');
|
|
11232
|
+
if (cov) {
|
|
11233
|
+
for (const k of ['topics', 'todos']) {
|
|
11234
|
+
if (cov[k] === 'over-ceiling') lines.push(`More than 5,000 ${kindWord(k)}, so this copy is partial. Nothing is removed just because Trimble stopped listing it.`);
|
|
11235
|
+
}
|
|
11236
|
+
const incomplete = ['topics', 'todos'].filter((k) => cov[k] === 'incomplete');
|
|
11237
|
+
if (incomplete.length) lines.push(`The ${incomplete.map(kindWord).join(' and ')} listing did not finish in the last sync. Nothing was removed because of it.`);
|
|
11238
|
+
}
|
|
11239
|
+
if (t.waitingReads > 0) lines.push(`${kbConnPlural(t.waitingReads, 'topic', 'topics')} waiting to be read, up to 50 per sync.`);
|
|
11240
|
+
if (t.moreComments > 0) lines.push(`Trimble returned more comments than FloLess reads in one go for ${kbConnPlural(t.moreComments, 'topic', 'topics')}. Some may not be here yet.`);
|
|
11241
|
+
if (t.missedOnce > 0) {
|
|
11242
|
+
lines.push(`${kbConnPlural(t.missedOnce, 'record was', 'records were')} not listed by Trimble in the last sync; FloLess removes ${t.missedOnce === 1 ? 'it' : 'them'} if the next full listing misses ${t.missedOnce === 1 ? 'it' : 'them'} too.`);
|
|
11243
|
+
}
|
|
11244
|
+
// The size cut, for topics and ToDos alike: a ToDo-only cut is as much a gap as a topic one.
|
|
11245
|
+
const cut = t.capacityCut;
|
|
11246
|
+
const notKeptTopics = (t.capacity && t.capacity.topics) || 0;
|
|
11247
|
+
const notKeptTodos = (t.capacity && t.capacity.todos) || 0;
|
|
11248
|
+
if (cut && (cut.topics || cut.todos)) {
|
|
11249
|
+
const counted = [notKeptTopics && kbConnPlural(notKeptTopics, 'topic', 'topics'), notKeptTodos && kbConnPlural(notKeptTodos, 'ToDo', 'ToDos')].filter(Boolean);
|
|
11250
|
+
const what = [cut.topics && 'topics', cut.todos && 'ToDos'].filter(Boolean).join(' and ');
|
|
11251
|
+
lines.push(`This project is bigger than FloLess keeps, so ${counted.length ? `${counted.join(' and ')} ${notKeptTopics + notKeptTodos === 1 ? 'is' : 'are'}` : `some ${what} are`} not in this copy. They are picked by Trimble's id, not by date, so old and new ${what} can both be missing.`);
|
|
11252
|
+
}
|
|
11253
|
+
if (t.positionLost) lines.push('FloLess lost its place in this project, so some topics may be read twice and a removal waits one more sync.');
|
|
11254
|
+
const r = t.rotation;
|
|
11255
|
+
if (r && r.failed > 0) lines.push(`The last comment check failed for ${kbConnPlural(r.failed, 'topic', 'topics')}. FloLess tries again.`);
|
|
11256
|
+
const n = t.counts || {};
|
|
11257
|
+
const details = [];
|
|
11258
|
+
if (r && r.of > 0) {
|
|
11259
|
+
details.push(`FloLess re-reads every kept topic's comments at least once every ${kbConnPlural(r.every, 'sync', 'syncs')}, as long as the topics stay the same.`);
|
|
11260
|
+
details.push(`This round: topic ${Math.min(r.at, r.of).toLocaleString()} of ${r.of.toLocaleString()}.`);
|
|
11261
|
+
if (r.oldestCheck) details.push(`Oldest comment check: ${kbConnWhen(r.oldestCheck)}.`);
|
|
11262
|
+
}
|
|
11263
|
+
if (n.noChangeTime > 0) details.push(`Trimble gave no change time for ${kbConnPlural(n.noChangeTime, 'record', 'records')}; FloLess shows ${n.noChangeTime === 1 ? 'it' : 'them'} as last listed.`);
|
|
11264
|
+
if (n.notAdmitted > 0) details.push(`${kbConnPlural(n.notAdmitted, 'answer', 'answers')} from Trimble ${n.notAdmitted === 1 ? 'was' : 'were'} older than what FloLess already had, so FloLess kept its copy.`);
|
|
11265
|
+
// Only a listing that finished is "full": the time of an incomplete one would be a claim the copy cannot back.
|
|
11266
|
+
if (t.lastCompleteAt) details.push(`Last full listing ${kbConnWhen(t.lastCompleteAt)}.`);
|
|
11267
|
+
const more = details.length
|
|
11268
|
+
? `<details class="kb-conn-gaps" data-kb-conn-gaps="${escapeAttr(`${sourceId}:kept`)}"${kbConnGapsOpen.has(`${sourceId}:kept`) ? ' open' : ''}>` +
|
|
11269
|
+
`<summary data-command-id="shell.kb-connected-kept-up#${escapeAttr(sourceId)}" data-command-instance-label="${escapeAttr(name)}">How this copy is kept up to date</summary>` +
|
|
11270
|
+
`<ul>${details.map((d) => `<li>${escapeHtml(d)}</li>`).join('')}</ul></details>` : '';
|
|
11271
|
+
return lines.map((line) => `<div class="kb-conn-note">${escapeHtml(line)}</div>`).join('') + more;
|
|
11272
|
+
}
|
|
11273
|
+
|
|
11274
|
+
/** The Outlook lines under a row's meta line (plan §5.3), each shown only when it says something. */
|
|
11275
|
+
function kbConnMailHtml(sourceId, c, name) {
|
|
11276
|
+
const o = c.outlook || {};
|
|
11277
|
+
const lines = [];
|
|
11278
|
+
// After a window change the last listing was of another window, so its coverage says nothing about this one until the
|
|
11279
|
+
// next sync (code review R12 #1).
|
|
11280
|
+
if (o.settingsPending) {
|
|
11281
|
+
lines.push(`You changed the window to the last ${o.windowDays} days. The next sync lists that window; until then, what this row says comes from the last sync, which listed the last ${o.listedWindowDays} days.`);
|
|
11282
|
+
}
|
|
11283
|
+
const cov = o.settingsPending ? null : o.coverage;
|
|
11284
|
+
// Dated by the listing itself: a later sync that stopped listed nothing (code review R13 #1).
|
|
11285
|
+
if (cov && cov.kind === 'complete') lines.push(`Last full listing ${kbConnWhen(o.listedAt || (c.lastSync && c.lastSync.at))}.`);
|
|
11286
|
+
else if (cov && cov.kind === 'partial') {
|
|
11287
|
+
lines.push(`Partial: more than 100,000 mails in the window. Outlook listed the mail received after ${kbConnWhen(cov.frontier)} and some received at that time; older mail was not listed. ` +
|
|
11288
|
+
'While the copy is partial, FloLess removes nothing that Outlook stops listing, so any message here may have left the folder.' +
|
|
11289
|
+
// Mail Outlook listed but FloLess could not identify may be missing at any date (code review R11 #1).
|
|
11290
|
+
(cov.omitted > 0 ? ` Outlook also listed ${kbConnPlural(cov.omitted, 'message', 'messages')} FloLess could not identify; ${cov.omitted === 1 ? 'it' : 'they'} may be missing here, whatever ${cov.omitted === 1 ? 'its' : 'their'} date.` : ''));
|
|
11291
|
+
} else if (cov && cov.kind === 'incomplete') lines.push(`Listing incomplete: ${cov.reason} Nothing was removed because of this listing.`);
|
|
11292
|
+
if (o.waitingReads > 0) lines.push(`${kbConnPlural(o.waitingReads, 'message', 'messages')} waiting to be read, up to 50 per sync.`);
|
|
11293
|
+
if (o.missedOnce > 0) {
|
|
11294
|
+
lines.push(`${kbConnPlural(o.missedOnce, 'message was', 'messages were')} not listed by Outlook in the last sync; FloLess removes ${o.missedOnce === 1 ? 'it' : 'them'} if the next full listing misses ${o.missedOnce === 1 ? 'it' : 'them'} too.`);
|
|
11295
|
+
}
|
|
11296
|
+
// The size-limit cut that still applies (plan §3.4), said whatever the last sync counted (code review R3 #1).
|
|
11297
|
+
if (o.capacityCutAt) lines.push(`This source reached FloLess's size limit: messages received before ${kbConnDate(o.capacityCutAt)} are not kept.`);
|
|
11298
|
+
if (o.rereadLeft > 0) {
|
|
11299
|
+
lines.push(`Reading every message again: ${o.rereadLeft.toLocaleString()} left, up to 50 per sync.` +
|
|
11300
|
+
(o.rereadMayRepeat ? ' FloLess lost track of which messages it had already read again, so some may be read twice.' : ''));
|
|
11301
|
+
}
|
|
11302
|
+
const n = o.counts || {};
|
|
11303
|
+
// Mail Outlook lists without a change time is kept, so it is never "left out" (code review R7 #2): FloLess cannot see
|
|
11304
|
+
// an edit to it until every message is read again.
|
|
11305
|
+
if (n.noChangeTime > 0) {
|
|
11306
|
+
lines.push(`Outlook gave no change time for ${kbConnPlural(n.noChangeTime, 'message', 'messages')}. FloLess keeps ${n.noChangeTime === 1 ? 'it' : 'them'}, and notices an edit to ${n.noChangeTime === 1 ? 'it' : 'them'} only when you choose Read every message again.`);
|
|
11307
|
+
}
|
|
11308
|
+
// A kept message whose newer version waits to be read is kept, not left out (convergence check 2026-11-07).
|
|
11309
|
+
if (n.newerPending > 0) {
|
|
11310
|
+
lines.push(`${kbConnPlural(n.newerPending, 'message has', 'messages have')} a newer version in Outlook that FloLess has not read yet; FloLess keeps the version it read until then.`);
|
|
11311
|
+
}
|
|
11312
|
+
// Kept mail whose text FloLess could not read is kept, so it is said on its own line too (code review R8 #1), and a
|
|
11313
|
+
// newer version too large to read says the older text is gone (code review R9 #2).
|
|
11314
|
+
if (n.keptTooLarge > 0) {
|
|
11315
|
+
lines.push(`${kbConnPlural(n.keptTooLarge, 'message has', 'messages have')} a newer version too large to read. FloLess keeps ${n.keptTooLarge === 1 ? 'its' : 'their'} sender and subject, and no longer keeps the older text.`);
|
|
11316
|
+
}
|
|
11317
|
+
if (n.noBody > 0) {
|
|
11318
|
+
lines.push(`Outlook gave no usable body for ${kbConnPlural(n.noBody, 'message', 'messages')}. FloLess keeps ${n.noBody === 1 ? 'it' : 'them'} without text, and reads ${n.noBody === 1 ? 'it' : 'them'} again when Outlook lists a newer change.`);
|
|
11319
|
+
}
|
|
11320
|
+
const onPurpose = [[n.draft, 'draft', 'drafts'], [n.noReceivedDate, 'message with no received date', 'messages with no received date']].filter(([k]) => k > 0);
|
|
11321
|
+
const unread = [[n.tooLarge, 'message too large to keep', 'messages too large to keep'],
|
|
11322
|
+
[n.notKept, 'message past the size limit', 'messages past the size limit'],
|
|
11323
|
+
[n.gone, 'message Outlook listed but could not find when FloLess read it', 'messages Outlook listed but could not find when FloLess read them'],
|
|
11324
|
+
[n.superseded, 'message Outlook offered only in an older version than FloLess had seen', 'messages Outlook offered only in an older version than FloLess had seen']].filter(([k]) => k > 0);
|
|
11325
|
+
const total = [...onPurpose, ...unread].reduce((sum, [k]) => sum + k, 0);
|
|
11326
|
+
const left = total ? `<details class="kb-conn-gaps" data-kb-conn-gaps="${escapeAttr(`${sourceId}:left`)}"${kbConnGapsOpen.has(`${sourceId}:left`) ? ' open' : ''}>` +
|
|
11327
|
+
`<summary data-command-id="shell.kb-connected-left-out#${escapeAttr(sourceId)}" data-command-instance-label="${escapeAttr(name)}">What was left out (${total.toLocaleString()})</summary>` +
|
|
11328
|
+
(onPurpose.length ? `<ul>${onPurpose.map(([k, one, many]) => `<li>${escapeHtml(kbConnPlural(k, one, many))}</li>`).join('')}</ul>` : '') +
|
|
11329
|
+
(unread.length ? `<ul>${unread.map(([k, one, many]) => `<li>${escapeHtml(kbConnPlural(k, one, many))}</li>`).join('')}</ul>` +
|
|
11330
|
+
'<div>FloLess reads these again when Outlook lists a newer change, or when you choose Read every message again.</div>' : '') +
|
|
11331
|
+
'</details>' : '';
|
|
11332
|
+
// Only a window shorter than the one listed can bring it under the ceiling, and the partial copy keeps the window the
|
|
11333
|
+
// source has; at 7 days the partial copy is the one choice (code review R13 #2).
|
|
11334
|
+
const days = o.windowDays || 90;
|
|
11335
|
+
const shorter = [30, 7].filter((d) => d < days);
|
|
11336
|
+
const ask = o.ceilingQuestion
|
|
11337
|
+
? '<div class="kb-conn-ask" role="status"><b>This folder holds more mail than one sync can list.</b> More than 100,000 mails arrived in the last ' +
|
|
11338
|
+
(shorter.length
|
|
11339
|
+
? `${escapeHtml(String(days))} days. Keep a shorter window, so FloLess can tell which mail left the folder, or keep a partial copy?`
|
|
11340
|
+
: `${escapeHtml(String(days))} days, the shortest window FloLess offers. Keep a partial copy?`) +
|
|
11341
|
+
'<div class="kb-conn-choices">' + [...shorter.map((d) => [String(d), `Keep the last ${d} days`, '']),
|
|
11342
|
+
['partial', 'Keep a partial copy', `Keeps the last ${days} days, but mail Outlook stops listing is not removed while the copy is partial`]].map(([v, label, tip], i) =>
|
|
11343
|
+
`<button type="button" class="kb-link${i === 0 ? ' kb-conn-primary' : ''}" data-kb-conn-ceiling="${escapeAttr(v)}" data-kb-conn-id="${escapeAttr(sourceId)}" data-kb-conn-rev="${escapeAttr(c.revision || '')}"` +
|
|
11344
|
+
`${tip ? ` data-tip="${escapeAttr(tip)}"` : ''} data-command-id="shell.kb-connected-ceiling#${escapeAttr(v)}" data-command-instance-label="${escapeAttr(label)}">${escapeHtml(label)}</button>`).join('') +
|
|
11345
|
+
'</div></div>' : '';
|
|
11346
|
+
return lines.map((line) => `<div class="kb-conn-note">${escapeHtml(line)}</div>`).join('') + ask + left;
|
|
11347
|
+
}
|
|
11348
|
+
// The choices a stop offers that this screen can act on; never none, so a stopped sync always has a way on.
|
|
11349
|
+
const kbConnKnownChoices = (choices) => {
|
|
11350
|
+
const known = (Array.isArray(choices) ? choices : []).filter((choice) => KB_CONN_CHOICES[choice]);
|
|
11351
|
+
return known.length ? known : ['retry', 'pause', 'remove'];
|
|
11352
|
+
};
|
|
11353
|
+
|
|
11354
|
+
const kbConnOf = (st, sourceId) => ((st && st.connected && st.connected.sources) || []).find((c) => c.sourceId === sourceId) || null;
|
|
11355
|
+
const kbConnUrl = (path) => kbUrl(current.id, `/connected${path}`);
|
|
11356
|
+
function kbConnRepaint() { kbInvalidateRefs(); if (knowledgeState) paintKnowledge(knowledgeState); }
|
|
11357
|
+
|
|
11358
|
+
function kbConnStopHtml(sourceId, stop) {
|
|
11359
|
+
const buttons = kbConnKnownChoices(stop.choices).map((choice, n) =>
|
|
11360
|
+
`<button type="button" class="kb-link${n === 0 ? ' kb-conn-primary' : ''}" data-kb-conn-choice="${escapeAttr(choice)}" data-kb-conn-id="${escapeAttr(sourceId)}"` +
|
|
11361
|
+
` data-command-id="shell.kb-connected-choice#${escapeAttr(choice)}" data-command-instance-label="${escapeAttr(KB_CONN_CHOICES[choice])}">${escapeHtml(KB_CONN_CHOICES[choice])}</button>`).join('');
|
|
11362
|
+
return `<div class="kb-conn-stop" role="status"><b>Not synced.</b> ${escapeHtml(stop.message)}${buttons ? `<div class="kb-conn-choices">${buttons}</div>` : ''}</div>`;
|
|
11363
|
+
}
|
|
11364
|
+
|
|
11365
|
+
function kbConnRowHtml(s, st, depth) {
|
|
11366
|
+
const c = kbConnOf(st, s.sourceId);
|
|
11367
|
+
const on = !!s.useAsKb;
|
|
11368
|
+
const sel = kbSel.selected.has(s.sourceId);
|
|
11369
|
+
const mail = kbConnIsMail(c);
|
|
11370
|
+
const name = (c && c.label) || s.filename || kbConnKindName(c);
|
|
11371
|
+
const isOpen = viewer.mode === 'file' && viewer.sourceId === s.sourceId;
|
|
11372
|
+
const syncing = kbConnSyncing.has(s.sourceId) || !!(c && c.syncing);
|
|
11373
|
+
// When the chat was last read: the newest version, or a later sync that found nothing new (it read the chat too).
|
|
11374
|
+
const checked = c && c.lastSync && c.lastSync.outcome !== 'stopped' ? Date.parse(c.lastSync.at || '') : NaN;
|
|
11375
|
+
const saved = Date.parse((c && c.lastSyncedAt) || '');
|
|
11376
|
+
const at = Number.isFinite(checked) && !(checked < saved) ? checked : saved;
|
|
11377
|
+
const when = Number.isFinite(at) ? `synced ${kbAgo(Date.now() - at)}` : 'not synced yet';
|
|
11378
|
+
const versions = c ? `${c.versions} version${c.versions === 1 ? '' : 's'}` : '';
|
|
11379
|
+
const since = Date.parse((c && c.windowStart) || '');
|
|
11380
|
+
const trimble = kbConnIsTrimble(c);
|
|
11381
|
+
const scope = trimble ? kbConnRegionName(c.trimble && c.trimble.region) : mail ? `last ${(c.outlook && c.outlook.windowDays) || 90} days`
|
|
11382
|
+
: Number.isFinite(since) ? `messages since ${new Date(since).toLocaleDateString()}` : '';
|
|
11383
|
+
const unread = !!(st && st.connected && st.connected.unreadable);
|
|
11384
|
+
const service = c ? kbConnService(c) : 'Connected source';
|
|
11385
|
+
const meta = unread ? `${service} · FloLess could not read its sync status just now. Reopen Knowledge to try again.`
|
|
11386
|
+
: [service, c && c.account, scope, when, versions].filter(Boolean).join(' · ');
|
|
11387
|
+
const chips = (syncing ? '<span class="kb-chip">syncing…</span>' : '') +
|
|
11388
|
+
(c && c.paused ? '<span class="kb-chip kb-conn-paused">paused</span>' : '') +
|
|
11389
|
+
(c && c.organizedPending ? '<span class="kb-chip new" data-tip="Organize again to use what this sync brought in">synced after the last Organize</span>' : '');
|
|
11390
|
+
const stop = kbConnStops.get(s.sourceId);
|
|
11391
|
+
const last = c && c.lastSync;
|
|
11392
|
+
const stopped = stop ? kbConnStopHtml(s.sourceId, stop)
|
|
11393
|
+
// A stop from before a reload: the same way on as a fresh one (the choices are this screen's, not stored).
|
|
11394
|
+
: last && last.outcome === 'stopped' ? kbConnStopHtml(s.sourceId, { message: `Last sync stopped: ${last.message || ''}`, choices: last.choices }) : '';
|
|
11395
|
+
const gaps = c && c.gaps === null
|
|
11396
|
+
? '<div class="kb-conn-note">FloLess could not check whether this copy holds every message. Sync again to check.</div>'
|
|
11397
|
+
: c && Array.isArray(c.gaps) && c.gaps.length
|
|
11398
|
+
? `<details class="kb-conn-gaps" data-kb-conn-gaps="${escapeAttr(s.sourceId)}"${kbConnGapsOpen.has(s.sourceId) ? ' open' : ''}>` +
|
|
11399
|
+
`<summary data-command-id="shell.kb-connected-gaps#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}">Some messages may be missing (${c.gaps.length} time range${c.gaps.length === 1 ? '' : 's'})</summary>` +
|
|
11400
|
+
`<div>Microsoft 365 said more messages may have changed at these times than one sync reads, so some may not be in this copy. Sync more often to keep a busy chat complete.</div>` +
|
|
11401
|
+
`<ul>${c.gaps.map((g) => `<li>${escapeHtml(new Date(g.from).toLocaleString())} – ${escapeHtml(new Date(g.to).toLocaleString())}</li>`).join('')}</ul></details>`
|
|
11402
|
+
: '';
|
|
11403
|
+
return `<div class="kb-src kb-conn${on ? '' : ' off'}${sel ? ' selected' : ''}" draggable="true"` +
|
|
11404
|
+
(depth != null ? ` style="--kb-depth:${depth}"` : '') +
|
|
11405
|
+
` data-source-id="${escapeAttr(s.sourceId)}"${isOpen ? ' aria-current="true"' : ''}>` +
|
|
11406
|
+
`<span class="kb-fico conn" aria-hidden="true" data-tip="${kbConnKindName(c)}">${kbConnGlyph(c && c.scope)}</span>` +
|
|
11407
|
+
'<div class="kb-fbody">' +
|
|
11408
|
+
`<button type="button" class="kb-fname" data-kb-open="${escapeAttr(s.sourceId)}" data-command-id="shell.kb-reference#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}" ` +
|
|
11409
|
+
`data-tip="Preview what was synced from “${escapeAttr(name)}” · Ctrl or Shift to select">${escapeHtml(name)}${sel ? '<span class="kb-sr"> (selected)</span>' : ''}</button>` +
|
|
11410
|
+
`<div class="kb-fmeta"${Number.isFinite(at) || mail ? ` data-tip="${escapeAttr([mail && Number.isFinite(since) ? `Mail received since ${new Date(since).toLocaleDateString()}` : '',
|
|
11411
|
+
Number.isFinite(at) ? `Last synced ${new Date(at).toLocaleString()}` : ''].filter(Boolean).join(' · '))}"` : ''}>${escapeHtml(meta)}${chips}</div>` +
|
|
11412
|
+
(mail && !unread ? kbConnMailHtml(s.sourceId, c, name) : '') + (trimble && !unread ? kbConnTrimbleHtml(s.sourceId, c, name) : '') + stopped + gaps +
|
|
11413
|
+
'</div>' +
|
|
11414
|
+
`<button type="button" class="kb-conn-sync" data-kb-conn-sync="${escapeAttr(s.sourceId)}" aria-label="Sync “${escapeAttr(name)}” now"${syncing ? ' aria-busy="true" disabled' : ''}` +
|
|
11415
|
+
` data-command-id="shell.kb-connected-sync#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}"` +
|
|
11416
|
+
` data-tip="${syncing ? 'Syncing…' : c && c.paused ? 'Paused. Sync now asks to resume it first' : `Sync now: read what changed in this ${kbConnThing(c)}`}"><span aria-hidden="true">⟳</span></button>` +
|
|
11417
|
+
`<button type="button" class="kb-toggle" role="switch" aria-checked="${on ? 'true' : 'false'}" data-kb-toggle ` +
|
|
11418
|
+
`aria-label="Use “${escapeAttr(name)}” as knowledge" data-command-id="shell.kb-category-row-toggle#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}" ` +
|
|
11419
|
+
`data-tip="${on ? 'Included in the knowledge base — click to exclude' : 'Excluded from the knowledge base — click to include'}"></button>` +
|
|
11420
|
+
`<button type="button" class="kb-cat-more kb-conn-more" data-kb-conn-menu="${escapeAttr(s.sourceId)}" aria-haspopup="menu" aria-label="More for “${escapeAttr(name)}”"` +
|
|
11421
|
+
` data-command-id="shell.kb-connected-menu#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}" data-tip="Sync, pause, remove or erase">⋯</button>` +
|
|
11422
|
+
'</div>';
|
|
11423
|
+
}
|
|
11424
|
+
|
|
11425
|
+
/** Below the reference list: removed sources whose messages are still stored, and what a copied project left out. */
|
|
11426
|
+
function kbConnExtrasHtml(st) {
|
|
11427
|
+
const conn = st.connected;
|
|
11428
|
+
if (!conn) return '';
|
|
11429
|
+
if (conn.unreadable) return '<div class="kb-conn-note" role="status">FloLess could not read the connected sources just now, so removed ones that still hold messages are not listed. Reopen Knowledge to try again.</div>';
|
|
11430
|
+
let html = '';
|
|
11431
|
+
const removed = Array.isArray(conn.removed) ? conn.removed : [];
|
|
11432
|
+
if (removed.length) {
|
|
11433
|
+
html += '<div class="kb-conn-removed"><h4 class="kb-uncategorized-head">Removed connected sources</h4>' +
|
|
11434
|
+
'<div class="kb-conn-note">What they synced stays stored until you erase it.</div>' +
|
|
11435
|
+
removed.map((r) => `<div class="kb-conn-removed-row"><span class="kb-fico conn" aria-hidden="true">${kbConnGlyph(r.scopeKind)}</span><span class="kb-conn-removed-name">${escapeHtml(r.label || kbConnKindName({ scope: r.scopeKind }))}` +
|
|
11436
|
+
`${r.erasePending ? '<span class="kb-conn-removed-why">Erase did not finish yet.</span>' : ''}</span>` +
|
|
11437
|
+
`<button type="button" class="kb-link danger" data-kb-conn-erase="${escapeAttr(r.sourceId)}" data-command-id="shell.kb-connected-erase#${escapeAttr(r.sourceId)}" data-command-instance-label="${escapeAttr(r.label || 'Teams chat')}">${r.erasePending ? 'Finish erasing…' : 'Erase…'}</button></div>`).join('') +
|
|
11438
|
+
'</div>';
|
|
11439
|
+
}
|
|
11440
|
+
const notice = conn.copyNotice;
|
|
11441
|
+
if (notice && notice.knowledgeOmitted) {
|
|
11442
|
+
html += '<div class="kb-conn-note kb-conn-copy">This copy’s knowledge was left out because FloLess could not confirm that connected chat messages were left out of it. Add the files again, or copy the project again.</div>';
|
|
11443
|
+
} else if (notice && notice.connectedLeftOut) {
|
|
11444
|
+
html += `<div class="kb-conn-note kb-conn-copy">${notice.connectedLeftOut} connected source${notice.connectedLeftOut === 1 ? ' was' : 's were'} not copied. Connect ${notice.connectedLeftOut === 1 ? 'it' : 'them'} again here.</div>`;
|
|
11445
|
+
}
|
|
11446
|
+
return html;
|
|
11447
|
+
}
|
|
11448
|
+
|
|
11449
|
+
async function kbConnSync(sourceId, opts = {}) {
|
|
11450
|
+
if (kbConnSyncing.has(sourceId)) return;
|
|
11451
|
+
kbConnSyncing.add(sourceId);
|
|
11452
|
+
const changing = kbConnChanging.get(sourceId);
|
|
11453
|
+
let changed = null;
|
|
11454
|
+
if (changing) { kbConnRepaint(); changed = await changing.catch(() => null); }
|
|
11455
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11456
|
+
const seen = changed ?? (c ? c.revision : null);
|
|
11457
|
+
kbConnStops.delete(sourceId);
|
|
11458
|
+
kbConnRepaint();
|
|
11459
|
+
try {
|
|
11460
|
+
const res = await api(kbConnUrl(`/${encodeURIComponent(sourceId)}/sync`), { method: 'POST',
|
|
11461
|
+
body: JSON.stringify({ ...opts, ...(seen !== null ? { revision: seen } : {}) }) });
|
|
11462
|
+
kbAnnounce(res.message || 'Synced.');
|
|
11463
|
+
} catch (err) {
|
|
11464
|
+
const body = (err && err.body) || {};
|
|
11465
|
+
kbConnStops.set(sourceId, { message: err.message, choices: kbConnKnownChoices(body.choices), target: body.target || null, opts });
|
|
11466
|
+
kbAnnounce(`Not synced. ${err.message}`);
|
|
11467
|
+
} finally {
|
|
11468
|
+
kbConnSyncing.delete(sourceId);
|
|
11469
|
+
kbInvalidateRefs();
|
|
11470
|
+
await renderKnowledge();
|
|
11471
|
+
}
|
|
11472
|
+
}
|
|
11473
|
+
|
|
11474
|
+
async function kbConnSetPaused(sourceId, paused) {
|
|
11475
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11476
|
+
try {
|
|
11477
|
+
await api(kbConnUrl(`/${encodeURIComponent(sourceId)}`), { method: 'PATCH', body: JSON.stringify({ paused, ...(c ? { revision: c.revision } : {}) }) });
|
|
11478
|
+
kbConnStops.delete(sourceId);
|
|
11479
|
+
kbAnnounce(paused ? 'Paused. It keeps what it synced.' : 'Resumed.');
|
|
11480
|
+
} catch (err) { const said = errorText(err, { action: paused ? 'pause this source' : 'resume this source' }); kbAnnounce(said); showToast(said, 'warn'); }
|
|
11481
|
+
kbInvalidateRefs();
|
|
11482
|
+
await renderKnowledge();
|
|
11483
|
+
}
|
|
11484
|
+
|
|
11485
|
+
function kbConnShowMenu(btn) {
|
|
11486
|
+
const id = btn.dataset.kbConnMenu;
|
|
11487
|
+
const c = kbConnOf(knowledgeState, id);
|
|
11488
|
+
const name = (c && c.label) || `this ${kbConnThing(c)}`;
|
|
11489
|
+
const pop = kbCatPop(btn,
|
|
11490
|
+
`<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-sync="${escapeAttr(id)}" data-command-id="shell.kb-connected-sync#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Sync now</button>` +
|
|
11491
|
+
`<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-pause="${escapeAttr(id)}" data-kb-conn-paused="${c && c.paused ? 'false' : 'true'}" data-command-id="shell.kb-connected-pause#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">${c && c.paused ? 'Resume syncing' : 'Pause syncing'}</button>` +
|
|
11492
|
+
(kbConnIsMail(c)
|
|
11493
|
+
? `<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-window-menu="${escapeAttr(id)}" data-command-id="shell.kb-connected-window-menu#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">${(c.outlook && c.outlook.windowDays || 90) !== 90 ? 'Change time window (use the last 90 days again)…' : 'Change time window…'}</button>` +
|
|
11494
|
+
`<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-reread="${escapeAttr(id)}" data-command-id="shell.kb-connected-reread#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Read every message again…</button>`
|
|
11495
|
+
: kbConnIsTrimble(c)
|
|
11496
|
+
? `<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-reread="${escapeAttr(id)}" data-command-id="shell.kb-connected-reread-topics#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Read every topic again…</button>`
|
|
11497
|
+
: '') +
|
|
11498
|
+
`<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-remove="${escapeAttr(id)}" data-command-id="shell.kb-connected-remove#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Remove…</button>` +
|
|
11499
|
+
'<div class="kb-ds-sep" role="separator"></div>' +
|
|
11500
|
+
`<button type="button" role="menuitem" class="kb-ds-mi danger" data-kb-conn-erase="${escapeAttr(id)}" data-command-id="shell.kb-connected-erase#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Erase…</button>`,
|
|
11501
|
+
`More for ${name}`, 'menu');
|
|
11502
|
+
const first = pop && pop.querySelector('.kb-ds-mi');
|
|
11503
|
+
if (first) first.focus();
|
|
11504
|
+
}
|
|
11505
|
+
|
|
11506
|
+
/** A themed dialog on the app's modal shell; resolves with the pressed action's id, or null for Cancel and Esc. */
|
|
11507
|
+
function kbConnDialog({ title, bodyHtml, actions, labelId, onOpen }) {
|
|
11508
|
+
return new Promise((resolve) => {
|
|
11509
|
+
const previous = document.activeElement;
|
|
11510
|
+
const backdrop = document.createElement('div');
|
|
11511
|
+
backdrop.className = 'modal-backdrop show kb-conn-dialog';
|
|
11512
|
+
backdrop.setAttribute('role', 'dialog');
|
|
11513
|
+
backdrop.setAttribute('aria-modal', 'true');
|
|
11514
|
+
backdrop.setAttribute('aria-labelledby', labelId);
|
|
11515
|
+
backdrop.innerHTML = `<div class="modal"><div class="modal-title" id="${labelId}">${escapeHtml(title)}</div><div class="kb-conn-dialog-body">${bodyHtml}</div>` +
|
|
11516
|
+
`<div class="modal-actions">${actions.map((a) => `<button type="button" class="${a.tone || ''}" data-kb-conn-act="${escapeAttr(a.id)}"${a.disabled ? ' disabled' : ''}${a.tip ? ` data-tip="${escapeAttr(a.tip)}"` : ''}>${escapeHtml(a.label)}</button>`).join('')}</div></div>`;
|
|
11517
|
+
// Each action's command id is an author-written literal at its call site; set through the DOM, it needs no escaping.
|
|
11518
|
+
backdrop.querySelectorAll('.modal-actions [data-kb-conn-act]').forEach((btn, n) => { btn.dataset.commandId = actions[n].commandId; });
|
|
11519
|
+
const finish = (value) => {
|
|
11520
|
+
backdrop.remove();
|
|
11521
|
+
document.removeEventListener('keydown', onKey, true);
|
|
11522
|
+
if (previous && previous.isConnected) previous.focus({ preventScroll: true });
|
|
11523
|
+
resolve(value);
|
|
11524
|
+
};
|
|
11525
|
+
const onKey = (e) => {
|
|
11526
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); finish(null); return; }
|
|
11527
|
+
if (e.key !== 'Tab') return;
|
|
11528
|
+
// Keep focus inside the dialog: an aria-modal dialog must not let Tab walk into the page behind it.
|
|
11529
|
+
const focusable = [...backdrop.querySelectorAll('button:not([disabled]):not([hidden]):not([tabindex="-1"]), input:not([disabled]), summary')];
|
|
11530
|
+
if (!focusable.length) return;
|
|
11531
|
+
const first = focusable[0], last = focusable[focusable.length - 1];
|
|
11532
|
+
if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
|
|
11533
|
+
else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
|
|
11534
|
+
};
|
|
11535
|
+
backdrop.addEventListener('click', (e) => {
|
|
11536
|
+
const act = e.target.closest('[data-kb-conn-act]');
|
|
11537
|
+
if (act) { finish(act.dataset.kbConnAct === 'cancel' ? null : { id: act.dataset.kbConnAct, form: backdrop }); return; }
|
|
11538
|
+
if (e.target === backdrop) finish(null);
|
|
11539
|
+
});
|
|
11540
|
+
// An action that waits for a choice in the body (Connect waits for a chat) turns on once one is made.
|
|
11541
|
+
backdrop.addEventListener('change', () => {
|
|
11542
|
+
for (const btn of backdrop.querySelectorAll('[data-kb-conn-act][disabled]')) {
|
|
11543
|
+
const needs = actions.find((a) => a.id === btn.dataset.kbConnAct)?.enabledWhen;
|
|
11544
|
+
if (needs && backdrop.querySelector(needs)) { btn.disabled = false; btn.removeAttribute('data-tip'); }
|
|
11545
|
+
}
|
|
11546
|
+
});
|
|
11547
|
+
document.addEventListener('keydown', onKey, true);
|
|
11548
|
+
document.body.append(backdrop);
|
|
11549
|
+
// A body that changes while open (the folder browser) wires itself here; it never resolves the dialog itself.
|
|
11550
|
+
if (onOpen) onOpen(backdrop);
|
|
11551
|
+
(backdrop.querySelector('[data-autofocus]') || backdrop.querySelector('[data-kb-conn-act="cancel"]'))?.focus();
|
|
11552
|
+
});
|
|
11553
|
+
}
|
|
11554
|
+
|
|
11555
|
+
/** The connect dialog's body: the account, the chats to choose from and how far back to read. */
|
|
11556
|
+
function kbConnPickerHtml(options) {
|
|
11557
|
+
const target = options.target || {};
|
|
11558
|
+
const chats = Array.isArray(options.chats) ? options.chats : [];
|
|
11559
|
+
const list = chats.length
|
|
11560
|
+
? `<div class="kb-conn-chats" role="radiogroup" aria-label="Teams chats">${chats.map((chat, n) =>
|
|
11561
|
+
`<label class="kb-conn-chat"><input type="radio" name="kb-conn-chat" value="${escapeAttr(chat.chatId)}" data-label="${escapeAttr(chat.label)}" data-command-id="shell.kb-connected-chat#${escapeAttr(chat.chatId)}" data-command-instance-label="${escapeAttr(chat.label)}"${chat.connected ? ' data-connected' : ''}${n === 0 ? ' data-autofocus' : ''}>` +
|
|
11562
|
+
`<span class="kb-conn-chat-name">${escapeHtml(chat.label)}</span><span class="kb-conn-chat-meta"${chat.connected ? ' data-tip="Already a source in this project. Choosing it syncs that source; it keeps its own time range."' : ''}>` +
|
|
11563
|
+
`${escapeHtml(chat.chatType === 'oneOnOne' ? 'one-on-one' : chat.chatType === 'meeting' ? 'meeting' : 'group')}${chat.connected ? ' · already connected' : ''}</span></label>`).join('')}</div>` +
|
|
11564
|
+
(options.more ? '<div class="kb-conn-note">Showing your 50 most recent chats.</div>' : '')
|
|
11565
|
+
: '<p class="kb-conn-p">This account has no Teams chats FloLess can read.</p>';
|
|
11566
|
+
const windows = [7, 30, 90].map((d) => `<label class="kb-conn-window"><input type="radio" name="kb-conn-window" value="${d}" data-command-id="shell.kb-connected-window#${escapeAttr(d)}" data-command-instance-label="${d} days"${d === 30 ? ' checked' : ''}><span>${d} days</span></label>`).join('');
|
|
11567
|
+
return `<div class="kb-conn-account">Account: <b>${escapeHtml(target.label || 'Microsoft 365 account')}</b> · the one chosen in Integrations ` +
|
|
11568
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Change</button></div>' +
|
|
11569
|
+
list +
|
|
11570
|
+
`<div class="kb-conn-field"><span class="kb-conn-field-label">Read messages from the last</span><div class="kb-conn-windows" role="radiogroup" aria-label="How far back">${windows}</div></div>` +
|
|
11571
|
+
'<ul class="kb-conn-warn">' +
|
|
11572
|
+
'<li>People’s messages are copied into this project’s knowledge and used the next time it is organized.</li>' +
|
|
11573
|
+
'<li>Each sync reads the 50 newest changes. For a busy chat, sync every day. Messages Teams delivers late may be missed.</li>' +
|
|
11574
|
+
'<li>A message can still mislead what Organize writes, so pages cite the messages they used.</li>' +
|
|
11575
|
+
'</ul>';
|
|
11576
|
+
}
|
|
11577
|
+
|
|
11578
|
+
/** Step 1 of Connect: which kind of source. Nothing is chosen for the person; Back in step 2 returns here. */
|
|
11579
|
+
async function kbConnOpenConnect() {
|
|
11580
|
+
for (;;) {
|
|
11581
|
+
const answer = await kbConnDialog({ title: 'Connect a source', labelId: 'kb-conn-title',
|
|
11582
|
+
bodyHtml: '<div class="kb-conn-kinds" role="radiogroup" aria-label="What to connect">' +
|
|
11583
|
+
[['teams-chat', 'Teams chat', 'Messages from one chat.'], ['outlook-folder', 'Outlook folder', 'Mail received in one folder.'],
|
|
11584
|
+
['trimble-project', 'Trimble Connect project', 'Topics (coordination issues), their comments and ToDos from one project.']].map(([v, label, line], n) =>
|
|
11585
|
+
`<label class="kb-conn-kind"><input type="radio" name="kb-conn-kind" value="${v}" data-command-id="shell.kb-connected-kind#${escapeAttr(v)}" data-command-instance-label="${label}"${n === 0 ? ' data-autofocus' : ''}>` +
|
|
11586
|
+
`<span><b>${label}</b>${line}</span></label>`).join('') + '</div>' +
|
|
11587
|
+
'<p class="kb-conn-p" data-kb-conn-kind-line>FloLess reads each source with the account you chose for that service in Integrations.</p>',
|
|
11588
|
+
onOpen: (box) => box.addEventListener('change', (e) => {
|
|
11589
|
+
if (e.target.name !== 'kb-conn-kind') return;
|
|
11590
|
+
const line = box.querySelector('[data-kb-conn-kind-line]');
|
|
11591
|
+
if (line) line.textContent = `FloLess reads it with the ${e.target.value === 'trimble-project' ? 'Trimble Connect' : 'Microsoft 365'} account chosen in Integrations.`;
|
|
11592
|
+
}),
|
|
11593
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11594
|
+
{ id: 'next', label: 'Next', tone: 'primary', commandId: 'shell.kb-connected-next', disabled: true, tip: 'Choose what to connect first',
|
|
11595
|
+
enabledWhen: 'input[name="kb-conn-kind"]:checked' }] });
|
|
11596
|
+
if (!answer || answer.id !== 'next') return;
|
|
11597
|
+
const kind = answer.form.querySelector('input[name="kb-conn-kind"]:checked')?.value;
|
|
11598
|
+
const result = kind === 'outlook-folder' ? await kbConnOpenOutlook() : kind === 'trimble-project' ? await kbConnOpenTrimble() : await kbConnOpenTeams();
|
|
11599
|
+
if (result !== 'back') return;
|
|
11600
|
+
}
|
|
11601
|
+
}
|
|
11602
|
+
|
|
11603
|
+
/** Change an Outlook source's window, take a partial copy, or read every message again: the person's own click, against
|
|
11604
|
+
* the revision this screen drew (a source that changed meanwhile is shown again instead). */
|
|
11605
|
+
async function kbConnSetMail(sourceId, change, done, revision) {
|
|
11606
|
+
// A Sync now clicked while this change or its reload is still out waits for it, and is sent against the revision the
|
|
11607
|
+
// change answered with: the reload may be superseded by a poll before it lands, so the row alone may still hold the old
|
|
11608
|
+
// one, and the sync would be answered "changed since you looked at it" (#3332 QA).
|
|
11609
|
+
const run = (async () => {
|
|
11610
|
+
let left = null;
|
|
11611
|
+
try {
|
|
11612
|
+
// `revision` is the source as the dialog or row the person acted on showed it, never one a refresh brought in since.
|
|
11613
|
+
const res = await api(kbConnUrl(`/${encodeURIComponent(sourceId)}`), { method: 'PATCH', body: JSON.stringify({ ...change, revision }) });
|
|
11614
|
+
if (res && typeof res.revision === 'string') left = res.revision;
|
|
11615
|
+
kbAnnounce(done);
|
|
11616
|
+
} catch (err) { const said = errorText(err, { action: 'change this source' }); kbAnnounce(said); showToast(said, 'warn'); }
|
|
11617
|
+
kbInvalidateRefs();
|
|
11618
|
+
await renderKnowledge();
|
|
11619
|
+
return left;
|
|
11620
|
+
})();
|
|
11621
|
+
kbConnChanging.set(sourceId, run);
|
|
11622
|
+
try { await run; } finally { if (kbConnChanging.get(sourceId) === run) kbConnChanging.delete(sourceId); }
|
|
11623
|
+
}
|
|
11624
|
+
|
|
11625
|
+
async function kbConnWindowDialog(sourceId) {
|
|
11626
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11627
|
+
if (!kbConnIsMail(c)) return;
|
|
11628
|
+
const now = (c.outlook && c.outlook.windowDays) || 90;
|
|
11629
|
+
const name = c.label || 'this folder';
|
|
11630
|
+
const seen = c.revision;
|
|
11631
|
+
const day = 86_400_000;
|
|
11632
|
+
const consequence = (d) => (d === now ? 'This is the window it keeps now.'
|
|
11633
|
+
: d < now ? `Mail received before ${new Date(Date.now() - d * day).toLocaleDateString()} will be removed from this copy at the next sync.`
|
|
11634
|
+
: 'FloLess reads the older mail over the next syncs, up to 50 messages each.');
|
|
11635
|
+
const answer = await kbConnDialog({ title: `Time window for “${name}”`, labelId: 'kb-conn-window-title',
|
|
11636
|
+
bodyHtml: `<div class="kb-conn-field" style="margin-top:0"><span class="kb-conn-field-label">Keep mail received in the last</span><div class="kb-conn-windows" role="radiogroup" aria-label="Time window">` +
|
|
11637
|
+
[90, 30, 7].map((d) => `<label class="kb-conn-window"><input type="radio" name="kb-conn-window" value="${d}" data-command-id="shell.kb-connected-window-choice#${escapeAttr(d)}" data-command-instance-label="${d} days"${d === now ? ' checked data-autofocus' : ''}><span>${d} days</span></label>`).join('') +
|
|
11638
|
+
`</div></div><p class="kb-conn-p" data-kb-conn-consequence role="status">${escapeHtml(consequence(now))}</p>`,
|
|
11639
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11640
|
+
{ id: 'apply', label: 'Change window', tone: 'primary', commandId: 'shell.kb-connected-window-go' }],
|
|
11641
|
+
onOpen: (box) => {
|
|
11642
|
+
const apply = box.querySelector('[data-kb-conn-act="apply"]');
|
|
11643
|
+
const sync = () => {
|
|
11644
|
+
const d = Number(box.querySelector('input[name="kb-conn-window"]:checked')?.value || now);
|
|
11645
|
+
box.querySelector('[data-kb-conn-consequence]').textContent = consequence(d);
|
|
11646
|
+
apply.hidden = d === now; // nothing to apply: the action is hidden, not disabled
|
|
11647
|
+
};
|
|
11648
|
+
box.addEventListener('change', sync);
|
|
11649
|
+
sync();
|
|
11650
|
+
} });
|
|
11651
|
+
if (!answer || answer.id !== 'apply') return;
|
|
11652
|
+
const d = Number(answer.form.querySelector('input[name="kb-conn-window"]:checked')?.value);
|
|
11653
|
+
if (d === 90 || d === 30 || d === 7) await kbConnSetMail(sourceId, { windowDays: d }, `“${name}” keeps the last ${d} days from the next sync.`, seen);
|
|
11654
|
+
}
|
|
11655
|
+
|
|
11656
|
+
async function kbConnRereadDialog(sourceId) {
|
|
11657
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11658
|
+
if (kbConnIsTrimble(c)) {
|
|
11659
|
+
const name = c.label || 'this project';
|
|
11660
|
+
const seen = c.revision;
|
|
11661
|
+
const answer = await kbConnDialog({ title: `Read every topic in “${name}” again?`, labelId: 'kb-conn-reread-title',
|
|
11662
|
+
bodyHtml: '<p class="kb-conn-p">FloLess reads every topic and its comments again, up to 50 per sync, so it can take many syncs. ' +
|
|
11663
|
+
'It also works out the size limit again, once. Use it when the copy looks wrong or topics are missing.</p>',
|
|
11664
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11665
|
+
{ id: 'reread', label: 'Read again', tone: 'primary', commandId: 'shell.kb-connected-reread-topics-go' }] });
|
|
11666
|
+
if (answer && answer.id === 'reread') await kbConnSetMail(sourceId, { reread: true }, `“${name}” is read again from the next sync, up to 50 topics each.`, seen);
|
|
11667
|
+
return;
|
|
11668
|
+
}
|
|
11669
|
+
if (!kbConnIsMail(c)) return;
|
|
11670
|
+
const name = c.label || 'this folder';
|
|
11671
|
+
const seen = c.revision;
|
|
11672
|
+
const answer = await kbConnDialog({ title: `Read every message in “${name}” again?`, labelId: 'kb-conn-reread-title',
|
|
11673
|
+
bodyHtml: '<p class="kb-conn-p">FloLess reads every message in the window again, up to 50 per sync, so it can take many syncs. ' +
|
|
11674
|
+
'Use it when a copy looks wrong or messages were left out.</p>',
|
|
11675
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11676
|
+
{ id: 'reread', label: 'Read again', tone: 'primary', commandId: 'shell.kb-connected-reread-go' }] });
|
|
11677
|
+
if (answer && answer.id === 'reread') await kbConnSetMail(sourceId, { reread: true }, `“${name}” is read again from the next sync, up to 50 messages each.`, seen);
|
|
11678
|
+
}
|
|
11679
|
+
|
|
11680
|
+
/** When the options cannot be listed: the reason, and the way on it names. */
|
|
11681
|
+
/** The dialog when the first list could not be read. Returns 'retry' when the person asked to try again. */
|
|
11682
|
+
async function kbConnOptionsFailed(err, title, library = 'microsoft-365') {
|
|
11683
|
+
const body = (err && err.body) || {};
|
|
11684
|
+
const choices = Array.isArray(body.choices) ? body.choices : [];
|
|
11685
|
+
const answer = await kbConnDialog({ title, labelId: 'kb-conn-title',
|
|
11686
|
+
bodyHtml: `<p class="kb-conn-p">${escapeHtml(errorText(err, { action: 'list what can be connected', retrySafe: true }))}</p>`,
|
|
11687
|
+
actions: [{ id: 'cancel', label: 'Close', commandId: 'shell.kb-connected-cancel' },
|
|
11688
|
+
...(choices.includes('retry') ? [{ id: 'retry', label: 'Try again', tone: 'primary', commandId: 'shell.kb-connected-options-retry' }] : []),
|
|
11689
|
+
...(choices.includes('open-integrations') ? [{ id: 'integrations', label: 'Open Integrations', tone: 'primary', commandId: 'shell.kb-connected-open-integrations' }] : []),
|
|
11690
|
+
...(choices.includes('open-tools') ? [{ id: 'tools', label: 'Open Tools', tone: 'primary', commandId: 'shell.kb-connected-open-tools' }] : [])] });
|
|
11691
|
+
if (answer && answer.id === 'integrations' && typeof openIntegrations === 'function') openIntegrations();
|
|
11692
|
+
if (answer && answer.id === 'tools' && typeof openLibrary === 'function') openLibrary(library, { tab: 'available' });
|
|
11693
|
+
return answer && answer.id === 'retry' ? 'retry' : null;
|
|
11694
|
+
}
|
|
11695
|
+
|
|
11696
|
+
const KB_CONN_ROOT = { id: 'msgfolderroot', label: 'Mailbox' };
|
|
11697
|
+
const kbConnFolderUrl = (parent, skip, target) => kbConnUrl(`/options?${new URLSearchParams({ kind: 'outlook-folder', parent, skip: String(skip),
|
|
11698
|
+
...(target && target.principal ? { expectedPrincipal: target.principal } : {}), ...(target && target.tenant ? { expectedTenant: target.tenant } : {}) })}`);
|
|
11699
|
+
|
|
11700
|
+
const kbConnProjectsUrl = (region, skip, target) => kbConnUrl(`/options?${new URLSearchParams({ kind: 'trimble-project', region, skip: String(skip),
|
|
11701
|
+
...(target && target.principal ? { expectedPrincipal: target.principal } : {}) })}`);
|
|
11702
|
+
const kbConnRegionEmpty = () => ({ projects: [], nextSkip: null, failed: null, omitted: 0, loading: true });
|
|
11703
|
+
|
|
11704
|
+
/** Step 2 for Trimble Connect (slice 2 plan §18 #5): every published region is asked for its first page, and the projects
|
|
11705
|
+
* are grouped by region; each region pages and retries on its own. A region with nothing to say is not shown. */
|
|
11706
|
+
async function kbConnOpenTrimble() {
|
|
11707
|
+
const proj = current;
|
|
11708
|
+
if (!proj) return null;
|
|
11709
|
+
// The first region verifies the account and says which regions exist; a stop here (not signed in) ends the dialog.
|
|
11710
|
+
let first;
|
|
11711
|
+
for (;;) {
|
|
11712
|
+
try { first = await api(kbConnProjectsUrl('europe', 0, null), { timeoutMs: 60_000 }); break; }
|
|
11713
|
+
catch (err) { if (await kbConnOptionsFailed(err, 'Connect a Trimble Connect project', 'trimble-connect') !== 'retry') return null; }
|
|
11714
|
+
}
|
|
11715
|
+
const view = { target: first.target, regions: {}, notice: null, picked: null };
|
|
11716
|
+
const order = KB_CONN_REGIONS.map(([r]) => r).filter((r) => (first.regions || []).includes(r));
|
|
11717
|
+
for (const r of order) view.regions[r] = kbConnRegionEmpty();
|
|
11718
|
+
const take = (r, res, append) => {
|
|
11719
|
+
const reg = view.regions[r];
|
|
11720
|
+
reg.loading = false;
|
|
11721
|
+
reg.failed = res.failed || null;
|
|
11722
|
+
reg.projects = append ? reg.projects.concat(res.projects || []) : (res.projects || []);
|
|
11723
|
+
reg.nextSkip = res.nextSkip == null ? null : res.nextSkip;
|
|
11724
|
+
reg.omitted = (append ? reg.omitted : 0) + (res.omitted || 0);
|
|
11725
|
+
};
|
|
11726
|
+
if (view.regions.europe) take('europe', first, false);
|
|
11727
|
+
const shown = () => order.filter((r) => { const g = view.regions[r]; return g.projects.length || g.failed || g.loading; });
|
|
11728
|
+
const picker = () => {
|
|
11729
|
+
if (view.notice) {
|
|
11730
|
+
return `<div class="kb-conn-stop" role="alert"><b>${escapeHtml(view.notice.title)}</b> ${escapeHtml(view.notice.text)}` +
|
|
11731
|
+
'<div class="kb-conn-choices"><button type="button" class="kb-link kb-conn-primary" data-kb-conn-restart data-command-id="shell.kb-connected-restart">Start again</button></div></div>';
|
|
11732
|
+
}
|
|
11733
|
+
const regions = shown();
|
|
11734
|
+
const loading = order.some((r) => view.regions[r].loading);
|
|
11735
|
+
if (!order.length) {
|
|
11736
|
+
// No region was asked: an AWARE that publishes none FloLess knows is not "no projects".
|
|
11737
|
+
return '<p class="kb-conn-p">The installed AWARE lists no Trimble Connect region FloLess can read, so no region was asked for projects. Update AWARE when FloLess offers it.</p>';
|
|
11738
|
+
}
|
|
11739
|
+
if (!regions.length) {
|
|
11740
|
+
return '<p class="kb-conn-p">No Trimble Connect projects found for this account in any region. ' +
|
|
11741
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Check the account in Integrations</button></p>';
|
|
11742
|
+
}
|
|
11743
|
+
// One region with projects and nothing else to say needs no heading: a lone heading is noise.
|
|
11744
|
+
const headed = !(regions.length === 1 && !loading && !view.regions[regions[0]].failed);
|
|
11745
|
+
const block = (r) => {
|
|
11746
|
+
const g = view.regions[r];
|
|
11747
|
+
const name = kbConnRegionName(r);
|
|
11748
|
+
const rows = g.projects.map((p) => `<label class="kb-conn-chat"><input type="radio" name="kb-conn-project" value="${escapeAttr(p.projectId)}" data-region="${escapeAttr(r)}" data-label="${escapeAttr(p.label)}"` +
|
|
11749
|
+
`${p.connected ? ' data-connected' : ''}${view.picked === `${r}:${p.projectId}` ? ' checked' : ''} data-command-id="shell.kb-connected-project#${escapeAttr(`${r}:${p.projectId}`)}" data-command-instance-label="${escapeAttr(p.label)}">` +
|
|
11750
|
+
`<span class="kb-conn-chat-name" data-tip="${escapeAttr(p.label)}">${escapeHtml(p.label)}</span>` +
|
|
11751
|
+
`<span class="kb-conn-chat-meta"${p.connected ? ' data-tip="Already a source in this project. Choosing it syncs that source."' : ''}>${p.connected ? 'already connected' : ''}</span></label>`).join('');
|
|
11752
|
+
const busy = g.loading ? ' aria-busy="true" disabled' : '';
|
|
11753
|
+
const tail = (g.failed ? `<div class="kb-conn-note">${escapeHtml(g.failed)} <button type="button" class="kb-link" data-kb-conn-region-retry="${escapeAttr(r)}"${busy} data-command-id="shell.kb-connected-region-retry#${escapeAttr(r)}" data-command-instance-label="${escapeAttr(name)}">${g.loading ? 'Loading…' : 'Retry'}</button></div>` : '') +
|
|
11754
|
+
(g.nextSkip != null ? `<button type="button" class="kb-link kb-conn-more-folders" data-kb-conn-region-more="${escapeAttr(r)}"${busy} data-command-id="shell.kb-connected-region-more#${escapeAttr(r)}" data-command-instance-label="${escapeAttr(name)}">${g.loading ? 'Loading…' : 'Show more projects'}</button>` : '') +
|
|
11755
|
+
(g.omitted > 0 ? `<div class="kb-conn-note">${escapeHtml(kbConnPlural(g.omitted, 'project', 'projects'))} could not be listed by Trimble and ${g.omitted === 1 ? 'is' : 'are'} not shown.</div>` : '') +
|
|
11756
|
+
(g.loading && !g.failed && !g.projects.length ? '<div class="kb-conn-note">Loading…</div>' : '');
|
|
11757
|
+
return `<div class="kb-conn-region" role="group" aria-label="${escapeAttr(name)}">${headed ? `<h4 class="kb-uncategorized-head kb-conn-region-head">${escapeHtml(name)}</h4>` : ''}${rows}${tail}</div>`;
|
|
11758
|
+
};
|
|
11759
|
+
return `<div class="kb-conn-chats kb-conn-regions" role="radiogroup" aria-label="Trimble Connect projects"${loading ? ' aria-busy="true"' : ''}>${regions.map(block).join('')}</div>` +
|
|
11760
|
+
(loading ? '<div class="kb-conn-note" role="status">Looking in every Trimble region…</div>' : '');
|
|
11761
|
+
};
|
|
11762
|
+
const answer = await kbConnDialog({ title: 'Connect a Trimble Connect project', labelId: 'kb-conn-title',
|
|
11763
|
+
bodyHtml: `<div class="kb-conn-account">Account: <b>${escapeHtml(view.target.label || 'Trimble Connect account')}</b> · the one chosen in Integrations ` +
|
|
11764
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Change</button></div>' +
|
|
11765
|
+
`<div data-kb-conn-picker>${picker()}</div>` +
|
|
11766
|
+
'<ul class="kb-conn-warn">' +
|
|
11767
|
+
'<li>The project’s topics (coordination issues), their comments and its ToDos are copied into this project’s knowledge as text and used the next time it is organized.</li>' +
|
|
11768
|
+
`<li>${escapeHtml(KB_CONN_TRIMBLE_NOT_INCLUDED)}</li>` +
|
|
11769
|
+
'<li>Anyone in the Trimble project can write a topic or a comment, and it can mislead what Organize writes, so pages cite what they used.</li>' +
|
|
11770
|
+
'</ul>' +
|
|
11771
|
+
'<details class="kb-conn-gaps"><summary data-command-id="shell.kb-connected-more-about">More about what is copied</summary><ul>' +
|
|
11772
|
+
'<li>Closed topics stay in the copy, with their status.</li>' +
|
|
11773
|
+
'<li>Each sync reads at most 50 topics, so a large project takes several syncs at first.</li>' +
|
|
11774
|
+
'<li>The newest 200 comments of a topic are kept; the topic says how many older ones are not.</li>' +
|
|
11775
|
+
'<li>A project with more than 5,000 topics or ToDos is kept as a partial copy, and the row says so.</li>' +
|
|
11776
|
+
'<li>A topic Trimble stops listing leaves after two syncs, and the page says so.</li>' +
|
|
11777
|
+
'</ul></details>',
|
|
11778
|
+
actions: [{ id: 'back', label: 'Back', commandId: 'shell.kb-connected-back' }, { id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11779
|
+
{ id: 'connect', label: 'Connect and sync', tone: 'primary', commandId: 'shell.kb-connected-connect', disabled: true, tip: 'Choose a project first' }],
|
|
11780
|
+
onOpen: (box) => {
|
|
11781
|
+
const host = box.querySelector('[data-kb-conn-picker]');
|
|
11782
|
+
const connect = box.querySelector('.modal-actions [data-kb-conn-act="connect"]');
|
|
11783
|
+
// A repaint keeps focus on the same project, Show more or Retry (by what it stands for, not by node).
|
|
11784
|
+
const keyOf = (el) => (!el || !el.dataset ? null : el.name === 'kb-conn-project' ? `p:${el.dataset.region}:${el.value}`
|
|
11785
|
+
: el.dataset.kbConnRegionMore ? `m:${el.dataset.kbConnRegionMore}` : el.dataset.kbConnRegionRetry ? `r:${el.dataset.kbConnRegionRetry}` : null);
|
|
11786
|
+
const paint = () => {
|
|
11787
|
+
const focused = document.activeElement && host.contains(document.activeElement) ? keyOf(document.activeElement) : null;
|
|
11788
|
+
host.innerHTML = picker();
|
|
11789
|
+
// A choice whose radio is no longer drawn is no choice: Connect never sends a project the person cannot see.
|
|
11790
|
+
if (view.picked && ![...host.querySelectorAll('input[name="kb-conn-project"]')].some((el) => `${el.dataset.region}:${el.value}` === view.picked)) view.picked = null;
|
|
11791
|
+
const ok = !!view.picked && !view.notice;
|
|
11792
|
+
connect.disabled = !ok;
|
|
11793
|
+
if (ok) connect.removeAttribute('data-tip'); else connect.dataset.tip = 'Choose a project first';
|
|
11794
|
+
if (focused) {
|
|
11795
|
+
const back = [...host.querySelectorAll('input[name="kb-conn-project"], [data-kb-conn-region-more], [data-kb-conn-region-retry]')].find((el) => keyOf(el) === focused);
|
|
11796
|
+
(back && !back.disabled ? back : host.querySelector('input[name="kb-conn-project"]'))?.focus();
|
|
11797
|
+
}
|
|
11798
|
+
};
|
|
11799
|
+
let epoch = 0; // Start again drops every answer that was still on its way
|
|
11800
|
+
const load = async (r, append) => {
|
|
11801
|
+
if (view.notice || !view.regions[r]) return;
|
|
11802
|
+
const mine = epoch;
|
|
11803
|
+
try {
|
|
11804
|
+
view.regions[r].loading = true;
|
|
11805
|
+
paint();
|
|
11806
|
+
let res;
|
|
11807
|
+
try { res = await api(kbConnProjectsUrl(r, append ? view.regions[r].nextSkip : 0, view.target), { timeoutMs: 60_000 }); }
|
|
11808
|
+
catch (err) {
|
|
11809
|
+
// The server's own sentence when it wrote one; a network failure or a timeout in plain words, never raw (errorText).
|
|
11810
|
+
res = { failed: errorText(err, { action: `list your ${kbConnRegionName(r)} projects`, retrySafe: true }), projects: [] };
|
|
11811
|
+
}
|
|
11812
|
+
if (mine !== epoch || view.notice || !box.isConnected) return;
|
|
11813
|
+
settle(r, res, append);
|
|
11814
|
+
} catch (err) {
|
|
11815
|
+
// Anything else leaves the region answerable, never stuck on Loading.
|
|
11816
|
+
console.warn('kb-conn: a Trimble region could not be drawn', err);
|
|
11817
|
+
if (mine !== epoch || !box.isConnected || !view.regions[r]) return;
|
|
11818
|
+
view.regions[r].loading = false;
|
|
11819
|
+
view.regions[r].failed = 'FloLess could not show this region. Retry in a moment.';
|
|
11820
|
+
paint();
|
|
11821
|
+
}
|
|
11822
|
+
};
|
|
11823
|
+
const settle = (r, res, append) => {
|
|
11824
|
+
if (res.targetChanged) {
|
|
11825
|
+
view.notice = { title: 'The Trimble Connect account changed while this was open.', text: 'The projects shown may belong to the other account, so start again.' };
|
|
11826
|
+
view.target = res.target || view.target;
|
|
11827
|
+
view.picked = null;
|
|
11828
|
+
box.querySelector('.kb-conn-account b').textContent = view.target.label || 'Trimble Connect account';
|
|
11829
|
+
paint();
|
|
11830
|
+
return;
|
|
11831
|
+
}
|
|
11832
|
+
take(r, res, append);
|
|
11833
|
+
paint();
|
|
11834
|
+
};
|
|
11835
|
+
host.addEventListener('change', (e) => {
|
|
11836
|
+
if (e.target.name !== 'kb-conn-project') return;
|
|
11837
|
+
view.picked = `${e.target.dataset.region}:${e.target.value}`;
|
|
11838
|
+
connect.disabled = false;
|
|
11839
|
+
connect.removeAttribute('data-tip');
|
|
11840
|
+
});
|
|
11841
|
+
host.addEventListener('click', (e) => {
|
|
11842
|
+
const more = e.target.closest('[data-kb-conn-region-more]');
|
|
11843
|
+
if (more) { void load(more.dataset.kbConnRegionMore, true); return; }
|
|
11844
|
+
const retry = e.target.closest('[data-kb-conn-region-retry]');
|
|
11845
|
+
if (retry) { void load(retry.dataset.kbConnRegionRetry, false); return; }
|
|
11846
|
+
if (e.target.closest('[data-kb-conn-restart]')) {
|
|
11847
|
+
epoch += 1;
|
|
11848
|
+
view.notice = null;
|
|
11849
|
+
view.picked = null;
|
|
11850
|
+
for (const r of order) view.regions[r] = kbConnRegionEmpty();
|
|
11851
|
+
paint();
|
|
11852
|
+
for (const r of order) void load(r, false);
|
|
11853
|
+
}
|
|
11854
|
+
});
|
|
11855
|
+
for (const r of order) if (r !== 'europe') void load(r, false);
|
|
11856
|
+
} });
|
|
11857
|
+
if (answer && answer.id === 'back') return 'back';
|
|
11858
|
+
if (answer && answer.id === 'integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return null; }
|
|
11859
|
+
if (!answer || answer.id !== 'connect' || !current || current.id !== proj.id) return null;
|
|
11860
|
+
const picked = answer.form.querySelector('input[name="kb-conn-project"]:checked');
|
|
11861
|
+
if (!picked) return null;
|
|
11862
|
+
try {
|
|
11863
|
+
const res = await api(kbConnUrl(''), { method: 'POST', body: JSON.stringify({ kind: 'trimble-project', projectId: picked.value, region: picked.dataset.region,
|
|
11864
|
+
label: picked.dataset.label, expected: view.target }) });
|
|
11865
|
+
kbAnnounce(picked.hasAttribute('data-connected') ? `“${picked.dataset.label}” is already connected. Syncing it…` : `Connected “${picked.dataset.label}”. Syncing…`);
|
|
11866
|
+
await renderKnowledge();
|
|
11867
|
+
if (res.source && res.source.sourceId) await kbConnSync(res.source.sourceId);
|
|
11868
|
+
} catch (err) {
|
|
11869
|
+
const said = errorText(err, { action: 'connect that project' });
|
|
11870
|
+
kbAnnounce(said);
|
|
11871
|
+
showToast(said, 'warn');
|
|
11872
|
+
await renderKnowledge();
|
|
11873
|
+
}
|
|
11874
|
+
return null;
|
|
11875
|
+
}
|
|
11876
|
+
|
|
11877
|
+
/** Step 2 for Outlook: one level of folders at a time. Only the chosen folder is connected, never its subfolders. */
|
|
11878
|
+
async function kbConnOpenOutlook() {
|
|
11879
|
+
const proj = current;
|
|
11880
|
+
if (!proj) return null;
|
|
11881
|
+
let first;
|
|
11882
|
+
for (;;) {
|
|
11883
|
+
try { first = await api(kbConnFolderUrl('msgfolderroot', 0, null), { timeoutMs: 60_000 }); break; }
|
|
11884
|
+
catch (err) { if (await kbConnOptionsFailed(err, 'Connect an Outlook folder') !== 'retry') return null; }
|
|
11885
|
+
}
|
|
11886
|
+
const view = { target: first.target, path: [KB_CONN_ROOT], page: first, folders: first.folders || [], notice: null, loading: false };
|
|
11887
|
+
const browser = () => {
|
|
11888
|
+
const level = view.path[view.path.length - 1];
|
|
11889
|
+
const crumbs = view.path.map((p, i) => (i === view.path.length - 1
|
|
11890
|
+
? `<span aria-current="location" data-tip="${escapeAttr(p.label)}">${escapeHtml(p.label)}</span>`
|
|
11891
|
+
: `<button type="button" class="kb-link" data-kb-conn-crumb="${i}" data-tip="${escapeAttr(p.label)}" data-command-id="shell.kb-connected-crumb#${escapeAttr(i)}" data-command-instance-label="${escapeAttr(p.label)}">${escapeHtml(p.label)}</button>`))
|
|
11892
|
+
.join('<span class="kb-conn-crumb-sep" aria-hidden="true">›</span>');
|
|
11893
|
+
if (view.notice) {
|
|
11894
|
+
return `<nav class="kb-conn-crumbs" aria-label="Folder path">${crumbs}</nav><div class="kb-conn-stop" role="alert"><b>${escapeHtml(view.notice.title)}</b> ${escapeHtml(view.notice.text)}` +
|
|
11895
|
+
`<div class="kb-conn-choices"><button type="button" class="kb-link kb-conn-primary" data-kb-conn-restart data-command-id="shell.kb-connected-restart">${escapeHtml(view.notice.button)}</button></div></div>`;
|
|
11896
|
+
}
|
|
11897
|
+
const checked = view.picked;
|
|
11898
|
+
const row = (f, isThis) => {
|
|
11899
|
+
const meta = isThis ? 'this folder itself'
|
|
11900
|
+
: [kbConnPlural(f.totalCount, 'mail', 'mails'), f.childCount ? kbConnPlural(f.childCount, 'subfolder', 'subfolders') : '', f.connected ? 'already connected' : ''].filter(Boolean).join(' · ');
|
|
11901
|
+
const open = !isThis && f.childCount > 0
|
|
11902
|
+
? `<button type="button" class="kb-link kb-conn-folder-open" data-kb-conn-open="${escapeAttr(f.folderId)}" data-label="${escapeAttr(f.label)}" tabindex="${checked === f.folderId ? '0' : '-1'}"` +
|
|
11903
|
+
` aria-label="Open subfolders of ${escapeAttr(f.label)}" data-tip="Browse inside this folder. Only the folder you choose is connected, not its subfolders."` +
|
|
11904
|
+
` data-command-id="shell.kb-connected-folder-open#${escapeAttr(f.folderId)}" data-command-instance-label="${escapeAttr(f.label)}">Open subfolders ›</button>` : '';
|
|
11905
|
+
return `<div class="kb-conn-folder${isThis ? ' this' : ''}"><label class="kb-conn-chat"><input type="radio" name="kb-conn-folder" value="${escapeAttr(f.folderId)}" data-label="${escapeAttr(f.label)}"` +
|
|
11906
|
+
`${f.connected ? ' data-connected' : ''}${checked === f.folderId ? ' checked' : ''}${view.loading ? ' disabled' : ''} data-command-id="shell.kb-connected-folder#${escapeAttr(f.folderId)}" data-command-instance-label="${escapeAttr(f.label)}">` +
|
|
11907
|
+
`<span class="kb-conn-chat-name" data-tip="${escapeAttr(f.label)}">${escapeHtml(isThis ? `This folder (${f.label})` : f.label)}</span>` +
|
|
11908
|
+
`<span class="kb-conn-chat-meta"${f.connected ? ' data-tip="Already a source in this project. Choosing it syncs that source."' : ''}>${escapeHtml(meta)}</span></label>${open}</div>`;
|
|
11909
|
+
};
|
|
11910
|
+
const here = level.id === 'msgfolderroot' ? '' : row({ folderId: level.id, label: level.label, totalCount: 0, childCount: 0 }, true);
|
|
11911
|
+
const list = view.folders.length || here
|
|
11912
|
+
? `<div class="kb-conn-folders" role="radiogroup" aria-label="Outlook folders in ${escapeAttr(level.label)}"${view.loading ? ' aria-busy="true"' : ''}>${here}${view.folders.map((f) => row(f, false)).join('')}` +
|
|
11913
|
+
(view.folders.length ? '' : '<div class="kb-conn-note" style="padding:4px 8px">No subfolders here. Choose this folder, or go back.</div>') + '</div>'
|
|
11914
|
+
: `<p class="kb-conn-p">${level.id === 'msgfolderroot' ? 'This account has no mail folders FloLess can read.' : 'No subfolders here.'}</p>`;
|
|
11915
|
+
const notes = [view.page.omitted > 0 ? `${kbConnPlural(view.page.omitted, 'folder', 'folders')} could not be listed by Outlook and ${view.page.omitted === 1 ? 'is' : 'are'} not shown.` : '',
|
|
11916
|
+
view.page.limitReached ? 'Outlook stopped listing here, so more folders may exist. Open a parent folder to narrow it down.' : ''].filter(Boolean);
|
|
11917
|
+
return `<nav class="kb-conn-crumbs" aria-label="Folder path">${crumbs}</nav>${list}` +
|
|
11918
|
+
(view.page.nextSkip != null ? `<button type="button" class="kb-link kb-conn-more-folders" data-kb-conn-more${view.loading ? ' aria-busy="true"' : ''} data-command-id="shell.kb-connected-more-folders">${view.loading ? 'Loading…' : 'Show more folders'}</button>` : '') +
|
|
11919
|
+
notes.map((n) => `<div class="kb-conn-note">${escapeHtml(n)}</div>`).join('') +
|
|
11920
|
+
(view.loading ? '<div class="kb-sr" role="status">Loading folders…</div>' : '');
|
|
11921
|
+
};
|
|
11922
|
+
const answer = await kbConnDialog({ title: 'Connect an Outlook folder', labelId: 'kb-conn-title',
|
|
11923
|
+
bodyHtml: `<div class="kb-conn-account">Account: <b>${escapeHtml(view.target.label || 'Microsoft 365 account')}</b> · the one chosen in Integrations ` +
|
|
11924
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Change</button></div>' +
|
|
11925
|
+
`<div data-kb-conn-browser>${browser()}</div>` +
|
|
11926
|
+
'<p class="kb-conn-fixed">FloLess keeps the mail received in the last 90 days, and older mail drops off as the window moves.</p>' +
|
|
11927
|
+
'<ul class="kb-conn-warn">' +
|
|
11928
|
+
'<li>Mail in this folder is copied into this project’s knowledge and used the next time it is organized.</li>' +
|
|
11929
|
+
'<li>Anyone can send you a mail, and a mail can mislead what Organize writes, so pages cite the mail they used.</li>' +
|
|
11930
|
+
'<li>A folder with more than 100,000 mails in 90 days asks you to keep a shorter window or a partial copy.</li>' +
|
|
11931
|
+
'</ul>' +
|
|
11932
|
+
'<details class="kb-conn-gaps"><summary data-command-id="shell.kb-connected-more-about">More about what is copied</summary><ul>' +
|
|
11933
|
+
'<li>Attachments are listed by name only.</li>' +
|
|
11934
|
+
'<li>Mail deleted in Outlook leaves this copy at the next sync.</li>' +
|
|
11935
|
+
'<li>Mail Outlook stops listing leaves after two syncs, and the page says so.</li>' +
|
|
11936
|
+
'<li>Each sync reads at most 50 messages; drafts and undated mail are left out.</li>' +
|
|
11937
|
+
'</ul></details>',
|
|
11938
|
+
actions: [{ id: 'back', label: 'Back', commandId: 'shell.kb-connected-back' }, { id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11939
|
+
{ id: 'connect', label: 'Connect and sync', tone: 'primary', commandId: 'shell.kb-connected-connect', disabled: true, tip: 'Choose a folder first' }],
|
|
11940
|
+
onOpen: (box) => {
|
|
11941
|
+
const host = box.querySelector('[data-kb-conn-browser]');
|
|
11942
|
+
const connect = box.querySelector('[data-kb-conn-act="connect"]');
|
|
11943
|
+
const paint = (focusFirst) => {
|
|
11944
|
+
host.innerHTML = browser();
|
|
11945
|
+
const ok = !!view.picked && !view.notice && !view.loading;
|
|
11946
|
+
connect.disabled = !ok;
|
|
11947
|
+
if (ok) connect.removeAttribute('data-tip'); else connect.dataset.tip = 'Choose a folder first';
|
|
11948
|
+
if (focusFirst) host.querySelector('input[name="kb-conn-folder"]')?.focus();
|
|
11949
|
+
};
|
|
11950
|
+
const load = async (path, append) => {
|
|
11951
|
+
if (view.loading) return;
|
|
11952
|
+
const level = path[path.length - 1];
|
|
11953
|
+
view.loading = true;
|
|
11954
|
+
paint(false);
|
|
11955
|
+
let res;
|
|
11956
|
+
try { res = await api(kbConnFolderUrl(level.id, append ? view.page.nextSkip : 0, view.target), { timeoutMs: 60_000 }); }
|
|
11957
|
+
catch (err) {
|
|
11958
|
+
view.loading = false;
|
|
11959
|
+
view.notice = { title: 'Folders not listed.', text: err.message, button: 'Start again from the mailbox' };
|
|
11960
|
+
paint(false);
|
|
11961
|
+
return;
|
|
11962
|
+
}
|
|
11963
|
+
view.loading = false;
|
|
11964
|
+
if (res.targetChanged) {
|
|
11965
|
+
view.target = res.target;
|
|
11966
|
+
// The listed folders and the path belong to the other account: none of them may stay selectable.
|
|
11967
|
+
view.picked = null;
|
|
11968
|
+
view.path = [KB_CONN_ROOT];
|
|
11969
|
+
view.folders = [];
|
|
11970
|
+
view.page = { nextSkip: null, omitted: 0, limitReached: false };
|
|
11971
|
+
view.notice = { title: 'The Microsoft 365 account changed while this was open.', text: 'The folders shown may belong to the other account, so start again.', button: 'Start again' };
|
|
11972
|
+
box.querySelector('.kb-conn-account b').textContent = res.target.label || 'Microsoft 365 account';
|
|
11973
|
+
paint(false);
|
|
11974
|
+
return;
|
|
11975
|
+
}
|
|
11976
|
+
// A level that listed replaces any earlier failure; the account-change reset never reaches here (code review R2 #3).
|
|
11977
|
+
view.notice = null;
|
|
11978
|
+
view.path = path;
|
|
11979
|
+
view.page = res;
|
|
11980
|
+
view.folders = append ? view.folders.concat(res.folders || []) : (res.folders || []);
|
|
11981
|
+
if (!append) view.picked = null;
|
|
11982
|
+
paint(!append);
|
|
11983
|
+
if (!append) kbAnnounce(`${level.label}: ${kbConnPlural(view.folders.length, 'folder', 'folders')}.`);
|
|
11984
|
+
};
|
|
11985
|
+
host.addEventListener('change', (e) => {
|
|
11986
|
+
if (e.target.name !== 'kb-conn-folder' || view.loading) return;
|
|
11987
|
+
view.picked = e.target.value;
|
|
11988
|
+
// Roving Tab stop: only the chosen row's Open subfolders button is in the Tab order.
|
|
11989
|
+
host.querySelectorAll('[data-kb-conn-open]').forEach((b) => { b.tabIndex = b.dataset.kbConnOpen === view.picked ? 0 : -1; });
|
|
11990
|
+
connect.disabled = false;
|
|
11991
|
+
connect.removeAttribute('data-tip');
|
|
11992
|
+
});
|
|
11993
|
+
host.addEventListener('click', (e) => {
|
|
11994
|
+
const open = e.target.closest('[data-kb-conn-open]');
|
|
11995
|
+
if (open) { e.preventDefault(); void load([...view.path, { id: open.dataset.kbConnOpen, label: open.dataset.label }], false); return; }
|
|
11996
|
+
const crumb = e.target.closest('[data-kb-conn-crumb]');
|
|
11997
|
+
if (crumb) { void load(view.path.slice(0, Number(crumb.dataset.kbConnCrumb) + 1), false); return; }
|
|
11998
|
+
if (e.target.closest('[data-kb-conn-more]')) { void load(view.path, true); return; }
|
|
11999
|
+
if (e.target.closest('[data-kb-conn-restart]')) {
|
|
12000
|
+
view.notice = null;
|
|
12001
|
+
view.picked = null;
|
|
12002
|
+
view.path = [KB_CONN_ROOT];
|
|
12003
|
+
view.folders = [];
|
|
12004
|
+
view.page = { nextSkip: null, omitted: 0, limitReached: false };
|
|
12005
|
+
void load([KB_CONN_ROOT], false);
|
|
12006
|
+
}
|
|
12007
|
+
});
|
|
12008
|
+
} });
|
|
12009
|
+
if (answer && answer.id === 'back') return 'back';
|
|
12010
|
+
if (answer && answer.id === 'integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return null; }
|
|
12011
|
+
if (!answer || answer.id !== 'connect' || !current || current.id !== proj.id) return null;
|
|
12012
|
+
const picked = answer.form.querySelector('input[name="kb-conn-folder"]:checked');
|
|
12013
|
+
if (!picked) return null;
|
|
12014
|
+
try {
|
|
12015
|
+
const res = await api(kbConnUrl(''), { method: 'POST', body: JSON.stringify({ kind: 'outlook-folder', folderId: picked.value, label: picked.dataset.label, expected: view.target }) });
|
|
12016
|
+
kbAnnounce(picked.hasAttribute('data-connected') ? `“${picked.dataset.label}” is already connected. Syncing it…` : `Connected “${picked.dataset.label}”. Syncing…`);
|
|
12017
|
+
await renderKnowledge();
|
|
12018
|
+
if (res.source && res.source.sourceId) await kbConnSync(res.source.sourceId);
|
|
12019
|
+
} catch (err) {
|
|
12020
|
+
const said = errorText(err, { action: 'connect that folder' });
|
|
12021
|
+
kbAnnounce(said);
|
|
12022
|
+
showToast(said, 'warn');
|
|
12023
|
+
await renderKnowledge();
|
|
12024
|
+
}
|
|
12025
|
+
return null;
|
|
12026
|
+
}
|
|
12027
|
+
|
|
12028
|
+
async function kbConnOpenTeams() {
|
|
12029
|
+
const proj = current;
|
|
12030
|
+
if (!proj) return null;
|
|
12031
|
+
let options;
|
|
12032
|
+
for (;;) {
|
|
12033
|
+
try { options = await api(kbConnUrl('/options'), { timeoutMs: 60_000 }); break; }
|
|
12034
|
+
catch (err) { if (await kbConnOptionsFailed(err, 'Connect a Teams chat') !== 'retry') return null; }
|
|
12035
|
+
}
|
|
12036
|
+
const target = options.target;
|
|
12037
|
+
const chats = Array.isArray(options.chats) ? options.chats : [];
|
|
12038
|
+
const answer = await kbConnDialog({ title: 'Connect a Teams chat', labelId: 'kb-conn-title',
|
|
12039
|
+
bodyHtml: kbConnPickerHtml(options),
|
|
12040
|
+
// No chat is picked for the person: connecting copies people's messages, so the chat is always their own choice.
|
|
12041
|
+
actions: [{ id: 'back', label: 'Back', commandId: 'shell.kb-connected-back' }, { id: 'cancel', label: chats.length ? 'Cancel' : 'Close', commandId: 'shell.kb-connected-cancel' },
|
|
12042
|
+
...(chats.length ? [{ id: 'connect', label: 'Connect and sync', tone: 'primary', commandId: 'shell.kb-connected-connect',
|
|
12043
|
+
disabled: true, tip: 'Choose a chat first', enabledWhen: 'input[name="kb-conn-chat"]:checked' }] : [])] });
|
|
12044
|
+
if (answer && answer.id === 'back') return 'back';
|
|
12045
|
+
if (answer && answer.id === 'integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return null; }
|
|
12046
|
+
if (!answer || answer.id !== 'connect' || !current || current.id !== proj.id) return null;
|
|
12047
|
+
const picked = answer.form.querySelector('input[name="kb-conn-chat"]:checked');
|
|
12048
|
+
const windowDays = Number(answer.form.querySelector('input[name="kb-conn-window"]:checked')?.value || 30);
|
|
12049
|
+
if (!picked) return;
|
|
12050
|
+
try {
|
|
12051
|
+
const res = await api(kbConnUrl(''), { method: 'POST', body: JSON.stringify({ chatId: picked.value, label: picked.dataset.label, windowDays, expected: target }) });
|
|
12052
|
+
kbAnnounce(picked.hasAttribute('data-connected')
|
|
12053
|
+
? `“${picked.dataset.label}” is already connected. Syncing it…` : `Connected “${picked.dataset.label}”. Syncing…`);
|
|
12054
|
+
await renderKnowledge();
|
|
12055
|
+
if (res.source && res.source.sourceId) await kbConnSync(res.source.sourceId);
|
|
12056
|
+
} catch (err) {
|
|
12057
|
+
const said = errorText(err, { action: 'connect that source' });
|
|
12058
|
+
kbAnnounce(said);
|
|
12059
|
+
showToast(said, 'warn');
|
|
12060
|
+
await renderKnowledge();
|
|
12061
|
+
}
|
|
12062
|
+
}
|
|
12063
|
+
|
|
12064
|
+
async function kbConnErase(sourceId) {
|
|
12065
|
+
const st = knowledgeState;
|
|
12066
|
+
const c = kbConnOf(st, sourceId);
|
|
12067
|
+
const removed = ((st && st.connected && st.connected.removed) || []).find((r) => r.sourceId === sourceId);
|
|
12068
|
+
const name = (c && c.label) || (removed && removed.label) || (kbConnIsMail(c) ? 'this folder' : 'this source');
|
|
12069
|
+
// Each source names what its own service keeps (a Trimble project keeps its topics), a removed one too: the
|
|
12070
|
+
// project-wide list is a Teams chat's, so it is only the last resort for a server that sends neither.
|
|
12071
|
+
const notReached = (c && Array.isArray(c.notReached) && c.notReached)
|
|
12072
|
+
|| (removed && Array.isArray(removed.notReached) && removed.notReached)
|
|
12073
|
+
|| (st && st.connected && st.connected.notReached) || [];
|
|
12074
|
+
const what = kbConnIsTrimble(c) || (removed && removed.scopeKind === 'trimble-project') ? 'its topics and ToDos' : 'its messages';
|
|
12075
|
+
const revision = c ? c.revision : 'removed';
|
|
12076
|
+
const answer = await kbConnDialog({ title: `Erase “${name}”?`, labelId: 'kb-conn-erase-title',
|
|
12077
|
+
bodyHtml: '<div class="kb-conn-h">This removes</div><ul class="kb-conn-list">' +
|
|
12078
|
+
`<li>${c ? `${c.versions} saved version${c.versions === 1 ? '' : 's'} of ${what}` : `the saved versions of ${what}`}</li>` +
|
|
12079
|
+
'<li>the knowledge pages organized from it</li><li>any quotes from it saved with workflow Agent steps and pinned pages</li>' +
|
|
12080
|
+
(c ? `<li>this ${kbConnThing(c)} as a source, so it stops syncing</li>` : '') + '</ul>' +
|
|
12081
|
+
`<div class="kb-conn-h">This cannot reach</div><ul class="kb-conn-list">${(notReached.length ? notReached
|
|
12082
|
+
: ['AI Chat conversations and reports already made, which may quote this source.']).map((line) => `<li>${escapeHtml(line)}</li>`).join('')}</ul>` +
|
|
12083
|
+
'<p class="kb-conn-p">It cannot be undone.</p>',
|
|
12084
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
12085
|
+
{ id: 'erase', label: 'Erase permanently', tone: 'danger', commandId: 'shell.kb-connected-erase-go' }] });
|
|
12086
|
+
if (!answer || answer.id !== 'erase') return;
|
|
12087
|
+
await kbConnEraseGo(sourceId, name, { revision });
|
|
12088
|
+
}
|
|
12089
|
+
|
|
12090
|
+
async function kbConnEraseGo(sourceId, name, body) {
|
|
12091
|
+
let res;
|
|
12092
|
+
try { res = await api(kbConnUrl(`/${encodeURIComponent(sourceId)}/erase`), { method: 'POST', body: JSON.stringify(body) }); }
|
|
12093
|
+
catch (err) { const said = errorText(err, { action: 'erase this source' }); kbAnnounce(said); showToast(said, 'warn'); kbInvalidateRefs(); await renderKnowledge(); return; }
|
|
12094
|
+
if (res.state === 'waiting') {
|
|
12095
|
+
const answer = await kbConnDialog({ title: `Stop the Organize and erase “${name}”?`, labelId: 'kb-conn-stop-title',
|
|
12096
|
+
bodyHtml: `<p class="kb-conn-p">${escapeHtml(res.message)} Its messages are already left out of everything new; stopping the Organize lets the Erase finish now. Organize again afterwards.</p>`,
|
|
12097
|
+
actions: [{ id: 'cancel', label: 'Wait for it', commandId: 'shell.kb-connected-cancel' },
|
|
12098
|
+
{ id: 'stop', label: 'Stop and erase', tone: 'danger', commandId: 'shell.kb-connected-stop-organize' }] });
|
|
12099
|
+
if (answer && answer.id === 'stop') return kbConnEraseGo(sourceId, name, { stopOrganize: res.organizeRequestId });
|
|
12100
|
+
kbAnnounce('Erasing as soon as the Organize ends.');
|
|
12101
|
+
} else if (res.state === 'incomplete') {
|
|
12102
|
+
// The page words this itself from the count; the server's list of what stayed is kept in the console.
|
|
12103
|
+
const left = Array.isArray(res.failures) ? res.failures.length : 0;
|
|
12104
|
+
if (left) console.warn('[knowledge] erase left items behind', res.failures);
|
|
12105
|
+
const said = left ? `Erase did not finish: ${left} item${left === 1 ? '' : 's'} could not be removed. Erase again.` : 'Erase did not finish. Erase again.';
|
|
12106
|
+
kbAnnounce(said);
|
|
12107
|
+
showToast(said, 'warn');
|
|
12108
|
+
} else {
|
|
12109
|
+
kbConnStops.delete(sourceId);
|
|
12110
|
+
kbAnnounce(`Erased “${name}”.`);
|
|
12111
|
+
}
|
|
12112
|
+
kbInvalidateRefs();
|
|
12113
|
+
await renderKnowledge();
|
|
12114
|
+
// The row the dialog returned focus to may be gone now; keep focus in the list rather than lose it to the page.
|
|
12115
|
+
if (!$wsKnowledge.contains(document.activeElement)) $wsKnowledge.querySelector('[data-kb-conn-new]')?.focus({ preventScroll: true });
|
|
12116
|
+
}
|
|
12117
|
+
|
|
12118
|
+
/** The click handler's connected-source half; true when it handled the click. */
|
|
12119
|
+
function kbConnClick(e) {
|
|
12120
|
+
const t = e.target;
|
|
12121
|
+
if (t.closest('[data-kb-conn-new]')) { kbCloseConfirm(); void kbConnOpenConnect(); return true; }
|
|
12122
|
+
const sync = t.closest('[data-kb-conn-sync]');
|
|
12123
|
+
if (sync) { kbCloseConfirm(); void kbConnSync(sync.dataset.kbConnSync); return true; }
|
|
12124
|
+
const menu = t.closest('[data-kb-conn-menu]');
|
|
12125
|
+
if (menu) { kbConnShowMenu(menu); return true; }
|
|
12126
|
+
const pause = t.closest('[data-kb-conn-pause]');
|
|
12127
|
+
if (pause) { kbCloseConfirm(); void kbConnSetPaused(pause.dataset.kbConnPause, pause.dataset.kbConnPaused === 'true'); return true; }
|
|
12128
|
+
const remove = t.closest('[data-kb-conn-remove]');
|
|
12129
|
+
if (remove) { kbConnRemove(remove.dataset.kbConnRemove); return true; }
|
|
12130
|
+
const erase = t.closest('[data-kb-conn-erase]');
|
|
12131
|
+
if (erase) { kbCloseConfirm(); void kbConnErase(erase.dataset.kbConnErase); return true; }
|
|
12132
|
+
const choice = t.closest('[data-kb-conn-choice]');
|
|
12133
|
+
if (choice) { kbConnChoose(choice.dataset.kbConnId, choice.dataset.kbConnChoice); return true; }
|
|
12134
|
+
const windowMenu = t.closest('[data-kb-conn-window-menu]');
|
|
12135
|
+
if (windowMenu) { kbCloseConfirm(); void kbConnWindowDialog(windowMenu.dataset.kbConnWindowMenu); return true; }
|
|
12136
|
+
const reread = t.closest('[data-kb-conn-reread]');
|
|
12137
|
+
if (reread) { kbCloseConfirm(); void kbConnRereadDialog(reread.dataset.kbConnReread); return true; }
|
|
12138
|
+
const ceiling = t.closest('[data-kb-conn-ceiling]');
|
|
12139
|
+
if (ceiling) {
|
|
12140
|
+
const id = ceiling.dataset.kbConnId, v = ceiling.dataset.kbConnCeiling;
|
|
12141
|
+
const name = kbConnOf(knowledgeState, id)?.label || 'This folder';
|
|
12142
|
+
void kbConnSetMail(id, v === 'partial' ? { beyondCeiling: 'partial' } : { windowDays: Number(v) },
|
|
12143
|
+
v === 'partial' ? `“${name}” keeps a partial copy.` : `“${name}” keeps the last ${v} days from the next sync.`, ceiling.dataset.kbConnRev);
|
|
12144
|
+
return true;
|
|
12145
|
+
}
|
|
12146
|
+
return false;
|
|
12147
|
+
}
|
|
12148
|
+
|
|
12149
|
+
function kbConnRemove(sourceId) {
|
|
12150
|
+
const anchor = $wsKnowledge.querySelector(`[data-kb-conn-menu="${CSS.escape(sourceId)}"]`);
|
|
12151
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
12152
|
+
if (anchor) kbShowRemoveConfirm(anchor, sourceId, (c && c.label) || `this ${kbConnThing(c)}`,
|
|
12153
|
+
'FloLess stops syncing it and leaves it out of future Organize runs. What it synced stays stored until you erase it, from Removed connected sources.',
|
|
12154
|
+
`shell.kb-connected-remove-go#${sourceId}`);
|
|
12155
|
+
}
|
|
12156
|
+
|
|
12157
|
+
function kbConnChoose(sourceId, choice) {
|
|
12158
|
+
const stop = kbConnStops.get(sourceId) || { opts: {}, target: null };
|
|
12159
|
+
// Keep the copy answers a stop by leaving the copy as it is, until the person syncs again.
|
|
12160
|
+
if (choice === 'cancel' || choice === 'keep') { kbConnStops.delete(sourceId); kbConnRepaint(); return; }
|
|
12161
|
+
if (choice === 'pause') { void kbConnSetPaused(sourceId, true); return; }
|
|
12162
|
+
if (choice === 'remove') { kbConnRemove(sourceId); return; }
|
|
12163
|
+
if (choice === 'open-integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return; }
|
|
12164
|
+
if (choice === 'open-tools') {
|
|
12165
|
+
if (typeof openLibrary === 'function') openLibrary(kbConnIsTrimble(kbConnOf(knowledgeState, sourceId)) ? 'trimble-connect' : 'microsoft-365', { tab: 'available' });
|
|
12166
|
+
return;
|
|
12167
|
+
}
|
|
12168
|
+
if (choice === 'reload') { kbConnStops.delete(sourceId); kbInvalidateRefs(); void renderKnowledge(); return; }
|
|
12169
|
+
if (choice === 'sync-with-current') { void kbConnSync(sourceId, { account: 'current-signin', ...(stop.target ? { expected: stop.target } : {}) }); return; }
|
|
12170
|
+
if (choice === 'confirm-target') { void kbConnSync(sourceId, { ...stop.opts, ...(stop.target ? { expected: stop.target } : {}) }); return; }
|
|
12171
|
+
if (choice === 'resume-and-sync') { void kbConnSync(sourceId, { ...stop.opts, resume: true }); return; }
|
|
12172
|
+
if (choice === 'sync-anyway') { void kbConnSync(sourceId, { ...stop.opts, overBudget: true }); return; }
|
|
12173
|
+
if (choice === 'rebuild') { void kbConnSync(sourceId, { ...stop.opts, rebuild: true }); return; }
|
|
12174
|
+
void kbConnSync(sourceId, stop.opts || {});
|
|
12175
|
+
}
|
|
12176
|
+
|
|
10871
12177
|
function kbColumn(st) {
|
|
10872
12178
|
// One collection: issued drawings, reference groups, then upload. Presentation never changes membership.
|
|
10873
12179
|
const loose = st.sources.filter((source) => !kbInDesignSet(source, st));
|
|
@@ -10879,10 +12185,11 @@
|
|
|
10879
12185
|
const newCat = kbCatUsable(st) && loose.length && !(kbCatEdit && kbCatEdit.mode === 'new' && !kbCatEdit.parentId)
|
|
10880
12186
|
? '<button type="button" class="kb-link kb-cat-new" data-kb-cat-new data-command-id="shell.kb-category-new" data-tip="Group references into categories">+ New category</button>' : '';
|
|
10881
12187
|
const flatEdit = !tree && kbCatEdit && kbCatEdit.mode === 'new' ? kbCatEditHtml(0) : '';
|
|
10882
|
-
const
|
|
12188
|
+
const connect = '<button type="button" class="kb-link kb-conn-new" data-kb-conn-new data-command-id="shell.kb-connected-new" data-tip="Sync a Teams chat, an Outlook folder or a Trimble Connect project into this project’s knowledge, with the account chosen in Integrations">+ Connect a source</button>';
|
|
12189
|
+
const body = '<div class="kb-reference-head"><h3>Reference files</h3><span class="kb-reference-actions">' + newCat + connect + '</span></div>' +
|
|
10883
12190
|
kbCatUnavailableHtml(st) + (loose.length
|
|
10884
12191
|
? (tree ? kbTreeHtml(st, loose) : flatEdit + '<h4 class="kb-uncategorized-head">Uncategorized references</h4>' + loose.map((source) => kbSourceRow(source, st)).join(''))
|
|
10885
|
-
: '<div class="kb-empty">' + (inSet ? 'Other reference files will appear here. Drawings are listed in the Design set above.' : 'No references added yet. Add files below to get started.') + '</div>') + kbSelBarHtml(st);
|
|
12192
|
+
: '<div class="kb-empty">' + (inSet ? 'Other reference files will appear here. Drawings are listed in the Design set above.' : 'No references added yet. Add files below to get started.') + '</div>') + kbConnExtrasHtml(st) + kbSelBarHtml(st);
|
|
10886
12193
|
const selected = st.sources.filter((s) => s.useAsKb).length;
|
|
10887
12194
|
return '<section class="kb-col">' +
|
|
10888
12195
|
'<div class="kb-refs-body">' + `<div class="kb-source-summary">${st.sources.length} source${st.sources.length === 1 ? '' : 's'} · ${selected} selected for Organize</div>` + kbDesignSetStrip(st) + body +
|
|
@@ -11213,6 +12520,54 @@
|
|
|
11213
12520
|
// One modal extends the existing Knowledge surface. Shared entries are immutable versions;
|
|
11214
12521
|
// nothing reaches this project's source list until the user explicitly accepts one.
|
|
11215
12522
|
let companyKnowledgeProjectId = null;
|
|
12523
|
+
// #3151: bumped on every open and close, so a request that outlives the dialog it started in
|
|
12524
|
+
// (the project changed under it) can tell, and drops its result instead of writing into the next one.
|
|
12525
|
+
let companyKnowledgeSession = 0;
|
|
12526
|
+
const COMPANY_KNOWLEDGE_BUSY_REASON = 'FloLess is still saving this change. You can close this window when it finishes.';
|
|
12527
|
+
|
|
12528
|
+
function companySetStatus(message) {
|
|
12529
|
+
if (!$companyKnowledgeStatus) return;
|
|
12530
|
+
$companyKnowledgeStatus.hidden = !message;
|
|
12531
|
+
$companyKnowledgeStatus.textContent = message || '';
|
|
12532
|
+
}
|
|
12533
|
+
|
|
12534
|
+
/** Close, ×, Back and the dismiss gestures wait while a change is in flight; the action button is render's. */
|
|
12535
|
+
function syncCompanyKnowledgeBusy() {
|
|
12536
|
+
for (const button of [$companyKnowledgeClose, $companyKnowledgeCancel]) {
|
|
12537
|
+
if (!button) continue;
|
|
12538
|
+
button.disabled = companyKnowledgeBusy;
|
|
12539
|
+
if (companyKnowledgeBusy) button.dataset.blockedReason = COMPANY_KNOWLEDGE_BUSY_REASON;
|
|
12540
|
+
else delete button.dataset.blockedReason;
|
|
12541
|
+
}
|
|
12542
|
+
$companyKnowledgeClose.dataset.tip = companyKnowledgeBusy ? COMPANY_KNOWLEDGE_BUSY_REASON : 'Close';
|
|
12543
|
+
$companyKnowledgeDialog.setAttribute('aria-busy', String(companyKnowledgeBusy));
|
|
12544
|
+
// A disabled button drops focus to the page; keep it in the dialog so Escape and Tab still land here.
|
|
12545
|
+
if (companyKnowledgeBusy && document.activeElement?.disabled && $companyKnowledgeModal.contains(document.activeElement)) {
|
|
12546
|
+
$companyKnowledgeDialog.focus({ preventScroll: true });
|
|
12547
|
+
}
|
|
12548
|
+
if (!companyKnowledgeBusy) companySetStatus('');
|
|
12549
|
+
}
|
|
12550
|
+
|
|
12551
|
+
/** A request from an earlier opening has settled after the dialog reopened (for another project): the
|
|
12552
|
+
* new dialog was painted busy and loaded before that change landed, so repaint it from a fresh read. */
|
|
12553
|
+
async function companyRefreshAfterStale() {
|
|
12554
|
+
if (!$companyKnowledgeModal.classList.contains('show') || !companyKnowledgeProjectId) { syncCompanyKnowledgeBusy(); return; }
|
|
12555
|
+
const session = companyKnowledgeSession;
|
|
12556
|
+
// Stay busy through the re-read, so an action started in the new dialog waits for it and its own
|
|
12557
|
+
// result can never be overwritten by this older read landing after it.
|
|
12558
|
+
companyKnowledgeBusy = true;
|
|
12559
|
+
try { await loadCompanyKnowledge(companyKnowledgeProjectId, session); } catch { /* the open dialog keeps what it loaded */ }
|
|
12560
|
+
finally {
|
|
12561
|
+
companyKnowledgeBusy = false;
|
|
12562
|
+
if (session === companyKnowledgeSession) renderCompanyKnowledge(); else void companyRefreshAfterStale();
|
|
12563
|
+
}
|
|
12564
|
+
}
|
|
12565
|
+
|
|
12566
|
+
/** Every person-driven way out of the dialog: blocked, with the reason said, while a change runs. */
|
|
12567
|
+
function dismissCompanyKnowledge() {
|
|
12568
|
+
if (companyKnowledgeBusy) { companySetStatus(COMPANY_KNOWLEDGE_BUSY_REASON); return; }
|
|
12569
|
+
closeCompanyKnowledge();
|
|
12570
|
+
}
|
|
11216
12571
|
|
|
11217
12572
|
function companyVersionNumber(entry, versionId) {
|
|
11218
12573
|
const at = entry && Array.isArray(entry.versions)
|
|
@@ -11335,21 +12690,28 @@
|
|
|
11335
12690
|
async function companyCatPost(path, body, okMsg) {
|
|
11336
12691
|
const state = companyKnowledgeState;
|
|
11337
12692
|
if (companyKnowledgeBusy || !state || !state.available) return null;
|
|
11338
|
-
|
|
12693
|
+
const session = companyKnowledgeSession, projectId = companyKnowledgeProjectId;
|
|
12694
|
+
companyKnowledgeBusy = true; companySetError(''); syncCompanyKnowledgeBusy();
|
|
11339
12695
|
try {
|
|
11340
12696
|
const res = await api(path, { method: 'POST', body: JSON.stringify({ expected: companyCatExpected(state), ...body }) });
|
|
11341
|
-
|
|
12697
|
+
// Company categories are company-wide, so the toast is true whichever project is on screen now.
|
|
11342
12698
|
if (okMsg) showToast(okMsg, 'ok');
|
|
12699
|
+
if (session !== companyKnowledgeSession) return null;
|
|
12700
|
+
companyCatEdit = null;
|
|
11343
12701
|
return res;
|
|
11344
12702
|
} catch (error) {
|
|
11345
|
-
const said =
|
|
11346
|
-
|
|
12703
|
+
const said = /^[A-Z]/.test(personText(error && error.body)) ? personText(error && error.body) : '';
|
|
12704
|
+
const message = said || 'FloLess could not change the company categories just now. Try again.';
|
|
12705
|
+
if (session !== companyKnowledgeSession) { showToast(message, 'warn'); return null; }
|
|
12706
|
+
companySetError(message);
|
|
11347
12707
|
if (body.expected && error && error.body && error.body.code === 'knowledge-categories-changed') companyCatEdit = null;
|
|
11348
12708
|
return null;
|
|
11349
12709
|
} finally {
|
|
11350
12710
|
companyKnowledgeBusy = false;
|
|
11351
|
-
|
|
11352
|
-
|
|
12711
|
+
if (session === companyKnowledgeSession) {
|
|
12712
|
+
try { await loadCompanyKnowledge(projectId); } catch { /* the error line says what happened */ }
|
|
12713
|
+
}
|
|
12714
|
+
if (session === companyKnowledgeSession) renderCompanyKnowledge(); else void companyRefreshAfterStale();
|
|
11353
12715
|
}
|
|
11354
12716
|
}
|
|
11355
12717
|
/** What a company category change is checked against: the categories' revision and the company folder. */
|
|
@@ -11534,44 +12896,56 @@
|
|
|
11534
12896
|
$companyKnowledgeAction.disabled = companyKnowledgeBusy || !available;
|
|
11535
12897
|
if (!available) $companyKnowledgeAction.dataset.blockedReason = 'Choose an available company folder first';
|
|
11536
12898
|
else delete $companyKnowledgeAction.dataset.blockedReason;
|
|
11537
|
-
|
|
12899
|
+
syncCompanyKnowledgeBusy();
|
|
11538
12900
|
}
|
|
11539
12901
|
|
|
11540
|
-
async function loadCompanyKnowledge(projectId) {
|
|
11541
|
-
|
|
11542
|
-
|
|
12902
|
+
async function loadCompanyKnowledge(projectId, session = companyKnowledgeSession) {
|
|
12903
|
+
const state = await api(`/api/company-knowledge?projectId=${encodeURIComponent(projectId)}`);
|
|
12904
|
+
// A read that finishes after its dialog closed belongs to no screen; never let it overwrite the next one.
|
|
12905
|
+
if (session === companyKnowledgeSession) companyKnowledgeState = state;
|
|
12906
|
+
return state;
|
|
11543
12907
|
}
|
|
11544
12908
|
|
|
11545
12909
|
async function openCompanyKnowledge(promotion, returnFocus) {
|
|
11546
12910
|
if (!current || !$companyKnowledgeModal) return;
|
|
12911
|
+
const session = ++companyKnowledgeSession;
|
|
11547
12912
|
companyKnowledgeProjectId = current.id;
|
|
11548
12913
|
companyKnowledgePromotion = promotion || null;
|
|
11549
12914
|
companyKnowledgePending = null;
|
|
11550
12915
|
companyKnowledgeReturnFocus = returnFocus || document.activeElement;
|
|
11551
|
-
companySetError('');
|
|
12916
|
+
companySetError(''); companySetStatus('');
|
|
11552
12917
|
$companyKnowledgeModal.classList.add('show');
|
|
11553
12918
|
$companyKnowledgeFolder.innerHTML = '<div class="company-empty">Loading company knowledge…</div>';
|
|
11554
12919
|
$companyKnowledgeList.innerHTML = '';
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
12920
|
+
// An earlier opening's change may still be running, which leaves Close disabled; focus the dialog then.
|
|
12921
|
+
($companyKnowledgeClose.disabled ? $companyKnowledgeDialog : $companyKnowledgeClose).focus({ preventScroll: true });
|
|
12922
|
+
try { await loadCompanyKnowledge(companyKnowledgeProjectId, session); }
|
|
12923
|
+
catch (error) {
|
|
12924
|
+
if (session !== companyKnowledgeSession) return;
|
|
12925
|
+
companyKnowledgeState = { configured: false, loadError: companyErrorMessage(error, 'FloLess could not load company references. Check the company folder and try again.') };
|
|
12926
|
+
}
|
|
12927
|
+
if (session === companyKnowledgeSession) renderCompanyKnowledge();
|
|
11559
12928
|
}
|
|
11560
12929
|
|
|
11561
12930
|
function closeCompanyKnowledge(restoreFocus = true) {
|
|
11562
12931
|
if (!$companyKnowledgeModal || !$companyKnowledgeModal.classList.contains('show')) return;
|
|
11563
12932
|
$companyKnowledgeModal.classList.remove('show');
|
|
12933
|
+
companyKnowledgeSession += 1;
|
|
11564
12934
|
const back = companyKnowledgeReturnFocus;
|
|
11565
12935
|
companyKnowledgeReturnFocus = null;
|
|
11566
12936
|
companyKnowledgePromotion = null;
|
|
11567
12937
|
companyKnowledgePending = null;
|
|
11568
12938
|
companyKnowledgeProjectId = null;
|
|
11569
|
-
companySetError('');
|
|
11570
|
-
|
|
12939
|
+
companySetError(''); companySetStatus('');
|
|
12940
|
+
// The Knowledge header repaints while the dialog is open (an Add, the status poll), replacing the
|
|
12941
|
+
// button that opened it; return focus to the one on screen now rather than dropping it on the page.
|
|
12942
|
+
const target = back && back.isConnected ? back : document.querySelector('[data-company-open]');
|
|
12943
|
+
if (restoreFocus && target) target.focus({ preventScroll: true });
|
|
11571
12944
|
}
|
|
11572
12945
|
|
|
11573
12946
|
async function chooseCompanyFolder() {
|
|
11574
12947
|
if (companyKnowledgeBusy) return;
|
|
12948
|
+
const session = companyKnowledgeSession, projectId = companyKnowledgeProjectId;
|
|
11575
12949
|
companyKnowledgeBusy = true; companySetError(''); renderCompanyKnowledge();
|
|
11576
12950
|
try {
|
|
11577
12951
|
const choice = await api('/api/company-knowledge/folder/choose', { method: 'POST', body: '{}' });
|
|
@@ -11579,17 +12953,27 @@
|
|
|
11579
12953
|
await api('/api/company-knowledge/folder/select', {
|
|
11580
12954
|
method: 'POST', body: JSON.stringify({ selectionId: choice.selectionId }),
|
|
11581
12955
|
});
|
|
11582
|
-
|
|
12956
|
+
// The folder is machine-wide: it is connected whichever project is on screen by now.
|
|
11583
12957
|
showToast('Company knowledge folder connected', 'ok');
|
|
12958
|
+
if (session === companyKnowledgeSession) await loadCompanyKnowledge(projectId, session);
|
|
11584
12959
|
}
|
|
11585
|
-
} catch (error) {
|
|
11586
|
-
|
|
12960
|
+
} catch (error) {
|
|
12961
|
+
const message = companyErrorMessage(error, 'FloLess could not use that company folder. Choose another folder and try again.');
|
|
12962
|
+
if (session === companyKnowledgeSession) companySetError(message); else showToast(message, 'warn');
|
|
12963
|
+
}
|
|
12964
|
+
finally { companyKnowledgeBusy = false; if (session === companyKnowledgeSession) renderCompanyKnowledge(); else void companyRefreshAfterStale(); }
|
|
11587
12965
|
}
|
|
11588
12966
|
|
|
11589
12967
|
async function performCompanyKnowledgeAction() {
|
|
11590
12968
|
if (companyKnowledgeBusy || !companyKnowledgeProjectId) return;
|
|
11591
12969
|
const state = companyKnowledgeState;
|
|
11592
12970
|
if (!state || !state.available) return;
|
|
12971
|
+
// #3151: the person cannot close the dialog while this runs, but a project switch still can. Every
|
|
12972
|
+
// await below re-checks the session: a stale result still tells the person what happened, but never
|
|
12973
|
+
// writes into the dialog that replaced it or reloads it with no project.
|
|
12974
|
+
const session = companyKnowledgeSession, projectId = companyKnowledgeProjectId;
|
|
12975
|
+
const projectName = current && current.id === projectId ? current.name : '';
|
|
12976
|
+
const stale = () => session !== companyKnowledgeSession;
|
|
11593
12977
|
companyKnowledgeBusy = true; companySetError(''); renderCompanyKnowledge();
|
|
11594
12978
|
try {
|
|
11595
12979
|
if (companyKnowledgePending?.kind === 'accept') {
|
|
@@ -11597,8 +12981,10 @@
|
|
|
11597
12981
|
const latest = entry && entry.versions[entry.versions.length - 1];
|
|
11598
12982
|
if (!entry || !latest) throw new Error('That company version is no longer available.');
|
|
11599
12983
|
const res = await api(`/api/company-knowledge/sources/${encodeURIComponent(entry.librarySourceId)}/versions/${encodeURIComponent(latest.versionId)}/accept`, {
|
|
11600
|
-
method: 'POST', body: JSON.stringify({ projectId
|
|
12984
|
+
method: 'POST', body: JSON.stringify({ projectId }),
|
|
11601
12985
|
});
|
|
12986
|
+
// Another project is on screen by now: say which project it went to instead of "this project".
|
|
12987
|
+
if (stale()) { showToast(`Added ${entry.displayName} v${entry.versions.length} to ${projectName || 'the project you started it in'}.`, 'ok'); return; }
|
|
11602
12988
|
companyKnowledgePending = null;
|
|
11603
12989
|
// #2491 R6.9: where it went in this project's categories, and why.
|
|
11604
12990
|
const placed = res && res.placement;
|
|
@@ -11606,24 +12992,30 @@
|
|
|
11606
12992
|
} else if (companyKnowledgePending?.kind === 'remove') {
|
|
11607
12993
|
const entry = state.sources.find((row) => row.librarySourceId === companyKnowledgePending.librarySourceId);
|
|
11608
12994
|
await api(`/api/company-knowledge/sources/${encodeURIComponent(companyKnowledgePending.librarySourceId)}`, { method: 'DELETE' });
|
|
11609
|
-
|
|
12995
|
+
// Company-wide, so the toast is true whichever project is on screen now.
|
|
11610
12996
|
showToast(`${entry ? entry.displayName : 'Company reference'} removed`, 'ok');
|
|
12997
|
+
if (stale()) return;
|
|
12998
|
+
companyKnowledgePending = null;
|
|
11611
12999
|
} else if (companyKnowledgePromotion) {
|
|
11612
13000
|
const promoted = await api('/api/company-knowledge/promote', {
|
|
11613
13001
|
method: 'POST', body: JSON.stringify({
|
|
11614
|
-
projectId
|
|
13002
|
+
projectId,
|
|
11615
13003
|
sourceId: companyKnowledgePromotion.sourceId,
|
|
11616
13004
|
librarySourceId: $companyPromotionLineage.value || null,
|
|
11617
13005
|
}),
|
|
11618
13006
|
});
|
|
11619
13007
|
const placed = promoted && promoted.placement;
|
|
11620
13008
|
showToast(`Company reference published${placed && placed.categoryId ? `, in ${placed.where}` : ''}.${placed && placed.note && !placed.categoryId ? ` ${placed.note}` : ''}`, placed && placed.note && !placed.categoryId ? 'warn' : 'ok');
|
|
13009
|
+
if (stale()) return;
|
|
11621
13010
|
companyKnowledgePromotion = null;
|
|
11622
13011
|
}
|
|
11623
|
-
await loadCompanyKnowledge(
|
|
11624
|
-
if (current && current.id ===
|
|
11625
|
-
} catch (error) {
|
|
11626
|
-
|
|
13012
|
+
await loadCompanyKnowledge(projectId, session);
|
|
13013
|
+
if (!stale() && current && current.id === projectId) await renderKnowledge();
|
|
13014
|
+
} catch (error) {
|
|
13015
|
+
// With its dialog gone, the toast is the only place left to say it.
|
|
13016
|
+
if (stale()) showToast(companyErrorMessage(error), 'warn'); else companySetError(companyErrorMessage(error));
|
|
13017
|
+
}
|
|
13018
|
+
finally { companyKnowledgeBusy = false; if (stale()) void companyRefreshAfterStale(); else renderCompanyKnowledge(); }
|
|
11627
13019
|
}
|
|
11628
13020
|
|
|
11629
13021
|
if ($companyKnowledgeModal) {
|
|
@@ -11636,13 +13028,14 @@
|
|
|
11636
13028
|
const remove = event.target.closest('[data-company-stage-remove]');
|
|
11637
13029
|
if (remove) { companyKnowledgePending = { kind: 'remove', librarySourceId: remove.dataset.companyStageRemove }; renderCompanyKnowledge(); $companyKnowledgeAction.focus(); }
|
|
11638
13030
|
});
|
|
11639
|
-
$companyKnowledgeClose.addEventListener('click', () =>
|
|
13031
|
+
$companyKnowledgeClose.addEventListener('click', () => dismissCompanyKnowledge());
|
|
11640
13032
|
$companyKnowledgeCancel.addEventListener('click', () => {
|
|
13033
|
+
if (companyKnowledgeBusy) { companySetStatus(COMPANY_KNOWLEDGE_BUSY_REASON); return; }
|
|
11641
13034
|
if (companyKnowledgePending) { companyKnowledgePending = null; companySetError(''); renderCompanyKnowledge(); }
|
|
11642
13035
|
else closeCompanyKnowledge();
|
|
11643
13036
|
});
|
|
11644
13037
|
$companyKnowledgeAction.addEventListener('click', performCompanyKnowledgeAction);
|
|
11645
|
-
onBackdropDismiss($companyKnowledgeModal, () =>
|
|
13038
|
+
onBackdropDismiss($companyKnowledgeModal, () => dismissCompanyKnowledge());
|
|
11646
13039
|
document.addEventListener('keydown', (event) => {
|
|
11647
13040
|
if (!$companyKnowledgeModal.classList.contains('show')) return;
|
|
11648
13041
|
// #2491 R6.9: the name box and the menus answer their own keys first; Escape closes them, not the dialog.
|
|
@@ -11663,7 +13056,7 @@
|
|
|
11663
13056
|
const at = items.indexOf(document.activeElement);
|
|
11664
13057
|
if (at >= 0) { event.preventDefault(); items[(at + (event.key === 'ArrowDown' ? 1 : items.length - 1)) % items.length].focus(); return; }
|
|
11665
13058
|
}
|
|
11666
|
-
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation();
|
|
13059
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); dismissCompanyKnowledge(); return; }
|
|
11667
13060
|
if (event.key !== 'Tab') return;
|
|
11668
13061
|
const focusable = [...$companyKnowledgeModal.querySelectorAll('button:not([hidden]):not(:disabled), input:not([hidden]):not(:disabled), [tabindex="0"]')]
|
|
11669
13062
|
.filter((node) => node.offsetParent !== null);
|
|
@@ -11759,7 +13152,7 @@
|
|
|
11759
13152
|
showToast(code === 'design-set-changed'
|
|
11760
13153
|
? 'The design set changed while this was open. Check it and choose again.'
|
|
11761
13154
|
// The server's own sentence says what to do (busy, file not in the project, an index it cannot take).
|
|
11762
|
-
: (err && err.body
|
|
13155
|
+
: personText(err && err.body) || 'Couldn’t change the design set. Try again.', 'warn');
|
|
11763
13156
|
}
|
|
11764
13157
|
if (current !== proj) return;
|
|
11765
13158
|
kbInvalidateRefs();
|
|
@@ -11960,7 +13353,7 @@
|
|
|
11960
13353
|
}
|
|
11961
13354
|
// Anchored to the SCROLL container (.kb-refs-body, position:relative) — .kb-col is overflow:hidden
|
|
11962
13355
|
// and would clip the popover. Same anchoring as .ws-history's rollback confirm.
|
|
11963
|
-
function kbShowRemoveConfirm(btn, sourceId, name) {
|
|
13356
|
+
function kbShowRemoveConfirm(btn, sourceId, name, bodyText, goCommandId) {
|
|
11964
13357
|
kbCloseConfirm();
|
|
11965
13358
|
const box = btn.closest('.kb-refs-body');
|
|
11966
13359
|
if (!box) return;
|
|
@@ -11970,10 +13363,15 @@
|
|
|
11970
13363
|
// from it — only the next Organize rebuilds the wiki without it.
|
|
11971
13364
|
pop.innerHTML =
|
|
11972
13365
|
`<div class="hc-title">Remove “${escapeHtml(name)}”?</div>` +
|
|
11973
|
-
|
|
11974
|
-
'stay in the knowledge base until you Organize again.</div>' +
|
|
13366
|
+
`<div class="hc-body">${escapeHtml(bodyText || 'It won’t be included in future Organize runs. Notes already compiled from it stay in the knowledge base until you Organize again.')}</div>` +
|
|
11975
13367
|
'<div class="hc-act"><button type="button" class="hc-cancel">Cancel</button>' +
|
|
11976
13368
|
`<button type="button" class="hc-go danger" data-kb-remove-go="${escapeAttr(sourceId)}">✕ Remove</button></div>`;
|
|
13369
|
+
// A caller that names its go button (the connected Remove) passes a literal id; set through the DOM, it needs no escaping.
|
|
13370
|
+
if (goCommandId) {
|
|
13371
|
+
const go = pop.querySelector('.hc-go');
|
|
13372
|
+
go.dataset.commandId = goCommandId;
|
|
13373
|
+
go.dataset.commandInstanceLabel = name;
|
|
13374
|
+
}
|
|
11977
13375
|
box.appendChild(pop);
|
|
11978
13376
|
const cr = box.getBoundingClientRect();
|
|
11979
13377
|
const br = btn.getBoundingClientRect();
|
|
@@ -12016,7 +13414,7 @@
|
|
|
12016
13414
|
function kbDsErrorText(err, fallback) {
|
|
12017
13415
|
const code = err && err.body && err.body.code;
|
|
12018
13416
|
if (code === 'design-set-changed') return 'The design set changed while this was open. Check it and try again.';
|
|
12019
|
-
return (err && err.body
|
|
13417
|
+
return personText(err && err.body) || fallback;
|
|
12020
13418
|
}
|
|
12021
13419
|
function kbDsOpenPanel(panel, focus) {
|
|
12022
13420
|
kbCloseConfirm();
|
|
@@ -12369,6 +13767,12 @@
|
|
|
12369
13767
|
// Which issues are open is the person's choice and survives repaints. `toggle` does not bubble, so this listens in capture.
|
|
12370
13768
|
$wsKnowledge.addEventListener('toggle', (e) => {
|
|
12371
13769
|
const d = e.target;
|
|
13770
|
+
// #2470 R6.8: a connected source's gap disclosure, likewise.
|
|
13771
|
+
if (d && d.dataset && d.dataset.kbConnGaps) {
|
|
13772
|
+
if (d.open) kbConnGapsOpen.add(d.dataset.kbConnGaps); else kbConnGapsOpen.delete(d.dataset.kbConnGaps);
|
|
13773
|
+
kbInvalidateRefs();
|
|
13774
|
+
return;
|
|
13775
|
+
}
|
|
12372
13776
|
if (!d || !d.classList || !d.classList.contains('kb-ds-issue')) return;
|
|
12373
13777
|
const issue = kbDsIssueById(d.dataset.kbDsIssueId);
|
|
12374
13778
|
if (!issue) return;
|
|
@@ -12388,6 +13792,7 @@
|
|
|
12388
13792
|
const rowAct = e.target.closest('[data-kb-row-act]');
|
|
12389
13793
|
if (rowAct) { kbRowAct(rowAct); return; }
|
|
12390
13794
|
if (kbCatClick(e)) return;
|
|
13795
|
+
if (kbConnClick(e)) return;
|
|
12391
13796
|
if (e.target.closest('.kb-ds') || e.target.closest('.kb-ds-menu') || e.target.closest('[data-kb-ds-jump]') || e.target.closest('[data-kb-ds-fremove], [data-kb-ds-fwithdraw]')) {
|
|
12392
13797
|
if (kbDsClick(e)) return;
|
|
12393
13798
|
}
|
|
@@ -12928,7 +14333,7 @@
|
|
|
12928
14333
|
];
|
|
12929
14334
|
};
|
|
12930
14335
|
/** The units this project's bill is written in: the server's answer, else the client's own copy. */
|
|
12931
|
-
const bomUnits = () => exportUnits ?? (current
|
|
14336
|
+
const bomUnits = () => exportUnits ?? shownUnits(current);
|
|
12932
14337
|
const BOM_DESCRIPTIVE = ['profile', 'grade', 'type'];
|
|
12933
14338
|
const DEFAULT_BOM_FORMATS = ['csv', 'xlsx'];
|
|
12934
14339
|
const DEFAULT_BOM_COLUMNS = ['profile', 'qty', 'length', 'lbft', 'weight'];
|
|
@@ -13224,6 +14629,9 @@
|
|
|
13224
14629
|
details: [
|
|
13225
14630
|
...(Array.isArray(receipt.unsupported) ? receipt.unsupported.map((row) => receiptItemText('Unsupported', row)) : []),
|
|
13226
14631
|
...(Array.isArray(receipt.warnings) ? receipt.warnings.map((warning) => receiptItemText('Warning', warning)) : []),
|
|
14632
|
+
...(receipt.profileMapping && Array.isArray(receipt.profileMapping.mapped)
|
|
14633
|
+
? receipt.profileMapping.mapped.map((row) => `Profile: ${row.from} was sent as ${row.to} (${row.memberCount} member${row.memberCount === 1 ? '' : 's'}). The model and bill of materials keep ${row.from}.`)
|
|
14634
|
+
: []),
|
|
13227
14635
|
].join('\n'),
|
|
13228
14636
|
};
|
|
13229
14637
|
}
|
|
@@ -13492,6 +14900,8 @@
|
|
|
13492
14900
|
await api(`/api/projects/${encodeURIComponent(projectId)}/host-bake-consent?appId=${encodeURIComponent(appId)}`, {
|
|
13493
14901
|
method: 'DELETE',
|
|
13494
14902
|
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
14903
|
+
// #3273: a send's busy claim waits for this cleanup, so a request that never answers must not hold it.
|
|
14904
|
+
timeoutMs: SEND_CLEANUP_MS,
|
|
13495
14905
|
});
|
|
13496
14906
|
} catch (_) { /* best effort; consent and its source lease also expire server-side */ }
|
|
13497
14907
|
finally { activeProjectHostBakeConsents.delete(token); }
|
|
@@ -13504,6 +14914,7 @@
|
|
|
13504
14914
|
method: 'POST',
|
|
13505
14915
|
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
13506
14916
|
body: '{}',
|
|
14917
|
+
signal: AbortSignal.timeout(SEND_CLEANUP_MS),
|
|
13507
14918
|
});
|
|
13508
14919
|
} catch (_) { /* a lost acknowledgement deliberately leaves the replay tombstone in place */ }
|
|
13509
14920
|
finally { activeProjectHostBakeConsents.delete(token); }
|
|
@@ -13512,14 +14923,373 @@
|
|
|
13512
14923
|
async function releaseCapturedSources(projectId, handles) {
|
|
13513
14924
|
await Promise.allSettled(handles.map((handleId) => api(
|
|
13514
14925
|
`/api/projects/${encodeURIComponent(projectId)}/export-captures/${encodeURIComponent(handleId)}/release`,
|
|
13515
|
-
{ method: 'POST' },
|
|
14926
|
+
{ method: 'POST', timeoutMs: SEND_CLEANUP_MS },
|
|
13516
14927
|
)));
|
|
13517
14928
|
}
|
|
13518
14929
|
|
|
13519
|
-
|
|
14930
|
+
// ── #3312: profile mapping before a Tekla send ──────────────────────────────────────────────────────────
|
|
14931
|
+
// Before a Tekla send FloLess asks Tekla (or an imported Tekla catalogue) which of the model's profiles it has,
|
|
14932
|
+
// suggests a match for each missing one, and lets the person decide. The model and the bill of materials keep
|
|
14933
|
+
// their own names: the table applies only to what is sent. Whatever is left unmapped is still sent, as written,
|
|
14934
|
+
// and Tekla makes a profile-less line the person gives a profile to there.
|
|
14935
|
+
const $pmModal = document.getElementById('profilemap-modal');
|
|
14936
|
+
const PM_CHIP = {
|
|
14937
|
+
name: ['Same name', 'is-sure'],
|
|
14938
|
+
exact: ['Same section', 'is-sure'],
|
|
14939
|
+
close: ['Within 1 mm', 'is-check'],
|
|
14940
|
+
check: ['Check orientation', 'is-check'],
|
|
14941
|
+
none: ['No match', ''],
|
|
14942
|
+
};
|
|
14943
|
+
const PM_LINE_LABEL = 'Leave unmapped — sent as a line';
|
|
14944
|
+
const PM_POOL_SHOWN = 60;
|
|
14945
|
+
const pmFileAsDataUrl = (file) => new Promise((resolve, reject) => {
|
|
14946
|
+
const reader = new FileReader();
|
|
14947
|
+
reader.onload = () => resolve(String(reader.result));
|
|
14948
|
+
reader.onerror = () => reject(reader.error || new Error('unreadable'));
|
|
14949
|
+
reader.readAsDataURL(file);
|
|
14950
|
+
});
|
|
14951
|
+
|
|
14952
|
+
async function checkTeklaProfiles(projectId, app, catalogueId, sourceHandle) {
|
|
14953
|
+
try {
|
|
14954
|
+
return await api(`/api/contract/${encodeURIComponent(app)}/host-profiles?project=${encodeURIComponent(projectId)}${sourceHandle ? `&sourceHandle=${encodeURIComponent(sourceHandle)}` : ''}`, {
|
|
14955
|
+
method: 'POST',
|
|
14956
|
+
body: JSON.stringify({ host: 'tekla', ...(catalogueId ? { catalogueId } : {}) }),
|
|
14957
|
+
timeoutMs: 150000,
|
|
14958
|
+
});
|
|
14959
|
+
} catch (error) {
|
|
14960
|
+
return {
|
|
14961
|
+
ok: true, supported: false, host: 'tekla', imported: [], revision: 0,
|
|
14962
|
+
reason: personText(error && error.body)
|
|
14963
|
+
|| 'FloLess could not check Tekla’s profiles just now. You can import a Tekla catalogue to check against, or continue without checking.',
|
|
14964
|
+
};
|
|
14965
|
+
}
|
|
14966
|
+
}
|
|
14967
|
+
|
|
14968
|
+
/**
|
|
14969
|
+
* The mapping window. Resolves { action: 'apply', profileMap, modelPath, revision } | { action: 'skip' } | null (cancelled).
|
|
14970
|
+
* It re-checks in place when the person switches the catalogue it checks against or imports one.
|
|
14971
|
+
*/
|
|
14972
|
+
function openProfileMapWindow({ projectId, app, first, returnFocus, sourceHandle }) {
|
|
14973
|
+
return new Promise((resolve) => {
|
|
14974
|
+
if (!$pmModal) { resolve({ action: 'skip' }); return; }
|
|
14975
|
+
const $title = document.getElementById('profilemap-title');
|
|
14976
|
+
const $sub = document.getElementById('profilemap-sub');
|
|
14977
|
+
const $source = document.getElementById('profilemap-source');
|
|
14978
|
+
const $sources = document.getElementById('profilemap-sources');
|
|
14979
|
+
const $import = document.getElementById('profilemap-import');
|
|
14980
|
+
const $file = document.getElementById('profilemap-file');
|
|
14981
|
+
const $body = document.getElementById('profilemap-body');
|
|
14982
|
+
const $note = document.getElementById('profilemap-note');
|
|
14983
|
+
const $apply = document.getElementById('profilemap-apply');
|
|
14984
|
+
const $cancel = document.getElementById('profilemap-cancel');
|
|
14985
|
+
const dialog = $pmModal.querySelector('.profilemap');
|
|
14986
|
+
let check = first;
|
|
14987
|
+
let choices = new Map();
|
|
14988
|
+
let initial = new Map();
|
|
14989
|
+
let poolIndex = new Map();
|
|
14990
|
+
let openRow = null;
|
|
14991
|
+
let busy = false;
|
|
14992
|
+
let done = false;
|
|
14993
|
+
|
|
14994
|
+
const seed = () => {
|
|
14995
|
+
initial = new Map((check.rows || []).map((row) => [row.profile, row.choice]));
|
|
14996
|
+
choices = new Map(initial);
|
|
14997
|
+
poolIndex = new Map((check.pool || []).map((entry) => [entry[0], entry]));
|
|
14998
|
+
};
|
|
14999
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
15000
|
+
const labelOf = (name) => {
|
|
15001
|
+
if (name == null) return PM_LINE_LABEL;
|
|
15002
|
+
const entry = poolIndex.get(name);
|
|
15003
|
+
return entry && entry[2] ? `${name} · ${entry[2]} mm` : name;
|
|
15004
|
+
};
|
|
15005
|
+
const sourceName = () => (check.source === 'imported' && check.catalogue
|
|
15006
|
+
? `the imported catalogue “${check.catalogue.name}” (${plural(check.catalogue.count, 'profile', 'profiles')})`
|
|
15007
|
+
: check.modelPath ? `the open Tekla model (${check.modelPath})` : 'the open Tekla model');
|
|
15008
|
+
|
|
15009
|
+
const rowHtml = (row) => {
|
|
15010
|
+
const [chipText, chipClass] = PM_CHIP[row.suggestion.confidence] || PM_CHIP.none;
|
|
15011
|
+
const chosen = choices.get(row.profile);
|
|
15012
|
+
const instance = escapeAttr(row.profile);
|
|
15013
|
+
const stale = row.staleSaved ? ` Your saved choice “${escapeHtml(row.staleSaved)}” is not in this catalogue, so it was not applied.` : '';
|
|
15014
|
+
return `<div class="pm-row${chosen !== initial.get(row.profile) ? ' changed' : ''}" data-pm-row="${instance}">
|
|
15015
|
+
<div class="pm-from"><span class="pm-name">${escapeHtml(row.profile)}</span><span class="pm-count">${escapeHtml(plural(row.memberCount, 'member', 'members'))}${row.choiceFrom === 'saved' ? ' · from your saved table' : ''}</span></div>
|
|
15016
|
+
<div class="pm-sugg"><span class="pm-chip ${chipClass}">${escapeHtml(chipText)}</span>
|
|
15017
|
+
<span class="pm-why">${row.suggestion.to ? `<strong>${escapeHtml(row.suggestion.to)}</strong> — ` : ''}${escapeHtml(row.suggestion.note)}${stale}</span></div>
|
|
15018
|
+
<div class="pm-pick wf-combo fm-select">
|
|
15019
|
+
<button type="button" class="wf-trigger pm-trigger" aria-haspopup="listbox" aria-expanded="${openRow === row.profile ? 'true' : 'false'}" data-command-id="shell.profile-map-choice" data-command-instance="${instance}" data-command-instance-label="${instance}" aria-label="Tekla profile for ${escapeAttr(row.profile)}: ${escapeAttr(labelOf(chosen))}">
|
|
15020
|
+
<span class="wf-trigger-label">${escapeHtml(labelOf(chosen))}</span>
|
|
15021
|
+
<svg class="wf-caret" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path fill="currentColor" d="M0 0l5 6 5-6z"/></svg>
|
|
15022
|
+
</button>
|
|
15023
|
+
${openRow === row.profile ? popoverHtml(row, '') : ''}
|
|
15024
|
+
</div>
|
|
15025
|
+
<div class="pm-caution" ${chosen != null && !(row.suggestion.safeNames || []).includes(chosen) ? '' : 'hidden'}>This is not the section the model draws. The member keeps its drawn position, so its faces and connections may not line up. Check the fit in Tekla.</div>
|
|
15026
|
+
</div>`;
|
|
15027
|
+
};
|
|
15028
|
+
|
|
15029
|
+
const optionsFor = (row, query) => {
|
|
15030
|
+
const q = query.trim().toLowerCase();
|
|
15031
|
+
const picked = new Set();
|
|
15032
|
+
const out = [{ value: '', label: PM_LINE_LABEL, meta: 'Tekla makes a line you give a profile to', line: true }];
|
|
15033
|
+
const add = (name, meta) => {
|
|
15034
|
+
if (picked.has(name)) return;
|
|
15035
|
+
picked.add(name);
|
|
15036
|
+
const entry = poolIndex.get(name);
|
|
15037
|
+
out.push({ value: name, label: name, meta: meta || (entry && entry[2] ? `${entry[2]} mm` : '') });
|
|
15038
|
+
};
|
|
15039
|
+
if (!q) {
|
|
15040
|
+
if (row.suggestion.to) add(row.suggestion.to, `suggested · ${(PM_CHIP[row.suggestion.confidence] || PM_CHIP.none)[0].toLowerCase()}`);
|
|
15041
|
+
(row.suggestion.alternatives || []).forEach((name) => add(name));
|
|
15042
|
+
}
|
|
15043
|
+
let shown = 0;
|
|
15044
|
+
for (const entry of check.pool || []) {
|
|
15045
|
+
if (shown >= PM_POOL_SHOWN) break;
|
|
15046
|
+
if (q && !(entry[0].toLowerCase().includes(q) || String(entry[2] || '').includes(q))) continue;
|
|
15047
|
+
if (!q && picked.has(entry[0])) continue;
|
|
15048
|
+
add(entry[0]);
|
|
15049
|
+
shown += 1;
|
|
15050
|
+
}
|
|
15051
|
+
return out;
|
|
15052
|
+
};
|
|
15053
|
+
|
|
15054
|
+
const popoverHtml = (row, query) => {
|
|
15055
|
+
const chosen = choices.get(row.profile);
|
|
15056
|
+
const options = optionsFor(row, query);
|
|
15057
|
+
const listId = `pm-list-${escapeAttr(row.profile).replace(/[^A-Za-z0-9_-]/g, '_')}`;
|
|
15058
|
+
return `<div class="wf-popover pm-popover" role="presentation">
|
|
15059
|
+
<div class="wf-search-wrap"><input class="wf-search pm-search" type="text" placeholder="Search Tekla’s profiles…" autocomplete="off" aria-label="Search Tekla’s profiles" aria-controls="${listId}" value="${escapeAttr(query)}"></div>
|
|
15060
|
+
<div class="wf-list pm-list" id="${listId}" role="listbox" aria-label="Tekla profiles for ${escapeAttr(row.profile)}">${options.map((o) => {
|
|
15061
|
+
const on = o.line ? chosen == null : chosen === o.value;
|
|
15062
|
+
return `<div class="wf-option${on ? ' selected' : ''}" role="option" tabindex="-1" aria-selected="${on ? 'true' : 'false'}" data-pm-value="${escapeAttr(o.value)}"><span class="wf-option-name">${escapeHtml(o.label)}</span>${o.meta ? `<span class="wf-option-meta">${escapeHtml(o.meta)}</span>` : ''}</div>`;
|
|
15063
|
+
}).join('')}${options.length === 1 && query ? '<div class="wf-empty-search">No profile in Tekla matches that.</div>' : ''}</div>
|
|
15064
|
+
</div>`;
|
|
15065
|
+
};
|
|
15066
|
+
|
|
15067
|
+
const render = () => {
|
|
15068
|
+
const rows = check.rows || [];
|
|
15069
|
+
$title.textContent = check.supported === false ? 'Check the profiles before sending'
|
|
15070
|
+
: rows.length ? 'Profiles Tekla does not have' : 'Every profile is in Tekla';
|
|
15071
|
+
$sources.hidden = true;
|
|
15072
|
+
if (check.supported === false) {
|
|
15073
|
+
$sub.textContent = check.reason || '';
|
|
15074
|
+
$source.textContent = '';
|
|
15075
|
+
$body.innerHTML = '<div class="pm-empty">Without a check, FloLess sends every member as the model names it. Any profile Tekla does not have still arrives, as a profile-less line you give a profile to in Tekla. The model and the bill of materials do not change.</div>';
|
|
15076
|
+
$note.textContent = '';
|
|
15077
|
+
$apply.textContent = 'Continue without checking';
|
|
15078
|
+
} else {
|
|
15079
|
+
$sub.textContent = rows.length
|
|
15080
|
+
? `${rows.length} of the ${plural(check.counts.profiles, 'profile', 'profiles')} in this model (${plural(rows.reduce((sum, row) => sum + row.memberCount, 0), 'member', 'members')}) ${rows.length === 1 ? 'is' : 'are'} not in Tekla. FloLess suggests a match; you can change any of them. Whatever you leave unmapped is still sent, and Tekla makes a line you give a profile to there. The model and the bill of materials keep their own names.`
|
|
15081
|
+
: `All ${plural(check.counts.profiles, 'profile', 'profiles')} in this model are in ${sourceName()}. Nothing needs mapping.`;
|
|
15082
|
+
$source.textContent = `Checked against ${sourceName()}.`;
|
|
15083
|
+
$body.innerHTML = rows.length
|
|
15084
|
+
? `<div class="pm-head" aria-hidden="true"><span>In the model</span><span>Suggestion</span><span>Send to Tekla as</span></div>${rows.map(rowHtml).join('')}`
|
|
15085
|
+
: '<div class="pm-empty">Nothing to map for this catalogue.</div>';
|
|
15086
|
+
$note.textContent = 'Sending replaces the parts FloLess sent to this Tekla model before, including any you gave a profile to by hand. Your choices are kept with the project for the next send.';
|
|
15087
|
+
$apply.textContent = rows.length ? 'Apply and continue' : 'Continue';
|
|
15088
|
+
}
|
|
15089
|
+
const imported = check.imported || [];
|
|
15090
|
+
$sources.hidden = imported.length === 0;
|
|
15091
|
+
// Built with DOM APIs, never markup: a saved catalogue is data from disk, and nothing in it may become HTML.
|
|
15092
|
+
const sourceButton = (id, label, pressed) => {
|
|
15093
|
+
const b = document.createElement('button');
|
|
15094
|
+
b.type = 'button';
|
|
15095
|
+
b.dataset.pmSource = id;
|
|
15096
|
+
b.setAttribute('aria-pressed', pressed ? 'true' : 'false');
|
|
15097
|
+
b.dataset.commandId = 'shell.profile-map-source';
|
|
15098
|
+
b.dataset.commandInstance = label;
|
|
15099
|
+
b.dataset.commandInstanceLabel = label;
|
|
15100
|
+
b.textContent = label;
|
|
15101
|
+
return b;
|
|
15102
|
+
};
|
|
15103
|
+
const sourceButtons = [];
|
|
15104
|
+
if (imported.length) {
|
|
15105
|
+
const open = sourceButton('', 'Open Tekla model', check.source !== 'imported');
|
|
15106
|
+
sourceButtons.push(open);
|
|
15107
|
+
for (const c of imported) {
|
|
15108
|
+
const count = Number.isInteger(c.count) && c.count >= 0 ? c.count : 0;
|
|
15109
|
+
const b = sourceButton(String(c.id), `${c.name} · ${count}`, check.source === 'imported' && !!check.catalogue && check.catalogue.id === c.id);
|
|
15110
|
+
b.dataset.commandInstance = String(c.name);
|
|
15111
|
+
b.dataset.commandInstanceLabel = String(c.name);
|
|
15112
|
+
sourceButtons.push(b);
|
|
15113
|
+
}
|
|
15114
|
+
}
|
|
15115
|
+
$sources.replaceChildren(...sourceButtons);
|
|
15116
|
+
$apply.disabled = busy;
|
|
15117
|
+
$import.disabled = busy;
|
|
15118
|
+
$import.toggleAttribute('aria-busy', busy);
|
|
15119
|
+
};
|
|
15120
|
+
|
|
15121
|
+
const recheck = async (catalogueId, keepNote) => {
|
|
15122
|
+
busy = true; render();
|
|
15123
|
+
if (!keepNote) $note.textContent = '';
|
|
15124
|
+
const next = await checkTeklaProfiles(projectId, app, catalogueId, sourceHandle);
|
|
15125
|
+
busy = false;
|
|
15126
|
+
// A check that failed in transit says nothing about which catalogues the project holds: keep the switcher.
|
|
15127
|
+
if (!next.supported && !(next.imported || []).length) next.imported = check.imported || [];
|
|
15128
|
+
check = next; openRow = null; seed(); render();
|
|
15129
|
+
return next;
|
|
15130
|
+
};
|
|
15131
|
+
|
|
15132
|
+
const close = (value) => {
|
|
15133
|
+
if (done) return;
|
|
15134
|
+
done = true;
|
|
15135
|
+
$pmModal.classList.remove('show');
|
|
15136
|
+
$pmModal.removeEventListener('click', onClick);
|
|
15137
|
+
$pmModal.removeEventListener('input', onInput);
|
|
15138
|
+
$pmModal.removeEventListener('keydown', onKey);
|
|
15139
|
+
$pmModal.removeEventListener('mousedown', onBackdrop);
|
|
15140
|
+
$file.removeEventListener('change', onFile);
|
|
15141
|
+
const back = typeof returnFocus === 'function' ? returnFocus() : returnFocus;
|
|
15142
|
+
if (back && back.isConnected) back.focus();
|
|
15143
|
+
resolve(value);
|
|
15144
|
+
};
|
|
15145
|
+
|
|
15146
|
+
const choose = (profile, value) => {
|
|
15147
|
+
choices.set(profile, value === '' ? null : value);
|
|
15148
|
+
openRow = null;
|
|
15149
|
+
render();
|
|
15150
|
+
const trigger = $body.querySelector(`[data-pm-row="${CSS.escape(profile)}"] .pm-trigger`);
|
|
15151
|
+
if (trigger) trigger.focus();
|
|
15152
|
+
};
|
|
15153
|
+
|
|
15154
|
+
function onClick(event) {
|
|
15155
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
15156
|
+
if (!target) return;
|
|
15157
|
+
if (target.closest('#profilemap-apply')) {
|
|
15158
|
+
if (busy) return;
|
|
15159
|
+
if (check.supported === false) { close({ action: 'skip' }); return; }
|
|
15160
|
+
close({ action: 'apply', profileMap: Object.fromEntries(choices), modelPath: check.modelPath || null, revision: check.revision || 0 });
|
|
15161
|
+
return;
|
|
15162
|
+
}
|
|
15163
|
+
if (target.closest('#profilemap-cancel')) { close(null); return; }
|
|
15164
|
+
if (target.closest('#profilemap-import')) { if (!busy) $file.click(); return; }
|
|
15165
|
+
const source = target.closest('[data-pm-source]');
|
|
15166
|
+
if (source) { if (!busy) void recheck(source.dataset.pmSource || undefined); return; }
|
|
15167
|
+
const option = target.closest('[data-pm-value]');
|
|
15168
|
+
const row = target.closest('[data-pm-row]');
|
|
15169
|
+
if (option && row) { choose(row.dataset.pmRow, option.dataset.pmValue); return; }
|
|
15170
|
+
const trigger = target.closest('.pm-trigger');
|
|
15171
|
+
if (trigger && row) {
|
|
15172
|
+
openRow = openRow === row.dataset.pmRow ? null : row.dataset.pmRow;
|
|
15173
|
+
render();
|
|
15174
|
+
const search = $body.querySelector('.pm-search');
|
|
15175
|
+
if (search) search.focus();
|
|
15176
|
+
}
|
|
15177
|
+
}
|
|
15178
|
+
function onInput(event) {
|
|
15179
|
+
const search = event.target instanceof Element ? event.target.closest('.pm-search') : null;
|
|
15180
|
+
if (!search || !openRow) return;
|
|
15181
|
+
const row = (check.rows || []).find((candidate) => candidate.profile === openRow);
|
|
15182
|
+
const list = search.closest('.pm-popover')?.querySelector('.pm-list');
|
|
15183
|
+
if (!row || !list) return;
|
|
15184
|
+
const holder = document.createElement('div');
|
|
15185
|
+
holder.innerHTML = popoverHtml(row, search.value);
|
|
15186
|
+
list.innerHTML = holder.querySelector('.pm-list').innerHTML;
|
|
15187
|
+
}
|
|
15188
|
+
function onKey(event) {
|
|
15189
|
+
if (event.key === 'Escape') {
|
|
15190
|
+
event.preventDefault();
|
|
15191
|
+
event.stopPropagation();
|
|
15192
|
+
if (openRow) { const profile = openRow; openRow = null; render(); const t = $body.querySelector(`[data-pm-row="${CSS.escape(profile)}"] .pm-trigger`); if (t) t.focus(); }
|
|
15193
|
+
else if (!busy) close(null);
|
|
15194
|
+
return;
|
|
15195
|
+
}
|
|
15196
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
15197
|
+
if (target && openRow && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
15198
|
+
const options = Array.from($body.querySelectorAll('.pm-popover [role="option"]'));
|
|
15199
|
+
const at = options.indexOf(document.activeElement);
|
|
15200
|
+
const next = event.key === 'ArrowDown' ? options[Math.min(options.length - 1, at + 1)] : (at <= 0 ? $body.querySelector('.pm-search') : options[at - 1]);
|
|
15201
|
+
if (next) { event.preventDefault(); next.focus(); }
|
|
15202
|
+
return;
|
|
15203
|
+
}
|
|
15204
|
+
if (target && (event.key === 'Enter' || event.key === ' ') && target.matches('[role="option"]')) {
|
|
15205
|
+
event.preventDefault();
|
|
15206
|
+
const row = target.closest('[data-pm-row]');
|
|
15207
|
+
if (row) choose(row.dataset.pmRow, target.dataset.pmValue);
|
|
15208
|
+
return;
|
|
15209
|
+
}
|
|
15210
|
+
if (event.key !== 'Tab') return;
|
|
15211
|
+
const focusable = Array.from($pmModal.querySelectorAll('button:not([disabled]), input:not([hidden]):not([disabled]), [tabindex="0"], [role="option"]')).filter((node) => !node.hidden && node.offsetParent !== null && node.getAttribute('tabindex') !== '-1');
|
|
15212
|
+
if (!focusable.length) return;
|
|
15213
|
+
const firstNode = focusable[0], lastNode = focusable[focusable.length - 1];
|
|
15214
|
+
if (event.shiftKey && document.activeElement === firstNode) { event.preventDefault(); lastNode.focus(); }
|
|
15215
|
+
else if (!event.shiftKey && document.activeElement === lastNode) { event.preventDefault(); firstNode.focus(); }
|
|
15216
|
+
}
|
|
15217
|
+
function onBackdrop(event) { if (event.target === $pmModal && !busy) close(null); }
|
|
15218
|
+
async function onFile() {
|
|
15219
|
+
const file = ($file.files || [])[0];
|
|
15220
|
+
$file.value = '';
|
|
15221
|
+
if (!file || busy) return;
|
|
15222
|
+
busy = true; render();
|
|
15223
|
+
try {
|
|
15224
|
+
const dataUrl = await pmFileAsDataUrl(file);
|
|
15225
|
+
const saved = await api(`/api/projects/${encodeURIComponent(projectId)}/host-profile-catalogues?appId=${encodeURIComponent(app)}`, {
|
|
15226
|
+
method: 'POST', body: JSON.stringify({ name: file.name, dataUrl }), timeoutMs: 120000,
|
|
15227
|
+
});
|
|
15228
|
+
busy = false;
|
|
15229
|
+
const next = await recheck(saved.catalogue && saved.catalogue.id, true);
|
|
15230
|
+
$note.textContent = next && next.supported && next.source === 'imported'
|
|
15231
|
+
? `Imported ${file.name}. The profiles are now checked against it.`
|
|
15232
|
+
: `Imported ${file.name}, but FloLess could not check the profiles against it. ${next && next.reason ? next.reason : 'Pick it from the list above to try again.'}`;
|
|
15233
|
+
} catch (error) {
|
|
15234
|
+
busy = false; render();
|
|
15235
|
+
$note.textContent = personText(error && error.body) || 'FloLess could not read that file. Choose a Tekla .profilecatalog or .lis file exported from Tekla and try again.';
|
|
15236
|
+
}
|
|
15237
|
+
}
|
|
15238
|
+
|
|
15239
|
+
seed();
|
|
15240
|
+
render();
|
|
15241
|
+
$pmModal.addEventListener('click', onClick);
|
|
15242
|
+
$pmModal.addEventListener('input', onInput);
|
|
15243
|
+
$pmModal.addEventListener('keydown', onKey);
|
|
15244
|
+
$pmModal.addEventListener('mousedown', onBackdrop);
|
|
15245
|
+
$file.addEventListener('change', onFile);
|
|
15246
|
+
$pmModal.classList.add('show');
|
|
15247
|
+
dialog.focus();
|
|
15248
|
+
});
|
|
15249
|
+
}
|
|
15250
|
+
|
|
15251
|
+
/**
|
|
15252
|
+
* The send's profile review. Resolves null when the person cancels; {} when the profiles were not checked
|
|
15253
|
+
* (the send then goes as before); else the fields the preflight and the send carry.
|
|
15254
|
+
*/
|
|
15255
|
+
async function reviewTeklaProfiles(projectId, app, sourceHandle, returnFocus) {
|
|
15256
|
+
showToast('Checking which profiles Tekla has…', 'info');
|
|
15257
|
+
const first = await checkTeklaProfiles(projectId, app, undefined, sourceHandle);
|
|
15258
|
+
if (first.supported && (first.rows || []).length === 0) {
|
|
15259
|
+
return { profileMap: {}, ...(first.modelPath ? { modelPath: first.modelPath } : {}), profileMapRevision: first.revision || 0 };
|
|
15260
|
+
}
|
|
15261
|
+
const answer = await openProfileMapWindow({ projectId, app, first, returnFocus, sourceHandle });
|
|
15262
|
+
if (!answer) return null;
|
|
15263
|
+
if (answer.action === 'skip') return {};
|
|
15264
|
+
let revision = answer.revision;
|
|
15265
|
+
try {
|
|
15266
|
+
const saved = await api(`/api/projects/${encodeURIComponent(projectId)}/host-profile-map?appId=${encodeURIComponent(app)}`, {
|
|
15267
|
+
method: 'PUT', body: JSON.stringify({ host: 'tekla', entries: answer.profileMap, baseRevision: answer.revision }),
|
|
15268
|
+
});
|
|
15269
|
+
revision = saved.revision;
|
|
15270
|
+
} catch (error) {
|
|
15271
|
+
// Keeping the table is a courtesy and never blocks the send, but the person is told it was not kept.
|
|
15272
|
+
console.warn('[workspaces] could not save the profile table', error);
|
|
15273
|
+
showToast('Your profile choices apply to this send, but FloLess could not remember them for next time.', 'warn');
|
|
15274
|
+
}
|
|
15275
|
+
return { profileMap: answer.profileMap, ...(answer.modelPath ? { modelPath: answer.modelPath } : {}), profileMapRevision: revision };
|
|
15276
|
+
}
|
|
15277
|
+
|
|
15278
|
+
/** What the table did, in a sentence for the send's summary. */
|
|
15279
|
+
function profileMappingText(mapping, counts) {
|
|
15280
|
+
if (!mapping || !mapping.reviewed) return '';
|
|
15281
|
+
const parts = [];
|
|
15282
|
+
const mapped = Array.isArray(mapping.mapped) ? mapping.mapped : [];
|
|
15283
|
+
if (mapped.length) parts.push(`${mapped.length} profile${mapped.length === 1 ? '' : 's'} renamed for Tekla`);
|
|
15284
|
+
const lines = Number(mapping.lines) || 0;
|
|
15285
|
+
if (lines) parts.push(`${lines} member${lines === 1 ? '' : 's'} arrived as profile-less lines — select them in Tekla and give them a profile`);
|
|
15286
|
+
return parts.join(', ');
|
|
15287
|
+
}
|
|
15288
|
+
|
|
15289
|
+
async function preflightHostSends(hosts, projectId, appId, sourceHandles, hostBodies = {}) {
|
|
13520
15290
|
const results = await Promise.allSettled(hosts.map((host, index) => api(
|
|
13521
15291
|
hostSendUrl(host, projectId, appId, sourceHandles[index]),
|
|
13522
|
-
{ method: 'POST', body: JSON.stringify({ preflight: true }) },
|
|
15292
|
+
{ method: 'POST', body: JSON.stringify({ preflight: true, ...(hostBodies[host] || {}) }) },
|
|
13523
15293
|
)));
|
|
13524
15294
|
const reviews = results.filter((result) => result.status === 'fulfilled').map((result) => result.value);
|
|
13525
15295
|
reviews.forEach((review) => activeProjectHostBakeConsents.set(review.consent, { projectId, appId }));
|
|
@@ -13634,13 +15404,14 @@
|
|
|
13634
15404
|
* be minutes old by the time a third host's turn comes round, and an application closed since
|
|
13635
15405
|
* then must be reported rather than sent into.
|
|
13636
15406
|
*/
|
|
13637
|
-
async function sendToHosts(hosts, projectId, app, approvedAt, sourceHandles, sourceKind, reviews) {
|
|
15407
|
+
async function sendToHosts(hosts, projectId, app, approvedAt, sourceHandles, sourceKind, reviews, hostBodies = {}) {
|
|
13638
15408
|
const done = [];
|
|
13639
15409
|
const failed = [];
|
|
13640
15410
|
const uncertain = [];
|
|
13641
15411
|
const aborted = [];
|
|
13642
15412
|
let uncertainHost = null;
|
|
13643
15413
|
let staleReview = false;
|
|
15414
|
+
let modelChanged = false;
|
|
13644
15415
|
/** Has the sign-off this batch was aimed at moved on? Only answerable while it is still open. */
|
|
13645
15416
|
const approvalMoved = () => !!current && current.id === projectId && current.approvedAt !== approvedAt;
|
|
13646
15417
|
try {
|
|
@@ -13667,7 +15438,7 @@
|
|
|
13667
15438
|
const res = await api(hostSendUrl(host, projectId, app, sourceHandles[i]), {
|
|
13668
15439
|
method: 'POST',
|
|
13669
15440
|
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': reviews[i].consent },
|
|
13670
|
-
body: JSON.stringify({}),
|
|
15441
|
+
body: JSON.stringify(hostBodies[host] || {}),
|
|
13671
15442
|
});
|
|
13672
15443
|
await acknowledgeProjectHostBakeConsent(projectId, app, reviews[i].consent);
|
|
13673
15444
|
track('workspace_export', { app, kind: `send:${host}`, sourceKind });
|
|
@@ -13677,22 +15448,26 @@
|
|
|
13677
15448
|
counts: res.counts,
|
|
13678
15449
|
warnings: res.warnings || [],
|
|
13679
15450
|
unsupported: res.receipt && Array.isArray(res.receipt.unsupported) ? res.receipt.unsupported : [],
|
|
15451
|
+
profileMapping: res.profileMapping || null,
|
|
13680
15452
|
approvedAt,
|
|
13681
15453
|
});
|
|
13682
15454
|
summary = receiptSummary(exportReceipts.get(`${projectId}:send:${host}`), `send:${host}`);
|
|
13683
15455
|
}
|
|
13684
15456
|
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt });
|
|
13685
15457
|
const omissionText = hostBakeOmissionSummary(res);
|
|
15458
|
+
const mappingText = profileMappingText(res.profileMapping);
|
|
13686
15459
|
done.push({
|
|
13687
15460
|
host,
|
|
13688
|
-
partial: !!omissionText || !!(summary && summary.partial),
|
|
13689
|
-
text: omissionText || (summary && summary.text),
|
|
15461
|
+
partial: !!omissionText || !!mappingText || !!(summary && summary.partial),
|
|
15462
|
+
text: [omissionText || (summary && summary.text), mappingText].filter(Boolean).join(' · '),
|
|
13690
15463
|
});
|
|
13691
15464
|
} catch (err) {
|
|
13692
15465
|
if (err && err.body && ['host-bake-dispatch-uncertain', 'host-bake-result-unverified'].includes(err.body.code)) {
|
|
13693
15466
|
const detail = err.body.error || (err && err.message) || String(err);
|
|
13694
15467
|
uncertain.push({ host, error: detail });
|
|
13695
15468
|
uncertainHost = host;
|
|
15469
|
+
// #3273: the card says so too, long after the toast is gone, and offers "Send again".
|
|
15470
|
+
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt, unconfirmed: true });
|
|
13696
15471
|
aborted.push(...hosts.slice(i + 1));
|
|
13697
15472
|
break;
|
|
13698
15473
|
}
|
|
@@ -13700,16 +15475,20 @@
|
|
|
13700
15475
|
|| (err && err.body && err.body.code === 'response-unreadable')) {
|
|
13701
15476
|
uncertain.push({ host, error: `FloLess lost the ${hostLabel(host)} response after dispatch. Check the open model before sending again.` });
|
|
13702
15477
|
uncertainHost = host;
|
|
15478
|
+
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt, unconfirmed: true });
|
|
13703
15479
|
aborted.push(...hosts.slice(i + 1));
|
|
13704
15480
|
break;
|
|
13705
15481
|
}
|
|
13706
|
-
if (err && err.body && ['host-bake-confirmation-stale', 'host-bake-preflight-required', 'stale-selection'].includes(err.body.code)) {
|
|
15482
|
+
if (err && err.body && ['host-bake-confirmation-stale', 'host-bake-preflight-required', 'stale-selection', 'host-profile-model-changed'].includes(err.body.code)) {
|
|
13707
15483
|
staleReview = true;
|
|
15484
|
+
// A different Tekla model is open now: the table must be checked against it, so the window opens again.
|
|
15485
|
+
if (err.body.code === 'host-profile-model-changed') modelChanged = true;
|
|
13708
15486
|
aborted.push(...hosts.slice(i));
|
|
13709
15487
|
break;
|
|
13710
15488
|
}
|
|
13711
|
-
const detail = (err && err.body
|
|
13712
|
-
|
|
15489
|
+
const detail = personText(err && err.body) || (err && err.message) || String(err);
|
|
15490
|
+
// A refusal Tekla made and undid is a definite answer (#3312): say what it was and that nothing changed.
|
|
15491
|
+
failed.push({ host, error: detail, rejected: !!(err && err.body && err.body.code === 'host-bake-rejected') });
|
|
13713
15492
|
}
|
|
13714
15493
|
}
|
|
13715
15494
|
} finally {
|
|
@@ -13733,7 +15512,9 @@
|
|
|
13733
15512
|
clean.length ? `Sent to ${sequenceText(clean.map((d) => d.host))}.` : '',
|
|
13734
15513
|
...partial.map((d) => `${hostLabel(d.host)} took it with gaps — ${d.text}.`),
|
|
13735
15514
|
...uncertain.map((row) => row.error),
|
|
13736
|
-
...failed.map((f) =>
|
|
15515
|
+
...failed.map((f) => (f.rejected
|
|
15516
|
+
? `${f.error} Choose Send again to review the profiles.`
|
|
15517
|
+
: `${hostLabel(f.host)} didn’t — ${reasonFragment(humanSendError(f.error))}.`)),
|
|
13737
15518
|
// The abort rides in the SAME sentence rather than firing its own toast: two toasts about
|
|
13738
15519
|
// one action is exactly the storm this single-line report replaced.
|
|
13739
15520
|
aborted.length
|
|
@@ -13746,13 +15527,9 @@
|
|
|
13746
15527
|
].filter(Boolean).join(' ');
|
|
13747
15528
|
showToast(sentence, partial.length || failed.length || uncertain.length || aborted.length ? 'warn' : 'ok');
|
|
13748
15529
|
}
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
await safeRenderExports('after that send finished', 'send-host',
|
|
13753
|
-
() => paintExports(approvedAt, 'send-host'));
|
|
13754
|
-
}
|
|
13755
|
-
return { staleReview, remainingHosts: staleReview ? [...aborted] : [] };
|
|
15530
|
+
// No repaint here (#3273): chooseAndSend refreshes the pane once it has released the send's busy claim, so a
|
|
15531
|
+
// refresh that is slow or never answers cannot keep the card on "Sending…".
|
|
15532
|
+
return { staleReview, modelChanged, remainingHosts: staleReview ? [...aborted] : [] };
|
|
13756
15533
|
}
|
|
13757
15534
|
|
|
13758
15535
|
/** The Send card's whole action: ask, then send. */
|
|
@@ -13767,6 +15544,7 @@
|
|
|
13767
15544
|
const busyKey = `${projectId}:send-host`;
|
|
13768
15545
|
if (exportBusy.has(busyKey)) { showToast(sendBusyText(), 'info'); return; }
|
|
13769
15546
|
exportBusy.add(busyKey);
|
|
15547
|
+
let sent = false; // a send reached the destinations, so the pane re-reads the listing once the claim is released
|
|
13770
15548
|
try {
|
|
13771
15549
|
const picked = await askSendDestinations(projectId);
|
|
13772
15550
|
if (current && current.id === projectId && !$wsExports.hidden) paintExports(current.approvedAt);
|
|
@@ -13776,6 +15554,8 @@
|
|
|
13776
15554
|
if (!sourceOption) { showToast('Choose an export source first.', 'warn'); return; }
|
|
13777
15555
|
const sourceSelector = JSON.parse(JSON.stringify(sourceOption.selector));
|
|
13778
15556
|
let remainingHosts = [...picked];
|
|
15557
|
+
let hostBodies = {};
|
|
15558
|
+
let teklaReviewed = false; // the mapping window is shown once per send, not again on a stale-review retry
|
|
13779
15559
|
// The user may have switched projects while the dialog was open — the send must not land on
|
|
13780
15560
|
// whatever is open NOW. Everything below is keyed to the captured project. One stale
|
|
13781
15561
|
// continuation is rebuilt and re-reviewed; a second fails closed instead of looping forever.
|
|
@@ -13787,7 +15567,24 @@
|
|
|
13787
15567
|
let reviews;
|
|
13788
15568
|
try {
|
|
13789
15569
|
showToast(attempt ? 'Checking the latest approved model…' : 'Checking what will be sent…', 'info');
|
|
13790
|
-
|
|
15570
|
+
// Tekla only (#3312): ask which profiles it has and let the person decide what the missing ones become.
|
|
15571
|
+
if (remainingHosts.includes('tekla') && !teklaReviewed) {
|
|
15572
|
+
const reviewed = await reviewTeklaProfiles(projectId, app, handles[remainingHosts.indexOf('tekla')], () => $wsExports.querySelector('[data-export="send-host"]'));
|
|
15573
|
+
if (reviewed === null) {
|
|
15574
|
+
await releaseCapturedSources(projectId, handles);
|
|
15575
|
+
exportBusy.delete(busyKey);
|
|
15576
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
15577
|
+
paintExports(current.approvedAt, 'send-host');
|
|
15578
|
+
const sendCard = $wsExports.querySelector('[data-export="send-host"]');
|
|
15579
|
+
if (sendCard instanceof HTMLElement && !sendCard.matches(':disabled,[aria-disabled="true"]')) sendCard.focus();
|
|
15580
|
+
}
|
|
15581
|
+
showToast('CAD send cancelled.', 'info');
|
|
15582
|
+
return;
|
|
15583
|
+
}
|
|
15584
|
+
teklaReviewed = true;
|
|
15585
|
+
if (reviewed.profileMap) hostBodies.tekla = reviewed;
|
|
15586
|
+
}
|
|
15587
|
+
reviews = await preflightHostSends(remainingHosts, projectId, app, handles, hostBodies);
|
|
13791
15588
|
const confirmed = await confirmAggregateHostSend(remainingHosts, reviews[0], attempt > 0 && reviews[0].kind === 'clean');
|
|
13792
15589
|
if (!confirmed) {
|
|
13793
15590
|
await Promise.allSettled(reviews.map((review) => cancelProjectHostBakeConsent(projectId, app, review.consent)));
|
|
@@ -13826,15 +15623,29 @@
|
|
|
13826
15623
|
const attemptApprovedAt = attempt > 0 && current && current.id === projectId
|
|
13827
15624
|
? current.approvedAt
|
|
13828
15625
|
: approvedAt;
|
|
13829
|
-
const result = await sendToHosts(remainingHosts, projectId, app, attemptApprovedAt, handles, sources[0].kind, reviews);
|
|
15626
|
+
const result = await sendToHosts(remainingHosts, projectId, app, attemptApprovedAt, handles, sources[0].kind, reviews, hostBodies);
|
|
15627
|
+
sent = true;
|
|
13830
15628
|
if (attempt === 0 && result && result.staleReview && result.remainingHosts.length) {
|
|
13831
15629
|
remainingHosts = result.remainingHosts;
|
|
15630
|
+
if (result.modelChanged) { teklaReviewed = false; delete hostBodies.tekla; }
|
|
15631
|
+
// The retry anchors to the approval this refresh reads, so it waits for it (every refresh is bounded).
|
|
15632
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
15633
|
+
await safeRenderExports('after that send finished', 'send-host', () => paintExports(approvedAt, 'send-host'));
|
|
15634
|
+
}
|
|
13832
15635
|
continue;
|
|
13833
15636
|
}
|
|
13834
15637
|
return;
|
|
13835
15638
|
}
|
|
13836
15639
|
} finally {
|
|
13837
15640
|
exportBusy.delete(busyKey);
|
|
15641
|
+
// #3273: the card leaves its busy state the moment the claim is released, whatever the outcome. It used to repaint
|
|
15642
|
+
// only while the claim was still held, so an exit that did not repaint again (or a refresh that never finished)
|
|
15643
|
+
// left "Sending…" up for good. After a send the pane then re-reads the listing, so it reflects the project as it
|
|
15644
|
+
// is now; that refresh runs with the claim already released, so it cannot hold the card either.
|
|
15645
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
15646
|
+
paintExports(current.approvedAt, sent ? 'send-host' : undefined);
|
|
15647
|
+
if (sent) await safeRenderExports('after that send finished', 'send-host', () => paintExports(approvedAt, 'send-host'));
|
|
15648
|
+
}
|
|
13838
15649
|
}
|
|
13839
15650
|
}
|
|
13840
15651
|
|
|
@@ -14138,6 +15949,16 @@
|
|
|
14138
15949
|
const rows = sent.length
|
|
14139
15950
|
? `<div class="e-renders e-sent-list" role="group" aria-label="Sent to">` +
|
|
14140
15951
|
sent.map((r) => {
|
|
15952
|
+
// #3273: a send FloLess could not confirm is never a ✓. The row keeps "sent" (it may well have landed), names
|
|
15953
|
+
// why it is unconfirmed, and carries no receipt: whatever receipt is held is from an earlier send.
|
|
15954
|
+
if (r.rec.unconfirmed) {
|
|
15955
|
+
return `<div class="e-render-entry">` +
|
|
15956
|
+
`<div class="e-render-row">` +
|
|
15957
|
+
`<span class="e-done unconfirmed"><span class="chk" aria-hidden="true">!</span> sent to ${escapeHtml(hostLabel(r.host))} – not confirmed <span class="t">${escapeHtml(hhmm(r.rec.at))}</span></span>` +
|
|
15958
|
+
`</div>` +
|
|
15959
|
+
`<div class="e-receipt partial"><span>FloLess couldn’t confirm what changed in ${escapeHtml(hostLabel(r.host))}. Check the open model before sending again.</span></div>` +
|
|
15960
|
+
`</div>`;
|
|
15961
|
+
}
|
|
14141
15962
|
// Asked of the receipt HERE rather than remembered as a flag at send time. The two
|
|
14142
15963
|
// drifted: a clean send stored "has details" and then opened an empty dialog, because
|
|
14143
15964
|
// what the button offers and what the dialog can show must be the same question.
|
|
@@ -14425,17 +16246,17 @@
|
|
|
14425
16246
|
// #2449: each approved source carries its own frozen connection-assumptions label from the server, bound to it.
|
|
14426
16247
|
const frozen = (row) => (row && row.connectionAssumptions && typeof row.connectionAssumptions.note === 'string' ? row.connectionAssumptions : null);
|
|
14427
16248
|
// #2521 row 5: `quick` first, so each option keeps the exact shape the #2449 checks read.
|
|
14428
|
-
if (data.default) out.push({ quick: data.default.quick, selector: { kind: 'latest-approved' }, label: `Latest approved · v${data.default.version}`, group: 'Recommended', version: data.default.version, assumptions: frozen(data.default) });
|
|
16249
|
+
if (data.default) out.push({ quick: data.default.quick, coverage: data.default.coverage, selector: { kind: 'latest-approved' }, label: `Latest approved · v${data.default.version}`, group: 'Recommended', version: data.default.version, assumptions: frozen(data.default) });
|
|
14429
16250
|
if (data.working) out.push({
|
|
14430
16251
|
selector: {
|
|
14431
16252
|
kind: 'working', expectedEtag: data.working.etag,
|
|
14432
16253
|
...(data.working.epoch !== null && Number.isInteger(Number(data.working.epoch)) ? { expectedEpoch: Number(data.working.epoch) } : {}),
|
|
14433
16254
|
},
|
|
14434
|
-
label: 'Working copy · DRAFT', group: 'Drafts', quick: data.working.quick,
|
|
16255
|
+
label: 'Working copy · DRAFT', group: 'Drafts', quick: data.working.quick, coverage: data.working.coverage,
|
|
14435
16256
|
});
|
|
14436
|
-
for (const saved of data.checkpoints || []) out.push({ selector: { kind: 'checkpoint', checkpointId: saved.checkpointId, expectedHash: saved.hash }, label: `Checkpoint ${String(saved.checkpointId).slice(0, 8)} · DRAFT`, group: 'Drafts', sub: saved.baseVersion ? `Pending work from v${saved.baseVersion}` : 'No approved baseline', quick: saved.quick });
|
|
16257
|
+
for (const saved of data.checkpoints || []) out.push({ selector: { kind: 'checkpoint', checkpointId: saved.checkpointId, expectedHash: saved.hash }, label: `Checkpoint ${String(saved.checkpointId).slice(0, 8)} · DRAFT`, group: 'Drafts', sub: saved.baseVersion ? `Pending work from v${saved.baseVersion}` : 'No approved baseline', quick: saved.quick, coverage: saved.coverage });
|
|
14437
16258
|
for (const row of data.defaultUnavailable?.reason === 'refused' ? [] : (data.approved || [])) {
|
|
14438
|
-
if (!data.default || Number(row.version) !== Number(data.default.version)) out.push({ quick: row.quick, selector: { kind: 'approved', version: row.version }, label: `Older approved · v${row.version}`, group: 'Approved history', version: row.version, assumptions: frozen(row) });
|
|
16259
|
+
if (!data.default || Number(row.version) !== Number(data.default.version)) out.push({ quick: row.quick, coverage: row.coverage, selector: { kind: 'approved', version: row.version }, label: `Older approved · v${row.version}`, group: 'Approved history', version: row.version, assumptions: frozen(row) });
|
|
14439
16260
|
}
|
|
14440
16261
|
return out;
|
|
14441
16262
|
}
|
|
@@ -14477,7 +16298,7 @@
|
|
|
14477
16298
|
const rows = options.filter((option) => option.group === group);
|
|
14478
16299
|
if (!rows.length) return '';
|
|
14479
16300
|
return `<div class="export-source-group" role="group" aria-label="${escapeAttr(group)}"><div class="export-source-group-label">${escapeHtml(group)}</div>`
|
|
14480
|
-
+ rows.map((option) => { const key = JSON.stringify(option.selector); const quickTip = quickPillHtml(option.quick) ? ` data-tip="${escapeAttr(`${option.label}: ${option.quick.label}. ${option.quick.tip || ''}`.trim())}"` : ''; return `<button type="button" class="export-source-option${key === selectedKey ? ' selected' : ''}" role="option" aria-selected="${String(key === selectedKey)}" data-export-source="${escapeAttr(key)}"${quickTip}><span>${escapeHtml(option.label)}${quickPillHtml(option.quick, { scope: option.label, focusable: false })}</span>${option.sub ? `<small>${escapeHtml(option.sub)}</small>` : ''}</button>`; }).join('') + '</div>';
|
|
16301
|
+
+ rows.map((option) => { const key = JSON.stringify(option.selector); const covered = coveragePillHtml(option.coverage, { besides: option.quick }); const quickTip = quickPillHtml(option.quick) || covered ? ` data-tip="${escapeAttr(`${option.label}: ${quickPillHtml(option.quick) ? `${option.quick.label}. ${option.quick.tip || ''}` : ''}${covered ? ` ${option.coverage.text || option.coverage.short}` : ''}`.replace(/\s+/gu, ' ').trim())}"` : ''; return `<button type="button" class="export-source-option${key === selectedKey ? ' selected' : ''}" role="option" aria-selected="${String(key === selectedKey)}" data-export-source="${escapeAttr(key)}"${quickTip}><span>${escapeHtml(option.label)}${quickPillHtml(option.quick, { scope: option.label, focusable: false })}${coveragePillHtml(option.coverage, { scope: option.label, focusable: false, besides: option.quick })}</span>${option.sub ? `<small>${escapeHtml(option.sub)}</small>` : ''}</button>`; }).join('') + '</div>';
|
|
14481
16302
|
}).join('');
|
|
14482
16303
|
let warning = '';
|
|
14483
16304
|
if (data.defaultUnavailable?.reason === 'refused') {
|
|
@@ -14514,15 +16335,22 @@
|
|
|
14514
16335
|
const source = currentExportSourceOption();
|
|
14515
16336
|
if (!source) return '';
|
|
14516
16337
|
const line = (q, scope) => (quickPillHtml(q) ? `<div class="export-quick-note" role="note"><b>${escapeHtml(scope)}:</b> ${escapeHtml(q.label)}. ${escapeHtml(q.tip || '')}</div>` : '');
|
|
14517
|
-
const selected = line(source.quick, source.label)
|
|
16338
|
+
const selected = line(source.quick, source.label)
|
|
16339
|
+
// #2554 slice 2: the selected source's unread drawing files, in their own line (a precise source can have them).
|
|
16340
|
+
+ (coveragePillHtml(source.coverage, { besides: source.quick })
|
|
16341
|
+
? `<div class="export-quick-note is-coverage" role="note"><b>${escapeHtml(source.label)}:</b> ${escapeHtml(source.coverage.text || source.coverage.short)} Files exported from it say so too.</div>` : '');
|
|
14518
16342
|
// #2521 row 5b: said BEFORE exporting, when this AWARE can only put a Quick model's label in an IFC's names.
|
|
14519
16343
|
const ifcNamesOnly = quickPillHtml(source.quick) && exportSourcesState.data && exportSourcesState.data.exportProvenance === 'name-only'
|
|
14520
16344
|
? '<div class="export-quick-note" role="note">An IFC exported now carries this label in its file name and project name only. Update AWARE from the bottom bar to also write it into the file\'s header and project properties.</div>'
|
|
14521
16345
|
: '';
|
|
14522
16346
|
const from = exportStateFrom;
|
|
14523
|
-
const
|
|
14524
|
-
&& !(source.selector.kind === 'latest-approved' && Number(source.version) === Number(from.version))
|
|
14525
|
-
|
|
16347
|
+
const filesListed = from && exportState && Object.values(exportState).some((e) => e && e.exportedAt)
|
|
16348
|
+
&& !(source.selector.kind === 'latest-approved' && Number(source.version) === Number(from.version));
|
|
16349
|
+
const filesScope = filesListed ? `Files below, exported from v${from.version}` : '';
|
|
16350
|
+
const files = (filesListed && from.quick ? line(from.quick, filesScope) : '')
|
|
16351
|
+
// #2554 slice 2: those files' unread drawing files too, when the version they came from left some.
|
|
16352
|
+
+ (filesListed && coveragePillHtml(from.coverage, { besides: from.quick })
|
|
16353
|
+
? `<div class="export-quick-note is-coverage" role="note"><b>${escapeHtml(filesScope)}:</b> ${escapeHtml(from.coverage.text || from.coverage.short)}</div>` : '');
|
|
14526
16354
|
return selected + ifcNamesOnly + files;
|
|
14527
16355
|
}
|
|
14528
16356
|
|
|
@@ -14603,6 +16431,7 @@
|
|
|
14603
16431
|
const approved = projectContractLifecycle === 'model' && exportSourcesState.status === 'ready' && !!currentExportSourceOption();
|
|
14604
16432
|
const approvalRefusal = approvalRefusalNote();
|
|
14605
16433
|
// Same 46px band every other project step carries (see the shared step-header rule in app.css).
|
|
16434
|
+
exportsPaintedGate = exportsLifecycleGateKey();
|
|
14606
16435
|
let html = '<div class="step-head"><span>Exports</span></div>' + exportSourceHtml();
|
|
14607
16436
|
if (!approved) {
|
|
14608
16437
|
// Same split as History's empty state (#490): with a model, Approve is genuinely the unlocking
|
|
@@ -14624,6 +16453,10 @@
|
|
|
14624
16453
|
? '<div class="ws-exports-gate">Drawing Filter saved — read the selected drawing content to build the model before exporting.</div>'
|
|
14625
16454
|
: approvalRefusal
|
|
14626
16455
|
? `<div class="ws-exports-gate">${escapeHtml(approvalRefusal)}</div>`
|
|
16456
|
+
: projectContractLifecycle === 'unknown'
|
|
16457
|
+
? (exportsLifecycleUnanswered
|
|
16458
|
+
? '<div class="ws-exports-gate">Couldn’t check what this project holds yet. <button type="button" data-exports-lifecycle-retry data-command-id="shell.workspace-stage-recheck#Exports">Try again</button></div>'
|
|
16459
|
+
: '<div class="ws-exports-gate">Checking what this project holds…</div>')
|
|
14627
16460
|
: hasModel
|
|
14628
16461
|
? `<div class="ws-exports-gate">Exports go out after sign-off — ` +
|
|
14629
16462
|
`<button type="button" id="ws-exports-approve">Approve this version</button> to enable them.</div>`
|
|
@@ -14732,23 +16565,51 @@
|
|
|
14732
16565
|
* for approval and export. The server therefore returns one authoritative value — `absent`,
|
|
14733
16566
|
* `filter-checkpoint`, or `model` — and both History and Exports consume that same answer.
|
|
14734
16567
|
*/
|
|
14735
|
-
async function projectContractState(projectId, appId) {
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
|
|
14742
|
-
|
|
14743
|
-
|
|
14744
|
-
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
16568
|
+
async function projectContractState(projectId, appId, stillWanted) {
|
|
16569
|
+
const budgetMs = 45000, attemptMs = 15000;
|
|
16570
|
+
const url = `/api/projects/${encodeURIComponent(projectId)}/contract-lifecycle?app=${encodeURIComponent(appId)}`;
|
|
16571
|
+
// A SLOW answer is not a missing one (#3139). On a loaded PC this route took 7-10 s while the old
|
|
16572
|
+
// single four-second deadline gave up on every try, so Model never opened however often the
|
|
16573
|
+
// person clicked. Each attempt now gets a longer deadline than the last (15 s, then what is left
|
|
16574
|
+
// of the budget), with a short pause between, until an answer arrives or the budget runs out.
|
|
16575
|
+
// The BUDGET is still a deadline, because a HANG is not an error and would never reach a catch:
|
|
16576
|
+
// every caller awaits this before painting, so without one a wedged connection leaves History
|
|
16577
|
+
// reading "Loading history…" and every Exports destination row on "Checking…" indefinitely.
|
|
16578
|
+
// This GET returns only the small lifecycle envelope, never the contract.
|
|
16579
|
+
// `stillWanted` lets a caller whose answer would be discarded (a project switch, a newer render) stop
|
|
16580
|
+
// asking, so superseded checks do not keep loading the very server that is already slow.
|
|
16581
|
+
const started = Date.now();
|
|
16582
|
+
const deadline = started + budgetMs;
|
|
16583
|
+
// `unknown` has its own unavailable UI and is never treated as `absent`. Say why in the console, since
|
|
16584
|
+
// the person's copy is the same for every cause.
|
|
16585
|
+
const gaveUp = (why, attempts) => {
|
|
16586
|
+
console.warn('[workspaces] project lifecycle check gave up', { projectId, why, attempts, elapsedMs: Date.now() - started });
|
|
14751
16587
|
return 'unknown';
|
|
16588
|
+
};
|
|
16589
|
+
for (let attempt = 0; ; attempt++) {
|
|
16590
|
+
const remaining = deadline - Date.now();
|
|
16591
|
+
if (remaining <= 0) return gaveUp('out of time', attempt);
|
|
16592
|
+
if (stillWanted && !stillWanted()) return 'unknown';
|
|
16593
|
+
let why = '';
|
|
16594
|
+
try {
|
|
16595
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(Math.min(remaining, attemptMs * 2 ** attempt)) });
|
|
16596
|
+
if (res.ok) {
|
|
16597
|
+
// Unknown responses fail closed: approval/export capability is granted only by an explicit
|
|
16598
|
+
// `model` lifecycle, never by a successful request with an unexpected body.
|
|
16599
|
+
const body = await res.json();
|
|
16600
|
+
return ['absent', 'filter-checkpoint', 'model'].includes(body && body.lifecycle) ? body.lifecycle : gaveUp('unexpected answer', attempt + 1);
|
|
16601
|
+
}
|
|
16602
|
+
// A busy or restarting server (5xx, 408, 429) may answer next time; any other refusal will not.
|
|
16603
|
+
if (!(res.status >= 500 || res.status === 408 || res.status === 429)) return gaveUp(`refused (${res.status})`, attempt + 1);
|
|
16604
|
+
why = `busy (${res.status})`;
|
|
16605
|
+
} catch (err) {
|
|
16606
|
+
// A timeout or network failure is worth another try; malformed JSON from a 200 is not.
|
|
16607
|
+
if (err instanceof SyntaxError) return gaveUp('malformed answer', attempt + 1);
|
|
16608
|
+
why = err && err.name || 'network';
|
|
16609
|
+
}
|
|
16610
|
+
const pause = Math.min(1000 * 2 ** attempt, 5000, deadline - Date.now());
|
|
16611
|
+
if (pause <= 0) return gaveUp(`out of time after ${why}`, attempt + 1);
|
|
16612
|
+
await new Promise((resolve) => setTimeout(resolve, pause));
|
|
14752
16613
|
}
|
|
14753
16614
|
}
|
|
14754
16615
|
|
|
@@ -14798,12 +16659,13 @@
|
|
|
14798
16659
|
console.error('[workspaces] exports refresh threw ' + (reason || '(no reason given)'), err);
|
|
14799
16660
|
// `err`, NOT `warn`, and the reason is in `showToast`'s own table rather than in taste: a `warn`
|
|
14800
16661
|
// auto-dismisses after 5 s while an `err` stays until it is closed. This message is long — the
|
|
14801
|
-
// trigger, the
|
|
16662
|
+
// trigger, the cause, and a two-clause recovery instruction — and it reports a programming
|
|
14802
16663
|
// error the reader can do nothing about except reopen the step. Five seconds is not enough to
|
|
14803
16664
|
// read it, and losing it leaves them looking at the half-painted card the bug just produced with
|
|
14804
16665
|
// no explanation at all, which is the silence this whole change removes. (Design review.)
|
|
14805
16666
|
showToast(
|
|
14806
|
-
|
|
16667
|
+
// #3097: the raw error is in the console line above, never in the toast.
|
|
16668
|
+
'Couldn’t refresh the exports view ' + (reason || 'just now') + ' because of a problem inside FloLess'
|
|
14807
16669
|
+ ' — leave the Exports step and open it again to retry.',
|
|
14808
16670
|
'err',
|
|
14809
16671
|
);
|
|
@@ -14878,18 +16740,25 @@
|
|
|
14878
16740
|
// inside the pane this fix is for, reachable by opening an empty project and clicking Exports
|
|
14879
16741
|
// while the open-time probe is still in flight.
|
|
14880
16742
|
const paintedWith = exportsHasModel;
|
|
16743
|
+
const handed = exportsLifecycleHanded?.gen === renderGen ? exportsLifecycleHanded.present : '';
|
|
16744
|
+
exportsLifecycleHanded = null;
|
|
16745
|
+
exportsLifecycleUnanswered = handed === 'unknown';
|
|
14881
16746
|
exportSourcesState.status = 'loading';
|
|
14882
16747
|
paintExports(current.approvedAt, restoreKind);
|
|
14883
|
-
const gen = ++modelPresenceGen;
|
|
14884
|
-
|
|
16748
|
+
const gen = handed ? modelPresenceGen : ++modelPresenceGen;
|
|
16749
|
+
exportsLifecycleWait = handed ? 0 : renderGen;
|
|
16750
|
+
const modelPresent = handed || await projectContractState(id, app,
|
|
16751
|
+
() => renderGen === exportsRenderGen && gen === modelPresenceGen && current?.id === id && !$wsExports.hidden);
|
|
14885
16752
|
// `renderGen` is listed for symmetry with the guard below, and it decides NOTHING here: this
|
|
14886
16753
|
// function bumps `exportsRenderGen` and then `modelPresenceGen` with no await between them, so a
|
|
14887
16754
|
// newer render moves both at once and `gen !== modelPresenceGen` has already caught it. The
|
|
14888
16755
|
// reason `modelPresenceGen` could not simply be reused is real but belongs to the LAST guard,
|
|
14889
16756
|
// where it is not checked at all. (Review round 5.)
|
|
16757
|
+
// An overtaken render returns here; syncExportsLifecycleGate redoes it when the overtaking check settles.
|
|
14890
16758
|
if (renderGen !== exportsRenderGen || gen !== modelPresenceGen || !current || current.id !== id || $wsExports.hidden) return;
|
|
14891
|
-
|
|
14892
|
-
if (
|
|
16759
|
+
exportsLifecycleWait = 0;
|
|
16760
|
+
if (!handed) applyModelPresence(modelPresent); // repaints the gate when its answer changed; this repaint restores focus too
|
|
16761
|
+
if (exportsHasModel !== paintedWith || exportsLifecycleUnanswered) paintExports(current.approvedAt, restoreKind);
|
|
14893
16762
|
let state = null;
|
|
14894
16763
|
let units = null; // the server's answer, applied below the staleness guard with the others
|
|
14895
16764
|
let filesFrom = null; // #2449: the approved version the listed files came from, same rule
|
|
@@ -14918,12 +16787,15 @@
|
|
|
14918
16787
|
// `checkpointPromise`, reintroduced one line up by the wait itself. The `return` on the line
|
|
14919
16788
|
// above made it worse: it abandoned the promise outright.
|
|
14920
16789
|
const sourcesRefused = !!approvalRefusalNote();
|
|
14921
|
-
|
|
14922
|
-
|
|
16790
|
+
// #3273: each with a deadline, because a request that never answers is not an error and would never reach the
|
|
16791
|
+
// failure branches below: the pane would sit on "Loading export sources…" for good.
|
|
16792
|
+
const bounded = { timeoutMs: EXPORTS_REFRESH_MS };
|
|
16793
|
+
const exportPromise = api(`/api/contract/${encodeURIComponent(app)}/exports?project=${encodeURIComponent(id)}`, bounded);
|
|
16794
|
+
const sourcePromise = sourcesRefused ? null : api(`/api/projects/${encodeURIComponent(id)}/export-sources`, bounded);
|
|
14923
16795
|
// Host readiness is intentionally not probed while painting Exports. A send preflight first
|
|
14924
16796
|
// establishes what the reviewed model would omit; only an authorized continuation may contact
|
|
14925
16797
|
// AWARE or a CAD bridge.
|
|
14926
|
-
const renderReadyPromise = hasRender ? api('/api/render/readiness') : Promise.resolve(null);
|
|
16798
|
+
const renderReadyPromise = hasRender ? api('/api/render/readiness', bounded) : Promise.resolve(null);
|
|
14927
16799
|
const [exportResult, renderReadyResult, sourceResult] = await Promise.allSettled([
|
|
14928
16800
|
exportPromise, renderReadyPromise, sourcePromise,
|
|
14929
16801
|
]);
|
|
@@ -14969,7 +16841,8 @@
|
|
|
14969
16841
|
// Prefer the server's own words, as the Tekla branch below already does. The route-gate
|
|
14970
16842
|
// 409s this endpoint while AWARE is still installing and says so actionably; replacing
|
|
14971
16843
|
// that with the generic line threw away the only sentence that told the user to wait.
|
|
14972
|
-
|
|
16844
|
+
// A deadline that ran out has no sentence for a person, so it takes the generic line.
|
|
16845
|
+
message: (renderReadyResult.reason && renderReadyResult.reason.name !== 'TimeoutError' && renderReadyResult.reason.message)
|
|
14973
16846
|
|| 'Could not check whether rendering is available.',
|
|
14974
16847
|
recovery: { action: 'retry', label: 'Check again' },
|
|
14975
16848
|
};
|
|
@@ -15187,7 +17060,7 @@
|
|
|
15187
17060
|
code === 'aware_too_old' ? (awareVersion
|
|
15188
17061
|
? `AWARE v${awareVersion} is too old to share a faithful model — Realistic and Shadowed need v${awareFloor} or later. Click ↑ Upgrade AWARE in the footer, then share again.`
|
|
15189
17062
|
: `Your installed AWARE is too old to share a faithful model — Realistic and Shadowed need v${awareFloor} or later. Click ↑ Upgrade AWARE in the footer, then share again.`) :
|
|
15190
|
-
(err
|
|
17063
|
+
errorText(err, { action: 'create the share link', unsure: 'Check the card for a share link before trying again.' }),
|
|
15191
17064
|
'warn');
|
|
15192
17065
|
} finally {
|
|
15193
17066
|
exportBusy.delete(busyKey);
|
|
@@ -15295,10 +17168,13 @@
|
|
|
15295
17168
|
const got = kind === 'render' && err && err.body && Array.isArray(err.body.rendered)
|
|
15296
17169
|
? err.body.rendered.length : 0;
|
|
15297
17170
|
publishedDespiteFailure = got > 0;
|
|
17171
|
+
// #3097: the server's sentence or the shared one (errorText), never the error's own text.
|
|
17172
|
+
const exportAction = kind === 'render' ? 'finish the render' : 'finish that export';
|
|
17173
|
+
if (got > 0 && !personText(err && err.body)) console.warn('[exports] the render stopped partway', err);
|
|
15298
17174
|
showToast(
|
|
15299
17175
|
got > 0
|
|
15300
|
-
? `${err && err.
|
|
15301
|
-
: (err
|
|
17176
|
+
? `${personText(err && err.body) || 'Rendering didn’t finish'} — ${got} viewpoint${got === 1 ? '' : 's'} did finish and ${got === 1 ? 'is' : 'are'} saved.`
|
|
17177
|
+
: errorText(err, { action: exportAction, unsure: 'Check the exports list before trying again.' }),
|
|
15302
17178
|
'warn');
|
|
15303
17179
|
} finally {
|
|
15304
17180
|
exportBusy.delete(busyKey);
|
|
@@ -15500,7 +17376,7 @@
|
|
|
15500
17376
|
try {
|
|
15501
17377
|
await api(endpoint, { method: 'POST', body: JSON.stringify({ path: st.path }) });
|
|
15502
17378
|
} catch (err) {
|
|
15503
|
-
const detail = err && err.body
|
|
17379
|
+
const detail = personText(err && err.body);
|
|
15504
17380
|
showToast(detail ? `${failMsg} — ${detail}` : failMsg, 'warn');
|
|
15505
17381
|
}
|
|
15506
17382
|
}
|
|
@@ -15517,7 +17393,7 @@
|
|
|
15517
17393
|
try {
|
|
15518
17394
|
await api(`/api/projects/${encodeURIComponent(projectId)}/exports/open`, { method: 'POST' });
|
|
15519
17395
|
} catch (err) {
|
|
15520
|
-
const detail = err && err.body
|
|
17396
|
+
const detail = personText(err && err.body);
|
|
15521
17397
|
const failMsg = 'Couldn’t open the exports folder';
|
|
15522
17398
|
showToast(detail ? `${failMsg} — ${detail}` : failMsg, 'warn');
|
|
15523
17399
|
}
|
|
@@ -15544,6 +17420,8 @@
|
|
|
15544
17420
|
if (e.target.closest('#ws-exports-approve')) { approveProject(); return; }
|
|
15545
17421
|
// The no-model gate's real next step — mirrors History's #hist-go-drawings.
|
|
15546
17422
|
if (e.target.closest('#ws-exports-go-drawings')) { chooseStep('drawings'); return; }
|
|
17423
|
+
// #3139: the lifecycle check ran out of time; ask again.
|
|
17424
|
+
if (e.target.closest('[data-exports-lifecycle-retry]')) { safeRenderExports('when you asked to check again'); return; }
|
|
15547
17425
|
if (e.target.closest('[data-open-exports-folder]')) { openExportsFolder(); return; }
|
|
15548
17426
|
const details = e.target.closest('[data-export-details]');
|
|
15549
17427
|
if (details) { showExportReceiptDetails(details.dataset.exportDetails, details); return; }
|
|
@@ -16030,7 +17908,7 @@
|
|
|
16030
17908
|
const skipped = Array.isArray(out && out.omitted) ? out.omitted.length : 0;
|
|
16031
17909
|
showToast(`Added to the design set${out && out.label ? ` as “${out.label}”` : ''}${skipped ? `, without ${skipped} file${skipped === 1 ? '' : 's'} it could not store` : ''}`, skipped ? 'warn' : 'ok');
|
|
16032
17910
|
if (current === proj) { kbInvalidateRefs(); renderKnowledge(); }
|
|
16033
|
-
} catch (err) { showToast((err && err.body
|
|
17911
|
+
} catch (err) { showToast(personText(err && err.body) || 'Couldn’t add them to the design set. Add them from Knowledge.', 'warn'); }
|
|
16034
17912
|
} } });
|
|
16035
17913
|
}
|
|
16036
17914
|
lastRevState = 'pending';
|
|
@@ -16616,6 +18494,29 @@
|
|
|
16616
18494
|
if (current && last?.req?.project === current.id) syncFilterFlo(last.req, last.view);
|
|
16617
18495
|
}
|
|
16618
18496
|
document.addEventListener('floless:chat-indicator', resyncFilterFlo);
|
|
18497
|
+
// Flo on the 3D model shows what AI Chat is doing on THIS project: the chat's own live mood while it replies, and
|
|
18498
|
+
// Your call while it waits for the person's answer, approval or Do it on a suggested change. Another project's
|
|
18499
|
+
// conversation leaves it idle.
|
|
18500
|
+
function modelFloMood() {
|
|
18501
|
+
const shell = document.getElementById('ai-chat-shell');
|
|
18502
|
+
if (!current || !shell || window.flolessChat?.scopeProjectId?.() !== current.id) return 'idle';
|
|
18503
|
+
if (shell.dataset.approvalPending === 'true') return 'yourcall';
|
|
18504
|
+
const mood = window.flolessChat?.floMood?.();
|
|
18505
|
+
return mood === 'yourcall' || mood === 'thinking' || mood === 'working' ? mood : 'idle';
|
|
18506
|
+
}
|
|
18507
|
+
// The chat changes mood mid-reply without announcing it, so while a model is open the mood is read once a second
|
|
18508
|
+
// (a few in-memory reads) and passed on only when it changed.
|
|
18509
|
+
function syncModelFlo() {
|
|
18510
|
+
const frame = frames.model;
|
|
18511
|
+
if (!frame || !frame.dataset.loaded) { syncModelFlo.sent = null; return; }
|
|
18512
|
+
const mood = modelFloMood();
|
|
18513
|
+
if (mood === syncModelFlo.sent) return;
|
|
18514
|
+
try { frame.contentWindow?.flolessModelFlo?.({ mood }); syncModelFlo.sent = mood; }
|
|
18515
|
+
catch (err) { if (err?.name !== 'SecurityError' && !syncModelFlo.warned) { syncModelFlo.warned = true; console.warn('Flo could not show the AI on the model', err); } }
|
|
18516
|
+
}
|
|
18517
|
+
document.addEventListener('floless:chat-indicator', syncModelFlo);
|
|
18518
|
+
frames.model?.addEventListener('load', () => { syncModelFlo.sent = null; setTimeout(syncModelFlo, 0); });
|
|
18519
|
+
setInterval(syncModelFlo, 1000);
|
|
16619
18520
|
// #2926: Flo's "Answer in AI Chat" opens the read's own conversation, where the question is.
|
|
16620
18521
|
window.addEventListener('floless:filter-flo-answer', () => {
|
|
16621
18522
|
const chatId = syncFilterFlo.last?.req?.chatConversation?.chatId;
|
|
@@ -16801,7 +18702,7 @@
|
|
|
16801
18702
|
// into test harnesses, where a free name it assigns would not exist. A review opened before this
|
|
16802
18703
|
// settles (a fresh page, a slow disk) reads in millimetres, never in nothing.
|
|
16803
18704
|
import('./display-units.js').then((m) => { reviewUnitsModule = m; }, () => {});
|
|
16804
|
-
const reviewUnits = () => (current
|
|
18705
|
+
const reviewUnits = () => shownUnits(current);
|
|
16805
18706
|
const reviewElevation = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatElevation(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
16806
18707
|
const reviewLength = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatLength(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
16807
18708
|
const isEndpointValue = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
|
|
@@ -18290,8 +20191,10 @@
|
|
|
18290
20191
|
return `<span class="gate-badge model findings-accepted" data-tip="${escapeAttr(`Sign-off gate. ${acceptedNote}`)}">Model</span>`;
|
|
18291
20192
|
if (gate === 'model')
|
|
18292
20193
|
return '<span class="gate-badge model" data-tip="Sign-off gate — this version was approved">Model</span>';
|
|
20194
|
+
// #3223 rank 7: never "Approve to sign it off" here. Approving does not sign off this row; it saves the reviewed model
|
|
20195
|
+
// as a new version above it, and reading the badge as the thing approved is what made "Approved as v2" look doubled.
|
|
18293
20196
|
if (kind === 'revision-read')
|
|
18294
|
-
return `<span class="gate-badge ai-read" data-tip="AI read
|
|
20197
|
+
return `<span class="gate-badge ai-read" data-tip="AI read: what the AI composed from ${Number(n) <= 1 ? 'the initial' : 'a revised'} drawing set. It is not an approved version. Approving saves the model you reviewed as a new version.">AI read</span>`;
|
|
18295
20198
|
return '<span class="gate-badge" data-tip="Unsigned — a working-tree restore, not a sign-off">unsigned</span>';
|
|
18296
20199
|
};
|
|
18297
20200
|
|
|
@@ -18603,7 +20506,7 @@
|
|
|
18603
20506
|
`<td><span class="ver${v.current ? ' cur' : ''}">v${escapeHtml(String(v.n))}</span></td>` +
|
|
18604
20507
|
`<td class="htime">${escapeHtml(histWhen(v.ts))}</td>` +
|
|
18605
20508
|
`<td><span class="hby">${avatarFor(v.author)}${escapeHtml(v.author)}</span></td>` +
|
|
18606
|
-
`<td>${gateBadge(v.gate, v.kind, v.n, typeof v.acceptedImportFindingsNote === 'string' ? v.acceptedImportFindingsNote : '')}${quickPillHtml(v.quick, { scope: `v${v.n}` })}</td>` +
|
|
20509
|
+
`<td>${gateBadge(v.gate, v.kind, v.n, typeof v.acceptedImportFindingsNote === 'string' ? v.acceptedImportFindingsNote : '')}${quickPillHtml(v.quick, { scope: `v${v.n}` })}${coveragePillHtml(v.coverage, { scope: `v${v.n}`, besides: v.quick })}</td>` +
|
|
18607
20510
|
`<td class="change">${revisionNoteHtml(v)}${changeCellHtml(v, meta)}${diffStatus}</td>` +
|
|
18608
20511
|
`<td>${action}</td></tr>`;
|
|
18609
20512
|
// The disclosure row is always emitted (hidden) so toggling is a pure show/hide + lazy fetch.
|
|
@@ -18636,7 +20539,7 @@
|
|
|
18636
20539
|
const resume = allowed.includes('resume')
|
|
18637
20540
|
? `<button type="button" class="btn-mini" data-resume-checkpoint="${escapeAttr(String(saved.id))}" data-tip="Switch the working copy to this exact saved checkpoint">Resume exact checkpoint</button>`
|
|
18638
20541
|
: '';
|
|
18639
|
-
return `<article class="saved-work-card"><div><b>${escapeHtml(base)}</b>${quickPillHtml(saved.quick, { scope: 'This checkpoint' })}<span>${escapeHtml(histWhen(saved.capturedAt))} · ${escapeHtml(String(saved.id || '').slice(0, 8))}</span></div>`
|
|
20542
|
+
return `<article class="saved-work-card"><div><b>${escapeHtml(base)}</b>${quickPillHtml(saved.quick, { scope: 'This checkpoint' })}${coveragePillHtml(saved.coverage, { scope: 'This checkpoint', besides: saved.quick })}<span>${escapeHtml(histWhen(saved.capturedAt))} · ${escapeHtml(String(saved.id || '').slice(0, 8))}</span></div>`
|
|
18640
20543
|
+ `<p>This checkpoint stays attached to its original approved base; it is never applied backward into another revision.</p>${resume}</article>`;
|
|
18641
20544
|
}).join('')}</div>`;
|
|
18642
20545
|
}
|
|
@@ -18646,6 +20549,19 @@
|
|
|
18646
20549
|
// #2470 R6.5b: each ledger render is numbered, so one overtaken by a newer render (the person went to Activity and back
|
|
18647
20550
|
// while it was reading) neither paints nor speaks.
|
|
18648
20551
|
let historyRenderGen = 0;
|
|
20552
|
+
// #3139: the ledger render that is waiting on its lifecycle check (0 when none). A check from elsewhere that bumps
|
|
20553
|
+
// modelPresenceGen overtakes that render, which then returns without painting; syncHistoryLifecycleWait renders
|
|
20554
|
+
// again so the pane is never left on "Loading history…" after every check has stopped.
|
|
20555
|
+
// That render is told (by its generation) that an answer is already applied, so it does not ask the server again; it
|
|
20556
|
+
// reads the latest applied answer when it gets there, because it first awaits the ledger and a newer check may land.
|
|
20557
|
+
let historyLifecycleWait = 0;
|
|
20558
|
+
let historyLifecycleHanded = 0;
|
|
20559
|
+
function syncHistoryLifecycleWait() {
|
|
20560
|
+
if (!historyLifecycleWait || historyLifecycleWait !== historyRenderGen || !current || $wsHistory.hidden) return;
|
|
20561
|
+
historyLifecycleWait = 0;
|
|
20562
|
+
historyLifecycleHanded = historyRenderGen + 1;
|
|
20563
|
+
renderHistory();
|
|
20564
|
+
}
|
|
18649
20565
|
/**
|
|
18650
20566
|
* The ledger was on screen and is being hidden (setStep): a render still reading neither paints nor speaks, and a
|
|
18651
20567
|
* revision-note editor it opened will not reopen or repaint it. A note the person already pressed Save on is still
|
|
@@ -18755,10 +20671,15 @@
|
|
|
18755
20671
|
//
|
|
18756
20672
|
// Built with DOM methods rather than innerHTML — the label comes from a descriptor, so it is the
|
|
18757
20673
|
// same "don't route it through a string template at all" rule `importFailedCmdRow` follows.
|
|
18758
|
-
const
|
|
18759
|
-
|
|
20674
|
+
const handed = historyLifecycleHanded === renderGen;
|
|
20675
|
+
historyLifecycleHanded = 0;
|
|
20676
|
+
const gen = handed ? modelPresenceGen : ++modelPresenceGen;
|
|
20677
|
+
historyLifecycleWait = handed ? 0 : renderGen;
|
|
20678
|
+
const hasModel = handed ? projectContractLifecycle : await projectContractState(id, current.app,
|
|
20679
|
+
() => gen === modelPresenceGen && current?.id === id && !$wsHistory.hidden && renderGen === historyRenderGen);
|
|
18760
20680
|
if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden || renderGen !== historyRenderGen) return;
|
|
18761
|
-
|
|
20681
|
+
historyLifecycleWait = 0;
|
|
20682
|
+
if (!handed) applyModelPresence(hasModel); // one answer, every surface — History used to keep its own
|
|
18762
20683
|
const empty = document.createElement('div');
|
|
18763
20684
|
empty.className = 'hist-empty';
|
|
18764
20685
|
const emptyRefusal = approvalRefusalNote();
|
|
@@ -18775,6 +20696,14 @@
|
|
|
18775
20696
|
empty.append(v1, ' and start the ledger.');
|
|
18776
20697
|
} else if (hasModel === 'filter-checkpoint') {
|
|
18777
20698
|
empty.append('Drawing Filter saved. Read the selected drawing content to build the model; History starts after the first drawing read is complete.');
|
|
20699
|
+
} else if (hasModel === 'unknown') {
|
|
20700
|
+
// #3139: the check ran out of time. "Nothing here yet" would claim an empty project FloLess never confirmed.
|
|
20701
|
+
const btn = document.createElement('button');
|
|
20702
|
+
btn.type = 'button';
|
|
20703
|
+
btn.id = 'hist-lifecycle-retry';
|
|
20704
|
+
btn.dataset.commandId = 'shell.workspace-stage-recheck#History';
|
|
20705
|
+
btn.textContent = 'Try again';
|
|
20706
|
+
empty.append('Couldn’t check what this project holds yet. ', btn);
|
|
18778
20707
|
} else {
|
|
18779
20708
|
const btn = document.createElement('button');
|
|
18780
20709
|
btn.type = 'button';
|
|
@@ -19140,16 +21069,20 @@
|
|
|
19140
21069
|
wrap.appendChild(btn);
|
|
19141
21070
|
return wrap;
|
|
19142
21071
|
}
|
|
19143
|
-
function renderDiffPanel(panel, diff, quick) {
|
|
21072
|
+
function renderDiffPanel(panel, diff, quick, coverage) {
|
|
19144
21073
|
panel.textContent = '';
|
|
19145
21074
|
panel.appendChild(diffBasePicker(diff));
|
|
19146
21075
|
for (const c of diffCautions(diff.warnings)) panel.appendChild(c); // above the numbers — context for reading them
|
|
19147
21076
|
// #2521 row 5: each side says what IT rests on, above the tonnage, so a Quick side never reads as precise.
|
|
19148
21077
|
const sides = quick ? [[quick.from, `v${diff.from}`], [quick.to, `v${diff.to}`]].filter(([q]) => quickPillHtml(q)) : [];
|
|
19149
|
-
|
|
21078
|
+
// #2554 slice 2: and which drawing files each side did not read, beside its label.
|
|
21079
|
+
const covers = coverage ? [[coverage.from, quick && quick.from, `v${diff.from}`], [coverage.to, quick && quick.to, `v${diff.to}`]]
|
|
21080
|
+
.filter(([c, q]) => coveragePillHtml(c, { besides: q })) : [];
|
|
21081
|
+
if (sides.length || covers.length) {
|
|
19150
21082
|
const note = el('div', 'hd-quick');
|
|
19151
21083
|
note.setAttribute('role', 'note');
|
|
19152
|
-
note.innerHTML = sides.map(([q, scope]) => quickPillHtml(q, { scope, showScope: true }))
|
|
21084
|
+
note.innerHTML = sides.map(([q, scope]) => quickPillHtml(q, { scope, showScope: true }))
|
|
21085
|
+
.concat(covers.map(([c, q, scope]) => coveragePillHtml(c, { scope, showScope: true, besides: q }))).join(' ');
|
|
19153
21086
|
panel.appendChild(note);
|
|
19154
21087
|
}
|
|
19155
21088
|
panel.appendChild(diffNetHeader(diff.tonnage));
|
|
@@ -19279,8 +21212,9 @@
|
|
|
19279
21212
|
// and server ship together, so that window is a half-finished upgrade, not a supported state.
|
|
19280
21213
|
if (!hasStatus && legacyUnreadableDiff(response.diff)) return { kind: 'unavailable' };
|
|
19281
21214
|
if (!wellFormedDiff(response.diff)) throw new Error('invalid comparison response');
|
|
21215
|
+
const coverage = response.coverage && typeof response.coverage === 'object' ? { coverage: response.coverage } : {};
|
|
19282
21216
|
return response.quick && typeof response.quick === 'object'
|
|
19283
|
-
? { kind: 'available', diff: response.diff, quick: response.quick } : { kind: 'available', diff: response.diff };
|
|
21217
|
+
? { kind: 'available', diff: response.diff, quick: response.quick, ...coverage } : { kind: 'available', diff: response.diff, ...coverage };
|
|
19284
21218
|
}
|
|
19285
21219
|
function restoreDiffFocus(panel, n) {
|
|
19286
21220
|
const target = panel.querySelector('.hd-base')
|
|
@@ -19329,7 +21263,10 @@
|
|
|
19329
21263
|
const box = el('div', 'hd-err');
|
|
19330
21264
|
box.setAttribute('role', 'status');
|
|
19331
21265
|
box.setAttribute('aria-live', 'polite');
|
|
19332
|
-
|
|
21266
|
+
// #3097: the server's own sentence when it wrote one; a malformed reply or a lost answer stays in the console.
|
|
21267
|
+
const said = personText(err && err.body);
|
|
21268
|
+
if (!said) console.warn('[history] the comparison did not load', err);
|
|
21269
|
+
box.appendChild(document.createTextNode('Couldn’t load the comparison' + (said ? ` — ${said}` : '') + ' — '));
|
|
19333
21270
|
const retry = el('button', null, 'try again');
|
|
19334
21271
|
retry.type = 'button';
|
|
19335
21272
|
retry.dataset.diffRetry = String(n);
|
|
@@ -19343,7 +21280,7 @@
|
|
|
19343
21280
|
panel.setAttribute('aria-busy', 'false');
|
|
19344
21281
|
if (progress) progress.textContent = '';
|
|
19345
21282
|
if (decoded.kind === 'unavailable') renderDiffUnavailable(panel);
|
|
19346
|
-
else renderDiffPanel(panel, decoded.diff, decoded.quick);
|
|
21283
|
+
else renderDiffPanel(panel, decoded.diff, decoded.quick, decoded.coverage);
|
|
19347
21284
|
if (opts && opts.restoreBaseFocus) restoreDiffFocus(panel, n);
|
|
19348
21285
|
}
|
|
19349
21286
|
function toggleDiff(btn) {
|
|
@@ -19484,7 +21421,7 @@
|
|
|
19484
21421
|
: `Added to the design set${out && out.label ? ` as “${out.label}”` : ''}${skipped ? `, without ${skipped} file${skipped === 1 ? '' : 's'} it could not store` : ''}`, skipped ? 'warn' : 'ok');
|
|
19485
21422
|
if (current === proj) kbInvalidateRefs();
|
|
19486
21423
|
})
|
|
19487
|
-
.catch((err) => showToast((err && err.body
|
|
21424
|
+
.catch((err) => showToast(personText(err && err.body) || 'Couldn’t add these drawings to the design set. Try again.', 'warn'))
|
|
19488
21425
|
.finally(() => dsLand.removeAttribute('aria-busy'));
|
|
19489
21426
|
return;
|
|
19490
21427
|
}
|
|
@@ -19497,6 +21434,8 @@
|
|
|
19497
21434
|
// The no-model empty state's real next step: go read a drawing. Same handler shape as the
|
|
19498
21435
|
// Approve it replaces, so the pane keeps owning its own inline actions.
|
|
19499
21436
|
if (e.target.closest('#hist-go-drawings')) { chooseStep('drawings'); return; }
|
|
21437
|
+
// #3139: the lifecycle check ran out of time; ask again from the top.
|
|
21438
|
+
if (e.target.closest('#hist-lifecycle-retry')) { renderHistory(); return; }
|
|
19500
21439
|
if (e.target.closest('.hc-cancel')) { closeRollbackConfirm(); return; }
|
|
19501
21440
|
const go = e.target.closest('[data-hc-go]');
|
|
19502
21441
|
if (go) { rollbackTo(Number(go.dataset.hcGo)); return; }
|
|
@@ -19796,9 +21735,8 @@
|
|
|
19796
21735
|
} catch (err) {
|
|
19797
21736
|
finishProgress();
|
|
19798
21737
|
const inUse = projectFolderInUseMessage(err);
|
|
19799
|
-
showToast(inUse || (action === 'duplicate'
|
|
19800
|
-
|
|
19801
|
-
: 'Action failed: ' + (err && err.message || err)), 'warn', inUse ? { persistent: true } : undefined);
|
|
21738
|
+
showToast(inUse || errorText(err, { action: action === 'duplicate' ? 'duplicate this project' : 'finish that',
|
|
21739
|
+
unsure: 'Check the project list before trying again.' }), 'warn', inUse ? { persistent: true } : undefined);
|
|
19802
21740
|
}
|
|
19803
21741
|
finally { finishProgress(); projActionBusy = false; }
|
|
19804
21742
|
loadProjects();
|
|
@@ -19881,51 +21819,186 @@
|
|
|
19881
21819
|
// it can start at this project's exact exports directory; the old browser download anchor could be
|
|
19882
21820
|
// blocked and always targeted Downloads. Cancel is an ordinary no-op. A per-project guard prevents
|
|
19883
21821
|
// duplicate dialogs without blocking unrelated project actions while the chooser is open.
|
|
19884
|
-
async function downloadProjectExport(id, label) {
|
|
19885
|
-
|
|
19886
|
-
|
|
21822
|
+
async function downloadProjectExport(id, label, choice) {
|
|
21823
|
+
// #2732: the choice made after an oversize warning travels in the query, the same one the Save route takes.
|
|
21824
|
+
const query = new URLSearchParams();
|
|
21825
|
+
if (choice) {
|
|
21826
|
+
query.set('inspected', choice.inspected);
|
|
21827
|
+
if (choice.everything) query.set('everything', 'true');
|
|
21828
|
+
for (const folder of choice.leaveOut) query.append('leaveOut', folder);
|
|
21829
|
+
}
|
|
21830
|
+
const qs = query.toString();
|
|
21831
|
+
const res = await fetch(`/api/projects/${encodeURIComponent(id)}/export.zip${qs ? `?${qs}` : ''}`);
|
|
21832
|
+
if (!res.ok) {
|
|
21833
|
+
const body = await res.json().catch(() => ({}));
|
|
21834
|
+
throw Object.assign(new Error(personText(body) || failureCopy({ status: res.status, body }, { action: 'export this project', retrySafe: true }).text), { status: res.status, body });
|
|
21835
|
+
}
|
|
19887
21836
|
const blob = await res.blob();
|
|
19888
21837
|
const cd = res.headers.get('content-disposition') || '';
|
|
19889
21838
|
const name = (cd.match(/filename="?([^"]+)"?/) || [])[1] || `${label}.zip`;
|
|
21839
|
+
// #2732: what the server actually left out, and whether the archive is within what import accepts (when known).
|
|
21840
|
+
let leftOut = [];
|
|
21841
|
+
try { const parsed = JSON.parse(decodeURIComponent(res.headers.get('x-floless-archive-left-out') || '%5B%5D')); if (Array.isArray(parsed)) leftOut = parsed.filter((f) => typeof f === 'string'); } catch { leftOut = []; }
|
|
21842
|
+
const fit = res.headers.get('x-floless-archive-within-import-limit');
|
|
21843
|
+
const withinImportFileLimit = fit === 'true' ? true : fit === 'false' ? false : null;
|
|
19890
21844
|
const url = URL.createObjectURL(blob);
|
|
19891
21845
|
const a = document.createElement('a');
|
|
19892
21846
|
a.href = url; a.download = name;
|
|
19893
21847
|
document.body.appendChild(a); a.click(); a.remove();
|
|
19894
21848
|
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
19895
|
-
return name;
|
|
21849
|
+
return { filename: name, leftOut, withinImportFileLimit };
|
|
21850
|
+
}
|
|
21851
|
+
|
|
21852
|
+
/**
|
|
21853
|
+
* #2732: the question when a project is past the archive bounds. Resolves { leaveOut, everything } (the folders to leave
|
|
21854
|
+
* out, earlier ones kept) or null when the person cancels; nothing is exported until they choose.
|
|
21855
|
+
*/
|
|
21856
|
+
let exportOversizeAsk = null;
|
|
21857
|
+
const xoNumber = (value) => Number(value || 0).toLocaleString('en-US');
|
|
21858
|
+
const xoPath = (path) => `<span class="xo-path">${escapeHtml(path)}</span>`;
|
|
21859
|
+
const XO_MAX_LEAVE_OUT = 16;
|
|
21860
|
+
const XO_TITLES = {
|
|
21861
|
+
files: 'Too many files for one archive',
|
|
21862
|
+
folders: 'Too many folders for one archive',
|
|
21863
|
+
depth: 'Folders nested too deep for one archive',
|
|
21864
|
+
time: 'Listing this project’s files is taking too long',
|
|
21865
|
+
};
|
|
21866
|
+
function exportOversizeLead(o) {
|
|
21867
|
+
const lead = {
|
|
21868
|
+
files: `FloLess stopped counting at ${xoNumber(o.limit)} files, the most it can import from one archive.`,
|
|
21869
|
+
folders: `This project holds more than ${xoNumber(o.limit)} folders, more than one archive should hold.`,
|
|
21870
|
+
depth: `A folder inside ${xoPath(String(o.deepFolder || '').split('/').slice(0, 2).join('/'))} is nested more than ${xoNumber(o.limit)} folders deep.`,
|
|
21871
|
+
time: `FloLess was still listing this project’s files after ${xoNumber(o.limit / 1000)} seconds.`,
|
|
21872
|
+
}[o.reason] || 'This project has more files than one archive should hold.';
|
|
21873
|
+
const seen = o.folder && o.folderFiles > 0 && o.reason !== 'depth'
|
|
21874
|
+
? ` At least ${xoNumber(o.folderFiles)} of the files it saw are in ${xoPath(o.folder)}.` : '';
|
|
21875
|
+
return lead + seen;
|
|
21876
|
+
}
|
|
21877
|
+
function askExportOversize(oversize) {
|
|
21878
|
+
const root = document.getElementById('export-oversize-modal');
|
|
21879
|
+
if (!root) return Promise.resolve(null);
|
|
21880
|
+
if (exportOversizeAsk) exportOversizeAsk.close(null);
|
|
21881
|
+
const o = oversize || {};
|
|
21882
|
+
const leftOut = Array.isArray(o.leftOut) ? o.leftOut : [];
|
|
21883
|
+
const canLeaveOut = !!o.folder && leftOut.length < XO_MAX_LEAVE_OUT;
|
|
21884
|
+
const $leave = document.getElementById('xo-leave-out');
|
|
21885
|
+
const $everything = document.getElementById('xo-everything');
|
|
21886
|
+
const $leftOut = document.getElementById('xo-left-out');
|
|
21887
|
+
const returnTo = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
21888
|
+
document.getElementById('xo-title').textContent = XO_TITLES[o.reason] || XO_TITLES.files;
|
|
21889
|
+
document.getElementById('xo-sub').innerHTML = exportOversizeLead(o);
|
|
21890
|
+
const leaveLine = canLeaveOut
|
|
21891
|
+
? `<li><b>Leave this folder out</b> — faster. The archive holds a note naming what was left out.</li>`
|
|
21892
|
+
: `<li>No folder FloLess saw can be left out${o.folder ? ` (one archive can leave out at most ${XO_MAX_LEAVE_OUT})` : ': only folders inside knowledge or exports can be'}.</li>`;
|
|
21893
|
+
document.getElementById('xo-choices').innerHTML = leaveLine
|
|
21894
|
+
+ `<li><b>Export everything</b> — slower. FloLess can import an archive of up to 10,000 files (and 2 GB once unzipped).</li>`;
|
|
21895
|
+
const shown = leftOut.slice(0, 3).map(escapeHtml).join(', ') + (leftOut.length > 3 ? ` +${leftOut.length - 3} more` : '');
|
|
21896
|
+
$leftOut.hidden = !leftOut.length;
|
|
21897
|
+
$leftOut.innerHTML = leftOut.length ? `Already left out, and staying out: ${shown}` : '';
|
|
21898
|
+
$leave.hidden = !canLeaveOut;
|
|
21899
|
+
// With nothing to leave out, Export everything is the one way forward, so it is the primary button.
|
|
21900
|
+
$everything.classList.toggle('primary', !canLeaveOut);
|
|
21901
|
+
$everything.textContent = leftOut.length ? 'Export the rest' : 'Export everything';
|
|
21902
|
+
return new Promise((resolve) => {
|
|
21903
|
+
const close = (result) => {
|
|
21904
|
+
if (exportOversizeAsk !== ask) return;
|
|
21905
|
+
exportOversizeAsk = null;
|
|
21906
|
+
root.classList.remove('show');
|
|
21907
|
+
root.removeEventListener('click', onClick);
|
|
21908
|
+
document.removeEventListener('keydown', onKey, true);
|
|
21909
|
+
if (returnTo && returnTo.isConnected) returnTo.focus();
|
|
21910
|
+
resolve(result);
|
|
21911
|
+
};
|
|
21912
|
+
function onClick(event) {
|
|
21913
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
21914
|
+
if (!target) return;
|
|
21915
|
+
if (target.closest('#xo-cancel')) close(null);
|
|
21916
|
+
else if (target.closest('#xo-everything')) close({ leaveOut: leftOut, everything: true });
|
|
21917
|
+
else if (target.closest('#xo-leave-out') && canLeaveOut) close({ leaveOut: [...leftOut, o.folder], everything: false });
|
|
21918
|
+
}
|
|
21919
|
+
function onKey(event) {
|
|
21920
|
+
if (!root.classList.contains('show')) return;
|
|
21921
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); close(null); return; }
|
|
21922
|
+
if (event.key !== 'Tab') return;
|
|
21923
|
+
const focusable = Array.from(root.querySelectorAll('button')).filter((element) => !element.hidden && element.getClientRects().length);
|
|
21924
|
+
if (!focusable.length) return;
|
|
21925
|
+
const first = focusable[0]; const last = focusable[focusable.length - 1];
|
|
21926
|
+
if (event.shiftKey && (document.activeElement === first || !root.contains(document.activeElement))) { event.preventDefault(); last.focus(); }
|
|
21927
|
+
else if (!event.shiftKey && (document.activeElement === last || !root.contains(document.activeElement))) { event.preventDefault(); first.focus(); }
|
|
21928
|
+
}
|
|
21929
|
+
const ask = { close };
|
|
21930
|
+
exportOversizeAsk = ask;
|
|
21931
|
+
root.addEventListener('click', onClick);
|
|
21932
|
+
document.addEventListener('keydown', onKey, true);
|
|
21933
|
+
root.classList.add('show');
|
|
21934
|
+
(canLeaveOut ? $leave : $everything).focus();
|
|
21935
|
+
});
|
|
19896
21936
|
}
|
|
21937
|
+
onBackdropDismiss(document.getElementById('export-oversize-modal'), () => { if (exportOversizeAsk) exportOversizeAsk.close(null); }, () => !!exportOversizeAsk);
|
|
19897
21938
|
|
|
19898
21939
|
async function exportProject(id) {
|
|
19899
21940
|
if (projectExportBusy.has(id)) return;
|
|
19900
21941
|
const proj = projects.find((p) => p.id === id);
|
|
19901
21942
|
const label = proj ? proj.name : id;
|
|
19902
21943
|
projectExportBusy.add(id);
|
|
19903
|
-
|
|
19904
|
-
|
|
21944
|
+
let dismissProgress = null;
|
|
21945
|
+
const startProgress = () => { if (!dismissProgress) dismissProgress = showToast(`Exporting “${label}”…`, 'progress'); };
|
|
19905
21946
|
const finishProgress = () => {
|
|
19906
|
-
if (!
|
|
19907
|
-
|
|
19908
|
-
dismissProgress
|
|
21947
|
+
if (!dismissProgress) return;
|
|
21948
|
+
const dismiss = dismissProgress;
|
|
21949
|
+
dismissProgress = null;
|
|
21950
|
+
dismiss();
|
|
21951
|
+
};
|
|
21952
|
+
// #2732: the Save route first, the browser download where the Save dialog is unavailable; both take the same choice.
|
|
21953
|
+
let viaDownload = false;
|
|
21954
|
+
const exportOnce = async (choice) => {
|
|
21955
|
+
if (!viaDownload) {
|
|
21956
|
+
try {
|
|
21957
|
+
return await api(`/api/projects/${encodeURIComponent(id)}/export/save`, { method: 'POST', body: JSON.stringify(choice ? { oversize: choice } : {}) });
|
|
21958
|
+
} catch (err) {
|
|
21959
|
+
if (!(err && err.body && err.body.code === 'native-save-unavailable')) throw err;
|
|
21960
|
+
viaDownload = true;
|
|
21961
|
+
}
|
|
21962
|
+
}
|
|
21963
|
+
return downloadProjectExport(id, label, choice);
|
|
19909
21964
|
};
|
|
19910
21965
|
try {
|
|
19911
|
-
|
|
19912
|
-
|
|
19913
|
-
|
|
19914
|
-
|
|
19915
|
-
track('workspace_project_exported', { app: proj ? proj.app : undefined });
|
|
19916
|
-
} catch (err) {
|
|
19917
|
-
if (err && err.body && err.body.code === 'native-save-unavailable') {
|
|
21966
|
+
let choice = null;
|
|
21967
|
+
for (;;) {
|
|
21968
|
+
startProgress();
|
|
21969
|
+
let result;
|
|
19918
21970
|
try {
|
|
19919
|
-
|
|
19920
|
-
|
|
19921
|
-
|
|
19922
|
-
|
|
19923
|
-
|
|
19924
|
-
|
|
19925
|
-
|
|
21971
|
+
result = await exportOnce(choice);
|
|
21972
|
+
} catch (err) {
|
|
21973
|
+
const body = err && err.body;
|
|
21974
|
+
if (body && body.code === 'archive-oversize' && body.oversize) {
|
|
21975
|
+
finishProgress();
|
|
21976
|
+
const picked = await askExportOversize(body.oversize);
|
|
21977
|
+
if (!picked) return;
|
|
21978
|
+
choice = { inspected: body.oversize.inspected, leaveOut: picked.leaveOut, everything: picked.everything };
|
|
21979
|
+
continue;
|
|
21980
|
+
}
|
|
21981
|
+
throw err;
|
|
21982
|
+
}
|
|
21983
|
+
finishProgress();
|
|
21984
|
+
if (result.cancelled) return;
|
|
21985
|
+
const leftOut = Array.isArray(result.leftOut) ? result.leftOut : [];
|
|
21986
|
+
showToast(`Exported “${label}” — ${result.filename}${leftOut.length ? `, without ${leftOut.join(', ')}. The archive notes what was left out.` : ''}`, 'ok');
|
|
21987
|
+
if (result.withinImportFileLimit === false) {
|
|
21988
|
+
showToast('This archive holds more than 10,000 files, so FloLess can’t import it. Unzip it by hand to use its files.', 'warn');
|
|
19926
21989
|
}
|
|
21990
|
+
track('workspace_project_exported', { app: proj ? proj.app : undefined });
|
|
21991
|
+
return;
|
|
19927
21992
|
}
|
|
21993
|
+
} catch (err) {
|
|
19928
21994
|
finishProgress();
|
|
21995
|
+
const body = err && err.body;
|
|
21996
|
+
// A choice made for a project that was replaced while the person chose, or a refused choice: the server's sentence.
|
|
21997
|
+
const said = body && (body.code === 'archive-project-changed' || body.code === 'invalid-export-choice') ? personText(body) : '';
|
|
21998
|
+
if (said) {
|
|
21999
|
+
showToast(said, 'warn');
|
|
22000
|
+
return;
|
|
22001
|
+
}
|
|
19929
22002
|
showToast(`We couldn’t export “${label}” because FloLess could not finish preparing it. Try again.`, 'warn');
|
|
19930
22003
|
} finally {
|
|
19931
22004
|
finishProgress();
|
|
@@ -20223,16 +22296,24 @@
|
|
|
20223
22296
|
renderKnowledge();
|
|
20224
22297
|
}
|
|
20225
22298
|
|
|
22299
|
+
/**
|
|
22300
|
+
* #3097: an error whose message is a sentence this page wrote for the person. Callers in other modules (chat, agents,
|
|
22301
|
+
* Project access) show it through errorText, which trusts only this marker.
|
|
22302
|
+
*/
|
|
22303
|
+
function personError(text) {
|
|
22304
|
+
return Object.assign(new Error(text), { forPerson: true });
|
|
22305
|
+
}
|
|
22306
|
+
|
|
20226
22307
|
/**
|
|
20227
22308
|
* #2106: open a project on its Knowledge step — where a person sees FloLess organizing its knowledge, the work a busy
|
|
20228
22309
|
* card's "Open it" leads to. Throws a plain sentence when the project can't be opened, so the caller can say so.
|
|
20229
22310
|
*/
|
|
20230
22311
|
async function openKnowledgeStep(projectId) {
|
|
20231
|
-
if (typeof projectId !== 'string' || !projectId) throw
|
|
22312
|
+
if (typeof projectId !== 'string' || !projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20232
22313
|
await setMode('workspaces');
|
|
20233
22314
|
const opened = await openProject(projectId, 'knowledge');
|
|
20234
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20235
|
-
if (current?.id !== projectId) throw
|
|
22315
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22316
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20236
22317
|
}
|
|
20237
22318
|
|
|
20238
22319
|
// #2470 R6.2: a project's Workflows step, where the workflows it owns are listed (Project access links here).
|
|
@@ -20312,16 +22393,16 @@
|
|
|
20312
22393
|
async function openLinkedProject(projectId) {
|
|
20313
22394
|
await setMode('workspaces');
|
|
20314
22395
|
const opened = await openProject(projectId);
|
|
20315
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20316
|
-
if (current?.id !== projectId) throw
|
|
22396
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22397
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20317
22398
|
}
|
|
20318
22399
|
|
|
20319
22400
|
/** A General project's Modules step: where Back to … after an Add a module returns to. */
|
|
20320
22401
|
async function openModulesStep(projectId) {
|
|
20321
22402
|
await setMode('workspaces');
|
|
20322
22403
|
const opened = await openProject(projectId, 'modules');
|
|
20323
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20324
|
-
if (current?.id !== projectId) throw
|
|
22404
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22405
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20325
22406
|
}
|
|
20326
22407
|
|
|
20327
22408
|
/** Show the archived projects on the Workspaces page, where Restore is, with this one in view. */
|
|
@@ -20336,11 +22417,11 @@
|
|
|
20336
22417
|
}
|
|
20337
22418
|
|
|
20338
22419
|
async function openWorkflowsStep(projectId) {
|
|
20339
|
-
if (typeof projectId !== 'string' || !projectId) throw
|
|
22420
|
+
if (typeof projectId !== 'string' || !projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20340
22421
|
await setMode('workspaces');
|
|
20341
22422
|
const opened = await openProject(projectId, 'workflows');
|
|
20342
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20343
|
-
if (current?.id !== projectId) throw
|
|
22423
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22424
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20344
22425
|
}
|
|
20345
22426
|
|
|
20346
22427
|
/**
|
|
@@ -20425,11 +22506,11 @@
|
|
|
20425
22506
|
|
|
20426
22507
|
// The Drawing Filter step of a project, where a drawing read's exclusions are saved and signed off.
|
|
20427
22508
|
async function openDrawingsStep(projectId) {
|
|
20428
|
-
if (typeof projectId !== 'string' || !projectId) throw
|
|
22509
|
+
if (typeof projectId !== 'string' || !projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20429
22510
|
await setMode('workspaces');
|
|
20430
22511
|
const opened = await openProject(projectId, 'drawings');
|
|
20431
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20432
|
-
if (current?.id !== projectId) throw
|
|
22512
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22513
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20433
22514
|
}
|
|
20434
22515
|
|
|
20435
22516
|
/**
|
|
@@ -20742,20 +22823,20 @@
|
|
|
20742
22823
|
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
20743
22824
|
if (!owner || typeof owner !== 'object'
|
|
20744
22825
|
|| !(owner.kind === 'workspace' || owner.kind === 'project' && validId(owner.projectId)
|
|
20745
|
-
|| owner.kind === 'workflow' && validId(owner.workflowId))) throw
|
|
22826
|
+
|| owner.kind === 'workflow' && validId(owner.workflowId))) throw personError('That conversation has no valid home to open.');
|
|
20746
22827
|
if (owner.kind === 'workflow') {
|
|
20747
|
-
if (typeof bridge.openOwnedWorkflow !== 'function') throw
|
|
22828
|
+
if (typeof bridge.openOwnedWorkflow !== 'function') throw personError('Open this conversation’s workflow from Workflows, then try Show in chat again.');
|
|
20748
22829
|
await bridge.openOwnedWorkflow(owner.workflowId);
|
|
20749
22830
|
return;
|
|
20750
22831
|
}
|
|
20751
22832
|
await setMode('workspaces');
|
|
20752
22833
|
if (owner.kind === 'project') {
|
|
20753
22834
|
const opened = await openProject(owner.projectId);
|
|
20754
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20755
|
-
if (current?.id !== owner.projectId) throw
|
|
22835
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22836
|
+
if (current?.id !== owner.projectId) throw personError('That project could not be opened. Try Show in chat again after opening its project in Workspaces.');
|
|
20756
22837
|
} else {
|
|
20757
22838
|
await leaveProjectToList(null);
|
|
20758
|
-
if (current) throw
|
|
22839
|
+
if (current) throw personError('You stayed in this project, so the conversation was not opened.');
|
|
20759
22840
|
}
|
|
20760
22841
|
}
|
|
20761
22842
|
|