@floless/app 0.156.0 → 0.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli-actions.mjs +21 -5
- package/dist/floless-server.cjs +70965 -43326
- package/dist/schemas/drawing-check.profile.v1.schema.json +15 -2
- package/dist/schemas/steel.model.v2.schema.json +25 -1
- package/dist/skills/floless-app-actions/SKILL.md +79 -17
- package/dist/skills/floless-app-knowledge/SKILL.md +21 -2
- package/dist/skills/floless-app-new-workflow/SKILL.md +23 -7
- package/dist/skills/floless-app-onboarding/SKILL.md +31 -1
- package/dist/skills/floless-app-report-issue/SKILL.md +3 -3
- package/dist/skills/floless-app-rfi/SKILL.md +40 -6
- package/dist/skills/floless-app-routines/SKILL.md +9 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +1 -1
- package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +4 -2
- package/dist/skills/floless-app-tweak-contract/SKILL.md +25 -5
- package/dist/skills/floless-app-workflows/SKILL.md +46 -10
- package/dist/skills/floless-app-workflows/references/agent-steps.md +119 -0
- package/dist/web/agent-steps.js +864 -47
- package/dist/web/agents.js +28 -8
- package/dist/web/app.css +478 -3
- package/dist/web/app.js +110 -11
- package/dist/web/aware-update-client.js +1 -0
- package/dist/web/aware.js +685 -170
- package/dist/web/chat-landing-scene.js +372 -0
- package/dist/web/chat.css +245 -1
- package/dist/web/chat.js +2466 -78
- package/dist/web/commands-drawing-check.js +17 -0
- package/dist/web/commands-shell.js +820 -3
- package/dist/web/commands-steel.js +6 -0
- package/dist/web/connections.js +1 -0
- package/dist/web/drawing-check-editor.html +33 -5
- package/dist/web/drawing-check-editor.js +538 -22
- package/dist/web/drawing-check-overlay.js +13 -0
- package/dist/web/flo-avatar.js +28 -3
- package/dist/web/guide.js +7 -2
- package/dist/web/index.html +119 -6
- package/dist/web/instructor.js +3 -3
- package/dist/web/model-view-query.js +12 -2
- package/dist/web/pages.js +865 -34
- package/dist/web/panels.js +5 -2
- package/dist/web/parser-setup-recovery.js +12 -4
- package/dist/web/project-access.js +549 -0
- package/dist/web/report-files.js +50 -0
- package/dist/web/startup-admission.js +132 -0
- package/dist/web/steel-3d-core.js +9 -0
- package/dist/web/steel-editor.html +642 -22
- package/dist/web/steel-model-v2-commands.js +63 -5
- package/dist/web/step-rename.js +287 -0
- package/dist/web/terminal-requests.js +59 -10
- package/dist/web/tool-updates.js +1 -0
- package/dist/web/workspace-root-management.js +39 -0
- package/dist/web/workspaces.js +1667 -63
- package/launch.mjs +9 -7
- package/package.json +3 -1
package/dist/web/aware.js
CHANGED
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
// One persistent array the inspect Execution tab reads; we mutate in place so
|
|
64
64
|
// every AGENTS[node].execution reference stays valid across re-renders.
|
|
65
65
|
const liveTrace = [];
|
|
66
|
+
let traceRunId = null; // #2374: the run the trace being shown belongs to (from its run-start)
|
|
66
67
|
// Latest normalized app payload, keyed by id, so handlers can read mode/gate.
|
|
67
68
|
const apps = new Map();
|
|
68
69
|
// Who owns each listed workflow, from the Workflows library (/api/workflows/library). A PARALLEL map like
|
|
@@ -302,10 +303,21 @@
|
|
|
302
303
|
});
|
|
303
304
|
window.addEventListener('pageshow', () => { awarePageUnloading = false; });
|
|
304
305
|
|
|
305
|
-
|
|
306
|
+
// The health poll and startup admission share one generation-fenced observation.
|
|
307
|
+
async function readHealth() {
|
|
308
|
+
if (globalThis.flolessStartupAdmission) return globalThis.flolessStartupAdmission.health();
|
|
309
|
+
const response = await fetch('/api/health', { cache: 'no-store', signal: AbortSignal.timeout(45_000) });
|
|
310
|
+
if (!response.ok) throw new Error('FloLess could not be reached. Make sure it is still running, then try again.');
|
|
311
|
+
return response.json();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async function api(path, opts = {}) {
|
|
315
|
+
await globalThis.flolessStartupAdmission?.admit(path, { method: opts?.method, signal: opts?.signal });
|
|
316
|
+
const { timeoutMs, ...requestOptions } = opts;
|
|
317
|
+
if (!requestOptions.signal && Number.isFinite(timeoutMs)) requestOptions.signal = AbortSignal.timeout(timeoutMs);
|
|
306
318
|
const res = await fetch(path, {
|
|
307
319
|
headers: { 'content-type': 'application/json' },
|
|
308
|
-
...
|
|
320
|
+
...requestOptions,
|
|
309
321
|
});
|
|
310
322
|
const body = await res.json().catch(() => ({
|
|
311
323
|
ok: false,
|
|
@@ -558,9 +570,12 @@
|
|
|
558
570
|
// #2241: an Agent step (its ANSWER is written by an AI at run time). Null for every other node. A label is a fact about the workflow,
|
|
559
571
|
// so it shows whether or not the feature is on; web/agent-steps.js builds the parts from the lock marker / source node, never invented here.
|
|
560
572
|
const aiStep = window.flolessAgentSteps?.entryParts(app, n, window.flolessAgentSteps.checkFor(app.id, n.id)) || null;
|
|
573
|
+
// #2374: a node FloLess found using (or decided by) an Agent step's answer carries a quieter chip and one Inspect line.
|
|
574
|
+
const aiUse = !aiStep && window.flolessAgentSteps?.useParts ? window.flolessAgentSteps.useParts(app, n) : null;
|
|
561
575
|
return {
|
|
562
576
|
_mode: n.mode,
|
|
563
577
|
_aiStep: aiStep ? { badge: aiStep.badge, attention: aiStep.attention } : null,
|
|
578
|
+
_aiUse: aiUse ? aiUse.chip : null,
|
|
564
579
|
_runtimeModel: !!n.runtimeModel, // B2: lock stamped runtime-model → card badge
|
|
565
580
|
_frozen: !!n.frozen, // source node carries a `frozen:` block → card badge + Unfreeze menu
|
|
566
581
|
icon: iconFor(n.agent),
|
|
@@ -570,7 +585,7 @@
|
|
|
570
585
|
title: escapeHtml(n.id),
|
|
571
586
|
subtitle: `${agentLabel}${cmd ? '/' + cmd : ''} · ${mode}`,
|
|
572
587
|
blurb: aiStep ? aiStep.blurb : blurbText ? escapeHtml(blurbText) : n.notes[0] ? escapeHtml(humanizeNote(n.notes[0].text)) : `${mode}-mode ${cmd ? '<code>' + cmd + '</code>' : escapeHtml(n.kind)} node`,
|
|
573
|
-
description: aiStep ? `${aiStep.descriptionHtml}${notesHtml}` : `${plainDesc ? `<p>${escapeHtml(plainDesc)}</p>` : ''}<p>Resolves to ${modeBadge} via <code>${escapeHtml(n.agent || n.kind)}${n.command ? '.' + escapeHtml(n.command) : ''}</code>.</p>${descInputs(inputs)}${execSource ? `<p class="dim-note">Full source in the <strong>Code</strong> tab.</p>` : ''}${notesHtml}`,
|
|
588
|
+
description: aiStep ? `${aiStep.descriptionHtml}${notesHtml}` : `${aiUse ? aiUse.descriptionHtml : ''}${plainDesc ? `<p>${escapeHtml(plainDesc)}</p>` : ''}<p>Resolves to ${modeBadge} via <code>${escapeHtml(n.agent || n.kind)}${n.command ? '.' + escapeHtml(n.command) : ''}</code>.</p>${descInputs(inputs)}${execSource ? `<p class="dim-note">Full source in the <strong>Code</strong> tab.</p>` : ''}${notesHtml}`,
|
|
574
589
|
// Rich agent/command detail when the manifest is installed (n.skill); else
|
|
575
590
|
// the lock-pointer fallback below (exec/agent-less nodes, uninstalled agents).
|
|
576
591
|
skill: skillBody(
|
|
@@ -1451,7 +1466,10 @@
|
|
|
1451
1466
|
paintKbInformed(null, false); // clear the previous workflow's row before the await, not after
|
|
1452
1467
|
if (!id) return;
|
|
1453
1468
|
try {
|
|
1454
|
-
const
|
|
1469
|
+
const path = `/api/kb-pin/${encodeURIComponent(id)}`;
|
|
1470
|
+
await globalThis.flolessStartupAdmission?.admit(path);
|
|
1471
|
+
if (read !== kbPinRead || currentId !== id) return;
|
|
1472
|
+
const r = await fetch(path, { cache: 'no-store' });
|
|
1455
1473
|
const d = await r.json();
|
|
1456
1474
|
if (read !== kbPinRead || currentId !== id) return; // superseded — a newer workflow owns the strip
|
|
1457
1475
|
if (r.ok && d.ok) paintKbInformed(d.pin, !!d.drift);
|
|
@@ -2181,6 +2199,8 @@
|
|
|
2181
2199
|
openAgents: () => { void window.flolessWorkspaces?.setMode?.('agents'); },
|
|
2182
2200
|
toast: (text, kind) => showToast(text, kind),
|
|
2183
2201
|
repaint: repaintAgentSteps,
|
|
2202
|
+
// #2374: the trace labels outputs from the run's own record, which arrives after the run ends.
|
|
2203
|
+
runRecordChanged: (appId) => { if (appId === currentId && state.currentTab === 'execution') renderInspect(); },
|
|
2184
2204
|
});
|
|
2185
2205
|
|
|
2186
2206
|
async function loadApp(id) {
|
|
@@ -2269,6 +2289,20 @@
|
|
|
2269
2289
|
return waitForPublicationAvailabilityIdle();
|
|
2270
2290
|
}
|
|
2271
2291
|
|
|
2292
|
+
// An SSE-driven availability re-read is for the workflow still selected underneath whatever is on
|
|
2293
|
+
// screen. While Workspaces or Agents is showing, a failure there is nothing the person did, and
|
|
2294
|
+
// returning to Workflows re-reads it (refreshCurrentWorkflow) and reports a failure itself — so it
|
|
2295
|
+
// is logged, not toasted. 2026-10-16: an expired module lease turned every chat approval's
|
|
2296
|
+
// projects-changed into a generic "We couldn't finish that" toast over a Tekla Parser project.
|
|
2297
|
+
// On Workflows the card is the person's to see, so a failure there is still reported.
|
|
2298
|
+
function reportBackgroundAvailabilityErr(e) {
|
|
2299
|
+
if (document.body.classList.contains('mode-workspaces') || document.body.classList.contains('mode-agents')) {
|
|
2300
|
+
console.warn('[floless] the selected workflow’s availability could not be refreshed in the background', e);
|
|
2301
|
+
return;
|
|
2302
|
+
}
|
|
2303
|
+
reportErr(e);
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2272
2306
|
// Workspaces keeps the existing workflow selected underneath its project surface. Returning to
|
|
2273
2307
|
// Workflows is therefore a re-open of that workflow: refresh both its publication state and the
|
|
2274
2308
|
// additive provenance strip, so a KB organize that happened while the project was open cannot
|
|
@@ -4115,7 +4149,13 @@
|
|
|
4115
4149
|
// after the report is cached here. It is kept by run id and joined to the report of the SAME run only, never to a
|
|
4116
4150
|
// newer one. `workflowPageLatest` is the newest version this window knows per workflow, for the empty viewer after
|
|
4117
4151
|
// a reload; for one Page it only ever grows.
|
|
4118
|
-
|
|
4152
|
+
// Keyed by CAPTURE: a completed run's runId, or `runId#fireKey` for one fire of a live trigger session (slice 3b),
|
|
4153
|
+
// so an older fire's news never joins a newer fire's report.
|
|
4154
|
+
const workflowPageByRun = new Map(); // captureKey → { app, home, pageId, version }
|
|
4155
|
+
function captureKeyOf(runId, fireKey) {
|
|
4156
|
+
if (typeof runId !== 'string' || !runId) return null;
|
|
4157
|
+
return typeof fireKey === 'string' && fireKey ? `${runId}#${fireKey}` : runId;
|
|
4158
|
+
}
|
|
4119
4159
|
const workflowPageLatest = new Map(); // app id → { home, pageId, version, at }
|
|
4120
4160
|
const WORKFLOW_PAGE_RUNS_KEPT = 64;
|
|
4121
4161
|
|
|
@@ -4127,7 +4167,8 @@
|
|
|
4127
4167
|
|
|
4128
4168
|
/** The Page version this cached report became, once its capture has landed. */
|
|
4129
4169
|
function reportPageOf(entry) {
|
|
4130
|
-
|
|
4170
|
+
const key = entry ? (typeof entry.captureKey === 'string' ? entry.captureKey : captureKeyOf(entry.runId)) : null;
|
|
4171
|
+
return key ? workflowPageByRun.get(key) || null : null;
|
|
4131
4172
|
}
|
|
4132
4173
|
|
|
4133
4174
|
function applyWorkflowPageCaptured(m) {
|
|
@@ -4138,12 +4179,23 @@
|
|
|
4138
4179
|
else console.warn(`Workflow ${m.app}: ${m.warning}`);
|
|
4139
4180
|
return;
|
|
4140
4181
|
}
|
|
4182
|
+
// #2262 slice 3c: saved, but part of what the run made could not go with it (a report folder's files).
|
|
4183
|
+
if (typeof m.notice === 'string') {
|
|
4184
|
+
if (currentId === m.app) showToast(m.notice, 'warn');
|
|
4185
|
+
else console.warn(`Workflow ${m.app}: ${m.notice}`);
|
|
4186
|
+
}
|
|
4187
|
+
if (m.relabelled === 'live-failed' && typeof m.home === 'string' && typeof m.pageId === 'string') {
|
|
4188
|
+
// A failed live session's versions changed label: an open copy of that Page must not keep the old one.
|
|
4189
|
+
window.flolessPages?.reloadIfOpen?.(m.home, m.pageId);
|
|
4190
|
+
window.flolessPages?.refresh?.();
|
|
4191
|
+
return;
|
|
4192
|
+
}
|
|
4141
4193
|
if (typeof m.home !== 'string' || typeof m.pageId !== 'string' || !Number.isInteger(m.version) || m.version < 1) {
|
|
4142
4194
|
console.warn('A workflow Page update could not be read, so it was ignored.', m);
|
|
4143
4195
|
return;
|
|
4144
4196
|
}
|
|
4145
4197
|
const page = { app: m.app, home: m.home, pageId: m.pageId, version: m.version };
|
|
4146
|
-
workflowPageByRun.set(m.runId, page);
|
|
4198
|
+
workflowPageByRun.set(captureKeyOf(m.runId, m.fireKey) || m.runId, page);
|
|
4147
4199
|
if (workflowPageByRun.size > WORKFLOW_PAGE_RUNS_KEPT) workflowPageByRun.delete(workflowPageByRun.keys().next().value);
|
|
4148
4200
|
noteWorkflowPageLatest(m.app, page);
|
|
4149
4201
|
window.flolessPages?.refresh?.();
|
|
@@ -4185,7 +4237,11 @@
|
|
|
4185
4237
|
function paintReportPageLinks() {
|
|
4186
4238
|
const app = currentId;
|
|
4187
4239
|
const cached = app ? lastReportByApp.get(app) : null;
|
|
4188
|
-
|
|
4240
|
+
// #2539: only for the report actually on screen — a complete report shown is that run's own (matched by handle), never
|
|
4241
|
+
// one opened from a Page version or another run.
|
|
4242
|
+
const shown = cached && !reportRunning && $reportOverlay.hidden
|
|
4243
|
+
&& (cached.handle ? currentCompleteReport?.handle === cached.handle : !currentCompleteReport);
|
|
4244
|
+
const page = shown ? reportPageOf(cached) : null;
|
|
4189
4245
|
if ($reportPage) {
|
|
4190
4246
|
$reportPage.hidden = !page;
|
|
4191
4247
|
if (page) {
|
|
@@ -4283,7 +4339,7 @@
|
|
|
4283
4339
|
if (foregroundTrigger) {
|
|
4284
4340
|
const ft = foregroundTrigger;
|
|
4285
4341
|
foregroundStopping = true;
|
|
4286
|
-
foregroundTrigger = null;
|
|
4342
|
+
foregroundTrigger = null; liveViewerMayHaveChanged();
|
|
4287
4343
|
if ($stopRunBtn) { $stopRunBtn.disabled = true; $stopRunBtn.textContent = 'Stopping…'; }
|
|
4288
4344
|
syncRunControls();
|
|
4289
4345
|
try { await api(`/api/trigger-run/${encodeURIComponent(ft.appId)}/stop`, { method: 'POST' }); } catch { /* best effort — the session may already be gone */ }
|
|
@@ -4342,6 +4398,7 @@
|
|
|
4342
4398
|
let currentCompleteReport = null;
|
|
4343
4399
|
let currentReportSection = 0;
|
|
4344
4400
|
let reportSectionRequest = 0;
|
|
4401
|
+
let reportObjectLookup = 0; // #2539: the newest Go to object; an older one never touches its message
|
|
4345
4402
|
function updateReportSectionNavigation(ordinal, index) {
|
|
4346
4403
|
const first = ordinal === 0;
|
|
4347
4404
|
const last = ordinal + 1 >= index.chunkCount;
|
|
@@ -4359,6 +4416,31 @@
|
|
|
4359
4416
|
}
|
|
4360
4417
|
if (controls.some(([control]) => control === focused)) window.Instructor?.refreshCarrier(focused);
|
|
4361
4418
|
}
|
|
4419
|
+
// #2262 slice 3c: "Open the full report" beside a complete report's Page version. The server answers the report's
|
|
4420
|
+
// handle for that version's run, after the report viewer's own checks; the Page viewer closes and this one opens.
|
|
4421
|
+
window.FlolessReports = {
|
|
4422
|
+
async openPageVersionReport({ home, id, n, title, beforeShow }) {
|
|
4423
|
+
let answer;
|
|
4424
|
+
try {
|
|
4425
|
+
await ensureReportDiscoverySession();
|
|
4426
|
+
answer = await api(`/api/pages/${encodeURIComponent(home)}/${encodeURIComponent(id)}/versions/${encodeURIComponent(n)}/full-report`);
|
|
4427
|
+
} catch (error) {
|
|
4428
|
+
showToast(error?.message && !/^HTTP \d+$/.test(error.message) ? error.message : 'FloLess couldn’t open the full report. Try again in a moment.', 'warn');
|
|
4429
|
+
return false;
|
|
4430
|
+
}
|
|
4431
|
+
if (typeof answer?.handle !== 'string' || !answer.handle) {
|
|
4432
|
+
showToast('FloLess couldn’t open the full report. Try again in a moment.', 'warn');
|
|
4433
|
+
return false;
|
|
4434
|
+
}
|
|
4435
|
+
beforeShow?.();
|
|
4436
|
+
$reportTitle.textContent = `HTML Viewer · ${title || 'Complete model report'}`;
|
|
4437
|
+
showModal($reportModal);
|
|
4438
|
+
$reportClose.focus();
|
|
4439
|
+
await paintCompleteReport({ handle: answer.handle });
|
|
4440
|
+
return true;
|
|
4441
|
+
},
|
|
4442
|
+
};
|
|
4443
|
+
|
|
4362
4444
|
function clearCompleteReportView() {
|
|
4363
4445
|
reportSectionRequest += 1;
|
|
4364
4446
|
currentCompleteReport = null;
|
|
@@ -4369,95 +4451,130 @@
|
|
|
4369
4451
|
$reportObjectError.textContent = '';
|
|
4370
4452
|
$reportFrame.removeAttribute('src');
|
|
4371
4453
|
}
|
|
4372
|
-
|
|
4454
|
+
/** Show one section of a saved complete report. Resolves true once it is on screen, false when it is not. */
|
|
4455
|
+
async function paintCompleteReport(report, asked = null, busyUntil = null) {
|
|
4456
|
+
// #2539: a report another read holds is waited for, not failed — right after a run that is the workflow's Page
|
|
4457
|
+
// saving its copy, which reads the whole report. Past this wait the viewer offers Try again instead.
|
|
4458
|
+
const REPORT_BUSY_WAIT_MS = 5 * 60_000;
|
|
4459
|
+
// The server answers a busy report with 202 and this code (never a failure status), whichever route was asked.
|
|
4460
|
+
const reportIsBusy = (error) => error?.body?.code === 'report-busy';
|
|
4373
4461
|
const request = ++reportSectionRequest;
|
|
4374
4462
|
const handle = encodeURIComponent(report.handle);
|
|
4375
4463
|
$reportOverlay.hidden = false;
|
|
4376
4464
|
$reportOverlay.replaceChildren(mkEl('div', 'spinner'), mkEl('div', null, 'Loading report section…'));
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
ordinal =
|
|
4388
|
-
index
|
|
4465
|
+
// A wait resumed for the same section (the frame found it busy) keeps its first deadline, never a fresh one.
|
|
4466
|
+
const waitUntil = busyUntil ?? Date.now() + REPORT_BUSY_WAIT_MS;
|
|
4467
|
+
for (;;) {
|
|
4468
|
+
let ordinal = asked;
|
|
4469
|
+
try {
|
|
4470
|
+
let index = await api(`/api/model-reports/${handle}/index?at=${ordinal ?? 0}`);
|
|
4471
|
+
if (request !== reportSectionRequest) return false;
|
|
4472
|
+
// Start with the first object's data, while First still opens Model information.
|
|
4473
|
+
// Ask the verified index where that object begins instead of assuming section 2.
|
|
4474
|
+
if (ordinal == null) {
|
|
4475
|
+
ordinal = 0;
|
|
4476
|
+
if (Number(index.objectCount) > 0 && index.current?.firstObject == null) {
|
|
4477
|
+
const firstObject = await api(`/api/model-reports/${handle}/object/0`);
|
|
4478
|
+
if (request !== reportSectionRequest) return false;
|
|
4479
|
+
ordinal = firstObject.chunkOrdinal;
|
|
4480
|
+
index = await api(`/api/model-reports/${handle}/index?at=${ordinal}`);
|
|
4481
|
+
}
|
|
4482
|
+
}
|
|
4483
|
+
if (request !== reportSectionRequest) return false;
|
|
4484
|
+
const response = await fetch(`/api/model-reports/${handle}/chunk/${ordinal}`, { credentials: 'same-origin', cache: 'no-store' });
|
|
4485
|
+
if (!response.ok || response.status === 202) {
|
|
4486
|
+
const body = await response.json().catch(() => null);
|
|
4487
|
+
throw Object.assign(new Error('Report section request failed'), { status: response.status, body });
|
|
4488
|
+
}
|
|
4489
|
+
const length = Number(response.headers.get('content-length'));
|
|
4490
|
+
if (Number.isFinite(length) && length > 1200 * 1024) {
|
|
4491
|
+
await response.body?.cancel();
|
|
4492
|
+
throw Object.assign(new Error('Report section exceeds viewer limit'), { status: 413 });
|
|
4389
4493
|
}
|
|
4390
|
-
}
|
|
4391
|
-
if (request !== reportSectionRequest) return;
|
|
4392
|
-
const response = await fetch(`/api/model-reports/${handle}/chunk/${ordinal}`, { credentials: 'same-origin', cache: 'no-store' });
|
|
4393
|
-
if (!response.ok) {
|
|
4394
|
-
const body = await response.json().catch(() => null);
|
|
4395
|
-
throw Object.assign(new Error('Report section request failed'), { status: response.status, body });
|
|
4396
|
-
}
|
|
4397
|
-
const length = Number(response.headers.get('content-length'));
|
|
4398
|
-
if (Number.isFinite(length) && length > 1200 * 1024) {
|
|
4399
4494
|
await response.body?.cancel();
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
$reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
|
|
4410
|
-
currentCompleteReport = report;
|
|
4411
|
-
currentReportSection = ordinal;
|
|
4412
|
-
const count = Number(index.objectCount) || 0;
|
|
4413
|
-
const properties = Number(index.propertyCount) || 0;
|
|
4414
|
-
const current = index.current || {};
|
|
4415
|
-
const objectRange = count === 0 ? 'No objects' : current.firstObject == null
|
|
4416
|
-
? `Model information · Report contains ${count} objects` : `Objects ${Number(current.firstObject) + 1}–${Number(current.lastObject) + 1} of ${count}`;
|
|
4417
|
-
const propertyRange = properties === 0 ? '0 properties'
|
|
4418
|
-
: current.firstProperty == null ? `Report contains ${properties} properties`
|
|
4419
|
-
: `Properties ${Number(current.firstProperty) + 1}–${Number(current.lastProperty) + 1} of ${properties}`;
|
|
4420
|
-
$reportSectionStatus.textContent = `${objectRange} · ${propertyRange} · section ${ordinal + 1} of ${index.chunkCount}`;
|
|
4421
|
-
updateReportSectionNavigation(ordinal, index);
|
|
4422
|
-
$reportNav.hidden = false;
|
|
4423
|
-
$reportDownload.hidden = false;
|
|
4424
|
-
$reportOpen.hidden = true;
|
|
4425
|
-
$reportShare.hidden = true;
|
|
4426
|
-
showSavedPathActions('');
|
|
4427
|
-
$reportOverlay.hidden = true; $reportOverlay.replaceChildren();
|
|
4428
|
-
// #1840: the caption says when the report's approved version accepted open import findings (the
|
|
4429
|
-
// server's sentence). The report body comes from AWARE's report protocol, which appears to have no
|
|
4430
|
-
// field for it (inferred from its parser's messages, not reproduced). When the server could not
|
|
4431
|
-
// read that approval's record, the caption says so instead of reading as a plain approval.
|
|
4432
|
-
$reportSub.textContent = report.scheduledCaption
|
|
4433
|
-
|| `Complete read-only report · ${count} objects · ${properties} properties · approved revision ${String(index.revisionId).slice(0, 12)} · source unchanged.`;
|
|
4434
|
-
if (typeof index.acceptedImportFindingsNote === 'string') $reportSub.textContent += ` ${index.acceptedImportFindingsNote}`;
|
|
4435
|
-
else if (index.approvalDetailsUnavailable === true) $reportSub.textContent += ' Approval details unavailable.';
|
|
4436
|
-
// What the report rests on comes first (a scheduled "Latest approved" run that read an older
|
|
4437
|
-
// approved version says which), never after the counts where it would read as a footnote.
|
|
4438
|
-
const warnings = Array.isArray(index.warnings) ? index.warnings.filter((warning) => typeof warning === 'string' && warning) : [];
|
|
4439
|
-
if (warnings.length) $reportSub.textContent = `${warnings.join(' ')} ${$reportSub.textContent}`;
|
|
4440
|
-
} catch (error) {
|
|
4441
|
-
if (request !== reportSectionRequest) return;
|
|
4442
|
-
clearCompleteReportView();
|
|
4443
|
-
$reportFrame.srcdoc = '';
|
|
4444
|
-
$reportSub.textContent = 'This report section could not be displayed.';
|
|
4445
|
-
const status = Number(error?.status);
|
|
4446
|
-
let remedy = 'Close the viewer and choose View report to retry loading this saved report.';
|
|
4447
|
-
if (status === 401) remedy = 'Sign in again, then close the viewer and choose View report to load this saved report.';
|
|
4448
|
-
else if (status === 403) remedy = 'Report access could not be confirmed. Check your account access and connection, then choose View report again.';
|
|
4449
|
-
else if (status === 404 || status === 410) remedy = 'This report is no longer available. Choose Run workflow to create a fresh report.';
|
|
4450
|
-
else if (status === 409) remedy = 'This saved report cannot be opened right now. If another read is running, wait for it to finish and choose View report again. Otherwise choose an approved model in Inputs and Run workflow to create a fresh report.';
|
|
4451
|
-
else if (status === 429) remedy = 'This report is busy. Wait for the current read to finish, then close the viewer and choose View report again.';
|
|
4452
|
-
else if (status === 413) {
|
|
4453
|
-
remedy = 'This section is too large for the viewer. Download complete report to read the saved report.';
|
|
4495
|
+
if (request !== reportSectionRequest) return false;
|
|
4496
|
+
$reportFrame.removeAttribute('srcdoc');
|
|
4497
|
+
// Navigate to the real session-gated route. Its restrictive CSP must belong to the
|
|
4498
|
+
// rendered document itself; a blob: copy would silently lose that response header.
|
|
4499
|
+
// #2539: which paint this frame load belongs to, and its wait deadline, should the frame find the report busy.
|
|
4500
|
+
Object.assign($reportFrame.dataset, { request: String(request), busyUntil: String(waitUntil) });
|
|
4501
|
+
$reportFrame.src = `/api/model-reports/${handle}/chunk/${ordinal}`;
|
|
4502
|
+
$reportFrame.hidden = false;
|
|
4503
|
+
$reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
|
|
4454
4504
|
currentCompleteReport = report;
|
|
4505
|
+
currentReportSection = ordinal;
|
|
4506
|
+
const count = Number(index.objectCount) || 0;
|
|
4507
|
+
const properties = Number(index.propertyCount) || 0;
|
|
4508
|
+
const current = index.current || {};
|
|
4509
|
+
const objectRange = count === 0 ? 'No objects' : current.firstObject == null
|
|
4510
|
+
? `Model information · Report contains ${count} objects` : `Objects ${Number(current.firstObject) + 1}–${Number(current.lastObject) + 1} of ${count}`;
|
|
4511
|
+
const propertyRange = properties === 0 ? '0 properties'
|
|
4512
|
+
: current.firstProperty == null ? `Report contains ${properties} properties`
|
|
4513
|
+
: `Properties ${Number(current.firstProperty) + 1}–${Number(current.lastProperty) + 1} of ${properties}`;
|
|
4514
|
+
$reportSectionStatus.textContent = `${objectRange} · ${propertyRange} · section ${ordinal + 1} of ${index.chunkCount}`;
|
|
4515
|
+
updateReportSectionNavigation(ordinal, index);
|
|
4516
|
+
$reportNav.hidden = false;
|
|
4455
4517
|
$reportDownload.hidden = false;
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4518
|
+
$reportOpen.hidden = true;
|
|
4519
|
+
$reportShare.hidden = true;
|
|
4520
|
+
showSavedPathActions('');
|
|
4521
|
+
$reportOverlay.hidden = true; $reportOverlay.replaceChildren();
|
|
4522
|
+
// #1840: the caption says when the report's approved version accepted open import findings (the
|
|
4523
|
+
// server's sentence). The report body comes from AWARE's report protocol, which appears to have no
|
|
4524
|
+
// field for it (inferred from its parser's messages, not reproduced). When the server could not
|
|
4525
|
+
// read that approval's record, the caption says so instead of reading as a plain approval.
|
|
4526
|
+
$reportSub.textContent = report.scheduledCaption
|
|
4527
|
+
|| `Complete read-only report · ${count} objects · ${properties} properties · approved revision ${String(index.revisionId).slice(0, 12)} · source unchanged.`;
|
|
4528
|
+
if (typeof index.acceptedImportFindingsNote === 'string') $reportSub.textContent += ` ${index.acceptedImportFindingsNote}`;
|
|
4529
|
+
else if (index.approvalDetailsUnavailable === true) $reportSub.textContent += ' Approval details unavailable.';
|
|
4530
|
+
// What the report rests on comes first (a scheduled "Latest approved" run that read an older
|
|
4531
|
+
// approved version says which), never after the counts where it would read as a footnote.
|
|
4532
|
+
const warnings = Array.isArray(index.warnings) ? index.warnings.filter((warning) => typeof warning === 'string' && warning) : [];
|
|
4533
|
+
if (warnings.length) $reportSub.textContent = `${warnings.join(' ')} ${$reportSub.textContent}`;
|
|
4534
|
+
paintReportPageLinks(); // #2539: the Page version this report became, now that it is on screen
|
|
4535
|
+
return true;
|
|
4536
|
+
} catch (error) {
|
|
4537
|
+
if (request !== reportSectionRequest) return false;
|
|
4538
|
+
// #2539: busy is not a failure. Say what it waits for (the server's sentence) and open the report by itself.
|
|
4539
|
+
if (reportIsBusy(error) && Date.now() < waitUntil) {
|
|
4540
|
+
const waiting = mkEl('div', null, String(error.body.error || 'This report is busy. It opens as soon as that finishes.'));
|
|
4541
|
+
waiting.setAttribute('role', 'status');
|
|
4542
|
+
$reportOverlay.replaceChildren(mkEl('div', 'spinner'), waiting);
|
|
4543
|
+
const pause = Math.min(10_000, Math.max(500, Number(error.body.retryAfterMs) || 2_000));
|
|
4544
|
+
await new Promise((resolve) => setTimeout(resolve, pause));
|
|
4545
|
+
if (request !== reportSectionRequest) return false;
|
|
4546
|
+
continue;
|
|
4547
|
+
}
|
|
4548
|
+
clearCompleteReportView();
|
|
4549
|
+
$reportFrame.srcdoc = '';
|
|
4550
|
+
$reportSub.textContent = 'This report section could not be displayed.';
|
|
4551
|
+
const status = Number(error?.status);
|
|
4552
|
+
let remedy = 'Close the viewer and choose View report to retry loading this saved report.';
|
|
4553
|
+
if (status === 401) remedy = 'Sign in again, then close the viewer and choose View report to load this saved report.';
|
|
4554
|
+
else if (status === 403) remedy = 'Report access could not be confirmed. Check your account access and connection, then choose View report again.';
|
|
4555
|
+
else if (status === 404 || status === 410) remedy = 'This report is no longer available. Choose Run workflow to create a fresh report.';
|
|
4556
|
+
else if (reportIsBusy(error)) remedy = 'This report is still busy. Choose Try again to open it, or close the viewer and choose View report later.';
|
|
4557
|
+
else if (status === 409) remedy = 'This saved report cannot be opened right now. If another read is running, wait for it to finish and choose View report again. Otherwise choose an approved model in Inputs and Run workflow to create a fresh report.';
|
|
4558
|
+
else if (status === 429) remedy = 'This report is busy. Wait for the current read to finish, then close the viewer and choose View report again.';
|
|
4559
|
+
else if (status === 413) {
|
|
4560
|
+
remedy = 'This section is too large for the viewer. Download complete report to read the saved report.';
|
|
4561
|
+
currentCompleteReport = report;
|
|
4562
|
+
$reportDownload.hidden = false;
|
|
4563
|
+
} else if (status === 503) remedy = 'Saved reports are being prepared. Wait a moment, then close the viewer and choose View report again.';
|
|
4564
|
+
// Keep diagnostics bounded: transport messages can contain private paths or server details.
|
|
4565
|
+
console.warn('Report section display failed', { status: Number.isFinite(status) ? status : null });
|
|
4566
|
+
$reportOverlay.hidden = false;
|
|
4567
|
+
$reportOverlay.replaceChildren(mkEl('div', null, remedy));
|
|
4568
|
+
if (reportIsBusy(error)) {
|
|
4569
|
+
const again = mkEl('button', 'ghost report-retry', 'Try again');
|
|
4570
|
+
again.type = 'button';
|
|
4571
|
+
again.setAttribute('data-command-id', 'shell.report-busy-retry');
|
|
4572
|
+
again.addEventListener('click', () => { void paintCompleteReport(report, asked); });
|
|
4573
|
+
$reportOverlay.append(again);
|
|
4574
|
+
again.focus?.();
|
|
4575
|
+
}
|
|
4576
|
+
return false;
|
|
4577
|
+
}
|
|
4461
4578
|
}
|
|
4462
4579
|
}
|
|
4463
4580
|
// The share route's user-facing cap (server/index.ts sets a 6 MB body limit; the JSON envelope
|
|
@@ -4480,13 +4597,14 @@
|
|
|
4480
4597
|
// INTERACTIVE 3D doc (viewer-3d) uses the script-enabled frame via a data: URL (opaque
|
|
4481
4598
|
// origin, cannot touch the app page) and keeps a "Loading 3D view…" overlay until the doc
|
|
4482
4599
|
// posts `viewer-ready`. Exactly one frame is shown at a time.
|
|
4483
|
-
function paintReport(html, interactive) {
|
|
4600
|
+
function paintReport(html, interactive, entry = null) {
|
|
4484
4601
|
clearCompleteReportView();
|
|
4485
4602
|
$reportOpen.hidden = false;
|
|
4486
4603
|
lastPaintedHtml = html || '';
|
|
4487
4604
|
lastPaintedInteractive = !!interactive; // drives the share copy: a 3D model is not a "frozen report"
|
|
4488
4605
|
showSavedPathActions(''); // default off; the caller re-shows if this report saved a file
|
|
4489
4606
|
if ($reportPage) $reportPage.hidden = true; // likewise its Page link (paintReportPageLinks, once it is cached)
|
|
4607
|
+
if (!interactive && entry && entry.withFiles) { paintReportWithFiles(html); return; }
|
|
4490
4608
|
if (interactive) {
|
|
4491
4609
|
$reportFrame.hidden = true; $reportFrame.srcdoc = '';
|
|
4492
4610
|
$reportFrame3d.hidden = false;
|
|
@@ -4506,6 +4624,21 @@
|
|
|
4506
4624
|
}
|
|
4507
4625
|
}
|
|
4508
4626
|
|
|
4627
|
+
// #2262 slice 3c: a report that carries files (`report_folder`) refers to them as `assets/…`, which resolve only in its
|
|
4628
|
+
// Page version. The run viewer shows a copy with those references made inert (web/report-files.js: no broken picture,
|
|
4629
|
+
// no failed request) and a note pointing to the Page version, where the files are ("Open in Pages" appears once it is
|
|
4630
|
+
// saved). Open and Share are hidden here: they would hand out this copy without its files — the Page has its own Share.
|
|
4631
|
+
// (A viewer that switches to the saved version itself was split out on the night shift — Fable, review stop signal.)
|
|
4632
|
+
const FILES_NOTE = 'This report has pictures and files that only show in its Page version. Use “Open in Pages” at the top to see it with them.';
|
|
4633
|
+
function paintReportWithFiles(html) {
|
|
4634
|
+
$reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
|
|
4635
|
+
$reportFrame.hidden = false;
|
|
4636
|
+
$reportFrame.srcdoc = window.FlolessReportFiles.neutralize(html, null, FILES_NOTE);
|
|
4637
|
+
$reportOverlay.hidden = true; $reportOverlay.replaceChildren();
|
|
4638
|
+
$reportOpen.hidden = true;
|
|
4639
|
+
$reportShare.hidden = true;
|
|
4640
|
+
}
|
|
4641
|
+
|
|
4509
4642
|
// Reset the viewer to "no report shown": clear BOTH frames + the Open buffer, so a stale
|
|
4510
4643
|
// interactive 3D doc can't linger (its WebGL loop running) behind an overlay, and ↗ Open
|
|
4511
4644
|
// can't reopen a previous app's report. Used by every empty / transition state.
|
|
@@ -4541,7 +4674,7 @@
|
|
|
4541
4674
|
} else {
|
|
4542
4675
|
$reportSub.textContent = `Last report${sfx} — rendered from the run's output, never composed by the UI.`;
|
|
4543
4676
|
}
|
|
4544
|
-
paintReport(cached.html, cached.interactive);
|
|
4677
|
+
paintReport(cached.html, cached.interactive, cached);
|
|
4545
4678
|
showSavedPathActions(cached.savedPath); // re-show Open file / Reveal if this run saved one
|
|
4546
4679
|
} else {
|
|
4547
4680
|
clearReportFrames();
|
|
@@ -5286,33 +5419,34 @@
|
|
|
5286
5419
|
if (res.credentialIssue) { $reportSub.textContent = 'Execution ended. Reconnect the integration to run again.'; surfaceCredentialIssue(res.credentialIssue); return; }
|
|
5287
5420
|
if (res.report && res.report.kind === 'complete-model-properties' && typeof res.report.handle === 'string') {
|
|
5288
5421
|
$reportTitle.textContent = `HTML Viewer · ${app.displayName}`;
|
|
5289
|
-
lastReportByApp.set(app.id, { nodeId, label: inputBadge, ...res.report });
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5422
|
+
lastReportByApp.set(app.id, { nodeId, label: inputBadge, ...res.report, runId: typeof res.runId === 'string' ? res.runId : null });
|
|
5423
|
+
// #2539: the run is over once the server answered. Showing its report may still wait for the workflow's Page to
|
|
5424
|
+
// save its copy, so the run controls are released now (not awaited) and the viewer opens the report by itself.
|
|
5425
|
+
const runApp = app.id;
|
|
5426
|
+
void paintCompleteReport(res.report).then((painted) => {
|
|
5427
|
+
if (!painted || !currentCompleteReport || !$reportOverlay.hidden) return;
|
|
5428
|
+
markFirstRunDone(runApp);
|
|
5429
|
+
$reportModal.dataset.html = '1';
|
|
5430
|
+
appendNarration(`Rendered the complete read-only property report from <strong>${escapeHtml(nodeId)}</strong>.`);
|
|
5431
|
+
});
|
|
5295
5432
|
return;
|
|
5296
5433
|
}
|
|
5297
5434
|
const html = res.report && res.report.html;
|
|
5298
5435
|
const interactive = !!(res.report && res.report.interactive);
|
|
5299
|
-
if (!html) {
|
|
5300
|
-
$reportSub.textContent = 'Execution ended without an HTML report.';
|
|
5301
|
-
$reportOverlay.innerHTML = `<div>Run completed but <code>${escapeHtml(nodeId)}</code> returned no <code>html</code>. Check the Execution tab.</div>`;
|
|
5302
|
-
return;
|
|
5303
|
-
}
|
|
5436
|
+
if (!html) { showNoReport(res, nodeId, app.id); return; }
|
|
5304
5437
|
if (interactive) {
|
|
5305
5438
|
$reportTitle.textContent = `3D Viewer · ${app.displayName}`;
|
|
5306
5439
|
$reportSub.innerHTML = `Live 3D view from <code>${escapeHtml(nodeId)}</code>${inputBadge ? ' · ' + escapeHtml(inputBadge) : ''} — drag to orbit, scroll to zoom, click an element to inspect.`;
|
|
5307
5440
|
}
|
|
5308
|
-
|
|
5441
|
+
const withFiles = !!(res.report && res.report.withFiles);
|
|
5442
|
+
paintReport(html, interactive, { withFiles, runId: typeof res.runId === 'string' ? res.runId : null });
|
|
5309
5443
|
if (!interactive) $reportSub.textContent = 'Report created from the latest workflow run.';
|
|
5310
5444
|
// If a node wrote an output file, the run reports its path — surface the
|
|
5311
5445
|
// ⧉ Open file / ▤ Reveal buttons and cache it so a later double-click restores them (#209).
|
|
5312
5446
|
const savedPath = res && typeof res.savedPath === 'string' ? res.savedPath : '';
|
|
5313
5447
|
showSavedPathActions(savedPath);
|
|
5314
5448
|
markFirstRunDone(app.id); // a real run rendered → this workflow is no longer "new" (app captured pre-await; a mid-run switch must not mark the wrong workflow)
|
|
5315
|
-
lastReportByApp.set(currentId, { nodeId, label: inputBadge, html, interactive, savedPath, runId: typeof res.runId === 'string' ? res.runId : null });
|
|
5449
|
+
lastReportByApp.set(currentId, { nodeId, label: inputBadge, html, interactive, savedPath, withFiles, runId: typeof res.runId === 'string' ? res.runId : null });
|
|
5316
5450
|
paintReportPageLinks();
|
|
5317
5451
|
$reportModal.dataset.html = '1';
|
|
5318
5452
|
appendNarration(`Rendered the ${interactive ? '3D view' : 'report'} from <strong>${escapeHtml(nodeId)}</strong>${inputBadge ? ' (' + escapeHtml(inputBadge) + ')' : ''} — live run against the model.`);
|
|
@@ -5347,6 +5481,7 @@
|
|
|
5347
5481
|
if (clientRunToken) { if (liveOutcome === 'no-answer') settleLiveRunWithoutAnswer(); else finishLiveRun(liveOutcome); }
|
|
5348
5482
|
reportRunning = false;
|
|
5349
5483
|
syncRunControls(); // run ended — hide the header Stop, restore Run from the gate
|
|
5484
|
+
paintReportPageLinks(); // #2539: hidden while the run was in flight; its Page version may already be known
|
|
5350
5485
|
}
|
|
5351
5486
|
}
|
|
5352
5487
|
|
|
@@ -5428,6 +5563,50 @@
|
|
|
5428
5563
|
if (first) first.focus(); else { card.tabIndex = -1; card.focus(); } // #2123: a not-run card may have no button
|
|
5429
5564
|
}
|
|
5430
5565
|
|
|
5566
|
+
// A run that finished without report HTML. #2415: when an AI step in it did not answer (its -ok check stops the run on
|
|
5567
|
+
// purpose), say which step and offer its questions instead of the generic words.
|
|
5568
|
+
function showNoReport(res, nodeId, appId) {
|
|
5569
|
+
const aiStop = globalThis.flolessAgentSteps?.stoppedReportView(res, nodeId);
|
|
5570
|
+
if (aiStop) { showAiStepStopped(aiStop, appId); return; }
|
|
5571
|
+
$reportSub.textContent = 'Execution ended without an HTML report.';
|
|
5572
|
+
$reportOverlay.innerHTML = `<div>Run completed but <code>${escapeHtml(nodeId)}</code> returned no <code>html</code>. Check the Execution tab.</div>`;
|
|
5573
|
+
}
|
|
5574
|
+
|
|
5575
|
+
// #2415: the run stopped before the report because an AI step did not answer. Not a fault, so no Report this problem:
|
|
5576
|
+
// the way on is the step's questions, in the canvas's Last run panel. textContent only — step names come from the run.
|
|
5577
|
+
function showAiStepStopped(view, appId) {
|
|
5578
|
+
clearReportFrames();
|
|
5579
|
+
$reportShare.hidden = true;
|
|
5580
|
+
$reportOverlay.hidden = false;
|
|
5581
|
+
$reportOverlay.replaceChildren();
|
|
5582
|
+
$reportSub.textContent = view.sub;
|
|
5583
|
+
const card = mkEl('div', 'cred-fail-card run-fail-card ai-stop-card');
|
|
5584
|
+
card.setAttribute('role', 'status');
|
|
5585
|
+
const status = mkEl('div', 'cred-fail-status');
|
|
5586
|
+
const icon = mkEl('span', 'cred-fail-icon', typeof floAvatar === 'function' ? '' : '△');
|
|
5587
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
5588
|
+
if (typeof floAvatar === 'function') { icon.classList.add('run-fail-flo'); floAvatar(icon, { size: 28, mood: 'warning' }); }
|
|
5589
|
+
status.append(icon, document.createTextNode(view.status));
|
|
5590
|
+
const actions = mkEl('div', 'cred-fail-actions');
|
|
5591
|
+
const open = mkEl('button', 'cred-open-integrations ai-stop-open', view.button);
|
|
5592
|
+
open.type = 'button';
|
|
5593
|
+
open.dataset.commandId = view.commandId;
|
|
5594
|
+
open.onclick = async () => {
|
|
5595
|
+
// The viewer closes only once Last run shows THIS run; otherwise it stays open, with focus on the button, and says why.
|
|
5596
|
+
let shown = false;
|
|
5597
|
+
try { shown = await globalThis.flolessAgentSteps?.openQuestions(appId, view.runId, () => hideModal($reportModal)) === true; } catch { shown = false; }
|
|
5598
|
+
if (shown) return;
|
|
5599
|
+
showToast(view.listed
|
|
5600
|
+
? 'FloLess couldn’t show this run’s questions yet. Close the viewer, then open Last run above the canvas.'
|
|
5601
|
+
: 'FloLess couldn’t show this run in Last run yet. Close the viewer, then open Last run above the canvas.', 'warn');
|
|
5602
|
+
open.focus();
|
|
5603
|
+
};
|
|
5604
|
+
actions.append(open);
|
|
5605
|
+
card.append(status, mkEl('div', 'cred-fail-headline', view.headline), mkEl('div', 'cred-fail-body', view.body), actions);
|
|
5606
|
+
$reportOverlay.append(card);
|
|
5607
|
+
open.focus();
|
|
5608
|
+
}
|
|
5609
|
+
|
|
5431
5610
|
const CRED_BODY_IDLE = 'Sign in again and then run the workflow — it takes about 30 seconds.';
|
|
5432
5611
|
|
|
5433
5612
|
function showCredentialReconnect(cred) {
|
|
@@ -6409,6 +6588,7 @@
|
|
|
6409
6588
|
|
|
6410
6589
|
async function closeReportViewer() {
|
|
6411
6590
|
hideModal($reportModal);
|
|
6591
|
+
reportSectionRequest += 1; // #2539: a section still waiting for a busy report stops asking once the viewer closes
|
|
6412
6592
|
const routineId = viewingScheduledReportRoutine;
|
|
6413
6593
|
viewingScheduledReportRoutine = null;
|
|
6414
6594
|
if (!routineId) return;
|
|
@@ -6442,7 +6622,11 @@
|
|
|
6442
6622
|
window.addEventListener('message', (e) => {
|
|
6443
6623
|
if ($reportFrame3d.hidden || e.source !== $reportFrame3d.contentWindow) return;
|
|
6444
6624
|
const t = e.data && e.data.type;
|
|
6445
|
-
if (t === 'viewer-ready') {
|
|
6625
|
+
if (t === 'viewer-ready') {
|
|
6626
|
+
$reportOverlay.hidden = true; $reportOverlay.replaceChildren();
|
|
6627
|
+
// #2262 slice 3c: a 3D view is a Page version too; its "Open in Pages" link waits for the view to be ready.
|
|
6628
|
+
paintReportPageLinks();
|
|
6629
|
+
}
|
|
6446
6630
|
else if (t === 'viewer-error') {
|
|
6447
6631
|
$reportOverlay.hidden = false; $reportOverlay.replaceChildren();
|
|
6448
6632
|
$reportOverlay.append(mkEl('div', null, '3D view failed to load — check your connection, then click ▶ Run workflow to try again.'));
|
|
@@ -6472,6 +6656,7 @@
|
|
|
6472
6656
|
$reportLast.onclick = () => { if (currentCompleteReport) void paintCompleteReport(currentCompleteReport, currentCompleteReport.chunkCount - 1); };
|
|
6473
6657
|
$reportGoObject.onclick = async () => {
|
|
6474
6658
|
if (!currentCompleteReport) return;
|
|
6659
|
+
const lookup = ++reportObjectLookup;
|
|
6475
6660
|
const raw = $reportObjectNumber.value.trim();
|
|
6476
6661
|
const number = Number(raw);
|
|
6477
6662
|
if (!/^[1-9][0-9]*$/.test(raw) || !Number.isSafeInteger(number) || number > currentCompleteReport.objectCount) {
|
|
@@ -6481,11 +6666,36 @@
|
|
|
6481
6666
|
return;
|
|
6482
6667
|
}
|
|
6483
6668
|
$reportObjectError.hidden = true;
|
|
6669
|
+
const report = currentCompleteReport;
|
|
6670
|
+
const request = reportSectionRequest;
|
|
6671
|
+
const waitUntil = Date.now() + 5 * 60_000;
|
|
6672
|
+
// Stale once the viewer closed or moved on, or a newer Go took over. The message belongs to the newest lookup, so a
|
|
6673
|
+
// stale one clears only its own text, and only when no newer lookup has written there.
|
|
6674
|
+
const stale = () => lookup !== reportObjectLookup || request !== reportSectionRequest || currentCompleteReport !== report;
|
|
6675
|
+
const leave = () => { if (lookup === reportObjectLookup) $reportObjectError.hidden = true; };
|
|
6484
6676
|
try {
|
|
6485
|
-
|
|
6486
|
-
|
|
6677
|
+
let located;
|
|
6678
|
+
for (;;) {
|
|
6679
|
+
try { located = await api(`/api/model-reports/${encodeURIComponent(report.handle)}/object/${number - 1}`); break; }
|
|
6680
|
+
catch (error) {
|
|
6681
|
+
// #2539: a busy report is waited for here too, saying why, and the object opens by itself.
|
|
6682
|
+
if (error?.body?.code !== 'report-busy' || Date.now() >= waitUntil) throw error;
|
|
6683
|
+
if (stale()) { leave(); return; } // a busy answer for a lookup already replaced writes nothing
|
|
6684
|
+
$reportObjectError.textContent = String(error.body.error || 'This report is busy. It opens as soon as that finishes.');
|
|
6685
|
+
$reportObjectError.hidden = false;
|
|
6686
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(10_000, Math.max(500, Number(error.body.retryAfterMs) || 2_000))));
|
|
6687
|
+
if (stale()) { leave(); return; }
|
|
6688
|
+
}
|
|
6689
|
+
}
|
|
6690
|
+
// The viewer may have closed or moved on while the lookup was answered: then it opens nothing, and drops the wait's text.
|
|
6691
|
+
if (stale()) { leave(); return; }
|
|
6692
|
+
$reportObjectError.hidden = true;
|
|
6693
|
+
await paintCompleteReport(report, located.chunkOrdinal);
|
|
6487
6694
|
} catch (error) {
|
|
6488
|
-
|
|
6695
|
+
if (stale()) { leave(); return; }
|
|
6696
|
+
$reportObjectError.textContent = error?.body?.code === 'report-busy'
|
|
6697
|
+
? 'This report is still busy. Choose Go again to open that object.'
|
|
6698
|
+
: error?.message || 'Could not find that object. Try again.';
|
|
6489
6699
|
$reportObjectError.hidden = false;
|
|
6490
6700
|
}
|
|
6491
6701
|
};
|
|
@@ -6495,7 +6705,16 @@
|
|
|
6495
6705
|
$reportFrame.addEventListener('load', () => {
|
|
6496
6706
|
if (!currentCompleteReport || !$reportFrame.getAttribute('src')?.startsWith('/api/model-reports/')) return;
|
|
6497
6707
|
try {
|
|
6498
|
-
|
|
6708
|
+
const shown = $reportFrame.contentDocument;
|
|
6709
|
+
if (shown?.contentType === 'text/html') return;
|
|
6710
|
+
// #2539: the report became busy between the section check and the frame's own request. Wait for it like any
|
|
6711
|
+
// busy read instead of calling it changed access.
|
|
6712
|
+
if (shown?.contentType === 'application/json' && JSON.parse(shown.body?.textContent || 'null')?.code === 'report-busy') {
|
|
6713
|
+
// Only for the paint still current (closing the viewer or moving on ends it), and within its first deadline.
|
|
6714
|
+
if ($reportFrame.dataset.request !== String(reportSectionRequest)) return;
|
|
6715
|
+
void paintCompleteReport(currentCompleteReport, currentReportSection, Number($reportFrame.dataset.busyUntil) || null);
|
|
6716
|
+
return;
|
|
6717
|
+
}
|
|
6499
6718
|
} catch { /* an inaccessible document is not an authenticated report */ }
|
|
6500
6719
|
clearCompleteReportView();
|
|
6501
6720
|
$reportFrame.removeAttribute('src');
|
|
@@ -6512,7 +6731,10 @@
|
|
|
6512
6731
|
link.download = 'complete-model-properties.html';
|
|
6513
6732
|
document.body.append(link); link.click(); link.remove();
|
|
6514
6733
|
} catch (error) {
|
|
6515
|
-
|
|
6734
|
+
// #2539: busy is not a failure of access; the report is there, it is just being read.
|
|
6735
|
+
showToast(error?.body?.code === 'report-busy'
|
|
6736
|
+
? 'This report is busy, so it can’t be downloaded yet. Choose Download complete report again in a moment.'
|
|
6737
|
+
: error?.message || 'Report access could not be confirmed. Try again.', 'warn');
|
|
6516
6738
|
}
|
|
6517
6739
|
};
|
|
6518
6740
|
|
|
@@ -6607,12 +6829,93 @@
|
|
|
6607
6829
|
};
|
|
6608
6830
|
$promptSel.onchange = () => { showWorkflowsLanding(false); loadApp($promptSel.value).catch(reportErr); };
|
|
6609
6831
|
|
|
6610
|
-
|
|
6832
|
+
/**
|
|
6833
|
+
* #2314: two steps share one name, so AWARE cannot compile the workflow. Ask which to rename; after a rename, compile again (the
|
|
6834
|
+
* workflow changed, so it is approved again, and an AI step's confirmation is asked of the person again). Cancel keeps it as is.
|
|
6835
|
+
*/
|
|
6836
|
+
async function renameStepThenCompile(id, ask) {
|
|
6837
|
+
const outcome = globalThis.flolessStepRename ? await globalThis.flolessStepRename.open(ask) : { renamed: false };
|
|
6838
|
+
if (!outcome.renamed) {
|
|
6839
|
+
// Keep the reason in view: the person cancelled the rename, so the workflow still cannot compile, and here is why.
|
|
6840
|
+
showToast(`${ask && ask.sentence ? `${ask.sentence} ` : ''}Nothing was renamed, so the workflow is not compiled yet.`, 'warn');
|
|
6841
|
+
return;
|
|
6842
|
+
}
|
|
6843
|
+
const r = outcome.result || {};
|
|
6844
|
+
if (r.warning) {
|
|
6845
|
+
// The rename did not land exactly as previewed (or could not be checked): the person looks before anything compiles.
|
|
6846
|
+
showToast(r.warning, 'warn');
|
|
6847
|
+
appendNarration(`Renamed the step <strong>${escapeHtml(r.renamed?.from || '')}</strong> to <strong>${escapeHtml(r.renamed?.to || '')}</strong>. ${escapeHtml(r.warning)}`);
|
|
6848
|
+
if (currentId === id) { try { await loadApp(id); } catch (e) { reportErr(e); } }
|
|
6849
|
+
return;
|
|
6850
|
+
}
|
|
6851
|
+
appendNarration(`Renamed the step <strong>${escapeHtml(r.renamed?.from || '')}</strong> to <strong>${escapeHtml(r.renamed?.to || '')}</strong>. The workflow changed, so it is compiled and approved again.`);
|
|
6852
|
+
if (currentId !== id) return;
|
|
6853
|
+
try { await loadApp(id); } catch (e) { reportErr(e); return; }
|
|
6854
|
+
if (currentId === id) await compileCurrentWorkflow();
|
|
6855
|
+
}
|
|
6856
|
+
|
|
6857
|
+
/**
|
|
6858
|
+
* #2474: a workflow you own runs from an immutable published copy, so its Compile publishes a new version from the
|
|
6859
|
+
* workflow's own file, exactly as the draft view does (`/api/compile` on the copy is refused). Consent works as it does
|
|
6860
|
+
* there: building is allowed, and the new version's AI step is confirmed by the person before it runs (Run asks). The
|
|
6861
|
+
* confirmation dialog is not shown first, because it could only show the old copy, not the bytes being published.
|
|
6862
|
+
*/
|
|
6863
|
+
async function publishOwnedFromHeader(id, workflowId) {
|
|
6864
|
+
const name = workflowLabelOf(id);
|
|
6865
|
+
$compileBtn.disabled = true;
|
|
6866
|
+
const prev = $compileBtn.textContent;
|
|
6867
|
+
$compileBtn.textContent = '⎙ Compiling…';
|
|
6868
|
+
const restore = () => { $compileBtn.textContent = prev; $compileBtn.disabled = false; };
|
|
6869
|
+
let newId;
|
|
6870
|
+
try {
|
|
6871
|
+
const res = await api(`/api/workflows/owned/${encodeURIComponent(workflowId)}/publish`, { method: 'POST' });
|
|
6872
|
+
newId = res?.workflow?.activePublication?.runtimeAppId || null;
|
|
6873
|
+
} catch (e) {
|
|
6874
|
+
restore();
|
|
6875
|
+
const ask = globalThis.flolessStepRename ? globalThis.flolessStepRename.askOf(e) : null;
|
|
6876
|
+
if (ask) { await renameStepThenCompile(id, ask); return; }
|
|
6877
|
+
// The publish route's own refusal is a sentence for the person; anything else is reported as usual.
|
|
6878
|
+
if (e?.body?.code === 'workflow-compile-failed' && typeof e.body.error === 'string') { showToast(e.body.error, 'warn'); return; }
|
|
6879
|
+
reportErr(e);
|
|
6880
|
+
return;
|
|
6881
|
+
}
|
|
6882
|
+
const notOpened = `${name} is compiled. FloLess couldn’t open the new version — open it from the Workflows page.`;
|
|
6883
|
+
// Only the publish answer names the new version: never fall back to the old copy, which would show the old steps as current.
|
|
6884
|
+
if (!newId) { restore(); showToast(notOpened, 'warn'); return; }
|
|
6885
|
+
// Refresh the lists without letting the refresh pick a workflow to open; the new version is opened next, on purpose.
|
|
6886
|
+
const owner = ownedWorkflowOf(id);
|
|
6887
|
+
try { await loadApps({ preserveSelection: true }); } catch (e) { console.warn('[compile] the workflow list could not be refreshed', e); }
|
|
6888
|
+
// The new version belongs to the same workflow. Even when the refresh failed, it is known as owned, so its next Compile
|
|
6889
|
+
// publishes again instead of reaching the refused copy.
|
|
6890
|
+
if (owner && !ownedWorkflowOf(newId)) workflowOwners.set(newId, owner);
|
|
6891
|
+
// The person opened something else meanwhile: its own load repainted the button, so it is left as that workflow shows it.
|
|
6892
|
+
if (currentId !== id) { showToast(`${name} is compiled.`, 'ok'); return; }
|
|
6893
|
+
try { await loadApp(newId); } catch (e) { console.warn('[compile] the new version could not be opened', e); restore(); showToast(notOpened, 'warn'); return; }
|
|
6894
|
+
if (currentId !== newId) { showToast(`${name} is compiled.`, 'ok'); return; } // a newer choice won while it was opening
|
|
6895
|
+
const app = apps.get(newId);
|
|
6896
|
+
const consent = globalThis.flolessAgentSteps?.consentStatus ? await globalThis.flolessAgentSteps.consentStatus(newId) : null;
|
|
6897
|
+
const unconfirmed = consent && (consent.state === 'needed' || consent.state === 'changed');
|
|
6898
|
+
if (unconfirmed) {
|
|
6899
|
+
appendNarration('Workflow compiled. It has an AI step whose answer may differ each run, and this version is not confirmed yet: FloLess asks you to confirm it before it runs.');
|
|
6900
|
+
showToast('Workflow compiled. Confirm its AI step before it runs.', 'ok');
|
|
6901
|
+
} else {
|
|
6902
|
+
appendNarration(app?.runnable
|
|
6903
|
+
? 'Workflow compiled. Review any notices above the canvas before running.'
|
|
6904
|
+
: `Compiled, but ${app?.notes?.length ?? 0} notice(s) remain — review them above the canvas.`);
|
|
6905
|
+
showToast('Workflow compiled', 'ok');
|
|
6906
|
+
}
|
|
6907
|
+
maybeAskPolicyAfterApproval();
|
|
6908
|
+
}
|
|
6909
|
+
|
|
6910
|
+
async function compileCurrentWorkflow() {
|
|
6611
6911
|
if (!currentId || $compileBtn.disabled || $compileBtn.hidden) return; // hidden = suppressed for a maintained drift
|
|
6612
6912
|
const id = currentId;
|
|
6913
|
+
const ownedId = ownedWorkflowOf(id)?.ownedWorkflow?.workflowId || null;
|
|
6914
|
+
if (ownedId) { await publishOwnedFromHeader(id, ownedId); return; }
|
|
6613
6915
|
// #2241 S4: a workflow with an AI step nobody has confirmed (or that changed) is approved from the confirmation dialog, which
|
|
6614
6916
|
// records the tick and approves the exact bytes it showed. 'proceed' = nothing to ask, the normal compile goes on.
|
|
6615
6917
|
const consent = globalThis.flolessAgentSteps ? await globalThis.flolessAgentSteps.confirmBeforeApprove(apps.get(id) || { id }) : 'proceed';
|
|
6918
|
+
if (consent === 'rename-step') { await renameStepThenCompile(id, globalThis.flolessAgentSteps.takeRenameAsk()); return; }
|
|
6616
6919
|
if (consent === 'cancel' || currentId !== id) return;
|
|
6617
6920
|
$compileBtn.disabled = true;
|
|
6618
6921
|
const prev = $compileBtn.textContent;
|
|
@@ -6630,9 +6933,12 @@
|
|
|
6630
6933
|
} catch (e) {
|
|
6631
6934
|
$compileBtn.textContent = prev;
|
|
6632
6935
|
$compileBtn.disabled = false;
|
|
6936
|
+
const ask = globalThis.flolessStepRename ? globalThis.flolessStepRename.askOf(e) : null;
|
|
6937
|
+
if (ask) { await renameStepThenCompile(id, ask); return; }
|
|
6633
6938
|
reportErr(e);
|
|
6634
6939
|
}
|
|
6635
|
-
}
|
|
6940
|
+
}
|
|
6941
|
+
$compileBtn.onclick = () => compileCurrentWorkflow();
|
|
6636
6942
|
|
|
6637
6943
|
// ── Bake into agent ──────────────────────────────────────────────────────────
|
|
6638
6944
|
// Open a preview/confirm modal (agent name + the inputs it will expose, mirrored
|
|
@@ -7213,14 +7519,8 @@
|
|
|
7213
7519
|
|
|
7214
7520
|
function graftTeklaReadErrorMessage(error) {
|
|
7215
7521
|
const body = error?.body;
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
if (body?.reason === 'no-subscription') return 'This account does not have a FloLess subscription. Sign in with a subscribed account or subscribe, then try again.';
|
|
7219
|
-
if (body?.reason === 'session-expired') return 'Your FloLess sign-in has expired. Sign in again, then try again.';
|
|
7220
|
-
if (body?.reason === 'signed-out') return 'You are signed out of FloLess. Sign in again, then try again.';
|
|
7221
|
-
if (body?.reason === 'seat-taken') return 'Your FloLess session has ended. Sign in again, then try again.';
|
|
7222
|
-
return 'Sign in to FloLess to check your account access, then try again.';
|
|
7223
|
-
}
|
|
7522
|
+
const access = accountAccessText(error);
|
|
7523
|
+
if (access) return access;
|
|
7224
7524
|
if (body?.bootstrap === 'failed') {
|
|
7225
7525
|
return 'FloLess could not prepare its runtime. Choose Try again on the setup card, then verify the model read again.';
|
|
7226
7526
|
}
|
|
@@ -7813,7 +8113,10 @@
|
|
|
7813
8113
|
}
|
|
7814
8114
|
showToast(body && body.code === 'exists'
|
|
7815
8115
|
? 'A workflow with that name already exists. Choose a different name, then try again.'
|
|
7816
|
-
: '
|
|
8116
|
+
// #2470: the server's sentence names the General project id and a name to use instead.
|
|
8117
|
+
: body && body.code === 'reserved-id' && typeof body.error === 'string' && body.error
|
|
8118
|
+
? `${body.error} Change the app: line in the file, then import it again.`
|
|
8119
|
+
: 'We couldn’t import that workflow because FloLess could not read it. Check the file, then try again.', 'err');
|
|
7817
8120
|
}
|
|
7818
8121
|
} finally {
|
|
7819
8122
|
_importing = false; // every path, including an unreadable file and the dialog's early return
|
|
@@ -8074,6 +8377,7 @@
|
|
|
8074
8377
|
const $body = $notesPopover.querySelector('.relnotes-body');
|
|
8075
8378
|
let notes = null;
|
|
8076
8379
|
try {
|
|
8380
|
+
await globalThis.flolessStartupAdmission?.admit('/api/release-notes');
|
|
8077
8381
|
const r = await fetch('/api/release-notes?component=' + encodeURIComponent(component) + '&version=' + encodeURIComponent(version));
|
|
8078
8382
|
notes = await r.json();
|
|
8079
8383
|
} catch { notes = null; }
|
|
@@ -8179,6 +8483,7 @@
|
|
|
8179
8483
|
resetNotesAffordance(el);
|
|
8180
8484
|
let notes = null;
|
|
8181
8485
|
try {
|
|
8486
|
+
await globalThis.flolessStartupAdmission?.admit('/api/release-notes');
|
|
8182
8487
|
const r = await fetch('/api/release-notes?component=' + encodeURIComponent(component) + '&version=' + encodeURIComponent(version));
|
|
8183
8488
|
notes = await r.json();
|
|
8184
8489
|
} catch { notes = null; }
|
|
@@ -8286,6 +8591,7 @@
|
|
|
8286
8591
|
async function refreshUpdate() {
|
|
8287
8592
|
if (!$appUpdate) return;
|
|
8288
8593
|
try {
|
|
8594
|
+
await globalThis.flolessStartupAdmission?.admit('/api/update');
|
|
8289
8595
|
const r = await fetch('/api/update');
|
|
8290
8596
|
const d = await r.json();
|
|
8291
8597
|
if (r.ok && d.supported && d.updateAvailable && d.targetVersion) {
|
|
@@ -8350,6 +8656,7 @@
|
|
|
8350
8656
|
}
|
|
8351
8657
|
async function refreshWorkflowUpdates() {
|
|
8352
8658
|
try {
|
|
8659
|
+
await globalThis.flolessStartupAdmission?.admit('/api/workflows/updates');
|
|
8353
8660
|
const r = await fetch('/api/workflows/updates');
|
|
8354
8661
|
const d = await r.json();
|
|
8355
8662
|
_wfUpdates = (r.ok && d.ok && Array.isArray(d.updates)) ? d.updates : [];
|
|
@@ -8576,6 +8883,7 @@
|
|
|
8576
8883
|
if (!$awareUpdate) return;
|
|
8577
8884
|
if (awareJobOwnsPill()) return;
|
|
8578
8885
|
try {
|
|
8886
|
+
await globalThis.flolessStartupAdmission?.admit('/api/aware/update');
|
|
8579
8887
|
const r = await fetch('/api/aware/update');
|
|
8580
8888
|
const d = await r.json();
|
|
8581
8889
|
if (awareJobOwnsPill()) return; // the job resolved while this request was in flight
|
|
@@ -9282,6 +9590,7 @@
|
|
|
9282
9590
|
(async () => {
|
|
9283
9591
|
let notes = null;
|
|
9284
9592
|
try {
|
|
9593
|
+
await globalThis.flolessStartupAdmission?.admit('/api/release-notes');
|
|
9285
9594
|
const r = await fetch('/api/release-notes?component=app&version=' + encodeURIComponent(pending));
|
|
9286
9595
|
notes = await r.json();
|
|
9287
9596
|
} catch { notes = null; }
|
|
@@ -9473,6 +9782,8 @@
|
|
|
9473
9782
|
// #2241 S5: a confirmation step starting means a change may soon be waiting for the person. (The last-run panel is refreshed when a run
|
|
9474
9783
|
// ends, never cleared here: the trace is replayed after a run, and a clear would discard the refresh already in flight.)
|
|
9475
9784
|
globalThis.flolessAgentSteps?.noteTrace(ev);
|
|
9785
|
+
if (ev.kind === 'run-start') traceRunId = typeof ev.run_id === 'string' ? ev.run_id : null;
|
|
9786
|
+
let usePill = null;
|
|
9476
9787
|
switch (ev.kind) {
|
|
9477
9788
|
case 'run-start': msg = `run start · ${escapeHtml(ev.app || '')} (${escapeHtml(ev.instance || 'default')})${runStartApprovalNote(ev)}`; break;
|
|
9478
9789
|
case 'node-start': lvl = 'event'; msg = `node ${node} · ${agent}${cmd}`; break;
|
|
@@ -9480,12 +9791,24 @@
|
|
|
9480
9791
|
case 'node-output': case 'output': case 'write': lvl = 'ok'; msg = `${escapeHtml(ev.kind)} ${node}`.trim();
|
|
9481
9792
|
// #2241 S5: AWARE marks an Agent step's output; the trace says so wherever it shows the output.
|
|
9482
9793
|
if (ev.nondeterministic === true && globalThis.flolessAgentSteps) msg += ` ${globalThis.flolessAgentSteps.aiPillHtml()}`;
|
|
9794
|
+
// #2374: an output FloLess found built on (or decided by) an Agent step's answer is labelled too, in quieter words.
|
|
9795
|
+
else if (ev.node) usePill = { node: ev.node, runId: typeof ev.run_id === 'string' ? ev.run_id : traceRunId };
|
|
9483
9796
|
break;
|
|
9484
9797
|
case 'run-end': lvl = ev.status === 'ok' ? 'ok' : 'err'; msg = `run ${escapeHtml(ev.status || 'ended')}`; break;
|
|
9485
9798
|
default: msg = `${escapeHtml(ev.kind)} ${node}`.trim();
|
|
9486
9799
|
}
|
|
9487
9800
|
// `node` (the raw node id) feeds the Execution tab's node-filter chips.
|
|
9488
|
-
|
|
9801
|
+
const row = { kind: ev.kind, ts: fmtTs(ev.ts), lvl, msg, node: ev.node || '' };
|
|
9802
|
+
// #2374: the label is looked up when the row is drawn, so it appears once that run's record has arrived (and only from it).
|
|
9803
|
+
if (usePill) {
|
|
9804
|
+
let text = msg;
|
|
9805
|
+
Object.defineProperty(row, 'msg', {
|
|
9806
|
+
enumerable: true,
|
|
9807
|
+
get() { const pill = globalThis.flolessAgentSteps?.usePillHtml?.(usePill.node, usePill.runId) || ''; return pill ? `${text} ${pill}` : text; },
|
|
9808
|
+
set(value) { text = value; },
|
|
9809
|
+
});
|
|
9810
|
+
}
|
|
9811
|
+
liveTrace.push(row);
|
|
9489
9812
|
|
|
9490
9813
|
// Paint the node's status on the canvas as the trace streams in. Once the
|
|
9491
9814
|
// user hits Stop, leave the canvas alone — late SSE events (the fs-watcher
|
|
@@ -9613,6 +9936,9 @@
|
|
|
9613
9936
|
// idea whether Node.js is missing. Telling someone to install what they already
|
|
9614
9937
|
// have is the exact bug this reason exists to prevent.
|
|
9615
9938
|
return "Couldn't check whether Node.js is installed — the check didn't finish, which usually means the machine was busy. Nothing is necessarily missing; try again.";
|
|
9939
|
+
case 'aware-version-unreadable':
|
|
9940
|
+
// The version check did not answer (usually a busy machine); AWARE is not necessarily old.
|
|
9941
|
+
return "Couldn't check the installed AWARE just now — it didn't answer, which usually means the machine was busy. Nothing is necessarily wrong; try again.";
|
|
9616
9942
|
case 'aware-version-required':
|
|
9617
9943
|
return 'This FloLess release needs AWARE 0.157.0 or newer. Update AWARE, then try again.';
|
|
9618
9944
|
case 'offline':
|
|
@@ -10244,10 +10570,9 @@
|
|
|
10244
10570
|
const healthTick = async () => {
|
|
10245
10571
|
let ok = false;
|
|
10246
10572
|
try {
|
|
10247
|
-
const
|
|
10248
|
-
ok =
|
|
10573
|
+
const h = await readHealth();
|
|
10574
|
+
ok = true;
|
|
10249
10575
|
if (ok) {
|
|
10250
|
-
const h = await r.json();
|
|
10251
10576
|
// Stamp the build + AWARE runtime versions into the footer once (so a
|
|
10252
10577
|
// stale install or AWARE mismatch is self-diagnosable). appVersion is
|
|
10253
10578
|
// the real sq.version on an install (package.json only from source);
|
|
@@ -10370,12 +10695,44 @@
|
|
|
10370
10695
|
const es = new EventSource('/api/events');
|
|
10371
10696
|
let reloadTimer = null;
|
|
10372
10697
|
let everOpened = false;
|
|
10698
|
+
let rootDisconnected = false;
|
|
10699
|
+
let connectionGeneration = 0;
|
|
10700
|
+
let pendingCatchup = null;
|
|
10701
|
+
function drainPendingCatchup() {
|
|
10702
|
+
const generation = pendingCatchup;
|
|
10703
|
+
const roots = window.flolessWorkspaceRoot;
|
|
10704
|
+
if (generation === null || generation !== connectionGeneration || !roots?.isCurrent(roots.current())) return;
|
|
10705
|
+
// Clear before dispatch: root publication and its GET continuation may both arrive here.
|
|
10706
|
+
pendingCatchup = null;
|
|
10707
|
+
window.dispatchEvent(new CustomEvent('floless:apps-changed', { detail: {} }));
|
|
10708
|
+
window.dispatchEvent(new CustomEvent('floless:projects-changed', { detail: {} }));
|
|
10709
|
+
window.dispatchEvent(new CustomEvent('floless:action-proposal', { detail: { resync: true } }));
|
|
10710
|
+
loadRequests();
|
|
10711
|
+
const workflowId = currentId;
|
|
10712
|
+
if (workflowId) refreshCurrentWorkflowAvailability().catch(error => {
|
|
10713
|
+
if (generation === connectionGeneration) reportBackgroundAvailabilityErr(error);
|
|
10714
|
+
});
|
|
10715
|
+
void refreshSelectedCompleteReportDiscovery(workflowId);
|
|
10716
|
+
void resyncLiveRun();
|
|
10717
|
+
if (workflowId) void refreshWorkflowPage(workflowId);
|
|
10718
|
+
}
|
|
10719
|
+
// One unfinished reconnect may resume after an existing dialog refresh or root selection.
|
|
10720
|
+
window.addEventListener('floless:workspace-root-state', drainPendingCatchup);
|
|
10373
10721
|
es.onopen = () => {
|
|
10722
|
+
const reconnect = everOpened || rootDisconnected;
|
|
10723
|
+
everOpened = true;
|
|
10724
|
+
rootDisconnected = false;
|
|
10725
|
+
const generation = ++connectionGeneration;
|
|
10726
|
+
pendingCatchup = reconnect ? generation : null;
|
|
10727
|
+
if (reconnect) {
|
|
10728
|
+
window.flolessWorkspaceRoot.invalidateConnection();
|
|
10729
|
+
globalThis.flolessStartupAdmission?.invalidate();
|
|
10730
|
+
}
|
|
10374
10731
|
setServerStatus(true);
|
|
10375
10732
|
// Core provisioning may have finished after the page read /api/apps but before this
|
|
10376
10733
|
// at-most-once stream connected. Re-read the catalogue on every open, including the
|
|
10377
10734
|
// first one; Workspaces defers its repaint while a dialog is active.
|
|
10378
|
-
window.dispatchEvent(new CustomEvent('floless:apps-changed', { detail: {} }));
|
|
10735
|
+
if (!reconnect) window.dispatchEvent(new CustomEvent('floless:apps-changed', { detail: {} }));
|
|
10379
10736
|
// A RECONNECT MEANS WE MISSED WHATEVER HAPPENED WHILE WE WERE GONE — and this catches up the
|
|
10380
10737
|
// PROJECT half of that, not every arm below (workflow imports, contract writes and the rest
|
|
10381
10738
|
// still heal on their next event or a reload). These events are
|
|
@@ -10386,25 +10743,21 @@
|
|
|
10386
10743
|
// reconnect only (never the first connect, which has nothing to catch up on) and carry NO
|
|
10387
10744
|
// payload: workspaces.js answers an empty event by re-reading the live set, which is exactly
|
|
10388
10745
|
// the catch-up question. (Found by review.)
|
|
10389
|
-
if (
|
|
10390
|
-
|
|
10391
|
-
//
|
|
10392
|
-
window.
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
if (currentId) refreshCurrentWorkflowAvailability().catch(reportErr);
|
|
10746
|
+
if (reconnect) {
|
|
10747
|
+
// The catalogue event also reads projects. None of this catch-up can use a cached root
|
|
10748
|
+
// from the previous server. A later accepted dialog observation may finish this work too.
|
|
10749
|
+
window.flolessWorkspaceRoot.refresh({ throwOnError: true,
|
|
10750
|
+
isCurrent: () => generation === connectionGeneration,
|
|
10751
|
+
}).then(drainPendingCatchup).catch(() => {
|
|
10752
|
+
if (generation === connectionGeneration && pendingCatchup === generation) showToast('FloLess could not check the current Workspace directory. Open Workspace directory to try again.', 'err');
|
|
10753
|
+
});
|
|
10754
|
+
return;
|
|
10399
10755
|
}
|
|
10400
10756
|
// Scheduled reports may finish with every browser closed; refresh their authorized
|
|
10401
10757
|
// pointers on both first connection and reconnect, never from SSE payload data.
|
|
10402
10758
|
void refreshSelectedCompleteReportDiscovery(currentId);
|
|
10403
10759
|
// #2228: progress events are at-most-once too — a reload or a reconnect asks where this tab's run is.
|
|
10404
10760
|
void resyncLiveRun();
|
|
10405
|
-
// #2262 slice 3a: a capture that landed while we were gone is read again, for the workflow on screen.
|
|
10406
|
-
if (everOpened && currentId) void refreshWorkflowPage(currentId);
|
|
10407
|
-
everOpened = true;
|
|
10408
10761
|
};
|
|
10409
10762
|
es.onmessage = (e) => {
|
|
10410
10763
|
let m;
|
|
@@ -10467,7 +10820,11 @@
|
|
|
10467
10820
|
// `clearExportReceiptsForApp` repaints via markSpecialNodes(), so the stale map was actively
|
|
10468
10821
|
// RE-APPLIED rather than merely left behind. Nothing self-healed until the user switched
|
|
10469
10822
|
// workflows. Re-read the payload rather than guess at the new state.
|
|
10470
|
-
if (m.appId === currentId) refreshCurrentWorkflowAvailability().catch(
|
|
10823
|
+
if (m.appId === currentId) refreshCurrentWorkflowAvailability().catch(reportBackgroundAvailabilityErr);
|
|
10824
|
+
} else if (m.type === 'contract-changed' && typeof m.appId === 'string' && typeof m.project === 'string') {
|
|
10825
|
+
// #2482: a PROJECT's contract changed (a checklist draft, a reference added from AI Chat). workspaces.js relays
|
|
10826
|
+
// it to that project's open editor frame, which has no event stream of its own.
|
|
10827
|
+
window.dispatchEvent(new CustomEvent('floless:contract-changed', { detail: m }));
|
|
10471
10828
|
} else if (m.type === 'projects-changed') {
|
|
10472
10829
|
// Relayed as a DOM event for the same reason apps-changed is (see that arm below):
|
|
10473
10830
|
// workspaces.js owns the project view and is the only listener. It reconciles the project it
|
|
@@ -10479,7 +10836,7 @@
|
|
|
10479
10836
|
// this tab happens to be showing.
|
|
10480
10837
|
window.dispatchEvent(new CustomEvent('floless:projects-changed', { detail: m }));
|
|
10481
10838
|
if (m.kind !== 'metadata' && (typeof m.appId !== 'string' || m.appId === currentId)) {
|
|
10482
|
-
refreshCurrentWorkflowAvailability().catch(
|
|
10839
|
+
refreshCurrentWorkflowAvailability().catch(reportBackgroundAvailabilityErr);
|
|
10483
10840
|
}
|
|
10484
10841
|
} else if (m.type === 'workspace-root-changed') {
|
|
10485
10842
|
// Root identity/path belongs to the server's protected registry. Re-read it so every open tab
|
|
@@ -10621,6 +10978,9 @@
|
|
|
10621
10978
|
// The terminal AI (or undo/reset) rewrote ~/.floless/ui/extensions.json —
|
|
10622
10979
|
// re-render the Dashboard / inspect-tab panels live. panels.js owns it.
|
|
10623
10980
|
if (window.flolessPanels) window.flolessPanels.refresh({ fromChange: true });
|
|
10981
|
+
} else if (m.type === 'knowledge-changed') {
|
|
10982
|
+
// #2399 slice 0b: a chat, a terminal or another window changed a project's references or design set.
|
|
10983
|
+
window.flolessWorkspaces?.knowledgeChanged?.(m.projectId);
|
|
10624
10984
|
} else if (m.type === 'revision-note-changed') {
|
|
10625
10985
|
window.dispatchEvent(new CustomEvent('floless:revision-note-changed', { detail: m }));
|
|
10626
10986
|
} else if (m.type === 'run-ended') {
|
|
@@ -10629,9 +10989,15 @@
|
|
|
10629
10989
|
if (m.id && m.id === currentId) void globalThis.flolessAgentSteps?.refreshRunRecord(m.id); // #2241 S5
|
|
10630
10990
|
} else if (m.type === 'routine-changed') {
|
|
10631
10991
|
loadRoutinesData();
|
|
10992
|
+
window.flolessProjectAccess?.refresh?.(); // Project access lists schedules: its chip count and open sheet follow
|
|
10993
|
+
} else if (m.type === 'agent-step-fires-changed') {
|
|
10994
|
+
// S8: a watcher's AI step recorded an event: its Inspect history and its routine card count are read again.
|
|
10995
|
+
globalThis.flolessAgentSteps?.watcherChanged?.(m.id);
|
|
10996
|
+
if (m.routineId) loadRoutinesData();
|
|
10632
10997
|
} else if (m.type === 'agent-changed') {
|
|
10633
10998
|
// #2062: an agent was paused, resumed, archived or restored; an open page of it shows the new state.
|
|
10634
10999
|
window.flolessAgents?.refreshAgent?.(m.agentId);
|
|
11000
|
+
window.flolessProjectAccess?.refresh?.();
|
|
10635
11001
|
} else if (m.type === 'routine-run-started') {
|
|
10636
11002
|
runningRoutines.add(m.id);
|
|
10637
11003
|
if ($routinesModal.classList.contains('show')) renderRoutinesList();
|
|
@@ -10705,7 +11071,13 @@
|
|
|
10705
11071
|
recheckLicenseAndGate();
|
|
10706
11072
|
}
|
|
10707
11073
|
};
|
|
10708
|
-
es.onerror = () =>
|
|
11074
|
+
es.onerror = () => {
|
|
11075
|
+
connectionGeneration++;
|
|
11076
|
+
pendingCatchup = null;
|
|
11077
|
+
rootDisconnected = true;
|
|
11078
|
+
window.flolessWorkspaceRoot.invalidateConnection();
|
|
11079
|
+
setServerStatus(false); // EventSource auto-reconnects; an earlier continuation must not catch up.
|
|
11080
|
+
};
|
|
10709
11081
|
}
|
|
10710
11082
|
|
|
10711
11083
|
// A Request start the chat routes refused with one of the codes below has its own sentence in AI
|
|
@@ -10727,9 +11099,45 @@
|
|
|
10727
11099
|
showToast(text, 'warn');
|
|
10728
11100
|
}
|
|
10729
11101
|
|
|
11102
|
+
// The sentence for a 402 from the subscription gate (server/subscription-gate.ts), or '' for any other failure.
|
|
11103
|
+
// The one copy every surface uses: when the FloLess sign-in lapsed, chat said "could not complete this chat action"
|
|
11104
|
+
// and a workflow refresh said "could not reach it", so nobody knew that signing in again was the fix (2026-10-16).
|
|
11105
|
+
// Reads the response body when the caller kept it, else the structured fields copied onto the error.
|
|
11106
|
+
function accountAccessText(error) {
|
|
11107
|
+
const access = error?.body || error;
|
|
11108
|
+
if (error?.status !== 402 && access?.error !== 'subscription required') return '';
|
|
11109
|
+
if (access?.state === 'expired') return 'Your FloLess subscription has expired. Renew your FloLess subscription, then try again.';
|
|
11110
|
+
if (access?.reason === 'no-subscription') return 'This account does not have a FloLess subscription. Sign in with a subscribed account or subscribe, then try again.';
|
|
11111
|
+
if (access?.reason === 'session-expired') return 'Your FloLess sign-in has expired. Sign in again, then try again.';
|
|
11112
|
+
if (access?.reason === 'signed-out') return 'You are signed out of FloLess. Sign in again, then try again.';
|
|
11113
|
+
if (access?.reason === 'seat-taken') return 'Your FloLess session has ended. Sign in again, then try again.';
|
|
11114
|
+
return 'Sign in to FloLess to check your account access, then try again.';
|
|
11115
|
+
}
|
|
11116
|
+
|
|
11117
|
+
// A refusal the server wrote for the person — a commercial module (Revit, Tekla, Drawing Checker)
|
|
11118
|
+
// that is not confirmed for this computer says what is wrong and what to do (module-registry
|
|
11119
|
+
// REFUSAL_COPY), and sends that sentence as `userMessage`. The generic "try again, reopen FloLess"
|
|
11120
|
+
// line used to replace it, although neither fixes the refusal. Only `userMessage` is shown: `error`
|
|
11121
|
+
// on the same code can be internal wording.
|
|
11122
|
+
function moduleRefusalText(e) {
|
|
11123
|
+
const text = e?.status === 403 && typeof e.body?.userMessage === 'string' ? e.body.userMessage.trim() : '';
|
|
11124
|
+
return text;
|
|
11125
|
+
}
|
|
11126
|
+
|
|
10730
11127
|
function reportErr(e) {
|
|
10731
11128
|
if (awarePageUnloading && e instanceof TypeError && e.message === 'Failed to fetch') return;
|
|
10732
11129
|
console.error(e);
|
|
11130
|
+
const refusal = moduleRefusalText(e);
|
|
11131
|
+
if (refusal) {
|
|
11132
|
+
showToast(refusal, 'warn');
|
|
11133
|
+
return;
|
|
11134
|
+
}
|
|
11135
|
+
// #2474: a change asked of a workflow's published copy says how to change the workflow instead.
|
|
11136
|
+
const owned = e?.status === 409 && e.body?.code === 'owned-workflow-publication' && typeof e.body.userMessage === 'string' ? e.body.userMessage.trim() : '';
|
|
11137
|
+
if (owned) {
|
|
11138
|
+
showToast(owned, 'warn');
|
|
11139
|
+
return;
|
|
11140
|
+
}
|
|
10733
11141
|
showToast('We couldn’t finish that. Your work is still here. Try again. If it keeps happening, reopen FloLess.', 'err');
|
|
10734
11142
|
}
|
|
10735
11143
|
|
|
@@ -10959,7 +11367,7 @@
|
|
|
10959
11367
|
try {
|
|
10960
11368
|
// A dead local server must not leave a Copy button waiting forever. Keep the
|
|
10961
11369
|
// authoritative revalidation, but fail closed after a short, user-action-sized wait.
|
|
10962
|
-
const latest = await api('/api/requests', {
|
|
11370
|
+
const latest = await api('/api/requests', { timeoutMs: 5000 });
|
|
10963
11371
|
current = Array.isArray(latest?.requests)
|
|
10964
11372
|
? latest.requests.find((candidate) => candidate && candidate.id === req.id)
|
|
10965
11373
|
: null;
|
|
@@ -12223,7 +12631,7 @@
|
|
|
12223
12631
|
let doneRequestsUnreadable = 0;
|
|
12224
12632
|
async function loadDoneRequests() {
|
|
12225
12633
|
try {
|
|
12226
|
-
const body = await api('/api/requests/done', {
|
|
12634
|
+
const body = await api('/api/requests/done', { timeoutMs: 30_000 });
|
|
12227
12635
|
doneRequests = Array.isArray(body?.requests) ? body.requests : [];
|
|
12228
12636
|
doneRequestsUnreadable = Number(body?.unreadable) || 0;
|
|
12229
12637
|
doneRequestsError = null;
|
|
@@ -12454,7 +12862,7 @@
|
|
|
12454
12862
|
try {
|
|
12455
12863
|
// Bounded: every later read waits behind this one, so a response that never arrives must not
|
|
12456
12864
|
// freeze the list for good. The route's own lock waits give up after 60 s.
|
|
12457
|
-
const { requests, chatPublications = [], needsYou, backlog = null } = await api('/api/requests', {
|
|
12865
|
+
const { requests, chatPublications = [], needsYou, backlog = null } = await api('/api/requests', { timeoutMs: 90_000 });
|
|
12458
12866
|
reconcileActiveInstructorRuns(requests, chatPublications);
|
|
12459
12867
|
pendingRequests = requests;
|
|
12460
12868
|
requestsBacklog = backlog && typeof backlog === 'object' ? backlog : null;
|
|
@@ -15532,9 +15940,7 @@
|
|
|
15532
15940
|
|
|
15533
15941
|
async function ensureReportDiscoverySession(force = false) {
|
|
15534
15942
|
if (!reportDiscoveryBootstrapMode) {
|
|
15535
|
-
reportDiscoveryBootstrapMode =
|
|
15536
|
-
if (!response.ok) throw new Error('report discovery health check unavailable');
|
|
15537
|
-
const health = await response.json();
|
|
15943
|
+
reportDiscoveryBootstrapMode = readHealth().then((health) => {
|
|
15538
15944
|
if (typeof health?.capabilities?.editorSessionHttpBootstrap !== 'boolean') {
|
|
15539
15945
|
throw new Error('report discovery session mode unavailable');
|
|
15540
15946
|
}
|
|
@@ -15630,9 +16036,7 @@
|
|
|
15630
16036
|
async function savedReportsStillStarting() {
|
|
15631
16037
|
if (!reportsMaybeStarting) return null;
|
|
15632
16038
|
try {
|
|
15633
|
-
const
|
|
15634
|
-
if (!response.ok) return null;
|
|
15635
|
-
const state = (await response.json())?.startup?.reports;
|
|
16039
|
+
const state = (await readHealth())?.startup?.reports;
|
|
15636
16040
|
// An older server has no startup field: it only ever answers once reports are ready.
|
|
15637
16041
|
if (state === undefined || state === 'ready') { reportsMaybeStarting = false; return null; }
|
|
15638
16042
|
return state === 'paused' ? 'paused' : 'checking';
|
|
@@ -15746,7 +16150,9 @@
|
|
|
15746
16150
|
}
|
|
15747
16151
|
// #2241 S5: the last scheduled run used an AI step - say so in the row, and how many questions it left for the person.
|
|
15748
16152
|
function routineAiHtml(r) {
|
|
15749
|
-
|
|
16153
|
+
// S8: a watcher has no run per event; its card speaks from the events that reached its AI step.
|
|
16154
|
+
const ai = r.kind === 'trigger' ? globalThis.flolessAgentSteps?.watcherCardParts?.(r.aiEvents) ?? null
|
|
16155
|
+
: !r.agent && r.lastRun ? globalThis.flolessAgentSteps?.routineAiParts(r.lastRun) : null;
|
|
15750
16156
|
if (!ai) return '';
|
|
15751
16157
|
return `<span class="rtn-dot">·</span><span class="rtn-ai" data-tip="${escapeAttr(ai.aiTip)}">${escapeHtml(ai.ai)}</span>`
|
|
15752
16158
|
+ (ai.questions ? `<span class="rtn-dot">·</span><span class="rtn-ai-q" data-tip="${escapeAttr(ai.questionsTip)}">${escapeHtml(ai.questions)}</span>` : '');
|
|
@@ -15956,10 +16362,14 @@
|
|
|
15956
16362
|
// depends on the report-frame `allow-same-origin` fix to repaint in Chrome.)
|
|
15957
16363
|
function applyTriggerReport(m) {
|
|
15958
16364
|
if (!m || !m.workflow || typeof m.html !== 'string') return;
|
|
15959
|
-
|
|
16365
|
+
const runId = typeof m.runId === 'string' ? m.runId : null;
|
|
16366
|
+
const entry = { nodeId: m.nodeId || null, label: 'live · on selection change', html: m.html,
|
|
16367
|
+
runId, captureKey: captureKeyOf(runId, m.fireKey), withFiles: m.withFiles === true };
|
|
16368
|
+
lastReportByApp.set(m.workflow, entry);
|
|
15960
16369
|
const open = $reportModal && $reportModal.classList.contains('show');
|
|
15961
16370
|
if (!open || currentId !== m.workflow || reportRunning) return;
|
|
15962
|
-
paintReport(m.html); // unhides Share + clears the overlay
|
|
16371
|
+
paintReport(m.html, false, entry); // unhides Share + clears the overlay
|
|
16372
|
+
paintReportPageLinks();
|
|
15963
16373
|
const t = new Date().toLocaleTimeString();
|
|
15964
16374
|
$reportSub.innerHTML =
|
|
15965
16375
|
`<span class="live-pip" aria-hidden="true"></span>Live · updated ${escapeHtml(t)} · on selection change — rendered from the node's output, never composed by the UI.`;
|
|
@@ -15982,11 +16392,12 @@
|
|
|
15982
16392
|
const interactive = m.interactive === true;
|
|
15983
16393
|
const savedPath = typeof m.savedPath === 'string' ? m.savedPath : '';
|
|
15984
16394
|
const fromChat = m.from !== 'terminal';
|
|
15985
|
-
|
|
15986
|
-
runId: typeof m.runId === 'string' ? m.runId : null }
|
|
16395
|
+
const entry = { nodeId: m.nodeId || null, label: fromChat ? 'from AI Chat' : 'from a terminal', html: m.html, interactive, savedPath,
|
|
16396
|
+
withFiles: m.withFiles === true, runId: typeof m.runId === 'string' ? m.runId : null };
|
|
16397
|
+
lastReportByApp.set(m.workflow, entry);
|
|
15987
16398
|
const open = $reportModal && $reportModal.classList.contains('show');
|
|
15988
16399
|
if (!open || currentId !== m.workflow || reportRunning) return;
|
|
15989
|
-
paintReport(m.html, interactive);
|
|
16400
|
+
paintReport(m.html, interactive, entry);
|
|
15990
16401
|
paintReportPageLinks();
|
|
15991
16402
|
$reportSub.textContent = fromChat ? 'Report from the run you confirmed in AI Chat — rendered from the run\'s output, never composed by the UI.'
|
|
15992
16403
|
: 'Report from a run started in a terminal — rendered from the run\'s output, never composed by the UI.';
|
|
@@ -15997,10 +16408,11 @@
|
|
|
15997
16408
|
if (!m || !m.workflow || typeof m.html !== 'string') return;
|
|
15998
16409
|
const prev = lastReportByApp.get(m.workflow);
|
|
15999
16410
|
const changed = !prev || prev.html !== m.html;
|
|
16000
|
-
|
|
16411
|
+
const entry = { nodeId: m.nodeId || null, label: 'scheduled', html: m.html, withFiles: m.withFiles === true, runId: typeof m.runId === 'string' ? m.runId : null };
|
|
16412
|
+
lastReportByApp.set(m.workflow, entry);
|
|
16001
16413
|
const open = $reportModal && $reportModal.classList.contains('show');
|
|
16002
16414
|
if (open && currentId === m.workflow && !reportRunning && !foregroundTrigger) {
|
|
16003
|
-
paintReport(m.html); // unhides Share + clears the overlay
|
|
16415
|
+
paintReport(m.html, false, entry); // unhides Share + clears the overlay
|
|
16004
16416
|
paintReportPageLinks();
|
|
16005
16417
|
const t = new Date().toLocaleTimeString();
|
|
16006
16418
|
$reportSub.innerHTML =
|
|
@@ -16427,6 +16839,31 @@
|
|
|
16427
16839
|
// server hosts the long-lived `aware app run`; here we open the Viewer, surface
|
|
16428
16840
|
// Stop, and reflect the live state. We never compose HTML — the Viewer relays
|
|
16429
16841
|
// exactly what the node returns (applyTriggerReport paints each fresh report).
|
|
16842
|
+
// S8 (#2495): while a person has the live run's Viewer on screen, the page says so every 15 s. An AI step's change card in a live
|
|
16843
|
+
// run is shown only while such a beat is recent; once the Viewer closes, the tab is hidden or the run ends, it says it stopped.
|
|
16844
|
+
let viewerBeatApp = null;
|
|
16845
|
+
function beatLiveViewer() {
|
|
16846
|
+
const viewing = !!foregroundTrigger && currentId === foregroundTrigger.appId && $reportModal.classList.contains('show')
|
|
16847
|
+
&& document.visibilityState === 'visible';
|
|
16848
|
+
const appId = viewing ? foregroundTrigger.appId : null;
|
|
16849
|
+
const send = (id, on) => fetch(`/api/trigger-run/${encodeURIComponent(id)}/viewing`, {
|
|
16850
|
+
method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ viewing: on }),
|
|
16851
|
+
}).catch(() => { /* presence only: a missed beat just means the next change is held */ });
|
|
16852
|
+
if (viewerBeatApp && viewerBeatApp !== appId) send(viewerBeatApp, false);
|
|
16853
|
+
if (appId) send(appId, true);
|
|
16854
|
+
viewerBeatApp = appId;
|
|
16855
|
+
}
|
|
16856
|
+
setInterval(beatLiveViewer, 15_000);
|
|
16857
|
+
document.addEventListener('visibilitychange', beatLiveViewer);
|
|
16858
|
+
/** The moment the Viewer closes or the live run ends, say so at once — not at the next beat — so a change card is never
|
|
16859
|
+
* approvable for up to 15 s after the person stopped looking. Only a change of who is viewing sends anything. */
|
|
16860
|
+
function liveViewerMayHaveChanged() {
|
|
16861
|
+
const viewing = !!foregroundTrigger && currentId === foregroundTrigger.appId && $reportModal.classList.contains('show')
|
|
16862
|
+
&& document.visibilityState === 'visible';
|
|
16863
|
+
if ((viewing ? foregroundTrigger.appId : null) !== viewerBeatApp) beatLiveViewer();
|
|
16864
|
+
}
|
|
16865
|
+
new MutationObserver(liveViewerMayHaveChanged).observe($reportModal, { attributes: true, attributeFilter: ['class'] });
|
|
16866
|
+
|
|
16430
16867
|
async function startForegroundTrigger(app) {
|
|
16431
16868
|
if (foregroundTrigger || foregroundStarting || foregroundStopping) return;
|
|
16432
16869
|
const id = currentId;
|
|
@@ -16450,6 +16887,7 @@
|
|
|
16450
16887
|
foregroundTrigger = { appId: id, sessionId: res.sessionId, firedCount: 0 };
|
|
16451
16888
|
markFirstRunDone(id); // a real live session started → a streaming workflow's "first run" is no longer new
|
|
16452
16889
|
paintForegroundListening();
|
|
16890
|
+
beatLiveViewer();
|
|
16453
16891
|
appendNarration(`Live session started for <strong>${escapeHtml(id)}</strong> — the report updates on every event. Click <strong>■ Stop run</strong> (top right) to end it.`);
|
|
16454
16892
|
} catch (e) {
|
|
16455
16893
|
// A refusal (a watcher already holds this host) names the concrete path back —
|
|
@@ -16495,7 +16933,7 @@
|
|
|
16495
16933
|
const fired = foregroundTrigger.firedCount > prevFired;
|
|
16496
16934
|
const viewerOpen = currentId === foregroundTrigger.appId && $reportModal.classList.contains('show');
|
|
16497
16935
|
if (snapshot.state === 'error') {
|
|
16498
|
-
foregroundTrigger = null;
|
|
16936
|
+
foregroundTrigger = null; liveViewerMayHaveChanged();
|
|
16499
16937
|
if (viewerOpen) {
|
|
16500
16938
|
$reportShare.hidden = true; // the error overlay is the primary content now
|
|
16501
16939
|
$reportOverlay.hidden = false;
|
|
@@ -16510,7 +16948,7 @@
|
|
|
16510
16948
|
if (snapshot.state === 'stopped') {
|
|
16511
16949
|
// The stream ended on its own — a one-shot (`once`) snapshot fired then exited,
|
|
16512
16950
|
// or the host closed cleanly. A clean self-exit reads as "Run complete".
|
|
16513
|
-
foregroundTrigger = null;
|
|
16951
|
+
foregroundTrigger = null; liveViewerMayHaveChanged();
|
|
16514
16952
|
if (viewerOpen) paintForegroundStopped('complete');
|
|
16515
16953
|
syncRunControls();
|
|
16516
16954
|
return;
|
|
@@ -17140,6 +17578,13 @@
|
|
|
17140
17578
|
};
|
|
17141
17579
|
// #2035: an agent's page opens a new routine with that agent chosen.
|
|
17142
17580
|
window.flolessRoutines = {
|
|
17581
|
+
/** Project access: open Routines with one routine's editor, so the person sees exactly the schedule they picked. */
|
|
17582
|
+
async open(routineId) {
|
|
17583
|
+
openRoutines();
|
|
17584
|
+
await loadRoutinesData();
|
|
17585
|
+
if (routinesData.some((r) => r.id === routineId)) await openRoutineEdit(routineId);
|
|
17586
|
+
else showToast('That schedule no longer exists. Routines lists the ones you have.', 'warn');
|
|
17587
|
+
},
|
|
17143
17588
|
/** #2046: a Guide suggestion — a new routine for this workflow, opened for the person to finish. */
|
|
17144
17589
|
async editForWorkflow(workflowId, returnFocus) {
|
|
17145
17590
|
await loadRoutinesData();
|
|
@@ -18089,8 +18534,7 @@
|
|
|
18089
18534
|
// Show the installed build (so a stale install is self-diagnosable from the
|
|
18090
18535
|
// gate — the highest-value spot since that's where a confused user lands).
|
|
18091
18536
|
// /api/health is un-gated, so this works even while unlicensed.
|
|
18092
|
-
|
|
18093
|
-
.then((r) => r.json())
|
|
18537
|
+
readHealth()
|
|
18094
18538
|
.then((h) => { if (h && h.appVersion) document.getElementById('lg-version').textContent = 'FloLess ' + h.appVersion; })
|
|
18095
18539
|
.catch(() => { /* version is a nicety; never block the gate on it */ });
|
|
18096
18540
|
document.getElementById('lg-signin').onclick = async () => {
|
|
@@ -18418,9 +18862,15 @@
|
|
|
18418
18862
|
|| String(b.updatedAt || '').localeCompare(String(a.updatedAt || '')));
|
|
18419
18863
|
}
|
|
18420
18864
|
|
|
18865
|
+
/** The owned workflow (not archived) a chat names by its owned id, or null. */
|
|
18866
|
+
function ownedForOpen(workflowId) {
|
|
18867
|
+
return wfOwned.find((row) => row.workflowId === workflowId && row.status !== 'archived') || null;
|
|
18868
|
+
}
|
|
18869
|
+
|
|
18870
|
+
/** Open an owned workflow's draft view; false when there is no such draft (or no view to show it in). */
|
|
18421
18871
|
function openDraftWorkflow(workflowId) {
|
|
18422
18872
|
const row = wfOwned.find((item) => item.workflowId === workflowId && item.status !== 'archived');
|
|
18423
|
-
if (!row || !$wfDraft) return;
|
|
18873
|
+
if (!row || !$wfDraft) return false;
|
|
18424
18874
|
selectionTicket += 1;
|
|
18425
18875
|
if (draftWorkflow) closeDraftView();
|
|
18426
18876
|
draftWorkflow = { workflowId: row.workflowId, displayName: row.displayName, ownerLabel: row.ownerLabel || 'Standalone',
|
|
@@ -18443,6 +18893,7 @@
|
|
|
18443
18893
|
notifyChatScope();
|
|
18444
18894
|
void watchDraft(draftWorkflow);
|
|
18445
18895
|
document.getElementById('wf-draft-title')?.focus();
|
|
18896
|
+
return true;
|
|
18446
18897
|
}
|
|
18447
18898
|
|
|
18448
18899
|
// The AI writes a draft's workflow file from its chat, which raises no workflow event, so an open draft re-reads
|
|
@@ -18552,11 +19003,32 @@
|
|
|
18552
19003
|
document.getElementById('wf-draft-compile')?.focus();
|
|
18553
19004
|
try {
|
|
18554
19005
|
await api(`/api/workflows/owned/${encodeURIComponent(d.workflowId)}/publish`, { method: 'POST' });
|
|
18555
|
-
} catch {
|
|
19006
|
+
} catch (error) {
|
|
18556
19007
|
// The route's own wording is internal; the person gets the plain sentence and two ways on.
|
|
18557
19008
|
d.busy = false;
|
|
18558
19009
|
if (draftWorkflow !== d) return;
|
|
18559
19010
|
d.compiling = false;
|
|
19011
|
+
// #2314: two steps share one name. Ask which to rename; after a rename, compile again. Cancel keeps today's failure.
|
|
19012
|
+
const ask = globalThis.flolessStepRename ? globalThis.flolessStepRename.askOf(error) : null;
|
|
19013
|
+
if (ask) {
|
|
19014
|
+
renderDraftView();
|
|
19015
|
+
const outcome = await globalThis.flolessStepRename.open(ask);
|
|
19016
|
+
if (draftWorkflow !== d) return;
|
|
19017
|
+
if (outcome.renamed) {
|
|
19018
|
+
const warning = outcome.result && outcome.result.warning;
|
|
19019
|
+
if (warning) {
|
|
19020
|
+
// Not exactly as previewed (or not checkable): no automatic Compile — the person looks, then presses Compile.
|
|
19021
|
+
showToast(warning, 'warn');
|
|
19022
|
+
d.note = warning;
|
|
19023
|
+
renderDraftView();
|
|
19024
|
+
return;
|
|
19025
|
+
}
|
|
19026
|
+
await compileDraftWorkflow();
|
|
19027
|
+
return;
|
|
19028
|
+
}
|
|
19029
|
+
// Cancelled: the draft's failure view stays, and the reason stays in view with it.
|
|
19030
|
+
showToast(`${ask.sentence ? `${ask.sentence} ` : ''}Nothing was renamed.`, 'warn');
|
|
19031
|
+
}
|
|
18560
19032
|
d.failed = true;
|
|
18561
19033
|
renderDraftView();
|
|
18562
19034
|
document.getElementById('wf-draft-failure')?.focus();
|
|
@@ -18689,12 +19161,18 @@
|
|
|
18689
19161
|
// #1997: open an installed workflow by its AWARE app id (the "Open workflow" next step of Approve updated
|
|
18690
19162
|
// workflows, e.g. "open it and press Compile").
|
|
18691
19163
|
// Only a workflow the Workflows page lists can be opened; one installed outside FloLess (from a terminal) is not.
|
|
18692
|
-
|
|
19164
|
+
// A chat working on a FloLess-owned workflow knows it by its owned id, not its AWARE app id (#2241 S6: the
|
|
19165
|
+
// "confirm its AI step" card from the workflow's own chat), so an owned id opens its published app, or its draft.
|
|
19166
|
+
canOpenApp: (appId) => wfLibrary.some((row) => row.id === appId) || Boolean(ownedForOpen(appId)),
|
|
18693
19167
|
async openApp(appId) {
|
|
18694
19168
|
await window.flolessWorkspaces?.setMode?.('workflows');
|
|
18695
19169
|
await loadApps();
|
|
18696
19170
|
if (!wfLibrary.some((row) => row.id === appId)) {
|
|
18697
|
-
|
|
19171
|
+
const owned = ownedForOpen(appId);
|
|
19172
|
+
const runtimeId = owned?.activePublication?.runtimeAppId;
|
|
19173
|
+
if (runtimeId && wfLibrary.some((row) => row.id === runtimeId)) appId = runtimeId;
|
|
19174
|
+
else if (owned) return openDraftWorkflow(owned.workflowId);
|
|
19175
|
+
else throw new Error('That workflow is not on your Workflows page, so FloLess cannot open it. Compile it from the terminal that installed it.');
|
|
18698
19176
|
}
|
|
18699
19177
|
await loadApp(appId);
|
|
18700
19178
|
showWorkflowsLanding(false);
|
|
@@ -18707,7 +19185,21 @@
|
|
|
18707
19185
|
// opened after the run) holds a different one or none. Say so instead of showing the wrong report.
|
|
18708
19186
|
const gone = 'This window no longer holds that run\'s report: a newer run replaced it, or the window opened after it ran. Open the workflow to see its latest results.';
|
|
18709
19187
|
const cached = lastReportByApp.get(appId);
|
|
18710
|
-
if (!runId
|
|
19188
|
+
if (!runId) throw new Error(gone);
|
|
19189
|
+
// #2266: a window opened (or reloaded) after the run reads the copy FloLess kept of THAT run's report, in the
|
|
19190
|
+
// workflow's Page. Never another run's: a report no longer kept says so.
|
|
19191
|
+
if (cached?.runId !== runId) {
|
|
19192
|
+
let kept = null;
|
|
19193
|
+
try { kept = await api(`/api/pages/workflow?app=${encodeURIComponent(appId)}&run=${encodeURIComponent(runId)}`); }
|
|
19194
|
+
catch { throw new Error('FloLess couldn’t read that run’s report just now. Try again, or open the workflow to see its latest results.'); }
|
|
19195
|
+
if (kept?.home && kept.page?.id && kept.shown?.kept === true) {
|
|
19196
|
+
if (typeof window.flolessPages?.open !== 'function') throw new Error('FloLess kept that run’s report, but this window cannot open Pages. Open it from the Pages list.');
|
|
19197
|
+
return await window.flolessPages.open(kept.home, kept.page.id, kept.shown.version);
|
|
19198
|
+
}
|
|
19199
|
+
throw new Error(kept?.shown?.note
|
|
19200
|
+
? `${kept.shown.note} Open the workflow to see its latest results.`
|
|
19201
|
+
: 'FloLess did not keep a copy of that run’s report. Open the workflow to see its latest results.');
|
|
19202
|
+
}
|
|
18711
19203
|
await this.openApp(appId);
|
|
18712
19204
|
// Opening the workflow waits; a newer report may have arrived meanwhile. Show this run's report or nothing.
|
|
18713
19205
|
if (lastReportByApp.get(appId) !== cached) throw new Error(gone);
|
|
@@ -18718,6 +19210,25 @@
|
|
|
18718
19210
|
},
|
|
18719
19211
|
// #1890 PR 3b: open a FloLess-owned workflow by its id — its published app when it has one, otherwise its draft
|
|
18720
19212
|
// view — so a conversation that moved into it can be followed there. Throws a plain sentence when it is gone.
|
|
19213
|
+
// Project access: an archived workflow has no canvas to open, so show it where it can be restored — its card in the
|
|
19214
|
+
// Workflows list's Archived section, opened, scrolled to and focused on Restore. Throws a plain sentence when it is gone.
|
|
19215
|
+
async openArchivedWorkflow(workflowId) {
|
|
19216
|
+
await window.flolessWorkspaces?.setMode?.('workflows');
|
|
19217
|
+
// The switch can stay on the current tab (another workflow's read failed): never focus a card nobody can see.
|
|
19218
|
+
if (document.body.classList.contains('mode-workspaces') || document.body.classList.contains('mode-agents')) {
|
|
19219
|
+
throw new Error('FloLess could not switch to the Workflows tab just now. Open it and find the workflow under Archived.');
|
|
19220
|
+
}
|
|
19221
|
+
// The list is what is needed here, not any one workflow: a reload that fails keeps the list already on screen.
|
|
19222
|
+
try { await loadApps(); } catch (error) { console.warn('[project-access] the workflow list could not be read again', error); }
|
|
19223
|
+
showWorkflowsLanding(true);
|
|
19224
|
+
const card = [...($wfLanding?.querySelectorAll('[data-wf-archived]') || [])].find((el) => el.getAttribute('data-wf-archived') === workflowId);
|
|
19225
|
+
if (!card) throw new Error('That workflow is no longer in the Archived list, so FloLess cannot show it. It may have been restored or removed.');
|
|
19226
|
+
const box = card.closest('.wf-archived');
|
|
19227
|
+
if (box) box.open = true;
|
|
19228
|
+
card.scrollIntoView?.({ block: 'center' });
|
|
19229
|
+
card.querySelector('[data-wf-restore]')?.focus();
|
|
19230
|
+
return true;
|
|
19231
|
+
},
|
|
18721
19232
|
async openOwnedWorkflow(workflowId) {
|
|
18722
19233
|
await window.flolessWorkspaces?.setMode?.('workflows');
|
|
18723
19234
|
await loadApps();
|
|
@@ -18792,6 +19303,10 @@
|
|
|
18792
19303
|
refreshCurrentWorkflow() {
|
|
18793
19304
|
return refreshCurrentWorkflow();
|
|
18794
19305
|
},
|
|
19306
|
+
// The person-facing sentence of a module refusal (see reportErr), or '' for any other failure.
|
|
19307
|
+
moduleRefusalText,
|
|
19308
|
+
// The person-facing sentence of a lapsed sign-in or subscription (HTTP 402), or '' for any other failure.
|
|
19309
|
+
accountAccessText,
|
|
18795
19310
|
reloadCompiledWorkflows,
|
|
18796
19311
|
// Workspaces is a replacement surface. Invalidate a pending workflow-pin read as soon as it
|
|
18797
19312
|
// opens, rather than allowing a late answer to survive behind the project UI until the return.
|
|
@@ -18991,7 +19506,7 @@
|
|
|
18991
19506
|
// Setup-first: if AWARE isn't ready, show the overlay and DEFER routing until it
|
|
18992
19507
|
// is (the health poll + finishBootstrapReady → onBootstrapReady do the routing).
|
|
18993
19508
|
let h = null;
|
|
18994
|
-
try { h = await (
|
|
19509
|
+
try { h = await readHealth(); }
|
|
18995
19510
|
catch { /* health unreachable → route now; the offline overlay handles a down server */ }
|
|
18996
19511
|
if (h && h.bootstrap && h.bootstrap !== 'ready') {
|
|
18997
19512
|
updateBootstrap({ status: h.bootstrap, reason: h.bootstrapReason ?? null, remediation: h.bootstrapRemediation ?? null });
|