@floless/app 0.114.0 → 0.116.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 +5847 -5525
- package/dist/skills/floless-app-bridge/SKILL.md +1 -1
- package/dist/skills/floless-app-onboarding/SKILL.md +1 -1
- package/dist/skills/floless-app-queue/SKILL.md +1 -1
- package/dist/skills/floless-app-routines/SKILL.md +1 -1
- package/dist/skills/floless-app-steel-model/SKILL.md +1 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +98 -17
- package/dist/skills/floless-app-ui/SKILL.md +1 -1
- package/dist/skills/floless-app-workflows/SKILL.md +1 -1
- package/dist/skills/reading-structural-drawings/SKILL.md +1 -1
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +1 -1
- package/dist/web/app.css +52 -0
- package/dist/web/aware.js +194 -5
- package/dist/web/index.html +1 -1
- package/dist/web/workspaces.js +661 -27
- package/package.json +2 -1
package/dist/web/workspaces.js
CHANGED
|
@@ -193,6 +193,14 @@
|
|
|
193
193
|
capability: 'Open model → new project',
|
|
194
194
|
sub: 'Copies the steel model open in Workflows into a new project here.',
|
|
195
195
|
label: 'Copy the open model',
|
|
196
|
+
// Describes the MECHANISM, never a live fact. Disabling this card when there is nothing to
|
|
197
|
+
// copy would need a server probe whose answer goes stale between render and click — so it
|
|
198
|
+
// could never be the only gate anyway (the rollback in createSeeded is). A tip that says
|
|
199
|
+
// what the card does sets the same expectation and cannot be wrong.
|
|
200
|
+
// "nothing is KEPT", not "nothing gets created" — the rollback's archive POST can itself
|
|
201
|
+
// fail, and on that branch a project does briefly exist. A tip must not promise what the
|
|
202
|
+
// failure path cannot honour.
|
|
203
|
+
tip: 'Copies the steel model currently open in Workflows. If nothing’s open there, nothing is kept.',
|
|
196
204
|
},
|
|
197
205
|
],
|
|
198
206
|
editor: '/steel-editor.html',
|
|
@@ -206,8 +214,12 @@
|
|
|
206
214
|
],
|
|
207
215
|
diff: true, // steel semantic diff expander
|
|
208
216
|
exports: [
|
|
209
|
-
|
|
210
|
-
|
|
217
|
+
// ONE card, THREE export kinds (bom-csv / bom-xlsx / bom-html). It was a card per file format
|
|
218
|
+
// while there were two; the report made three, and three tiles of the same bill is a grid that
|
|
219
|
+
// says "pick a card" when the real question is "which columns, and in what". `file:false`
|
|
220
|
+
// because a card fronting several kinds cannot state its status through the single-kind
|
|
221
|
+
// exportState path — bomCardState lists one row per file actually produced, like Render.
|
|
222
|
+
{ kind: 'bom', ico: '▤', name: 'Bill of materials', fmt: 'CSV · XLSX · Report', verb: 'Export BOM', file: false },
|
|
211
223
|
{ kind: 'ifc', ico: '◈', name: 'Model', fmt: 'IFC4', verb: 'Export IFC', file: true, open: false },
|
|
212
224
|
// ONE card for every CAD destination, not one per application. It was Tekla-only while
|
|
213
225
|
// Tekla was the only host that could receive a model; Revit, SketchUp and Rhino now can
|
|
@@ -335,6 +347,35 @@
|
|
|
335
347
|
let wsAppEntries = wsDefaultAppEntries();
|
|
336
348
|
let current = null; // the open project (null = landing)
|
|
337
349
|
|
|
350
|
+
/**
|
|
351
|
+
* Does the open project hold a model, as far as the Exports pane knows? (#490)
|
|
352
|
+
*
|
|
353
|
+
* Module state rather than a `paintExports` parameter because there are eighteen call sites — a
|
|
354
|
+
* repaint triggered by a finished export, a host-readiness probe, an SSE nudge — and every one of
|
|
355
|
+
* them would have to remember to thread it through. One that forgot would silently repaint the gate
|
|
356
|
+
* as if a model existed, which is the exact bug being fixed. `renderExports` owns refreshing it;
|
|
357
|
+
* `openProject` resets it so a model-less project cannot leave a stale `false` on the next one.
|
|
358
|
+
*
|
|
359
|
+
* Declared HERE with the other project-scoped state rather than beside `paintExports`, because
|
|
360
|
+
* `openProject` assigns it and sits earlier in the file — a `let` further down works only as long as
|
|
361
|
+
* nothing calls that function during module init, which is not a property worth depending on.
|
|
362
|
+
*
|
|
363
|
+
* Defaults TRUE, matching `projectHasContract`'s fail-open: the cost of a wrong `true` is the
|
|
364
|
+
* pre-existing 404, and the cost of a wrong `false` is telling someone their real model is missing.
|
|
365
|
+
*/
|
|
366
|
+
let exportsHasModel = true;
|
|
367
|
+
|
|
368
|
+
/** Sequence number for model-presence probes. A project-id check is NOT a staleness guard: two
|
|
369
|
+
* probes can be in flight for the SAME project, and an older "absent" answer landing last would
|
|
370
|
+
* re-disable Approve on a project that now has a model. Every writer bumps it; older results drop. */
|
|
371
|
+
let modelPresenceGen = 0;
|
|
372
|
+
|
|
373
|
+
/** The header's AUTHORED tooltip, captured from the static markup so the has-a-model state restores
|
|
374
|
+
* it verbatim. The first cut substituted "exports unlock after it", which is a FALSE description of
|
|
375
|
+
* an already-approved project — its exports are unlocked and its gate is gone. */
|
|
376
|
+
const APPROVE_TIP = document.getElementById('ws-approve')?.getAttribute('data-tip')
|
|
377
|
+
|| 'Locks in this version — your edits already auto-save; this is the sign-off.';
|
|
378
|
+
|
|
338
379
|
// The open app's visible label for a step key (Model→"Model" for steel, "Traced" for vectorize) —
|
|
339
380
|
// so shared chrome (banners, prompts) names the app's OWN step, never hard-coded steel vocabulary.
|
|
340
381
|
// Falls back to a capitalized key if the descriptor is missing a step.
|
|
@@ -681,6 +722,7 @@
|
|
|
681
722
|
const target = entry.ambiguous ? entry.appId : '';
|
|
682
723
|
return `<button type="button" class="ws-seed${isDrawing ? ' ws-seed-drop' : ''}" ` +
|
|
683
724
|
`aria-label="${escapeAttr((action.label || action.headline) + (target ? ` (on the ${target} workflow)` : ''))}" ` +
|
|
725
|
+
(action.tip ? `data-tip="${escapeAttr(action.tip)}" ` : '') +
|
|
684
726
|
`data-seed-app="${escapeAttr(entry.appId)}" data-seed-template="${escapeAttr(entry.templateId)}" data-seed-action="${escapeAttr(action.kind)}"` +
|
|
685
727
|
(isDrawing ? ` data-seed-drop="${escapeAttr(entry.appId)}"` : '') +
|
|
686
728
|
`>` +
|
|
@@ -939,11 +981,32 @@
|
|
|
939
981
|
if (!name) return;
|
|
940
982
|
try {
|
|
941
983
|
const { project, seeded } = await api('/api/projects', { method: 'POST', body: JSON.stringify({ name, app: appId, seedFromApp: true }) });
|
|
942
|
-
// Tell the truth about the import: seeded=false means there was no current model to copy
|
|
943
|
-
// (or it was unreadable) — the project is EMPTY, don't imply the model came across.
|
|
944
984
|
const seedLabel = (WORKSPACE_APPS[templateId] && WORKSPACE_APPS[templateId].seedLabel) || 'model';
|
|
945
|
-
|
|
946
|
-
|
|
985
|
+
// ROLL BACK when there was nothing to copy (#489). `seeded:false` means the app held no current
|
|
986
|
+
// model (or it was unreadable), so this card's ONE job did not happen. Saying so in a toast was
|
|
987
|
+
// honest but not enough: it still created and opened a project indistinguishable from a real
|
|
988
|
+
// one, whose Model tab reads "No model for steel-model" and whose only other signal is a 404 in
|
|
989
|
+
// a console the user never opens. They then have to discover the failure two clicks later and
|
|
990
|
+
// clean up a junk project. The sibling drop-a-drawing create already rolls its own failure back
|
|
991
|
+
// through archiveEmptyProject; this is the same move, and it can make the stronger statement —
|
|
992
|
+
// the branch happens BEFORE openProject, so nothing was ever shown and "no project was created"
|
|
993
|
+
// is literally true, where the drawing path can only say the empty one "was removed".
|
|
994
|
+
if (!seeded) {
|
|
995
|
+
const removed = await archiveEmptyProject(project.id);
|
|
996
|
+
showToast(
|
|
997
|
+
removed
|
|
998
|
+
? `There’s no ${seedLabel} currently open in Workflows to copy — no project was created.`
|
|
999
|
+
: `There’s no ${seedLabel} currently open in Workflows to copy — but an empty project was left behind; archive it from the ⋯ menu.`,
|
|
1000
|
+
'warn',
|
|
1001
|
+
);
|
|
1002
|
+
// `archiveEmptyProject` drops the local row whether or not the archive SUCCEEDED, so on
|
|
1003
|
+
// failure the card the toast just told the user to open a menu on would not be there. Go back
|
|
1004
|
+
// to the server: it still holds that project, so the card returns and the instruction can
|
|
1005
|
+
// actually be followed. On success this also reconciles against any racing loadProjects().
|
|
1006
|
+
if (removed) renderLanding(); else await loadProjects();
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
showToast(`Project "${project.name}" created from the current ${seedLabel}`, 'ok');
|
|
947
1010
|
track('workspace_project_created', { app: appId }); // takeoff-import create path
|
|
948
1011
|
projects.unshift(project);
|
|
949
1012
|
openProject(project.id);
|
|
@@ -1054,6 +1117,41 @@
|
|
|
1054
1117
|
setStep(initialStep);
|
|
1055
1118
|
applyMode();
|
|
1056
1119
|
syncWorkspaceGuide(); // point the shared beacon at THIS project's document lifecycle
|
|
1120
|
+
// Detached, but never silent: `projectHasContract` cannot reject, yet the code after its await can
|
|
1121
|
+
// (stepLabel -> wsApp on a descriptor without steps), and an unhandled rejection would leave the
|
|
1122
|
+
// header un-updated with nothing said.
|
|
1123
|
+
refreshModelPresence(p.id, p.app).catch((e) => { // gate the header CHECK Approve for THIS project (#490)
|
|
1124
|
+
console.error('[workspaces] could not resolve model presence', e);
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* One probe, three surfaces (#490). The header **✓ Approve** has the same defect the issue reported
|
|
1130
|
+
* on History and Exports — measured on a model-less project it is fully enabled, and the route it
|
|
1131
|
+
* posts to answers `404 {"error":"no contract to approve"}`. It is not an inline call-to-action
|
|
1132
|
+
* though: it is persistent chrome with nothing to swap it for, so it gets the codebase's
|
|
1133
|
+
* `aria-disabled` + `data-tip` treatment (`.e-act`, `.kb-organize`, `$migConfirm`) rather than
|
|
1134
|
+
* History's removal. `aria-disabled` and not `disabled`, for the reason those three already record:
|
|
1135
|
+
* a disabled button is unhoverable and unfocusable, so the tip explaining WHY would never reach the
|
|
1136
|
+
* person who needs it — and `approveProject` re-checks the same flag rather than trusting the
|
|
1137
|
+
* attribute.
|
|
1138
|
+
*/
|
|
1139
|
+
async function refreshModelPresence(projectId, appId) {
|
|
1140
|
+
const gen = ++modelPresenceGen;
|
|
1141
|
+
const present = await projectHasContract(projectId, appId);
|
|
1142
|
+
if (gen !== modelPresenceGen || !current || current.id !== projectId) return; // superseded
|
|
1143
|
+
applyModelPresence(present);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/** Push the answer to the flag AND the header together, so no two surfaces can disagree. */
|
|
1147
|
+
function applyModelPresence(present) {
|
|
1148
|
+
exportsHasModel = present;
|
|
1149
|
+
const btn = document.getElementById('ws-approve');
|
|
1150
|
+
if (!btn) return;
|
|
1151
|
+
btn.setAttribute('aria-disabled', String(!present));
|
|
1152
|
+
btn.setAttribute('data-tip', present
|
|
1153
|
+
? APPROVE_TIP
|
|
1154
|
+
: `Nothing to approve yet — read a drawing on ${stepLabel('drawings')} first`);
|
|
1057
1155
|
}
|
|
1058
1156
|
function closeProject() {
|
|
1059
1157
|
current = null;
|
|
@@ -1076,6 +1174,9 @@
|
|
|
1076
1174
|
// was already per-project, the two variables behind it were not.)
|
|
1077
1175
|
migReady = null;
|
|
1078
1176
|
closeMigrate();
|
|
1177
|
+
// Reset with the rest of the per-project state — this file resets `histDiffSupported` for exactly
|
|
1178
|
+
// this reason. Bumping the generation also voids any probe still in flight for the closing project.
|
|
1179
|
+
exportsHasModel = true; modelPresenceGen++;
|
|
1079
1180
|
lastRevState = 'none'; $revisionCard.hidden = true; closeProjMenu(); applyMode(); syncWorkspaceGuide();
|
|
1080
1181
|
}
|
|
1081
1182
|
document.getElementById('ws-back').addEventListener('click', closeProject);
|
|
@@ -1146,8 +1247,33 @@
|
|
|
1146
1247
|
// Exports gate unlocks without a reload.
|
|
1147
1248
|
async function approveProject() {
|
|
1148
1249
|
if (!current) return;
|
|
1250
|
+
// The flag, not the attribute — `aria-disabled` is advisory and the button stays clickable BY
|
|
1251
|
+
// DESIGN (that is what keeps its data-tip reachable), so this is the check that actually holds.
|
|
1252
|
+
// Without it the header button still fires the 404 that #490 is about. Say what to do instead
|
|
1253
|
+
// rather than reporting the failure: the user has no model, and that is the only useful sentence.
|
|
1254
|
+
// RE-PROBE before refusing, never refuse from the cache. A stale `false` here is far worse than
|
|
1255
|
+
// the 404 it replaced: it blocks a legitimate sign-off while confidently telling the user to read a
|
|
1256
|
+
// drawing they have already read — and stale IS reachable, because a model can appear without this
|
|
1257
|
+
// pane hearing about it (an AI read landing while Drawings is open, a staged review confirmed
|
|
1258
|
+
// elsewhere, the editor's first autosave). One request at click time removes the whole class.
|
|
1259
|
+
if (!exportsHasModel) {
|
|
1260
|
+
const stillNone = !(await projectHasContract(current.id, current.app));
|
|
1261
|
+
if (!current) return; // closed during the probe
|
|
1262
|
+
applyModelPresence(!stillNone); // correct the cache either way — the header was lying too
|
|
1263
|
+
if (stillNone) {
|
|
1264
|
+
showToast(`There’s no model to approve yet — read a drawing on ${stepLabel('drawings')} first.`, 'warn');
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1149
1268
|
const approvingProject = current;
|
|
1150
1269
|
const btn = document.getElementById('ws-approve');
|
|
1270
|
+
// Unreachable today (#ws-approve is static markup), but approveProject is driven from THREE
|
|
1271
|
+
// controls — a silent return would turn all three into dead clicks if the header were ever renamed.
|
|
1272
|
+
if (!btn) {
|
|
1273
|
+
console.error('[workspaces] #ws-approve is missing — Approve cannot run');
|
|
1274
|
+
showToast('Couldn’t start Approve — reload the page.', 'warn');
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1151
1277
|
btn.disabled = true;
|
|
1152
1278
|
const prev = btn.textContent;
|
|
1153
1279
|
btn.textContent = '◆ Approving…';
|
|
@@ -2377,6 +2503,10 @@
|
|
|
2377
2503
|
function exportUrl(kind, projectId, appId) {
|
|
2378
2504
|
const qs = `?project=${encodeURIComponent(projectId)}`;
|
|
2379
2505
|
const base = `/api/contract/${encodeURIComponent(appId)}`;
|
|
2506
|
+
// The BATCH route: one request, one project lock, every picked format. Three separate requests
|
|
2507
|
+
// would release the lock between formats — long enough for a render to take it and leave this
|
|
2508
|
+
// card waiting minutes — and would let the workbook see a different approved version than the CSV.
|
|
2509
|
+
if (kind === 'bom') return `${base}/export-bom${qs}`;
|
|
2380
2510
|
if (kind === 'bom-csv') return `${base}/export-bom/csv${qs}`;
|
|
2381
2511
|
if (kind === 'bom-xlsx') return `${base}/export-bom/xlsx${qs}`;
|
|
2382
2512
|
if (kind === 'ifc') return `${base}/export-ifc${qs}`;
|
|
@@ -2536,6 +2666,193 @@
|
|
|
2536
2666
|
return options;
|
|
2537
2667
|
}
|
|
2538
2668
|
|
|
2669
|
+
// ── The Bill of Materials card ────────────────────────────────────────────────────────────────
|
|
2670
|
+
// Formats cheap-first, which is also the order the server writes them in: a report that fails still
|
|
2671
|
+
// leaves the CSV and the workbook on disk. `meta` carries the extension AND the cost, the same shape
|
|
2672
|
+
// the render dialog's own options use.
|
|
2673
|
+
// The extension is IN the label because a checklist row has no neutral slot beside it — its status
|
|
2674
|
+
// slot is coloured (ready / checking / blocked) and none of those tones means "here is a hint".
|
|
2675
|
+
// The cost asymmetry is not repeated here; it belongs in the live footnote, which is the only place
|
|
2676
|
+
// that can state it for the combination actually picked.
|
|
2677
|
+
const BOM_FORMATS = [
|
|
2678
|
+
{ value: 'csv', label: 'CSV' },
|
|
2679
|
+
{ value: 'xlsx', label: 'Excel workbook (.xlsx)' },
|
|
2680
|
+
{ value: 'html', label: 'Report (.html)' },
|
|
2681
|
+
];
|
|
2682
|
+
|
|
2683
|
+
// One row per format on the card, in this fixed order — deliberately NOT newest-first like the
|
|
2684
|
+
// render card. All three come out of ONE click, so their timestamps are equal to the minute and
|
|
2685
|
+
// sorting by time only makes the order look arbitrary from one repaint to the next.
|
|
2686
|
+
const BOM_ROWS = [
|
|
2687
|
+
{ kind: 'bom-csv', format: 'csv', label: 'CSV' },
|
|
2688
|
+
{ kind: 'bom-xlsx', format: 'xlsx', label: 'Excel workbook' },
|
|
2689
|
+
{ kind: 'bom-html', format: 'html', label: 'Report' },
|
|
2690
|
+
];
|
|
2691
|
+
|
|
2692
|
+
// Mirrors the server's registry (bom-format.ts). Canonical order, never pick order: a bill is a
|
|
2693
|
+
// standard deliverable, and the same columns arriving in a different sequence week to week is
|
|
2694
|
+
// exactly what breaks an estimator's comparison. `meta` teaches the two that are new.
|
|
2695
|
+
// Each label is EXACTLY the header the file will carry, so the picker is a preview of the bill
|
|
2696
|
+
// rather than a glossary of it. What Grade and Type mean for the ROWS — that picking them
|
|
2697
|
+
// subdivides the bill — is the dialog's `sub`, because that is the part a label cannot say.
|
|
2698
|
+
const BOM_COLUMNS = [
|
|
2699
|
+
{ value: 'profile', label: 'Profile' },
|
|
2700
|
+
{ value: 'grade', label: 'Grade' },
|
|
2701
|
+
{ value: 'type', label: 'Type' },
|
|
2702
|
+
{ value: 'qty', label: 'Qty' },
|
|
2703
|
+
{ value: 'length', label: 'Length (ft)' },
|
|
2704
|
+
{ value: 'lbft', label: 'lb/ft' },
|
|
2705
|
+
{ value: 'weight', label: 'Weight (lb)' },
|
|
2706
|
+
];
|
|
2707
|
+
const BOM_DESCRIPTIVE = ['profile', 'grade', 'type'];
|
|
2708
|
+
const DEFAULT_BOM_FORMATS = ['csv', 'xlsx'];
|
|
2709
|
+
const DEFAULT_BOM_COLUMNS = ['profile', 'qty', 'length', 'lbft', 'weight'];
|
|
2710
|
+
|
|
2711
|
+
// Picks made this session, per project — the same in-memory treatment renderChoices gets, so a
|
|
2712
|
+
// detailer exporting a second project does not inherit the first one's columns.
|
|
2713
|
+
const bomChoices = new Map();
|
|
2714
|
+
|
|
2715
|
+
const splitPicks = (v) => String(v || '').split(',').map((s) => s.trim()).filter(Boolean);
|
|
2716
|
+
|
|
2717
|
+
/**
|
|
2718
|
+
* The refusals, in one place so the live footnote and the OK handler cannot disagree about what is
|
|
2719
|
+
* allowed. Each exists because the alternative is a file that looks like a bill and is not — the
|
|
2720
|
+
* server enforces the same three (bomColumnRefusal), because a browser is not a gate.
|
|
2721
|
+
*/
|
|
2722
|
+
function bomRefusal(formats, columns) {
|
|
2723
|
+
if (!formats.length) return 'Pick at least one format to export.';
|
|
2724
|
+
if (!columns.length) return 'Pick at least one column to export.';
|
|
2725
|
+
// Same ORDER as the server's bomColumnRefusal, deliberately: unticking Profile breaks both this
|
|
2726
|
+
// and the descriptive rule, and only this message names the real conflict and both ways out —
|
|
2727
|
+
// and adding Profile satisfies the other rule too, where adding Grade would earn a second refusal.
|
|
2728
|
+
if (columns.includes('lbft') && !columns.includes('profile')) {
|
|
2729
|
+
return 'lb/ft is a property of the profile — pick Profile too, or drop lb/ft.';
|
|
2730
|
+
}
|
|
2731
|
+
if (!columns.some((c) => BOM_DESCRIPTIVE.includes(c))) {
|
|
2732
|
+
return 'Pick at least one of Profile, Grade or Type — a bill has to say what the material is.';
|
|
2733
|
+
}
|
|
2734
|
+
return null;
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
/**
|
|
2738
|
+
* The live footnote: what this click will cost, and the one consequence the dialog cannot otherwise
|
|
2739
|
+
* show. Not a restatement of the picks — the trigger buttons already summarise those, and
|
|
2740
|
+
* renderEstimate's whole justification is saying something no static label could.
|
|
2741
|
+
*
|
|
2742
|
+
* The cost line leads because the formats are not alike: two are instant and the report compiles and
|
|
2743
|
+
* runs an AWARE app. No invented number — "a few seconds" is what has actually been measured until
|
|
2744
|
+
* someone measures it properly, and an under-promise is what makes a working export read as hung.
|
|
2745
|
+
*/
|
|
2746
|
+
function bomPreview(values) {
|
|
2747
|
+
const formats = splitPicks(values.formats);
|
|
2748
|
+
const columns = splitPicks(values.columns);
|
|
2749
|
+
const refusal = bomRefusal(formats, columns);
|
|
2750
|
+
if (refusal) return refusal;
|
|
2751
|
+
|
|
2752
|
+
const instant = formats.filter((f) => f !== 'html');
|
|
2753
|
+
const n = formats.length;
|
|
2754
|
+
const files = `${n} file${n === 1 ? '' : 's'}`;
|
|
2755
|
+
let text;
|
|
2756
|
+
if (!formats.includes('html')) text = `${files}, written straight away.`;
|
|
2757
|
+
else if (!instant.length) text = 'One file — the report takes a few seconds to render.';
|
|
2758
|
+
else {
|
|
2759
|
+
const names = instant.map((f) => (f === 'csv' ? 'CSV' : 'Excel workbook'));
|
|
2760
|
+
text = `${files}. The ${names.join(' and ')} ${names.length === 1 ? 'is' : 'are'} written straight away; the report takes a few seconds.`;
|
|
2761
|
+
}
|
|
2762
|
+
// Said ONLY when it can bite. The bill this button writes is the one you picked; the bill a Run
|
|
2763
|
+
// writes is baked into the approved lock and is always the full one, because what a locked run
|
|
2764
|
+
// produces must not depend on a preference living in a browser. Someone who has not narrowed
|
|
2765
|
+
// anything has no contradiction to be warned about, so they are not.
|
|
2766
|
+
const narrowed = columns.length !== DEFAULT_BOM_COLUMNS.length
|
|
2767
|
+
|| DEFAULT_BOM_COLUMNS.some((c) => !columns.includes(c));
|
|
2768
|
+
return narrowed ? `${text} Running the workflow still writes the full bill.` : text;
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
async function askBomOptions(projectId) {
|
|
2772
|
+
if (!bridge.formModal) return { formats: [...DEFAULT_BOM_FORMATS], columns: [...DEFAULT_BOM_COLUMNS] };
|
|
2773
|
+
const last = bomChoices.get(projectId) || {};
|
|
2774
|
+
const chosen = await bridge.formModal({
|
|
2775
|
+
title: 'Export Bill of Materials',
|
|
2776
|
+
// The one mechanic that is not obvious from the controls, and the reason Grade is worth picking:
|
|
2777
|
+
// the columns are the grouping, not just the headings.
|
|
2778
|
+
sub: 'Rows are grouped by the columns you pick — adding Grade or Type can split one line into several.',
|
|
2779
|
+
okLabel: 'Export',
|
|
2780
|
+
onChange: bomPreview,
|
|
2781
|
+
// The card repaints on the way in, which moves focus off the button, so naming it explicitly is
|
|
2782
|
+
// what keeps Cancel from dropping focus behind the dialog — same reasoning as the render dialog.
|
|
2783
|
+
returnFocusTo: $wsExports.querySelector('[data-export="bom"]'),
|
|
2784
|
+
returnFocusFallback: () => (current && current.id === projectId
|
|
2785
|
+
? $wsExports.querySelector('[data-export="bom"]')
|
|
2786
|
+
: null),
|
|
2787
|
+
fields: [
|
|
2788
|
+
// `checklist compact` — the same control the CAD-destination card and the render dialog's
|
|
2789
|
+
// viewpoints use for a multi-pick, so the two consolidated export cards in this grid ask
|
|
2790
|
+
// their question the same way. Every row is visible and ticked or not, which is what a
|
|
2791
|
+
// column picker wants: a collapsed "5 selected" hides the very thing being chosen.
|
|
2792
|
+
{
|
|
2793
|
+
name: 'formats', label: 'Formats', type: 'checklist', compact: true,
|
|
2794
|
+
// Defaults to the two cards this one replaced. A consolidated card must not quietly give a
|
|
2795
|
+
// plain click FEWER files than before, nor surprise anyone with the slower opt-in format.
|
|
2796
|
+
value: (last.formats || DEFAULT_BOM_FORMATS).join(','),
|
|
2797
|
+
options: BOM_FORMATS,
|
|
2798
|
+
},
|
|
2799
|
+
{
|
|
2800
|
+
name: 'columns', label: 'Columns', type: 'checklist', compact: true,
|
|
2801
|
+
value: (last.columns || DEFAULT_BOM_COLUMNS).join(','),
|
|
2802
|
+
options: BOM_COLUMNS,
|
|
2803
|
+
},
|
|
2804
|
+
],
|
|
2805
|
+
});
|
|
2806
|
+
if (!chosen) return null;
|
|
2807
|
+
const formats = splitPicks(chosen.formats);
|
|
2808
|
+
const columns = splitPicks(chosen.columns);
|
|
2809
|
+
// Refuse and say which rule — never disable OK (formModal gates only checkbox/files anyway), and
|
|
2810
|
+
// never silently repair the selection. Dropping lb/ft or adding Profile behind someone's back
|
|
2811
|
+
// changes the deliverable's shape without telling them, which is worse than asking again.
|
|
2812
|
+
const refusal = bomRefusal(formats, columns);
|
|
2813
|
+
if (refusal) { showToast(refusal, 'warn'); return null; }
|
|
2814
|
+
const options = { formats, columns };
|
|
2815
|
+
bomChoices.set(projectId, options);
|
|
2816
|
+
return options;
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
/**
|
|
2820
|
+
* The BOM card's state — the same {meta, disabled, tip} shape as renderCardState, and for the same
|
|
2821
|
+
* reason: it fronts several export kinds, so `exportState[c.kind]` cannot describe it.
|
|
2822
|
+
*/
|
|
2823
|
+
function bomCardState(approved) {
|
|
2824
|
+
if (!approved) return {
|
|
2825
|
+
meta: '<span class="e-status">Available after approval</span>',
|
|
2826
|
+
disabled: true,
|
|
2827
|
+
tip: 'Approve this version first',
|
|
2828
|
+
};
|
|
2829
|
+
// `exportState == null` means the LISTING failed, not that nothing was exported. Printing "not
|
|
2830
|
+
// exported yet" would be a definite negative the server never confirmed.
|
|
2831
|
+
if (exportState == null) {
|
|
2832
|
+
return { meta: '<span class="e-status">Status unavailable</span>', disabled: false, tip: '' };
|
|
2833
|
+
}
|
|
2834
|
+
const done = BOM_ROWS
|
|
2835
|
+
.filter((row) => exportState[row.kind] && exportState[row.kind].exportedAt)
|
|
2836
|
+
.map((row) => ({ ...row, exportedAt: exportState[row.kind].exportedAt }));
|
|
2837
|
+
if (!done.length) {
|
|
2838
|
+
return { meta: '<span class="e-status">not exported yet</span>', disabled: false, tip: '' };
|
|
2839
|
+
}
|
|
2840
|
+
const rows = done.map((row) =>
|
|
2841
|
+
`<div class="e-render-row">` +
|
|
2842
|
+
`<span class="e-done"><span class="chk">✓</span> ${escapeHtml(row.label)} <span class="t">${escapeHtml(hhmm(row.exportedAt))}</span></span>` +
|
|
2843
|
+
`<span class="e-links">` +
|
|
2844
|
+
`<button type="button" class="e-link" data-openfile="${escapeAttr(row.kind)}" data-tip="Open in its default app">⧉ Open</button>` +
|
|
2845
|
+
`<button type="button" class="e-link" data-reveal="${escapeAttr(row.kind)}" data-tip="Show the file in its folder">▤ Reveal</button>` +
|
|
2846
|
+
`</span>` +
|
|
2847
|
+
`</div>`).join('');
|
|
2848
|
+
// At most three rows, so this never scrolls — but it reuses the render card's themed scroller
|
|
2849
|
+
// verbatim rather than inventing a second way to list produced files.
|
|
2850
|
+
return {
|
|
2851
|
+
meta: `<div class="e-renders" role="group" aria-label="Exported files">${rows}</div>`,
|
|
2852
|
+
disabled: false, tip: '', rendered: true,
|
|
2853
|
+
};
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2539
2856
|
const receiptKey = (kind) => `${current ? current.id : ''}:${kind}`;
|
|
2540
2857
|
|
|
2541
2858
|
function receiptItemText(prefix, value) {
|
|
@@ -3315,7 +3632,8 @@
|
|
|
3315
3632
|
// below. `special` keeps the branches from growing a third arm each time a kind is added.
|
|
3316
3633
|
const special = c.kind === 'send-host' ? sendHostCardState(approved)
|
|
3317
3634
|
: c.kind === 'share-3d' ? shareCardState(approved)
|
|
3318
|
-
: c.kind === 'render' ? renderCardState(approved)
|
|
3635
|
+
: c.kind === 'render' ? renderCardState(approved)
|
|
3636
|
+
: c.kind === 'bom' ? bomCardState(approved) : null;
|
|
3319
3637
|
if (special) {
|
|
3320
3638
|
meta = special.meta;
|
|
3321
3639
|
} else if (!approved) {
|
|
@@ -3339,7 +3657,11 @@
|
|
|
3339
3657
|
// Re-labelled once a link exists, mirroring the file kinds' "Re-export" convention. Gated on the
|
|
3340
3658
|
// in-memory record rather than exportState, which only ever tracks file exports.
|
|
3341
3659
|
const shared = approved && c.kind === 'share-3d' && shareLinks.has(`${current.id}:share-3d`);
|
|
3342
|
-
|
|
3660
|
+
// `special.rendered` means "this card has already produced something", whatever card it is. It was
|
|
3661
|
+
// gated on `c.kind === 'render'` as well, which made the flag unreadable for any other multi-kind
|
|
3662
|
+
// card: the BOM card would have gone on saying "Export BOM" forever after a successful export.
|
|
3663
|
+
// Safe for the CAD card, which reports the same idea through its own `sent`.
|
|
3664
|
+
const rendered = approved && special && special.rendered;
|
|
3343
3665
|
const sentSomewhere = approved && c.kind === 'send-host' && special && special.sent;
|
|
3344
3666
|
const busyLabel = c.kind === 'send-host' ? sendBusyText() : c.kind === 'share-3d' ? 'Creating…'
|
|
3345
3667
|
: c.kind === 'render' ? 'Rendering…' : 'Exporting…';
|
|
@@ -3356,14 +3678,22 @@
|
|
|
3356
3678
|
// and every other project-scoped export serializes on that same key. In-process those queue
|
|
3357
3679
|
// with no timeout, so a sibling card clicked meanwhile would just sit on "Exporting…" with no
|
|
3358
3680
|
// explanation. Say what is happening instead of letting it hang.
|
|
3359
|
-
|
|
3360
|
-
|
|
3681
|
+
//
|
|
3682
|
+
// A LIST rather than one kind, because `render` is no longer the only card shaped like this. The
|
|
3683
|
+
// BOM's Report format installs an agent if missing, then compiles and runs an AWARE app, all
|
|
3684
|
+
// inside the project lock; a CAD send takes that lock once per destination. Both reproduced the
|
|
3685
|
+
// exact hang this line exists to prevent — a sibling card clicked meanwhile sat silent.
|
|
3686
|
+
const HOLDS_PROJECT = ['render', 'bom', 'send-host'];
|
|
3687
|
+
const holder = HOLDS_PROJECT.find((k) => k !== c.kind && exportBusy.has(`${current.id}:${k}`));
|
|
3688
|
+
const disabled = !!holder || (special ? special.disabled : !approved);
|
|
3361
3689
|
const busyTip = c.kind === 'send-host' ? sendBusyText()
|
|
3362
3690
|
: c.kind === 'share-3d' ? 'Rendering the model and uploading the link'
|
|
3363
3691
|
: c.kind === 'render' ? renderBusyText()
|
|
3364
3692
|
: 'Export in progress';
|
|
3365
3693
|
const tip = busy ? busyTip
|
|
3366
|
-
:
|
|
3694
|
+
: holder === 'render' ? 'Waiting for the render to finish — it holds this project while it runs'
|
|
3695
|
+
: holder === 'bom' ? 'Waiting for the bill of materials to finish — it holds this project while it runs'
|
|
3696
|
+
: holder === 'send-host' ? 'Waiting for the CAD send to finish — it holds this project while it runs'
|
|
3367
3697
|
: special ? special.tip : (approved ? '' : 'Approve this version first');
|
|
3368
3698
|
// A button blocked by a DURABLE, card-specific reason is `aria-disabled`, never `disabled`: a
|
|
3369
3699
|
// natively disabled control leaves the tab order, so a keyboard or screen-reader user can
|
|
@@ -3413,7 +3743,11 @@
|
|
|
3413
3743
|
for (const attr of EXPORT_FOCUS_ATTRS) {
|
|
3414
3744
|
if (element.hasAttribute(attr)) return { attr, value: element.getAttribute(attr), cardKind };
|
|
3415
3745
|
}
|
|
3416
|
-
|
|
3746
|
+
// BOTH gate buttons. The gate renders one or the other depending on whether a model exists, and
|
|
3747
|
+
// this pane repaints on a timer and on every export completion — so a keyboard user sitting on
|
|
3748
|
+
// "Go to <step>" would be dropped to <body> with no announcement.
|
|
3749
|
+
return (element.id === 'ws-exports-approve' || element.id === 'ws-exports-go-drawings')
|
|
3750
|
+
? { id: element.id, cardKind: null } : null;
|
|
3417
3751
|
}
|
|
3418
3752
|
|
|
3419
3753
|
function restoreExportFocus(identity) {
|
|
@@ -3433,6 +3767,7 @@
|
|
|
3433
3767
|
}
|
|
3434
3768
|
|
|
3435
3769
|
function paintExports(approvedAt, requestedRestoreKind) {
|
|
3770
|
+
const hasModel = exportsHasModel;
|
|
3436
3771
|
// An explicit kind says "put them back on the button they pressed" — but only if they are still
|
|
3437
3772
|
// here. A send runs for minutes and its refresh repaints at the END; honouring the request
|
|
3438
3773
|
// unconditionally would reach across and yank focus out of whatever they had moved on to, which
|
|
@@ -3445,8 +3780,14 @@
|
|
|
3445
3780
|
const approved = !!approvedAt;
|
|
3446
3781
|
let html = '';
|
|
3447
3782
|
if (!approved) {
|
|
3448
|
-
|
|
3449
|
-
|
|
3783
|
+
// Same split as History's empty state (#490): with a model, Approve is genuinely the unlocking
|
|
3784
|
+
// action; with none, `POST …/approve` 404s, so pointing at it is a dead end and the real next
|
|
3785
|
+
// step is to go read a drawing. `stepLabel('drawings')` because that label is per-app.
|
|
3786
|
+
html += hasModel
|
|
3787
|
+
? `<div class="ws-exports-gate">Exports go out after sign-off — ` +
|
|
3788
|
+
`<button type="button" id="ws-exports-approve">Approve this version</button> to enable them.</div>`
|
|
3789
|
+
: `<div class="ws-exports-gate">Nothing to export yet — ` +
|
|
3790
|
+
`<button type="button" id="ws-exports-go-drawings">Go to ${escapeHtml(stepLabel('drawings'))}</button> to get started.</div>`;
|
|
3450
3791
|
}
|
|
3451
3792
|
// The word `exports` was styled like a link (mono, accent-bright) and was inert, so people
|
|
3452
3793
|
// clicked it and nothing happened. It is now the control it already looked like: a real button
|
|
@@ -3454,8 +3795,14 @@
|
|
|
3454
3795
|
// one the per-file Reveal button uses — rather than a new icon vocabulary. Left ENABLED before
|
|
3455
3796
|
// the first export on purpose: the sentence asserts the folder as a present-tense fact, and a
|
|
3456
3797
|
// disabled-in-its-empty-state control is exactly the trap this pane is reviewed for.
|
|
3457
|
-
|
|
3458
|
-
|
|
3798
|
+
//
|
|
3799
|
+
// The headline used to read "Export at any stage", which flatly contradicted the gate directly
|
|
3800
|
+
// above it ("Exports go out after sign-off") and every card's own "Available after approval"
|
|
3801
|
+
// caption. The note's job — per the comment above — is to justify the exports-FOLDER button
|
|
3802
|
+
// staying enabled, not to claim the export actions work unapproved. "Polishing is optional" was
|
|
3803
|
+
// the true and useful half, and it survives; only the opening clause overreached.
|
|
3804
|
+
html += `<div class="exports-note"><b>Any approved version can be exported</b> — polishing further ` +
|
|
3805
|
+
`is optional. Each writes to this project’s <button type="button" class="exports-note-link" data-open-exports-folder ` +
|
|
3459
3806
|
`aria-label="Open the exports folder" data-tip="Open this project’s exports folder">▤ exports</button> folder.</div>`;
|
|
3460
3807
|
const cards = (wsApp() && wsApp().exports) || [];
|
|
3461
3808
|
html += '<div class="export-grid">' + cards.map((c) => cardHtml(c, approved)).join('') + '</div>';
|
|
@@ -3527,6 +3874,47 @@
|
|
|
3527
3874
|
* there is no identity left to restore. Carrying the kind through both paints means pressing
|
|
3528
3875
|
* Send leaves you on Send.
|
|
3529
3876
|
*/
|
|
3877
|
+
/**
|
|
3878
|
+
* Does the open project hold a stored document at all? (#490)
|
|
3879
|
+
*
|
|
3880
|
+
* NOT the same question as "does it have versions", and conflating them is the bug. History's empty
|
|
3881
|
+
* state fires whenever the ledger is empty, which covers TWO situations: a real model waiting for its
|
|
3882
|
+
* first sign-off, and a project nothing has ever been read into. Only the second must not offer
|
|
3883
|
+
* Approve — `POST …/approve` 404s there, and the primary call-to-action on the screen becomes the one
|
|
3884
|
+
* control that lies while every export button around it is correctly gated.
|
|
3885
|
+
*
|
|
3886
|
+
* Decided HERE and shared by both panes rather than derived twice, for the reason
|
|
3887
|
+
* `/api/projects/:id/versions` already gives for shipping `diffSupported` from the server: a client
|
|
3888
|
+
* that guesses is how an affordance appears for something the server will then refuse. Two panes
|
|
3889
|
+
* guessing separately is the same failure with an extra way to disagree.
|
|
3890
|
+
*
|
|
3891
|
+
* `quietMissing=1` answers 204 for both kinds of absence and never emits an ETag, so this costs one
|
|
3892
|
+
* cheap request and cannot be confused with a real document.
|
|
3893
|
+
*/
|
|
3894
|
+
async function projectHasContract(projectId, appId) {
|
|
3895
|
+
try {
|
|
3896
|
+
const url = `/api/contract/${encodeURIComponent(appId)}?project=${encodeURIComponent(projectId)}&quietMissing=1`;
|
|
3897
|
+
// TIMEOUT, because a HANG is not an error and would never reach the catch below. Both callers
|
|
3898
|
+
// await this before painting, so without a deadline a wedged connection leaves History reading
|
|
3899
|
+
// "Loading history…" and every Exports destination row on "Checking…" indefinitely, with no
|
|
3900
|
+
// error and no retry. HEAD, not GET — `web/aware.js`'s copy of this probe already does it and
|
|
3901
|
+
// says why: a GET pulls the whole contract (hundreds of KB on a real model) for a boolean, on
|
|
3902
|
+
// every repaint, and repaints fire after every export and every send to a CAD host.
|
|
3903
|
+
const res = await fetch(url, { method: 'HEAD', signal: AbortSignal.timeout(4000) });
|
|
3904
|
+
// 204 is the ONE unambiguous "nothing here" — the route collapses both kinds of absence into it
|
|
3905
|
+
// after its own app/project mismatch check. EVERYTHING else fails open, including a body that
|
|
3906
|
+
// would not parse: a truncated or malformed 200 means the probe failed, not that the model is
|
|
3907
|
+
// gone, and reading that as absence would disable Approve on a real project.
|
|
3908
|
+
return res.status !== 204;
|
|
3909
|
+
} catch {
|
|
3910
|
+
// Fail OPEN, deliberately. A network blip must not repaint a real project's History as "nothing
|
|
3911
|
+
// here yet — go read a drawing", which is a lie about the user's work and hides the Approve they
|
|
3912
|
+
// were about to click. The cost of the other direction is the pre-existing behaviour: Approve is
|
|
3913
|
+
// offered, and if there is genuinely nothing it answers 404 exactly as it does today.
|
|
3914
|
+
return true;
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
|
|
3530
3918
|
async function renderExports(restoreKind) {
|
|
3531
3919
|
if (!current) return;
|
|
3532
3920
|
const id = current.id, app = current.app;
|
|
@@ -3537,7 +3925,18 @@
|
|
|
3537
3925
|
? Object.fromEntries(SEND_HOSTS.map((h) => [h.host, { ok: false, state: 'checking' }]))
|
|
3538
3926
|
: {};
|
|
3539
3927
|
renderReadinessState = hasRender ? { ok: false, state: 'checking' } : null;
|
|
3928
|
+
// WHAT WAS PAINTED, not what the flag says. The header's probe can settle between this paint and
|
|
3929
|
+
// ours and move the flag WITHOUT repainting this pane — comparing to the flag then finds them
|
|
3930
|
+
// equal, skips the repaint, and leaves the gate drawn with the old value. That is #490 reproduced
|
|
3931
|
+
// inside the pane this fix is for, reachable by opening an empty project and clicking Exports
|
|
3932
|
+
// while the open-time probe is still in flight.
|
|
3933
|
+
const paintedWith = exportsHasModel;
|
|
3540
3934
|
paintExports(current.approvedAt, restoreKind);
|
|
3935
|
+
const gen = ++modelPresenceGen;
|
|
3936
|
+
const modelPresent = await projectHasContract(id, app);
|
|
3937
|
+
if (gen !== modelPresenceGen || !current || current.id !== id || $wsExports.hidden) return;
|
|
3938
|
+
applyModelPresence(modelPresent);
|
|
3939
|
+
if (modelPresent !== paintedWith) paintExports(current.approvedAt, restoreKind);
|
|
3541
3940
|
let state = null;
|
|
3542
3941
|
let approvedAt = current.approvedAt; // fallback if the fetch fails (best-known)
|
|
3543
3942
|
const exportPromise = api(`/api/contract/${encodeURIComponent(app)}/exports?project=${encodeURIComponent(id)}`);
|
|
@@ -3612,6 +4011,15 @@
|
|
|
3612
4011
|
// The Render card is the only one that asks anything before it runs, so the options are
|
|
3613
4012
|
// collected BEFORE the busy state — marking the card "Rendering…" while a dialog is still open
|
|
3614
4013
|
// would be a lie about what the machine is doing.
|
|
4014
|
+
let bomOptions = null;
|
|
4015
|
+
if (kind === 'bom') {
|
|
4016
|
+
bomOptions = await askBomOptions(projectId);
|
|
4017
|
+
if (!bomOptions) return; // cancelled or refused — nothing started, so nothing to unwind
|
|
4018
|
+
// The dialog is awaited, so the project can move under us; everything below keys off the
|
|
4019
|
+
// captured ids, and bailing here keeps the request from being aimed somewhere else.
|
|
4020
|
+
if (!current || current.id !== projectId) return;
|
|
4021
|
+
}
|
|
4022
|
+
|
|
3615
4023
|
let renderOptions = null;
|
|
3616
4024
|
if (kind === 'render') {
|
|
3617
4025
|
renderOptions = await askRenderOptions(projectId);
|
|
@@ -3698,10 +4106,38 @@
|
|
|
3698
4106
|
// paint a stale intermediate state over it.
|
|
3699
4107
|
let refreshing = false;
|
|
3700
4108
|
try {
|
|
3701
|
-
// Render
|
|
3702
|
-
const
|
|
3703
|
-
|
|
4109
|
+
// Render and the BOM are the exports whose POST carries a body — the options their modal collected.
|
|
4110
|
+
const body = renderOptions || bomOptions;
|
|
4111
|
+
const res = await api(exportUrl(kind, projectId, app), body
|
|
4112
|
+
? { method: 'POST', body: JSON.stringify(body), headers: { 'content-type': 'application/json' } }
|
|
3704
4113
|
: { method: 'POST' });
|
|
4114
|
+
if (kind === 'bom') {
|
|
4115
|
+
// The batch answers per format. A 200 here means SOMETHING landed, not that everything did —
|
|
4116
|
+
// so the toast names what failed rather than letting a green tick stand for a partial run, and
|
|
4117
|
+
// the files that did land are already on the card.
|
|
4118
|
+
const results = Array.isArray(res.results) ? res.results : [];
|
|
4119
|
+
const ok = results.filter((r) => r && r.ok);
|
|
4120
|
+
const failed = results.filter((r) => r && !r.ok);
|
|
4121
|
+
const nameOf = (f) => (BOM_FORMATS.find((x) => x.value === f) || {}).label || f;
|
|
4122
|
+
if (failed.length) {
|
|
4123
|
+
showToast(
|
|
4124
|
+
`${ok.length} of ${results.length} exported — ${failed.map((r) => nameOf(r.format)).join(', ')} failed: `
|
|
4125
|
+
+ (failed[0].error || 'no reason given'),
|
|
4126
|
+
'warn');
|
|
4127
|
+
} else {
|
|
4128
|
+
showToast(`Exported — ${ok.map((r) => nameOf(r.format)).join(', ')}`, 'ok');
|
|
4129
|
+
}
|
|
4130
|
+
// Per FORMAT, so the analytics keep the granularity the two separate cards used to give.
|
|
4131
|
+
for (const r of ok) track('workspace_export', { app, kind: `bom-${r.format}` });
|
|
4132
|
+
// Set BEFORE handing off, exactly as the shared success path does: the `finally` below runs
|
|
4133
|
+
// while this refresh is still in flight and would otherwise paint the pre-refresh state over
|
|
4134
|
+
// it — the card reading "not exported yet" for a second after a successful export.
|
|
4135
|
+
refreshing = true;
|
|
4136
|
+
return renderExports().catch((refreshErr) => {
|
|
4137
|
+
console.warn('exports refresh failed after a BOM export', refreshErr);
|
|
4138
|
+
if (current && current.id === projectId) paintExports(current.approvedAt);
|
|
4139
|
+
});
|
|
4140
|
+
}
|
|
3705
4141
|
track('workspace_export', { app, kind }); // a successful export/bake (e.g. { app:'vectorize', kind:'svg' })
|
|
3706
4142
|
if (res.counts) exportReceipts.set(`${projectId}:${kind}`, {
|
|
3707
4143
|
counts: res.counts,
|
|
@@ -3925,6 +4361,8 @@
|
|
|
3925
4361
|
|
|
3926
4362
|
$wsExports.addEventListener('click', (e) => {
|
|
3927
4363
|
if (e.target.closest('#ws-exports-approve')) { approveProject(); return; }
|
|
4364
|
+
// The no-model gate's real next step — mirrors History's #hist-go-drawings.
|
|
4365
|
+
if (e.target.closest('#ws-exports-go-drawings')) { setStep('drawings'); return; }
|
|
3928
4366
|
if (e.target.closest('[data-open-exports-folder]')) { openExportsFolder(); return; }
|
|
3929
4367
|
const details = e.target.closest('[data-export-details]');
|
|
3930
4368
|
if (details) { showExportReceiptDetails(details.dataset.exportDetails, details); return; }
|
|
@@ -4101,6 +4539,11 @@
|
|
|
4101
4539
|
const tip = (vr.versions || [])[0];
|
|
4102
4540
|
if (tip && tip.kind === 'revision-read' && tip.n > revBaseVersion) {
|
|
4103
4541
|
current.approvedAt = vr.approvedAt || undefined; // the AI read cleared the sign-off (exports re-lock)
|
|
4542
|
+
// A model may have just come into existence, and the repaints below fire only for the VISIBLE
|
|
4543
|
+
// pane — which on the drop-a-drawing flow is Drawings, neither of them. Without this the header
|
|
4544
|
+
// stays gated, telling the user to read a drawing they just finished reading. (approveProject
|
|
4545
|
+
// re-probes so the ACTION is never blocked; this stops the chrome lying in the meantime.)
|
|
4546
|
+
refreshModelPresence(current.id, current.app).catch(() => { /* header stays as-is */ });
|
|
4104
4547
|
if (!$wsHistory.hidden) renderHistory();
|
|
4105
4548
|
// …and the Exports pane, if it is the one showing. "Exports re-lock" was the intent, but
|
|
4106
4549
|
// nothing repainted them: the pane kept its live buttons and its per-destination Details
|
|
@@ -4953,6 +5396,143 @@
|
|
|
4953
5396
|
}
|
|
4954
5397
|
|
|
4955
5398
|
/** One tickable decision. `idx` indexes the decision list, which is what the progress count walks. */
|
|
5399
|
+
/**
|
|
5400
|
+
* Group decisions that are the SAME decision reported many times (#493).
|
|
5401
|
+
*
|
|
5402
|
+
* On a real read this is the difference between a usable gate and an unreachable one: a 218-member
|
|
5403
|
+
* model produced 260 decisions, 230 of them carrying one identical sentence — sheet S-203 declares
|
|
5404
|
+
* no `default_tos`, restated once per member end. Those are not 230 judgements. They are one fact,
|
|
5405
|
+
* and ticking it 230 times cannot inform the decision that is actually being made.
|
|
5406
|
+
*
|
|
5407
|
+
* THE KEY IS EXACT (code, message) EQUALITY, and that is the safety property rather than a
|
|
5408
|
+
* convenience. A `dedup-merge-proposed` row always names its own survivor and retired members in its
|
|
5409
|
+
* message, so two of them can never collide — the key structurally cannot sweep up a decision whose
|
|
5410
|
+
* instances differ, which is what keeps this a collapse of duplicates and not a bulk-accept in
|
|
5411
|
+
* disguise. (The "Needs your decision" bucket still renders NO bulk bar; that rule is untouched.)
|
|
5412
|
+
*
|
|
5413
|
+
* Runs are built in list order, so the rows stay in the order the reader would otherwise have met
|
|
5414
|
+
* them.
|
|
5415
|
+
*/
|
|
5416
|
+
/**
|
|
5417
|
+
* The decisions a fan-out row may collapse — and NOTHING ELSE MAY.
|
|
5418
|
+
*
|
|
5419
|
+
* DEFAULT-DENY, for the same reason `BULKABLE_DECISIONS` and `MIGRATE_TOPIC` are: a collapsed row is
|
|
5420
|
+
* one confirmation standing for many, which is the act epic §8 restricts, so eligibility has to be
|
|
5421
|
+
* granted deliberately rather than inherited by any code whose sentence happens to repeat. The first
|
|
5422
|
+
* cut keyed purely on (code, message) and was opt-out — review proved that reintroduced a bulk accept
|
|
5423
|
+
* by exactly the route the sibling tables were written to prevent.
|
|
5424
|
+
*
|
|
5425
|
+
* THE TEST IS THE SAME ONE `BULKABLE_DECISIONS` applies, one level down: is the repeated sentence a
|
|
5426
|
+
* statement about a SHEET (or the document) that the migrator restates per item, or a finding about
|
|
5427
|
+
* each particular item? `elevation-default-missing` is the first: it says sheet X declares no
|
|
5428
|
+
* `default_tos`, and every end that follows that sheet default gets the identical sentence. Resolving
|
|
5429
|
+
* it means giving sheet X a default — one act, whatever the fan-out.
|
|
5430
|
+
*
|
|
5431
|
+
* `col-metadata-unassigned` is the counter-example and the reason this list exists. Its message names
|
|
5432
|
+
* only the column mark ("column \"C1\" carries col-level note …"), so two DIFFERENT columns sharing a
|
|
5433
|
+
* mark across two sheets produce the identical sentence — and its question ("assign it to an end,
|
|
5434
|
+
* both ends, or the member") genuinely can be answered differently for each. Under the opt-out key
|
|
5435
|
+
* they collapsed into one row, titled with only the first sheet. Measured by review, not reasoned.
|
|
5436
|
+
*/
|
|
5437
|
+
const FANOUT_ELIGIBLE = new Set(['elevation-default-missing']);
|
|
5438
|
+
|
|
5439
|
+
function byIdenticalCause(list) {
|
|
5440
|
+
const runs = new Map();
|
|
5441
|
+
for (const d of list) {
|
|
5442
|
+
// `sheet` IS PART OF THE KEY, even though the eligible code names its sheet in the message. The
|
|
5443
|
+
// server's own `decisionsDigest` keys a decision on [code, sheet, path, message], so dropping a
|
|
5444
|
+
// field it treats as identity is how the two disagree about what "the same decision" means.
|
|
5445
|
+
// `path` is the axis a fan-out is meant to collapse, so it — and only it — is left out.
|
|
5446
|
+
//
|
|
5447
|
+
// JSON.stringify of the tuple, not a delimiter-joined string: a separator has to be a character
|
|
5448
|
+
// the fields cannot contain, and choosing one invisibly is how a raw NUL ended up in this source
|
|
5449
|
+
// on the first cut. Encoding the tuple needs no reserved character at all.
|
|
5450
|
+
//
|
|
5451
|
+
// An INELIGIBLE code is keyed by identity, so it can never share a run with anything.
|
|
5452
|
+
const key = FANOUT_ELIGIBLE.has(d.code)
|
|
5453
|
+
? JSON.stringify([d.code, d.sheet ?? null, d.message || ''])
|
|
5454
|
+
: JSON.stringify(['@solo', runs.size, d.code]);
|
|
5455
|
+
if (!runs.has(key)) runs.set(key, []);
|
|
5456
|
+
runs.get(key).push(d);
|
|
5457
|
+
}
|
|
5458
|
+
return [...runs.values()];
|
|
5459
|
+
}
|
|
5460
|
+
|
|
5461
|
+
/**
|
|
5462
|
+
* One row standing for N identical decisions, with the individual items disclosed behind an
|
|
5463
|
+
* expander. One real checkbox, so `syncMigrateProgress`'s `boxes.length` counts DECISIONS — which is
|
|
5464
|
+
* what "0 of 4 confirmed" should have meant all along.
|
|
5465
|
+
*
|
|
5466
|
+
* Honest by construction: the count is on the row face (not hidden in a tooltip), the expander
|
|
5467
|
+
* offers the evidence proactively rather than asking to be trusted, the badge stays "Decide", and
|
|
5468
|
+
* the message is the server's own sentence shown once, verbatim.
|
|
5469
|
+
*
|
|
5470
|
+
* Safe because the commit does not depend on these boxes. `confirmMigrate` sends
|
|
5471
|
+
* `acknowledgeDecisions: report.decisionsDigest` — a digest the SERVER computed over the whole
|
|
5472
|
+
* decision set at preview time — so the ticking is a client-side "prove you read them" gate and
|
|
5473
|
+
* collapsing rows cannot weaken the precondition. Verified against the route before building this.
|
|
5474
|
+
*/
|
|
5475
|
+
function migFanoutRow(run, idx) {
|
|
5476
|
+
const first = run[0];
|
|
5477
|
+
const row = revEl('div', 'rev-row k-changed');
|
|
5478
|
+
const id = `mig-dec-${idx}`;
|
|
5479
|
+
const label = revEl('label', 'rev-check');
|
|
5480
|
+
const box = document.createElement('input');
|
|
5481
|
+
box.type = 'checkbox';
|
|
5482
|
+
box.dataset.migidx = String(idx);
|
|
5483
|
+
box.dataset.migcode = first.code;
|
|
5484
|
+
box.dataset.migfanout = String(run.length); // read by syncMigrateProgress for the "ends affected" line
|
|
5485
|
+
// The scope belongs in the ACCESSIBLE NAME, not only in the visible count — a screen-reader user
|
|
5486
|
+
// must hear what they are confirming before they tick it, not after.
|
|
5487
|
+
box.setAttribute('aria-label', `Confirm this decision for all ${run.length} affected items`);
|
|
5488
|
+
box.setAttribute('aria-describedby', `${id}-msg`);
|
|
5489
|
+
label.appendChild(box);
|
|
5490
|
+
|
|
5491
|
+
const main = revEl('div', 'rev-row-main');
|
|
5492
|
+
const head = revEl('div', 'rev-row-head');
|
|
5493
|
+
head.appendChild(revEl('span', 'rev-kind-badge', 'Decide'));
|
|
5494
|
+
// The shared ROOT CAUSE names the row — there is no single member to name, and naming one of the
|
|
5495
|
+
// 230 would be worse than naming none.
|
|
5496
|
+
const title = revEl('span', 'rev-row-title', first.sheet || first.path || migTopic(first.code));
|
|
5497
|
+
title.id = `${id}-title`;
|
|
5498
|
+
head.appendChild(title);
|
|
5499
|
+
head.appendChild(revEl('span', 'ws-archived-count', String(run.length)));
|
|
5500
|
+
main.appendChild(head);
|
|
5501
|
+
|
|
5502
|
+
const msg = revEl('div', 'rev-row-note', first.message || first.code);
|
|
5503
|
+
msg.id = `${id}-msg`;
|
|
5504
|
+
main.appendChild(msg);
|
|
5505
|
+
|
|
5506
|
+
// SAY WHAT THE TICK COVERS, in the visible row and not only in the accessible name. The count
|
|
5507
|
+
// badge above states the scale; this states the CONSEQUENCE, which is the part someone consenting
|
|
5508
|
+
// needs. Without it the row reads as one decision that happens to mention a number.
|
|
5509
|
+
main.appendChild(revEl('div', 'mig-fanout-scope',
|
|
5510
|
+
`Confirming this row confirms it for all ${run.length}.`));
|
|
5511
|
+
|
|
5512
|
+
// CLOSED by default — never auto-open a 230-item list next to sibling rows the user must also see.
|
|
5513
|
+
const det = document.createElement('details');
|
|
5514
|
+
det.className = 'mig-fanout';
|
|
5515
|
+
const sum = document.createElement('summary');
|
|
5516
|
+
sum.className = 'mig-fanout-summary';
|
|
5517
|
+
sum.setAttribute('data-tip', 'See exactly which items this covers');
|
|
5518
|
+
sum.appendChild(revEl('span', 'ws-archived-caret', '›'));
|
|
5519
|
+
sum.appendChild(document.createTextNode(`Show all ${run.length} affected items`));
|
|
5520
|
+
det.appendChild(sum);
|
|
5521
|
+
const listEl = revEl('div', 'mig-fanout-list');
|
|
5522
|
+
for (const d of run) {
|
|
5523
|
+
// Read-only evidence, not 230 more checkboxes: the commit is digest-based, so per-item ticks
|
|
5524
|
+
// would imply a granularity the server cannot honour.
|
|
5525
|
+
listEl.appendChild(revEl('span', 'mig-fanout-item',
|
|
5526
|
+
[d.sheet, d.path, d.id].filter(Boolean).join(' · ') || d.code));
|
|
5527
|
+
}
|
|
5528
|
+
det.appendChild(listEl);
|
|
5529
|
+
main.appendChild(det);
|
|
5530
|
+
|
|
5531
|
+
row.appendChild(label);
|
|
5532
|
+
row.appendChild(main);
|
|
5533
|
+
return row;
|
|
5534
|
+
}
|
|
5535
|
+
|
|
4956
5536
|
function migDecisionRow(issue, idx, proposal) {
|
|
4957
5537
|
const row = revEl('div', 'rev-row k-changed');
|
|
4958
5538
|
const id = `mig-dec-${idx}`;
|
|
@@ -5090,11 +5670,21 @@
|
|
|
5090
5670
|
};
|
|
5091
5671
|
if (choices.length) {
|
|
5092
5672
|
body.appendChild(section('Needs your decision',
|
|
5093
|
-
'each of these could have gone another way — take them one at a time'
|
|
5673
|
+
'each of these could have gone another way — take them one at a time; '
|
|
5674
|
+
+ 'some apply to many parts of the model at once'));
|
|
5094
5675
|
for (const [topic, list] of byTopic(choices)) {
|
|
5676
|
+
const runs = byIdenticalCause(list);
|
|
5677
|
+
// THE HEADER COUNTS DECISIONS, matching the rows beneath it and the progress line. Passing the
|
|
5678
|
+
// raw instance count made the same unlabelled number mean two different things on one screen —
|
|
5679
|
+
// a topic would read "230" over a single row that the progress line counted as one. The
|
|
5680
|
+
// fan-out is stated on the row that owns it, which is the only place it means something.
|
|
5095
5681
|
// `null` bucket → `group` renders no bulk bar. The absence IS the rule, not an oversight.
|
|
5096
|
-
const g = group(topic,
|
|
5097
|
-
for (const
|
|
5682
|
+
const g = group(topic, runs.length, null);
|
|
5683
|
+
for (const run of runs) {
|
|
5684
|
+
g.appendChild(run.length === 1
|
|
5685
|
+
? migDecisionRow(run[0], idxOf.get(run[0]), proposalFor(run[0]))
|
|
5686
|
+
: migFanoutRow(run, idxOf.get(run[0])));
|
|
5687
|
+
}
|
|
5098
5688
|
body.appendChild(g);
|
|
5099
5689
|
}
|
|
5100
5690
|
}
|
|
@@ -5140,11 +5730,18 @@
|
|
|
5140
5730
|
const boxes = [...$migBody.querySelectorAll('input[type="checkbox"][data-migidx]')];
|
|
5141
5731
|
const done = boxes.filter((b) => b.checked).length;
|
|
5142
5732
|
const left = boxes.length - done;
|
|
5733
|
+
// A collapsed row stands for many items (#493), so the count of BOXES is the count of decisions
|
|
5734
|
+
// while the count of ITEMS is what the reader is actually agreeing about. State both, and only
|
|
5735
|
+
// when they differ — on a model with no fan-out the parenthetical would be noise.
|
|
5736
|
+
const items = boxes.reduce((n, b) => n + (Number(b.dataset.migfanout) || 1), 0);
|
|
5737
|
+
const fannedOut = items > boxes.length;
|
|
5143
5738
|
if (!boxes.length) { $migProgress.hidden = true; }
|
|
5144
5739
|
else {
|
|
5145
5740
|
$migProgress.replaceChildren();
|
|
5146
5741
|
$migProgress.appendChild(revEl('b', null, String(done)));
|
|
5147
|
-
$migProgress.appendChild(document.createTextNode(
|
|
5742
|
+
$migProgress.appendChild(document.createTextNode(
|
|
5743
|
+
` of ${boxes.length} decision${boxes.length === 1 ? '' : 's'} confirmed`));
|
|
5744
|
+
if (fannedOut) $migProgress.appendChild(document.createTextNode(` (${items} items affected)`));
|
|
5148
5745
|
if (left) $migProgress.appendChild(document.createTextNode(` — ${left} still to go.`));
|
|
5149
5746
|
$migProgress.hidden = false;
|
|
5150
5747
|
}
|
|
@@ -5152,7 +5749,8 @@
|
|
|
5152
5749
|
$migConfirm.setAttribute('aria-disabled', String(!ready));
|
|
5153
5750
|
$migConfirm.setAttribute('data-tip', ready
|
|
5154
5751
|
? 'Convert this project — a new version is recorded'
|
|
5155
|
-
: `Confirm all ${boxes.length}
|
|
5752
|
+
: `Confirm all ${boxes.length} decision${boxes.length === 1 ? '' : 's'} before converting`
|
|
5753
|
+
+ `${fannedOut ? ` (covers ${items} items)` : ''} — ${left} left`);
|
|
5156
5754
|
}
|
|
5157
5755
|
|
|
5158
5756
|
function closeMigrate() {
|
|
@@ -5483,9 +6081,42 @@
|
|
|
5483
6081
|
versions = rows;
|
|
5484
6082
|
if (!rows.length) {
|
|
5485
6083
|
// Empty = an inline-action banner (never a bare header row that reads as broken/loading).
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
6084
|
+
//
|
|
6085
|
+
// TWO empty states, because "no versions" has two causes and only one of them is Approve's.
|
|
6086
|
+
// With a model present, Approve genuinely is the next step and creates v1. With NO model the
|
|
6087
|
+
// approve route 404s — so offering it made the screen's most prominent control the only one that
|
|
6088
|
+
// lied, while every export button beside it was correctly gated. The honest next step there is a
|
|
6089
|
+
// different action on a different step, so Approve is REMOVED rather than disabled: the same
|
|
6090
|
+
// reasoning `migRefusal` records for rendering no Confirm at all — an inert primary button reads
|
|
6091
|
+
// as an invitation to find the way around it, and here there is nothing to get around.
|
|
6092
|
+
//
|
|
6093
|
+
// stepLabel('drawings'), never the literal word: the step key is shared but its LABEL is per-app
|
|
6094
|
+
// ("Drawings" on steel-model, "Source" on vectorize), so hardcoding it would ship a new
|
|
6095
|
+
// wrong-word bug on the other workspace app in a change about correctness.
|
|
6096
|
+
//
|
|
6097
|
+
// Built with DOM methods rather than innerHTML — the label comes from a descriptor, so it is the
|
|
6098
|
+
// same "don't route it through a string template at all" rule `importFailedCmdRow` follows.
|
|
6099
|
+
const gen = ++modelPresenceGen;
|
|
6100
|
+
const hasModel = await projectHasContract(id, current.app);
|
|
6101
|
+
if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden) return;
|
|
6102
|
+
applyModelPresence(hasModel); // one answer, every surface — History used to keep its own
|
|
6103
|
+
const empty = document.createElement('div');
|
|
6104
|
+
empty.className = 'hist-empty';
|
|
6105
|
+
const btn = document.createElement('button');
|
|
6106
|
+
btn.type = 'button';
|
|
6107
|
+
if (hasModel) {
|
|
6108
|
+
btn.id = 'hist-approve';
|
|
6109
|
+
btn.textContent = 'Approve this version';
|
|
6110
|
+
empty.append('No versions yet — ', btn, ' to create ');
|
|
6111
|
+
const v1 = document.createElement('b');
|
|
6112
|
+
v1.textContent = 'v1';
|
|
6113
|
+
empty.append(v1, ' and start the ledger.');
|
|
6114
|
+
} else {
|
|
6115
|
+
btn.id = 'hist-go-drawings';
|
|
6116
|
+
btn.textContent = `Go to ${stepLabel('drawings')}`;
|
|
6117
|
+
empty.append('Nothing here yet — ', btn, ' to get started.');
|
|
6118
|
+
}
|
|
6119
|
+
$wsHistory.replaceChildren(empty);
|
|
5489
6120
|
return;
|
|
5490
6121
|
}
|
|
5491
6122
|
// Working copy = the draft; when it isn't signed off (approvedAt cleared by an edit or a
|
|
@@ -5947,6 +6578,9 @@
|
|
|
5947
6578
|
|
|
5948
6579
|
$wsHistory.addEventListener('click', (e) => {
|
|
5949
6580
|
if (e.target.closest('#hist-approve')) { approveProject(); return; }
|
|
6581
|
+
// The no-model empty state's real next step: go read a drawing. Same handler shape as the
|
|
6582
|
+
// Approve it replaces, so the pane keeps owning its own inline actions.
|
|
6583
|
+
if (e.target.closest('#hist-go-drawings')) { setStep('drawings'); return; }
|
|
5950
6584
|
if (e.target.closest('.hc-cancel')) { closeRollbackConfirm(); return; }
|
|
5951
6585
|
const go = e.target.closest('[data-hc-go]');
|
|
5952
6586
|
if (go) { rollbackTo(Number(go.dataset.hcGo)); return; }
|