@floless/app 0.127.5 → 0.128.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +10189 -13091
- package/dist/schemas/drawing.vector.v1.schema.json +1 -1
- package/dist/schemas/steel.model.v2.schema.json +50 -127
- package/dist/skills/floless-app-steel-model/SKILL.md +5 -6
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +172 -1704
- package/dist/skills/floless-app-tweak-contract/SKILL.md +64 -174
- package/dist/skills/reading-structural-drawings/SKILL.md +2 -2
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +2 -2
- package/dist/templates/steel-model.flo +45 -24
- package/dist/web/app.css +18 -92
- package/dist/web/aware.js +7 -1
- package/dist/web/grid-core.js +47 -0
- package/dist/web/index.html +0 -27
- package/dist/web/renderers.js +3 -14
- package/dist/web/steel-3d-view.js +87 -35
- package/dist/web/steel-editor.html +82 -58
- package/dist/web/steel-filter-core.js +7 -26
- package/dist/web/steel-filter.html +7 -7
- package/dist/web/steel-model-adapter.js +19 -250
- package/dist/web/steel-model-v2-commands.js +1 -0
- package/dist/web/workspaces.js +46 -838
- package/package.json +1 -1
- package/dist/schemas/steel.takeoff.v1.schema.json +0 -562
- package/dist/schemas/steel.takeoff.v1.staging-snapshot.json +0 -263
package/dist/web/workspaces.js
CHANGED
|
@@ -433,10 +433,11 @@
|
|
|
433
433
|
* `openProject` assigns it and sits earlier in the file — a `let` further down works only as long as
|
|
434
434
|
* nothing calls that function during module init, which is not a property worth depending on.
|
|
435
435
|
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
436
|
+
* Unknown fails closed. Approval and export capability must come from the lifecycle response, never
|
|
437
|
+
* from a successful presence request or stale state carried from another project.
|
|
438
438
|
*/
|
|
439
|
-
let
|
|
439
|
+
let projectContractLifecycle = 'unknown';
|
|
440
|
+
let exportsHasModel = false;
|
|
440
441
|
|
|
441
442
|
/** Sequence number for model-presence probes. A project-id check is NOT a staleness guard: two
|
|
442
443
|
* probes can be in flight for the SAME project, and an older "absent" answer landing last would
|
|
@@ -455,7 +456,11 @@
|
|
|
455
456
|
let label = 'Review & approve';
|
|
456
457
|
let tip = APPROVE_TIP;
|
|
457
458
|
let unavailable = false;
|
|
458
|
-
if (
|
|
459
|
+
if (projectContractLifecycle === 'filter-checkpoint') {
|
|
460
|
+
label = 'Read members first';
|
|
461
|
+
tip = 'The Drawing Filter is saved. Read the selected drawing content before approval.';
|
|
462
|
+
unavailable = true;
|
|
463
|
+
} else if (!exportsHasModel) {
|
|
459
464
|
label = 'Review unavailable';
|
|
460
465
|
tip = `Nothing to approve yet — read a drawing on ${stepLabel('drawings')} first`;
|
|
461
466
|
unavailable = true;
|
|
@@ -1616,7 +1621,6 @@
|
|
|
1616
1621
|
// otherwise leave it on screen bound to `migState.projectId` — the project just navigated away
|
|
1617
1622
|
// from. Narrow (the backdrop covers the combo, so only an untrapped Tab reaches it) and the symmetry
|
|
1618
1623
|
// is the point: `closeRevReview` on the line above exists for exactly this.
|
|
1619
|
-
migReady = null; closeMigrate();
|
|
1620
1624
|
// Per-project, like everything above it: never let one project's answer describe another's. Not
|
|
1621
1625
|
// observable today (every history render is preceded by a fetch that sets it, and a failed fetch
|
|
1622
1626
|
// renders no rows), but leaving a stale cross-project value in place is the shape of bug this
|
|
@@ -1641,7 +1645,7 @@
|
|
|
1641
1645
|
setStep(initialStep);
|
|
1642
1646
|
applyMode();
|
|
1643
1647
|
syncWorkspaceGuide(); // point the shared beacon at THIS project's document lifecycle
|
|
1644
|
-
// Detached, but never silent:
|
|
1648
|
+
// Detached, but never silent: the lifecycle probe cannot reject, yet the code after its await can
|
|
1645
1649
|
// (stepLabel -> wsApp on a descriptor without steps), and an unhandled rejection would leave the
|
|
1646
1650
|
// header un-updated with nothing said.
|
|
1647
1651
|
refreshModelPresence(p.id, p.app).catch((e) => { // gate the header CHECK Approve for THIS project (#490)
|
|
@@ -1663,14 +1667,15 @@
|
|
|
1663
1667
|
*/
|
|
1664
1668
|
async function refreshModelPresence(projectId, appId) {
|
|
1665
1669
|
const gen = ++modelPresenceGen;
|
|
1666
|
-
const present = await
|
|
1670
|
+
const present = await projectContractState(projectId, appId);
|
|
1667
1671
|
if (gen !== modelPresenceGen || !current || current.id !== projectId) return; // superseded
|
|
1668
1672
|
applyModelPresence(present);
|
|
1669
1673
|
}
|
|
1670
1674
|
|
|
1671
1675
|
/** Push the answer to the flag AND the header together, so no two surfaces can disagree. */
|
|
1672
1676
|
function applyModelPresence(present) {
|
|
1673
|
-
|
|
1677
|
+
projectContractLifecycle = present;
|
|
1678
|
+
exportsHasModel = present === 'model';
|
|
1674
1679
|
renderApprovalHeader();
|
|
1675
1680
|
}
|
|
1676
1681
|
function closeProject() {
|
|
@@ -1690,17 +1695,14 @@
|
|
|
1690
1695
|
// have applied a review to a project that was no longer on screen. The card is hidden two lines
|
|
1691
1696
|
// down for the same reason; the modal was simply missed.
|
|
1692
1697
|
closeRevReview();
|
|
1693
|
-
// AND SO IS THE CONVERSION OFFER, for the same reason plus one of its own. `migReady` is derived
|
|
1694
1698
|
// from the OPEN project's contract and is what gates the `⋯` menu item — left set, the landing
|
|
1695
1699
|
// kebab for the project just closed would still offer "Convert to the 3D model…", and clicking it
|
|
1696
1700
|
// would do nothing at all, because `openMigrate` bails on a null `current`. A menu item that is
|
|
1697
1701
|
// visible and inert is worse than one that is absent. (Found by the code review; the modal below
|
|
1698
1702
|
// was already per-project, the two variables behind it were not.)
|
|
1699
|
-
migReady = null;
|
|
1700
|
-
closeMigrate();
|
|
1701
1703
|
// Reset with the rest of the per-project state — this file resets `histDiffSupported` for exactly
|
|
1702
1704
|
// this reason. Bumping the generation also voids any probe still in flight for the closing project.
|
|
1703
|
-
exportsHasModel =
|
|
1705
|
+
projectContractLifecycle = 'unknown'; exportsHasModel = false; modelPresenceGen++;
|
|
1704
1706
|
closeProjMenu(); applyMode(); syncWorkspaceGuide(); // revision state cleared by resetRevisionState() above
|
|
1705
1707
|
}
|
|
1706
1708
|
document.getElementById('ws-back').addEventListener('click', closeProject);
|
|
@@ -1741,7 +1743,6 @@
|
|
|
1741
1743
|
// The conversion offer is Model-step scoped, and re-derived on every entry rather than cached:
|
|
1742
1744
|
// the project's contract can change under this shell (a revision read, another tab, the editor's
|
|
1743
1745
|
// own save), and a banner offering to convert a project that is already v2 is worse than none.
|
|
1744
|
-
refreshMigrateGate();
|
|
1745
1746
|
// Exports is a shell-rendered pane (not an iframe): show/hide + (re)paint on open.
|
|
1746
1747
|
const showExports = s === 'exports';
|
|
1747
1748
|
$wsExports.hidden = !showExports;
|
|
@@ -1768,8 +1769,8 @@
|
|
|
1768
1769
|
// ── Approve (per-project) ───────────────────────────────────────────────────
|
|
1769
1770
|
// One sign-off flow behind FOUR controls, all of which call approveProject(): the header
|
|
1770
1771
|
// #ws-approve ("Review & approve"), the Exports pending-changes banner ([data-review-changes]),
|
|
1771
|
-
// the Exports gate link #ws-exports-approve ("Approve this version")
|
|
1772
|
-
//
|
|
1772
|
+
// and the Exports gate link #ws-exports-approve ("Approve this version"). History stays a ledger,
|
|
1773
|
+
// so approval is deliberately not duplicated there.
|
|
1773
1774
|
//
|
|
1774
1775
|
// What unlocks the Exports gate without a reload is the confirm's refreshApprovalState() +
|
|
1775
1776
|
// renderExports(), which re-read the server's approval state and export sources — NOT the
|
|
@@ -4533,7 +4534,7 @@
|
|
|
4533
4534
|
// Cards are enabled by an explicit source, not by the mutable working-copy sign-off flag. Latest
|
|
4534
4535
|
// approved is selected by default when present; a no-baseline project stays closed until the
|
|
4535
4536
|
// person deliberately chooses its DRAFT working copy/checkpoint.
|
|
4536
|
-
const approved = exportSourcesState.status === 'ready' && !!currentExportSourceOption();
|
|
4537
|
+
const approved = projectContractLifecycle === 'model' && exportSourcesState.status === 'ready' && !!currentExportSourceOption();
|
|
4537
4538
|
let html = exportSourceHtml();
|
|
4538
4539
|
if (!approved) {
|
|
4539
4540
|
// Same split as History's empty state (#490): with a model, Approve is genuinely the unlocking
|
|
@@ -4541,6 +4542,8 @@
|
|
|
4541
4542
|
// step is to go read a drawing. `stepLabel('drawings')` because that label is per-app.
|
|
4542
4543
|
html += exportSourcesState.data?.defaultUnavailable?.reason === 'refused'
|
|
4543
4544
|
? `<div class="ws-exports-gate refused" role="alert">Exports are paused because the approved snapshot failed its integrity check. <button type="button" data-review-changes>Review approval</button></div>`
|
|
4545
|
+
: projectContractLifecycle === 'filter-checkpoint'
|
|
4546
|
+
? '<div class="ws-exports-gate">Drawing Filter saved — read the selected drawing content to build the model before exporting.</div>'
|
|
4544
4547
|
: hasModel
|
|
4545
4548
|
? `<div class="ws-exports-gate">Exports go out after sign-off — ` +
|
|
4546
4549
|
`<button type="button" id="ws-exports-approve">Approve this version</button> to enable them.</div>`
|
|
@@ -4633,43 +4636,29 @@
|
|
|
4633
4636
|
* Send leaves you on Send.
|
|
4634
4637
|
*/
|
|
4635
4638
|
/**
|
|
4636
|
-
*
|
|
4637
|
-
*
|
|
4638
|
-
* NOT the same question as "does it have versions", and conflating them is the bug. History's empty
|
|
4639
|
-
* state fires whenever the ledger is empty, which covers TWO situations: a real model waiting for its
|
|
4640
|
-
* first sign-off, and a project nothing has ever been read into. Only the second must not offer
|
|
4641
|
-
* Approve — `POST …/approve` 404s there, and the primary call-to-action on the screen becomes the one
|
|
4642
|
-
* control that lies while every export button around it is correctly gated.
|
|
4639
|
+
* Ask the server which project lifecycle the workspace should render (#490, #709).
|
|
4643
4640
|
*
|
|
4644
|
-
*
|
|
4645
|
-
*
|
|
4646
|
-
*
|
|
4647
|
-
* guessing separately is the same failure with an extra way to disagree.
|
|
4648
|
-
*
|
|
4649
|
-
* `quietMissing=1` answers 204 for both kinds of absence and never emits an ETag, so this costs one
|
|
4650
|
-
* cheap request and cannot be confused with a real document.
|
|
4641
|
+
* Presence alone cannot distinguish an initial Drawing Filter checkpoint from a model that is ready
|
|
4642
|
+
* for approval and export. The server therefore returns one authoritative value — `absent`,
|
|
4643
|
+
* `filter-checkpoint`, or `model` — and both History and Exports consume that same answer.
|
|
4651
4644
|
*/
|
|
4652
|
-
async function
|
|
4645
|
+
async function projectContractState(projectId, appId) {
|
|
4653
4646
|
try {
|
|
4654
|
-
const url = `/api/
|
|
4647
|
+
const url = `/api/projects/${encodeURIComponent(projectId)}/contract-lifecycle?app=${encodeURIComponent(appId)}`;
|
|
4655
4648
|
// TIMEOUT, because a HANG is not an error and would never reach the catch below. Both callers
|
|
4656
4649
|
// await this before painting, so without a deadline a wedged connection leaves History reading
|
|
4657
4650
|
// "Loading history…" and every Exports destination row on "Checking…" indefinitely, with no
|
|
4658
|
-
// error and no retry.
|
|
4659
|
-
|
|
4660
|
-
//
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
// gone, and reading that as absence would disable Approve on a real project.
|
|
4666
|
-
return res.status !== 204;
|
|
4651
|
+
// error and no retry. This GET returns only the small lifecycle envelope, never the contract.
|
|
4652
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(4000) });
|
|
4653
|
+
// Unknown responses fail closed: approval/export capability is granted only by an explicit
|
|
4654
|
+
// `model` lifecycle, never by a successful request with an unexpected body.
|
|
4655
|
+
if (!res.ok) return 'unknown';
|
|
4656
|
+
const body = await res.json();
|
|
4657
|
+
return ['absent', 'filter-checkpoint', 'model'].includes(body && body.lifecycle) ? body.lifecycle : 'unknown';
|
|
4667
4658
|
} catch {
|
|
4668
|
-
//
|
|
4669
|
-
//
|
|
4670
|
-
|
|
4671
|
-
// offered, and if there is genuinely nothing it answers 404 exactly as it does today.
|
|
4672
|
-
return true;
|
|
4659
|
+
// A timeout, network failure, or malformed JSON also fails closed until an authoritative answer
|
|
4660
|
+
// can be obtained. `unknown` has its own unavailable UI and is not treated as `absent`.
|
|
4661
|
+
return 'unknown';
|
|
4673
4662
|
}
|
|
4674
4663
|
}
|
|
4675
4664
|
|
|
@@ -4692,10 +4681,10 @@
|
|
|
4692
4681
|
exportSourcesState.status = 'loading';
|
|
4693
4682
|
paintExports(current.approvedAt, restoreKind);
|
|
4694
4683
|
const gen = ++modelPresenceGen;
|
|
4695
|
-
const modelPresent = await
|
|
4684
|
+
const modelPresent = await projectContractState(id, app);
|
|
4696
4685
|
if (gen !== modelPresenceGen || !current || current.id !== id || $wsExports.hidden) return;
|
|
4697
4686
|
applyModelPresence(modelPresent);
|
|
4698
|
-
if (
|
|
4687
|
+
if (exportsHasModel !== paintedWith) paintExports(current.approvedAt, restoreKind);
|
|
4699
4688
|
let state = null;
|
|
4700
4689
|
let approvedAt = current.approvedAt; // fallback if the fetch fails (best-known)
|
|
4701
4690
|
const exportPromise = api(`/api/contract/${encodeURIComponent(app)}/exports?project=${encodeURIComponent(id)}`);
|
|
@@ -6119,783 +6108,6 @@
|
|
|
6119
6108
|
if (e.key === 'Escape') { e.preventDefault(); if (!$revReviewConfirm.disabled) closeRevReview(); }
|
|
6120
6109
|
});
|
|
6121
6110
|
|
|
6122
|
-
// ── Convert to the model (steel.takeoff/v1 → steel.model/v2, unit 5, P7e) ───────
|
|
6123
|
-
//
|
|
6124
|
-
// Preview what the conversion will do, confirm the judgement calls it had to make, commit. Before
|
|
6125
|
-
// this the only way to migrate a project was to call the API by hand.
|
|
6126
|
-
//
|
|
6127
|
-
// THE CONFIRM IS A SERVER PRECONDITION, not a screen convention. `/migrate` refuses a commit whose
|
|
6128
|
-
// body does not carry `acknowledgeDecisions` — the preview's `report.decisionsDigest` — so this modal
|
|
6129
|
-
// is where a human meets the list, but it is not the only thing standing between an unconfirmed
|
|
6130
|
-
// decision and a written document. See `decisionsDigest` in server/steel-model-migrate.ts for what
|
|
6131
|
-
// that precondition does and, just as importantly, does not prove.
|
|
6132
|
-
|
|
6133
|
-
const $migGate = document.getElementById('ws-migrate-gate');
|
|
6134
|
-
const $migModal = document.getElementById('migrate-modal');
|
|
6135
|
-
const $migSub = document.getElementById('migrate-sub');
|
|
6136
|
-
const $migChanged = document.getElementById('migrate-changed');
|
|
6137
|
-
const $migCounts = document.getElementById('migrate-counts');
|
|
6138
|
-
const $migBody = document.getElementById('migrate-body');
|
|
6139
|
-
const $migProgress = document.getElementById('migrate-progress');
|
|
6140
|
-
const $migConfirm = document.getElementById('migrate-confirm');
|
|
6141
|
-
const $migCancel = document.getElementById('migrate-cancel');
|
|
6142
|
-
|
|
6143
|
-
/**
|
|
6144
|
-
* Which cluster a decision belongs to, for grouping inside the modal.
|
|
6145
|
-
*
|
|
6146
|
-
* DEFAULT-DENY, exactly like `BULKABLE_DECISIONS` below and like the revision registry this app
|
|
6147
|
-
* already runs on: an unmapped code lands in "Other" rather than being folded into the
|
|
6148
|
-
* nearest-sounding topic. A wrong guess at grouping is worse than a visibly ungrouped item, because
|
|
6149
|
-
* a decision filed under the wrong heading is one the reader skims past believing they understood
|
|
6150
|
-
* it. `migrate-decisions.test.ts` asserts every emitted code resolves, so a new one upstream shows
|
|
6151
|
-
* up as a failing test rather than silently landing in the wrong cluster.
|
|
6152
|
-
*/
|
|
6153
|
-
const MIGRATE_TOPIC = {
|
|
6154
|
-
'grid-authority-unconfirmed': 'Grid and registration',
|
|
6155
|
-
'grid-field-conflict': 'Grid and registration',
|
|
6156
|
-
'grid-hidden-level-unioned': 'Grid and registration',
|
|
6157
|
-
'grid-label-duplicate': 'Grid and registration',
|
|
6158
|
-
'grid-ends-propagated': 'Grid and registration',
|
|
6159
|
-
'datum-ref-ambiguous': 'Grid and registration',
|
|
6160
|
-
'datum-ref-unresolved': 'Grid and registration',
|
|
6161
|
-
'datum-ref-malformed': 'Grid and registration',
|
|
6162
|
-
'control-ref-malformed': 'Sheet controls',
|
|
6163
|
-
'control-origin-unanchored': 'Sheet controls',
|
|
6164
|
-
'control-ref-unresolved': 'Sheet controls',
|
|
6165
|
-
'control-incomplete': 'Sheet controls',
|
|
6166
|
-
'control-dropped': 'Sheet controls',
|
|
6167
|
-
'elevation-default-missing': 'Elevations',
|
|
6168
|
-
'elevation-in-inferred': 'Elevations',
|
|
6169
|
-
'column-zero-height': 'Elevations',
|
|
6170
|
-
// Its own cluster rather than "Elevations", where its sibling sits: this one is about where the
|
|
6171
|
-
// member stands in PLAN, and filing a plan finding under an elevation heading is the skim-past
|
|
6172
|
-
// failure the default-deny note above exists to prevent.
|
|
6173
|
-
'column-plan-offset': 'Member geometry',
|
|
6174
|
-
'dedup-merge-proposed': 'Duplicate members',
|
|
6175
|
-
'marker-unbound': 'Duplicate members',
|
|
6176
|
-
'marker-merge-dependent': 'Duplicate members',
|
|
6177
|
-
'col-metadata-unassigned': 'Member notes',
|
|
6178
|
-
'drawing-hash-substituted': 'Where the evidence came from',
|
|
6179
|
-
'observation-locator-provisional': 'Where the evidence came from',
|
|
6180
|
-
'legacy-provenance-assumed': 'Where the evidence came from',
|
|
6181
|
-
'field-unmapped': 'Things that will not carry across',
|
|
6182
|
-
'enum-value-unsupported': 'Things that will not carry across',
|
|
6183
|
-
'scratch-history-discarded': 'Things that will not carry across',
|
|
6184
|
-
'grid-ends-materialized': 'Things that will not carry across',
|
|
6185
|
-
'view-camera-unframed': 'Saved views',
|
|
6186
|
-
'view-generated-unresolved': 'Saved views',
|
|
6187
|
-
'view-generated-regenerated': 'Saved views',
|
|
6188
|
-
};
|
|
6189
|
-
const migTopic = (code) => (Object.hasOwn(MIGRATE_TOPIC, code) ? MIGRATE_TOPIC[code] : 'Other');
|
|
6190
|
-
|
|
6191
|
-
/**
|
|
6192
|
-
* The decisions a bulk "Accept all" may cover — and NOTHING ELSE MAY.
|
|
6193
|
-
*
|
|
6194
|
-
* Two kinds of thing wear the same `decision` severity. An ACKNOWLEDGEMENT records a consequence the
|
|
6195
|
-
* user could not have avoided (undo history cannot cross the format change; a legacy document states
|
|
6196
|
-
* no provenance so one is assumed). A CHOICE names something that could have gone differently (which
|
|
6197
|
-
* sheet's grid became the model's; whether a column's note belongs to an end or the member). Epic §8
|
|
6198
|
-
* allows a bulk accept only over a "frozen, fully enumerated, zero-conflict set" and says any
|
|
6199
|
-
* unresolved field conflict means "the user chooses before commit" — so a control that ticks past a
|
|
6200
|
-
* choice is the thing that rule exists to forbid.
|
|
6201
|
-
*
|
|
6202
|
-
* THE TEST IS SCOPE: is this ONE global statement about the document as a whole, or a finding about a
|
|
6203
|
-
* particular modelled thing? A document-wide statement carries no `sheet` and no `path`, and accepting
|
|
6204
|
-
* the second one is the same act as accepting the first — there is nothing to compare, so a single
|
|
6205
|
-
* confirmation over the enumerated set says exactly what N confirmations would. Anything naming a
|
|
6206
|
-
* sheet, a member, a level or a view is a per-item judgement and stays a choice, because there
|
|
6207
|
-
* accepting one tells you nothing about the next.
|
|
6208
|
-
*
|
|
6209
|
-
* NOT "could an edit to the v1 remove it", which an earlier version of this comment claimed and review
|
|
6210
|
-
* immediately disproved: every code below can be removed by editing the source (add a `source.sha256`,
|
|
6211
|
-
* add a `source.elementId`, set a recognised `source.kind`, clear undo/redo, drop the unmapped field).
|
|
6212
|
-
* By that rule the list would have to be empty — the rule was simply wrong, not the set. Worth writing
|
|
6213
|
-
* down because it was the SECOND overclaim in this spot: the first was "records an unavoidable
|
|
6214
|
-
* consequence", which let `elevation-in-inferred`, `enum-value-unsupported`,
|
|
6215
|
-
* `view-generated-regenerated`, `grid-hidden-level-unioned` and `control-dropped` onto the list. Those
|
|
6216
|
-
* five each name a specific sheet or view, so bulk-ticking them accepted a per-item judgement in one
|
|
6217
|
-
* click — the epic §8 violation this list exists to prevent, one level in from the merge case that
|
|
6218
|
-
* prompted it. They are pinned in `mustNeverBulk` now.
|
|
6219
|
-
*
|
|
6220
|
-
* DEFAULT-DENY. A code not on this list is a choice and gets no bulk control, which means a decision
|
|
6221
|
-
* added by a later unit is per-item until someone deliberately promotes it — the safe direction to
|
|
6222
|
-
* fail. It also disposes of `marker-merge-dependent`, whose grouping should follow the merge it
|
|
6223
|
-
* depends on: the report carries no structured link to that merge, so rather than invent one, an
|
|
6224
|
-
* unlinkable dependent stays a choice, which is where it belongs anyway.
|
|
6225
|
-
*
|
|
6226
|
-
* `dedup-merge-proposed` is absent DELIBERATELY, including for proposals whose `conflicts` are empty.
|
|
6227
|
-
* Deciding bulk-eligibility per instance would be a second axis of logic, and getting it wrong once
|
|
6228
|
-
* reproduces exactly the defect the pre-code review caught here: `dedup-multi-match` being a `block`
|
|
6229
|
-
* rules out ambiguous and transitive candidates, but a pairwise-compatible clique can still disagree
|
|
6230
|
-
* on winner fields and remain tickable.
|
|
6231
|
-
*/
|
|
6232
|
-
const BULKABLE_DECISIONS = new Set([
|
|
6233
|
-
'drawing-hash-substituted', 'observation-locator-provisional', 'legacy-provenance-assumed',
|
|
6234
|
-
'scratch-history-discarded', 'field-unmapped',
|
|
6235
|
-
]);
|
|
6236
|
-
const migBulkable = (code) => BULKABLE_DECISIONS.has(code);
|
|
6237
|
-
|
|
6238
|
-
// What the gate banner and the `⋯` item know: the open project is v1 and these are its preconditions.
|
|
6239
|
-
// Null whenever the open project is not convertible, which is what keeps both affordances off.
|
|
6240
|
-
let migReady = null;
|
|
6241
|
-
// The open review: { projectId, etag, head, digest, decisions }.
|
|
6242
|
-
let migState = null;
|
|
6243
|
-
|
|
6244
|
-
/**
|
|
6245
|
-
* Re-read the open project's contract to decide whether the conversion is offered.
|
|
6246
|
-
*
|
|
6247
|
-
* A RAW `fetch`, not `api()` — the confirm needs the `ETag` header and neither `bridge.api` nor the
|
|
6248
|
-
* local fallback exposes headers (see the top of this file). Same idiom the steel editor uses.
|
|
6249
|
-
*/
|
|
6250
|
-
async function refreshMigrateGate() {
|
|
6251
|
-
migReady = null;
|
|
6252
|
-
if ($migGate) { $migGate.replaceChildren(); $migGate.hidden = true; }
|
|
6253
|
-
if (!current || currentStep !== 'model') return;
|
|
6254
|
-
const projectId = current.id;
|
|
6255
|
-
const appId = current.app;
|
|
6256
|
-
try {
|
|
6257
|
-
const url = `/api/contract/${encodeURIComponent(appId)}?project=${encodeURIComponent(projectId)}&quietMissing=1`;
|
|
6258
|
-
const res = await fetch(url, { headers: { 'content-type': 'application/json' } });
|
|
6259
|
-
if (!res.ok) return;
|
|
6260
|
-
const etag = res.headers.get('ETag');
|
|
6261
|
-
const doc = await res.json().catch(() => null);
|
|
6262
|
-
// The baked-.flo fallback legitimately serves no ETag, and a conversion cannot be confirmed
|
|
6263
|
-
// against a document we cannot pin — so no tag means no offer, rather than an offer that 428s.
|
|
6264
|
-
if (!etag || !doc || doc.type !== 'steel.takeoff/v1') return;
|
|
6265
|
-
const vr = await api(`/api/projects/${encodeURIComponent(projectId)}/versions`).catch(() => null);
|
|
6266
|
-
// `versions[0].n`, NOT `versions.length`. The ledger is newest-first and `n` is CLAIMED rather
|
|
6267
|
-
// than counted, so the two differ the moment a project's history has a gap — and a count would
|
|
6268
|
-
// then 428 forever with a message about a version history the user cannot see anything wrong in.
|
|
6269
|
-
const head = (Array.isArray(vr && vr.versions) ? vr.versions : [])[0]?.n ?? 0;
|
|
6270
|
-
if (!current || current.id !== projectId || currentStep !== 'model') return; // moved during the fetch
|
|
6271
|
-
migReady = { projectId, appId, etag, head };
|
|
6272
|
-
renderMigrateGate();
|
|
6273
|
-
} catch { /* an offer that cannot be made is simply not made */ }
|
|
6274
|
-
}
|
|
6275
|
-
|
|
6276
|
-
function renderMigrateGate() {
|
|
6277
|
-
if (!$migGate) return;
|
|
6278
|
-
// EMPTIED as well as hidden. `hidden` alone leaves the old text in the DOM, so any future path that
|
|
6279
|
-
// shows this element again — or any CSS regression like the one that made `[hidden]` inert here —
|
|
6280
|
-
// shows a stale offer for a project that may already be converted.
|
|
6281
|
-
if (!migReady || !current || current.id !== migReady.projectId) {
|
|
6282
|
-
$migGate.replaceChildren();
|
|
6283
|
-
$migGate.hidden = true;
|
|
6284
|
-
return;
|
|
6285
|
-
}
|
|
6286
|
-
$migGate.replaceChildren();
|
|
6287
|
-
$migGate.appendChild(document.createTextNode('This project uses the older per-sheet format. '));
|
|
6288
|
-
const go = revEl('button', null, 'Convert to the 3D model →');
|
|
6289
|
-
go.type = 'button';
|
|
6290
|
-
go.setAttribute('data-migrate-open', '1');
|
|
6291
|
-
go.setAttribute('data-tip', 'See exactly what the conversion will do before anything changes');
|
|
6292
|
-
$migGate.appendChild(go);
|
|
6293
|
-
$migGate.hidden = false;
|
|
6294
|
-
}
|
|
6295
|
-
|
|
6296
|
-
/**
|
|
6297
|
-
* The preview, fetched RAW rather than through the shared `api()` helper.
|
|
6298
|
-
*
|
|
6299
|
-
* `api()` treats a body with `ok: false` as a failure and throws. The preview's `ok` IS
|
|
6300
|
-
* `report.ok`, which is false whenever the conversion needs any decision confirmed — the ordinary
|
|
6301
|
-
* case, and the entire reason this modal exists. Routed through `api()` the normal path became an
|
|
6302
|
-
* error toast and the modal never opened.
|
|
6303
|
-
*
|
|
6304
|
-
* Measured in the browser, not reasoned about: the route tests drive `inject()` and read the body
|
|
6305
|
-
* directly, so no server test could have seen this. Only a non-2xx status is an error here, and the
|
|
6306
|
-
* parsed body rides along on it so the caller can still read `code`.
|
|
6307
|
-
*/
|
|
6308
|
-
async function migPreview(appId, projectId) {
|
|
6309
|
-
const res = await fetch(
|
|
6310
|
-
`/api/contract/${encodeURIComponent(appId)}/migrate-preview?project=${encodeURIComponent(projectId)}`,
|
|
6311
|
-
{ method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({}) });
|
|
6312
|
-
const body = await res.json().catch(() => null);
|
|
6313
|
-
if (!res.ok) {
|
|
6314
|
-
const err = new Error((body && body.error) || `HTTP ${res.status}`);
|
|
6315
|
-
err.body = body;
|
|
6316
|
-
throw err;
|
|
6317
|
-
}
|
|
6318
|
-
return body;
|
|
6319
|
-
}
|
|
6320
|
-
|
|
6321
|
-
/** One quiet line of what the conversion produces. Same `bits` idiom as `renderReview` — the zero
|
|
6322
|
-
* clause is omitted rather than printed as "0 of X". */
|
|
6323
|
-
function migCountsLine(report) {
|
|
6324
|
-
const c = (report && report.counts) || {};
|
|
6325
|
-
const bits = [];
|
|
6326
|
-
if (c.canonicalMembers) bits.push([String(c.canonicalMembers), ` model member${c.canonicalMembers > 1 ? 's' : ''}`]);
|
|
6327
|
-
if (c.observations) bits.push([String(c.observations), ` piece${c.observations > 1 ? 's' : ''} of evidence`]);
|
|
6328
|
-
const regs = (report && report.registrations) || [];
|
|
6329
|
-
if (regs.length) bits.push([String(regs.length), ` sheet${regs.length > 1 ? 's' : ''} registered onto the model frame`]);
|
|
6330
|
-
$migCounts.replaceChildren();
|
|
6331
|
-
if (!bits.length) { $migCounts.hidden = true; return; }
|
|
6332
|
-
bits.forEach(([n, rest], i) => {
|
|
6333
|
-
if (i) $migCounts.appendChild(document.createTextNode(' · '));
|
|
6334
|
-
$migCounts.appendChild(revEl('b', null, n));
|
|
6335
|
-
$migCounts.appendChild(document.createTextNode(rest));
|
|
6336
|
-
});
|
|
6337
|
-
$migCounts.appendChild(document.createTextNode(' — what this conversion produces.'));
|
|
6338
|
-
$migCounts.hidden = false;
|
|
6339
|
-
}
|
|
6340
|
-
|
|
6341
|
-
/** A label and a VALUE — not a transition. `fieldLine`'s arrow is wrong for a statement of fact. */
|
|
6342
|
-
function migFact(label, value) {
|
|
6343
|
-
const row = revEl('div', 'rev-field');
|
|
6344
|
-
row.appendChild(revEl('span', 'rev-field-key', prettyKey(label)));
|
|
6345
|
-
row.appendChild(revEl('span', 'hd-prof', value));
|
|
6346
|
-
return row;
|
|
6347
|
-
}
|
|
6348
|
-
|
|
6349
|
-
/** One tickable decision. `idx` indexes the decision list, which is what the progress count walks. */
|
|
6350
|
-
/**
|
|
6351
|
-
* Group decisions that are the SAME decision reported many times (#493).
|
|
6352
|
-
*
|
|
6353
|
-
* On a real read this is the difference between a usable gate and an unreachable one: a 218-member
|
|
6354
|
-
* model produced 260 decisions, 230 of them carrying one identical sentence — sheet S-203 declares
|
|
6355
|
-
* no `default_tos`, restated once per member end. Those are not 230 judgements. They are one fact,
|
|
6356
|
-
* and ticking it 230 times cannot inform the decision that is actually being made.
|
|
6357
|
-
*
|
|
6358
|
-
* THE KEY IS EXACT (code, message) EQUALITY, and that is the safety property rather than a
|
|
6359
|
-
* convenience. A `dedup-merge-proposed` row always names its own survivor and retired members in its
|
|
6360
|
-
* message, so two of them can never collide — the key structurally cannot sweep up a decision whose
|
|
6361
|
-
* instances differ, which is what keeps this a collapse of duplicates and not a bulk-accept in
|
|
6362
|
-
* disguise. (The "Needs your decision" bucket still renders NO bulk bar; that rule is untouched.)
|
|
6363
|
-
*
|
|
6364
|
-
* Runs are built in list order, so the rows stay in the order the reader would otherwise have met
|
|
6365
|
-
* them.
|
|
6366
|
-
*/
|
|
6367
|
-
/**
|
|
6368
|
-
* The decisions a fan-out row may collapse — and NOTHING ELSE MAY.
|
|
6369
|
-
*
|
|
6370
|
-
* DEFAULT-DENY, for the same reason `BULKABLE_DECISIONS` and `MIGRATE_TOPIC` are: a collapsed row is
|
|
6371
|
-
* one confirmation standing for many, which is the act epic §8 restricts, so eligibility has to be
|
|
6372
|
-
* granted deliberately rather than inherited by any code whose sentence happens to repeat. The first
|
|
6373
|
-
* cut keyed purely on (code, message) and was opt-out — review proved that reintroduced a bulk accept
|
|
6374
|
-
* by exactly the route the sibling tables were written to prevent.
|
|
6375
|
-
*
|
|
6376
|
-
* THE TEST IS THE SAME ONE `BULKABLE_DECISIONS` applies, one level down: is the repeated sentence a
|
|
6377
|
-
* statement about a SHEET (or the document) that the migrator restates per item, or a finding about
|
|
6378
|
-
* each particular item? `elevation-default-missing` is the first: it says sheet X declares no
|
|
6379
|
-
* `default_tos`, and every end that follows that sheet default gets the identical sentence. Resolving
|
|
6380
|
-
* it means giving sheet X a default — one act, whatever the fan-out.
|
|
6381
|
-
*
|
|
6382
|
-
* `col-metadata-unassigned` is the counter-example and the reason this list exists. Its message names
|
|
6383
|
-
* only the column mark ("column \"C1\" carries col-level note …"), so two DIFFERENT columns sharing a
|
|
6384
|
-
* mark across two sheets produce the identical sentence — and its question ("assign it to an end,
|
|
6385
|
-
* both ends, or the member") genuinely can be answered differently for each. Under the opt-out key
|
|
6386
|
-
* they collapsed into one row, titled with only the first sheet. Measured by review, not reasoned.
|
|
6387
|
-
*/
|
|
6388
|
-
const FANOUT_ELIGIBLE = new Set(['elevation-default-missing']);
|
|
6389
|
-
|
|
6390
|
-
function byIdenticalCause(list) {
|
|
6391
|
-
const runs = new Map();
|
|
6392
|
-
for (const d of list) {
|
|
6393
|
-
// `sheet` IS PART OF THE KEY, even though the eligible code names its sheet in the message. The
|
|
6394
|
-
// server's own `decisionsDigest` keys a decision on [code, sheet, path, message], so dropping a
|
|
6395
|
-
// field it treats as identity is how the two disagree about what "the same decision" means.
|
|
6396
|
-
// `path` is the axis a fan-out is meant to collapse, so it — and only it — is left out.
|
|
6397
|
-
//
|
|
6398
|
-
// JSON.stringify of the tuple, not a delimiter-joined string: a separator has to be a character
|
|
6399
|
-
// the fields cannot contain, and choosing one invisibly is how a raw NUL ended up in this source
|
|
6400
|
-
// on the first cut. Encoding the tuple needs no reserved character at all.
|
|
6401
|
-
//
|
|
6402
|
-
// An INELIGIBLE code is keyed by identity, so it can never share a run with anything.
|
|
6403
|
-
const key = FANOUT_ELIGIBLE.has(d.code)
|
|
6404
|
-
? JSON.stringify([d.code, d.sheet ?? null, d.message || ''])
|
|
6405
|
-
: JSON.stringify(['@solo', runs.size, d.code]);
|
|
6406
|
-
if (!runs.has(key)) runs.set(key, []);
|
|
6407
|
-
runs.get(key).push(d);
|
|
6408
|
-
}
|
|
6409
|
-
return [...runs.values()];
|
|
6410
|
-
}
|
|
6411
|
-
|
|
6412
|
-
/**
|
|
6413
|
-
* One row standing for N identical decisions, with the individual items disclosed behind an
|
|
6414
|
-
* expander. One real checkbox, so `syncMigrateProgress`'s `boxes.length` counts DECISIONS — which is
|
|
6415
|
-
* what "0 of 4 confirmed" should have meant all along.
|
|
6416
|
-
*
|
|
6417
|
-
* Honest by construction: the count is on the row face (not hidden in a tooltip), the expander
|
|
6418
|
-
* offers the evidence proactively rather than asking to be trusted, the badge stays "Decide", and
|
|
6419
|
-
* the message is the server's own sentence shown once, verbatim.
|
|
6420
|
-
*
|
|
6421
|
-
* Safe because the commit does not depend on these boxes. `confirmMigrate` sends
|
|
6422
|
-
* `acknowledgeDecisions: report.decisionsDigest` — a digest the SERVER computed over the whole
|
|
6423
|
-
* decision set at preview time — so the ticking is a client-side "prove you read them" gate and
|
|
6424
|
-
* collapsing rows cannot weaken the precondition. Verified against the route before building this.
|
|
6425
|
-
*/
|
|
6426
|
-
function migFanoutRow(run, idx) {
|
|
6427
|
-
const first = run[0];
|
|
6428
|
-
const row = revEl('div', 'rev-row k-changed');
|
|
6429
|
-
const id = `mig-dec-${idx}`;
|
|
6430
|
-
const label = revEl('label', 'rev-check');
|
|
6431
|
-
const box = document.createElement('input');
|
|
6432
|
-
box.type = 'checkbox';
|
|
6433
|
-
box.dataset.migidx = String(idx);
|
|
6434
|
-
box.dataset.migcode = first.code;
|
|
6435
|
-
box.dataset.migfanout = String(run.length); // read by syncMigrateProgress for the "ends affected" line
|
|
6436
|
-
// The scope belongs in the ACCESSIBLE NAME, not only in the visible count — a screen-reader user
|
|
6437
|
-
// must hear what they are confirming before they tick it, not after.
|
|
6438
|
-
box.setAttribute('aria-label', `Confirm this decision for all ${run.length} affected items`);
|
|
6439
|
-
box.setAttribute('aria-describedby', `${id}-msg`);
|
|
6440
|
-
label.appendChild(box);
|
|
6441
|
-
|
|
6442
|
-
const main = revEl('div', 'rev-row-main');
|
|
6443
|
-
const head = revEl('div', 'rev-row-head');
|
|
6444
|
-
head.appendChild(revEl('span', 'rev-kind-badge', 'Decide'));
|
|
6445
|
-
// The shared ROOT CAUSE names the row — there is no single member to name, and naming one of the
|
|
6446
|
-
// 230 would be worse than naming none.
|
|
6447
|
-
const title = revEl('span', 'rev-row-title', first.sheet || first.path || migTopic(first.code));
|
|
6448
|
-
title.id = `${id}-title`;
|
|
6449
|
-
head.appendChild(title);
|
|
6450
|
-
head.appendChild(revEl('span', 'ws-archived-count', String(run.length)));
|
|
6451
|
-
main.appendChild(head);
|
|
6452
|
-
|
|
6453
|
-
const msg = revEl('div', 'rev-row-note', first.message || first.code);
|
|
6454
|
-
msg.id = `${id}-msg`;
|
|
6455
|
-
main.appendChild(msg);
|
|
6456
|
-
|
|
6457
|
-
// SAY WHAT THE TICK COVERS, in the visible row and not only in the accessible name. The count
|
|
6458
|
-
// badge above states the scale; this states the CONSEQUENCE, which is the part someone consenting
|
|
6459
|
-
// needs. Without it the row reads as one decision that happens to mention a number.
|
|
6460
|
-
main.appendChild(revEl('div', 'mig-fanout-scope',
|
|
6461
|
-
`Confirming this row confirms it for all ${run.length}.`));
|
|
6462
|
-
|
|
6463
|
-
// CLOSED by default — never auto-open a 230-item list next to sibling rows the user must also see.
|
|
6464
|
-
const det = document.createElement('details');
|
|
6465
|
-
det.className = 'mig-fanout';
|
|
6466
|
-
const sum = document.createElement('summary');
|
|
6467
|
-
sum.className = 'mig-fanout-summary';
|
|
6468
|
-
sum.setAttribute('data-tip', 'See exactly which items this covers');
|
|
6469
|
-
sum.appendChild(revEl('span', 'ws-archived-caret', '›'));
|
|
6470
|
-
sum.appendChild(document.createTextNode(`Show all ${run.length} affected items`));
|
|
6471
|
-
det.appendChild(sum);
|
|
6472
|
-
const listEl = revEl('div', 'mig-fanout-list');
|
|
6473
|
-
for (const d of run) {
|
|
6474
|
-
// Read-only evidence, not 230 more checkboxes: the commit is digest-based, so per-item ticks
|
|
6475
|
-
// would imply a granularity the server cannot honour.
|
|
6476
|
-
listEl.appendChild(revEl('span', 'mig-fanout-item',
|
|
6477
|
-
[d.sheet, d.path, d.id].filter(Boolean).join(' · ') || d.code));
|
|
6478
|
-
}
|
|
6479
|
-
det.appendChild(listEl);
|
|
6480
|
-
main.appendChild(det);
|
|
6481
|
-
|
|
6482
|
-
row.appendChild(label);
|
|
6483
|
-
row.appendChild(main);
|
|
6484
|
-
return row;
|
|
6485
|
-
}
|
|
6486
|
-
|
|
6487
|
-
function migDecisionRow(issue, idx, proposal) {
|
|
6488
|
-
const row = revEl('div', 'rev-row k-changed');
|
|
6489
|
-
const id = `mig-dec-${idx}`;
|
|
6490
|
-
const label = revEl('label', 'rev-check');
|
|
6491
|
-
const box = document.createElement('input');
|
|
6492
|
-
box.type = 'checkbox';
|
|
6493
|
-
box.dataset.migidx = String(idx);
|
|
6494
|
-
box.dataset.migcode = issue.code;
|
|
6495
|
-
if (migBulkable(issue.code)) box.dataset.migbulk = '1';
|
|
6496
|
-
box.setAttribute('aria-labelledby', `${id}-title`);
|
|
6497
|
-
box.setAttribute('aria-describedby', `${id}-msg`);
|
|
6498
|
-
label.appendChild(box);
|
|
6499
|
-
|
|
6500
|
-
const main = revEl('div', 'rev-row-main');
|
|
6501
|
-
const head = revEl('div', 'rev-row-head');
|
|
6502
|
-
head.appendChild(revEl('span', 'rev-kind-badge', migBulkable(issue.code) ? 'Acknowledge' : 'Decide'));
|
|
6503
|
-
const title = revEl('span', 'rev-row-title', issue.sheet || issue.path || migTopic(issue.code));
|
|
6504
|
-
title.id = `${id}-title`;
|
|
6505
|
-
head.appendChild(title);
|
|
6506
|
-
main.appendChild(head);
|
|
6507
|
-
|
|
6508
|
-
const msg = revEl('div', 'rev-row-note', issue.message || issue.code);
|
|
6509
|
-
msg.id = `${id}-msg`;
|
|
6510
|
-
main.appendChild(msg);
|
|
6511
|
-
|
|
6512
|
-
// EVERY MEMBER NAMED, never a count. Epic §8 requires a merge to show its exact survivor and the
|
|
6513
|
-
// exact members retired into it; "3 members" is precisely the summary it forbids.
|
|
6514
|
-
if (proposal) {
|
|
6515
|
-
const fields = revEl('div', 'rev-fields');
|
|
6516
|
-
fields.appendChild(migFact('keeps', `${proposal.survivor.sheet}/${proposal.survivor.id}`));
|
|
6517
|
-
for (const m of proposal.members) {
|
|
6518
|
-
if (m.sheet === proposal.survivor.sheet && m.id === proposal.survivor.id) continue;
|
|
6519
|
-
fields.appendChild(migFact('retires',
|
|
6520
|
-
`${m.sheet}/${m.id}${m.swappedToSurvivor ? ' · reversed to match the survivor' : ''}`));
|
|
6521
|
-
}
|
|
6522
|
-
// `diffLine` HERE AND NOWHERE ELSE in this block, because here a before → after genuinely applies:
|
|
6523
|
-
// two members disagree and the merge keeps one value. The `keeps`/`retires` lines above are
|
|
6524
|
-
// statements of fact, not transitions — an earlier cut drew them with `fieldLine` and an empty
|
|
6525
|
-
// second value, which renders `Keeps S-201/C3 →`: an arrow pointing at nothing, on the one
|
|
6526
|
-
// screen where the user is consenting to members being retired. Found by review; unreachable in
|
|
6527
|
-
// the demo fixture, which produces no merge proposals at all, so the browser pass never drew it.
|
|
6528
|
-
for (const c of proposal.conflicts || []) {
|
|
6529
|
-
fields.appendChild(diffLine(c, 'the two disagree', 'the survivor’s value is kept',
|
|
6530
|
-
'The members being merged do not agree on this field, and merging keeps the survivor’s.'));
|
|
6531
|
-
}
|
|
6532
|
-
main.appendChild(fields);
|
|
6533
|
-
}
|
|
6534
|
-
|
|
6535
|
-
row.appendChild(label);
|
|
6536
|
-
row.appendChild(main);
|
|
6537
|
-
return row;
|
|
6538
|
-
}
|
|
6539
|
-
|
|
6540
|
-
/** The refusal surfaces: a conversion that cannot happen, and a preview that cannot be committed. */
|
|
6541
|
-
function migRefusal(title, lead, lines) {
|
|
6542
|
-
const wrap = document.createDocumentFragment();
|
|
6543
|
-
wrap.appendChild(revEl('div', 'hd-empty', lead));
|
|
6544
|
-
if (lines.length) {
|
|
6545
|
-
const g = group(title, lines.length, null);
|
|
6546
|
-
for (const t of lines) g.appendChild(revEl('div', 'rev-issue', t));
|
|
6547
|
-
wrap.appendChild(g);
|
|
6548
|
-
}
|
|
6549
|
-
return wrap;
|
|
6550
|
-
}
|
|
6551
|
-
|
|
6552
|
-
function renderMigrate(payload) {
|
|
6553
|
-
const report = (payload && payload.report) || {};
|
|
6554
|
-
const issues = Array.isArray(report.issues) ? report.issues : [];
|
|
6555
|
-
const blocks = issues.filter((i) => i.severity === 'block');
|
|
6556
|
-
const decisions = issues.filter((i) => i.severity === 'decision');
|
|
6557
|
-
const notes = issues.filter((i) => i.severity === 'report');
|
|
6558
|
-
migCountsLine(report);
|
|
6559
|
-
const body = document.createDocumentFragment();
|
|
6560
|
-
|
|
6561
|
-
// 1. CANNOT CONVERT. No Confirm rendered at all — a block is not something you can tick past, and
|
|
6562
|
-
// an inert primary button reads as an invitation to find the way around it.
|
|
6563
|
-
if (!payload.candidate) {
|
|
6564
|
-
$migCounts.hidden = true;
|
|
6565
|
-
body.appendChild(migRefusal('What is in the way', blocks.length
|
|
6566
|
-
? 'This project cannot be converted yet. Each of these has to be resolved in the drawings or the model first:'
|
|
6567
|
-
: 'This project cannot be converted yet.', blocks.map((b) => `${b.sheet ? `${b.sheet} — ` : ''}${b.message || b.code}`)));
|
|
6568
|
-
$migBody.replaceChildren(body);
|
|
6569
|
-
return { committable: false, decisions: [] };
|
|
6570
|
-
}
|
|
6571
|
-
|
|
6572
|
-
// 2. A DRAFT PREVIEW. The server strips the digest when it previewed posted bytes rather than the
|
|
6573
|
-
// stored document, because a draft-derived digest is one the commit can never accept. Unreachable
|
|
6574
|
-
// from this modal — it always previews the store — so this is a GUARD, kept because the
|
|
6575
|
-
// alternative is a renderer whose correctness depends on every future caller remembering to omit
|
|
6576
|
-
// one body key.
|
|
6577
|
-
if (payload.previewOf !== 'stored' || !report.decisionsDigest) {
|
|
6578
|
-
body.appendChild(migRefusal('', 'This preview was taken against unsaved changes rather than the '
|
|
6579
|
-
+ 'stored model, so it cannot be converted from here. Save the model, then preview again.', []));
|
|
6580
|
-
$migBody.replaceChildren(body);
|
|
6581
|
-
return { committable: false, decisions: [] };
|
|
6582
|
-
}
|
|
6583
|
-
|
|
6584
|
-
// 3. THE ORDINARY PATH. Choices first, acknowledgements second: the section needing real judgement
|
|
6585
|
-
// leads, and the one that is a click each sits last, right above Confirm.
|
|
6586
|
-
const proposals = Array.isArray(report.mergeProposals) ? report.mergeProposals : [];
|
|
6587
|
-
const merges = decisions.filter((d) => d.code === 'dedup-merge-proposed');
|
|
6588
|
-
// BY CONSTRUCTION, not by assumption: `proposeMerges` pushes a proposal and its issue in the same
|
|
6589
|
-
// loop iteration, so the Nth issue is the Nth proposal. Length-checked anyway — if they ever fall
|
|
6590
|
-
// out of step the rows lose their detail rather than attributing one merge's members to another.
|
|
6591
|
-
const aligned = merges.length === proposals.length;
|
|
6592
|
-
const proposalFor = (issue) => (aligned && issue.code === 'dedup-merge-proposed'
|
|
6593
|
-
? proposals[merges.indexOf(issue)] : null);
|
|
6594
|
-
|
|
6595
|
-
const byTopic = (list) => {
|
|
6596
|
-
const m = new Map();
|
|
6597
|
-
for (const d of list) {
|
|
6598
|
-
const t = migTopic(d.code);
|
|
6599
|
-
if (!m.has(t)) m.set(t, []);
|
|
6600
|
-
m.get(t).push(d);
|
|
6601
|
-
}
|
|
6602
|
-
return m;
|
|
6603
|
-
};
|
|
6604
|
-
const idxOf = new Map(decisions.map((d, i) => [d, i]));
|
|
6605
|
-
const choices = decisions.filter((d) => !migBulkable(d.code));
|
|
6606
|
-
const acks = decisions.filter((d) => migBulkable(d.code));
|
|
6607
|
-
|
|
6608
|
-
if (!decisions.length) {
|
|
6609
|
-
body.appendChild(revEl('div', 'hd-empty',
|
|
6610
|
-
'This conversion needs no decisions from you — nothing had to be assumed or chosen.'));
|
|
6611
|
-
}
|
|
6612
|
-
// THE KIND IS THE OUTER AXIS and topic the inner one, so a topic can legitimately appear under both
|
|
6613
|
-
// — "Saved views" has one decision of each kind in the demo model. Without a heading naming the kind,
|
|
6614
|
-
// the reader sees the same title twice, one with a bulk control and one without, and no way to tell
|
|
6615
|
-
// why. Measured in the browser: the first cut of this shipped exactly that.
|
|
6616
|
-
const section = (text, sub) => {
|
|
6617
|
-
const h = revEl('div', 'mig-section');
|
|
6618
|
-
h.appendChild(revEl('span', 'mig-section-title', text));
|
|
6619
|
-
h.appendChild(revEl('span', 'mig-section-sub', sub));
|
|
6620
|
-
return h;
|
|
6621
|
-
};
|
|
6622
|
-
if (choices.length) {
|
|
6623
|
-
body.appendChild(section('Needs your decision',
|
|
6624
|
-
'each of these could have gone another way — take them one at a time; '
|
|
6625
|
-
+ 'some apply to many parts of the model at once'));
|
|
6626
|
-
for (const [topic, list] of byTopic(choices)) {
|
|
6627
|
-
const runs = byIdenticalCause(list);
|
|
6628
|
-
// THE HEADER COUNTS DECISIONS, matching the rows beneath it and the progress line. Passing the
|
|
6629
|
-
// raw instance count made the same unlabelled number mean two different things on one screen —
|
|
6630
|
-
// a topic would read "230" over a single row that the progress line counted as one. The
|
|
6631
|
-
// fan-out is stated on the row that owns it, which is the only place it means something.
|
|
6632
|
-
// `null` bucket → `group` renders no bulk bar. The absence IS the rule, not an oversight.
|
|
6633
|
-
const g = group(topic, runs.length, null);
|
|
6634
|
-
for (const run of runs) {
|
|
6635
|
-
g.appendChild(run.length === 1
|
|
6636
|
-
? migDecisionRow(run[0], idxOf.get(run[0]), proposalFor(run[0]))
|
|
6637
|
-
: migFanoutRow(run, idxOf.get(run[0])));
|
|
6638
|
-
}
|
|
6639
|
-
body.appendChild(g);
|
|
6640
|
-
}
|
|
6641
|
-
}
|
|
6642
|
-
if (acks.length) {
|
|
6643
|
-
body.appendChild(section('To acknowledge',
|
|
6644
|
-
'consequences of the change itself — nothing here could have gone another way'));
|
|
6645
|
-
for (const [topic, list] of byTopic(acks)) {
|
|
6646
|
-
const g = group(topic, list.length, `mig-${topic.replace(/\W+/g, '-')}`);
|
|
6647
|
-
for (const d of list) g.appendChild(migDecisionRow(d, idxOf.get(d), null));
|
|
6648
|
-
body.appendChild(g);
|
|
6649
|
-
}
|
|
6650
|
-
}
|
|
6651
|
-
if (notes.length) {
|
|
6652
|
-
const det = document.createElement('details');
|
|
6653
|
-
det.className = 'ws-archived rev-issues';
|
|
6654
|
-
if (!decisions.length) det.open = true;
|
|
6655
|
-
const sum = document.createElement('summary');
|
|
6656
|
-
sum.className = 'ws-archived-summary';
|
|
6657
|
-
sum.appendChild(revEl('span', 'ws-archived-caret', '›'));
|
|
6658
|
-
sum.appendChild(document.createTextNode('For your information '));
|
|
6659
|
-
sum.appendChild(revEl('span', 'ws-archived-count', String(notes.length)));
|
|
6660
|
-
det.appendChild(sum);
|
|
6661
|
-
for (const n of notes) {
|
|
6662
|
-
const r = revEl('div', 'rev-issue', n.message || n.code || '');
|
|
6663
|
-
r.appendChild(revEl('span', 'rev-issue-path', n.sheet || n.path || ''));
|
|
6664
|
-
det.appendChild(r);
|
|
6665
|
-
}
|
|
6666
|
-
body.appendChild(det);
|
|
6667
|
-
}
|
|
6668
|
-
$migBody.replaceChildren(body);
|
|
6669
|
-
return { committable: true, decisions };
|
|
6670
|
-
}
|
|
6671
|
-
|
|
6672
|
-
/**
|
|
6673
|
-
* The tick progress and the Confirm gate.
|
|
6674
|
-
*
|
|
6675
|
-
* `aria-disabled` rather than the `disabled` attribute, matching `.kb-organize` and `.ecard .e-act`:
|
|
6676
|
-
* a disabled button is unhoverable and unfocusable, so the `data-tip` explaining WHY would never
|
|
6677
|
-
* reach the person who needs it. The click handler checks the same flag.
|
|
6678
|
-
*/
|
|
6679
|
-
function syncMigrateProgress() {
|
|
6680
|
-
if (!migState) return;
|
|
6681
|
-
const boxes = [...$migBody.querySelectorAll('input[type="checkbox"][data-migidx]')];
|
|
6682
|
-
const done = boxes.filter((b) => b.checked).length;
|
|
6683
|
-
const left = boxes.length - done;
|
|
6684
|
-
// A collapsed row stands for many items (#493), so the count of BOXES is the count of decisions
|
|
6685
|
-
// while the count of ITEMS is what the reader is actually agreeing about. State both, and only
|
|
6686
|
-
// when they differ — on a model with no fan-out the parenthetical would be noise.
|
|
6687
|
-
const items = boxes.reduce((n, b) => n + (Number(b.dataset.migfanout) || 1), 0);
|
|
6688
|
-
const fannedOut = items > boxes.length;
|
|
6689
|
-
if (!boxes.length) { $migProgress.hidden = true; }
|
|
6690
|
-
else {
|
|
6691
|
-
$migProgress.replaceChildren();
|
|
6692
|
-
$migProgress.appendChild(revEl('b', null, String(done)));
|
|
6693
|
-
$migProgress.appendChild(document.createTextNode(
|
|
6694
|
-
` of ${boxes.length} decision${boxes.length === 1 ? '' : 's'} confirmed`));
|
|
6695
|
-
if (fannedOut) $migProgress.appendChild(document.createTextNode(` (${items} items affected)`));
|
|
6696
|
-
if (left) $migProgress.appendChild(document.createTextNode(` — ${left} still to go.`));
|
|
6697
|
-
$migProgress.hidden = false;
|
|
6698
|
-
}
|
|
6699
|
-
const ready = left === 0;
|
|
6700
|
-
$migConfirm.setAttribute('aria-disabled', String(!ready));
|
|
6701
|
-
$migConfirm.setAttribute('data-tip', ready
|
|
6702
|
-
? 'Convert this project — a new version is recorded'
|
|
6703
|
-
: `Confirm all ${boxes.length} decision${boxes.length === 1 ? '' : 's'} before converting`
|
|
6704
|
-
+ `${fannedOut ? ` (covers ${items} items)` : ''} — ${left} left`);
|
|
6705
|
-
}
|
|
6706
|
-
|
|
6707
|
-
function closeMigrate() {
|
|
6708
|
-
$migModal.classList.remove('show');
|
|
6709
|
-
const st = migState;
|
|
6710
|
-
migState = null;
|
|
6711
|
-
$migChanged.hidden = true;
|
|
6712
|
-
$migConfirm.disabled = false;
|
|
6713
|
-
const back = st && st.returnFocus;
|
|
6714
|
-
if (back instanceof HTMLElement && back.isConnected) back.focus();
|
|
6715
|
-
}
|
|
6716
|
-
|
|
6717
|
-
async function openMigrate() {
|
|
6718
|
-
if (!current || !migReady || migReady.projectId !== current.id) return;
|
|
6719
|
-
const { projectId, appId, etag, head } = migReady;
|
|
6720
|
-
const returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
6721
|
-
let payload;
|
|
6722
|
-
try {
|
|
6723
|
-
payload = await migPreview(appId, projectId);
|
|
6724
|
-
} catch (err) {
|
|
6725
|
-
showToast('Could not preview the conversion: ' + ((err && err.message) || err), 'warn');
|
|
6726
|
-
return;
|
|
6727
|
-
}
|
|
6728
|
-
if (!current || current.id !== projectId) return; // switched projects during the fetch
|
|
6729
|
-
// RENDER BEFORE ADOPTING THE STATE, the ordering the revision modal was fixed to use: a throw
|
|
6730
|
-
// inside the renderer must not leave the state latched with no modal on screen.
|
|
6731
|
-
$migSub.textContent = 'Nothing changes until you confirm. This records a new version and cannot be undone.';
|
|
6732
|
-
$migChanged.hidden = true;
|
|
6733
|
-
const { committable } = renderMigrate(payload);
|
|
6734
|
-
$migConfirm.hidden = !committable;
|
|
6735
|
-
migState = { projectId, appId, etag, head, digest: payload.report && payload.report.decisionsDigest, returnFocus };
|
|
6736
|
-
if (committable) syncMigrateProgress(); else $migProgress.hidden = true;
|
|
6737
|
-
$migModal.classList.add('show');
|
|
6738
|
-
// The first thing still to do — which, with choices rendered first, is the harder work.
|
|
6739
|
-
const first = $migBody.querySelector('input[type="checkbox"]:not(:checked)');
|
|
6740
|
-
(first || $migCancel).focus();
|
|
6741
|
-
}
|
|
6742
|
-
|
|
6743
|
-
/** Re-preview in place after a stale precondition, clearing every tick. Mirrors the revision modal's
|
|
6744
|
-
* 409 branch, including its render-first-then-adopt ordering. */
|
|
6745
|
-
async function migRestage(why) {
|
|
6746
|
-
// CAPTURED, not re-read after the await. Cancel stays live while this is in flight (it is not part
|
|
6747
|
-
// of the busy chrome), so a user who cancels mid-restage sets `migState` to null — and building the
|
|
6748
|
-
// next state from the global afterwards would spread `null`, render into a closed modal, and leave a
|
|
6749
|
-
// half-formed `migState` behind it. The identity check below is what makes cancelling actually
|
|
6750
|
-
// cancel. Found by review.
|
|
6751
|
-
const st = migState;
|
|
6752
|
-
if (!st) return;
|
|
6753
|
-
const { projectId, appId } = st;
|
|
6754
|
-
let fresh, next;
|
|
6755
|
-
try {
|
|
6756
|
-
const res = await fetch(`/api/contract/${encodeURIComponent(appId)}?project=${encodeURIComponent(projectId)}`,
|
|
6757
|
-
{ headers: { 'content-type': 'application/json' } });
|
|
6758
|
-
const etag = res.headers.get('ETag');
|
|
6759
|
-
const vr = await api(`/api/projects/${encodeURIComponent(projectId)}/versions`).catch(() => null);
|
|
6760
|
-
const head = (Array.isArray(vr && vr.versions) ? vr.versions : [])[0]?.n ?? 0;
|
|
6761
|
-
fresh = await migPreview(appId, projectId);
|
|
6762
|
-
if (!etag) throw new Error('the model no longer reports a version tag');
|
|
6763
|
-
next = { ...st, etag, head, digest: fresh.report && fresh.report.decisionsDigest };
|
|
6764
|
-
} catch (err) {
|
|
6765
|
-
if (migState !== st) return; // cancelled while we were asking; say nothing, close nothing
|
|
6766
|
-
showToast('Could not re-check the conversion: ' + ((err && err.message) || err), 'warn');
|
|
6767
|
-
closeMigrate();
|
|
6768
|
-
return;
|
|
6769
|
-
}
|
|
6770
|
-
// The review may have been cancelled or replaced while the three fetches were in flight. Rendering
|
|
6771
|
-
// now would paint into a modal the user has already dismissed.
|
|
6772
|
-
if (migState !== st) return;
|
|
6773
|
-
// RENDER BEFORE ADOPTING THE STATE — and an earlier cut of this function adopted first, which is
|
|
6774
|
-
// the very bug `openMigrate` carries a comment about and the revision modal was fixed for. It is
|
|
6775
|
-
// worse here than there: `renderMigrate` throwing after the swap would leave the OLD rows on screen,
|
|
6776
|
-
// still ticked, above a Confirm now carrying the NEW digest. That posts a decision set the user
|
|
6777
|
-
// never saw and earns a 200 for it. Rendering first means a throw leaves the stale-but-consistent
|
|
6778
|
-
// pair, and the caller's `finally` still restores the button.
|
|
6779
|
-
const { committable } = renderMigrate(fresh); // replaceChildren builds new, unticked inputs
|
|
6780
|
-
// ALL THREE ADOPTED TOGETHER. Taking a new digest against an old ETag would confirm a mixture of two
|
|
6781
|
-
// moments, which is the exact failure the preconditions exist to prevent.
|
|
6782
|
-
migState = next;
|
|
6783
|
-
$migConfirm.hidden = !committable;
|
|
6784
|
-
if (committable) syncMigrateProgress(); else $migProgress.hidden = true;
|
|
6785
|
-
$migChanged.replaceChildren();
|
|
6786
|
-
$migChanged.appendChild(revEl('b', null, why));
|
|
6787
|
-
$migChanged.appendChild(document.createTextNode(' This is the current preview, and your ticks were'
|
|
6788
|
-
+ ' cleared — the same decision can mean something different against a model that moved.'));
|
|
6789
|
-
$migChanged.hidden = false;
|
|
6790
|
-
}
|
|
6791
|
-
|
|
6792
|
-
async function confirmMigrate() {
|
|
6793
|
-
const st = migState;
|
|
6794
|
-
if (!st) return;
|
|
6795
|
-
if ($migConfirm.getAttribute('aria-disabled') === 'true') return; // the gate, not just the styling
|
|
6796
|
-
$migConfirm.disabled = true;
|
|
6797
|
-
$migConfirm.setAttribute('aria-busy', 'true');
|
|
6798
|
-
const label = $migConfirm.textContent;
|
|
6799
|
-
$migConfirm.textContent = 'Converting…';
|
|
6800
|
-
try {
|
|
6801
|
-
let res;
|
|
6802
|
-
try {
|
|
6803
|
-
res = await api(`/api/contract/${encodeURIComponent(st.appId)}/migrate?project=${encodeURIComponent(st.projectId)}`, {
|
|
6804
|
-
method: 'POST',
|
|
6805
|
-
headers: { 'content-type': 'application/json', 'If-Match': st.etag },
|
|
6806
|
-
body: JSON.stringify({ expectLedgerHead: st.head, acknowledgeDecisions: st.digest }),
|
|
6807
|
-
});
|
|
6808
|
-
} catch (err) {
|
|
6809
|
-
const code = err && err.body && err.body.code;
|
|
6810
|
-
// THREE OUTCOMES, and the difference is whether re-previewing would tell the user anything.
|
|
6811
|
-
//
|
|
6812
|
-
// A moved document or ledger, or a mismatched digest: what they looked at is not what would be
|
|
6813
|
-
// written, but a fresh preview IS meaningful. Re-preview in place rather than closing, which
|
|
6814
|
-
// would lose their place. `contract-not-migratable` joins them — a re-preview renders the blocks
|
|
6815
|
-
// that now stand in the way, which is exactly what they need to see.
|
|
6816
|
-
if (code === 'precondition-failed' || code === 'precondition-required'
|
|
6817
|
-
|| code === 'contract-not-migratable') {
|
|
6818
|
-
await migRestage('The project changed while you were reviewing.');
|
|
6819
|
-
return;
|
|
6820
|
-
}
|
|
6821
|
-
// ALREADY CONVERTED, OR GONE. Re-previewing would say nothing useful — there is no v1 left to
|
|
6822
|
-
// preview — so the modal CLOSES rather than sitting there re-clickable against a store that can
|
|
6823
|
-
// never accept it. Found by review: `runMigration` checks the contract TYPE before the ETag, so
|
|
6824
|
-
// another tab converting this same project earns `contract-type-unsupported`, not a precondition
|
|
6825
|
-
// failure, and the branch above would have left this modal open and repeat-clickable forever.
|
|
6826
|
-
// THE FULL SET, enumerated rather than sampled, because a code that falls through to the toast
|
|
6827
|
-
// below leaves the modal open and repeat-clickable. The commit route can return exactly:
|
|
6828
|
-
// `project-required` (unreachable — this caller always sends ?project), `unknown-project`,
|
|
6829
|
-
// `precondition-required`, `precondition-failed`, `contract-absent`,
|
|
6830
|
-
// `contract-type-unsupported`, `contract-not-migratable` and `contract-recovery-pending`.
|
|
6831
|
-
// The first branch takes the three worth re-previewing; these four are terminal.
|
|
6832
|
-
const TERMINAL = {
|
|
6833
|
-
'contract-type-unsupported': 'This project has already been converted — it is on the 3D model now',
|
|
6834
|
-
'contract-absent': 'That project no longer holds a contract to convert',
|
|
6835
|
-
'unknown-project': 'That project no longer exists',
|
|
6836
|
-
'contract-recovery-pending': 'This project has an unfinished conversion to recover first — reopen it and try again',
|
|
6837
|
-
};
|
|
6838
|
-
if (Object.hasOwn(TERMINAL, code)) {
|
|
6839
|
-
showToast(TERMINAL[code], 'warn');
|
|
6840
|
-
closeMigrate();
|
|
6841
|
-
refreshMigrateGate(); // the offer is gone, or was never valid; stop showing it
|
|
6842
|
-
return;
|
|
6843
|
-
}
|
|
6844
|
-
showToast('Could not convert: ' + ((err && err.message) || err), 'warn');
|
|
6845
|
-
return; // NOT closed — the review is still valid and their ticks are still worth something
|
|
6846
|
-
}
|
|
6847
|
-
// The store is v2 now. `clearApproval` ran inside the transaction, but this shell holds
|
|
6848
|
-
// `approvedAt` in memory and only refreshes it through the exports/history paths — so without
|
|
6849
|
-
// this line a stale "approved" badge survives a conversion that invalidated the sign-off.
|
|
6850
|
-
if (current && current.id === st.projectId) {
|
|
6851
|
-
current.approvedAt = undefined;
|
|
6852
|
-
if (!$wsHistory.hidden) renderHistory();
|
|
6853
|
-
if (!$wsExports.hidden) renderExports();
|
|
6854
|
-
syncWorkspaceGuide();
|
|
6855
|
-
// AND the Approve header, for the same reason the line above gives. Converting a legacy
|
|
6856
|
-
// project MINTS its incarnation (`ensureProjectIncarnationLocked`, inside the migration
|
|
6857
|
-
// transaction), so the "duplicate it to sign off" state this header was showing is now false
|
|
6858
|
-
// — and nothing else re-asks. It survived before only because the header's click-to-retry
|
|
6859
|
-
// treated that state as a failed probe; it is not one, so the thing that CHANGES the
|
|
6860
|
-
// condition is what has to say so.
|
|
6861
|
-
// Reported, not swallowed — matching openProject's identical call. `refreshApprovalState`
|
|
6862
|
-
// handles its own fetch failures, so the only way this rejects is a throw from the render it
|
|
6863
|
-
// does BEFORE its try (a missing node, a descriptor with no steps). Dropping that would leave
|
|
6864
|
-
// the header still telling the user to duplicate a project whose incarnation was just minted,
|
|
6865
|
-
// with nothing said anywhere.
|
|
6866
|
-
refreshApprovalState(st.projectId).catch((e) => console.error('[workspaces] approval header did not refresh after conversion', e));
|
|
6867
|
-
}
|
|
6868
|
-
showToast(`Converted to the 3D model — version ${res.versionN} is on History`, 'ok');
|
|
6869
|
-
closeMigrate();
|
|
6870
|
-
refreshMigrateGate(); // the offer is gone: the project is no longer v1
|
|
6871
|
-
} finally {
|
|
6872
|
-
$migConfirm.disabled = false;
|
|
6873
|
-
$migConfirm.removeAttribute('aria-busy');
|
|
6874
|
-
$migConfirm.textContent = label;
|
|
6875
|
-
}
|
|
6876
|
-
}
|
|
6877
|
-
|
|
6878
|
-
$migBody.addEventListener('change', (e) => {
|
|
6879
|
-
if (e.target && e.target.matches('input[type="checkbox"][data-migidx]')) syncMigrateProgress();
|
|
6880
|
-
});
|
|
6881
|
-
$migBody.addEventListener('click', (e) => {
|
|
6882
|
-
const bulk = e.target.closest('[data-revbulk]');
|
|
6883
|
-
if (!bulk) return;
|
|
6884
|
-
const on = bulk.dataset.revbulkon === '1';
|
|
6885
|
-
// Scoped to the CLICKED GROUP, and additionally to rows the code list marks bulkable — belt and
|
|
6886
|
-
// braces, because a bulk bar can only appear on an acknowledgement group in the first place.
|
|
6887
|
-
const g = bulk.closest('.rev-group');
|
|
6888
|
-
for (const box of (g || $migBody).querySelectorAll('input[data-migbulk="1"]')) box.checked = on;
|
|
6889
|
-
syncMigrateProgress();
|
|
6890
|
-
});
|
|
6891
|
-
$migGate.addEventListener('click', (e) => { if (e.target.closest('[data-migrate-open]')) openMigrate(); });
|
|
6892
|
-
$migConfirm.addEventListener('click', confirmMigrate);
|
|
6893
|
-
$migCancel.addEventListener('click', closeMigrate);
|
|
6894
|
-
onBackdropDismiss($migModal, closeMigrate, () => !$migConfirm.disabled);
|
|
6895
|
-
$migModal.addEventListener('keydown', (e) => {
|
|
6896
|
-
if (e.key === 'Escape') { e.preventDefault(); if (!$migConfirm.disabled) closeMigrate(); }
|
|
6897
|
-
});
|
|
6898
|
-
|
|
6899
6111
|
// ── History step ────────────────────────────────────────────────────────────────
|
|
6900
6112
|
// The project's version ledger. A version = a commit (Approve = Model gate, Rollback = unsigned).
|
|
6901
6113
|
// The draft contract is the working tree; an unapproved draft shows the working-copy banner.
|
|
@@ -7088,21 +6300,21 @@
|
|
|
7088
6300
|
// Built with DOM methods rather than innerHTML — the label comes from a descriptor, so it is the
|
|
7089
6301
|
// same "don't route it through a string template at all" rule `importFailedCmdRow` follows.
|
|
7090
6302
|
const gen = ++modelPresenceGen;
|
|
7091
|
-
const hasModel = await
|
|
6303
|
+
const hasModel = await projectContractState(id, current.app);
|
|
7092
6304
|
if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden) return;
|
|
7093
6305
|
applyModelPresence(hasModel); // one answer, every surface — History used to keep its own
|
|
7094
6306
|
const empty = document.createElement('div');
|
|
7095
6307
|
empty.className = 'hist-empty';
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
if (hasModel) {
|
|
7099
|
-
btn.id = 'hist-approve';
|
|
7100
|
-
btn.textContent = 'Approve this version';
|
|
7101
|
-
empty.append('No versions yet — ', btn, ' to create ');
|
|
6308
|
+
if (hasModel === 'model') {
|
|
6309
|
+
empty.append('No approved versions yet. Review the model, then use Review & approve in the project header to create ');
|
|
7102
6310
|
const v1 = document.createElement('b');
|
|
7103
6311
|
v1.textContent = 'v1';
|
|
7104
6312
|
empty.append(v1, ' and start the ledger.');
|
|
6313
|
+
} else if (hasModel === 'filter-checkpoint') {
|
|
6314
|
+
empty.append('Drawing Filter saved. Read the selected drawing content to build the model; History starts after the first drawing read is complete.');
|
|
7105
6315
|
} else {
|
|
6316
|
+
const btn = document.createElement('button');
|
|
6317
|
+
btn.type = 'button';
|
|
7106
6318
|
btn.id = 'hist-go-drawings';
|
|
7107
6319
|
btn.textContent = `Go to ${stepLabel('drawings')}`;
|
|
7108
6320
|
empty.append('Nothing here yet — ', btn, ' to get started.');
|
|
@@ -7118,9 +6330,9 @@
|
|
|
7118
6330
|
const working = approvalState.status === 'ready' && approvalState.pendingCount > 0
|
|
7119
6331
|
? (headKind === 'revision-read'
|
|
7120
6332
|
? `<div class="hist-working">● <b>The AI read ${headIsInitialRead ? 'the initial' : 'a revised'} drawing set — review it before signing.</b> ` +
|
|
7121
|
-
`Open <b>${escapeHtml(stepLabel('model'))}</b> to check the change, then
|
|
6333
|
+
`Open <b>${escapeHtml(stepLabel('model'))}</b> to check the change, then use Review & approve in the project header. Exports keep using ${approvalState.headVersion ? `approved v${approvalState.headVersion}` : 'an explicitly selected DRAFT'}.</div>`
|
|
7122
6334
|
: '<div class="hist-working">● <b>Working copy isn’t signed off.</b> ' +
|
|
7123
|
-
|
|
6335
|
+
`Use Review & approve in the project header. Exports keep using ${approvalState.headVersion ? `approved v${approvalState.headVersion}` : 'an explicitly selected DRAFT'}.</div>`)
|
|
7124
6336
|
: '';
|
|
7125
6337
|
$wsHistory.innerHTML =
|
|
7126
6338
|
'<div class="hist-note"><b>Approved versions</b> are immutable. Starting from an older version creates a new working revision; it never rewrites history.</div>' +
|
|
@@ -7624,7 +6836,6 @@
|
|
|
7624
6836
|
}
|
|
7625
6837
|
|
|
7626
6838
|
$wsHistory.addEventListener('click', (e) => {
|
|
7627
|
-
if (e.target.closest('#hist-approve')) { approveProject(); return; }
|
|
7628
6839
|
// The no-model empty state's real next step: go read a drawing. Same handler shape as the
|
|
7629
6840
|
// Approve it replaces, so the pane keeps owning its own inline actions.
|
|
7630
6841
|
if (e.target.closest('#hist-go-drawings')) { setStep('drawings'); return; }
|
|
@@ -7682,13 +6893,10 @@
|
|
|
7682
6893
|
// A conversion is a lifecycle act, so this menu beside Rename/Duplicate/Archive is where it belongs
|
|
7683
6894
|
// — and an earlier cut of this unit put it here. It was DEAD CODE, by construction: `openProjMenu`
|
|
7684
6895
|
// is wired only to the LANDING-GRID kebab (the `$landing` click handler), `applyMode` hides the
|
|
7685
|
-
// landing whenever a project is open, and `migReady` is only ever set while a project IS open on its
|
|
7686
6896
|
// Model step. The two conditions are mutually exclusive, so the branch could never render — except
|
|
7687
|
-
// in the one state where `migReady` leaked past `closeProject`, where it rendered an item that did
|
|
7688
6897
|
// nothing at all. Found by review.
|
|
7689
6898
|
//
|
|
7690
6899
|
// Putting it back means surfacing it from the open-project chrome (the header picker), where
|
|
7691
|
-
// `migReady` can actually be true. Until then the Model-step banner carries discovery, and shipping
|
|
7692
6900
|
// a branch with a comment describing behaviour that never happens is worse than shipping neither.
|
|
7693
6901
|
const r = anchor.getBoundingClientRect();
|
|
7694
6902
|
// 288 = the menu's actual 280px width (.menu in app.css) + an 8px margin. It read 260 — an
|