@floless/app 0.168.0 → 0.169.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 +83100 -68895
- package/dist/skills/floless-app-rfi/SKILL.md +4 -2
- package/dist/templates/college-phase-exporter.flo +7 -2
- package/dist/templates/trimble-list-projects.flo +10 -2
- package/dist/web/agent-steps.js +2 -2
- package/dist/web/agents.js +49 -13
- package/dist/web/app.css +44 -3
- package/dist/web/app.js +47 -4
- package/dist/web/aware-update-client.js +4 -4
- package/dist/web/aware.js +401 -31
- package/dist/web/chat.css +10 -0
- package/dist/web/chat.js +223 -22
- package/dist/web/commands-drawing-check.js +3 -0
- package/dist/web/commands-shell.js +111 -4
- package/dist/web/commands-steel.js +9 -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 +502 -182
- package/dist/web/failure-copy.js +20 -2
- package/dist/web/flo-3d.js +310 -0
- package/dist/web/flo-card.js +72 -0
- package/dist/web/guide.js +3 -1
- package/dist/web/index.html +26 -4
- package/dist/web/instructor.js +3 -0
- package/dist/web/model-editor-steel-adapter.js +41 -1
- package/dist/web/model-viewport-toolbar.js +11 -0
- package/dist/web/pages.js +17 -14
- package/dist/web/panels.js +1 -1
- package/dist/web/project-history.js +2 -2
- package/dist/web/project-modules.js +3 -3
- package/dist/web/project-reconciliation.js +1 -1
- package/dist/web/project-rfis.js +2 -2
- package/dist/web/project-workflows.js +6 -4
- package/dist/web/renderers.js +6 -0
- package/dist/web/report-csp.js +68 -0
- package/dist/web/revit-editor.js +1 -1
- package/dist/web/run-history.js +2 -3
- package/dist/web/steel-3d-flo.js +309 -0
- package/dist/web/steel-3d-view.js +159 -0
- package/dist/web/steel-editor.html +130 -9
- package/dist/web/terminal-requests.js +78 -0
- package/dist/web/tool-updates.js +3 -2
- 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 +626 -140
- package/launch.mjs +5 -0
- package/package.json +8 -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');
|
|
@@ -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;
|
|
@@ -1225,9 +1235,10 @@
|
|
|
1225
1235
|
*/
|
|
1226
1236
|
let projectContractLifecycle = 'unknown';
|
|
1227
1237
|
// 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
|
-
|
|
1238
|
+
// ever re-ask a lifecycle check that timed out or failed. It re-asks by itself once more; then the header says it
|
|
1239
|
+
// could not check rather than "Checking…" forever. Once, because each check already keeps trying for its own 45 s
|
|
1240
|
+
// budget (#3139): three re-asks made a hung server read "Checking project…" for over three minutes.
|
|
1241
|
+
const SOURCELESS_PRESENCE_RETRIES = 1;
|
|
1231
1242
|
let sourcelessPresence = { projectId: null, openSeq: 0, tries: 0, gaveUp: false, timer: null };
|
|
1232
1243
|
let exportsHasModel = false;
|
|
1233
1244
|
// A project may open on Model/Exports/History while its lifecycle probe is still in flight. Keep
|
|
@@ -1242,7 +1253,7 @@
|
|
|
1242
1253
|
* re-disable Approve on a project that now has a model. Every writer bumps it; older results drop. */
|
|
1243
1254
|
let modelPresenceGen = 0;
|
|
1244
1255
|
// One lifecycle request per open project. Tab clicks attach to this promise instead of starting
|
|
1245
|
-
// competing
|
|
1256
|
+
// competing probes (each keeps trying for up to 45 s) whose generation guards make all but the last answer disappear.
|
|
1246
1257
|
let modelPresenceProbe = null;
|
|
1247
1258
|
|
|
1248
1259
|
/** The header's AUTHORED tooltip, captured from the static markup so the has-a-model state restores
|
|
@@ -2852,7 +2863,9 @@
|
|
|
2852
2863
|
`<span class="ws-body"><span><span class="ws-name">${escapeHtml(p.name)}</span>` +
|
|
2853
2864
|
(projectCapability ? `<span class="ws-meta">${escapeHtml(projectCapability)}</span>` : '') +
|
|
2854
2865
|
// #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>` : '') +
|
|
2866
|
+
(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>` : '') +
|
|
2867
|
+
// #2554 slice 2: a model that left drawing files unread says so beside its label, or on its own when precise.
|
|
2868
|
+
(!(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
2869
|
(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
2870
|
`<span class="ws-meta ws-registration-status"${p.registrationState === 'unavailable' ? '' : ' hidden'}>${escapeHtml(p.registrationReason || 'Project folder unavailable. Locate or restore it.')}</span>` +
|
|
2858
2871
|
`<span class="ws-meta ws-registration-location-note"${p.registrationState !== 'unavailable' && p.registrationLocationWarning ? '' : ' hidden'}>${escapeHtml(p.registrationLocationWarning || '')}</span>` +
|
|
@@ -3470,12 +3483,21 @@
|
|
|
3470
3483
|
const $teklaSourceStatus = document.getElementById('tekla-source-status');
|
|
3471
3484
|
let teklaSourceChoice = null;
|
|
3472
3485
|
let teklaSourcePicking = false;
|
|
3486
|
+
const TEKLA_SOURCE_BUSY_REASON = 'FloLess is still reading that model. This window updates when it is done.';
|
|
3473
3487
|
function setTeklaSourcePicking(busy, message = '') {
|
|
3474
3488
|
teklaSourcePicking = busy;
|
|
3475
3489
|
$teklaSourceModal?.setAttribute('aria-busy', String(busy));
|
|
3476
3490
|
if ($teklaSourceFolder) $teklaSourceFolder.disabled = busy;
|
|
3477
3491
|
if ($teklaSourceZip) $teklaSourceZip.disabled = busy;
|
|
3478
|
-
if ($teklaSourceCancel)
|
|
3492
|
+
if ($teklaSourceCancel) {
|
|
3493
|
+
$teklaSourceCancel.disabled = busy;
|
|
3494
|
+
if (busy) $teklaSourceCancel.dataset.blockedReason = TEKLA_SOURCE_BUSY_REASON;
|
|
3495
|
+
else delete $teklaSourceCancel.dataset.blockedReason;
|
|
3496
|
+
}
|
|
3497
|
+
// A disabled button drops focus to the page; keep it in the dialog so Escape and Tab still land here.
|
|
3498
|
+
if (busy && document.activeElement?.disabled && $teklaSourceModal?.contains(document.activeElement)) {
|
|
3499
|
+
$teklaSourceDialog?.focus();
|
|
3500
|
+
}
|
|
3479
3501
|
if ($teklaSourceStatus) {
|
|
3480
3502
|
$teklaSourceStatus.textContent = message;
|
|
3481
3503
|
$teklaSourceStatus.hidden = !message;
|
|
@@ -3494,6 +3516,11 @@
|
|
|
3494
3516
|
$teklaSourceModal?.classList.remove('show');
|
|
3495
3517
|
if (restoreFocus && state?.returnFocus?.isConnected) state.returnFocus.focus();
|
|
3496
3518
|
}
|
|
3519
|
+
/** #3151: Cancel, Escape and the backdrop agree — none of them closes the window while a source is read. */
|
|
3520
|
+
function dismissTeklaSourceChoice() {
|
|
3521
|
+
if (teklaSourcePicking) { setTeklaSourcePicking(true, TEKLA_SOURCE_BUSY_REASON); return; }
|
|
3522
|
+
closeTeklaSourceChoice();
|
|
3523
|
+
}
|
|
3497
3524
|
async function chooseTeklaSource(kind) {
|
|
3498
3525
|
const choice = teklaSourceChoice;
|
|
3499
3526
|
if (!choice || teklaSourcePicking) return;
|
|
@@ -3520,10 +3547,10 @@
|
|
|
3520
3547
|
}
|
|
3521
3548
|
$teklaSourceFolder?.addEventListener('click', () => { void chooseTeklaSource('folder'); });
|
|
3522
3549
|
$teklaSourceZip?.addEventListener('click', () => { void chooseTeklaSource('zip'); });
|
|
3523
|
-
$teklaSourceCancel?.addEventListener('click', () =>
|
|
3524
|
-
$teklaSourceModal?.addEventListener('click', (event) => { if (event.target === $teklaSourceModal)
|
|
3550
|
+
$teklaSourceCancel?.addEventListener('click', () => dismissTeklaSourceChoice());
|
|
3551
|
+
$teklaSourceModal?.addEventListener('click', (event) => { if (event.target === $teklaSourceModal) dismissTeklaSourceChoice(); });
|
|
3525
3552
|
$teklaSourceModal?.addEventListener('keydown', (event) => {
|
|
3526
|
-
if (event.key === 'Escape') { event.preventDefault();
|
|
3553
|
+
if (event.key === 'Escape') { event.preventDefault(); dismissTeklaSourceChoice(); return; }
|
|
3527
3554
|
if (event.key !== 'Tab') return;
|
|
3528
3555
|
const controls = [...$teklaSourceModal.querySelectorAll('button:not([disabled])')];
|
|
3529
3556
|
if (!controls.length) return;
|
|
@@ -5567,7 +5594,7 @@
|
|
|
5567
5594
|
frames.model.dataset.loaded = ''; frames.drawings.dataset.loaded = '';
|
|
5568
5595
|
// Start the small lifecycle envelope BEFORE the heavier approval review request. Both hit the
|
|
5569
5596
|
// same localhost event loop; sending approval first could keep the lifecycle request queued until
|
|
5570
|
-
// its
|
|
5597
|
+
// its client deadline, falsely leaving an existing model in the checking state. This
|
|
5571
5598
|
// promise also owns every tab activation until it settles (refreshModelPresence deduplicates it).
|
|
5572
5599
|
refreshModelPresence(p.id, p.app).catch((e) => {
|
|
5573
5600
|
console.error('[workspaces] could not resolve model presence', e);
|
|
@@ -5625,18 +5652,20 @@
|
|
|
5625
5652
|
}
|
|
5626
5653
|
const gen = ++modelPresenceGen;
|
|
5627
5654
|
const promise = (async () => {
|
|
5628
|
-
const present = await projectContractState(projectId, appId);
|
|
5655
|
+
const present = await projectContractState(projectId, appId, () => gen === modelPresenceGen && current?.id === projectId);
|
|
5629
5656
|
if (gen !== modelPresenceGen || !current || current.id !== projectId) return false; // superseded
|
|
5630
|
-
|
|
5657
|
+
// A step the person clicked is settled by applyModelPresence (settleAskedStep), whichever check answers it;
|
|
5658
|
+
// this restores only the step a project was opened on.
|
|
5659
|
+
const held = pendingPresenceStep?.projectId === projectId && !pendingPresenceStep.asked ? pendingPresenceStep.step : '';
|
|
5631
5660
|
// A timeout/network error is not evidence that this project has no model. Keep the requested
|
|
5632
5661
|
// destination so its next activation can retry the probe and restore it after recovery.
|
|
5633
|
-
if (present !== 'unknown') pendingPresenceStep = null;
|
|
5662
|
+
if (present !== 'unknown' && held) pendingPresenceStep = null;
|
|
5634
5663
|
applyModelPresence(present);
|
|
5635
5664
|
// Restore only when this same project's authoritative answer says a model exists. A confirmed
|
|
5636
5665
|
// preliminary lifecycle remains on Drawing Filter and gets the real prerequisite gate below.
|
|
5637
5666
|
// #2470 R6.5b: History on a kind with two views is never gated (its Activity view needs no model), so it is
|
|
5638
5667
|
// restored on any known answer too, and opens on Activity when Approvals still has to wait.
|
|
5639
|
-
if (
|
|
5668
|
+
if (held && currentStep === 'drawings' && (present === 'model' || (present !== 'unknown' && held === 'history' && !stageGateFor(held)))) setStep(held);
|
|
5640
5669
|
return true;
|
|
5641
5670
|
})();
|
|
5642
5671
|
modelPresenceProbe = { projectId, promise };
|
|
@@ -5648,15 +5677,98 @@
|
|
|
5648
5677
|
|
|
5649
5678
|
/** Push the answer to the flag AND the header together, so no two surfaces can disagree. */
|
|
5650
5679
|
function applyModelPresence(present) {
|
|
5680
|
+
// #3139: which Exports render was already waiting on its check before this answer. Opening the clicked step below
|
|
5681
|
+
// can start a new render, which waits on its own check and must not be redone by the answer that opened it.
|
|
5682
|
+
const exportsWaiting = typeof exportsLifecycleWait === 'number' ? exportsLifecycleWait : 0;
|
|
5651
5683
|
projectContractLifecycle = present;
|
|
5652
5684
|
exportsHasModel = present === 'model';
|
|
5653
5685
|
retrySourcelessPresence(present);
|
|
5654
5686
|
renderApprovalHeader();
|
|
5687
|
+
// #3139, through `typeof` because harnesses lift this function alone. The clicked step first: before the gate
|
|
5688
|
+
// repaint, which may move the person off a tab the answer locked; and before the panes, because opening the step
|
|
5689
|
+
// hides the pane it was clicked from, so that pane is not redone behind it.
|
|
5690
|
+
if (typeof settleAskedStep === 'function') settleAskedStep(present);
|
|
5655
5691
|
applyStageGating();
|
|
5656
5692
|
// A lifecycle probe may resolve after the saved-filter card already painted under `unknown`.
|
|
5657
5693
|
// Retire it in the same turn that reveals the replacement strip; waiting for the request poll
|
|
5658
5694
|
// would briefly recreate the two competing status bands this hand-off exists to remove.
|
|
5659
5695
|
if (currentStep === 'drawings' && lastRevState === 'pending') retireRevisionCardForStrip(revCardReq);
|
|
5696
|
+
if (typeof syncExportsLifecycleGate === 'function') syncExportsLifecycleGate(present, exportsWaiting);
|
|
5697
|
+
if (typeof syncHistoryLifecycleWait === 'function') syncHistoryLifecycleWait();
|
|
5698
|
+
}
|
|
5699
|
+
|
|
5700
|
+
/**
|
|
5701
|
+
* #3139: the step the person clicked while the lifecycle was unknown (deferStageUntilLifecycle marks it `asked`) is
|
|
5702
|
+
* settled by whichever check applies an answer — its own, or an Exports or History render's that overtook it, which
|
|
5703
|
+
* used to drop the click. A real answer opens it from wherever the person is (any later step choice would already
|
|
5704
|
+
* have dropped it, see dropAskedStep) or says which earlier stage it waits for; no answer says so once and offers
|
|
5705
|
+
* Try again, then lets the step go, so a much later check can never move the person (#1669).
|
|
5706
|
+
*/
|
|
5707
|
+
function settleAskedStep(present) {
|
|
5708
|
+
const held = pendingPresenceStep;
|
|
5709
|
+
if (!held?.asked || !current || held.projectId !== current.id) return;
|
|
5710
|
+
pendingPresenceStep = null;
|
|
5711
|
+
if (pendingPresenceToast) pendingPresenceToast();
|
|
5712
|
+
pendingPresenceToast = null;
|
|
5713
|
+
const s = held.step;
|
|
5714
|
+
if (present === 'unknown') {
|
|
5715
|
+
const projectId = held.projectId;
|
|
5716
|
+
// Held as the pending toast, so a click on another step or another project closes it like the checking one.
|
|
5717
|
+
pendingPresenceToast = showToast(`Couldn’t check project stages, so ${stepLabel(s)} hasn’t opened yet. Your project is unchanged.`, 'warn', {
|
|
5718
|
+
persistent: true,
|
|
5719
|
+
action: { label: 'Try again', commandId: `shell.workspace-stage-recheck#${stepLabel(s)}`, onClick: () => { if (current?.id === projectId) chooseStep(s); } },
|
|
5720
|
+
});
|
|
5721
|
+
return;
|
|
5722
|
+
}
|
|
5723
|
+
// A confirmed preliminary answer turns the apparent availability into the real prerequisite gate. Reuse that
|
|
5724
|
+
// specific explanation instead of replacing it with generic readiness copy. History opens on its Activity view.
|
|
5725
|
+
const reason = stageGateFor(s);
|
|
5726
|
+
if (present === 'model' || (s === 'history' && !reason)) setStep(s);
|
|
5727
|
+
else if (reason) showToast(reason, 'warn');
|
|
5728
|
+
}
|
|
5729
|
+
|
|
5730
|
+
/** #3139: moves off a tab that just became locked. FloLess's move, not the person's, so a step they clicked stays held. */
|
|
5731
|
+
let stepRedirecting = false;
|
|
5732
|
+
function redirectStep(s) {
|
|
5733
|
+
stepRedirecting = true;
|
|
5734
|
+
try { setStep(s); } finally { stepRedirecting = false; }
|
|
5735
|
+
}
|
|
5736
|
+
|
|
5737
|
+
/**
|
|
5738
|
+
* #3139: the person (or the chat, or a "View" link) moved to another step by a route other than chooseStep, so a
|
|
5739
|
+
* step they clicked earlier is no longer what they want: drop it and its checking toast. Reached from setStep
|
|
5740
|
+
* through `typeof` (harnesses lift setStep alone). An open-time hold is not `asked` and is left alone, and so is a
|
|
5741
|
+
* move FloLess makes itself (redirectStep): that is not the person's choice.
|
|
5742
|
+
*/
|
|
5743
|
+
function dropAskedStep() {
|
|
5744
|
+
if (stepRedirecting || !pendingPresenceStep?.asked) return;
|
|
5745
|
+
pendingPresenceStep = null;
|
|
5746
|
+
if (pendingPresenceToast) pendingPresenceToast();
|
|
5747
|
+
pendingPresenceToast = null;
|
|
5748
|
+
}
|
|
5749
|
+
|
|
5750
|
+
/**
|
|
5751
|
+
* #3139: whichever check settles — the Exports render's own, or another that overtook it (a General project's
|
|
5752
|
+
* re-check, a model-creating read, a step click) — a visible Exports pane shows that answer. An overtaken render
|
|
5753
|
+
* returned before loading the export sources, so it is redone in full, with this answer handed to it so it does not
|
|
5754
|
+
* ask the server again (after a check that gave up, that would put "Checking…" back beside "Couldn’t check");
|
|
5755
|
+
* otherwise the gate is repainted when its answer changed. `waitingBefore` is the render that was waiting before this
|
|
5756
|
+
* answer: one this answer itself started (by opening the clicked step) waits on its own check and is left to it.
|
|
5757
|
+
* Without this "Checking what this project holds…" or "Loading export sources…" outlived every check.
|
|
5758
|
+
*/
|
|
5759
|
+
function syncExportsLifecycleGate(present, waitingBefore) {
|
|
5760
|
+
exportsLifecycleUnanswered = present === 'unknown';
|
|
5761
|
+
if (!current || $wsExports.hidden) return;
|
|
5762
|
+
if (exportsLifecycleWait && exportsLifecycleWait === exportsRenderGen && exportsLifecycleWait === waitingBefore) {
|
|
5763
|
+
exportsLifecycleWait = 0;
|
|
5764
|
+
exportsLifecycleHanded = { gen: exportsRenderGen + 1, present };
|
|
5765
|
+
safeRenderExports('after the project check finished');
|
|
5766
|
+
return;
|
|
5767
|
+
}
|
|
5768
|
+
if (exportsLifecycleGateKey() !== exportsPaintedGate) paintExports(current.approvedAt);
|
|
5769
|
+
}
|
|
5770
|
+
function exportsLifecycleGateKey() {
|
|
5771
|
+
return projectContractLifecycle + (exportsLifecycleUnanswered ? ':unanswered' : '');
|
|
5660
5772
|
}
|
|
5661
5773
|
|
|
5662
5774
|
/** Re-ask a General project's lifecycle after a check that settled `unknown` (see SOURCELESS_PRESENCE_RETRIES). */
|
|
@@ -6735,7 +6847,7 @@
|
|
|
6735
6847
|
if (typeof syncHistoryViews === 'function' && typeof currentStep !== 'undefined') {
|
|
6736
6848
|
const activity = syncHistoryViews(currentStep, d);
|
|
6737
6849
|
// 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');
|
|
6850
|
+
if (currentStep === 'history' && activity && !$wsHistory.hidden) (typeof redirectStep === 'function' ? redirectStep : setStep)('history');
|
|
6739
6851
|
}
|
|
6740
6852
|
if (!d || !d.filter) {
|
|
6741
6853
|
// The tab strip is shared across projects. Remove every steel-only gate when switching to an
|
|
@@ -6781,7 +6893,7 @@
|
|
|
6781
6893
|
// A project opened on the old default Model step can become gated when the lifecycle probe
|
|
6782
6894
|
// returns. Move it to the first actionable stage instead of leaving a locked tab selected.
|
|
6783
6895
|
if (currentStep !== 'drawings' && stageGateFor(currentStep)) {
|
|
6784
|
-
setStep('drawings');
|
|
6896
|
+
(typeof redirectStep === 'function' ? redirectStep : setStep)('drawings');
|
|
6785
6897
|
return;
|
|
6786
6898
|
}
|
|
6787
6899
|
// The strip always speaks for a save waiting on the person (confirm), refused (blocked) or needing a
|
|
@@ -6905,30 +7017,31 @@
|
|
|
6905
7017
|
const d = wsApp();
|
|
6906
7018
|
if (!current || !d?.filter || projectContractLifecycle !== 'unknown'
|
|
6907
7019
|
|| !['model', 'rfis', 'exports', 'history'].includes(s)) return false;
|
|
6908
|
-
|
|
7020
|
+
// FloLess's own redirect (redirectStep) only repaints the step the person is on; it must not replace their click.
|
|
7021
|
+
if (typeof stepRedirecting !== 'undefined' && stepRedirecting) return false;
|
|
7022
|
+
pendingPresenceStep = { projectId: current.id, step: s, asked: true };
|
|
6909
7023
|
const projectId = current.id;
|
|
6910
7024
|
if (pendingPresenceToast) pendingPresenceToast();
|
|
6911
|
-
|
|
7025
|
+
// Persistent while the check runs (#3139): it retries by itself for up to its budget, so the promise stays on
|
|
7026
|
+
// screen until the answer opens the step. Past a few seconds it says the wait is longer than usual, swapped in
|
|
7027
|
+
// place so the toast does not flicker.
|
|
7028
|
+
let dismissShown = showToast(`Checking project stages… ${stepLabel(s)} will open when ready.`, 'info', { persistent: true });
|
|
7029
|
+
let slowTimer = null;
|
|
7030
|
+
const intentToast = () => { clearTimeout(slowTimer); dismissShown(); };
|
|
7031
|
+
slowTimer = setTimeout(() => {
|
|
7032
|
+
if (pendingPresenceToast !== intentToast) return;
|
|
7033
|
+
dismissShown(true);
|
|
7034
|
+
dismissShown = showToast(`Still checking project stages. This is taking longer than usual. ${stepLabel(s)} will open when ready.`, 'info', { persistent: true });
|
|
7035
|
+
}, 6000);
|
|
6912
7036
|
pendingPresenceToast = intentToast;
|
|
6913
|
-
|
|
7037
|
+
// Whichever check applies an answer settles this click (settleAskedStep, from applyModelPresence): this one, or an
|
|
7038
|
+
// Exports or History render's that overtook it. Until then the step stays held and its toast stays up.
|
|
7039
|
+
refreshModelPresence(projectId, current.app).catch((err) => {
|
|
6914
7040
|
// 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
7041
|
if (pendingPresenceToast === intentToast) {
|
|
6930
7042
|
intentToast();
|
|
6931
7043
|
pendingPresenceToast = null;
|
|
7044
|
+
if (pendingPresenceStep?.asked && pendingPresenceStep.projectId === projectId) pendingPresenceStep = null;
|
|
6932
7045
|
}
|
|
6933
7046
|
console.error('[workspaces] tab lifecycle check failed', err);
|
|
6934
7047
|
});
|
|
@@ -7011,6 +7124,7 @@
|
|
|
7011
7124
|
// the model boundary speculatively. The existing request is reused and this destination opens
|
|
7012
7125
|
// automatically if it reports a model; the most recent click wins.
|
|
7013
7126
|
if (deferStageUntilLifecycle(s)) return;
|
|
7127
|
+
if (typeof dropAskedStep === 'function') dropAskedStep();
|
|
7014
7128
|
const lockedReason = stageGateFor(s);
|
|
7015
7129
|
if (lockedReason) {
|
|
7016
7130
|
if (currentStep !== 'drawings') setStep('drawings');
|
|
@@ -7516,7 +7630,8 @@
|
|
|
7516
7630
|
const APPROVAL_REASON_CODES = ['tekla-approval-refused', 'grant-unavailable', 'approval-nothing-exportable', ...IMPORT_FINDINGS_REFUSAL_CODES];
|
|
7517
7631
|
function knownApprovalFailureReason(error) {
|
|
7518
7632
|
const body = error && error.body;
|
|
7519
|
-
|
|
7633
|
+
// #3097: a `diagnostic` reply's `error` is what was thrown, not a sentence for the person, whatever its code.
|
|
7634
|
+
if (!body || body.diagnostic || typeof body.error !== 'string' || !body.error.trim()) return '';
|
|
7520
7635
|
return APPROVAL_REASON_CODES.includes(body.code) ? body.error.trim() : '';
|
|
7521
7636
|
}
|
|
7522
7637
|
/** The raw error, for the Technical details disclosure only: never the headline of a notice. */
|
|
@@ -7859,6 +7974,24 @@
|
|
|
7859
7974
|
return `<span class="quick-pill${q.state === 'unknown' ? ' is-unknown' : ''}"${carrier} data-tip="${escapeAttr(tip)}">${escapeHtml((opts.showScope ? scope : '') + q.short)}</span>${spoken}`;
|
|
7860
7975
|
}
|
|
7861
7976
|
|
|
7977
|
+
/**
|
|
7978
|
+
* #2554 slice 2: which drawing files a model did NOT read, beside its Quick label and never inside it (a fully
|
|
7979
|
+
* reviewed precise model can still be part of its set). Neutral, because the amber is the Quick label's; dashed when
|
|
7980
|
+
* FloLess could not tell. A model that read its whole set shows none. `besides` is the Quick label of the same
|
|
7981
|
+
* document: when FloLess could not read that document at all, its dashed Quick pill already says so, and a second
|
|
7982
|
+
* dashed pill naming no file would add nothing.
|
|
7983
|
+
*/
|
|
7984
|
+
function coveragePillHtml(c, opts = {}) {
|
|
7985
|
+
if (!c || (c.state !== 'part' && c.state !== 'unknown') || typeof c.short !== 'string' || !c.short) return '';
|
|
7986
|
+
if (opts.besides && opts.besides.state === 'unknown' && c.state === 'unknown' && !c.count && quickPillHtml(opts.besides)) return '';
|
|
7987
|
+
const scope = opts.scope ? `${opts.scope}: ` : '';
|
|
7988
|
+
const tip = `${scope}${c.text || c.short}`;
|
|
7989
|
+
const nested = opts.focusable === false;
|
|
7990
|
+
const carrier = nested ? '' : ' data-command-id="shell.read-coverage-note" tabindex="0"';
|
|
7991
|
+
const spoken = nested ? `<span class="sr-only"> (${escapeHtml(tip)})</span>` : '';
|
|
7992
|
+
return `<span class="coverage-pill${c.state === 'unknown' ? ' is-unknown' : ''}"${carrier} data-tip="${escapeAttr(tip)}">${escapeHtml((opts.showScope ? scope : '') + c.short)}</span>${spoken}`;
|
|
7993
|
+
}
|
|
7994
|
+
|
|
7862
7995
|
/**
|
|
7863
7996
|
* The header chip: ONE compact chip for the approved head and, whenever it differs from the head, the working copy.
|
|
7864
7997
|
* Its tooltip names each document and says what it rests on, so the header never grows a second chip that pushes
|
|
@@ -7873,14 +8006,33 @@
|
|
|
7873
8006
|
const parts = [];
|
|
7874
8007
|
if (q && s.headVersion && quickPillHtml(q.head)) parts.push([`v${s.headVersion}`, q.head]);
|
|
7875
8008
|
if (q && (s.pendingCount > 0 || !s.headVersion) && quickPillHtml(q.draft)) parts.push(['Working copy', q.draft]);
|
|
8009
|
+
// #2554 slice 2: which drawing files each document did not read, scoped the same way, folded into the same chip.
|
|
8010
|
+
const c = s.status === 'ready' && s.review && s.review.coverage ? s.review.coverage : null;
|
|
8011
|
+
const covered = [];
|
|
8012
|
+
if (c && s.headVersion && coveragePillHtml(c.head, { besides: q && q.head })) covered.push([`v${s.headVersion}`, c.head]);
|
|
8013
|
+
if (c && (s.pendingCount > 0 || !s.headVersion) && coveragePillHtml(c.draft, { besides: q && q.draft })) covered.push(['Working copy', c.draft]);
|
|
8014
|
+
const coverageTip = covered.map(([scope, note]) => `${scope}: ${note.text || note.short}`).join(' ');
|
|
8015
|
+
const coverageShort = covered.some(([, note]) => note.state === 'part') ? 'Part of the set' : 'Part of the set?';
|
|
8016
|
+
if (!parts.length && covered.length) {
|
|
8017
|
+
$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>`;
|
|
8018
|
+
$quick.hidden = false;
|
|
8019
|
+
return;
|
|
8020
|
+
}
|
|
7876
8021
|
if (!parts.length) { $quick.innerHTML = ''; $quick.hidden = true; return; }
|
|
7877
8022
|
// "Quick model" when any document it speaks for is readably Quick; "Possibly Quick model" when none is; dashed
|
|
7878
8023
|
// whenever one of them could not be read.
|
|
7879
8024
|
const anyQuick = parts.some(([, label]) => label.state === 'quick');
|
|
7880
8025
|
const anyUnknown = parts.some(([, label]) => label.state === 'unknown');
|
|
8026
|
+
// The Quick document's explanation, then why each unreadable one could not be read (#2673); with two, each names
|
|
8027
|
+
// the document it explains, so a busy working copy is never read as a damaged version.
|
|
8028
|
+
const quickPart = parts.find(([, label]) => label.state === 'quick');
|
|
8029
|
+
const explained = [...(quickPart ? [quickPart] : []), ...parts.filter(([, label]) => label.state === 'unknown')]
|
|
8030
|
+
.filter(([, label]) => label.tip);
|
|
7881
8031
|
const tip = parts.map(([scope, label]) => `${scope}: ${label.label}.`).join(' ')
|
|
7882
|
-
+ ` ${
|
|
7883
|
-
|
|
8032
|
+
+ ` ${explained.map(([scope, label]) => (explained.length > 1 ? `${scope}: ${label.tip}` : label.tip)).join(' ')}`;
|
|
8033
|
+
const suffix = covered.length ? ` · ${coverageShort}` : '';
|
|
8034
|
+
const fullTip = covered.length ? `${tip.trim()} ${coverageTip}` : tip.trim();
|
|
8035
|
+
$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
8036
|
$quick.hidden = false;
|
|
7885
8037
|
}
|
|
7886
8038
|
|
|
@@ -7896,7 +8048,7 @@
|
|
|
7896
8048
|
const ownsDialog = () => !!dialog && approvalDialogState === dialog && onProject();
|
|
7897
8049
|
if (ownsDialog() && $approvalRevisionNoteText) $approvalRevisionNoteText.value = '';
|
|
7898
8050
|
if (res && res.approvedAt) project.approvedAt = res.approvedAt;
|
|
7899
|
-
const { version: n, accepted, headline, assumed, quick } = approvalOutcomeWords(res);
|
|
8051
|
+
const { version: n, accepted, headline, assumed, quick, coverage } = approvalOutcomeWords(res);
|
|
7900
8052
|
if (n) expandDiffOnce = { projectId: project.id, n };
|
|
7901
8053
|
// An outcome can land while the person is editing this project again: a background check, or a dialog
|
|
7902
8054
|
// closed while the note above was saving. Reloading the editor then would discard edits not yet saved, so
|
|
@@ -7926,7 +8078,7 @@
|
|
|
7926
8078
|
// Edits still unsaved in the editor are not in any count FloLess read, so with them on screen no pending
|
|
7927
8079
|
// count is claimed at all: the sentence says what is known instead.
|
|
7928
8080
|
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');
|
|
8081
|
+
showToast(`${headline} ${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
8082
|
track('workspace_project_approved', { app: project.app });
|
|
7931
8083
|
if (onProject() && !$wsExports.hidden) safeRenderExports('after approving this version');
|
|
7932
8084
|
if (onProject() && !$wsHistory.hidden) await renderHistory();
|
|
@@ -7936,7 +8088,7 @@
|
|
|
7936
8088
|
: 'No changes remain pending.';
|
|
7937
8089
|
// The footer described the decision ("…will be approved…"); the decision has happened.
|
|
7938
8090
|
$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>`;
|
|
8091
|
+
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> ${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>`;
|
|
7940
8092
|
setApprovalPhase('approved', accepted ? headline : `Approved${n ? ` as v${n}` : ''}`);
|
|
7941
8093
|
$approvalClose.focus();
|
|
7942
8094
|
}
|
|
@@ -7958,7 +8110,16 @@
|
|
|
7958
8110
|
// #2521 row 5: an approved Quick model says so in the same breath, read from the approved version itself.
|
|
7959
8111
|
const quick = res && res.quick && (res.quick.state === 'quick' || res.quick.state === 'unknown') && typeof res.quick.label === 'string'
|
|
7960
8112
|
? `${res.quick.label}. ` : '';
|
|
7961
|
-
|
|
8113
|
+
// #2554 slice 2: and when it left drawing files unread, what that means for the approval and what covers them.
|
|
8114
|
+
// Unknown is never announced as a partial approval: it says FloLess could not tell. And when the version itself could
|
|
8115
|
+
// not be read (its Quick label is unknown too, with no file known unread) it is folded into that label, as the pills are.
|
|
8116
|
+
const c = res && res.coverage;
|
|
8117
|
+
const folded = c && c.state === 'unknown' && !c.count && res.quick && res.quick.state === 'unknown';
|
|
8118
|
+
const coverage = !c || folded || typeof c.brief !== 'string' ? ''
|
|
8119
|
+
: c.state === 'part' ? `${c.brief} This approval covers only the drawing files that were read; a later read of the others covers them. `
|
|
8120
|
+
: c.state === 'unknown' ? `${c.brief} FloLess could not tell whether this version read every drawing file; History shows what is known. `
|
|
8121
|
+
: '';
|
|
8122
|
+
return { version, accepted, headline, assumed, quick, coverage, sentence: `${headline} ${quick}${coverage}${assumed}`.trim() };
|
|
7962
8123
|
}
|
|
7963
8124
|
|
|
7964
8125
|
// One receipt read. The server answers under the project's approval locks, which on a large model
|
|
@@ -11213,6 +11374,54 @@
|
|
|
11213
11374
|
// One modal extends the existing Knowledge surface. Shared entries are immutable versions;
|
|
11214
11375
|
// nothing reaches this project's source list until the user explicitly accepts one.
|
|
11215
11376
|
let companyKnowledgeProjectId = null;
|
|
11377
|
+
// #3151: bumped on every open and close, so a request that outlives the dialog it started in
|
|
11378
|
+
// (the project changed under it) can tell, and drops its result instead of writing into the next one.
|
|
11379
|
+
let companyKnowledgeSession = 0;
|
|
11380
|
+
const COMPANY_KNOWLEDGE_BUSY_REASON = 'FloLess is still saving this change. You can close this window when it finishes.';
|
|
11381
|
+
|
|
11382
|
+
function companySetStatus(message) {
|
|
11383
|
+
if (!$companyKnowledgeStatus) return;
|
|
11384
|
+
$companyKnowledgeStatus.hidden = !message;
|
|
11385
|
+
$companyKnowledgeStatus.textContent = message || '';
|
|
11386
|
+
}
|
|
11387
|
+
|
|
11388
|
+
/** Close, ×, Back and the dismiss gestures wait while a change is in flight; the action button is render's. */
|
|
11389
|
+
function syncCompanyKnowledgeBusy() {
|
|
11390
|
+
for (const button of [$companyKnowledgeClose, $companyKnowledgeCancel]) {
|
|
11391
|
+
if (!button) continue;
|
|
11392
|
+
button.disabled = companyKnowledgeBusy;
|
|
11393
|
+
if (companyKnowledgeBusy) button.dataset.blockedReason = COMPANY_KNOWLEDGE_BUSY_REASON;
|
|
11394
|
+
else delete button.dataset.blockedReason;
|
|
11395
|
+
}
|
|
11396
|
+
$companyKnowledgeClose.dataset.tip = companyKnowledgeBusy ? COMPANY_KNOWLEDGE_BUSY_REASON : 'Close';
|
|
11397
|
+
$companyKnowledgeDialog.setAttribute('aria-busy', String(companyKnowledgeBusy));
|
|
11398
|
+
// A disabled button drops focus to the page; keep it in the dialog so Escape and Tab still land here.
|
|
11399
|
+
if (companyKnowledgeBusy && document.activeElement?.disabled && $companyKnowledgeModal.contains(document.activeElement)) {
|
|
11400
|
+
$companyKnowledgeDialog.focus({ preventScroll: true });
|
|
11401
|
+
}
|
|
11402
|
+
if (!companyKnowledgeBusy) companySetStatus('');
|
|
11403
|
+
}
|
|
11404
|
+
|
|
11405
|
+
/** A request from an earlier opening has settled after the dialog reopened (for another project): the
|
|
11406
|
+
* new dialog was painted busy and loaded before that change landed, so repaint it from a fresh read. */
|
|
11407
|
+
async function companyRefreshAfterStale() {
|
|
11408
|
+
if (!$companyKnowledgeModal.classList.contains('show') || !companyKnowledgeProjectId) { syncCompanyKnowledgeBusy(); return; }
|
|
11409
|
+
const session = companyKnowledgeSession;
|
|
11410
|
+
// Stay busy through the re-read, so an action started in the new dialog waits for it and its own
|
|
11411
|
+
// result can never be overwritten by this older read landing after it.
|
|
11412
|
+
companyKnowledgeBusy = true;
|
|
11413
|
+
try { await loadCompanyKnowledge(companyKnowledgeProjectId, session); } catch { /* the open dialog keeps what it loaded */ }
|
|
11414
|
+
finally {
|
|
11415
|
+
companyKnowledgeBusy = false;
|
|
11416
|
+
if (session === companyKnowledgeSession) renderCompanyKnowledge(); else void companyRefreshAfterStale();
|
|
11417
|
+
}
|
|
11418
|
+
}
|
|
11419
|
+
|
|
11420
|
+
/** Every person-driven way out of the dialog: blocked, with the reason said, while a change runs. */
|
|
11421
|
+
function dismissCompanyKnowledge() {
|
|
11422
|
+
if (companyKnowledgeBusy) { companySetStatus(COMPANY_KNOWLEDGE_BUSY_REASON); return; }
|
|
11423
|
+
closeCompanyKnowledge();
|
|
11424
|
+
}
|
|
11216
11425
|
|
|
11217
11426
|
function companyVersionNumber(entry, versionId) {
|
|
11218
11427
|
const at = entry && Array.isArray(entry.versions)
|
|
@@ -11335,21 +11544,28 @@
|
|
|
11335
11544
|
async function companyCatPost(path, body, okMsg) {
|
|
11336
11545
|
const state = companyKnowledgeState;
|
|
11337
11546
|
if (companyKnowledgeBusy || !state || !state.available) return null;
|
|
11338
|
-
|
|
11547
|
+
const session = companyKnowledgeSession, projectId = companyKnowledgeProjectId;
|
|
11548
|
+
companyKnowledgeBusy = true; companySetError(''); syncCompanyKnowledgeBusy();
|
|
11339
11549
|
try {
|
|
11340
11550
|
const res = await api(path, { method: 'POST', body: JSON.stringify({ expected: companyCatExpected(state), ...body }) });
|
|
11341
|
-
|
|
11551
|
+
// Company categories are company-wide, so the toast is true whichever project is on screen now.
|
|
11342
11552
|
if (okMsg) showToast(okMsg, 'ok');
|
|
11553
|
+
if (session !== companyKnowledgeSession) return null;
|
|
11554
|
+
companyCatEdit = null;
|
|
11343
11555
|
return res;
|
|
11344
11556
|
} catch (error) {
|
|
11345
|
-
const said =
|
|
11346
|
-
|
|
11557
|
+
const said = /^[A-Z]/.test(personText(error && error.body)) ? personText(error && error.body) : '';
|
|
11558
|
+
const message = said || 'FloLess could not change the company categories just now. Try again.';
|
|
11559
|
+
if (session !== companyKnowledgeSession) { showToast(message, 'warn'); return null; }
|
|
11560
|
+
companySetError(message);
|
|
11347
11561
|
if (body.expected && error && error.body && error.body.code === 'knowledge-categories-changed') companyCatEdit = null;
|
|
11348
11562
|
return null;
|
|
11349
11563
|
} finally {
|
|
11350
11564
|
companyKnowledgeBusy = false;
|
|
11351
|
-
|
|
11352
|
-
|
|
11565
|
+
if (session === companyKnowledgeSession) {
|
|
11566
|
+
try { await loadCompanyKnowledge(projectId); } catch { /* the error line says what happened */ }
|
|
11567
|
+
}
|
|
11568
|
+
if (session === companyKnowledgeSession) renderCompanyKnowledge(); else void companyRefreshAfterStale();
|
|
11353
11569
|
}
|
|
11354
11570
|
}
|
|
11355
11571
|
/** What a company category change is checked against: the categories' revision and the company folder. */
|
|
@@ -11534,44 +11750,56 @@
|
|
|
11534
11750
|
$companyKnowledgeAction.disabled = companyKnowledgeBusy || !available;
|
|
11535
11751
|
if (!available) $companyKnowledgeAction.dataset.blockedReason = 'Choose an available company folder first';
|
|
11536
11752
|
else delete $companyKnowledgeAction.dataset.blockedReason;
|
|
11537
|
-
|
|
11753
|
+
syncCompanyKnowledgeBusy();
|
|
11538
11754
|
}
|
|
11539
11755
|
|
|
11540
|
-
async function loadCompanyKnowledge(projectId) {
|
|
11541
|
-
|
|
11542
|
-
|
|
11756
|
+
async function loadCompanyKnowledge(projectId, session = companyKnowledgeSession) {
|
|
11757
|
+
const state = await api(`/api/company-knowledge?projectId=${encodeURIComponent(projectId)}`);
|
|
11758
|
+
// A read that finishes after its dialog closed belongs to no screen; never let it overwrite the next one.
|
|
11759
|
+
if (session === companyKnowledgeSession) companyKnowledgeState = state;
|
|
11760
|
+
return state;
|
|
11543
11761
|
}
|
|
11544
11762
|
|
|
11545
11763
|
async function openCompanyKnowledge(promotion, returnFocus) {
|
|
11546
11764
|
if (!current || !$companyKnowledgeModal) return;
|
|
11765
|
+
const session = ++companyKnowledgeSession;
|
|
11547
11766
|
companyKnowledgeProjectId = current.id;
|
|
11548
11767
|
companyKnowledgePromotion = promotion || null;
|
|
11549
11768
|
companyKnowledgePending = null;
|
|
11550
11769
|
companyKnowledgeReturnFocus = returnFocus || document.activeElement;
|
|
11551
|
-
companySetError('');
|
|
11770
|
+
companySetError(''); companySetStatus('');
|
|
11552
11771
|
$companyKnowledgeModal.classList.add('show');
|
|
11553
11772
|
$companyKnowledgeFolder.innerHTML = '<div class="company-empty">Loading company knowledge…</div>';
|
|
11554
11773
|
$companyKnowledgeList.innerHTML = '';
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11774
|
+
// An earlier opening's change may still be running, which leaves Close disabled; focus the dialog then.
|
|
11775
|
+
($companyKnowledgeClose.disabled ? $companyKnowledgeDialog : $companyKnowledgeClose).focus({ preventScroll: true });
|
|
11776
|
+
try { await loadCompanyKnowledge(companyKnowledgeProjectId, session); }
|
|
11777
|
+
catch (error) {
|
|
11778
|
+
if (session !== companyKnowledgeSession) return;
|
|
11779
|
+
companyKnowledgeState = { configured: false, loadError: companyErrorMessage(error, 'FloLess could not load company references. Check the company folder and try again.') };
|
|
11780
|
+
}
|
|
11781
|
+
if (session === companyKnowledgeSession) renderCompanyKnowledge();
|
|
11559
11782
|
}
|
|
11560
11783
|
|
|
11561
11784
|
function closeCompanyKnowledge(restoreFocus = true) {
|
|
11562
11785
|
if (!$companyKnowledgeModal || !$companyKnowledgeModal.classList.contains('show')) return;
|
|
11563
11786
|
$companyKnowledgeModal.classList.remove('show');
|
|
11787
|
+
companyKnowledgeSession += 1;
|
|
11564
11788
|
const back = companyKnowledgeReturnFocus;
|
|
11565
11789
|
companyKnowledgeReturnFocus = null;
|
|
11566
11790
|
companyKnowledgePromotion = null;
|
|
11567
11791
|
companyKnowledgePending = null;
|
|
11568
11792
|
companyKnowledgeProjectId = null;
|
|
11569
|
-
companySetError('');
|
|
11570
|
-
|
|
11793
|
+
companySetError(''); companySetStatus('');
|
|
11794
|
+
// The Knowledge header repaints while the dialog is open (an Add, the status poll), replacing the
|
|
11795
|
+
// button that opened it; return focus to the one on screen now rather than dropping it on the page.
|
|
11796
|
+
const target = back && back.isConnected ? back : document.querySelector('[data-company-open]');
|
|
11797
|
+
if (restoreFocus && target) target.focus({ preventScroll: true });
|
|
11571
11798
|
}
|
|
11572
11799
|
|
|
11573
11800
|
async function chooseCompanyFolder() {
|
|
11574
11801
|
if (companyKnowledgeBusy) return;
|
|
11802
|
+
const session = companyKnowledgeSession, projectId = companyKnowledgeProjectId;
|
|
11575
11803
|
companyKnowledgeBusy = true; companySetError(''); renderCompanyKnowledge();
|
|
11576
11804
|
try {
|
|
11577
11805
|
const choice = await api('/api/company-knowledge/folder/choose', { method: 'POST', body: '{}' });
|
|
@@ -11579,17 +11807,27 @@
|
|
|
11579
11807
|
await api('/api/company-knowledge/folder/select', {
|
|
11580
11808
|
method: 'POST', body: JSON.stringify({ selectionId: choice.selectionId }),
|
|
11581
11809
|
});
|
|
11582
|
-
|
|
11810
|
+
// The folder is machine-wide: it is connected whichever project is on screen by now.
|
|
11583
11811
|
showToast('Company knowledge folder connected', 'ok');
|
|
11812
|
+
if (session === companyKnowledgeSession) await loadCompanyKnowledge(projectId, session);
|
|
11584
11813
|
}
|
|
11585
|
-
} catch (error) {
|
|
11586
|
-
|
|
11814
|
+
} catch (error) {
|
|
11815
|
+
const message = companyErrorMessage(error, 'FloLess could not use that company folder. Choose another folder and try again.');
|
|
11816
|
+
if (session === companyKnowledgeSession) companySetError(message); else showToast(message, 'warn');
|
|
11817
|
+
}
|
|
11818
|
+
finally { companyKnowledgeBusy = false; if (session === companyKnowledgeSession) renderCompanyKnowledge(); else void companyRefreshAfterStale(); }
|
|
11587
11819
|
}
|
|
11588
11820
|
|
|
11589
11821
|
async function performCompanyKnowledgeAction() {
|
|
11590
11822
|
if (companyKnowledgeBusy || !companyKnowledgeProjectId) return;
|
|
11591
11823
|
const state = companyKnowledgeState;
|
|
11592
11824
|
if (!state || !state.available) return;
|
|
11825
|
+
// #3151: the person cannot close the dialog while this runs, but a project switch still can. Every
|
|
11826
|
+
// await below re-checks the session: a stale result still tells the person what happened, but never
|
|
11827
|
+
// writes into the dialog that replaced it or reloads it with no project.
|
|
11828
|
+
const session = companyKnowledgeSession, projectId = companyKnowledgeProjectId;
|
|
11829
|
+
const projectName = current && current.id === projectId ? current.name : '';
|
|
11830
|
+
const stale = () => session !== companyKnowledgeSession;
|
|
11593
11831
|
companyKnowledgeBusy = true; companySetError(''); renderCompanyKnowledge();
|
|
11594
11832
|
try {
|
|
11595
11833
|
if (companyKnowledgePending?.kind === 'accept') {
|
|
@@ -11597,8 +11835,10 @@
|
|
|
11597
11835
|
const latest = entry && entry.versions[entry.versions.length - 1];
|
|
11598
11836
|
if (!entry || !latest) throw new Error('That company version is no longer available.');
|
|
11599
11837
|
const res = await api(`/api/company-knowledge/sources/${encodeURIComponent(entry.librarySourceId)}/versions/${encodeURIComponent(latest.versionId)}/accept`, {
|
|
11600
|
-
method: 'POST', body: JSON.stringify({ projectId
|
|
11838
|
+
method: 'POST', body: JSON.stringify({ projectId }),
|
|
11601
11839
|
});
|
|
11840
|
+
// Another project is on screen by now: say which project it went to instead of "this project".
|
|
11841
|
+
if (stale()) { showToast(`Added ${entry.displayName} v${entry.versions.length} to ${projectName || 'the project you started it in'}.`, 'ok'); return; }
|
|
11602
11842
|
companyKnowledgePending = null;
|
|
11603
11843
|
// #2491 R6.9: where it went in this project's categories, and why.
|
|
11604
11844
|
const placed = res && res.placement;
|
|
@@ -11606,24 +11846,30 @@
|
|
|
11606
11846
|
} else if (companyKnowledgePending?.kind === 'remove') {
|
|
11607
11847
|
const entry = state.sources.find((row) => row.librarySourceId === companyKnowledgePending.librarySourceId);
|
|
11608
11848
|
await api(`/api/company-knowledge/sources/${encodeURIComponent(companyKnowledgePending.librarySourceId)}`, { method: 'DELETE' });
|
|
11609
|
-
|
|
11849
|
+
// Company-wide, so the toast is true whichever project is on screen now.
|
|
11610
11850
|
showToast(`${entry ? entry.displayName : 'Company reference'} removed`, 'ok');
|
|
11851
|
+
if (stale()) return;
|
|
11852
|
+
companyKnowledgePending = null;
|
|
11611
11853
|
} else if (companyKnowledgePromotion) {
|
|
11612
11854
|
const promoted = await api('/api/company-knowledge/promote', {
|
|
11613
11855
|
method: 'POST', body: JSON.stringify({
|
|
11614
|
-
projectId
|
|
11856
|
+
projectId,
|
|
11615
11857
|
sourceId: companyKnowledgePromotion.sourceId,
|
|
11616
11858
|
librarySourceId: $companyPromotionLineage.value || null,
|
|
11617
11859
|
}),
|
|
11618
11860
|
});
|
|
11619
11861
|
const placed = promoted && promoted.placement;
|
|
11620
11862
|
showToast(`Company reference published${placed && placed.categoryId ? `, in ${placed.where}` : ''}.${placed && placed.note && !placed.categoryId ? ` ${placed.note}` : ''}`, placed && placed.note && !placed.categoryId ? 'warn' : 'ok');
|
|
11863
|
+
if (stale()) return;
|
|
11621
11864
|
companyKnowledgePromotion = null;
|
|
11622
11865
|
}
|
|
11623
|
-
await loadCompanyKnowledge(
|
|
11624
|
-
if (current && current.id ===
|
|
11625
|
-
} catch (error) {
|
|
11626
|
-
|
|
11866
|
+
await loadCompanyKnowledge(projectId, session);
|
|
11867
|
+
if (!stale() && current && current.id === projectId) await renderKnowledge();
|
|
11868
|
+
} catch (error) {
|
|
11869
|
+
// With its dialog gone, the toast is the only place left to say it.
|
|
11870
|
+
if (stale()) showToast(companyErrorMessage(error), 'warn'); else companySetError(companyErrorMessage(error));
|
|
11871
|
+
}
|
|
11872
|
+
finally { companyKnowledgeBusy = false; if (stale()) void companyRefreshAfterStale(); else renderCompanyKnowledge(); }
|
|
11627
11873
|
}
|
|
11628
11874
|
|
|
11629
11875
|
if ($companyKnowledgeModal) {
|
|
@@ -11636,13 +11882,14 @@
|
|
|
11636
11882
|
const remove = event.target.closest('[data-company-stage-remove]');
|
|
11637
11883
|
if (remove) { companyKnowledgePending = { kind: 'remove', librarySourceId: remove.dataset.companyStageRemove }; renderCompanyKnowledge(); $companyKnowledgeAction.focus(); }
|
|
11638
11884
|
});
|
|
11639
|
-
$companyKnowledgeClose.addEventListener('click', () =>
|
|
11885
|
+
$companyKnowledgeClose.addEventListener('click', () => dismissCompanyKnowledge());
|
|
11640
11886
|
$companyKnowledgeCancel.addEventListener('click', () => {
|
|
11887
|
+
if (companyKnowledgeBusy) { companySetStatus(COMPANY_KNOWLEDGE_BUSY_REASON); return; }
|
|
11641
11888
|
if (companyKnowledgePending) { companyKnowledgePending = null; companySetError(''); renderCompanyKnowledge(); }
|
|
11642
11889
|
else closeCompanyKnowledge();
|
|
11643
11890
|
});
|
|
11644
11891
|
$companyKnowledgeAction.addEventListener('click', performCompanyKnowledgeAction);
|
|
11645
|
-
onBackdropDismiss($companyKnowledgeModal, () =>
|
|
11892
|
+
onBackdropDismiss($companyKnowledgeModal, () => dismissCompanyKnowledge());
|
|
11646
11893
|
document.addEventListener('keydown', (event) => {
|
|
11647
11894
|
if (!$companyKnowledgeModal.classList.contains('show')) return;
|
|
11648
11895
|
// #2491 R6.9: the name box and the menus answer their own keys first; Escape closes them, not the dialog.
|
|
@@ -11663,7 +11910,7 @@
|
|
|
11663
11910
|
const at = items.indexOf(document.activeElement);
|
|
11664
11911
|
if (at >= 0) { event.preventDefault(); items[(at + (event.key === 'ArrowDown' ? 1 : items.length - 1)) % items.length].focus(); return; }
|
|
11665
11912
|
}
|
|
11666
|
-
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation();
|
|
11913
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); dismissCompanyKnowledge(); return; }
|
|
11667
11914
|
if (event.key !== 'Tab') return;
|
|
11668
11915
|
const focusable = [...$companyKnowledgeModal.querySelectorAll('button:not([hidden]):not(:disabled), input:not([hidden]):not(:disabled), [tabindex="0"]')]
|
|
11669
11916
|
.filter((node) => node.offsetParent !== null);
|
|
@@ -11759,7 +12006,7 @@
|
|
|
11759
12006
|
showToast(code === 'design-set-changed'
|
|
11760
12007
|
? 'The design set changed while this was open. Check it and choose again.'
|
|
11761
12008
|
// The server's own sentence says what to do (busy, file not in the project, an index it cannot take).
|
|
11762
|
-
: (err && err.body
|
|
12009
|
+
: personText(err && err.body) || 'Couldn’t change the design set. Try again.', 'warn');
|
|
11763
12010
|
}
|
|
11764
12011
|
if (current !== proj) return;
|
|
11765
12012
|
kbInvalidateRefs();
|
|
@@ -12016,7 +12263,7 @@
|
|
|
12016
12263
|
function kbDsErrorText(err, fallback) {
|
|
12017
12264
|
const code = err && err.body && err.body.code;
|
|
12018
12265
|
if (code === 'design-set-changed') return 'The design set changed while this was open. Check it and try again.';
|
|
12019
|
-
return (err && err.body
|
|
12266
|
+
return personText(err && err.body) || fallback;
|
|
12020
12267
|
}
|
|
12021
12268
|
function kbDsOpenPanel(panel, focus) {
|
|
12022
12269
|
kbCloseConfirm();
|
|
@@ -13708,7 +13955,7 @@
|
|
|
13708
13955
|
aborted.push(...hosts.slice(i));
|
|
13709
13956
|
break;
|
|
13710
13957
|
}
|
|
13711
|
-
const detail = (err && err.body
|
|
13958
|
+
const detail = personText(err && err.body) || (err && err.message) || String(err);
|
|
13712
13959
|
failed.push({ host, error: detail });
|
|
13713
13960
|
}
|
|
13714
13961
|
}
|
|
@@ -14425,17 +14672,17 @@
|
|
|
14425
14672
|
// #2449: each approved source carries its own frozen connection-assumptions label from the server, bound to it.
|
|
14426
14673
|
const frozen = (row) => (row && row.connectionAssumptions && typeof row.connectionAssumptions.note === 'string' ? row.connectionAssumptions : null);
|
|
14427
14674
|
// #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) });
|
|
14675
|
+
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
14676
|
if (data.working) out.push({
|
|
14430
14677
|
selector: {
|
|
14431
14678
|
kind: 'working', expectedEtag: data.working.etag,
|
|
14432
14679
|
...(data.working.epoch !== null && Number.isInteger(Number(data.working.epoch)) ? { expectedEpoch: Number(data.working.epoch) } : {}),
|
|
14433
14680
|
},
|
|
14434
|
-
label: 'Working copy · DRAFT', group: 'Drafts', quick: data.working.quick,
|
|
14681
|
+
label: 'Working copy · DRAFT', group: 'Drafts', quick: data.working.quick, coverage: data.working.coverage,
|
|
14435
14682
|
});
|
|
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 });
|
|
14683
|
+
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
14684
|
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) });
|
|
14685
|
+
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
14686
|
}
|
|
14440
14687
|
return out;
|
|
14441
14688
|
}
|
|
@@ -14477,7 +14724,7 @@
|
|
|
14477
14724
|
const rows = options.filter((option) => option.group === group);
|
|
14478
14725
|
if (!rows.length) return '';
|
|
14479
14726
|
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>';
|
|
14727
|
+
+ 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
14728
|
}).join('');
|
|
14482
14729
|
let warning = '';
|
|
14483
14730
|
if (data.defaultUnavailable?.reason === 'refused') {
|
|
@@ -14514,15 +14761,22 @@
|
|
|
14514
14761
|
const source = currentExportSourceOption();
|
|
14515
14762
|
if (!source) return '';
|
|
14516
14763
|
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)
|
|
14764
|
+
const selected = line(source.quick, source.label)
|
|
14765
|
+
// #2554 slice 2: the selected source's unread drawing files, in their own line (a precise source can have them).
|
|
14766
|
+
+ (coveragePillHtml(source.coverage, { besides: source.quick })
|
|
14767
|
+
? `<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
14768
|
// #2521 row 5b: said BEFORE exporting, when this AWARE can only put a Quick model's label in an IFC's names.
|
|
14519
14769
|
const ifcNamesOnly = quickPillHtml(source.quick) && exportSourcesState.data && exportSourcesState.data.exportProvenance === 'name-only'
|
|
14520
14770
|
? '<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
14771
|
: '';
|
|
14522
14772
|
const from = exportStateFrom;
|
|
14523
|
-
const
|
|
14524
|
-
&& !(source.selector.kind === 'latest-approved' && Number(source.version) === Number(from.version))
|
|
14525
|
-
|
|
14773
|
+
const filesListed = from && exportState && Object.values(exportState).some((e) => e && e.exportedAt)
|
|
14774
|
+
&& !(source.selector.kind === 'latest-approved' && Number(source.version) === Number(from.version));
|
|
14775
|
+
const filesScope = filesListed ? `Files below, exported from v${from.version}` : '';
|
|
14776
|
+
const files = (filesListed && from.quick ? line(from.quick, filesScope) : '')
|
|
14777
|
+
// #2554 slice 2: those files' unread drawing files too, when the version they came from left some.
|
|
14778
|
+
+ (filesListed && coveragePillHtml(from.coverage, { besides: from.quick })
|
|
14779
|
+
? `<div class="export-quick-note is-coverage" role="note"><b>${escapeHtml(filesScope)}:</b> ${escapeHtml(from.coverage.text || from.coverage.short)}</div>` : '');
|
|
14526
14780
|
return selected + ifcNamesOnly + files;
|
|
14527
14781
|
}
|
|
14528
14782
|
|
|
@@ -14603,6 +14857,7 @@
|
|
|
14603
14857
|
const approved = projectContractLifecycle === 'model' && exportSourcesState.status === 'ready' && !!currentExportSourceOption();
|
|
14604
14858
|
const approvalRefusal = approvalRefusalNote();
|
|
14605
14859
|
// Same 46px band every other project step carries (see the shared step-header rule in app.css).
|
|
14860
|
+
exportsPaintedGate = exportsLifecycleGateKey();
|
|
14606
14861
|
let html = '<div class="step-head"><span>Exports</span></div>' + exportSourceHtml();
|
|
14607
14862
|
if (!approved) {
|
|
14608
14863
|
// Same split as History's empty state (#490): with a model, Approve is genuinely the unlocking
|
|
@@ -14624,6 +14879,10 @@
|
|
|
14624
14879
|
? '<div class="ws-exports-gate">Drawing Filter saved — read the selected drawing content to build the model before exporting.</div>'
|
|
14625
14880
|
: approvalRefusal
|
|
14626
14881
|
? `<div class="ws-exports-gate">${escapeHtml(approvalRefusal)}</div>`
|
|
14882
|
+
: projectContractLifecycle === 'unknown'
|
|
14883
|
+
? (exportsLifecycleUnanswered
|
|
14884
|
+
? '<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>'
|
|
14885
|
+
: '<div class="ws-exports-gate">Checking what this project holds…</div>')
|
|
14627
14886
|
: hasModel
|
|
14628
14887
|
? `<div class="ws-exports-gate">Exports go out after sign-off — ` +
|
|
14629
14888
|
`<button type="button" id="ws-exports-approve">Approve this version</button> to enable them.</div>`
|
|
@@ -14732,23 +14991,51 @@
|
|
|
14732
14991
|
* for approval and export. The server therefore returns one authoritative value — `absent`,
|
|
14733
14992
|
* `filter-checkpoint`, or `model` — and both History and Exports consume that same answer.
|
|
14734
14993
|
*/
|
|
14735
|
-
async function projectContractState(projectId, appId) {
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
|
|
14742
|
-
|
|
14743
|
-
|
|
14744
|
-
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
14994
|
+
async function projectContractState(projectId, appId, stillWanted) {
|
|
14995
|
+
const budgetMs = 45000, attemptMs = 15000;
|
|
14996
|
+
const url = `/api/projects/${encodeURIComponent(projectId)}/contract-lifecycle?app=${encodeURIComponent(appId)}`;
|
|
14997
|
+
// A SLOW answer is not a missing one (#3139). On a loaded PC this route took 7-10 s while the old
|
|
14998
|
+
// single four-second deadline gave up on every try, so Model never opened however often the
|
|
14999
|
+
// person clicked. Each attempt now gets a longer deadline than the last (15 s, then what is left
|
|
15000
|
+
// of the budget), with a short pause between, until an answer arrives or the budget runs out.
|
|
15001
|
+
// The BUDGET is still a deadline, because a HANG is not an error and would never reach a catch:
|
|
15002
|
+
// every caller awaits this before painting, so without one a wedged connection leaves History
|
|
15003
|
+
// reading "Loading history…" and every Exports destination row on "Checking…" indefinitely.
|
|
15004
|
+
// This GET returns only the small lifecycle envelope, never the contract.
|
|
15005
|
+
// `stillWanted` lets a caller whose answer would be discarded (a project switch, a newer render) stop
|
|
15006
|
+
// asking, so superseded checks do not keep loading the very server that is already slow.
|
|
15007
|
+
const started = Date.now();
|
|
15008
|
+
const deadline = started + budgetMs;
|
|
15009
|
+
// `unknown` has its own unavailable UI and is never treated as `absent`. Say why in the console, since
|
|
15010
|
+
// the person's copy is the same for every cause.
|
|
15011
|
+
const gaveUp = (why, attempts) => {
|
|
15012
|
+
console.warn('[workspaces] project lifecycle check gave up', { projectId, why, attempts, elapsedMs: Date.now() - started });
|
|
14751
15013
|
return 'unknown';
|
|
15014
|
+
};
|
|
15015
|
+
for (let attempt = 0; ; attempt++) {
|
|
15016
|
+
const remaining = deadline - Date.now();
|
|
15017
|
+
if (remaining <= 0) return gaveUp('out of time', attempt);
|
|
15018
|
+
if (stillWanted && !stillWanted()) return 'unknown';
|
|
15019
|
+
let why = '';
|
|
15020
|
+
try {
|
|
15021
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(Math.min(remaining, attemptMs * 2 ** attempt)) });
|
|
15022
|
+
if (res.ok) {
|
|
15023
|
+
// Unknown responses fail closed: approval/export capability is granted only by an explicit
|
|
15024
|
+
// `model` lifecycle, never by a successful request with an unexpected body.
|
|
15025
|
+
const body = await res.json();
|
|
15026
|
+
return ['absent', 'filter-checkpoint', 'model'].includes(body && body.lifecycle) ? body.lifecycle : gaveUp('unexpected answer', attempt + 1);
|
|
15027
|
+
}
|
|
15028
|
+
// A busy or restarting server (5xx, 408, 429) may answer next time; any other refusal will not.
|
|
15029
|
+
if (!(res.status >= 500 || res.status === 408 || res.status === 429)) return gaveUp(`refused (${res.status})`, attempt + 1);
|
|
15030
|
+
why = `busy (${res.status})`;
|
|
15031
|
+
} catch (err) {
|
|
15032
|
+
// A timeout or network failure is worth another try; malformed JSON from a 200 is not.
|
|
15033
|
+
if (err instanceof SyntaxError) return gaveUp('malformed answer', attempt + 1);
|
|
15034
|
+
why = err && err.name || 'network';
|
|
15035
|
+
}
|
|
15036
|
+
const pause = Math.min(1000 * 2 ** attempt, 5000, deadline - Date.now());
|
|
15037
|
+
if (pause <= 0) return gaveUp(`out of time after ${why}`, attempt + 1);
|
|
15038
|
+
await new Promise((resolve) => setTimeout(resolve, pause));
|
|
14752
15039
|
}
|
|
14753
15040
|
}
|
|
14754
15041
|
|
|
@@ -14878,18 +15165,25 @@
|
|
|
14878
15165
|
// inside the pane this fix is for, reachable by opening an empty project and clicking Exports
|
|
14879
15166
|
// while the open-time probe is still in flight.
|
|
14880
15167
|
const paintedWith = exportsHasModel;
|
|
15168
|
+
const handed = exportsLifecycleHanded?.gen === renderGen ? exportsLifecycleHanded.present : '';
|
|
15169
|
+
exportsLifecycleHanded = null;
|
|
15170
|
+
exportsLifecycleUnanswered = handed === 'unknown';
|
|
14881
15171
|
exportSourcesState.status = 'loading';
|
|
14882
15172
|
paintExports(current.approvedAt, restoreKind);
|
|
14883
|
-
const gen = ++modelPresenceGen;
|
|
14884
|
-
|
|
15173
|
+
const gen = handed ? modelPresenceGen : ++modelPresenceGen;
|
|
15174
|
+
exportsLifecycleWait = handed ? 0 : renderGen;
|
|
15175
|
+
const modelPresent = handed || await projectContractState(id, app,
|
|
15176
|
+
() => renderGen === exportsRenderGen && gen === modelPresenceGen && current?.id === id && !$wsExports.hidden);
|
|
14885
15177
|
// `renderGen` is listed for symmetry with the guard below, and it decides NOTHING here: this
|
|
14886
15178
|
// function bumps `exportsRenderGen` and then `modelPresenceGen` with no await between them, so a
|
|
14887
15179
|
// newer render moves both at once and `gen !== modelPresenceGen` has already caught it. The
|
|
14888
15180
|
// reason `modelPresenceGen` could not simply be reused is real but belongs to the LAST guard,
|
|
14889
15181
|
// where it is not checked at all. (Review round 5.)
|
|
15182
|
+
// An overtaken render returns here; syncExportsLifecycleGate redoes it when the overtaking check settles.
|
|
14890
15183
|
if (renderGen !== exportsRenderGen || gen !== modelPresenceGen || !current || current.id !== id || $wsExports.hidden) return;
|
|
14891
|
-
|
|
14892
|
-
if (
|
|
15184
|
+
exportsLifecycleWait = 0;
|
|
15185
|
+
if (!handed) applyModelPresence(modelPresent); // repaints the gate when its answer changed; this repaint restores focus too
|
|
15186
|
+
if (exportsHasModel !== paintedWith || exportsLifecycleUnanswered) paintExports(current.approvedAt, restoreKind);
|
|
14893
15187
|
let state = null;
|
|
14894
15188
|
let units = null; // the server's answer, applied below the staleness guard with the others
|
|
14895
15189
|
let filesFrom = null; // #2449: the approved version the listed files came from, same rule
|
|
@@ -15500,7 +15794,7 @@
|
|
|
15500
15794
|
try {
|
|
15501
15795
|
await api(endpoint, { method: 'POST', body: JSON.stringify({ path: st.path }) });
|
|
15502
15796
|
} catch (err) {
|
|
15503
|
-
const detail = err && err.body
|
|
15797
|
+
const detail = personText(err && err.body);
|
|
15504
15798
|
showToast(detail ? `${failMsg} — ${detail}` : failMsg, 'warn');
|
|
15505
15799
|
}
|
|
15506
15800
|
}
|
|
@@ -15517,7 +15811,7 @@
|
|
|
15517
15811
|
try {
|
|
15518
15812
|
await api(`/api/projects/${encodeURIComponent(projectId)}/exports/open`, { method: 'POST' });
|
|
15519
15813
|
} catch (err) {
|
|
15520
|
-
const detail = err && err.body
|
|
15814
|
+
const detail = personText(err && err.body);
|
|
15521
15815
|
const failMsg = 'Couldn’t open the exports folder';
|
|
15522
15816
|
showToast(detail ? `${failMsg} — ${detail}` : failMsg, 'warn');
|
|
15523
15817
|
}
|
|
@@ -15544,6 +15838,8 @@
|
|
|
15544
15838
|
if (e.target.closest('#ws-exports-approve')) { approveProject(); return; }
|
|
15545
15839
|
// The no-model gate's real next step — mirrors History's #hist-go-drawings.
|
|
15546
15840
|
if (e.target.closest('#ws-exports-go-drawings')) { chooseStep('drawings'); return; }
|
|
15841
|
+
// #3139: the lifecycle check ran out of time; ask again.
|
|
15842
|
+
if (e.target.closest('[data-exports-lifecycle-retry]')) { safeRenderExports('when you asked to check again'); return; }
|
|
15547
15843
|
if (e.target.closest('[data-open-exports-folder]')) { openExportsFolder(); return; }
|
|
15548
15844
|
const details = e.target.closest('[data-export-details]');
|
|
15549
15845
|
if (details) { showExportReceiptDetails(details.dataset.exportDetails, details); return; }
|
|
@@ -16030,7 +16326,7 @@
|
|
|
16030
16326
|
const skipped = Array.isArray(out && out.omitted) ? out.omitted.length : 0;
|
|
16031
16327
|
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
16328
|
if (current === proj) { kbInvalidateRefs(); renderKnowledge(); }
|
|
16033
|
-
} catch (err) { showToast((err && err.body
|
|
16329
|
+
} catch (err) { showToast(personText(err && err.body) || 'Couldn’t add them to the design set. Add them from Knowledge.', 'warn'); }
|
|
16034
16330
|
} } });
|
|
16035
16331
|
}
|
|
16036
16332
|
lastRevState = 'pending';
|
|
@@ -16616,6 +16912,29 @@
|
|
|
16616
16912
|
if (current && last?.req?.project === current.id) syncFilterFlo(last.req, last.view);
|
|
16617
16913
|
}
|
|
16618
16914
|
document.addEventListener('floless:chat-indicator', resyncFilterFlo);
|
|
16915
|
+
// Flo on the 3D model shows what AI Chat is doing on THIS project: the chat's own live mood while it replies, and
|
|
16916
|
+
// Your call while it waits for the person's answer, approval or Do it on a suggested change. Another project's
|
|
16917
|
+
// conversation leaves it idle.
|
|
16918
|
+
function modelFloMood() {
|
|
16919
|
+
const shell = document.getElementById('ai-chat-shell');
|
|
16920
|
+
if (!current || !shell || window.flolessChat?.scopeProjectId?.() !== current.id) return 'idle';
|
|
16921
|
+
if (shell.dataset.approvalPending === 'true') return 'yourcall';
|
|
16922
|
+
const mood = window.flolessChat?.floMood?.();
|
|
16923
|
+
return mood === 'yourcall' || mood === 'thinking' || mood === 'working' ? mood : 'idle';
|
|
16924
|
+
}
|
|
16925
|
+
// The chat changes mood mid-reply without announcing it, so while a model is open the mood is read once a second
|
|
16926
|
+
// (a few in-memory reads) and passed on only when it changed.
|
|
16927
|
+
function syncModelFlo() {
|
|
16928
|
+
const frame = frames.model;
|
|
16929
|
+
if (!frame || !frame.dataset.loaded) { syncModelFlo.sent = null; return; }
|
|
16930
|
+
const mood = modelFloMood();
|
|
16931
|
+
if (mood === syncModelFlo.sent) return;
|
|
16932
|
+
try { frame.contentWindow?.flolessModelFlo?.({ mood }); syncModelFlo.sent = mood; }
|
|
16933
|
+
catch (err) { if (err?.name !== 'SecurityError' && !syncModelFlo.warned) { syncModelFlo.warned = true; console.warn('Flo could not show the AI on the model', err); } }
|
|
16934
|
+
}
|
|
16935
|
+
document.addEventListener('floless:chat-indicator', syncModelFlo);
|
|
16936
|
+
frames.model?.addEventListener('load', () => { syncModelFlo.sent = null; setTimeout(syncModelFlo, 0); });
|
|
16937
|
+
setInterval(syncModelFlo, 1000);
|
|
16619
16938
|
// #2926: Flo's "Answer in AI Chat" opens the read's own conversation, where the question is.
|
|
16620
16939
|
window.addEventListener('floless:filter-flo-answer', () => {
|
|
16621
16940
|
const chatId = syncFilterFlo.last?.req?.chatConversation?.chatId;
|
|
@@ -18603,7 +18922,7 @@
|
|
|
18603
18922
|
`<td><span class="ver${v.current ? ' cur' : ''}">v${escapeHtml(String(v.n))}</span></td>` +
|
|
18604
18923
|
`<td class="htime">${escapeHtml(histWhen(v.ts))}</td>` +
|
|
18605
18924
|
`<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>` +
|
|
18925
|
+
`<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
18926
|
`<td class="change">${revisionNoteHtml(v)}${changeCellHtml(v, meta)}${diffStatus}</td>` +
|
|
18608
18927
|
`<td>${action}</td></tr>`;
|
|
18609
18928
|
// The disclosure row is always emitted (hidden) so toggling is a pure show/hide + lazy fetch.
|
|
@@ -18636,7 +18955,7 @@
|
|
|
18636
18955
|
const resume = allowed.includes('resume')
|
|
18637
18956
|
? `<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
18957
|
: '';
|
|
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>`
|
|
18958
|
+
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
18959
|
+ `<p>This checkpoint stays attached to its original approved base; it is never applied backward into another revision.</p>${resume}</article>`;
|
|
18641
18960
|
}).join('')}</div>`;
|
|
18642
18961
|
}
|
|
@@ -18646,6 +18965,19 @@
|
|
|
18646
18965
|
// #2470 R6.5b: each ledger render is numbered, so one overtaken by a newer render (the person went to Activity and back
|
|
18647
18966
|
// while it was reading) neither paints nor speaks.
|
|
18648
18967
|
let historyRenderGen = 0;
|
|
18968
|
+
// #3139: the ledger render that is waiting on its lifecycle check (0 when none). A check from elsewhere that bumps
|
|
18969
|
+
// modelPresenceGen overtakes that render, which then returns without painting; syncHistoryLifecycleWait renders
|
|
18970
|
+
// again so the pane is never left on "Loading history…" after every check has stopped.
|
|
18971
|
+
// That render is told (by its generation) that an answer is already applied, so it does not ask the server again; it
|
|
18972
|
+
// reads the latest applied answer when it gets there, because it first awaits the ledger and a newer check may land.
|
|
18973
|
+
let historyLifecycleWait = 0;
|
|
18974
|
+
let historyLifecycleHanded = 0;
|
|
18975
|
+
function syncHistoryLifecycleWait() {
|
|
18976
|
+
if (!historyLifecycleWait || historyLifecycleWait !== historyRenderGen || !current || $wsHistory.hidden) return;
|
|
18977
|
+
historyLifecycleWait = 0;
|
|
18978
|
+
historyLifecycleHanded = historyRenderGen + 1;
|
|
18979
|
+
renderHistory();
|
|
18980
|
+
}
|
|
18649
18981
|
/**
|
|
18650
18982
|
* The ledger was on screen and is being hidden (setStep): a render still reading neither paints nor speaks, and a
|
|
18651
18983
|
* revision-note editor it opened will not reopen or repaint it. A note the person already pressed Save on is still
|
|
@@ -18755,10 +19087,15 @@
|
|
|
18755
19087
|
//
|
|
18756
19088
|
// Built with DOM methods rather than innerHTML — the label comes from a descriptor, so it is the
|
|
18757
19089
|
// same "don't route it through a string template at all" rule `importFailedCmdRow` follows.
|
|
18758
|
-
const
|
|
18759
|
-
|
|
19090
|
+
const handed = historyLifecycleHanded === renderGen;
|
|
19091
|
+
historyLifecycleHanded = 0;
|
|
19092
|
+
const gen = handed ? modelPresenceGen : ++modelPresenceGen;
|
|
19093
|
+
historyLifecycleWait = handed ? 0 : renderGen;
|
|
19094
|
+
const hasModel = handed ? projectContractLifecycle : await projectContractState(id, current.app,
|
|
19095
|
+
() => gen === modelPresenceGen && current?.id === id && !$wsHistory.hidden && renderGen === historyRenderGen);
|
|
18760
19096
|
if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden || renderGen !== historyRenderGen) return;
|
|
18761
|
-
|
|
19097
|
+
historyLifecycleWait = 0;
|
|
19098
|
+
if (!handed) applyModelPresence(hasModel); // one answer, every surface — History used to keep its own
|
|
18762
19099
|
const empty = document.createElement('div');
|
|
18763
19100
|
empty.className = 'hist-empty';
|
|
18764
19101
|
const emptyRefusal = approvalRefusalNote();
|
|
@@ -18775,6 +19112,14 @@
|
|
|
18775
19112
|
empty.append(v1, ' and start the ledger.');
|
|
18776
19113
|
} else if (hasModel === 'filter-checkpoint') {
|
|
18777
19114
|
empty.append('Drawing Filter saved. Read the selected drawing content to build the model; History starts after the first drawing read is complete.');
|
|
19115
|
+
} else if (hasModel === 'unknown') {
|
|
19116
|
+
// #3139: the check ran out of time. "Nothing here yet" would claim an empty project FloLess never confirmed.
|
|
19117
|
+
const btn = document.createElement('button');
|
|
19118
|
+
btn.type = 'button';
|
|
19119
|
+
btn.id = 'hist-lifecycle-retry';
|
|
19120
|
+
btn.dataset.commandId = 'shell.workspace-stage-recheck#History';
|
|
19121
|
+
btn.textContent = 'Try again';
|
|
19122
|
+
empty.append('Couldn’t check what this project holds yet. ', btn);
|
|
18778
19123
|
} else {
|
|
18779
19124
|
const btn = document.createElement('button');
|
|
18780
19125
|
btn.type = 'button';
|
|
@@ -19140,16 +19485,20 @@
|
|
|
19140
19485
|
wrap.appendChild(btn);
|
|
19141
19486
|
return wrap;
|
|
19142
19487
|
}
|
|
19143
|
-
function renderDiffPanel(panel, diff, quick) {
|
|
19488
|
+
function renderDiffPanel(panel, diff, quick, coverage) {
|
|
19144
19489
|
panel.textContent = '';
|
|
19145
19490
|
panel.appendChild(diffBasePicker(diff));
|
|
19146
19491
|
for (const c of diffCautions(diff.warnings)) panel.appendChild(c); // above the numbers — context for reading them
|
|
19147
19492
|
// #2521 row 5: each side says what IT rests on, above the tonnage, so a Quick side never reads as precise.
|
|
19148
19493
|
const sides = quick ? [[quick.from, `v${diff.from}`], [quick.to, `v${diff.to}`]].filter(([q]) => quickPillHtml(q)) : [];
|
|
19149
|
-
|
|
19494
|
+
// #2554 slice 2: and which drawing files each side did not read, beside its label.
|
|
19495
|
+
const covers = coverage ? [[coverage.from, quick && quick.from, `v${diff.from}`], [coverage.to, quick && quick.to, `v${diff.to}`]]
|
|
19496
|
+
.filter(([c, q]) => coveragePillHtml(c, { besides: q })) : [];
|
|
19497
|
+
if (sides.length || covers.length) {
|
|
19150
19498
|
const note = el('div', 'hd-quick');
|
|
19151
19499
|
note.setAttribute('role', 'note');
|
|
19152
|
-
note.innerHTML = sides.map(([q, scope]) => quickPillHtml(q, { scope, showScope: true }))
|
|
19500
|
+
note.innerHTML = sides.map(([q, scope]) => quickPillHtml(q, { scope, showScope: true }))
|
|
19501
|
+
.concat(covers.map(([c, q, scope]) => coveragePillHtml(c, { scope, showScope: true, besides: q }))).join(' ');
|
|
19153
19502
|
panel.appendChild(note);
|
|
19154
19503
|
}
|
|
19155
19504
|
panel.appendChild(diffNetHeader(diff.tonnage));
|
|
@@ -19279,8 +19628,9 @@
|
|
|
19279
19628
|
// and server ship together, so that window is a half-finished upgrade, not a supported state.
|
|
19280
19629
|
if (!hasStatus && legacyUnreadableDiff(response.diff)) return { kind: 'unavailable' };
|
|
19281
19630
|
if (!wellFormedDiff(response.diff)) throw new Error('invalid comparison response');
|
|
19631
|
+
const coverage = response.coverage && typeof response.coverage === 'object' ? { coverage: response.coverage } : {};
|
|
19282
19632
|
return response.quick && typeof response.quick === 'object'
|
|
19283
|
-
? { kind: 'available', diff: response.diff, quick: response.quick } : { kind: 'available', diff: response.diff };
|
|
19633
|
+
? { kind: 'available', diff: response.diff, quick: response.quick, ...coverage } : { kind: 'available', diff: response.diff, ...coverage };
|
|
19284
19634
|
}
|
|
19285
19635
|
function restoreDiffFocus(panel, n) {
|
|
19286
19636
|
const target = panel.querySelector('.hd-base')
|
|
@@ -19343,7 +19693,7 @@
|
|
|
19343
19693
|
panel.setAttribute('aria-busy', 'false');
|
|
19344
19694
|
if (progress) progress.textContent = '';
|
|
19345
19695
|
if (decoded.kind === 'unavailable') renderDiffUnavailable(panel);
|
|
19346
|
-
else renderDiffPanel(panel, decoded.diff, decoded.quick);
|
|
19696
|
+
else renderDiffPanel(panel, decoded.diff, decoded.quick, decoded.coverage);
|
|
19347
19697
|
if (opts && opts.restoreBaseFocus) restoreDiffFocus(panel, n);
|
|
19348
19698
|
}
|
|
19349
19699
|
function toggleDiff(btn) {
|
|
@@ -19484,7 +19834,7 @@
|
|
|
19484
19834
|
: `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
19835
|
if (current === proj) kbInvalidateRefs();
|
|
19486
19836
|
})
|
|
19487
|
-
.catch((err) => showToast((err && err.body
|
|
19837
|
+
.catch((err) => showToast(personText(err && err.body) || 'Couldn’t add these drawings to the design set. Try again.', 'warn'))
|
|
19488
19838
|
.finally(() => dsLand.removeAttribute('aria-busy'));
|
|
19489
19839
|
return;
|
|
19490
19840
|
}
|
|
@@ -19497,6 +19847,8 @@
|
|
|
19497
19847
|
// The no-model empty state's real next step: go read a drawing. Same handler shape as the
|
|
19498
19848
|
// Approve it replaces, so the pane keeps owning its own inline actions.
|
|
19499
19849
|
if (e.target.closest('#hist-go-drawings')) { chooseStep('drawings'); return; }
|
|
19850
|
+
// #3139: the lifecycle check ran out of time; ask again from the top.
|
|
19851
|
+
if (e.target.closest('#hist-lifecycle-retry')) { renderHistory(); return; }
|
|
19500
19852
|
if (e.target.closest('.hc-cancel')) { closeRollbackConfirm(); return; }
|
|
19501
19853
|
const go = e.target.closest('[data-hc-go]');
|
|
19502
19854
|
if (go) { rollbackTo(Number(go.dataset.hcGo)); return; }
|
|
@@ -19881,51 +20233,185 @@
|
|
|
19881
20233
|
// it can start at this project's exact exports directory; the old browser download anchor could be
|
|
19882
20234
|
// blocked and always targeted Downloads. Cancel is an ordinary no-op. A per-project guard prevents
|
|
19883
20235
|
// duplicate dialogs without blocking unrelated project actions while the chooser is open.
|
|
19884
|
-
async function downloadProjectExport(id, label) {
|
|
19885
|
-
|
|
19886
|
-
|
|
20236
|
+
async function downloadProjectExport(id, label, choice) {
|
|
20237
|
+
// #2732: the choice made after an oversize warning travels in the query, the same one the Save route takes.
|
|
20238
|
+
const query = new URLSearchParams();
|
|
20239
|
+
if (choice) {
|
|
20240
|
+
query.set('inspected', choice.inspected);
|
|
20241
|
+
if (choice.everything) query.set('everything', 'true');
|
|
20242
|
+
for (const folder of choice.leaveOut) query.append('leaveOut', folder);
|
|
20243
|
+
}
|
|
20244
|
+
const qs = query.toString();
|
|
20245
|
+
const res = await fetch(`/api/projects/${encodeURIComponent(id)}/export.zip${qs ? `?${qs}` : ''}`);
|
|
20246
|
+
if (!res.ok) {
|
|
20247
|
+
const body = await res.json().catch(() => ({}));
|
|
20248
|
+
throw Object.assign(new Error(personText(body) || failureCopy({ status: res.status, body }, { action: 'export this project', retrySafe: true }).text), { status: res.status, body });
|
|
20249
|
+
}
|
|
19887
20250
|
const blob = await res.blob();
|
|
19888
20251
|
const cd = res.headers.get('content-disposition') || '';
|
|
19889
20252
|
const name = (cd.match(/filename="?([^"]+)"?/) || [])[1] || `${label}.zip`;
|
|
20253
|
+
// #2732: what the server actually left out, and whether the archive is within what import accepts (when known).
|
|
20254
|
+
let leftOut = [];
|
|
20255
|
+
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 = []; }
|
|
20256
|
+
const fit = res.headers.get('x-floless-archive-within-import-limit');
|
|
20257
|
+
const withinImportFileLimit = fit === 'true' ? true : fit === 'false' ? false : null;
|
|
19890
20258
|
const url = URL.createObjectURL(blob);
|
|
19891
20259
|
const a = document.createElement('a');
|
|
19892
20260
|
a.href = url; a.download = name;
|
|
19893
20261
|
document.body.appendChild(a); a.click(); a.remove();
|
|
19894
20262
|
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
19895
|
-
return name;
|
|
20263
|
+
return { filename: name, leftOut, withinImportFileLimit };
|
|
19896
20264
|
}
|
|
19897
20265
|
|
|
20266
|
+
/**
|
|
20267
|
+
* #2732: the question when a project is past the archive bounds. Resolves { leaveOut, everything } (the folders to leave
|
|
20268
|
+
* out, earlier ones kept) or null when the person cancels; nothing is exported until they choose.
|
|
20269
|
+
*/
|
|
20270
|
+
let exportOversizeAsk = null;
|
|
20271
|
+
const xoNumber = (value) => Number(value || 0).toLocaleString('en-US');
|
|
20272
|
+
const xoPath = (path) => `<span class="xo-path">${escapeHtml(path)}</span>`;
|
|
20273
|
+
const XO_MAX_LEAVE_OUT = 16;
|
|
20274
|
+
const XO_TITLES = {
|
|
20275
|
+
files: 'Too many files for one archive',
|
|
20276
|
+
folders: 'Too many folders for one archive',
|
|
20277
|
+
depth: 'Folders nested too deep for one archive',
|
|
20278
|
+
time: 'Listing this project’s files is taking too long',
|
|
20279
|
+
};
|
|
20280
|
+
function exportOversizeLead(o) {
|
|
20281
|
+
const lead = {
|
|
20282
|
+
files: `FloLess stopped counting at ${xoNumber(o.limit)} files, the most it can import from one archive.`,
|
|
20283
|
+
folders: `This project holds more than ${xoNumber(o.limit)} folders, more than one archive should hold.`,
|
|
20284
|
+
depth: `A folder inside ${xoPath(String(o.deepFolder || '').split('/').slice(0, 2).join('/'))} is nested more than ${xoNumber(o.limit)} folders deep.`,
|
|
20285
|
+
time: `FloLess was still listing this project’s files after ${xoNumber(o.limit / 1000)} seconds.`,
|
|
20286
|
+
}[o.reason] || 'This project has more files than one archive should hold.';
|
|
20287
|
+
const seen = o.folder && o.folderFiles > 0 && o.reason !== 'depth'
|
|
20288
|
+
? ` At least ${xoNumber(o.folderFiles)} of the files it saw are in ${xoPath(o.folder)}.` : '';
|
|
20289
|
+
return lead + seen;
|
|
20290
|
+
}
|
|
20291
|
+
function askExportOversize(oversize) {
|
|
20292
|
+
const root = document.getElementById('export-oversize-modal');
|
|
20293
|
+
if (!root) return Promise.resolve(null);
|
|
20294
|
+
if (exportOversizeAsk) exportOversizeAsk.close(null);
|
|
20295
|
+
const o = oversize || {};
|
|
20296
|
+
const leftOut = Array.isArray(o.leftOut) ? o.leftOut : [];
|
|
20297
|
+
const canLeaveOut = !!o.folder && leftOut.length < XO_MAX_LEAVE_OUT;
|
|
20298
|
+
const $leave = document.getElementById('xo-leave-out');
|
|
20299
|
+
const $everything = document.getElementById('xo-everything');
|
|
20300
|
+
const $leftOut = document.getElementById('xo-left-out');
|
|
20301
|
+
const returnTo = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
20302
|
+
document.getElementById('xo-title').textContent = XO_TITLES[o.reason] || XO_TITLES.files;
|
|
20303
|
+
document.getElementById('xo-sub').innerHTML = exportOversizeLead(o);
|
|
20304
|
+
const leaveLine = canLeaveOut
|
|
20305
|
+
? `<li><b>Leave this folder out</b> — faster. The archive holds a note naming what was left out.</li>`
|
|
20306
|
+
: `<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>`;
|
|
20307
|
+
document.getElementById('xo-choices').innerHTML = leaveLine
|
|
20308
|
+
+ `<li><b>Export everything</b> — slower. FloLess can import an archive of up to 10,000 files (and 2 GB once unzipped).</li>`;
|
|
20309
|
+
const shown = leftOut.slice(0, 3).map(escapeHtml).join(', ') + (leftOut.length > 3 ? ` +${leftOut.length - 3} more` : '');
|
|
20310
|
+
$leftOut.hidden = !leftOut.length;
|
|
20311
|
+
$leftOut.innerHTML = leftOut.length ? `Already left out, and staying out: ${shown}` : '';
|
|
20312
|
+
$leave.hidden = !canLeaveOut;
|
|
20313
|
+
// With nothing to leave out, Export everything is the one way forward, so it is the primary button.
|
|
20314
|
+
$everything.classList.toggle('primary', !canLeaveOut);
|
|
20315
|
+
$everything.textContent = leftOut.length ? 'Export the rest' : 'Export everything';
|
|
20316
|
+
return new Promise((resolve) => {
|
|
20317
|
+
const close = (result) => {
|
|
20318
|
+
if (exportOversizeAsk !== ask) return;
|
|
20319
|
+
exportOversizeAsk = null;
|
|
20320
|
+
root.classList.remove('show');
|
|
20321
|
+
root.removeEventListener('click', onClick);
|
|
20322
|
+
document.removeEventListener('keydown', onKey, true);
|
|
20323
|
+
if (returnTo && returnTo.isConnected) returnTo.focus();
|
|
20324
|
+
resolve(result);
|
|
20325
|
+
};
|
|
20326
|
+
function onClick(event) {
|
|
20327
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
20328
|
+
if (!target) return;
|
|
20329
|
+
if (target.closest('#xo-cancel')) close(null);
|
|
20330
|
+
else if (target.closest('#xo-everything')) close({ leaveOut: leftOut, everything: true });
|
|
20331
|
+
else if (target.closest('#xo-leave-out') && canLeaveOut) close({ leaveOut: [...leftOut, o.folder], everything: false });
|
|
20332
|
+
}
|
|
20333
|
+
function onKey(event) {
|
|
20334
|
+
if (!root.classList.contains('show')) return;
|
|
20335
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); close(null); return; }
|
|
20336
|
+
if (event.key !== 'Tab') return;
|
|
20337
|
+
const focusable = Array.from(root.querySelectorAll('button')).filter((element) => !element.hidden && element.getClientRects().length);
|
|
20338
|
+
if (!focusable.length) return;
|
|
20339
|
+
const first = focusable[0]; const last = focusable[focusable.length - 1];
|
|
20340
|
+
if (event.shiftKey && (document.activeElement === first || !root.contains(document.activeElement))) { event.preventDefault(); last.focus(); }
|
|
20341
|
+
else if (!event.shiftKey && (document.activeElement === last || !root.contains(document.activeElement))) { event.preventDefault(); first.focus(); }
|
|
20342
|
+
}
|
|
20343
|
+
const ask = { close };
|
|
20344
|
+
exportOversizeAsk = ask;
|
|
20345
|
+
root.addEventListener('click', onClick);
|
|
20346
|
+
document.addEventListener('keydown', onKey, true);
|
|
20347
|
+
root.classList.add('show');
|
|
20348
|
+
(canLeaveOut ? $leave : $everything).focus();
|
|
20349
|
+
});
|
|
20350
|
+
}
|
|
20351
|
+
onBackdropDismiss(document.getElementById('export-oversize-modal'), () => { if (exportOversizeAsk) exportOversizeAsk.close(null); }, () => !!exportOversizeAsk);
|
|
20352
|
+
|
|
19898
20353
|
async function exportProject(id) {
|
|
19899
20354
|
if (projectExportBusy.has(id)) return;
|
|
19900
20355
|
const proj = projects.find((p) => p.id === id);
|
|
19901
20356
|
const label = proj ? proj.name : id;
|
|
19902
20357
|
projectExportBusy.add(id);
|
|
19903
|
-
|
|
19904
|
-
|
|
20358
|
+
let dismissProgress = null;
|
|
20359
|
+
const startProgress = () => { if (!dismissProgress) dismissProgress = showToast(`Exporting “${label}”…`, 'progress'); };
|
|
19905
20360
|
const finishProgress = () => {
|
|
19906
|
-
if (!
|
|
19907
|
-
|
|
19908
|
-
dismissProgress
|
|
20361
|
+
if (!dismissProgress) return;
|
|
20362
|
+
const dismiss = dismissProgress;
|
|
20363
|
+
dismissProgress = null;
|
|
20364
|
+
dismiss();
|
|
20365
|
+
};
|
|
20366
|
+
// #2732: the Save route first, the browser download where the Save dialog is unavailable; both take the same choice.
|
|
20367
|
+
let viaDownload = false;
|
|
20368
|
+
const exportOnce = async (choice) => {
|
|
20369
|
+
if (!viaDownload) {
|
|
20370
|
+
try {
|
|
20371
|
+
return await api(`/api/projects/${encodeURIComponent(id)}/export/save`, { method: 'POST', body: JSON.stringify(choice ? { oversize: choice } : {}) });
|
|
20372
|
+
} catch (err) {
|
|
20373
|
+
if (!(err && err.body && err.body.code === 'native-save-unavailable')) throw err;
|
|
20374
|
+
viaDownload = true;
|
|
20375
|
+
}
|
|
20376
|
+
}
|
|
20377
|
+
return downloadProjectExport(id, label, choice);
|
|
19909
20378
|
};
|
|
19910
20379
|
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') {
|
|
20380
|
+
let choice = null;
|
|
20381
|
+
for (;;) {
|
|
20382
|
+
startProgress();
|
|
20383
|
+
let result;
|
|
19918
20384
|
try {
|
|
19919
|
-
|
|
19920
|
-
|
|
19921
|
-
|
|
19922
|
-
|
|
19923
|
-
|
|
19924
|
-
|
|
19925
|
-
|
|
20385
|
+
result = await exportOnce(choice);
|
|
20386
|
+
} catch (err) {
|
|
20387
|
+
const body = err && err.body;
|
|
20388
|
+
if (body && body.code === 'archive-oversize' && body.oversize) {
|
|
20389
|
+
finishProgress();
|
|
20390
|
+
const picked = await askExportOversize(body.oversize);
|
|
20391
|
+
if (!picked) return;
|
|
20392
|
+
choice = { inspected: body.oversize.inspected, leaveOut: picked.leaveOut, everything: picked.everything };
|
|
20393
|
+
continue;
|
|
20394
|
+
}
|
|
20395
|
+
throw err;
|
|
20396
|
+
}
|
|
20397
|
+
finishProgress();
|
|
20398
|
+
if (result.cancelled) return;
|
|
20399
|
+
const leftOut = Array.isArray(result.leftOut) ? result.leftOut : [];
|
|
20400
|
+
showToast(`Exported “${label}” — ${result.filename}${leftOut.length ? `, without ${leftOut.join(', ')}. The archive notes what was left out.` : ''}`, 'ok');
|
|
20401
|
+
if (result.withinImportFileLimit === false) {
|
|
20402
|
+
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
20403
|
}
|
|
20404
|
+
track('workspace_project_exported', { app: proj ? proj.app : undefined });
|
|
20405
|
+
return;
|
|
19927
20406
|
}
|
|
20407
|
+
} catch (err) {
|
|
19928
20408
|
finishProgress();
|
|
20409
|
+
const body = err && err.body;
|
|
20410
|
+
// A choice made for a project that was replaced while the person chose, or a refused choice: the server's sentence.
|
|
20411
|
+
if (body && (body.code === 'archive-project-changed' || body.code === 'invalid-export-choice') && typeof body.error === 'string') {
|
|
20412
|
+
showToast(body.error, 'warn');
|
|
20413
|
+
return;
|
|
20414
|
+
}
|
|
19929
20415
|
showToast(`We couldn’t export “${label}” because FloLess could not finish preparing it. Try again.`, 'warn');
|
|
19930
20416
|
} finally {
|
|
19931
20417
|
finishProgress();
|