@floless/app 0.131.0 → 0.131.1
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.
- package/dist/floless-server.cjs +306 -9
- package/dist/web/reference-changes.js +55 -0
- package/dist/web/steel-editor.html +740 -24
- package/dist/web/steel-split-view.js +19 -0
- package/package.json +1 -1
|
@@ -619,6 +619,33 @@
|
|
|
619
619
|
/* Clearance for the world-axis TRIAD, which is drawn whenever the 3D pane is on screen — so this keys
|
|
620
620
|
off pane visibility, not off which pane owns the tools. */
|
|
621
621
|
body.pane3d-shown #bottomDock{right:104px}
|
|
622
|
+
/* SPLIT: the dock's LEFT group belongs to a pane, not to the stage's corner. The rule above already
|
|
623
|
+
clears #ptrBars onto the 3D pane; the left side never got the equivalent, so #m3dLegendLauncher —
|
|
624
|
+
which expands the 3D pane's OWN panel (aria-controls=m3dLegend) — and the gesture hint both sat in the
|
|
625
|
+
plan's bottom-left. This moves their PLACEMENT only. The hint's TEXT is written by updateStatusChip()
|
|
626
|
+
in steel-3d-view.js from 3D-renderer state alone; it does not read activePane and is not changed here,
|
|
627
|
+
so in split it still reads as the 3D sentence wherever it sits. Say so plainly rather than letting the
|
|
628
|
+
comment imply this fixed that too. (Second review, finding 7.)
|
|
629
|
+
--dock-pane3d-left is DERIVED in applySplitRatio() — not measured off the pane, which would force a
|
|
630
|
+
layout inside every sample of a divider drag.
|
|
631
|
+
3D ACTIVE: shift the whole left group onto the 3D pane, so launcher and hint stay adjacent exactly as
|
|
632
|
+
they read in a single view. Padding only shrinks the content box, so #ptrBars stays right-aligned.
|
|
633
|
+
The +12px is DOCK_GUTTER_PX — the inset every other pane-anchored control uses, and the thing that
|
|
634
|
+
keeps the launcher's 8px-wider hit target off the divider. Keep it in step with the JS constant, which
|
|
635
|
+
subtracts the same 12 from the fit budget. */
|
|
636
|
+
body.split-view.v3d #bottomDock.dock-per-pane{padding-left:calc(var(--dock-pane3d-left,0px) + 12px)}
|
|
637
|
+
/* 2D ACTIVE: the hint belongs over the plan, but the launcher still belongs to the pane it controls. So
|
|
638
|
+
take the launcher OUT of the flex flow — being first, any offset on it would drag the hint along too —
|
|
639
|
+
and pin it to the 3D pane. bottom:0 reproduces the dock's own align-items:flex-end. The +12px matches
|
|
640
|
+
the padding above, so the launcher does not shift when the active pane changes. */
|
|
641
|
+
body.split-view:not(.v3d) #bottomDock.dock-per-pane #m3dLegendLauncher{position:absolute;left:calc(var(--dock-pane3d-left,0px) + 12px);bottom:0}
|
|
642
|
+
/* …and stop the hint growing across the divider into the pane it is not describing.
|
|
643
|
+
The cap goes on #canvasStatus, the visible pill — NOT on its #bottomDockLeft parent. That parent's
|
|
644
|
+
flex:1 is what pushes #ptrBars to the dock's right edge, so capping IT dragged Select/Snap ~160px
|
|
645
|
+
leftwards and straight under the launcher. Capping the child leaves the spacer free to expand.
|
|
646
|
+
The -12px is the gutter: the 7px divider plus ~5px of air, so the pill stops short of the seam
|
|
647
|
+
rather than butting against it. MIN_PANE_PX keeps the offset ≥275, so the cap never goes negative. */
|
|
648
|
+
body.split-view:not(.v3d) #bottomDock.dock-per-pane #canvasStatus{max-width:calc(var(--dock-pane3d-left,100%) - 12px)}
|
|
622
649
|
#bottomDockLeft{display:flex;align-items:center;gap:8px;flex:1;min-width:0;pointer-events:none}
|
|
623
650
|
#ptrBars{position:static;z-index:auto;display:flex;align-items:flex-end;gap:8px;flex:none;pointer-events:auto}
|
|
624
651
|
#canvasStatus{display:none;align-items:center;gap:0;flex:1;min-width:0;pointer-events:auto}
|
|
@@ -1473,6 +1500,31 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1473
1500
|
#rcUncomparable .rcuwhy{color:var(--mut);font-size:11.5px;line-height:1.6}
|
|
1474
1501
|
#rcUncomparable .rcurow{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:2px 0;font-size:11.5px;color:var(--mut)}
|
|
1475
1502
|
#rcUncomparable .rcurow .rcuv{color:var(--text);font-variant-numeric:tabular-nums}
|
|
1503
|
+
/* ── The version history (#734 Phase 6). One row per version, newest first.
|
|
1504
|
+
NO NESTED SCROLLPORT: `#rvBody` is this modal's one scroll container and the page's global `*`
|
|
1505
|
+
scrollbar rules (:179) already reach it, which is why the change list declares none either. A
|
|
1506
|
+
version chain is short — a `max-height` here would add a second bar for nothing. ── */
|
|
1507
|
+
#rvHistoryStage{padding:14px}
|
|
1508
|
+
#rvhSubject{color:var(--mut);font-size:12px;line-height:1.55;margin-bottom:10px}
|
|
1509
|
+
#rvhSubject b{color:var(--text);font-weight:600}
|
|
1510
|
+
#rvhList .rvhrow{display:flex;align-items:center;gap:10px;padding:8px 10px;border:1px solid var(--line);border-radius:7px;margin-bottom:6px;background:var(--sunken)}
|
|
1511
|
+
/* The row you are ON, in the idiom this page already uses four times over (`.rcrow.sel`, `.refrow.sel`,
|
|
1512
|
+
`.refobjrow.sel`, `.lrow.clip.sel`) — one selected-ness in this modal, not two. */
|
|
1513
|
+
#rvhList .rvhrow.now{box-shadow:inset 2px 0 0 var(--brand);background:var(--brand-wash)}
|
|
1514
|
+
#rvhList .rvhnum{flex:none;color:var(--mut);font-size:10.5px;font-variant-numeric:tabular-nums;min-width:56px}
|
|
1515
|
+
#rvhList .rvhmain{flex:1;min-width:0}
|
|
1516
|
+
#rvhList .rvhnm{color:var(--text);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1517
|
+
#rvhList .rvhwhen{color:var(--mut);font-size:10.5px;line-height:1.6}
|
|
1518
|
+
#rvhList .rvhacts{flex:none;display:flex;align-items:center;gap:8px}
|
|
1519
|
+
/* The confirm sits INSIDE the row it is about, so a list of eight versions cannot leave you unsure
|
|
1520
|
+
which one you just agreed to. Muted rather than amber: a rollback is a supported action the user
|
|
1521
|
+
asked for, not a fault — the same reasoning the refusal stage states for staying out of `--err`. */
|
|
1522
|
+
#rvhList .rvhconfirm{flex:1;min-width:0;color:var(--mut);font-size:11.5px;line-height:1.5}
|
|
1523
|
+
/* The post-rollback sentence, in `.rcban.plain`'s two tokens rather than `--ok` green. This modal's
|
|
1524
|
+
vocabulary for a good, uneventful outcome is colourless everywhere else (`.rcempty` included), and a
|
|
1525
|
+
success-green would be a tone this surface does not otherwise have. */
|
|
1526
|
+
#rvhNote{margin-top:10px;padding:7px 10px;border:1px solid var(--line);border-radius:7px;color:var(--mut);font-size:11.5px;line-height:1.55}
|
|
1527
|
+
#rvhNote:empty{display:none;padding:0;border:0}
|
|
1476
1528
|
/* ── Favourites tab (#m3dFavBody) — the Views-tab row/search recipe. No create button (★ lives in the
|
|
1477
1529
|
Inspector); a kind-filter + search header, per-row kind swatch + portability badge + row-click-to-arm. ── */
|
|
1478
1530
|
#favHeadRow{display:flex;align-items:stretch;gap:6px;margin-bottom:6px;flex:none}
|
|
@@ -2124,6 +2176,20 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
2124
2176
|
<div id=rcList class=rcregion></div>
|
|
2125
2177
|
<div id=rcUncomparable style="display:none"></div>
|
|
2126
2178
|
</div>
|
|
2179
|
+
<!-- ── The version history (#734 Phase 6, design §7.3) ──────────────────────────────────────────
|
|
2180
|
+
ITS OWN STAGE, not a section under the change list, and that is DEPARTURE B — flagged rather
|
|
2181
|
+
than folded in. §7.3 puts it below the list; it has to be reachable when there is no list at
|
|
2182
|
+
all, because that is the only way to roll back. Given it must be a surface in its own right,
|
|
2183
|
+
drawing it a second time inside a panel that already holds up to 12,000 rows adds a duplicate
|
|
2184
|
+
and a second scroll region. Reverting is one `rvhPaint()` call into a host after
|
|
2185
|
+
`#rcUncomparable`. Pawel's call; asked in the PR alongside Departure A. -->
|
|
2186
|
+
<div id=rvHistoryStage style="display:none">
|
|
2187
|
+
<div id=rvhSubject></div>
|
|
2188
|
+
<div id=rvhList></div>
|
|
2189
|
+
<!-- `aria-live` as well as `role=status`: the post-rollback outcome lands on a repaint, and without
|
|
2190
|
+
it a screen-reader user gets silence where a sighted one gets the sentence. -->
|
|
2191
|
+
<div id=rvhNote role=status aria-live=polite></div>
|
|
2192
|
+
</div>
|
|
2127
2193
|
</div>
|
|
2128
2194
|
<div class=rvfoot id=rvFoot>
|
|
2129
2195
|
<div id=rvFootNote class=rvnote role=status></div>
|
|
@@ -2413,6 +2479,31 @@ let view3dShown = false; // is the 3D canvas ON SCREEN? (true in
|
|
|
2413
2479
|
let view2dShown = true; // …and the plan canvas. Both derived in reflectViewChrome.
|
|
2414
2480
|
let splitAvailable = true; // last known "the stage can hold two panes" — the resize edge detector
|
|
2415
2481
|
const SPLIT_MODE_KEY='steel:viewMode:v1', SPLIT_RATIO_KEY='steel:splitRatio:v1';
|
|
2482
|
+
// The narrowest the bottom dock's LEFT group may get before it stops docking to the 3D pane and falls
|
|
2483
|
+
// back to spanning the stage. Sized for the BINDING case — 3D active, where the launcher, the hint and
|
|
2484
|
+
// Select/Snap all share the 3D pane's budget: 28px launcher + 8px gap + 28px collapsed status toggle +
|
|
2485
|
+
// 8px before Select/Snap.
|
|
2486
|
+
//
|
|
2487
|
+
// The 2D-active arrangement is cheaper (only the 28px launcher and its 8px gap sit right of the offset —
|
|
2488
|
+
// the hint is over the plan), so between 36 and 72px it would still fit and is nonetheless dropped to the
|
|
2489
|
+
// fallback. That is deliberate: ONE threshold means the two arrangements switch at the same divider
|
|
2490
|
+
// position, so dragging past it does not reshuffle the dock differently depending on which pane happens
|
|
2491
|
+
// to be active. The cost is a narrow band of extra conservatism; the alternative is two thresholds and a
|
|
2492
|
+
// seam the user can find. (Code review — the earlier comment here claimed no arrangement fits below 72,
|
|
2493
|
+
// which is not true of the 2D-active one.)
|
|
2494
|
+
const DOCK_MIN_LEFT_PX=72;
|
|
2495
|
+
// How far INSIDE the 3D pane the docked group sits. Every other pane-anchored control on this stage is
|
|
2496
|
+
// inset by the same 12px — #m3dLegend, #zoombar, and #bottomDock itself are all left:12px — so a launcher
|
|
2497
|
+
// flush on the pane edge was the odd one out, sitting ~3px off the divider's hairline with its shadow
|
|
2498
|
+
// bleeding across the seam. It is also a HIT-TEST fix, which is the half that actually bites:
|
|
2499
|
+
// #m3dLegendLauncher::before extends its target 8px to the LEFT (inset:-1px -8px), and #bottomDock's
|
|
2500
|
+
// z-index:8 beats #splitBar's 6 — so flush on the edge, the launcher was swallowing the bottom ~44px of
|
|
2501
|
+
// the divider, and a press there expanded the 3D panel instead of starting a drag. (Second review.)
|
|
2502
|
+
const DOCK_GUTTER_PX=12;
|
|
2503
|
+
// Extra room required to switch the per-pane layout ON, over what is required to keep it on. Wide enough
|
|
2504
|
+
// that a hand shaking on the divider cannot sit astride the boundary — the switch relocates the launcher
|
|
2505
|
+
// by hundreds of px, so a flicker is far more jarring than a slightly late switch. (Codex review, D2.)
|
|
2506
|
+
const DOCK_HYSTERESIS_PX=32;
|
|
2416
2507
|
let splitRatio = 0.5;
|
|
2417
2508
|
// Fallback palette (colorFor indexes this array by profile order) when a contract ships no `palette`
|
|
2418
2509
|
// — e.g. a contract shared/committed with raster_b64 + palette stripped for confidentiality.
|
|
@@ -8637,8 +8728,45 @@ reflectOriginGrid();
|
|
|
8637
8728
|
// first move of every drag — small, but it makes a careful adjustment feel like it slipped. (Codex
|
|
8638
8729
|
// review, H10.)
|
|
8639
8730
|
const ratioAt=clientX=>{const r=wrap.getBoundingClientRect(),d=dividerPx();return (clientX-r.left-d/2)/Math.max(1,r.width-d);};
|
|
8640
|
-
|
|
8641
|
-
|
|
8731
|
+
// onMove is the STREAM — no `settled`, so the fit gate keeps its full turn-on slack against hand jitter.
|
|
8732
|
+
// The pointerup that ENDS a real drag settles, so the layout comes to rest on what actually fits rather
|
|
8733
|
+
// than on whichever side of the slack the last sample happened to land.
|
|
8734
|
+
//
|
|
8735
|
+
// …but ONLY if the divider actually moved, which is what `moved` is for. Every pointerdown gets a pointerup
|
|
8736
|
+
// whether or not it was a drag, so settling unconditionally meant a bare CLICK on the divider — the one that
|
|
8737
|
+
// focuses it for the arrow keys — could re-dock the chrome on its own, and a DOUBLE-click fired two settled
|
|
8738
|
+
// pointerups and THEN the dblclick reset: starting off with room in [72,104) the first pointerup docked and
|
|
8739
|
+
// the reset to 50% could immediately undock, a visible teleport inside one gesture. That is the very
|
|
8740
|
+
// oscillation the slack exists to prevent, so a pointerup that moved nothing must change nothing.
|
|
8741
|
+
// (Codex review, E1.)
|
|
8742
|
+
// …and `moved` keys on DISPLACEMENT, not on the event: a pointermove can fire at the same coordinates
|
|
8743
|
+
// (the spec lets it report a change in pressure or contact geometry alone), and a hand delivering a click
|
|
8744
|
+
// rarely holds still to the pixel — either would have made a click a "drag" again and reopened the whole
|
|
8745
|
+
// defect. DRAG_SLOP is the usual click-vs-drag tolerance; below it the divider still tracks the pointer
|
|
8746
|
+
// through the stream, it simply does not count as a gesture that may settle. (Codex review, F3.)
|
|
8747
|
+
const DRAG_SLOP=3;
|
|
8748
|
+
// ONE gesture at a time, identified by its pointerId. The handlers live on `window` and the state below is
|
|
8749
|
+
// shared, so without this a second finger's pointerdown re-based pressX mid-drag (making the slop measure
|
|
8750
|
+
// from the wrong origin) and ANY pointerup or pointercancel — from a pointer that never touched the
|
|
8751
|
+
// divider — tore the live gesture down. A second press does not RE-USE this state, it replaces it: see the
|
|
8752
|
+
// pointerdown handler, which ends the standing gesture first. (Codex review, G4 and H1.)
|
|
8753
|
+
let dragId=null,pressX=0,pressRatio=0.5,moved=false;
|
|
8754
|
+
const endDrag=()=>{if(dragId!==null){try{bar.releasePointerCapture(dragId);}catch(_){}}dragId=null;bar.classList.remove('drag');document.body.style.userSelect='';window.removeEventListener('pointermove',onMove);window.removeEventListener('pointerup',onUp);window.removeEventListener('pointercancel',onCancel);};
|
|
8755
|
+
const onMove=e=>{if(e.pointerId!==dragId)return;if(Math.abs(e.clientX-pressX)>DRAG_SLOP)moved=true;apply(ratioAt(e.clientX),false);};
|
|
8756
|
+
const onUp=e=>{if(e.pointerId!==dragId)return;endDrag();apply(splitRatio,true,moved);};
|
|
8757
|
+
// A CANCEL IS NOT A RELEASE. pointercancel means the gesture was taken away — the browser claimed it for a
|
|
8758
|
+
// scroll, the pen left range, the touch was interrupted — so it must not keep the position the user never
|
|
8759
|
+
// finished choosing. It restores the ratio captured at pointerdown, which the stream has been overwriting
|
|
8760
|
+
// all along; running the success path here instead would persist a half-made drag and could re-dock on it.
|
|
8761
|
+
// Sharing only the teardown is what stops an interrupted drag stranding `.drag`, the userSelect lock, the
|
|
8762
|
+
// listeners, and a `moved:true` that a later unrelated pointerup would have settled on.
|
|
8763
|
+
//
|
|
8764
|
+
// NEITHER `save` NOR `settled`, and both omissions are the point. Saving would write the RESTORED number
|
|
8765
|
+
// over the stored preference — and those are not the same thing: a wide-window 0.85 that this narrow stage
|
|
8766
|
+
// clamped to 0.596 is still 0.85 in storage, so a cancel that saved would quietly destroy the wider layout
|
|
8767
|
+
// the user chose. Settling would let a cancel turn the dock gate ON through the bare threshold, moving the
|
|
8768
|
+
// launcher hundreds of px as the outcome of a gesture that was ABANDONED. (Codex review, F1, G3 and H3.)
|
|
8769
|
+
const onCancel=e=>{if(e.pointerId!==dragId)return;endDrag();apply(pressRatio,false);};
|
|
8642
8770
|
// focus() explicitly, because the preventDefault() on the line before it suppresses the browser's OWN
|
|
8643
8771
|
// click-to-focus — and this separator promises an arrow-key nudge, which needs focus to reach the keydown
|
|
8644
8772
|
// handler below. Without it, "click the divider, then press Left/Right" silently did nothing: focus
|
|
@@ -8647,15 +8775,22 @@ reflectOriginGrid();
|
|
|
8647
8775
|
// this focus (measured), so a clicked divider keeps the brand tint until focus leaves — kept deliberately:
|
|
8648
8776
|
// it is the existing focus state, not a new one, and it says the separator now owns the arrow keys.
|
|
8649
8777
|
// (Independent QA E2E, item 14.)
|
|
8650
|
-
|
|
8651
|
-
|
|
8778
|
+
// A new press ENDS any gesture still standing rather than being refused. Refusing was the obvious reading of
|
|
8779
|
+
// "one at a time" and it is the one that can wedge: nothing captured the pointer, so a release outside the
|
|
8780
|
+
// browser window was never delivered, `dragId` stayed set, and every later press was turned away — a
|
|
8781
|
+
// divider dead for the rest of the page's life. Taking over cannot wedge, and the pointerId filter still
|
|
8782
|
+
// stops the OLD pointer's events from touching the new gesture. setPointerCapture is the other half: it is
|
|
8783
|
+
// what makes the terminal event arrive at all once the pointer leaves the window, which is exactly what a
|
|
8784
|
+
// slider-like control needs. (Codex review, G4 and H1.)
|
|
8785
|
+
bar.addEventListener('pointerdown',e=>{if(dragId!==null)endDrag();e.preventDefault();bar.focus({preventScroll:true});bar.classList.add('drag');document.body.style.userSelect='none';dragId=e.pointerId;pressX=e.clientX;pressRatio=splitRatio;moved=false;try{bar.setPointerCapture(e.pointerId);}catch(_){}window.addEventListener('pointermove',onMove);window.addEventListener('pointerup',onUp);window.addEventListener('pointercancel',onCancel);});
|
|
8786
|
+
bar.addEventListener('dblclick',()=>apply(0.5,true,true));
|
|
8652
8787
|
// stopPropagation, not just preventDefault: steel-3d-view.js binds onKey on WINDOW and only skips
|
|
8653
8788
|
// INPUT/SELECT/TEXTAREA, so a div[tabindex=0] sails through it. Without this, an arrow key on the
|
|
8654
8789
|
// focused divider moved the divider AND panned the 3D camera — and this divider exists only in the mode
|
|
8655
8790
|
// where the 3D canvas is always on screen, so that collision is routine, not theoretical. (Code review.)
|
|
8656
8791
|
bar.addEventListener('keydown',e=>{const step=(e.shiftKey?0.1:0.02);
|
|
8657
|
-
if(e.key==='ArrowLeft'){e.preventDefault();e.stopPropagation();apply(splitRatio-step,true);}
|
|
8658
|
-
else if(e.key==='ArrowRight'){e.preventDefault();e.stopPropagation();apply(splitRatio+step,true);}});
|
|
8792
|
+
if(e.key==='ArrowLeft'){e.preventDefault();e.stopPropagation();apply(splitRatio-step,true,true);}
|
|
8793
|
+
else if(e.key==='ArrowRight'){e.preventDefault();e.stopPropagation();apply(splitRatio+step,true,true);}});
|
|
8659
8794
|
// Re-clamp the geometry on every resize frame. Distinct from onStageResize, which changes the MODE and
|
|
8660
8795
|
// only on an availability edge; both may coexist because they answer different questions.
|
|
8661
8796
|
window.addEventListener('resize',()=>{if(viewMode==='split')apply(splitRatio,false);});
|
|
@@ -12116,6 +12251,13 @@ function openRefRowMenu(r,anchorEl){closeRefRowMenu();
|
|
|
12116
12251
|
if(refDisp(r).locked){toast('“'+r.name+'” is locked — unlock it to load a new version');return;}
|
|
12117
12252
|
if(!window.openRefVersion){toast('The reference panel isn’t ready yet — try again in a moment');return;}
|
|
12118
12253
|
window.openRefVersion(r);}));
|
|
12254
|
+
// THE HISTORY, AND THE ONLY WAY TO ROLL BACK (#734 Phase 6). Never refused on the lock: reading a list
|
|
12255
|
+
// writes nothing, and a locked reference is exactly the one whose history somebody wants to check. The
|
|
12256
|
+
// rollback ACTION inside it is refused by the server on the lock, with the sentence the schema's own
|
|
12257
|
+
// rule gives — a refusal at the act rather than an item withheld from the menu.
|
|
12258
|
+
m.append(mk('Version history…',()=>{
|
|
12259
|
+
if(!window.openRefHistory){toast('The reference panel isn’t ready yet — try again in a moment');return;}
|
|
12260
|
+
window.openRefHistory(r);}));
|
|
12119
12261
|
m.append(mk('Reload its geometry',async()=>{
|
|
12120
12262
|
if(refDisp(r).locked){toast('“'+r.name+'” is locked — unlock it to reload it');return;} // the lock freezes reload, as the schema says
|
|
12121
12263
|
// ALREADY BEING READ — REFUSE BEFORE DESTROYING ANYTHING. `loadReferenceGeometry` returns
|
|
@@ -12780,6 +12922,17 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
12780
12922
|
* unreachable. The import modal solves the same problem with `riBackgrounded` and this is its sibling.
|
|
12781
12923
|
*/
|
|
12782
12924
|
let rvBackgrounded=false;
|
|
12925
|
+
/**
|
|
12926
|
+
* WHICH of the three flows owns this modal right now: 'upload' | 'rollback' | 'compare' | null.
|
|
12927
|
+
*
|
|
12928
|
+
* `rvBusy` says something is running; it cannot say what should happen when the user closes mid-run,
|
|
12929
|
+
* and the three answers genuinely differ. An upload and a rollback both own a contract mutation whose
|
|
12930
|
+
* route DETACHES from the client, so closing is a BACKGROUNDING action and the answer must come back
|
|
12931
|
+
* on screen when it lands. A per-version compare writes nothing and its route keeps the ordinary
|
|
12932
|
+
* disconnect guard, so closing really is a cancel — and letting it background instead would leave an
|
|
12933
|
+
* AWARE run grinding through two whole-building IFCs for a panel nobody will see. (#734 Phase 6.)
|
|
12934
|
+
*/
|
|
12935
|
+
let rvFlow=null;
|
|
12783
12936
|
/** The version this upload was compared against — see `rcPreviousVersionId`. */
|
|
12784
12937
|
let rvComparedAgainst=null;
|
|
12785
12938
|
/** `undefined` keeps the reference's own filter (the default), `null` is an explicit unfiltered read,
|
|
@@ -12795,7 +12948,7 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
12795
12948
|
const rvProg=(label,soft)=>{rvClearSoft();rv$('rvProgTxt').textContent=label;
|
|
12796
12949
|
if(soft)rvSoftT=setTimeout(()=>{rv$('rvProgTxt').textContent=soft;},6000);};
|
|
12797
12950
|
|
|
12798
|
-
function rvStage(s){ // 'drop' | 'prog' | 'refuse' | 'result'
|
|
12951
|
+
function rvStage(s){ // 'drop' | 'prog' | 'refuse' | 'result' | 'history'
|
|
12799
12952
|
rvStageNow=s;
|
|
12800
12953
|
// The answer floats over a LIVE canvas; the three stages before it hold the screen. See the CSS.
|
|
12801
12954
|
rv$('refVersionModal').classList.toggle('rvfloat',s==='result');
|
|
@@ -12803,17 +12956,31 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
12803
12956
|
rv$('rvProgStage').style.display=s==='prog'?'':'none';
|
|
12804
12957
|
rv$('rvRefuseStage').style.display=s==='refuse'?'':'none';
|
|
12805
12958
|
rv$('rvResultStage').style.display=s==='result'?'':'none';
|
|
12959
|
+
rv$('rvHistoryStage').style.display=s==='history'?'':'none';
|
|
12806
12960
|
// THE FOOT IS HIDDEN ON THE REFUSAL, because that state draws its OWN weighted actions and one of
|
|
12807
12961
|
// them is Cancel. Two Cancels, one of them the quiet default, is the shape the import modal removed
|
|
12808
12962
|
// from its backdrop for exactly this reason.
|
|
12809
12963
|
rv$('rvFoot').style.display=s==='refuse'?'none':'';
|
|
12810
12964
|
rv$('rvCancel').style.display=s==='result'?'none':'';
|
|
12965
|
+
// ON THE HISTORY IT IS `Close`, NOT `Cancel`. Nothing is in flight to cancel, and offering to cancel
|
|
12966
|
+
// a list somebody is merely reading invites the reading that something is pending.
|
|
12967
|
+
rv$('rvCancel').textContent=s==='history'?'Close':'Cancel';
|
|
12811
12968
|
rv$('rvDone').style.display=s==='result'?'':'none';
|
|
12969
|
+
// The way back to the history, offered only from the change list — it is created lazily by
|
|
12970
|
+
// `rcPaintFoot`, so it may not exist yet, and it must never offer the history you are already on.
|
|
12971
|
+
const hist=rv$('rvFoot').querySelector('.rvhist');
|
|
12972
|
+
if(hist)hist.style.display=s==='result'?'':'none';
|
|
12973
|
+
// THE FOOT NOTE BELONGS TO THE CHANGE LIST ALONE. `rcPaintFoot` writes "Compared by: location,
|
|
12974
|
+
// geometry, …" there, and the foot survives every stage change — so opening the history after a
|
|
12975
|
+
// comparison left that sentence sitting under a list of versions, where it describes nothing on
|
|
12976
|
+
// screen. Cleared on the way out rather than re-blanked by each stage that does not want it.
|
|
12977
|
+
if(s!=='result')rv$('rvFootNote').textContent='';
|
|
12812
12978
|
rv$('rvClose').style.display=s==='prog'?'none':''; // mid-run, Cancel owns the exit
|
|
12813
12979
|
rv$('rvProgNote').style.display='none';
|
|
12814
12980
|
rv$('rvTitle').textContent=s==='prog'?'Reading the files'
|
|
12815
12981
|
:s==='result'?'What changed'
|
|
12816
12982
|
:s==='refuse'?'These files could not be compared'
|
|
12983
|
+
:s==='history'?'Version history'
|
|
12817
12984
|
:'Load a new version';
|
|
12818
12985
|
}
|
|
12819
12986
|
|
|
@@ -12836,15 +13003,416 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
12836
13003
|
}
|
|
12837
13004
|
window.openRefVersion=openRefVersion;
|
|
12838
13005
|
|
|
13006
|
+
// ── The version history (#734 Phase 6) — the only surface a reference can be rolled back from ──────
|
|
13007
|
+
//
|
|
13008
|
+
// `rvhRef` rather than `rvRef`: the two flows share this modal but not their subject's lifetime. An
|
|
13009
|
+
// upload replaces `rvRef` wholesale with `d.reference` mid-flight, so reading it here after a
|
|
13010
|
+
// backgrounded upload landed would paint one reference's history under another's title.
|
|
13011
|
+
let rvhRef=null;
|
|
13012
|
+
|
|
13013
|
+
function openRefHistory(r){
|
|
13014
|
+
if(!r)return;
|
|
13015
|
+
// A READ IS NOT A CANCEL. An upload in flight owns this modal; showing the history over it would
|
|
13016
|
+
// hide the spinner and lose the answer, so the read waits — the same rule `openRefVersion` follows.
|
|
13017
|
+
if(rvBusy){rv$('refVersionModal').style.display='flex';return;}
|
|
13018
|
+
rvStop();rvClearSoft();
|
|
13019
|
+
rvhRef=r;rvhNote('');
|
|
13020
|
+
rvhPaint();
|
|
13021
|
+
rvStage('history');rv$('refVersionModal').style.display='flex';rv$('rvBody').scrollTop=0;
|
|
13022
|
+
}
|
|
13023
|
+
window.openRefHistory=openRefHistory;
|
|
13024
|
+
|
|
13025
|
+
/**
|
|
13026
|
+
* The one-time outcome sentence under the list.
|
|
13027
|
+
*
|
|
13028
|
+
* CLEARED BY ITS THREE CALLERS, NOT BY `rvhPaint` — and that is deliberate rather than an oversight.
|
|
13029
|
+
* The rollback success path runs `rvhPaint(); rvStage('history'); rvhNote(…)`, so a paint that cleared
|
|
13030
|
+
* the note would wipe it a moment before it is written. `openRefHistory`, the foot's `Version history`
|
|
13031
|
+
* button and `rvhRollback`'s entry each clear it explicitly instead. (An earlier version of this
|
|
13032
|
+
* comment claimed the opposite invariant, which would have invited exactly that bug back.)
|
|
13033
|
+
*
|
|
13034
|
+
* The PERMANENT record of a restore is the row itself ("restored 16 Aug — restored from version 1");
|
|
13035
|
+
* this is a one-time confirmation, not a second copy of history.
|
|
13036
|
+
*/
|
|
13037
|
+
const rvhNote=msg=>{rv$('rvhNote').textContent=msg||'';};
|
|
13038
|
+
|
|
13039
|
+
function rvhPaint(){
|
|
13040
|
+
const host=rv$('rvhList');host.replaceChildren();
|
|
13041
|
+
const sub=rv$('rvhSubject');sub.replaceChildren();
|
|
13042
|
+
const r=rvhRef;if(!r)return;
|
|
13043
|
+
const core=RC();
|
|
13044
|
+
const rows=core?core.versionRows(r.versions):[];
|
|
13045
|
+
const b=document.createElement('b');b.textContent='“'+r.name+'”';
|
|
13046
|
+
sub.append(b,document.createTextNode(rows.length
|
|
13047
|
+
? ' — '+rows.length+' version'+(rows.length===1?'':'s')+'. Every version keeps its own file, so you can go back to one and still ask what changed since.'
|
|
13048
|
+
: ' was added before FloLess started recording versions, so there is nothing to list yet. The next version you load starts its history.'));
|
|
13049
|
+
// NO DEAD BUTTON ON THE EMPTY STATE. A chainless reference — which is every reference added before
|
|
13050
|
+
// versioning existed — gets the sentence and nothing else; disabled chrome for an action that cannot
|
|
13051
|
+
// apply is the exact thing CLAUDE.md's design rule was written after.
|
|
13052
|
+
for(const row of rows)host.appendChild(rvhRow(row));
|
|
13053
|
+
}
|
|
13054
|
+
|
|
13055
|
+
function rvhRow(row){
|
|
13056
|
+
const el=document.createElement('div');el.className='rvhrow'+(row.current?' now':'');
|
|
13057
|
+
el.dataset.vid=row.id||'';
|
|
13058
|
+
el.appendChild(Object.assign(document.createElement('span'),{className:'rvhnum',textContent:'version '+row.n}));
|
|
13059
|
+
const main=document.createElement('div');main.className='rvhmain';
|
|
13060
|
+
main.appendChild(Object.assign(document.createElement('div'),{className:'rvhnm',textContent:row.name}));
|
|
13061
|
+
// THE DATE IN THE READER'S OWN LOCALE, and the WORD from the pure core — "recorded", "restored" and
|
|
13062
|
+
// "imported" are three different facts and the module owns which one this row is. TRAILING PROSE
|
|
13063
|
+
// RATHER THAN A CHIP, deliberately: a chip would need its qualifier on hover, and hover-only content
|
|
13064
|
+
// reaches neither a keyboard nor a screen reader. (UX review.)
|
|
13065
|
+
const when=row.importedAt?new Date(row.importedAt):null;
|
|
13066
|
+
const date=when&&!isNaN(when)?when.toLocaleDateString():null;
|
|
13067
|
+
main.appendChild(Object.assign(document.createElement('div'),{className:'rvhwhen',
|
|
13068
|
+
textContent:(date?row.dateWord+' '+date:row.dateWord)+(row.note?' — '+row.note:'')}));
|
|
13069
|
+
el.appendChild(main);
|
|
13070
|
+
const acts=document.createElement('div');acts.className='rvhacts';
|
|
13071
|
+
if(row.current){
|
|
13072
|
+
// A LABEL, NOT AN EMPTY SLOT. Rolling back to where you already are does nothing and comparing a
|
|
13073
|
+
// version with itself is refused by the server, so neither control could do anything but produce a
|
|
13074
|
+
// refusal — but leaving the slot blank reads as unfinished rather than as "correctly nothing",
|
|
13075
|
+
// which is the disabled-vs-hidden trap one tier along. `rc-plain` is this modal's own recede
|
|
13076
|
+
// treatment. (UX review.)
|
|
13077
|
+
acts.appendChild(Object.assign(document.createElement('span'),{className:'rc-chip rc-plain',textContent:'Current version'}));
|
|
13078
|
+
el.appendChild(acts);
|
|
13079
|
+
return el;
|
|
13080
|
+
}
|
|
13081
|
+
// A ROW WITH NO ID CAN BE DRAWN BUT NOT ACTED ON — both actions address a version by id, so two
|
|
13082
|
+
// buttons here would be two clicks that do nothing, silently, which is the defect the ⋯ menu's own
|
|
13083
|
+
// rule rejects. Said instead. (Silent-failure review.)
|
|
13084
|
+
if(!row.actionable){
|
|
13085
|
+
acts.appendChild(Object.assign(document.createElement('span'),{className:'rc-chip rc-unk',
|
|
13086
|
+
textContent:'No id recorded'}));
|
|
13087
|
+
acts.firstChild.dataset.tip='This version has no id recorded, so FloLess cannot restore it or compare against it.';
|
|
13088
|
+
el.appendChild(acts);
|
|
13089
|
+
return el;
|
|
13090
|
+
}
|
|
13091
|
+
// THE QUIET ONE IS THE READ. Compare writes nothing and answers a question; rollback is what this
|
|
13092
|
+
// surface exists for, so it keeps the page's default button weight and compare drops to `.pilllink`
|
|
13093
|
+
// — the three-weight rule this modal's CSS states, applied in the order the actions actually rank.
|
|
13094
|
+
const cmp=document.createElement('button');cmp.type='button';cmp.className='pilllink';
|
|
13095
|
+
cmp.textContent='What changed since this';
|
|
13096
|
+
cmp.dataset.tip='Compare this version with the one you have. Nothing is re-read or replaced.';
|
|
13097
|
+
cmp.addEventListener('click',()=>rvhCompare(row));
|
|
13098
|
+
const back=document.createElement('button');back.type='button';
|
|
13099
|
+
back.textContent='Roll back to this';
|
|
13100
|
+
back.addEventListener('click',()=>rvhAskConfirm(row));
|
|
13101
|
+
acts.append(cmp,back);
|
|
13102
|
+
el.appendChild(acts);
|
|
13103
|
+
return el;
|
|
13104
|
+
}
|
|
13105
|
+
|
|
13106
|
+
/**
|
|
13107
|
+
* The confirm, INSIDE the row it is about, and swapped IN PLACE.
|
|
13108
|
+
*
|
|
13109
|
+
* Not `window.confirm`, which renders the light OS dialog against this page's dark theme. Not a toast
|
|
13110
|
+
* either: this is a question and a toast cannot be answered.
|
|
13111
|
+
*
|
|
13112
|
+
* A TARGETED SWAP RATHER THAN A REPAINT, and that is the whole reason this is its own function. A
|
|
13113
|
+
* `rvhPaint()` here would destroy the button that was just clicked and strand focus on `<body>` — the
|
|
13114
|
+
* single most repeated bug class in this file, which `buildRefObjRow` and the filter-caret restore
|
|
13115
|
+
* both carry comments about. (UX review.)
|
|
13116
|
+
*/
|
|
13117
|
+
function rvhAskConfirm(row){
|
|
13118
|
+
// BY A REAL ID ONLY. `[data-vid=""]` matches the FIRST idless row rather than the clicked one, so on
|
|
13119
|
+
// a chain with two of them the confirm would open inside the wrong row — and an idless row draws no
|
|
13120
|
+
// Roll back button anyway, so reaching here with one is a bug worth saying rather than absorbing.
|
|
13121
|
+
if(!row||!row.id){console.warn('[reference] no confirm for a version row with no id',row);return;}
|
|
13122
|
+
const el=rv$('rvhList').querySelector('.rvhrow[data-vid="'+CSS.escape(row.id)+'"]');
|
|
13123
|
+
if(!el){console.warn('[reference] the row to confirm in is gone',row.id);return;}
|
|
13124
|
+
const acts=el.querySelector('.rvhacts');if(!acts)return;
|
|
13125
|
+
acts.replaceChildren();
|
|
13126
|
+
const q=document.createElement('div');q.className='rvhconfirm';
|
|
13127
|
+
// IT NAMES THE COST BEFORE THE COMMIT, not after. The duration is discovered in the spinner
|
|
13128
|
+
// otherwise, by which point the user has already agreed to it; and the reassurance answers the real
|
|
13129
|
+
// anxiety, which is whether going back throws the newer versions away. It does not. (UX review.)
|
|
13130
|
+
q.textContent='Go back to version '+row.n+'? FloLess re-reads that whole file — whole-building models '
|
|
13131
|
+
+'can take several minutes — and any measurement on this reference is dropped. '
|
|
13132
|
+
+'Nothing is lost: every version stays in this history.';
|
|
13133
|
+
el.insertBefore(q,acts);
|
|
13134
|
+
const keep=document.createElement('button');keep.type='button';keep.className='ghost';
|
|
13135
|
+
keep.textContent='Keep this one';
|
|
13136
|
+
keep.addEventListener('click',()=>{const fresh=rvhRow(row);el.replaceWith(fresh);
|
|
13137
|
+
const b=fresh.querySelector('.rvhacts button:last-child');if(b)b.focus();});
|
|
13138
|
+
const go=document.createElement('button');go.type='button';go.className='rvprimary';
|
|
13139
|
+
go.textContent='Roll back';
|
|
13140
|
+
go.addEventListener('click',()=>rvhRollback(row));
|
|
13141
|
+
acts.append(keep,go);
|
|
13142
|
+
// FOCUS LANDS ON THE SAFE OPTION. The button that was pressed has just been replaced, so focus has to
|
|
13143
|
+
// be placed explicitly or it falls to `<body>`; and for an action costing minutes and dropping the
|
|
13144
|
+
// measurement, the accidental-Enter target must be the one that does nothing. (UX review.)
|
|
13145
|
+
keep.focus();
|
|
13146
|
+
}
|
|
13147
|
+
|
|
13148
|
+
/**
|
|
13149
|
+
* Roll back, and carry across everything a re-read would otherwise take.
|
|
13150
|
+
*
|
|
13151
|
+
* A ROLLBACK IS A RE-READ, so it is held to the same three answers as `Load a new version…` and
|
|
13152
|
+
* `Reload its geometry`, in the same order and for the same reasons: the tree's open groups and the
|
|
13153
|
+
* drilled-into object migrate on the identity the file supplies, the measurement CANNOT be migrated
|
|
13154
|
+
* and is dropped, and whatever could not be carried is SAID. See `refSessionMigrate`.
|
|
13155
|
+
*
|
|
13156
|
+
* IT SAYS "re-reading version 2" RATHER THAN APPEARING TO HANG. The geometry cache is keyed per
|
|
13157
|
+
* reference, not per version, so an earlier version's geometry is genuinely gone and this always pays
|
|
13158
|
+
* a full read — on a real building, minutes. Design §4.3 states it so it is not discovered here.
|
|
13159
|
+
*/
|
|
13160
|
+
async function rvhRollback(row){
|
|
13161
|
+
const r=rvhRef;if(!r||!row)return;
|
|
13162
|
+
if(!row.id){console.warn('[reference] a version row with no id cannot be rolled back to',row);
|
|
13163
|
+
rvhNote('That version has no id recorded, so FloLess cannot restore it.');return;}
|
|
13164
|
+
// ALREADY BEING RE-READ — REFUSE BEFORE DESTROYING ANYTHING. `Reload its geometry` and a rollback
|
|
13165
|
+
// both replace this reference's objects and both drop its measurement; run at once they land in
|
|
13166
|
+
// arbitrary order and the canvas ends up showing one version while the contract claims another. The
|
|
13167
|
+
// reload item makes the reciprocal check (`refLoading`) and this is its other half — said out loud,
|
|
13168
|
+
// because the user asked for something. (Silent-failure review.)
|
|
13169
|
+
if(refLoading.has(r.id)){toast('“'+r.name+'” is already being re-read — wait for that to finish first');return;}
|
|
13170
|
+
const mine=++rvRun;
|
|
13171
|
+
// `rvBackgrounded=false` for the reason `rvSubmit` clears it too: one flag, three flows, and a stale
|
|
13172
|
+
// `true` left by an abandoned earlier run would make this one reopen a modal nobody backgrounded.
|
|
13173
|
+
rvBusy=true;rvFlow='rollback';rvBackgrounded=false;
|
|
13174
|
+
rvhNote('');
|
|
13175
|
+
rvStage('prog');rv$('rvProgNote').style.display='block';
|
|
13176
|
+
rvProg('Re-reading version '+row.n+' of “'+r.name+'”…',
|
|
13177
|
+
'FloLess keeps every version’s file but only the current version’s geometry, so going back means reading that file again. Whole-building models can take several minutes.');
|
|
13178
|
+
rvAbort=new AbortController();
|
|
13179
|
+
let mid=null,d=null;
|
|
13180
|
+
try{
|
|
13181
|
+
mid=newMutationId();claimMutation(mid);
|
|
13182
|
+
const res=await fetch(refApi('/'+encodeURIComponent(r.id)+'/rollback'),{
|
|
13183
|
+
method:'POST',signal:rvAbort.signal,
|
|
13184
|
+
headers:{'content-type':'application/json','x-floless-mutation-id':mid},
|
|
13185
|
+
body:JSON.stringify({versionId:row.id,expectedVersionId:rvCurrentVersionId(r)}),
|
|
13186
|
+
});
|
|
13187
|
+
d=await res.json().catch(()=>({}));
|
|
13188
|
+
// Gone while this was in flight. The write may still have landed, and suppressing our own echo is
|
|
13189
|
+
// what would leave a committed rollback invisible — so the claim is released and the broadcast
|
|
13190
|
+
// reconciles instead. (The version route's reasoning, verbatim.)
|
|
13191
|
+
if(mine!==rvRun){releaseMutation(mid);return;}
|
|
13192
|
+
rvClearSoft();
|
|
13193
|
+
if(!res.ok||!d.ok){
|
|
13194
|
+
// EVERY REFUSAL HERE IS A NO-WRITE — the route refuses before the read for the cheap ones and
|
|
13195
|
+
// inside the lock for a stale version — so the claim must go, or it sits in a bounded 32-entry
|
|
13196
|
+
// ring wrongly suppressing somebody else's event and evicting a live claim early.
|
|
13197
|
+
releaseMutation(mid);
|
|
13198
|
+
// A REFUSAL PAINTED INTO A HIDDEN PANEL IS A REFUSAL NOBODY READ. Backgrounded, this modal is
|
|
13199
|
+
// `display:none`, so the note below would render perfectly and silently.
|
|
13200
|
+
if(rvBackgrounded){
|
|
13201
|
+
toast('Could not go back to version '+row.n+' of “'+r.name+'” — '+((d&&d.error)||'FloLess could not re-read it.'));
|
|
13202
|
+
rv$('refVersionModal').style.display='flex';rvBackgrounded=false;
|
|
13203
|
+
}
|
|
13204
|
+
rvhPaint();rvStage('history');
|
|
13205
|
+
rvhNote((d&&d.error)||'FloLess could not go back to that version.');
|
|
13206
|
+
return;
|
|
13207
|
+
}
|
|
13208
|
+
}catch(e){
|
|
13209
|
+
if(mine!==rvRun||(e&&e.name==='AbortError')){if(mid)releaseMutation(mid);return;}
|
|
13210
|
+
// A THROWN request tells us nothing about whether the write landed, which is exactly why the claim
|
|
13211
|
+
// must go: suppressing our own echo would leave a committed rollback invisible here.
|
|
13212
|
+
if(mid)releaseMutation(mid);
|
|
13213
|
+
rvClearSoft();
|
|
13214
|
+
if(rvBackgrounded){rv$('refVersionModal').style.display='flex';rvBackgrounded=false;}
|
|
13215
|
+
rvhPaint();rvStage('history');
|
|
13216
|
+
rvhNote('Could not reach the reader — check the app is running.');
|
|
13217
|
+
console.error('[reference] rollback failed',e);return;
|
|
13218
|
+
}finally{if(mine===rvRun){rvBusy=false;rvFlow=null;rvAbort=null;}}
|
|
13219
|
+
// ── PAST THE POINT OF NO RETURN. Everything above is the transaction; everything below is showing
|
|
13220
|
+
// it, and they are deliberately not one try — a throw in the presentation half must not report a
|
|
13221
|
+
// failure for a rollback that is committed on disk. (The version route learned this the hard way.)
|
|
13222
|
+
//
|
|
13223
|
+
// `carried` IS DECLARED OUT HERE, not inside the try, so the catch can still say what was lost. It
|
|
13224
|
+
// was scoped inside, which put it out of reach exactly where it matters most: by the time a throw
|
|
13225
|
+
// can land below, `refMeasureDropFor` and `refGeom.set` have already run, so the measurement is gone
|
|
13226
|
+
// and the geometry is swapped whatever happens next. Reporting the failure without the loss is the
|
|
13227
|
+
// one remaining way this feature could take somebody's session without a word — which is the thing
|
|
13228
|
+
// it exists to prevent. (Silent-failure review; the upload path already does this and says why.)
|
|
13229
|
+
let carried=[];
|
|
13230
|
+
try{
|
|
13231
|
+
// ALREADY THERE, AND HANDLED BEFORE ANYTHING ELSE. The route answers this without reading, without
|
|
13232
|
+
// committing and — the part that matters here — WITHOUT BROADCASTING, so there is no etag to adopt
|
|
13233
|
+
// and no echo will ever arrive to sweep the claim. Releasing it explicitly is not tidiness: the
|
|
13234
|
+
// ring is 32 entries, so a leak both suppresses a real event carrying that id and evicts a live
|
|
13235
|
+
// claim early.
|
|
13236
|
+
if(d.unchanged){
|
|
13237
|
+
releaseMutation(mid);
|
|
13238
|
+
rvhRef=d.reference||r;
|
|
13239
|
+
if(rvBackgrounded){rv$('refVersionModal').style.display='flex';rvBackgrounded=false;}
|
|
13240
|
+
rvhPaint();rvStage('history');
|
|
13241
|
+
rvhNote('“'+r.name+'” is already on version '+row.n+'.');return;
|
|
13242
|
+
}
|
|
13243
|
+
adoptReferenceWrite(d.etag);
|
|
13244
|
+
const i=refList().findIndex(x=>x&&x.id===r.id);
|
|
13245
|
+
// REMOVED WHILE THIS WAS IN FLIGHT. The route detaches from the client on purpose, so the rollback
|
|
13246
|
+
// really does commit; what must not happen is this tab asserting the reference is back.
|
|
13247
|
+
if(i<0){
|
|
13248
|
+
rvBackgrounded=false;
|
|
13249
|
+
console.warn('[reference] a rollback landed for',r.id,'after it was removed — not resurrecting it');
|
|
13250
|
+
rvClose();toast('“'+r.name+'” was removed while it was being rolled back, so there is nothing to show.');return;
|
|
13251
|
+
}
|
|
13252
|
+
C.reference_models[i]=d.reference;
|
|
13253
|
+
rvhRef=d.reference;
|
|
13254
|
+
// TAKEN BEFORE THE NEW OBJECTS REPLACE THE OLD ONES — `refGeom.set` below is the moment the labels
|
|
13255
|
+
// this resolves against stop existing.
|
|
13256
|
+
const snap=refSessionSnapshot(r.id);
|
|
13257
|
+
refGeom.set(r.id,refGeomFrom(d));
|
|
13258
|
+
refFailed.delete(r.id);refEmpty.delete(r.id);refUnresolved.delete(r.id);
|
|
13259
|
+
refMeasureDropFor(r.id);
|
|
13260
|
+
// SEEDED AT THE MOMENT OF THE DROP, not left to `refSessionMigrate` below. A throw between here
|
|
13261
|
+
// and there leaves `carried` empty while the measurement is already gone — and an empty `carried`
|
|
13262
|
+
// makes `refCarryoverSentence` return null, so the catch would say nothing about a measurement
|
|
13263
|
+
// that no longer exists. `refSessionMigrate` re-derives the same fact from `snap.hadMeasure`, so
|
|
13264
|
+
// the success path replaces this rather than doubling it. (Silent-failure review.)
|
|
13265
|
+
if(snap.hadMeasure)carried=['your measurement'];
|
|
13266
|
+
// Positional keys against objects that have all moved; cleared here and re-derived from the
|
|
13267
|
+
// snapshot's LABELS below. `refTreeQuery` stays, for the reason the other two paths give: a group
|
|
13268
|
+
// choice records the query it was made under, so clearing the box leaves every carried choice inert.
|
|
13269
|
+
refTreeGroups.delete(r.id);
|
|
13270
|
+
pushReferences();
|
|
13271
|
+
try{carried=refSessionMigrate(r.id,snap);}
|
|
13272
|
+
catch(e){console.error('[reference] could not carry the session across the rollback of',r.id,e);
|
|
13273
|
+
carried=['what you had open in this reference'];}
|
|
13274
|
+
renderRefsTab();panel();
|
|
13275
|
+
// THE ANSWER COMES BACK ON SCREEN if the user closed the modal while it ran. A rollback backgrounds
|
|
13276
|
+
// rather than cancels — the route detaches and commits either way — so without this the geometry
|
|
13277
|
+
// silently swaps under the user and the sentence below is painted where nobody can read it, which
|
|
13278
|
+
// is the one thing this feature exists to prevent.
|
|
13279
|
+
if(rvBackgrounded){rv$('refVersionModal').style.display='flex';rvBackgrounded=false;
|
|
13280
|
+
toast('“'+r.name+'” is back on version '+row.n+'.');}
|
|
13281
|
+
rvhPaint();rvStage('history');
|
|
13282
|
+
// THE SENTENCE, IN THE PANEL RATHER THAN A TOAST, because there is a panel to put it in — and the
|
|
13283
|
+
// `version` tail is the honest one: a rollback really does have an earlier version to name, where
|
|
13284
|
+
// `Reload its geometry` re-reads the same file and has none.
|
|
13285
|
+
const lost=refCarryoverSentence(carried,'version');
|
|
13286
|
+
// A PARTIAL RESTORE MUST NOT READ AS A CLEAN ONE. The route computes and sends `unmatched` — the
|
|
13287
|
+
// storeys or types this version's filter names that no longer resolve in the file — and saying
|
|
13288
|
+
// only "back on version 2" while silently reading less of it than the version did is the same
|
|
13289
|
+
// class of lie the import path already refuses to tell. (Silent-failure review.)
|
|
13290
|
+
const missed=Array.isArray(d.unmatched)&&d.unmatched.length
|
|
13291
|
+
? ' Nothing matched '+d.unmatched.map(u=>'“'+u+'”').join(', ')
|
|
13292
|
+
+' — that part of the file may have been renamed since this version was loaded.'
|
|
13293
|
+
: '';
|
|
13294
|
+
// …AND THE BYTES MAY NOT BE THE VERSION'S BYTES. The server compared the file's hash against what
|
|
13295
|
+
// the chain recorded and told us they differ; asserting "back on version 2" on its own would then
|
|
13296
|
+
// be a sentence the server has already contradicted.
|
|
13297
|
+
const drifted=d.fileChanged
|
|
13298
|
+
? ' The file behind that version is not the one recorded under it, so this is that file as it stands today.'
|
|
13299
|
+
: '';
|
|
13300
|
+
rvhNote('“'+r.name+'” is back on version '+row.n+', now version '+((d.versions||[]).length||'?')+' in its history.'
|
|
13301
|
+
+missed+drifted+(lost?' '+lost:''));
|
|
13302
|
+
// FOCUS AFTER A REPAINT IS EXPLICIT OR IT IS NOWHERE. The `Roll back` button that had it no longer
|
|
13303
|
+
// exists; without this a keyboard user is dropped onto `<body>`. (UX review.)
|
|
13304
|
+
const nowRow=rv$('rvhList').querySelector('.rvhrow.now');
|
|
13305
|
+
if(nowRow){nowRow.setAttribute('tabindex','-1');nowRow.focus();}
|
|
13306
|
+
}catch(e){
|
|
13307
|
+
console.error('[reference] the rollback landed, but the history could not be repainted',e);
|
|
13308
|
+
// THE SENTENCE SURVIVES THE PANEL. `#rvhNote` is never painted on this path, so the carry-over has
|
|
13309
|
+
// no other way out — and the geometry really was replaced and the measurement really was dropped,
|
|
13310
|
+
// which makes losing it here the one remaining way this feature takes the user's session without a
|
|
13311
|
+
// word. Appended to the one toast rather than fired as a second, which would replace it.
|
|
13312
|
+
const lost=refCarryoverSentence(carried,'version');
|
|
13313
|
+
rvClose();toast('Rolled “'+r.name+'” back to version '+row.n+' — reload the view to see it'
|
|
13314
|
+
+(lost?' — '+lost:''),false,lost?TOAST_MS+1400:undefined);
|
|
13315
|
+
}
|
|
13316
|
+
}
|
|
13317
|
+
|
|
13318
|
+
/**
|
|
13319
|
+
* "What changed since version N" — the question design §4.4 keeps the whole chain answerable for.
|
|
13320
|
+
*
|
|
13321
|
+
* THE REVISED SIDE IS ALWAYS THE CURRENT VERSION, and that is this panel's constraint rather than the
|
|
13322
|
+
* server's (the route takes two arbitrary ids). The change list's rows zoom to objects ON THE CANVAS
|
|
13323
|
+
* and its `removed` rows draw ghosts INTO it, so a comparison whose revised side is not what is on
|
|
13324
|
+
* screen would produce rows pointing at nothing and outlines nobody could place.
|
|
13325
|
+
*
|
|
13326
|
+
* NO SESSION MIGRATION AND NO GEOMETRY SWAP: nothing is re-read and nothing is replaced. This is the
|
|
13327
|
+
* one path into the change panel that costs the user's session nothing, so it must not fire the
|
|
13328
|
+
* carry-over sentence — `rcCarried` is cleared for exactly that reason.
|
|
13329
|
+
*/
|
|
13330
|
+
async function rvhCompare(row){
|
|
13331
|
+
const r=rvhRef;if(!r||!row)return;
|
|
13332
|
+
if(!row.id){console.warn('[reference] a version row with no id cannot be compared',row);
|
|
13333
|
+
rvhNote('That version has no id recorded, so FloLess cannot compare against it.');return;}
|
|
13334
|
+
const current=rvCurrentVersionId(r);
|
|
13335
|
+
if(!current||current===row.id)return; // the current row draws no compare button; belt and braces
|
|
13336
|
+
const mine=++rvRun;
|
|
13337
|
+
// 'compare' RATHER THAN JUST BUSY, and it is what makes closing mid-run a real cancel: this writes
|
|
13338
|
+
// nothing and its route keeps the ordinary disconnect guard, so aborting the fetch stops the AWARE
|
|
13339
|
+
// run. Backgrounded instead, it would read two whole-building IFCs for a panel nobody will see.
|
|
13340
|
+
rvBusy=true;rvFlow='compare';rvBackgrounded=false;
|
|
13341
|
+
rvStage('prog');
|
|
13342
|
+
// NO "you can close this" NOTE. That sentence is true of an upload and a rollback, whose routes
|
|
13343
|
+
// detach and commit regardless; it is false here, where closing cancels. Saying it would promise an
|
|
13344
|
+
// answer that is not coming.
|
|
13345
|
+
rvProg('Comparing version '+row.n+' with the version you have…',
|
|
13346
|
+
'AWARE is reading both files and matching their objects. Whole-building models can take several minutes.');
|
|
13347
|
+
rvAbort=new AbortController();
|
|
13348
|
+
let d=null;
|
|
13349
|
+
try{
|
|
13350
|
+
const res=await fetch(refApi('/'+encodeURIComponent(r.id)+'/compare'),{
|
|
13351
|
+
method:'POST',signal:rvAbort.signal,headers:{'content-type':'application/json'},
|
|
13352
|
+
body:JSON.stringify({baseVersionId:row.id,revisedVersionId:current}),
|
|
13353
|
+
});
|
|
13354
|
+
d=await res.json().catch(()=>({}));
|
|
13355
|
+
if(mine!==rvRun)return;
|
|
13356
|
+
rvClearSoft();
|
|
13357
|
+
if(!res.ok||!d.ok){
|
|
13358
|
+
// THE REFUSAL STATE, which already knows every one of these codes — including the one that
|
|
13359
|
+
// matters most here, `reference-compare-refused`. `readOnly` because none of its upload
|
|
13360
|
+
// remedies apply to two versions already in this chain: see `rvRefusal`'s own note.
|
|
13361
|
+
rvRefusal(d,res.status,{readOnly:true});return;
|
|
13362
|
+
}
|
|
13363
|
+
}catch(e){
|
|
13364
|
+
// AN ABORT HERE IS THE USER CLOSING THE PANEL, and `rvClose` has already torn the state down —
|
|
13365
|
+
// repainting a stage into a hidden modal would leave it there for the next open.
|
|
13366
|
+
if(mine!==rvRun||(e&&e.name==='AbortError'))return;
|
|
13367
|
+
rvClearSoft();rvhPaint();rvStage('history');
|
|
13368
|
+
rvhNote('Could not reach the reader — check the app is running.');
|
|
13369
|
+
console.error('[reference] version compare failed',e);return;
|
|
13370
|
+
}finally{if(mine===rvRun){rvBusy=false;rvFlow=null;rvAbort=null;}}
|
|
13371
|
+
// ── THE PRESENTATION HALF, GUARDED — as `rvSubmit`, `rvLoadSeparately` and `rvhRollback` all guard
|
|
13372
|
+
// theirs. This one had no handler, and the consequence is worse here than elsewhere: the `finally`
|
|
13373
|
+
// above has already cleared `rvBusy` while the stage is still 'prog', so a throw inside `rcShow`
|
|
13374
|
+
// became an unhandled rejection out of a bare click handler and stranded the user on a spinner that
|
|
13375
|
+
// was no longer spinning for anything, with nothing said. (Correctness review.)
|
|
13376
|
+
try{
|
|
13377
|
+
// NOTHING WAS LOST, so nothing is reported. This path replaces no geometry.
|
|
13378
|
+
rcCarried=[];
|
|
13379
|
+
// `rvRef` is what `rcShow` reads for the refId and what the ghost layer addresses; the two flows
|
|
13380
|
+
// share the panel, so the subject is handed over explicitly rather than assumed to already match.
|
|
13381
|
+
rvRef=r;
|
|
13382
|
+
rvComparedAgainst=row.id; // the ghosts are read from the EARLIER side — see `rcPreviousVersionId`
|
|
13383
|
+
const rows=(RC()&&RC().versionRows(r.versions))||[];
|
|
13384
|
+
const revisedRow=rows.find(x=>x.id===current);
|
|
13385
|
+
rcShow({comparison:d.comparison,version:{name:(d.revised&&d.revised.name)||r.name},
|
|
13386
|
+
versions:r.versions||[],pair:{baseN:row.n,revisedN:(revisedRow&&revisedRow.n)||rows.length}});
|
|
13387
|
+
}catch(e){
|
|
13388
|
+
console.error('[reference] the comparison arrived, but the panel could not be drawn',e);
|
|
13389
|
+
// BACK TO THE HISTORY, which is where this was launched from and is a live surface — not left on a
|
|
13390
|
+
// dead spinner. Nothing was replaced, so there is nothing to report beyond the failure itself.
|
|
13391
|
+
rvhPaint();rvStage('history');
|
|
13392
|
+
rvhNote('FloLess compared those two versions but could not draw the result.');
|
|
13393
|
+
}
|
|
13394
|
+
}
|
|
13395
|
+
|
|
12839
13396
|
function rvClose(){
|
|
13397
|
+
// A READ-ONLY COMPARE IS CANCELLED, NOT BACKGROUNDED. It creates nothing durable, and its route keeps
|
|
13398
|
+
// the ordinary disconnect guard — so aborting the fetch closes the socket and stops the AWARE run.
|
|
13399
|
+
// Backgrounding it would keep two whole-building IFCs being read for an answer nobody wants.
|
|
13400
|
+
// `rvBackgrounded` is CLEARED, not merely left: one flag serves three flows, so a stale `true` would
|
|
13401
|
+
// make the next flow's landing reopen a modal nobody backgrounded.
|
|
13402
|
+
if(rvBusy&&rvStageNow==='prog'&&rvFlow==='compare'){
|
|
13403
|
+
rvStop();rvClearSoft();rvBusy=false;rvFlow=null;rvBackgrounded=false;
|
|
13404
|
+
rv$('refVersionModal').style.display='none';rcGhostReset();return;
|
|
13405
|
+
}
|
|
12840
13406
|
// Mid-run this is a BACKGROUNDING action for the same reason the import's is: the route detaches from
|
|
12841
13407
|
// the client deliberately, so an accepted upload finishes and commits whether this modal is on screen
|
|
12842
13408
|
// or not. Cancelling it here would only hide the answer.
|
|
12843
13409
|
if(rvBusy&&rvStageNow==='prog'){
|
|
12844
13410
|
rvBackgrounded=true;rvClearSoft();rv$('refVersionModal').style.display='none';
|
|
12845
|
-
toast('
|
|
13411
|
+
toast(rvFlow==='rollback'
|
|
13412
|
+
? 'FloLess will keep re-reading that version in the background.'
|
|
13413
|
+
: 'FloLess will keep reading the new version in the background.');return;
|
|
12846
13414
|
}
|
|
12847
|
-
rvStop();rvClearSoft();rv$('refVersionModal').style.display='none';
|
|
13415
|
+
rvStop();rvClearSoft();rvFlow=null;rv$('refVersionModal').style.display='none';
|
|
12848
13416
|
// THE GHOSTS GO WITH THE PANEL THAT EXPLAINS THEM. They are an annotation on a change list; left on
|
|
12849
13417
|
// the canvas after it closes they are unexplained red shapes inside somebody else's building, and
|
|
12850
13418
|
// nothing on screen would say they are objects that no longer exist.
|
|
@@ -12908,7 +13476,7 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
12908
13476
|
if(!rvSha||!rvRef)return;
|
|
12909
13477
|
const r=rvRef;
|
|
12910
13478
|
if(mine===undefined){mine=++rvRun;} // a retry from a refusal state is a NEW attempt
|
|
12911
|
-
rvBusy=true;rvBackgrounded=false;rcCarried=[]; // a new run never inherits the last one's carryover sentence
|
|
13479
|
+
rvBusy=true;rvFlow='upload';rvBackgrounded=false;rcCarried=[]; // a new run never inherits the last one's carryover sentence
|
|
12912
13480
|
// HELD FOR THE PANEL, not just sent: this is the version the ghosts will be read from, and knowing
|
|
12913
13481
|
// it beats inferring it from the chain's array order afterwards. See `rcPreviousVersionId`.
|
|
12914
13482
|
rvComparedAgainst=rvCurrentVersionId(r);
|
|
@@ -12957,7 +13525,7 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
12957
13525
|
if(mid)releaseMutation(mid);
|
|
12958
13526
|
rvClearSoft();rvStage('drop');rvErr('Could not load a new version — check the app is running.');
|
|
12959
13527
|
console.error('[reference] version upload failed',e);return;
|
|
12960
|
-
}finally{if(mine===rvRun){rvBusy=false;rvAbort=null;}}
|
|
13528
|
+
}finally{if(mine===rvRun){rvBusy=false;rvFlow=null;rvAbort=null;}}
|
|
12961
13529
|
// ── PAST THE POINT OF NO RETURN. Everything above is the transaction; everything below is showing it,
|
|
12962
13530
|
// and they are deliberately not one try — a throw in the presentation half must not report a failure
|
|
12963
13531
|
// for a version that is committed on disk. (The import route learned this the expensive way.)
|
|
@@ -13040,7 +13608,19 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
13040
13608
|
reload:()=>location.reload(),
|
|
13041
13609
|
};
|
|
13042
13610
|
|
|
13043
|
-
|
|
13611
|
+
/**
|
|
13612
|
+
* `readOnly` marks a refusal from the per-version COMPARE, which has different remedies to an upload.
|
|
13613
|
+
*
|
|
13614
|
+
* Every one of `REFUSAL_ACTIONS`' three ways out is about a FILE THE USER JUST DROPPED — "choose a
|
|
13615
|
+
* different file" reopens the dropzone, and "load it as a separate reference instead" POSTs `rvSha`.
|
|
13616
|
+
* A history compare drops no file, so on that path `rvSha` is either null (the button is then a
|
|
13617
|
+
* control whose only outcome is nothing) or, worse, LEFT OVER from an upload earlier in the session
|
|
13618
|
+
* against a different reference — in which case the primary action inserts that file into the project
|
|
13619
|
+
* from a refusal about two historical versions. Neither is a remedy; the only honest way out of "these
|
|
13620
|
+
* two versions of your own file do not relate" is to close. (Correctness review.)
|
|
13621
|
+
*/
|
|
13622
|
+
function rvRefusal(d,status,opts){
|
|
13623
|
+
const readOnly=!!(opts&&opts.readOnly);
|
|
13044
13624
|
const host=rv$('rvRefuseStage');host.replaceChildren();
|
|
13045
13625
|
const code=d&&d.code;
|
|
13046
13626
|
const core=RC();
|
|
@@ -13052,11 +13632,17 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
13052
13632
|
// THE WORDS ARE THE CORE'S, built from the numbers AWARE actually reported — never assembled here,
|
|
13053
13633
|
// where a missing count would become a fabricated zero inside the one answer whose whole job is to
|
|
13054
13634
|
// be honest about what could not be established.
|
|
13055
|
-
|
|
13635
|
+
// THE BASE SIDE'S OWN NAME, off the refusal, and `rvRef` only as a fallback. Both routes send it
|
|
13636
|
+
// (`baseName`) precisely so this sentence can be exact — and on the history-compare path `rvRef`
|
|
13637
|
+
// is not the subject yet, so reading it names either nothing or a DIFFERENT reference, inside the
|
|
13638
|
+
// one panel whose whole job is to be honest about what could not be established. (Review.)
|
|
13639
|
+
const copy=core.refusalCopy(d.refused,(d.refused&&d.refused.baseName)||(rvRef&&rvRef.name));
|
|
13056
13640
|
lead.textContent=copy.lead;
|
|
13057
13641
|
const why=document.createElement('div');why.className='rfwhy';why.textContent=copy.why;
|
|
13058
13642
|
host.append(lead,why);
|
|
13059
|
-
|
|
13643
|
+
// Three weighted ways out, quietest to loudest — but all three are about a file that was just
|
|
13644
|
+
// dropped, so a read-only comparison gets only the one that applies. THERE IS NO FOURTH.
|
|
13645
|
+
actions=readOnly?[{id:'cancel',label:'Close',weight:'primary'}]:core.REFUSAL_ACTIONS;
|
|
13060
13646
|
}else{
|
|
13061
13647
|
lead.textContent=(d&&d.error)||'Could not load a new version of this reference.';
|
|
13062
13648
|
host.appendChild(lead);
|
|
@@ -13085,6 +13671,11 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
13085
13671
|
// is worse than none. `status` is logged rather than shown: the code is what a user can act on.
|
|
13086
13672
|
if(!code)console.warn('[reference] a version refusal arrived with no code',status,d&&d.error);
|
|
13087
13673
|
}
|
|
13674
|
+
// A BELT ON TOP OF THE BRACES, and deliberately not only on the branch above. None of the compare
|
|
13675
|
+
// route's OTHER codes currently reaches a branch that offers an upload remedy — but "currently" is
|
|
13676
|
+
// the load-bearing word: this chain keys on codes, both routes can grow one, and the failure mode is
|
|
13677
|
+
// a button that silently does nothing or inserts somebody else's file. One line makes it structural.
|
|
13678
|
+
if(readOnly)actions=actions.filter(a=>a.id==='cancel');
|
|
13088
13679
|
for(const a of actions)acts.appendChild(rvActBtn(a.label,a.weight,RV_ACT[a.id]||RV_ACT.cancel));
|
|
13089
13680
|
host.appendChild(acts);
|
|
13090
13681
|
rvStage('refuse');
|
|
@@ -13176,7 +13767,7 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
13176
13767
|
if(mid)releaseMutation(mid);
|
|
13177
13768
|
rvClearSoft();rvStage('drop');rvErr('Could not add that reference.');
|
|
13178
13769
|
console.error('[reference] separate insert failed',e);return;
|
|
13179
|
-
}finally{if(mine===rvRun){rvBusy=false;rvAbort=null;}}
|
|
13770
|
+
}finally{if(mine===rvRun){rvBusy=false;rvFlow=null;rvAbort=null;}}
|
|
13180
13771
|
rvClose();
|
|
13181
13772
|
try{
|
|
13182
13773
|
adoptReferenceWrite(d.etag);
|
|
@@ -13223,6 +13814,9 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
13223
13814
|
// WHAT THIS COMPARISON WAS ACTUALLY AGAINST, captured from the request rather than re-derived —
|
|
13224
13815
|
// see `rcPreviousVersionId`. Null on a chainless reference, which is the one case that falls back.
|
|
13225
13816
|
comparedAgainst:rvComparedAgainst,
|
|
13817
|
+
// WHICH TWO VERSIONS THIS IS ABOUT, when it is not "the one you had vs the one you just dropped".
|
|
13818
|
+
// Absent on the upload path, which is the ordinary one, so its header is untouched.
|
|
13819
|
+
pair:d.pair||null,
|
|
13226
13820
|
changes:Array.isArray(c.changes)?c.changes:[],summary:c.summary,criteria:c.criteria||[],
|
|
13227
13821
|
selected:c.selected||null,identity:c.identity||null,
|
|
13228
13822
|
version:d.version||null,versions:Array.isArray(d.versions)?d.versions:[]};
|
|
@@ -13248,9 +13842,14 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
13248
13842
|
const b=document.createElement('b');b.textContent='“'+rcData.name+'”';
|
|
13249
13843
|
const n=rcData.versions.length;
|
|
13250
13844
|
const when=rcData.version&&rcData.version.importedAt?new Date(rcData.version.importedAt):null;
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
|
|
13845
|
+
// TWO DIFFERENT QUESTIONS, TWO DIFFERENT SENTENCES. An upload compares the file you just dropped
|
|
13846
|
+
// against the one you had; a history compare names BOTH versions, because neither of them is "the
|
|
13847
|
+
// one you just dropped" and a header saying so would be false. (#734 Phase 6.)
|
|
13848
|
+
sub.append(b,document.createTextNode(rcData.pair
|
|
13849
|
+
? ' — version '+rcData.pair.baseN+' compared with version '+rcData.pair.revisedN
|
|
13850
|
+
+' (the version you have), matching each object by the id its file gives it.'
|
|
13851
|
+
: (n?' — version '+n:'')+(when&&!isNaN(when)?', imported '+when.toLocaleDateString():'')
|
|
13852
|
+
+'. Compared with the version you had, matching each object by the id its file gives it.'));
|
|
13254
13853
|
head.appendChild(sub);
|
|
13255
13854
|
const stats=document.createElement('div');stats.id='rcStats';
|
|
13256
13855
|
stats.setAttribute('role','list');stats.setAttribute('aria-label','What changed, in numbers');
|
|
@@ -13563,7 +14162,10 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
13563
14162
|
* panel dead on it would trade one bad batch for every remaining ghost. (Review: `!res.ok` alone
|
|
13564
14163
|
* could not tell the two apart, and a single 500 disabled the layer for the panel's life.)
|
|
13565
14164
|
*/
|
|
13566
|
-
|
|
14165
|
+
// `reference-versions-ambiguous` joins them for the same reason: a chain with a duplicate id cannot be
|
|
14166
|
+
// fixed by asking again in a smaller batch, so retrying would re-request every batch for the panel's
|
|
14167
|
+
// life. (#734 Phase 6 — the gate the ghost route shipped without.)
|
|
14168
|
+
const RC_GHOST_FATAL=new Set(['reference-ghost-file-missing','reference-ghost-version-unknown','reference-versions-ambiguous']);
|
|
13567
14169
|
|
|
13568
14170
|
/**
|
|
13569
14171
|
* Say it, once, and put the ids back if they can still be asked for.
|
|
@@ -13747,12 +14349,34 @@ const RI_MAX_BYTES=150*1024*1024;
|
|
|
13747
14349
|
function rcPaintFoot(){
|
|
13748
14350
|
const note=rv$('rvFootNote');
|
|
13749
14351
|
const c=rcData&&rcData.criteria;
|
|
14352
|
+
// THE `Version history` BUTTON IS NOT BUILT HERE. It was, lazily, and creating it re-entered
|
|
14353
|
+
// `rvStage(rvStageNow)` — which at this moment is still `'prog'`, because `rcShow` paints the whole
|
|
14354
|
+
// panel BEFORE it switches the stage. `rvStage` clears `#rvFootNote` on every non-result stage, so
|
|
14355
|
+
// the sentence written one line above was wiped microseconds later, and `rvStage('result')` does not
|
|
14356
|
+
// put it back. The result: the FIRST comparison of a page session silently lost its "Compared by:"
|
|
14357
|
+
// receipt and every later one kept it, because by then the button existed. A button is not per-paint
|
|
14358
|
+
// state; it is built once at wire-up. (Silent-failure review.)
|
|
13750
14359
|
note.textContent=c&&c.length?'Compared by: '+c.join(', ')+'.':'';
|
|
13751
14360
|
}
|
|
13752
14361
|
|
|
13753
14362
|
rv$('rvClose').onclick=rvClose;
|
|
13754
14363
|
rv$('rvCancel').onclick=rvClose;
|
|
13755
14364
|
rv$('rvDone').onclick=rvClose;
|
|
14365
|
+
// A WAY BACK TO THE HISTORY, so the change panel is not a dead end — and, on the upload path, the
|
|
14366
|
+
// first place the newly-appended version is visible as history at all. Quiet: `Done` is the action.
|
|
14367
|
+
// BUILT HERE, ONCE, rather than lazily inside `rcPaintFoot` — see that function's note for what the
|
|
14368
|
+
// lazy version cost. `rvStage` owns its visibility, alongside Cancel and Done.
|
|
14369
|
+
{
|
|
14370
|
+
const hist=document.createElement('button');hist.type='button';hist.className='ghost rvhist';
|
|
14371
|
+
hist.textContent='Version history';
|
|
14372
|
+
hist.style.display='none';
|
|
14373
|
+
hist.addEventListener('click',()=>{
|
|
14374
|
+
const live=rvRef&&refById(rvRef.id);
|
|
14375
|
+
if(!live){toast('That reference is no longer in this project.');return;}
|
|
14376
|
+
rvhRef=live;rvhNote('');rvhPaint();rvStage('history');rv$('rvBody').scrollTop=0;
|
|
14377
|
+
});
|
|
14378
|
+
rv$('rvFoot').insertBefore(hist,rv$('rvDone'));
|
|
14379
|
+
}
|
|
13756
14380
|
// THE BACKDROP IS NOT AN EXIT MID-RUN — the same rule the import modal states: hiding one of two
|
|
13757
14381
|
// identical exits and leaving the invisible one is the version of that rule that does not hold.
|
|
13758
14382
|
rv$('rvBackdrop').onclick=()=>{if(!(rvBusy&&rvStageNow==='prog'))rvClose();};
|
|
@@ -14285,10 +14909,25 @@ function applyViewState(on){ // TRANSITION: flip the toggle, swap the
|
|
|
14285
14909
|
// closePlans() before the combo is hidden — a popover left open across the switch is hidden with its
|
|
14286
14910
|
// wrapper, but would strand `aria-expanded=true` and the .open caret behind it.
|
|
14287
14911
|
if(!panes.two)closePlans(false);
|
|
14912
|
+
reflectViewChrome(); // everything idempotent, shared with setActivePane
|
|
14288
14913
|
// Clamp the ratio against THIS stage on the way in. Entering split is the moment a ratio saved at some
|
|
14289
14914
|
// other width first has to hold, and nothing else on this path was checking it. (Code review.)
|
|
14290
|
-
|
|
14291
|
-
reflectViewChrome()
|
|
14915
|
+
//
|
|
14916
|
+
// AFTER reflectViewChrome(), not before: that is what sets body.pane3d-shown, and `#bottomDock` is 92px
|
|
14917
|
+
// narrower under it (right:104px vs 12px — the world-axis-triad clearance). applySplitRatio measures the
|
|
14918
|
+
// dock to decide whether the per-pane layout fits, so running first measured a dock 92px wider than the
|
|
14919
|
+
// one about to be painted and let `.dock-per-pane` on in a band where it does not fit — on the 2d→split
|
|
14920
|
+
// click and the boot restore, the two main entry paths. Nothing re-measures afterwards (the
|
|
14921
|
+
// ResizeObserver watches #stagewrap, whose size does not change when the dock's inset does), so it
|
|
14922
|
+
// persisted until the next resize or drag. reflectViewChrome neither reads nor writes splitRatio, and
|
|
14923
|
+
// both still run before paint. (Code review.)
|
|
14924
|
+
// …and on the way OUT, drop the per-pane class here, because applySplitRatio — which owns that cleanup
|
|
14925
|
+
// for every other caller — is not reached on this path at all. Leaving it behind is inert today (all
|
|
14926
|
+
// three rules that read it are body.split-view-scoped), but a class that outlives the condition it names
|
|
14927
|
+
// is a trap for the next unscoped rule, and single 2D/3D would otherwise carry it for a whole session.
|
|
14928
|
+
// (Browser pass: single 2D still had .dock-per-pane after a split→2D toggle.)
|
|
14929
|
+
if(viewMode==='split')applySplitRatio(splitRatio,false,true); // settled: a view switch is one-shot
|
|
14930
|
+
else document.getElementById('bottomDock')?.classList.remove('dock-per-pane');
|
|
14292
14931
|
reflectSplitAvailability(); // PURE reflection — it must never call setView.
|
|
14293
14932
|
}
|
|
14294
14933
|
// The IDEMPOTENT half of a view change: derive view3d/view3dShown and reflect the chrome. Split out of
|
|
@@ -14335,6 +14974,17 @@ function setActivePane(which){
|
|
|
14335
14974
|
onActivePaneChange(); // B6: disarm the 2D-only takeover tools BEFORE the pane changes under them
|
|
14336
14975
|
activePane=next;
|
|
14337
14976
|
reflectViewChrome(); // the idempotent half only — no snap reset, no menu closing
|
|
14977
|
+
// …then RE-MEASURE the dock fit, because #ptrBars is not the same width in the two active panes: the
|
|
14978
|
+
// Reference button is hidden while the plan is active, so the bar measures 432.6px there and 440.6px with
|
|
14979
|
+
// the 3D pane active (1440×900, demo model). `room` is dock − offset − THAT width, so an 8px step lands
|
|
14980
|
+
// straight in the gate's own band: a layout settled at room 81.9 with the plan active becomes room 73.9 on
|
|
14981
|
+
// the switch, and at a slightly narrower divider it drops under DOCK_MIN_LEFT_PX entirely — the dock left
|
|
14982
|
+
// enabled below the width it requires, which is what the gate exists to prevent. Nothing else re-ran it:
|
|
14983
|
+
// the ResizeObserver watches #stagewrap, whose size a pane switch does not change. AFTER
|
|
14984
|
+
// reflectViewChrome(), which is what sets body.v3d and therefore the bar's content — the same ordering
|
|
14985
|
+
// trap as the pane3d-shown one in applyViewState. Settled, because a pane switch is one-shot, not a
|
|
14986
|
+
// stream. (Codex review, J5.)
|
|
14987
|
+
if(viewMode==='split')applySplitRatio(splitRatio,false,true);
|
|
14338
14988
|
panel(); // the inspector's hints are view-scoped (Add-member, Move/Copy)
|
|
14339
14989
|
}
|
|
14340
14990
|
function reflectActivePane(){
|
|
@@ -14400,13 +15050,79 @@ function onActivePaneChange(){
|
|
|
14400
15050
|
// reopened on a ~600px stage gave the 3D pane 89px, and #m3dLegend (min-width:210px at left:12px) hung
|
|
14401
15051
|
// out through the pane edge — precisely the defect MIN_PANE_PX exists to prevent. It also owns
|
|
14402
15052
|
// aria-valuenow, which was otherwise stale at 50 until the first drag. (Code review.)
|
|
14403
|
-
|
|
15053
|
+
// `settled` = this is a ONE-SHOT layout, not a sample from a pointer/resize stream. It only affects the
|
|
15054
|
+
// fit gate's turn-on threshold — see the Schmitt-trigger note below.
|
|
15055
|
+
function applySplitRatio(r,save,settled){
|
|
14404
15056
|
const wrap=document.getElementById('stagewrap');if(!wrap||!SplitView)return;
|
|
14405
|
-
const
|
|
15057
|
+
const wrapW=wrap.getBoundingClientRect().width;
|
|
15058
|
+
// EVERY LAYOUT READ HAPPENS HERE, before the first style write, and that ordering is the whole point of
|
|
15059
|
+
// D1 rather than an incidental tidy. All four are ratio-INDEPENDENT — the stage's width, the dock's box,
|
|
15060
|
+
// where the dock starts, and how wide Select/Snap is — so reading them up front costs one layout that the
|
|
15061
|
+
// browser has already done, while a read placed AFTER a write costs a forced synchronous one. The earlier
|
|
15062
|
+
// shape read #ptrBars after writing --dock-pane3d-left, and a custom property invalidates the whole
|
|
15063
|
+
// inherited subtree (in the docked v3d case it also changes padding-left), so that read WAS forced — one
|
|
15064
|
+
// per pointer sample, which is the very quantity D1 was raised about. (Second review, finding 2.)
|
|
15065
|
+
const dock=document.getElementById('bottomDock');
|
|
15066
|
+
const ptr=document.getElementById('ptrBars');
|
|
15067
|
+
const dockW=dock?dock.getBoundingClientRect().width:0;
|
|
15068
|
+
const dockLeft=dock?dock.offsetLeft:0;
|
|
15069
|
+
const ptrW=ptr?ptr.getBoundingClientRect().width:0;
|
|
15070
|
+
const res=SplitView.clampRatio(r,wrapW);
|
|
14406
15071
|
splitRatio=res.ratio;
|
|
14407
15072
|
wrap.style.setProperty('--split-ratio',String(splitRatio));
|
|
14408
15073
|
const bar=document.getElementById('splitBar');
|
|
14409
15074
|
if(bar)bar.setAttribute('aria-valuenow',String(Math.round(splitRatio*100)));
|
|
15075
|
+
// Where the 3D pane starts, expressed as an offset INSIDE #bottomDock, so the dock's left group can sit
|
|
15076
|
+
// on the pane it belongs to instead of in the stage's corner (see the body.split-view dock rules). It is
|
|
15077
|
+
// an offset from the DOCK, not from the stage, because a percentage inside #bottomDock would resolve
|
|
15078
|
+
// against the dock's own width — inset 12px left and 104px right — so plain CSS cannot express it.
|
|
15079
|
+
if(dock&&viewMode==='split'){
|
|
15080
|
+
// DERIVED, not measured. Reading pane3d.offsetLeft here would be a layout read after the --split-ratio
|
|
15081
|
+
// write above, forcing a synchronous layout inside every pointer sample of a drag (measured: +78 layouts,
|
|
15082
|
+
// +80 style recalcs over an 80-step drag). SplitView.paneThreeLeftPx runs the same arithmetic the CSS
|
|
15083
|
+
// does, beside the clampRatio that shares its `usable`, so the two cannot drift. Everything else this
|
|
15084
|
+
// needs was measured above the write. (Codex review, D1; second review, finding 2.)
|
|
15085
|
+
const off=SplitView.paneThreeLeftPx(wrapW,splitRatio)-dockLeft;
|
|
15086
|
+
wrap.style.setProperty('--dock-pane3d-left',off+'px');
|
|
15087
|
+
// …but only let the 3D-active rule USE it while the group still fits on that pane. #ptrBars is flex:none,
|
|
15088
|
+
// so #bottomDockLeft collapses to 0 first and then Select/Snap simply overflows: at the 3D pane's 280px
|
|
15089
|
+
// minimum this pushed it 205px off the right of the stage. Below the threshold we fall back to the
|
|
15090
|
+
// stage-wide dock — the pre-split behaviour — which is honest degradation rather than a broken layout.
|
|
15091
|
+
// Measured from the live #ptrBars because its width follows its own content, not a constant we could pin.
|
|
15092
|
+
// DOCK_GUTTER_PX comes off the budget too: the group is inset by it (see the rules), so counting the full
|
|
15093
|
+
// offset would let the gate promise 12px it has already spent.
|
|
15094
|
+
const room=dockW-off-DOCK_GUTTER_PX-ptrW;
|
|
15095
|
+
// SCHMITT TRIGGER, not a bare comparison. The switch moves the launcher ~730px, and a bare threshold sits
|
|
15096
|
+
// exactly on the drag path: one pixel of hand jitter at the boundary flipped it on every consecutive
|
|
15097
|
+
// pointer sample, teleporting the bottom chrome back and forth. So it takes DOCK_MIN_LEFT_PX + slack to
|
|
15098
|
+
// turn ON and a fall below DOCK_MIN_LEFT_PX to turn OFF — the boundary you must cross to undo a switch is
|
|
15099
|
+
// never the one that caused it, which is what kills the oscillation. (Codex review, D2.)
|
|
15100
|
+
//
|
|
15101
|
+
// …but ONLY on a STREAM. `settled` says this call is a one-shot — the boot clamp, a view switch, the
|
|
15102
|
+
// pointerup that ends a drag, a dblclick, an arrow-key nudge — where there is no hand on the divider and
|
|
15103
|
+
// therefore nothing to oscillate. Charging the turn-on slack there does not prevent a flicker, it just
|
|
15104
|
+
// withholds an arrangement that fits: measured at 1600×900 with the Inspector panel open, a 50/50 split
|
|
15105
|
+
// leaves 78.9px of room — past DOCK_MIN_LEFT_PX, short of the slack — so the chrome sat in the old corner
|
|
15106
|
+
// on every boot at that size, which is the very bug this change exists to fix. The streams (drag samples,
|
|
15107
|
+
// the ResizeObserver, window resize) keep the full trigger. Note the asymmetry is one-way and safe: a
|
|
15108
|
+
// settled call can only ever turn the layout ON in that band, and once on, the stream's own stay-on
|
|
15109
|
+
// threshold is DOCK_MIN_LEFT_PX, so it cannot hand the next drag a state that immediately flips back.
|
|
15110
|
+
const on=dock.classList.contains('dock-per-pane');
|
|
15111
|
+
const need=(on||settled)?DOCK_MIN_LEFT_PX:DOCK_MIN_LEFT_PX+DOCK_HYSTERESIS_PX;
|
|
15112
|
+
dock.classList.toggle('dock-per-pane',room>=need);
|
|
15113
|
+
}else if(dock){
|
|
15114
|
+
// Drop the class whenever this runs outside a split — in practice the BOOT clamp, since applyViewState,
|
|
15115
|
+
// setActivePane, the ResizeObserver and the divider's window-resize listener all carry their own
|
|
15116
|
+
// `viewMode==='split'` guard. (The divider's other callers — pointerup, cancel, dblclick, the arrows —
|
|
15117
|
+
// do NOT carry one; they are simply unreachable outside split, because #splitBar is display:none there.
|
|
15118
|
+
// Stating that rather than implying a guard the code does not have. Second review, finding 9.) The view
|
|
15119
|
+
// TOGGLE leaving split is handled at the guard in applyViewState, which never reaches this function.
|
|
15120
|
+
// Every rule that reads the class is body.split-view-scoped, so leaving it behind is inert today — but a
|
|
15121
|
+
// class that outlives the condition it names is a trap for the next unscoped rule. Only the CLASS is
|
|
15122
|
+
// dropped: --dock-pane3d-left is left on #stagewrap, which is genuinely harmless because every re-entry
|
|
15123
|
+
// to split recomputes it before paint, so there is no stale-value flash to prevent. (Code review.)
|
|
15124
|
+
dock.classList.remove('dock-per-pane');
|
|
15125
|
+
}
|
|
14410
15126
|
if(save)try{localStorage.setItem(SPLIT_RATIO_KEY,String(splitRatio));}catch(_){}
|
|
14411
15127
|
}
|
|
14412
15128
|
function reflectSplitAvailability(){
|
|
@@ -14627,7 +15343,7 @@ viewHandlersLive=true;
|
|
|
14627
15343
|
// once and the Split preference is gone for good. Widening later restores it via onStageResize's edge.
|
|
14628
15344
|
requestedMode=SplitView.sanitizeMode(saved);
|
|
14629
15345
|
try{splitRatio=SplitView.sanitizeRatio(parseFloat(localStorage.getItem(SPLIT_RATIO_KEY)));}catch(_){splitRatio=0.5;}
|
|
14630
|
-
applySplitRatio(splitRatio,false); // clamp against THIS stage, and seed aria-valuenow with it
|
|
15346
|
+
applySplitRatio(splitRatio,false,true); // clamp against THIS stage, and seed aria-valuenow with it (settled: boot)
|
|
14631
15347
|
// SEED THE EDGE DETECTOR, unconditionally and AFTER #vtSplit exists — two bugs live here:
|
|
14632
15348
|
// · splitAvailable starts true, and reflectSplitAvailability ALSO returns true when the button is
|
|
14633
15349
|
// absent. Booting narrow then widening would be true→true: no edge, no restore, and the saved
|