@floless/app 0.141.1 → 0.143.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.
@@ -5,7 +5,7 @@
5
5
  var def = window.Commands.define;
6
6
  def('revit.projection', { label: 'Camera projection', actsOn: 'Opens perspective and orthographic camera choices', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
7
7
  def('revit.projection-mode', { label: 'Set camera projection', actsOn: 'Draws the Revit model in {instance}', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
8
- def('revit.fit', { label: 'Fit all to view', actsOn: 'Frames the whole Revit model', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
8
+ def('revit.fit', { label: 'Fit all to view', key: 'Also: Home', actsOn: 'Frames the whole Revit model', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
9
9
  def('revit.fit-selection', { label: 'Zoom to selected', actsOn: 'Frames the selected Revit object', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
10
10
  def('revit.display-mode', { label: 'Display mode', actsOn: 'Opens solid, wireframe, X-ray and realistic choices', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
11
11
  def('revit.display-mode-set', { label: 'Set display mode', actsOn: 'Draws the Revit model as {instance}', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
@@ -1479,13 +1479,22 @@
1479
1479
  group: 'In AI Chat', key: 'Enter sends · Shift + Enter starts a new line', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand',
1480
1480
  });
1481
1481
  def('shell.chat-attach', {
1482
- label: 'Attach file', actsOn: 'Adds images (up to five per message) or PDFs from this computer to the next message or follow-up',
1482
+ label: 'Attach file', actsOn: 'Adds images (up to five per message) or PDFs from this computer to the next message or follow-up; on the Drawing Filter only pictures can be sent and a PDF is turned away as soon as it is chosen, because the AI answering there cannot open one',
1483
1483
  group: 'In AI Chat', persistence: 'working', interaction: 'dialog', risk: [], guidance: 'on-demand',
1484
1484
  });
1485
1485
  def('shell.chat-attach-input', {
1486
- label: 'Choose attachments', actsOn: 'Selects images (up to five per message) or PDFs to add to the next message or follow-up',
1486
+ label: 'Choose attachments', actsOn: 'Selects images (up to five per message) or PDFs to add to the next message or follow-up; on the Drawing Filter a PDF is turned away as soon as it is chosen, because the AI answering there cannot open one',
1487
1487
  group: 'In AI Chat', persistence: 'working', interaction: 'dialog', risk: [], guidance: 'on-demand',
1488
1488
  });
1489
+ def('shell.chat-subjects', {
1490
+ label: 'Selected objects for the next question', actsOn: 'Says which selected Steel Model objects will be attached to your next question',
1491
+ group: 'In AI Chat', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
1492
+ why: 'A question sent with objects selected is linked to them, so selecting one later shows the question and opens it in chat.',
1493
+ });
1494
+ def('shell.chat-subjects-remove', {
1495
+ label: 'Leave selected objects out', actsOn: 'Sends your next question without the selected Steel Model objects, until the selection changes',
1496
+ group: 'In AI Chat', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
1497
+ });
1489
1498
  def('shell.chat-attachment-remove', {
1490
1499
  label: 'Remove pending attachment', actsOn: 'Leaves {instance} out of the next message',
1491
1500
  group: 'In AI Chat', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
@@ -1542,9 +1551,18 @@
1542
1551
  group: 'In AI Chat', persistence: 'external', interaction: 'instant', risk: ['destructive'], guidance: 'on-demand',
1543
1552
  });
1544
1553
  def('shell.chat-approval-request', {
1545
- label: 'Approve for this request', actsOn: 'Allows this access action and future access actions until the current response finishes; keeps your permission setting and review checkpoints unchanged, and Tekla model reads still ask every time',
1554
+ label: 'Approve for this request', actsOn: 'Allows this access action and future access actions until the current response finishes; keeps your permission setting and review checkpoints unchanged; Tekla reads ask unless you allow them for this chat',
1546
1555
  group: 'In AI Chat', persistence: 'external', interaction: 'instant', risk: ['destructive'], guidance: 'on-demand',
1547
- why: 'Saves approving each access action one by one during this response. A Tekla model read still asks you every time.',
1556
+ why: 'Saves approving each access action one by one during this response. A Tekla read is not covered: it has its own Allow for this chat.',
1557
+ });
1558
+ def('shell.chat-tekla-allow-chat', {
1559
+ label: 'Allow Tekla reads for this chat', actsOn: 'Allows this Tekla read and every later read this chat may ask for, of the open model name or the parts you have selected, without asking again in this conversation until you revoke it',
1560
+ group: 'In AI Chat', persistence: 'external', interaction: 'instant', risk: [], guidance: 'on-demand',
1561
+ why: 'Saves approving each Tekla read one by one. FloLess still checks Tekla live before every read and shows every result; nothing in the model changes.',
1562
+ });
1563
+ def('shell.chat-tekla-allowance-revoke', {
1564
+ label: 'Revoke Tekla reads for this chat', actsOn: 'Makes Chat ask you again before each Tekla read in this conversation; a read already running may finish',
1565
+ group: 'In AI Chat', persistence: 'external', interaction: 'instant', risk: [], guidance: 'on-demand',
1548
1566
  });
1549
1567
  def('shell.chat-approval-revoke', {
1550
1568
  label: 'Revoke request auto-approval', actsOn: 'Asks before future access actions in this request; actions already approved may finish',
@@ -2228,6 +2228,10 @@
2228
2228
  def('steel.registration-detail', { label: 'Registration details', actsOn: 'Shows the exact reason this sheet’s registration was refused, naming the contract fields to change', group: 'On the steel canvas', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'The plain-English warning is for you; this is the sentence your terminal AI needs.' });
2229
2229
  def('steel.registration-copy', { label: 'Copy reason', actsOn: 'Copies the exact registration refusal to the clipboard', group: 'On the steel canvas', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'This sheet cannot be corrected in the editor — paste the reason to your terminal AI and ask it to fix the registration.' });
2230
2230
  def('steel.review-select', { label: 'Select this connection', actsOn: 'Selects {instance} from the review list', group: 'In the review list', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'A watched connection selects the members it watches; an unwatched one opens the 3D view and selects the connection itself.' });
2231
+ def('steel.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.' });
2232
+ def('steel.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' });
2233
+ def('steel.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.' });
2234
+ def('steel.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' });
2231
2235
  def('steel.connection-part-back', { label: 'Back to connection', actsOn: 'Selects the whole connection that owns this part', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
2232
2236
  def('steel.connection-part-edit', { label: 'Edit on parent member', actsOn: 'Selects the member that owns this connection part', group: 'In the Properties panel', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
2233
2237
  def('steel.quick-dimension-place', { label: 'Place spacing dimensions', actsOn: 'Arms a running dimension row for the current selection', group: 'In the Properties panel', persistence: 'working', interaction: 'mode', risk: [], guidance: 'active-command', steps: ['Click where the spacing dimension row should sit'], why: 'The dimensions stay attached to the selected members or grid lines.' });
@@ -17,6 +17,26 @@ export function rankFilterControls(controls, instruction, focusedControl) {
17
17
  return [...controls].sort((a, b) => score(b) - score(a));
18
18
  }
19
19
 
20
+ /**
21
+ * How much of the view the answering AI is told about.
22
+ *
23
+ * These were 10 facts and a 500-character text budget — a few dozen short strings out of a sheet
24
+ * with thousands of elements — and the answer then carried a line telling the model not to claim a
25
+ * complete audit, which was true and unhelpful in equal measure. The numbers were never measured
26
+ * against a model's capacity; they were a cautious guess made when this path had no other evidence
27
+ * and could not afford to be wrong.
28
+ *
29
+ * It has other evidence now: the sheet itself is attached as a picture, so these facts are the
30
+ * CONTROLS and the drawing carries the rest. That makes a wider fact list cheap and a narrow one
31
+ * pointlessly lossy, so the budgets are raised to where a real sheet fits.
32
+ */
33
+ const MAX_FACTS = 200;
34
+ const MAX_FACT_CHARS = 1_000;
35
+ // Under the server's MAX_FACT_CHARS (20,000), not equal to it: a fact of exactly the limit passes
36
+ // by one character, and the next word added to the prefix would tip every message into a refusal
37
+ // nobody can see. Margin on purpose.
38
+ const MAX_SAMPLE_CHARS = 18_000;
39
+
20
40
  export function readOnlyFilterContext(snapshot, instruction, scope) {
21
41
  const facts = [
22
42
  scope,
@@ -27,24 +47,33 @@ export function readOnlyFilterContext(snapshot, instruction, scope) {
27
47
  for (const row of controls) {
28
48
  const entry = row.dimension+':'+JSON.stringify(row.label)+' '+(row.checked?'on':'off')+' ('+row.count+')'
29
49
  +(row.notRead ? ' not read by FloLess and cannot be changed here' : '');
30
- if (part && part.length + entry.length + 2 > 500) {
50
+ if (part && part.length + entry.length + 2 > MAX_FACT_CHARS) {
31
51
  facts.push(part); part = '';
32
52
  }
33
- if (facts.length >= 10) break;
53
+ if (facts.length >= MAX_FACTS) break;
34
54
  part += (part ? '; ' : '') + entry;
35
55
  represented++;
36
56
  }
37
- if (part && facts.length < 10) facts.push(part);
57
+ if (part && facts.length < MAX_FACTS) facts.push(part);
38
58
  const samples = snapshot.sheetTextSamples || [];
39
- let sampleCount = 0, sampleFact = 'Text examples, not a complete read: ';
59
+ let sampleCount = 0, sampleFact = 'Text on this sheet: ';
40
60
  for (const row of samples) {
41
61
  const entry = JSON.stringify(row.text)+' on '+JSON.stringify(row.layer)+' '+(row.selected?'selected':'excluded');
42
- if (sampleFact.length + entry.length + 2 > 500) break;
62
+ if (sampleFact.length + entry.length + 2 > MAX_SAMPLE_CHARS) break;
43
63
  sampleFact += (sampleCount ? '; ' : '') + entry;
44
64
  sampleCount++;
45
65
  }
46
66
  if (sampleCount) facts.push(sampleFact);
47
- facts.push('Partial drawing view: '+represented+' of '+(snapshot.controlTotal ?? controls.length)+' controls and '+sampleCount+' of '+(snapshot.textTotal ?? samples.length)+' text items are listed. More drawing content may exist. Do not claim a complete audit.');
67
+ const allControls = represented >= (snapshot.controlTotal ?? controls.length);
68
+ const allText = sampleCount >= (snapshot.textTotal ?? samples.length);
69
+ // Still honest about what is listed, but no longer an instruction to hedge: when the sheet itself
70
+ // is attached, the drawing is the evidence and these facts are the controls beside it. Telling the
71
+ // model to distrust a complete list is how a question with a real answer got a cautious non-answer.
72
+ facts.push('Controls listed: '+represented+' of '+(snapshot.controlTotal ?? controls.length)
73
+ +'. Text items listed: '+sampleCount+' of '+(snapshot.textTotal ?? samples.length)+'.'
74
+ + (allControls && allText
75
+ ? ' That is everything this view holds.'
76
+ : ' Some of this view is not listed here; if the answer depends on what is missing, say so and say what to open.'));
48
77
  return { subject:instruction, commandId:'filter.ask-ai-question', surface:'steel-filter', tone:'idle', facts };
49
78
  }
50
79
 
@@ -17,15 +17,51 @@ export function filterAiTouchesUnreadLayer(proposal, filter) {
17
17
  && blocked.has(facetKey('layer', item.value)));
18
18
  }
19
19
 
20
+ /**
21
+ * How long an answer may be.
22
+ *
23
+ * This was 500 characters, and it REJECTED rather than truncated — an answer one character over was
24
+ * thrown away whole and the person saw a failure. 500 is about four sentences, which is fine for
25
+ * “turn that layer off” and useless for the questions this surface is actually asked. Measured
26
+ * 2026-09-28: asked to list the elevation callouts on one sheet, the model returned a correct and
27
+ * well-organised answer of roughly 1,200 characters, which the old cap would have discarded.
28
+ *
29
+ * The outer 8,000-character bound on the whole JSON document is the real backstop and is unchanged;
30
+ * this one now sits under it with room for a real answer rather than in front of it.
31
+ */
32
+ export const MAX_FILTER_EXPLANATION = 6_000;
33
+
20
34
  /** Reject malformed or contradictory suggestions before any surface presents them. */
21
35
  export function parseFilterAiProposalShape(answer) {
22
- if (typeof answer !== 'string' || answer.length > 8_000) throw new Error('AI returned a suggestion that is too large. Ask about fewer layers.');
36
+ if (typeof answer !== 'string' || answer.length > 32_000) throw new Error('AI returned a suggestion that is too large. Ask about fewer layers.');
23
37
  let value;
24
- try { value = JSON.parse(answer); }
25
- catch { throw new Error('AI did not return a usable selection. Ask it to try again.'); }
38
+ // A model that wraps the envelope in a ```json fence produced the envelope; the fence is packaging,
39
+ // not a different answer, so unwrap it before deciding anything.
40
+ const unfenced = /^```(?:json)?\s*\n([\s\S]*?)\n?```$/i.exec(answer.trim())?.[1] ?? answer;
41
+ try { value = JSON.parse(unfenced); }
42
+ catch {
43
+ // PROSE IS AN ANSWER. The envelope exists so a SELECTION CHANGE can be audited rather than
44
+ // parsed out of a sentence — it was never meant to be the price of admission for an answer that
45
+ // proposes no change. A correct, complete reply that happened to arrive as plain text was being
46
+ // thrown away and shown as "AI's answer could not be shown", which is the worst of both: the
47
+ // work was done, the person paid for it, and they got nothing. Seen in a real browser with an
48
+ // answer that named nine elevations correctly.
49
+ //
50
+ // Accepted as an explanation with NO changes, which is exactly what it is: nothing here can
51
+ // propose a tick, so nothing can be applied by accident.
52
+ // But a FAILED ENVELOPE is not prose. Text opening with `{` or `[` was trying to be the envelope
53
+ // and did not finish — truncated, or malformed. Its debris may be a half-written list of CHANGES,
54
+ // and showing that as an answer would present machine wreckage as a reply and hide the fact that
55
+ // a change was proposed and lost. Only text that never attempted the envelope is prose.
56
+ const text = unfenced.trim();
57
+ if (!text || text.startsWith('{') || text.startsWith('[')) {
58
+ throw new Error('AI did not return a usable selection. Ask it to try again.');
59
+ }
60
+ return { explanation: text.slice(0, MAX_FILTER_EXPLANATION), changes: [], mode: null };
61
+ }
26
62
  if (!value || Array.isArray(value) || typeof value !== 'object'
27
63
  || Object.keys(value).sort().join(',') !== 'changes,explanation,mode'
28
- || typeof value.explanation !== 'string' || !value.explanation.trim() || value.explanation.length > 500
64
+ || typeof value.explanation !== 'string' || !value.explanation.trim() || value.explanation.length > MAX_FILTER_EXPLANATION
29
65
  || !Array.isArray(value.changes) || value.changes.length > 30
30
66
  || (value.mode !== null && (typeof value.mode !== 'string'
31
67
  || !value.mode || value.mode !== canonicalMode(value.mode.split('+'))))) {
@@ -426,7 +426,6 @@
426
426
  binding must never eat a literal "?" the user meant to type. */
427
427
 
428
428
  var lastHovered = null;
429
- var lastHoveredAt = 0;
430
429
  var lastHoveredOrder = 0;
431
430
  var lastFocused = null;
432
431
  var lastFocusedOrder = 0;
@@ -445,10 +444,13 @@
445
444
 
446
445
  function recordHoverIntent(e) {
447
446
  lastHovered = e && e.target;
448
- lastHoveredAt = Date.now();
449
447
  lastHoveredOrder = ++intentOrder;
450
448
  }
451
449
 
450
+ function clearHoverIntent() {
451
+ lastHovered = null;
452
+ }
453
+
452
454
  function recordFocusIntent(e) {
453
455
  lastFocused = e && e.target;
454
456
  lastFocusedOrder = ++intentOrder;
@@ -462,6 +464,7 @@
462
464
  if (!doc || typeof doc.addEventListener !== 'function' || remembersIntentDocument(doc)) return;
463
465
  rememberIntentDocument(doc);
464
466
  doc.addEventListener('mouseover', recordHoverIntent, true);
467
+ doc.addEventListener('mouseleave', clearHoverIntent, true);
465
468
  doc.addEventListener('focusin', recordFocusIntent, true);
466
469
  }
467
470
 
@@ -488,9 +491,9 @@
488
491
  • Hover-first would explain whatever the mouse was last parked over,
489
492
  which is meaningless for someone tabbing through with the keyboard.
490
493
 
491
- The rule: a RECENT pointer movement means the user is pointing at what they
492
- mean; otherwise they are navigating by keyboard and focus wins. */
493
- var HOVER_INTENT_MS = 3000;
494
+ The last intent wins. A pointer that remains over a control does not become
495
+ irrelevant after an arbitrary timeout; leaving the document or moving focus
496
+ by keyboard retires that pointer intent. */
494
497
 
495
498
  /* A model editor's panel tabs are its own controls, moved into the main window's #left-model-panel frame
496
499
  (web/model-panel-bridge.js): a third document, searched after the editor's own. */
@@ -530,18 +533,18 @@
530
533
  var hasActive = active && active !== document.body;
531
534
  /* A control can disappear while the pointer remains parked at its old coordinates. The revision
532
535
  result does exactly that: Apply is hidden, then focus moves to Close. Treating the hidden Apply
533
- as fresh pointer intent makes `?` narrate an action that is no longer on screen. The same goes for
536
+ as pointer intent makes `?` narrate an action that is no longer on screen. The same goes for
534
537
  one a full-window overlay has since covered (#1445): it keeps its layout but is inert. */
535
538
  var hoveredIsRendered = lastHovered && lastHovered.isConnected && isOnScreen(lastHovered);
536
- var pointerIsFresh = hoveredIsRendered && (Date.now() - lastHoveredAt) < HOVER_INTENT_MS;
539
+ var pointerIntent = hoveredIsRendered;
537
540
  var focusedOrder = lastFocused === active ? lastFocusedOrder : 0;
538
541
 
539
- var el = hasActive ? active : (pointerIsFresh ? lastHovered : null);
542
+ var el = hasActive ? active : (pointerIntent ? lastHovered : null);
540
543
  /* Most recent intentional target wins. This keeps pointer-over-another-control
541
- useful, but a later Tab/Shift+Tab transition must beat the still-fresh hover
544
+ useful, but a later Tab/Shift+Tab transition must beat the earlier hover
542
545
  left by a prior click. Programmatic focus in the browser emits focusin too,
543
546
  so replacements that restore focus participate in the same ordering. */
544
- if (pointerIsFresh && lastHovered !== active && focusFor(lastHovered)
547
+ if (pointerIntent && lastHovered !== active && focusFor(lastHovered)
545
548
  && (!hasActive || !focusedOrder || lastHoveredOrder > focusedOrder)) {
546
549
  el = lastHovered;
547
550
  }
@@ -1451,7 +1454,6 @@
1451
1454
  // control elsewhere remains the user's valid pointer intent after a keyboard close.
1452
1455
  if (lastHovered && lastHovered.closest && lastHovered.closest('#command-sheet')) {
1453
1456
  lastHovered = null;
1454
- lastHoveredAt = 0;
1455
1457
  }
1456
1458
  setBackgroundInert(false);
1457
1459
  if (coveredDialogAriaBefore) {
@@ -215,7 +215,31 @@
215
215
  stack.append(sections[first], split, sections[second], empty);
216
216
  }
217
217
 
218
+ // The model objects selected in the live editor, as AI Chat may attach them to a question (#1653): a frozen copy,
219
+ // or null whenever no editor is live here or nothing it can name is selected. The editor's own shape is checked,
220
+ // not trusted: the server validates again, but a pill must never count what it cannot send.
221
+ function readSelection() {
222
+ const subjects = state.modelAvailable && modelVisible() ? state.snapshot?.subjects : null;
223
+ if (!subjects || typeof subjects !== 'object' || typeof subjects.source !== 'string') return null;
224
+ const items = Array.isArray(subjects.items) ? subjects.items.filter((item) => item && typeof item.kind === 'string'
225
+ && typeof item.id === 'string' && item.id).map((item) => Object.freeze({ kind: item.kind, id: item.id,
226
+ label: typeof item.label === 'string' ? item.label : item.id })) : [];
227
+ const total = Number.isSafeInteger(subjects.total) && subjects.total >= items.length ? subjects.total : items.length;
228
+ if (!total || !items.length) return null;
229
+ return Object.freeze({ source: subjects.source, revision: Number.isSafeInteger(subjects.revision) ? subjects.revision : null,
230
+ total, key: typeof subjects.key === 'string' && subjects.key.length <= 64 ? subjects.key : null, items: Object.freeze(items) });
231
+ }
232
+ let selectionKey = 'null';
233
+ // Chat repaints its pill when this changes. Called from reflect(), which every path that forgets a model reaches.
234
+ function announceSelection() {
235
+ const next = readSelection();
236
+ const key = JSON.stringify(next);
237
+ if (key === selectionKey) return;
238
+ selectionKey = key;
239
+ window.dispatchEvent(new window.CustomEvent('floless:model-selection'));
240
+ }
218
241
  function reflect() {
242
+ announceSelection();
219
243
  const both = presented('narrative') && presented('model');
220
244
  const first = state.order[0];
221
245
  const splitLocked = approvalSplitLocked(first);
@@ -691,7 +715,9 @@
691
715
  state.snapshot.selectedId = typeof data.selectedId === 'string' ? data.selectedId : null;
692
716
  state.snapshot.selectedIds = Array.isArray(data.selectedIds) ? data.selectedIds.filter((id) => typeof id === 'string') : (state.snapshot.selectedId ? [state.snapshot.selectedId] : []);
693
717
  state.snapshot.selectionOrigin = data.selectionOrigin || 'tree';
718
+ state.snapshot.subjects = data.subjects && typeof data.subjects === 'object' ? data.subjects : null;
694
719
  }
720
+ announceSelection();
695
721
  pendingSelectIds = null;
696
722
  const picked = selectedIdsOf(data);
697
723
  modelContent.querySelectorAll('[data-entity-id]').forEach((row) => {
@@ -701,6 +727,20 @@
701
727
  if (state.followSelection && state.snapshot?.selectedIds?.length === 1) { renderModel(); revealSelectedEntity(); }
702
728
  return;
703
729
  }
730
+ // An object card's Show in chat: the editor names a conversation and one message in it (#1653).
731
+ if (data.type === 'open-chat') {
732
+ state.revision = data.revision;
733
+ const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
734
+ if (!uuid.test(String(data.chatId)) || !uuid.test(String(data.messageEventId))
735
+ || typeof data.projectId !== 'string' || !data.projectId || data.projectId.length > 200) return;
736
+ // Said where a sighted person looks, not only to a screen reader: the click happened in the model panel.
737
+ const refuse = (message) => { status.textContent = message; window.showToast?.(message, 'info'); };
738
+ const open = window.flolessChat?.openConversation;
739
+ if (typeof open !== 'function') { refuse('AI Chat is not ready yet. Try Show in chat again in a moment.'); return; }
740
+ Promise.resolve().then(() => open(data.chatId, { messageEventId: data.messageEventId, projectId: data.projectId }))
741
+ .catch((error) => refuse(error?.message || 'That conversation could not be opened. Try Show in chat again.'));
742
+ return;
743
+ }
704
744
  if (data.type !== 'snapshot') return;
705
745
  state.revision = data.revision; state.snapshot = data.snapshot; state.modelAvailable = true;
706
746
  if (state.datasetKey !== data.snapshot.datasetKey) state.datasetKey = data.snapshot.datasetKey || null;
@@ -725,6 +765,9 @@
725
765
  frame.addEventListener('load', onModelFrameLoad);
726
766
 
727
767
  window.flolessLeftPane = Object.freeze({
768
+ readSelection,
769
+ // AI Chat stored a question about model objects: the live editor reads its links again.
770
+ chatLinksChanged() { if (state.modelAvailable) send({ type: 'chat-links-changed' }); },
728
771
  showSection(key) {
729
772
  if (!available(key)) return false;
730
773
  const changed = !shown(key); sessionVisible[key] = true; reflect(); return changed;
@@ -50,7 +50,6 @@ export function createModelClipSession({
50
50
  let sequence = 0;
51
51
  let disposed = false;
52
52
  let mutationDepth = 0;
53
- let pendingReason = null;
54
53
 
55
54
  const clips = () => tools.state().clips ?? [];
56
55
  const orderedIds = () => clips().map((clip) => clip.id);
@@ -76,7 +75,7 @@ export function createModelClipSession({
76
75
  return value;
77
76
  };
78
77
  const publish = (reason) => {
79
- if (mutationDepth) { pendingReason = reason; return current(); }
78
+ if (mutationDepth) return current();
80
79
  return emit(reason);
81
80
  };
82
81
  const beginEdit = (reason) => {
@@ -87,7 +86,7 @@ export function createModelClipSession({
87
86
  try { beginEdit(reason); return operation(); }
88
87
  finally {
89
88
  mutationDepth -= 1;
90
- if (!mutationDepth) { pendingReason = null; emit(reason); }
89
+ if (!mutationDepth) emit(reason);
91
90
  }
92
91
  };
93
92
  const nextIdentity = (kind) => {
@@ -12,6 +12,16 @@ Object.freeze(MODEL_NAMED_VIEWS);
12
12
 
13
13
  export const MODEL_VIEW_KEYS = Object.freeze({ t: 'top', f: 'front', r: 'right', b: 'back', l: 'left' });
14
14
 
15
+ /** Keep an entire model sphere inside the camera frustum as navigation changes its distance. */
16
+ export function modelCameraClipRange(distance, radius, orthographic = false) {
17
+ if (!Number.isFinite(distance) || distance < 0 || !Number.isFinite(radius) || radius < 0) throw new RangeError('Camera clipping needs a finite distance and radius.');
18
+ // Orthographic zoom changes magnification without moving the camera. Its near plane must
19
+ // reach behind a camera that sits inside the model after framing a close detail.
20
+ const near = orthographic ? distance - radius * 1.05 : Math.max(0.1, (distance - radius) * 0.5);
21
+ const far = Math.max(near + 1, (distance + radius) * 1.05);
22
+ return { near, far };
23
+ }
24
+
15
25
  /** Apply FloLess CAD mouse conventions to an OrbitControls-compatible controller. */
16
26
  export function applyCadOrbitPolicy(controls, mouse = THREE.MOUSE) {
17
27
  if (!controls) throw new Error('CAD navigation needs OrbitControls.');
@@ -85,9 +95,12 @@ function cadRepivotAction({ controls, getCamera, pickPoint, cursor }) {
85
95
  }
86
96
 
87
97
  /** Shared keyboard pan/rotate/named-view behavior. Escape remains owned by the active tool plugin. */
88
- export function handleCadNavigationKey({ getCamera, getControls, applyView, fitSelection, canFitSelection = () => true, canApplyView = () => true }, event) {
98
+ export function handleCadNavigationKey({ getCamera, getControls, applyView, fitAll, fitSelection, canFitSelection = () => true, canApplyView = () => true }, event) {
89
99
  const arrows = Object.freeze({ ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] });
90
100
  if (event.defaultPrevented) return false;
101
+ if (event.key === 'Home' && !event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey && fitAll) {
102
+ event.preventDefault(); fitAll(); return true;
103
+ }
91
104
  if (((event.key === ' ' && event.shiftKey) || ((event.key === 'z' || event.key === 'Z') && event.altKey)) && canFitSelection(event)) {
92
105
  event.preventDefault(); fitSelection?.(); return true;
93
106
  }
@@ -122,7 +135,7 @@ export function handleCadNavigationKey({ getCamera, getControls, applyView, fitS
122
135
  * parallel listener set or copying camera behavior.
123
136
  */
124
137
  export function mountCadInputArbiter({
125
- surface, controls, mouse = THREE.MOUSE, win = window, getCamera, pickPoint, applyView, fitSelection,
138
+ surface, controls, mouse = THREE.MOUSE, win = window, getCamera, pickPoint, applyView, fitAll, fitSelection,
126
139
  isActive = () => true, canFitSelection, canApplyView, orbitInput = null, orbitThreshold = 5, plugin = {},
127
140
  }) {
128
141
  if (!surface || !controls || !win) throw new Error('CAD input arbiter needs a surface, controls, and window.');
@@ -212,13 +225,14 @@ export function mountCadInputArbiter({
212
225
  if (!isActive()) return;
213
226
  if (event.defaultPrevented || event.cancelBubble === true) return;
214
227
  const active = win.document?.activeElement; if (active && /^(INPUT|SELECT|TEXTAREA)$/.test(active.tagName)) return;
228
+ const menuOwnsHome = event.key === 'Home' && !!active?.closest?.('.m3dmenu,[role="menu"]');
215
229
  dispatch('keyDown', event);
216
230
  if (event.key === 'Escape' && orbitGesture) {
217
231
  if (!orbitGesture.pending) orbitInput?.cancel(orbitGesture.down);
218
232
  orbitGesture = null;
219
233
  }
220
234
  if (orbitInput && !event.defaultPrevented) orbitInput.document(event);
221
- if (!event.defaultPrevented) handleCadNavigationKey({ getCamera, getControls: () => controls, applyView, fitSelection, canFitSelection, canApplyView }, event);
235
+ if (!event.defaultPrevented && !menuOwnsHome) handleCadNavigationKey({ getCamera, getControls: () => controls, applyView, fitAll, fitSelection, canFitSelection, canApplyView }, event);
222
236
  });
223
237
  listen(win, 'keyup', (event) => { dispatch('keyUp', event); if (orbitInput && !event.defaultPrevented) orbitInput.document(event); });
224
238
  controls.addEventListener('start', repivot); removers.push(() => controls.removeEventListener('start', repivot));
@@ -61,7 +61,6 @@ export function modelCubeDirection(point) {
61
61
  }
62
62
 
63
63
  export function nextModelCubeKeyboardView(current, key) {
64
- if (key === 'Home') return 'iso';
65
64
  return KEY_ADJACENCY[current]?.[key] ?? current;
66
65
  }
67
66
 
@@ -102,7 +101,7 @@ function disposeScene(scene) {
102
101
  function renderAccessibleName(canvas, status, highlighted) {
103
102
  const face = FACE_LABELS[highlighted];
104
103
  const label = highlighted === 'iso' ? 'Isometric' : `${face[0]}${face.slice(1).toLowerCase()}`;
105
- canvas.setAttribute('aria-label', `ViewCube. ${label} view selected. Arrow keys choose a face, Home chooses isometric, Enter applies.`);
104
+ canvas.setAttribute('aria-label', `ViewCube. ${label} view selected. Arrow keys choose a face, Enter applies. Home fits the whole model.`);
106
105
  status.textContent = `${label} view selected`;
107
106
  }
108
107
 
@@ -129,7 +128,7 @@ export function mountModelOrientationOverlay({
129
128
  cleanup(() => { cubeRenderer.dispose(); cubeRenderer.forceContextLoss?.(); });
130
129
  cubeRenderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2)); cubeRenderer.setSize(MODEL_VIEW_CUBE_PX, MODEL_VIEW_CUBE_PX);
131
130
  const cubeCanvas = cubeRenderer.domElement; cubeCanvas.tabIndex = 0; cubeCanvas.setAttribute('role', 'button');
132
- cubeCanvas.dataset.tip = 'ViewCube: arrows choose a face, Home chooses ISO, Enter applies, Escape returns to the model';
131
+ cubeCanvas.dataset.tip = 'ViewCube: arrows choose a face, Enter applies, Home fits the whole model, Escape returns to the model';
133
132
  cubeHost.appendChild(cubeCanvas); cleanup(() => cubeCanvas.remove());
134
133
 
135
134
  const status = document.createElement('span'); status.className = 'model-view-cube-status'; status.setAttribute('aria-live', 'polite'); status.setAttribute('aria-atomic', 'true');
@@ -151,7 +151,7 @@ export function createPanelHost({ win = window, root, bodies, install = (_doc) =
151
151
 
152
152
  export function createModelPanelBridge({ win = window, origin = location.origin, snapshot, selectedId, selectedIds = () => {
153
153
  const id = selectedId(); return typeof id === 'string' ? [id] : [];
154
- }, select, expand, panel = (_tab, _person, _follow) => false }) {
154
+ }, selectedSubjects = () => null, select, expand, panel = (_tab, _person, _follow) => false, chatLinksChanged = null }) {
155
155
  let requested = false;
156
156
  let generation = null;
157
157
  let revision = 0;
@@ -167,9 +167,12 @@ export function createModelPanelBridge({ win = window, origin = location.origin,
167
167
  const publishStatus = (message = '') => send({ type: 'status', state: lifecycle, message });
168
168
  const publishSnapshot = () => {
169
169
  if (lifecycle !== 'ready') return false;
170
- return send({ type: 'snapshot', snapshot: { ...snapshot(), datasetKey } });
170
+ return send({ type: 'snapshot', snapshot: { ...snapshot(), subjects: selectedSubjects(), datasetKey } });
171
171
  };
172
- const publishSelection = (selectionOrigin = 'tree') => lifecycle === 'ready' && send({ type: 'selection', selectedId: selectedId(), selectedIds: selectedIds(), selectionOrigin });
172
+ // `subjects` is the selection as model objects a chat message may be about (#1653): {source, revision, total,
173
+ // items: [{kind, id, label}]}, or null. Raw selected ids stay beside it for the tree's own rows.
174
+ const publishSelection = (selectionOrigin = 'tree') => lifecycle === 'ready' && send({ type: 'selection', selectedId: selectedId(), selectedIds: selectedIds(),
175
+ subjects: selectedSubjects(), selectionOrigin });
173
176
  const actionResult = (requestId, ok, message = '') => send({ type: 'action-result', requestId, ok, message });
174
177
 
175
178
  const receive = (event) => {
@@ -184,6 +187,11 @@ export function createModelPanelBridge({ win = window, origin = location.origin,
184
187
  }
185
188
  if (!requested || data.generation !== generation) return;
186
189
  if (data.type === 'release') { requested = false; generation = null; return; }
190
+ // AI Chat stored a question about model objects: an editor that shows chat links reads them again.
191
+ if (data.type === 'chat-links-changed') {
192
+ try { chatLinksChanged?.(); } catch (error) { try { win.console?.error?.('[model-panel] chat links refresh failed', error); } catch { /* reporting must not throw */ } }
193
+ return;
194
+ }
187
195
  if (data.type !== 'action' || typeof data.requestId !== 'string') return;
188
196
  if (data.action === 'select' && typeof data.entityId === 'string') {
189
197
  let ok = false;
@@ -223,6 +231,10 @@ export function createModelPanelBridge({ win = window, origin = location.origin,
223
231
  publishSelection,
224
232
  // Ask the main window to show one of the snapshot's tabs — what a toolbar button that opens a tab does.
225
233
  reveal: (tab) => lifecycle === 'ready' && send({ type: 'reveal', tab }),
234
+ // Ask the main window to open one AI Chat conversation at one message — an object card's Show in chat. The
235
+ // project is carried so the main window refuses rather than asking for the conversation in another scope.
236
+ openChat: (chatId, messageEventId, projectId) => typeof chatId === 'string' && typeof messageEventId === 'string'
237
+ && typeof projectId === 'string' && !!projectId && send({ type: 'open-chat', chatId, messageEventId, projectId }),
226
238
  ready(key) { lifecycle = 'ready'; datasetKey = key; publishSnapshot(); },
227
239
  failed(message) { lifecycle = 'failed'; datasetKey = null; publishStatus(message); },
228
240
  dispose() { if (disposed) return; disposed = true; requested = false; win.removeEventListener('message', receive); },
@@ -954,6 +954,7 @@ export function createRevitViewport({ canvas, onSelect = () => {}, onOutlineBuil
954
954
  mountContext = context;
955
955
  inputArbiter = mountCadInputArbiter({
956
956
  surface: canvas, controls, orbitInput, getCamera: () => camera, pickPoint: pickSurface, applyView,
957
+ fitAll: () => controller.fitAll(),
957
958
  fitSelection: () => fit(ownedMeshes.filter((mesh) => selected.includes(mesh.userData.entityId))),
958
959
  isActive: () => mounted && shown && paintAllowed && canvas.offsetParent !== null,
959
960
  plugin: selectionInputProxy,
@@ -481,8 +481,6 @@ export function mountToolbarChrome({ toolbar, getItems = defaultItems, port = nu
481
481
  const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;
482
482
  let next = null;
483
483
  if (step) next = (at + step + items.length) % items.length;
484
- else if (e.key === 'Home') next = 0;
485
- else if (e.key === 'End') next = items.length - 1;
486
484
  if (next === null) return;
487
485
  e.preventDefault();
488
486
  e.stopPropagation(); // a host may bind arrow keys globally too; without this the camera pans as well
@@ -27,8 +27,6 @@ import { createModelPanelBridge, createModelSelectionOriginGuard, createPanelHos
27
27
  const $ = (id) => document.getElementById(id);
28
28
  const projectId = new URLSearchParams(location.search).get('project') || '';
29
29
  let entities = [], properties = [], relationships = [], entityById = new Map(), propertyByEntity = new Map(), selectedId = null, selectedIds = [], selectionOrigin = 'tree', classificationFollowedId = null, facade = null, viewport = null, inspector = null;
30
- let measureTool = null;
31
- let cadTools = null;
32
30
  let selectionTools = null;
33
31
  let selectionFilterChrome = null;
34
32
  let spatialTools = null;
@@ -745,10 +743,10 @@ function mountSharedModelTools() {
745
743
  },
746
744
  });
747
745
  own(() => dock.destroy());
748
- measureTool = nextMeasureTool; cadTools = nextCadTools; selectionTools = nextSelectionTools; selectionFilterChrome = nextSelectionFilterChrome;
749
- sharedTools = { destroy() { if (destroyed) return; destroyed = true; rollback(); measureTool = null; cadTools = null; selectionTools = null; selectionFilterChrome = null; } };
746
+ selectionTools = nextSelectionTools; selectionFilterChrome = nextSelectionFilterChrome;
747
+ sharedTools = { destroy() { if (destroyed) return; destroyed = true; rollback(); selectionTools = null; selectionFilterChrome = null; } };
750
748
  } catch (error) {
751
- destroyed = true; rollback(); measureTool = null; cadTools = null; selectionTools = null; selectionFilterChrome = null; sharedTools = null; throw error;
749
+ destroyed = true; rollback(); selectionTools = null; selectionFilterChrome = null; sharedTools = null; throw error;
752
750
  }
753
751
  }
754
752
 
@@ -823,7 +821,7 @@ function disposeEditor() {
823
821
  const facadeOwnsViewport = !!facade;
824
822
  facade?.dispose();
825
823
  if (!facadeOwnsViewport) viewport?.dispose();
826
- facade = null; viewport = null; measureTool = null; cadTools = null; selectionTools = null;
824
+ facade = null; viewport = null; selectionTools = null;
827
825
  }
828
826
 
829
827
  window.addEventListener('pagehide', (event) => {