@floless/app 0.156.0 → 0.158.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 +28 -5
- package/dist/floless-server.cjs +110947 -67461
- 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 +82 -17
- package/dist/skills/floless-app-knowledge/SKILL.md +34 -2
- package/dist/skills/floless-app-knowledge/references/schema.md +4 -1
- 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 +35 -1
- package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +4 -2
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +51 -1
- 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 +620 -17
- package/dist/web/app.js +110 -11
- package/dist/web/aware-update-client.js +1 -0
- package/dist/web/aware.js +921 -220
- package/dist/web/chat-landing-scene.js +372 -0
- package/dist/web/chat.css +263 -1
- package/dist/web/chat.js +2660 -86
- package/dist/web/commands-drawing-check.js +17 -0
- package/dist/web/commands-shell.js +1059 -8
- 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 +143 -8
- package/dist/web/instructor.js +4 -4
- package/dist/web/kb-categories.js +351 -0
- package/dist/web/kb-graph-worker.js +73 -0
- package/dist/web/model-view-query.js +12 -2
- package/dist/web/pages.js +978 -39
- 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/run-page-view.js +353 -0
- package/dist/web/startup-admission.js +132 -0
- package/dist/web/steel-3d-core.js +9 -0
- package/dist/web/steel-editor.html +681 -22
- package/dist/web/steel-model-v2-commands.js +63 -5
- package/dist/web/step-rename.js +287 -0
- package/dist/web/tab-signal.js +323 -0
- package/dist/web/terminal-requests.js +103 -13
- package/dist/web/tool-updates.js +1 -0
- package/dist/web/workspace-root-management.js +39 -0
- package/dist/web/workspaces.js +2883 -146
- package/launch-starting-page.mjs +181 -0
- package/launch.mjs +97 -12
- package/package.json +5 -1
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run viewer's view of a report that carries files (`report_folder`, #2262 slice 3c; follow-up #2476).
|
|
3
|
+
*
|
|
4
|
+
* Such a report refers to its pictures and files as `assets/…`, which resolve only inside its saved Page version. While
|
|
5
|
+
* that version is being saved the viewer shows the report's inert copy (the server made it; this file never touches a
|
|
6
|
+
* report's HTML) with a plain note, then switches to the version's own isolated frame once that frame says it is ready.
|
|
7
|
+
* What it says at every moment comes from the SERVER's answer about this exact run — never a guess:
|
|
8
|
+
*
|
|
9
|
+
* pending inert copy, "Saving this report…" (after 90 s: "Still saving…"); polled every 10 s, never an endless spinner
|
|
10
|
+
* saved with files: the Page version's frame, once it posts `floless-page-ready` for THIS navigation;
|
|
11
|
+
* without files: inert copy and the stored reason
|
|
12
|
+
* failed inert copy and the server's words
|
|
13
|
+
* none provisional for 30 s after the report arrived (a sender that could not queue first), then terminal
|
|
14
|
+
* frame did not become ready within 20 s, or reported itself unavailable: inert copy and "could not be shown here"
|
|
15
|
+
*
|
|
16
|
+
* Ordering: every answer and every piece of news carries `rev` and the server process's `epoch`. A state applies only if
|
|
17
|
+
* its `rev` is higher than the one held in the same epoch; a new epoch (FloLess restarted) resets what is held and
|
|
18
|
+
* reconciles from a new lookup. Only the newest lookup's answer may apply, and a new epoch invalidates every older one.
|
|
19
|
+
* One paint GENERATION fences every asynchronous step: a later paint, close, or workspace switch makes them do nothing.
|
|
20
|
+
*
|
|
21
|
+
* Loaded as a classic script before aware.js; tested by server/run-page-view-ui.test.ts with a fake clock.
|
|
22
|
+
*/
|
|
23
|
+
(function (root) {
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
var READY_WAIT_MS = 20000;
|
|
27
|
+
var POLL_MS = 10000;
|
|
28
|
+
var STILL_SAVING_MS = 90000;
|
|
29
|
+
var NONE_PROVISIONAL_MS = 30000;
|
|
30
|
+
var LOOKUP_TIMEOUT_MS = 15000;
|
|
31
|
+
var NEWS_KEPT = 64;
|
|
32
|
+
|
|
33
|
+
var NOTES = {
|
|
34
|
+
pending: 'Saving this report with its pictures and files to the workflow’s Page. It switches to that version when it is saved.',
|
|
35
|
+
still: 'Still saving this report to the workflow’s Page — large files take longer. It switches by itself when it is saved.',
|
|
36
|
+
opening: 'Opening the saved version of this report with its pictures and files…',
|
|
37
|
+
none: 'No saved version of this run was found on the workflow’s Page, so its pictures and files cannot be shown here. Run the workflow again to save it.',
|
|
38
|
+
frame: 'The saved version could not be shown here. Use Open in Pages to see it with its pictures and files.',
|
|
39
|
+
links: 'This report has links or content that open only in Pages. Use Open in Pages.',
|
|
40
|
+
};
|
|
41
|
+
var WITHHELD_NEXT = 'Run the workflow again to save them with it; if this keeps happening, ask AI Chat to check the workflow’s report folder.';
|
|
42
|
+
var FAILED_TAIL = 'Its pictures and files are not shown here.';
|
|
43
|
+
var PAGE_REQUESTS = ['floless-page-open', 'floless-page-link-unsupported', 'floless-page-blocked'];
|
|
44
|
+
|
|
45
|
+
function sentence(text) {
|
|
46
|
+
var t = String(text || '').trim();
|
|
47
|
+
return t && !/[.!?]$/.test(t) ? t + '.' : t;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function create(env) {
|
|
51
|
+
var win = env.win || root;
|
|
52
|
+
var now = env.now || function () { return Date.now(); };
|
|
53
|
+
var setTimer = env.setTimeout || function (fn, ms) { return root.setTimeout(fn, ms); };
|
|
54
|
+
var clearTimer = env.clearTimeout || function (id) { root.clearTimeout(id); };
|
|
55
|
+
var token = env.token || function () {
|
|
56
|
+
var bytes = new Uint8Array(16);
|
|
57
|
+
root.crypto.getRandomValues(bytes);
|
|
58
|
+
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-';
|
|
59
|
+
var out = '';
|
|
60
|
+
for (var i = 0; i < 16; i += 1) out += alphabet.charAt(bytes[i] % 64);
|
|
61
|
+
return out;
|
|
62
|
+
};
|
|
63
|
+
var inert = env.inert;
|
|
64
|
+
var page = env.page;
|
|
65
|
+
var noteEl = env.note;
|
|
66
|
+
|
|
67
|
+
var gen = 0;
|
|
68
|
+
var view = null;
|
|
69
|
+
var news = new Map(); // "app\nrun\nfire" → newest answer heard (any window state)
|
|
70
|
+
|
|
71
|
+
function nkey(app, runId, fire) { return app + '\n' + runId + '\n' + (fire || ''); }
|
|
72
|
+
|
|
73
|
+
function setNote(text) {
|
|
74
|
+
if (!noteEl) return;
|
|
75
|
+
noteEl.hidden = !text;
|
|
76
|
+
noteEl.textContent = text || '';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function clearTimers(v) {
|
|
80
|
+
if (!v) return;
|
|
81
|
+
[v.pollTimer, v.stillTimer, v.readyTimer].forEach(function (t) { if (t != null) clearTimer(t); });
|
|
82
|
+
v.pollTimer = v.stillTimer = v.readyTimer = null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function blankPageFrame() {
|
|
86
|
+
page.hidden = true;
|
|
87
|
+
if (page.hasAttribute('src')) {
|
|
88
|
+
// Navigate away first so a hidden document stops running, then drop the address.
|
|
89
|
+
page.setAttribute('src', 'about:blank');
|
|
90
|
+
page.removeAttribute('src');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Whatever was on screen is over: every pending step does nothing, the Page frame is empty, the inert copy is back. */
|
|
95
|
+
function invalidate() {
|
|
96
|
+
gen += 1;
|
|
97
|
+
clearTimers(view);
|
|
98
|
+
view = null;
|
|
99
|
+
blankPageFrame();
|
|
100
|
+
if (inert) inert.hidden = false;
|
|
101
|
+
setNote('');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function reset() {
|
|
105
|
+
invalidate();
|
|
106
|
+
news.clear();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Has this step been overtaken (another paint, a close, a workspace switch, another workflow)? */
|
|
110
|
+
function stale(v, g) { return v !== view || v.gen !== g || gen !== g || env.currentApp() !== v.app; }
|
|
111
|
+
|
|
112
|
+
// ── applying what the server says ──────────────────────────────────────────────────────────────────────
|
|
113
|
+
|
|
114
|
+
function normalise(raw) {
|
|
115
|
+
if (!raw || typeof raw !== 'object') return null;
|
|
116
|
+
if (['pending', 'saved', 'failed', 'none'].indexOf(raw.state) < 0) return null;
|
|
117
|
+
if (!Number.isInteger(raw.rev) || typeof raw.epoch !== 'string' || !raw.epoch) return null;
|
|
118
|
+
return {
|
|
119
|
+
state: raw.state, rev: raw.rev, epoch: raw.epoch,
|
|
120
|
+
version: Number.isInteger(raw.version) ? raw.version : null,
|
|
121
|
+
files: Number.isInteger(raw.files) ? raw.files : null,
|
|
122
|
+
filesWithheld: typeof raw.filesWithheld === 'string' ? raw.filesWithheld : '',
|
|
123
|
+
reason: typeof raw.reason === 'string' ? raw.reason : '',
|
|
124
|
+
frameUrl: typeof raw.frameUrl === 'string' && raw.frameUrl.charAt(0) === '/' && raw.frameUrl.indexOf('//') !== 0 ? raw.frameUrl : '',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** `workflow-page-captured` news → the same shape as a lookup answer (or null when it says nothing about a capture). */
|
|
129
|
+
function fromNews(m) {
|
|
130
|
+
if (!m || typeof m.app !== 'string' || typeof m.runId !== 'string' || !m.runId) return null;
|
|
131
|
+
if (typeof m.warning === 'string') return normalise({ state: 'failed', rev: m.rev, epoch: m.epoch, reason: m.warning });
|
|
132
|
+
if (Number.isInteger(m.version) && m.version >= 1) {
|
|
133
|
+
return normalise({ state: 'saved', rev: m.rev, epoch: m.epoch, version: m.version, files: m.files, filesWithheld: m.filesWithheld });
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function noteNews(key, a) {
|
|
139
|
+
var prev = news.get(key);
|
|
140
|
+
if (prev && prev.epoch === a.epoch && prev.rev >= a.rev) return;
|
|
141
|
+
news.delete(key);
|
|
142
|
+
news.set(key, a);
|
|
143
|
+
if (news.size > NEWS_KEPT) news.delete(news.keys().next().value);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The ordering gate. Returns true when `a` was applied. */
|
|
147
|
+
function apply(v, a, fromNewsItem) {
|
|
148
|
+
if (v.sticky) return false;
|
|
149
|
+
var h = v.held;
|
|
150
|
+
if (h.epoch !== null && a.epoch !== h.epoch) {
|
|
151
|
+
// FloLess restarted (or an answer from another process): what was held no longer orders anything, and every
|
|
152
|
+
// lookup still out was asked of the old process.
|
|
153
|
+
h.epoch = null; h.rev = 0; h.answer = null;
|
|
154
|
+
if (fromNewsItem) startLookup(v); // a new lookup supersedes (and so invalidates) every one still out
|
|
155
|
+
}
|
|
156
|
+
if (h.epoch === null) h.epoch = a.epoch;
|
|
157
|
+
var before = h.answer;
|
|
158
|
+
if (a.rev < h.rev) return false;
|
|
159
|
+
if (before && a.rev === h.rev && a.state !== before.state) return false;
|
|
160
|
+
var sameRev = !!before && a.rev === h.rev;
|
|
161
|
+
h.rev = a.rev;
|
|
162
|
+
// An answer of the same state at the same rev only ever adds (a lookup brings the frame address the news lacks).
|
|
163
|
+
h.answer = sameRev
|
|
164
|
+
? { state: a.state, rev: a.rev, epoch: a.epoch, version: a.version != null ? a.version : before.version,
|
|
165
|
+
files: a.files != null ? a.files : before.files, filesWithheld: a.filesWithheld || before.filesWithheld,
|
|
166
|
+
reason: a.reason || before.reason, frameUrl: a.frameUrl || before.frameUrl }
|
|
167
|
+
: a;
|
|
168
|
+
render(v);
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function pendingNote(v) { return now() - v.startedAt >= STILL_SAVING_MS ? NOTES.still : NOTES.pending; }
|
|
173
|
+
|
|
174
|
+
function render(v) {
|
|
175
|
+
if (v.sticky || v.shown) return;
|
|
176
|
+
var a = v.held.answer;
|
|
177
|
+
if (!a || a.state === 'pending') { setNote(pendingNote(v)); ensurePoll(v); return; }
|
|
178
|
+
if (a.state === 'none') {
|
|
179
|
+
if (now() - v.startedAt < NONE_PROVISIONAL_MS) { setNote(pendingNote(v)); ensurePoll(v); return; }
|
|
180
|
+
setNote(NOTES.none); stopPoll(v); return;
|
|
181
|
+
}
|
|
182
|
+
if (a.state === 'failed') {
|
|
183
|
+
setNote(a.reason ? sentence(a.reason) + ' ' + FAILED_TAIL : 'This report could not be saved to the workflow’s Page. ' + FAILED_TAIL);
|
|
184
|
+
stopPoll(v); return;
|
|
185
|
+
}
|
|
186
|
+
// saved
|
|
187
|
+
if (a.files > 0) {
|
|
188
|
+
// It IS saved (never "saving"). One 20 s deadline covers finding its frame's address AND the frame saying it is
|
|
189
|
+
// ready, however many answers or redraws come in between; past it the viewer says so and points to Pages.
|
|
190
|
+
setNote(NOTES.opening);
|
|
191
|
+
startOpeningDeadline(v);
|
|
192
|
+
if (a.frameUrl) { stopPoll(v); showVersion(v, a); return; }
|
|
193
|
+
// Asked once straight away (a lookup already out may predate the save, and a new one supersedes it); after that the
|
|
194
|
+
// poll keeps asking, so repeated news or redraws never add lookups.
|
|
195
|
+
if (!v.addressAsked) { v.addressAsked = true; startLookup(v); }
|
|
196
|
+
ensurePoll(v);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
stopPoll(v);
|
|
200
|
+
// What happened, why, and what to do next (#2476 review: the reason alone left the person without a way forward).
|
|
201
|
+
setNote((a.filesWithheld
|
|
202
|
+
? 'Saved to the workflow’s Page without its pictures and files: ' + a.filesWithheld.replace(/[.\s]+$/, '') + '.'
|
|
203
|
+
: 'Saved to the workflow’s Page without its pictures and files.') + ' ' + WITHHELD_NEXT);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function stopPoll(v) { if (v.pollTimer != null) { clearTimer(v.pollTimer); v.pollTimer = null; } }
|
|
207
|
+
|
|
208
|
+
function ensurePoll(v) {
|
|
209
|
+
if (v.pollTimer != null || v.sticky || v.shown) return;
|
|
210
|
+
var g = v.gen;
|
|
211
|
+
v.pollTimer = setTimer(function () {
|
|
212
|
+
v.pollTimer = null;
|
|
213
|
+
if (stale(v, g)) return;
|
|
214
|
+
startLookup(v);
|
|
215
|
+
}, POLL_MS);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ── asking the server ──────────────────────────────────────────────────────────────────────────────────
|
|
219
|
+
|
|
220
|
+
function startLookup(v) {
|
|
221
|
+
var g = v.gen;
|
|
222
|
+
var seq = (v.lookupSeq += 1);
|
|
223
|
+
v.lookupBusy = true;
|
|
224
|
+
var url = '/api/pages/workflow?app=' + encodeURIComponent(v.app) + '&run=' + encodeURIComponent(v.runId)
|
|
225
|
+
+ (v.fire ? '&fire=' + encodeURIComponent(v.fire) : '');
|
|
226
|
+
var asking;
|
|
227
|
+
try { asking = Promise.resolve(env.api(url, { timeoutMs: LOOKUP_TIMEOUT_MS })); } catch (e) { asking = Promise.reject(e); }
|
|
228
|
+
asking.then(function (body) {
|
|
229
|
+
if (stale(v, g) || v.lookupSeq !== seq) return;
|
|
230
|
+
v.lookupBusy = false;
|
|
231
|
+
var a = normalise(body && body.run);
|
|
232
|
+
if (!a) { if (!v.held.answer || v.held.answer.state !== 'saved') ensurePoll(v); return; }
|
|
233
|
+
if (a.state === 'saved' && a.version != null && body && typeof body.home === 'string' && body.page && typeof body.page.id === 'string') {
|
|
234
|
+
try { env.onSaved({ app: v.app, runId: v.runId, fire: v.fire, home: body.home, pageId: body.page.id, version: a.version }); }
|
|
235
|
+
catch (e) { /* the header link is a convenience; the frame below does not depend on it */ }
|
|
236
|
+
}
|
|
237
|
+
apply(v, a, false);
|
|
238
|
+
}).catch(function () {
|
|
239
|
+
if (stale(v, g)) return;
|
|
240
|
+
if (v.lookupSeq === seq) v.lookupBusy = false;
|
|
241
|
+
// The question could not be answered (offline, slow): keep what is shown and ask again while it matters.
|
|
242
|
+
var a = v.held.answer;
|
|
243
|
+
if (!a || a.state === 'pending' || a.state === 'none' || (a.state === 'saved' && a.files > 0 && !a.frameUrl)) ensurePoll(v);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ── the Page version's frame ───────────────────────────────────────────────────────────────────────────
|
|
248
|
+
|
|
249
|
+
/** Started once, when the version is known saved with files; never restarted by later answers or the frame's load. */
|
|
250
|
+
function startOpeningDeadline(v) {
|
|
251
|
+
if (v.readyTimer != null) return;
|
|
252
|
+
var g = v.gen;
|
|
253
|
+
v.readyTimer = setTimer(function () {
|
|
254
|
+
v.readyTimer = null;
|
|
255
|
+
// Only while it is still "saved with files, not yet shown": a newer answer (failed, saved without files) keeps its own note.
|
|
256
|
+
var a = v.held.answer;
|
|
257
|
+
if (!stale(v, g) && !v.shown && a && a.state === 'saved' && a.files > 0) fallback(v);
|
|
258
|
+
}, READY_WAIT_MS);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function showVersion(v, a) {
|
|
262
|
+
if (v.navUrl === a.frameUrl) return;
|
|
263
|
+
v.navUrl = a.frameUrl;
|
|
264
|
+
var nav = token();
|
|
265
|
+
v.nav = { token: nav };
|
|
266
|
+
startOpeningDeadline(v);
|
|
267
|
+
page.hidden = true;
|
|
268
|
+
page.setAttribute('src', a.frameUrl + '?nav=' + nav);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function fallback(v) {
|
|
272
|
+
if (v.readyTimer != null) { clearTimer(v.readyTimer); v.readyTimer = null; }
|
|
273
|
+
v.sticky = true;
|
|
274
|
+
v.shown = false;
|
|
275
|
+
v.nav = null;
|
|
276
|
+
stopPoll(v);
|
|
277
|
+
blankPageFrame();
|
|
278
|
+
if (inert) inert.hidden = false;
|
|
279
|
+
setNote(NOTES.frame);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function becameReady(v) {
|
|
283
|
+
if (v.readyTimer != null) { clearTimer(v.readyTimer); v.readyTimer = null; }
|
|
284
|
+
v.shown = true;
|
|
285
|
+
stopPoll(v);
|
|
286
|
+
if (v.stillTimer != null) { clearTimer(v.stillTimer); v.stillTimer = null; }
|
|
287
|
+
page.hidden = false;
|
|
288
|
+
if (inert) inert.hidden = true;
|
|
289
|
+
setNote('');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function onMessage(event) {
|
|
293
|
+
var v = view;
|
|
294
|
+
if (!v || !page || event.source !== page.contentWindow || !event.source) return;
|
|
295
|
+
var d = event.data;
|
|
296
|
+
if (!d || typeof d.type !== 'string') return;
|
|
297
|
+
if (d.type === 'floless-page-ready' || d.type === 'floless-page-unavailable') {
|
|
298
|
+
// Only the CURRENT navigation of the CURRENT paint: a message queued by an earlier document carries its token.
|
|
299
|
+
if (!v.nav || d.nav !== v.nav.token || stale(v, v.gen)) return;
|
|
300
|
+
if (d.type === 'floless-page-ready') becameReady(v); else fallback(v);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (PAGE_REQUESTS.indexOf(d.type) >= 0 && v.shown && !v.linksNoted) {
|
|
304
|
+
// A link ask or a blocked site needs the Pages screen's consent step; this view does not host it.
|
|
305
|
+
v.linksNoted = true;
|
|
306
|
+
setNote(NOTES.links);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
win.addEventListener('message', onMessage);
|
|
310
|
+
|
|
311
|
+
// ── the entry points aware.js calls ────────────────────────────────────────────────────────────────────
|
|
312
|
+
|
|
313
|
+
/** Show a report that carries files. `entry`: { runId, captureKey?, fireKey? } of the report on screen. */
|
|
314
|
+
function paint(entry) {
|
|
315
|
+
invalidate();
|
|
316
|
+
var app = env.currentApp();
|
|
317
|
+
var runId = entry && typeof entry.runId === 'string' && entry.runId ? entry.runId : null;
|
|
318
|
+
var fire = entry && typeof entry.fireKey === 'string' && entry.fireKey ? entry.fireKey : null;
|
|
319
|
+
if (!fire && entry && typeof entry.captureKey === 'string' && entry.captureKey.indexOf('#') > 0) {
|
|
320
|
+
fire = entry.captureKey.slice(entry.captureKey.indexOf('#') + 1) || null;
|
|
321
|
+
runId = runId || entry.captureKey.slice(0, entry.captureKey.indexOf('#'));
|
|
322
|
+
}
|
|
323
|
+
if (inert) inert.hidden = false;
|
|
324
|
+
if (!app || !runId) { setNote(NOTES.none); return; }
|
|
325
|
+
var v = view = {
|
|
326
|
+
gen: gen, app: app, runId: runId, fire: fire, nk: nkey(app, runId, fire), startedAt: now(),
|
|
327
|
+
held: { epoch: null, rev: 0, answer: null }, lookupSeq: 0, lookupBusy: false, addressAsked: false,
|
|
328
|
+
pollTimer: null, stillTimer: null, readyTimer: null, nav: null, navUrl: '', sticky: false, shown: false, linksNoted: false,
|
|
329
|
+
};
|
|
330
|
+
var g = v.gen;
|
|
331
|
+
// The "still saving" wording takes over by itself, with no news needed.
|
|
332
|
+
v.stillTimer = setTimer(function () { v.stillTimer = null; if (!stale(v, g)) render(v); }, STILL_SAVING_MS);
|
|
333
|
+
var heard = news.get(v.nk);
|
|
334
|
+
if (heard) apply(v, heard, false); else render(v);
|
|
335
|
+
if (!v.lookupBusy) startLookup(v);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** `workflow-page-captured` news from the server. */
|
|
339
|
+
function onNews(m) {
|
|
340
|
+
var a = fromNews(m);
|
|
341
|
+
if (!a) return;
|
|
342
|
+
var key = nkey(m.app, m.runId, typeof m.fireKey === 'string' ? m.fireKey : '');
|
|
343
|
+
noteNews(key, a);
|
|
344
|
+
if (view && view.nk === key && env.currentApp() === view.app && view.gen === gen) apply(view, a, true);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return { paint: paint, invalidate: invalidate, reset: reset, onNews: onNews,
|
|
348
|
+
/** For tests and diagnostics: what the view holds. */
|
|
349
|
+
inspect: function () { return view && { gen: view.gen, state: view.held.answer && view.held.answer.state, epoch: view.held.epoch, rev: view.held.rev, shown: view.shown, sticky: view.sticky, lookupSeq: view.lookupSeq }; } };
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
root.FlolessRunPageView = { create: create, NOTES: NOTES, READY_WAIT_MS: READY_WAIT_MS, POLL_MS: POLL_MS, STILL_SAVING_MS: STILL_SAVING_MS, NONE_PROVISIONAL_MS: NONE_PROVISIONAL_MS };
|
|
353
|
+
})(typeof window !== 'undefined' ? window : globalThis);
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* Keep startup reads in the page until the server has recovered their stores.
|
|
2
|
+
* Waiting here uses no HTTP connection. The server's own barrier still authorizes every request.
|
|
3
|
+
*/
|
|
4
|
+
(() => {
|
|
5
|
+
function createStartupAdmission(options = {}) {
|
|
6
|
+
const fetchHealth = options.fetch || globalThis.fetch.bind(globalThis);
|
|
7
|
+
const origin = options.origin || globalThis.location.origin;
|
|
8
|
+
const setTimer = options.setTimeout || globalThis.setTimeout.bind(globalThis);
|
|
9
|
+
const clearTimer = options.clearTimeout || globalThis.clearTimeout.bind(globalThis);
|
|
10
|
+
const probeTimeoutMs = options.probeTimeoutMs ?? 45000;
|
|
11
|
+
const pollDelayMs = options.pollDelayMs ?? 1000;
|
|
12
|
+
let generation = 0, suspended = false, disposed = false, probe = null, delay = null;
|
|
13
|
+
const wakeups = new Set();
|
|
14
|
+
const reset = () => Object.assign(new Error('Startup observation was superseded.'), { code: 'startup-observation-superseded' });
|
|
15
|
+
const cancelled = () => new DOMException('The read was cancelled.', 'AbortError');
|
|
16
|
+
|
|
17
|
+
function wait(promise, signal) {
|
|
18
|
+
if (signal?.aborted) return Promise.reject(signal.reason || cancelled());
|
|
19
|
+
if (!signal) return promise;
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
const abort = () => { cleanup(); reject(signal.reason || cancelled()); };
|
|
22
|
+
const cleanup = () => signal.removeEventListener('abort', abort);
|
|
23
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
24
|
+
promise.then(value => { cleanup(); resolve(value); }, error => { cleanup(); reject(error); });
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function wake() { for (const resume of [...wakeups]) resume(); }
|
|
29
|
+
function invalidate() {
|
|
30
|
+
generation++;
|
|
31
|
+
const oldProbe = probe; probe = null;
|
|
32
|
+
if (oldProbe) { clearTimer(oldProbe.timer); oldProbe.controller.abort(); oldProbe.reject(reset()); }
|
|
33
|
+
const oldDelay = delay; delay = null;
|
|
34
|
+
if (oldDelay) { clearTimer(oldDelay.timer); oldDelay.reject(reset()); }
|
|
35
|
+
wake();
|
|
36
|
+
}
|
|
37
|
+
function suspend() { suspended = true; invalidate(); }
|
|
38
|
+
function resume() { suspended = false; invalidate(); }
|
|
39
|
+
function dispose() { disposed = true; suspended = false; invalidate(); }
|
|
40
|
+
|
|
41
|
+
async function active(signal) {
|
|
42
|
+
while (suspended) {
|
|
43
|
+
let resume;
|
|
44
|
+
try {
|
|
45
|
+
await wait(new Promise(resolve => {
|
|
46
|
+
resume = () => resolve();
|
|
47
|
+
wakeups.add(resume);
|
|
48
|
+
}), signal);
|
|
49
|
+
} finally { wakeups.delete(resume); }
|
|
50
|
+
}
|
|
51
|
+
if (disposed) throw cancelled();
|
|
52
|
+
if (signal?.aborted) throw signal.reason || cancelled();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function observation() {
|
|
56
|
+
if (probe) return probe.promise;
|
|
57
|
+
const owner = { generation, controller: new AbortController(), timer: null, promise: null, reject: null };
|
|
58
|
+
const superseded = new Promise((_, reject) => { owner.reject = reject; });
|
|
59
|
+
owner.timer = setTimer(() => owner.controller.abort(), probeTimeoutMs);
|
|
60
|
+
probe = owner;
|
|
61
|
+
owner.promise = Promise.race([Promise.resolve().then(async () => {
|
|
62
|
+
if (owner.generation !== generation) throw reset();
|
|
63
|
+
let response;
|
|
64
|
+
try { response = await fetchHealth('/api/health', { cache: 'no-store', signal: owner.controller.signal }); }
|
|
65
|
+
catch (cause) {
|
|
66
|
+
if (owner.generation !== generation) throw reset();
|
|
67
|
+
throw Object.assign(new Error('FloLess could not be reached. Make sure it is still running, then try again.'), { cause });
|
|
68
|
+
}
|
|
69
|
+
let body;
|
|
70
|
+
try { body = await response.json(); }
|
|
71
|
+
catch (cause) { throw Object.assign(new Error('FloLess could not check whether project recovery is finished. Try again in a moment.'), { cause }); }
|
|
72
|
+
if (owner.generation !== generation) throw reset();
|
|
73
|
+
if (!response.ok) throw Object.assign(new Error('FloLess could not be reached. Make sure it is still running, then try again.'), { status: response.status, body });
|
|
74
|
+
const admission = body?.startupAdmission;
|
|
75
|
+
if (!admission || typeof admission.ready !== 'boolean' || typeof admission.instanceId !== 'string' || !admission.instanceId
|
|
76
|
+
|| !Array.isArray(admission.independentReadPaths) || !admission.independentReadPaths.every(path => typeof path === 'string')
|
|
77
|
+
|| !Array.isArray(admission.independentReadPrefixes) || !admission.independentReadPrefixes.every(path => typeof path === 'string')) {
|
|
78
|
+
throw new Error('FloLess could not check whether project recovery is finished. Try again in a moment.');
|
|
79
|
+
}
|
|
80
|
+
return body;
|
|
81
|
+
}), superseded]).finally(() => {
|
|
82
|
+
clearTimer(owner.timer);
|
|
83
|
+
if (probe === owner) probe = null;
|
|
84
|
+
});
|
|
85
|
+
return owner.promise;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function health({ signal } = {}) {
|
|
89
|
+
for (;;) {
|
|
90
|
+
await active(signal);
|
|
91
|
+
try { return await wait(observation(), signal); }
|
|
92
|
+
catch (error) { if (error?.code !== 'startup-observation-superseded') throw error; }
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function pause() {
|
|
97
|
+
if (!delay) {
|
|
98
|
+
const owner = { timer: null, promise: null, reject: null };
|
|
99
|
+
owner.promise = new Promise((resolve, reject) => {
|
|
100
|
+
owner.reject = reject;
|
|
101
|
+
owner.timer = setTimer(resolve, pollDelayMs);
|
|
102
|
+
}).finally(() => { if (delay === owner) delay = null; });
|
|
103
|
+
delay = owner;
|
|
104
|
+
}
|
|
105
|
+
return delay.promise;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function admit(path, { method = 'GET', signal } = {}) {
|
|
109
|
+
const url = new URL(path, origin);
|
|
110
|
+
if (url.origin !== origin || !['GET', 'HEAD'].includes(method.toUpperCase()) || !url.pathname.startsWith('/api/')) return;
|
|
111
|
+
const pathname = decodeURIComponent(url.pathname);
|
|
112
|
+
if (pathname === '/api/health') return;
|
|
113
|
+
for (;;) {
|
|
114
|
+
const body = await health({ signal });
|
|
115
|
+
const admission = body.startupAdmission;
|
|
116
|
+
if (admission.ready || admission.independentReadPaths.includes(pathname)
|
|
117
|
+
|| admission.independentReadPrefixes.some(prefix => pathname === prefix || pathname.startsWith(`${prefix}/`))) return;
|
|
118
|
+
try { await wait(pause(), signal); }
|
|
119
|
+
catch (error) { if (error?.code !== 'startup-observation-superseded') throw error; }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return { admit, health, invalidate, suspend, resume, dispose };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
globalThis.createStartupAdmission = createStartupAdmission;
|
|
127
|
+
if (typeof window !== 'undefined' && window.document) {
|
|
128
|
+
window.flolessStartupAdmission = createStartupAdmission();
|
|
129
|
+
window.addEventListener('pagehide', () => window.flolessStartupAdmission.suspend());
|
|
130
|
+
window.addEventListener('pageshow', event => { if (event.persisted) window.flolessStartupAdmission.resume(); });
|
|
131
|
+
}
|
|
132
|
+
})();
|
|
@@ -1063,6 +1063,15 @@ export function isUnknownElev(e) { return !!e && e.unknown === true; }
|
|
|
1063
1063
|
export function isAssumedElev(e) { return !!e && e.assumed === true; }
|
|
1064
1064
|
/** Either spelling of "nobody has confirmed this height". */
|
|
1065
1065
|
export function isUnresolvedElev(e) { return isUnknownElev(e) || isAssumedElev(e); }
|
|
1066
|
+
/**
|
|
1067
|
+
* DECIDED BY THE AI in a Quick model build (#2521). Real geometry that a quick BOM counts, so it is NOT
|
|
1068
|
+
* unresolved (`isUnresolvedElev` stays false and the member is measured), but it is not evidence either:
|
|
1069
|
+
* never agreement, never an anchor, never the person's answer. Ask this wherever a decision rests on
|
|
1070
|
+
* whether a height is EVIDENCE.
|
|
1071
|
+
*/
|
|
1072
|
+
export function isDecidedElev(e) { return !!e && !!e.decided && typeof e.decided === 'object' && typeof e.known === 'number'; }
|
|
1073
|
+
/** Is this height EVIDENCE: a number the drawings or the person gave? Not when unresolved or decided by the AI. */
|
|
1074
|
+
export function isEvidenceElev(e) { return knownZ(e) !== null && !isUnresolvedElev(e) && !isDecidedElev(e); }
|
|
1066
1075
|
/** The known elevation in mm, or null when unknown/malformed. Never returns 0 for "unknown". */
|
|
1067
1076
|
export function knownZ(e) { return e && typeof e.known === 'number' && Number.isFinite(e.known) ? e.known : null; }
|
|
1068
1077
|
|