@floless/app 0.169.0 → 0.171.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.
Files changed (87) hide show
  1. package/dist/floless-server.cjs +65531 -43728
  2. package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
  3. package/dist/schemas/steel.model.v2.schema.json +196 -4
  4. package/dist/skills/floless-app-bridge/SKILL.md +3 -3
  5. package/dist/skills/floless-app-knowledge/SKILL.md +46 -15
  6. package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
  7. package/dist/skills/floless-app-onboarding/SKILL.md +5 -4
  8. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +0 -3
  9. package/dist/skills/floless-app-queue/SKILL.md +2 -3
  10. package/dist/skills/floless-app-report-issue/SKILL.md +2 -2
  11. package/dist/skills/floless-app-routines/SKILL.md +2 -2
  12. package/dist/skills/floless-app-routines/references/routines-api.md +20 -8
  13. package/dist/skills/floless-app-steel-model/SKILL.md +42 -39
  14. package/dist/skills/floless-app-steel-model/references/custom-connections.md +47 -0
  15. package/dist/skills/floless-app-steel-model/references/custom-sections.md +32 -0
  16. package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
  17. package/dist/skills/floless-app-ui/SKILL.md +71 -126
  18. package/dist/skills/floless-app-workflows/SKILL.md +22 -3
  19. package/dist/skills/floless-app-workflows/references/agent-steps.md +40 -6
  20. package/dist/skills/floless-app-workflows/references/exec-contract.md +27 -0
  21. package/dist/skills/floless-app-workflows/references/script-runner.md +105 -0
  22. package/dist/web/add-ons.js +407 -0
  23. package/dist/web/agent-steps.js +89 -18
  24. package/dist/web/agents.js +32 -22
  25. package/dist/web/analytics.js +1 -1
  26. package/dist/web/app.css +331 -190
  27. package/dist/web/app.js +33 -13
  28. package/dist/web/aware.js +926 -218
  29. package/dist/web/chat.css +6 -1
  30. package/dist/web/chat.js +316 -112
  31. package/dist/web/checkpoint-standard.js +5 -3
  32. package/dist/web/commands-drawing-check.js +1 -0
  33. package/dist/web/commands-filter.js +23 -0
  34. package/dist/web/commands-shell.js +479 -78
  35. package/dist/web/commands-steel.js +69 -2
  36. package/dist/web/commands-tekla-parser.js +23 -0
  37. package/dist/web/connections.js +14 -3
  38. package/dist/web/drawing-check-editor.js +352 -88
  39. package/dist/web/failure-copy.js +33 -2
  40. package/dist/web/filter-ai-proposal.js +11 -8
  41. package/dist/web/flo-3d.js +1 -1
  42. package/dist/web/guide.js +36 -29
  43. package/dist/web/index.html +98 -57
  44. package/dist/web/instructor.js +101 -17
  45. package/dist/web/kb-categories.js +64 -7
  46. package/dist/web/left-pane.js +4 -1
  47. package/dist/web/local-discovery.js +8 -7
  48. package/dist/web/missed-routines.js +239 -0
  49. package/dist/web/model-change-findings.js +430 -0
  50. package/dist/web/model-change-review.js +414 -0
  51. package/dist/web/model-editor-steel-adapter.js +2 -2
  52. package/dist/web/model-measure.js +6 -0
  53. package/dist/web/model-spatial-panel.js +19 -4
  54. package/dist/web/model-spatial-tools.js +3 -3
  55. package/dist/web/model-viewport-revit-adapter.js +3 -3
  56. package/dist/web/origin-rule.js +155 -0
  57. package/dist/web/project-access.js +1 -1
  58. package/dist/web/project-history.js +7 -1
  59. package/dist/web/project-modules.js +2 -2
  60. package/dist/web/project-rfis.js +6 -1
  61. package/dist/web/project-workflows.js +2 -2
  62. package/dist/web/revit-editor.css +85 -0
  63. package/dist/web/revit-editor.js +58 -9
  64. package/dist/web/run-history.js +12 -1
  65. package/dist/web/sha256-sync.js +62 -0
  66. package/dist/web/steel-3d-core.js +46 -9
  67. package/dist/web/steel-3d-flo.js +153 -7
  68. package/dist/web/steel-3d-view.js +33 -5
  69. package/dist/web/steel-ai-marks.js +3 -1
  70. package/dist/web/steel-custom-connection.js +161 -0
  71. package/dist/web/steel-custom-sections.js +1796 -0
  72. package/dist/web/steel-editor.html +732 -161
  73. package/dist/web/steel-environments.js +297 -0
  74. package/dist/web/steel-filter-usage.js +299 -0
  75. package/dist/web/steel-filter.html +104 -6
  76. package/dist/web/steel-model-v2-client-validation.js +11 -1
  77. package/dist/web/steel-model-v2-commands.js +116 -13
  78. package/dist/web/steel-model-v2-projection.js +1 -1
  79. package/dist/web/steel-read-confidence.js +1 -56
  80. package/dist/web/step-rename.js +3 -2
  81. package/dist/web/tekla-editor.html +1 -0
  82. package/dist/web/terminal-requests.js +1 -1
  83. package/dist/web/tool-updates.js +7 -6
  84. package/dist/web/workspaces.js +1968 -138
  85. package/launch.mjs +87 -9
  86. package/package.json +4 -1
  87. package/dist/web/panels.js +0 -831
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
- // False: the message is one of FloLess's own generic sentences, not the server's reason for this request.
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
- function highlightCSharp(src) {
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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
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 (CSHARP_KEYWORDS.has(word)) out += span('kw', word);
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 plainDesc = execSource ? leadingComment(execSource) : '';
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 : ''}${plainDesc ? `<p>${escapeHtml(plainDesc)}</p>` : ''}<p>Resolves to ${modeBadge} via <code>${escapeHtml(n.agent || n.kind)}${n.command ? '.' + escapeHtml(n.command) : ''}</code>.</p>${descInputs(inputs)}${execSource ? `<p class="dim-note">Full source in the <strong>Code</strong> tab.</p>` : ''}${notesHtml}`,
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') return '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
- const rows = (check.unavailable || []).filter((u) => u.reinstall);
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
- let res = null;
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
- res = await api(`/api/app/${encodeURIComponent(id)}/reinstall-approved-tool`, { method: 'POST', body: JSON.stringify({ agent, version }) });
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.message, 'info');
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
- if (row) row.textContent = (error.body && error.body.code === 'reinstall-failed') ? `${error.message} You can try again, or Compile again.` : error.message;
983
- else showToast(error.message, 'warn'); // the person moved on: the failure still reaches them
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(res.message, res.reinstalled === true ? 'ok' : 'warn');
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.message;
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
- async function dispatchManualRun(request, payload) {
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;
@@ -1227,7 +1353,6 @@
1227
1353
  }
1228
1354
 
1229
1355
  function acceptsManualRunEvent(message) {
1230
- if (message.runOrigin === 'panel' && !activeManualRun && !state.running && !reportRunning) return true;
1231
1356
  if (!message.runRequestId) return !activeManualRun;
1232
1357
  return !!activeManualRun && !cancelRequested && activeManualRun.id === message.runRequestId;
1233
1358
  }
@@ -1274,6 +1399,8 @@
1274
1399
  if (gateState === 'ready' && app.approvalCheck && app.approvalCheck.bridgeWarnings && app.approvalCheck.bridgeWarnings.length) {
1275
1400
  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
1401
  }
1402
+ const tooOld = gateState !== 'draft' ? awareTooOldFor(app.id) : null;
1403
+ if (tooOld) gateTips[gateState] = `Needs a newer AWARE.\n${awareTooOldSentence(tooOld)}`;
1277
1404
  $runState.dataset.tip = activeTips[status.label] || gateTips[gateState] || '';
1278
1405
 
1279
1406
  // Push a snapshot to the Instructor band. One-way: the band renders what it
@@ -1287,6 +1414,8 @@
1287
1414
  statusLabel: status.label,
1288
1415
  // #1996: what the Instructor says for a not-confirmed carried-forward approval or an incomplete record.
1289
1416
  remedy: (app.approvalCheck && app.approvalCheck.remedy) || null,
1417
+ // #3234: comes before every other state: nothing else can be done until AWARE is upgraded.
1418
+ awareTooOld: tooOld ? { minimum: tooOld.minimum } : null,
1290
1419
  recordIncomplete: recordNeedsCheck(app, gateState),
1291
1420
  bridgeWarning: !!(app.approvalCheck && app.approvalCheck.bridgeWarnings && app.approvalCheck.bridgeWarnings.length),
1292
1421
  totalInputs: inputs.length,
@@ -1314,7 +1443,10 @@
1314
1443
  if ($stopRunBtn) $stopRunBtn.hidden = !(reportRunning || state.running || foregroundStopping || foregroundTrigger);
1315
1444
  syncReportStopControls();
1316
1445
  const agentChanged = gateStateFor(app) === 'agent-changed';
1317
- $runBtn.dataset.tip = agentChanged
1446
+ const awareTooOld = awareTooOldFor(app.id);
1447
+ $runBtn.dataset.tip = awareTooOld
1448
+ ? `This workflow needs AWARE ${awareTooOld.minimum} or newer — upgrade AWARE first`
1449
+ : agentChanged
1318
1450
  ? (app.approvalCheck
1319
1451
  ? (app.approvalCheck.remedy === 'publish'
1320
1452
  ? 'This workflow changed outside FloLess since it was published — ask AI Chat to publish it again first'
@@ -1377,20 +1509,26 @@
1377
1509
  : 'Compile first — there is no approved lock yet, so Bake is blocked.';
1378
1510
  }
1379
1511
 
1380
- if (app.notes.length) {
1512
+ // #3234: a built-in runner (AWARE's `script`) that the AWARE here does not have yet. It is part of AWARE itself, so
1513
+ // installing a tool cannot help: say so, and leave it out of the install rows. The server works it out from the CLI
1514
+ // version, so this holds whether or not the tool's manifest is installed.
1515
+ const tooOld = awareTooOldFor(app.id);
1516
+ if (app.notes.length || tooOld) {
1381
1517
  const n = app.notes.length;
1382
1518
  const missing = missingAgentGroups(app.notes);
1519
+ if (tooOld) for (const id of tooOld.agents) missing.delete(id);
1383
1520
  const installed = installedIdSet();
1384
1521
  const pending = [...missing.keys()].filter((id) => installingIds.has(id) || missingAgentFailures.has(workflowAgentKey(id)) || (!installed.has(id) && !completedAgentInstalls.has(workflowAgentKey(id))));
1385
1522
  const canInstall = pending.filter((id) => !installingIds.has(id));
1386
1523
  const unchecked = [...missing.keys()].some((id) => installed.has(id) && !completedAgentInstalls.has(workflowAgentKey(id)));
1387
1524
  const nextAction = pending.some((id) => missingAgentFailures.has(workflowAgentKey(id))) ? 'attention' : 'installing';
1388
1525
  const ordinaryNotes = app.notes.filter((nt) => !missingAgentId(nt.text));
1526
+ const awareRow = tooOld ? awareTooOldRow(tooOld) : '';
1389
1527
  const sig = notesSig(app.notes);
1390
1528
  // Strip severity = worst note kind (info < warn < error). Drives colour +
1391
1529
  // icon; AWARE 0.48 tags each note with `kind` (#170) so we render by it
1392
1530
  // rather than guessing from the text.
1393
- const worst = app.notes.some((x) => x.kind === 'error') ? 'error'
1531
+ const worst = tooOld || app.notes.some((x) => x.kind === 'error') ? 'error'
1394
1532
  : app.notes.some((x) => x.kind === 'warn') ? 'warn' : 'info';
1395
1533
  const icon = worst === 'error' ? '✕' : worst === 'warn' ? '⚠' : 'ℹ';
1396
1534
  $notesStrip.hidden = false;
@@ -1399,10 +1537,10 @@
1399
1537
  $notesStrip.classList.remove('sev-info', 'sev-warn', 'sev-error');
1400
1538
  $notesStrip.classList.add('sev-' + worst);
1401
1539
  $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>` +
1540
+ `<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
1541
  missingAgentsBulkButton(pending, canInstall) +
1404
1542
  `<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>` : '') +
1543
+ (awareRow || missing.size ? `<ul class="missing-agent-list" aria-live="polite">${awareRow}${missingAgentRows(missing)}</ul>` : '') +
1406
1544
  (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
1545
  // Collapse decision: a remembered choice for this exact note set wins;
1408
1546
  // otherwise default to collapsed for benign info-only sets (keep the canvas
@@ -1626,7 +1764,7 @@
1626
1764
  } catch (error) {
1627
1765
  const copied = await copyToClipboard(markedInstruction(request));
1628
1766
  const workspaceProblem = ['instructor-workspace-root-changed', 'instructor-workspace-earlier-generation', 'instructor-workspace-unavailable'].includes(error?.code);
1629
- showToast(workspaceProblem ? error.message
1767
+ 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
1768
  : `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
1769
  try { await loadRequests(); } catch (refreshError) { console.error(refreshError); }
1632
1770
  activeInstructorRuns.delete(fingerprint);
@@ -1805,9 +1943,11 @@
1805
1943
  } catch (e) {
1806
1944
  if (guide) throw e;
1807
1945
  if (!building) { reportErr(e); return null; }
1808
- // Every message on this path is written for people (ours, the AI setup's, the build route's); the toast's own
1809
- // filter still catches anything technical.
1810
- showToast(`${e?.message || 'FloLess couldn’t start building it.'} To try again, use ≡ → New workflow with the same name and place; FloLess picks up the same draft.`, 'warn', { persistent: true });
1946
+ // Ours and the AI setup's are marked forPerson; the build route's reply is read again from its body (errorText).
1947
+ // The retry step is the unknown-outcome advice too, so an unexplained failure does not say "try again" twice.
1948
+ const again = 'To try again, use ≡ → New workflow with the same name and place; FloLess picks up the same draft.';
1949
+ const said = errorText(e, { action: 'start building it', unsure: again });
1950
+ showToast(said.includes(again) ? said : `${said} ${again}`, 'warn', { persistent: true });
1811
1951
  return null;
1812
1952
  }
1813
1953
  }
@@ -1817,12 +1957,12 @@
1817
1957
  * Guide build uses the AI its Guide conversation uses; ≡ New workflow uses the AI Chat's own choice.
1818
1958
  */
1819
1959
  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.');
1960
+ if (typeof window.flolessChat?.startWorkflowBuild !== 'function') throw Object.assign(new Error('AI Chat is still starting. Try again in a moment.'), { forPerson: true });
1821
1961
  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.');
1962
+ if (!provider) throw Object.assign(new Error('Sign in to Claude or Codex in AI Chat, then build the workflow again.'), { forPerson: true });
1823
1963
  // Reopening a started build needs no AI set up first: the conversation opens either way, and says if it can't send.
1824
1964
  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' });
1965
+ 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
1966
  const result = await window.flolessChat.startWorkflowBuild(buildId, payload.source === 'menu' ? { ...payload, provider } : payload);
1827
1967
  try { ({ workflows: wfOwned } = await api('/api/workflows/owned')); } catch { /* the next refresh lists it */ }
1828
1968
  return result;
@@ -2975,12 +3115,13 @@
2975
3115
  // status-bar app like hello-world runs exec yet emits no HTML, so it has no
2976
3116
  // report-viewer node (and Run must fill the trace, not open an empty viewer).
2977
3117
  // 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 non-report node doesn't false-qualify it.
3118
+ // `html =` OR shorthand `html` (preceded by `{`/`,`, followed by `=`/`,`/`}`), or a JavaScript
3119
+ // `html:` (#3234: a script step returns a plain object) — so a local `html` variable in a
3120
+ // non-report node doesn't false-qualify it.
2980
3121
  const producesHtml = app.nodes.some((n) => {
2981
3122
  const cfg = n.config;
2982
3123
  if (!cfg) return false;
2983
- if (typeof cfg.code === 'string' && /[,{]\s*html\s*[=,}]/.test(cfg.code)) return true;
3124
+ if (typeof cfg.code === 'string' && /[,{]\s*html\s*[=:,}]/.test(cfg.code)) return true;
2984
3125
  if (cfg.args && typeof cfg.args === 'object') {
2985
3126
  for (const v of Object.values(cfg.args)) {
2986
3127
  if (typeof v === 'string' && /\{\{\s*[\w.-]+\.result\.html\s*\}\}/.test(v)) return true;
@@ -4156,10 +4297,10 @@
4156
4297
  const version = Number(link.dataset.version);
4157
4298
  void (async () => {
4158
4299
  try {
4159
- if (typeof window.flolessPages?.open !== 'function') throw new Error('The Pages viewer is not loaded. Reload FloLess and try again.');
4300
+ 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
4301
  await closeReportViewer();
4161
4302
  await window.flolessPages.open(link.dataset.home, link.dataset.page, Number.isInteger(version) && version > 0 ? version : undefined);
4162
- } catch (e) { showToast(`FloLess couldn’t open the workflow’s Page. ${e && e.message ? e.message : ''}`.trim(), 'warn'); }
4303
+ } catch (e) { showToast(errorText(e, { action: 'open the workflow’s Page', retrySafe: true }), 'warn'); }
4163
4304
  })();
4164
4305
  });
4165
4306
 
@@ -4311,9 +4452,9 @@
4311
4452
  answer = await api(`/api/pages/${encodeURIComponent(home)}/${encodeURIComponent(id)}/versions/${encodeURIComponent(n)}/full-report`);
4312
4453
  } catch (error) {
4313
4454
  console.warn('full report did not open', error);
4314
- // The server's reason when it gave one (#3097: api() marks it); a lost connection or an unexplained failure gets
4315
- // the shared sentence for this read, never the browser's "Failed to fetch".
4316
- showToast(error?.serverText ? error.message : failureCopy(error, { action: 'open the full report', retrySafe: true }).text, 'warn');
4455
+ // The server's reason when it gave one, read again from its reply (#3097 errorText); a lost connection or an
4456
+ // unexplained failure gets the shared sentence for this read, never the browser's "Failed to fetch".
4457
+ showToast(errorText(error, { action: 'open the full report', retrySafe: true }), 'warn');
4317
4458
  return false;
4318
4459
  }
4319
4460
  if (typeof answer?.handle !== 'string' || !answer.handle) {
@@ -4390,6 +4531,7 @@
4390
4531
  await response.body?.cancel();
4391
4532
  if (request !== reportSectionRequest) return false;
4392
4533
  $reportFrame.removeAttribute('srcdoc');
4534
+ $reportFrame.dataset.surface = 'light'; // #3233
4393
4535
  // Navigate to the real session-gated route. Its restrictive CSP must belong to the
4394
4536
  // rendered document itself; a blob: copy would silently lose that response header.
4395
4537
  // #2539: which paint this frame load belongs to, and its wait deadline, should the frame find the report busy.
@@ -4442,7 +4584,7 @@
4442
4584
  continue;
4443
4585
  }
4444
4586
  clearCompleteReportView();
4445
- $reportFrame.srcdoc = '';
4587
+ $reportFrame.srcdoc = ''; delete $reportFrame.dataset.surface;
4446
4588
  $reportSub.textContent = 'This report section could not be displayed.';
4447
4589
  const status = Number(error?.status);
4448
4590
  let remedy = 'Close the viewer and choose View report to retry loading this saved report.';
@@ -4496,6 +4638,7 @@
4496
4638
  function paintReport(html, interactive, entry = null) {
4497
4639
  runPageView.invalidate(); // #2476: a new paint ends the previous report's Page frame, its lookups and its timers
4498
4640
  clearCompleteReportView();
4641
+ paintAiStopBanner(entry && entry.aiStop ? entry.aiStop : null); // #3229: every report says whether its run stopped, or nothing
4499
4642
  $reportOpen.hidden = false;
4500
4643
  lastPaintedHtml = html || '';
4501
4644
  lastPaintedInteractive = !!interactive; // drives the share copy: a 3D model is not a "frozen report"
@@ -4503,7 +4646,7 @@
4503
4646
  if ($reportPage) $reportPage.hidden = true; // likewise its Page link (paintReportPageLinks, once it is cached)
4504
4647
  if (!interactive && entry && entry.withFiles) { paintReportWithFiles(html, entry); return; }
4505
4648
  if (interactive) {
4506
- $reportFrame.hidden = true; $reportFrame.srcdoc = '';
4649
+ $reportFrame.hidden = true; $reportFrame.srcdoc = ''; delete $reportFrame.dataset.surface;
4507
4650
  $reportFrame3d.hidden = false;
4508
4651
  $reportFrame3d.src = 'data:text/html;charset=utf-8,' + encodeURIComponent(html);
4509
4652
  // A 3D doc IS shareable: AWARE's viewer-3d renders one self-contained HTML file, and the public
@@ -4516,6 +4659,7 @@
4516
4659
  } else {
4517
4660
  $reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
4518
4661
  // #3130: the report's own content rules ride at its top; lastPaintedHtml keeps exactly what the run produced.
4662
+ $reportFrame.dataset.surface = 'light'; // #3233: until the report has loaded and its own text colour can say otherwise
4519
4663
  $reportFrame.hidden = false; $reportFrame.srcdoc = window.FlolessReportCsp.withReportCsp(html);
4520
4664
  $reportOverlay.hidden = true; $reportOverlay.replaceChildren();
4521
4665
  $reportShare.hidden = false;
@@ -4530,6 +4674,7 @@
4530
4674
  function paintReportWithFiles(html, entry) {
4531
4675
  $reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
4532
4676
  $reportFrame.hidden = false;
4677
+ $reportFrame.dataset.surface = 'light'; // #3233
4533
4678
  $reportFrame.srcdoc = window.FlolessReportCsp.withReportCsp(html); // #3130
4534
4679
  $reportOverlay.hidden = true; $reportOverlay.replaceChildren();
4535
4680
  $reportOpen.hidden = true;
@@ -4537,14 +4682,59 @@
4537
4682
  runPageView.paint(entry);
4538
4683
  }
4539
4684
 
4685
+ // #3233: the page a report is painted on. A report that paints no background of its own used to show FloLess's dark --bg
4686
+ // through, so a report written for the browser's default light page read as dark grey on near-black. Every report now starts
4687
+ // 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
4688
+ // dark page it never painted gets a dark one. A report that declares `color-scheme: dark` gets the browser's own dark page
4689
+ // whatever this says, and a report that paints its own background covers it.
4690
+ let reportColorCanvas = null;
4691
+ /** A CSS colour as sRGB [r, g, b] (0–255), or null. A computed colour keeps the form it was written in (`oklch()`,
4692
+ * `color(srgb …)`), so anything that is not plain rgb() is painted on a 1×1 canvas and read back. */
4693
+ function rgbOfCssColor(color) {
4694
+ const m = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/.exec(color);
4695
+ if (m) return [Number(m[1]), Number(m[2]), Number(m[3])];
4696
+ if (!color) return null;
4697
+ reportColorCanvas ??= document.createElement('canvas');
4698
+ reportColorCanvas.width = reportColorCanvas.height = 1;
4699
+ const ctx = reportColorCanvas.getContext('2d', { willReadFrequently: true });
4700
+ if (!ctx) return null;
4701
+ ctx.clearRect(0, 0, 1, 1);
4702
+ ctx.fillStyle = 'rgba(0, 0, 0, 0)'; // a colour the canvas rejects leaves this, not the last colour read
4703
+ ctx.fillStyle = color;
4704
+ ctx.fillRect(0, 0, 1, 1);
4705
+ const [r, g, b, a] = ctx.getImageData(0, 0, 1, 1).data;
4706
+ return a ? [r, g, b] : null; // nothing painted: a colour the canvas could not read
4707
+ }
4708
+ function reportSurfaceOf(doc) {
4709
+ try {
4710
+ const color = doc?.body && doc.defaultView ? doc.defaultView.getComputedStyle(doc.body).color : '';
4711
+ const rgb = rgbOfCssColor(color);
4712
+ if (!rgb) return 'light';
4713
+ const linear = (c) => { const v = c / 255; return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4; };
4714
+ const luminance = 0.2126 * linear(rgb[0]) + 0.7152 * linear(rgb[1]) + 0.0722 * linear(rgb[2]);
4715
+ // 0.179 is where a colour contrasts equally with white and with black.
4716
+ return luminance > 0.179 ? 'dark' : 'light';
4717
+ } catch { return 'light'; } // an unreadable document keeps the light page
4718
+ }
4719
+ function paintReportSurface() {
4720
+ if (!$reportFrame.dataset.surface) return; // the empty viewer follows the theme
4721
+ let doc = null;
4722
+ try { doc = $reportFrame.contentDocument; } catch { /* not readable: stays light */ }
4723
+ $reportFrame.dataset.surface = reportSurfaceOf(doc);
4724
+ }
4725
+ $reportFrame.addEventListener('load', paintReportSurface);
4726
+ // A report's own dark rules follow the computer's theme, so its text colour can change while it is on screen.
4727
+ try { window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', paintReportSurface); } catch { /* no matchMedia */ }
4728
+
4540
4729
  // Reset the viewer to "no report shown": clear BOTH frames + the Open buffer, so a stale
4541
4730
  // interactive 3D doc can't linger (its WebGL loop running) behind an overlay, and ↗ Open
4542
4731
  // can't reopen a previous app's report. Used by every empty / transition state.
4543
4732
  function clearReportFrames() {
4544
4733
  runPageView.invalidate(); // #2476
4545
4734
  clearCompleteReportView();
4735
+ paintAiStopBanner(null);
4546
4736
  $reportOpen.hidden = false;
4547
- $reportFrame.srcdoc = ''; $reportFrame.hidden = false;
4737
+ $reportFrame.srcdoc = ''; $reportFrame.hidden = false; delete $reportFrame.dataset.surface;
4548
4738
  $reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
4549
4739
  lastPaintedHtml = '';
4550
4740
  showSavedPathActions(''); // no report shown → no saved-file actions
@@ -4960,7 +5150,31 @@
4960
5150
  setExportActionBusy(appId, 'ifc', true);
4961
5151
  showToast('Generating IFC…', 'info');
4962
5152
  try {
4963
- const res = await api('/api/contract/' + encodeURIComponent(appId) + '/export-ifc', { method: 'POST' });
5153
+ const url0 = '/api/contract/' + encodeURIComponent(appId) + '/export-ifc';
5154
+ let res;
5155
+ try { res = await api(url0, { method: 'POST' }); }
5156
+ catch (err) {
5157
+ // Add-ons S1a: members on a custom section with no IFC shape are asked about before anything is written.
5158
+ const ask = err && err.body && err.body.needsChoice === 'custom-sections' ? err.body : null;
5159
+ if (!ask) throw err;
5160
+ const members = Array.isArray(ask.members) ? ask.members : [];
5161
+ const named = members.slice(0, 6).map((m) => `${m.id} (${m.designation})`).join(', ') + (members.length > 6 ? `, and ${members.length - 6} more` : '');
5162
+ const chosen = await formModal({
5163
+ title: 'Custom sections in this IFC file',
5164
+ sub: `${ask.message}${named ? ` Members: ${named}.` : ''} Nothing is exported until you choose.`,
5165
+ okLabel: 'Export',
5166
+ fields: [{
5167
+ name: 'choice', label: 'For these members', type: 'select', value: 'leave-out', commandId: 'shell.ifc-custom-section-choice',
5168
+ options: [
5169
+ { value: 'leave-out', label: 'Leave them out', meta: 'Recommended · listed as left out' },
5170
+ { value: 'bounding-box', label: 'Send their bounding box', meta: 'Named as an assumption' },
5171
+ ],
5172
+ }],
5173
+ });
5174
+ if (!chosen) { showToast('IFC export stopped. Nothing was exported.', 'info'); return; }
5175
+ res = await api(url0, { method: 'POST', headers: { 'content-type': 'application/json' },
5176
+ body: JSON.stringify({ customSections: { choice: chosen.choice === 'bounding-box' ? 'bounding-box' : 'leave-out', key: ask.key } }) });
5177
+ }
4964
5178
  if (res.counts) exportReceiptsByApp.set(exportReceiptKey(appId, 'ifc'), {
4965
5179
  counts: res.counts,
4966
5180
  warnings: res.warnings || [],
@@ -4991,12 +5205,17 @@
4991
5205
  const noScale = byReason('view-scale-invalid');
4992
5206
  const conflict = byReason('cross-view-conflict');
4993
5207
  const mixedPlacement = byReason('placement-evidence-conflict');
5208
+ // Add-ons S1a: a member on a custom section is not an RFI member; it is one this file does not carry as itself.
5209
+ const customOut = byReason('custom-section-not-exported') + byReason('custom-section-unverified');
4994
5210
  const rfi = detail
4995
- ? detail.length - noFit - noHeight - noFrame - noScale - conflict - mixedPlacement
5211
+ ? detail.length - noFit - noHeight - noFrame - noScale - conflict - mixedPlacement - customOut
4996
5212
  : skips.filter((s) => !SKIP_REASON_PREFIX.test(String(s))).length;
4997
5213
  const notes = [];
4998
5214
  if (isVector) { if (dropped) notes.push(`${dropped} unplaced`); }
4999
5215
  else {
5216
+ if (customOut) notes.push(`${customOut} on a custom section this file leaves out`);
5217
+ const boxed = Array.isArray(res.customSections) ? res.customSections.filter((row) => row && row.sent === 'bounding-box').length : 0;
5218
+ if (boxed) notes.push(`${boxed} sent as a bounding box, named in the file as an assumption`);
5000
5219
  // Same wording as the 3D toast, deliberately: the two describe the same members of the same
5001
5220
  // document, and two sentences for one fact is how a user learns to distrust both.
5002
5221
  if (noHeight) notes.push(`${noHeight} with no known height — answer the elevation question`);
@@ -5169,6 +5388,8 @@
5169
5388
  'view-scale-invalid': 'no valid drawing scale',
5170
5389
  'cross-view-conflict': 'conflicting drawing views',
5171
5390
  'placement-evidence-conflict': 'conflicting placement evidence',
5391
+ 'custom-section-unverified': 'a custom section that cannot be checked',
5392
+ 'custom-section-not-exported': 'a custom section this send does not carry',
5172
5393
  };
5173
5394
  const grouped = {};
5174
5395
  rows.forEach((row) => { grouped[row.reason] = (grouped[row.reason] || 0) + 1; });
@@ -5414,18 +5635,24 @@
5414
5635
  $reportShare.hidden = true; // the frame is blank — only a painted report is shareable
5415
5636
  $reportOverlay.hidden = false;
5416
5637
  let clientRunToken = null;
5417
- if (opts.debug) {
5418
- $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>`;
5419
- $reportOverlay.prepend(runningFlo());
5420
- } else {
5421
- // #2228: the working Flo, what the run is doing, elapsed time and a real bar when the run reports one —
5422
- // the same view the canvas strip uses, so a long render reads the same in both places.
5638
+ const runAppId = currentId;
5639
+ // #2228: the working Flo, what the run is doing, elapsed time and a real bar when the run reports one —
5640
+ // the same view the canvas strip uses, so a long render reads the same in both places. #3253: a Run anyway resend
5641
+ // is watched as a new attempt with a view of its own; this run then holds that one.
5642
+ const trackOverlay = () => {
5423
5643
  $reportOverlay.replaceChildren();
5424
5644
  const host = mkEl('div', 'rp-host');
5425
5645
  $reportOverlay.append(host); // Stop lives in the report header (#reportStop), beside the run it stops
5426
- clientRunToken = beginLiveRun(currentId, 'overlay', host,
5646
+ clientRunToken = beginLiveRun(runAppId, 'overlay', host,
5427
5647
  approvedModelReport ? 'Reading the selected approved model to make a complete, read-only report…' : 'Running the workflow against the live model…');
5428
5648
  if (!host.firstChild) $reportOverlay.prepend(runningFlo()); // the view could not mount: keep the working Flo
5649
+ return clientRunToken;
5650
+ };
5651
+ if (opts.debug) {
5652
+ $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>`;
5653
+ $reportOverlay.prepend(runningFlo());
5654
+ } else {
5655
+ trackOverlay();
5429
5656
  }
5430
5657
  let liveOutcome = 'failed';
5431
5658
  const $reportWatch = document.getElementById('report-watch');
@@ -5438,10 +5665,12 @@
5438
5665
  // so VS attaches to aware-tekla.exe; a normal run goes through aware app run.
5439
5666
  const res = opts.debug
5440
5667
  ? 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 } : {}) });
5668
+ : await dispatchManualRun(request, { id: app.id, simulate: false, inputs, ...(clientRunToken ? { clientRunToken } : {}) }, trackOverlay);
5442
5669
  liveOutcome = 'ok';
5443
5670
  const reportVideos = runVideos(res);
5444
5671
  if (res && typeof res.mediaWarning === 'string') showToast(res.mediaWarning, 'warn');
5672
+ // #3228: a step that works with FloLess was turned away (another FloLess replaced the connection): say so in plain words.
5673
+ if (res && typeof res.connectionWarning === 'string') showToast(res.connectionWarning, 'warn');
5445
5674
  if ($reportWatch && reportVideos.length) {
5446
5675
  $reportWatch.hidden = false;
5447
5676
  $reportWatch.onclick = () => watchRunVideos(reportVideos, `Rendered by ${app.displayName}`);
@@ -5471,13 +5700,15 @@
5471
5700
  $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
5701
  }
5473
5702
  const withFiles = !!(res.report && res.report.withFiles);
5474
- paintReport(html, interactive, { withFiles, runId: typeof res.runId === 'string' ? res.runId : null });
5475
- if (!interactive) $reportSub.textContent = 'Report created from the latest workflow run.';
5703
+ // #3229: the run stopped at an AI step's check after this report was made; the viewer says so above it.
5704
+ const aiStop = globalThis.flolessAgentSteps?.stoppedRunView?.(res) ?? null;
5705
+ paintReport(html, interactive, { withFiles, runId: typeof res.runId === 'string' ? res.runId : null, aiStop });
5706
+ if (!interactive) $reportSub.textContent = aiStop ? 'Report created before the run stopped.' : 'Report created from the latest workflow run.';
5476
5707
  // If a node wrote an output file, the run reports its path — surface the
5477
5708
  // ⧉ Open file / ▤ Reveal buttons and cache it so a later double-click restores them (#209).
5478
5709
  const savedPath = res && typeof res.savedPath === 'string' ? res.savedPath : '';
5479
5710
  showSavedPathActions(savedPath);
5480
- lastReportByApp.set(currentId, { nodeId, label: inputBadge, html, interactive, savedPath, withFiles, runId: typeof res.runId === 'string' ? res.runId : null });
5711
+ lastReportByApp.set(currentId, { nodeId, label: inputBadge, html, interactive, savedPath, withFiles, runId: typeof res.runId === 'string' ? res.runId : null, aiStop });
5481
5712
  paintReportPageLinks();
5482
5713
  $reportModal.dataset.html = '1';
5483
5714
  reportReadyNote(app, nodeId);
@@ -5504,6 +5735,8 @@
5504
5735
  // in the viewer overlay + a toast. No console.error — the server returns the
5505
5736
  // failure in-band, so a failed run isn't a console-worthy fault.
5506
5737
  $reportSub.textContent = 'Execution ended without a report.';
5738
+ // #3228: one of its steps could not connect to FloLess; this says why, beside the failure.
5739
+ if (e.body && typeof e.body.connectionWarning === 'string') showToast(e.body.connectionWarning, 'warn');
5507
5740
  // #2796: Try again only once the server has answered that this run ended. With no answer the run may still be
5508
5741
  // going on the host, and a second one could do its work twice.
5509
5742
  showRunFailure(e.body || {}, runFailureMessage(msg), app, opts.debug || liveOutcome === 'no-answer' ? null : () => runReport(nodeId));
@@ -5511,7 +5744,7 @@
5511
5744
  }
5512
5745
  } finally {
5513
5746
  if (request) finishManualRun(request);
5514
- if (clientRunToken) { if (liveOutcome === 'no-answer') settleLiveRunWithoutAnswer(); else finishLiveRun(liveOutcome); }
5747
+ finishOwnLiveRun(clientRunToken, liveOutcome);
5515
5748
  reportRunning = false;
5516
5749
  syncRunControls(); // run ended — hide the header Stop, restore Run from the gate
5517
5750
  paintReportPageLinks(); // #2539: hidden while the run was in flight; its Page version may already be known
@@ -5621,6 +5854,29 @@
5621
5854
  $reportOverlay.innerHTML = `<div>Run completed but <code>${escapeHtml(nodeId)}</code> returned no <code>html</code>. Check the Execution tab.</div>`;
5622
5855
  }
5623
5856
 
5857
+ // #3229: the report shown was made before the run stopped at an AI step's check (`view` from flolessAgentSteps.stoppedRunView),
5858
+ // or null to hide the banner. Above the frame, never over it, and not dismissible: it goes with the next run or report.
5859
+ // textContent only — the step id comes from the run.
5860
+ function paintAiStopBanner(view) {
5861
+ const banner = document.getElementById('report-ai-stop');
5862
+ if (!banner) return;
5863
+ banner.replaceChildren();
5864
+ banner.hidden = !view;
5865
+ if (!view) return;
5866
+ const appId = currentId;
5867
+ const open = mkEl('button', 'ghost report-ai-stop-open', view.button);
5868
+ open.type = 'button';
5869
+ open.dataset.commandId = view.commandId;
5870
+ open.onclick = async () => {
5871
+ let shown = false;
5872
+ try { shown = await globalThis.flolessAgentSteps?.openQuestions(appId, view.runId, () => hideModal($reportModal)) === true; } catch { shown = false; }
5873
+ if (shown) return;
5874
+ showToast('FloLess couldn’t show this run in Last run yet. Close the viewer, then open Last run above the canvas.', 'warn');
5875
+ open.focus();
5876
+ };
5877
+ banner.append(mkEl('span', 'report-ai-stop-status', 'Needs you'), mkEl('span', 'report-ai-stop-text', view.banner), open);
5878
+ }
5879
+
5624
5880
  // #2415: the run stopped before the report because an AI step did not answer. Not a fault, so no Report this problem:
5625
5881
  // the way on is the step's questions, in the canvas's Last run panel. textContent only — step names come from the run.
5626
5882
  function showAiStepStopped(view, appId) {
@@ -5768,6 +6024,14 @@
5768
6024
  $cancel.textContent = (actionLabels && actionLabels.cancel) || 'Cancel';
5769
6025
  $dont.hidden = !!(actionLabels && actionLabels.hideDiscard);
5770
6026
  $save.hidden = !!(actionLabels && actionLabels.hideSave); // when there is nothing safe to save (a refused write)
6027
+ // A caller that gives the buttons another meaning names it, so Instructor explains what they do here.
6028
+ const ownIds = [$save, $dont, $cancel].map((b) => b.getAttribute('data-command-id'));
6029
+ const ids = actionLabels && actionLabels.commandIds;
6030
+ if (ids) {
6031
+ if (ids.confirm) $save.setAttribute('data-command-id', ids.confirm);
6032
+ if (ids.discard) $dont.setAttribute('data-command-id', ids.discard);
6033
+ if (ids.cancel) $cancel.setAttribute('data-command-id', ids.cancel);
6034
+ }
5771
6035
  $title.textContent = titleMsg || 'Unsaved input changes'; // reset each call (default = the inputs-switch copy)
5772
6036
  $sub.textContent = subMsg || `You changed the inputs for “${appName}” but haven’t saved them yet. What would you like to do?`;
5773
6037
  showModal($confirmModal);
@@ -5786,6 +6050,7 @@
5786
6050
  });
5787
6051
  $dont.hidden = false;
5788
6052
  $save.hidden = false;
6053
+ [$save, $dont, $cancel].forEach((b, i) => { if (ownIds[i] !== null) b.setAttribute('data-command-id', ownIds[i]); });
5789
6054
  document.removeEventListener('keydown', onKey, true);
5790
6055
  $save.onclick = $dont.onclick = $cancel.onclick = $confirmModal.onclick = null;
5791
6056
  if (returnFocus && returnFocus.isConnected && !returnFocus.matches(':disabled,[aria-disabled="true"]')) returnFocus.focus();
@@ -5953,6 +6218,8 @@
5953
6218
  'view-scale-invalid': 'Source view has no valid drawing scale',
5954
6219
  'cross-view-conflict': 'Source views disagree on placement',
5955
6220
  'placement-evidence-conflict': 'Invalid scale and conflicting placement evidence',
6221
+ 'custom-section-unverified': 'Custom section cannot be checked',
6222
+ 'custom-section-not-exported': 'Custom section is not carried by this send',
5956
6223
  'not-in-model': 'No longer in the model',
5957
6224
  };
5958
6225
  const groups = new Map();
@@ -6035,6 +6302,7 @@
6035
6302
  else if (f.commandId === 'shell.new-workflow-location') commandCarrier = ' data-command-id="shell.new-workflow-location"';
6036
6303
  else if (f.commandId === 'workflow.select-model-revision') commandCarrier = ' data-command-id="workflow.select-model-revision"';
6037
6304
  else if (f.commandId === 'shell.render-caption-choice') commandCarrier = ' data-command-id="shell.render-caption-choice"';
6305
+ else if (f.commandId === 'shell.ifc-custom-section-choice') commandCarrier = ' data-command-id="shell.ifc-custom-section-choice"';
6038
6306
  let optionIndex = 0;
6039
6307
  const optionRow = (o) => `<div id="${id}-option-${optionIndex++}" class="wf-option${isOn(o) && !o.unavailable ? ' selected' : ''}${o.volatile ? ' volatile' : ''}${o.unavailable ? ' is-unavailable' : ''}" role="option" data-id="${escapeAttr(String(o.value))}" data-trigger-label="${escapeAttr(o.triggerLabel || '')}"${o.unavailable ? ` aria-disabled="true" data-blocked-reason="${escapeAttr(String(o.unavailable))}" data-tip="${escapeAttr(String(o.unavailable))}"` : ''}${commandCarrier}${commandCarrier ? ` data-command-instance="${escapeAttr(String(o.value))}" data-command-instance-label="${escapeAttr(String(o.label))}"` : ''} data-search="${escapeAttr(String(o.search || o.label).toLowerCase())}" tabindex="-1" aria-label="${escapeAttr(o.ariaLabel || o.label)}" aria-selected="${isOn(o) ? 'true' : 'false'}"><span class="wf-option-name">${escapeHtml(o.label)}</span>${o.meta ? `<span class="wf-option-meta">${escapeHtml(o.meta)}</span>` : ''}</div>`;
6040
6308
  const grouped = opts.some((o) => o.group);
@@ -6745,7 +7013,7 @@
6745
7013
  // #2539: a busy report is waited for here too, saying why, and the object opens by itself.
6746
7014
  if (error?.body?.code !== 'report-busy' || Date.now() >= waitUntil) throw error;
6747
7015
  if (stale()) { leave(); return; } // a busy answer for a lookup already replaced writes nothing
6748
- $reportObjectError.textContent = String(error.body.error || 'This report is busy. It opens as soon as that finishes.');
7016
+ $reportObjectError.textContent = personText(error.body) || 'This report is busy. It opens as soon as that finishes.';
6749
7017
  $reportObjectError.hidden = false;
6750
7018
  await new Promise((resolve) => setTimeout(resolve, Math.min(10_000, Math.max(500, Number(error.body.retryAfterMs) || 2_000))));
6751
7019
  if (stale()) { leave(); return; }
@@ -6759,7 +7027,7 @@
6759
7027
  if (stale()) { leave(); return; }
6760
7028
  $reportObjectError.textContent = error?.body?.code === 'report-busy'
6761
7029
  ? 'This report is still busy. Choose Go again to open that object.'
6762
- : error?.message || 'Could not find that object. Try again.';
7030
+ : errorText(error, { action: 'find that object', retrySafe: true });
6763
7031
  $reportObjectError.hidden = false;
6764
7032
  }
6765
7033
  };
@@ -6798,7 +7066,7 @@
6798
7066
  // #2539: busy is not a failure of access; the report is there, it is just being read.
6799
7067
  showToast(error?.body?.code === 'report-busy'
6800
7068
  ? 'This report is busy, so it can’t be downloaded yet. Choose Download complete report again in a moment.'
6801
- : error?.message || 'Report access could not be confirmed. Try again.', 'warn');
7069
+ : errorText(error, { action: 'download the complete report', retrySafe: true }), 'warn');
6802
7070
  }
6803
7071
  };
6804
7072
 
@@ -6828,7 +7096,7 @@
6828
7096
  try {
6829
7097
  // The report stays open until the Page is known to open (beforeShow); a Page that cannot be opened says why and leaves it.
6830
7098
  await window.flolessPages.open(page.home, page.pageId, page.version, { share: true, beforeShow: () => closeReportViewer() });
6831
- } catch (e) { showToast(`FloLess couldn’t open the workflow’s Page to share it. ${e && e.message ? e.message : ''}`.trim(), 'warn'); }
7099
+ } catch (e) { showToast(errorText(e, { action: 'open the workflow’s Page to share it', retrySafe: true }), 'warn'); }
6832
7100
  return;
6833
7101
  }
6834
7102
  // Share exactly what's on screen — the HTML we painted — so the link can never carry a different
@@ -6977,9 +7245,18 @@
6977
7245
  if (currentId !== newId) { showToast(`${name} is compiled.`, 'ok'); return; } // a newer choice won while it was opening
6978
7246
  const app = apps.get(newId);
6979
7247
  const consent = globalThis.flolessAgentSteps?.consentStatus ? await globalThis.flolessAgentSteps.consentStatus(newId) : null;
7248
+ // #3284: the answer is about this version's confirmation, so it is never said over another workflow opened while it was read.
7249
+ if (currentId !== newId) { showToast(`${name} is compiled.`, 'ok'); return; }
6980
7250
  const unconfirmed = consent && (consent.state === 'needed' || consent.state === 'changed');
6981
7251
  if (unconfirmed) {
6982
7252
  showToast('Workflow compiled. Confirm its AI step before it runs.', 'ok');
7253
+ } else if (app?.runnable && consent?.state === 'current' && consent.latest?.onOtherVersion) {
7254
+ // #3284: not asked, because the step is what the person ticked; the new version's write warning is still theirs to see.
7255
+ const kept = (consent.steps?.length ?? 1) > 1
7256
+ ? 'Workflow compiled. The AI steps are unchanged, so the earlier confirmation that their answers may differ each run still stands.'
7257
+ : 'Workflow compiled. The AI step is unchanged, so the earlier confirmation that its answer may differ each run still stands.';
7258
+ if (consent.carriedWarning) standingToast('compile', `${kept} ${consent.carriedWarning}`, 'warn');
7259
+ else { standingToast('compile'); showToast(kept, 'ok'); }
6983
7260
  } else {
6984
7261
  compiledToast(app);
6985
7262
  }
@@ -7727,9 +8004,8 @@
7727
8004
  await window.flolessChat.openVerifiedTeklaDraft(receipt);
7728
8005
  } catch (e) {
7729
8006
  console.warn('Continue in AI Chat failed', e);
7730
- showToast(e?.plainEnglish && e.message
7731
- ? e.message
7732
- : 'FloLess could not open AI Chat. Open a project or workflow, then verify the model read again.', 'warn');
8007
+ // AI Chat's own refusals are marked forPerson (chat.js); anything else gets the shared sentence (#3097 errorText).
8008
+ showToast(errorText(e, { action: 'open AI Chat', unsure: 'Open a project or workflow, then verify the model read again.' }), 'warn');
7733
8009
  return;
7734
8010
  }
7735
8011
  closeGraftModal();
@@ -8227,8 +8503,9 @@
8227
8503
  }
8228
8504
  // A file FloLess could not read is a 400. The Workspace refusing to keep it (no Workspace folder, a folder it
8229
8505
  // cannot write) is labelled by the server, whose sentence names why. Anything else is unconfirmed: it may have been kept.
8230
- showToast(body && body.stage === 'workspace' && typeof body.error === 'string' && body.error
8231
- ? `We couldn’t save that workflow to your Workspace: ${body.error.replace(/[.\s]+$/, '')}. Try again.`
8506
+ const workspaceSaid = body && body.stage === 'workspace' ? personText(body) : '';
8507
+ showToast(workspaceSaid
8508
+ ? `We couldn’t save that workflow to your Workspace: ${workspaceSaid.replace(/[.\s]+$/, '')}. Try again.`
8232
8509
  // Only a 400 is a verdict on the file; a lost response (no status) may follow a kept draft.
8233
8510
  : e && e.status === 400
8234
8511
  ? 'We couldn’t import that workflow because FloLess could not read it. Check the file, then try again.'
@@ -8700,12 +8977,16 @@
8700
8977
  }
8701
8978
  if (!r.ok || !d.ok) throw new Error(d.error || 'update failed');
8702
8979
  // Success: the server is exiting + Update.exe relaunches the new build. The health
8703
- // poll flips to offline (R1 overlay), then the new version reconnects on its own.
8980
+ // poll flips to offline, and the card says FloLess is updating (not that it stopped
8981
+ // responding); then the new version reconnects on its own.
8982
+ markAppUpdateRelaunch(v);
8704
8983
  // Recovery guard: if the relaunch never happens and this page stays alive (e.g. a UAC
8705
8984
  // prompt was declined after the server already responded), re-enable the pill after 90 s
8706
8985
  // so the user can retry — the page won't go offline in that case.
8707
8986
  _appUpdateRecoveryTimer = setTimeout(() => {
8708
8987
  _appUpdateRecoveryTimer = null;
8988
+ // FloLess never went away for the update: a later outage is not this update.
8989
+ if (serverState !== 'updating') clearAppUpdateRelaunch();
8709
8990
  if ($appUpdate && $appUpdate.disabled) {
8710
8991
  $appUpdate.disabled = false;
8711
8992
  _updateApplying = null; // relaunch never happened — release the lock so retry works
@@ -8715,6 +8996,7 @@
8715
8996
  }
8716
8997
  }, 90_000);
8717
8998
  } catch (e) {
8999
+ clearAppUpdateRelaunch();
8718
9000
  $appUpdate.disabled = false;
8719
9001
  _updateApplying = null;
8720
9002
  try { localStorage.removeItem('floless.whatsNew.pending'); } catch { /* private mode */ }
@@ -9257,7 +9539,7 @@
9257
9539
  // first /api/workflows/updates went out ahead of /api/apps and the workflow picker then waited
9258
9540
  // behind it — measured empty for ~59 s on a cold server (#358). It is an OFFER (a pill), never
9259
9541
  // needed for first paint. It was also firing while the subscription gate would 402 it, then not
9260
- // retrying for an hour — the same reason panels.js boot is deferred to loadWorkspaceData().
9542
+ // retrying for an hour.
9261
9543
  // loadWorkspaceData() re-runs when the health poll recovers from an outage, so only the INTERVAL is
9262
9544
  // guarded — the fetch itself must repeat. Guarding the whole function meant a first load that failed
9263
9545
  // during an outage (the fetch fails too) marked the poll started, and the recovery run was then
@@ -10200,11 +10482,13 @@
10200
10482
  liveTrace.length = 0;
10201
10483
  state.hasRun = true;
10202
10484
  // #2228: a simulated run stubs every node, so it reports no progress; a real one is watched live.
10203
- const clientRunToken = simulate ? null : beginLiveRun(currentId, 'strip');
10485
+ let clientRunToken = simulate ? null : beginLiveRun(currentId, 'strip');
10204
10486
  let liveOutcome = 'failed';
10205
10487
  try {
10206
10488
  const runAppId = currentId;
10207
- const res = await dispatchManualRun(request, { id: app.id, simulate, inputs: currentInputs(), ...(clientRunToken ? { clientRunToken } : {}) });
10489
+ // #3253: a Run anyway resend is watched as a new attempt; this run then holds that one.
10490
+ const retrack = () => (clientRunToken = beginLiveRun(runAppId, 'strip'));
10491
+ const res = await dispatchManualRun(request, { id: app.id, simulate, inputs: currentInputs(), ...(clientRunToken ? { clientRunToken } : {}) }, retrack);
10208
10492
  liveOutcome = 'ok';
10209
10493
  const videos = runVideos(res);
10210
10494
  if (videos.length) { finishLiveRun('ok'); offerRunVideos(runAppId, videos); }
@@ -10212,11 +10496,20 @@
10212
10496
  if (res && typeof res.mediaWarning === 'string') showToast(res.mediaWarning, 'warn');
10213
10497
  // SSE usually fills liveTrace first; backfill from the response if it didn't.
10214
10498
  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
- if (res.credentialIssue) { surfaceCredentialIssue(res.credentialIssue); return; }
10499
+ // A "succeeded" run carrying a rejected token → prompt reconnect, not a result. #3228: a step that could not connect
10500
+ // to FloLess is still said, so the step that did not run is never left unmentioned behind the reconnect prompt.
10501
+ if (res.credentialIssue) {
10502
+ if (typeof res.connectionWarning === 'string') showToast(res.connectionWarning, 'warn');
10503
+ surfaceCredentialIssue(res.credentialIssue); return;
10504
+ }
10217
10505
  switchToExecution();
10218
10506
  const steps = liveTrace.filter((r) => r.kind === 'node-start').length;
10219
- standingToast('run', simulate ? `Simulated run complete · ${steps} node${steps === 1 ? '' : 's'} stubbed. See the Execution tab.`
10507
+ // #3228: a run can end with a step that works with FloLess turned away; "Run complete" would hide that it did not run.
10508
+ // #3229: a run its AI step's check stopped ended "ok"; the toast says where it stopped, never "Run complete".
10509
+ const aiStop = !simulate ? globalThis.flolessAgentSteps?.stoppedRunView?.(res) ?? null : null;
10510
+ if (res && typeof res.connectionWarning === 'string') standingToast('run', res.connectionWarning, 'warn', false);
10511
+ else if (aiStop) standingToast('run', aiStop.toast, 'warn'); // stays up: it may be the only sign the run did not finish
10512
+ else standingToast('run', simulate ? `Simulated run complete · ${steps} node${steps === 1 ? '' : 's'} stubbed. See the Execution tab.`
10220
10513
  : `Run complete · ${steps} node${steps === 1 ? '' : 's'}. See the Execution tab.`, 'ok', false);
10221
10514
  } catch (e) {
10222
10515
  liveOutcome = (e && e.body && e.body.cancelled) ? 'stopped'
@@ -10232,7 +10525,8 @@
10232
10525
  } else {
10233
10526
  const cred = e.body && e.body.credentialIssue;
10234
10527
  if (cred) {
10235
- // A rejected token — prompt reconnect for that integration, not the host hint.
10528
+ // A rejected token — prompt reconnect for that integration, not the host hint (#3228: and say the FloLess step too).
10529
+ if (e.body && typeof e.body.connectionWarning === 'string') showToast(e.body.connectionWarning, 'warn');
10236
10530
  surfaceCredentialIssue(cred);
10237
10531
  } else {
10238
10532
  // A failed run is an expected, recoverable outcome (the server returns it
@@ -10246,14 +10540,16 @@
10246
10540
  if (e && e.body && (e.body.refusal || notRun)) clearNodeStatus();
10247
10541
  // A not-run answer is already a whole sentence ("…, so it didn’t run. …"); "Run failed:" would misstate it.
10248
10542
  // Nothing failed — it was declined with a reason — so the toast is informational, not a warning.
10249
- standingToast('run', notRun ? runFailureMessage(msg)
10543
+ // #3228: the failure was a step that could not connect to FloLess: that sentence says what happened and what to do.
10544
+ const connection = e && e.body && typeof e.body.connectionWarning === 'string' ? e.body.connectionWarning : null;
10545
+ standingToast('run', connection ?? (notRun ? runFailureMessage(msg)
10250
10546
  : 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');
10547
+ : 'Run failed: ' + runFailureMessage(msg)), notRun && !connection ? 'info' : 'warn');
10252
10548
  }
10253
10549
  }
10254
10550
  } finally {
10255
10551
  finishManualRun(request);
10256
- if (clientRunToken) { if (liveOutcome === 'no-answer') settleLiveRunWithoutAnswer(); else finishLiveRun(liveOutcome); }
10552
+ finishOwnLiveRun(clientRunToken, liveOutcome);
10257
10553
  state.running = false;
10258
10554
  runningSimulation = false;
10259
10555
  $runBtn.disabled = false;
@@ -10397,6 +10693,20 @@
10397
10693
  let serverOnline = null;
10398
10694
  // SSE is newer evidence than a health probe already in flight. Fence all effects of that probe.
10399
10695
  let serverObservationEpoch = 0;
10696
+ // What the card says while FloLess is not answering (2026-11-06). A health check that goes unanswered while the
10697
+ // /api/events stream is still open means the FloLess process is alive but busy: a process that exits closes that
10698
+ // connection, and the stream's error moves the card to 'reconnecting' at once. That is weak evidence (a stuck process
10699
+ // keeps its connection open too), so the busy copy only says FloLess may be busy, and offers a refresh after
10700
+ // BUSY_ESCALATE_MS.
10701
+ // 'updating' is an update the person started, which closes FloLess and opens the new version.
10702
+ let serverState = null; // 'online' | 'busy' | 'reconnecting' | 'updating'
10703
+ let eventStreamOpen = false;
10704
+ let appUpdateRelaunch = null; // { version, until } while an update the person started relaunches FloLess
10705
+ let appUpdateRelaunchTimer = null;
10706
+ const BUSY_ESCALATE_MS = 120000; // offer a refresh (it stops nothing)
10707
+ const BUSY_STUCK_MS = 600000; // only then suggest closing FloLess, which stops what it was doing
10708
+ 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)
10709
+ const APP_UPDATE_RELAUNCH_MAX_MS = 600000; // past this an outage is an ordinary one, whatever was started before
10400
10710
 
10401
10711
  // The overlay leads with AUTO-RECOVERY. The login watchdog (FlolessApp --supervise)
10402
10712
  // respawns a dead server within seconds, so a crash heals itself with NO user action
@@ -10409,6 +10719,8 @@
10409
10719
  // reliable fallback when the watchdog itself is down is "reopen FloLess", which the
10410
10720
  // escalation line offers. The link is a real <a href> the USER clicks — a synthetic
10411
10721
  // anchor.click() is silently dropped by Chromium for external protocols.
10722
+ // Since 2026-11-06 the card also says 'Waiting for FloLess…' (busy: Start is never offered, FloLess is running) and
10723
+ // 'Updating FloLess…' (Start after APP_UPDATE_RELAUNCH_MS); SERVER_STATE_ESCALATIONS holds each state's timing.
10412
10724
  const ESCALATE_MS = 15000; // 3 missed 5s health polls ⇒ the watchdog isn't recovering
10413
10725
  let escalateTimer = null;
10414
10726
  let lastFocusBeforeOverlay = null;
@@ -10435,18 +10747,86 @@
10435
10747
  const next = at < 0 ? (event.shiftKey ? actions.length - 1 : 0) : (at + (event.shiftKey ? actions.length - 1 : 1)) % actions.length;
10436
10748
  actions[next].focus();
10437
10749
  }
10438
- function showOfflineOverlay() {
10439
- if (offlineOverlayEl) return;
10750
+ /** The card's words for one state; `footer` is the status bar label. Never claims more than the window can see. */
10751
+ function serverStateCopy(state) {
10752
+ const desktop = document.documentElement.classList.contains('desktop');
10753
+ const view = desktop ? 'This window' : 'This tab';
10754
+ if (state === 'busy') {
10755
+ return { title: 'Waiting for FloLess…', footer: 'waiting for FloLess',
10756
+ 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.` };
10757
+ }
10758
+ if (state === 'updating') {
10759
+ const what = appUpdateRelaunch?.version ? `version ${appUpdateRelaunch.version}` : 'an update';
10760
+ return { title: 'Updating FloLess…', footer: 'updating FloLess',
10761
+ body: `FloLess is installing ${what} and will open again by itself. Please keep ${view.toLowerCase()} open. It reconnects when FloLess is back.` };
10762
+ }
10763
+ return { title: 'Reconnecting to FloLess…', footer: 'server offline',
10764
+ body: `FloLess isn’t responding. ${desktop ? 'FloLess' : 'This tab'} will keep trying to reconnect.` };
10765
+ }
10766
+ /** What the card says once a state has lasted a while, and which choices it then offers. */
10767
+ const SERVER_STATE_ESCALATIONS = {
10768
+ reconnecting: [{ after: ESCALATE_MS, refresh: true, start: true,
10769
+ text: 'This is taking longer than usual. You can refresh this page, or start FloLess if it is closed.' }],
10770
+ // FloLess is running, so never "Start". Refreshing is offered first because it stops nothing; quitting is advised only
10771
+ // much later, because it does stop what FloLess is doing (a large approval can take several minutes).
10772
+ busy: [
10773
+ { after: BUSY_ESCALATE_MS, refresh: true, start: false,
10774
+ text: 'Still waiting. Large jobs can take several minutes. Refreshing this page does not stop FloLess.' },
10775
+ { after: BUSY_STUCK_MS, refresh: true, start: false,
10776
+ 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.` },
10777
+ ],
10778
+ // The old FloLess has closed by now, so starting it is a real choice if the new one does not open by itself.
10779
+ updating: [{ after: APP_UPDATE_RELAUNCH_MS, refresh: true, start: true,
10780
+ 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.' }],
10781
+ };
10782
+ /** Say `state` on the card: its words, which choices show, and when it escalates. Restarts the escalation on every
10783
+ * call; setServerStatus calls it only when the state changes, so repeats of one state never restart it. */
10784
+ function applyOverlayState(state) {
10785
+ if (!offlineOverlayEl) return;
10786
+ const copy = serverStateCopy(state);
10787
+ offlineOverlayEl.querySelector('h1').textContent = copy.title;
10788
+ offlineOverlayEl.querySelector('.so-body').textContent = copy.body;
10789
+ const card = offlineOverlayEl.querySelector('.so-card');
10790
+ const focusedChoice = offlineOverlayEl.contains(document.activeElement) && document.activeElement !== card;
10791
+ const show = (step) => {
10792
+ const status = document.getElementById('so-status');
10793
+ if (status) status.textContent = step ? step.text : '';
10794
+ const refresh = document.getElementById('so-refresh');
10795
+ if (refresh) refresh.hidden = !step?.refresh;
10796
+ const start = document.getElementById('so-start');
10797
+ if (start) start.hidden = !step?.start;
10798
+ };
10799
+ show(null);
10800
+ // A choice that just disappeared must not keep focus: back to the card.
10801
+ if (focusedChoice && document.activeElement?.hidden) card.focus();
10802
+ if (escalateTimer) { clearTimeout(escalateTimer); escalateTimer = null; }
10803
+ let at = 0;
10804
+ const next = (steps) => {
10805
+ const step = steps[0];
10806
+ if (!step) return;
10807
+ escalateTimer = setTimeout(() => {
10808
+ escalateTimer = null;
10809
+ if (serverState !== state) return; // healed, or now saying something else
10810
+ show(step);
10811
+ next(steps.slice(1));
10812
+ }, step.after - at);
10813
+ at = step.after;
10814
+ };
10815
+ next(SERVER_STATE_ESCALATIONS[state] || []);
10816
+ }
10817
+ function showOfflineOverlay(state = 'reconnecting') {
10818
+ if (offlineOverlayEl) { applyOverlayState(state); return; }
10440
10819
  lastFocusBeforeOverlay = document.activeElement; // restored on heal (WCAG 2.4.3)
10441
10820
  const wrap = document.createElement('div');
10442
10821
  wrap.id = 'server-offline-overlay';
10443
- // role=status on the card → screen readers announce its text on insertion. The
10444
- // spinner is decorative (aria-hidden). The manual link is hidden until escalation.
10822
+ // role=status on the card → screen readers announce its text on insertion, and its changes
10823
+ // when the state moves (busy → reconnecting). The spinner is decorative (aria-hidden). The
10824
+ // manual choices are hidden until escalation.
10445
10825
  wrap.innerHTML =
10446
- `<div class="so-card" role="status" tabindex="-1">
10826
+ `<div class="so-card" role="status" aria-atomic="true" tabindex="-1">
10447
10827
  <div class="so-spinner" aria-hidden="true"></div>
10448
- <h1>Reconnecting to FloLess…</h1>
10449
- <p>FloLess isn’t responding. ${document.documentElement.classList.contains('desktop') ? 'FloLess' : 'This tab'} will keep trying to reconnect.</p>
10828
+ <h1></h1>
10829
+ <p class="so-body"></p>
10450
10830
  <p class="so-status" id="so-status"></p>
10451
10831
  <div class="so-actions">
10452
10832
  <button type="button" id="so-refresh" data-command-id="app.reconnect-refresh" class="secondary" hidden>Refresh page</button>
@@ -10470,20 +10850,27 @@
10470
10850
  }
10471
10851
  });
10472
10852
  window.addEventListener('keydown', trapOfflineOverlayKeys, true);
10853
+ applyOverlayState(state);
10473
10854
  // No action is required, so move focus to the CARD (tabindex=-1), NOT the link —
10474
10855
  // keeps keyboard focus inside the overlay without implying the link is the action.
10475
10856
  if (!document.getElementById('leave-guard-modal')?.classList.contains('show')) wrap.querySelector('.so-card').focus();
10476
- // Reveal the manual fallback only if recovery is clearly stuck (watchdog down).
10477
- if (escalateTimer) clearTimeout(escalateTimer);
10478
- escalateTimer = setTimeout(() => {
10479
- if (serverOnline === true) return; // healed
10480
- const s = document.getElementById('so-status');
10481
- const a = document.getElementById('so-start');
10482
- if (s) s.textContent = 'This is taking longer than usual. You can refresh this page, or start FloLess if it is closed.';
10483
- const refresh = document.getElementById('so-refresh');
10484
- if (refresh) refresh.hidden = false;
10485
- if (a) a.hidden = false;
10486
- }, ESCALATE_MS);
10857
+ }
10858
+ /** An update the person started is closing FloLess and opening the new version: say so while it does. */
10859
+ function markAppUpdateRelaunch(version) {
10860
+ if (appUpdateRelaunchTimer) clearTimeout(appUpdateRelaunchTimer);
10861
+ appUpdateRelaunch = { version: version || null, until: Date.now() + APP_UPDATE_RELAUNCH_MAX_MS };
10862
+ appUpdateRelaunchTimer = setTimeout(clearAppUpdateRelaunch, APP_UPDATE_RELAUNCH_MAX_MS);
10863
+ if (serverOnline === false) setServerStatus(false);
10864
+ }
10865
+ /**
10866
+ * The update is over: FloLess answered again after it (a new build reloads this page instead), the request failed,
10867
+ * or its last window passed. From then on an outage is an ordinary one, and the card says so at once.
10868
+ */
10869
+ function clearAppUpdateRelaunch() {
10870
+ if (appUpdateRelaunchTimer) { clearTimeout(appUpdateRelaunchTimer); appUpdateRelaunchTimer = null; }
10871
+ if (!appUpdateRelaunch) return;
10872
+ appUpdateRelaunch = null;
10873
+ if (serverOnline === false) setServerStatus(false);
10487
10874
  }
10488
10875
  function hideOfflineOverlay() {
10489
10876
  if (escalateTimer) { clearTimeout(escalateTimer); escalateTimer = null; }
@@ -10790,11 +11177,12 @@
10790
11177
  }
10791
11178
  } catch (err) {
10792
11179
  console.warn('node install did not start', err);
10793
- // #3097: the server's own reason when it gave one (api() marks it); otherwise the shared sentence. A start is a
10794
- // change, so an unexplained failure asks the person to check before starting it again.
10795
- statusText = err && err.serverText
10796
- ? `Couldn’t start the install. ${err.message}`
10797
- : failureCopy(err, { action: 'start the install', unsure: 'If Windows asks for permission in a moment, allow it; if nothing happens, choose Install again.' }).text;
11180
+ // #3097: the server's own reason when it gave one, read from its reply; otherwise the shared sentence. A start is
11181
+ // a change, so an unexplained failure asks the person to check before starting it again.
11182
+ const said = personText(err && err.body);
11183
+ statusText = said
11184
+ ? `Couldn’t start the install. ${said}`
11185
+ : errorText(err, { action: 'start the install', unsure: 'If Windows asks for permission in a moment, allow it; if nothing happens, choose Install again.' });
10798
11186
  } finally {
10799
11187
  nodeInstall.startInFlight = false;
10800
11188
  rerenderBootstrap();
@@ -11016,6 +11404,7 @@
11016
11404
  const style = document.createElement('style');
11017
11405
  style.textContent = `
11018
11406
  footer .status .stat-server .dot.offline{background:var(--err,#f87171);box-shadow:0 0 6px var(--err,#f87171);}
11407
+ footer .status .stat-server .dot.waiting{background:var(--warn,#fbbf24);box-shadow:0 0 6px var(--warn,#fbbf24);}
11019
11408
  #server-status-restart{appearance:none;border:1px solid var(--err,#f87171);background:transparent;color:var(--err,#f87171);
11020
11409
  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
11410
  /* display:inline-block on the ID above would beat the UA [hidden]{display:none}
@@ -11125,6 +11514,7 @@
11125
11514
  stat.classList.add('stat-server');
11126
11515
  const btn = document.createElement('a'); // real anchor — the href performs the launch
11127
11516
  btn.id = 'server-status-restart';
11517
+ btn.dataset.commandId = 'app.footer-restart';
11128
11518
  btn.href = 'floless://start';
11129
11519
  btn.textContent = '↻ Restart FloLess';
11130
11520
  btn.dataset.tip = 'Restart the local server';
@@ -11136,25 +11526,36 @@
11136
11526
  });
11137
11527
  stat.appendChild(btn);
11138
11528
  }
11529
+ /**
11530
+ * One observation of the server (`online`: it answered), turned into ONE state for the footer and the card. Called
11531
+ * again with the same reachability whenever what is known changes (the event stream dropped, an update started or
11532
+ * ended), so the card moves from 'busy' to 'reconnecting' while the server stays unreachable.
11533
+ */
11139
11534
  function setServerStatus(online) {
11140
11535
  if (window.__flolessStopped) return; // stopped on purpose — the "FloLess has stopped" screen owns the page
11141
- if (online === serverOnline) return;
11142
11536
  const wasOnline = serverOnline;
11143
11537
  serverOnline = online;
11538
+ if (appUpdateRelaunch && Date.now() >= appUpdateRelaunch.until) appUpdateRelaunch = null;
11539
+ const state = online ? 'online' : appUpdateRelaunch ? 'updating' : eventStreamOpen ? 'busy' : 'reconnecting';
11540
+ if (state === serverState) return;
11541
+ const was = serverState;
11542
+ serverState = state;
11144
11543
  const stat = document.querySelector('footer .status .stat-server') || document.querySelector('footer .status .stat');
11145
11544
  const dot = stat && stat.querySelector('.dot');
11146
11545
  const label = stat && stat.querySelector('.stat-val');
11147
11546
  const btn = document.getElementById('server-status-restart');
11148
- if (dot) dot.classList.toggle('offline', !online);
11149
- if (label) label.textContent = online ? 'runtime online' : 'server offline';
11150
- if (btn) btn.hidden = online;
11547
+ if (dot) { dot.classList.toggle('offline', state === 'reconnecting'); dot.classList.toggle('waiting', state === 'busy' || state === 'updating'); }
11548
+ if (label) label.textContent = online ? 'runtime online' : serverStateCopy(state).footer;
11549
+ if (btn) btn.hidden = state !== 'reconnecting'; // FloLess running (busy) or relaunching itself: nothing to start
11151
11550
  if (online) {
11551
+ // Answering again after an update the person started: the update is over (a new build reloads this page first).
11552
+ if (was === 'updating') clearAppUpdateRelaunch();
11152
11553
  hideOfflineOverlay(); // also clears the escalation timer + restores focus
11153
11554
  // Recovered from a boot-time / never-loaded outage: now that the server is
11154
11555
  // back, pull the workspace so the canvas fills in instead of staying empty.
11155
11556
  if (wasOnline === false && !currentId) loadWorkspaceData();
11156
11557
  } else {
11157
- showOfflineOverlay();
11558
+ showOfflineOverlay(state);
11158
11559
  }
11159
11560
  }
11160
11561
  let shownVersion = false;
@@ -11295,6 +11696,7 @@
11295
11696
  function connectionsChangeOf(m) {
11296
11697
  if (!m || typeof m !== 'object') return null;
11297
11698
  if (m.type === 'connect-result' && m.status === 'connected') return { reason: 'connected', id: typeof m.id === 'string' ? m.id : null };
11699
+ if (m.type === 'disconnect-result') return { reason: m.status === 'disconnected' ? 'disconnected' : 'disconnect-unconfirmed', id: typeof m.id === 'string' ? m.id : null };
11298
11700
  if (m.type === 'fs-change' && m.kind === 'credential') return { reason: 'credential', id: null };
11299
11701
  if (m.type === 'agent-install-result' && m.ok) return { reason: 'installed', id: typeof m.id === 'string' ? m.id : null };
11300
11702
  if (m.type === 'connections-changed') return { reason: 'tool-ready', id: typeof m.id === 'string' ? m.id : null };
@@ -11332,6 +11734,7 @@
11332
11734
  window.addEventListener('floless:workspace-root-state', drainPendingCatchup);
11333
11735
  es.onopen = () => {
11334
11736
  serverObservationEpoch++;
11737
+ eventStreamOpen = true; // the FloLess process is there: an unanswered health check now means busy, not gone
11335
11738
  const reconnect = everOpened || rootDisconnected;
11336
11739
  everOpened = true;
11337
11740
  rootDisconnected = false;
@@ -11392,25 +11795,7 @@
11392
11795
  // single-flight and idempotent, so the two racing is fine.
11393
11796
  if (window.awareUpdateController) window.awareUpdateController.adopt().catch(() => {});
11394
11797
  } else if (m.type === 'run-live' || m.type === 'node-progress' || m.type === 'run-finished') {
11395
- // #2228: live progress of a long run. This tab's own run is matched by its token; a run of the
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
- }
11798
+ onRunEvent(m);
11414
11799
  } else if (m.type === 'run-media' && Array.isArray(m.media)) {
11415
11800
  // #2230: the videos a run rendered, for a tab that lost the Run answer (a reload mid-run). The tab that
11416
11801
  // still holds the answer offers them from it; offerRunVideos is idempotent either way.
@@ -11441,6 +11826,9 @@
11441
11826
  // #2482: a PROJECT's contract changed (a checklist draft, a reference added from AI Chat). workspaces.js relays
11442
11827
  // it to that project's open editor frame, which has no event stream of its own.
11443
11828
  window.dispatchEvent(new CustomEvent('floless:contract-changed', { detail: m }));
11829
+ } else if (m.type === 'add-ons-changed') {
11830
+ // #3296 S1b: an add-on changed (from the chat, a card, another window). My add-ons re-reads while it is open.
11831
+ window.dispatchEvent(new CustomEvent('floless:add-ons-changed', { detail: { id: typeof m.id === 'string' ? m.id : null, rev: Number.isInteger(m.rev) ? m.rev : null } }));
11444
11832
  } else if (m.type === 'pages-changed') {
11445
11833
  // #2702: a Page was created, got a version, was shared, published, revoked or deleted — from the chat, a workflow
11446
11834
  // run or the viewer. Open Pages lists re-read (pages.js is the only listener); nothing is polled.
@@ -11593,19 +11981,12 @@
11593
11981
  }
11594
11982
  } else if (m.type === 'request-added' || m.type === 'requests-changed') {
11595
11983
  loadRequests();
11596
- if (window.flolessPanels) window.flolessPanels.refreshPending(); // composer's "queued" line
11597
- } else if (m.type === 'extensions-changed') {
11598
- // The terminal AI (or undo/reset) rewrote ~/.floless/ui/extensions.json —
11599
- // re-render the Dashboard / inspect-tab panels live. panels.js owns it.
11600
- if (window.flolessPanels) window.flolessPanels.refresh({ fromChange: true });
11601
11984
  } else if (m.type === 'knowledge-changed') {
11602
11985
  // #2399 slice 0b: a chat, a terminal or another window changed a project's references or design set.
11603
11986
  window.flolessWorkspaces?.knowledgeChanged?.(m.projectId);
11604
11987
  } else if (m.type === 'revision-note-changed') {
11605
11988
  window.dispatchEvent(new CustomEvent('floless:revision-note-changed', { detail: m }));
11606
11989
  } else if (m.type === 'run-ended') {
11607
- // Panel data bindings (last-run-output/-status) go stale after any run.
11608
- if (window.flolessPanels) window.flolessPanels.refreshData();
11609
11990
  // #2470 R6.2: a project's Workflows step shows each workflow's last run; it re-reads only while on screen.
11610
11991
  window.flolessProjectWorkflows?.refresh?.();
11611
11992
  window.flolessRunHistory?.refresh?.(); // Workflows → History re-reads only while on screen
@@ -11629,7 +12010,6 @@
11629
12010
  window.flolessProjectWorkflows?.refresh?.(); // #2470 R6.2, as run-ended
11630
12011
  window.flolessRunHistory?.refresh?.();
11631
12012
  loadRoutinesData();
11632
- if (window.flolessPanels) window.flolessPanels.refreshData(); // routine runs also refresh bindings
11633
12013
  window.flolessAgents?.refreshRuns?.(); // #2035: an open agent page shows the run its routine just started
11634
12014
  if (currentId) void globalThis.flolessAgentSteps?.refreshRunRecord(currentId); // #2241 S5: a scheduled run may have left questions
11635
12015
  } else if (m.type === 'trigger-session-changed') {
@@ -11667,6 +12047,9 @@
11667
12047
  } else if (slot) {
11668
12048
  slot.innerHTML = connectResultSlotHtml(m);
11669
12049
  }
12050
+ } else if (m.type === 'disconnect-result') {
12051
+ // #3301: a service was disconnected (here, in another window or from AI Chat): every open Integrations flips.
12052
+ refreshIntegrations();
11670
12053
  } else if (m.type === 'fs-change' && m.kind === 'credential') {
11671
12054
  // `aware connect`/`disconnect` wrote/removed a token in the local vault —
11672
12055
  // refresh the Integrations window so its status reflects reality live.
@@ -11699,6 +12082,7 @@
11699
12082
  };
11700
12083
  es.onerror = () => {
11701
12084
  serverObservationEpoch++;
12085
+ eventStreamOpen = false; // the connection to FloLess closed: an outage, not a busy server
11702
12086
  // A later health poll must not borrow a pre-disconnect shared startup probe.
11703
12087
  globalThis.flolessStartupAdmission?.invalidate();
11704
12088
  connectionGeneration++;
@@ -12046,7 +12430,7 @@
12046
12430
  //
12047
12431
  // WHICH SURFACES MUST USE THIS: every one whose failure message BLAMES a cause — the row ⧉, the
12048
12432
  // request-help modal, the revision card. The queue-then-best-effort-copy callers (useTemplate,
12049
- // tweakNode, requestNewWorkflow, panels.js's customize box) say only "queued, not
12433
+ // tweakNode, requestNewWorkflow) say only "queued, not
12050
12434
  // copied" and name no cause, so they cannot conflate anything and are deliberately left alone. Add
12051
12435
  // a new surface that names a cause and it belongs here.
12052
12436
  async function copyRequest(req, stillOwned = () => true) {
@@ -12480,20 +12864,21 @@
12480
12864
  // Refused for another reason once the project was free: say why, exactly as the other start surfaces do.
12481
12865
  const notReady = error?.code === 'chat-runtime-not-ready';
12482
12866
  const explained = notReady ? '' : chatStartErrorText(error);
12483
- if (notReady) showToast(error.message, 'warn');
12867
+ if (notReady) showToast(errorText(error), 'warn');
12484
12868
  else reportChatStartErr(error);
12485
- say(notReady ? error.message : explained || `Couldn’t start ${requestLabel(request)} in AI Chat. Try again.`);
12869
+ say(notReady ? errorText(error) : explained || `Couldn’t start ${requestLabel(request)} in AI Chat. Try again.`);
12486
12870
  }
12487
12871
  };
12488
12872
  requestStartWaits.set(request.id, setTimeout(tick, REQUEST_START_WAIT_MS));
12489
12873
  }
12490
12874
 
12491
12875
  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.');
12876
+ if (typeof window.flolessChat?.startRequest !== 'function') throw Object.assign(new Error('AI Chat is still starting. Try again in a moment.'), { forPerson: true });
12493
12877
  if (mode === 'start') {
12494
12878
  const ready = await ensureChatRuntimeReady(provider, { onProgress: (status) => onSetup?.(status), isCancelled });
12495
12879
  if (ready.cancelled || isCancelled()) throw Object.assign(new Error('The start was cancelled.'), { code: 'chat-start-cancelled' });
12496
- if (!ready.ok) throw Object.assign(new Error(ready.reason), { code: 'chat-runtime-not-ready' });
12880
+ // ready.reason is this file's own sentence (ensureChatRuntimeReady), so it is said as written.
12881
+ if (!ready.ok) throw Object.assign(new Error(ready.reason), { code: 'chat-runtime-not-ready', forPerson: true });
12497
12882
  }
12498
12883
  return window.flolessChat.startRequest(requestId, provider, mode, { ownChat, restoreFirst });
12499
12884
  }
@@ -12773,7 +13158,7 @@
12773
13158
  if (holder.kind === 'knowledge') {
12774
13159
  // #2106: the project's Knowledge step, where its organizing shows.
12775
13160
  try { await openKnowledgeStepOf(holder.projectId); }
12776
- catch (error) { showToast(error?.message || 'FloLess couldn’t open that project’s Knowledge step. Open it from Workspaces.', 'warn'); }
13161
+ catch (error) { showToast(errorText(error, { action: 'open that project’s Knowledge step', unsure: 'Open it from Workspaces.' }), 'warn'); }
12777
13162
  return;
12778
13163
  }
12779
13164
  if (holder.kind === 'chat' && holder.chatId && holder.owner && typeof window.flolessChat?.openConversationIn === 'function') {
@@ -13494,10 +13879,10 @@
13494
13879
  // The same refusal handling as the queued rows' start surface (request-chat-start-eligibility.test.ts).
13495
13880
  const notReady = error?.code === 'chat-runtime-not-ready';
13496
13881
  const explained = notReady ? '' : chatStartErrorText(error);
13497
- if (notReady) showToast(error.message, 'warn');
13882
+ if (notReady) showToast(errorText(error), 'warn');
13498
13883
  else reportChatStartErr(error);
13499
13884
  if (actionStatus) actionStatus.textContent = notReady
13500
- ? error.message
13885
+ ? errorText(error)
13501
13886
  : explained || `Couldn’t open ${requestLabel(request)} in AI Chat. Try again.`;
13502
13887
  if (!button.isConnected) return;
13503
13888
  button.disabled = false;
@@ -13659,7 +14044,7 @@
13659
14044
  * Does this queued request belong to what the user has open? (Pure — unit-tested.)
13660
14045
  *
13661
14046
  * Three cases, and the middle one is the whole point of the filter:
13662
- * - A request with NEITHER appId nor project (dashboard customization or a standalone new
14047
+ * - A request with NEITHER appId nor project (a standalone new
13663
14048
  * workflow) belongs to no open project/app scope, so it is always shown. A project-owned new
13664
14049
  * workflow carries `project` and follows the project rule below.
13665
14050
  * - A PROJECT scope matches on project id only. A Workspaces tweak-contract carries both a
@@ -13696,7 +14081,7 @@
13696
14081
  *
13697
14082
  * A project-keyed request must NEVER fall through to appId: every steel-model project carries
13698
14083
  * `appId: "steel-model"`, so the old head line printed the same word against three unrelated
13699
- * projects' work. Requests that belong to neither (ui-customize, new-workflow) get a plain-English
14084
+ * projects' work. A request that belongs to neither (new-workflow) gets a plain-English
13700
14085
  * stand-in rather than a blank — the row still has to say what it is about.
13701
14086
  */
13702
14087
  function requestOwnerName(r) {
@@ -13705,7 +14090,7 @@
13705
14090
  if (r.type === 'new-workflow' && r.buildId && r.workflowName) return r.workflowName;
13706
14091
  if (r.project) return r.projectName || r.project;
13707
14092
  if (r.appId) return r.appId;
13708
- return r.type === 'ui-customize' ? 'your dashboard' : r.type === 'new-workflow' ? (r.workflowName || 'a new workflow') : '';
14093
+ return r.type === 'new-workflow' ? (r.workflowName || 'a new workflow') : '';
13709
14094
  }
13710
14095
 
13711
14096
  function requestMatchesChatScope(request) {
@@ -13759,7 +14144,7 @@
13759
14144
  // One path for a question and a change, so a waiting message is never labelled a suggestion.
13760
14145
  return r.instructorContext.commandId === 'filter.ask-ai-change' ? 'filter answer' : 'filter question';
13761
14146
  if (r.type === 'revision-read') return (!r.baseVersion || r.baseVersion <= 0) ? 'initial drawing read' : 'updated drawing read';
13762
- return r.type === 'use-template' ? 'template' : r.type === 'ui-customize' ? 'dashboard' : r.type === 'rebake' ? 're-bake' : r.type === 'guide' ? 'guide' : r.type === 'new-workflow' ? 'new workflow' : r.type === 'knowledge-organize' ? 'organize' : r.type === 'knowledge-adjust' ? 'adjust' : r.type === 'knowledge-consult' ? 'knowledge' : r.type === 'project-kickoff' ? 'kickoff' : r.type === 'tweak-contract' ? 'contract' : 'tweak';
14147
+ return r.type === 'use-template' ? 'template' : r.type === 'rebake' ? 're-bake' : r.type === 'guide' ? 'guide' : r.type === 'new-workflow' ? 'new workflow' : r.type === 'knowledge-organize' ? 'organize' : r.type === 'knowledge-adjust' ? 'adjust' : r.type === 'knowledge-consult' ? 'knowledge' : r.type === 'project-kickoff' ? 'kickoff' : r.type === 'tweak-contract' ? 'contract' : 'tweak';
13763
14148
  }
13764
14149
 
13765
14150
  function isInitialDrawingRead(r) {
@@ -14156,7 +14541,7 @@
14156
14541
  : 'Its discard record could be read again, so there was nothing to decide.';
14157
14542
  discardRecordUi.delete(id);
14158
14543
  } catch (error) {
14159
- discardRecordUi.set(id, { status: error?.message || 'That didn’t work. Try again.' });
14544
+ discardRecordUi.set(id, { status: errorText(error, { action: 'record your choice', unsure: 'Check the request below before choosing again.' }) });
14160
14545
  await loadRequests().catch(() => {});
14161
14546
  renderRequests();
14162
14547
  focusDiscardRecordControl(id, choice === 'keep' ? 'keep' : 'ask');
@@ -14684,11 +15069,11 @@
14684
15069
  // Refused after Restore: say why in the list as well, exactly as the other start surfaces do.
14685
15070
  const notReady = error?.code === 'chat-runtime-not-ready';
14686
15071
  const explained = notReady ? '' : chatStartErrorText(error);
14687
- if (notReady) showToast(error.message, 'warn');
15072
+ if (notReady) showToast(errorText(error), 'warn');
14688
15073
  else reportChatStartErr(error);
14689
15074
  await loadRequests().catch(() => {}); renderRequests();
14690
15075
  const actionStatus = document.getElementById('requests-action-status');
14691
- if (actionStatus) actionStatus.textContent = notReady ? error.message : explained || `Couldn’t start ${requestLabel(request)} in AI Chat. Try again.`;
15076
+ if (actionStatus) actionStatus.textContent = notReady ? errorText(error) : explained || `Couldn’t start ${requestLabel(request)} in AI Chat. Try again.`;
14692
15077
  }
14693
15078
  }
14694
15079
 
@@ -14843,7 +15228,7 @@
14843
15228
  const anyRunnable = headlessReady() && shown.some((r) => r && r.canRun);
14844
15229
  const queuedHtml = shown.map((r, shownIndex) => {
14845
15230
  const label = requestLabel(r);
14846
- const badgeCls = r.type === 'tweak' || r.type === 'ui-customize' || r.type === 'rebake' || r.type === 'revision-read' || r.type === 'knowledge-organize' || r.type === 'knowledge-adjust' || r.type === 'tweak-contract' ? 'req-type req-type-tweak' : 'req-type';
15231
+ const badgeCls = r.type === 'tweak' || r.type === 'rebake' || r.type === 'revision-read' || r.type === 'knowledge-organize' || r.type === 'knowledge-adjust' || r.type === 'tweak-contract' ? 'req-type req-type-tweak' : 'req-type';
14847
15232
  // One name, and only the name. The node/input/sheet chips that used to sit here ("· node
14848
15233
  // render") are already spelled out in the instruction body right below, so they cost a line
14849
15234
  // of chrome to repeat what the sentence underneath says in English.
@@ -14947,7 +15332,7 @@
14947
15332
  ? `<button class="req-chat-action primary" data-request-chat="start" data-id="${escapeAttr(r.id)}" data-command-id="shell.requests-start-chat#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(commandInstance)}" aria-label="Work on ${escapeAttr(chatLabel)} in AI Chat" data-tip="The AI starts on this now, in this request’s own conversation in AI Chat"${starting ? ' disabled aria-busy="true"' : ''}>${escapeHtml(starting || 'Work on it')}</button>`
14948
15333
  : '';
14949
15334
  const chatMeta = discardQuestion ? '' : chatProvider && inChatScope
14950
- ? `<span class="req-chat-meta">AI Chat · ${escapeHtml(runtimeLabel(chatProvider))} · ${r.type === 'guide' || (r.type === 'tweak-contract' && r.mode === 'query') ? 'Read only' : 'Auto'}</span>`
15335
+ ? `<span class="req-chat-meta">AI Chat · ${escapeHtml(runtimeLabel(chatProvider))} · ${r.type === 'guide' ? 'Read only' : 'Auto'}</span>`
14951
15336
  : chatProvider && hasChatOwner
14952
15337
  ? `<span class="req-chat-elsewhere" data-tip="${escapeAttr(requestChatScopeReason(r))}">${escapeHtml(requestChatScopeReason(r))}</span>`
14953
15338
  : '';
@@ -15054,10 +15439,10 @@
15054
15439
  }
15055
15440
  const notReady = error?.code === 'chat-runtime-not-ready';
15056
15441
  const explained = notReady ? '' : chatStartErrorText(error);
15057
- if (notReady) showToast(error.message, 'warn');
15442
+ if (notReady) showToast(errorText(error), 'warn');
15058
15443
  else reportChatStartErr(error);
15059
15444
  if (actionStatus) actionStatus.textContent = notReady
15060
- ? error.message
15445
+ ? errorText(error)
15061
15446
  : explained || `Couldn’t ${starting ? 'start' : 'open'} ${requestLabel(request)} in AI Chat. Try again.`;
15062
15447
  if (notReady || !button.isConnected) {
15063
15448
  endStart();
@@ -15609,10 +15994,10 @@
15609
15994
  btn.onclick = () => saveAgentCommandTemplate(btn.dataset.agent, btn.dataset.cmd);
15610
15995
  });
15611
15996
  } catch (e) {
15612
- // #3097: the server's reason when it gave one (api() marks it), else the shared sentence for this read; never
15997
+ // #3097: the server's reason when it gave one, read from its reply, else the shared sentence for this read; never
15613
15998
  // "error: " plus the browser's exception text. The error itself goes to the console.
15614
15999
  console.warn('agent commands unavailable', id, e);
15615
- const said = e && e.serverText ? e.message : failureCopy(e, { action: 'load this agent’s commands', retrySafe: true }).text;
16000
+ const said = errorText(e, { action: 'load this agent’s commands', retrySafe: true });
15616
16001
  box.innerHTML = `<div class="cmd-desc">${escapeHtml(said)}</div>`;
15617
16002
  }
15618
16003
  }
@@ -15676,6 +16061,8 @@
15676
16061
  // "Available" means available-to-install, so already-installed agents live only
15677
16062
  // in the Installed tab. agentCatalog holds the installed set (id per item).
15678
16063
  function installedIdSet() { return new Set(agentCatalog.map((a) => a.id)); }
16064
+ // A `planned` tool has no runnable program yet (aware-aeco/aware#767): installing it could never make it usable.
16065
+ function offeredForInstall(a, installed) { return !installed.has(a.id) && a.status !== 'planned'; }
15679
16066
 
15680
16067
  function availCardHtml(a) {
15681
16068
  const name = escapeHtml(a.display_name || a.id);
@@ -15738,7 +16125,7 @@
15738
16125
  }
15739
16126
 
15740
16127
  const installed = installedIdSet();
15741
- const notInstalled = availableCatalog.filter((a) => !installed.has(a.id));
16128
+ const notInstalled = availableCatalog.filter((a) => offeredForInstall(a, installed));
15742
16129
  const q = ($libAvailSearch.value || '').toLowerCase().trim();
15743
16130
  const match = (a) => !q
15744
16131
  || a.id.toLowerCase().includes(q)
@@ -15800,7 +16187,7 @@
15800
16187
  showToast(`Installing “${nice}” — this can take a minute or two`, 'info');
15801
16188
  api('/api/agents/install', { method: 'POST', body: JSON.stringify({ id, ...(appId ? { appId, sourceHash } : {}) }) })
15802
16189
  .catch((e) => { // the START failed (bad id / server) — completion errors arrive via SSE
15803
- recordAgentInstallResult({ id, appId, sourceHash, ok: false, error: e.message || 'Please try again.' });
16190
+ recordAgentInstallResult({ id, appId, sourceHash, ok: false, error: errorText(e, { action: `start installing “${nice}”` }) });
15804
16191
  refreshAgentNotes();
15805
16192
  if ($libModal && $libModal.classList.contains('show')) renderAvailable();
15806
16193
  reportErr(e, 'install this tool');
@@ -16267,6 +16654,32 @@
16267
16654
  return granted.drive ? 'Allowed: Gmail sending and Drive file list.' : 'Allowed: Gmail sending. Not allowed: Drive file list (optional).';
16268
16655
  }
16269
16656
 
16657
+ /**
16658
+ * #3295: Microsoft adds every permission approved for FloLess Desktop earlier, so a sign-in can allow more than FloLess
16659
+ * asks for. Information plus a way out, never a gate: the account stays usable and its state is unchanged. The server
16660
+ * lists the extra permissions in words, the ones that write first.
16661
+ */
16662
+ function microsoftGrantNotice(slot, noticeId) {
16663
+ const grant = slot.microsoftGrant;
16664
+ if (!grant || grant.state !== 'wider' || !Array.isArray(grant.extra) || !grant.extra.length) return '';
16665
+ const shown = grant.extra.slice(0, 4).map((permission) => escapeHtml(permission.meaning));
16666
+ const more = grant.extra.length - shown.length;
16667
+ if (more > 0) shown.push(`and ${more} more`);
16668
+ const what = shown.length <= 2
16669
+ ? `: it ${shown.join(' and ')}.`
16670
+ : `. It:<ul class="int-grant-list">${shown.map((line) => `<li>${line}</li>`).join('')}</ul>`;
16671
+ const reconnect = slot.alias ? 'click Reconnect this account' : 'click Reconnect on this card';
16672
+ return `<div class="int-notice is-warn int-grant-notice" role="note" id="${escapeAttr(noticeId)}">`
16673
+ + '<strong class="int-grant-title">This sign-in allows more than FloLess asked for</strong>'
16674
+ // AWARE does not record which app issued a sign-in, so the approval is "the app this sign-in uses"; revoking FloLess
16675
+ // Desktop and reconnecting (which signs in with it) is the way out either way.
16676
+ + `<span class="int-grant-body">Microsoft kept permissions from an earlier approval of the app this sign-in uses${what} `
16677
+ + '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 '
16678
+ + '<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>, '
16679
+ + `open FloLess Desktop and remove its access, then ${reconnect}. If your organisation approved it, ask your IT admin to remove it. `
16680
+ + 'You can keep using this account meanwhile.</span></div>';
16681
+ }
16682
+
16270
16683
  function renderIntegrationAccounts(integration) {
16271
16684
  const slots = Array.isArray(integration.accountSlots) ? integration.accountSlots : [];
16272
16685
  if (!slots.length) return integration.chatSupported
@@ -16317,11 +16730,15 @@
16317
16730
  ? `<span class="int-account-access${slot.granted.gmail ? '' : ' is-warn'}">${escapeHtml(googleAccessLine(slot.granted, slot.alias))}</span>` : '';
16318
16731
  // #2649: a named account reconnects on its own whenever it needs a new sign-in or new consent; the card's main
16319
16732
  // button is the default account's. Its Drive choice is the card's checkbox, the person's current selection.
16733
+ const grantNoticeId = `int-grant-${integration.id}-${slot.alias || 'default'}`.replace(/[^A-Za-z0-9_-]/g, '-');
16734
+ const grantNotice = integration.id === 'microsoft-365' ? microsoftGrantNotice(slot, grantNoticeId) : '';
16320
16735
  const needsSignIn = slot.status !== 'valid' || (slot.granted && !slot.granted.gmail)
16321
16736
  || ['scope-missing', 'identity-unverified', 'credential-expired', 'generation-unavailable'].includes(slot.unavailableCode);
16322
- const reconnect = slot.alias && needsSignIn
16737
+ // A wider Microsoft grant also offers a named account its own Reconnect: the way out after removing the approval.
16738
+ const reconnect = slot.alias && (needsSignIn || grantNotice)
16323
16739
  ? `<button class="int-action int-account-reconnect" type="button" data-int="${escapeAttr(integration.id)}" data-int-action="connect"`
16324
16740
  + ` data-int-alias="${escapeAttr(slot.alias)}"`
16741
+ + (grantNotice ? ` aria-describedby="${escapeAttr(grantNoticeId)}"` : '')
16325
16742
  + ` data-command-id="shell.integrations-account-reconnect#${escapeAttr(`${integration.id}:${slot.alias}`)}"`
16326
16743
  + ` data-command-instance-label="${escapeAttr(`${integration.name} account ${slot.alias}`)}"`
16327
16744
  + ` aria-label="Reconnect ${escapeAttr(integration.name)} account ${escapeAttr(slot.alias)}">Reconnect this account</button>`
@@ -16333,6 +16750,7 @@
16333
16750
  </div>
16334
16751
  <span class="int-chat-state">${state}</span>
16335
16752
  ${access}
16753
+ ${grantNotice}
16336
16754
  <span class="int-account-reason">${escapeHtml(why)}</span>
16337
16755
  ${reconnect}
16338
16756
  </div>`;
@@ -16430,6 +16848,186 @@
16430
16848
  + ` data-command-id="shell.integrations-connect#${escapeAttr(i.id)}" data-command-instance-label="${escapeAttr(i.name)}">Reconnect</button>`;
16431
16849
  }
16432
16850
 
16851
+ /**
16852
+ * #3301: the account a card's Disconnect removes — the one its Connected badge stands for (the first signed-in
16853
+ * account, as the server picks it), and how the confirm names it: the verified account, else its FloLess name.
16854
+ */
16855
+ function disconnectTarget(i) {
16856
+ const slots = Array.isArray(i.accountSlots) ? i.accountSlots : [];
16857
+ const slot = slots.find((s) => s.status === 'valid') || slots[0] || null;
16858
+ const alias = slot && typeof slot.alias === 'string' && slot.alias ? slot.alias : null;
16859
+ const label = slot?.verifiedPrincipal?.presentationLabel || alias || null;
16860
+ return { alias, label };
16861
+ }
16862
+
16863
+ /** The Disconnect button's carriers: the account it removes and its Instructor registration. */
16864
+ function disconnectButtonAttrs(i) {
16865
+ const { alias } = disconnectTarget(i);
16866
+ return ` data-command-id="shell.integrations-disconnect#${escapeAttr(i.id)}" data-command-instance-label="${escapeAttr(i.name)}"`
16867
+ + (alias ? ` data-int-alias="${escapeAttr(alias)}"` : '');
16868
+ }
16869
+
16870
+ /**
16871
+ * #3301: the Disconnect confirm's words. Names the service and the account, says what stops working and that
16872
+ * connecting again undoes it. An AWARE older than 0.175.0 keeps Google's sign-in for the whole computer
16873
+ * (aware-aeco/aware#782): the server says when that is so (`signOutWholeComputer`, #3334), and only then does it warn.
16874
+ */
16875
+ function disconnectConfirmCopy(i) {
16876
+ const { alias, label } = disconnectTarget(i);
16877
+ const title = `Disconnect ${i.name}${alias ? ` (${alias})` : ''}?`;
16878
+ const who = label || 'the default account';
16879
+ const sub = `This removes the saved sign-in for ${who} from this computer. Knowledge sources from ${i.name} stop syncing, `
16880
+ + '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.';
16881
+ // Other signed-in accounts of the same service keep working; say which, so "disconnect" is not read as the whole service.
16882
+ const slots = Array.isArray(i.accountSlots) ? i.accountSlots : [];
16883
+ const others = slots.filter((s) => s.status === 'valid' && (s.alias || null) !== alias)
16884
+ .map((s) => s.verifiedPrincipal?.presentationLabel || s.alias || 'the default account');
16885
+ const stays = others.length ? ` ${others.join(', ')} stay${others.length === 1 ? 's' : ''} connected.` : '';
16886
+ return { title, sub: sub + stays, alias, google: i.signOutWholeComputer === true };
16887
+ }
16888
+
16889
+ /**
16890
+ * #3301: what a finished Disconnect says, from the route's answer and the card as AWARE now reports it. Nothing was
16891
+ * stored, or the follow-up check could not run: the server's own sentence. Another account still signed in: the card
16892
+ * stays Connected, so it says so and keeps focus on its Disconnect. Otherwise the service is disconnected and Connect
16893
+ * is next.
16894
+ */
16895
+ function disconnectOutcome(i, result, refreshed) {
16896
+ if (result && typeof result.note === 'string' && result.note) {
16897
+ return { text: result.note, tone: 'info', focus: refreshed?.status === 'connected' ? 'disconnect' : 'connect' };
16898
+ }
16899
+ if (refreshed?.status === 'connected') {
16900
+ const { alias, label } = disconnectTarget(i);
16901
+ const who = label || alias || 'the default account';
16902
+ return { text: `Disconnected ${who} from ${i.name}. Another ${i.name} account is still connected.`, tone: 'ok', focus: 'disconnect' };
16903
+ }
16904
+ return { text: `${i.name} disconnected. Click Connect to sign in again.`, tone: 'ok', focus: 'connect' };
16905
+ }
16906
+
16907
+ /**
16908
+ * #3301: ask, then disconnect in the app. Opens above Integrations (which is inerted while it is up); Cancel holds
16909
+ * focus and Esc or the backdrop cancel, except while the request is out, so its outcome is never lost. A failure stays
16910
+ * here in words, with Try again and the terminal command as a last resort. On success the card is redrawn from AWARE,
16911
+ * the change is announced, and focus moves to the redrawn card's Connect.
16912
+ */
16913
+ let intDisconnectOpen = false;
16914
+ function confirmIntegrationDisconnect(i) {
16915
+ if (intDisconnectOpen) return;
16916
+ const $modal = document.getElementById('int-disconnect-modal');
16917
+ const $box = $modal.querySelector('.modal');
16918
+ const $title = document.getElementById('int-disconnect-title');
16919
+ const $sub = document.getElementById('int-disconnect-sub');
16920
+ const $google = document.getElementById('int-disconnect-google');
16921
+ const $error = document.getElementById('int-disconnect-error');
16922
+ const $ok = document.getElementById('int-disconnect-ok');
16923
+ const $cancel = document.getElementById('int-disconnect-cancel');
16924
+ const $copy = document.getElementById('int-disconnect-copy');
16925
+ const copy = disconnectConfirmCopy(i);
16926
+ $title.textContent = copy.title;
16927
+ $sub.textContent = copy.sub;
16928
+ $google.hidden = !copy.google;
16929
+ // A hidden notice still reaches a screen reader through aria-describedby, so it is named only when it is shown (#3334).
16930
+ $modal.setAttribute('aria-describedby', copy.google ? 'int-disconnect-sub int-disconnect-google' : 'int-disconnect-sub');
16931
+ $error.textContent = '';
16932
+ $copy.hidden = true;
16933
+ $copy.textContent = 'Copy command';
16934
+ $ok.textContent = 'Disconnect';
16935
+ $ok.disabled = $cancel.disabled = false;
16936
+ $box.removeAttribute('aria-busy');
16937
+ $ok.setAttribute('data-command-instance-label', i.name);
16938
+ $cancel.setAttribute('data-command-instance-label', `disconnecting ${i.name}`);
16939
+ const returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
16940
+ const covered = Array.from(document.querySelectorAll('.modal-backdrop.show')).filter((m) => m !== $modal)
16941
+ .map((modal) => ({ modal, inert: !!modal.inert, ariaHidden: modal.getAttribute('aria-hidden') }));
16942
+ covered.forEach(({ modal }) => { modal.inert = true; modal.setAttribute('aria-hidden', 'true'); });
16943
+ intDisconnectOpen = true;
16944
+ showModal($modal);
16945
+ setTimeout(() => $cancel.focus(), 0);
16946
+ let working = false;
16947
+ let closed = false;
16948
+ let command = '';
16949
+ // Once per opening: a late continuation of this dialog must never close or unhook a newer one.
16950
+ const close = (focusTarget) => {
16951
+ if (closed) return;
16952
+ closed = true;
16953
+ intDisconnectOpen = false;
16954
+ hideModal($modal);
16955
+ covered.forEach(({ modal, inert, ariaHidden }) => {
16956
+ modal.inert = inert;
16957
+ if (ariaHidden === null) modal.removeAttribute('aria-hidden');
16958
+ else modal.setAttribute('aria-hidden', ariaHidden);
16959
+ });
16960
+ document.removeEventListener('keydown', onKey, true);
16961
+ $ok.onclick = $cancel.onclick = $copy.onclick = null;
16962
+ $modal.onclick = $modal.onmousedown = null;
16963
+ // A closed dialog keeps no busy state behind (the accessibility tree still reads hidden controls' names).
16964
+ $ok.textContent = 'Disconnect';
16965
+ $ok.disabled = $cancel.disabled = false;
16966
+ $box.removeAttribute('aria-busy');
16967
+ const target = typeof focusTarget === 'function' ? focusTarget() : focusTarget;
16968
+ if (target && target.isConnected) target.focus();
16969
+ else if (returnFocus && returnFocus.isConnected) returnFocus.focus();
16970
+ else document.getElementById('integrations-close')?.focus();
16971
+ };
16972
+ const onKey = (e) => {
16973
+ if (document.getElementById('server-offline-overlay')) return;
16974
+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); if (!working) close(); }
16975
+ else if (e.key === 'Tab') {
16976
+ // Above Integrations: own Tab so the lower dialog's trap cannot pull focus behind this one.
16977
+ e.stopPropagation();
16978
+ const focusable = Array.from($modal.querySelectorAll('button:not([disabled]):not([hidden])')).filter((el) => el.getClientRects().length);
16979
+ if (!focusable.length) { e.preventDefault(); return; }
16980
+ const first = focusable[0]; const last = focusable[focusable.length - 1];
16981
+ if (e.shiftKey && (document.activeElement === first || !$modal.contains(document.activeElement))) { e.preventDefault(); last.focus(); }
16982
+ else if (!e.shiftKey && (document.activeElement === last || !$modal.contains(document.activeElement))) { e.preventDefault(); first.focus(); }
16983
+ }
16984
+ };
16985
+ $cancel.onclick = () => { if (!working) close(); };
16986
+ $copy.onclick = async () => {
16987
+ const copied = await copyToClipboard(command);
16988
+ $copy.textContent = copied ? 'Copied' : 'Copy command';
16989
+ if (!copied) showToast(`Run in your terminal: ${command}`, 'info');
16990
+ setTimeout(() => { $copy.textContent = 'Copy command'; }, 1600);
16991
+ };
16992
+ $ok.onclick = async () => {
16993
+ working = true;
16994
+ $error.textContent = '';
16995
+ $box.setAttribute('aria-busy', 'true');
16996
+ $box.focus();
16997
+ $ok.textContent = 'Disconnecting…';
16998
+ $ok.disabled = $cancel.disabled = true;
16999
+ let result;
17000
+ try {
17001
+ result = await api(`/api/integrations/${encodeURIComponent(i.id)}/disconnect`, {
17002
+ method: 'POST', body: JSON.stringify(copy.alias ? { alias: copy.alias } : {}),
17003
+ });
17004
+ } catch (error) {
17005
+ working = false;
17006
+ $box.removeAttribute('aria-busy');
17007
+ command = typeof error?.body?.command === 'string' ? error.body.command : '';
17008
+ $error.textContent = errorText(error, { action: `disconnect ${i.name}` });
17009
+ $copy.hidden = !command;
17010
+ $ok.textContent = 'Try again';
17011
+ $ok.disabled = $cancel.disabled = false;
17012
+ $ok.focus();
17013
+ // The card underneath shows what AWARE holds now (a failure can land after the sign-in was removed).
17014
+ void refreshIntegrations();
17015
+ return;
17016
+ }
17017
+ const id = (window.CSS && CSS.escape) ? CSS.escape(i.id) : i.id;
17018
+ // Still working while the card is redrawn, so Esc or the backdrop cannot close the dialog mid-way.
17019
+ await refreshIntegrations();
17020
+ working = false;
17021
+ // Worded from the server's answer and the redrawn card, never assumed: another account may still be connected.
17022
+ const outcome = disconnectOutcome(i, result, integrations.find((row) => row.id === i.id));
17023
+ document.getElementById('integrations-status').textContent = outcome.text;
17024
+ close(() => $integrationsList.querySelector(`[data-integration-id="${id}"] .int-action[data-int-action="${outcome.focus}"]`));
17025
+ showToast(outcome.text, outcome.tone);
17026
+ };
17027
+ onBackdropDismiss($modal, () => close(), () => !working);
17028
+ document.addEventListener('keydown', onKey, true);
17029
+ }
17030
+
16433
17031
  /** One OAuth integration's card (#2649: a named function, so its rendered carriers and controls are tested). */
16434
17032
  function integrationCardHtml(i) {
16435
17033
  const action = i.status === 'connected' ? 'Disconnect' : i.status === 'expired' ? 'Reconnect' : 'Connect';
@@ -16442,10 +17040,18 @@
16442
17040
  const reconnect = google ? google.reconnect
16443
17041
  : i.id === MICROSOFT_INTEGRATION_ID && i.status === 'connected' ? reconnectButtonHtml(i) : '';
16444
17042
  // #2466: what a Microsoft sign-in asks for, said before the person clicks (FLOLESS_M365_SCOPES, server/oauth-presets.ts).
17043
+ // #3295: while a sign-in allows more than that, or FloLess cannot tell what it allows, the card never says it only reads.
17044
+ const grants = i.id === MICROSOFT_INTEGRATION_ID && Array.isArray(i.accountSlots) ? i.accountSlots.map((slot) => slot.microsoftGrant?.state) : [];
17045
+ const wider = grants.filter((state) => state === 'wider').length;
16445
17046
  const microsoftHelp = i.id === MICROSOFT_INTEGRATION_ID
16446
17047
  ? '<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. It only reads. Excel’s permission also allows changes '
16448
- + '(Microsoft has no read-only one), but FloLess never edits a file.</div>'
17048
+ + 'Excel workbooks, Outlook mail, Planner and Teams chats. '
17049
+ + (wider
17050
+ ? `FloLess itself only reads, but Microsoft gave ${wider > 1 ? 'some of your sign-ins' : 'one of your sign-ins'} more. See the note below. `
17051
+ : grants.includes('unknown')
17052
+ ? 'FloLess itself only reads, but Microsoft didn’t say what your sign-in allows, so FloLess can’t check it. '
17053
+ : 'It only reads. ')
17054
+ + 'Excel’s permission also allows changes (Microsoft has no read-only one), but FloLess never edits a file.</div>'
16449
17055
  : '';
16450
17056
  return `
16451
17057
  <div class="int-item int-${i.status}" data-integration-id="${escapeAttr(i.id)}" tabindex="-1">
@@ -16463,7 +17069,7 @@
16463
17069
  <span class="int-badge int-badge-${i.status}">${badge}</span>
16464
17070
  <span class="int-recovery-actions">
16465
17071
  ${reconnect}
16466
- <button class="int-action" data-int="${escapeAttr(i.id)}" data-int-action="${action.toLowerCase()}"${action === 'Disconnect' ? '' : ` data-command-id="shell.integrations-connect#${escapeAttr(i.id)}" data-command-instance-label="${escapeAttr(i.name)}"`}>${action}</button>
17072
+ <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
17073
  </span>
16468
17074
  </div>
16469
17075
  ${i.status === 'connected' || (google && !google.deviceCodeAvailable) ? '' : `
@@ -16575,13 +17181,12 @@
16575
17181
  });
16576
17182
  $integrationsList.querySelectorAll('.int-action[data-int]').forEach((btn) => {
16577
17183
  btn.onclick = async () => {
16578
- // Connect/Reconnect drive the device-code sign-in IN the app (AWARE owns
16579
- // the OAuth + token storage; we only show the code + reflect the result —
16580
- // the token never crosses floless.app). Disconnect stays a copied command.
17184
+ // Connect/Reconnect drive the sign-in IN the app (AWARE owns the OAuth + token storage; we only show the code
17185
+ // and reflect the result — the token never crosses floless.app). #3301: Disconnect runs in the app too, after a
17186
+ // confirm: AWARE deletes the stored sign-in itself, so no secret crosses here either.
16581
17187
  if (btn.dataset.intAction === 'disconnect') {
16582
- const cmd = 'aware disconnect ' + btn.dataset.int;
16583
- const copied = await copyToClipboard(cmd);
16584
- showToast(`${copied ? 'Copied — run' : 'Run'} in your terminal: ${cmd}`, 'info');
17188
+ const integration = integrations.find((row) => row.id === btn.dataset.int);
17189
+ if (integration) confirmIntegrationDisconnect(integration);
16585
17190
  return;
16586
17191
  }
16587
17192
  // #2649: a named account's own Reconnect carries its account; the Drive choice is the card's checkbox.
@@ -16679,22 +17284,23 @@
16679
17284
  });
16680
17285
  if (slot) slot.innerHTML = 'Starting sign-in…';
16681
17286
  try {
16682
- const res = await api(`/api/connect/${encodeURIComponent(id)}`, { method: 'POST', body });
17287
+ // `connect`, not `res`: a start it declines carries the route’s own sentence in `message` (a constant per service).
17288
+ const connect = await api(`/api/connect/${encodeURIComponent(id)}`, { method: 'POST', body });
16683
17289
  // A managed-preset pre-flight (e.g. port 80 already in use) refuses to start
16684
17290
  // and broadcasts the reason over SSE (connect-result). Clear the guard so the
16685
17291
  // user can retry after fixing it, and don't claim the browser opened. #2649: the
16686
17292
  // reason also comes back here, so a card waiting on a reconnecting SSE still says why.
16687
- if (res && res.started === false) {
17293
+ if (connect && connect.started === false) {
16688
17294
  connecting.delete(id);
16689
- if (slot && typeof res.message === 'string') slot.innerHTML = connectResultSlotHtml({ status: 'failed', message: res.message });
17295
+ if (slot && typeof connect.message === 'string') slot.innerHTML = connectResultSlotHtml({ status: 'failed', message: connect.message });
16690
17296
  return;
16691
17297
  }
16692
17298
  if (slot) {
16693
- if (res.flow === 'device-code' && res.prompt) {
17299
+ if (connect.flow === 'device-code' && connect.prompt) {
16694
17300
  // Fallback flow: show the device code to enter at the verification URL.
16695
17301
  slot.innerHTML =
16696
- `Go to <a href="${escapeAttr(res.prompt.verification_uri)}" target="_blank" rel="noopener">${escapeHtml(res.prompt.verification_uri)}</a>` +
16697
- ` and enter code <strong class="dc-code">${escapeHtml(res.prompt.user_code)}</strong> — waiting for sign-in…`;
17302
+ `Go to <a href="${escapeAttr(connect.prompt.verification_uri)}" target="_blank" rel="noopener">${escapeHtml(connect.prompt.verification_uri)}</a>` +
17303
+ ` and enter code <strong class="dc-code">${escapeHtml(connect.prompt.user_code)}</strong> — waiting for sign-in…`;
16698
17304
  } else {
16699
17305
  // OAuth: aware opened the provider sign-in in the browser.
16700
17306
  slot.innerHTML = 'Opening your browser to sign in… complete it there and this will update automatically.';
@@ -16706,7 +17312,7 @@
16706
17312
  // (a 409 busy lock, whose sentence names it) are shown where the person clicked; anything else goes to the usual
16707
17313
  // error report.
16708
17314
  const own = e && (e.status === 400 || (e.status === 409 && e.body?.code === 'lifecycle-busy'));
16709
- const said = own && e.body && typeof e.body.error === 'string' ? e.body.error : '';
17315
+ const said = own ? personText(e.body) : '';
16710
17316
  if (slot) slot.innerHTML = said ? escapeHtml(said) : '';
16711
17317
  if (!said) reportErr(e);
16712
17318
  }
@@ -16731,7 +17337,8 @@
16731
17337
  const db = document.getElementById('debug-btn');
16732
17338
  if (db) {
16733
17339
  const node = id && currentId && apps.get(currentId)?.nodes.find((n) => n.id === id);
16734
- db.hidden = !(node && node.config && typeof node.config.code === 'string');
17340
+ // #3234: the debugger attaches to the Tekla bridge, so only a Tekla exec step offers it (the server refuses any other).
17341
+ db.hidden = !(node && node.agent === 'tekla' && node.command === 'exec' && node.config && typeof node.config.code === 'string');
16735
17342
  }
16736
17343
  };
16737
17344
 
@@ -17008,7 +17615,7 @@
17008
17615
  const ai = r.kind === 'trigger' ? globalThis.flolessAgentSteps?.watcherCardParts?.(r.aiEvents) ?? null
17009
17616
  : !r.agent && r.lastRun ? globalThis.flolessAgentSteps?.routineAiParts(r.lastRun) : null;
17010
17617
  if (!ai) return '';
17011
- return `<span class="rtn-dot">·</span><span class="rtn-ai" data-tip="${escapeAttr(ai.aiTip)}">${escapeHtml(ai.ai)}</span>`
17618
+ return `<span class="rtn-dot">·</span><span class="rtn-ai${ai.stoppedAt ? ' is-stopped' : ''}" data-tip="${escapeAttr(ai.aiTip)}">${escapeHtml(ai.ai)}</span>`
17012
17619
  + (ai.questions ? `<span class="rtn-dot">·</span><span class="rtn-ai-q" data-tip="${escapeAttr(ai.questionsTip)}">${escapeHtml(ai.questions)}</span>` : '');
17013
17620
  }
17014
17621
  function lastRunTip(r) {
@@ -17029,6 +17636,10 @@
17029
17636
  // #2241 S5: a run with an AI step says so, and says how many questions it left for you.
17030
17637
  const ai = globalThis.flolessAgentSteps?.routineAiParts(lr);
17031
17638
  const aiWords = ai ? ` — ${ai.ai}${ai.questions ? ' · ' + ai.questions : ''}` : '';
17639
+ // #3229: a run its AI step's check stopped ended "ok"; the row never reads as a finished run.
17640
+ const head = ai && ai.stoppedAt
17641
+ ? `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 : ''}`
17642
+ : `Last run ${lr.status}${aiWords}`;
17032
17643
  // A run that finished on a stated assumption says so with its outcome, never only in the report.
17033
17644
  const warnings = Array.isArray(lr.warnings) ? lr.warnings.filter((warning) => typeof warning === 'string' && warning) : [];
17034
17645
  // #1998: a run made under an approval carried forward to newer tool versions says so, in AWARE's words.
@@ -17040,7 +17651,7 @@
17040
17651
  && typeof w.detail === 'string' && w.detail.trim() && (w.via === null || typeof w.via === 'string')
17041
17652
  && Array.isArray(w.choices) && w.choices.every((choice) => typeof choice === 'string')) : [];
17042
17653
  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 `Last run ${lr.status}${aiWords}${lr.reason ? ' — ' + lr.reason : ''}${warnings.length ? ' — ' + warnings.join(' ') : ''} · ${absTime(lr.at)}${dur}${carried}${bridge}`;
17654
+ return `${head}${lr.reason ? ' — ' + lr.reason : ''}${warnings.length ? ' — ' + warnings.join(' ') : ''} · ${absTime(lr.at)}${dur}${carried}${bridge}`;
17044
17655
  }
17045
17656
 
17046
17657
  // ── Trigger-routine row helpers ─────────────────────────────────────────────
@@ -17098,9 +17709,19 @@
17098
17709
  return { label: 'stopped', dotClass: '', tip: 'Not running', sr: 'Status: stopped' };
17099
17710
  }
17100
17711
 
17101
- async function loadRoutinesData() {
17712
+ let routinesLoadSeq = 0;
17713
+ let routinesLoadLatest = Promise.resolve();
17714
+ // Several loads can be in flight (each routine-changed event starts one): only the newest answer is applied, so an
17715
+ // older list arriving last never brings back a question already answered. A superseded load resolves with the newest
17716
+ // one, so a caller that awaits it still reads the fresh list.
17717
+ function loadRoutinesData() {
17718
+ routinesLoadLatest = applyRoutinesLoad(++routinesLoadSeq);
17719
+ return routinesLoadLatest;
17720
+ }
17721
+ async function applyRoutinesLoad(seq) {
17102
17722
  try {
17103
17723
  const res = await api('/api/routines');
17724
+ if (seq !== routinesLoadSeq) return routinesLoadLatest;
17104
17725
  // The Workflows landing repaints only when the routines its "Scheduled" chips read change, not on every
17105
17726
  // scheduler tick.
17106
17727
  const chipKey = (list) => JSON.stringify(list.filter((r) => r.enabled && !r.broken).map((r) => [r.workflow, r.name]));
@@ -17118,6 +17739,9 @@
17118
17739
  }
17119
17740
  for (const id of live) void refreshRoutineReportDiscovery(id);
17120
17741
  if (routinesData.some((r) => r.agent)) void refreshRoutineAgents();
17742
+ // Owner ruling 2026-11-06: the card asking whether to run what was missed while FloLess was closed.
17743
+ try { window.flolessMissedRoutines?.update(routinesData, { api, reportErr, reload: loadRoutinesData }); }
17744
+ catch (err) { console.error('Missed-routines card failed', err); }
17121
17745
  if ($routinesModal.classList.contains('show')) renderRoutinesList();
17122
17746
  // Last, and on its own: a landing repaint that throws must not skip the reconcile above.
17123
17747
  if (wfLanding && chipsChanged) {
@@ -17249,7 +17873,8 @@
17249
17873
  const savedPath = typeof m.savedPath === 'string' ? m.savedPath : '';
17250
17874
  const fromChat = m.from !== 'terminal';
17251
17875
  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 };
17876
+ withFiles: m.withFiles === true, runId: typeof m.runId === 'string' ? m.runId : null,
17877
+ aiStop: globalThis.flolessAgentSteps?.stoppedRunView?.(m) ?? null }; // #3229: the same banner as after this window's own Run
17253
17878
  lastReportByApp.set(m.workflow, entry);
17254
17879
  const open = $reportModal && $reportModal.classList.contains('show');
17255
17880
  if (!open || currentId !== m.workflow || reportRunning) return;
@@ -17264,7 +17889,8 @@
17264
17889
  if (!m || !m.workflow || typeof m.html !== 'string') return;
17265
17890
  const prev = lastReportByApp.get(m.workflow);
17266
17891
  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 };
17892
+ const entry = { nodeId: m.nodeId || null, label: 'scheduled', html: m.html, withFiles: m.withFiles === true, runId: typeof m.runId === 'string' ? m.runId : null,
17893
+ aiStop: globalThis.flolessAgentSteps?.stoppedRunView?.(m) ?? null }; // #3229: a scheduled run that stopped at an AI step says so too
17268
17894
  lastReportByApp.set(m.workflow, entry);
17269
17895
  const open = $reportModal && $reportModal.classList.contains('show');
17270
17896
  if (open && currentId === m.workflow && !reportRunning && !foregroundTrigger) {
@@ -17480,6 +18106,33 @@
17480
18106
  }
17481
18107
  // ── tab signal (end)
17482
18108
 
18109
+ /** A run-live, node-progress or run-finished event from the server's event stream. */
18110
+ function onRunEvent(m) {
18111
+ // #2228: live progress of a long run. This tab's own run is matched by its token; a run of the
18112
+ // workflow this tab shows that someone else started is followed read-only (no Stop).
18113
+ // #2241: a run that FAILED after an Agent answered ends with run-finished, not run-ended: its AI record is read then too.
18114
+ if (m.type === 'run-finished' && m.id && m.id === currentId) void globalThis.flolessAgentSteps?.refreshRunRecord(m.id);
18115
+ // Workflows → History: a run starting shows as Running, and a failed run ends with run-finished alone.
18116
+ if (m.type !== 'node-progress') window.flolessRunHistory?.refresh?.();
18117
+ // #3253: the one rule for every branch below (this tab's own run, one it follows, the report overlay, the tab
18118
+ // signal): the ending of another attempt (a Run anyway's refused one, however late) never ends, settles or forgets
18119
+ // the attempt this tab is watching now.
18120
+ if (m.type === 'run-finished' && m.clientRunToken && liveRun && liveRun.token && m.clientRunToken !== liveRun.token) return;
18121
+ signalRunEvent(m); // the browser tab hears its run's ending even when the strip already settled
18122
+ if (liveRunOwns(m)) {
18123
+ if (m.type === 'run-live') { if (m.runId) { liveRun.runId = m.runId; signalRunNote(liveRun); } }
18124
+ else if (m.type === 'node-progress') onLiveProgress(m);
18125
+ else finishLiveRun(typeof m.outcome === 'string' ? m.outcome : 'failed');
18126
+ } else if (m.id === currentId && !(liveRun && liveRun.owner && !liveRun.ended)) {
18127
+ if (m.type === 'run-finished') {
18128
+ if (liveRun && !liveRun.owner && (!m.runId || m.runId === liveRun.runId)) finishLiveRun(typeof m.outcome === 'string' ? m.outcome : 'failed');
18129
+ } else {
18130
+ if (!liveRun || liveRun.ended || (m.runId && liveRun.runId && m.runId !== liveRun.runId)) observeLiveRun(m);
18131
+ if (m.type === 'node-progress') onLiveProgress(m);
18132
+ }
18133
+ }
18134
+ }
18135
+
17483
18136
  function liveRunOwns(m) {
17484
18137
  if (!liveRun || liveRun.ended) return false;
17485
18138
  if (m.clientRunToken && m.clientRunToken === liveRun.token) return true;
@@ -17550,6 +18203,12 @@
17550
18203
  syncRunStrip();
17551
18204
  }
17552
18205
 
18206
+ /** A Run's own ending: settle the tracked attempt it holds (by token), never a later one that replaced it. */
18207
+ function finishOwnLiveRun(token, outcome) {
18208
+ if (!token || !liveRun || liveRun.token !== token) return;
18209
+ if (outcome === 'no-answer') settleLiveRunWithoutAnswer(); else finishLiveRun(outcome);
18210
+ }
18211
+
17553
18212
  function finishLiveRun(outcome) {
17554
18213
  if (pageLeaving) return; // the page is going away mid-run: keep the token so the next page resumes it
17555
18214
  if (liveRun && liveRun.ended && signalRunIs(liveRun)) {
@@ -17804,7 +18463,9 @@
17804
18463
  $reportSub.innerHTML = `Live run of <code>${escapeHtml(id)}</code> — the report re-renders on every event.`;
17805
18464
  showModal($reportModal);
17806
18465
  try {
17807
- const res = await api('/api/trigger-run', { method: 'POST', body: JSON.stringify({ id, inputs: currentInputs() }) });
18466
+ const res = await postAskingElsewhere('/api/trigger-run', { id, inputs: currentInputs() }, { onApprove: () => {
18467
+ if ($compileBtn && !$compileBtn.disabled) $compileBtn.click();
18468
+ } });
17808
18469
  foregroundTrigger = { appId: id, sessionId: res.sessionId, firedCount: 0 };
17809
18470
  paintForegroundListening();
17810
18471
  beatLiveViewer();
@@ -17940,6 +18601,38 @@
17940
18601
  return null;
17941
18602
  }
17942
18603
 
18604
+ /** #3232: how a routine's workflow reads — an owned one by its name and owner (server-resolved), else its id. */
18605
+ function routineWorkflowText(r) {
18606
+ const label = r.workflowLabel;
18607
+ return label?.name ? (label.owner ? `${label.name} · ${label.owner}` : label.name) : r.workflow;
18608
+ }
18609
+
18610
+ /**
18611
+ * #3232: the row's "what it runs" span. An owned workflow's name and project stay on one line beside the schedule:
18612
+ * the name shortens first, the project after it, and the whole label is the tip.
18613
+ */
18614
+ function routineWorkflowHtml(r, whatText) {
18615
+ const label = r.agent ? null : r.workflowLabel;
18616
+ if (!label?.name) return `<span class="rtn-wf">${escapeHtml(whatText)}</span>`;
18617
+ return `<span class="rtn-wf named" data-tip="${escapeAttr(whatText)}"><span class="rtn-wf-name">${escapeHtml(label.name)}</span>`
18618
+ + (label.owner ? `<span class="rtn-wf-owner">· ${escapeHtml(label.owner)}</span>` : '') + '</span>';
18619
+ }
18620
+
18621
+ /**
18622
+ * #3232: the workflows a routine can run, read from `/api/apps?names=1` each time the form opens — every installed workflow
18623
+ * it could run before, by its id, except an owned workflow's publications: the server names the ACTIVE one
18624
+ * (`ownedWorkflowLabel`), listed once as "<name> · <project>", and a superseded one is left out. The value stays the
18625
+ * runtime id the server stores; the label is what the person recognises. When the server could not read the names
18626
+ * (`ownedNamesUnavailable`), `namesUnavailable` says so, so the form tells the person rather than quietly leaving them out.
18627
+ */
18628
+ async function routineWorkflowChoices() {
18629
+ const { apps: installed, ownedNamesUnavailable } = await api('/api/apps?names=1');
18630
+ const choices = installed.filter((a) => a.execution !== 'internal' && (!a.ownedPublication || a.ownedWorkflowLabel?.name))
18631
+ .map((a) => ({ id: a.id, label: a.ownedPublication ? `${a.ownedWorkflowLabel.name} · ${a.ownedWorkflowLabel.owner}` : a.id }))
18632
+ .sort((x, y) => x.label.localeCompare(y.label));
18633
+ return { choices, namesUnavailable: ownedNamesUnavailable === true };
18634
+ }
18635
+
17943
18636
  function renderRoutinesList() {
17944
18637
  const $list = document.getElementById('routines-list');
17945
18638
  const $quota = document.getElementById('rtn-quota');
@@ -17995,8 +18688,8 @@
17995
18688
  if (held) { nextLabel = held.label; nextTip = held.tip; }
17996
18689
  }
17997
18690
  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.workflow;
18691
+ // #2035: an agent routine names its agent, not a workflow id; #3232: an owned workflow is named, not its runtime id.
18692
+ const whatText = r.agent ? `Agent · ${routineAgentNames.get(r.agent.agentId) || 'agent'}` : routineWorkflowText(r);
18000
18693
  const toggleTip = isTrigger ? (r.enabled ? 'Stop listening' : 'Start listening') : `${r.enabled ? 'Disable' : 'Enable'} this routine`;
18001
18694
  // One sentence for all three surfaces a blocked ▶ speaks through: the hover tip, the `?`
18002
18695
  // band (which reads data-blocked-reason), and the toast when a click still reaches the
@@ -18015,7 +18708,7 @@
18015
18708
  <div class="rtn-item ${isTrigger ? 'trigger ' : ''}${r.enabled ? '' : 'disabled'} ${running ? 'running' : ''}" data-id="${escapeAttr(r.id)}">
18016
18709
  <div class="rtn-main">
18017
18710
  <div class="rtn-name">${escapeHtml(r.name)}</div>
18018
- <div class="rtn-sub"><span class="rtn-wf">${escapeHtml(whatText)}</span><span class="rtn-dot">·</span><span>${escapeHtml(whenText)}</span>${broken}${routineAiHtml(r)}</div>
18711
+ <div class="rtn-sub">${routineWorkflowHtml(r, whatText)}<span class="rtn-dot">·</span><span>${escapeHtml(whenText)}</span>${broken}${routineAiHtml(r)}</div>
18019
18712
  ${reportLine}
18020
18713
  </div>
18021
18714
  <div class="rtn-meta"${isTrigger ? ' aria-live="polite" aria-atomic="true"' : ''}>
@@ -18051,7 +18744,12 @@
18051
18744
  }
18052
18745
  async function runRoutineNow(id) {
18053
18746
  try {
18054
- await api(`/api/routines/${encodeURIComponent(id)}/run`, { method: 'POST' });
18747
+ const workflow = routinesData.find((r) => r.id === id)?.workflow;
18748
+ await postAskingElsewhere(`/api/routines/${encodeURIComponent(id)}/run`, {}, { routine: true, onApprove: async () => {
18749
+ if (!workflow) return;
18750
+ hideModal($routinesModal);
18751
+ await selectComboById(workflow);
18752
+ } });
18055
18753
  runningRoutines.add(id); // optimistic, for immediate feedback; SSE confirms it moments later
18056
18754
  renderRoutinesList();
18057
18755
  // #2062: a hand run starts a paused agent; its schedule stays held. Queued, not yet started — the row says how it went.
@@ -18062,6 +18760,7 @@
18062
18760
  // and nothing was started, so never say it was. Keyed on the FLAG rather than the status: this
18063
18761
  // route is lifecycle-gated, so a 409 can also mean "aware is busy with maintenance", which is a
18064
18762
  // different sentence and belongs in the error path.
18763
+ if (e.body && e.body.elsewhereStopped) return; // the person chose not to run it; nothing started
18065
18764
  if (!(e.body && e.body.running)) { reportErr(e, 'run this routine now'); return; }
18066
18765
  showToast(RTN_ALREADY_RUNNING, 'info');
18067
18766
  // RECONCILE rather than add: the 409 is a point-in-time snapshot, and the run can end while the
@@ -18344,17 +19043,22 @@
18344
19043
  const r = id ? routinesData.find((x) => x.id === id) : null;
18345
19044
  editReturnFocus = opts.returnFocus || null;
18346
19045
  const $wf = document.getElementById('rtn-workflow');
18347
- try {
18348
- const { apps: list } = await api('/api/apps');
18349
- editWorkflows = list.filter((a) => a.execution !== 'internal');
18350
- } catch { editWorkflows = []; }
18351
- $wf.innerHTML = editWorkflows.map((a) => `<option value="${escapeAttr(a.id)}">${escapeHtml(a.id)}</option>`).join('');
19046
+ let namesUnavailable = false;
19047
+ try { ({ choices: editWorkflows, namesUnavailable } = await routineWorkflowChoices()); } catch { editWorkflows = []; }
19048
+ document.getElementById('rtn-workflow-unnamed').hidden = !(namesUnavailable && !r);
19049
+ // Editing a routine whose workflow is no longer listed (archived, locked) still shows what it runs.
19050
+ if (r && !r.agent && r.workflow && !editWorkflows.some((a) => a.id === r.workflow)) {
19051
+ editWorkflows = [{ id: r.workflow, label: routineWorkflowText(r) }, ...editWorkflows];
19052
+ }
19053
+ $wf.innerHTML = editWorkflows.map((a) => `<option value="${escapeAttr(a.id)}">${escapeHtml(a.label)}</option>`).join('');
18352
19054
  document.getElementById('rtn-edit-title').textContent = r ? 'Edit routine' : 'New routine';
18353
19055
  document.getElementById('rtn-name').value = r ? r.name : '';
18354
19056
  // #2046: a Guide suggestion names the workflow; it is preselected only when it is one of the choices.
18355
19057
  const suggested = !r && opts.workflowId && editWorkflows.some((a) => a.id === opts.workflowId) ? opts.workflowId : null;
18356
19058
  if (!r && opts.workflowId && !suggested) {
18357
- showToast(`${opts.workflowId} can’t be scheduled from here, so no workflow is chosen yet. Pick the one to run in the list.`, 'warn');
19059
+ showToast(namesUnavailable
19060
+ ? '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.'
19061
+ : `${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
19062
  }
18359
19063
  const wfId = r ? r.workflow : opts.workflowId && !suggested ? '' : (suggested || (editWorkflows[0] ? editWorkflows[0].id : ''));
18360
19064
  $wf.value = wfId;
@@ -18441,7 +19145,8 @@
18441
19145
  await loadRoutinesData();
18442
19146
  } catch (e) {
18443
19147
  // #2035: the server words an agent routine's refusal for the person (archived, another folder…); say that.
18444
- const said = asAgent && typeof e?.body?.error === 'string' && e.status < 500 ? e.body.error : null;
19148
+ // #3097 3c.4: so does every routine refusal it marks as its own (`refusal: 'routine'`), for a workflow routine too.
19149
+ const said = (asAgent || e?.body?.refusal === 'routine') && typeof e?.body?.error === 'string' && e.status < 500 ? e.body.error : null;
18445
19150
  showToast(said || 'We couldn’t save this routine because FloLess could not save the change. Try again.', 'err');
18446
19151
  }
18447
19152
  }
@@ -19146,11 +19851,11 @@
19146
19851
  if (error?.code === 'chat-start-cancelled' || gone()) return;
19147
19852
  const notReady = error?.code === 'chat-runtime-not-ready';
19148
19853
  const explained = notReady ? '' : chatStartErrorText(error);
19149
- if (notReady) showToast(error.message, 'warn');
19854
+ if (notReady) showToast(errorText(error), 'warn');
19150
19855
  else reportChatStartErr(error);
19151
19856
  setRequestHelpBusy(null);
19152
19857
  const sub = document.getElementById('request-help-sub');
19153
- if (sub) sub.textContent = notReady ? error.message : explained || (requestHelpCopied
19858
+ if (sub) sub.textContent = notReady ? errorText(error) : explained || (requestHelpCopied
19154
19859
  ? 'The request is still in Requests. Try again, start it in the background, or use the copied instruction in your terminal.'
19155
19860
  : 'The request is still in Requests. Try again, start it in the background, or copy the terminal instruction.');
19156
19861
  // A Request with no safe instruction has nothing to copy either — AI Chat's sentence says to
@@ -19228,9 +19933,6 @@
19228
19933
  loadTemplates().catch(() => {}),
19229
19934
  loadRequests().catch(() => {}),
19230
19935
  ]);
19231
- // Custom Panels boot is deferred to here so panels.js never fetches while the
19232
- // subscription gate / AWARE bootstrap would 402/409 it.
19233
- if (window.flolessPanels) window.flolessPanels.boot();
19234
19936
  return loadApps().catch((e) => {
19235
19937
  reportErr(e);
19236
19938
  // #2644: a module refusal means the server answered; it is never "unreachable". (loadApp already shows a refused
@@ -19611,11 +20313,6 @@
19611
20313
  }
19612
20314
  }
19613
20315
 
19614
- // ── Custom Panels bridge (web/panels.js) ─────────────────────────────────────
19615
- // panels.js renders ~/.floless/ui/extensions.json into the Dashboard view. It
19616
- // loads AFTER this file and reuses these seams instead of duplicating the fetch /
19617
- // report-viewer plumbing — the renderer composes nothing itself. Kept minimal on
19618
- // purpose; widen only when a panel block genuinely needs another seam.
19619
20316
  // #1890: AI Chat is always on. Where no project or owned workflow is open — the Workspaces landing, the Workflows
19620
20317
  // landing, an installed (not owned) workflow — the conversation belongs to the workspace, with what is open as context.
19621
20318
  function currentChatScope() {
@@ -19732,10 +20429,20 @@
19732
20429
  notifyChatScope();
19733
20430
  }
19734
20431
 
20432
+ // #3234: the card names what the workflow needs ("Tekla model", the author's "Steel model", "AI step"), never the
20433
+ // runner its steps use. The server derives it (app-reader appListFacts); a row from an older server falls back to the
20434
+ // provider it sent.
19735
20435
  function workflowCardMeta(row) {
19736
20436
  const nodes = Number(row.nodes) || 0;
19737
- const provider = PROVIDER_LABELS[row.provider] || row.provider || '';
19738
- return `${nodes} node${nodes === 1 ? '' : 's'}${provider ? ` · ${provider}` : ''}`;
20437
+ const count = `${nodes} node${nodes === 1 ? '' : 's'}`;
20438
+ if (Array.isArray(row.needs)) return [count, ...row.needs.filter((n) => typeof n === 'string')].join(' · ');
20439
+ const provider = row.provider && row.provider !== 'other' ? (PROVIDER_LABELS[row.provider] || row.provider) : '';
20440
+ return `${count}${provider ? ` · ${provider}` : ''}`;
20441
+ }
20442
+ // …and, on a line of its own that is never cut short, that this computer's AWARE is too old to run it.
20443
+ function workflowCardAwareLine(row) {
20444
+ const minimum = row.needsAware && typeof row.needsAware.minimum === 'string' ? row.needsAware.minimum : '';
20445
+ return minimum ? `<div class="ws-meta wf-card-aware">Needs AWARE ${escapeHtml(minimum)} or newer</div>` : '';
19739
20446
  }
19740
20447
 
19741
20448
  // The card's "Scheduled" chip and its tip ('' = no chip). A routine runs the installed app it names, which is the
@@ -20077,13 +20784,14 @@
20077
20784
  const ownedRow = row.ownedWorkflow;
20078
20785
  const name = ownedRow ? ownedRow.displayName : (row.displayName || row.name || row.id);
20079
20786
  const chip = ownedRow ? 'Yours' : 'Installed';
20080
- const where = ownedRow ? (row.ownerLabel || 'Standalone') : (PROVIDER_LABELS[row.provider] || 'Installed workflow');
20787
+ const where = ownedRow ? (row.ownerLabel || 'Standalone') : 'Installed workflow'; // #3234: what it needs is on the next line
20081
20788
  const scheduledTip = scheduledRoutineTip(routinesData, row.id);
20082
20789
  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
20790
  + `<div class="ws-body"><div class="wf-card-text"><span class="ws-kind wf-kind">${chip}</span>`
20084
20791
  + (scheduledTip ? `<span class="ws-kind wf-kind wf-scheduled" data-tip="${esc(scheduledTip)}">Scheduled</span>` : '')
20085
20792
  + `<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></div>`
20793
+ + `<div class="ws-meta wf-card-nodes">${esc(workflowCardMeta(row) + (dateLine(row) ? ` · ${dateLine(row)}` : ''))}</div>`
20794
+ + `${workflowCardAwareLine(row)}</div>`
20087
20795
  + (ownedRow ? kebabHtml(ownedRow.workflowId, name) : '') + `</div></div>`;
20088
20796
  };
20089
20797
  // One section: a disclosure whose summary names it and counts its cards. Your workflows and Installed start open,
@@ -20540,7 +21248,7 @@
20540
21248
  },
20541
21249
  // Open report HTML in the existing sandboxed HTML Viewer (same modal + srcdoc
20542
21250
  // iframe the canvas report node uses — no new sandbox surface). `savedPath` is
20543
- // optional: pass the run's saved_path so a dashboard-panel run surfaces the same
21251
+ // optional: pass the run's saved_path so the report surfaces the same
20544
21252
  // ⧉ Open file / ▤ Reveal buttons as a canvas run (#209); omit → they stay hidden.
20545
21253
  showHtmlReport(title, html, savedPath) {
20546
21254
  $reportTitle.textContent = title;
@@ -20584,26 +21292,26 @@
20584
21292
  // opened after the run) holds a different one or none. Say so instead of showing the wrong report.
20585
21293
  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
21294
  const cached = lastReportByApp.get(appId);
20587
- if (!runId) throw new Error(gone);
21295
+ if (!runId) throw Object.assign(new Error(gone), { forPerson: true });
20588
21296
  // #2266: a window opened (or reloaded) after the run reads the copy FloLess kept of THAT run's report, in the
20589
21297
  // workflow's Page. Never another run's: a report no longer kept says so.
20590
21298
  if (cached?.runId !== runId) {
20591
21299
  let kept = null;
20592
21300
  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.'); }
21301
+ 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
21302
  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.');
21303
+ 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
21304
  return await window.flolessPages.open(kept.home, kept.page.id, kept.shown.version);
20597
21305
  }
20598
- throw new Error(kept?.shown?.note
21306
+ throw Object.assign(new Error(kept?.shown?.note
20599
21307
  ? `${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.');
21308
+ : 'FloLess did not keep a copy of that run’s report. Open the workflow to see its latest results.'), { forPerson: true });
20601
21309
  }
20602
21310
  await this.openApp(appId);
20603
21311
  // 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);
21312
+ if (lastReportByApp.get(appId) !== cached) throw Object.assign(new Error(gone), { forPerson: true });
20605
21313
  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.');
21314
+ 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
21315
  showReport(nodeId);
20608
21316
  return true;
20609
21317
  },
@@ -20615,13 +21323,13 @@
20615
21323
  await window.flolessWorkspaces?.setMode?.('workflows');
20616
21324
  // The switch can stay on the current tab (another workflow's read failed): never focus a card nobody can see.
20617
21325
  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.');
21326
+ 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
21327
  }
20620
21328
  // The list is what is needed here, not any one workflow: a reload that fails keeps the list already on screen.
20621
21329
  try { await loadApps(); } catch (error) { console.warn('[project-access] the workflow list could not be read again', error); }
20622
21330
  showWorkflowsLanding(true);
20623
21331
  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.');
21332
+ 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
21333
  const box = card.closest('.wf-archived');
20626
21334
  if (box) box.open = true;
20627
21335
  card.scrollIntoView?.({ block: 'center' });
@@ -20640,13 +21348,13 @@
20640
21348
  // #2185: a draft built a moment ago is not in the cached list yet: read it once more before saying it is gone.
20641
21349
  if (!wfOwned.some((row) => row.workflowId === workflowId)) {
20642
21350
  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.'); }
21351
+ 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
21352
  }
20645
21353
  if (wfOwned.some((row) => row.workflowId === workflowId && row.status !== 'archived')) {
20646
21354
  openDraftWorkflow(workflowId);
20647
21355
  return true;
20648
21356
  }
20649
- throw new Error('That workflow is no longer here, so its conversation can’t be opened.');
21357
+ throw Object.assign(new Error('That workflow is no longer here, so its conversation can’t be opened.'), { forPerson: true });
20650
21358
  },
20651
21359
  // The New project dialog's AI choice (#1605): the installed Claude/Codex rows as last read, and
20652
21360
  // a fresh read of them. The same shared runtime state preferredChatProvider() answers from, so
@@ -20717,7 +21425,7 @@
20717
21425
  chooseInstructorRuntime,
20718
21426
  instructorAskOptions,
20719
21427
  instructionFor,
20720
- markedInstruction, // marked (paste-safe) form for clipboard copies — panels.js uses it (#73)
21428
+ markedInstruction, // marked (paste-safe) form for clipboard copies (#73)
20721
21429
  copyRequest, // copy ONE request, telling "no instruction body" apart from "clipboard refused"
20722
21430
  async runReadOnlyRequest(request, runtime) {
20723
21431
  if (!runtime || typeof window.flolessChat?.startRequest !== 'function') {