@floless/app 0.159.0 → 0.160.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +29576 -23804
- package/dist/schemas/steel.model.v2.schema.json +1 -0
- package/dist/skills/floless-app-onboarding/SKILL.md +4 -3
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +1 -2
- package/dist/skills/floless-app-rfi/SKILL.md +29 -1
- package/dist/skills/floless-app-steel-model/SKILL.md +2 -2
- package/dist/web/app.css +184 -151
- package/dist/web/app.js +17 -51
- package/dist/web/aware.js +504 -542
- package/dist/web/chat-question-card.js +24 -1
- package/dist/web/chat.css +131 -29
- package/dist/web/chat.js +1225 -178
- package/dist/web/commands-shell.js +676 -50
- package/dist/web/commands-steel.js +1 -0
- package/dist/web/guide.js +8 -0
- package/dist/web/index.html +23 -41
- package/dist/web/instructor.js +14 -5
- package/dist/web/pages.js +115 -18
- package/dist/web/panels.js +19 -1
- package/dist/web/project-rfis.js +715 -0
- package/dist/web/project-workflows.js +236 -4
- package/dist/web/run-history.js +198 -0
- package/dist/web/run-page-view.js +12 -2
- package/dist/web/steel-3d-core.js +29 -1
- package/dist/web/steel-editor.html +71 -10
- package/dist/web/steel-model-v2-projection.js +7 -0
- package/dist/web/workspaces.js +136 -48
- package/package.json +2 -1
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
if (!f || f.checked === false) return 'Last run not checked';
|
|
46
46
|
const when = f.lastRunAt ? ago(f.lastRunAt, now) : '';
|
|
47
47
|
switch (f.lastRun) {
|
|
48
|
+
// #2644: a Drawing Checker or Steel Model workflow this account's plan does not include: its run is not shown.
|
|
49
|
+
case 'locked': return 'Locked: its module isn’t active for this account, so its last run isn’t shown';
|
|
48
50
|
case 'none': return 'This version hasn’t run yet';
|
|
49
51
|
case 'ok': return when ? `This version last ran ${when} and finished` : 'This version’s last run finished';
|
|
50
52
|
case 'failed': return when ? `This version last ran ${when} and failed` : 'This version’s last run failed';
|
|
@@ -75,6 +77,70 @@
|
|
|
75
77
|
</div>`;
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
/**
|
|
81
|
+
* #2603: a workflow folder whose details name another owner. FloLess no longer lists it as a workflow, and nothing
|
|
82
|
+
* runs or edits it until the person chooses; neither choice deletes anything. Shown on the project's Workflows step
|
|
83
|
+
* (`where: 'step'`) and, for folders no project step shows — the standalone workflows, a folder no project lives in —
|
|
84
|
+
* on the Workflows page (`where: 'landing'`). Each place has its own Instructor ids; the instance is the workflow id.
|
|
85
|
+
*/
|
|
86
|
+
const SET_APART_WHY = {
|
|
87
|
+
'misplaced': (x) => `Its details name “${x}”, but it was found in this folder.`,
|
|
88
|
+
'foreign-root': () => 'Its details name a project in a different Workspace.',
|
|
89
|
+
'owner-missing': (x) => `Its details name “${x}”, which can’t be found any more.`,
|
|
90
|
+
'incarnation-mismatch': (x) => `Its details name an earlier copy of “${x}”, not the project as it is now.`,
|
|
91
|
+
};
|
|
92
|
+
const noProjectHere = (q) => q.folder && q.folder.kind === 'project' && !q.folder.projectId;
|
|
93
|
+
/** One set-apart folder: where it is AND its workflow id — copies of one workflow can sit in several folders. */
|
|
94
|
+
const setApartKey = (q) => (q.folder.kind === 'standalone' ? `standalone/${q.workflowId}` : `project/${q.folder.locator}/${q.workflowId}`);
|
|
95
|
+
function setApartRowHtml(q, row, where) {
|
|
96
|
+
const name = q.displayName || 'Unnamed workflow';
|
|
97
|
+
const why = (SET_APART_WHY[q.reason] || SET_APART_WHY.misplaced)(q.claimedOwnerLabel || 'another project');
|
|
98
|
+
const notes = [];
|
|
99
|
+
if (where === 'landing') notes.push(q.folder.kind === 'standalone' ? 'Among the standalone workflows.' : `In the folder “${q.folderLabel || q.folder.locator}”, where no project lives now.`);
|
|
100
|
+
notes.push(why);
|
|
101
|
+
if (!q.hasSource) notes.push('It has no workflow file, so the draft would start empty.');
|
|
102
|
+
if (q.archived) notes.push('It was archived, and stays archived if you keep it.');
|
|
103
|
+
if (q.hasConversations) notes.push('Its chats stay with the old folder, and while they are kept FloLess keeps older Knowledge versions instead of cleaning them up.');
|
|
104
|
+
const key = esc(setApartKey(q));
|
|
105
|
+
const label = `data-command-instance-label="${esc(name)}"`;
|
|
106
|
+
const busy = row.busy ? ' disabled' : '';
|
|
107
|
+
// The command ids are written whole; only the instance after "#" varies.
|
|
108
|
+
const keep = noProjectHere(q) ? ''
|
|
109
|
+
: row.unreadable
|
|
110
|
+
? (where === 'landing'
|
|
111
|
+
? `<button type="button" class="ghost" data-pw-setapart="keep-empty" data-pw-setapart-id="${key}" data-command-id="shell.workflows-setapart-keep-empty#${esc(setApartKey(q))}" ${label}${busy}
|
|
112
|
+
data-tip="Makes an empty draft with this name. The old folder is kept aside, so the file can still be recovered.">${row.busy === 'keep-empty' ? 'Keeping…' : 'Keep without its workflow file'}</button>`
|
|
113
|
+
: `<button type="button" class="ghost" data-pw-setapart="keep-empty" data-pw-setapart-id="${key}" data-command-id="shell.project-workflow-setapart-keep-empty#${esc(setApartKey(q))}" ${label}${busy}
|
|
114
|
+
data-tip="Makes an empty draft with this name. The old folder is kept aside, so the file can still be recovered.">${row.busy === 'keep-empty' ? 'Keeping…' : 'Keep without its workflow file'}</button>`)
|
|
115
|
+
: (where === 'landing'
|
|
116
|
+
? `<button type="button" class="ghost" data-pw-setapart="keep" data-pw-setapart-id="${key}" data-command-id="shell.workflows-setapart-keep#${esc(setApartKey(q))}" ${label}${busy}
|
|
117
|
+
data-tip="Moves the old folder aside, then makes a new draft from its name and workflow file.">${row.busy === 'keep' ? 'Keeping…' : 'Keep as a workflow here'}</button>`
|
|
118
|
+
: `<button type="button" class="ghost" data-pw-setapart="keep" data-pw-setapart-id="${key}" data-command-id="shell.project-workflow-setapart-keep#${esc(setApartKey(q))}" ${label}${busy}
|
|
119
|
+
data-tip="Moves the old folder aside, then makes a new draft in this project from its name and workflow file.">${row.busy === 'keep' ? 'Keeping…' : 'Keep as a workflow here'}</button>`);
|
|
120
|
+
const asideTip = 'Moves the folder aside and keeps it on this computer. It is not listed as a workflow, and it is not included when the project is exported or duplicated.';
|
|
121
|
+
const aside = where === 'landing'
|
|
122
|
+
? `<button type="button" class="ghost" data-pw-setapart="set-aside" data-pw-setapart-id="${key}" data-command-id="shell.workflows-setapart-aside#${esc(setApartKey(q))}" ${label}${busy}
|
|
123
|
+
data-tip="${asideTip}">${row.busy === 'set-aside' ? 'Setting aside…' : 'Set it aside'}</button>`
|
|
124
|
+
: `<button type="button" class="ghost" data-pw-setapart="set-aside" data-pw-setapart-id="${key}" data-command-id="shell.project-workflow-setapart-aside#${esc(setApartKey(q))}" ${label}${busy}
|
|
125
|
+
data-tip="${asideTip}">${row.busy === 'set-aside' ? 'Setting aside…' : 'Set it aside'}</button>`;
|
|
126
|
+
const note = row.unreadable
|
|
127
|
+
? '<p class="pm-note">FloLess couldn’t read this workflow’s file, so it hasn’t made a draft and nothing was moved.</p>'
|
|
128
|
+
: row.error ? `<p class="pm-note">${esc(row.error)}</p>` : '';
|
|
129
|
+
return `<div class="pm-strip-row pw-setapart-row"${row.busy ? ' aria-busy="true"' : ''}>
|
|
130
|
+
<span><span class="pg-row-title">${esc(name)}</span>${q.archived ? ' <span class="pw-chip is-muted">Archived</span>' : ''}
|
|
131
|
+
<span class="pg-row-meta">${esc(notes.join(' '))}</span>${note}</span>
|
|
132
|
+
<span class="pm-strip-acts">${keep}${aside}</span></div>`;
|
|
133
|
+
}
|
|
134
|
+
function setApartHtml(view, where = 'step') {
|
|
135
|
+
const items = view.setApart || [];
|
|
136
|
+
if (!items.length) return '';
|
|
137
|
+
const title = items.length === 1 ? '1 workflow folder was set apart' : `${items.length} workflow folders were set apart`;
|
|
138
|
+
return `<div class="pg-empty pm-strip pw-setapart" role="group" aria-label="Workflow folders set apart">
|
|
139
|
+
<p class="pg-empty-title">${title}</p>
|
|
140
|
+
<p class="pg-row-meta">Their details name a different owner from the folder they are in, so FloLess isn’t listing them as workflows. Nothing can run or edit them until you choose. Nothing is deleted.</p>
|
|
141
|
+
${items.map((q) => setApartRowHtml(q, (view.setApartRows || {})[setApartKey(q)] || {}, where)).join('')}</div>`;
|
|
142
|
+
}
|
|
143
|
+
|
|
78
144
|
const LOAD_FAILED = 'FloLess couldn’t read the workflow list just now. Check that FloLess is still running, then try again.';
|
|
79
145
|
/**
|
|
80
146
|
* The sentence a failed read shows. FloLess's own "could not be reached" / "took too long" answers (no HTTP status) are
|
|
@@ -102,6 +168,7 @@
|
|
|
102
168
|
}
|
|
103
169
|
const active = view.rows.filter((w) => w.status !== 'archived');
|
|
104
170
|
const archived = view.rows.filter((w) => w.status === 'archived');
|
|
171
|
+
const setApart = setApartHtml(view);
|
|
105
172
|
const list = active.length
|
|
106
173
|
? `<div class="pg-list" role="list" aria-label="Workflows in this project">${active.map((w) => rowHtml(w, now)).join('')}</div>`
|
|
107
174
|
: `<div class="pg-empty pw-empty"><p class="pg-empty-title">No workflows in this project yet</p>
|
|
@@ -111,7 +178,7 @@
|
|
|
111
178
|
<summary class="ws-archived-summary" data-command-id="shell.project-workflows-archived"><span class="ws-archived-caret hd-caret" aria-hidden="true">▸</span>Archived <span class="ws-archived-count">${archived.length}</span></summary>
|
|
112
179
|
<div class="pg-list" role="list" aria-label="Archived workflows">${archived.map((w) => rowHtml(w, now)).join('')}</div></details>`
|
|
113
180
|
: '';
|
|
114
|
-
return head + list + archivedHtml;
|
|
181
|
+
return head + setApart + list + archivedHtml;
|
|
115
182
|
}
|
|
116
183
|
|
|
117
184
|
// One pane, one project at a time: a read that answers after the person left the project or the step is dropped.
|
|
@@ -153,10 +220,22 @@
|
|
|
153
220
|
try {
|
|
154
221
|
const body = await api(`/api/workflows/owned?archived=1&projectId=${encodeURIComponent(mine.project.id)}`);
|
|
155
222
|
if (state !== mine || mine.generation !== generation) return;
|
|
156
|
-
|
|
223
|
+
const setApart = Array.isArray(body.quarantined) ? body.quarantined : [];
|
|
224
|
+
// A row's follow-up (its file couldn't be read, or what the last answer said) is kept while it is still listed.
|
|
225
|
+
const rowsState = Object.fromEntries(Object.entries(mine.view.setApartRows || {})
|
|
226
|
+
.filter(([id, row]) => (row.unreadable || row.error) && setApart.some((q) => setApartKey(q) === id))
|
|
227
|
+
.map(([id, row]) => [id, { ...(row.unreadable ? { unreadable: true } : {}), ...(row.error ? { error: row.error } : {}) }]));
|
|
228
|
+
mine.view = { ...mine.view, status: 'ready', rows: Array.isArray(body.workflows) ? body.workflows : [], setApart, setApartRows: rowsState, error: null };
|
|
157
229
|
const n = mine.view.rows.filter((w) => w.status !== 'archived').length;
|
|
158
230
|
paint();
|
|
159
|
-
|
|
231
|
+
if (mine.focusAfterSetApart) {
|
|
232
|
+
// The answered row is gone: the keyboard goes to the next set-apart row, else to the step's heading.
|
|
233
|
+
mine.focusAfterSetApart = false;
|
|
234
|
+
(mine.pane.querySelector('[data-pw-setapart]') || mine.pane.querySelector('[data-pw-heading]'))?.focus({ preventScroll: true });
|
|
235
|
+
}
|
|
236
|
+
const said = n === 0 ? 'No workflows in this project yet' : `${n} workflow${n === 1 ? '' : 's'} in this project`;
|
|
237
|
+
announce(mine.pane, setApart.length
|
|
238
|
+
? `${said}. ${setApart.length} set-apart folder${setApart.length === 1 ? ' needs' : 's need'} your decision.` : said);
|
|
160
239
|
} catch (error) {
|
|
161
240
|
if (state !== mine || mine.generation !== generation) return;
|
|
162
241
|
const gone = error?.status === 404 && error?.body?.code === 'unknown-project';
|
|
@@ -226,6 +305,113 @@
|
|
|
226
305
|
} finally { opening = false; }
|
|
227
306
|
}
|
|
228
307
|
|
|
308
|
+
const post = (path, body) => fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
|
|
309
|
+
.then(async (res) => {
|
|
310
|
+
const answer = await res.json().catch(() => ({}));
|
|
311
|
+
if (!res.ok || answer.ok === false) { const err = new Error(answer.error || `HTTP ${res.status}`); err.status = res.status; err.body = answer; throw err; }
|
|
312
|
+
return answer;
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* #2603: the person's answer about one set-apart folder. The server re-checks it is the folder they were shown and
|
|
317
|
+
* moves the folder aside before it makes anything, so a failure says exactly what did and didn't change. `ctx` is
|
|
318
|
+
* the place it was answered in (the project step or the Workflows page): its rows, how to repaint and re-read it.
|
|
319
|
+
*/
|
|
320
|
+
async function answerSetApart(button, ctx) {
|
|
321
|
+
const id = button.getAttribute('data-pw-setapart-id');
|
|
322
|
+
const choice = button.getAttribute('data-pw-setapart');
|
|
323
|
+
const q = ctx.items().find((item) => setApartKey(item) === id);
|
|
324
|
+
if (!q || ctx.rows()[id]?.busy) return;
|
|
325
|
+
const name = q.displayName || 'Unnamed workflow';
|
|
326
|
+
const here = q.folder.kind === 'standalone' ? 'among the standalone workflows' : ctx.where === 'step' ? 'in this project' : 'here';
|
|
327
|
+
ctx.setRow(id, { ...(ctx.rows()[id] || {}), busy: choice, error: null });
|
|
328
|
+
ctx.repaint();
|
|
329
|
+
ctx.announce(choice === 'set-aside' ? `Setting “${name}” aside…` : `Keeping “${name}” as a workflow ${here}…`);
|
|
330
|
+
try {
|
|
331
|
+
const folder = q.folder.kind === 'standalone' ? { kind: 'standalone' } : { kind: 'project', locator: q.folder.locator };
|
|
332
|
+
const answer = await post('/api/workflows/quarantined/repair', { folder, workflowId: q.workflowId, metadataDigest: q.metadataDigest, choice });
|
|
333
|
+
// Said wherever the person is now: the change happened even if they left this place.
|
|
334
|
+
toast(answer.outcome === 'set-aside' ? `“${name}” was set aside. Nothing was deleted.`
|
|
335
|
+
: answer.alreadyKept ? `An identical copy of “${name}” is already a workflow ${here}, so FloLess used it. The old folder was set aside.`
|
|
336
|
+
: answer.withoutSource ? `“${name}” is now an empty draft ${here}. The old folder was set aside, with its file.`
|
|
337
|
+
: `“${name}” is now a ${q.archived ? 'workflow (archived)' : 'draft'} ${here}. The old folder was set aside.`, 'ok');
|
|
338
|
+
if (!ctx.alive()) return;
|
|
339
|
+
ctx.afterAnswer();
|
|
340
|
+
void ctx.reload();
|
|
341
|
+
} catch (error) {
|
|
342
|
+
const code = error?.body?.code;
|
|
343
|
+
const unreadable = code === 'source-unreadable';
|
|
344
|
+
// The server's own sentence when it wrote one (it says what changed); a fixed one only when nothing answered.
|
|
345
|
+
const said = typeof error?.body?.error === 'string' && error.body.error ? error.body.error : null;
|
|
346
|
+
if (!said) console.error('[project-workflows] a set-apart folder could not be answered', error);
|
|
347
|
+
const message = unreadable ? null : said || 'FloLess couldn’t reach the server just now. Look at the list again before trying once more.';
|
|
348
|
+
if (!ctx.alive()) return;
|
|
349
|
+
ctx.setRow(id, { unreadable: unreadable || !!ctx.rows()[id]?.unreadable, error: message });
|
|
350
|
+
ctx.repaint();
|
|
351
|
+
ctx.announce(unreadable ? 'FloLess couldn’t read this workflow’s file, so it hasn’t made a draft and nothing was moved.' : message);
|
|
352
|
+
[...ctx.host().querySelectorAll('[data-pw-setapart-id]')].find((el) => el.getAttribute('data-pw-setapart-id') === id)?.focus({ preventScroll: true });
|
|
353
|
+
// Whatever the answer was, the list is read again so it shows what is true now.
|
|
354
|
+
void ctx.reload();
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** The project step as a place to answer set-apart folders. */
|
|
359
|
+
function stepContext(mine) {
|
|
360
|
+
return {
|
|
361
|
+
where: 'step',
|
|
362
|
+
items: () => mine.view.setApart || [],
|
|
363
|
+
rows: () => mine.view.setApartRows || {},
|
|
364
|
+
setRow: (id, row) => { mine.view = { ...mine.view, setApartRows: { ...(mine.view.setApartRows || {}), [id]: row } }; },
|
|
365
|
+
repaint: () => paint(),
|
|
366
|
+
announce: (text) => announce(mine.pane, text),
|
|
367
|
+
alive: () => state === mine,
|
|
368
|
+
host: () => mine.pane,
|
|
369
|
+
afterAnswer: () => { mine.focusAfterSetApart = true; },
|
|
370
|
+
reload: () => load(),
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* #2603: the Workflows page shows the set-apart folders no project step can — the standalone workflows' and those in
|
|
376
|
+
* a folder no project lives in. aware.js owns the page and calls this after each paint with the slot and the list.
|
|
377
|
+
*/
|
|
378
|
+
const landing = { host: null, items: [], rows: {}, reload: null, focusNext: false };
|
|
379
|
+
function landingContext() {
|
|
380
|
+
return {
|
|
381
|
+
where: 'landing',
|
|
382
|
+
items: () => landing.items,
|
|
383
|
+
rows: () => landing.rows,
|
|
384
|
+
setRow: (id, row) => { landing.rows = { ...landing.rows, [id]: row }; },
|
|
385
|
+
repaint: () => paintLanding(),
|
|
386
|
+
announce: (text) => { const live = landing.host?.querySelector('.pw-live'); if (live) live.textContent = text; },
|
|
387
|
+
alive: () => !!landing.host && landing.host.isConnected,
|
|
388
|
+
host: () => landing.host,
|
|
389
|
+
afterAnswer: () => { landing.focusNext = true; },
|
|
390
|
+
reload: () => (typeof landing.reload === 'function' ? landing.reload() : undefined),
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function paintLanding() {
|
|
394
|
+
if (!landing.host) return;
|
|
395
|
+
const active = landing.host.contains(document.activeElement) ? document.activeElement?.getAttribute('data-command-id') : null;
|
|
396
|
+
landing.host.innerHTML = '<span class="sr-only pw-live" role="status" aria-live="polite"></span>'
|
|
397
|
+
+ setApartHtml({ setApart: landing.items, setApartRows: landing.rows }, 'landing');
|
|
398
|
+
const again = active ? [...landing.host.querySelectorAll('[data-command-id]')].find((el) => el.getAttribute('data-command-id') === active) : null;
|
|
399
|
+
if (again) again.focus({ preventScroll: true });
|
|
400
|
+
else if (landing.focusNext) landing.host.querySelector('[data-pw-setapart]')?.focus({ preventScroll: true });
|
|
401
|
+
landing.focusNext = false;
|
|
402
|
+
}
|
|
403
|
+
function renderLandingSetApart(host, quarantined, reload) {
|
|
404
|
+
if (!host) return;
|
|
405
|
+
const items = (Array.isArray(quarantined) ? quarantined : []).filter((q) => q && q.folder && (q.folder.kind === 'standalone' || !q.folder.projectId));
|
|
406
|
+
const keep = new Set(items.map((q) => setApartKey(q)));
|
|
407
|
+
landing.rows = Object.fromEntries(Object.entries(landing.rows).filter(([id, row]) => keep.has(id) && (row.unreadable || row.error))
|
|
408
|
+
.map(([id, row]) => [id, { ...row, busy: undefined }]));
|
|
409
|
+
landing.host = host;
|
|
410
|
+
landing.items = items;
|
|
411
|
+
landing.reload = reload;
|
|
412
|
+
paintLanding();
|
|
413
|
+
}
|
|
414
|
+
|
|
229
415
|
async function newWorkflow(button) {
|
|
230
416
|
const mine = state;
|
|
231
417
|
if (!mine || mine.view.busyNew) return;
|
|
@@ -248,9 +434,13 @@
|
|
|
248
434
|
}
|
|
249
435
|
|
|
250
436
|
document.addEventListener('click', (event) => {
|
|
437
|
+
const onLanding = landing.host && landing.host.contains(event.target) ? event.target.closest('[data-pw-setapart]') : null;
|
|
438
|
+
if (onLanding) { event.preventDefault(); void answerSetApart(onLanding, landingContext()); return; }
|
|
251
439
|
if (!state || !state.pane.contains(event.target)) return;
|
|
252
440
|
const open = event.target.closest('[data-pw-open]');
|
|
253
441
|
if (open) { event.preventDefault(); void openRow(open); return; }
|
|
442
|
+
const answer = event.target.closest('[data-pw-setapart]');
|
|
443
|
+
if (answer) { event.preventDefault(); void answerSetApart(answer, stepContext(state)); return; }
|
|
254
444
|
const create = event.target.closest('[data-pw-new]');
|
|
255
445
|
if (create) { event.preventDefault(); void newWorkflow(create); return; }
|
|
256
446
|
const access = event.target.closest('[data-pw-access]');
|
|
@@ -270,5 +460,47 @@
|
|
|
270
460
|
}, true);
|
|
271
461
|
window.addEventListener('floless:apps-changed', refresh);
|
|
272
462
|
|
|
273
|
-
|
|
463
|
+
/**
|
|
464
|
+
* #2603: the sentence a Duplicate or Import adds about the project's workflows, from the transfer's `workflowTransfer`.
|
|
465
|
+
* Null when there is nothing to say (no workflows, or an answer without the field). `warn` when any were not copied.
|
|
466
|
+
*/
|
|
467
|
+
const NOT_COPIED_WHY = {
|
|
468
|
+
'not-this-projects': 'it names another project as its owner',
|
|
469
|
+
'metadata-unreadable': 'its details couldn’t be read',
|
|
470
|
+
'source-unreadable': 'its workflow file couldn’t be read',
|
|
471
|
+
'ambiguous': 'the archive holds two different versions of it',
|
|
472
|
+
'unavailable': 'FloLess couldn’t read them just now',
|
|
473
|
+
};
|
|
474
|
+
function transferNote(raw, operation = 'duplicate') {
|
|
475
|
+
if (!raw || typeof raw !== 'object' || !Number.isInteger(raw.copied) || !Array.isArray(raw.notCopied)) return null;
|
|
476
|
+
const keeps = operation === 'import' ? 'They are still in the archive.' : 'The original keeps them.';
|
|
477
|
+
if (raw.outcome === 'unavailable') {
|
|
478
|
+
return { text: `FloLess couldn’t copy its workflows just now, so it has none. ${keeps}`, warn: true };
|
|
479
|
+
}
|
|
480
|
+
const parts = [];
|
|
481
|
+
if (raw.copied > 0) {
|
|
482
|
+
const archived = Number.isInteger(raw.archivedCopied) && raw.archivedCopied > 0 ? `, ${raw.archivedCopied} archived` : '';
|
|
483
|
+
parts.push(`${raw.copied} ${raw.copied === 1 ? 'workflow' : 'workflows'} copied as ${raw.copied === 1 ? 'a draft' : 'drafts'}${archived}.`);
|
|
484
|
+
}
|
|
485
|
+
const left = Number.isInteger(raw.leftBehindFiles) ? raw.leftBehindFiles : 0;
|
|
486
|
+
if (left > 0) parts.push(`${left} other ${left === 1 ? 'file' : 'files'} in the workflow folders, such as chats, ${left === 1 ? 'wasn’t' : 'weren’t'} carried.`);
|
|
487
|
+
if (raw.notCopied.length) {
|
|
488
|
+
const groups = new Map();
|
|
489
|
+
for (const row of raw.notCopied) {
|
|
490
|
+
const why = NOT_COPIED_WHY[row && row.reason] || 'FloLess couldn’t read it';
|
|
491
|
+
if (!groups.has(why)) groups.set(why, []);
|
|
492
|
+
groups.get(why).push(row && typeof row.displayName === 'string' && row.displayName ? `“${row.displayName}”` : null);
|
|
493
|
+
}
|
|
494
|
+
const said = [...groups].map(([why, names]) => {
|
|
495
|
+
const named = names.filter(Boolean).slice(0, 2);
|
|
496
|
+
const rest = names.length - named.length;
|
|
497
|
+
const who = named.length ? `${named.join(' and ')}${rest ? ` and ${rest} more` : ''}` : `${rest} ${rest === 1 ? 'workflow' : 'workflows'}`;
|
|
498
|
+
return `${who} (${why})`;
|
|
499
|
+
});
|
|
500
|
+
parts.push(`Not copied: ${said.join('; ')}. ${operation === 'import' ? `${raw.notCopied.length === 1 ? 'It is' : 'They are'} still in the archive.` : `The original keeps ${raw.notCopied.length === 1 ? 'it' : 'them'}.`}`);
|
|
501
|
+
}
|
|
502
|
+
return parts.length ? { text: parts.join(' '), warn: raw.notCopied.length > 0 } : null;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
window.flolessProjectWorkflows = { render, refresh, html, runLine, transferNote, renderLandingSetApart };
|
|
274
506
|
})();
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflows → History (docs/superpowers/specs/2026-10-23-workflow-run-history-design.md): every run of every workflow,
|
|
3
|
+
* grouped per workflow, newest first. The server builds the list from AWARE's traces (GET /api/workflows/run-history);
|
|
4
|
+
* this file only renders it into the panel web/aware.js gives it, the way web/pages.js renders the Pages tab.
|
|
5
|
+
*/
|
|
6
|
+
(function () {
|
|
7
|
+
const bridge = window.flolessBridge || {};
|
|
8
|
+
const api = bridge.api || (async (path) => {
|
|
9
|
+
const res = await fetch(path);
|
|
10
|
+
const body = await res.json().catch(() => ({}));
|
|
11
|
+
if (!res.ok) throw Object.assign(new Error(body.error || 'request failed'), { status: res.status, body });
|
|
12
|
+
return body;
|
|
13
|
+
});
|
|
14
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
15
|
+
const toast = (msg, kind) => { if (typeof window.showToast === 'function') window.showToast(msg, kind); };
|
|
16
|
+
|
|
17
|
+
const OUTCOME = {
|
|
18
|
+
succeeded: 'Succeeded', failed: 'Failed', stopped: 'Stopped', running: 'Running', 'not-run': 'Didn’t run', simulated: 'Simulated',
|
|
19
|
+
};
|
|
20
|
+
const ENDED_EARLY = 'No end was recorded for this run: it was stopped, FloLess closed while it ran, or it is still running outside FloLess. Run it again to get a complete result.';
|
|
21
|
+
const failedTip = (step) => (step
|
|
22
|
+
? `This run stopped at the step “${step}”. Open the workflow to check that step, then run it again.`
|
|
23
|
+
: 'This run failed. Open the workflow to see what went wrong, then run it again.');
|
|
24
|
+
const DAMAGED = 'FloLess couldn’t read this workflow’s files, so it can’t be opened or run. Its earlier runs are still listed. Ask AI Chat to repair or reinstall it.';
|
|
25
|
+
const MISSING = 'This workflow’s compiled copy is missing, so it can’t run until it is compiled again. Its earlier runs are still listed; Open workflow opens it so you can compile it.';
|
|
26
|
+
const AI_TIP = 'An AI step answered part of this run, so its output can differ from run to run.';
|
|
27
|
+
const SIM_TIP = 'A simulated or trial run: FloLess checked the steps without changing your model, so it made nothing.';
|
|
28
|
+
const UNREADABLE = 'FloLess couldn’t read this workflow’s runs. Check that the files in your AWARE folder are available, then try again.';
|
|
29
|
+
|
|
30
|
+
/** What was last read, so a repaint (a search, coming back to the tab) shows it at once. */
|
|
31
|
+
let cache = null;
|
|
32
|
+
/** Which sections the person opened or closed, by workflow id, kept across repaints. A search opens its matches. */
|
|
33
|
+
const openState = new Map();
|
|
34
|
+
let clickedSection = null;
|
|
35
|
+
const lists = new Set();
|
|
36
|
+
|
|
37
|
+
const when = (iso) => {
|
|
38
|
+
const t = Date.parse(iso);
|
|
39
|
+
return Number.isFinite(t)
|
|
40
|
+
? new Date(t).toLocaleString(undefined, { day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit' }) : '';
|
|
41
|
+
};
|
|
42
|
+
function duration(ms) {
|
|
43
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms)) return '';
|
|
44
|
+
const s = Math.round(ms / 1000);
|
|
45
|
+
if (s < 1) return 'under 1 s';
|
|
46
|
+
if (s < 60) return `${s} s`;
|
|
47
|
+
if (s < 3600) return `${Math.floor(s / 60)} min ${s % 60} s`;
|
|
48
|
+
return `${Math.floor(s / 3600)} h ${Math.floor((s % 3600) / 60)} min`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function rowHtml(w, r) {
|
|
52
|
+
const key = r.runId || `${r.routine?.id || 'routine'}@${r.startedAt}`;
|
|
53
|
+
const label = `${w.name}, ${when(r.startedAt)}`;
|
|
54
|
+
const tip = r.outcome === 'stopped' && r.endedEarly ? ENDED_EARLY : r.outcome === 'simulated' ? SIM_TIP
|
|
55
|
+
: r.outcome === 'failed' ? failedTip(r.failedStep) : '';
|
|
56
|
+
const detail = r.outcome === 'failed' && r.failedStep ? `At step “${r.failedStep}”` : r.outcome === 'not-run' ? (r.reason || '') : '';
|
|
57
|
+
const pills = [
|
|
58
|
+
r.routine ? `<span class="rh-pill" data-tip="${esc(`Started by the routine “${r.routine.name}”.`)}">Routine: ${esc(r.routine.name)}</span>` : '',
|
|
59
|
+
r.aiStep ? `<span class="pg-ai-badge rh-ai" tabindex="0" data-tip="${esc(AI_TIP)}">AI step</span>` : '',
|
|
60
|
+
r.simulated && r.outcome !== 'simulated' ? `<span class="rh-pill" data-tip="${esc(SIM_TIP)}">Simulated</span>` : '',
|
|
61
|
+
].join('');
|
|
62
|
+
const report = r.report && r.runId && !w.damaged && !w.missing
|
|
63
|
+
? `<button type="button" class="btn-mini rh-btn" data-rh-report="${esc(r.runId)}" data-rh-app="${esc(w.id)}" data-command-id="shell.workflows-history-report#${esc(r.runId)}" data-command-instance-label="${esc(label)}" aria-label="${esc(`View report: ${label}`)}" data-tip="Opens the report this run made">View report</button>` : '';
|
|
64
|
+
const rowClass = r.outcome === 'failed' ? ' is-failed' : r.outcome === 'not-run' ? ' is-not-run' : '';
|
|
65
|
+
return `<div class="rh-row${rowClass}" role="listitem" data-rh-run="${esc(key)}">`
|
|
66
|
+
+ `<time class="rh-when" datetime="${esc(r.startedAt)}">${esc(when(r.startedAt))}</time>`
|
|
67
|
+
+ `<span class="rh-outcome rh-${esc(r.outcome)}"${tip ? ` tabindex="0" data-tip="${esc(tip)}"` : ''}>${esc(OUTCOME[r.outcome] || r.outcome)}</span>`
|
|
68
|
+
+ `<span class="rh-dur">${esc(duration(r.durationMs))}</span>`
|
|
69
|
+
+ `<span class="rh-detail">${detail ? `<span class="rh-detail-text"${r.outcome === 'failed' ? ` data-tip="${esc(detail)}"` : ''}>${esc(detail)}</span>` : ''}${pills}</span>`
|
|
70
|
+
+ `<span class="rh-actions">${report}${w.damaged ? '' : `<button type="button" class="btn-mini rh-btn rh-open" data-rh-${w.missing ? 'draft' : 'open'}="${esc(w.id)}" data-command-id="shell.workflows-history-open#${esc(key)}" data-command-instance-label="${esc(label)}" aria-label="${esc(`Open workflow: ${label}`)}" data-tip="Opens this workflow">Open workflow</button>`}</span>`
|
|
71
|
+
+ `</div>`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function sectionHtml(w, open) {
|
|
75
|
+
const last = w.runs[0];
|
|
76
|
+
const summaryLast = last ? `Last run ${when(last.startedAt)}, ${(OUTCOME[last.outcome] || last.outcome).toLowerCase()}` : '';
|
|
77
|
+
const count = w.unreadable ? (w.runs.length ? `${w.total} runs, some couldn’t be read` : 'Runs couldn’t be read')
|
|
78
|
+
: `${w.total} run${w.total === 1 ? '' : 's'}`;
|
|
79
|
+
return `<details class="ws-archived wf-section rh-section" data-rh-workflow="${esc(w.id)}"${open ? ' open' : ''}>`
|
|
80
|
+
+ `<summary class="ws-archived-summary rh-summary" data-command-id="shell.workflows-history-section#${esc(w.id)}" data-command-instance-label="${esc(w.name)}">`
|
|
81
|
+
+ `<span class="ws-archived-caret hd-caret" aria-hidden="true">▸</span><span class="rh-sum-name">${esc(w.name)}</span>`
|
|
82
|
+
+ (w.ownerLabel ? `<span class="rh-sum-meta">${esc(w.ownerLabel)}</span>` : '')
|
|
83
|
+
+ `<span class="rh-sum-meta">${count}</span>`
|
|
84
|
+
+ (summaryLast ? `<span class="rh-sum-meta">${esc(summaryLast)}</span>` : '')
|
|
85
|
+
+ `</summary>`
|
|
86
|
+
+ (w.damaged ? `<p class="pg-wf-note" role="status">${esc(DAMAGED)}</p>` : '')
|
|
87
|
+
+ (w.missing ? `<p class="pg-wf-note" role="status">${esc(MISSING)}</p>` : '')
|
|
88
|
+
+ (w.unreadable ? `<p class="pg-wf-note" role="status">${esc(UNREADABLE)}</p>` : '')
|
|
89
|
+
+ (w.total > w.runs.length ? `<p class="rh-cut">Showing the newest ${w.runs.length} of ${w.total} runs.</p>` : '')
|
|
90
|
+
+ (w.runs.length ? `<div class="rh-list" role="list" aria-label="${esc(`Runs of ${w.name}`)}">${w.runs.map((r) => rowHtml(w, r)).join('')}</div>` : '')
|
|
91
|
+
+ `</details>`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const matches = (w, terms) => terms.every((t) => `${w.name} ${w.ownerLabel || ''}`.toLowerCase().includes(t));
|
|
95
|
+
|
|
96
|
+
function paint(container, opts) {
|
|
97
|
+
const query = String(opts?.getQuery?.() ?? '').trim();
|
|
98
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
99
|
+
const focused = container.contains(document.activeElement) ? document.activeElement?.getAttribute('data-command-id') : null;
|
|
100
|
+
container.dataset.rhState = 'ready';
|
|
101
|
+
if (!cache.length) {
|
|
102
|
+
container.innerHTML = `<div class="pg-empty"><p>No runs yet. Open a workflow and run it, and its runs will show here.</p>`
|
|
103
|
+
+ `<p><button type="button" class="ghost rh-act" data-rh-act="show-workflows" data-command-id="shell.workflows-history-show-workflows">Show workflows</button></p></div>`;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const shown = cache.filter((w) => matches(w, terms));
|
|
107
|
+
if (!shown.length) {
|
|
108
|
+
container.innerHTML = `<div class="pg-empty" role="status"><p class="rh-nomatch"></p>`
|
|
109
|
+
+ `<p><button type="button" class="ghost rh-act" data-rh-act="clear-search" data-command-id="shell.workflows-history-clear-search">Clear search</button></p></div>`;
|
|
110
|
+
container.querySelector('.rh-nomatch').textContent = `No workflow matches “${query}”.`; // text, never markup: it echoes what was typed
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// An unreadable section starts open: its note is the thing to see.
|
|
114
|
+
container.innerHTML = shown.map((w, i) => sectionHtml(w, terms.length > 0
|
|
115
|
+
|| (openState.has(w.id) ? openState.get(w.id) : i === 0 || Boolean(w.unreadable)))).join('');
|
|
116
|
+
if (focused && document.activeElement === document.body) {
|
|
117
|
+
[...container.querySelectorAll('[data-command-id]')].find((el) => el.getAttribute('data-command-id') === focused)?.focus({ preventScroll: true });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Draw the list again from what was last read: nothing is fetched. */
|
|
122
|
+
function repaint(container) {
|
|
123
|
+
const entry = [...lists].find((e) => e.container === container);
|
|
124
|
+
if (entry && cache && container.dataset.rhState === 'ready') paint(container, entry.opts);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Render the run history into `container`. `opts.getQuery()` is the landing's search text; `opts.onAction(act)` hears the
|
|
129
|
+
* buttons that leave this list ('show-workflows', 'clear-search'); `opts.openWorkflow(appId)`, `opts.openDraft(workflowId)`
|
|
130
|
+
* (a workflow you own whose compiled copy is missing) and `opts.openReport(appId, runId)` open what a row points at.
|
|
131
|
+
*/
|
|
132
|
+
async function render(container, opts = {}) {
|
|
133
|
+
if (!container) return;
|
|
134
|
+
for (const e of [...lists]) if (e.container === container || !e.container.isConnected) lists.delete(e);
|
|
135
|
+
const entry = { container, opts };
|
|
136
|
+
lists.add(entry);
|
|
137
|
+
wire(container, entry);
|
|
138
|
+
const token = (container.dataset.rhToken = String(Math.random()));
|
|
139
|
+
if (cache) paint(container, opts);
|
|
140
|
+
else { container.dataset.rhState = 'loading'; container.innerHTML = '<p class="pg-loading-line" role="status">Reading runs…</p>'; }
|
|
141
|
+
const current = () => container.dataset.rhToken === token && container.isConnected;
|
|
142
|
+
let body;
|
|
143
|
+
try { body = await api('/api/workflows/run-history'); } catch (err) {
|
|
144
|
+
if (!current()) return;
|
|
145
|
+
console.warn('The run history could not be read', err);
|
|
146
|
+
cache = null;
|
|
147
|
+
container.dataset.rhState = 'error';
|
|
148
|
+
const said = typeof err?.body?.error === 'string' && err.body.error ? err.body.error
|
|
149
|
+
: 'FloLess couldn’t read the run history. Check that FloLess is running, then try again.';
|
|
150
|
+
container.innerHTML = `<div class="pg-empty" role="alert"><p>${esc(said)}</p>`
|
|
151
|
+
+ `<p><button type="button" class="ghost rh-act" data-rh-act="retry" data-command-id="shell.workflows-history-retry">Try again</button></p></div>`;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (!current()) return;
|
|
155
|
+
cache = (Array.isArray(body.workflows) ? body.workflows : []).filter((w) => w && typeof w.id === 'string' && Array.isArray(w.runs));
|
|
156
|
+
paint(container, opts);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** A run ended somewhere: read the history again for every list on screen. */
|
|
160
|
+
function refresh() {
|
|
161
|
+
for (const e of [...lists]) {
|
|
162
|
+
if (!e.container.isConnected) { lists.delete(e); continue; }
|
|
163
|
+
void render(e.container, e.opts);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const wired = new WeakSet();
|
|
168
|
+
function wire(container, entry) {
|
|
169
|
+
entry.container._rhEntry = entry;
|
|
170
|
+
if (wired.has(container)) return;
|
|
171
|
+
wired.add(container);
|
|
172
|
+
// A section drawn open fires `toggle` too, so only a toggle that follows a click on its heading is the person's.
|
|
173
|
+
container.addEventListener('toggle', (event) => {
|
|
174
|
+
const box = event.target.closest?.('.rh-section');
|
|
175
|
+
if (box && box.dataset.rhWorkflow === clickedSection) { openState.set(clickedSection, box.open); clickedSection = null; }
|
|
176
|
+
}, true);
|
|
177
|
+
container.addEventListener('click', (event) => {
|
|
178
|
+
const opts = container._rhEntry?.opts || {};
|
|
179
|
+
if (event.target.closest('.rh-summary')) clickedSection = event.target.closest('.rh-section')?.dataset.rhWorkflow ?? null;
|
|
180
|
+
const open = event.target.closest('[data-rh-open]');
|
|
181
|
+
if (open) { opts.openWorkflow?.(open.dataset.rhOpen); return; }
|
|
182
|
+
const draft = event.target.closest('[data-rh-draft]');
|
|
183
|
+
if (draft) { opts.openDraft?.(draft.dataset.rhDraft); return; }
|
|
184
|
+
const report = event.target.closest('[data-rh-report]');
|
|
185
|
+
if (report) {
|
|
186
|
+
Promise.resolve(opts.openReport?.(report.dataset.rhApp, report.dataset.rhReport))
|
|
187
|
+
.catch((err) => toast(err?.message || 'FloLess couldn’t open that run’s report. Open the workflow to see its latest results.', 'warn'));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const act = event.target.closest('[data-rh-act]');
|
|
191
|
+
if (!act) return;
|
|
192
|
+
if (act.dataset.rhAct === 'retry') void render(container, opts);
|
|
193
|
+
else opts.onAction?.(act.dataset.rhAct);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
window.flolessRunHistory = { render, repaint, refresh };
|
|
198
|
+
})();
|
|
@@ -180,7 +180,8 @@
|
|
|
180
180
|
setNote(NOTES.none); stopPoll(v); return;
|
|
181
181
|
}
|
|
182
182
|
if (a.state === 'failed') {
|
|
183
|
-
|
|
183
|
+
// #2644: locked is not a failed save, so it never tells the person to run again: the module's sentence says what to do.
|
|
184
|
+
setNote(a.locked ? sentence(a.reason) : a.reason ? sentence(a.reason) + ' ' + FAILED_TAIL : 'This report could not be saved to the workflow’s Page. ' + FAILED_TAIL);
|
|
184
185
|
stopPoll(v); return;
|
|
185
186
|
}
|
|
186
187
|
// saved
|
|
@@ -235,9 +236,18 @@
|
|
|
235
236
|
catch (e) { /* the header link is a convenience; the frame below does not depend on it */ }
|
|
236
237
|
}
|
|
237
238
|
apply(v, a, false);
|
|
238
|
-
}).catch(function () {
|
|
239
|
+
}).catch(function (err) {
|
|
239
240
|
if (stale(v, g)) return;
|
|
240
241
|
if (v.lookupSeq === seq) v.lookupBusy = false;
|
|
242
|
+
// #2644: a Drawing Checker or Steel Model workflow this account's plan does not include. That is an answer, not a
|
|
243
|
+
// lookup that failed for now: say why, in the module's own words, and stop asking.
|
|
244
|
+
var locked = err && err.status === 403 && err.body && typeof err.body.userMessage === 'string' ? err.body.userMessage.trim() : '';
|
|
245
|
+
// Only the latest lookup may answer: an older one's refusal never overwrites a newer answer.
|
|
246
|
+
if (locked && v.lookupSeq !== seq) return;
|
|
247
|
+
if (locked) {
|
|
248
|
+
apply(v, { state: 'failed', locked: true, rev: v.held.rev + 1, epoch: v.held.epoch || 'locked', version: null, files: null, filesWithheld: '', reason: locked, frameUrl: '' }, false);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
241
251
|
// The question could not be answered (offline, slow): keep what is shown and ask again while it matters.
|
|
242
252
|
var a = v.held.answer;
|
|
243
253
|
if (!a || a.state === 'pending' || a.state === 'none' || (a.state === 'saved' && a.files > 0 && !a.frameUrl)) ensurePoll(v);
|
|
@@ -1150,6 +1150,30 @@ export function sheetIncludesElevation(fromZ, toZ, elevMm, tol = MODEL_V2_TOL.CU
|
|
|
1150
1150
|
*/
|
|
1151
1151
|
export const COLUMN_BELOW_REACH_MM = FT_TO_MM; // 12" = one foot, from the one definition of the foot (steel-units.js), not a second 304.8
|
|
1152
1152
|
|
|
1153
|
+
/**
|
|
1154
|
+
* The same convention for a project built to a metric standard: a round 300 mm, not the 304.8 a
|
|
1155
|
+
* converted foot lands on (owner ruling, Pawel, 2026-10-23 — asked as "should the minimum column stub
|
|
1156
|
+
* be a round 300 mm instead of the imperial 304.8 mm it inherits today?", answered yes).
|
|
1157
|
+
*
|
|
1158
|
+
* The number a UK detailer reads off this setting is a drafting convention in their own units; 304.8
|
|
1159
|
+
* is an artefact of where the default came from, and it showed through verbatim — a BS/EN project's
|
|
1160
|
+
* Inspect pane read "Columns ending up to 304.8 mm under this level are drawn dashed".
|
|
1161
|
+
*
|
|
1162
|
+
* KEYED ON THE PROJECT'S ENVIRONMENT, NOT ITS DISPLAY UNITS, and that is the load-bearing choice.
|
|
1163
|
+
* `displayUnits` is a per-person VIEW preference that flips at any time, while this resolver decides
|
|
1164
|
+
* what a SHEET DRAWS and is asked by the server's `membersOnSheet` as well as the browser — where no
|
|
1165
|
+
* display preference exists at all. Tying it to the view toggle would make switching units silently
|
|
1166
|
+
* change which columns appear on a drawing, and would let the two callers disagree. `environment` is
|
|
1167
|
+
* immutable, is a property of the project rather than of the reader, and is exactly the question
|
|
1168
|
+
* "which standard is this built to".
|
|
1169
|
+
*/
|
|
1170
|
+
export const COLUMN_BELOW_REACH_MM_METRIC = 300;
|
|
1171
|
+
|
|
1172
|
+
/** The default reach for a project built to `environment` — metric standards get the round number. */
|
|
1173
|
+
export function defaultColumnBelowReach(environment) {
|
|
1174
|
+
return environment === 'UK' ? COLUMN_BELOW_REACH_MM_METRIC : COLUMN_BELOW_REACH_MM;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1153
1177
|
/**
|
|
1154
1178
|
* The most a person may set the reach to: 100 ft. A column that ends further under a floor than that is not "the
|
|
1155
1179
|
* column below" this floor in any building, so a larger number is a typing mistake (a bare 8839 in a project that
|
|
@@ -1173,7 +1197,11 @@ export function isValidColumnBelowReach(mm) {
|
|
|
1173
1197
|
*/
|
|
1174
1198
|
export function columnBelowReachOf(doc) {
|
|
1175
1199
|
const stored = doc && typeof doc === 'object' ? doc.column_below_reach_mm : undefined;
|
|
1176
|
-
|
|
1200
|
+
if (isValidColumnBelowReach(stored)) return stored;
|
|
1201
|
+
// Only the DEFAULT varies by standard. A stored reach is the person's own number and is returned
|
|
1202
|
+
// verbatim whatever the environment — converting it here would change a saved drawing convention
|
|
1203
|
+
// behind their back, and a project that switched standards cannot exist (environment is immutable).
|
|
1204
|
+
return defaultColumnBelowReach(doc && typeof doc === 'object' ? doc.environment : undefined);
|
|
1177
1205
|
}
|
|
1178
1206
|
|
|
1179
1207
|
/**
|