@floless/app 0.156.0 → 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 +21 -5
- package/dist/floless-server.cjs +70965 -43326
- 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 +79 -17
- package/dist/skills/floless-app-knowledge/SKILL.md +21 -2
- package/dist/skills/floless-app-new-workflow/SKILL.md +23 -7
- package/dist/skills/floless-app-onboarding/SKILL.md +31 -1
- package/dist/skills/floless-app-report-issue/SKILL.md +3 -3
- package/dist/skills/floless-app-rfi/SKILL.md +40 -6
- package/dist/skills/floless-app-routines/SKILL.md +9 -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 +46 -10
- package/dist/skills/floless-app-workflows/references/agent-steps.md +119 -0
- package/dist/web/agent-steps.js +864 -47
- package/dist/web/agents.js +28 -8
- package/dist/web/app.css +478 -3
- package/dist/web/app.js +110 -11
- package/dist/web/aware-update-client.js +1 -0
- package/dist/web/aware.js +685 -170
- package/dist/web/chat-landing-scene.js +372 -0
- package/dist/web/chat.css +245 -1
- package/dist/web/chat.js +2466 -78
- package/dist/web/commands-drawing-check.js +17 -0
- package/dist/web/commands-shell.js +820 -3
- 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 +119 -6
- package/dist/web/instructor.js +3 -3
- package/dist/web/model-view-query.js +12 -2
- package/dist/web/pages.js +865 -34
- package/dist/web/panels.js +5 -2
- package/dist/web/parser-setup-recovery.js +12 -4
- package/dist/web/project-access.js +549 -0
- package/dist/web/report-files.js +50 -0
- 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 +59 -10
- package/dist/web/tool-updates.js +1 -0
- package/dist/web/workspace-root-management.js +39 -0
- package/dist/web/workspaces.js +1667 -63
- package/launch.mjs +9 -7
- 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
|
|
@@ -1073,6 +1107,8 @@
|
|
|
1073
1107
|
if (['ready', 'failed', 'not-applicable'].includes(coreDefaults)) missingCoreRoots.add(root);
|
|
1074
1108
|
}
|
|
1075
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']);
|
|
1076
1112
|
return Object.keys(WORKSPACE_APPS).filter((root) => byRoot.has(root)).map((root) => {
|
|
1077
1113
|
// Sorted, so which app a card targets is stable across loads rather than dependent on the
|
|
1078
1114
|
// order `aware app list` happened to return. The canonical install wins when present: it is
|
|
@@ -1122,6 +1158,11 @@
|
|
|
1122
1158
|
* still preliminary.
|
|
1123
1159
|
*/
|
|
1124
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 };
|
|
1125
1166
|
let exportsHasModel = false;
|
|
1126
1167
|
// A project may open on Model/Exports/History while its lifecycle probe is still in flight. Keep
|
|
1127
1168
|
// the most recently requested destination until the probe settles so the latest click counts.
|
|
@@ -1146,11 +1187,36 @@
|
|
|
1146
1187
|
|
|
1147
1188
|
function renderApprovalHeader() {
|
|
1148
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';
|
|
1149
1197
|
const s = approvalState;
|
|
1150
1198
|
let label = 'Review & approve';
|
|
1151
1199
|
let tip = APPROVE_TIP;
|
|
1152
1200
|
let unavailable = false;
|
|
1153
|
-
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') {
|
|
1154
1220
|
const tekla = isTeklaParserProject();
|
|
1155
1221
|
label = tekla ? 'Review after read' : 'Review after import';
|
|
1156
1222
|
tip = tekla
|
|
@@ -1446,6 +1512,7 @@
|
|
|
1446
1512
|
if (freshVisit) setLandingQuery('');
|
|
1447
1513
|
$project.hidden = !ws || !current;
|
|
1448
1514
|
$spine.hidden = !ws || !current;
|
|
1515
|
+
window.flolessProjectAccess?.setProject(ws && current ? current : null);
|
|
1449
1516
|
if (!ws && !$projMenu.hidden) closeProjMenu();
|
|
1450
1517
|
if (ws && !current) loadProjects();
|
|
1451
1518
|
// Name the tab after what's actually on screen. aware.js is the single writer of
|
|
@@ -1497,10 +1564,13 @@
|
|
|
1497
1564
|
}
|
|
1498
1565
|
if (opening) {
|
|
1499
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;
|
|
1500
1569
|
$workflowTab.innerHTML = '<span class="rtn-spinner" aria-hidden="true"></span><span>Opening Workflows…</span>';
|
|
1501
1570
|
} else {
|
|
1502
1571
|
$workflowTab.removeAttribute('aria-label');
|
|
1503
1572
|
$workflowTab.textContent = 'Workflows';
|
|
1573
|
+
if ($workflowTab.idleIcon) $workflowTab.prepend($workflowTab.idleIcon);
|
|
1504
1574
|
}
|
|
1505
1575
|
}
|
|
1506
1576
|
async function setMode(m) {
|
|
@@ -1526,7 +1596,11 @@
|
|
|
1526
1596
|
await bridge.refreshCurrentWorkflow();
|
|
1527
1597
|
} catch (error) {
|
|
1528
1598
|
if (sequence === modeChangeSequence) {
|
|
1529
|
-
|
|
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');
|
|
1530
1604
|
}
|
|
1531
1605
|
return;
|
|
1532
1606
|
} finally {
|
|
@@ -1867,7 +1941,26 @@
|
|
|
1867
1941
|
if (!$wsExports.hidden) safeRenderExports('after a units change');
|
|
1868
1942
|
});
|
|
1869
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
|
+
});
|
|
1870
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' });
|
|
1871
1964
|
const m = (e && e.detail) || {};
|
|
1872
1965
|
if (m.kind === 'metadata' && typeof m.registrationId === 'string') {
|
|
1873
1966
|
refreshRegisteredProject(m);
|
|
@@ -2427,6 +2520,7 @@
|
|
|
2427
2520
|
const createCommand = action.kind === 'tekla-source' ? 'data-command-id="shell.project-create-tekla-read" '
|
|
2428
2521
|
: action.kind === 'rvt' ? 'data-command-id="shell.project-create-revit-read" '
|
|
2429
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" '
|
|
2430
2524
|
: action.kind !== 'drawing' ? ''
|
|
2431
2525
|
: entry.templateId === 'steel-model' ? 'data-command-id="shell.project-create-steel-from-drawings" '
|
|
2432
2526
|
: entry.templateId === 'vectorize' ? 'data-command-id="shell.project-create-trace-from-drawing" '
|
|
@@ -2482,7 +2576,11 @@
|
|
|
2482
2576
|
*/
|
|
2483
2577
|
function thumbBandHtml(p, displayApp) {
|
|
2484
2578
|
const kind = `<span class="ws-kind">${escapeHtml(displayApp)}</span>`;
|
|
2485
|
-
|
|
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
|
+
}
|
|
2486
2584
|
return `<button type="button" class="ws-thumb" data-thumb="${escapeAttr(p.id)}" ` +
|
|
2487
2585
|
`aria-label="${escapeAttr(`View the thumbnail of “${p.name}” larger`)}" data-tip="View this thumbnail larger">` +
|
|
2488
2586
|
`<img alt="" loading="lazy">${kind}<span class="ws-thumb-expand" aria-hidden="true">⤢</span></button>`;
|
|
@@ -3168,6 +3266,9 @@
|
|
|
3168
3266
|
// their page counts and the proposed checklist can be shown. The setup dialog asks only the
|
|
3169
3267
|
// folder and the client's name.
|
|
3170
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 });
|
|
3171
3272
|
} else {
|
|
3172
3273
|
// Unreachable today, and it must not be SILENT the day it isn't: an unhandled kind still
|
|
3173
3274
|
// renders a full dashed, focusable card, so without this the first person to add one gets a
|
|
@@ -3357,11 +3458,13 @@
|
|
|
3357
3458
|
if (!project || !failedOperationId || isTeklaParserProject(project)) return;
|
|
3358
3459
|
try {
|
|
3359
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 };
|
|
3360
3462
|
revitActiveOperation = started.operation;
|
|
3361
3463
|
paintRevitSourceState('Replacing source RVT…', 'Reading the already stored RVT again…');
|
|
3362
3464
|
paintRevitSourceActions('active', true);
|
|
3363
3465
|
pollRevitImport(started.operation.operationId, project.id);
|
|
3364
3466
|
} catch (error) {
|
|
3467
|
+
sourceControlOutcome = { verb: 'retry', projectId: project.id, operationId: failedOperationId, ok: false };
|
|
3365
3468
|
paintRevitSourceState('Couldn’t retry the RVT', `${error && error.message || error} The existing model was not changed.`);
|
|
3366
3469
|
paintRevitSourceActions('failed', revitSourceState?.canReplace === true, revitActiveOperation?.failure?.retryable !== false, revitActiveOperation);
|
|
3367
3470
|
}
|
|
@@ -3380,11 +3483,13 @@
|
|
|
3380
3483
|
? `/api/tekla-imports/${encodeURIComponent(operationId)}/cancel`
|
|
3381
3484
|
: `/api/model-imports/${encodeURIComponent(operationId)}/cancel`;
|
|
3382
3485
|
await api(cancelPath, { method: 'POST', body: '{}' });
|
|
3486
|
+
sourceControlOutcome = { verb: 'cancel', projectId, operationId, ok: true };
|
|
3383
3487
|
revitActiveOperation = null;
|
|
3384
3488
|
paintRevitSourceState('Replacement cancelled', 'The existing model was not changed.');
|
|
3385
3489
|
paintRevitSourceActions('ready', true);
|
|
3386
3490
|
$revitReplace?.focus();
|
|
3387
3491
|
} catch (error) {
|
|
3492
|
+
sourceControlOutcome = { verb: 'cancel', projectId, operationId, ok: false };
|
|
3388
3493
|
const status = error && error.status;
|
|
3389
3494
|
showToast(status === 403
|
|
3390
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.`
|
|
@@ -3669,15 +3774,8 @@
|
|
|
3669
3774
|
const code = String(error && (error.code || error.body?.code) || '');
|
|
3670
3775
|
// Account access can expire while this dialog is open, before the folder chooser
|
|
3671
3776
|
// or project creation runs. Name that cause without blaming the selected folder.
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
if (access?.reason === 'session-expired') return 'Your FloLess sign-in has expired. Sign in again, then try again.';
|
|
3675
|
-
if (access?.reason === 'signed-out') return 'You are signed out of FloLess. Sign in again, then try again.';
|
|
3676
|
-
if (access?.reason === 'seat-taken') return 'Your FloLess session has ended. Sign in again, then try again.';
|
|
3677
|
-
if (access?.state === 'expired') return 'Your FloLess subscription has expired. Renew your subscription, then try again.';
|
|
3678
|
-
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.';
|
|
3679
|
-
return 'Sign in to FloLess to check your account access, then try again.';
|
|
3680
|
-
}
|
|
3777
|
+
const access = bridge.accountAccessText?.(error);
|
|
3778
|
+
if (access) return access;
|
|
3681
3779
|
// A setup refusal with no sentence for the person (#1965 review, round 3). The code covers several
|
|
3682
3780
|
// causes — the parser's setup has not finished, or a check refused this project while its card shows
|
|
3683
3781
|
// the ready state — so the sentence names none of them, only the card that shows what is left to do.
|
|
@@ -3747,7 +3845,9 @@
|
|
|
3747
3845
|
// never be the one shown as chosen and sent.
|
|
3748
3846
|
// Setup kinds that create a project only — no AI Chat intake, no drawing-intake task. The two model
|
|
3749
3847
|
// sources are read by FloLess itself; a Drawing Checker profile starts empty and is built on its page.
|
|
3750
|
-
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'];
|
|
3751
3851
|
function projectSetupProvider(state) {
|
|
3752
3852
|
if (!state || NO_CHAT_SETUP_KINDS.includes(state.kind)) return null;
|
|
3753
3853
|
const runtimes = bridge.chatProviderRuntimes?.() || [];
|
|
@@ -3873,6 +3973,10 @@
|
|
|
3873
3973
|
$projectSetupCreateOnly.classList.toggle('primary', !provider);
|
|
3874
3974
|
$projectSetupTitle.textContent = `New ${descDisplayName(state.templateId)} project`;
|
|
3875
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');
|
|
3876
3980
|
$projectSetupCreateOnly.textContent = state.busy ? 'Creating…' : (NO_CHAT_SETUP_KINDS.includes(state.kind) ? 'Create project' : 'Create project only');
|
|
3877
3981
|
$projectSetupSourceCount.textContent = state.files.length > 1 ? `+ ${state.files.length - 1} more` : '';
|
|
3878
3982
|
$projectSetupFolder.textContent = state.directory
|
|
@@ -4005,12 +4109,13 @@
|
|
|
4005
4109
|
await importTeklaIntoProject(project, state.teklaSource, state.appId);
|
|
4006
4110
|
return;
|
|
4007
4111
|
}
|
|
4008
|
-
if (state.kind === 'drawing-check-profile') {
|
|
4112
|
+
if (state.kind === 'drawing-check-profile' || state.kind === 'general-project') {
|
|
4009
4113
|
projects.unshift(project);
|
|
4010
4114
|
track('workspace_project_created', { app: state.appId });
|
|
4011
4115
|
setProjectSetupBusy(false);
|
|
4012
4116
|
closeProjectSetup({ restoreFocus: false });
|
|
4013
|
-
|
|
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');
|
|
4014
4119
|
return;
|
|
4015
4120
|
}
|
|
4016
4121
|
projects.unshift(project);
|
|
@@ -4099,8 +4204,8 @@
|
|
|
4099
4204
|
*/
|
|
4100
4205
|
async function createFromDrawing(appId, templateId, files, { kind = 'drawings', sourceLabel = '', teklaSource = null, returnFocus = null } = {}) {
|
|
4101
4206
|
if (!$projectSetup || projectSetupState) return false;
|
|
4102
|
-
// A Drawing Checker profile
|
|
4103
|
-
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;
|
|
4104
4209
|
if (kind === 'drawings' && files.length > 20) {
|
|
4105
4210
|
showToast('Choose up to 20 drawings for a new project.', 'warn');
|
|
4106
4211
|
return false;
|
|
@@ -4945,9 +5050,13 @@
|
|
|
4945
5050
|
const nav = opts || {};
|
|
4946
5051
|
// Latest navigation wins from the first line: an older open still waiting on a lookup must not replace a newer one.
|
|
4947
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());
|
|
4948
5057
|
let p = projects.find((x) => x.id === id);
|
|
4949
5058
|
if (!p) { try { p = (await api('/api/projects')).projects.find((x) => x.id === id); } catch { /* fall through */ } }
|
|
4950
|
-
if (
|
|
5059
|
+
if (unwanted()) return STAYED_IN_PROJECT;
|
|
4951
5060
|
if (!p) { showToast('Project not found — it may have been archived.', 'warn'); return loadProjects(); }
|
|
4952
5061
|
if (window.flolessWorkspaceRoot?.current()?.available === false) {
|
|
4953
5062
|
if (p.registrationId) window.flolessProjectReconciliation?.openRegistration(p.registrationId);
|
|
@@ -4971,7 +5080,7 @@
|
|
|
4971
5080
|
return;
|
|
4972
5081
|
}
|
|
4973
5082
|
if (!nav.skipLeaveGuard && current && current.id !== p.id && !(await leaveOpenProject(nav.returnFocus))) return STAYED_IN_PROJECT;
|
|
4974
|
-
if (
|
|
5083
|
+
if (unwanted()) return STAYED_IN_PROJECT;
|
|
4975
5084
|
if (current?.uuid !== p.uuid) revisionNoteEditorGeneration++;
|
|
4976
5085
|
current = p;
|
|
4977
5086
|
// #1890: a new workspace conversation suggests this project's units (the one opened last).
|
|
@@ -4988,6 +5097,7 @@
|
|
|
4988
5097
|
if (pendingPresenceToast) pendingPresenceToast();
|
|
4989
5098
|
pendingPresenceToast = null;
|
|
4990
5099
|
exportState = null;
|
|
5100
|
+
exportStateFrom = null;
|
|
4991
5101
|
exportUnits = null; // a new project's units arrive with its export listing; never inherit the last one's
|
|
4992
5102
|
renderReadinessState = null;
|
|
4993
5103
|
let sourceStateProbe = null;
|
|
@@ -5032,13 +5142,17 @@
|
|
|
5032
5142
|
// would open an empty pane, so it lands on its Checker step. Scoped to Drawing Checker on purpose:
|
|
5033
5143
|
// Revit and Tekla keep their existing behaviour for a carried-over step.
|
|
5034
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;
|
|
5035
5148
|
if ((d.filter || isModelSourceProject(p)) && ['model', 'exports', 'history'].includes(initialStep)) {
|
|
5036
5149
|
pendingPresenceStep = { projectId: p.id, step: initialStep };
|
|
5037
5150
|
}
|
|
5038
5151
|
// The LIVE app id, deliberately: the frames address the server with it (contract reads, saves),
|
|
5039
5152
|
// and after a rename only the live id resolves. Only the descriptor came from the lineage root.
|
|
5040
5153
|
const qs = `?app=${encodeURIComponent(p.app)}&project=${encodeURIComponent(p.id)}`;
|
|
5041
|
-
|
|
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}` : '';
|
|
5042
5156
|
frames.drawings.dataset.want = d.filter ? `${d.filter}${qs}` : '';
|
|
5043
5157
|
renderStepTabs(); // paint the tab labels for THIS app before the first step shows
|
|
5044
5158
|
disposeModelEditorFrame('project-open');
|
|
@@ -5126,6 +5240,7 @@
|
|
|
5126
5240
|
function applyModelPresence(present) {
|
|
5127
5241
|
projectContractLifecycle = present;
|
|
5128
5242
|
exportsHasModel = present === 'model';
|
|
5243
|
+
retrySourcelessPresence(present);
|
|
5129
5244
|
renderApprovalHeader();
|
|
5130
5245
|
applyStageGating();
|
|
5131
5246
|
// A lifecycle probe may resolve after the saved-filter card already painted under `unknown`.
|
|
@@ -5134,6 +5249,47 @@
|
|
|
5134
5249
|
if (currentStep === 'drawings' && lastRevState === 'pending') retireRevisionCardForStrip(revCardReq);
|
|
5135
5250
|
}
|
|
5136
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
|
+
|
|
5137
5293
|
/**
|
|
5138
5294
|
* Hand the saved-checkpoint status to the stage strip, which owns Done / Now / Next for it, and
|
|
5139
5295
|
* report whether the hand-off happened.
|
|
@@ -5206,6 +5362,7 @@
|
|
|
5206
5362
|
exportSourcesState = { status: 'unavailable', data: null, selected: null, open: false };
|
|
5207
5363
|
closeApprovalReview();
|
|
5208
5364
|
exportState = null;
|
|
5365
|
+
exportStateFrom = null;
|
|
5209
5366
|
exportUnits = null; // a new project's units arrive with its export listing; never inherit the last one's
|
|
5210
5367
|
renderReadinessState = null;
|
|
5211
5368
|
resetRevisionState();
|
|
@@ -5976,6 +6133,13 @@
|
|
|
5976
6133
|
const show = k === s && (k !== 'drawings' || drawingsHasFrame);
|
|
5977
6134
|
f.hidden = !show;
|
|
5978
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
|
+
}
|
|
5979
6143
|
}
|
|
5980
6144
|
if (window.flolessLeftPane) {
|
|
5981
6145
|
window.flolessLeftPane.setWorkspaceModelVisible(s === 'model');
|
|
@@ -6071,6 +6235,14 @@
|
|
|
6071
6235
|
|| !['clean', 'dirty', 'saving', 'error', 'conflict'].includes(message.state)) return;
|
|
6072
6236
|
modelContractSaveState = { projectId: current.id, appId: current.app, state: message.state, generation: message.generation };
|
|
6073
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
|
+
});
|
|
6074
6246
|
const approvalPhaseText = {
|
|
6075
6247
|
saving: 'Saving model edits…', comparing: 'Comparing changes…', approving: 'Approving and compiling…',
|
|
6076
6248
|
reconciling: 'Reconciling approval…', approved: 'Approved', failed: 'Nothing was approved.', stale: 'The review changed.',
|
|
@@ -6462,7 +6634,10 @@
|
|
|
6462
6634
|
const accepted = res && res.version && res.version.approval && res.version.approval.acceptedImportFindings;
|
|
6463
6635
|
const headline = accepted ? importFindingsCopy(accepted).approved(Number.isInteger(n) ? n : null)
|
|
6464
6636
|
: `Approved${Number.isInteger(n) ? ` as v${n}` : ''}.`;
|
|
6465
|
-
|
|
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');
|
|
6466
6641
|
track('workspace_project_approved', { app: project.app });
|
|
6467
6642
|
if (bridge.markWorkspaceApproved && wsDescOf(project)?.docGuide) bridge.markWorkspaceApproved(project.app);
|
|
6468
6643
|
if (!$wsExports.hidden) safeRenderExports('after approving this version');
|
|
@@ -6473,7 +6648,7 @@
|
|
|
6473
6648
|
: 'No changes remain pending.';
|
|
6474
6649
|
// The footer described the decision ("…will be approved…"); the decision has happened.
|
|
6475
6650
|
$approvalCounts.textContent = '';
|
|
6476
|
-
$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>`;
|
|
6477
6652
|
setApprovalPhase('approved', accepted ? headline : `Approved${Number.isInteger(n) ? ` as v${n}` : ''}`);
|
|
6478
6653
|
$approvalClose.focus();
|
|
6479
6654
|
}
|
|
@@ -6905,6 +7080,8 @@
|
|
|
6905
7080
|
});
|
|
6906
7081
|
$approveBtn?.addEventListener('click', () => {
|
|
6907
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;
|
|
6908
7085
|
// Re-ask only where the answer can differ. A failed probe can; so can `no-contract`, which stops
|
|
6909
7086
|
// being true the moment anything writes a model — and the writers we know about say so
|
|
6910
7087
|
// explicitly, but this is the backstop for the ones we do not (another tab, the terminal AI, a
|
|
@@ -7028,6 +7205,9 @@
|
|
|
7028
7205
|
let lastStepHeadHtml = null; // same repaint-iff-changed contract as lastRefsHtml
|
|
7029
7206
|
let lastViewKey = null; // identity of what the viewer host is currently showing
|
|
7030
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
|
|
7031
7211
|
let kbAdjustBusy = null; // project id of an in-flight Adjust submit (or null) — scoped to the
|
|
7032
7212
|
// project so switching away can't strand another project's box; also the
|
|
7033
7213
|
// re-entry guard (no duplicate queue). See kbAdjustActive.
|
|
@@ -7049,7 +7229,8 @@
|
|
|
7049
7229
|
* has a non-empty draft. Self-heals — the moment it's none of those, the next tick repaints fresh. */
|
|
7050
7230
|
function kbAdjustActive() {
|
|
7051
7231
|
if (kbAdjustBusy && current && kbAdjustBusy === current.id) return true;
|
|
7052
|
-
|
|
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');
|
|
7053
7234
|
if (!det) return false;
|
|
7054
7235
|
if (det.contains(document.activeElement)) return true;
|
|
7055
7236
|
const ta = det.querySelector('#kb-adjust-input');
|
|
@@ -7112,12 +7293,15 @@
|
|
|
7112
7293
|
async function loadKnowledgeState(proj) {
|
|
7113
7294
|
// Each read is bounded (#1604): the 3-second poll skips its ticks while a render is out, so a
|
|
7114
7295
|
// request that never answered would stop the column refreshing for good.
|
|
7115
|
-
const bounded = () => ({
|
|
7116
|
-
const [status, reqs, company] = await Promise.all([
|
|
7296
|
+
const bounded = () => ({ timeoutMs: 90_000 });
|
|
7297
|
+
const [status, reqs, company, designSet] = await Promise.all([
|
|
7117
7298
|
api(kbUrl(proj.id, '/status'), bounded()),
|
|
7118
7299
|
api('/api/requests', bounded()).catch(() => []),
|
|
7119
7300
|
api(`/api/company-knowledge?projectId=${encodeURIComponent(proj.id)}`, bounded())
|
|
7120
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.' }] })),
|
|
7121
7305
|
]);
|
|
7122
7306
|
const list = Array.isArray(reqs) ? reqs : (reqs.requests || []);
|
|
7123
7307
|
const manifest = status.manifest || { revision: 0, currentGeneration: null, sources: [] };
|
|
@@ -7128,6 +7312,7 @@
|
|
|
7128
7312
|
organize: status.organize || null,
|
|
7129
7313
|
queued: list.filter((r) => r && r.type === 'knowledge-organize' && r.project === proj.id),
|
|
7130
7314
|
company,
|
|
7315
|
+
designSet,
|
|
7131
7316
|
};
|
|
7132
7317
|
}
|
|
7133
7318
|
|
|
@@ -7152,11 +7337,40 @@
|
|
|
7152
7337
|
: `${(n / (1024 * 1024)).toFixed(1)} MB`);
|
|
7153
7338
|
function kbIcon(mime) {
|
|
7154
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: '◩' };
|
|
7155
7345
|
if (m.includes('pdf')) return { cls: 'pdf', glyph: '▤' };
|
|
7156
7346
|
if (m.startsWith('image/')) return { cls: 'img', glyph: '▣' };
|
|
7157
7347
|
if (m.includes('csv')) return { cls: 'sheet', glyph: '◧' };
|
|
7158
7348
|
return { cls: 'txt', glyph: '▦' };
|
|
7159
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
|
+
|
|
7160
7374
|
// Literal chip copy per state (never interpolated from the server); unknown state falls back escaped.
|
|
7161
7375
|
const KB_CHIP = {
|
|
7162
7376
|
new: ['new', 'new'],
|
|
@@ -7191,6 +7405,269 @@
|
|
|
7191
7405
|
return `<span class="kb-chip ${cls}">${escapeHtml(state)}</span>`;
|
|
7192
7406
|
}
|
|
7193
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
|
+
|
|
7194
7671
|
function kbSourceRow(s, st) {
|
|
7195
7672
|
const on = !!s.useAsKb;
|
|
7196
7673
|
const ico = kbIcon(s.mime);
|
|
@@ -7212,7 +7689,9 @@
|
|
|
7212
7689
|
`<div class="kb-fbody">` +
|
|
7213
7690
|
`<button type="button" class="kb-fname" data-kb-open="${escapeAttr(s.sourceId)}" ` +
|
|
7214
7691
|
`data-tip="Preview “${escapeAttr(name)}”">${escapeHtml(name)}</button>` +
|
|
7215
|
-
`<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) +
|
|
7216
7695
|
err +
|
|
7217
7696
|
`</div>` +
|
|
7218
7697
|
`<button type="button" class="kb-toggle" role="switch" aria-checked="${on ? 'true' : 'false'}" data-kb-toggle ` +
|
|
@@ -7541,7 +8020,10 @@
|
|
|
7541
8020
|
const alive = () => epoch === viewEpoch && key === lastViewKey &&
|
|
7542
8021
|
current && current.id === proj.id && !$wsKnowledge.hidden;
|
|
7543
8022
|
|
|
7544
|
-
|
|
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);
|
|
7545
8027
|
const ac = new AbortController();
|
|
7546
8028
|
kbTextAbort = ac;
|
|
7547
8029
|
|
|
@@ -7564,7 +8046,7 @@
|
|
|
7564
8046
|
}
|
|
7565
8047
|
|
|
7566
8048
|
if (row.mime === 'application/pdf') kbPaintPdf(row, url);
|
|
7567
|
-
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);
|
|
7568
8050
|
else kbPaintText(row, url, ac, alive);
|
|
7569
8051
|
}
|
|
7570
8052
|
|
|
@@ -7655,7 +8137,7 @@
|
|
|
7655
8137
|
}
|
|
7656
8138
|
if (!stillOurs()) return;
|
|
7657
8139
|
|
|
7658
|
-
const fresh = st
|
|
8140
|
+
const fresh = kbViewRow(st, row.sourceId);
|
|
7659
8141
|
if (!fresh) {
|
|
7660
8142
|
// The row is gone. Repaint the column too — merely closing the viewer would leave it listed,
|
|
7661
8143
|
// because nothing else is polling.
|
|
@@ -7694,6 +8176,197 @@
|
|
|
7694
8176
|
img.src = url;
|
|
7695
8177
|
}
|
|
7696
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
|
+
|
|
7697
8370
|
/** Text is read as a stream and STOPPED at 256 KB. The upload cap is 100 MB per file, so an uncapped
|
|
7698
8371
|
* <pre> would hang the tab; cancelling the reader also stops the server-side read. The bytes go in
|
|
7699
8372
|
* with textContent — never innerHTML, never markdown, never a parsed CSV table. */
|
|
@@ -7747,15 +8420,18 @@
|
|
|
7747
8420
|
}
|
|
7748
8421
|
|
|
7749
8422
|
function kbColumn(st) {
|
|
7750
|
-
|
|
7751
|
-
const
|
|
7752
|
-
|
|
7753
|
-
|
|
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;
|
|
7754
8430
|
return '<section class="kb-col">' +
|
|
7755
|
-
'<div class="kb-refs-body">' +
|
|
7756
|
-
'<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">' +
|
|
7757
8433
|
'<span class="di" aria-hidden="true">⤓</span><span class="dt">Drop references here</span>' +
|
|
7758
|
-
'<span class="ds">PDF ·
|
|
8434
|
+
'<span class="ds">PDF · Word · Excel · email · images · text</span>' +
|
|
7759
8435
|
'</button>' + body +
|
|
7760
8436
|
'</div>' + kbFoot(st) + '</section>';
|
|
7761
8437
|
}
|
|
@@ -7814,6 +8490,8 @@
|
|
|
7814
8490
|
$wsKnowledge.innerHTML = kbStepHeadHtml(knowledgeState) +
|
|
7815
8491
|
'<div class="kb-split">' +
|
|
7816
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>' +
|
|
7817
8495
|
'<div class="kb-refs-stub" aria-hidden="true"><span class="vertical-label">References</span></div>' +
|
|
7818
8496
|
'<div class="pane-rail kb-rail">' +
|
|
7819
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>' +
|
|
@@ -7942,14 +8620,16 @@
|
|
|
7942
8620
|
const curGen = st.currentGeneration ? st.currentGeneration.generationId : '';
|
|
7943
8621
|
return 'page:' + (viewer.generationId || curGen) + ':' + curGen + ':' + (viewer.slug || '');
|
|
7944
8622
|
}
|
|
7945
|
-
const row = viewer.mode === 'file' ? st
|
|
8623
|
+
const row = viewer.mode === 'file' ? kbViewRow(st, viewer.sourceId) : null;
|
|
7946
8624
|
const gen = viewer.mode === 'graph' && st.currentGeneration ? st.currentGeneration.generationId : '';
|
|
7947
|
-
|
|
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('|');
|
|
7948
8628
|
}
|
|
7949
8629
|
|
|
7950
8630
|
function paintKnowledge(st) {
|
|
7951
8631
|
// The previewed source may have been removed under us (by this tab or the terminal AI).
|
|
7952
|
-
if (viewer.mode === 'file' && !st
|
|
8632
|
+
if (viewer.mode === 'file' && !kbViewRow(st, viewer.sourceId)) {
|
|
7953
8633
|
setViewer({ mode: 'graph', sourceId: null });
|
|
7954
8634
|
}
|
|
7955
8635
|
kbEnsureShell();
|
|
@@ -7966,7 +8646,7 @@
|
|
|
7966
8646
|
// DOM; suppressing the repaint while it's active (kbAdjustActive) is simpler and safer than
|
|
7967
8647
|
// snapshotting/restoring every piece. lastRefsHtml is left stale, so the next tick (once the box is
|
|
7968
8648
|
// inactive) catches the column up to the latest state.
|
|
7969
|
-
if (html !== lastRefsHtml && !kbAdjustActive()) {
|
|
8649
|
+
if (html !== lastRefsHtml && !kbAdjustActive() && !kbDsPanelBusy()) {
|
|
7970
8650
|
const oldBody = refsHost.querySelector('.kb-refs-body');
|
|
7971
8651
|
const scrollTop = oldBody ? oldBody.scrollTop : 0;
|
|
7972
8652
|
refsHost.innerHTML = html;
|
|
@@ -7981,6 +8661,14 @@
|
|
|
7981
8661
|
if (btn) btn.focus();
|
|
7982
8662
|
kbFocusSourceId = null;
|
|
7983
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
|
+
}
|
|
7984
8672
|
}
|
|
7985
8673
|
|
|
7986
8674
|
const key = kbViewKey(st);
|
|
@@ -7991,7 +8679,7 @@
|
|
|
7991
8679
|
kbAbortPreview();
|
|
7992
8680
|
lastViewKey = key;
|
|
7993
8681
|
if (viewer.mode === 'file') {
|
|
7994
|
-
const row = st
|
|
8682
|
+
const row = kbViewRow(st, viewer.sourceId);
|
|
7995
8683
|
if (row) {
|
|
7996
8684
|
if (viewHost) viewHost.innerHTML = kbViewShell(row, kbViewLoading(row));
|
|
7997
8685
|
kbLoadPreview(current, row);
|
|
@@ -8146,6 +8834,19 @@
|
|
|
8146
8834
|
$companyKnowledgePromotion.hidden = !companyKnowledgePromotion;
|
|
8147
8835
|
if (companyKnowledgePromotion) {
|
|
8148
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
|
+
}
|
|
8149
8850
|
const prior = $companyPromotionLineage.value;
|
|
8150
8851
|
const entries = available ? state.sources.filter((entry) => !entry.removedAt) : [];
|
|
8151
8852
|
$companyPromotionLineage.innerHTML = '<option value="">New company entry</option>' + entries.map((entry) =>
|
|
@@ -8332,17 +9033,94 @@
|
|
|
8332
9033
|
catch { showToast('Could not read the selected files', 'warn'); return; }
|
|
8333
9034
|
if (current !== proj) return; // switched projects mid-read — never upload against the wrong KB
|
|
8334
9035
|
try {
|
|
8335
|
-
|
|
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 } : {}) }) });
|
|
8336
9041
|
if (current !== proj) return;
|
|
8337
9042
|
const n = (res.sources || []).length;
|
|
8338
|
-
|
|
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
|
+
}
|
|
8339
9056
|
track('kb_sources_added', { app: proj.app, n });
|
|
8340
|
-
} catch {
|
|
8341
|
-
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');
|
|
8342
9063
|
}
|
|
8343
9064
|
if (current === proj) renderKnowledge();
|
|
8344
9065
|
}
|
|
8345
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
|
+
|
|
8346
9124
|
async function kbToggle(sourceId, next) {
|
|
8347
9125
|
const proj = current;
|
|
8348
9126
|
if (!proj) return;
|
|
@@ -8351,13 +9129,13 @@
|
|
|
8351
9129
|
if (current === proj) renderKnowledge(); // re-render reconciles the optimistic flip either way
|
|
8352
9130
|
}
|
|
8353
9131
|
|
|
8354
|
-
async function kbRemove(sourceId) {
|
|
9132
|
+
async function kbRemove(sourceId, okMsg) {
|
|
8355
9133
|
const proj = current;
|
|
8356
9134
|
if (!proj) return;
|
|
8357
9135
|
kbCloseConfirm();
|
|
8358
9136
|
try {
|
|
8359
9137
|
await api(kbUrl(proj.id, `/sources/${encodeURIComponent(sourceId)}`), { method: 'DELETE' });
|
|
8360
|
-
showToast('Reference removed', 'ok');
|
|
9138
|
+
showToast(okMsg || 'Reference removed', 'ok');
|
|
8361
9139
|
} catch { showToast('Couldn’t remove this reference. Try again.', 'warn'); }
|
|
8362
9140
|
if (current === proj) renderKnowledge();
|
|
8363
9141
|
}
|
|
@@ -8477,7 +9255,7 @@
|
|
|
8477
9255
|
document.removeEventListener('mousedown', kbOnDocDown, true);
|
|
8478
9256
|
}
|
|
8479
9257
|
function kbOnDocDown(e) {
|
|
8480
|
-
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();
|
|
8481
9259
|
}
|
|
8482
9260
|
// Anchored to the SCROLL container (.kb-refs-body, position:relative) — .kb-col is overflow:hidden
|
|
8483
9261
|
// and would clip the popover. Same anchoring as .ws-history's rollback confirm.
|
|
@@ -8503,19 +9281,398 @@
|
|
|
8503
9281
|
document.addEventListener('mousedown', kbOnDocDown, true);
|
|
8504
9282
|
}
|
|
8505
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
|
+
|
|
8506
9653
|
// One delegated listener for the whole pane — the column is re-rendered wholesale on every state
|
|
8507
9654
|
// change, so per-render wiring would leak handlers.
|
|
8508
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
|
+
}
|
|
8509
9659
|
const promote = e.target.closest('[data-company-promote]');
|
|
8510
9660
|
if (promote) {
|
|
8511
9661
|
const row = knowledgeState && knowledgeState.sources.find((source) => source.sourceId === promote.dataset.companyPromote);
|
|
8512
|
-
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);
|
|
8513
9663
|
return;
|
|
8514
9664
|
}
|
|
8515
9665
|
const company = e.target.closest('[data-company-open]');
|
|
8516
9666
|
if (company) { openCompanyKnowledge(null, company); return; }
|
|
8517
9667
|
const go = e.target.closest('[data-kb-remove-go]');
|
|
8518
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; }
|
|
8519
9676
|
if (e.target.closest('.hc-cancel')) { kbCloseConfirm(); return; }
|
|
8520
9677
|
const rm = e.target.closest('[data-kb-remove]');
|
|
8521
9678
|
if (rm) {
|
|
@@ -8526,14 +9683,33 @@
|
|
|
8526
9683
|
}
|
|
8527
9684
|
const tog = e.target.closest('[data-kb-toggle]');
|
|
8528
9685
|
if (tog) {
|
|
8529
|
-
const row = tog.closest('.kb-src');
|
|
9686
|
+
const row = tog.dataset.kbToggleId ? null : tog.closest('.kb-src');
|
|
8530
9687
|
const next = tog.getAttribute('aria-checked') !== 'true';
|
|
8531
9688
|
tog.setAttribute('aria-checked', String(next)); // optimistic — reconciled by the re-render
|
|
8532
|
-
row.classList.toggle('off', !next);
|
|
9689
|
+
if (row) row.classList.toggle('off', !next);
|
|
8533
9690
|
// The DOM now disagrees with the model. If the PATCH fails, the re-rendered HTML would EQUAL the
|
|
8534
9691
|
// cache and the repaint would be skipped, stranding the wrong optimistic state on screen.
|
|
8535
9692
|
kbInvalidateRefs();
|
|
8536
|
-
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 });
|
|
8537
9713
|
return;
|
|
8538
9714
|
}
|
|
8539
9715
|
// Preview a source: the filename button. Re-clicking the open one is a no-op, not a reload.
|
|
@@ -8655,6 +9831,12 @@
|
|
|
8655
9831
|
});
|
|
8656
9832
|
// Live-enable the Adjust submit as the user types (the draft is DOM-owned; see kbSyncAdjustSubmit).
|
|
8657
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
|
+
});
|
|
8658
9840
|
$wsKnowledgeFile.addEventListener('change', () => {
|
|
8659
9841
|
kbUpload($wsKnowledgeFile.files);
|
|
8660
9842
|
$wsKnowledgeFile.value = ''; // let the same file be picked twice in a row
|
|
@@ -10294,7 +11476,9 @@
|
|
|
10294
11476
|
function exportSourceOptions(data) {
|
|
10295
11477
|
if (!data) return [];
|
|
10296
11478
|
const out = [];
|
|
10297
|
-
|
|
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) });
|
|
10298
11482
|
if (data.working) out.push({
|
|
10299
11483
|
selector: {
|
|
10300
11484
|
kind: 'working', expectedEtag: data.working.etag,
|
|
@@ -10304,7 +11488,7 @@
|
|
|
10304
11488
|
});
|
|
10305
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' });
|
|
10306
11490
|
for (const row of data.defaultUnavailable?.reason === 'refused' ? [] : (data.approved || [])) {
|
|
10307
|
-
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) });
|
|
10308
11492
|
}
|
|
10309
11493
|
return out;
|
|
10310
11494
|
}
|
|
@@ -10354,6 +11538,57 @@
|
|
|
10354
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>`;
|
|
10355
11539
|
}
|
|
10356
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
|
+
|
|
10357
11592
|
function paintExports(approvedAt, requestedRestoreKind) {
|
|
10358
11593
|
const hasModel = exportsHasModel;
|
|
10359
11594
|
// An explicit kind says "put them back on the button they pressed" — but only if they are still
|
|
@@ -10410,6 +11645,7 @@
|
|
|
10410
11645
|
// caption. The note's job — per the comment above — is to justify the exports-FOLDER button
|
|
10411
11646
|
// staying enabled, not to claim the export actions work unapproved. "Polishing is optional" was
|
|
10412
11647
|
// the true and useful half, and it survives; only the opening clause overreached.
|
|
11648
|
+
html += exportsAssumptionsHtml();
|
|
10413
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 ` +
|
|
10414
11650
|
`is optional. Each writes to this project’s <button type="button" class="exports-note-link" data-open-exports-folder ` +
|
|
10415
11651
|
`aria-label="Open the exports folder" data-tip="Open this project’s exports folder">▤ exports</button> folder.</div>`;
|
|
@@ -10657,6 +11893,7 @@
|
|
|
10657
11893
|
if (exportsHasModel !== paintedWith) paintExports(current.approvedAt, restoreKind);
|
|
10658
11894
|
let state = null;
|
|
10659
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
|
|
10660
11897
|
// SAYS THE THING THE GUARD MEANS. `if (units)` was correct only because the ternary above can
|
|
10661
11898
|
// never produce a falsy value — so a later, entirely reasonable "report what the server actually
|
|
10662
11899
|
// said, stop coercing" change to `units = r.units` would silently re-enable the resurrected-
|
|
@@ -10744,6 +11981,7 @@
|
|
|
10744
11981
|
// there for why.
|
|
10745
11982
|
answered = true;
|
|
10746
11983
|
approvedAt = r.approvedAt || undefined;
|
|
11984
|
+
filesFrom = r.receiptsFrom && Number.isInteger(r.receiptsFrom.version) && typeof r.receiptsFrom.hash === 'string' ? r.receiptsFrom : null;
|
|
10747
11985
|
units = r.units === 'mm' ? 'mm' : 'ft-in';
|
|
10748
11986
|
} else {
|
|
10749
11987
|
// Surface the load failure — don't let it read as "nothing exported yet" (a lie).
|
|
@@ -10772,6 +12010,7 @@
|
|
|
10772
12010
|
// on failure; moving this line below the guard dropped its `if` by accident. (Review round 3.)
|
|
10773
12011
|
if (answered) current.approvedAt = approvedAt;
|
|
10774
12012
|
exportState = state;
|
|
12013
|
+
exportStateFrom = answered ? filesFrom : null;
|
|
10775
12014
|
syncWorkspaceGuide(); // fresh approve/export state → tick the Export (and re-sync Approve) guide rows
|
|
10776
12015
|
paintExports(approvedAt, restoreKind);
|
|
10777
12016
|
}
|
|
@@ -11478,6 +12717,23 @@
|
|
|
11478
12717
|
revBaseVersion = (req && typeof req.baseVersion === 'number') ? req.baseVersion : 0;
|
|
11479
12718
|
revBaseProject = proj.id; // the baseline belongs to THIS project — see resetRevisionState
|
|
11480
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
|
+
}
|
|
11481
12737
|
lastRevState = 'pending';
|
|
11482
12738
|
startRevisionPoll();
|
|
11483
12739
|
renderRevisionCard();
|
|
@@ -11771,7 +13027,7 @@
|
|
|
11771
13027
|
// Bounded (#1604): the poll skips its ticks while this is out, so a read that never answered
|
|
11772
13028
|
// would stop the card for good. 90 s, like the Requests window: the route's own lock waits
|
|
11773
13029
|
// give up after 60 s.
|
|
11774
|
-
const b = await api('/api/requests', {
|
|
13030
|
+
const b = await api('/api/requests', { timeoutMs: 90_000 });
|
|
11775
13031
|
reqs = Array.isArray(b) ? b : (b.requests || []);
|
|
11776
13032
|
// Every owned success is fresh evidence of server contact, even if a later-started poll is in
|
|
11777
13033
|
// flight or has failed. The route can legitimately outlast the 3-second polling interval.
|
|
@@ -12213,7 +13469,10 @@
|
|
|
12213
13469
|
const isAnsweredZ = (z) => !!z && typeof z === 'object' && !!z.answered && typeof z.answered === 'object' && typeof z.known === 'number';
|
|
12214
13470
|
const endpointHeightText = (z) => {
|
|
12215
13471
|
if (!z || typeof z.known !== 'number') return 'no height';
|
|
12216
|
-
|
|
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}`;
|
|
12217
13476
|
};
|
|
12218
13477
|
const endWordOf = (key) => (key === 'from' ? 'Start' : 'End');
|
|
12219
13478
|
function plainLine(key, before, after) {
|
|
@@ -12944,7 +14203,7 @@
|
|
|
12944
14203
|
if (!props.length && !binds.length) {
|
|
12945
14204
|
// No disabled control standing in for an empty state — the group simply is not rendered.
|
|
12946
14205
|
body.appendChild(revEl('div', 'hd-empty', issues.length
|
|
12947
|
-
? '
|
|
14206
|
+
? 'This read found changes needing attention. The affected values were kept; review the details below.'
|
|
12948
14207
|
: leftOut.length
|
|
12949
14208
|
? 'Nothing needs your decision. What this read found is listed below with what was left out and why.'
|
|
12950
14209
|
: 'This read found no changes to make — the revised set matches what is already in the model.'));
|
|
@@ -12982,11 +14241,12 @@
|
|
|
12982
14241
|
const sum = document.createElement('summary');
|
|
12983
14242
|
sum.className = 'ws-archived-summary';
|
|
12984
14243
|
sum.appendChild(revEl('span', 'ws-archived-caret', '›'));
|
|
12985
|
-
sum.appendChild(document.createTextNode('
|
|
14244
|
+
sum.appendChild(document.createTextNode('Changes needing attention '));
|
|
12986
14245
|
sum.appendChild(revEl('span', 'ws-archived-count', String(issues.length)));
|
|
12987
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.'));
|
|
12988
14248
|
for (const it of issues) {
|
|
12989
|
-
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.');
|
|
12990
14250
|
row.appendChild(revEl('span', 'rev-issue-path', it.path || ''));
|
|
12991
14251
|
det.appendChild(row);
|
|
12992
14252
|
}
|
|
@@ -13782,7 +15042,7 @@
|
|
|
13782
15042
|
'data-tip="Show the complete member-by-member comparison">' +
|
|
13783
15043
|
'<span class="hd-caret">▸</span><span class="hd-toggle-label">View detailed changes</span></button>'
|
|
13784
15044
|
: '';
|
|
13785
|
-
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)}`;
|
|
13786
15046
|
if (!s || !Array.isArray(s.bullets)) {
|
|
13787
15047
|
return `<div class="hist-event">${escapeHtml(v.message)}</div>${detailWarning}${toggle}`;
|
|
13788
15048
|
}
|
|
@@ -13797,6 +15057,29 @@
|
|
|
13797
15057
|
`<ul class="hist-change-list">${bullets}</ul>${cautions}${detailWarning}${toggle}`;
|
|
13798
15058
|
}
|
|
13799
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
|
+
|
|
13800
15083
|
/**
|
|
13801
15084
|
* #1840: an approval that accepted open Tekla import findings carries the server's own sentence on
|
|
13802
15085
|
* its History row (one source for every approved surface), in the caution register the readiness
|
|
@@ -13808,6 +15091,20 @@
|
|
|
13808
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>`;
|
|
13809
15092
|
}
|
|
13810
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
|
+
|
|
13811
15108
|
function readinessHtml(v) {
|
|
13812
15109
|
const ready = v && v.readiness;
|
|
13813
15110
|
if (!ready || typeof ready.state !== 'string') return '';
|
|
@@ -14695,6 +15992,24 @@
|
|
|
14695
15992
|
}
|
|
14696
15993
|
|
|
14697
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
|
+
}
|
|
14698
16013
|
const note = e.target.closest('[data-revision-note]');
|
|
14699
16014
|
if (note) { editRevisionNote(Number(note.dataset.revisionNote)); return; }
|
|
14700
16015
|
const retryNote = e.target.closest('[data-revision-note-retry]');
|
|
@@ -15439,6 +16754,156 @@
|
|
|
15439
16754
|
if (current?.id !== projectId) throw new Error('That project could not be opened. Open it from Workspaces.');
|
|
15440
16755
|
}
|
|
15441
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
|
+
|
|
15442
16907
|
// A cross-project object pin still belongs to its original conversation, wherever its model is shown.
|
|
15443
16908
|
async function openChatOwner(owner) {
|
|
15444
16909
|
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
@@ -15499,10 +16964,149 @@
|
|
|
15499
16964
|
flashCard(project.id, { scroll: true });
|
|
15500
16965
|
if (current?.id === project.id) reconcileNow();
|
|
15501
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
|
+
|
|
15502
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
|
+
},
|
|
15503
17105
|
setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind,
|
|
15504
|
-
openHistory: wsOpenHistory, openKnowledgePage, openKnowledgeStep, openDrawingsStep, drawingFilterCheckpointSaved,
|
|
17106
|
+
openHistory: wsOpenHistory, openKnowledgePage, openKnowledgeStep, openDrawingsStep, openConnection, drawingFilterCheckpointSaved,
|
|
15505
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),
|
|
15506
17110
|
};
|
|
15507
17111
|
applyMode(); // restore persisted mode immediately (matches panels.js applyView timing)
|
|
15508
17112
|
})();
|