@floless/app 0.157.0 → 0.158.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.
@@ -0,0 +1,353 @@
1
+ /**
2
+ * The run viewer's view of a report that carries files (`report_folder`, #2262 slice 3c; follow-up #2476).
3
+ *
4
+ * Such a report refers to its pictures and files as `assets/…`, which resolve only inside its saved Page version. While
5
+ * that version is being saved the viewer shows the report's inert copy (the server made it; this file never touches a
6
+ * report's HTML) with a plain note, then switches to the version's own isolated frame once that frame says it is ready.
7
+ * What it says at every moment comes from the SERVER's answer about this exact run — never a guess:
8
+ *
9
+ * pending inert copy, "Saving this report…" (after 90 s: "Still saving…"); polled every 10 s, never an endless spinner
10
+ * saved with files: the Page version's frame, once it posts `floless-page-ready` for THIS navigation;
11
+ * without files: inert copy and the stored reason
12
+ * failed inert copy and the server's words
13
+ * none provisional for 30 s after the report arrived (a sender that could not queue first), then terminal
14
+ * frame did not become ready within 20 s, or reported itself unavailable: inert copy and "could not be shown here"
15
+ *
16
+ * Ordering: every answer and every piece of news carries `rev` and the server process's `epoch`. A state applies only if
17
+ * its `rev` is higher than the one held in the same epoch; a new epoch (FloLess restarted) resets what is held and
18
+ * reconciles from a new lookup. Only the newest lookup's answer may apply, and a new epoch invalidates every older one.
19
+ * One paint GENERATION fences every asynchronous step: a later paint, close, or workspace switch makes them do nothing.
20
+ *
21
+ * Loaded as a classic script before aware.js; tested by server/run-page-view-ui.test.ts with a fake clock.
22
+ */
23
+ (function (root) {
24
+ 'use strict';
25
+
26
+ var READY_WAIT_MS = 20000;
27
+ var POLL_MS = 10000;
28
+ var STILL_SAVING_MS = 90000;
29
+ var NONE_PROVISIONAL_MS = 30000;
30
+ var LOOKUP_TIMEOUT_MS = 15000;
31
+ var NEWS_KEPT = 64;
32
+
33
+ var NOTES = {
34
+ pending: 'Saving this report with its pictures and files to the workflow’s Page. It switches to that version when it is saved.',
35
+ still: 'Still saving this report to the workflow’s Page — large files take longer. It switches by itself when it is saved.',
36
+ opening: 'Opening the saved version of this report with its pictures and files…',
37
+ none: 'No saved version of this run was found on the workflow’s Page, so its pictures and files cannot be shown here. Run the workflow again to save it.',
38
+ frame: 'The saved version could not be shown here. Use Open in Pages to see it with its pictures and files.',
39
+ links: 'This report has links or content that open only in Pages. Use Open in Pages.',
40
+ };
41
+ var WITHHELD_NEXT = 'Run the workflow again to save them with it; if this keeps happening, ask AI Chat to check the workflow’s report folder.';
42
+ var FAILED_TAIL = 'Its pictures and files are not shown here.';
43
+ var PAGE_REQUESTS = ['floless-page-open', 'floless-page-link-unsupported', 'floless-page-blocked'];
44
+
45
+ function sentence(text) {
46
+ var t = String(text || '').trim();
47
+ return t && !/[.!?]$/.test(t) ? t + '.' : t;
48
+ }
49
+
50
+ function create(env) {
51
+ var win = env.win || root;
52
+ var now = env.now || function () { return Date.now(); };
53
+ var setTimer = env.setTimeout || function (fn, ms) { return root.setTimeout(fn, ms); };
54
+ var clearTimer = env.clearTimeout || function (id) { root.clearTimeout(id); };
55
+ var token = env.token || function () {
56
+ var bytes = new Uint8Array(16);
57
+ root.crypto.getRandomValues(bytes);
58
+ var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-';
59
+ var out = '';
60
+ for (var i = 0; i < 16; i += 1) out += alphabet.charAt(bytes[i] % 64);
61
+ return out;
62
+ };
63
+ var inert = env.inert;
64
+ var page = env.page;
65
+ var noteEl = env.note;
66
+
67
+ var gen = 0;
68
+ var view = null;
69
+ var news = new Map(); // "app\nrun\nfire" → newest answer heard (any window state)
70
+
71
+ function nkey(app, runId, fire) { return app + '\n' + runId + '\n' + (fire || ''); }
72
+
73
+ function setNote(text) {
74
+ if (!noteEl) return;
75
+ noteEl.hidden = !text;
76
+ noteEl.textContent = text || '';
77
+ }
78
+
79
+ function clearTimers(v) {
80
+ if (!v) return;
81
+ [v.pollTimer, v.stillTimer, v.readyTimer].forEach(function (t) { if (t != null) clearTimer(t); });
82
+ v.pollTimer = v.stillTimer = v.readyTimer = null;
83
+ }
84
+
85
+ function blankPageFrame() {
86
+ page.hidden = true;
87
+ if (page.hasAttribute('src')) {
88
+ // Navigate away first so a hidden document stops running, then drop the address.
89
+ page.setAttribute('src', 'about:blank');
90
+ page.removeAttribute('src');
91
+ }
92
+ }
93
+
94
+ /** Whatever was on screen is over: every pending step does nothing, the Page frame is empty, the inert copy is back. */
95
+ function invalidate() {
96
+ gen += 1;
97
+ clearTimers(view);
98
+ view = null;
99
+ blankPageFrame();
100
+ if (inert) inert.hidden = false;
101
+ setNote('');
102
+ }
103
+
104
+ function reset() {
105
+ invalidate();
106
+ news.clear();
107
+ }
108
+
109
+ /** Has this step been overtaken (another paint, a close, a workspace switch, another workflow)? */
110
+ function stale(v, g) { return v !== view || v.gen !== g || gen !== g || env.currentApp() !== v.app; }
111
+
112
+ // ── applying what the server says ──────────────────────────────────────────────────────────────────────
113
+
114
+ function normalise(raw) {
115
+ if (!raw || typeof raw !== 'object') return null;
116
+ if (['pending', 'saved', 'failed', 'none'].indexOf(raw.state) < 0) return null;
117
+ if (!Number.isInteger(raw.rev) || typeof raw.epoch !== 'string' || !raw.epoch) return null;
118
+ return {
119
+ state: raw.state, rev: raw.rev, epoch: raw.epoch,
120
+ version: Number.isInteger(raw.version) ? raw.version : null,
121
+ files: Number.isInteger(raw.files) ? raw.files : null,
122
+ filesWithheld: typeof raw.filesWithheld === 'string' ? raw.filesWithheld : '',
123
+ reason: typeof raw.reason === 'string' ? raw.reason : '',
124
+ frameUrl: typeof raw.frameUrl === 'string' && raw.frameUrl.charAt(0) === '/' && raw.frameUrl.indexOf('//') !== 0 ? raw.frameUrl : '',
125
+ };
126
+ }
127
+
128
+ /** `workflow-page-captured` news → the same shape as a lookup answer (or null when it says nothing about a capture). */
129
+ function fromNews(m) {
130
+ if (!m || typeof m.app !== 'string' || typeof m.runId !== 'string' || !m.runId) return null;
131
+ if (typeof m.warning === 'string') return normalise({ state: 'failed', rev: m.rev, epoch: m.epoch, reason: m.warning });
132
+ if (Number.isInteger(m.version) && m.version >= 1) {
133
+ return normalise({ state: 'saved', rev: m.rev, epoch: m.epoch, version: m.version, files: m.files, filesWithheld: m.filesWithheld });
134
+ }
135
+ return null;
136
+ }
137
+
138
+ function noteNews(key, a) {
139
+ var prev = news.get(key);
140
+ if (prev && prev.epoch === a.epoch && prev.rev >= a.rev) return;
141
+ news.delete(key);
142
+ news.set(key, a);
143
+ if (news.size > NEWS_KEPT) news.delete(news.keys().next().value);
144
+ }
145
+
146
+ /** The ordering gate. Returns true when `a` was applied. */
147
+ function apply(v, a, fromNewsItem) {
148
+ if (v.sticky) return false;
149
+ var h = v.held;
150
+ if (h.epoch !== null && a.epoch !== h.epoch) {
151
+ // FloLess restarted (or an answer from another process): what was held no longer orders anything, and every
152
+ // lookup still out was asked of the old process.
153
+ h.epoch = null; h.rev = 0; h.answer = null;
154
+ if (fromNewsItem) startLookup(v); // a new lookup supersedes (and so invalidates) every one still out
155
+ }
156
+ if (h.epoch === null) h.epoch = a.epoch;
157
+ var before = h.answer;
158
+ if (a.rev < h.rev) return false;
159
+ if (before && a.rev === h.rev && a.state !== before.state) return false;
160
+ var sameRev = !!before && a.rev === h.rev;
161
+ h.rev = a.rev;
162
+ // An answer of the same state at the same rev only ever adds (a lookup brings the frame address the news lacks).
163
+ h.answer = sameRev
164
+ ? { state: a.state, rev: a.rev, epoch: a.epoch, version: a.version != null ? a.version : before.version,
165
+ files: a.files != null ? a.files : before.files, filesWithheld: a.filesWithheld || before.filesWithheld,
166
+ reason: a.reason || before.reason, frameUrl: a.frameUrl || before.frameUrl }
167
+ : a;
168
+ render(v);
169
+ return true;
170
+ }
171
+
172
+ function pendingNote(v) { return now() - v.startedAt >= STILL_SAVING_MS ? NOTES.still : NOTES.pending; }
173
+
174
+ function render(v) {
175
+ if (v.sticky || v.shown) return;
176
+ var a = v.held.answer;
177
+ if (!a || a.state === 'pending') { setNote(pendingNote(v)); ensurePoll(v); return; }
178
+ if (a.state === 'none') {
179
+ if (now() - v.startedAt < NONE_PROVISIONAL_MS) { setNote(pendingNote(v)); ensurePoll(v); return; }
180
+ setNote(NOTES.none); stopPoll(v); return;
181
+ }
182
+ if (a.state === 'failed') {
183
+ setNote(a.reason ? sentence(a.reason) + ' ' + FAILED_TAIL : 'This report could not be saved to the workflow’s Page. ' + FAILED_TAIL);
184
+ stopPoll(v); return;
185
+ }
186
+ // saved
187
+ if (a.files > 0) {
188
+ // It IS saved (never "saving"). One 20 s deadline covers finding its frame's address AND the frame saying it is
189
+ // ready, however many answers or redraws come in between; past it the viewer says so and points to Pages.
190
+ setNote(NOTES.opening);
191
+ startOpeningDeadline(v);
192
+ if (a.frameUrl) { stopPoll(v); showVersion(v, a); return; }
193
+ // Asked once straight away (a lookup already out may predate the save, and a new one supersedes it); after that the
194
+ // poll keeps asking, so repeated news or redraws never add lookups.
195
+ if (!v.addressAsked) { v.addressAsked = true; startLookup(v); }
196
+ ensurePoll(v);
197
+ return;
198
+ }
199
+ stopPoll(v);
200
+ // What happened, why, and what to do next (#2476 review: the reason alone left the person without a way forward).
201
+ setNote((a.filesWithheld
202
+ ? 'Saved to the workflow’s Page without its pictures and files: ' + a.filesWithheld.replace(/[.\s]+$/, '') + '.'
203
+ : 'Saved to the workflow’s Page without its pictures and files.') + ' ' + WITHHELD_NEXT);
204
+ }
205
+
206
+ function stopPoll(v) { if (v.pollTimer != null) { clearTimer(v.pollTimer); v.pollTimer = null; } }
207
+
208
+ function ensurePoll(v) {
209
+ if (v.pollTimer != null || v.sticky || v.shown) return;
210
+ var g = v.gen;
211
+ v.pollTimer = setTimer(function () {
212
+ v.pollTimer = null;
213
+ if (stale(v, g)) return;
214
+ startLookup(v);
215
+ }, POLL_MS);
216
+ }
217
+
218
+ // ── asking the server ──────────────────────────────────────────────────────────────────────────────────
219
+
220
+ function startLookup(v) {
221
+ var g = v.gen;
222
+ var seq = (v.lookupSeq += 1);
223
+ v.lookupBusy = true;
224
+ var url = '/api/pages/workflow?app=' + encodeURIComponent(v.app) + '&run=' + encodeURIComponent(v.runId)
225
+ + (v.fire ? '&fire=' + encodeURIComponent(v.fire) : '');
226
+ var asking;
227
+ try { asking = Promise.resolve(env.api(url, { timeoutMs: LOOKUP_TIMEOUT_MS })); } catch (e) { asking = Promise.reject(e); }
228
+ asking.then(function (body) {
229
+ if (stale(v, g) || v.lookupSeq !== seq) return;
230
+ v.lookupBusy = false;
231
+ var a = normalise(body && body.run);
232
+ if (!a) { if (!v.held.answer || v.held.answer.state !== 'saved') ensurePoll(v); return; }
233
+ if (a.state === 'saved' && a.version != null && body && typeof body.home === 'string' && body.page && typeof body.page.id === 'string') {
234
+ try { env.onSaved({ app: v.app, runId: v.runId, fire: v.fire, home: body.home, pageId: body.page.id, version: a.version }); }
235
+ catch (e) { /* the header link is a convenience; the frame below does not depend on it */ }
236
+ }
237
+ apply(v, a, false);
238
+ }).catch(function () {
239
+ if (stale(v, g)) return;
240
+ if (v.lookupSeq === seq) v.lookupBusy = false;
241
+ // The question could not be answered (offline, slow): keep what is shown and ask again while it matters.
242
+ var a = v.held.answer;
243
+ if (!a || a.state === 'pending' || a.state === 'none' || (a.state === 'saved' && a.files > 0 && !a.frameUrl)) ensurePoll(v);
244
+ });
245
+ }
246
+
247
+ // ── the Page version's frame ───────────────────────────────────────────────────────────────────────────
248
+
249
+ /** Started once, when the version is known saved with files; never restarted by later answers or the frame's load. */
250
+ function startOpeningDeadline(v) {
251
+ if (v.readyTimer != null) return;
252
+ var g = v.gen;
253
+ v.readyTimer = setTimer(function () {
254
+ v.readyTimer = null;
255
+ // Only while it is still "saved with files, not yet shown": a newer answer (failed, saved without files) keeps its own note.
256
+ var a = v.held.answer;
257
+ if (!stale(v, g) && !v.shown && a && a.state === 'saved' && a.files > 0) fallback(v);
258
+ }, READY_WAIT_MS);
259
+ }
260
+
261
+ function showVersion(v, a) {
262
+ if (v.navUrl === a.frameUrl) return;
263
+ v.navUrl = a.frameUrl;
264
+ var nav = token();
265
+ v.nav = { token: nav };
266
+ startOpeningDeadline(v);
267
+ page.hidden = true;
268
+ page.setAttribute('src', a.frameUrl + '?nav=' + nav);
269
+ }
270
+
271
+ function fallback(v) {
272
+ if (v.readyTimer != null) { clearTimer(v.readyTimer); v.readyTimer = null; }
273
+ v.sticky = true;
274
+ v.shown = false;
275
+ v.nav = null;
276
+ stopPoll(v);
277
+ blankPageFrame();
278
+ if (inert) inert.hidden = false;
279
+ setNote(NOTES.frame);
280
+ }
281
+
282
+ function becameReady(v) {
283
+ if (v.readyTimer != null) { clearTimer(v.readyTimer); v.readyTimer = null; }
284
+ v.shown = true;
285
+ stopPoll(v);
286
+ if (v.stillTimer != null) { clearTimer(v.stillTimer); v.stillTimer = null; }
287
+ page.hidden = false;
288
+ if (inert) inert.hidden = true;
289
+ setNote('');
290
+ }
291
+
292
+ function onMessage(event) {
293
+ var v = view;
294
+ if (!v || !page || event.source !== page.contentWindow || !event.source) return;
295
+ var d = event.data;
296
+ if (!d || typeof d.type !== 'string') return;
297
+ if (d.type === 'floless-page-ready' || d.type === 'floless-page-unavailable') {
298
+ // Only the CURRENT navigation of the CURRENT paint: a message queued by an earlier document carries its token.
299
+ if (!v.nav || d.nav !== v.nav.token || stale(v, v.gen)) return;
300
+ if (d.type === 'floless-page-ready') becameReady(v); else fallback(v);
301
+ return;
302
+ }
303
+ if (PAGE_REQUESTS.indexOf(d.type) >= 0 && v.shown && !v.linksNoted) {
304
+ // A link ask or a blocked site needs the Pages screen's consent step; this view does not host it.
305
+ v.linksNoted = true;
306
+ setNote(NOTES.links);
307
+ }
308
+ }
309
+ win.addEventListener('message', onMessage);
310
+
311
+ // ── the entry points aware.js calls ────────────────────────────────────────────────────────────────────
312
+
313
+ /** Show a report that carries files. `entry`: { runId, captureKey?, fireKey? } of the report on screen. */
314
+ function paint(entry) {
315
+ invalidate();
316
+ var app = env.currentApp();
317
+ var runId = entry && typeof entry.runId === 'string' && entry.runId ? entry.runId : null;
318
+ var fire = entry && typeof entry.fireKey === 'string' && entry.fireKey ? entry.fireKey : null;
319
+ if (!fire && entry && typeof entry.captureKey === 'string' && entry.captureKey.indexOf('#') > 0) {
320
+ fire = entry.captureKey.slice(entry.captureKey.indexOf('#') + 1) || null;
321
+ runId = runId || entry.captureKey.slice(0, entry.captureKey.indexOf('#'));
322
+ }
323
+ if (inert) inert.hidden = false;
324
+ if (!app || !runId) { setNote(NOTES.none); return; }
325
+ var v = view = {
326
+ gen: gen, app: app, runId: runId, fire: fire, nk: nkey(app, runId, fire), startedAt: now(),
327
+ held: { epoch: null, rev: 0, answer: null }, lookupSeq: 0, lookupBusy: false, addressAsked: false,
328
+ pollTimer: null, stillTimer: null, readyTimer: null, nav: null, navUrl: '', sticky: false, shown: false, linksNoted: false,
329
+ };
330
+ var g = v.gen;
331
+ // The "still saving" wording takes over by itself, with no news needed.
332
+ v.stillTimer = setTimer(function () { v.stillTimer = null; if (!stale(v, g)) render(v); }, STILL_SAVING_MS);
333
+ var heard = news.get(v.nk);
334
+ if (heard) apply(v, heard, false); else render(v);
335
+ if (!v.lookupBusy) startLookup(v);
336
+ }
337
+
338
+ /** `workflow-page-captured` news from the server. */
339
+ function onNews(m) {
340
+ var a = fromNews(m);
341
+ if (!a) return;
342
+ var key = nkey(m.app, m.runId, typeof m.fireKey === 'string' ? m.fireKey : '');
343
+ noteNews(key, a);
344
+ if (view && view.nk === key && env.currentApp() === view.app && view.gen === gen) apply(view, a, true);
345
+ }
346
+
347
+ return { paint: paint, invalidate: invalidate, reset: reset, onNews: onNews,
348
+ /** For tests and diagnostics: what the view holds. */
349
+ inspect: function () { return view && { gen: view.gen, state: view.held.answer && view.held.answer.state, epoch: view.held.epoch, rev: view.held.rev, shown: view.shown, sticky: view.sticky, lookupSeq: view.lookupSeq }; } };
350
+ }
351
+
352
+ root.FlolessRunPageView = { create: create, NOTES: NOTES, READY_WAIT_MS: READY_WAIT_MS, POLL_MS: POLL_MS, STILL_SAVING_MS: STILL_SAVING_MS, NONE_PROVISIONAL_MS: NONE_PROVISIONAL_MS };
353
+ })(typeof window !== 'undefined' ? window : globalThis);
@@ -3585,14 +3585,15 @@ const EditorFocus = (() => {
3585
3585
  Promise.resolve().then(() => runner(job.req, current)).then(
3586
3586
  (outcome) => vacate(job, current() && outcome ? outcome : { superseded: true }),
3587
3587
  // The runner shows its own sentences; this is only the last line of defence, so the caller is never left waiting.
3588
- (error) => { console.error('[steel] could not show the connection asked for', error); vacate(job, current() ? { ok: false, said: 'The model could not show connection ' + job.req.jointId + '. Press Open in the model again, or find it in the Model panel.' } : { superseded: true }); });
3588
+ (error) => { console.error('[steel] could not show the connection asked for', error); vacate(job, current() ? { ok: false, said: job.req.memberId ? 'The model could not show member ' + job.req.memberId + '. Press Show in the model again, or find it in the Model panel.' : 'The model could not show connection ' + job.req.jointId + '. Press Open in the model again, or find it in the Model panel.' } : { superseded: true }); });
3589
3589
  };
3590
3590
  window.flolessEditorState = { project: PROJECT, ready: false };
3591
3591
  const text = (value) => typeof value === 'string' && value ? value : '';
3592
3592
  // #2450: a request may also ask to raise an RFI, and name the check to show first.
3593
+ // #2471: or name one member (an AI Chat answer's cited member) instead of a connection.
3593
3594
  const normalise = (req) => req && text(req.jointId)
3594
3595
  ? { jointId: req.jointId, ...(req.raiseRfi === true ? { raiseRfi: true } : {}), ...(text(req.checkId) ? { checkId: req.checkId } : {}) }
3595
- : null;
3596
+ : req && text(req.memberId) ? { memberId: req.memberId } : null;
3596
3597
  window.flolessEditorFocus = (req) => {
3597
3598
  if (!normalise(req)) return false;
3598
3599
  const id = typeof req.requestId === 'string' && req.requestId ? req.requestId : 'editor-' + (++made);
@@ -26261,6 +26262,19 @@ const EDITOR_FOCUS_3D_WAIT_MS=20000;
26261
26262
  async function runEditorFocus(req,current){
26262
26263
  const until=Date.now()+EDITOR_FOCUS_3D_WAIT_MS;
26263
26264
  while(!window.Steel3DView&&Date.now()<until){await new Promise(resolve=>setTimeout(resolve,100));if(!current())return null;}
26265
+ // #2471: a member an answer cited. The shell checked the project is the cited one; this frame shows that project.
26266
+ if(req.memberId){
26267
+ const m=await focusMember(req.memberId,{current,
26268
+ beforeSelect:()=>rfiFormFor?'An RFI form is open. Finish or cancel it, then press Show in the model again.':'',
26269
+ beforeFrame:()=>{if(rfiOpen())closeRFI();}});
26270
+ if(!m||!current())return null;
26271
+ if(!m.ok){
26272
+ const said=m.reason==='missing'?m.said+' Ask about it again in the chat.':m.reason==='view'?m.said+' Switch to the 3D view, then press Show in the model again.':m.said;
26273
+ toast(said,false,9000);
26274
+ return {ok:false,reason:m.reason,said};
26275
+ }
26276
+ return {ok:true};
26277
+ }
26264
26278
  const r=await focusConnection(req.jointId,{current,fallbackToMain:true,
26265
26279
  beforeSelect:()=>rfiFormFor?'An RFI form is open. Finish or cancel it, then press Open in the model again.':'',
26266
26280
  beforeFrame:()=>{if(rfiOpen())closeRFI();}});
@@ -26291,7 +26305,7 @@ EditorFocus.setRunner(async(req,current)=>{
26291
26305
  catch(error){
26292
26306
  console.error('[steel] could not show the connection asked for',error);
26293
26307
  if(!current())return null;
26294
- const said='The model could not show connection '+req.jointId+'. Press Open in the model again, or find it in the Model panel.';
26308
+ const said=req.memberId?'The model could not show member '+req.memberId+'. Press Show in the model again, or find it in the Model panel.':'The model could not show connection '+req.jointId+'. Press Open in the model again, or find it in the Model panel.';
26295
26309
  toast(said,false,9000);
26296
26310
  return {ok:false,said};
26297
26311
  }
@@ -26380,6 +26394,31 @@ async function focusConnection(jointId,opts){
26380
26394
  if(modelEditor.dispatch('model.fit-selection')===false)return {ok:false,reason:'frame',said:'Connection '+jointId+' is selected, but it is hidden in the 3D view. Use Show all in the Visibility menu, then press Open in the model again.'};
26381
26395
  return {ok:true};
26382
26396
  }
26397
+ // #2471: one member, selected and framed in the 3D view — an AI Chat answer's "Show in the model" for a member it cited.
26398
+ // The connection fallback's own sequence (cmpMember): leave any connection selection, select the member, frame it.
26399
+ async function focusMember(memberId,opts){
26400
+ const o=opts||{},current=o.current||(()=>true);
26401
+ if(!(C.members||[]).some(m=>m&&m.id===memberId))return {ok:false,reason:'missing',said:'Member '+memberId+' is no longer in the model.'};
26402
+ let ready=await requestView3d();
26403
+ if(!current())return null;
26404
+ // Opened from another step, the editor restores its own last view at the same moment and that supersedes this request,
26405
+ // although 3D comes up anyway: give it a few seconds to settle before saying it could not show the member.
26406
+ for(const until=Date.now()+5000;!ready&&Date.now()<until;){
26407
+ await new Promise(resolve=>setTimeout(resolve,100));
26408
+ if(!current())return null;
26409
+ ready=!!window.Steel3DView&&viewMode==='3d'&&!viewTransition;
26410
+ }
26411
+ const busy=o.beforeSelect?o.beforeSelect():'';
26412
+ if(busy)return {ok:false,reason:'busy',said:busy};
26413
+ if(!ready||!window.Steel3DView)return {ok:false,reason:'view',said:'The 3D view could not show member '+memberId+'.'};
26414
+ if(!selIdOK(memberId))return {ok:false,reason:'filter',said:'Member '+memberId+' is excluded by the selection filter. Turn on that member type under Select, then try again.'};
26415
+ if(modelEditor.isReady()&&modelEditor.steel.clearConnSel)modelEditor.steel.clearConnSel();
26416
+ modelSelection.replaceMembers([memberId]);selDimIds.clear();sel3dDimIds.clear();modelSelection.clearGrids();render();
26417
+ if(!selIds.has(memberId))return {ok:false,reason:'select',said:'The 3D view could not select member '+memberId+'.'};
26418
+ if(o.beforeFrame)o.beforeFrame();
26419
+ if(modelEditor.dispatch('model.fit-selection')===false)return {ok:false,reason:'frame',said:'Member '+memberId+' is selected, but it is hidden in the 3D view. Use Show all in the Visibility menu, then press Show in the model again.'};
26420
+ return {ok:true};
26421
+ }
26383
26422
  async function rfiOpenTarget(button){
26384
26423
  const tuple=JSON.parse(button.dataset.rfiTarget),held=rfiCurrentTarget(tuple);
26385
26424
  const localErrorKey=Number.isSafeInteger(tuple[3])?rfiOccurrenceKey(tuple[0],tuple[3]):null;