@floless/app 0.142.0 → 0.144.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.
Files changed (54) hide show
  1. package/dist/floless-server.cjs +218260 -189290
  2. package/dist/schemas/steel.model.v2.schema.json +50 -2
  3. package/dist/schemas/tekla.model.v1.schema.json +66 -0
  4. package/dist/schemas/tekla.model.v2.schema.json +69 -0
  5. package/dist/schemas/tekla.source-package.v1.schema.json +37 -0
  6. package/dist/skills/floless-app-steel-takeoff/SKILL.md +24 -1
  7. package/dist/skills/floless-app-workflows/SKILL.md +8 -2
  8. package/dist/skills/floless-app-workflows/references/workspace-data.md +25 -4
  9. package/dist/templates/floless-workspace-model-report.flo +27 -23
  10. package/dist/templates/revit-model.flo +6 -2
  11. package/dist/templates/tekla-model-report.flo +60 -0
  12. package/dist/templates/tekla-parser.flo +61 -0
  13. package/dist/web/app.css +89 -2
  14. package/dist/web/app.js +5 -4
  15. package/dist/web/aware.js +441 -47
  16. package/dist/web/chat.css +2 -0
  17. package/dist/web/chat.js +37 -3
  18. package/dist/web/commands-revit.js +4 -0
  19. package/dist/web/commands-shell.js +136 -3
  20. package/dist/web/commands-steel.js +8 -2
  21. package/dist/web/commands-tekla-parser.js +48 -0
  22. package/dist/web/commands.js +1 -1
  23. package/dist/web/filter-ai-context.js +35 -6
  24. package/dist/web/filter-ai-proposal.js +40 -4
  25. package/dist/web/grid-core.js +15 -0
  26. package/dist/web/index.html +40 -2
  27. package/dist/web/instructor.js +26 -14
  28. package/dist/web/left-pane.js +160 -10
  29. package/dist/web/model-artifact-loader.js +15 -0
  30. package/dist/web/model-display-units.js +89 -0
  31. package/dist/web/model-editor-revit-adapter.js +21 -4
  32. package/dist/web/model-editor.css +4 -2
  33. package/dist/web/model-measure.js +10 -6
  34. package/dist/web/model-panel-bridge.js +46 -3
  35. package/dist/web/model-pointer-dock.js +21 -1
  36. package/dist/web/model-property-display.js +91 -0
  37. package/dist/web/model-revit-module.js +9 -0
  38. package/dist/web/model-selection-tools.js +11 -0
  39. package/dist/web/model-spatial-panel.js +52 -21
  40. package/dist/web/model-structural-grid-view.js +334 -0
  41. package/dist/web/model-tekla-selection.js +32 -0
  42. package/dist/web/model-viewport-revit-adapter.js +119 -32
  43. package/dist/web/revit-editor.css +11 -1
  44. package/dist/web/revit-editor.html +4 -3
  45. package/dist/web/revit-editor.js +589 -111
  46. package/dist/web/steel-3d-view.js +58 -372
  47. package/dist/web/steel-editor.html +258 -17
  48. package/dist/web/steel-filter.html +17 -3
  49. package/dist/web/tekla-editor.html +71 -0
  50. package/dist/web/tekla-structural-grid-adapter.js +56 -0
  51. package/dist/web/workspaces.js +872 -97
  52. package/distribution-profile-production.mjs +4 -0
  53. package/distribution-resource-inventory.mjs +4 -2
  54. package/package.json +5 -2
package/dist/web/chat.css CHANGED
@@ -765,6 +765,8 @@
765
765
  .ai-chat-event strong { color: var(--text); font-weight: 500; }
766
766
  .ai-chat-event.error { border-color: color-mix(in srgb, var(--err) 42%, var(--border)); color: var(--err); }
767
767
  .ai-chat-event.knowledge { border-color: color-mix(in srgb, var(--accent) 36%, var(--border)); }
768
+ /* The chat model's object links (#1653): a quiet receipt under its answer. */
769
+ .ai-chat-event.links { border-color: color-mix(in srgb, var(--accent) 24%, var(--border)); }
768
770
  .ai-chat-live-status {
769
771
  align-self: flex-start;
770
772
  display: inline-flex;
package/dist/web/chat.js CHANGED
@@ -44,6 +44,8 @@
44
44
  // The last sentence report() put under the box, held there until the person acts on it (#1683):
45
45
  // { message, scope, chatId, draft, attachments, blocked }. See heldReport().
46
46
  reportHold: null,
47
+ // Only this exact report announcement may be removed when its composer reason ends (#1704).
48
+ reportLiveMessage: null,
47
49
  // A Tekla model library carried over from a Graft receipt but not yet bound to its chat. It is
48
50
  // browser-only until Send: opening, editing or removing it never calls the binding route.
49
51
  // pendingTeklaLibrary waits for the provider chooser to create the chat it belongs to.
@@ -127,9 +129,9 @@
127
129
  return body;
128
130
  }
129
131
 
130
- function announce(message) {
132
+ function announce(message, stillCurrent = () => true) {
131
133
  ui.status.textContent = '';
132
- requestAnimationFrame(() => { ui.status.textContent = message; });
134
+ requestAnimationFrame(() => { if (stillCurrent()) ui.status.textContent = message; });
133
135
  }
134
136
 
135
137
  function setBusy(busy) {
@@ -345,7 +347,8 @@
345
347
  || error?.name === 'TypeError' || error?.name === 'SyntaxError';
346
348
  if (unexpected) console.error(`[ai-chat] ${message}`, error?.cause ?? '', error);
347
349
  else if (status !== null) console.warn(`[ai-chat] ${message}`, error);
348
- announce(message);
350
+ state.reportLiveMessage = message;
351
+ announce(message, () => state.reportLiveMessage === message);
349
352
  ui.hint.textContent = message;
350
353
  ui.hint.classList.add('error');
351
354
  holdReport(message);
@@ -461,6 +464,16 @@
461
464
  // Painted as it was reported, so the poll does not restyle it.
462
465
  if (filterNote && message === filterNote) ui.hint.classList.add('error');
463
466
  }
467
+ // The refusal no longer describes the composer. Only remove that exact announcement:
468
+ // a response may have since claimed the same live region (#1704).
469
+ if (state.reportLiveMessage && ui.hint.textContent !== state.reportLiveMessage) {
470
+ retireReportAnnouncement();
471
+ }
472
+ }
473
+
474
+ function retireReportAnnouncement() {
475
+ if (ui.status.textContent === state.reportLiveMessage) ui.status.textContent = '';
476
+ state.reportLiveMessage = null;
464
477
  }
465
478
 
466
479
  function scopeKey(scope) {
@@ -1818,6 +1831,15 @@
1818
1831
  compaction: 'Conversation summary updated', 'knowledge-citation': 'Knowledge cited', state: 'Status', request: 'Request',
1819
1832
  };
1820
1833
  const payload = event.payload || {};
1834
+ if (event.type === 'chat-subjects') {
1835
+ // The chat model linked Steel objects to this question (#1653). Its note is untrusted text: textContent only.
1836
+ item.classList.add('links');
1837
+ const count = Array.isArray(payload.items) ? payload.items.length : 0;
1838
+ label.textContent = payload.role === 'answer' ? 'Named in answer' : 'Linked objects';
1839
+ const note = typeof payload.aiNote === 'string' ? payload.aiNote : '';
1840
+ item.append(label, document.createTextNode(` · ${count} object${count === 1 ? '' : 's'}${note ? ` · AI note: ${note}` : ''}`));
1841
+ return item;
1842
+ }
1821
1843
  label.textContent = event.type === 'error' && payload.outcome === 'not-sent' ? 'Not sent' : labels[event.type] || event.type;
1822
1844
  let detail = event.type === 'error' ? errorMessage(payloadText(event)) : payloadText(event);
1823
1845
  if (!detail && event.type === 'tool') {
@@ -2107,13 +2129,18 @@
2107
2129
  ui.feed.append(emptyFeedNotice());
2108
2130
  } else {
2109
2131
  let assistant = null;
2132
+ // The chat model's object links (#1653) are written while it answers. They wait until the turn's answer
2133
+ // has been shown and follow it, so an answer is never split by one or pushed below its own receipts.
2134
+ let links = [];
2110
2135
  const flushAssistant = () => {
2111
2136
  if (!assistant) return;
2112
2137
  const rendered = renderedLiveAssistantText(assistant.event, assistant.text);
2113
2138
  ui.feed.append(renderMessage(assistant.event, 'assistant', rendered.text, rendered.streaming));
2114
2139
  assistant = null;
2115
2140
  };
2141
+ const flushLinks = () => { if (links.length) { ui.feed.append(...links.map((link) => link.node)); links = []; } };
2116
2142
  for (const event of state.events) {
2143
+ if (links.length && event.turnId !== links[0].turnId) { flushAssistant(); flushLinks(); }
2117
2144
  if (event.type === 'assistant-message' && event.payload?.delta) {
2118
2145
  // Codex keeps a stable item id while Claude's SDK may assign one per stream packet.
2119
2146
  // Consecutive deltas in the same turn are one visible answer; a tool or other event
@@ -2130,11 +2157,13 @@
2130
2157
  // Provider tools commonly split one answer into before/after chunks. They are not prose,
2131
2158
  // so keep collecting same-turn deltas across them instead of rendering abandoned fragments.
2132
2159
  if (['tool', 'usage', 'knowledge-citation', 'attachment', 'compaction', 'state'].includes(event.type)) continue;
2160
+ if (event.type === 'chat-subjects') { links.push({ turnId: event.turnId, node: renderEvent(event) }); continue; }
2133
2161
  flushAssistant();
2134
2162
  const node = renderEvent(event);
2135
2163
  if (node) ui.feed.append(node);
2136
2164
  }
2137
2165
  flushAssistant();
2166
+ flushLinks();
2138
2167
  // A provider can send text before it finishes tools, usage, or its terminal turn signal.
2139
2168
  // Keep this fixed activity row visible for the full durable turn so an intermittent stream
2140
2169
  // never looks like a failed response. Recovery deliberately has no live indicator.
@@ -2936,6 +2965,8 @@
2936
2965
  }
2937
2966
  if (state.events.some((item) => item.eventId === event.eventId)) return;
2938
2967
  state.events.push(event);
2968
+ // The chat model linked objects during this answer: an open Steel card reads its links again (#1653).
2969
+ if (event.type === 'chat-subjects') subjectLinksSaved(event.payload);
2939
2970
  state.events.sort((a, b) => a.sequence - b.sequence);
2940
2971
  state.chat.lastEventSequence = Math.max(state.chat.lastEventSequence || 0, event.sequence || 0);
2941
2972
  const listChat = state.chats.find((item) => item.chatId === chatId);
@@ -3246,10 +3277,13 @@
3246
3277
  closeSource(); closePicker();
3247
3278
  clearProviderChoice();
3248
3279
  const scopeChanged = scopeKey(scope) !== scopeKey(state.scope);
3280
+ // The new project's history may take time to load. Its old project's refusal is already false.
3281
+ if (scopeChanged) retireReportAnnouncement();
3249
3282
  state.scope = scope;
3250
3283
  state.scopeInitialized = true;
3251
3284
  if (scopeChanged) { try { window.flolessLeftPane?.chatLinksChanged?.(); } catch { /* the card refreshes on its next read */ } }
3252
3285
  state.chat = null; state.chats = []; state.archivedChats = []; state.unreadableChats = []; state.events = []; state.capability = null; state.desktop = null; state.attachments = []; state.integrations = null;
3286
+ if (scopeChanged) clearReport();
3253
3287
  // A published filter answer still lands in its own project's conversation; reopening it resumes.
3254
3288
  for (const entry of state.filterPending.values()) clearTimeout(entry.timer);
3255
3289
  state.filterPending.clear(); state.filterNotices.clear(); state.filterCardMessages.clear();
@@ -3,6 +3,8 @@
3
3
  if (!window.Commands) return;
4
4
  window.Commands.surfaceScope('revit-editor');
5
5
  var def = window.Commands.define;
6
+ def('revit.display-units', { label: 'Display units', actsOn: 'Displays this project’s lengths in {instance}', group: 'In the Revit model toolbar', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand' });
7
+ def('revit.display-units-retry', { label: 'Retry display units', actsOn: 'Reloads this project’s saved display-unit preference', group: 'In the Revit model toolbar', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
6
8
  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
9
  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
10
  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' });
@@ -21,6 +23,8 @@
21
23
  def('revit.clip-action', { label: 'Change clipping', actsOn: 'Applies {instance} to the visible model', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
22
24
  def('revit.work-plane', { label: 'Working plane', actsOn: 'Opens active-frame and working-plane controls', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
23
25
  def('revit.work-plane-action', { label: 'Change working plane', actsOn: 'Applies {instance} to measuring coordinates and snaps', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
26
+ def('revit.work-plane-offset', { label: 'Working-plane offset', actsOn: 'Edits the {instance} plane’s offset along its normal', group: 'In the Revit spatial controls', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
27
+ def('revit.work-plane-set', { label: 'Set working plane', actsOn: 'Applies the {instance} plane at the entered offset to measuring coordinates and snaps', group: 'In the Revit spatial controls', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
24
28
  def('revit.work-area', { label: 'Work area', actsOn: 'Opens shared model-cropping controls', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
25
29
  def('revit.work-area-action', { label: 'Change work area', actsOn: 'Applies {instance} to the visible model extent', group: 'In the Revit model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
26
30
  def('revit.measure', { label: 'Dimension', actsOn: 'Measures between two snapped points in the loaded model', group: 'In the Revit model snapping bar', persistence: 'local', interaction: 'mode', risk: [], guidance: 'on-demand' });
@@ -794,6 +794,17 @@
794
794
  why: 'The project is created only after you choose a drawing and confirm its setup.',
795
795
  });
796
796
 
797
+ def('shell.project-create-tekla-read', {
798
+ label: 'Read Tekla model',
799
+ actsOn: 'Opens the read-only Tekla source picker to start a Parser project',
800
+ group: 'In the project list',
801
+ persistence: 'none',
802
+ interaction: 'dialog',
803
+ risk: [],
804
+ guidance: 'on-demand',
805
+ why: 'The source model is not changed; FloLess starts a read only after you choose a model folder or ZIP.',
806
+ });
807
+
797
808
  def('shell.project-steel-missing-workflow', {
798
809
  label: 'Steel model needs setup',
799
810
  actsOn: 'Explains that the Steel workflow is missing and how to report the setup problem',
@@ -815,14 +826,58 @@
815
826
  });
816
827
 
817
828
  def('shell.revit-view-access', {
818
- label: 'View Revit setup',
819
- actsOn: 'Opens Revit access and setup details for this Workspace',
829
+ label: 'View Revit Parser setup',
830
+ actsOn: 'Opens Revit Parser access and setup details for this Workspace',
831
+ group: 'In the project list',
832
+ persistence: 'none',
833
+ interaction: 'dialog',
834
+ risk: [],
835
+ guidance: 'on-demand',
836
+ why: 'This card explains why the read-only Revit Parser is unavailable and opens the detailed recovery action.',
837
+ });
838
+
839
+ def('shell.revit-retry-setup', {
840
+ label: 'Retry Revit Parser setup',
841
+ actsOn: 'Retries the read-only Revit Parser setup for this Workspace',
842
+ group: 'In the project list',
843
+ persistence: 'none',
844
+ interaction: 'instant',
845
+ risk: [],
846
+ guidance: 'on-demand',
847
+ why: 'This card appears when automatic Revit Parser setup did not finish; retrying checks the same verified parser and entitlement again.',
848
+ });
849
+
850
+ def('shell.tekla-view-access', {
851
+ label: 'View Tekla Parser setup',
852
+ actsOn: 'Opens Tekla Parser account and setup details for this Workspace',
820
853
  group: 'In the project list',
821
854
  persistence: 'none',
822
855
  interaction: 'dialog',
823
856
  risk: [],
824
857
  guidance: 'on-demand',
825
- why: 'This card explains why Revit projects cannot be opened and leads to the available recovery action.',
858
+ why: 'This card explains why the read-only Tekla Parser is unavailable and leads to the available recovery action.',
859
+ });
860
+
861
+ def('shell.tekla-retry-setup', {
862
+ label: 'Retry Tekla Parser setup',
863
+ actsOn: 'Retries the read-only Tekla Parser setup for this Workspace',
864
+ group: 'In the project list',
865
+ persistence: 'none',
866
+ interaction: 'instant',
867
+ risk: [],
868
+ guidance: 'on-demand',
869
+ why: 'This card appears when automatic Tekla Parser setup did not finish; retrying checks the same verified parser and entitlement again.',
870
+ });
871
+
872
+ def('shell.tekla-report-setup-issue', {
873
+ label: 'Report Tekla Parser setup issue',
874
+ actsOn: 'Opens the shared FloLess issue report for an unverifiable Tekla Parser setup',
875
+ group: 'In the project list',
876
+ persistence: 'none',
877
+ interaction: 'dialog',
878
+ risk: [],
879
+ guidance: 'on-demand',
880
+ why: 'A security check did not pass. The model remains untouched and setup is not retried automatically.',
826
881
  });
827
882
 
828
883
  def('shell.revit-report-setup-issue', {
@@ -846,6 +901,26 @@
846
901
  guidance: 'on-demand',
847
902
  });
848
903
 
904
+ def('shell.tekla-source-folder', {
905
+ label: 'Choose Tekla model folder',
906
+ actsOn: 'Chooses an extracted Tekla model directory for a read-only snapshot',
907
+ group: 'In Tekla source selection',
908
+ persistence: 'none',
909
+ interaction: 'dialog',
910
+ risk: [],
911
+ guidance: 'on-demand',
912
+ });
913
+
914
+ def('shell.tekla-source-zip', {
915
+ label: 'Choose Tekla model ZIP',
916
+ actsOn: 'Chooses one Tekla model archive for a read-only snapshot',
917
+ group: 'In Tekla source selection',
918
+ persistence: 'none',
919
+ interaction: 'dialog',
920
+ risk: [],
921
+ guidance: 'on-demand',
922
+ });
923
+
849
924
  def('shell.project-name', {
850
925
  label: 'Project name',
851
926
  actsOn: 'Sets the name shown for this project in FloLess',
@@ -981,6 +1056,36 @@
981
1056
  guidance: 'on-demand',
982
1057
  });
983
1058
 
1059
+ def('shell.model-search', {
1060
+ label: 'Search model objects',
1061
+ actsOn: 'Filters the current Model list by object name, type, profile, or ID',
1062
+ group: 'In the Model section of the left panel',
1063
+ persistence: 'none',
1064
+ interaction: 'instant',
1065
+ risk: [],
1066
+ guidance: 'on-demand',
1067
+ });
1068
+
1069
+ def('shell.model-search-clear', {
1070
+ label: 'Clear model search',
1071
+ actsOn: 'Clears the current object filter and restores the complete Model list',
1072
+ group: 'In the Model section of the left panel',
1073
+ persistence: 'none',
1074
+ interaction: 'instant',
1075
+ risk: [],
1076
+ guidance: 'on-demand',
1077
+ });
1078
+
1079
+ def('shell.grid-elevation', {
1080
+ label: 'Grid visibility: {instance}',
1081
+ actsOn: 'Shows or hides the structural grid at {instance}',
1082
+ group: 'In the Grid object in the Model section',
1083
+ persistence: 'local',
1084
+ interaction: 'instant',
1085
+ risk: [],
1086
+ guidance: 'on-demand',
1087
+ });
1088
+
984
1089
  def('shell.model-item', {
985
1090
  label: 'Select model object', actsOn: 'Selects {instance} in the model and Inspector. Ctrl adds or removes it; Shift takes the rows in between',
986
1091
  group: 'In the Model section of the left panel', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand',
@@ -1964,6 +2069,13 @@
1964
2069
 
1965
2070
  /* ── the report viewer ──────────────────────────────────────────────────── */
1966
2071
 
2072
+ def('shell.report-first-section', { label: 'First report section', actsOn: 'Shows the start of the complete model property report', group: 'In the report viewer', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
2073
+ def('shell.report-previous-section', { label: 'Previous report section', actsOn: 'Shows the preceding section of the report', group: 'In the report viewer', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
2074
+ def('shell.report-next-section', { label: 'Next report section', actsOn: 'Shows the following section of the report', group: 'In the report viewer', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
2075
+ def('shell.report-last-section', { label: 'Last report section', actsOn: 'Shows the final section of the report', group: 'In the report viewer', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
2076
+ def('shell.report-object-number', { label: 'Object number', actsOn: 'Chooses the model object to show', group: 'In the report viewer', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
2077
+ def('shell.report-go-object', { label: 'Go to object', actsOn: 'Shows the first report section containing that object', group: 'In the report viewer', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
2078
+
1967
2079
  def('shell.report-stop', {
1968
2080
  label: 'Stop the live session',
1969
2081
  actsOn: 'Stops the report updating on each change',
@@ -1985,6 +2097,16 @@
1985
2097
  why: 'Hosted on floless.io. Anyone with the link can read it, so treat it as public.',
1986
2098
  });
1987
2099
 
2100
+ def('shell.report-download', {
2101
+ label: 'Download the complete report',
2102
+ actsOn: 'Downloads every object and property from this completed read-only report',
2103
+ group: 'In the report viewer',
2104
+ persistence: 'external',
2105
+ interaction: 'instant',
2106
+ risk: [],
2107
+ guidance: 'on-demand',
2108
+ });
2109
+
1988
2110
  def('shell.report-open-file', {
1989
2111
  label: 'Open the saved file',
1990
2112
  actsOn: 'Opens it in its default application',
@@ -2453,6 +2575,17 @@
2453
2575
  why: 'Greyed out while that routine is already running: the run in progress is the routine doing its job, so a second start is refused rather than queued behind it.',
2454
2576
  });
2455
2577
 
2578
+ def('shell.routine-view-report', {
2579
+ label: 'View saved report',
2580
+ actsOn: 'Opens the verified, read-only report saved by {instance}',
2581
+ group: 'In the Routines dialog',
2582
+ persistence: 'none',
2583
+ interaction: 'instant',
2584
+ risk: [],
2585
+ guidance: 'on-demand',
2586
+ why: 'The report is checked against your current access before it opens. An earlier successful report remains clearly dated if the latest attempt failed.',
2587
+ });
2588
+
2456
2589
  def('shell.routine-delete', {
2457
2590
  label: 'Delete the routine',
2458
2591
  actsOn: 'Removes the routine for good',
@@ -2228,9 +2228,9 @@
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: 'Questions asked in AI Chat with objects selected stay linked to those objects.' });
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
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 no longer in the model', actsOn: 'Shows AI Chat questions about objects this model no longer has, with the name each had when asked', 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.' });
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
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' });
2235
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' });
2236
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' });
@@ -2298,6 +2298,12 @@
2298
2298
  def('steel.connection-row-delete', { label: 'Remove connection row', actsOn: 'Deletes the connection-library row for {instance}', group: 'In the Connections dialog', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'Used rows require confirmation. Placed geometry remains but loses its recipe reference.' });
2299
2299
  def('steel.rfi-profile', { label: 'Set RFI profile', actsOn: 'Sets the live profile for {instance} so FloLess can price the member and check any filed size answer', group: 'In the RFI dialog', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand' });
2300
2300
  def('steel.rfi-profile-retry', { label: 'Retry profile check', actsOn: 'Saves the live profile again and rechecks {instance} against current RFI truth', group: 'In the RFI dialog', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'Offered only after saving or reading current RFI truth failed. The row stays paused until the saved model and the RFI record agree, so retrying cannot expose a stale Apply or Resolved action.' });
2301
+ // #1723 — a height the drawing states, proposed instead of asked for. Every one of these is the same
2302
+ // edit as typing the elevation in Properties, so it clears the "not confirmed" mark on that end.
2303
+ def('steel.rfi-use-height', { label: 'Use or confirm a height', actsOn: 'Sets {instance} as the top of steel for that member end', group: 'In the RFI dialog', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'Use applies a height read off the drawing; Confirm keeps the height already drawn, offered only where the drawings back it. Nothing changes until you choose, and FloLess re-reads the questions first and refuses if the offer has changed.' });
2304
+ def('steel.rfi-height', { label: 'Height', actsOn: 'Holds the height you type for {instance}', group: 'In the RFI dialog', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'Nothing changes until Set height is pressed or Enter is typed.' });
2305
+ def('steel.rfi-set-height', { label: 'Set height', actsOn: 'Sets the typed height as the top of steel for {instance}', group: 'In the RFI dialog', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'Use it when the proposed height is wrong or there is none. It is the same edit as typing the elevation in Properties.' });
2306
+ def('steel.inspector-use-height', { label: 'Use or confirm a height', actsOn: 'Sets {instance} as the top of steel for that member end', group: 'In the Properties panel', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'Use applies a height read off the drawing; Confirm keeps the height already drawn, offered only where the drawings back it. Nothing changes until you choose, and FloLess re-reads the questions first and refuses if the offer has changed.' });
2301
2307
  def('steel.provisional-select', { label: 'Inspect source trace', actsOn: 'Selects the exact source-view trace for {instance} and opens its evidence inspector', group: 'On the steel canvas', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand', why: 'A source trace is evidence, not physical steel, so selecting it exposes the unresolved placement without enabling model edits.' });
2302
2308
  def('steel.provisional-review', { label: 'Review question', actsOn: 'Opens the unresolved placement question for source-only members on this view', group: 'On the steel canvas', persistence: 'none', interaction: 'dialog', risk: [], guidance: 'on-demand', why: 'The traced member stays outside the physical model until its drawing scale, registration, and endpoint readings establish one placement.' });
2303
2309
  def('steel.provisional-source', { label: 'Open source', actsOn: 'Opens the exact drawing region where the source-only member was traced', group: 'On the steel canvas', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
@@ -0,0 +1,48 @@
1
+ (function () {
2
+ 'use strict';
3
+ if (!window.Commands) return;
4
+ window.Commands.surfaceScope('tekla-parser-editor');
5
+ var def = window.Commands.define;
6
+ def('tekla-parser.display-units', { label: 'Display units', actsOn: 'Displays this project’s lengths in {instance}', group: 'In the Tekla Parser model toolbar', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand' });
7
+ def('tekla-parser.display-units-retry', { label: 'Retry display units', actsOn: 'Reloads this project’s saved display-unit preference', group: 'In the Tekla Parser model toolbar', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
8
+ def('tekla-parser.projection', { label: 'Camera projection', actsOn: 'Opens perspective and orthographic camera choices', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
9
+ def('tekla-parser.projection-mode', { label: 'Set camera projection', actsOn: 'Draws the read-only Tekla snapshot in {instance}', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
10
+ def('tekla-parser.fit', { label: 'Fit all to view', actsOn: 'Frames the whole read-only Tekla snapshot', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
11
+ def('tekla-parser.fit-selection', { label: 'Zoom to selected', actsOn: 'Frames the selected model object', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
12
+ def('tekla-parser.display-mode', { label: 'Display mode', actsOn: 'Opens solid, wireframe, X-ray and realistic choices', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
13
+ def('tekla-parser.display-mode-set', { label: 'Set display mode', actsOn: 'Draws the read-only Tekla snapshot as {instance}', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
14
+ def('tekla-parser.lighting', { label: 'Lighting settings', actsOn: 'Adjusts sunlight direction and model brightness', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'dialog', risk: [], guidance: 'on-demand' });
15
+ def('tekla-parser.visibility', { label: 'Visibility', actsOn: 'Opens temporary visibility actions', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
16
+ def('tekla-parser.show-all', { label: 'Show all', actsOn: 'Restores every hidden or isolated object', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
17
+ def('tekla-parser.isolate', { label: 'Isolate selected', actsOn: 'Shows only the selected model object', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
18
+ def('tekla-parser.ghost-unselected', { label: 'Ghost unselected', actsOn: 'Fades every object outside the current selection', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
19
+ def('tekla-parser.hide-selected', { label: 'Hide selected', actsOn: 'Temporarily hides the selected model object', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
20
+ def('tekla-parser.saved-views', { label: 'Saved views', actsOn: 'Stores or restores a camera view for this exact snapshot', group: 'In the Tekla Parser model toolbar', persistence: 'working', interaction: 'dialog', risk: [], guidance: 'on-demand' });
21
+ def('tekla-parser.spatial-controls', { label: 'Spatial controls', actsOn: 'Opens coordinate frame, working plane, clip, and work-area controls', group: 'In the Tekla Parser coordinate HUD', persistence: 'local', interaction: 'dialog', risk: [], guidance: 'on-demand' });
22
+ def('tekla-parser.clip', { label: 'Clipping', actsOn: 'Opens shared clip-plane and clip-box actions', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
23
+ def('tekla-parser.clip-action', { label: 'Change clipping', actsOn: 'Applies {instance} to the visible snapshot', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
24
+ def('tekla-parser.work-plane', { label: 'Working plane', actsOn: 'Opens active-frame and working-plane controls', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
25
+ def('tekla-parser.work-plane-action', { label: 'Change working plane', actsOn: 'Applies {instance} to measuring coordinates and snaps', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
26
+ def('tekla-parser.work-plane-offset', { label: 'Working-plane offset', actsOn: 'Edits the {instance} plane’s offset along its normal', group: 'In the Tekla Parser spatial controls', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand' });
27
+ def('tekla-parser.work-plane-set', { label: 'Set working plane', actsOn: 'Applies the {instance} plane at the entered offset to measuring coordinates and snaps', group: 'In the Tekla Parser spatial controls', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
28
+ def('tekla-parser.work-area', { label: 'Work area', actsOn: 'Opens shared model-cropping controls', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
29
+ def('tekla-parser.work-area-action', { label: 'Change work area', actsOn: 'Applies {instance} to the visible snapshot extent', group: 'In the Tekla Parser model toolbar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
30
+ def('tekla-parser.measure', { label: 'Dimension', actsOn: 'Measures between two snapped points in the loaded snapshot', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'mode', risk: [], guidance: 'active-command', steps: ['Click the first point', 'Click the second point', 'Click to place the dimension'], escLabel: 'Esc goes back one step; from the first point, Esc cancels' });
31
+ def('tekla-parser.measure-clear', { label: 'Clear dimensions', actsOn: 'Clears session-only model dimensions', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
32
+ def('tekla-parser.measure-axis-free', { label: 'Free measurement', actsOn: 'Clears the X, Y and Z measurement locks', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
33
+ def('tekla-parser.measure-axis-x', { label: 'Measure along X', actsOn: 'Toggles the active-frame X dimension lock', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
34
+ def('tekla-parser.measure-axis-y', { label: 'Measure along Y', actsOn: 'Toggles the active-frame Y dimension lock', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
35
+ def('tekla-parser.measure-axis-z', { label: 'Measure along Z', actsOn: 'Toggles the active-frame vertical dimension lock', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
36
+ def('tekla-parser.snap-mesh-vertex', { label: 'Mesh vertex snapping', actsOn: 'Snaps dimensions to authenticated triangle-mesh vertices', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
37
+ def('tekla-parser.snap-mesh-edge-midpoint', { label: 'Mesh edge midpoint snapping', actsOn: 'Snaps dimensions to authenticated triangle-edge midpoints', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
38
+ def('tekla-parser.snap-mesh-edge-nearest', { label: 'Mesh edge nearest snapping', actsOn: 'Snaps dimensions to the nearest point on an authenticated triangle edge', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
39
+ def('tekla-parser.snap-surface', { label: 'Mesh surface snapping', actsOn: 'Snaps dimensions to the authenticated model surface beneath the pointer', group: 'In the Tekla Parser snapping bar', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
40
+ def('tekla-parser.selection-filter', { label: 'Selection filter', actsOn: 'Narrows selectable model objects by {instance}', group: 'In the Tekla Parser selection bar', persistence: 'local', interaction: 'dialog', risk: [], guidance: 'on-demand' });
41
+ def('tekla-parser.inspector-toggle', { label: 'Toggle the Properties panel', actsOn: 'Collapses or opens the read-only Properties panel', group: 'In the Properties panel', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
42
+ def('tekla-parser.authority', { label: 'Model authority', actsOn: 'Switches between an available working and approved snapshot', group: 'In the Tekla Parser header', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
43
+ def('tekla-parser.audit-filter', { label: 'Filter import findings', actsOn: 'Shows {instance} findings in the read-only import audit', anyInstance: 'all', group: 'In the Tekla Parser Audit pane', persistence: 'local', interaction: 'instant', risk: [], guidance: 'on-demand' });
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
+ 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
+ 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.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' });
48
+ })();
@@ -70,7 +70,7 @@
70
70
  drift out of step with the registrations. That table was the alternative,
71
71
  and a second statement of which command sits where is exactly the drift
72
72
  this design exists to prevent. */
73
- var SURFACE = ['shell', 'steel-editor', 'revit-editor', 'steel-filter', 'vector-editor', 'vector-3d'];
73
+ var SURFACE = ['shell', 'steel-editor', 'revit-editor', 'tekla-parser-editor', 'steel-filter', 'vector-editor', 'vector-3d'];
74
74
 
75
75
  var registry = Object.create(null);
76
76
  /* Templates removed by retire() — a capability gated OFF in this build, not one nobody
@@ -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('+'))))) {
@@ -869,8 +869,14 @@ export function gridGeometry(g, mmPerPx, opts = {}) {
869
869
  // Bubbles print what a registration control resolves against — one rule, `axisLabelsFor` (#740).
870
870
  const lx = axisLabelsFor(g, 'x', 'num', X.offsets.length);
871
871
  const ly = axisLabelsFor(g, 'y', 'alpha', Y.offsets.length);
872
+ const identityScope = typeof g?.identity_scope === 'string' && g.identity_scope.trim() ? g.identity_scope.trim() : null;
872
873
  const v = X.offsets.map((off, i) => ({ x: ox + px(off), label: lx[i] }));
873
874
  const h = Y.offsets.map((off, i) => ({ y: yUp ? oy + px(off) : oy - px(off), label: ly[i] })); // projected sheet: up = -Y; native model: world mm, already Y-up
875
+ if (identityScope) {
876
+ const used = new Set();
877
+ for (const line of v) { line.id = gridSubIdentity(identityScope, 'x', line.x * k, line.label); if (used.has(line.id)) throw new Error('Structural grid has a duplicate X-axis identity.'); used.add(line.id); }
878
+ for (const line of h) { line.id = gridSubIdentity(identityScope, 'y', line.y * k, line.label); if (used.has(line.id)) throw new Error('Structural grid has a duplicate Y-axis identity.'); used.add(line.id); }
879
+ }
874
880
  // Z levels are absolute, sorted/deduped, and retain their authored label source index.
875
881
  const resolvedZ = parseLevels(g && g.z, g && g.labels_z);
876
882
  const levelsZ = resolvedZ.err ? [] : resolvedZ.levels;
@@ -916,6 +922,15 @@ export function gridGeometry(g, mmPerPx, opts = {}) {
916
922
  return geo;
917
923
  }
918
924
 
925
+ /** Stable provider-neutral identity for one authenticated native grid axis or level. */
926
+ export function gridSubIdentity(scope, axis, positionMm, authoredLabel) {
927
+ const owner = String(scope ?? '').trim(); const direction = String(axis ?? '').toLowerCase();
928
+ const position = Number(positionMm); const label = String(authoredLabel ?? '').normalize('NFC');
929
+ if (!owner || !['x', 'y', 'z'].includes(direction) || !Number.isFinite(position)) throw new TypeError('Structural grid identity is incomplete.');
930
+ const canonicalPosition = Object.is(position, -0) ? '0' : String(position);
931
+ return `grid:${encodeURIComponent(owner)}:${direction}:${canonicalPosition}:${encodeURIComponent(label)}`;
932
+ }
933
+
919
934
  /**
920
935
  * Drag one END of a grid line along its axis (extend/shorten — the bubbles are the grips).
921
936
  * end 0 = the lo end (top of a v-line / left of an h-line), 1 = hi. Clamps to a 12" minimum line and