@floless/app 0.160.0 → 0.162.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/aware-version-pin.mjs +43 -0
- package/dist/floless-server.cjs +126990 -120010
- package/dist/schemas/steel.model.v2.schema.json +23 -0
- package/dist/skills/floless-app-knowledge/SKILL.md +6 -5
- package/dist/skills/floless-app-rfi/SKILL.md +18 -5
- package/dist/skills/floless-app-steel-model/SKILL.md +28 -6
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +579 -282
- package/dist/templates/floless-workspace-read.flo +9 -1
- package/dist/templates/steel-model.flo +6 -2
- package/dist/templates/viewer-3d-demo.flo +8 -2
- package/dist/web/app.css +198 -17
- package/dist/web/app.js +23 -0
- package/dist/web/aware.js +303 -54
- package/dist/web/chat-question-card.js +10 -3
- package/dist/web/chat.css +79 -5
- package/dist/web/chat.js +1513 -243
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-filter.js +11 -0
- package/dist/web/commands-shell.js +467 -29
- package/dist/web/commands-steel.js +40 -38
- package/dist/web/drawing-check-editor.js +76 -3
- package/dist/web/index.html +46 -2
- package/dist/web/instructor.js +5 -3
- package/dist/web/leave-guard.js +12 -2
- package/dist/web/pages.js +43 -12
- package/dist/web/project-history.js +349 -0
- package/dist/web/project-reconciliation.js +1 -0
- package/dist/web/project-rfis.js +260 -21
- package/dist/web/startup-admission.js +53 -7
- package/dist/web/steel-3d-core.js +115 -6
- package/dist/web/steel-3d-view.js +61 -5
- package/dist/web/steel-editor.html +439 -118
- package/dist/web/steel-filter.html +139 -0
- package/dist/web/steel-model-v2-commands.js +3 -3
- package/dist/web/steel-model-v2-projection.js +132 -4
- package/dist/web/steel-plan-transform.js +78 -0
- package/dist/web/tool-updates.js +59 -3
- package/dist/web/workspaces.js +1553 -196
- package/launch.mjs +36 -5
- package/package.json +6 -4
package/dist/web/workspaces.js
CHANGED
|
@@ -660,6 +660,9 @@
|
|
|
660
660
|
let exportState = null; // kind → { path, exportedAt } after a successful list; null = unknown/failed
|
|
661
661
|
// #2449: { version, hash } of the approved version exportState's files came from, from the SAME listing; null = unknown.
|
|
662
662
|
let exportStateFrom = null;
|
|
663
|
+
// #2781: DRAFT exports (working copy / checkpoint) from the same listing. Receipt-less by design and kept apart from
|
|
664
|
+
// `exportState`, so nothing that reads the approved rows can ever count one.
|
|
665
|
+
let exportDrafts = [];
|
|
663
666
|
/*
|
|
664
667
|
* THE UNITS THE SERVER SAYS THIS PROJECT'S BILL IS IN — from the same response the card is built
|
|
665
668
|
* from, refreshed every time the card is. `null` until it has answered.
|
|
@@ -779,10 +782,14 @@
|
|
|
779
782
|
},
|
|
780
783
|
editor: '/steel-editor.html',
|
|
781
784
|
filter: '/steel-filter.html',
|
|
785
|
+
// #2470 R6.6c: the RFIs step shows this editor's own RFI page, in the same frame as Model (plan
|
|
786
|
+
// 2026-10-25-2470-r6-6c-steel-rfis-step-PLAN.md): one document, so the list keeps the model state it works from.
|
|
787
|
+
rfisInEditor: true,
|
|
782
788
|
steps: [
|
|
783
789
|
{ key: 'knowledge', label: 'Knowledge' }, // per-project KB — the job's context, consulted by everything
|
|
784
790
|
{ key: 'drawings', label: 'Drawing Filter' },
|
|
785
791
|
{ key: 'model', label: 'Model' },
|
|
792
|
+
{ key: 'rfis', label: 'RFIs' }, // #2470 R6.6c: owner ruling 2026-10-25, right after Model
|
|
786
793
|
{ key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages; #2568: just before Exports (both are output)
|
|
787
794
|
{ key: 'exports', label: 'Exports' },
|
|
788
795
|
{ key: 'history', label: 'History' },
|
|
@@ -1016,6 +1023,9 @@
|
|
|
1016
1023
|
{ key: 'workflows', label: 'Workflows' }, // #2470 R6.2: the workflows this project owns
|
|
1017
1024
|
{ key: 'rfis', label: 'RFIs' }, // #2470 R6.6: the project's questions for the engineer, client or architect
|
|
1018
1025
|
{ key: 'modules', label: 'Modules' }, // #2470 R6.7: the module projects linked to this one
|
|
1026
|
+
// #2470 R6.5: what happened in the project. Keyed `journal`, not `history`: the module kinds' `history` step is
|
|
1027
|
+
// their approval ledger, which setStep renders under that key.
|
|
1028
|
+
{ key: 'journal', label: 'History' },
|
|
1019
1029
|
],
|
|
1020
1030
|
diff: false,
|
|
1021
1031
|
exports: [],
|
|
@@ -1971,6 +1981,9 @@
|
|
|
1971
1981
|
window.addEventListener('floless:contract-changed', (e) => {
|
|
1972
1982
|
const m = (e && e.detail) || {};
|
|
1973
1983
|
if (current && m.project === current.id) tellModelFrame(m);
|
|
1984
|
+
// A published edit changes the comparison too, including this editor's own save. Re-read the
|
|
1985
|
+
// server's pending groups rather than leaving the last approved verdict in the header (#2775).
|
|
1986
|
+
if (current && m.project === current.id && m.appId === current.app) refreshApprovalState(current.id);
|
|
1974
1987
|
});
|
|
1975
1988
|
window.addEventListener('floless:projects-changed', (e) => {
|
|
1976
1989
|
// Sent after the event stream reconnects too (aware.js), with no detail: frames may have been missed, so the
|
|
@@ -3796,6 +3809,9 @@
|
|
|
3796
3809
|
const $projectSetupError = document.getElementById('project-setup-error');
|
|
3797
3810
|
const $projectSetupProvider = document.getElementById('project-setup-provider');
|
|
3798
3811
|
const $projectSetupKickoffNote = document.getElementById('project-setup-kickoff-note');
|
|
3812
|
+
const $projectSetupBuild = document.getElementById('project-setup-build');
|
|
3813
|
+
const $projectSetupQuickTerms = document.getElementById('project-setup-quick-terms');
|
|
3814
|
+
const $projectSetupBuildLocked = document.getElementById('project-setup-build-locked');
|
|
3799
3815
|
const $projectSetupCancel = document.getElementById('project-setup-cancel');
|
|
3800
3816
|
const $projectSetupCreateOnly = document.getElementById('project-setup-create-only');
|
|
3801
3817
|
const $projectSetupCreate = document.getElementById('project-setup-create');
|
|
@@ -4034,6 +4050,38 @@
|
|
|
4034
4050
|
|
|
4035
4051
|
// Repaint only the AI lines while the dialog waits for a setup; a full render would re-enable the
|
|
4036
4052
|
// create buttons under the wait.
|
|
4053
|
+
/**
|
|
4054
|
+
* #2521 row 7a: the Model choice is offered only where this dialog starts a read: a Steel model from drawings, with an
|
|
4055
|
+
* AI to start the chat with. Once a submission was sent its choice is fixed, so a retry is the same intake (a changed
|
|
4056
|
+
* choice would be a different one, which the server answers as a conflict).
|
|
4057
|
+
*/
|
|
4058
|
+
function projectSetupBuildShown(state, provider) {
|
|
4059
|
+
return !!(state.askCatalogue && provider);
|
|
4060
|
+
}
|
|
4061
|
+
function paintProjectSetupBuild(state, provider) {
|
|
4062
|
+
if (!$projectSetupBuild) return;
|
|
4063
|
+
const shown = projectSetupBuildShown(state, provider);
|
|
4064
|
+
$projectSetupBuild.hidden = !shown;
|
|
4065
|
+
const locked = !!state.submissionId;
|
|
4066
|
+
const mode = (locked ? state.sentBuildMode : state.buildMode) === 'quick' ? 'quick' : 'precise';
|
|
4067
|
+
for (const button of $projectSetupBuild.querySelectorAll('[data-build-mode]')) {
|
|
4068
|
+
button.setAttribute('aria-pressed', String(button.dataset.buildMode === mode));
|
|
4069
|
+
if (locked) button.setAttribute('aria-disabled', 'true');
|
|
4070
|
+
else button.removeAttribute('aria-disabled');
|
|
4071
|
+
}
|
|
4072
|
+
$projectSetupQuickTerms.hidden = mode !== 'quick';
|
|
4073
|
+
$projectSetupBuildLocked.hidden = !locked;
|
|
4074
|
+
if (shown && mode === 'quick') $projectSetupCreateOnly.setAttribute('aria-describedby', 'project-setup-quick-create-only');
|
|
4075
|
+
else $projectSetupCreateOnly.removeAttribute('aria-describedby');
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
function chooseProjectSetupBuildMode(button) {
|
|
4079
|
+
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4080
|
+
projectSetupState.buildMode = button.dataset.buildMode === 'quick' ? 'quick' : 'precise';
|
|
4081
|
+
renderProjectSetup();
|
|
4082
|
+
if (projectSetupState.buildMode === 'quick') $projectSetupQuickTerms.scrollIntoView?.({ block: 'nearest' });
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4037
4085
|
function renderProjectSetupWhileBusy(state) {
|
|
4038
4086
|
if (projectSetupState !== state) return;
|
|
4039
4087
|
paintProjectSetupProviders(state, projectSetupProvider(state));
|
|
@@ -4068,6 +4116,7 @@
|
|
|
4068
4116
|
: 'FloLess stores this project here, and AI starts in this folder.';
|
|
4069
4117
|
if ($projectSetupName.value !== state.name) $projectSetupName.value = state.name;
|
|
4070
4118
|
$projectSetupStandard.hidden = !state.askCatalogue;
|
|
4119
|
+
paintProjectSetupBuild(state, provider);
|
|
4071
4120
|
$projectSetupStandard.querySelectorAll('[data-environment]').forEach((button) => {
|
|
4072
4121
|
button.setAttribute('aria-pressed', String(button.dataset.environment === state.environment));
|
|
4073
4122
|
});
|
|
@@ -4221,6 +4270,8 @@
|
|
|
4221
4270
|
let snapshots = state.snapshots || null;
|
|
4222
4271
|
if (!snapshots) snapshots = await Promise.all(state.files.map(readFileAsSnapshot));
|
|
4223
4272
|
state.snapshots = snapshots;
|
|
4273
|
+
// #2521 row 7a: the choice is settled with the first send and every retry repeats it.
|
|
4274
|
+
if (!state.submissionId) state.sentBuildMode = projectSetupBuildShown(state, provider) && state.buildMode === 'quick' ? 'quick' : null;
|
|
4224
4275
|
const submissionId = state.submissionId || crypto.randomUUID();
|
|
4225
4276
|
state.submissionId = submissionId;
|
|
4226
4277
|
rememberProjectChatIntake(submissionId);
|
|
@@ -4231,10 +4282,12 @@
|
|
|
4231
4282
|
directorySelectionId: state.directory.selectionId,
|
|
4232
4283
|
snapshots,
|
|
4233
4284
|
provider,
|
|
4285
|
+
...(state.sentBuildMode === 'quick' ? { buildMode: 'quick' } : {}),
|
|
4234
4286
|
});
|
|
4235
4287
|
const project = result.project;
|
|
4236
4288
|
state.project = project;
|
|
4237
4289
|
state.request = result.request;
|
|
4290
|
+
state.buildModeNotice = result.buildModeNotice || null;
|
|
4238
4291
|
if (!projects.some((item) => item.id === project.id)) {
|
|
4239
4292
|
projects.unshift(project);
|
|
4240
4293
|
track('workspace_project_created', { app: state.appId });
|
|
@@ -4262,9 +4315,12 @@
|
|
|
4262
4315
|
setProjectSetupBusy(false);
|
|
4263
4316
|
closeProjectSetup({ restoreFocus: false });
|
|
4264
4317
|
// A General project's chat is Flo's kickoff; its first reply may still be on its way (#2470 R6.4).
|
|
4265
|
-
|
|
4318
|
+
// #2521 row 7a: said from what was queued, never from the button still pressed.
|
|
4319
|
+
if (state.buildModeNotice?.why) showToast(`Project created. ${state.buildModeNotice.why}`, 'warn');
|
|
4320
|
+
else showToast(state.kind === 'general-project'
|
|
4266
4321
|
? 'Project created — Flo will help you set it up in AI Chat.'
|
|
4267
|
-
: 'Project created — the
|
|
4322
|
+
: state.request?.buildMode === 'quick' ? 'Project created — the Quick model read is running in AI Chat.'
|
|
4323
|
+
: 'Project created — the drawing task is running in AI Chat.', 'ok');
|
|
4268
4324
|
}
|
|
4269
4325
|
|
|
4270
4326
|
async function resumeInterruptedProjectChatIntake() {
|
|
@@ -4280,7 +4336,9 @@
|
|
|
4280
4336
|
await openProject(result.project.id, result.project.app === 'floless-general' ? 'knowledge' : 'drawings');
|
|
4281
4337
|
await bridge.openChatConversation(result.chat.chatId);
|
|
4282
4338
|
forgetProjectChatIntake(submissionId);
|
|
4283
|
-
|
|
4339
|
+
// #2521 row 7a: a Quick choice queued Precise is said on recovery too, from the saved receipt.
|
|
4340
|
+
if (result.buildModeNotice?.why) showToast(`Recovered the project and its AI Chat. ${result.buildModeNotice.why}`, 'warn');
|
|
4341
|
+
else showToast('Recovered the project and its AI Chat.', 'ok');
|
|
4284
4342
|
} catch (error) {
|
|
4285
4343
|
const code = error && (error.code || error.body && error.body.code);
|
|
4286
4344
|
if (code === 'project-intake-not-found' || code === 'project-intake-damaged') {
|
|
@@ -4325,6 +4383,8 @@
|
|
|
4325
4383
|
linkFrom,
|
|
4326
4384
|
askCatalogue: kind === 'drawings' && templateId === 'steel-model',
|
|
4327
4385
|
environment: null,
|
|
4386
|
+
// #2521 row 7a: Precise unless the person presses Quick; what was sent is kept in `sentBuildMode`.
|
|
4387
|
+
buildMode: 'precise',
|
|
4328
4388
|
directory: null,
|
|
4329
4389
|
name: '',
|
|
4330
4390
|
nameDirty: false,
|
|
@@ -4381,6 +4441,9 @@
|
|
|
4381
4441
|
projectSetupState.environment = button.dataset.environment;
|
|
4382
4442
|
renderProjectSetup();
|
|
4383
4443
|
});
|
|
4444
|
+
$projectSetupBuild?.addEventListener('click', (event) => {
|
|
4445
|
+
chooseProjectSetupBuildMode(event.target.closest('[data-build-mode]'));
|
|
4446
|
+
});
|
|
4384
4447
|
$projectSetupProvider?.addEventListener('click', (event) => {
|
|
4385
4448
|
chooseProjectSetupProvider(event.target.closest('[data-chat-provider]'));
|
|
4386
4449
|
});
|
|
@@ -5192,6 +5255,9 @@
|
|
|
5192
5255
|
if (unwanted()) return STAYED_IN_PROJECT;
|
|
5193
5256
|
if (current?.uuid !== p.uuid) revisionNoteEditorGeneration++;
|
|
5194
5257
|
current = p;
|
|
5258
|
+
// #2470 R6.6c: whatever editor is still loaded belongs to the project as it was before this open, and the frame is
|
|
5259
|
+
// reset below; until the new document says it is ready, no step message goes to the old one.
|
|
5260
|
+
editorBridge = null;
|
|
5195
5261
|
// #1890: a new workspace conversation suggests this project's units (the one opened last).
|
|
5196
5262
|
try { localStorage.setItem('floless:last-project', p.id); } catch { /* private mode: no suggestion */ }
|
|
5197
5263
|
revitSourceState = null;
|
|
@@ -5207,6 +5273,7 @@
|
|
|
5207
5273
|
pendingPresenceToast = null;
|
|
5208
5274
|
exportState = null;
|
|
5209
5275
|
exportStateFrom = null;
|
|
5276
|
+
exportDrafts = [];
|
|
5210
5277
|
exportUnits = null; // a new project's units arrive with its export listing; never inherit the last one's
|
|
5211
5278
|
renderReadinessState = null;
|
|
5212
5279
|
let sourceStateProbe = null;
|
|
@@ -5254,7 +5321,7 @@
|
|
|
5254
5321
|
// A sourceless project (General, #2470) has no Model, Drawings, Exports or History step; a step carried
|
|
5255
5322
|
// over from another project lands on its first step instead of a pane it does not have.
|
|
5256
5323
|
if (d.sourceless && !d.steps.some((step) => step.key === initialStep)) initialStep = d.steps[0].key;
|
|
5257
|
-
if ((d.filter || isModelSourceProject(p)) && ['model', 'exports', 'history'].includes(initialStep)) {
|
|
5324
|
+
if ((d.filter || isModelSourceProject(p)) && ['model', 'rfis', 'exports', 'history'].includes(initialStep)) {
|
|
5258
5325
|
pendingPresenceStep = { projectId: p.id, step: initialStep };
|
|
5259
5326
|
}
|
|
5260
5327
|
// The LIVE app id, deliberately: the frames address the server with it (contract reads, saves),
|
|
@@ -5406,7 +5473,7 @@
|
|
|
5406
5473
|
* Two points matter. Drawing-first creation opens the project before its read is queued, so the
|
|
5407
5474
|
* lifecycle probe commonly caches `absent`; gating on `filter-checkpoint` left the two competing
|
|
5408
5475
|
* status bands standing in the most ordinary path there is. But an unresolved (`unknown`)
|
|
5409
|
-
* lifecycle un-gates every tab, so the strip paints nothing — and retiring against that would
|
|
5476
|
+
* lifecycle un-gates every tab, so without live progress the strip paints nothing — and retiring against that would
|
|
5410
5477
|
* leave the user with no status at all. Asking the strip itself settles both without a second
|
|
5411
5478
|
* predicate that has to be kept in agreement with `stageGateFor`.
|
|
5412
5479
|
*/
|
|
@@ -5464,6 +5531,9 @@
|
|
|
5464
5531
|
}
|
|
5465
5532
|
function closeProject() {
|
|
5466
5533
|
openNavSeq++;
|
|
5534
|
+
// #2470 R6.6c: an editor that hosts the RFIs step is away now (it may stay loaded in the hidden frame).
|
|
5535
|
+
if (wsApp()?.rfisInEditor) postStepToEditor(null);
|
|
5536
|
+
editorBridge = null;
|
|
5467
5537
|
current = null;
|
|
5468
5538
|
approvalStateGen++;
|
|
5469
5539
|
approvalState = { status: 'unavailable', review: null, pendingCount: 0, headVersion: null, error: '' };
|
|
@@ -5471,6 +5541,7 @@
|
|
|
5471
5541
|
closeApprovalReview();
|
|
5472
5542
|
exportState = null;
|
|
5473
5543
|
exportStateFrom = null;
|
|
5544
|
+
exportDrafts = [];
|
|
5474
5545
|
exportUnits = null; // a new project's units arrive with its export listing; never inherit the last one's
|
|
5475
5546
|
renderReadinessState = null;
|
|
5476
5547
|
resetRevisionState();
|
|
@@ -5775,7 +5846,7 @@
|
|
|
5775
5846
|
review.dataset.commandId = 'shell.revision-filter-open';
|
|
5776
5847
|
review.setAttribute('data-tip', 'Focus the Drawing Filter below');
|
|
5777
5848
|
actions.appendChild(review);
|
|
5778
|
-
$stageGuidance.appendChild(actions);
|
|
5849
|
+
($stageGuidance.querySelector('#ws-stage-guidance-body') || $stageGuidance).appendChild(actions);
|
|
5779
5850
|
markScrollable($stageGuidance);
|
|
5780
5851
|
}
|
|
5781
5852
|
|
|
@@ -5872,23 +5943,75 @@
|
|
|
5872
5943
|
/**
|
|
5873
5944
|
* Avoid re-announcing unchanged progress every time the three-second request poll repaints.
|
|
5874
5945
|
*
|
|
5875
|
-
* The bounded visible region is named and becomes keyboard-scrollable when needed.
|
|
5876
|
-
*
|
|
5946
|
+
* The bounded visible region is named and becomes keyboard-scrollable when needed. A separate
|
|
5947
|
+
* concise live region announces status changes; complete details remain readable on expansion.
|
|
5877
5948
|
*/
|
|
5878
|
-
function paintStageGuidance(content, state = 'info') {
|
|
5949
|
+
function paintStageGuidance(content, state = 'info', projectId = null) {
|
|
5879
5950
|
if (!$stageGuidance) return;
|
|
5880
5951
|
// Only a real projection may take the progress path. Any other object would render `undefined`
|
|
5881
5952
|
// into the heading with no throw and no log, which is the failure this surface exists to remove.
|
|
5882
5953
|
const progress = content && typeof content === 'object' && !Array.isArray(content)
|
|
5883
5954
|
&& typeof content.heading === 'string' && typeof content.state === 'string'
|
|
5884
5955
|
&& Number.isSafeInteger(content.doneCount) ? content : null;
|
|
5885
|
-
|
|
5956
|
+
// Presentation belongs to a project in this window, not to a polling revision or a read stage.
|
|
5957
|
+
// A fresh window starts expanded; switching away and back keeps the person's choice.
|
|
5958
|
+
const scope = projectId ?? (typeof current !== 'undefined' && current ? current.id : '');
|
|
5959
|
+
const choices = $stageGuidance._collapseChoices ||= new Map();
|
|
5960
|
+
const key = `${scope}:` + (progress
|
|
5886
5961
|
? `progress:${progress.requestId}:${progress.state}:${progress.revision}:${progress.heading}`
|
|
5887
|
-
: `text:${state}:${typeof content === 'string' ? content : ''}
|
|
5962
|
+
: `text:${state}:${typeof content === 'string' ? content : ''}`);
|
|
5888
5963
|
$stageGuidance.hidden = false;
|
|
5889
5964
|
if ($stageGuidance._renderKey === key) return;
|
|
5890
5965
|
$stageGuidance._renderKey = key;
|
|
5891
5966
|
$stageGuidance.className = `ws-stage-guidance state-${progress ? progress.state : state}`;
|
|
5967
|
+
const restoreToggleFocus = document.activeElement?.matches?.('.wsg-toggle');
|
|
5968
|
+
let compactAnnouncement = '';
|
|
5969
|
+
const mountToggle = () => {
|
|
5970
|
+
const body = document.createElement('div');
|
|
5971
|
+
body.id = 'ws-stage-guidance-body';
|
|
5972
|
+
while ($stageGuidance.firstChild) body.appendChild($stageGuidance.firstChild);
|
|
5973
|
+
$stageGuidance.appendChild(body);
|
|
5974
|
+
const toolbar = document.createElement('div');
|
|
5975
|
+
toolbar.className = 'wsg-toolbar';
|
|
5976
|
+
const summary = document.createElement('span');
|
|
5977
|
+
summary.className = 'wsg-compact';
|
|
5978
|
+
summary.setAttribute('aria-hidden', 'true');
|
|
5979
|
+
if (progress) {
|
|
5980
|
+
const title = document.createElement('strong');
|
|
5981
|
+
title.textContent = progress.heading;
|
|
5982
|
+
summary.append(title);
|
|
5983
|
+
for (const [label, text] of [
|
|
5984
|
+
[progress.nowLabel || 'Now', progress.now], ['Heads up', progress.caution],
|
|
5985
|
+
['Done', progress.done], ['Next', progress.next],
|
|
5986
|
+
]) {
|
|
5987
|
+
if (!text) continue;
|
|
5988
|
+
const highlight = document.createElement('b');
|
|
5989
|
+
highlight.className = 'wsg-compact-label';
|
|
5990
|
+
highlight.textContent = ` · ${label}: `;
|
|
5991
|
+
summary.append(highlight, document.createTextNode(text));
|
|
5992
|
+
}
|
|
5993
|
+
} else summary.textContent = typeof content === 'string' ? content : '';
|
|
5994
|
+
const toggle = document.createElement('button');
|
|
5995
|
+
toggle.type = 'button';
|
|
5996
|
+
toggle.className = 'wsg-toggle';
|
|
5997
|
+
toggle.dataset.commandId = 'shell.workspace-progress-toggle';
|
|
5998
|
+
toggle.setAttribute('aria-controls', body.id);
|
|
5999
|
+
const apply = () => {
|
|
6000
|
+
const collapsed = choices.get(scope) === true;
|
|
6001
|
+
$stageGuidance.classList.toggle('is-collapsed', collapsed);
|
|
6002
|
+
toggle.textContent = collapsed ? 'Expand' : 'Collapse';
|
|
6003
|
+
toggle.setAttribute('aria-label', `${collapsed ? 'Expand' : 'Collapse'} drawing read progress`);
|
|
6004
|
+
toggle.setAttribute('aria-expanded', String(!collapsed));
|
|
6005
|
+
toggle.setAttribute('data-tip', collapsed ? 'Show full drawing read progress' : 'Keep drawing read progress on one line');
|
|
6006
|
+
if (live && live.textContent !== compactAnnouncement) live.textContent = compactAnnouncement;
|
|
6007
|
+
markScrollable($stageGuidance);
|
|
6008
|
+
};
|
|
6009
|
+
toggle.addEventListener('click', () => { choices.set(scope, choices.get(scope) !== true); apply(); });
|
|
6010
|
+
toolbar.append(summary, toggle);
|
|
6011
|
+
$stageGuidance.prepend(toolbar);
|
|
6012
|
+
apply();
|
|
6013
|
+
if (restoreToggleFocus) toggle.focus();
|
|
6014
|
+
};
|
|
5892
6015
|
let live = document.getElementById('ws-stage-guidance-live');
|
|
5893
6016
|
if (!live) {
|
|
5894
6017
|
live = document.createElement('span');
|
|
@@ -5903,18 +6026,17 @@
|
|
|
5903
6026
|
// Only a string is guidance. Coercing an object here would paint the literal `[object Object]`
|
|
5904
6027
|
// into the strip with no throw and no log.
|
|
5905
6028
|
const text = typeof content === 'string' ? content : '';
|
|
5906
|
-
|
|
6029
|
+
compactAnnouncement = text.length > 200 ? `${text.slice(0, 199)}…` : text;
|
|
5907
6030
|
const visible = document.createElement('span');
|
|
5908
|
-
visible.setAttribute('aria-hidden', 'true');
|
|
5909
6031
|
visible.textContent = text;
|
|
5910
6032
|
$stageGuidance.replaceChildren(visible);
|
|
6033
|
+
mountToggle();
|
|
5911
6034
|
markScrollable($stageGuidance);
|
|
5912
6035
|
return;
|
|
5913
6036
|
}
|
|
5914
6037
|
|
|
5915
6038
|
const head = document.createElement('div');
|
|
5916
6039
|
head.className = 'wsg-head';
|
|
5917
|
-
head.setAttribute('aria-hidden', 'true');
|
|
5918
6040
|
const signal = document.createElement('span');
|
|
5919
6041
|
signal.className = 'wsg-signal';
|
|
5920
6042
|
signal.setAttribute('aria-hidden', 'true');
|
|
@@ -5932,7 +6054,6 @@
|
|
|
5932
6054
|
|
|
5933
6055
|
const details = document.createElement('div');
|
|
5934
6056
|
details.className = 'wsg-details';
|
|
5935
|
-
details.setAttribute('aria-hidden', 'true');
|
|
5936
6057
|
details.appendChild(stageGuidanceRow('Done', progress.done));
|
|
5937
6058
|
if (progress.now) details.appendChild(stageGuidanceRow(progress.nowLabel, progress.now));
|
|
5938
6059
|
if (progress.caution) details.appendChild(stageGuidanceRow('Heads up', progress.caution));
|
|
@@ -5940,24 +6061,25 @@
|
|
|
5940
6061
|
|
|
5941
6062
|
const instant = new Date(progress.updatedAt);
|
|
5942
6063
|
const updatedText = `Updated ${instant.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`;
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
`Done: ${progress.done}`,
|
|
6064
|
+
// The full panel stays readable separately. The established live region announces only the
|
|
6065
|
+
// current status, action and warnings, in either mode, without replaying history and the clock.
|
|
6066
|
+
compactAnnouncement = [progress.heading, `${progress.doneCount} check${progress.doneCount === 1 ? '' : 's'} complete`,
|
|
5947
6067
|
progress.now ? `${progress.nowLabel}: ${progress.now}` : '',
|
|
5948
6068
|
progress.caution ? `Heads up: ${progress.caution}` : '',
|
|
5949
6069
|
progress.next ? `Next: ${progress.next}` : '',
|
|
5950
|
-
|
|
5951
|
-
|
|
6070
|
+
].filter(Boolean).map((part) => {
|
|
6071
|
+
const bounded = part.length > 200 ? `${part.slice(0, 199)}…` : part;
|
|
6072
|
+
return /[.!?…]$/.test(bounded) ? bounded : `${bounded}.`;
|
|
6073
|
+
}).join(' ');
|
|
5952
6074
|
|
|
5953
6075
|
// Server summaries are prose and usually end in a full stop already. Joining with another one
|
|
5954
6076
|
// makes a screen reader read "confirmed dot dot", so only unpunctuated segments get a stop.
|
|
5955
6077
|
const updated = document.createElement('time');
|
|
5956
6078
|
updated.className = 'wsg-updated';
|
|
5957
|
-
updated.setAttribute('aria-hidden', 'true');
|
|
5958
6079
|
updated.dateTime = progress.updatedAt;
|
|
5959
6080
|
updated.textContent = updatedText;
|
|
5960
6081
|
$stageGuidance.replaceChildren(head, activity, details, updated);
|
|
6082
|
+
mountToggle();
|
|
5961
6083
|
markScrollable($stageGuidance);
|
|
5962
6084
|
}
|
|
5963
6085
|
|
|
@@ -5985,7 +6107,7 @@
|
|
|
5985
6107
|
|
|
5986
6108
|
function stageGateFor(step) {
|
|
5987
6109
|
const d = wsApp();
|
|
5988
|
-
if (!d || !d.filter || !['model', 'exports', 'history'].includes(step)) return '';
|
|
6110
|
+
if (!d || !d.filter || !['model', 'rfis', 'exports', 'history'].includes(step)) return '';
|
|
5989
6111
|
const initialRead = revCardReq && isInitialRevisionRead(revCardReq);
|
|
5990
6112
|
const waitingForInitial = initialRead && lastRevState === 'pending';
|
|
5991
6113
|
const stagedInitial = initialRead && lastRevState === 'staged';
|
|
@@ -6014,10 +6136,12 @@
|
|
|
6014
6136
|
if (waitingForInitial && revCardReq?.prepassReady) return `Check steel, member marks, grids, dimensions, and relevant callouts. Ask in AI Chat on the left if you need help. ${readyFilterNextStep(revCardReq)}`;
|
|
6015
6137
|
if (waitingForInitial && revCardReq?.preparationRetryable) return `Steel Filter preparation was interrupted. Your drawings are still attached. Return to the same ${readSessionName(revCardReq)} and retry preparation for this same request.`;
|
|
6016
6138
|
if (waitingForInitial) return `The initial drawing read is waiting for ${readRunsInChat(revCardReq) ? 'AI Chat' : 'your terminal AI'}. The model unlocks after you review the Drawing Filter and press Save filter.`;
|
|
6139
|
+
if (projectContractLifecycle === 'filter-checkpoint' && !revisionListKnown) return 'Checking the drawing read. Stages open once FloLess knows where it stands.';
|
|
6017
6140
|
if (projectContractLifecycle === 'filter-checkpoint') return 'Attach the drawing set again in Drawing Filter to restart the read. The earlier request is no longer available to receive a saved filter.';
|
|
6018
6141
|
return 'Read and save a Drawing Filter first. The model will unlock after the first drawing read.';
|
|
6019
6142
|
}
|
|
6020
6143
|
if (waitingForInitial) return `The ${step === 'exports' ? 'steel model' : 'first model'} must be ready before ${step === 'exports' ? 'exports' : 'history'} is available.`;
|
|
6144
|
+
if (projectContractLifecycle === 'filter-checkpoint' && !revisionListKnown) return 'Checking the drawing read. Stages open once FloLess knows where it stands.';
|
|
6021
6145
|
if (projectContractLifecycle === 'filter-checkpoint') return `Attach the drawing set again in Drawing Filter before opening ${step === 'exports' ? 'Exports' : 'History'}. The earlier request can no longer continue.`;
|
|
6022
6146
|
return `Create the first steel model before opening ${step === 'exports' ? 'Exports' : 'History'}.`;
|
|
6023
6147
|
}
|
|
@@ -6087,10 +6211,6 @@
|
|
|
6087
6211
|
const stagedInitial = initialRead && lastRevState === 'staged';
|
|
6088
6212
|
const failedInitial = initialRead && lastRevState === 'failed';
|
|
6089
6213
|
const unavailableInitial = initialRead && lastRevState === 'unavailable';
|
|
6090
|
-
if (!locked && !stripPending) {
|
|
6091
|
-
clearStageGuidance();
|
|
6092
|
-
return;
|
|
6093
|
-
}
|
|
6094
6214
|
const ownsProgress = waitingForInitial && stageGuidanceOwnsSavedCheckpoint(revCardReq);
|
|
6095
6215
|
const liveProgress = ownsProgress ? drawingProgressView(revCardReq, Date.now(), revRequestsFailed) : null;
|
|
6096
6216
|
if (ownsProgress && revCardReq?.steelProgress && !liveProgress) {
|
|
@@ -6113,6 +6233,12 @@
|
|
|
6113
6233
|
paintStageGuidance(liveProgress);
|
|
6114
6234
|
return;
|
|
6115
6235
|
}
|
|
6236
|
+
// Saving the Filter can unlock the tabs while its initial drawing read is still running.
|
|
6237
|
+
// Progress belongs to that read, not to the prerequisite gate; only idle guidance needs a gate.
|
|
6238
|
+
if (!locked && !stripPending) {
|
|
6239
|
+
clearStageGuidance();
|
|
6240
|
+
return;
|
|
6241
|
+
}
|
|
6116
6242
|
// An unfinished Filter save (being written, waiting on its confirmation, refused, needing a reload,
|
|
6117
6243
|
// or never pressed) outranks every sentence below — the one they would otherwise show here is "The
|
|
6118
6244
|
// Drawing Filter is saved" (#1781). Live progress above still wins: a read already running works from
|
|
@@ -6162,6 +6288,10 @@
|
|
|
6162
6288
|
? `Drawing read is paused in AI Chat · ${OPEN_AI_CHAT} and tell it to continue the drawing read.`
|
|
6163
6289
|
: waitingForInitial
|
|
6164
6290
|
? 'Drawing read not started · Open Requests — if Start in AI Chat is shown, choose it; otherwise copy the request into Claude Code or Codex. Then return to review and save the Drawing Filter.'
|
|
6291
|
+
: projectContractLifecycle === 'filter-checkpoint' && !revisionListKnown
|
|
6292
|
+
? (revRequestsFailed
|
|
6293
|
+
? 'Checking the drawing read · FloLess cannot reach it right now and keeps trying. Your drawings are still attached.'
|
|
6294
|
+
: 'Checking the drawing read · FloLess is looking up this project’s drawing request.')
|
|
6165
6295
|
: projectContractLifecycle === 'filter-checkpoint'
|
|
6166
6296
|
? 'Drawing read needs restarting · The earlier drawing request is no longer available. Attach the drawing set again in Drawing Filter to restart the read.'
|
|
6167
6297
|
: 'Start in Drawing Filter by attaching a PDF drawing set. The Model, Exports, and History stages unlock after the first steel model is created.';
|
|
@@ -6174,7 +6304,7 @@
|
|
|
6174
6304
|
function deferStageUntilLifecycle(s) {
|
|
6175
6305
|
const d = wsApp();
|
|
6176
6306
|
if (!current || !d?.filter || projectContractLifecycle !== 'unknown'
|
|
6177
|
-
|| !['model', 'exports', 'history'].includes(s)) return false;
|
|
6307
|
+
|| !['model', 'rfis', 'exports', 'history'].includes(s)) return false;
|
|
6178
6308
|
pendingPresenceStep = { projectId: current.id, step: s };
|
|
6179
6309
|
const projectId = current.id;
|
|
6180
6310
|
if (pendingPresenceToast) pendingPresenceToast();
|
|
@@ -6233,6 +6363,9 @@
|
|
|
6233
6363
|
showToast(lockedReason, 'warn');
|
|
6234
6364
|
return;
|
|
6235
6365
|
}
|
|
6366
|
+
// #2521 row 7b: a design-set read panel's Model preset was read when it opened; leaving Knowledge drops it, so coming
|
|
6367
|
+
// back reads the model's mode afresh instead of submitting a choice the model may have moved on from.
|
|
6368
|
+
if (s !== 'knowledge' && kbDsPanel && kbDsPanel.kind === 'read') kbDsPanel = null;
|
|
6236
6369
|
currentStep = s;
|
|
6237
6370
|
$stepTabs.querySelectorAll('button').forEach((b) => {
|
|
6238
6371
|
const on = b.dataset.step === s;
|
|
@@ -6243,18 +6376,22 @@
|
|
|
6243
6376
|
// step shows a lightweight placeholder pane instead of an about:blank iframe.
|
|
6244
6377
|
const d = wsApp();
|
|
6245
6378
|
const drawingsHasFrame = !!(d && d.filter);
|
|
6379
|
+
// #2470 R6.6c: a kind whose RFIs live in its editor shows the model frame on the RFIs step too.
|
|
6380
|
+
const rfisInEditor = !!(d && d.rfisInEditor);
|
|
6246
6381
|
for (const [k, f] of Object.entries(frames)) {
|
|
6247
|
-
const show = k === s && (k !== 'drawings' || drawingsHasFrame);
|
|
6382
|
+
const show = (k === s || (k === 'model' && s === 'rfis' && rfisInEditor)) && (k !== 'drawings' || drawingsHasFrame);
|
|
6248
6383
|
f.hidden = !show;
|
|
6249
6384
|
if (show && !f.dataset.loaded && f.dataset.want) { f.src = f.dataset.want; f.dataset.loaded = '1'; }
|
|
6250
6385
|
// Coming back to an editor that stayed loaded while hidden: tell it, so it can read again what changed on
|
|
6251
6386
|
// another step meanwhile (the Drawing Checker's references after a Knowledge change, #2482). Others ignore it.
|
|
6387
|
+
// An editor that hosts the RFIs step hears about every step instead, below.
|
|
6252
6388
|
else if (show && k === 'model' && f.dataset.loaded) {
|
|
6253
6389
|
const project = typeof current !== 'undefined' ? current : null;
|
|
6254
|
-
try { if (project) f.contentWindow?.postMessage({ type: 'floless:step-shown', step: s, projectId: project.id }, location.origin); }
|
|
6390
|
+
try { if (project && !rfisInEditor) f.contentWindow?.postMessage({ type: 'floless:step-shown', step: s, projectId: project.id }, location.origin); }
|
|
6255
6391
|
catch { /* the frame is between documents */ }
|
|
6256
6392
|
}
|
|
6257
6393
|
}
|
|
6394
|
+
if (rfisInEditor) postStepToEditor(s);
|
|
6258
6395
|
if (window.flolessLeftPane) {
|
|
6259
6396
|
window.flolessLeftPane.setWorkspaceModelVisible(s === 'model');
|
|
6260
6397
|
}
|
|
@@ -6322,7 +6459,7 @@
|
|
|
6322
6459
|
// reached through globalThis, so a harness that lifts setStep without it still runs.
|
|
6323
6460
|
const $rfisPane = document.getElementById('ws-rfis');
|
|
6324
6461
|
if ($rfisPane) {
|
|
6325
|
-
const showRfis = s === 'rfis';
|
|
6462
|
+
const showRfis = s === 'rfis' && !rfisInEditor;
|
|
6326
6463
|
$rfisPane.hidden = !showRfis;
|
|
6327
6464
|
const project = typeof current !== 'undefined' ? current : null;
|
|
6328
6465
|
if (showRfis && project) globalThis.flolessProjectRfis?.render?.($rfisPane, project);
|
|
@@ -6336,6 +6473,15 @@
|
|
|
6336
6473
|
const project = typeof current !== 'undefined' ? current : null;
|
|
6337
6474
|
if (showModules && project && window.flolessProjectModules) window.flolessProjectModules.render($modulesPane, project);
|
|
6338
6475
|
}
|
|
6476
|
+
// #2470 R6.5: a General project's History is a shell-rendered pane too: its journal (project-history.js). Reached
|
|
6477
|
+
// through globalThis, like the RFIs one, so a harness that lifts setStep without it still runs.
|
|
6478
|
+
const $journalPane = document.getElementById('ws-journal');
|
|
6479
|
+
if ($journalPane) {
|
|
6480
|
+
const showJournal = s === 'journal';
|
|
6481
|
+
$journalPane.hidden = !showJournal;
|
|
6482
|
+
const project = typeof current !== 'undefined' ? current : null;
|
|
6483
|
+
if (showJournal && project) globalThis.flolessProjectHistory?.render?.($journalPane, project);
|
|
6484
|
+
}
|
|
6339
6485
|
// Knowledge is a shell-rendered pane too: the project's Knowledge Base (References column).
|
|
6340
6486
|
const showKnowledge = s === 'knowledge';
|
|
6341
6487
|
$wsKnowledge.hidden = !showKnowledge;
|
|
@@ -6386,6 +6532,69 @@
|
|
|
6386
6532
|
|| !['clean', 'dirty', 'saving', 'error', 'conflict'].includes(message.state)) return;
|
|
6387
6533
|
modelContractSaveState = { projectId: current.id, appId: current.app, state: message.state, generation: message.generation };
|
|
6388
6534
|
});
|
|
6535
|
+
/*
|
|
6536
|
+
* #2470 R6.6c — the steel editor hosts the RFIs step (plan §10). The shell tells the editor which step is showing on
|
|
6537
|
+
* every change (`floless:step-shown`, with a rising `seq`; `step: null` when the project closes); the editor says when
|
|
6538
|
+
* it is ready (`floless:editor-ready`, answered with the current step), and may ask to switch between its two steps
|
|
6539
|
+
* (`floless:rfis-request-step`, model or rfis only, answered with `floless:rfis-step-ack`). Only from this project's
|
|
6540
|
+
* own model frame: the Edit-contract overlay and a direct URL run the RFI page locally and never move these steps.
|
|
6541
|
+
*/
|
|
6542
|
+
let editorStepSeq = 0;
|
|
6543
|
+
/** The editor document that completed the ready handshake for the project on screen — the only one that may navigate. */
|
|
6544
|
+
let editorBridge = null;
|
|
6545
|
+
/** The editor request being carried out right now: the step message it causes names it, so the editor can tell its
|
|
6546
|
+
* own older request's echo from the person choosing a step. */
|
|
6547
|
+
let editorStepCause = null;
|
|
6548
|
+
const sameUuid = (a, b) => String(a || '').toLowerCase() === String(b || '').toLowerCase();
|
|
6549
|
+
function postStepToEditor(step) {
|
|
6550
|
+
const win = frames.model?.contentWindow;
|
|
6551
|
+
// Only the document that said it is ready for the project on screen hears the step. A project reopened while its
|
|
6552
|
+
// old editor is still loaded would otherwise tell that old document to show RFIs and start a read the reset below
|
|
6553
|
+
// it then cuts off; the new document asks for the step itself once it is ready.
|
|
6554
|
+
if (!win || !frames.model.dataset.loaded || !editorBridge || editorBridge.win !== win) return;
|
|
6555
|
+
const project = typeof current !== 'undefined' ? current : null;
|
|
6556
|
+
try {
|
|
6557
|
+
win.postMessage({ type: 'floless:step-shown', step, seq: ++editorStepSeq,
|
|
6558
|
+
projectId: project ? project.id : null, projectUuid: project ? (project.uuid || null) : null,
|
|
6559
|
+
...(editorStepCause ? { cause: editorStepCause } : {}) }, location.origin);
|
|
6560
|
+
} catch (error) {
|
|
6561
|
+
// The frame is between documents: the document that loads next sends its own ready and hears the step then.
|
|
6562
|
+
console.warn('[workspaces] could not tell the steel editor which step shows', error);
|
|
6563
|
+
}
|
|
6564
|
+
}
|
|
6565
|
+
window.addEventListener('message', (event) => {
|
|
6566
|
+
const message = event.data;
|
|
6567
|
+
if (event.origin !== location.origin || event.source !== frames.model?.contentWindow || !message || !current) return;
|
|
6568
|
+
const d = wsApp();
|
|
6569
|
+
if (!d || !d.rfisInEditor || message.projectId !== current.id) return;
|
|
6570
|
+
if (message.type === 'floless:editor-ready') {
|
|
6571
|
+
// This document now owns the bridge for this project incarnation; it learns the uuid from the step message.
|
|
6572
|
+
editorBridge = { win: event.source, projectId: current.id, projectUuid: current.uuid || null };
|
|
6573
|
+
postStepToEditor(currentStep);
|
|
6574
|
+
return;
|
|
6575
|
+
}
|
|
6576
|
+
if (message.type !== 'floless:rfis-request-step') return;
|
|
6577
|
+
// Only the document that said it is ready, for this incarnation of this project, may move the steps.
|
|
6578
|
+
if (!editorBridge || editorBridge.win !== event.source || editorBridge.projectId !== current.id
|
|
6579
|
+
|| !sameUuid(editorBridge.projectUuid, current.uuid) || !sameUuid(message.projectUuid, current.uuid)) return;
|
|
6580
|
+
const reply = (ok, reason) => {
|
|
6581
|
+
try {
|
|
6582
|
+
event.source.postMessage({ type: 'floless:rfis-step-ack', requestId: message.requestId, ok, step: currentStep,
|
|
6583
|
+
projectId: current.id, projectUuid: current.uuid || null, ...(reason ? { reason } : {}) }, location.origin);
|
|
6584
|
+
} catch (error) { console.warn('[workspaces] could not answer the steel editor', error); }
|
|
6585
|
+
};
|
|
6586
|
+
if (message.step !== 'rfis' && message.step !== 'model') { reply(false, 'That step can’t be opened from the model.'); return; }
|
|
6587
|
+
editorStepCause = typeof message.requestId === 'string' ? message.requestId : null;
|
|
6588
|
+
try {
|
|
6589
|
+
if (currentStep !== message.step) chooseStep(message.step);
|
|
6590
|
+
// Already there (the editor disagreed with the shell): say the step again, so both agree.
|
|
6591
|
+
else postStepToEditor(currentStep);
|
|
6592
|
+
} finally { editorStepCause = null; }
|
|
6593
|
+
// chooseStep may wait for the project's stages or refuse with its own toast; the editor follows `step-shown`.
|
|
6594
|
+
if (currentStep === message.step) reply(true);
|
|
6595
|
+
else reply(false, 'That step isn’t available yet. FloLess said why in its notice.');
|
|
6596
|
+
});
|
|
6597
|
+
|
|
6389
6598
|
// The Drawing Checker's "Use the design set" sends a person to this project's Knowledge step, where the design
|
|
6390
6599
|
// set lives (epic #2399 0d-dc). Only from the editor frame of the project on screen, and only to Knowledge.
|
|
6391
6600
|
window.addEventListener('message', (event) => {
|
|
@@ -6395,50 +6604,117 @@
|
|
|
6395
6604
|
setStep('knowledge');
|
|
6396
6605
|
});
|
|
6397
6606
|
const approvalPhaseText = {
|
|
6398
|
-
saving: 'Saving model edits…', comparing: 'Comparing
|
|
6399
|
-
reconciling: '
|
|
6607
|
+
saving: 'Saving your model edits…', comparing: 'Comparing with the approved version…', approving: 'Approving and compiling…',
|
|
6608
|
+
reconciling: 'Checking whether the approval finished…', approved: 'Approved', failed: 'Nothing was approved.', stale: 'The review changed.',
|
|
6400
6609
|
abandoned: 'Nothing was approved. The previous approval attempt ended safely.',
|
|
6401
6610
|
};
|
|
6402
|
-
|
|
6611
|
+
// Checking the result never needs the person: it may be closed, and FloLess keeps checking for them.
|
|
6612
|
+
const approvalDismissible = (phase) => ['saving', 'comparing', 'ready', 'failed', 'stale', 'approved', 'abandoned', 'recovery-close', 'reconciling'].includes(phase);
|
|
6403
6613
|
|
|
6404
6614
|
function setApprovalPhase(phase, message) {
|
|
6615
|
+
// Long work shows WHERE it is, not one spinner: each busy phase is a step in a short list, so a slow
|
|
6616
|
+
// compile reads as progress and never as a hang (owner report 2026-10-24, the Camden approval).
|
|
6617
|
+
const APPROVAL_STEP_LABELS = Object.freeze({
|
|
6618
|
+
save: 'Save your model edits', compare: 'Compare with the approved version',
|
|
6619
|
+
approve: 'Approve and compile', confirm: 'Confirm the result', recover: 'Check the previous approval attempt',
|
|
6620
|
+
});
|
|
6621
|
+
const APPROVAL_PHASE_STEP = Object.freeze({ saving: 'save', comparing: 'compare', approving: 'approve', reconciling: 'confirm' });
|
|
6622
|
+
const APPROVAL_FLOW_STEPS = Object.freeze({
|
|
6623
|
+
prepare: ['save', 'compare'], approve: ['save', 'compare', 'approve', 'confirm'], recover: ['recover'],
|
|
6624
|
+
});
|
|
6625
|
+
const approvalBusy = (phase) => ['saving', 'comparing', 'approving', 'reconciling'].includes(phase);
|
|
6626
|
+
const formatApprovalElapsed = (ms) => { const s = Math.max(0, Math.floor(ms / 1000)); return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`; };
|
|
6627
|
+
|
|
6628
|
+
function approvalProgressHtml(st, phase, headline) {
|
|
6629
|
+
const flow = APPROVAL_FLOW_STEPS[st.flow] || APPROVAL_FLOW_STEPS.prepare;
|
|
6630
|
+
const activeKey = st.flow === 'recover' ? 'recover' : APPROVAL_PHASE_STEP[phase];
|
|
6631
|
+
const activeIndex = Math.max(0, flow.indexOf(activeKey));
|
|
6632
|
+
const rows = flow.map((key, index) => {
|
|
6633
|
+
const state = index < activeIndex ? 'done' : index === activeIndex ? 'active' : 'waiting';
|
|
6634
|
+
const spoken = state === 'done' ? 'done' : state === 'active' ? 'in progress' : 'waiting';
|
|
6635
|
+
return `<li class="approval-step is-${state}"${state === 'active' ? ' aria-current="step"' : ''}><span class="approval-step-mark" aria-hidden="true"></span>`
|
|
6636
|
+
+ `<span class="approval-step-label">${escapeHtml(APPROVAL_STEP_LABELS[key])}</span><span class="sr-only"> (${spoken})</span></li>`;
|
|
6637
|
+
}).join('');
|
|
6638
|
+
const what = st.flow === 'approve' && st.approvingWhat ? `<p class="approval-progress-what">${escapeHtml(st.approvingWhat)}</p>` : '';
|
|
6639
|
+
return `<div class="approval-progress"><div class="approval-progress-head"><b>${escapeHtml(headline)}</b>`
|
|
6640
|
+
+ '<span class="approval-elapsed" aria-hidden="true"></span></div>'
|
|
6641
|
+
+ `${what}<ol class="approval-steps">${rows}</ol><p class="approval-progress-note" hidden></p></div>`;
|
|
6642
|
+
}
|
|
6643
|
+
|
|
6644
|
+
// The elapsed time and the "this is normal" reassurance. The timer is never announced; each
|
|
6645
|
+
// reassurance is, once. Only a real DOM gets a ticker (there is nothing to update otherwise).
|
|
6646
|
+
function tickApprovalProgress() {
|
|
6647
|
+
const st = approvalDialogState;
|
|
6648
|
+
if (!st || !approvalBusy(st.phase) || typeof $approvalBody?.querySelector !== 'function') return;
|
|
6649
|
+
const elapsed = Date.now() - (st.busySince || Date.now());
|
|
6650
|
+
const clock = $approvalBody.querySelector('.approval-elapsed');
|
|
6651
|
+
if (clock) clock.textContent = elapsed >= 3000 ? formatApprovalElapsed(elapsed) : '';
|
|
6652
|
+
const note = $approvalBody.querySelector('.approval-progress-note');
|
|
6653
|
+
const text = st.phase === 'reconciling'
|
|
6654
|
+
? (elapsed >= 4000 ? 'You can close this window. FloLess keeps checking and tells you when it knows.' : '')
|
|
6655
|
+
: elapsed >= 45000 ? 'Still working. Large models can take a few minutes.'
|
|
6656
|
+
: elapsed >= 10000 ? 'Large models can take a minute. Keep FloLess open.' : '';
|
|
6657
|
+
if (note) { note.textContent = text; note.hidden = !text; }
|
|
6658
|
+
if (text && st.announcedNote !== text && $approvalLive) { st.announcedNote = text; $approvalLive.textContent = text; }
|
|
6659
|
+
}
|
|
6660
|
+
|
|
6405
6661
|
const st = approvalDialogState;
|
|
6406
6662
|
if (!st) return;
|
|
6407
6663
|
const changed = st.phase !== phase;
|
|
6664
|
+
const wasBusy = approvalBusy(st.phase);
|
|
6408
6665
|
st.phase = phase;
|
|
6409
6666
|
if ($approvalRevisionNote) $approvalRevisionNote.hidden = !['ready', 'failed'].includes(phase);
|
|
6410
6667
|
// Recovery may be dismissed, but it must never unlock a second mutation while the durable
|
|
6411
6668
|
// outcome is pending or unreadable. Dismissibility and mutation safety are separate concerns.
|
|
6412
|
-
const locked = !approvalDismissible(phase) || ['abandoned', 'recovery-close'].includes(phase);
|
|
6669
|
+
const locked = !approvalDismissible(phase) || ['abandoned', 'recovery-close', 'reconciling'].includes(phase);
|
|
6413
6670
|
const cancelVisible = ['saving', 'comparing', 'ready', 'failed', 'stale'].includes(phase);
|
|
6671
|
+
const closeVisible = ['approved', 'abandoned', 'recovery-close'].includes(phase) || phase === 'reconciling';
|
|
6414
6672
|
const active = document.activeElement;
|
|
6415
6673
|
const activeControlWillHide = (active === $approvalCancel && !cancelVisible)
|
|
6416
6674
|
|| (active === $approvalRetry && phase !== 'failed')
|
|
6417
6675
|
|| (active === $approvalReload && phase !== 'stale')
|
|
6418
|
-
|| (active === $approvalClose && !
|
|
6676
|
+
|| (active === $approvalClose && !closeVisible)
|
|
6419
6677
|
|| (active === $approvalConfirm && !['ready', 'abandoned'].includes(phase));
|
|
6420
6678
|
if (activeControlWillHide || (locked && active && $approvalBody.contains(active))) $approvalDialog.focus();
|
|
6421
|
-
|
|
6422
|
-
|
|
6679
|
+
const busy = approvalBusy(phase);
|
|
6680
|
+
// Also when a dialog opens straight into a busy phase (a reopened check), so its clock really starts.
|
|
6681
|
+
if (busy && (!wasBusy || !st.busySince)) { st.busySince = Date.now(); st.announcedNote = ''; }
|
|
6682
|
+
const flow = APPROVAL_FLOW_STEPS[st.flow] || APPROVAL_FLOW_STEPS.prepare;
|
|
6683
|
+
const stepIndex = flow.indexOf(st.flow === 'recover' ? 'recover' : APPROVAL_PHASE_STEP[phase]);
|
|
6684
|
+
const busyText = message || approvalPhaseText[phase];
|
|
6685
|
+
// One source for the subtitle, the step list and what a screen reader hears, so they cannot disagree.
|
|
6686
|
+
const subText = busy && flow.length > 1 && stepIndex >= 0 ? `Step ${stepIndex + 1} of ${flow.length} · ${busyText}` : busyText;
|
|
6687
|
+
if (changed && $approvalLive) $approvalLive.textContent = busy ? subText : (message || approvalPhaseText[phase] || '');
|
|
6688
|
+
$approvalBody?.setAttribute('aria-busy', String(busy));
|
|
6423
6689
|
$approvalCancel.hidden = !cancelVisible;
|
|
6424
6690
|
$approvalRetry.hidden = phase !== 'failed';
|
|
6425
6691
|
$approvalReload.hidden = phase !== 'stale';
|
|
6426
|
-
$approvalClose.hidden = !
|
|
6427
|
-
|
|
6692
|
+
$approvalClose.hidden = !closeVisible;
|
|
6693
|
+
// While the approval runs, its button stays where it was and says what is happening, so the footer
|
|
6694
|
+
// never collapses into an empty strip.
|
|
6695
|
+
const working = phase === 'approving';
|
|
6696
|
+
$approvalConfirm.hidden = !['ready', 'abandoned'].includes(phase) && !working;
|
|
6697
|
+
$approvalConfirm.classList?.toggle('is-working', working);
|
|
6698
|
+
if (working) { $approvalConfirm.disabled = true; $approvalConfirm.innerHTML = '<span class="rtn-spinner" aria-hidden="true"></span>Approving…'; }
|
|
6428
6699
|
// Unlocking never re-enables a control the review blocked with a reason (nothing drawn, or a
|
|
6429
6700
|
// refusal no new choice can fix): it stays disabled, and focus skips it.
|
|
6430
6701
|
$approvalBody.querySelectorAll('[data-approval-decision],[data-approval-conflict],[data-approval-discard],[data-approval-open-audit]').forEach((node) => { node.disabled = locked || node.hasAttribute('data-blocked-reason'); });
|
|
6431
|
-
if (
|
|
6432
|
-
|
|
6433
|
-
$
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6702
|
+
if (busy) {
|
|
6703
|
+
$approvalBody.innerHTML = approvalProgressHtml(st, phase, busyText);
|
|
6704
|
+
$approvalSub.textContent = subText;
|
|
6705
|
+
if (!st.ticker && typeof $approvalBody.querySelector === 'function') {
|
|
6706
|
+
st.ticker = setInterval(tickApprovalProgress, 1000);
|
|
6707
|
+
// A display ticker never keeps a non-browser host alive (Node test harnesses run this code).
|
|
6708
|
+
st.ticker?.unref?.();
|
|
6709
|
+
}
|
|
6710
|
+
} else {
|
|
6711
|
+
if (st.ticker) { clearInterval(st.ticker); st.ticker = null; }
|
|
6712
|
+
if (['approved', 'failed', 'stale', 'abandoned', 'recovery-close'].includes(phase)) {
|
|
6713
|
+
// A terminal/recovery outcome replaces the in-flight phase visibly as well as in the live region.
|
|
6714
|
+
// Leaving "Approving and compiling…" above an Approved/failed body makes a finished command look
|
|
6715
|
+
// stuck — the exact ambiguity this state machine exists to remove.
|
|
6716
|
+
$approvalSub.textContent = message || approvalPhaseText[phase] || '';
|
|
6717
|
+
}
|
|
6442
6718
|
}
|
|
6443
6719
|
}
|
|
6444
6720
|
|
|
@@ -6535,15 +6811,81 @@
|
|
|
6535
6811
|
const approvalRefusalDetail = (sentence) => String(sentence || '').replace(/\s*Nothing was approved\.\s*/g, ' ').trim();
|
|
6536
6812
|
/** Refusals whose sentence the server writes for people. Any other error text (a bake or compile
|
|
6537
6813
|
* message, an internal conflict) stays behind the generic copy instead of reaching the screen. */
|
|
6538
|
-
const APPROVAL_REASON_CODES = ['tekla-approval-refused', 'grant-unavailable', ...IMPORT_FINDINGS_REFUSAL_CODES];
|
|
6814
|
+
const APPROVAL_REASON_CODES = ['tekla-approval-refused', 'grant-unavailable', 'approval-nothing-exportable', ...IMPORT_FINDINGS_REFUSAL_CODES];
|
|
6539
6815
|
function knownApprovalFailureReason(error) {
|
|
6540
6816
|
const body = error && error.body;
|
|
6541
6817
|
if (!body || typeof body.error !== 'string' || !body.error.trim()) return '';
|
|
6542
6818
|
return APPROVAL_REASON_CODES.includes(body.code) ? body.error.trim() : '';
|
|
6543
6819
|
}
|
|
6820
|
+
/** The raw error, for the Technical details disclosure only: never the headline of a notice. */
|
|
6821
|
+
function approvalTechnicalDetail(error) {
|
|
6822
|
+
const body = error && error.body;
|
|
6823
|
+
const text = String((body && (body.error || body.message)) || (error && error.message) || '').trim().slice(0, 300);
|
|
6824
|
+
const code = body && typeof body.code === 'string' ? body.code : '';
|
|
6825
|
+
// What AWARE itself printed, when the server passed it on (a build refusal): the line that says why.
|
|
6826
|
+
const aware = body && typeof body.reason === 'string' ? body.reason.trim().split(/\r?\n/).find((line) => line.trim()) || '' : '';
|
|
6827
|
+
return [text, code && !text.includes(code) ? `(${code})` : '', error && error.status ? `HTTP ${error.status}` : '',
|
|
6828
|
+
aware && !text.includes(aware) ? `— ${aware.trim().slice(0, 300)}` : ''].filter(Boolean).join(' ');
|
|
6829
|
+
}
|
|
6830
|
+
/**
|
|
6831
|
+
* #2767: a review or approval the server REFUSED, in the person's words: the server's own sentence when it
|
|
6832
|
+
* wrote one (`userMessage`, or a refusal code whose sentence is written for people), else plain words for
|
|
6833
|
+
* the kind of refusal, each with what to do next. The raw text goes under Technical details only.
|
|
6834
|
+
* A sentence the server wrote for people is always said, whatever the status. Otherwise null when there
|
|
6835
|
+
* was no answer or the server failed (5xx), so only an attempt that really was interrupted is described
|
|
6836
|
+
* as one. Any other refusal (`kind: 'other'`, e.g. a 409 or a 400 about the stored model) is said in
|
|
6837
|
+
* general words; the caller decides whether it outranks a plain retry.
|
|
6838
|
+
*/
|
|
6839
|
+
function approvalRefusalOf(error) {
|
|
6840
|
+
const body = error && error.body;
|
|
6841
|
+
const status = Number(error && error.status);
|
|
6842
|
+
if (!body || typeof body !== 'object' || !Number.isInteger(status) || status < 400) return null;
|
|
6843
|
+
const technical = approvalTechnicalDetail(error);
|
|
6844
|
+
const written = typeof body.userMessage === 'string' && body.userMessage.trim() ? body.userMessage.trim() : knownApprovalFailureReason(error);
|
|
6845
|
+
if (written) {
|
|
6846
|
+
// A sentence that starts a notice starts with a capital, whichever route wrote it.
|
|
6847
|
+
const reason = approvalRefusalDetail(written);
|
|
6848
|
+
return { reason: reason.charAt(0).toUpperCase() + reason.slice(1), next: '', technical };
|
|
6849
|
+
}
|
|
6850
|
+
if (status === 401) {
|
|
6851
|
+
return { reason: 'This computer is signed out, so FloLess could not approve this model.', next: 'Sign in again, then try again.', technical };
|
|
6852
|
+
}
|
|
6853
|
+
if (status === 403) {
|
|
6854
|
+
return { reason: 'FloLess couldn’t confirm that this computer may approve this project.',
|
|
6855
|
+
next: 'Sign in again, then try again. If that doesn’t help, check that your plan includes this module, or use Report an issue.', technical };
|
|
6856
|
+
}
|
|
6857
|
+
// Only a build AWARE refused is called one (the route's other 422s are not about the workflow).
|
|
6858
|
+
if (body.code === 'approval-build-failed') {
|
|
6859
|
+
return { reason: 'FloLess couldn’t build the workflow from this model, so it stopped before approving anything.',
|
|
6860
|
+
next: 'Trying again will probably give the same result. Ask the AI in the chat what went wrong, or use Report an issue; Technical details below say what FloLess saw.', technical };
|
|
6861
|
+
}
|
|
6862
|
+
if (status >= 500) return null;
|
|
6863
|
+
return { kind: 'other', reason: 'FloLess couldn’t approve this model as it is now, so it stopped before approving anything.',
|
|
6864
|
+
next: 'Start a new review to try again. If it happens again, use Report an issue; Technical details below say what FloLess saw.', technical };
|
|
6865
|
+
}
|
|
6866
|
+
/** The body of a refusal notice: the reason, what to do next, and the raw text behind a disclosure. */
|
|
6867
|
+
function approvalRefusalNoticeHtml(headline, refusal) {
|
|
6868
|
+
const tech = refusal.technical && refusal.technical !== refusal.reason
|
|
6869
|
+
? `<details class="approval-tech"><summary>Technical details</summary><div><span>${escapeHtml(refusal.technical)}</span></div></details>` : '';
|
|
6870
|
+
return `<div class="approval-notice approval-notice-error" role="alert" data-approval-refusal><b>${escapeHtml(headline)}</b> `
|
|
6871
|
+
+ `<p>${escapeHtml(refusal.reason)}${refusal.next ? ` ${escapeHtml(refusal.next)}` : ''}</p>${tech}</div>`;
|
|
6872
|
+
}
|
|
6544
6873
|
|
|
6545
6874
|
function renderApprovalReview() {
|
|
6546
6875
|
if (!approvalDialogState) return;
|
|
6876
|
+
/** A contract key as words: `read_notes` -> "read notes". */
|
|
6877
|
+
const approvalKeyWords = (key) => key.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' ').toLowerCase().trim();
|
|
6878
|
+
|
|
6879
|
+
/** The answer to "what does approving do": which version this becomes and what it replaces. */
|
|
6880
|
+
function approvalVersionCardHtml(review) {
|
|
6881
|
+
const mf = review.moveForward;
|
|
6882
|
+
const lead = mf ? (mf.replacesLatest ? `This replaces approved v${mf.toVersion}.` : `Your changes go on top of approved v${mf.toVersion} as the next approved version.`)
|
|
6883
|
+
: review.base ? `This becomes the next approved version, after approved v${review.base.version}.`
|
|
6884
|
+
: 'This becomes the first approved version of this model.';
|
|
6885
|
+
return `<div class="approval-version-card"><b>${escapeHtml(lead)}</b>`
|
|
6886
|
+
+ '<p>Approved exports and the compiled workflow use the approved version. You can keep editing the working copy afterwards.</p></div>';
|
|
6887
|
+
}
|
|
6888
|
+
|
|
6547
6889
|
const review = approvalDialogState.review;
|
|
6548
6890
|
const groups = Array.isArray(review.groups) ? review.groups : [];
|
|
6549
6891
|
const findings = review.importFindings && Number(review.importFindings.open) > 0 ? review.importFindings : null;
|
|
@@ -6563,15 +6905,29 @@
|
|
|
6563
6905
|
? review.moveForward.replacesLatest
|
|
6564
6906
|
? `This model will replace v${review.moveForward.toVersion} as the approved version`
|
|
6565
6907
|
: `Your changes from v${review.moveForward.fromVersion} will be applied on top of approved v${review.moveForward.toVersion}`
|
|
6566
|
-
: review.base ? `Compared with approved v${review.base.version}` : 'First approval
|
|
6567
|
-
|
|
6908
|
+
: review.base ? `Compared with approved v${review.base.version}` : 'First approval of this model';
|
|
6909
|
+
// A whole-model review says what it is in its version card; repeating the summary above it only adds noise.
|
|
6910
|
+
$approvalImpact.textContent = [review.selective === false ? '' : review.summary, ...(Array.isArray(review.cautions) ? review.cautions : [])].filter(Boolean).join(' ');
|
|
6911
|
+
const firstApproval = !review.base && !review.moveForward;
|
|
6568
6912
|
const groupHtml = groups.map((group) => {
|
|
6569
6913
|
const picked = decisions[group.id];
|
|
6914
|
+
// A value reads as a person would say it: a counted summary, a word or a number, never raw JSON.
|
|
6915
|
+
// A first approval has nothing before it, so it shows what the model now holds, not "— → value".
|
|
6916
|
+
const factValue = (value) => value === undefined ? '—'
|
|
6917
|
+
: value && typeof value === 'object' && typeof value.summary === 'string' ? value.summary
|
|
6918
|
+
// A small list or record is counted too: raw JSON never reaches the person, at any size.
|
|
6919
|
+
: Array.isArray(value) ? `${value.length.toLocaleString('en-US')} item${value.length === 1 ? '' : 's'}`
|
|
6920
|
+
: value && typeof value === 'object' ? `${Object.keys(value).length} field${Object.keys(value).length === 1 ? '' : 's'}`
|
|
6921
|
+
: typeof value === 'string' ? value : typeof value === 'number' || typeof value === 'boolean' ? String(value) : JSON.stringify(value);
|
|
6570
6922
|
const facts = Array.isArray(group.technicalFacts) && group.technicalFacts.length
|
|
6571
|
-
? `<details class="approval-tech"><summary>Technical details</summary>${group.technicalFacts.map((fact) => `<div><b>${escapeHtml(String(fact.label || 'Detail'))}</b> <span>${escapeHtml(
|
|
6923
|
+
? `<details class="approval-tech"><summary>Technical details</summary>${group.technicalFacts.map((fact) => `<div><b>${escapeHtml(approvalKeyWords(String(fact.label || 'Detail')))}</b> <span>${escapeHtml(firstApproval && fact.before === undefined ? factValue(fact.after) : `${factValue(fact.before)} → ${factValue(fact.after)}`)}</span></div>`).join('')}</details>` : '';
|
|
6924
|
+
// Nothing is replaced by a first approval, so a risk pill there would only alarm.
|
|
6925
|
+
const riskPill = firstApproval && review.selective === false ? ''
|
|
6926
|
+
: `<span class="approval-risk ${escapeAttr(String(group.risk || 'low'))}">${escapeHtml(String(group.risk || 'low'))}</span>`;
|
|
6927
|
+
const headline = firstApproval && review.selective === false && group.headline === 'Entire model' ? 'Everything in the model' : String(group.headline || group.category || 'Change');
|
|
6572
6928
|
const discard = review.selective ? `<button type="button" class="approval-discard" data-approval-discard="${escapeAttr(group.id)}">Discard change…</button>` : '';
|
|
6573
6929
|
return `<section class="approval-group"><div class="approval-group-head"><div>`
|
|
6574
|
-
+
|
|
6930
|
+
+ `${riskPill}<b>${escapeHtml(headline)}</b></div>`
|
|
6575
6931
|
+ `<span>${escapeHtml(String(group.location || ''))}</span></div><p>${escapeHtml(String(group.detail || ''))}</p>`
|
|
6576
6932
|
+ (review.selective === false ? '<p class="approval-whole-model">This review approves the entire model as one version. To keep working without approving, cancel this review.</p>' : `<div class="approval-decisions" role="radiogroup" aria-label="Decision for ${escapeAttr(String(group.headline || 'change'))}">`
|
|
6577
6933
|
+ ['approve', 'leave-pending'].map((decision) => approvalDecisionButtonHtml(group, decision, picked, findingsCopy, blockedReason)).join('')
|
|
@@ -6602,7 +6958,7 @@
|
|
|
6602
6958
|
: '';
|
|
6603
6959
|
const findingsHtml = nothingDrawn ? nothingDrawnHtml(nothingDrawn) : unreadable ? unreadableFindingsHtml(unreadable)
|
|
6604
6960
|
: findings ? importFindingsWarningHtml(findings, !!blockedReason) : '';
|
|
6605
|
-
$approvalBody.innerHTML = refusalHtml + findingsHtml + (groupHtml + conflictHtml || '<div class="approval-empty">No pending changes. The working copy already matches the latest approved version.</div>');
|
|
6961
|
+
$approvalBody.innerHTML = refusalHtml + findingsHtml + (groups.length ? approvalVersionCardHtml(review) : '') + (groupHtml + conflictHtml || '<div class="approval-empty">No pending changes. The working copy already matches the latest approved version.</div>');
|
|
6606
6962
|
const values = Object.values(decisions);
|
|
6607
6963
|
const approved = values.filter((value) => value === 'approve').length;
|
|
6608
6964
|
const remaining = groups.length - values.length;
|
|
@@ -6629,6 +6985,17 @@
|
|
|
6629
6985
|
const st = approvalDialogState;
|
|
6630
6986
|
if (st && !approvalDismissible(st.phase)) return;
|
|
6631
6987
|
approvalDialogState = null;
|
|
6988
|
+
if (st && st.ticker) { clearInterval(st.ticker); st.ticker = null; }
|
|
6989
|
+
// Closing while FloLess checks the result never drops the check: it carries on quietly and the
|
|
6990
|
+
// outcome arrives as a notice. The remembered operation keeps reopening on this same check.
|
|
6991
|
+
const undecided = st && !st.checking && st.phase === 'recovery-close' && st.operationId && st.operationToken;
|
|
6992
|
+
const stProject = undecided && (projects.find((candidate) => candidate.id === st.projectId) || (current && current.id === st.projectId ? current : null));
|
|
6993
|
+
const handOff = st && (st.checking || (stProject ? { project: stProject, operationId: st.operationId, operationToken: st.operationToken,
|
|
6994
|
+
refusal: st.refusalHeard || null } : null));
|
|
6995
|
+
if (handOff) {
|
|
6996
|
+
void watchApprovalOutcomeInBackground(handOff.project, handOff.operationId, handOff.operationToken, handOff.refusal || null);
|
|
6997
|
+
showToast('FloLess keeps checking whether the approval finished and will tell you here.', 'info');
|
|
6998
|
+
}
|
|
6632
6999
|
if ($approvalRevisionNoteText) $approvalRevisionNoteText.value = '';
|
|
6633
7000
|
$approvalModal.classList.remove('show');
|
|
6634
7001
|
$approvalModal.removeAttribute('aria-busy');
|
|
@@ -6815,50 +7182,95 @@
|
|
|
6815
7182
|
$quick.hidden = false;
|
|
6816
7183
|
}
|
|
6817
7184
|
|
|
6818
|
-
async function finishApprovalSuccess(res, project) {
|
|
7185
|
+
async function finishApprovalSuccess(res, project, { recovered = false } = {}) {
|
|
7186
|
+
// The dialog this outcome belongs to. A background check starts with none, and a dialog opened while this
|
|
7187
|
+
// awaits is someone else's: neither is ever painted with this result.
|
|
7188
|
+
const dialog = approvalDialogState;
|
|
6819
7189
|
const revisionNoteStatus = await finishApprovalRevisionNote(res, project);
|
|
6820
|
-
|
|
7190
|
+
// After that await the person may be on another project, or in another review: the editor and header are
|
|
7191
|
+
// touched only while this project is on screen, and the dialog only while it is still this outcome's own
|
|
7192
|
+
// dialog AND this project is on screen (opening another project does not close an open dialog).
|
|
7193
|
+
const onProject = () => !!current && current.id === project.id;
|
|
7194
|
+
const ownsDialog = () => !!dialog && approvalDialogState === dialog && onProject();
|
|
7195
|
+
if (ownsDialog() && $approvalRevisionNoteText) $approvalRevisionNoteText.value = '';
|
|
6821
7196
|
if (res && res.approvedAt) project.approvedAt = res.approvedAt;
|
|
6822
|
-
const n
|
|
6823
|
-
if (
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
7197
|
+
const { version: n, accepted, headline, assumed, quick } = approvalOutcomeWords(res);
|
|
7198
|
+
if (n) expandDiffOnce = { projectId: project.id, n };
|
|
7199
|
+
// An outcome can land while the person is editing this project again: a background check, or a dialog
|
|
7200
|
+
// closed while the note above was saving. Reloading the editor then would discard edits not yet saved, so
|
|
7201
|
+
// an editor with unsaved edits is never reloaded, whoever finishes, and the notice says so.
|
|
7202
|
+
const editorHasUnsavedEdits = () => {
|
|
7203
|
+
const win = frames.model && frames.model.contentWindow;
|
|
7204
|
+
const state = win && typeof win.contractSaveState === 'function' ? win.contractSaveState()
|
|
7205
|
+
: modelContractSaveState?.projectId === project.id && modelContractSaveState?.appId === project.app ? modelContractSaveState.state : null;
|
|
7206
|
+
return !!state && state !== 'clean';
|
|
7207
|
+
};
|
|
7208
|
+
const keptEdits = onProject() && editorHasUnsavedEdits();
|
|
7209
|
+
if (onProject() && !keptEdits) reloadModelFromServerTruth();
|
|
7210
|
+
const fresh = onProject() ? await refreshApprovalState(project.id) : null;
|
|
7211
|
+
// A recovered receipt's count is from when it was approved; edits made since are pending now, so a
|
|
7212
|
+
// recovery reports the count just read back, and when that read failed it says so (null) rather than
|
|
7213
|
+
// claiming "No changes remain pending" over work it never looked at.
|
|
7214
|
+
const pending = recovered ? (fresh && Array.isArray(fresh.groups) ? fresh.groups.length : null)
|
|
7215
|
+
: Number.isInteger(Number(res && res.pendingCount)) ? Number(res.pendingCount) : approvalState.pendingCount;
|
|
7216
|
+
const pendingUnknown = 'FloLess could not check which changes are still pending; open the review to see them.';
|
|
6827
7217
|
const saved = res && res.savedWorkCheckpoint;
|
|
6828
|
-
//
|
|
6829
|
-
//
|
|
6830
|
-
const
|
|
6831
|
-
|
|
6832
|
-
: `Approved${Number.isInteger(n) ? ` as v${n}` : ''}.`;
|
|
6833
|
-
// #2449: an approval resting on connection assumptions (or one whose record could not be read) is never announced
|
|
6834
|
-
// as a plain approval either; the server's own sentence, the same one History shows.
|
|
6835
|
-
const assumed = res && res.connectionAssumptions && typeof res.connectionAssumptions.note === 'string' ? res.connectionAssumptions.note : '';
|
|
6836
|
-
// #2521 row 5: an approved Quick model says so in the same breath, read from the approved version itself.
|
|
6837
|
-
const quick = res && res.quick && (res.quick.state === 'quick' || res.quick.state === 'unknown') && typeof res.quick.label === 'string'
|
|
6838
|
-
? `${res.quick.label}. ` : '';
|
|
6839
|
-
showToast(`${headline} ${quick}${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');
|
|
7218
|
+
// Edits still unsaved in the editor are not in any count FloLess read, so with them on screen no pending
|
|
7219
|
+
// count is claimed at all: the sentence says what is known instead.
|
|
7220
|
+
const keptEditsNote = 'Your newer edits stay in the editor and were not reloaded; once they are saved, reopen the model to see the approved version and what is still pending.';
|
|
7221
|
+
showToast(`${headline} ${quick}${assumed ? `${assumed} ` : ''}${keptEdits ? keptEditsNote : pending === null ? pendingUnknown : 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');
|
|
6840
7222
|
track('workspace_project_approved', { app: project.app });
|
|
6841
|
-
if (!$wsExports.hidden) safeRenderExports('after approving this version');
|
|
6842
|
-
if (!$wsHistory.hidden) await renderHistory();
|
|
6843
|
-
if (!
|
|
6844
|
-
$approvalImpact.textContent = pending
|
|
7223
|
+
if (onProject() && !$wsExports.hidden) safeRenderExports('after approving this version');
|
|
7224
|
+
if (onProject() && !$wsHistory.hidden) await renderHistory();
|
|
7225
|
+
if (!ownsDialog()) return;
|
|
7226
|
+
$approvalImpact.textContent = keptEdits ? keptEditsNote : pending === null ? pendingUnknown : pending
|
|
6845
7227
|
? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}.`
|
|
6846
7228
|
: 'No changes remain pending.';
|
|
6847
7229
|
// The footer described the decision ("…will be approved…"); the decision has happened.
|
|
6848
7230
|
$approvalCounts.textContent = '';
|
|
6849
|
-
$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>`;
|
|
6850
|
-
setApprovalPhase('approved', accepted ? headline : `Approved${
|
|
7231
|
+
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> ${quick ? `${escapeHtml(quick)}` : ''}The approved model and compiled workflow are ready.${assumed ? ' ' + escapeHtml(assumed) : ''}${revisionNoteStatus ? ' ' + escapeHtml(revisionNoteStatus) : ''}${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
|
|
7232
|
+
setApprovalPhase('approved', accepted ? headline : `Approved${n ? ` as v${n}` : ''}`);
|
|
6851
7233
|
$approvalClose.focus();
|
|
6852
7234
|
}
|
|
6853
7235
|
|
|
7236
|
+
/**
|
|
7237
|
+
* What the server recorded for an approval, in the words every surface uses: the dialog, its toast and the
|
|
7238
|
+
* notice for an approval that finished while another project was open. One builder, so no surface can
|
|
7239
|
+
* announce a plain approval that the record qualifies.
|
|
7240
|
+
*/
|
|
7241
|
+
function approvalOutcomeWords(res) {
|
|
7242
|
+
const n = res && res.version && Number(res.version.n);
|
|
7243
|
+
const version = Number.isInteger(n) && n > 0 ? n : null;
|
|
7244
|
+
// #1840: an approval that accepted open import findings is never announced as a plain "Approved".
|
|
7245
|
+
const accepted = res && res.version && res.version.approval && res.version.approval.acceptedImportFindings;
|
|
7246
|
+
const headline = accepted ? importFindingsCopy(accepted).approved(version) : `Approved${version ? ` as v${version}` : ''}.`;
|
|
7247
|
+
// #2449: an approval resting on connection assumptions (or one whose record could not be read) is never
|
|
7248
|
+
// announced as a plain approval either; the server's own sentence, the same one History shows.
|
|
7249
|
+
const assumed = res && res.connectionAssumptions && typeof res.connectionAssumptions.note === 'string' ? res.connectionAssumptions.note : '';
|
|
7250
|
+
// #2521 row 5: an approved Quick model says so in the same breath, read from the approved version itself.
|
|
7251
|
+
const quick = res && res.quick && (res.quick.state === 'quick' || res.quick.state === 'unknown') && typeof res.quick.label === 'string'
|
|
7252
|
+
? `${res.quick.label}. ` : '';
|
|
7253
|
+
return { version, accepted, headline, assumed, quick, sentence: `${headline} ${quick}${assumed}`.trim() };
|
|
7254
|
+
}
|
|
7255
|
+
|
|
7256
|
+
// One receipt read. The server answers under the project's approval locks, which on a large model
|
|
7257
|
+
// takes seconds even when idle (5 s measured on the Camden read, 2026-10-24); the old 4 s deadline
|
|
7258
|
+
// turned every answer into "unknown" and stranded the person on "could not be confirmed". The
|
|
7259
|
+
// deadline now only catches a request that will never answer, and an unknown answer is simply asked
|
|
7260
|
+
// again (waitForApprovalOutcome) rather than reported.
|
|
6854
7261
|
async function reconcileApprovalOperation(project, operationId, operationToken) {
|
|
6855
|
-
setApprovalPhase('reconciling');
|
|
6856
7262
|
try {
|
|
6857
7263
|
const response = await fetch(`/api/projects/${encodeURIComponent(project.id)}/approval-operations/${encodeURIComponent(operationId)}?token=${encodeURIComponent(operationToken)}`, {
|
|
6858
|
-
signal: AbortSignal.timeout(
|
|
7264
|
+
signal: AbortSignal.timeout(30000),
|
|
6859
7265
|
});
|
|
6860
7266
|
if (response.status === 404) return { status: 'not-found' };
|
|
6861
|
-
if (!response.ok)
|
|
7267
|
+
if (!response.ok) {
|
|
7268
|
+
// #2767: a refusal written for the person (e.g. module access that could not be confirmed) is
|
|
7269
|
+
// kept, so "cannot tell yet" can say what is in the way instead of guessing at it.
|
|
7270
|
+
const body = await response.json().catch(() => null);
|
|
7271
|
+
const userMessage = body && typeof body.userMessage === 'string' ? body.userMessage.trim() : '';
|
|
7272
|
+
return { status: 'unknown', httpStatus: response.status, ...(userMessage ? { userMessage } : {}) };
|
|
7273
|
+
}
|
|
6862
7274
|
const receipt = await response.json();
|
|
6863
7275
|
return receipt && ['complete', 'pending', 'abandoned'].includes(receipt.status) ? receipt : { status: 'unknown' };
|
|
6864
7276
|
} catch { return { status: 'unknown' }; }
|
|
@@ -6868,9 +7280,126 @@
|
|
|
6868
7280
|
: receipt?.status === 'abandoned' ? 'abandoned'
|
|
6869
7281
|
: receipt?.status === 'not-found' ? 'continue' : 'locked';
|
|
6870
7282
|
|
|
6871
|
-
|
|
7283
|
+
// How long the dialog keeps checking on its own before it says it still cannot tell. Checking goes on
|
|
7284
|
+
// after that too, in the background, until the person closes the window or asks again.
|
|
7285
|
+
const APPROVAL_CHECK_WINDOW_MS = 120000;
|
|
7286
|
+
const approvalSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7287
|
+
|
|
7288
|
+
/**
|
|
7289
|
+
* Ask for the operation's receipt until it is decided (complete, abandoned, or never written), backing
|
|
7290
|
+
* off 1 s, 2 s, 4 s, then every 5 s. `stillWanted()` going false ends the wait quietly with `null`: the
|
|
7291
|
+
* dialog was closed or replaced, and whoever took over asks for themselves.
|
|
7292
|
+
*/
|
|
7293
|
+
async function waitForApprovalOutcome(project, operationId, operationToken, { stillWanted, limitMs = APPROVAL_CHECK_WINDOW_MS } = {}) {
|
|
7294
|
+
const started = Date.now();
|
|
7295
|
+
let delay = 1000;
|
|
7296
|
+
for (;;) {
|
|
7297
|
+
const receipt = await reconcileApprovalOperation(project, operationId, operationToken);
|
|
7298
|
+
if (approvalRecoveryDisposition(receipt) !== 'locked') return receipt;
|
|
7299
|
+
// Signed out or refused: asking again cannot help, so hand back now and let the notice say so.
|
|
7300
|
+
if (receipt.httpStatus === 401 || receipt.httpStatus === 403) return receipt;
|
|
7301
|
+
if (stillWanted && !stillWanted()) return null;
|
|
7302
|
+
if (Date.now() - started >= limitMs) return receipt;
|
|
7303
|
+
await approvalSleep(delay);
|
|
7304
|
+
if (stillWanted && !stillWanted()) return null;
|
|
7305
|
+
delay = Math.min(delay * 2, 5000);
|
|
7306
|
+
}
|
|
7307
|
+
}
|
|
7308
|
+
|
|
7309
|
+
/**
|
|
7310
|
+
* The dialog was closed while FloLess was still checking. Keep asking, quietly, for as long as the same
|
|
7311
|
+
* project is open, then say what happened. The remembered operation stays until the outcome is known,
|
|
7312
|
+
* so reopening the review always resumes this same check and can never start a second approval.
|
|
7313
|
+
*/
|
|
7314
|
+
const approvalBackgroundWatches = new Set();
|
|
7315
|
+
async function watchApprovalOutcomeInBackground(project, operationId, operationToken, refusal = null) {
|
|
7316
|
+
if (approvalBackgroundWatches.has(operationId)) return;
|
|
7317
|
+
approvalBackgroundWatches.add(operationId);
|
|
7318
|
+
const name = String(project.name || 'this project');
|
|
7319
|
+
// A review of this same project, once reopened, takes the check over; switching to another project does not
|
|
7320
|
+
// stop it, because the person was promised an answer.
|
|
7321
|
+
const dialogOwns = () => !!approvalDialogState && approvalDialogState.projectId === project.id;
|
|
7322
|
+
try {
|
|
7323
|
+
let receipt;
|
|
7324
|
+
try {
|
|
7325
|
+
receipt = await waitForApprovalOutcome(project, operationId, operationToken, { stillWanted: () => !dialogOwns(), limitMs: 30 * 60000 });
|
|
7326
|
+
} catch {
|
|
7327
|
+
showToast(`FloLess could not read whether “${name}” was approved. Open its review to check again.`, 'warn');
|
|
7328
|
+
return;
|
|
7329
|
+
}
|
|
7330
|
+
if (!receipt || dialogOwns()) return;
|
|
7331
|
+
// From here the outcome is KNOWN: a later failure to refresh the screen never turns it back into
|
|
7332
|
+
// "could not read", and each notice says what was recorded and nothing more.
|
|
7333
|
+
const disposition = approvalRecoveryDisposition(receipt);
|
|
7334
|
+
const onScreen = !!current && current.id === project.id;
|
|
7335
|
+
if (disposition === 'complete') {
|
|
7336
|
+
if (onScreen) {
|
|
7337
|
+
try { await finishApprovalSuccess(receipt, project, { recovered: true }); }
|
|
7338
|
+
catch { showToast(`The approval of “${name}” finished, but FloLess could not refresh this screen. Reload FloLess to see the approved version.`, 'warn'); }
|
|
7339
|
+
} else {
|
|
7340
|
+
// Elsewhere: the same recorded sentence the dialog would show (findings, assumptions, Quick model
|
|
7341
|
+
// included), and the remembered operation stays so opening this project's review records it there.
|
|
7342
|
+
showToast(`“${name}”: ${approvalOutcomeWords(receipt).sentence} Open the project to see it.`, 'ok');
|
|
7343
|
+
}
|
|
7344
|
+
} else if (disposition === 'locked') {
|
|
7345
|
+
// #2767: the server's own sentence when it said why it would not answer (module access, for one).
|
|
7346
|
+
showToast(receipt.userMessage
|
|
7347
|
+
? `FloLess could not check the approval of “${name}”. ${receipt.userMessage} Then open its review to check again.`
|
|
7348
|
+
: receipt.httpStatus === 401
|
|
7349
|
+
? `FloLess could not check the approval of “${name}” because this computer is signed out. Sign in again, then open its review.`
|
|
7350
|
+
: receipt.httpStatus === 403
|
|
7351
|
+
// Refused: reopening reuses the same refused key, so point to the record that will answer.
|
|
7352
|
+
? `FloLess would not show the result of the approval of “${name}” to this window. Open its History to see whether a new version was approved.`
|
|
7353
|
+
: `FloLess still cannot confirm whether “${name}” was approved. Nothing else is approved meanwhile; open its review to check again.`, 'warn');
|
|
7354
|
+
} else {
|
|
7355
|
+
rememberApprovalOperation(project, null);
|
|
7356
|
+
// #2767: a refusal says its reason here too, never "stopped before it finished".
|
|
7357
|
+
showToast(refusal
|
|
7358
|
+
? `Nothing was approved for “${name}”. ${refusal.reason}${refusal.next ? ` ${refusal.next}` : ''}`
|
|
7359
|
+
: disposition === 'abandoned'
|
|
7360
|
+
? `Nothing was approved for “${name}”. The approval stopped before it finished, and your model is unchanged. Open the review to try again.`
|
|
7361
|
+
: `FloLess has no record that the approval of “${name}” started, so nothing was approved. Open the review to try again.`, 'warn');
|
|
7362
|
+
// The header reports its own refresh failure; the outcome above stands either way.
|
|
7363
|
+
if (onScreen) { try { await refreshApprovalState(project.id); } catch { /* reported by the header */ } }
|
|
7364
|
+
}
|
|
7365
|
+
} finally { approvalBackgroundWatches.delete(operationId); }
|
|
7366
|
+
}
|
|
7367
|
+
|
|
7368
|
+
/** Checking runs inside the dialog with its own step; a close hands it to the background watcher. */
|
|
7369
|
+
async function checkApprovalOutcome(project, operationId, operationToken, refusal = null) {
|
|
7370
|
+
const st = approvalDialogState;
|
|
7371
|
+
if (!st) return null;
|
|
7372
|
+
// The refusal travels with the check, so a close hands the background watcher the reason too.
|
|
7373
|
+
st.checking = { project, operationId, operationToken, refusal };
|
|
7374
|
+
setApprovalPhase('reconciling');
|
|
7375
|
+
const receipt = await waitForApprovalOutcome(project, operationId, operationToken, { stillWanted: () => approvalDialogState === st });
|
|
7376
|
+
if (approvalDialogState === st) st.checking = null;
|
|
7377
|
+
return receipt;
|
|
7378
|
+
}
|
|
7379
|
+
|
|
7380
|
+
function showLockedApprovalRecovery(receipt, refusal = null) {
|
|
6872
7381
|
const pending = receipt?.status === 'pending';
|
|
6873
|
-
|
|
7382
|
+
// Kept on the dialog, so "Check again" and a close (the background watcher) can still say it later.
|
|
7383
|
+
if (approvalDialogState && refusal) approvalDialogState.refusalHeard = refusal;
|
|
7384
|
+
// Signed out (401) or refused (403, e.g. this window no longer holds the approval's private key):
|
|
7385
|
+
// checking again by itself cannot help, so each says what will.
|
|
7386
|
+
const signedOut = receipt?.httpStatus === 401;
|
|
7387
|
+
const refused = receipt?.httpStatus === 403;
|
|
7388
|
+
// #2767: the server's own sentence, when it said why it would not answer (module access, for one).
|
|
7389
|
+
const said = typeof receipt?.userMessage === 'string' && receipt.userMessage ? receipt.userMessage : '';
|
|
7390
|
+
// #2767: what the approval request itself was told, when it was refused: said as what FloLess heard,
|
|
7391
|
+
// since only the recorded outcome may say whether anything was approved.
|
|
7392
|
+
const heard = refusal && refusal.reason ? `<p>The approval request was refused: ${escapeHtml(refusal.reason)}</p>` : '';
|
|
7393
|
+
$approvalBody.innerHTML = '<div class="approval-notice approval-notice-wait">'
|
|
7394
|
+
+ `<b>${pending ? 'FloLess is still finishing this approval.' : 'FloLess cannot tell yet whether this approval finished.'}</b> `
|
|
7395
|
+
+ heard
|
|
7396
|
+
+ (said ? `It could not read the result. ${escapeHtml(said)} When that is resolved, check again. `
|
|
7397
|
+
: signedOut ? 'It could not read the result because this computer is signed out. Sign in again, then check again. '
|
|
7398
|
+
: refused ? 'FloLess would not show this approval’s result to this window. Open History to see whether a new version was approved. '
|
|
7399
|
+
: 'It may already have finished on this computer; FloLess shows no result it cannot confirm, and no second approval can start meanwhile. ')
|
|
7400
|
+
+ (signedOut || refused ? '' : 'Close this window and FloLess keeps checking and tells you, or check again now.')
|
|
7401
|
+
+ '<div class="approval-notice-actions"><button type="button" class="btn-mini" data-approval-check-again data-command-id="shell.approval-check-again">Check again</button></div></div>';
|
|
7402
|
+
if ($approvalCounts) $approvalCounts.textContent = '';
|
|
6874
7403
|
setApprovalPhase('recovery-close', pending ? 'Approval recovery is still in progress.' : 'The approval result is not available yet.');
|
|
6875
7404
|
$approvalClose.focus();
|
|
6876
7405
|
}
|
|
@@ -6879,7 +7408,9 @@
|
|
|
6879
7408
|
// "Nothing was approved" is said because the reconcile answered `abandoned` (the operation was
|
|
6880
7409
|
// retired with no committed row); the reason says WHY, instead of generic recovery copy. (A refusal
|
|
6881
7410
|
// made before any write says it in the review itself; see confirmApprovalReview.)
|
|
6882
|
-
function showAbandonedApprovalRecovery(project, reason = '') {
|
|
7411
|
+
function showAbandonedApprovalRecovery(project, reason = '', technical = '') {
|
|
7412
|
+
const approvalTechHtml = (technical) => technical
|
|
7413
|
+
? `<details class="approval-tech"><summary>Technical details</summary><div><span>${escapeHtml(technical)}</span></div></details>` : '';
|
|
6883
7414
|
const st = approvalDialogState;
|
|
6884
7415
|
if (!st) return;
|
|
6885
7416
|
rememberApprovalOperation(project, null);
|
|
@@ -6892,7 +7423,10 @@
|
|
|
6892
7423
|
$approvalImpact.textContent = '';
|
|
6893
7424
|
$approvalCounts.textContent = '';
|
|
6894
7425
|
const detail = approvalRefusalDetail(reason);
|
|
6895
|
-
$approvalBody.innerHTML =
|
|
7426
|
+
$approvalBody.innerHTML = '<div class="approval-notice approval-notice-error" role="alert"><b>Nothing was approved. Your model is unchanged.</b> '
|
|
7427
|
+
+ `<p>${detail ? `${escapeHtml(detail)} ` : 'The approval stopped before it finished, so FloLess undid it and restored your working copy. '}`
|
|
7428
|
+
+ 'That attempt is finished. Start a new review to approve again.</p>'
|
|
7429
|
+
+ `${approvalTechHtml(technical && technical !== detail ? technical : '')}</div>`;
|
|
6896
7430
|
$approvalConfirm.setAttribute('data-command-id', 'shell.approval-start-new-review');
|
|
6897
7431
|
$approvalConfirm.removeAttribute('data-blocked-reason');
|
|
6898
7432
|
$approvalConfirm.textContent = 'Start a new review';
|
|
@@ -6901,6 +7435,72 @@
|
|
|
6901
7435
|
$approvalConfirm.focus();
|
|
6902
7436
|
}
|
|
6903
7437
|
|
|
7438
|
+
/**
|
|
7439
|
+
* #2767: the server refused the approval (or the review behind it) and said why. Not the "previous attempt
|
|
7440
|
+
* ended safely" panel: that presents a refusal as an interruption and sends the person round "Start a new
|
|
7441
|
+
* review" without ever telling them what stands in the way. The attempt is over all the same, so the
|
|
7442
|
+
* remembered operation is forgotten (a reopen never resumes it) and a new review is one click away.
|
|
7443
|
+
*/
|
|
7444
|
+
function showApprovalRefused(project, refusal) {
|
|
7445
|
+
const st = approvalDialogState;
|
|
7446
|
+
if (!st) return;
|
|
7447
|
+
rememberApprovalOperation(project, null);
|
|
7448
|
+
st.operationId = null;
|
|
7449
|
+
st.operationToken = null;
|
|
7450
|
+
st.decisions = {};
|
|
7451
|
+
st.conflicts = {};
|
|
7452
|
+
st.retryAction = null;
|
|
7453
|
+
$approvalImpact.textContent = '';
|
|
7454
|
+
$approvalCounts.textContent = '';
|
|
7455
|
+
$approvalBody.innerHTML = approvalRefusalNoticeHtml('Nothing was approved. Your model is unchanged.', refusal);
|
|
7456
|
+
$approvalConfirm.setAttribute('data-command-id', 'shell.approval-start-new-review');
|
|
7457
|
+
$approvalConfirm.removeAttribute('data-blocked-reason');
|
|
7458
|
+
$approvalConfirm.textContent = 'Start a new review';
|
|
7459
|
+
$approvalConfirm.disabled = false;
|
|
7460
|
+
// The same terminal phase as an ended attempt (Close, or a new review), with its own words.
|
|
7461
|
+
setApprovalPhase('abandoned', `Nothing was approved. ${refusal.reason}`);
|
|
7462
|
+
// A state label, distinct from an interrupted attempt's "ended safely"; the notice says what and why.
|
|
7463
|
+
$approvalSub.textContent = 'The approval was refused';
|
|
7464
|
+
$approvalConfirm.focus();
|
|
7465
|
+
if (typeof bridge !== 'undefined' && typeof bridge.reviewWorkflowUpdate === 'function'
|
|
7466
|
+
&& /E_APP_AGENT_PIN_UNSATISFIED/.test(refusal.technical || '')) void offerApprovalWorkflowUpdate(project, st);
|
|
7467
|
+
}
|
|
7468
|
+
|
|
7469
|
+
/** Offer the same scoped update review after a known source/tool mismatch; never repeat the approval. */
|
|
7470
|
+
async function offerApprovalWorkflowUpdate(project, dialogState) {
|
|
7471
|
+
try {
|
|
7472
|
+
const inventory = await api('/api/workflows/updates');
|
|
7473
|
+
const offer = (inventory.updates || []).find((item) => item.id === project.app);
|
|
7474
|
+
if (!offer || approvalDialogState !== dialogState || dialogState.phase !== 'abandoned') return;
|
|
7475
|
+
const notice = $approvalBody.querySelector('[data-approval-refusal]');
|
|
7476
|
+
if (!notice) return;
|
|
7477
|
+
notice.insertAdjacentHTML('beforeend', '<p>A bundled workflow update may resolve this tool mismatch. Updating does not approve your model. Afterwards return here to Review and approve.</p>'
|
|
7478
|
+
+ `<div class="approval-notice-actions"><button type="button" class="btn-mini" data-approval-workflow-update data-command-id="shell.workflow-update#approval:${escapeAttr(project.id)}:${escapeAttr(project.app)}" data-command-instance-label="${escapeAttr(project.name || project.app)}">Review workflow update</button></div>`);
|
|
7479
|
+
} catch { /* Keep the original refusal and its actionable AI Chat/report guidance if inventory is unavailable. */ }
|
|
7480
|
+
}
|
|
7481
|
+
|
|
7482
|
+
/** "Check again" on a result FloLess could not read yet: reads it again, never sends a second approval. */
|
|
7483
|
+
async function checkApprovalAgain() {
|
|
7484
|
+
const st = approvalDialogState;
|
|
7485
|
+
if (!st || st.phase !== 'recovery-close' || !st.operationId || !st.operationToken || !current || current.id !== st.projectId) return;
|
|
7486
|
+
const project = current;
|
|
7487
|
+
// #2767: the refusal the approval request got, if any, still decides how the outcome is told.
|
|
7488
|
+
const refusal = st.refusalHeard || null;
|
|
7489
|
+
try {
|
|
7490
|
+
const receipt = await checkApprovalOutcome(project, st.operationId, st.operationToken, refusal);
|
|
7491
|
+
if (!receipt || approvalDialogState !== st) return;
|
|
7492
|
+
const disposition = approvalRecoveryDisposition(receipt);
|
|
7493
|
+
if (disposition === 'complete') await finishApprovalSuccess(receipt, project, { recovered: true });
|
|
7494
|
+
else if (disposition === 'locked') showLockedApprovalRecovery(receipt, refusal);
|
|
7495
|
+
else if (refusal && (disposition === 'abandoned' || refusal.kind !== 'other')) showApprovalRefused(project, refusal);
|
|
7496
|
+
// No receipt at all is not an undo: say only what is known.
|
|
7497
|
+
else showAbandonedApprovalRecovery(project, disposition === 'continue' ? 'FloLess has no record that this approval started.' : '');
|
|
7498
|
+
} catch {
|
|
7499
|
+
// Reading the outcome failed part-way: stay on the honest "cannot tell yet" notice, never a dead dialog.
|
|
7500
|
+
if (approvalDialogState === st) showLockedApprovalRecovery({ status: 'unknown' }, refusal);
|
|
7501
|
+
}
|
|
7502
|
+
}
|
|
7503
|
+
|
|
6904
7504
|
async function startNewApprovalReview() {
|
|
6905
7505
|
const st = approvalDialogState;
|
|
6906
7506
|
if (!st || st.phase !== 'abandoned' || !current || current.id !== st.projectId) return;
|
|
@@ -6929,23 +7529,21 @@
|
|
|
6929
7529
|
$approvalConfirm.disabled = true;
|
|
6930
7530
|
// A fresh dialog starts with no blocked reason; the review's own render sets one if it needs it.
|
|
6931
7531
|
$approvalConfirm.removeAttribute('data-blocked-reason');
|
|
6932
|
-
|
|
7532
|
+
const remembered = rememberedApprovalOperation(project);
|
|
7533
|
+
approvalDialogState = { projectId: project.id, review: { groups: [] }, decisions: {}, conflicts: {}, returnFocus: document.activeElement, stale: false, phase: 'comparing',
|
|
7534
|
+
flow: remembered ? 'recover' : 'prepare' };
|
|
6933
7535
|
const dialogState = approvalDialogState;
|
|
6934
|
-
setApprovalPhase('comparing');
|
|
7536
|
+
setApprovalPhase(remembered ? 'reconciling' : 'comparing');
|
|
6935
7537
|
$approvalDialog.focus();
|
|
6936
7538
|
try {
|
|
6937
|
-
const remembered = rememberedApprovalOperation(project);
|
|
6938
7539
|
if (remembered && $approvalRevisionNoteText) { $approvalRevisionNoteText.value = remembered.revisionNoteText || ''; approvalDialogState.revisionNoteText = $approvalRevisionNoteText.value; }
|
|
6939
7540
|
if (remembered) {
|
|
6940
7541
|
approvalDialogState.operationId = remembered.operationId;
|
|
6941
7542
|
approvalDialogState.operationToken = remembered.operationToken;
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
6945
|
-
receipt = await reconcileApprovalOperation(project, remembered.operationId, remembered.operationToken);
|
|
6946
|
-
}
|
|
7543
|
+
const receipt = await checkApprovalOutcome(project, remembered.operationId, remembered.operationToken);
|
|
7544
|
+
if (!receipt || approvalDialogState !== dialogState) return;
|
|
6947
7545
|
if (approvalRecoveryDisposition(receipt) === 'complete') {
|
|
6948
|
-
await finishApprovalSuccess(receipt, project);
|
|
7546
|
+
await finishApprovalSuccess(receipt, project, { recovered: true });
|
|
6949
7547
|
return;
|
|
6950
7548
|
}
|
|
6951
7549
|
if (approvalRecoveryDisposition(receipt) === 'abandoned') {
|
|
@@ -6957,6 +7555,9 @@
|
|
|
6957
7555
|
return;
|
|
6958
7556
|
}
|
|
6959
7557
|
}
|
|
7558
|
+
// No earlier attempt to finish: this is the ordinary save-and-compare preparation.
|
|
7559
|
+
dialogState.flow = 'prepare';
|
|
7560
|
+
dialogState.busySince = Date.now();
|
|
6960
7561
|
const win = frames.model && frames.model.contentWindow;
|
|
6961
7562
|
// History is server-owned after partial approval and may hide an editor whose in-memory draft
|
|
6962
7563
|
// predates that partition. Other tabs can be reached immediately after an edit, before the
|
|
@@ -7015,10 +7616,20 @@
|
|
|
7015
7616
|
if (approvalDialogState !== dialogState) return;
|
|
7016
7617
|
approvalDialogState.stale = false;
|
|
7017
7618
|
approvalDialogState.retryAction = 'prepare';
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7619
|
+
// #2767: a review the server refused says why (module access, a signed-out computer), not "try again
|
|
7620
|
+
// when the model can be saved", which sends the person round the same refusal.
|
|
7621
|
+
const refusal = approvalRefusalOf(error);
|
|
7622
|
+
if (refusal && refusal.kind !== 'other') {
|
|
7623
|
+
$approvalImpact.textContent = '';
|
|
7624
|
+
$approvalBody.innerHTML = approvalRefusalNoticeHtml('Nothing was approved.', refusal);
|
|
7625
|
+
setApprovalPhase('failed', `Nothing was approved. ${refusal.reason}`);
|
|
7626
|
+
$approvalSub.textContent = 'FloLess could not open this review';
|
|
7627
|
+
} else {
|
|
7628
|
+
$approvalSub.textContent = 'Approval status unavailable';
|
|
7629
|
+
$approvalImpact.textContent = (error && error.message) || 'Could not load the comparison.';
|
|
7630
|
+
$approvalBody.innerHTML = '<div class="approval-notice approval-notice-error"><b>Nothing was approved.</b> Try again when the model can be saved and compared.</div>';
|
|
7631
|
+
setApprovalPhase('failed', 'Nothing was approved. Try again.');
|
|
7632
|
+
}
|
|
7022
7633
|
$approvalRetry.focus();
|
|
7023
7634
|
}
|
|
7024
7635
|
}
|
|
@@ -7055,6 +7666,20 @@
|
|
|
7055
7666
|
}
|
|
7056
7667
|
|
|
7057
7668
|
async function confirmApprovalReview() {
|
|
7669
|
+
/** What the person is approving, in one sentence, kept on screen while it runs. */
|
|
7670
|
+
function approvalWhatSentence(st) {
|
|
7671
|
+
const review = st.review || {};
|
|
7672
|
+
const groups = Array.isArray(review.groups) ? review.groups : [];
|
|
7673
|
+
const approved = Object.values(st.decisions || {}).filter((value) => value === 'approve').length;
|
|
7674
|
+
const pending = groups.length - approved;
|
|
7675
|
+
if (review.selective === false) {
|
|
7676
|
+
return review.wholeVersionReason === 'first-approval' || !review.base
|
|
7677
|
+
? 'Approving the whole model as its first approved version.'
|
|
7678
|
+
: `Approving the whole model as the next approved version after v${review.base.version}.`;
|
|
7679
|
+
}
|
|
7680
|
+
return `Approving ${approved} change${approved === 1 ? '' : 's'}${pending > 0 ? ` · ${pending} stay${pending === 1 ? 's' : ''} pending` : ''}.`;
|
|
7681
|
+
}
|
|
7682
|
+
|
|
7058
7683
|
const st = approvalDialogState;
|
|
7059
7684
|
if (!st || $approvalConfirm.disabled || !current || current.id !== st.projectId) return;
|
|
7060
7685
|
const project = current;
|
|
@@ -7077,6 +7702,10 @@
|
|
|
7077
7702
|
const findings = st.review.importFindings;
|
|
7078
7703
|
const acceptOpenImportFindings = findings && Number(findings.open) > 0 && Object.values(st.decisions).includes('approve')
|
|
7079
7704
|
? { contractHash: findings.contractHash, digest: findings.digest, open: findings.open } : null;
|
|
7705
|
+
st.flow = 'approve';
|
|
7706
|
+
st.approvingWhat = approvalWhatSentence(st);
|
|
7707
|
+
// "N changes need review" is a question the person has just answered; the step list says what runs now.
|
|
7708
|
+
$approvalImpact.textContent = '';
|
|
7080
7709
|
setApprovalPhase('approving');
|
|
7081
7710
|
$approvalConfirm.disabled = true;
|
|
7082
7711
|
st.refusal = null;
|
|
@@ -7120,17 +7749,30 @@
|
|
|
7120
7749
|
setApprovalPhase('stale', 'The review changed. Reload current review.');
|
|
7121
7750
|
$approvalReload.focus();
|
|
7122
7751
|
} else if (approvalDialogState) {
|
|
7123
|
-
|
|
7752
|
+
// #2767: a refusal the server explained is said as one, never as an interruption. Still checked
|
|
7753
|
+
// first: only the recorded outcome may say that nothing was approved.
|
|
7754
|
+
const refusal = approvalRefusalOf(error);
|
|
7755
|
+
const recovered = await checkApprovalOutcome(project, operationId, operationToken, refusal);
|
|
7756
|
+
// Closed while checking: the background watcher took the check over and will report it.
|
|
7757
|
+
if (!recovered || approvalDialogState !== st) return;
|
|
7124
7758
|
if (approvalRecoveryDisposition(recovered) === 'complete') {
|
|
7125
7759
|
await finishApprovalSuccess(recovered, project);
|
|
7126
7760
|
return;
|
|
7127
7761
|
}
|
|
7128
|
-
|
|
7129
|
-
|
|
7762
|
+
const disposition = approvalRecoveryDisposition(recovered);
|
|
7763
|
+
// Retired by the server after it answered: a refusal, never an interruption. With no record of the
|
|
7764
|
+
// attempt, only a refusal that says what to do outranks retrying the same decisions.
|
|
7765
|
+
if (refusal && (disposition === 'abandoned' || (disposition === 'continue' && refusal.kind !== 'other'))) {
|
|
7766
|
+
showApprovalRefused(project, refusal);
|
|
7767
|
+
return;
|
|
7768
|
+
}
|
|
7769
|
+
// No refusal to tell (no answer at all, or a server fault): the attempt really was interrupted.
|
|
7770
|
+
if (disposition === 'abandoned') {
|
|
7771
|
+
showAbandonedApprovalRecovery(project, '', approvalTechnicalDetail(error));
|
|
7130
7772
|
return;
|
|
7131
7773
|
}
|
|
7132
|
-
if (
|
|
7133
|
-
showLockedApprovalRecovery(recovered);
|
|
7774
|
+
if (disposition === 'locked') {
|
|
7775
|
+
showLockedApprovalRecovery(recovered, refusal);
|
|
7134
7776
|
return;
|
|
7135
7777
|
}
|
|
7136
7778
|
approvalDialogState.decisions = decisionSnapshot.decisions;
|
|
@@ -7220,6 +7862,13 @@
|
|
|
7220
7862
|
if (again) again.focus();
|
|
7221
7863
|
return;
|
|
7222
7864
|
}
|
|
7865
|
+
if (event.target.closest('[data-approval-check-again]')) { checkApprovalAgain(); return; }
|
|
7866
|
+
if (event.target.closest('[data-approval-workflow-update]') && approvalDialogState && approvalDismissible(approvalDialogState.phase)) {
|
|
7867
|
+
const appId = current?.app;
|
|
7868
|
+
closeApprovalReview();
|
|
7869
|
+
if (appId) bridge.reviewWorkflowUpdate(appId).catch((error) => showToast(error.message, 'warn'));
|
|
7870
|
+
return;
|
|
7871
|
+
}
|
|
7223
7872
|
const openAudit = event.target.closest('[data-approval-open-audit]');
|
|
7224
7873
|
if (openAudit && approvalDialogState && approvalDismissible(approvalDialogState.phase)) {
|
|
7225
7874
|
// #1840: show the findings themselves. Nothing is approved; the review can be reopened.
|
|
@@ -7300,7 +7949,8 @@
|
|
|
7300
7949
|
// model would mislead). Same-origin contentWindow call, like the Approve flush above.
|
|
7301
7950
|
function wsFindActive() {
|
|
7302
7951
|
if (!$app.classList.contains('mode-workspaces')) return false;
|
|
7303
|
-
|
|
7952
|
+
// The Model step must be showing — the same frame also shows on the RFIs step (#2470 R6.6c), where Find has no model.
|
|
7953
|
+
if (!current || frames.model.hidden || currentStep !== 'model') return false;
|
|
7304
7954
|
const w = frames.model.contentWindow;
|
|
7305
7955
|
if (!w || typeof w.findMember !== 'function') return false;
|
|
7306
7956
|
try { if (w.document.getElementById('aiUpdateBanner')) return false; } catch { return false; }
|
|
@@ -7364,8 +8014,8 @@
|
|
|
7364
8014
|
|
|
7365
8015
|
// ── Knowledge step (Slice 8 Stage B) ──────────────────────────────────────────
|
|
7366
8016
|
// The per-project Knowledge Base, References column: drop references → per-source useAsKb
|
|
7367
|
-
// toggle → remove → Organize. The UI NEVER parses a source or edits the wiki — Organize
|
|
7368
|
-
// `knowledge-organize`
|
|
8017
|
+
// toggle → remove → Organize. The UI NEVER parses a source or edits the wiki — Organize hands a
|
|
8018
|
+
// `knowledge-organize` task to project AI Chat with the floless-app-knowledge skill
|
|
7369
8019
|
// (start → compile into the server-minted wikiDir → finish). Routes: server/knowledge-routes.ts.
|
|
7370
8020
|
// The graph + note columns are Stage C/D; their area shows a forthcoming placeholder.
|
|
7371
8021
|
//
|
|
@@ -7409,6 +8059,22 @@
|
|
|
7409
8059
|
let kbAdjustBusy = null; // project id of an in-flight Adjust submit (or null) — scoped to the
|
|
7410
8060
|
// project so switching away can't strand another project's box; also the
|
|
7411
8061
|
// re-entry guard (no duplicate queue). See kbAdjustActive.
|
|
8062
|
+
let kbOrganizeBusy = null;
|
|
8063
|
+
let kbLastTaskAnnouncement = '';
|
|
8064
|
+
const kbSubmissionKey = (projectId, kind) => `floless:knowledge-submit:${projectId}:${kind}`;
|
|
8065
|
+
function kbSubmissionId(projectId, kind, prompt = '') {
|
|
8066
|
+
const key = kbSubmissionKey(projectId, kind);
|
|
8067
|
+
try {
|
|
8068
|
+
const prior = JSON.parse(sessionStorage.getItem(key) || 'null');
|
|
8069
|
+
if (prior?.id && prior.prompt === prompt) return prior.id;
|
|
8070
|
+
} catch { /* a fresh submission can still be deduplicated by the server */ }
|
|
8071
|
+
const id = crypto.randomUUID();
|
|
8072
|
+
try { sessionStorage.setItem(key, JSON.stringify({ id, prompt })); } catch { /* private mode */ }
|
|
8073
|
+
return id;
|
|
8074
|
+
}
|
|
8075
|
+
function kbSubmissionDone(projectId, kind) {
|
|
8076
|
+
try { sessionStorage.removeItem(kbSubmissionKey(projectId, kind)); } catch { /* private mode */ }
|
|
8077
|
+
}
|
|
7412
8078
|
|
|
7413
8079
|
const kbUrl = (id, tail = '') => `/api/projects/${encodeURIComponent(id)}/knowledge${tail}`;
|
|
7414
8080
|
const kbRawUrl = (id, sourceId) => kbUrl(id, `/sources/${encodeURIComponent(sourceId)}/raw`);
|
|
@@ -7462,6 +8128,7 @@
|
|
|
7462
8128
|
|
|
7463
8129
|
/** Leaving the project or the step: close the viewer and drop every cache. */
|
|
7464
8130
|
function kbResetViewer() {
|
|
8131
|
+
kbLastTaskAnnouncement = '';
|
|
7465
8132
|
setViewer({ mode: 'graph', sourceId: null });
|
|
7466
8133
|
lastRefsHtml = null;
|
|
7467
8134
|
kbFocusSourceId = null;
|
|
@@ -7509,9 +8176,10 @@
|
|
|
7509
8176
|
sources: Array.isArray(manifest.sources) ? manifest.sources : [],
|
|
7510
8177
|
currentGeneration: status.currentGeneration || null,
|
|
7511
8178
|
organize: status.organize || null,
|
|
8179
|
+
handoff: status.handoff || null,
|
|
7512
8180
|
// #2491 R6.9: the person's categories and where each reference sits.
|
|
7513
8181
|
categories: status.categories || { v: 1, revision: 0, categories: [], placements: {}, state: 'absent' },
|
|
7514
|
-
queued: list.filter((r) => r && r.type === 'knowledge-organize' && r.project === proj.id),
|
|
8182
|
+
queued: status.pendingRequests || list.filter((r) => r && r.type === 'knowledge-organize' && r.project === proj.id),
|
|
7515
8183
|
company,
|
|
7516
8184
|
designSet,
|
|
7517
8185
|
};
|
|
@@ -7519,10 +8187,12 @@
|
|
|
7519
8187
|
|
|
7520
8188
|
// Pending = started (organize.json, has startedAt) OR merely queued (a request, has createdAt).
|
|
7521
8189
|
function kbPending(st) {
|
|
7522
|
-
if (st.organize) return { started: true, since: Date.parse(st.organize.startedAt) };
|
|
7523
|
-
const q = st.queued[
|
|
8190
|
+
if (st.organize) return { started: true, since: Date.parse(st.organize.startedAt), handoff: (st.queued || []).find((r) => r.id === st.organize.requestId)?.handoff || st.handoff || null };
|
|
8191
|
+
const q = (st.queued || []).find((r) => r.type === 'knowledge-organize');
|
|
7524
8192
|
// id: which queued request Cancel deletes; wait (#2131): its start met work already changing the project.
|
|
7525
|
-
if (q) return { started: false, since: Date.parse(q.createdAt), id: q.id, wait: q.organizeWait || null
|
|
8193
|
+
if (q) return { started: false, since: Date.parse(q.createdAt), id: q.id, wait: q.organizeWait || null,
|
|
8194
|
+
retryable: q.knowledgeChat?.state !== 'accepted',
|
|
8195
|
+
handoff: q.handoff || (st.handoff?.requestId === q.id ? st.handoff : q.knowledgeChat || null) };
|
|
7526
8196
|
return null;
|
|
7527
8197
|
}
|
|
7528
8198
|
const kbAgo = (ms) => {
|
|
@@ -7753,7 +8423,8 @@
|
|
|
7753
8423
|
`<div class="kb-ds-ph" id="kb-ds-ph-${escapeAttr(issue.issueId)}">Read “${escapeHtml(issue.label)}” into the model</div>` +
|
|
7754
8424
|
`<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>` +
|
|
7755
8425
|
`<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>` +
|
|
7756
|
-
(out ? `<div class="kb-ds-lbl">Left out</div><ul class="kb-ds-out" role="list">${out}</ul>` : '') + over +
|
|
8426
|
+
(out ? `<div class="kb-ds-lbl">Left out</div><ul class="kb-ds-out" role="list">${out}</ul>` : '') + over +
|
|
8427
|
+
(kbDsPanel.build ? revisionBuildChoiceHtml(kbDsPanel.build, { idPrefix: `kb-ds-rb-${issue.issueId}`, compact: true }) : '') + err +
|
|
7757
8428
|
'<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>' +
|
|
7758
8429
|
(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>` : '') +
|
|
7759
8430
|
'</div></div>';
|
|
@@ -7766,7 +8437,8 @@
|
|
|
7766
8437
|
const files = issue.files || [];
|
|
7767
8438
|
const active = files.filter((f) => !f.withdrawn).length;
|
|
7768
8439
|
const date = issue.issuedOn ? `<span class="kb-ds-date">${escapeHtml(issue.issuedOn)}</span>` : '';
|
|
7769
|
-
const
|
|
8440
|
+
const selected = files.filter((f) => (st.sources || []).some((s) => s.sourceId === f.sourceId && s.blobSha256 === f.blobSha256 && s.useAsKb)).length;
|
|
8441
|
+
const count = `${active} file${active === 1 ? '' : 's'}${active !== files.length ? ` of ${files.length}` : ''} · ${selected} for Organize`;
|
|
7770
8442
|
const chips = (issue.current ? '<span class="kb-chip run">Current</span>' : '') + (issue.withdrawn ? '<span class="kb-chip kb-chip-wd">Withdrawn</span>' : '');
|
|
7771
8443
|
const all = kbDsShowAll.has(issue.issueId);
|
|
7772
8444
|
const shown = all ? files : files.slice(0, KB_DS_FILES_SHOWN);
|
|
@@ -7799,8 +8471,8 @@
|
|
|
7799
8471
|
'</div>';
|
|
7800
8472
|
return `<details class="kb-ds-issue${issue.current ? ' current' : ''}${issue.withdrawn ? ' wd' : ''}" data-kb-ds-issue-id="${id}"${open ? ' open' : ''}>` +
|
|
7801
8473
|
`<summary class="kb-ds-sum" data-command-id="shell.kb-design-issue-open"><span class="kb-adjust-caret" aria-hidden="true">▸</span>` +
|
|
7802
|
-
`<span class="kb-ds-line1"><span class="kb-ds-label">${escapeHtml(issue.label)}</span>${date}
|
|
7803
|
-
|
|
8474
|
+
`<span class="kb-ds-line1"><span class="kb-ds-label">${escapeHtml(issue.label)}</span>${date}</span>` +
|
|
8475
|
+
`<span class="kb-ds-line2"><span class="kb-ds-count">${escapeHtml(count)}</span>${chips}</span></summary>` +
|
|
7804
8476
|
'<div class="kb-ds-body">' +
|
|
7805
8477
|
(origin ? `<div class="kb-ds-origin">${escapeHtml(origin)}</div>` : '') + warnings +
|
|
7806
8478
|
`<ul class="kb-ds-files" role="list">${shown.map((f) => kbIssueFileRow(f, issue, st)).join('')}</ul>${more}` +
|
|
@@ -7865,7 +8537,7 @@
|
|
|
7865
8537
|
const recordWarnings = (ds.warnings || []).filter((w) => !w.issueId).map((w) =>
|
|
7866
8538
|
`<div class="kb-ds-warn-line" role="status"><span class="kb-ds-bang" aria-hidden="true">!</span><span>${escapeHtml(w.message)}</span></div>`).join('');
|
|
7867
8539
|
return `<section class="kb-src kb-ds${ds.status === 'changed' ? ' changed' : ''}" role="region" aria-labelledby="kb-ds-title">` +
|
|
7868
|
-
head(add) +
|
|
8540
|
+
head(add) + `<div class="kb-ds-sub">Each issue is one release of the drawings. ${st.sources.filter((s) => kbInDesignSet(s, st)).length} source files · included in Organize only when switched on.</div>` + recordWarnings +
|
|
7869
8541
|
kbAddIssuePanel(st) + body + '</section>';
|
|
7870
8542
|
}
|
|
7871
8543
|
|
|
@@ -8517,8 +9189,7 @@
|
|
|
8517
9189
|
const pending = kbPending(st);
|
|
8518
9190
|
const gen = st.currentGeneration;
|
|
8519
9191
|
|
|
8520
|
-
//
|
|
8521
|
-
// before that the terminal AI hasn't picked the request up yet, so no spinner.
|
|
9192
|
+
// Accepted by Chat is distinct from the server lifecycle actually starting to organize.
|
|
8522
9193
|
let pendingLine = '';
|
|
8523
9194
|
if (pending) {
|
|
8524
9195
|
const age = kbAgo(Date.now() - pending.since);
|
|
@@ -8530,25 +9201,43 @@
|
|
|
8530
9201
|
const lead = pending.started
|
|
8531
9202
|
? `Organizing…${age ? ` started ${escapeHtml(age)}` : ''}`
|
|
8532
9203
|
: pending.wait ? kbWaitLead(pending.wait)
|
|
8533
|
-
:
|
|
9204
|
+
: pending.handoff?.error ? escapeHtml(pending.handoff.error)
|
|
9205
|
+
: pending.handoff?.state === 'legacy-active' ? 'An earlier organization task is still active. Follow it with the AI that started it.'
|
|
9206
|
+
: pending.handoff?.chatId ? 'Organization sent to this project’s AI Chat — waiting to start…'
|
|
9207
|
+
: 'Organization is waiting for AI Chat. Use Retry handoff to send this saved task.';
|
|
8534
9208
|
// A queued organize (not yet started) can be cancelled — at that point there is no organize lock
|
|
8535
9209
|
// to strand, so this is the immediate, user-initiated escape from a button wedged by an organize
|
|
8536
9210
|
// no terminal AI drains (the 24h TTL sweep is the automatic backstop). It sits INSIDE the text
|
|
8537
9211
|
// span, flowing like a trailing word: the rail is too narrow to pin a separate control beside text
|
|
8538
9212
|
// that may wrap. Never offered once started — a running pass is lifecycle-owned (its finish/fail
|
|
8539
9213
|
// clears it), and the guarded DELETE route refuses it (409) anyway.
|
|
8540
|
-
const cancel = (!pending.started && pending.id)
|
|
8541
|
-
? ` <button type="button" class="kb-pending-cancel" data-kb-cancel-organize="${escapeAttr(pending.id)}" data-tip="Cancel
|
|
9214
|
+
const cancel = (!pending.started && pending.id && (!pending.handoff || pending.handoff.state === 'legacy-pending' || pending.handoff.canCancel))
|
|
9215
|
+
? ` <button type="button" class="kb-pending-cancel" data-kb-cancel-organize="${escapeAttr(pending.id)}" data-command-id="shell.kb-organize-cancel" data-tip="Cancel this saved organization task">Cancel</button>`
|
|
8542
9216
|
: '';
|
|
9217
|
+
const chat = pending.handoff?.chatId
|
|
9218
|
+
? ` <button type="button" class="kb-pending-cancel" data-kb-open-chat="${escapeAttr(pending.handoff.chatId)}" data-command-id="shell.kb-open-chat">Open chat</button>` : '';
|
|
9219
|
+
const retry = !pending.started && pending.retryable && pending.handoff?.state !== 'legacy-active' && (!pending.handoff?.chatId || pending.handoff.error)
|
|
9220
|
+
? ' <button type="button" class="kb-pending-cancel" data-kb-retry-handoff data-command-id="shell.kb-retry-handoff">Retry handoff</button>' : '';
|
|
8543
9221
|
pendingLine = `<div class="${cls}">${ico}<span>${lead}` +
|
|
8544
|
-
(stale ? ' <span class="kb-stale">
|
|
8545
|
-
cancel + '</span></div>';
|
|
9222
|
+
(stale ? ' <span class="kb-stale">Taking longer than expected — check AI Chat.</span>' : '') +
|
|
9223
|
+
chat + retry + cancel + '</span></div>';
|
|
8546
9224
|
}
|
|
8547
9225
|
|
|
9226
|
+
const adjustment = (st.queued || []).find((r) => r.type === 'knowledge-adjust');
|
|
9227
|
+
const adjustmentHandoff = adjustment && (adjustment.handoff || (st.handoff?.requestId === adjustment.id ? st.handoff : adjustment.knowledgeChat));
|
|
9228
|
+
if (!pending && adjustment) {
|
|
9229
|
+
pendingLine = '<div class="kb-pending queued"><span>' +
|
|
9230
|
+
escapeHtml(adjustmentHandoff?.error || 'Adjustment saved for this project’s AI Chat.') +
|
|
9231
|
+
(adjustmentHandoff?.chatId ? ` <button type="button" class="kb-pending-cancel" data-kb-open-chat="${escapeAttr(adjustmentHandoff.chatId)}" data-command-id="shell.kb-open-chat">Open chat</button>` : '') +
|
|
9232
|
+
(adjustment.knowledgeChat?.state !== 'accepted' && (adjustmentHandoff?.error || !adjustmentHandoff?.chatId) ? ' <button type="button" class="kb-pending-cancel" data-kb-retry-adjustment data-command-id="shell.kb-retry-adjustment">Retry handoff</button>' : '') +
|
|
9233
|
+
'</span></div>';
|
|
9234
|
+
}
|
|
8548
9235
|
let status;
|
|
8549
9236
|
if (st.sources.some((s) => s.state === 'error')) status = '<span class="err">✕ last organize failed</span>';
|
|
8550
9237
|
else if (gen) {
|
|
9238
|
+
const fresh = st.sources.filter((s) => s.useAsKb && s.state !== 'organized').length;
|
|
8551
9239
|
status = `<span class="ok">✓ organized</span> · ${escapeHtml(kbAgo(Date.now() - Date.parse(gen.publishedAt)))}` +
|
|
9240
|
+
(fresh ? ` · ${fresh} selected reference${fresh === 1 ? '' : 's'} await organization` : '') +
|
|
8552
9241
|
(st.manifest.lastLintSummary ? ` · ${escapeHtml(st.manifest.lastLintSummary)}` : '');
|
|
8553
9242
|
} else if (pending) status = ''; // the pending line already narrates it — never invite a press on the (correctly) disabled Organize
|
|
8554
9243
|
else status = st.sources.length ? 'Not yet organized — press Organize when you’re ready.' : '';
|
|
@@ -8560,30 +9249,26 @@
|
|
|
8560
9249
|
// tooltip actually fires; the click handler no-ops on it.
|
|
8561
9250
|
// The label stays plain "Organize": a pass is a FULL recompile from the truth set, so "Organize
|
|
8562
9251
|
// new" would misdescribe it.
|
|
8563
|
-
const why =
|
|
8564
|
-
:
|
|
9252
|
+
const why = kbOrganizeBusy === current?.id ? 'Sending organization to AI Chat'
|
|
9253
|
+
: pending ? 'An organization task is already saved for this project'
|
|
9254
|
+
: !st.sources.length ? 'Add a reference below the list to get started'
|
|
8565
9255
|
: enabled === 0 ? 'Turn on at least one reference to organize'
|
|
8566
|
-
: '
|
|
8567
|
-
const off = !!pending || enabled === 0 || !st.sources.length;
|
|
9256
|
+
: 'Send the selected references to this project’s AI Chat to create knowledge summaries';
|
|
9257
|
+
const off = !!pending || kbOrganizeBusy === current?.id || enabled === 0 || !st.sources.length;
|
|
8568
9258
|
const organizeBtn = `<button type="button" class="primary kb-organize" id="kb-organize"` +
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
// Adjust
|
|
8572
|
-
//
|
|
8573
|
-
// edits the wiki. A queued adjust is invisible to /status by design, so its ONLY pending signal is the
|
|
8574
|
-
// footer Requests counter; nothing here fakes per-request progress. The textarea always renders empty
|
|
8575
|
-
// and the submit disabled — the live draft/enabled state and the in-flight "Queuing…" state are
|
|
8576
|
-
// DOM-owned and never repainted away, because paintKnowledge suppresses the refs repaint while the box
|
|
8577
|
-
// is active (kbAdjustActive), so what the user is typing in / submitting is never swapped out.
|
|
9259
|
+
` data-command-id="shell.kb-organize"${off ? ` aria-disabled="true" data-blocked-reason="${escapeAttr(why)}"` : ''} data-tip="${escapeAttr(why)}">✦ Organize</button>`;
|
|
9260
|
+
|
|
9261
|
+
// Adjust uses the same project Chat handoff. The draft stays DOM-owned while the box is active,
|
|
9262
|
+
// so polling cannot erase the person's instruction or move the caret during submission.
|
|
8578
9263
|
const adjustBox = gen
|
|
8579
9264
|
? '<details class="kb-adjust">' +
|
|
8580
|
-
'<summary class="kb-adjust-summary"><span class="kb-adjust-caret" aria-hidden="true">▸</span>Adjust
|
|
9265
|
+
'<summary class="kb-adjust-summary" data-command-id="shell.kb-adjust-open"><span class="kb-adjust-caret" aria-hidden="true">▸</span>Adjust summaries</summary>' +
|
|
8581
9266
|
'<div class="kb-adjust-body">' +
|
|
8582
|
-
'<label class="kb-adjust-label" for="kb-adjust-input">Tell
|
|
8583
|
-
'<textarea id="kb-adjust-input" class="kb-adjust-input" rows="2" maxlength="2000" placeholder="e.g. “Merge the two RFI pages”"></textarea>' +
|
|
9267
|
+
'<label class="kb-adjust-label" for="kb-adjust-input">Tell AI Chat what to change</label>' +
|
|
9268
|
+
'<textarea id="kb-adjust-input" class="kb-adjust-input" data-command-id="shell.kb-adjust-input" rows="2" maxlength="2000" placeholder="e.g. “Merge the two RFI pages”"></textarea>' +
|
|
8584
9269
|
'<div class="kb-adjust-foot">' +
|
|
8585
|
-
'<span class="kb-adjust-hint">
|
|
8586
|
-
'<button type="button" class="primary kb-adjust-submit" id="kb-adjust-submit" aria-disabled="true" data-tip="Type an instruction first">✎ Adjust</button>' +
|
|
9270
|
+
'<span class="kb-adjust-hint">Sends this adjustment to the project’s AI Chat.</span>' +
|
|
9271
|
+
'<button type="button" class="primary kb-adjust-submit" id="kb-adjust-submit" data-command-id="shell.kb-adjust-submit" aria-disabled="true" data-blocked-reason="Type an instruction first" data-tip="Type an instruction first">✎ Adjust</button>' +
|
|
8587
9272
|
'</div>' +
|
|
8588
9273
|
'</div>' +
|
|
8589
9274
|
'</details>'
|
|
@@ -8640,11 +9325,25 @@
|
|
|
8640
9325
|
function kbGraphTruncatedEmpty() { return '<section class="kb-col kb-placeholder"><div class="kb-ph-inner"><span class="kb-ph-ico" aria-hidden="true">✦</span><div class="kb-ph-title">Graph incomplete</div><div class="kb-ph-sub">Some knowledge pages couldn’t be loaded, so the graph is incomplete and nothing could be shown. Click a file on the left to preview it.</div></div></section>'; }
|
|
8641
9326
|
function kbGraphEmpty(st) {
|
|
8642
9327
|
const done = st && st.currentGeneration;
|
|
9328
|
+
const sources = st?.sources || [];
|
|
9329
|
+
const enabled = sources.filter((s) => s.useAsKb).length;
|
|
9330
|
+
const pending = st && kbPending(st);
|
|
9331
|
+
const handoffFailed = pending?.handoff?.error;
|
|
9332
|
+
const failed = sources.some((s) => s.state === 'error');
|
|
9333
|
+
const title = done ? 'Nothing to graph yet' : handoffFailed ? 'Organization needs attention' : pending?.started ? 'Organizing your references' : pending ? 'Organization is pending'
|
|
9334
|
+
: failed ? 'Organization didn’t finish' : sources.length ? 'Your reference files are here' : 'Add reference files';
|
|
9335
|
+
const sub = done ? 'This project’s references are organized, but their pages aren’t linked to each other yet. Click a file on the left to preview it.'
|
|
9336
|
+
: handoffFailed ? (pending.retryable ? 'Your files are kept. Use Retry handoff, or open AI Chat to see what happened.' : 'Your files are kept. Open AI Chat to see what happened and continue the saved task.')
|
|
9337
|
+
: pending?.handoff?.state === 'legacy-active' ? 'An earlier organization task is still active. Follow it with the AI that started it. Your files are kept.'
|
|
9338
|
+
: pending?.started ? 'Your AI is creating knowledge summaries from the selected references. You can preview your files while you wait.'
|
|
9339
|
+
: pending ? (pending.handoff?.chatId ? 'Follow the organization task in this project’s AI Chat. You can preview your files while you wait.' : 'Your organization task is saved. Use Retry handoff to send it to AI Chat. You can preview your files now.')
|
|
9340
|
+
: failed ? 'Your files are kept. Use Organize to try again, or open AI Chat to see what happened.'
|
|
9341
|
+
: enabled ? `Organize the ${enabled} selected reference${enabled === 1 ? '' : 's'} to create browsable knowledge summaries. You can preview any file now.`
|
|
9342
|
+
: sources.length ? 'Turn on references to include them in Organize. Design-set files are not included automatically. You can preview any file now.'
|
|
9343
|
+
: 'Add files below the references list, then choose which ones to organize.';
|
|
8643
9344
|
return '<section class="kb-col kb-placeholder"><div class="kb-ph-inner"><span class="kb-ph-ico" aria-hidden="true">✦</span>' +
|
|
8644
|
-
'<div class="kb-ph-title">' +
|
|
8645
|
-
'<div class="kb-ph-sub">' + (
|
|
8646
|
-
? 'This project’s references are organized, but their pages aren’t linked to each other yet. Click a file on the left to preview it.'
|
|
8647
|
-
: 'No knowledge base yet — add references and Organize to build one. Click a file on the left to preview it in the meantime.') + '</div></div></section>';
|
|
9345
|
+
'<div class="kb-ph-title">' + title + '</div>' +
|
|
9346
|
+
'<div class="kb-ph-sub">' + escapeHtml(sub) + '</div></div></section>';
|
|
8648
9347
|
}
|
|
8649
9348
|
// loading + error REUSE the file viewer's own message idiom (.kb-view-msg / .kb-view-spin /
|
|
8650
9349
|
// .kb-view-ico.err / .primary Retry) so the graph's "can't show content yet" states look identical
|
|
@@ -9422,10 +10121,9 @@
|
|
|
9422
10121
|
}
|
|
9423
10122
|
|
|
9424
10123
|
function kbColumn(st) {
|
|
9425
|
-
//
|
|
10124
|
+
// One collection: issued drawings, reference groups, then upload. Presentation never changes membership.
|
|
9426
10125
|
const loose = st.sources.filter((source) => !kbInDesignSet(source, st));
|
|
9427
10126
|
const inSet = st.sources.length - loose.length;
|
|
9428
|
-
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>` : '';
|
|
9429
10127
|
// #2491 R6.9: once the first category exists the list is a tree; until then it is exactly the flat list, plus a way to
|
|
9430
10128
|
// make one. A categories file that cannot be read shows every reference flat and says so.
|
|
9431
10129
|
kbSelFor(current, st);
|
|
@@ -9433,15 +10131,17 @@
|
|
|
9433
10131
|
const newCat = kbCatUsable(st) && loose.length && !(kbCatEdit && kbCatEdit.mode === 'new' && !kbCatEdit.parentId)
|
|
9434
10132
|
? '<button type="button" class="kb-link kb-cat-new" data-kb-cat-new data-command-id="shell.kb-category-new" data-tip="Group references into categories">+ New category</button>' : '';
|
|
9435
10133
|
const flatEdit = !tree && kbCatEdit && kbCatEdit.mode === 'new' ? kbCatEditHtml(0) : '';
|
|
9436
|
-
const body =
|
|
9437
|
-
|
|
9438
|
-
|
|
10134
|
+
const body = '<div class="kb-reference-head"><h3>Reference files</h3>' + newCat + '</div>' +
|
|
10135
|
+
kbCatUnavailableHtml(st) + (loose.length
|
|
10136
|
+
? (tree ? kbTreeHtml(st, loose) : flatEdit + '<h4 class="kb-uncategorized-head">Uncategorized references</h4>' + loose.map((source) => kbSourceRow(source, st)).join(''))
|
|
10137
|
+
: '<div class="kb-empty">' + (inSet ? 'Other reference files will appear here. Drawings are listed in the Design set above.' : 'No references added yet. Add files below to get started.') + '</div>') + kbSelBarHtml(st);
|
|
10138
|
+
const selected = st.sources.filter((s) => s.useAsKb).length;
|
|
9439
10139
|
return '<section class="kb-col">' +
|
|
9440
|
-
'<div class="kb-refs-body">' + kbDesignSetStrip(st) +
|
|
10140
|
+
'<div class="kb-refs-body">' + `<div class="kb-source-summary">${st.sources.length} source${st.sources.length === 1 ? '' : 's'} · ${selected} selected for Organize</div>` + kbDesignSetStrip(st) + body +
|
|
9441
10141
|
'<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">' +
|
|
9442
10142
|
'<span class="di" aria-hidden="true">⤓</span><span class="dt">Drop references here</span>' +
|
|
9443
10143
|
'<span class="ds">PDF · Word · Excel · email · images · text</span>' +
|
|
9444
|
-
'</button>' +
|
|
10144
|
+
'</button>' +
|
|
9445
10145
|
'</div>' + kbFoot(st) + '</section>';
|
|
9446
10146
|
}
|
|
9447
10147
|
|
|
@@ -9633,7 +10333,9 @@
|
|
|
9633
10333
|
const gen = viewer.mode === 'graph' && st.currentGeneration ? st.currentGeneration.generationId : '';
|
|
9634
10334
|
// The text state too (#2491): a Word, Excel or email file whose text lands while it is open repaints with it.
|
|
9635
10335
|
const text = row && row.text ? `${row.text.state}:${row.text.blobSha256 || ''}` : '';
|
|
9636
|
-
|
|
10336
|
+
const emptyState = viewer.mode === 'graph' && !st.currentGeneration
|
|
10337
|
+
? JSON.stringify([st.sources.map((s) => [s.sourceId, s.useAsKb, s.state]), kbPending(st)]) : '';
|
|
10338
|
+
return [current && current.id, viewer.mode, viewer.sourceId || '', row ? row.blobSha256 : '', text, gen, emptyState].join('|');
|
|
9637
10339
|
}
|
|
9638
10340
|
|
|
9639
10341
|
function paintKnowledge(st) {
|
|
@@ -9642,6 +10344,10 @@
|
|
|
9642
10344
|
setViewer({ mode: 'graph', sourceId: null });
|
|
9643
10345
|
}
|
|
9644
10346
|
kbEnsureShell();
|
|
10347
|
+
const task = kbPending(st);
|
|
10348
|
+
const announcement = task?.handoff?.error || (task?.started ? 'AI Chat is organizing your references.'
|
|
10349
|
+
: task ? 'Organization is waiting to start.' : st.handoff?.error || (st.handoff?.state === 'completed' ? 'Knowledge task completed.' : ''));
|
|
10350
|
+
if (announcement !== kbLastTaskAnnouncement) { kbLastTaskAnnouncement = announcement; if (announcement) kbAnnounce(announcement); }
|
|
9645
10351
|
kbPaintStepHead(st); // the source count lives up there now, so it tracks the same state
|
|
9646
10352
|
const refsHost = $wsKnowledge.querySelector('.kb-refs-host');
|
|
9647
10353
|
const viewHost = kbViewHost();
|
|
@@ -9658,10 +10364,12 @@
|
|
|
9658
10364
|
if (html !== lastRefsHtml && !kbAdjustActive() && !kbDsPanelBusy() && !kbCatEditActive() && !kbDragIds && !kbDragHover) {
|
|
9659
10365
|
const oldBody = refsHost.querySelector('.kb-refs-body');
|
|
9660
10366
|
const scrollTop = oldBody ? oldBody.scrollTop : 0;
|
|
10367
|
+
const focusedCommand = refsHost.contains(document.activeElement) ? document.activeElement?.getAttribute('data-command-id') : null;
|
|
9661
10368
|
refsHost.innerHTML = html;
|
|
9662
10369
|
lastRefsHtml = html;
|
|
9663
10370
|
const newBody = refsHost.querySelector('.kb-refs-body');
|
|
9664
10371
|
if (newBody) newBody.scrollTop = scrollTop;
|
|
10372
|
+
if (focusedCommand) Array.from(refsHost.querySelectorAll('[data-command-id]')).find((el) => el.getAttribute('data-command-id') === focusedCommand)?.focus({ preventScroll: true });
|
|
9665
10373
|
// Selecting a row changes its HTML (it gains aria-current), so the repaint destroys the very
|
|
9666
10374
|
// button the user just clicked. Put focus back — but only when a handler asked for it, never on
|
|
9667
10375
|
// a poll tick, which must not steal focus.
|
|
@@ -10348,18 +11056,42 @@
|
|
|
10348
11056
|
|
|
10349
11057
|
async function kbOrganize() {
|
|
10350
11058
|
const proj = current;
|
|
10351
|
-
if (!proj) return;
|
|
11059
|
+
if (!proj || kbOrganizeBusy) return;
|
|
11060
|
+
kbOrganizeBusy = proj.id;
|
|
11061
|
+
const button = $wsKnowledge.querySelector('#kb-organize');
|
|
11062
|
+
if (button) { button.setAttribute('aria-disabled', 'true'); button.setAttribute('data-blocked-reason', 'Sending organization to AI Chat'); }
|
|
10352
11063
|
try {
|
|
10353
|
-
await api(kbUrl(proj.id, '/organize'), { method: 'POST', body:
|
|
11064
|
+
const result = await api(kbUrl(proj.id, '/organize'), { method: 'POST', body: JSON.stringify({ clientSubmissionId: kbSubmissionId(proj.id, 'organize') }) });
|
|
11065
|
+
kbSubmissionDone(proj.id, 'organize');
|
|
10354
11066
|
// Refresh the footer Requests counter in THIS tab — there is no server `request-added`
|
|
10355
11067
|
// broadcast, so nothing else would move the badge.
|
|
10356
11068
|
if (bridge.loadRequests) await bridge.loadRequests();
|
|
10357
|
-
showToast(
|
|
11069
|
+
showToast(result.handoff?.error || (result.handoff?.state === 'legacy-active'
|
|
11070
|
+
? 'An earlier organization task is still active. Its work has been kept.'
|
|
11071
|
+
: result.handoff?.chatId ? 'Organization sent to this project’s AI Chat' : 'Organization saved. Retry handoff to send it to AI Chat.'), result.handoff?.error ? 'warn' : 'ok');
|
|
11072
|
+
if (current?.id === proj.id && result.handoff?.chatId && bridge.openChatConversation) await bridge.openChatConversation(result.handoff.chatId);
|
|
10358
11073
|
track('kb_organize_queued', { app: proj.app });
|
|
10359
|
-
} catch { showToast('Couldn’t
|
|
11074
|
+
} catch { showToast('Couldn’t confirm delivery to AI Chat. Retry Organize to check the same task; your files are kept.', 'warn'); }
|
|
11075
|
+
finally { kbOrganizeBusy = null; }
|
|
10360
11076
|
if (current === proj) renderKnowledge();
|
|
10361
11077
|
}
|
|
10362
11078
|
|
|
11079
|
+
async function kbRetryAdjustment() {
|
|
11080
|
+
const proj = current;
|
|
11081
|
+
const saved = knowledgeState?.queued?.find((r) => r.type === 'knowledge-adjust');
|
|
11082
|
+
if (!proj || !saved?.instruction || kbAdjustBusy) return;
|
|
11083
|
+
kbAdjustBusy = proj.id;
|
|
11084
|
+
try {
|
|
11085
|
+
const result = await api(kbUrl(proj.id, '/request'), { method: 'POST', body: JSON.stringify({
|
|
11086
|
+
prompt: saved.instruction, clientSubmissionId: kbSubmissionId(proj.id, 'adjust', saved.instruction),
|
|
11087
|
+
}) });
|
|
11088
|
+
if (!result.handoff?.error) kbSubmissionDone(proj.id, 'adjust');
|
|
11089
|
+
showToast(result.handoff?.error || 'Adjustment sent to this project’s AI Chat', result.handoff?.error ? 'warn' : 'ok');
|
|
11090
|
+
if (current?.id === proj.id && result.handoff?.chatId && bridge.openChatConversation) await bridge.openChatConversation(result.handoff.chatId);
|
|
11091
|
+
} catch { showToast('Couldn’t confirm the adjustment handoff. The saved task is kept; try again.', 'warn'); }
|
|
11092
|
+
finally { kbAdjustBusy = null; if (current?.id === proj.id) renderKnowledge(); }
|
|
11093
|
+
}
|
|
11094
|
+
|
|
10363
11095
|
// Cancel a QUEUED (not-yet-started) organize via its GUARDED lifecycle route — the immediate,
|
|
10364
11096
|
// user-initiated escape from an Organize button wedged by an organize no terminal AI drained (the
|
|
10365
11097
|
// server-side 24h TTL sweep is the automatic backstop). The SERVER decides safety atomically: it
|
|
@@ -10402,8 +11134,8 @@
|
|
|
10402
11134
|
const ta = $wsKnowledge.querySelector('#kb-adjust-input');
|
|
10403
11135
|
const btn = $wsKnowledge.querySelector('#kb-adjust-submit');
|
|
10404
11136
|
if (!ta || !btn) return;
|
|
10405
|
-
if (ta.value.trim()) { btn.removeAttribute('aria-disabled'); btn.setAttribute('data-tip', '
|
|
10406
|
-
else { btn.setAttribute('aria-disabled', 'true'); btn.setAttribute('data-tip', 'Type an instruction first'); }
|
|
11137
|
+
if (ta.value.trim()) { btn.removeAttribute('aria-disabled'); btn.removeAttribute('data-blocked-reason'); btn.setAttribute('data-tip', 'Send this adjustment to the project’s AI Chat'); }
|
|
11138
|
+
else { btn.setAttribute('aria-disabled', 'true'); btn.setAttribute('data-blocked-reason', 'Type an instruction first'); btn.setAttribute('data-tip', 'Type an instruction first'); }
|
|
10407
11139
|
}
|
|
10408
11140
|
|
|
10409
11141
|
async function kbAdjustSubmit() {
|
|
@@ -10425,9 +11157,12 @@
|
|
|
10425
11157
|
kbAdjustBusy = proj.id;
|
|
10426
11158
|
ta.disabled = true; btn.disabled = true; btn.textContent = '✎ Queuing…';
|
|
10427
11159
|
let ok = false;
|
|
11160
|
+
let handoff = null;
|
|
10428
11161
|
try {
|
|
10429
|
-
await api(kbUrl(proj.id, '/request'), { method: 'POST', body: JSON.stringify({ prompt }) });
|
|
10430
|
-
|
|
11162
|
+
const result = await api(kbUrl(proj.id, '/request'), { method: 'POST', body: JSON.stringify({ prompt, clientSubmissionId: kbSubmissionId(proj.id, 'adjust', prompt) }) });
|
|
11163
|
+
handoff = result.handoff;
|
|
11164
|
+
ok = !handoff?.error;
|
|
11165
|
+
if (ok) kbSubmissionDone(proj.id, 'adjust');
|
|
10431
11166
|
if (bridge.loadRequests) await bridge.loadRequests(); // bump the footer Requests counter (nothing else moves it here)
|
|
10432
11167
|
} catch { /* the failure is reported through `ok` below — the message was never shown */ }
|
|
10433
11168
|
kbAdjustBusy = null;
|
|
@@ -10443,13 +11178,14 @@
|
|
|
10443
11178
|
kbSyncAdjustSubmit(); // empty draft → submit aria-disabled + rest tooltip
|
|
10444
11179
|
const det = ta.closest('.kb-adjust');
|
|
10445
11180
|
if (det) { det.open = false; const sum = det.querySelector('.kb-adjust-summary'); if (sum) sum.focus(); } // a11y: focus doesn't vanish
|
|
10446
|
-
showToast('Adjustment
|
|
11181
|
+
showToast('Adjustment sent to this project’s AI Chat', 'ok');
|
|
11182
|
+
if (handoff?.chatId && bridge.openChatConversation) await bridge.openChatConversation(handoff.chatId);
|
|
10447
11183
|
track('kb_adjust_queued', { app: proj.app });
|
|
10448
11184
|
} else {
|
|
10449
11185
|
ta.disabled = false; ta.focus(); // preserve the text + caret, return focus for a retry
|
|
10450
11186
|
btn.disabled = false; btn.textContent = '✎ Adjust';
|
|
10451
11187
|
kbSyncAdjustSubmit();
|
|
10452
|
-
showToast('
|
|
11188
|
+
showToast(handoff?.error || 'Couldn’t confirm delivery. Your instruction is kept here; retry to check the same task.', 'warn');
|
|
10453
11189
|
}
|
|
10454
11190
|
kbInvalidateRefs(); // the box stays active (focus) → next inactive tick settles the footer
|
|
10455
11191
|
}
|
|
@@ -10631,26 +11367,50 @@
|
|
|
10631
11367
|
const proj = current;
|
|
10632
11368
|
if (!proj) return;
|
|
10633
11369
|
kbDsOpenPanel({ kind: 'read', issueId, plan: null }, { issueId, control: '.kb-ds-panel' });
|
|
11370
|
+
// #2521 row 7b: bound to THIS panel: one closed and reopened for the same issue meanwhile is another one. The Model
|
|
11371
|
+
// preset is read in parallel with the plan; the panel shows once both are in (the preset waits 8 s at most).
|
|
11372
|
+
const panel = kbDsPanel;
|
|
11373
|
+
const presetRead = revisionBuildPreset(proj);
|
|
10634
11374
|
let plan;
|
|
10635
11375
|
try { plan = await api(`${kbDsBase(proj)}/issues/${encodeURIComponent(issueId)}/read-plan`); }
|
|
10636
11376
|
catch (err) {
|
|
10637
|
-
if (current !== proj ||
|
|
11377
|
+
if (current !== proj || kbDsPanel !== panel) return;
|
|
10638
11378
|
kbDsPanel = null;
|
|
10639
11379
|
showToast(kbDsErrorText(err, 'Couldn’t check the files of this issue. Try again.'), 'warn');
|
|
10640
11380
|
kbDsRepaint();
|
|
10641
11381
|
return;
|
|
10642
11382
|
}
|
|
10643
|
-
if (current !== proj ||
|
|
11383
|
+
if (current !== proj || kbDsPanel !== panel) return;
|
|
11384
|
+
// The same Quick / Precise choice as Attach, preset to the model's own mode.
|
|
11385
|
+
const preset = await presetRead;
|
|
11386
|
+
if (current !== proj || kbDsPanel !== panel) return;
|
|
11387
|
+
kbDsPanel.build = { mode: preset.mode, members: preset.members, note: preset.note, autoAccept: false, error: '' };
|
|
10644
11388
|
kbDsPanel.plan = plan;
|
|
10645
11389
|
kbDsPanel.chosen = new Set(plan.included.map((f) => f.index));
|
|
10646
11390
|
kbDsFocus = { issueId, control: '.kb-ds-panel input[type="checkbox"], .kb-ds-panel .btn-mini' };
|
|
10647
11391
|
kbDsRepaint();
|
|
10648
11392
|
}
|
|
10649
11393
|
|
|
11394
|
+
/** #2521 row 7b: a press (or tick) on a read panel's Model choice, kept in the panel so a repaint redraws it. */
|
|
11395
|
+
function kbDsChooseBuild(target) {
|
|
11396
|
+
if (!kbDsPanel || !kbDsPanel.build || !chooseRevisionBuild(kbDsPanel.build, target)) return false;
|
|
11397
|
+
kbDsFocus = { issueId: kbDsPanel.issueId, control: target.closest('[data-rev-build-auto]')
|
|
11398
|
+
? '.kb-ds-panel [data-rev-build-auto]' : `.kb-ds-panel [data-rev-build="${kbDsPanel.build.mode}"]` };
|
|
11399
|
+
kbDsRepaint();
|
|
11400
|
+
return true;
|
|
11401
|
+
}
|
|
11402
|
+
|
|
10650
11403
|
async function kbDsReadGo(issueId, returnFocus) {
|
|
10651
11404
|
const proj = current;
|
|
10652
11405
|
const panel = kbDsPanel;
|
|
10653
11406
|
if (!proj || !panel || panel.kind !== 'read' || !panel.plan) return;
|
|
11407
|
+
if (!panel.build || !panel.build.mode) {
|
|
11408
|
+
if (panel.build) panel.build.error = REVISION_BUILD_CHOOSE;
|
|
11409
|
+
kbDsFocus = { issueId, control: '.kb-ds-panel [data-rev-build="quick"]' };
|
|
11410
|
+
kbDsRepaint();
|
|
11411
|
+
return;
|
|
11412
|
+
}
|
|
11413
|
+
const consent = revisionBuildBody(panel.build); // what the person pressed, as of this press
|
|
10654
11414
|
const chosen = [...panel.chosen].sort((a, b) => a - b);
|
|
10655
11415
|
const asPlanned = panel.plan.chosenByDefault && chosen.length === panel.plan.included.length
|
|
10656
11416
|
&& chosen.every((n, i) => n === panel.plan.included[i].index);
|
|
@@ -10660,6 +11420,7 @@
|
|
|
10660
11420
|
: await api(`${kbDsBase(proj)}/issues/${encodeURIComponent(issueId)}/read-plan?files=${chosen.join(',')}`);
|
|
10661
11421
|
// The panel promised the ticked files (40 at most). If the server would take a different set — a copy changed
|
|
10662
11422
|
// meanwhile — show its plan instead of starting a read the person did not see.
|
|
11423
|
+
if (current !== proj || kbDsPanel !== panel) return; // cancelled or replaced while the plan was checked
|
|
10663
11424
|
const promised = chosen.slice(0, 40).join(',');
|
|
10664
11425
|
if (!asPlanned && plan.included.map((f) => f.index).join(',') !== promised) {
|
|
10665
11426
|
if (current !== proj || !kbDsPanel) return;
|
|
@@ -10671,11 +11432,11 @@
|
|
|
10671
11432
|
return;
|
|
10672
11433
|
}
|
|
10673
11434
|
const res = await api(`/api/projects/${encodeURIComponent(proj.id)}/revision-requests`, { method: 'POST',
|
|
10674
|
-
body: JSON.stringify({ appId: proj.app, designIssue: { issueId, ...(asPlanned ? {} : { files: chosen }), planKey: plan.planKey } }) });
|
|
11435
|
+
body: JSON.stringify({ appId: proj.app, designIssue: { issueId, ...(asPlanned ? {} : { files: chosen }), planKey: plan.planKey }, ...consent }) });
|
|
10675
11436
|
if (current !== proj) return;
|
|
10676
11437
|
const n = plan.included.length;
|
|
10677
11438
|
const issue = kbDsIssueById(issueId);
|
|
10678
|
-
|
|
11439
|
+
revisionQueuedToasts(res, 'Read queued', `${n} file${n === 1 ? '' : 's'} of “${(issue && issue.label) || 'the issue'}” for your terminal AI`);
|
|
10679
11440
|
track('kb_design_issue_read', { app: proj.app, n });
|
|
10680
11441
|
if (bridge.loadRequests) bridge.loadRequests().catch(() => {});
|
|
10681
11442
|
kbDsClosePanel({ issueId, control: '[data-kb-ds-read]' });
|
|
@@ -10801,6 +11562,7 @@
|
|
|
10801
11562
|
}
|
|
10802
11563
|
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; }
|
|
10803
11564
|
if ((b = t('[data-kb-ds-read]'))) { kbDsOpenRead(b.dataset.kbDsRead); return true; }
|
|
11565
|
+
if ((b = t('.kb-ds-panel [data-rev-build]')) && kbDsChooseBuild(b)) return true;
|
|
10804
11566
|
if ((b = t('[data-kb-ds-read-go]'))) { kbDsReadGo(b.dataset.kbDsReadGo, b.closest('.kb-ds-issue')?.querySelector('[data-kb-ds-read]')); return true; }
|
|
10805
11567
|
if ((b = t('[data-kb-ds-requests]'))) { if (bridge.openRequest) bridge.openRequest(null); return true; }
|
|
10806
11568
|
if ((b = t('[data-kb-ds-jump]'))) {
|
|
@@ -10813,6 +11575,7 @@
|
|
|
10813
11575
|
}
|
|
10814
11576
|
// Ticks and typing in a panel are kept in its state, so a repaint redraws them as they were.
|
|
10815
11577
|
$wsKnowledge.addEventListener('change', (e) => {
|
|
11578
|
+
if (e.target.closest('.kb-ds-panel [data-rev-build-auto]') && kbDsChooseBuild(e.target)) return;
|
|
10816
11579
|
const pick = e.target.closest('[data-kb-ds-pick], [data-kb-ds-add-pick]');
|
|
10817
11580
|
if (!pick || !kbDsPanel) return;
|
|
10818
11581
|
if (kbDsPanel.kind === 'read' && pick.dataset.kbDsPick !== undefined) {
|
|
@@ -10972,6 +11735,13 @@
|
|
|
10972
11735
|
}
|
|
10973
11736
|
const cancelOrg = e.target.closest('[data-kb-cancel-organize]');
|
|
10974
11737
|
if (cancelOrg) { kbCancelOrganize(cancelOrg.getAttribute('data-kb-cancel-organize')); return; }
|
|
11738
|
+
const openKnowledgeChat = e.target.closest('[data-kb-open-chat]');
|
|
11739
|
+
if (openKnowledgeChat) {
|
|
11740
|
+
if (bridge.openChatConversation) bridge.openChatConversation(openKnowledgeChat.dataset.kbOpenChat).catch(() => showToast('Couldn’t open AI Chat. Try again.', 'warn'));
|
|
11741
|
+
return;
|
|
11742
|
+
}
|
|
11743
|
+
if (e.target.closest('[data-kb-retry-handoff]')) { kbOrganize(); return; }
|
|
11744
|
+
if (e.target.closest('[data-kb-retry-adjustment]')) { kbRetryAdjustment(); return; }
|
|
10975
11745
|
const org = e.target.closest('#kb-organize');
|
|
10976
11746
|
if (org) { if (org.getAttribute('aria-disabled') !== 'true') kbOrganize(); return; } // aria-disabled still receives clicks
|
|
10977
11747
|
const adjBtn = e.target.closest('#kb-adjust-submit');
|
|
@@ -11242,6 +12012,16 @@
|
|
|
11242
12012
|
return `Takes ${humanRange(lo * n, hi * n)}${each}. This project's other exports wait until it finishes.`;
|
|
11243
12013
|
}
|
|
11244
12014
|
|
|
12015
|
+
/** What the Render dialog says it will draw, from the export source the person has selected. */
|
|
12016
|
+
function renderSourceSentence(source) {
|
|
12017
|
+
const kind = source && source.selector && source.selector.kind;
|
|
12018
|
+
if (kind === 'working') return 'Renders the working copy: a DRAFT, not an approved version.';
|
|
12019
|
+
if (kind === 'checkpoint') return 'Renders a saved checkpoint: a DRAFT, not an approved version.';
|
|
12020
|
+
if (kind === 'approved' && source.version) return `Renders approved version v${source.version}, not the latest.`;
|
|
12021
|
+
if (kind === 'latest-approved' && source.version) return `Renders the latest approved version, v${source.version}.`;
|
|
12022
|
+
return 'Renders the approved model.';
|
|
12023
|
+
}
|
|
12024
|
+
|
|
11245
12025
|
async function askRenderOptions(projectId) {
|
|
11246
12026
|
// `viewpoints` (plural) — the shape doExport actually reads. This said `viewpoint` and would
|
|
11247
12027
|
// have thrown on `.length` the moment it was reached.
|
|
@@ -11251,7 +12031,8 @@
|
|
|
11251
12031
|
title: 'Render image',
|
|
11252
12032
|
// The Tekla card in this same grid genuinely mutates a live host model, so users have an
|
|
11253
12033
|
// earned reason to be wary of buttons here. Say plainly that this one only reads.
|
|
11254
|
-
|
|
12034
|
+
// Names the source it will really render (#2781): the dialog used to say "the approved model" while a DRAFT was selected.
|
|
12035
|
+
sub: `${renderSourceSentence(currentExportSourceOption())} Nothing in your model changes.`,
|
|
11255
12036
|
okLabel: 'Render',
|
|
11256
12037
|
// The estimate has to be live: it is the product of two fields (how many angles × how dear
|
|
11257
12038
|
// each is), so no fixed label can state it. This is the difference between choosing five
|
|
@@ -11784,6 +12565,65 @@
|
|
|
11784
12565
|
`</span></div>`;
|
|
11785
12566
|
}
|
|
11786
12567
|
|
|
12568
|
+
/**
|
|
12569
|
+
* #2521 row 5b: the file on this card was made from a Quick (or possibly Quick) model, said after the export toast is
|
|
12570
|
+
* gone, and where the file itself carries it. Read from the file's own receipt. A picture saved without its caption
|
|
12571
|
+
* says so on a line of its own; an IFC from an older AWARE says what a newer one would add.
|
|
12572
|
+
*/
|
|
12573
|
+
function exportProvenanceHtml(kind, approved) {
|
|
12574
|
+
if (!approved || !exportState) return '';
|
|
12575
|
+
// The bill card fronts three files, each with its own receipt: each format whose file carries a label gets a line.
|
|
12576
|
+
const BOM_FORMATS = [['bom-csv', 'CSV'], ['bom-xlsx', 'Excel workbook'], ['bom-html', 'HTML report']];
|
|
12577
|
+
const kinds = kind === 'bom' ? BOM_FORMATS : omittedKindsFor(kind).map((k) => [k, '']);
|
|
12578
|
+
const files = [];
|
|
12579
|
+
for (const [k, format] of kinds) {
|
|
12580
|
+
const entry = exportState[k];
|
|
12581
|
+
if (!entry) continue;
|
|
12582
|
+
const sources = Array.isArray(entry.variants) && entry.variants.length ? entry.variants : [entry];
|
|
12583
|
+
const record = (sources.find((source) => source && source.provenance) || {}).provenance;
|
|
12584
|
+
if (!record || typeof record.label !== 'string') continue;
|
|
12585
|
+
files.push({ record, format });
|
|
12586
|
+
if (kind !== 'bom') break;
|
|
12587
|
+
}
|
|
12588
|
+
if (!files.length) return '';
|
|
12589
|
+
const carriersOf = (record) => (Array.isArray(record.carriers) ? record.carriers : []);
|
|
12590
|
+
const lines = [];
|
|
12591
|
+
// The label once when every file shares it; each file on its own line, named first, when they were exported at
|
|
12592
|
+
// different times and say different things (design review of row 5b).
|
|
12593
|
+
if (files.length > 1 && files.every((f) => f.record.label === files[0].record.label)) {
|
|
12594
|
+
const extras = files.flatMap((f) => carriersOf(f.record).filter((c) => c !== 'file-name').map((c) => provenanceWhere(c, f.format))).filter(Boolean);
|
|
12595
|
+
lines.push(`${files[0].record.label}. ${files.length === 2 ? 'Both' : `All ${files.length}`} files say so: in the file name${extras.length ? `, plus ${joinAnd(extras)}` : ''}.`);
|
|
12596
|
+
} else {
|
|
12597
|
+
if (files.length > 1) lines.push('These files were exported at different times, so they don\'t all say the same thing.');
|
|
12598
|
+
for (const f of files) {
|
|
12599
|
+
const where = carriersOf(f.record).map((c) => provenanceWhere(c, '')).filter(Boolean);
|
|
12600
|
+
lines.push(`${f.format ? `${f.format}: ` : ''}${f.record.label}. Says so in ${joinAnd(where.length ? where : ['the file name'])}.`);
|
|
12601
|
+
}
|
|
12602
|
+
}
|
|
12603
|
+
if (files.some((f) => f.record.captionDeclined)) lines.push('Rendered without the caption: the label is in the file name only.');
|
|
12604
|
+
// What to do next is a hint, not a warning: muted, so amber stays the label's alone.
|
|
12605
|
+
const hint = files.some((f) => carriersOf(f.record).includes('ifc-project-name'))
|
|
12606
|
+
? '<div class="e-receipt stale"><span>Update AWARE from the bottom bar, then export again, to also write it into the IFC header and project properties.</span></div>'
|
|
12607
|
+
: '';
|
|
12608
|
+
return `<div class="e-receipt partial"><ul class="e-receipt-lines">${lines.map((line) => `<li>${escapeHtml(line)}</li>`).join('')}</ul></div>${hint}`;
|
|
12609
|
+
}
|
|
12610
|
+
|
|
12611
|
+
/** Where a file carries its label, in the card's words; `format` names the file when several share one line. */
|
|
12612
|
+
function provenanceWhere(carrier, format) {
|
|
12613
|
+
const WHERE = {
|
|
12614
|
+
'file-name': 'the file name', 'report-banner': format ? `a note at the top of the ${format}` : 'a note at the top of the report',
|
|
12615
|
+
'xlsx-about': format ? `an About sheet in the ${format === 'Excel workbook' ? 'workbook' : format}` : 'an About sheet',
|
|
12616
|
+
'ifc-header': 'the IFC header', 'ifc-pset': 'the project properties', 'ifc-project-name': 'the IFC project name',
|
|
12617
|
+
'glb-extras': 'the 3D file metadata', 'render-caption': 'a caption drawn into the picture',
|
|
12618
|
+
};
|
|
12619
|
+
return WHERE[carrier] || '';
|
|
12620
|
+
}
|
|
12621
|
+
|
|
12622
|
+
/** "a", "a and b", "a, b and c". */
|
|
12623
|
+
function joinAnd(items) {
|
|
12624
|
+
return items.length <= 1 ? (items[0] || '') : `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`;
|
|
12625
|
+
}
|
|
12626
|
+
|
|
11787
12627
|
function receiptHtml(kind, approved) {
|
|
11788
12628
|
const receipt = approved ? currentReceipt(kind) : null;
|
|
11789
12629
|
if (!receipt) return '';
|
|
@@ -12582,6 +13422,55 @@
|
|
|
12582
13422
|
};
|
|
12583
13423
|
}
|
|
12584
13424
|
|
|
13425
|
+
// #2781: the DRAFT exports on a card, from the working copy or a saved checkpoint. Kept apart from the approved rows
|
|
13426
|
+
// above them on purpose: no tick (a tick means deliverable), a DRAFT pill, and a sentence that says what they are.
|
|
13427
|
+
const DRAFT_KIND_LABELS = {
|
|
13428
|
+
'bom-csv': 'CSV', 'bom-xlsx': 'Excel', 'bom-html': 'Report', ifc: 'IFC', svg: 'SVG',
|
|
13429
|
+
'render-png': 'Image', 'render-mp4': 'Turntable video',
|
|
13430
|
+
};
|
|
13431
|
+
const DRAFT_ROWS_SHOWN = 4;
|
|
13432
|
+
/** The DRAFT files that belong on this card, newest first (the server already sorted them). */
|
|
13433
|
+
function draftExportsFor(c) {
|
|
13434
|
+
const kinds = c.kind === 'bom' ? ['bom-csv', 'bom-xlsx', 'bom-html'] : c.kind === 'render' ? ['render-png', 'render-mp4'] : [c.kind];
|
|
13435
|
+
return exportDrafts.filter((d) => kinds.includes(d.kind));
|
|
13436
|
+
}
|
|
13437
|
+
/** "14:02" for today; "25 Oct 14:02" otherwise, so an old draft is not mistaken for a new one. */
|
|
13438
|
+
function draftWhen(iso) {
|
|
13439
|
+
const d = new Date(iso);
|
|
13440
|
+
if (isNaN(d.getTime())) return '';
|
|
13441
|
+
const now = new Date();
|
|
13442
|
+
if (d.getFullYear() === now.getFullYear() && d.getMonth() === now.getMonth() && d.getDate() === now.getDate()) return hhmm(iso);
|
|
13443
|
+
return `${d.getDate()} ${['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()]} ${hhmm(iso)}`;
|
|
13444
|
+
}
|
|
13445
|
+
function draftExportsHtml(c) {
|
|
13446
|
+
const rows = draftExportsFor(c);
|
|
13447
|
+
if (!rows.length) return '';
|
|
13448
|
+
const shown = rows.slice(0, DRAFT_ROWS_SHOWN);
|
|
13449
|
+
const head = rows[0];
|
|
13450
|
+
const from = head.source === 'checkpoint' ? 'a saved checkpoint' : 'the working copy';
|
|
13451
|
+
const named = new Map();
|
|
13452
|
+
const list = shown.map((d) => {
|
|
13453
|
+
const label = DRAFT_KIND_LABELS[d.kind] || d.kind;
|
|
13454
|
+
const when = draftWhen(d.exportedAt);
|
|
13455
|
+
// The instance names WHICH draft file, so `?` can tell two of them apart: two drafts of one kind made in the same
|
|
13456
|
+
// minute (a re-export, several viewpoints) get a number. An IFC has no Open: no default app opens one usefully,
|
|
13457
|
+
// so it is not offered rather than offered and refused.
|
|
13458
|
+
const base = `${label} draft ${when}`.trim();
|
|
13459
|
+
const nth = (named.get(base) || 0) + 1;
|
|
13460
|
+
named.set(base, nth);
|
|
13461
|
+
const instance = nth > 1 ? `${base} (${nth})` : base;
|
|
13462
|
+
const key = `draft:${d.filename}`;
|
|
13463
|
+
return `<li class="e-draft-row"><span class="e-draft-what">${escapeHtml(label)} <span class="t">${escapeHtml(when)}</span></span>` +
|
|
13464
|
+
`<span class="e-links">${d.kind === 'ifc' ? '' : fileActionButton('open', { kind: key, instance })}${fileActionButton('reveal', { kind: key, instance })}</span></li>`;
|
|
13465
|
+
}).join('');
|
|
13466
|
+
const more = rows.length > shown.length
|
|
13467
|
+
? `<div class="e-draft-more">+${rows.length - shown.length} older draft file${rows.length - shown.length === 1 ? '' : 's'} in the exports folder</div>` : '';
|
|
13468
|
+
return `<div class="e-draft" role="group" aria-label="Draft exports, not an approved version">` +
|
|
13469
|
+
`<div class="e-draft-head"><span class="e-draft-pill">DRAFT</span><span class="e-draft-cap">not an approved version</span></div>` +
|
|
13470
|
+
`<ul class="e-draft-list">${list}</ul>${more}` +
|
|
13471
|
+
`<div class="e-draft-note">Made from ${from} at ${escapeHtml(draftWhen(head.exportedAt))}. The model may have changed since.</div></div>`;
|
|
13472
|
+
}
|
|
13473
|
+
|
|
12585
13474
|
function cardHtml(c, approved) {
|
|
12586
13475
|
let meta;
|
|
12587
13476
|
const busy = exportBusy.has(`${current.id}:${c.kind}`);
|
|
@@ -12616,6 +13505,10 @@
|
|
|
12616
13505
|
meta = `<span class="e-status">not exported yet</span>`;
|
|
12617
13506
|
}
|
|
12618
13507
|
}
|
|
13508
|
+
// #2781: with DRAFT files listed below, "not exported yet" would say the opposite of what is on screen, and the
|
|
13509
|
+
// approved line is about approved versions only: say that.
|
|
13510
|
+
const drafts = draftExportsHtml(c);
|
|
13511
|
+
if (drafts && meta) meta = meta.replace('not exported yet', 'no approved export yet').replace('not rendered yet', 'no approved render yet');
|
|
12619
13512
|
const exported = approved && c.file && exportState && exportState[c.kind] && exportState[c.kind].exportedAt;
|
|
12620
13513
|
// Re-labelled once a link exists, mirroring the file kinds' "Re-export" convention. Gated on the
|
|
12621
13514
|
// in-memory record rather than exportState, which only ever tracks file exports.
|
|
@@ -12676,6 +13569,7 @@
|
|
|
12676
13569
|
`<div class="e-top"><div class="e-ico">${escapeHtml(c.ico)}</div>` +
|
|
12677
13570
|
`<div><div class="e-name">${escapeHtml(c.name)}</div><div class="e-fmt">${escapeHtml(c.fmt)}</div></div></div>` +
|
|
12678
13571
|
`<div class="e-meta${special ? ' e-meta-stacked' : ''}">${meta}</div>` +
|
|
13572
|
+
drafts +
|
|
12679
13573
|
// Only the still gets a preview: an MP4 has no frame to show without decoding one, and a
|
|
12680
13574
|
// card is not a video player. Click opens it exactly like ⧉ Open — no lightbox.
|
|
12681
13575
|
(c.kind === 'render' && approved && exportState && exportState['render-png']
|
|
@@ -12700,6 +13594,7 @@
|
|
|
12700
13594
|
// says what the producer could not emit from what it was given, this says what was never
|
|
12701
13595
|
// given to it. A model missing three heights and an AWARE weld failure are not one fact.
|
|
12702
13596
|
(c.kind === 'send-host' ? '' : omittedHtml(c.kind, approved)) +
|
|
13597
|
+
(c.kind === 'send-host' ? '' : exportProvenanceHtml(c.kind, approved)) +
|
|
12703
13598
|
// REGISTERED, because #1156a changed what this button DOES. It used to refuse an export outright
|
|
12704
13599
|
// when any member's endpoint elevation was unresolved; now the file exports build what they can
|
|
12705
13600
|
// and name what they left out, while a bake into a live host still refuses (and says why). A
|
|
@@ -12789,6 +13684,15 @@
|
|
|
12789
13684
|
const key = JSON.stringify(exportSourcesState.selected);
|
|
12790
13685
|
const found = options.find((option) => JSON.stringify(option.selector) === key);
|
|
12791
13686
|
if (found) return found;
|
|
13687
|
+
// #2781: a DRAFT choice survives an export. Exporting saves the working copy, which moves its etag/epoch, so
|
|
13688
|
+
// the exact selector no longer matches the refreshed list; the person's choice is the KIND (and which
|
|
13689
|
+
// checkpoint), and the export re-reads the live identity when it starts anyway.
|
|
13690
|
+
const want = exportSourcesState.selected;
|
|
13691
|
+
if (want.kind === 'working' || want.kind === 'checkpoint') {
|
|
13692
|
+
const kept = options.find((option) => option.selector.kind === want.kind
|
|
13693
|
+
&& (want.kind === 'working' || option.selector.checkpointId === want.checkpointId));
|
|
13694
|
+
if (kept) return kept;
|
|
13695
|
+
}
|
|
12792
13696
|
}
|
|
12793
13697
|
return options.find((option) => option.selector.kind === 'latest-approved') || null;
|
|
12794
13698
|
}
|
|
@@ -12849,11 +13753,36 @@
|
|
|
12849
13753
|
if (!source) return '';
|
|
12850
13754
|
const line = (q, scope) => (quickPillHtml(q) ? `<div class="export-quick-note" role="note"><b>${escapeHtml(scope)}:</b> ${escapeHtml(q.label)}. ${escapeHtml(q.tip || '')}</div>` : '');
|
|
12851
13755
|
const selected = line(source.quick, source.label);
|
|
13756
|
+
// #2521 row 5b: said BEFORE exporting, when this AWARE can only put a Quick model's label in an IFC's names.
|
|
13757
|
+
const ifcNamesOnly = quickPillHtml(source.quick) && exportSourcesState.data && exportSourcesState.data.exportProvenance === 'name-only'
|
|
13758
|
+
? '<div class="export-quick-note" role="note">An IFC exported now carries this label in its file name and project name only. Update AWARE from the bottom bar to also write it into the file\'s header and project properties.</div>'
|
|
13759
|
+
: '';
|
|
12852
13760
|
const from = exportStateFrom;
|
|
12853
13761
|
const files = from && from.quick && exportState && Object.values(exportState).some((e) => e && e.exportedAt)
|
|
12854
13762
|
&& !(source.selector.kind === 'latest-approved' && Number(source.version) === Number(from.version))
|
|
12855
13763
|
? line(from.quick, `Files below, exported from v${from.version}`) : '';
|
|
12856
|
-
return selected + files;
|
|
13764
|
+
return selected + ifcNamesOnly + files;
|
|
13765
|
+
}
|
|
13766
|
+
|
|
13767
|
+
/**
|
|
13768
|
+
* #2675: the listed files come from the latest approved version even while the working copy has unapproved
|
|
13769
|
+
* edits, or while another source (a DRAFT, an older version) is selected. Without this line a ✓ on a card reads as if it covered those
|
|
13770
|
+
* edits. Neutral, not a warning: the files are correct, they are just not the current draft. Silent while
|
|
13771
|
+
* the working copy is still signed off, when the files and the model agree.
|
|
13772
|
+
*/
|
|
13773
|
+
function exportedFromNoteHtml() {
|
|
13774
|
+
const from = exportStateFrom;
|
|
13775
|
+
if (!from || !Number.isInteger(Number(from.version))) return '';
|
|
13776
|
+
if (!exportState || !Object.values(exportState).some((e) => e && e.exportedAt)) return '';
|
|
13777
|
+
// Silent only when the selected source IS the version the files came from and the model has not moved on.
|
|
13778
|
+
// A DRAFT, a checkpoint or an older approved version selected is a different source from these files.
|
|
13779
|
+
const source = currentExportSourceOption();
|
|
13780
|
+
const sel = source && source.selector;
|
|
13781
|
+
const sameSource = !!sel && (sel.kind === 'latest-approved'
|
|
13782
|
+
|| (sel.kind === 'approved' && Number(sel.version) === Number(from.version)));
|
|
13783
|
+
if (current && current.approvedAt && sameSource) return '';
|
|
13784
|
+
return `<div class="exports-note exports-from-note" role="note">These files were exported from approved v${escapeHtml(String(from.version))}. ` +
|
|
13785
|
+
'Changes made since then are not in them.</div>';
|
|
12857
13786
|
}
|
|
12858
13787
|
|
|
12859
13788
|
/**
|
|
@@ -12956,6 +13885,7 @@
|
|
|
12956
13885
|
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 ` +
|
|
12957
13886
|
`is optional. Each writes to this project’s <button type="button" class="exports-note-link" data-open-exports-folder ` +
|
|
12958
13887
|
`aria-label="Open the exports folder" data-tip="Open this project’s exports folder">▤ exports</button> folder.</div>`;
|
|
13888
|
+
html += exportedFromNoteHtml();
|
|
12959
13889
|
const cards = (wsApp() && wsApp().exports) || [];
|
|
12960
13890
|
html += '<div class="export-grid">' + cards.map((c) => cardHtml(c, approved)).join('') + '</div>';
|
|
12961
13891
|
$wsExports.innerHTML = html;
|
|
@@ -13201,6 +14131,7 @@
|
|
|
13201
14131
|
let state = null;
|
|
13202
14132
|
let units = null; // the server's answer, applied below the staleness guard with the others
|
|
13203
14133
|
let filesFrom = null; // #2449: the approved version the listed files came from, same rule
|
|
14134
|
+
let draftRows = []; // #2781: the DRAFT files from the same answer
|
|
13204
14135
|
// SAYS THE THING THE GUARD MEANS. `if (units)` was correct only because the ternary above can
|
|
13205
14136
|
// never produce a falsy value — so a later, entirely reasonable "report what the server actually
|
|
13206
14137
|
// said, stop coercing" change to `units = r.units` would silently re-enable the resurrected-
|
|
@@ -13258,7 +14189,10 @@
|
|
|
13258
14189
|
if (!sourcesRefused && sourceResult.status === 'fulfilled') {
|
|
13259
14190
|
exportSourcesState.status = 'ready';
|
|
13260
14191
|
exportSourcesState.data = sourceResult.value;
|
|
13261
|
-
|
|
14192
|
+
const keptOption = currentExportSourceOption();
|
|
14193
|
+
if (!keptOption) exportSourcesState.selected = null;
|
|
14194
|
+
// #2781: a kept DRAFT choice adopts the refreshed identity, so the list highlights it and the next export freezes it.
|
|
14195
|
+
else if (exportSourcesState.selected && keptOption.selector.kind !== 'latest-approved') exportSourcesState.selected = keptOption.selector;
|
|
13262
14196
|
} else {
|
|
13263
14197
|
exportSourcesState = { status: 'unavailable', data: null, selected: null, open: false };
|
|
13264
14198
|
}
|
|
@@ -13288,6 +14222,7 @@
|
|
|
13288
14222
|
// there for why.
|
|
13289
14223
|
answered = true;
|
|
13290
14224
|
approvedAt = r.approvedAt || undefined;
|
|
14225
|
+
draftRows = Array.isArray(r.drafts) ? r.drafts.filter((d) => d && typeof d.kind === 'string' && typeof d.filename === 'string' && typeof d.path === 'string') : [];
|
|
13291
14226
|
filesFrom = r.receiptsFrom && Number.isInteger(r.receiptsFrom.version) && typeof r.receiptsFrom.hash === 'string' ? r.receiptsFrom : null;
|
|
13292
14227
|
units = r.units === 'mm' ? 'mm' : 'ft-in';
|
|
13293
14228
|
} else {
|
|
@@ -13318,6 +14253,7 @@
|
|
|
13318
14253
|
if (answered) current.approvedAt = approvedAt;
|
|
13319
14254
|
exportState = state;
|
|
13320
14255
|
exportStateFrom = answered ? filesFrom : null;
|
|
14256
|
+
exportDrafts = answered ? draftRows : [];
|
|
13321
14257
|
paintExports(approvedAt, restoreKind);
|
|
13322
14258
|
}
|
|
13323
14259
|
|
|
@@ -13368,7 +14304,7 @@
|
|
|
13368
14304
|
const result = await api(`/api/projects/${encodeURIComponent(projectId)}/export-raw`, {
|
|
13369
14305
|
method: 'POST', body: JSON.stringify({ sourceHandle: source.handleId }),
|
|
13370
14306
|
});
|
|
13371
|
-
exportSourcesState.selected = null;
|
|
14307
|
+
if (!(source.kind === 'working' || source.kind === 'checkpoint')) exportSourcesState.selected = null; // a DRAFT choice is kept (#2781)
|
|
13372
14308
|
showToast(`Exported raw package — ${result.filename}`, 'ok');
|
|
13373
14309
|
// Through the wrapper, and that is the POINT here rather than tidiness: this `await` sits
|
|
13374
14310
|
// inside a try whose catch says "Raw export failed", so a repaint bug used to be reported to
|
|
@@ -13379,6 +14315,15 @@
|
|
|
13379
14315
|
}
|
|
13380
14316
|
}
|
|
13381
14317
|
|
|
14318
|
+
/**
|
|
14319
|
+
* A failed attempt must not leave its in-memory receipt standing as this attempt's result, but a DRAFT attempt never
|
|
14320
|
+
* wrote the approved file's record in the first place (#2781), so a failed one leaves that record alone.
|
|
14321
|
+
*/
|
|
14322
|
+
function forgetExportReceiptAfterFailure(projectId, kind, source) {
|
|
14323
|
+
if (source && (source.kind === 'working' || source.kind === 'checkpoint')) return;
|
|
14324
|
+
exportReceipts.delete(`${projectId}:${kind}`);
|
|
14325
|
+
}
|
|
14326
|
+
|
|
13382
14327
|
async function doExport(kind) {
|
|
13383
14328
|
if (!current) return;
|
|
13384
14329
|
// Sending to a CAD application is its own flow end to end: it asks WHERE first, then performs
|
|
@@ -13492,9 +14437,14 @@
|
|
|
13492
14437
|
try {
|
|
13493
14438
|
// Render and the BOM are the exports whose POST carries a body — the options their modal collected.
|
|
13494
14439
|
const body = renderOptions || bomOptions;
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
14440
|
+
// #2521 row 5b: a render of a Quick model may ask how to continue (the caption). Answered here, so the render
|
|
14441
|
+
// proceeds only once the person has chosen; a cancelled question ends it, having said what was saved.
|
|
14442
|
+
const res = kind === 'render'
|
|
14443
|
+
? await postRenderAnsweringCaption(projectId, app, capturedSource.handleId, body)
|
|
14444
|
+
: await api(exportUrl(kind, projectId, app, capturedSource.handleId), body
|
|
14445
|
+
? { method: 'POST', body: JSON.stringify(body), headers: { 'content-type': 'application/json' } }
|
|
14446
|
+
: { method: 'POST' });
|
|
14447
|
+
if (res === null) { refreshing = true; return safeRenderExports('after that render'); }
|
|
13498
14448
|
if (kind === 'bom') {
|
|
13499
14449
|
// The batch answers per format. A 200 here means SOMETHING landed, not that everything did —
|
|
13500
14450
|
// so the toast names what failed rather than letting a green tick stand for a partial run, and
|
|
@@ -13509,7 +14459,10 @@
|
|
|
13509
14459
|
+ (failed[0].error || 'no reason given'),
|
|
13510
14460
|
'warn');
|
|
13511
14461
|
} else {
|
|
13512
|
-
|
|
14462
|
+
// #2521 row 5b: a bill made from a Quick (or possibly Quick) model says so; the files carry it too.
|
|
14463
|
+
const quick = (ok.find((r) => r.quick && r.quick.label) || {}).quick;
|
|
14464
|
+
showToast(`Exported — ${ok.map((r) => nameOf(r.format)).join(', ')}${quick ? ` — ${quick.label}, named in the files` : ''}`,
|
|
14465
|
+
quick && quick.state === 'unknown' ? 'warn' : 'ok');
|
|
13513
14466
|
}
|
|
13514
14467
|
// Per FORMAT, so the analytics keep the granularity the two separate cards used to give.
|
|
13515
14468
|
for (const r of ok) track('workspace_export', { app, kind: `bom-${r.format}` });
|
|
@@ -13520,15 +14473,22 @@
|
|
|
13520
14473
|
return safeRenderExports('after that bill of materials export', undefined,
|
|
13521
14474
|
() => { if (current && current.id === projectId) paintExports(current.approvedAt); });
|
|
13522
14475
|
}
|
|
13523
|
-
|
|
14476
|
+
// Non-default APPROVED sources are one-shot; a later export returns to latest approved. A DRAFT choice is kept (#2781):
|
|
14477
|
+
// the person chose it on purpose, the banner under the selector keeps saying it is unapproved, and the card lists
|
|
14478
|
+
// what it produced as DRAFT.
|
|
14479
|
+
const draftExport = capturedSource.kind === 'working' || capturedSource.kind === 'checkpoint';
|
|
14480
|
+
if (!draftExport) exportSourcesState.selected = null;
|
|
13524
14481
|
track('workspace_export', { app, kind, sourceKind: capturedSource.kind }); // a successful export/bake
|
|
13525
|
-
|
|
14482
|
+
// A DRAFT export's counts never replace the approved file's in-memory receipt (#2781): that record is what the card
|
|
14483
|
+
// shows as the approved export's counts and warnings, and a draft is not one.
|
|
14484
|
+
const receiptNow = res.counts ? {
|
|
13526
14485
|
counts: res.counts,
|
|
13527
14486
|
warnings: res.warnings || [],
|
|
13528
14487
|
unsupported: res.receipt && Array.isArray(res.receipt.unsupported) ? res.receipt.unsupported : [],
|
|
13529
14488
|
approvedAt,
|
|
13530
|
-
}
|
|
13531
|
-
|
|
14489
|
+
} : null;
|
|
14490
|
+
if (receiptNow && !draftExport) exportReceipts.set(`${projectId}:${kind}`, receiptNow);
|
|
14491
|
+
const summary = receiptSummary(draftExport ? receiptNow : exportReceipts.get(`${projectId}:${kind}`), kind);
|
|
13532
14492
|
// #1156a: an export that LEFT MEMBERS OUT must not announce itself as clean. The two sources
|
|
13533
14493
|
// are different questions - the receipt says what the producer could not emit from what it was
|
|
13534
14494
|
// given, `skippedDetail` says what was never given to it - so BOTH are gathered before a single
|
|
@@ -13539,10 +14499,12 @@
|
|
|
13539
14499
|
summary && summary.partial ? summary.text : null,
|
|
13540
14500
|
omittedNow ? `${omittedNow} member${omittedNow === 1 ? '' : 's'} left out — see the card for why` : null,
|
|
13541
14501
|
].filter(Boolean);
|
|
14502
|
+
// #2521 row 5b: a file made from a Quick (or possibly Quick) model says so here too; the file carries it as well.
|
|
14503
|
+
const quickBit = res.quick && res.quick.label ? ` — ${res.quick.label}, named in the file` : '';
|
|
13542
14504
|
showToast(gaps.length
|
|
13543
|
-
? `Exported with gaps — ${gaps.join(' · ')}`
|
|
13544
|
-
: `Exported — ${res.filename || kind}`,
|
|
13545
|
-
gaps.length ? 'warn' : 'ok');
|
|
14505
|
+
? `Exported with gaps — ${gaps.join(' · ')}${quickBit}`
|
|
14506
|
+
: `Exported — ${res.filename || kind}${quickBit}`,
|
|
14507
|
+
gaps.length || (res.quick && res.quick.state === 'unknown') ? 'warn' : 'ok');
|
|
13546
14508
|
refreshing = true;
|
|
13547
14509
|
// The catch is what makes the finally's skip safe: if the refresh itself throws, nothing else
|
|
13548
14510
|
// would repaint and the card would sit in its busy state forever, with exportBusy already
|
|
@@ -13554,7 +14516,7 @@
|
|
|
13554
14516
|
} catch (err) {
|
|
13555
14517
|
// The durable export listing may still show the previously published file, but its in-session
|
|
13556
14518
|
// receipt must not masquerade as the result of this failed attempt.
|
|
13557
|
-
|
|
14519
|
+
forgetExportReceiptAfterFailure(projectId, kind, capturedSource);
|
|
13558
14520
|
// The render route ships machine-readable readiness on its 409 precisely so the card can
|
|
13559
14521
|
// show WHICH dependency broke. Dropping it left the card looking ready with an enabled
|
|
13560
14522
|
// button, and the only trace of the refusal was a toast that evaporates.
|
|
@@ -13588,6 +14550,66 @@
|
|
|
13588
14550
|
}
|
|
13589
14551
|
}
|
|
13590
14552
|
|
|
14553
|
+
/**
|
|
14554
|
+
* #2521 row 5b: POST a render, answering the question a Quick model's render asks when the renderer cannot draw the
|
|
14555
|
+
* Quick model caption (owner ruling 2026-10-24: ask, default update). Each answer renders the same frozen version
|
|
14556
|
+
* the server handed back; pictures already saved stay saved. Resolves the render's answer, or null when the person
|
|
14557
|
+
* cancelled (after saying what was and was not saved).
|
|
14558
|
+
*/
|
|
14559
|
+
async function postRenderAnsweringCaption(projectId, app, handleId, body) {
|
|
14560
|
+
let handle = handleId;
|
|
14561
|
+
let request = body;
|
|
14562
|
+
let saved = 0;
|
|
14563
|
+
for (;;) {
|
|
14564
|
+
try {
|
|
14565
|
+
return await api(exportUrl('render', projectId, app, handle),
|
|
14566
|
+
{ method: 'POST', body: JSON.stringify(request), headers: { 'content-type': 'application/json' } });
|
|
14567
|
+
} catch (err) {
|
|
14568
|
+
const ask = err && err.body && err.body.needsChoice === 'caption' ? err.body : null;
|
|
14569
|
+
if (!ask) throw err;
|
|
14570
|
+
saved += Array.isArray(ask.rendered) ? ask.rendered.length : 0;
|
|
14571
|
+
const choice = await askRenderCaption(ask, projectId, saved);
|
|
14572
|
+
if (!choice) {
|
|
14573
|
+
try { await releaseCapturedSources(projectId, [ask.sourceHandle]); } catch { /* it expires on its own */ }
|
|
14574
|
+
const pending = Array.isArray(ask.pending) && ask.pending.length ? ask.pending : request.viewpoints || [];
|
|
14575
|
+
showToast(saved
|
|
14576
|
+
? `Render stopped. ${saved} ${saved === 1 ? 'picture is' : 'pictures are'} saved; ${pending.join(', ')} ${pending.length === 1 ? 'was' : 'were'} not saved.`
|
|
14577
|
+
: 'Render stopped. Nothing was rendered.', 'info');
|
|
14578
|
+
return null;
|
|
14579
|
+
}
|
|
14580
|
+
handle = ask.sourceHandle;
|
|
14581
|
+
request = {
|
|
14582
|
+
...request,
|
|
14583
|
+
...(Array.isArray(ask.pending) && ask.pending.length ? { viewpoints: ask.pending } : {}),
|
|
14584
|
+
...(choice === 'without-caption' ? { withoutCaption: true } : {}),
|
|
14585
|
+
};
|
|
14586
|
+
}
|
|
14587
|
+
}
|
|
14588
|
+
}
|
|
14589
|
+
|
|
14590
|
+
/** The caption question itself. Resolves 'update', 'without-caption', or null when cancelled. */
|
|
14591
|
+
async function askRenderCaption(ask, projectId, saved) {
|
|
14592
|
+
if (!bridge.formModal) return null;
|
|
14593
|
+
const chosen = await bridge.formModal({
|
|
14594
|
+
title: 'Quick model caption',
|
|
14595
|
+
sub: `${ask.message} Nothing more is rendered until you choose${saved ? `, and the ${saved === 1 ? 'picture' : 'pictures'} already saved stay saved` : ''}.`,
|
|
14596
|
+
okLabel: 'Continue',
|
|
14597
|
+
returnFocusTo: $wsExports.querySelector('[data-export="render"]'),
|
|
14598
|
+
returnFocusFallback: () => (current && current.id === projectId
|
|
14599
|
+
? $wsExports.querySelector('[data-export="render"]')
|
|
14600
|
+
: null),
|
|
14601
|
+
fields: [{
|
|
14602
|
+
name: 'choice', label: 'How to continue', type: 'select', value: 'update', commandId: 'shell.render-caption-choice',
|
|
14603
|
+
options: [
|
|
14604
|
+
{ value: 'update', label: 'Update the renderer', meta: 'Recommended · tries again now' },
|
|
14605
|
+
{ value: 'without-caption', label: 'Render without the caption', meta: 'The label goes in the file name only. This is recorded.' },
|
|
14606
|
+
],
|
|
14607
|
+
}],
|
|
14608
|
+
});
|
|
14609
|
+
if (!chosen) return null;
|
|
14610
|
+
return chosen.choice === 'without-caption' ? 'without-caption' : 'update';
|
|
14611
|
+
}
|
|
14612
|
+
|
|
13591
14613
|
function showExportReceiptDetails(kind, returnFocusTo) {
|
|
13592
14614
|
const projectId = current && current.id;
|
|
13593
14615
|
const summary = receiptSummary(currentReceipt(kind), kind);
|
|
@@ -13698,9 +14720,13 @@
|
|
|
13698
14720
|
* most recent.
|
|
13699
14721
|
*/
|
|
13700
14722
|
async function fileAction(endpoint, kind, failMsg) {
|
|
13701
|
-
|
|
14723
|
+
// #2781: a DRAFT file is found by its own file name in the draft list, never through the approved rows.
|
|
14724
|
+
const draftName = String(kind).startsWith('draft:') ? String(kind).slice(6) : null;
|
|
14725
|
+
const [baseKind, variant] = draftName ? ['draft', ''] : String(kind).split(':');
|
|
13702
14726
|
const row = exportState && exportState[baseKind];
|
|
13703
|
-
const st =
|
|
14727
|
+
const st = draftName
|
|
14728
|
+
? exportDrafts.find((d) => d.filename === draftName)
|
|
14729
|
+
: variant && row && Array.isArray(row.variants)
|
|
13704
14730
|
? row.variants.find((v) => v.variant === variant)
|
|
13705
14731
|
: row;
|
|
13706
14732
|
if (!st || !st.path) return; // button only shows when a path exists; belt-and-braces
|
|
@@ -13829,6 +14855,10 @@
|
|
|
13829
14855
|
// no SSE hook — and refreshes History on completion. Cards are DOM-built (textContent, never
|
|
13830
14856
|
// innerHTML) so an AI-supplied error string can never reach the DOM as markup.
|
|
13831
14857
|
let lastRevState = 'none';
|
|
14858
|
+
// #2816: 'none' above also means "the request list has not answered for this project yet". Only a
|
|
14859
|
+
// list that HAS answered may say the earlier drawing request is gone; before that, a pending read
|
|
14860
|
+
// (live, just written by the reader's shell PUT) would be reported as missing.
|
|
14861
|
+
let revisionListKnown = false;
|
|
13832
14862
|
// A reconstruction refusal is permanent for that immutable staged generation. Remember it for this
|
|
13833
14863
|
// browser session so the 3-second request poll cannot resurrect a Review action that the server has
|
|
13834
14864
|
// already proved will never work. The exact stage id keeps a later replacement generation eligible.
|
|
@@ -13875,13 +14905,17 @@
|
|
|
13875
14905
|
* miss without widening that window — an unknown project falls back to 0, exactly as a cold page
|
|
13876
14906
|
* load always has.
|
|
13877
14907
|
*/
|
|
14908
|
+
let revisionBuildAsk = null; // #2521 row 7b: the open confirm step after the file picker, if any (askRevisionBuild)
|
|
13878
14909
|
function resetRevisionState() {
|
|
13879
14910
|
lastRevState = 'none';
|
|
14911
|
+
revisionListKnown = false;
|
|
13880
14912
|
revCardReq = null;
|
|
13881
14913
|
$revisionCard._renderKey = '';
|
|
13882
14914
|
revisionGen++; // voids any render still in flight for the project being left
|
|
13883
14915
|
revisionRequestsSuccessGen = revisionGen; // old same-id failures cannot cross a close/re-open boundary
|
|
13884
14916
|
revisionOwnerGen++; // voids Attach/Copy work, without letting a routine poll do so
|
|
14917
|
+
if (revisionBuildAsk) revisionBuildAsk.close(null); // #2521 row 7b: its choice was for the project being left
|
|
14918
|
+
if (kbDsPanel && kbDsPanel.kind === 'read') kbDsPanel = null; // …and so was a design-set read panel's preset
|
|
13885
14919
|
stopRevisionPoll();
|
|
13886
14920
|
$revisionCard.hidden = true;
|
|
13887
14921
|
$revisionCard.replaceChildren();
|
|
@@ -14001,16 +15035,192 @@
|
|
|
14001
15035
|
}
|
|
14002
15036
|
}
|
|
14003
15037
|
|
|
14004
|
-
|
|
14005
|
-
|
|
15038
|
+
/**
|
|
15039
|
+
* #2521 row 7b: how a read of drawings into an existing Steel model project builds the model. The person chooses Quick
|
|
15040
|
+
* or Precise, preset to the working copy's own mode (the copy a re-read changes): Quick only when the model readably is
|
|
15041
|
+
* one. A model that reads "Possibly Quick model", or whose mode FloLess could not check, presets nothing and the person
|
|
15042
|
+
* presses one (owner ruling 2026-10-26: "Precise default but user must choose, no auto-default"). `members` says
|
|
15043
|
+
* whether there are members a read could change, so auto-accept is offered only on a re-read (owner ruling 2026-10-25).
|
|
15044
|
+
* The same terms the chat card and the New project dialog state (QUICK_MODEL_TERMS, QUICK_AUTO_ACCEPT_TERMS).
|
|
15045
|
+
*/
|
|
15046
|
+
const REVISION_QUICK_TERMS = 'The AI answers this read\'s drawing questions itself instead of asking you, and files an RFI, marked as its own, only for a question it cannot settle; nothing is sent to anyone. It records every decision it makes, so you can review them afterwards, and the model is labelled as a Quick model. The AI never approves anything: you still decide on the Drawing Filter and on the review.';
|
|
15047
|
+
const REVISION_AUTO_ACCEPT_TERMS = 'You also chose to have the AI’s height changes to members already in the model ticked for you in the review: untick any you do not want; nothing changes until you confirm the review.';
|
|
15048
|
+
const REVISION_BUILD_CHOOSE = 'Choose Quick model or Precise model first.';
|
|
15049
|
+
function revisionBuildDefault(state) {
|
|
15050
|
+
// A reviewable working copy is the evidence that a model exists, so only then is auto-accept offered (Codex plan
|
|
15051
|
+
// review, finding 5): no model yet, a first read still at its Filter, or a state FloLess could not read offers none.
|
|
15052
|
+
const ready = !!(state && state.status === 'ready');
|
|
15053
|
+
const unsure = (why) => ({ mode: null, members: ready,
|
|
15054
|
+
note: `${why} Press Quick model or Precise model to continue. Precise model is the safe choice.` });
|
|
15055
|
+
if (state && state.status === 'unreviewable' && state.reason === 'no-contract') return { mode: 'precise', members: false, note: '' };
|
|
15056
|
+
// The first read has not published its model yet: it may be building a Quick or a Precise one, so neither is preset.
|
|
15057
|
+
if (state && state.status === 'unreviewable' && state.reason === 'filter-checkpoint') return unsure('This project’s first drawing read has not finished, so FloLess cannot tell yet how its model is built.');
|
|
15058
|
+
const draft = ready && state.review && state.review.quick ? state.review.quick.draft : null;
|
|
15059
|
+
if (!draft) return unsure('FloLess could not check how this model was built.');
|
|
15060
|
+
if (draft.state === 'quick') return { mode: 'quick', members: true, note: 'This model is a Quick model, so Quick model is chosen. You can switch.' };
|
|
15061
|
+
if (draft.state === 'precise') return { mode: 'precise', members: true, note: '' };
|
|
15062
|
+
return unsure('This model reads as Possibly Quick model: FloLess could not read which AI decisions it rests on.');
|
|
15063
|
+
}
|
|
15064
|
+
/**
|
|
15065
|
+
* The preset for `proj`, from a FRESH approval verdict of its own (a settled one can be stale: the model may have
|
|
15066
|
+
* changed elsewhere), bounded so a hung read still lets the person choose. It never touches the shared approval
|
|
15067
|
+
* state: a read given up on must not leave the header or History waiting on it (Codex code review, round 1).
|
|
15068
|
+
* Computed once per surface, so a late answer never changes a choice already on screen.
|
|
15069
|
+
*/
|
|
15070
|
+
async function revisionBuildPreset(proj, ms = 8000) {
|
|
15071
|
+
let timer;
|
|
15072
|
+
const late = new Promise((resolve) => { timer = setTimeout(() => resolve(null), ms); });
|
|
15073
|
+
const read = api(`/api/projects/${encodeURIComponent(proj.id)}/approval-review`)
|
|
15074
|
+
.then((review) => (review && review.reviewable === false ? { status: 'unreviewable', reason: review.reason } : { status: 'ready', review }))
|
|
15075
|
+
.catch(() => null);
|
|
15076
|
+
const state = await Promise.race([read, late]);
|
|
15077
|
+
clearTimeout(timer);
|
|
15078
|
+
return revisionBuildDefault(current === proj ? state : null);
|
|
15079
|
+
}
|
|
15080
|
+
/** What the route is sent: Quick only when pressed, auto-accept only with it; Precise sends neither (as row 7a). */
|
|
15081
|
+
function revisionBuildBody(choice) {
|
|
15082
|
+
if (!choice || choice.mode !== 'quick') return {};
|
|
15083
|
+
return { buildMode: 'quick', ...(choice.autoAccept && choice.members ? { quickAutoAccept: true } : {}) };
|
|
15084
|
+
}
|
|
15085
|
+
/** A press on the choice. Precise clears the auto-accept tick, which only rides with Quick. */
|
|
15086
|
+
function chooseRevisionBuild(choice, target) {
|
|
15087
|
+
if (!choice || !target) return false;
|
|
15088
|
+
const mode = target.closest('[data-rev-build]');
|
|
15089
|
+
if (mode) {
|
|
15090
|
+
choice.mode = mode.dataset.revBuild === 'quick' ? 'quick' : 'precise';
|
|
15091
|
+
if (choice.mode !== 'quick') choice.autoAccept = false;
|
|
15092
|
+
choice.error = '';
|
|
15093
|
+
return true;
|
|
15094
|
+
}
|
|
15095
|
+
const auto = target.closest('[data-rev-build-auto]');
|
|
15096
|
+
if (auto) { choice.autoAccept = choice.mode === 'quick' && !!auto.checked; return true; }
|
|
15097
|
+
return false;
|
|
15098
|
+
}
|
|
15099
|
+
/**
|
|
15100
|
+
* The choice, painted from its state. `compact` (the Knowledge read panel) keeps each button's trade-off in its
|
|
15101
|
+
* tooltip; the Quick terms are consent text and always show in full while Quick is pressed.
|
|
15102
|
+
*/
|
|
15103
|
+
function revisionBuildChoiceHtml(choice, { idPrefix, compact = false }) {
|
|
15104
|
+
const sub = { quick: 'AI answers the drawing questions · faster · not precise', precise: 'You answer them · hours · best evidence' };
|
|
15105
|
+
const button = (mode, label) => {
|
|
15106
|
+
const pressed = choice.mode === mode;
|
|
15107
|
+
const suggested = mode === 'precise' && !choice.mode ? ' · suggested' : '';
|
|
15108
|
+
return `<button type="button" data-rev-build="${mode}" data-command-id="shell.revision-build-mode#${mode === 'quick' ? 'Quick' : 'Precise'}" aria-pressed="${pressed}"`
|
|
15109
|
+
+ `${mode === 'quick' ? ` aria-describedby="${idPrefix}-terms"` : ''}${compact ? ` data-tip="${escapeAttr(sub[mode])}"` : ''}>`
|
|
15110
|
+
+ `<span class="project-setup-standard-label">${escapeHtml(label + suggested)}</span>${compact ? '' : `<span>${escapeHtml(sub[mode])}</span>`}</button>`;
|
|
15111
|
+
};
|
|
15112
|
+
const quick = choice.mode === 'quick';
|
|
15113
|
+
const auto = quick && choice.members
|
|
15114
|
+
? `<label class="modal-check"><input type="checkbox" data-rev-build-auto data-command-id="shell.revision-quick-auto-accept"${choice.autoAccept ? ' checked' : ''}`
|
|
15115
|
+
+ ` aria-describedby="${idPrefix}-auto-terms"><span>Tick the AI’s height changes to members already in the model for me</span></label>`
|
|
15116
|
+
+ `<p id="${idPrefix}-auto-terms"${choice.autoAccept ? '' : ' hidden'}>${escapeHtml(REVISION_AUTO_ACCEPT_TERMS)}</p>` : '';
|
|
15117
|
+
return `<fieldset class="project-setup-field project-setup-standard project-setup-build rev-build${compact ? ' is-compact' : ''}">`
|
|
15118
|
+
+ `<legend class="project-setup-label">Model</legend>`
|
|
15119
|
+
+ (choice.note ? `<div class="project-setup-note" role="status">${escapeHtml(choice.note)}</div>` : '')
|
|
15120
|
+
+ `<div class="project-setup-standard-options">${button('quick', 'Quick model')}${button('precise', 'Precise model')}</div>`
|
|
15121
|
+
+ (choice.error ? `<div class="ac-error rev-build-error" role="alert">${escapeHtml(choice.error)}</div>` : '')
|
|
15122
|
+
+ `<div class="project-setup-quick-terms" id="${idPrefix}-terms" role="group" aria-label="Quick model terms"${quick ? '' : ' hidden'}>`
|
|
15123
|
+
+ `<strong>Before you read these drawings as a Quick model</strong><p>${escapeHtml(REVISION_QUICK_TERMS)}</p>${auto}</div></fieldset>`;
|
|
15124
|
+
}
|
|
15125
|
+
/** The toasts for a queued read, phrased from what the server QUEUED, never from the press; a fallback says why. */
|
|
15126
|
+
function revisionQueuedToasts(res, lead, tail) {
|
|
15127
|
+
const req = res && res.request;
|
|
15128
|
+
showToast(`${lead}${req && req.buildMode === 'quick' ? ' as a Quick model' : ''} — ${tail}`, 'ok');
|
|
15129
|
+
if (res && res.buildModeNotice && res.buildModeNotice.why) showToast(res.buildModeNotice.why, 'warn');
|
|
15130
|
+
}
|
|
15131
|
+
|
|
15132
|
+
/**
|
|
15133
|
+
* The confirm step after the file picker (owner ruling 2026-10-26). Resolves the person's choice, or null when they
|
|
15134
|
+
* cancel (nothing is queued, as cancelling the picker). Leaving the project closes it (resetRevisionState).
|
|
15135
|
+
*/
|
|
15136
|
+
function askRevisionBuild(files, preset) {
|
|
15137
|
+
const root = document.getElementById('revision-build-modal');
|
|
15138
|
+
if (!root) return Promise.resolve(null);
|
|
15139
|
+
if (revisionBuildAsk) revisionBuildAsk.close(null);
|
|
15140
|
+
const $choice = document.getElementById('rb-choice');
|
|
15141
|
+
const returnTo = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
15142
|
+
const choice = { mode: preset.mode, members: preset.members, note: preset.note, autoAccept: false, error: '' };
|
|
15143
|
+
const names = files.map((f) => f.name);
|
|
15144
|
+
document.getElementById('rb-files').textContent = names.length > 1 ? `${names[0]} and ${names.length - 1} more` : (names[0] || '');
|
|
15145
|
+
return new Promise((resolve) => {
|
|
15146
|
+
const paint = (focusSel) => {
|
|
15147
|
+
$choice.innerHTML = revisionBuildChoiceHtml(choice, { idPrefix: 'rb' });
|
|
15148
|
+
const target = focusSel && $choice.querySelector(focusSel);
|
|
15149
|
+
if (target) target.focus();
|
|
15150
|
+
};
|
|
15151
|
+
const close = (result) => {
|
|
15152
|
+
if (revisionBuildAsk !== ask) return;
|
|
15153
|
+
revisionBuildAsk = null;
|
|
15154
|
+
root.classList.remove('show');
|
|
15155
|
+
root.removeEventListener('click', onClick);
|
|
15156
|
+
root.removeEventListener('change', onChange);
|
|
15157
|
+
document.removeEventListener('keydown', onKey, true);
|
|
15158
|
+
if (returnTo && returnTo.isConnected) returnTo.focus();
|
|
15159
|
+
resolve(result);
|
|
15160
|
+
};
|
|
15161
|
+
const queue = () => {
|
|
15162
|
+
if (!choice.mode) { choice.error = REVISION_BUILD_CHOOSE; paint('[data-rev-build="quick"]'); return; }
|
|
15163
|
+
close({ mode: choice.mode, autoAccept: choice.autoAccept, members: choice.members });
|
|
15164
|
+
};
|
|
15165
|
+
function onClick(event) {
|
|
15166
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
15167
|
+
if (!target) return;
|
|
15168
|
+
if (target.closest('#rb-cancel')) { close(null); return; }
|
|
15169
|
+
if (target.closest('#rb-ok')) { queue(); return; }
|
|
15170
|
+
const mode = target.closest('[data-rev-build]');
|
|
15171
|
+
if (mode && chooseRevisionBuild(choice, mode)) paint(`[data-rev-build="${choice.mode}"]`);
|
|
15172
|
+
}
|
|
15173
|
+
function onChange(event) {
|
|
15174
|
+
if (chooseRevisionBuild(choice, event.target)) paint('[data-rev-build-auto]');
|
|
15175
|
+
}
|
|
15176
|
+
function onKey(event) {
|
|
15177
|
+
if (!root.classList.contains('show')) return;
|
|
15178
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); close(null); return; }
|
|
15179
|
+
if (event.key !== 'Tab') return;
|
|
15180
|
+
const focusable = Array.from(root.querySelectorAll('button, input'))
|
|
15181
|
+
.filter((element) => !element.closest('[hidden]') && element.getClientRects().length);
|
|
15182
|
+
if (!focusable.length) return;
|
|
15183
|
+
const first = focusable[0]; const last = focusable[focusable.length - 1];
|
|
15184
|
+
if (event.shiftKey && (document.activeElement === first || !root.contains(document.activeElement))) { event.preventDefault(); last.focus(); }
|
|
15185
|
+
else if (!event.shiftKey && (document.activeElement === last || !root.contains(document.activeElement))) { event.preventDefault(); first.focus(); }
|
|
15186
|
+
}
|
|
15187
|
+
const ask = { close };
|
|
15188
|
+
revisionBuildAsk = ask;
|
|
15189
|
+
root.addEventListener('click', onClick);
|
|
15190
|
+
root.addEventListener('change', onChange);
|
|
15191
|
+
// On the document, as step-rename.js does: focus moved out of the dialog by another surface still comes back.
|
|
15192
|
+
document.addEventListener('keydown', onKey, true);
|
|
15193
|
+
root.classList.add('show');
|
|
15194
|
+
paint(choice.mode ? `[data-rev-build="${choice.mode}"]` : '[data-rev-build="quick"]');
|
|
15195
|
+
});
|
|
15196
|
+
}
|
|
15197
|
+
|
|
15198
|
+
// The backdrop dismisses only a click that also STARTED on it (onBackdropDismiss), so a drag-select of the terms that
|
|
15199
|
+
// ends outside the dialog never cancels the person's attach.
|
|
15200
|
+
onBackdropDismiss(document.getElementById('revision-build-modal'), () => { if (revisionBuildAsk) revisionBuildAsk.close(null); }, () => !!revisionBuildAsk);
|
|
15201
|
+
|
|
15202
|
+
async function attachRevision(files, owner) {
|
|
15203
|
+
// #2521 row 7b: `owner` is the project and generation captured before the file picker opened (the Attach click), so
|
|
15204
|
+
// files picked for a project the user has since left never reach the next one. Without it: the project on screen now.
|
|
15205
|
+
const proj = owner ? owner.proj : current; // capture — the user may switch projects during the async file reads / POST
|
|
14006
15206
|
if (!proj || !files.length) return;
|
|
14007
15207
|
if (!validateSteelDrawingFiles(wsDescOf(proj) === WORKSPACE_APPS['steel-model'] ? 'steel-model' : '', files)) return;
|
|
14008
|
-
const projectGeneration = revisionOwnerGen;
|
|
15208
|
+
const projectGeneration = owner ? owner.gen : revisionOwnerGen;
|
|
14009
15209
|
const attachGeneration = ++revisionAttachGen;
|
|
14010
15210
|
const ownsAttach = () => current === proj
|
|
14011
15211
|
&& revisionOwnerGen === projectGeneration
|
|
14012
15212
|
&& revisionAttachGen === attachGeneration;
|
|
15213
|
+
if (!ownsAttach()) return;
|
|
14013
15214
|
const returnFocus = document.activeElement;
|
|
15215
|
+
// #2521 row 7b: a Steel model read asks Quick or Precise first, preset to the model's own mode. Other templates
|
|
15216
|
+
// have no Quick model, so their attach stays one step.
|
|
15217
|
+
let choice = null;
|
|
15218
|
+
if (wsDescOf(proj) === WORKSPACE_APPS['steel-model']) {
|
|
15219
|
+
const preset = await revisionBuildPreset(proj);
|
|
15220
|
+
if (!ownsAttach()) return;
|
|
15221
|
+
choice = await askRevisionBuild(files, preset);
|
|
15222
|
+
if (!choice || !ownsAttach()) return;
|
|
15223
|
+
}
|
|
14014
15224
|
let snapshots;
|
|
14015
15225
|
try { snapshots = await Promise.all(files.map(readFileAsSnapshot)); }
|
|
14016
15226
|
catch { showToast('Could not read the selected files', 'warn'); return; }
|
|
@@ -14018,7 +15228,7 @@
|
|
|
14018
15228
|
let res;
|
|
14019
15229
|
try {
|
|
14020
15230
|
res = await api(`/api/projects/${encodeURIComponent(proj.id)}/revision-requests`, {
|
|
14021
|
-
method: 'POST', body: JSON.stringify({ appId: proj.app, snapshots }),
|
|
15231
|
+
method: 'POST', body: JSON.stringify({ appId: proj.app, snapshots, ...revisionBuildBody(choice) }),
|
|
14022
15232
|
});
|
|
14023
15233
|
} catch (err) { if (ownsAttach()) showToast(err?.body?.code === 'steel-pdf-required' ? err.body.error : 'We couldn’t attach that file because FloLess could not save it. Try again.', 'warn'); return; }
|
|
14024
15234
|
const req = res && res.request;
|
|
@@ -14036,7 +15246,7 @@
|
|
|
14036
15246
|
if (!ownsAttach()) return; // don't drive a replaced project's card/poll/modal or narrate its Copy
|
|
14037
15247
|
revBaseVersion = (req && typeof req.baseVersion === 'number') ? req.baseVersion : 0;
|
|
14038
15248
|
revBaseProject = proj.id; // the baseline belongs to THIS project — see resetRevisionState
|
|
14039
|
-
|
|
15249
|
+
revisionQueuedToasts(res, `${revBaseVersion <= 0 ? 'Initial' : 'Revised'} set queued`, `${files.length} file${files.length > 1 ? 's' : ''} for your terminal AI`);
|
|
14040
15250
|
// #2399 slice 0c: the drawings also land in the project's design set as an issue. Said either way, never silent.
|
|
14041
15251
|
const landed = res && res.designSet;
|
|
14042
15252
|
if (landed && landed.landed && landed.created) {
|
|
@@ -14063,8 +15273,9 @@
|
|
|
14063
15273
|
}
|
|
14064
15274
|
|
|
14065
15275
|
document.getElementById('ws-attach-revision').addEventListener('click', async () => {
|
|
15276
|
+
const owner = { proj: current, gen: revisionOwnerGen };
|
|
14066
15277
|
const files = await pickDrawingFiles($revisionFile, wsDescOf(current) === WORKSPACE_APPS['steel-model'] ? 'steel-model' : '');
|
|
14067
|
-
if (files.length) attachRevision(files);
|
|
15278
|
+
if (files.length) attachRevision(files, owner);
|
|
14068
15279
|
});
|
|
14069
15280
|
|
|
14070
15281
|
function buildPendingCard(req) {
|
|
@@ -14318,6 +15529,7 @@
|
|
|
14318
15529
|
revisionGen += 1;
|
|
14319
15530
|
revisionRequestsSuccessGen = revisionGen;
|
|
14320
15531
|
lastRevState = 'none';
|
|
15532
|
+
revisionListKnown = true;
|
|
14321
15533
|
await renderRevisionCard();
|
|
14322
15534
|
}
|
|
14323
15535
|
|
|
@@ -14361,6 +15573,7 @@
|
|
|
14361
15573
|
return;
|
|
14362
15574
|
}
|
|
14363
15575
|
revisionRequestsSuccessGen = Math.max(revisionRequestsSuccessGen, gen);
|
|
15576
|
+
revisionListKnown = true;
|
|
14364
15577
|
} catch (e) {
|
|
14365
15578
|
// The request that failed may belong to a project the user has already left. Do not let its
|
|
14366
15579
|
// late failure mark the newly opened project's server state as disconnected. For the same
|
|
@@ -14828,9 +16041,14 @@
|
|
|
14828
16041
|
if (answered) {
|
|
14829
16042
|
const note = revEl('div', 'rev-row-note');
|
|
14830
16043
|
const how = answered.how === 'typed' ? `typed ${answered.typed || reviewElevation(a.z.known)}` : `confirmed ${answered.shownAs || reviewElevation(a.z.known)}`;
|
|
16044
|
+
// #2788: where a confirmed proposal came from, so a derived height never reads as one taken off a drawing.
|
|
16045
|
+
const p = answered.how === 'confirmed' && answered.proposal && typeof answered.proposal === 'object' ? answered.proposal : null;
|
|
16046
|
+
const came = !p ? '' : p.how === 'derived' ? `, which the read derived from ${p.basis}`
|
|
16047
|
+
: p.how === 'measured' ? `, which the read measured on the drawings${p.basis ? ` (${p.basis})` : ''}`
|
|
16048
|
+
: `, read off the drawings${p.basis ? ` (${p.basis})` : ''}`;
|
|
14831
16049
|
note.appendChild(document.createTextNode(`You answered the ${end.toLowerCase()} height on a height question: `));
|
|
14832
16050
|
note.appendChild(revEl('b', null, how));
|
|
14833
|
-
note.appendChild(document.createTextNode(answered.note ? ` (${answered.note})
|
|
16051
|
+
note.appendChild(document.createTextNode(`${came}${answered.note ? ` (${answered.note})` : ''}.`));
|
|
14834
16052
|
notes.push(note);
|
|
14835
16053
|
const over = answered.overDrawing;
|
|
14836
16054
|
if (over && typeof over.low === 'number' && typeof over.high === 'number') {
|
|
@@ -17017,8 +18235,26 @@
|
|
|
17017
18235
|
wrap.appendChild(el('span', 'hd-net-label', 'Net steel:'));
|
|
17018
18236
|
wrap.appendChild(el('span', 'hd-net-arrow', net > 0 ? '▲' : net < 0 ? '▼' : '•'));
|
|
17019
18237
|
wrap.appendChild(el('span', 'hd-net-val', `${net > 0 ? '+' : ''}${net} ${word}`));
|
|
18238
|
+
// #2735: the bill prices members on ASSUMED heights, so these totals can rest on them. Say so on its own
|
|
18239
|
+
// line under the figure (a label, not a reliability warning, so not an .hd-warn banner).
|
|
18240
|
+
const assumed = diffAssumedNoteText(t);
|
|
18241
|
+
if (assumed) {
|
|
18242
|
+
const note = el('span', 'hd-net-assumed', assumed);
|
|
18243
|
+
note.setAttribute('role', 'note');
|
|
18244
|
+
note.dataset.tip = 'Heights the drawings do not state, placed at a plan elevation.';
|
|
18245
|
+
wrap.appendChild(note);
|
|
18246
|
+
}
|
|
17020
18247
|
return wrap;
|
|
17021
18248
|
}
|
|
18249
|
+
// The line under Net steel when either side prices members on assumed heights, or '' when neither does.
|
|
18250
|
+
// Newer side first: it is the figure being read.
|
|
18251
|
+
function diffAssumedNoteText(t) {
|
|
18252
|
+
const count = (v) => (typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : 0);
|
|
18253
|
+
const now = count(t && t.toAssumed), before = count(t && t.fromAssumed);
|
|
18254
|
+
if (!now && !before) return '';
|
|
18255
|
+
const lead = 'Includes members priced on assumed heights: ';
|
|
18256
|
+
return now === before ? `${lead}${now} in both versions.` : `${lead}${now} now, ${before} before.`;
|
|
18257
|
+
}
|
|
17022
18258
|
// The engine's four honest signals — each names its CONSEQUENCE so a withheld member/connection is
|
|
17023
18259
|
// never silently absent from the panel. ALL render here (not just identity), above the numbers.
|
|
17024
18260
|
function diffCautions(w) {
|
|
@@ -18362,6 +19598,127 @@
|
|
|
18362
19598
|
}
|
|
18363
19599
|
}
|
|
18364
19600
|
|
|
19601
|
+
/**
|
|
19602
|
+
* Show one place on the drawings in a project's Drawing Filter (#2777 slice D, AI Chat's "Open in Drawing
|
|
19603
|
+
* Filter"): its sheet, with the area outlined. The Filter does the showing (`flolessFilterFocus`,
|
|
19604
|
+
* steel-filter.html); this only gets the person to the Drawings step and hands the request over.
|
|
19605
|
+
*
|
|
19606
|
+
* The same discipline as `openConnection` above, for the same reasons: one slot (a later click replaces
|
|
19607
|
+
* and withdraws the earlier request by its id), the project already open only switches step (so nothing
|
|
19608
|
+
* unsaved is reloaded away), another project goes through `openProject` and its leave guard, every wait is
|
|
19609
|
+
* watched, and whatever stops waiting without the Filter's answer withdraws the request.
|
|
19610
|
+
*
|
|
19611
|
+
* Resolves the Filter's own outcome — `{ok:true}` or `{ok:false,said}` — or `{superseded:true}`. What
|
|
19612
|
+
* cannot be done is thrown as a sentence written for the person (`plain`).
|
|
19613
|
+
*/
|
|
19614
|
+
let placeRequestSeq = 0;
|
|
19615
|
+
let placeRequest = null;
|
|
19616
|
+
const withdrawPlaceRequest = (request) => {
|
|
19617
|
+
try { request?.page?.flolessFilterFocusCancel?.(request.id); } catch { /* that page is gone */ }
|
|
19618
|
+
};
|
|
19619
|
+
async function openDrawingAt(target) {
|
|
19620
|
+
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
19621
|
+
const place = target && target.place;
|
|
19622
|
+
const again = 'Open in Drawing Filter';
|
|
19623
|
+
if (!target || !validId(target.projectId) || !place || !validId(place.pageId) || !validId(place.sheet) || !/^[0-9a-f]{64}$/.test(String(place.sourceHash || ''))) {
|
|
19624
|
+
throw connectionError('That place could not be opened. Open its project from Workspaces.');
|
|
19625
|
+
}
|
|
19626
|
+
const mine = { id: `place-${++placeRequestSeq}`, page: null };
|
|
19627
|
+
withdrawPlaceRequest(placeRequest);
|
|
19628
|
+
placeRequest = mine;
|
|
19629
|
+
const superseded = () => placeRequest !== mine;
|
|
19630
|
+
let ended = false;
|
|
19631
|
+
const stillWanted = () => !ended && !superseded();
|
|
19632
|
+
const pause = () => new Promise((resolve) => setTimeout(resolve, 100));
|
|
19633
|
+
const leftWorkspaces = () => connectionError(`You left Workspaces, so the place was not shown. Open the project from Workspaces, then press ${again} again.`);
|
|
19634
|
+
const navigating = async (work, bounded) => {
|
|
19635
|
+
const bound = bounded ? Date.now() + CONNECTION_NAVIGATION_WAIT_MS : Infinity;
|
|
19636
|
+
let done = null;
|
|
19637
|
+
const finished = work.then((value) => { done = { value }; }, (error) => { done = { error }; });
|
|
19638
|
+
for (;;) {
|
|
19639
|
+
await Promise.race([finished, pause()]);
|
|
19640
|
+
if (done) { if (done.error) throw done.error; return done.value; }
|
|
19641
|
+
if (superseded()) return { superseded: true };
|
|
19642
|
+
if (Date.now() >= bound) throw connectionError(`The project did not open in time, so the place was not shown. Open it from Workspaces, then press ${again} again.`);
|
|
19643
|
+
}
|
|
19644
|
+
};
|
|
19645
|
+
let until = Infinity;
|
|
19646
|
+
// The document the Drawings frame held before this call opened the project (#2605's trap, for this frame).
|
|
19647
|
+
let pageLeftBehind = null;
|
|
19648
|
+
const interrupted = () => {
|
|
19649
|
+
if (superseded()) return { superseded: true };
|
|
19650
|
+
if (mode !== 'workspaces') throw leftWorkspaces();
|
|
19651
|
+
if (current?.id !== target.projectId) throw connectionError('You moved to another project, so the place was not shown.');
|
|
19652
|
+
if (currentStep !== 'drawings' && !(pendingPresenceStep && pendingPresenceStep.step === 'drawings')) {
|
|
19653
|
+
throw connectionError(`The Drawings step is not open, so the place was not shown. Open the Drawings step, then press ${again} again.`);
|
|
19654
|
+
}
|
|
19655
|
+
if (Date.now() >= until) throw connectionError(`The Drawing Filter did not open in time, so the place was not shown. Open the Drawings step, then press ${again} again.`);
|
|
19656
|
+
return null;
|
|
19657
|
+
};
|
|
19658
|
+
try {
|
|
19659
|
+
if ((await navigating(Promise.resolve(setMode('workspaces'))))?.superseded || superseded()) return { superseded: true };
|
|
19660
|
+
if (mode !== 'workspaces') throw connectionError(`You stayed where you were, so the place was not shown. Open the project from Workspaces, then press ${again} again.`);
|
|
19661
|
+
if (current?.id !== target.projectId) {
|
|
19662
|
+
try { pageLeftBehind = frames.drawings.contentWindow?.document ?? null; } catch { pageLeftBehind = null; }
|
|
19663
|
+
const opened = await navigating(openProject(target.projectId, 'drawings', { stillWanted }), true);
|
|
19664
|
+
if (opened?.superseded || superseded()) return { superseded: true };
|
|
19665
|
+
if (opened === STAYED_IN_PROJECT) throw connectionError(`That project did not open, so the place was not shown. Open it from Workspaces to see why, then press ${again} again.`);
|
|
19666
|
+
if (current?.id !== target.projectId) throw connectionError('That project could not be opened. Open it from Workspaces.');
|
|
19667
|
+
} else if (currentStep !== 'drawings') {
|
|
19668
|
+
setStep('drawings');
|
|
19669
|
+
}
|
|
19670
|
+
if (!frames.drawings.dataset.want) throw connectionError('This project has no Drawing Filter to show the place in.');
|
|
19671
|
+
until = Date.now() + CONNECTION_FRAME_WAIT_MS;
|
|
19672
|
+
let answer = null, settled = null, page = null, doc = null, reloaded = false;
|
|
19673
|
+
const notTaken = `The Drawing Filter could not take the request. Press ${again} again.`;
|
|
19674
|
+
for (;;) {
|
|
19675
|
+
if (settled) {
|
|
19676
|
+
if (superseded()) return { superseded: true };
|
|
19677
|
+
if (mode !== 'workspaces') throw leftWorkspaces();
|
|
19678
|
+
if (current?.id !== target.projectId) throw connectionError('You moved to another project, so the place was not shown.');
|
|
19679
|
+
if (frames.drawings.contentWindow !== page || page.document !== doc) throw connectionError(`The Drawing Filter reloaded, so the place was not shown. Press ${again} again.`);
|
|
19680
|
+
const outcome = settled.outcome;
|
|
19681
|
+
return outcome && typeof outcome === 'object' ? { ...outcome } : { ok: false, said: notTaken };
|
|
19682
|
+
}
|
|
19683
|
+
const stop = interrupted();
|
|
19684
|
+
if (stop) return stop;
|
|
19685
|
+
const child = frames.drawings.contentWindow;
|
|
19686
|
+
if (!answer) {
|
|
19687
|
+
const state = child && child.flolessFilterState;
|
|
19688
|
+
// A Filter that showed nothing may only be out of date: the read prepared its drawings after the page loaded.
|
|
19689
|
+
// It has nothing unsaved, so it is reloaded once, and only what the reloaded page says is reported.
|
|
19690
|
+
if (state && state.project === target.projectId && state.failed === true && !reloaded
|
|
19691
|
+
&& (!pageLeftBehind || child.document !== pageLeftBehind)) {
|
|
19692
|
+
reloaded = true;
|
|
19693
|
+
pageLeftBehind = child.document;
|
|
19694
|
+
frames.drawings.src = frames.drawings.dataset.want;
|
|
19695
|
+
until = Date.now() + CONNECTION_FRAME_WAIT_MS;
|
|
19696
|
+
} else if (state && state.project === target.projectId && typeof child.flolessFilterFocus === 'function'
|
|
19697
|
+
&& (!pageLeftBehind || child.document !== pageLeftBehind)) {
|
|
19698
|
+
page = child; doc = child.document;
|
|
19699
|
+
answer = child.flolessFilterFocus({ requestId: mine.id, sourceHash: place.sourceHash, pageId: place.pageId, sheet: place.sheet,
|
|
19700
|
+
...(Array.isArray(place.region) ? { region: place.region } : {}) });
|
|
19701
|
+
if (!answer || typeof answer.then !== 'function') return { ok: false, said: notTaken };
|
|
19702
|
+
mine.page = page;
|
|
19703
|
+
answer.then((outcome) => { settled = { outcome }; }, (error) => {
|
|
19704
|
+
console.error('[workspaces] the Drawing Filter could not answer for the place', error);
|
|
19705
|
+
settled = { outcome: { ok: false, said: notTaken } };
|
|
19706
|
+
});
|
|
19707
|
+
}
|
|
19708
|
+
} else if (child !== page || child.document !== doc) {
|
|
19709
|
+
throw connectionError(`The Drawing Filter reloaded, so the place was not shown. Press ${again} again.`);
|
|
19710
|
+
}
|
|
19711
|
+
await pause();
|
|
19712
|
+
}
|
|
19713
|
+
} catch (error) {
|
|
19714
|
+
if (!superseded()) withdrawPlaceRequest(mine);
|
|
19715
|
+
throw error;
|
|
19716
|
+
} finally {
|
|
19717
|
+
ended = true;
|
|
19718
|
+
if (placeRequest === mine) placeRequest = null;
|
|
19719
|
+
}
|
|
19720
|
+
}
|
|
19721
|
+
|
|
18365
19722
|
// A cross-project object pin still belongs to its original conversation, wherever its model is shown.
|
|
18366
19723
|
async function openChatOwner(owner) {
|
|
18367
19724
|
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
@@ -18564,7 +19921,7 @@
|
|
|
18564
19921
|
tellModelFrame({ type: 'knowledge-changed', projectId });
|
|
18565
19922
|
},
|
|
18566
19923
|
setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind,
|
|
18567
|
-
openHistory: wsOpenHistory, openKnowledgePage, openKnowledgeStep, openDrawingsStep, openWorkflowsStep, openConnection, drawingFilterCheckpointSaved,
|
|
19924
|
+
openHistory: wsOpenHistory, openKnowledgePage, openKnowledgeStep, openDrawingsStep, openWorkflowsStep, openConnection, openDrawingAt, drawingFilterCheckpointSaved,
|
|
18568
19925
|
// #2470 R6.7: the Modules step of a General project (project-modules.js).
|
|
18569
19926
|
moduleCreateCardsHtml, activateCreateCard, openLinkedProject, openModulesStep, showArchivedProjects,
|
|
18570
19927
|
syncWorkspaceReporter, openChatOwner, openPagesHome, folderDecisionCompleted,
|