@floless/app 0.156.0 → 0.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli-actions.mjs +21 -5
- package/dist/floless-server.cjs +70965 -43326
- package/dist/schemas/drawing-check.profile.v1.schema.json +15 -2
- package/dist/schemas/steel.model.v2.schema.json +25 -1
- package/dist/skills/floless-app-actions/SKILL.md +79 -17
- package/dist/skills/floless-app-knowledge/SKILL.md +21 -2
- package/dist/skills/floless-app-new-workflow/SKILL.md +23 -7
- package/dist/skills/floless-app-onboarding/SKILL.md +31 -1
- package/dist/skills/floless-app-report-issue/SKILL.md +3 -3
- package/dist/skills/floless-app-rfi/SKILL.md +40 -6
- package/dist/skills/floless-app-routines/SKILL.md +9 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +1 -1
- package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +4 -2
- package/dist/skills/floless-app-tweak-contract/SKILL.md +25 -5
- package/dist/skills/floless-app-workflows/SKILL.md +46 -10
- package/dist/skills/floless-app-workflows/references/agent-steps.md +119 -0
- package/dist/web/agent-steps.js +864 -47
- package/dist/web/agents.js +28 -8
- package/dist/web/app.css +478 -3
- package/dist/web/app.js +110 -11
- package/dist/web/aware-update-client.js +1 -0
- package/dist/web/aware.js +685 -170
- package/dist/web/chat-landing-scene.js +372 -0
- package/dist/web/chat.css +245 -1
- package/dist/web/chat.js +2466 -78
- package/dist/web/commands-drawing-check.js +17 -0
- package/dist/web/commands-shell.js +820 -3
- package/dist/web/commands-steel.js +6 -0
- package/dist/web/connections.js +1 -0
- package/dist/web/drawing-check-editor.html +33 -5
- package/dist/web/drawing-check-editor.js +538 -22
- package/dist/web/drawing-check-overlay.js +13 -0
- package/dist/web/flo-avatar.js +28 -3
- package/dist/web/guide.js +7 -2
- package/dist/web/index.html +119 -6
- package/dist/web/instructor.js +3 -3
- package/dist/web/model-view-query.js +12 -2
- package/dist/web/pages.js +865 -34
- package/dist/web/panels.js +5 -2
- package/dist/web/parser-setup-recovery.js +12 -4
- package/dist/web/project-access.js +549 -0
- package/dist/web/report-files.js +50 -0
- package/dist/web/startup-admission.js +132 -0
- package/dist/web/steel-3d-core.js +9 -0
- package/dist/web/steel-editor.html +642 -22
- package/dist/web/steel-model-v2-commands.js +63 -5
- package/dist/web/step-rename.js +287 -0
- package/dist/web/terminal-requests.js +59 -10
- package/dist/web/tool-updates.js +1 -0
- package/dist/web/workspace-root-management.js +39 -0
- package/dist/web/workspaces.js +1667 -63
- package/launch.mjs +9 -7
- package/package.json +3 -1
|
@@ -59,10 +59,38 @@ const carryAssumed = (prev, next) => (prev && prev.assumed === true
|
|
|
59
59
|
// the new number is no longer what they answered (and a typed elevation is their own statement anyway).
|
|
60
60
|
: prev && prev.answered && typeof prev.answered === 'object' && next && next.known === prev.known
|
|
61
61
|
? { ...next, answered: prev.answered }
|
|
62
|
-
:
|
|
62
|
+
// A height the AI DECIDED in a Quick build (#2521) rides along on every move, like a placed one: a
|
|
63
|
+
// translated AI height is still the AI's. Only a person typing an elevation replaces it.
|
|
64
|
+
: prev && prev.decided && typeof prev.decided === 'object' && next
|
|
65
|
+
? { ...next, decided: prev.decided }
|
|
66
|
+
: next);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The decision an end's height was DERIVED from (#2521): a copy, a split or a merge makes a new end whose height
|
|
70
|
+
* came from an AI decision about another end. It still rests on that decision, so the mark stays, but `derived`
|
|
71
|
+
* says it is not the decision's own subject, so Make precise never asks it as if it were.
|
|
72
|
+
*/
|
|
73
|
+
const derivedDecision = (decided) => ({ ...decided, derived: true });
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* One DERIVED decision standing for every AI decision a new end's height came from (#2521, Codex review): a split
|
|
77
|
+
* point between two AI heights, or a merge of members that each carry one, rests on all of them. The first is
|
|
78
|
+
* `decisionId`; the others are `alsoRestsOn`, so Make precise can ask every one. `null` when none is the AI's.
|
|
79
|
+
*/
|
|
80
|
+
function derivedFromAll(zs) {
|
|
81
|
+
const decided = zs.filter((z) => z && z.decided && typeof z.decided === 'object');
|
|
82
|
+
if (!decided.length) return null;
|
|
83
|
+
const first = decided[0].decided;
|
|
84
|
+
const others = [...new Set(decided.flatMap((z) => [z.decided.decisionId, ...(z.decided.alsoRestsOn || [])]))]
|
|
85
|
+
.filter((id) => id !== first.decisionId);
|
|
86
|
+
const { alsoRestsOn: _drop, ...rest } = first;
|
|
87
|
+
return { ...rest, derived: true, ...(others.length ? { alsoRestsOn: others } : {}) };
|
|
88
|
+
}
|
|
63
89
|
|
|
64
90
|
/** A copied member is a NEW member: an answer the person gave about the original is not an answer about it. */
|
|
65
|
-
const withoutAnswer = (z) => (z && z.answered ? { known: z.known }
|
|
91
|
+
const withoutAnswer = (z) => (z && z.answered ? { known: z.known }
|
|
92
|
+
: z && z.decided && typeof z.decided === 'object' ? { known: z.known, decided: derivedDecision(z.decided) }
|
|
93
|
+
: z);
|
|
66
94
|
|
|
67
95
|
/*
|
|
68
96
|
* The drag-start snapshot `moveWorkPoints` compares against — every field the gizmo's availability, its
|
|
@@ -552,6 +580,19 @@ function assertSplitInferredSupportAuthority(doc) {
|
|
|
552
580
|
}
|
|
553
581
|
}
|
|
554
582
|
|
|
583
|
+
/**
|
|
584
|
+
* The end whose mark a split point inherits: a placed end first (#1155), else an end the AI decided (#2521), as a
|
|
585
|
+
* DERIVED decision, since the split point is a new end, not the decision's own subject.
|
|
586
|
+
*/
|
|
587
|
+
function splitMarkSource(fromZ, toZ) {
|
|
588
|
+
// A placed end wins over an AI one: it is the weaker claim (unproven, left out of the BOM, asked), so the split
|
|
589
|
+
// point never reads as more settled than its least settled end.
|
|
590
|
+
if (fromZ.assumed === true) return fromZ;
|
|
591
|
+
if (toZ.assumed === true) return toZ;
|
|
592
|
+
const decided = derivedFromAll([fromZ, toZ]);
|
|
593
|
+
return decided ? { known: fromZ.known, decided } : fromZ;
|
|
594
|
+
}
|
|
595
|
+
|
|
555
596
|
function interpolatedSplitPoint(original, t) {
|
|
556
597
|
const point = {
|
|
557
598
|
x: quantizeMm(original.from.x + (original.to.x - original.from.x) * t),
|
|
@@ -562,7 +603,7 @@ function interpolatedSplitPoint(original, t) {
|
|
|
562
603
|
// new members with new ids that no diff against the original could catch.
|
|
563
604
|
z: isKnown(original.from.z) && isKnown(original.to.z)
|
|
564
605
|
? carryAssumed(
|
|
565
|
-
original.from.z
|
|
606
|
+
splitMarkSource(original.from.z, original.to.z),
|
|
566
607
|
{ known: quantizeMm(original.from.z.known + (original.to.z.known - original.from.z.known) * t) },
|
|
567
608
|
)
|
|
568
609
|
: { unknown: true },
|
|
@@ -600,6 +641,11 @@ function splitMemberAt(doc, memberId, t, expect, mintId, { requireKnownElevation
|
|
|
600
641
|
const first = clone(original), second = clone(original);
|
|
601
642
|
first.id = mintId(); second.id = mintId();
|
|
602
643
|
first.to = clone(split); second.from = clone(split);
|
|
644
|
+
// #2521: the halves are NEW members, so an AI decision on the original's outer ends is not their own subject.
|
|
645
|
+
for (const [half, key] of [[first, 'from'], [second, 'to']]) {
|
|
646
|
+
const z = half[key].z;
|
|
647
|
+
if (z && z.decided && typeof z.decided === 'object') half[key] = { ...half[key], z: { ...z, decided: derivedDecision(z.decided) } };
|
|
648
|
+
}
|
|
603
649
|
if (Array.isArray(original.ends)) {
|
|
604
650
|
first.ends = [clone(original.ends[0] || {}), {}];
|
|
605
651
|
second.ends = [{}, clone(original.ends[1] || {})];
|
|
@@ -749,7 +795,11 @@ function mergeMemberGroup(doc, sheet, memberIds, mergedPx, mintId, resolveSectio
|
|
|
749
795
|
// MERGE is split's inverse and needs the same rule: if either source end was placed rather than
|
|
750
796
|
// proven, so is the survivor's. The survivor gets a NEW id, so nothing downstream can compare it
|
|
751
797
|
// against the originals to notice the mark went missing.
|
|
752
|
-
|
|
798
|
+
// And an end the AI decided (#2521), carried as DERIVED: the survivor is a new member, not the decision's subject.
|
|
799
|
+
// Every source's decision, not only the first (Codex review). A placed end still wins: it is the weaker claim.
|
|
800
|
+
const allDecided = derivedFromAll(sources.flatMap((m) => [m.from.z, m.to.z]));
|
|
801
|
+
const anyAssumed = sources.flatMap((m) => [m.from.z, m.to.z]).find((z) => z && z.assumed === true)
|
|
802
|
+
|| (allDecided ? { known: 0, decided: allDecided } : null);
|
|
753
803
|
merged.from = {x:physical.from[0],y:physical.from[1],z:carryAssumed(anyAssumed,{known:physical.from[2]})};
|
|
754
804
|
merged.to = {x:physical.to[0],y:physical.to[1],z:carryAssumed(anyAssumed,{known:physical.to[2]})};
|
|
755
805
|
for (const joint of doc.joints || []) {
|
|
@@ -1194,6 +1244,11 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
1194
1244
|
const member = memberById(doc, memberId);
|
|
1195
1245
|
if (member.role === 'column') return { changedIds: [] };
|
|
1196
1246
|
[member.from.z, member.to.z] = [member.to.z, member.from.z];
|
|
1247
|
+
// #2521: an AI decision names its end; swapped onto the other end it is no longer that end's own subject.
|
|
1248
|
+
for (const key of ['from', 'to']) {
|
|
1249
|
+
const z = member[key].z;
|
|
1250
|
+
if (z && z.decided && typeof z.decided === 'object') member[key].z = { ...z, decided: derivedDecision(z.decided) };
|
|
1251
|
+
}
|
|
1197
1252
|
if (member.ends) member.ends = [member.ends[1] || {}, member.ends[0] || {}];
|
|
1198
1253
|
for (const plan of doc.plans || []) for (const dim of plan.dims || []) {
|
|
1199
1254
|
for (const key of ['aRef', 'bRef']) {
|
|
@@ -1291,7 +1346,10 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
1291
1346
|
const source = endpoint(member, from);
|
|
1292
1347
|
known(source.z, `${memberId}.${from}`);
|
|
1293
1348
|
known(endpoint(member, to).z, `${memberId}.${to}`);
|
|
1294
|
-
|
|
1349
|
+
// #2521: a height copied onto another end is not that end's own AI decision: it is derived from it.
|
|
1350
|
+
const copied = clone(source.z);
|
|
1351
|
+
setEndpoint(member, to, { ...endpoint(member, to), z: copied && copied.decided && typeof copied.decided === 'object'
|
|
1352
|
+
? { ...copied, decided: derivedDecision(copied.decided) } : copied });
|
|
1295
1353
|
member.ends = member.ends || [{}, {}];
|
|
1296
1354
|
member.ends[to] = clone(member.ends[from] || {});
|
|
1297
1355
|
return { changedIds: [memberId] };
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Two steps share one name (#2314, epic #2241 slice 3c).
|
|
3
|
+
*
|
|
4
|
+
* When AWARE refuses to compile a workflow because two steps resolve to the same name (`E_APP_AMBIGUOUS_NODE_ID`), the server
|
|
5
|
+
* answers Compile with an ask instead of a dead end. This dialog is that ask: which of the two steps to rename (AWARE's suggestion
|
|
6
|
+
* first), the new name, the exact change in the file (an AWARE dry run, nothing written), and anything FloLess cannot be sure
|
|
7
|
+
* about. The rename is applied only when the person presses the primary button, and only exactly as previewed: the server
|
|
8
|
+
* re-makes the preview under the source lock and refuses a different one. The primary's label carries any extra consent
|
|
9
|
+
* ("Rename anyway", "Rewrite and rename"). Afterwards the caller compiles again, so the workflow is approved again and an AI
|
|
10
|
+
* step's confirmation is asked of the person again; this file never approves anything.
|
|
11
|
+
*/
|
|
12
|
+
(function () {
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const NOTE = 'Renaming edits the workflow file, so it needs compiling and approving again. If it has an AI step, you confirm that step again too.';
|
|
16
|
+
const PREVIEW_DELAY_MS = 300;
|
|
17
|
+
|
|
18
|
+
const esc = (value) => String(value ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
19
|
+
const routeOf = (target) => (target.kind === 'installed'
|
|
20
|
+
? `/api/app/${encodeURIComponent(target.id)}/steps`
|
|
21
|
+
: `/api/workflows/owned/${encodeURIComponent(target.workflowId)}/steps`);
|
|
22
|
+
|
|
23
|
+
/** How a step is named in the dialog: where it sits, in plain words, with its name in code type. */
|
|
24
|
+
function stepLabel(step) {
|
|
25
|
+
if (!step) return 'This step';
|
|
26
|
+
return step.where && step.where !== 'a top-level step'
|
|
27
|
+
? `The step <span class="sr-code">“${esc(step.id)}”</span> ${esc(step.where)}`
|
|
28
|
+
: `The top-level step <span class="sr-code">“${esc(step.id)}”</span>`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The same, as plain text (a radio's accessible name). */
|
|
32
|
+
function stepText(step, fallback) {
|
|
33
|
+
if (!step) return `The step “${fallback}”`;
|
|
34
|
+
return step.where && step.where !== 'a top-level step' ? `The step “${step.id}” ${step.where}` : `The top-level step “${step.id}”`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The words of the dialog for one preview. Pure: no DOM, so it can be tested on its own. */
|
|
38
|
+
function previewView(preview, step) {
|
|
39
|
+
const edits = Array.isArray(preview.edits) ? preview.edits : [];
|
|
40
|
+
const uncertain = Array.isArray(preview.uncertain) ? preview.uncertain : [];
|
|
41
|
+
// Every planned edit, in a scroll box: "Exact change in the file" is exactly that, never a sample.
|
|
42
|
+
const shown = edits.map((e) =>
|
|
43
|
+
`<span class="sr-was">Line ${esc(e.line)} before: ${esc(String(e.before).trim())}</span>\n<span class="sr-now">Line ${esc(e.line)} after: ${esc(String(e.after).trim())}</span>`).join('\n');
|
|
44
|
+
const sentence = `${stepLabel(step)} will be called <span class="sr-code">“${esc(preview.to)}”</span>.`
|
|
45
|
+
+ (edits.length > 1 ? ` ${edits.length} places in the file change.` : '');
|
|
46
|
+
const body = `<div>${sentence}</div>`
|
|
47
|
+
+ (edits.length ? `<div class="fm-note-label">Exact change in the file</div><pre class="sr-lines" tabindex="0" aria-label="Exact change in the file">${shown}</pre>` : '');
|
|
48
|
+
const warnings = [];
|
|
49
|
+
if (uncertain.length) {
|
|
50
|
+
warnings.push(`<b>Check these.</b> After the rename they may read a different step:<ul class="sr-warning-list">${uncertain.map((u) =>
|
|
51
|
+
`<li><span class="sr-code">“${esc(u.text)}”</span>${u.step ? ` in the “${esc(u.step)}” step` : ''}</li>`).join('')}</ul>`);
|
|
52
|
+
}
|
|
53
|
+
if (preview.needsRewrite) warnings.push('<b>Heads up.</b> Renaming rewrites the whole workflow file, which removes its comments.');
|
|
54
|
+
const primary = uncertain.length && preview.needsRewrite ? 'Rewrite and rename anyway'
|
|
55
|
+
: uncertain.length ? 'Rename anyway' : preview.needsRewrite ? 'Rewrite and rename' : 'Rename step';
|
|
56
|
+
return { body, warning: warnings.join('<br>'), primary };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function post(url, body) {
|
|
60
|
+
const response = await fetch(url, { method: 'POST', credentials: 'same-origin', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
|
|
61
|
+
const data = await response.json().catch(() => ({}));
|
|
62
|
+
return { status: response.status, data };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let isOpen = false;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Show the ask. Resolves `{ renamed: true, result }` once the server renamed the step, else `{ renamed: false }`.
|
|
69
|
+
* `ask` is the server's `ambiguous-step-name` ask; `ask.target` says which workflow file it is about.
|
|
70
|
+
*/
|
|
71
|
+
function open(ask) {
|
|
72
|
+
const root = document.getElementById('step-rename-modal');
|
|
73
|
+
if (!root || isOpen || !ask || !Array.isArray(ask.repairs) || !ask.repairs.length) return Promise.resolve({ renamed: false });
|
|
74
|
+
isOpen = true;
|
|
75
|
+
const $ = (id) => document.getElementById(id);
|
|
76
|
+
const ok = $('sr-ok'); const hint = $('sr-hint'); const err = $('sr-error'); const input = $('sr-name');
|
|
77
|
+
const msg = $('sr-name-msg'); const pv = $('sr-preview'); const warning = $('sr-warning');
|
|
78
|
+
const returnTo = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
79
|
+
const route = routeOf(ask.target);
|
|
80
|
+
const stepOf = (path) => (ask.steps || []).find((s) => s.path === path);
|
|
81
|
+
let choice = Math.max(0, ask.repairs.findIndex((r) => r.isDefault));
|
|
82
|
+
let dirty = false;
|
|
83
|
+
let preview = null;
|
|
84
|
+
let seq = 0;
|
|
85
|
+
let busy = false;
|
|
86
|
+
let timer = null;
|
|
87
|
+
|
|
88
|
+
return new Promise((resolve) => {
|
|
89
|
+
const setReady = (ready, why) => {
|
|
90
|
+
ok.setAttribute('aria-disabled', ready && !busy ? 'false' : 'true');
|
|
91
|
+
hint.textContent = ready ? '' : why || '';
|
|
92
|
+
hint.classList.remove('nudge');
|
|
93
|
+
};
|
|
94
|
+
const showError = (text) => { err.textContent = text || ''; err.hidden = !text; };
|
|
95
|
+
const setEditable = (on) => {
|
|
96
|
+
input.readOnly = !on;
|
|
97
|
+
root.querySelectorAll('input[name="sr-step"]').forEach((r) => { r.disabled = !on; });
|
|
98
|
+
};
|
|
99
|
+
const nameError = (text, suggestedId) => {
|
|
100
|
+
input.setAttribute('aria-invalid', text ? 'true' : 'false');
|
|
101
|
+
msg.classList.toggle('is-error', !!text);
|
|
102
|
+
// With a suggestion on offer the button asks the question, so the sentence drops its own "Use X instead?".
|
|
103
|
+
const shown = suggestedId ? String(text).replace(/\s*Use “[^”]*” instead\?\s*$/, '') : text;
|
|
104
|
+
msg.innerHTML = text ? esc(shown) + (suggestedId && suggestedId !== input.value.trim()
|
|
105
|
+
? ` <button type="button" class="sr-use" data-sr-use="${esc(suggestedId)}" data-command-id="shell.step-rename-use-suggested">Use “${esc(suggestedId)}”</button>` : '') : '';
|
|
106
|
+
};
|
|
107
|
+
const paintSteps = () => {
|
|
108
|
+
const many = (ask.steps || []).length > 2;
|
|
109
|
+
$('sr-sub').textContent = `${many ? `${ask.steps.length} steps are all` : 'Both are'} called “${ask.scopedId}”, so the workflow can’t tell which one is meant. Rename one of them, then compile again.`;
|
|
110
|
+
$('sr-steps').innerHTML = ask.repairs.map((r, i) => {
|
|
111
|
+
const step = stepOf(r.nodePath);
|
|
112
|
+
return `<label class="sr-step"><input type="radio" name="sr-step" value="${i}"${i === choice ? ' checked' : ''}`
|
|
113
|
+
+ ` data-command-id="shell.step-rename-choose#${esc(r.nodePath)}" data-command-instance-label="the step “${esc(step ? step.id : r.nodePath)}”"`
|
|
114
|
+
+ ` aria-label="${esc(stepText(step, r.nodePath))}${r.isDefault ? ' (suggested)' : ''}">`
|
|
115
|
+
+ `<span>${stepLabel(step)}${r.isDefault ? '<span class="sr-tag">Suggested</span>' : ''}</span></label>`;
|
|
116
|
+
}).join('');
|
|
117
|
+
};
|
|
118
|
+
const paintPreview = () => {
|
|
119
|
+
if (!preview) return;
|
|
120
|
+
const view = previewView(preview, stepOf(ask.repairs[choice].nodePath));
|
|
121
|
+
pv.removeAttribute('aria-busy');
|
|
122
|
+
pv.innerHTML = view.body;
|
|
123
|
+
warning.hidden = !view.warning;
|
|
124
|
+
warning.innerHTML = view.warning;
|
|
125
|
+
ok.textContent = view.primary;
|
|
126
|
+
setReady(true);
|
|
127
|
+
};
|
|
128
|
+
const checking = () => {
|
|
129
|
+
preview = null;
|
|
130
|
+
pv.setAttribute('aria-busy', 'true');
|
|
131
|
+
pv.textContent = 'Checking what will change…';
|
|
132
|
+
warning.hidden = true;
|
|
133
|
+
ok.textContent = 'Rename step';
|
|
134
|
+
setReady(false, 'Checking what will change…');
|
|
135
|
+
};
|
|
136
|
+
async function refresh() {
|
|
137
|
+
clearTimeout(timer);
|
|
138
|
+
const mine = ++seq;
|
|
139
|
+
const repair = ask.repairs[choice];
|
|
140
|
+
const newId = input.value.trim();
|
|
141
|
+
showError('');
|
|
142
|
+
if (!newId) { nameError('Type a name for the step.'); preview = null; pv.textContent = ''; setReady(false, 'Type a name first.'); return; }
|
|
143
|
+
// Only an error is cleared here: a "Suggested name" note stays, so the polite announcement is not wiped mid-read.
|
|
144
|
+
if (msg.classList.contains('is-error')) nameError('');
|
|
145
|
+
checking();
|
|
146
|
+
let answer;
|
|
147
|
+
try { answer = await post(`${route}/rename-preview`, { nodePath: repair.nodePath, newId }); }
|
|
148
|
+
catch { answer = null; }
|
|
149
|
+
if (mine !== seq || !isOpen) return; // a newer check (or a closed dialog) owns the screen
|
|
150
|
+
if (answer && answer.status === 200 && answer.data.ok && answer.data.preview) {
|
|
151
|
+
preview = answer.data.preview;
|
|
152
|
+
paintPreview();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
pv.removeAttribute('aria-busy');
|
|
156
|
+
const data = answer ? answer.data : {};
|
|
157
|
+
if (answer && /^step-name-|^step-not-found$/.test(String(data.code))) {
|
|
158
|
+
nameError(data.error || 'That name can’t be used here. Try another.', data.suggestedId);
|
|
159
|
+
pv.textContent = '';
|
|
160
|
+
setReady(false, 'Choose a free name first.');
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
// "Check again" only where trying again can help (a failed check, a lost connection); an older AWARE or a file FloLess
|
|
164
|
+
// will not edit is answered with its sentence alone.
|
|
165
|
+
const retryable = !answer || !data.code || ['step-rename-failed', 'step-names-unchecked', 'step-rename-preview-stale'].includes(String(data.code));
|
|
166
|
+
pv.innerHTML = esc(data.error || 'FloLess couldn’t check the change just now.')
|
|
167
|
+
+ (retryable ? ' <button type="button" class="sr-retry" data-sr-retry data-command-id="shell.step-rename-retry">Check again</button>' : '');
|
|
168
|
+
setReady(false, retryable ? 'FloLess needs to check the change first.' : 'This rename can’t go ahead here.');
|
|
169
|
+
}
|
|
170
|
+
const schedule = () => { clearTimeout(timer); checking(); timer = setTimeout(() => { void refresh(); }, PREVIEW_DELAY_MS); };
|
|
171
|
+
|
|
172
|
+
const close = (result) => {
|
|
173
|
+
clearTimeout(timer);
|
|
174
|
+
seq += 1;
|
|
175
|
+
document.removeEventListener('keydown', onKey, true);
|
|
176
|
+
root.removeEventListener('click', onClick);
|
|
177
|
+
root.removeEventListener('change', onChange);
|
|
178
|
+
input.removeEventListener('input', onInput);
|
|
179
|
+
root.classList.remove('show');
|
|
180
|
+
isOpen = false;
|
|
181
|
+
if (returnTo && returnTo.isConnected) returnTo.focus();
|
|
182
|
+
resolve(result);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
async function confirm() {
|
|
186
|
+
if (busy) return;
|
|
187
|
+
if (ok.getAttribute('aria-disabled') === 'true' || !preview) { hint.classList.add('nudge'); return; }
|
|
188
|
+
busy = true;
|
|
189
|
+
seq += 1; // an in-flight check can no longer repaint the dialog under "Renaming…"
|
|
190
|
+
clearTimeout(timer);
|
|
191
|
+
setEditable(false);
|
|
192
|
+
const label = ok.textContent;
|
|
193
|
+
ok.textContent = 'Renaming…';
|
|
194
|
+
setReady(false, 'Renaming…');
|
|
195
|
+
showError('');
|
|
196
|
+
const repair = ask.repairs[choice];
|
|
197
|
+
let answer;
|
|
198
|
+
try {
|
|
199
|
+
answer = await post(`${route}/rename`, {
|
|
200
|
+
nodePath: repair.nodePath, newId: input.value.trim(),
|
|
201
|
+
expectedSourceHash: preview.sourceHash, previewToken: preview.previewToken,
|
|
202
|
+
// The button the person pressed said "anyway" / "Rewrite": that is the acceptance, and only of what is shown.
|
|
203
|
+
acceptUncertain: Array.isArray(preview.uncertain) && preview.uncertain.length > 0,
|
|
204
|
+
rewriteFile: preview.needsRewrite === true,
|
|
205
|
+
});
|
|
206
|
+
} catch { answer = null; }
|
|
207
|
+
busy = false;
|
|
208
|
+
setEditable(true);
|
|
209
|
+
if (answer && answer.status === 200 && answer.data.ok) { close({ renamed: true, result: answer.data }); return; }
|
|
210
|
+
const data = answer ? answer.data : {};
|
|
211
|
+
if (answer && data.preview && /^step-rename-/.test(String(data.code))) {
|
|
212
|
+
if (data.preview.to !== input.value.trim() || data.preview.nodePath !== repair.nodePath) { void refresh(); showError(data.error || ''); return; }
|
|
213
|
+
preview = data.preview;
|
|
214
|
+
paintPreview();
|
|
215
|
+
showError(data.error || 'The workflow changed since the preview. Look at it again, then confirm.');
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
ok.textContent = label;
|
|
219
|
+
if (answer && /^step-name-|^step-not-found$/.test(String(data.code))) {
|
|
220
|
+
nameError(data.error, data.suggestedId);
|
|
221
|
+
setReady(false, 'Choose a free name first.');
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
setReady(!!preview);
|
|
225
|
+
showError(data.error || 'FloLess couldn’t rename the step, so the workflow is unchanged. Check that FloLess is running and try again.');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const focusables = () => [...root.querySelectorAll('button, input, [tabindex="0"]')]
|
|
229
|
+
.filter((el) => !el.hidden && !el.closest('[hidden]') && !(el.type === 'radio' && !el.checked));
|
|
230
|
+
function onKey(event) {
|
|
231
|
+
if (!root.classList.contains('show')) return;
|
|
232
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); if (!busy) close({ renamed: false }); return; }
|
|
233
|
+
if (event.key === 'Enter' && event.target === input) { event.preventDefault(); clearTimeout(timer); if (preview) void confirm(); else void refresh(); return; }
|
|
234
|
+
if (event.key !== 'Tab') return;
|
|
235
|
+
const list = focusables();
|
|
236
|
+
if (!list.length) return;
|
|
237
|
+
const first = list[0]; const last = list[list.length - 1];
|
|
238
|
+
if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
|
|
239
|
+
else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
|
|
240
|
+
else if (!root.contains(document.activeElement)) { event.preventDefault(); first.focus(); }
|
|
241
|
+
}
|
|
242
|
+
function onChange(event) {
|
|
243
|
+
const radio = event.target;
|
|
244
|
+
if (!(radio instanceof HTMLInputElement) || radio.name !== 'sr-step') return;
|
|
245
|
+
choice = Number(radio.value) || 0;
|
|
246
|
+
if (!dirty) {
|
|
247
|
+
input.value = ask.repairs[choice].newId;
|
|
248
|
+
msg.classList.remove('is-error');
|
|
249
|
+
msg.textContent = `Suggested name: “${input.value}”.`;
|
|
250
|
+
}
|
|
251
|
+
void refresh();
|
|
252
|
+
}
|
|
253
|
+
function onInput() { if (busy) return; dirty = true; nameError(''); schedule(); }
|
|
254
|
+
function onClick(event) {
|
|
255
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
256
|
+
if (!target) return;
|
|
257
|
+
const use = target.closest('[data-sr-use]');
|
|
258
|
+
if (use) { input.value = use.getAttribute('data-sr-use'); dirty = true; void refresh(); input.focus(); return; }
|
|
259
|
+
if (target.closest('[data-sr-retry]')) { void refresh(); return; }
|
|
260
|
+
const button = target.closest('button');
|
|
261
|
+
if (!button) return;
|
|
262
|
+
if (button.id === 'sr-ok') void confirm();
|
|
263
|
+
else if (button.id === 'sr-cancel' && !busy) close({ renamed: false });
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
input.value = ask.repairs[choice].newId;
|
|
267
|
+
input.setAttribute('aria-invalid', 'false');
|
|
268
|
+
msg.textContent = '';
|
|
269
|
+
showError('');
|
|
270
|
+
$('sr-note').textContent = NOTE;
|
|
271
|
+
paintSteps();
|
|
272
|
+
document.addEventListener('keydown', onKey, true);
|
|
273
|
+
root.addEventListener('click', onClick);
|
|
274
|
+
root.addEventListener('change', onChange);
|
|
275
|
+
input.addEventListener('input', onInput);
|
|
276
|
+
root.classList.add('show');
|
|
277
|
+
const checked = root.querySelector('input[name="sr-step"]:checked');
|
|
278
|
+
if (checked) checked.focus(); else $('sr-title').focus();
|
|
279
|
+
void refresh();
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** True when an api() error is the ask (the server attached one). */
|
|
284
|
+
const askOf = (error) => (error && error.body && error.body.code === 'ambiguous-step-name' && error.body.ask ? error.body.ask : null);
|
|
285
|
+
|
|
286
|
+
globalThis.flolessStepRename = { open, askOf, previewView, stepLabel, NOTE };
|
|
287
|
+
})();
|
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
21
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
22
|
-
const CONFIRM_VERBS = { 'workflows.run': 'Run it', 'routines.run': 'Run it', 'projects.archive': 'Archive it', 'projects.unarchive': 'Bring it back'
|
|
22
|
+
const CONFIRM_VERBS = { 'workflows.run': 'Run it', 'routines.run': 'Run it', 'projects.archive': 'Archive it', 'projects.unarchive': 'Bring it back',
|
|
23
|
+
// #2363: what each step does on the window's side, so none of them says a bare "Do it".
|
|
24
|
+
'models.start-import': 'Choose the file', 'tekla.start-upload': 'Choose the source', 'models.retry-import': 'Try it again',
|
|
25
|
+
'models.cancel-import': 'Cancel it', 'tekla.cancel-import': 'Cancel it', 'parser-setup.start-fresh': 'Open the review',
|
|
26
|
+
'models.retry-revit-setup': 'Try setup again', 'models.retry-tekla-setup': 'Try setup again',
|
|
27
|
+
'workspace-root.review-retirement': 'Open the review', 'workspace-root.confirm-retirement': 'Record it' };
|
|
23
28
|
const EYEBROWS = { write: 'Needs your OK', destructive: 'Needs your OK', 'human-only': 'Your decision' };
|
|
24
29
|
const FINAL = new Set(['done', 'failed', 'cancelled', 'declined', 'expired', 'superseded', 'unknown']);
|
|
25
30
|
|
|
@@ -36,6 +41,7 @@
|
|
|
36
41
|
let linkedId = null;
|
|
37
42
|
|
|
38
43
|
const api = async (method, path) => {
|
|
44
|
+
await globalThis.flolessStartupAdmission?.admit(path, { method });
|
|
39
45
|
const res = await fetch(path, { method, credentials: 'same-origin', headers: method === 'POST' ? { 'content-type': 'application/json' } : {}, body: method === 'POST' ? '{}' : undefined });
|
|
40
46
|
let body = null;
|
|
41
47
|
try { body = await res.json(); } catch { body = null; }
|
|
@@ -143,7 +149,8 @@
|
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
const dialogOpen = () => Boolean(backdrop?.classList.contains('show'));
|
|
146
|
-
|
|
152
|
+
// #2420: one asked before FloLess restarted is answerable too, until its own time runs out (answering shows it again).
|
|
153
|
+
const answerable = (p) => p.state === 'proposed' && Date.parse(p.expiresAt) > Date.now();
|
|
147
154
|
// A step only a person does is never "done" in FloLess's records: once its screen was opened here, it has done its
|
|
148
155
|
// job in this window and stops asking (it still expires on the server, and the terminal was told so).
|
|
149
156
|
const waiting = () => [...shown.values()].filter((e) => !e.gone && !e.opened && answerable(e.p)).map((e) => e.p);
|
|
@@ -199,7 +206,11 @@
|
|
|
199
206
|
status.setAttribute('role', 'status');
|
|
200
207
|
|
|
201
208
|
const stale = entry.gone ? ['FloLess can’t find that request', 'It may be from before FloLess last restarted. Nothing ran. Ask your terminal to try again.']
|
|
202
|
-
: p.state === 'expired'
|
|
209
|
+
: p.state === 'expired' && p.restarted && p.supersededBy
|
|
210
|
+
? ['Shown again', 'FloLess restarted after your terminal asked, so the request is shown again as it works now. Nothing ran.']
|
|
211
|
+
: p.state === 'expired' && p.result?.code === 'asked-again'
|
|
212
|
+
? ['Your terminal asked for this again', 'FloLess restarted after it first asked, so the newer request is shown instead. Nothing ran.']
|
|
213
|
+
: p.state === 'expired' || (p.state === 'proposed' && Date.parse(p.expiresAt) <= Date.now())
|
|
203
214
|
? ['This request expired', 'It waited too long, so FloLess dropped it. Nothing ran. Ask your terminal again if you still want it.']
|
|
204
215
|
: p.state === 'superseded' ? ['Your terminal’s request was replaced', `${p.changedNote || 'Something changed after it was asked.'} This one can’t be run. Nothing ran.`]
|
|
205
216
|
: p.state === 'declined' ? [`Not run: ${summary}`, 'You chose Not now. Nothing happened. Ask your terminal again if you change your mind.']
|
|
@@ -241,6 +252,14 @@
|
|
|
241
252
|
head.append(b);
|
|
242
253
|
}
|
|
243
254
|
node.append(head);
|
|
255
|
+
// A step only a person does has no confirm to show again: its screen opens as it is now either way.
|
|
256
|
+
const askedBeforeRestart = p.state === 'proposed' && p.restarted && risk !== 'human-only';
|
|
257
|
+
if (askedBeforeRestart) {
|
|
258
|
+
const before = document.createElement('p');
|
|
259
|
+
before.className = 'ai-chat-filter-note ai-chat-action-changed terminal-request-restarted';
|
|
260
|
+
before.textContent = 'Your terminal asked for this before FloLess restarted. FloLess may have changed since, so it will show the request again as it works now. Nothing runs until you confirm that one.';
|
|
261
|
+
node.append(before);
|
|
262
|
+
}
|
|
244
263
|
if (p.changedNote && p.state === 'proposed') {
|
|
245
264
|
const changed = document.createElement('p');
|
|
246
265
|
changed.className = 'ai-chat-filter-note ai-chat-action-changed';
|
|
@@ -254,7 +273,8 @@
|
|
|
254
273
|
|
|
255
274
|
if (p.state === 'done') {
|
|
256
275
|
node.classList.add('is-done');
|
|
257
|
-
|
|
276
|
+
// A step this window was handed but could not take is said here, never left reading as done.
|
|
277
|
+
status.textContent = entry.error || (p.next ? 'Done. Its result is ready to view.' : String(p.doneNote || 'Done.'));
|
|
258
278
|
if (p.next) {
|
|
259
279
|
const actions = document.createElement('div');
|
|
260
280
|
actions.className = 'ai-chat-filter-actions';
|
|
@@ -318,8 +338,11 @@
|
|
|
318
338
|
node.append(actions, note, status);
|
|
319
339
|
return node;
|
|
320
340
|
}
|
|
321
|
-
const
|
|
322
|
-
confirm
|
|
341
|
+
const verbLabel = askedBeforeRestart ? 'Check it again' : (CONFIRM_VERBS[p.actionId] || 'Do it');
|
|
342
|
+
const confirm = button(entry.busy === 'confirm' ? (askedBeforeRestart ? 'Checking…' : 'Starting…') : verbLabel,
|
|
343
|
+
askedBeforeRestart ? 'shell.terminal-request-check-again' : 'shell.terminal-request-confirm', p.id, summary, 'ai-chat-filter-apply');
|
|
344
|
+
confirm.dataset.tip = askedBeforeRestart ? 'Shows this request again as it works now. Nothing runs yet.'
|
|
345
|
+
: risk === 'destructive' ? 'Runs it now, for real. FloLess checks first that nothing changed since your terminal asked.'
|
|
323
346
|
: 'Makes this change now. FloLess checks first that nothing changed since your terminal asked.';
|
|
324
347
|
confirm.disabled = Boolean(entry.busy);
|
|
325
348
|
if (entry.busy === 'confirm') confirm.setAttribute('aria-busy', 'true');
|
|
@@ -327,7 +350,7 @@
|
|
|
327
350
|
actions.append(later, confirm);
|
|
328
351
|
const pending = document.createElement('p');
|
|
329
352
|
pending.className = 'ai-chat-filter-note';
|
|
330
|
-
pending.textContent = entry.busy === 'confirm' ? 'Starting it now…' : p.expected ? 'Nothing has run yet. It uses this as it is now. If it changes before you confirm, you will be asked again.'
|
|
353
|
+
pending.textContent = entry.busy === 'confirm' ? (askedBeforeRestart ? 'Checking it now…' : 'Starting it now…') : askedBeforeRestart ? 'Nothing has run yet.' : p.expected ? 'Nothing has run yet. It uses this as it is now. If it changes before you confirm, you will be asked again.'
|
|
331
354
|
: 'Nothing has run yet.';
|
|
332
355
|
status.textContent = entry.error || '';
|
|
333
356
|
node.append(actions, pending, status);
|
|
@@ -349,13 +372,15 @@
|
|
|
349
372
|
await window.flolessWorkspaces.openChatOwner({ kind: 'project', projectId: screen.projectId }); opened = true;
|
|
350
373
|
} else if (['workspaces', 'workflows'].includes(screen?.view) && typeof window.flolessWorkspaces?.setMode === 'function') {
|
|
351
374
|
await window.flolessWorkspaces.setMode(screen.view); opened = true;
|
|
375
|
+
} else if (screen?.view === 'tool-update-policy' && typeof window.openToolUpdatePolicy === 'function') {
|
|
376
|
+
window.openToolUpdatePolicy(); opened = true;
|
|
352
377
|
}
|
|
353
378
|
} catch (error) {
|
|
354
379
|
// The bridge throws sentences written for the person (e.g. "This window no longer holds that run's report…").
|
|
355
380
|
opened = false;
|
|
356
381
|
why = typeof error?.message === 'string' ? error.message : '';
|
|
357
382
|
}
|
|
358
|
-
if (!opened) { status.textContent = why || 'FloLess couldn’t open that from here. Open it from Workflows or Workspaces instead.'; return false; }
|
|
383
|
+
if (!opened) { status.textContent = why || 'FloLess couldn’t open that from here. Open it from Workflows or Workspaces instead.'; announce(status.textContent); return false; }
|
|
359
384
|
if (close) closeDialog();
|
|
360
385
|
return true;
|
|
361
386
|
}
|
|
@@ -366,17 +391,34 @@
|
|
|
366
391
|
entry.error = '';
|
|
367
392
|
paint();
|
|
368
393
|
const title = String(entry.p.title || 'the request');
|
|
394
|
+
// A fresh card offered in its place is where the person answers next, so focus goes to its button.
|
|
395
|
+
let freshId = '';
|
|
369
396
|
try {
|
|
370
397
|
const { ok, body, status } = await api('POST', `/api/actions/proposals/${encodeURIComponent(entry.p.id)}/${verb}`);
|
|
371
398
|
if (ok && body.proposal) {
|
|
372
399
|
entry.p = body.proposal;
|
|
373
400
|
announce(verb === 'confirm' ? `${title}: started.` : verb === 'decline' ? 'Nothing ran.' : `Asked ${title} to stop.`);
|
|
401
|
+
// A step only this window may take (a model source, the setup review, Stop FloLess) is taken here once confirmed,
|
|
402
|
+
// exactly as a chat card does: the request stays running until this window says how the step went.
|
|
403
|
+
if (verb === 'confirm' && entry.p.browserStep) {
|
|
404
|
+
entry.error = typeof window.flolessRunBrowserStep === 'function'
|
|
405
|
+
? await window.flolessRunBrowserStep(entry.p.browserStep)
|
|
406
|
+
: 'FloLess could not take this step from here. Open the project or screen it names and do it there.';
|
|
407
|
+
// A Stop FloLess that went ahead is settled by the server when it accepts the stop; this window can no longer report.
|
|
408
|
+
const stopped = entry.p.browserStep.flow === 'stop-app' && !entry.error;
|
|
409
|
+
const settled = !stopped && typeof window.flolessReportBrowserStep === 'function' ? await window.flolessReportBrowserStep(entry.p.id, entry.error) : null;
|
|
410
|
+
if (settled) entry.p = settled;
|
|
411
|
+
// The step opened something in this window (a project, a review). This dialog sits over it, so step aside.
|
|
412
|
+
if (!entry.error) closeDialog();
|
|
413
|
+
}
|
|
374
414
|
} else if (body.fresh) {
|
|
375
|
-
// It changed or expired: the old card says so, and the fresh one is
|
|
415
|
+
// It changed or expired: the old card says so, and the fresh one is listed first to answer instead.
|
|
416
|
+
const restarted = Boolean(entry.p.restarted);
|
|
376
417
|
if (body.proposal) entry.p = body.proposal;
|
|
377
418
|
shown.set(body.fresh.id, { p: body.fresh, busy: '', error: '' });
|
|
378
419
|
focusId = body.fresh.id;
|
|
379
|
-
|
|
420
|
+
freshId = body.fresh.id;
|
|
421
|
+
announce(restarted ? 'Request shown again as it works now. Nothing has run.' : body.error || 'It changed after your terminal asked. The current request is shown first.');
|
|
380
422
|
} else {
|
|
381
423
|
if (body.proposal) entry.p = body.proposal;
|
|
382
424
|
entry.error = status === 404 ? 'FloLess no longer has that request. Ask your terminal to try again.'
|
|
@@ -387,6 +429,13 @@
|
|
|
387
429
|
} finally {
|
|
388
430
|
entry.busy = '';
|
|
389
431
|
paint();
|
|
432
|
+
if (freshId && dialogOpen()) {
|
|
433
|
+
const fresh = list.querySelector(`[data-proposal-id="${CSS.escape(freshId)}"]`);
|
|
434
|
+
(fresh?.querySelector('.ai-chat-filter-apply') || fresh?.querySelector('.terminal-request-title'))?.focus({ preventScroll: true });
|
|
435
|
+
}
|
|
436
|
+
// #2318: the card's status line is created afresh on every repaint, and a live region that is inserted (not
|
|
437
|
+
// changed) is often not read out. The dialog's own live region is what says it.
|
|
438
|
+
if (entry.error) announce(entry.error);
|
|
390
439
|
// Esc while it was starting: the dialog is gone, so the notice carries "running" instead.
|
|
391
440
|
if (!dialogOpen()) showNotice();
|
|
392
441
|
// A last "Not now" leaves nothing to decide: close and say so.
|
package/dist/web/tool-updates.js
CHANGED
|
@@ -273,6 +273,7 @@
|
|
|
273
273
|
function plural(n, one, many) { return n + ' ' + (n === 1 ? one : many); }
|
|
274
274
|
|
|
275
275
|
async function call(path, method, payload, signal) {
|
|
276
|
+
await globalThis.flolessStartupAdmission?.admit(path, { method, signal });
|
|
276
277
|
var res = await fetch(path, { method: method || 'GET', headers: { 'content-type': 'application/json' }, body: payload, signal: signal });
|
|
277
278
|
var body = await res.json().catch(function (error) {
|
|
278
279
|
if (error && error.name === 'AbortError') throw error; // the page gave this request up: not "an unreadable answer"
|
|
@@ -193,5 +193,44 @@
|
|
|
193
193
|
})
|
|
194
194
|
.observe(modal, { attributes: true, attributeFilter: ['class'] });
|
|
195
195
|
window.addEventListener('floless:workspace-root-state', () => { if (shown && !busy) void refresh(); });
|
|
196
|
+
// #2363: a confirmed chat card opens this review for one saved directory and presses the same buttons the person would,
|
|
197
|
+
// so the preview and the recording run here, with this window's editor session. `record` also presses the confirm
|
|
198
|
+
// button, but only once the review needs nothing more from the person (a directory in use needs a destination first).
|
|
199
|
+
// Resolves '' on success, or one plain sentence: why it could not, or what the person does next.
|
|
200
|
+
async function until(test, ms) { const end = Date.now() + ms; while (Date.now() < end) { if (test()) return true; await new Promise((r) => setTimeout(r, 50)); } return test(); }
|
|
201
|
+
async function reviewRetirementForCard({ rootId, action, record }) {
|
|
202
|
+
if (busy) return 'A directory choice is already being recorded. Let it finish, then ask again.';
|
|
203
|
+
if (typeof window.flolessWorkspaceRoot?.open !== 'function') return 'FloLess could not open the saved directories from here. Use the Workspace directory button on the Workspaces screen.';
|
|
204
|
+
// A review the person already has open is theirs: another directory's is never thrown away for a card.
|
|
205
|
+
if (modal.classList.contains('show') && step) {
|
|
206
|
+
if (step.row.rootId !== rootId) return 'A review of another saved directory is open. Finish or close it, then ask again.';
|
|
207
|
+
back();
|
|
208
|
+
}
|
|
209
|
+
if (!modal.classList.contains('show')) { data = null; step = null; message = ''; problem = ''; }
|
|
210
|
+
await window.flolessWorkspaceRoot.open();
|
|
211
|
+
// Opening a dialog that is already open does not reload it, so read the list here whichever way it was opened.
|
|
212
|
+
if (!data) await refresh();
|
|
213
|
+
if (!await until(() => data || problem, 8000) || !data) return problem || 'FloLess could not read its saved directories. Close the dialog and open it again.';
|
|
214
|
+
const row = data.roots.find((r) => r.rootId === rootId);
|
|
215
|
+
if (!row) return 'That saved directory is no longer in the list, so nothing was done. Check the list in the dialog.';
|
|
216
|
+
const control = [...content.querySelectorAll('[data-registration-action]')].find((c) => c.dataset.registrationAction === action && c.dataset.rootId === rootId);
|
|
217
|
+
if (!control) {
|
|
218
|
+
return action === 'restore'
|
|
219
|
+
? 'That directory can be restored only once it has been stopped and its original folder is back. The dialog lists each one’s state.'
|
|
220
|
+
: 'FloLess stops using a saved directory only when it cannot reach it right now, and not one already stopped. The dialog lists each one’s state.';
|
|
221
|
+
}
|
|
222
|
+
control.click();
|
|
223
|
+
if (!record) return '';
|
|
224
|
+
// The review this card started: if the person moves to another one while FloLess waits, theirs is left for them to decide.
|
|
225
|
+
const mine = step;
|
|
226
|
+
const needsDestination = () => step.action === 'retire' && step.row.rootId === data.activeRootId;
|
|
227
|
+
if (!await until(() => step && !step.checking && (step.previewId || step.failed || needsDestination()), 15000)) return 'FloLess is still checking this directory. The review is open; confirm it there when it is ready.';
|
|
228
|
+
if (!step?.previewId) return problem || 'The review is open. Choose where to switch, then press the confirm button there.';
|
|
229
|
+
if (step !== mine || mine.row.rootId !== rootId || mine.action !== action) return 'The review on screen changed while FloLess waited, so it recorded nothing. The review that is open is yours to confirm.';
|
|
230
|
+
content.querySelector('[data-registration-action="confirm"]')?.click();
|
|
231
|
+
await until(() => !busy && (!step || problem), 20000);
|
|
232
|
+
return problem || (step ? 'The review is open. Confirm it there to record it.' : '');
|
|
233
|
+
}
|
|
234
|
+
window.flolessWorkspaceRootReview = reviewRetirementForCard;
|
|
196
235
|
render();
|
|
197
236
|
})();
|