@floless/app 0.140.0 → 0.141.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.
@@ -32,6 +32,8 @@
32
32
  narrative: stack.querySelector('[data-left-section="narrative"]'),
33
33
  model: stack.querySelector('[data-left-section="model"]'),
34
34
  };
35
+ const approvalTray = document.getElementById('chat-approval-tray');
36
+ const chatShell = approvalTray?.closest('.ai-chat-shell');
35
37
  const switches = {
36
38
  narrative: pane.querySelector('[data-left-section-switch="narrative"]'),
37
39
  model: pane.querySelector('[data-left-section-switch="model"]'),
@@ -61,6 +63,7 @@
61
63
  const groupDisclosure = new Map();
62
64
  let dragKey = null;
63
65
  let splitSession = null;
66
+ let modelRequestedDuringApproval = false;
64
67
  let nextActionId = 0;
65
68
  let revealSequence = 0;
66
69
  let pendingRevealId = null;
@@ -101,6 +104,71 @@
101
104
 
102
105
  function available(key) { return key === 'narrative' || state.modelAvailable; }
103
106
  function shown(key) { return available(key) && (state.visible[key] || sessionVisible[key]); }
107
+ function approvalVisible() {
108
+ return !!approvalTray?.children.length && !approvalTray.closest('.ai-chat-shell')?.classList.contains('history-open');
109
+ }
110
+ function pendingDecisionVisible() {
111
+ return approvalVisible() && !!approvalTray.querySelector('.ai-chat-approval:not(.ai-chat-approval-scope)');
112
+ }
113
+ function compactApproval() {
114
+ return window.innerHeight <= 520 && approvalVisible() && shown('narrative') && shown('model');
115
+ }
116
+ function presented(key) { return shown(key) && !(key === 'model' && compactApproval() && !modelRequestedDuringApproval); }
117
+ function minimumNarrativeRatio() { return (290 + 5.5) / stack.clientHeight * 100; }
118
+ // The AI Chat section is never shorter than the rows of its chat that do not shrink (#1515): its
119
+ // heading and controls, the chat toolbar, the recovery and attachment rows and the composer. The
120
+ // conversation feed, the ⚙ strip and the approval tray are the rows that give height back — chat.css
121
+ // declares exactly those minmax(0, …), and chat-ui.test.ts holds this list to that template. Below
122
+ // this floor the composer would be pushed out through the host's overflow: hidden edge, leaving the
123
+ // panel with no message box at all. It is measured, not a constant: the composer grows with a long
124
+ // message, an attachment row can appear, and the disclosure wraps with the panel's width. Model
125
+ // yields height to it, down to Model's own minimum and never further: a window too short for both
126
+ // is a cue to hide one.
127
+ const CHAT_YIELDING_ROWS = [1, 2, 5];
128
+ // While the conversation area holds an empty-state card that carries an action (the Claude / Codex
129
+ // chooser, Sign in…, or the pending sign-in's "Sign-in window open"), the feed stops being a row that
130
+ // gives its height back: it must keep enough room for that action. chat.css hides the card outright
131
+ // at a feed of 44px or less (#1501), so at the default split on a 1280x720 window a new user saw no
132
+ // way to start a chat at all (#1554). 53px is one above chat.css's 52px tier — the single row of title
133
+ // plus action, whose tallest form is the chooser's at 48.25px — so the card keeps its title too.
134
+ // chat-ui.test.ts ties this number to that threshold. Once a conversation starts the card is gone and
135
+ // the feed yields again, so the person's own split comes back. The open ⚙ strip is deliberately not
136
+ // counted: it still takes its height from the feed first (#1501), so with it open the feed can be
137
+ // shorter than this. That strip is never open over the Claude / Codex chooser (chat.js closes it and
138
+ // disables ⚙ there), and when it is open over a sign-in card it carries that same Sign in… action itself.
139
+ const EMPTY_ACTION_FEED_PX = 53;
140
+ function emptyActionFeedReserve() {
141
+ const feed = chatShell?.querySelector('.ai-chat-feed');
142
+ if (!feed || chatShell.classList.contains('history-open')) return 0;
143
+ return Array.from(feed.children).some((child) => child.classList.contains('ai-chat-empty') && child.querySelector('button'))
144
+ ? EMPTY_ACTION_FEED_PX : 0;
145
+ }
146
+ function narrativeFloorRatio() {
147
+ const height = stack.clientHeight;
148
+ if (!(height > 0) || !chatShell || !presented('narrative') || !presented('model')) return 0;
149
+ const rows = window.getComputedStyle(chatShell).gridTemplateRows.split(' ').map(Number.parseFloat);
150
+ if (!rows.length || rows.some((row) => !Number.isFinite(row))) return 0;
151
+ const rigid = rows.reduce((sum, row, index) => sum + (CHAT_YIELDING_ROWS.includes(index) ? 0 : row), 0)
152
+ + emptyActionFeedReserve();
153
+ const around = sections.narrative.getBoundingClientRect().height - chatShell.getBoundingClientRect().height;
154
+ const modelMinimum = Number.parseFloat(window.getComputedStyle(sections.model).minHeight) || 0;
155
+ return Math.min((around + rigid + 5.5) / height * 100, 100 - (modelMinimum + 5.5) / height * 100);
156
+ }
157
+ // The split on screen: the saved ratio, moved only as far as the AI Chat floor needs. The saved value
158
+ // is left alone, so a taller window gives the person's own layout back.
159
+ function shownRatio(floor = narrativeFloorRatio()) {
160
+ return state.order[0] === 'narrative' ? Math.max(state.ratio, floor) : Math.min(state.ratio, 100 - floor);
161
+ }
162
+ function approvalSplitLocked(first) {
163
+ if (!presented('narrative') || !presented('model') || !approvalVisible()) return false;
164
+ if (pendingDecisionVisible()) return true;
165
+ // The ratio on screen, not the saved one: the AI Chat floor can already be showing enough room.
166
+ const onScreen = shownRatio();
167
+ const narrativeRatio = first === 'narrative' ? onScreen : 100 - onScreen;
168
+ // The clamp and lock must compare in the same units: recomputing pixel height at the
169
+ // exact boundary can round 290 to 289.99999999999994 and cancel an active drag.
170
+ return !!approvalTray.querySelector('.ai-chat-approval-scope') && narrativeRatio + 1e-9 < minimumNarrativeRatio();
171
+ }
104
172
  function commandInstance(value) { return encodeURIComponent(String(value)); }
105
173
 
106
174
  function applyChatIndicator(button) {
@@ -133,7 +201,7 @@
133
201
  button.dataset.commandId = `shell.left-section#${label}`;
134
202
  button.dataset.commandInstanceLabel = label;
135
203
  button.dataset.leftCollapsedSection = key;
136
- button.setAttribute('aria-pressed', String(shown(key)));
204
+ button.setAttribute('aria-pressed', String(presented(key)));
137
205
  button.setAttribute('aria-label', `Expand ${label}`);
138
206
  button.dataset.tip = `Expand ${label}`;
139
207
  button.textContent = label;
@@ -148,28 +216,54 @@
148
216
  }
149
217
 
150
218
  function reflect() {
151
- const both = shown('narrative') && shown('model');
219
+ const both = presented('narrative') && presented('model');
152
220
  const first = state.order[0];
221
+ const splitLocked = approvalSplitLocked(first);
222
+ if (splitLocked && splitSession) finishSplit(false);
223
+ if (!presented('model') && sections.model.contains(document.activeElement)) switches.model.focus({ preventScroll: true });
153
224
  split.hidden = !both;
154
- empty.hidden = shown('narrative') || shown('model');
225
+ split.setAttribute('aria-disabled', String(splitLocked));
226
+ split.tabIndex = splitLocked ? -1 : 0;
227
+ split.dataset.tip = splitLocked ? 'Resize is paused while approval needs space' : 'Drag or use arrow keys to resize · Enter or double-click to reset';
228
+ if (splitLocked) split.dataset.blockedReason = 'Resolve or leave this approval before resizing the panels.';
229
+ else delete split.dataset.blockedReason;
230
+ if (splitLocked && document.activeElement === split) switches.narrative.focus({ preventScroll: true });
231
+ empty.hidden = presented('narrative') || presented('model');
155
232
  pane.setAttribute('aria-label', state.modelAvailable ? 'AI Chat and Model panels' : 'AI Chat panel');
156
233
  for (const key of Object.keys(sections)) {
157
- const isShown = shown(key);
234
+ const isShown = presented(key);
158
235
  sections[key].hidden = !isShown;
159
236
  switches[key].hidden = !available(key);
160
237
  switches[key].setAttribute('aria-pressed', String(isShown));
238
+ if (key === 'model') switches.model.dataset.tip = compactApproval() && !modelRequestedDuringApproval
239
+ ? 'Show Model while approval waits' : 'Show or hide Model';
240
+ }
241
+ sizeSplit(both, first, splitLocked);
242
+ collapsedHost.replaceChildren(...state.order.filter(available).map(collapsedButton));
243
+ }
244
+
245
+ // Section heights and the separator's range. Also run on its own whenever the AI Chat floor can have
246
+ // moved (see the ResizeObserver at the end), which needs none of reflect()'s focus or button work.
247
+ function sizeSplit(both = presented('narrative') && presented('model'), first = state.order[0], splitLocked = approvalSplitLocked(first)) {
248
+ const floor = narrativeFloorRatio();
249
+ const ratio = shownRatio(floor);
250
+ for (const key of Object.keys(sections)) {
161
251
  sections[key].style.flex = both
162
- ? `0 0 calc(${key === first ? state.ratio : 100 - state.ratio}% - 5.5px)`
163
- : (isShown ? '1 1 auto' : '0 0 auto');
252
+ ? `0 0 calc(${key === first ? ratio : 100 - ratio}% - 5.5px)`
253
+ : (presented(key) ? '1 1 auto' : '0 0 auto');
164
254
  }
165
- if (both) {
166
- const topPercent = Math.round(state.ratio);
167
- split.setAttribute('aria-valuemin', '25');
168
- split.setAttribute('aria-valuemax', '75');
255
+ if (both && !splitLocked) {
256
+ const topPercent = Math.round(ratio);
257
+ const low = first === 'narrative' ? Math.max(25, floor) : Math.min(25, 100 - floor);
258
+ const high = first === 'narrative' ? Math.max(75, floor) : Math.min(75, 100 - floor);
259
+ split.setAttribute('aria-valuemin', String(Math.round(low)));
260
+ split.setAttribute('aria-valuemax', String(Math.round(high)));
169
261
  split.setAttribute('aria-valuenow', String(topPercent));
170
262
  split.setAttribute('aria-valuetext', `${topPercent}% for ${first === 'model' ? 'Model' : 'AI Chat'}`);
263
+ } else if (splitLocked) {
264
+ split.removeAttribute('aria-valuemin'); split.removeAttribute('aria-valuemax'); split.removeAttribute('aria-valuenow');
265
+ split.setAttribute('aria-valuetext', 'Temporarily held to show approval; saved split returns afterward');
171
266
  }
172
- collapsedHost.replaceChildren(...state.order.filter(available).map(collapsedButton));
173
267
  }
174
268
 
175
269
  function setVisible(key, value, announce = true) {
@@ -199,7 +293,14 @@
199
293
 
200
294
  pane.addEventListener('click', (event) => {
201
295
  const switcher = event.target.closest('[data-left-section-switch]');
202
- if (switcher) { const key = switcher.dataset.leftSectionSwitch; setVisible(key, !shown(key)); return; }
296
+ if (switcher) {
297
+ const key = switcher.dataset.leftSectionSwitch;
298
+ if (key === 'model' && compactApproval() && !modelRequestedDuringApproval) {
299
+ modelRequestedDuringApproval = true; reflect();
300
+ status.textContent = 'Model panel shown while approval waits.';
301
+ } else setVisible(key, !shown(key));
302
+ return;
303
+ }
203
304
  const close = event.target.closest('[data-left-section-close]');
204
305
  if (close) {
205
306
  const key = close.dataset.leftSectionClose;
@@ -209,7 +310,9 @@
209
310
  }
210
311
  const collapsed = event.target.closest('[data-left-collapsed-section]');
211
312
  if (collapsed) {
212
- setVisible(collapsed.dataset.leftCollapsedSection, true, false);
313
+ if (collapsed.dataset.leftCollapsedSection === 'model' && compactApproval() && !modelRequestedDuringApproval) {
314
+ modelRequestedDuringApproval = true; reflect();
315
+ } else setVisible(collapsed.dataset.leftCollapsedSection, true, false);
213
316
  document.querySelector('.pane-rail-left .panel-toggle[data-side="left"]')?.click();
214
317
  }
215
318
  });
@@ -245,7 +348,23 @@
245
348
  });
246
349
  });
247
350
 
248
- function setRatio(value) { state.ratio = Math.max(25, Math.min(75, value)); reflect(); }
351
+ function setRatio(value) {
352
+ let next = Math.max(25, Math.min(75, value));
353
+ if (approvalVisible() && !pendingDecisionVisible() && presented('narrative') && presented('model')
354
+ && approvalTray.querySelector('.ai-chat-approval-scope') && stack.clientHeight > 0) {
355
+ const minimum = minimumNarrativeRatio();
356
+ if (minimum > 75) return false; // the split cannot fit both sections at this height
357
+ next = state.order[0] === 'narrative' ? Math.max(next, minimum) : Math.min(next, 100 - minimum);
358
+ next = Math.max(25, Math.min(75, next));
359
+ }
360
+ // The divider stops where the AI Chat composer would start leaving its shell (#1515).
361
+ const floor = narrativeFloorRatio();
362
+ next = state.order[0] === 'narrative' ? Math.max(next, floor) : Math.min(next, 100 - floor);
363
+ // Compared with the divider on SCREEN: a press or drag the floor absorbs moves nothing, so it must
364
+ // not replace a saved split the floor is only covering for now (a taller window would bring it back).
365
+ if (next === shownRatio(floor)) return false;
366
+ state.ratio = next; reflect(); return true;
367
+ }
249
368
  function finishSplit(commit) {
250
369
  if (!splitSession) return;
251
370
  const session = splitSession;
@@ -254,10 +373,11 @@
254
373
  if (!commit) state.ratio = session.startRatio;
255
374
  try { if (!split.hasPointerCapture || split.hasPointerCapture(session.pointerId)) split.releasePointerCapture(session.pointerId); } catch { /* capture may already be gone */ }
256
375
  reflect();
257
- if (commit) save();
376
+ if (commit && state.ratio !== session.startRatio) save();
258
377
  }
259
378
  split.addEventListener('pointerdown', (event) => {
260
379
  if (event.button !== 0 || event.isPrimary === false) return;
380
+ if (split.getAttribute('aria-disabled') === 'true') return;
261
381
  if (splitSession) finishSplit(false);
262
382
  event.preventDefault(); split.focus();
263
383
  const rect = stack.getBoundingClientRect();
@@ -277,19 +397,22 @@
277
397
  window.addEventListener('blur', () => finishSplit(false));
278
398
  document.addEventListener('visibilitychange', () => { if (document.hidden) finishSplit(false); });
279
399
  split.addEventListener('dblclick', (event) => {
400
+ if (split.getAttribute('aria-disabled') === 'true') return;
280
401
  if (splitSession) { event.preventDefault(); return; }
281
- state.ratio = defaults.ratio; save(); reflect();
402
+ if (setRatio(defaults.ratio)) save();
282
403
  });
283
404
  window.addEventListener('keydown', (event) => {
284
405
  if (event.key === 'Escape' && splitSession) { event.preventDefault(); finishSplit(false); return; }
285
406
  if (event.target !== split) return;
407
+ if (split.getAttribute('aria-disabled') === 'true') { event.preventDefault(); return; }
286
408
  if (splitSession) {
287
409
  if (['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) event.preventDefault();
288
410
  return;
289
411
  }
290
- if (event.key === 'Enter') { event.preventDefault(); state.ratio = defaults.ratio; save(); reflect(); return; }
412
+ if (event.key === 'Enter') { event.preventDefault(); if (setRatio(defaults.ratio)) save(); return; }
291
413
  if (!['ArrowUp', 'ArrowDown'].includes(event.key)) return;
292
- event.preventDefault(); setRatio(state.ratio + (event.key === 'ArrowUp' ? -1 : 1) * (event.shiftKey ? 10 : 2)); save();
414
+ // Step from where the divider is shown, not from a saved ratio the AI Chat floor is overriding.
415
+ event.preventDefault(); if (setRatio(shownRatio() + (event.key === 'ArrowUp' ? -1 : 1) * (event.shiftKey ? 10 : 2))) save();
293
416
  });
294
417
 
295
418
  function renderNodes(nodes, host) {
@@ -632,5 +755,49 @@
632
755
  forgetModel(); hello();
633
756
  },
634
757
  });
758
+ if (approvalTray) new MutationObserver(() => {
759
+ if (!approvalTray.children.length) modelRequestedDuringApproval = false;
760
+ reflect();
761
+ }).observe(approvalTray, { childList: true });
762
+ if (chatShell) new MutationObserver(reflect).observe(chatShell, { attributes: true, attributeFilter: ['class'] });
763
+ // An empty-state card with an action arriving in, or leaving, the conversation area moves the floor
764
+ // (#1554). Its own size does not: the feed is sized by the split, so only the swap is watched, and
765
+ // re-sizing the split changes no child of the feed, so this cannot feed back into itself.
766
+ // A floor that moves can also start or end a Revoke approval's hold on the split; that needs
767
+ // reflect()'s focus, tooltip and blocked-reason work, not only new section heights.
768
+ const refitFloor = () => {
769
+ if (String(approvalSplitLocked(state.order[0])) !== split.getAttribute('aria-disabled')) reflect();
770
+ else sizeSplit();
771
+ };
772
+ const chatFeed = chatShell?.querySelector('.ai-chat-feed');
773
+ if (chatFeed) new MutationObserver(refitFloor).observe(chatFeed, { childList: true });
774
+ // The AI Chat floor moves with the chat's rows that do not shrink and with the stack's own height (the
775
+ // Instructor strip opening, not only a window resize), so the split is re-sized whenever the composer,
776
+ // the recovery or attachment row, or the stack changes size: a message growing to six lines at the
777
+ // minimum takes height from Model instead of pushing the composer out. None of these, nor the three
778
+ // below, is sized by the split, so re-sizing it cannot feed back into this. (Row 4 also holds the offscreen-activity
779
+ // badge, which follows the feed's height; chat.js only shows it with 88px of feed to spare, so it is
780
+ // counted but not watched, and the next re-size picks it up.)
781
+ if (chatShell && typeof window.ResizeObserver === 'function') {
782
+ const floorWatch = new window.ResizeObserver(refitFloor);
783
+ for (const id of ['chat-composer', 'chat-recovery', 'chat-attachments']) {
784
+ const row = document.getElementById(id);
785
+ if (row) floorWatch.observe(row);
786
+ }
787
+ // The chat toolbar and the section's own heading and controls are counted in the floor too (the
788
+ // toolbar as a rigid row, the other two as the height around the shell), and none of them is sized
789
+ // by the split. Unwatched, a change to one of them after the last fit left the floor stale: an
790
+ // independent QA run measured the conversation area 1.45px under its reserve, enough to drop the
791
+ // empty state's title (#1554).
792
+ for (const part of [chatShell.querySelector('.ai-chat-toolbar'), sections.narrative.querySelector('.left-section-heading'),
793
+ sections.narrative.querySelector('.ai-chat-controls')]) {
794
+ if (part) floorWatch.observe(part);
795
+ }
796
+ floorWatch.observe(stack);
797
+ }
798
+ window.addEventListener('resize', () => {
799
+ if (window.innerHeight > 520) modelRequestedDuringApproval = false;
800
+ reflect();
801
+ });
635
802
  arrange(); reflect();
636
803
  })();
@@ -17,6 +17,7 @@
17
17
  const selections = new Map();
18
18
  let scanController = null;
19
19
  let scanGeneration = 0;
20
+ let folderPending = false;
20
21
  let opener = null;
21
22
  let openedFromLibrary = false;
22
23
  let allFindings = [];
@@ -52,7 +53,9 @@
52
53
  }
53
54
  function setBusy(busy) {
54
55
  if (busy && document.activeElement === scanButton) closeButton.focus();
55
- chooseButton.disabled = busy;
56
+ // `|| folderPending` because a Remove ends the running scan before it sends its request, and
57
+ // that setBusy(false) would otherwise hand Add back in the middle of the folder change.
58
+ chooseButton.disabled = busy || folderPending;
56
59
  scanButton.disabled = busy;
57
60
  scanButton.textContent = busy ? 'Scanning…' : 'Scan this computer';
58
61
  scanButton.setAttribute('aria-busy', String(busy));
@@ -66,6 +69,39 @@
66
69
  errors.replaceChildren();
67
70
  errors.hidden = true;
68
71
  }
72
+ // Take the server's list of what the next scan will read. It is the only place that knows — it
73
+ // alone can ask the filesystem which directory a path is, and its list moves under this window
74
+ // when a lease runs out or a second window picks something. Returns whether anything changed here.
75
+ function takeFolders(folders) {
76
+ const before = [...selections.keys()];
77
+ selections.clear();
78
+ for (const folder of folders) selections.set(folder.id, folder.path);
79
+ paintFolders();
80
+ return before.length !== folders.length || before.some((id, at) => id !== folders[at].id);
81
+ }
82
+ /**
83
+ * Run ONE folder change at a time — an Add or a Remove.
84
+ *
85
+ * Two in flight can answer out of order, and each reply is a snapshot of the WHOLE list as the
86
+ * server had it when it handled that request. An older snapshot arriving last would put back a
87
+ * folder already released, and the next scan would then refuse it as expired. Discarding all but
88
+ * the newest REPLY does not fix that: the client cannot know which request the server applied
89
+ * last, only which it sent last. Never having two in flight does.
90
+ */
91
+ async function oneFolderChangeAtATime(run) {
92
+ if (folderPending) return;
93
+ folderPending = true;
94
+ const controls = () => [chooseButton, ...folderList.querySelectorAll('button')];
95
+ for (const control of controls()) control.disabled = true;
96
+ try { await run(); } finally {
97
+ folderPending = false;
98
+ // Re-read the controls: a reply repaints the rows, so these are not the buttons we disabled.
99
+ for (const control of controls()) control.disabled = false;
100
+ // Hand Add back to whoever it belongs to. setBusy keeps it disabled while a scan runs, and a
101
+ // scan can have started during this change, so restore that rather than assume it is free.
102
+ chooseButton.disabled = Boolean(scanController);
103
+ }
104
+ }
69
105
  function paintFolders() {
70
106
  folderList.replaceChildren();
71
107
  for (const [id, path] of selections) {
@@ -75,14 +111,23 @@
75
111
  remove.type = 'button';
76
112
  remove.dataset.commandId = 'shell.discovery-remove-folder';
77
113
  remove.setAttribute('aria-label', `Remove folder ${path}`);
78
- remove.addEventListener('click', () => {
114
+ remove.addEventListener('click', () => oneFolderChangeAtATime(async () => {
79
115
  ++scanGeneration;
80
116
  scanController?.abort();
81
117
  scanController = null;
82
118
  setBusy(false);
83
- selections.delete(id); paintFolders(); resetResults();
84
- status.textContent = 'Scope changed. Scan again to see current findings.';
85
- });
119
+ // Drop it on the SERVER, not just from this list: a row hidden here would still be a live
120
+ // selection, and the next pick would report it back as a folder the scan reads.
121
+ try {
122
+ const data = await post('/api/local-discovery/folders/release', { selectionId: id });
123
+ takeFolders(Array.isArray(data.folders) ? data.folders : []);
124
+ resetResults();
125
+ status.textContent = 'Scope changed. Scan again to see current findings.';
126
+ } catch (error) {
127
+ status.textContent = error.message
128
+ || 'FloLess could not remove this folder from the next scan. It is still listed — try Remove again.';
129
+ }
130
+ }));
86
131
  row.append(remove);
87
132
  folderList.append(row);
88
133
  }
@@ -211,20 +256,22 @@
211
256
  if (generation === scanGeneration) { scanController = null; setBusy(false); }
212
257
  }
213
258
  }
214
- chooseButton.addEventListener('click', async () => {
215
- chooseButton.disabled = true;
259
+ chooseButton.addEventListener('click', () => oneFolderChangeAtATime(async () => {
216
260
  try {
217
261
  const data = await post('/api/local-discovery/folders/choose', {});
218
- if (!data.cancelled && data.selectionId && data.path) {
219
- if (selections.size >= 3) selections.delete(selections.keys().next().value);
220
- selections.set(data.selectionId, data.path);
221
- paintFolders();
262
+ if (!data.cancelled && Array.isArray(data.folders)) {
263
+ if (!takeFolders(data.folders)) {
264
+ // The same selections in the same order: nothing changed for this window, so the findings
265
+ // below still describe what the next scan will read. Leave them alone.
266
+ status.textContent = 'This folder is already in the next scan. Nothing was added, and no scan has started.';
267
+ return;
268
+ }
269
+ // The scan reads something different now, so the findings below it are from the older scope.
222
270
  resetResults();
223
271
  status.textContent = 'Folder added to the next scan. Up to three selected folders can be included. No scan has started.';
224
272
  }
225
273
  } catch (error) { status.textContent = error.message || 'FloLess could not choose that folder. Try another local folder.'; }
226
- finally { chooseButton.disabled = false; }
227
- });
274
+ }));
228
275
  scanButton.addEventListener('click', scan);
229
276
  filterInput.addEventListener('input', () => { page = 0; paintPage(); });
230
277
  previousButton.addEventListener('click', () => { page = Math.max(0, page - 1); paintPage(); });
@@ -115,7 +115,7 @@
115
115
  #m3dAxes,.model-world-axes-host,.model-axis-triad-host{position:absolute;right:15px;bottom:12px;width:78px;height:78px;z-index:8;pointer-events:none;filter:drop-shadow(0 6px 14px rgba(0,0,0,.5))}
116
116
  .model-view-cube-host canvas,#m3dCube canvas,.model-world-axes-host canvas,.model-axis-triad-host canvas,#m3dAxes canvas{display:block;width:100%;height:100%}
117
117
  .model-view-cube-host canvas:focus-visible,#m3dCube canvas:focus-visible{outline:2px solid var(--brand,var(--accent,#60a5fa));outline-offset:3px;border-radius:8px}
118
- .model-orientation-status,.model-view-cube-status{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
118
+ .model-view-cube-status{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
119
119
 
120
120
  .model-clip-list{border-top:1px solid var(--line);margin-top:8px;padding-top:4px}.model-clip-list-header{height:30px;display:flex;align-items:center;gap:7px;padding:0 5px;color:var(--text)}.model-clip-list-header strong{font-size:11px;text-transform:uppercase;letter-spacing:.08em}.model-clip-count{min-width:18px;height:18px;display:grid;place-items:center;border-radius:9px;background:var(--btn);color:var(--muted);font-size:10px}.model-clip-enable-all{width:24px;min-width:24px;min-height:24px;padding:0;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-enable-all[data-state="on"]{color:var(--brand,#60a5fa)}.model-clip-enable-all[data-state="mixed"]{color:#64748b}.model-clip-clear{margin-left:auto}.model-clip-list-rows{display:grid;gap:2px}.model-clip-row{min-height:30px;display:grid;grid-template-columns:24px minmax(0,1fr) 24px;align-items:center;gap:4px;border-radius:5px;padding:2px 3px}.model-clip-row:hover,.model-clip-row.is-selected{background:var(--accent-soft)}.model-clip-row.is-selected{outline:1px solid color-mix(in srgb,var(--brand,#3b82f6) 58%,transparent)}.model-clip-row button{min-width:0;min-height:24px;padding:2px 5px;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-row button:hover{background:var(--btn-hover);color:var(--text)}.model-clip-enable{width:22px;border:1px solid var(--line)!important;color:var(--brand,#60a5fa)!important}.model-clip-enable[aria-pressed="false"]{color:transparent!important}.model-clip-label{text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)!important}.model-clip-remove{font-size:16px;line-height:1}.model-clip-rename{width:100%;min-width:0;height:25px;border:1px solid var(--brand,#3b82f6);border-radius:4px;background:var(--bg,#020817);color:var(--text);padding:2px 6px;font:inherit;outline:none}.model-clip-list-empty{padding:10px 7px 12px;color:var(--muted);font-size:11px;line-height:1.45}.model-clip-drag-readout{position:fixed;z-index:60;pointer-events:none;padding:5px 9px;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--text);box-shadow:0 3px 10px rgba(0,0,0,.45);font:11px var(--mono,monospace)}
121
121
 
@@ -130,7 +130,7 @@
130
130
  .model-inspector-toggle{position:absolute;right:calc(var(--panelw,240px) - 5px);top:50%;transform:translateY(-50%);z-index:12;width:11px;height:var(--grip-h,32px);min-width:0;min-height:0;padding:0;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--text-dim,var(--muted)) 60%,var(--btn-hover,#22324a));border:0;border-radius:5px;box-shadow:none;line-height:1;color:var(--text);transition:right .26s cubic-bezier(.2,.6,.2,1)}
131
131
  .model-inspector-toggle:hover{background:var(--brand,var(--accent,#60a5fa));color:#fff}
132
132
  .model-inspector-toggle svg{width:13px;height:13px;display:block;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;transition:transform .15s ease}
133
- .model-editor-shell.panel-layout,.editor-root.model-editor-shell{position:relative;grid-template-columns:minmax(0,1fr) 11px var(--panelw,240px) 0}
133
+ .editor-root.model-editor-shell{position:relative;grid-template-columns:minmax(0,1fr) 11px var(--panelw,240px) 0}
134
134
  body.panel-collapsed .model-inspector-resizer{pointer-events:none;cursor:default;width:0}
135
135
  body.panel-collapsed .model-inspector-panel{width:0!important;padding:0;overflow:hidden;border-left-width:0}
136
136
  body.panel-collapsed .model-inspector-stub{width:var(--pane-collapsed,36px)}
@@ -167,7 +167,7 @@ body:has(.model-inspector-resizer.drag) .model-inspector-panel,body:has(.model-i
167
167
  /* Shared model-space dimension and acquisition overlay. Providers supply points; this presentation,
168
168
  including witness lines, ticks, reticle and acquired-target readout, is identical in every module. */
169
169
  .measure-armed{cursor:crosshair}
170
- #modelDimensionOverlay,.model-dimension-overlay-host{position:absolute;inset:0;z-index:9;pointer-events:none}
170
+ #modelDimensionOverlay{position:absolute;inset:0;z-index:9;pointer-events:none}
171
171
  .model-dim-overlay{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
172
172
  .dimension-mark line,.dimension-preview line{stroke:#60a5fa;stroke-width:1.5;vector-effect:non-scaling-stroke}
173
173
  .dimension-preview line{stroke-dasharray:5 4;opacity:.82}
@@ -186,7 +186,7 @@ body:has(.model-inspector-resizer.drag) .model-inspector-panel,body:has(.model-i
186
186
  .model-dimension-editor>strong{font-size:12px;letter-spacing:.07em;text-transform:uppercase}
187
187
  .model-dimension-choice{display:grid;grid-template-columns:72px repeat(5,minmax(34px,1fr));gap:4px;align-items:center}
188
188
  .model-dimension-choice>span{color:var(--mut,var(--muted));font-size:10px;text-transform:uppercase}
189
- .model-dimension-choice button,.model-dimension-editor-actions button{min-height:28px;padding:3px 7px;background:var(--btn,var(--panel2));border:1px solid var(--line);border-radius:5px;color:var(--text);font:inherit}
189
+ .model-dimension-choice button,.model-dimension-editor-actions button{min-height:28px;padding:3px 7px;background:var(--btn,var(--panel-2,#172235));border:1px solid var(--line);border-radius:5px;color:var(--text);font:inherit}
190
190
  .model-dimension-choice button.on{background:var(--brand,var(--accent,#60a5fa));border-color:var(--brand,var(--accent,#60a5fa));color:#0f172a}
191
191
  .model-dimension-choice button:focus-visible,.model-dimension-editor-actions button:focus-visible{outline:2px solid var(--brand,var(--accent,#60a5fa));outline-offset:1px}
192
192
  .model-dimension-editor-actions{display:flex;justify-content:flex-end;gap:6px;padding-top:2px}
@@ -81,3 +81,66 @@ export function revitPropertyEncodingLabel(row) {
81
81
  // V1 snapshots predate the explicit discriminator and are source-semantic by contract.
82
82
  return row?.storageType ? `Source ${row.storageType}` : 'Imported value';
83
83
  }
84
+
85
+ /**
86
+ * The revision the editor opens first: the working draft, else the approved model, else none.
87
+ * None is an ordinary state (a project whose RVT is importing, never finished importing, or was
88
+ * never added), so the caller renders an empty state instead of treating it as a failure (#1522).
89
+ */
90
+ export function revitInitialAuthority(state) {
91
+ if (state?.draft) return 'draft';
92
+ if (state?.approved) return 'approved';
93
+ return null;
94
+ }
95
+
96
+ /**
97
+ * Plain-English copy for a Revit project with no model to show. Returns null when the project is
98
+ * not in a known no-model state: it has a revision, or it records a published source with no
99
+ * revision behind it, which is inconsistent and must stay a loud failure, not a calm message.
100
+ * Nothing in the editor refreshes on its own, so no copy may promise that the view will update.
101
+ */
102
+ export function revitNoModelCopy(state) {
103
+ if (!state || revitInitialAuthority(state)) return null;
104
+ const pending = typeof state.pendingSource?.filename === 'string' && state.pendingSource.filename.trim()
105
+ ? state.pendingSource.filename : null;
106
+ if (pending && state.importing === true) {
107
+ return {
108
+ kind: 'importing', title: 'Your model is still importing',
109
+ body: `FloLess is converting ${pending} into a model you can view. When the import finishes, open the Model tab again to see it.`,
110
+ };
111
+ }
112
+ // Not running covers a failed or cancelled import and the moment before one is recorded, so the
113
+ // copy claims only what is certain: no model has been made from this RVT yet.
114
+ if (pending) {
115
+ return {
116
+ kind: 'import-unfinished', title: 'No model from this RVT yet',
117
+ body: `${pending} was added to this project, but no model has been made from it yet. Open the Source tab to see how its import went, then try the import again or choose another RVT if it did not finish.`,
118
+ };
119
+ }
120
+ if (state.source) return null;
121
+ return {
122
+ kind: 'no-source', title: 'No Revit model yet',
123
+ body: 'This project has no RVT file yet. Add one on the Source tab; once it is imported, the model opens here.',
124
+ };
125
+ }
126
+
127
+ const SVG_NS = 'http://www.w3.org/2000/svg';
128
+ /**
129
+ * Render the no-model state into the viewport's status overlay: a muted outline cube, a title and
130
+ * the explanation, with no spinner, because nothing is loading here.
131
+ */
132
+ export function renderRevitNoModelState(host, copy, doc = host.ownerDocument) {
133
+ host.replaceChildren();
134
+ host.dataset.state = copy.kind;
135
+ host.setAttribute('role', 'status');
136
+ host.classList.add('viewport-state-empty');
137
+ const icon = doc.createElementNS(SVG_NS, 'svg');
138
+ icon.setAttribute('viewBox', '0 0 24 24'); icon.setAttribute('aria-hidden', 'true'); icon.setAttribute('class', 'viewport-state-icon');
139
+ for (const d of ['M12 3 20 7.5v9L12 21l-8-4.5v-9L12 3Z', 'M4 7.5 12 12l8-4.5', 'M12 12v9']) {
140
+ const path = doc.createElementNS(SVG_NS, 'path'); path.setAttribute('d', d); icon.append(path);
141
+ }
142
+ const title = doc.createElement('strong'); title.textContent = copy.title;
143
+ const body = doc.createElement('span'); body.textContent = copy.body;
144
+ host.append(icon, title, body);
145
+ host.style.display = 'flex';
146
+ }
@@ -0,0 +1,79 @@
1
+ /* ──────────────────────────────────────────────────────────────────────────
2
+ Esc from inside a page the shell shows in its full-window overlay (#1571).
3
+
4
+ The shell's editor overlay (#contract-editor in index.html) hosts one of
5
+ these pages in an iframe. A keydown inside an iframe never reaches the
6
+ shell's own document, so without this Esc could close the overlay only
7
+ while focus sat on the overlay's own bar — and a user who has just been
8
+ working in the editor has focus in here.
9
+
10
+ The rule is a LADDER whose last rung is "close": Esc is the page's first.
11
+ It cancels a tool, closes a menu or modal, drops a pick, clears the
12
+ selection — and only an Esc that NOTHING in the page used goes up to the
13
+ shell, which closes the overlay through the same path as its Close button
14
+ (so the Drawing Filter's unsaved-changes question still asks).
15
+
16
+ "Nothing used it" is read from the event, not re-derived here:
17
+ • a handler that consumed it and stopped propagation never lets it reach
18
+ the window-level listener below, and
19
+ • a handler that consumed it and let it bubble calls preventDefault(),
20
+ which is the page's contract for "this Esc was mine". The read happens
21
+ in a macrotask, after the WHOLE dispatch, so a window listener bound
22
+ after this one (the 3D view binds its own inside init()) is heard too.
23
+ A page whose Esc handlers act without either (the steel editor's own
24
+ ladder) marks them with OverlayEscape.markUsed(e) instead — a mark only
25
+ this forwarder reads. preventDefault() would be read by the page's OTHER
26
+ listeners too (the 3D view skips a prevented key), so it would change what
27
+ that Esc does inside the page; markUsed changes nothing but this.
28
+
29
+ Esc while typing into a text field never closes the overlay: there, Esc
30
+ belongs to the field (revert the value, leave the field), even when the
31
+ field has no handler of its own.
32
+
33
+ The shell decides whether the overlay is open and whether THIS window is the
34
+ one it is showing — the same page embedded anywhere else (a workspace step)
35
+ gets `false` back and nothing happens.
36
+ ────────────────────────────────────────────────────────────────────────── */
37
+ (function () {
38
+ 'use strict';
39
+
40
+ function typingInto(t) {
41
+ if (!t) return false;
42
+ if (t.isContentEditable) return true;
43
+ if (t.tagName === 'TEXTAREA' || t.tagName === 'SELECT') return true;
44
+ if (t.tagName !== 'INPUT') return false;
45
+ // A checkbox, radio, button or range has no text to revert: Esc on one is not "typing".
46
+ return !/^(checkbox|radio|button|submit|reset|range|color|file|image)$/i.test(t.type || '');
47
+ }
48
+
49
+ /**
50
+ * @param {object} [opts]
51
+ * @param {function} [opts.idle] page-local veto, read after the dispatch: return false while the page
52
+ * has something Esc should act on that its handlers do not mark. Must not throw
53
+ * on a half-torn-down page (a throw counts as "not idle").
54
+ */
55
+ // Esc events a page handler used without preventDefault(). Weak, so a mark never outlives its event.
56
+ var used = typeof WeakSet === 'function' ? new WeakSet() : null;
57
+ function markUsed(e) { if (used && e && typeof e === 'object') used.add(e); }
58
+
59
+ function mount(opts) {
60
+ var idle = opts && typeof opts.idle === 'function' ? opts.idle : null;
61
+ function onKey(e) {
62
+ if (e.key !== 'Escape' || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.isComposing || e.repeat) return;
63
+ if (e.defaultPrevented || typingInto(e.target)) return;
64
+ setTimeout(function () {
65
+ if (e.defaultPrevented || (used && used.has(e))) return;
66
+ if (idle) { var ok = false; try { ok = idle() === true; } catch (err) { ok = false; } if (!ok) return; }
67
+ try {
68
+ if (window.parent && window.parent !== window && typeof window.parent.__floOverlayEscape === 'function') {
69
+ window.parent.__floOverlayEscape(window);
70
+ }
71
+ } catch (err) { /* cross-origin or torn-down parent */ }
72
+ }, 0);
73
+ }
74
+ window.addEventListener('keydown', onKey);
75
+ return { dispose: function () { window.removeEventListener('keydown', onKey); } };
76
+ }
77
+
78
+ window.OverlayEscape = { mount: mount, markUsed: markUsed, typingInto: typingInto };
79
+ })();
@@ -30,6 +30,13 @@ body.model-panel-host{display:flex;flex-direction:column;background:var(--panel)
30
30
  .model-selection-filter-flyout{position:fixed;z-index:95;width:286px;max-height:min(430px,60vh);display:flex;flex-direction:column;padding:8px;background:var(--panel);border:1px solid var(--line-strong);border-radius:8px;box-shadow:var(--shadow)}.model-filter-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:7px}.model-filter-actions{display:flex;gap:4px}.model-filter-actions button{min-height:25px;padding:2px 7px;font-size:10px}.model-selection-filter-flyout>input{width:100%;min-height:31px;padding:5px 8px;color:var(--text);background:var(--bg);border:1px solid var(--line);border-radius:6px;font:inherit}.model-selection-filter-flyout>input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.model-filter-list{min-height:44px;margin-top:7px;overflow:auto;border-top:1px solid var(--line);padding-top:5px}.model-filter-option{display:flex;align-items:center;gap:5px;min-height:29px;padding:4px 5px;border-radius:5px;cursor:pointer}.model-filter-option:hover{background:var(--accent-soft)}.model-filter-option span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;unicode-bidi:plaintext}
31
31
  .model-spatial-dialog{position:fixed;z-index:96;width:min(360px,calc(100vw - 24px));max-height:min(520px,75vh);display:flex;flex-direction:column;gap:8px;padding:11px;background:var(--panel);border:1px solid var(--line-strong);border-radius:9px;box-shadow:var(--shadow)}.model-spatial-dialog-header{display:flex;align-items:center;justify-content:space-between;gap:8px}.model-spatial-dialog input{width:100%;min-height:32px;padding:6px 8px;color:var(--text);background:var(--bg);border:1px solid var(--line);border-radius:6px;font:inherit}.model-spatial-dialog input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.model-spatial-dialog-actions{display:flex;justify-content:flex-end;gap:5px}.model-saved-view-list{display:grid;gap:4px;overflow:auto;min-height:42px;border-top:1px solid var(--line);padding-top:7px}.model-saved-view-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:5px}.model-saved-view-row>button:first-child{text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.model-dialog-note{color:var(--muted);font-size:11px}
32
32
  .viewport-state{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:7px;text-align:center;background:rgba(8,13,24,.72);z-index:20}.viewport-state span:last-child{color:var(--muted)}.state-spinner{width:24px;height:24px;border:2px solid var(--line);border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}
33
+ /* No revision to open yet (#1522): the viewport keeps its scrim and says why, and the model-only chrome steps aside. */
34
+ .viewport-state-empty{gap:6px;padding:24px}.viewport-state-empty .viewport-state-icon{width:32px;height:32px;margin-bottom:6px;fill:none;stroke:var(--muted);stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.viewport-state-empty strong{font-size:14px;font-weight:600;color:var(--text)}.viewport-state-empty span{max-width:42ch;color:var(--muted)}
35
+ .editor-root[data-model-state="empty"].model-editor-shell,.editor-root[data-model-state="empty"]{grid-template-columns:minmax(0,1fr)}
36
+ /* Hidden by position, not by name: everything beside the viewport (the Properties column) and everything in it but the
37
+ status. The shared chrome stays styled only by model-editor.css (model-editor-shell.test.ts). */
38
+ .editor-root[data-model-state="empty"]>:not(.model-stage),.editor-root[data-model-state="empty"]>.model-stage>:not(#loadingState){display:none}
39
+ body:has(.editor-root[data-model-state="empty"]) .read-only-chip{display:none}
33
40
  #toast{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);padding:8px 12px;border:1px solid var(--line);border-radius:7px;background:var(--panel);box-shadow:var(--shadow);opacity:0;pointer-events:none;z-index:90;transition:opacity .15s}#toast.show{opacity:1}
34
41
  #tooltip{position:fixed;z-index:100;background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:5px 8px;font-size:11.5px;line-height:1.35;color:var(--text);pointer-events:none;max-width:260px;box-shadow:var(--shadow-tip);opacity:0;transition:opacity .12s}#tooltip.show{opacity:1}
35
42
  @media(max-width:820px){:root{--panelw:280px}.authority-kicker,.source-name{display:none}}