@floless/app 0.137.3 → 0.138.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +47890 -27033
- package/dist/internal-workflows/floless-rfi-gmail-send/.floless-owner.json +1 -0
- package/dist/internal-workflows/floless-rfi-gmail-send/floless-rfi-gmail-send.flo +32 -0
- package/dist/schemas/steel.model.v2.schema.json +218 -27
- package/dist/skills/floless-app-knowledge/SKILL.md +5 -2
- package/dist/skills/floless-app-rfi/SKILL.md +410 -0
- package/dist/skills/floless-app-routines/SKILL.md +7 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -5
- package/dist/skills/floless-app-steel-model/SKILL.md +34 -32
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +498 -34
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +6 -6
- package/dist/skills/floless-app-tweak-contract/SKILL.md +6 -2
- package/dist/templates/floless-workspace-knowledge.flo +20 -4
- package/dist/templates/steel-model.flo +27 -15
- package/dist/web/app.css +559 -131
- package/dist/web/app.js +216 -54
- package/dist/web/aware.js +982 -128
- package/dist/web/checkpoint-standard.js +218 -0
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +237 -5
- package/dist/web/commands-steel.js +172 -47
- package/dist/web/connection-review-client.js +2 -2
- package/dist/web/display-units.js +243 -0
- package/dist/web/grid-core.js +474 -58
- package/dist/web/grid-display.js +344 -0
- package/dist/web/index.html +106 -66
- package/dist/web/instructor-reporter.js +5 -0
- package/dist/web/instructor.js +175 -33
- package/dist/web/json-schema-subset.js +145 -25
- package/dist/web/steel-3d-core.js +237 -151
- package/dist/web/steel-3d-view.js +366 -113
- package/dist/web/steel-catalog-picker.js +98 -15
- package/dist/web/steel-detail-refs.js +1 -1
- package/dist/web/steel-editor.html +6479 -921
- package/dist/web/steel-filter.html +404 -57
- package/dist/web/steel-model-adapter.js +1 -1
- package/dist/web/steel-model-commands.js +72 -66
- package/dist/web/steel-model-v2-client-validation.js +10 -3
- package/dist/web/steel-model-v2-commands.js +269 -77
- package/dist/web/steel-model-v2-projection.js +18 -17
- package/dist/web/steel-plan-transform.js +52 -9
- package/dist/web/steel-plan-view-id.js +1 -7
- package/dist/web/steel-read-confidence.js +454 -5
- package/dist/web/steel-units.js +39 -0
- package/dist/web/steel-view-generation.js +21 -7
- package/dist/web/workspaces.js +2178 -497
- package/package.json +5 -1
package/dist/web/aware.js
CHANGED
|
@@ -62,7 +62,9 @@
|
|
|
62
62
|
const exportReceiptsByApp = new Map(); // appId:kind → latest reconciled receipt counts
|
|
63
63
|
const exportBusyByApp = new Set(); // appId:kind → one in-flight host/export mutation
|
|
64
64
|
|
|
65
|
-
// The
|
|
65
|
+
// The closed set of reason prefixes the LEGACY `skipped` list uses (contract-to-scene.ts). Prefer
|
|
66
|
+
// `skippedDetail`, which carries an explicit reason per member and is what the routes now send;
|
|
67
|
+
// this remains the fallback for a response that predates it.
|
|
66
68
|
// a connection it could not expand, a trim it could not apply, or a member whose weight the AISC
|
|
67
69
|
// catalogue knows and whose footprint it does not tabulate. Anything else in `skipped` is a bare
|
|
68
70
|
// member id — an RFI with no resolvable size.
|
|
@@ -179,6 +181,11 @@
|
|
|
179
181
|
// round-trip. The id stays in `pendingDeleteAnswerIds` (filtered out of every render) until then.
|
|
180
182
|
const pendingDeleteAnswerIds = new Set();
|
|
181
183
|
const answerDeleteTimers = new Map();
|
|
184
|
+
const answerSessionLaunches = new Set();
|
|
185
|
+
// Exists only between the click and POST /api/guide returning. Once the server gives the question
|
|
186
|
+
// an id, `pendingRequests` is authoritative and this optimistic shell is removed.
|
|
187
|
+
const optimisticInstructorRequests = new Map();
|
|
188
|
+
let optimisticInstructorRequestSequence = 0;
|
|
182
189
|
const ANSWER_UNDO_MS = 6000;
|
|
183
190
|
|
|
184
191
|
function selectLeftPaneTab(tab, { focus = false, explicit = false } = {}) {
|
|
@@ -297,6 +304,173 @@
|
|
|
297
304
|
return out.join('');
|
|
298
305
|
}
|
|
299
306
|
|
|
307
|
+
function answerSessionProviderLabel(provider) {
|
|
308
|
+
return provider === 'claude' ? 'Claude' : provider === 'codex' ? 'Codex' : 'terminal AI';
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// The exact session id, provider URI, compatibility tuple, and working folder remain private on
|
|
312
|
+
// the server. Both visible surfaces receive this deliberately small state projection and render it
|
|
313
|
+
// here, so Requests cannot promise something the answer card refuses (or vice versa).
|
|
314
|
+
function answerSessionControlHtml(answer, surface) {
|
|
315
|
+
const continuation = answer && answer.continuation;
|
|
316
|
+
if (!continuation) return '';
|
|
317
|
+
const provider = continuation.provider === 'claude' ? 'claude' : 'codex';
|
|
318
|
+
const label = answerSessionProviderLabel(provider);
|
|
319
|
+
const rawAnswerId = String(answer.id || '');
|
|
320
|
+
const answerId = escapeAttr(rawAnswerId);
|
|
321
|
+
const attemptId = escapeAttr(String(continuation.attemptId || ''));
|
|
322
|
+
const instance = escapeAttr(`${label} session for ${answer.instructorContext?.subject || 'this answer'}`);
|
|
323
|
+
const prefix = surface === 'requests' ? 'requests' : 'answer';
|
|
324
|
+
const attrs = `data-answer-id="${answerId}" data-attempt-id="${attemptId}" data-provider="${provider}" data-answer-surface="${prefix}"`;
|
|
325
|
+
// Keep the command half literal so the Instructor inventory can prove every carrier. Only the
|
|
326
|
+
// escaped instance after "#" is dynamic; raw answer ids must never reach attribute markup.
|
|
327
|
+
const openButton = (text, extra = '') => `<button type="button" class="answer-session-open" id="${prefix}-answer-session-${answerId}" data-command-id="shell.answer-session-open#${escapeAttr(`${prefix}:${rawAnswerId}`)}" data-command-instance-label="${instance}" ${attrs}${extra}>${text}</button>`;
|
|
328
|
+
const openAgainButton = (text) => `<button type="button" class="answer-session-open" id="${prefix}-answer-session-${answerId}" data-command-id="shell.answer-session-open-again#${escapeAttr(`${prefix}:${rawAnswerId}`)}" data-command-instance-label="${instance}" ${attrs}>${text}</button>`;
|
|
329
|
+
const retryUncertainButton = (text) => `<button type="button" class="answer-session-open" id="${prefix}-answer-session-${answerId}" data-command-id="shell.answer-session-retry-uncertain#${escapeAttr(`${prefix}:${rawAnswerId}`)}" data-command-instance-label="${instance}" ${attrs}>${text}</button>`;
|
|
330
|
+
let content = '';
|
|
331
|
+
if (continuation.state === 'preparing') {
|
|
332
|
+
content = '<span class="answer-session-status"><span class="answer-session-spinner" aria-hidden="true"></span>Saving this session…</span>';
|
|
333
|
+
} else if (continuation.state === 'available') {
|
|
334
|
+
content = openButton(`Continue in ${label}`);
|
|
335
|
+
} else if (continuation.state === 'dispatching') {
|
|
336
|
+
content = openButton(`Asking Windows to open ${label}…`, ' aria-disabled="true" aria-busy="true"');
|
|
337
|
+
} else if (continuation.state === 'asked-windows') {
|
|
338
|
+
content = `<span class="answer-session-status">FloLess asked Windows to open ${label}.</span>${openAgainButton('Open again')}`;
|
|
339
|
+
} else if (continuation.state === 'dispatch-uncertain') {
|
|
340
|
+
content = `<span class="answer-session-status answer-session-warning">Windows may already have received the earlier request.</span>${retryUncertainButton('Try opening again…')}`;
|
|
341
|
+
} else {
|
|
342
|
+
const copy = continuation.reason === 'unsupported-provider'
|
|
343
|
+
? `This answer is saved. Its ${label} session isn’t available to reopen.`
|
|
344
|
+
: continuation.reason === 'provider-version'
|
|
345
|
+
? `This version of ${label} can’t reopen the saved session.`
|
|
346
|
+
: continuation.reason === 'capture-failed'
|
|
347
|
+
? `This answer is saved, but its ${label} session could not be preserved.`
|
|
348
|
+
: 'No saved session is available for this answer.';
|
|
349
|
+
content = `<span class="answer-session-status answer-session-unavailable">${copy}</span>`;
|
|
350
|
+
}
|
|
351
|
+
return `<div class="answer-session-continuation" role="group" aria-label="Continue this AI session" ${attrs}>${content}</div>`;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function replaceAnswerContinuation(answerId, attemptId, continuation) {
|
|
355
|
+
let changed = false;
|
|
356
|
+
instructorAnswers = instructorAnswers.map((answer) => {
|
|
357
|
+
if (answer.id !== answerId || answer.continuation?.attemptId !== attemptId) return answer;
|
|
358
|
+
changed = true;
|
|
359
|
+
return { ...answer, continuation };
|
|
360
|
+
});
|
|
361
|
+
return changed;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function focusedAnswerSessionControl() {
|
|
365
|
+
const group = document.activeElement?.closest?.('.answer-session-continuation');
|
|
366
|
+
if (!group) return null;
|
|
367
|
+
return {
|
|
368
|
+
answerId: group.dataset.answerId || '', attemptId: group.dataset.attemptId || '',
|
|
369
|
+
surface: group.dataset.answerSurface === 'requests' ? 'requests' : 'answer',
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function restoreAnswerSessionFocus(target) {
|
|
374
|
+
if (!target?.answerId || !target?.attemptId) return;
|
|
375
|
+
const selector = `[data-answer-id="${CSS.escape(target.answerId)}"]`
|
|
376
|
+
+ `[data-attempt-id="${CSS.escape(target.attemptId)}"]`
|
|
377
|
+
+ `[data-answer-surface="${CSS.escape(target.surface)}"]`;
|
|
378
|
+
const button = document.querySelector(`.answer-session-open${selector}`);
|
|
379
|
+
if (button) { button.focus({ preventScroll: true }); return; }
|
|
380
|
+
const group = document.querySelector(`.answer-session-continuation${selector}`);
|
|
381
|
+
if (group) {
|
|
382
|
+
group.tabIndex = -1;
|
|
383
|
+
group.focus({ preventScroll: true });
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
(target.surface === 'requests'
|
|
387
|
+
? document.querySelector('#requests-modal .modal.requests')
|
|
388
|
+
: document.getElementById('ai-answers-tab'))?.focus?.({ preventScroll: true });
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function repaintAnswerSessionSurfaces(focusTarget = focusedAnswerSessionControl()) {
|
|
392
|
+
renderInstructorAnswers({ revealNew: false });
|
|
393
|
+
const requestsModal = document.getElementById('requests-modal');
|
|
394
|
+
if (requestsModal?.classList.contains('show')) renderRequests();
|
|
395
|
+
restoreAnswerSessionFocus(focusTarget);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function announceAnswerSession(message, surface) {
|
|
399
|
+
if (surface === 'requests') {
|
|
400
|
+
const status = document.getElementById('requests-answer-session-status');
|
|
401
|
+
if (status) {
|
|
402
|
+
status.textContent = message;
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
announceAnswers(message);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async function launchAnswerSession(button) {
|
|
410
|
+
const answerId = button.dataset.answerId || '';
|
|
411
|
+
const attemptId = button.dataset.attemptId || '';
|
|
412
|
+
const provider = button.dataset.provider === 'claude' ? 'claude' : 'codex';
|
|
413
|
+
const surface = button.dataset.answerSurface === 'requests' ? 'requests' : 'answer';
|
|
414
|
+
const focusTarget = { answerId, attemptId, surface };
|
|
415
|
+
const key = `${answerId}\0${attemptId}`;
|
|
416
|
+
if (!answerId || !attemptId || answerSessionLaunches.has(key) || button.getAttribute('aria-disabled') === 'true') return;
|
|
417
|
+
const answer = instructorAnswers.find((candidate) => candidate.id === answerId
|
|
418
|
+
&& candidate.continuation?.attemptId === attemptId);
|
|
419
|
+
if (!answer) return;
|
|
420
|
+
const prior = answer.continuation;
|
|
421
|
+
if (!['available', 'asked-windows', 'dispatch-uncertain'].includes(prior.state)) return;
|
|
422
|
+
const confirmUncertain = prior.state === 'dispatch-uncertain';
|
|
423
|
+
if (confirmUncertain) {
|
|
424
|
+
const label = answerSessionProviderLabel(provider);
|
|
425
|
+
const choice = await confirmUnsavedSwitch(
|
|
426
|
+
'',
|
|
427
|
+
`Windows may already have received the earlier request. Trying again can open the same session twice in ${label}.`,
|
|
428
|
+
`Try opening ${label} again?`,
|
|
429
|
+
{ confirm: 'Try opening again', hideDiscard: true, initialFocus: 'cancel' },
|
|
430
|
+
);
|
|
431
|
+
if (choice !== 'save') return;
|
|
432
|
+
}
|
|
433
|
+
answerSessionLaunches.add(key);
|
|
434
|
+
replaceAnswerContinuation(answerId, attemptId, { ...prior, state: 'dispatching' });
|
|
435
|
+
repaintAnswerSessionSurfaces(focusTarget);
|
|
436
|
+
announceAnswerSession(`Asking Windows to open ${answerSessionProviderLabel(provider)}`, surface);
|
|
437
|
+
try {
|
|
438
|
+
const response = await api(`/api/answers/${encodeURIComponent(answerId)}/desktop-session/launch`, {
|
|
439
|
+
method: 'POST', body: JSON.stringify({
|
|
440
|
+
attemptId, expectedState: prior.state, ...(confirmUncertain ? { confirmUncertain: true } : {}),
|
|
441
|
+
}),
|
|
442
|
+
});
|
|
443
|
+
replaceAnswerContinuation(answerId, attemptId, response.continuation);
|
|
444
|
+
announceAnswerSession(`FloLess asked Windows to open ${answerSessionProviderLabel(provider)}`, surface);
|
|
445
|
+
} catch (error) {
|
|
446
|
+
if (error?.body?.code === 'provider-version') {
|
|
447
|
+
replaceAnswerContinuation(answerId, attemptId, { ...prior, state: 'unavailable', reason: 'provider-version' });
|
|
448
|
+
announceAnswerSession(`This version of ${answerSessionProviderLabel(provider)} can’t reopen the saved session.`, surface);
|
|
449
|
+
} else if (error?.body?.code === 'confirm-uncertain') {
|
|
450
|
+
replaceAnswerContinuation(answerId, attemptId, { ...prior, state: 'dispatch-uncertain' });
|
|
451
|
+
announceAnswerSession('Windows may already have received the earlier request.', surface);
|
|
452
|
+
} else if (error?.body?.code === 'workspace-invalid') {
|
|
453
|
+
replaceAnswerContinuation(answerId, attemptId, { ...prior, state: 'unavailable', reason: 'capture-failed' });
|
|
454
|
+
announceAnswerSession('The saved session workspace is no longer available.', surface);
|
|
455
|
+
} else if (error?.body?.code === 'state-changed') {
|
|
456
|
+
await loadRequests();
|
|
457
|
+
announceAnswerSession('This saved answer session changed in another window.', surface);
|
|
458
|
+
} else {
|
|
459
|
+
replaceAnswerContinuation(answerId, attemptId, prior);
|
|
460
|
+
reportErr(error);
|
|
461
|
+
}
|
|
462
|
+
} finally {
|
|
463
|
+
answerSessionLaunches.delete(key);
|
|
464
|
+
repaintAnswerSessionSurfaces(focusTarget);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function bindAnswerSessionControls(root) {
|
|
469
|
+
root.querySelectorAll('.answer-session-open').forEach((button) => {
|
|
470
|
+
button.onclick = () => { void launchAnswerSession(button); };
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
300
474
|
function answerCard(answer, isNew) {
|
|
301
475
|
const subjectText = answer.instructorContext.subject || 'this context';
|
|
302
476
|
const subject = escapeHtml(subjectText);
|
|
@@ -307,13 +481,17 @@
|
|
|
307
481
|
`<span class="answer-new-badge">New answer</span>${prose}`,
|
|
308
482
|
answer.finishedAt);
|
|
309
483
|
card.dataset.answerId = answer.id;
|
|
484
|
+
const body = card.querySelector('.body');
|
|
485
|
+
if (body && answer.continuation) {
|
|
486
|
+
body.insertAdjacentHTML('beforeend', answerSessionControlHtml(answer, 'answer'));
|
|
487
|
+
bindAnswerSessionControls(card);
|
|
488
|
+
}
|
|
310
489
|
|
|
311
490
|
// A fresh arrival always renders expanded — the glow-and-scroll is meant to reveal its content, so
|
|
312
491
|
// a card that lit up and then hid its own body would be actively confusing. Otherwise honour the
|
|
313
492
|
// per-id collapse the user set.
|
|
314
493
|
const collapsed = !isNew && collapsedAnswerIds.has(answer.id);
|
|
315
494
|
if (collapsed) card.classList.add('answer-collapsed');
|
|
316
|
-
const body = card.querySelector('.body');
|
|
317
495
|
const bodyId = `answer-body-${answer.id}`;
|
|
318
496
|
if (body) body.id = bodyId;
|
|
319
497
|
const who = card.querySelector('.who');
|
|
@@ -330,21 +508,31 @@
|
|
|
330
508
|
setCollapseToggleState(chevron, collapsed, `${runtime} · ${subjectText}`);
|
|
331
509
|
chevron.onclick = () => toggleAnswerCollapse(answer.id);
|
|
332
510
|
|
|
333
|
-
const del = document.createElement('button');
|
|
334
|
-
del
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
511
|
+
const del = answerCanDelete(answer) ? document.createElement('button') : null;
|
|
512
|
+
if (del) {
|
|
513
|
+
del.type = 'button';
|
|
514
|
+
del.className = 'answer-del';
|
|
515
|
+
del.textContent = '×';
|
|
516
|
+
del.setAttribute('aria-label', `Remove this answer, ${runtime} · ${subjectText}`);
|
|
517
|
+
del.setAttribute('data-tip', 'Remove this answer');
|
|
518
|
+
del.onclick = () => removeAnswerWithUndo(answer.id);
|
|
519
|
+
}
|
|
340
520
|
|
|
341
521
|
if (who) {
|
|
342
522
|
who.insertBefore(chevron, who.firstChild); // chevron | name … time | ×
|
|
343
|
-
who.appendChild(del);
|
|
523
|
+
if (del) who.appendChild(del);
|
|
344
524
|
}
|
|
345
525
|
return card;
|
|
346
526
|
}
|
|
347
527
|
|
|
528
|
+
function answerCanDelete(answer) {
|
|
529
|
+
const key = `${answer?.id || ''}\0${answer?.continuation?.attemptId || ''}`;
|
|
530
|
+
return !answer?.continuation
|
|
531
|
+
|| (answer.continuation.state !== 'preparing'
|
|
532
|
+
&& answer.continuation.state !== 'dispatching'
|
|
533
|
+
&& !answerSessionLaunches.has(key));
|
|
534
|
+
}
|
|
535
|
+
|
|
348
536
|
// One place that writes the chevron's per-state ARIA/tooltip, so the toggle and the card class can
|
|
349
537
|
// never drift. `expanded` name folds the subject in so a screen reader tells the per-card toggles
|
|
350
538
|
// apart from each other and from the bulk one.
|
|
@@ -421,14 +609,16 @@
|
|
|
421
609
|
collapseAll.textContent = 'Collapse all';
|
|
422
610
|
collapseAll.onclick = () => toggleAllAnswers(visible);
|
|
423
611
|
|
|
612
|
+
const clearable = visible.filter(answerCanDelete);
|
|
424
613
|
const clearAll = document.createElement('button');
|
|
425
614
|
clearAll.type = 'button';
|
|
426
615
|
clearAll.id = 'answers-clear-all';
|
|
427
616
|
clearAll.className = 'answers-bulk answers-clear';
|
|
428
617
|
clearAll.setAttribute('data-command-id', 'shell.answers-clear');
|
|
429
|
-
clearAll.textContent = 'Clear all';
|
|
430
|
-
clearAll.setAttribute('data-tip',
|
|
431
|
-
clearAll.onclick = () => clearAllAnswers(
|
|
618
|
+
clearAll.textContent = clearable.length === visible.length ? 'Clear all' : 'Clear available';
|
|
619
|
+
clearAll.setAttribute('data-tip', clearable.length === 1 ? 'Remove this answer' : `Remove ${clearable.length} answers that are ready to clear`);
|
|
620
|
+
clearAll.onclick = () => clearAllAnswers(clearable);
|
|
621
|
+
clearAll.hidden = clearable.length === 0;
|
|
432
622
|
|
|
433
623
|
bar.append(count, spacer, collapseAll, clearAll);
|
|
434
624
|
return bar;
|
|
@@ -495,11 +685,19 @@
|
|
|
495
685
|
if (!ids.length) return;
|
|
496
686
|
if (!(await confirmClearAnswers(ids.length))) return;
|
|
497
687
|
try {
|
|
498
|
-
|
|
688
|
+
const results = await Promise.allSettled(ids.map((id) =>
|
|
689
|
+
api(`/api/requests/${encodeURIComponent(id)}`, { method: 'DELETE' })));
|
|
499
690
|
await loadRequests();
|
|
500
691
|
renderInstructorAnswers({ revealNew: false });
|
|
501
|
-
|
|
502
|
-
|
|
692
|
+
const cleared = results.filter((result) => result.status === 'fulfilled').length;
|
|
693
|
+
const failed = results.length - cleared;
|
|
694
|
+
announceAnswers(`${cleared ? `Cleared ${cleared} answer${cleared === 1 ? '' : 's'}` : 'No answers cleared'}${failed ? `; ${failed} kept` : ''}`);
|
|
695
|
+
showToast(
|
|
696
|
+
`${cleared ? `Cleared ${cleared} answer${cleared === 1 ? '' : 's'}` : 'No answers cleared'}${failed ? ` — kept ${failed}` : ''}`,
|
|
697
|
+
failed ? 'info' : 'ok',
|
|
698
|
+
);
|
|
699
|
+
const firstFailure = results.find((result) => result.status === 'rejected');
|
|
700
|
+
if (firstFailure?.status === 'rejected') reportErr(firstFailure.reason);
|
|
503
701
|
} catch (error) { reportErr(error); }
|
|
504
702
|
}
|
|
505
703
|
|
|
@@ -551,6 +749,82 @@
|
|
|
551
749
|
renderInstructorAnswers({ revealNew: true });
|
|
552
750
|
}
|
|
553
751
|
|
|
752
|
+
function pendingInstructorStatus(request) {
|
|
753
|
+
const runtime = request.runtime || request.run?.runtime;
|
|
754
|
+
const provider = runtimeLabel(runtime || '');
|
|
755
|
+
if (request.optimistic) return { label: 'Sending your question…', active: true };
|
|
756
|
+
if (request.run?.state === 'running') return { label: `${provider} is working on your answer.`, active: true };
|
|
757
|
+
if (request.run?.state === 'queued') return { label: `Waiting for ${provider} to start.`, active: true };
|
|
758
|
+
if (['failed', 'stopped', 'interrupted', 'contract-violation', 'needs-you', 'exited-unresolved'].includes(request.run?.state)) {
|
|
759
|
+
return { label: `${provider} stopped before finishing. Open Requests for details.`, active: false };
|
|
760
|
+
}
|
|
761
|
+
return { label: `Question saved. Waiting for ${provider} to start.`, active: true };
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
function pendingInstructorCard(request) {
|
|
765
|
+
const subject = request.instructorContext?.subject || 'this context';
|
|
766
|
+
const runtime = request.runtime || request.run?.runtime;
|
|
767
|
+
const provider = runtimeLabel(runtime || '');
|
|
768
|
+
const status = pendingInstructorStatus(request);
|
|
769
|
+
const card = msgEl(
|
|
770
|
+
'aware instructor-answer instructor-answer-pending',
|
|
771
|
+
`${escapeHtml(provider)} · ${escapeHtml(subject)}`,
|
|
772
|
+
`<span class="instructor-answer-pending-status">${status.active ? '<span class="answer-session-spinner" aria-hidden="true"></span>' : ''}${escapeHtml(status.label)}</span>`,
|
|
773
|
+
request.createdAt,
|
|
774
|
+
);
|
|
775
|
+
card.dataset.pendingRequestId = request.id;
|
|
776
|
+
return card;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
function instructorRequestClientFingerprint(request) {
|
|
780
|
+
const body = { instructorContext: request?.instructorContext };
|
|
781
|
+
if (request?.project) {
|
|
782
|
+
body.project = request.project;
|
|
783
|
+
body.projectLabel = request.projectLabel;
|
|
784
|
+
body.appId = request.appId;
|
|
785
|
+
} else if (request?.appId) body.appId = request.appId;
|
|
786
|
+
return JSON.stringify(body);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function visiblePendingInstructorRequests() {
|
|
790
|
+
// `/api/guide` broadcasts the durable row before its POST response settles. Prefer the
|
|
791
|
+
// optimistic card during that small overlap so one click never paints two copies of the same
|
|
792
|
+
// question; settlement then swaps it for the server-owned id without a flash.
|
|
793
|
+
const durable = pendingRequests.filter((request) => !optimisticInstructorRequests.has(instructorRequestClientFingerprint(request)));
|
|
794
|
+
return [...optimisticInstructorRequests.values(), ...durable]
|
|
795
|
+
.filter((request) => request?.type === 'guide' && answerInVisibleScope(request))
|
|
796
|
+
.filter((request) => request.optimistic || !instructorAnswers.some((answer) => answer.id === request.id));
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
function beginOptimisticInstructorRequest(body, runtime, fingerprint) {
|
|
800
|
+
const id = `sending-${++optimisticInstructorRequestSequence}`;
|
|
801
|
+
optimisticInstructorRequests.set(fingerprint, {
|
|
802
|
+
id, type: 'guide', optimistic: true, runtime,
|
|
803
|
+
createdAt: new Date().toISOString(), ...body,
|
|
804
|
+
});
|
|
805
|
+
renderInstructorAnswers({ revealNew: false });
|
|
806
|
+
if (!state.collapse.left) selectLeftPaneTab('answers');
|
|
807
|
+
else document.getElementById('ai-answers-tab')?.classList.add('instructor-answer-new');
|
|
808
|
+
announceAnswers('Sending your question. Pending work is shown in AI answers.');
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
function settleOptimisticInstructorRequest(fingerprint, request = null) {
|
|
812
|
+
const optimistic = optimisticInstructorRequests.get(fingerprint);
|
|
813
|
+
optimisticInstructorRequests.delete(fingerprint);
|
|
814
|
+
if (request?.id) {
|
|
815
|
+
const runtime = request.runtime || optimistic?.runtime;
|
|
816
|
+
const existing = pendingRequests.find((candidate) => candidate?.id === request.id);
|
|
817
|
+
if (!existing) {
|
|
818
|
+
pendingRequests = [{ ...request, ...(runtime ? { runtime } : {}) }, ...pendingRequests];
|
|
819
|
+
} else if (runtime && !existing.runtime) {
|
|
820
|
+
pendingRequests = pendingRequests.map((candidate) => candidate?.id === request.id
|
|
821
|
+
? { ...candidate, runtime }
|
|
822
|
+
: candidate);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
renderInstructorAnswers({ revealNew: false });
|
|
826
|
+
}
|
|
827
|
+
|
|
554
828
|
function renderInstructorAnswers({ revealNew = true } = {}) {
|
|
555
829
|
const feed = document.getElementById('ai-answers');
|
|
556
830
|
if (!feed) return;
|
|
@@ -560,6 +834,8 @@
|
|
|
560
834
|
// Newest-first: the latest answer sits at the top. A blind reverse of the stored order would ride
|
|
561
835
|
// on filesystem read order; sorting on finishedAt is the ordering the user actually asked for.
|
|
562
836
|
const ordered = [...visible].sort((a, b) => String(b.finishedAt || '').localeCompare(String(a.finishedAt || '')));
|
|
837
|
+
const pending = visiblePendingInstructorRequests()
|
|
838
|
+
.sort((a, b) => String(b.createdAt || '').localeCompare(String(a.createdAt || '')));
|
|
563
839
|
const wasNearTop = feed.scrollTop < 72;
|
|
564
840
|
const unseen = revealNew ? visible.filter((answer) => arrivedInstructorAnswerIds.has(answer.id)) : [];
|
|
565
841
|
const unreadCount = visible.filter((answer) => !readInstructorAnswerIds.has(answer.id)).length;
|
|
@@ -573,11 +849,12 @@
|
|
|
573
849
|
else answersTab?.removeAttribute('aria-label');
|
|
574
850
|
const newAnswer = unseen.length ? unseen[unseen.length - 1] : null;
|
|
575
851
|
feed.innerHTML = '';
|
|
576
|
-
if (!ordered.length) {
|
|
852
|
+
if (!ordered.length && !pending.length) {
|
|
577
853
|
const scope = wsRequestScope?.kind === 'project' ? 'this project' : wsRequestScope ? 'Workspaces' : 'this workflow';
|
|
578
854
|
feed.innerHTML = `<div class="ai-answers-empty" tabindex="-1">No AI answers for ${scope} yet. Direct answers you start from Instructor will appear here.</div>`;
|
|
579
855
|
} else {
|
|
580
|
-
feed.appendChild(answersToolbar(ordered));
|
|
856
|
+
if (ordered.length) feed.appendChild(answersToolbar(ordered));
|
|
857
|
+
pending.forEach((request) => feed.appendChild(pendingInstructorCard(request)));
|
|
581
858
|
ordered.forEach((answer) => feed.appendChild(answerCard(answer, answer === newAnswer)));
|
|
582
859
|
}
|
|
583
860
|
syncAnswerBulkToggle();
|
|
@@ -587,14 +864,11 @@
|
|
|
587
864
|
|
|
588
865
|
const obscured = !!document.querySelector('.modal-backdrop.show') || !!($contractEditor && !$contractEditor.hidden);
|
|
589
866
|
const wasCollapsed = state.collapse.left;
|
|
590
|
-
const collapsedToggleHadFocus = wasCollapsed
|
|
591
|
-
&& document.activeElement?.matches('.collapsed-stub .panel-toggle[data-side="left"]');
|
|
592
867
|
if (wasCollapsed && !obscured) {
|
|
593
868
|
state.collapse.left = false;
|
|
594
869
|
applyCollapse(); // session reveal only; the user's saved collapse preference remains untouched
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
870
|
+
// No focus hand-off: the pane has ONE grip now, in its rail, and a focused grip stays focused. The
|
|
871
|
+
// collapsed-stub copy this used to move focus away from no longer exists.
|
|
598
872
|
}
|
|
599
873
|
const paneAlreadyOpenOnAnswers = !wasCollapsed && leftPaneTab === 'answers';
|
|
600
874
|
if (wasCollapsed && !obscured) selectLeftPaneTab('answers');
|
|
@@ -638,7 +912,10 @@
|
|
|
638
912
|
// lifecycle and let reportErr() distinguish teardown noise from an error the user can still act on.
|
|
639
913
|
// `pageshow` matters for a document restored from the back-forward cache.
|
|
640
914
|
let awarePageUnloading = false;
|
|
641
|
-
window.addEventListener('pagehide', () => {
|
|
915
|
+
window.addEventListener('pagehide', () => {
|
|
916
|
+
awarePageUnloading = true;
|
|
917
|
+
releaseAppHostBakeConsentsOnPageHide();
|
|
918
|
+
});
|
|
642
919
|
window.addEventListener('pageshow', () => { awarePageUnloading = false; });
|
|
643
920
|
|
|
644
921
|
async function api(path, opts) {
|
|
@@ -646,7 +923,11 @@
|
|
|
646
923
|
headers: { 'content-type': 'application/json' },
|
|
647
924
|
...opts,
|
|
648
925
|
});
|
|
649
|
-
const body = await res.json().catch(() => ({
|
|
926
|
+
const body = await res.json().catch(() => ({
|
|
927
|
+
ok: false,
|
|
928
|
+
code: 'response-unreadable',
|
|
929
|
+
error: `FloLess received an unreadable response (HTTP ${res.status}).`,
|
|
930
|
+
}));
|
|
650
931
|
if (!res.ok || body.ok === false) {
|
|
651
932
|
// Centralised so EVERY caller that spawns `aware` reports the refusal honestly rather than
|
|
652
933
|
// showing the raw `aware_maintenance_busy` code. The server refuses instead of queuing
|
|
@@ -1145,11 +1426,17 @@
|
|
|
1145
1426
|
$kbInformed.hidden = true;
|
|
1146
1427
|
$kbInformedPages.innerHTML = '';
|
|
1147
1428
|
delete $kbInformed.dataset.kbProject;
|
|
1429
|
+
delete $kbInformed.dataset.kbGeneration;
|
|
1148
1430
|
return;
|
|
1149
1431
|
}
|
|
1150
1432
|
// The pin's own project, so the click handler opens the KB that actually informed this workflow
|
|
1151
1433
|
// rather than whichever project Workspaces happens to have open.
|
|
1152
1434
|
$kbInformed.dataset.kbProject = String(pin.projectId || '');
|
|
1435
|
+
// The GENERATION the pin recorded, so a citation opens the page as it read when this workflow was
|
|
1436
|
+
// built — not whatever an Organize pass has published since. The page route honours
|
|
1437
|
+
// `?generation=`; without this the click silently opened the CURRENT page on a drifted knowledge
|
|
1438
|
+
// base, which is the one place provenance must not guess.
|
|
1439
|
+
$kbInformed.dataset.kbGeneration = String(pin.generationId || '');
|
|
1153
1440
|
// Every value here is file-derived (a wiki page's own slug and title) and lands in innerHTML, so
|
|
1154
1441
|
// it is escaped exactly like the node/agent strings in buildAgentEntry above.
|
|
1155
1442
|
$kbInformedPages.innerHTML = pin.pages.map((pg, i) => {
|
|
@@ -1161,6 +1448,12 @@
|
|
|
1161
1448
|
const label = String(pg.title || slug);
|
|
1162
1449
|
const sep = i ? '<span class="kb-informed-sep">·</span>' : '';
|
|
1163
1450
|
return `${sep}<button type="button" class="kb-page-link" data-kb-slug="${escapeAttr(slug)}"`
|
|
1451
|
+
// Registered per cited page: `?` on a citation has to be able to say that it leaves Workflows
|
|
1452
|
+
// AND that the page it opens is the version this workflow was built from, which is the whole
|
|
1453
|
+
// point of the pin. The slug is the instance key, and it is data off a wiki file, so it is
|
|
1454
|
+
// escaped like every other value here.
|
|
1455
|
+
+ ` data-command-id="shell.kb-citation#${escapeAttr(slug)}"`
|
|
1456
|
+
+ ` data-command-instance-label="${escapeAttr(label)}"`
|
|
1164
1457
|
+ ` data-tip="Open “${escapeAttr(label)}” (${escapeAttr(slug)}) in the Knowledge Base"`
|
|
1165
1458
|
// The visible label alone does not say this leaves Workflows, and `data-tip` is a purely
|
|
1166
1459
|
// VISUAL tooltip (web/app.js wires no aria-describedby), so the full action goes in an
|
|
@@ -1478,12 +1771,13 @@
|
|
|
1478
1771
|
}
|
|
1479
1772
|
|
|
1480
1773
|
async function startInstructorAnswer(request, runtime, fingerprint) {
|
|
1774
|
+
activeInstructorRuns.set(fingerprint, request.id);
|
|
1775
|
+
renderInstructorAnswers({ revealNew: false });
|
|
1481
1776
|
try {
|
|
1482
1777
|
const res = await api(`/api/requests/${encodeURIComponent(request.id)}/run`, {
|
|
1483
1778
|
method: 'POST', body: JSON.stringify(runtime ? { runtime } : {}),
|
|
1484
1779
|
});
|
|
1485
1780
|
const chosen = (res.run && res.run.runtime) || runtime;
|
|
1486
|
-
activeInstructorRuns.set(fingerprint, request.id);
|
|
1487
1781
|
showToast(`Asked ${runtimeLabel(chosen)} — the answer will appear in AI answers`, 'ok');
|
|
1488
1782
|
await loadRequests();
|
|
1489
1783
|
return true;
|
|
@@ -1494,6 +1788,7 @@
|
|
|
1494
1788
|
? `Couldn’t start ${chosen}. Request queued and copied — paste it in your terminal.`
|
|
1495
1789
|
: `Couldn’t start ${chosen}. Request queued — open Requests to copy it.`, 'err');
|
|
1496
1790
|
try { await loadRequests(); } catch (refreshError) { console.error(refreshError); }
|
|
1791
|
+
activeInstructorRuns.delete(fingerprint);
|
|
1497
1792
|
return false;
|
|
1498
1793
|
}
|
|
1499
1794
|
}
|
|
@@ -1507,30 +1802,34 @@
|
|
|
1507
1802
|
const fingerprint = JSON.stringify(body);
|
|
1508
1803
|
const matchingPending = mode === 'direct' && pendingRequests.find((request) => {
|
|
1509
1804
|
if (request.type !== 'guide' || (request.run?.state !== 'queued' && request.run?.state !== 'running')) return false;
|
|
1510
|
-
|
|
1511
|
-
if (request.project) {
|
|
1512
|
-
storedBody.project = request.project;
|
|
1513
|
-
storedBody.projectLabel = request.projectLabel;
|
|
1514
|
-
storedBody.appId = request.appId;
|
|
1515
|
-
} else if (request.appId) storedBody.appId = request.appId;
|
|
1516
|
-
return JSON.stringify(storedBody) === fingerprint;
|
|
1805
|
+
return instructorRequestClientFingerprint(request) === fingerprint;
|
|
1517
1806
|
});
|
|
1518
1807
|
if (mode === 'direct' && (activeInstructorRuns.has(fingerprint) || matchingPending)) {
|
|
1519
1808
|
showToast('That answer is already running — watch Requests for progress', 'ok');
|
|
1520
1809
|
return true;
|
|
1521
1810
|
}
|
|
1522
1811
|
|
|
1812
|
+
if (mode === 'direct') beginOptimisticInstructorRequest(body, options.runtime, fingerprint);
|
|
1813
|
+
|
|
1523
1814
|
let request;
|
|
1524
1815
|
try {
|
|
1525
1816
|
({ request } = await api('/api/guide', { method: 'POST', body: JSON.stringify(body) }));
|
|
1526
1817
|
} catch (e) {
|
|
1818
|
+
settleOptimisticInstructorRequest(fingerprint);
|
|
1527
1819
|
console.error(e);
|
|
1528
1820
|
const reason = e && e.message ? ` — ${e.message}` : '';
|
|
1529
1821
|
showToast(`Couldn’t send this request${reason}`, 'err');
|
|
1530
1822
|
return false;
|
|
1531
1823
|
}
|
|
1532
1824
|
|
|
1533
|
-
|
|
1825
|
+
settleOptimisticInstructorRequest(fingerprint, request);
|
|
1826
|
+
|
|
1827
|
+
if (mode === 'direct') {
|
|
1828
|
+
// The durable question is visible now; run admission continues independently. The Ask control
|
|
1829
|
+
// must not sit on “Starting…” while Windows capability checks and workspace setup happen.
|
|
1830
|
+
void startInstructorAnswer(request, options.runtime, fingerprint);
|
|
1831
|
+
return true;
|
|
1832
|
+
}
|
|
1534
1833
|
|
|
1535
1834
|
// Delivery is already durable at this point. Clipboard and refresh are conveniences: neither
|
|
1536
1835
|
// may turn a successfully queued request into a false failure report.
|
|
@@ -2409,11 +2708,13 @@
|
|
|
2409
2708
|
// Append a first-class action button to a card (e.g. "View report ▸"). The
|
|
2410
2709
|
// click is self-contained: it stops the canvas/inspect handlers from also
|
|
2411
2710
|
// firing, then runs the action. Idempotent — callers clear stale buttons first.
|
|
2412
|
-
function addNodeAction(card, label, onClick) {
|
|
2711
|
+
function addNodeAction(card, label, onClick, commandId = null, commandInstanceLabel = null) {
|
|
2413
2712
|
const btn = document.createElement('button');
|
|
2414
2713
|
btn.type = 'button';
|
|
2415
2714
|
btn.className = 'node-action';
|
|
2416
2715
|
btn.textContent = label;
|
|
2716
|
+
if (commandId) btn.setAttribute('data-command-id', `${commandId}#${commandInstanceLabel || label.replace(/\s*▸$/, '')}`);
|
|
2717
|
+
if (commandInstanceLabel) btn.setAttribute('data-command-instance-label', commandInstanceLabel);
|
|
2417
2718
|
btn.addEventListener('click', (e) => {
|
|
2418
2719
|
e.stopPropagation();
|
|
2419
2720
|
e.preventDefault();
|
|
@@ -2555,7 +2856,9 @@
|
|
|
2555
2856
|
|
|
2556
2857
|
function addHostExportAction(card, appId, kind, label, busyLabel, onClick) {
|
|
2557
2858
|
const busy = exportActionBusy(appId, kind);
|
|
2558
|
-
const
|
|
2859
|
+
const instance = kind === 'tekla' ? 'Tekla' : 'IFC';
|
|
2860
|
+
const commandId = kind === 'tekla' ? 'shell.workflow-host-send' : 'shell.export-run';
|
|
2861
|
+
const btn = addNodeAction(card, busy ? busyLabel : label, onClick, commandId, instance);
|
|
2559
2862
|
btn.dataset.exportApp = appId;
|
|
2560
2863
|
btn.dataset.exportKind = kind;
|
|
2561
2864
|
if (busy) {
|
|
@@ -2747,7 +3050,6 @@
|
|
|
2747
3050
|
const rebakeInput = app && app.rebakeInput ? app.rebakeInput : null;
|
|
2748
3051
|
const cards = document.querySelectorAll('.agent-card');
|
|
2749
3052
|
const firstId = cards.length ? cards[0].dataset.agentId : null;
|
|
2750
|
-
let hasTeklaAction = false;
|
|
2751
3053
|
cards.forEach((card) => {
|
|
2752
3054
|
const id = card.dataset.agentId;
|
|
2753
3055
|
const isReport = !!rid && id === rid;
|
|
@@ -2808,16 +3110,11 @@
|
|
|
2808
3110
|
addNodeAction(card, 'Export BOM (CSV) ▸', () => exportContractBom(currentId, 'csv'));
|
|
2809
3111
|
addNodeAction(card, 'Export BOM (Excel) ▸', () => exportContractBom(currentId, 'xlsx'));
|
|
2810
3112
|
const teklaBtn = addHostExportAction(card, currentId, 'tekla', 'Send to Tekla ▸', 'Sending to Tekla…', () => exportContractTekla(currentId));
|
|
2811
|
-
// INSIDE the guard with the line it drives: `hasTeklaAction` is what triggers
|
|
2812
|
-
// refreshTeklaReadiness() after this loop, and in the publication state nothing renders the
|
|
2813
|
-
// result — the button is disabled either way. Left outside, selecting such a workflow fired a
|
|
2814
|
-
// real host probe and then a full repaint that changed nothing.
|
|
2815
|
-
if (!publication) hasTeklaAction = true;
|
|
2816
3113
|
// NO Tekla readiness line in the publication state. It renders into the SAME
|
|
2817
3114
|
// `.node-action-state` slot, so both lines would stack — and a green "Ready" sitting beside
|
|
2818
3115
|
// "you can't use these" contradicts it outright. Whether Tekla is running is not the reason
|
|
2819
3116
|
// this button cannot work, and it cannot work either way.
|
|
2820
|
-
if (!publication) {
|
|
3117
|
+
if (!publication && teklaReadinessState) {
|
|
2821
3118
|
const teklaState = addTeklaActionState(card);
|
|
2822
3119
|
const teklaBusy = exportActionBusy(currentId, 'tekla');
|
|
2823
3120
|
teklaBtn.disabled = !teklaBusy && !teklaState.ready;
|
|
@@ -2826,6 +3123,8 @@
|
|
|
2826
3123
|
: teklaState.ready
|
|
2827
3124
|
? 'Create native parts in the open Tekla model'
|
|
2828
3125
|
: teklaState.message;
|
|
3126
|
+
} else if (!publication) {
|
|
3127
|
+
teklaBtn.dataset.tip = 'Review the model, then create native parts in the open Tekla model';
|
|
2829
3128
|
}
|
|
2830
3129
|
addExportReceipt(card, currentId, 'tekla');
|
|
2831
3130
|
}
|
|
@@ -2857,7 +3156,6 @@
|
|
|
2857
3156
|
else if (!card.dataset.tip) card.dataset.tip = 'Double-click to open the Drawing Filter';
|
|
2858
3157
|
}
|
|
2859
3158
|
});
|
|
2860
|
-
if (hasTeklaAction && !teklaReadinessState) refreshTeklaReadiness();
|
|
2861
3159
|
}
|
|
2862
3160
|
|
|
2863
3161
|
// B3 "swap re-bakes": pick a new source drawing for a baked app and queue a
|
|
@@ -3441,10 +3739,33 @@
|
|
|
3441
3739
|
// `nofootprint:` member has an EXACT weight and no tabulated footprint, so it is priced in the
|
|
3442
3740
|
// BOM and missing from this view. Calling both "RFI" hid the second entirely (#627).
|
|
3443
3741
|
const skips = Array.isArray(res.skipped) ? res.skipped : [];
|
|
3444
|
-
|
|
3445
|
-
|
|
3742
|
+
// `skippedDetail` says WHY each member is missing. Without it every bare id was counted as
|
|
3743
|
+
// "no AISC size", which became a lie the moment a member could be left out for having no
|
|
3744
|
+
// HEIGHT instead — sending a detailer hunting a designation that is already correct, which is
|
|
3745
|
+
// the exact mislabel the approve gate spends twenty lines of comment refusing to make.
|
|
3746
|
+
// Falls back to the old prefix count when the field is absent, so an older server still reads.
|
|
3747
|
+
const detail = Array.isArray(res.skippedDetail) ? res.skippedDetail : null;
|
|
3748
|
+
const byReason = (reason) => detail ? detail.filter((row) => row && row.reason === reason).length : 0;
|
|
3749
|
+
const noFit = detail ? byReason('no-footprint') : skips.filter((s) => String(s).startsWith('nofootprint:')).length;
|
|
3750
|
+
const noHeight = byReason('unknown-elevation');
|
|
3751
|
+
const noFrame = byReason('unregistered-view');
|
|
3752
|
+
const noScale = byReason('view-scale-invalid');
|
|
3753
|
+
const conflict = byReason('cross-view-conflict');
|
|
3754
|
+
const mixedPlacement = byReason('placement-evidence-conflict');
|
|
3755
|
+
const rfi = detail
|
|
3756
|
+
? detail.length - noFit - noHeight - noFrame - noScale - conflict - mixedPlacement
|
|
3757
|
+
: skips.filter((s) => !SKIP_REASON_PREFIX.test(String(s))).length;
|
|
3446
3758
|
const parts = [];
|
|
3447
|
-
if (
|
|
3759
|
+
if (noHeight) parts.push(`${noHeight} with no known height — answer the elevation question`);
|
|
3760
|
+
if (noFrame) parts.push(`${noFrame} from an unregistered source view — review its registration question`);
|
|
3761
|
+
if (noScale) parts.push(`${noScale} from a source view with no valid scale — review its placement question`);
|
|
3762
|
+
if (conflict) parts.push(`${conflict} with source views that disagree on placement — review the conflicting traces`);
|
|
3763
|
+
if (mixedPlacement) parts.push(`${mixedPlacement} with invalid scale and conflicting placement evidence — review the source traces`);
|
|
3764
|
+
// "no resolved size", not "no AISC size": this shell renders UK models too, and AISC is the
|
|
3765
|
+
// American Institute of Steel Construction — naming it to someone modelling British steel points
|
|
3766
|
+
// them at the wrong standards body for their own designation. The shell has no contract in scope
|
|
3767
|
+
// to name the right one, so it names none, which is true in every environment.
|
|
3768
|
+
if (rfi) parts.push(`${rfi} with no resolved section size (RFI)`);
|
|
3448
3769
|
if (noFit) parts.push(`${noFit} priced but not drawn (no tabulated footprint)`);
|
|
3449
3770
|
$reportSub.textContent = (parts.length ? `${parts.join(', ')} — not shown. ` : '')
|
|
3450
3771
|
+ 'Live 3D view from the approved model — drag to orbit, scroll to zoom, click an element to inspect.';
|
|
@@ -3486,20 +3807,46 @@
|
|
|
3486
3807
|
// in two — an RFI member has no size, while a `nofootprint:` member has an exact weight and no
|
|
3487
3808
|
// tabulated footprint, so the BOM prices steel this .ifc does not contain. Label each honestly;
|
|
3488
3809
|
// the second used to be reported as an RFI, which is the one thing it is not (#627).
|
|
3489
|
-
|
|
3490
|
-
|
|
3810
|
+
// `skippedDetail` says WHY, exactly as the 3D route already reports it (#1156a). Until this
|
|
3811
|
+
// export stopped refusing an unknown endpoint elevation, every bare id here really was a
|
|
3812
|
+
// member with no size; now it is not, and counting one as the other sends a detailer hunting
|
|
3813
|
+
// a designation that is already correct. Falls back to the prefix count for an older server.
|
|
3814
|
+
const detail = Array.isArray(res.skippedDetail) ? res.skippedDetail : null;
|
|
3815
|
+
const byReason = (reason) => detail ? detail.filter((row) => row && row.reason === reason).length : 0;
|
|
3816
|
+
const noFit = detail ? byReason('no-footprint') : skips.filter((s) => String(s).startsWith('nofootprint:')).length;
|
|
3817
|
+
const noHeight = byReason('unknown-elevation');
|
|
3818
|
+
const noFrame = byReason('unregistered-view');
|
|
3819
|
+
const noScale = byReason('view-scale-invalid');
|
|
3820
|
+
const conflict = byReason('cross-view-conflict');
|
|
3821
|
+
const mixedPlacement = byReason('placement-evidence-conflict');
|
|
3822
|
+
const rfi = detail
|
|
3823
|
+
? detail.length - noFit - noHeight - noFrame - noScale - conflict - mixedPlacement
|
|
3824
|
+
: skips.filter((s) => !SKIP_REASON_PREFIX.test(String(s))).length;
|
|
3491
3825
|
const notes = [];
|
|
3492
3826
|
if (isVector) { if (dropped) notes.push(`${dropped} unplaced`); }
|
|
3493
3827
|
else {
|
|
3828
|
+
// Same wording as the 3D toast, deliberately: the two describe the same members of the same
|
|
3829
|
+
// document, and two sentences for one fact is how a user learns to distrust both.
|
|
3830
|
+
if (noHeight) notes.push(`${noHeight} with no known height — answer the elevation question`);
|
|
3831
|
+
if (noFrame) notes.push(`${noFrame} from an unregistered source view`);
|
|
3832
|
+
if (noScale) notes.push(`${noScale} from a source view with no valid scale`);
|
|
3833
|
+
if (conflict) notes.push(`${conflict} with source views that disagree on placement`);
|
|
3834
|
+
if (mixedPlacement) notes.push(`${mixedPlacement} with invalid scale and conflicting placement evidence`);
|
|
3494
3835
|
if (rfi) notes.push(`${rfi} RFI member${rfi === 1 ? '' : 's'}`);
|
|
3495
3836
|
if (noFit) notes.push(`${noFit} member${noFit === 1 ? '' : 's'} priced but not exported (no tabulated footprint)`);
|
|
3496
3837
|
}
|
|
3497
3838
|
if (res.extrusionsSkipped) notes.push(`${res.extrusionsSkipped} extruded ${res.extrusionsSkipped === 1 ? 'body' : 'bodies'} (view-only)`);
|
|
3498
3839
|
const summary = exportReceiptText(appId, 'ifc');
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3840
|
+
// COMPOSED, never alternated. This used to show the receipt summary INSTEAD of the notes
|
|
3841
|
+
// whenever the receipt was partial — so a model that was both partially emitted by AWARE and
|
|
3842
|
+
// missing members here reported only the first, and the omission vanished from the one
|
|
3843
|
+
// message whose job is to stop members going missing quietly.
|
|
3844
|
+
const gaps = [summary && summary.partial ? summary.text : null, notes.length ? notes.join(', ') + ' skipped' : null]
|
|
3845
|
+
.filter(Boolean).join(' · ');
|
|
3846
|
+
showToast(gaps
|
|
3847
|
+
? `IFC exported with gaps — ${gaps}`
|
|
3848
|
+
: `IFC downloaded — ${res.filename || appId + '.ifc'}`,
|
|
3849
|
+
gaps ? 'warn' : 'ok');
|
|
3503
3850
|
} catch (e) {
|
|
3504
3851
|
// A receipt describes the attempt the user just made. Keeping the prior session receipt here
|
|
3505
3852
|
// would make a failed re-export look successful, even though the durable file stays untouched.
|
|
@@ -3544,33 +3891,199 @@
|
|
|
3544
3891
|
return out;
|
|
3545
3892
|
}
|
|
3546
3893
|
|
|
3894
|
+
const activeAppHostBakeConsents = new Map();
|
|
3895
|
+
const hostBakeReviewStale = (body) => body && [
|
|
3896
|
+
'host-bake-confirmation-stale', 'host-bake-preflight-required', 'stale-selection',
|
|
3897
|
+
].includes(body.code);
|
|
3898
|
+
|
|
3899
|
+
function releaseAppHostBakeConsentsOnPageHide() {
|
|
3900
|
+
for (const [token, appId] of activeAppHostBakeConsents) {
|
|
3901
|
+
fetch('/api/apps/' + encodeURIComponent(appId) + '/host-bake-consent', {
|
|
3902
|
+
method: 'DELETE', keepalive: true,
|
|
3903
|
+
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
3904
|
+
}).catch(() => {});
|
|
3905
|
+
}
|
|
3906
|
+
activeAppHostBakeConsents.clear();
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
async function cancelAppHostBakeConsent(appId, token) {
|
|
3910
|
+
if (!token) return;
|
|
3911
|
+
try {
|
|
3912
|
+
await api('/api/apps/' + encodeURIComponent(appId) + '/host-bake-consent', {
|
|
3913
|
+
method: 'DELETE',
|
|
3914
|
+
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
3915
|
+
});
|
|
3916
|
+
} catch (_) { /* best effort; the server-side expiry remains authoritative */ }
|
|
3917
|
+
finally { activeAppHostBakeConsents.delete(token); }
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3920
|
+
async function acknowledgeAppHostBakeConsent(appId, token) {
|
|
3921
|
+
if (!token) return;
|
|
3922
|
+
try {
|
|
3923
|
+
await fetch('/api/apps/' + encodeURIComponent(appId) + '/host-bake-consent/acknowledge', {
|
|
3924
|
+
method: 'POST',
|
|
3925
|
+
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
3926
|
+
body: '{}',
|
|
3927
|
+
});
|
|
3928
|
+
} catch (_) { /* a lost acknowledgement deliberately leaves the replay tombstone in place */ }
|
|
3929
|
+
finally { activeAppHostBakeConsents.delete(token); }
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3932
|
+
async function confirmHostBakeReview(review, hostLabel, forceCleanPrompt = false) {
|
|
3933
|
+
const omitted = review.counts && Number(review.counts.omitted) || 0;
|
|
3934
|
+
if (review.kind === 'clean' && !forceCleanPrompt) return true;
|
|
3935
|
+
const selection = review.mode === 'selection';
|
|
3936
|
+
const title = review.kind === 'clean'
|
|
3937
|
+
? 'Model changed—send the latest model?'
|
|
3938
|
+
: `${selection ? 'Send selection' : 'Send'} with ${omitted} member${omitted === 1 ? '' : 's'} left out?`;
|
|
3939
|
+
const sub = review.kind === 'clean'
|
|
3940
|
+
? `The reviewed model changed. FloLess checked the latest version and found no omissions for ${hostLabel}.`
|
|
3941
|
+
: selection
|
|
3942
|
+
? `The rest can be sent to ${hostLabel}. This cannot remove parts owned by earlier sends or the whole-model source.`
|
|
3943
|
+
: `The rest can be sent to ${hostLabel}. Previously baked parts for the members below may be removed from the open model.`;
|
|
3944
|
+
const result = await formModal({
|
|
3945
|
+
title,
|
|
3946
|
+
sub,
|
|
3947
|
+
fields: omitted > 0 ? [{
|
|
3948
|
+
name: 'host-bake-omissions',
|
|
3949
|
+
type: 'omissions',
|
|
3950
|
+
label: 'Members left out',
|
|
3951
|
+
rows: review.skippedDetail || [],
|
|
3952
|
+
commandId: 'shell.host-bake-omissions',
|
|
3953
|
+
}] : [],
|
|
3954
|
+
okLabel: 'Continue',
|
|
3955
|
+
okCommandId: 'shell.host-send-continue',
|
|
3956
|
+
okCommandInstanceLabel: hostLabel,
|
|
3957
|
+
cancelCommandInstanceLabel: 'the CAD send review',
|
|
3958
|
+
danger: !selection && omitted > 0,
|
|
3959
|
+
safeDefault: true,
|
|
3960
|
+
modalState: forceCleanPrompt ? 'stale' : 'review',
|
|
3961
|
+
modalMode: selection ? 'selection' : 'whole',
|
|
3962
|
+
});
|
|
3963
|
+
return result != null;
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
async function showHostBakeEmptyReview(review, hostLabel) {
|
|
3967
|
+
await formModal({
|
|
3968
|
+
title: 'Nothing in this model can be sent',
|
|
3969
|
+
sub: `Every member is unresolved. Nothing was sent to ${hostLabel}.`,
|
|
3970
|
+
fields: [{
|
|
3971
|
+
name: 'host-bake-omissions',
|
|
3972
|
+
type: 'omissions',
|
|
3973
|
+
label: 'Members left out',
|
|
3974
|
+
rows: review.skippedDetail || [],
|
|
3975
|
+
commandId: 'shell.host-bake-omissions',
|
|
3976
|
+
}],
|
|
3977
|
+
okLabel: 'Close',
|
|
3978
|
+
okCommandId: 'shell.dialog-close',
|
|
3979
|
+
okCommandInstanceLabel: 'the host-send review',
|
|
3980
|
+
cancelCommandInstanceLabel: 'the CAD send review',
|
|
3981
|
+
hideCancel: true,
|
|
3982
|
+
modalState: 'review',
|
|
3983
|
+
modalMode: review.mode === 'selection' ? 'selection' : 'whole',
|
|
3984
|
+
});
|
|
3985
|
+
}
|
|
3986
|
+
|
|
3987
|
+
function hostBakeSuccessText(result, hostLabel) {
|
|
3988
|
+
const counts = result && result.reviewCounts;
|
|
3989
|
+
if (!counts || !counts.omitted) return result.message || `Sent to ${hostLabel}.`;
|
|
3990
|
+
const rows = Array.isArray(result.skippedDetail) ? result.skippedDetail : [];
|
|
3991
|
+
const labels = {
|
|
3992
|
+
'unknown-elevation': 'no known height',
|
|
3993
|
+
'unknown-profile': 'no resolved section size',
|
|
3994
|
+
'no-footprint': 'no tabulated cross-section',
|
|
3995
|
+
unplaceable: 'geometry that could not be placed',
|
|
3996
|
+
'unregistered-view': 'an unregistered source view',
|
|
3997
|
+
'view-scale-invalid': 'no valid drawing scale',
|
|
3998
|
+
'cross-view-conflict': 'conflicting drawing views',
|
|
3999
|
+
'placement-evidence-conflict': 'conflicting placement evidence',
|
|
4000
|
+
};
|
|
4001
|
+
const grouped = {};
|
|
4002
|
+
rows.forEach((row) => { grouped[row.reason] = (grouped[row.reason] || 0) + 1; });
|
|
4003
|
+
const reasons = Object.entries(grouped).map(([reason, count]) => `${count} with ${labels[reason] || 'an unresolved placement'}`);
|
|
4004
|
+
return `Sent ${counts.buildable} of ${counts.requested} members to ${hostLabel} — left out ${reasons.join(' and ') || counts.omitted + ' members'}.`;
|
|
4005
|
+
}
|
|
4006
|
+
|
|
3547
4007
|
// Send to Tekla ▸ — create native parts in the OPEN Tekla model from the approved model. Needs
|
|
3548
4008
|
// Tekla running with a model; when it's not, the server returns a clear needsTekla state (api()
|
|
3549
4009
|
// throws with err.body.needsTekla) — surfaced as an informational nudge, not a hard error.
|
|
3550
4010
|
async function exportContractTekla(appId) {
|
|
3551
4011
|
if (exportActionBusy(appId, 'tekla')) return;
|
|
3552
4012
|
setExportActionBusy(appId, 'tekla', true);
|
|
3553
|
-
showToast('
|
|
4013
|
+
showToast('Checking what will be sent to Tekla…', 'info');
|
|
4014
|
+
let hostRequestStage = 'idle';
|
|
3554
4015
|
try {
|
|
3555
|
-
const
|
|
4016
|
+
const endpoint = '/api/contract/' + encodeURIComponent(appId) + '/export-tekla';
|
|
4017
|
+
let forceCleanPrompt = false;
|
|
4018
|
+
let res;
|
|
4019
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
4020
|
+
let review;
|
|
4021
|
+
try {
|
|
4022
|
+
hostRequestStage = 'preflight';
|
|
4023
|
+
review = await api(endpoint, { method: 'POST', body: JSON.stringify({ preflight: true }) });
|
|
4024
|
+
hostRequestStage = 'idle';
|
|
4025
|
+
activeAppHostBakeConsents.set(review.consent, appId);
|
|
4026
|
+
} catch (error) {
|
|
4027
|
+
if (error && error.body && error.body.code === 'host-bake-empty') {
|
|
4028
|
+
await showHostBakeEmptyReview(error.body, 'Tekla');
|
|
4029
|
+
return;
|
|
4030
|
+
}
|
|
4031
|
+
throw error;
|
|
4032
|
+
}
|
|
4033
|
+
const confirmed = await confirmHostBakeReview(review, 'Tekla', forceCleanPrompt);
|
|
4034
|
+
if (!confirmed) {
|
|
4035
|
+
await cancelAppHostBakeConsent(appId, review.consent);
|
|
4036
|
+
showToast('Send to Tekla cancelled.', 'info');
|
|
4037
|
+
return;
|
|
4038
|
+
}
|
|
4039
|
+
showToast('Sending to Tekla…', 'info');
|
|
4040
|
+
try {
|
|
4041
|
+
hostRequestStage = 'continuation';
|
|
4042
|
+
res = await api(endpoint, {
|
|
4043
|
+
method: 'POST',
|
|
4044
|
+
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': review.consent },
|
|
4045
|
+
body: JSON.stringify({}),
|
|
4046
|
+
});
|
|
4047
|
+
hostRequestStage = 'idle';
|
|
4048
|
+
await acknowledgeAppHostBakeConsent(appId, review.consent);
|
|
4049
|
+
break;
|
|
4050
|
+
} catch (error) {
|
|
4051
|
+
if (attempt === 0 && error && hostBakeReviewStale(error.body)) {
|
|
4052
|
+
await cancelAppHostBakeConsent(appId, review.consent);
|
|
4053
|
+
forceCleanPrompt = true;
|
|
4054
|
+
showToast('The model changed. Checking the latest version…', 'info');
|
|
4055
|
+
continue;
|
|
4056
|
+
}
|
|
4057
|
+
activeAppHostBakeConsents.delete(review.consent);
|
|
4058
|
+
throw error;
|
|
4059
|
+
}
|
|
4060
|
+
}
|
|
4061
|
+
if (!res) return;
|
|
3556
4062
|
if (res.counts) exportReceiptsByApp.set(exportReceiptKey(appId, 'tekla'), {
|
|
3557
4063
|
counts: res.counts,
|
|
3558
4064
|
warnings: res.warnings || [],
|
|
3559
4065
|
unsupported: res.receipt && Array.isArray(res.receipt.unsupported) ? res.receipt.unsupported : [],
|
|
3560
4066
|
});
|
|
3561
4067
|
const summary = exportReceiptText(appId, 'tekla');
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
summary && summary.partial ? 'warn' : 'ok');
|
|
4068
|
+
const omissionText = hostBakeSuccessText(res, 'Tekla');
|
|
4069
|
+
const partial = !!(res.reviewCounts && res.reviewCounts.omitted) || !!(summary && summary.partial);
|
|
4070
|
+
showToast(partial ? omissionText : (res.message || 'Baked into the Tekla model.'), partial ? 'warn' : 'ok');
|
|
3566
4071
|
} catch (e) {
|
|
3567
4072
|
// Do not leave counts from an earlier successful send attached to this failed attempt.
|
|
3568
4073
|
exportReceiptsByApp.delete(exportReceiptKey(appId, 'tekla'));
|
|
3569
4074
|
const needsTekla = e && e.body && e.body.needsTekla;
|
|
4075
|
+
const transportLost = (e instanceof TypeError && /failed to fetch|networkerror|load failed/i.test(e.message || ''))
|
|
4076
|
+
|| (e && e.body && e.body.code === 'response-unreadable');
|
|
4077
|
+
const responseLost = hostRequestStage === 'continuation' && transportLost;
|
|
4078
|
+
const reviewLost = hostRequestStage === 'preflight' && transportLost;
|
|
3570
4079
|
if (e && e.body && e.body.readiness) {
|
|
3571
4080
|
teklaReadinessState = e.body.readiness;
|
|
3572
4081
|
}
|
|
3573
|
-
showToast(
|
|
4082
|
+
showToast(responseLost
|
|
4083
|
+
? 'FloLess lost the Tekla response after dispatch. Check the open model before sending again.'
|
|
4084
|
+
: reviewLost
|
|
4085
|
+
? 'FloLess couldn’t finish reviewing the Tekla send. Nothing was sent; try the review again.'
|
|
4086
|
+
: (e && e.message ? e.message : String(e)), needsTekla ? 'info' : 'warn');
|
|
3574
4087
|
} finally {
|
|
3575
4088
|
setExportActionBusy(appId, 'tekla', false);
|
|
3576
4089
|
}
|
|
@@ -4028,7 +4541,7 @@
|
|
|
4028
4541
|
// `onChange(values) -> string` makes the dialog able to answer a question no static label can:
|
|
4029
4542
|
// one whose answer DEPENDS on the choices (five viewpoints cost five times one). Its return value
|
|
4030
4543
|
// becomes the footnote line under the fields. Optional — dialogs that don't pass it are unchanged.
|
|
4031
|
-
function formModal({ title, sub = '', fields, okLabel = 'Save', danger = false, hideCancel = false, returnFocusTo = null, returnFocusFallback = null, footnote = '', onChange = null }) {
|
|
4544
|
+
function formModal({ title, sub = '', fields, okLabel = 'Save', okCommandId = null, okCommandInstanceLabel = null, cancelCommandInstanceLabel = null, danger = false, safeDefault = false, hideCancel = false, hideOk = false, returnFocusTo = null, returnFocusFallback = null, footnote = '', onChange = null, modalState = null, modalMode = null }) {
|
|
4032
4545
|
return new Promise((resolve) => {
|
|
4033
4546
|
if (_formModalOpen) { console.warn('formModal: a modal is already open — refusing re-entry'); resolve(null); return; }
|
|
4034
4547
|
const returnFocus = returnFocusTo instanceof HTMLElement
|
|
@@ -4045,6 +4558,10 @@
|
|
|
4045
4558
|
.filter((modal) => modal !== $formModal)
|
|
4046
4559
|
.map((modal) => ({ modal, inert: !!modal.inert, ariaHidden: modal.getAttribute('aria-hidden') }));
|
|
4047
4560
|
$title.textContent = title;
|
|
4561
|
+
if (modalState) $formModal.dataset.state = modalState;
|
|
4562
|
+
else delete $formModal.dataset.state;
|
|
4563
|
+
if (modalMode) $formModal.dataset.mode = modalMode;
|
|
4564
|
+
else delete $formModal.dataset.mode;
|
|
4048
4565
|
$sub.textContent = sub || '';
|
|
4049
4566
|
$sub.hidden = !sub;
|
|
4050
4567
|
if (sub) $formModal.setAttribute('aria-describedby', 'form-modal-sub');
|
|
@@ -4075,6 +4592,32 @@
|
|
|
4075
4592
|
if (f.type === 'note') {
|
|
4076
4593
|
return `<div class="modal-field"><div class="fm-note-label" id="${id}-label">${escapeHtml(f.label || f.name)}</div><pre class="fm-note" id="${id}" role="region" tabindex="0" aria-labelledby="${id}-label">${escapeHtml(val)}</pre></div>`;
|
|
4077
4594
|
}
|
|
4595
|
+
if (f.type === 'omissions') {
|
|
4596
|
+
const rows = Array.isArray(f.rows) ? f.rows : [];
|
|
4597
|
+
const reasonText = {
|
|
4598
|
+
'unknown-elevation': 'No known height',
|
|
4599
|
+
'unknown-profile': 'No resolved section size',
|
|
4600
|
+
'no-footprint': 'No tabulated cross-section',
|
|
4601
|
+
'unplaceable': 'Geometry could not be placed',
|
|
4602
|
+
'unregistered-view': 'Source view is not registered to the model',
|
|
4603
|
+
'view-scale-invalid': 'Source view has no valid drawing scale',
|
|
4604
|
+
'cross-view-conflict': 'Source views disagree on placement',
|
|
4605
|
+
'placement-evidence-conflict': 'Invalid scale and conflicting placement evidence',
|
|
4606
|
+
'not-in-model': 'No longer in the model',
|
|
4607
|
+
};
|
|
4608
|
+
const groups = new Map();
|
|
4609
|
+
rows.forEach((row) => {
|
|
4610
|
+
const reason = reasonText[row.reason] || 'Could not be built';
|
|
4611
|
+
if (!groups.has(reason)) groups.set(reason, []);
|
|
4612
|
+
groups.get(reason).push(row);
|
|
4613
|
+
});
|
|
4614
|
+
const grouped = [...groups.entries()]
|
|
4615
|
+
.sort((a, b) => b[1].length - a[1].length || a[0].localeCompare(b[0]))
|
|
4616
|
+
.map(([reason, members]) => `<section class="fm-omission-group"><h4>${escapeHtml(reason)} <span>${members.length}</span></h4><ul>${members.map((row) => `<li data-member-id="${escapeAttr(row.memberId)}" data-reason="${escapeAttr(row.reason)}">${escapeHtml(row.memberId)}</li>`).join('')}</ul></section>`)
|
|
4617
|
+
.join('');
|
|
4618
|
+
const command = f.commandId === 'shell.host-bake-omissions' ? ' data-command-id="shell.host-bake-omissions"' : '';
|
|
4619
|
+
return `<div class="modal-field fm-omissions-field"><div class="fm-note-label" id="${id}-label">${escapeHtml(f.label || 'Members left out')}</div><div class="fm-omissions" id="${id}" role="region" tabindex="0" aria-labelledby="${id}-label"${command}>${grouped}</div></div>`;
|
|
4620
|
+
}
|
|
4078
4621
|
// Read-only "what's currently loaded" context row (e.g. the source drawing already
|
|
4079
4622
|
// baked into a re-bake app). Inert — a muted label + glyph + filename, not a field.
|
|
4080
4623
|
if (f.type === 'current') {
|
|
@@ -4164,13 +4707,24 @@
|
|
|
4164
4707
|
`<div class="fm-footnote" data-fm-footnote role="status" aria-live="polite"${footnote ? '' : ' hidden'}>${escapeHtml(footnote)}</div>`);
|
|
4165
4708
|
}
|
|
4166
4709
|
$ok.textContent = okLabel;
|
|
4710
|
+
const allowedOkCommand = okCommandId === 'shell.host-send-continue' || okCommandId === 'shell.dialog-close';
|
|
4711
|
+
$ok.setAttribute('data-command-id', allowedOkCommand
|
|
4712
|
+
? `${okCommandId}#${okCommandInstanceLabel || 'the dialog'}`
|
|
4713
|
+
: 'shell.form-submit');
|
|
4714
|
+
if (allowedOkCommand && okCommandInstanceLabel) {
|
|
4715
|
+
$ok.setAttribute('data-command-instance-label', okCommandInstanceLabel);
|
|
4716
|
+
} else $ok.removeAttribute('data-command-instance-label');
|
|
4717
|
+
$cancel.setAttribute('data-command-id', `shell.dialog-cancel#${cancelCommandInstanceLabel || 'the form'}`);
|
|
4718
|
+
if (cancelCommandInstanceLabel) $cancel.setAttribute('data-command-instance-label', cancelCommandInstanceLabel);
|
|
4719
|
+
else $cancel.removeAttribute('data-command-instance-label');
|
|
4167
4720
|
// A destructive confirm flips the emphasis: the commit button is neutral→red
|
|
4168
4721
|
// (.danger) and the SAFE Cancel becomes the accent primary + gets focus, so a
|
|
4169
4722
|
// stray Enter never deletes (#85).
|
|
4170
4723
|
$ok.classList.toggle('danger', !!danger);
|
|
4171
|
-
$ok.classList.toggle('primary', !danger);
|
|
4172
|
-
$cancel.classList.toggle('primary', !!danger);
|
|
4724
|
+
$ok.classList.toggle('primary', !danger && !safeDefault);
|
|
4725
|
+
$cancel.classList.toggle('primary', !!danger || !!safeDefault);
|
|
4173
4726
|
$cancel.hidden = !!hideCancel;
|
|
4727
|
+
$ok.hidden = !!hideOk;
|
|
4174
4728
|
coveredModals.forEach(({ modal }) => {
|
|
4175
4729
|
modal.inert = true;
|
|
4176
4730
|
modal.setAttribute('aria-hidden', 'true');
|
|
@@ -4195,7 +4749,7 @@
|
|
|
4195
4749
|
|| $body.querySelector('.fm-select-trigger:not([disabled])')
|
|
4196
4750
|
|| $body.querySelector('.fm-files .fm-drop, .fm-file .fm-drop, .fm-images .fm-drop');
|
|
4197
4751
|
if (first) { first.focus(); if (first.select) first.select(); }
|
|
4198
|
-
else if (danger && !hideCancel) $cancel.focus();
|
|
4752
|
+
else if ((danger || safeDefault) && !hideCancel) $cancel.focus();
|
|
4199
4753
|
else $ok.focus();
|
|
4200
4754
|
// OK-gate probes: required consent checks (below) AND required multi-file fields must be
|
|
4201
4755
|
// satisfied. Declared here so the fm-files setup can re-run the gate; wired after all setups.
|
|
@@ -4627,7 +5181,9 @@
|
|
|
4627
5181
|
else modal.setAttribute('aria-hidden', ariaHidden);
|
|
4628
5182
|
});
|
|
4629
5183
|
$ok.onclick = null; $cancel.onclick = null; $formModal.onclick = null; $formModal.onkeydown = null; $body.onpaste = null; $body.onclick = null; $body.ondragover = null; $body.ondrop = null;
|
|
4630
|
-
$ok.classList.remove('danger'); $ok.classList.add('primary'); $cancel.classList.remove('primary'); $cancel.hidden = false; $ok.disabled = false; // reset chrome for the next caller
|
|
5184
|
+
$ok.classList.remove('danger'); $ok.classList.add('primary'); $cancel.classList.remove('primary'); $cancel.hidden = false; $ok.hidden = false; $ok.disabled = false; $cancel.setAttribute('data-command-id', 'shell.dialog-cancel#the form'); $cancel.removeAttribute('data-command-instance-label'); // reset chrome for the next caller
|
|
5185
|
+
$ok.setAttribute('data-command-id', 'shell.form-submit'); $ok.removeAttribute('data-command-instance-label');
|
|
5186
|
+
delete $formModal.dataset.state; delete $formModal.dataset.mode;
|
|
4631
5187
|
let focusTarget = returnFocus;
|
|
4632
5188
|
if ((!focusTarget || !focusTarget.isConnected) && typeof returnFocusFallback === 'function') {
|
|
4633
5189
|
focusTarget = returnFocusFallback();
|
|
@@ -4665,7 +5221,7 @@
|
|
|
4665
5221
|
// bridge" button and pressed Enter did not install anything — they submitted the dialog and
|
|
4666
5222
|
// sent the model. Cancel had the same problem, and answered Save. Buttons and checkboxes
|
|
4667
5223
|
// handle their own keys; let them.
|
|
4668
|
-
else if (e.key === 'Enter' && !danger && !$ok.disabled
|
|
5224
|
+
else if (e.key === 'Enter' && !danger && !safeDefault && !$ok.disabled
|
|
4669
5225
|
&& e.target.tagName !== 'TEXTAREA'
|
|
4670
5226
|
&& e.target.tagName !== 'BUTTON'
|
|
4671
5227
|
&& e.target.getAttribute('role') !== 'button'
|
|
@@ -6134,6 +6690,41 @@
|
|
|
6134
6690
|
const AWARE_RECOVERY_PILL = 'AWARE update needs finishing';
|
|
6135
6691
|
const AWARE_RECOVERY_PILL_TIP = "An earlier AWARE update didn't finish — open this to pick it up";
|
|
6136
6692
|
|
|
6693
|
+
// Once a runtime update reaches partial/retrying, the only remaining action is bridge work.
|
|
6694
|
+
// Keep the server's immutable operation on the transaction, but present the action truthfully.
|
|
6695
|
+
const awarePresentationOperation = (state, operation) => {
|
|
6696
|
+
if (!state) return operation;
|
|
6697
|
+
if (state.status === 'partial' || state.status === 'retrying') return 'bridge-repair';
|
|
6698
|
+
if (state.status === 'runtime-failed' && state.error && state.error.code === 'bridge-pending-failed') {
|
|
6699
|
+
return 'bridge-repair';
|
|
6700
|
+
}
|
|
6701
|
+
if (state.status === 'runtime-failed' && state.error && state.error.code === 'marker-clear-failed') {
|
|
6702
|
+
return 'maintenance-recovery';
|
|
6703
|
+
}
|
|
6704
|
+
return operation;
|
|
6705
|
+
};
|
|
6706
|
+
|
|
6707
|
+
function paintAwareBusyPill(state, operation) {
|
|
6708
|
+
if (!$awareUpdate) return;
|
|
6709
|
+
operation = awarePresentationOperation(state, operation);
|
|
6710
|
+
$awareUpdate.textContent = state.status === 'retrying'
|
|
6711
|
+
? 'Retrying bridge…'
|
|
6712
|
+
: operation === 'bridge-repair' ? 'Repairing installed bridges…'
|
|
6713
|
+
: operation === 'maintenance-recovery' ? 'Finishing AWARE update…'
|
|
6714
|
+
: '↑ Upgrading AWARE…';
|
|
6715
|
+
$awareUpdate.dataset.operation = operation;
|
|
6716
|
+
if (operation === 'maintenance-recovery') {
|
|
6717
|
+
$awareUpdate.dataset.commandId = 'shell.aware-update-finish';
|
|
6718
|
+
$awareUpdate.dataset.tip = AWARE_RECOVERY_PILL_TIP;
|
|
6719
|
+
return;
|
|
6720
|
+
}
|
|
6721
|
+
const bridgeWork = state.status === 'retrying' || operation === 'bridge-repair';
|
|
6722
|
+
$awareUpdate.dataset.commandId = bridgeWork ? 'shell.aware-bridge-repair' : 'shell.aware-update';
|
|
6723
|
+
$awareUpdate.dataset.tip = bridgeWork
|
|
6724
|
+
? 'Repair installed bridges that do not match AWARE'
|
|
6725
|
+
: "What's new in v" + (state.target || '');
|
|
6726
|
+
}
|
|
6727
|
+
|
|
6137
6728
|
function paintAwareAttentionPill() {
|
|
6138
6729
|
if (!$awareUpdate) return;
|
|
6139
6730
|
// The KIND is derived here rather than passed in, so this stays the single painter and every
|
|
@@ -6145,16 +6736,20 @@
|
|
|
6145
6736
|
// said "this needs attention" for a recovery while the painter said "bridges", and a refused
|
|
6146
6737
|
// start — which carried no operation — landed on the bridge label every time.
|
|
6147
6738
|
const recovery = !!live && live.status === 'runtime-failed'
|
|
6148
|
-
&& (live.operation || awareUpgradeOperation) === 'maintenance-recovery';
|
|
6739
|
+
&& awarePresentationOperation(live, live.operation || awareUpgradeOperation) === 'maintenance-recovery';
|
|
6740
|
+
const pendingCorrupt = !!live && live.status === 'runtime-failed'
|
|
6741
|
+
&& live.error && live.error.code === 'bridge-pending-corrupt';
|
|
6149
6742
|
$awareUpdate.hidden = false;
|
|
6150
6743
|
$awareUpdate.disabled = false;
|
|
6151
6744
|
// No ↑ on either: that glyph means "a runtime upgrade is on offer", and neither of these is one.
|
|
6152
6745
|
// The command id moves with the label, or Instructor narrates the wrong job from the registry.
|
|
6153
|
-
$awareUpdate.dataset.commandId = recovery ? 'shell.aware-update-finish' : 'shell.aware-
|
|
6746
|
+
$awareUpdate.dataset.commandId = recovery ? 'shell.aware-update-finish' : 'shell.aware-bridge-repair';
|
|
6154
6747
|
$awareUpdate.textContent = recovery ? AWARE_RECOVERY_PILL : 'Installed bridges need attention';
|
|
6155
6748
|
$awareUpdate.dataset.tip = recovery
|
|
6156
6749
|
? AWARE_RECOVERY_PILL_TIP
|
|
6157
|
-
:
|
|
6750
|
+
: pendingCorrupt
|
|
6751
|
+
? 'FloLess cannot read its saved bridge-repair state — open for details'
|
|
6752
|
+
: 'A bridge repair did not finish — open it to see which bridge and try again';
|
|
6158
6753
|
$awareUpdate.setAttribute('aria-haspopup', 'dialog');
|
|
6159
6754
|
}
|
|
6160
6755
|
|
|
@@ -6172,7 +6767,8 @@
|
|
|
6172
6767
|
*/
|
|
6173
6768
|
const awareNeedsAttention = (s) => !!s && (s.status === 'partial'
|
|
6174
6769
|
|| (s.status === 'runtime-failed'
|
|
6175
|
-
&& ['bridge-repair', 'maintenance-recovery'].includes(
|
|
6770
|
+
&& ['bridge-repair', 'maintenance-recovery'].includes(
|
|
6771
|
+
awarePresentationOperation(s, s.operation || awareUpgradeOperation))));
|
|
6176
6772
|
|
|
6177
6773
|
/**
|
|
6178
6774
|
* True when the live job state owns the pill and this generic re-check must keep its hands off.
|
|
@@ -6216,7 +6812,7 @@
|
|
|
6216
6812
|
$awareUpdate.hidden = false;
|
|
6217
6813
|
} else if (r.ok && d.updateAvailable && d.targetVersion && d.operation === 'bridge-repair') {
|
|
6218
6814
|
const count = Array.isArray(d.bridges) ? d.bridges.filter((row) => row.status !== 'current').length : 0;
|
|
6219
|
-
$awareUpdate.dataset.commandId = 'shell.aware-
|
|
6815
|
+
$awareUpdate.dataset.commandId = 'shell.aware-bridge-repair';
|
|
6220
6816
|
$awareUpdate.textContent = `Repair ${count || ''} installed bridge${count === 1 ? '' : 's'}`.replace(' ', ' ');
|
|
6221
6817
|
$awareUpdate.dataset.target = d.targetVersion;
|
|
6222
6818
|
$awareUpdate.dataset.operation = 'bridge-repair';
|
|
@@ -6443,7 +7039,7 @@
|
|
|
6443
7039
|
const status = s.status || 'idle';
|
|
6444
7040
|
const target = s.target || awareUpgradeTarget || '';
|
|
6445
7041
|
if (target) awareUpgradeTarget = target;
|
|
6446
|
-
const operation = s.operation || awareUpgradeOperation;
|
|
7042
|
+
const operation = awarePresentationOperation(s, s.operation || awareUpgradeOperation);
|
|
6447
7043
|
const busy = awareBusy(status);
|
|
6448
7044
|
$awareUpgradeModal.dataset.state = status;
|
|
6449
7045
|
$awareUpgradeModal.setAttribute('aria-busy', busy ? 'true' : 'false');
|
|
@@ -6461,6 +7057,7 @@
|
|
|
6461
7057
|
// sentence directly above it.
|
|
6462
7058
|
const nothingToDo = status === 'runtime-failed' && s.error
|
|
6463
7059
|
&& (s.error.code === 'runtime-current' || s.error.code === 'unknown-operation'
|
|
7060
|
+
|| s.error.code === 'bridge-pending-corrupt'
|
|
6464
7061
|
// A recovery whose copy declares no action has nothing that pressing could achieve.
|
|
6465
7062
|
|| (operation === 'maintenance-recovery' && !awareRecoveryCopy(s.error.code).action));
|
|
6466
7063
|
$awareUpgradeOk.hidden = (status !== 'idle' && status !== 'runtime-failed') || nothingToDo;
|
|
@@ -6600,7 +7197,9 @@
|
|
|
6600
7197
|
// instead let a failed recovery open under its own copy — the painter reads `s.operation` —
|
|
6601
7198
|
// and then start a runtime UPGRADE when the button was pressed, because the button passes this
|
|
6602
7199
|
// variable. The dialog and its button have to be acting on the same job.
|
|
6603
|
-
const showing = awareBusy(current.status) || awareNeedsAttention(current)
|
|
7200
|
+
const showing = awareBusy(current.status) || awareNeedsAttention(current)
|
|
7201
|
+
? awarePresentationOperation(current, current.operation)
|
|
7202
|
+
: null;
|
|
6604
7203
|
awareUpgradeOperation = showing
|
|
6605
7204
|
|| (check.recoveryPending
|
|
6606
7205
|
? 'maintenance-recovery'
|
|
@@ -6637,33 +7236,9 @@
|
|
|
6637
7236
|
$awareUpdate.setAttribute('aria-busy', busy ? 'true' : 'false');
|
|
6638
7237
|
if (busy) {
|
|
6639
7238
|
$awareUpdate.hidden = false;
|
|
6640
|
-
// The
|
|
6641
|
-
//
|
|
6642
|
-
|
|
6643
|
-
? 'Retrying bridge…'
|
|
6644
|
-
: operation === 'bridge-repair' ? 'Repairing installed bridges…'
|
|
6645
|
-
// A recovery is not an upgrade, and the ↑ glyph means "a runtime upgrade is on
|
|
6646
|
-
// offer" everywhere else in this footer — so it announced the wrong work with the
|
|
6647
|
-
// wrong glyph for the whole time the job ran.
|
|
6648
|
-
: operation === 'maintenance-recovery' ? 'Finishing AWARE update…'
|
|
6649
|
-
: '↑ Upgrading AWARE…';
|
|
6650
|
-
// The id follows the label HERE too, not only on the attention pill. The footer can be
|
|
6651
|
-
// painted as an upgrade and become a recovery when the 202 says so — and Instructor
|
|
6652
|
-
// narrates from the registry, so the id left behind described an upgrade over
|
|
6653
|
-
// "Finishing AWARE update…" for the whole time the job ran.
|
|
6654
|
-
// BOTH branches stamp BOTH fields. A one-sided write is how the id came to disagree
|
|
6655
|
-
// with the label in the first place, and `dataset.operation` is what openAwareUpgrade
|
|
6656
|
-
// falls back to — so a stale one reopens the dialog on the wrong job.
|
|
6657
|
-
$awareUpdate.dataset.operation = operation;
|
|
6658
|
-
if (operation === 'maintenance-recovery') {
|
|
6659
|
-
$awareUpdate.dataset.commandId = 'shell.aware-update-finish';
|
|
6660
|
-
$awareUpdate.dataset.tip = AWARE_RECOVERY_PILL_TIP;
|
|
6661
|
-
} else {
|
|
6662
|
-
$awareUpdate.dataset.commandId = 'shell.aware-update';
|
|
6663
|
-
$awareUpdate.dataset.tip = operation === 'bridge-repair'
|
|
6664
|
-
? 'Repair installed bridges that do not match AWARE'
|
|
6665
|
-
: "What's new in v" + (s.target || '');
|
|
6666
|
-
}
|
|
7239
|
+
// The label, command and tip move as one. In particular, retrying after a runtime update
|
|
7240
|
+
// is bridge-only work and must not borrow the runtime-upgrade Instructor narration.
|
|
7241
|
+
paintAwareBusyPill(s, operation);
|
|
6667
7242
|
} else if (awareNeedsAttention(s)) {
|
|
6668
7243
|
// Every suppressed automatic failure must land on an ENABLED attention pill. Without the
|
|
6669
7244
|
// runtime-failed arm the pill stays frozen on "Repairing installed bridges…" forever,
|
|
@@ -7654,6 +8229,23 @@
|
|
|
7654
8229
|
if (typeof m.appId !== 'string' || m.appId === currentId) {
|
|
7655
8230
|
refreshCurrentWorkflowAvailability().catch(reportErr);
|
|
7656
8231
|
}
|
|
8232
|
+
} else if (m.type === 'display-units-changed') {
|
|
8233
|
+
/*
|
|
8234
|
+
* A PROJECT'S DISPLAY UNITS CHANGED — here, in another tab, or from the terminal AI.
|
|
8235
|
+
*
|
|
8236
|
+
* Relayed as a DOM event for exactly the reason `projects-changed` above is: workspaces.js
|
|
8237
|
+
* owns the project view and is the only listener, and it caches this value. The steel editor
|
|
8238
|
+
* already has its own subscription (it is an iframe with its own connection); the SHELL had
|
|
8239
|
+
* none, so its copy of `displayUnits` was whatever the project carried when it was opened and
|
|
8240
|
+
* nothing ever corrected it. That is why the export column picker went on offering
|
|
8241
|
+
* `Length (ft)` after a switch to millimetres while the server wrote `Length (mm)` — a defect
|
|
8242
|
+
* that survived three review rounds of being patched at the reading end instead of the
|
|
8243
|
+
* writing end.
|
|
8244
|
+
*
|
|
8245
|
+
* Relayed UNGATED, like `projects-changed`: `appId` scopes the event to a workflow and the
|
|
8246
|
+
* open PROJECT is a different question.
|
|
8247
|
+
*/
|
|
8248
|
+
window.dispatchEvent(new CustomEvent('floless:display-units-changed', { detail: m }));
|
|
7657
8249
|
} else if (m.type === 'kb-pin-changed' && m.id === currentId && !inWorkspacesMode()) {
|
|
7658
8250
|
// The event is only an invalidation. Re-read the workflow-scoped pin so the server remains
|
|
7659
8251
|
// the source of truth; refresh clears first and its epoch rejects any older response.
|
|
@@ -8140,13 +8732,21 @@
|
|
|
8140
8732
|
const RUN_VIEW = {
|
|
8141
8733
|
queued: { badge: 'Queued', cls: 'active', spin: true, note: (rt) => `Starting ${rt}.` },
|
|
8142
8734
|
running: { badge: 'Running', cls: 'active', spin: true, note: (rt) => `${rt} is working on this. It clears itself when it’s done.` },
|
|
8143
|
-
|
|
8735
|
+
// Recovery-aware for the same reason `stopped` and `exited-unresolved` are: "Your input is
|
|
8736
|
+
// needed" NAMES THE USER'S NEXT ACTION, and there is no way to take it when the server offered
|
|
8737
|
+
// no route back. The badge still names the STATE the run is in, which remains true either way;
|
|
8738
|
+
// it is this line that has to stop asking for something the row cannot accept.
|
|
8739
|
+
'needs-you': { badge: 'Needs your input', cls: 'warn', note: (rt, offered) => offered ? 'Your input is needed:' : 'This request stopped while waiting on your answer:' },
|
|
8144
8740
|
interrupted: { badge: 'Interrupted', cls: 'warn', note: () => 'This request stopped before finishing.' },
|
|
8145
8741
|
// Never the identifier `contract-violation` — the user did not write the contract.
|
|
8146
8742
|
'contract-violation': { badge: 'Unverified', cls: 'err', note: () => 'This request finished without a verified result.' },
|
|
8147
|
-
|
|
8743
|
+
// `offered` is whether a recovery is actually on the row. A note that names a ROUTE BACK is only
|
|
8744
|
+
// true while that route exists, so the two whose prose sends the user to a desktop app say the
|
|
8745
|
+
// other thing when the server has withheld both recoveries — otherwise the row tells the user to
|
|
8746
|
+
// continue somewhere and then, a line later, that it cannot be continued at all.
|
|
8747
|
+
'exited-unresolved': { badge: 'Finished, unconfirmed', cls: 'warn', note: (rt, offered) => offered ? 'Review and confirm this request in a desktop app.' : 'This request finished without confirming what it did.' },
|
|
8148
8748
|
failed: { badge: 'Failed', cls: 'err', note: () => 'The run failed.' },
|
|
8149
|
-
stopped: { badge: 'Stopped', cls: 'muted', note: () => 'Continue this request in a desktop app.' },
|
|
8749
|
+
stopped: { badge: 'Stopped', cls: 'muted', note: (rt, offered) => offered ? 'Continue this request in a desktop app.' : 'This request was stopped.' },
|
|
8150
8750
|
};
|
|
8151
8751
|
|
|
8152
8752
|
// A parked run is a hand-off, not a browser-owned conversation (§G). The server stamps a command
|
|
@@ -8162,11 +8762,10 @@
|
|
|
8162
8762
|
return copied ? 'ok' : 'denied';
|
|
8163
8763
|
}
|
|
8164
8764
|
|
|
8165
|
-
function runStatusHtml(run, stampedResumeCommand, desktopHandoffs, requestId, commandInstance) {
|
|
8765
|
+
function runStatusHtml(run, stampedResumeCommand, desktopHandoffs, requestId, commandInstance, ownRecoverySurface) {
|
|
8166
8766
|
if (!run || !run.state) return '';
|
|
8167
8767
|
const v = RUN_VIEW[run.state] || { badge: String(run.state), cls: 'muted', note: () => '' };
|
|
8168
8768
|
const rt = runtimeLabel(run.runtime);
|
|
8169
|
-
const note = v.note(rt);
|
|
8170
8769
|
// `resumeCommand` belongs to the SERVER'S request view, not persisted `run` metadata: the
|
|
8171
8770
|
// store deliberately carries only runtime/session identity, while terminal-runtime.ts owns argv.
|
|
8172
8771
|
const resumeCommand = RESUMABLE_RUN_STATES.has(run.state) ? stampedResumeCommand : null;
|
|
@@ -8191,6 +8790,39 @@
|
|
|
8191
8790
|
const terminalFallback = !handoffs && resumeCommand
|
|
8192
8791
|
? `<details class="req-terminal-fallback"><summary>Terminal fallback</summary><div class="req-run-resume"><button type="button" class="req-run-resume-command" data-id="${escapeAttr(requestId)}" data-attempt-id="${escapeAttr(run.leaseId)}" data-resume-command="${escapeAttr(resumeCommand)}" data-command-id="shell.requests-resume-copy#${escapeAttr(`${requestId}:${run.leaseId}`)}" data-command-instance-label="${escapeAttr(`terminal session for ${commandInstance}`)}" data-tip="Copy command to continue this session" aria-label="Copy terminal fallback command"><code>${escapeHtml(resumeCommand)}</code></button></div>${run.cwd ? `<div class="req-run-where">Run in · ${escapeHtml(run.cwd)}</div>` : ''}</details>`
|
|
8193
8792
|
: '';
|
|
8793
|
+
// The folder is a CAPTION for a recovery card — "run this command HERE" — not standalone guidance,
|
|
8794
|
+
// so it belongs to the card and renders with it. Printed on its own condition it went wrong twice:
|
|
8795
|
+
// beside the fallback it appeared TWICE, once inside the disclosure and once under it; and on a row
|
|
8796
|
+
// floless had deliberately refused any recovery for it was the only thing left, an imperative path
|
|
8797
|
+
// with no command, no explanation and nothing to click. `Run in` is the imperative half — a state
|
|
8798
|
+
// the badge calls continuable but that carries no way to continue says so plainly and past-tenses
|
|
8799
|
+
// the path, rather than sending the user to a folder to do something floless will not name.
|
|
8800
|
+
const continuable = RESUMABLE_RUN_STATES.has(run.state);
|
|
8801
|
+
const noRecovery = !handoffs && !resumeCommand;
|
|
8802
|
+
// Computed here, below the recovery it depends on: a note that names a route back is prose about
|
|
8803
|
+
// THIS row, not about the state in the abstract, so it cannot be written before we know whether
|
|
8804
|
+
// the row has one. See RUN_VIEW's `offered` note.
|
|
8805
|
+
//
|
|
8806
|
+
// A row with its OWN recovery surface counts as offered even with neither terminal recovery
|
|
8807
|
+
// stamped, because it does have a next action and its own question names it — a pre-save drawing
|
|
8808
|
+
// read is waiting on Save in Drawing Filter, not on an answer to a stopped session. So those rows
|
|
8809
|
+
// keep the note master gives them. The refusal below keeps its own separate test: having a next
|
|
8810
|
+
// action is why the generic "can't be continued" is withheld there, not a reason to state it.
|
|
8811
|
+
const note = v.note(rt, !noRecovery || !!ownRecoverySurface);
|
|
8812
|
+
// The refusal answers "why is there no button", so it is owed whenever the recovery is missing —
|
|
8813
|
+
// never conditioned on the folder, which is the one part of this row that may legitimately be
|
|
8814
|
+
// absent. A run with neither would otherwise show the same dead end with even less to read.
|
|
8815
|
+
// Withheld here for a row that owns its own recovery surface: there, "no recovery" is a pause
|
|
8816
|
+
// the row is already asking the user to end, not a dead end, and only the flow that ends it can
|
|
8817
|
+
// say whether it will lift. Everywhere else the sentence is the answer to "why is there no
|
|
8818
|
+
// button", and is owed whenever the recovery is missing — never conditioned on the folder, which
|
|
8819
|
+
// is the one part of this row that may legitimately be absent.
|
|
8820
|
+
const refused = noRecovery && continuable && !ownRecoverySurface
|
|
8821
|
+
? '<p class="req-run-note">This run can’t be continued.</p>'
|
|
8822
|
+
: '';
|
|
8823
|
+
const folder = run.cwd && noRecovery
|
|
8824
|
+
? `<div class="req-run-where">${continuable ? 'Ran in' : 'Run in'} · ${escapeHtml(run.cwd)}</div>`
|
|
8825
|
+
: '';
|
|
8194
8826
|
return `
|
|
8195
8827
|
<div class="req-run-status">
|
|
8196
8828
|
<div class="req-run-head">
|
|
@@ -8201,7 +8833,7 @@
|
|
|
8201
8833
|
${run.question ? `<p class="req-run-question">${escapeHtml(run.question)}</p>` : ''}
|
|
8202
8834
|
${desktop}
|
|
8203
8835
|
${terminalFallback}
|
|
8204
|
-
${
|
|
8836
|
+
${refused}${folder}
|
|
8205
8837
|
${run.lastOutput ? `<details class="req-run-output"><summary>Show what it printed</summary><pre>${escapeHtml(run.lastOutput)}</pre></details>` : ''}
|
|
8206
8838
|
</div>`;
|
|
8207
8839
|
}
|
|
@@ -8556,6 +9188,7 @@
|
|
|
8556
9188
|
const epoch = ++requestFetchEpoch;
|
|
8557
9189
|
const { requests, answers = [] } = await api('/api/requests');
|
|
8558
9190
|
if (epoch !== requestFetchEpoch) return;
|
|
9191
|
+
const continuationFocus = focusedAnswerSessionControl();
|
|
8559
9192
|
reconcileActiveInstructorRuns(requests, answers);
|
|
8560
9193
|
if (!hydratedInstructorAnswers) {
|
|
8561
9194
|
acceptInstructorAnswers(answers, { initial: true });
|
|
@@ -8564,6 +9197,9 @@
|
|
|
8564
9197
|
acceptInstructorAnswers(answers);
|
|
8565
9198
|
}
|
|
8566
9199
|
pendingRequests = requests;
|
|
9200
|
+
// `acceptInstructorAnswers` paints before the queue assignment above. Paint once more so an
|
|
9201
|
+
// answer that is still queued/running is visible without opening Requests.
|
|
9202
|
+
renderInstructorAnswers({ revealNew: false });
|
|
8567
9203
|
// The upload modal starts with the POST response, but polling owns the live request state. Do not
|
|
8568
9204
|
// leave an old Start button or first-step explanation visible after the request becomes prepared,
|
|
8569
9205
|
// staged, failed, or disappears. Move to the live row, which already renders every lifecycle state.
|
|
@@ -8611,6 +9247,7 @@
|
|
|
8611
9247
|
previousRequestIds = ids;
|
|
8612
9248
|
const $rm = document.getElementById('requests-modal');
|
|
8613
9249
|
if ($rm && $rm.classList.contains('show')) renderRequests(); // keep an open list live
|
|
9250
|
+
restoreAnswerSessionFocus(continuationFocus);
|
|
8614
9251
|
} catch { /* non-fatal */ }
|
|
8615
9252
|
}
|
|
8616
9253
|
|
|
@@ -8695,6 +9332,17 @@
|
|
|
8695
9332
|
.filter(Boolean).join(' ');
|
|
8696
9333
|
}
|
|
8697
9334
|
|
|
9335
|
+
function answerSessionSearchText(answer) {
|
|
9336
|
+
return [
|
|
9337
|
+
answerSessionProviderLabel(answer?.continuation?.provider),
|
|
9338
|
+
answer?.instructorContext?.subject,
|
|
9339
|
+
answer?.appId,
|
|
9340
|
+
answer?.project,
|
|
9341
|
+
answer?.projectLabel,
|
|
9342
|
+
answer?.answer,
|
|
9343
|
+
].filter(Boolean).join(' ');
|
|
9344
|
+
}
|
|
9345
|
+
|
|
8698
9346
|
function requestLabel(r) {
|
|
8699
9347
|
if (r.type === 'revision-read') return (!r.baseVersion || r.baseVersion <= 0) ? 'initial drawing read' : 'updated drawing read';
|
|
8700
9348
|
return r.type === 'use-template' ? 'template' : r.type === 'ui-customize' ? 'dashboard' : r.type === 'rebake' ? 're-bake' : r.type === 'guide' ? 'guide' : r.type === 'new-workflow' ? 'new workflow' : r.type === 'knowledge-organize' ? 'organize' : r.type === 'knowledge-adjust' ? 'adjust' : r.type === 'knowledge-consult' ? 'knowledge' : r.type === 'tweak-contract' ? 'contract' : 'tweak';
|
|
@@ -8848,6 +9496,120 @@
|
|
|
8848
9496
|
: 'Read the updated drawing and apply the changes to this steel model.';
|
|
8849
9497
|
}
|
|
8850
9498
|
|
|
9499
|
+
|
|
9500
|
+
/**
|
|
9501
|
+
* Why a drawing read was refused, in the words of the person who has to act on it.
|
|
9502
|
+
*
|
|
9503
|
+
* The server writes these (`auditRetry.items`) precisely because the check ids beside them
|
|
9504
|
+
* (`auditRetry.blockers`) mean nothing to a steel detailer. Owner ruling 2026-09-02: *"we cannot
|
|
9505
|
+
* end up just with sentence 'model refused'."* Before this, a blocked read showed NOTHING in the
|
|
9506
|
+
* app at all — the refusal went only to the terminal AI as a 400 body.
|
|
9507
|
+
*
|
|
9508
|
+
* Static by design. Every item's own last line says what to do, and the doing is already owned by
|
|
9509
|
+
* this row's existing Start and Copy buttons; a control here would either duplicate them or invent
|
|
9510
|
+
* a verb with no endpoint behind it.
|
|
9511
|
+
*
|
|
9512
|
+
* The raw `blockers` ids are NEVER rendered. If a check ever blocks without an authored
|
|
9513
|
+
* explanation, that is a gap to fix in the server, not a check id to improvise into the UI.
|
|
9514
|
+
*/
|
|
9515
|
+
/**
|
|
9516
|
+
* The four refusal codes that produce a card, and the SENTENCE each one can honestly open with.
|
|
9517
|
+
*
|
|
9518
|
+
* Three of these rendered nothing at all before #1074 — the guard admitted `audit-blocked` alone —
|
|
9519
|
+
* so an attestation refusal or a lifecycle invalidation left the row silent. Widening the guard
|
|
9520
|
+
* without splitting the lead would have been a second defect: "the drawing read finished without
|
|
9521
|
+
* producing a model" is simply untrue of a read that DID produce one and was then overtaken by a
|
|
9522
|
+
* change underneath it. A card whose first sentence is false is worse than a card that says nothing.
|
|
9523
|
+
*/
|
|
9524
|
+
const AUDIT_REFUSAL_LEAD = {
|
|
9525
|
+
'audit-blocked': 'The drawing read finished without producing a model.',
|
|
9526
|
+
'attestation-retired': 'This drawing read could not be applied to the project.',
|
|
9527
|
+
'attestation-unparseable': 'This drawing read could not be applied to the project.',
|
|
9528
|
+
'base-invalidated-audit': 'This drawing read no longer matches the project it was made against.',
|
|
9529
|
+
'selection-invalidated-audit': 'This drawing read no longer matches the drawing selection it was made against.',
|
|
9530
|
+
};
|
|
9531
|
+
|
|
9532
|
+
/**
|
|
9533
|
+
* WHOSE MOVE IT IS, in the label rather than in a badge (#1074).
|
|
9534
|
+
*
|
|
9535
|
+
* Every item used to open with "Next:", which reads as an instruction — and half of these are not
|
|
9536
|
+
* instructions to the person reading them. Telling a detailer "Next: open the Drawing Filter and
|
|
9537
|
+
* save it again" for a fault no Save can clear is the dead end this issue is named after, and it is
|
|
9538
|
+
* a real one: they try it, nothing changes, and they try it again.
|
|
9539
|
+
*
|
|
9540
|
+
* A word and a colour, and nothing more. `--accent-bright` stays reserved for the one label that IS
|
|
9541
|
+
* a call to action, so the eye finds it; the two the app or the terminal AI owns drop to
|
|
9542
|
+
* `--text-dim` and read as information. An unfixable fault keeps full contrast in `--err` — it is
|
|
9543
|
+
* the worst case, and dimming it because it sorts last would hide the thing most worth reporting.
|
|
9544
|
+
*/
|
|
9545
|
+
// `unknown` is the LEGACY row's owner, and it is deliberately not `user`.
|
|
9546
|
+
//
|
|
9547
|
+
// `recovery` is optional so every request stored before #1074 still reads, and my first cut
|
|
9548
|
+
// defaulted an absent one to `user` — which made an old card claim "needs you" and sort to the top
|
|
9549
|
+
// as the user's work, when its own guidance might be telling the READER to run again. Manufacturing
|
|
9550
|
+
// human ownership out of missing data is the same class of defect as the wrong label it replaced.
|
|
9551
|
+
// An unknown route keeps the neutral "Next:" wording it has always had, is counted as nobody's, and
|
|
9552
|
+
// sorts last. (Found by review.)
|
|
9553
|
+
const AUDIT_OWNER_LABEL = { user: 'Next:', reader: 'Terminal AI:', server: 'FloLess:', none: 'Status:', unknown: 'Next:' };
|
|
9554
|
+
/**
|
|
9555
|
+
* CARD order, which is deliberately NOT the queue's order — do not "fix" one to match the other.
|
|
9556
|
+
*
|
|
9557
|
+
* The queue is ordered by causal dependency (none, user, server, reader) because that decides which
|
|
9558
|
+
* step to TAKE: a scope change invalidates the artifacts built on it. This list answers a different
|
|
9559
|
+
* question, asked by a person rather than by the reader: which of these is mine? The list can scroll,
|
|
9560
|
+
* and people do not read to the bottom of one, so what they can act on goes first.
|
|
9561
|
+
*/
|
|
9562
|
+
const AUDIT_OWNER_ORDER = { user: 0, reader: 1, server: 2, none: 3, unknown: 4 };
|
|
9563
|
+
|
|
9564
|
+
function auditRefusalHtml(r) {
|
|
9565
|
+
const retry = r && r.auditRetry;
|
|
9566
|
+
if (!retry || !Object.prototype.hasOwnProperty.call(AUDIT_REFUSAL_LEAD, retry.code)) return '';
|
|
9567
|
+
const lead = AUDIT_REFUSAL_LEAD[retry.code];
|
|
9568
|
+
const items = Array.isArray(retry.items) ? retry.items.filter((i) => i && i.what && i.why && i.next) : [];
|
|
9569
|
+
if (!items.length) {
|
|
9570
|
+
return `<div class="req-audit"><p class="req-audit-lead">${escapeHtml(lead)} `
|
|
9571
|
+
+ 'FloLess could not explain why in plain English. Please report this.</p></div>';
|
|
9572
|
+
}
|
|
9573
|
+
// The owner of the FIRST route: the queue is ordered so its head is the next step, and a card
|
|
9574
|
+
// showing every entry would be showing work that has not happened yet and may never need to.
|
|
9575
|
+
const ownerOf = (item) => {
|
|
9576
|
+
const owner = Array.isArray(item.recovery) && item.recovery[0] && item.recovery[0].owner;
|
|
9577
|
+
return (owner && owner !== 'unknown' && Object.prototype.hasOwnProperty.call(AUDIT_OWNER_LABEL, owner))
|
|
9578
|
+
? owner : 'unknown';
|
|
9579
|
+
};
|
|
9580
|
+
// STABLE sort, user first. A scrollable list caps at 220px and people do not read to the bottom
|
|
9581
|
+
// of one; what they can actually act on belongs at the top. Sorted rather than sectioned, because
|
|
9582
|
+
// a header per owner would repeat what the count line and the labels already say, on a list that
|
|
9583
|
+
// is usually one to three items.
|
|
9584
|
+
const ordered = items
|
|
9585
|
+
.map((item, index) => ({ item, index, owner: ownerOf(item) }))
|
|
9586
|
+
.sort((a, b) => (AUDIT_OWNER_ORDER[a.owner] - AUDIT_OWNER_ORDER[b.owner]) || (a.index - b.index));
|
|
9587
|
+
const mine = ordered.filter((row) => row.owner === 'user').length;
|
|
9588
|
+
// UNKNOWN IS NOT NOBODY. A legacy row carries no route, and saying "none need you right now" over
|
|
9589
|
+
// it would be a claim the data does not support — its own guidance may well be asking the user for
|
|
9590
|
+
// something, and a card that says to ignore it can stall the request outright. So the reassurance
|
|
9591
|
+
// is only ever printed when EVERY item has a known, non-user owner. With an unknown in the mix the
|
|
9592
|
+
// count says how many reasons there are and stops there, which is what it said before #1074.
|
|
9593
|
+
// (Found by review, in a fix from the round before.)
|
|
9594
|
+
const unknown = ordered.filter((row) => row.owner === 'unknown').length;
|
|
9595
|
+
const nobodyNeedsYou = mine === 0 && unknown === 0;
|
|
9596
|
+
const count = items.length > 1
|
|
9597
|
+
? `<p class="req-audit-count">${items.length} reasons it was not accepted`
|
|
9598
|
+
+ `${mine === items.length ? '' : mine ? ` — ${mine} ${mine === 1 ? 'needs' : 'need'} you` : nobodyNeedsYou ? ' — none need you right now' : ''}:</p>`
|
|
9599
|
+
: (nobodyNeedsYou ? '<p class="req-audit-count">Nothing here needs you right now:</p>' : '');
|
|
9600
|
+
const list = ordered.map(({ item, owner }) => `
|
|
9601
|
+
<li class="req-audit-item" data-owner="${escapeHtml(owner)}">
|
|
9602
|
+
<p class="req-audit-what">${escapeHtml(item.what)}</p>
|
|
9603
|
+
<p class="req-audit-why">${escapeHtml(item.why)}</p>
|
|
9604
|
+
<p class="req-audit-next"><span class="req-audit-next-label">${escapeHtml(AUDIT_OWNER_LABEL[owner])}</span> ${escapeHtml(item.next)}</p>
|
|
9605
|
+
</li>`).join('');
|
|
9606
|
+
return `<div class="req-audit">
|
|
9607
|
+
<p class="req-audit-lead">${escapeHtml(lead)}</p>
|
|
9608
|
+
${count}
|
|
9609
|
+
<ul class="req-audit-list">${list}</ul>
|
|
9610
|
+
</div>`;
|
|
9611
|
+
}
|
|
9612
|
+
|
|
8851
9613
|
/** One exact next step above the request rows; automatic start is offered only when policy allows it. */
|
|
8852
9614
|
function drawingRequestGuidance(r) {
|
|
8853
9615
|
if (!r) return '';
|
|
@@ -8964,20 +9726,27 @@
|
|
|
8964
9726
|
// Drop the query WITH the box, and before anything is filtered by it: a hidden filter still
|
|
8965
9727
|
// filtering is how a list ends up inexplicably empty (the last two requests clear while a
|
|
8966
9728
|
// stale query is still narrowing).
|
|
9729
|
+
const continuations = instructorAnswers.filter((answer) => answer?.continuation)
|
|
9730
|
+
.filter((answer) => !pendingDeleteAnswerIds.has(answer.id));
|
|
8967
9731
|
if ($search) {
|
|
8968
|
-
$search.hidden = pendingRequests.length < 2;
|
|
9732
|
+
$search.hidden = pendingRequests.length + continuations.length < 2;
|
|
8969
9733
|
if ($search.hidden && requestQuery) { requestQuery = ''; $search.value = ''; }
|
|
8970
9734
|
}
|
|
8971
9735
|
const normalizedRequestQuery = requestQuery.trim();
|
|
8972
9736
|
const scope = activeRequestScope();
|
|
8973
9737
|
const inScope = visibleRequests(pendingRequests, scope, '', requestSearchText);
|
|
8974
9738
|
const shown = shownRequests(normalizedRequestQuery);
|
|
9739
|
+
const savedInScope = visibleRequests(continuations, scope, '', answerSessionSearchText);
|
|
9740
|
+
const savedAnswers = visibleRequests(
|
|
9741
|
+
continuations, requestScopeAll ? null : scope, normalizedRequestQuery, answerSessionSearchText,
|
|
9742
|
+
)
|
|
9743
|
+
.sort((a, b) => String(b.finishedAt || '').localeCompare(String(a.finishedAt || '')));
|
|
8975
9744
|
shownSnapshot = shown; // the bulk actions act on THIS paint — see the note on shownSnapshot
|
|
8976
|
-
const nothingQueued = pendingRequests.length === 0;
|
|
9745
|
+
const nothingQueued = pendingRequests.length === 0 && continuations.length === 0;
|
|
8977
9746
|
|
|
8978
9747
|
// The scope tabs only earn their space when there is something to scope TO and something
|
|
8979
|
-
// queued to scope. Counts live ON the tabs
|
|
8980
|
-
//
|
|
9748
|
+
// queued to scope. Counts live ON the tabs and explicitly say they count queued work;
|
|
9749
|
+
// completed answer history is rendered below and must not make the totals look wrong.
|
|
8981
9750
|
const $scope = document.getElementById('requests-scope');
|
|
8982
9751
|
const $here = document.getElementById('requests-scope-here');
|
|
8983
9752
|
const $all = document.getElementById('requests-scope-all');
|
|
@@ -8987,9 +9756,9 @@
|
|
|
8987
9756
|
const kind = scope.kind === 'project' ? 'project' : 'workflow';
|
|
8988
9757
|
// The label is the REAL name, so you can see WHICH project you're scoped to — it can
|
|
8989
9758
|
// ellipsize, which is why the tip repeats it in full rather than describing it generically.
|
|
8990
|
-
$here.innerHTML = `<span class="req-scope-name">${escapeHtml(scope.label)}</span><span class="req-scope-n">· ${inScope.length}</span>`;
|
|
9759
|
+
$here.innerHTML = `<span class="req-scope-name">${escapeHtml(scope.label)}</span><span class="req-scope-n">· ${inScope.length} queued</span>`;
|
|
8991
9760
|
$here.setAttribute('data-tip', `Only what's queued for the ${kind} you have open — ${scope.label}`);
|
|
8992
|
-
$all.innerHTML = `<span class="req-scope-name">All requests</span><span class="req-scope-n">· ${pendingRequests.length}</span>`;
|
|
9761
|
+
$all.innerHTML = `<span class="req-scope-name">All requests</span><span class="req-scope-n">· ${pendingRequests.length} queued</span>`;
|
|
8993
9762
|
$all.setAttribute('data-tip', 'Every queued request, including other projects and workflows');
|
|
8994
9763
|
$here.classList.toggle('active', !requestScopeAll);
|
|
8995
9764
|
$here.setAttribute('aria-selected', String(!requestScopeAll));
|
|
@@ -9025,14 +9794,14 @@
|
|
|
9025
9794
|
: `Copy ${copyableShown.length} request${copyableShown.length === 1 ? '' : 's'} that still need to be started`);
|
|
9026
9795
|
}
|
|
9027
9796
|
|
|
9028
|
-
if (shown.length === 0) {
|
|
9797
|
+
if (shown.length === 0 && savedAnswers.length === 0) {
|
|
9029
9798
|
// Three different nothings, and conflating them is what makes a filter feel broken: an
|
|
9030
9799
|
// empty queue, a queue with nothing for THIS project, and a search that missed.
|
|
9031
9800
|
const msg = nothingQueued
|
|
9032
9801
|
? 'No requests queued. Save a Template or ✎ Tweak a node to send a change to your terminal AI.'
|
|
9033
9802
|
: normalizedRequestQuery
|
|
9034
|
-
? `No request matches “${escapeHtml(normalizedRequestQuery)}”.${!requestScopeAll && inScope.length < pendingRequests.length ? ' Try All to search
|
|
9035
|
-
: `Nothing queued for ${escapeHtml(scope ? scope.label : 'this')} — ${pendingRequests.length}
|
|
9803
|
+
? `No request or saved AI session matches “${escapeHtml(normalizedRequestQuery)}”.${!requestScopeAll && (inScope.length + savedInScope.length) < (pendingRequests.length + continuations.length) ? ' Try All to search everything.' : ''}`
|
|
9804
|
+
: `Nothing queued or saved for ${escapeHtml(scope ? scope.label : 'this')} — ${pendingRequests.length + continuations.length} item${pendingRequests.length + continuations.length === 1 ? '' : 's'} waiting elsewhere. <button type="button" class="req-showall">Show all</button>`;
|
|
9036
9805
|
$list.innerHTML = `<div class="empty-state">${msg}</div>`;
|
|
9037
9806
|
const $showAll = $list.querySelector('.req-showall');
|
|
9038
9807
|
if ($showAll) $showAll.onclick = () => setRequestScopeAll(true);
|
|
@@ -9044,7 +9813,7 @@
|
|
|
9044
9813
|
// has no button. Derived from this paint — deliberately not a stored "has run before" flag,
|
|
9045
9814
|
// which would make the same list read differently for two people.
|
|
9046
9815
|
const anyRunnable = headlessReady() && shown.some((r) => r && r.canRun);
|
|
9047
|
-
|
|
9816
|
+
const queuedHtml = shown.map((r, shownIndex) => {
|
|
9048
9817
|
const label = requestLabel(r);
|
|
9049
9818
|
const badgeCls = r.type === 'tweak' || r.type === 'ui-customize' || r.type === 'rebake' || r.type === 'revision-read' || r.type === 'knowledge-organize' || r.type === 'knowledge-adjust' || r.type === 'tweak-contract' ? 'req-type req-type-tweak' : 'req-type';
|
|
9050
9819
|
// One name, and only the name. The node/input/sheet chips that used to sit here ("· node
|
|
@@ -9073,6 +9842,15 @@
|
|
|
9073
9842
|
const run = settledRevision ? null : (r.run || null);
|
|
9074
9843
|
const resumeCommand = settledRevision ? null : r.resumeCommand;
|
|
9075
9844
|
const desktopHandoffs = settledRevision ? null : r.desktopHandoffs;
|
|
9845
|
+
// A drawing read owns a second recovery surface — the Drawing Filter Save flow, the staged and
|
|
9846
|
+
// failed cards, `drawingRequestGuidance` — so a bare "no recovery" row is not the dead end it
|
|
9847
|
+
// is for every other type: the row is already asking for the Save that may lift it. Whether it
|
|
9848
|
+
// WILL lift is a prediction only the Save route can make (it turns on the process being proved
|
|
9849
|
+
// contained, the project still existing, and the contract still being current), and this row
|
|
9850
|
+
// has no business making it: two review rounds produced two different wrong answers. So the
|
|
9851
|
+
// generic sentence is reserved for the types with no second surface, where "no recovery" is
|
|
9852
|
+
// unambiguous — and the drawing read keeps saying what it already says, correctly.
|
|
9853
|
+
const ownRecoverySurface = r.type === 'revision-read';
|
|
9076
9854
|
const inFlight = !!run && (run.state === 'queued' || run.state === 'running');
|
|
9077
9855
|
const desktopClaimed = !!(desktopHandoffs && desktopHandoffs.claim);
|
|
9078
9856
|
const lifecycleOwned = r.type === 'knowledge-organize';
|
|
@@ -9111,8 +9889,9 @@
|
|
|
9111
9889
|
? `<div class="req-instruction req-summary">${highlightQuery(requestSummary(r), normalizedRequestQuery)}</div><details class="req-technical"${normalizedRequestQuery && instructionFor(r).toLowerCase().includes(normalizedRequestQuery.toLowerCase()) ? ' open' : ''}><summary data-command-id="shell.requests-technical#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(commandInstance)}">Show technical instructions</summary><div class="req-technical-body">${highlightQuery(instructionFor(r), normalizedRequestQuery)}</div></details>`
|
|
9112
9890
|
: `<div class="req-instruction">${highlightQuery(instructionFor(r), normalizedRequestQuery) || 'This request has no instruction, so it can’t be handed to your terminal AI. Clear it and queue it again.'}</div>`}
|
|
9113
9891
|
${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>` : ''}
|
|
9114
|
-
${runStatusHtml(run, resumeCommand, desktopHandoffs, r.id, commandInstance)}
|
|
9892
|
+
${runStatusHtml(run, resumeCommand, desktopHandoffs, r.id, commandInstance, ownRecoverySurface)}
|
|
9115
9893
|
${r.status === 'pending' && !revisionReadHasTerminalOwner(r) && !r.canRun && r.runWhy && (anyRunnable || r.type === 'revision-read') ? `<div class="req-why-not">Why there is no automatic start: ${escapeHtml(r.runWhy)}</div>` : ''}
|
|
9894
|
+
${auditRefusalHtml(r)}
|
|
9116
9895
|
</div>
|
|
9117
9896
|
<div class="req-actions">
|
|
9118
9897
|
${runBtn}
|
|
@@ -9121,6 +9900,29 @@
|
|
|
9121
9900
|
</div>
|
|
9122
9901
|
</div>`;
|
|
9123
9902
|
}).join('');
|
|
9903
|
+
const savedHtml = savedAnswers.length ? `
|
|
9904
|
+
<section class="saved-answer-sessions" aria-labelledby="saved-answer-sessions-title">
|
|
9905
|
+
<div class="requests-section-title" id="saved-answer-sessions-title">AI answer history · ${savedAnswers.length}</div>
|
|
9906
|
+
${savedAnswers.map((answer) => {
|
|
9907
|
+
const provider = answerSessionProviderLabel(answer.continuation?.provider);
|
|
9908
|
+
const subject = answer.instructorContext?.subject || 'AI answer';
|
|
9909
|
+
const finished = answer.finishedAt ? new Date(answer.finishedAt) : null;
|
|
9910
|
+
const finishedLabel = finished && !isNaN(finished) ? nowStamp(finished) : '';
|
|
9911
|
+
return `<div class="saved-answer-session" data-answer-id="${escapeAttr(answer.id)}">
|
|
9912
|
+
<div class="saved-answer-session-head">
|
|
9913
|
+
<span class="req-type">${provider}</span>
|
|
9914
|
+
<span class="saved-answer-session-subject">${escapeHtml(subject)}</span>
|
|
9915
|
+
${finishedLabel ? `<span class="req-time">${escapeHtml(finishedLabel)}</span>` : ''}
|
|
9916
|
+
</div>
|
|
9917
|
+
${answerSessionControlHtml(answer, 'requests')}
|
|
9918
|
+
</div>`;
|
|
9919
|
+
}).join('')}
|
|
9920
|
+
</section>` : '';
|
|
9921
|
+
const queuedSection = queuedHtml
|
|
9922
|
+
? `${savedHtml ? '<div class="requests-section-title">Queued requests</div>' : ''}${queuedHtml}`
|
|
9923
|
+
: '';
|
|
9924
|
+
$list.innerHTML = `${savedHtml}${queuedSection}`;
|
|
9925
|
+
bindAnswerSessionControls($list);
|
|
9124
9926
|
$list.querySelectorAll('.req-run').forEach((b) => {
|
|
9125
9927
|
b.onclick = () => {
|
|
9126
9928
|
const r = pendingRequests.find((x) => x.id === b.dataset.id);
|
|
@@ -9467,9 +10269,6 @@
|
|
|
9467
10269
|
agentCatalog = agents;
|
|
9468
10270
|
const $ac = document.getElementById('agents-count');
|
|
9469
10271
|
if ($ac) $ac.textContent = agents.length;
|
|
9470
|
-
// Narrative banner shows the REAL installed-agent count, not a placeholder.
|
|
9471
|
-
const $acn = document.getElementById('agent-count-narr');
|
|
9472
|
-
if ($acn) $acn.textContent = agents.length;
|
|
9473
10272
|
}
|
|
9474
10273
|
|
|
9475
10274
|
openLibrary = function openLibraryReal() {
|
|
@@ -9836,6 +10635,7 @@
|
|
|
9836
10635
|
// ── Integrations: real connection state from the local vault ────────────────
|
|
9837
10636
|
const VENDOR_ICON = { microsoft: '▦', google: 'G', trimble: '◬', autodesk: 'A' };
|
|
9838
10637
|
let integrations = [];
|
|
10638
|
+
let runtimeSectionExpanded = false;
|
|
9839
10639
|
|
|
9840
10640
|
openIntegrations = function openIntegrationsReal() {
|
|
9841
10641
|
$integrationsModal.classList.add('show');
|
|
@@ -9844,6 +10644,24 @@
|
|
|
9844
10644
|
refreshHeadless().then(renderRuntimeSection);
|
|
9845
10645
|
};
|
|
9846
10646
|
|
|
10647
|
+
function runtimeSectionSummary(runtimes, active, folder) {
|
|
10648
|
+
const installed = runtimes.filter((runtime) => runtime.state === 'found');
|
|
10649
|
+
const selected = installed.find((runtime) => runtime.id === active);
|
|
10650
|
+
const provider = selected ? `${selected.label} default` : 'No default terminal AI';
|
|
10651
|
+
const count = `${installed.length} installed`;
|
|
10652
|
+
return `${provider} · ${count} · ${folder ? `Runs in ${folder}` : 'Folder not chosen'}`;
|
|
10653
|
+
}
|
|
10654
|
+
|
|
10655
|
+
function setRuntimeSectionExpanded(expanded) {
|
|
10656
|
+
runtimeSectionExpanded = !!expanded;
|
|
10657
|
+
const $toggle = document.getElementById('int-runtimes-toggle');
|
|
10658
|
+
const $body = document.getElementById('int-runtimes-body');
|
|
10659
|
+
if (!$toggle || !$body) return;
|
|
10660
|
+
$toggle.setAttribute('aria-expanded', String(runtimeSectionExpanded));
|
|
10661
|
+
$toggle.setAttribute('data-tip', `${runtimeSectionExpanded ? 'Collapse' : 'Expand'} headless run settings`);
|
|
10662
|
+
$body.hidden = !runtimeSectionExpanded;
|
|
10663
|
+
}
|
|
10664
|
+
|
|
9847
10665
|
/**
|
|
9848
10666
|
* Which terminal AIs are installed, which one headless runs use, and the folder they run in.
|
|
9849
10667
|
*
|
|
@@ -9855,15 +10673,22 @@
|
|
|
9855
10673
|
*/
|
|
9856
10674
|
function renderRuntimeSection() {
|
|
9857
10675
|
const $sec = document.getElementById('int-runtimes-section');
|
|
10676
|
+
const $toggle = document.getElementById('int-runtimes-toggle');
|
|
10677
|
+
const $summary = document.getElementById('int-runtimes-summary');
|
|
9858
10678
|
const $list = document.getElementById('int-runtimes');
|
|
9859
10679
|
const $folder = document.getElementById('int-folder');
|
|
9860
|
-
if (!$sec || !$list || !$folder) return;
|
|
10680
|
+
if (!$sec || !$toggle || !$summary || !$list || !$folder) return;
|
|
9861
10681
|
const rts = headlessRuntimes();
|
|
9862
10682
|
// Hidden entirely when detection failed — an empty "Headless runs" box explains nothing. When
|
|
9863
10683
|
// detection SUCCEEDED and found nothing, the rows are the explanation (each carries its command).
|
|
9864
10684
|
$sec.hidden = !rts.length;
|
|
9865
10685
|
if (!rts.length) return;
|
|
9866
10686
|
const active = headlessInfo && headlessInfo.provider;
|
|
10687
|
+
const folder = headlessInfo && headlessInfo.folder;
|
|
10688
|
+
$summary.textContent = runtimeSectionSummary(rts, active, folder);
|
|
10689
|
+
if (folder) $summary.setAttribute('data-tip', folder); else $summary.removeAttribute('data-tip');
|
|
10690
|
+
$toggle.onclick = () => setRuntimeSectionExpanded(!runtimeSectionExpanded);
|
|
10691
|
+
setRuntimeSectionExpanded(runtimeSectionExpanded);
|
|
9867
10692
|
$list.innerHTML = rts.map((r) => {
|
|
9868
10693
|
const found = r.state === 'found';
|
|
9869
10694
|
const isDefault = found && r.id === active;
|
|
@@ -9878,7 +10703,7 @@
|
|
|
9878
10703
|
</div>
|
|
9879
10704
|
<div class="int-rt-side">
|
|
9880
10705
|
<span class="int-rt-badge">${found ? 'Installed' : 'Not installed'}</span>
|
|
9881
|
-
${found && !isDefault ? `<button class="int-action" data-rt="${escapeAttr(r.id)}">Use this one</button>` : ''}
|
|
10706
|
+
${found && !isDefault ? `<button class="int-action" data-rt="${escapeAttr(r.id)}" data-command-id="shell.headless-runtime#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(r.label)}">Use this one</button>` : ''}
|
|
9882
10707
|
</div>
|
|
9883
10708
|
</div>`;
|
|
9884
10709
|
}).join('');
|
|
@@ -9892,11 +10717,10 @@
|
|
|
9892
10717
|
} catch (e) { reportErr(e); }
|
|
9893
10718
|
};
|
|
9894
10719
|
});
|
|
9895
|
-
const folder = headlessInfo && headlessInfo.folder;
|
|
9896
10720
|
$folder.innerHTML = `
|
|
9897
10721
|
<span>Runs in</span>
|
|
9898
10722
|
<span class="int-folder-path${folder ? '' : ' is-unset'}"${folder ? ` data-tip="${escapeAttr(folder)}"` : ''}>${folder ? escapeHtml(folder) : 'not chosen yet — floless will ask the first time you run one'}</span>
|
|
9899
|
-
<button class="int-action" id="int-folder-set">${folder ? 'Change…' : 'Choose…'}</button>`;
|
|
10723
|
+
<button class="int-action" id="int-folder-set" data-command-id="shell.headless-folder">${folder ? 'Change…' : 'Choose…'}</button>`;
|
|
9900
10724
|
const $set = document.getElementById('int-folder-set');
|
|
9901
10725
|
if ($set) $set.onclick = () => { void nominateDefaultFolder(); };
|
|
9902
10726
|
}
|
|
@@ -10059,6 +10883,11 @@
|
|
|
10059
10883
|
let editTriggerSource = null; // picked workflow's triggerSource (null = not trigger-eligible)
|
|
10060
10884
|
let editRoutineMode = 'schedule'; // 'schedule' | 'trigger' — chosen kind in the edit form
|
|
10061
10885
|
const runningRoutines = new Set(); // ids executing now (SSE start → ended)
|
|
10886
|
+
// Why a second start is refused, in the user's words. Said identically by the greyed ▶ (tip + `?`)
|
|
10887
|
+
// and by the toast when a click races ahead of the repaint. "or waiting its turn" is not padding:
|
|
10888
|
+
// the queue refuses a routine that is QUEUED behind another as well as one that is mid-run, and
|
|
10889
|
+
// the row greys for both, so a sentence that claimed "running" would be wrong in the first case.
|
|
10890
|
+
const RTN_ALREADY_RUNNING = 'Already running or waiting its turn — starting it again would only run it twice';
|
|
10062
10891
|
|
|
10063
10892
|
const RTN_DAY_LABELS = { sun: 'Sun', mon: 'Mon', tue: 'Tue', wed: 'Wed', thu: 'Thu', fri: 'Fri', sat: 'Sat' };
|
|
10064
10893
|
const RTN_DAY_ORDER = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
|
|
@@ -10483,6 +11312,19 @@
|
|
|
10483
11312
|
}
|
|
10484
11313
|
const whenText = isTrigger ? triggerWhenText(r) : scheduleText(r.schedule);
|
|
10485
11314
|
const toggleTip = isTrigger ? (r.enabled ? 'Stop listening' : 'Start listening') : `${r.enabled ? 'Disable' : 'Enable'} this routine`;
|
|
11315
|
+
// One sentence for all three surfaces a blocked ▶ speaks through: the hover tip, the `?`
|
|
11316
|
+
// band (which reads data-blocked-reason), and the toast when a click still reaches the
|
|
11317
|
+
// server and is refused. A static "Run now" tip on a button that will not run is the same
|
|
11318
|
+
// lie the toast used to tell.
|
|
11319
|
+
//
|
|
11320
|
+
// The HOVER surface is real, and it was measured rather than assumed — two reviewers
|
|
11321
|
+
// independently predicted it was dead, reasoning that a `disabled` control dispatches no mouse
|
|
11322
|
+
// events at all. It suppresses ACTIVATION events (click), not pointing: `mouseover` still fires,
|
|
11323
|
+
// so `app.js`'s delegated handler resolves it, and parked away the tooltip is down while hovering
|
|
11324
|
+
// the greyed ▶ raises it with this sentence. What that rests on is `.rtn-act` carrying no
|
|
11325
|
+
// `pointer-events: none` when disabled — add one and the tip really would go silent, while
|
|
11326
|
+
// the `?` band (which reads the attribute, not the pointer) would carry on working.
|
|
11327
|
+
const runTip = running ? RTN_ALREADY_RUNNING : 'Run now';
|
|
10486
11328
|
return `
|
|
10487
11329
|
<div class="rtn-item ${isTrigger ? 'trigger ' : ''}${r.enabled ? '' : 'disabled'} ${running ? 'running' : ''}" data-id="${escapeAttr(r.id)}">
|
|
10488
11330
|
<div class="rtn-main">
|
|
@@ -10498,7 +11340,7 @@
|
|
|
10498
11340
|
<input type="checkbox" data-rtn-toggle="${escapeAttr(r.id)}" ${r.enabled ? 'checked' : ''}>
|
|
10499
11341
|
<span class="rtn-toggle-track"></span>
|
|
10500
11342
|
</label>
|
|
10501
|
-
${isTrigger ? '' : `<button class="rtn-act" data-rtn-run="${escapeAttr(r.id)}" data-
|
|
11343
|
+
${isTrigger ? '' : `<button class="rtn-act" data-rtn-run="${escapeAttr(r.id)}" data-command-id="shell.routine-run#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(r.name)}" aria-label="Run ${escapeAttr(r.name)} now" data-tip="${escapeAttr(runTip)}"${running ? ` disabled data-blocked-reason="${escapeAttr(RTN_ALREADY_RUNNING)}"` : ''}>▶</button>`}
|
|
10502
11344
|
<button class="rtn-act" data-rtn-edit="${escapeAttr(r.id)}" data-tip="Edit">✎</button>
|
|
10503
11345
|
<button class="rtn-act rtn-del-act" data-rtn-del="${escapeAttr(r.id)}" data-tip="Delete">×</button>
|
|
10504
11346
|
</div>
|
|
@@ -10519,10 +11361,22 @@
|
|
|
10519
11361
|
async function runRoutineNow(id) {
|
|
10520
11362
|
try {
|
|
10521
11363
|
await api(`/api/routines/${encodeURIComponent(id)}/run`, { method: 'POST' });
|
|
10522
|
-
runningRoutines.add(id);
|
|
11364
|
+
runningRoutines.add(id); // optimistic, for immediate feedback; SSE confirms it moments later
|
|
10523
11365
|
renderRoutinesList();
|
|
10524
11366
|
showToast('Routine started', 'ok');
|
|
10525
|
-
} catch (e) {
|
|
11367
|
+
} catch (e) {
|
|
11368
|
+
// 409 with running:true — the server refused because this routine is already queued or mid-run,
|
|
11369
|
+
// and nothing was started, so never say it was. Keyed on the FLAG rather than the status: this
|
|
11370
|
+
// route is lifecycle-gated, so a 409 can also mean "aware is busy with maintenance", which is a
|
|
11371
|
+
// different sentence and belongs in the error path.
|
|
11372
|
+
if (!(e.body && e.body.running)) { reportErr(e); return; }
|
|
11373
|
+
showToast(RTN_ALREADY_RUNNING, 'info');
|
|
11374
|
+
// RECONCILE rather than add: the 409 is a point-in-time snapshot, and the run can end while the
|
|
11375
|
+
// response is in flight. Adding the id locally would then re-assert a run that the
|
|
11376
|
+
// routine-run-ended handler has already cleared, leaving the row greyed with no end event left
|
|
11377
|
+
// to arrive. Every sibling handler here reloads for the same reason.
|
|
11378
|
+
loadRoutinesData();
|
|
11379
|
+
}
|
|
10526
11380
|
}
|
|
10527
11381
|
// Destructive-action confirm. Cancel holds focus (so Enter/Esc/backdrop all cancel);
|
|
10528
11382
|
// only an explicit Delete click removes the routine. Resolves true to proceed.
|
|
@@ -11026,7 +11880,7 @@
|
|
|
11026
11880
|
}
|
|
11027
11881
|
// The pin's OWN projectId, stashed on the row when it was painted — never a guess about which
|
|
11028
11882
|
// project is "current" in the other mode.
|
|
11029
|
-
ws.openKnowledgePage($kbInformed.dataset.kbProject, btn.dataset.kbSlug);
|
|
11883
|
+
ws.openKnowledgePage($kbInformed.dataset.kbProject, btn.dataset.kbSlug, $kbInformed.dataset.kbGeneration || null);
|
|
11030
11884
|
});
|
|
11031
11885
|
|
|
11032
11886
|
// Take over the menu/keyboard Save from app.js's demo stub: in the real app the
|