@floless/app 0.149.1 → 0.151.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 +104263 -88361
- package/dist/schemas/drawing-check.profile.v1.schema.json +45 -2
- package/dist/schemas/steel.model.v2.schema.json +9 -0
- package/dist/skills/floless-app-approval/SKILL.md +79 -4
- package/dist/skills/floless-app-onboarding/SKILL.md +200 -87
- package/dist/skills/floless-app-onboarding/references/aware-runtime.md +27 -18
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +207 -0
- package/dist/skills/floless-app-routines/SKILL.md +4 -1
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +4 -2
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +14 -9
- package/dist/skills/floless-app-workflows/SKILL.md +2 -2
- package/dist/templates/tekla-parser.flo +13 -3
- package/dist/web/agents.js +983 -0
- package/dist/web/app.css +556 -43
- package/dist/web/app.js +34 -112
- package/dist/web/aware.js +1774 -169
- package/dist/web/chat.css +62 -1
- package/dist/web/chat.js +1666 -59
- package/dist/web/commands-drawing-check.js +15 -0
- package/dist/web/commands-revit.js +5 -0
- package/dist/web/commands-shell.js +955 -53
- package/dist/web/commands-tekla-parser.js +8 -1
- package/dist/web/connections.js +57 -14
- package/dist/web/drawing-check-editor.html +10 -2
- package/dist/web/drawing-check-editor.js +569 -40
- package/dist/web/drawing-check-overlay.js +45 -2
- package/dist/web/guide.js +675 -0
- package/dist/web/index.html +162 -31
- package/dist/web/instructor.js +91 -8
- package/dist/web/leave-guard.js +1 -0
- package/dist/web/left-pane.js +20 -1
- package/dist/web/local-discovery.js +12 -2
- package/dist/web/model-editor.css +32 -32
- package/dist/web/model-panel-bridge.js +11 -3
- package/dist/web/model-viewport-lighting.js +4 -2
- package/dist/web/model-viewport-revit-adapter.js +3 -0
- package/dist/web/model-viewport-toolbar.js +6 -3
- package/dist/web/model-viewport.js +11 -1
- package/dist/web/revit-editor.css +14 -14
- package/dist/web/revit-editor.js +64 -12
- package/dist/web/steel-3d-core.js +133 -0
- package/dist/web/steel-3d-view.js +10 -0
- package/dist/web/steel-editor.html +171 -39
- package/dist/web/steel-model-v2-client-validation.js +11 -0
- package/dist/web/steel-model-v2-commands.js +80 -5
- package/dist/web/tool-updates.js +533 -0
- package/dist/web/workspaces.js +896 -123
- package/package.json +2 -2
- package/dist/skills/floless-app-onboarding/references/floless-app-tour.md +0 -156
package/dist/web/workspaces.js
CHANGED
|
@@ -280,6 +280,9 @@
|
|
|
280
280
|
// mode — and the markup stays the one place that sentence is written.
|
|
281
281
|
const WORKSPACE_TAB_TIP = $workspaceTab?.getAttribute('data-tip') || '';
|
|
282
282
|
const $landing = document.getElementById('ws-landing');
|
|
283
|
+
// The landing search's query. Kept here, not only in the input, because renderLanding() rebuilds the
|
|
284
|
+
// whole landing with innerHTML on background refreshes; applyMode() empties it on each fresh visit.
|
|
285
|
+
let landingQuery = '';
|
|
283
286
|
const $project = document.getElementById('ws-project');
|
|
284
287
|
const $spine = document.getElementById('ws-spine');
|
|
285
288
|
const $projName = document.getElementById('ws-proj-name');
|
|
@@ -517,15 +520,18 @@
|
|
|
517
520
|
});
|
|
518
521
|
}
|
|
519
522
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
if (!file) return null;
|
|
523
|
+
// One ZIP of a Tekla model as a source — shared by the ZIP picker and a ZIP dropped on the card.
|
|
524
|
+
function teklaZipSource(file) {
|
|
523
525
|
if (!/\.zip$/i.test(file.name) || file.size > 1024 * 1024 * 1024) throw new Error('Choose one Tekla model ZIP up to 1 GB.');
|
|
524
526
|
return { label: file.name, kind: 'zip', entries: [{ path: file.name, file }] };
|
|
525
527
|
}
|
|
528
|
+
async function pickTeklaZip(fallbackInput) {
|
|
529
|
+
const file = await pickZipFile(fallbackInput);
|
|
530
|
+
return file ? teklaZipSource(file) : null;
|
|
531
|
+
}
|
|
526
532
|
|
|
527
533
|
// Single-image picker for Add/Replace thumbnail — same File System Access preference + hidden-input
|
|
528
|
-
// fallback as
|
|
534
|
+
// fallback as pickDrawingFiles and pickZipFile. Returns null on cancel; rethrows anything but a cancel.
|
|
529
535
|
const THUMB_FILE_TYPES = [{
|
|
530
536
|
description: 'Image',
|
|
531
537
|
accept: { 'image/*': ['.png', '.jpg', '.jpeg', '.webp', '.gif', '.bmp'] },
|
|
@@ -668,8 +674,8 @@
|
|
|
668
674
|
|
|
669
675
|
const LS_MODE = 'floless:mode';
|
|
670
676
|
// Per-app Workspaces presentation. The flag (floless.workspace, surfaced on /api/apps) says WHICH
|
|
671
|
-
// apps are workspaces; this map says HOW to render each (presentation is ours — spec §3.2).
|
|
672
|
-
// first-party
|
|
677
|
+
// apps are workspaces; this map says HOW to render each (presentation is ours — spec §3.2). All
|
|
678
|
+
// first-party today; promote to a .flo-declared descriptor when a user-authored one appears.
|
|
673
679
|
// NB: both apps keep the SAME data-step keys (drawings/model/exports/history) so setStep() and the
|
|
674
680
|
// frame slots are unchanged — only the first two LABELS and which HTML each frame loads differ.
|
|
675
681
|
//
|
|
@@ -677,8 +683,17 @@
|
|
|
677
683
|
// "✓ exported HH:MM" line + ⧉ Open / ▤ Reveal); `open:false` (IFC) = reveal-only (no OS default app
|
|
678
684
|
// for a .ifc). Tekla is an ACTION (host mutation, no file). `kind` matches the server's export route
|
|
679
685
|
// + listing (projectExportFiles). renderExports()/exportUrl() read wsApp().exports — never a global.
|
|
686
|
+
//
|
|
687
|
+
// `cardIcon`: the create card's mark — the INNER markup of a 24×24 outline drawing, which
|
|
688
|
+
// workspaceCreateCardHtml wraps in an <svg> and inserts unescaped (authored here, never user data).
|
|
689
|
+
// Each one says what the card makes, never whose product it reads: no vendor logo for Revit/Tekla.
|
|
690
|
+
// On a create action, `dropHint` is the line telling the person the card also takes a dropped file
|
|
691
|
+
// (shown only for a kind workspaceCreateCardHtml treats as a dropzone); `dropWarn` is what a READY
|
|
692
|
+
// card that takes no file says when one is dropped on it. Locked and setting-up cards answer with
|
|
693
|
+
// their own sentence instead (cardDropWarning).
|
|
680
694
|
const WORKSPACE_APPS = {
|
|
681
695
|
'steel-model': {
|
|
696
|
+
cardIcon: '<path d="M3 8.5h10v3H9.5v6H13v3H3v-3h3.5v-6H3z"/><path d="M3 8.5 11 3.5h10l-8 5"/><path d="M21 3.5v3l-8 5"/><path d="M17.5 8.7v3.8"/><path d="M9.5 17.5l8-5H21l-8 5"/><path d="M21 12.5v3l-8 5"/>', // a 3D I-beam
|
|
682
697
|
displayName: 'Steel model',
|
|
683
698
|
projectCapability: 'review, detail, export',
|
|
684
699
|
createActions: [
|
|
@@ -688,6 +703,7 @@
|
|
|
688
703
|
capability: 'PDF or image → 3D steel model',
|
|
689
704
|
sub: 'Turn steel drawings into a 3D model you can review and export.',
|
|
690
705
|
label: 'Pick drawings',
|
|
706
|
+
dropHint: 'Click or drop drawings',
|
|
691
707
|
},
|
|
692
708
|
],
|
|
693
709
|
editor: '/steel-editor.html',
|
|
@@ -726,6 +742,7 @@
|
|
|
726
742
|
],
|
|
727
743
|
},
|
|
728
744
|
vectorize: {
|
|
745
|
+
cardIcon: '<path d="M5 16C8 6 16 6 19 16"/><rect x="3.25" y="16" width="3.5" height="3.5" rx=".5"/><rect x="17.25" y="16" width="3.5" height="3.5" rx=".5"/><rect x="10.5" y="7" width="3" height="3" rx=".5"/><path d="M6.5 8.5h4M13.5 8.5h4"/><circle cx="5" cy="8.5" r="1.5"/><circle cx="19" cy="8.5" r="1.5"/>', // a curve with anchors and handles
|
|
729
746
|
displayName: 'Trace',
|
|
730
747
|
projectCapability: 'editable 2D drawing',
|
|
731
748
|
docGuide: true,
|
|
@@ -736,6 +753,7 @@
|
|
|
736
753
|
capability: 'Drawing → editable shapes',
|
|
737
754
|
sub: 'Turn one drawing into editable lines and shapes.',
|
|
738
755
|
label: 'Pick drawing',
|
|
756
|
+
dropHint: 'Click or drop a drawing',
|
|
739
757
|
},
|
|
740
758
|
],
|
|
741
759
|
editor: '/vector-editor.html',
|
|
@@ -757,7 +775,7 @@
|
|
|
757
775
|
// participates in first-paint fallback: /api/apps must positively report the canonical
|
|
758
776
|
// installer-owned workflow plus its coarse access state before this card appears.
|
|
759
777
|
serverAuthorizedOnly: true,
|
|
760
|
-
cardIcon: '
|
|
778
|
+
cardIcon: '<path d="M12 3 20 7 12 11 4 7z"/><path d="M4 7v10l8 4 8-4V7"/><path d="M12 11v10"/><path d="M4 10.3l8 4 8-4M4 13.7l8 4 8-4"/>', // a building model, floor by floor
|
|
761
779
|
displayName: 'Revit Parser',
|
|
762
780
|
projectCapability: 'read-only 3D model',
|
|
763
781
|
readOnlyLabel: 'Read-only',
|
|
@@ -767,6 +785,7 @@
|
|
|
767
785
|
capability: 'Read-only 3D model',
|
|
768
786
|
sub: 'Open an RVT without Revit. Inspect its hierarchy and properties—the source RVT is never changed.',
|
|
769
787
|
label: 'Choose RVT for Revit Parser',
|
|
788
|
+
dropHint: 'Click or drop an .rvt',
|
|
770
789
|
}],
|
|
771
790
|
editor: '/revit-editor.html',
|
|
772
791
|
filter: null,
|
|
@@ -783,7 +802,7 @@
|
|
|
783
802
|
// Tekla is a family entitlement; this descriptor names only the read-only parser module so
|
|
784
803
|
// future Tekla modules can have their own workflows and product language.
|
|
785
804
|
serverAuthorizedOnly: true,
|
|
786
|
-
cardIcon: '
|
|
805
|
+
cardIcon: '<path d="M5 20V4M19 20V4M5 4h14M5 12h14"/><path d="M5 12l14 8M19 12 5 20"/><path d="M3 20h4M17 20h4"/>', // a braced steel frame
|
|
787
806
|
displayName: 'Tekla Parser',
|
|
788
807
|
projectCapability: 'read-only 3D model',
|
|
789
808
|
readOnlyLabel: 'Read-only',
|
|
@@ -791,8 +810,9 @@
|
|
|
791
810
|
kind: 'tekla-source',
|
|
792
811
|
headline: 'Tekla Parser',
|
|
793
812
|
capability: 'Read-only 3D model',
|
|
794
|
-
sub: 'Open a Tekla model
|
|
813
|
+
sub: 'Open a Tekla model as a reviewable 3D model. Inspect its hierarchy and properties—the source model is never changed.',
|
|
795
814
|
label: 'Choose Tekla model…',
|
|
815
|
+
dropHint: 'Click or drop a folder or .zip',
|
|
796
816
|
}],
|
|
797
817
|
editor: '/tekla-editor.html',
|
|
798
818
|
filter: null,
|
|
@@ -823,9 +843,16 @@
|
|
|
823
843
|
},
|
|
824
844
|
'setup-integrity-failure': {
|
|
825
845
|
status: 'Setup could not be verified',
|
|
826
|
-
body: 'FloLess could not verify
|
|
846
|
+
body: 'FloLess could not verify this Tekla Parser setup, so it was not used. No model files were changed.',
|
|
827
847
|
action: 'Report issue', aria: 'Tekla Parser setup could not be verified — report issue',
|
|
828
848
|
},
|
|
849
|
+
// The parser files installed with FloLess are missing, damaged or another release's: retrying
|
|
850
|
+
// setup cannot fix that, reinstalling does. One sentence true for every one of those causes.
|
|
851
|
+
'setup-repair-required': {
|
|
852
|
+
status: 'Needs repair',
|
|
853
|
+
body: 'The Tekla Parser files installed with FloLess can’t be used. Reinstall FloLess from floless.io, then check again. Existing projects were not changed.',
|
|
854
|
+
action: 'Check again', aria: 'Tekla Parser needs repair — check again',
|
|
855
|
+
},
|
|
829
856
|
'check-unavailable': {
|
|
830
857
|
status: 'Couldn’t check access', body: 'FloLess couldn’t verify Tekla Parser access. Existing projects were not changed.',
|
|
831
858
|
action: 'Check again', aria: 'Tekla Parser access check unavailable — check again',
|
|
@@ -839,7 +866,7 @@
|
|
|
839
866
|
// it opens straight into its own editor frame, never the read-only source chrome. Every branch
|
|
840
867
|
// that means "Revit or Tekla" therefore says so (isModelSourceProject), not serverAuthorizedOnly.
|
|
841
868
|
serverAuthorizedOnly: true,
|
|
842
|
-
cardIcon: '
|
|
869
|
+
cardIcon: '<rect x="2.5" y="4.5" width="19" height="15" rx="1.5"/><path d="M15 19.5v-4h6.5"/><path d="m6.5 11 2.5 2.5 5-5"/>', // a drawing sheet, checked
|
|
843
870
|
displayName: 'Drawing Checker',
|
|
844
871
|
projectCapability: 'checks shop drawings',
|
|
845
872
|
createActions: [{
|
|
@@ -848,6 +875,8 @@
|
|
|
848
875
|
capability: 'Checks shop drawings',
|
|
849
876
|
sub: 'Make a profile for one client from drawings you already trust.',
|
|
850
877
|
label: 'New client profile…',
|
|
878
|
+
// Takes no file, but a file dropped on it still gets an answer rather than nothing.
|
|
879
|
+
dropWarn: 'Drawing Checker starts from a client profile, not a file, so nothing was uploaded. Click the card to make the profile, then add reference drawings on its page.',
|
|
851
880
|
}],
|
|
852
881
|
editor: '/drawing-check-editor.html',
|
|
853
882
|
filter: null,
|
|
@@ -906,7 +935,10 @@
|
|
|
906
935
|
* case where naming the live workflow on the card tells the user something they don't know. */
|
|
907
936
|
const wsRenamed = (p) => !!(p && p.templateId && p.app && p.app !== p.templateId);
|
|
908
937
|
let mode = 'workflows';
|
|
909
|
-
try {
|
|
938
|
+
try {
|
|
939
|
+
const saved = localStorage.getItem(LS_MODE);
|
|
940
|
+
if (saved === 'workspaces' || saved === 'agents') mode = saved;
|
|
941
|
+
} catch { /* private mode */ }
|
|
910
942
|
let projects = [];
|
|
911
943
|
let projectsLoadError = null; // last /api/projects failure reason, or null — an empty list means
|
|
912
944
|
// "none yet" ONLY when this is null (see the empty state in renderLanding)
|
|
@@ -961,12 +993,18 @@
|
|
|
961
993
|
byRoot.get(root).push(a.id);
|
|
962
994
|
}
|
|
963
995
|
const capabilityByRoot = new Map();
|
|
996
|
+
// The server decides when a "Needs setup" card has a remedy the person can act on (#1965 review);
|
|
997
|
+
// the card only renders that sentence, and only on the state it was written for.
|
|
998
|
+
const remedyByRoot = new Map();
|
|
964
999
|
for (const capability of capabilities || []) {
|
|
965
1000
|
if (!capability || typeof capability.templateId !== 'string'
|
|
966
1001
|
|| capability.appId !== capability.templateId
|
|
967
1002
|
|| WORKSPACE_APPS[capability.templateId]?.serverAuthorizedOnly !== true) continue;
|
|
968
|
-
const known = ['ready', 'access-required', 'account-selection-required', 'setup-provisioning', 'setup-unavailable', 'setup-integrity-failure', 'check-unavailable'];
|
|
1003
|
+
const known = ['ready', 'access-required', 'account-selection-required', 'setup-provisioning', 'setup-unavailable', 'setup-integrity-failure', 'setup-repair-required', 'check-unavailable'];
|
|
969
1004
|
capabilityByRoot.set(capability.templateId, known.includes(capability.status) ? capability.status : 'check-unavailable');
|
|
1005
|
+
if (capability.status === 'setup-unavailable' && typeof capability.setupRemedy === 'string' && capability.setupRemedy.trim()) {
|
|
1006
|
+
remedyByRoot.set(capability.templateId, capability.setupRemedy.trim());
|
|
1007
|
+
}
|
|
970
1008
|
// A capability row exists only after the server positively found the canonical module. Add
|
|
971
1009
|
// its presentation entry even when authorization intentionally filtered it out of `apps`.
|
|
972
1010
|
if (!byRoot.has(capability.templateId)) byRoot.set(capability.templateId, [capability.templateId]);
|
|
@@ -989,11 +1027,13 @@
|
|
|
989
1027
|
// the one the user has not deliberately made a variant of.
|
|
990
1028
|
const ids = byRoot.get(root).slice().sort();
|
|
991
1029
|
const capabilityStatus = capabilityByRoot.get(root);
|
|
1030
|
+
const setupRemedy = remedyByRoot.get(root);
|
|
992
1031
|
return {
|
|
993
1032
|
appId: WORKSPACE_APPS[root]?.serverAuthorizedOnly === true ? root : ids.indexOf(root) >= 0 ? root : ids[0],
|
|
994
1033
|
templateId: root,
|
|
995
1034
|
ambiguous: WORKSPACE_APPS[root]?.serverAuthorizedOnly === true ? false : ids.length > 1,
|
|
996
1035
|
...(capabilityStatus ? { capabilityStatus } : {}),
|
|
1036
|
+
...(setupRemedy ? { setupRemedy } : {}),
|
|
997
1037
|
...(missingCoreRoots.has(root) ? { missing: true } : {}),
|
|
998
1038
|
};
|
|
999
1039
|
});
|
|
@@ -1090,14 +1130,19 @@
|
|
|
1090
1130
|
} else if (s.pendingCount > 0) {
|
|
1091
1131
|
label = s.headVersion ? `Review changes · ${s.pendingCount}` : 'Review & approve';
|
|
1092
1132
|
} else if (s.headVersion) {
|
|
1093
|
-
|
|
1094
|
-
|
|
1133
|
+
// #1840: an approved head that accepted open import findings never reads as a plain "Approved".
|
|
1134
|
+
const accepted = s.review && s.review.approvedHeadImportFindings;
|
|
1135
|
+
label = accepted ? `Approved with findings · v${s.headVersion}` : `Approved · v${s.headVersion}`;
|
|
1136
|
+
tip = accepted && accepted.note ? `${accepted.note} The working copy matches this version.`
|
|
1137
|
+
: 'The working copy matches the latest approved version.';
|
|
1095
1138
|
unavailable = true;
|
|
1096
1139
|
}
|
|
1097
1140
|
$approveBtn.textContent = label;
|
|
1098
1141
|
$approveBtn.setAttribute('aria-disabled', String(unavailable));
|
|
1099
1142
|
$approveBtn.setAttribute('data-tip', tip);
|
|
1100
1143
|
$approveBtn.classList.toggle('approval-clean', s.status === 'ready' && !!s.headVersion && s.pendingCount === 0);
|
|
1144
|
+
$approveBtn.classList.toggle('approval-findings-accepted', s.status === 'ready' && !!s.headVersion && s.pendingCount === 0
|
|
1145
|
+
&& !!(s.review && s.review.approvedHeadImportFindings));
|
|
1101
1146
|
}
|
|
1102
1147
|
|
|
1103
1148
|
/**
|
|
@@ -1309,9 +1354,20 @@
|
|
|
1309
1354
|
}
|
|
1310
1355
|
function applyMode() {
|
|
1311
1356
|
const ws = mode === 'workspaces';
|
|
1357
|
+
// #2007: the third mode. Its surface and the hiding of the workflow canvas are app.css's `mode-agents` rules;
|
|
1358
|
+
// agents.js renders the surface (and reads this class at load, since it loads after this file).
|
|
1359
|
+
const agents = mode === 'agents';
|
|
1360
|
+
$app.classList.toggle('mode-agents', agents);
|
|
1361
|
+
document.body.classList.toggle('mode-agents', agents);
|
|
1362
|
+
document.documentElement.classList.remove('mode-agents-boot');
|
|
1363
|
+
window.flolessAgents?.show(agents);
|
|
1364
|
+
// Coming back to Workflows starts its landing search empty too, as coming back here does (below).
|
|
1365
|
+
if (!ws && $app.classList.contains('mode-workspaces') && bridge.resetWorkflowsLandingSearch) bridge.resetWorkflowsLandingSearch();
|
|
1312
1366
|
$app.classList.toggle('mode-workspaces', ws);
|
|
1313
1367
|
document.body.classList.toggle('mode-workspaces', ws);
|
|
1314
1368
|
document.documentElement.classList.remove('mode-workspaces-boot');
|
|
1369
|
+
// #2007: with both mode classes set, the workflow spotlight closes off Workflows and is offered again on it.
|
|
1370
|
+
if (bridge.syncGuideSpotlight) bridge.syncGuideSpotlight();
|
|
1315
1371
|
// The provenance strip is workflow-level data. Workspaces replaces that surface (including its
|
|
1316
1372
|
// landing), so cancel any late workflow-pin paint before the project UI starts loading.
|
|
1317
1373
|
if (ws && bridge.clearKbInformed) bridge.clearKbInformed();
|
|
@@ -1329,7 +1385,11 @@
|
|
|
1329
1385
|
? 'Back to all projects — leaves this project for the project list.'
|
|
1330
1386
|
: WORKSPACE_TAB_TIP);
|
|
1331
1387
|
}
|
|
1388
|
+
// A fresh visit starts unfiltered, so a project created or opened since is never hidden by an old search.
|
|
1389
|
+
// Cleared on the cards already on screen too, not only for the repaint loadProjects() brings later.
|
|
1390
|
+
const freshVisit = $landing.hidden && ws && !current;
|
|
1332
1391
|
$landing.hidden = !ws || !!current;
|
|
1392
|
+
if (freshVisit) setLandingQuery('');
|
|
1333
1393
|
$project.hidden = !ws || !current;
|
|
1334
1394
|
$spine.hidden = !ws || !current;
|
|
1335
1395
|
if (!ws && !$projMenu.hidden) closeProjMenu();
|
|
@@ -1339,7 +1399,9 @@
|
|
|
1339
1399
|
// the combo isn't even visible in Workspaces mode. Every path that changes the open project
|
|
1340
1400
|
// (open, close, rename → openProject, mode switch, boot) ends here, so the title can't go stale.
|
|
1341
1401
|
if (bridge.setWorkspaceTitle) {
|
|
1342
|
-
|
|
1402
|
+
// #2007: the Agents tab names itself too, and tells Instructor which module is on screen.
|
|
1403
|
+
if (agents) bridge.setWorkspaceTitle('Agents', true, null, 'agents');
|
|
1404
|
+
else bridge.setWorkspaceTitle(workspaceTabSubject(ws, current), ws && !current, ws && current ? current.id : null);
|
|
1343
1405
|
}
|
|
1344
1406
|
// Scope the shared Requests window to the open project, so it stops stacking every other
|
|
1345
1407
|
// project's queued work. Three states, and the landing is NOT the same as Workflows mode:
|
|
@@ -1388,7 +1450,9 @@
|
|
|
1388
1450
|
}
|
|
1389
1451
|
}
|
|
1390
1452
|
async function setMode(m) {
|
|
1391
|
-
const next = m === 'workspaces'
|
|
1453
|
+
const next = m === 'workspaces' || m === 'agents' ? m : 'workflows';
|
|
1454
|
+
// #2007: leaving an agent with unsaved changes asks first (Save / Discard / Stay).
|
|
1455
|
+
if (mode === 'agents' && next !== 'agents' && window.flolessAgents && !(await window.flolessAgents.confirmLeave())) return;
|
|
1392
1456
|
// The still-selected Workspaces tab remains the cancellation path. Re-activating the pending
|
|
1393
1457
|
// Workflows tab would only start another read, supersede the useful one, and extend the wait.
|
|
1394
1458
|
if (next === 'workflows' && $workflowTab?.getAttribute('aria-busy') === 'true') return;
|
|
@@ -1446,6 +1510,8 @@
|
|
|
1446
1510
|
if (!pending && b.dataset.mode === 'workspaces' && mode === 'workspaces' && current) { closeProject(); return; }
|
|
1447
1511
|
// #1890: the active Workflows tab goes home to the Workflows landing, the same way.
|
|
1448
1512
|
if (!pending && b.dataset.mode === 'workflows' && mode === 'workflows' && bridge.showWorkflowsLanding) { bridge.showWorkflowsLanding(); return; }
|
|
1513
|
+
// #2007: and the active Agents tab goes home to the list of agents.
|
|
1514
|
+
if (!pending && b.dataset.mode === 'agents' && mode === 'agents' && window.flolessAgents) { void window.flolessAgents.home(); return; }
|
|
1449
1515
|
setMode(b.dataset.mode);
|
|
1450
1516
|
});
|
|
1451
1517
|
document.addEventListener('keydown', (e) => {
|
|
@@ -1540,7 +1606,9 @@
|
|
|
1540
1606
|
// Keep descriptor order for a stable card order. A load failure RE-WIDENS the entries to the
|
|
1541
1607
|
// descriptor keys (the catch assigns them): still usable, and a card for something uninstalled is
|
|
1542
1608
|
// refused by the server on click.
|
|
1543
|
-
|
|
1609
|
+
// The remedy is free text (it can hold commas and colons), so it enters the signature JSON-quoted:
|
|
1610
|
+
// a changed remedy repaints the card, and no remedy can forge another row's signature.
|
|
1611
|
+
const cardsSig = (entries) => entries.map((e) => `${e.appId}>${e.templateId}${e.ambiguous ? '?' : ''}:${e.capabilityStatus || ''}:${e.missing ? 'missing' : ''}:${JSON.stringify(e.setupRemedy || '')}`).join(',');
|
|
1544
1612
|
const cardsBefore = cardsSig(wsAppEntries);
|
|
1545
1613
|
let coreDefaults = null;
|
|
1546
1614
|
try {
|
|
@@ -2060,8 +2128,8 @@
|
|
|
2060
2128
|
function workspaceCreateEntries(entries) {
|
|
2061
2129
|
// Create affordances stay docked at the top, separate from existing projects. Cards come out in
|
|
2062
2130
|
// descriptor order, per workflow. (A sort used to push the kind:'current' card last because it
|
|
2063
|
-
// started from a different mode; that card is gone — #625 —
|
|
2064
|
-
//
|
|
2131
|
+
// started from a different mode; that card is gone — #625 — so declaration order IS the intended
|
|
2132
|
+
// order.)
|
|
2065
2133
|
return entries.flatMap((entry) => {
|
|
2066
2134
|
const d = WORKSPACE_APPS[entry.templateId];
|
|
2067
2135
|
const actions = d && Array.isArray(d.createActions) ? d.createActions : [];
|
|
@@ -2071,6 +2139,9 @@
|
|
|
2071
2139
|
|
|
2072
2140
|
function workspaceCreateCardHtml(entry, action) {
|
|
2073
2141
|
const descriptor = WORKSPACE_APPS[entry.templateId];
|
|
2142
|
+
// The descriptor's own drawing when it has one (see `cardIcon` on WORKSPACE_APPS), else `fallback`.
|
|
2143
|
+
const seedIcon = (fallback) => `<span class="ws-seed-icon" aria-hidden="true">${descriptor?.cardIcon
|
|
2144
|
+
? `<svg viewBox="0 0 24 24" focusable="false">${descriptor.cardIcon}</svg>` : fallback}</span>`;
|
|
2074
2145
|
if (entry.missing === true) {
|
|
2075
2146
|
const descriptionId = `ws-${entry.templateId}-missing`;
|
|
2076
2147
|
const buttonStart = entry.templateId === 'vectorize'
|
|
@@ -2078,7 +2149,8 @@
|
|
|
2078
2149
|
: `<button type="button" class="ws-seed ws-seed-remedy" data-command-id="shell.project-steel-missing-workflow" `;
|
|
2079
2150
|
return buttonStart +
|
|
2080
2151
|
`aria-label="${escapeAttr(`${action.headline} needs setup — why unavailable`)}" aria-describedby="${escapeAttr(descriptionId)}" ` +
|
|
2081
|
-
`data-seed-app="${escapeAttr(entry.appId)}" data-seed-template="${escapeAttr(entry.templateId)}" data-seed-action="${escapeAttr(action.kind)}"
|
|
2152
|
+
`data-seed-app="${escapeAttr(entry.appId)}" data-seed-template="${escapeAttr(entry.templateId)}" data-seed-action="${escapeAttr(action.kind)}" ` +
|
|
2153
|
+
`data-drop-warn="${escapeAttr(`Nothing was opened. ${missingWorkspaceWorkflowMessage(entry.templateId)}`)}">` +
|
|
2082
2154
|
`<span class="ws-seed-icon" aria-hidden="true">!</span>` +
|
|
2083
2155
|
`<span class="ws-seed-headline">${escapeHtml(action.headline)}</span>` +
|
|
2084
2156
|
`<span class="ws-seed-capability ws-seed-state">Needs setup</span>` +
|
|
@@ -2115,11 +2187,17 @@
|
|
|
2115
2187
|
};
|
|
2116
2188
|
const states = descriptor.accessCopy || revitStates;
|
|
2117
2189
|
const state = states[entry.capabilityStatus] || states['check-unavailable'];
|
|
2190
|
+
// A remedy the server wrote for this "Needs setup" replaces "setup didn’t finish"; the button
|
|
2191
|
+
// still re-runs setup, so the person can check again once they have fixed it.
|
|
2192
|
+
const body = entry.capabilityStatus === 'setup-unavailable' && entry.setupRemedy ? entry.setupRemedy : state.body;
|
|
2118
2193
|
const descriptionId = `ws-${entry.templateId}-${entry.capabilityStatus || 'check-unavailable'}`;
|
|
2119
2194
|
const actionable = !!state.action;
|
|
2120
2195
|
const provisioning = entry.capabilityStatus === 'setup-provisioning';
|
|
2121
2196
|
const teklaCommand = entry.capabilityStatus === 'setup-unavailable'
|
|
2122
2197
|
? 'data-command-id="shell.tekla-retry-setup"'
|
|
2198
|
+
: entry.capabilityStatus === 'setup-repair-required'
|
|
2199
|
+
// Its own command, so `?` explains a re-check after a reinstall, not "retry setup".
|
|
2200
|
+
? 'data-command-id="shell.tekla-check-install"'
|
|
2123
2201
|
: entry.capabilityStatus === 'setup-integrity-failure'
|
|
2124
2202
|
? 'data-command-id="shell.tekla-report-setup-issue"'
|
|
2125
2203
|
: 'data-command-id="shell.tekla-view-access"';
|
|
@@ -2140,16 +2218,17 @@
|
|
|
2140
2218
|
: entry.templateId === 'drawing-check'
|
|
2141
2219
|
? `${drawingCheckCommand} data-module-remedy="drawing-check" data-module-remedy-state="${remedyState}"`
|
|
2142
2220
|
: `${teklaCommand} data-module-remedy="tekla-parser" data-module-remedy-state="${remedyState}"` : '') + `>` +
|
|
2143
|
-
|
|
2221
|
+
seedIcon('!') +
|
|
2144
2222
|
`<span class="ws-seed-headline">${escapeHtml(descriptor.displayName)}</span>` +
|
|
2145
2223
|
(descriptor.readOnlyLabel ? `<span class="ws-seed-readonly">${escapeHtml(descriptor.readOnlyLabel)}</span>` : '') +
|
|
2146
2224
|
`<span class="ws-seed-capability ws-seed-state">${escapeHtml(state.status)}</span>` +
|
|
2147
|
-
`<span class="ws-seed-sub" id="${escapeAttr(descriptionId)}">${escapeHtml(
|
|
2225
|
+
`<span class="ws-seed-sub" id="${escapeAttr(descriptionId)}">${escapeHtml(body)}</span>` +
|
|
2148
2226
|
(state.action ? `<span class="ws-seed-action">${escapeHtml(state.action)} →</span>` : '') +
|
|
2149
2227
|
`</${actionable ? 'button' : 'div'}>`;
|
|
2150
2228
|
}
|
|
2151
|
-
const acceptsDrop = action.kind === 'drawing' || action.kind === 'rvt';
|
|
2229
|
+
const acceptsDrop = action.kind === 'drawing' || action.kind === 'rvt' || action.kind === 'tekla-source';
|
|
2152
2230
|
const createCommand = action.kind === 'tekla-source' ? 'data-command-id="shell.project-create-tekla-read" '
|
|
2231
|
+
: action.kind === 'rvt' ? 'data-command-id="shell.project-create-revit-read" '
|
|
2153
2232
|
: action.kind === 'drawing-check-profile' ? 'data-command-id="shell.project-create-drawing-check-profile" '
|
|
2154
2233
|
: action.kind !== 'drawing' ? ''
|
|
2155
2234
|
: entry.templateId === 'steel-model' ? 'data-command-id="shell.project-create-steel-from-drawings" '
|
|
@@ -2165,13 +2244,17 @@
|
|
|
2165
2244
|
createCommand +
|
|
2166
2245
|
(action.tip ? `data-tip="${escapeAttr(action.tip)}" ` : '') +
|
|
2167
2246
|
`data-seed-app="${escapeAttr(entry.appId)}" data-seed-template="${escapeAttr(entry.templateId)}" data-seed-action="${escapeAttr(action.kind)}"` +
|
|
2168
|
-
(acceptsDrop ? ` data-seed-drop="${escapeAttr(entry.appId)}" data-seed-drop-kind="${escapeAttr(action.kind)}"`
|
|
2247
|
+
(acceptsDrop ? ` data-seed-drop="${escapeAttr(entry.appId)}" data-seed-drop-kind="${escapeAttr(action.kind)}"`
|
|
2248
|
+
: ` data-drop-warn="${escapeAttr(action.dropWarn || `Nothing was opened. ${action.headline} doesn’t take a dropped file; click the card to start.`)}"`) +
|
|
2169
2249
|
`>` +
|
|
2170
|
-
|
|
2250
|
+
seedIcon('+') +
|
|
2171
2251
|
`<span class="ws-seed-headline">${escapeHtml(action.headline)}</span>` +
|
|
2172
2252
|
(descriptor?.readOnlyLabel ? `<span class="ws-seed-readonly">${escapeHtml(descriptor.readOnlyLabel)}</span>` : '') +
|
|
2173
2253
|
(action.capability ? `<span class="ws-seed-capability">${escapeHtml(action.capability)}</span>` : '') +
|
|
2174
2254
|
`<span class="ws-seed-sub">${escapeHtml(action.sub)}</span>` +
|
|
2255
|
+
// Kept out of the accessible name (aria-hidden for good measure): the aria-label names the
|
|
2256
|
+
// click route, which everyone has; "or drop" names a pointer-only one.
|
|
2257
|
+
(acceptsDrop && action.dropHint ? `<span class="ws-seed-hint" aria-hidden="true">${escapeHtml(action.dropHint)}</span>` : '') +
|
|
2175
2258
|
(target
|
|
2176
2259
|
? `<span class="ws-seed-target" data-tip="You have more than one of these workflows installed.\nThis card creates on:\n${escapeAttr(target)}">On ${escapeHtml(target)}</span>`
|
|
2177
2260
|
: '') +
|
|
@@ -2247,8 +2330,13 @@
|
|
|
2247
2330
|
const folderName = window.flolessWorkspaceRoot ? window.flolessWorkspaceRoot.name() : 'Workspace directory';
|
|
2248
2331
|
let html = `<div class="ws-head"><div class="ws-head-text"><h2>Workspaces</h2>` +
|
|
2249
2332
|
`<div class="ws-sub">${rootUnavailable ? 'Workspace directory unavailable. Choose another folder to continue.' : 'Open a project to view its drawings, model, Knowledge and history.'}</div></div>` +
|
|
2250
|
-
`<div class="ws-head-actions"
|
|
2251
|
-
|
|
2333
|
+
`<div class="ws-head-actions">` +
|
|
2334
|
+
// Shown only when there is a project card to search (absent, never disabled, in the empty state).
|
|
2335
|
+
(!rootUnavailable && projects.length
|
|
2336
|
+
? `<input type="search" id="ws-landing-search" class="ws-landing-search" data-command-id="shell.project-list-search" placeholder="Search projects" aria-label="Search projects by name, description, kind or workflow" autocomplete="off" spellcheck="false" value="${escapeAttr(landingQuery)}">`
|
|
2337
|
+
: '') +
|
|
2338
|
+
`<button type="button" class="ws-import-btn ws-folder-btn${rootUnavailable ? ' is-unavailable' : ''}" id="ws-workspace-folder" data-command-id="menu.workspace-folder" data-tip="${escapeAttr(rootPath || 'Choose the Workspace directory FloLess reads for projects and workflows')}">Workspace directory · ${escapeHtml(rootUnavailable ? 'unavailable' : folderName)}</button>` +
|
|
2339
|
+
`${rootUnavailable ? '' : '<button type="button" class="ws-import-btn" id="ws-import-project" data-command-id="shell.project-import" data-tip="Restore a project from an exported .zip file or a zipped project folder">↓ Import project…</button>'}</div></div>`;
|
|
2252
2340
|
if (rootUnavailable) {
|
|
2253
2341
|
html += `<div class="ws-empty-note ws-root-unavailable" role="status" aria-live="polite"><b>Workspace directory unavailable.</b> ` +
|
|
2254
2342
|
`Choose another folder to continue. ` +
|
|
@@ -2286,11 +2374,15 @@
|
|
|
2286
2374
|
thumbBandHtml(p, displayApp) +
|
|
2287
2375
|
`<span class="ws-body"><span><span class="ws-name">${escapeHtml(p.name)}</span>` +
|
|
2288
2376
|
(projectCapability ? `<span class="ws-meta">${escapeHtml(projectCapability)}</span>` : '') +
|
|
2377
|
+
(p.importedMidSave ? `<span class="ws-meta ws-unverified" data-tip="${escapeAttr(UNVERIFIED_IMPORT_TIP)}">Imported mid-save · not verified. Export again on the source computer.</span>` : '') +
|
|
2289
2378
|
`<span class="ws-meta ws-meta-app"><span class="ws-meta-kind">${escapeHtml(displayApp)}</span>${wfName}<span class="ws-sep"> · </span><span class="t">${escapeHtml(relAgo(p.updatedAt))}</span></span></span>` +
|
|
2290
|
-
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}" aria-label="Project actions" data-tip="Rename · Thumbnail · Duplicate · Export · Archive">⋯</button>` +
|
|
2379
|
+
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}" aria-label="Project actions" data-tip="${p.importedMidSave ? 'Rename · Thumbnail · Mark as checked · Duplicate · Export · Archive' : 'Rename · Thumbnail · Duplicate · Export · Archive'}">⋯</button>` +
|
|
2291
2380
|
`</span></div>`;
|
|
2292
2381
|
}
|
|
2293
2382
|
html += `</div>`;
|
|
2383
|
+
// The search's no-match message. Always rendered (empty) beside a search box, and filled in by
|
|
2384
|
+
// applyLandingSearch(): a live region inserted with its text already inside is announced unreliably.
|
|
2385
|
+
if (projects.length) html += `<div class="ws-empty-note ws-search-empty" id="ws-search-empty" role="status" aria-live="polite"></div>`;
|
|
2294
2386
|
// Empty state — but ONLY when the list really is empty. A failed load also leaves `projects`
|
|
2295
2387
|
// empty, and telling someone with 11 projects "No projects yet — start one" is a lie that reads
|
|
2296
2388
|
// like their work is gone. The toast alone can't carry this: it auto-dismisses, and the false
|
|
@@ -2306,29 +2398,16 @@
|
|
|
2306
2398
|
+ (guess ? `${escapeHtml(guess)} ` : 'FloLess could not read the Workspace directory. ')
|
|
2307
2399
|
+ ` <button type="button" id="ws-retry-projects">↻ Try again</button></div>`;
|
|
2308
2400
|
} else {
|
|
2309
|
-
// First-run onboarding (#598).
|
|
2310
|
-
//
|
|
2311
|
-
//
|
|
2312
|
-
//
|
|
2313
|
-
// Deliberately NOT the Workflows card's shape. The create cards are already on screen right
|
|
2314
|
-
// above this, and they are the actual first action — a second bordered, accent-filled "start
|
|
2315
|
-
// here" panel under them would put two accent affordances in a staring contest and invert the
|
|
2316
|
-
// hierarchy. So: the same plain note, one added sentence, and the tour as a QUIET text link
|
|
2317
|
-
// (the .onb-build-btn tier, never the filled .onb-tour-btn one).
|
|
2318
|
-
//
|
|
2319
|
-
// The added sentence says what a project IS, because that is the one thing a newcomer here
|
|
2320
|
-
// cannot infer — not "no Run here", which .ws-sub already states unconditionally two lines up.
|
|
2401
|
+
// First-run onboarding (#598, #2046). The create cards above are the actual first action, so the way to the
|
|
2402
|
+
// Guide is a QUIET text link (the .onb-build-btn tier, never the filled .onb-tour-btn one), and the added
|
|
2403
|
+
// sentence says what a project IS — the one thing a newcomer here cannot infer.
|
|
2321
2404
|
const note = 'No projects yet — start one from the cards above, or Import project to restore an exported .zip.';
|
|
2322
2405
|
const what = 'A project is an approved, running copy of a workflow app — you open it like a document and keep working. Building or changing the app itself happens in Workflows mode.';
|
|
2323
2406
|
html += `<div class="ws-empty-note">${escapeHtml(note)} ${escapeHtml(what)}${archived.length ? ' You have archived projects below.' : ''}`
|
|
2324
|
-
//
|
|
2325
|
-
// entry points should hear one action, not two. The id is what carries focus across a
|
|
2326
|
-
// repaint (landingFocusKey keys on it).
|
|
2407
|
+
// The same Guide as the Workflows card. The id is what carries focus across a repaint (landingFocusKey keys on it).
|
|
2327
2408
|
+ `<div class="ws-empty-tour">New here? `
|
|
2328
|
-
+ `<button type="button" id="ws-onb-tour" class="ws-empty-tour-btn" `
|
|
2329
|
-
+ `
|
|
2330
|
-
+ `data-tip="Copies a prompt — paste it into Claude Code or Codex">Start the guided tour →</button>`
|
|
2331
|
-
+ `<span class="sr-only ws-empty-tour-live" aria-live="polite"></span>`
|
|
2409
|
+
+ `<button type="button" id="ws-onb-tour" class="ws-empty-tour-btn" data-command-id="shell.ask-guide#the Workspaces page" `
|
|
2410
|
+
+ `data-tip="Ask the Guide in AI Chat to look at your setup and suggest what to do first.">Ask the Guide →</button>`
|
|
2332
2411
|
+ `</div></div>`;
|
|
2333
2412
|
}
|
|
2334
2413
|
}
|
|
@@ -2368,20 +2447,56 @@
|
|
|
2368
2447
|
const keepFocus = landingFocusKey(document.activeElement);
|
|
2369
2448
|
const keepScroll = $landing.scrollTop;
|
|
2370
2449
|
const keepArchivedOpen = !!$landing.querySelector('.ws-archived')?.open;
|
|
2450
|
+
const search = document.activeElement?.id === 'ws-landing-search' ? document.activeElement : null;
|
|
2451
|
+
const keepCaret = search ? [search.selectionStart, search.selectionEnd] : null;
|
|
2371
2452
|
$landing.innerHTML = html;
|
|
2372
2453
|
// Reapply in this order: the disclosure changes the scrollable height, so it must land before the
|
|
2373
|
-
// offset; focus lands
|
|
2454
|
+
// offset; focus lands next, with preventScroll so its scroll-into-view can't undo that offset. The
|
|
2455
|
+
// search filter runs after both: it needs the restored focus to put the caret back, and it hides the
|
|
2456
|
+
// same cards the previous paint hid, so the height the offset was restored against barely moves.
|
|
2374
2457
|
if (keepArchivedOpen) { const d = $landing.querySelector('.ws-archived'); if (d) d.open = true; }
|
|
2375
2458
|
$landing.scrollTop = keepScroll;
|
|
2376
2459
|
if (keepFocus) $landing.querySelector(keepFocus)?.focus({ focusVisible: true, preventScroll: true });
|
|
2460
|
+
applyLandingSearch(keepCaret); // re-filter the new cards; put the caret back where the user left it
|
|
2461
|
+
// Clear search only exists once the filter has run, so focus on it is put back here, not above.
|
|
2462
|
+
if (keepFocus === '#ws-search-clear') $landing.querySelector(keepFocus)?.focus({ focusVisible: true, preventScroll: true });
|
|
2377
2463
|
paintCardThumbs();
|
|
2378
2464
|
tipTruncatedNames();
|
|
2379
2465
|
// The first-run tour link, when the empty state rendered one. app.js owns the copy behaviour so
|
|
2380
2466
|
// both entry points to the tour stay identical; a no-op when the button isn't on screen.
|
|
2381
|
-
|
|
2467
|
+
wireAskGuide($landing.querySelector('#ws-onb-tour'));
|
|
2382
2468
|
reflashCard(); // a repaint must not swallow an in-flight confirmation glow
|
|
2383
2469
|
}
|
|
2384
2470
|
|
|
2471
|
+
/** Hide the project cards that don't match the landing search: every typed word must appear in the
|
|
2472
|
+
* card's name, capability, kind or workflow (never its "2 h ago", which every card has). The create
|
|
2473
|
+
* cards and the Archived list are not results, so they are left alone. `caret` restores the
|
|
2474
|
+
* selection a rebuild dropped. */
|
|
2475
|
+
function applyLandingSearch(caret) {
|
|
2476
|
+
const input = $landing.querySelector('#ws-landing-search');
|
|
2477
|
+
if (!input) return;
|
|
2478
|
+
const terms = landingQuery.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
2479
|
+
let shown = 0;
|
|
2480
|
+
for (const card of $landing.querySelectorAll('.ws-grid .ws-card[data-open]')) {
|
|
2481
|
+
const hay = Array.from(card.querySelectorAll('.ws-name, .ws-meta:not(.ws-meta-app), .ws-meta-kind, .ws-meta-wf'), (el) => el.textContent).join(' ').toLowerCase();
|
|
2482
|
+
card.hidden = !terms.every((t) => hay.includes(t));
|
|
2483
|
+
if (!card.hidden) shown++;
|
|
2484
|
+
}
|
|
2485
|
+
const note = $landing.querySelector('#ws-search-empty');
|
|
2486
|
+
if (note) {
|
|
2487
|
+
note.textContent = shown ? '' : `No projects match “${landingQuery.trim()}”.${archived.length ? ' Archived projects aren’t searched.' : ''} `;
|
|
2488
|
+
if (!shown) note.insertAdjacentHTML('beforeend', '<button type="button" id="ws-search-clear" data-command-id="shell.project-list-search-clear">Clear search</button>');
|
|
2489
|
+
}
|
|
2490
|
+
tipTruncatedNames(); // a card hidden at the last measurement measured as unclipped; re-measure the shown ones
|
|
2491
|
+
if (caret) input.setSelectionRange(caret[0], caret[1]);
|
|
2492
|
+
}
|
|
2493
|
+
function setLandingQuery(q) {
|
|
2494
|
+
landingQuery = q;
|
|
2495
|
+
const input = $landing.querySelector('#ws-landing-search');
|
|
2496
|
+
if (input) input.value = q;
|
|
2497
|
+
applyLandingSearch();
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2385
2500
|
/** Make a clamped project name reachable: the two-line clamp on .ws-name (see app.css) can hide the
|
|
2386
2501
|
* tail, which for a real project name is often the discriminating part. Attach the full value as a
|
|
2387
2502
|
* data-tip ONLY where something is actually hidden — MEASURED (scrollHeight past clientHeight is
|
|
@@ -2489,6 +2604,8 @@
|
|
|
2489
2604
|
const del = e.target.closest('[data-delete-archived]');
|
|
2490
2605
|
if (del) { e.stopPropagation(); deleteArchivedProject(del.dataset.deleteArchived); return; }
|
|
2491
2606
|
if (e.target.closest('#ws-retry-projects')) { e.stopPropagation(); retryProjects(); return; }
|
|
2607
|
+
// Clearing empties the message the button sits in, so focus goes back to the search box.
|
|
2608
|
+
if (e.target.closest('#ws-search-clear')) { setLandingQuery(''); $landing.querySelector('#ws-landing-search')?.focus(); return; }
|
|
2492
2609
|
if (e.target.closest('#ws-workspace-folder')) {
|
|
2493
2610
|
e.stopPropagation();
|
|
2494
2611
|
if (window.flolessWorkspaceRoot) window.flolessWorkspaceRoot.open();
|
|
@@ -2547,7 +2664,11 @@
|
|
|
2547
2664
|
'reader-release-unavailable': 'The required Revit reader version is unavailable. Report this issue.',
|
|
2548
2665
|
};
|
|
2549
2666
|
const category = setup?.category;
|
|
2550
|
-
|
|
2667
|
+
// A remedy the server wrote for this failure says what the person can fix; it wins over the category line.
|
|
2668
|
+
const remedy = typeof setup?.setupRemedy === 'string' ? setup.setupRemedy.trim() : '';
|
|
2669
|
+
const explanation = remedy || details[category] || 'Revit Parser setup still needs attention. Try setup again.';
|
|
2670
|
+
// The server wrote the remedy for the person and it names their folders, so it is toasted as written.
|
|
2671
|
+
const explanationToast = remedy ? authoredToastCopy(remedy) : explanation;
|
|
2551
2672
|
// Provisioning broadcasts can repaint the landing before this request settles. Apply the
|
|
2552
2673
|
// safe result to the live replacement instead of leaving its card and Instructor narration stale.
|
|
2553
2674
|
const settledRemedy = revitRemedy.isConnected
|
|
@@ -2555,7 +2676,7 @@
|
|
|
2555
2676
|
: document.querySelector('[data-revit-remedy="setup-unavailable"]');
|
|
2556
2677
|
if (!settledRemedy) {
|
|
2557
2678
|
window.Instructor?.clear();
|
|
2558
|
-
showToast(
|
|
2679
|
+
showToast(explanationToast, 'warn');
|
|
2559
2680
|
return;
|
|
2560
2681
|
}
|
|
2561
2682
|
const settledAction = settledRemedy.querySelector('.ws-seed-action');
|
|
@@ -2576,7 +2697,7 @@
|
|
|
2576
2697
|
if (originalBlockedReason === null) settledRemedy.removeAttribute('data-blocked-reason');
|
|
2577
2698
|
else settledRemedy.setAttribute('data-blocked-reason', originalBlockedReason);
|
|
2578
2699
|
window.Instructor?.refreshCarrier(settledRemedy);
|
|
2579
|
-
showToast(
|
|
2700
|
+
showToast(explanationToast, 'warn');
|
|
2580
2701
|
return;
|
|
2581
2702
|
}
|
|
2582
2703
|
window.dispatchEvent(new CustomEvent('floless:open-revit-access', {
|
|
@@ -2597,26 +2718,34 @@
|
|
|
2597
2718
|
}));
|
|
2598
2719
|
return;
|
|
2599
2720
|
}
|
|
2600
|
-
|
|
2721
|
+
const remedyState = moduleRemedy.dataset.moduleRemedyState;
|
|
2722
|
+
if (remedyState === 'setup-unavailable' || remedyState === 'setup-repair-required') {
|
|
2723
|
+
// A broken installation is re-CHECKED (after a reinstall), never "set up again".
|
|
2724
|
+
const repair = remedyState === 'setup-repair-required';
|
|
2601
2725
|
const originalLabel = moduleRemedy.getAttribute('aria-label');
|
|
2602
2726
|
const action = moduleRemedy.querySelector('.ws-seed-action');
|
|
2603
2727
|
const originalAction = action?.textContent || '';
|
|
2604
2728
|
moduleRemedy.disabled = true;
|
|
2605
2729
|
moduleRemedy.setAttribute('aria-busy', 'true');
|
|
2606
|
-
moduleRemedy.setAttribute('aria-label', 'Tekla Parser setup retry in progress');
|
|
2607
|
-
moduleRemedy.setAttribute('data-blocked-reason',
|
|
2608
|
-
|
|
2730
|
+
moduleRemedy.setAttribute('aria-label', repair ? 'Tekla Parser check in progress' : 'Tekla Parser setup retry in progress');
|
|
2731
|
+
moduleRemedy.setAttribute('data-blocked-reason', repair
|
|
2732
|
+
? 'Tekla Parser check is already in progress.' : 'Tekla Parser setup retry is already in progress.');
|
|
2733
|
+
if (action) action.textContent = repair ? 'Checking…' : 'Trying…';
|
|
2609
2734
|
window.Instructor?.refreshCarrier(moduleRemedy);
|
|
2610
2735
|
let status = null;
|
|
2736
|
+
let setupRemedy = '';
|
|
2611
2737
|
try {
|
|
2612
2738
|
const setup = await api('/api/tekla-defaults/retry', { method: 'POST' });
|
|
2613
2739
|
status = setup?.status || null;
|
|
2740
|
+
setupRemedy = typeof setup?.setupRemedy === 'string' ? setup.setupRemedy.trim() : '';
|
|
2614
2741
|
} catch {
|
|
2615
2742
|
// The server may have accepted the retry even when this response was lost. Reconcile from
|
|
2616
2743
|
// its authoritative catalogue; never turn a transport loss into a false setup failure.
|
|
2617
2744
|
try {
|
|
2618
2745
|
const catalogue = await api('/api/apps');
|
|
2619
|
-
|
|
2746
|
+
const capability = catalogue.workspaceCapabilities?.find((entry) => entry.templateId === 'tekla-parser');
|
|
2747
|
+
status = capability?.status || null;
|
|
2748
|
+
setupRemedy = typeof capability?.setupRemedy === 'string' ? capability.setupRemedy.trim() : '';
|
|
2620
2749
|
} catch { /* the next health/SSE refresh will reconcile */ }
|
|
2621
2750
|
}
|
|
2622
2751
|
moduleRemedy.disabled = false;
|
|
@@ -2638,6 +2767,23 @@
|
|
|
2638
2767
|
}
|
|
2639
2768
|
const liveRemedy = document.querySelector('[data-module-remedy="tekla-parser"]');
|
|
2640
2769
|
if (liveRemedy) window.Instructor?.refreshCarrier(liveRemedy);
|
|
2770
|
+
// The re-render replaced the card that had focus; keep keyboard users on it.
|
|
2771
|
+
if (liveRemedy && (document.activeElement === document.body || !document.activeElement)) liveRemedy.focus();
|
|
2772
|
+
if (status === 'setup-repair-required') {
|
|
2773
|
+
showToast('Tekla Parser still needs repair. Reinstall FloLess from floless.io, then check again.', 'warn');
|
|
2774
|
+
return;
|
|
2775
|
+
}
|
|
2776
|
+
// The server's remedy says what the person can fix (#1965 review); the card shows it too. It names
|
|
2777
|
+
// their folders and projects, so it is toasted as written, never swapped for a generic line.
|
|
2778
|
+
if (status === 'setup-unavailable' && setupRemedy) {
|
|
2779
|
+
showToast(authoredToastCopy(setupRemedy), 'warn');
|
|
2780
|
+
return;
|
|
2781
|
+
}
|
|
2782
|
+
// The card now asks for a report; a toast promising that another try helps would contradict it.
|
|
2783
|
+
if (status === 'setup-integrity-failure') {
|
|
2784
|
+
showToast('Tekla Parser setup could not be verified. Use Report issue on the card.', 'warn');
|
|
2785
|
+
return;
|
|
2786
|
+
}
|
|
2641
2787
|
showToast(status
|
|
2642
2788
|
? 'Tekla Parser setup still needs attention. Try setup again.'
|
|
2643
2789
|
: 'FloLess couldn’t confirm whether Tekla Parser setup finished. Check again.', 'warn');
|
|
@@ -2658,9 +2804,8 @@
|
|
|
2658
2804
|
const appId = seed.dataset.seedApp;
|
|
2659
2805
|
const templateId = seed.dataset.seedTemplate || appId;
|
|
2660
2806
|
if (!WORKSPACE_APPS[templateId]) return;
|
|
2661
|
-
//
|
|
2662
|
-
//
|
|
2663
|
-
// not silently inherit the file picker.
|
|
2807
|
+
// Each create kind has its own branch below. The 'drawing' check stays a check rather than an
|
|
2808
|
+
// assumption: a future kind must declare its own branch, not silently inherit the file picker.
|
|
2664
2809
|
if (seed.dataset.seedAction === 'drawing') {
|
|
2665
2810
|
if (workspaceWorkflowKnownMissing(appId)) {
|
|
2666
2811
|
showToast(missingWorkspaceWorkflowMessage(templateId), 'warn');
|
|
@@ -2693,7 +2838,17 @@
|
|
|
2693
2838
|
}
|
|
2694
2839
|
}
|
|
2695
2840
|
});
|
|
2841
|
+
$landing.addEventListener('input', (e) => {
|
|
2842
|
+
if (e.target.id !== 'ws-landing-search') return;
|
|
2843
|
+
landingQuery = e.target.value;
|
|
2844
|
+
applyLandingSearch();
|
|
2845
|
+
});
|
|
2696
2846
|
$landing.addEventListener('keydown', (e) => {
|
|
2847
|
+
// Esc clears a search that has text (handled here, not left to the browser, so every engine
|
|
2848
|
+
// behaves the same); an empty box lets Esc through to whatever else listens for it.
|
|
2849
|
+
if (e.key === 'Escape' && e.target.id === 'ws-landing-search' && e.target.value) {
|
|
2850
|
+
e.preventDefault(); e.stopPropagation(); setLandingQuery(''); return;
|
|
2851
|
+
}
|
|
2697
2852
|
if (e.key !== 'Enter' && e.key !== ' ') return;
|
|
2698
2853
|
// The CARD ITSELF must be the focused element — never merely an ancestor of it.
|
|
2699
2854
|
//
|
|
@@ -2708,11 +2863,10 @@
|
|
|
2708
2863
|
openProject(e.target.dataset.open);
|
|
2709
2864
|
});
|
|
2710
2865
|
|
|
2711
|
-
//
|
|
2712
|
-
//
|
|
2713
|
-
//
|
|
2714
|
-
//
|
|
2715
|
-
// driven by pickDrawingFiles() above when the File System Access API isn't available.
|
|
2866
|
+
// Hidden fallback pickers for the create cards' click path: drawings, one .rvt, a Tekla folder, a
|
|
2867
|
+
// Tekla .zip. They live outside $landing so an innerHTML re-render can't wipe them, and the pick*()
|
|
2868
|
+
// helpers above use them only when the File System Access API is missing. Files DROPPED on a card
|
|
2869
|
+
// are handled by dropOnLanding below.
|
|
2716
2870
|
const $seedFile = document.createElement('input');
|
|
2717
2871
|
$seedFile.type = 'file'; $seedFile.accept = '.pdf,image/*'; $seedFile.multiple = true; $seedFile.hidden = true;
|
|
2718
2872
|
document.body.appendChild($seedFile);
|
|
@@ -2905,33 +3059,173 @@
|
|
|
2905
3059
|
const $thumbFile = document.createElement('input');
|
|
2906
3060
|
$thumbFile.type = 'file'; $thumbFile.accept = 'image/*'; $thumbFile.hidden = true;
|
|
2907
3061
|
document.body.appendChild($thumbFile);
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
3062
|
+
// Files dropped on the landing. Every create card takes part: a card that reads a file starts a
|
|
3063
|
+
// project from it, and every other one (locked, needing setup, or Drawing Checker, which starts from
|
|
3064
|
+
// a profile) still accepts the drop so it can say why nothing opened (cardDropWarning). Anywhere else
|
|
3065
|
+
// the drop is refused with a no-drop cursor (the guard below), so the browser never leaves the app to
|
|
3066
|
+
// display the dropped file, which is what an unhandled drop does.
|
|
3067
|
+
const DRAWING_EXTENSIONS = Object.values(DRAWING_FILE_TYPES[0].accept).flat();
|
|
3068
|
+
const isDrawingFile = (file) => DRAWING_EXTENSIONS.some((ext) => file.name.toLowerCase().endsWith(ext));
|
|
3069
|
+
const DRAWING_FORMATS = 'PDF and image files (PNG, JPG, GIF, WebP or BMP)';
|
|
3070
|
+
const draggingFiles = (e) => Array.from(e.dataTransfer?.types || []).includes('Files');
|
|
3071
|
+
// While files are dragged over the window, `data-file-drag` on $landing (so a re-render keeps it)
|
|
3072
|
+
// shows every card that takes a file. Set on every dragenter and dragover, which keep firing while a
|
|
3073
|
+
// drag hovers, so nothing can leave it wrongly cleared for more than a moment. Cleared when the drag
|
|
3074
|
+
// leaves the window (a dragleave whose relatedTarget is null: moving between elements names the new
|
|
3075
|
+
// one), on a drop, and on the first pointer move after the drag — a drag fires no pointer events, and
|
|
3076
|
+
// no event reliably ends one that started outside the page. (A count of enters and leaves was tried
|
|
3077
|
+
// first: one unpaired leave, such as a leftover from the previous drag, cleared it mid-drag.)
|
|
3078
|
+
function endFileDrag() {
|
|
3079
|
+
if (!('fileDrag' in $landing.dataset)) return;
|
|
3080
|
+
delete $landing.dataset.fileDrag;
|
|
3081
|
+
$landing.querySelectorAll('.drag-over').forEach((zone) => zone.classList.remove('drag-over'));
|
|
3082
|
+
}
|
|
3083
|
+
function fileDragEnter(e) {
|
|
3084
|
+
if (draggingFiles(e) && !('fileDrag' in $landing.dataset)) $landing.dataset.fileDrag = '';
|
|
3085
|
+
}
|
|
3086
|
+
function fileDragLeave(e) { if (draggingFiles(e) && !e.relatedTarget) endFileDrag(); }
|
|
3087
|
+
window.addEventListener('dragenter', fileDragEnter);
|
|
3088
|
+
window.addEventListener('dragover', fileDragEnter);
|
|
3089
|
+
window.addEventListener('dragleave', fileDragLeave);
|
|
3090
|
+
window.addEventListener('drop', endFileDrag, true);
|
|
3091
|
+
window.addEventListener('pointermove', endFileDrag, { passive: true });
|
|
3092
|
+
// Anywhere in the app that nothing takes a file — an open dialog, the header — a dropped one is
|
|
3093
|
+
// refused instead of opened in place of FloLess. Bubble phase, and only when nothing below handled
|
|
3094
|
+
// it, so the real drop zones (the cards, chat, Knowledge) answer first; never on a file input,
|
|
3095
|
+
// whose own default is to take the file.
|
|
3096
|
+
const unhandledFileDrag = (e) => draggingFiles(e) && !e.defaultPrevented
|
|
3097
|
+
&& !(e.target instanceof HTMLInputElement && e.target.type === 'file');
|
|
3098
|
+
window.addEventListener('dragover', (e) => { if (unhandledFileDrag(e)) { e.preventDefault(); e.dataTransfer.dropEffect = 'none'; } });
|
|
3099
|
+
window.addEventListener('drop', (e) => { if (unhandledFileDrag(e)) e.preventDefault(); });
|
|
3100
|
+
|
|
3101
|
+
// A file dropped on the wrong card: what this card opens, and where the file goes instead. Only a
|
|
3102
|
+
// card that is on screen and ready is ever named, and a folder or .zip is only SUGGESTED for Tekla
|
|
3103
|
+
// Parser, since a folder of drawings or a project archive is neither a Tekla model.
|
|
3104
|
+
function misdropMessage(zone, opens, files, folderCount) {
|
|
3105
|
+
const cardFor = (kind) => $landing.querySelector(`[data-seed-drop-kind="${kind}"] .ws-seed-headline`)?.textContent;
|
|
3106
|
+
const name = zone.querySelector('.ws-seed-headline')?.textContent || 'This card';
|
|
3107
|
+
const other = (card) => (card && card !== name ? card : null);
|
|
3108
|
+
const revit = files.some((file) => /\.rvt$/i.test(file.name)) && other(cardFor('rvt'));
|
|
3109
|
+
const drawing = files.some(isDrawingFile) && other(cardFor('drawing'));
|
|
3110
|
+
const tekla = (folderCount || files.some((file) => /\.zip$/i.test(file.name))) && other(cardFor('tekla-source'));
|
|
3111
|
+
const next = revit ? `Drop it on ${revit} instead.`
|
|
3112
|
+
: drawing ? `Drop it on ${drawing} instead.`
|
|
3113
|
+
: folderCount && zone.dataset.seedDropKind === 'drawing'
|
|
3114
|
+
? `Folders aren’t opened: drop the drawings inside it instead${tekla ? `, or drop a Tekla model folder on ${tekla}` : ''}.`
|
|
3115
|
+
: tekla ? `If it is a Tekla model, drop it on ${tekla} instead.`
|
|
3116
|
+
: 'Drop one of those, or click the card to choose it.';
|
|
3117
|
+
return `${name} opens ${opens}, so nothing was opened. ${next}`;
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
// What a card that takes no file says when one is dropped on it. A locked or setting-up card answers
|
|
3121
|
+
// with what it shows NOW (retrying setup rewrites the card in place) plus its next step; that text can
|
|
3122
|
+
// carry the server's own remedy naming the person's folders, so it goes out as authored copy.
|
|
3123
|
+
function cardDropWarning(zone) {
|
|
3124
|
+
if (zone.dataset.dropWarn) return zone.dataset.dropWarn;
|
|
3125
|
+
const said = zone.querySelector('.ws-seed-sub')?.textContent?.trim() || '';
|
|
3126
|
+
const action = zone.querySelector('.ws-seed-action')?.textContent?.replace(/\s*→\s*$/, '').trim();
|
|
3127
|
+
// A busy card (setting up, or retrying: its action then reads "Trying…") has nothing to press yet.
|
|
3128
|
+
return authoredToastCopy(`Nothing was opened. ${said}`
|
|
3129
|
+
+ (zone.getAttribute('aria-busy') === 'true' ? ' Drop the file again once it finishes.'
|
|
3130
|
+
: action ? ` Use “${action}” on the card, then drop the file again.` : ''));
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
// A Tekla model dropped on its card: the whole model folder, or one .zip of it, read as the folder
|
|
3134
|
+
// and ZIP pickers read them (filesFromDirectoryHandle, teklaZipSource). The folder's handle must be
|
|
3135
|
+
// requested INSIDE the drop event (the browser empties dataTransfer once the handler returns), so
|
|
3136
|
+
// only its answer is awaited. A browser without getAsFileSystemHandle is pointed to the click route.
|
|
3137
|
+
let teklaDropReading = false;
|
|
3138
|
+
function dropTeklaSource(zone, items, files, folderCount) {
|
|
3139
|
+
const appId = zone.dataset.seedDrop;
|
|
3140
|
+
const templateId = zone.dataset.seedTemplate || appId;
|
|
3141
|
+
if (items.length !== 1 || !(folderCount || /\.zip$/i.test(files[0]?.name || ''))) {
|
|
3142
|
+
showToast(misdropMessage(zone, 'a Tekla model folder or one .zip of it', files, folderCount), 'warn');
|
|
3143
|
+
return;
|
|
3144
|
+
}
|
|
3145
|
+
if (teklaDropReading) {
|
|
3146
|
+
showToast('FloLess is still reading the Tekla model you dropped a moment ago, so nothing new was opened. Wait for its project setup to open, then drop again if you need to.', 'warn');
|
|
3147
|
+
return;
|
|
3148
|
+
}
|
|
3149
|
+
const label = items[0].getAsFile?.()?.name || 'the Tekla model';
|
|
3150
|
+
const folder = folderCount ? items[0].getAsFileSystemHandle?.() : null;
|
|
3151
|
+
// A big model folder takes a while to read, and nothing else on screen moves meanwhile.
|
|
3152
|
+
const reading = folderCount ? showToast(`Reading ${label}…`, 'progress') : null;
|
|
3153
|
+
teklaDropReading = true;
|
|
3154
|
+
void (async () => {
|
|
3155
|
+
try {
|
|
3156
|
+
let source;
|
|
3157
|
+
if (!folderCount) source = teklaZipSource(files[0]);
|
|
3158
|
+
else {
|
|
3159
|
+
const handle = await folder;
|
|
3160
|
+
if (handle?.kind !== 'directory') throw new Error('FloLess couldn’t read the dropped folder, so nothing was opened. Click the card to choose the Tekla model folder instead.');
|
|
3161
|
+
source = await filesFromDirectoryHandle(handle);
|
|
3162
|
+
}
|
|
3163
|
+
// The read may have outlasted the moment: never open setup over another window or a project.
|
|
3164
|
+
if (projectSetupState || teklaSourceChoice || $landing.hidden) {
|
|
3165
|
+
throw new Error(`FloLess finished reading ${label}, but something else is open now, so nothing was opened. Drop the model on Tekla Parser again when you are ready.`);
|
|
3166
|
+
}
|
|
3167
|
+
await createFromTeklaSource(appId, templateId, source, zone.isConnected ? zone : null);
|
|
3168
|
+
} catch (error) {
|
|
3169
|
+
// Our own checks throw a plain Error that already says what to do. Anything else is the browser
|
|
3170
|
+
// failing to read a file (moved, locked, unreadable), whose message is not written for people.
|
|
3171
|
+
if (error?.name !== 'Error') console.warn('[workspaces] could not read a dropped Tekla model', error);
|
|
3172
|
+
showToast(error?.name === 'Error' && error.message ? error.message
|
|
3173
|
+
: 'FloLess couldn’t read every file of that Tekla model, so nothing was opened. Check it is still there and not open in another program, then drop it again or click the card to choose it.', 'warn');
|
|
3174
|
+
} finally {
|
|
3175
|
+
teklaDropReading = false;
|
|
3176
|
+
reading?.(true);
|
|
3177
|
+
}
|
|
3178
|
+
})();
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
// Every create card accepts the drag (so a card that takes no file can still answer the drop); off
|
|
3182
|
+
// the cards the no-drop cursor says it lands nowhere.
|
|
3183
|
+
$landing.addEventListener('dragover', dragOverLanding);
|
|
3184
|
+
function dragOverLanding(e) {
|
|
3185
|
+
if (!draggingFiles(e)) return;
|
|
2911
3186
|
e.preventDefault();
|
|
2912
|
-
zone.
|
|
2913
|
-
|
|
3187
|
+
const zone = e.target.closest('.ws-seed');
|
|
3188
|
+
if (!zone) { e.dataTransfer.dropEffect = 'none'; return; }
|
|
3189
|
+
if (zone.dataset.seedDrop) zone.classList.add('drag-over');
|
|
3190
|
+
}
|
|
2914
3191
|
$landing.addEventListener('dragleave', (e) => {
|
|
2915
3192
|
const zone = e.target.closest('[data-seed-drop]');
|
|
2916
3193
|
if (zone && !zone.contains(e.relatedTarget)) zone.classList.remove('drag-over');
|
|
2917
3194
|
});
|
|
2918
|
-
$landing.addEventListener('drop',
|
|
2919
|
-
|
|
2920
|
-
if (!
|
|
3195
|
+
$landing.addEventListener('drop', dropOnLanding);
|
|
3196
|
+
function dropOnLanding(e) {
|
|
3197
|
+
if (!draggingFiles(e)) return;
|
|
2921
3198
|
e.preventDefault();
|
|
2922
|
-
zone.
|
|
2923
|
-
|
|
3199
|
+
const zone = e.target.closest('.ws-seed');
|
|
3200
|
+
if (!zone) return;
|
|
3201
|
+
if (!zone.dataset.seedDrop) { showToast(cardDropWarning(zone), 'warn'); return; }
|
|
3202
|
+
const items = Array.from(e.dataTransfer.items || []).filter((item) => item.kind === 'file');
|
|
3203
|
+
const isFolder = items.map((item) => !!item.webkitGetAsEntry?.()?.isDirectory);
|
|
3204
|
+
const folderCount = isFolder.filter(Boolean).length;
|
|
3205
|
+
// A dropped folder also comes through as an empty file named like the folder ("plans.pdf"
|
|
3206
|
+
// included), so the files are taken from the non-folder items only.
|
|
3207
|
+
const files = items.filter((_, i) => !isFolder[i]).map((item) => item.getAsFile()).filter(Boolean);
|
|
2924
3208
|
// Same two ids as the click path — the dropzone IS the seed button, so it carries both.
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
3209
|
+
const appId = zone.dataset.seedDrop;
|
|
3210
|
+
const templateId = zone.dataset.seedTemplate || appId;
|
|
3211
|
+
const kind = zone.dataset.seedDropKind;
|
|
3212
|
+
if (kind === 'tekla-source') { dropTeklaSource(zone, items, files, folderCount); return; }
|
|
3213
|
+
if (kind === 'rvt') {
|
|
3214
|
+
if (files.length === 1 && !folderCount && /\.rvt$/i.test(files[0].name)) createFromRvt(appId, templateId, files[0]);
|
|
3215
|
+
else showToast(misdropMessage(zone, 'one Revit .rvt file', files, folderCount), 'warn');
|
|
3216
|
+
return;
|
|
2933
3217
|
}
|
|
2934
|
-
|
|
3218
|
+
const drawings = files.filter(isDrawingFile);
|
|
3219
|
+
if (!drawings.length) { showToast(misdropMessage(zone, DRAWING_FORMATS, files, folderCount), 'warn'); return; }
|
|
3220
|
+
if (workspaceWorkflowKnownMissing(appId)) { showToast(missingWorkspaceWorkflowMessage(templateId), 'warn'); return; }
|
|
3221
|
+
const skippedFiles = files.length - drawings.length;
|
|
3222
|
+
const skipped = [
|
|
3223
|
+
skippedFiles && `Skipped ${skippedFiles} ${skippedFiles === 1 ? 'file that isn’t a PDF or image' : 'files that aren’t PDFs or images'}.`,
|
|
3224
|
+
folderCount && `Skipped ${folderCount === 1 ? '1 folder' : `${folderCount} folders`}: folders aren’t opened, so drop the drawings inside instead.`,
|
|
3225
|
+
].filter(Boolean);
|
|
3226
|
+
if (skipped.length) showToast(skipped.join(' '), 'warn');
|
|
3227
|
+
createFromDrawing(appId, templateId, drawings);
|
|
3228
|
+
}
|
|
2935
3229
|
|
|
2936
3230
|
async function promptName(title, label, value) {
|
|
2937
3231
|
if (!bridge.formModal) return null;
|
|
@@ -3024,8 +3318,23 @@
|
|
|
3024
3318
|
}
|
|
3025
3319
|
|
|
3026
3320
|
function projectSetupErrorMessage(error) {
|
|
3321
|
+
// A sentence the server wrote for the person (#1965 review) — what to fix, or what restarting costs —
|
|
3322
|
+
// names their own folders, so it is shown as written rather than run through the filter below.
|
|
3323
|
+
const userMessage = error && typeof error.body?.userMessage === 'string' ? error.body.userMessage.trim() : '';
|
|
3324
|
+
if (userMessage) return userMessage;
|
|
3027
3325
|
const raw = String(error && error.body?.error || error && error.message || error || '');
|
|
3028
3326
|
const code = String(error && (error.code || error.body?.code) || '');
|
|
3327
|
+
// A setup refusal with no sentence for the person (#1965 review, round 3). The code covers several
|
|
3328
|
+
// causes — the parser's setup has not finished, or a check refused this project while its card shows
|
|
3329
|
+
// the ready state — so the sentence names none of them, only the card that shows what is left to do.
|
|
3330
|
+
// Never "check the folder": the folder is not what stopped it.
|
|
3331
|
+
if (code === 'setup-unavailable') {
|
|
3332
|
+
const product = WORKSPACE_APPS[projectSetupState?.templateId]?.displayName;
|
|
3333
|
+
return product
|
|
3334
|
+
? `${product} can’t create projects right now, so this project wasn’t created. Do what the ${product} card says, `
|
|
3335
|
+
+ 'waiting first if it is still setting up, then try again. If the card shows no problem and this keeps happening, use Report an issue.'
|
|
3336
|
+
: 'This project can’t be created right now. Try again in a moment; if this keeps happening, use Report an issue.';
|
|
3337
|
+
}
|
|
3029
3338
|
if (code === 'not-installed') return missingWorkspaceWorkflowMessage(projectSetupState?.templateId);
|
|
3030
3339
|
if (code === 'chat-provider-unavailable' || /sign in|provider .* unavailable|chat providers are not configured/i.test(raw)) {
|
|
3031
3340
|
return 'Sign in to Claude or Codex before starting this project in AI Chat. You can still create the project only.';
|
|
@@ -3677,14 +3986,25 @@
|
|
|
3677
3986
|
|
|
3678
3987
|
function teklaAdmissionMessage(error) {
|
|
3679
3988
|
const message = error?.message || String(error || '');
|
|
3989
|
+
// The server's copy-limit refusals (tekla-source-upload.ts / tekla-source-package.ts): sizes and counts.
|
|
3990
|
+
const TEKLA_COPY_LIMIT = /^Tekla (?:ZIP|folder upload|source package)\b[^.]*\bexceeds? (?:its|their) (?:limit|compressed byte limit|total byte limit)$/;
|
|
3680
3991
|
// #1849: reading without some catalogue files needs a newer AWARE; the server names the version.
|
|
3681
3992
|
const degradedAware = /needs AWARE (\d+\.\d+\.\d+) or newer/.exec(message);
|
|
3682
3993
|
if (degradedAware) return /could not check which AWARE/.test(message)
|
|
3683
3994
|
? `Reading a model without some of its catalogue files needs AWARE ${degradedAware[1]} or newer, and FloLess could not check which AWARE this computer has. Restart FloLess so it can check AWARE again, then choose the model again. Or add the missing files and read it with them. The source model was not changed.`
|
|
3684
3995
|
: `Reading a model without some of its catalogue files needs AWARE ${degradedAware[1]} or newer. Use Upgrade AWARE at the bottom of the window, then choose the model again. Or add the missing files and read it with them. The source model was not changed.`;
|
|
3996
|
+
// #1974: the server measured the model and names its size, the limit and what to do; show it as written.
|
|
3997
|
+
// The sentence is teklaModelTooLargeMessage's (server/tekla-model-size.ts); tekla-upload-ui.test.ts
|
|
3998
|
+
// drives this through that real function, so a reword there goes red here.
|
|
3999
|
+
if (/^This Tekla model is too large for Tekla Parser to read\. /.test(message)) return message;
|
|
4000
|
+
// The copy limits (file size, total size, file count) lump several causes, so one sentence names none;
|
|
4001
|
+
// choosing the same source again can never pass them.
|
|
4002
|
+
if (TEKLA_COPY_LIMIT.test(message)) return 'This Tekla source is larger than FloLess can copy for one read. Choose a smaller copy of the model, for example one with only the phases or areas you need. The source model was not changed.';
|
|
3685
4003
|
if (/No upload progress was detected for 30 seconds/i.test(message)) return 'No upload progress was detected for 30 seconds, so FloLess stopped this copy. No partial snapshot was saved, and the source ZIP was not changed.';
|
|
3686
4004
|
if (/upload made no progress for 2 minutes/i.test(message)) return 'The Tekla ZIP upload made no progress for 2 minutes, so FloLess stopped this copy. No partial snapshot was saved, and the source ZIP was not changed.';
|
|
3687
4005
|
if (/413|too large|payload too large/i.test(message)) return 'This Tekla ZIP is too large to copy in one read. Choose the model folder instead, or make a smaller ZIP and try again.';
|
|
4006
|
+
// Checked before the access branch below: its sentence mentions access, but signing in won't help.
|
|
4007
|
+
if (error?.code === 'access-renewal-unreachable') return message;
|
|
3688
4008
|
if (/401|403|sign.?in|unauthori[sz]ed|forbidden|access/i.test(message)) return 'FloLess could not confirm access for this read. Sign in again, then choose the Tekla source once more.';
|
|
3689
4009
|
if (/failed to fetch|network|browser could not copy|source copy failed/i.test(message)) return 'FloLess could not finish copying this Tekla source. Check the connection, then choose the source again.';
|
|
3690
4010
|
if (/layout|format|framing|integrity|verif|manifest|database/i.test(message)) return 'FloLess could not verify this Tekla source. Choose the model folder or ZIP again. The source model was not changed.';
|
|
@@ -3692,7 +4012,11 @@
|
|
|
3692
4012
|
}
|
|
3693
4013
|
function teklaAdmissionTitle(error) {
|
|
3694
4014
|
const message = error?.message || String(error || '');
|
|
3695
|
-
|
|
4015
|
+
const TEKLA_COPY_LIMIT = /^Tekla (?:ZIP|folder upload|source package)\b[^.]*\bexceeds? (?:its|their) (?:limit|compressed byte limit|total byte limit)$/; // as in teklaAdmissionMessage
|
|
4016
|
+
if (TEKLA_COPY_LIMIT.test(message)) return 'This Tekla source is too large for one read';
|
|
4017
|
+
const tooLarge = /^This Tekla model is too large for Tekla Parser to read\. .* Tekla Parser reads up to (\d+(?:\.\d)? [MG]B)\./.exec(message);
|
|
4018
|
+
return tooLarge ? `This Tekla model is over the ${tooLarge[1]} read limit`
|
|
4019
|
+
: /No upload progress was detected for 30 seconds/i.test(message) ? 'Tekla ZIP copy stopped'
|
|
3696
4020
|
: /needs AWARE \d+\.\d+\.\d+ or newer/.test(message) ? 'Update AWARE to read without catalogue files'
|
|
3697
4021
|
: /layout|format|framing/i.test(message)
|
|
3698
4022
|
? 'We can’t safely read this model yet' : 'Tekla source needs attention';
|
|
@@ -3783,7 +4107,26 @@
|
|
|
3783
4107
|
async function readReplacementSourceState(project) {
|
|
3784
4108
|
if (!project || current?.id !== project.id) return null;
|
|
3785
4109
|
const tekla = wsDescOf(project) === WORKSPACE_APPS['tekla-parser'];
|
|
3786
|
-
const
|
|
4110
|
+
const read = () => api(`/api/${tekla ? 'tekla' : 'revit'}-projects/${encodeURIComponent(project.id)}/source-state`);
|
|
4111
|
+
// source-state judges from the cached 15-minute access lease without renewing it, while the
|
|
4112
|
+
// upload route renews first. A lapsed copy answers canReplace:false, or refuses the read with 403
|
|
4113
|
+
// when no verified snapshot is stored yet; either would tell the person to sign in again. The
|
|
4114
|
+
// status route renews the lease, so renew once and ask again before calling access gone.
|
|
4115
|
+
let response = null;
|
|
4116
|
+
try { response = await read(); }
|
|
4117
|
+
catch (error) { if (error?.status !== 403) throw error; }
|
|
4118
|
+
if (response?.state?.canReplace !== true) {
|
|
4119
|
+
let renewal = null;
|
|
4120
|
+
try { renewal = await api('/api/license/status'); }
|
|
4121
|
+
catch (error) { console.warn('[workspaces] could not renew the access lease before a source read', error); }
|
|
4122
|
+
if (current?.id !== project.id) return null;
|
|
4123
|
+
if (!renewal || renewal.desktopAccess?.state === 'unavailable') {
|
|
4124
|
+
// `unavailable` covers several causes, so the sentence names none of them.
|
|
4125
|
+
throw Object.assign(new Error('FloLess could not renew this computer’s access just now, so nothing was read. Try again in a moment. If it keeps happening, restart FloLess.'),
|
|
4126
|
+
{ code: 'access-renewal-unreachable' });
|
|
4127
|
+
}
|
|
4128
|
+
response = await read();
|
|
4129
|
+
}
|
|
3787
4130
|
return current?.id === project.id ? response.state : null;
|
|
3788
4131
|
}
|
|
3789
4132
|
|
|
@@ -5249,6 +5592,9 @@
|
|
|
5249
5592
|
// (paintExports), and it never reads approvedAt: that field is compatibility metadata only, as
|
|
5250
5593
|
// the approvalState declaration above says.
|
|
5251
5594
|
const approvalDecisionLabel = (decision) => decision === 'approve' ? 'Approve this change' : 'Leave pending';
|
|
5595
|
+
// A whole-model review has one human sign-off in the footer, not a per-change selection.
|
|
5596
|
+
const approvalReviewDecisions = (review, decisions) => review.selective === false
|
|
5597
|
+
? Object.fromEntries((review.groups || []).map((group) => [group.id, 'approve'])) : decisions;
|
|
5252
5598
|
let modelContractSaveState = null;
|
|
5253
5599
|
window.addEventListener('message', (event) => {
|
|
5254
5600
|
const message = event.data;
|
|
@@ -5288,7 +5634,9 @@
|
|
|
5288
5634
|
$approvalReload.hidden = phase !== 'stale';
|
|
5289
5635
|
$approvalClose.hidden = !['approved', 'abandoned', 'recovery-close'].includes(phase);
|
|
5290
5636
|
$approvalConfirm.hidden = !['ready', 'abandoned'].includes(phase);
|
|
5291
|
-
|
|
5637
|
+
// Unlocking never re-enables a control the review blocked with a reason (nothing drawn, or a
|
|
5638
|
+
// refusal no new choice can fix): it stays disabled, and focus skips it.
|
|
5639
|
+
$approvalBody.querySelectorAll('[data-approval-decision],[data-approval-conflict],[data-approval-discard],[data-approval-open-audit]').forEach((node) => { node.disabled = locked || node.hasAttribute('data-blocked-reason'); });
|
|
5292
5640
|
if (phase === 'saving' || phase === 'comparing') {
|
|
5293
5641
|
const text = message || approvalPhaseText[phase];
|
|
5294
5642
|
$approvalBody.innerHTML = `<div class="approval-loading"><span class="rtn-spinner" aria-hidden="true"></span><span aria-hidden="true">${escapeHtml(text)}</span></div>`;
|
|
@@ -5303,11 +5651,121 @@
|
|
|
5303
5651
|
}
|
|
5304
5652
|
}
|
|
5305
5653
|
|
|
5654
|
+
// ── Open Tekla import findings (#1840) ──────────────────────────────────────────────────────
|
|
5655
|
+
// A Tekla copy can carry open Audit findings. Approval no longer refuses them late: the review
|
|
5656
|
+
// warns first, and approving the change IS the person's acceptance of them as stated assumptions
|
|
5657
|
+
// (the decision button says so). Nothing is preselected, so nothing can be approved by accident.
|
|
5658
|
+
// Group names and order are the Audit tab's own (web/revit-editor.js renderTeklaAudit).
|
|
5659
|
+
const IMPORT_FINDING_GROUP_LABELS = Object.freeze({
|
|
5660
|
+
'missing-source-files': 'Missing source files', 'not-shown': 'Not shown',
|
|
5661
|
+
'fit-not-confirmed': 'Fit not confirmed', 'shape-not-evaluated': 'Shape detail not evaluated',
|
|
5662
|
+
});
|
|
5663
|
+
// Refusals the server answers BEFORE anything is written for this operation. A question the person
|
|
5664
|
+
// answers by choosing again; nothing drawn and the unfixable ones lock Approve with the server's
|
|
5665
|
+
// sentence, because the same request can never succeed (no retry offer, no reconcile loop).
|
|
5666
|
+
const IMPORT_FINDINGS_QUESTION_CODES = ['import-findings-acceptance-required', 'import-findings-acceptance-stale'];
|
|
5667
|
+
const IMPORT_FINDINGS_UNFIXABLE_CODES = ['import-findings-acceptance-invalid', 'import-findings-unreadable'];
|
|
5668
|
+
const IMPORT_FINDINGS_REFUSAL_CODES = [...IMPORT_FINDINGS_QUESTION_CODES, 'tekla-nothing-drawn', ...IMPORT_FINDINGS_UNFIXABLE_CODES];
|
|
5669
|
+
function importFindingsCopy(findings) {
|
|
5670
|
+
const n = Number(findings && findings.open) || 0;
|
|
5671
|
+
const one = n === 1;
|
|
5672
|
+
const count = n.toLocaleString('en-US');
|
|
5673
|
+
const openPhrase = one ? '1 import finding is open' : `${count} import findings are open`;
|
|
5674
|
+
return {
|
|
5675
|
+
title: one ? '1 import finding is still open' : `${count} import findings are still open`,
|
|
5676
|
+
body: `FloLess could not fully check part of this Tekla model when it read it. You can leave the model pending, or approve it and record that you accepted ${one ? 'this finding' : 'these findings'} as stated assumptions. Either way, the Audit tab keeps listing ${one ? 'it' : 'them'}.`,
|
|
5677
|
+
// While Approve is locked, the warning offers only what is possible: leaving the model pending.
|
|
5678
|
+
blockedBody: `FloLess could not fully check part of this Tekla model when it read it. This copy cannot be approved as it is, so leave it pending. The Audit tab keeps listing the ${one ? 'finding' : 'findings'}.`,
|
|
5679
|
+
approve: `Approve with ${count} ${one ? 'finding' : 'findings'} accepted`,
|
|
5680
|
+
noneChosen: 'Nothing will be approved until you choose.',
|
|
5681
|
+
leave: `Nothing will be approved. The model stays pending: ${openPhrase}.`,
|
|
5682
|
+
accept: `The model will be approved with ${count} open import ${one ? 'finding' : 'findings'} accepted.`,
|
|
5683
|
+
left: `Nothing was approved. The model stays pending: ${openPhrase}.`,
|
|
5684
|
+
approved: (version) => `Approved${version ? ` as v${version}` : ''} with ${count} open import ${one ? 'finding' : 'findings'} accepted.`,
|
|
5685
|
+
};
|
|
5686
|
+
}
|
|
5687
|
+
/** The groups, only when they add up to the total the server sealed (never a partial breakdown). */
|
|
5688
|
+
function importFindingGroups(findings) {
|
|
5689
|
+
const groups = Array.isArray(findings && findings.groups) ? findings.groups.filter((group) => group && IMPORT_FINDING_GROUP_LABELS[group.key] && Number(group.count) > 0) : [];
|
|
5690
|
+
return groups.reduce((sum, group) => sum + Number(group.count), 0) === Number(findings && findings.open) ? groups : [];
|
|
5691
|
+
}
|
|
5692
|
+
function importFindingsWarningHtml(findings, blocked = false) {
|
|
5693
|
+
const copy = importFindingsCopy(findings);
|
|
5694
|
+
const groups = importFindingGroups(findings);
|
|
5695
|
+
const list = groups.length
|
|
5696
|
+
? `<ul class="approval-findings-list" aria-label="Open findings by kind">${groups.map((group) => `<li><span>${escapeHtml(IMPORT_FINDING_GROUP_LABELS[group.key])}</span><span class="approval-findings-count">${escapeHtml(Number(group.count).toLocaleString('en-US'))}</span></li>`).join('')}</ul>`
|
|
5697
|
+
: '';
|
|
5698
|
+
return '<section class="approval-notice approval-notice-warn approval-findings" aria-labelledby="approval-findings-title" aria-describedby="approval-findings-meaning">'
|
|
5699
|
+
+ `<div class="approval-findings-head"><b id="approval-findings-title">${escapeHtml(copy.title)}</b>`
|
|
5700
|
+
+ '<button type="button" class="btn-mini" data-approval-open-audit data-command-id="shell.approval-open-audit" data-tip="Close this review and show the findings in the Audit tab. Nothing is approved.">Open Audit tab</button></div>'
|
|
5701
|
+
+ `<p id="approval-findings-meaning">${escapeHtml(blocked ? copy.blockedBody : copy.body)}</p>${list}</section>`;
|
|
5702
|
+
}
|
|
5703
|
+
const NOTHING_DRAWN_BLOCKED = 'Nothing in this copy could be drawn in 3D, so it cannot be approved yet.';
|
|
5704
|
+
// An unfixable refusal whose server sentence says nothing beyond "Nothing was approved.": the lock
|
|
5705
|
+
// still needs a reason, true for every unfixable code, and never a question.
|
|
5706
|
+
const IMPORT_FINDINGS_UNFIXABLE_FALLBACK = 'FloLess cannot approve this copy as it is.';
|
|
5707
|
+
// After an unfixable refusal nothing in this review can change the answer, and reopening it gives the
|
|
5708
|
+
// same stop, so the notice offers only what is true: close it, and the model stays pending.
|
|
5709
|
+
const APPROVAL_LEAVE_PENDING_NOTE = 'Close this review to leave the model pending.';
|
|
5710
|
+
// A move-forward overlap choice the render disables follows its linked change's decision; the
|
|
5711
|
+
// Instructor says so, and the phase code keeps it disabled (it carries a blocked reason).
|
|
5712
|
+
const APPROVAL_CONFLICT_BLOCKED = 'This choice follows the decision for its linked change.';
|
|
5713
|
+
/**
|
|
5714
|
+
* One decision button. Each is its own Instructor command: approving a copy with open import
|
|
5715
|
+
* findings IS accepting them, so that button never narrates as a plain "Approve".
|
|
5716
|
+
*/
|
|
5717
|
+
function approvalDecisionButtonHtml(group, decision, picked, findingsCopy, blockedReason) {
|
|
5718
|
+
// The command id half is a literal in each branch; only the instance after "#" is data.
|
|
5719
|
+
const carrier = decision === 'leave-pending' ? `data-command-id="shell.approval-decision-leave-pending#${escapeAttr(group.id)}"`
|
|
5720
|
+
: findingsCopy ? `data-command-id="shell.approval-decision-accept-findings#${escapeAttr(group.id)}"`
|
|
5721
|
+
: `data-command-id="shell.approval-decision-approve#${escapeAttr(group.id)}"`;
|
|
5722
|
+
const blocked = decision === 'approve' && blockedReason
|
|
5723
|
+
? ` disabled data-tip="${escapeAttr(blockedReason)}" data-blocked-reason="${escapeAttr(blockedReason)}"` : '';
|
|
5724
|
+
return `<button type="button" role="radio" aria-checked="${String(picked === decision)}" class="${picked === decision ? 'selected' : ''}" data-approval-decision="${decision}" data-group-id="${escapeAttr(group.id)}" ${carrier} data-command-instance-label="${escapeAttr(String(group.headline || group.category || 'Change'))}"${blocked}>`
|
|
5725
|
+
+ `${escapeHtml(decision === 'approve' && findingsCopy ? findingsCopy.approve : approvalDecisionLabel(decision))}</button>`;
|
|
5726
|
+
}
|
|
5727
|
+
/** The kept hard stop the review can show in advance: a copy with nothing drawn in 3D. */
|
|
5728
|
+
function nothingDrawnHtml(nothingDrawn) {
|
|
5729
|
+
return '<section class="approval-notice approval-notice-warn approval-findings" aria-labelledby="approval-nothing-drawn-title">'
|
|
5730
|
+
+ '<div class="approval-findings-head"><b id="approval-nothing-drawn-title">Nothing to approve yet</b>'
|
|
5731
|
+
+ '<button type="button" class="btn-mini" data-approval-open-audit data-command-id="shell.approval-open-audit" data-tip="Close this review and show the findings in the Audit tab. Nothing is approved.">Open Audit tab</button></div>'
|
|
5732
|
+
+ `<p>${escapeHtml(String(nothingDrawn.error))}</p></section>`;
|
|
5733
|
+
}
|
|
5734
|
+
/**
|
|
5735
|
+
* The other kept hard stop the review shows in advance: a copy whose open import findings this
|
|
5736
|
+
* version of FloLess cannot read, so they can be neither shown nor accepted (the server's sentence).
|
|
5737
|
+
*/
|
|
5738
|
+
function unreadableFindingsHtml(unreadable) {
|
|
5739
|
+
return '<section class="approval-notice approval-notice-warn approval-findings" aria-labelledby="approval-unreadable-findings-title">'
|
|
5740
|
+
+ '<div class="approval-findings-head"><b id="approval-unreadable-findings-title">Import findings cannot be read</b></div>'
|
|
5741
|
+
+ `<p>${escapeHtml(approvalRefusalDetail(unreadable.error))}</p></section>`;
|
|
5742
|
+
}
|
|
5743
|
+
/** A server sentence shown under a bold "Nothing was approved." without saying it twice. */
|
|
5744
|
+
const approvalRefusalDetail = (sentence) => String(sentence || '').replace(/\s*Nothing was approved\.\s*/g, ' ').trim();
|
|
5745
|
+
/** Refusals whose sentence the server writes for people. Any other error text (a bake or compile
|
|
5746
|
+
* message, an internal conflict) stays behind the generic copy instead of reaching the screen. */
|
|
5747
|
+
const APPROVAL_REASON_CODES = ['tekla-approval-refused', 'grant-unavailable', ...IMPORT_FINDINGS_REFUSAL_CODES];
|
|
5748
|
+
function knownApprovalFailureReason(error) {
|
|
5749
|
+
const body = error && error.body;
|
|
5750
|
+
if (!body || typeof body.error !== 'string' || !body.error.trim()) return '';
|
|
5751
|
+
return APPROVAL_REASON_CODES.includes(body.code) ? body.error.trim() : '';
|
|
5752
|
+
}
|
|
5753
|
+
|
|
5306
5754
|
function renderApprovalReview() {
|
|
5307
5755
|
if (!approvalDialogState) return;
|
|
5308
5756
|
const review = approvalDialogState.review;
|
|
5309
5757
|
const groups = Array.isArray(review.groups) ? review.groups : [];
|
|
5310
|
-
const
|
|
5758
|
+
const findings = review.importFindings && Number(review.importFindings.open) > 0 ? review.importFindings : null;
|
|
5759
|
+
const findingsCopy = findings ? importFindingsCopy(findings) : null;
|
|
5760
|
+
const nothingDrawn = review.nothingDrawn && typeof review.nothingDrawn.error === 'string' ? review.nothingDrawn : null;
|
|
5761
|
+
const unreadable = !nothingDrawn && review.unreadableFindings && typeof review.unreadableFindings.error === 'string'
|
|
5762
|
+
? review.unreadableFindings : null;
|
|
5763
|
+
// Why Approve is unavailable, when it is: nothing drawn, findings this build cannot read (both
|
|
5764
|
+
// served in advance), or a refusal no new choice can fix.
|
|
5765
|
+
const blockedReason = nothingDrawn ? NOTHING_DRAWN_BLOCKED
|
|
5766
|
+
: unreadable ? approvalRefusalDetail(unreadable.error) || IMPORT_FINDINGS_UNFIXABLE_FALLBACK
|
|
5767
|
+
: approvalDialogState.unapprovable || '';
|
|
5768
|
+
const decisions = approvalReviewDecisions(review, approvalDialogState.decisions);
|
|
5311
5769
|
const conflicts = review.moveForward && Array.isArray(review.moveForward.conflicts) ? review.moveForward.conflicts : [];
|
|
5312
5770
|
const conflictDecisions = approvalDialogState.conflicts || {};
|
|
5313
5771
|
$approvalSub.textContent = review.moveForward
|
|
@@ -5322,9 +5780,9 @@
|
|
|
5322
5780
|
return `<section class="approval-group"><div class="approval-group-head"><div>`
|
|
5323
5781
|
+ `<span class="approval-risk ${escapeAttr(String(group.risk || 'low'))}">${escapeHtml(String(group.risk || 'low'))}</span><b>${escapeHtml(String(group.headline || group.category || 'Change'))}</b></div>`
|
|
5324
5782
|
+ `<span>${escapeHtml(String(group.location || ''))}</span></div><p>${escapeHtml(String(group.detail || ''))}</p>`
|
|
5325
|
-
+ `<div class="approval-decisions" role="radiogroup" aria-label="Decision for ${escapeAttr(String(group.headline || 'change'))}">`
|
|
5326
|
-
+ ['approve', 'leave-pending'].map((decision) =>
|
|
5327
|
-
+
|
|
5783
|
+
+ (review.selective === false ? '<p class="approval-whole-model">This review approves the entire model as one version. To keep working without approving, cancel this review.</p>' : `<div class="approval-decisions" role="radiogroup" aria-label="Decision for ${escapeAttr(String(group.headline || 'change'))}">`
|
|
5784
|
+
+ ['approve', 'leave-pending'].map((decision) => approvalDecisionButtonHtml(group, decision, picked, findingsCopy, blockedReason)).join('')
|
|
5785
|
+
+ '</div>') + `${facts}${discard}</section>`;
|
|
5328
5786
|
}).join('');
|
|
5329
5787
|
const requiredConflictDecision = (conflict) => {
|
|
5330
5788
|
const linked = (conflict.groupIds || []).map((id) => decisions[id]);
|
|
@@ -5332,26 +5790,45 @@
|
|
|
5332
5790
|
if (!linked.length || linked.every((value) => value === 'leave-pending')) return 'keep-latest-pending';
|
|
5333
5791
|
return null;
|
|
5334
5792
|
};
|
|
5793
|
+
const conflictBlocked = ` disabled data-tip="${escapeAttr(APPROVAL_CONFLICT_BLOCKED)}" data-blocked-reason="${escapeAttr(APPROVAL_CONFLICT_BLOCKED)}"`;
|
|
5335
5794
|
const conflictHtml = conflicts.map((conflict) => {
|
|
5336
5795
|
const picked = conflictDecisions[conflict.id];
|
|
5337
5796
|
const required = requiredConflictDecision(conflict);
|
|
5338
5797
|
return `<section class="approval-group approval-conflict"><div class="approval-group-head"><div><span class="approval-risk high">overlap</span><b>${escapeHtml(conflict.headline)}</b></div><span>${escapeHtml(conflict.path)}</span></div><p>${escapeHtml(conflict.detail)}</p>`
|
|
5339
5798
|
+ `<div class="approval-decisions" role="radiogroup" aria-label="Overlap decision for ${escapeAttr(conflict.path)}">`
|
|
5340
|
-
+ `<button type="button" role="radio" aria-checked="${String(picked === 'use-draft')}" class="${picked === 'use-draft' ? 'selected' : ''}" data-approval-conflict="use-draft" data-conflict-id="${escapeAttr(conflict.id)}"${required !== 'use-draft' ?
|
|
5341
|
-
+ `<button type="button" role="radio" aria-checked="${String(picked === 'keep-latest-pending')}" class="${picked === 'keep-latest-pending' ? 'selected' : ''}" data-approval-conflict="keep-latest-pending" data-conflict-id="${escapeAttr(conflict.id)}"${required !== 'keep-latest-pending' ?
|
|
5799
|
+
+ `<button type="button" role="radio" aria-checked="${String(picked === 'use-draft')}" class="${picked === 'use-draft' ? 'selected' : ''}" data-approval-conflict="use-draft" data-conflict-id="${escapeAttr(conflict.id)}"${required !== 'use-draft' ? conflictBlocked : ''}>Use my DRAFT value</button>`
|
|
5800
|
+
+ `<button type="button" role="radio" aria-checked="${String(picked === 'keep-latest-pending')}" class="${picked === 'keep-latest-pending' ? 'selected' : ''}" data-approval-conflict="keep-latest-pending" data-conflict-id="${escapeAttr(conflict.id)}"${required !== 'keep-latest-pending' ? conflictBlocked : ''}>Keep v${escapeHtml(String(review.moveForward.toVersion))} · save mine as pending</button></div></section>`;
|
|
5342
5801
|
}).join('');
|
|
5343
|
-
|
|
5802
|
+
// A refusal the server explained stays on screen across re-renders (every decision click rebuilds
|
|
5803
|
+
// the body), and the findings warning sits above the change it is about. An unfixable one says
|
|
5804
|
+
// its lock reason and that closing the review leaves the model pending, since nothing in this
|
|
5805
|
+
// review can change the answer.
|
|
5806
|
+
const unapprovable = approvalDialogState.unapprovable || '';
|
|
5807
|
+
const refusalHtml = approvalDialogState.refusal || unapprovable
|
|
5808
|
+
? `<div class="approval-notice approval-notice-error" role="alert"><b>Nothing was approved.</b> ${escapeHtml(unapprovable || approvalRefusalDetail(approvalDialogState.refusal))}${unapprovable ? ` ${escapeHtml(APPROVAL_LEAVE_PENDING_NOTE)}` : ''}</div>`
|
|
5809
|
+
: '';
|
|
5810
|
+
const findingsHtml = nothingDrawn ? nothingDrawnHtml(nothingDrawn) : unreadable ? unreadableFindingsHtml(unreadable)
|
|
5811
|
+
: findings ? importFindingsWarningHtml(findings, !!blockedReason) : '';
|
|
5812
|
+
$approvalBody.innerHTML = refusalHtml + findingsHtml + (groupHtml + conflictHtml || '<div class="approval-empty">No pending changes. The working copy already matches the latest approved version.</div>');
|
|
5344
5813
|
const values = Object.values(decisions);
|
|
5345
5814
|
const approved = values.filter((value) => value === 'approve').length;
|
|
5346
5815
|
const remaining = groups.length - values.length;
|
|
5347
5816
|
const remainingConflicts = conflicts.filter((conflict) => conflictDecisions[conflict.id] !== requiredConflictDecision(conflict)).length;
|
|
5348
|
-
$approvalCounts.textContent =
|
|
5817
|
+
$approvalCounts.textContent = blockedReason ? 'Nothing will be approved. The model stays pending.'
|
|
5818
|
+
: findingsCopy && values.length === 0 ? findingsCopy.noneChosen
|
|
5819
|
+
: findingsCopy && remaining === 0 && remainingConflicts === 0 ? (approved ? findingsCopy.accept : findingsCopy.leave)
|
|
5820
|
+
: remaining > 0 ? `${values.length} of ${groups.length} changes decided · ${remaining} still ${remaining === 1 ? 'needs' : 'need'} review`
|
|
5349
5821
|
: remainingConflicts > 0 ? `${remainingConflicts} overlap${remainingConflicts === 1 ? '' : 's'} still need a decision`
|
|
5350
5822
|
: approved ? `${approved} change${approved === 1 ? '' : 's'} will be approved · ${groups.length - approved} left pending`
|
|
5351
5823
|
: groups.length ? 'All changes will remain pending' : 'Nothing needs approval';
|
|
5352
|
-
$approvalConfirm.setAttribute('data-command-id', 'shell.approval-confirm');
|
|
5353
|
-
$approvalConfirm.
|
|
5354
|
-
$approvalConfirm.
|
|
5824
|
+
$approvalConfirm.setAttribute('data-command-id', findingsCopy ? 'shell.approval-confirm-with-findings' : 'shell.approval-confirm');
|
|
5825
|
+
if (blockedReason) $approvalConfirm.setAttribute('data-blocked-reason', blockedReason);
|
|
5826
|
+
else $approvalConfirm.removeAttribute('data-blocked-reason');
|
|
5827
|
+
// A whole-model review (#1990) has its one sign-off here; with open findings, this IS the acceptance (#1840).
|
|
5828
|
+
$approvalConfirm.textContent = approved && findingsCopy ? findingsCopy.approve
|
|
5829
|
+
: review.selective === false && groups.length ? 'Approve entire model'
|
|
5830
|
+
: approved ? `Approve ${approved} change${approved === 1 ? '' : 's'}` : 'Approve selected changes';
|
|
5831
|
+
$approvalConfirm.disabled = remaining !== 0 || remainingConflicts !== 0 || approved === 0 || groups.length === 0 || approvalDialogState.stale || !!blockedReason;
|
|
5355
5832
|
}
|
|
5356
5833
|
|
|
5357
5834
|
function closeApprovalReview() {
|
|
@@ -5361,7 +5838,17 @@
|
|
|
5361
5838
|
approvalDialogState = null;
|
|
5362
5839
|
$approvalModal.classList.remove('show');
|
|
5363
5840
|
$approvalModal.removeAttribute('aria-busy');
|
|
5841
|
+
// The confirm button outlives this review: a reason it was blocked for must not follow it into
|
|
5842
|
+
// the next project's dialog, where the Instructor would read it out.
|
|
5843
|
+
$approvalConfirm.removeAttribute('data-blocked-reason');
|
|
5364
5844
|
if (st && st.returnFocus && st.returnFocus.isConnected) st.returnFocus.focus();
|
|
5845
|
+
// #1840: an explicit Leave pending on a copy with open findings ends with its reason, so the
|
|
5846
|
+
// person is told why nothing was approved after the dialog has gone.
|
|
5847
|
+
const findings = st && st.phase === 'ready' && st.review && st.review.importFindings;
|
|
5848
|
+
if (findings && Number(findings.open) > 0 && Object.values(st.decisions || {}).includes('leave-pending')
|
|
5849
|
+
&& !Object.values(st.decisions || {}).includes('approve')) {
|
|
5850
|
+
showToast(importFindingsCopy(findings).left, 'info');
|
|
5851
|
+
}
|
|
5365
5852
|
}
|
|
5366
5853
|
|
|
5367
5854
|
const approvalOperationStoragePrefix = 'floless:approval-operation:v1';
|
|
@@ -5429,17 +5916,24 @@
|
|
|
5429
5916
|
await refreshApprovalState(project.id);
|
|
5430
5917
|
const pending = Number.isInteger(Number(res && res.pendingCount)) ? Number(res.pendingCount) : approvalState.pendingCount;
|
|
5431
5918
|
const saved = res && res.savedWorkCheckpoint;
|
|
5432
|
-
|
|
5919
|
+
// #1840: the outcome says what the server recorded. An approval that accepted open import
|
|
5920
|
+
// findings is never announced as a plain "Approved".
|
|
5921
|
+
const accepted = res && res.version && res.version.approval && res.version.approval.acceptedImportFindings;
|
|
5922
|
+
const headline = accepted ? importFindingsCopy(accepted).approved(Number.isInteger(n) ? n : null)
|
|
5923
|
+
: `Approved${Number.isInteger(n) ? ` as v${n}` : ''}.`;
|
|
5924
|
+
showToast(`${headline} ${pending ? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}; approved exports omit them unless you explicitly choose DRAFT.` : 'No changes remain pending.'}`, 'ok');
|
|
5433
5925
|
track('workspace_project_approved', { app: project.app });
|
|
5434
5926
|
if (bridge.markWorkspaceApproved && wsDescOf(project)?.docGuide) bridge.markWorkspaceApproved(project.app);
|
|
5435
5927
|
if (!$wsExports.hidden) safeRenderExports('after approving this version');
|
|
5436
5928
|
if (!$wsHistory.hidden) await renderHistory();
|
|
5437
5929
|
if (!approvalDialogState) return;
|
|
5438
5930
|
$approvalImpact.textContent = pending
|
|
5439
|
-
? `${pending} change${pending === 1 ? '' : 's'}
|
|
5931
|
+
? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}.`
|
|
5440
5932
|
: 'No changes remain pending.';
|
|
5441
|
-
|
|
5442
|
-
|
|
5933
|
+
// The footer described the decision ("…will be approved…"); the decision has happened.
|
|
5934
|
+
$approvalCounts.textContent = '';
|
|
5935
|
+
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> The approved model and compiled workflow are ready.${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
|
|
5936
|
+
setApprovalPhase('approved', accepted ? headline : `Approved${Number.isInteger(n) ? ` as v${n}` : ''}`);
|
|
5443
5937
|
$approvalClose.focus();
|
|
5444
5938
|
}
|
|
5445
5939
|
|
|
@@ -5467,7 +5961,11 @@
|
|
|
5467
5961
|
$approvalClose.focus();
|
|
5468
5962
|
}
|
|
5469
5963
|
|
|
5470
|
-
|
|
5964
|
+
// `reason` is the server's own sentence when the failed request stated one (#1840). On this path,
|
|
5965
|
+
// "Nothing was approved" is said because the reconcile answered `abandoned` (the operation was
|
|
5966
|
+
// retired with no committed row); the reason says WHY, instead of generic recovery copy. (A refusal
|
|
5967
|
+
// made before any write says it in the review itself; see confirmApprovalReview.)
|
|
5968
|
+
function showAbandonedApprovalRecovery(project, reason = '') {
|
|
5471
5969
|
const st = approvalDialogState;
|
|
5472
5970
|
if (!st) return;
|
|
5473
5971
|
rememberApprovalOperation(project, null);
|
|
@@ -5479,8 +5977,10 @@
|
|
|
5479
5977
|
$approvalSub.textContent = 'The previous approval attempt ended safely.';
|
|
5480
5978
|
$approvalImpact.textContent = '';
|
|
5481
5979
|
$approvalCounts.textContent = '';
|
|
5482
|
-
|
|
5980
|
+
const detail = approvalRefusalDetail(reason);
|
|
5981
|
+
$approvalBody.innerHTML = `<div class="approval-notice"><b>Nothing was approved.</b> ${detail ? `${escapeHtml(detail)} ` : ''}FloLess restored your working copy. That approval attempt is finished and cannot be retried.</div>`;
|
|
5483
5982
|
$approvalConfirm.setAttribute('data-command-id', 'shell.approval-start-new-review');
|
|
5983
|
+
$approvalConfirm.removeAttribute('data-blocked-reason');
|
|
5484
5984
|
$approvalConfirm.textContent = 'Start a new review';
|
|
5485
5985
|
$approvalConfirm.disabled = false;
|
|
5486
5986
|
setApprovalPhase('abandoned');
|
|
@@ -5512,6 +6012,8 @@
|
|
|
5512
6012
|
$approvalImpact.textContent = '';
|
|
5513
6013
|
$approvalCounts.textContent = '';
|
|
5514
6014
|
$approvalConfirm.disabled = true;
|
|
6015
|
+
// A fresh dialog starts with no blocked reason; the review's own render sets one if it needs it.
|
|
6016
|
+
$approvalConfirm.removeAttribute('data-blocked-reason');
|
|
5515
6017
|
approvalDialogState = { projectId: project.id, review: { groups: [] }, decisions: {}, conflicts: {}, returnFocus: document.activeElement, stale: false, phase: 'comparing' };
|
|
5516
6018
|
const dialogState = approvalDialogState;
|
|
5517
6019
|
setApprovalPhase('comparing');
|
|
@@ -5590,7 +6092,7 @@
|
|
|
5590
6092
|
$approvalRetry.focus();
|
|
5591
6093
|
} else {
|
|
5592
6094
|
setApprovalPhase('ready');
|
|
5593
|
-
($approvalBody.querySelector('[data-approval-decision]') || $approvalConfirm).focus();
|
|
6095
|
+
($approvalBody.querySelector('[data-approval-decision]:not([disabled])') || $approvalConfirm).focus();
|
|
5594
6096
|
}
|
|
5595
6097
|
} catch (error) {
|
|
5596
6098
|
if (approvalDialogState !== dialogState) return;
|
|
@@ -5608,19 +6110,49 @@
|
|
|
5608
6110
|
const st = approvalDialogState;
|
|
5609
6111
|
if (!st || $approvalConfirm.disabled || !current || current.id !== st.projectId) return;
|
|
5610
6112
|
const project = current;
|
|
6113
|
+
st.decisions = approvalReviewDecisions(st.review, st.decisions);
|
|
5611
6114
|
const decisionSnapshot = { decisions: { ...st.decisions }, conflicts: { ...st.conflicts } };
|
|
5612
6115
|
const { operationId, operationToken } = ensureApprovalOperationPair(st);
|
|
5613
6116
|
rememberApprovalOperation(project, { projectId: project.id, appId: project.app, operationId, operationToken,
|
|
5614
6117
|
reviewId: st.review.reviewId, decisions: decisionSnapshot.decisions, conflicts: decisionSnapshot.conflicts });
|
|
6118
|
+
// #1840: choosing "Approve with N findings accepted" IS the acceptance. It names exactly the
|
|
6119
|
+
// contract and audit the review served (never a remembered or derived value).
|
|
6120
|
+
const findings = st.review.importFindings;
|
|
6121
|
+
const acceptOpenImportFindings = findings && Number(findings.open) > 0 && Object.values(st.decisions).includes('approve')
|
|
6122
|
+
? { contractHash: findings.contractHash, digest: findings.digest, open: findings.open } : null;
|
|
5615
6123
|
setApprovalPhase('approving');
|
|
5616
6124
|
$approvalConfirm.disabled = true;
|
|
6125
|
+
st.refusal = null;
|
|
5617
6126
|
try {
|
|
5618
6127
|
const res = await api(`/api/contract/${encodeURIComponent(project.app)}/approve?project=${encodeURIComponent(project.id)}`, {
|
|
5619
|
-
method: 'POST', body: JSON.stringify({ mode: st.review.mode || 'head', reviewId: st.review.reviewId, decisions: st.decisions, conflicts: st.conflicts, claimedChannel: 'browser', operationId, operationToken
|
|
6128
|
+
method: 'POST', body: JSON.stringify({ mode: st.review.mode || 'head', reviewId: st.review.reviewId, decisions: st.decisions, conflicts: st.conflicts, claimedChannel: 'browser', operationId, operationToken,
|
|
6129
|
+
...(acceptOpenImportFindings ? { acceptOpenImportFindings } : {}) }),
|
|
5620
6130
|
});
|
|
5621
6131
|
await finishApprovalSuccess(res, project);
|
|
5622
6132
|
} catch (error) {
|
|
5623
|
-
if (approvalDialogState && error && error.body && error.body.code
|
|
6133
|
+
if (approvalDialogState && error && error.body && IMPORT_FINDINGS_REFUSAL_CODES.includes(error.body.code)) {
|
|
6134
|
+
// Refused BEFORE anything durable was written for this operation (no claim, no recovery), so it
|
|
6135
|
+
// is never a retry. Forget the operation pair, clear the decision, re-bind the warning to the
|
|
6136
|
+
// findings of the copy that would actually be approved, and keep the reason on screen.
|
|
6137
|
+
rememberApprovalOperation(project, null);
|
|
6138
|
+
st.operationId = null;
|
|
6139
|
+
st.operationToken = null;
|
|
6140
|
+
st.decisions = {};
|
|
6141
|
+
st.conflicts = {};
|
|
6142
|
+
if (error.body.importFindings && Number(error.body.importFindings.open) > 0) st.review.importFindings = error.body.importFindings;
|
|
6143
|
+
// Nothing drawn is not a question: its own notice replaces the warning and locks Approve.
|
|
6144
|
+
if (error.body.code === 'tekla-nothing-drawn') st.review.nothingDrawn = { error: String(error.body.error || '') };
|
|
6145
|
+
else if (IMPORT_FINDINGS_UNFIXABLE_CODES.includes(error.body.code)) {
|
|
6146
|
+
// An unfixable refusal is not a question either: any choice would be refused again, so
|
|
6147
|
+
// Approve is locked BEFORE the render, keyed on the code (never on whether the sentence
|
|
6148
|
+
// happens to say more than "Nothing was approved."), and nothing offers to retry it.
|
|
6149
|
+
st.refusal = String(error.body.error || '').trim() || IMPORT_FINDINGS_UNFIXABLE_FALLBACK;
|
|
6150
|
+
st.unapprovable = approvalRefusalDetail(st.refusal) || IMPORT_FINDINGS_UNFIXABLE_FALLBACK;
|
|
6151
|
+
} else st.refusal = error.body.error || 'The import findings need your decision before approval.';
|
|
6152
|
+
renderApprovalReview();
|
|
6153
|
+
setApprovalPhase('ready', `Nothing was approved. ${st.unapprovable ? `${st.unapprovable} ${APPROVAL_LEAVE_PENDING_NOTE}` : approvalRefusalDetail(error.body.error)}`);
|
|
6154
|
+
($approvalBody.querySelector('[data-approval-decision]:not([disabled])') || $approvalDialog).focus();
|
|
6155
|
+
} else if (approvalDialogState && error && error.body && error.body.code === 'approval-review-stale') {
|
|
5624
6156
|
rememberApprovalOperation(project, null);
|
|
5625
6157
|
st.operationId = null;
|
|
5626
6158
|
st.operationToken = null;
|
|
@@ -5636,7 +6168,7 @@
|
|
|
5636
6168
|
return;
|
|
5637
6169
|
}
|
|
5638
6170
|
if (approvalRecoveryDisposition(recovered) === 'abandoned') {
|
|
5639
|
-
showAbandonedApprovalRecovery(project);
|
|
6171
|
+
showAbandonedApprovalRecovery(project, knownApprovalFailureReason(error));
|
|
5640
6172
|
return;
|
|
5641
6173
|
}
|
|
5642
6174
|
if (approvalRecoveryDisposition(recovered) === 'locked') {
|
|
@@ -5664,14 +6196,14 @@
|
|
|
5664
6196
|
try {
|
|
5665
6197
|
const review = await api(`/api/projects/${encodeURIComponent(st.projectId)}/approval-review`);
|
|
5666
6198
|
if (!approvalDialogState || approvalDialogState !== st) return;
|
|
5667
|
-
st.review = review; st.decisions = {}; st.conflicts = {}; st.stale = false;
|
|
6199
|
+
st.review = review; st.decisions = {}; st.conflicts = {}; st.stale = false; st.refusal = null; st.unapprovable = '';
|
|
5668
6200
|
st.operationId = null;
|
|
5669
6201
|
st.operationToken = null;
|
|
5670
6202
|
rememberApprovalOperation(project, null);
|
|
5671
6203
|
$approvalImpact.textContent = '';
|
|
5672
6204
|
renderApprovalReview();
|
|
5673
6205
|
setApprovalPhase('ready');
|
|
5674
|
-
($approvalBody.querySelector('[data-approval-decision]') || $approvalConfirm).focus();
|
|
6206
|
+
($approvalBody.querySelector('[data-approval-decision]:not([disabled])') || $approvalConfirm).focus();
|
|
5675
6207
|
} catch (error) {
|
|
5676
6208
|
$approvalImpact.textContent = (error && error.message) || 'Could not reload the current review.';
|
|
5677
6209
|
setApprovalPhase('stale', 'The current review could not be loaded.');
|
|
@@ -5724,6 +6256,18 @@
|
|
|
5724
6256
|
if ((conflict.groupIds || []).some((id) => id === group.id)) delete approvalDialogState.conflicts[conflict.id];
|
|
5725
6257
|
}
|
|
5726
6258
|
renderApprovalReview();
|
|
6259
|
+
// The re-render replaced the clicked button; without this, focus fell to <body> and Esc and the
|
|
6260
|
+
// dialog's Tab trap (both on the modal) stopped working after a keyboard decision.
|
|
6261
|
+
const again = $approvalBody.querySelector(`[data-approval-decision="${CSS.escape(decision.dataset.approvalDecision)}"][data-group-id="${CSS.escape(group.id)}"]`);
|
|
6262
|
+
if (again) again.focus();
|
|
6263
|
+
return;
|
|
6264
|
+
}
|
|
6265
|
+
const openAudit = event.target.closest('[data-approval-open-audit]');
|
|
6266
|
+
if (openAudit && approvalDialogState && approvalDismissible(approvalDialogState.phase)) {
|
|
6267
|
+
// #1840: show the findings themselves. Nothing is approved; the review can be reopened.
|
|
6268
|
+
closeApprovalReview();
|
|
6269
|
+
chooseStep('model');
|
|
6270
|
+
if (window.flolessLeftPane && typeof window.flolessLeftPane.showModelTab === 'function') window.flolessLeftPane.showModelTab('audit');
|
|
5727
6271
|
return;
|
|
5728
6272
|
}
|
|
5729
6273
|
const conflict = event.target.closest('[data-approval-conflict]');
|
|
@@ -10621,7 +11165,9 @@
|
|
|
10621
11165
|
applyStageGating();
|
|
10622
11166
|
return;
|
|
10623
11167
|
}
|
|
10624
|
-
|
|
11168
|
+
// A read whose discard record cannot be read (#1874) is decided on in Requests, not here: this card's
|
|
11169
|
+
// Review/Confirm/Discard would act on a read nobody can yet say is live.
|
|
11170
|
+
const mine = reqs.filter((r) => r && r.type === 'revision-read' && r.project === proj.id && !r.discardRecordUnreadable);
|
|
10625
11171
|
// One project can retain an old failed request after the user follows its recovery instruction and
|
|
10626
11172
|
// attaches the set again. The request list is durable oldest-first; the newest lifecycle is the one
|
|
10627
11173
|
// this card must follow. Status priority hid the retry behind the old failure and stopped this poll.
|
|
@@ -11006,6 +11552,93 @@
|
|
|
11006
11552
|
try { const s = JSON.stringify(v); return s.length > 60 ? s.slice(0, 57) + '…' : s; } catch { return '…'; }
|
|
11007
11553
|
};
|
|
11008
11554
|
|
|
11555
|
+
/*
|
|
11556
|
+
* A MEMBER'S END, said the way a detailer reads it (#1903).
|
|
11557
|
+
*
|
|
11558
|
+
* A `member-changed` `from`/`to` field is a whole work point `{x, y, z}`, and `shortVal` of that is a
|
|
11559
|
+
* 57-character JSON cut — `{"x":1234.5,"y":…` — on a consent screen. Since #1903 the commonest such row
|
|
11560
|
+
* is a height the PERSON answered on a question card for a member already in the model, proposed here
|
|
11561
|
+
* rather than written straight in. So an endpoint field is drawn as its own lines: the height, and x and
|
|
11562
|
+
* y too whenever they move (accepting the row moves the whole point, so a moved point is never hidden
|
|
11563
|
+
* behind its height). Values are in the project's display units through the shared helper, loaded when
|
|
11564
|
+
* the review opens; until then they read in millimetres rather than not at all.
|
|
11565
|
+
*/
|
|
11566
|
+
let reviewUnitsModule = null;
|
|
11567
|
+
// Preloaded once, here, rather than awaited inside `openRevisionReview`: that function is lifted whole
|
|
11568
|
+
// into test harnesses, where a free name it assigns would not exist. A review opened before this
|
|
11569
|
+
// settles (a fresh page, a slow disk) reads in millimetres, never in nothing.
|
|
11570
|
+
import('./display-units.js').then((m) => { reviewUnitsModule = m; }, () => {});
|
|
11571
|
+
const reviewUnits = () => (current && current.displayUnits === 'mm' ? 'mm' : 'ft-in');
|
|
11572
|
+
const reviewElevation = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatElevation(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
11573
|
+
const reviewLength = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatLength(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
11574
|
+
const isEndpointValue = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
|
|
11575
|
+
&& typeof v.x === 'number' && typeof v.y === 'number' && !!v.z && typeof v.z === 'object';
|
|
11576
|
+
const isEndpointField = (f) => (f.key === 'from' || f.key === 'to') && isEndpointValue(f.before) && isEndpointValue(f.after);
|
|
11577
|
+
const isAnsweredZ = (z) => !!z && typeof z === 'object' && !!z.answered && typeof z.answered === 'object' && typeof z.known === 'number';
|
|
11578
|
+
const endpointHeightText = (z) => {
|
|
11579
|
+
if (!z || typeof z.known !== 'number') return 'no height';
|
|
11580
|
+
return `${reviewElevation(z.known)}${z.assumed === true ? ' (placed, not from the drawings)' : ''}`;
|
|
11581
|
+
};
|
|
11582
|
+
const endWordOf = (key) => (key === 'from' ? 'Start' : 'End');
|
|
11583
|
+
function plainLine(key, before, after) {
|
|
11584
|
+
const row = revEl('div', 'rev-field');
|
|
11585
|
+
row.appendChild(revEl('span', 'rev-field-key', key));
|
|
11586
|
+
row.appendChild(revEl('span', 'hd-prof', before));
|
|
11587
|
+
row.appendChild(revEl('span', 'hd-arrow', '→'));
|
|
11588
|
+
row.appendChild(revEl('span', 'hd-prof', after));
|
|
11589
|
+
return row;
|
|
11590
|
+
}
|
|
11591
|
+
/** The lines for one endpoint field, plus the notes that say whose number the new height is. */
|
|
11592
|
+
function endpointFieldLines(f) {
|
|
11593
|
+
const lines = [], notes = [];
|
|
11594
|
+
const end = endWordOf(f.key);
|
|
11595
|
+
const b = f.before, a = f.after;
|
|
11596
|
+
const heightChanged = !canonicalEqual(b.z, a.z);
|
|
11597
|
+
// Only a height THIS read changes is "your answer" here. An answer recorded on an earlier read and
|
|
11598
|
+
// carried unchanged is not news, even when the point moves in x/y (code review).
|
|
11599
|
+
const answered = heightChanged && isAnsweredZ(a.z) ? a.z.answered : null;
|
|
11600
|
+
if (heightChanged) {
|
|
11601
|
+
const before = endpointHeightText(b.z);
|
|
11602
|
+
let after = endpointHeightText(a.z);
|
|
11603
|
+
// Same number, new record: the row exists because the height becomes the person's answer. Said, so
|
|
11604
|
+
// the line is not read as a change that changes nothing.
|
|
11605
|
+
if (before === after && answered) after += ' (your answer)';
|
|
11606
|
+
lines.push(plainLine(`${end} height`, before, after));
|
|
11607
|
+
}
|
|
11608
|
+
if (b.x !== a.x) lines.push(plainLine(`${end} x`, reviewLength(b.x), reviewLength(a.x)));
|
|
11609
|
+
if (b.y !== a.y) lines.push(plainLine(`${end} y`, reviewLength(b.y), reviewLength(a.y)));
|
|
11610
|
+
// The server proposed this field because SOMETHING in it differs. If it is none of x, y and the height
|
|
11611
|
+
// (a key this renderer does not know), fall back to the generic line rather than draw nothing.
|
|
11612
|
+
if (!lines.length) lines.push(diffLine(f.key, f.before, f.after));
|
|
11613
|
+
if (answered) {
|
|
11614
|
+
const note = revEl('div', 'rev-row-note');
|
|
11615
|
+
const how = answered.how === 'typed' ? `typed ${answered.typed || reviewElevation(a.z.known)}` : `confirmed ${answered.shownAs || reviewElevation(a.z.known)}`;
|
|
11616
|
+
note.appendChild(document.createTextNode(`You answered the ${end.toLowerCase()} height on a height question: `));
|
|
11617
|
+
note.appendChild(revEl('b', null, how));
|
|
11618
|
+
note.appendChild(document.createTextNode(answered.note ? ` (${answered.note}).` : '.'));
|
|
11619
|
+
notes.push(note);
|
|
11620
|
+
const over = answered.overDrawing;
|
|
11621
|
+
if (over && typeof over.low === 'number' && typeof over.high === 'number') {
|
|
11622
|
+
const stated = Math.abs(over.high - over.low) < 0.5 ? reviewElevation(over.low) : `between ${reviewElevation(over.low)} and ${reviewElevation(over.high)}`;
|
|
11623
|
+
const drawn = revEl('div', 'rev-row-note');
|
|
11624
|
+
drawn.appendChild(document.createTextNode('The drawings state '));
|
|
11625
|
+
drawn.appendChild(revEl('b', null, stated));
|
|
11626
|
+
drawn.appendChild(document.createTextNode(' here; accepting sets your answer instead of the drawings’ height.'));
|
|
11627
|
+
notes.push(drawn);
|
|
11628
|
+
}
|
|
11629
|
+
}
|
|
11630
|
+
// A move in x/y rides on the same tick as the answered height, so it counts as ANOTHER change.
|
|
11631
|
+
return { lines, notes, answered: !!answered, moved: b.x !== a.x || b.y !== a.y };
|
|
11632
|
+
}
|
|
11633
|
+
/** Key-order-blind equality, the same rule the server's `valuesDiffer` uses for every field. */
|
|
11634
|
+
function canonicalEqual(x, y) {
|
|
11635
|
+
const canon = (v) => JSON.stringify(v ?? null, (_k, val) => (
|
|
11636
|
+
val && typeof val === 'object' && !Array.isArray(val)
|
|
11637
|
+
? Object.fromEntries(Object.keys(val).sort().map((k) => [k, val[k]]))
|
|
11638
|
+
: val));
|
|
11639
|
+
return canon(x) === canon(y);
|
|
11640
|
+
}
|
|
11641
|
+
|
|
11009
11642
|
/** A before → after line, reusing History's existing transform chip rather than inventing one. */
|
|
11010
11643
|
function fieldLine(key, before, after) {
|
|
11011
11644
|
const row = revEl('div', 'rev-field');
|
|
@@ -11212,8 +11845,29 @@
|
|
|
11212
11845
|
const desc = [];
|
|
11213
11846
|
if (p.kind === 'member-changed' || p.kind === 'plan-changed') {
|
|
11214
11847
|
const fields = revEl('div', 'rev-fields');
|
|
11215
|
-
|
|
11848
|
+
const notes = [];
|
|
11849
|
+
let answeredEnds = 0, otherFields = 0;
|
|
11850
|
+
for (const f of p.fields || []) {
|
|
11851
|
+
if (p.kind === 'member-changed' && isEndpointField(f)) {
|
|
11852
|
+
const drawn = endpointFieldLines(f);
|
|
11853
|
+
for (const line of drawn.lines) fields.appendChild(line);
|
|
11854
|
+
notes.push(...drawn.notes);
|
|
11855
|
+
if (drawn.answered) answeredEnds += 1;
|
|
11856
|
+
if (!drawn.answered || drawn.moved) otherFields += 1;
|
|
11857
|
+
} else {
|
|
11858
|
+
fields.appendChild(fieldLine(f.key, f.before, f.after));
|
|
11859
|
+
otherFields += 1;
|
|
11860
|
+
}
|
|
11861
|
+
}
|
|
11216
11862
|
desc.push(fields);
|
|
11863
|
+
// ONE TICK TAKES THE WHOLE ROW (#1903 plan review). A height the person answered can share a row
|
|
11864
|
+
// with other changes the read proposes for the same member; accepting it takes those too, so the
|
|
11865
|
+
// row says so FIRST (design review: it is the most consequential note) rather than letting the
|
|
11866
|
+
// height stand for the whole decision.
|
|
11867
|
+
if (answeredEnds && otherFields) {
|
|
11868
|
+
desc.push(revEl('div', 'rev-row-note', 'Ticking this row also applies the other changes shown for this member.'));
|
|
11869
|
+
}
|
|
11870
|
+
desc.push(...notes);
|
|
11217
11871
|
} else if (p.kind === 'model-changed') {
|
|
11218
11872
|
const isGrid = p.key === 'grid';
|
|
11219
11873
|
const obj = (v) => v && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -12191,7 +12845,10 @@
|
|
|
12191
12845
|
author === 'You'
|
|
12192
12846
|
? '<span class="avatar you">YOU</span>'
|
|
12193
12847
|
: `<span class="avatar ai">${escapeHtml((author || '?').replace(/[^A-Za-z0-9]/g, '').slice(0, 2).toUpperCase() || 'AI')}</span>`;
|
|
12194
|
-
const gateBadge = (gate, kind, n) => {
|
|
12848
|
+
const gateBadge = (gate, kind, n, acceptedNote = '') => {
|
|
12849
|
+
// #1840: a sign-off that accepted open Tekla import findings says so on its own badge too.
|
|
12850
|
+
if (gate === 'model' && acceptedNote)
|
|
12851
|
+
return `<span class="gate-badge model findings-accepted" data-tip="${escapeAttr(`Sign-off gate. ${acceptedNote}`)}">Model</span>`;
|
|
12195
12852
|
if (gate === 'model')
|
|
12196
12853
|
return '<span class="gate-badge model" data-tip="Sign-off gate — this version was approved">Model</span>';
|
|
12197
12854
|
if (kind === 'revision-read')
|
|
@@ -12351,7 +13008,7 @@
|
|
|
12351
13008
|
'data-tip="Show the complete member-by-member comparison">' +
|
|
12352
13009
|
'<span class="hd-caret">▸</span><span class="hd-toggle-label">View detailed changes</span></button>'
|
|
12353
13010
|
: '';
|
|
12354
|
-
const detailWarning = `${readinessHtml(v)}${detailReconciliationWarningHtml(v)}${shellAuthoredNoteHtml(v)}`;
|
|
13011
|
+
const detailWarning = `${acceptedImportFindingsHtml(v)}${readinessHtml(v)}${detailReconciliationWarningHtml(v)}${shellAuthoredNoteHtml(v)}`;
|
|
12355
13012
|
if (!s || !Array.isArray(s.bullets)) {
|
|
12356
13013
|
return `<div class="hist-event">${escapeHtml(v.message)}</div>${detailWarning}${toggle}`;
|
|
12357
13014
|
}
|
|
@@ -12366,6 +13023,17 @@
|
|
|
12366
13023
|
`<ul class="hist-change-list">${bullets}</ul>${cautions}${detailWarning}${toggle}`;
|
|
12367
13024
|
}
|
|
12368
13025
|
|
|
13026
|
+
/**
|
|
13027
|
+
* #1840: an approval that accepted open Tekla import findings carries the server's own sentence on
|
|
13028
|
+
* its History row (one source for every approved surface), in the caution register the readiness
|
|
13029
|
+
* notes use: the findings are still open and may still need action.
|
|
13030
|
+
*/
|
|
13031
|
+
function acceptedImportFindingsHtml(v) {
|
|
13032
|
+
const note = v && v.kind === 'approve' && typeof v.acceptedImportFindingsNote === 'string' ? v.acceptedImportFindingsNote : '';
|
|
13033
|
+
if (!note) return '';
|
|
13034
|
+
return `<div class="hist-change-caution" role="note"><strong>${escapeHtml(note)}</strong> FloLess could not fully check these when it read the model; the Audit tab lists each one.</div>`;
|
|
13035
|
+
}
|
|
13036
|
+
|
|
12369
13037
|
function readinessHtml(v) {
|
|
12370
13038
|
const ready = v && v.readiness;
|
|
12371
13039
|
if (!ready || typeof ready.state !== 'string') return '';
|
|
@@ -12404,7 +13072,7 @@
|
|
|
12404
13072
|
`<td><span class="ver${v.current ? ' cur' : ''}">v${escapeHtml(String(v.n))}</span></td>` +
|
|
12405
13073
|
`<td class="htime">${escapeHtml(histWhen(v.ts))}</td>` +
|
|
12406
13074
|
`<td><span class="hby">${avatarFor(v.author)}${escapeHtml(v.author)}</span></td>` +
|
|
12407
|
-
`<td>${gateBadge(v.gate, v.kind, v.n)}</td>` +
|
|
13075
|
+
`<td>${gateBadge(v.gate, v.kind, v.n, typeof v.acceptedImportFindingsNote === 'string' ? v.acceptedImportFindingsNote : '')}</td>` +
|
|
12408
13076
|
`<td class="change">${changeCellHtml(v, meta)}${diffStatus}</td>` +
|
|
12409
13077
|
`<td>${action}</td></tr>`;
|
|
12410
13078
|
// The disclosure row is always emitted (hidden) so toggling is a pure show/hide + lazy fetch.
|
|
@@ -12654,6 +13322,7 @@
|
|
|
12654
13322
|
if (!current) return;
|
|
12655
13323
|
const proj = current;
|
|
12656
13324
|
closeRollbackConfirm();
|
|
13325
|
+
let restoreRequested = false;
|
|
12657
13326
|
try {
|
|
12658
13327
|
const win = frames.model && frames.model.contentWindow;
|
|
12659
13328
|
// History owns the server-side working revision. Its hidden editor can still hold the
|
|
@@ -12668,6 +13337,7 @@
|
|
|
12668
13337
|
|| (working.epoch !== null && !Number.isInteger(Number(working.epoch)))) {
|
|
12669
13338
|
throw new Error('Working revision identity is unavailable. Reload History before starting.');
|
|
12670
13339
|
}
|
|
13340
|
+
restoreRequested = true;
|
|
12671
13341
|
const started = await api(`/api/projects/${encodeURIComponent(proj.id)}/revisions/start`, {
|
|
12672
13342
|
method: 'POST', body: JSON.stringify({ version: n, expectedEtag: working.etag, expectedEpoch: working.epoch === null ? null : Number(working.epoch) }),
|
|
12673
13343
|
});
|
|
@@ -12687,13 +13357,21 @@
|
|
|
12687
13357
|
await refreshApprovalState(proj.id);
|
|
12688
13358
|
renderHistory();
|
|
12689
13359
|
} catch (err) {
|
|
12690
|
-
|
|
13360
|
+
console.warn('[workspaces] saved-version restore did not finish', err);
|
|
13361
|
+
showToast(err && err.status === 409 && err.body && typeof err.body.error === 'string'
|
|
13362
|
+
? err.body.error : 'We couldn’t restore that version because FloLess could not save the change. Try again.', 'warn');
|
|
13363
|
+
if (restoreRequested) reloadModelFromServerTruth();
|
|
13364
|
+
// A failed publication may already have cleared the server's sign-off. Re-read it rather
|
|
13365
|
+
// than leaving the old approved badge visible while recovery is pending.
|
|
13366
|
+
try { await refreshApprovalState(proj.id); renderHistory(); }
|
|
13367
|
+
catch (refreshError) { console.warn('[workspaces] approval state could not refresh after restore', refreshError); }
|
|
12691
13368
|
}
|
|
12692
13369
|
}
|
|
12693
13370
|
|
|
12694
13371
|
async function resumeCheckpoint(checkpointId) {
|
|
12695
13372
|
if (!current) return;
|
|
12696
13373
|
const proj = current;
|
|
13374
|
+
let restoreRequested = false;
|
|
12697
13375
|
try {
|
|
12698
13376
|
const win = frames.model && frames.model.contentWindow;
|
|
12699
13377
|
// Do not write a hidden editor's stale in-memory draft over the exact checkpoint selected in
|
|
@@ -12705,6 +13383,7 @@
|
|
|
12705
13383
|
|| (working.epoch !== null && !Number.isInteger(Number(working.epoch)))) {
|
|
12706
13384
|
throw new Error('Working revision identity is unavailable. Reload Saved work.');
|
|
12707
13385
|
}
|
|
13386
|
+
restoreRequested = true;
|
|
12708
13387
|
await api(`/api/projects/${encodeURIComponent(proj.id)}/checkpoints/${encodeURIComponent(checkpointId)}/resume`, {
|
|
12709
13388
|
method: 'POST',
|
|
12710
13389
|
body: JSON.stringify({ expectedEtag: working.etag, expectedEpoch: working.epoch === null ? null : Number(working.epoch) }),
|
|
@@ -12715,7 +13394,12 @@
|
|
|
12715
13394
|
await refreshApprovalState(proj.id);
|
|
12716
13395
|
renderHistory();
|
|
12717
13396
|
} catch (err) {
|
|
12718
|
-
|
|
13397
|
+
console.warn('[workspaces] saved-work resume did not finish', err);
|
|
13398
|
+
showToast(err && err.status === 409 && err.body && typeof err.body.error === 'string'
|
|
13399
|
+
? err.body.error : 'We couldn’t resume this saved work because FloLess could not reach it. Try again.', 'warn');
|
|
13400
|
+
if (restoreRequested) reloadModelFromServerTruth();
|
|
13401
|
+
try { await refreshApprovalState(proj.id); renderHistory(); }
|
|
13402
|
+
catch (refreshError) { console.warn('[workspaces] approval state could not refresh after resume', refreshError); }
|
|
12719
13403
|
}
|
|
12720
13404
|
}
|
|
12721
13405
|
|
|
@@ -13212,6 +13896,8 @@
|
|
|
13212
13896
|
// the workflow picker). ───────────────────────────────────────────────
|
|
13213
13897
|
let menuFor = null;
|
|
13214
13898
|
const projectExportBusy = new Set();
|
|
13899
|
+
// #1922: the durable record behind the one-off import toast. Plain words: what is uncertain, why, what to do.
|
|
13900
|
+
const UNVERIFIED_IMPORT_TIP = 'This project was zipped while a save was still being written, so this copy may be missing that save or hold only part of it. To get a complete copy, use Export on the computer it came from and import that file. If you have checked this copy and it is complete, use Mark as checked in the ⋯ menu.';
|
|
13215
13901
|
function menuItem(action, label) {
|
|
13216
13902
|
return `<button class="menu-item" data-act="${action}" role="menuitem"><span class="menu-label">${escapeHtml(label)}</span></button>`;
|
|
13217
13903
|
}
|
|
@@ -13232,7 +13918,10 @@
|
|
|
13232
13918
|
const thumbItems = menuItem('thumbnail', hasThumb ? 'Replace thumbnail…' : 'Add thumbnail…')
|
|
13233
13919
|
+ (hasThumb ? menuItem('remove-thumbnail', 'Remove thumbnail') : '');
|
|
13234
13920
|
const duplicateItem = `<button class="menu-item" data-act="duplicate" data-command-id="shell.project-duplicate#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(menuProj && menuProj.name)}" role="menuitem"><span class="menu-label">Duplicate</span></button>`;
|
|
13235
|
-
|
|
13921
|
+
const checkedItem = menuProj && menuProj.importedMidSave
|
|
13922
|
+
? `<button class="menu-item" data-act="clear-unverified" data-command-id="shell.project-clear-unverified#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(menuProj.name)}" role="menuitem"><span class="menu-label">Mark as checked</span></button>`
|
|
13923
|
+
: '';
|
|
13924
|
+
$projMenu.innerHTML = menuItem('rename', 'Rename…') + thumbItems + checkedItem + duplicateItem +
|
|
13236
13925
|
menuItem('export', 'Export…') +
|
|
13237
13926
|
'<div class="menu-divider"></div>' + menuItem('archive', 'Archive');
|
|
13238
13927
|
// NO "Convert to the 3D model…" ITEM HERE, and its absence is a decision rather than an oversight.
|
|
@@ -13315,6 +14004,7 @@
|
|
|
13315
14004
|
function flashCard(id, opts) {
|
|
13316
14005
|
const el = $landing.querySelector(`.ws-card[data-open="${escapeAttr(id)}"]`);
|
|
13317
14006
|
if (!el) return;
|
|
14007
|
+
if (el.hidden) setLandingQuery(''); // never confirm on a card the search is hiding (an import, a rename)
|
|
13318
14008
|
if (opts && opts.scroll) el.scrollIntoView({ block: 'nearest' });
|
|
13319
14009
|
flashId = id;
|
|
13320
14010
|
armFlash(id, el);
|
|
@@ -13438,6 +14128,13 @@
|
|
|
13438
14128
|
const resultToast = formatRfiTransferToast(rfiTransfer, 'duplicate', project.name, true);
|
|
13439
14129
|
finishProgress();
|
|
13440
14130
|
showToast(resultToast.message, resultToast.tone);
|
|
14131
|
+
} else if (action === 'clear-unverified') {
|
|
14132
|
+
// No confirm: the person is saying they checked it, and the label is one Import away from
|
|
14133
|
+
// returning. The project's contents are untouched; only the marker goes.
|
|
14134
|
+
const { project } = await api(`/api/projects/${encodeURIComponent(id)}/imported-mid-save`, { method: 'DELETE' });
|
|
14135
|
+
projects = projects.map((p) => (p.id === id ? project : p));
|
|
14136
|
+
renderLanding();
|
|
14137
|
+
showToast(`Marked “${project.name}” as checked.`, 'ok');
|
|
13441
14138
|
} else if (action === 'remove-thumbnail') {
|
|
13442
14139
|
// No confirm, deliberately. A thumbnail is decorative metadata with nothing downstream of it
|
|
13443
14140
|
// and is one menu item away from being re-added — unlike the archived-project Delete, which
|
|
@@ -13608,7 +14305,7 @@
|
|
|
13608
14305
|
};
|
|
13609
14306
|
try {
|
|
13610
14307
|
const buf = await file.arrayBuffer();
|
|
13611
|
-
const { project, appInstalled, rfiTransfer } = await api('/api/projects/import', {
|
|
14308
|
+
const { project, appInstalled, rfiTransfer, leftOut } = await api('/api/projects/import', {
|
|
13612
14309
|
method: 'POST', headers: { 'content-type': 'application/zip' }, body: buf,
|
|
13613
14310
|
});
|
|
13614
14311
|
projects.unshift(project); // newest → front, matching duplicate/create
|
|
@@ -13616,15 +14313,73 @@
|
|
|
13616
14313
|
flashCard(project.id, { scroll: true });
|
|
13617
14314
|
track('workspace_project_imported', { app: project.app });
|
|
13618
14315
|
const resultToast = formatRfiTransferToast(rfiTransfer, 'import', project.name, appInstalled);
|
|
14316
|
+
const leftOutNote = importLeftOutNote(leftOut, project.name);
|
|
13619
14317
|
finishProgress();
|
|
13620
|
-
showToast(resultToast.message, resultToast.tone);
|
|
14318
|
+
showToast(leftOutNote.skipped ? `${resultToast.message} ${leftOutNote.skipped}` : resultToast.message, resultToast.tone);
|
|
14319
|
+
if (leftOutNote.warning) showToast(leftOutNote.warning, 'warn', { persistent: true });
|
|
13621
14320
|
loadProjects(); // background reconcile against the server truth (mirrors duplicate/rename/archive)
|
|
13622
14321
|
} catch (err) {
|
|
13623
14322
|
finishProgress();
|
|
13624
|
-
showToast(
|
|
14323
|
+
showToast(importRefusalMessage(err, file.name), 'err');
|
|
13625
14324
|
} finally { finishProgress(); }
|
|
13626
14325
|
}
|
|
13627
14326
|
|
|
14327
|
+
// #1887: a project FOLDER zipped by hand carries files FloLess keeps for itself on each computer (the
|
|
14328
|
+
// contract's publication journal, caches, saved checkpoints, undo steps). The server leaves them out and
|
|
14329
|
+
// classifies them in `leftOut`; this turns that into plain words that never claim more than is true:
|
|
14330
|
+
// - zipped mid-save → a persistent warning: the copy may miss that save or hold part of it;
|
|
14331
|
+
// - saved checkpoints / undo steps → a persistent warning: those stay on the source computer;
|
|
14332
|
+
// - anything else is set up fresh here → one quiet sentence on the success toast.
|
|
14333
|
+
function importLeftOutNote(leftOut, projectName) {
|
|
14334
|
+
const files = leftOut && Array.isArray(leftOut.files) ? leftOut.files.length : 0;
|
|
14335
|
+
if (!files) return { skipped: '', warning: '' };
|
|
14336
|
+
const behind = Array.isArray(leftOut.leftBehind) ? leftOut.leftBehind : [];
|
|
14337
|
+
const names = [behind.includes('checkpoints') ? 'saved checkpoints' : '', behind.includes('undo') ? 'member-end undo steps' : '']
|
|
14338
|
+
.filter(Boolean).join(' and ');
|
|
14339
|
+
const stayBehind = names ? `Its ${names} stay on the computer it came from.` : '';
|
|
14340
|
+
const checkpointStep = behind.includes('checkpoints') ? ' If you need a saved checkpoint, approve it there, then move the project again.' : '';
|
|
14341
|
+
if (leftOut.interruptedSave === true) {
|
|
14342
|
+
// No "History and current model came across" here: after a torn save that is exactly what
|
|
14343
|
+
// cannot be promised.
|
|
14344
|
+
return {
|
|
14345
|
+
skipped: '',
|
|
14346
|
+
warning: `Imported “${projectName}”, but it was zipped while a save was still being written, so this copy may be missing that save or hold only part of it. To get a complete copy, use Export on the computer it came from and import that file.${stayBehind ? ` ${stayBehind}` : ''}`,
|
|
14347
|
+
};
|
|
14348
|
+
}
|
|
14349
|
+
if (stayBehind) {
|
|
14350
|
+
return { skipped: '', warning: `Imported “${projectName}”. ${stayBehind.slice(0, -1)}; its History and current model came across.${checkpointStep}` };
|
|
14351
|
+
}
|
|
14352
|
+
return {
|
|
14353
|
+
skipped: files === 1
|
|
14354
|
+
? 'Skipped 1 file FloLess keeps for itself on each computer; it sets it up fresh here, so nothing in the project is lost.'
|
|
14355
|
+
: `Skipped ${files} files FloLess keeps for itself on each computer; it sets them up fresh here, so nothing in the project is lost.`,
|
|
14356
|
+
warning: '',
|
|
14357
|
+
};
|
|
14358
|
+
}
|
|
14359
|
+
|
|
14360
|
+
// A refused import names the file and the server's reason — never the old generic "could not read it",
|
|
14361
|
+
// which hid the one fact the person needed (#1887). A malformed archive (`invalid`) gets the few common
|
|
14362
|
+
// reasons in plain words plus the Export next step; any other refusal the server explains in a complete
|
|
14363
|
+
// sentence of its own (e.g. a module this account lacks) is shown as written. Only a dropped connection
|
|
14364
|
+
// or a server fault — no reason to show — falls back to "try again".
|
|
14365
|
+
function importRefusalMessage(err, fileName) {
|
|
14366
|
+
const body = err && err.body;
|
|
14367
|
+
const reason = body && body.ok === false && typeof body.error === 'string' && body.error.trim()
|
|
14368
|
+
&& !(typeof err.status === 'number' && err.status >= 500) ? body.error.trim() : '';
|
|
14369
|
+
const tooLarge = `Couldn’t import “${fileName}”: it is larger than FloLess can import in one go. Remove large files you don’t need from the zip, then import it again.`;
|
|
14370
|
+
if (err && err.status === 413) return tooLarge;
|
|
14371
|
+
if (!reason) return `Couldn’t import “${fileName}” because FloLess could not finish reading it. Try again.`;
|
|
14372
|
+
// A checklist made by a newer FloLess is not a damaged file: its sentence already says to update FloLess, so the
|
|
14373
|
+
// hand-zipped Export advice below would send the person looking for a fault the file does not have.
|
|
14374
|
+
if (/^This checklist was made by a newer FloLess; /.test(reason)) return `Couldn’t import “${fileName}”. ${reason}`;
|
|
14375
|
+
if (body.code !== 'invalid') return `Couldn’t import “${fileName}”. ${/[.!?]$/.test(reason) ? reason : `${reason}.`}`;
|
|
14376
|
+
if (/^archive is too large|^archive has too many entries/.test(reason)) return tooLarge;
|
|
14377
|
+
const plain = /^archive has no project\.json/.test(reason) ? 'it has no project.json, so it is not a FloLess project'
|
|
14378
|
+
: /^not a valid project archive/.test(reason) ? 'it is not a readable .zip file'
|
|
14379
|
+
: reason.replace(/\.$/, '');
|
|
14380
|
+
return `Couldn’t import “${fileName}”: ${plain}. If you zipped the project folder yourself, use Export on the computer it came from, then import that file.`;
|
|
14381
|
+
}
|
|
14382
|
+
|
|
13628
14383
|
// #1719: when another program has a file open inside the project folder, Windows refuses to move or
|
|
13629
14384
|
// remove it. The server answers with a complete plain-English sentence (what happened, why, what to do),
|
|
13630
14385
|
// so it is shown as-is instead of under a generic "Action failed:" prefix or a "could not save" guess.
|
|
@@ -13811,10 +14566,28 @@
|
|
|
13811
14566
|
renderKnowledge();
|
|
13812
14567
|
}
|
|
13813
14568
|
|
|
14569
|
+
// A cross-project object pin still belongs to its original conversation, wherever its model is shown.
|
|
14570
|
+
async function openChatOwner(owner) {
|
|
14571
|
+
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
14572
|
+
if (!owner || typeof owner !== 'object'
|
|
14573
|
+
|| !(owner.kind === 'workspace' || owner.kind === 'project' && validId(owner.projectId)
|
|
14574
|
+
|| owner.kind === 'workflow' && validId(owner.workflowId))) throw new Error('That conversation has no valid home to open.');
|
|
14575
|
+
if (owner.kind === 'workflow') {
|
|
14576
|
+
if (typeof bridge.openOwnedWorkflow !== 'function') throw new Error('Open this conversation’s workflow from Workflows, then try Show in chat again.');
|
|
14577
|
+
await bridge.openOwnedWorkflow(owner.workflowId);
|
|
14578
|
+
return;
|
|
14579
|
+
}
|
|
14580
|
+
await setMode('workspaces');
|
|
14581
|
+
if (owner.kind === 'project') {
|
|
14582
|
+
await openProject(owner.projectId);
|
|
14583
|
+
if (current?.id !== owner.projectId) throw new Error('That project could not be opened. Try Show in chat again after opening its project in Workspaces.');
|
|
14584
|
+
} else closeProject();
|
|
14585
|
+
}
|
|
14586
|
+
|
|
13814
14587
|
window.flolessWorkspaces = {
|
|
13815
14588
|
setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind,
|
|
13816
14589
|
openHistory: wsOpenHistory, openKnowledgePage, drawingFilterCheckpointSaved,
|
|
13817
|
-
syncWorkspaceReporter,
|
|
14590
|
+
syncWorkspaceReporter, openChatOwner,
|
|
13818
14591
|
};
|
|
13819
14592
|
applyMode(); // restore persisted mode immediately (matches panels.js applyView timing)
|
|
13820
14593
|
})();
|