@floless/app 0.134.1 → 0.134.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +2837 -1082
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +268 -31
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +18 -1
- package/dist/web/app.css +14 -0
- package/dist/web/app.js +4 -0
- package/dist/web/commands-filter.js +16 -13
- package/dist/web/commands-shell.js +33 -0
- package/dist/web/commands-steel.js +49 -9
- package/dist/web/commands.js +4 -0
- package/dist/web/connection-review-client.js +120 -0
- package/dist/web/index.html +25 -4
- package/dist/web/instructor.js +29 -11
- package/dist/web/steel-3d-core.js +101 -7
- package/dist/web/steel-3d-view.js +757 -242
- package/dist/web/steel-canvas-guidance.js +9 -1
- package/dist/web/steel-detail-refs.js +118 -0
- package/dist/web/steel-editor.html +1476 -188
- package/dist/web/steel-filter-core.js +53 -22
- package/dist/web/steel-filter.html +472 -78
- package/dist/web/steel-model-v2-client-validation.js +6 -0
- package/dist/web/steel-profile-colours.js +54 -0
- package/dist/web/steel-read-confidence.js +140 -0
- package/dist/web/steel-reference-sheet.js +50 -0
- package/dist/web/steel-view-generation.js +119 -27
- package/dist/web/workspaces.js +444 -58
- package/package.json +2 -1
package/dist/web/workspaces.js
CHANGED
|
@@ -429,19 +429,26 @@
|
|
|
429
429
|
* `openProject` assigns it and sits earlier in the file — a `let` further down works only as long as
|
|
430
430
|
* nothing calls that function during module init, which is not a property worth depending on.
|
|
431
431
|
*
|
|
432
|
-
* Unknown fails closed
|
|
433
|
-
*
|
|
432
|
+
* Unknown still fails closed for actions that require a model. It is not, however, presented as a
|
|
433
|
+
* confirmed stage lock: a project-open probe is routine loading, not evidence that the project is
|
|
434
|
+
* still preliminary.
|
|
434
435
|
*/
|
|
435
436
|
let projectContractLifecycle = 'unknown';
|
|
436
437
|
let exportsHasModel = false;
|
|
437
438
|
// A project may open on Model/Exports/History while its lifecycle probe is still in flight. Keep
|
|
438
|
-
//
|
|
439
|
+
// the most recently requested destination until the probe settles so the latest click counts.
|
|
439
440
|
let pendingPresenceStep = null;
|
|
441
|
+
// Dismiss handle for the one user-initiated checking toast. A later tab click replaces it rather
|
|
442
|
+
// than stacking another copy while both clicks attach to the same lifecycle request.
|
|
443
|
+
let pendingPresenceToast = null;
|
|
440
444
|
|
|
441
445
|
/** Sequence number for model-presence probes. A project-id check is NOT a staleness guard: two
|
|
442
446
|
* probes can be in flight for the SAME project, and an older "absent" answer landing last would
|
|
443
447
|
* re-disable Approve on a project that now has a model. Every writer bumps it; older results drop. */
|
|
444
448
|
let modelPresenceGen = 0;
|
|
449
|
+
// One lifecycle request per open project. Tab clicks attach to this promise instead of starting
|
|
450
|
+
// competing four-second probes whose generation guards make all but the last answer disappear.
|
|
451
|
+
let modelPresenceProbe = null;
|
|
445
452
|
|
|
446
453
|
/** The header's AUTHORED tooltip, captured from the static markup so the has-a-model state restores
|
|
447
454
|
* it verbatim. The first cut substituted "exports unlock after it", which is a FALSE description of
|
|
@@ -1690,12 +1697,15 @@
|
|
|
1690
1697
|
projectContractLifecycle = 'unknown';
|
|
1691
1698
|
exportsHasModel = false;
|
|
1692
1699
|
modelPresenceGen++;
|
|
1700
|
+
modelPresenceProbe = null;
|
|
1693
1701
|
pendingPresenceStep = null;
|
|
1702
|
+
if (pendingPresenceToast) pendingPresenceToast();
|
|
1703
|
+
pendingPresenceToast = null;
|
|
1694
1704
|
exportState = null;
|
|
1695
1705
|
hostReadinessStates = {};
|
|
1696
1706
|
renderReadinessState = null;
|
|
1697
1707
|
track('workspace_project_opened', { app: p.app }); // a real open (card click or post-create landing)
|
|
1698
|
-
resetRevisionState(); closeRevReview(); // fresh project — drop any prior revision state and any open review
|
|
1708
|
+
resetRevisionState(); closeRevisionDiscard(false, false); closeRevReview(); // fresh project — drop any prior revision state and any open review
|
|
1699
1709
|
// Per-project, like everything above it: never let one project's answer describe another's. Not
|
|
1700
1710
|
// observable today (every history render is preceded by a fetch that sets it, and a failed fetch
|
|
1701
1711
|
// renders no rows), but leaving a stale cross-project value in place is the shape of bug this
|
|
@@ -1720,6 +1730,13 @@
|
|
|
1720
1730
|
renderStepTabs(); // paint the tab labels for THIS app before the first step shows
|
|
1721
1731
|
frames.model.src = 'about:blank'; frames.drawings.src = 'about:blank'; // reset any previous project
|
|
1722
1732
|
frames.model.dataset.loaded = ''; frames.drawings.dataset.loaded = '';
|
|
1733
|
+
// Start the small lifecycle envelope BEFORE the heavier approval review request. Both hit the
|
|
1734
|
+
// same localhost event loop; sending approval first could keep the lifecycle request queued until
|
|
1735
|
+
// its four-second client deadline, falsely leaving an existing model in the checking state. This
|
|
1736
|
+
// promise also owns every tab activation until it settles (refreshModelPresence deduplicates it).
|
|
1737
|
+
refreshModelPresence(p.id, p.app).catch((e) => {
|
|
1738
|
+
console.error('[workspaces] could not resolve model presence', e);
|
|
1739
|
+
});
|
|
1723
1740
|
// BEFORE the first step renders, and that order is the fix rather than a tidy-up.
|
|
1724
1741
|
//
|
|
1725
1742
|
// `initialStep` is not always 'model' — a project re-opened from the picker keeps `currentStep`,
|
|
@@ -1739,12 +1756,6 @@
|
|
|
1739
1756
|
setStep(pendingPresenceStep ? 'drawings' : initialStep);
|
|
1740
1757
|
applyMode();
|
|
1741
1758
|
syncWorkspaceGuide(); // point the shared beacon at THIS project's document lifecycle
|
|
1742
|
-
// Detached, but never silent: the lifecycle probe cannot reject, yet the code after its await can
|
|
1743
|
-
// (stepLabel -> wsApp on a descriptor without steps), and an unhandled rejection would leave the
|
|
1744
|
-
// header un-updated with nothing said.
|
|
1745
|
-
refreshModelPresence(p.id, p.app).catch((e) => { // gate the header CHECK Approve for THIS project (#490)
|
|
1746
|
-
console.error('[workspaces] could not resolve model presence', e);
|
|
1747
|
-
});
|
|
1748
1759
|
}
|
|
1749
1760
|
|
|
1750
1761
|
/**
|
|
@@ -1758,18 +1769,43 @@
|
|
|
1758
1769
|
* person who needs it — and `approveProject` re-checks the same flag rather than trusting the
|
|
1759
1770
|
* attribute.
|
|
1760
1771
|
*/
|
|
1761
|
-
async function refreshModelPresence(projectId, appId) {
|
|
1772
|
+
async function refreshModelPresence(projectId, appId, supersede = false) {
|
|
1773
|
+
// A caller may attach to a probe that a model-creating mutation supersedes a moment later. Follow
|
|
1774
|
+
// same-project successors until one actually applies, so that caller cannot mistake the stale
|
|
1775
|
+
// probe's completion for an authoritative timeout and show a false retry warning.
|
|
1776
|
+
const awaitAuthoritative = async (initialPromise) => {
|
|
1777
|
+
let observed = initialPromise;
|
|
1778
|
+
let applied = await observed;
|
|
1779
|
+
while (!applied) {
|
|
1780
|
+
const successor = modelPresenceProbe;
|
|
1781
|
+
if (!successor || successor.projectId !== projectId || successor.promise === observed) return false;
|
|
1782
|
+
observed = successor.promise;
|
|
1783
|
+
applied = await observed;
|
|
1784
|
+
}
|
|
1785
|
+
return true;
|
|
1786
|
+
};
|
|
1787
|
+
if (!supersede && modelPresenceProbe?.projectId === projectId) {
|
|
1788
|
+
return awaitAuthoritative(modelPresenceProbe.promise);
|
|
1789
|
+
}
|
|
1762
1790
|
const gen = ++modelPresenceGen;
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1791
|
+
const promise = (async () => {
|
|
1792
|
+
const present = await projectContractState(projectId, appId);
|
|
1793
|
+
if (gen !== modelPresenceGen || !current || current.id !== projectId) return false; // superseded
|
|
1794
|
+
const restore = pendingPresenceStep?.projectId === projectId ? pendingPresenceStep.step : '';
|
|
1795
|
+
// A timeout/network error is not evidence that this project has no model. Keep the requested
|
|
1796
|
+
// destination so its next activation can retry the probe and restore it after recovery.
|
|
1797
|
+
if (present !== 'unknown') pendingPresenceStep = null;
|
|
1798
|
+
applyModelPresence(present);
|
|
1799
|
+
// Restore only when this same project's authoritative answer says a model exists. A confirmed
|
|
1800
|
+
// preliminary lifecycle remains on Drawing Filter and gets the real prerequisite gate below.
|
|
1801
|
+
if (present === 'model' && restore && currentStep === 'drawings') setStep(restore);
|
|
1802
|
+
return true;
|
|
1803
|
+
})();
|
|
1804
|
+
modelPresenceProbe = { projectId, promise };
|
|
1805
|
+
try { return await awaitAuthoritative(promise); }
|
|
1806
|
+
finally {
|
|
1807
|
+
if (modelPresenceProbe?.promise === promise) modelPresenceProbe = null;
|
|
1808
|
+
}
|
|
1773
1809
|
}
|
|
1774
1810
|
|
|
1775
1811
|
/** Push the answer to the flag AND the header together, so no two surfaces can disagree. */
|
|
@@ -1795,6 +1831,7 @@
|
|
|
1795
1831
|
// `revReviewState.projectId` still named the project the user had just left — so confirming would
|
|
1796
1832
|
// have applied a review to a project that was no longer on screen. The card is hidden two lines
|
|
1797
1833
|
// down for the same reason; the modal was simply missed.
|
|
1834
|
+
closeRevisionDiscard(false, false);
|
|
1798
1835
|
closeRevReview();
|
|
1799
1836
|
// from the OPEN project's contract and is what gates the `⋯` menu item — left set, the landing
|
|
1800
1837
|
// kebab for the project just closed would still offer "Convert to the 3D model…", and clicking it
|
|
@@ -1803,7 +1840,9 @@
|
|
|
1803
1840
|
// was already per-project, the two variables behind it were not.)
|
|
1804
1841
|
// Reset with the rest of the per-project state — this file resets `histDiffSupported` for exactly
|
|
1805
1842
|
// this reason. Bumping the generation also voids any probe still in flight for the closing project.
|
|
1806
|
-
projectContractLifecycle = 'unknown'; exportsHasModel = false; modelPresenceGen++; pendingPresenceStep = null;
|
|
1843
|
+
projectContractLifecycle = 'unknown'; exportsHasModel = false; modelPresenceGen++; modelPresenceProbe = null; pendingPresenceStep = null;
|
|
1844
|
+
if (pendingPresenceToast) pendingPresenceToast();
|
|
1845
|
+
pendingPresenceToast = null;
|
|
1807
1846
|
closeProjMenu(); applyMode(); syncWorkspaceGuide(); // revision state cleared by resetRevisionState() above
|
|
1808
1847
|
}
|
|
1809
1848
|
document.getElementById('ws-back').addEventListener('click', closeProject);
|
|
@@ -1843,7 +1882,9 @@
|
|
|
1843
1882
|
return `${revCardReq?.clearWhy || 'FloLess cannot safely release this drawing read yet.'} Open Requests for the available recovery.`;
|
|
1844
1883
|
}
|
|
1845
1884
|
if (unavailableInitial) return 'This drawing read uses a status this version of FloLess does not recognize. Open Requests for details and update FloLess before continuing.';
|
|
1846
|
-
|
|
1885
|
+
// Loading is not a prerequisite failure. setStep keeps the safety boundary by queueing later
|
|
1886
|
+
// stages until this probe produces a real lifecycle answer.
|
|
1887
|
+
if (projectContractLifecycle === 'unknown') return '';
|
|
1847
1888
|
if (step === 'model') {
|
|
1848
1889
|
if (waitingForInitial && revCardReq?.filterSaved) return 'The Drawing Filter is saved. Return to the same terminal AI session that prepared it and tell it to continue the drawing read.';
|
|
1849
1890
|
if (waitingForInitial && revCardReq?.prepassReady) return 'Review the selected lines, then press Save filter. After Save, return to the terminal AI that prepared it and tell it to continue.';
|
|
@@ -1921,8 +1962,6 @@
|
|
|
1921
1962
|
: `The drawing read failed · ${revCardReq?.clearWhy || 'FloLess cannot safely release this drawing read yet.'} Open Requests for the available recovery.`)
|
|
1922
1963
|
: unavailableInitial
|
|
1923
1964
|
? 'This drawing read uses a status this version of FloLess does not recognize · Open Requests for details and update FloLess before continuing.'
|
|
1924
|
-
: projectContractLifecycle === 'unknown'
|
|
1925
|
-
? 'Checking which project stages are ready… You can keep working in Drawing Filter. Select Model, Exports, or History to retry the check.'
|
|
1926
1965
|
: waitingForInitial && revCardReq?.filterSaved
|
|
1927
1966
|
? 'Stage 1 of 4 complete · The Drawing Filter is saved. Return to the same terminal AI session that prepared it and tell it to continue the drawing read. Model, Exports, and History unlock when it finishes.'
|
|
1928
1967
|
: waitingForInitial && revCardReq?.prepassReady
|
|
@@ -1934,7 +1973,45 @@
|
|
|
1934
1973
|
: 'Start in Drawing Filter by attaching a PDF or image. The Model, Exports, and History stages unlock after the first steel model is created.';
|
|
1935
1974
|
}
|
|
1936
1975
|
|
|
1976
|
+
function deferStageUntilLifecycle(s) {
|
|
1977
|
+
const d = wsApp();
|
|
1978
|
+
if (!current || !d?.filter || projectContractLifecycle !== 'unknown'
|
|
1979
|
+
|| !['model', 'exports', 'history'].includes(s)) return false;
|
|
1980
|
+
pendingPresenceStep = { projectId: current.id, step: s };
|
|
1981
|
+
const projectId = current.id;
|
|
1982
|
+
if (pendingPresenceToast) pendingPresenceToast();
|
|
1983
|
+
const intentToast = showToast(`Checking project stages… ${stepLabel(s)} will open when ready.`, 'info');
|
|
1984
|
+
pendingPresenceToast = intentToast;
|
|
1985
|
+
refreshModelPresence(projectId, current.app).then(() => {
|
|
1986
|
+
// A later click owns the shared probe's feedback and destination.
|
|
1987
|
+
if (pendingPresenceToast !== intentToast) return;
|
|
1988
|
+
intentToast();
|
|
1989
|
+
pendingPresenceToast = null;
|
|
1990
|
+
// The request's four-second deadline is a recovery boundary, not a silent discarded click.
|
|
1991
|
+
if (current?.id !== projectId) return;
|
|
1992
|
+
if (projectContractLifecycle === 'unknown') {
|
|
1993
|
+
showToast(`Couldn’t check project stages. Select ${stepLabel(s)} again to retry.`, 'warn');
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
// A confirmed preliminary answer turns the apparent availability into the real prerequisite
|
|
1997
|
+
// gate. Reuse that specific explanation instead of replacing it with generic readiness copy.
|
|
1998
|
+
const reason = stageGateFor(s);
|
|
1999
|
+
if (reason) showToast(reason, 'warn');
|
|
2000
|
+
}).catch((err) => {
|
|
2001
|
+
if (pendingPresenceToast === intentToast) {
|
|
2002
|
+
intentToast();
|
|
2003
|
+
pendingPresenceToast = null;
|
|
2004
|
+
}
|
|
2005
|
+
console.error('[workspaces] tab lifecycle check failed', err);
|
|
2006
|
+
});
|
|
2007
|
+
return true;
|
|
2008
|
+
}
|
|
2009
|
+
|
|
1937
2010
|
function setStep(s) {
|
|
2011
|
+
// Keep the tab visually available while the routine open-project check runs, but do not cross
|
|
2012
|
+
// the model boundary speculatively. The existing request is reused and this destination opens
|
|
2013
|
+
// automatically if it reports a model; the most recent click wins.
|
|
2014
|
+
if (deferStageUntilLifecycle(s)) return;
|
|
1938
2015
|
const lockedReason = stageGateFor(s);
|
|
1939
2016
|
if (lockedReason) {
|
|
1940
2017
|
if (currentStep !== 'drawings') setStep('drawings');
|
|
@@ -1986,17 +2063,10 @@
|
|
|
1986
2063
|
if (b?.getAttribute('aria-disabled') === 'true') {
|
|
1987
2064
|
e.preventDefault();
|
|
1988
2065
|
const reason = stageGateFor(b.dataset.step);
|
|
1989
|
-
if (projectContractLifecycle === 'unknown' && current) {
|
|
1990
|
-
pendingPresenceStep = { projectId: current.id, step: b.dataset.step };
|
|
1991
|
-
refreshModelPresence(current.id, current.app).catch((err) => console.error('[workspaces] could not retry model presence', err));
|
|
1992
|
-
}
|
|
1993
2066
|
if (reason) showToast(reason, 'warn');
|
|
1994
2067
|
return;
|
|
1995
2068
|
}
|
|
1996
|
-
if (b)
|
|
1997
|
-
pendingPresenceStep = null;
|
|
1998
|
-
setStep(b.dataset.step);
|
|
1999
|
-
}
|
|
2069
|
+
if (b) setStep(b.dataset.step);
|
|
2000
2070
|
});
|
|
2001
2071
|
|
|
2002
2072
|
// ── Approve (per-project) ───────────────────────────────────────────────────
|
|
@@ -5523,6 +5593,10 @@
|
|
|
5523
5593
|
// no SSE hook — and refreshes History on completion. Cards are DOM-built (textContent, never
|
|
5524
5594
|
// innerHTML) so an AI-supplied error string can never reach the DOM as markup.
|
|
5525
5595
|
let lastRevState = 'none';
|
|
5596
|
+
// A reconstruction refusal is permanent for that immutable staged generation. Remember it for this
|
|
5597
|
+
// browser session so the 3-second request poll cannot resurrect a Review action that the server has
|
|
5598
|
+
// already proved will never work. The exact stage id keeps a later replacement generation eligible.
|
|
5599
|
+
const unavailableRevisionReviewStages = new Set();
|
|
5526
5600
|
let revBaseVersion = 0; // the ledger head captured at attach — success = the head advances past it
|
|
5527
5601
|
let revBaseProject = null; // …and WHICH project it was captured in; a baseline means nothing anywhere else
|
|
5528
5602
|
let revCardReq = null;
|
|
@@ -5563,6 +5637,18 @@
|
|
|
5563
5637
|
$revisionCard.replaceChildren();
|
|
5564
5638
|
}
|
|
5565
5639
|
const isInitialRevisionRead = (req) => !req || !req.baseVersion || req.baseVersion <= 0;
|
|
5640
|
+
function isRevisionStale(req) {
|
|
5641
|
+
return !!req && Number.isInteger(req.baseVersion) && Number.isInteger(req.headVersion)
|
|
5642
|
+
&& req.baseVersion !== req.headVersion;
|
|
5643
|
+
}
|
|
5644
|
+
function canDiscardRevision(req) {
|
|
5645
|
+
if (!req || req.canDiscardRevision !== true) return false;
|
|
5646
|
+
if (typeof req.stageId === 'string' && req.stageId.trim().length > 0) return true;
|
|
5647
|
+
// An audited staged request can lose its pointer/record identity to a torn or corrupt write. Its
|
|
5648
|
+
// server cleanup removes the opaque request directory before the request row, so it remains safe
|
|
5649
|
+
// to offer Discard even though there is no generation token the browser could honestly send.
|
|
5650
|
+
return req.status === 'staged' && req.steelAuditPolicy === 1;
|
|
5651
|
+
}
|
|
5566
5652
|
function stopRevisionPoll() { if (revisionPoll) { clearInterval(revisionPoll); revisionPoll = null; } }
|
|
5567
5653
|
function startRevisionPoll() {
|
|
5568
5654
|
stopRevisionPoll();
|
|
@@ -5686,14 +5772,45 @@
|
|
|
5686
5772
|
function buildStagedCard(req) {
|
|
5687
5773
|
// A STATIC dot, not the pending spinner: the read has finished and nothing is in flight. The
|
|
5688
5774
|
// spinner would say the opposite, and this state can sit here indefinitely — it waits on a person.
|
|
5775
|
+
const stale = isRevisionStale(req);
|
|
5776
|
+
const hasGeneration = typeof req.stageId === 'string' && req.stageId.trim().length > 0;
|
|
5777
|
+
const reviewUnavailable = hasGeneration && unavailableRevisionReviewStages.has(req.stageId);
|
|
5778
|
+
const canDiscard = canDiscardRevision(req);
|
|
5689
5779
|
const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
|
|
5690
5780
|
const txt = revEl('span', 'wrc-text');
|
|
5691
|
-
txt.appendChild(revEl('b', null, 'A revision is ready for your review.'));
|
|
5692
|
-
txt.appendChild(document.createTextNode(
|
|
5781
|
+
txt.appendChild(revEl('b', null, !hasGeneration || reviewUnavailable ? 'This revision is unavailable.' : stale ? 'This revision can’t be applied.' : 'A revision is ready for your review.'));
|
|
5782
|
+
txt.appendChild(document.createTextNode(!hasGeneration || reviewUnavailable
|
|
5783
|
+
? reviewUnavailable
|
|
5784
|
+
? canDiscard
|
|
5785
|
+
? ' The original proposal cannot be reconstructed. Discard this read, then attach the drawing set again.'
|
|
5786
|
+
: ' The original proposal cannot be reconstructed.'
|
|
5787
|
+
: canDiscard
|
|
5788
|
+
? ' The staged generation could not be recovered. Discard this read, then attach the drawing set again.'
|
|
5789
|
+
: ' The staged generation could not be recovered.'
|
|
5790
|
+
: stale
|
|
5791
|
+
? canDiscard
|
|
5792
|
+
? ` This read started from v${req.baseVersion}, but the project is now at v${req.headVersion}. View its proposed changes or discard it, then attach the drawing set again.`
|
|
5793
|
+
: ` This read started from v${req.baseVersion}, but the project is now at v${req.headVersion}. View its proposed changes. Release the current owner, then return here to discard it before attaching the drawing set again.`
|
|
5794
|
+
: canDiscard
|
|
5795
|
+
? ' Nothing has been applied yet — review what this read may change, or discard it to attach another set.'
|
|
5796
|
+
: ' Nothing has been applied yet — review what this read may change.'));
|
|
5797
|
+
if (!canDiscard && req.discardWhy) {
|
|
5798
|
+
txt.appendChild(document.createTextNode(` ${req.discardWhy} When that ownership is released, return here to discard the read safely.`));
|
|
5799
|
+
} else if (!canDiscard && req.canClear === false) {
|
|
5800
|
+
txt.appendChild(document.createTextNode(` ${req.clearWhy || 'FloLess cannot safely release this drawing read yet.'} Open Requests for the available recovery.`));
|
|
5801
|
+
}
|
|
5693
5802
|
const actions = revEl('span', 'wrc-actions');
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5803
|
+
if (hasGeneration && !reviewUnavailable) {
|
|
5804
|
+
const review = revEl('button', 'btn-mini', stale ? 'View proposed changes' : 'Review changes');
|
|
5805
|
+
review.type = 'button'; review.dataset.revreview = ''; review.dataset.commandId = 'shell.revision-review-open';
|
|
5806
|
+
actions.appendChild(review);
|
|
5807
|
+
}
|
|
5808
|
+
if (canDiscard) {
|
|
5809
|
+
const discard = revEl('button', 'btn-mini wrc-discard', 'Discard read…');
|
|
5810
|
+
discard.type = 'button'; discard.dataset.revdiscard = ''; discard.dataset.commandId = 'shell.revision-discard-open';
|
|
5811
|
+
discard.setAttribute('data-tip', 'Remove this staged drawing read without changing the model or History');
|
|
5812
|
+
actions.appendChild(discard);
|
|
5813
|
+
}
|
|
5697
5814
|
return [dot, txt, actions];
|
|
5698
5815
|
}
|
|
5699
5816
|
function buildFailedCard(req) {
|
|
@@ -5815,7 +5932,13 @@
|
|
|
5815
5932
|
// pane — which on the drop-a-drawing flow is Drawings, neither of them. Without this the header
|
|
5816
5933
|
// stays gated, telling the user to read a drawing they just finished reading. (approveProject
|
|
5817
5934
|
// re-probes so the ACTION is never blocked; this stops the chrome lying in the meantime.)
|
|
5818
|
-
|
|
5935
|
+
// The read may have CREATED the first model. Do not attach this refresh to the older
|
|
5936
|
+
// pre-read lifecycle request: that answer describes the checkpoint before the mutation and
|
|
5937
|
+
// could re-lock the tabs after the model exists. Superseding bumps the generation so the old
|
|
5938
|
+
// answer is ignored and this post-mutation request becomes authoritative.
|
|
5939
|
+
refreshModelPresence(proj.id, proj.app, true).catch((e) => {
|
|
5940
|
+
console.error('[workspaces] post-read model presence did not refresh', e);
|
|
5941
|
+
});
|
|
5819
5942
|
// AND the approval state, which model presence alone no longer covers. Before "not reviewable"
|
|
5820
5943
|
// was told apart from "the probe failed", an empty project sat in the ERROR state here and the
|
|
5821
5944
|
// header's click-to-retry quietly repaired it on the next click. That retry is gone by design —
|
|
@@ -5854,13 +5977,15 @@
|
|
|
5854
5977
|
// and the modal is the authority on this request until it closes. If the request vanished from
|
|
5855
5978
|
// under it, the modal's own confirm learns that from the server and closes; the next tick then
|
|
5856
5979
|
// paints the truth.
|
|
5857
|
-
if (revReviewState) return;
|
|
5858
|
-
const cardKey = `${state}:${revCardReq ? revCardReq.id : ''}:${pending && pending.filterSaved ? 'filter-saved' : pending && pending.prepassReady ? 'filter-ready' : 'read-pending'}:${pending && pending.run ? pending.run.state || '' : ''}
|
|
5980
|
+
if (revReviewState || revDiscardState) return;
|
|
5981
|
+
const cardKey = `${state}:${revCardReq ? revCardReq.id : ''}:${pending && pending.filterSaved ? 'filter-saved' : pending && pending.prepassReady ? 'filter-ready' : 'read-pending'}:${pending && pending.run ? pending.run.state || '' : ''}`
|
|
5982
|
+
+ (staged ? `:${staged.baseVersion}:${staged.headVersion}:${staged.stageId || ''}:${staged.canDiscardRevision === true}:${staged.discardState || ''}:${staged.discardWhy || ''}:${staged.canClear === true}:${staged.clearWhy || ''}:${unavailableRevisionReviewStages.has(staged.stageId)}` : '');
|
|
5859
5983
|
if ($revisionCard._renderKey === cardKey && !$revisionCard.hidden) return; // preserve focus across the 3 s poll
|
|
5860
5984
|
const restoreFocus = typeof document !== 'undefined' && $revisionCard.contains(document.activeElement);
|
|
5861
5985
|
$revisionCard._renderKey = cardKey;
|
|
5862
5986
|
$revisionCard.className = 'ws-revision-card state-' + state
|
|
5863
|
-
+ (pending && pending.filterSaved ? ' state-filter-saved' : pending && pending.prepassReady ? ' state-filter-ready' : '')
|
|
5987
|
+
+ (pending && pending.filterSaved ? ' state-filter-saved' : pending && pending.prepassReady ? ' state-filter-ready' : '')
|
|
5988
|
+
+ (staged && isRevisionStale(staged) ? ' state-stale' : '');
|
|
5864
5989
|
$revisionCard.replaceChildren(...(
|
|
5865
5990
|
state === 'failed' ? buildFailedCard(failed)
|
|
5866
5991
|
: state === 'staged' ? buildStagedCard(staged)
|
|
@@ -5893,10 +6018,35 @@
|
|
|
5893
6018
|
frame.src = frame.dataset.want;
|
|
5894
6019
|
}
|
|
5895
6020
|
|
|
6021
|
+
/**
|
|
6022
|
+
* Close the load race between the base Drawing Filter navigation and the async request poll.
|
|
6023
|
+
*
|
|
6024
|
+
* `syncDrawingRevisionRequest` can update `dataset.want` while the iframe is still booting the URL
|
|
6025
|
+
* assigned by `setStep`. In that window the child bridge does not exist yet, and the older navigation
|
|
6026
|
+
* can finish after the sync attempt, leaving the parent authoritative target on the checkpoint while
|
|
6027
|
+
* the visible child stays on the empty base URL. Reconcile after every child load, when its final URL
|
|
6028
|
+
* is observable. Exact path + query equality prevents a reload loop and preserves the bridge path for
|
|
6029
|
+
* an already-loaded editor with unsaved facet changes.
|
|
6030
|
+
*/
|
|
6031
|
+
function reconcileDrawingRevisionRequestAfterLoad() {
|
|
6032
|
+
const frame = frames.drawings;
|
|
6033
|
+
if (!frame?.dataset.loaded || !frame.dataset.want) return;
|
|
6034
|
+
try {
|
|
6035
|
+
const wanted = new URL(frame.dataset.want, location.origin);
|
|
6036
|
+
const shown = new URL(frame.contentWindow.location.href);
|
|
6037
|
+
if (shown.pathname === wanted.pathname && shown.search === wanted.search) return;
|
|
6038
|
+
} catch { /* the loaded child is not ready/same-origin — navigate to the authoritative target */ }
|
|
6039
|
+
frame.src = frame.dataset.want;
|
|
6040
|
+
}
|
|
6041
|
+
frames.drawings.addEventListener('load', () => {
|
|
6042
|
+
requestAnimationFrame(reconcileDrawingRevisionRequestAfterLoad);
|
|
6043
|
+
});
|
|
6044
|
+
|
|
5896
6045
|
function focusDrawingFilterSave() {
|
|
5897
6046
|
const frame = frames.drawings;
|
|
5898
6047
|
if (!frame) return;
|
|
5899
6048
|
let onLoad;
|
|
6049
|
+
const focusTarget = frame.dataset.want;
|
|
5900
6050
|
const focusSave = () => {
|
|
5901
6051
|
try {
|
|
5902
6052
|
const shown = new URL(frame.contentWindow.location.href);
|
|
@@ -5915,8 +6065,16 @@
|
|
|
5915
6065
|
return true;
|
|
5916
6066
|
} catch { return false; }
|
|
5917
6067
|
};
|
|
5918
|
-
onLoad = () => requestAnimationFrame(() => {
|
|
5919
|
-
|
|
6068
|
+
onLoad = () => requestAnimationFrame(() => {
|
|
6069
|
+
// The promised target belongs to the exact request/project that rendered the CTA. If navigation
|
|
6070
|
+
// retires it before the load settles, drop this listener rather than focusing a later project.
|
|
6071
|
+
if (frame.dataset.want !== focusTarget) { frame.removeEventListener('load', onLoad); return; }
|
|
6072
|
+
if (!focusSave()) frame.focus();
|
|
6073
|
+
});
|
|
6074
|
+
// Keep listening until `focusSave()` reaches the promised target. A stale/base load may fire
|
|
6075
|
+
// first and be followed by `reconcileDrawingRevisionRequestAfterLoad`'s authoritative checkpoint
|
|
6076
|
+
// navigation; `{ once:true }` would consume the promise on that intermediate document.
|
|
6077
|
+
frame.addEventListener('load', onLoad);
|
|
5920
6078
|
if (!focusSave()) frame.focus();
|
|
5921
6079
|
}
|
|
5922
6080
|
|
|
@@ -5943,6 +6101,8 @@
|
|
|
5943
6101
|
if (!req) return;
|
|
5944
6102
|
if (e.target.closest('[data-revreview]')) {
|
|
5945
6103
|
openRevisionReview(req);
|
|
6104
|
+
} else if (e.target.closest('[data-revdiscard]')) {
|
|
6105
|
+
openRevisionDiscard(req, e.target.closest('[data-revdiscard]'));
|
|
5946
6106
|
} else if (e.target.closest('[data-revcopy]') && bridge.copyRequest) {
|
|
5947
6107
|
const copyButton = e.target.closest('[data-revcopy]');
|
|
5948
6108
|
await copyRevisionCardRequest(req, copyButton);
|
|
@@ -5964,13 +6124,22 @@
|
|
|
5964
6124
|
// the arrays it sent. So this render must preserve the order it was given, and must never filter or
|
|
5965
6125
|
// re-sort a bucket — an index is only meaningful against the array it was shown in.
|
|
5966
6126
|
const $revReview = document.getElementById('revreview-modal');
|
|
6127
|
+
const $revReviewTitle = document.getElementById('revreview-title');
|
|
5967
6128
|
const $revReviewBody = document.getElementById('revreview-body');
|
|
5968
6129
|
const $revReviewCounts = document.getElementById('revreview-counts');
|
|
5969
6130
|
const $revReviewChanged = document.getElementById('revreview-changed');
|
|
5970
6131
|
const $revReviewSub = document.getElementById('revreview-sub');
|
|
5971
6132
|
const $revReviewConfirm = document.getElementById('revreview-confirm');
|
|
5972
6133
|
const $revReviewCancel = document.getElementById('revreview-cancel');
|
|
5973
|
-
|
|
6134
|
+
const $revReviewDiscard = document.getElementById('revreview-discard');
|
|
6135
|
+
const $revDiscard = document.getElementById('revdiscard-modal');
|
|
6136
|
+
const $revDiscardDialog = $revDiscard.querySelector('.revision-discard');
|
|
6137
|
+
const $revDiscardSub = document.getElementById('revdiscard-sub');
|
|
6138
|
+
const $revDiscardError = document.getElementById('revdiscard-error');
|
|
6139
|
+
const $revDiscardCancel = document.getElementById('revdiscard-cancel');
|
|
6140
|
+
const $revDiscardConfirm = document.getElementById('revdiscard-confirm');
|
|
6141
|
+
let revReviewState = null; // { projectId, requestId, stageId, summary, request, stale, returnFocus }
|
|
6142
|
+
let revDiscardState = null; // { projectId, requestId, stageId, request, returnFocus, reviewWasOpen, terminal, coveredRoots }
|
|
5974
6143
|
|
|
5975
6144
|
/** `elevation_in` → `Elevation in`. A fallback, not a dictionary — the keys are schema names. */
|
|
5976
6145
|
const prettyKey = (k) => String(k).replace(/_/g, ' ').replace(/^./, (c) => c.toUpperCase());
|
|
@@ -6321,7 +6490,12 @@
|
|
|
6321
6490
|
return g;
|
|
6322
6491
|
}
|
|
6323
6492
|
|
|
6324
|
-
|
|
6493
|
+
/** A stale revision remains useful evidence, but none of its decision controls tell the truth. */
|
|
6494
|
+
function makeRevisionReviewReadOnly(root) {
|
|
6495
|
+
root.querySelectorAll('.rev-check, .rev-group-actions').forEach((control) => control.remove());
|
|
6496
|
+
}
|
|
6497
|
+
|
|
6498
|
+
function renderReview(summary, { readOnly = false } = {}) {
|
|
6325
6499
|
// COUNTS: one quiet line, and never "0 of X" — the zero clause is simply omitted.
|
|
6326
6500
|
// The numbers carry a <b>, so the two figures worth scanning stand out of the muted sentence —
|
|
6327
6501
|
// the rule for it existed and nothing emitted the element.
|
|
@@ -6335,7 +6509,9 @@
|
|
|
6335
6509
|
$revReviewCounts.appendChild(revEl('b', null, n));
|
|
6336
6510
|
$revReviewCounts.appendChild(document.createTextNode(rest));
|
|
6337
6511
|
});
|
|
6338
|
-
$revReviewCounts.appendChild(document.createTextNode(
|
|
6512
|
+
$revReviewCounts.appendChild(document.createTextNode(readOnly
|
|
6513
|
+
? ' — what this read was sure of when it was prepared.'
|
|
6514
|
+
: ' — what the read was sure of, already taken.'));
|
|
6339
6515
|
$revReviewCounts.hidden = false;
|
|
6340
6516
|
} else { $revReviewCounts.hidden = true; }
|
|
6341
6517
|
|
|
@@ -6351,12 +6527,12 @@
|
|
|
6351
6527
|
: 'This read found no changes to make — the revised set matches what is already in the model.'));
|
|
6352
6528
|
}
|
|
6353
6529
|
if (props.length) {
|
|
6354
|
-
const g = group('Needs your decision', props.length, 'proposals');
|
|
6530
|
+
const g = group(readOnly ? 'Changes this read proposed' : 'Needs your decision', props.length, 'proposals');
|
|
6355
6531
|
props.forEach((p, i) => g.appendChild(proposalRow(p, i, 'proposals')));
|
|
6356
6532
|
body.appendChild(g);
|
|
6357
6533
|
}
|
|
6358
6534
|
if (binds.length) {
|
|
6359
|
-
const g = group('Evidence links', binds.length, 'bindingProposals');
|
|
6535
|
+
const g = group(readOnly ? 'Evidence links this read proposed' : 'Evidence links', binds.length, 'bindingProposals');
|
|
6360
6536
|
binds.forEach((b, i) => g.appendChild(bindingRow(b, i)));
|
|
6361
6537
|
body.appendChild(g);
|
|
6362
6538
|
}
|
|
@@ -6379,6 +6555,7 @@
|
|
|
6379
6555
|
}
|
|
6380
6556
|
body.appendChild(det);
|
|
6381
6557
|
}
|
|
6558
|
+
if (readOnly) makeRevisionReviewReadOnly(body);
|
|
6382
6559
|
$revReviewBody.replaceChildren(body);
|
|
6383
6560
|
}
|
|
6384
6561
|
|
|
@@ -6395,16 +6572,22 @@
|
|
|
6395
6572
|
* Safe to call unconditionally, which is what lets `closeProject` use it: it clears a class, nulls
|
|
6396
6573
|
* the state, restores focus, and `renderRevisionCard` returns immediately when no project is open.
|
|
6397
6574
|
*/
|
|
6398
|
-
function closeRevReview() {
|
|
6575
|
+
function closeRevReview(restoreFocus = true) {
|
|
6399
6576
|
const wasOpen = !!revReviewState;
|
|
6577
|
+
if (revDiscardState?.reviewWasOpen) closeRevisionDiscard(false, false);
|
|
6400
6578
|
$revReview.classList.remove('show');
|
|
6401
6579
|
const st = revReviewState;
|
|
6402
6580
|
revReviewState = null;
|
|
6581
|
+
$revReviewTitle.textContent = 'Review this read';
|
|
6403
6582
|
$revReviewChanged.hidden = true;
|
|
6404
6583
|
$revReviewConfirm.disabled = false;
|
|
6584
|
+
$revReviewConfirm.hidden = false;
|
|
6585
|
+
$revReviewDiscard.hidden = true;
|
|
6405
6586
|
const back = st && st.returnFocus;
|
|
6406
|
-
if (
|
|
6407
|
-
|
|
6587
|
+
if (restoreFocus) {
|
|
6588
|
+
if (back instanceof HTMLElement && back.isConnected) back.focus();
|
|
6589
|
+
else { const b = $revisionCard.querySelector('[data-revreview]'); if (b) b.focus(); }
|
|
6590
|
+
}
|
|
6408
6591
|
// Only when something was actually open — otherwise every `closeProject` would fire a stray fetch.
|
|
6409
6592
|
if (wasOpen) renderRevisionCard();
|
|
6410
6593
|
}
|
|
@@ -6413,33 +6596,190 @@
|
|
|
6413
6596
|
if (!current || !req) return;
|
|
6414
6597
|
const projectId = current.id;
|
|
6415
6598
|
const returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
6599
|
+
const trigger = returnFocus?.closest?.('[data-revreview]') || null;
|
|
6600
|
+
const triggerLabel = trigger?.textContent || '';
|
|
6601
|
+
if (trigger) {
|
|
6602
|
+
trigger.disabled = true;
|
|
6603
|
+
trigger.setAttribute('aria-busy', 'true');
|
|
6604
|
+
trigger.textContent = 'Loading review…';
|
|
6605
|
+
}
|
|
6416
6606
|
let body;
|
|
6417
6607
|
try {
|
|
6418
6608
|
body = await api(`/api/projects/${encodeURIComponent(projectId)}/revision-read/staged?requestId=${encodeURIComponent(req.id)}`);
|
|
6419
6609
|
} catch (err) {
|
|
6610
|
+
if (err && err.body && ['revision-base-unavailable', 'stage-unavailable'].includes(err.body.code)
|
|
6611
|
+
&& typeof err.body.stageId === 'string' && err.body.stageId.trim().length > 0) {
|
|
6612
|
+
// The GET reads the pointer that is current at request time; another tab may have replaced the
|
|
6613
|
+
// card's generation already. Retire the exact generation the server rejected, never the stale
|
|
6614
|
+
// card token. Temporary read/recovery errors use a different code and remain retryable.
|
|
6615
|
+
unavailableRevisionReviewStages.add(err.body.stageId);
|
|
6616
|
+
}
|
|
6420
6617
|
showToast('Could not load the review: ' + ((err && err.message) || err), 'warn');
|
|
6421
6618
|
renderRevisionCard();
|
|
6422
6619
|
return;
|
|
6620
|
+
} finally {
|
|
6621
|
+
if (trigger?.isConnected) {
|
|
6622
|
+
trigger.disabled = false;
|
|
6623
|
+
trigger.removeAttribute('aria-busy');
|
|
6624
|
+
trigger.textContent = triggerLabel;
|
|
6625
|
+
}
|
|
6423
6626
|
}
|
|
6424
6627
|
if (!current || current.id !== projectId) return; // switched projects during the fetch
|
|
6425
6628
|
const summary = body && body.staged;
|
|
6426
6629
|
if (!summary) { showToast('That review is no longer available', 'warn'); renderRevisionCard(); return; }
|
|
6630
|
+
// THE GET OWNS THE MODAL STATE. The card is a polled snapshot and the History head can advance
|
|
6631
|
+
// between clicking its Review action and this response arriving. Reusing the card's versions here
|
|
6632
|
+
// briefly exposed Apply for a review the server had already classified read-only. Fail closed on an
|
|
6633
|
+
// incomplete response rather than mixing one generation's rows with another generation's controls.
|
|
6634
|
+
if (typeof body.readOnly !== 'boolean' || !Number.isInteger(body.baseVersion) || !Number.isInteger(body.headVersion)) {
|
|
6635
|
+
showToast('Could not load the review: the server returned an incomplete review state', 'warn');
|
|
6636
|
+
renderRevisionCard();
|
|
6637
|
+
return;
|
|
6638
|
+
}
|
|
6639
|
+
const readOnly = body.readOnly;
|
|
6640
|
+
const reviewRequest = {
|
|
6641
|
+
...req,
|
|
6642
|
+
baseVersion: body.baseVersion,
|
|
6643
|
+
headVersion: body.headVersion,
|
|
6644
|
+
stageId: summary.stageId,
|
|
6645
|
+
};
|
|
6427
6646
|
// RENDER BEFORE ADOPTING THE STATE — the same ordering the 409 path was fixed to use, and this was
|
|
6428
6647
|
// the arm that still had it backwards. `revReviewState` is what makes `renderRevisionCard` skip its
|
|
6429
6648
|
// repaint, so setting it first and then throwing inside `renderReview` left the guard latched with
|
|
6430
6649
|
// no modal on screen: the card would never repaint again for the life of the page.
|
|
6431
|
-
$
|
|
6650
|
+
$revReviewTitle.textContent = readOnly ? 'This read is out of date' : 'Review this read';
|
|
6651
|
+
$revReviewSub.textContent = readOnly
|
|
6652
|
+
? `This read started from v${reviewRequest.baseVersion}, but the project is now at v${reviewRequest.headVersion}. It can’t be applied to the current model. The proposal below is for reference only.`
|
|
6653
|
+
: 'Nothing is applied until you confirm. Everything starts unticked — tick what this read may change.';
|
|
6432
6654
|
$revReviewChanged.hidden = true;
|
|
6433
|
-
renderReview(summary);
|
|
6434
|
-
revReviewState = { projectId, requestId: req.id, stageId: summary.stageId, summary, returnFocus };
|
|
6655
|
+
renderReview(summary, { readOnly });
|
|
6656
|
+
revReviewState = { projectId, requestId: req.id, stageId: summary.stageId, summary, request: reviewRequest, stale: readOnly, returnFocus };
|
|
6657
|
+
$revReviewConfirm.hidden = readOnly;
|
|
6658
|
+
$revReviewDiscard.hidden = !canDiscardRevision(reviewRequest);
|
|
6435
6659
|
$revReview.classList.add('show');
|
|
6436
6660
|
const first = $revReviewBody.querySelector('input[type="checkbox"]');
|
|
6437
6661
|
(first || $revReviewCancel).focus();
|
|
6438
6662
|
}
|
|
6439
6663
|
|
|
6664
|
+
function openRevisionDiscard(req, returnFocus = document.activeElement) {
|
|
6665
|
+
if (!current || !canDiscardRevision(req)) return;
|
|
6666
|
+
const reviewWasOpen = !!revReviewState;
|
|
6667
|
+
// The confirmation is the only active root whether it opens over the review or directly over the
|
|
6668
|
+
// workspace. Preserve exact prior states because another modal can already be layered underneath.
|
|
6669
|
+
const coveredRoots = [document.getElementById('app'), ...document.querySelectorAll('.modal-backdrop.show')]
|
|
6670
|
+
.filter((root) => root && root !== $revDiscard)
|
|
6671
|
+
.map((root) => ({ root, inert: !!root.inert, ariaHidden: root.getAttribute('aria-hidden') }));
|
|
6672
|
+
for (const { root } of coveredRoots) { root.inert = true; root.setAttribute('aria-hidden', 'true'); }
|
|
6673
|
+
revDiscardState = {
|
|
6674
|
+
projectId: current.id,
|
|
6675
|
+
requestId: req.id,
|
|
6676
|
+
stageId: req.stageId,
|
|
6677
|
+
request: req,
|
|
6678
|
+
returnFocus: returnFocus instanceof HTMLElement ? returnFocus : null,
|
|
6679
|
+
reviewWasOpen,
|
|
6680
|
+
terminal: false,
|
|
6681
|
+
coveredRoots,
|
|
6682
|
+
};
|
|
6683
|
+
const stale = isRevisionStale(req);
|
|
6684
|
+
$revDiscardSub.textContent = stale
|
|
6685
|
+
? `This permanently removes the staged review based on v${req.baseVersion}. It does not change the current project at v${req.headVersion} or its History. To read these drawings again, attach the set again.`
|
|
6686
|
+
: 'This permanently removes this staged review. It does not change the model or History. To read these drawings again, attach the set again.';
|
|
6687
|
+
$revDiscardError.hidden = true;
|
|
6688
|
+
$revDiscardError.textContent = '';
|
|
6689
|
+
$revDiscardConfirm.hidden = false;
|
|
6690
|
+
$revDiscardConfirm.disabled = false;
|
|
6691
|
+
$revDiscardConfirm.textContent = 'Discard read';
|
|
6692
|
+
$revDiscardCancel.disabled = false;
|
|
6693
|
+
$revDiscardCancel.textContent = 'Keep review';
|
|
6694
|
+
$revDiscard.classList.add('show');
|
|
6695
|
+
$revDiscardCancel.focus();
|
|
6696
|
+
}
|
|
6697
|
+
|
|
6698
|
+
function closeRevisionDiscard(restoreFocus = true, settleTerminal = true) {
|
|
6699
|
+
const st = revDiscardState;
|
|
6700
|
+
revDiscardState = null;
|
|
6701
|
+
$revDiscard.classList.remove('show');
|
|
6702
|
+
$revDiscardDialog.removeAttribute('aria-busy');
|
|
6703
|
+
$revDiscardError.hidden = true;
|
|
6704
|
+
$revDiscardError.textContent = '';
|
|
6705
|
+
$revDiscardConfirm.hidden = false;
|
|
6706
|
+
$revDiscardConfirm.disabled = false;
|
|
6707
|
+
$revDiscardConfirm.removeAttribute('aria-busy');
|
|
6708
|
+
$revDiscardConfirm.textContent = 'Discard read';
|
|
6709
|
+
$revDiscardCancel.disabled = false;
|
|
6710
|
+
$revDiscardCancel.textContent = 'Keep review';
|
|
6711
|
+
for (const covered of st?.coveredRoots || []) {
|
|
6712
|
+
covered.root.inert = covered.inert;
|
|
6713
|
+
if (covered.ariaHidden === null) covered.root.removeAttribute('aria-hidden');
|
|
6714
|
+
else covered.root.setAttribute('aria-hidden', covered.ariaHidden);
|
|
6715
|
+
}
|
|
6716
|
+
if (settleTerminal && st?.terminal) {
|
|
6717
|
+
if (st.reviewWasOpen && revReviewState) closeRevReview(false);
|
|
6718
|
+
const focusRecovery = () => {
|
|
6719
|
+
if (current && current.id === st.projectId) requestAnimationFrame(() => document.getElementById('ws-attach-revision')?.focus());
|
|
6720
|
+
};
|
|
6721
|
+
// Focus recovery must not wait behind the card's network poll. `/api/requests` deliberately has
|
|
6722
|
+
// no client timeout, so a stalled server would otherwise leave focus parked in hidden modal chrome.
|
|
6723
|
+
focusRecovery();
|
|
6724
|
+
try { Promise.resolve(renderRevisionCard()).catch(() => {}); } catch (_) { /* focus is already safe */ }
|
|
6725
|
+
} else if (restoreFocus && st?.returnFocus instanceof HTMLElement && st.returnFocus.isConnected) st.returnFocus.focus();
|
|
6726
|
+
}
|
|
6727
|
+
|
|
6728
|
+
async function confirmRevisionDiscard() {
|
|
6729
|
+
const st = revDiscardState;
|
|
6730
|
+
if (!st || st.terminal) return;
|
|
6731
|
+
$revDiscardError.hidden = true;
|
|
6732
|
+
$revDiscardDialog.setAttribute('aria-busy', 'true');
|
|
6733
|
+
$revDiscardConfirm.disabled = true;
|
|
6734
|
+
$revDiscardConfirm.setAttribute('aria-busy', 'true');
|
|
6735
|
+
$revDiscardConfirm.textContent = 'Discarding…';
|
|
6736
|
+
$revDiscardCancel.disabled = true;
|
|
6737
|
+
try {
|
|
6738
|
+
await api(`/api/projects/${encodeURIComponent(st.projectId)}/revision-read/discard`, {
|
|
6739
|
+
method: 'POST', body: JSON.stringify({ requestId: st.requestId, stageId: st.stageId }),
|
|
6740
|
+
});
|
|
6741
|
+
} catch (error) {
|
|
6742
|
+
const code = error?.body?.code;
|
|
6743
|
+
const terminal = ['stage-superseded', 'revision-request-retired', 'revision-request-discarded'].includes(code);
|
|
6744
|
+
const conflictMessage = code === 'stage-superseded'
|
|
6745
|
+
? 'A newer review is now available. Close this message and reopen the current review before discarding it.'
|
|
6746
|
+
: code === 'revision-request-retired'
|
|
6747
|
+
? 'This review was applied elsewhere and is no longer available. Close this message to see the current project.'
|
|
6748
|
+
: 'This drawing read has already been discarded. Close this message to attach the set again.';
|
|
6749
|
+
$revDiscardError.textContent = terminal
|
|
6750
|
+
? conflictMessage
|
|
6751
|
+
: `Couldn’t discard this read. ${(error && error.message) || 'Try again.'}`;
|
|
6752
|
+
$revDiscardError.hidden = false;
|
|
6753
|
+
$revDiscardDialog.removeAttribute('aria-busy');
|
|
6754
|
+
$revDiscardCancel.disabled = false;
|
|
6755
|
+
if (terminal) {
|
|
6756
|
+
st.terminal = true;
|
|
6757
|
+
$revDiscardConfirm.hidden = true;
|
|
6758
|
+
$revDiscardCancel.textContent = 'Close';
|
|
6759
|
+
$revDiscardCancel.focus();
|
|
6760
|
+
if (bridge.loadRequests) bridge.loadRequests().catch(() => {});
|
|
6761
|
+
} else {
|
|
6762
|
+
$revDiscardConfirm.disabled = false;
|
|
6763
|
+
$revDiscardConfirm.removeAttribute('aria-busy');
|
|
6764
|
+
$revDiscardConfirm.textContent = 'Discard read';
|
|
6765
|
+
}
|
|
6766
|
+
return;
|
|
6767
|
+
}
|
|
6768
|
+
const reviewWasOpen = st.reviewWasOpen;
|
|
6769
|
+
lastRevState = 'none';
|
|
6770
|
+
closeRevisionDiscard(false, false);
|
|
6771
|
+
if (reviewWasOpen && revReviewState) closeRevReview();
|
|
6772
|
+
else await renderRevisionCard();
|
|
6773
|
+
if (bridge.loadRequests) bridge.loadRequests().catch(() => {});
|
|
6774
|
+
showToast('Drawing read discarded — you can attach a revised set again', 'ok');
|
|
6775
|
+
if (current && current.id === st.projectId) {
|
|
6776
|
+
requestAnimationFrame(() => document.getElementById('ws-attach-revision')?.focus());
|
|
6777
|
+
}
|
|
6778
|
+
}
|
|
6779
|
+
|
|
6440
6780
|
async function confirmRevisionReview() {
|
|
6441
6781
|
const st = revReviewState;
|
|
6442
|
-
if (!st) return;
|
|
6782
|
+
if (!st || st.stale) return;
|
|
6443
6783
|
const accept = { proposals: [], bindingProposals: [] };
|
|
6444
6784
|
for (const box of $revReviewBody.querySelectorAll('input[type="checkbox"]:checked')) {
|
|
6445
6785
|
const bucket = box.dataset.revbucket;
|
|
@@ -6520,12 +6860,36 @@
|
|
|
6520
6860
|
const on = bulk.dataset.revbulkon === '1';
|
|
6521
6861
|
for (const box of $revReviewBody.querySelectorAll(`input[data-revbucket="${bulk.dataset.revbulk}"]`)) box.checked = on;
|
|
6522
6862
|
});
|
|
6863
|
+
$revReviewDiscard.addEventListener('click', (e) => {
|
|
6864
|
+
const st = revReviewState;
|
|
6865
|
+
if (st) openRevisionDiscard({ ...st.request, stageId: st.stageId }, e.currentTarget);
|
|
6866
|
+
});
|
|
6523
6867
|
$revReviewConfirm.addEventListener('click', confirmRevisionReview);
|
|
6524
6868
|
$revReviewCancel.addEventListener('click', closeRevReview);
|
|
6525
6869
|
onBackdropDismiss($revReview, closeRevReview, () => !$revReviewConfirm.disabled);
|
|
6526
6870
|
$revReview.addEventListener('keydown', (e) => {
|
|
6527
6871
|
if (e.key === 'Escape') { e.preventDefault(); if (!$revReviewConfirm.disabled) closeRevReview(); }
|
|
6528
6872
|
});
|
|
6873
|
+
$revDiscardCancel.addEventListener('click', () => closeRevisionDiscard());
|
|
6874
|
+
$revDiscardConfirm.addEventListener('click', confirmRevisionDiscard);
|
|
6875
|
+
onBackdropDismiss($revDiscard, () => closeRevisionDiscard(), () => !$revDiscardDialog.hasAttribute('aria-busy'));
|
|
6876
|
+
document.addEventListener('keydown', (e) => {
|
|
6877
|
+
if (!$revDiscard.classList.contains('show')) return;
|
|
6878
|
+
if (e.key === 'Escape') {
|
|
6879
|
+
e.preventDefault(); e.stopPropagation();
|
|
6880
|
+
if (!$revDiscardDialog.hasAttribute('aria-busy')) closeRevisionDiscard();
|
|
6881
|
+
} else if (e.key === 'Tab') {
|
|
6882
|
+
const focusable = [...$revDiscard.querySelectorAll('button:not([disabled]):not([hidden]), [tabindex]:not([tabindex="-1"])')]
|
|
6883
|
+
.filter((el) => el instanceof HTMLElement && !el.hidden && el.getClientRects().length);
|
|
6884
|
+
if (!focusable.length) { e.preventDefault(); return; }
|
|
6885
|
+
const first = focusable[0], last = focusable[focusable.length - 1];
|
|
6886
|
+
if (e.shiftKey && (document.activeElement === first || !$revDiscard.contains(document.activeElement))) {
|
|
6887
|
+
e.preventDefault(); last.focus();
|
|
6888
|
+
} else if (!e.shiftKey && (document.activeElement === last || !$revDiscard.contains(document.activeElement))) {
|
|
6889
|
+
e.preventDefault(); first.focus();
|
|
6890
|
+
}
|
|
6891
|
+
}
|
|
6892
|
+
}, true);
|
|
6529
6893
|
|
|
6530
6894
|
// ── History step ────────────────────────────────────────────────────────────────
|
|
6531
6895
|
// The project's version ledger. A version = a commit (Approve = Model gate, Rollback = unsigned).
|
|
@@ -6589,6 +6953,27 @@
|
|
|
6589
6953
|
};
|
|
6590
6954
|
}
|
|
6591
6955
|
|
|
6956
|
+
function detailReconciliationWarningHtml(v) {
|
|
6957
|
+
if (!v || v.kind !== 'revision-read') return '';
|
|
6958
|
+
const audit = v.source && v.source.readAudit;
|
|
6959
|
+
const report = audit && audit.report;
|
|
6960
|
+
if (!audit || audit.version !== 1 || !report || report.version !== 1
|
|
6961
|
+
|| report.policy !== 'steel-read-completion/v1' || !Array.isArray(report.checks)
|
|
6962
|
+
|| !report.counts || report.counts.joints !== 0) return '';
|
|
6963
|
+
const matchingChecks = report.checks.filter((row) => row && typeof row === 'object'
|
|
6964
|
+
&& row.id === 'detail-reconciliation');
|
|
6965
|
+
if (matchingChecks.length !== 1) return '';
|
|
6966
|
+
const check = matchingChecks[0];
|
|
6967
|
+
if ((check.status !== 'pass' && check.status !== 'warning') || typeof check.detail !== 'string') return '';
|
|
6968
|
+
const match = /^([1-9]\d*) detail\/connection marker\(s\) reconciled$/.exec(check.detail);
|
|
6969
|
+
if (!match) return '';
|
|
6970
|
+
const markers = Number(match[1]);
|
|
6971
|
+
if (!Number.isSafeInteger(markers)) return '';
|
|
6972
|
+
return '<div class="hist-change-caution" role="note"><span aria-hidden="true">⚠</span> ' +
|
|
6973
|
+
'<strong>Connection details need follow-up.</strong> The read accounted for ' + markers +
|
|
6974
|
+
' detail/connection markers, but modeled 0 joints in this version.</div>';
|
|
6975
|
+
}
|
|
6976
|
+
|
|
6592
6977
|
function changeCellHtml(v, meta) {
|
|
6593
6978
|
const s = v.changeSummary;
|
|
6594
6979
|
const n = Number(v.n);
|
|
@@ -6599,8 +6984,9 @@
|
|
|
6599
6984
|
'data-tip="Show the complete member-by-member comparison">' +
|
|
6600
6985
|
'<span class="hd-caret">▸</span><span class="hd-toggle-label">View detailed changes</span></button>'
|
|
6601
6986
|
: '';
|
|
6987
|
+
const detailWarning = detailReconciliationWarningHtml(v);
|
|
6602
6988
|
if (!s || !Array.isArray(s.bullets)) {
|
|
6603
|
-
return `<div class="hist-event">${escapeHtml(v.message)}</div>${toggle}`;
|
|
6989
|
+
return `<div class="hist-event">${escapeHtml(v.message)}</div>${detailWarning}${toggle}`;
|
|
6604
6990
|
}
|
|
6605
6991
|
const visible = meta.canDiff ? s.bullets.slice(0, 4) : s.bullets;
|
|
6606
6992
|
const more = s.bullets.length - visible.length;
|
|
@@ -6610,7 +6996,7 @@
|
|
|
6610
6996
|
? `<div class="hist-change-caution">⚠ ${escapeHtml(s.cautions.join(' '))}</div>`
|
|
6611
6997
|
: '';
|
|
6612
6998
|
return `<div class="hist-change-head">${escapeHtml(String(s.headline || v.message))}</div>` +
|
|
6613
|
-
`<ul class="hist-change-list">${bullets}</ul>${cautions}${toggle}`;
|
|
6999
|
+
`<ul class="hist-change-list">${bullets}</ul>${cautions}${detailWarning}${toggle}`;
|
|
6614
7000
|
}
|
|
6615
7001
|
|
|
6616
7002
|
function versionRowHtml(v) {
|