@floless/app 0.155.2 → 0.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli-actions.mjs +392 -0
- package/dist/floless-server.cjs +182734 -141519
- package/dist/schemas/drawing-check.profile.v1.schema.json +15 -2
- package/dist/schemas/steel.model.v2.schema.json +25 -1
- package/dist/skills/floless-app-actions/SKILL.md +199 -0
- package/dist/skills/floless-app-approval/SKILL.md +8 -5
- package/dist/skills/floless-app-bridge/SKILL.md +12 -9
- package/dist/skills/floless-app-knowledge/SKILL.md +50 -14
- package/dist/skills/floless-app-new-workflow/SKILL.md +26 -10
- package/dist/skills/floless-app-onboarding/SKILL.md +31 -1
- package/dist/skills/floless-app-onboarding/references/aware-runtime.md +4 -4
- package/dist/skills/floless-app-queue/SKILL.md +10 -6
- package/dist/skills/floless-app-report-issue/SKILL.md +15 -12
- package/dist/skills/floless-app-rfi/SKILL.md +98 -73
- package/dist/skills/floless-app-routines/SKILL.md +27 -15
- package/dist/skills/floless-app-routines/references/routines-api.md +8 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +1 -1
- package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +4 -2
- package/dist/skills/floless-app-tweak-contract/SKILL.md +25 -5
- package/dist/skills/floless-app-workflows/SKILL.md +50 -13
- package/dist/skills/floless-app-workflows/references/agent-steps.md +119 -0
- package/dist/web/agent-steps.js +1750 -0
- package/dist/web/agents.js +33 -8
- package/dist/web/app.css +681 -4
- package/dist/web/app.js +111 -11
- package/dist/web/aware-update-client.js +1 -0
- package/dist/web/aware.js +1257 -202
- package/dist/web/chat-landing-scene.js +372 -0
- package/dist/web/chat.css +254 -1
- package/dist/web/chat.js +2657 -87
- package/dist/web/commands-drawing-check.js +17 -0
- package/dist/web/commands-shell.js +1108 -4
- package/dist/web/commands-steel.js +6 -0
- package/dist/web/connections.js +1 -0
- package/dist/web/drawing-check-editor.html +33 -5
- package/dist/web/drawing-check-editor.js +538 -22
- package/dist/web/drawing-check-overlay.js +13 -0
- package/dist/web/flo-avatar.js +28 -3
- package/dist/web/guide.js +7 -2
- package/dist/web/index.html +171 -7
- package/dist/web/instructor.js +6 -4
- package/dist/web/leave-guard.js +4 -2
- package/dist/web/left-pane.js +8 -3
- package/dist/web/model-revit-module.js +15 -0
- package/dist/web/model-view-query.js +12 -2
- package/dist/web/model-viewport-revit-adapter.js +3 -1
- package/dist/web/pages.js +891 -36
- package/dist/web/panels.js +8 -5
- package/dist/web/parser-setup-recovery.js +12 -4
- package/dist/web/project-access.js +549 -0
- package/dist/web/project-reconciliation.js +357 -0
- package/dist/web/report-files.js +50 -0
- package/dist/web/revit-editor.js +116 -27
- package/dist/web/startup-admission.js +132 -0
- package/dist/web/steel-3d-core.js +9 -0
- package/dist/web/steel-editor.html +642 -22
- package/dist/web/steel-model-v2-commands.js +63 -5
- package/dist/web/step-rename.js +287 -0
- package/dist/web/terminal-requests.js +590 -0
- package/dist/web/tool-updates.js +148 -13
- package/dist/web/workspace-root-management.js +39 -0
- package/dist/web/workspaces.js +1879 -74
- package/launch.mjs +82 -2
- package/package.json +3 -1
package/dist/web/workspaces.js
CHANGED
|
@@ -13,8 +13,11 @@
|
|
|
13
13
|
* ========================================================================== */
|
|
14
14
|
(() => {
|
|
15
15
|
const bridge = window.flolessBridge || {};
|
|
16
|
-
const api = bridge.api || (async (path, opts) => {
|
|
17
|
-
|
|
16
|
+
const api = bridge.api || (async (path, opts = {}) => {
|
|
17
|
+
await globalThis.flolessStartupAdmission?.admit(path, { method: opts?.method, signal: opts?.signal });
|
|
18
|
+
const { timeoutMs, ...requestOptions } = opts;
|
|
19
|
+
if (!requestOptions.signal && Number.isFinite(timeoutMs)) requestOptions.signal = AbortSignal.timeout(timeoutMs);
|
|
20
|
+
const res = await fetch(path, { headers: { 'content-type': 'application/json' }, ...requestOptions });
|
|
18
21
|
const body = await res.json().catch(() => ({
|
|
19
22
|
ok: false,
|
|
20
23
|
code: 'response-unreadable',
|
|
@@ -375,6 +378,8 @@
|
|
|
375
378
|
const $revitReassure = document.getElementById('ws-source-reassure');
|
|
376
379
|
let revitSourceState = null;
|
|
377
380
|
let revitActiveOperation = null;
|
|
381
|
+
// How the Source step's last Cancel or Try again ended, for a chat card that pressed it (modelSourceStep): the route's own answer.
|
|
382
|
+
let sourceControlOutcome = null;
|
|
378
383
|
// The Source card an import leaves ("…It is not approved yet.") stays true only until that model is approved.
|
|
379
384
|
let revitSourceAwaitsApproval = false;
|
|
380
385
|
// Every paint of the Source pane counts, so a late answer can tell that something newer was painted.
|
|
@@ -645,6 +650,8 @@
|
|
|
645
650
|
*/
|
|
646
651
|
let exportsRenderGen = 0;
|
|
647
652
|
let exportState = null; // kind → { path, exportedAt } after a successful list; null = unknown/failed
|
|
653
|
+
// #2449: { version, hash } of the approved version exportState's files came from, from the SAME listing; null = unknown.
|
|
654
|
+
let exportStateFrom = null;
|
|
648
655
|
/*
|
|
649
656
|
* THE UNITS THE SERVER SAYS THIS PROJECT'S BILL IS IN — from the same response the card is built
|
|
650
657
|
* from, refreshed every time the card is. `null` until it has answered.
|
|
@@ -956,6 +963,33 @@
|
|
|
956
963
|
},
|
|
957
964
|
},
|
|
958
965
|
},
|
|
966
|
+
'floless-general': {
|
|
967
|
+
// A General project (#2470) is a blank project for any work: no drawing, no model, no module, so it
|
|
968
|
+
// is in the base plan. `floless-general` is a project type FloLess owns, not an installed workflow,
|
|
969
|
+
// so its card is always there (installedWorkspaceAppEntries) and nothing has to be set up. It has no
|
|
970
|
+
// editor and no model: it opens on Knowledge, and its header has nothing to approve while it holds
|
|
971
|
+
// no model (renderApprovalHeader). Last on the landing: the card for the work no other card fits.
|
|
972
|
+
sourceless: true,
|
|
973
|
+
cardIcon: '<rect x="3" y="7.5" width="18" height="12" rx="1.5"/><path d="M9 7.5v-2A1.5 1.5 0 0 1 10.5 4h3A1.5 1.5 0 0 1 15 5.5v2"/><path d="M3 12.5h18"/><path d="M11 12.5v2h2v-2"/>', // a briefcase: the job, whatever it is
|
|
974
|
+
displayName: 'General',
|
|
975
|
+
projectCapability: 'workflows, knowledge, chat',
|
|
976
|
+
createActions: [{
|
|
977
|
+
kind: 'general-project',
|
|
978
|
+
headline: 'General project',
|
|
979
|
+
capability: 'Workflows, knowledge, chat',
|
|
980
|
+
sub: 'Start with nothing but a name. Add knowledge, pages and workflows as you go.',
|
|
981
|
+
label: 'New General project…',
|
|
982
|
+
dropWarn: 'General starts from a name, not a file, so nothing was uploaded. Click the card to make the project, then add files on its Knowledge page.',
|
|
983
|
+
}],
|
|
984
|
+
editor: null,
|
|
985
|
+
filter: null,
|
|
986
|
+
steps: [
|
|
987
|
+
{ key: 'knowledge', label: 'Knowledge' },
|
|
988
|
+
{ key: 'pages', label: 'Pages' },
|
|
989
|
+
],
|
|
990
|
+
diff: false,
|
|
991
|
+
exports: [],
|
|
992
|
+
},
|
|
959
993
|
};
|
|
960
994
|
// A project names its app by the LIVE id, which a rename or a duplicate moves off the descriptor
|
|
961
995
|
// keys above — so resolve through the lineage ROOT the server ships beside it (`templateId`, derived
|
|
@@ -981,6 +1015,15 @@
|
|
|
981
1015
|
if (saved === 'workspaces' || saved === 'agents') mode = saved;
|
|
982
1016
|
} catch { /* private mode */ }
|
|
983
1017
|
let projects = [];
|
|
1018
|
+
const registeredRows = new Map();
|
|
1019
|
+
const registeredCards = new Map();
|
|
1020
|
+
const registeredPickerRows = new Map();
|
|
1021
|
+
const metadataRefreshes = new Map();
|
|
1022
|
+
function indexRegisteredRows() {
|
|
1023
|
+
registeredRows.clear();
|
|
1024
|
+
for (const row of projects) if (row.registrationId) registeredRows.set(row.registrationId, row);
|
|
1025
|
+
for (const row of archived) if (row.registrationId) registeredRows.set(row.registrationId, row);
|
|
1026
|
+
}
|
|
984
1027
|
let projectsLoadError = null; // last /api/projects failure reason, or null — an empty list means
|
|
985
1028
|
// "none yet" ONLY when this is null (see the empty state in renderLanding)
|
|
986
1029
|
let archived = []; // archived projects (the "Trash") — listed under a collapsed section on the landing
|
|
@@ -1064,6 +1107,8 @@
|
|
|
1064
1107
|
if (['ready', 'failed', 'not-applicable'].includes(coreDefaults)) missingCoreRoots.add(root);
|
|
1065
1108
|
}
|
|
1066
1109
|
}
|
|
1110
|
+
// A General project needs nothing installed, so its card is always offered (#2470).
|
|
1111
|
+
if (!byRoot.has('floless-general')) byRoot.set('floless-general', ['floless-general']);
|
|
1067
1112
|
return Object.keys(WORKSPACE_APPS).filter((root) => byRoot.has(root)).map((root) => {
|
|
1068
1113
|
// Sorted, so which app a card targets is stable across loads rather than dependent on the
|
|
1069
1114
|
// order `aware app list` happened to return. The canonical install wins when present: it is
|
|
@@ -1113,6 +1158,11 @@
|
|
|
1113
1158
|
* still preliminary.
|
|
1114
1159
|
*/
|
|
1115
1160
|
let projectContractLifecycle = 'unknown';
|
|
1161
|
+
// A General project (#2470) has no Model, Exports or History step, so nothing the person clicks would
|
|
1162
|
+
// ever re-ask a lifecycle check that timed out or failed. It re-asks by itself, a few times, further
|
|
1163
|
+
// apart each time; then the header says it could not check rather than "Checking…" forever.
|
|
1164
|
+
const SOURCELESS_PRESENCE_RETRIES = 3;
|
|
1165
|
+
let sourcelessPresence = { projectId: null, openSeq: 0, tries: 0, gaveUp: false, timer: null };
|
|
1116
1166
|
let exportsHasModel = false;
|
|
1117
1167
|
// A project may open on Model/Exports/History while its lifecycle probe is still in flight. Keep
|
|
1118
1168
|
// the most recently requested destination until the probe settles so the latest click counts.
|
|
@@ -1137,11 +1187,36 @@
|
|
|
1137
1187
|
|
|
1138
1188
|
function renderApprovalHeader() {
|
|
1139
1189
|
if (!$approveBtn) return;
|
|
1190
|
+
// A General project (#2470) has nothing of its own to approve, so the button is withheld rather than
|
|
1191
|
+
// left as a permanently dead "Review unavailable". Only once the lifecycle answer CONFIRMS there is no
|
|
1192
|
+
// model: while it is unknown (still checking, or the check failed) the button stays and shows its usual
|
|
1193
|
+
// checking or retry state, and should a model ever be there (an imported folder that carried one) it
|
|
1194
|
+
// says what it always does. Workflows in the project keep their own Compile/Approve and drift gate.
|
|
1195
|
+
const sourceless = !!(typeof current !== 'undefined' && current && wsDescOf(current)?.sourceless);
|
|
1196
|
+
$approveBtn.hidden = sourceless && projectContractLifecycle === 'absent';
|
|
1140
1197
|
const s = approvalState;
|
|
1141
1198
|
let label = 'Review & approve';
|
|
1142
1199
|
let tip = APPROVE_TIP;
|
|
1143
1200
|
let unavailable = false;
|
|
1144
|
-
if (
|
|
1201
|
+
if (sourceless) {
|
|
1202
|
+
// A General project has no Drawing Filter and no workflow to approve with, so no model-specific
|
|
1203
|
+
// branch below applies. The button is hidden once the check confirms there is no model.
|
|
1204
|
+
const gaveUp = sourcelessPresence.gaveUp && sourcelessPresence.projectId === current.id;
|
|
1205
|
+
if (exportsHasModel) {
|
|
1206
|
+
label = 'Review unavailable';
|
|
1207
|
+
// A step that exists: a project of the model's own type, made from its drawings or source.
|
|
1208
|
+
tip = 'This General project holds a model that came in with an imported folder, and a General project cannot approve a model. To review and approve it, create a project of the model’s type on the Workspaces page and read its drawings or source there.';
|
|
1209
|
+
} else if (projectContractLifecycle === 'unknown') {
|
|
1210
|
+
label = gaveUp ? 'Couldn’t check project' : 'Checking project…';
|
|
1211
|
+
tip = gaveUp
|
|
1212
|
+
? 'FloLess couldn’t confirm whether this project holds a model. Click to check again.'
|
|
1213
|
+
: 'Checking whether this project holds a model.';
|
|
1214
|
+
} else {
|
|
1215
|
+
label = 'Review unavailable';
|
|
1216
|
+
tip = 'A General project has nothing of its own to approve.';
|
|
1217
|
+
}
|
|
1218
|
+
unavailable = true;
|
|
1219
|
+
} else if (s.status === 'waiting-for-model-read') {
|
|
1145
1220
|
const tekla = isTeklaParserProject();
|
|
1146
1221
|
label = tekla ? 'Review after read' : 'Review after import';
|
|
1147
1222
|
tip = tekla
|
|
@@ -1437,6 +1512,7 @@
|
|
|
1437
1512
|
if (freshVisit) setLandingQuery('');
|
|
1438
1513
|
$project.hidden = !ws || !current;
|
|
1439
1514
|
$spine.hidden = !ws || !current;
|
|
1515
|
+
window.flolessProjectAccess?.setProject(ws && current ? current : null);
|
|
1440
1516
|
if (!ws && !$projMenu.hidden) closeProjMenu();
|
|
1441
1517
|
if (ws && !current) loadProjects();
|
|
1442
1518
|
// Name the tab after what's actually on screen. aware.js is the single writer of
|
|
@@ -1488,10 +1564,13 @@
|
|
|
1488
1564
|
}
|
|
1489
1565
|
if (opening) {
|
|
1490
1566
|
$workflowTab.setAttribute('aria-label', 'Opening Workflows');
|
|
1567
|
+
// The tab's own icon is kept on the tab while the spinner stands in for it, and put back when it is done.
|
|
1568
|
+
$workflowTab.idleIcon ??= $workflowTab.querySelector?.('.mode-icon') || null;
|
|
1491
1569
|
$workflowTab.innerHTML = '<span class="rtn-spinner" aria-hidden="true"></span><span>Opening Workflows…</span>';
|
|
1492
1570
|
} else {
|
|
1493
1571
|
$workflowTab.removeAttribute('aria-label');
|
|
1494
1572
|
$workflowTab.textContent = 'Workflows';
|
|
1573
|
+
if ($workflowTab.idleIcon) $workflowTab.prepend($workflowTab.idleIcon);
|
|
1495
1574
|
}
|
|
1496
1575
|
}
|
|
1497
1576
|
async function setMode(m) {
|
|
@@ -1517,7 +1596,11 @@
|
|
|
1517
1596
|
await bridge.refreshCurrentWorkflow();
|
|
1518
1597
|
} catch (error) {
|
|
1519
1598
|
if (sequence === modeChangeSequence) {
|
|
1520
|
-
|
|
1599
|
+
// A module refusal (Revit or Tekla access not confirmed) is not FloLess failing to reach the
|
|
1600
|
+
// workflow, and trying again will not fix it: say what the server says to do instead. A lapsed
|
|
1601
|
+
// FloLess sign-in is not FloLess being unreachable either: say to sign in again.
|
|
1602
|
+
showToast(bridge.moduleRefusalText?.(error) || bridge.accountAccessText?.(error)
|
|
1603
|
+
|| 'We couldn’t refresh this workflow because FloLess could not reach it. Try again.', 'warn');
|
|
1521
1604
|
}
|
|
1522
1605
|
return;
|
|
1523
1606
|
} finally {
|
|
@@ -1604,6 +1687,7 @@
|
|
|
1604
1687
|
const res = await api('/api/projects');
|
|
1605
1688
|
if (stale()) return;
|
|
1606
1689
|
projects = res.projects;
|
|
1690
|
+
indexRegisteredRows();
|
|
1607
1691
|
projectsLoadError = null;
|
|
1608
1692
|
} catch (err) {
|
|
1609
1693
|
if (stale()) return;
|
|
@@ -1634,6 +1718,7 @@
|
|
|
1634
1718
|
const res = await api('/api/projects/archived');
|
|
1635
1719
|
if (stale()) return;
|
|
1636
1720
|
archived = res.projects;
|
|
1721
|
+
indexRegisteredRows();
|
|
1637
1722
|
} catch (err) {
|
|
1638
1723
|
if (stale()) return;
|
|
1639
1724
|
archived = [];
|
|
@@ -1856,8 +1941,31 @@
|
|
|
1856
1941
|
if (!$wsExports.hidden) safeRenderExports('after a units change');
|
|
1857
1942
|
});
|
|
1858
1943
|
|
|
1944
|
+
/**
|
|
1945
|
+
* Relay a change to the open project's editor frame (#2482). The editor has no event stream of its own: one more
|
|
1946
|
+
* long-lived connection per tab took two open tabs past the browser's six per server, and every other request then
|
|
1947
|
+
* waited, so the page looked offline. Only frames about the project on screen go, to that frame's origin.
|
|
1948
|
+
*/
|
|
1949
|
+
function tellModelFrame(frame) {
|
|
1950
|
+
const project = typeof current !== 'undefined' ? current : null;
|
|
1951
|
+
const f = typeof frames !== 'undefined' ? frames.model : null;
|
|
1952
|
+
if (!project || !f || !f.dataset.loaded) return;
|
|
1953
|
+
try { f.contentWindow?.postMessage({ type: 'floless:project-event', projectId: project.id, frame }, location.origin); }
|
|
1954
|
+
catch { /* the frame is between documents */ }
|
|
1955
|
+
}
|
|
1956
|
+
window.addEventListener('floless:contract-changed', (e) => {
|
|
1957
|
+
const m = (e && e.detail) || {};
|
|
1958
|
+
if (current && m.project === current.id) tellModelFrame(m);
|
|
1959
|
+
});
|
|
1859
1960
|
window.addEventListener('floless:projects-changed', (e) => {
|
|
1961
|
+
// Sent after the event stream reconnects too (aware.js), with no detail: frames may have been missed, so the
|
|
1962
|
+
// editor reads again.
|
|
1963
|
+
if (!e || !e.detail || !Object.keys(e.detail).length) tellModelFrame({ type: 'resync' });
|
|
1860
1964
|
const m = (e && e.detail) || {};
|
|
1965
|
+
if (m.kind === 'metadata' && typeof m.registrationId === 'string') {
|
|
1966
|
+
refreshRegisteredProject(m);
|
|
1967
|
+
return;
|
|
1968
|
+
}
|
|
1861
1969
|
if (!current) {
|
|
1862
1970
|
// THE LANDING IS DERIVED FROM THE SAME LIVE SET, so it goes stale on exactly these events —
|
|
1863
1971
|
// and not merely cosmetically: its cards carry `data-open`/`data-kebab` ids, so after a rename
|
|
@@ -1912,6 +2020,127 @@
|
|
|
1912
2020
|
});
|
|
1913
2021
|
}
|
|
1914
2022
|
|
|
2023
|
+
// A save invalidates exactly one registered display row. The event grants no authority:
|
|
2024
|
+
// the keyed route checks the physical target and returns its current registration view.
|
|
2025
|
+
async function refreshRegisteredProject(event) {
|
|
2026
|
+
const root = window.flolessWorkspaceRoot?.current()?.root;
|
|
2027
|
+
if (!root || event.rootId !== root.rootId || event.generation !== root.generation) return;
|
|
2028
|
+
const registrationId = event.registrationId;
|
|
2029
|
+
const cached = registeredRows.get(registrationId);
|
|
2030
|
+
if (!cached) return;
|
|
2031
|
+
const running = metadataRefreshes.get(registrationId);
|
|
2032
|
+
if (running) { running.again = true; return; }
|
|
2033
|
+
const state = { again: false, retries: event._retry ? 0 : 1 };
|
|
2034
|
+
metadataRefreshes.set(registrationId, state);
|
|
2035
|
+
try {
|
|
2036
|
+
do {
|
|
2037
|
+
state.again = false;
|
|
2038
|
+
const navigation = openNavSeq;
|
|
2039
|
+
const seq = projectsLoadSeq;
|
|
2040
|
+
const response = await api(`/api/project-registrations/${encodeURIComponent(registrationId)}/view`);
|
|
2041
|
+
const activeRoot = window.flolessWorkspaceRoot?.current()?.root;
|
|
2042
|
+
if (activeRoot?.rootId !== root.rootId || activeRoot?.generation !== root.generation
|
|
2043
|
+
|| response.root?.rootId !== root.rootId || response.root?.generation !== root.generation
|
|
2044
|
+
|| seq !== projectsLoadSeq || registeredRows.get(registrationId) !== cached) return;
|
|
2045
|
+
const registration = response.registration;
|
|
2046
|
+
const fresh = response.project;
|
|
2047
|
+
if (registration?.registrationId !== registrationId || !fresh
|
|
2048
|
+
|| registration.projectId !== cached.id || String(registration.projectUuid).toLowerCase() !== String(cached.uuid).toLowerCase()
|
|
2049
|
+
|| fresh.id !== cached.id || String(fresh.uuid).toLowerCase() !== String(cached.uuid).toLowerCase()
|
|
2050
|
+
|| !['available', 'unavailable'].includes(registration.status)) {
|
|
2051
|
+
throw new Error('The project view no longer matches this registration.');
|
|
2052
|
+
}
|
|
2053
|
+
const wasUnits = cached.displayUnits === 'mm' ? 'mm' : 'ft-in';
|
|
2054
|
+
const wasApproved = cached.approvedAt;
|
|
2055
|
+
Object.assign(cached, fresh, {
|
|
2056
|
+
displayUnits: fresh.displayUnits === 'mm' ? 'mm' : 'ft-in',
|
|
2057
|
+
registrationState: registration.status,
|
|
2058
|
+
registrationRevision: registration.entryRevision,
|
|
2059
|
+
registrationReason: registration.reason,
|
|
2060
|
+
registrationPhysicalIdentityGuarantee: registration.physicalIdentityGuarantee,
|
|
2061
|
+
registrationLocationWarning: registration.locationWarning,
|
|
2062
|
+
});
|
|
2063
|
+
if (!Object.hasOwn(fresh, 'approvedAt')) delete cached.approvedAt;
|
|
2064
|
+
patchRegisteredCard(cached);
|
|
2065
|
+
if (navigation !== openNavSeq || current?.registrationId !== registrationId) continue;
|
|
2066
|
+
const units = cached.displayUnits === 'mm' ? 'mm' : 'ft-in';
|
|
2067
|
+
Object.assign(current, cached);
|
|
2068
|
+
if (!Object.hasOwn(cached, 'approvedAt')) delete current.approvedAt;
|
|
2069
|
+
$projName.textContent = cached.name;
|
|
2070
|
+
paintProjectLocationWarning(cached);
|
|
2071
|
+
if (registration.status === 'unavailable') {
|
|
2072
|
+
// Keep the editor and its unsaved draft in place while the person reviews recovery.
|
|
2073
|
+
showToast('This project folder is unavailable. Review its location before continuing.', 'warn');
|
|
2074
|
+
window.flolessProjectReconciliation?.openRegistration(registrationId);
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
2077
|
+
if (wasUnits !== units || wasApproved !== cached.approvedAt) {
|
|
2078
|
+
exportUnits = null;
|
|
2079
|
+
if (!$wsExports.hidden) safeRenderExports('after this project changed');
|
|
2080
|
+
}
|
|
2081
|
+
} while (state.again);
|
|
2082
|
+
} catch (error) {
|
|
2083
|
+
if (!workspacePageUnloading) {
|
|
2084
|
+
showToast('Couldn’t refresh this project. Check its folder or reload to try again.', 'warn');
|
|
2085
|
+
if (state.retries) setTimeout(() => refreshRegisteredProject({ ...event, _retry: true }), 2000);
|
|
2086
|
+
}
|
|
2087
|
+
} finally {
|
|
2088
|
+
if (metadataRefreshes.get(registrationId) === state) metadataRefreshes.delete(registrationId);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
function patchRegisteredCard(project) {
|
|
2093
|
+
const picker = registeredPickerRows.get(project.registrationId);
|
|
2094
|
+
if (picker?.isConnected) {
|
|
2095
|
+
const pickerName = picker.querySelector('.wf-option-name');
|
|
2096
|
+
if (pickerName) pickerName.textContent = project.name;
|
|
2097
|
+
picker.dataset.search = `${project.name} ${projectAppName(project)} ${project.app}`.toLowerCase();
|
|
2098
|
+
}
|
|
2099
|
+
const card = registeredCards.get(project.registrationId);
|
|
2100
|
+
if (!card?.isConnected) return;
|
|
2101
|
+
const name = card.querySelector('.ws-name, .ws-archived-name');
|
|
2102
|
+
const time = card.querySelector('.t');
|
|
2103
|
+
const status = card.querySelector('.ws-registration-status');
|
|
2104
|
+
const locationWarning = card.querySelector('.ws-registration-location-note');
|
|
2105
|
+
if (name) name.textContent = project.name;
|
|
2106
|
+
if (time) time.textContent = relAgo(project.updatedAt);
|
|
2107
|
+
if (status) {
|
|
2108
|
+
status.hidden = project.registrationState !== 'unavailable';
|
|
2109
|
+
status.textContent = project.registrationReason || 'Project folder unavailable. Locate or restore it.';
|
|
2110
|
+
}
|
|
2111
|
+
if (locationWarning) {
|
|
2112
|
+
locationWarning.hidden = project.registrationState === 'unavailable' || !project.registrationLocationWarning;
|
|
2113
|
+
locationWarning.textContent = project.registrationLocationWarning || '';
|
|
2114
|
+
}
|
|
2115
|
+
const unavailable = project.registrationState === 'unavailable';
|
|
2116
|
+
const menu = card.querySelector('.ws-kebab');
|
|
2117
|
+
if (unavailable) {
|
|
2118
|
+
card.setAttribute('data-command-id', `shell.project-registration-review#${project.registrationId}`);
|
|
2119
|
+
card.setAttribute('data-command-instance-label', project.name);
|
|
2120
|
+
if (menu) {
|
|
2121
|
+
menu.setAttribute('data-command-id', `shell.project-registration-review#${project.registrationId}`);
|
|
2122
|
+
menu.setAttribute('data-command-instance-label', project.name);
|
|
2123
|
+
menu.setAttribute('data-tip', 'Review project folder');
|
|
2124
|
+
menu.setAttribute('aria-label', 'Review project folder');
|
|
2125
|
+
}
|
|
2126
|
+
} else if (card.getAttribute('data-command-id')?.startsWith('shell.project-registration-review#')) {
|
|
2127
|
+
card.removeAttribute('data-command-id');
|
|
2128
|
+
card.removeAttribute('data-command-instance-label');
|
|
2129
|
+
if (menu) {
|
|
2130
|
+
menu.removeAttribute('data-command-id'); menu.removeAttribute('data-command-instance-label');
|
|
2131
|
+
menu.setAttribute('data-tip', project.importedMidSave ? 'Rename · Thumbnail · Mark as checked · Duplicate · Export · Archive' : 'Rename · Thumbnail · Duplicate · Export · Archive');
|
|
2132
|
+
menu.setAttribute('aria-label', 'Project actions');
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
function paintProjectLocationWarning(project) {
|
|
2138
|
+
const warning = document.getElementById('ws-project-location-warning');
|
|
2139
|
+
if (!warning) return;
|
|
2140
|
+
warning.hidden = project.registrationState === 'unavailable' || !project.registrationLocationWarning;
|
|
2141
|
+
warning.textContent = project.registrationLocationWarning || '';
|
|
2142
|
+
}
|
|
2143
|
+
|
|
1915
2144
|
/**
|
|
1916
2145
|
* Reconcile the OPEN project against the server's live set — the answer to "is what I have still
|
|
1917
2146
|
* there, and under what id".
|
|
@@ -1978,7 +2207,7 @@
|
|
|
1978
2207
|
// through the fix's own path. `openProject`'s fallback fetch keeps one entry and discards the
|
|
1979
2208
|
// array, so this is the only place the whole list lands. (Found by review.)
|
|
1980
2209
|
if (!current || current.id !== id) continue; // the user moved on mid-read; ask again for the new one
|
|
1981
|
-
if (seq === projectsLoadSeq) projects = res.projects;
|
|
2210
|
+
if (seq === projectsLoadSeq) { projects = res.projects; indexRegisteredRows(); }
|
|
1982
2211
|
// Identity first; the id only as the legacy fallback.
|
|
1983
2212
|
const mine = uuid
|
|
1984
2213
|
? res.projects.find((p) => p.uuid === uuid)
|
|
@@ -1987,6 +2216,14 @@
|
|
|
1987
2216
|
// read predates it, so recording it would let the loop exit on a claim that was never true —
|
|
1988
2217
|
// and the trailing pass re-reads anyway. (Found by review round 3.)
|
|
1989
2218
|
if (mine && mine.id === id) {
|
|
2219
|
+
paintProjectLocationWarning(mine);
|
|
2220
|
+
if (mine.registrationState === 'unavailable' && mine.registrationId) {
|
|
2221
|
+
Object.assign(current, mine);
|
|
2222
|
+
showToast('This project folder is unavailable. Review its location before continuing.', 'warn');
|
|
2223
|
+
window.flolessProjectReconciliation?.openRegistration(mine.registrationId);
|
|
2224
|
+
if (!reconcileAgain) validated = id;
|
|
2225
|
+
continue;
|
|
2226
|
+
}
|
|
1990
2227
|
/*
|
|
1991
2228
|
* "UNCHANGED" MEANS THE IDENTITY, NOT THE ROW. `mine` is a freshly read server row, and the
|
|
1992
2229
|
* reconnect catch-up (`aware.js` `es.onopen`) re-announces `projects-changed` precisely
|
|
@@ -2283,6 +2520,7 @@
|
|
|
2283
2520
|
const createCommand = action.kind === 'tekla-source' ? 'data-command-id="shell.project-create-tekla-read" '
|
|
2284
2521
|
: action.kind === 'rvt' ? 'data-command-id="shell.project-create-revit-read" '
|
|
2285
2522
|
: action.kind === 'drawing-check-profile' ? 'data-command-id="shell.project-create-drawing-check-profile" '
|
|
2523
|
+
: action.kind === 'general-project' ? 'data-command-id="shell.project-create-general" '
|
|
2286
2524
|
: action.kind !== 'drawing' ? ''
|
|
2287
2525
|
: entry.templateId === 'steel-model' ? 'data-command-id="shell.project-create-steel-from-drawings" '
|
|
2288
2526
|
: entry.templateId === 'vectorize' ? 'data-command-id="shell.project-create-trace-from-drawing" '
|
|
@@ -2338,7 +2576,11 @@
|
|
|
2338
2576
|
*/
|
|
2339
2577
|
function thumbBandHtml(p, displayApp) {
|
|
2340
2578
|
const kind = `<span class="ws-kind">${escapeHtml(displayApp)}</span>`;
|
|
2341
|
-
|
|
2579
|
+
// A General project (#2470) has no drawing or model to picture, so its band shows the card's own mark.
|
|
2580
|
+
const sourceless = wsDescOf(p)?.sourceless ? wsDescOf(p).cardIcon : '';
|
|
2581
|
+
if (!p.thumbnailTag) {
|
|
2582
|
+
return `<span class="ws-thumb">${kind}${sourceless ? `<svg class="ws-thumb-mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false">${sourceless}</svg>` : '▦'}</span>`;
|
|
2583
|
+
}
|
|
2342
2584
|
return `<button type="button" class="ws-thumb" data-thumb="${escapeAttr(p.id)}" ` +
|
|
2343
2585
|
`aria-label="${escapeAttr(`View the thumbnail of “${p.name}” larger`)}" data-tip="View this thumbnail larger">` +
|
|
2344
2586
|
`<img alt="" loading="lazy">${kind}<span class="ws-thumb-expand" aria-hidden="true">⤢</span></button>`;
|
|
@@ -2381,7 +2623,7 @@
|
|
|
2381
2623
|
function workspaceProjectGroups(list) {
|
|
2382
2624
|
const groups = new Map();
|
|
2383
2625
|
for (const project of list) {
|
|
2384
|
-
const key = project.templateId || project.app || '';
|
|
2626
|
+
const key = project.templateId || project.app || 'other-projects';
|
|
2385
2627
|
if (!groups.has(key)) groups.set(key, {
|
|
2386
2628
|
key, label: projectAppName(project) || 'Other projects', projects: [],
|
|
2387
2629
|
});
|
|
@@ -2451,6 +2693,7 @@
|
|
|
2451
2693
|
|
|
2452
2694
|
let landingPageFocusCommand = null;
|
|
2453
2695
|
function renderLanding() {
|
|
2696
|
+
indexRegisteredRows();
|
|
2454
2697
|
syncProjectGroupSearchRoot();
|
|
2455
2698
|
const rootState = window.flolessWorkspaceRoot && window.flolessWorkspaceRoot.current();
|
|
2456
2699
|
const rootPath = rootState && rootState.root && rootState.root.path;
|
|
@@ -2465,6 +2708,7 @@
|
|
|
2465
2708
|
: '') +
|
|
2466
2709
|
`<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>` +
|
|
2467
2710
|
`${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>`;
|
|
2711
|
+
html += '<div class="ws-folder-review-note" id="ws-folder-review-note" hidden></div>';
|
|
2468
2712
|
if (rootUnavailable) {
|
|
2469
2713
|
html += `<div class="ws-empty-note ws-root-unavailable" role="status" aria-live="polite"><b>Workspace directory unavailable.</b> ` +
|
|
2470
2714
|
`Choose another folder to continue. ` +
|
|
@@ -2479,6 +2723,9 @@
|
|
|
2479
2723
|
}
|
|
2480
2724
|
html += `</div>`;
|
|
2481
2725
|
}
|
|
2726
|
+
}
|
|
2727
|
+
// Last-known registered rows remain useful recovery entry points when the drive is offline.
|
|
2728
|
+
// Only creation/import controls above require an available root.
|
|
2482
2729
|
const projectGroups = projects.length ? workspaceProjectGroups(projects) : [];
|
|
2483
2730
|
for (const [groupIndex, group] of projectGroups.entries()) {
|
|
2484
2731
|
const groupGridId = `ws-project-group-grid-${groupIndex}`;
|
|
@@ -2505,13 +2752,15 @@
|
|
|
2505
2752
|
const wfName = wsRenamed(p)
|
|
2506
2753
|
? `<span class="ws-sep"> · </span><span class="ws-meta-wf" data-tip="The workflow this project runs on:\n${escapeAttr(p.app)}">${escapeHtml(p.app)}</span>`
|
|
2507
2754
|
: '';
|
|
2508
|
-
html += `<div class="ws-card" role="button" tabindex="0" data-open="${escapeAttr(p.id)}">` +
|
|
2755
|
+
html += `<div class="ws-card" role="button" tabindex="0" data-open="${escapeAttr(p.id)}"${p.registrationId ? ` data-registration-id="${escapeAttr(p.registrationId)}"` : ''}${p.registrationState === 'unavailable' ? ` data-command-id="shell.project-registration-review#${escapeAttr(p.registrationId)}" data-command-instance-label="${escapeAttr(p.name)}"` : ''}>` +
|
|
2509
2756
|
thumbBandHtml(p, displayApp) +
|
|
2510
2757
|
`<span class="ws-body"><span><span class="ws-name">${escapeHtml(p.name)}</span>` +
|
|
2511
2758
|
(projectCapability ? `<span class="ws-meta">${escapeHtml(projectCapability)}</span>` : '') +
|
|
2512
2759
|
(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>` : '') +
|
|
2760
|
+
`<span class="ws-meta ws-registration-status"${p.registrationState === 'unavailable' ? '' : ' hidden'}>${escapeHtml(p.registrationReason || 'Project folder unavailable. Locate or restore it.')}</span>` +
|
|
2761
|
+
`<span class="ws-meta ws-registration-location-note"${p.registrationState !== 'unavailable' && p.registrationLocationWarning ? '' : ' hidden'}>${escapeHtml(p.registrationLocationWarning || '')}</span>` +
|
|
2513
2762
|
`<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>` +
|
|
2514
|
-
`<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>` +
|
|
2763
|
+
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}"${p.registrationState === 'unavailable' ? ` data-command-id="shell.project-registration-review#${escapeAttr(p.registrationId)}" data-command-instance-label="${escapeAttr(p.name)}"` : ''} aria-label="${p.registrationState === 'unavailable' ? 'Review project folder' : 'Project actions'}" data-tip="${p.registrationState === 'unavailable' ? 'Review project folder' : p.importedMidSave ? 'Rename · Thumbnail · Mark as checked · Duplicate · Export · Archive' : 'Rename · Thumbnail · Duplicate · Export · Archive'}">⋯</button>` +
|
|
2515
2764
|
`</span></div>`;
|
|
2516
2765
|
}
|
|
2517
2766
|
html += `</div></section>`;
|
|
@@ -2523,7 +2772,7 @@
|
|
|
2523
2772
|
// empty, and telling someone with 11 projects "No projects yet — start one" is a lie that reads
|
|
2524
2773
|
// like their work is gone. The toast alone can't carry this: it auto-dismisses, and the false
|
|
2525
2774
|
// sentence stays on screen. Say what happened and offer the retry instead.
|
|
2526
|
-
if (!projects.length) {
|
|
2775
|
+
if (!projects.length && !rootUnavailable) {
|
|
2527
2776
|
if (projectsLoadError) {
|
|
2528
2777
|
// role=status/polite, not alert: this can appear on an ordinary repaint (any action that
|
|
2529
2778
|
// re-runs loadProjects re-renders it), and assertive would interrupt a screen-reader user
|
|
@@ -2564,11 +2813,14 @@
|
|
|
2564
2813
|
rows += `<div class="ws-archived-row">` +
|
|
2565
2814
|
`<span class="ws-archived-info">` +
|
|
2566
2815
|
`<span class="ws-archived-name">${escapeHtml(p.name)}</span>` +
|
|
2816
|
+
(p.registrationState !== 'unavailable' && p.registrationLocationWarning ? `<span class="ws-registration-location-note">${escapeHtml(p.registrationLocationWarning)}</span>` : '') +
|
|
2567
2817
|
`<span class="ws-archived-meta"${wfTip}>${escapeHtml(displayApp)} · archived <span class="t">${escapeHtml(relAgo(p.updatedAt))}</span></span>` +
|
|
2568
2818
|
`</span>` +
|
|
2569
2819
|
`<span class="ws-archived-actions">` +
|
|
2570
|
-
|
|
2571
|
-
|
|
2820
|
+
(p.registrationState === 'unavailable'
|
|
2821
|
+
? `<button type="button" class="btn-mini" data-project-registration-review="${escapeAttr(p.registrationId)}" data-command-id="shell.project-registration-review#${escapeAttr(p.registrationId)}" data-command-instance-label="${escapeAttr(p.name)}">Review folder…</button>`
|
|
2822
|
+
: `<button type="button" class="btn-mini ws-restore" data-restore="${escapeAttr(p.id)}" data-tip="Un-archive — returns to the live grid">↺ Restore</button>` +
|
|
2823
|
+
`<button type="button" class="btn-mini ws-del" data-delete-archived="${escapeAttr(p.id)}" data-tip="Permanently erase this project from disk">Delete…</button>`) +
|
|
2572
2824
|
`</span>` +
|
|
2573
2825
|
`</div>`;
|
|
2574
2826
|
}
|
|
@@ -2577,7 +2829,6 @@
|
|
|
2577
2829
|
`<div class="ws-archived-list">${rows}</div>` +
|
|
2578
2830
|
`</details>`;
|
|
2579
2831
|
}
|
|
2580
|
-
}
|
|
2581
2832
|
// Carry the user's place across the rebuild below, which replaces the landing wholesale: that
|
|
2582
2833
|
// drops focus to <body>, collapses the Archived disclosure, and can leave a scrolled grid showing
|
|
2583
2834
|
// a different slice. Every caller used to be a click or keypress in this tab, so the user's
|
|
@@ -2592,6 +2843,9 @@
|
|
|
2592
2843
|
const search = document.activeElement?.id === 'ws-landing-search' ? document.activeElement : null;
|
|
2593
2844
|
const keepCaret = search ? [search.selectionStart, search.selectionEnd] : null;
|
|
2594
2845
|
$landing.innerHTML = html;
|
|
2846
|
+
registeredCards.clear();
|
|
2847
|
+
for (const card of $landing.querySelectorAll('[data-registration-id]')) registeredCards.set(card.dataset.registrationId, card);
|
|
2848
|
+
window.flolessProjectReconciliation?.paintNotice();
|
|
2595
2849
|
// Reapply in this order: the disclosure changes the scrollable height, so it must land before the
|
|
2596
2850
|
// offset; focus lands next, with preventScroll so its scroll-into-view can't undo that offset. The
|
|
2597
2851
|
// search filter runs after both: it needs the restored focus to put the caret back, and it hides the
|
|
@@ -2632,7 +2886,7 @@
|
|
|
2632
2886
|
const terms = landingQuery.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
2633
2887
|
let shown = 0;
|
|
2634
2888
|
for (const card of $landing.querySelectorAll('.ws-grid .ws-card[data-open]')) {
|
|
2635
|
-
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();
|
|
2889
|
+
const hay = Array.from(card.querySelectorAll('.ws-name, .ws-meta:not(.ws-meta-app):not(.ws-registration-status):not(.ws-registration-location-note), .ws-meta-kind, .ws-meta-wf'), (el) => el.textContent).join(' ').toLowerCase();
|
|
2636
2890
|
card.hidden = !terms.every((t) => hay.includes(t));
|
|
2637
2891
|
if (!card.hidden) shown++;
|
|
2638
2892
|
}
|
|
@@ -2757,6 +3011,8 @@
|
|
|
2757
3011
|
}
|
|
2758
3012
|
|
|
2759
3013
|
$landing.addEventListener('click', async (e) => {
|
|
3014
|
+
const registrationReview = e.target.closest('[data-project-registration-review]');
|
|
3015
|
+
if (registrationReview) { window.flolessProjectReconciliation?.openRegistration(registrationReview.dataset.projectRegistrationReview); return; }
|
|
2760
3016
|
const groupToggle = e.target.closest('[data-project-group-toggle]');
|
|
2761
3017
|
if (groupToggle) {
|
|
2762
3018
|
const expanded = groupToggle.getAttribute('aria-expanded') !== 'true';
|
|
@@ -3010,6 +3266,9 @@
|
|
|
3010
3266
|
// their page counts and the proposed checklist can be shown. The setup dialog asks only the
|
|
3011
3267
|
// folder and the client's name.
|
|
3012
3268
|
createFromDrawing(appId, templateId, [], { kind: 'drawing-check-profile', sourceLabel: 'Client profile', returnFocus: seed });
|
|
3269
|
+
} else if (seed.dataset.seedAction === 'general-project') {
|
|
3270
|
+
// A General project starts from nothing but its name and folder (#2470).
|
|
3271
|
+
createFromDrawing(appId, templateId, [], { kind: 'general-project', sourceLabel: 'Blank project', returnFocus: seed });
|
|
3013
3272
|
} else {
|
|
3014
3273
|
// Unreachable today, and it must not be SILENT the day it isn't: an unhandled kind still
|
|
3015
3274
|
// renders a full dashed, focusable card, so without this the first person to add one gets a
|
|
@@ -3199,11 +3458,13 @@
|
|
|
3199
3458
|
if (!project || !failedOperationId || isTeklaParserProject(project)) return;
|
|
3200
3459
|
try {
|
|
3201
3460
|
const started = await api(`/api/model-imports/${encodeURIComponent(failedOperationId)}/retry`, { method: 'POST', body: '{}' });
|
|
3461
|
+
sourceControlOutcome = { verb: 'retry', projectId: project.id, operationId: failedOperationId, ok: true };
|
|
3202
3462
|
revitActiveOperation = started.operation;
|
|
3203
3463
|
paintRevitSourceState('Replacing source RVT…', 'Reading the already stored RVT again…');
|
|
3204
3464
|
paintRevitSourceActions('active', true);
|
|
3205
3465
|
pollRevitImport(started.operation.operationId, project.id);
|
|
3206
3466
|
} catch (error) {
|
|
3467
|
+
sourceControlOutcome = { verb: 'retry', projectId: project.id, operationId: failedOperationId, ok: false };
|
|
3207
3468
|
paintRevitSourceState('Couldn’t retry the RVT', `${error && error.message || error} The existing model was not changed.`);
|
|
3208
3469
|
paintRevitSourceActions('failed', revitSourceState?.canReplace === true, revitActiveOperation?.failure?.retryable !== false, revitActiveOperation);
|
|
3209
3470
|
}
|
|
@@ -3222,11 +3483,13 @@
|
|
|
3222
3483
|
? `/api/tekla-imports/${encodeURIComponent(operationId)}/cancel`
|
|
3223
3484
|
: `/api/model-imports/${encodeURIComponent(operationId)}/cancel`;
|
|
3224
3485
|
await api(cancelPath, { method: 'POST', body: '{}' });
|
|
3486
|
+
sourceControlOutcome = { verb: 'cancel', projectId, operationId, ok: true };
|
|
3225
3487
|
revitActiveOperation = null;
|
|
3226
3488
|
paintRevitSourceState('Replacement cancelled', 'The existing model was not changed.');
|
|
3227
3489
|
paintRevitSourceActions('ready', true);
|
|
3228
3490
|
$revitReplace?.focus();
|
|
3229
3491
|
} catch (error) {
|
|
3492
|
+
sourceControlOutcome = { verb: 'cancel', projectId, operationId, ok: false };
|
|
3230
3493
|
const status = error && error.status;
|
|
3231
3494
|
showToast(status === 403
|
|
3232
3495
|
? `We couldn’t cancel this import because ${isTeklaParserProject() ? 'Tekla Parser' : 'Revit'} access is not available for this account. Check your account access, then try again.`
|
|
@@ -3511,15 +3774,8 @@
|
|
|
3511
3774
|
const code = String(error && (error.code || error.body?.code) || '');
|
|
3512
3775
|
// Account access can expire while this dialog is open, before the folder chooser
|
|
3513
3776
|
// or project creation runs. Name that cause without blaming the selected folder.
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
if (access?.reason === 'session-expired') return 'Your FloLess sign-in has expired. Sign in again, then try again.';
|
|
3517
|
-
if (access?.reason === 'signed-out') return 'You are signed out of FloLess. Sign in again, then try again.';
|
|
3518
|
-
if (access?.reason === 'seat-taken') return 'Your FloLess session has ended. Sign in again, then try again.';
|
|
3519
|
-
if (access?.state === 'expired') return 'Your FloLess subscription has expired. Renew your subscription, then try again.';
|
|
3520
|
-
if (access?.reason === 'no-subscription') return 'This account does not have a FloLess subscription. Sign in with a subscribed account or subscribe, then try again.';
|
|
3521
|
-
return 'Sign in to FloLess to check your account access, then try again.';
|
|
3522
|
-
}
|
|
3777
|
+
const access = bridge.accountAccessText?.(error);
|
|
3778
|
+
if (access) return access;
|
|
3523
3779
|
// A setup refusal with no sentence for the person (#1965 review, round 3). The code covers several
|
|
3524
3780
|
// causes — the parser's setup has not finished, or a check refused this project while its card shows
|
|
3525
3781
|
// the ready state — so the sentence names none of them, only the card that shows what is left to do.
|
|
@@ -3589,7 +3845,9 @@
|
|
|
3589
3845
|
// never be the one shown as chosen and sent.
|
|
3590
3846
|
// Setup kinds that create a project only — no AI Chat intake, no drawing-intake task. The two model
|
|
3591
3847
|
// sources are read by FloLess itself; a Drawing Checker profile starts empty and is built on its page.
|
|
3592
|
-
const NO_CHAT_SETUP_KINDS = ['rvt', 'tekla-source', 'drawing-check-profile'];
|
|
3848
|
+
const NO_CHAT_SETUP_KINDS = ['rvt', 'tekla-source', 'drawing-check-profile', 'general-project'];
|
|
3849
|
+
// Setup kinds that start from no file at all: a Drawing Checker profile and a General project.
|
|
3850
|
+
const NO_FILE_SETUP_KINDS = ['drawing-check-profile', 'general-project'];
|
|
3593
3851
|
function projectSetupProvider(state) {
|
|
3594
3852
|
if (!state || NO_CHAT_SETUP_KINDS.includes(state.kind)) return null;
|
|
3595
3853
|
const runtimes = bridge.chatProviderRuntimes?.() || [];
|
|
@@ -3715,6 +3973,10 @@
|
|
|
3715
3973
|
$projectSetupCreateOnly.classList.toggle('primary', !provider);
|
|
3716
3974
|
$projectSetupTitle.textContent = `New ${descDisplayName(state.templateId)} project`;
|
|
3717
3975
|
$projectSetupSourceName.textContent = state.sourceLabel || state.files[0]?.name || (state.kind === 'rvt' ? 'Revit model' : 'Drawing set');
|
|
3976
|
+
// A General project has no source to name, only where it starts from.
|
|
3977
|
+
const $sourceKicker = $projectSetupSourceName.previousElementSibling;
|
|
3978
|
+
if ($sourceKicker) $sourceKicker.textContent = state.kind === 'general-project' ? 'Starting point' : 'Source';
|
|
3979
|
+
$projectSetupSourceName.parentElement?.setAttribute('aria-label', state.kind === 'general-project' ? 'Starting point' : 'Selected source drawings');
|
|
3718
3980
|
$projectSetupCreateOnly.textContent = state.busy ? 'Creating…' : (NO_CHAT_SETUP_KINDS.includes(state.kind) ? 'Create project' : 'Create project only');
|
|
3719
3981
|
$projectSetupSourceCount.textContent = state.files.length > 1 ? `+ ${state.files.length - 1} more` : '';
|
|
3720
3982
|
$projectSetupFolder.textContent = state.directory
|
|
@@ -3847,12 +4109,13 @@
|
|
|
3847
4109
|
await importTeklaIntoProject(project, state.teklaSource, state.appId);
|
|
3848
4110
|
return;
|
|
3849
4111
|
}
|
|
3850
|
-
if (state.kind === 'drawing-check-profile') {
|
|
4112
|
+
if (state.kind === 'drawing-check-profile' || state.kind === 'general-project') {
|
|
3851
4113
|
projects.unshift(project);
|
|
3852
4114
|
track('workspace_project_created', { app: state.appId });
|
|
3853
4115
|
setProjectSetupBusy(false);
|
|
3854
4116
|
closeProjectSetup({ restoreFocus: false });
|
|
3855
|
-
|
|
4117
|
+
// A General project opens on Knowledge: the job's context, and the first thing to add.
|
|
4118
|
+
await openProject(project.id, state.kind === 'general-project' ? 'knowledge' : 'model');
|
|
3856
4119
|
return;
|
|
3857
4120
|
}
|
|
3858
4121
|
projects.unshift(project);
|
|
@@ -3941,8 +4204,8 @@
|
|
|
3941
4204
|
*/
|
|
3942
4205
|
async function createFromDrawing(appId, templateId, files, { kind = 'drawings', sourceLabel = '', teklaSource = null, returnFocus = null } = {}) {
|
|
3943
4206
|
if (!$projectSetup || projectSetupState) return false;
|
|
3944
|
-
// A Drawing Checker profile
|
|
3945
|
-
if (!Array.isArray(files) || (!files.length && kind
|
|
4207
|
+
// A Drawing Checker profile and a General project start with no source file: what goes in them comes later.
|
|
4208
|
+
if (!Array.isArray(files) || (!files.length && !NO_FILE_SETUP_KINDS.includes(kind))) return false;
|
|
3946
4209
|
if (kind === 'drawings' && files.length > 20) {
|
|
3947
4210
|
showToast('Choose up to 20 drawings for a new project.', 'warn');
|
|
3948
4211
|
return false;
|
|
@@ -4787,10 +5050,23 @@
|
|
|
4787
5050
|
const nav = opts || {};
|
|
4788
5051
|
// Latest navigation wins from the first line: an older open still waiting on a lookup must not replace a newer one.
|
|
4789
5052
|
const navToken = ++openNavSeq;
|
|
5053
|
+
// A caller acting for someone (a chat card's "Open in the model", #2450) can be overtaken by that
|
|
5054
|
+
// person's next click, which may not open a project at all. Until this open changes anything, it
|
|
5055
|
+
// also gives way when its caller says it is no longer wanted.
|
|
5056
|
+
const unwanted = () => navToken !== openNavSeq || (typeof nav.stillWanted === 'function' && !nav.stillWanted());
|
|
4790
5057
|
let p = projects.find((x) => x.id === id);
|
|
4791
5058
|
if (!p) { try { p = (await api('/api/projects')).projects.find((x) => x.id === id); } catch { /* fall through */ } }
|
|
4792
|
-
if (
|
|
5059
|
+
if (unwanted()) return STAYED_IN_PROJECT;
|
|
4793
5060
|
if (!p) { showToast('Project not found — it may have been archived.', 'warn'); return loadProjects(); }
|
|
5061
|
+
if (window.flolessWorkspaceRoot?.current()?.available === false) {
|
|
5062
|
+
if (p.registrationId) window.flolessProjectReconciliation?.openRegistration(p.registrationId);
|
|
5063
|
+
else window.flolessWorkspaceRoot.open();
|
|
5064
|
+
return STAYED_IN_PROJECT;
|
|
5065
|
+
}
|
|
5066
|
+
if (p.registrationState === 'unavailable' && p.registrationId) {
|
|
5067
|
+
window.flolessProjectReconciliation?.openRegistration(p.registrationId);
|
|
5068
|
+
return STAYED_IN_PROJECT;
|
|
5069
|
+
}
|
|
4794
5070
|
// Never a broken open (spec §3.2): a project whose app has no client descriptor can't be rendered
|
|
4795
5071
|
// — toast and bail BEFORE mutating any view state, matching the create-card skip. wsApp() would
|
|
4796
5072
|
// return null for it and the frame wiring would fail.
|
|
@@ -4804,7 +5080,7 @@
|
|
|
4804
5080
|
return;
|
|
4805
5081
|
}
|
|
4806
5082
|
if (!nav.skipLeaveGuard && current && current.id !== p.id && !(await leaveOpenProject(nav.returnFocus))) return STAYED_IN_PROJECT;
|
|
4807
|
-
if (
|
|
5083
|
+
if (unwanted()) return STAYED_IN_PROJECT;
|
|
4808
5084
|
if (current?.uuid !== p.uuid) revisionNoteEditorGeneration++;
|
|
4809
5085
|
current = p;
|
|
4810
5086
|
// #1890: a new workspace conversation suggests this project's units (the one opened last).
|
|
@@ -4821,6 +5097,7 @@
|
|
|
4821
5097
|
if (pendingPresenceToast) pendingPresenceToast();
|
|
4822
5098
|
pendingPresenceToast = null;
|
|
4823
5099
|
exportState = null;
|
|
5100
|
+
exportStateFrom = null;
|
|
4824
5101
|
exportUnits = null; // a new project's units arrive with its export listing; never inherit the last one's
|
|
4825
5102
|
renderReadinessState = null;
|
|
4826
5103
|
let sourceStateProbe = null;
|
|
@@ -4832,6 +5109,7 @@
|
|
|
4832
5109
|
// file resets state to avoid — and the next path that renders rows would inherit it.
|
|
4833
5110
|
histDiffSupported = false;
|
|
4834
5111
|
$projName.textContent = p.name;
|
|
5112
|
+
paintProjectLocationWarning(p);
|
|
4835
5113
|
// Lazily src the frames once per project; switching steps only toggles hidden so the
|
|
4836
5114
|
// editor's state survives a Source⇄Traced round-trip. Frame URLs come from the app descriptor:
|
|
4837
5115
|
// the 'model' frame loads the app's editor; the 'drawings' frame loads its filter (steel) OR is
|
|
@@ -4864,13 +5142,17 @@
|
|
|
4864
5142
|
// would open an empty pane, so it lands on its Checker step. Scoped to Drawing Checker on purpose:
|
|
4865
5143
|
// Revit and Tekla keep their existing behaviour for a carried-over step.
|
|
4866
5144
|
if (isDrawingCheckProject(p) && !d.steps.some((step) => step.key === initialStep)) initialStep = 'model';
|
|
5145
|
+
// A sourceless project (General, #2470) has no Model, Drawings, Exports or History step; a step carried
|
|
5146
|
+
// over from another project lands on its first step instead of a pane it does not have.
|
|
5147
|
+
if (d.sourceless && !d.steps.some((step) => step.key === initialStep)) initialStep = d.steps[0].key;
|
|
4867
5148
|
if ((d.filter || isModelSourceProject(p)) && ['model', 'exports', 'history'].includes(initialStep)) {
|
|
4868
5149
|
pendingPresenceStep = { projectId: p.id, step: initialStep };
|
|
4869
5150
|
}
|
|
4870
5151
|
// The LIVE app id, deliberately: the frames address the server with it (contract reads, saves),
|
|
4871
5152
|
// and after a rename only the live id resolves. Only the descriptor came from the lineage root.
|
|
4872
5153
|
const qs = `?app=${encodeURIComponent(p.app)}&project=${encodeURIComponent(p.id)}`;
|
|
4873
|
-
|
|
5154
|
+
// No editor (a General project): the model frame stays blank and hidden, never `null?app=…`.
|
|
5155
|
+
frames.model.dataset.want = d.editor ? `${d.editor}${qs}` : '';
|
|
4874
5156
|
frames.drawings.dataset.want = d.filter ? `${d.filter}${qs}` : '';
|
|
4875
5157
|
renderStepTabs(); // paint the tab labels for THIS app before the first step shows
|
|
4876
5158
|
disposeModelEditorFrame('project-open');
|
|
@@ -4958,6 +5240,7 @@
|
|
|
4958
5240
|
function applyModelPresence(present) {
|
|
4959
5241
|
projectContractLifecycle = present;
|
|
4960
5242
|
exportsHasModel = present === 'model';
|
|
5243
|
+
retrySourcelessPresence(present);
|
|
4961
5244
|
renderApprovalHeader();
|
|
4962
5245
|
applyStageGating();
|
|
4963
5246
|
// A lifecycle probe may resolve after the saved-filter card already painted under `unknown`.
|
|
@@ -4966,6 +5249,47 @@
|
|
|
4966
5249
|
if (currentStep === 'drawings' && lastRevState === 'pending') retireRevisionCardForStrip(revCardReq);
|
|
4967
5250
|
}
|
|
4968
5251
|
|
|
5252
|
+
/** Re-ask a General project's lifecycle after a check that settled `unknown` (see SOURCELESS_PRESENCE_RETRIES). */
|
|
5253
|
+
function retrySourcelessPresence(present) {
|
|
5254
|
+
const project = current;
|
|
5255
|
+
if (!project || !wsDescOf(project)?.sourceless) return;
|
|
5256
|
+
// A fresh count per open: "open the project again to check again" is how the person retries.
|
|
5257
|
+
if (sourcelessPresence.projectId !== project.id || sourcelessPresence.openSeq !== openNavSeq) {
|
|
5258
|
+
clearTimeout(sourcelessPresence.timer);
|
|
5259
|
+
sourcelessPresence = { projectId: project.id, openSeq: openNavSeq, tries: 0, gaveUp: false, timer: null };
|
|
5260
|
+
}
|
|
5261
|
+
if (present !== 'unknown') {
|
|
5262
|
+
// A definite answer ends any retry still waiting, so it can never supersede this answer later.
|
|
5263
|
+
clearTimeout(sourcelessPresence.timer);
|
|
5264
|
+
sourcelessPresence = { ...sourcelessPresence, tries: 0, gaveUp: false, timer: null };
|
|
5265
|
+
return;
|
|
5266
|
+
}
|
|
5267
|
+
if (sourcelessPresence.tries >= SOURCELESS_PRESENCE_RETRIES) {
|
|
5268
|
+
if (!sourcelessPresence.gaveUp) console.warn('[workspaces] gave up checking whether a General project holds a model', { projectId: project.id, tries: sourcelessPresence.tries });
|
|
5269
|
+
sourcelessPresence.gaveUp = true;
|
|
5270
|
+
return;
|
|
5271
|
+
}
|
|
5272
|
+
sourcelessPresence.tries += 1;
|
|
5273
|
+
clearTimeout(sourcelessPresence.timer);
|
|
5274
|
+
const openSeq = sourcelessPresence.openSeq;
|
|
5275
|
+
sourcelessPresence.timer = setTimeout(() => {
|
|
5276
|
+
// Only for the same open of the same project: leaving and reopening starts its own count.
|
|
5277
|
+
if (current && current.id === project.id && openNavSeq === openSeq && sourcelessPresence.openSeq === openSeq) {
|
|
5278
|
+
refreshModelPresence(project.id, project.app, true).catch((e) => console.error('[workspaces] could not re-check model presence', e));
|
|
5279
|
+
}
|
|
5280
|
+
}, 2000 * sourcelessPresence.tries);
|
|
5281
|
+
}
|
|
5282
|
+
|
|
5283
|
+
/** "Check again" on a General project whose checks gave up. Returns whether it applied. */
|
|
5284
|
+
function recheckSourcelessPresence() {
|
|
5285
|
+
const project = current;
|
|
5286
|
+
if (!project || !wsDescOf(project)?.sourceless || !sourcelessPresence.gaveUp || sourcelessPresence.projectId !== project.id) return false;
|
|
5287
|
+
sourcelessPresence = { ...sourcelessPresence, tries: 0, gaveUp: false, timer: null };
|
|
5288
|
+
renderApprovalHeader();
|
|
5289
|
+
refreshModelPresence(project.id, project.app, true).catch((e) => console.error('[workspaces] could not re-check model presence', e));
|
|
5290
|
+
return true;
|
|
5291
|
+
}
|
|
5292
|
+
|
|
4969
5293
|
/**
|
|
4970
5294
|
* Hand the saved-checkpoint status to the stage strip, which owns Done / Now / Next for it, and
|
|
4971
5295
|
* report whether the hand-off happened.
|
|
@@ -5038,6 +5362,7 @@
|
|
|
5038
5362
|
exportSourcesState = { status: 'unavailable', data: null, selected: null, open: false };
|
|
5039
5363
|
closeApprovalReview();
|
|
5040
5364
|
exportState = null;
|
|
5365
|
+
exportStateFrom = null;
|
|
5041
5366
|
exportUnits = null; // a new project's units arrive with its export listing; never inherit the last one's
|
|
5042
5367
|
renderReadinessState = null;
|
|
5043
5368
|
resetRevisionState();
|
|
@@ -5808,6 +6133,13 @@
|
|
|
5808
6133
|
const show = k === s && (k !== 'drawings' || drawingsHasFrame);
|
|
5809
6134
|
f.hidden = !show;
|
|
5810
6135
|
if (show && !f.dataset.loaded && f.dataset.want) { f.src = f.dataset.want; f.dataset.loaded = '1'; }
|
|
6136
|
+
// Coming back to an editor that stayed loaded while hidden: tell it, so it can read again what changed on
|
|
6137
|
+
// another step meanwhile (the Drawing Checker's references after a Knowledge change, #2482). Others ignore it.
|
|
6138
|
+
else if (show && k === 'model' && f.dataset.loaded) {
|
|
6139
|
+
const project = typeof current !== 'undefined' ? current : null;
|
|
6140
|
+
try { if (project) f.contentWindow?.postMessage({ type: 'floless:step-shown', step: s, projectId: project.id }, location.origin); }
|
|
6141
|
+
catch { /* the frame is between documents */ }
|
|
6142
|
+
}
|
|
5811
6143
|
}
|
|
5812
6144
|
if (window.flolessLeftPane) {
|
|
5813
6145
|
window.flolessLeftPane.setWorkspaceModelVisible(s === 'model');
|
|
@@ -5903,6 +6235,14 @@
|
|
|
5903
6235
|
|| !['clean', 'dirty', 'saving', 'error', 'conflict'].includes(message.state)) return;
|
|
5904
6236
|
modelContractSaveState = { projectId: current.id, appId: current.app, state: message.state, generation: message.generation };
|
|
5905
6237
|
});
|
|
6238
|
+
// The Drawing Checker's "Use the design set" sends a person to this project's Knowledge step, where the design
|
|
6239
|
+
// set lives (epic #2399 0d-dc). Only from the editor frame of the project on screen, and only to Knowledge.
|
|
6240
|
+
window.addEventListener('message', (event) => {
|
|
6241
|
+
const message = event.data;
|
|
6242
|
+
if (event.origin !== location.origin || event.source !== frames.model?.contentWindow
|
|
6243
|
+
|| !message || message.type !== 'floless:open-knowledge' || !current || message.projectId !== current.id) return;
|
|
6244
|
+
setStep('knowledge');
|
|
6245
|
+
});
|
|
5906
6246
|
const approvalPhaseText = {
|
|
5907
6247
|
saving: 'Saving model edits…', comparing: 'Comparing changes…', approving: 'Approving and compiling…',
|
|
5908
6248
|
reconciling: 'Reconciling approval…', approved: 'Approved', failed: 'Nothing was approved.', stale: 'The review changed.',
|
|
@@ -6294,7 +6634,10 @@
|
|
|
6294
6634
|
const accepted = res && res.version && res.version.approval && res.version.approval.acceptedImportFindings;
|
|
6295
6635
|
const headline = accepted ? importFindingsCopy(accepted).approved(Number.isInteger(n) ? n : null)
|
|
6296
6636
|
: `Approved${Number.isInteger(n) ? ` as v${n}` : ''}.`;
|
|
6297
|
-
|
|
6637
|
+
// #2449: an approval resting on connection assumptions (or one whose record could not be read) is never announced
|
|
6638
|
+
// as a plain approval either; the server's own sentence, the same one History shows.
|
|
6639
|
+
const assumed = res && res.connectionAssumptions && typeof res.connectionAssumptions.note === 'string' ? res.connectionAssumptions.note : '';
|
|
6640
|
+
showToast(`${headline} ${assumed ? `${assumed} ` : ''}${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');
|
|
6298
6641
|
track('workspace_project_approved', { app: project.app });
|
|
6299
6642
|
if (bridge.markWorkspaceApproved && wsDescOf(project)?.docGuide) bridge.markWorkspaceApproved(project.app);
|
|
6300
6643
|
if (!$wsExports.hidden) safeRenderExports('after approving this version');
|
|
@@ -6305,7 +6648,7 @@
|
|
|
6305
6648
|
: 'No changes remain pending.';
|
|
6306
6649
|
// The footer described the decision ("…will be approved…"); the decision has happened.
|
|
6307
6650
|
$approvalCounts.textContent = '';
|
|
6308
|
-
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> The approved model and compiled workflow are ready.${revisionNoteStatus ? ' ' + escapeHtml(revisionNoteStatus) : ''}${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
|
|
6651
|
+
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> The approved model and compiled workflow are ready.${assumed ? ' ' + escapeHtml(assumed) : ''}${revisionNoteStatus ? ' ' + escapeHtml(revisionNoteStatus) : ''}${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
|
|
6309
6652
|
setApprovalPhase('approved', accepted ? headline : `Approved${Number.isInteger(n) ? ` as v${n}` : ''}`);
|
|
6310
6653
|
$approvalClose.focus();
|
|
6311
6654
|
}
|
|
@@ -6737,6 +7080,8 @@
|
|
|
6737
7080
|
});
|
|
6738
7081
|
$approveBtn?.addEventListener('click', () => {
|
|
6739
7082
|
if ($approveBtn.getAttribute('aria-disabled') === 'true') {
|
|
7083
|
+
// "Couldn’t check project" on a General project: the click is the "check again" its tip offers.
|
|
7084
|
+
if (recheckSourcelessPresence()) return;
|
|
6740
7085
|
// Re-ask only where the answer can differ. A failed probe can; so can `no-contract`, which stops
|
|
6741
7086
|
// being true the moment anything writes a model — and the writers we know about say so
|
|
6742
7087
|
// explicitly, but this is the backstop for the ones we do not (another tab, the terminal AI, a
|
|
@@ -6860,6 +7205,9 @@
|
|
|
6860
7205
|
let lastStepHeadHtml = null; // same repaint-iff-changed contract as lastRefsHtml
|
|
6861
7206
|
let lastViewKey = null; // identity of what the viewer host is currently showing
|
|
6862
7207
|
let kbFocusSourceId = null; // consumed once after a repaint, to restore focus to a filename button
|
|
7208
|
+
// The design set the person just changed from this screen: the first repaint that shows it (whichever read lands it,
|
|
7209
|
+
// this screen's own or the change event's) brings it into view and keeps keyboard focus in the column.
|
|
7210
|
+
let kbFocusDesignSet = null; // { sourceId } | null
|
|
6863
7211
|
let kbAdjustBusy = null; // project id of an in-flight Adjust submit (or null) — scoped to the
|
|
6864
7212
|
// project so switching away can't strand another project's box; also the
|
|
6865
7213
|
// re-entry guard (no duplicate queue). See kbAdjustActive.
|
|
@@ -6881,7 +7229,8 @@
|
|
|
6881
7229
|
* has a non-empty draft. Self-heals — the moment it's none of those, the next tick repaints fresh. */
|
|
6882
7230
|
function kbAdjustActive() {
|
|
6883
7231
|
if (kbAdjustBusy && current && kbAdjustBusy === current.id) return true;
|
|
6884
|
-
|
|
7232
|
+
// By its own input: the design set's sheet index is a .kb-adjust disclosure too, and comes first (#2399 0b).
|
|
7233
|
+
const det = $wsKnowledge.querySelector('#kb-adjust-input')?.closest('.kb-adjust');
|
|
6885
7234
|
if (!det) return false;
|
|
6886
7235
|
if (det.contains(document.activeElement)) return true;
|
|
6887
7236
|
const ta = det.querySelector('#kb-adjust-input');
|
|
@@ -6944,12 +7293,15 @@
|
|
|
6944
7293
|
async function loadKnowledgeState(proj) {
|
|
6945
7294
|
// Each read is bounded (#1604): the 3-second poll skips its ticks while a render is out, so a
|
|
6946
7295
|
// request that never answered would stop the column refreshing for good.
|
|
6947
|
-
const bounded = () => ({
|
|
6948
|
-
const [status, reqs, company] = await Promise.all([
|
|
7296
|
+
const bounded = () => ({ timeoutMs: 90_000 });
|
|
7297
|
+
const [status, reqs, company, designSet] = await Promise.all([
|
|
6949
7298
|
api(kbUrl(proj.id, '/status'), bounded()),
|
|
6950
7299
|
api('/api/requests', bounded()).catch(() => []),
|
|
6951
7300
|
api(`/api/company-knowledge?projectId=${encodeURIComponent(proj.id)}`, bounded())
|
|
6952
7301
|
.catch((error) => ({ configured: false, loadError: String((error && error.message) || error) })),
|
|
7302
|
+
// #2399 slice 0b: a design set that cannot be read is said as such, never as "none".
|
|
7303
|
+
api(`/api/projects/${encodeURIComponent(proj.id)}/design-set`, bounded())
|
|
7304
|
+
.catch(() => ({ status: 'unknown', revision: 0, warnings: [{ code: 'unreadable', message: 'FloLess could not read the design set just now.' }] })),
|
|
6953
7305
|
]);
|
|
6954
7306
|
const list = Array.isArray(reqs) ? reqs : (reqs.requests || []);
|
|
6955
7307
|
const manifest = status.manifest || { revision: 0, currentGeneration: null, sources: [] };
|
|
@@ -6960,6 +7312,7 @@
|
|
|
6960
7312
|
organize: status.organize || null,
|
|
6961
7313
|
queued: list.filter((r) => r && r.type === 'knowledge-organize' && r.project === proj.id),
|
|
6962
7314
|
company,
|
|
7315
|
+
designSet,
|
|
6963
7316
|
};
|
|
6964
7317
|
}
|
|
6965
7318
|
|
|
@@ -6984,11 +7337,40 @@
|
|
|
6984
7337
|
: `${(n / (1024 * 1024)).toFixed(1)} MB`);
|
|
6985
7338
|
function kbIcon(mime) {
|
|
6986
7339
|
const m = String(mime || '');
|
|
7340
|
+
// #2491 R6.3: Word, Excel and email, in the same glyph family. Matched on the exact stored types (the server
|
|
7341
|
+
// stores one canonical type per kind, macro-enabled files included).
|
|
7342
|
+
if (m === KB_MIME_DOCX) return { cls: 'doc', glyph: '▥' };
|
|
7343
|
+
if (m === KB_MIME_XLSX) return { cls: 'sheet', glyph: '◧' };
|
|
7344
|
+
if (m === KB_MIME_EML || m === KB_MIME_MSG) return { cls: 'mail', glyph: '◩' };
|
|
6987
7345
|
if (m.includes('pdf')) return { cls: 'pdf', glyph: '▤' };
|
|
6988
7346
|
if (m.startsWith('image/')) return { cls: 'img', glyph: '▣' };
|
|
6989
7347
|
if (m.includes('csv')) return { cls: 'sheet', glyph: '◧' };
|
|
6990
7348
|
return { cls: 'txt', glyph: '▦' };
|
|
6991
7349
|
}
|
|
7350
|
+
// #2491 R6.3: the office formats whose TEXT FloLess reads; the original is only ever downloaded.
|
|
7351
|
+
const KB_MIME_DOCX = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
|
7352
|
+
const KB_MIME_XLSX = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
7353
|
+
const KB_MIME_MSG = 'application/vnd.ms-outlook';
|
|
7354
|
+
const KB_MIME_EML = 'message/rfc822';
|
|
7355
|
+
const KB_OFFICE_MIMES = new Set([KB_MIME_DOCX, KB_MIME_XLSX, KB_MIME_MSG, KB_MIME_EML]);
|
|
7356
|
+
const kbIsEmail = (mime) => mime === KB_MIME_EML || mime === KB_MIME_MSG;
|
|
7357
|
+
/** The row's text-read chips: nothing when it was read in full. Literal copy; reasons live in the viewer. */
|
|
7358
|
+
function kbTextChips(s) {
|
|
7359
|
+
if (s.kind !== 'file' || !KB_OFFICE_MIMES.has(s.mime)) return '';
|
|
7360
|
+
const t = s.text;
|
|
7361
|
+
const state = t ? t.state : 'pending';
|
|
7362
|
+
const chip = state === 'partial'
|
|
7363
|
+
? '<span class="kb-chip new" data-tip="FloLess could read only part of this file’s text. Open it to see what was missed.">partly read</span>'
|
|
7364
|
+
: state === 'failed'
|
|
7365
|
+
? '<span class="kb-chip err" data-tip="FloLess couldn’t read this file’s text. The file is kept. Open it for the reason.">text not read</span>'
|
|
7366
|
+
: state === 'pending'
|
|
7367
|
+
? '<span class="kb-chip" data-tip="FloLess reads this file’s text when you Organize or open it.">not read yet</span>'
|
|
7368
|
+
: '';
|
|
7369
|
+
const macros = t && t.macros
|
|
7370
|
+
? '<span class="kb-chip" data-tip="Contains macros. FloLess only reads its text and never runs them.">macros</span>' : '';
|
|
7371
|
+
return chip + macros;
|
|
7372
|
+
}
|
|
7373
|
+
|
|
6992
7374
|
// Literal chip copy per state (never interpolated from the server); unknown state falls back escaped.
|
|
6993
7375
|
const KB_CHIP = {
|
|
6994
7376
|
new: ['new', 'new'],
|
|
@@ -7023,6 +7405,269 @@
|
|
|
7023
7405
|
return `<span class="kb-chip ${cls}">${escapeHtml(state)}</span>`;
|
|
7024
7406
|
}
|
|
7025
7407
|
|
|
7408
|
+
// ── The project's design set (#2399 slice 0b) ───────────────────────────────────────────────────
|
|
7409
|
+
// One reference marked as the drawing set the job is built from. FloLess never reads a title block: the sheet index
|
|
7410
|
+
// is supplied by the person's AI and always labelled "not checked". Every warning the server gives is shown as it
|
|
7411
|
+
// gave it, and none blocks anything.
|
|
7412
|
+
const KB_DRAWING_MIMES = new Set(['application/pdf', 'image/png', 'image/jpeg', 'image/webp']);
|
|
7413
|
+
const KEY_DESIGN_SET = 'the design set'; // design-set-store.ts: the revision a stale screen is caught by
|
|
7414
|
+
const KB_DS_SUPPLIER = { chat: 'your AI', cli: 'your terminal AI', person: 'you' };
|
|
7415
|
+
const KEY_DS_PROJECT = 'the project'; // design-set-store.ts KEY_PROJECT
|
|
7416
|
+
const KEY_DS_REFERENCE = 'the chosen reference'; // design-set-store.ts KEY_DESIGN_REFERENCE
|
|
7417
|
+
/** The design-set revision this screen shows, written into each control it draws (never read from newer state). */
|
|
7418
|
+
const kbDsRev = (st) => (st && st.designSet && typeof st.designSet.revisionKey === 'string' && st.designSet.status !== 'unknown'
|
|
7419
|
+
? st.designSet.revisionKey : '(unreadable)');
|
|
7420
|
+
function kbActiveDesignSet(st) {
|
|
7421
|
+
const ds = st && st.designSet;
|
|
7422
|
+
return ds && (ds.status === 'registered' || ds.status === 'changed') && ds.designSet ? ds.designSet : null;
|
|
7423
|
+
}
|
|
7424
|
+
function kbIsDesignSet(s, st) {
|
|
7425
|
+
const active = kbActiveDesignSet(st);
|
|
7426
|
+
return !!active && active.sourceId === s.sourceId && active.blobSha256 === s.blobSha256;
|
|
7427
|
+
}
|
|
7428
|
+
/** "Use as design set" on a drawing row that is not the design set. Hidden, never disabled, everywhere else. */
|
|
7429
|
+
function kbDesignSetUse(s, st) {
|
|
7430
|
+
if (!st || !st.designSet) return '';
|
|
7431
|
+
if (s.kind === 'observation' || !s.useAsKb || !KB_DRAWING_MIMES.has(s.mime) || kbIsDesignSet(s, st)) return '';
|
|
7432
|
+
const name = s.filename || 'untitled';
|
|
7433
|
+
return '<div class="kb-ds-use-line"><button type="button" class="kb-link kb-ds-use" ' +
|
|
7434
|
+
`data-kb-ds-use="${escapeAttr(s.sourceId)}" data-kb-ds-rev="${escapeAttr(kbDsRev(st))}" data-kb-ds-blob="${escapeAttr(s.blobSha256)}" data-command-id="shell.kb-design-set-use" ` +
|
|
7435
|
+
`aria-label="Use “${escapeAttr(name)}” as the design set" data-tip="Mark this as the drawing set the job is built from">Use as design set</button></div>`;
|
|
7436
|
+
}
|
|
7437
|
+
// ── The design set as issues (#2399 slice 0c) ───────────────────────────────────────────────────
|
|
7438
|
+
// Each issue is one release of the drawings (Rev C, IFC), listed like the revision block of a title sheet: newest
|
|
7439
|
+
// first, one current. Nothing here deletes: a file or an issue is withdrawn and restored, and a file removed from the
|
|
7440
|
+
// references stays in its issue ("Copy kept"). Every sentence the server gives is shown as it gave it.
|
|
7441
|
+
const KB_DS_FILES_SHOWN = 5;
|
|
7442
|
+
const KB_DS_ORIGIN = { 'drawing-filter': 'Added from the Drawing Filter', 'project-intake': 'Added with the first upload', v1: 'Chosen as the design set before issues', knowledge: '' };
|
|
7443
|
+
const KB_DS_PRESENCE = {
|
|
7444
|
+
removed: ['Copy kept', 'Removed from your references. The design set kept its copy.'],
|
|
7445
|
+
replaced: ['Replaced', 'The reference now holds another file. The design set kept the one it was issued with.'],
|
|
7446
|
+
missing: ['File missing', 'The stored copy of this file is gone. Add the file again.'],
|
|
7447
|
+
};
|
|
7448
|
+
let kbDsOpen = null; // { projectId, ids: Set<issueId> } — which issues are expanded (the current one by default)
|
|
7449
|
+
let kbDsShowAll = new Set(); // issue ids whose whole file list is shown
|
|
7450
|
+
let kbDsPanel = null; // { kind: 'add'|'rename'|'read', issueId?, plan?, error? } — the inline panel that is open
|
|
7451
|
+
let kbDsFocus = null; // { issueId, control } — what takes focus after the repaint an action causes
|
|
7452
|
+
|
|
7453
|
+
/** Issue files as viewer rows, so a file whose reference was removed still previews from its issue. */
|
|
7454
|
+
function kbIssueFileRows(st) {
|
|
7455
|
+
const out = [];
|
|
7456
|
+
const issues = (st && st.designSet && st.designSet.issues) || [];
|
|
7457
|
+
for (const issue of issues) {
|
|
7458
|
+
for (const f of issue.files || []) {
|
|
7459
|
+
out.push({ sourceId: `ds:${issue.issueId}:${f.index}`, blobSha256: f.blobSha256, filename: f.filename, mime: f.mime, bytes: f.bytes,
|
|
7460
|
+
kind: 'issue-file', rawUrl: current ? `/api/projects/${encodeURIComponent(current.id)}/design-set/issues/${encodeURIComponent(issue.issueId)}/files/${f.index}` : '' });
|
|
7461
|
+
}
|
|
7462
|
+
}
|
|
7463
|
+
return out;
|
|
7464
|
+
}
|
|
7465
|
+
/** A viewer row by id: a reference, or an issue file. */
|
|
7466
|
+
function kbViewRow(st, id) {
|
|
7467
|
+
return (st.sources || []).find((s) => s.sourceId === id) || kbIssueFileRows(st).find((r) => r.sourceId === id) || null;
|
|
7468
|
+
}
|
|
7469
|
+
/** Is this reference a file of any issue (by its row, or by the bytes it holds)? Those are listed under their issue. */
|
|
7470
|
+
function kbInDesignSet(s, st) {
|
|
7471
|
+
const issues = (st && st.designSet && st.designSet.issues) || [];
|
|
7472
|
+
return issues.some((i) => (i.files || []).some((f) => f.sourceId === s.sourceId && f.blobSha256 === s.blobSha256));
|
|
7473
|
+
}
|
|
7474
|
+
function kbDsIsOpen(issue, st) {
|
|
7475
|
+
const proj = current && current.id;
|
|
7476
|
+
if (!kbDsOpen || kbDsOpen.projectId !== proj) kbDsOpen = { projectId: proj, ids: new Set(issue.current ? [issue.issueId] : []) };
|
|
7477
|
+
return kbDsOpen.ids.has(issue.issueId) || (issue.current && !kbDsOpen.touched);
|
|
7478
|
+
}
|
|
7479
|
+
function kbDsUses(f) {
|
|
7480
|
+
if (f.usedBy === 'unknown') return '<span class="kb-chip" data-tip="FloLess could not check which reads used this file">Use unknown</span>';
|
|
7481
|
+
const versions = (Array.isArray(f.usedBy) ? f.usedBy : []).filter((u) => u.version).map((u) => u.version);
|
|
7482
|
+
if (!versions.length) return '';
|
|
7483
|
+
const v = versions.slice(0, 2).map((n) => `v${n}`).join(', ') + (versions.length > 2 ? ` +${versions.length - 2}` : '');
|
|
7484
|
+
return `<span class="kb-chip" data-tip="${escapeAttr(`Model ${versions.length === 1 ? 'version' : 'versions'} ${versions.join(', ')} ${versions.length === 1 ? 'was' : 'were'} read from this file and keep their own copy`)}">Used by ${escapeHtml(v)}</span>`;
|
|
7485
|
+
}
|
|
7486
|
+
|
|
7487
|
+
function kbIssueFileRow(f, issue, st) {
|
|
7488
|
+
const row = (st.sources || []).find((s) => s.sourceId === f.sourceId && s.blobSha256 === f.blobSha256);
|
|
7489
|
+
const openId = row ? row.sourceId : `ds:${issue.issueId}:${f.index}`;
|
|
7490
|
+
const isOpen = viewer.mode === 'file' && viewer.sourceId === openId;
|
|
7491
|
+
const ico = kbIcon(f.mime);
|
|
7492
|
+
const name = f.filename || 'untitled';
|
|
7493
|
+
const p = KB_DS_PRESENCE[f.presence];
|
|
7494
|
+
// The file as the Instructor names this row: its issue and number, and its name for the person.
|
|
7495
|
+
const fileKey = `${issue.issueId}:${f.index}`;
|
|
7496
|
+
const fileLabel = ` data-command-instance-label="${escapeAttr(`“${name}” of ${issue.label}`)}"`;
|
|
7497
|
+
const chips = (f.withdrawn ? '<span class="kb-chip kb-chip-wd">Withdrawn</span>' : '') +
|
|
7498
|
+
(p ? `<span class="kb-chip kb-chip-presence" data-tip="${escapeAttr(p[1])}">${p[0]}</span>` : '') + kbDsUses(f);
|
|
7499
|
+
// A file still in use has a ✕ (Withdraw, or remove its reference); a withdrawn one has Restore. Neither is shown disabled.
|
|
7500
|
+
// A file in use has a ✕ (Withdraw, or remove its reference). A withdrawn one has Restore, and keeps a ✕ to remove its
|
|
7501
|
+
// reference while the reference is there — its knowledge-base switch stays too. Nothing is shown disabled.
|
|
7502
|
+
const restore = f.withdrawn
|
|
7503
|
+
? `<button type="button" class="kb-link kb-ds-frestore" data-kb-ds-frestore="${f.index}" data-kb-ds-issue="${escapeAttr(issue.issueId)}" data-kb-ds-rev="${escapeAttr(kbDsRev(st))}" data-command-id="shell.kb-design-file-restore#${escapeAttr(fileKey)}"${fileLabel} aria-label="Restore “${escapeAttr(name)}” to ${escapeAttr(issue.label)}" data-tip="Put this file back into use in the issue">Restore</button>`
|
|
7504
|
+
: '';
|
|
7505
|
+
const x = !f.withdrawn || row
|
|
7506
|
+
? `<button type="button" class="kb-x" data-kb-ds-fx="${f.index}" data-kb-ds-issue="${escapeAttr(issue.issueId)}" data-kb-ds-rev="${escapeAttr(kbDsRev(st))}"${row ? ` data-kb-ds-row="${escapeAttr(row.sourceId)}"` : ''}${f.withdrawn ? ' data-kb-ds-fwd' : ''} data-command-id="shell.kb-design-file-remove#${escapeAttr(fileKey)}"${fileLabel} aria-label="${f.withdrawn ? 'Remove the reference' : 'Withdraw or remove'} “${escapeAttr(name)}”" data-tip="${f.withdrawn ? 'Remove this file from your references; the design set keeps its copy' : 'Withdraw this file from the issue'}">✕</button>`
|
|
7507
|
+
: '';
|
|
7508
|
+
const act = restore + x;
|
|
7509
|
+
return `<li class="kb-ds-file${f.withdrawn ? ' wd' : ''}"${isOpen ? ' aria-current="true"' : ''}>` +
|
|
7510
|
+
`<span class="kb-fico ${ico.cls}" aria-hidden="true">${ico.glyph}</span>` +
|
|
7511
|
+
`<div class="kb-fbody"><button type="button" class="kb-fname" data-kb-open="${escapeAttr(openId)}" data-command-id="shell.kb-design-file-preview#${escapeAttr(fileKey)}"${fileLabel} data-tip="Preview “${escapeAttr(name)}”">${escapeHtml(name)}</button>` +
|
|
7512
|
+
(chips ? `<div class="kb-fmeta">${chips}${p ? `<span class="sr-only">${escapeHtml(p[1])}</span>` : ''}</div>` : '') + '</div>' +
|
|
7513
|
+
(row ? `<button type="button" class="kb-toggle" role="switch" aria-checked="${row.useAsKb ? 'true' : 'false'}" data-kb-toggle data-kb-toggle-id="${escapeAttr(row.sourceId)}" data-command-id="shell.kb-design-file-knowledge#${escapeAttr(fileKey)}"${fileLabel} ` +
|
|
7514
|
+
`aria-label="Use “${escapeAttr(name)}” as knowledge" data-tip="${row.useAsKb ? 'Included in the knowledge base — click to exclude' : 'Not in the knowledge base — click to include it when you organize'}"></button>` : '') +
|
|
7515
|
+
act + '</li>';
|
|
7516
|
+
}
|
|
7517
|
+
|
|
7518
|
+
function kbIssuePanel(issue, st) {
|
|
7519
|
+
if (!kbDsPanel || kbDsPanel.issueId !== issue.issueId) return '';
|
|
7520
|
+
const err = kbDsPanel.error ? `<div class="kb-ds-err" role="alert">${escapeHtml(kbDsPanel.error)}${kbDsPanel.openRequests ? ' <button type="button" class="kb-link" data-kb-ds-requests data-command-id="shell.requests-open">Open Requests</button>' : ''}</div>` : '';
|
|
7521
|
+
if (kbDsPanel.kind === 'rename') {
|
|
7522
|
+
return `<div class="kb-ds-panel" role="group" aria-labelledby="kb-ds-ph-${escapeAttr(issue.issueId)}">` +
|
|
7523
|
+
`<div class="kb-ds-ph" id="kb-ds-ph-${escapeAttr(issue.issueId)}">Rename this issue</div>` +
|
|
7524
|
+
'<label class="kb-ds-lbl" for="kb-ds-label">Label</label>' +
|
|
7525
|
+
`<input class="kb-adjust-input kb-ds-in" id="kb-ds-label" data-command-id="shell.kb-design-panel-label" maxlength="60" value="${escapeAttr(kbDsPanel.label ?? issue.label)}" autocomplete="off">` +
|
|
7526
|
+
'<label class="kb-ds-lbl" for="kb-ds-date">Issue date <span class="kb-ds-opt">(optional, YYYY-MM-DD)</span></label>' +
|
|
7527
|
+
`<input class="kb-adjust-input kb-ds-in" id="kb-ds-date" data-command-id="shell.kb-design-panel-date" maxlength="10" inputmode="numeric" placeholder="2026-10-17" value="${escapeAttr(kbDsPanel.date ?? (issue.issuedOn || ''))}" autocomplete="off">` +
|
|
7528
|
+
err + '<div class="kb-ds-pact"><button type="button" class="btn-mini" data-kb-ds-cancel data-command-id="shell.kb-design-panel-cancel">Cancel</button>' +
|
|
7529
|
+
`<button type="button" class="btn-mini primary" data-kb-ds-rename-go="${escapeAttr(issue.issueId)}" data-kb-ds-rev="${escapeAttr(kbDsPanel.rev || kbDsRev(st))}" data-command-id="shell.kb-design-issue-rename-save">Save</button></div></div>`;
|
|
7530
|
+
}
|
|
7531
|
+
if (kbDsPanel.kind === 'read') {
|
|
7532
|
+
const plan = kbDsPanel.plan;
|
|
7533
|
+
if (!plan) return '<div class="kb-ds-panel"><div class="kb-fmeta">Checking the files…</div></div>';
|
|
7534
|
+
const chosen = kbDsPanel.chosen || new Set(plan.included.map((f) => f.index));
|
|
7535
|
+
const already = Array.isArray(plan.alreadyRead) ? new Set(plan.alreadyRead) : new Set();
|
|
7536
|
+
const byIndex = new Map((issue.files || []).map((f) => [f.index, f]));
|
|
7537
|
+
// Files that can still be chosen for this read are ticks; the rest are listed with the server's reason.
|
|
7538
|
+
const CHOOSABLE = new Set(['over-limit', 'not-chosen', 'read-before']);
|
|
7539
|
+
const left = new Map(plan.skipped.map((s) => [s.index, s]));
|
|
7540
|
+
const usable = (issue.files || []).filter((f) => !left.has(f.index) || CHOOSABLE.has(left.get(f.index).code) || chosen.has(f.index));
|
|
7541
|
+
const items = usable.map((f) => {
|
|
7542
|
+
const id = `kb-ds-r-${f.index}`;
|
|
7543
|
+
const note = already.has(f.index) ? ' <span class="kb-ds-opt">already read</span>' : '';
|
|
7544
|
+
return `<li><input type="checkbox" id="${id}" data-kb-ds-pick="${f.index}" data-command-id="shell.kb-design-read-pick#${escapeAttr(`${issue.issueId}:${f.index}`)}" data-command-instance-label="${escapeAttr(`“${f.filename}”`)}"${chosen.has(f.index) ? ' checked' : ''}>` +
|
|
7545
|
+
`<label for="${id}">${escapeHtml(f.filename)}${note}</label></li>`;
|
|
7546
|
+
}).join('');
|
|
7547
|
+
const out = plan.skipped.filter((s) => !usable.some((f) => f.index === s.index))
|
|
7548
|
+
.map((s) => `<li><span class="kb-ds-num">${escapeHtml((byIndex.get(s.index) || s).filename)}</span> — ${escapeHtml(s.reason)}</li>`).join('');
|
|
7549
|
+
const n = chosen.size;
|
|
7550
|
+
const over = n > 40 ? '<div class="kb-ds-note">Only 40 files are read at a time, so the first 40 you ticked are read now. Read the rest next: the files no read has covered yet are ticked by default.</div>' : '';
|
|
7551
|
+
return `<div class="kb-ds-panel" role="group" aria-labelledby="kb-ds-ph-${escapeAttr(issue.issueId)}">` +
|
|
7552
|
+
`<div class="kb-ds-ph" id="kb-ds-ph-${escapeAttr(issue.issueId)}">Read “${escapeHtml(issue.label)}” into the model</div>` +
|
|
7553
|
+
`<div class="kb-ds-note">FloLess queues one drawing read for your AI. It proposes changes to the model, and nothing is applied until you review them.${plan.beingRead.length ? ' A read of some of these files is still open in Requests.' : ''}${plan.alreadyRead === 'unknown' ? ' FloLess could not check which files were read before.' : ''}</div>` +
|
|
7554
|
+
`<div class="kb-ds-lbl">Will be read (${Math.min(n, 40)})</div><ul class="kb-ds-picks" role="list">${items || '<li class="kb-ds-opt">No file of this issue can be read just now.</li>'}</ul>` +
|
|
7555
|
+
(out ? `<div class="kb-ds-lbl">Left out</div><ul class="kb-ds-out" role="list">${out}</ul>` : '') + over + err +
|
|
7556
|
+
'<div class="kb-ds-pact"><button type="button" class="btn-mini" data-kb-ds-cancel data-command-id="shell.kb-design-panel-cancel">Cancel</button>' +
|
|
7557
|
+
(n ? `<button type="button" class="btn-mini primary" data-kb-ds-read-go="${escapeAttr(issue.issueId)}" data-command-id="shell.kb-design-issue-read-go">Read ${Math.min(n, 40)} file${Math.min(n, 40) === 1 ? '' : 's'}</button>` : '') +
|
|
7558
|
+
'</div></div>';
|
|
7559
|
+
}
|
|
7560
|
+
return '';
|
|
7561
|
+
}
|
|
7562
|
+
|
|
7563
|
+
function kbIssueRow(issue, st, canRead) {
|
|
7564
|
+
const open = kbDsIsOpen(issue, st);
|
|
7565
|
+
const files = issue.files || [];
|
|
7566
|
+
const active = files.filter((f) => !f.withdrawn).length;
|
|
7567
|
+
const date = issue.issuedOn ? `<span class="kb-ds-date">${escapeHtml(issue.issuedOn)}</span>` : '';
|
|
7568
|
+
const count = `${active} file${active === 1 ? '' : 's'}${active !== files.length ? ` of ${files.length}` : ''}`;
|
|
7569
|
+
const chips = (issue.current ? '<span class="kb-chip run">Current</span>' : '') + (issue.withdrawn ? '<span class="kb-chip kb-chip-wd">Withdrawn</span>' : '');
|
|
7570
|
+
const all = kbDsShowAll.has(issue.issueId);
|
|
7571
|
+
const shown = all ? files : files.slice(0, KB_DS_FILES_SHOWN);
|
|
7572
|
+
const more = files.length > shown.length
|
|
7573
|
+
? `<button type="button" class="kb-link" data-kb-ds-all="${escapeAttr(issue.issueId)}" data-command-id="shell.kb-design-issue-files-all">Show all ${files.length} files</button>` : '';
|
|
7574
|
+
const warnings = (issue.warnings || []).map((w) => {
|
|
7575
|
+
const use = w.sourceId && (st.sources || []).some((x) => x.sourceId === w.sourceId)
|
|
7576
|
+
? ` <button type="button" class="kb-link" data-kb-ds-use="${escapeAttr(w.sourceId)}" data-kb-ds-rev="${escapeAttr(kbDsRev(st))}" `
|
|
7577
|
+
+ `data-kb-ds-blob="${escapeAttr((st.sources || []).find((x) => x.sourceId === w.sourceId)?.blobSha256 || '')}" data-command-id="shell.kb-design-set-use" `
|
|
7578
|
+
+ 'data-tip="Use the file that was added again as the design set">Use this one</button>' : '';
|
|
7579
|
+
return `<div class="kb-ds-warn-line" role="status"><span class="kb-ds-bang" aria-hidden="true">!</span><span>${escapeHtml(w.message)}${use}</span></div>`;
|
|
7580
|
+
}).join('');
|
|
7581
|
+
const n = (issue.sheets || []).length;
|
|
7582
|
+
const who = KB_DS_SUPPLIER[issue.sheetsSuppliedBy] || 'your AI';
|
|
7583
|
+
const byFile = new Map(files.map((f) => [f.index, f.filename]));
|
|
7584
|
+
const index = n
|
|
7585
|
+
? '<details class="kb-adjust kb-ds-index"><summary class="kb-adjust-summary" data-command-id="shell.kb-design-set-index">' +
|
|
7586
|
+
`<span class="kb-adjust-caret" aria-hidden="true">▸</span>Sheet index (${n})<span class="kb-chip new">not checked</span></summary>` +
|
|
7587
|
+
'<ol class="kb-ds-sheets" role="list" tabindex="0" aria-label="Sheet index">' + issue.sheets.map((sh) =>
|
|
7588
|
+
`<li><span class="kb-ds-num">${escapeHtml(sh.number)}</span> · ${escapeHtml(sh.title || 'untitled')} · p.${escapeHtml(String(sh.page))}${files.length > 1 ? ` <span class="kb-ds-opt">${escapeHtml(byFile.get(sh.file || 0) || '')}</span>` : ''}</li>`).join('') + '</ol>' +
|
|
7589
|
+
`<div class="kb-ds-foot">Supplied by ${escapeHtml(who)}. FloLess does not read title blocks, so check it against the drawings.</div></details>`
|
|
7590
|
+
: '';
|
|
7591
|
+
const origin = KB_DS_ORIGIN[issue.origin && issue.origin.kind] || '';
|
|
7592
|
+
const id = escapeAttr(issue.issueId);
|
|
7593
|
+
const rev = escapeAttr(kbDsRev(st));
|
|
7594
|
+
const actions = '<div class="kb-ds-actions">' +
|
|
7595
|
+
(canRead && active && !issue.withdrawn ? `<button type="button" class="kb-link" data-kb-ds-read="${id}" data-command-id="shell.kb-design-issue-read" data-tip="Choose which files of this issue your AI reads into the model">Read into the model</button>` : '') +
|
|
7596
|
+
(!issue.current ? `<button type="button" class="kb-link" data-kb-ds-current="${id}" data-kb-ds-rev="${rev}" data-command-id="shell.kb-design-issue-current" data-tip="Make this the issue the job is built from">Make current</button>` : '') +
|
|
7597
|
+
`<button type="button" class="kb-link kb-ds-more" data-kb-ds-more="${id}" data-kb-ds-rev="${rev}" aria-haspopup="menu" data-command-id="shell.kb-design-issue-more" data-tip="Rename, index or withdraw this issue">More…</button>` +
|
|
7598
|
+
'</div>';
|
|
7599
|
+
return `<details class="kb-ds-issue${issue.current ? ' current' : ''}${issue.withdrawn ? ' wd' : ''}" data-kb-ds-issue-id="${id}"${open ? ' open' : ''}>` +
|
|
7600
|
+
`<summary class="kb-ds-sum" data-command-id="shell.kb-design-issue-open"><span class="kb-adjust-caret" aria-hidden="true">▸</span>` +
|
|
7601
|
+
`<span class="kb-ds-line1"><span class="kb-ds-label">${escapeHtml(issue.label)}</span>${date}<span class="kb-ds-count">${escapeHtml(count)}</span></span>` +
|
|
7602
|
+
(chips ? `<span class="kb-ds-line2">${chips}</span>` : '') + '</summary>' +
|
|
7603
|
+
'<div class="kb-ds-body">' +
|
|
7604
|
+
(origin ? `<div class="kb-ds-origin">${escapeHtml(origin)}</div>` : '') + warnings +
|
|
7605
|
+
`<ul class="kb-ds-files" role="list">${shown.map((f) => kbIssueFileRow(f, issue, st)).join('')}</ul>${more}` +
|
|
7606
|
+
index + actions + kbIssuePanel(issue, st) +
|
|
7607
|
+
'</div></details>';
|
|
7608
|
+
}
|
|
7609
|
+
|
|
7610
|
+
/** The references a new issue can be made of: every drawing file in the project's knowledge. */
|
|
7611
|
+
function kbDsAddable(st) {
|
|
7612
|
+
return (st.sources || []).filter((s) => s.kind !== 'observation' && KB_DRAWING_MIMES.has(s.mime));
|
|
7613
|
+
}
|
|
7614
|
+
function kbAddIssuePanel(st) {
|
|
7615
|
+
if (!kbDsPanel || kbDsPanel.kind !== 'add') return '';
|
|
7616
|
+
// Every drawing can go into a new release, including one already in an earlier issue (it may be unchanged); the
|
|
7617
|
+
// drawings in no issue yet are ticked to start with.
|
|
7618
|
+
const drawings = kbDsAddable(st);
|
|
7619
|
+
const issues = (st.designSet && st.designSet.issues) || [];
|
|
7620
|
+
const chosen = kbDsPanel.chosen || new Set(drawings.filter((s) => !kbInDesignSet(s, st)).map((s) => s.sourceId));
|
|
7621
|
+
const inIssue = (s) => issues.filter((i) => (i.files || []).some((f) => f.sourceId === s.sourceId && f.blobSha256 === s.blobSha256)).map((i) => i.label);
|
|
7622
|
+
const list = drawings.length
|
|
7623
|
+
? '<ul class="kb-ds-picks" role="list">' + drawings.map((s, i) => {
|
|
7624
|
+
const where = inIssue(s);
|
|
7625
|
+
return `<li><input type="checkbox" id="kb-ds-a-${i}" data-kb-ds-add-pick="${escapeAttr(s.sourceId)}" data-command-id="shell.kb-design-add-pick#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(`“${s.filename || 'untitled'}”`)}"${chosen.has(s.sourceId) ? ' checked' : ''}>` +
|
|
7626
|
+
`<label for="kb-ds-a-${i}">${escapeHtml(s.filename || 'untitled')}${where.length ? ` <span class="kb-ds-opt">in ${escapeHtml(where.slice(0, 2).join(', '))}</span>` : ''}</label></li>`;
|
|
7627
|
+
}).join('') + '</ul>'
|
|
7628
|
+
: '<div class="kb-ds-note">There are no drawings in this project yet. Upload the drawings of this issue.</div>';
|
|
7629
|
+
const err = kbDsPanel.error ? `<div class="kb-ds-err" role="alert">${escapeHtml(kbDsPanel.error)}</div>` : '';
|
|
7630
|
+
return '<div class="kb-ds-panel" role="group" aria-labelledby="kb-ds-ph-add">' +
|
|
7631
|
+
'<div class="kb-ds-ph" id="kb-ds-ph-add">Add an issue</div>' +
|
|
7632
|
+
'<div class="kb-ds-lbl">Drawings in this issue</div>' + list +
|
|
7633
|
+
'<button type="button" class="kb-link" data-kb-ds-upload data-command-id="shell.add-knowledge" data-tip="Pick drawing files from your computer; they are ticked here when they arrive">Upload new files…</button>' +
|
|
7634
|
+
(drawings.length ? '<label class="kb-ds-lbl" for="kb-ds-label">Label <span class="kb-ds-opt">(for example Rev C or IFC)</span></label>' +
|
|
7635
|
+
`<input class="kb-adjust-input kb-ds-in" id="kb-ds-label" data-command-id="shell.kb-design-panel-label" maxlength="60" placeholder="Issue ${((st.designSet && st.designSet.issues) || []).length + 1}" value="${escapeAttr(kbDsPanel.label || '')}" autocomplete="off">` +
|
|
7636
|
+
'<label class="kb-ds-lbl" for="kb-ds-date">Issue date <span class="kb-ds-opt">(optional, YYYY-MM-DD)</span></label>' +
|
|
7637
|
+
`<input class="kb-adjust-input kb-ds-in" id="kb-ds-date" data-command-id="shell.kb-design-panel-date" maxlength="10" inputmode="numeric" placeholder="2026-10-17" value="${escapeAttr(kbDsPanel.date || '')}" autocomplete="off">` : '') +
|
|
7638
|
+
err + '<div class="kb-ds-pact"><button type="button" class="btn-mini" data-kb-ds-cancel data-command-id="shell.kb-design-panel-cancel">Cancel</button>' +
|
|
7639
|
+
(drawings.length ? `<button type="button" class="btn-mini primary" data-kb-ds-add-go data-kb-ds-rev="${escapeAttr(kbDsPanel.rev || kbDsRev(st))}" data-command-id="shell.kb-design-issue-add-save">Add issue</button>` : '') +
|
|
7640
|
+
'</div></div>';
|
|
7641
|
+
}
|
|
7642
|
+
|
|
7643
|
+
function kbDesignSetStrip(st) {
|
|
7644
|
+
const ds = st && st.designSet;
|
|
7645
|
+
if (!ds) return '';
|
|
7646
|
+
const head = (extra) => `<div class="kb-ds-head"><span class="kb-adjust-label" id="kb-ds-title">Design set</span>${extra || ''}</div>`;
|
|
7647
|
+
if (ds.status === 'unknown') {
|
|
7648
|
+
// Said in the server's words; a broken record also offers Clear (it is moved aside, never lost).
|
|
7649
|
+
const why = (ds.warnings || [])[0];
|
|
7650
|
+
const broken = why && why.code === 'design-set-unreadable';
|
|
7651
|
+
return `<section class="kb-src kb-ds" role="region" aria-labelledby="kb-ds-title">${head()}` +
|
|
7652
|
+
`<div class="kb-fmeta">${escapeHtml(why ? why.message : 'FloLess could not read the design set just now. It tries again when this step refreshes.')}</div>` +
|
|
7653
|
+
(broken ? `<div class="kb-ds-actions"><button type="button" class="kb-link" data-kb-ds-clear data-kb-ds-rev="(unreadable)" data-command-id="shell.kb-design-set-clear" data-tip="Replace the unreadable record with no design set. The old record is kept aside and no reference is removed.">Clear</button></div>` : '') +
|
|
7654
|
+
'</section>';
|
|
7655
|
+
}
|
|
7656
|
+
const issues = ds.issues || [];
|
|
7657
|
+
const canRead = !!(current && (current.templateId || current.app) === 'steel-model');
|
|
7658
|
+
const add = !kbDsPanel || kbDsPanel.kind !== 'add'
|
|
7659
|
+
? '<button type="button" class="kb-link kb-ds-add" data-kb-ds-add data-command-id="shell.kb-design-issue-add" data-tip="Group drawings into an issue, such as Rev C or IFC">Add issue</button>' : '';
|
|
7660
|
+
const body = issues.length
|
|
7661
|
+
? issues.map((issue) => kbIssueRow(issue, st, canRead)).join('')
|
|
7662
|
+
: (kbDsPanel && kbDsPanel.kind === 'add' ? '' : '<div class="kb-ds-note">No drawings issued yet. Add an issue to track a release such as Rev C or IFC.</div>');
|
|
7663
|
+
// Warnings about the record itself (an earlier one set aside) belong to no issue: said above the issues, always.
|
|
7664
|
+
const recordWarnings = (ds.warnings || []).filter((w) => !w.issueId).map((w) =>
|
|
7665
|
+
`<div class="kb-ds-warn-line" role="status"><span class="kb-ds-bang" aria-hidden="true">!</span><span>${escapeHtml(w.message)}</span></div>`).join('');
|
|
7666
|
+
return `<section class="kb-src kb-ds${ds.status === 'changed' ? ' changed' : ''}" role="region" aria-labelledby="kb-ds-title">` +
|
|
7667
|
+
head(add) + '<div class="kb-ds-sub">Each issue is one release of the drawings.</div>' + recordWarnings +
|
|
7668
|
+
kbAddIssuePanel(st) + body + '</section>';
|
|
7669
|
+
}
|
|
7670
|
+
|
|
7026
7671
|
function kbSourceRow(s, st) {
|
|
7027
7672
|
const on = !!s.useAsKb;
|
|
7028
7673
|
const ico = kbIcon(s.mime);
|
|
@@ -7044,7 +7689,9 @@
|
|
|
7044
7689
|
`<div class="kb-fbody">` +
|
|
7045
7690
|
`<button type="button" class="kb-fname" data-kb-open="${escapeAttr(s.sourceId)}" ` +
|
|
7046
7691
|
`data-tip="Preview “${escapeAttr(name)}”">${escapeHtml(name)}</button>` +
|
|
7047
|
-
`<div class="kb-fmeta">${escapeHtml(meta)}<span class="kb-chip ${chip[0]}">${chip[1]}</span>${imported}${kbCompanyChip(s, st)}
|
|
7692
|
+
`<div class="kb-fmeta">${escapeHtml(meta)}<span class="kb-chip ${chip[0]}">${chip[1]}</span>${kbTextChips(s)}${imported}${kbCompanyChip(s, st)}` +
|
|
7693
|
+
`${kbIsDesignSet(s, st) ? '<span class="kb-chip run kb-chip-ds">design set</span>' : ''}</div>` +
|
|
7694
|
+
kbDesignSetUse(s, st) +
|
|
7048
7695
|
err +
|
|
7049
7696
|
`</div>` +
|
|
7050
7697
|
`<button type="button" class="kb-toggle" role="switch" aria-checked="${on ? 'true' : 'false'}" data-kb-toggle ` +
|
|
@@ -7373,7 +8020,10 @@
|
|
|
7373
8020
|
const alive = () => epoch === viewEpoch && key === lastViewKey &&
|
|
7374
8021
|
current && current.id === proj.id && !$wsKnowledge.hidden;
|
|
7375
8022
|
|
|
7376
|
-
|
|
8023
|
+
// #2491 R6.3: a Word, Excel or email file shows the TEXT FloLess read from it — never its bytes.
|
|
8024
|
+
if (!row.rawUrl && KB_OFFICE_MIMES.has(row.mime)) { await kbLoadOfficeText(proj, row, alive); return; }
|
|
8025
|
+
|
|
8026
|
+
const url = row.rawUrl || kbRawUrl(proj.id, row.sourceId);
|
|
7377
8027
|
const ac = new AbortController();
|
|
7378
8028
|
kbTextAbort = ac;
|
|
7379
8029
|
|
|
@@ -7396,7 +8046,7 @@
|
|
|
7396
8046
|
}
|
|
7397
8047
|
|
|
7398
8048
|
if (row.mime === 'application/pdf') kbPaintPdf(row, url);
|
|
7399
|
-
else if (row.mime === 'image/png' || row.mime === 'image/jpeg') kbPaintImage(row, url, alive);
|
|
8049
|
+
else if (row.mime === 'image/png' || row.mime === 'image/jpeg' || row.mime === 'image/webp') kbPaintImage(row, url, alive);
|
|
7400
8050
|
else kbPaintText(row, url, ac, alive);
|
|
7401
8051
|
}
|
|
7402
8052
|
|
|
@@ -7487,7 +8137,7 @@
|
|
|
7487
8137
|
}
|
|
7488
8138
|
if (!stillOurs()) return;
|
|
7489
8139
|
|
|
7490
|
-
const fresh = st
|
|
8140
|
+
const fresh = kbViewRow(st, row.sourceId);
|
|
7491
8141
|
if (!fresh) {
|
|
7492
8142
|
// The row is gone. Repaint the column too — merely closing the viewer would leave it listed,
|
|
7493
8143
|
// because nothing else is polling.
|
|
@@ -7526,6 +8176,197 @@
|
|
|
7526
8176
|
img.src = url;
|
|
7527
8177
|
}
|
|
7528
8178
|
|
|
8179
|
+
/** Read a response body as UTF-8, stopping at KB_TEXT_CAP. Null when aborted or the connection dropped. */
|
|
8180
|
+
async function kbReadCapped(res) {
|
|
8181
|
+
const chunks = [];
|
|
8182
|
+
let total = 0;
|
|
8183
|
+
let truncated = false;
|
|
8184
|
+
const reader = res.body.getReader();
|
|
8185
|
+
for (;;) {
|
|
8186
|
+
const { done, value } = await reader.read();
|
|
8187
|
+
if (done) break;
|
|
8188
|
+
chunks.push(value);
|
|
8189
|
+
total += value.length;
|
|
8190
|
+
if (total >= KB_TEXT_CAP) { truncated = true; await reader.cancel(); break; }
|
|
8191
|
+
}
|
|
8192
|
+
const flat = new Uint8Array(Math.min(total, KB_TEXT_CAP));
|
|
8193
|
+
let at = 0;
|
|
8194
|
+
for (const c of chunks) {
|
|
8195
|
+
if (at >= flat.length) break;
|
|
8196
|
+
flat.set(c.subarray(0, Math.min(c.length, flat.length - at)), at);
|
|
8197
|
+
at += c.length;
|
|
8198
|
+
}
|
|
8199
|
+
return { text: new TextDecoder('utf-8').decode(flat), truncated };
|
|
8200
|
+
}
|
|
8201
|
+
|
|
8202
|
+
/**
|
|
8203
|
+
* #2491 R6.3 (spec §10, §14 finding 8, §14.1): the text FloLess read from a Word, Excel or email reference. GET only
|
|
8204
|
+
* (it reads the text when it was not read yet, so the state comes from its headers, never from a HEAD). The text goes
|
|
8205
|
+
* in with textContent like any stored text; nothing a document says ever reaches innerHTML.
|
|
8206
|
+
*/
|
|
8207
|
+
async function kbLoadOfficeText(proj, row, alive) {
|
|
8208
|
+
const name = row.filename || 'untitled';
|
|
8209
|
+
const unread = !row.text || row.text.state === 'pending';
|
|
8210
|
+
if (unread) {
|
|
8211
|
+
kbPaintView(row, '<div class="kb-view-msg" role="status"><span class="kb-view-spin" aria-hidden="true"></span>' +
|
|
8212
|
+
`<div class="kb-view-msg-sub">Reading the text of “${escapeHtml(name)}”… Large workbooks can take a few seconds.</div></div>`);
|
|
8213
|
+
}
|
|
8214
|
+
const ac = new AbortController();
|
|
8215
|
+
kbTextAbort = ac;
|
|
8216
|
+
let res;
|
|
8217
|
+
try { res = await fetch(kbUrl(proj.id, `/sources/${encodeURIComponent(row.sourceId)}/text`), { signal: ac.signal, cache: 'no-store' }); }
|
|
8218
|
+
catch (err) {
|
|
8219
|
+
if (err && err.name === 'AbortError') return;
|
|
8220
|
+
if (alive()) kbPaintError(row, 'Lost the connection while loading it.');
|
|
8221
|
+
return;
|
|
8222
|
+
}
|
|
8223
|
+
if (!alive()) return;
|
|
8224
|
+
if (res.status === 404) { await kbHandleMissing(proj, row, alive); return; }
|
|
8225
|
+
if (!res.ok) {
|
|
8226
|
+
kbPaintError(row, res.status === 402 ? 'Your session needs refreshing — sign in again and retry.' : 'The server hit an error trying to read it.');
|
|
8227
|
+
return;
|
|
8228
|
+
}
|
|
8229
|
+
const state = res.headers.get('X-FloLess-Text-State') || 'pending';
|
|
8230
|
+
const macros = res.headers.get('X-FloLess-Text-Macros') === '1';
|
|
8231
|
+
const bytes = Number(res.headers.get('X-FloLess-Text-Bytes')) || 0;
|
|
8232
|
+
let warnings = [];
|
|
8233
|
+
try { warnings = JSON.parse(decodeURIComponent(res.headers.get('X-FloLess-Text-Warnings') || '%5B%5D')); } catch { warnings = []; }
|
|
8234
|
+
if (!Array.isArray(warnings)) warnings = [];
|
|
8235
|
+
warnings = warnings.filter((w) => typeof w === 'string').slice(0, 20);
|
|
8236
|
+
let read;
|
|
8237
|
+
try { read = await kbReadCapped(res); }
|
|
8238
|
+
catch (err) {
|
|
8239
|
+
if (err && err.name === 'AbortError') return;
|
|
8240
|
+
if (alive()) kbPaintError(row, 'Lost the connection while reading it.');
|
|
8241
|
+
return;
|
|
8242
|
+
}
|
|
8243
|
+
if (!alive()) return;
|
|
8244
|
+
kbPaintOfficeText(proj, row, { state, macros, bytes, warnings, text: read.text, truncated: read.truncated });
|
|
8245
|
+
}
|
|
8246
|
+
|
|
8247
|
+
function kbPaintOfficeText(proj, row, t) {
|
|
8248
|
+
const name = row.filename || 'untitled';
|
|
8249
|
+
const raw = kbRawUrl(proj.id, row.sourceId);
|
|
8250
|
+
const download = `<a class="kb-link kb-text-download" href="${escapeAttr(raw)}" download="${escapeAttr(name)}" data-command-id="shell.kb-text-download" ` +
|
|
8251
|
+
`aria-label="Download the original of “${escapeAttr(name)}”" data-tip="Download the original file">Download original</a>`;
|
|
8252
|
+
const reasons = t.warnings.length ? `<ul class="kb-text-reasons">${t.warnings.map((w) => `<li>${escapeHtml(w)}</li>`).join('')}</ul>` : '';
|
|
8253
|
+
const choices = (primary) =>
|
|
8254
|
+
`<button type="button" class="${primary ? 'primary' : ''}" data-kb-text-replace="${escapeAttr(row.sourceId)}" data-command-id="shell.kb-text-replace-open" ` +
|
|
8255
|
+
'data-tip="Choose a new copy of this file; this one is removed once the new one is added">Replace file…</button>' +
|
|
8256
|
+
`<button type="button" data-kb-text-paste="${escapeAttr(row.sourceId)}" data-command-id="shell.kb-text-paste-note" ` +
|
|
8257
|
+
'data-tip="Paste the file’s text yourself; FloLess keeps it as a text note beside this file">Paste its text as a note</button>';
|
|
8258
|
+
const macroLine = t.macros ? '<div class="kb-text-macros">Contains macros. FloLess only reads its text and never runs them.</div>' : '';
|
|
8259
|
+
if (t.state === 'failed' || (t.state === 'pending' && !t.text)) {
|
|
8260
|
+
const failed = t.state === 'failed';
|
|
8261
|
+
kbPaintView(row,
|
|
8262
|
+
'<div class="kb-view-msg" role="status"><span class="kb-view-ico err" aria-hidden="true">⚠</span>' +
|
|
8263
|
+
`<div class="kb-view-msg-title">${failed ? 'Couldn’t read the text in this file.' : 'FloLess hasn’t read this file’s text yet.'}</div>` +
|
|
8264
|
+
`<div class="kb-view-msg-sub">${failed ? '' : 'It reads it when you Organize, or try again now. '}The original file is kept.</div>` +
|
|
8265
|
+
reasons + macroLine +
|
|
8266
|
+
`<div class="kb-view-act">${failed ? choices(true) : '<button type="button" class="primary" data-kb-retry data-command-id="shell.kb-text-retry">↻ Try again</button>' + choices(false)}${download}</div>` +
|
|
8267
|
+
'<div class="kb-paste-host"></div></div>');
|
|
8268
|
+
return;
|
|
8269
|
+
}
|
|
8270
|
+
const lead = kbIsEmail(row.mime) ? 'Text FloLess read from this email; attachments are listed by name only.' : 'Text FloLess read from this file.';
|
|
8271
|
+
const banner = t.state === 'partial'
|
|
8272
|
+
? '<div class="kb-text-banner" role="status"><div class="kb-text-banner-title">Some of this file’s text couldn’t be read.</div>' +
|
|
8273
|
+
reasons + '<div class="kb-text-banner-sub">FloLess kept the original.</div>' +
|
|
8274
|
+
`<div class="kb-view-act">${choices(false)}</div><div class="kb-paste-host"></div></div>`
|
|
8275
|
+
: '';
|
|
8276
|
+
const notice = t.truncated
|
|
8277
|
+
? `<div class="kb-view-note">Showing the first ${escapeHtml(kbBytes(KB_TEXT_CAP))} of ${escapeHtml(kbBytes(t.bytes))} of text.</div>` : '';
|
|
8278
|
+
kbPaintView(row,
|
|
8279
|
+
`<div class="kb-text-strip" role="note"><span>${escapeHtml(lead)}</span>${download}</div>` + macroLine + banner +
|
|
8280
|
+
`<pre class="kb-view-pre" tabindex="0" role="region" aria-label="Text read from “${escapeAttr(name)}”"></pre>${notice}`);
|
|
8281
|
+
const pre = kbViewHost() && kbViewHost().querySelector('.kb-view-pre');
|
|
8282
|
+
// FloLess's own provenance line (a digest and a reader version) is for the AI, not the person: shown from line 2.
|
|
8283
|
+
const shown = t.text.startsWith('<!-- floless:extracted-text ') ? t.text.slice(t.text.indexOf('\n') + 1) : t.text;
|
|
8284
|
+
if (pre) pre.textContent = shown; // the escaping guarantee: a document's "<script>" stays literal text
|
|
8285
|
+
}
|
|
8286
|
+
|
|
8287
|
+
/** Paste its text as a note: a small panel in the viewer; the note is added as "<name>.txt" beside the file. */
|
|
8288
|
+
function kbOpenPasteNote(sourceId) {
|
|
8289
|
+
const host = kbViewHost() && kbViewHost().querySelector('.kb-paste-host');
|
|
8290
|
+
const row = knowledgeState && knowledgeState.sources.find((s) => s.sourceId === sourceId);
|
|
8291
|
+
if (!host || !row) return;
|
|
8292
|
+
host.innerHTML = '<div class="kb-paste">' +
|
|
8293
|
+
'<label class="kb-ds-lbl" for="kb-paste-text">The file’s text</label>' +
|
|
8294
|
+
'<textarea id="kb-paste-text" class="kb-adjust-input kb-paste-area" data-command-id="shell.kb-text-paste-input" rows="8" ' +
|
|
8295
|
+
'placeholder="Paste the text here. FloLess keeps it as a text note beside this file."></textarea>' +
|
|
8296
|
+
'<div class="kb-view-act"><button type="button" data-kb-paste-cancel data-command-id="shell.kb-text-paste-cancel">Cancel</button>' +
|
|
8297
|
+
`<button type="button" class="primary" data-kb-paste-go="${escapeAttr(sourceId)}" data-command-id="shell.kb-text-paste-save">Add note</button></div></div>`;
|
|
8298
|
+
const area = host.querySelector('textarea');
|
|
8299
|
+
if (area) area.focus({ preventScroll: false });
|
|
8300
|
+
}
|
|
8301
|
+
|
|
8302
|
+
async function kbPasteNote(sourceId) {
|
|
8303
|
+
const proj = current;
|
|
8304
|
+
const row = knowledgeState && knowledgeState.sources.find((s) => s.sourceId === sourceId);
|
|
8305
|
+
const area = kbViewHost() && kbViewHost().querySelector('#kb-paste-text');
|
|
8306
|
+
const text = area ? area.value : '';
|
|
8307
|
+
if (!proj || !row) return;
|
|
8308
|
+
if (!text.trim()) { showToast('Paste some text first.', 'warn'); if (area) area.focus(); return; }
|
|
8309
|
+
const base = String(row.filename || 'untitled').replace(/\.[^.]+$/, '');
|
|
8310
|
+
const name = `${base} (text).txt`;
|
|
8311
|
+
const dataUrl = `data:text/plain;base64,${btoa(unescape(encodeURIComponent(text)))}`;
|
|
8312
|
+
try {
|
|
8313
|
+
await api(kbUrl(proj.id, '/sources'), { method: 'POST',
|
|
8314
|
+
body: JSON.stringify({ files: [{ name, dataUrl }], ...(proj.uuid ? { expectedProjectUuid: proj.uuid } : {}) }) });
|
|
8315
|
+
if (current !== proj) return;
|
|
8316
|
+
showToast(`Added “${name}” as a note`, 'ok');
|
|
8317
|
+
} catch (err) {
|
|
8318
|
+
console.error('[workspaces] adding a pasted note failed', err);
|
|
8319
|
+
showToast(err && err.body && err.body.code === 'project-changed'
|
|
8320
|
+
? 'This project was replaced while the note was being added, so nothing was added. Open the project and paste it again.'
|
|
8321
|
+
: (err && err.body && err.body.reason) || 'Couldn’t add the note. Check your connection, then add it again.', 'warn');
|
|
8322
|
+
}
|
|
8323
|
+
if (current === proj) renderKnowledge();
|
|
8324
|
+
}
|
|
8325
|
+
|
|
8326
|
+
/** Replace file…: upload the chosen file; once it is in, remove the reference it replaces. */
|
|
8327
|
+
let kbReplaceTarget = null;
|
|
8328
|
+
async function kbReplaceWith(file) {
|
|
8329
|
+
const proj = current;
|
|
8330
|
+
const old = kbReplaceTarget;
|
|
8331
|
+
kbReplaceTarget = null;
|
|
8332
|
+
if (!proj || !old || !file) return;
|
|
8333
|
+
if (file.size > KB_MAX_FILE_BYTES) { showToast(`“${file.name}” is too large (max ${KB_MB(KB_MAX_FILE_BYTES)} MB)`, 'warn'); return; }
|
|
8334
|
+
let upload;
|
|
8335
|
+
try { upload = await readFileAsSnapshot(file); } catch { showToast('Could not read the selected file', 'warn'); return; }
|
|
8336
|
+
if (current !== proj) return;
|
|
8337
|
+
let added = null;
|
|
8338
|
+
try {
|
|
8339
|
+
// Per-file outcome, so a file FloLess cannot take is explained in its own words and nothing is removed.
|
|
8340
|
+
const res = await api(kbUrl(proj.id, '/sources'), { method: 'POST',
|
|
8341
|
+
body: JSON.stringify({ files: [upload], partial: true, ...(proj.uuid ? { expectedProjectUuid: proj.uuid } : {}) }) });
|
|
8342
|
+
const result = (res.results || [])[0];
|
|
8343
|
+
added = (res.sources || [])[0] || null;
|
|
8344
|
+
if (!added) {
|
|
8345
|
+
showToast(`Couldn’t replace “${old.filename}”: ${(result && result.reason) || 'the new file could not be added.'} The original is still there.`, 'warn');
|
|
8346
|
+
if (current === proj) renderKnowledge();
|
|
8347
|
+
return;
|
|
8348
|
+
}
|
|
8349
|
+
await api(kbUrl(proj.id, `/sources/${encodeURIComponent(old.sourceId)}`), { method: 'DELETE' });
|
|
8350
|
+
if (current !== proj) return;
|
|
8351
|
+
setViewer({ mode: 'file', sourceId: added.sourceId });
|
|
8352
|
+
kbFocusSourceId = added.sourceId;
|
|
8353
|
+
showToast(`Replaced “${old.filename}” with “${added.filename}”`, 'ok');
|
|
8354
|
+
} catch (err) {
|
|
8355
|
+
console.error('[workspaces] replacing a knowledge file failed', err);
|
|
8356
|
+
if (added && current === proj) {
|
|
8357
|
+
// The new file is in; only the old one could not be removed. Say so, and show the new one.
|
|
8358
|
+
setViewer({ mode: 'file', sourceId: added.sourceId });
|
|
8359
|
+
kbFocusSourceId = added.sourceId;
|
|
8360
|
+
showToast(`Added “${added.filename}”, but couldn’t remove “${old.filename}”. Remove it from the list.`, 'warn');
|
|
8361
|
+
} else {
|
|
8362
|
+
showToast(err && err.body && err.body.code === 'project-changed'
|
|
8363
|
+
? 'This project was replaced while the file was being read, so nothing changed.'
|
|
8364
|
+
: 'Couldn’t replace the file. The original is still there. Check your connection, then try again.', 'warn');
|
|
8365
|
+
}
|
|
8366
|
+
}
|
|
8367
|
+
if (current === proj) renderKnowledge();
|
|
8368
|
+
}
|
|
8369
|
+
|
|
7529
8370
|
/** Text is read as a stream and STOPPED at 256 KB. The upload cap is 100 MB per file, so an uncapped
|
|
7530
8371
|
* <pre> would hang the tab; cancelling the reader also stops the server-side read. The bytes go in
|
|
7531
8372
|
* with textContent — never innerHTML, never markdown, never a parsed CSV table. */
|
|
@@ -7579,15 +8420,18 @@
|
|
|
7579
8420
|
}
|
|
7580
8421
|
|
|
7581
8422
|
function kbColumn(st) {
|
|
7582
|
-
|
|
7583
|
-
const
|
|
7584
|
-
|
|
7585
|
-
|
|
8423
|
+
// #2399 slice 0c: a file of an issue is listed under its issue, not again here; the list says how many went there.
|
|
8424
|
+
const loose = st.sources.filter((source) => !kbInDesignSet(source, st));
|
|
8425
|
+
const inSet = st.sources.length - loose.length;
|
|
8426
|
+
const jump = inSet ? `<button type="button" class="kb-link kb-ds-jump" data-kb-ds-jump data-command-id="shell.kb-design-set-jump" data-tip="Go to the Design set">${inSet} more in the design set</button>` : '';
|
|
8427
|
+
const body = (loose.length
|
|
8428
|
+
? loose.map((source) => kbSourceRow(source, st)).join('')
|
|
8429
|
+
: (inSet ? '' : '<div class="kb-empty">No references yet — drop files above (PDF, Word, Excel, email, pictures or text), or ask your terminal AI to add them.</div>')) + jump;
|
|
7586
8430
|
return '<section class="kb-col">' +
|
|
7587
|
-
'<div class="kb-refs-body">' +
|
|
7588
|
-
'<button type="button" class="kb-drop" id="kb-drop" data-command-id="shell.add-knowledge" data-tip="Drop files here, or click to pick them">' +
|
|
8431
|
+
'<div class="kb-refs-body">' + kbDesignSetStrip(st) +
|
|
8432
|
+
'<button type="button" class="kb-drop" id="kb-drop" data-command-id="shell.add-knowledge" data-tip="Drop PDF, Word, Excel, email (.msg, .eml), picture or text files here, or click to pick them">' +
|
|
7589
8433
|
'<span class="di" aria-hidden="true">⤓</span><span class="dt">Drop references here</span>' +
|
|
7590
|
-
'<span class="ds">PDF ·
|
|
8434
|
+
'<span class="ds">PDF · Word · Excel · email · images · text</span>' +
|
|
7591
8435
|
'</button>' + body +
|
|
7592
8436
|
'</div>' + kbFoot(st) + '</section>';
|
|
7593
8437
|
}
|
|
@@ -7646,6 +8490,8 @@
|
|
|
7646
8490
|
$wsKnowledge.innerHTML = kbStepHeadHtml(knowledgeState) +
|
|
7647
8491
|
'<div class="kb-split">' +
|
|
7648
8492
|
'<div class="kb-refs-host" id="kb-refs-host"></div>' +
|
|
8493
|
+
// Outside the repainted host: the drop zone's "Choose files" announcement must outlive a poll repaint.
|
|
8494
|
+
'<div class="kb-live" id="kb-drop-live" aria-live="polite"></div>' +
|
|
7649
8495
|
'<div class="kb-refs-stub" aria-hidden="true"><span class="vertical-label">References</span></div>' +
|
|
7650
8496
|
'<div class="pane-rail kb-rail">' +
|
|
7651
8497
|
'<div class="resize-handle" data-kb-rail-resize role="separator" tabindex="0" aria-orientation="vertical" aria-controls="kb-refs-host" aria-label="Resize References panel" data-command-id="shell.knowledge-refs-resize" data-tip="Drag to resize · double-click to reset"></div>' +
|
|
@@ -7774,14 +8620,16 @@
|
|
|
7774
8620
|
const curGen = st.currentGeneration ? st.currentGeneration.generationId : '';
|
|
7775
8621
|
return 'page:' + (viewer.generationId || curGen) + ':' + curGen + ':' + (viewer.slug || '');
|
|
7776
8622
|
}
|
|
7777
|
-
const row = viewer.mode === 'file' ? st
|
|
8623
|
+
const row = viewer.mode === 'file' ? kbViewRow(st, viewer.sourceId) : null;
|
|
7778
8624
|
const gen = viewer.mode === 'graph' && st.currentGeneration ? st.currentGeneration.generationId : '';
|
|
7779
|
-
|
|
8625
|
+
// The text state too (#2491): a Word, Excel or email file whose text lands while it is open repaints with it.
|
|
8626
|
+
const text = row && row.text ? `${row.text.state}:${row.text.blobSha256 || ''}` : '';
|
|
8627
|
+
return [current && current.id, viewer.mode, viewer.sourceId || '', row ? row.blobSha256 : '', text, gen].join('|');
|
|
7780
8628
|
}
|
|
7781
8629
|
|
|
7782
8630
|
function paintKnowledge(st) {
|
|
7783
8631
|
// The previewed source may have been removed under us (by this tab or the terminal AI).
|
|
7784
|
-
if (viewer.mode === 'file' && !st
|
|
8632
|
+
if (viewer.mode === 'file' && !kbViewRow(st, viewer.sourceId)) {
|
|
7785
8633
|
setViewer({ mode: 'graph', sourceId: null });
|
|
7786
8634
|
}
|
|
7787
8635
|
kbEnsureShell();
|
|
@@ -7798,7 +8646,7 @@
|
|
|
7798
8646
|
// DOM; suppressing the repaint while it's active (kbAdjustActive) is simpler and safer than
|
|
7799
8647
|
// snapshotting/restoring every piece. lastRefsHtml is left stale, so the next tick (once the box is
|
|
7800
8648
|
// inactive) catches the column up to the latest state.
|
|
7801
|
-
if (html !== lastRefsHtml && !kbAdjustActive()) {
|
|
8649
|
+
if (html !== lastRefsHtml && !kbAdjustActive() && !kbDsPanelBusy()) {
|
|
7802
8650
|
const oldBody = refsHost.querySelector('.kb-refs-body');
|
|
7803
8651
|
const scrollTop = oldBody ? oldBody.scrollTop : 0;
|
|
7804
8652
|
refsHost.innerHTML = html;
|
|
@@ -7813,6 +8661,14 @@
|
|
|
7813
8661
|
if (btn) btn.focus();
|
|
7814
8662
|
kbFocusSourceId = null;
|
|
7815
8663
|
}
|
|
8664
|
+
kbDsRestoreFocus(refsHost);
|
|
8665
|
+
const shown = kbActiveDesignSet(st);
|
|
8666
|
+
if (kbFocusDesignSet && (shown ? shown.sourceId : null) === kbFocusDesignSet.sourceId) {
|
|
8667
|
+
const target = refsHost.querySelector('.kb-ds .kb-fname, .kb-ds button') || refsHost.querySelector('#kb-drop');
|
|
8668
|
+
if (newBody) newBody.scrollTop = 0;
|
|
8669
|
+
if (target) target.focus({ preventScroll: true });
|
|
8670
|
+
kbFocusDesignSet = null;
|
|
8671
|
+
}
|
|
7816
8672
|
}
|
|
7817
8673
|
|
|
7818
8674
|
const key = kbViewKey(st);
|
|
@@ -7823,7 +8679,7 @@
|
|
|
7823
8679
|
kbAbortPreview();
|
|
7824
8680
|
lastViewKey = key;
|
|
7825
8681
|
if (viewer.mode === 'file') {
|
|
7826
|
-
const row = st
|
|
8682
|
+
const row = kbViewRow(st, viewer.sourceId);
|
|
7827
8683
|
if (row) {
|
|
7828
8684
|
if (viewHost) viewHost.innerHTML = kbViewShell(row, kbViewLoading(row));
|
|
7829
8685
|
kbLoadPreview(current, row);
|
|
@@ -7978,6 +8834,19 @@
|
|
|
7978
8834
|
$companyKnowledgePromotion.hidden = !companyKnowledgePromotion;
|
|
7979
8835
|
if (companyKnowledgePromotion) {
|
|
7980
8836
|
$companyPromotionSource.textContent = companyKnowledgePromotion.filename;
|
|
8837
|
+
// #2491 R6.3 (spec §8.5, §14.1): say what is copied, that an email carries people's details, and what an older
|
|
8838
|
+
// FloLess on the same folder sees. Said, never refused: the person decides.
|
|
8839
|
+
const notes = document.getElementById('company-promotion-notes');
|
|
8840
|
+
if (notes) {
|
|
8841
|
+
const mime = companyKnowledgePromotion.mime || '';
|
|
8842
|
+
const lines = !KB_OFFICE_MIMES.has(mime) ? [] : [
|
|
8843
|
+
'FloLess copies the original file and the text it read from it.',
|
|
8844
|
+
...(kbIsEmail(mime) ? ['This email contains people’s names, email addresses and messages. Company knowledge is shared with everyone in your company. Share it only if that’s fine.'] : []),
|
|
8845
|
+
'Colleagues using an older FloLess will not see the company library until they update.',
|
|
8846
|
+
];
|
|
8847
|
+
notes.hidden = !lines.length;
|
|
8848
|
+
notes.innerHTML = lines.map((line, i) => `<p class="${i === 1 && kbIsEmail(mime) ? 'warn' : ''}">${escapeHtml(line)}</p>`).join('');
|
|
8849
|
+
}
|
|
7981
8850
|
const prior = $companyPromotionLineage.value;
|
|
7982
8851
|
const entries = available ? state.sources.filter((entry) => !entry.removedAt) : [];
|
|
7983
8852
|
$companyPromotionLineage.innerHTML = '<option value="">New company entry</option>' + entries.map((entry) =>
|
|
@@ -8164,17 +9033,94 @@
|
|
|
8164
9033
|
catch { showToast('Could not read the selected files', 'warn'); return; }
|
|
8165
9034
|
if (current !== proj) return; // switched projects mid-read — never upload against the wrong KB
|
|
8166
9035
|
try {
|
|
8167
|
-
|
|
9036
|
+
// The project these files were picked for, by its incarnation: a project recreated under the same id is not it.
|
|
9037
|
+
// Per file (#2491): one file FloLess cannot take (an old .doc, an unsupported type) never sinks the rest of the
|
|
9038
|
+
// drop, and it is named with the reason in the server's plain words.
|
|
9039
|
+
const res = await api(kbUrl(proj.id, '/sources'), { method: 'POST',
|
|
9040
|
+
body: JSON.stringify({ files: uploads, partial: true, ...(proj.uuid ? { expectedProjectUuid: proj.uuid } : {}) }) });
|
|
8168
9041
|
if (current !== proj) return;
|
|
8169
9042
|
const n = (res.sources || []).length;
|
|
8170
|
-
|
|
9043
|
+
const missed = (res.results || []).filter((r) => r && r.outcome !== 'added');
|
|
9044
|
+
if (!missed.length) showToast(`Added ${n} reference${n === 1 ? '' : 's'}`, 'ok');
|
|
9045
|
+
else {
|
|
9046
|
+
const first = missed[0];
|
|
9047
|
+
const more = missed.length > 1 ? ` (and ${missed.length - 1} more not added)` : '';
|
|
9048
|
+
showToast(`${n ? `Added ${n} reference${n === 1 ? '' : 's'}. ` : ''}“${first.name}” wasn’t added: ${first.reason || 'FloLess could not take it.'}${more}`, 'warn');
|
|
9049
|
+
}
|
|
9050
|
+
// #2399 slice 0c: files uploaded from an open Add issue panel arrive ticked in it.
|
|
9051
|
+
if (kbDsPanel && kbDsPanel.kind === 'add') {
|
|
9052
|
+
if (kbDsPanel.chosen) for (const row of res.sources || []) kbDsPanel.chosen.add(row.sourceId);
|
|
9053
|
+
kbDsForceNext = true;
|
|
9054
|
+
kbDsFocus = { control: '.kb-ds-panel [data-kb-ds-add-go], .kb-ds-panel [data-kb-ds-upload]' };
|
|
9055
|
+
}
|
|
8171
9056
|
track('kb_sources_added', { app: proj.app, n });
|
|
8172
|
-
} catch {
|
|
8173
|
-
showToast(
|
|
9057
|
+
} catch (err) {
|
|
9058
|
+
showToast(err && err.body && err.body.code === 'project-changed'
|
|
9059
|
+
? 'This project was replaced while the files were being read, so nothing was added. Choose the files again.'
|
|
9060
|
+
// #2491: a file FloLess cannot take (an old .doc, an unsupported type) says why, in the server's plain words.
|
|
9061
|
+
: err && err.body && err.body.reason ? `Nothing was added. ${err.body.reason}`
|
|
9062
|
+
: 'Couldn’t add these references. Check the files and try again.', 'warn');
|
|
8174
9063
|
}
|
|
8175
9064
|
if (current === proj) renderKnowledge();
|
|
8176
9065
|
}
|
|
8177
9066
|
|
|
9067
|
+
/** Choose (or with null, clear) the design set. The revision on screen goes with it, so a design set changed
|
|
9068
|
+
* meanwhile (by a chat card or another window) is never overwritten by a screen that had not seen it. */
|
|
9069
|
+
async function kbDesignSetRegister(sourceId, seen) {
|
|
9070
|
+
const proj = current;
|
|
9071
|
+
if (!proj) return;
|
|
9072
|
+
kbCloseConfirm();
|
|
9073
|
+
// The repaint destroys the control that was pressed; the one that shows the result takes focus (paintKnowledge).
|
|
9074
|
+
kbFocusDesignSet = { sourceId };
|
|
9075
|
+
try {
|
|
9076
|
+
// What the person saw when they pressed it: the revision drawn into that control, this project's incarnation, and
|
|
9077
|
+
// for a choice the bytes of the row. Any of them having moved is a 409, never a write over something unseen.
|
|
9078
|
+
const expected = { [KEY_DESIGN_SET]: seen.revision, [KEY_DS_PROJECT]: proj.uuid || '(none)',
|
|
9079
|
+
...(sourceId ? { [KEY_DS_REFERENCE]: seen.blob || '(missing)' } : {}) };
|
|
9080
|
+
await api(`/api/projects/${encodeURIComponent(proj.id)}/design-set`, { method: 'POST', body: JSON.stringify({ sourceId, expected }) });
|
|
9081
|
+
showToast(sourceId ? 'Design set chosen' : 'Design set cleared', 'ok');
|
|
9082
|
+
track(sourceId ? 'kb_design_set_chosen' : 'kb_design_set_cleared', { app: proj.app });
|
|
9083
|
+
} catch (err) {
|
|
9084
|
+
kbFocusDesignSet = null;
|
|
9085
|
+
const code = err && err.body && err.body.code;
|
|
9086
|
+
showToast(code === 'design-set-changed'
|
|
9087
|
+
? 'The design set changed while this was open. Check it and choose again.'
|
|
9088
|
+
// The server's own sentence says what to do (busy, file not in the project, an index it cannot take).
|
|
9089
|
+
: (err && err.body && typeof err.body.error === 'string' && err.body.error) || 'Couldn’t change the design set. Try again.', 'warn');
|
|
9090
|
+
}
|
|
9091
|
+
if (current !== proj) return;
|
|
9092
|
+
kbInvalidateRefs();
|
|
9093
|
+
renderKnowledge();
|
|
9094
|
+
}
|
|
9095
|
+
function kbDesignSetAsk() {
|
|
9096
|
+
const proj = current;
|
|
9097
|
+
const d = knowledgeState && kbActiveDesignSet(knowledgeState);
|
|
9098
|
+
if (!proj || !d) return;
|
|
9099
|
+
const chat = window.flolessChat;
|
|
9100
|
+
if (!chat || typeof chat.fillMessageBox !== 'function' || chat.scopeProjectId?.() !== proj.id) {
|
|
9101
|
+
showToast('Open this project’s AI chat first, then ask again.', 'warn'); return;
|
|
9102
|
+
}
|
|
9103
|
+
chat.fillMessageBox(`Please read the design set “${d.filename}” in this project’s knowledge and record its sheet index: each sheet’s number, title and page.`);
|
|
9104
|
+
}
|
|
9105
|
+
function kbShowDesignSetClearConfirm(btn) {
|
|
9106
|
+
kbCloseConfirm();
|
|
9107
|
+
const box = btn.closest('.kb-refs-body');
|
|
9108
|
+
if (!box) return;
|
|
9109
|
+
const pop = document.createElement('div');
|
|
9110
|
+
pop.className = 'hist-confirm';
|
|
9111
|
+
pop.innerHTML = '<div class="hc-title">Clear the design set?</div>' +
|
|
9112
|
+
'<div class="hc-body">The file stays in your references. Its sheet index is forgotten.</div>' +
|
|
9113
|
+
'<div class="hc-act"><button type="button" class="hc-cancel">Keep</button>' +
|
|
9114
|
+
`<button type="button" class="hc-go danger" data-kb-ds-clear-go data-kb-ds-rev="${escapeAttr(btn.dataset.kbDsRev || '(unreadable)')}">Clear</button></div>`;
|
|
9115
|
+
box.appendChild(pop);
|
|
9116
|
+
const cr = box.getBoundingClientRect();
|
|
9117
|
+
const br = btn.getBoundingClientRect();
|
|
9118
|
+
pop.style.top = `${br.bottom - cr.top + box.scrollTop + 6}px`;
|
|
9119
|
+
pop.style.left = `${Math.max(8, Math.min(br.right - cr.left - pop.offsetWidth, box.clientWidth - pop.offsetWidth - 8))}px`;
|
|
9120
|
+
document.addEventListener('mousedown', kbOnDocDown, true);
|
|
9121
|
+
const keep = pop.querySelector('.hc-cancel'); if (keep) keep.focus();
|
|
9122
|
+
}
|
|
9123
|
+
|
|
8178
9124
|
async function kbToggle(sourceId, next) {
|
|
8179
9125
|
const proj = current;
|
|
8180
9126
|
if (!proj) return;
|
|
@@ -8183,13 +9129,13 @@
|
|
|
8183
9129
|
if (current === proj) renderKnowledge(); // re-render reconciles the optimistic flip either way
|
|
8184
9130
|
}
|
|
8185
9131
|
|
|
8186
|
-
async function kbRemove(sourceId) {
|
|
9132
|
+
async function kbRemove(sourceId, okMsg) {
|
|
8187
9133
|
const proj = current;
|
|
8188
9134
|
if (!proj) return;
|
|
8189
9135
|
kbCloseConfirm();
|
|
8190
9136
|
try {
|
|
8191
9137
|
await api(kbUrl(proj.id, `/sources/${encodeURIComponent(sourceId)}`), { method: 'DELETE' });
|
|
8192
|
-
showToast('Reference removed', 'ok');
|
|
9138
|
+
showToast(okMsg || 'Reference removed', 'ok');
|
|
8193
9139
|
} catch { showToast('Couldn’t remove this reference. Try again.', 'warn'); }
|
|
8194
9140
|
if (current === proj) renderKnowledge();
|
|
8195
9141
|
}
|
|
@@ -8309,7 +9255,7 @@
|
|
|
8309
9255
|
document.removeEventListener('mousedown', kbOnDocDown, true);
|
|
8310
9256
|
}
|
|
8311
9257
|
function kbOnDocDown(e) {
|
|
8312
|
-
if (!e.target.closest('.hist-confirm') && !e.target.closest('[data-kb-remove]')) kbCloseConfirm();
|
|
9258
|
+
if (!e.target.closest('.hist-confirm') && !e.target.closest('[data-kb-remove]') && !e.target.closest('[data-kb-ds-clear]')) kbCloseConfirm();
|
|
8313
9259
|
}
|
|
8314
9260
|
// Anchored to the SCROLL container (.kb-refs-body, position:relative) — .kb-col is overflow:hidden
|
|
8315
9261
|
// and would clip the popover. Same anchoring as .ws-history's rollback confirm.
|
|
@@ -8335,19 +9281,398 @@
|
|
|
8335
9281
|
document.addEventListener('mousedown', kbOnDocDown, true);
|
|
8336
9282
|
}
|
|
8337
9283
|
|
|
9284
|
+
// ── Design set issues: what the controls do (#2399 slice 0c) ──────────────────────────────────────
|
|
9285
|
+
// Every change carries the design-set revision drawn into the control that was pressed and this project's incarnation,
|
|
9286
|
+
// so a design set changed meanwhile (by a chat card or another window) is never written over by a screen that had not
|
|
9287
|
+
// seen it. An open panel's typed values live in `kbDsPanel`, so a repaint never loses them.
|
|
9288
|
+
let kbDsForceNext = false;
|
|
9289
|
+
/** A poll must not repaint under a panel the person is typing in or ticking; a repaint this code asks for still runs. */
|
|
9290
|
+
function kbDsPanelBusy() {
|
|
9291
|
+
if (kbDsForceNext) { kbDsForceNext = false; return false; }
|
|
9292
|
+
const panel = kbDsPanel && $wsKnowledge.querySelector('.kb-ds-panel');
|
|
9293
|
+
return !!panel && panel.contains(document.activeElement);
|
|
9294
|
+
}
|
|
9295
|
+
function kbDsRepaint() {
|
|
9296
|
+
kbInvalidateRefs();
|
|
9297
|
+
kbDsForceNext = true;
|
|
9298
|
+
if (knowledgeState) paintKnowledge(knowledgeState);
|
|
9299
|
+
kbDsForceNext = false;
|
|
9300
|
+
}
|
|
9301
|
+
/** After a repaint the control that was pressed is gone: focus its successor, or the issue, or the section. */
|
|
9302
|
+
function kbDsRestoreFocus(host) {
|
|
9303
|
+
const want = kbDsFocus;
|
|
9304
|
+
if (!want) return;
|
|
9305
|
+
kbDsFocus = null;
|
|
9306
|
+
const issue = want.issueId ? host.querySelector(`[data-kb-ds-issue-id="${CSS.escape(want.issueId)}"]`) : null;
|
|
9307
|
+
const scope = issue || host.querySelector('.kb-ds');
|
|
9308
|
+
const target = (want.control && scope && scope.querySelector(want.control))
|
|
9309
|
+
|| (issue && issue.querySelector('.kb-ds-sum')) || host.querySelector('.kb-ds .kb-ds-add, .kb-ds .kb-ds-sum');
|
|
9310
|
+
if (target) target.focus({ preventScroll: false });
|
|
9311
|
+
if (want.select && target && typeof target.select === 'function') target.select();
|
|
9312
|
+
}
|
|
9313
|
+
const kbDsExpected = (proj, rev) => ({ [KEY_DESIGN_SET]: rev || '(unreadable)', [KEY_DS_PROJECT]: proj.uuid || '(none)' });
|
|
9314
|
+
const kbDsBase = (proj) => `/api/projects/${encodeURIComponent(proj.id)}/design-set`;
|
|
9315
|
+
function kbDsErrorText(err, fallback) {
|
|
9316
|
+
const code = err && err.body && err.body.code;
|
|
9317
|
+
if (code === 'design-set-changed') return 'The design set changed while this was open. Check it and try again.';
|
|
9318
|
+
return (err && err.body && typeof err.body.error === 'string' && err.body.error) || fallback;
|
|
9319
|
+
}
|
|
9320
|
+
function kbDsOpenPanel(panel, focus) {
|
|
9321
|
+
kbCloseConfirm();
|
|
9322
|
+
// The revision the person is editing against, kept with the panel: a repaint while it is open (another window renamed
|
|
9323
|
+
// the issue) must not quietly give Save the newer revision and let it overwrite that change.
|
|
9324
|
+
kbDsPanel = { ...panel, rev: kbDsRev(knowledgeState) };
|
|
9325
|
+
if (panel.issueId) { kbDsIsOpen({ issueId: panel.issueId }, knowledgeState); kbDsOpen.ids.add(panel.issueId); }
|
|
9326
|
+
kbDsFocus = focus;
|
|
9327
|
+
kbDsRepaint();
|
|
9328
|
+
}
|
|
9329
|
+
function kbDsClosePanel(focus) {
|
|
9330
|
+
kbDsPanel = null;
|
|
9331
|
+
kbDsFocus = focus || null;
|
|
9332
|
+
kbDsRepaint();
|
|
9333
|
+
}
|
|
9334
|
+
/** One write to the design set, then a fresh read of it. The server's own sentence says what went wrong. */
|
|
9335
|
+
async function kbDsWrite(method, path, body, okMsg, focus) {
|
|
9336
|
+
const proj = current;
|
|
9337
|
+
if (!proj) return false;
|
|
9338
|
+
let ok = true;
|
|
9339
|
+
try {
|
|
9340
|
+
await api(`${kbDsBase(proj)}${path}`, { method, body: JSON.stringify(body) });
|
|
9341
|
+
if (okMsg) showToast(okMsg, 'ok');
|
|
9342
|
+
} catch (err) {
|
|
9343
|
+
ok = false;
|
|
9344
|
+
const text = kbDsErrorText(err, 'Couldn’t change the design set. Try again.');
|
|
9345
|
+
if (kbDsPanel) kbDsPanel.error = text; else showToast(text, 'warn');
|
|
9346
|
+
}
|
|
9347
|
+
if (current !== proj) return ok;
|
|
9348
|
+
if (ok && kbDsPanel && kbDsPanel.kind !== 'read') kbDsPanel = null;
|
|
9349
|
+
kbDsFocus = focus || null;
|
|
9350
|
+
kbInvalidateRefs();
|
|
9351
|
+
kbDsForceNext = true;
|
|
9352
|
+
await renderKnowledge();
|
|
9353
|
+
kbDsForceNext = false;
|
|
9354
|
+
return ok;
|
|
9355
|
+
}
|
|
9356
|
+
const kbDsIssueById = (id) => ((knowledgeState && knowledgeState.designSet && knowledgeState.designSet.issues) || []).find((i) => i.issueId === id) || null;
|
|
9357
|
+
|
|
9358
|
+
/** The More menu: rename, index, withdraw or restore an issue — anchored like every other popover in this column. */
|
|
9359
|
+
function kbDsShowMenu(btn) {
|
|
9360
|
+
kbCloseConfirm();
|
|
9361
|
+
const issue = kbDsIssueById(btn.dataset.kbDsMore);
|
|
9362
|
+
const box = btn.closest('.kb-refs-body');
|
|
9363
|
+
if (!issue || !box) return;
|
|
9364
|
+
const pop = document.createElement('div');
|
|
9365
|
+
pop.className = 'hist-confirm kb-ds-menu';
|
|
9366
|
+
pop.setAttribute('role', 'menu');
|
|
9367
|
+
pop.setAttribute('aria-label', `More for ${issue.label}`);
|
|
9368
|
+
const id = escapeAttr(issue.issueId);
|
|
9369
|
+
const rev = escapeAttr(btn.dataset.kbDsRev || '(unreadable)');
|
|
9370
|
+
const live = issue.files.some((f) => !f.withdrawn && f.presence === 'present');
|
|
9371
|
+
pop.innerHTML =
|
|
9372
|
+
`<button type="button" role="menuitem" class="kb-ds-mi" data-kb-ds-rename="${id}" data-command-id="shell.kb-design-issue-rename">Rename or date…</button>` +
|
|
9373
|
+
(live ? `<button type="button" role="menuitem" class="kb-ds-mi" data-kb-ds-ask="${id}" data-command-id="shell.kb-design-set-ask">Ask AI to build the sheet index</button>` : '') +
|
|
9374
|
+
(issue.withdrawnAt
|
|
9375
|
+
? `<button type="button" role="menuitem" class="kb-ds-mi" data-kb-ds-irestore="${id}" data-kb-ds-rev="${rev}" data-command-id="shell.kb-design-issue-restore">Restore issue</button>`
|
|
9376
|
+
: `<button type="button" role="menuitem" class="kb-ds-mi" data-kb-ds-iwithdraw="${id}" data-kb-ds-rev="${rev}" data-command-id="shell.kb-design-issue-withdraw">Withdraw issue</button>`);
|
|
9377
|
+
box.appendChild(pop);
|
|
9378
|
+
const cr = box.getBoundingClientRect();
|
|
9379
|
+
const br = btn.getBoundingClientRect();
|
|
9380
|
+
pop.style.top = `${br.bottom - cr.top + box.scrollTop + 6}px`;
|
|
9381
|
+
pop.style.left = `${Math.max(8, Math.min(br.left - cr.left, box.clientWidth - pop.offsetWidth - 8))}px`;
|
|
9382
|
+
document.addEventListener('mousedown', kbOnDocDown, true);
|
|
9383
|
+
const first = pop.querySelector('.kb-ds-mi'); if (first) first.focus();
|
|
9384
|
+
}
|
|
9385
|
+
|
|
9386
|
+
/** ✕ on a file of an issue: withdraw it (the default, it stays in the issue's history) or remove its reference. */
|
|
9387
|
+
function kbDsShowFileChoice(btn) {
|
|
9388
|
+
kbCloseConfirm();
|
|
9389
|
+
const issue = kbDsIssueById(btn.dataset.kbDsIssue);
|
|
9390
|
+
const f = issue && issue.files.find((x) => x.index === Number(btn.dataset.kbDsFx));
|
|
9391
|
+
const box = btn.closest('.kb-refs-body');
|
|
9392
|
+
if (!f || !box) return;
|
|
9393
|
+
const versions = Array.isArray(f.usedBy) ? f.usedBy.filter((u) => u.version).map((u) => `v${u.version}`) : [];
|
|
9394
|
+
const open = Array.isArray(f.usedBy) && f.usedBy.some((u) => !u.version);
|
|
9395
|
+
const use = f.usedBy === 'unknown' ? 'FloLess could not check which reads used it. '
|
|
9396
|
+
: versions.length || open ? `${[...versions, ...(open ? ['a read still open'] : [])].join(', ')} ${versions.length + (open ? 1 : 0) === 1 ? 'was' : 'were'} read from it and keep${versions.length + (open ? 1 : 0) === 1 ? 's' : ''} its own copy. ` : '';
|
|
9397
|
+
const row = btn.dataset.kbDsRow;
|
|
9398
|
+
const pop = document.createElement('div');
|
|
9399
|
+
pop.className = 'hist-confirm';
|
|
9400
|
+
pop.setAttribute('role', 'dialog');
|
|
9401
|
+
pop.setAttribute('aria-label', `Withdraw ${f.filename}`);
|
|
9402
|
+
if (btn.hasAttribute('data-kb-ds-fwd')) {
|
|
9403
|
+
pop.innerHTML = `<div class="hc-title">Remove “${escapeHtml(f.filename)}” from your references?</div>` +
|
|
9404
|
+
`<div class="hc-body">${escapeHtml(use)}It is withdrawn from ${escapeHtml(issue.label)} already. The design set keeps its copy.</div>` +
|
|
9405
|
+
'<div class="hc-act"><button type="button" class="hc-cancel" data-command-id="shell.kb-design-panel-cancel">Cancel</button>' +
|
|
9406
|
+
`<button type="button" class="hc-go" data-kb-ds-fremove="${escapeAttr(row || '')}" data-kb-ds-issue="${escapeAttr(issue.issueId)}" data-command-id="shell.kb-design-file-remove-go">Remove reference</button></div>`;
|
|
9407
|
+
} else
|
|
9408
|
+
pop.innerHTML = `<div class="hc-title">Withdraw “${escapeHtml(f.filename)}” from ${escapeHtml(issue.label)}?</div>` +
|
|
9409
|
+
`<div class="hc-body">${escapeHtml(use)}It stays in this issue’s history and nothing is thrown away. You can restore it.` +
|
|
9410
|
+
(row ? ' Or remove it from your references; the design set still keeps its copy.' : '') + '</div>' +
|
|
9411
|
+
'<div class="hc-act"><button type="button" class="hc-cancel" data-command-id="shell.kb-design-panel-cancel">Cancel</button>' +
|
|
9412
|
+
(row ? `<button type="button" class="hc-alt" data-kb-ds-fremove="${escapeAttr(row)}" data-kb-ds-issue="${escapeAttr(issue.issueId)}" data-command-id="shell.kb-design-file-remove-go">Remove reference</button>` : '') +
|
|
9413
|
+
`<button type="button" class="hc-go" data-kb-ds-fwithdraw="${f.index}" data-kb-ds-issue="${escapeAttr(issue.issueId)}" data-kb-ds-rev="${escapeAttr(btn.dataset.kbDsRev || '(unreadable)')}" data-command-id="shell.kb-design-file-withdraw">Withdraw</button></div>`;
|
|
9414
|
+
box.appendChild(pop);
|
|
9415
|
+
const cr = box.getBoundingClientRect();
|
|
9416
|
+
const br = btn.getBoundingClientRect();
|
|
9417
|
+
pop.style.top = `${br.bottom - cr.top + box.scrollTop + 6}px`;
|
|
9418
|
+
pop.style.left = `${Math.max(8, Math.min(br.right - cr.left - pop.offsetWidth, box.clientWidth - pop.offsetWidth - 8))}px`;
|
|
9419
|
+
document.addEventListener('mousedown', kbOnDocDown, true);
|
|
9420
|
+
// The safe choice has focus: Withdraw when it is offered, never the removal that happens to come first in the row.
|
|
9421
|
+
const safe = pop.querySelector('[data-kb-ds-fwithdraw]') || pop.querySelector('[data-kb-ds-fremove]'); if (safe) safe.focus();
|
|
9422
|
+
}
|
|
9423
|
+
|
|
9424
|
+
async function kbDsOpenRead(issueId) {
|
|
9425
|
+
const proj = current;
|
|
9426
|
+
if (!proj) return;
|
|
9427
|
+
kbDsOpenPanel({ kind: 'read', issueId, plan: null }, { issueId, control: '.kb-ds-panel' });
|
|
9428
|
+
let plan;
|
|
9429
|
+
try { plan = await api(`${kbDsBase(proj)}/issues/${encodeURIComponent(issueId)}/read-plan`); }
|
|
9430
|
+
catch (err) {
|
|
9431
|
+
if (current !== proj || !kbDsPanel || kbDsPanel.issueId !== issueId) return;
|
|
9432
|
+
kbDsPanel = null;
|
|
9433
|
+
showToast(kbDsErrorText(err, 'Couldn’t check the files of this issue. Try again.'), 'warn');
|
|
9434
|
+
kbDsRepaint();
|
|
9435
|
+
return;
|
|
9436
|
+
}
|
|
9437
|
+
if (current !== proj || !kbDsPanel || kbDsPanel.kind !== 'read' || kbDsPanel.issueId !== issueId) return;
|
|
9438
|
+
kbDsPanel.plan = plan;
|
|
9439
|
+
kbDsPanel.chosen = new Set(plan.included.map((f) => f.index));
|
|
9440
|
+
kbDsFocus = { issueId, control: '.kb-ds-panel input[type="checkbox"], .kb-ds-panel .btn-mini' };
|
|
9441
|
+
kbDsRepaint();
|
|
9442
|
+
}
|
|
9443
|
+
|
|
9444
|
+
async function kbDsReadGo(issueId, returnFocus) {
|
|
9445
|
+
const proj = current;
|
|
9446
|
+
const panel = kbDsPanel;
|
|
9447
|
+
if (!proj || !panel || panel.kind !== 'read' || !panel.plan) return;
|
|
9448
|
+
const chosen = [...panel.chosen].sort((a, b) => a - b);
|
|
9449
|
+
const asPlanned = panel.plan.chosenByDefault && chosen.length === panel.plan.included.length
|
|
9450
|
+
&& chosen.every((n, i) => n === panel.plan.included[i].index);
|
|
9451
|
+
try {
|
|
9452
|
+
// A changed choice gets its own plan key first: the read takes exactly what this panel shows.
|
|
9453
|
+
const plan = asPlanned ? panel.plan
|
|
9454
|
+
: await api(`${kbDsBase(proj)}/issues/${encodeURIComponent(issueId)}/read-plan?files=${chosen.join(',')}`);
|
|
9455
|
+
// The panel promised the ticked files (40 at most). If the server would take a different set — a copy changed
|
|
9456
|
+
// meanwhile — show its plan instead of starting a read the person did not see.
|
|
9457
|
+
const promised = chosen.slice(0, 40).join(',');
|
|
9458
|
+
if (!asPlanned && plan.included.map((f) => f.index).join(',') !== promised) {
|
|
9459
|
+
if (current !== proj || !kbDsPanel) return;
|
|
9460
|
+
kbDsPanel.plan = { ...plan, chosenByDefault: false };
|
|
9461
|
+
kbDsPanel.chosen = new Set(plan.included.map((f) => f.index));
|
|
9462
|
+
kbDsPanel.error = 'Some of the files you ticked cannot be read just now; the list below says why. Check it, then read again.';
|
|
9463
|
+
kbDsFocus = { issueId, control: '.kb-ds-err, [data-kb-ds-read-go]' };
|
|
9464
|
+
kbDsRepaint();
|
|
9465
|
+
return;
|
|
9466
|
+
}
|
|
9467
|
+
const res = await api(`/api/projects/${encodeURIComponent(proj.id)}/revision-requests`, { method: 'POST',
|
|
9468
|
+
body: JSON.stringify({ appId: proj.app, designIssue: { issueId, ...(asPlanned ? {} : { files: chosen }), planKey: plan.planKey } }) });
|
|
9469
|
+
if (current !== proj) return;
|
|
9470
|
+
const n = plan.included.length;
|
|
9471
|
+
const issue = kbDsIssueById(issueId);
|
|
9472
|
+
showToast(`Read queued — ${n} file${n === 1 ? '' : 's'} of “${(issue && issue.label) || 'the issue'}” for your terminal AI`, 'ok');
|
|
9473
|
+
track('kb_design_issue_read', { app: proj.app, n });
|
|
9474
|
+
if (bridge.loadRequests) bridge.loadRequests().catch(() => {});
|
|
9475
|
+
kbDsClosePanel({ issueId, control: '[data-kb-ds-read]' });
|
|
9476
|
+
if (res && res.request && bridge.showRequestQueuedModal) bridge.showRequestQueuedModal(res.request, { copied: false, fileCount: n, returnFocus });
|
|
9477
|
+
} catch (err) {
|
|
9478
|
+
if (current !== proj || !kbDsPanel) return;
|
|
9479
|
+
const code = err && err.body && err.body.code;
|
|
9480
|
+
kbDsPanel.error = kbDsErrorText(err, 'Couldn’t queue the read. Try again.');
|
|
9481
|
+
kbDsPanel.openRequests = ['revision-read-active', 'multiple-failed-reads', 'recovery-pending'].includes(code);
|
|
9482
|
+
kbDsFocus = { issueId, control: '.kb-ds-err .kb-link, [data-kb-ds-read-go]' };
|
|
9483
|
+
kbDsRepaint();
|
|
9484
|
+
}
|
|
9485
|
+
}
|
|
9486
|
+
|
|
9487
|
+
/** The issue date as the server checks it: empty, or a real calendar date written YYYY-MM-DD. */
|
|
9488
|
+
const KB_DS_DATE_ERROR = 'The issue date must be a calendar date written as YYYY-MM-DD, or empty.';
|
|
9489
|
+
function kbDsDateOk(raw) {
|
|
9490
|
+
if (!raw) return true;
|
|
9491
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(raw)) return false;
|
|
9492
|
+
const at = new Date(`${raw}T00:00:00Z`);
|
|
9493
|
+
return Number.isFinite(at.getTime()) && at.toISOString().slice(0, 10) === raw;
|
|
9494
|
+
}
|
|
9495
|
+
async function kbDsAddGo(rev) {
|
|
9496
|
+
const proj = current;
|
|
9497
|
+
const st = knowledgeState;
|
|
9498
|
+
if (!proj || !st || !kbDsPanel || kbDsPanel.kind !== 'add') return;
|
|
9499
|
+
const drawings = kbDsAddable(st);
|
|
9500
|
+
const chosen = kbDsPanel.chosen ? drawings.filter((s) => kbDsPanel.chosen.has(s.sourceId)) : drawings.filter((s) => !kbInDesignSet(s, st));
|
|
9501
|
+
const label = ($wsKnowledge.querySelector('#kb-ds-label')?.value || '').trim();
|
|
9502
|
+
const issuedOn = ($wsKnowledge.querySelector('#kb-ds-date')?.value || '').trim();
|
|
9503
|
+
kbDsPanel.label = label; kbDsPanel.date = issuedOn;
|
|
9504
|
+
if (!kbDsDateOk(issuedOn)) { kbDsPanel.error = KB_DS_DATE_ERROR; kbDsFocus = { control: '#kb-ds-date' }; kbDsRepaint(); return; }
|
|
9505
|
+
if (!chosen.length) { kbDsPanel.error = 'Tick at least one drawing, or upload new files.'; kbDsFocus = { control: '.kb-ds-panel input[type="checkbox"]' }; kbDsRepaint(); return; }
|
|
9506
|
+
if (chosen.length > 50) { kbDsPanel.error = `Only 50 files fit in one issue; ${chosen.length} are ticked. Untick some and add them as another issue.`; kbDsFocus = { control: '.kb-ds-panel input[type="checkbox"]' }; kbDsRepaint(); return; }
|
|
9507
|
+
const before = new Set(((st.designSet && st.designSet.issues) || []).map((i) => i.issueId));
|
|
9508
|
+
const ok = await kbDsWrite('POST', '/issues', { sourceIds: chosen.map((s) => s.sourceId), ...(label ? { label } : {}), ...(issuedOn ? { issuedOn } : {}),
|
|
9509
|
+
expected: kbDsExpected(proj, rev) }, `Added ${label ? `“${label}”` : 'an issue'} to the design set`, { control: '.kb-ds-add' });
|
|
9510
|
+
if (ok && knowledgeState) {
|
|
9511
|
+
const added = ((knowledgeState.designSet && knowledgeState.designSet.issues) || []).find((i) => !before.has(i.issueId));
|
|
9512
|
+
if (added) { kbDsIsOpen(added, knowledgeState); kbDsOpen.ids.add(added.issueId); kbDsFocus = { issueId: added.issueId }; kbDsRepaint(); }
|
|
9513
|
+
}
|
|
9514
|
+
}
|
|
9515
|
+
|
|
9516
|
+
/** Clicks inside the Design set. Returns true when it handled the click. */
|
|
9517
|
+
function kbDsClick(e) {
|
|
9518
|
+
const proj = current;
|
|
9519
|
+
if (!proj) return false;
|
|
9520
|
+
const t = (sel) => e.target.closest(sel);
|
|
9521
|
+
let b;
|
|
9522
|
+
if ((b = t('[data-kb-ds-add]'))) { kbDsOpenPanel({ kind: 'add' }, { control: '.kb-ds-panel input[type="checkbox"], .kb-ds-panel [data-kb-ds-upload]' }); return true; }
|
|
9523
|
+
if ((b = t('[data-kb-ds-upload]'))) { $wsKnowledgeFile.click(); return true; }
|
|
9524
|
+
if ((b = t('[data-kb-ds-cancel]'))) {
|
|
9525
|
+
const issueId = kbDsPanel && kbDsPanel.issueId;
|
|
9526
|
+
kbDsClosePanel(issueId ? { issueId, control: kbDsPanel && kbDsPanel.kind === 'read' ? '[data-kb-ds-read]' : '[data-kb-ds-more]' } : { control: '.kb-ds-add' });
|
|
9527
|
+
return true;
|
|
9528
|
+
}
|
|
9529
|
+
if ((b = t('[data-kb-ds-add-go]'))) { kbDsAddGo(b.dataset.kbDsRev); return true; }
|
|
9530
|
+
if ((b = t('[data-kb-ds-current]'))) {
|
|
9531
|
+
const id = b.dataset.kbDsCurrent;
|
|
9532
|
+
kbDsWrite('PATCH', `/issues/${encodeURIComponent(id)}`, { makeCurrent: true, expected: kbDsExpected(proj, b.dataset.kbDsRev) },
|
|
9533
|
+
'This issue is now the current one', { issueId: id, control: '.kb-ds-sum' });
|
|
9534
|
+
return true;
|
|
9535
|
+
}
|
|
9536
|
+
if ((b = t('[data-kb-ds-more]'))) { kbDsShowMenu(b); return true; }
|
|
9537
|
+
if ((b = t('[data-kb-ds-rename]'))) {
|
|
9538
|
+
const issue = kbDsIssueById(b.dataset.kbDsRename);
|
|
9539
|
+
if (issue) kbDsOpenPanel({ kind: 'rename', issueId: issue.issueId }, { issueId: issue.issueId, control: '#kb-ds-label', select: true });
|
|
9540
|
+
return true;
|
|
9541
|
+
}
|
|
9542
|
+
if ((b = t('[data-kb-ds-rename-go]'))) {
|
|
9543
|
+
const id = b.dataset.kbDsRenameGo;
|
|
9544
|
+
const label = ($wsKnowledge.querySelector('#kb-ds-label')?.value || '').trim();
|
|
9545
|
+
const date = ($wsKnowledge.querySelector('#kb-ds-date')?.value || '').trim();
|
|
9546
|
+
if (kbDsPanel) { kbDsPanel.label = label; kbDsPanel.date = date; }
|
|
9547
|
+
if (!kbDsDateOk(date) && kbDsPanel) { kbDsPanel.error = KB_DS_DATE_ERROR; kbDsFocus = { issueId: id, control: '#kb-ds-date' }; kbDsRepaint(); return true; }
|
|
9548
|
+
kbDsWrite('PATCH', `/issues/${encodeURIComponent(id)}`, { ...(label ? { label } : {}), issuedOn: date || null, expected: kbDsExpected(proj, b.dataset.kbDsRev) },
|
|
9549
|
+
'Issue renamed', { issueId: id, control: '[data-kb-ds-more]' });
|
|
9550
|
+
return true;
|
|
9551
|
+
}
|
|
9552
|
+
if ((b = t('[data-kb-ds-ask]')) && b.dataset.kbDsAsk) {
|
|
9553
|
+
kbCloseConfirm();
|
|
9554
|
+
const issue = kbDsIssueById(b.dataset.kbDsAsk);
|
|
9555
|
+
const chat = window.flolessChat;
|
|
9556
|
+
if (!issue) return true;
|
|
9557
|
+
if (!chat || typeof chat.fillMessageBox !== 'function' || chat.scopeProjectId?.() !== proj.id) {
|
|
9558
|
+
showToast('Open this project’s AI chat first, then ask again.', 'warn'); return true;
|
|
9559
|
+
}
|
|
9560
|
+
chat.fillMessageBox(`Please read the design-set issue “${issue.label}” in this project’s knowledge and record its sheet index: each sheet’s number, title and page, and which file it is in.`);
|
|
9561
|
+
return true;
|
|
9562
|
+
}
|
|
9563
|
+
if ((b = t('[data-kb-ds-iwithdraw]'))) {
|
|
9564
|
+
const id = b.dataset.kbDsIwithdraw;
|
|
9565
|
+
kbCloseConfirm();
|
|
9566
|
+
kbDsWrite('POST', `/issues/${encodeURIComponent(id)}/withdraw`, { expected: kbDsExpected(proj, b.dataset.kbDsRev) },
|
|
9567
|
+
'Issue withdrawn. Nothing was thrown away; you can restore it.', { issueId: id, control: '[data-kb-ds-more]' });
|
|
9568
|
+
return true;
|
|
9569
|
+
}
|
|
9570
|
+
if ((b = t('[data-kb-ds-irestore]'))) {
|
|
9571
|
+
const id = b.dataset.kbDsIrestore;
|
|
9572
|
+
kbCloseConfirm();
|
|
9573
|
+
kbDsWrite('POST', `/issues/${encodeURIComponent(id)}/restore`, { expected: kbDsExpected(proj, b.dataset.kbDsRev) }, 'Issue restored', { issueId: id, control: '[data-kb-ds-more]' });
|
|
9574
|
+
return true;
|
|
9575
|
+
}
|
|
9576
|
+
if ((b = t('[data-kb-ds-fx]'))) { kbDsShowFileChoice(b); return true; }
|
|
9577
|
+
if ((b = t('[data-kb-ds-fwithdraw]'))) {
|
|
9578
|
+
const id = b.dataset.kbDsIssue;
|
|
9579
|
+
kbCloseConfirm();
|
|
9580
|
+
kbDsWrite('POST', `/issues/${encodeURIComponent(id)}/withdraw`, { file: Number(b.dataset.kbDsFwithdraw), expected: kbDsExpected(proj, b.dataset.kbDsRev) },
|
|
9581
|
+
'File withdrawn. You can restore it.', { issueId: id, control: `[data-kb-ds-frestore="${CSS.escape(b.dataset.kbDsFwithdraw)}"]` });
|
|
9582
|
+
return true;
|
|
9583
|
+
}
|
|
9584
|
+
if ((b = t('[data-kb-ds-fremove]'))) {
|
|
9585
|
+
const id = b.dataset.kbDsIssue;
|
|
9586
|
+
kbDsFocus = { issueId: id };
|
|
9587
|
+
kbRemove(b.dataset.kbDsFremove, 'Reference removed. The design set kept its copy.');
|
|
9588
|
+
return true;
|
|
9589
|
+
}
|
|
9590
|
+
if ((b = t('[data-kb-ds-frestore]'))) {
|
|
9591
|
+
const id = b.dataset.kbDsIssue;
|
|
9592
|
+
kbDsWrite('POST', `/issues/${encodeURIComponent(id)}/restore`, { file: Number(b.dataset.kbDsFrestore), expected: kbDsExpected(proj, b.dataset.kbDsRev) },
|
|
9593
|
+
'File restored', { issueId: id, control: `[data-kb-ds-fx="${CSS.escape(b.dataset.kbDsFrestore)}"]` });
|
|
9594
|
+
return true;
|
|
9595
|
+
}
|
|
9596
|
+
if ((b = t('[data-kb-ds-all]'))) { kbDsShowAll.add(b.dataset.kbDsAll); kbDsFocus = { issueId: b.dataset.kbDsAll, control: `.kb-ds-file:nth-child(${KB_DS_FILES_SHOWN + 1}) .kb-fname` }; kbDsRepaint(); return true; }
|
|
9597
|
+
if ((b = t('[data-kb-ds-read]'))) { kbDsOpenRead(b.dataset.kbDsRead); return true; }
|
|
9598
|
+
if ((b = t('[data-kb-ds-read-go]'))) { kbDsReadGo(b.dataset.kbDsReadGo, b.closest('.kb-ds-issue')?.querySelector('[data-kb-ds-read]')); return true; }
|
|
9599
|
+
if ((b = t('[data-kb-ds-requests]'))) { if (bridge.openRequest) bridge.openRequest(null); return true; }
|
|
9600
|
+
if ((b = t('[data-kb-ds-jump]'))) {
|
|
9601
|
+
const sec = $wsKnowledge.querySelector('.kb-ds');
|
|
9602
|
+
// The first issue, not the first control in the page order (Add issue comes before it in the header).
|
|
9603
|
+
if (sec) { sec.scrollIntoView({ block: 'start' }); const first = sec.querySelector('.kb-ds-sum') || sec.querySelector('.kb-ds-add'); if (first) first.focus({ preventScroll: true }); }
|
|
9604
|
+
return true;
|
|
9605
|
+
}
|
|
9606
|
+
return false;
|
|
9607
|
+
}
|
|
9608
|
+
// Ticks and typing in a panel are kept in its state, so a repaint redraws them as they were.
|
|
9609
|
+
$wsKnowledge.addEventListener('change', (e) => {
|
|
9610
|
+
const pick = e.target.closest('[data-kb-ds-pick], [data-kb-ds-add-pick]');
|
|
9611
|
+
if (!pick || !kbDsPanel) return;
|
|
9612
|
+
if (kbDsPanel.kind === 'read' && pick.dataset.kbDsPick !== undefined) {
|
|
9613
|
+
const n = Number(pick.dataset.kbDsPick);
|
|
9614
|
+
if (pick.checked) kbDsPanel.chosen.add(n); else kbDsPanel.chosen.delete(n);
|
|
9615
|
+
kbDsFocus = { issueId: kbDsPanel.issueId, control: `[data-kb-ds-pick="${n}"]` };
|
|
9616
|
+
} else if (kbDsPanel.kind === 'add' && pick.dataset.kbDsAddPick !== undefined) {
|
|
9617
|
+
const st = knowledgeState;
|
|
9618
|
+
if (!kbDsPanel.chosen) kbDsPanel.chosen = new Set(kbDsAddable(st).filter((s) => !kbInDesignSet(s, st)).map((s) => s.sourceId));
|
|
9619
|
+
if (pick.checked) kbDsPanel.chosen.add(pick.dataset.kbDsAddPick); else kbDsPanel.chosen.delete(pick.dataset.kbDsAddPick);
|
|
9620
|
+
kbDsFocus = { control: `[data-kb-ds-add-pick="${CSS.escape(pick.dataset.kbDsAddPick)}"]` };
|
|
9621
|
+
}
|
|
9622
|
+
kbDsPanel.error = null;
|
|
9623
|
+
const label = $wsKnowledge.querySelector('#kb-ds-label'); const date = $wsKnowledge.querySelector('#kb-ds-date');
|
|
9624
|
+
if (label) kbDsPanel.label = label.value; if (date) kbDsPanel.date = date.value;
|
|
9625
|
+
kbDsRepaint();
|
|
9626
|
+
});
|
|
9627
|
+
$wsKnowledge.addEventListener('input', (e) => {
|
|
9628
|
+
if (!kbDsPanel) return;
|
|
9629
|
+
if (e.target.id === 'kb-ds-label') kbDsPanel.label = e.target.value;
|
|
9630
|
+
if (e.target.id === 'kb-ds-date') kbDsPanel.date = e.target.value;
|
|
9631
|
+
});
|
|
9632
|
+
$wsKnowledge.addEventListener('keydown', (e) => {
|
|
9633
|
+
if (e.key !== 'Escape') return;
|
|
9634
|
+
if (e.target.closest('.kb-ds-menu')) { kbCloseConfirm(); return; }
|
|
9635
|
+
if (kbDsPanel && e.target.closest('.kb-ds-panel')) {
|
|
9636
|
+
e.preventDefault();
|
|
9637
|
+
const issueId = kbDsPanel.issueId;
|
|
9638
|
+
kbDsClosePanel(issueId ? { issueId, control: kbDsPanel && kbDsPanel.kind === 'read' ? '[data-kb-ds-read]' : '[data-kb-ds-more]' } : { control: '.kb-ds-add' });
|
|
9639
|
+
}
|
|
9640
|
+
});
|
|
9641
|
+
// Which issues are open is the person's choice and survives repaints. `toggle` does not bubble, so this listens in capture.
|
|
9642
|
+
$wsKnowledge.addEventListener('toggle', (e) => {
|
|
9643
|
+
const d = e.target;
|
|
9644
|
+
if (!d || !d.classList || !d.classList.contains('kb-ds-issue')) return;
|
|
9645
|
+
const issue = kbDsIssueById(d.dataset.kbDsIssueId);
|
|
9646
|
+
if (!issue) return;
|
|
9647
|
+
kbDsIsOpen(issue, knowledgeState);
|
|
9648
|
+
kbDsOpen.touched = true;
|
|
9649
|
+
if (d.open) kbDsOpen.ids.add(issue.issueId); else kbDsOpen.ids.delete(issue.issueId);
|
|
9650
|
+
kbInvalidateRefs();
|
|
9651
|
+
}, true);
|
|
9652
|
+
|
|
8338
9653
|
// One delegated listener for the whole pane — the column is re-rendered wholesale on every state
|
|
8339
9654
|
// change, so per-render wiring would leak handlers.
|
|
8340
9655
|
$wsKnowledge.addEventListener('click', (e) => {
|
|
9656
|
+
if (e.target.closest('.kb-ds') || e.target.closest('.kb-ds-menu') || e.target.closest('[data-kb-ds-jump]') || e.target.closest('[data-kb-ds-fremove], [data-kb-ds-fwithdraw]')) {
|
|
9657
|
+
if (kbDsClick(e)) return;
|
|
9658
|
+
}
|
|
8341
9659
|
const promote = e.target.closest('[data-company-promote]');
|
|
8342
9660
|
if (promote) {
|
|
8343
9661
|
const row = knowledgeState && knowledgeState.sources.find((source) => source.sourceId === promote.dataset.companyPromote);
|
|
8344
|
-
if (row) openCompanyKnowledge({ sourceId: row.sourceId, filename: row.filename || 'untitled' }, promote);
|
|
9662
|
+
if (row) openCompanyKnowledge({ sourceId: row.sourceId, filename: row.filename || 'untitled', mime: row.mime }, promote);
|
|
8345
9663
|
return;
|
|
8346
9664
|
}
|
|
8347
9665
|
const company = e.target.closest('[data-company-open]');
|
|
8348
9666
|
if (company) { openCompanyKnowledge(null, company); return; }
|
|
8349
9667
|
const go = e.target.closest('[data-kb-remove-go]');
|
|
8350
9668
|
if (go) { kbRemove(go.dataset.kbRemoveGo); return; }
|
|
9669
|
+
const dsClearGo = e.target.closest('[data-kb-ds-clear-go]');
|
|
9670
|
+
if (dsClearGo) { kbDesignSetRegister(null, { revision: dsClearGo.dataset.kbDsRev || '(unreadable)' }); return; }
|
|
9671
|
+
const dsUse = e.target.closest('[data-kb-ds-use]');
|
|
9672
|
+
if (dsUse) { kbDesignSetRegister(dsUse.dataset.kbDsUse, { revision: dsUse.dataset.kbDsRev || '(unreadable)', blob: dsUse.dataset.kbDsBlob || '' }); return; }
|
|
9673
|
+
if (e.target.closest('[data-kb-ds-ask]')) { kbDesignSetAsk(); return; }
|
|
9674
|
+
const dsClear = e.target.closest('[data-kb-ds-clear]');
|
|
9675
|
+
if (dsClear) { kbShowDesignSetClearConfirm(dsClear); return; }
|
|
8351
9676
|
if (e.target.closest('.hc-cancel')) { kbCloseConfirm(); return; }
|
|
8352
9677
|
const rm = e.target.closest('[data-kb-remove]');
|
|
8353
9678
|
if (rm) {
|
|
@@ -8358,14 +9683,33 @@
|
|
|
8358
9683
|
}
|
|
8359
9684
|
const tog = e.target.closest('[data-kb-toggle]');
|
|
8360
9685
|
if (tog) {
|
|
8361
|
-
const row = tog.closest('.kb-src');
|
|
9686
|
+
const row = tog.dataset.kbToggleId ? null : tog.closest('.kb-src');
|
|
8362
9687
|
const next = tog.getAttribute('aria-checked') !== 'true';
|
|
8363
9688
|
tog.setAttribute('aria-checked', String(next)); // optimistic — reconciled by the re-render
|
|
8364
|
-
row.classList.toggle('off', !next);
|
|
9689
|
+
if (row) row.classList.toggle('off', !next);
|
|
8365
9690
|
// The DOM now disagrees with the model. If the PATCH fails, the re-rendered HTML would EQUAL the
|
|
8366
9691
|
// cache and the repaint would be skipped, stranding the wrong optimistic state on screen.
|
|
8367
9692
|
kbInvalidateRefs();
|
|
8368
|
-
kbToggle(row.dataset.sourceId, next);
|
|
9693
|
+
kbToggle(tog.dataset.kbToggleId || row.dataset.sourceId, next);
|
|
9694
|
+
return;
|
|
9695
|
+
}
|
|
9696
|
+
// #2491 R6.3: the text viewer's choices.
|
|
9697
|
+
const replace = e.target.closest('[data-kb-text-replace]');
|
|
9698
|
+
if (replace) {
|
|
9699
|
+
const row = knowledgeState && knowledgeState.sources.find((s) => s.sourceId === replace.dataset.kbTextReplace);
|
|
9700
|
+
const input = document.getElementById('ws-knowledge-replace');
|
|
9701
|
+
if (row && input) { kbReplaceTarget = { sourceId: row.sourceId, filename: row.filename || 'untitled' }; input.value = ''; input.click(); }
|
|
9702
|
+
return;
|
|
9703
|
+
}
|
|
9704
|
+
const paste = e.target.closest('[data-kb-text-paste]');
|
|
9705
|
+
if (paste) { kbOpenPasteNote(paste.dataset.kbTextPaste); return; }
|
|
9706
|
+
const pasteGo = e.target.closest('[data-kb-paste-go]');
|
|
9707
|
+
if (pasteGo) { kbPasteNote(pasteGo.dataset.kbPasteGo); return; }
|
|
9708
|
+
if (e.target.closest('[data-kb-paste-cancel]')) {
|
|
9709
|
+
const host = kbViewHost() && kbViewHost().querySelector('.kb-paste-host');
|
|
9710
|
+
if (host) host.innerHTML = '';
|
|
9711
|
+
const back = kbViewHost() && kbViewHost().querySelector('[data-kb-text-paste]');
|
|
9712
|
+
if (back) back.focus({ preventScroll: true });
|
|
8369
9713
|
return;
|
|
8370
9714
|
}
|
|
8371
9715
|
// Preview a source: the filename button. Re-clicking the open one is a no-op, not a reload.
|
|
@@ -8487,6 +9831,12 @@
|
|
|
8487
9831
|
});
|
|
8488
9832
|
// Live-enable the Adjust submit as the user types (the draft is DOM-owned; see kbSyncAdjustSubmit).
|
|
8489
9833
|
$wsKnowledge.addEventListener('input', (e) => { if (e.target && e.target.id === 'kb-adjust-input') kbSyncAdjustSubmit(); });
|
|
9834
|
+
// #2491 R6.3: Replace file… picks exactly one file.
|
|
9835
|
+
const $wsKnowledgeReplace = document.getElementById('ws-knowledge-replace');
|
|
9836
|
+
if ($wsKnowledgeReplace) $wsKnowledgeReplace.addEventListener('change', () => {
|
|
9837
|
+
const file = $wsKnowledgeReplace.files && $wsKnowledgeReplace.files[0];
|
|
9838
|
+
if (file) kbReplaceWith(file); else kbReplaceTarget = null;
|
|
9839
|
+
});
|
|
8490
9840
|
$wsKnowledgeFile.addEventListener('change', () => {
|
|
8491
9841
|
kbUpload($wsKnowledgeFile.files);
|
|
8492
9842
|
$wsKnowledgeFile.value = ''; // let the same file be picked twice in a row
|
|
@@ -10126,7 +11476,9 @@
|
|
|
10126
11476
|
function exportSourceOptions(data) {
|
|
10127
11477
|
if (!data) return [];
|
|
10128
11478
|
const out = [];
|
|
10129
|
-
|
|
11479
|
+
// #2449: each approved source carries its own frozen connection-assumptions label from the server, bound to it.
|
|
11480
|
+
const frozen = (row) => (row && row.connectionAssumptions && typeof row.connectionAssumptions.note === 'string' ? row.connectionAssumptions : null);
|
|
11481
|
+
if (data.default) out.push({ selector: { kind: 'latest-approved' }, label: `Latest approved · v${data.default.version}`, group: 'Recommended', version: data.default.version, assumptions: frozen(data.default) });
|
|
10130
11482
|
if (data.working) out.push({
|
|
10131
11483
|
selector: {
|
|
10132
11484
|
kind: 'working', expectedEtag: data.working.etag,
|
|
@@ -10136,7 +11488,7 @@
|
|
|
10136
11488
|
});
|
|
10137
11489
|
for (const saved of data.checkpoints || []) out.push({ selector: { kind: 'checkpoint', checkpointId: saved.checkpointId, expectedHash: saved.hash }, label: `Checkpoint ${String(saved.checkpointId).slice(0, 8)} · DRAFT`, group: 'Drafts', sub: saved.baseVersion ? `Pending work from v${saved.baseVersion}` : 'No approved baseline' });
|
|
10138
11490
|
for (const row of data.defaultUnavailable?.reason === 'refused' ? [] : (data.approved || [])) {
|
|
10139
|
-
if (!data.default || Number(row.version) !== Number(data.default.version)) out.push({ selector: { kind: 'approved', version: row.version }, label: `Older approved · v${row.version}`, group: 'Approved history' });
|
|
11491
|
+
if (!data.default || Number(row.version) !== Number(data.default.version)) out.push({ selector: { kind: 'approved', version: row.version }, label: `Older approved · v${row.version}`, group: 'Approved history', version: row.version, assumptions: frozen(row) });
|
|
10140
11492
|
}
|
|
10141
11493
|
return out;
|
|
10142
11494
|
}
|
|
@@ -10186,6 +11538,57 @@
|
|
|
10186
11538
|
return `<div class="export-source"><label id="export-source-label">Export source</label><div class="export-source-combo"><button type="button" class="wf-trigger export-source-trigger" aria-haspopup="listbox" aria-expanded="${String(exportSourcesState.open)}" aria-labelledby="export-source-label export-source-value"><span id="export-source-value">${escapeHtml(selected ? selected.label : 'Choose export source')}</span><span class="wf-caret" aria-hidden="true">▾</span></button><div class="wf-popover export-source-popover" role="listbox" aria-label="Export source"${exportSourcesState.open ? '' : ' hidden'}>${grouped}</div></div>${raw}${warning}</div>`;
|
|
10187
11539
|
}
|
|
10188
11540
|
|
|
11541
|
+
/**
|
|
11542
|
+
* #2449: the connection assumptions the SELECTED export source rests on, from that source's own frozen approval record,
|
|
11543
|
+
* said once above the cards. Only the bill of materials report carries the note inside its file; the other formats do
|
|
11544
|
+
* not, and the sentence says so, so a shared file is not taken as resting on nothing. A draft or checkpoint is not an
|
|
11545
|
+
* approved version: it says so instead of borrowing its base version's list.
|
|
11546
|
+
*/
|
|
11547
|
+
function exportsAssumptionsHtml() {
|
|
11548
|
+
const source = currentExportSourceOption();
|
|
11549
|
+
if (!source) return '';
|
|
11550
|
+
return selectedSourceAssumptionsHtml(source) + exportedFilesAssumptionsHtml(source);
|
|
11551
|
+
}
|
|
11552
|
+
|
|
11553
|
+
/**
|
|
11554
|
+
* The files already listed on the cards were exported from the LATEST approved version (the listing only returns
|
|
11555
|
+
* receipts for it). While another source is selected the note above describes that source, so the written files
|
|
11556
|
+
* keep their own line here: a CSV, Excel, IFC or SVG file carries no note inside it (PR #2507 review).
|
|
11557
|
+
*/
|
|
11558
|
+
function exportedFilesAssumptionsHtml(source) {
|
|
11559
|
+
const latest = exportSourceOptions(exportSourcesState.data).find((o) => o.selector.kind === 'latest-approved');
|
|
11560
|
+
const a = latest && latest.assumptions;
|
|
11561
|
+
if (!a || !exportState || !Object.values(exportState).some((e) => e && e.exportedAt)) return '';
|
|
11562
|
+
// Only when the listing that returned these files names the SAME approved version and contract as the source
|
|
11563
|
+
// listing: the two are separate requests, and an approval in another tab between them must not relabel v4's files
|
|
11564
|
+
// with v5's assumptions. A mismatch says nothing until the next refresh brings them back in step.
|
|
11565
|
+
const from = exportStateFrom;
|
|
11566
|
+
const latestHash = exportSourcesState.data && exportSourcesState.data.default && exportSourcesState.data.default.hash;
|
|
11567
|
+
if (!from || Number(from.version) !== Number(latest.version) || from.hash !== latestHash) return '';
|
|
11568
|
+
const sel = source.selector;
|
|
11569
|
+
if (sel.kind === 'latest-approved' || (sel.kind === 'approved' && Number(sel.version) === Number(latest.version))) return '';
|
|
11570
|
+
return `<div class="hist-change-caution hist-assumptions ws-exports-files-assumptions" role="note"><strong>The files already exported below come from approved version v${escapeHtml(String(latest.version))}: ${escapeHtml(a.note)}</strong>` +
|
|
11571
|
+
`<div class="hist-assumption-about">Choose Latest approved · v${escapeHtml(String(latest.version))} as the source to see the statements.</div></div>`;
|
|
11572
|
+
}
|
|
11573
|
+
|
|
11574
|
+
function selectedSourceAssumptionsHtml(source) {
|
|
11575
|
+
const kind = source.selector && source.selector.kind;
|
|
11576
|
+
if (kind === 'working' || kind === 'checkpoint') {
|
|
11577
|
+
// Said for every steel draft (only steel records connection assumptions), never only when some approved
|
|
11578
|
+
// version happens to rest on one: a draft made before the first approval needs it just as much.
|
|
11579
|
+
const steel = !!(current && (current.templateId || current.app) === 'steel-model');
|
|
11580
|
+
return steel ? '<div class="hist-change-caution hist-assumptions ws-exports-assumptions" role="note"><strong>A draft is not an approved version, so FloLess has no record of the connection assumptions it rests on.</strong>' +
|
|
11581
|
+
'<div class="hist-assumption-about">The AI Chat readiness review lists the ones on the current model.</div></div>' : '';
|
|
11582
|
+
}
|
|
11583
|
+
const a = source.assumptions;
|
|
11584
|
+
if (!a) return '';
|
|
11585
|
+
const entries = a.state === 'recorded' && Array.isArray(a.entries) ? a.entries : [];
|
|
11586
|
+
const items = entries.slice(0, 5).map((e) => `<li>“${escapeHtml(String(e.statement || ''))}” <span class="hist-assumption-about">About ${escapeHtml(String(e.readingText || ''))} (${escapeHtml(String(e.jointId || ''))})</span></li>`).join('');
|
|
11587
|
+
const more = entries.length > 5 ? `<li>${escapeHtml(String(entries.length - 5))} more are listed on version v${escapeHtml(String(source.version))} in History.</li>` : '';
|
|
11588
|
+
return `<div class="hist-change-caution hist-assumptions ws-exports-assumptions" role="note"><strong>Approved version v${escapeHtml(String(source.version))}: ${escapeHtml(a.note)}</strong>` +
|
|
11589
|
+
`${items || more ? `<ul>${items}${more}</ul>` : ''}<div class="hist-assumption-about">The bill of materials report (HTML) says this inside the file. The CSV, Excel, IFC and SVG files do not, so mention it when you share them.</div></div>`;
|
|
11590
|
+
}
|
|
11591
|
+
|
|
10189
11592
|
function paintExports(approvedAt, requestedRestoreKind) {
|
|
10190
11593
|
const hasModel = exportsHasModel;
|
|
10191
11594
|
// An explicit kind says "put them back on the button they pressed" — but only if they are still
|
|
@@ -10242,6 +11645,7 @@
|
|
|
10242
11645
|
// caption. The note's job — per the comment above — is to justify the exports-FOLDER button
|
|
10243
11646
|
// staying enabled, not to claim the export actions work unapproved. "Polishing is optional" was
|
|
10244
11647
|
// the true and useful half, and it survives; only the opening clause overreached.
|
|
11648
|
+
html += exportsAssumptionsHtml();
|
|
10245
11649
|
html += `<div class="exports-note"><b>Any saved source can be exported</b> — approved is the safe default, while DRAFT and older versions stay explicit. Polishing further ` +
|
|
10246
11650
|
`is optional. Each writes to this project’s <button type="button" class="exports-note-link" data-open-exports-folder ` +
|
|
10247
11651
|
`aria-label="Open the exports folder" data-tip="Open this project’s exports folder">▤ exports</button> folder.</div>`;
|
|
@@ -10489,6 +11893,7 @@
|
|
|
10489
11893
|
if (exportsHasModel !== paintedWith) paintExports(current.approvedAt, restoreKind);
|
|
10490
11894
|
let state = null;
|
|
10491
11895
|
let units = null; // the server's answer, applied below the staleness guard with the others
|
|
11896
|
+
let filesFrom = null; // #2449: the approved version the listed files came from, same rule
|
|
10492
11897
|
// SAYS THE THING THE GUARD MEANS. `if (units)` was correct only because the ternary above can
|
|
10493
11898
|
// never produce a falsy value — so a later, entirely reasonable "report what the server actually
|
|
10494
11899
|
// said, stop coercing" change to `units = r.units` would silently re-enable the resurrected-
|
|
@@ -10576,6 +11981,7 @@
|
|
|
10576
11981
|
// there for why.
|
|
10577
11982
|
answered = true;
|
|
10578
11983
|
approvedAt = r.approvedAt || undefined;
|
|
11984
|
+
filesFrom = r.receiptsFrom && Number.isInteger(r.receiptsFrom.version) && typeof r.receiptsFrom.hash === 'string' ? r.receiptsFrom : null;
|
|
10579
11985
|
units = r.units === 'mm' ? 'mm' : 'ft-in';
|
|
10580
11986
|
} else {
|
|
10581
11987
|
// Surface the load failure — don't let it read as "nothing exported yet" (a lie).
|
|
@@ -10604,6 +12010,7 @@
|
|
|
10604
12010
|
// on failure; moving this line below the guard dropped its `if` by accident. (Review round 3.)
|
|
10605
12011
|
if (answered) current.approvedAt = approvedAt;
|
|
10606
12012
|
exportState = state;
|
|
12013
|
+
exportStateFrom = answered ? filesFrom : null;
|
|
10607
12014
|
syncWorkspaceGuide(); // fresh approve/export state → tick the Export (and re-sync Approve) guide rows
|
|
10608
12015
|
paintExports(approvedAt, restoreKind);
|
|
10609
12016
|
}
|
|
@@ -11310,6 +12717,23 @@
|
|
|
11310
12717
|
revBaseVersion = (req && typeof req.baseVersion === 'number') ? req.baseVersion : 0;
|
|
11311
12718
|
revBaseProject = proj.id; // the baseline belongs to THIS project — see resetRevisionState
|
|
11312
12719
|
showToast(`${revBaseVersion <= 0 ? 'Initial' : 'Revised'} set queued — ${files.length} file${files.length > 1 ? 's' : ''} for your terminal AI`, 'ok');
|
|
12720
|
+
// #2399 slice 0c: the drawings also land in the project's design set as an issue. Said either way, never silent.
|
|
12721
|
+
const landed = res && res.designSet;
|
|
12722
|
+
if (landed && landed.landed && landed.created) {
|
|
12723
|
+
const left = Array.isArray(landed.omitted) ? landed.omitted.length : 0;
|
|
12724
|
+
showToast(`Added to the design set as “${landed.label || 'a new issue'}”${left ? `, without ${left} file${left === 1 ? '' : 's'} Knowledge could not store` : ''}`, left ? 'warn' : 'ok', { action: { label: 'View', commandId: 'shell.kb-design-set-view',
|
|
12725
|
+
onClick: () => { if (current === proj) setStep('knowledge'); } } });
|
|
12726
|
+
} else if (landed && !landed.landed) {
|
|
12727
|
+
showToast('These drawings are not in the design set yet. The read goes ahead.', 'warn', { action: { label: 'Add them', commandId: 'shell.kb-design-set-land',
|
|
12728
|
+
onClick: async () => {
|
|
12729
|
+
try {
|
|
12730
|
+
const out = await api(`/api/projects/${encodeURIComponent(proj.id)}/design-set/issues/from-read`, { method: 'POST', body: JSON.stringify({ requestId: req.id }) });
|
|
12731
|
+
const skipped = Array.isArray(out && out.omitted) ? out.omitted.length : 0;
|
|
12732
|
+
showToast(`Added to the design set${out && out.label ? ` as “${out.label}”` : ''}${skipped ? `, without ${skipped} file${skipped === 1 ? '' : 's'} it could not store` : ''}`, skipped ? 'warn' : 'ok');
|
|
12733
|
+
if (current === proj) { kbInvalidateRefs(); renderKnowledge(); }
|
|
12734
|
+
} catch (err) { showToast((err && err.body && err.body.error) || 'Couldn’t add them to the design set. Add them from Knowledge.', 'warn'); }
|
|
12735
|
+
} } });
|
|
12736
|
+
}
|
|
11313
12737
|
lastRevState = 'pending';
|
|
11314
12738
|
startRevisionPoll();
|
|
11315
12739
|
renderRevisionCard();
|
|
@@ -11603,7 +13027,7 @@
|
|
|
11603
13027
|
// Bounded (#1604): the poll skips its ticks while this is out, so a read that never answered
|
|
11604
13028
|
// would stop the card for good. 90 s, like the Requests window: the route's own lock waits
|
|
11605
13029
|
// give up after 60 s.
|
|
11606
|
-
const b = await api('/api/requests', {
|
|
13030
|
+
const b = await api('/api/requests', { timeoutMs: 90_000 });
|
|
11607
13031
|
reqs = Array.isArray(b) ? b : (b.requests || []);
|
|
11608
13032
|
// Every owned success is fresh evidence of server contact, even if a later-started poll is in
|
|
11609
13033
|
// flight or has failed. The route can legitimately outlast the 3-second polling interval.
|
|
@@ -12045,7 +13469,10 @@
|
|
|
12045
13469
|
const isAnsweredZ = (z) => !!z && typeof z === 'object' && !!z.answered && typeof z.answered === 'object' && typeof z.known === 'number';
|
|
12046
13470
|
const endpointHeightText = (z) => {
|
|
12047
13471
|
if (!z || typeof z.known !== 'number') return 'no height';
|
|
12048
|
-
|
|
13472
|
+
// #2521: a height the AI chose in a Quick model build is said as such, never shown as a plain drawn height.
|
|
13473
|
+
const tail = z.assumed === true ? ' (placed, not from the drawings)'
|
|
13474
|
+
: z.decided && typeof z.decided === 'object' ? ' (chosen by the AI in the Quick model, not from the drawings)' : '';
|
|
13475
|
+
return `${reviewElevation(z.known)}${tail}`;
|
|
12049
13476
|
};
|
|
12050
13477
|
const endWordOf = (key) => (key === 'from' ? 'Start' : 'End');
|
|
12051
13478
|
function plainLine(key, before, after) {
|
|
@@ -12776,7 +14203,7 @@
|
|
|
12776
14203
|
if (!props.length && !binds.length) {
|
|
12777
14204
|
// No disabled control standing in for an empty state — the group simply is not rendered.
|
|
12778
14205
|
body.appendChild(revEl('div', 'hd-empty', issues.length
|
|
12779
|
-
? '
|
|
14206
|
+
? 'This read found changes needing attention. The affected values were kept; review the details below.'
|
|
12780
14207
|
: leftOut.length
|
|
12781
14208
|
? 'Nothing needs your decision. What this read found is listed below with what was left out and why.'
|
|
12782
14209
|
: 'This read found no changes to make — the revised set matches what is already in the model.'));
|
|
@@ -12814,11 +14241,12 @@
|
|
|
12814
14241
|
const sum = document.createElement('summary');
|
|
12815
14242
|
sum.className = 'ws-archived-summary';
|
|
12816
14243
|
sum.appendChild(revEl('span', 'ws-archived-caret', '›'));
|
|
12817
|
-
sum.appendChild(document.createTextNode('
|
|
14244
|
+
sum.appendChild(document.createTextNode('Changes needing attention '));
|
|
12818
14245
|
sum.appendChild(revEl('span', 'ws-archived-count', String(issues.length)));
|
|
12819
14246
|
det.appendChild(sum);
|
|
14247
|
+
det.appendChild(revEl('div', 'rev-issue', 'The changes listed here were not applied. The existing values for these items were kept. You can continue with those values, ask the terminal AI to correct the read, or ask it to raise an RFI.'));
|
|
12820
14248
|
for (const it of issues) {
|
|
12821
|
-
const row = revEl('div', 'rev-issue', it.message || it.code || '
|
|
14249
|
+
const row = revEl('div', 'rev-issue', it.message || it.code || 'This item needs attention.');
|
|
12822
14250
|
row.appendChild(revEl('span', 'rev-issue-path', it.path || ''));
|
|
12823
14251
|
det.appendChild(row);
|
|
12824
14252
|
}
|
|
@@ -13614,7 +15042,7 @@
|
|
|
13614
15042
|
'data-tip="Show the complete member-by-member comparison">' +
|
|
13615
15043
|
'<span class="hd-caret">▸</span><span class="hd-toggle-label">View detailed changes</span></button>'
|
|
13616
15044
|
: '';
|
|
13617
|
-
const detailWarning = `${acceptedImportFindingsHtml(v)}${readinessHtml(v)}${detailReconciliationWarningHtml(v)}${shellAuthoredNoteHtml(v)}`;
|
|
15045
|
+
const detailWarning = `${acceptedImportFindingsHtml(v)}${connectionAssumptionsHtml(v)}${readinessHtml(v)}${detailReconciliationWarningHtml(v)}${shellAuthoredNoteHtml(v)}${designIssueNoteHtml(v)}`;
|
|
13618
15046
|
if (!s || !Array.isArray(s.bullets)) {
|
|
13619
15047
|
return `<div class="hist-event">${escapeHtml(v.message)}</div>${detailWarning}${toggle}`;
|
|
13620
15048
|
}
|
|
@@ -13629,6 +15057,29 @@
|
|
|
13629
15057
|
`<ul class="hist-change-list">${bullets}</ul>${cautions}${detailWarning}${toggle}`;
|
|
13630
15058
|
}
|
|
13631
15059
|
|
|
15060
|
+
/**
|
|
15061
|
+
* #2399 slice 0c (plan R4, R17): a version a drawing read made says which design-set issue it read and what it left
|
|
15062
|
+
* out — kept on the version, so it holds after the read's request is gone. A read whose drawings are in no issue offers
|
|
15063
|
+
* to add them; the server answers with the existing issue if they are already there.
|
|
15064
|
+
*/
|
|
15065
|
+
function designIssueNoteHtml(v) {
|
|
15066
|
+
if (!v || v.kind !== 'revision-read' || !v.source || !Array.isArray(v.source.files) || !v.source.files.length) return '';
|
|
15067
|
+
const d = v.source.designIssue;
|
|
15068
|
+
const n = escapeAttr(String(v.n));
|
|
15069
|
+
if (!d || typeof d.issueId !== 'string') {
|
|
15070
|
+
return '<div class="hist-ds-line"><button type="button" class="btn-mini" ' +
|
|
15071
|
+
`data-hist-ds-land="${n}" data-command-id="shell.history-design-set-land#v${escapeAttr(String(v.n))}" data-tip="Add the drawings this read was given to the project's design set, as an issue">Add these drawings to the design set</button></div>`;
|
|
15072
|
+
}
|
|
15073
|
+
const omitted = Array.isArray(d.omitted) ? d.omitted.filter((o) => o && typeof o.filename === 'string') : [];
|
|
15074
|
+
const covered = Array.isArray(d.included) ? d.included.length : null;
|
|
15075
|
+
if (!omitted.length) {
|
|
15076
|
+
return `<div class="hist-change-note" role="note">${escapeHtml(`Read from a design-set issue${covered !== null ? `: ${covered} file${covered === 1 ? '' : 's'}` : ''}.`)}</div>`;
|
|
15077
|
+
}
|
|
15078
|
+
const names = omitted.slice(0, 5).map((o) => `“${o.filename}”`).join(', ') + (omitted.length > 5 ? ` and ${omitted.length - 5} more` : '');
|
|
15079
|
+
return '<div class="hist-change-caution" role="note"><strong>Read from part of a design-set issue.</strong> ' +
|
|
15080
|
+
escapeHtml(`${covered !== null ? `${covered} of its files were read; ` : ''}${omitted.length} ${omitted.length === 1 ? 'was' : 'were'} left out: ${names}.`) + '</div>';
|
|
15081
|
+
}
|
|
15082
|
+
|
|
13632
15083
|
/**
|
|
13633
15084
|
* #1840: an approval that accepted open Tekla import findings carries the server's own sentence on
|
|
13634
15085
|
* its History row (one source for every approved surface), in the caution register the readiness
|
|
@@ -13640,6 +15091,20 @@
|
|
|
13640
15091
|
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>`;
|
|
13641
15092
|
}
|
|
13642
15093
|
|
|
15094
|
+
/**
|
|
15095
|
+
* #2449: the connection assumptions this approved version rests on, frozen when it was approved. Each one's own words,
|
|
15096
|
+
* what it is about, and who confirmed it; a later record or withdraw never changes what an earlier version says here.
|
|
15097
|
+
*/
|
|
15098
|
+
function connectionAssumptionsHtml(v) {
|
|
15099
|
+
const a = v && v.kind === 'approve' && v.connectionAssumptions && typeof v.connectionAssumptions.note === 'string' ? v.connectionAssumptions : null;
|
|
15100
|
+
if (!a) return '';
|
|
15101
|
+
const entries = a.state === 'recorded' && Array.isArray(a.entries) ? a.entries : [];
|
|
15102
|
+
// Every one, never "N more" pointing elsewhere: nothing else shows this version's frozen list (the readiness review
|
|
15103
|
+
// shows the current model's), and the list is bounded by the store (ten per connection).
|
|
15104
|
+
const items = entries.map((e) => `<li>“${escapeHtml(String(e.statement || ''))}” <span class="hist-assumption-about">About ${escapeHtml(String(e.readingText || ''))} (${escapeHtml(String(e.jointId || ''))})</span></li>`).join('');
|
|
15105
|
+
return `<div class="hist-change-caution hist-assumptions" role="note"><strong>${escapeHtml(a.note)}</strong>${items ? `<ul>${items}</ul>` : ''}</div>`;
|
|
15106
|
+
}
|
|
15107
|
+
|
|
13643
15108
|
function readinessHtml(v) {
|
|
13644
15109
|
const ready = v && v.readiness;
|
|
13645
15110
|
if (!ready || typeof ready.state !== 'string') return '';
|
|
@@ -14527,6 +15992,24 @@
|
|
|
14527
15992
|
}
|
|
14528
15993
|
|
|
14529
15994
|
$wsHistory.addEventListener('click', (e) => {
|
|
15995
|
+
// #2399 slice 0c: add the drawings a read was given to the design set, after the fact (plan R4).
|
|
15996
|
+
const dsLand = e.target.closest('[data-hist-ds-land]');
|
|
15997
|
+
if (dsLand) {
|
|
15998
|
+
const proj = current;
|
|
15999
|
+
if (!proj) return;
|
|
16000
|
+
dsLand.setAttribute('aria-busy', 'true');
|
|
16001
|
+
api(`/api/projects/${encodeURIComponent(proj.id)}/design-set/issues/from-read`, { method: 'POST', body: JSON.stringify({ version: Number(dsLand.dataset.histDsLand) }) })
|
|
16002
|
+
.then((out) => {
|
|
16003
|
+
const skipped = Array.isArray(out && out.omitted) ? out.omitted.length : 0;
|
|
16004
|
+
showToast(out && out.created === false
|
|
16005
|
+
? `These drawings are already in the design set${out.label ? ` as “${out.label}”` : ''}`
|
|
16006
|
+
: `Added to the design set${out && out.label ? ` as “${out.label}”` : ''}${skipped ? `, without ${skipped} file${skipped === 1 ? '' : 's'} it could not store` : ''}`, skipped ? 'warn' : 'ok');
|
|
16007
|
+
if (current === proj) kbInvalidateRefs();
|
|
16008
|
+
})
|
|
16009
|
+
.catch((err) => showToast((err && err.body && typeof err.body.error === 'string' && err.body.error) || 'Couldn’t add these drawings to the design set. Try again.', 'warn'))
|
|
16010
|
+
.finally(() => dsLand.removeAttribute('aria-busy'));
|
|
16011
|
+
return;
|
|
16012
|
+
}
|
|
14530
16013
|
const note = e.target.closest('[data-revision-note]');
|
|
14531
16014
|
if (note) { editRevisionNote(Number(note.dataset.revisionNote)); return; }
|
|
14532
16015
|
const retryNote = e.target.closest('[data-revision-note-retry]');
|
|
@@ -14570,6 +16053,17 @@
|
|
|
14570
16053
|
return `<button class="menu-item" data-act="${action}" role="menuitem"><span class="menu-label">${escapeHtml(label)}</span></button>`;
|
|
14571
16054
|
}
|
|
14572
16055
|
function openProjMenu(id, anchor) {
|
|
16056
|
+
if (window.flolessWorkspaceRoot?.current()?.available === false) {
|
|
16057
|
+
const row = projects.find((project) => project.id === id);
|
|
16058
|
+
if (row?.registrationId) window.flolessProjectReconciliation?.openRegistration(row.registrationId);
|
|
16059
|
+
else window.flolessWorkspaceRoot.open();
|
|
16060
|
+
return;
|
|
16061
|
+
}
|
|
16062
|
+
const unavailable = projects.find((project) => project.id === id && project.registrationState === 'unavailable');
|
|
16063
|
+
if (unavailable?.registrationId) {
|
|
16064
|
+
window.flolessProjectReconciliation?.openRegistration(unavailable.registrationId);
|
|
16065
|
+
return;
|
|
16066
|
+
}
|
|
14573
16067
|
menuFor = id;
|
|
14574
16068
|
// An explicit popup wins over the passive fullscreen suggestion. The app-shell listener removes
|
|
14575
16069
|
// the nudge synchronously without persisting its seen key, before this menu can receive a click.
|
|
@@ -15122,11 +16616,13 @@
|
|
|
15122
16616
|
// marker (.wf-option.selected in app.css) actually shows — mirrors the workflow picker (aware.js).
|
|
15123
16617
|
// It matters more now the action icons are gone: without it the open row is visually unmarked.
|
|
15124
16618
|
const here = current && current.id === p.id;
|
|
15125
|
-
return `<div class="wf-option${here ? ' selected' : ''}" role="option" id="ws-proj-opt-${pid}" data-id="${pid}" data-search="${escapeAttr((p.name + ' ' + displayApp + ' ' + p.app).toLowerCase())}" tabindex="-1" aria-selected="${here ? 'true' : 'false'}">`
|
|
16619
|
+
return `<div class="wf-option${here ? ' selected' : ''}" role="option" id="ws-proj-opt-${pid}" data-id="${pid}"${p.registrationId ? ` data-registration-id="${escapeAttr(p.registrationId)}"` : ''} data-search="${escapeAttr((p.name + ' ' + displayApp + ' ' + p.app).toLowerCase())}" tabindex="-1" aria-selected="${here ? 'true' : 'false'}">`
|
|
15126
16620
|
+ `<span class="wf-option-name">${escapeHtml(p.name)}</span><span class="wf-option-meta">${meta}</span></div>`;
|
|
15127
16621
|
}).join('');
|
|
15128
16622
|
html += `<div class="wf-empty-search" hidden>No projects match '<span class="wf-empty-term"></span>'</div>`;
|
|
15129
16623
|
$projList.innerHTML = html;
|
|
16624
|
+
registeredPickerRows.clear();
|
|
16625
|
+
for (const row of $projList.querySelectorAll('[data-registration-id]')) registeredPickerRows.set(row.dataset.registrationId, row);
|
|
15130
16626
|
}
|
|
15131
16627
|
function projComboVisible() { return [...$projList.querySelectorAll('.wf-option')].filter((o) => !o.hidden); }
|
|
15132
16628
|
function projComboClearHighlight() {
|
|
@@ -15249,6 +16745,165 @@
|
|
|
15249
16745
|
if (current?.id !== projectId) throw new Error('That project could not be opened. Open it from Workspaces.');
|
|
15250
16746
|
}
|
|
15251
16747
|
|
|
16748
|
+
// The Drawing Filter step of a project, where a drawing read's exclusions are saved and signed off.
|
|
16749
|
+
async function openDrawingsStep(projectId) {
|
|
16750
|
+
if (typeof projectId !== 'string' || !projectId) throw new Error('That project could not be opened. Open it from Workspaces.');
|
|
16751
|
+
await setMode('workspaces');
|
|
16752
|
+
const opened = await openProject(projectId, 'drawings');
|
|
16753
|
+
if (opened === STAYED_IN_PROJECT) throw new Error('You stayed in this project, so the other one was not opened.');
|
|
16754
|
+
if (current?.id !== projectId) throw new Error('That project could not be opened. Open it from Workspaces.');
|
|
16755
|
+
}
|
|
16756
|
+
|
|
16757
|
+
/**
|
|
16758
|
+
* Show one connection in a project's model editor, selected and framed (#2450 — the readiness card's
|
|
16759
|
+
* "Open in the model"). The editor does the selecting (`flolessEditorFocus`, steel-editor.html); this
|
|
16760
|
+
* only gets the person to the right editor and hands the request over.
|
|
16761
|
+
*
|
|
16762
|
+
* ONE SLOT, the latest request. A new call takes it, and the request it replaces is withdrawn from the
|
|
16763
|
+
* editor it was handed to BY ITS ID, so a withdrawal can never cancel the request that replaced it.
|
|
16764
|
+
* No call ever waits on another call: an earlier call's project change still in progress gives way
|
|
16765
|
+
* (`openProject`'s `stillWanted`) before it changes anything.
|
|
16766
|
+
*
|
|
16767
|
+
* The project already open stays open: `openProject` resets the frames, which would reload the editor
|
|
16768
|
+
* and could cost edits not yet saved, so the same project only switches to its Model step. Another
|
|
16769
|
+
* project goes through `openProject`, and its leave guard. Then it waits for the editor page of THIS
|
|
16770
|
+
* project to exist and hands the request over; the editor holds it until its model is ready.
|
|
16771
|
+
*
|
|
16772
|
+
* Every wait is watched. Getting there ends on a later click; the project open also has a generous
|
|
16773
|
+
* bound and gives way once this call has ended. The mode switch has no bound: it waits only while the
|
|
16774
|
+
* person answers a question, and cannot be called back. Then,
|
|
16775
|
+
* before and after the hand-over: a later call, leaving Workspaces, another project, the Model step
|
|
16776
|
+
* closed and not about to open, a reload of the frame (its document changes; its window does not), or
|
|
16777
|
+
* the editor's deadline. Whenever this stops waiting without the editor's answer, the request is withdrawn from
|
|
16778
|
+
* the editor, so it never selects anything after the person was told it was not shown.
|
|
16779
|
+
*
|
|
16780
|
+
* Resolves the editor's own outcome — `{ok:true}`, `{ok:true,fallback,said}` when it landed on the
|
|
16781
|
+
* main member instead, `{ok:false,said?}` — or `{superseded:true}` when a later call took over. What
|
|
16782
|
+
* cannot be done is thrown as a sentence written for the person (`plain`).
|
|
16783
|
+
*/
|
|
16784
|
+
const CONNECTION_FRAME_WAIT_MS = 60000;
|
|
16785
|
+
// Getting to the project can include the person answering a "leave unsaved changes?" question, so it
|
|
16786
|
+
// is bounded generously; a later click frees it at once either way.
|
|
16787
|
+
const CONNECTION_NAVIGATION_WAIT_MS = 300000;
|
|
16788
|
+
let connectionRequestSeq = 0;
|
|
16789
|
+
/** The latest request: `{ id, page }`, `page` being the editor window it was handed to, once it was. */
|
|
16790
|
+
let connectionRequest = null;
|
|
16791
|
+
// Every sentence this throws is written for the person; `plain` tells the caller it may show it as is.
|
|
16792
|
+
const connectionError = (sentence) => Object.assign(new Error(sentence), { plain: true });
|
|
16793
|
+
/** Withdraw a request from the editor it was handed to, by its id. Harmless when that editor has moved on. */
|
|
16794
|
+
const withdrawConnectionRequest = (request) => {
|
|
16795
|
+
try { request?.page?.flolessEditorFocusCancel?.(request.id); } catch { /* that page is gone */ }
|
|
16796
|
+
};
|
|
16797
|
+
async function openConnection(target) {
|
|
16798
|
+
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
16799
|
+
if (!target || !validId(target.projectId) || !validId(target.jointId)) throw connectionError('That connection could not be opened. Open its project from Workspaces.');
|
|
16800
|
+
const mine = { id: `connection-${++connectionRequestSeq}`, page: null };
|
|
16801
|
+
withdrawConnectionRequest(connectionRequest);
|
|
16802
|
+
connectionRequest = mine;
|
|
16803
|
+
const superseded = () => connectionRequest !== mine;
|
|
16804
|
+
// Once this call has ended, for any reason, a project change it started gives way before it lands.
|
|
16805
|
+
let ended = false;
|
|
16806
|
+
const stillWanted = () => !ended && !superseded();
|
|
16807
|
+
const stayedOutside = () => connectionError('You stayed where you were, so the connection was not shown. Open the project from Workspaces, then press Open in the model again.');
|
|
16808
|
+
const leftWorkspaces = () => connectionError('You left Workspaces, so the connection was not shown. Open the project from Workspaces, then press Open in the model again.');
|
|
16809
|
+
const pause = () => new Promise((resolve) => setTimeout(resolve, 100));
|
|
16810
|
+
/**
|
|
16811
|
+
* Wait for a step of getting there, watched: a later click ends it at once. `bounded` adds the deadline,
|
|
16812
|
+
* for a step whose late arrival can be refused (`openProject` gives way through `stillWanted`). The mode
|
|
16813
|
+
* switch is never bounded: it only waits while the person answers a question (an Agent's unsaved
|
|
16814
|
+
* changes), and it cannot be called back, so a deadline there would say "not shown" and then switch.
|
|
16815
|
+
*/
|
|
16816
|
+
const navigating = async (work, bounded) => {
|
|
16817
|
+
const bound = bounded ? Date.now() + CONNECTION_NAVIGATION_WAIT_MS : Infinity;
|
|
16818
|
+
let done = null;
|
|
16819
|
+
const finished = work.then((value) => { done = { value }; }, (error) => { done = { error }; });
|
|
16820
|
+
for (;;) {
|
|
16821
|
+
// Back the moment the step finishes, or on the next check, whichever comes first.
|
|
16822
|
+
await Promise.race([finished, pause()]);
|
|
16823
|
+
if (done) { if (done.error) throw done.error; return done.value; }
|
|
16824
|
+
if (superseded()) return { superseded: true };
|
|
16825
|
+
if (Date.now() >= bound) throw connectionError('The project did not open in time, so the connection was not shown. Open it from Workspaces, then press Open in the model again.');
|
|
16826
|
+
}
|
|
16827
|
+
};
|
|
16828
|
+
let until = Infinity;
|
|
16829
|
+
// Everything that ends this call's wait without the editor's answer.
|
|
16830
|
+
const interrupted = () => {
|
|
16831
|
+
if (superseded()) return { superseded: true };
|
|
16832
|
+
if (mode !== 'workspaces') throw leftWorkspaces();
|
|
16833
|
+
if (current?.id !== target.projectId) throw connectionError('You moved to another project, so the connection was not shown.');
|
|
16834
|
+
// The project's stages kept the Model step locked, or the person went to another step: the step's
|
|
16835
|
+
// own message says why, and there is nothing to wait for.
|
|
16836
|
+
if (currentStep !== 'model' && !(pendingPresenceStep && pendingPresenceStep.step === 'model')) {
|
|
16837
|
+
throw connectionError('The Model step is not open, so the connection was not shown. Open the Model step, then press Open in the model again.');
|
|
16838
|
+
}
|
|
16839
|
+
if (Date.now() >= until) throw connectionError('The model did not open in time, so the connection was not shown. Open the Model step, then press Open in the model again.');
|
|
16840
|
+
return null;
|
|
16841
|
+
};
|
|
16842
|
+
try {
|
|
16843
|
+
if ((await navigating(Promise.resolve(setMode('workspaces'))))?.superseded || superseded()) return { superseded: true };
|
|
16844
|
+
// setMode leaves the person where they were when they chose to stay (an Agent with unsaved changes).
|
|
16845
|
+
if (mode !== 'workspaces') throw stayedOutside();
|
|
16846
|
+
if (current?.id !== target.projectId) {
|
|
16847
|
+
const opened = await navigating(openProject(target.projectId, 'model', { stillWanted }), true);
|
|
16848
|
+
if (opened?.superseded || superseded()) return { superseded: true };
|
|
16849
|
+
// openProject answers "stayed" for several causes (the person chose to stay, the project's folder is
|
|
16850
|
+
// not available and its dialog is open, another navigation took over): say only what is certain.
|
|
16851
|
+
if (opened === STAYED_IN_PROJECT) throw connectionError('That project did not open, so the connection was not shown. Open it from Workspaces to see why, then press Open in the model again.');
|
|
16852
|
+
if (current?.id !== target.projectId) throw connectionError('That project could not be opened. Open it from Workspaces.');
|
|
16853
|
+
} else if (currentStep !== 'model') {
|
|
16854
|
+
setStep('model');
|
|
16855
|
+
}
|
|
16856
|
+
if (!frames.model.dataset.want) throw connectionError('This project has no model editor to show the connection in.');
|
|
16857
|
+
// The editor's deadline starts once the person is in the project.
|
|
16858
|
+
until = Date.now() + CONNECTION_FRAME_WAIT_MS;
|
|
16859
|
+
let answer = null, settled = null, page = null, doc = null;
|
|
16860
|
+
const notTaken = 'The model could not take the request. Press Open in the model again.';
|
|
16861
|
+
for (;;) {
|
|
16862
|
+
// An answer already in is the editor's account of what it did: once it has selected the connection,
|
|
16863
|
+
// leaving the step or the deadline passing does not make that untrue. Only a later click, another
|
|
16864
|
+
// project or a reload (a different page) stand between it and the person.
|
|
16865
|
+
if (settled) {
|
|
16866
|
+
if (superseded()) return { superseded: true };
|
|
16867
|
+
// The Model step may have been left after the selection, but not Workspaces: hidden, it shows nothing.
|
|
16868
|
+
if (mode !== 'workspaces') throw leftWorkspaces();
|
|
16869
|
+
if (current?.id !== target.projectId) throw connectionError('You moved to another project, so the connection was not shown.');
|
|
16870
|
+
if (frames.model.contentWindow !== page || page.document !== doc) throw connectionError('The model reloaded, so the connection was not shown. Press Open in the model again.');
|
|
16871
|
+
const outcome = settled.outcome;
|
|
16872
|
+
return outcome && typeof outcome === 'object' ? { ...outcome } : { ok: false, said: notTaken };
|
|
16873
|
+
}
|
|
16874
|
+
const stop = interrupted();
|
|
16875
|
+
if (stop) return stop;
|
|
16876
|
+
const child = frames.model.contentWindow;
|
|
16877
|
+
if (!answer) {
|
|
16878
|
+
const state = child && child.flolessEditorState;
|
|
16879
|
+
if (state && state.project === target.projectId && typeof child.flolessEditorFocus === 'function') {
|
|
16880
|
+
// The frame's window survives a reload; its DOCUMENT does not. That is what tells a reload apart.
|
|
16881
|
+
page = child; doc = child.document;
|
|
16882
|
+
answer = child.flolessEditorFocus({ jointId: target.jointId, requestId: mine.id,
|
|
16883
|
+
// #2450: the readiness card's "Raise an RFI" also opens the editor's review dialog for it.
|
|
16884
|
+
...(target.raiseRfi === true ? { raiseRfi: true } : {}), ...(validId(target.checkId) ? { checkId: target.checkId } : {}) });
|
|
16885
|
+
if (!answer || typeof answer.then !== 'function') return { ok: false, said: notTaken };
|
|
16886
|
+
mine.page = page;
|
|
16887
|
+
answer.then((outcome) => { settled = { outcome }; }, (error) => {
|
|
16888
|
+
console.error('[workspaces] the model editor could not answer for the connection', error);
|
|
16889
|
+
settled = { outcome: { ok: false, said: notTaken } };
|
|
16890
|
+
});
|
|
16891
|
+
}
|
|
16892
|
+
} else if (child !== page || child.document !== doc) {
|
|
16893
|
+
throw connectionError('The model reloaded, so the connection was not shown. Press Open in the model again.');
|
|
16894
|
+
}
|
|
16895
|
+
await pause();
|
|
16896
|
+
}
|
|
16897
|
+
} catch (error) {
|
|
16898
|
+
// This call ended without the editor's answer: whatever it handed over is withdrawn.
|
|
16899
|
+
if (!superseded()) withdrawConnectionRequest(mine);
|
|
16900
|
+
throw error;
|
|
16901
|
+
} finally {
|
|
16902
|
+
ended = true;
|
|
16903
|
+
if (connectionRequest === mine) connectionRequest = null;
|
|
16904
|
+
}
|
|
16905
|
+
}
|
|
16906
|
+
|
|
15252
16907
|
// A cross-project object pin still belongs to its original conversation, wherever its model is shown.
|
|
15253
16908
|
async function openChatOwner(owner) {
|
|
15254
16909
|
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
@@ -15298,10 +16953,160 @@
|
|
|
15298
16953
|
return Boolean(carrier);
|
|
15299
16954
|
}
|
|
15300
16955
|
|
|
16956
|
+
async function folderDecisionCompleted(result, operation) {
|
|
16957
|
+
const project = result.project;
|
|
16958
|
+
if (operation === 'import') {
|
|
16959
|
+
const toast = formatRfiTransferToast(result.rfiTransfer, 'import', project.name, result.appInstalled);
|
|
16960
|
+
const leftOut = importLeftOutNote(result.leftOut, project.name);
|
|
16961
|
+
showToast(toast.message + (leftOut ? ` ${leftOut}` : ''), leftOut ? 'warn' : toast.tone);
|
|
16962
|
+
} else showToast(`Project folder updated for “${project.name}”.`, 'ok');
|
|
16963
|
+
await loadProjects({ quiet: true });
|
|
16964
|
+
flashCard(project.id, { scroll: true });
|
|
16965
|
+
if (current?.id === project.id) reconcileNow();
|
|
16966
|
+
}
|
|
16967
|
+
/** The drop zone asks for the one click the browser needs, until it is used or left. Painted imperatively, so the
|
|
16968
|
+
* column's HTML cache is dropped on the way out and the next paint restores the zone's own words. */
|
|
16969
|
+
function kbDropAttention(drop) {
|
|
16970
|
+
drop.classList.add('attention');
|
|
16971
|
+
const dt = drop.querySelector('.dt'); if (dt) dt.textContent = 'Choose files';
|
|
16972
|
+
const ds = drop.querySelector('.ds'); if (ds) ds.textContent = 'Click here to pick the files to add';
|
|
16973
|
+
kbInvalidateRefs();
|
|
16974
|
+
const live = $wsKnowledge.querySelector('#kb-drop-live');
|
|
16975
|
+
if (live) live.textContent = 'Choose files is ready. Press it to pick the files to add.';
|
|
16976
|
+
drop.scrollIntoView({ block: 'nearest' });
|
|
16977
|
+
drop.focus();
|
|
16978
|
+
// Not on blur: the chat card that asked repaints right after and takes focus back. The zone keeps asking until the
|
|
16979
|
+
// person picks, or for a minute; a poll repaint in between restores its own words too (the cache was dropped).
|
|
16980
|
+
let timer = null;
|
|
16981
|
+
const done = () => {
|
|
16982
|
+
clearTimeout(timer); $wsKnowledgeFile.removeEventListener('change', done);
|
|
16983
|
+
if (live) live.textContent = '';
|
|
16984
|
+
if (knowledgeState && drop.isConnected) { kbInvalidateRefs(); paintKnowledge(knowledgeState); }
|
|
16985
|
+
};
|
|
16986
|
+
timer = setTimeout(done, 60_000);
|
|
16987
|
+
$wsKnowledgeFile.addEventListener('change', done);
|
|
16988
|
+
}
|
|
16989
|
+
|
|
16990
|
+
/**
|
|
16991
|
+
* #2399 slice 0b: a confirmed chat card to pick files. This window opens the project's Knowledge step and presses its own
|
|
16992
|
+
* drop zone, so the file dialog and the upload are the window's. The browser opens a file dialog only on a click of the
|
|
16993
|
+
* person's: when the confirm click is too long ago by now, the drop zone is left focused in front of them instead.
|
|
16994
|
+
* Resolves '' when the dialog was opened, or one plain sentence: why not, or what the person does next.
|
|
16995
|
+
*/
|
|
16996
|
+
async function knowledgePickStep(step) {
|
|
16997
|
+
const { projectId, projectUuid } = step || {};
|
|
16998
|
+
if (typeof projectId !== 'string' || !projectId) return 'FloLess could not tell which project this is for. Open it from Workspaces.';
|
|
16999
|
+
await setMode('workspaces');
|
|
17000
|
+
// Already in that project: switch step as a press on its Knowledge tab does. Re-opening a project that is open
|
|
17001
|
+
// left the step tabs showing the step it was on.
|
|
17002
|
+
if (current?.id === projectId) setStep('knowledge');
|
|
17003
|
+
else {
|
|
17004
|
+
const opened = await openProject(projectId, 'knowledge');
|
|
17005
|
+
if (opened === STAYED_IN_PROJECT) return 'You stayed in the project you were in, so the other one was not opened.';
|
|
17006
|
+
}
|
|
17007
|
+
if (current?.id !== projectId) return 'That project could not be opened. Open it from Workspaces.';
|
|
17008
|
+
// The card names the project's incarnation, or "(none)" for an older project that has none. A different one is a
|
|
17009
|
+
// replaced project; with none on either side FloLess cannot tell, so the person picks from the step they can see.
|
|
17010
|
+
const cardUuid = typeof projectUuid === 'string' && projectUuid ? projectUuid : '(none)';
|
|
17011
|
+
const hereUuid = current.uuid || '(none)';
|
|
17012
|
+
if (cardUuid !== hereUuid) return 'This project was replaced since the card was made, so nothing was opened. Ask again for the project as it is now.';
|
|
17013
|
+
const unverified = cardUuid === '(none)';
|
|
17014
|
+
// The step paints its column on its own; wait briefly for the drop zone it draws.
|
|
17015
|
+
let drop = null;
|
|
17016
|
+
for (let i = 0; i < 40 && !(drop = $wsKnowledge.querySelector('#kb-drop')); i += 1) await new Promise((r) => setTimeout(r, 50));
|
|
17017
|
+
if (!drop || current?.id !== projectId) return 'The project’s Knowledge step did not open. Open the project and use Drop references there.';
|
|
17018
|
+
if (unverified || (navigator.userActivation && !navigator.userActivation.isActive)) {
|
|
17019
|
+
kbDropAttention(drop);
|
|
17020
|
+
return 'Choose files is ready in this project’s Knowledge step. Press it to pick the files.';
|
|
17021
|
+
}
|
|
17022
|
+
$wsKnowledgeFile.click();
|
|
17023
|
+
return '';
|
|
17024
|
+
}
|
|
17025
|
+
|
|
17026
|
+
/**
|
|
17027
|
+
* #2363: a confirmed chat card for a model source. This window opens the project and presses the Source step's own
|
|
17028
|
+
* Replace, Try again or Cancel control, so the real call (and the file picker) are the window's, with its editor session.
|
|
17029
|
+
* Resolves '' when it pressed the control, or one plain sentence: why it could not, or what the person does next.
|
|
17030
|
+
*/
|
|
17031
|
+
async function modelSourceStep(step) {
|
|
17032
|
+
const { verb, importer, projectId, operationId } = step || {};
|
|
17033
|
+
if (typeof projectId !== 'string' || !projectId || !['replace', 'retry', 'cancel'].includes(verb)) return 'FloLess could not tell which project this is for. Open it from Workspaces.';
|
|
17034
|
+
await setMode('workspaces');
|
|
17035
|
+
// The Source step is where the controls are; the project's default step is the Model tab, which hides them.
|
|
17036
|
+
const opened = await openProject(projectId, 'drawings');
|
|
17037
|
+
if (opened === STAYED_IN_PROJECT) return 'You stayed in the project you were in, so the other one was not opened.';
|
|
17038
|
+
if (current?.id !== projectId) return 'That project could not be opened. Open it from Workspaces.';
|
|
17039
|
+
if (!isModelSourceProject(current)) return 'This project does not read a Revit or Tekla model, so it has no model source to change.';
|
|
17040
|
+
const tekla = isTeklaParserProject(current);
|
|
17041
|
+
if (tekla !== (importer === 'tekla')) return `This project reads a ${tekla ? 'Tekla' : 'Revit'} model, not a ${importer === 'tekla' ? 'Tekla' : 'Revit'} one, so nothing was done. Ask again for the right project.`;
|
|
17042
|
+
// A state that could not be read says nothing about the project: never press a control on what an earlier project left.
|
|
17043
|
+
const source = await refreshRevitSourceState(projectId);
|
|
17044
|
+
if (current?.id !== projectId) return 'That project could not be opened. Open it from Workspaces.';
|
|
17045
|
+
if (!source) return 'FloLess could not read this project’s model source just now, so it did nothing. Check the project’s Source step.';
|
|
17046
|
+
const running = revitActiveOperation && !['ready', 'failed', 'cancelled'].includes(revitActiveOperation.state);
|
|
17047
|
+
// A Tekla folder or ZIP still being copied has no import yet; its own Cancel read stops the copy.
|
|
17048
|
+
const copying = tekla && !!teklaUploadAbort && teklaUploadProjectId === projectId;
|
|
17049
|
+
if (verb === 'replace') {
|
|
17050
|
+
if (running || copying) return 'An import is still running for this project, so its source cannot be replaced yet. Wait for it, or cancel it first.';
|
|
17051
|
+
if (!source.canReplace || $revitReplace.hidden) return 'This project’s model source cannot be replaced from here right now. Its Source step says why.';
|
|
17052
|
+
// A Revit file is chosen in the browser's own picker, which opens only on a click of the person's.
|
|
17053
|
+
// The confirm click may be too long ago by now; the Replace control is then left in front for them.
|
|
17054
|
+
if (!tekla && navigator.userActivation && !navigator.userActivation.isActive) {
|
|
17055
|
+
$revitReplace.scrollIntoView({ block: 'center' }); $revitReplace.focus();
|
|
17056
|
+
return `${$revitReplace.textContent || 'Replace RVT…'} is ready on this project. Press it to choose the file.`;
|
|
17057
|
+
}
|
|
17058
|
+
$revitReplace.click();
|
|
17059
|
+
return '';
|
|
17060
|
+
}
|
|
17061
|
+
if (copying && verb === 'cancel') return 'The Tekla source is still being copied, which this card cannot cancel. Press Cancel read on the project’s Source step.';
|
|
17062
|
+
const here = revitActiveOperation?.operationId;
|
|
17063
|
+
if (typeof operationId === 'string' && operationId && here !== operationId) {
|
|
17064
|
+
return verb === 'cancel'
|
|
17065
|
+
? 'That import has already finished or been replaced by a newer one, so nothing was cancelled. The project shows where it stands.'
|
|
17066
|
+
: 'That import is no longer the project’s latest, so nothing was retried. The project shows where it stands.';
|
|
17067
|
+
}
|
|
17068
|
+
// The controls answer by toast and repaint, not by a result: wait for the route's own answer to THIS press, for this project
|
|
17069
|
+
// and this import. Moving to another project, or the import ending some other way, is not a confirmation.
|
|
17070
|
+
const answered = async (verb, id) => {
|
|
17071
|
+
const end = Date.now() + 8000;
|
|
17072
|
+
while (Date.now() < end) {
|
|
17073
|
+
const o = sourceControlOutcome;
|
|
17074
|
+
if (o && o.verb === verb && o.projectId === projectId && o.operationId === id) return o.ok;
|
|
17075
|
+
if (current?.id !== projectId) return null;
|
|
17076
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
17077
|
+
}
|
|
17078
|
+
return null;
|
|
17079
|
+
};
|
|
17080
|
+
if (verb === 'cancel') {
|
|
17081
|
+
if (!running || $revitCancel.hidden) return 'Nothing is running to cancel any more. The project shows where it stands.';
|
|
17082
|
+
sourceControlOutcome = null;
|
|
17083
|
+
$revitCancel.click();
|
|
17084
|
+
const ok = await answered('cancel', here);
|
|
17085
|
+
return ok === true ? '' : ok === false ? 'The import was not cancelled: it may already be finishing. The project shows where it stands.'
|
|
17086
|
+
: 'Cancelling was asked for, but FloLess has not confirmed it yet. The project shows where it stands.';
|
|
17087
|
+
}
|
|
17088
|
+
if (tekla) return 'A Tekla read cannot be retried. Choose the Tekla source again from the project.';
|
|
17089
|
+
if (revitActiveOperation?.state !== 'failed' || $revitRetry.hidden) return 'This import did not fail, or it cannot be retried. The project shows where it stands.';
|
|
17090
|
+
sourceControlOutcome = null;
|
|
17091
|
+
$revitRetry.click();
|
|
17092
|
+
const ok = await answered('retry', here);
|
|
17093
|
+
return ok === true ? '' : ok === false ? 'The import was not started again. The project shows what went wrong.'
|
|
17094
|
+
: 'Trying again was asked for, but FloLess has not confirmed it yet. The project shows where it stands.';
|
|
17095
|
+
}
|
|
17096
|
+
|
|
15301
17097
|
window.flolessWorkspaces = {
|
|
17098
|
+
modelSourceStep,
|
|
17099
|
+
knowledgePickStep,
|
|
17100
|
+
// #2399 slice 0b: the open Knowledge step re-reads its project when something else changed it.
|
|
17101
|
+
knowledgeChanged: (projectId) => {
|
|
17102
|
+
if (current && current.id === projectId && !$wsKnowledge.hidden) renderKnowledge();
|
|
17103
|
+
tellModelFrame({ type: 'knowledge-changed', projectId });
|
|
17104
|
+
},
|
|
15302
17105
|
setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind,
|
|
15303
|
-
openHistory: wsOpenHistory, openKnowledgePage, openKnowledgeStep, drawingFilterCheckpointSaved,
|
|
15304
|
-
syncWorkspaceReporter, openChatOwner, openPagesHome,
|
|
17106
|
+
openHistory: wsOpenHistory, openKnowledgePage, openKnowledgeStep, openDrawingsStep, openConnection, drawingFilterCheckpointSaved,
|
|
17107
|
+
syncWorkspaceReporter, openChatOwner, openPagesHome, folderDecisionCompleted,
|
|
17108
|
+
// Project access (project-access.js loads after this file): the project open now, or null.
|
|
17109
|
+
currentProject: () => ($app.classList.contains('mode-workspaces') && current ? current : null),
|
|
15305
17110
|
};
|
|
15306
17111
|
applyMode(); // restore persisted mode immediately (matches panels.js applyView timing)
|
|
15307
17112
|
})();
|