@floless/app 0.152.1 → 0.154.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/floless-server.cjs +5913 -3408
  2. package/dist/internal-workflows/floless-rfi-gmail-send/.floless-owner.json +1 -1
  3. package/dist/internal-workflows/floless-rfi-gmail-send/floless-rfi-gmail-send.flo +4 -2
  4. package/dist/schemas/revit.model.v1.schema.json +5 -0
  5. package/dist/schemas/steel.model.v2.schema.json +1 -1
  6. package/dist/skills/floless-app-new-workflow/SKILL.md +8 -2
  7. package/dist/skills/floless-app-onboarding/SKILL.md +8 -5
  8. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +8 -3
  9. package/dist/skills/floless-app-queue/SKILL.md +23 -4
  10. package/dist/skills/floless-app-steel-takeoff/SKILL.md +18 -2
  11. package/dist/web/agents.js +8 -1
  12. package/dist/web/app.css +107 -5
  13. package/dist/web/app.js +106 -12
  14. package/dist/web/aware.js +424 -57
  15. package/dist/web/chat.css +60 -13
  16. package/dist/web/chat.js +814 -148
  17. package/dist/web/commands-shell.js +200 -21
  18. package/dist/web/commands-steel.js +78 -3
  19. package/dist/web/guide.js +213 -13
  20. package/dist/web/index.html +16 -9
  21. package/dist/web/instructor.js +2 -1
  22. package/dist/web/leave-guard.js +51 -7
  23. package/dist/web/left-pane.js +251 -46
  24. package/dist/web/model-editor-steel-adapter.js +3 -0
  25. package/dist/web/model-viewport.js +14 -6
  26. package/dist/web/revit-editor.js +1 -0
  27. package/dist/web/steel-3d-view.js +15 -7
  28. package/dist/web/steel-editor.html +367 -54
  29. package/dist/web/tekla-structural-grid-adapter.js +7 -1
  30. package/dist/web/tool-updates.js +141 -33
  31. package/dist/web/workspaces.js +125 -21
  32. package/package.json +1 -1
@@ -1387,15 +1387,49 @@ rect.lblhot:focus-visible{outline:2px solid var(--brand);outline-offset:2px;stro
1387
1387
  #panel .mer-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;margin-bottom:4px}
1388
1388
  #panel .mer-title{font-size:10px;font-weight:700;line-height:1.35;letter-spacing:.08em;text-transform:uppercase;color:var(--text)}
1389
1389
  #panel .mer-toolbar,#panel .mer-nav{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:10px}
1390
- #panel .mer-group{margin-top:12px;padding-top:9px;border-top:1px solid var(--line)}
1391
- #panel .mer-group-title{font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--mut);margin-bottom:5px}
1392
- #panel .mer-row{display:grid;grid-template-columns:18px minmax(0,1fr);gap:7px;padding:8px 5px;border-left:3px solid transparent;border-radius:4px}
1390
+ /* The review list: type header -> member row -> end sub-rows. Tokens only; the header, search box and selected-row
1391
+ tint are the Objects list's recipes (#m3dLegend .cat-hdr / .lsearch / .lsel) restated for #panel, which that list's
1392
+ selectors do not reach. The list is its own scroll container (themed by the global * scrollbar rule above) so the
1393
+ nav and Apply stay in reach however many members there are. */
1394
+ #panel .mer-scope{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;margin-top:6px;font-size:11px;line-height:1.4;color:var(--mut)}
1395
+ #panel .mer-scope button{font-size:11px;padding:4px 7px}
1396
+ #panel .mer-search{display:flex;align-items:center;gap:6px;height:26px;margin-top:10px;padding:0 8px;background:var(--bg);border:1px solid var(--line);border-radius:6px}
1397
+ #panel .mer-search:focus-within{border-color:var(--brand)}
1398
+ #panel .mer-search .lsico{color:var(--mut);flex:none;display:inline-flex;align-items:center}
1399
+ #panel .mer-search input{flex:1;min-width:0;width:auto;height:auto;background:transparent;border:0;outline:none;color:var(--text);font:12px var(--ui);padding:0}
1400
+ #panel .mer-search input::placeholder{color:var(--mut)}
1401
+ #panel .mer-search .lsx{width:auto;height:auto;background:transparent;border:0;color:var(--mut);font-size:14px;line-height:1;padding:0 3px;border-radius:4px;cursor:pointer;flex:none;visibility:hidden}
1402
+ #panel .mer-search.has .lsx{visibility:visible}
1403
+ #panel .mer-search .lsx:hover{color:var(--text);background:var(--hover-soft)}
1404
+ #panel .mer-search .lsx:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
1405
+ #panel .mer-list{margin-top:8px;max-height:min(52vh,460px);overflow:auto;padding-right:2px;scrollbar-width:thin;scrollbar-color:var(--scroll) transparent}
1406
+ #panel .mer-empty{padding:10px 4px;font-size:12px;line-height:1.45;color:var(--mut)}
1407
+ #panel .mer-link{display:inline;width:auto;padding:0;border:0;background:transparent;color:var(--brand);font-size:inherit;cursor:pointer;text-decoration:underline}
1408
+ #panel .mer-link:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
1409
+ #panel .mer-group{margin-top:6px;padding-top:6px;border-top:1px solid var(--line)}
1410
+ #panel .mer-group:first-child{margin-top:0;padding-top:0;border-top:0}
1411
+ #panel .mer-type-hdr{display:flex;align-items:center;gap:6px;width:100%;padding:3px 4px;border:0;border-radius:5px;background:transparent;color:var(--text);cursor:pointer;user-select:none;white-space:nowrap;text-align:left}
1412
+ #panel .mer-type-hdr:hover{background:var(--hover-soft)}
1413
+ #panel .mer-type-hdr:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
1414
+ #panel .mer-type-hdr .cat-chevron{font-size:10px;color:var(--mut);width:12px;flex:none;text-align:center}
1415
+ #panel .mer-type-hdr .cat-label{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:12px;font-weight:600;color:var(--text)}
1416
+ #panel .mer-type-hdr .cat-count,#panel .mer-type-hdr .mer-type-ends{font-size:10px;color:var(--mut);font-variant-numeric:tabular-nums}
1417
+ #panel .mer-row{display:block;padding:6px 5px 6px 8px;border-left:3px solid transparent;border-radius:4px;cursor:pointer;user-select:none}
1418
+ #panel .mer-row.sel{background:color-mix(in srgb,var(--brand) 12%,transparent)} /* selected in the model: a tint. Focused (the end the canvas marks) keeps the bar + wash below, so the two read apart */
1393
1419
  #panel .mer-row.focused{background:var(--brand-wash);border-left-color:var(--brand)}
1394
1420
  #panel .mer-row:focus-within{outline:2px solid var(--brand);outline-offset:-2px}
1395
- #panel .mer-row label{display:flex;align-items:flex-start;gap:7px;min-width:0;color:var(--text);font-size:12px;font-weight:600;line-height:1.35;cursor:pointer}
1396
- #panel .mer-row input[type=checkbox]{margin-top:1px;cursor:pointer}
1397
- #panel .mer-evidence{font-size:11px;line-height:1.4;color:var(--mut);margin-top:3px;overflow-wrap:anywhere}
1398
- #panel .mer-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}
1421
+ #panel .mer-mhead{display:flex;align-items:center;gap:7px;min-width:0}
1422
+ #panel .mer-mname{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:600;color:var(--text)}
1423
+ #panel .mer-ckgap{width:14px;flex:none}
1424
+ #panel .mer-end{margin:5px 0 0 16px;padding-left:2px;border-radius:3px}
1425
+ #panel .mer-end.focused{box-shadow:inset 2px 0 0 var(--brand)}
1426
+ #panel .mer-endline{display:flex;align-items:center;gap:7px;min-width:0}
1427
+ #panel .mer-end label{display:inline;min-width:0;color:var(--text);font-size:12px;font-weight:600;line-height:1.35;cursor:pointer}
1428
+ #panel .mer-end-sum{font-size:11px;color:var(--mut);font-variant-numeric:tabular-nums}
1429
+ #panel .mer-row input[type=checkbox]{margin:0;cursor:pointer}
1430
+ #panel .mer-evidence{font-size:11px;line-height:1.4;color:var(--mut);margin-top:3px;margin-left:21px;overflow-wrap:anywhere}
1431
+ #panel .mer-actions{display:flex;gap:6px;flex-wrap:wrap;margin-left:21px}
1432
+ #panel .mer-actions:not(:empty){margin-top:6px}
1399
1433
  #panel .mer-actions button,#panel .mer-toolbar button,#panel .mer-nav button{font-size:11px;padding:4px 7px}
1400
1434
  #panel .mer-actions button.selected{border-color:var(--brand);background:var(--brand-wash);color:var(--text)}
1401
1435
  #panel .mer-primary{width:100%;margin-top:10px;background:var(--brand);border-color:var(--brand);color:var(--brand-ink);font-weight:700}
@@ -1867,6 +1901,19 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
1867
1901
  goes UNDER the view band instead — still the pair together over 3D, just stacked. This rule follows
1868
1902
  the v3d one because split-view carries v3d too. */
1869
1903
  body.split-view #m3dToolBar{left:12px;top:calc(12px + var(--m3d-view-h, 40px) + 8px)}
1904
+ /* ROOM FOR BOTH ON ONE ROW (Split). syncBand() measures the two bands' natural widths against the 3D pane and
1905
+ sets body.bands-inline when view band + model band + the ViewCube's reserve fit, so a wide Split pane reads
1906
+ like plain 3D (model band to the RIGHT of the view band) and only a narrow one stacks. Same offset as the
1907
+ v3d rule above, restated here because the split rule above outranks it. Specificity (0,3,1) beats the split
1908
+ rule's (0,2,1). */
1909
+ body.split-view.bands-inline #m3dToolBar{left:calc(var(--m3d-view-w, 335px) + 22px);top:12px}
1910
+ /* A band whose dropdown is OPEN paints above the other band. Both bands are z-index 59 in one stacking
1911
+ context, so the later one in the DOM won: in Split the model band is re-parented into #pane3d AFTER the view
1912
+ band and covered its open Wireframe/Solid/Realistic menu. The band with no open menu steps DOWN one (58)
1913
+ rather than the open one going up, so both stay under the toasts (60) and the modals. :has() on <body>
1914
+ because the model band lives in #pane3d in 3D/Split but in #stagewrap in 2D. */
1915
+ body:has(#m3dBar .m3dmenu.open) #m3dToolBar:not(:has(.m3dmenu.open,.cmmenu.open)){z-index:58}
1916
+ body:has(#m3dToolBar .m3dmenu.open,#m3dToolBar .cmmenu.open) #m3dBar:not(:has(.m3dmenu.open)){z-index:58}
1870
1917
  /* The model band: same card, always on — Add member and Dimension work in 2D as well as 3D. */
1871
1918
  #m3dToolBar{position:absolute;top:12px;left:12px;display:flex;flex-direction:row;flex-wrap:wrap;gap:2px;align-items:center;z-index:59;
1872
1919
  padding:4px;background:var(--panel);border:1px solid var(--line);border-radius:9px;box-shadow:0 6px 20px rgba(0,0,0,.5)} /* bounded to the stage so narrow windows wrap this local toolbar instead of widening the whole document; above the model-glued label chips (z:3-4, under the 3D chrome — #614), below toasts (60) */
@@ -2623,7 +2670,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
2623
2670
  <span class=stat id=mcStat><span class=k>Members</span><span class=v><b id=mc>0</b></span></span>
2624
2671
  <span class=stat id=wtStat><span class=k>Weight</span><span class=v><b id=wt>0</b> <span id=wtT>tons</span></span></span>
2625
2672
  <span class="stat sub" id=wtLbStat><span class=k></span><span class=v><b id=wtlb>0</b> <span id=wtU>lb</span></span></span>
2626
- <p class=statgrp-note>Counted from the active plan sheet, not the whole model.</p>
2673
+ <p class=statgrp-note id=structNote>Members on this plan sheet. The 3D view counts the whole model.</p>
2627
2674
  </div>
2628
2675
  </div>
2629
2676
  <!-- The collapsed button carries the TOTAL and goes amber with it. Folding a warning away behind a
@@ -4611,6 +4658,7 @@ let findHits=new Set(); // Find-in-model highlight (Workspaces Ctrl+F) — kep
4611
4658
  let undo=[], redo=[];
4612
4659
  let memberEndReview=null;
4613
4660
  let memberEndScan=null;
4661
+ let merCollapsed=new Set((()=>{try{return JSON.parse(localStorage.getItem('floless.merCollapsed')||'[]');}catch{return [];}})()); // member types the review list has folded; its own key, so the Objects list's folds stay the Objects list's
4614
4662
  let viewPropsId=null,viewPropsClaimSig=null,viewPropsCommitting=false; // the saved view the Properties panel shows (a Views-tab click), the selection/tool snapshot it holds the panel under (see viewPropsClaim), and a depth commit in progress (see the panel wrapper)
4615
4663
  let memberEndStatus={known:false,count:null,etag:null,revision:null,scopeSig:null};
4616
4664
  const memberEndKey=f=>f.memberId+'\0'+f.end;
@@ -4618,12 +4666,39 @@ function memberEndHistoryAction(direction){return direction==='redo'?{label:'Red
4618
4666
  function memberEndScope(){const plan=C.plans&&C.plans[C.active];return view3d?{kind:'model-3d'}:{kind:'active-view',viewId:plan?viewIdOf(plan):''};}
4619
4667
  function memberEndScopeSig(scope){return JSON.stringify(scope||memberEndScope());}
4620
4668
  function memberEndUnresolved(report){const c=report&&report.counts||{};return (c.needsReview||0)+(c.stale||0)+(c.notCheckable||0);}
4669
+ // The scope the Quality pill's ends count is read against. While a review is open it is the review's own PINNED scope, not
4670
+ // whatever view the user is looking at now: the count was measured against the scope the review was scanned with, and a
4671
+ // 2D -> 3D switch changes the view, not the answer (it used to fall from 143 to 2, then "—", because the pill kept comparing
4672
+ // the 2D scan to the 3D scope). With no review open there is nothing to pin, so it follows the live view as before.
4673
+ function memberEndStatusScopeSig(){return memberEndScopeSig(memberEndReview?memberEndReview.scope:undefined);}
4621
4674
  function updateMemberEndStatus(){
4622
- const stale=!memberEndStatus.known||memberEndStatus.etag!==serverEtag||memberEndStatus.revision!==serverRevision||memberEndStatus.scopeSig!==memberEndScopeSig();
4675
+ const stale=!memberEndStatus.known||memberEndStatus.etag!==serverEtag||memberEndStatus.revision!==serverRevision||memberEndStatus.scopeSig!==memberEndStatusScopeSig();
4623
4676
  const n=stale?null:memberEndStatus.count,el=document.getElementById('endsStat'),v=document.getElementById('endsCount'),b=document.getElementById('memberEndsB');
4624
4677
  if(v)v.textContent=n==null?'—':String(n);if(el)el.classList.toggle('has',n>0);if(b)b.textContent=n==null?'Check member ends short of supports':'Member ends short of supports ('+n+')';
4625
4678
  }
4626
- function invalidateMemberEndReview(message){memberEndStatus={known:false,count:null,etag:null,revision:null,scopeSig:null};if(memberEndReview||memberEndScan){memberEndReview=null;memberEndScan=null;document.body.classList.remove('member-end-review');modelSelection.clearMembers();render();}updateMemberEndStatus();if(message)toast(message);}
4679
+ // Only a review pinned to one sheet depends on anything outside itself, and only on that sheet still being in the model.
4680
+ // A pure view-mode switch (2D / 3D / Split) can never take a review's scope away, so it never closes the review.
4681
+ const MEMBER_END_SHEET_GONE='The sheet this member-end review was checked on is no longer in the model — check member ends again.';
4682
+ function memberEndReviewCanExist(review){const sc=review&&review.scope;return !sc||sc.kind!=='active-view'||(C.plans||[]).some(pl=>viewIdOf(pl)===sc.viewId);}
4683
+ // While a member-end review is open the 3D view ghosts everything outside the selection, so the member being reviewed stands out.
4684
+ // Ghost is left alone in two cases, and in both nothing is restored: an Isolate is already active (turning Ghost on lifts it, and the
4685
+ // user already has a focused view), or anything changes object visibility after the review's own Ghost -- a Ghost toggle, Isolate, Hide,
4686
+ // Show all, a saved view, a legend hide. That is detected at the sink, not at the commands: the 3D viewport counts every visibility
4687
+ // change (Steel3DView.visibilityRevision), the review records the count right after its own toggle, and close restores Ghost only if the
4688
+ // count is unchanged. A toggle off then on lands on the same value, but the count still moved. Otherwise Ghost goes back to off on close.
4689
+ // Needs the 3D view to exist (it starts on first 3D use), so a review opened in 2D is re-checked when 3D first exists.
4690
+ let memberEndGhost=null;
4691
+ function memberEndVisibilityRevision(){const r=modelEditor.steel.visibilityRevision();return Number.isFinite(r)?r:null;}
4692
+ function memberEndIsolated(){return modelEditor.steel.isIsolated();}
4693
+ function memberEndGhostSync(){
4694
+ if(!view3dReady)return;
4695
+ try{
4696
+ const on=modelEditor.ghostUnselected();
4697
+ if(memberEndReview){if(!memberEndGhost){const iso=memberEndIsolated();if(!on&&!iso)modelEditor.dispatch('model.ghost-unselected');memberEndGhost={prior:on,skip:iso,revision:memberEndVisibilityRevision()};}}
4698
+ else if(memberEndGhost){const was=memberEndGhost;memberEndGhost=null;if(!was.skip&&!was.prior&&on&&was.revision!==null&&memberEndVisibilityRevision()===was.revision)modelEditor.dispatch('model.ghost-unselected');}
4699
+ }catch(e){console.warn('member-end review: could not sync Ghost unselected',e);}
4700
+ }
4701
+ function invalidateMemberEndReview(message){memberEndStatus={known:false,count:null,etag:null,revision:null,scopeSig:null};if(memberEndReview||memberEndScan){memberEndReview=null;memberEndScan=null;document.body.classList.remove('member-end-review');modelSelection.clearMembers();memberEndGhostSync();render();}updateMemberEndStatus();if(message)toast(message);}
4627
4702
  window.invalidateMemberEndReview=invalidateMemberEndReview;
4628
4703
  function memberEndGroup(f){if(f.basis&&f.basis.kind==='drawing'){for(const p of C.plans||[])for(const o of p.memberObservations||[])if(f.basis.origins.some(x=>x.observationId===o.id))return viewLabel(p)+(p.viewKind==='elevation'?' · elevation':'');}return f.basis&&f.basis.kind==='geometry-review'?'3D geometry review':'Model';}
4629
4704
  function memberEndRole(f){return f.role==='horizontal-brace'?'Horizontal brace':f.role==='vertical-brace'?'Vertical brace':f.role==='brace-unknown'?'Brace':'Beam';}
@@ -4735,19 +4810,19 @@ async function memberEndRequest(path,body){
4735
4810
  let res;try{res=await fetch('/api/projects/'+encodeURIComponent(PROJECT)+'/member-ends/'+path,{method:'POST',headers,body:JSON.stringify(body)});}catch(e){if(mid)releaseMutation(mid);throw e;}
4736
4811
  const d=await res.json().catch(()=>({}));if(!res.ok){if(mid)releaseMutation(mid);const error=new Error(d.error||('Member-end request failed ('+res.status+')'));error.code=d.code;error.status=res.status;throw error;}return d;
4737
4812
  }
4738
- async function scanMemberEnds(liveMessage){
4813
+ async function scanMemberEnds(liveMessage,pinnedScope){ // pinnedScope: re-check the scope an open review was scanned with (Undo/Redo, a stale apply) instead of the view you are on; only the explicit "Check this sheet/3D model" rescan omits it
4739
4814
  closeMore();if((memberEndScan&&memberEndScan.busy)||(memberEndReview&&memberEndReview.busy))return;if(!PROJECT){toast('Open this model from a project to check member ends.');return;}
4740
4815
  if(gridMode)setGridMode(false);if(csaxisMode){csaxisMode=false;setCsMode();}if(dimStyleMode)setDimStyleMode(false);if(dimMode){dimMode=false;setDimMode();}modelEditor.steel.disarmFrame3d(); // the review takes the Properties panel, so every other panel takeover lets go of it and of the canvas click — incl. the 3D local-frame tool, left out of #1449 because it arms through the csSyncF3d seam (#1412/#1413)
4741
4816
  revealInspector(); // the review list this scan is about to render IS the command's output — a collapsed Inspector would swallow it, progress and findings alike (#1352)
4742
4817
  memberEndScan={busy:true,error:false,live:'Checking member ends against drawing and model evidence…'};panel();
4743
4818
  const b=document.getElementById('memberEndsB');if(b)b.textContent='Checking member ends…';
4744
- try{await window.flushContract();const scope=memberEndScope();const d=await memberEndRequest('scan',{scope});serverEtag=d.etag;serverRevision=d.storeRevision;memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(scope)};
4745
- if(!d.report.findings.length){memberEndReview=null;memberEndScan={busy:false,error:false,live:'No member ends are short of support centerlines.'};document.body.classList.remove('member-end-review');updateMemberEndStatus();panel();const settled=memberEndScan;if(b){b.classList.add('ok');b.textContent='No short member ends ✓';}setTimeout(()=>{if(memberEndScan===settled){memberEndScan=null;panel();}if(b)b.classList.remove('ok');updateMemberEndStatus();},1500);return;}
4746
- const chosen=memberEndChoicesForReport(d.report),selected=new Set();for(const f of d.report.findings)if(f.classification==='needs-review'&&f.targets&&f.targets.length===1&&!f.geometryOnly)selected.add(memberEndKey(f));
4747
- memberEndScan=null;memberEndReview={report:d.report,scope,chosen,selected,focus:0,busy:false,undoToken:d.undo&&d.undo.token||null,undoDirection:d.undo&&d.undo.direction||null,live:typeof liveMessage==='string'?liveMessage:'Check each endpoint against its drawing or model evidence.'};document.body.classList.add('member-end-review');modelSelection.clearMembers();focusMemberEnd(0);updateMemberEndStatus();
4748
- }catch(e){memberEndReview=null;memberEndStatus={known:false,count:null,etag:null,revision:null,scopeSig:null};document.body.classList.remove('member-end-review');modelSelection.clearMembers();memberEndScan={busy:false,error:true,live:e&&e.message?e.message:'Could not check member ends.'};updateMemberEndStatus();panel();toast(memberEndScan.live);}
4819
+ try{const open=memberEndReview,prior=pinnedScope&&open&&memberEndScopeSig(open.scope)===memberEndScopeSig(pinnedScope)?open:null;await window.flushContract();const scope=pinnedScope||memberEndScope();const d=await memberEndRequest('scan',{scope});serverEtag=d.etag;serverRevision=d.storeRevision;memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(scope)};
4820
+ if(!d.report.findings.length){memberEndReview=null;memberEndGhostSync();memberEndScan={busy:false,error:false,live:'No member ends are short of support centerlines.'};document.body.classList.remove('member-end-review');updateMemberEndStatus();panel();const settled=memberEndScan;if(b){b.classList.add('ok');b.textContent='No short member ends ✓';}setTimeout(()=>{if(memberEndScan===settled){memberEndScan=null;panel();}if(b)b.classList.remove('ok');updateMemberEndStatus();},1500);return;}
4821
+ const chosen=memberEndChoicesForReport(d.report,prior&&prior.chosen),selected=new Set();for(const f of d.report.findings){const key=memberEndKey(f);if(prior){if(prior.selected.has(key)&&f.classification==='needs-review'&&chosen.get(key)&&memberEndTargetEqual(chosen.get(key),prior.chosen.get(key)))selected.add(key);}else if(f.classification==='needs-review'&&f.targets&&f.targets.length===1&&!f.geometryOnly)selected.add(key);}
4822
+ memberEndScan=null;memberEndReview={report:d.report,scope,chosen,selected,focus:0,query:prior?prior.query||'':'',anchor:null,busy:false,undoToken:d.undo&&d.undo.token||null,undoDirection:d.undo&&d.undo.direction||null,live:typeof liveMessage==='string'?liveMessage:'Check each endpoint against its drawing or model evidence.'};document.body.classList.add('member-end-review');modelSelection.clearMembers();focusMemberEnd(0);memberEndGhostSync();updateMemberEndStatus();
4823
+ }catch(e){memberEndReview=null;memberEndGhostSync();memberEndStatus={known:false,count:null,etag:null,revision:null,scopeSig:null};document.body.classList.remove('member-end-review');modelSelection.clearMembers();memberEndScan={busy:false,error:true,live:e&&e.message?e.message:'Could not check member ends.'};updateMemberEndStatus();panel();toast(memberEndScan.live);}
4749
4824
  }
4750
- function closeMemberEndReview(){if(memberEndReview&&memberEndReview.busy){memberEndReview.live='Finish the current member-end action before closing.';panel();return;}memberEndReview=null;document.body.classList.remove('member-end-review');modelSelection.clearMembers();render();moreBtn.focus();}
4825
+ function closeMemberEndReview(){if(memberEndReview&&memberEndReview.busy){memberEndReview.live='Finish the current member-end action before closing.';panel();return;}memberEndReview=null;document.body.classList.remove('member-end-review');modelSelection.clearMembers();memberEndGhostSync();render();moreBtn.focus();}
4751
4826
  // Ends Apply would extend right now: ticked, still needing review, with a chosen support. The one thing closing the
4752
4827
  // review loses; every decision already made is on the server, and so is Undo (the scan hands its token back).
4753
4828
  function memberEndTicked(review){let n=0;for(const f of review.report.findings){const key=memberEndKey(f);if(f.classification==='needs-review'&&review.selected.has(key)&&review.chosen.get(key))n++;}return n;}
@@ -4765,7 +4840,7 @@ function memberEndYieldPanel(name,arm,btnId){
4765
4840
  leaveMemberEndReview();return true;
4766
4841
  }
4767
4842
  const MEMBER_END_REOPEN='open ⋯ → Model checks and choose Member ends short of supports'; // the button's own label gains a count once a check has run, so name the stable words
4768
- function leaveMemberEndReview(message){memberEndReview=null;document.body.classList.remove('member-end-review');modelSelection.clearMembers();toast(message||'Member-end review closed. Decisions you applied are saved; '+MEMBER_END_REOPEN+' to pick up where you left off.');}
4843
+ function leaveMemberEndReview(message){memberEndReview=null;document.body.classList.remove('member-end-review');modelSelection.clearMembers();memberEndGhostSync();toast(message||'Member-end review closed. Decisions you applied are saved; '+MEMBER_END_REOPEN+' to pick up where you left off.');}
4769
4844
  // After the question is answered the review's own controls are gone, so focus goes to the first usable control of the
4770
4845
  // pane just opened, or (a pane with nothing to operate, like Set local axes' click prompt) to the command's own button
4771
4846
  // when it is on screen, else to the ⋯ menu that holds it.
@@ -4783,13 +4858,26 @@ async function memberEndLeaveApply(){const r=memberEndReview,leaving=r&&r.leavin
4783
4858
  // Undo is not lost: the next check hands it back (the scan returns the newest resolution's token).
4784
4859
  const u=document.getElementById('undoToast');if(u){clearTimeout(u._h);u.style.opacity='0';u.style.visibility='hidden';}
4785
4860
  r.leaving=null;leaveMemberEndReview('Extended '+n+' member end'+(n===1?'':'s')+' to support centerlines and closed the review. To undo it or carry on, '+MEMBER_END_REOPEN+'.');leaving.arm();focusTakeoverPane(leaving.btnId);}
4786
- function focusMemberEnd(index){if(!memberEndReview||memberEndReview.busy)return;const rows=memberEndReview.report.findings;if(!rows.length)return;memberEndReview.focus=(index+rows.length)%rows.length;const f=rows[memberEndReview.focus];modelSelection.replaceMembers([f.memberId]);render();queueMicrotask(()=>document.querySelector('.mer-row.focused input,.mer-row.focused button')?.focus({preventScroll:true}));}
4787
- function chooseMemberEndTarget(key,index){if(!memberEndReview||memberEndReview.busy)return;const f=memberEndReview.report.findings.find(x=>memberEndKey(x)===key);const t=f&&f.targets&&f.targets[index];if(!f||!t)return;memberEndReview.chosen.set(key,t);memberEndReview.selected.add(key);memberEndReview.live='Selected '+memberEndTargetName(t)+' for '+f.memberId+' end '+(f.end+1)+'.';panel();render();}
4861
+ // Focus a finding (the canvas marks it) and pick its MEMBER in the model. `opts` carries a row click's modifiers (Ctrl/Cmd toggles,
4862
+ // Shift ranges over `opts.order`, the members the list draws); Previous/Next, a scan and a target choice pass none and replace.
4863
+ // Keyboard focus follows into the row's first control only for those non-pointer routes: a click leaves it on the row it landed on.
4864
+ function focusMemberEnd(index,opts){
4865
+ if(!memberEndReview||memberEndReview.busy)return;const r=memberEndReview,rows=r.report.findings;if(!rows.length)return;
4866
+ opts=opts||{};r.focus=(index+rows.length)%rows.length;const f=rows[r.focus];
4867
+ const pick=memberEndPickSelection({mode:opts.shift?'range':opts.ctrl?'toggle':'plain',current:selIds,target:f.memberId,anchor:r.anchor,order:opts.order||memberEndVisibleOrder(r,memberEndCurrentView(r))});
4868
+ r.anchor=pick.anchor;modelSelection.replaceMembers(pick.ids,opts.pointer?'inspector':'programmatic');memberEndRepaint();
4869
+ queueMicrotask(()=>{
4870
+ if(opts.pointer){const row=[...document.querySelectorAll('#panel [data-mer-member]')].find(x=>x.dataset.merMember===f.memberId);if(row)row.focus({preventScroll:true});return;}
4871
+ document.querySelector('#panel .mer-member.focused .mer-end.focused input,#panel .mer-member.focused input,#panel .mer-member.focused button')?.focus({preventScroll:true});
4872
+ document.querySelector('#panel .mer-member.focused')?.scrollIntoView?.({block:'nearest'});
4873
+ });
4874
+ }
4875
+ function chooseMemberEndTarget(key,index){if(!memberEndReview||memberEndReview.busy)return;const f=memberEndReview.report.findings.find(x=>memberEndKey(x)===key);const t=f&&f.targets&&f.targets[index];if(!f||!t)return;memberEndReview.chosen.set(key,t);memberEndReview.selected.add(key);memberEndReview.live='Selected '+memberEndTargetName(t)+' for '+f.memberId+' end '+(f.end+1)+'.';panel();memberEndRepaint();}
4788
4876
  async function applyMemberEndSelection(){if(!memberEndReview||memberEndReview.busy)return;const selections=[];for(const f of memberEndReview.report.findings){const key=memberEndKey(f),target=memberEndReview.chosen.get(key);if(f.classification==='needs-review'&&memberEndReview.selected.has(key)&&target)selections.push({findingId:f.findingId,contextHash:f.contextHash,memberId:f.memberId,end:f.end,target});}if(!selections.length)return;
4789
- const review=memberEndReview;review.busy=true;review.live='Extending selected member ends…';panel();try{const d=await memberEndRequest('apply',{scope:review.scope,selections});installMemberEndContract(d.contract,d.etag,d.storeRevision);if(memberEndReview!==review)return scanMemberEnds();const previousChosen=review.chosen;review.report=d.report;review.undoToken=d.undoToken;review.undoDirection='undo';review.selected.clear();review.chosen=memberEndChoicesForReport(d.report,previousChosen);review.busy=false;review.live='Extended '+selections.length+' member end'+(selections.length===1?'':'s')+' to support centerlines.';memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(review.scope)};updateMemberEndStatus();panel();undoToast(review.live,()=>undoMemberEndResolution());}catch(e){if(memberEndReview===review){review.busy=false;review.live=e.message||'The model changed — check member ends again.';panel();}toast(e.message||'Could not extend member ends.');}}
4790
- async function keepMemberEnd(f){if(!memberEndReview||memberEndReview.busy)return;const review=memberEndReview;review.busy=true;panel();try{const d=await memberEndRequest('keep-short',{scope:review.scope,findingId:f.findingId,contextHash:f.contextHash,memberId:f.memberId,end:f.end,reason:'other-reviewed'});installMemberEndContract(d.contract,d.etag,d.storeRevision);if(memberEndReview!==review)return scanMemberEnds();review.report=d.report;review.undoToken=d.undoToken;review.undoDirection='undo';review.selected.delete(memberEndKey(f));review.busy=false;review.live='Kept '+f.memberId+' end '+(f.end+1)+' short.';memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(review.scope)};updateMemberEndStatus();panel();}catch(e){if(memberEndReview===review){review.busy=false;review.live=e.message||'Could not keep this member end short.';panel();}}}
4791
- async function restoreMemberEnd(f){if(!memberEndReview||memberEndReview.busy)return;const review=memberEndReview;review.busy=true;panel();try{const d=await memberEndRequest('restore',{scope:review.scope,findingId:f.findingId,contextHash:f.contextHash,memberId:f.memberId,end:f.end});installMemberEndContract(d.contract,d.etag,d.storeRevision);if(memberEndReview!==review)return scanMemberEnds();review.report=d.report;review.undoToken=d.undoToken;review.undoDirection='undo';review.busy=false;review.live='Restored the traced endpoint for '+f.memberId+'.';memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(review.scope)};updateMemberEndStatus();panel();}catch(e){if(memberEndReview===review){review.busy=false;review.live=e.message||'Could not restore the traced endpoint.';panel();}}}
4792
- async function undoMemberEndResolution(){if(!memberEndReview||memberEndReview.busy||!memberEndReview.undoToken)return;const review=memberEndReview,token=review.undoToken;review.busy=true;review.live='Updating member-end history…';panel();try{const d=await memberEndRequest('undo',{token});installMemberEndContract(d.contract,d.etag,d.storeRevision);const next=memberEndHistoryAction(d.direction),completed=d.direction==='redo'?'Undid member-end changes':'Redid member-end changes';review.busy=false;await scanMemberEnds(completed+' · '+next.label+' is available');}catch(e){if(memberEndReview===review){review.busy=false;if(e.code==='member-end-undo-unavailable'){review.undoToken=null;review.undoDirection=null;review.live='This history action is no longer available. Check member ends again.';}else review.live='Could not confirm the history action. Check member ends again before retrying.';panel();}toast(e.message||'Could not update member-end history.');}}
4877
+ const review=memberEndReview;review.busy=true;review.live='Extending selected member ends…';panel();try{const d=await memberEndRequest('apply',{scope:review.scope,selections});installMemberEndContract(d.contract,d.etag,d.storeRevision);if(memberEndReview!==review)return scanMemberEnds(undefined,review.scope);const previousChosen=review.chosen;review.report=d.report;review.undoToken=d.undoToken;review.undoDirection='undo';review.selected.clear();review.chosen=memberEndChoicesForReport(d.report,previousChosen);review.busy=false;review.live='Extended '+selections.length+' member end'+(selections.length===1?'':'s')+' to support centerlines.';memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(review.scope)};updateMemberEndStatus();panel();undoToast(review.live,()=>undoMemberEndResolution());}catch(e){if(memberEndReview===review){review.busy=false;review.live=e.message||'The model changed — check member ends again.';panel();}toast(e.message||'Could not extend member ends.');}}
4878
+ async function keepMemberEnd(f){if(!memberEndReview||memberEndReview.busy)return;const review=memberEndReview;review.busy=true;panel();try{const d=await memberEndRequest('keep-short',{scope:review.scope,findingId:f.findingId,contextHash:f.contextHash,memberId:f.memberId,end:f.end,reason:'other-reviewed'});installMemberEndContract(d.contract,d.etag,d.storeRevision);if(memberEndReview!==review)return scanMemberEnds(undefined,review.scope);review.report=d.report;review.undoToken=d.undoToken;review.undoDirection='undo';review.selected.delete(memberEndKey(f));review.busy=false;review.live='Kept '+f.memberId+' end '+(f.end+1)+' short.';memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(review.scope)};updateMemberEndStatus();panel();}catch(e){if(memberEndReview===review){review.busy=false;review.live=e.message||'Could not keep this member end short.';panel();}}}
4879
+ async function restoreMemberEnd(f){if(!memberEndReview||memberEndReview.busy)return;const review=memberEndReview;review.busy=true;panel();try{const d=await memberEndRequest('restore',{scope:review.scope,findingId:f.findingId,contextHash:f.contextHash,memberId:f.memberId,end:f.end});installMemberEndContract(d.contract,d.etag,d.storeRevision);if(memberEndReview!==review)return scanMemberEnds(undefined,review.scope);review.report=d.report;review.undoToken=d.undoToken;review.undoDirection='undo';review.busy=false;review.live='Restored the traced endpoint for '+f.memberId+'.';memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(review.scope)};updateMemberEndStatus();panel();}catch(e){if(memberEndReview===review){review.busy=false;review.live=e.message||'Could not restore the traced endpoint.';panel();}}}
4880
+ async function undoMemberEndResolution(){if(!memberEndReview||memberEndReview.busy||!memberEndReview.undoToken)return;const review=memberEndReview,token=review.undoToken;review.busy=true;review.live='Updating member-end history…';panel();try{const d=await memberEndRequest('undo',{token});installMemberEndContract(d.contract,d.etag,d.storeRevision);const next=memberEndHistoryAction(d.direction),completed=d.direction==='redo'?'Undid member-end changes':'Redid member-end changes';review.busy=false;await scanMemberEnds(completed+' · '+next.label+' is available',review.scope);}catch(e){if(memberEndReview===review){review.busy=false;if(e.code==='member-end-undo-unavailable'){review.undoToken=null;review.undoDirection=null;review.live='This history action is no longer available. Check member ends again.';}else review.live='Could not confirm the history action. Check member ends again before retrying.';panel();}toast(e.message||'Could not update member-end history.');}}
4793
4881
  // Selection is MODEL-WIDE, not per-sheet: the 3D shows every plan, so a pick / box-select / Ctrl-click can
4794
4882
  // span sheets. byId + selArr therefore search ALL plans (not just the active P) so the inspector + edits see
4795
4883
  // the whole selection — else selecting a roof (S-203) member while S-202 is active shows nothing, and a
@@ -4854,6 +4942,31 @@ const selArr=()=>[...selIds].map(byId).filter(Boolean);
4854
4942
  // The active-sheet subset of the selection — for 2D coordinate/decoration ops (handles, badges, move/copy,
4855
4943
  // 2D drag/zoom) that draw or compute in THIS sheet's px space, where an off-sheet member's wp is meaningless.
4856
4944
  const sel2d=()=>P.members.filter(m=>selIds.has(m.id));
4945
+ /** The order the 2D selection number badges read in: LEFT to RIGHT, then BOTTOM to TOP within a column. `sel2d()` is
4946
+ * plan-internal order (the order members were drawn/imported), so five parallel beams picked left to right were
4947
+ * numbered 2,3,1,4,5. Members whose centres fall within `tol` model units in X are ONE column (anchored on the
4948
+ * column's first member, so a drifting row cannot chain into the next column); inside a column the lower one on the
4949
+ * SCREEN comes first. Plan Y grows DOWN the screen (no flip transform on the plan SVG), so bottom-first is Y
4950
+ * descending. Pure: returns a new array and never touches the selection itself. */
4951
+ function orderForSelectionBadges(list,centreOf,tol){
4952
+ const t=Number.isFinite(tol)?tol:8,a=list.map(m=>({m,c:centreOf(m)})).sort((p,q)=>p.c[0]-q.c[0]);
4953
+ const out=[];let col=[],x0=0;
4954
+ const flush=()=>{col.sort((p,q)=>q.c[1]-p.c[1]);for(const e of col)out.push(e.m);col=[];};
4955
+ for(const e of a){if(col.length&&e.c[0]-x0>t)flush();if(!col.length)x0=e.c[0];col.push(e);}
4956
+ flush();return out;}
4957
+ /** Split view: does the 3D pane have room for the view band AND the model band on ONE row, clear of the ViewCube?
4958
+ * The model band sits at `viewW + 22` (12 left inset + 10 gap) and must end 124px short of the pane's right edge
4959
+ * (12 inset + 84 cube + 12 inset + 16 gap — the same reserve model-editor.css caps the view band with). Pure. */
4960
+ function bandsFitInline(o){const {paneW,viewW,bandW}=o,cubeReserve=o.cubeReserve==null?124:o.cubeReserve,lead=o.lead==null?22:o.lead;
4961
+ return [paneW,viewW,bandW].every(n=>Number.isFinite(n)&&n>0)&&viewW+lead+bandW<=paneW-cubeReserve;}
4962
+ /** The UNWRAPPED width of a floating band: every shown child + its margins + the flex gaps + padding and border.
4963
+ * offsetWidth cannot answer this — it is the wrapped width once the pane is narrow, which is exactly when the
4964
+ * question matters. `cs` is injectable so a test can drive it without a layout engine. */
4965
+ function naturalBarWidth(el,cs=getComputedStyle){
4966
+ const st=cs(el),px=v=>parseFloat(v)||0,kids=[...el.children].filter(k=>k.offsetWidth>0);
4967
+ let w=px(st.paddingLeft)+px(st.paddingRight)+px(st.borderLeftWidth)+px(st.borderRightWidth)+px(st.columnGap)*Math.max(0,kids.length-1);
4968
+ for(const k of kids){const ks=cs(k);w+=k.offsetWidth+px(ks.marginLeft)+px(ks.marginRight);}
4969
+ return w;}
4857
4970
  /* The THIRD accessor, and the one for consumers that need neither sheet (#942).
4858
4971
  `sel2d()` is the 2D coordinate accessor and `selArr()` the model-wide one — but `selArr()` still resolves
4859
4972
  through a PROJECTION, so on a model whose only sheet is refused it resolves nothing at all, while the 3D
@@ -9005,11 +9118,13 @@ function render(){
9005
9118
  const prev=(nu&&sh)?(nu+'-'+sh):(co.text||'');
9006
9119
  s+=cob(kc,co.text||nu,co.disp,sh,prev,kl+' '+(co.text||nu||'')+(sh?' → '+sh:'')+hint(sh,prev));}
9007
9120
  }
9008
- // numbered badges on the selected members (1..N in selection order; coincident ones fan out so duplicates are countable)
9121
+ // numbered badges on the selected members (1..N left→right then bottom→up, see orderForSelectionBadges; coincident ones fan out so duplicates are countable)
9009
9122
  // sized in 1/zoom units → constant on screen at any zoom (updateBadges keeps them in sync while zooming)
9010
9123
  const selM=sel2d();
9011
- if(selM.length>=2){const mid=m=>{const v=memberViewLine(m);return [(v[0][0]+v[1][0])/2,(v[0][1]+v[1][1])/2];};const grp={};const R=12/zoom,F=13/zoom; // badge sits on the DRAWN line (offset brace included)
9012
- selM.forEach((m,idx)=>{if(!visible2d(m))return;const c=mid(m),k=Math.round(c[0]/8)+','+Math.round(c[1]/8);(grp[k]=grp[k]||[]).push({idx,c});});
9124
+ if(selM.length>=2){const mid=m=>{const v=memberViewLine(m);return [(v[0][0]+v[1][0])/2,(v[0][1]+v[1][1])/2];};const grp={};
9125
+ const selB=orderForSelectionBadges(selM,mid,8); // number the badges left→right then bottom→up, not in plan-internal order
9126
+ const R=12/zoom,F=13/zoom; // badge sits on the DRAWN line (offset brace included)
9127
+ selB.forEach((m,idx)=>{if(!visible2d(m))return;const c=mid(m),k=Math.round(c[0]/8)+','+Math.round(c[1]/8);(grp[k]=grp[k]||[]).push({idx,c});});
9013
9128
  for(const k in grp){const a=grp[k],n=a.length;a.forEach((it,j)=>{const x=it.c[0]+(j-(n-1)/2)*R*2,y=it.c[1];const d=`data-bx="${it.c[0]}" data-fi="${j}" data-gn="${n}"`;
9014
9129
  s+=`<circle class=numbg ${d} cx="${x}" cy="${y}" r="${R}"/><text class=numtx ${d} x="${x}" y="${y}" style="font-size:${F}px">${it.idx+1}</text>`;});}}
9015
9130
  s+=renderDims();
@@ -9196,6 +9311,19 @@ const PLAN_STATS=['mcStat','wtStat','dupStat'];
9196
9311
  function hideStat(id){const el=document.getElementById(id);if(el)el.style.display='none';}
9197
9312
  /** …and put it back. The state stats() hides for is REVERSIBLE, so the hiding has to be too — see there. */
9198
9313
  function showStat(id){const el=document.getElementById(id);if(el)el.style.display='';}
9314
+ /** Which members the Structure readouts count. In a PLAN view they are that sheet's; in 3D (and in Split with the 3D
9315
+ * pane active) the owner wants the whole model — a 3D scene shows every member, so a per-sheet number beside it
9316
+ * reads as a wrong count. 'none' = a plan is wanted but the model has no plan view to be active. Pure. */
9317
+ function structureScope(is3d,noPlanView){return is3d?'model':noPlanView?'none':'sheet';}
9318
+ function structureMembers(scope,planMembers,modelMembers){return scope==='model'?modelMembers:planMembers;}
9319
+ /** Plain-English note + tooltip for the Structure panel, stating which scope the numbers are. */
9320
+ function structureCopy(scope,sheetName){
9321
+ if(scope==='model')return {note:'All members in the model, across every plan sheet.',tip:'How much steel is in the whole model — members and weight'};
9322
+ const nm=sheetName?' ('+sheetName+')':'';
9323
+ return {note:'Members on this plan sheet'+nm+'. The 3D view counts the whole model.',tip:'How much steel is on this plan sheet'+nm+' — members and weight'};}
9324
+ /** Repaint the Structure readouts when the VIEW changes (2D / 3D / Split, active pane) — those do not render(),
9325
+ * and stats() is otherwise only reached from render(). Quiet before the model has loaded. */
9326
+ function refreshStructureStats(){if(C&&P)stats();}
9199
9327
  function stats(){
9200
9328
  // FIRST, and deliberately ABOVE the early return below: the RFI count is PROJECT-scoped (#1090), so it
9201
9329
  // is honest in exactly the state the per-sheet numbers are not. Every writer of `#rc` sat AFTER that
@@ -9214,18 +9342,24 @@ function stats(){
9214
9342
  // repeat the reason.
9215
9343
  //
9216
9344
  // A model with no plan view cannot report plan-derived counts honestly. A projected plan can.
9217
- if(NO_PLAN_VIEW){for(const id of PLAN_STATS)hideStat(id);return;}
9345
+ const scope=structureScope(view3d,NO_PLAN_VIEW); // 3D counts the whole model, so a 3D-only model (no plan view) still reads
9346
+ if(scope==='none'){for(const id of PLAN_STATS)hideStat(id);return;}
9218
9347
  // REVERSIBLE, and this line is the whole of it: hideStat writes an INLINE display:none that nothing else
9219
9348
  // clears, so without this the first no-plan-view sheet would hide these four permanently — including
9220
9349
  // after the user activates a plan sheet again, which setPlan() allows and which is the ordinary way back.
9221
9350
  // (Three, not four: `rfiStat` left this set in #1090 and is painted unconditionally above.)
9222
9351
  for(const id of PLAN_STATS)showStat(id);
9223
- document.getElementById('mc').textContent=P.members.length;
9352
+ const counted=structureMembers(scope,P.members,allMembers());
9353
+ document.getElementById('mc').textContent=counted.length;
9354
+ {const cp=structureCopy(scope,viewLabel(C.plans[C.active])||P.sheet||''),note=document.getElementById('structNote'),btn=document.getElementById('structBtn');
9355
+ if(note&&note.textContent!==cp.note)note.textContent=cp.note;if(btn)btn.setAttribute('data-tip',cp.tip);}
9224
9356
  // In the project's own units: feet x lb/ft -> lb -> short tons, or metres x kg/m -> kg -> tonnes.
9225
9357
  // A member with no billable weight is simply skipped here; it is counted by `paintRfiStat` above,
9226
9358
  // over the whole project rather than this sheet.
9227
9359
  const metric=displayUnits()===DisplayUnits.MM;
9228
- let w=0; for(const m of P.members){const wpf=_wtBill(m.profile); if(wpf!=null)w+=_propMass(ensureMeta(m),wpf);}
9360
+ // Model scope walks the CANONICAL members: _lenMm/_lenFt resolve through the model by id, so every member weighs,
9361
+ // not just the ones projected onto this sheet — and ensureMeta (which mutates) stays out of a read-only repaint.
9362
+ let w=0; for(const m of counted){const wpf=_wtBill(m.profile); if(wpf!=null)w+=_propMass(scope==='model'?m:ensureMeta(m),wpf);}
9229
9363
  document.getElementById('wt').textContent=(w/(metric?1000:2000)).toFixed(1);
9230
9364
  document.getElementById('wtlb').textContent=Math.round(w).toLocaleString();
9231
9365
  document.getElementById('wtT').textContent=_uw().tonnage;
@@ -9425,7 +9559,7 @@ function inspectorHeightNotes(m,canonical){
9425
9559
  const when=typeof a.answeredAt==='string'&&!Number.isNaN(Date.parse(a.answeredAt))?' on '+new Date(a.answeredAt).toLocaleDateString():'';
9426
9560
  const said=a.how==='typed'?'You typed '+(a.typed||fmtDispElev(z.known)):'You confirmed '+(a.shownAs||fmtDispElev(z.known));
9427
9561
  const text=document.createElement('span');
9428
- const fromPicture=a.basis==='read-of-your-picture'?' (the read’s reading of your picture)':'';
9562
+ const fromPicture=a.basis==='read-of-your-picture'?' (the read’s reading of your picture)':a.basis==='read-of-your-note'?' (the read’s reading of your note)':'';
9429
9563
  text.textContent=' '+said+fromPicture+' for “'+String(a.label||'this end')+'” when the drawing read asked'+when+'. FloLess uses your answer as this height.';
9430
9564
  box.append(chip,text);
9431
9565
  // #1906: the person's source note and pictures travel with the answer, so the model says why.
@@ -9517,24 +9651,157 @@ function refPanelPreempted(){
9517
9651
  if(view3d&&v&&modelEditor.steel.frameArmed&&modelEditor.steel.frameArmed())return 'mode';
9518
9652
  return null;
9519
9653
  }
9654
+ // Review list view-model: type -> member -> ends, narrowed by a filter. PURE (no DOM, no globals) so a test can run
9655
+ // the shipped function. `typeOf(finding)` -> {k,label}; `textOf(finding)` is the reason text the filter also matches;
9656
+ // `typeOrder` is the Objects tree's type order. The filter matches a member's mark, its type and any end's reason
9657
+ // text, every space-separated word having to hit. `endOrder` is the Previous/Next walk (every shown end, in the order
9658
+ // the list draws them); `order` is the member order Shift+click ranges over.
9659
+ function memberEndBuildView(findings,opts){
9660
+ opts=opts||{};
9661
+ const typeOf=opts.typeOf||(()=>({k:'beam',label:'Beam'})),textOf=opts.textOf||(()=>''),typeOrder=opts.typeOrder||[];
9662
+ const tokens=String(opts.query||'').trim().toLowerCase().split(/\s+/).filter(Boolean);
9663
+ const byMember=new Map();
9664
+ (findings||[]).forEach((f,i)=>{
9665
+ let m=byMember.get(f.memberId);
9666
+ if(!m){const t=typeOf(f)||{};m={memberId:f.memberId,typeKey:t.k||'beam',typeLabel:t.label||'Beam',ends:[]};byMember.set(f.memberId,m);}
9667
+ m.ends.push({f,i});
9668
+ });
9669
+ const groups=new Map();let shown=0;
9670
+ for(const m of byMember.values()){
9671
+ m.ends.sort((a,b)=>a.f.end-b.f.end);
9672
+ if(tokens.length){const hay=[m.memberId,m.typeLabel].concat(m.ends.map(e=>textOf(e.f))).join(' ').toLowerCase();if(!tokens.every(t=>hay.includes(t)))continue;}
9673
+ shown++;
9674
+ let g=groups.get(m.typeKey);if(!g){g={key:m.typeKey,label:m.typeLabel,items:[],endCount:0};groups.set(m.typeKey,g);}
9675
+ g.items.push(m);g.endCount+=m.ends.length;
9676
+ }
9677
+ const rank=k=>{const at=typeOrder.indexOf(k);return at<0?typeOrder.length:at;};
9678
+ const list=[...groups.values()].map((g,n)=>({g,n})).sort((a,b)=>rank(a.g.key)-rank(b.g.key)||a.n-b.n).map(x=>x.g);
9679
+ const order=[],endOrder=[];
9680
+ for(const g of list)for(const m of g.items){order.push(m.memberId);for(const e of m.ends)endOrder.push(e);}
9681
+ return {groups:list,order,endOrder,shownMembers:shown,totalMembers:byMember.size,query:tokens.join(' ')};
9682
+ }
9683
+ // Row selection is the members selected in the MODEL; ticks are a separate set (state.selected) and never come through here.
9684
+ // plain = replace; toggle (Ctrl/Cmd) = flip this member; range (Shift) = every member drawn between the anchor and this one.
9685
+ // `order` is only what the list currently draws, so a collapsed or filtered-out member is never swept into a range.
9686
+ function memberEndPickSelection(o){
9687
+ const cur=[...(o.current||[])],order=o.order||[];
9688
+ if(o.mode==='toggle')return {ids:cur.includes(o.target)?cur.filter(id=>id!==o.target):cur.concat([o.target]),anchor:o.target};
9689
+ if(o.mode==='range'&&o.anchor&&order.includes(o.anchor)&&order.includes(o.target)){
9690
+ const a=order.indexOf(o.anchor),b=order.indexOf(o.target);
9691
+ return {ids:order.slice(Math.min(a,b),Math.max(a,b)+1),anchor:o.anchor};
9692
+ }
9693
+ return {ids:[o.target],anchor:o.target};
9694
+ }
9695
+ function memberEndTriState(tickable,ticked){return !tickable?'na':!ticked?'none':ticked===tickable?'all':'some';}
9696
+ // One reason shown once under the member line, but only when every end shares it AND none has a chosen support (those are end-specific).
9697
+ function memberEndSharedReason(ends,textOf,hasTarget){
9698
+ if(ends.length<2||ends.some(e=>hasTarget(e.f)))return '';
9699
+ const first=ends[0].f,text=textOf(first);
9700
+ return text&&ends.every(e=>e.f.classification===first.classification&&textOf(e.f)===text)?text:'';
9701
+ }
9702
+ function memberEndEvidenceText(f){return memberEndReason(f)||memberEndClassification(f);}
9703
+ // Type of a reviewed member, from the same source the Objects tree groups by (memberTypeOf / memberTypeRecords). A finding whose
9704
+ // member is not in the model any more still gets a type from its recorded role rather than falling out of the list.
9705
+ function memberEndTypeResolver(){
9706
+ const byId=new Map();
9707
+ for(const m of (C&&C.members)||[])if(m&&m.id!=null)byId.set(m.id,m);
9708
+ for(const pl of (C&&C.plans)||[])for(const m of pl.members||[])if(m&&m.id!=null&&!byId.has(m.id))byId.set(m.id,m);
9709
+ return f=>{
9710
+ const m=byId.get(f.memberId);
9711
+ if(m){const k=memberTypeOf(m);return {k,label:memberTypeLabel(k)};}
9712
+ const k=String(f.role||'').includes('brace')?'brace':'beam';
9713
+ return {k,label:memberTypeLabel(k)};
9714
+ };
9715
+ }
9716
+ function memberEndCurrentView(review){
9717
+ return memberEndBuildView(review.report.findings,{typeOf:memberEndTypeResolver(),textOf:memberEndEvidenceText,typeOrder:memberTypeRecords().map(t=>t.k),query:review.query||''});
9718
+ }
9719
+ // Groups the list draws open: not collapsed by the user, or holding the focused row, or any group while a filter is typed (so a
9720
+ // match inside a collapsed type still surfaces). Same rule as the Objects list; the saved collapse set is never touched.
9721
+ function memberEndGroupOpen(review,group){
9722
+ const focused=review.report.findings[review.focus];
9723
+ return !merCollapsed.has(group.key)||!!(review.query||'').trim()||(!!focused&&group.items.some(m=>m.memberId===focused.memberId));
9724
+ }
9725
+ function memberEndVisibleOrder(review,view){
9726
+ const order=[];for(const g of view.groups)if(memberEndGroupOpen(review,g))for(const m of g.items)order.push(m.memberId);
9727
+ return order;
9728
+ }
9729
+ function saveMerCollapsed(){try{localStorage.setItem('floless.merCollapsed',JSON.stringify([...merCollapsed]));}catch{}}
9730
+ function memberEndRepaint(){if(view2dShown)render();else panel();} // 3D-only: the plan canvas is hidden, repaint the panel and let the selection drive the 3D view
9731
+ function memberEndStep(direction){
9732
+ const r=memberEndReview;if(!r||r.busy)return;
9733
+ const seq=memberEndCurrentView(r).endOrder.map(e=>e.i);if(!seq.length)return;
9734
+ const at=seq.indexOf(r.focus);
9735
+ focusMemberEnd(at<0?(direction>0?seq[0]:seq[seq.length-1]):seq[(at+direction+seq.length)%seq.length]);
9736
+ }
9737
+ // The review is pinned to the scope it was scanned with. When the user is now looking at a different scope (another sheet,
9738
+ // or 3D after a sheet) it keeps its list and offers a fresh check of THIS view; ticks that would be dropped by that are asked about first.
9739
+ function memberEndRescanHere(){
9740
+ const r=memberEndReview;if(!r||r.busy)return;
9741
+ const n=memberEndTicked(r);
9742
+ if(n&&!r.rescanAsked){r.rescanAsked=true;r.live=n+' ticked end'+(n===1?'':'s')+' will be dropped by a new check. Extend them first, or press Check again to continue.';panel();return;}
9743
+ r.rescanAsked=false;scanMemberEnds();
9744
+ }
9520
9745
  function renderMemberEndPanel(p){
9521
- const state=memberEndReview,rows=state.report.findings,groups=new Map();rows.forEach((f,i)=>{const g=memberEndGroup(f);if(!groups.has(g))groups.set(g,[]);groups.get(g).push([f,i]);});
9522
- const canChoose=rows.filter(f=>f.classification==='needs-review'&&(f.targets||[]).length>0),readyToSelect=canChoose.filter(f=>state.chosen.has(memberEndKey(f))),selected=readyToSelect.filter(f=>state.selected.has(memberEndKey(f))).length;
9746
+ const state=memberEndReview,rows=state.report.findings,query=state.query||'';
9747
+ const view=memberEndCurrentView(state);
9748
+ const readyOf=f=>f.classification==='needs-review'&&state.chosen.has(memberEndKey(f));
9749
+ const canChoose=rows.filter(f=>f.classification==='needs-review'&&(f.targets||[]).length>0);
9750
+ const selected=memberEndTicked(state),visibleReady=view.endOrder.filter(e=>readyOf(e.f)),visibleTicked=visibleReady.filter(e=>state.selected.has(memberEndKey(e.f))).length,hiddenTicked=selected-visibleTicked;
9751
+ const shownIds=new Set(memberEndVisibleOrder(state,view)),shownReady=visibleReady.filter(e=>shownIds.has(e.f.memberId)),shownTicked=shownReady.filter(e=>state.selected.has(memberEndKey(e.f))).length; // Select all acts on what the list DRAWS: open groups that match the filter, never ends folded away inside a collapsed group
9752
+ const memberIds=new Set(rows.map(f=>f.memberId)),selectedMembers=[...memberIds].filter(id=>selIds.has(id)).length;
9753
+ const focusedFinding=rows[state.focus],focusedMember=focusedFinding?focusedFinding.memberId:null;
9523
9754
  const historyAction=memberEndHistoryAction(state.undoDirection);
9755
+ // The rebuild below replaces every node: remember where focus and the list scroll were and put them back, or typing in the filter loses the caret every keystroke.
9756
+ const active=document.activeElement,keep=active&&active.id&&p.contains(active)?{id:active.id,start:active.selectionStart,end:active.selectionEnd}:null,keepMember=active&&active.dataset&&active.dataset.merMember?active.dataset.merMember:null;
9757
+ const oldList=p.querySelector('.mer-list'),keepScroll=oldList?oldList.scrollTop:0;
9524
9758
  p.setAttribute('aria-busy',String(!!state.busy));p.setAttribute('aria-labelledby','memberEndReviewTitle');
9525
9759
  const disabled=state.busy?' disabled':'';
9526
- let html=`<div class=mer-head><div><div class=mer-title id=memberEndReviewTitle>Member ends short of support centerlines</div><div class=hint>${memberEndUnresolved(state.report)} unresolved end${memberEndUnresolved(state.report)===1?'':'s'} on ${new Set(rows.map(f=>f.memberId)).size} member${new Set(rows.map(f=>f.memberId)).size===1?'':'s'}</div></div><button id=merDone data-command-id="steel.member-end-review-close" class=ghost data-tip="Close member-end review"${disabled}>Done</button></div>`;
9527
- const toolbar=[];if(readyToSelect.length>selected)toolbar.push(`<button id=merAll data-command-id="steel.member-end-select-all" class=ghost${disabled}>Select all</button>`);if(selected)toolbar.push(`<button id=merClear data-command-id="steel.member-end-select-clear" class=ghost${disabled}>Clear</button>`);html+=`<div class=mer-toolbar>${toolbar.join('')}<span class=hint>${selected} selected</span></div>`;
9528
- for(const [group,items] of groups){html+=`<section class=mer-group><div class=mer-group-title>${esc(group)}</div>`;for(const [f,i] of items){const key=memberEndKey(f),target=state.chosen.get(key),checked=state.selected.has(key),canCheck=f.classification==='needs-review'&&!!target;
9529
- const evidence=target?memberEndTargetName(target)+' · Extend '+fmtDisp(memberEndDistance(f,target)):memberEndReason(f)||memberEndClassification(f);
9530
- html+=`<div class="mer-row${i===state.focus?' focused':''}" data-mer-row="${i}">${canCheck?`<input type=checkbox data-mer-check="${i}" data-command-id="steel.member-end-select#${esc(f.memberId+' end '+(f.end+1))}" aria-label="Include ${esc(f.memberId)} end ${f.end+1}" ${checked?'checked':''}${disabled}>`:'<span aria-hidden=true></span>'}<div><label${canCheck?` for="merCheck${i}"`:''}>${esc(memberEndRole(f)+' '+f.memberId+' · End '+(f.end+1))}</label><div class=mer-evidence>${esc(evidence)}</div><div class=mer-actions>`;
9531
- if(f.classification==='needs-review'){
9532
- if((f.targets||[]).length>1)html+=(f.targets||[]).map((t,ti)=>`<button data-command-id="steel.member-end-target#${esc(memberEndTargetName(t))}" class="ghost${memberEndTargetEqual(target,t)?' selected':''}" data-mer-target="${i}:${ti}" aria-pressed="${memberEndTargetEqual(target,t)}" data-tip="Choose ${esc(memberEndTargetName(t))}"${disabled}>${String.fromCharCode(65+ti)} · ${esc(memberEndTargetName(t))}</button>`).join('');
9533
- if(memberEndCanKeepShort(f))html+=`<button data-command-id="steel.member-end-keep-short#${esc(f.memberId+' end '+(f.end+1))}" class=ghost data-mer-keep="${i}" data-tip="Record this endpoint as intentionally short for the current model context"${disabled}>Keep short</button>`;
9760
+ let scopeNote='';
9761
+ if(state.scope&&(state.scope.kind==='active-view'||state.scope.kind==='model-3d')){
9762
+ const pl=state.scope.kind==='active-view'?(C.plans||[]).find(x=>viewIdOf(x)===state.scope.viewId):null;
9763
+ const where=state.scope.kind==='model-3d'?'the whole 3D model':(pl?viewLabel(pl):state.scope.viewId),here=memberEndScope();
9764
+ const differs=memberEndScopeSig(here)!==memberEndScopeSig(state.scope);
9765
+ scopeNote=`<div class=mer-scope><span>Checked on ${esc(where)}${differs?' · not the view you are on':''}</span>${differs?`<button id=merRescan data-command-id="steel.member-end-rescan" class=ghost data-tip="Check member ends again for the view you are on. This list stays until it finishes."${disabled}>${here.kind==='model-3d'?'Check the 3D model':'Check this sheet'}</button>`:''}</div>`;
9766
+ }
9767
+ let html=`<div class=mer-head><div><div class=mer-title id=memberEndReviewTitle>Member ends short of support centerlines</div><div class=hint>${memberEndUnresolved(state.report)} unresolved end${memberEndUnresolved(state.report)===1?'':'s'} on ${memberIds.size} member${memberIds.size===1?'':'s'}</div></div><button id=merDone data-command-id="steel.member-end-review-close" class=ghost data-tip="Close member-end review"${disabled}>Done</button></div>${scopeNote}`;
9768
+ const toolbar=[];if(shownReady.length>shownTicked)toolbar.push(`<button id=merAll data-command-id="steel.member-end-select-all" data-tip="Tick every end in the groups shown below. Collapsed groups are left alone." class=ghost${disabled}>Select all</button>`);if(selected)toolbar.push(`<button id=merClear data-command-id="steel.member-end-select-clear" class=ghost${disabled}>Clear</button>`);
9769
+ const counts=selected+' end'+(selected===1?'':'s')+' ticked'+(hiddenTicked>0?' ('+hiddenTicked+' hidden by filter)':'')+(selectedMembers>1?' · '+selectedMembers+' members selected':'');
9770
+ html+=`<div class=mer-toolbar>${toolbar.join('')}<span class=hint>${counts}</span></div>`;
9771
+ html+=`<div class="mer-search${query?' has':''}"><span class=lsico aria-hidden=true><svg viewBox="0 0 16 16" width=12 height=12 fill=none stroke=currentColor stroke-width=1.6 stroke-linecap=round><circle cx=7 cy=7 r=4.5></circle><line x1=10.6 y1=10.6 x2=14 y2=14></line></svg></span><input id=merFilter type=text role=searchbox autocomplete=off placeholder="Filter members…" aria-label="Filter members by mark, type or reason" data-command-id="steel.member-end-filter" value="${esc(query)}"><button type=button class=lsx id=merFilterClear aria-label="Clear filter" data-command-id="steel.member-end-filter-clear" data-tip="Clear">×</button></div>`;
9772
+ if(query)html+=`<div class=hint id=merFilterCount role=status>${view.shownMembers} of ${view.totalMembers} member${view.totalMembers===1?'':'s'}</div>`;
9773
+ html+='<div class=mer-list id=merList>';
9774
+ if(query&&!view.groups.length)html+=`<div class=mer-empty role=status>No members match “${esc(query)}”. <button type=button id=merFilterReset class=mer-link data-command-id="steel.member-end-filter-reset">Clear</button></div>`;
9775
+ view.groups.forEach((g,gi)=>{
9776
+ const open=memberEndGroupOpen(state,g);
9777
+ html+=`<section class=mer-group><button type=button class="cat-hdr mer-type-hdr" id=merType${gi} data-mer-type="${esc(g.key)}" aria-expanded="${open}" data-command-id="steel.member-end-group#${esc(g.label)}" data-tip="${open?'Collapse':'Expand'} ${esc(g.label)}"><span class=cat-chevron aria-hidden=true>${open?'▼':'▶'}</span><span class=cat-label>${esc(g.label)}</span><span class=cat-count>(${g.items.length})</span><span class=mer-type-ends>· ${g.endCount} end${g.endCount===1?'':'s'}</span></button>`;
9778
+ if(open){
9779
+ html+=`<div class=mer-members role=listbox aria-multiselectable=true aria-labelledby="merType${gi}">`;
9780
+ for(const m of g.items){
9781
+ const tickable=m.ends.filter(e=>readyOf(e.f)),tickedHere=tickable.filter(e=>state.selected.has(memberEndKey(e.f))).length,tri=memberEndTriState(tickable.length,tickedHere);
9782
+ const shared=memberEndSharedReason(m.ends,memberEndEvidenceText,f=>readyOf(f));
9783
+ const isSel=selIds.has(m.memberId),isFocus=m.memberId===focusedMember;
9784
+ html+=`<div class="mer-row mer-member${isFocus?' focused':''}${isSel?' sel':''}" role=option tabindex=0 aria-selected="${isSel}" data-mer-member="${esc(m.memberId)}" data-mer-first="${m.ends[0].i}" data-command-id="steel.member-end-focus#${esc(m.memberId)}"><div class=mer-mhead>${m.ends.length>1&&tri!=='na'?`<input type=checkbox data-mer-mcheck="${esc(m.memberId)}" data-tri="${tri}" data-command-id="steel.member-end-select-member#${esc(m.memberId)}" aria-label="Include both ends of ${esc(m.memberId)}" ${tri==='all'?'checked':''}${disabled}>`:'<span class=mer-ckgap aria-hidden=true></span>'}<span class=mer-mname data-tip="${esc(m.memberId+' · '+memberEndGroup(m.ends[0].f))}">${esc(m.memberId)}</span></div>`;
9785
+ if(shared)html+=`<div class="mer-evidence mer-shared">${esc(shared)}</div>`;
9786
+ for(const {f,i} of m.ends){
9787
+ const key=memberEndKey(f),target=state.chosen.get(key),checked=state.selected.has(key),canCheck=readyOf(f);
9788
+ const sum=target?'· Extend '+fmtDisp(memberEndDistance(f,target)):'';
9789
+ const evidence=target?memberEndTargetName(target):(shared?'':memberEndEvidenceText(f));
9790
+ html+=`<div class="mer-end${i===state.focus?' focused':''}" data-mer-end="${i}"><div class=mer-endline>${canCheck?`<input type=checkbox data-mer-check="${i}" id=merCheck${i} data-command-id="steel.member-end-select#${esc(f.memberId+' end '+(f.end+1))}" aria-label="Include ${esc(f.memberId)} end ${f.end+1}" ${checked?'checked':''}${disabled}>`:'<span class=mer-ckgap aria-hidden=true></span>'}<label${canCheck?` for="merCheck${i}"`:''}>End ${f.end+1}</label><span class=mer-end-sum>${esc(sum)}</span></div>${evidence?`<div class=mer-evidence>${esc(evidence)}</div>`:''}<div class=mer-actions>`;
9791
+ if(f.classification==='needs-review'){
9792
+ if((f.targets||[]).length>1)html+=(f.targets||[]).map((t,ti)=>`<button data-command-id="steel.member-end-target#${esc(memberEndTargetName(t))}" class="ghost${memberEndTargetEqual(target,t)?' selected':''}" data-mer-target="${i}:${ti}" aria-pressed="${memberEndTargetEqual(target,t)}" data-tip="Choose ${esc(memberEndTargetName(t))}"${disabled}>${String.fromCharCode(65+ti)} · ${esc(memberEndTargetName(t))}</button>`).join('');
9793
+ if(memberEndCanKeepShort(f))html+=`<button data-command-id="steel.member-end-keep-short#${esc(f.memberId+' end '+(f.end+1))}" class=ghost data-mer-keep="${i}" data-tip="Record this endpoint as intentionally short for the current model context"${disabled}>Keep short</button>`;
9794
+ }
9795
+ if((f.classification==='aligned-auto'||f.classification==='aligned-manual')&&f.basis&&f.basis.kind==='drawing')html+=`<button data-command-id="steel.member-end-restore#${esc(f.memberId+' end '+(f.end+1))}" class=ghost data-mer-restore="${i}" data-tip="Restore the immutable endpoint traced from the drawing"${disabled}>Restore traced end</button>`;
9796
+ html+='</div></div>';
9797
+ }
9798
+ html+='</div>';
9534
9799
  }
9535
- if((f.classification==='aligned-auto'||f.classification==='aligned-manual')&&f.basis&&f.basis.kind==='drawing')html+=`<button data-command-id="steel.member-end-restore#${esc(f.memberId+' end '+(f.end+1))}" class=ghost data-mer-restore="${i}" data-tip="Restore the immutable endpoint traced from the drawing"${disabled}>Restore traced end</button>`;
9536
- html+='</div></div></div>';}
9537
- html+='</section>';}
9800
+ html+='</div>';
9801
+ }
9802
+ html+='</section>';
9803
+ });
9804
+ html+='</div>';
9538
9805
  // Nothing ticked any more (Clear, an untick, Keep short): closing now loses nothing, so the question goes. Not mid-apply,
9539
9806
  // where a batch that landed has just cleared the ticks and the answer is still being carried out.
9540
9807
  if(state.leaving&&!state.leaving.applying&&!memberEndTicked(state))state.leaving=null;
@@ -9543,19 +9810,53 @@ function renderMemberEndPanel(p){
9543
9810
  html+=`<div class=mer-live role=status aria-live=polite aria-atomic=true>${esc(state.live||'')}</div><div class=mer-leave role=group aria-labelledby=merLeaveText><p id=merLeaveText>Opening ${esc(state.leaving.name)} will close this review with ${ends} ticked but not applied. Extend ${n===1?'it':'them'}, discard the tick${n===1?'':'s'}, or go back to the review?</p><button id=merLeaveApply data-command-id="steel.member-end-leave-apply" class=mer-primary${disabled}>${state.busy?'Working…':'Extend '+n+' end'+(n===1?'':'s')+' and continue'}</button><div class=mer-leave-alt><button id=merLeaveBack data-command-id="steel.member-end-leave-back" class=ghost${disabled}>Back to review</button><button id=merLeaveDiscard data-command-id="steel.member-end-leave-discard" class=ghost${disabled}>Discard tick${n===1?'':'s'}</button></div></div>`;
9544
9811
  }else{
9545
9812
  html+=`<div class=mer-nav><button id=merPrev data-command-id="steel.member-end-review-nav#previous" class=ghost${disabled}>Previous</button><button id=merNext data-command-id="steel.member-end-review-nav#next" class=ghost${disabled}>Next</button>${state.undoToken?`<button id=merUndo data-command-id="steel.member-end-history#${esc(historyAction.label)}" class=ghost data-tip="${historyAction.tip}"${disabled}>${historyAction.label}</button>`:''}</div><div class=mer-live role=status aria-live=polite aria-atomic=true>${esc(state.live||'')}</div>`;
9546
- if(selected)html+=`<button id=merApply data-command-id="steel.member-end-apply" class=mer-primary${disabled}>${state.busy?'Working…':'Extend '+selected+' end'+(selected===1?'':'s')+' to centerlines'}</button>`;else html+=`<div class=hint style="margin-top:9px">${canChoose.length?'No ends selected':'No endpoints are available to extend'}</div>`;
9813
+ if(selected)html+=`<button id=merApply data-command-id="steel.member-end-apply" class=mer-primary${disabled}>${state.busy?'Working…':'Extend '+selected+' end'+(selected===1?'':'s')+' to centerlines'}</button>`;else html+=`<div class=hint style="margin-top:9px">${canChoose.length?'No ends ticked':'No endpoints are available to extend'}</div>`;
9547
9814
  }
9548
9815
  p.innerHTML=html;
9549
9816
  const leaveApply=document.getElementById('merLeaveApply'),leaveBack=document.getElementById('merLeaveBack'),leaveDiscard=document.getElementById('merLeaveDiscard');if(leaveApply)leaveApply.onclick=memberEndLeaveApply;if(leaveBack)leaveBack.onclick=memberEndLeaveBack;if(leaveDiscard)leaveDiscard.onclick=memberEndLeaveDiscard;
9550
9817
  const done=document.getElementById('merDone');if(done)done.onclick=closeMemberEndReview;
9551
- const all=document.getElementById('merAll');if(all)all.onclick=()=>{for(const f of readyToSelect)state.selected.add(memberEndKey(f));panel();};
9818
+ const rescan=document.getElementById('merRescan');if(rescan)rescan.onclick=memberEndRescanHere;
9819
+ const all=document.getElementById('merAll');if(all)all.onclick=()=>{for(const e of shownReady)state.selected.add(memberEndKey(e.f));panel();};
9552
9820
  const clear=document.getElementById('merClear');if(clear)clear.onclick=()=>{state.selected.clear();panel();};
9553
- p.querySelectorAll('[data-mer-row]').forEach(row=>row.addEventListener('click',e=>{if(e.target.closest('button,input'))return;focusMemberEnd(+row.dataset.merRow);}));
9554
- p.querySelectorAll('[data-mer-check]').forEach(input=>{input.id='merCheck'+input.dataset.merCheck;input.onchange=()=>{const f=rows[+input.dataset.merCheck],key=memberEndKey(f);input.checked?state.selected.add(key):state.selected.delete(key);state.focus=+input.dataset.merCheck;panel();render();};input.onfocus=()=>{state.focus=+input.dataset.merCheck;modelSelection.replaceMembers([rows[state.focus].memberId],'inspector');};});
9821
+ // Filter: the text lives in the review state, so the rebuild above redraws it; Esc clears it first and never closes the review while it has text.
9822
+ const filter=document.getElementById('merFilter');
9823
+ if(filter){
9824
+ filter.oninput=()=>{state.query=filter.value;panel();};
9825
+ filter.onkeydown=e=>{if(e.key==='Escape'){e.stopPropagation();if(filter.value){state.query='';panel();}else filter.blur();}};
9826
+ }
9827
+ const clearFilter=()=>{state.query='';panel();queueMicrotask(()=>{const f=document.getElementById('merFilter');if(f)f.focus({preventScroll:true});});};
9828
+ const fclear=document.getElementById('merFilterClear');if(fclear)fclear.onclick=clearFilter;
9829
+ const freset=document.getElementById('merFilterReset');if(freset)freset.onclick=clearFilter;
9830
+ p.querySelectorAll('[data-mer-type]').forEach(h=>h.onclick=()=>{const k=h.dataset.merType;if(merCollapsed.has(k))merCollapsed.delete(k);else merCollapsed.add(k);saveMerCollapsed();panel();});
9831
+ // Row clicks only pick the MEMBER (focus + model selection); they never touch a tick. Plain replaces, Ctrl/Cmd toggles, Shift ranges.
9832
+ const drawn=memberEndVisibleOrder(state,view);
9833
+ p.querySelectorAll('[data-mer-member]').forEach(row=>{
9834
+ const pick=(e,end)=>focusMemberEnd(end,{ctrl:e.ctrlKey||e.metaKey,shift:e.shiftKey,pointer:true,order:drawn});
9835
+ row.addEventListener('click',e=>{if(e.target.closest('button,input,label'))return;const endEl=e.target.closest('[data-mer-end]');pick(e,endEl?+endEl.dataset.merEnd:+row.dataset.merFirst);});
9836
+ row.addEventListener('keydown',e=>{
9837
+ if(e.target!==row)return;
9838
+ if(e.key==='Enter'||e.key===' '){e.preventDefault();pick(e,+row.dataset.merFirst);}
9839
+ else if(e.key==='ArrowDown'||e.key==='ArrowUp'){e.preventDefault();const rowsEl=[...p.querySelectorAll('[data-mer-member]')],next=rowsEl[rowsEl.indexOf(row)+(e.key==='ArrowDown'?1:-1)];if(next)next.focus();}
9840
+ });
9841
+ });
9842
+ p.querySelectorAll('[data-mer-mcheck]').forEach(input=>{
9843
+ if(input.dataset.tri==='some')input.indeterminate=true;
9844
+ input.onchange=()=>{
9845
+ const id=input.dataset.merMcheck,ends=rows.filter(f=>f.memberId===id&&readyOf(f));
9846
+ const everyTicked=ends.every(f=>state.selected.has(memberEndKey(f)));
9847
+ for(const f of ends){if(everyTicked)state.selected.delete(memberEndKey(f));else state.selected.add(memberEndKey(f));}
9848
+ panel();
9849
+ };
9850
+ });
9851
+ // A tick only changes the tick set (and which end the canvas marks); the model selection is left exactly as the row clicks made it.
9852
+ p.querySelectorAll('[data-mer-check]').forEach(input=>{input.onchange=()=>{const i=+input.dataset.merCheck,f=rows[i],key=memberEndKey(f);input.checked?state.selected.add(key):state.selected.delete(key);state.focus=i;memberEndRepaint();};});
9555
9853
  p.querySelectorAll('[data-mer-target]').forEach(b=>b.onclick=()=>{const [i,t]=b.dataset.merTarget.split(':').map(Number);state.focus=i;chooseMemberEndTarget(memberEndKey(rows[i]),t);});
9556
9854
  p.querySelectorAll('[data-mer-keep]').forEach(b=>b.onclick=()=>keepMemberEnd(rows[+b.dataset.merKeep]));
9557
9855
  p.querySelectorAll('[data-mer-restore]').forEach(b=>b.onclick=()=>restoreMemberEnd(rows[+b.dataset.merRestore]));
9558
- const prev=document.getElementById('merPrev'),next=document.getElementById('merNext'),applyB=document.getElementById('merApply'),undoB=document.getElementById('merUndo');if(prev)prev.onclick=()=>focusMemberEnd(state.focus-1);if(next)next.onclick=()=>focusMemberEnd(state.focus+1);if(applyB)applyB.onclick=applyMemberEndSelection;if(undoB)undoB.onclick=undoMemberEndResolution;
9856
+ const prev=document.getElementById('merPrev'),next=document.getElementById('merNext'),applyB=document.getElementById('merApply'),undoB=document.getElementById('merUndo');if(prev)prev.onclick=()=>memberEndStep(-1);if(next)next.onclick=()=>memberEndStep(1);if(applyB)applyB.onclick=applyMemberEndSelection;if(undoB)undoB.onclick=undoMemberEndResolution;
9857
+ const newList=p.querySelector('.mer-list');if(newList&&keepScroll)newList.scrollTop=keepScroll;
9858
+ if(keep){const el=document.getElementById(keep.id);if(el&&el.focus){el.focus({preventScroll:true});if(keep.id==='merFilter'&&keep.start!=null){try{el.setSelectionRange(keep.start,keep.end);}catch(_){}}}}
9859
+ else if(keepMember){const el=[...p.querySelectorAll('[data-mer-member]')].find(x=>x.dataset.merMember===keepMember);if(el)el.focus({preventScroll:true});}
9559
9860
  }
9560
9861
  function renderMemberEndScanPanel(p){
9561
9862
  const state=memberEndScan;p.setAttribute('aria-busy',String(!!state.busy));p.setAttribute('aria-labelledby','memberEndScanTitle');
@@ -13270,10 +13571,20 @@ let modelShellMount=null;
13270
13571
  // two rows while the model band stayed at the one-row offset and the two overlapped. Written on <body>
13271
13572
  // so #m3dToolBar inherits them; the observer re-measures on every wrap and view-mode change.
13272
13573
  if(toolbar&&window.ResizeObserver){
13273
- const syncBand=()=>{const s=document.body.style;s.setProperty('--m3d-view-w',toolbar.offsetWidth+'px');s.setProperty('--m3d-view-h',toolbar.offsetHeight+'px');};
13574
+ const modelBand=document.getElementById('m3dToolBar'),pane3d=document.getElementById('pane3d');
13575
+ const syncBand=()=>{const s=document.body.style;s.setProperty('--m3d-view-w',toolbar.offsetWidth+'px');s.setProperty('--m3d-view-h',toolbar.offsetHeight+'px');
13576
+ // Split only: do both bands + the cube's reserve fit on ONE row? Natural (unwrapped) widths are summed from the
13577
+ // children, so the verdict does not depend on which layout is showing now (no flip-flop between the two).
13578
+ const inline=document.body.classList.contains('split-view')&&!!modelBand&&!!pane3d&&bandsFitInline({paneW:pane3d.clientWidth,viewW:naturalBarWidth(toolbar),bandW:naturalBarWidth(modelBand)});
13579
+ if(document.body.classList.contains('bands-inline')!==inline)document.body.classList.toggle('bands-inline',inline);};
13274
13580
  // Measure once up front too: the observer's first callback is async, so without this the model band
13275
13581
  // would paint one frame at the 335px/40px defaults before jumping to the measured position.
13276
- syncBand();new ResizeObserver(syncBand).observe(toolbar);
13582
+ // The pane (split-divider drag, window resize) and the model band (its buttons come and go with the active
13583
+ // pane) change the answer too, so they are watched with the view band.
13584
+ syncBand();const bandRO=new ResizeObserver(syncBand);bandRO.observe(toolbar);
13585
+ if(pane3d)bandRO.observe(pane3d);
13586
+ if(modelBand){bandRO.observe(modelBand);new MutationObserver(syncBand).observe(modelBand,{subtree:true,attributes:true,attributeFilter:['style','hidden']});}
13587
+ new MutationObserver(syncBand).observe(document.body,{attributes:true,attributeFilter:['class']}); // entering/leaving Split flips body.split-view
13277
13588
  }
13278
13589
  // The 2D view band (#1428) is measured the same way for the same reason: in 2D-only the model band docks
13279
13590
  // off ITS right edge (`#m3dToolBar{left:calc(var(--v2d-view-w)…)}`), and a width assumed in CSS is what
@@ -20790,6 +21101,7 @@ function reflectViewChrome(){
20790
21101
  if(window.Steel3DView&&window.Steel3DView.setInputActive)window.Steel3DView.setInputActive(view3d); // key ownership follows the ACTIVE pane
20791
21102
  reflectActivePane();
20792
21103
  syncLegendToPane(); // Objects lists the active pane's objects
21104
+ refreshStructureStats(); // the Structure count is per-sheet in a plan and model-wide in 3D, so it follows the view
20793
21105
  }
20794
21106
  // A pointerdown in a pane makes it active AND still performs its action — a click that only focuses is a
20795
21107
  // click the user has to repeat. In a single mode this is a no-op: resolveActivePane forces the pane.
@@ -21085,7 +21397,8 @@ async function setView(on,{remember=true}={}){
21085
21397
  // that survives that round trip today. The 2D pane keeps its viewBox; a narrower pane just shows less.
21086
21398
  if(effects.show2d)render();
21087
21399
  if(propPopOpen()){if(propPopPinned){dockPropPop();renderPropPop();}else closePropPop(true);} // the popup is anchored to one canvas — re-dock if pinned (renderPropPop re-syncs its "Show in this view" checkbox to the now-live view), else dismiss on the view switch
21088
- if(memberEndReview&&memberEndScopeSig(memberEndReview.scope)!==memberEndScopeSig())invalidateMemberEndReview('The view changed — check member ends again.');
21400
+ if(memberEndReview&&!memberEndReviewCanExist(memberEndReview))invalidateMemberEndReview(MEMBER_END_SHEET_GONE); // a 2D/3D/Split switch no longer ends the review: it stays pinned to the scope it was scanned with (review.scope) and only goes when that scope itself is gone
21401
+ memberEndGhostSync(); // a review opened in 2D ghosts as soon as the 3D view exists
21089
21402
  panel(); // repaint the inspector for the NOW-current view (view3d is final here): a cross-view tool stays armed but its in-progress draft was dropped above — Add-member's drawHint (:2288) and Move/Copy's cmHint are view-specific, so without this the panel keeps the stale 2D "Click 2: end" (drawDraft already null) instead of the 3D working-plane hint (and vice-versa on return)
21090
21403
  refreshPropLabels3d();updatePropHint(); // push the label set to whichever view is now live (3D shows them; 2D hides the 3D host) + refresh the corner note
21091
21404
  updCS();if(typeof csSyncF3d==='function')csSyncF3d(); // the Axes chip is view-scoped (2D=P.frame, 3D=frame3d) — resync it + the 3D-frame fields on every switch (applyViewState alone doesn't; Codex MAJOR 6)
@@ -24734,7 +25047,7 @@ function yourAnswersHtml(){const rows=[];
24734
25047
  const said=a.how==='typed'?'you typed '+(a.typed||fmtDispElev(z.known)):'you confirmed '+(a.shownAs||fmtDispElev(z.known));
24735
25048
  const when=typeof a.answeredAt==='string'&&!Number.isNaN(Date.parse(a.answeredAt))?', '+new Date(a.answeredAt).toLocaleDateString():'';
24736
25049
  const pics=(Array.isArray(a.evidence)?a.evidence:[]).map(ref=>' <button type=button class=answer-picture data-command-id="steel.answer-picture-open#'+esc(ref.fileName)+'" data-answer-request="'+esc(a.requestId)+'" data-answer-evidence="'+esc(ref.attachmentId)+'" data-command-instance-label="'+esc(String(a.label||m.id))+'" data-tip="Open '+esc(ref.fileName)+'">'+esc(ref.fileName)+'</button>').join('');
24737
- rows.push('<li>'+esc(String(a.label||m.id))+': '+esc(said)+(a.basis==='read-of-your-picture'?' (the read’s reading of your picture)':'')+' on height question'+esc(when)+(a.note?' — '+esc(a.note):'')+pics+'</li>');}
25050
+ rows.push('<li>'+esc(String(a.label||m.id))+': '+esc(said)+(a.basis==='read-of-your-picture'?' (the read’s reading of your picture)':a.basis==='read-of-your-note'?' (the read’s reading of your note)':'')+' on height question'+esc(when)+(a.note?' — '+esc(a.note):'')+pics+'</li>');}
24738
25051
  return rows.length?'<h3>Your answers</h3><ul>'+rows.join('')+'</ul>':'';}
24739
25052
  /** A button that opens a picture the person attached to an answer (#1906), served only after its digest check. */
24740
25053
  function answerPictureButton(requestId,ref,instance){const b=document.createElement('button');b.type='button';b.className='answer-picture';
@@ -25403,7 +25716,7 @@ function resetPlanViewState(i){
25403
25716
  // --- multi-plan: switch between all steel plan views ---
25404
25717
  function setPlan(i){
25405
25718
  if(memberEndReview&&memberEndReview.busy){memberEndReview.live='Finish the current member-end action before changing views.';panel();return;}
25406
- if(memberEndReview&&C.plans&&C.plans[i]&&memberEndReview.scope.kind==='active-view'&&memberEndReview.scope.viewId!==viewIdOf(C.plans[i]))invalidateMemberEndReview('The view changed — check member ends again.');
25719
+ // Switching sheet keeps an active-view review open: it was scanned for another sheet, and the panel says so and offers "Check this sheet" (renderMemberEndPanel) instead of silently dropping the user's list.
25407
25720
  const canonical=C.plans[i];
25408
25721
  if(!canonical){
25409
25722
  NO_PLAN_VIEW=true;C.active=0;P={sheet:'',members:[],segments:[],dims:[],details:[],callouts:[],tos_callouts:[],grid:null,default_tos_mm:0};