@floless/app 0.151.0 → 0.152.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +14426 -8494
- package/dist/skills/floless-app-knowledge/SKILL.md +25 -2
- package/dist/skills/floless-app-onboarding/SKILL.md +18 -1
- package/dist/skills/floless-app-report-issue/SKILL.md +10 -5
- package/dist/skills/floless-app-routines/SKILL.md +1 -1
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -4
- package/dist/templates/revit-model.flo +6 -2
- package/dist/templates/tekla-parser.flo +6 -2
- package/dist/web/agents.js +146 -9
- package/dist/web/app.css +215 -19
- package/dist/web/app.js +53 -8
- package/dist/web/aware.js +852 -53
- package/dist/web/chat.css +98 -4
- package/dist/web/chat.js +550 -35
- package/dist/web/commands-shell.js +290 -20
- package/dist/web/connections.js +24 -6
- package/dist/web/flo-avatar.js +191 -0
- package/dist/web/flo.js +156 -0
- package/dist/web/guide.js +695 -57
- package/dist/web/index.html +58 -7
- package/dist/web/instructor.js +6 -1
- package/dist/web/local-discovery.js +35 -6
- package/dist/web/panels.js +2 -0
- package/dist/web/parser-setup-recovery.js +250 -0
- package/dist/web/tool-updates.js +330 -36
- package/dist/web/workspace-root-management.js +197 -0
- package/dist/web/workspaces.js +235 -15
- package/package.json +1 -1
package/dist/web/aware.js
CHANGED
|
@@ -2104,8 +2104,9 @@
|
|
|
2104
2104
|
const openId = currentId;
|
|
2105
2105
|
const generation = ++appsLoadGeneration;
|
|
2106
2106
|
let owned = null;
|
|
2107
|
+
let unreadable = [];
|
|
2107
2108
|
try {
|
|
2108
|
-
({ apps: list } = await api('/api/workflows/library'));
|
|
2109
|
+
({ apps: list, unreadable = [] } = await api('/api/workflows/library'));
|
|
2109
2110
|
try { ({ workflows: owned } = await api('/api/workflows/owned?archived=1')); }
|
|
2110
2111
|
catch { /* the owned list is additive here: a failed read keeps the drafts last shown */ }
|
|
2111
2112
|
// An older refresh that finishes after a newer one must not overwrite what the newer one showed.
|
|
@@ -2114,6 +2115,7 @@
|
|
|
2114
2115
|
list = list.filter((a) => a.execution !== 'internal');
|
|
2115
2116
|
rememberWorkflowOwners(list);
|
|
2116
2117
|
wfLibrary = list;
|
|
2118
|
+
wfUnreadable = Array.isArray(unreadable) ? unreadable.filter((row) => row && typeof row.id === 'string') : [];
|
|
2117
2119
|
} catch (e) {
|
|
2118
2120
|
// Usable before THIS refresh, or built by an earlier one (an overlapping refresh disabled it first, and its
|
|
2119
2121
|
// own success was then superseded): a failed refresh never strands a picker that has workflows in it.
|
|
@@ -2270,6 +2272,8 @@
|
|
|
2270
2272
|
let wfLanding = false;
|
|
2271
2273
|
let wfLandingBooted = false;
|
|
2272
2274
|
let wfLibrary = [];
|
|
2275
|
+
// C12 (#1337): installed workflows AWARE could not read ({ id, name, workflowId? }), named on the landing, never hidden.
|
|
2276
|
+
let wfUnreadable = [];
|
|
2273
2277
|
// #1890 PR 3b-0: every owned workflow, drafts included (/api/workflows/owned), and the draft open in the canvas
|
|
2274
2278
|
// area, if any. A draft has no runtime app, so it is never `currentId` and never goes to loadApp.
|
|
2275
2279
|
let wfOwned = [];
|
|
@@ -4844,8 +4848,9 @@
|
|
|
4844
4848
|
$reportShare.hidden = true; // the frame is blank — only a painted report is shareable
|
|
4845
4849
|
$reportOverlay.hidden = false;
|
|
4846
4850
|
$reportOverlay.innerHTML = opts.debug
|
|
4847
|
-
? `<div
|
|
4848
|
-
: `<div
|
|
4851
|
+
? `<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>`
|
|
4852
|
+
: `<div>${approvedModelReport ? 'Reading the selected approved model to make a complete, read-only report…' : `Running <code>${escapeHtml(currentId)}</code> against the live model…`}</div><button type="button" class="overlay-stop">■ Stop run</button>`;
|
|
4853
|
+
$reportOverlay.prepend(runningFlo());
|
|
4849
4854
|
showModal($reportModal);
|
|
4850
4855
|
$reportModal.dataset.nodeId = nodeId;
|
|
4851
4856
|
|
|
@@ -4941,21 +4946,30 @@
|
|
|
4941
4946
|
const code = body && typeof body.code === 'string' ? body.code : '';
|
|
4942
4947
|
const compileFix = (code === 'agent-version-changed' || code === 'needs-compile') && !$compileBtn.hidden;
|
|
4943
4948
|
const reinstall = code === 'agent-files-changed';
|
|
4949
|
+
// #2123: FloLess refused before anything started (the workflow was archived, edited or re-published): it never
|
|
4950
|
+
// "stopped before it finished", and no node is running.
|
|
4951
|
+
const notRun = !!(body && body.notRun);
|
|
4952
|
+
if (notRun) clearNodeStatus();
|
|
4953
|
+
// A not-run answer whose fix the sentence names (restore, publish, compile, run again) is no fault: "Report this
|
|
4954
|
+
// problem" would imply a bug. The server says which sentences send the person to Report an issue; those keep it.
|
|
4955
|
+
const reportable = !notRun || body.reportable === true;
|
|
4944
4956
|
clearReportFrames();
|
|
4945
4957
|
$reportShare.hidden = true;
|
|
4946
4958
|
$reportOverlay.hidden = false;
|
|
4947
4959
|
$reportOverlay.replaceChildren();
|
|
4948
|
-
$reportSub.textContent = 'The report could not be created.';
|
|
4960
|
+
$reportSub.textContent = notRun ? 'Nothing ran, so no report was made.' : 'The report could not be created.';
|
|
4949
4961
|
|
|
4950
4962
|
const card = mkEl('div', 'cred-fail-card run-fail-card');
|
|
4951
4963
|
card.setAttribute('role', 'status');
|
|
4952
4964
|
const status = mkEl('div', 'cred-fail-status');
|
|
4953
|
-
|
|
4965
|
+
// #2079: Flo, hat off (it stopped working), says this needs attention; the headline says what.
|
|
4966
|
+
const icon = mkEl('span', 'cred-fail-icon', typeof floAvatar === 'function' ? '' : '⚠');
|
|
4954
4967
|
icon.setAttribute('aria-hidden', 'true');
|
|
4955
|
-
|
|
4968
|
+
if (typeof floAvatar === 'function') { icon.classList.add('run-fail-flo'); floAvatar(icon, { size: 28, mood: 'warning' }); }
|
|
4969
|
+
status.append(icon, document.createTextNode(compileFix ? 'Needs compiling' : reinstall ? 'Tool changed' : notRun ? 'Didn’t run' : 'Run stopped'));
|
|
4956
4970
|
const headline = mkEl('div', 'cred-fail-headline', compileFix
|
|
4957
4971
|
? 'This workflow needs compiling again'
|
|
4958
|
-
: reinstall ? 'A tool needs reinstalling' : 'The workflow stopped before it finished');
|
|
4972
|
+
: reinstall ? 'A tool needs reinstalling' : notRun ? 'This workflow didn’t run' : 'The workflow stopped before it finished');
|
|
4959
4973
|
const text = mkEl('div', 'cred-fail-body', message);
|
|
4960
4974
|
for (const warning of (body && body.bridgeWarnings) || []) {
|
|
4961
4975
|
const label = warning.status === 'declaration-invalid' ? 'Ran with an invalid bridge declaration' : 'Ran with a bridge mismatch';
|
|
@@ -4978,11 +4992,12 @@
|
|
|
4978
4992
|
detail: { workflow: (app && app.displayName) || currentId || '', message,
|
|
4979
4993
|
reason: body && typeof body.reason === 'string' ? body.reason : '', returnFocus: report },
|
|
4980
4994
|
}));
|
|
4981
|
-
actions.append(report);
|
|
4995
|
+
if (reportable) actions.append(report);
|
|
4982
4996
|
card.append(status, headline, text, actions);
|
|
4983
4997
|
$reportOverlay.append(card);
|
|
4984
|
-
showToast(message, 'warn');
|
|
4985
|
-
|
|
4998
|
+
showToast(message, notRun ? 'info' : 'warn');
|
|
4999
|
+
const first = actions.querySelector('button');
|
|
5000
|
+
if (first) first.focus(); else { card.tabIndex = -1; card.focus(); } // #2123: a not-run card may have no button
|
|
4986
5001
|
}
|
|
4987
5002
|
|
|
4988
5003
|
const CRED_BODY_IDLE = 'Sign in again and then run the workflow — it takes about 30 seconds.';
|
|
@@ -6254,6 +6269,8 @@
|
|
|
6254
6269
|
// markup is injected via graftFill() (replaceChildren + insertAdjacentHTML) so the
|
|
6255
6270
|
// escaping discipline is explicit at each call site.
|
|
6256
6271
|
const $graftModal = document.getElementById('graft-modal');
|
|
6272
|
+
let graftOpener = null; // #2155: the control Build a tool was opened from (see returnFromGraft)
|
|
6273
|
+
const $graftDialog = $graftModal?.querySelector('.modal.graft');
|
|
6257
6274
|
const $graftBack = document.getElementById('graft-back');
|
|
6258
6275
|
const $graftCancel = document.getElementById('graft-cancel');
|
|
6259
6276
|
const $graftPrimary = document.getElementById('graft-primary');
|
|
@@ -6336,12 +6353,17 @@
|
|
|
6336
6353
|
$graftCancel.setAttribute('data-command-instance-label', 'building a tool');
|
|
6337
6354
|
const supported = prefill && GRAFT_KINDS.some((item) => item.kind === prefill.kind)
|
|
6338
6355
|
&& typeof prefill.ref === 'string' && prefill.ref.trim();
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6356
|
+
// #2055: a Discover program's install folder, named so Graft can say where the prefill came from (or that none was found).
|
|
6357
|
+
const origin = prefill && prefill.origin && typeof prefill.origin.label === 'string'
|
|
6358
|
+
? { label: prefill.origin.label.slice(0, 160), folderKnown: Boolean(supported), unreadable: prefill.origin.unreadable === true, ref: supported ? prefill.ref : '' } : null;
|
|
6359
|
+
graftState = { origin, kind: supported ? prefill.kind : 'dlls', ref: supported ? prefill.ref : '', decompile: false, showMore: false, preview: null, stagedRef: null, verifyInFlight: false, commitInFlight: false, probe: null, focusCheckRow: false, onPrimary: runGraftIntrospect, onBack: null };
|
|
6342
6360
|
$graftBack.disabled = false; $graftCancel.disabled = false;
|
|
6361
|
+
// #2155: where to put the person back on Cancel / Escape (the Tools library hides itself before this runs).
|
|
6362
|
+
const opener = document.activeElement;
|
|
6363
|
+
graftOpener = opener && typeof opener.focus === 'function' && opener !== document.body && !$graftModal.contains(opener) ? opener : null;
|
|
6343
6364
|
graftRenderPicker();
|
|
6344
6365
|
showModal($graftModal);
|
|
6366
|
+
graftLandFocus(); // #2128: an open modal dialog holds the keyboard from the start, wherever it was opened from
|
|
6345
6367
|
}
|
|
6346
6368
|
document.addEventListener('floless:discovery-graft', (event) => {
|
|
6347
6369
|
const source = event.detail;
|
|
@@ -6352,6 +6374,9 @@
|
|
|
6352
6374
|
|
|
6353
6375
|
function graftRenderPicker() {
|
|
6354
6376
|
clearGraftInstructorNote();
|
|
6377
|
+
// #2128: Back from the preview returns here, so the picker owns its own title (not only openGraftModal).
|
|
6378
|
+
document.getElementById('graft-title').textContent = 'Graft into tool';
|
|
6379
|
+
document.getElementById('graft-sub').textContent = 'Choose a DLL, package, or API spec. AWARE will inspect it and prepare command descriptions for your review.';
|
|
6355
6380
|
graftState.probe = null; // a check belongs to one inspected source; choosing again starts clean
|
|
6356
6381
|
graftState.onPrimary = runGraftIntrospect;
|
|
6357
6382
|
graftState.onBack = null;
|
|
@@ -6360,23 +6385,34 @@
|
|
|
6360
6385
|
`<button type="button" class="graft-kind${k.kind === graftState.kind ? ' selected' : ''}" data-kind="${k.kind}">` +
|
|
6361
6386
|
`<div class="gk-name">${escapeHtml(k.label)}</div><div class="gk-desc">${escapeHtml(k.desc)}</div></button>`).join('');
|
|
6362
6387
|
const moreBtn = graftState.showMore ? '' : '<button type="button" class="graft-more" id="graft-more">▸ More source types</button>';
|
|
6388
|
+
const chooseBtn = GRAFT_FOLDER_KINDS[graftState.kind]
|
|
6389
|
+
? '<button type="button" class="graft-choose" id="graft-choose" data-command-id="shell.graft-choose-folder" data-tip="Pick a folder instead of typing the path" aria-describedby="graft-field-label">Choose folder…</button>'
|
|
6390
|
+
: '';
|
|
6363
6391
|
const decompile = cfg.decompile
|
|
6364
6392
|
? `<label class="rtn-toggle" style="margin-top:4px;"><input type="checkbox" id="graft-decompile"${graftState.decompile ? ' checked' : ''}><span class="rtn-toggle-track"></span><span class="rtn-toggle-label">Include decompiled private types (slower)</span></label>`
|
|
6365
6393
|
: '';
|
|
6366
6394
|
graftFill(graftBodyEl(),
|
|
6367
6395
|
`<div class="modal-field"><label>Source type</label><div class="graft-kinds">${tiles}</div>${moreBtn}</div>` +
|
|
6368
6396
|
`<div class="modal-field"><label id="graft-field-label">${escapeHtml(cfg.field.label)}</label>` +
|
|
6369
|
-
`<
|
|
6397
|
+
`<p class="graft-hint graft-origin" id="graft-origin" hidden></p>` +
|
|
6398
|
+
`<div class="graft-row"><input type="text" id="graft-ref" placeholder="${escapeHtml(cfg.field.placeholder)}" value="${escapeHtml(graftState.ref)}" autocomplete="off" spellcheck="false" aria-describedby="graft-origin graft-hint">${chooseBtn}</div>` +
|
|
6370
6399
|
`<div class="graft-hint" id="graft-hint">${escapeHtml(cfg.field.hint)}</div>` +
|
|
6371
|
-
`<div id="graft-matched"></div>${decompile}</div>`);
|
|
6400
|
+
`<div id="graft-matched" role="status"></div>${decompile}</div>`);
|
|
6401
|
+
graftRenderOrigin();
|
|
6372
6402
|
graftBodyEl().querySelectorAll('.graft-kind').forEach((el) => { el.onclick = () => { graftState.kind = el.dataset.kind; graftRenderPicker(); }; });
|
|
6373
6403
|
const more = document.getElementById('graft-more'); if (more) more.onclick = () => { graftState.showMore = true; graftRenderPicker(); };
|
|
6374
6404
|
const ref = document.getElementById('graft-ref');
|
|
6375
6405
|
ref.oninput = () => {
|
|
6376
6406
|
graftState.ref = ref.value;
|
|
6407
|
+
graftRenderOrigin();
|
|
6408
|
+
// A picker failure note is about the last attempt; typing (or a chosen folder) brings back the field's own hint.
|
|
6409
|
+
const hintEl = document.getElementById('graft-hint');
|
|
6410
|
+
if (hintEl) hintEl.textContent = graftCfg(graftState.kind).field.hint;
|
|
6377
6411
|
graftFooter({ primaryLabel: 'Inspect source', primaryDisabled: !graftState.ref.trim() });
|
|
6378
6412
|
if (graftCfg(graftState.kind).match) graftMatchDebounced();
|
|
6379
6413
|
};
|
|
6414
|
+
const choose = document.getElementById('graft-choose');
|
|
6415
|
+
if (choose) choose.onclick = () => graftChooseFolder(choose, ref);
|
|
6380
6416
|
ref.onkeydown = (e) => { if (e.key === 'Enter' && graftState.ref.trim()) runGraftIntrospect(); };
|
|
6381
6417
|
const dec = document.getElementById('graft-decompile'); if (dec) dec.onchange = () => { graftState.decompile = dec.checked; };
|
|
6382
6418
|
graftFooter({ backShown: false, primaryLabel: 'Inspect source', primaryDisabled: !graftState.ref.trim() });
|
|
@@ -6384,6 +6420,53 @@
|
|
|
6384
6420
|
if (graftCfg(graftState.kind).match && graftState.ref.trim()) graftMatch();
|
|
6385
6421
|
}
|
|
6386
6422
|
|
|
6423
|
+
// #2055: path-based sources can be picked with the native folder picker; each turns the folder into its field's form.
|
|
6424
|
+
const trimSlash = (folder) => folder.replace(/[\\/]+$/, '');
|
|
6425
|
+
const GRAFT_FOLDER_KINDS = {
|
|
6426
|
+
dlls: (folder) => `${trimSlash(folder)}\\*.dll`,
|
|
6427
|
+
headers: (folder) => `${trimSlash(folder)}\\*.h`,
|
|
6428
|
+
csharp: (folder) => folder,
|
|
6429
|
+
};
|
|
6430
|
+
/** The note above the field: where a Discover prefill came from, or that no install folder was found. Never a block. */
|
|
6431
|
+
function graftRenderOrigin() {
|
|
6432
|
+
const el = document.getElementById('graft-origin');
|
|
6433
|
+
if (!el) return;
|
|
6434
|
+
const origin = graftState.origin;
|
|
6435
|
+
let text = '';
|
|
6436
|
+
if (origin && graftState.kind === 'dlls' && origin.folderKnown && graftState.ref === origin.ref) {
|
|
6437
|
+
text = `From Discover: the install folder for ${origin.label}. Check the DLLs listed below, or choose another folder.`;
|
|
6438
|
+
} else if (origin && graftState.kind === 'dlls' && !origin.folderKnown && !graftState.ref.trim()) {
|
|
6439
|
+
text = origin.unreadable
|
|
6440
|
+
? `FloLess couldn’t look in the install folder for ${origin.label}. Choose its folder, or paste the path to its DLLs.`
|
|
6441
|
+
: `FloLess didn’t find where ${origin.label} is installed. Choose its folder, or paste the path to its DLLs.`;
|
|
6442
|
+
}
|
|
6443
|
+
el.textContent = text;
|
|
6444
|
+
el.hidden = !text;
|
|
6445
|
+
}
|
|
6446
|
+
async function graftChooseFolder(button, input) {
|
|
6447
|
+
const toForm = GRAFT_FOLDER_KINDS[graftState.kind];
|
|
6448
|
+
if (!toForm) return;
|
|
6449
|
+
const generation = graftGeneration;
|
|
6450
|
+
const kind = graftState.kind;
|
|
6451
|
+
button.disabled = true;
|
|
6452
|
+
try {
|
|
6453
|
+
const res = await api('/api/graft/choose-folder', { method: 'POST', body: JSON.stringify({ current: graftState.ref }) });
|
|
6454
|
+
// The window was closed or reopened, or the source type changed, while the picker was open: nothing to fill.
|
|
6455
|
+
if (generation !== graftGeneration || kind !== graftState.kind || !input.isConnected) return;
|
|
6456
|
+
if (!res || res.cancelled || typeof res.path !== 'string') return;
|
|
6457
|
+
input.value = toForm(res.path);
|
|
6458
|
+
input.oninput();
|
|
6459
|
+
} catch (err) {
|
|
6460
|
+
const hint = document.getElementById('graft-hint');
|
|
6461
|
+
// The server's own sentence only when the server answered; a dropped connection says what to do instead.
|
|
6462
|
+
const said = err && err.status && typeof err.message === 'string' && err.message ? err.message : '';
|
|
6463
|
+
if (generation === graftGeneration && input.isConnected && hint) hint.textContent = said || 'FloLess couldn’t open the folder picker. Paste the folder path instead.';
|
|
6464
|
+
} finally {
|
|
6465
|
+
button.disabled = false;
|
|
6466
|
+
if (generation === graftGeneration && input.isConnected) input.focus();
|
|
6467
|
+
}
|
|
6468
|
+
}
|
|
6469
|
+
|
|
6387
6470
|
let graftMatchTimer = null;
|
|
6388
6471
|
function graftMatchDebounced() { clearTimeout(graftMatchTimer); graftMatchTimer = setTimeout(graftMatch, 350); }
|
|
6389
6472
|
async function graftMatch() {
|
|
@@ -6392,12 +6475,26 @@
|
|
|
6392
6475
|
if (!glob) { el.replaceChildren(); return; }
|
|
6393
6476
|
try {
|
|
6394
6477
|
const { files } = await api('/api/graft/match', { method: 'POST', body: JSON.stringify({ glob }) });
|
|
6395
|
-
|
|
6478
|
+
// An older answer must not describe a newer path (a Choose folder or a keystroke since it was asked).
|
|
6479
|
+
if (graftState.ref.trim() !== glob || !el.isConnected) return;
|
|
6480
|
+
if (!files || !files.length) {
|
|
6481
|
+
// #2055: a Discover prefill whose folder holds no DLLs says where they usually are, rather than showing nothing.
|
|
6482
|
+
if (graftState.origin && graftState.kind === 'dlls') {
|
|
6483
|
+
graftFill(el, '<div class="graft-hint graft-no-match">No DLLs in this folder. Programs often keep them in a bin folder. Choose that folder, or paste its path.</div>');
|
|
6484
|
+
} else el.replaceChildren();
|
|
6485
|
+
return;
|
|
6486
|
+
}
|
|
6396
6487
|
graftFill(el,
|
|
6397
6488
|
`<div class="graft-matched"><div class="graft-matched-h">Matched assemblies (${files.length})</div>` +
|
|
6398
6489
|
`<div class="graft-matched-f">${files.map(escapeHtml).join('<br>')}</div></div>` +
|
|
6399
6490
|
(files.length > 1 ? '<div class="graft-hint">All assemblies load together so AWARE can resolve references across them.</div>' : ''));
|
|
6400
|
-
} catch {
|
|
6491
|
+
} catch {
|
|
6492
|
+
if (graftState.ref.trim() !== glob || !el.isConnected) return;
|
|
6493
|
+
// #2055: under a Discover prefill the note promises a list below — so a failed lookup says so instead of showing nothing.
|
|
6494
|
+
if (graftState.origin && graftState.kind === 'dlls') {
|
|
6495
|
+
graftFill(el, '<div class="graft-hint graft-no-match">FloLess couldn’t list the DLLs for this path. Check the path, or choose another folder.</div>');
|
|
6496
|
+
} else el.replaceChildren();
|
|
6497
|
+
}
|
|
6401
6498
|
}
|
|
6402
6499
|
|
|
6403
6500
|
function graftIntrospectingLabel(kind) {
|
|
@@ -6506,8 +6603,12 @@
|
|
|
6506
6603
|
if (graftState.focusCheckRow) {
|
|
6507
6604
|
graftState.focusCheckRow = false;
|
|
6508
6605
|
document.getElementById('graft-check-row')?.focus();
|
|
6606
|
+
} else if (verifyButton) {
|
|
6607
|
+
verifyButton.focus();
|
|
6509
6608
|
} else {
|
|
6510
|
-
|
|
6609
|
+
// #2128: the Inspect button that had focus was disabled while AWARE read the source, so focus fell to
|
|
6610
|
+
// the page. Land on the preview's first control, never the page behind.
|
|
6611
|
+
graftLandFocus();
|
|
6511
6612
|
}
|
|
6512
6613
|
graftState.onBack = graftRenderPicker;
|
|
6513
6614
|
graftState.onPrimary = () => runGraftCommit(false);
|
|
@@ -6521,10 +6622,26 @@
|
|
|
6521
6622
|
const candidates = Array.isArray(preview.probeCandidates) ? preview.probeCandidates : [];
|
|
6522
6623
|
const needs = accounts.length
|
|
6523
6624
|
? `<dt>Needs an account</dt><dd>${accounts.map(escapeHtml).join(', ')}</dd>` : '';
|
|
6625
|
+
// #2116: a web service at a plain-http address (or with a port number) can't carry a check — AWARE pins
|
|
6626
|
+
// a check to a plain https address only. Say so, instead of offering commands AWARE would then refuse.
|
|
6627
|
+
// A tool that names no full web address at all (no servers in its spec) can't carry one either.
|
|
6628
|
+
// On an AWARE known to be older than the first that builds checks, say exactly what to update.
|
|
6629
|
+
const reason = !check && preview.probeUnavailable ? preview.probeUnavailable : null;
|
|
6630
|
+
const unavailableLine = !reason ? ''
|
|
6631
|
+
: reason.reason === 'aware-outdated'
|
|
6632
|
+
? `None. Adding a connection check needs AWARE ${escapeHtml(reason.minimum)} or newer, and this computer has ${escapeHtml(reason.version)}. Update AWARE (choose Upgrade AWARE beside the AWARE version if it shows, or run npm i -g @aware-aeco/cli@latest in a terminal), then inspect the source again. You can still create the tool and use it without one.`
|
|
6633
|
+
: reason.reason === 'insecure-address'
|
|
6634
|
+
? `None. A connection check works only with a secure https address (no port number), and this tool uses <code class="conn-code">${escapeHtml(reason.address)}</code>. You can still create the tool and use it without one.`
|
|
6635
|
+
: reason.reason === 'no-address'
|
|
6636
|
+
? 'None. A connection check needs the full https address of the service, and this tool’s source doesn’t name one. You can still create the tool and use it without one.'
|
|
6637
|
+
: '';
|
|
6524
6638
|
const checkLine = check
|
|
6525
6639
|
? `<dd>${escapeHtml(check.describe || check.command)}</dd>`
|
|
6526
|
-
:
|
|
6527
|
-
|
|
6640
|
+
: unavailableLine
|
|
6641
|
+
? `<dd class="graft-identity-prose">${unavailableLine}</dd>`
|
|
6642
|
+
: `<dd>None yet${candidates.length ? '' : ' — no command can be used for one. You can still connect without a check.'}</dd>`;
|
|
6643
|
+
// The button only where a check can really be added: never beside a sentence saying it can't.
|
|
6644
|
+
const add = !check && !unavailableLine && candidates.length
|
|
6528
6645
|
? '<button type="button" class="graft-verify-button" id="graft-add-check" data-command-id="shell.graft-add-check" aria-expanded="false" aria-controls="graft-check-picker">Add a connection check</button>'
|
|
6529
6646
|
+ '<div id="graft-check-picker" class="graft-check-picker" hidden></div>'
|
|
6530
6647
|
: '';
|
|
@@ -6799,6 +6916,9 @@
|
|
|
6799
6916
|
const body = { stagedRef: graftState.stagedRef };
|
|
6800
6917
|
if (force) body.force = true;
|
|
6801
6918
|
const res = await api('/api/graft/commit', { method: 'POST', body: JSON.stringify(body) });
|
|
6919
|
+
// #2128: the dialog no longer shows the review, so it no longer says "Review generated commands".
|
|
6920
|
+
document.getElementById('graft-title').textContent = 'Tool created';
|
|
6921
|
+
document.getElementById('graft-sub').textContent = 'You can use it in any workflow now.';
|
|
6802
6922
|
graftFill(graftBodyEl(), `<div class="graft-success"><div class="gs-icon">⊕</div><div class="gs-msg" id="graft-success-msg" tabindex="-1">Tool created — now in the Tools library as <code>${escapeHtml(res.agentId)}</code>.</div></div>`);
|
|
6803
6923
|
const nextSteps = graftSuccessActions(graftState.preview, res.agentId);
|
|
6804
6924
|
if (nextSteps) graftBodyEl().append(nextSteps);
|
|
@@ -6842,10 +6962,85 @@
|
|
|
6842
6962
|
}
|
|
6843
6963
|
|
|
6844
6964
|
$graftBack.onclick = () => { graftGeneration += 1; clearGraftInstructorNote(); if (graftState.onBack) graftState.onBack(); };
|
|
6845
|
-
|
|
6965
|
+
// #2155: Cancel and Escape both put the person back where they opened Build a tool from — the Tools library
|
|
6966
|
+
// (reopened, on its Graft button) or the control that opened it — instead of dropping focus on the page.
|
|
6967
|
+
function returnFromGraft() {
|
|
6968
|
+
const opener = graftOpener;
|
|
6969
|
+
graftOpener = null;
|
|
6970
|
+
if (opener?.id === 'lib-graft' && typeof openLibrary === 'function') {
|
|
6971
|
+
openLibrary();
|
|
6972
|
+
// After the library's own tab switch, which moves focus to its search box on the next task.
|
|
6973
|
+
setTimeout(() => document.getElementById('lib-graft')?.focus(), 0);
|
|
6974
|
+
return;
|
|
6975
|
+
}
|
|
6976
|
+
if (opener?.isConnected && opener.getClientRects().length > 0) { opener.focus(); if (document.activeElement === opener) return; }
|
|
6977
|
+
// The opener is gone or hidden (the closed ≡ menu, a Discover dialog that closed to hand over): the dialog still
|
|
6978
|
+
// open underneath, if any, gets focus; otherwise the menu button, so focus never drops to the page.
|
|
6979
|
+
const underneath = Array.from(document.querySelectorAll('.modal-backdrop.show')).find((el) => el !== $graftModal);
|
|
6980
|
+
const candidates = underneath ? Array.from(underneath.querySelectorAll(
|
|
6981
|
+
'button, input, select, textarea, a[href], summary, [contenteditable]:not([contenteditable="false"]), audio[controls], video[controls], [tabindex]',
|
|
6982
|
+
)).filter((el) => !el.disabled && el.getAttribute('tabindex') !== '-1' && !el.hidden && el.getClientRects().length > 0
|
|
6983
|
+
&& getComputedStyle(el).visibility !== 'hidden') : [];
|
|
6984
|
+
// The first control that really takes focus; if none does, the menu button.
|
|
6985
|
+
for (const el of candidates) { el.focus(); if (document.activeElement === el) return; }
|
|
6986
|
+
document.getElementById('menu-btn')?.focus();
|
|
6987
|
+
}
|
|
6988
|
+
function dismissGraftModal() { graftGeneration += 1; closeGraftModal(); returnFromGraft(); }
|
|
6989
|
+
$graftCancel.onclick = dismissGraftModal;
|
|
6990
|
+
document.addEventListener('keydown', (e) => {
|
|
6991
|
+
if (e.key !== 'Escape' || !$graftModal.classList.contains('show')) return;
|
|
6992
|
+
// Another dialog or the reconnect / start-up screen shown over it owns Escape; so does a combobox inside it.
|
|
6993
|
+
if (graftCovered() || e.defaultPrevented) return;
|
|
6994
|
+
const active = document.activeElement;
|
|
6995
|
+
if (active && active !== document.body && !$graftModal.contains(active)
|
|
6996
|
+
&& active.closest('[role="dialog"], [role="alertdialog"]')) return;
|
|
6997
|
+
// While a step cannot be cancelled (Cancel is disabled mid-commit), Escape does nothing either.
|
|
6998
|
+
if ($graftCancel.disabled) return;
|
|
6999
|
+
e.preventDefault();
|
|
7000
|
+
e.stopPropagation();
|
|
7001
|
+
dismissGraftModal();
|
|
7002
|
+
});
|
|
6846
7003
|
$graftPrimary.onclick = () => { if (graftState.onPrimary) graftState.onPrimary(); };
|
|
6847
7004
|
onBackdropDismiss($graftModal, closeGraftModal, () => !$graftCancel.disabled);
|
|
6848
7005
|
|
|
7006
|
+
// #2128: keep keyboard focus inside the open Build a tool dialog. Tab from the last control goes to the
|
|
7007
|
+
// first (Shift+Tab the other way), and a Tab pressed while focus is outside it (fallen to the page after
|
|
7008
|
+
// a rebuild) comes back in. Another dialog, or the reconnect / AWARE start-up screen, shown with it keeps
|
|
7009
|
+
// the keyboard — even when focus sits on the page rather than inside it.
|
|
7010
|
+
const graftFocusable = () => Array.from($graftModal.querySelectorAll(
|
|
7011
|
+
'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])',
|
|
7012
|
+
)).filter((el) => !el.hidden && el.getClientRects().length > 0);
|
|
7013
|
+
const GRAFT_COVERS = '#server-offline-overlay, #aware-bootstrap-overlay, .modal-backdrop.show';
|
|
7014
|
+
const graftCovered = () => Array.from(document.querySelectorAll(GRAFT_COVERS))
|
|
7015
|
+
.some((el) => el !== $graftModal && !el.hidden && el.getClientRects().length > 0);
|
|
7016
|
+
// Focus lands on the first control of the step's body (the source field, a check), never a footer button: Enter on
|
|
7017
|
+
// a focused Cancel would throw the inspected source away. A step with nothing to fill lands on its title, which
|
|
7018
|
+
// a screen reader announces and from which Tab reaches the step's controls.
|
|
7019
|
+
function graftLandFocus() {
|
|
7020
|
+
const first = graftFocusable().find((el) => el.closest('#graft-body'));
|
|
7021
|
+
if (first) first.focus(); else (document.getElementById('graft-title') ?? $graftDialog)?.focus();
|
|
7022
|
+
}
|
|
7023
|
+
document.addEventListener('keydown', (e) => {
|
|
7024
|
+
if (e.key !== 'Tab' || !$graftModal.classList.contains('show')) return;
|
|
7025
|
+
const active = document.activeElement;
|
|
7026
|
+
const otherDialog = active && active !== document.body && !$graftModal.contains(active)
|
|
7027
|
+
&& active.closest(`${GRAFT_COVERS}, [role="dialog"], [role="alertdialog"]`);
|
|
7028
|
+
if (otherDialog || graftCovered()) return;
|
|
7029
|
+
const controls = graftFocusable();
|
|
7030
|
+
if (!controls.length) { e.preventDefault(); $graftDialog?.focus(); return; }
|
|
7031
|
+
const first = controls[0];
|
|
7032
|
+
const last = controls[controls.length - 1];
|
|
7033
|
+
const inside = $graftModal.contains(active);
|
|
7034
|
+
// From a focused non-control inside it (the title, the dialog, a success message) Shift+Tab would walk out.
|
|
7035
|
+
if (e.shiftKey && (!inside || active === first || !controls.includes(active))) {
|
|
7036
|
+
e.preventDefault();
|
|
7037
|
+
last.focus();
|
|
7038
|
+
} else if (!e.shiftKey && (!inside || active === last)) {
|
|
7039
|
+
e.preventDefault();
|
|
7040
|
+
first.focus();
|
|
7041
|
+
}
|
|
7042
|
+
});
|
|
7043
|
+
|
|
6849
7044
|
// Secondary entry: "⊕ Graft new agent" inside the Agents Library modal.
|
|
6850
7045
|
const $libGraft = document.getElementById('lib-graft');
|
|
6851
7046
|
if ($libGraft) $libGraft.onclick = () => { hideModal($libModal); openGraftModal(); };
|
|
@@ -8730,11 +8925,17 @@
|
|
|
8730
8925
|
// person saw nothing — the node stayed "running".)
|
|
8731
8926
|
const msg = e && e.message ? e.message : String(e);
|
|
8732
8927
|
// #1998: AWARE refused before anything started (an approval it will not run): no node is "running".
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8928
|
+
// #2123: so did FloLess's own ownership admission (archived, edited, re-published while waiting): `notRun`.
|
|
8929
|
+
const notRun = !!(e && e.body && e.body.notRun);
|
|
8930
|
+
if (e && e.body && (e.body.refusal || notRun)) clearNodeStatus();
|
|
8931
|
+
// A not-run answer is already a whole sentence ("…, so it didn’t run. …"); "Run failed:" would misstate it.
|
|
8932
|
+
// Nothing failed — it was declined with a reason — so the toast is informational, not a warning.
|
|
8933
|
+
showToast(notRun ? runFailureMessage(msg) : (simulate ? 'Simulate failed' : 'Run failed') + ': ' + runFailureMessage(msg), notRun ? 'info' : 'warn');
|
|
8934
|
+
appendNarration(notRun
|
|
8935
|
+
? escapeHtml(runFailureMessage(msg))
|
|
8936
|
+
: simulate
|
|
8937
|
+
? `Simulate couldn't validate <code>${escapeHtml(currentId)}</code> — it stubs each node from its output-schema, but exec nodes have none, so the cross-node templates render undefined. Use <strong>▶ Run workflow</strong> for a live run against the host.`
|
|
8938
|
+
: `Run failed: ${escapeHtml(runFailureMessage(msg))}`);
|
|
8738
8939
|
}
|
|
8739
8940
|
}
|
|
8740
8941
|
} finally {
|
|
@@ -8936,7 +9137,7 @@
|
|
|
8936
9137
|
// have is the exact bug this reason exists to prevent.
|
|
8937
9138
|
return "Couldn't check whether Node.js is installed — the check didn't finish, which usually means the machine was busy. Nothing is necessarily missing; try again.";
|
|
8938
9139
|
case 'aware-version-required':
|
|
8939
|
-
return 'This FloLess release needs AWARE 0.
|
|
9140
|
+
return 'This FloLess release needs AWARE 0.157.0 or newer. Update AWARE, then try again.';
|
|
8940
9141
|
case 'offline':
|
|
8941
9142
|
return 'No network connection was detected. Connect to the internet, then try again.';
|
|
8942
9143
|
case 'smoke-failed':
|
|
@@ -9576,6 +9777,9 @@
|
|
|
9576
9777
|
if (window.flolessPanels) window.flolessPanels.refreshData();
|
|
9577
9778
|
} else if (m.type === 'routine-changed') {
|
|
9578
9779
|
loadRoutinesData();
|
|
9780
|
+
} else if (m.type === 'agent-changed') {
|
|
9781
|
+
// #2062: an agent was paused, resumed, archived or restored; an open page of it shows the new state.
|
|
9782
|
+
window.flolessAgents?.refreshAgent?.(m.agentId);
|
|
9579
9783
|
} else if (m.type === 'routine-run-started') {
|
|
9580
9784
|
runningRoutines.add(m.id);
|
|
9581
9785
|
if ($routinesModal.classList.contains('show')) renderRoutinesList();
|
|
@@ -9681,6 +9885,8 @@
|
|
|
9681
9885
|
// state.favorites holds the template list so app.js's category-suggestion code
|
|
9682
9886
|
// keeps working; the chip/star/library behaviour is overridden below.
|
|
9683
9887
|
let agentCatalog = [];
|
|
9888
|
+
// C12 (#1337): installed tools AWARE could not read ({ id }), shown in the library by name instead of left out.
|
|
9889
|
+
let agentUnreadable = [];
|
|
9684
9890
|
|
|
9685
9891
|
async function loadTemplates() {
|
|
9686
9892
|
const { templates } = await api('/api/templates');
|
|
@@ -10179,6 +10385,144 @@
|
|
|
10179
10385
|
// `chat-runtime-not-ready` so callers can show that reason instead of a generic failure. The
|
|
10180
10386
|
// caller's `isCancelled()` (the surface closed, or the Request changed) stops it before anything is
|
|
10181
10387
|
// started, with `chat-start-cancelled`, which callers drop silently.
|
|
10388
|
+
// ── #2061: Start in AI Chat on a project something else is changing ─────────────────────────────────────────────
|
|
10389
|
+
// Asked, never refused: wait (the start is tried again by itself — the same link and submission, so it can never send
|
|
10390
|
+
// twice), open the work holding the project, or stop it. The wait lives in this window only and says so.
|
|
10391
|
+
const REQUEST_START_BUSY_CODES = new Set(['chat-owner-busy', 'chat-project-run-busy', 'chat-project-knowledge-busy', 'chat-host-busy']);
|
|
10392
|
+
const REQUEST_START_WAIT_MS = 5000;
|
|
10393
|
+
const REQUEST_START_WAIT_CAP_MS = 30 * 60 * 1000;
|
|
10394
|
+
// #2106: the remedy every waiter gives once organizing has held the project for the whole wait (server copy:
|
|
10395
|
+
// knowledgeStuckRemedy in project-wait-clock.ts).
|
|
10396
|
+
const KNOWLEDGE_STUCK_REMEDY_START = 'If organizing has stopped, restart FloLess — that clears an organize that already finished. If it still shows as organizing after that, open a terminal outside FloLess (Claude Code or Codex) and ask it to check and recover the stuck knowledge organize for this project, then start this request again.';
|
|
10397
|
+
const requestStartWaits = new Map();
|
|
10398
|
+
|
|
10399
|
+
function busyChoiceDialog({ title, sub, actions, focusId }) {
|
|
10400
|
+
return new Promise((resolve) => {
|
|
10401
|
+
const previous = document.activeElement;
|
|
10402
|
+
const backdrop = document.createElement('div');
|
|
10403
|
+
backdrop.className = 'modal-backdrop show req-busy-dialog';
|
|
10404
|
+
backdrop.setAttribute('role', 'alertdialog'); backdrop.setAttribute('aria-modal', 'true'); backdrop.setAttribute('aria-labelledby', 'req-busy-title');
|
|
10405
|
+
const modal = document.createElement('div'); modal.className = 'modal';
|
|
10406
|
+
const head = document.createElement('div'); head.className = 'modal-title'; head.id = 'req-busy-title'; head.textContent = title;
|
|
10407
|
+
const body = document.createElement('div'); body.className = 'modal-sub'; body.textContent = sub;
|
|
10408
|
+
const row = document.createElement('div'); row.className = 'modal-actions';
|
|
10409
|
+
const finish = (value) => { backdrop.remove(); document.removeEventListener('keydown', onKey, true); if (previous?.isConnected) previous.focus(); resolve(value); };
|
|
10410
|
+
const onKey = (event) => { if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); finish(null); } };
|
|
10411
|
+
let focusTarget = null;
|
|
10412
|
+
for (const action of actions) {
|
|
10413
|
+
const control = document.createElement('button');
|
|
10414
|
+
control.type = 'button'; control.textContent = action.label; control.dataset.commandId = action.commandId;
|
|
10415
|
+
if (action.className) control.className = action.className;
|
|
10416
|
+
control.onclick = () => finish(action.id);
|
|
10417
|
+
if (action.commandId === focusId) focusTarget = control;
|
|
10418
|
+
row.append(control);
|
|
10419
|
+
}
|
|
10420
|
+
modal.append(head, body, row); backdrop.append(modal);
|
|
10421
|
+
backdrop.addEventListener('mousedown', (event) => { if (event.target === backdrop) finish(null); });
|
|
10422
|
+
document.addEventListener('keydown', onKey, true);
|
|
10423
|
+
document.body.append(backdrop);
|
|
10424
|
+
(focusTarget || row.querySelector('button'))?.focus();
|
|
10425
|
+
});
|
|
10426
|
+
}
|
|
10427
|
+
|
|
10428
|
+
/**
|
|
10429
|
+
* #2104: the design program a holder is using, by the name a person knows it ("Revit"), or `fallback` when FloLess
|
|
10430
|
+
* cannot name it (SketchUp/AutoCAD/ArchiCAD share one claim, and older records carry no key).
|
|
10431
|
+
*/
|
|
10432
|
+
function hostProgramLabel(holder, fallback) {
|
|
10433
|
+
const kind = String(holder?.hostKey || '').split(':', 1)[0];
|
|
10434
|
+
return ({ tekla: 'Tekla', revit: 'Revit', rhino: 'Rhino' })[kind] || fallback;
|
|
10435
|
+
}
|
|
10436
|
+
|
|
10437
|
+
async function askRequestStartBusy(request, provider, holder) {
|
|
10438
|
+
// #2106: FloLess organizing this project's knowledge — wait or open its Knowledge step; never stopped from here.
|
|
10439
|
+
if (holder.kind === 'knowledge') {
|
|
10440
|
+
const actions = [{ id: null, label: 'Cancel', commandId: 'shell.requests-start-busy-cancel' }];
|
|
10441
|
+
if (holder.projectId) actions.push({ id: 'open', label: 'Open it', commandId: 'shell.requests-start-busy-open' });
|
|
10442
|
+
actions.push({ id: 'wait', label: 'Wait and start when it’s free', commandId: 'shell.requests-start-busy-wait', className: 'primary' });
|
|
10443
|
+
const choice = await busyChoiceDialog({
|
|
10444
|
+
title: 'FloLess is organizing this project’s knowledge right now',
|
|
10445
|
+
sub: 'Nothing was started. Wait, and FloLess starts this request in AI Chat by itself when organizing finishes (keep FloLess open), or open the project’s Knowledge step to see it.',
|
|
10446
|
+
actions, focusId: 'shell.requests-start-busy-wait',
|
|
10447
|
+
});
|
|
10448
|
+
if (choice === 'open') await openProjectWaitHolder({ projectWait: { holder } });
|
|
10449
|
+
else if (choice === 'wait') {
|
|
10450
|
+
waitToStartRequestChat(request, provider, 'knowledge organizing', 'the project', {
|
|
10451
|
+
waiting: 'Waiting for FloLess to finish organizing this project’s knowledge. This request starts in AI Chat by itself when it’s done.',
|
|
10452
|
+
toast: 'Waiting for FloLess to finish organizing this project’s knowledge — this request starts in AI Chat by itself.',
|
|
10453
|
+
cap: `FloLess has been organizing this project’s knowledge for over 30 minutes, so this request was not started. ${KNOWLEDGE_STUCK_REMEDY_START}`,
|
|
10454
|
+
started: 'Organizing finished — this request started in AI Chat.',
|
|
10455
|
+
});
|
|
10456
|
+
}
|
|
10457
|
+
return;
|
|
10458
|
+
}
|
|
10459
|
+
const who = holder.kind === 'chat' ? `“${holder.title || 'another AI Chat conversation'}”` : (holder.title || 'another background request');
|
|
10460
|
+
const canAct = holder.kind === 'chat' ? Boolean(holder.owner && holder.chatId) : Boolean(holder.requestId);
|
|
10461
|
+
const actions = [{ id: null, label: 'Cancel', commandId: 'shell.requests-start-busy-cancel' }];
|
|
10462
|
+
if (canAct) actions.push({ id: 'open', label: 'Open it', commandId: 'shell.requests-start-busy-open' });
|
|
10463
|
+
if (canAct) actions.push({ id: 'stop', label: 'Stop it', commandId: 'shell.requests-start-busy-stop', className: 'req-busy-stop' });
|
|
10464
|
+
actions.push({ id: 'wait', label: 'Wait and start when it’s free', commandId: 'shell.requests-start-busy-wait', className: 'primary' });
|
|
10465
|
+
const choice = await busyChoiceDialog({
|
|
10466
|
+
// A holder of the same design program (reason 'host') is not changing this project — say what it is doing.
|
|
10467
|
+
title: holder.reason === 'host' ? `${who} is using ${hostProgramLabel(holder, 'the same design program')} on this computer right now` : `${who} is changing this project right now`,
|
|
10468
|
+
sub: `Nothing was started. Wait, and FloLess starts this request in AI Chat by itself when ${holder.reason === 'host' ? hostProgramLabel(holder, 'the design program') : 'the project'} is free (keep FloLess open), or open or stop that work.`,
|
|
10469
|
+
actions, focusId: 'shell.requests-start-busy-wait',
|
|
10470
|
+
});
|
|
10471
|
+
if (choice === 'open') {
|
|
10472
|
+
if (holder.kind === 'chat') await openProjectWaitHolder({ projectWait: { holder } });
|
|
10473
|
+
else await openRequests(holder.requestId);
|
|
10474
|
+
return;
|
|
10475
|
+
}
|
|
10476
|
+
if (choice === 'stop') {
|
|
10477
|
+
try {
|
|
10478
|
+
if (holder.kind === 'chat') {
|
|
10479
|
+
await api(`/api/chat/conversations/${encodeURIComponent(holder.chatId)}/stop`, { method: 'POST', body: JSON.stringify({ owner: holder.owner, expectTurnId: holder.turnId || undefined }) });
|
|
10480
|
+
} else {
|
|
10481
|
+
await api(`/api/requests/${encodeURIComponent(holder.requestId)}/run/stop`, { method: 'POST', body: JSON.stringify(holder.leaseId ? { expectLeaseId: holder.leaseId } : {}) });
|
|
10482
|
+
}
|
|
10483
|
+
} catch (error) {
|
|
10484
|
+
if (error?.body?.code !== 'stop-stale') console.warn('[requests] could not stop the work holding the project:', error);
|
|
10485
|
+
showToast(error?.body?.code === 'stop-stale' ? 'That work had already finished, so nothing was stopped.' : 'FloLess couldn’t stop that work. This request waits for it instead.', 'warn');
|
|
10486
|
+
}
|
|
10487
|
+
}
|
|
10488
|
+
if (choice === 'stop' || choice === 'wait') waitToStartRequestChat(request, provider, who, holder.reason === 'host' ? hostProgramLabel(holder, 'the design program') : 'the project');
|
|
10489
|
+
}
|
|
10490
|
+
|
|
10491
|
+
// `copy` (#2106) replaces the sentences for work that is not "someone changing the project" — knowledge organizing.
|
|
10492
|
+
function waitToStartRequestChat(request, provider, who, what = 'the project', copy = null) {
|
|
10493
|
+
if (requestStartWaits.has(request.id)) return;
|
|
10494
|
+
const since = Date.now();
|
|
10495
|
+
const status = () => document.getElementById('requests-action-status');
|
|
10496
|
+
const say = (text) => { const node = status(); if (node) node.textContent = text; };
|
|
10497
|
+
say(copy?.waiting ?? `Waiting for ${who} to finish. This request starts in AI Chat by itself when ${what} is free.`);
|
|
10498
|
+
showToast(copy?.toast ?? `Waiting for ${who} to finish — this request starts in AI Chat by itself.`, 'ok');
|
|
10499
|
+
const tick = async () => {
|
|
10500
|
+
if (!requestStartWaits.has(request.id)) return;
|
|
10501
|
+
if (Date.now() - since >= REQUEST_START_WAIT_CAP_MS) {
|
|
10502
|
+
requestStartWaits.delete(request.id);
|
|
10503
|
+
showToast(copy?.cap ?? `Still waiting for ${who} after 30 minutes, so this request was not started. Start it again when that work is done.`, 'warn', { persistent: true });
|
|
10504
|
+
return;
|
|
10505
|
+
}
|
|
10506
|
+
try {
|
|
10507
|
+
await startRequestChatWithSetup(request.id, provider, 'start');
|
|
10508
|
+
requestStartWaits.delete(request.id);
|
|
10509
|
+
say('');
|
|
10510
|
+
showToast(copy?.started ?? `${what === 'the project' ? 'The project' : what === 'the design program' ? 'The design program' : what} is free — this request started in AI Chat.`, 'ok');
|
|
10511
|
+
await loadRequests(); renderRequests();
|
|
10512
|
+
} catch (error) {
|
|
10513
|
+
if (REQUEST_START_BUSY_CODES.has(String(error?.code || ''))) { requestStartWaits.set(request.id, setTimeout(tick, REQUEST_START_WAIT_MS)); return; }
|
|
10514
|
+
requestStartWaits.delete(request.id);
|
|
10515
|
+
// Refused for another reason once the project was free: say why, exactly as the other start surfaces do.
|
|
10516
|
+
const notReady = error?.code === 'chat-runtime-not-ready';
|
|
10517
|
+
const explained = notReady ? '' : chatStartErrorText(error);
|
|
10518
|
+
if (notReady) showToast(error.message, 'warn');
|
|
10519
|
+
else reportChatStartErr(error);
|
|
10520
|
+
say(notReady ? error.message : explained || `Couldn’t start ${requestLabel(request)} in AI Chat. Try again.`);
|
|
10521
|
+
}
|
|
10522
|
+
};
|
|
10523
|
+
requestStartWaits.set(request.id, setTimeout(tick, REQUEST_START_WAIT_MS));
|
|
10524
|
+
}
|
|
10525
|
+
|
|
10182
10526
|
async function startRequestChatWithSetup(requestId, provider, mode, { onSetup, isCancelled = () => false } = {}) {
|
|
10183
10527
|
if (typeof window.flolessChat?.startRequest !== 'function') throw new Error('AI Chat is still starting. Try again in a moment.');
|
|
10184
10528
|
if (mode === 'start') {
|
|
@@ -10383,13 +10727,109 @@
|
|
|
10383
10727
|
</div>`;
|
|
10384
10728
|
}
|
|
10385
10729
|
|
|
10730
|
+
/**
|
|
10731
|
+
* #2061: a background request waiting for other work to finish changing its project, or one that stopped waiting
|
|
10732
|
+
* and needs the person. The server writes both sentences' facts; the row names who holds the project and opens it.
|
|
10733
|
+
*/
|
|
10734
|
+
function projectWaitHtml(r, commandInstance) {
|
|
10735
|
+
const wait = r.projectWait;
|
|
10736
|
+
if (!wait || (wait.state !== 'waiting' && wait.state !== 'needs-you')) return '';
|
|
10737
|
+
const holder = wait.holder || {};
|
|
10738
|
+
if (holder.kind === 'knowledge') return knowledgeWaitHtml(r, wait, holder, commandInstance);
|
|
10739
|
+
const title = String(holder.title || (holder.kind === 'chat' ? 'another AI Chat conversation' : 'another background request'));
|
|
10740
|
+
// A request's name carries its own words in quotes ("the background request “…”"); shortening it must not lose the
|
|
10741
|
+
// closing quote, or the sentence after it reads as part of the request's words. A name that is not cut is left as is.
|
|
10742
|
+
const cut = title.length > 48 ? `${title.slice(0, 45).trimEnd()}…` : null;
|
|
10743
|
+
const quoteLost = cut !== null && title.endsWith('”') && (cut.match(/“/g) || []).length > (cut.match(/”/g) || []).length;
|
|
10744
|
+
const short = cut === null ? title : quoteLost ? `${cut}”` : cut;
|
|
10745
|
+
const who = holder.kind === 'chat' ? `“${short}”` : short;
|
|
10746
|
+
const target = String(wait.target?.label || 'this project');
|
|
10747
|
+
const canOpen = holder.kind === 'chat' ? Boolean(holder.chatId && holder.owner) : Boolean(holder.requestId);
|
|
10748
|
+
const open = canOpen
|
|
10749
|
+
? `<button type="button" class="req-wait-open" data-id="${escapeAttr(r.id)}" data-command-id="shell.requests-wait-open#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(commandInstance)}"${title !== short ? ` data-tip="${escapeAttr(title)}"` : ''}>${holder.kind === 'chat' ? 'Open that conversation' : 'Go to that request'}</button>`
|
|
10750
|
+
: '';
|
|
10751
|
+
const waiting = wait.state === 'waiting';
|
|
10752
|
+
// A holder that stopped to ask a question keeps its folder until it is answered or stopped — say so, or the wait
|
|
10753
|
+
// reads as if it will end by itself.
|
|
10754
|
+
// #2103: a holder of the same design program on this computer is not changing this project — say what it is doing.
|
|
10755
|
+
const host = holder.reason === 'host';
|
|
10756
|
+
// #2103: nothing is known to hold it yet — FloLess's own check of the design program stayed busy, and is tried again.
|
|
10757
|
+
const checking = holder.kind === 'check';
|
|
10758
|
+
const note = waiting
|
|
10759
|
+
? (checking
|
|
10760
|
+
? 'FloLess couldn’t yet check whether the design program this request uses is free. It keeps checking, and this starts by itself when the program is free.'
|
|
10761
|
+
: holder.needsAnswer
|
|
10762
|
+
? `Waiting for ${who}, which needs your answer before ${host ? hostProgramLabel(holder, 'the design program') : target} is free. Answer it or stop it, and this starts by itself.`
|
|
10763
|
+
: host
|
|
10764
|
+
? `Waiting for ${who}, which is using ${hostProgramLabel(holder, 'the same design program')} on this computer right now. This starts by itself when it’s done.`
|
|
10765
|
+
: `Waiting for ${who} to finish changing ${target}. This starts by itself when it’s done.`)
|
|
10766
|
+
: String(wait.message || `This request stopped waiting for ${target}. Press ▶ to run it again.`);
|
|
10767
|
+
return `
|
|
10768
|
+
<div class="req-run-status req-wait" role="status" aria-live="polite">
|
|
10769
|
+
<div class="req-run-head">
|
|
10770
|
+
<span class="req-run-badge req-run-badge-${waiting ? 'muted' : 'warn'}">${waiting ? 'Waiting' : 'Needs you'}</span>
|
|
10771
|
+
</div>
|
|
10772
|
+
<p class="req-run-note">${escapeHtml(note)}</p>
|
|
10773
|
+
${open ? `<div class="req-wait-actions">${open}</div>` : ''}
|
|
10774
|
+
</div>`;
|
|
10775
|
+
}
|
|
10776
|
+
|
|
10777
|
+
/** #2106: a background request waiting for FloLess to finish organizing its project's knowledge (no Stop: never a run). */
|
|
10778
|
+
function knowledgeWaitHtml(r, wait, holder, commandInstance) {
|
|
10779
|
+
const target = String(wait.target?.label || 'this project');
|
|
10780
|
+
const waiting = wait.state === 'waiting';
|
|
10781
|
+
const note = waiting
|
|
10782
|
+
? `Waiting for FloLess to finish organizing ${target}’s knowledge. This starts by itself when it’s done.`
|
|
10783
|
+
: String(wait.message || `This request stopped waiting for ${target}. Press ▶ to run it again.`);
|
|
10784
|
+
const open = holder.projectId
|
|
10785
|
+
? `<button type="button" class="req-wait-open" data-id="${escapeAttr(r.id)}" data-command-id="shell.requests-wait-open#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(commandInstance)}">Open its Knowledge step</button>`
|
|
10786
|
+
: '';
|
|
10787
|
+
return `
|
|
10788
|
+
<div class="req-run-status req-wait" role="status" aria-live="polite">
|
|
10789
|
+
<div class="req-run-head">
|
|
10790
|
+
<span class="req-run-badge req-run-badge-${waiting ? 'muted' : 'warn'}">${waiting ? 'Waiting' : 'Needs you'}</span>
|
|
10791
|
+
</div>
|
|
10792
|
+
<p class="req-run-note">${escapeHtml(note)}</p>
|
|
10793
|
+
${open ? `<div class="req-wait-actions">${open}</div>` : ''}
|
|
10794
|
+
</div>`;
|
|
10795
|
+
}
|
|
10796
|
+
|
|
10797
|
+
/** #2106: a project's Knowledge step. A missing Workspaces bridge is said, never a silent no-op. */
|
|
10798
|
+
async function openKnowledgeStepOf(projectId) {
|
|
10799
|
+
const open = window.flolessWorkspaces?.openKnowledgeStep;
|
|
10800
|
+
if (typeof open !== 'function') throw new Error('FloLess couldn’t open that project’s Knowledge step. Open it from Workspaces.');
|
|
10801
|
+
await open(projectId);
|
|
10802
|
+
}
|
|
10803
|
+
|
|
10804
|
+
/** #2061: show the work a waiting request is waiting for — its conversation, or its row in Requests. */
|
|
10805
|
+
async function openProjectWaitHolder(req) {
|
|
10806
|
+
const holder = req?.projectWait?.holder;
|
|
10807
|
+
if (!holder) return;
|
|
10808
|
+
if (holder.kind === 'knowledge') {
|
|
10809
|
+
// #2106: the project's Knowledge step, where its organizing shows.
|
|
10810
|
+
try { await openKnowledgeStepOf(holder.projectId); }
|
|
10811
|
+
catch (error) { showToast(error?.message || 'FloLess couldn’t open that project’s Knowledge step. Open it from Workspaces.', 'warn'); }
|
|
10812
|
+
return;
|
|
10813
|
+
}
|
|
10814
|
+
if (holder.kind === 'chat' && holder.chatId && holder.owner && typeof window.flolessChat?.openConversationIn === 'function') {
|
|
10815
|
+
const opened = await window.flolessChat.openConversationIn({ owner: holder.owner }, holder.chatId).catch(() => false);
|
|
10816
|
+
if (!opened) showToast('FloLess couldn’t open that conversation. It may have finished or moved; check AI Chat.', 'warn');
|
|
10817
|
+
return;
|
|
10818
|
+
}
|
|
10819
|
+
if (holder.kind !== 'chat' && holder.requestId) await openRequests(holder.requestId);
|
|
10820
|
+
}
|
|
10821
|
+
|
|
10386
10822
|
// Start a run. `runtime` is the §E4 per-run override — omitted, the server resolves the default.
|
|
10387
10823
|
async function runRequestHeadless(req, runtime) {
|
|
10388
10824
|
try {
|
|
10389
10825
|
const res = await api(`/api/requests/${encodeURIComponent(req.id)}/run`, {
|
|
10390
10826
|
method: 'POST', body: JSON.stringify(runtime ? { runtime } : {}),
|
|
10391
10827
|
});
|
|
10392
|
-
|
|
10828
|
+
// #2061: the project is busy; the request waits and starts by itself. The row says who it is waiting for.
|
|
10829
|
+
// #2103: a wait for the design program (Tekla, Revit…) another piece of work is using says so, not "the project".
|
|
10830
|
+
if (res && res.waiting && res.projectWait?.holder?.kind === 'check') showToast('FloLess is checking whether the design program is free — this request starts by itself when it is.', 'ok');
|
|
10831
|
+
else if (res && res.waiting) showToast(`Waiting for ${res.projectWait?.holder?.reason === 'host' ? hostProgramLabel(res.projectWait.holder, 'the design program') : 'the project'} to be free — this request starts by itself. The row shows what it’s waiting for.`, 'ok');
|
|
10832
|
+
else showToast(`Running in ${runtimeLabel((res.run && res.run.runtime) || runtime)} — the row updates as it goes`, 'ok');
|
|
10393
10833
|
await loadRequests();
|
|
10394
10834
|
renderRequests();
|
|
10395
10835
|
return res;
|
|
@@ -10431,12 +10871,22 @@
|
|
|
10431
10871
|
}
|
|
10432
10872
|
|
|
10433
10873
|
async function stopRequestRun(req) {
|
|
10874
|
+
// #2061: "Stop waiting" names the wait shown, so it can never stop the run that wait just started.
|
|
10875
|
+
const waiting = req.projectWait?.state === 'waiting' && !requestHasActiveRun(req);
|
|
10434
10876
|
try {
|
|
10435
|
-
await api(`/api/requests/${encodeURIComponent(req.id)}/run/stop`, { method: 'POST'
|
|
10877
|
+
await api(`/api/requests/${encodeURIComponent(req.id)}/run/stop`, { method: 'POST',
|
|
10878
|
+
...(waiting ? { body: JSON.stringify({ waitId: req.projectWait.waitId }) } : {}) });
|
|
10436
10879
|
await loadRequests();
|
|
10437
10880
|
renderRequests();
|
|
10438
10881
|
focusRequestContinuation(req.id);
|
|
10439
|
-
} catch (e) {
|
|
10882
|
+
} catch (e) {
|
|
10883
|
+
if (e?.body?.code === 'stop-stale') {
|
|
10884
|
+
showToast('This request had already stopped waiting, so nothing was stopped. The list now shows what it is doing.', 'ok');
|
|
10885
|
+
await loadRequests().catch(() => {}); renderRequests();
|
|
10886
|
+
return;
|
|
10887
|
+
}
|
|
10888
|
+
reportErr(e);
|
|
10889
|
+
}
|
|
10440
10890
|
}
|
|
10441
10891
|
|
|
10442
10892
|
/**
|
|
@@ -10907,6 +11357,197 @@
|
|
|
10907
11357
|
let wsRequestScope = null;
|
|
10908
11358
|
let requestScopeAll = false; // the scope tab: false = what's open, true = every queued request
|
|
10909
11359
|
let requestQuery = '';
|
|
11360
|
+
// #2060: Queued is the work waiting; Done lists the Requests that left the queue (finished, or cleared), so each one's
|
|
11361
|
+
// conversation stays reachable — and a background run's record with it. Nothing in Done starts, re-runs or approves.
|
|
11362
|
+
let requestViewMode = 'queued';
|
|
11363
|
+
let doneRequests = null; // null: not read yet
|
|
11364
|
+
let doneRequestsError = null;
|
|
11365
|
+
let doneRequestsUnreadable = 0;
|
|
11366
|
+
async function loadDoneRequests() {
|
|
11367
|
+
try {
|
|
11368
|
+
const body = await api('/api/requests/done', { signal: AbortSignal.timeout(30_000) });
|
|
11369
|
+
doneRequests = Array.isArray(body?.requests) ? body.requests : [];
|
|
11370
|
+
doneRequestsUnreadable = Number(body?.unreadable) || 0;
|
|
11371
|
+
doneRequestsError = null;
|
|
11372
|
+
} catch (error) {
|
|
11373
|
+
console.warn('floless: could not read the done requests', error);
|
|
11374
|
+
doneRequestsError = 'FloLess couldn’t read the done requests.';
|
|
11375
|
+
}
|
|
11376
|
+
}
|
|
11377
|
+
async function setRequestViewMode(mode) {
|
|
11378
|
+
const next = mode === 'done' ? 'done' : 'queued';
|
|
11379
|
+
if (next === requestViewMode) return;
|
|
11380
|
+
requestViewMode = next;
|
|
11381
|
+
renderRequests();
|
|
11382
|
+
if (next === 'done') { await loadDoneRequests(); if (requestViewMode === 'done') renderRequests(); }
|
|
11383
|
+
}
|
|
11384
|
+
// What a background run's outcome reads as in Done. Leaving the queue is not success: only `succeeded` says Finished.
|
|
11385
|
+
const DONE_RUN_WORDS = {
|
|
11386
|
+
succeeded: 'Finished', answered: 'Answered', 'needs-you': 'Stopped to ask you something', 'exited-unresolved': 'Ended without finishing',
|
|
11387
|
+
'contract-violation': 'Ended with a result FloLess couldn’t confirm', stopped: 'Stopped', interrupted: 'Interrupted', failed: 'Didn’t finish',
|
|
11388
|
+
queued: 'Still starting', running: 'Still running',
|
|
11389
|
+
};
|
|
11390
|
+
function doneRequestSearchText(r) {
|
|
11391
|
+
return [requestLabel(r), requestOwnerName(r), r.appId, r.project, r.summary].filter(Boolean).join(' ');
|
|
11392
|
+
}
|
|
11393
|
+
function doneRequestRowHtml(r, query) {
|
|
11394
|
+
const label = requestLabel(r);
|
|
11395
|
+
const owner = requestOwnerName(r);
|
|
11396
|
+
const left = r.removedAt ? new Date(r.removedAt) : null;
|
|
11397
|
+
const leftLabel = left && !isNaN(left) ? nowStamp(left) : '';
|
|
11398
|
+
const commandInstance = `${label}${owner ? ` for ${owner}` : ''}${leftLabel ? `, done ${leftLabel}` : ''}`;
|
|
11399
|
+
const badgeCls = r.type === 'guide' || r.type === 'new-workflow' || r.type === 'use-template' ? 'req-type' : 'req-type req-type-tweak';
|
|
11400
|
+
const run = r.run;
|
|
11401
|
+
const runWords = run ? (DONE_RUN_WORDS[run.state] || String(run.state || '').replace(/-/g, ' ')) : '';
|
|
11402
|
+
const reported = run ? (run.answer || run.question || run.lastOutput || '') : '';
|
|
11403
|
+
const runHtml = run
|
|
11404
|
+
? `<p class="req-run-note req-done-run">Background run · ${escapeHtml(runtimeLabel(run.runtime))} · ${escapeHtml(runWords)}</p>`
|
|
11405
|
+
+ `<details class="req-technical"><summary data-command-id="shell.requests-done-report#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(commandInstance)}">What the run reported</summary><div class="req-technical-body">${escapeHtml(reported || 'The run didn’t report anything.')}</div></details>`
|
|
11406
|
+
: '';
|
|
11407
|
+
const link = r.chatConversation || null;
|
|
11408
|
+
const unreadable = link?.chatState === 'unreadable';
|
|
11409
|
+
const linked = Boolean(link?.chatId) && !unreadable;
|
|
11410
|
+
const provider = preferredChatProvider();
|
|
11411
|
+
const inScope = Boolean(r.project || r.workflowId) && requestMatchesChatScope(r);
|
|
11412
|
+
const chatLabel = `${label}${owner ? ` for ${owner}` : ''}`;
|
|
11413
|
+
let action = '';
|
|
11414
|
+
if (provider && inScope) {
|
|
11415
|
+
action = `<button class="req-chat-action" data-done-chat="${linked ? 'open' : 'discuss'}" data-id="${escapeAttr(r.id)}" data-command-id="shell.requests-done-discuss#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(commandInstance)}" aria-label="${linked ? 'Open' : 'Discuss'} ${escapeAttr(chatLabel)} in AI Chat" data-tip="${linked ? 'Open this request’s conversation in AI Chat' : 'Start a conversation about this request in AI Chat. Nothing runs.'}">${linked ? 'Open AI Chat' : 'Discuss in AI Chat'}</button>`;
|
|
11416
|
+
} else if (provider && (r.project || r.workflowId)) {
|
|
11417
|
+
action = `<span class="req-chat-elsewhere" data-tip="Open ${escapeAttr(owner)} to open this request’s conversation">Open ${escapeHtml(owner)} for AI Chat</span>`;
|
|
11418
|
+
} else if (!provider) {
|
|
11419
|
+
action = '<span class="req-chat-elsewhere" data-tip="AI Chat needs Claude or Codex on this computer">AI Chat isn’t available</span>';
|
|
11420
|
+
}
|
|
11421
|
+
// "Unreadable" covers a damaged saved file but also a passing read failure, so Discuss stays offered (it may simply
|
|
11422
|
+
// work now) and the row says where a damaged conversation is repaired: AI Chat's list, where it can be discarded.
|
|
11423
|
+
const unreadableNote = unreadable
|
|
11424
|
+
? '<p class="req-run-note req-done-run">FloLess couldn’t open this request’s conversation just now. Try Discuss in AI Chat. If its saved file is damaged, AI Chat’s conversation list (☷) shows it with a way to discard it. After that, Discuss adds this request to the conversation open in AI Chat if it is idle, or starts a new one.</p>'
|
|
11425
|
+
: '';
|
|
11426
|
+
return `
|
|
11427
|
+
<div class="req-item req-done-item" data-id="${escapeAttr(r.id)}">
|
|
11428
|
+
<div class="req-info">
|
|
11429
|
+
<div class="req-head"><span class="${badgeCls}">${escapeHtml(label)}</span> ${owner ? `<span class="req-owner">${highlightQuery(owner, query)}</span>` : ''}${leftLabel ? `<span class="req-time" data-tip="Left the queue ${escapeAttr(leftLabel)}">${escapeHtml(leftLabel)}</span>` : ''}</div>
|
|
11430
|
+
<div class="req-instruction">${highlightQuery(r.summary || '', query) || 'This request kept no words to show.'}</div>
|
|
11431
|
+
${runHtml}${unreadableNote}
|
|
11432
|
+
</div>
|
|
11433
|
+
<div class="req-actions">${action}</div>
|
|
11434
|
+
</div>`;
|
|
11435
|
+
}
|
|
11436
|
+
/** Requests → Done: what left the queue, newest first. Read-only apart from opening or discussing a conversation. */
|
|
11437
|
+
function renderDoneRequests($list) {
|
|
11438
|
+
const $clear = document.getElementById('requests-clear');
|
|
11439
|
+
const $copy = document.getElementById('requests-copy');
|
|
11440
|
+
const $search = document.getElementById('requests-search');
|
|
11441
|
+
const $guidance = document.getElementById('requests-guidance');
|
|
11442
|
+
if ($clear) $clear.hidden = true;
|
|
11443
|
+
if ($copy) $copy.hidden = true;
|
|
11444
|
+
if ($guidance) $guidance.hidden = true;
|
|
11445
|
+
const all = doneRequests || [];
|
|
11446
|
+
if ($search) {
|
|
11447
|
+
$search.hidden = all.length < 2;
|
|
11448
|
+
if ($search.hidden && requestQuery) { requestQuery = ''; $search.value = ''; }
|
|
11449
|
+
}
|
|
11450
|
+
const query = requestQuery.trim();
|
|
11451
|
+
const scope = activeRequestScope();
|
|
11452
|
+
const inScope = visibleRequests(all, scope, '', doneRequestSearchText);
|
|
11453
|
+
const shown = visibleRequests(all, requestScopeAll ? null : scope, query, doneRequestSearchText);
|
|
11454
|
+
const $scope = document.getElementById('requests-scope');
|
|
11455
|
+
const $here = document.getElementById('requests-scope-here');
|
|
11456
|
+
const $all = document.getElementById('requests-scope-all');
|
|
11457
|
+
if ($scope) $scope.hidden = !scope || all.length === 0;
|
|
11458
|
+
if (scope && $here && $all) {
|
|
11459
|
+
const kind = scope.kind === 'project' ? 'project' : 'workflow';
|
|
11460
|
+
$here.innerHTML = `<span class="req-scope-name">${escapeHtml(scope.label)}</span><span class="req-scope-n">· ${inScope.length} done</span>`;
|
|
11461
|
+
$here.setAttribute('data-tip', `Only what was done for the ${kind} you have open — ${scope.label}`);
|
|
11462
|
+
$all.innerHTML = `<span class="req-scope-name">All requests</span><span class="req-scope-n">· ${all.length} done</span>`;
|
|
11463
|
+
$all.setAttribute('data-tip', 'Every done request, including other projects and workflows');
|
|
11464
|
+
$here.classList.toggle('active', !requestScopeAll);
|
|
11465
|
+
$here.setAttribute('aria-selected', String(!requestScopeAll));
|
|
11466
|
+
$all.classList.toggle('active', requestScopeAll);
|
|
11467
|
+
$all.setAttribute('aria-selected', String(requestScopeAll));
|
|
11468
|
+
}
|
|
11469
|
+
const skipped = doneRequestsUnreadable
|
|
11470
|
+
? `<p class="req-run-note req-done-skipped">${doneRequestsUnreadable} earlier request${doneRequestsUnreadable === 1 ? '' : 's'} couldn’t be read and ${doneRequestsUnreadable === 1 ? 'isn’t' : 'aren’t'} shown.</p>`
|
|
11471
|
+
: '';
|
|
11472
|
+
if (doneRequests === null && doneRequestsError) {
|
|
11473
|
+
paintRequestList($list, `<div class="empty-state">${escapeHtml(doneRequestsError)} <button type="button" class="req-showall" data-done-retry>Try again</button></div>`, query);
|
|
11474
|
+
} else if (doneRequests === null) {
|
|
11475
|
+
paintRequestList($list, '<div class="empty-state">Reading the done requests…</div>', query);
|
|
11476
|
+
} else if (shown.length === 0) {
|
|
11477
|
+
const msg = all.length === 0
|
|
11478
|
+
? 'Nothing done yet. Requests appear here once they leave the queue.'
|
|
11479
|
+
: query
|
|
11480
|
+
? `No done request matches “${escapeHtml(query)}”.${!requestScopeAll && inScope.length < all.length ? ' Try All to search everything.' : ''}`
|
|
11481
|
+
: `Nothing done for ${escapeHtml(scope ? scope.label : 'this')} yet — ${all.length} done elsewhere. <button type="button" class="req-showall">Show all</button>`;
|
|
11482
|
+
paintRequestList($list, `<div class="empty-state">${msg}</div>${skipped}`, query);
|
|
11483
|
+
} else {
|
|
11484
|
+
paintRequestList($list, `${doneRequestsError ? `<p class="req-run-note req-done-skipped">${escapeHtml(doneRequestsError)} Showing what was read earlier.</p>` : ''}${shown.map((r) => doneRequestRowHtml(r, query)).join('')}${skipped}`, query);
|
|
11485
|
+
}
|
|
11486
|
+
const $showAll = $list.querySelector('.req-showall:not([data-done-retry])');
|
|
11487
|
+
if ($showAll) $showAll.onclick = () => setRequestScopeAll(true);
|
|
11488
|
+
const $retry = $list.querySelector('[data-done-retry]');
|
|
11489
|
+
if ($retry) $retry.onclick = async () => { await loadDoneRequests(); renderRequests(); };
|
|
11490
|
+
$list.querySelectorAll('[data-done-chat]').forEach((button) => {
|
|
11491
|
+
button.onclick = async () => {
|
|
11492
|
+
const request = (doneRequests || []).find((candidate) => candidate?.id === button.dataset.id);
|
|
11493
|
+
const provider = preferredChatProvider();
|
|
11494
|
+
if (!request || !provider) return;
|
|
11495
|
+
const original = button.textContent;
|
|
11496
|
+
button.disabled = true;
|
|
11497
|
+
button.setAttribute('aria-busy', 'true');
|
|
11498
|
+
button.textContent = 'Opening…';
|
|
11499
|
+
const actionStatus = document.getElementById('requests-action-status');
|
|
11500
|
+
if (actionStatus) actionStatus.textContent = `Opening ${requestLabel(request)} for ${requestOwnerName(request)} in AI Chat.`;
|
|
11501
|
+
const requestsModal = document.getElementById('requests-modal');
|
|
11502
|
+
try {
|
|
11503
|
+
// Discuss, never Start: the server refuses to run a Request that left the queue.
|
|
11504
|
+
await startRequestChatWithSetup(request.id, provider, 'discuss', {
|
|
11505
|
+
isCancelled: () => !requestsModal?.classList.contains('show') || requestViewMode !== 'done',
|
|
11506
|
+
// FloLess is installing its own copy of this AI first (#1607): say so, as the queued rows do.
|
|
11507
|
+
onSetup: (status) => {
|
|
11508
|
+
const notice = window.flolessChat?.runtimeNotice?.(provider, status);
|
|
11509
|
+
if (actionStatus) actionStatus.textContent = notice?.body || `FloLess is setting up ${runtimeLabel(provider)} before it opens this request.`;
|
|
11510
|
+
},
|
|
11511
|
+
});
|
|
11512
|
+
closeRequests();
|
|
11513
|
+
} catch (error) {
|
|
11514
|
+
if (error?.code === 'chat-start-cancelled') return;
|
|
11515
|
+
// The same refusal handling as the queued rows' start surface (request-chat-start-eligibility.test.ts).
|
|
11516
|
+
const notReady = error?.code === 'chat-runtime-not-ready';
|
|
11517
|
+
const explained = notReady ? '' : chatStartErrorText(error);
|
|
11518
|
+
if (notReady) showToast(error.message, 'warn');
|
|
11519
|
+
else reportChatStartErr(error);
|
|
11520
|
+
if (actionStatus) actionStatus.textContent = notReady
|
|
11521
|
+
? error.message
|
|
11522
|
+
: explained || `Couldn’t open ${requestLabel(request)} in AI Chat. Try again.`;
|
|
11523
|
+
if (!button.isConnected) return;
|
|
11524
|
+
button.disabled = false;
|
|
11525
|
+
button.removeAttribute('aria-busy');
|
|
11526
|
+
button.textContent = original;
|
|
11527
|
+
button.focus();
|
|
11528
|
+
}
|
|
11529
|
+
};
|
|
11530
|
+
});
|
|
11531
|
+
}
|
|
11532
|
+
/** The Queued | Done switch, the sub-line and the footer note follow the view. */
|
|
11533
|
+
function paintRequestViewChrome() {
|
|
11534
|
+
const done = requestViewMode === 'done';
|
|
11535
|
+
for (const [id, mode] of [['requests-view-queued', 'queued'], ['requests-view-done', 'done']]) {
|
|
11536
|
+
const tab = document.getElementById(id);
|
|
11537
|
+
if (!tab) continue;
|
|
11538
|
+
tab.classList.toggle('active', requestViewMode === mode);
|
|
11539
|
+
tab.setAttribute('aria-selected', String(requestViewMode === mode));
|
|
11540
|
+
tab.tabIndex = requestViewMode === mode ? 0 : -1;
|
|
11541
|
+
}
|
|
11542
|
+
const $queued = document.getElementById('requests-view-queued');
|
|
11543
|
+
if ($queued) $queued.textContent = pendingRequests.length ? `Queued (${pendingRequests.length})` : 'Queued';
|
|
11544
|
+
const $sub = document.getElementById('requests-sub');
|
|
11545
|
+
if ($sub) $sub.textContent = done
|
|
11546
|
+
? 'Requests that left the queue in the last 30 days. Open their conversation or discuss them in AI Chat. Nothing here runs again.'
|
|
11547
|
+
: 'Start queued work in AI Chat or run it in the background with your terminal AI.';
|
|
11548
|
+
const $note = document.getElementById('requests-done-note');
|
|
11549
|
+
if ($note) $note.hidden = !done;
|
|
11550
|
+
}
|
|
10910
11551
|
let previousRequestCount = 0;
|
|
10911
11552
|
let previousRequestIds = null;
|
|
10912
11553
|
let reqPulseTimer = null;
|
|
@@ -10939,6 +11580,11 @@
|
|
|
10939
11580
|
const { requests, chatPublications = [] } = await api('/api/requests', { signal: AbortSignal.timeout(90_000) });
|
|
10940
11581
|
reconcileActiveInstructorRuns(requests, chatPublications);
|
|
10941
11582
|
pendingRequests = requests;
|
|
11583
|
+
// A Request leaving the queue arrives in Done: re-read it while Done is what the open window shows.
|
|
11584
|
+
// Not awaited: the queue's own update never waits on the Done read.
|
|
11585
|
+
if (requestViewMode === 'done' && document.getElementById('requests-modal')?.classList.contains('show')) {
|
|
11586
|
+
void loadDoneRequests().then(() => { if (requestViewMode === 'done') renderRequests(); });
|
|
11587
|
+
}
|
|
10942
11588
|
const nextPublishedChatIds = new Set(chatPublications.map((publication) => publication?.chatId).filter(Boolean));
|
|
10943
11589
|
const newlyPublishedHere = publishedAnswerChatIds !== null && chatPublications.some((publication) => {
|
|
10944
11590
|
if (!publication?.chatId || publishedAnswerChatIds.has(publication.chatId)) return false;
|
|
@@ -11898,6 +12544,8 @@
|
|
|
11898
12544
|
// A press still held inside the list: paint once it is released (see holdRequestListRepaints).
|
|
11899
12545
|
// Everything waits, not only the rows, so the bulk actions keep acting on what is on screen.
|
|
11900
12546
|
if ($list.__requestsHeld) { $list.__requestsOwed = true; return; }
|
|
12547
|
+
paintRequestViewChrome();
|
|
12548
|
+
if (requestViewMode === 'done') { renderDoneRequests($list); return; }
|
|
11901
12549
|
// Search is pointless over an empty queue, and over a single request it is just clutter.
|
|
11902
12550
|
// Drop the query WITH the box, and before anything is filtered by it: a hidden filter still
|
|
11903
12551
|
// filtering is how a list ends up inexplicably empty (the last two requests clear while a
|
|
@@ -12024,7 +12672,10 @@
|
|
|
12024
12672
|
// generic sentence is reserved for the types with no second surface, where "no recovery" is
|
|
12025
12673
|
// unambiguous — and the drawing read keeps saying what it already says, correctly.
|
|
12026
12674
|
const ownRecoverySurface = r.type === 'revision-read';
|
|
12027
|
-
|
|
12675
|
+
// #2061: waiting for another piece of work to finish changing this request's project. It holds the row like a run
|
|
12676
|
+
// (■ stops the wait), and nothing has started yet.
|
|
12677
|
+
const projectWaiting = !settledRevision && r.projectWait?.state === 'waiting';
|
|
12678
|
+
const inFlight = (!!run && (run.state === 'queued' || run.state === 'running')) || projectWaiting;
|
|
12028
12679
|
const desktopClaimed = !!(desktopHandoffs && desktopHandoffs.claim);
|
|
12029
12680
|
const lifecycleOwned = r.type === 'knowledge-organize';
|
|
12030
12681
|
const canClear = requestCanClear(r);
|
|
@@ -12035,6 +12686,8 @@
|
|
|
12035
12686
|
const discardQuestion = requestHasDiscardQuestion(r);
|
|
12036
12687
|
const del = lifecycleOwned
|
|
12037
12688
|
? '<span class="req-lifecycle" data-tip="This clears itself when your terminal AI finishes or fails the organize">finishing in your terminal</span>'
|
|
12689
|
+
: projectWaiting
|
|
12690
|
+
? '<span class="req-lifecycle" data-tip="Stop waiting first if you want to clear this request">waiting</span>'
|
|
12038
12691
|
: inFlight || desktopClaimed
|
|
12039
12692
|
? '<span class="req-lifecycle" data-tip="Stop the run if you need to pause it. Clear stays unavailable until the saved session is continued and finished">running</span>'
|
|
12040
12693
|
: !canClear && r.clearState === 'session-saved'
|
|
@@ -12054,7 +12707,9 @@
|
|
|
12054
12707
|
const canRunNow = headlessReady() && r.canRun && (!chatExecutionOwner || chatExecutionOwner === 'discussion')
|
|
12055
12708
|
&& (r.type !== 'revision-read' || r.status === 'pending')
|
|
12056
12709
|
&& !revisionReadHasTerminalOwner(r) && !inFlight && !desktopHandoffs && !resumeCommand;
|
|
12057
|
-
const runBtn =
|
|
12710
|
+
const runBtn = projectWaiting
|
|
12711
|
+
? `<button class="req-stop" data-id="${escapeAttr(r.id)}" data-command-id="shell.requests-stop-waiting#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(commandInstance)}" data-tip="Stop waiting" aria-label="Stop waiting">■</button>`
|
|
12712
|
+
: inFlight
|
|
12058
12713
|
? `<button class="req-stop" data-id="${escapeAttr(r.id)}" data-command-id="shell.requests-stop#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(commandInstance)}" data-tip="Stop this run" aria-label="Stop this run">■</button>`
|
|
12059
12714
|
: canRunNow && !filterGuide
|
|
12060
12715
|
? r.preparationRetryable
|
|
@@ -12088,6 +12743,7 @@
|
|
|
12088
12743
|
? `<div class="req-instruction req-summary">${highlightQuery(r.instructorContext.subject || 'Drawing Filter AI request', normalizedRequestQuery)}</div><p class="req-run-note">${escapeHtml(filterGuideRequestNote(r))}</p><details class="req-technical"><summary data-command-id="shell.requests-technical#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(commandInstance)}">Show detailed instructions</summary><div class="req-technical-body">${highlightQuery(instructionFor(r), normalizedRequestQuery)}</div></details>`
|
|
12089
12744
|
: `<div class="req-instruction">${highlightQuery(instructionFor(r), normalizedRequestQuery) || 'This request has no instructions to send. Remove it and create the request again.'}</div>`}
|
|
12090
12745
|
${r.snapshots && r.snapshots.length ? `<div class="req-thumbs">${r.snapshots.map((sp, i) => { const pdf = /\.pdf$/i.test(String(sp)); return `<button type="button" class="req-thumb" data-id="${escapeAttr(r.id)}" data-n="${i}" aria-label="View ${pdf ? 'PDF' : 'screenshot'} ${i + 1}">${pdf ? '<span class="req-thumb-pdf">PDF</span>' : `<img src="/api/requests/${encodeURIComponent(r.id)}/snapshot/${i}" alt="">`}</button>`; }).join('')}</div>` : ''}
|
|
12746
|
+
${settledRevision ? '' : projectWaitHtml(r, commandInstance)}
|
|
12091
12747
|
${runStatusHtml(run, resumeCommand, desktopHandoffs, r.id, commandInstance, ownRecoverySurface,
|
|
12092
12748
|
filterGuide
|
|
12093
12749
|
? (r.instructorContext.commandId === 'filter.ask-ai-change' ? 'change' : 'question') : null, r.filterAiNotStarted === true)}
|
|
@@ -12157,6 +12813,12 @@
|
|
|
12157
12813
|
closeRequests();
|
|
12158
12814
|
} catch (error) {
|
|
12159
12815
|
if (error?.code === 'chat-start-cancelled') return;
|
|
12816
|
+
// #2061: the project is busy — ask (wait and start by itself / open it / stop it), never only "failed".
|
|
12817
|
+
if (starting && REQUEST_START_BUSY_CODES.has(String(error?.code || '')) && error?.holder) {
|
|
12818
|
+
if (actionStatus) actionStatus.textContent = '';
|
|
12819
|
+
void askRequestStartBusy(request, provider, error.holder);
|
|
12820
|
+
return;
|
|
12821
|
+
}
|
|
12160
12822
|
const notReady = error?.code === 'chat-runtime-not-ready';
|
|
12161
12823
|
const explained = notReady ? '' : chatStartErrorText(error);
|
|
12162
12824
|
if (notReady) showToast(error.message, 'warn');
|
|
@@ -12185,6 +12847,12 @@
|
|
|
12185
12847
|
if (r) void runRequestHeadless(r);
|
|
12186
12848
|
};
|
|
12187
12849
|
});
|
|
12850
|
+
$list.querySelectorAll('.req-wait-open').forEach((b) => {
|
|
12851
|
+
b.onclick = () => {
|
|
12852
|
+
const r = pendingRequests.find((x) => x.id === b.dataset.id);
|
|
12853
|
+
if (r) void openProjectWaitHolder(r);
|
|
12854
|
+
};
|
|
12855
|
+
});
|
|
12188
12856
|
$list.querySelectorAll('.req-stop').forEach((b) => {
|
|
12189
12857
|
b.onclick = () => {
|
|
12190
12858
|
const r = pendingRequests.find((x) => x.id === b.dataset.id);
|
|
@@ -12377,6 +13045,7 @@
|
|
|
12377
13045
|
// previous visit would silently answer a different question than the one just asked.
|
|
12378
13046
|
requestScopeAll = false;
|
|
12379
13047
|
requestQuery = '';
|
|
13048
|
+
requestViewMode = 'queued';
|
|
12380
13049
|
const $search = document.getElementById('requests-search');
|
|
12381
13050
|
if ($search) $search.value = '';
|
|
12382
13051
|
const $requestsModal = document.getElementById('requests-modal');
|
|
@@ -12532,10 +13201,12 @@
|
|
|
12532
13201
|
|
|
12533
13202
|
// ── Agents library: real installed agents + their commands ───────────────────
|
|
12534
13203
|
async function loadAgentCatalog() {
|
|
12535
|
-
const { agents } = await api('/api/agents');
|
|
13204
|
+
const { agents, unreadable } = await api('/api/agents');
|
|
12536
13205
|
agentCatalog = agents;
|
|
13206
|
+
agentUnreadable = Array.isArray(unreadable) ? unreadable.filter((row) => row && typeof row.id === 'string') : [];
|
|
12537
13207
|
const $ac = document.getElementById('agents-count');
|
|
12538
|
-
|
|
13208
|
+
// A damaged tool is still installed: the count matches the cards the library shows.
|
|
13209
|
+
if ($ac) $ac.textContent = agents.length + agentUnreadable.length;
|
|
12539
13210
|
refreshAgentNotes();
|
|
12540
13211
|
}
|
|
12541
13212
|
|
|
@@ -12622,6 +13293,18 @@
|
|
|
12622
13293
|
renderLibrary = function renderLibraryReal() {
|
|
12623
13294
|
const q = ($libSearch.value || '').toLowerCase().trim();
|
|
12624
13295
|
const items = agentCatalog.filter((a) => !q || a.id.toLowerCase().includes(q) || (a.kind || '').toLowerCase().includes(q));
|
|
13296
|
+
const damaged = agentUnreadable.filter((a) => !q || a.id.toLowerCase().includes(q));
|
|
13297
|
+
// C12 (#1337): a tool AWARE could not read is named here with what to do, never silently left out of the list.
|
|
13298
|
+
const damagedHtml = damaged.map((a) => `
|
|
13299
|
+
<div class="lib-card lib-card-unreadable" data-agent-unreadable="${escapeAttr(a.id)}">
|
|
13300
|
+
<div class="lib-item">
|
|
13301
|
+
<div class="info">
|
|
13302
|
+
<div class="name">${escapeHtml(a.id)}</div>
|
|
13303
|
+
<div class="meta">Can’t be read</div>
|
|
13304
|
+
</div>
|
|
13305
|
+
</div>
|
|
13306
|
+
<p class="lib-update-error"><strong>FloLess couldn’t read this tool.</strong> Its files are damaged or incomplete, so workflows that use it can’t run. Install it again from the Available tab, or ask AI Chat to reinstall it.</p>
|
|
13307
|
+
</div>`).join('');
|
|
12625
13308
|
// Each agent is ONE grid cell: the card header + its (lazy) command list live
|
|
12626
13309
|
// in the same `.lib-card`, so expanding nests the commands directly under the
|
|
12627
13310
|
// picked card instead of scattering them into a neighbouring grid slot.
|
|
@@ -12656,7 +13339,8 @@
|
|
|
12656
13339
|
${failureHtml}
|
|
12657
13340
|
<div class="lib-commands" id="cmds-${id}" hidden></div>
|
|
12658
13341
|
</div>`;
|
|
12659
|
-
}).join('')
|
|
13342
|
+
}).join('');
|
|
13343
|
+
$libList.innerHTML = (damagedHtml + $libList.innerHTML) || '<div class="empty-state">No tools match.</div>';
|
|
12660
13344
|
$libList.querySelectorAll('[data-expand]').forEach((btn) => {
|
|
12661
13345
|
btn.onclick = () => expandAgent(btn.dataset.expand);
|
|
12662
13346
|
});
|
|
@@ -13939,6 +14623,8 @@
|
|
|
13939
14623
|
function lastRunTip(r) {
|
|
13940
14624
|
if (!r.lastRun) return 'Never run yet';
|
|
13941
14625
|
const lr = r.lastRun;
|
|
14626
|
+
// #2062: a fire missed while FloLess was closed — the server's sentence says it all ("Missed — FloLess wasn’t running at …").
|
|
14627
|
+
if (lr.status === 'skipped' && lr.missed && lr.reason) return lr.reason;
|
|
13942
14628
|
// #2035: an agent routine only starts the agent; how that run went is the agent run's own record.
|
|
13943
14629
|
if (r.agent) {
|
|
13944
14630
|
const when = absTime(lr.at);
|
|
@@ -14050,11 +14736,27 @@
|
|
|
14050
14736
|
const lives = run.targets.map((t) => t.live);
|
|
14051
14737
|
const declined = run.targets.reduce((sum, t) => sum + (t.declines ? t.declines.list.filter((d) => d.state === 'declined').length + t.declines.moreDeclined : 0), 0);
|
|
14052
14738
|
const tail = declined ? ` · ${declined} step${declined === 1 ? '' : 's'} declined — see Questions for you on the Agents page` : '';
|
|
14739
|
+
// #2122: every live state has a deliberate summary; only a run whose every part finished (or was skipped up front)
|
|
14740
|
+
// says Done, and a state this list does not know yet reads as needing a look — never as Done.
|
|
14741
|
+
// Most urgent first: the person is being asked something, then work still going, then work that stopped short.
|
|
14742
|
+
if (lives.some((l) => l === 'waiting-for-you')) return `Waiting for your approval on the Agents page${tail}`;
|
|
14053
14743
|
if (lives.some((l) => l === 'working' || l === 'starting' || l === 'waiting')) return `Running${tail}`;
|
|
14054
|
-
|
|
14744
|
+
// #2105: 'needs-you' — it waited the full time for busy work and stopped without changing anything.
|
|
14745
|
+
if (lives.some((l) => l === 'failed' || l === 'failed-reply' || l === 'uncertain' || l === 'needs-recovery' || l === 'needs-you' || l === 'unreadable')) return `Needs a look on the Agents page${tail}`;
|
|
14746
|
+
if (lives.some((l) => l === 'stopped')) return `Stopped before it finished${tail}`;
|
|
14747
|
+
if (lives.some((l) => l === 'archived')) return `Its conversation was archived${tail}`;
|
|
14748
|
+
if (lives.some((l) => l === 'stale')) return `Belongs to an earlier workspace folder${tail}`;
|
|
14749
|
+
if (!lives.every((l) => l === 'done' || l === 'skipped')) return `Needs a look on the Agents page${tail}`;
|
|
14750
|
+
if (lives.length && lives.every((l) => l === 'skipped')) return `Skipped — see the Agents page for why${tail}`;
|
|
14751
|
+
if (lives.some((l) => l === 'skipped')) return `Done, with some parts skipped — see the Agents page${tail}`;
|
|
14055
14752
|
return `Done${tail}`;
|
|
14056
14753
|
}
|
|
14057
14754
|
|
|
14755
|
+
/** #2122: only a run still going — or still asking the person — can change on its own, so only those are asked about again. */
|
|
14756
|
+
function agentRunStillGoing(summary) {
|
|
14757
|
+
return summary === '' || /^(Running|Waiting for your approval)/.test(summary);
|
|
14758
|
+
}
|
|
14759
|
+
|
|
14058
14760
|
async function refreshRoutineAgents() {
|
|
14059
14761
|
const agentsApi = window.flolessAgents;
|
|
14060
14762
|
if (!agentsApi?.list) return;
|
|
@@ -14086,7 +14788,7 @@
|
|
|
14086
14788
|
const viewerOpenForApp = currentId === r.workflow && $reportModal.classList.contains('show') && !reportRunning;
|
|
14087
14789
|
if (fired && viewerOpenForApp) {
|
|
14088
14790
|
showTriggerCollecting();
|
|
14089
|
-
} else if (viewerOpenForApp && (snapshot.state === 'error' || snapshot.state === 'stopped') && $reportOverlay.querySelector('.spinner')) {
|
|
14791
|
+
} else if (viewerOpenForApp && (snapshot.state === 'error' || snapshot.state === 'stopped') && $reportOverlay.querySelector('.flo-run, .spinner')) {
|
|
14090
14792
|
// The session ended before this fire produced a report — don't spin forever.
|
|
14091
14793
|
// Fall back to the last report if we have one, else an idle prompt.
|
|
14092
14794
|
clearTriggerCollecting();
|
|
@@ -14166,13 +14868,21 @@
|
|
|
14166
14868
|
// A trigger fired (new selection) but its report is still computing on the host.
|
|
14167
14869
|
// Show a spinner over the viewer — the previous report dims behind the overlay —
|
|
14168
14870
|
// until applyTriggerReport paints the fresh one. Built with DOM nodes (no
|
|
14169
|
-
// innerHTML);
|
|
14871
|
+
// innerHTML); shows the same running Flo as the manual run overlay.
|
|
14170
14872
|
function showTriggerCollecting() {
|
|
14171
14873
|
$reportOverlay.hidden = false;
|
|
14172
14874
|
$reportOverlay.replaceChildren();
|
|
14173
|
-
const sp = mkEl('div', 'spinner');
|
|
14174
14875
|
const msg = mkEl('div', null, 'New selection — collecting report…');
|
|
14175
|
-
$reportOverlay.append(
|
|
14876
|
+
$reportOverlay.append(runningFlo(), msg);
|
|
14877
|
+
}
|
|
14878
|
+
|
|
14879
|
+
// #2079: while a workflow runs for you, Flo works over the viewer, hat on, its light looping the ring. Plain
|
|
14880
|
+
// loading (a report section, a 3D view, a live session starting) keeps the plain .spinner ring.
|
|
14881
|
+
function runningFlo() {
|
|
14882
|
+
const host = mkEl('div', 'flo-run');
|
|
14883
|
+
if (typeof floAvatar === 'function') floAvatar(host, { size: 40, mood: 'working', hat: true });
|
|
14884
|
+
else host.classList.add('spinner');
|
|
14885
|
+
return host;
|
|
14176
14886
|
}
|
|
14177
14887
|
|
|
14178
14888
|
// The trigger session errored/stopped while a "collecting…" spinner was up (a
|
|
@@ -14222,10 +14932,18 @@
|
|
|
14222
14932
|
// never a dead end. Other failures are recoverable; the server returns them
|
|
14223
14933
|
// in-band, so a failed start is a viewer message + toast, not a console fault.
|
|
14224
14934
|
const blocked = !!(e.body && e.body.blocked);
|
|
14935
|
+
// #2123: FloLess declined before anything started (archived, edited, re-published) and said why in plain words.
|
|
14936
|
+
const notRun = !!(e.body && e.body.notRun && typeof e.body.error === 'string');
|
|
14225
14937
|
$reportShare.hidden = true; // the overlay is the primary content — nothing to share
|
|
14226
14938
|
$reportOverlay.hidden = false;
|
|
14227
14939
|
$reportOverlay.replaceChildren();
|
|
14228
|
-
if (
|
|
14940
|
+
if (notRun) {
|
|
14941
|
+
// The server's plain sentence, through the same mapping every other run answer gets.
|
|
14942
|
+
const sentence = runFailureMessage(e.body.error);
|
|
14943
|
+
$reportOverlay.append(mkEl('div', null, sentence));
|
|
14944
|
+
$reportSub.textContent = 'Nothing ran, so no report was made.';
|
|
14945
|
+
showToast(sentence, 'info');
|
|
14946
|
+
} else if (blocked) {
|
|
14229
14947
|
$reportOverlay.append(
|
|
14230
14948
|
mkEl('div', null, 'One live model, one watcher — a session is already watching this host.'),
|
|
14231
14949
|
mkEl('div', null, 'To run here, stop it first: open ⏱ Routines and disable the watcher, then click ▶ Run workflow.'),
|
|
@@ -14330,6 +15048,17 @@
|
|
|
14330
15048
|
}
|
|
14331
15049
|
}
|
|
14332
15050
|
|
|
15051
|
+
// #2062: a routine whose agent holds it says so where its next run time would be. Its own switch is untouched and
|
|
15052
|
+
// keeps working; a routine switched off or broken says that instead (its own state comes first).
|
|
15053
|
+
function routineHoldText(r) {
|
|
15054
|
+
if (!r.agent || !r.enabled || r.broken) return null;
|
|
15055
|
+
if (r.agentHold === 'paused') return { label: 'paused with the agent',
|
|
15056
|
+
tip: 'Its agent is paused, so this routine doesn’t start it. Resume the agent on the Agents page and this routine runs on its schedule again. Its own switch is unchanged.' };
|
|
15057
|
+
if (r.agentHold === 'archived') return { label: 'paused — agent archived',
|
|
15058
|
+
tip: 'Its agent is archived, so this routine doesn’t start it. Restore the agent on the Agents page and this routine runs on its schedule again.' };
|
|
15059
|
+
return null;
|
|
15060
|
+
}
|
|
15061
|
+
|
|
14333
15062
|
function renderRoutinesList() {
|
|
14334
15063
|
const $list = document.getElementById('routines-list');
|
|
14335
15064
|
const $quota = document.getElementById('rtn-quota');
|
|
@@ -14381,6 +15110,8 @@
|
|
|
14381
15110
|
: `<span class="rtn-status ${escapeAttr(r.lastRun ? ({ started: 'ok', starting: '' }[r.lastRun.status] ?? r.lastRun.status) : '')}" data-tip="${escapeAttr(lastRunTip(r))}"></span>`;
|
|
14382
15111
|
nextTip = r.nextFireAt ? `Next run: ${absTime(r.nextFireAt)}` : (r.broken ? r.broken.reason : r.enabled ? 'Not scheduled' : 'Disabled');
|
|
14383
15112
|
nextLabel = !r.enabled ? 'disabled' : r.broken ? 'broken' : relTime(r.nextFireAt);
|
|
15113
|
+
const held = routineHoldText(r);
|
|
15114
|
+
if (held) { nextLabel = held.label; nextTip = held.tip; }
|
|
14384
15115
|
}
|
|
14385
15116
|
const whenText = isTrigger ? triggerWhenText(r) : scheduleText(r.schedule);
|
|
14386
15117
|
// #2035: an agent routine names its agent, not a workflow id.
|
|
@@ -14442,7 +15173,9 @@
|
|
|
14442
15173
|
await api(`/api/routines/${encodeURIComponent(id)}/run`, { method: 'POST' });
|
|
14443
15174
|
runningRoutines.add(id); // optimistic, for immediate feedback; SSE confirms it moments later
|
|
14444
15175
|
renderRoutinesList();
|
|
14445
|
-
|
|
15176
|
+
// #2062: a hand run starts a paused agent; its schedule stays held. Queued, not yet started — the row says how it went.
|
|
15177
|
+
const held = routinesData.find((r) => r.id === id)?.agentHold === 'paused';
|
|
15178
|
+
showToast(held ? 'Routine queued by hand. Its agent is paused, so its schedule stays off.' : 'Routine started', 'ok');
|
|
14446
15179
|
} catch (e) {
|
|
14447
15180
|
// 409 with running:true — the server refused because this routine is already queued or mid-run,
|
|
14448
15181
|
// and nothing was started, so never say it was. Keyed on the FLAG rather than the status: this
|
|
@@ -14840,7 +15573,7 @@
|
|
|
14840
15573
|
routineAgentPoll = setTimeout(async () => {
|
|
14841
15574
|
if (!$routinesModal.classList.contains('show')) return;
|
|
14842
15575
|
const going = routinesData.some((r) => r.agent && (r.lastRun?.status === 'starting'
|
|
14843
|
-
|| (r.lastRun?.status === 'started' &&
|
|
15576
|
+
|| (r.lastRun?.status === 'started' && agentRunStillGoing(routineAgentRunState.get(r.id) || ''))));
|
|
14844
15577
|
if (going) await refreshRoutineAgents();
|
|
14845
15578
|
pollRoutineAgents();
|
|
14846
15579
|
}, 8000);
|
|
@@ -14935,6 +15668,25 @@
|
|
|
14935
15668
|
const $riImportList = document.getElementById('ri-import-list');
|
|
14936
15669
|
const $riImportInclude = document.getElementById('ri-import-include');
|
|
14937
15670
|
|
|
15671
|
+
const $riSendError = document.getElementById('ri-send-error');
|
|
15672
|
+
const riClearSendError = () => { if ($riSendError) { $riSendError.hidden = true; $riSendError.textContent = ''; } };
|
|
15673
|
+
// What a failed send says: what happened, why, and what to do next. The typed text always stays.
|
|
15674
|
+
function riSendFailureCopy(err, importDetailsShown) {
|
|
15675
|
+
if (err === 'rejected') {
|
|
15676
|
+
const fix = importDetailsShown ? 'shorten the description or untick “Include these import details”' : 'shorten or simplify the description';
|
|
15677
|
+
return `FloLess reached our support inbox, but it would not accept this report as written. Your text is still here: ${fix}, then press Send report again.`;
|
|
15678
|
+
}
|
|
15679
|
+
if (err === 'declined') {
|
|
15680
|
+
return 'FloLess reached our support inbox, but it refused this report. Your text is still here: update FloLess to the latest version, then press Send report again.';
|
|
15681
|
+
}
|
|
15682
|
+
if (err === 'unavailable') {
|
|
15683
|
+
return 'FloLess reached our support inbox, but it is having trouble right now. Your text is still here: press Send report again in a few minutes.';
|
|
15684
|
+
}
|
|
15685
|
+
if (err === 'offline') {
|
|
15686
|
+
return 'FloLess could not reach our support inbox, so the report was not sent. Check your internet connection, then press Send report again — your text is still here.';
|
|
15687
|
+
}
|
|
15688
|
+
return 'FloLess ran into a problem on this computer before it could send the report. Your text is still here: press Send report again, and if it keeps happening restart FloLess.';
|
|
15689
|
+
}
|
|
14938
15690
|
const riSyncSend = () => { $riSend.disabled = !($riTitle.value.trim() && $riDesc.value.trim()); };
|
|
14939
15691
|
function riHideAndRestoreFocus() {
|
|
14940
15692
|
hideModal($riModal);
|
|
@@ -15004,6 +15756,7 @@
|
|
|
15004
15756
|
riReturnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
15005
15757
|
if ($menu.contains(riReturnFocus)) riReturnFocus = $menuBtn;
|
|
15006
15758
|
riSubmitting = false;
|
|
15759
|
+
riClearSendError();
|
|
15007
15760
|
$riForm.hidden = false;
|
|
15008
15761
|
$riState.hidden = true;
|
|
15009
15762
|
while ($riState.firstChild) $riState.removeChild($riState.firstChild);
|
|
@@ -15112,18 +15865,23 @@
|
|
|
15112
15865
|
riSyncSend();
|
|
15113
15866
|
});
|
|
15114
15867
|
|
|
15115
|
-
function riRenderSuccess(ref, droppedImportReference = null) {
|
|
15868
|
+
function riRenderSuccess(ref, droppedImportReference = null, queued = false) {
|
|
15116
15869
|
const wrap = document.createElement('div');
|
|
15117
|
-
|
|
15870
|
+
// #2125: the report could not be delivered (inbox down or no connection), so the server kept it to send later.
|
|
15871
|
+
// `is-held` tints the check: saved, but not sent.
|
|
15872
|
+
wrap.className = queued ? 'graft-success is-held' : 'graft-success';
|
|
15118
15873
|
const icon = document.createElement('div');
|
|
15119
15874
|
icon.className = 'gs-icon';
|
|
15120
15875
|
icon.setAttribute('aria-hidden', 'true');
|
|
15121
15876
|
icon.appendChild(riCheckIcon());
|
|
15122
15877
|
const msg = document.createElement('div');
|
|
15123
15878
|
msg.className = 'gs-msg';
|
|
15124
|
-
msg.
|
|
15125
|
-
|
|
15126
|
-
|
|
15879
|
+
msg.id = 'ri-state-msg';
|
|
15880
|
+
msg.textContent = queued
|
|
15881
|
+
? 'Saved on this computer — not sent yet. FloLess could not deliver it just now, so it kept your report and will keep trying, sending it automatically whenever FloLess is running. You don\'t need to send it again.'
|
|
15882
|
+
: ref
|
|
15883
|
+
? `Received — logged as ${ref} · We'll follow up privately.`
|
|
15884
|
+
: "Received · We'll follow up privately.";
|
|
15127
15885
|
wrap.append(icon, msg);
|
|
15128
15886
|
// #1757: the person chose to include the import details, but FloLess could not attach them (the
|
|
15129
15887
|
// import is no longer readable to this session). Say so, and give them the reference to pass on.
|
|
@@ -15136,6 +15894,7 @@
|
|
|
15136
15894
|
const actions = document.createElement('div');
|
|
15137
15895
|
actions.className = 'modal-actions';
|
|
15138
15896
|
const done = riButton('ri-done', 'Done', true, () => riClose());
|
|
15897
|
+
done.setAttribute('aria-describedby', 'ri-state-msg'); // focus lands on Done: let it read the outcome
|
|
15139
15898
|
actions.append(done);
|
|
15140
15899
|
riShowState(wrap, actions);
|
|
15141
15900
|
done.focus();
|
|
@@ -15162,6 +15921,7 @@
|
|
|
15162
15921
|
const body = $riDesc.value.trim();
|
|
15163
15922
|
if (!title || !body) return;
|
|
15164
15923
|
riSubmitting = true;
|
|
15924
|
+
riClearSendError();
|
|
15165
15925
|
$riSend.disabled = true;
|
|
15166
15926
|
$riSend.textContent = 'Sending…';
|
|
15167
15927
|
// Versions are filled by the health fetch on open; if a fast submit beat it, fetch them
|
|
@@ -15186,7 +15946,7 @@
|
|
|
15186
15946
|
const importFailure = riImport && $riImport && !$riImport.hidden && $riImportInclude?.checked ? riImport : undefined;
|
|
15187
15947
|
const r = await api('/api/report-issue', { method: 'POST', body: JSON.stringify({ category: riCategory, title, body, context, importFailure }) });
|
|
15188
15948
|
riSubmitting = false; // response in hand — Done / Escape / backdrop may close
|
|
15189
|
-
riRenderSuccess(r.ref || '', importFailure && r.importDetailsAttached === false ? importFailure.operationId : null);
|
|
15949
|
+
riRenderSuccess(r.ref || '', importFailure && r.importDetailsAttached === false ? importFailure.operationId : null, r.queued === true);
|
|
15190
15950
|
} catch (e) {
|
|
15191
15951
|
riSubmitting = false;
|
|
15192
15952
|
const err = (e && e.body && e.body.error) || '';
|
|
@@ -15196,7 +15956,10 @@
|
|
|
15196
15956
|
showToast('Too many reports just now — please wait a moment and try again', 'warn');
|
|
15197
15957
|
$riSend.disabled = false; $riSend.textContent = 'Send report';
|
|
15198
15958
|
} else {
|
|
15199
|
-
|
|
15959
|
+
const copy = riSendFailureCopy(err, Boolean(riImport && $riImport && !$riImport.hidden && $riImportInclude?.checked));
|
|
15960
|
+
$riSendError.textContent = copy;
|
|
15961
|
+
$riSendError.hidden = false;
|
|
15962
|
+
showToast('Report not sent — your text is kept', 'err');
|
|
15200
15963
|
$riSend.disabled = false; $riSend.textContent = 'Send report';
|
|
15201
15964
|
}
|
|
15202
15965
|
}
|
|
@@ -15347,6 +16110,21 @@
|
|
|
15347
16110
|
const b = e.target.closest('button[data-reqscope]');
|
|
15348
16111
|
if (b) setRequestScopeAll(b.dataset.reqscope === 'all');
|
|
15349
16112
|
};
|
|
16113
|
+
const $reqView = document.getElementById('requests-view');
|
|
16114
|
+
if ($reqView) {
|
|
16115
|
+
$reqView.onclick = (e) => {
|
|
16116
|
+
const b = e.target.closest('button[data-reqview]');
|
|
16117
|
+
if (b) void setRequestViewMode(b.dataset.reqview);
|
|
16118
|
+
};
|
|
16119
|
+
// A tablist moves between its tabs with the arrow keys.
|
|
16120
|
+
$reqView.onkeydown = (e) => {
|
|
16121
|
+
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
|
|
16122
|
+
e.preventDefault();
|
|
16123
|
+
const next = requestViewMode === 'done' ? 'queued' : 'done';
|
|
16124
|
+
void setRequestViewMode(next);
|
|
16125
|
+
document.getElementById(`requests-view-${next}`)?.focus();
|
|
16126
|
+
};
|
|
16127
|
+
}
|
|
15350
16128
|
const $reqSearch = document.getElementById('requests-search');
|
|
15351
16129
|
if ($reqSearch) $reqSearch.oninput = () => { requestQuery = $reqSearch.value; renderRequests(); };
|
|
15352
16130
|
const $reqList = document.getElementById('requests-list');
|
|
@@ -15924,8 +16702,25 @@
|
|
|
15924
16702
|
function scheduledRoutineTip(routines, workflowId) {
|
|
15925
16703
|
const names = routines.filter((r) => r.enabled && !r.broken && r.workflow === workflowId).map((r) => `“${r.name}”`);
|
|
15926
16704
|
if (!names.length) return '';
|
|
15927
|
-
|
|
15928
|
-
|
|
16705
|
+
// #2062: never read as always-on — a routine runs only while FloLess is running on this computer.
|
|
16706
|
+
return names.length === 1 ? `Runs from the routine ${names[0]}, only while FloLess is running on this computer.`
|
|
16707
|
+
: `Runs from ${names.length} routines (${names.join(', ')}), only while FloLess is running on this computer.`;
|
|
16708
|
+
}
|
|
16709
|
+
|
|
16710
|
+
/**
|
|
16711
|
+
* C12 (#1337): the Workflows landing's notice naming every installed workflow AWARE could not read. The others still
|
|
16712
|
+
* list; this says which one is missing from the page, why, and what to do. Empty when every workflow was readable.
|
|
16713
|
+
*/
|
|
16714
|
+
function unreadableWorkflowsNoteHtml(rows, esc) {
|
|
16715
|
+
if (!Array.isArray(rows) || !rows.length) return '';
|
|
16716
|
+
const names = rows.map((row) => `“${esc(row.name || row.id)}”`);
|
|
16717
|
+
const list = names.length === 1 ? names[0] : `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;
|
|
16718
|
+
const one = rows.length === 1;
|
|
16719
|
+
// Static, rendered with the page: a plain note, not a live region (it would only be announced twice).
|
|
16720
|
+
return `<div class="ws-empty-note ws-load-error wf-unreadable" data-wf-unreadable="${rows.length}">`
|
|
16721
|
+
+ `<b>FloLess couldn’t read ${one ? 'one installed workflow' : `${rows.length} installed workflows`}: ${list}.</b> `
|
|
16722
|
+
+ `${one ? 'Its files are damaged or incomplete, so it can’t be opened or run' : 'Their files are damaged or incomplete, so they can’t be opened or run'}. `
|
|
16723
|
+
+ `Your other workflows are not affected. Ask AI Chat to repair or reinstall ${one ? 'it' : 'them'}.</div>`;
|
|
15929
16724
|
}
|
|
15930
16725
|
|
|
15931
16726
|
function renderWorkflowsLanding() {
|
|
@@ -15959,11 +16754,14 @@
|
|
|
15959
16754
|
+ `<div class="wf-draft-actions"><button type="button" data-wf-restore="${esc(row.workflowId)}" data-command-id="workflow.unarchive#${esc(row.workflowId)}" data-command-instance-label="${esc(row.displayName)}" data-tip="Restore this workflow to the Workflows page with its files, chat and history"${busy ? ' disabled aria-busy="true"' : ''}>${busy ? 'Restoring…' : 'Restore'}</button></div>`
|
|
15960
16755
|
+ `</div></div></div>`;
|
|
15961
16756
|
};
|
|
16757
|
+
// C12 (#1337): owned workflows whose installed copy AWARE could not read show as drafts that need compiling again.
|
|
16758
|
+
const unreadableOwned = new Set(wfUnreadable.map((row) => row.workflowId).filter(Boolean));
|
|
16759
|
+
const unreadableNote = unreadableWorkflowsNoteHtml(wfUnreadable, esc);
|
|
15962
16760
|
const draftCard = (row) => {
|
|
15963
16761
|
const recompile = Boolean(row.activePublication);
|
|
15964
16762
|
const name = row.displayName;
|
|
15965
16763
|
const chip = recompile ? 'Needs compiling' : 'Draft';
|
|
15966
|
-
const meta = `${recompile ? 'Compiled copy missing' : 'Not compiled yet'} · ${row.ownerLabel || 'Standalone'}`;
|
|
16764
|
+
const meta = `${recompile ? (unreadableOwned.has(row.workflowId) ? 'Compiled copy unreadable' : 'Compiled copy missing') : 'Not compiled yet'} · ${row.ownerLabel || 'Standalone'}`;
|
|
15967
16765
|
return `<div class="ws-card wf-card wf-card-draft" role="button" tabindex="0" data-wf-draft="${esc(row.workflowId)}" data-command-id="shell.workflows-landing-open-draft#${esc(name)}" data-command-instance-label="${esc(name)}">`
|
|
15968
16766
|
+ `<div class="ws-body"><div class="wf-card-text"><span class="ws-kind wf-kind is-draft">${chip}</span>`
|
|
15969
16767
|
+ `<div class="ws-name">${esc(name)}</div><div class="ws-meta">${esc(meta)}</div></div></div></div>`;
|
|
@@ -15994,6 +16792,7 @@
|
|
|
15994
16792
|
+ `<div class="ws-create-grid"><div class="ws-card ws-create ws-card-create wf-create" role="button" tabindex="0" data-wf-new="1" data-command-id="shell.workflows-landing-new">`
|
|
15995
16793
|
+ `<div class="ws-thumb">+</div><div class="ws-body"><div><div class="ws-name">New workflow</div>`
|
|
15996
16794
|
+ `<div class="ws-meta">Name it and choose where it belongs. AI builds it with you.</div></div></div></div></div>`
|
|
16795
|
+
+ unreadableNote
|
|
15997
16796
|
+ (wfLibrary.length || unlisted.length || archived.length || restoredRows.length
|
|
15998
16797
|
? yoursGroup + group('Installed', installed, both)
|
|
15999
16798
|
+ '<div class="ws-empty-note ws-search-empty" id="wf-search-empty" role="status" aria-live="polite"></div>'
|