@floless/app 0.169.0 → 0.170.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +71580 -59849
- package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
- package/dist/schemas/steel.model.v2.schema.json +2 -1
- package/dist/skills/floless-app-knowledge/SKILL.md +43 -13
- package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
- package/dist/skills/floless-app-routines/SKILL.md +2 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +20 -8
- package/dist/skills/floless-app-steel-model/SKILL.md +8 -5
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
- package/dist/skills/floless-app-workflows/SKILL.md +22 -3
- package/dist/skills/floless-app-workflows/references/agent-steps.md +40 -6
- package/dist/skills/floless-app-workflows/references/exec-contract.md +27 -0
- package/dist/skills/floless-app-workflows/references/script-runner.md +105 -0
- package/dist/web/agent-steps.js +89 -18
- package/dist/web/agents.js +32 -22
- package/dist/web/app.css +223 -1
- package/dist/web/app.js +24 -3
- package/dist/web/aware.js +877 -189
- package/dist/web/chat.js +184 -95
- package/dist/web/checkpoint-standard.js +5 -3
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-shell.js +440 -11
- package/dist/web/commands-steel.js +60 -1
- package/dist/web/drawing-check-editor.js +352 -88
- package/dist/web/failure-copy.js +32 -2
- package/dist/web/filter-ai-proposal.js +11 -8
- package/dist/web/flo-3d.js +1 -1
- package/dist/web/guide.js +33 -26
- package/dist/web/index.html +69 -1
- package/dist/web/instructor.js +99 -15
- package/dist/web/left-pane.js +4 -1
- package/dist/web/local-discovery.js +8 -7
- package/dist/web/missed-routines.js +239 -0
- package/dist/web/model-measure.js +6 -0
- package/dist/web/model-spatial-panel.js +19 -4
- package/dist/web/model-spatial-tools.js +3 -3
- package/dist/web/model-viewport-revit-adapter.js +3 -3
- package/dist/web/origin-rule.js +155 -0
- package/dist/web/project-access.js +1 -1
- package/dist/web/project-modules.js +2 -2
- package/dist/web/project-rfis.js +6 -1
- package/dist/web/project-workflows.js +2 -2
- package/dist/web/revit-editor.js +22 -8
- package/dist/web/run-history.js +12 -1
- package/dist/web/steel-3d-core.js +39 -9
- package/dist/web/steel-3d-flo.js +26 -4
- package/dist/web/steel-3d-view.js +8 -3
- package/dist/web/steel-ai-marks.js +3 -1
- package/dist/web/steel-editor.html +455 -122
- package/dist/web/steel-environments.js +297 -0
- package/dist/web/steel-filter.html +3 -2
- package/dist/web/steel-model-v2-client-validation.js +8 -1
- package/dist/web/steel-model-v2-commands.js +23 -9
- package/dist/web/steel-model-v2-projection.js +1 -1
- package/dist/web/step-rename.js +3 -2
- package/dist/web/terminal-requests.js +1 -1
- package/dist/web/tool-updates.js +7 -6
- package/dist/web/workspaces.js +1714 -119
- package/package.json +4 -1
package/dist/web/aware.js
CHANGED
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
function agentDisplayName(id) {
|
|
176
|
-
return ({ 'html-report': 'HTML Report', 'html-report-stream': 'HTML Report', 'viewer-3d': '3D Viewer', file: 'File' })[id] || id;
|
|
176
|
+
return ({ 'html-report': 'HTML Report', 'html-report-stream': 'HTML Report', 'viewer-3d': '3D Viewer', file: 'File', script: 'Script' })[id] || id;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
function runFailureMessage(message) {
|
|
@@ -253,6 +253,23 @@
|
|
|
253
253
|
}).join('');
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
// #3234: the listing row's answer (app-reader appListFacts → needsAware), or null.
|
|
257
|
+
function awareTooOldFor(id) {
|
|
258
|
+
const row = wfLibrary.find((item) => item.id === id);
|
|
259
|
+
const t = row && row.needsAware;
|
|
260
|
+
return t && typeof t.minimum === 'string' && Array.isArray(t.agents) && t.agents.length ? t : null;
|
|
261
|
+
}
|
|
262
|
+
// The one explanation every surface uses (the notice above the canvas, the status pill's tip).
|
|
263
|
+
function awareTooOldSentence(t) {
|
|
264
|
+
const steps = t.agents.length === 1 ? `${agentDisplayName(t.agents[0])} steps` : 'Some of its steps';
|
|
265
|
+
return `This workflow's ${steps} run inside AWARE itself and need no other program. This computer has AWARE ${t.installed || 'an older version'}, which cannot run them, and installing a tool will not help. `
|
|
266
|
+
+ 'To fix it, choose Upgrade AWARE beside the AWARE version at the bottom of the window, then press Compile. If Upgrade AWARE does not show, the newer AWARE is not available to this computer yet.';
|
|
267
|
+
}
|
|
268
|
+
function awareTooOldRow(t) {
|
|
269
|
+
return `<li class="missing-agent-row"><div><strong>AWARE ${escapeHtml(t.minimum)} or newer</strong>` +
|
|
270
|
+
`<div class="missing-agent-detail">${escapeHtml(awareTooOldSentence(t))}</div></div></li>`;
|
|
271
|
+
}
|
|
272
|
+
|
|
256
273
|
function missingAgentsBulkButton(pending, canInstall) {
|
|
257
274
|
if (pending.length <= 1) return '';
|
|
258
275
|
return `<button class="btn small" type="button" data-note-install-all data-command-id="shell.workflow-agents-install-all" aria-label="Install all missing tools" aria-busy="${!canInstall.length}" ${canInstall.length ? '' : 'disabled data-blocked-reason="Tool installations are in progress. Please wait."'}>${canInstall.length ? `Install all (${canInstall.length})` : 'Installing…'}</button>`;
|
|
@@ -268,17 +285,20 @@
|
|
|
268
285
|
'microsoft-365': '<rect x="2" y="2" width="8" height="8" rx="1"/><rect x="14" y="2" width="8" height="8" rx="1"/><rect x="2" y="14" width="8" height="8" rx="1"/><rect x="14" y="14" width="8" height="8" rx="1"/>',
|
|
269
286
|
email: '<rect x="2" y="4" width="20" height="16" rx="2"/><path d="M2 7l10 7 10-7"/>',
|
|
270
287
|
http: '<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',
|
|
288
|
+
// #3234: AWARE's built-in script runner — braces, since its step is code that needs no program.
|
|
289
|
+
script: '<path d="M8 3H7a2 2 0 00-2 2v5a2 2 0 01-2 2 2 2 0 012 2v5a2 2 0 002 2h1"/><path d="M16 3h1a2 2 0 012 2v5a2 2 0 002 2 2 2 0 00-2 2v5a2 2 0 01-2 2h-1"/>',
|
|
271
290
|
};
|
|
272
291
|
const AGENT_NAMES = {
|
|
273
292
|
tekla: 'Tekla', file: 'File', excel: 'Excel', revit: 'Revit', slack: 'Slack',
|
|
274
293
|
'trimble-connect': 'Trimble Connect', 'microsoft-365': 'Microsoft 365', email: 'Email', http: 'HTTP',
|
|
294
|
+
script: 'Script step (runs inside AWARE, no other program needed)',
|
|
275
295
|
};
|
|
276
296
|
const _svgWrap = (inner) => `<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${inner}</svg>`;
|
|
277
297
|
const iconFor = (agent) => _svgWrap(AGENT_ICONS[agent] || '<path d="M12 2l8 10-8 10L4 12z"/>');
|
|
278
298
|
const iconTipFor = (agent) => AGENT_NAMES[agent] || (agent ? agent.replace(/-/g, ' ') : '');
|
|
279
299
|
const AGENT_ICONS_TEXT = {
|
|
280
300
|
tekla: '⊞', file: '🗀', excel: '◵', revit: '◰', slack: '✦',
|
|
281
|
-
'trimble-connect': '☁', 'microsoft-365': '✉', email: '✉', http: '⇄',
|
|
301
|
+
'trimble-connect': '☁', 'microsoft-365': '✉', email: '✉', http: '⇄', script: '{}',
|
|
282
302
|
};
|
|
283
303
|
const iconTextFor = (agent) => AGENT_ICONS_TEXT[agent] || '◈';
|
|
284
304
|
|
|
@@ -358,8 +378,7 @@
|
|
|
358
378
|
const err = new Error(serverText || apiFailureText({ status: res.status, body }, readOnly));
|
|
359
379
|
err.body = body; // preserve the in-band payload (e.g. credentialIssue) for callers
|
|
360
380
|
err.status = res.status; // callers need to distinguish a terminal refusal from a transient outage
|
|
361
|
-
//
|
|
362
|
-
err.serverText = Boolean(serverText) && body.code !== 'response-unreadable';
|
|
381
|
+
// #3097 3b: no marker for "the server said this"; a reader works the sentence out again from `body` (errorText).
|
|
363
382
|
throw err;
|
|
364
383
|
}
|
|
365
384
|
return body;
|
|
@@ -498,7 +517,13 @@
|
|
|
498
517
|
'bool', 'string', 'char', 'object', 'dynamic', 'this', 'base', 'typeof', 'nameof',
|
|
499
518
|
'default', 'get', 'set', 'async', 'await', 'yield', 'lock', 'params', 'when', 'where',
|
|
500
519
|
]);
|
|
501
|
-
|
|
520
|
+
// #3234: the same C-family scanner colours a script step's JavaScript, with its own keywords and `template` strings.
|
|
521
|
+
const JS_KEYWORDS = new Set([
|
|
522
|
+
'const', 'let', 'var', 'function', 'return', 'if', 'else', 'for', 'of', 'in', 'while', 'do', 'switch', 'case', 'break',
|
|
523
|
+
'continue', 'try', 'catch', 'finally', 'throw', 'new', 'typeof', 'instanceof', 'null', 'undefined', 'true', 'false',
|
|
524
|
+
'this', 'class', 'extends', 'delete', 'void', 'yield', 'default',
|
|
525
|
+
]);
|
|
526
|
+
function highlightCSharp(src, keywords = CSHARP_KEYWORDS) {
|
|
502
527
|
const esc = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
503
528
|
const span = (cls, text) => `<span class="${cls}">${esc(text)}</span>`;
|
|
504
529
|
const n = src.length;
|
|
@@ -519,13 +544,13 @@
|
|
|
519
544
|
while (j < n) { if (src[j] === '"') { if (src[j + 1] === '"') { j += 2; continue; } j++; break; } j++; }
|
|
520
545
|
out += span('st', src.slice(i, j)); i = j; continue;
|
|
521
546
|
}
|
|
522
|
-
if (c === '"' || c === "'" || (c === '$' && src[i + 1] === '"')) { // string / char
|
|
547
|
+
if (c === '"' || c === "'" || c === '`' || (c === '$' && src[i + 1] === '"')) { // string / char / JS template
|
|
523
548
|
const quote = c === '$' ? '"' : c;
|
|
524
549
|
let j = c === '$' ? i + 2 : i + 1;
|
|
525
550
|
while (j < n) {
|
|
526
551
|
if (src[j] === '\\') { j += 2; continue; }
|
|
527
552
|
if (src[j] === quote) { j++; break; }
|
|
528
|
-
if (src[j] === '\n') break;
|
|
553
|
+
if (src[j] === '\n' && quote !== '`') break;
|
|
529
554
|
j++;
|
|
530
555
|
}
|
|
531
556
|
out += span('st', src.slice(i, j)); i = j; continue;
|
|
@@ -537,7 +562,7 @@
|
|
|
537
562
|
if (/[A-Za-z_]/.test(c)) { // identifier / keyword / type
|
|
538
563
|
let j = i; while (j < n && /[A-Za-z0-9_]/.test(src[j])) j++;
|
|
539
564
|
const word = src.slice(i, j);
|
|
540
|
-
if (
|
|
565
|
+
if (keywords.has(word)) out += span('kw', word);
|
|
541
566
|
else if (/^[A-Z]/.test(word)) out += span('ty', word);
|
|
542
567
|
else out += esc(word);
|
|
543
568
|
i = j; continue;
|
|
@@ -564,6 +589,16 @@
|
|
|
564
589
|
return out.join(' ').replace(/\s+/g, ' ').trim();
|
|
565
590
|
}
|
|
566
591
|
|
|
592
|
+
// A node's plain-English Description, as paragraphs: the code's leading comment when it has one, else the
|
|
593
|
+
// step's own `description:` from the .flo (#2952: a step that calls a tool has no code to carry a comment).
|
|
594
|
+
// A blank line in the authored text starts a new paragraph; any other line break is just wrapping.
|
|
595
|
+
function plainDescriptionParas(n, execSource) {
|
|
596
|
+
const fromCode = execSource ? leadingComment(execSource) : '';
|
|
597
|
+
if (fromCode) return [fromCode];
|
|
598
|
+
const own = typeof n.description === 'string' ? n.description : '';
|
|
599
|
+
return own.split(/\r?\n[ \t]*\r?\n/).map((p) => p.replace(/\s+/g, ' ').trim()).filter(Boolean);
|
|
600
|
+
}
|
|
601
|
+
|
|
567
602
|
function buildAgentEntry(app, n) {
|
|
568
603
|
const pin = app.lock.agentPins && n.agent ? app.lock.agentPins[n.agent] : null;
|
|
569
604
|
// All file-derived strings are escaped here: cardEl/renderInspect inject these
|
|
@@ -583,9 +618,12 @@
|
|
|
583
618
|
const execSource = n.config && typeof n.config.code === 'string' ? n.config.code
|
|
584
619
|
: n.inputs && typeof n.inputs.code === 'string' ? n.inputs.code : null;
|
|
585
620
|
const pythonSource = n.agent === 'blender';
|
|
621
|
+
const jsSource = n.agent === 'script'; // #3234: AWARE's built-in script runner takes JavaScript
|
|
586
622
|
// Description tab: a plain-English explanation + a small input table that
|
|
587
623
|
// EXCLUDES the code (code belongs to the Code tab, never dumped here).
|
|
588
|
-
const
|
|
624
|
+
const plainParas = plainDescriptionParas(n, execSource);
|
|
625
|
+
// The card blurb is the first sentence of the FIRST paragraph only, so a paragraph without a full stop never runs into the next.
|
|
626
|
+
const plainDesc = plainParas[0] || '';
|
|
589
627
|
const blurbText = plainDesc && (s => s.length > 80 ? s.slice(0, 79) + '…' : s)(plainDesc.replace(/\.\s+.*/, '.').trim());
|
|
590
628
|
// #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,
|
|
591
629
|
// 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.
|
|
@@ -605,7 +643,7 @@
|
|
|
605
643
|
title: escapeHtml(n.id),
|
|
606
644
|
subtitle: `${agentLabel}${cmd ? '/' + cmd : ''} · ${mode}`,
|
|
607
645
|
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`,
|
|
608
|
-
description: aiStep ? `${aiStep.descriptionHtml}${notesHtml}` : `${aiUse ? aiUse.descriptionHtml : ''}${
|
|
646
|
+
description: aiStep ? `${aiStep.descriptionHtml}${notesHtml}` : `${aiUse ? aiUse.descriptionHtml : ''}${plainParas.map((p) => `<p class="node-desc">${escapeHtml(p)}</p>`).join('')}<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}`,
|
|
609
647
|
// Rich agent/command detail when the manifest is installed (n.skill); else
|
|
610
648
|
// the lock-pointer fallback below (exec/agent-less nodes, uninstalled agents).
|
|
611
649
|
skill: skillBody(
|
|
@@ -620,6 +658,8 @@
|
|
|
620
658
|
// non-exec nodes there is no script; we show the resolved lockfile YAML.
|
|
621
659
|
code: execSource && pythonSource
|
|
622
660
|
? escapeHtml(`# ${n.agent}${n.command ? '.' + n.command : ''} · node "${n.id}" · live source from ~/.aware/apps/${app.id}/\n${execSource}`)
|
|
661
|
+
: execSource && jsSource
|
|
662
|
+
? highlightCSharp(`// ${n.agent}${n.command ? '.' + n.command : ''} · node "${n.id}" · live source from ~/.aware/apps/${app.id}/\n${execSource}`, JS_KEYWORDS)
|
|
623
663
|
: execSource
|
|
624
664
|
? highlightCSharp(`// ${n.agent || n.kind}${n.command ? '.' + n.command : ''} · node "${n.id}" · live source from ~/.aware/apps/${app.id}/\n${execSource}`)
|
|
625
665
|
: app.lock.present
|
|
@@ -701,6 +741,9 @@
|
|
|
701
741
|
// #1998: the exact tool version this workflow was approved with cannot run; the person chooses (reinstall
|
|
702
742
|
// it, or Compile again). Presentation only: the gate is 'agent-changed'.
|
|
703
743
|
'needs-you': { label: 'Needs you', className: 'drift' },
|
|
744
|
+
// #3234: steps that run inside AWARE need a newer AWARE than this computer has. It comes before every other
|
|
745
|
+
// state: Compile, a reinstall or a run all fail until AWARE is upgraded. Presentation only.
|
|
746
|
+
'needs-aware': { label: 'Needs newer AWARE', className: 'drift' },
|
|
704
747
|
drift: { label: 'Needs refresh', className: 'drift' },
|
|
705
748
|
uncompiled: { label: 'Not set up', className: 'uncompiled' },
|
|
706
749
|
};
|
|
@@ -761,6 +804,7 @@
|
|
|
761
804
|
// #1996: what the pill shows for a gate state. The gate itself (and the Instructor's runState) is unchanged;
|
|
762
805
|
// only the label can say more.
|
|
763
806
|
function presentedGateState(app, gateState) {
|
|
807
|
+
if (gateState !== 'draft' && awareTooOldFor(app.id)) return 'needs-aware';
|
|
764
808
|
if (gateState === 'agent-changed' && app.approvalCheck && app.approvalCheck.remedy === 'publish') return 'needs-publish';
|
|
765
809
|
if (gateState === 'agent-changed' && app.approvalCheck && app.approvalCheck.remedy === 'needs-you') return 'needs-you';
|
|
766
810
|
if (gateState === 'ready' && app.approvalCheck && app.approvalCheck.bridgeWarnings && app.approvalCheck.bridgeWarnings.length) return 'needs-you';
|
|
@@ -807,11 +851,20 @@
|
|
|
807
851
|
// verbatim in the details, because that record is the label — never "unchanged behaviour".
|
|
808
852
|
const $approvalStrip = document.getElementById('approval-strip');
|
|
809
853
|
let approvalStripReinstalling = null; // `${appId}\u0000${agent}` while a reinstall is in flight
|
|
854
|
+
// #3097: what a failed reinstall says when the server explained no further (errorText, web/failure-copy.js).
|
|
855
|
+
const REINSTALL_FAILURE = { action: 'put the approved tool back', unsure: 'Reopen the workflow to see whether the tool is back before trying again.' };
|
|
810
856
|
|
|
811
857
|
function approvalStripState(app) {
|
|
812
858
|
const check = app && app.approvalCheck;
|
|
813
859
|
if (!check) return null;
|
|
814
|
-
if (gateStateFor(app) === 'agent-changed' && check.remedy === 'needs-you')
|
|
860
|
+
if (gateStateFor(app) === 'agent-changed' && check.remedy === 'needs-you') {
|
|
861
|
+
// #3234: a version this AWARE is too old to run cannot be reinstalled either; the notice above the canvas says
|
|
862
|
+
// to upgrade AWARE, so the strip offers no reinstall for it. A bridge warning or a carried-over approval still
|
|
863
|
+
// shows: the check falls through to them.
|
|
864
|
+
const tooOld = awareTooOldFor(app.id);
|
|
865
|
+
const unavailable = Array.isArray(check.unavailable) ? check.unavailable : [];
|
|
866
|
+
if (!(tooOld && unavailable.length && unavailable.every((u) => tooOld.agents.includes(u.agent)))) return 'needs-you';
|
|
867
|
+
}
|
|
815
868
|
if (check.current && check.origin === 'successor' && Array.isArray(check.successors) && check.successors.length) return 'carried';
|
|
816
869
|
if (Array.isArray(check.bridgeWarnings) && check.bridgeWarnings.length) return 'bridge-warning';
|
|
817
870
|
return null;
|
|
@@ -869,7 +922,9 @@
|
|
|
869
922
|
return;
|
|
870
923
|
}
|
|
871
924
|
if (state === 'needs-you') {
|
|
872
|
-
|
|
925
|
+
// #3234: a runner this AWARE is too old for gets no reinstall (AWARE would refuse it); the notice says to upgrade.
|
|
926
|
+
const tooOld = awareTooOldFor(app.id);
|
|
927
|
+
const rows = (check.unavailable || []).filter((u) => u.reinstall && !(tooOld && tooOld.agents.includes(u.agent)));
|
|
873
928
|
$approvalStrip.className = 'approval-strip approval-needs-you';
|
|
874
929
|
$approvalStrip.setAttribute('role', 'group');
|
|
875
930
|
$approvalStrip.setAttribute('aria-label', 'A tool version needs your decision');
|
|
@@ -959,10 +1014,11 @@
|
|
|
959
1014
|
$compileBtn.disabled = true; // never approve whichever copy happens to be installed mid-swap
|
|
960
1015
|
const app = apps.get(id);
|
|
961
1016
|
if (app) paintApprovalStrip(app);
|
|
962
|
-
|
|
1017
|
+
// `outcome`, not `res`: its `message` is the route's own sentence for a person (afterReinstallMessage).
|
|
1018
|
+
let outcome = null;
|
|
963
1019
|
let error = null;
|
|
964
1020
|
try {
|
|
965
|
-
|
|
1021
|
+
outcome = await api(`/api/app/${encodeURIComponent(id)}/reinstall-approved-tool`, { method: 'POST', body: JSON.stringify({ agent, version }) });
|
|
966
1022
|
} catch (err) {
|
|
967
1023
|
error = err;
|
|
968
1024
|
} finally {
|
|
@@ -973,14 +1029,15 @@
|
|
|
973
1029
|
// The state moved on; repaint from it (only if the person is still on this workflow).
|
|
974
1030
|
if (stillHere()) await loadApp(id).catch(reportErr);
|
|
975
1031
|
else repaintShown();
|
|
976
|
-
showToast(error
|
|
1032
|
+
showToast(errorText(error, REINSTALL_FAILURE), 'info');
|
|
977
1033
|
return;
|
|
978
1034
|
}
|
|
979
1035
|
if (error) {
|
|
980
1036
|
repaintShown();
|
|
981
1037
|
const row = stillHere() && $approvalStrip.querySelector(`.approval-row[data-agent="${CSS.escape(agent)}"] .approval-row-error`);
|
|
982
|
-
|
|
983
|
-
|
|
1038
|
+
const said = errorText(error, REINSTALL_FAILURE);
|
|
1039
|
+
if (row) row.textContent = (error.body && error.body.code === 'reinstall-failed') ? `${said} You can try again, or Compile again.` : said;
|
|
1040
|
+
else showToast(said, 'warn'); // the person moved on: the failure still reaches them
|
|
984
1041
|
return;
|
|
985
1042
|
}
|
|
986
1043
|
if (stillHere()) await loadApp(id).catch(reportErr);
|
|
@@ -988,7 +1045,7 @@
|
|
|
988
1045
|
if (typeof loadAgentCatalog === 'function') {
|
|
989
1046
|
loadAgentCatalog().catch((err) => console.warn('[floless] the Agents list could not be refreshed after a reinstall', err));
|
|
990
1047
|
}
|
|
991
|
-
showToast(
|
|
1048
|
+
showToast(outcome.message, outcome.reinstalled === true ? 'ok' : 'warn');
|
|
992
1049
|
});
|
|
993
1050
|
}
|
|
994
1051
|
|
|
@@ -1127,7 +1184,8 @@
|
|
|
1127
1184
|
if (err.body && err.body.statement && policyView) { policyView.statement = err.body.statement; policyView.statementSha256 = err.body.statementSha256; renderPolicyModal(); }
|
|
1128
1185
|
t.disabled = false; t.removeAttribute('aria-busy'); t.textContent = prev;
|
|
1129
1186
|
const $e = $policyModal.querySelector('.policy-error') || $err;
|
|
1130
|
-
if ($e) $e.textContent = err
|
|
1187
|
+
if ($e) $e.textContent = errorText(err, { action: off ? 'turn automatic tool updates off' : 'turn automatic tool updates on',
|
|
1188
|
+
unsure: 'Reopen this setting to see whether it changed before trying again.' });
|
|
1131
1189
|
}
|
|
1132
1190
|
}
|
|
1133
1191
|
});
|
|
@@ -1199,11 +1257,79 @@
|
|
|
1199
1257
|
}
|
|
1200
1258
|
|
|
1201
1259
|
// Run's own outcome is authoritative, even if a Stop acknowledgement was lost or arrived later.
|
|
1202
|
-
|
|
1260
|
+
/**
|
|
1261
|
+
* #3253: the workflow's FloLess steps are set to reach another FloLess on this computer (it was approved while that one
|
|
1262
|
+
* was in charge). Ask before anything starts: compile and approve it here (the default), run it anyway, or cancel. On an
|
|
1263
|
+
* AWARE that can point at only one FloLess, compiling here would not help yet, so that choice is replaced by what does.
|
|
1264
|
+
*/
|
|
1265
|
+
async function askRunElsewhere(elsewhere, { routine = false } = {}) {
|
|
1266
|
+
const port = Number.isInteger(elsewhere.port) ? ` The other FloLess is on port ${elsewhere.port}.` : '';
|
|
1267
|
+
const what = 'Its FloLess steps (the ones that use your FloLess projects, and its AI steps) are set to reach another FloLess '
|
|
1268
|
+
+ 'running on this computer. If it runs as it is, they would read that FloLess’s projects instead of yours, and its AI steps would not start.';
|
|
1269
|
+
const sub = elsewhere.overlay
|
|
1270
|
+
? `${what} That happened because it was approved while the other FloLess was in charge. `
|
|
1271
|
+
+ `${routine ? 'Open the workflow, then compile and approve it there' : 'Compile and approve it here'} to point it at this FloLess.${port}`
|
|
1272
|
+
: `${what} Compiling it here would not change that yet: your version of AWARE (the engine FloLess runs on) can point at only one `
|
|
1273
|
+
+ 'FloLess at a time, and the other FloLess holds it. Update AWARE and then compile and approve it here, or close the other '
|
|
1274
|
+
+ `FloLess and restart this one so it takes over, or run it anyway.${port}`;
|
|
1275
|
+
const commandIds = { confirm: routine ? 'shell.run-elsewhere-open' : 'shell.run-elsewhere-approve',
|
|
1276
|
+
discard: 'shell.run-elsewhere-anyway', cancel: 'shell.dialog-cancel#the another-FloLess prompt' };
|
|
1277
|
+
const choice = await confirmUnsavedSwitch('', sub, 'This workflow is set up for another FloLess',
|
|
1278
|
+
elsewhere.overlay ? { confirm: routine ? 'Open the workflow' : 'Compile and approve here', discard: 'Run anyway', cancel: 'Cancel', commandIds }
|
|
1279
|
+
: { hideSave: true, discard: 'Run anyway', cancel: 'Cancel', initialFocus: 'cancel', commandIds });
|
|
1280
|
+
return choice === 'save' ? 'approve' : choice === 'discard' ? 'anyway' : 'cancel';
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* #3253: POST a run (a routine's Run now, a live run) and, while the server answers that its FloLess steps reach another
|
|
1285
|
+
* FloLess, ask; "Run anyway" posts again naming the endpoints shown, and other endpoints ask again. Not running throws a
|
|
1286
|
+
* not-run answer the caller already shows; "Compile and approve here" (or "Open the workflow") calls `onApprove` first.
|
|
1287
|
+
*/
|
|
1288
|
+
async function postAskingElsewhere(url, body, { routine = false, onApprove } = {}) {
|
|
1289
|
+
let send = body;
|
|
1290
|
+
for (;;) {
|
|
1291
|
+
try {
|
|
1292
|
+
return await api(url, { method: 'POST', body: JSON.stringify(send) });
|
|
1293
|
+
} catch (error) {
|
|
1294
|
+
if (!(error && error.status === 409 && error.body && error.body.code === 'floless-steps-elsewhere' && error.body.elsewhere)) throw error;
|
|
1295
|
+
const choice = await askRunElsewhere(error.body.elsewhere, { routine });
|
|
1296
|
+
if (choice !== 'anyway') {
|
|
1297
|
+
if (choice === 'approve' && onApprove) await onApprove();
|
|
1298
|
+
throw Object.assign(new Error('Run stopped before execution started.'), { body: { notRun: true, elsewhereStopped: true, error: 'Run stopped before execution started.' } });
|
|
1299
|
+
}
|
|
1300
|
+
send = { ...body, runElsewhere: error.body.elsewhere.signature };
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
/**
|
|
1306
|
+
* `retrack` (a tracked run only) starts a fresh tracked attempt for a Run anyway resend and returns its token: the
|
|
1307
|
+
* refused attempt ended under its own token, before, during or after the ask, and its ending must never settle,
|
|
1308
|
+
* or drop the saved token of, the run that actually goes ahead.
|
|
1309
|
+
*/
|
|
1310
|
+
async function dispatchManualRun(request, payload, retrack) {
|
|
1203
1311
|
let result, error;
|
|
1204
1312
|
try {
|
|
1205
1313
|
result = await api('/api/run', { method: 'POST', body: JSON.stringify({ ...payload, runRequestId: request.id }) });
|
|
1206
1314
|
} catch (caught) { error = caught; }
|
|
1315
|
+
// #3253: asked again for as long as the server answers with other endpoints than the ones the person accepted.
|
|
1316
|
+
while (error && error.status === 409 && error.body && error.body.code === 'floless-steps-elsewhere' && error.body.elsewhere) {
|
|
1317
|
+
const { signature } = error.body.elsewhere;
|
|
1318
|
+
const choice = await askRunElsewhere(error.body.elsewhere);
|
|
1319
|
+
if (choice !== 'anyway') {
|
|
1320
|
+
if (choice === 'approve' && $compileBtn && !$compileBtn.disabled) $compileBtn.click();
|
|
1321
|
+
error = Object.assign(new Error('Run stopped before execution started.'), { body: { cancelled: true, error: 'Run stopped before execution started.' } });
|
|
1322
|
+
break;
|
|
1323
|
+
}
|
|
1324
|
+
// A new request id: the refused one is finished on the server. "Run anyway" covers exactly the endpoints shown;
|
|
1325
|
+
// if they changed meanwhile, the server answers with the new ones and the loop asks again.
|
|
1326
|
+
request.id = crypto.randomUUID();
|
|
1327
|
+
if (payload.clientRunToken && retrack) payload = { ...payload, clientRunToken: retrack() };
|
|
1328
|
+
error = undefined;
|
|
1329
|
+
try {
|
|
1330
|
+
result = await api('/api/run', { method: 'POST', body: JSON.stringify({ ...payload, runRequestId: request.id, runElsewhere: signature }) });
|
|
1331
|
+
} catch (caught) { error = caught; }
|
|
1332
|
+
}
|
|
1207
1333
|
// A Stop reply can disappear even after the server has settled this run. Its acknowledgement
|
|
1208
1334
|
// cannot hold the authoritative result hostage or change it after completion.
|
|
1209
1335
|
request.settled = true;
|
|
@@ -1274,6 +1400,8 @@
|
|
|
1274
1400
|
if (gateState === 'ready' && app.approvalCheck && app.approvalCheck.bridgeWarnings && app.approvalCheck.bridgeWarnings.length) {
|
|
1275
1401
|
gateTips.ready += '\nBridge needs attention. Review the warning and choices above the canvas. Run workflow is still available; the run record will note the warning.';
|
|
1276
1402
|
}
|
|
1403
|
+
const tooOld = gateState !== 'draft' ? awareTooOldFor(app.id) : null;
|
|
1404
|
+
if (tooOld) gateTips[gateState] = `Needs a newer AWARE.\n${awareTooOldSentence(tooOld)}`;
|
|
1277
1405
|
$runState.dataset.tip = activeTips[status.label] || gateTips[gateState] || '';
|
|
1278
1406
|
|
|
1279
1407
|
// Push a snapshot to the Instructor band. One-way: the band renders what it
|
|
@@ -1287,6 +1415,8 @@
|
|
|
1287
1415
|
statusLabel: status.label,
|
|
1288
1416
|
// #1996: what the Instructor says for a not-confirmed carried-forward approval or an incomplete record.
|
|
1289
1417
|
remedy: (app.approvalCheck && app.approvalCheck.remedy) || null,
|
|
1418
|
+
// #3234: comes before every other state: nothing else can be done until AWARE is upgraded.
|
|
1419
|
+
awareTooOld: tooOld ? { minimum: tooOld.minimum } : null,
|
|
1290
1420
|
recordIncomplete: recordNeedsCheck(app, gateState),
|
|
1291
1421
|
bridgeWarning: !!(app.approvalCheck && app.approvalCheck.bridgeWarnings && app.approvalCheck.bridgeWarnings.length),
|
|
1292
1422
|
totalInputs: inputs.length,
|
|
@@ -1314,7 +1444,10 @@
|
|
|
1314
1444
|
if ($stopRunBtn) $stopRunBtn.hidden = !(reportRunning || state.running || foregroundStopping || foregroundTrigger);
|
|
1315
1445
|
syncReportStopControls();
|
|
1316
1446
|
const agentChanged = gateStateFor(app) === 'agent-changed';
|
|
1317
|
-
|
|
1447
|
+
const awareTooOld = awareTooOldFor(app.id);
|
|
1448
|
+
$runBtn.dataset.tip = awareTooOld
|
|
1449
|
+
? `This workflow needs AWARE ${awareTooOld.minimum} or newer — upgrade AWARE first`
|
|
1450
|
+
: agentChanged
|
|
1318
1451
|
? (app.approvalCheck
|
|
1319
1452
|
? (app.approvalCheck.remedy === 'publish'
|
|
1320
1453
|
? 'This workflow changed outside FloLess since it was published — ask AI Chat to publish it again first'
|
|
@@ -1377,20 +1510,26 @@
|
|
|
1377
1510
|
: 'Compile first — there is no approved lock yet, so Bake is blocked.';
|
|
1378
1511
|
}
|
|
1379
1512
|
|
|
1380
|
-
|
|
1513
|
+
// #3234: a built-in runner (AWARE's `script`) that the AWARE here does not have yet. It is part of AWARE itself, so
|
|
1514
|
+
// installing a tool cannot help: say so, and leave it out of the install rows. The server works it out from the CLI
|
|
1515
|
+
// version, so this holds whether or not the tool's manifest is installed.
|
|
1516
|
+
const tooOld = awareTooOldFor(app.id);
|
|
1517
|
+
if (app.notes.length || tooOld) {
|
|
1381
1518
|
const n = app.notes.length;
|
|
1382
1519
|
const missing = missingAgentGroups(app.notes);
|
|
1520
|
+
if (tooOld) for (const id of tooOld.agents) missing.delete(id);
|
|
1383
1521
|
const installed = installedIdSet();
|
|
1384
1522
|
const pending = [...missing.keys()].filter((id) => installingIds.has(id) || missingAgentFailures.has(workflowAgentKey(id)) || (!installed.has(id) && !completedAgentInstalls.has(workflowAgentKey(id))));
|
|
1385
1523
|
const canInstall = pending.filter((id) => !installingIds.has(id));
|
|
1386
1524
|
const unchecked = [...missing.keys()].some((id) => installed.has(id) && !completedAgentInstalls.has(workflowAgentKey(id)));
|
|
1387
1525
|
const nextAction = pending.some((id) => missingAgentFailures.has(workflowAgentKey(id))) ? 'attention' : 'installing';
|
|
1388
1526
|
const ordinaryNotes = app.notes.filter((nt) => !missingAgentId(nt.text));
|
|
1527
|
+
const awareRow = tooOld ? awareTooOldRow(tooOld) : '';
|
|
1389
1528
|
const sig = notesSig(app.notes);
|
|
1390
1529
|
// Strip severity = worst note kind (info < warn < error). Drives colour +
|
|
1391
1530
|
// icon; AWARE 0.48 tags each note with `kind` (#170) so we render by it
|
|
1392
1531
|
// rather than guessing from the text.
|
|
1393
|
-
const worst = app.notes.some((x) => x.kind === 'error') ? 'error'
|
|
1532
|
+
const worst = tooOld || app.notes.some((x) => x.kind === 'error') ? 'error'
|
|
1394
1533
|
: app.notes.some((x) => x.kind === 'warn') ? 'warn' : 'info';
|
|
1395
1534
|
const icon = worst === 'error' ? '✕' : worst === 'warn' ? '⚠' : 'ℹ';
|
|
1396
1535
|
$notesStrip.hidden = false;
|
|
@@ -1399,10 +1538,10 @@
|
|
|
1399
1538
|
$notesStrip.classList.remove('sev-info', 'sev-warn', 'sev-error');
|
|
1400
1539
|
$notesStrip.classList.add('sev-' + worst);
|
|
1401
1540
|
$notesStrip.innerHTML =
|
|
1402
|
-
`<div class="notes-head"><span class="notes-title">${icon} ${missing.size ? (pending.length ? `${pending.length} tool${pending.length === 1 ? ' needs' : 's need'} ${nextAction}` : unchecked ? 'Check tool installations before compiling' : 'Tools installed — compile to refresh checks') : `${n} workflow notice${n === 1 ? '' : 's'}`}</span>` +
|
|
1541
|
+
`<div class="notes-head"><span class="notes-title">${icon} ${tooOld && !missing.size ? 'Needs a newer AWARE' : missing.size ? (pending.length ? `${pending.length} tool${pending.length === 1 ? ' needs' : 's need'} ${nextAction}` : unchecked ? 'Check tool installations before compiling' : 'Tools installed — compile to refresh checks') : `${n} workflow notice${n === 1 ? '' : 's'}`}</span>` +
|
|
1403
1542
|
missingAgentsBulkButton(pending, canInstall) +
|
|
1404
1543
|
`<button class="notes-dismiss" type="button" aria-label="Collapse compiler notes" data-tip="Collapse">×</button></div>` +
|
|
1405
|
-
(missing.size ? `<ul class="missing-agent-list" aria-live="polite">${missingAgentRows(missing)}</ul>` : '') +
|
|
1544
|
+
(awareRow || missing.size ? `<ul class="missing-agent-list" aria-live="polite">${awareRow}${missingAgentRows(missing)}</ul>` : '') +
|
|
1406
1545
|
(ordinaryNotes.length ? `<ul>${ordinaryNotes.map((nt) => `<li><span class="note-kind ${nt.kind}">${nt.kind}</span><code>${escapeHtml(nt.nodeId)}</code> — ${escapeHtml(humanizeNote(nt.text))}</li>`).join('')}</ul>` : '');
|
|
1407
1546
|
// Collapse decision: a remembered choice for this exact note set wins;
|
|
1408
1547
|
// otherwise default to collapsed for benign info-only sets (keep the canvas
|
|
@@ -1626,7 +1765,7 @@
|
|
|
1626
1765
|
} catch (error) {
|
|
1627
1766
|
const copied = await copyToClipboard(markedInstruction(request));
|
|
1628
1767
|
const workspaceProblem = ['instructor-workspace-root-changed', 'instructor-workspace-earlier-generation', 'instructor-workspace-unavailable'].includes(error?.code);
|
|
1629
|
-
showToast(workspaceProblem ? error.
|
|
1768
|
+
showToast(workspaceProblem ? errorText(error, { action: 'start this answer in AI Chat', unsure: 'Your question is saved in Requests; open it there to try again.' })
|
|
1630
1769
|
: `AI Chat couldn’t start this answer. Your question is saved in Requests; open it there to try again.${copied ? ' The question is also copied.' : ''}`, 'err');
|
|
1631
1770
|
try { await loadRequests(); } catch (refreshError) { console.error(refreshError); }
|
|
1632
1771
|
activeInstructorRuns.delete(fingerprint);
|
|
@@ -1805,9 +1944,11 @@
|
|
|
1805
1944
|
} catch (e) {
|
|
1806
1945
|
if (guide) throw e;
|
|
1807
1946
|
if (!building) { reportErr(e); return null; }
|
|
1808
|
-
//
|
|
1809
|
-
//
|
|
1810
|
-
|
|
1947
|
+
// Ours and the AI setup's are marked forPerson; the build route's reply is read again from its body (errorText).
|
|
1948
|
+
// The retry step is the unknown-outcome advice too, so an unexplained failure does not say "try again" twice.
|
|
1949
|
+
const again = 'To try again, use ≡ → New workflow with the same name and place; FloLess picks up the same draft.';
|
|
1950
|
+
const said = errorText(e, { action: 'start building it', unsure: again });
|
|
1951
|
+
showToast(said.includes(again) ? said : `${said} ${again}`, 'warn', { persistent: true });
|
|
1811
1952
|
return null;
|
|
1812
1953
|
}
|
|
1813
1954
|
}
|
|
@@ -1817,12 +1958,12 @@
|
|
|
1817
1958
|
* Guide build uses the AI its Guide conversation uses; ≡ New workflow uses the AI Chat's own choice.
|
|
1818
1959
|
*/
|
|
1819
1960
|
async function buildWorkflowInChat({ buildId, payload, reopen = false }) {
|
|
1820
|
-
if (typeof window.flolessChat?.startWorkflowBuild !== 'function') throw new Error('AI Chat is still starting. Try again in a moment.');
|
|
1961
|
+
if (typeof window.flolessChat?.startWorkflowBuild !== 'function') throw Object.assign(new Error('AI Chat is still starting. Try again in a moment.'), { forPerson: true });
|
|
1821
1962
|
const provider = payload.source === 'guide' ? (window.flolessChat.currentProvider?.() || preferredChatProvider()) : preferredChatProvider();
|
|
1822
|
-
if (!provider) throw new Error('Sign in to Claude or Codex in AI Chat, then build the workflow again.');
|
|
1963
|
+
if (!provider) throw Object.assign(new Error('Sign in to Claude or Codex in AI Chat, then build the workflow again.'), { forPerson: true });
|
|
1823
1964
|
// Reopening a started build needs no AI set up first: the conversation opens either way, and says if it can't send.
|
|
1824
1965
|
const ready = reopen ? { ok: true } : await ensureChatRuntimeReady(provider);
|
|
1825
|
-
if (!ready.ok) throw Object.assign(new Error(ready.reason || 'Claude or Codex could not be set up for AI Chat. Try again in a moment.'), { code: 'chat-runtime-not-ready' });
|
|
1966
|
+
if (!ready.ok) throw Object.assign(new Error(ready.reason || 'Claude or Codex could not be set up for AI Chat. Try again in a moment.'), { code: 'chat-runtime-not-ready', forPerson: true });
|
|
1826
1967
|
const result = await window.flolessChat.startWorkflowBuild(buildId, payload.source === 'menu' ? { ...payload, provider } : payload);
|
|
1827
1968
|
try { ({ workflows: wfOwned } = await api('/api/workflows/owned')); } catch { /* the next refresh lists it */ }
|
|
1828
1969
|
return result;
|
|
@@ -2975,12 +3116,13 @@
|
|
|
2975
3116
|
// status-bar app like hello-world runs exec yet emits no HTML, so it has no
|
|
2976
3117
|
// report-viewer node (and Run must fill the trace, not open an empty viewer).
|
|
2977
3118
|
// The code test matches `html` in anonymous-object-property position only —
|
|
2978
|
-
// `html =` OR shorthand `html` (preceded by `{`/`,`, followed by `=`/`,`/`}`)
|
|
2979
|
-
// — so a local `html` variable in a
|
|
3119
|
+
// `html =` OR shorthand `html` (preceded by `{`/`,`, followed by `=`/`,`/`}`), or a JavaScript
|
|
3120
|
+
// `html:` (#3234: a script step returns a plain object) — so a local `html` variable in a
|
|
3121
|
+
// non-report node doesn't false-qualify it.
|
|
2980
3122
|
const producesHtml = app.nodes.some((n) => {
|
|
2981
3123
|
const cfg = n.config;
|
|
2982
3124
|
if (!cfg) return false;
|
|
2983
|
-
if (typeof cfg.code === 'string' && /[,{]\s*html\s*[
|
|
3125
|
+
if (typeof cfg.code === 'string' && /[,{]\s*html\s*[=:,}]/.test(cfg.code)) return true;
|
|
2984
3126
|
if (cfg.args && typeof cfg.args === 'object') {
|
|
2985
3127
|
for (const v of Object.values(cfg.args)) {
|
|
2986
3128
|
if (typeof v === 'string' && /\{\{\s*[\w.-]+\.result\.html\s*\}\}/.test(v)) return true;
|
|
@@ -4156,10 +4298,10 @@
|
|
|
4156
4298
|
const version = Number(link.dataset.version);
|
|
4157
4299
|
void (async () => {
|
|
4158
4300
|
try {
|
|
4159
|
-
if (typeof window.flolessPages?.open !== 'function') throw new Error('
|
|
4301
|
+
if (typeof window.flolessPages?.open !== 'function') throw Object.assign(new Error('FloLess couldn’t open the workflow’s Page, because the Pages viewer is not loaded. Reload FloLess and try again.'), { forPerson: true });
|
|
4160
4302
|
await closeReportViewer();
|
|
4161
4303
|
await window.flolessPages.open(link.dataset.home, link.dataset.page, Number.isInteger(version) && version > 0 ? version : undefined);
|
|
4162
|
-
} catch (e) { showToast(
|
|
4304
|
+
} catch (e) { showToast(errorText(e, { action: 'open the workflow’s Page', retrySafe: true }), 'warn'); }
|
|
4163
4305
|
})();
|
|
4164
4306
|
});
|
|
4165
4307
|
|
|
@@ -4311,9 +4453,9 @@
|
|
|
4311
4453
|
answer = await api(`/api/pages/${encodeURIComponent(home)}/${encodeURIComponent(id)}/versions/${encodeURIComponent(n)}/full-report`);
|
|
4312
4454
|
} catch (error) {
|
|
4313
4455
|
console.warn('full report did not open', error);
|
|
4314
|
-
// The server's reason when it gave one (#3097
|
|
4315
|
-
// the shared sentence for this read, never the browser's "Failed to fetch".
|
|
4316
|
-
showToast(
|
|
4456
|
+
// The server's reason when it gave one, read again from its reply (#3097 errorText); a lost connection or an
|
|
4457
|
+
// unexplained failure gets the shared sentence for this read, never the browser's "Failed to fetch".
|
|
4458
|
+
showToast(errorText(error, { action: 'open the full report', retrySafe: true }), 'warn');
|
|
4317
4459
|
return false;
|
|
4318
4460
|
}
|
|
4319
4461
|
if (typeof answer?.handle !== 'string' || !answer.handle) {
|
|
@@ -4390,6 +4532,7 @@
|
|
|
4390
4532
|
await response.body?.cancel();
|
|
4391
4533
|
if (request !== reportSectionRequest) return false;
|
|
4392
4534
|
$reportFrame.removeAttribute('srcdoc');
|
|
4535
|
+
$reportFrame.dataset.surface = 'light'; // #3233
|
|
4393
4536
|
// Navigate to the real session-gated route. Its restrictive CSP must belong to the
|
|
4394
4537
|
// rendered document itself; a blob: copy would silently lose that response header.
|
|
4395
4538
|
// #2539: which paint this frame load belongs to, and its wait deadline, should the frame find the report busy.
|
|
@@ -4442,7 +4585,7 @@
|
|
|
4442
4585
|
continue;
|
|
4443
4586
|
}
|
|
4444
4587
|
clearCompleteReportView();
|
|
4445
|
-
$reportFrame.srcdoc = '';
|
|
4588
|
+
$reportFrame.srcdoc = ''; delete $reportFrame.dataset.surface;
|
|
4446
4589
|
$reportSub.textContent = 'This report section could not be displayed.';
|
|
4447
4590
|
const status = Number(error?.status);
|
|
4448
4591
|
let remedy = 'Close the viewer and choose View report to retry loading this saved report.';
|
|
@@ -4496,6 +4639,7 @@
|
|
|
4496
4639
|
function paintReport(html, interactive, entry = null) {
|
|
4497
4640
|
runPageView.invalidate(); // #2476: a new paint ends the previous report's Page frame, its lookups and its timers
|
|
4498
4641
|
clearCompleteReportView();
|
|
4642
|
+
paintAiStopBanner(entry && entry.aiStop ? entry.aiStop : null); // #3229: every report says whether its run stopped, or nothing
|
|
4499
4643
|
$reportOpen.hidden = false;
|
|
4500
4644
|
lastPaintedHtml = html || '';
|
|
4501
4645
|
lastPaintedInteractive = !!interactive; // drives the share copy: a 3D model is not a "frozen report"
|
|
@@ -4503,7 +4647,7 @@
|
|
|
4503
4647
|
if ($reportPage) $reportPage.hidden = true; // likewise its Page link (paintReportPageLinks, once it is cached)
|
|
4504
4648
|
if (!interactive && entry && entry.withFiles) { paintReportWithFiles(html, entry); return; }
|
|
4505
4649
|
if (interactive) {
|
|
4506
|
-
$reportFrame.hidden = true; $reportFrame.srcdoc = '';
|
|
4650
|
+
$reportFrame.hidden = true; $reportFrame.srcdoc = ''; delete $reportFrame.dataset.surface;
|
|
4507
4651
|
$reportFrame3d.hidden = false;
|
|
4508
4652
|
$reportFrame3d.src = 'data:text/html;charset=utf-8,' + encodeURIComponent(html);
|
|
4509
4653
|
// A 3D doc IS shareable: AWARE's viewer-3d renders one self-contained HTML file, and the public
|
|
@@ -4516,6 +4660,7 @@
|
|
|
4516
4660
|
} else {
|
|
4517
4661
|
$reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
|
|
4518
4662
|
// #3130: the report's own content rules ride at its top; lastPaintedHtml keeps exactly what the run produced.
|
|
4663
|
+
$reportFrame.dataset.surface = 'light'; // #3233: until the report has loaded and its own text colour can say otherwise
|
|
4519
4664
|
$reportFrame.hidden = false; $reportFrame.srcdoc = window.FlolessReportCsp.withReportCsp(html);
|
|
4520
4665
|
$reportOverlay.hidden = true; $reportOverlay.replaceChildren();
|
|
4521
4666
|
$reportShare.hidden = false;
|
|
@@ -4530,6 +4675,7 @@
|
|
|
4530
4675
|
function paintReportWithFiles(html, entry) {
|
|
4531
4676
|
$reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
|
|
4532
4677
|
$reportFrame.hidden = false;
|
|
4678
|
+
$reportFrame.dataset.surface = 'light'; // #3233
|
|
4533
4679
|
$reportFrame.srcdoc = window.FlolessReportCsp.withReportCsp(html); // #3130
|
|
4534
4680
|
$reportOverlay.hidden = true; $reportOverlay.replaceChildren();
|
|
4535
4681
|
$reportOpen.hidden = true;
|
|
@@ -4537,14 +4683,59 @@
|
|
|
4537
4683
|
runPageView.paint(entry);
|
|
4538
4684
|
}
|
|
4539
4685
|
|
|
4686
|
+
// #3233: the page a report is painted on. A report that paints no background of its own used to show FloLess's dark --bg
|
|
4687
|
+
// through, so a report written for the browser's default light page read as dark grey on near-black. Every report now starts
|
|
4688
|
+
// on a light page, the one a browser gives it; once it has loaded its own text colour decides, so light text written for a
|
|
4689
|
+
// dark page it never painted gets a dark one. A report that declares `color-scheme: dark` gets the browser's own dark page
|
|
4690
|
+
// whatever this says, and a report that paints its own background covers it.
|
|
4691
|
+
let reportColorCanvas = null;
|
|
4692
|
+
/** A CSS colour as sRGB [r, g, b] (0–255), or null. A computed colour keeps the form it was written in (`oklch()`,
|
|
4693
|
+
* `color(srgb …)`), so anything that is not plain rgb() is painted on a 1×1 canvas and read back. */
|
|
4694
|
+
function rgbOfCssColor(color) {
|
|
4695
|
+
const m = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/.exec(color);
|
|
4696
|
+
if (m) return [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
4697
|
+
if (!color) return null;
|
|
4698
|
+
reportColorCanvas ??= document.createElement('canvas');
|
|
4699
|
+
reportColorCanvas.width = reportColorCanvas.height = 1;
|
|
4700
|
+
const ctx = reportColorCanvas.getContext('2d', { willReadFrequently: true });
|
|
4701
|
+
if (!ctx) return null;
|
|
4702
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
4703
|
+
ctx.fillStyle = 'rgba(0, 0, 0, 0)'; // a colour the canvas rejects leaves this, not the last colour read
|
|
4704
|
+
ctx.fillStyle = color;
|
|
4705
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
4706
|
+
const [r, g, b, a] = ctx.getImageData(0, 0, 1, 1).data;
|
|
4707
|
+
return a ? [r, g, b] : null; // nothing painted: a colour the canvas could not read
|
|
4708
|
+
}
|
|
4709
|
+
function reportSurfaceOf(doc) {
|
|
4710
|
+
try {
|
|
4711
|
+
const color = doc?.body && doc.defaultView ? doc.defaultView.getComputedStyle(doc.body).color : '';
|
|
4712
|
+
const rgb = rgbOfCssColor(color);
|
|
4713
|
+
if (!rgb) return 'light';
|
|
4714
|
+
const linear = (c) => { const v = c / 255; return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4; };
|
|
4715
|
+
const luminance = 0.2126 * linear(rgb[0]) + 0.7152 * linear(rgb[1]) + 0.0722 * linear(rgb[2]);
|
|
4716
|
+
// 0.179 is where a colour contrasts equally with white and with black.
|
|
4717
|
+
return luminance > 0.179 ? 'dark' : 'light';
|
|
4718
|
+
} catch { return 'light'; } // an unreadable document keeps the light page
|
|
4719
|
+
}
|
|
4720
|
+
function paintReportSurface() {
|
|
4721
|
+
if (!$reportFrame.dataset.surface) return; // the empty viewer follows the theme
|
|
4722
|
+
let doc = null;
|
|
4723
|
+
try { doc = $reportFrame.contentDocument; } catch { /* not readable: stays light */ }
|
|
4724
|
+
$reportFrame.dataset.surface = reportSurfaceOf(doc);
|
|
4725
|
+
}
|
|
4726
|
+
$reportFrame.addEventListener('load', paintReportSurface);
|
|
4727
|
+
// A report's own dark rules follow the computer's theme, so its text colour can change while it is on screen.
|
|
4728
|
+
try { window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', paintReportSurface); } catch { /* no matchMedia */ }
|
|
4729
|
+
|
|
4540
4730
|
// Reset the viewer to "no report shown": clear BOTH frames + the Open buffer, so a stale
|
|
4541
4731
|
// interactive 3D doc can't linger (its WebGL loop running) behind an overlay, and ↗ Open
|
|
4542
4732
|
// can't reopen a previous app's report. Used by every empty / transition state.
|
|
4543
4733
|
function clearReportFrames() {
|
|
4544
4734
|
runPageView.invalidate(); // #2476
|
|
4545
4735
|
clearCompleteReportView();
|
|
4736
|
+
paintAiStopBanner(null);
|
|
4546
4737
|
$reportOpen.hidden = false;
|
|
4547
|
-
$reportFrame.srcdoc = ''; $reportFrame.hidden = false;
|
|
4738
|
+
$reportFrame.srcdoc = ''; $reportFrame.hidden = false; delete $reportFrame.dataset.surface;
|
|
4548
4739
|
$reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
|
|
4549
4740
|
lastPaintedHtml = '';
|
|
4550
4741
|
showSavedPathActions(''); // no report shown → no saved-file actions
|
|
@@ -5414,18 +5605,24 @@
|
|
|
5414
5605
|
$reportShare.hidden = true; // the frame is blank — only a painted report is shareable
|
|
5415
5606
|
$reportOverlay.hidden = false;
|
|
5416
5607
|
let clientRunToken = null;
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
// the same view the canvas strip uses, so a long render reads the same in both places.
|
|
5608
|
+
const runAppId = currentId;
|
|
5609
|
+
// #2228: the working Flo, what the run is doing, elapsed time and a real bar when the run reports one —
|
|
5610
|
+
// the same view the canvas strip uses, so a long render reads the same in both places. #3253: a Run anyway resend
|
|
5611
|
+
// is watched as a new attempt with a view of its own; this run then holds that one.
|
|
5612
|
+
const trackOverlay = () => {
|
|
5423
5613
|
$reportOverlay.replaceChildren();
|
|
5424
5614
|
const host = mkEl('div', 'rp-host');
|
|
5425
5615
|
$reportOverlay.append(host); // Stop lives in the report header (#reportStop), beside the run it stops
|
|
5426
|
-
clientRunToken = beginLiveRun(
|
|
5616
|
+
clientRunToken = beginLiveRun(runAppId, 'overlay', host,
|
|
5427
5617
|
approvedModelReport ? 'Reading the selected approved model to make a complete, read-only report…' : 'Running the workflow against the live model…');
|
|
5428
5618
|
if (!host.firstChild) $reportOverlay.prepend(runningFlo()); // the view could not mount: keep the working Flo
|
|
5619
|
+
return clientRunToken;
|
|
5620
|
+
};
|
|
5621
|
+
if (opts.debug) {
|
|
5622
|
+
$reportOverlay.innerHTML = `<div>Launching the .NET debugger for <code>${escapeHtml(nodeId)}</code> — a Windows picker will pop; choose your <strong>Visual Studio</strong> to attach to <code>aware-tekla.exe</code>, then step through. The report renders when you let it finish.</div>`;
|
|
5623
|
+
$reportOverlay.prepend(runningFlo());
|
|
5624
|
+
} else {
|
|
5625
|
+
trackOverlay();
|
|
5429
5626
|
}
|
|
5430
5627
|
let liveOutcome = 'failed';
|
|
5431
5628
|
const $reportWatch = document.getElementById('report-watch');
|
|
@@ -5438,10 +5635,12 @@
|
|
|
5438
5635
|
// so VS attaches to aware-tekla.exe; a normal run goes through aware app run.
|
|
5439
5636
|
const res = opts.debug
|
|
5440
5637
|
? await api('/api/debug-node', { method: 'POST', body: JSON.stringify({ id: currentId, nodeId, inputs }) })
|
|
5441
|
-
: await dispatchManualRun(request, { id: app.id, simulate: false, inputs, ...(clientRunToken ? { clientRunToken } : {}) });
|
|
5638
|
+
: await dispatchManualRun(request, { id: app.id, simulate: false, inputs, ...(clientRunToken ? { clientRunToken } : {}) }, trackOverlay);
|
|
5442
5639
|
liveOutcome = 'ok';
|
|
5443
5640
|
const reportVideos = runVideos(res);
|
|
5444
5641
|
if (res && typeof res.mediaWarning === 'string') showToast(res.mediaWarning, 'warn');
|
|
5642
|
+
// #3228: a step that works with FloLess was turned away (another FloLess replaced the connection): say so in plain words.
|
|
5643
|
+
if (res && typeof res.connectionWarning === 'string') showToast(res.connectionWarning, 'warn');
|
|
5445
5644
|
if ($reportWatch && reportVideos.length) {
|
|
5446
5645
|
$reportWatch.hidden = false;
|
|
5447
5646
|
$reportWatch.onclick = () => watchRunVideos(reportVideos, `Rendered by ${app.displayName}`);
|
|
@@ -5471,13 +5670,15 @@
|
|
|
5471
5670
|
$reportSub.innerHTML = `Live 3D view from <code>${escapeHtml(nodeId)}</code>${inputBadge ? ' · ' + escapeHtml(inputBadge) : ''} — drag to orbit, scroll to zoom, click an element to inspect.`;
|
|
5472
5671
|
}
|
|
5473
5672
|
const withFiles = !!(res.report && res.report.withFiles);
|
|
5474
|
-
|
|
5475
|
-
|
|
5673
|
+
// #3229: the run stopped at an AI step's check after this report was made; the viewer says so above it.
|
|
5674
|
+
const aiStop = globalThis.flolessAgentSteps?.stoppedRunView?.(res) ?? null;
|
|
5675
|
+
paintReport(html, interactive, { withFiles, runId: typeof res.runId === 'string' ? res.runId : null, aiStop });
|
|
5676
|
+
if (!interactive) $reportSub.textContent = aiStop ? 'Report created before the run stopped.' : 'Report created from the latest workflow run.';
|
|
5476
5677
|
// If a node wrote an output file, the run reports its path — surface the
|
|
5477
5678
|
// ⧉ Open file / ▤ Reveal buttons and cache it so a later double-click restores them (#209).
|
|
5478
5679
|
const savedPath = res && typeof res.savedPath === 'string' ? res.savedPath : '';
|
|
5479
5680
|
showSavedPathActions(savedPath);
|
|
5480
|
-
lastReportByApp.set(currentId, { nodeId, label: inputBadge, html, interactive, savedPath, withFiles, runId: typeof res.runId === 'string' ? res.runId : null });
|
|
5681
|
+
lastReportByApp.set(currentId, { nodeId, label: inputBadge, html, interactive, savedPath, withFiles, runId: typeof res.runId === 'string' ? res.runId : null, aiStop });
|
|
5481
5682
|
paintReportPageLinks();
|
|
5482
5683
|
$reportModal.dataset.html = '1';
|
|
5483
5684
|
reportReadyNote(app, nodeId);
|
|
@@ -5504,6 +5705,8 @@
|
|
|
5504
5705
|
// in the viewer overlay + a toast. No console.error — the server returns the
|
|
5505
5706
|
// failure in-band, so a failed run isn't a console-worthy fault.
|
|
5506
5707
|
$reportSub.textContent = 'Execution ended without a report.';
|
|
5708
|
+
// #3228: one of its steps could not connect to FloLess; this says why, beside the failure.
|
|
5709
|
+
if (e.body && typeof e.body.connectionWarning === 'string') showToast(e.body.connectionWarning, 'warn');
|
|
5507
5710
|
// #2796: Try again only once the server has answered that this run ended. With no answer the run may still be
|
|
5508
5711
|
// going on the host, and a second one could do its work twice.
|
|
5509
5712
|
showRunFailure(e.body || {}, runFailureMessage(msg), app, opts.debug || liveOutcome === 'no-answer' ? null : () => runReport(nodeId));
|
|
@@ -5511,7 +5714,7 @@
|
|
|
5511
5714
|
}
|
|
5512
5715
|
} finally {
|
|
5513
5716
|
if (request) finishManualRun(request);
|
|
5514
|
-
|
|
5717
|
+
finishOwnLiveRun(clientRunToken, liveOutcome);
|
|
5515
5718
|
reportRunning = false;
|
|
5516
5719
|
syncRunControls(); // run ended — hide the header Stop, restore Run from the gate
|
|
5517
5720
|
paintReportPageLinks(); // #2539: hidden while the run was in flight; its Page version may already be known
|
|
@@ -5621,6 +5824,29 @@
|
|
|
5621
5824
|
$reportOverlay.innerHTML = `<div>Run completed but <code>${escapeHtml(nodeId)}</code> returned no <code>html</code>. Check the Execution tab.</div>`;
|
|
5622
5825
|
}
|
|
5623
5826
|
|
|
5827
|
+
// #3229: the report shown was made before the run stopped at an AI step's check (`view` from flolessAgentSteps.stoppedRunView),
|
|
5828
|
+
// or null to hide the banner. Above the frame, never over it, and not dismissible: it goes with the next run or report.
|
|
5829
|
+
// textContent only — the step id comes from the run.
|
|
5830
|
+
function paintAiStopBanner(view) {
|
|
5831
|
+
const banner = document.getElementById('report-ai-stop');
|
|
5832
|
+
if (!banner) return;
|
|
5833
|
+
banner.replaceChildren();
|
|
5834
|
+
banner.hidden = !view;
|
|
5835
|
+
if (!view) return;
|
|
5836
|
+
const appId = currentId;
|
|
5837
|
+
const open = mkEl('button', 'ghost report-ai-stop-open', view.button);
|
|
5838
|
+
open.type = 'button';
|
|
5839
|
+
open.dataset.commandId = view.commandId;
|
|
5840
|
+
open.onclick = async () => {
|
|
5841
|
+
let shown = false;
|
|
5842
|
+
try { shown = await globalThis.flolessAgentSteps?.openQuestions(appId, view.runId, () => hideModal($reportModal)) === true; } catch { shown = false; }
|
|
5843
|
+
if (shown) return;
|
|
5844
|
+
showToast('FloLess couldn’t show this run in Last run yet. Close the viewer, then open Last run above the canvas.', 'warn');
|
|
5845
|
+
open.focus();
|
|
5846
|
+
};
|
|
5847
|
+
banner.append(mkEl('span', 'report-ai-stop-status', 'Needs you'), mkEl('span', 'report-ai-stop-text', view.banner), open);
|
|
5848
|
+
}
|
|
5849
|
+
|
|
5624
5850
|
// #2415: the run stopped before the report because an AI step did not answer. Not a fault, so no Report this problem:
|
|
5625
5851
|
// the way on is the step's questions, in the canvas's Last run panel. textContent only — step names come from the run.
|
|
5626
5852
|
function showAiStepStopped(view, appId) {
|
|
@@ -5768,6 +5994,14 @@
|
|
|
5768
5994
|
$cancel.textContent = (actionLabels && actionLabels.cancel) || 'Cancel';
|
|
5769
5995
|
$dont.hidden = !!(actionLabels && actionLabels.hideDiscard);
|
|
5770
5996
|
$save.hidden = !!(actionLabels && actionLabels.hideSave); // when there is nothing safe to save (a refused write)
|
|
5997
|
+
// A caller that gives the buttons another meaning names it, so Instructor explains what they do here.
|
|
5998
|
+
const ownIds = [$save, $dont, $cancel].map((b) => b.getAttribute('data-command-id'));
|
|
5999
|
+
const ids = actionLabels && actionLabels.commandIds;
|
|
6000
|
+
if (ids) {
|
|
6001
|
+
if (ids.confirm) $save.setAttribute('data-command-id', ids.confirm);
|
|
6002
|
+
if (ids.discard) $dont.setAttribute('data-command-id', ids.discard);
|
|
6003
|
+
if (ids.cancel) $cancel.setAttribute('data-command-id', ids.cancel);
|
|
6004
|
+
}
|
|
5771
6005
|
$title.textContent = titleMsg || 'Unsaved input changes'; // reset each call (default = the inputs-switch copy)
|
|
5772
6006
|
$sub.textContent = subMsg || `You changed the inputs for “${appName}” but haven’t saved them yet. What would you like to do?`;
|
|
5773
6007
|
showModal($confirmModal);
|
|
@@ -5786,6 +6020,7 @@
|
|
|
5786
6020
|
});
|
|
5787
6021
|
$dont.hidden = false;
|
|
5788
6022
|
$save.hidden = false;
|
|
6023
|
+
[$save, $dont, $cancel].forEach((b, i) => { if (ownIds[i] !== null) b.setAttribute('data-command-id', ownIds[i]); });
|
|
5789
6024
|
document.removeEventListener('keydown', onKey, true);
|
|
5790
6025
|
$save.onclick = $dont.onclick = $cancel.onclick = $confirmModal.onclick = null;
|
|
5791
6026
|
if (returnFocus && returnFocus.isConnected && !returnFocus.matches(':disabled,[aria-disabled="true"]')) returnFocus.focus();
|
|
@@ -6745,7 +6980,7 @@
|
|
|
6745
6980
|
// #2539: a busy report is waited for here too, saying why, and the object opens by itself.
|
|
6746
6981
|
if (error?.body?.code !== 'report-busy' || Date.now() >= waitUntil) throw error;
|
|
6747
6982
|
if (stale()) { leave(); return; } // a busy answer for a lookup already replaced writes nothing
|
|
6748
|
-
$reportObjectError.textContent =
|
|
6983
|
+
$reportObjectError.textContent = personText(error.body) || 'This report is busy. It opens as soon as that finishes.';
|
|
6749
6984
|
$reportObjectError.hidden = false;
|
|
6750
6985
|
await new Promise((resolve) => setTimeout(resolve, Math.min(10_000, Math.max(500, Number(error.body.retryAfterMs) || 2_000))));
|
|
6751
6986
|
if (stale()) { leave(); return; }
|
|
@@ -6759,7 +6994,7 @@
|
|
|
6759
6994
|
if (stale()) { leave(); return; }
|
|
6760
6995
|
$reportObjectError.textContent = error?.body?.code === 'report-busy'
|
|
6761
6996
|
? 'This report is still busy. Choose Go again to open that object.'
|
|
6762
|
-
: error
|
|
6997
|
+
: errorText(error, { action: 'find that object', retrySafe: true });
|
|
6763
6998
|
$reportObjectError.hidden = false;
|
|
6764
6999
|
}
|
|
6765
7000
|
};
|
|
@@ -6798,7 +7033,7 @@
|
|
|
6798
7033
|
// #2539: busy is not a failure of access; the report is there, it is just being read.
|
|
6799
7034
|
showToast(error?.body?.code === 'report-busy'
|
|
6800
7035
|
? 'This report is busy, so it can’t be downloaded yet. Choose Download complete report again in a moment.'
|
|
6801
|
-
: error
|
|
7036
|
+
: errorText(error, { action: 'download the complete report', retrySafe: true }), 'warn');
|
|
6802
7037
|
}
|
|
6803
7038
|
};
|
|
6804
7039
|
|
|
@@ -6828,7 +7063,7 @@
|
|
|
6828
7063
|
try {
|
|
6829
7064
|
// The report stays open until the Page is known to open (beforeShow); a Page that cannot be opened says why and leaves it.
|
|
6830
7065
|
await window.flolessPages.open(page.home, page.pageId, page.version, { share: true, beforeShow: () => closeReportViewer() });
|
|
6831
|
-
} catch (e) { showToast(
|
|
7066
|
+
} catch (e) { showToast(errorText(e, { action: 'open the workflow’s Page to share it', retrySafe: true }), 'warn'); }
|
|
6832
7067
|
return;
|
|
6833
7068
|
}
|
|
6834
7069
|
// Share exactly what's on screen — the HTML we painted — so the link can never carry a different
|
|
@@ -6977,9 +7212,18 @@
|
|
|
6977
7212
|
if (currentId !== newId) { showToast(`${name} is compiled.`, 'ok'); return; } // a newer choice won while it was opening
|
|
6978
7213
|
const app = apps.get(newId);
|
|
6979
7214
|
const consent = globalThis.flolessAgentSteps?.consentStatus ? await globalThis.flolessAgentSteps.consentStatus(newId) : null;
|
|
7215
|
+
// #3284: the answer is about this version's confirmation, so it is never said over another workflow opened while it was read.
|
|
7216
|
+
if (currentId !== newId) { showToast(`${name} is compiled.`, 'ok'); return; }
|
|
6980
7217
|
const unconfirmed = consent && (consent.state === 'needed' || consent.state === 'changed');
|
|
6981
7218
|
if (unconfirmed) {
|
|
6982
7219
|
showToast('Workflow compiled. Confirm its AI step before it runs.', 'ok');
|
|
7220
|
+
} else if (app?.runnable && consent?.state === 'current' && consent.latest?.onOtherVersion) {
|
|
7221
|
+
// #3284: not asked, because the step is what the person ticked; the new version's write warning is still theirs to see.
|
|
7222
|
+
const kept = (consent.steps?.length ?? 1) > 1
|
|
7223
|
+
? 'Workflow compiled. The AI steps are unchanged, so the earlier confirmation that their answers may differ each run still stands.'
|
|
7224
|
+
: 'Workflow compiled. The AI step is unchanged, so the earlier confirmation that its answer may differ each run still stands.';
|
|
7225
|
+
if (consent.carriedWarning) standingToast('compile', `${kept} ${consent.carriedWarning}`, 'warn');
|
|
7226
|
+
else { standingToast('compile'); showToast(kept, 'ok'); }
|
|
6983
7227
|
} else {
|
|
6984
7228
|
compiledToast(app);
|
|
6985
7229
|
}
|
|
@@ -7727,9 +7971,8 @@
|
|
|
7727
7971
|
await window.flolessChat.openVerifiedTeklaDraft(receipt);
|
|
7728
7972
|
} catch (e) {
|
|
7729
7973
|
console.warn('Continue in AI Chat failed', e);
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
: 'FloLess could not open AI Chat. Open a project or workflow, then verify the model read again.', 'warn');
|
|
7974
|
+
// AI Chat's own refusals are marked forPerson (chat.js); anything else gets the shared sentence (#3097 errorText).
|
|
7975
|
+
showToast(errorText(e, { action: 'open AI Chat', unsure: 'Open a project or workflow, then verify the model read again.' }), 'warn');
|
|
7733
7976
|
return;
|
|
7734
7977
|
}
|
|
7735
7978
|
closeGraftModal();
|
|
@@ -8227,8 +8470,9 @@
|
|
|
8227
8470
|
}
|
|
8228
8471
|
// A file FloLess could not read is a 400. The Workspace refusing to keep it (no Workspace folder, a folder it
|
|
8229
8472
|
// cannot write) is labelled by the server, whose sentence names why. Anything else is unconfirmed: it may have been kept.
|
|
8230
|
-
|
|
8231
|
-
|
|
8473
|
+
const workspaceSaid = body && body.stage === 'workspace' ? personText(body) : '';
|
|
8474
|
+
showToast(workspaceSaid
|
|
8475
|
+
? `We couldn’t save that workflow to your Workspace: ${workspaceSaid.replace(/[.\s]+$/, '')}. Try again.`
|
|
8232
8476
|
// Only a 400 is a verdict on the file; a lost response (no status) may follow a kept draft.
|
|
8233
8477
|
: e && e.status === 400
|
|
8234
8478
|
? 'We couldn’t import that workflow because FloLess could not read it. Check the file, then try again.'
|
|
@@ -8700,12 +8944,16 @@
|
|
|
8700
8944
|
}
|
|
8701
8945
|
if (!r.ok || !d.ok) throw new Error(d.error || 'update failed');
|
|
8702
8946
|
// Success: the server is exiting + Update.exe relaunches the new build. The health
|
|
8703
|
-
// poll flips to offline
|
|
8947
|
+
// poll flips to offline, and the card says FloLess is updating (not that it stopped
|
|
8948
|
+
// responding); then the new version reconnects on its own.
|
|
8949
|
+
markAppUpdateRelaunch(v);
|
|
8704
8950
|
// Recovery guard: if the relaunch never happens and this page stays alive (e.g. a UAC
|
|
8705
8951
|
// prompt was declined after the server already responded), re-enable the pill after 90 s
|
|
8706
8952
|
// so the user can retry — the page won't go offline in that case.
|
|
8707
8953
|
_appUpdateRecoveryTimer = setTimeout(() => {
|
|
8708
8954
|
_appUpdateRecoveryTimer = null;
|
|
8955
|
+
// FloLess never went away for the update: a later outage is not this update.
|
|
8956
|
+
if (serverState !== 'updating') clearAppUpdateRelaunch();
|
|
8709
8957
|
if ($appUpdate && $appUpdate.disabled) {
|
|
8710
8958
|
$appUpdate.disabled = false;
|
|
8711
8959
|
_updateApplying = null; // relaunch never happened — release the lock so retry works
|
|
@@ -8715,6 +8963,7 @@
|
|
|
8715
8963
|
}
|
|
8716
8964
|
}, 90_000);
|
|
8717
8965
|
} catch (e) {
|
|
8966
|
+
clearAppUpdateRelaunch();
|
|
8718
8967
|
$appUpdate.disabled = false;
|
|
8719
8968
|
_updateApplying = null;
|
|
8720
8969
|
try { localStorage.removeItem('floless.whatsNew.pending'); } catch { /* private mode */ }
|
|
@@ -10200,11 +10449,13 @@
|
|
|
10200
10449
|
liveTrace.length = 0;
|
|
10201
10450
|
state.hasRun = true;
|
|
10202
10451
|
// #2228: a simulated run stubs every node, so it reports no progress; a real one is watched live.
|
|
10203
|
-
|
|
10452
|
+
let clientRunToken = simulate ? null : beginLiveRun(currentId, 'strip');
|
|
10204
10453
|
let liveOutcome = 'failed';
|
|
10205
10454
|
try {
|
|
10206
10455
|
const runAppId = currentId;
|
|
10207
|
-
|
|
10456
|
+
// #3253: a Run anyway resend is watched as a new attempt; this run then holds that one.
|
|
10457
|
+
const retrack = () => (clientRunToken = beginLiveRun(runAppId, 'strip'));
|
|
10458
|
+
const res = await dispatchManualRun(request, { id: app.id, simulate, inputs: currentInputs(), ...(clientRunToken ? { clientRunToken } : {}) }, retrack);
|
|
10208
10459
|
liveOutcome = 'ok';
|
|
10209
10460
|
const videos = runVideos(res);
|
|
10210
10461
|
if (videos.length) { finishLiveRun('ok'); offerRunVideos(runAppId, videos); }
|
|
@@ -10212,11 +10463,20 @@
|
|
|
10212
10463
|
if (res && typeof res.mediaWarning === 'string') showToast(res.mediaWarning, 'warn');
|
|
10213
10464
|
// SSE usually fills liveTrace first; backfill from the response if it didn't.
|
|
10214
10465
|
if (liveTrace.length === 0 && Array.isArray(res.events)) res.events.forEach(pushTrace);
|
|
10215
|
-
// A "succeeded" run carrying a rejected token → prompt reconnect, not a result.
|
|
10216
|
-
|
|
10466
|
+
// A "succeeded" run carrying a rejected token → prompt reconnect, not a result. #3228: a step that could not connect
|
|
10467
|
+
// to FloLess is still said, so the step that did not run is never left unmentioned behind the reconnect prompt.
|
|
10468
|
+
if (res.credentialIssue) {
|
|
10469
|
+
if (typeof res.connectionWarning === 'string') showToast(res.connectionWarning, 'warn');
|
|
10470
|
+
surfaceCredentialIssue(res.credentialIssue); return;
|
|
10471
|
+
}
|
|
10217
10472
|
switchToExecution();
|
|
10218
10473
|
const steps = liveTrace.filter((r) => r.kind === 'node-start').length;
|
|
10219
|
-
|
|
10474
|
+
// #3228: a run can end with a step that works with FloLess turned away; "Run complete" would hide that it did not run.
|
|
10475
|
+
// #3229: a run its AI step's check stopped ended "ok"; the toast says where it stopped, never "Run complete".
|
|
10476
|
+
const aiStop = !simulate ? globalThis.flolessAgentSteps?.stoppedRunView?.(res) ?? null : null;
|
|
10477
|
+
if (res && typeof res.connectionWarning === 'string') standingToast('run', res.connectionWarning, 'warn', false);
|
|
10478
|
+
else if (aiStop) standingToast('run', aiStop.toast, 'warn'); // stays up: it may be the only sign the run did not finish
|
|
10479
|
+
else standingToast('run', simulate ? `Simulated run complete · ${steps} node${steps === 1 ? '' : 's'} stubbed. See the Execution tab.`
|
|
10220
10480
|
: `Run complete · ${steps} node${steps === 1 ? '' : 's'}. See the Execution tab.`, 'ok', false);
|
|
10221
10481
|
} catch (e) {
|
|
10222
10482
|
liveOutcome = (e && e.body && e.body.cancelled) ? 'stopped'
|
|
@@ -10232,7 +10492,8 @@
|
|
|
10232
10492
|
} else {
|
|
10233
10493
|
const cred = e.body && e.body.credentialIssue;
|
|
10234
10494
|
if (cred) {
|
|
10235
|
-
// A rejected token — prompt reconnect for that integration, not the host hint.
|
|
10495
|
+
// A rejected token — prompt reconnect for that integration, not the host hint (#3228: and say the FloLess step too).
|
|
10496
|
+
if (e.body && typeof e.body.connectionWarning === 'string') showToast(e.body.connectionWarning, 'warn');
|
|
10236
10497
|
surfaceCredentialIssue(cred);
|
|
10237
10498
|
} else {
|
|
10238
10499
|
// A failed run is an expected, recoverable outcome (the server returns it
|
|
@@ -10246,14 +10507,16 @@
|
|
|
10246
10507
|
if (e && e.body && (e.body.refusal || notRun)) clearNodeStatus();
|
|
10247
10508
|
// A not-run answer is already a whole sentence ("…, so it didn’t run. …"); "Run failed:" would misstate it.
|
|
10248
10509
|
// Nothing failed — it was declined with a reason — so the toast is informational, not a warning.
|
|
10249
|
-
|
|
10510
|
+
// #3228: the failure was a step that could not connect to FloLess: that sentence says what happened and what to do.
|
|
10511
|
+
const connection = e && e.body && typeof e.body.connectionWarning === 'string' ? e.body.connectionWarning : null;
|
|
10512
|
+
standingToast('run', connection ?? (notRun ? runFailureMessage(msg)
|
|
10250
10513
|
: simulate ? `Simulate failed: ${runFailureMessage(msg).replace(/([^.!?])$/, '$1.')} Simulate can’t check code steps, so ▶ Run workflow is the real test.`
|
|
10251
|
-
: 'Run failed: ' + runFailureMessage(msg), notRun ? 'info' : 'warn');
|
|
10514
|
+
: 'Run failed: ' + runFailureMessage(msg)), notRun && !connection ? 'info' : 'warn');
|
|
10252
10515
|
}
|
|
10253
10516
|
}
|
|
10254
10517
|
} finally {
|
|
10255
10518
|
finishManualRun(request);
|
|
10256
|
-
|
|
10519
|
+
finishOwnLiveRun(clientRunToken, liveOutcome);
|
|
10257
10520
|
state.running = false;
|
|
10258
10521
|
runningSimulation = false;
|
|
10259
10522
|
$runBtn.disabled = false;
|
|
@@ -10397,6 +10660,20 @@
|
|
|
10397
10660
|
let serverOnline = null;
|
|
10398
10661
|
// SSE is newer evidence than a health probe already in flight. Fence all effects of that probe.
|
|
10399
10662
|
let serverObservationEpoch = 0;
|
|
10663
|
+
// What the card says while FloLess is not answering (2026-11-06). A health check that goes unanswered while the
|
|
10664
|
+
// /api/events stream is still open means the FloLess process is alive but busy: a process that exits closes that
|
|
10665
|
+
// connection, and the stream's error moves the card to 'reconnecting' at once. That is weak evidence (a stuck process
|
|
10666
|
+
// keeps its connection open too), so the busy copy only says FloLess may be busy, and offers a refresh after
|
|
10667
|
+
// BUSY_ESCALATE_MS.
|
|
10668
|
+
// 'updating' is an update the person started, which closes FloLess and opens the new version.
|
|
10669
|
+
let serverState = null; // 'online' | 'busy' | 'reconnecting' | 'updating'
|
|
10670
|
+
let eventStreamOpen = false;
|
|
10671
|
+
let appUpdateRelaunch = null; // { version, until } while an update the person started relaunches FloLess
|
|
10672
|
+
let appUpdateRelaunchTimer = null;
|
|
10673
|
+
const BUSY_ESCALATE_MS = 120000; // offer a refresh (it stops nothing)
|
|
10674
|
+
const BUSY_STUCK_MS = 600000; // only then suggest closing FloLess, which stops what it was doing
|
|
10675
|
+
const APP_UPDATE_RELAUNCH_MS = 90000; // how long the card says 'updating' before offering Refresh/Start; matches applyAppUpdate's 90 s recovery guard (a separate literal: keep in step)
|
|
10676
|
+
const APP_UPDATE_RELAUNCH_MAX_MS = 600000; // past this an outage is an ordinary one, whatever was started before
|
|
10400
10677
|
|
|
10401
10678
|
// The overlay leads with AUTO-RECOVERY. The login watchdog (FlolessApp --supervise)
|
|
10402
10679
|
// respawns a dead server within seconds, so a crash heals itself with NO user action
|
|
@@ -10409,6 +10686,8 @@
|
|
|
10409
10686
|
// reliable fallback when the watchdog itself is down is "reopen FloLess", which the
|
|
10410
10687
|
// escalation line offers. The link is a real <a href> the USER clicks — a synthetic
|
|
10411
10688
|
// anchor.click() is silently dropped by Chromium for external protocols.
|
|
10689
|
+
// Since 2026-11-06 the card also says 'Waiting for FloLess…' (busy: Start is never offered, FloLess is running) and
|
|
10690
|
+
// 'Updating FloLess…' (Start after APP_UPDATE_RELAUNCH_MS); SERVER_STATE_ESCALATIONS holds each state's timing.
|
|
10412
10691
|
const ESCALATE_MS = 15000; // 3 missed 5s health polls ⇒ the watchdog isn't recovering
|
|
10413
10692
|
let escalateTimer = null;
|
|
10414
10693
|
let lastFocusBeforeOverlay = null;
|
|
@@ -10435,18 +10714,86 @@
|
|
|
10435
10714
|
const next = at < 0 ? (event.shiftKey ? actions.length - 1 : 0) : (at + (event.shiftKey ? actions.length - 1 : 1)) % actions.length;
|
|
10436
10715
|
actions[next].focus();
|
|
10437
10716
|
}
|
|
10438
|
-
|
|
10439
|
-
|
|
10717
|
+
/** The card's words for one state; `footer` is the status bar label. Never claims more than the window can see. */
|
|
10718
|
+
function serverStateCopy(state) {
|
|
10719
|
+
const desktop = document.documentElement.classList.contains('desktop');
|
|
10720
|
+
const view = desktop ? 'This window' : 'This tab';
|
|
10721
|
+
if (state === 'busy') {
|
|
10722
|
+
return { title: 'Waiting for FloLess…', footer: 'waiting for FloLess',
|
|
10723
|
+
body: `FloLess is still running but hasn’t answered for a while. It may be busy with something large, for example approving a big model. ${view} carries on by itself as soon as FloLess answers.` };
|
|
10724
|
+
}
|
|
10725
|
+
if (state === 'updating') {
|
|
10726
|
+
const what = appUpdateRelaunch?.version ? `version ${appUpdateRelaunch.version}` : 'an update';
|
|
10727
|
+
return { title: 'Updating FloLess…', footer: 'updating FloLess',
|
|
10728
|
+
body: `FloLess is installing ${what} and will open again by itself. Please keep ${view.toLowerCase()} open. It reconnects when FloLess is back.` };
|
|
10729
|
+
}
|
|
10730
|
+
return { title: 'Reconnecting to FloLess…', footer: 'server offline',
|
|
10731
|
+
body: `FloLess isn’t responding. ${desktop ? 'FloLess' : 'This tab'} will keep trying to reconnect.` };
|
|
10732
|
+
}
|
|
10733
|
+
/** What the card says once a state has lasted a while, and which choices it then offers. */
|
|
10734
|
+
const SERVER_STATE_ESCALATIONS = {
|
|
10735
|
+
reconnecting: [{ after: ESCALATE_MS, refresh: true, start: true,
|
|
10736
|
+
text: 'This is taking longer than usual. You can refresh this page, or start FloLess if it is closed.' }],
|
|
10737
|
+
// FloLess is running, so never "Start". Refreshing is offered first because it stops nothing; quitting is advised only
|
|
10738
|
+
// much later, because it does stop what FloLess is doing (a large approval can take several minutes).
|
|
10739
|
+
busy: [
|
|
10740
|
+
{ after: BUSY_ESCALATE_MS, refresh: true, start: false,
|
|
10741
|
+
text: 'Still waiting. Large jobs can take several minutes. Refreshing this page does not stop FloLess.' },
|
|
10742
|
+
{ after: BUSY_STUCK_MS, refresh: true, start: false,
|
|
10743
|
+
text: `FloLess has not answered for ${BUSY_STUCK_MS / 60000} minutes. If nothing changes, close FloLess and open it again. Anything it was working on will stop.` },
|
|
10744
|
+
],
|
|
10745
|
+
// The old FloLess has closed by now, so starting it is a real choice if the new one does not open by itself.
|
|
10746
|
+
updating: [{ after: APP_UPDATE_RELAUNCH_MS, refresh: true, start: true,
|
|
10747
|
+
text: 'This is taking longer than usual. Updates can take a few minutes. If FloLess does not open by itself, start it from the Start menu or desktop shortcut.' }],
|
|
10748
|
+
};
|
|
10749
|
+
/** Say `state` on the card: its words, which choices show, and when it escalates. Restarts the escalation on every
|
|
10750
|
+
* call; setServerStatus calls it only when the state changes, so repeats of one state never restart it. */
|
|
10751
|
+
function applyOverlayState(state) {
|
|
10752
|
+
if (!offlineOverlayEl) return;
|
|
10753
|
+
const copy = serverStateCopy(state);
|
|
10754
|
+
offlineOverlayEl.querySelector('h1').textContent = copy.title;
|
|
10755
|
+
offlineOverlayEl.querySelector('.so-body').textContent = copy.body;
|
|
10756
|
+
const card = offlineOverlayEl.querySelector('.so-card');
|
|
10757
|
+
const focusedChoice = offlineOverlayEl.contains(document.activeElement) && document.activeElement !== card;
|
|
10758
|
+
const show = (step) => {
|
|
10759
|
+
const status = document.getElementById('so-status');
|
|
10760
|
+
if (status) status.textContent = step ? step.text : '';
|
|
10761
|
+
const refresh = document.getElementById('so-refresh');
|
|
10762
|
+
if (refresh) refresh.hidden = !step?.refresh;
|
|
10763
|
+
const start = document.getElementById('so-start');
|
|
10764
|
+
if (start) start.hidden = !step?.start;
|
|
10765
|
+
};
|
|
10766
|
+
show(null);
|
|
10767
|
+
// A choice that just disappeared must not keep focus: back to the card.
|
|
10768
|
+
if (focusedChoice && document.activeElement?.hidden) card.focus();
|
|
10769
|
+
if (escalateTimer) { clearTimeout(escalateTimer); escalateTimer = null; }
|
|
10770
|
+
let at = 0;
|
|
10771
|
+
const next = (steps) => {
|
|
10772
|
+
const step = steps[0];
|
|
10773
|
+
if (!step) return;
|
|
10774
|
+
escalateTimer = setTimeout(() => {
|
|
10775
|
+
escalateTimer = null;
|
|
10776
|
+
if (serverState !== state) return; // healed, or now saying something else
|
|
10777
|
+
show(step);
|
|
10778
|
+
next(steps.slice(1));
|
|
10779
|
+
}, step.after - at);
|
|
10780
|
+
at = step.after;
|
|
10781
|
+
};
|
|
10782
|
+
next(SERVER_STATE_ESCALATIONS[state] || []);
|
|
10783
|
+
}
|
|
10784
|
+
function showOfflineOverlay(state = 'reconnecting') {
|
|
10785
|
+
if (offlineOverlayEl) { applyOverlayState(state); return; }
|
|
10440
10786
|
lastFocusBeforeOverlay = document.activeElement; // restored on heal (WCAG 2.4.3)
|
|
10441
10787
|
const wrap = document.createElement('div');
|
|
10442
10788
|
wrap.id = 'server-offline-overlay';
|
|
10443
|
-
// role=status on the card → screen readers announce its text on insertion
|
|
10444
|
-
// spinner is decorative (aria-hidden). The
|
|
10789
|
+
// role=status on the card → screen readers announce its text on insertion, and its changes
|
|
10790
|
+
// when the state moves (busy → reconnecting). The spinner is decorative (aria-hidden). The
|
|
10791
|
+
// manual choices are hidden until escalation.
|
|
10445
10792
|
wrap.innerHTML =
|
|
10446
|
-
`<div class="so-card" role="status" tabindex="-1">
|
|
10793
|
+
`<div class="so-card" role="status" aria-atomic="true" tabindex="-1">
|
|
10447
10794
|
<div class="so-spinner" aria-hidden="true"></div>
|
|
10448
|
-
<h1
|
|
10449
|
-
<p
|
|
10795
|
+
<h1></h1>
|
|
10796
|
+
<p class="so-body"></p>
|
|
10450
10797
|
<p class="so-status" id="so-status"></p>
|
|
10451
10798
|
<div class="so-actions">
|
|
10452
10799
|
<button type="button" id="so-refresh" data-command-id="app.reconnect-refresh" class="secondary" hidden>Refresh page</button>
|
|
@@ -10470,20 +10817,27 @@
|
|
|
10470
10817
|
}
|
|
10471
10818
|
});
|
|
10472
10819
|
window.addEventListener('keydown', trapOfflineOverlayKeys, true);
|
|
10820
|
+
applyOverlayState(state);
|
|
10473
10821
|
// No action is required, so move focus to the CARD (tabindex=-1), NOT the link —
|
|
10474
10822
|
// keeps keyboard focus inside the overlay without implying the link is the action.
|
|
10475
10823
|
if (!document.getElementById('leave-guard-modal')?.classList.contains('show')) wrap.querySelector('.so-card').focus();
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10824
|
+
}
|
|
10825
|
+
/** An update the person started is closing FloLess and opening the new version: say so while it does. */
|
|
10826
|
+
function markAppUpdateRelaunch(version) {
|
|
10827
|
+
if (appUpdateRelaunchTimer) clearTimeout(appUpdateRelaunchTimer);
|
|
10828
|
+
appUpdateRelaunch = { version: version || null, until: Date.now() + APP_UPDATE_RELAUNCH_MAX_MS };
|
|
10829
|
+
appUpdateRelaunchTimer = setTimeout(clearAppUpdateRelaunch, APP_UPDATE_RELAUNCH_MAX_MS);
|
|
10830
|
+
if (serverOnline === false) setServerStatus(false);
|
|
10831
|
+
}
|
|
10832
|
+
/**
|
|
10833
|
+
* The update is over: FloLess answered again after it (a new build reloads this page instead), the request failed,
|
|
10834
|
+
* or its last window passed. From then on an outage is an ordinary one, and the card says so at once.
|
|
10835
|
+
*/
|
|
10836
|
+
function clearAppUpdateRelaunch() {
|
|
10837
|
+
if (appUpdateRelaunchTimer) { clearTimeout(appUpdateRelaunchTimer); appUpdateRelaunchTimer = null; }
|
|
10838
|
+
if (!appUpdateRelaunch) return;
|
|
10839
|
+
appUpdateRelaunch = null;
|
|
10840
|
+
if (serverOnline === false) setServerStatus(false);
|
|
10487
10841
|
}
|
|
10488
10842
|
function hideOfflineOverlay() {
|
|
10489
10843
|
if (escalateTimer) { clearTimeout(escalateTimer); escalateTimer = null; }
|
|
@@ -10790,11 +11144,12 @@
|
|
|
10790
11144
|
}
|
|
10791
11145
|
} catch (err) {
|
|
10792
11146
|
console.warn('node install did not start', err);
|
|
10793
|
-
// #3097: the server's own reason when it gave one
|
|
10794
|
-
// change, so an unexplained failure asks the person to check before starting it again.
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
11147
|
+
// #3097: the server's own reason when it gave one, read from its reply; otherwise the shared sentence. A start is
|
|
11148
|
+
// a change, so an unexplained failure asks the person to check before starting it again.
|
|
11149
|
+
const said = personText(err && err.body);
|
|
11150
|
+
statusText = said
|
|
11151
|
+
? `Couldn’t start the install. ${said}`
|
|
11152
|
+
: errorText(err, { action: 'start the install', unsure: 'If Windows asks for permission in a moment, allow it; if nothing happens, choose Install again.' });
|
|
10798
11153
|
} finally {
|
|
10799
11154
|
nodeInstall.startInFlight = false;
|
|
10800
11155
|
rerenderBootstrap();
|
|
@@ -11016,6 +11371,7 @@
|
|
|
11016
11371
|
const style = document.createElement('style');
|
|
11017
11372
|
style.textContent = `
|
|
11018
11373
|
footer .status .stat-server .dot.offline{background:var(--err,#f87171);box-shadow:0 0 6px var(--err,#f87171);}
|
|
11374
|
+
footer .status .stat-server .dot.waiting{background:var(--warn,#fbbf24);box-shadow:0 0 6px var(--warn,#fbbf24);}
|
|
11019
11375
|
#server-status-restart{appearance:none;border:1px solid var(--err,#f87171);background:transparent;color:var(--err,#f87171);
|
|
11020
11376
|
font-family:var(--mono,monospace);font-size:11px;cursor:pointer;padding:1px 7px;border-radius:4px;margin-left:2px;text-decoration:none;display:inline-block;}
|
|
11021
11377
|
/* display:inline-block on the ID above would beat the UA [hidden]{display:none}
|
|
@@ -11125,6 +11481,7 @@
|
|
|
11125
11481
|
stat.classList.add('stat-server');
|
|
11126
11482
|
const btn = document.createElement('a'); // real anchor — the href performs the launch
|
|
11127
11483
|
btn.id = 'server-status-restart';
|
|
11484
|
+
btn.dataset.commandId = 'app.footer-restart';
|
|
11128
11485
|
btn.href = 'floless://start';
|
|
11129
11486
|
btn.textContent = '↻ Restart FloLess';
|
|
11130
11487
|
btn.dataset.tip = 'Restart the local server';
|
|
@@ -11136,25 +11493,36 @@
|
|
|
11136
11493
|
});
|
|
11137
11494
|
stat.appendChild(btn);
|
|
11138
11495
|
}
|
|
11496
|
+
/**
|
|
11497
|
+
* One observation of the server (`online`: it answered), turned into ONE state for the footer and the card. Called
|
|
11498
|
+
* again with the same reachability whenever what is known changes (the event stream dropped, an update started or
|
|
11499
|
+
* ended), so the card moves from 'busy' to 'reconnecting' while the server stays unreachable.
|
|
11500
|
+
*/
|
|
11139
11501
|
function setServerStatus(online) {
|
|
11140
11502
|
if (window.__flolessStopped) return; // stopped on purpose — the "FloLess has stopped" screen owns the page
|
|
11141
|
-
if (online === serverOnline) return;
|
|
11142
11503
|
const wasOnline = serverOnline;
|
|
11143
11504
|
serverOnline = online;
|
|
11505
|
+
if (appUpdateRelaunch && Date.now() >= appUpdateRelaunch.until) appUpdateRelaunch = null;
|
|
11506
|
+
const state = online ? 'online' : appUpdateRelaunch ? 'updating' : eventStreamOpen ? 'busy' : 'reconnecting';
|
|
11507
|
+
if (state === serverState) return;
|
|
11508
|
+
const was = serverState;
|
|
11509
|
+
serverState = state;
|
|
11144
11510
|
const stat = document.querySelector('footer .status .stat-server') || document.querySelector('footer .status .stat');
|
|
11145
11511
|
const dot = stat && stat.querySelector('.dot');
|
|
11146
11512
|
const label = stat && stat.querySelector('.stat-val');
|
|
11147
11513
|
const btn = document.getElementById('server-status-restart');
|
|
11148
|
-
if (dot) dot.classList.toggle('offline',
|
|
11149
|
-
if (label) label.textContent = online ? 'runtime online' :
|
|
11150
|
-
if (btn) btn.hidden =
|
|
11514
|
+
if (dot) { dot.classList.toggle('offline', state === 'reconnecting'); dot.classList.toggle('waiting', state === 'busy' || state === 'updating'); }
|
|
11515
|
+
if (label) label.textContent = online ? 'runtime online' : serverStateCopy(state).footer;
|
|
11516
|
+
if (btn) btn.hidden = state !== 'reconnecting'; // FloLess running (busy) or relaunching itself: nothing to start
|
|
11151
11517
|
if (online) {
|
|
11518
|
+
// Answering again after an update the person started: the update is over (a new build reloads this page first).
|
|
11519
|
+
if (was === 'updating') clearAppUpdateRelaunch();
|
|
11152
11520
|
hideOfflineOverlay(); // also clears the escalation timer + restores focus
|
|
11153
11521
|
// Recovered from a boot-time / never-loaded outage: now that the server is
|
|
11154
11522
|
// back, pull the workspace so the canvas fills in instead of staying empty.
|
|
11155
11523
|
if (wasOnline === false && !currentId) loadWorkspaceData();
|
|
11156
11524
|
} else {
|
|
11157
|
-
showOfflineOverlay();
|
|
11525
|
+
showOfflineOverlay(state);
|
|
11158
11526
|
}
|
|
11159
11527
|
}
|
|
11160
11528
|
let shownVersion = false;
|
|
@@ -11295,6 +11663,7 @@
|
|
|
11295
11663
|
function connectionsChangeOf(m) {
|
|
11296
11664
|
if (!m || typeof m !== 'object') return null;
|
|
11297
11665
|
if (m.type === 'connect-result' && m.status === 'connected') return { reason: 'connected', id: typeof m.id === 'string' ? m.id : null };
|
|
11666
|
+
if (m.type === 'disconnect-result') return { reason: m.status === 'disconnected' ? 'disconnected' : 'disconnect-unconfirmed', id: typeof m.id === 'string' ? m.id : null };
|
|
11298
11667
|
if (m.type === 'fs-change' && m.kind === 'credential') return { reason: 'credential', id: null };
|
|
11299
11668
|
if (m.type === 'agent-install-result' && m.ok) return { reason: 'installed', id: typeof m.id === 'string' ? m.id : null };
|
|
11300
11669
|
if (m.type === 'connections-changed') return { reason: 'tool-ready', id: typeof m.id === 'string' ? m.id : null };
|
|
@@ -11332,6 +11701,7 @@
|
|
|
11332
11701
|
window.addEventListener('floless:workspace-root-state', drainPendingCatchup);
|
|
11333
11702
|
es.onopen = () => {
|
|
11334
11703
|
serverObservationEpoch++;
|
|
11704
|
+
eventStreamOpen = true; // the FloLess process is there: an unanswered health check now means busy, not gone
|
|
11335
11705
|
const reconnect = everOpened || rootDisconnected;
|
|
11336
11706
|
everOpened = true;
|
|
11337
11707
|
rootDisconnected = false;
|
|
@@ -11392,25 +11762,7 @@
|
|
|
11392
11762
|
// single-flight and idempotent, so the two racing is fine.
|
|
11393
11763
|
if (window.awareUpdateController) window.awareUpdateController.adopt().catch(() => {});
|
|
11394
11764
|
} else if (m.type === 'run-live' || m.type === 'node-progress' || m.type === 'run-finished') {
|
|
11395
|
-
|
|
11396
|
-
// workflow this tab shows that someone else started is followed read-only (no Stop).
|
|
11397
|
-
// #2241: a run that FAILED after an Agent answered ends with run-finished, not run-ended: its AI record is read then too.
|
|
11398
|
-
if (m.type === 'run-finished' && m.id && m.id === currentId) void globalThis.flolessAgentSteps?.refreshRunRecord(m.id);
|
|
11399
|
-
// Workflows → History: a run starting shows as Running, and a failed run ends with run-finished alone.
|
|
11400
|
-
if (m.type !== 'node-progress') window.flolessRunHistory?.refresh?.();
|
|
11401
|
-
signalRunEvent(m); // the browser tab hears its run's ending even when the strip already settled
|
|
11402
|
-
if (liveRunOwns(m)) {
|
|
11403
|
-
if (m.type === 'run-live') { if (m.runId) { liveRun.runId = m.runId; signalRunNote(liveRun); } }
|
|
11404
|
-
else if (m.type === 'node-progress') onLiveProgress(m);
|
|
11405
|
-
else finishLiveRun(typeof m.outcome === 'string' ? m.outcome : 'failed');
|
|
11406
|
-
} else if (m.id === currentId && !(liveRun && liveRun.owner && !liveRun.ended)) {
|
|
11407
|
-
if (m.type === 'run-finished') {
|
|
11408
|
-
if (liveRun && !liveRun.owner && (!m.runId || m.runId === liveRun.runId)) finishLiveRun(typeof m.outcome === 'string' ? m.outcome : 'failed');
|
|
11409
|
-
} else {
|
|
11410
|
-
if (!liveRun || liveRun.ended || (m.runId && liveRun.runId && m.runId !== liveRun.runId)) observeLiveRun(m);
|
|
11411
|
-
if (m.type === 'node-progress') onLiveProgress(m);
|
|
11412
|
-
}
|
|
11413
|
-
}
|
|
11765
|
+
onRunEvent(m);
|
|
11414
11766
|
} else if (m.type === 'run-media' && Array.isArray(m.media)) {
|
|
11415
11767
|
// #2230: the videos a run rendered, for a tab that lost the Run answer (a reload mid-run). The tab that
|
|
11416
11768
|
// still holds the answer offers them from it; offerRunVideos is idempotent either way.
|
|
@@ -11667,6 +12019,9 @@
|
|
|
11667
12019
|
} else if (slot) {
|
|
11668
12020
|
slot.innerHTML = connectResultSlotHtml(m);
|
|
11669
12021
|
}
|
|
12022
|
+
} else if (m.type === 'disconnect-result') {
|
|
12023
|
+
// #3301: a service was disconnected (here, in another window or from AI Chat): every open Integrations flips.
|
|
12024
|
+
refreshIntegrations();
|
|
11670
12025
|
} else if (m.type === 'fs-change' && m.kind === 'credential') {
|
|
11671
12026
|
// `aware connect`/`disconnect` wrote/removed a token in the local vault —
|
|
11672
12027
|
// refresh the Integrations window so its status reflects reality live.
|
|
@@ -11699,6 +12054,7 @@
|
|
|
11699
12054
|
};
|
|
11700
12055
|
es.onerror = () => {
|
|
11701
12056
|
serverObservationEpoch++;
|
|
12057
|
+
eventStreamOpen = false; // the connection to FloLess closed: an outage, not a busy server
|
|
11702
12058
|
// A later health poll must not borrow a pre-disconnect shared startup probe.
|
|
11703
12059
|
globalThis.flolessStartupAdmission?.invalidate();
|
|
11704
12060
|
connectionGeneration++;
|
|
@@ -12480,20 +12836,21 @@
|
|
|
12480
12836
|
// Refused for another reason once the project was free: say why, exactly as the other start surfaces do.
|
|
12481
12837
|
const notReady = error?.code === 'chat-runtime-not-ready';
|
|
12482
12838
|
const explained = notReady ? '' : chatStartErrorText(error);
|
|
12483
|
-
if (notReady) showToast(error
|
|
12839
|
+
if (notReady) showToast(errorText(error), 'warn');
|
|
12484
12840
|
else reportChatStartErr(error);
|
|
12485
|
-
say(notReady ? error
|
|
12841
|
+
say(notReady ? errorText(error) : explained || `Couldn’t start ${requestLabel(request)} in AI Chat. Try again.`);
|
|
12486
12842
|
}
|
|
12487
12843
|
};
|
|
12488
12844
|
requestStartWaits.set(request.id, setTimeout(tick, REQUEST_START_WAIT_MS));
|
|
12489
12845
|
}
|
|
12490
12846
|
|
|
12491
12847
|
async function startRequestChatWithSetup(requestId, provider, mode, { onSetup, isCancelled = () => false, ownChat = false, restoreFirst = false } = {}) {
|
|
12492
|
-
if (typeof window.flolessChat?.startRequest !== 'function') throw new Error('AI Chat is still starting. Try again in a moment.');
|
|
12848
|
+
if (typeof window.flolessChat?.startRequest !== 'function') throw Object.assign(new Error('AI Chat is still starting. Try again in a moment.'), { forPerson: true });
|
|
12493
12849
|
if (mode === 'start') {
|
|
12494
12850
|
const ready = await ensureChatRuntimeReady(provider, { onProgress: (status) => onSetup?.(status), isCancelled });
|
|
12495
12851
|
if (ready.cancelled || isCancelled()) throw Object.assign(new Error('The start was cancelled.'), { code: 'chat-start-cancelled' });
|
|
12496
|
-
|
|
12852
|
+
// ready.reason is this file's own sentence (ensureChatRuntimeReady), so it is said as written.
|
|
12853
|
+
if (!ready.ok) throw Object.assign(new Error(ready.reason), { code: 'chat-runtime-not-ready', forPerson: true });
|
|
12497
12854
|
}
|
|
12498
12855
|
return window.flolessChat.startRequest(requestId, provider, mode, { ownChat, restoreFirst });
|
|
12499
12856
|
}
|
|
@@ -12773,7 +13130,7 @@
|
|
|
12773
13130
|
if (holder.kind === 'knowledge') {
|
|
12774
13131
|
// #2106: the project's Knowledge step, where its organizing shows.
|
|
12775
13132
|
try { await openKnowledgeStepOf(holder.projectId); }
|
|
12776
|
-
catch (error) { showToast(error
|
|
13133
|
+
catch (error) { showToast(errorText(error, { action: 'open that project’s Knowledge step', unsure: 'Open it from Workspaces.' }), 'warn'); }
|
|
12777
13134
|
return;
|
|
12778
13135
|
}
|
|
12779
13136
|
if (holder.kind === 'chat' && holder.chatId && holder.owner && typeof window.flolessChat?.openConversationIn === 'function') {
|
|
@@ -13494,10 +13851,10 @@
|
|
|
13494
13851
|
// The same refusal handling as the queued rows' start surface (request-chat-start-eligibility.test.ts).
|
|
13495
13852
|
const notReady = error?.code === 'chat-runtime-not-ready';
|
|
13496
13853
|
const explained = notReady ? '' : chatStartErrorText(error);
|
|
13497
|
-
if (notReady) showToast(error
|
|
13854
|
+
if (notReady) showToast(errorText(error), 'warn');
|
|
13498
13855
|
else reportChatStartErr(error);
|
|
13499
13856
|
if (actionStatus) actionStatus.textContent = notReady
|
|
13500
|
-
? error
|
|
13857
|
+
? errorText(error)
|
|
13501
13858
|
: explained || `Couldn’t open ${requestLabel(request)} in AI Chat. Try again.`;
|
|
13502
13859
|
if (!button.isConnected) return;
|
|
13503
13860
|
button.disabled = false;
|
|
@@ -14156,7 +14513,7 @@
|
|
|
14156
14513
|
: 'Its discard record could be read again, so there was nothing to decide.';
|
|
14157
14514
|
discardRecordUi.delete(id);
|
|
14158
14515
|
} catch (error) {
|
|
14159
|
-
discardRecordUi.set(id, { status: error
|
|
14516
|
+
discardRecordUi.set(id, { status: errorText(error, { action: 'record your choice', unsure: 'Check the request below before choosing again.' }) });
|
|
14160
14517
|
await loadRequests().catch(() => {});
|
|
14161
14518
|
renderRequests();
|
|
14162
14519
|
focusDiscardRecordControl(id, choice === 'keep' ? 'keep' : 'ask');
|
|
@@ -14684,11 +15041,11 @@
|
|
|
14684
15041
|
// Refused after Restore: say why in the list as well, exactly as the other start surfaces do.
|
|
14685
15042
|
const notReady = error?.code === 'chat-runtime-not-ready';
|
|
14686
15043
|
const explained = notReady ? '' : chatStartErrorText(error);
|
|
14687
|
-
if (notReady) showToast(error
|
|
15044
|
+
if (notReady) showToast(errorText(error), 'warn');
|
|
14688
15045
|
else reportChatStartErr(error);
|
|
14689
15046
|
await loadRequests().catch(() => {}); renderRequests();
|
|
14690
15047
|
const actionStatus = document.getElementById('requests-action-status');
|
|
14691
|
-
if (actionStatus) actionStatus.textContent = notReady ? error
|
|
15048
|
+
if (actionStatus) actionStatus.textContent = notReady ? errorText(error) : explained || `Couldn’t start ${requestLabel(request)} in AI Chat. Try again.`;
|
|
14692
15049
|
}
|
|
14693
15050
|
}
|
|
14694
15051
|
|
|
@@ -15054,10 +15411,10 @@
|
|
|
15054
15411
|
}
|
|
15055
15412
|
const notReady = error?.code === 'chat-runtime-not-ready';
|
|
15056
15413
|
const explained = notReady ? '' : chatStartErrorText(error);
|
|
15057
|
-
if (notReady) showToast(error
|
|
15414
|
+
if (notReady) showToast(errorText(error), 'warn');
|
|
15058
15415
|
else reportChatStartErr(error);
|
|
15059
15416
|
if (actionStatus) actionStatus.textContent = notReady
|
|
15060
|
-
? error
|
|
15417
|
+
? errorText(error)
|
|
15061
15418
|
: explained || `Couldn’t ${starting ? 'start' : 'open'} ${requestLabel(request)} in AI Chat. Try again.`;
|
|
15062
15419
|
if (notReady || !button.isConnected) {
|
|
15063
15420
|
endStart();
|
|
@@ -15609,10 +15966,10 @@
|
|
|
15609
15966
|
btn.onclick = () => saveAgentCommandTemplate(btn.dataset.agent, btn.dataset.cmd);
|
|
15610
15967
|
});
|
|
15611
15968
|
} catch (e) {
|
|
15612
|
-
// #3097: the server's reason when it gave one
|
|
15969
|
+
// #3097: the server's reason when it gave one, read from its reply, else the shared sentence for this read; never
|
|
15613
15970
|
// "error: " plus the browser's exception text. The error itself goes to the console.
|
|
15614
15971
|
console.warn('agent commands unavailable', id, e);
|
|
15615
|
-
const said =
|
|
15972
|
+
const said = errorText(e, { action: 'load this agent’s commands', retrySafe: true });
|
|
15616
15973
|
box.innerHTML = `<div class="cmd-desc">${escapeHtml(said)}</div>`;
|
|
15617
15974
|
}
|
|
15618
15975
|
}
|
|
@@ -15676,6 +16033,8 @@
|
|
|
15676
16033
|
// "Available" means available-to-install, so already-installed agents live only
|
|
15677
16034
|
// in the Installed tab. agentCatalog holds the installed set (id per item).
|
|
15678
16035
|
function installedIdSet() { return new Set(agentCatalog.map((a) => a.id)); }
|
|
16036
|
+
// A `planned` tool has no runnable program yet (aware-aeco/aware#767): installing it could never make it usable.
|
|
16037
|
+
function offeredForInstall(a, installed) { return !installed.has(a.id) && a.status !== 'planned'; }
|
|
15679
16038
|
|
|
15680
16039
|
function availCardHtml(a) {
|
|
15681
16040
|
const name = escapeHtml(a.display_name || a.id);
|
|
@@ -15738,7 +16097,7 @@
|
|
|
15738
16097
|
}
|
|
15739
16098
|
|
|
15740
16099
|
const installed = installedIdSet();
|
|
15741
|
-
const notInstalled = availableCatalog.filter((a) =>
|
|
16100
|
+
const notInstalled = availableCatalog.filter((a) => offeredForInstall(a, installed));
|
|
15742
16101
|
const q = ($libAvailSearch.value || '').toLowerCase().trim();
|
|
15743
16102
|
const match = (a) => !q
|
|
15744
16103
|
|| a.id.toLowerCase().includes(q)
|
|
@@ -15800,7 +16159,7 @@
|
|
|
15800
16159
|
showToast(`Installing “${nice}” — this can take a minute or two`, 'info');
|
|
15801
16160
|
api('/api/agents/install', { method: 'POST', body: JSON.stringify({ id, ...(appId ? { appId, sourceHash } : {}) }) })
|
|
15802
16161
|
.catch((e) => { // the START failed (bad id / server) — completion errors arrive via SSE
|
|
15803
|
-
recordAgentInstallResult({ id, appId, sourceHash, ok: false, error: e
|
|
16162
|
+
recordAgentInstallResult({ id, appId, sourceHash, ok: false, error: errorText(e, { action: `start installing “${nice}”` }) });
|
|
15804
16163
|
refreshAgentNotes();
|
|
15805
16164
|
if ($libModal && $libModal.classList.contains('show')) renderAvailable();
|
|
15806
16165
|
reportErr(e, 'install this tool');
|
|
@@ -16267,6 +16626,32 @@
|
|
|
16267
16626
|
return granted.drive ? 'Allowed: Gmail sending and Drive file list.' : 'Allowed: Gmail sending. Not allowed: Drive file list (optional).';
|
|
16268
16627
|
}
|
|
16269
16628
|
|
|
16629
|
+
/**
|
|
16630
|
+
* #3295: Microsoft adds every permission approved for FloLess Desktop earlier, so a sign-in can allow more than FloLess
|
|
16631
|
+
* asks for. Information plus a way out, never a gate: the account stays usable and its state is unchanged. The server
|
|
16632
|
+
* lists the extra permissions in words, the ones that write first.
|
|
16633
|
+
*/
|
|
16634
|
+
function microsoftGrantNotice(slot, noticeId) {
|
|
16635
|
+
const grant = slot.microsoftGrant;
|
|
16636
|
+
if (!grant || grant.state !== 'wider' || !Array.isArray(grant.extra) || !grant.extra.length) return '';
|
|
16637
|
+
const shown = grant.extra.slice(0, 4).map((permission) => escapeHtml(permission.meaning));
|
|
16638
|
+
const more = grant.extra.length - shown.length;
|
|
16639
|
+
if (more > 0) shown.push(`and ${more} more`);
|
|
16640
|
+
const what = shown.length <= 2
|
|
16641
|
+
? `: it ${shown.join(' and ')}.`
|
|
16642
|
+
: `. It:<ul class="int-grant-list">${shown.map((line) => `<li>${line}</li>`).join('')}</ul>`;
|
|
16643
|
+
const reconnect = slot.alias ? 'click Reconnect this account' : 'click Reconnect on this card';
|
|
16644
|
+
return `<div class="int-notice is-warn int-grant-notice" role="note" id="${escapeAttr(noticeId)}">`
|
|
16645
|
+
+ '<strong class="int-grant-title">This sign-in allows more than FloLess asked for</strong>'
|
|
16646
|
+
// AWARE does not record which app issued a sign-in, so the approval is "the app this sign-in uses"; revoking FloLess
|
|
16647
|
+
// Desktop and reconnecting (which signs in with it) is the way out either way.
|
|
16648
|
+
+ `<span class="int-grant-body">Microsoft kept permissions from an earlier approval of the app this sign-in uses${what} `
|
|
16649
|
+
+ 'FloLess didn’t ask for them, but while they’re allowed, Microsoft 365 commands run from FloLess can use them. To remove them, sign in at '
|
|
16650
|
+
+ '<a href="https://myapps.microsoft.com" target="_blank" rel="noopener noreferrer">myapps.microsoft.com<span class="sr-only"> (opens in a new tab)</span></a>, '
|
|
16651
|
+
+ `open FloLess Desktop and remove its access, then ${reconnect}. If your organisation approved it, ask your IT admin to remove it. `
|
|
16652
|
+
+ 'You can keep using this account meanwhile.</span></div>';
|
|
16653
|
+
}
|
|
16654
|
+
|
|
16270
16655
|
function renderIntegrationAccounts(integration) {
|
|
16271
16656
|
const slots = Array.isArray(integration.accountSlots) ? integration.accountSlots : [];
|
|
16272
16657
|
if (!slots.length) return integration.chatSupported
|
|
@@ -16317,11 +16702,15 @@
|
|
|
16317
16702
|
? `<span class="int-account-access${slot.granted.gmail ? '' : ' is-warn'}">${escapeHtml(googleAccessLine(slot.granted, slot.alias))}</span>` : '';
|
|
16318
16703
|
// #2649: a named account reconnects on its own whenever it needs a new sign-in or new consent; the card's main
|
|
16319
16704
|
// button is the default account's. Its Drive choice is the card's checkbox, the person's current selection.
|
|
16705
|
+
const grantNoticeId = `int-grant-${integration.id}-${slot.alias || 'default'}`.replace(/[^A-Za-z0-9_-]/g, '-');
|
|
16706
|
+
const grantNotice = integration.id === 'microsoft-365' ? microsoftGrantNotice(slot, grantNoticeId) : '';
|
|
16320
16707
|
const needsSignIn = slot.status !== 'valid' || (slot.granted && !slot.granted.gmail)
|
|
16321
16708
|
|| ['scope-missing', 'identity-unverified', 'credential-expired', 'generation-unavailable'].includes(slot.unavailableCode);
|
|
16322
|
-
|
|
16709
|
+
// A wider Microsoft grant also offers a named account its own Reconnect: the way out after removing the approval.
|
|
16710
|
+
const reconnect = slot.alias && (needsSignIn || grantNotice)
|
|
16323
16711
|
? `<button class="int-action int-account-reconnect" type="button" data-int="${escapeAttr(integration.id)}" data-int-action="connect"`
|
|
16324
16712
|
+ ` data-int-alias="${escapeAttr(slot.alias)}"`
|
|
16713
|
+
+ (grantNotice ? ` aria-describedby="${escapeAttr(grantNoticeId)}"` : '')
|
|
16325
16714
|
+ ` data-command-id="shell.integrations-account-reconnect#${escapeAttr(`${integration.id}:${slot.alias}`)}"`
|
|
16326
16715
|
+ ` data-command-instance-label="${escapeAttr(`${integration.name} account ${slot.alias}`)}"`
|
|
16327
16716
|
+ ` aria-label="Reconnect ${escapeAttr(integration.name)} account ${escapeAttr(slot.alias)}">Reconnect this account</button>`
|
|
@@ -16333,6 +16722,7 @@
|
|
|
16333
16722
|
</div>
|
|
16334
16723
|
<span class="int-chat-state">${state}</span>
|
|
16335
16724
|
${access}
|
|
16725
|
+
${grantNotice}
|
|
16336
16726
|
<span class="int-account-reason">${escapeHtml(why)}</span>
|
|
16337
16727
|
${reconnect}
|
|
16338
16728
|
</div>`;
|
|
@@ -16430,6 +16820,186 @@
|
|
|
16430
16820
|
+ ` data-command-id="shell.integrations-connect#${escapeAttr(i.id)}" data-command-instance-label="${escapeAttr(i.name)}">Reconnect</button>`;
|
|
16431
16821
|
}
|
|
16432
16822
|
|
|
16823
|
+
/**
|
|
16824
|
+
* #3301: the account a card's Disconnect removes — the one its Connected badge stands for (the first signed-in
|
|
16825
|
+
* account, as the server picks it), and how the confirm names it: the verified account, else its FloLess name.
|
|
16826
|
+
*/
|
|
16827
|
+
function disconnectTarget(i) {
|
|
16828
|
+
const slots = Array.isArray(i.accountSlots) ? i.accountSlots : [];
|
|
16829
|
+
const slot = slots.find((s) => s.status === 'valid') || slots[0] || null;
|
|
16830
|
+
const alias = slot && typeof slot.alias === 'string' && slot.alias ? slot.alias : null;
|
|
16831
|
+
const label = slot?.verifiedPrincipal?.presentationLabel || alias || null;
|
|
16832
|
+
return { alias, label };
|
|
16833
|
+
}
|
|
16834
|
+
|
|
16835
|
+
/** The Disconnect button's carriers: the account it removes and its Instructor registration. */
|
|
16836
|
+
function disconnectButtonAttrs(i) {
|
|
16837
|
+
const { alias } = disconnectTarget(i);
|
|
16838
|
+
return ` data-command-id="shell.integrations-disconnect#${escapeAttr(i.id)}" data-command-instance-label="${escapeAttr(i.name)}"`
|
|
16839
|
+
+ (alias ? ` data-int-alias="${escapeAttr(alias)}"` : '');
|
|
16840
|
+
}
|
|
16841
|
+
|
|
16842
|
+
/**
|
|
16843
|
+
* #3301: the Disconnect confirm's words. Names the service and the account, says what stops working and that
|
|
16844
|
+
* connecting again undoes it. An AWARE older than 0.175.0 keeps Google's sign-in for the whole computer
|
|
16845
|
+
* (aware-aeco/aware#782): the server says when that is so (`signOutWholeComputer`, #3334), and only then does it warn.
|
|
16846
|
+
*/
|
|
16847
|
+
function disconnectConfirmCopy(i) {
|
|
16848
|
+
const { alias, label } = disconnectTarget(i);
|
|
16849
|
+
const title = `Disconnect ${i.name}${alias ? ` (${alias})` : ''}?`;
|
|
16850
|
+
const who = label || 'the default account';
|
|
16851
|
+
const sub = `This removes the saved sign-in for ${who} from this computer. Knowledge sources from ${i.name} stop syncing, `
|
|
16852
|
+
+ 'and workflows and AI Chat checks that use it will ask you to sign in again. To undo it, reconnect: click Connect on this card and sign in.';
|
|
16853
|
+
// Other signed-in accounts of the same service keep working; say which, so "disconnect" is not read as the whole service.
|
|
16854
|
+
const slots = Array.isArray(i.accountSlots) ? i.accountSlots : [];
|
|
16855
|
+
const others = slots.filter((s) => s.status === 'valid' && (s.alias || null) !== alias)
|
|
16856
|
+
.map((s) => s.verifiedPrincipal?.presentationLabel || s.alias || 'the default account');
|
|
16857
|
+
const stays = others.length ? ` ${others.join(', ')} stay${others.length === 1 ? 's' : ''} connected.` : '';
|
|
16858
|
+
return { title, sub: sub + stays, alias, google: i.signOutWholeComputer === true };
|
|
16859
|
+
}
|
|
16860
|
+
|
|
16861
|
+
/**
|
|
16862
|
+
* #3301: what a finished Disconnect says, from the route's answer and the card as AWARE now reports it. Nothing was
|
|
16863
|
+
* stored, or the follow-up check could not run: the server's own sentence. Another account still signed in: the card
|
|
16864
|
+
* stays Connected, so it says so and keeps focus on its Disconnect. Otherwise the service is disconnected and Connect
|
|
16865
|
+
* is next.
|
|
16866
|
+
*/
|
|
16867
|
+
function disconnectOutcome(i, result, refreshed) {
|
|
16868
|
+
if (result && typeof result.note === 'string' && result.note) {
|
|
16869
|
+
return { text: result.note, tone: 'info', focus: refreshed?.status === 'connected' ? 'disconnect' : 'connect' };
|
|
16870
|
+
}
|
|
16871
|
+
if (refreshed?.status === 'connected') {
|
|
16872
|
+
const { alias, label } = disconnectTarget(i);
|
|
16873
|
+
const who = label || alias || 'the default account';
|
|
16874
|
+
return { text: `Disconnected ${who} from ${i.name}. Another ${i.name} account is still connected.`, tone: 'ok', focus: 'disconnect' };
|
|
16875
|
+
}
|
|
16876
|
+
return { text: `${i.name} disconnected. Click Connect to sign in again.`, tone: 'ok', focus: 'connect' };
|
|
16877
|
+
}
|
|
16878
|
+
|
|
16879
|
+
/**
|
|
16880
|
+
* #3301: ask, then disconnect in the app. Opens above Integrations (which is inerted while it is up); Cancel holds
|
|
16881
|
+
* focus and Esc or the backdrop cancel, except while the request is out, so its outcome is never lost. A failure stays
|
|
16882
|
+
* here in words, with Try again and the terminal command as a last resort. On success the card is redrawn from AWARE,
|
|
16883
|
+
* the change is announced, and focus moves to the redrawn card's Connect.
|
|
16884
|
+
*/
|
|
16885
|
+
let intDisconnectOpen = false;
|
|
16886
|
+
function confirmIntegrationDisconnect(i) {
|
|
16887
|
+
if (intDisconnectOpen) return;
|
|
16888
|
+
const $modal = document.getElementById('int-disconnect-modal');
|
|
16889
|
+
const $box = $modal.querySelector('.modal');
|
|
16890
|
+
const $title = document.getElementById('int-disconnect-title');
|
|
16891
|
+
const $sub = document.getElementById('int-disconnect-sub');
|
|
16892
|
+
const $google = document.getElementById('int-disconnect-google');
|
|
16893
|
+
const $error = document.getElementById('int-disconnect-error');
|
|
16894
|
+
const $ok = document.getElementById('int-disconnect-ok');
|
|
16895
|
+
const $cancel = document.getElementById('int-disconnect-cancel');
|
|
16896
|
+
const $copy = document.getElementById('int-disconnect-copy');
|
|
16897
|
+
const copy = disconnectConfirmCopy(i);
|
|
16898
|
+
$title.textContent = copy.title;
|
|
16899
|
+
$sub.textContent = copy.sub;
|
|
16900
|
+
$google.hidden = !copy.google;
|
|
16901
|
+
// A hidden notice still reaches a screen reader through aria-describedby, so it is named only when it is shown (#3334).
|
|
16902
|
+
$modal.setAttribute('aria-describedby', copy.google ? 'int-disconnect-sub int-disconnect-google' : 'int-disconnect-sub');
|
|
16903
|
+
$error.textContent = '';
|
|
16904
|
+
$copy.hidden = true;
|
|
16905
|
+
$copy.textContent = 'Copy command';
|
|
16906
|
+
$ok.textContent = 'Disconnect';
|
|
16907
|
+
$ok.disabled = $cancel.disabled = false;
|
|
16908
|
+
$box.removeAttribute('aria-busy');
|
|
16909
|
+
$ok.setAttribute('data-command-instance-label', i.name);
|
|
16910
|
+
$cancel.setAttribute('data-command-instance-label', `disconnecting ${i.name}`);
|
|
16911
|
+
const returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
16912
|
+
const covered = Array.from(document.querySelectorAll('.modal-backdrop.show')).filter((m) => m !== $modal)
|
|
16913
|
+
.map((modal) => ({ modal, inert: !!modal.inert, ariaHidden: modal.getAttribute('aria-hidden') }));
|
|
16914
|
+
covered.forEach(({ modal }) => { modal.inert = true; modal.setAttribute('aria-hidden', 'true'); });
|
|
16915
|
+
intDisconnectOpen = true;
|
|
16916
|
+
showModal($modal);
|
|
16917
|
+
setTimeout(() => $cancel.focus(), 0);
|
|
16918
|
+
let working = false;
|
|
16919
|
+
let closed = false;
|
|
16920
|
+
let command = '';
|
|
16921
|
+
// Once per opening: a late continuation of this dialog must never close or unhook a newer one.
|
|
16922
|
+
const close = (focusTarget) => {
|
|
16923
|
+
if (closed) return;
|
|
16924
|
+
closed = true;
|
|
16925
|
+
intDisconnectOpen = false;
|
|
16926
|
+
hideModal($modal);
|
|
16927
|
+
covered.forEach(({ modal, inert, ariaHidden }) => {
|
|
16928
|
+
modal.inert = inert;
|
|
16929
|
+
if (ariaHidden === null) modal.removeAttribute('aria-hidden');
|
|
16930
|
+
else modal.setAttribute('aria-hidden', ariaHidden);
|
|
16931
|
+
});
|
|
16932
|
+
document.removeEventListener('keydown', onKey, true);
|
|
16933
|
+
$ok.onclick = $cancel.onclick = $copy.onclick = null;
|
|
16934
|
+
$modal.onclick = $modal.onmousedown = null;
|
|
16935
|
+
// A closed dialog keeps no busy state behind (the accessibility tree still reads hidden controls' names).
|
|
16936
|
+
$ok.textContent = 'Disconnect';
|
|
16937
|
+
$ok.disabled = $cancel.disabled = false;
|
|
16938
|
+
$box.removeAttribute('aria-busy');
|
|
16939
|
+
const target = typeof focusTarget === 'function' ? focusTarget() : focusTarget;
|
|
16940
|
+
if (target && target.isConnected) target.focus();
|
|
16941
|
+
else if (returnFocus && returnFocus.isConnected) returnFocus.focus();
|
|
16942
|
+
else document.getElementById('integrations-close')?.focus();
|
|
16943
|
+
};
|
|
16944
|
+
const onKey = (e) => {
|
|
16945
|
+
if (document.getElementById('server-offline-overlay')) return;
|
|
16946
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); if (!working) close(); }
|
|
16947
|
+
else if (e.key === 'Tab') {
|
|
16948
|
+
// Above Integrations: own Tab so the lower dialog's trap cannot pull focus behind this one.
|
|
16949
|
+
e.stopPropagation();
|
|
16950
|
+
const focusable = Array.from($modal.querySelectorAll('button:not([disabled]):not([hidden])')).filter((el) => el.getClientRects().length);
|
|
16951
|
+
if (!focusable.length) { e.preventDefault(); return; }
|
|
16952
|
+
const first = focusable[0]; const last = focusable[focusable.length - 1];
|
|
16953
|
+
if (e.shiftKey && (document.activeElement === first || !$modal.contains(document.activeElement))) { e.preventDefault(); last.focus(); }
|
|
16954
|
+
else if (!e.shiftKey && (document.activeElement === last || !$modal.contains(document.activeElement))) { e.preventDefault(); first.focus(); }
|
|
16955
|
+
}
|
|
16956
|
+
};
|
|
16957
|
+
$cancel.onclick = () => { if (!working) close(); };
|
|
16958
|
+
$copy.onclick = async () => {
|
|
16959
|
+
const copied = await copyToClipboard(command);
|
|
16960
|
+
$copy.textContent = copied ? 'Copied' : 'Copy command';
|
|
16961
|
+
if (!copied) showToast(`Run in your terminal: ${command}`, 'info');
|
|
16962
|
+
setTimeout(() => { $copy.textContent = 'Copy command'; }, 1600);
|
|
16963
|
+
};
|
|
16964
|
+
$ok.onclick = async () => {
|
|
16965
|
+
working = true;
|
|
16966
|
+
$error.textContent = '';
|
|
16967
|
+
$box.setAttribute('aria-busy', 'true');
|
|
16968
|
+
$box.focus();
|
|
16969
|
+
$ok.textContent = 'Disconnecting…';
|
|
16970
|
+
$ok.disabled = $cancel.disabled = true;
|
|
16971
|
+
let result;
|
|
16972
|
+
try {
|
|
16973
|
+
result = await api(`/api/integrations/${encodeURIComponent(i.id)}/disconnect`, {
|
|
16974
|
+
method: 'POST', body: JSON.stringify(copy.alias ? { alias: copy.alias } : {}),
|
|
16975
|
+
});
|
|
16976
|
+
} catch (error) {
|
|
16977
|
+
working = false;
|
|
16978
|
+
$box.removeAttribute('aria-busy');
|
|
16979
|
+
command = typeof error?.body?.command === 'string' ? error.body.command : '';
|
|
16980
|
+
$error.textContent = errorText(error, { action: `disconnect ${i.name}` });
|
|
16981
|
+
$copy.hidden = !command;
|
|
16982
|
+
$ok.textContent = 'Try again';
|
|
16983
|
+
$ok.disabled = $cancel.disabled = false;
|
|
16984
|
+
$ok.focus();
|
|
16985
|
+
// The card underneath shows what AWARE holds now (a failure can land after the sign-in was removed).
|
|
16986
|
+
void refreshIntegrations();
|
|
16987
|
+
return;
|
|
16988
|
+
}
|
|
16989
|
+
const id = (window.CSS && CSS.escape) ? CSS.escape(i.id) : i.id;
|
|
16990
|
+
// Still working while the card is redrawn, so Esc or the backdrop cannot close the dialog mid-way.
|
|
16991
|
+
await refreshIntegrations();
|
|
16992
|
+
working = false;
|
|
16993
|
+
// Worded from the server's answer and the redrawn card, never assumed: another account may still be connected.
|
|
16994
|
+
const outcome = disconnectOutcome(i, result, integrations.find((row) => row.id === i.id));
|
|
16995
|
+
document.getElementById('integrations-status').textContent = outcome.text;
|
|
16996
|
+
close(() => $integrationsList.querySelector(`[data-integration-id="${id}"] .int-action[data-int-action="${outcome.focus}"]`));
|
|
16997
|
+
showToast(outcome.text, outcome.tone);
|
|
16998
|
+
};
|
|
16999
|
+
onBackdropDismiss($modal, () => close(), () => !working);
|
|
17000
|
+
document.addEventListener('keydown', onKey, true);
|
|
17001
|
+
}
|
|
17002
|
+
|
|
16433
17003
|
/** One OAuth integration's card (#2649: a named function, so its rendered carriers and controls are tested). */
|
|
16434
17004
|
function integrationCardHtml(i) {
|
|
16435
17005
|
const action = i.status === 'connected' ? 'Disconnect' : i.status === 'expired' ? 'Reconnect' : 'Connect';
|
|
@@ -16442,10 +17012,18 @@
|
|
|
16442
17012
|
const reconnect = google ? google.reconnect
|
|
16443
17013
|
: i.id === MICROSOFT_INTEGRATION_ID && i.status === 'connected' ? reconnectButtonHtml(i) : '';
|
|
16444
17014
|
// #2466: what a Microsoft sign-in asks for, said before the person clicks (FLOLESS_M365_SCOPES, server/oauth-presets.ts).
|
|
17015
|
+
// #3295: while a sign-in allows more than that, or FloLess cannot tell what it allows, the card never says it only reads.
|
|
17016
|
+
const grants = i.id === MICROSOFT_INTEGRATION_ID && Array.isArray(i.accountSlots) ? i.accountSlots.map((slot) => slot.microsoftGrant?.state) : [];
|
|
17017
|
+
const wider = grants.filter((state) => state === 'wider').length;
|
|
16445
17018
|
const microsoftHelp = i.id === MICROSOFT_INTEGRATION_ID
|
|
16446
17019
|
? '<div class="int-drive-help is-flush" id="int-microsoft-access-help">When you sign in, FloLess asks Microsoft to let AI Chat read your OneDrive and SharePoint files, '
|
|
16447
|
-
+ 'Excel workbooks, Outlook mail, Planner and Teams chats.
|
|
16448
|
-
+
|
|
17020
|
+
+ 'Excel workbooks, Outlook mail, Planner and Teams chats. '
|
|
17021
|
+
+ (wider
|
|
17022
|
+
? `FloLess itself only reads, but Microsoft gave ${wider > 1 ? 'some of your sign-ins' : 'one of your sign-ins'} more. See the note below. `
|
|
17023
|
+
: grants.includes('unknown')
|
|
17024
|
+
? 'FloLess itself only reads, but Microsoft didn’t say what your sign-in allows, so FloLess can’t check it. '
|
|
17025
|
+
: 'It only reads. ')
|
|
17026
|
+
+ 'Excel’s permission also allows changes (Microsoft has no read-only one), but FloLess never edits a file.</div>'
|
|
16449
17027
|
: '';
|
|
16450
17028
|
return `
|
|
16451
17029
|
<div class="int-item int-${i.status}" data-integration-id="${escapeAttr(i.id)}" tabindex="-1">
|
|
@@ -16463,7 +17041,7 @@
|
|
|
16463
17041
|
<span class="int-badge int-badge-${i.status}">${badge}</span>
|
|
16464
17042
|
<span class="int-recovery-actions">
|
|
16465
17043
|
${reconnect}
|
|
16466
|
-
<button class="int-action" data-int="${escapeAttr(i.id)}" data-int-action="${action.toLowerCase()}"${action === 'Disconnect' ?
|
|
17044
|
+
<button class="int-action" data-int="${escapeAttr(i.id)}" data-int-action="${action.toLowerCase()}"${action === 'Disconnect' ? disconnectButtonAttrs(i) : ` data-command-id="shell.integrations-connect#${escapeAttr(i.id)}" data-command-instance-label="${escapeAttr(i.name)}"`}>${action}</button>
|
|
16467
17045
|
</span>
|
|
16468
17046
|
</div>
|
|
16469
17047
|
${i.status === 'connected' || (google && !google.deviceCodeAvailable) ? '' : `
|
|
@@ -16575,13 +17153,12 @@
|
|
|
16575
17153
|
});
|
|
16576
17154
|
$integrationsList.querySelectorAll('.int-action[data-int]').forEach((btn) => {
|
|
16577
17155
|
btn.onclick = async () => {
|
|
16578
|
-
// Connect/Reconnect drive the
|
|
16579
|
-
// the
|
|
16580
|
-
// the
|
|
17156
|
+
// Connect/Reconnect drive the sign-in IN the app (AWARE owns the OAuth + token storage; we only show the code
|
|
17157
|
+
// and reflect the result — the token never crosses floless.app). #3301: Disconnect runs in the app too, after a
|
|
17158
|
+
// confirm: AWARE deletes the stored sign-in itself, so no secret crosses here either.
|
|
16581
17159
|
if (btn.dataset.intAction === 'disconnect') {
|
|
16582
|
-
const
|
|
16583
|
-
|
|
16584
|
-
showToast(`${copied ? 'Copied — run' : 'Run'} in your terminal: ${cmd}`, 'info');
|
|
17160
|
+
const integration = integrations.find((row) => row.id === btn.dataset.int);
|
|
17161
|
+
if (integration) confirmIntegrationDisconnect(integration);
|
|
16585
17162
|
return;
|
|
16586
17163
|
}
|
|
16587
17164
|
// #2649: a named account's own Reconnect carries its account; the Drive choice is the card's checkbox.
|
|
@@ -16679,22 +17256,23 @@
|
|
|
16679
17256
|
});
|
|
16680
17257
|
if (slot) slot.innerHTML = 'Starting sign-in…';
|
|
16681
17258
|
try {
|
|
16682
|
-
|
|
17259
|
+
// `connect`, not `res`: a start it declines carries the route’s own sentence in `message` (a constant per service).
|
|
17260
|
+
const connect = await api(`/api/connect/${encodeURIComponent(id)}`, { method: 'POST', body });
|
|
16683
17261
|
// A managed-preset pre-flight (e.g. port 80 already in use) refuses to start
|
|
16684
17262
|
// and broadcasts the reason over SSE (connect-result). Clear the guard so the
|
|
16685
17263
|
// user can retry after fixing it, and don't claim the browser opened. #2649: the
|
|
16686
17264
|
// reason also comes back here, so a card waiting on a reconnecting SSE still says why.
|
|
16687
|
-
if (
|
|
17265
|
+
if (connect && connect.started === false) {
|
|
16688
17266
|
connecting.delete(id);
|
|
16689
|
-
if (slot && typeof
|
|
17267
|
+
if (slot && typeof connect.message === 'string') slot.innerHTML = connectResultSlotHtml({ status: 'failed', message: connect.message });
|
|
16690
17268
|
return;
|
|
16691
17269
|
}
|
|
16692
17270
|
if (slot) {
|
|
16693
|
-
if (
|
|
17271
|
+
if (connect.flow === 'device-code' && connect.prompt) {
|
|
16694
17272
|
// Fallback flow: show the device code to enter at the verification URL.
|
|
16695
17273
|
slot.innerHTML =
|
|
16696
|
-
`Go to <a href="${escapeAttr(
|
|
16697
|
-
` and enter code <strong class="dc-code">${escapeHtml(
|
|
17274
|
+
`Go to <a href="${escapeAttr(connect.prompt.verification_uri)}" target="_blank" rel="noopener">${escapeHtml(connect.prompt.verification_uri)}</a>` +
|
|
17275
|
+
` and enter code <strong class="dc-code">${escapeHtml(connect.prompt.user_code)}</strong> — waiting for sign-in…`;
|
|
16698
17276
|
} else {
|
|
16699
17277
|
// OAuth: aware opened the provider sign-in in the browser.
|
|
16700
17278
|
slot.innerHTML = 'Opening your browser to sign in… complete it there and this will update automatically.';
|
|
@@ -16706,7 +17284,7 @@
|
|
|
16706
17284
|
// (a 409 busy lock, whose sentence names it) are shown where the person clicked; anything else goes to the usual
|
|
16707
17285
|
// error report.
|
|
16708
17286
|
const own = e && (e.status === 400 || (e.status === 409 && e.body?.code === 'lifecycle-busy'));
|
|
16709
|
-
const said = own
|
|
17287
|
+
const said = own ? personText(e.body) : '';
|
|
16710
17288
|
if (slot) slot.innerHTML = said ? escapeHtml(said) : '';
|
|
16711
17289
|
if (!said) reportErr(e);
|
|
16712
17290
|
}
|
|
@@ -16731,7 +17309,8 @@
|
|
|
16731
17309
|
const db = document.getElementById('debug-btn');
|
|
16732
17310
|
if (db) {
|
|
16733
17311
|
const node = id && currentId && apps.get(currentId)?.nodes.find((n) => n.id === id);
|
|
16734
|
-
|
|
17312
|
+
// #3234: the debugger attaches to the Tekla bridge, so only a Tekla exec step offers it (the server refuses any other).
|
|
17313
|
+
db.hidden = !(node && node.agent === 'tekla' && node.command === 'exec' && node.config && typeof node.config.code === 'string');
|
|
16735
17314
|
}
|
|
16736
17315
|
};
|
|
16737
17316
|
|
|
@@ -17008,7 +17587,7 @@
|
|
|
17008
17587
|
const ai = r.kind === 'trigger' ? globalThis.flolessAgentSteps?.watcherCardParts?.(r.aiEvents) ?? null
|
|
17009
17588
|
: !r.agent && r.lastRun ? globalThis.flolessAgentSteps?.routineAiParts(r.lastRun) : null;
|
|
17010
17589
|
if (!ai) return '';
|
|
17011
|
-
return `<span class="rtn-dot">·</span><span class="rtn-ai" data-tip="${escapeAttr(ai.aiTip)}">${escapeHtml(ai.ai)}</span>`
|
|
17590
|
+
return `<span class="rtn-dot">·</span><span class="rtn-ai${ai.stoppedAt ? ' is-stopped' : ''}" data-tip="${escapeAttr(ai.aiTip)}">${escapeHtml(ai.ai)}</span>`
|
|
17012
17591
|
+ (ai.questions ? `<span class="rtn-dot">·</span><span class="rtn-ai-q" data-tip="${escapeAttr(ai.questionsTip)}">${escapeHtml(ai.questions)}</span>` : '');
|
|
17013
17592
|
}
|
|
17014
17593
|
function lastRunTip(r) {
|
|
@@ -17029,6 +17608,10 @@
|
|
|
17029
17608
|
// #2241 S5: a run with an AI step says so, and says how many questions it left for you.
|
|
17030
17609
|
const ai = globalThis.flolessAgentSteps?.routineAiParts(lr);
|
|
17031
17610
|
const aiWords = ai ? ` — ${ai.ai}${ai.questions ? ' · ' + ai.questions : ''}` : '';
|
|
17611
|
+
// #3229: a run its AI step's check stopped ended "ok"; the row never reads as a finished run.
|
|
17612
|
+
const head = ai && ai.stoppedAt
|
|
17613
|
+
? `Last run stopped at the AI step “${ai.stoppedAt.length > 40 ? `${ai.stoppedAt.slice(0, 39)}…` : ai.stoppedAt}”, so the steps after it did not run${ai.questions ? ' · ' + ai.questions : ''}`
|
|
17614
|
+
: `Last run ${lr.status}${aiWords}`;
|
|
17032
17615
|
// A run that finished on a stated assumption says so with its outcome, never only in the report.
|
|
17033
17616
|
const warnings = Array.isArray(lr.warnings) ? lr.warnings.filter((warning) => typeof warning === 'string' && warning) : [];
|
|
17034
17617
|
// #1998: a run made under an approval carried forward to newer tool versions says so, in AWARE's words.
|
|
@@ -17040,7 +17623,7 @@
|
|
|
17040
17623
|
&& typeof w.detail === 'string' && w.detail.trim() && (w.via === null || typeof w.via === 'string')
|
|
17041
17624
|
&& Array.isArray(w.choices) && w.choices.every((choice) => typeof choice === 'string')) : [];
|
|
17042
17625
|
const bridge = bridgeWarnings.map((w) => `\n${w.status === 'declaration-invalid' ? 'Ran with an invalid bridge declaration' : 'Ran with a bridge mismatch'}: ${w.via ? w.via + ' → ' : ''}${w.name}. ${w.detail}`).join('');
|
|
17043
|
-
return
|
|
17626
|
+
return `${head}${lr.reason ? ' — ' + lr.reason : ''}${warnings.length ? ' — ' + warnings.join(' ') : ''} · ${absTime(lr.at)}${dur}${carried}${bridge}`;
|
|
17044
17627
|
}
|
|
17045
17628
|
|
|
17046
17629
|
// ── Trigger-routine row helpers ─────────────────────────────────────────────
|
|
@@ -17098,9 +17681,19 @@
|
|
|
17098
17681
|
return { label: 'stopped', dotClass: '', tip: 'Not running', sr: 'Status: stopped' };
|
|
17099
17682
|
}
|
|
17100
17683
|
|
|
17101
|
-
|
|
17684
|
+
let routinesLoadSeq = 0;
|
|
17685
|
+
let routinesLoadLatest = Promise.resolve();
|
|
17686
|
+
// Several loads can be in flight (each routine-changed event starts one): only the newest answer is applied, so an
|
|
17687
|
+
// older list arriving last never brings back a question already answered. A superseded load resolves with the newest
|
|
17688
|
+
// one, so a caller that awaits it still reads the fresh list.
|
|
17689
|
+
function loadRoutinesData() {
|
|
17690
|
+
routinesLoadLatest = applyRoutinesLoad(++routinesLoadSeq);
|
|
17691
|
+
return routinesLoadLatest;
|
|
17692
|
+
}
|
|
17693
|
+
async function applyRoutinesLoad(seq) {
|
|
17102
17694
|
try {
|
|
17103
17695
|
const res = await api('/api/routines');
|
|
17696
|
+
if (seq !== routinesLoadSeq) return routinesLoadLatest;
|
|
17104
17697
|
// The Workflows landing repaints only when the routines its "Scheduled" chips read change, not on every
|
|
17105
17698
|
// scheduler tick.
|
|
17106
17699
|
const chipKey = (list) => JSON.stringify(list.filter((r) => r.enabled && !r.broken).map((r) => [r.workflow, r.name]));
|
|
@@ -17118,6 +17711,9 @@
|
|
|
17118
17711
|
}
|
|
17119
17712
|
for (const id of live) void refreshRoutineReportDiscovery(id);
|
|
17120
17713
|
if (routinesData.some((r) => r.agent)) void refreshRoutineAgents();
|
|
17714
|
+
// Owner ruling 2026-11-06: the card asking whether to run what was missed while FloLess was closed.
|
|
17715
|
+
try { window.flolessMissedRoutines?.update(routinesData, { api, reportErr, reload: loadRoutinesData }); }
|
|
17716
|
+
catch (err) { console.error('Missed-routines card failed', err); }
|
|
17121
17717
|
if ($routinesModal.classList.contains('show')) renderRoutinesList();
|
|
17122
17718
|
// Last, and on its own: a landing repaint that throws must not skip the reconcile above.
|
|
17123
17719
|
if (wfLanding && chipsChanged) {
|
|
@@ -17249,7 +17845,8 @@
|
|
|
17249
17845
|
const savedPath = typeof m.savedPath === 'string' ? m.savedPath : '';
|
|
17250
17846
|
const fromChat = m.from !== 'terminal';
|
|
17251
17847
|
const entry = { nodeId: m.nodeId || null, label: fromChat ? 'from AI Chat' : 'from a terminal', html: m.html, interactive, savedPath,
|
|
17252
|
-
withFiles: m.withFiles === true, runId: typeof m.runId === 'string' ? m.runId : null
|
|
17848
|
+
withFiles: m.withFiles === true, runId: typeof m.runId === 'string' ? m.runId : null,
|
|
17849
|
+
aiStop: globalThis.flolessAgentSteps?.stoppedRunView?.(m) ?? null }; // #3229: the same banner as after this window's own Run
|
|
17253
17850
|
lastReportByApp.set(m.workflow, entry);
|
|
17254
17851
|
const open = $reportModal && $reportModal.classList.contains('show');
|
|
17255
17852
|
if (!open || currentId !== m.workflow || reportRunning) return;
|
|
@@ -17264,7 +17861,8 @@
|
|
|
17264
17861
|
if (!m || !m.workflow || typeof m.html !== 'string') return;
|
|
17265
17862
|
const prev = lastReportByApp.get(m.workflow);
|
|
17266
17863
|
const changed = !prev || prev.html !== m.html;
|
|
17267
|
-
const entry = { nodeId: m.nodeId || null, label: 'scheduled', html: m.html, withFiles: m.withFiles === true, runId: typeof m.runId === 'string' ? m.runId : null
|
|
17864
|
+
const entry = { nodeId: m.nodeId || null, label: 'scheduled', html: m.html, withFiles: m.withFiles === true, runId: typeof m.runId === 'string' ? m.runId : null,
|
|
17865
|
+
aiStop: globalThis.flolessAgentSteps?.stoppedRunView?.(m) ?? null }; // #3229: a scheduled run that stopped at an AI step says so too
|
|
17268
17866
|
lastReportByApp.set(m.workflow, entry);
|
|
17269
17867
|
const open = $reportModal && $reportModal.classList.contains('show');
|
|
17270
17868
|
if (open && currentId === m.workflow && !reportRunning && !foregroundTrigger) {
|
|
@@ -17480,6 +18078,33 @@
|
|
|
17480
18078
|
}
|
|
17481
18079
|
// ── tab signal (end)
|
|
17482
18080
|
|
|
18081
|
+
/** A run-live, node-progress or run-finished event from the server's event stream. */
|
|
18082
|
+
function onRunEvent(m) {
|
|
18083
|
+
// #2228: live progress of a long run. This tab's own run is matched by its token; a run of the
|
|
18084
|
+
// workflow this tab shows that someone else started is followed read-only (no Stop).
|
|
18085
|
+
// #2241: a run that FAILED after an Agent answered ends with run-finished, not run-ended: its AI record is read then too.
|
|
18086
|
+
if (m.type === 'run-finished' && m.id && m.id === currentId) void globalThis.flolessAgentSteps?.refreshRunRecord(m.id);
|
|
18087
|
+
// Workflows → History: a run starting shows as Running, and a failed run ends with run-finished alone.
|
|
18088
|
+
if (m.type !== 'node-progress') window.flolessRunHistory?.refresh?.();
|
|
18089
|
+
// #3253: the one rule for every branch below (this tab's own run, one it follows, the report overlay, the tab
|
|
18090
|
+
// signal): the ending of another attempt (a Run anyway's refused one, however late) never ends, settles or forgets
|
|
18091
|
+
// the attempt this tab is watching now.
|
|
18092
|
+
if (m.type === 'run-finished' && m.clientRunToken && liveRun && liveRun.token && m.clientRunToken !== liveRun.token) return;
|
|
18093
|
+
signalRunEvent(m); // the browser tab hears its run's ending even when the strip already settled
|
|
18094
|
+
if (liveRunOwns(m)) {
|
|
18095
|
+
if (m.type === 'run-live') { if (m.runId) { liveRun.runId = m.runId; signalRunNote(liveRun); } }
|
|
18096
|
+
else if (m.type === 'node-progress') onLiveProgress(m);
|
|
18097
|
+
else finishLiveRun(typeof m.outcome === 'string' ? m.outcome : 'failed');
|
|
18098
|
+
} else if (m.id === currentId && !(liveRun && liveRun.owner && !liveRun.ended)) {
|
|
18099
|
+
if (m.type === 'run-finished') {
|
|
18100
|
+
if (liveRun && !liveRun.owner && (!m.runId || m.runId === liveRun.runId)) finishLiveRun(typeof m.outcome === 'string' ? m.outcome : 'failed');
|
|
18101
|
+
} else {
|
|
18102
|
+
if (!liveRun || liveRun.ended || (m.runId && liveRun.runId && m.runId !== liveRun.runId)) observeLiveRun(m);
|
|
18103
|
+
if (m.type === 'node-progress') onLiveProgress(m);
|
|
18104
|
+
}
|
|
18105
|
+
}
|
|
18106
|
+
}
|
|
18107
|
+
|
|
17483
18108
|
function liveRunOwns(m) {
|
|
17484
18109
|
if (!liveRun || liveRun.ended) return false;
|
|
17485
18110
|
if (m.clientRunToken && m.clientRunToken === liveRun.token) return true;
|
|
@@ -17550,6 +18175,12 @@
|
|
|
17550
18175
|
syncRunStrip();
|
|
17551
18176
|
}
|
|
17552
18177
|
|
|
18178
|
+
/** A Run's own ending: settle the tracked attempt it holds (by token), never a later one that replaced it. */
|
|
18179
|
+
function finishOwnLiveRun(token, outcome) {
|
|
18180
|
+
if (!token || !liveRun || liveRun.token !== token) return;
|
|
18181
|
+
if (outcome === 'no-answer') settleLiveRunWithoutAnswer(); else finishLiveRun(outcome);
|
|
18182
|
+
}
|
|
18183
|
+
|
|
17553
18184
|
function finishLiveRun(outcome) {
|
|
17554
18185
|
if (pageLeaving) return; // the page is going away mid-run: keep the token so the next page resumes it
|
|
17555
18186
|
if (liveRun && liveRun.ended && signalRunIs(liveRun)) {
|
|
@@ -17804,7 +18435,9 @@
|
|
|
17804
18435
|
$reportSub.innerHTML = `Live run of <code>${escapeHtml(id)}</code> — the report re-renders on every event.`;
|
|
17805
18436
|
showModal($reportModal);
|
|
17806
18437
|
try {
|
|
17807
|
-
const res = await
|
|
18438
|
+
const res = await postAskingElsewhere('/api/trigger-run', { id, inputs: currentInputs() }, { onApprove: () => {
|
|
18439
|
+
if ($compileBtn && !$compileBtn.disabled) $compileBtn.click();
|
|
18440
|
+
} });
|
|
17808
18441
|
foregroundTrigger = { appId: id, sessionId: res.sessionId, firedCount: 0 };
|
|
17809
18442
|
paintForegroundListening();
|
|
17810
18443
|
beatLiveViewer();
|
|
@@ -17940,6 +18573,38 @@
|
|
|
17940
18573
|
return null;
|
|
17941
18574
|
}
|
|
17942
18575
|
|
|
18576
|
+
/** #3232: how a routine's workflow reads — an owned one by its name and owner (server-resolved), else its id. */
|
|
18577
|
+
function routineWorkflowText(r) {
|
|
18578
|
+
const label = r.workflowLabel;
|
|
18579
|
+
return label?.name ? (label.owner ? `${label.name} · ${label.owner}` : label.name) : r.workflow;
|
|
18580
|
+
}
|
|
18581
|
+
|
|
18582
|
+
/**
|
|
18583
|
+
* #3232: the row's "what it runs" span. An owned workflow's name and project stay on one line beside the schedule:
|
|
18584
|
+
* the name shortens first, the project after it, and the whole label is the tip.
|
|
18585
|
+
*/
|
|
18586
|
+
function routineWorkflowHtml(r, whatText) {
|
|
18587
|
+
const label = r.agent ? null : r.workflowLabel;
|
|
18588
|
+
if (!label?.name) return `<span class="rtn-wf">${escapeHtml(whatText)}</span>`;
|
|
18589
|
+
return `<span class="rtn-wf named" data-tip="${escapeAttr(whatText)}"><span class="rtn-wf-name">${escapeHtml(label.name)}</span>`
|
|
18590
|
+
+ (label.owner ? `<span class="rtn-wf-owner">· ${escapeHtml(label.owner)}</span>` : '') + '</span>';
|
|
18591
|
+
}
|
|
18592
|
+
|
|
18593
|
+
/**
|
|
18594
|
+
* #3232: the workflows a routine can run, read from `/api/apps?names=1` each time the form opens — every installed workflow
|
|
18595
|
+
* it could run before, by its id, except an owned workflow's publications: the server names the ACTIVE one
|
|
18596
|
+
* (`ownedWorkflowLabel`), listed once as "<name> · <project>", and a superseded one is left out. The value stays the
|
|
18597
|
+
* runtime id the server stores; the label is what the person recognises. When the server could not read the names
|
|
18598
|
+
* (`ownedNamesUnavailable`), `namesUnavailable` says so, so the form tells the person rather than quietly leaving them out.
|
|
18599
|
+
*/
|
|
18600
|
+
async function routineWorkflowChoices() {
|
|
18601
|
+
const { apps: installed, ownedNamesUnavailable } = await api('/api/apps?names=1');
|
|
18602
|
+
const choices = installed.filter((a) => a.execution !== 'internal' && (!a.ownedPublication || a.ownedWorkflowLabel?.name))
|
|
18603
|
+
.map((a) => ({ id: a.id, label: a.ownedPublication ? `${a.ownedWorkflowLabel.name} · ${a.ownedWorkflowLabel.owner}` : a.id }))
|
|
18604
|
+
.sort((x, y) => x.label.localeCompare(y.label));
|
|
18605
|
+
return { choices, namesUnavailable: ownedNamesUnavailable === true };
|
|
18606
|
+
}
|
|
18607
|
+
|
|
17943
18608
|
function renderRoutinesList() {
|
|
17944
18609
|
const $list = document.getElementById('routines-list');
|
|
17945
18610
|
const $quota = document.getElementById('rtn-quota');
|
|
@@ -17995,8 +18660,8 @@
|
|
|
17995
18660
|
if (held) { nextLabel = held.label; nextTip = held.tip; }
|
|
17996
18661
|
}
|
|
17997
18662
|
const whenText = isTrigger ? triggerWhenText(r) : scheduleText(r.schedule);
|
|
17998
|
-
// #2035: an agent routine names its agent, not a workflow id.
|
|
17999
|
-
const whatText = r.agent ? `Agent · ${routineAgentNames.get(r.agent.agentId) || 'agent'}` : r
|
|
18663
|
+
// #2035: an agent routine names its agent, not a workflow id; #3232: an owned workflow is named, not its runtime id.
|
|
18664
|
+
const whatText = r.agent ? `Agent · ${routineAgentNames.get(r.agent.agentId) || 'agent'}` : routineWorkflowText(r);
|
|
18000
18665
|
const toggleTip = isTrigger ? (r.enabled ? 'Stop listening' : 'Start listening') : `${r.enabled ? 'Disable' : 'Enable'} this routine`;
|
|
18001
18666
|
// One sentence for all three surfaces a blocked ▶ speaks through: the hover tip, the `?`
|
|
18002
18667
|
// band (which reads data-blocked-reason), and the toast when a click still reaches the
|
|
@@ -18015,7 +18680,7 @@
|
|
|
18015
18680
|
<div class="rtn-item ${isTrigger ? 'trigger ' : ''}${r.enabled ? '' : 'disabled'} ${running ? 'running' : ''}" data-id="${escapeAttr(r.id)}">
|
|
18016
18681
|
<div class="rtn-main">
|
|
18017
18682
|
<div class="rtn-name">${escapeHtml(r.name)}</div>
|
|
18018
|
-
<div class="rtn-sub"
|
|
18683
|
+
<div class="rtn-sub">${routineWorkflowHtml(r, whatText)}<span class="rtn-dot">·</span><span>${escapeHtml(whenText)}</span>${broken}${routineAiHtml(r)}</div>
|
|
18019
18684
|
${reportLine}
|
|
18020
18685
|
</div>
|
|
18021
18686
|
<div class="rtn-meta"${isTrigger ? ' aria-live="polite" aria-atomic="true"' : ''}>
|
|
@@ -18051,7 +18716,12 @@
|
|
|
18051
18716
|
}
|
|
18052
18717
|
async function runRoutineNow(id) {
|
|
18053
18718
|
try {
|
|
18054
|
-
|
|
18719
|
+
const workflow = routinesData.find((r) => r.id === id)?.workflow;
|
|
18720
|
+
await postAskingElsewhere(`/api/routines/${encodeURIComponent(id)}/run`, {}, { routine: true, onApprove: async () => {
|
|
18721
|
+
if (!workflow) return;
|
|
18722
|
+
hideModal($routinesModal);
|
|
18723
|
+
await selectComboById(workflow);
|
|
18724
|
+
} });
|
|
18055
18725
|
runningRoutines.add(id); // optimistic, for immediate feedback; SSE confirms it moments later
|
|
18056
18726
|
renderRoutinesList();
|
|
18057
18727
|
// #2062: a hand run starts a paused agent; its schedule stays held. Queued, not yet started — the row says how it went.
|
|
@@ -18062,6 +18732,7 @@
|
|
|
18062
18732
|
// and nothing was started, so never say it was. Keyed on the FLAG rather than the status: this
|
|
18063
18733
|
// route is lifecycle-gated, so a 409 can also mean "aware is busy with maintenance", which is a
|
|
18064
18734
|
// different sentence and belongs in the error path.
|
|
18735
|
+
if (e.body && e.body.elsewhereStopped) return; // the person chose not to run it; nothing started
|
|
18065
18736
|
if (!(e.body && e.body.running)) { reportErr(e, 'run this routine now'); return; }
|
|
18066
18737
|
showToast(RTN_ALREADY_RUNNING, 'info');
|
|
18067
18738
|
// RECONCILE rather than add: the 409 is a point-in-time snapshot, and the run can end while the
|
|
@@ -18344,17 +19015,22 @@
|
|
|
18344
19015
|
const r = id ? routinesData.find((x) => x.id === id) : null;
|
|
18345
19016
|
editReturnFocus = opts.returnFocus || null;
|
|
18346
19017
|
const $wf = document.getElementById('rtn-workflow');
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
|
|
18350
|
-
|
|
18351
|
-
|
|
19018
|
+
let namesUnavailable = false;
|
|
19019
|
+
try { ({ choices: editWorkflows, namesUnavailable } = await routineWorkflowChoices()); } catch { editWorkflows = []; }
|
|
19020
|
+
document.getElementById('rtn-workflow-unnamed').hidden = !(namesUnavailable && !r);
|
|
19021
|
+
// Editing a routine whose workflow is no longer listed (archived, locked) still shows what it runs.
|
|
19022
|
+
if (r && !r.agent && r.workflow && !editWorkflows.some((a) => a.id === r.workflow)) {
|
|
19023
|
+
editWorkflows = [{ id: r.workflow, label: routineWorkflowText(r) }, ...editWorkflows];
|
|
19024
|
+
}
|
|
19025
|
+
$wf.innerHTML = editWorkflows.map((a) => `<option value="${escapeAttr(a.id)}">${escapeHtml(a.label)}</option>`).join('');
|
|
18352
19026
|
document.getElementById('rtn-edit-title').textContent = r ? 'Edit routine' : 'New routine';
|
|
18353
19027
|
document.getElementById('rtn-name').value = r ? r.name : '';
|
|
18354
19028
|
// #2046: a Guide suggestion names the workflow; it is preselected only when it is one of the choices.
|
|
18355
19029
|
const suggested = !r && opts.workflowId && editWorkflows.some((a) => a.id === opts.workflowId) ? opts.workflowId : null;
|
|
18356
19030
|
if (!r && opts.workflowId && !suggested) {
|
|
18357
|
-
showToast(
|
|
19031
|
+
showToast(namesUnavailable
|
|
19032
|
+
? 'FloLess couldn’t read the names of your own workflows just now, so no workflow is chosen yet. Close this and open it again in a moment.'
|
|
19033
|
+
: `${workflowLabelOf(opts.workflowId)} can’t be scheduled from here, so no workflow is chosen yet. Pick the one to run in the list.`, 'warn');
|
|
18358
19034
|
}
|
|
18359
19035
|
const wfId = r ? r.workflow : opts.workflowId && !suggested ? '' : (suggested || (editWorkflows[0] ? editWorkflows[0].id : ''));
|
|
18360
19036
|
$wf.value = wfId;
|
|
@@ -18441,7 +19117,8 @@
|
|
|
18441
19117
|
await loadRoutinesData();
|
|
18442
19118
|
} catch (e) {
|
|
18443
19119
|
// #2035: the server words an agent routine's refusal for the person (archived, another folder…); say that.
|
|
18444
|
-
|
|
19120
|
+
// #3097 3c.4: so does every routine refusal it marks as its own (`refusal: 'routine'`), for a workflow routine too.
|
|
19121
|
+
const said = (asAgent || e?.body?.refusal === 'routine') && typeof e?.body?.error === 'string' && e.status < 500 ? e.body.error : null;
|
|
18445
19122
|
showToast(said || 'We couldn’t save this routine because FloLess could not save the change. Try again.', 'err');
|
|
18446
19123
|
}
|
|
18447
19124
|
}
|
|
@@ -19146,11 +19823,11 @@
|
|
|
19146
19823
|
if (error?.code === 'chat-start-cancelled' || gone()) return;
|
|
19147
19824
|
const notReady = error?.code === 'chat-runtime-not-ready';
|
|
19148
19825
|
const explained = notReady ? '' : chatStartErrorText(error);
|
|
19149
|
-
if (notReady) showToast(error
|
|
19826
|
+
if (notReady) showToast(errorText(error), 'warn');
|
|
19150
19827
|
else reportChatStartErr(error);
|
|
19151
19828
|
setRequestHelpBusy(null);
|
|
19152
19829
|
const sub = document.getElementById('request-help-sub');
|
|
19153
|
-
if (sub) sub.textContent = notReady ? error
|
|
19830
|
+
if (sub) sub.textContent = notReady ? errorText(error) : explained || (requestHelpCopied
|
|
19154
19831
|
? 'The request is still in Requests. Try again, start it in the background, or use the copied instruction in your terminal.'
|
|
19155
19832
|
: 'The request is still in Requests. Try again, start it in the background, or copy the terminal instruction.');
|
|
19156
19833
|
// A Request with no safe instruction has nothing to copy either — AI Chat's sentence says to
|
|
@@ -19732,10 +20409,20 @@
|
|
|
19732
20409
|
notifyChatScope();
|
|
19733
20410
|
}
|
|
19734
20411
|
|
|
20412
|
+
// #3234: the card names what the workflow needs ("Tekla model", the author's "Steel model", "AI step"), never the
|
|
20413
|
+
// runner its steps use. The server derives it (app-reader appListFacts); a row from an older server falls back to the
|
|
20414
|
+
// provider it sent.
|
|
19735
20415
|
function workflowCardMeta(row) {
|
|
19736
20416
|
const nodes = Number(row.nodes) || 0;
|
|
19737
|
-
const
|
|
19738
|
-
return
|
|
20417
|
+
const count = `${nodes} node${nodes === 1 ? '' : 's'}`;
|
|
20418
|
+
if (Array.isArray(row.needs)) return [count, ...row.needs.filter((n) => typeof n === 'string')].join(' · ');
|
|
20419
|
+
const provider = row.provider && row.provider !== 'other' ? (PROVIDER_LABELS[row.provider] || row.provider) : '';
|
|
20420
|
+
return `${count}${provider ? ` · ${provider}` : ''}`;
|
|
20421
|
+
}
|
|
20422
|
+
// …and, on a line of its own that is never cut short, that this computer's AWARE is too old to run it.
|
|
20423
|
+
function workflowCardAwareLine(row) {
|
|
20424
|
+
const minimum = row.needsAware && typeof row.needsAware.minimum === 'string' ? row.needsAware.minimum : '';
|
|
20425
|
+
return minimum ? `<div class="ws-meta wf-card-aware">Needs AWARE ${escapeHtml(minimum)} or newer</div>` : '';
|
|
19739
20426
|
}
|
|
19740
20427
|
|
|
19741
20428
|
// The card's "Scheduled" chip and its tip ('' = no chip). A routine runs the installed app it names, which is the
|
|
@@ -20077,13 +20764,14 @@
|
|
|
20077
20764
|
const ownedRow = row.ownedWorkflow;
|
|
20078
20765
|
const name = ownedRow ? ownedRow.displayName : (row.displayName || row.name || row.id);
|
|
20079
20766
|
const chip = ownedRow ? 'Yours' : 'Installed';
|
|
20080
|
-
const where = ownedRow ? (row.ownerLabel || 'Standalone') :
|
|
20767
|
+
const where = ownedRow ? (row.ownerLabel || 'Standalone') : 'Installed workflow'; // #3234: what it needs is on the next line
|
|
20081
20768
|
const scheduledTip = scheduledRoutineTip(routinesData, row.id);
|
|
20082
20769
|
return `<div class="ws-card wf-card" role="button" tabindex="0" data-wf-id="${esc(row.id)}" data-command-id="shell.workflows-landing-open#${esc(name)}" data-command-instance-label="${esc(name)}">`
|
|
20083
20770
|
+ `<div class="ws-body"><div class="wf-card-text"><span class="ws-kind wf-kind">${chip}</span>`
|
|
20084
20771
|
+ (scheduledTip ? `<span class="ws-kind wf-kind wf-scheduled" data-tip="${esc(scheduledTip)}">Scheduled</span>` : '')
|
|
20085
20772
|
+ `<div class="ws-name">${esc(name)}</div><div class="ws-meta">${esc(where)}</div>`
|
|
20086
|
-
+ `<div class="ws-meta wf-card-nodes">${esc(workflowCardMeta(row) + (dateLine(row) ? ` · ${dateLine(row)}` : ''))}</div
|
|
20773
|
+
+ `<div class="ws-meta wf-card-nodes">${esc(workflowCardMeta(row) + (dateLine(row) ? ` · ${dateLine(row)}` : ''))}</div>`
|
|
20774
|
+
+ `${workflowCardAwareLine(row)}</div>`
|
|
20087
20775
|
+ (ownedRow ? kebabHtml(ownedRow.workflowId, name) : '') + `</div></div>`;
|
|
20088
20776
|
};
|
|
20089
20777
|
// One section: a disclosure whose summary names it and counts its cards. Your workflows and Installed start open,
|
|
@@ -20584,26 +21272,26 @@
|
|
|
20584
21272
|
// opened after the run) holds a different one or none. Say so instead of showing the wrong report.
|
|
20585
21273
|
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.';
|
|
20586
21274
|
const cached = lastReportByApp.get(appId);
|
|
20587
|
-
if (!runId) throw new Error(gone);
|
|
21275
|
+
if (!runId) throw Object.assign(new Error(gone), { forPerson: true });
|
|
20588
21276
|
// #2266: a window opened (or reloaded) after the run reads the copy FloLess kept of THAT run's report, in the
|
|
20589
21277
|
// workflow's Page. Never another run's: a report no longer kept says so.
|
|
20590
21278
|
if (cached?.runId !== runId) {
|
|
20591
21279
|
let kept = null;
|
|
20592
21280
|
try { kept = await api(`/api/pages/workflow?app=${encodeURIComponent(appId)}&run=${encodeURIComponent(runId)}`); }
|
|
20593
|
-
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.'); }
|
|
21281
|
+
catch { throw Object.assign(new Error('FloLess couldn’t read that run’s report just now. Try again, or open the workflow to see its latest results.'), { forPerson: true }); }
|
|
20594
21282
|
if (kept?.home && kept.page?.id && kept.shown?.kept === true) {
|
|
20595
|
-
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.');
|
|
21283
|
+
if (typeof window.flolessPages?.open !== 'function') throw Object.assign(new Error('FloLess kept that run’s report, but this window cannot open Pages. Open it from the Pages list.'), { forPerson: true });
|
|
20596
21284
|
return await window.flolessPages.open(kept.home, kept.page.id, kept.shown.version);
|
|
20597
21285
|
}
|
|
20598
|
-
throw new Error(kept?.shown?.note
|
|
21286
|
+
throw Object.assign(new Error(kept?.shown?.note
|
|
20599
21287
|
? `${kept.shown.note} Open the workflow to see its latest results.`
|
|
20600
|
-
: 'FloLess did not keep a copy of that run’s report. Open the workflow to see its latest results.');
|
|
21288
|
+
: 'FloLess did not keep a copy of that run’s report. Open the workflow to see its latest results.'), { forPerson: true });
|
|
20601
21289
|
}
|
|
20602
21290
|
await this.openApp(appId);
|
|
20603
21291
|
// Opening the workflow waits; a newer report may have arrived meanwhile. Show this run's report or nothing.
|
|
20604
|
-
if (lastReportByApp.get(appId) !== cached) throw new Error(gone);
|
|
21292
|
+
if (lastReportByApp.get(appId) !== cached) throw Object.assign(new Error(gone), { forPerson: true });
|
|
20605
21293
|
const nodeId = reportNodeId();
|
|
20606
|
-
if (!nodeId) throw new Error('This workflow has no report view, so there is nothing to open. Its results are in the workflow.');
|
|
21294
|
+
if (!nodeId) throw Object.assign(new Error('This workflow has no report view, so there is nothing to open. Its results are in the workflow.'), { forPerson: true });
|
|
20607
21295
|
showReport(nodeId);
|
|
20608
21296
|
return true;
|
|
20609
21297
|
},
|
|
@@ -20615,13 +21303,13 @@
|
|
|
20615
21303
|
await window.flolessWorkspaces?.setMode?.('workflows');
|
|
20616
21304
|
// The switch can stay on the current tab (another workflow's read failed): never focus a card nobody can see.
|
|
20617
21305
|
if (document.body.classList.contains('mode-workspaces') || document.body.classList.contains('mode-agents')) {
|
|
20618
|
-
throw new Error('FloLess could not switch to the Workflows tab just now. Open it and find the workflow under Archived.');
|
|
21306
|
+
throw Object.assign(new Error('FloLess could not switch to the Workflows tab just now. Open it and find the workflow under Archived.'), { forPerson: true });
|
|
20619
21307
|
}
|
|
20620
21308
|
// The list is what is needed here, not any one workflow: a reload that fails keeps the list already on screen.
|
|
20621
21309
|
try { await loadApps(); } catch (error) { console.warn('[project-access] the workflow list could not be read again', error); }
|
|
20622
21310
|
showWorkflowsLanding(true);
|
|
20623
21311
|
const card = [...($wfLanding?.querySelectorAll('[data-wf-archived]') || [])].find((el) => el.getAttribute('data-wf-archived') === workflowId);
|
|
20624
|
-
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.');
|
|
21312
|
+
if (!card) throw Object.assign(new Error('That workflow is no longer in the Archived list, so FloLess cannot show it. It may have been restored or removed.'), { forPerson: true });
|
|
20625
21313
|
const box = card.closest('.wf-archived');
|
|
20626
21314
|
if (box) box.open = true;
|
|
20627
21315
|
card.scrollIntoView?.({ block: 'center' });
|
|
@@ -20640,13 +21328,13 @@
|
|
|
20640
21328
|
// #2185: a draft built a moment ago is not in the cached list yet: read it once more before saying it is gone.
|
|
20641
21329
|
if (!wfOwned.some((row) => row.workflowId === workflowId)) {
|
|
20642
21330
|
try { ({ workflows: wfOwned } = await api('/api/workflows/owned')); }
|
|
20643
|
-
catch { throw new Error('FloLess couldn’t load your workflows just now. Try again, or open it from the Workflows page.'); }
|
|
21331
|
+
catch { throw Object.assign(new Error('FloLess couldn’t load your workflows just now. Try again, or open it from the Workflows page.'), { forPerson: true }); }
|
|
20644
21332
|
}
|
|
20645
21333
|
if (wfOwned.some((row) => row.workflowId === workflowId && row.status !== 'archived')) {
|
|
20646
21334
|
openDraftWorkflow(workflowId);
|
|
20647
21335
|
return true;
|
|
20648
21336
|
}
|
|
20649
|
-
throw new Error('That workflow is no longer here, so its conversation can’t be opened.');
|
|
21337
|
+
throw Object.assign(new Error('That workflow is no longer here, so its conversation can’t be opened.'), { forPerson: true });
|
|
20650
21338
|
},
|
|
20651
21339
|
// The New project dialog's AI choice (#1605): the installed Claude/Codex rows as last read, and
|
|
20652
21340
|
// a fresh read of them. The same shared runtime state preferredChatProvider() answers from, so
|