@floless/app 0.145.0 → 0.146.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 +2703 -1659
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +37 -4
- package/dist/web/app.css +35 -0
- package/dist/web/aware.js +72 -3
- package/dist/web/chat.js +19 -8
- package/dist/web/commands-revit.js +6 -0
- package/dist/web/commands-shell.js +11 -0
- package/dist/web/commands-tekla-parser.js +6 -0
- package/dist/web/filter-ai-context.js +8 -2
- package/dist/web/index.html +11 -0
- package/dist/web/left-pane.js +4 -1
- package/dist/web/model-chat-questions.js +178 -0
- package/dist/web/model-inspector.js +44 -19
- package/dist/web/revit-editor.css +19 -0
- package/dist/web/revit-editor.js +72 -3
- package/dist/web/steel-editor.html +16 -95
- package/dist/web/workspaces.js +37 -5
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
two-phase Drawing Filter process: first prepare and save the deterministic Filter, then read only the
|
|
8
8
|
selected evidence into model-global members, registered plan views, observations, and revision history.
|
|
9
9
|
metadata:
|
|
10
|
-
version: 0.
|
|
10
|
+
version: 0.61.0
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
# Steel Takeoff — read drawings into `steel.model/v2`
|
|
@@ -1121,10 +1121,43 @@ Work in this order:
|
|
|
1121
1121
|
candidate yourself; a choice lists heights from lowest to highest and none of them is preferred.
|
|
1122
1122
|
|
|
1123
1123
|
9. **Every plan view you read members from MUST state its own `elevation_mm`.** Without one there is
|
|
1124
|
-
nowhere to place an unresolved end, and those members leave the model. If the set does not
|
|
1125
|
-
|
|
1124
|
+
nowhere to place an unresolved end, and those members leave the model. If the set does not state a
|
|
1125
|
+
plan's elevation outright, **ask the user for it before you read members from that sheet** — one
|
|
1126
1126
|
question per view, never one per member. A plan with no elevation is a question, not something to
|
|
1127
|
-
work around.
|
|
1127
|
+
work around, and you never author `elevation_mm` from your own guess.
|
|
1128
|
+
|
|
1129
|
+
**But do not ask cold for what the set carries: look at the sheets first, and where you can read a
|
|
1130
|
+
level, PROPOSE it**, quoting what you read and the sheet it is on, and author `elevation_mm` only
|
|
1131
|
+
after the user confirms or corrects it. Ask with no proposal only when the whole set is silent — and
|
|
1132
|
+
then name the sheets you checked. Where to look:
|
|
1133
|
+
|
|
1134
|
+
- the `datums[]` you recorded in the design-set knowledge — a level on a building section or frame
|
|
1135
|
+
elevation that this plan's title names (`ROOF FRAMING PLAN` → `ROOF`; a silent `SECOND FLOOR
|
|
1136
|
+
FRAMING PLAN` → `LEVEL 02` on the frame elevations);
|
|
1137
|
+
- a `T.O. STEEL` note that governs the **whole** plan's framing (a general note, `U.N.O.`). One
|
|
1138
|
+
member's callout is **not** the plan's level — it governs its own end (step 8), and a roof's
|
|
1139
|
+
callouts can span over two feet that one plan level would flatten;
|
|
1140
|
+
- the page picture (`…/pages/<pageId>/picture`), for a level that is drawn rather than written.
|
|
1141
|
+
|
|
1142
|
+
Put what you read to the server, which checks it and writes the question:
|
|
1143
|
+
`POST …/revision-requests/<id>/plan-elevation-proposal` with
|
|
1144
|
+
`{ plan: { viewId, sourceHash, pageId }, readings: [...] }`. `viewId` is the plan's id in the
|
|
1145
|
+
project's `plans[]` — the checkpoint shell's on a first read; for a plan a revised set adds, the
|
|
1146
|
+
id you will give it (the question then says the view is not registered yet). The question names a
|
|
1147
|
+
view by its sheet, so a sheet carrying **more than one** plan view is refused: ask about each of
|
|
1148
|
+
those views with no proposal, naming the view yourself. Each reading is `{ value, asRead, page: { sourceHash, pageId, sheet }, quote,
|
|
1149
|
+
elementIds }` when the sheet's text carries it, or `{ value, asRead, page, near }` when it is drawn
|
|
1150
|
+
— `value` is your conversion of `asRead` to world millimetres. A quote its cited elements do not
|
|
1151
|
+
carry is refused. **Relay the returned `proposal.ask` verbatim**: it names the sheet, quotes the
|
|
1152
|
+
drawing beside the converted value (so the person can check your conversion) and attributes every
|
|
1153
|
+
value to your reading, never to the drawings as fact, says when a reading
|
|
1154
|
+
was read off the picture and not checked, and asks whether THIS plan is at that level. Readings
|
|
1155
|
+
that disagree come back as a choice from lowest to highest with none preferred — never pick one.
|
|
1156
|
+
|
|
1157
|
+
**Propose only what you READ.** Never another plan's elevation, the plan's cut plane, or
|
|
1158
|
+
arithmetic — the server cannot tell a guess from a reading once you type it, so a guess must never
|
|
1159
|
+
reach the person dressed as one. Unlike an end's height (step 8), a plan's elevation is yours to
|
|
1160
|
+
write once the user has answered in the chat: it has always been the reader's field.
|
|
1128
1161
|
|
|
1129
1162
|
### Model-global members
|
|
1130
1163
|
|
package/dist/web/app.css
CHANGED
|
@@ -2122,6 +2122,41 @@
|
|
|
2122
2122
|
font-size: 13px; padding: 6px 0 0; font-family: var(--ui); }
|
|
2123
2123
|
.lib-update-link:hover { text-decoration: underline; }
|
|
2124
2124
|
|
|
2125
|
+
/* ========== REPORT AN ISSUE — failed-import details (#1757) ========== */
|
|
2126
|
+
/* Deliberately NOT a .modal-field: that rule stretches every input to 100% width with text padding,
|
|
2127
|
+
which would turn the consent checkbox into a bar. Same surface vocabulary as .integrations-hint. */
|
|
2128
|
+
.ri-import {
|
|
2129
|
+
margin-bottom: 12px;
|
|
2130
|
+
padding: 10px 12px;
|
|
2131
|
+
background: var(--surface-2);
|
|
2132
|
+
border: 1px solid var(--border);
|
|
2133
|
+
border-radius: 4px;
|
|
2134
|
+
}
|
|
2135
|
+
.ri-import-head {
|
|
2136
|
+
font-size: 10px;
|
|
2137
|
+
text-transform: uppercase;
|
|
2138
|
+
letter-spacing: 0.14em;
|
|
2139
|
+
color: var(--text-muted);
|
|
2140
|
+
margin-bottom: 8px;
|
|
2141
|
+
}
|
|
2142
|
+
.ri-import-list {
|
|
2143
|
+
display: grid;
|
|
2144
|
+
grid-template-columns: max-content minmax(0, 1fr);
|
|
2145
|
+
gap: 4px 12px;
|
|
2146
|
+
margin: 0 0 10px;
|
|
2147
|
+
font-size: 11px;
|
|
2148
|
+
}
|
|
2149
|
+
.ri-import-list dt { color: var(--text-dim); }
|
|
2150
|
+
.ri-import-list dd { margin: 0; color: var(--text); font-family: var(--mono); overflow-wrap: anywhere; }
|
|
2151
|
+
.ri-import-include {
|
|
2152
|
+
display: inline-flex;
|
|
2153
|
+
align-items: center;
|
|
2154
|
+
gap: 8px;
|
|
2155
|
+
font-size: 12px;
|
|
2156
|
+
color: var(--text);
|
|
2157
|
+
cursor: pointer;
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2125
2160
|
/* ========== INTEGRATIONS MODAL ========== */
|
|
2126
2161
|
.modal.integrations { width: 760px; max-height: 86vh; display: flex; flex-direction: column; }
|
|
2127
2162
|
.integrations-hint {
|
package/dist/web/aware.js
CHANGED
|
@@ -13333,6 +13333,12 @@
|
|
|
13333
13333
|
let riAwareVersion = ''; // the versions the modal promises ("sent automatically: …")
|
|
13334
13334
|
let riReturnFocus = null;
|
|
13335
13335
|
let riReturnToIntegration = false;
|
|
13336
|
+
// #1757: the failed import this report is about, set only by a failed card's "Report this problem".
|
|
13337
|
+
// Its details are attached only while the consent box is checked, and the SERVER re-reads them.
|
|
13338
|
+
let riImport = null;
|
|
13339
|
+
const $riImport = document.getElementById('ri-import');
|
|
13340
|
+
const $riImportList = document.getElementById('ri-import-list');
|
|
13341
|
+
const $riImportInclude = document.getElementById('ri-import-include');
|
|
13336
13342
|
|
|
13337
13343
|
const riSyncSend = () => { $riSend.disabled = !($riTitle.value.trim() && $riDesc.value.trim()); };
|
|
13338
13344
|
function riHideAndRestoreFocus() {
|
|
@@ -13411,6 +13417,10 @@
|
|
|
13411
13417
|
riSetCategory('bug');
|
|
13412
13418
|
riAppVersion = '';
|
|
13413
13419
|
riAwareVersion = '';
|
|
13420
|
+
riImport = null;
|
|
13421
|
+
if ($riImport) $riImport.hidden = true;
|
|
13422
|
+
if ($riImportList) $riImportList.replaceChildren();
|
|
13423
|
+
if ($riImportInclude) $riImportInclude.checked = true;
|
|
13414
13424
|
$riSend.disabled = true;
|
|
13415
13425
|
$riSend.textContent = 'Send report';
|
|
13416
13426
|
// Auto-attached diagnostics line — versions + the open workflow, read fresh from health.
|
|
@@ -13435,6 +13445,55 @@
|
|
|
13435
13445
|
riSyncSend();
|
|
13436
13446
|
});
|
|
13437
13447
|
|
|
13448
|
+
// Plain labels for the fields the server's reportDetails() returns — nothing else is ever listed.
|
|
13449
|
+
const RI_IMPORT_STAGE = { 'waiting-for-aware': 'Starting', converting: 'Converting', validating: 'Checking', publishing: 'Adding to the project' };
|
|
13450
|
+
const RI_IMPORT_KIND = { model: 'The model itself', service: 'A temporary service problem', access: 'Sign-in or access',
|
|
13451
|
+
setup: 'Setup needs repair', busy: 'Another import was running', interrupted: 'FloLess stopped mid-import',
|
|
13452
|
+
superseded: 'Replaced by a newer choice', internal: 'An unexpected FloLess problem' };
|
|
13453
|
+
// Every field the server would send is listed — what the person sees is exactly what they consent to.
|
|
13454
|
+
function riImportRows(details) {
|
|
13455
|
+
const rows = [['Import', details.importer === 'tekla' ? 'Tekla read' : 'Revit import'], ['Reference', details.operationId]];
|
|
13456
|
+
if (details.kind) rows.push(['Kind of problem', RI_IMPORT_KIND[details.kind] || details.kind]);
|
|
13457
|
+
if (details.reason) rows.push(['Why it stopped', details.reason]);
|
|
13458
|
+
if (details.stage) rows.push(['Stopped while', RI_IMPORT_STAGE[details.stage] || details.stage]);
|
|
13459
|
+
if (typeof details.elapsedSeconds === 'number') rows.push(['Time taken', `${details.elapsedSeconds} s`]);
|
|
13460
|
+
if (details.failedAt) rows.push(['Failed at', new Date(details.failedAt).toLocaleString()]);
|
|
13461
|
+
if (details.code) rows.push(['Failure code', details.code]);
|
|
13462
|
+
if (details.providerCode) rows.push(['Service code', details.providerCode]);
|
|
13463
|
+
if (details.diagnosticId) rows.push(['Diagnostic reference', details.diagnosticId]);
|
|
13464
|
+
if (details.awareRunId) rows.push(['Run reference', details.awareRunId]);
|
|
13465
|
+
return rows;
|
|
13466
|
+
}
|
|
13467
|
+
window.addEventListener('floless:report-import-issue', async (event) => {
|
|
13468
|
+
const detail = event.detail || {};
|
|
13469
|
+
const importer = detail.importer === 'tekla' ? 'tekla' : 'revit';
|
|
13470
|
+
if (typeof detail.operationId !== 'string' || !detail.operationId) return;
|
|
13471
|
+
openReportIssue();
|
|
13472
|
+
if (detail.returnFocus instanceof HTMLElement) riReturnFocus = detail.returnFocus;
|
|
13473
|
+
const noun = importer === 'tekla' ? 'Tekla read' : 'Revit import';
|
|
13474
|
+
$riTitle.value = `${noun} failed${detail.title ? `: ${detail.title}` : ''}`.slice(0, 200);
|
|
13475
|
+
$riDesc.value = `My ${noun} failed. FloLess showed: “${detail.title || 'the import failed'}”.`;
|
|
13476
|
+
riSyncSend();
|
|
13477
|
+
const ref = { importer, operationId: detail.operationId };
|
|
13478
|
+
riImport = ref;
|
|
13479
|
+
try {
|
|
13480
|
+
const path = importer === 'tekla' ? 'tekla-imports' : 'model-imports';
|
|
13481
|
+
// The import routes, and the server's re-read on send, sit behind the editor session.
|
|
13482
|
+
await bootstrapEditorSession();
|
|
13483
|
+
const r = await api(`/api/${path}/${encodeURIComponent(ref.operationId)}/report-details`);
|
|
13484
|
+
if (riImport !== ref || !r?.details) return; // the dialog was reopened for something else
|
|
13485
|
+
$riImportList.replaceChildren(...riImportRows(r.details).flatMap(([label, value]) => {
|
|
13486
|
+
const dt = document.createElement('dt'); dt.textContent = label;
|
|
13487
|
+
const dd = document.createElement('dd'); dd.textContent = String(value);
|
|
13488
|
+
return [dt, dd];
|
|
13489
|
+
}));
|
|
13490
|
+
$riImport.hidden = false;
|
|
13491
|
+
} catch {
|
|
13492
|
+
// Nothing to show means nothing is attached: the report still sends with what the person wrote.
|
|
13493
|
+
if (riImport === ref) riImport = null;
|
|
13494
|
+
}
|
|
13495
|
+
});
|
|
13496
|
+
|
|
13438
13497
|
window.addEventListener('floless:report-revit-setup-issue', (event) => {
|
|
13439
13498
|
openReportIssue();
|
|
13440
13499
|
const card = event.detail?.returnFocus;
|
|
@@ -13444,7 +13503,7 @@
|
|
|
13444
13503
|
riSyncSend();
|
|
13445
13504
|
});
|
|
13446
13505
|
|
|
13447
|
-
function riRenderSuccess(ref) {
|
|
13506
|
+
function riRenderSuccess(ref, droppedImportReference = null) {
|
|
13448
13507
|
const wrap = document.createElement('div');
|
|
13449
13508
|
wrap.className = 'graft-success';
|
|
13450
13509
|
const icon = document.createElement('div');
|
|
@@ -13457,6 +13516,14 @@
|
|
|
13457
13516
|
? `Received — logged as ${ref} · We'll follow up privately.`
|
|
13458
13517
|
: "Received · We'll follow up privately.";
|
|
13459
13518
|
wrap.append(icon, msg);
|
|
13519
|
+
// #1757: the person chose to include the import details, but FloLess could not attach them (the
|
|
13520
|
+
// import is no longer readable to this session). Say so, and give them the reference to pass on.
|
|
13521
|
+
if (droppedImportReference) {
|
|
13522
|
+
const note = document.createElement('div');
|
|
13523
|
+
note.className = 'modal-sub';
|
|
13524
|
+
note.textContent = `The import details could not be attached. If we ask, the import reference is ${droppedImportReference}.`;
|
|
13525
|
+
wrap.append(note);
|
|
13526
|
+
}
|
|
13460
13527
|
const actions = document.createElement('div');
|
|
13461
13528
|
actions.className = 'modal-actions';
|
|
13462
13529
|
const done = riButton('ri-done', 'Done', true, () => riClose());
|
|
@@ -13506,9 +13573,11 @@
|
|
|
13506
13573
|
awareVersion: riAwareVersion || null,
|
|
13507
13574
|
};
|
|
13508
13575
|
try {
|
|
13509
|
-
|
|
13576
|
+
// Consent is the checked box on a list that is actually showing; the server re-reads the details.
|
|
13577
|
+
const importFailure = riImport && $riImport && !$riImport.hidden && $riImportInclude?.checked ? riImport : undefined;
|
|
13578
|
+
const r = await api('/api/report-issue', { method: 'POST', body: JSON.stringify({ category: riCategory, title, body, context, importFailure }) });
|
|
13510
13579
|
riSubmitting = false; // response in hand — Done / Escape / backdrop may close
|
|
13511
|
-
riRenderSuccess(r.ref || '');
|
|
13580
|
+
riRenderSuccess(r.ref || '', importFailure && r.importDetailsAttached === false ? importFailure.operationId : null);
|
|
13512
13581
|
} catch (e) {
|
|
13513
13582
|
riSubmitting = false;
|
|
13514
13583
|
const err = (e && e.body && e.body.error) || '';
|
package/dist/web/chat.js
CHANGED
|
@@ -2526,11 +2526,14 @@
|
|
|
2526
2526
|
ui.attach.setAttribute('aria-label', `Attach ${kinds} · ${imageCount} of ${MAX_IMAGES_PER_MESSAGE} images`);
|
|
2527
2527
|
}
|
|
2528
2528
|
|
|
2529
|
-
/* #1653: the
|
|
2529
|
+
/* #1653: the model objects selected when a question is sent are attached to it — Steel Model objects, or the
|
|
2530
|
+
objects of a model in the snapshot viewer (Revit, Tekla Parser). The pill shows what
|
|
2530
2531
|
would go with the next NEW question — never with a follow-up to a running response, never on the Drawing
|
|
2531
2532
|
Filter, never in a workflow's conversation — and one click leaves them out until the selection changes. */
|
|
2532
2533
|
const MAX_LISTED_SUBJECTS = 200;
|
|
2533
2534
|
const MAX_SUBJECT_SAMPLE = 50;
|
|
2535
|
+
// What each model calls its objects, one and many; an unknown one still reads as plain English.
|
|
2536
|
+
const SUBJECT_NOUNS = { steel: ['Steel object', 'Steel objects', 'Steel Model object', 'Steel Model objects'], revit: ['Revit element', 'Revit elements', 'Revit element', 'Revit elements'], 'tekla-parser': ['Tekla object', 'Tekla objects', 'Tekla object', 'Tekla objects'] };
|
|
2534
2537
|
|
|
2535
2538
|
function subjectsKey(selection) {
|
|
2536
2539
|
return selection ? `${selection.source}|${selection.key || selection.items.map((item) => `${item.kind}:${item.id}`).sort().join('\n')}` : '';
|
|
@@ -2541,7 +2544,7 @@
|
|
|
2541
2544
|
if (filterSurface().state !== 'off') return null;
|
|
2542
2545
|
let selection = null;
|
|
2543
2546
|
try { selection = window.flolessLeftPane?.readSelection?.() || null; } catch { selection = null; }
|
|
2544
|
-
if (!selection || selection.source
|
|
2547
|
+
if (!selection || !Object.hasOwn(SUBJECT_NOUNS, selection.source) || !selection.items?.length) return null;
|
|
2545
2548
|
if (state.subjectsDismissed && state.subjectsDismissed === subjectsKey(selection)) return null;
|
|
2546
2549
|
return selection;
|
|
2547
2550
|
}
|
|
@@ -2550,10 +2553,12 @@
|
|
|
2550
2553
|
function subjectsPayload(selection) {
|
|
2551
2554
|
if (!selection) return null;
|
|
2552
2555
|
const pick = (item) => ({ kind: item.kind, id: item.id, label: item.label });
|
|
2556
|
+
// A snapshot model's objects travel with the source file they were read from; Steel's carry no such field.
|
|
2557
|
+
const identity = typeof selection.sourceDigest === 'string' ? { sourceDigest: selection.sourceDigest } : {};
|
|
2553
2558
|
if (selection.total > MAX_LISTED_SUBJECTS) {
|
|
2554
|
-
return { source: selection.source, revision: selection.revision, group: { count: selection.total, sample: selection.items.slice(0, MAX_SUBJECT_SAMPLE).map(pick) } };
|
|
2559
|
+
return { source: selection.source, revision: selection.revision, ...identity, group: { count: selection.total, sample: selection.items.slice(0, MAX_SUBJECT_SAMPLE).map(pick) } };
|
|
2555
2560
|
}
|
|
2556
|
-
return { source: selection.source, revision: selection.revision, items: selection.items.slice(0, MAX_LISTED_SUBJECTS).map(pick) };
|
|
2561
|
+
return { source: selection.source, revision: selection.revision, ...identity, items: selection.items.slice(0, MAX_LISTED_SUBJECTS).map(pick) };
|
|
2557
2562
|
}
|
|
2558
2563
|
|
|
2559
2564
|
function subjectLabels(items, total, shown = 3) {
|
|
@@ -2568,13 +2573,15 @@
|
|
|
2568
2573
|
const listed = Array.isArray(subjects.items) ? subjects.items : Array.isArray(subjects.group?.sample) ? subjects.group.sample : [];
|
|
2569
2574
|
const count = Array.isArray(subjects.items) ? subjects.items.length : Number(subjects.group?.count) || listed.length;
|
|
2570
2575
|
if (!count) return '';
|
|
2571
|
-
|
|
2576
|
+
const nouns = Object.hasOwn(SUBJECT_NOUNS, subjects.source) ? SUBJECT_NOUNS[subjects.source] : ['object', 'objects'];
|
|
2577
|
+
return `About ${count} ${count === 1 ? nouns[0] : nouns[1]}${listed.length ? `: ${subjectLabels(listed, count)}` : ''}`;
|
|
2572
2578
|
}
|
|
2573
2579
|
|
|
2574
2580
|
// A question was saved with objects: the model editor's object card reads its links again.
|
|
2575
2581
|
function subjectLinksSaved(subjects) {
|
|
2576
2582
|
if (!subjects) return;
|
|
2577
|
-
|
|
2583
|
+
// The card still refreshes on its next read; the cause is kept for whoever debugs a card that stayed stale.
|
|
2584
|
+
try { window.flolessLeftPane?.chatLinksChanged?.(); } catch (error) { console.warn('[chat] the model card was not told about the new question', error); }
|
|
2578
2585
|
}
|
|
2579
2586
|
|
|
2580
2587
|
function paintSubjectsPill() {
|
|
@@ -2586,7 +2593,8 @@
|
|
|
2586
2593
|
label.dataset.tip = count > MAX_LISTED_SUBJECTS
|
|
2587
2594
|
? `More than ${MAX_LISTED_SUBJECTS} objects are selected, so FloLess attaches them to your next question as one set instead of listing each one.`
|
|
2588
2595
|
: `${subjectLabels(selection.items, count, 5)}. Attached to your next question.`;
|
|
2589
|
-
|
|
2596
|
+
const nouns = SUBJECT_NOUNS[selection.source];
|
|
2597
|
+
label.setAttribute('aria-label', `${count} ${count === 1 ? nouns[2] : nouns[3]} selected, attached to your next question`);
|
|
2590
2598
|
label.addEventListener('click', () => { announce(label.dataset.tip); });
|
|
2591
2599
|
const remove = button('×', 'shell.chat-subjects-remove');
|
|
2592
2600
|
remove.setAttribute('aria-label', 'Leave the selected objects out of your next question');
|
|
@@ -3658,7 +3666,10 @@
|
|
|
3658
3666
|
|
|
3659
3667
|
function autosize() {
|
|
3660
3668
|
ui.input.style.height = 'auto';
|
|
3661
|
-
|
|
3669
|
+
// The box is border-box, so it must hold its border as well as the text, or overflow-y:auto
|
|
3670
|
+
// draws a scrollbar on a single line (#1763).
|
|
3671
|
+
const border = ui.input.offsetHeight - ui.input.clientHeight;
|
|
3672
|
+
ui.input.style.height = `${Math.min(132, ui.input.scrollHeight + border)}px`;
|
|
3662
3673
|
}
|
|
3663
3674
|
|
|
3664
3675
|
function draftFitsStorage(owner, draft) {
|
|
@@ -43,5 +43,11 @@
|
|
|
43
43
|
def('revit.open-model', { label: 'Open Model tab', actsOn: 'Opens the just-imported model on the Model tab', group: 'In the Revit workspace', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
44
44
|
def('revit.replace-import', { label: 'Replace RVT', actsOn: 'Chooses a new RVT while keeping the current model available until replacement succeeds', group: 'In the Revit workspace', persistence: 'working', interaction: 'dialog', risk: [], guidance: 'on-demand' });
|
|
45
45
|
def('revit.retry-import', { label: 'Retry Revit import', actsOn: 'Retries reading the already stored RVT source', group: 'In the Revit workspace', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
46
|
+
def('revit.report-import-failure', { label: 'Report this problem', actsOn: 'Opens Report an issue for this failed import, listing the failure details you can choose to include', group: 'In the Revit workspace', persistence: 'none', interaction: 'dialog', risk: [], guidance: 'on-demand' });
|
|
46
47
|
def('revit.cancel-import', { label: 'Cancel Revit import', actsOn: 'Cancels the in-progress Revit import without removing the current model', group: 'In the Revit workspace', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
48
|
+
// Questions in chat (#1653): the card in the Properties panel, worded as the Steel Model's (web/model-chat-questions.js).
|
|
49
|
+
def('revit.chat-question-show', { label: 'Show in chat', actsOn: 'Opens AI Chat at the question “{instance}”', anyInstance: 'a question asked about this object', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'A question stays linked to the objects selected when it was asked, and to the objects the AI’s answer named.' });
|
|
50
|
+
def('revit.chat-questions-more', { label: 'Show more questions', actsOn: 'Shows the older questions asked in AI Chat about the selection', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
51
|
+
def('revit.chat-questions-orphans', { label: 'Questions about objects not in the model', actsOn: 'Shows AI Chat questions about objects this model does not have now, with the name each was linked under', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'A question is never moved to another object, even one with the same name.' });
|
|
52
|
+
def('revit.chat-questions-retry', { label: 'Retry loading questions', actsOn: 'Reads the questions asked in AI Chat about this project again', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
47
53
|
})();
|
|
@@ -2653,6 +2653,17 @@
|
|
|
2653
2653
|
why: 'Steps to reproduce are what turn a report into a fix.',
|
|
2654
2654
|
});
|
|
2655
2655
|
|
|
2656
|
+
def('shell.issue-include-import', {
|
|
2657
|
+
label: 'Include import details',
|
|
2658
|
+
actsOn: 'Attaches the listed details of the failed import to this report',
|
|
2659
|
+
group: 'In the Report an issue dialog',
|
|
2660
|
+
persistence: 'none',
|
|
2661
|
+
interaction: 'instant',
|
|
2662
|
+
risk: [],
|
|
2663
|
+
guidance: 'on-demand',
|
|
2664
|
+
why: 'Only shown when you report a failed import. It sends exactly the listed references and codes — never your file, its name or its location. Untick it to send the report without them.',
|
|
2665
|
+
});
|
|
2666
|
+
|
|
2656
2667
|
def('shell.issue-send', {
|
|
2657
2668
|
label: 'Send the report',
|
|
2658
2669
|
actsOn: 'Sends it to the FloLess team',
|
|
@@ -44,5 +44,11 @@
|
|
|
44
44
|
def('tekla-parser.audit-finding', { label: 'Show import finding', actsOn: 'Selects and frames {instance} when verified geometry is available', group: 'In the Tekla Parser Audit pane', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
45
45
|
def('tekla-parser.open-model', { label: 'Open Model tab', actsOn: 'Opens the new read-only snapshot on the Model tab', group: 'In the Tekla Parser workspace', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
46
46
|
def('tekla-parser.replace-source', { label: 'Choose or replace Tekla source', actsOn: 'Chooses a Tekla model folder or ZIP; an existing snapshot stays available until replacement succeeds', group: 'In the Tekla Parser workspace', persistence: 'working', interaction: 'dialog', risk: [], guidance: 'on-demand' });
|
|
47
|
+
def('tekla-parser.report-import-failure', { label: 'Report this problem', actsOn: 'Opens Report an issue for this failed read, listing the failure details you can choose to include', group: 'In the Tekla Parser workspace', persistence: 'none', interaction: 'dialog', risk: [], guidance: 'on-demand' });
|
|
47
48
|
def('tekla-parser.cancel-import', { label: 'Cancel Tekla read', actsOn: 'Cancels the in-progress read without removing the current snapshot', group: 'In the Tekla Parser workspace', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
49
|
+
// Questions in chat (#1653): the card in the Properties panel, worded as the Steel Model's (web/model-chat-questions.js).
|
|
50
|
+
def('tekla-parser.chat-question-show', { label: 'Show in chat', actsOn: 'Opens AI Chat at the question “{instance}”', anyInstance: 'a question asked about this object', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'A question stays linked to the objects selected when it was asked, and to the objects the AI’s answer named.' });
|
|
51
|
+
def('tekla-parser.chat-questions-more', { label: 'Show more questions', actsOn: 'Shows the older questions asked in AI Chat about the selection', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
52
|
+
def('tekla-parser.chat-questions-orphans', { label: 'Questions about objects not in the model', actsOn: 'Shows AI Chat questions about objects this snapshot does not have now, with the name each was linked under', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'A question is never moved to another object, even one with the same name.' });
|
|
53
|
+
def('tekla-parser.chat-questions-retry', { label: 'Retry loading questions', actsOn: 'Reads the questions asked in AI Chat about this project again', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
|
|
48
54
|
})();
|
|
@@ -42,6 +42,12 @@ export function readOnlyFilterContext(snapshot, instruction, scope) {
|
|
|
42
42
|
scope,
|
|
43
43
|
('Current sheet: '+(snapshot.sheet || 'not loaded')+'; mode: '+(snapshot.mode || 'not loaded')+'. Checked properties must all match.').slice(0,500),
|
|
44
44
|
];
|
|
45
|
+
// Two facts are ALWAYS appended after the control loop -- the sheet's text sample and the
|
|
46
|
+
// "Controls listed" count -- and those two are the honest ones. Reserve their slots here: filling
|
|
47
|
+
// the budget with controls used to push the message to 201 or 202 facts, over the server's limit,
|
|
48
|
+
// and the whole question was then refused. To the person that reads as the AI failing rather than
|
|
49
|
+
// as a control list that was too long to send.
|
|
50
|
+
const CONTROL_FACT_LIMIT = MAX_FACTS - 2;
|
|
45
51
|
const controls = snapshot.controls || [];
|
|
46
52
|
let represented = 0, part = '';
|
|
47
53
|
for (const row of controls) {
|
|
@@ -50,11 +56,11 @@ export function readOnlyFilterContext(snapshot, instruction, scope) {
|
|
|
50
56
|
if (part && part.length + entry.length + 2 > MAX_FACT_CHARS) {
|
|
51
57
|
facts.push(part); part = '';
|
|
52
58
|
}
|
|
53
|
-
if (facts.length >=
|
|
59
|
+
if (facts.length >= CONTROL_FACT_LIMIT) break;
|
|
54
60
|
part += (part ? '; ' : '') + entry;
|
|
55
61
|
represented++;
|
|
56
62
|
}
|
|
57
|
-
if (part && facts.length <
|
|
63
|
+
if (part && facts.length < CONTROL_FACT_LIMIT) facts.push(part);
|
|
58
64
|
const samples = snapshot.sheetTextSamples || [];
|
|
59
65
|
let sampleCount = 0, sampleFact = 'Text on this sheet: ';
|
|
60
66
|
for (const row of samples) {
|
package/dist/web/index.html
CHANGED
|
@@ -379,6 +379,7 @@
|
|
|
379
379
|
<button type="button" id="ws-revit-open-model" class="primary" data-command-id="revit.open-model" data-tip="Show the imported model on the Model tab. It stays a draft until approved." hidden>Open Model tab</button>
|
|
380
380
|
<button type="button" id="ws-revit-replace" class="btn-mini" data-command-id="revit.replace-import" data-tip="Choose a new RVT. The current model remains available until the replacement is ready.">Replace RVT…</button>
|
|
381
381
|
<button type="button" id="ws-revit-retry" class="btn-mini" data-command-id="revit.retry-import" data-tip="Try importing the already stored RVT again." hidden>Try import again</button>
|
|
382
|
+
<button type="button" id="ws-import-report" class="btn-mini" data-command-id="revit.report-import-failure" data-tip="Send this import’s failure details to the FloLess team. You see exactly what is included before sending." hidden>Report this problem</button>
|
|
382
383
|
<button type="button" id="ws-revit-cancel" class="btn-mini" data-command-id="revit.cancel-import" data-tip="Cancel this import. The existing model remains unchanged." hidden>Cancel import</button>
|
|
383
384
|
</div>
|
|
384
385
|
<div class="ws-source-reassure" id="ws-source-reassure" role="status" aria-live="polite" hidden>The current model remains unchanged until this import finishes.</div>
|
|
@@ -1489,6 +1490,16 @@
|
|
|
1489
1490
|
<label for="ri-desc">Description</label>
|
|
1490
1491
|
<textarea data-command-id="shell.issue-description" id="ri-desc" placeholder="What happened? What did you expect? Steps to reproduce if it's a bug."></textarea>
|
|
1491
1492
|
</div>
|
|
1493
|
+
<!-- #1757: shown only when the dialog was opened from a failed import's "Report this problem".
|
|
1494
|
+
Lists exactly what would be attached; the checkbox is the consent. -->
|
|
1495
|
+
<div class="ri-import" id="ri-import" hidden>
|
|
1496
|
+
<div class="ri-import-head">Import details to include</div>
|
|
1497
|
+
<dl class="ri-import-list" id="ri-import-list"></dl>
|
|
1498
|
+
<label class="ri-import-include">
|
|
1499
|
+
<input type="checkbox" id="ri-import-include" data-command-id="shell.issue-include-import" checked>
|
|
1500
|
+
<span>Include these import details</span>
|
|
1501
|
+
</label>
|
|
1502
|
+
</div>
|
|
1492
1503
|
<div class="integrations-hint" id="ri-context"></div>
|
|
1493
1504
|
<div class="modal-actions">
|
|
1494
1505
|
<button data-command-id="shell.dialog-cancel#the issue report" id="ri-cancel">Cancel</button>
|
package/dist/web/left-pane.js
CHANGED
|
@@ -250,7 +250,10 @@
|
|
|
250
250
|
label: typeof item.label === 'string' ? item.label : item.id })) : [];
|
|
251
251
|
const total = Number.isSafeInteger(subjects.total) && subjects.total >= items.length ? subjects.total : items.length;
|
|
252
252
|
if (!total || !items.length) return null;
|
|
253
|
-
|
|
253
|
+
// A Steel revision is an integer; a snapshot model's is the 64-hex revision id, with the digest of its source file.
|
|
254
|
+
const hex = (value) => typeof value === 'string' && /^[0-9a-f]{64}$/.test(value);
|
|
255
|
+
const revision = Number.isSafeInteger(subjects.revision) || hex(subjects.revision) ? subjects.revision : null;
|
|
256
|
+
return Object.freeze({ source: subjects.source, revision, ...(hex(subjects.sourceDigest) ? { sourceDigest: subjects.sourceDigest } : {}),
|
|
254
257
|
total, key: typeof subjects.key === 'string' && subjects.key.length <= 64 ? subjects.key : null, items: Object.freeze(items) });
|
|
255
258
|
}
|
|
256
259
|
let selectionKey = 'null';
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* model-chat-questions.js - model objects in AI Chat (#1653), shared by every model viewer and the server.
|
|
3
|
+
*
|
|
4
|
+
* A question asked in the left AI Chat with objects selected is linked to them, and the chat model may link the
|
|
5
|
+
* objects its answer names. This module holds what every viewer must say the same way: how an object is named when it
|
|
6
|
+
* goes to chat, the key that tells one selection from another, and the "Questions in chat" card. The Steel Model and
|
|
7
|
+
* the snapshot viewer (Revit, Tekla Parser) all render the card from here, and the server names objects with the same
|
|
8
|
+
* function the viewer uses, so a label never differs between the pill, the card and the chat model's links. Each page
|
|
9
|
+
* styles the card with its own theme tokens; the words and the rows are only here.
|
|
10
|
+
*
|
|
11
|
+
* Pure: no page globals. DOM builders take the document they build in.
|
|
12
|
+
*/
|
|
13
|
+
import { teklaObjectFields, teklaObjectLabel } from './model-property-display.js';
|
|
14
|
+
|
|
15
|
+
/** A label exactly as the server stores it (server/chat-subjects.ts): control characters and runs of space
|
|
16
|
+
* collapsed, cut to 120 characters, trimmed. Sent this way and compared this way, so an unchanged long name never
|
|
17
|
+
* reads as renamed. */
|
|
18
|
+
export function subjectLabelText(text) {
|
|
19
|
+
return [...String(text || '').replace(/[\u0000-\u001f\u007f]+/g, ' ').replace(/\s+/g, ' ').trim()].slice(0, 120).join('').trimEnd();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* An object of a snapshot model as AI Chat names it. Revit: what it is, then its id (`Basic Wall · element:382`) -
|
|
24
|
+
* many elements share a type and some rows carry none, so a name without the id reads as a duplicate. Tekla Parser:
|
|
25
|
+
* the name, profile and Tekla ID the viewer shows, with the entity id added when the read had no Tekla ID.
|
|
26
|
+
* `rows` are the entity's property rows (Tekla reads its name and profile from them).
|
|
27
|
+
*/
|
|
28
|
+
export function modelSubjectLabel(source, entity, rows = []) {
|
|
29
|
+
const id = String(entity?.id ?? '');
|
|
30
|
+
if (source === 'tekla-parser') {
|
|
31
|
+
const fields = teklaObjectFields(entity || {}, rows);
|
|
32
|
+
const label = teklaObjectLabel(entity || {}, rows);
|
|
33
|
+
return fields.id == null ? `${label} · ${id}` : label;
|
|
34
|
+
}
|
|
35
|
+
const what = entity?.name || entity?.typeName || entity?.categoryName || entity?.category || 'Revit element';
|
|
36
|
+
return `${what} · ${id}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 64-bit FNV-1a over the WHOLE canonical list, so a pill left out for one selection returns for another even when
|
|
40
|
+
* only objects past the 200 the pane receives changed. */
|
|
41
|
+
export function subjectsKeyOf(items) {
|
|
42
|
+
let h1 = 0x811c9dc5, h2 = 0x01000193;
|
|
43
|
+
for (const item of items) {
|
|
44
|
+
const text = `${item.kind}:${item.id}\n`;
|
|
45
|
+
for (let i = 0; i < text.length; i++) {
|
|
46
|
+
const c = text.charCodeAt(i);
|
|
47
|
+
h1 = Math.imul(h1 ^ c, 0x01000193) >>> 0; h2 = Math.imul(h2 ^ c, 0x811c9dc5) >>> 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return h1.toString(16).padStart(8, '0') + h2.toString(16).padStart(8, '0');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* -- Questions in chat: the object card ---------------------------------------------------------------------------
|
|
54
|
+
Selecting an object shows how many questions were about it, the first line of each, and Show in chat, which opens
|
|
55
|
+
that conversation at that question. Nothing is re-attached by label: an object the model no longer has keeps its
|
|
56
|
+
questions under "Questions about objects not in the model", with the label it had when asked. A failed read says so
|
|
57
|
+
and offers Retry; it never claims there are no questions. */
|
|
58
|
+
|
|
59
|
+
/** Said when Show in chat cannot reach AI Chat for this project. */
|
|
60
|
+
export const CHAT_NOT_OPEN_COPY = 'AI Chat is not open for this project. Open the project in Workspaces, then choose Show in chat again.';
|
|
61
|
+
|
|
62
|
+
export function chatQuestionDate(iso) {
|
|
63
|
+
const date = new Date(iso);
|
|
64
|
+
return Number.isNaN(date.getTime()) ? '' : date.toLocaleDateString(undefined, { day: 'numeric', month: 'short', year: 'numeric' });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* One row per question: the links of one message collapse into it, naming the objects it was about. A link is the
|
|
69
|
+
* person's selection, the chat model's note on it, or its answer naming the object. What a row says never depends on
|
|
70
|
+
* which link arrived first: every link of a question carries the same question line and time, the newest note wins,
|
|
71
|
+
* and "named in the answer" is a fact of the set. Newest question first.
|
|
72
|
+
*/
|
|
73
|
+
export function chatQuestionRows(links) {
|
|
74
|
+
const byMessage = new Map();
|
|
75
|
+
for (const link of links) {
|
|
76
|
+
let row = byMessage.get(link.messageEventId);
|
|
77
|
+
if (!row) { row = { link, labels: [], seen: new Set(), selected: false, named: false, aiNote: '', aiSeq: -1 }; byMessage.set(link.messageEventId, row); }
|
|
78
|
+
const key = `${link.kind}\0${link.id}`;
|
|
79
|
+
if (!row.seen.has(key)) { row.seen.add(key); row.labels.push(link.label || link.id); }
|
|
80
|
+
if (link.origin === 'ai-answer') row.named = true;
|
|
81
|
+
else if (link.origin === 'ai-note') { if (link.linkSequence > row.aiSeq) { row.aiSeq = link.linkSequence; row.aiNote = link.aiNote || ''; } }
|
|
82
|
+
else { if (!row.selected) row.link = link; row.selected = true; } // "When asked" reads the label from when the person asked
|
|
83
|
+
}
|
|
84
|
+
const askedAt = (row) => String(row.link.askedAt || row.link.createdAt);
|
|
85
|
+
return [...byMessage.values()].sort((a, b) => askedAt(b).localeCompare(askedAt(a)) || (b.link.sequence - a.link.sequence));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The id is all a link knows of its object, and a reader may give a removed object's id to a new one. So a row whose
|
|
89
|
+
* object is named differently now says what it was called when asked, rather than quietly vouching for it.
|
|
90
|
+
* `currentLabel(link)` is the object's label now, '' when unknown. */
|
|
91
|
+
export function chatQuestionWas(row, currentLabel) {
|
|
92
|
+
const link = row.link; if (!link.label) return '';
|
|
93
|
+
const now = subjectLabelText(currentLabel(link));
|
|
94
|
+
return now && now !== subjectLabelText(link.label) ? link.label : '';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function chatQuestionRow(doc, row, opts) {
|
|
98
|
+
const { about, unresolved, commandPrefix, currentLabel, onShow, toast } = opts;
|
|
99
|
+
const link = row.link, li = doc.createElement('div'); li.className = 'chat-q';
|
|
100
|
+
const note = doc.createElement('div'); note.className = 'chat-q-note'; note.textContent = link.note; note.dataset.tip = link.note;
|
|
101
|
+
li.append(note);
|
|
102
|
+
// The chat model's own sentence, said to be its own: untrusted text, one line, textContent only.
|
|
103
|
+
if (row.aiNote) { const ai = doc.createElement('div'); ai.className = 'chat-q-ai'; ai.textContent = `AI note: ${row.aiNote}`; ai.dataset.tip = row.aiNote; li.append(ai); }
|
|
104
|
+
const meta = doc.createElement('div'); meta.className = 'chat-q-meta';
|
|
105
|
+
meta.textContent = [link.chatTitle, chatQuestionDate(link.askedAt || link.createdAt)].filter(Boolean).join(' · ') + (link.archived ? ' · archived' : '');
|
|
106
|
+
li.append(meta);
|
|
107
|
+
if (row.named) { const named = doc.createElement('div'); named.className = 'chat-q-about'; named.textContent = row.selected ? 'Also named in the answer' : 'Named in the answer'; li.append(named); }
|
|
108
|
+
if (about) {
|
|
109
|
+
const who = doc.createElement('div'); who.className = 'chat-q-about';
|
|
110
|
+
const names = row.labels.slice(0, 3);
|
|
111
|
+
who.textContent = (unresolved ? 'Was: ' : 'About ') + names.join(', ') + (row.labels.length > 3 ? ` and ${row.labels.length - 3} more` : '');
|
|
112
|
+
li.append(who);
|
|
113
|
+
} else {
|
|
114
|
+
const was = chatQuestionWas(row, currentLabel);
|
|
115
|
+
if (was) { const who = doc.createElement('div'); who.className = 'chat-q-about'; who.textContent = `When asked: ${was}`; li.append(who); }
|
|
116
|
+
}
|
|
117
|
+
const show = doc.createElement('button'); show.type = 'button'; show.className = 'ghost chat-q-show'; show.textContent = 'Show in chat';
|
|
118
|
+
show.dataset.commandId = `${commandPrefix}.chat-question-show#${link.messageEventId}`; show.dataset.commandInstanceLabel = link.note;
|
|
119
|
+
show.setAttribute('aria-label', `Show in chat: ${link.note}`);
|
|
120
|
+
show.style.gridRow = `1/span ${li.children.length}`; // spans every line this row has, and no empty ones
|
|
121
|
+
show.onclick = () => { if (!onShow(link)) toast(CHAT_NOT_OPEN_COPY); };
|
|
122
|
+
li.append(show); return li;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function chatQuestionList(doc, host, rows, opts) {
|
|
126
|
+
const shown = rows.slice(0, 3), rest = rows.slice(3);
|
|
127
|
+
for (const row of shown) host.append(chatQuestionRow(doc, row, opts));
|
|
128
|
+
if (!rest.length) return;
|
|
129
|
+
const more = doc.createElement('details'); more.className = 'chat-q-more'; more.open = opts.ui.moreOpen === true;
|
|
130
|
+
const sum = doc.createElement('summary'); sum.dataset.commandId = `${opts.commandPrefix}.chat-questions-more`; more.append(sum);
|
|
131
|
+
const say = () => { sum.textContent = more.open ? 'Show fewer' : `Show ${rest.length} more`; }; say();
|
|
132
|
+
more.addEventListener('toggle', () => { opts.ui.moreOpen = more.open; say(); }); // stays open across repaints
|
|
133
|
+
for (const row of rest) more.append(chatQuestionRow(doc, row, opts));
|
|
134
|
+
host.append(more);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The "Questions in chat" card, or null when there is nothing to say.
|
|
139
|
+
* chatLinks {state: 'idle'|'ready'|'failed', links, partial}
|
|
140
|
+
* selected the selected objects as [{kind, id}]; empty when nothing is selected, and then the questions about
|
|
141
|
+
* objects not in the model are offered instead
|
|
142
|
+
* resolves(link) the link's object is in the model shown now
|
|
143
|
+
* currentLabel(link) the object's label now, '' when unknown
|
|
144
|
+
* commandPrefix the page's Instructor namespace ('steel', 'revit', 'tekla-parser')
|
|
145
|
+
* onShow(link) open AI Chat at that question; false when AI Chat cannot be reached
|
|
146
|
+
* onRetry(), toast(text)
|
|
147
|
+
* ui {moreOpen, orphansOpen}, kept by the page so an open list stays open across repaints
|
|
148
|
+
*/
|
|
149
|
+
export function renderChatQuestions({ doc, chatLinks, selected, resolves, currentLabel, commandPrefix, onShow, onRetry, toast, ui }) {
|
|
150
|
+
if (!chatLinks || chatLinks.state === 'idle') return null;
|
|
151
|
+
const box = doc.createElement('section'); box.className = 'chat-questions'; box.setAttribute('aria-label', 'Questions in chat');
|
|
152
|
+
if (chatLinks.state === 'failed') {
|
|
153
|
+
// Said with nothing selected too: that is where questions about removed objects would be listed.
|
|
154
|
+
const line = doc.createElement('div'); line.className = 'hint chat-q-failed'; line.textContent = 'Questions in chat could not be loaded.';
|
|
155
|
+
const retry = doc.createElement('button'); retry.type = 'button'; retry.className = 'ghost'; retry.textContent = 'Retry';
|
|
156
|
+
retry.dataset.commandId = `${commandPrefix}.chat-questions-retry`;
|
|
157
|
+
retry.onclick = () => onRetry(); line.append(' ', retry); box.append(line); return box;
|
|
158
|
+
}
|
|
159
|
+
const opts = { commandPrefix, currentLabel, onShow, toast, ui };
|
|
160
|
+
const atLeast = chatLinks.partial ? 'at least ' : '';
|
|
161
|
+
if (selected.length) {
|
|
162
|
+
const keys = new Set(selected.map((item) => `${item.kind}\0${item.id}`));
|
|
163
|
+
const rows = chatQuestionRows(chatLinks.links.filter((link) => keys.has(`${link.kind}\0${link.id}`) && resolves(link)));
|
|
164
|
+
if (!rows.length) return null;
|
|
165
|
+
const title = doc.createElement('div'); title.className = 'sect chat-q-title'; title.textContent = `Questions in chat (${atLeast}${rows.length})`;
|
|
166
|
+
box.append(title); chatQuestionList(doc, box, rows, { ...opts, about: selected.length > 1, unresolved: false });
|
|
167
|
+
return box;
|
|
168
|
+
}
|
|
169
|
+
const orphans = chatQuestionRows(chatLinks.links.filter((link) => !resolves(link)));
|
|
170
|
+
if (!orphans.length) return null;
|
|
171
|
+
const det = doc.createElement('details'); det.className = 'chat-q-orphans'; det.open = ui.orphansOpen === true;
|
|
172
|
+
det.addEventListener('toggle', () => { ui.orphansOpen = det.open; });
|
|
173
|
+
const sum = doc.createElement('summary'); sum.dataset.commandId = `${commandPrefix}.chat-questions-orphans`;
|
|
174
|
+
// Removed, never there, or read from another source file: an answer can name an id the model lacks.
|
|
175
|
+
sum.textContent = `Questions about objects not in the model (${atLeast}${orphans.length})`; det.append(sum);
|
|
176
|
+
chatQuestionList(doc, det, orphans, { ...opts, about: true, unresolved: true });
|
|
177
|
+
box.append(det); return box;
|
|
178
|
+
}
|