@floless/app 0.133.1 → 0.134.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 +138 -46
- package/dist/web/app.css +101 -0
- package/dist/web/app.js +68 -1
- package/dist/web/aware.js +316 -8
- package/dist/web/commands-shell.js +36 -1
- package/dist/web/commands-steel.js +22 -0
- package/dist/web/commands.js +11 -0
- package/dist/web/index.html +15 -3
- package/dist/web/instructor.js +1 -1
- package/dist/web/steel-3d-core.js +87 -0
- package/dist/web/steel-3d-view.js +363 -6
- package/dist/web/steel-editor.html +179 -19
- package/dist/web/workspaces.js +186 -13
- package/package.json +1 -1
package/dist/web/aware.js
CHANGED
|
@@ -171,6 +171,15 @@
|
|
|
171
171
|
const readInstructorAnswerIds = storedAnswerIds(ANSWER_READ_KEY);
|
|
172
172
|
let answerGlowTimer = null;
|
|
173
173
|
let leftPaneTab = 'narrative';
|
|
174
|
+
// Per-id collapse state (session only, never persisted): a card is collapsed iff its id is here.
|
|
175
|
+
// Keyed by id, never position — cards insert at the TOP, so an index would drift under new arrivals.
|
|
176
|
+
const collapsedAnswerIds = new Set();
|
|
177
|
+
// Deferred-commit removal. `×` hides the card immediately and starts a timer; the DELETE fires only
|
|
178
|
+
// when the timer elapses, so an Undo within the window is a pure client-side restore with no server
|
|
179
|
+
// round-trip. The id stays in `pendingDeleteAnswerIds` (filtered out of every render) until then.
|
|
180
|
+
const pendingDeleteAnswerIds = new Set();
|
|
181
|
+
const answerDeleteTimers = new Map();
|
|
182
|
+
const ANSWER_UNDO_MS = 6000;
|
|
174
183
|
|
|
175
184
|
function selectLeftPaneTab(tab, { focus = false, explicit = false } = {}) {
|
|
176
185
|
leftPaneTab = tab === 'answers' ? 'answers' : 'narrative';
|
|
@@ -216,18 +225,308 @@
|
|
|
216
225
|
return !answer.project && !!currentId && answer.appId === currentId;
|
|
217
226
|
}
|
|
218
227
|
|
|
228
|
+
/* The terminal AI writes its answer as markdown, and the card used to render that markdown raw —
|
|
229
|
+
a reader met a literal `# Dimension` and `**Where this lives:**` where a heading and a bold lead
|
|
230
|
+
belonged. This handles the block shapes those answers actually contain; mdInline still does the
|
|
231
|
+
inline half (bold, code, italic).
|
|
232
|
+
|
|
233
|
+
ESCAPE FIRST, then build. Every branch below composes markup out of text that can no longer
|
|
234
|
+
carry any, which is the order the guide description in this file already uses and the reason the
|
|
235
|
+
`<img src=x onerror=…>` case in instructor-answers-rendered.test.ts stays inert prose.
|
|
236
|
+
|
|
237
|
+
ponytail: hand-rolled for the handful of line shapes these answers use rather than shipping a
|
|
238
|
+
markdown library into web/ — reach for one when answers start carrying tables, links, nested
|
|
239
|
+
lists, or 4-space-indented code (which flattens into a paragraph here; fenced blocks are what
|
|
240
|
+
the models actually emit, and indent-detection would misfire on list continuations). */
|
|
241
|
+
function answerProse(raw) {
|
|
242
|
+
const out = [];
|
|
243
|
+
let list = null;
|
|
244
|
+
let para = [];
|
|
245
|
+
let fence = null;
|
|
246
|
+
const closeList = () => { if (list) { out.push(`</${list}>`); list = null; } };
|
|
247
|
+
// Joined with <br>, not a space. The renderer this replaced turned EVERY newline into one, and a
|
|
248
|
+
// model that hard-wraps a paragraph, or writes `key: value` runs and unbulleted steps as bare
|
|
249
|
+
// lines, would otherwise have that structure silently collapse into one running sentence. Soft-
|
|
250
|
+
// wrap joining is the stricter markdown reading; fidelity to what the AI laid out matters more
|
|
251
|
+
// here, and a blank line still starts a real new paragraph.
|
|
252
|
+
const closePara = () => { if (para.length) { out.push(`<p>${mdInline(para.join('<br>'))}</p>`); para = []; } };
|
|
253
|
+
const openList = (kind) => { if (list !== kind) { closeList(); out.push(`<${kind}>`); list = kind; } };
|
|
254
|
+
|
|
255
|
+
for (const line of escapeHtml(raw || '').split(/\r?\n/)) {
|
|
256
|
+
if (/^\s*```/.test(line)) {
|
|
257
|
+
if (fence) { out.push(`<pre><code>${fence.join('\n')}</code></pre>`); fence = null; }
|
|
258
|
+
else { closePara(); closeList(); fence = []; }
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (fence) { fence.push(line); continue; }
|
|
262
|
+
|
|
263
|
+
// `\S` first: `"## "` with nothing after it would otherwise match, `.trim()` to empty, and emit
|
|
264
|
+
// an EMPTY heading — the characters gone from the screen and an accessibility failure ("heading
|
|
265
|
+
// must have content") in their place. Failing the match instead drops it to a paragraph, where
|
|
266
|
+
// the degenerate input at least stays visible as the text the model typed.
|
|
267
|
+
const heading = /^(#{1,6})\s+(\S.*)$/.exec(line);
|
|
268
|
+
if (heading) {
|
|
269
|
+
closePara(); closeList();
|
|
270
|
+
// Levels collapse to h3/h4/h5: this is a card in a narrow side panel, so a document h1 would
|
|
271
|
+
// be both oversized here and a lie about the page's outline.
|
|
272
|
+
const tag = heading[1].length === 1 ? 'h3' : heading[1].length === 2 ? 'h4' : 'h5';
|
|
273
|
+
out.push(`<${tag}>${mdInline(heading[2].trim())}</${tag}>`);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const bullet = /^\s*[-*]\s+(.+)$/.exec(line);
|
|
278
|
+
const numbered = /^\s*\d+[.)]\s+(.+)$/.exec(line);
|
|
279
|
+
if (bullet || numbered) {
|
|
280
|
+
closePara();
|
|
281
|
+
openList(bullet ? 'ul' : 'ol');
|
|
282
|
+
out.push(`<li>${mdInline((bullet || numbered)[1].trim())}</li>`);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (!line.trim()) { closePara(); closeList(); continue; }
|
|
287
|
+
// closeList BEFORE the paragraph opens. A prose line after a list item used to append a <p>
|
|
288
|
+
// while the <ul> was still open — content the parser keeps but the list semantics lose, since
|
|
289
|
+
// <p> is not permitted content for <ul> and a screen reader stops reading it as part of the
|
|
290
|
+
// list. The line becomes a paragraph AFTER the list instead.
|
|
291
|
+
closeList();
|
|
292
|
+
para.push(line.trim());
|
|
293
|
+
}
|
|
294
|
+
// An unterminated fence still renders as the code block it was opening, rather than vanishing.
|
|
295
|
+
if (fence) out.push(`<pre><code>${fence.join('\n')}</code></pre>`);
|
|
296
|
+
closePara(); closeList();
|
|
297
|
+
return out.join('');
|
|
298
|
+
}
|
|
299
|
+
|
|
219
300
|
function answerCard(answer, isNew) {
|
|
220
|
-
const
|
|
221
|
-
const
|
|
301
|
+
const subjectText = answer.instructorContext.subject || 'this context';
|
|
302
|
+
const subject = escapeHtml(subjectText);
|
|
303
|
+
const prose = answerProse(answer.answer);
|
|
222
304
|
const runtime = answer.runtime === 'claude' ? 'Claude' : answer.runtime === 'codex' ? 'Codex' : 'terminal AI';
|
|
223
305
|
const card = msgEl(`aware instructor-answer${isNew ? ' instructor-answer-new' : ''}`,
|
|
224
306
|
`${runtime} · ${subject}`,
|
|
225
307
|
`<span class="answer-new-badge">New answer</span>${prose}`,
|
|
226
308
|
answer.finishedAt);
|
|
227
309
|
card.dataset.answerId = answer.id;
|
|
310
|
+
|
|
311
|
+
// A fresh arrival always renders expanded — the glow-and-scroll is meant to reveal its content, so
|
|
312
|
+
// a card that lit up and then hid its own body would be actively confusing. Otherwise honour the
|
|
313
|
+
// per-id collapse the user set.
|
|
314
|
+
const collapsed = !isNew && collapsedAnswerIds.has(answer.id);
|
|
315
|
+
if (collapsed) card.classList.add('answer-collapsed');
|
|
316
|
+
const body = card.querySelector('.body');
|
|
317
|
+
const bodyId = `answer-body-${answer.id}`;
|
|
318
|
+
if (body) body.id = bodyId;
|
|
319
|
+
const who = card.querySelector('.who');
|
|
320
|
+
if (who) who.classList.add('answer-who');
|
|
321
|
+
|
|
322
|
+
// The chevron owns the disclosure and the × owns the removal — two independent buttons, never one
|
|
323
|
+
// nested in the other. A header that wraps a nested × steals the delete button's hit box the moment
|
|
324
|
+
// closest() routes a click (see reference_nested_control_in_role_button_card.md).
|
|
325
|
+
const chevron = document.createElement('button');
|
|
326
|
+
chevron.type = 'button';
|
|
327
|
+
chevron.className = 'answer-collapse-toggle';
|
|
328
|
+
chevron.textContent = '▸';
|
|
329
|
+
chevron.setAttribute('aria-controls', bodyId);
|
|
330
|
+
setCollapseToggleState(chevron, collapsed, `${runtime} · ${subjectText}`);
|
|
331
|
+
chevron.onclick = () => toggleAnswerCollapse(answer.id);
|
|
332
|
+
|
|
333
|
+
const del = document.createElement('button');
|
|
334
|
+
del.type = 'button';
|
|
335
|
+
del.className = 'answer-del';
|
|
336
|
+
del.textContent = '×';
|
|
337
|
+
del.setAttribute('aria-label', `Remove this answer, ${runtime} · ${subjectText}`);
|
|
338
|
+
del.setAttribute('data-tip', 'Remove this answer');
|
|
339
|
+
del.onclick = () => removeAnswerWithUndo(answer.id);
|
|
340
|
+
|
|
341
|
+
if (who) {
|
|
342
|
+
who.insertBefore(chevron, who.firstChild); // chevron | name … time | ×
|
|
343
|
+
who.appendChild(del);
|
|
344
|
+
}
|
|
228
345
|
return card;
|
|
229
346
|
}
|
|
230
347
|
|
|
348
|
+
// One place that writes the chevron's per-state ARIA/tooltip, so the toggle and the card class can
|
|
349
|
+
// never drift. `expanded` name folds the subject in so a screen reader tells the per-card toggles
|
|
350
|
+
// apart from each other and from the bulk one.
|
|
351
|
+
function setCollapseToggleState(chevron, collapsed, name) {
|
|
352
|
+
chevron.setAttribute('aria-expanded', String(!collapsed));
|
|
353
|
+
chevron.setAttribute('aria-label', `${collapsed ? 'Expand' : 'Collapse'} this answer, ${name}`);
|
|
354
|
+
chevron.setAttribute('data-tip', collapsed ? 'Expand this answer' : 'Collapse this answer');
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function announceAnswers(message) {
|
|
358
|
+
const status = document.getElementById('narrative-answer-status');
|
|
359
|
+
if (status) status.textContent = message;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Toggle one card in place (no full re-render): flip the class + the chevron's ARIA, then re-derive
|
|
363
|
+
// the bulk button's aggregate label from what is now on screen.
|
|
364
|
+
function toggleAnswerCollapse(id) {
|
|
365
|
+
const willCollapse = !collapsedAnswerIds.has(id);
|
|
366
|
+
if (willCollapse) collapsedAnswerIds.add(id); else collapsedAnswerIds.delete(id);
|
|
367
|
+
const card = document.querySelector(`#ai-answers [data-answer-id="${CSS.escape(id)}"]`);
|
|
368
|
+
if (card) {
|
|
369
|
+
card.classList.toggle('answer-collapsed', willCollapse);
|
|
370
|
+
const chevron = card.querySelector('.answer-collapse-toggle');
|
|
371
|
+
const name = card.querySelector('.who-name')?.textContent || 'this context';
|
|
372
|
+
if (chevron) setCollapseToggleState(chevron, willCollapse, name);
|
|
373
|
+
}
|
|
374
|
+
syncAnswerBulkToggle();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// The bulk toggle's label is DERIVED, never stored: any card expanded → it offers "Collapse all";
|
|
378
|
+
// none expanded → "Expand all". A fresh arrival (always expanded) naturally returns it to the mixed
|
|
379
|
+
// state with no special-casing. Reads the live DOM so a single-card toggle keeps it honest too.
|
|
380
|
+
function syncAnswerBulkToggle() {
|
|
381
|
+
const button = document.getElementById('answers-collapse-all');
|
|
382
|
+
if (!button) return;
|
|
383
|
+
const cards = [...document.querySelectorAll('#ai-answers [data-answer-id]')];
|
|
384
|
+
const anyExpanded = cards.some((card) => !card.classList.contains('answer-collapsed'));
|
|
385
|
+
button.textContent = anyExpanded ? 'Collapse all' : 'Expand all';
|
|
386
|
+
button.setAttribute('aria-expanded', String(anyExpanded));
|
|
387
|
+
button.setAttribute('data-tip', anyExpanded ? 'Collapse every answer shown here' : 'Expand every answer shown here');
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function toggleAllAnswers(visible) {
|
|
391
|
+
const anyExpanded = visible.some((answer) => !collapsedAnswerIds.has(answer.id));
|
|
392
|
+
for (const answer of visible) {
|
|
393
|
+
if (anyExpanded) collapsedAnswerIds.add(answer.id); else collapsedAnswerIds.delete(answer.id);
|
|
394
|
+
}
|
|
395
|
+
renderInstructorAnswers({ revealNew: false });
|
|
396
|
+
announceAnswers(`${anyExpanded ? 'Collapsed' : 'Expanded'} ${visible.length} answer${visible.length === 1 ? '' : 's'}`);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// The bulk row: a count on the left, the two actions on the right — the same shape as the Requests
|
|
400
|
+
// scope row. Built fresh each render (its handlers close over THIS paint's `visible`), which is also
|
|
401
|
+
// why "Clear all" acts on the snapshot the user is looking at, never a freshly re-derived scope.
|
|
402
|
+
function answersToolbar(visible) {
|
|
403
|
+
const bar = document.createElement('div');
|
|
404
|
+
bar.className = 'answers-toolbar';
|
|
405
|
+
bar.id = 'answers-toolbar';
|
|
406
|
+
|
|
407
|
+
const count = document.createElement('span');
|
|
408
|
+
count.className = 'answers-count';
|
|
409
|
+
count.textContent = `${visible.length} answer${visible.length === 1 ? '' : 's'}`;
|
|
410
|
+
|
|
411
|
+
const spacer = document.createElement('span');
|
|
412
|
+
spacer.className = 'answers-toolbar-spacer';
|
|
413
|
+
spacer.setAttribute('aria-hidden', 'true');
|
|
414
|
+
|
|
415
|
+
const collapseAll = document.createElement('button');
|
|
416
|
+
collapseAll.type = 'button';
|
|
417
|
+
collapseAll.id = 'answers-collapse-all';
|
|
418
|
+
collapseAll.className = 'answers-bulk';
|
|
419
|
+
collapseAll.setAttribute('data-command-id', 'shell.answers-collapse-all');
|
|
420
|
+
collapseAll.setAttribute('aria-label', 'Collapse or expand all answers');
|
|
421
|
+
collapseAll.textContent = 'Collapse all';
|
|
422
|
+
collapseAll.onclick = () => toggleAllAnswers(visible);
|
|
423
|
+
|
|
424
|
+
const clearAll = document.createElement('button');
|
|
425
|
+
clearAll.type = 'button';
|
|
426
|
+
clearAll.id = 'answers-clear-all';
|
|
427
|
+
clearAll.className = 'answers-bulk answers-clear';
|
|
428
|
+
clearAll.setAttribute('data-command-id', 'shell.answers-clear');
|
|
429
|
+
clearAll.textContent = 'Clear all';
|
|
430
|
+
clearAll.setAttribute('data-tip', visible.length === 1 ? 'Remove this answer' : `Remove all ${visible.length} answers shown here`);
|
|
431
|
+
clearAll.onclick = () => clearAllAnswers(visible);
|
|
432
|
+
|
|
433
|
+
bar.append(count, spacer, collapseAll, clearAll);
|
|
434
|
+
return bar;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// `×` on a card: hide it now, offer Undo, and only commit the (permanent) server delete once the
|
|
438
|
+
// window elapses. Keyed by id throughout so a card arriving mid-window can't shift what a timer or a
|
|
439
|
+
// focus target points at.
|
|
440
|
+
function removeAnswerWithUndo(id) {
|
|
441
|
+
if (pendingDeleteAnswerIds.has(id)) return;
|
|
442
|
+
// The card that will take this one's on-screen slot, captured BEFORE the re-render, so focus never
|
|
443
|
+
// falls to <body>. nextElementSibling first (the one just below), else the one above — a heuristic
|
|
444
|
+
// that holds whatever the sort order is.
|
|
445
|
+
const removing = document.querySelector(`#ai-answers [data-answer-id="${CSS.escape(id)}"]`);
|
|
446
|
+
const neighbourId = removing?.nextElementSibling?.dataset?.answerId
|
|
447
|
+
|| removing?.previousElementSibling?.dataset?.answerId
|
|
448
|
+
|| null;
|
|
449
|
+
|
|
450
|
+
pendingDeleteAnswerIds.add(id);
|
|
451
|
+
renderInstructorAnswers({ revealNew: false });
|
|
452
|
+
const focusTarget = neighbourId
|
|
453
|
+
? document.querySelector(`#ai-answers [data-answer-id="${CSS.escape(neighbourId)}"] .answer-collapse-toggle`)
|
|
454
|
+
: (document.getElementById('answers-collapse-all') || document.querySelector('.ai-answers-empty'));
|
|
455
|
+
focusTarget?.focus?.({ preventScroll: true });
|
|
456
|
+
announceAnswers('Answer removed');
|
|
457
|
+
|
|
458
|
+
const commit = async () => {
|
|
459
|
+
answerDeleteTimers.delete(id);
|
|
460
|
+
// The reload is INSIDE the guard: a blip on loadRequests() after the DELETE already landed would
|
|
461
|
+
// otherwise reject this setTimeout-fired async fn as an unhandled rejection (no toast, no log) and
|
|
462
|
+
// strand the id in pendingDeleteAnswerIds forever. `finally` drops the pending id and repaints on
|
|
463
|
+
// every path, matching how deleteOneRequest wraps DELETE + reload + render in one try.
|
|
464
|
+
try {
|
|
465
|
+
await api(`/api/requests/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
466
|
+
await loadRequests(); // refreshes instructorAnswers (the row is gone server-side now)
|
|
467
|
+
} catch (error) {
|
|
468
|
+
reportErr(error);
|
|
469
|
+
} finally {
|
|
470
|
+
pendingDeleteAnswerIds.delete(id);
|
|
471
|
+
renderInstructorAnswers({ revealNew: false });
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
answerDeleteTimers.set(id, setTimeout(commit, ANSWER_UNDO_MS));
|
|
475
|
+
|
|
476
|
+
// Pass ANSWER_UNDO_MS so the visible toast and the commit window are ONE number, not two literals
|
|
477
|
+
// that happen to match — bump the constant and the toast follows.
|
|
478
|
+
showUndoToast('Answer removed', () => {
|
|
479
|
+
const timer = answerDeleteTimers.get(id);
|
|
480
|
+
if (!timer) return; // already committed — a late Undo is a safe no-op
|
|
481
|
+
clearTimeout(timer);
|
|
482
|
+
answerDeleteTimers.delete(id);
|
|
483
|
+
pendingDeleteAnswerIds.delete(id);
|
|
484
|
+
renderInstructorAnswers({ revealNew: false });
|
|
485
|
+
document.querySelector(`#ai-answers [data-answer-id="${CSS.escape(id)}"] .answer-collapse-toggle`)?.focus?.({ preventScroll: true });
|
|
486
|
+
announceAnswers('Removal undone');
|
|
487
|
+
}, ANSWER_UNDO_MS);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// "Clear all" removes every answer in the SHOWN scope, confirmed once. No undo here (that was the
|
|
491
|
+
// deliberate split: undo for a single mis-click, a confirm for the bulk wipe). Per-id DELETE in a
|
|
492
|
+
// loop, exactly how the Requests dialog clears a scoped set — an answer's id IS its request id.
|
|
493
|
+
async function clearAllAnswers(visible) {
|
|
494
|
+
const ids = visible.map((answer) => answer.id);
|
|
495
|
+
if (!ids.length) return;
|
|
496
|
+
if (!(await confirmClearAnswers(ids.length))) return;
|
|
497
|
+
try {
|
|
498
|
+
for (const id of ids) await api(`/api/requests/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
499
|
+
await loadRequests();
|
|
500
|
+
renderInstructorAnswers({ revealNew: false });
|
|
501
|
+
announceAnswers(`Cleared ${ids.length} answer${ids.length === 1 ? '' : 's'}`);
|
|
502
|
+
showToast(`Cleared ${ids.length} answer${ids.length === 1 ? '' : 's'}`, 'ok');
|
|
503
|
+
} catch (error) { reportErr(error); }
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function confirmClearAnswers(count) {
|
|
507
|
+
return new Promise((resolve) => {
|
|
508
|
+
const modal = document.getElementById('answers-clear-modal');
|
|
509
|
+
const sub = document.getElementById('answers-clear-sub');
|
|
510
|
+
const confirm = document.getElementById('answers-clear-confirm');
|
|
511
|
+
const cancel = document.getElementById('answers-clear-cancel');
|
|
512
|
+
if (!modal || !confirm || !cancel) { resolve(false); return; }
|
|
513
|
+
if (sub) sub.textContent = `Remove ${count === 1 ? 'this answer' : `all ${count} answers`} shown here? This can’t be undone.`;
|
|
514
|
+
showModal(modal);
|
|
515
|
+
setTimeout(() => cancel.focus(), 0); // Cancel holds default focus, mirroring the routine delete
|
|
516
|
+
const done = (result) => {
|
|
517
|
+
hideModal(modal);
|
|
518
|
+
confirm.onclick = cancel.onclick = modal.onclick = null;
|
|
519
|
+
document.removeEventListener('keydown', onKey, true);
|
|
520
|
+
resolve(result);
|
|
521
|
+
};
|
|
522
|
+
const onKey = (event) => { if (event.key === 'Escape') { event.preventDefault(); done(false); } };
|
|
523
|
+
confirm.onclick = () => done(true);
|
|
524
|
+
cancel.onclick = () => done(false);
|
|
525
|
+
onBackdropDismiss(modal, () => done(false));
|
|
526
|
+
document.addEventListener('keydown', onKey, true);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
|
|
231
530
|
function acceptInstructorAnswers(answers, { initial = false } = {}) {
|
|
232
531
|
instructorAnswers = answers;
|
|
233
532
|
if (initial) {
|
|
@@ -255,8 +554,13 @@
|
|
|
255
554
|
function renderInstructorAnswers({ revealNew = true } = {}) {
|
|
256
555
|
const feed = document.getElementById('ai-answers');
|
|
257
556
|
if (!feed) return;
|
|
258
|
-
|
|
259
|
-
|
|
557
|
+
// A card mid-way through the deferred-delete window is filtered out of every render, so a poll
|
|
558
|
+
// that refreshes the feed can't flash it back into view before its Undo window closes.
|
|
559
|
+
const visible = instructorAnswers.filter(answerInVisibleScope).filter((answer) => !pendingDeleteAnswerIds.has(answer.id));
|
|
560
|
+
// Newest-first: the latest answer sits at the top. A blind reverse of the stored order would ride
|
|
561
|
+
// on filesystem read order; sorting on finishedAt is the ordering the user actually asked for.
|
|
562
|
+
const ordered = [...visible].sort((a, b) => String(b.finishedAt || '').localeCompare(String(a.finishedAt || '')));
|
|
563
|
+
const wasNearTop = feed.scrollTop < 72;
|
|
260
564
|
const unseen = revealNew ? visible.filter((answer) => arrivedInstructorAnswerIds.has(answer.id)) : [];
|
|
261
565
|
const unreadCount = visible.filter((answer) => !readInstructorAnswerIds.has(answer.id)).length;
|
|
262
566
|
const unreadBadge = document.getElementById('answer-unread');
|
|
@@ -269,12 +573,14 @@
|
|
|
269
573
|
else answersTab?.removeAttribute('aria-label');
|
|
270
574
|
const newAnswer = unseen.length ? unseen[unseen.length - 1] : null;
|
|
271
575
|
feed.innerHTML = '';
|
|
272
|
-
if (!
|
|
576
|
+
if (!ordered.length) {
|
|
273
577
|
const scope = wsRequestScope?.kind === 'project' ? 'this project' : wsRequestScope ? 'Workspaces' : 'this workflow';
|
|
274
|
-
feed.innerHTML = `<div class="ai-answers-empty">No AI answers for ${scope} yet. Direct answers you start from Instructor will appear here.</div>`;
|
|
578
|
+
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>`;
|
|
275
579
|
} else {
|
|
276
|
-
|
|
580
|
+
feed.appendChild(answersToolbar(ordered)); // sticky bulk row — first child, hidden with an empty feed by simply not existing
|
|
581
|
+
ordered.forEach((answer) => feed.appendChild(answerCard(answer, answer === newAnswer)));
|
|
277
582
|
}
|
|
583
|
+
syncAnswerBulkToggle();
|
|
278
584
|
if (!newAnswer) {
|
|
279
585
|
return;
|
|
280
586
|
}
|
|
@@ -297,7 +603,9 @@
|
|
|
297
603
|
document.getElementById('ai-answers-tab')?.classList.add('instructor-answer-new');
|
|
298
604
|
}
|
|
299
605
|
const card = feed.querySelector(`[data-answer-id="${CSS.escape(newAnswer.id)}"]`);
|
|
300
|
-
|
|
606
|
+
// Newest-first puts the arrival at the TOP, so the auto-scroll follows a reader sitting near the
|
|
607
|
+
// top — not the bottom, which now holds the oldest answers someone may be mid-read of.
|
|
608
|
+
if (card && !obscured && (wasCollapsed || (paneAlreadyOpenOnAnswers && wasNearTop))) requestAnimationFrame(() => card.scrollIntoView({ block: 'nearest' }));
|
|
301
609
|
const status = document.getElementById('narrative-answer-status');
|
|
302
610
|
if (status) status.textContent = wasCollapsed && !obscured
|
|
303
611
|
? `Terminal AI answered about ${newAnswer.instructorContext.subject}. AI answers opened.`
|
|
@@ -664,13 +664,16 @@
|
|
|
664
664
|
});
|
|
665
665
|
|
|
666
666
|
def('shell.narrative-tab', {
|
|
667
|
-
label: 'Narrative', actsOn: 'Shows curated workflow and run narration
|
|
667
|
+
label: 'Narrative', actsOn: 'Shows curated workflow and run narration, not the chat transcript',
|
|
668
|
+
group: 'In the Narrative panel',
|
|
668
669
|
persistence: 'none', interaction: 'mode', risk: [], guidance: 'on-demand',
|
|
670
|
+
why: 'Narration follows the workflow, so a question you asked lands under AI answers instead — this tab never fills up with your own prompts.',
|
|
669
671
|
});
|
|
670
672
|
|
|
671
673
|
def('shell.ai-answers-tab', {
|
|
672
674
|
label: 'AI answers', actsOn: 'Shows durable read-only answers for the visible workflow or project', group: 'In the Narrative panel',
|
|
673
675
|
persistence: 'none', interaction: 'mode', risk: [], guidance: 'on-demand',
|
|
676
|
+
why: 'An answer outlives the run that wrote it, so a question asked once stays readable here instead of scrolling away in the terminal.',
|
|
674
677
|
});
|
|
675
678
|
|
|
676
679
|
def('shell.requests-run', {
|
|
@@ -1086,6 +1089,38 @@
|
|
|
1086
1089
|
guidance: 'on-demand',
|
|
1087
1090
|
});
|
|
1088
1091
|
|
|
1092
|
+
def('shell.answers-collapse-all', {
|
|
1093
|
+
label: 'Collapse or expand all answers',
|
|
1094
|
+
actsOn: 'Folds every answer down to its header, or opens them all back up',
|
|
1095
|
+
group: 'In the AI answers tab',
|
|
1096
|
+
persistence: 'none',
|
|
1097
|
+
interaction: 'instant',
|
|
1098
|
+
risk: [],
|
|
1099
|
+
guidance: 'on-demand',
|
|
1100
|
+
why: 'A long answer you have read can get out of the way without being removed.',
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
def('shell.answers-clear', {
|
|
1104
|
+
label: 'Clear all answers',
|
|
1105
|
+
actsOn: 'Removes every answer shown here after you confirm',
|
|
1106
|
+
group: 'In the AI answers tab',
|
|
1107
|
+
persistence: 'working',
|
|
1108
|
+
interaction: 'dialog',
|
|
1109
|
+
risk: ['destructive'],
|
|
1110
|
+
guidance: 'on-demand',
|
|
1111
|
+
why: 'Answers are durable records, so the bulk wipe asks first — a single one has an Undo instead.',
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
def('shell.answers-clear-confirm', {
|
|
1115
|
+
label: 'Clear the AI answers',
|
|
1116
|
+
actsOn: 'Removes the answers for good',
|
|
1117
|
+
group: 'In the AI answers tab',
|
|
1118
|
+
persistence: 'working',
|
|
1119
|
+
interaction: 'instant',
|
|
1120
|
+
risk: ['destructive'],
|
|
1121
|
+
guidance: 'on-demand',
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1089
1124
|
def('shell.request-help-copy', {
|
|
1090
1125
|
label: 'Copy the request',
|
|
1091
1126
|
actsOn: 'Puts this request on your clipboard',
|
|
@@ -877,6 +877,17 @@
|
|
|
877
877
|
guidance: 'on-demand',
|
|
878
878
|
});
|
|
879
879
|
|
|
880
|
+
def('steel.position-gizmo', {
|
|
881
|
+
label: 'Position handle',
|
|
882
|
+
actsOn: 'Shows a drag handle on the selected member for setting its Profile Position in 3D',
|
|
883
|
+
group: 'In the ⋯ menu — Display',
|
|
884
|
+
persistence: 'local',
|
|
885
|
+
interaction: 'instant',
|
|
886
|
+
risk: [],
|
|
887
|
+
guidance: 'on-demand',
|
|
888
|
+
why: 'Turns on a Tekla-style handle at the selected member’s start point: drag the blue arrow to set the depth offset, the green arrow to set the width offset, and the red arc to set the rotation — all read in the Edit frame shown above Profile Position, the same values the Inspect panel sets, here by hand in the 3D view. Double-click a handle to type an exact value instead (it bypasses the snap). The handle works whatever coordinate system is active, and it hides the coordinate-system gizmo while it is up (and vice-versa) so their blue/green axes never clash. The reference line never moves; ¼" and 5° snaps apply unless you hold Shift, and Esc cancels a drag.',
|
|
889
|
+
});
|
|
890
|
+
|
|
880
891
|
def('steel.show-property-labels', {
|
|
881
892
|
label: 'Show property labels',
|
|
882
893
|
actsOn: 'Shows or hides the property labels on the plan',
|
|
@@ -1971,4 +1982,15 @@
|
|
|
1971
1982
|
guidance: 'on-demand',
|
|
1972
1983
|
why: 'Looks along the member from its start point with the work-line marked — the quickest way to see whether a face and an offset put the steel where you meant.',
|
|
1973
1984
|
});
|
|
1985
|
+
|
|
1986
|
+
def('steel.position-from-member', {
|
|
1987
|
+
label: 'From member',
|
|
1988
|
+
actsOn: 'Sets the coordinate system to this member’s own axes',
|
|
1989
|
+
group: 'In the Inspect panel',
|
|
1990
|
+
persistence: 'working',
|
|
1991
|
+
interaction: 'instant',
|
|
1992
|
+
risk: [],
|
|
1993
|
+
guidance: 'on-demand',
|
|
1994
|
+
why: 'Adopts the selected member’s own axes — including its roll — as the 3D coordinate system, so its Rotation then reads 0 and Depth/Width read against its own faces. The steel does not move; only the frame the numbers are read against changes, and adopting again is a no-op. 3D view only.',
|
|
1995
|
+
});
|
|
1974
1996
|
})();
|
package/dist/web/commands.js
CHANGED
|
@@ -27,6 +27,17 @@
|
|
|
27
27
|
once per FILE (surfaceScope) rather than per command, because a registration
|
|
28
28
|
file is wholly one surface — see the note beside SURFACE below.
|
|
29
29
|
|
|
30
|
+
`why` is OPTIONAL and, today, NOT READ COPY. Two consumers: the command
|
|
31
|
+
sheet's search haystack (instructor.js), and the `tip` of the entry the sheet
|
|
32
|
+
synthesizes when the command it activates has NO control on screen — a branch
|
|
33
|
+
any registered, always-rendered button never reaches, and which
|
|
34
|
+
controlGuidance would then suppress anyway because an entry carrying `actsOn`
|
|
35
|
+
never runs out of derived facts. So `why` earns a command its keyword hits
|
|
36
|
+
and covers the off-screen case; it is not what a user reads beside a live
|
|
37
|
+
control. Write it, but do not budget prose there expecting it on screen —
|
|
38
|
+
the sentence the strip reads out is `actsOn`. (Recorded because a commit
|
|
39
|
+
claimed the opposite and nothing here said otherwise.)
|
|
40
|
+
|
|
30
41
|
`guidance` exists because `interaction` alone got tiers wrong: treating every
|
|
31
42
|
gesture as a narrated command would demand step text for canvas pan and orbit,
|
|
32
43
|
which need none, while drag-to-place genuinely does.
|
package/dist/web/index.html
CHANGED
|
@@ -127,11 +127,10 @@
|
|
|
127
127
|
<aside class="chat" id="chat-panel" data-group="In the Narrative panel">
|
|
128
128
|
<div class="panel-label">
|
|
129
129
|
<span class="narrative-tabs" role="tablist" aria-label="Left panel content">
|
|
130
|
-
<button data-command-id="shell.narrative-tab" type="button" class="narrative-tab active" id="narrative-tab" role="tab" aria-selected="true" aria-controls="messages">Narrative</button>
|
|
131
|
-
<button data-command-id="shell.ai-answers-tab" type="button" class="narrative-tab" id="ai-answers-tab" role="tab" aria-selected="false" aria-controls="ai-answers" tabindex="-1">AI answers <span class="answer-unread" id="answer-unread" hidden></span></button>
|
|
130
|
+
<button data-command-id="shell.narrative-tab" type="button" class="narrative-tab active" id="narrative-tab" role="tab" aria-selected="true" aria-controls="messages" data-tip="Curated narration of this workflow and its runs — the full chat stays in your terminal AI">Narrative</button>
|
|
131
|
+
<button data-command-id="shell.ai-answers-tab" type="button" class="narrative-tab" id="ai-answers-tab" role="tab" aria-selected="false" aria-controls="ai-answers" tabindex="-1" data-tip="Answers your terminal AI wrote for an Instructor question, kept with this workflow or project">AI answers <span class="answer-unread" id="answer-unread" hidden></span></button>
|
|
132
132
|
</span>
|
|
133
133
|
<span class="label-end">
|
|
134
|
-
<span class="role">curated · full chat in your terminal</span>
|
|
135
134
|
<button data-command-id="shell.narrative-panel" type="button" class="panel-toggle" data-side="left" aria-label="Collapse Narrative panel" aria-controls="chat-panel" aria-expanded="true" data-tip="Collapse Narrative panel">‹</button>
|
|
136
135
|
</span>
|
|
137
136
|
</div>
|
|
@@ -1096,6 +1095,19 @@
|
|
|
1096
1095
|
</div>
|
|
1097
1096
|
</div>
|
|
1098
1097
|
|
|
1098
|
+
<!-- Confirm bulk-clearing the AI answers. Answers are durable result records, not queue rows, so the
|
|
1099
|
+
bulk wipe confirms (individual × has an Undo instead — the two safety nets are deliberately split). -->
|
|
1100
|
+
<div class="modal-backdrop" id="answers-clear-modal">
|
|
1101
|
+
<div class="modal">
|
|
1102
|
+
<div class="modal-title">Clear AI answers</div>
|
|
1103
|
+
<div class="modal-sub" id="answers-clear-sub"></div>
|
|
1104
|
+
<div class="modal-actions">
|
|
1105
|
+
<button data-command-id="shell.dialog-cancel#clearing the AI answers" id="answers-clear-cancel">Cancel</button>
|
|
1106
|
+
<button data-command-id="shell.answers-clear-confirm" id="answers-clear-confirm">Clear all</button>
|
|
1107
|
+
</div>
|
|
1108
|
+
</div>
|
|
1109
|
+
</div>
|
|
1110
|
+
|
|
1099
1111
|
<!-- Graft into agent — build an agent from a foreign tool (DLL / C# source /
|
|
1100
1112
|
NuGet / OpenAPI / …). The wizard body (#graft-body) is built per-step in
|
|
1101
1113
|
aware.js. AWARE reads the source + builds the agent (incl. its Tekla
|
package/dist/web/instructor.js
CHANGED
|
@@ -533,7 +533,7 @@
|
|
|
533
533
|
// the shell
|
|
534
534
|
'In the header', 'In the workflow picker', 'In the project picker',
|
|
535
535
|
'In the project workspace', 'On the workflow canvas',
|
|
536
|
-
'In the Narrative panel', 'In the node Inspect panel', 'In the Instructor strip',
|
|
536
|
+
'In the Narrative panel', 'In the AI answers tab', 'In the node Inspect panel', 'In the Instructor strip',
|
|
537
537
|
'In the ≡ menu', 'In the footer',
|
|
538
538
|
'In the contract editor', 'In the report viewer', 'In the guide',
|
|
539
539
|
'In the agent library', 'In the requests list', 'In the run request dialog', 'In the Routines dialog',
|
|
@@ -1542,6 +1542,31 @@ function cross3(a, b) {
|
|
|
1542
1542
|
return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
1543
1543
|
}
|
|
1544
1544
|
|
|
1545
|
+
/**
|
|
1546
|
+
* The world part frame the Profile Position gizmo (slice 3a) draws its arrows in, for a given authoring
|
|
1547
|
+
* basis. It is the SAME frame the bake and the inspector read (`partFrame`), so a dragged handle moves
|
|
1548
|
+
* the steel exactly where a typed offset would: width = `frame.y`, depth = `frame.z`, member axis =
|
|
1549
|
+
* `frame.x` (basis-independent). The coordinate system's normal `up` is derived from the basis
|
|
1550
|
+
* (`x × y` for a canonical orthonormal basis), never stored — global uses world Z.
|
|
1551
|
+
*
|
|
1552
|
+
* Returns null (the gizmo then shows nothing) for a zero-length member or a basis that is not a usable
|
|
1553
|
+
* frame, so a caller never has to guard `partFrame`'s throw on a degenerate `up`/`upX`.
|
|
1554
|
+
*
|
|
1555
|
+
* @param {number[]} refFrom the authored reference-line start (the gizmo anchor)
|
|
1556
|
+
* @param {number[]} refTo the authored reference-line end
|
|
1557
|
+
* @param {{kind?:string, x?:number[], y?:number[]}} basis a `positionAuthoringBasis()` snapshot
|
|
1558
|
+
* @returns {{x:number[], y:number[], z:number[], degenerate:boolean}|null}
|
|
1559
|
+
*/
|
|
1560
|
+
export function positionGizmoFrame(refFrom, refTo, basis) {
|
|
1561
|
+
let up, upX;
|
|
1562
|
+
if (!basis || basis.kind === 'global') { up = [0, 0, 1]; upX = [1, 0, 0]; }
|
|
1563
|
+
else {
|
|
1564
|
+
if (!finiteVec3(basis.x) || !finiteVec3(basis.y)) return null;
|
|
1565
|
+
up = cross3(basis.x, basis.y); upX = [basis.x[0], basis.x[1], basis.x[2]];
|
|
1566
|
+
}
|
|
1567
|
+
try { return partFrame(refFrom, refTo, up, upX); } catch (_) { return null; }
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1545
1570
|
/**
|
|
1546
1571
|
* `partFrame` with its axes reordered into the MESH's local order — the one place that says which frame
|
|
1547
1572
|
* axis each of a member geometry's local axes becomes. `orientMember` (`web/steel-3d-view.js`) feeds the
|
|
@@ -1626,6 +1651,68 @@ export function positionOffsetVector(frame, ex, depthFace, widthFace, rotDeg, wi
|
|
|
1626
1651
|
];
|
|
1627
1652
|
}
|
|
1628
1653
|
|
|
1654
|
+
// The ¼" / 5° snaps the 3D Profile Position gizmo applies to a dragged offset / roll (Shift = free).
|
|
1655
|
+
export const POSITION_OFFSET_SNAP_MM = 25.4 / 4;
|
|
1656
|
+
export const POSITION_ROT_SNAP_DEG = 5;
|
|
1657
|
+
|
|
1658
|
+
/** Round `value` to the nearest multiple of `step` (the gizmo's ¼"/5° drag snap); `step<=0` = free. */
|
|
1659
|
+
export function snapToStep(value, step) {
|
|
1660
|
+
return step > 0 ? Math.round(value / step) * step : value;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* The fold applied to a roll (deg) before it is COMMITTED to storage — the SAME `r % 360` (signed) the
|
|
1665
|
+
* Inspect panel commit already uses (`steel-editor.html:6755`/`:7053`). One shared helper so the 3D gizmo's
|
|
1666
|
+
* drag/type commit and the panel can never store two different conventions: a re-expressed base is generically
|
|
1667
|
+
* off-grid, and a cross-seam arc drag accumulates a continuous angle that can run past ±360, so the raw value
|
|
1668
|
+
* must be folded — but signed, because a detailer reads "−5°", not "355°". A non-finite roll reads as 0.
|
|
1669
|
+
*/
|
|
1670
|
+
export function rollCommitNorm(deg) {
|
|
1671
|
+
return (typeof deg === 'number' && isFinite(deg) ? deg : 0) % 360;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
/**
|
|
1675
|
+
* The shortest-arc increment (rad) from `prevRad` to `curRad`, folded into (−π, π]. Used to CONTINUOUSLY
|
|
1676
|
+
* unwrap the roll arc during a drag: summing these steps tracks the true swept angle, so crossing the ±180°
|
|
1677
|
+
* seam adds a small step instead of the ~2π jump a bare `cur − start` produces (which moved a beam ~360° in one
|
|
1678
|
+
* tick). Both `atan2` outputs live in (−π, π]; this returns their signed shortest difference.
|
|
1679
|
+
*/
|
|
1680
|
+
export function unwrapAngleStep(prevRad, curRad) {
|
|
1681
|
+
let d = curRad - prevRad;
|
|
1682
|
+
while (d > Math.PI) d -= 2 * Math.PI;
|
|
1683
|
+
while (d <= -Math.PI) d += 2 * Math.PI;
|
|
1684
|
+
return d;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* The world translation the steel undergoes when ONE numeric Profile Position offset changes by
|
|
1689
|
+
* `deltaMm` (the depth offset for `axis:'depth'`, the width offset for `'width'`), holding the other
|
|
1690
|
+
* offset, the named faces and the roll fixed. This is exactly `positionOffsetVector`'s linear response
|
|
1691
|
+
* to that offset — factored out so the 3D gizmo's live preview and the bake CANNOT drift apart. A
|
|
1692
|
+
* hand-copied second copy of this sign/swing convention is precisely the class of silent error the
|
|
1693
|
+
* clash-and-exact-placement rule exists to catch, so the gizmo's preview MUST call this, never re-derive
|
|
1694
|
+
* it. `frame` is a `partFrame` triple; the delta is measured on the section's own (unrotated) axis and
|
|
1695
|
+
* then swung by `rotDeg`, matching §1.3's position-then-rotate order.
|
|
1696
|
+
*
|
|
1697
|
+
* @param {{y:number[], z:number[]}} frame
|
|
1698
|
+
* @param {'depth'|'width'} axis
|
|
1699
|
+
* @param {number} deltaMm
|
|
1700
|
+
* @param {number} rotDeg
|
|
1701
|
+
* @returns {[number, number, number]}
|
|
1702
|
+
*/
|
|
1703
|
+
export function positionSwingDelta(frame, axis, deltaMm, rotDeg) {
|
|
1704
|
+
const th = ((typeof rotDeg === 'number' && isFinite(rotDeg) ? rotDeg : 0) * Math.PI) / 180;
|
|
1705
|
+
const c = Math.cos(th), s = Math.sin(th), d = typeof deltaMm === 'number' && isFinite(deltaMm) ? deltaMm : 0;
|
|
1706
|
+
// width offset (oy) swings to c·y + s·z ; depth offset (oz) swings to −s·y + c·z — the exact partial
|
|
1707
|
+
// derivatives of positionOffsetVector w.r.t. widthOffMm / depthOffMm.
|
|
1708
|
+
const wy = axis === 'depth' ? -s : c, wz = axis === 'depth' ? c : s;
|
|
1709
|
+
return [
|
|
1710
|
+
d * (wy * frame.y[0] + wz * frame.z[0]),
|
|
1711
|
+
d * (wy * frame.y[1] + wz * frame.z[1]),
|
|
1712
|
+
d * (wy * frame.y[2] + wz * frame.z[2]),
|
|
1713
|
+
];
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1629
1716
|
/**
|
|
1630
1717
|
* Reversing a member's two work points must leave the STEEL exactly where it is — and it takes TWO
|
|
1631
1718
|
* transforms, one per branch of `partFrame`. An earlier draft had one rule and it was wrong for a column.
|