@floless/app 0.152.0 → 0.153.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.
@@ -23,13 +23,14 @@
23
23
  const empty = document.getElementById('left-pane-empty');
24
24
  const modelContext = document.getElementById('left-model-context');
25
25
  const modelIndexHeader = document.getElementById('left-model-index-header');
26
+ const layoutToggle = document.getElementById('left-layout-toggle');
26
27
  // A PANEL tab's slot (web/model-panel-bridge.js has the contract): the editor moves its own controls into
27
28
  // this frame. It is replaced by a fresh, empty one whenever the generation changes, so a departing editor's
28
29
  // controls leave with it. No src: the frame's first about:blank document is this origin and stays put.
29
30
  const panelSlot = document.getElementById('left-model-panel-slot');
30
31
  let panelFrame = document.getElementById('left-model-panel');
31
32
  if (!frame || !pane || !stack || !split || !status || !modelTabs || !modelSearch || !modelSearchInput || !modelSearchClear || !modelIndexLabel || !followSelection || !modelContent || !collapsedHost || !empty || !modelContext
32
- || !modelIndexHeader || !panelSlot || !panelFrame) return;
33
+ || !modelIndexHeader || !panelSlot || !panelFrame || !layoutToggle) return;
33
34
 
34
35
  const sections = {
35
36
  narrative: stack.querySelector('[data-left-section="narrative"]'),
@@ -41,7 +42,9 @@
41
42
  narrative: pane.querySelector('[data-left-section-switch="narrative"]'),
42
43
  model: pane.querySelector('[data-left-section-switch="model"]'),
43
44
  };
44
- const defaults = { order: ['narrative', 'model'], visible: { narrative: true, model: true }, ratio: 58, tab: 'model', followSelection: true };
45
+ const defaults = { order: ['narrative', 'model'], visible: { narrative: true, model: true }, ratio: 58, columnRatio: 50, tab: 'model', followSelection: true };
46
+ const LABELS = { narrative: 'AI Chat', model: 'Model' };
47
+ const otherOf = (key) => (key === 'model' ? 'narrative' : 'model');
45
48
  let stored = {};
46
49
  try { stored = JSON.parse(localStorage.getItem(STORAGE_KEY) || '{}'); } catch { /* a locked-down profile still gets the pane */ }
47
50
  const validOrder = Array.isArray(stored.order) && stored.order.length === 2
@@ -53,6 +56,9 @@
53
56
  model: stored.visible?.model !== false,
54
57
  },
55
58
  ratio: Number.isFinite(stored.ratio) ? Math.max(25, Math.min(75, stored.ratio)) : defaults.ratio,
59
+ // 'columns' puts AI Chat and Model side by side; anything else read back is the stacked default.
60
+ layout: stored.layout === 'columns' ? 'columns' : 'stack',
61
+ columnRatio: Number.isFinite(stored.columnRatio) ? Math.max(25, Math.min(75, stored.columnRatio)) : defaults.columnRatio,
56
62
  tab: typeof stored.tab === 'string' ? stored.tab : defaults.tab,
57
63
  followSelection: typeof stored.followSelection === 'boolean' ? stored.followSelection : defaults.followSelection,
58
64
  modelAvailable: false,
@@ -92,7 +98,7 @@
92
98
  }
93
99
 
94
100
  function save() {
95
- try { localStorage.setItem(STORAGE_KEY, JSON.stringify({ order: state.order, visible: state.visible, ratio: state.ratio, tab: state.tab, followSelection: state.followSelection })); }
101
+ try { localStorage.setItem(STORAGE_KEY, JSON.stringify({ order: state.order, visible: state.visible, ratio: state.ratio, layout: state.layout, columnRatio: state.columnRatio, tab: state.tab, followSelection: state.followSelection })); }
96
102
  catch (error) { console.warn('[left-pane] Could not save panel layout.', error); }
97
103
  }
98
104
 
@@ -134,10 +140,27 @@
134
140
  function pendingDecisionVisible() {
135
141
  return approvalVisible() && !!approvalTray.querySelector('.ai-chat-approval:not(.ai-chat-approval-scope)');
136
142
  }
143
+ // Side by side needs the window to give the pane two columns and still leave the canvas room
144
+ // (web/app.js owns that width). Without the room the saved choice stays, and the panels stack
145
+ // until there is room again.
146
+ let layoutApiMissing = false;
147
+ const layoutApiReady = () => typeof window.flolessPanelLayout?.canFitLeftColumns === 'function';
148
+ function columnsFit() {
149
+ const api = window.flolessPanelLayout;
150
+ if (!layoutApiReady()) {
151
+ // Without the shell's width side there is no room to promise: stacked is the safe layout.
152
+ if (!layoutApiMissing) { layoutApiMissing = true; console.warn('[left-pane] The panel width controls did not load, so side by side is unavailable.'); }
153
+ return false;
154
+ }
155
+ return api.canFitLeftColumns() === true;
156
+ }
157
+ function columnsWanted() { return state.layout === 'columns' && columnsFit(); }
158
+ // Side by side, each section has the full height, so none of the stacked height rules below apply.
137
159
  function compactApproval() {
138
- return window.innerHeight <= 520 && approvalVisible() && shown('narrative') && shown('model');
160
+ return !columnsWanted() && window.innerHeight <= 520 && approvalVisible() && shown('narrative') && shown('model');
139
161
  }
140
162
  function presented(key) { return shown(key) && !(key === 'model' && compactApproval() && !modelRequestedDuringApproval); }
163
+ function sideBySide() { return columnsWanted() && presented('narrative') && presented('model'); }
141
164
  function minimumNarrativeRatio() { return (290 + 5.5) / stack.clientHeight * 100; }
142
165
  // The AI Chat section is never shorter than the rows of its chat that do not shrink (#1515): its
143
166
  // heading and controls, the chat toolbar, the recovery and attachment rows and the composer. The
@@ -169,7 +192,7 @@
169
192
  }
170
193
  function narrativeFloorRatio() {
171
194
  const height = stack.clientHeight;
172
- if (!(height > 0) || !chatShell || !presented('narrative') || !presented('model')) return 0;
195
+ if (!(height > 0) || !chatShell || !presented('narrative') || !presented('model') || sideBySide()) return 0;
173
196
  const rows = window.getComputedStyle(chatShell).gridTemplateRows.split(' ').map(Number.parseFloat);
174
197
  if (!rows.length || rows.some((row) => !Number.isFinite(row))) return 0;
175
198
  const rigid = rows.reduce((sum, row, index) => sum + (CHAT_YIELDING_ROWS.includes(index) ? 0 : row), 0)
@@ -193,6 +216,8 @@
193
216
  // exact boundary can round 290 to 289.99999999999994 and cancel an active drag.
194
217
  return !!approvalTray.querySelector('.ai-chat-approval-scope') && narrativeRatio + 1e-9 < minimumNarrativeRatio();
195
218
  }
219
+ // The approval hold is about HEIGHT: side by side, AI Chat has the pane's full height and nothing is held.
220
+ function splitLockedNow() { return !sideBySide() && approvalSplitLocked(state.order[0]); }
196
221
  function commandInstance(value) { return encodeURIComponent(String(value)); }
197
222
 
198
223
  function applyChatIndicator(button) {
@@ -269,13 +294,19 @@
269
294
  announceSelection();
270
295
  const both = presented('narrative') && presented('model');
271
296
  const first = state.order[0];
272
- const splitLocked = approvalSplitLocked(first);
273
- if (splitLocked && splitSession) finishSplit(false);
297
+ const columns = sideBySide();
298
+ const splitLocked = !columns && approvalSplitLocked(first);
299
+ if (splitSession && (splitLocked || splitSession.columns !== columns)) finishSplit(false);
300
+ stack.classList.toggle('left-pane-columns', columns);
301
+ window.flolessPanelLayout?.setLeftColumns?.(columns);
302
+ split.setAttribute('aria-orientation', columns ? 'vertical' : 'horizontal');
303
+ reflectLayoutToggle(both);
274
304
  if (!presented('model') && sections.model.contains(document.activeElement)) switches.model.focus({ preventScroll: true });
275
305
  split.hidden = !both;
276
306
  split.setAttribute('aria-disabled', String(splitLocked));
277
307
  split.tabIndex = splitLocked ? -1 : 0;
278
- split.dataset.tip = splitLocked ? 'Resize is paused while approval needs space' : 'Drag or use arrow keys to resize · Enter or double-click to reset';
308
+ split.dataset.tip = splitLocked ? 'Resize is paused while approval needs space'
309
+ : `Drag or use arrow keys to resize ${columns ? 'the columns' : 'the panels'} · Enter or double-click to reset`;
279
310
  if (splitLocked) split.dataset.blockedReason = 'Resolve or leave this approval before resizing the panels.';
280
311
  else delete split.dataset.blockedReason;
281
312
  if (splitLocked && document.activeElement === split) switches.narrative.focus({ preventScroll: true });
@@ -289,13 +320,24 @@
289
320
  if (key === 'model') switches.model.dataset.tip = compactApproval() && !modelRequestedDuringApproval
290
321
  ? 'Show Model while approval waits' : 'Show or hide Model';
291
322
  }
292
- sizeSplit(both, first, splitLocked);
323
+ sizeSplit(both, first, splitLocked, columns);
293
324
  collapsedHost.replaceChildren(...state.order.filter(available).map(collapsedButton));
294
325
  }
295
326
 
296
327
  // Section heights and the separator's range. Also run on its own whenever the AI Chat floor can have
297
328
  // moved (see the ResizeObserver at the end), which needs none of reflect()'s focus or button work.
298
- function sizeSplit(both = presented('narrative') && presented('model'), first = state.order[0], splitLocked = approvalSplitLocked(first)) {
329
+ function sizeSplit(both = presented('narrative') && presented('model'), first = state.order[0], splitLocked = splitLockedNow(), columns = sideBySide()) {
330
+ if (columns) {
331
+ // Side by side: the divider shares the pane's WIDTH. A column never goes under its CSS minimum,
332
+ // so each flex basis may shrink to make room for the other.
333
+ const ratio = shownColumnRatio();
334
+ const [low, high] = columnBounds();
335
+ for (const key of Object.keys(sections)) sections[key].style.flex = `1 1 calc(${key === first ? ratio : 100 - ratio}% - 5.5px)`;
336
+ split.setAttribute('aria-valuemin', String(Math.round(low))); split.setAttribute('aria-valuemax', String(Math.round(high)));
337
+ split.setAttribute('aria-valuenow', String(Math.round(ratio)));
338
+ split.setAttribute('aria-valuetext', `${Math.round(ratio)}% of the width for ${LABELS[first]}`);
339
+ return;
340
+ }
299
341
  const floor = narrativeFloorRatio();
300
342
  const ratio = shownRatio(floor);
301
343
  for (const key of Object.keys(sections)) {
@@ -326,21 +368,73 @@
326
368
  if (key === 'model' && value && pendingRevealId) revealSelectedEntity();
327
369
  }
328
370
 
329
- function move(key, delta, announce = true) {
330
- // A panel move also rewrites the ratio so each section keeps its physical
331
- // height. Do not let it sample the temporary ratio from an unfinished
371
+ // The layout switch in the toolbar: pressed while side by side is the saved choice. It only means
372
+ // something with both panels open, so it is hidden otherwise rather than shown disabled.
373
+ function reflectLayoutToggle(both) {
374
+ const wanted = state.layout === 'columns';
375
+ layoutToggle.hidden = !both;
376
+ const fit = columnsFit();
377
+ // Pressed is the saved choice; the label says when the window is holding it back, so neither
378
+ // claims columns that are not on screen.
379
+ layoutToggle.setAttribute('aria-pressed', String(wanted));
380
+ const ready = layoutApiReady();
381
+ layoutToggle.setAttribute('aria-label', wanted && !fit ? (ready ? 'Side by side, waiting for a wider window' : 'Side by side, not available right now') : 'Side by side');
382
+ layoutToggle.dataset.tip = fit ? (wanted ? 'Stack AI Chat and Model' : 'Place AI Chat and Model side by side')
383
+ : !ready ? 'Side by side is not available right now · reload FloLess to try again'
384
+ : wanted ? 'Side by side needs a wider window, so the panels are stacked for now · click to keep them stacked'
385
+ : 'Side by side needs a wider window · click to keep it for when there is room';
386
+ }
387
+ // What to say when side by side cannot be shown: only the remedies that would actually work now.
388
+ function noRoomMessage() {
389
+ if (!layoutApiReady()) return 'Side by side is not available right now because the panel width controls did not load, so AI Chat and Model stay stacked. Reload FloLess to try again.';
390
+ // Folding Inspect is offered only while it is open AND folding it would actually make the room.
391
+ const foldHelps = !document.getElementById('app')?.classList.contains('right-collapsed')
392
+ && window.flolessPanelLayout.canFitLeftColumns({ inspectFolded: true }) === true;
393
+ return `Side by side needs a wider window, so AI Chat and Model stay stacked for now. ${foldHelps
394
+ ? 'Widen the window or fold the Inspect panel, and they move side by side.' : 'Widen the window, and they move side by side.'}`;
395
+ }
396
+ // Said where a sighted person looks too: the click changed nothing they can see.
397
+ function tellNoRoom() { const message = noRoomMessage(); status.textContent = message; window.showToast?.(message, 'info'); }
398
+
399
+ // Puts one panel above, below, left of or right of the other; left or right is side by side.
400
+ function place(key, where, announce = true) {
401
+ // A panel move also rewrites the ratios so each section keeps its physical
402
+ // size. Do not let it sample the temporary ratio from an unfinished
332
403
  // splitter gesture; Escape must still be able to restore one coherent state.
333
- if (splitSession) return;
334
- const from = state.order.indexOf(key);
335
- const to = Math.max(0, Math.min(state.order.length - 1, from + delta));
336
- if (from < 0 || from === to) return;
337
- state.order.splice(from, 1); state.order.splice(to, 0, key);
338
- state.ratio = 100 - state.ratio;
339
- save(); arrange(); reflect();
340
- if (panelShown !== null) { panelShown = null; renderModel(); } // the move re-created the panel frame's document
341
- if (announce) status.textContent = `${key === 'model' ? 'Model' : 'AI Chat'} panel moved ${to === 0 ? 'above' : 'below'} ${state.order[1 - to] === 'model' ? 'Model' : 'AI Chat'}.`;
404
+ if (splitSession || !sections[key]) return;
405
+ const other = otherOf(key);
406
+ const columns = where === 'left' || where === 'right';
407
+ if (columns && !(shown(key) && shown(other))) {
408
+ if (announce) {
409
+ const message = `${LABELS[other]} is hidden. Show it with the ${LABELS[other].toUpperCase()} switch above, then place the panels side by side.`;
410
+ status.textContent = message; window.showToast?.(message, 'info');
411
+ }
412
+ return;
413
+ }
414
+ const order = where === 'above' || where === 'left' ? [key, other] : [other, key];
415
+ const reordered = order[0] !== state.order[0];
416
+ const layout = columns ? 'columns' : 'stack';
417
+ if (!reordered && layout === state.layout) return;
418
+ if (reordered) { state.order = order; state.ratio = 100 - state.ratio; state.columnRatio = 100 - state.columnRatio; arrange(); }
419
+ state.layout = layout;
420
+ save(); reflect();
421
+ if (reordered && panelShown !== null) { panelShown = null; renderModel(); } // the move re-created the panel frame's document
422
+ if (announce) {
423
+ if (columns && !columnsFit()) tellNoRoom();
424
+ else status.textContent = columns
425
+ ? `${LABELS[key]} panel moved ${where} of ${LABELS[other]}, side by side.`
426
+ : `${LABELS[key]} panel moved ${where} ${LABELS[other]}.`;
427
+ }
342
428
  pane.querySelector(`[data-left-reorder="${key}"]`)?.focus();
343
429
  }
430
+ function setLayout(layout) {
431
+ if (splitSession || layout === state.layout) return;
432
+ state.layout = layout;
433
+ save(); reflect();
434
+ if (layout === 'columns' && !columnsFit()) tellNoRoom();
435
+ else status.textContent = layout === 'columns' ? 'AI Chat and Model placed side by side.' : 'AI Chat and Model stacked.';
436
+ }
437
+ layoutToggle.addEventListener('click', () => setLayout(state.layout === 'columns' ? 'stack' : 'columns'));
344
438
 
345
439
  pane.addEventListener('click', (event) => {
346
440
  const switcher = event.target.closest('[data-left-section-switch]');
@@ -370,8 +464,9 @@
370
464
 
371
465
  pane.addEventListener('keydown', (event) => {
372
466
  const grip = event.target.closest('[data-left-reorder]');
373
- if (grip && event.altKey && ['ArrowUp', 'ArrowDown'].includes(event.key)) {
374
- event.preventDefault(); move(grip.dataset.leftReorder, event.key === 'ArrowUp' ? -1 : 1); return;
467
+ const where = { ArrowUp: 'above', ArrowDown: 'below', ArrowLeft: 'left', ArrowRight: 'right' }[event.key];
468
+ if (grip && event.altKey && where) {
469
+ event.preventDefault(); place(grip.dataset.leftReorder, where); return;
375
470
  }
376
471
  const sectionSwitch = event.target.closest('[data-left-section-switch]');
377
472
  if (!sectionSwitch || !['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
@@ -382,23 +477,120 @@
382
477
  event.preventDefault(); live[next]?.focus();
383
478
  });
384
479
  document.addEventListener('floless:chat-indicator', syncChatIndicator);
385
- pane.querySelectorAll('[data-left-reorder]').forEach((grip) => {
386
- grip.addEventListener('dragstart', (event) => {
387
- if (splitSession) { event.preventDefault(); return; }
388
- dragKey = grip.dataset.leftReorder; event.dataTransfer.effectAllowed = 'move'; event.dataTransfer.setData('text/plain', dragKey);
480
+ // A panel is dragged by its whole header (the ⠿ grip inside it is the keyboard carrier). Dropped on
481
+ // the other panel it stacks above or below it, by the half it lands on; dropped on the strip that
482
+ // opens over the canvas beside the pane it docks as a second column, side by side. The custom data
483
+ // type keeps the drag out of text fields: the AI Chat composer must not receive the word "model".
484
+ const DRAG_TYPE = 'application/x-floless-left-section';
485
+ const dockZone = document.createElement('div');
486
+ dockZone.className = 'left-dock-zone'; dockZone.hidden = true; dockZone.setAttribute('aria-hidden', 'true');
487
+ const dockTitle = document.createElement('strong'); dockTitle.textContent = 'Place side by side';
488
+ const dockNote = document.createElement('span');
489
+ dockZone.append(dockTitle, dockNote);
490
+ document.body.append(dockZone);
491
+ function clearDropMarks() {
492
+ pane.querySelectorAll('.drag-over').forEach((el) => el.classList.remove('drag-over', 'drag-over-top', 'drag-over-bottom'));
493
+ dockZone.classList.remove('drag-over');
494
+ }
495
+ function endSectionDrag() {
496
+ dragKey = null; clearDropMarks();
497
+ dockZone.hidden = true; document.body.classList.remove('left-pane-section-dragging');
498
+ }
499
+ // The strip opens beside the pane, about a column wide, unless the dragged panel already is the
500
+ // right-hand column (dropping there would change nothing).
501
+ function openDockZone(key) {
502
+ if (!presented(otherOf(key)) || (sideBySide() && state.order[1] === key)) return;
503
+ const rect = pane.getBoundingClientRect();
504
+ const room = (window.innerWidth || 0) - rect.right;
505
+ if (!(rect.height > 0) || room < 120) return;
506
+ dockNote.textContent = columnsFit() ? `Drop to dock ${LABELS[key]} as a second column`
507
+ : 'Needs a wider window · drop to keep this choice; the panels stay stacked until there is room';
508
+ Object.assign(dockZone.style, { left: `${rect.right + 8}px`, top: `${rect.top + 8}px`, height: `${rect.height - 16}px`, width: `${Math.min(340, room - 24)}px` });
509
+ dockZone.hidden = false;
510
+ }
511
+ pane.querySelectorAll('[data-left-drag]').forEach((heading) => {
512
+ // The × inside the header is a button, not a handle. A browser fires dragstart on the draggable
513
+ // header itself, never on the button the press began on, so the press is what is remembered.
514
+ let pressedOnClose = false;
515
+ heading.addEventListener('pointerdown', (event) => { pressedOnClose = !!event.target.closest?.('.left-section-close'); });
516
+ heading.addEventListener('dragstart', (event) => {
517
+ const fromClose = pressedOnClose || !!event.target.closest?.('.left-section-close');
518
+ pressedOnClose = false;
519
+ if (splitSession || fromClose) { event.preventDefault(); return; }
520
+ dragKey = heading.dataset.leftDrag;
521
+ event.dataTransfer.effectAllowed = 'move'; event.dataTransfer.setData(DRAG_TYPE, dragKey);
522
+ // Workspace frames would swallow the drag over the canvas, so they stop taking the pointer meanwhile.
523
+ document.body.classList.add('left-pane-section-dragging');
524
+ openDockZone(dragKey);
389
525
  });
390
- grip.addEventListener('dragend', () => { dragKey = null; pane.querySelectorAll('.drag-over').forEach((el) => el.classList.remove('drag-over')); });
526
+ heading.addEventListener('dragend', endSectionDrag);
391
527
  });
392
528
  pane.querySelectorAll('[data-left-section]').forEach((section) => {
393
- section.addEventListener('dragover', (event) => { if (!dragKey || dragKey === section.dataset.leftSection) return; event.preventDefault(); section.classList.add('drag-over'); });
394
- section.addEventListener('dragleave', () => section.classList.remove('drag-over'));
529
+ // The upper or lower half of the panel under the pointer. Without a usable position the dragged
530
+ // panel takes the target's place, as dropping onto a panel always did.
531
+ const landing = (event) => {
532
+ const rect = section.getBoundingClientRect();
533
+ if (!Number.isFinite(event.clientY) || !(rect.height > 0)) {
534
+ return state.order.indexOf(section.dataset.leftSection) === 0 ? 'above' : 'below';
535
+ }
536
+ return event.clientY < rect.top + rect.height / 2 ? 'above' : 'below';
537
+ };
538
+ section.addEventListener('dragover', (event) => {
539
+ if (!dragKey || dragKey === section.dataset.leftSection) return;
540
+ event.preventDefault();
541
+ if (event.dataTransfer) event.dataTransfer.dropEffect = 'move';
542
+ const where = landing(event);
543
+ section.classList.add('drag-over');
544
+ section.classList.toggle('drag-over-top', where === 'above'); section.classList.toggle('drag-over-bottom', where === 'below');
545
+ });
546
+ section.addEventListener('dragleave', (event) => {
547
+ if (event.relatedTarget && section.contains(event.relatedTarget)) return;
548
+ section.classList.remove('drag-over', 'drag-over-top', 'drag-over-bottom');
549
+ });
395
550
  section.addEventListener('drop', (event) => {
396
- event.preventDefault(); section.classList.remove('drag-over');
397
- const target = section.dataset.leftSection;
398
- if (dragKey && dragKey !== target) move(dragKey, state.order.indexOf(target) - state.order.indexOf(dragKey));
551
+ if (!dragKey) return;
552
+ event.preventDefault();
553
+ const key = dragKey, target = section.dataset.leftSection, where = landing(event);
554
+ endSectionDrag();
555
+ if (key !== target) place(key, where);
399
556
  });
400
557
  });
558
+ dockZone.addEventListener('dragover', (event) => {
559
+ if (!dragKey) return;
560
+ event.preventDefault();
561
+ if (event.dataTransfer) event.dataTransfer.dropEffect = 'move';
562
+ dockZone.classList.add('drag-over');
563
+ });
564
+ dockZone.addEventListener('dragleave', () => dockZone.classList.remove('drag-over'));
565
+ dockZone.addEventListener('drop', (event) => {
566
+ if (!dragKey) return;
567
+ event.preventDefault();
568
+ const key = dragKey;
569
+ endSectionDrag();
570
+ place(key, 'right');
571
+ });
401
572
 
573
+ // The divider's real range: a quarter to three quarters, narrowed so neither column goes under the
574
+ // 260px the stylesheet holds it to. Unknown width (not laid out yet): the plain quarter range.
575
+ function columnBounds() {
576
+ const width = stack.clientWidth;
577
+ const reserve = width > 0 ? (260 + 5.5) / width * 100 : 0;
578
+ const low = Math.max(25, reserve), high = Math.min(75, 100 - reserve);
579
+ return low <= high ? [low, high] : [50, 50];
580
+ }
581
+ function shownColumnRatio() { const [low, high] = columnBounds(); return Math.max(low, Math.min(high, state.columnRatio)); }
582
+ // Reset is the person's choice even when the columns' minimum already shows half and half.
583
+ function resetColumnRatio() {
584
+ if (state.columnRatio === defaults.columnRatio) return false;
585
+ state.columnRatio = defaults.columnRatio; sizeSplit(); return true;
586
+ }
587
+ function setColumnRatio(value) {
588
+ const [low, high] = columnBounds();
589
+ const next = Math.max(low, Math.min(high, value));
590
+ // Compared with the divider on screen: a press the columns' minimum absorbs saves nothing.
591
+ if (next === shownColumnRatio()) return false;
592
+ state.columnRatio = next; sizeSplit(); return true;
593
+ }
402
594
  function setRatio(value) {
403
595
  let next = Math.max(25, Math.min(75, value));
404
596
  if (approvalVisible() && !pendingDecisionVisible() && presented('narrative') && presented('model')
@@ -420,11 +612,11 @@
420
612
  if (!splitSession) return;
421
613
  const session = splitSession;
422
614
  splitSession = null;
423
- split.classList.remove('dragging'); document.body.classList.remove('left-pane-height-resizing');
424
- if (!commit) state.ratio = session.startRatio;
615
+ split.classList.remove('dragging'); document.body.classList.remove('left-pane-height-resizing', 'left-pane-width-resizing');
616
+ if (!commit) state[session.key] = session.startRatio;
425
617
  try { if (!split.hasPointerCapture || split.hasPointerCapture(session.pointerId)) split.releasePointerCapture(session.pointerId); } catch { /* capture may already be gone */ }
426
618
  reflect();
427
- if (commit && state.ratio !== session.startRatio) save();
619
+ if (commit && state[session.key] !== session.startRatio) save();
428
620
  }
429
621
  split.addEventListener('pointerdown', (event) => {
430
622
  if (event.button !== 0 || event.isPrimary === false) return;
@@ -432,15 +624,18 @@
432
624
  if (splitSession) finishSplit(false);
433
625
  event.preventDefault(); split.focus();
434
626
  const rect = stack.getBoundingClientRect();
435
- if (!(rect.height > 0)) return;
436
- splitSession = { pointerId: event.pointerId, top: rect.top, height: rect.height, startRatio: state.ratio };
627
+ const columns = sideBySide();
628
+ if (!((columns ? rect.width : rect.height) > 0)) return;
629
+ splitSession = { pointerId: event.pointerId, columns, top: rect.top, height: rect.height, left: rect.left, width: rect.width,
630
+ key: columns ? 'columnRatio' : 'ratio', startRatio: columns ? state.columnRatio : state.ratio };
437
631
  try { split.setPointerCapture(event.pointerId); } catch { /* window listeners still own the gesture */ }
438
- split.classList.add('dragging'); document.body.classList.add('left-pane-height-resizing');
632
+ split.classList.add('dragging'); document.body.classList.add(columns ? 'left-pane-width-resizing' : 'left-pane-height-resizing');
439
633
  });
440
634
  window.addEventListener('pointermove', (event) => {
441
635
  if (!splitSession || event.pointerId !== splitSession.pointerId) return;
442
636
  if (event.pointerType === 'mouse' && event.buttons === 0) { finishSplit(true); return; }
443
- setRatio(((event.clientY - splitSession.top) / splitSession.height) * 100);
637
+ if (splitSession.columns) setColumnRatio(((event.clientX - splitSession.left) / splitSession.width) * 100);
638
+ else setRatio(((event.clientY - splitSession.top) / splitSession.height) * 100);
444
639
  });
445
640
  window.addEventListener('pointerup', (event) => { if (splitSession?.pointerId === event.pointerId) finishSplit(true); });
446
641
  window.addEventListener('pointercancel', (event) => { if (splitSession?.pointerId === event.pointerId) finishSplit(false); });
@@ -450,6 +645,7 @@
450
645
  split.addEventListener('dblclick', (event) => {
451
646
  if (split.getAttribute('aria-disabled') === 'true') return;
452
647
  if (splitSession) { event.preventDefault(); return; }
648
+ if (sideBySide()) { if (resetColumnRatio()) save(); return; }
453
649
  if (setRatio(defaults.ratio)) save();
454
650
  });
455
651
  window.addEventListener('keydown', (event) => {
@@ -457,7 +653,14 @@
457
653
  if (event.target !== split) return;
458
654
  if (split.getAttribute('aria-disabled') === 'true') { event.preventDefault(); return; }
459
655
  if (splitSession) {
460
- if (['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) event.preventDefault();
656
+ if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Enter'].includes(event.key)) event.preventDefault();
657
+ return;
658
+ }
659
+ // Side by side the divider is upright, so Left and Right move it.
660
+ if (sideBySide()) {
661
+ if (event.key === 'Enter') { event.preventDefault(); if (resetColumnRatio()) save(); return; }
662
+ if (!['ArrowLeft', 'ArrowRight'].includes(event.key)) return;
663
+ event.preventDefault(); if (setColumnRatio(shownColumnRatio() + (event.key === 'ArrowLeft' ? -1 : 1) * (event.shiftKey ? 10 : 2))) save();
461
664
  return;
462
665
  }
463
666
  if (event.key === 'Enter') { event.preventDefault(); if (setRatio(defaults.ratio)) save(); return; }
@@ -981,7 +1184,7 @@
981
1184
  // A floor that moves can also start or end a Revoke approval's hold on the split; that needs
982
1185
  // reflect()'s focus, tooltip and blocked-reason work, not only new section heights.
983
1186
  const refitFloor = () => {
984
- if (String(approvalSplitLocked(state.order[0])) !== split.getAttribute('aria-disabled')) reflect();
1187
+ if (String(splitLockedNow()) !== split.getAttribute('aria-disabled')) reflect();
985
1188
  else sizeSplit();
986
1189
  };
987
1190
  const chatFeed = chatShell?.querySelector('.ai-chat-feed');
@@ -1014,5 +1217,7 @@
1014
1217
  if (window.innerHeight > 520) modelRequestedDuringApproval = false;
1015
1218
  reflect();
1016
1219
  });
1220
+ // Inspect folding, opening or changing width moves the room for two columns as much as the window does.
1221
+ window.addEventListener('floless:panel-room', () => reflect());
1017
1222
  arrange(); reflect();
1018
1223
  })();
@@ -196,6 +196,9 @@ export function createSteelAdapter({ viewport, editorBridge = {} }) {
196
196
  // notifies. The Objects-pane Show all needs this rather than the controller's Ghost flag (or the
197
197
  // toolbar mark painted from it), which Show all clears only after the renderer has notified.
198
198
  hasVisibilityTreatment: () => !!invoke('hasVisibilityTreatment', [], false),
199
+ // Monotonic count of every Ghost/Isolate/Hide/Show-all/saved-view change. null when the renderer has no such counter, which a caller must read as "cannot tell".
200
+ visibilityRevision: () => invoke('visibilityRevision', [], null),
201
+ isIsolated: () => !!invoke('isIsolated', [], false),
199
202
  selectionHiddenIds: () => invoke('selectionHiddenIds', [], []),
200
203
  connHiddenIds: () => invoke('connHiddenIds', [], []),
201
204
  setGroupsHidden: (keys, hidden) => invoke('setGroupsHidden', [keys, hidden]),
@@ -366,6 +366,12 @@ export function createModelViewportController(options) {
366
366
  ghostUnselected: state.ghostUnselected,
367
367
  hasVisibilityFilter: state.hasVisibilityFilter,
368
368
  });
369
+ // THE choke point for object-visibility changes (Ghost unselected, Isolate, Hide selected, Show all, a saved view's
370
+ // objects state, and the scene reporting its own change). Every writer below calls visibilityChanged(); a host that
371
+ // wants to know whether the user touched visibility between two moments compares visibilityRevision() instead of
372
+ // watching individual commands, so a new way to change visibility cannot slip past it.
373
+ let visibilityRevision = 0;
374
+ const visibilityChanged = () => { visibilityRevision += 1; };
369
375
  const publishState = () => {
370
376
  const snapshot = editorState();
371
377
  for (const listener of [...stateSubscribers]) {
@@ -533,8 +539,9 @@ export function createModelViewportController(options) {
533
539
  const next = value ?? adapter.sectionState();
534
540
  state = transitionViewportState(state, { type: 'section', clipping: next.clipping, workPlane: next.workPlane, workArea: next.workArea, activeClipGesture: next.activeClipGesture ?? null }); publishState(); return true;
535
541
  },
536
- reportVisibility(filtered) {
542
+ reportVisibility(filtered, options) {
537
543
  if (disposed) return false;
544
+ if (!options || options.intentional !== false) visibilityChanged(); // an internal refresh ({ intentional: false }) republishes the state without counting as a user change
538
545
  state = transitionViewportState(state, { type: 'visibility', filtered: filtered ?? adapter.hasVisibilityFilter() }); publishState(); return true;
539
546
  },
540
547
  commitSelection(commit) {
@@ -570,7 +577,7 @@ export function createModelViewportController(options) {
570
577
  state = transitionViewportState(state, { type: 'hover', key: next }); applyPresentation(); return next;
571
578
  },
572
579
  hideSelection() {
573
- ensureLive(); const outcome = adapter.hideSelection(state.selectedKeys);
580
+ ensureLive(); const outcome = adapter.hideSelection(state.selectedKeys); visibilityChanged();
574
581
  const hiddenKeys = Array.isArray(outcome?.hiddenKeys) ? outcome.hiddenKeys.filter((key) => state.selectedKeys.includes(key)) : [];
575
582
  state = transitionViewportState(state, { type: 'visibility', filtered: adapter.hasVisibilityFilter() });
576
583
  const hoverHidden = hiddenKeys.includes(state.hoverKey);
@@ -582,19 +589,19 @@ export function createModelViewportController(options) {
582
589
  publishState(); return Number.isFinite(outcome?.count) ? outcome.count : outcome;
583
590
  },
584
591
  isolateSelection() {
585
- ensureLive(); const result = adapter.isolateSelection(state.selectedKeys);
592
+ ensureLive(); const result = adapter.isolateSelection(state.selectedKeys); visibilityChanged();
586
593
  state = transitionViewportState(state, { type: 'visibility', filtered: adapter.hasVisibilityFilter() });
587
594
  if (state.ghostUnselected) { state = transitionViewportState(state, { type: 'ghost', enabled: false }); applyPresentation(); }
588
595
  publishState(); return result;
589
596
  },
590
597
  showAll() {
591
- ensureLive(); adapter.clearVisibility();
598
+ ensureLive(); adapter.clearVisibility(); visibilityChanged();
592
599
  state = transitionViewportState(state, { type: 'visibility', filtered: adapter.hasVisibilityFilter() });
593
600
  state = transitionViewportState(state, { type: 'ghost', enabled: false });
594
601
  applyPresentation(); publishState();
595
602
  },
596
603
  setGhostUnselected(enabled) {
597
- ensureLive();
604
+ ensureLive(); visibilityChanged();
598
605
  // Isolate and Ghost unselected are alternatives: Ghost lifts an isolation, and the adapter brings back only what
599
606
  // the isolation hid. An isolation already cleared some other way leaves nothing to lift.
600
607
  if (enabled && adapter.isIsolated?.()) {
@@ -606,9 +613,10 @@ export function createModelViewportController(options) {
606
613
  },
607
614
  toggleGhostUnselected() { return api.setGhostUnselected(!state.ghostUnselected); },
608
615
  ghostUnselected() { ensureLive(); return state.ghostUnselected; },
616
+ visibilityRevision() { return visibilityRevision; },
609
617
  visibilitySnapshot() { ensureLive(); return immutable(adapter.snapshotVisibility()); },
610
618
  applyVisibilitySnapshot(value) {
611
- ensureLive(); adapter.applyVisibilitySnapshot(value);
619
+ ensureLive(); adapter.applyVisibilitySnapshot(value); visibilityChanged();
612
620
  state = transitionViewportState(state, { type: 'visibility', filtered: adapter.hasVisibilityFilter() });
613
621
  if (value && Object.prototype.hasOwnProperty.call(value, 'ghostUnselected')) {
614
622
  state = transitionViewportState(state, { type: 'ghost', enabled: value.ghostUnselected });
@@ -1514,7 +1514,7 @@ function buildFromScene(sc) {
1514
1514
  buildRefLines();
1515
1515
  syncMemberLabels(); // refresh the member-label pool from the (possibly edited) member set
1516
1516
  syncPropLabels(); // re-anchor the property labels too (member geometry may have moved)
1517
- if (hadVisibilityFilter !== hasVisibilityFilter()) notifyVisibilityChange(); // keep the host's recovery control honest when an edit removes the last hidden/isolated mesh
1517
+ if (hadVisibilityFilter !== hasVisibilityFilter()) notifyVisibilityChange({ intentional: false }); // keep the host's recovery control honest when an edit removes the last hidden/isolated mesh
1518
1518
  applyGroupVisibility(); applyDisplayMode();
1519
1519
  built = true;
1520
1520
  // Fit only on entering 3D (rebuild(true)) — NOT on every edit. Frames whatever is on screen, so a
@@ -4225,7 +4225,12 @@ function visibleObjectIds() {
4225
4225
  return out;
4226
4226
  }
4227
4227
  function visibleGridIds() { return [...structGridLines].filter(([, line]) => line.visible).map(([id]) => id); }
4228
- function notifyVisibilityChange() { syncSpatialVisibility(); viewportReports?.reportVisibility(); if (api && api.onIsolateChange) api.onIsolateChange(isolatedIds !== null || isolatedGridIds !== null); }
4228
+ // Counts every INTENTIONAL scene-side visibility change; the facade adds the controller's own count (its writers + this report), so the sum only ever rises.
4229
+ // notifyVisibilityChange() is the intentional path (a user's hide/solo/isolate/show-all/saved view/work area/Ghost). An internal refresh that only keeps the
4230
+ // host's controls honest (a stale grid selection dropped, a rebuild pruning the last hidden mesh) passes { intentional: false }: it republishes the state but
4231
+ // does not move the revision, so a review does not mistake it for the user choosing something.
4232
+ let sceneVisibilityRevision = 0;
4233
+ function notifyVisibilityChange(options) { const intentional = !options || options.intentional !== false; if (intentional) sceneVisibilityRevision += 1; syncSpatialVisibility(); viewportReports?.reportVisibility(undefined, { intentional }); if (api && api.onIsolateChange) api.onIsolateChange(isolatedIds !== null || isolatedGridIds !== null); }
4229
4234
  function toggleGroup(k) { if (groupHidden.has(k)) groupHidden.delete(k); else groupHidden.add(k); soloGroups.clear(); applyGroupVisibility(); applyDisplayMode(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
4230
4235
  // Hide/show a SET of groups in one pass (a legend type-category master toggle) — deterministic (not a flip),
4231
4236
  // so "hide all" / "show all" for the category is exact. Clears solo, like toggleGroup.
@@ -4742,7 +4747,7 @@ function setWorkAreaBox(box) {
4742
4747
  const whole = workArea ? workArea.whole : true; // keep the current cut/whole mode across a re-define; a brand-new work area defaults to "show whole parts" (no surprise slicing)
4743
4748
  workArea = { enabled: true, whole, planes: boxToPlanes(box), box: box.clone() };
4744
4749
  applyClips(); renderWorkArea(); refreshWorkAreaVis(); renderWorkPlane();
4745
- publishWorkAreaState();
4750
+ publishWorkAreaState(); notifyVisibilityChange(); // a work area (whole-parts) hides/shows whole meshes: that is a visibility change the user made
4746
4751
  return true;
4747
4752
  }
4748
4753
  function workAreaSetAll() { return setWorkAreaBox(visibleWorldBox()); } // "set work area to all objects" — ALL objects, so a visible reference model counts; steel-only made this return false (a dead control) on a project holding only a borrowed IFC
@@ -4755,7 +4760,7 @@ function workAreaToggle(on) {
4755
4760
  if (api && api.beginClipEdit) api.beginClipEdit(); // undoable
4756
4761
  workArea.enabled = on === undefined ? !workArea.enabled : !!on;
4757
4762
  applyClips(); renderWorkArea(); refreshWorkAreaVis(); renderWorkPlane();
4758
- publishWorkAreaState();
4763
+ publishWorkAreaState(); notifyVisibilityChange();
4759
4764
  return workArea.enabled;
4760
4765
  }
4761
4766
  // "Show whole parts" toggle: whole → a part touching the box shows in full (nothing sliced); cut → hard planar
@@ -4765,10 +4770,10 @@ function workAreaSetWhole(on) {
4765
4770
  if (api && api.beginClipEdit) api.beginClipEdit(); // undoable
4766
4771
  workArea.whole = on === undefined ? !workArea.whole : !!on;
4767
4772
  applyClips(); refreshWorkAreaVis();
4768
- publishWorkAreaState();
4773
+ publishWorkAreaState(); notifyVisibilityChange();
4769
4774
  return workArea.whole;
4770
4775
  }
4771
- function clearWorkArea() { if (api && api.beginClipEdit && workArea) api.beginClipEdit(); workArea = null; applyClips(); renderWorkArea(); refreshWorkAreaVis(); renderWorkPlane(); publishWorkAreaState(); }
4776
+ function clearWorkArea() { const had = workArea !== null; if (api && api.beginClipEdit && workArea) api.beginClipEdit(); workArea = null; applyClips(); renderWorkArea(); refreshWorkAreaVis(); renderWorkPlane(); publishWorkAreaState(); if (had) notifyVisibilityChange(); }
4772
4777
  function workAreaState() { return workArea ? { on: workArea.enabled, whole: !!workArea.whole } : null; }
4773
4778
  // The camera viewpoint as plain data — position + orbit target + projection + the ortho frustum half-height
4774
4779
  // and zoom. A saved view restores it via setCameraState. (perspCam/orthoCam share position; orthoBaseH+zoom
@@ -5789,7 +5794,7 @@ function reconcileGridVisibilityState(scopeChanged=false){
5789
5794
  selectedGridIds=new Set(next.selected);gridSelectionHidden=new Set(next.hidden);isolatedGridIds=next.isolated===null?null:new Set(next.isolated);
5790
5795
  if(next.clearMeshIsolation){isolatedIds=null;applyGroupVisibility();rebuildEndpoints();refreshOverlayDims();refreshDims();}
5791
5796
  if(next.selectionChanged&&api&&api.onGridSelectionReset)api.onGridSelectionReset();
5792
- if(next.changed){updateStatusChip();notifyVisibilityChange();}
5797
+ if(next.changed){updateStatusChip();notifyVisibilityChange({intentional:false});}
5793
5798
  }
5794
5799
  function setGridSelection(ids){selectedGridIds=ids instanceof Set?new Set(ids):new Set(ids||[]);applyDisplayMode();updateStatusChip();}
5795
5800
  // A Ghost change arriving here is an object-visibility change like any other, so it notifies as
@@ -9121,6 +9126,7 @@ function disposeSteel() {
9121
9126
  function dispose() {
9122
9127
  if (!viewportController) return disposeSteel();
9123
9128
  const current = viewportController;
9129
+ sceneVisibilityRevision += current.visibilityRevision(); // keep the facade's revision from falling when the controller goes away
9124
9130
  viewportController = null;
9125
9131
  return current.dispose();
9126
9132
  }
@@ -9364,6 +9370,8 @@ window.Steel3DView = {
9364
9370
  // Instructor seam: what this module has armed, and the one slot that paints what the shell produced.
9365
9371
  instructorCommand, renderGuidance,
9366
9372
  isolateSelected, hideSelected, clearIsolation, isIsolated, hasVisibilityFilter, hasVisibilityTreatment,
9373
+ // Monotonic count of every Ghost/Isolate/Hide/Show-all/saved-view change; a caller compares two readings to learn whether visibility was touched in between.
9374
+ visibilityRevision: () => sceneVisibilityRevision + (viewportController ? viewportController.visibilityRevision() : 0),
9367
9375
  setGhostUnselected: (on) => viewportController ? viewportController.setGhostUnselected(on) : setGhostUnselected(on),
9368
9376
  toggleGhostUnselected: () => viewportController ? viewportController.toggleGhostUnselected() : setGhostUnselected(!ghostUnselectedEnabled),
9369
9377
  ghostUnselected: () => viewportController ? viewportController.ghostUnselected() : ghostUnselectedEnabled,