@floless/app 0.154.0 → 0.155.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 (47) hide show
  1. package/dist/floless-server.cjs +49492 -37984
  2. package/dist/schemas/steel.model.v2.schema.json +19 -5
  3. package/dist/skills/floless-app-onboarding/SKILL.md +22 -13
  4. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +12 -8
  5. package/dist/skills/floless-app-steel-model/SKILL.md +23 -2
  6. package/dist/skills/floless-app-steel-takeoff/SKILL.md +158 -65
  7. package/dist/skills/floless-app-workflows/SKILL.md +23 -5
  8. package/dist/skills/floless-app-workflows/references/blender-exec.md +183 -0
  9. package/dist/skills/floless-app-workflows/references/dev-server-and-run-trace.md +27 -12
  10. package/dist/templates/blender-construction-sequence.flo +96 -0
  11. package/dist/web/agents.js +33 -13
  12. package/dist/web/app.css +275 -33
  13. package/dist/web/aware.js +745 -82
  14. package/dist/web/chat-question-card.js +477 -0
  15. package/dist/web/chat.css +177 -12
  16. package/dist/web/chat.js +1537 -717
  17. package/dist/web/commands-shell.js +424 -7
  18. package/dist/web/commands-steel.js +105 -4
  19. package/dist/web/guide.js +4 -3
  20. package/dist/web/index.html +96 -7
  21. package/dist/web/instructor.js +10 -9
  22. package/dist/web/left-pane.js +40 -3
  23. package/dist/web/media-player.js +234 -0
  24. package/dist/web/model-editor-contract.js +2 -0
  25. package/dist/web/model-editor-revit-adapter.js +1 -0
  26. package/dist/web/model-editor-steel-adapter.js +89 -1
  27. package/dist/web/model-panel-bridge.js +16 -2
  28. package/dist/web/model-view-query.js +590 -0
  29. package/dist/web/model-viewport-revit-adapter.js +15 -1
  30. package/dist/web/model-viewport-toolbar.js +5 -2
  31. package/dist/web/pages.js +592 -0
  32. package/dist/web/panels.js +2 -1
  33. package/dist/web/revit-editor.js +181 -16
  34. package/dist/web/run-progress.js +193 -0
  35. package/dist/web/run-strip.js +173 -0
  36. package/dist/web/steel-3d-core.js +70 -0
  37. package/dist/web/steel-editor.html +2751 -219
  38. package/dist/web/steel-frames-core.js +958 -0
  39. package/dist/web/steel-last-seen.js +315 -0
  40. package/dist/web/steel-marks-core.js +530 -0
  41. package/dist/web/steel-model-slim.js +95 -0
  42. package/dist/web/steel-model-v2-client-validation.js +14 -2
  43. package/dist/web/steel-model-v2-commands.js +258 -27
  44. package/dist/web/steel-model-v2-projection.js +78 -18
  45. package/dist/web/steel-read-confidence.js +11 -2
  46. package/dist/web/workspaces.js +416 -26
  47. package/package.json +3 -2
@@ -0,0 +1,234 @@
1
+ // The video player for what a run rendered (#2230): a Blender construction sequence, a fly-through,
2
+ // a turntable. It plays a file the server serves by opaque id (/api/run-output/…), inside the media
3
+ // viewer modal in index.html. No native chrome: the <video> has no `controls`; play/pause, the time,
4
+ // a themed scrubber and loop are our own controls, in both themes.
5
+ //
6
+ // open({ sub, items: [{ url, name, kind, path, frames }], loop, unavailable }) — the one entry point.
7
+ // A plain script (no import/export); its one global is `flolessMediaPlayer`.
8
+
9
+ (function () {
10
+ const $modal = document.getElementById('media-modal');
11
+ if (!$modal) return;
12
+ const $title = document.getElementById('media-title');
13
+ const $sub = document.getElementById('media-sub');
14
+ const $stage = document.getElementById('media-stage');
15
+ const $video = document.getElementById('media-video');
16
+ const $status = document.getElementById('media-status');
17
+ const $play = document.getElementById('media-play');
18
+ const $time = document.getElementById('media-time');
19
+ const $total = document.getElementById('media-total');
20
+ const $seek = document.getElementById('media-seek');
21
+ const $loop = document.getElementById('media-loop');
22
+ const $list = document.getElementById('media-list');
23
+ const $open = document.getElementById('media-open-file');
24
+ const $reveal = document.getElementById('media-reveal');
25
+ const $close = document.getElementById('media-close');
26
+ const LOOP_KEY = 'floless.media.loop';
27
+
28
+ let items = [];
29
+ let current = null;
30
+ let scrubbing = false;
31
+ let resumeAfterScrub = false;
32
+ let returnFocus = null;
33
+ let unavailableText = '';
34
+
35
+ function clock(sec) {
36
+ const t = Math.max(0, Math.floor(Number(sec) || 0));
37
+ const h = Math.floor(t / 3600), m = Math.floor((t % 3600) / 60), s = t % 60;
38
+ const ss = String(s).padStart(2, '0');
39
+ return h ? `${h}:${String(m).padStart(2, '0')}:${ss}` : `${m}:${ss}`;
40
+ }
41
+
42
+ function setStatus(text, kind) {
43
+ $status.textContent = text || '';
44
+ $status.hidden = !text;
45
+ $status.dataset.kind = kind || '';
46
+ }
47
+
48
+ function setControlsEnabled(on) {
49
+ for (const el of [$play, $seek, $loop]) el.disabled = !on;
50
+ const row = document.getElementById('media-controls');
51
+ if (row) row.classList.toggle('is-loading', !on);
52
+ }
53
+
54
+ function paintPlay() {
55
+ const ended = $video.ended || ($video.duration && $video.currentTime >= $video.duration && !$video.loop);
56
+ const playing = !$video.paused && !$video.ended;
57
+ $play.textContent = playing ? '❚❚' : ended ? '↻' : '▶';
58
+ const label = playing ? 'Pause' : ended ? 'Replay' : 'Play';
59
+ $play.setAttribute('aria-label', label);
60
+ $play.dataset.tip = `${label} (Space)`;
61
+ }
62
+
63
+ function paintTime() {
64
+ const d = Number.isFinite($video.duration) ? $video.duration : 0;
65
+ $time.textContent = clock($video.currentTime);
66
+ $total.textContent = clock(d);
67
+ if (!scrubbing) {
68
+ $seek.max = String(d || 0);
69
+ $seek.value = String($video.currentTime || 0);
70
+ }
71
+ $seek.setAttribute('aria-valuetext', `${clock($video.currentTime)} of ${clock(d)}`);
72
+ const pct = d ? ($video.currentTime / d) * 100 : 0;
73
+ $seek.style.setProperty('--played', `${pct}%`);
74
+ }
75
+
76
+ function paintLoop() {
77
+ $loop.setAttribute('aria-pressed', String($video.loop));
78
+ $loop.dataset.tip = $video.loop ? 'Loop is on (L)' : 'Loop is off (L)';
79
+ }
80
+
81
+ function paintList() {
82
+ $list.replaceChildren();
83
+ $list.hidden = items.length < 2;
84
+ if (items.length < 2) return;
85
+ items.forEach((item, i) => {
86
+ const b = document.createElement('button');
87
+ b.type = 'button';
88
+ b.className = 'media-chip';
89
+ b.textContent = item.name;
90
+ b.dataset.commandId = `shell.media-choose#${i + 1}`;
91
+ b.setAttribute('aria-pressed', String(item === current));
92
+ b.onclick = () => load(item, true);
93
+ $list.append(b);
94
+ });
95
+ }
96
+
97
+ function load(item, autoplay) {
98
+ current = item;
99
+ $title.textContent = item.name || 'Video';
100
+ $open.hidden = $reveal.hidden = !item.path;
101
+ setControlsEnabled(false);
102
+ setStatus('Loading video…', 'loading');
103
+ $stage.dataset.state = 'loading';
104
+ $video.removeAttribute('src');
105
+ $video.src = item.url;
106
+ $video.load();
107
+ paintList();
108
+ if (autoplay) {
109
+ $video.addEventListener('canplay', function once() {
110
+ $video.removeEventListener('canplay', once);
111
+ // The person just clicked Watch, so play is allowed; if the browser still refuses, the big
112
+ // Play stays up and nothing is reported as an error.
113
+ $video.play().catch(() => paintPlay());
114
+ });
115
+ }
116
+ }
117
+
118
+ async function fileAction(endpoint, failMsg) {
119
+ if (!current || !current.path) return;
120
+ try {
121
+ const res = await fetch(endpoint, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ path: current.path }) });
122
+ if (!res.ok) throw new Error(String(res.status));
123
+ } catch {
124
+ setStatus(failMsg, 'error');
125
+ }
126
+ }
127
+
128
+ function close() {
129
+ $video.pause();
130
+ $video.removeAttribute('src');
131
+ $video.load();
132
+ $modal.classList.remove('show');
133
+ if (returnFocus && typeof returnFocus.focus === 'function') returnFocus.focus();
134
+ returnFocus = null;
135
+ }
136
+
137
+ function seekBy(sec) {
138
+ if (!Number.isFinite($video.duration)) return;
139
+ $video.currentTime = Math.max(0, Math.min($video.duration, $video.currentTime + sec));
140
+ }
141
+
142
+ $video.addEventListener('loadedmetadata', () => {
143
+ setStatus('', '');
144
+ $stage.dataset.state = 'ready';
145
+ setControlsEnabled(true);
146
+ // Play could not take focus while it was still disabled (loading); give it now, unless the person has
147
+ // already moved focus somewhere inside the player.
148
+ if ($modal.classList.contains('show') && !$modal.contains(document.activeElement)) $play.focus();
149
+ const meta = [];
150
+ if (current && current.subtitle) meta.push(current.subtitle);
151
+ meta.push(clock($video.duration));
152
+ if ($video.videoWidth) meta.push(`${$video.videoWidth}×${$video.videoHeight}`);
153
+ if (current && current.frames) meta.push(`${current.frames} frames`);
154
+ $sub.textContent = meta.join(' · ');
155
+ paintTime();
156
+ paintPlay();
157
+ });
158
+ $video.addEventListener('timeupdate', paintTime);
159
+ for (const ev of ['play', 'pause', 'ended']) $video.addEventListener(ev, paintPlay);
160
+ $video.addEventListener('error', () => {
161
+ setControlsEnabled(false);
162
+ $stage.dataset.state = 'error';
163
+ // A 404/410 from the server and a file this browser cannot decode look alike here, so the message names
164
+ // both causes rather than guess one; Open file / Reveal (or a re-run) are the way forward either way.
165
+ setStatus(unavailableText || (current && current.path
166
+ ? 'FloLess couldn’t play this video here — it may have changed since the run, or be in a format this window can’t show. Open it in your default player, or run the workflow again to make a new one.'
167
+ : 'FloLess couldn’t play this video here — it may have changed since the run. Run the workflow again to make a new one.'), 'error');
168
+ });
169
+
170
+ $play.onclick = () => {
171
+ if ($video.paused || $video.ended) {
172
+ if ($video.ended) $video.currentTime = 0;
173
+ $video.play().catch(() => paintPlay());
174
+ } else {
175
+ $video.pause();
176
+ }
177
+ };
178
+ $seek.addEventListener('input', () => {
179
+ if (!scrubbing) { scrubbing = true; resumeAfterScrub = !$video.paused; $video.pause(); }
180
+ $video.currentTime = Number($seek.value);
181
+ paintTime();
182
+ });
183
+ $seek.addEventListener('change', () => {
184
+ scrubbing = false;
185
+ if (resumeAfterScrub) $video.play().catch(() => paintPlay());
186
+ resumeAfterScrub = false;
187
+ });
188
+ $loop.onclick = () => {
189
+ $video.loop = !$video.loop;
190
+ try { localStorage.setItem(LOOP_KEY, $video.loop ? '1' : '0'); } catch { /* private mode */ }
191
+ paintLoop();
192
+ };
193
+ $open.onclick = () => fileAction('/api/open-file', 'Couldn’t open the video in your default player.');
194
+ $reveal.onclick = () => fileAction('/api/reveal', 'Couldn’t show the video in its folder.');
195
+ $close.onclick = close;
196
+ $modal.addEventListener('click', (e) => { if (e.target === $modal) close(); });
197
+
198
+ // On the document, not the modal: a click on the video surface or the backdrop leaves focus on <body>, and the
199
+ // shortcuts must still work while the player is open. Typing in a text field elsewhere is never a shortcut.
200
+ document.addEventListener('keydown', (e) => {
201
+ const t = e.target;
202
+ if (t && t !== document.body && !$modal.contains(t) && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;
203
+ if (!$modal.classList.contains('show')) return;
204
+ if (e.key === 'Escape') { e.preventDefault(); close(); return; }
205
+ const onSeek = document.activeElement === $seek;
206
+ const onButton = document.activeElement && document.activeElement.tagName === 'BUTTON';
207
+ if ((e.key === ' ' || e.key === 'k' || e.key === 'K') && !onSeek && !onButton) { e.preventDefault(); $play.click(); return; }
208
+ if (onSeek) return; // the scrubber keeps its own arrows / PageUp / Home / End
209
+ if (e.key === 'ArrowLeft') { e.preventDefault(); seekBy(e.shiftKey ? -1 : -5); }
210
+ else if (e.key === 'ArrowRight') { e.preventDefault(); seekBy(e.shiftKey ? 1 : 5); }
211
+ else if (e.key === 'Home') { e.preventDefault(); $video.currentTime = 0; }
212
+ else if (e.key === 'End' && Number.isFinite($video.duration)) { e.preventDefault(); $video.currentTime = $video.duration; }
213
+ else if (e.key === 'l' || e.key === 'L') { e.preventDefault(); $loop.click(); }
214
+ });
215
+
216
+ function open(opts) {
217
+ items = (opts && Array.isArray(opts.items) ? opts.items : []).filter((it) => it && it.url);
218
+ if (!items.length) return;
219
+ returnFocus = document.activeElement;
220
+ // A caller that knows how its video is made says how to make it again (a turntable is re-rendered, not re-run).
221
+ unavailableText = (opts && typeof opts.unavailable === 'string' && opts.unavailable) || '';
222
+ let loop = !!(opts && opts.loop);
223
+ try { const saved = localStorage.getItem(LOOP_KEY); if (saved !== null && !(opts && opts.loop)) loop = saved === '1'; } catch { /* private mode */ }
224
+ $video.loop = loop;
225
+ paintLoop();
226
+ $sub.textContent = (opts && opts.sub) || '';
227
+ for (const it of items) it.subtitle = (opts && opts.sub) || '';
228
+ $modal.classList.add('show');
229
+ load(items[0], true);
230
+ $play.focus();
231
+ }
232
+
233
+ window.flolessMediaPlayer = { open, close };
234
+ })();
@@ -278,6 +278,8 @@ export const MODEL_COMMANDS_V1 = Object.freeze({
278
278
  'model.visibility': cmd('model.visibility', 'chrome', null),
279
279
  'model.isolate': cmd('model.isolate', 'viewport', 'isolateSelected'),
280
280
  'model.ghost-unselected': cmd('model.ghost-unselected', 'viewport', 'toggleGhostUnselected'),
281
+ // Sets Ghost unselected outright, for a caller that knows the state it wants (AI Chat, #2255) rather than flipping it.
282
+ 'model.ghost-unselected.set': cmd('model.ghost-unselected', 'viewport', 'setGhostUnselected', 'boolean'),
281
283
  'model.hide-selected': cmd('model.hide-selected', 'viewport', 'hideSelected'),
282
284
  'model.show-all': cmd('model.show-all', 'viewport', 'showAll'),
283
285
 
@@ -138,6 +138,7 @@ function provider(viewport) {
138
138
  fitSelection: viewport.fitSelection,
139
139
  isolateSelected: viewport.isolateSelected,
140
140
  toggleGhostUnselected: viewport.toggleGhostUnselected,
141
+ setGhostUnselected: viewport.setGhostUnselected,
141
142
  hideSelected: viewport.hideSelected,
142
143
  showAll: viewport.showAll,
143
144
  setSelection: viewport.setSelection,
@@ -117,6 +117,7 @@ function steelViewportProvider(resolve) {
117
117
 
118
118
  isolateSelected: () => v().isolateSelected(),
119
119
  toggleGhostUnselected: () => v().toggleGhostUnselected(),
120
+ setGhostUnselected: (on) => v().setGhostUnselected(on),
120
121
  hideSelected: () => v().hideSelected(), // returns the count, which the page toasts
121
122
  showAll: () => v().showAllGroups(),
122
123
 
@@ -347,13 +348,19 @@ const CONTROLS = Object.freeze({
347
348
  },
348
349
  });
349
350
 
351
+ /**
352
+ * The tag glyph both Labels buttons draw: the 3D toolbar's and the 2D plan toolbar's. One string, so the two
353
+ * buttons cannot drift apart; `steel-2d-labels-button.test.ts` holds the rendered 2D button to it.
354
+ */
355
+ export const STEEL_LABELS_ICON_V1 = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8.6 2.3H13a.7.7 0 0 1 .7.7v4.4a1 1 0 0 1-.3.7l-5.6 5.6a1 1 0 0 1-1.4 0L2.3 9.6a1 1 0 0 1 0-1.4l5.6-5.6a1 1 0 0 1 .7-.3z"/><circle cx="10.9" cy="5.1" r="1"/></svg>';
356
+
350
357
  /** Steel's own menu — reference lines and the shared property-label controls. Never a common control. */
351
358
  const CONTRIBUTIONS = Object.freeze({
352
359
  'steel.labels': [{
353
360
  // The contribution's own id is STEEL_TOOLBAR_CONTRIBUTIONS_V1's single member; stated here
354
361
  // because a contribution has no `model.*` control to bind through.
355
362
  kind: 'menu', el: 'm3dView', menu: 'm3dViewMenu', aria: true, label: 'Labels', semantic: 'steel.labels',
356
- icon: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8.6 2.3H13a.7.7 0 0 1 .7.7v4.4a1 1 0 0 1-.3.7l-5.6 5.6a1 1 0 0 1-1.4 0L2.3 9.6a1 1 0 0 1 0-1.4l5.6-5.6a1 1 0 0 1 .7-.3z"/><circle cx="10.9" cy="5.1" r="1"/></svg>',
363
+ icon: STEEL_LABELS_ICON_V1,
357
364
  cmd: STEEL_TOOLBAR_CONTRIBUTIONS_V1[0],
358
365
  tip: 'Show or hide reference lines and property labels on the 3D model',
359
366
  items: [
@@ -384,6 +391,87 @@ const CONTRIBUTIONS = Object.freeze({
384
391
  }],
385
392
  });
386
393
 
394
+ /* ───────────────────────────────────────────────────────────────────────────────────────────────
395
+ * THE 2D PLAN TOOLBAR'S LABELS MENU (#2216)
396
+ *
397
+ * The 3D toolbar's Labels menu holds a Ref line switch and the Property labels section. The 2D plan toolbar
398
+ * gets the section alone (reference lines are a 3D thing), and it is DERIVED from the 3D one rather than
399
+ * written a third time: same rows, same words, same tooltips, same order. Only what has to differ is
400
+ * renamed — the element ids (the page wires them by id), the Instructor instance (`#View` becomes `#2D`)
401
+ * and the spoken name of the view the switch edits.
402
+ *
403
+ * The shapes below are matched by SHAPE, not by position, and the derive throws on a section it does not
404
+ * recognise: a row added to the 3D section arrives in 2D by itself, and an id, command suffix or aria name
405
+ * this function has never seen fails at boot and in the tests (steel-2d-labels-button.test.ts) instead of
406
+ * rendering a 2D menu that quietly lacks it or names the wrong view.
407
+ * ─────────────────────────────────────────────────────────────────────────────────────────────── */
408
+
409
+ /** Element ids of the 3D section → the 2D menu's. `m3dPl…` rows become `pl2d…`; the master switch is the one outlier. */
410
+ const labelsIdFor2d = (el) => {
411
+ if (el === 'm3dPropLabels') return 'pl2dPropLabels';
412
+ if (typeof el === 'string' && el.startsWith('m3dPl')) return 'pl2d' + el.slice('m3dPl'.length);
413
+ throw new Error(`steelLabels2dControl: unrecognised property-label element "${el}" — teach labelsIdFor2d about it`);
414
+ };
415
+
416
+ /** The 3D master switch's accessible name: the one aria name the derive knows how to carry over to 2D. */
417
+ const LABELS_ARIA_3D = 'Property labels in 3D';
418
+
419
+ /** Exported so the tests can hold its refusals: an id, command suffix or aria name it was never taught must throw. */
420
+ export function deriveLabelsItemFor2d(item) {
421
+ const out = { ...item };
422
+ if (out.el !== undefined) out.el = labelsIdFor2d(out.el);
423
+ if (out.controls !== undefined) out.controls = labelsIdFor2d(out.controls);
424
+ if (out.revealBy !== undefined) out.revealBy = labelsIdFor2d(out.revealBy);
425
+ if (typeof out.cmd === 'string') {
426
+ if (!out.cmd.endsWith('#View')) throw new Error(`steelLabels2dControl: "${out.cmd}" is not a 3D property-label command`);
427
+ out.cmd = out.cmd.slice(0, -'#View'.length) + '#2D';
428
+ }
429
+ if (out.ariaLabel !== undefined) {
430
+ // Only the 3D master switch's name is known to be about "3D"; any other aria name is a row this derive was
431
+ // never taught, and renaming it blindly would put the wrong view's name on it.
432
+ if (out.ariaLabel !== LABELS_ARIA_3D) throw new Error(`steelLabels2dControl: unrecognised aria name "${out.ariaLabel}" — teach deriveLabelsItemFor2d about it`);
433
+ out.ariaLabel = 'Property labels in 2D plan';
434
+ }
435
+ if (out.items) {
436
+ if (!out.items.length) throw new Error('steelLabels2dControl: an empty group in the 3D Property labels section — nothing to derive');
437
+ out.items = out.items.map(deriveLabelsItemFor2d);
438
+ }
439
+ return Object.freeze(out);
440
+ }
441
+
442
+ /** The trigger's Instructor command: its own template (the 2D toolbar's place), not the 3D `steel.toolbar-menu`. */
443
+ export const STEEL_LABELS_2D_TRIGGER_V1 = 'steel.toolbar-menu-2d#property labels';
444
+
445
+ /**
446
+ * The 2D plan toolbar's Labels menu as a render-plan control: the 3D menu's Property labels section, nothing else.
447
+ * Same tag glyph, same label word and the same tip family as the 3D button.
448
+ */
449
+ export function steelLabels2dControl() {
450
+ const menu3d = CONTRIBUTIONS['steel.labels'][0];
451
+ const section = menu3d.items.find((item) => item.kind === 'section');
452
+ if (!section) throw new Error('steelLabels2dControl: the 3D Labels menu no longer has a Property labels section to derive from');
453
+ if (!section.items?.length) throw new Error('steelLabels2dControl: the 3D Property labels section is empty - nothing to derive');
454
+ return Object.freeze({
455
+ kind: 'menu', el: 'pl2dBtn', menu: 'pl2dMenu', aria: true, label: menu3d.label, semantic: 'steel.labels-2d',
456
+ icon: menu3d.icon,
457
+ cmd: STEEL_LABELS_2D_TRIGGER_V1,
458
+ tip: 'Show or hide property labels on the 2D plan',
459
+ items: [deriveLabelsItemFor2d(section)],
460
+ });
461
+ }
462
+
463
+ /**
464
+ * The 2D menu in the same plan shape the 3D bar renders, so the page, the guards and the tests all draw it
465
+ * through the one renderer. The rule before it is the one the 3D bar puts before its own Labels menu.
466
+ */
467
+ export function steelLabels2dPlan() {
468
+ const plan = {
469
+ schema: 'floless.model-toolbar-plan/v1',
470
+ clusters: [{ kind: 'contribution', id: 'steel.labels-2d', separatorBefore: true, controls: [steelLabels2dControl()] }],
471
+ };
472
+ return Object.freeze({ ...plan, carriers: Object.freeze(toolbarCarriers(plan)) });
473
+ }
474
+
387
475
  /**
388
476
  * The plan for a given capability set — Steel's own by default.
389
477
  *
@@ -173,7 +173,7 @@ export function createModelPanelBridge({ win = window, origin = location.origin,
173
173
  const id = selectedId(); return typeof id === 'string' ? [id] : [];
174
174
  }, select, expand, selectGroup = (_groupId) => false, search = (_tab, _query) => false,
175
175
  selectionState = () => ({}), panel = (_tab, _person, _follow) => false,
176
- gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksChanged = null }) {
176
+ gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksChanged = null, view = /** @type {((command: any, target: any) => any) | null} */ (null) }) {
177
177
  let requested = false;
178
178
  let generation = null;
179
179
  let revision = 0;
@@ -195,7 +195,7 @@ gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksCha
195
195
  // items: [{kind, id, label}]}, or null. Raw selected ids stay beside it for the tree's own rows.
196
196
  const publishSelection = (selectionOrigin = 'tree') => lifecycle === 'ready' && send({ type: 'selection', selectedId: selectedId(), selectedIds: selectedIds(),
197
197
  subjects: selectedSubjects(), selectionOrigin, ...selectionState() });
198
- const actionResult = (requestId, ok, message = '') => send({ type: 'action-result', requestId, ok, message });
198
+ const actionResult = (requestId, ok, message = '', result = undefined) => send({ type: 'action-result', requestId, ok, message, ...(result === undefined ? {} : { result }) });
199
199
 
200
200
  const receive = (event) => {
201
201
  if (disposed || win.parent === win || event.source !== win.parent || event.origin !== origin) return;
@@ -252,6 +252,20 @@ gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksCha
252
252
  actionResult(data.requestId, ok, ok ? '' : 'Grid visibility could not be updated. Try again.');
253
253
  return;
254
254
  }
255
+ // #2255: an AI view command the main window claimed for this view. The editor checks the claimed target itself and
256
+ // answers with its report, which the main window passes to the server as it is (the server checks its shape).
257
+ if (data.action === 'view' && data.command && typeof data.command === 'object' && data.target && typeof data.target === 'object') {
258
+ // `ran: false`: the editor was never asked, so nothing changed. An editor that was asked and failed may have changed something.
259
+ if (lifecycle !== 'ready' || typeof view !== 'function') {
260
+ send({ type: 'action-result', requestId: data.requestId, ok: false, ran: false, message: 'This model view is not ready yet.' });
261
+ return;
262
+ }
263
+ let result = null;
264
+ try { result = view(data.command, data.target); }
265
+ catch (error) { try { win.console?.error?.('[model-panel] view action failed', error); } catch { /* reporting must still continue */ } }
266
+ actionResult(data.requestId, !!result, result ? '' : 'This model view could not apply the change.', result ?? undefined);
267
+ return;
268
+ }
255
269
  // The main window shows one of the snapshot's panelTabs (tab: its key) or has left them (tab: null). `person` is
256
270
  // true when a person chose it (a click on the tab), not the main window restoring or following the editor's reveal.
257
271
  // `follow` is the Follow selection switch, for a panel tab that declared `follows` (it re-arrives when the switch flips).