@floless/app 0.162.1 → 0.164.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 (39) hide show
  1. package/dist/floless-server.cjs +39748 -35132
  2. package/dist/schemas/steel.model.v2.schema.json +16 -2
  3. package/dist/skills/floless-app-actions/SKILL.md +54 -3
  4. package/dist/skills/floless-app-onboarding/SKILL.md +2 -2
  5. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +8 -6
  6. package/dist/skills/floless-app-report-issue/SKILL.md +12 -1
  7. package/dist/skills/floless-app-rfi/SKILL.md +36 -9
  8. package/dist/skills/floless-app-steel-model/SKILL.md +5 -3
  9. package/dist/skills/floless-app-steel-takeoff/SKILL.md +39 -34
  10. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +10 -6
  11. package/dist/web/agents.js +24 -4
  12. package/dist/web/app.css +47 -7
  13. package/dist/web/app.js +22 -3
  14. package/dist/web/aware.js +157 -43
  15. package/dist/web/chat.css +36 -1
  16. package/dist/web/chat.js +322 -44
  17. package/dist/web/commands-filter.js +35 -0
  18. package/dist/web/commands-shell.js +208 -11
  19. package/dist/web/commands-steel.js +23 -0
  20. package/dist/web/failure-copy.js +168 -0
  21. package/dist/web/index.html +35 -1
  22. package/dist/web/instructor.js +3 -1
  23. package/dist/web/landing-sort.js +277 -0
  24. package/dist/web/model-editor-steel-adapter.js +5 -0
  25. package/dist/web/model-panel-bridge.js +13 -2
  26. package/dist/web/model-view-query.js +23 -15
  27. package/dist/web/project-access.js +3 -3
  28. package/dist/web/project-rfis.js +303 -10
  29. package/dist/web/project-workflows.js +1 -1
  30. package/dist/web/steel-3d-view.js +162 -1
  31. package/dist/web/steel-ai-marks.js +233 -0
  32. package/dist/web/steel-editor.html +950 -36
  33. package/dist/web/steel-filter-core.js +2 -0
  34. package/dist/web/steel-filter-flo.js +225 -0
  35. package/dist/web/steel-filter.html +156 -9
  36. package/dist/web/steel-model-v2-commands.js +3 -1
  37. package/dist/web/steel-profile-colours.js +124 -24
  38. package/dist/web/workspaces.js +380 -58
  39. package/package.json +1 -1
@@ -1407,6 +1407,8 @@ rect.lblhot:focus-visible{outline:2px solid var(--brand);outline-offset:2px;stro
1407
1407
  tags for the metadata line. */
1408
1408
  #rfiStat b{color:var(--ok)} /* nothing outstanding — the resolved state */
1409
1409
  #rfiStat.has b{color:var(--warn)} /* …and "needs review", never an error */
1410
+ /* #2920: a green 0 beside questions nobody filed would read as all-clear, so the 0 goes muted and the second figure warns. */
1411
+ #rfiStat.readq:not(.has) #rc{color:var(--mut)} #rfiStat .rcread{color:var(--mut);font-weight:400} #rfiStat .rcread b{color:var(--warn)}
1410
1412
  #rfiStat.unknown::after{content:'!';display:inline-grid;place-items:center;width:14px;height:14px;margin-left:4px;border:1px solid color-mix(in srgb,var(--warn) 72%,transparent);border-radius:999px;color:var(--warn);font-size:10px;font-weight:800;line-height:1;background:color-mix(in srgb,var(--warn) 12%,transparent)}
1411
1413
  /* #2450 — the Raise an RFI dialog wears the RFI list's own rows, chips, notes and forms. */
1412
1414
  #rfiRaiseModal{position:fixed;inset:0;z-index:20;display:none;align-items:center;justify-content:center}
@@ -1450,6 +1452,7 @@ rect.lblhot:focus-visible{outline:2px solid var(--brand);outline-offset:2px;stro
1450
1452
  #rfiList .rfirow+.rfirow{border-top:1px solid var(--line)}
1451
1453
  #rfiList .rfirow:hover{background:var(--hover-soft)}
1452
1454
  #rfiList .rfirow:focus-within{outline:2px solid var(--brand);outline-offset:-2px}
1455
+ #rfiList .rfirow.is-mentioned{outline:2px solid var(--brand);outline-offset:-2px}
1453
1456
  /* The status badge. A SIZE symptom is dashed — it is not filed yet, and the canvas already spells
1454
1457
  "unresolved" as a dash everywhere else (line.member.rfi, polygon.member.rfi). A record's badge is
1455
1458
  a solid outline, so "filed" and "not filed" are told apart by SHAPE and survive losing colour. */
@@ -1474,6 +1477,11 @@ rect.lblhot:focus-visible{outline:2px solid var(--brand);outline-offset:2px;stro
1474
1477
  #rfiList .rfiunfiled>.rfinote,#rfiList .rfiunfiled>.rfiacts{padding:0 8px}
1475
1478
  #rfiList .rfiunfiled .rfiwhy{color:var(--warn)}
1476
1479
  #rfiList .rfiunfiled b.rfiwarn{color:var(--warn)}
1480
+ /* #2920: the read's unfiled questions, one block per kind; long kinds open on request. */
1481
+ #rfiList .rfiread:focus{outline:none}
1482
+ #rfiList .rfireadgroup{padding:6px 8px 2px;border-top:1px dashed var(--line);margin-top:6px}
1483
+ #rfiList .rfireadgroup .rfirow{padding-left:0;padding-right:0}
1484
+ #rfiList .rfireadhead{font-size:12px;line-height:1.5} #rfiList .rfireadn{color:var(--mut)}
1477
1485
  #rfiList .rfiacts{margin-top:6px;display:flex;flex-wrap:wrap;gap:5px;align-items:center}
1478
1486
  #rfiList .rfiacts button{font-size:11px;padding:3px 8px}
1479
1487
  #rfiList .rfiacts [aria-disabled=true]{opacity:.48;cursor:progress;background:var(--btn);border-color:var(--ctrl-border)}
@@ -1547,6 +1555,11 @@ rect.lblhot:focus-visible{outline:2px solid var(--brand);outline-offset:2px;stro
1547
1555
  blurs a focused control when it is disabled, which would drop focus to body for the whole request
1548
1556
  and let Tab walk out of an aria-modal dialog. */
1549
1557
  #rfiList .rfiform [aria-disabled=true]{opacity:.4;cursor:default}
1558
+ /* #2470 R6.6e: the not-confirmed sends of an RFI, and the tick in the Send it again dialog. */
1559
+ #rfiList .rfisettled{margin:4px 0 0;padding-left:18px}
1560
+ #coCardModal .rfiform{display:flex;flex-direction:column;gap:8px}
1561
+ #coCardModal .rfiform label{display:flex;flex-direction:column;gap:3px;font-size:12px;color:var(--mut)}
1562
+ #coCardModal .rfiform label.rficheck{flex-direction:row;align-items:center;gap:8px;color:var(--text);cursor:pointer}
1550
1563
  /* The pill group clips its children, so the global focus ring (offset 2px) lands outside the border
1551
1564
  and is cut off. Inset it, the same way #reviewFly .frow does. */
1552
1565
  #rfiList .rfidisp button:focus-visible{outline-offset:-2px}
@@ -1872,6 +1885,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
1872
1885
  /* Same trap: "Send selection to Tekla" is hidden with an empty selection, and plain [hidden] loses
1873
1886
  to the #moreMenu rule above — without this it ships as a visible row that only scolds you. */
1874
1887
  #moreMenu #sendTeklaB[hidden],#moreMenu #sendRevitB[hidden],#moreMenu #sendSketchupB[hidden],#moreMenu #sendRhinoB[hidden]{display:none}
1888
+ #moreMenu #aiMarksToggleB[hidden]{display:none} /* #2521 row 6: the AI decisions switch exists only on a model with marks */
1875
1889
  #moreMenu button:disabled{opacity:.4;cursor:default;background:transparent}
1876
1890
  #moreMenu button.on{color:var(--brand)}
1877
1891
  button:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
@@ -1885,6 +1899,27 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
1885
1899
  #srcStat{white-space:nowrap}
1886
1900
  /* #2521 row 5: the Quick model chip. Amber (= needs review, never an error), as last saved; dashed when unknown. */
1887
1901
  #quickStat{white-space:nowrap;color:var(--warn)}
1902
+ /* #2521 row 6: the AI-decision marks (an open square at an end, a ring at a joint) and the strip. Tokens only. */
1903
+ .ai-end-mark{fill:var(--panel);fill-opacity:.85;stroke:var(--warn);pointer-events:none}
1904
+ .ai-joint-mark{fill:none;stroke:var(--warn);pointer-events:none}
1905
+ /* Above #bottomDock (bottom 12px, its bars 36px tall), never under its hint or the Select/Snap bars, in 2D, 3D and split. */
1906
+ .ai-strip{position:absolute;left:12px;bottom:56px;z-index:6;max-width:min(620px,calc(100% - 20px));background:var(--panel);border:1px solid var(--warn-edge);border-radius:6px;padding:5px 9px;font-size:11.5px;line-height:1.45;color:var(--mut);box-shadow:0 2px 8px rgba(0,0,0,.25)}
1907
+ .ai-strip[hidden]{display:none}
1908
+ .ai-strip .ai-line{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px}
1909
+ .ai-strip .ai-lead{color:var(--warn);font-weight:600}
1910
+ .ai-strip .ai-key{display:inline-flex;align-items:center;gap:4px;white-space:nowrap}
1911
+ .ai-strip .ai-key svg{flex:none}
1912
+ .ai-strip .ai-key .sq{fill:var(--panel);stroke:var(--warn);stroke-width:1.5}
1913
+ .ai-strip .ai-key .rg{fill:none;stroke:var(--warn);stroke-width:1.5}
1914
+ .ai-strip .chip.assumed{margin:0;cursor:default}
1915
+ .ai-strip .ai-more{border:0;background:transparent;color:var(--text);font:inherit;text-decoration:underline;text-underline-offset:2px;padding:0 2px;cursor:pointer}
1916
+ .ai-strip .ai-more:focus-visible,.ai-strip .chip:focus-visible,.v2-ai-decisions:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
1917
+ .ai-strip .ai-details{margin-top:5px;padding-top:5px;border-top:1px solid var(--line);max-height:40vh;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--line) transparent}
1918
+ .ai-strip .ai-details::-webkit-scrollbar{width:8px}.ai-strip .ai-details::-webkit-scrollbar-thumb{background:var(--line);border-radius:4px}.ai-strip .ai-details::-webkit-scrollbar-track{background:transparent}
1919
+ .ai-strip .ai-details ul{margin:0 0 4px;padding-left:16px}
1920
+ .v2-ai-decisions .ai-head{display:flex;align-items:center;gap:6px;margin-bottom:2px}
1921
+ .v2-ai-decisions .ai-row{margin:2px 0}
1922
+ .v2-ai-decisions .ai-foot{color:var(--mut);margin-top:3px}
1888
1923
  #quickStat.is-unknown{text-decoration:underline dashed;text-underline-offset:3px}
1889
1924
  .conf-quick{margin:0 0 8px;padding:6px 10px;border:1px solid var(--warn-edge);border-radius:6px;color:var(--mut);font-size:12px;line-height:1.45}
1890
1925
  .conf-quick b{color:var(--warn)}
@@ -2980,7 +3015,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
2980
3015
  <div class=statgrp id=qualGrp>
2981
3016
  <button data-command-id="steel.quality-stats" type=button class="stat statgrp-btn" id=qualBtn aria-expanded=false aria-controls=qualPanel data-tip="What is unresolved on this sheet — RFI, duplicates, member ends, and how well the drawing was read">Quality <b id=qualN>0</b></button>
2982
3017
  <div class=statgrp-panel id=qualPanel hidden>
2983
- <button data-command-id="steel.rfi-list" class="stat act" id=rfiStat aria-expanded="false" aria-controls="rfiModal" data-tip="List every RFI — a question for an engineer, or a member whose size FloLess cannot price"><span class=k>RFI</span><span class=v><b id=rc>0</b></span></button>
3018
+ <button data-command-id="steel.rfi-list" class="stat act" id=rfiStat aria-expanded="false" aria-controls="rfiModal" data-tip="List every RFI — a question for an engineer, or a member whose size FloLess cannot price"><span class=k>RFI</span><span class=v><b id=rc>0</b><span id=rcRead class=rcread style="display:none"> · <b id=rcReadN>0</b> not filed</span></span></button>
2984
3019
  <span class=stat id=dupStat data-tip="Overlapping/duplicate members (same geometry)"><span class=k>Duplicates</span><span class=v><b id=dpc>0</b></span></span>
2985
3020
  <span class=stat id=endsStat data-tip="Member ends that may stop at a support face instead of its centerline."><span class=k>Member ends</span><span class=v><b id=endsCount>—</b></span></span>
2986
3021
  <!-- Written by refresh() and shown only when every count above is zero. A panel of four zeroes states
@@ -3065,6 +3100,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
3065
3100
  to 16 — then jumped on the first drag. One authority on what a legal size is. -->
3066
3101
  <div class=mrow><span class=mlbl>Grid label size</span><input data-command-id="steel.grid-label-size" id=gridLabelSize type=range min=14 max=48 step=1 aria-label="Grid label size in pixels" data-tip="How big the grid bubbles are drawn, in both 2D and 3D. Like a CAD drawing they hold this size on screen however far you zoom in or out."><span id=gridLabelSizeV class=mval>26 px</span></div>
3067
3102
  <button data-command-id="steel.position-gizmo" id=posGizmoToggleB class=dtog role=menuitemcheckbox aria-checked=false data-tip="Show a drag handle on the selected member for moving it and rolling its section right in the 3D view"><span class=mck aria-hidden=true></span>Position handle</button>
3103
+ <button data-command-id="steel.show-ai-decisions" id=aiMarksToggleB class=dtog role=menuitemcheckbox aria-checked=true hidden data-tip="Marks the member ends and connections where the AI made a decision in this Quick model, in 2D and 3D. The AI decisions strip and Inspect stay either way."><span class=mck aria-hidden=true></span>AI decisions</button>
3068
3104
  <div class=pl-section id=plSection>
3069
3105
  <div class=pl-header><button data-command-id="steel.property-label-visibility#Display" id=plToggleB class=dtog role=menuitemcheckbox aria-checked=true aria-label="Property labels in the active view" data-tip="Show or hide labels here without losing their settings. The 2D plan, the 3D default and each saved 3D view have their own switch and choice of members; the properties shown are shared."><span class=mck aria-hidden=true></span></button>
3070
3106
  <button data-command-id="steel.property-label-settings#Display" id=plDisclosure class=pl-disclosure aria-expanded=false aria-controls=plScope data-tip="Choose which members have property labels">Property labels<span class=pl-chevron aria-hidden=true>▸</span></button></div>
@@ -3133,6 +3169,9 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
3133
3169
  #stage3d keeps position:absolute;inset:0, which is what lets the 3D engine's resize() and its
3134
3170
  ResizeObserver(canvas.parentElement) keep working untouched — they now measure #pane3d. -->
3135
3171
  <div id=stagewrap>
3172
+ <!-- #2521 row 6: the AI decisions strip. Always shown for a Quick (or possibly Quick) model, whatever is selected and
3173
+ whether or not the marks are switched on: it is where "unmarked members may still rest on AI decisions" lives. -->
3174
+ <div id=aiStrip class=ai-strip role=note aria-label="AI decisions in this model" hidden></div>
3136
3175
  <div id=pane2d>
3137
3176
  <div id=stage><svg id=svg tabindex=-1 aria-label="2D model plan"></svg></div>
3138
3177
  <!-- #935: this sheet's registration is present and REFUSED, so the steel on screen may be metres from
@@ -3617,15 +3656,17 @@ const EditorFocus = (() => {
3617
3656
  Promise.resolve().then(() => runner(job.req, current)).then(
3618
3657
  (outcome) => vacate(job, current() && outcome ? outcome : { superseded: true }),
3619
3658
  // The runner shows its own sentences; this is only the last line of defence, so the caller is never left waiting.
3620
- (error) => { console.error('[steel] could not show the connection asked for', error); vacate(job, current() ? { ok: false, said: job.req.memberId ? 'The model could not show member ' + job.req.memberId + '. Press Show in the model again, or find it in the Model panel.' : 'The model could not show connection ' + job.req.jointId + '. Press Open in the model again, or find it in the Model panel.' } : { superseded: true }); });
3659
+ (error) => { console.error('[steel] could not show the connection asked for', error); vacate(job, current() ? { ok: false, said: job.req.rfiId ? 'FloLess could not show ' + job.req.rfiId + '. Find it on the RFIs page, or press it in the chat again.' : job.req.memberId ? 'The model could not show member ' + job.req.memberId + '. Press Show in the model again, or find it in the Model panel.' : 'The model could not show connection ' + job.req.jointId + '. Press Open in the model again, or find it in the Model panel.' } : { superseded: true }); });
3621
3660
  };
3622
3661
  window.flolessEditorState = { project: PROJECT, ready: false };
3623
3662
  const text = (value) => typeof value === 'string' && value ? value : '';
3624
3663
  // #2450: a request may also ask to raise an RFI, and name the check to show first.
3625
3664
  // #2471: or name one member (an AI Chat answer's cited member) instead of a connection.
3665
+ // #2874: or one RFI a chat message mentioned, shown on this project's RFIs page.
3626
3666
  const normalise = (req) => req && text(req.jointId)
3627
3667
  ? { jointId: req.jointId, ...(req.raiseRfi === true ? { raiseRfi: true } : {}), ...(text(req.checkId) ? { checkId: req.checkId } : {}) }
3628
- : req && text(req.memberId) ? { memberId: req.memberId } : null;
3668
+ : req && text(req.memberId) ? { memberId: req.memberId }
3669
+ : req && text(req.rfiId) && /^RFI-\d{3,16}$/.test(req.rfiId) ? { rfiId: req.rfiId } : null;
3629
3670
  window.flolessEditorFocus = (req) => {
3630
3671
  if (!normalise(req)) return false;
3631
3672
  const id = typeof req.requestId === 'string' && req.requestId ? req.requestId : 'editor-' + (++made);
@@ -4026,6 +4067,7 @@ let GridDisplay = null; // grid-display.js — the Grid pane's ONE boundary betw
4026
4067
  // directly above: a deferred module script binds AFTER boot() has drawn, and the vm harness cannot see it.
4027
4068
  let ViewGen = null; // steel-view-generation.js pure F11 helpers — loaded before saved views are sanitised
4028
4069
  let ModelCmd = null; // steel-model-commands.js — the model boundary's WRITE half (unit 5, P3a); the read half is steel-model-adapter.js
4070
+ let AiMarks = null; // steel-ai-marks.js (#2521 row 6): which members rest on an AI decision
4029
4071
  let V2Projection = null, V2Commands = null, V2Validation = null, FilterCore = null, ProfileColours = null, ReferenceSheet = null, ReadConfidence = null;
4030
4072
  let ChatQuestions = null; // model-chat-questions.js — the Questions in chat card and chat labels, shared with every model viewer
4031
4073
  let FramesCore = null; // steel-frames-core.js — the moment-frame schedule rules the server shares: what a frame row is, which girder sizes a sheet shows, how a read may add (#2210)
@@ -4247,6 +4289,7 @@ let reviewEventWatermark = null; // a review frame th
4247
4289
  let reviewCycle = null; // the in-flight refresh: { bounds, attempts, late }
4248
4290
  function reviewEventMatches(m){return m&&typeof m==='object'&&m.type==='review-changed'&&m.appId===APP_ID&&((m.project||'')===PROJECT);}
4249
4291
  /* #2449: an assumption on one of this project's connections was recorded or withdrawn. */
4292
+ function aiDecisionsEventMatches(m){return m&&typeof m==='object'&&m.type==='ai-decisions-changed'&&m.appId===APP_ID&&((m.project||'')===PROJECT);}
4250
4293
  function assumptionEventMatches(m){return m&&typeof m==='object'&&m.type==='connection-assumptions-changed'&&m.appId===APP_ID&&((m.project||'')===PROJECT);}
4251
4294
  function reviewFrameOrderable(m){return Number.isSafeInteger(m.reviewRevision)&&m.reviewRevision>=0;}
4252
4295
  function editorHasUnsavedWork(){const sv=document.getElementById('saveStat');return !!sv&&(sv.classList.contains('dirty')||sv.classList.contains('err')||sv.classList.contains('conflict'));}
@@ -4397,9 +4440,15 @@ function handleReviewChanged(m){
4397
4440
  /* #2521 row 5: paint the Quick model chip from the server's `quick` (the snapshot served, or what a save stored). The
4398
4441
  server sends the words; a precise model, or no field, hides the chip. It describes the model AS LAST SAVED. */
4399
4442
  let lastSavedQuick=null;
4443
+ /* #2521 row 6: the same verdict for the AI-decision marks, which must never read "precise" from a label FloLess never
4444
+ read: undefined until a snapshot or save answered (the marks then say they could not read everything), null only
4445
+ for an explicit precise answer, {state:'unknown'} for a verdict it cannot read. */
4446
+ let lastSavedVerdict;
4400
4447
  function paintQuickStat(q){
4401
4448
  if(q===undefined)return; // a reply whose body could not be read leaves the last label in place; null = precise
4449
+ lastSavedVerdict=q===null?null:q&&q.state==='quick'&&typeof q.short==='string'?q:{state:'unknown'};
4402
4450
  lastSavedQuick=q&&(q.state==='quick'||q.state==='unknown')&&typeof q.short==='string'?q:null;
4451
+ if(window.aiMarksRepaintStrip)window.aiMarksRepaintStrip(); // #2521 row 6: the strip reads the last-saved verdict too
4403
4452
  const el=document.getElementById('quickStat');if(!el)return;
4404
4453
  // Precise: hide the chip AND clear an open confidence report's line, so both describe the same saved document.
4405
4454
  if(!lastSavedQuick){el.style.display='none';el.textContent='';el.removeAttribute('data-tip');if(typeof renderConfQuick==='function')renderConfQuick();return;}
@@ -4477,6 +4526,8 @@ function startContractEvents(){
4477
4526
  same value lands immediately after, so nothing is lost by dropping it. */
4478
4527
  if(displayUnitsEventMatches(m)){handleDisplayUnitsChanged(m);return;}
4479
4528
  // #2449: an assumption was recorded or withdrawn. Forget what the inspector was told and ask again.
4529
+ // #2521 row 6: the AI-decision record changed. Forget what Inspect was told (a late answer from before is dropped by the epoch).
4530
+ if(aiDecisionsEventMatches(m)){if(contractEventReady&&window.aiMarksRecordChanged)window.aiMarksRecordChanged();return;}
4480
4531
  if(assumptionEventMatches(m)){if(contractEventReady&&window.forgetConnectionAssumptions)window.forgetConnectionAssumptions();return;}
4481
4532
  if(reviewEventMatches(m)){if(!contractEventReady){if(reviewFrameOrderable(m)&&(!reviewEventWatermark||m.reviewRevision>=reviewEventWatermark.reviewRevision))reviewEventWatermark=m;}else handleReviewChanged(m);return;}
4482
4533
  if(!contractEventMatches(m))return;if(!contractEventReady)bufferContractEvent(m);else handleContractChanged(m);};
@@ -4705,7 +4756,7 @@ async function boot() {
4705
4756
  if (!APP_ID) { showEmpty('⊞', 'No workflow selected', 'Open a workflow in the FloLess canvas, then open the contract editor from that workflow’s node.'); return; }
4706
4757
  armEarlyViewToggle(); // BEFORE the first await — that is the whole point; see above
4707
4758
  startContractEvents(); // subscribe first; contract events buffer until the atomic snapshot is installed
4708
- [DisplayUnits, GridDisplay, SteelCore, ViewGen, ModelCmd, DetailRefs, V2Projection, V2Commands, V2Validation, SplitView, FilterCore, PlanXf, CatalogPicker, ModelEditor, ViewportToolbar, ModelLighting, PointerDock, EditorShell, ReviewClient, ProfileColours, ReferenceSheet, ReadConfidence, CkStd, ModelPanelBridge, ChatQuestions, SteelSlim, LastSeen, MarksCore, FramesCore] = await Promise.all([
4759
+ [DisplayUnits, GridDisplay, SteelCore, ViewGen, ModelCmd, DetailRefs, V2Projection, V2Commands, V2Validation, SplitView, FilterCore, PlanXf, CatalogPicker, ModelEditor, ViewportToolbar, ModelLighting, PointerDock, EditorShell, ReviewClient, ProfileColours, ReferenceSheet, ReadConfidence, CkStd, ModelPanelBridge, ChatQuestions, SteelSlim, LastSeen, MarksCore, FramesCore, AiMarks] = await Promise.all([
4709
4760
  import('./display-units.js'), import('./grid-display.js'),
4710
4761
  import('./steel-3d-core.js'), import('./steel-view-generation.js'), import('./steel-model-commands.js'),
4711
4762
  import('./steel-detail-refs.js'), import('./steel-model-v2-projection.js'),
@@ -4716,7 +4767,7 @@ async function boot() {
4716
4767
  import('./connection-review-client.js'), import('./steel-profile-colours.js'),
4717
4768
  import('./steel-reference-sheet.js'), import('./steel-read-confidence.js'),
4718
4769
  import('./checkpoint-standard.js'), import('./model-panel-bridge.js'), import('./model-chat-questions.js'),
4719
- import('./steel-model-slim.js'), import('./steel-last-seen.js'), import('./steel-marks-core.js'), import('./steel-frames-core.js'),
4770
+ import('./steel-model-slim.js'), import('./steel-last-seen.js'), import('./steel-marks-core.js'), import('./steel-frames-core.js'), import('./steel-ai-marks.js'),
4720
4771
  ]);
4721
4772
  ({ FT_TO_MM, IN_TO_MM, LB_PER_FT_TO_KG_PER_M } = SteelCore); // the shared unit constants, bound before main() and every reader of them
4722
4773
  // BEFORE the first paint, deliberately. Every length on this page reads through it, so resolving it
@@ -5375,6 +5426,211 @@ function seeChangesFromOpenTab(opener) { openChangeList({ situation: 'B', baseTa
5375
5426
  function main(bootRecordedBase) {
5376
5427
  let P, X0,Y0,X1,Y1, FT, RB64, EXTX, EXTY, profs, NO_PLAN_VIEW=false; // per-plan, set by setPlan()
5377
5428
  let v2IdSeq=0;
5429
+ /* #2521 row 6: what rests on an AI decision, marked on the canvas, in 3D and in Inspect, with one strip for what cannot
5430
+ be marked. Plan: docs/superpowers/specs/2026-10-29-quick-model-row6-PLAN.md (Revisions 1 and 2). The analysis
5431
+ (web/steel-ai-marks.js) reads the LIVE model, so a mark follows the member on screen; what is shown combines it with
5432
+ the last-saved verdict (`aiMarksDisplayState`), so the screen never says less than the Quick label. A mark is a
5433
+ FINDING: unmarked never means drawn, and the strip says so whenever anything is shown. */
5434
+ let showAiMarks=(()=>{try{return localStorage.getItem('steel:aiMarks:v2')!=='0';}catch(_){return true;}})(); // ⋯ Display → AI decisions: on by default (owner ruling 2026-10-29)
5435
+ let aiMarksMemo=null,aiStripOpen=false,aiMarks3dSent=null;
5436
+ function aiMarksNow(){
5437
+ if(!AiMarks||!C||C.type!=='steel.model/v2')return null;
5438
+ // Every edit, undo, redo and installed save reply bumps the generation; a replaced model is a new C. So hover, zoom and
5439
+ // selection repaints reuse one analysis (plan R11).
5440
+ if(aiMarksMemo&&aiMarksMemo.c===C&&aiMarksMemo.gen===modelEditGeneration)return aiMarksMemo.marks;
5441
+ const marks=AiMarks.aiDecisionMarksOf(C);aiMarksMemo={c:C,gen:modelEditGeneration,marks};return marks;
5442
+ }
5443
+ function aiMarksState(){if(!AiMarks)return'none';return AiMarks.aiMarksDisplayState(aiMarksNow()||{state:'none'},lastSavedVerdict);}
5444
+ const aiHasCanvasMarks=m=>!!m&&(m.ends.length>0||m.joints.length>0);
5445
+ const aiEndWord=(role,end)=>role==='column'?(end===0?'base':'top'):(end===0?'start':'end');
5446
+ /* What the mark means, on the member's OWN tooltip (the marks themselves never take a pointer). */
5447
+ function aiTipFor(m){
5448
+ if(!showAiMarks||!m)return'';const marks=aiMarksNow(),list=marks&&marks.members.get(m.id);if(!list)return'';
5449
+ const ends=list.filter(x=>x.kind==='height').map(x=>aiEndWord(m.role,x.end));
5450
+ const parts=[];
5451
+ if(ends.length)parts.push('The AI chose this member’s '+ends.join(' and ')+' height'+(ends.length>1?'s':'')+'.');
5452
+ if(list.some(x=>x.kind==='connection'))parts.push('The AI assumed a connection on it.');
5453
+ return parts.length?parts.join(' ')+' Select it to see why.':'';
5454
+ }
5455
+ function aiDistToSeg(p,a,b){return SteelCore.projectPointOnSegment2d(p,a,b,SteelCore.SEG_DEGENERACY.atMost(0)).distance;} // only an exactly zero-length segment is a point
5456
+ /* A joint's ring: the main member's end its `at` names (a base plate, a beam-end shear plate); else the end of a secondary
5457
+ member nearest the main member's line, where it frames in; else the middle of the main member. */
5458
+ function aiJointPoint2d(j,byId){
5459
+ const main=j.main&&byId.get(j.main);
5460
+ if(!main){const sm=j.memberIds.map(id=>byId.get(id)).find(Boolean);return sm?[(sm.wp[0][0]+sm.wp[1][0])/2,(sm.wp[0][1]+sm.wp[1][1])/2]:null;}
5461
+ if(j.mainEnd===0||j.mainEnd===1)return main.wp[j.mainEnd];
5462
+ let best=null,bd=Infinity;
5463
+ for(const id of j.memberIds){if(id===j.main)continue;const sm=byId.get(id);if(!sm)continue;for(const p of sm.wp){const d=aiDistToSeg(p,main.wp[0],main.wp[1]);if(d<bd){bd=d;best=p;}}}
5464
+ return best||[(main.wp[0][0]+main.wp[1][0])/2,(main.wp[0][1]+main.wp[1][1])/2];
5465
+ }
5466
+ /* The canvas marks of the plan on screen, sized in 1/zoom like the review marker (updateBadges redraws them on zoom). */
5467
+ function aiMarksInner(){
5468
+ if(!showAiMarks||!P||!Array.isArray(P.members))return'';
5469
+ const marks=aiMarksNow();if(!aiHasCanvasMarks(marks))return'';
5470
+ // Positions come from every member this plan draws; visibility only decides whether a mark is shown. An end mark needs
5471
+ // its member shown; a ring needs ANY member of the joint shown (it rests on the connection whichever one is hidden).
5472
+ const byId=new Map(),shown=new Set();
5473
+ for(const m of P.members)if(m&&Array.isArray(m.wp)&&m.wp[0]&&m.wp[1]){byId.set(m.id,m);if(visible2d(m))shown.add(m.id);}
5474
+ const h=10/zoom,sw=1.6/zoom,r=8/zoom;let out='';
5475
+ for(const e of marks.ends){const m=shown.has(e.memberId)&&byId.get(e.memberId),p=m&&m.wp[e.end];if(!p)continue;
5476
+ out+=`<rect class=ai-end-mark data-ai-member="${esc(e.memberId)}" data-ai-end="${e.end}" x="${p[0]-h/2}" y="${p[1]-h/2}" width="${h}" height="${h}" style="stroke-width:${sw}px"/>`;}
5477
+ for(const j of marks.joints){if(!j.memberIds.some(id=>shown.has(id)))continue;const p=aiJointPoint2d(j,byId);if(!p)continue;
5478
+ out+=`<circle class=ai-joint-mark data-ai-joint="${esc(j.jointId)}" cx="${p[0]}" cy="${p[1]}" r="${r}" style="stroke-width:${sw}px"/>`;}
5479
+ return out;
5480
+ }
5481
+ function aiPlanLabel(viewId){const plan=(C.plans||[]).find(p=>V2Projection.planViewId(p)===viewId);return plan?String(plan.title||plan.sheet||viewId):String(viewId);}
5482
+ /* The record's words for one decision, when FloLess has read them: what was chosen, why, and how sure the AI was. */
5483
+ function aiChosenText(id,marks){
5484
+ const entry=marks.entries.get(id),rec=aiRecord.rows.get(id);
5485
+ const chosen=(entry&&typeof entry.chosen==='string'&&entry.chosen)||(rec&&rec.chosen)||'';
5486
+ let t=chosen?'the AI chose '+chosen:'the AI decided it';
5487
+ if(rec&&rec.why)t+=' (why: '+String(rec.why).replace(/\.\s*$/,'')+(rec.confidence?'; '+rec.confidence+' confidence':'')+')';
5488
+ else if(!AI_DECISION_ID.test(id))t+=' (FloLess cannot read this decision’s id, so it cannot say why)';
5489
+ else if(aiRecord.absent.has(id))t+=' (this decision is not in the project’s record, so FloLess cannot say why)';
5490
+ else if(aiRecordFailed(id))t+=' (FloLess could not read why just now; it tries again when you select the member)';
5491
+ else if(aiRecord.inflight.has(id))t+=' (reading why…)';
5492
+ return t;
5493
+ }
5494
+ function aiNoteText(item,marks){
5495
+ const entry=item.decisionId?marks.entries.get(item.decisionId):null,chosen=entry&&entry.chosen?': '+entry.chosen:'';
5496
+ if(item.reason==='unreadable')return'An AI decision FloLess could not read.';
5497
+ switch(item.channel){
5498
+ case'filter':return'The Drawing Filter (which sheets and areas the read used) was chosen by the AI'+chosen+'. Every member rests on that choice.';
5499
+ case'setup-origin':return'The model origin was chosen by the AI'+chosen+'. Every member’s position rests on it.';
5500
+ case'audit-gap':return'The AI settled a question the drawings left open'+chosen+'.';
5501
+ case'unmodelled-detail':return'The AI left a detail unmodelled'+chosen+'.';
5502
+ case'connection':return'The AI assumed a connection FloLess cannot place on a member now'+chosen+'.';
5503
+ case'setup':return'The AI decided the scale or level of a drawing view no longer in the model'+chosen+'.';
5504
+ default:return'An AI decision FloLess could not read.';
5505
+ }
5506
+ }
5507
+ /* The strip: legend, the view's own AI setup, the count of model-wide decisions, the general sentence, and Details. */
5508
+ function renderAiStrip(){
5509
+ const el=document.getElementById('aiStrip');if(!el)return;
5510
+ const state=C?aiMarksState():'none';
5511
+ if(state==='none'){if(!el.hidden){el.hidden=true;el.textContent='';el.dataset.key='';}return;}
5512
+ const marks=aiMarksNow()||{ends:[],joints:[],views:new Map(),model:[],entries:new Map(),members:new Map()};
5513
+ const vid=C&&C.plans&&C.plans[C.active]?V2Projection.planViewId(C.plans[C.active]):'';
5514
+ const key=[state,showAiMarks,aiStripOpen,aiMarksMemo&&aiMarksMemo.gen,vid,aiRecord.epoch].join('|');
5515
+ if(el.dataset.key===key&&!el.hidden)return; // render() calls this on every repaint: rebuild only when something it shows moved
5516
+ const hadFocus=el.contains(document.activeElement)?document.activeElement.getAttribute('data-command-id'):null;
5517
+ el.dataset.key=key;el.textContent='';el.hidden=false;
5518
+ const line=document.createElement('div');line.className='ai-line';el.appendChild(line);
5519
+ const span=(cls,text)=>{const x=document.createElement('span');if(cls)x.className=cls;x.textContent=text;return x;};
5520
+ if(state==='unknown')line.appendChild(span('ai-lead','FloLess could not read every AI decision this model rests on.'));
5521
+ else line.appendChild(span('ai-lead','AI decisions'));
5522
+ const keyMark=(shape,text)=>{const k=document.createElement('span');k.className='ai-key';
5523
+ k.innerHTML=shape==='sq'?'<svg width=11 height=11 aria-hidden=true><rect class=sq x=1.5 y=1.5 width=8 height=8 /></svg>':'<svg width=12 height=12 aria-hidden=true><circle class=rg cx=6 cy=6 r=4.5 /></svg>';
5524
+ k.appendChild(document.createTextNode(text));return k;};
5525
+ if(showAiMarks&&marks.ends.length)line.appendChild(keyMark('sq','height the AI chose'));
5526
+ if(showAiMarks&&marks.joints.length)line.appendChild(keyMark('rg','connection the AI assumed'));
5527
+ if(!showAiMarks&&aiHasCanvasMarks(marks))line.appendChild(span('','Marks hidden (⋯ Display → AI decisions).'));
5528
+ const viewRows=vid?marks.views.get(vid):null;
5529
+ if(viewRows&&viewRows.length){
5530
+ const rows=[...new Set(viewRows.map(v=>v.row))];
5531
+ const chip=span('chip assumed','AI chose this view’s '+rows.map(r=>r==='scale'?'scale':'level').join(' and '));
5532
+ chip.tabIndex=0;chip.setAttribute('role','note');
5533
+ chip.setAttribute('data-command-id','steel.ai-decision-view-note#'+vid);chip.setAttribute('data-command-instance-label',aiPlanLabel(vid));
5534
+ const said=viewRows.map(v=>'its '+(v.row==='scale'?'drawing scale':'level')+(marks.entries.get(v.decisionId)&&marks.entries.get(v.decisionId).chosen?' ('+marks.entries.get(v.decisionId).chosen+')':'')).join(' and ');
5535
+ const tip='The AI decided '+said+' for '+aiPlanLabel(vid)+'. Every member drawn on this view rests on that choice, and Inspect says so for each. Not reviewed.';
5536
+ chip.setAttribute('data-tip',tip);chip.setAttribute('aria-label',tip);
5537
+ line.appendChild(chip);
5538
+ }
5539
+ if(marks.model.length)line.appendChild(span('','+ '+marks.model.length+' that bear'+(marks.model.length===1?'s':'')+' on the whole model.'));
5540
+ line.appendChild(span('','Unmarked members may still rest on AI decisions FloLess cannot trace.'));
5541
+ const more=document.createElement('button');more.type='button';more.className='ai-more';more.textContent=aiStripOpen?'Less':'Details';
5542
+ more.setAttribute('data-command-id','steel.ai-decisions-note');more.setAttribute('aria-expanded',String(aiStripOpen));more.setAttribute('aria-controls','aiStripDetails');
5543
+ more.setAttribute('data-tip','What the AI decided that bears on the whole model, and what the marks and the label each describe');
5544
+ more.onclick=e=>{e.stopPropagation();aiStripOpen=!aiStripOpen;renderAiStrip();};
5545
+ line.appendChild(more);
5546
+ if(aiStripOpen){
5547
+ const d=document.createElement('div');d.className='ai-details';d.id='aiStripDetails';
5548
+ if(marks.model.length){const ul=document.createElement('ul');for(const item of marks.model){const li=document.createElement('li');li.textContent=aiNoteText(item,marks);ul.appendChild(li);}d.appendChild(ul);}
5549
+ const n=marks.decisionCount;
5550
+ d.appendChild(span('',(n?'Your current edits rest on '+n+' AI decision'+(n===1?'':'s')+' FloLess can trace. ':'Your current edits rest on no AI decision FloLess can trace. ')
5551
+ +'The marks follow your current edits; the Quick model label describes the model as last saved. None of these decisions is reviewed.'));
5552
+ el.appendChild(d);
5553
+ }
5554
+ if(hadFocus){const back=el.querySelector('[data-command-id="'+CSS.escape(hadFocus)+'"]');if(back)back.focus();}
5555
+ }
5556
+ /* Inspect, one member selected: every AI decision it rests on, in words, then what FloLess cannot see. */
5557
+ function inspectorAiDecisions(m,canonical,p){
5558
+ const marks=aiMarksNow(),list=marks&&marks.members.get(canonical.id);if(!list||!list.length)return;
5559
+ aiRecordWant([...new Set(list.flatMap(x=>x.kind==='height'?x.decisionIds:[x.decisionId]))]);
5560
+ const box=document.createElement('div');box.className='hint v2-ai-decisions';box.setAttribute('role','note');box.tabIndex=0;
5561
+ box.setAttribute('data-command-id','steel.inspector-ai-decisions');box.setAttribute('aria-label','Rests on AI decisions');
5562
+ box.style.cssText='margin:4px 0 8px;grid-column:1/-1;line-height:1.5';
5563
+ // The record's words arrive later: they refill THIS note only, never the panel, so a height being typed is never lost.
5564
+ box._aiRefill=()=>{const now=aiMarksNow(),l=now&&now.members.get(canonical.id);if(l&&l.length)fillAiNote(box,m,canonical,l,now);};
5565
+ fillAiNote(box,m,canonical,list,marks);
5566
+ // After the elevation fields' row and any notes under it, like the height notes; else at the end of the panel.
5567
+ const input=document.getElementById(m.role==='column'?'tosC':'tosB'),cell=input&&input.closest('.pval');
5568
+ let anchor=cell&&cell.parentElement&&cell.parentElement!==document.getElementById('panel')?cell.parentElement:null;
5569
+ if(anchor){while(anchor.nextElementSibling&&/\bv2-elevation-/.test(anchor.nextElementSibling.className))anchor=anchor.nextElementSibling;anchor.after(box);}
5570
+ else p.appendChild(box);
5571
+ }
5572
+ function fillAiNote(box,m,canonical,list,marks){
5573
+ box.textContent='';
5574
+ const head=document.createElement('div');head.className='ai-head';
5575
+ const chip=document.createElement('span');chip.className='chip assumed';chip.textContent='AI decision';
5576
+ const b=document.createElement('b');b.textContent='Rests on AI decisions';head.append(chip,b);box.appendChild(head);
5577
+ for(const mark of list){
5578
+ const row=document.createElement('div');row.className='ai-row';
5579
+ if(mark.kind==='height'){
5580
+ const z=(mark.end===0?canonical.from:canonical.to)?.z,now=z&&Number.isFinite(z.known)?fmtDispElev(z.known):'';
5581
+ const word=aiEndWord(m.role,mark.end),n=mark.decisionIds.length;
5582
+ row.textContent=word.charAt(0).toUpperCase()+word.slice(1)+' height'+(now?' '+now:'')+' rests on '+(n===1?'an AI decision':n+' AI decisions')
5583
+ +(mark.derived?', derived from '+(n===1?'it':'them')+' by a copy, split or merge':'')+': '+mark.decisionIds.map(id=>aiChosenText(id,marks)).join('; ')+'.';
5584
+ }else if(mark.kind==='connection'){
5585
+ const joint=(C.joints||[]).find(j=>j&&j.id===mark.jointId);
5586
+ row.textContent='Its connection '+String(joint&&joint.name||mark.jointId)+' rests on an AI assumption: '+aiChosenText(mark.decisionId,marks)+'.';
5587
+ }else{
5588
+ row.textContent='Drawn on '+aiPlanLabel(mark.viewId)+', whose '+(mark.row==='scale'?'drawing scale':'level')+' the AI decided: '+aiChosenText(mark.decisionId,marks)+'.';
5589
+ }
5590
+ box.appendChild(row);
5591
+ }
5592
+ const foot=document.createElement('div');foot.className='ai-foot';
5593
+ foot.textContent='Not reviewed. FloLess lists what it can trace; this member may still rest on other AI decisions.';box.appendChild(foot);
5594
+ }
5595
+ /* The record's words (why, confidence), read by id on demand (plan R8, V2). In-flight requests are shared; an epoch,
5596
+ bumped when the record changes or the model is replaced, drops an answer that arrives after it is stale, before it
5597
+ reaches the cache or the screen. A failed read is retried after half a minute. */
5598
+ const AI_DECISION_ID=/^[0-9a-f]{12}$/; // the record's id shape: anything else is never sent (one bad id would refuse the whole batch)
5599
+ const aiRecord={epoch:0,rows:new Map(),failed:new Map(),absent:new Set(),inflight:new Map(),repaint:0};
5600
+ function aiRecordInvalidate(){aiRecord.epoch++;aiRecord.rows.clear();aiRecord.failed.clear();aiRecord.absent.clear();aiRecord.inflight.clear();}
5601
+ const aiRecordFailed=id=>{const t=aiRecord.failed.get(id);return t!==undefined&&Date.now()-t<30000;};
5602
+ function aiRecordWant(ids){
5603
+ if(!PROJECT)return;
5604
+ const missing=ids.filter(id=>AI_DECISION_ID.test(id)&&!aiRecord.rows.has(id)&&!aiRecord.absent.has(id)&&!aiRecordFailed(id)&&!aiRecord.inflight.has(id));
5605
+ for(let i=0;i<missing.length;i+=200){
5606
+ const chunk=missing.slice(i,i+200),epoch=aiRecord.epoch;
5607
+ const done=fetch('/api/projects/'+encodeURIComponent(PROJECT)+'/ai-decisions?ids='+chunk.join(','))
5608
+ .then(r=>r.ok?r.json():Promise.reject(new Error('the server answered '+r.status)))
5609
+ .catch(e=>{console.warn('ai-decisions: could not read the record for project',PROJECT,String(e&&e.message||e));return null;}).then(d=>{
5610
+ if(epoch!==aiRecord.epoch)return; // stale: the record changed while this was asked
5611
+ for(const id of chunk)aiRecord.inflight.delete(id);
5612
+ const rows=d&&!d.unavailable&&Array.isArray(d.decisions)?d.decisions:null;
5613
+ for(const row of rows||[])if(row&&typeof row.id==='string')aiRecord.rows.set(row.id,row);
5614
+ // A full answer that lacks an id means the record does not hold it: said once, not retried until the record changes.
5615
+ // No answer, or an unavailable record, is a failed read: retried after half a minute.
5616
+ for(const id of chunk)if(!aiRecord.rows.has(id)){if(rows)aiRecord.absent.add(id);else aiRecord.failed.set(id,Date.now());}
5617
+ if(!aiRecord.repaint)aiRecord.repaint=requestAnimationFrame(()=>{aiRecord.repaint=0;for(const b of document.querySelectorAll('.v2-ai-decisions'))if(b._aiRefill)b._aiRefill();}); // the note only: never the panel's fields
5618
+ });
5619
+ for(const id of chunk)aiRecord.inflight.set(id,done);
5620
+ }
5621
+ }
5622
+ /* The 3D marks follow the 2D ones: the same analysis, the same switch. Pushed only when they change. */
5623
+ function syncAiMarks3d(force){
5624
+ if(!view3dReady)return; // through the Steel adapter, never the raw viewport (the seam ratchet only shrinks)
5625
+ const marks=showAiMarks?aiMarksNow():null;
5626
+ if(!force&&aiMarks3dSent&&aiMarks3dSent.marks===marks)return;
5627
+ aiMarks3dSent={marks};
5628
+ modelEditor.steel.setAiMarks(aiHasCanvasMarks(marks)?AiMarks.canvasMarksOf(marks):null);
5629
+ }
5630
+ function updAiMarksToggle(){const b=document.getElementById('aiMarksToggleB');if(!b)return;b.hidden=!aiHasCanvasMarks(aiMarksNow());b.classList.toggle('on',showAiMarks);b.setAttribute('aria-checked',String(showAiMarks));}
5631
+ /* The two callers outside main(): the label paint (paintQuickStat) and the record-changed event. */
5632
+ window.aiMarksRepaintStrip=renderAiStrip;
5633
+ window.aiMarksRecordChanged=()=>{aiRecordInvalidate();render();};
5378
5634
  const newModelId=()=>`m-v2-${Date.now().toString(36)}-${(v2IdSeq++).toString(36)}`;
5379
5635
  V2_SESSION=V2Commands.createV2CommandSession(C,{
5380
5636
  validate:doc=>V2Validation.validateClientSteelModelV2(doc,V2_SCHEMA),
@@ -5531,7 +5787,7 @@ function installMemberEndContract(doc,etag,revision,keepHistory){
5531
5787
  // apply() restores decisions from `serverDecided`, so its history stays valid (see adoptSaveReply).
5532
5788
  if(!keepHistory){undo.length=0;redo.length=0;picStore.clear();picSeen=new Map();updUR();} // nothing left to undo to, so the pictures kept for it go too (the live library is fingerprinted again at the next snapshot)
5533
5789
  serverDecided=decidedMembers(doc.members);
5534
- bumpModelEditGeneration(); // the server replaced the document under the editor; nothing captured before this describes what is now on screen
5790
+ aiRecordInvalidate();bumpModelEditGeneration(); // the server replaced the document under the editor; nothing captured before this describes what is now on screen
5535
5791
  // A restamped row is rewritten too: it still holds the document from BEFORE the server's change, and a
5536
5792
  // reload would put that back — a staled decision returning live, refused on the next save. A row from
5537
5793
  // another generation (a stale draft that could not be parked) is not ours to touch: only the user's own
@@ -7842,11 +8098,21 @@ function updUR(){document.getElementById('undoB').disabled=!undo.length;document
7842
8098
  // AND in 3D, stable across plans. (The per-plan `profs` still drives the legend/datalist; only the colour
7843
8099
  // index moved off it — a blank/RFI/other-plan profile must not shift a real profile's slot.) Rebuilt at
7844
8100
  // render() top so it tracks edits without touching every profs.push site.
7845
- let colorRank=[];
8101
+ let colorRank=null; // the ProfileColours.profileColourContext of the last render
7846
8102
  const canonProfile=s=>ProfileColours.canonicalProfile(s);
7847
- function buildColorRank(){colorRank=ProfileColours.profileColourRank(C,WT);}
8103
+ function buildColorRank(){colorRank=ProfileColours.profileColourContext(C,WT,profileColourSpellings);} // rank + per-section member spellings, rebuilt per render (#2877)
8104
+ // #2877: every spelling the editor's catalogue lists for a member's section, minus aliases that are another
8105
+ // section's own name (ProfileColours.catalogueSpellings, the same rule the scene bake applies to the server
8106
+ // catalogue), so a colour keyed `UC305X97` or `UC305*305*97` resolves identically in 2D, the Inspector, the
8107
+ // Profile colours menu and 3D. Memoised: the catalogue is fixed once loaded and colorFor() runs per member.
8108
+ const _colourSpellings=new Map();
8109
+ function profileColourSpellings(p){const k=String(p==null?'':p);if(_colourSpellings.has(k))return _colourSpellings.get(k);
8110
+ const out=k.trim()?ProfileColours.catalogueSpellings(_profileCatalogRow(_canonDes(k)),s=>_profileCatalogRow(_canonDes(s))):[];_colourSpellings.set(k,out);return out;}
7848
8111
  function colorFor(p){return ProfileColours.profileColour(p,C.profile_colors,colorRank,PAL,message=>console.warn('steel-editor: '+message));}
7849
- function setProfileColour(profile,colour){ProfileColours.setCanonicalProfileColour(C.profile_colors,profile,colour);}
8112
+ // Removes every key a lookup for this section reads (its members' spellings, its catalogue spellings), from a
8113
+ // context built now so an edit since the last render cannot leave a stale spelling that outranks the new key.
8114
+ function setProfileColour(profile,colour){ProfileColours.setCanonicalProfileColour(C.profile_colors,profile,colour,
8115
+ ProfileColours.sectionSpellings(ProfileColours.profileColourContext(C,WT,profileColourSpellings),profile));}
7850
8116
  // F5: per member-type 2D line style. Tokens → px; dashes chosen to avoid the reserved semantic patterns
7851
8117
  // (RFI 10 6, brace 30 8 6 8, grid 12 4 2 4). med+solid (or absent) = today's default (line.member stroke-width:6).
7852
8118
  const MS_W={thin:3,med:6,thick:9},MS_D={solid:'',dashed:'14 8',dotted:'2 8',dashdot:'18 7 3 7'};
@@ -10237,14 +10503,14 @@ function render(){
10237
10503
  // #2214: a column that ends under this sheet's floor is drawn dashed and lighter. It has ONE tooltip, so the
10238
10504
  // below-the-floor sentence and the placeholder sentence are composed rather than competing attributes.
10239
10505
  const _cb=m.belowCut?colBelowInfo(m):null;
10240
- const _tipText=[_cb&&_cb.tip,_phText].filter(Boolean).join(' ');
10506
+ const _tipText=[_cb&&_cb.tip,_phText,aiTipFor(m)].filter(Boolean).join(' ');
10241
10507
  const _ph=_tipText?` data-tip="${esc(_tipText)}"`:'';
10242
10508
  if(pts){const components=pts.components||[pts];s+=components.map((part,index)=>`<polygon class="member${rfi?' rfi':''}${m.belowCut?' colbelow':''}${sel?' sel':''}${fh?' find-hit':''}" data-id="${m.id}" data-part="${index}" points="${_polyStr(part)}" fill="${c}" stroke="${c}"${g}${_ph}/>`).join('');continue;}}
10243
10509
  const ls=memberLineStyle(m); // F5: category line weight/dash. Inline style (NOT a presentation attr) so it beats line.member/.sel CSS width; the glow still cues selection.
10244
10510
  const _fx=on?`filter:drop-shadow(0 0 3px ${c}) drop-shadow(0 0 8px ${c});`:'', _sw=(ls&&ls.w)?`stroke-width:${ls.w}px;`:'', _sd=(ls&&ls.d&&!rfi)?`stroke-dasharray:${ls.d};stroke-linecap:butt;`:''; /* butt WITH a dash: line.member's round cap adds half the stroke width at EACH end of every dash, so at thick (9px) it ate every gap — dashed 14/8 and dotted 2/8 both left -1px of gap and drew solid. Round caps stay on solid lines, where they have nothing to close. */ // RFI keeps its semantic 10 6 dash
10245
10511
  const _sty=(_fx||_sw||_sd)?` style="${_fx}${_sw}${_sd}"`:'';
10246
10512
  // A column below the floor whose footprint cannot be built falls to this line, and must still say what it is (#2214).
10247
- const _lcb=(m.role==='column'&&m.belowCut)?colBelowInfo(m):null,_lt=_lcb?` data-tip="${esc(_lcb.tip)}"`:'';
10513
+ const _lcb=(m.role==='column'&&m.belowCut)?colBelowInfo(m):null,_ltText=[_lcb&&_lcb.tip,aiTipFor(m)].filter(Boolean).join(' '),_lt=_ltText?` data-tip="${esc(_ltText)}"`:'';
10248
10514
  s+=`<line class="member${rfi?' rfi':''}${_lcb?' colbelow':''}${sel?' sel':''}${fh?' find-hit':''}" data-id="${m.id}"${_lt} x1="${m.wp[0][0]}" y1="${m.wp[0][1]}" x2="${m.wp[1][0]}" y2="${m.wp[1][1]}" stroke="${c}"${_sty}/>`;}
10249
10515
  {const hsel=sel2d().filter(visible2d);if(hsel.length>=1&&!P.elevationView){const HR=epR();for(const sm of hsel)for(let i=0;i<2;i++) s+=`<circle class="handle ${i===0?'ep-start':'ep-end'}" data-mid="${sm.id}" data-h="${i}" cx="${sm.wp[i][0]}" cy="${sm.wp[i][1]}" r="${HR}"/>`;}} // end 1 (start) yellow, end 2 (end) magenta · shown for every selected member · radius grows with zoom (epR) so it stays visible against the thick line
10250
10516
  if(mode==='add'||(picking&&pickKind==='profile')){
@@ -10280,13 +10546,14 @@ function render(){
10280
10546
  s+=renderPropLabels(); // right-click property-label chips (2D); 3D labels ride the div-overlay pool
10281
10547
  s+=renderSelLenLabels(); // on-select member-length chips (2D), gated by the ⋯ Display "Show member length" toggle
10282
10548
  s+=memberEndReviewSvg();
10549
+ s+='<g class=ai-marks aria-hidden=true>'+aiMarksInner()+'</g>'; // #2521 row 6: ends and joints that rest on an AI decision (never a click target)
10283
10550
  if(P.frame)s+=axisGlyphSvg(P.frame.o,P.frame.u,false); // local-axes glyph at the origin (only when a frame is set; removed on reset)
10284
10551
  // No datalist population here any more. The #profiles and #details <datalist>s went with the rest of
10285
10552
  // them (an OS-drawn white popup has no themed mode), and COMBO_SRC.profiles/.details already read
10286
10553
  // `profs` and `detTexts()` live — so the combobox offers the same list with no mirror to keep filled.
10287
10554
  // Deleting the elements while these two writes stayed made render() throw on null here, which also
10288
10555
  // killed every call after it on this line (stats/panel/upd*/syncDisplayRows). Measured in Chromium.
10289
- svg.innerHTML=s; if(P.elevationView)sizeElevationLabels(); layoutPropLabels2d(); stats(); panel(); updUR(); updDup(); updRegistration(); updateMemberEndStatus(); updConf(); updCS(); updConnBtn(); updBpBtn(); updSpBtn(); syncReachRow(); syncDisplayRows(); syncUnitsRow();syncEnvChip();restoreProfilePickerFocus(profileFocusToken);if(typeof askAiRefreshSelection==='function')askAiRefreshSelection();
10556
+ svg.innerHTML=s; if(P.elevationView)sizeElevationLabels(); layoutPropLabels2d(); stats(); panel(); updUR(); updDup(); updRegistration(); updateMemberEndStatus(); updConf(); updCS(); updConnBtn(); updBpBtn(); updSpBtn(); syncReachRow(); syncDisplayRows(); syncUnitsRow();syncEnvChip();renderAiStrip();syncAiMarks3d();restoreProfilePickerFocus(profileFocusToken);if(typeof askAiRefreshSelection==='function')askAiRefreshSelection();
10290
10557
  if(selFilterReady)reflectSelFilter(); // keep the Select-bar Members/Connections buttons in sync with the model — a new/removed connection kind (e.g. the first auto-detailed base plate) flips their on/off without a manual toggle. Gated on selFilterReady so it doesn't run until the deferred first reflect has armed it (that reflect needs BASE_MEMBER_TYPES, initialised later in main()).
10291
10558
  if(view3dShown&&window.Steel3DView){updateIsolateBtn();if((selIds.size||selGridIds.size)&&modelEditor.steel.selectedClips&&modelEditor.steel.selectedClips().length)modelEditor.steel.setSelectedClips([]);} // canonical commits keep member + grid highlight in sync; selecting geometry still clears clip-tool selection (exclusive)
10292
10559
  syncLegendToPane(); // the Objects list: the selection, and in 2D the sheet it lists
@@ -10616,7 +10883,8 @@ function updateBadges(){const R=12/zoom,F=13/zoom,ox=el=>(+el.dataset.fi-(+el.da
10616
10883
  svg.querySelectorAll('circle.handle,circle.dimhandle').forEach(h=>h.setAttribute('r',epR()));
10617
10884
  // (brace arrowheads need no rescale here — they are content-unit sized, so they scale with the member
10618
10885
  // stroke exactly like the line they cap. See braceHeadPoints().)
10619
- {const dg=svg.querySelector('g.dimsg');if(dg)dg.innerHTML=renderDimsInner();} // dims shrink below DIM_ZMIN (see dimSvg) so dense dims don't overlap when zoomed out (B8) — every part of a dim is zoom-derived, so rebuild the group rather than patch it
10886
+ {const dg=svg.querySelector('g.dimsg');if(dg)dg.innerHTML=renderDimsInner();}
10887
+ {const ag=svg.querySelector('g.ai-marks');if(ag)ag.innerHTML=aiMarksInner();} // #2521 row 6: the AI-decision marks hold their screen size while zooming // dims shrink below DIM_ZMIN (see dimSvg) so dense dims don't overlap when zoomed out (B8) — every part of a dim is zoom-derived, so rebuild the group rather than patch it
10620
10888
  sizeElevationLabels(); // an elevation's level text (#2780)
10621
10889
  sizeGridBubbles(); // radius, font AND centre — the bubble hangs off its line end by its own radius, so a zoom that changes the radius moves it too
10622
10890
  // property-label chips: recompute size + stacked screen offset from the baked anchor (ax,ay) + per-row screen
@@ -10876,7 +11144,7 @@ function projectedMemberLookup(presence=V2Projection.createMemberPresenceIndex(C
10876
11144
 
10877
11145
  function syncV2SelectionNotice(p){
10878
11146
  if(!p||!selIds.size||viewPropsId)return; // a view in the panel keeps the selection, not its notices
10879
- p.querySelectorAll('.v2-selection-notice,.v2-elevation-warning,.v2-elevation-proposal,.v2-elevation-answered').forEach(el=>el.remove());
11147
+ p.querySelectorAll('.v2-selection-notice,.v2-elevation-warning,.v2-elevation-proposal,.v2-elevation-answered,.v2-ai-decisions').forEach(el=>el.remove());
10880
11148
  const presence=V2Projection.createMemberPresenceIndex(C);
10881
11149
  const ids=[...selIds].filter(id=>presence.members.has(id));
10882
11150
  if(!ids.length)return;
@@ -10991,7 +11259,10 @@ function syncV2SelectionNotice(p){
10991
11259
  if(m&&canonical&&m.role==='column'){mark('bos',!Number.isFinite(canonical.from?.z?.known));mark('tosC',!Number.isFinite(canonical.to?.z?.known));}
10992
11260
  else if(m&&canonical){mark('tosA',!Number.isFinite(canonical.from?.z?.known));mark('tosB',!Number.isFinite(canonical.to?.z?.known));}
10993
11261
  if(m&&canonical)inspectorHeightNotes(m,canonical);
11262
+ if(m&&canonical)inspectorAiDecisions(m,canonical,p); // #2521 row 6
10994
11263
  }
11264
+ // #2521 row 6: a member no plan view draws (read from an elevation, or picked in 3D) still rests on what it rests on.
11265
+ else if(!projected.length&&selected.length===1)inspectorAiDecisions(selected[0],selected[0],p);
10995
11266
  }
10996
11267
  /**
10997
11268
  * Under each elevation field of ONE selected member (#1723): say when the height shown is only where the
@@ -11007,6 +11278,20 @@ function answeredProposalSaid(a){const p=a&&a.how==='confirmed'&&a.proposal&&typ
11007
11278
  if(p.how==='derived')return', which the read derived from '+String(p.basis||'');
11008
11279
  if(p.how==='measured')return', which the read measured on the drawings'+(p.basis?' ('+String(p.basis)+')':'');
11009
11280
  return', read off the drawings'+(p.basis?' ('+String(p.basis)+')':'');}
11281
+ /** The Inspector's own "drawn at" sentence for an end with no live question row (an unfiled placement).
11282
+ * #2873: an estimate-placed end says its basis here or nowhere — and once the end has been moved off the
11283
+ * estimate, or the estimate was set aside, the read's number is said as history, never as this height's basis. */
11284
+ function inspectorDrawnFallback(z,assumed){
11285
+ const why=typeof z.why==='string'&&z.why.trim()?z.why.trim():'';
11286
+ const est=assumed&&z.estimate&&Number.isFinite(z.estimate.value)&&typeof z.estimate.basis==='string'&&z.estimate.basis.trim()?z.estimate:null;
11287
+ if(!est)return 'Drawn at this height for now.'+(why?' '+why:' The drawings do not confirm it.');
11288
+ const basis=est.basis.trim().replace(/\.$/,'');
11289
+ if(est.value===z.known)return 'Drawn at this height for now.'+(why?' '+why:'')+' The estimate’s basis: '+basis+'.';
11290
+ const history=' The drawing read estimated '+fmtDispElev(est.value)+' (basis: '+basis+'), but this end is not drawn at that height.';
11291
+ // The stored reason still says "placed at the drawing read's provisional estimate", which is no longer true.
11292
+ if(/provisional estimate/.test(why))return 'Drawn at this height for now; nothing on the drawings confirms it.'+history;
11293
+ return 'Drawn at this height for now.'+(why?' '+why:' The drawings do not confirm it.')+history;
11294
+ }
11010
11295
  function inspectorHeightNotes(m,canonical){
11011
11296
  const ids=m.role==='column'?['bos','tosC']:['tosA','tosB'];
11012
11297
  [0,1].forEach(end=>{
@@ -11051,12 +11336,19 @@ function inspectorHeightNotes(m,canonical){
11051
11336
  // The server's basis-aware sentence when the questions have been read; the model's own fact otherwise.
11052
11337
  // Otherwise the seam's own reason, which names the real basis (a plan's cut plane, the other end, the
11053
11338
  // read's own number) — a plan-placed end has no live question row, and must still say why.
11054
- const drawn=g&&g.currentValue&&g.currentValue.note?g.currentValue.note
11055
- :'Drawn at this height for now.'+(typeof z.why==='string'&&z.why.trim()?' '+z.why.trim():' The drawings do not confirm it.');
11339
+ const drawn=g&&g.currentValue&&g.currentValue.note?g.currentValue.note:inspectorDrawnFallback(z,assumed);
11056
11340
  const confirmsDrawn=!!p&&p.candidates.every(c=>c&&(c.readings||[]).every(rd=>rd&&rd.source==='server-placement'));
11057
11341
  if(assumed&&!p)parts.push(drawn+' Type the right height to settle it.');
11058
11342
  else if(assumed&&!confirmsDrawn)parts.push(drawn);
11059
11343
  if(p)parts.push(p.ask);
11344
+ // #2873: inspecting the steel says whether its question is already an RFI. Only a FILED record counts
11345
+ // (a live-only row is the question, not an RFI), and "not filed" is said only when the list was read.
11346
+ if(assumed){
11347
+ const filed=rfiFiledForGap(gapKey);
11348
+ if(filed)parts.push('Filed as '+filed.id+' ('+(RFI_STATUS_LABEL[filed.status]||'Open').toLowerCase()+').');
11349
+ else if(rfiState.status==='ok')parts.push('No RFI has been filed for this height yet.');
11350
+ else if(rfiState.status==='fail')parts.push('FloLess could not load the RFI list, so it cannot say yet whether this height has an RFI.');
11351
+ }
11060
11352
  const text=document.createElement('div');text.textContent=parts.join(' ');box.appendChild(text);
11061
11353
  if(p&&rfiEndUnresolved(canonical.id,end)){
11062
11354
  const acts=document.createElement('div');acts.className='row';acts.style.cssText='gap:5px;flex-wrap:wrap;margin-top:4px';
@@ -14830,11 +15122,12 @@ redrawForUnitsFn=()=>{syncUnitsRow();syncReachRow();syncEnvChip();render();sync3
14830
15122
  b.onclick=e=>{e.stopPropagation();if(b.disabled||displayUnits()===units)return;commitDisplayUnits(units);};};
14831
15123
  pick('unitsFt',DisplayUnits.FT_IN);pick('unitsMm',DisplayUnits.MM);
14832
15124
  }
14833
- function syncDisplayRows(){updGridToggle();updPosGizmoToggle();updDimToggle();updCalloutToggle();updPlToggle();updRefToggle();}
15125
+ function syncDisplayRows(){updAiMarksToggle();updGridToggle();updPosGizmoToggle();updDimToggle();updCalloutToggle();updPlToggle();updRefToggle();}
14834
15126
  function updDimToggle(){const b=document.getElementById('dimToggleB');if(!b)return;b.disabled=false;b.classList.toggle('on',dimsVisible);b.setAttribute('aria-checked',String(dimsVisible));}
14835
15127
  document.getElementById('dimToggleB').onclick=e=>{e.stopPropagation();dimsVisible=!dimsVisible;updDimToggle();render();};
14836
15128
 
14837
15129
  function updPosGizmoToggle(){const b=document.getElementById('posGizmoToggleB');if(!b)return;b.disabled=false;b.classList.toggle('on',showPosGizmo);b.setAttribute('aria-checked',String(showPosGizmo));}
15130
+ document.getElementById('aiMarksToggleB').onclick=e=>{e.stopPropagation();showAiMarks=!showAiMarks;try{localStorage.setItem('steel:aiMarks:v2',showAiMarks?'1':'0');}catch(_){}updAiMarksToggle();render();}; // #2521 row 6: hides the 2D and 3D marks only; the strip and Inspect stay (owner ruling 2026-10-29)
14838
15131
  document.getElementById('posGizmoToggleB').onclick=e=>{e.stopPropagation();showPosGizmo=!showPosGizmo;try{localStorage.setItem('steel:posGizmo:v2',showPosGizmo?'1':'0');}catch(_){}updPosGizmoToggle();if(view3dReady&&window.Steel3DView&&window.Steel3DView.setPositionGizmoVisible)window.Steel3DView.setPositionGizmoVisible(showPosGizmo);}; // the gizmo is a 3D overlay — push straight to the view (.stopPropagation keeps the menu open, like every .dtog)
14839
15132
  // ⋯ Display → Grid label size. One setting, both views: 2D re-places its bubbles from the anchors baked
14840
15133
  // by gridSvg (no re-render — a rebuild between a dblclick's two clicks would kill the rename gesture),
@@ -16506,7 +16799,8 @@ function paintChatQuestions(p){
16506
16799
  function modelPanelSnapshot(){
16507
16800
  const n=allMembers().length;
16508
16801
  return {context:n+' member'+(n===1?'':'s'),selectedId:[...selIds].at(-1)||null,selectedIds:[...selIds],tabs:[],bodies:{},
16509
- panelTabs:view3dShown?LEGEND_TABS:LEGEND_TABS.filter(t=>t.key==='objects')}; // Views, Favourites and References act on the 3D view
16802
+ panelTabs:view3dShown?LEGEND_TABS:LEGEND_TABS.filter(t=>t.key==='objects'), // Views, Favourites and References act on the 3D view
16803
+ ...(PROJECT?{viewer:steelViewTarget()}:{})}; // #2876: the view an AI Chat view command may be applied to (a project's model only)
16510
16804
  }
16511
16805
  let editorTerminalDisposed=false,editorBfcacheSuspended=false,editorBfcacheWas3d=false;
16512
16806
  function disposeEditor(reason='parent-replacement'){
@@ -23066,7 +23360,8 @@ async function setView(on,{remember=true}={}){
23066
23360
  // nothing to undo here; just stop.
23067
23361
  if(seq!==viewSeq)return;
23068
23362
  modelSelection.replay();
23069
- if(window.Steel3DView.setPositionGizmoVisible)window.Steel3DView.setPositionGizmoVisible(showPosGizmo); // reflect the persisted ⋯ Display → Position handle state when 3D becomes visible
23363
+ if(window.Steel3DView.setPositionGizmoVisible)window.Steel3DView.setPositionGizmoVisible(showPosGizmo);
23364
+ syncAiMarks3d(true); // #2521 row 6: the AI-decision marks, as the switch and the live model say // reflect the persisted ⋯ Display → Position handle state when 3D becomes visible
23070
23365
  if(window.Steel3DView.setGridLabelPx)window.Steel3DView.setGridLabelPx(gridLabelPx); // the renderer reads the shared key at LOAD and the slider pushes live, but a size set BEFORE the module arrived reaches it through neither — so relay it here too, like every other preference in this block. Makes a 2D/3D divergence self-healing on the next switch rather than permanent.
23071
23366
  wire3DBar();loadSteelFavourites();build3DLegend();
23072
23367
  // Push what we already hold, THEN stream the rest in behind the native steel. Deliberately not
@@ -24406,6 +24701,8 @@ const RFI_GMAIL_API={
24406
24701
  deliver:id=>'/api/projects/'+encodeURIComponent(PROJECT)+'/rfis/'+encodeURIComponent(id)+'/deliver',
24407
24702
  continueAttempt:(id,attemptId)=>'/api/projects/'+encodeURIComponent(PROJECT)+'/rfis/'+encodeURIComponent(id)+'/delivery-attempts/'+encodeURIComponent(attemptId)+'/continue',
24408
24703
  confirmSent:(id,attemptId)=>'/api/projects/'+encodeURIComponent(PROJECT)+'/rfis/'+encodeURIComponent(id)+'/delivery-attempts/'+encodeURIComponent(attemptId)+'/confirm-sent',
24704
+ // #2470 R6.6e: the three ways out of a send FloLess could not confirm (way = try-again | sent-another-way | leave-unconfirmed).
24705
+ settle:(id,attemptId,way)=>'/api/projects/'+encodeURIComponent(PROJECT)+'/rfis/'+encodeURIComponent(id)+'/delivery-attempts/'+encodeURIComponent(attemptId)+'/'+way,
24409
24706
  };
24410
24707
  let rfiGmailReadiness={status:PROJECT?'loading':'off',message:''};
24411
24708
  let rfiGmailReadinessSeq=0;
@@ -24421,7 +24718,8 @@ let rfiRecordsSeq=0; // bumped on every settled list response, so the
24421
24718
  success hides a real failure. The panel this replaces carried the same guard (`qSeq`); dropping it
24422
24719
  in the rewrite was a regression, not a simplification. */
24423
24720
  let rfiFetchSeq=0;
24424
- /* One browser-side ceiling covers save-before-promotion plus the RFI POST. It is intentionally shorter
24721
+ /** #2874: the RFI a chat mention just opened, outlined for a moment; renderRfiList redraws the outline while it is set. */
24722
+ let rfiMentioned=null;/* One browser-side ceiling covers save-before-promotion plus the RFI POST. It is intentionally shorter
24425
24723
  than the server ledger's lifetime: the browser may stop waiting while the server finishes, then the
24426
24724
  SAME operation key safely discovers that outcome instead of issuing a second action. */
24427
24725
  const RFI_ACTION_TIMEOUT_MS=30_000;
@@ -24525,6 +24823,26 @@ async function refreshRfiGmailReadiness(){
24525
24823
  * how a row is matched to a record the server already filed under it. */
24526
24824
  const rfiSizeGapKey=id=>'unknown-size:'+id;
24527
24825
 
24826
+ /** #2873: the FILED record that asks this gap, newest first (the server sorts by seq descending), or null.
24827
+ * A live-only row is the open question itself, not an RFI, so it never counts. */
24828
+ /** #2873: the Inspector's height notes say whether an RFI is filed, so they follow the RFI list when it
24829
+ * loads or changes — never while focus sits inside one of them (a Use button the person is on). */
24830
+ function rfiRepaintHeightNotes(){
24831
+ const p=document.getElementById('panel'),a=document.activeElement;
24832
+ if(!p||(a&&a.closest&&a.closest('.v2-elevation-proposal,.v2-elevation-answered')))return;
24833
+ syncV2SelectionNotice(p);
24834
+ }
24835
+ function rfiFiledForGap(gapKey){
24836
+ for(const r of rfiState.records){
24837
+ if(!r||r.liveOnly||typeof r.id!=='string')continue;
24838
+ // A grouped record speaks for several heights: THIS height's status is its occurrence's, never the group's,
24839
+ // so its occurrences are asked FIRST, before any top-level key the group may also carry.
24840
+ const occ=r.grouped?(r.occurrences||[]).find(o=>o&&o.technical&&o.technical.gapKey===gapKey):null;
24841
+ if(occ)return {id:r.id,status:typeof occ.status==='string'?occ.status:r.status};
24842
+ if(r.gapKey===gapKey||(r.liveGap&&r.liveGap.gapKey===gapKey))return r;
24843
+ }
24844
+ return null;
24845
+ }
24528
24846
  /** Records that are not closed, by gap key — what suppresses a symptom row. */
24529
24847
  function rfiLiveByGap(){
24530
24848
  const out=new Map();
@@ -24639,15 +24957,22 @@ function paintRfiStat(){
24639
24957
  ?'Reading this project’s filed RFIs…'
24640
24958
  :'FloLess could not read the project’s current questions — open the list to see why';
24641
24959
  n.textContent=unread?'—':String(count);
24960
+ // #2920: the read's unfiled questions, beside the open count and never added to it — they are not RFIs yet.
24961
+ const readN=unread?0:rfiReadCount(),readEl=document.getElementById('rcRead'),readNum=document.getElementById('rcReadN');
24962
+ if(readEl&&readNum){readEl.style.display=readN?'':'none';readNum.textContent=String(readN);}
24963
+ if(b.classList&&b.classList.toggle)b.classList.toggle('readq',readN>0);
24964
+ // A class, so the Quality summary's observer sees it: questions nobody could check are not "nothing unresolved".
24965
+ if(b.classList&&b.classList.toggle)b.classList.toggle('readunknown',!unread&&!!rfiState.readQuestionsUnavailable);
24966
+ const readTip=readN?' '+readN+' question'+(readN===1?'':'s')+' from the drawing read '+(readN===1?'is':'are')+' not filed yet.':'';
24642
24967
  if(b.classList&&b.classList.toggle)b.classList.toggle('has',unread||count>0);
24643
24968
  if(b.classList&&b.classList.toggle)b.classList.toggle('unknown',!!rfiRecovery);
24644
24969
  const unknownTip=rfiRecovery?' An RFI attempt has an unknown result — open the list to review it.':'';
24645
24970
  // setAttribute, not `dataset`: the tooltip handler reads the ATTRIBUTE, and so does every probe.
24646
24971
  b.setAttribute('data-tip',(unread?unreadTip
24647
- :'List every RFI — a question for an engineer, or a member whose size FloLess cannot price')+unknownTip);
24972
+ :'List every RFI — a question for an engineer, or a member whose size FloLess cannot price.'+readTip)+unknownTip);
24648
24973
  b.setAttribute('aria-label',rfiState.status==='loading'
24649
24974
  ?'Reading RFIs. '+unreadTip+unknownTip
24650
- :unread?'RFIs unavailable. '+unreadTip+unknownTip:'RFIs, '+count+' open.'+unknownTip);
24975
+ :unread?'RFIs unavailable. '+unreadTip+unknownTip:'RFIs, '+count+' open.'+readTip+unknownTip);
24651
24976
  }
24652
24977
 
24653
24978
  const liveDrawingTargets=g=>{const rows=Array.isArray(g&&g.drawingTargets)&&g.drawingTargets.length?g.drawingTargets:g&&g.drawingTarget?[g.drawingTarget]:[];
@@ -24678,7 +25003,10 @@ async function refreshRfiRecords(opts){
24678
25003
  rfiState={status:'fail',records:live,sizeTruth:'known',liveTruth:j.liveTruth==='unavailable'?'unavailable':'known',detail:'',
24679
25004
  liveDetail:String(j.liveTruthDetail||''),http:r.status||0,error:String((j&&j.error)||''),
24680
25005
  // #2521 row 3b-2: a Quick version's unfiled questions live in the version, so they show even now.
24681
- quickFiling:Array.isArray(j&&j.quickFiling)?j.quickFiling:[]};
25006
+ quickFiling:Array.isArray(j&&j.quickFiling)?j.quickFiling:[],
25007
+ // #2920: the newest read's unfiled questions are counted from the version, so they show even now.
25008
+ readQuestions:j&&j.readQuestions&&typeof j.readQuestions==='object'?j.readQuestions:null,
25009
+ readQuestionsUnavailable:!!(j&&j.readQuestionsUnavailable)};
24682
25010
  }else{
24683
25011
  const filed=j.rfis.map(r=>{
24684
25012
  const g=r&&r.liveGap,targets=liveDrawingTargets(g);
@@ -24694,7 +25022,9 @@ async function refreshRfiRecords(opts){
24694
25022
  sizeTruth:j.sizeTruth==='known'?'known':'unavailable',
24695
25023
  liveTruth:j.liveTruth==='known'?'known':'unavailable',
24696
25024
  detail:String(j.sizeTruthDetail||''),liveDetail:String(j.liveTruthDetail||''),http:200,error:'',
24697
- quickFiling:Array.isArray(j.quickFiling)?j.quickFiling:[]};
25025
+ quickFiling:Array.isArray(j.quickFiling)?j.quickFiling:[],
25026
+ readQuestions:j.readQuestions&&typeof j.readQuestions==='object'?j.readQuestions:null,
25027
+ readQuestionsUnavailable:!!j.readQuestionsUnavailable};
24698
25028
  }
24699
25029
  }catch(e){
24700
25030
  if(mine!==rfiFetchSeq)return false;
@@ -24713,6 +25043,7 @@ async function refreshRfiRecords(opts){
24713
25043
  // BEFORE the paint, so a sentence about a record that has since moved on never reaches the screen.
24714
25044
  rfiPruneOutcome();
24715
25045
  paintRfiStat();
25046
+ rfiRepaintHeightNotes();
24716
25047
  // NEVER repaint the list out from under someone's hands. `openRFI` starts this read, so it lands a
24717
25048
  // moment after the dialog opens - and a repaint replaces the row's profile input, which discards
24718
25049
  // whatever the user has typed into it and leaves the combo popup pointing at a node that is gone.
@@ -24951,6 +25282,8 @@ function rfiDeliveryOf(r){
24951
25282
  return {status,attemptId,preparedAt:String(d.preparedAt||''),
24952
25283
  canContinue:d.canContinue===true||status==='prepared',
24953
25284
  canConfirmFoundInSent:d.canConfirmFoundInSent===true||status==='outcome-unknown',
25285
+ to:String(d.to||''),
25286
+ canTryAgain:d.canTryAgain===true,canRecordSentAnotherWay:d.canRecordSentAnotherWay===true,canLeaveUnconfirmed:d.canLeaveUnconfirmed===true,
24954
25287
  reconciliationMarker:String(d.reconciliationMarker||(r.id&&attemptId?(r.id+'/'+attemptId):''))};
24955
25288
  }
24956
25289
  const rfiDeliveryBlocks=r=>{const d=rfiDeliveryOf(r);return !!d&&(d.status==='prepared'||d.status==='outcome-unknown');};
@@ -25425,7 +25758,7 @@ function rfiMergeResponse(j){
25425
25758
  // assumed: a truth that flipped to `unavailable` would otherwise leave Apply and `resolved` offered.
25426
25759
  if(j&&(j.sizeTruth==='known'||j.sizeTruth==='unavailable'))rfiState={...rfiState,sizeTruth:j.sizeTruth};
25427
25760
  if(merged){
25428
- rfiFetchSeq++;rfiRecordsSeq++;rfiPruneTargetErrors();paintRfiStat();
25761
+ rfiFetchSeq++;rfiRecordsSeq++;rfiPruneTargetErrors();paintRfiStat();rfiRepaintHeightNotes();
25429
25762
  // The bump above cancels any read still in flight. If one of those owned the `loading` transition
25430
25763
  // that Retry started, nothing would ever end it — `openRFI` will not re-read while `loading` and
25431
25764
  // the loading banner offers no Retry, so the dialog sticks with no way out.
@@ -25869,6 +26202,7 @@ function rfiGmailUnknownCopy(base,attempt,record){
25869
26202
  function rfiGmailBusyMessage(action,id){
25870
26203
  if(action==='deliver')return 'Sending '+id+' with Gmail…';
25871
26204
  if(action==='confirm')return 'Recording the Sent-folder confirmation for '+id+'…';
26205
+ if(action==='settle')return 'Settling the unconfirmed Gmail send of '+id+'…';
25872
26206
  return 'Continuing the prepared Gmail send for '+id+'…';
25873
26207
  }
25874
26208
  const RFI_GMAIL_RECOVERY_KEY_PREFIX='floless:rfi-gmail-recovery:v1:';
@@ -25893,7 +26227,7 @@ function rfiGmailRecoveryKey(attemptId,action){
25893
26227
  return opKey;
25894
26228
  }
25895
26229
  function rfiForgetGmailRecoveryKeys(attemptId){
25896
- for(const action of ['continue','confirm']){
26230
+ for(const action of ['continue','confirm',...RFI_SETTLE_WAYS.map(w=>'settle-'+w.key)]){
25897
26231
  const storageKey=rfiGmailRecoveryStorageKey(attemptId,action);
25898
26232
  rfiGmailRecoveryKeys.delete(storageKey);try{localStorage.removeItem(storageKey);}catch(_){}
25899
26233
  }
@@ -25988,6 +26322,212 @@ async function rfiRecoverGmail(button){
25988
26322
  deadline.clear();rfiGmailBusy=null;renderRfiList();paintRfiFail();paintRfiStat();
25989
26323
  }
25990
26324
  }
26325
+ // ── The ways out of a send FloLess could not confirm (#2470 R6.6e) ────────────────────────────────────────────
26326
+ // Only the ways the server offers, never preselected: the person chooses. Each is final and stays in the history.
26327
+ const RFI_SETTLE_WAYS=[
26328
+ {key:'try-again',allowed:'canTryAgain',label:'Send it again with Gmail',help:'They may get it twice. FloLess asks you to confirm first.',primary:'Send it again…'},
26329
+ {key:'sent-another-way',allowed:'canRecordSentAnotherWay',label:'I sent it another way',help:'FloLess records it and marks the RFI sent. It sends nothing.',primary:'Record as sent'},
26330
+ {key:'leave-unconfirmed',allowed:'canLeaveUnconfirmed',label:'Leave it unconfirmed',help:'FloLess won’t finish or send this, and can’t say whether Gmail already did. The RFI is free again, and its history will show this send as not confirmed.',primary:'Leave unconfirmed'},
26331
+ ];
26332
+ const RFI_SETTLED_WORDS={'try-again':'sent again with Gmail','sent-another-way':'sent another way','left-unconfirmed':'left unconfirmed'};
26333
+ // What became of the new send of a Try again: said only as far as FloLess knows it (a refused one reached nobody).
26334
+ const rfiResendWords=s=>!s||s==='recorded'||s==='confirmed-sent'?'':s==='failed'?' · Gmail didn’t receive the new send':' · the new send isn’t confirmed either';
26335
+ // Refusals that mean the list on screen is out of date: the panel closes and the list is read again.
26336
+ const RFI_SETTLE_OUT_OF_DATE=new Set(['rfi-delivery-terminal','rfi-delivery-stale','rfi-revision-stale','rfi-delivery-evidence-present','rfi-delivery-not-found']);
26337
+ const rfiRefreshSaid=rowKey=>rfiRefreshAfterAction(rowKey).catch(error=>{console.warn('[steel] the RFI list could not be read again',error&&error.message?error.message:error);return false;});
26338
+ const RFI_HOW_MAX=120;
26339
+ let rfiSettleFor=null; // {rowKey,id,attemptId,way,via,to,how,error,busy} | null — one open at a time
26340
+ const rfiSettledOpen=new Set(); // RFIs whose not-confirmed sends are listed
26341
+ /** A send that holds this RFI — the live one, or one from before it last changed — by its attempt id. */
26342
+ function rfiHeldAttempt(r,attemptId){
26343
+ const held=(Array.isArray(r&&r.holdingDeliveries)?r.holdingDeliveries:[]).find(h=>h&&h.attemptId===attemptId);
26344
+ if(held)return held;
26345
+ const d=rfiDeliveryOf(r);
26346
+ return d&&d.attemptId===attemptId&&(d.status==='prepared'||d.status==='outcome-unknown')?d:null;
26347
+ }
26348
+ function rfiSettleButton(r,delivery,rowKey){
26349
+ if(!delivery||!delivery.attemptId||!RFI_SETTLE_WAYS.some(w=>delivery[w.allowed]))return '';
26350
+ if((rfiSettleFor&&rfiSettleFor.rowKey===rowKey)||(rfiGmailBusy&&rfiGmailBusy.rowKey===rowKey))return '';
26351
+ const text=delivery.status==='prepared'?'Something else…':'I didn’t find it…';
26352
+ return '<button class=ghost data-command-id="steel.rfi-gmail-settle#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'" aria-label="'+esc(text.replace('…','')+': '+r.id)+'" data-rfi-ctl="settle:open" data-rfi-settle-open="'+esc(r.id)+'" data-rfi-settle-attempt="'+esc(delivery.attemptId)+'" data-tip="Other ways to settle this send: send it again, record that you sent it, or leave it unconfirmed">'+text+'</button>';
26353
+ }
26354
+ /** The earlier held sends, the not-confirmed history, and the open settle panel of one row. */
26355
+ function rfiSettleHtml(r,rowKey){
26356
+ let html='';
26357
+ for(const h of (Array.isArray(r.holdingDeliveries)?r.holdingDeliveries:[]).filter(h=>h&&h.stale)){
26358
+ html+='<div class=rfiunknown role=note>An earlier Gmail send to '+esc(h.to||'')+' ('+esc(rfiAgo(h.preparedAt))+') is still held. Settle it to free this RFI.</div>';
26359
+ if(!(rfiSettleFor&&rfiSettleFor.rowKey===rowKey&&rfiSettleFor.attemptId===h.attemptId))
26360
+ html+='<div class=rfiacts><button class=ghost data-command-id="steel.rfi-gmail-leave-earlier#'+esc(h.attemptId)+'" data-command-instance-label="'+esc(r.id)+'" aria-label="'+esc('Leave the earlier send of '+r.id+' unconfirmed')+'" data-rfi-ctl="settle:earlier" data-rfi-settle-open="'+esc(r.id)+'" data-rfi-settle-attempt="'+esc(h.attemptId)+'" data-tip="Settles that earlier send without recording a send">Leave it unconfirmed…</button></div>';
26361
+ }
26362
+ const history=r.deliveryHistory;
26363
+ if(history&&Array.isArray(history.settled)&&history.settled.length){
26364
+ const reach=history.mayHaveReached||{},open=rfiSettledOpen.has(r.id);
26365
+ html+='<div class=rfinote role=note>'+esc(reach.to||'')+(reach.moreThanOnce?' may have received it more than once.':' may already have this RFI.')+'</div>'
26366
+ +'<div class=rfiacts><button class=ghost data-command-id="steel.rfi-settled-history#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'" data-rfi-ctl="settle:history" data-rfi-settle-history="'+esc(r.id)+'" aria-expanded="'+open+'">Not confirmed ('+history.settled.length+')</button></div>'
26367
+ +(open?'<ul class="rfinote rfisettled" aria-label="'+esc('Sends of '+r.id+' FloLess couldn’t confirm')+'">'+history.settled.map(h=>'<li>Gmail send to '+esc(h.to)+' · '+esc(rfiAgo(h.preparedAt))+' · not confirmed, '+esc(RFI_SETTLED_WORDS[h.choice]||h.choice)+(h.stale?' (an earlier send)':'')+rfiResendWords(h.resend)+'</li>').join('')+'</ul>':'');
26368
+ }
26369
+ const f=rfiSettleFor;
26370
+ if(f&&f.rowKey===rowKey)html+=rfiSettlePanelHtml(r,f);
26371
+ return html;
26372
+ }
26373
+ function rfiSettlePanelHtml(r,f){
26374
+ const held=rfiHeldAttempt(r,f.attemptId);
26375
+ if(!held)return '';
26376
+ const ways=RFI_SETTLE_WAYS.filter(w=>held[w.allowed]),chosen=RFI_SETTLE_WAYS.find(w=>w.key===f.way);
26377
+ const off=f.busy?' disabled':'',seg=(label,attr,items,value)=>'<div class=seg2 role=radiogroup aria-label="'+label+'">'+items.map(([key,text],i)=>
26378
+ '<button type=button role=radio aria-checked="'+(value===key)+'" tabindex="'+(value===key||(!value&&i===0)?0:-1)+'"'+(value===key?' class=on':'')+' data-rfi-ctl="settle:'+attr+':'+key+'" data-rfi-settle-'+attr+'="'+key+'" '
26379
+ // Each command id is written whole; only the instance after "#" varies.
26380
+ +(attr==='way'?'data-command-id="steel.rfi-settle-way#'+esc(key)+'"':'data-command-id="steel.rfi-settle-via#'+esc(key)+'"')
26381
+ +' data-command-instance-label="'+esc(text)+'"'+off+'>'+esc(text)+'</button>').join('')+'</div>';
26382
+ let html='<div class=rfiform role=group aria-label="'+esc('Settle the unconfirmed send of '+r.id)+'" data-rfi-settle-panel>';
26383
+ if(held.stale)html+='<div class=rfinote>This earlier send to '+esc(held.to||'')+' is from before this RFI last changed, so the only way to settle it is to leave it unconfirmed.</div>';
26384
+ if(ways.length>1)html+=seg('What do you want to do?','way',ways.map(w=>[w.key,w.label]),f.way);
26385
+ if(chosen)html+='<div class=rfinote>'+esc(chosen.help)+'</div>';
26386
+ if(f.way==='sent-another-way'){
26387
+ html+=seg('How did you send it?','via',[['email','Email'],['other','Other']],f.via)
26388
+ +'<label>Who did you send it to?<input type=email autocomplete=email data-rfi-ctl="settle:to" data-rfi-settle-input=to value="'+esc(f.to)+'" data-command-id="steel.rfi-settle-to#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'"'+(f.busy?' readonly':'')+'></label>';
26389
+ if(f.via==='other')html+='<label>How did you send it?<input maxlength='+RFI_HOW_MAX+' placeholder="Handed over at the site meeting" data-rfi-ctl="settle:how" data-rfi-settle-input=how value="'+esc(f.how)+'" data-command-id="steel.rfi-settle-how#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'"'+(f.busy?' readonly':'')+'></label><div class=rfinote data-rfi-settle-count>'+f.how.length+' of '+RFI_HOW_MAX+'</div>';
26390
+ }
26391
+ if(f.error)html+='<div class=rfifail role=alert>'+esc(f.error)+'</div>';
26392
+ if(f.busy)html+='<div class=rfinote role=status>'+esc(rfiGmailBusyMessage('settle',r.id))+'</div>';
26393
+ return html+'<div class=rfirow-acts><button type=button class=ghost data-rfi-ctl="settle:cancel" data-rfi-settle-cancel=1 data-command-id="steel.rfi-settle-cancel#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'"'+off+'>Cancel</button>'
26394
+ +'<button type=button data-rfi-ctl="settle:submit" data-rfi-settle-submit=1 data-command-id="steel.rfi-settle-submit#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'"'+(f.busy?' aria-busy=true aria-disabled=true data-blocked-reason="This send is being settled now"':'')+'>'+esc(f.busy?'Saving…':chosen?chosen.primary:'Choose one')+'</button></div></div>';
26395
+ }
26396
+ function rfiAgo(iso){
26397
+ const t=Date.parse(iso);if(!Number.isFinite(t))return 'earlier';
26398
+ const m=Math.round(Math.max(0,Date.now()-t)/60000);
26399
+ if(m<1)return 'just now';if(m<60)return m+' min ago';
26400
+ const h=Math.round(m/60);if(h<24)return h+' h ago';
26401
+ const d=Math.round(h/24);return d===1?'yesterday':d+' days ago';
26402
+ }
26403
+ function rfiOpenSettle(id,attemptId){
26404
+ if(rfiBusy()){toast('One RFI is still being recorded — wait for it to finish.');return;}
26405
+ const r=rfiState.records.find(x=>x&&x.id===id),held=r&&rfiHeldAttempt(r,attemptId);
26406
+ if(!held){toast(id+' — that send is already settled. The list has been read again.');void rfiRefreshAfterAction(rfiRowKey('record',id)).then(()=>renderRfiList()).catch(()=>{});return;}
26407
+ const ways=RFI_SETTLE_WAYS.filter(w=>held[w.allowed]);
26408
+ // Only one way (an earlier send): it is the choice. Otherwise nothing is chosen for the person.
26409
+ rfiSettleFor={rowKey:rfiRowKey('record',id),id,attemptId,way:ways.length===1?ways[0].key:'',via:'',to:String(held.to||''),how:'',error:'',busy:false};
26410
+ rfiFocusOverride={rows:[rfiSettleFor.rowKey],ctl:ways.length>1?'settle:way:'+ways[0].key:'settle:submit'};
26411
+ renderRfiList();
26412
+ }
26413
+ function rfiCloseSettle(){
26414
+ const f=rfiSettleFor;if(!f||f.busy)return;
26415
+ rfiSettleFor=null;rfiFocusOverride={rows:[f.rowKey],ctl:'*first'};renderRfiList();
26416
+ }
26417
+ function rfiSettleChoose(kind,value){
26418
+ const f=rfiSettleFor;if(!f||f.busy)return;
26419
+ f[kind]=value;f.error='';rfiFocusOverride={rows:[f.rowKey],ctl:'settle:'+kind+':'+value};renderRfiList();
26420
+ }
26421
+ function rfiSettleSubmit(){
26422
+ const f=rfiSettleFor;if(!f||f.busy)return;
26423
+ const to=String(f.to||'').trim(),how=String(f.how||'').trim(),address=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(to);
26424
+ // Asked, not refused: the button stays live and says what is missing.
26425
+ f.error=!f.way?'Choose what you want to do first.'
26426
+ :f.way==='sent-another-way'&&!f.via?'Say how you sent it: by email, or another way.'
26427
+ :f.way==='sent-another-way'&&!address?'Give the one email address it went to, like name@company.com.'
26428
+ :f.way==='sent-another-way'&&f.via==='other'&&!how?'Say in a few words how you sent it.':'';
26429
+ if(f.error){
26430
+ rfiFocusOverride={rows:[f.rowKey],ctl:!f.way?'settle:way:'+RFI_SETTLE_WAYS[0].key:!f.via?'settle:via:email':!address?'settle:to':'settle:how'};
26431
+ rfiSay(f.error);renderRfiList();return;
26432
+ }
26433
+ if(f.way==='try-again'){rfiSettleAskAgain(f);return;}
26434
+ void rfiSettleSend(f,f.way==='sent-another-way'?{to,via:f.via,...(f.via==='other'?{how}:{})}:{}).catch(rfiGestureFailure);
26435
+ }
26436
+ /** Try Gmail again asks first, in a dialog with a tick the person must give (owner ruling, #2470 R6.6e). */
26437
+ function rfiSettleAskAgain(f){
26438
+ const r=rfiState.records.find(x=>x&&x.id===f.id),held=r&&rfiHeldAttempt(r,f.attemptId);
26439
+ if(!r||!held)return;
26440
+ const from=document.querySelector('[data-rfi-settle-submit]');
26441
+ openCalloutCard({title:'Send it again?',from,
26442
+ html:'<p>FloLess can’t tell whether Gmail already sent '+esc(r.id)+' to '+esc(held.to||'')+'. If it did, they will get it twice.</p>'
26443
+ +'<div class=rfiform><label>Gmail sends a new email to<input type=email autocomplete=email data-rfi-again-to value="'+esc(f.againTo||held.to||'')+'" data-command-id="steel.rfi-gmail-again-to"></label>'
26444
+ +'<label class=rficheck><input type=checkbox data-rfi-again-tick data-command-id="steel.rfi-gmail-again-tick"><span>I understand they may get it twice</span></label></div>',
26445
+ actions:[
26446
+ {label:'Cancel',ghost:true,cmd:'steel.rfi-gmail-again-cancel',run:()=>closeCalloutCard()},
26447
+ {label:'Send again with Gmail',primary:true,cmd:'steel.rfi-gmail-again-send',run:()=>{
26448
+ const body=document.getElementById('coCardBody'),status=document.getElementById('coCardStatus');
26449
+ const toInput=body.querySelector('[data-rfi-again-to]'),tick=body.querySelector('[data-rfi-again-tick]');
26450
+ const to=String(toInput&&toInput.value||'').trim();
26451
+ // Asked, not refused: the button stays live and says what is missing.
26452
+ if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(to)){status.setAttribute('role','alert');status.textContent='Give one email address, like name@company.com.';toInput&&toInput.focus();return;}
26453
+ if(!tick||!tick.checked){status.setAttribute('role','alert');status.textContent='Tick the box to confirm you understand they may get it twice.';if(tick){tick.setAttribute('aria-invalid','true');tick.focus();}return;}
26454
+ f.againTo=to;closeCalloutCard();
26455
+ if(rfiSettleFor!==f)return;
26456
+ void rfiSettleSend(f,{to,recordRevision:r.recordRevision}).catch(rfiGestureFailure);
26457
+ }},
26458
+ ]});
26459
+ const first=document.querySelector('#coCardBody [data-rfi-again-tick]');if(first)first.focus();
26460
+ }
26461
+ async function rfiSettleSend(f,fields){
26462
+ const rowKey=f.rowKey,way=f.way;
26463
+ if(rfiBusy()){toast('One RFI is still being recorded — wait for it to finish.');return;}
26464
+ let opKey;
26465
+ try{opKey=rfiGmailRecoveryKey(f.attemptId,'settle-'+way);}
26466
+ catch(error){f.error=error.message;renderRfiList();return;}
26467
+ f.busy=true;f.error='';rfiOutcome=null;rfiGmailBusy={rowKey,action:'settle'};
26468
+ rfiFocusOverride={rows:[rowKey],ctl:'settle:submit'};rfiSay(rfiGmailBusyMessage('settle',f.id));renderRfiList();
26469
+ const deadline=rfiDeadline(RFI_ACTION_TIMEOUT_MS);
26470
+ try{
26471
+ const res=await deadline.race(rfiPost(RFI_GMAIL_API.settle(f.id,f.attemptId,way),JSON.stringify({operationKey:opKey,...fields}),deadline.signal));
26472
+ const body=res.body||{};
26473
+ if(way==='try-again'&&(res.httpOk||body.attempt)){
26474
+ // The answer is about the new send: Gmail's result reads exactly like a first send's.
26475
+ rfiForgetGmailRecoveryKeys(f.attemptId);rfiSettleFor=null;
26476
+ await rfiFinishGmailResponse(rowKey,res,body);
26477
+ // The new send never started (the project is being archived, or it changed): say the server's reason, not
26478
+ // "not finished recording", which is not what happened. The earlier send is settled either way.
26479
+ const fresh=body.attempt;
26480
+ // "Didn't start" only when the server says so; otherwise Gmail may have taken it and only the record is missing.
26481
+ if(body.settledAttempt&&fresh&&fresh.status==='prepared'&&body.error)
26482
+ rfiGmailOutcome(rowKey,'rfi-gmail-prepared',(body.code==='rfi-gmail-prepared'?'The earlier send is settled, but the new Gmail send didn’t start. ':'The earlier send is settled. ')+String(body.error),'unknown');
26483
+ return;
26484
+ }
26485
+ if(res.httpOk){
26486
+ rfiForgetGmailRecoveryKeys(f.attemptId);rfiSettleFor=null;rfiGmailUnknownRows.delete(rowKey);
26487
+ await rfiRefreshSaid(rowKey);
26488
+ const message=way==='leave-unconfirmed'?f.id+' left unconfirmed. It’s free again.':f.id+' recorded as sent another way, to '+fields.to+'.';
26489
+ rfiSay(message);toast(message,false,0,true);rfiFocusOverride={rows:[rowKey],ctl:'*first'};return;
26490
+ }
26491
+ rfiForgetGmailRecoveryKeys(f.attemptId);
26492
+ // Settled somewhere else, or it changed: say what the server said and show the list as it now is.
26493
+ if(RFI_SETTLE_OUT_OF_DATE.has(body.code)){
26494
+ rfiSettleFor=null;
26495
+ await rfiRefreshSaid(rowKey);
26496
+ const message=String(body.error||f.id+' changed since you opened it.');
26497
+ rfiSay(message);toast(message);rfiFocusOverride={rows:[rowKey],ctl:'*first'};return;
26498
+ }
26499
+ // Refused: nothing changed. Say why in the panel; the next try is a new intent.
26500
+ // The answer carries Gmail's readiness: show it at once, never wait on a second check before the panel answers.
26501
+ if(body.code==='rfi-gmail-not-ready'&&body.readiness&&typeof body.readiness==='object'){
26502
+ rfiGmailReadiness={status:String(body.readiness.status||'unavailable'),message:String(body.readiness.message||'')};paintRfiGmailReadiness();
26503
+ }
26504
+ f.busy=false;f.error=String(body.error||'FloLess couldn’t do that just now. Try again.');
26505
+ rfiFocusOverride={rows:[rowKey],ctl:'settle:submit'};rfiSay(f.error);
26506
+ }catch(error){
26507
+ if(deadline.cancelled())return;
26508
+ if(!deadline.timedOut())console.warn('[steel] settle response was lost',error&&error.message?error.message:error);
26509
+ if(way==='try-again'){
26510
+ // A Try again can still be sending after the browser stops waiting: read the list, and if the earlier send is
26511
+ // no longer the one holding the RFI, a new Gmail send may be on its way — say so, never offer to send again.
26512
+ // Bounded: a read that hangs too must not leave every RFI action waiting behind it.
26513
+ const read=await Promise.race([rfiRefreshSaid(rowKey),new Promise(resolve=>setTimeout(()=>resolve('timeout'),RFI_ACTION_TIMEOUT_MS))]);
26514
+ const fresh=read==='timeout'?null:rfiState.records.find(r=>r&&r.id===f.id),now=fresh&&rfiGmailAttemptFrom(null,fresh);
26515
+ if(now&&now.attemptId!==f.attemptId){
26516
+ rfiSettleFor=null;rfiGmailUnknownRows.add(rowKey);
26517
+ await rfiFinishGmailResponse(rowKey,{httpOk:true},{rfi:fresh});return;
26518
+ }
26519
+ if(!now||!rfiHeldAttempt(fresh,f.attemptId)){
26520
+ rfiSettleFor=null;rfiGmailUnknownRows.add(rowKey);
26521
+ rfiGmailOutcome(rowKey,'rfi-gmail-outcome-unknown','FloLess stopped waiting, and a new Gmail send may be on its way. Do not send this RFI again. Check it once the connection recovers.','unknown');return;
26522
+ }
26523
+ }
26524
+ // No answer: the same key does it once, so trying again is safe.
26525
+ f.busy=false;f.error='FloLess didn’t get an answer, so it can’t tell whether that was recorded. Doing it again does it once.';
26526
+ rfiFocusOverride={rows:[rowKey],ctl:'settle:submit'};rfiSay(f.error);
26527
+ }finally{
26528
+ deadline.clear();rfiGmailBusy=null;renderRfiList();paintRfiFail();paintRfiStat();
26529
+ }
26530
+ }
25991
26531
  async function rfiSubmitForm(){
25992
26532
  const f=rfiFormFor;
25993
26533
  if(!f||f.busy)return;
@@ -26205,20 +26745,27 @@ function renderRfiList(){
26205
26745
  ?'<b>Nothing closed yet.</b>No RFI on this project has been closed.'
26206
26746
  :total
26207
26747
  ?'<b>Nothing matches this filter.</b>There are '+total+' RFI'+(total===1?'':'s')+' here — widen the filter above to see them.'
26748
+ // #2920: never the all-clear while the read's own questions are waiting above, unfiled.
26749
+ :rfiReadCount()
26750
+ ?'<b>No RFIs '+(rfiStatusFilter==='all'?'yet':'are open')+'.</b>The questions from the drawing read above are not filed yet.'
26751
+ :rfiState.readQuestionsUnavailable
26752
+ ?'<b>No RFIs are open.</b>The questions the drawing read asked could not be checked — see above.'
26208
26753
  :rfiStatusFilter==='all'
26209
26754
  ?'<b>No RFIs yet.</b>Nothing has been asked about this project, and every member has a size FloLess can price.'
26210
26755
  :'<b>Nothing is waiting on an answer.</b>Every question that was asked has been closed, and every member has a size FloLess can price.';
26211
- list.innerHTML=rfiQuickFilingHtml()+'<div class=rfiempty>'+empty+'</div>';
26756
+ list.innerHTML=rfiQuickFilingHtml()+rfiReadQuestionsHtml()+'<div class=rfiempty>'+empty+'</div>';
26212
26757
  wireRfiList();
26213
26758
  rfiRestoreFocus(restore);
26214
26759
  return;
26215
26760
  }
26216
26761
 
26217
- const shown=rows.slice(0,RFI_ROW_CAP);
26218
- let html=rfiQuickFilingHtml();
26762
+ const shown=rfiShownRows(rows,RFI_ROW_CAP,rfiMentioned);
26763
+ let html=rfiQuickFilingHtml()+rfiReadQuestionsHtml();
26219
26764
  for(const row of shown)html+=(row.kind==='record'?rfiRecordRowHtml(row.record):rfiSymptomRowHtml(row));
26220
26765
  if(rows.length>shown.length)html+='<div class=rfimore>'+(rows.length-shown.length)+' more not listed here — narrow the filter above.</div>';
26221
26766
  list.innerHTML=html;
26767
+ // #2874: the RFI a chat mention just opened keeps its outline through a repaint while it shows.
26768
+ if(rfiMentioned){const r=_rfiByAttr(list,'data-rfi-row',rfiRowKey('record',rfiMentioned));if(r)r.classList.add('is-mentioned');}
26222
26769
  wireRfiList();
26223
26770
  rfiRestoreFocus(restore);
26224
26771
  }
@@ -26568,7 +27115,78 @@ function rfiTargetControls(r,occurrenceIndex){
26568
27115
  * shown here, where the person is now looking, and the outcome goes back to the shell for its own line.
26569
27116
  */
26570
27117
  const EDITOR_FOCUS_3D_WAIT_MS=20000;
27118
+ /** The last-resort sentence when showing what was asked for failed in a way the runner did not foresee. */
27119
+ function editorFocusFailed(req){
27120
+ if(req.rfiId)return 'FloLess could not show '+req.rfiId+'. Find it on the RFIs page, or press it in the chat again.';
27121
+ return req.memberId?'The model could not show member '+req.memberId+'. Press Show in the model again, or find it in the Model panel.'
27122
+ :'The model could not show connection '+req.jointId+'. Press Open in the model again, or find it in the Model panel.';
27123
+ }
27124
+ /**
27125
+ * #2874: one RFI a chat message mentioned, on this project's RFIs page. "Shown" only once the page is up, its records
27126
+ * are read, a view that lists the RFI is on (the status filter and the scope widen to All and the whole project when
27127
+ * they hide it), and its row is focused and outlined. Every other outcome is a sentence, never an error page.
27128
+ */
27129
+ /**
27130
+ * #2874: read the records for a chat mention, so a just-filed or just-removed RFI is judged on the list as it is now,
27131
+ * never on the one the page held before. Each read is cancelled at the deadline, so none is left running; a read
27132
+ * another one replaced left the old list in place, so it is read again. True once a read is the one the list shows,
27133
+ * false at the deadline, null when the request was replaced meanwhile.
27134
+ */
27135
+ async function rfiReadForMention(until,current){
27136
+ while(Date.now()<until){
27137
+ const stop=new AbortController();
27138
+ let late=false;
27139
+ const timer=setTimeout(()=>{late=true;stop.abort();},Math.max(0,until-Date.now()));
27140
+ let shown=false;
27141
+ try{shown=await refreshRfiRecords({signal:stop.signal});}
27142
+ catch(e){console.warn('[rfi] a records read for a chat mention failed',e);}
27143
+ finally{clearTimeout(timer);stop.abort();}
27144
+ if(!current())return null;
27145
+ if(shown)return true;
27146
+ if(late||Date.now()>=until)return false;
27147
+ await new Promise(resolve=>setTimeout(resolve,100));
27148
+ if(!current())return null;
27149
+ }
27150
+ return false;
27151
+ }
27152
+ /** The rows the RFI list draws: the first `cap`, in order, with the RFI a chat mention asked for kept in the last place
27153
+ * when it falls past the cap, since widening the filter cannot bring a row below that cut into view. */
27154
+ function rfiShownRows(rows,cap,mentioned){
27155
+ const shown=rows.slice(0,cap);
27156
+ if(!mentioned||rows.length<=cap)return shown;
27157
+ const at=rows.findIndex(row=>row&&row.kind==='record'&&row.record&&row.record.id===mentioned);
27158
+ return at>=cap?[...shown.slice(0,cap-1),rows[at]]:shown;
27159
+ }
27160
+ async function runRfiFocus(rfiId,current){
27161
+ // Every failure is shown here, where the person is looking, as well as returned for the chat's own line.
27162
+ const failed=said=>{answerToast(said);return {ok:false,said};};
27163
+ if(rfiFormFor&&rfiOpen())return failed('An RFI form is open. Finish or cancel it, then press '+rfiId+' in the chat again.');
27164
+ if(!(await openRFI(null,null,null)))return current()?failed('FloLess could not open the RFIs page. Click RFIs above, then find '+rfiId+'.'):null;
27165
+ if(!current())return null;
27166
+ const fresh=await rfiReadForMention(Date.now()+EDITOR_FOCUS_3D_WAIT_MS,current);
27167
+ if(fresh===null)return null;
27168
+ if(!fresh)return failed('The RFIs did not load in time, so '+rfiId+' was not shown. Press it in the chat again.');
27169
+ if(!rfiState.records.some(row=>row&&row.id===rfiId)){
27170
+ const said=rfiState.status==='ok'?rfiId+' is no longer one of this project’s RFIs. The list shows the RFIs it has now.'
27171
+ :'FloLess could not read this project’s RFIs just now, so '+rfiId+' was not shown. Press it in the chat again in a moment.';
27172
+ return {...failed(said),reason:'missing'};
27173
+ }
27174
+ const list=document.getElementById('rfiList');
27175
+ const rowOf=()=>_rfiByAttr(list,'data-rfi-row',rfiRowKey('record',rfiId));
27176
+ // Set before the list is drawn again, so it keeps this RFI in view even past the number of rows it draws.
27177
+ rfiMentioned=rfiId;
27178
+ let widened=false;
27179
+ if(!rowOf()){rfiScope='project';rfiStatusFilter='all';widened=true;renderRfiList();}
27180
+ const row=rowOf();
27181
+ if(!row){rfiMentioned=null;return failed(rfiId+' could not be shown on the RFIs page. Find it under All.');}
27182
+ rfiApplyFocus({recordId:rfiId});
27183
+ row.classList.add('is-mentioned');
27184
+ setTimeout(()=>{if(rfiMentioned!==rfiId)return;rfiMentioned=null;
27185
+ const shown=_rfiByAttr(document.getElementById('rfiList'),'data-rfi-row',rfiRowKey('record',rfiId));if(shown)shown.classList.remove('is-mentioned');},2400);
27186
+ return widened?{ok:true,said:'Showing all RFIs, so '+rfiId+' is in view.'}:{ok:true};
27187
+ }
26571
27188
  async function runEditorFocus(req,current){
27189
+ if(req.rfiId)return runRfiFocus(req.rfiId,current);
26572
27190
  const until=Date.now()+EDITOR_FOCUS_3D_WAIT_MS;
26573
27191
  while(!window.Steel3DView&&Date.now()<until){await new Promise(resolve=>setTimeout(resolve,100));if(!current())return null;}
26574
27192
  // #2471: a member an answer cited. The shell checked the project is the cited one; this frame shows that project.
@@ -26614,7 +27232,7 @@ EditorFocus.setRunner(async(req,current)=>{
26614
27232
  catch(error){
26615
27233
  console.error('[steel] could not show the connection asked for',error);
26616
27234
  if(!current())return null;
26617
- const said=req.memberId?'The model could not show member '+req.memberId+'. Press Show in the model again, or find it in the Model panel.':'The model could not show connection '+req.jointId+'. Press Open in the model again, or find it in the Model panel.';
27235
+ const said=editorFocusFailed(req);
26618
27236
  answerToast(said);
26619
27237
  return {ok:false,said};
26620
27238
  }
@@ -26765,6 +27383,146 @@ async function focusMember(memberId,opts){
26765
27383
  if(modelEditor.dispatch('model.fit-selection')===false)return {ok:false,reason:'frame',said:'Member '+memberId+' is selected, but it is hidden in the 3D view. Use Show all in the Visibility menu, then press Show in the model again.'};
26766
27384
  return {ok:true};
26767
27385
  }
27386
+ /* -- AI Chat's view command (#2255; the steel model, #2876) ----------------------------------------------------------
27387
+ The structured query the Revit and Tekla Parser viewers take (web/model-view-query.js), evaluated over this model's
27388
+ members by the rows its Properties panel shows (PROP_DEFS, plus Material) and applied through the calls the 3D
27389
+ toolbar makes. Only the view changes: nothing is saved.
27390
+ The steel model is edited live, so the view a command was claimed for is this page's session, not a model revision:
27391
+ a query is matched against the members as they are when it is applied. Ids keep the revision they were shared with
27392
+ (the selection's serverRevision), as in every viewer. When the 3D view is not on screen it comes up first, the way
27393
+ Show in the model brings it up; the query is checked before that, so a request that cannot apply moves nothing, and
27394
+ checked again after, synchronously from there to its last change, so an edit cannot land in the middle. */
27395
+ // Made on first use with the editor's own id helper (it falls back where crypto is missing), so loading this block runs nothing.
27396
+ let steelViewerSessionId=null;
27397
+ const steelViewSession=()=>steelViewerSessionId||(steelViewerSessionId=newMutationId());
27398
+ /** Bringing the 3D view up must leave time to answer before the main window stops waiting (9 s, web/chat.js). */
27399
+ const STEEL_VIEW_3D_WAIT_MS=7000;
27400
+ const STEEL_VIEW_MODES=Object.freeze(['wire','xray','solid','realistic','shadowed']);
27401
+ /** Rows whose value is a world elevation in millimetres (see _effTos), compared as lengths. */
27402
+ const STEEL_VIEW_ELEVATION_KEYS=new Set(['tos_start','tos_end','col_tos','col_bos']);
27403
+ function steelViewTarget(){
27404
+ return {projectId:PROJECT,source:'steel',revision:'live',sourceDigest:'live',viewerSessionId:steelViewSession(),loading:false};
27405
+ }
27406
+ /** One candidate per member: { id, label, facts: Map<lowercase name, fact[]>, names, colour }. */
27407
+ function steelViewCandidates(){
27408
+ const members=allMembers().filter(m=>m&&m.id!=null);
27409
+ const lookup={members:new Map(members.map(m=>[m.id,m])),details:new Map()};
27410
+ return members.map(m=>{
27411
+ const facts=new Map(),names=new Map();
27412
+ const add=(name,shown,number=null,unit=null,lengthMm=null)=>{
27413
+ const key=name.toLocaleLowerCase(),list=facts.get(key)||[];
27414
+ list.push({group:'Properties',text:String(shown),number,unit,lengthMm});facts.set(key,list);if(!names.has(key))names.set(key,name);
27415
+ };
27416
+ for(const def of PROP_DEFS){
27417
+ // A row the panel withholds (a plan-derived default) is not a value to match on.
27418
+ if(def.needsPlan&&!def.canonicalGet)continue;
27419
+ let raw,shown;
27420
+ try{raw=def.needsPlan?def.canonicalGet(m):(def.labelGet||def.get)(m);if(raw===undefined||raw===null)continue;shown=def.fmt(raw);}
27421
+ catch(_){continue;}
27422
+ if(shown==null||shown==='')continue;
27423
+ if(def.key==='length'){const mm=_lenMm(m);add(def.label,shown,Number.isFinite(mm)?mm:null,'mm',Number.isFinite(mm)?mm:null);}
27424
+ else if(STEEL_VIEW_ELEVATION_KEYS.has(def.key)&&Number.isFinite(raw))add(def.label,shown,raw,'mm',raw);
27425
+ else if(def.key==='weight'&&Number.isFinite(raw))add(def.label,shown,raw,_uw().weight,null);
27426
+ else add(def.label,shown);
27427
+ }
27428
+ let material=null;try{material=m.material||profileDefaultMaterial(m.profile);}catch(_){}
27429
+ if(material)add('Material',material);
27430
+ return {id:m.id,label:subjectLabelText(subjectLabel({kind:'member',id:m.id},lookup))||String(m.id),facts,names,colour:null};
27431
+ });
27432
+ }
27433
+ async function applySteelModelView(command,target){
27434
+ const selectedNow=()=>{try{return modelEditor.isReady()?(modelEditor.getState().selectionCount??selIds.size):selIds.size;}catch(_){return selIds.size;}};
27435
+ const base={total:0,matched:0,selectionApplied:0,selectedFinal:0,notDrawable:0,noField:0,unchecked:0,overCap:false,
27436
+ framed:false,display:null,skipped:[],assumptions:[],references:[],samples:[]};
27437
+ const refuse=(reason,extra={})=>({...base,selectedFinal:selectedNow(),status:'not-applied',reason,...extra});
27438
+ // Only the view this command was claimed for: this page, showing this project's model.
27439
+ const sameView=()=>!editorTerminalDisposed&&!!target&&target.viewerSessionId===steelViewSession();
27440
+ if(!sameView())return refuse('session-changed');
27441
+ if(target.projectId!==PROJECT)return refuse('model-changed');
27442
+ let parsed;
27443
+ try{parsed=ModelPanelBridge.parseModelViewCommand(command);}
27444
+ catch(error){console.error('[steel] an AI view command could not be read',error);return refuse('failed');}
27445
+ // The query over the members as they are now. `drawn` (member ids built in 3D) is known once the 3D view is up.
27446
+ const evaluate=(drawn)=>{
27447
+ const candidates=steelViewCandidates(),total=candidates.length;
27448
+ if(!parsed.select)return {total,selection:null};
27449
+ const ev=ModelPanelBridge.evaluateModelViewQuery(candidates,parsed.select,{selectedIds:[...selIds],knownIds:new Set(candidates.map(c=>c.id)),
27450
+ revision:serverRevision>=0?String(serverRevision):'',displayUnits:displayUnits()});
27451
+ if(!ev.ok)return {total,refusal:refuse(ev.reason,{total,field:ev.field??null,commonFields:ev.commonFields??null,missing:ev.missing??0})};
27452
+ const counts={total,matched:ev.matchedIds.length,noField:ev.noField,unchecked:ev.unchecked,references:ev.references,assumptions:ev.assumptions};
27453
+ if(!ev.matchedIds.length)return {total,refusal:refuse('no-match',counts)};
27454
+ if(!drawn)return {total,selection:{ids:ev.matchedIds,counts}};
27455
+ // A member with no geometry (an elevation that was never read) is matched but has nothing to select in 3D.
27456
+ const ids=ev.matchedIds.filter(id=>drawn.has(id)),notDrawable=ev.matchedIds.length-ids.length;
27457
+ if(!ids.length)return {total,refusal:refuse('nothing-drawable',{...counts,notDrawable})};
27458
+ return {total,selection:{ids,counts:{...counts,notDrawable}}};
27459
+ };
27460
+ const needsSelection=ModelPanelBridge.displayNeedsSelection(parsed.display);
27461
+ let checked;
27462
+ try{checked=evaluate(null);}
27463
+ catch(error){console.error('[steel] an AI view command could not be evaluated',error);return refuse('failed');}
27464
+ if(checked.refusal)return checked.refusal;
27465
+ if(needsSelection&&!checked.selection&&!selIds.size)return refuse('selection-required',{total:checked.total});
27466
+ // The 3D view holds the selection's display tools: bring it up, in the layout the person chose (requestFocusView).
27467
+ const ready3d=()=>view3dShown&&view3dReady&&!!window.Steel3DView&&modelEditor.isReady()&&!viewTransition;
27468
+ // A request refused once the 3D view was brought up for it puts the 2D plan back (and cancels a switch still on its
27469
+ // way), unless the person picked a view meanwhile: "Nothing changed" must stay true of the layout too.
27470
+ let putBack=()=>{};
27471
+ const refuseAfter3d=(reason,extra)=>{putBack();return refuse(reason,extra);};
27472
+ if(!ready3d()){
27473
+ const choice=viewChoiceSeq,before=viewMode;let gaveUp=false,timer=null;
27474
+ // viewWantSeq++ calls off a 3D/Split switch still waiting; focusViewSeq++ calls off requestFocusView's own retry of
27475
+ // a Split restore it took over; remember:false keeps the person's saved layout (this is not their choice) (#2876 review).
27476
+ if(before==='2d')putBack=()=>{if(viewChoiceSeq!==choice)return;viewWantSeq++;focusViewSeq++;if(viewMode!=='2d')setView('2d',{remember:false});};
27477
+ const up=(async()=>view3dSettled(await requestFocusView(),()=>!gaveUp,choice))();
27478
+ const outcome=await Promise.race([up,new Promise(resolve=>{timer=setTimeout(()=>resolve('late'),STEEL_VIEW_3D_WAIT_MS);})]);
27479
+ clearTimeout(timer);gaveUp=true;
27480
+ if(!sameView())return refuse('session-changed');
27481
+ if(outcome!==true||!ready3d())return refuseAfter3d('loading',{total:checked.total});
27482
+ }
27483
+ // From here to the last change nothing awaits.
27484
+ let evaluated;
27485
+ const drawnIds=modelEditor.steel.drawnMemberIds();
27486
+ if(!Array.isArray(drawnIds))return refuseAfter3d('loading',{total:checked.total});
27487
+ try{evaluated=evaluate(new Set(drawnIds));}
27488
+ catch(error){console.error('[steel] an AI view command could not be evaluated',error);return refuseAfter3d('failed',{total:checked.total});}
27489
+ if(evaluated.refusal){putBack();return evaluated.refusal;}
27490
+ const {total,selection}=evaluated,display=parsed.display;
27491
+ if(needsSelection&&!selection&&!selectedNow())return refuseAfter3d('selection-required',{total});
27492
+ if(viewMode==='split')setActivePane('3d');
27493
+ // Nothing has changed up to here. From here on, every step is the call a person's click makes.
27494
+ if(selection){
27495
+ if(modelEditor.steel.clearConnSel)modelEditor.steel.clearConnSel();
27496
+ modelSelection.replaceMembers(selection.ids);selDimIds.clear();sel3dDimIds.clear();modelSelection.clearGrids();render();
27497
+ if(!selection.ids.some(id=>selIds.has(id)))return refuse('failed',{total});
27498
+ }
27499
+ const selectionApplied=selection?selection.ids.filter(id=>selIds.has(id)).length:0;
27500
+ const skipped=[],applied=[];
27501
+ // Framed only when the fit ran: a selection that is all hidden leaves the camera where it was.
27502
+ let framed=false;
27503
+ try{
27504
+ if(selection&&display?.fit!=='none'&&display?.fit!=='all')framed=modelEditor.dispatch('model.fit-selection')===true;
27505
+ if(display?.visibility==='isolate'){modelEditor.dispatch('model.isolate');applied.push('isolate');}
27506
+ if(display?.visibility==='hide-selected'){modelEditor.dispatch('model.hide-selected');applied.push('hide-selected');}
27507
+ if(display?.visibility==='show-all'){modelEditor.dispatch('model.show-all');applied.push('show-all');}
27508
+ if(display?.ghostUnselected!=null){modelEditor.dispatch('model.ghost-unselected.set',display.ghostUnselected);applied.push('ghost');}
27509
+ if(display?.mode){modelEditor.dispatch('model.display-mode.set',display.mode);reflectMode();applied.push('mode');}
27510
+ if(display?.fit==='all'){modelEditor.dispatch('model.fit');applied.push('fit-all');}
27511
+ else if(display?.fit==='selection'&&!selection&&selectedNow()){framed=modelEditor.dispatch('model.fit-selection')===true;applied.push('fit-selection');}
27512
+ }catch(error){
27513
+ console.error('[steel] an AI display change failed part way',error);
27514
+ skipped.push('display-failed');
27515
+ }
27516
+ render();
27517
+ modelPanelBridge?.publishSnapshot();
27518
+ const state=modelEditor.getState()||{},mode=modelEditor.displayMode();
27519
+ const lookup={members:new Map(allMembers().filter(Boolean).map(m=>[m.id,m])),details:new Map()};
27520
+ return {...base,...(selection?.counts??{}),total,
27521
+ status:skipped.length?'partial':'applied',reason:null,skipped,
27522
+ selectionApplied,selectedFinal:state.selectionCount??selIds.size,framed,
27523
+ display:{ghostUnselected:modelEditor.ghostUnselected()===true,mode:STEEL_VIEW_MODES.includes(mode)?mode:'solid',filtered:state.hasVisibilityFilter===true,applied},
27524
+ samples:selection?selection.ids.slice(0,10).map(id=>(subjectLabelText(subjectLabel({kind:'member',id},lookup))||String(id)).slice(0,120)):[]};
27525
+ }
26768
27526
  async function rfiOpenTarget(button){
26769
27527
  const tuple=JSON.parse(button.dataset.rfiTarget),held=rfiCurrentTarget(tuple);
26770
27528
  const localErrorKey=Number.isSafeInteger(tuple[3])?rfiOccurrenceKey(tuple[0],tuple[3]):null;
@@ -26888,6 +27646,7 @@ function rfiGroupedRecordRowHtml(r){
26888
27646
  deliveryActs='<button data-command-id="steel.rfi-gmail-continue#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'" aria-label="Continue recording this send: '+esc(r.id)+'" data-rfi-ctl="gmail:continue" data-rfi-gmail-action=continue data-rfi-gmail-on="'+esc(r.id)+'" data-rfi-gmail-attempt="'+esc(delivery.attemptId)+'" data-tip="Resume only this prepared Gmail attempt"'+(busy?' aria-busy=true aria-disabled=true data-blocked-reason="This prepared Gmail attempt is already being continued"':'')+'>'+(busy?'Continuing this send…':'Continue recording this send')+'</button>';}
26889
27647
  if(delivery&&delivery.status==='outcome-unknown'&&delivery.canConfirmFoundInSent&&delivery.attemptId){const busy=deliveryBusy&&rfiGmailBusy.action==='confirm';
26890
27648
  deliveryActs='<button data-command-id="steel.rfi-gmail-confirm-sent#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'" aria-label="I found it in Sent: '+esc(r.id)+'" data-rfi-ctl="gmail:confirm" data-rfi-gmail-action=confirm data-rfi-gmail-on="'+esc(r.id)+'" data-rfi-gmail-attempt="'+esc(delivery.attemptId)+'" data-tip="Use only after matching this exact attempt in the connected account’s Sent folder"'+(busy?' aria-busy=true aria-disabled=true data-blocked-reason="This Sent-folder confirmation is already being recorded"':'')+'>'+(busy?'Recording confirmation…':'I found it in Sent')+'</button>';}
27649
+ deliveryActs+=rfiSettleButton(r,delivery,rowKey);
26891
27650
  const occurrences=expanded?'<ol id="'+panelId+'" class=rfioccurrences aria-label="Occurrences in '+esc(r.id)+'">'+ordered.map(occ=>{
26892
27651
  const index=occ.occurrenceIndex,key=rfiOccurrenceKey(r.id,index),technical=rfiTechnicalOccurrences.has(key);
26893
27652
  const occurrenceForm=formOpen&&rfiFormFor.scopeKind!=='group'&&rfiFormFor.occurrenceIndex===index;
@@ -26907,7 +27666,7 @@ function rfiGroupedRecordRowHtml(r){
26907
27666
  const sheetSummary=rfiScope==='sheet'?matching.length+' of '+count+' occurrences on this sheet · ':'';
26908
27667
  return '<div class="rfirow'+(formOpen?' editing':'')+'" data-rfi-row="'+esc(rowKey)+'"'+(rowBusy?' aria-busy="true"':'')+'><span class="rfikind '+rfiStatusTone(r)+'">'+esc(kind)+'</span><div class=rfitx>'
26909
27668
  +esc(r.question||'This grouped RFI records no question.')+'<div class=rfimeta><span>'+esc(r.id)+'</span><span>'+esc(rfiStatusWords(r))+'</span><span>'+sheetSummary+count+' occurrences · '+r.counts.sheets+' sheets · '+r.counts.entities+' members/connections</span></div>'
26910
- +deliveryNote+(groupForm?rfiFormHtml(r,'all '+count+' occurrences',rowKey):(formOpen?'':recovering?rfiRecoveryHtml(rowKey)+(copy?'<div class=rfiacts>'+copy+'</div>':''):'<div class=rfiacts>'+gmail+send+allAnswer+allClose+allReopen+copy+deliveryActs+'</div>'))
27669
+ +deliveryNote+rfiSettleHtml(r,rowKey)+(groupForm?rfiFormHtml(r,'all '+count+' occurrences',rowKey):(formOpen?'':recovering?rfiRecoveryHtml(rowKey)+(copy?'<div class=rfiacts>'+copy+'</div>':''):'<div class=rfiacts>'+gmail+send+allAnswer+allClose+allReopen+copy+deliveryActs+'</div>'))
26911
27670
  +'<button class="ghost rfigroup-toggle" data-command-id="steel.rfi-group-toggle#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'" data-rfi-expand="'+esc(r.id)+'" data-rfi-ctl=expand aria-expanded="'+expanded+'" aria-controls="'+panelId+'"><span>'+(expanded?'Hide':'Show')+' '+count+' occurrences</span><span aria-hidden=true>'+(expanded?'▴':'▾')+'</span></button>'
26912
27671
  +(formOpen?'':rfiOutcomeHtml(rowKey))+occurrences+'</div></div>';
26913
27672
  }
@@ -26966,6 +27725,134 @@ async function rfiQuickRefile(versionN){
26966
27725
  finally{rfiQuickRefileBusy=null;await refreshRfiRecords();if(rfiOpen())renderRfiList();if(window.__tip)window.__tip.hide();}
26967
27726
  }
26968
27727
 
27728
+ /* #2920 — the questions the newest drawing read asked that nobody filed (owner ruling 2026-10-29). A guided read
27729
+ files only what its reader names, so a read that names nothing published its questions to an empty list. They
27730
+ show here, grouped by kind, and a person raises the ones they want; none is an RFI until somebody does. */
27731
+ const RFI_READ_KIND={
27732
+ 'unknown-elevation':{label:'Member-end heights the read assumed',sub:'Each end is placed at a plan level so the member is built. No drawing confirms the height.'},
27733
+ 'unresolved-line':{label:'Drawn lines not matched to a member'},
27734
+ 'column-short-of-beam':{label:'Columns that stop short of the beams on them'},
27735
+ 'section-inconsistent':{label:'Beams on one span with different sections'},
27736
+ };
27737
+ /** One grouped RFI holds at most this many questions (the store's group limit); more become several. */
27738
+ const RFI_READ_GROUP_MAX=64;
27739
+ /** A group longer than this opens on request, so 84 height rows do not bury everything below them. */
27740
+ const RFI_READ_OPEN_MAX=3;
27741
+ let rfiReadBusy=null,rfiReadFail=null;
27742
+ const rfiReadOpenKinds=new Set();
27743
+ function rfiReadKindLabel(kind,served){
27744
+ // The server's words first: they are the title a grouped RFI of this kind is filed under.
27745
+ if(typeof served==='string'&&served)return served;
27746
+ const known=RFI_READ_KIND[kind];if(known)return known.label;
27747
+ const words=String(kind||'question').replace(/-/g,' ');return words.charAt(0).toUpperCase()+words.slice(1);
27748
+ }
27749
+ /** The read's unfiled questions, by kind, in the order the read listed them. */
27750
+ function rfiReadGroups(){
27751
+ const rq=rfiState.readQuestions;
27752
+ if(!rq||!Array.isArray(rq.notFiled)||!rq.notFiled.length)return [];
27753
+ const byKind=new Map();
27754
+ for(const q of rq.notFiled){if(!q||typeof q.gapKey!=='string')continue;if(!byKind.has(q.kind))byKind.set(q.kind,[]);byKind.get(q.kind).push(q);}
27755
+ return [...byKind].map(([kind,rows])=>({kind,rows}));
27756
+ }
27757
+ /** How many of the read's questions are not filed: the chip's second figure. */
27758
+ function rfiReadCount(){
27759
+ const rq=rfiState.readQuestions;
27760
+ return rq&&Number.isSafeInteger(rq.notFiledCount)&&rq.notFiledCount>0&&!rq.rfiFileUnavailable?rq.notFiledCount:0;
27761
+ }
27762
+ /** A question cut to a phrase Instructor can say: the start of the sentence, never the row's internal id. */
27763
+ function rfiReadShortQuestion(text){
27764
+ const s=String(text||'').replace(/\s+/g,' ').trim();
27765
+ if(!s)return 'this question';
27766
+ return s.length>70?s.slice(0,67).replace(/\s+\S*$/,'')+'…':s;
27767
+ }
27768
+ function rfiReadMembersHtml(ids){
27769
+ if(!Array.isArray(ids)||!ids.length)return '';
27770
+ const shown=ids.slice(0,6).map(id=>'<span>'+esc(id)+'</span>').join('');
27771
+ return '<div class=rfimeta>'+shown+(ids.length>6?'<span>and '+(ids.length-6)+' more</span>':'')+'</div>';
27772
+ }
27773
+ function rfiReadFailHtml(key){
27774
+ return rfiReadFail&&rfiReadFail.key===key?'<div class="rfinote rfiwhy" role=status>'+esc(rfiReadFail.text)+'</div>':'';
27775
+ }
27776
+ function rfiReadRaiseAllLabel(n){
27777
+ const parts=Math.ceil(n/RFI_READ_GROUP_MAX);
27778
+ return parts===1?'Raise one RFI for all '+n:'Raise '+parts+' RFIs for all '+n;
27779
+ }
27780
+ function rfiReadQuestionsHtml(){
27781
+ const rq=rfiState.readQuestions,groups=rfiReadGroups();
27782
+ // Said, never hidden: a list that could not look at the read's questions must not read as one that has none.
27783
+ if(rfiState.readQuestionsUnavailable)return '<section class="rfiunfiled rfiread" data-rfi-read-unavailable aria-label="From the read"><div class=glab>From the read</div><div class="rfinote rfiwhy">FloLess could not list the questions the drawing read asked, so some may be missing from this list. Reopen this step to try again.</div></section>';
27784
+ if(!rq||!groups.length)return '';
27785
+ const unknown=!!rq.rfiFileUnavailable,v=esc(rq.versionN);
27786
+ const heading=unknown?'From the read, filing status unknown':'From the read, not filed';
27787
+ const note=unknown
27788
+ ?'FloLess could not read the RFI file, so it cannot tell which of these questions from the drawing read of version '+v+' are filed already.'
27789
+ :'The drawing read of version '+v+' asked these questions. None of them is an RFI until you raise it.';
27790
+ let html='<section class="rfiunfiled rfiread" data-rfi-row=readsection tabindex=-1 data-rfi-read-version="'+v+'" aria-label="'+esc(heading)+'"><div class=glab>'+esc(heading)+'</div><div class=rfinote>'+note+'</div>';
27791
+ for(const g of groups){
27792
+ const n=g.rows.length,known=RFI_READ_KIND[g.kind],label=rfiReadKindLabel(g.kind,g.rows[0]&&g.rows[0].kindLabel),groupKey='readgroup:'+g.kind;
27793
+ const open=n<=RFI_READ_OPEN_MAX||rfiReadOpenKinds.has(g.kind),busyAll=rfiReadBusy===groupKey;
27794
+ const members=new Set();for(const q of g.rows)for(const id of (q.memberIds||[]))members.add(id);
27795
+ const count=g.kind==='unknown-elevation'&&members.size?n+' end'+(n===1?'':'s')+' on '+members.size+' member'+(members.size===1?'':'s'):String(n);
27796
+ const raiseAll=!unknown&&n>1?'<button data-command-id="steel.rfi-read-raise-all#'+esc(label)+'" data-command-instance-label="'+esc(label)+'" data-rfi-ctl="read-raise-all" data-rfi-read-raise-all="'+esc(g.kind)+'" data-tip="Files these '+n+' questions as '+(n>RFI_READ_GROUP_MAX?'grouped RFIs of up to '+RFI_READ_GROUP_MAX+' questions each':'one grouped RFI')+'. Nothing is sent to anyone."'
27797
+ +(rfiReadBusy!==null?' aria-busy='+(busyAll?'true':'false')+' aria-disabled=true data-blocked-reason="'+(busyAll?'These questions are being filed':'Another question is being filed')+'"':'')+'>'+(busyAll?'Raising…':esc(rfiReadRaiseAllLabel(n)))+'</button>':'';
27798
+ const toggle=n>RFI_READ_OPEN_MAX?'<button class=ghost data-command-id="steel.rfi-read-toggle#'+esc(label)+'" data-command-instance-label="'+esc(label)+'" data-rfi-ctl="read-toggle" data-rfi-read-toggle="'+esc(g.kind)+'" aria-expanded="'+open+'">'+(open?'Hide':'Show '+n)+'</button>':'';
27799
+ html+='<div class=rfireadgroup data-rfi-row="'+esc(groupKey)+'" data-rfi-read-kind="'+esc(g.kind)+'"><div class=rfireadhead><b>'+esc(label)+'</b> <span class=rfireadn>('+esc(count)+')</span></div>'
27800
+ +(known&&known.sub?'<div class=rfinote>'+esc(known.sub)+'</div>':'')
27801
+ +rfiReadFailHtml(groupKey)
27802
+ +(raiseAll||toggle?'<div class=rfiacts>'+raiseAll+toggle+'</div>':'');
27803
+ if(open)for(const q of g.rows){
27804
+ const key='read:'+q.gapKey,busy=rfiReadBusy===key;
27805
+ const raise=unknown?'':'<div class=rfiacts><button data-command-id="steel.rfi-read-raise#'+esc(q.id||q.gapKey)+'" data-command-instance-label="'+esc(rfiReadShortQuestion(q.question))+'" data-rfi-ctl="read-raise" data-rfi-read-raise="'+esc(q.gapKey)+'" data-tip="Files this question as an open RFI. Nothing is sent to anyone."'
27806
+ +(rfiReadBusy!==null?' aria-busy='+(busy?'true':'false')+' aria-disabled=true data-blocked-reason="'+(busy?'This question is being filed':'Another question is being filed')+'"':'')+'>'+(busy?'Raising…':'Raise an RFI')+'</button></div>';
27807
+ html+='<div class=rfirow data-rfi-row="'+esc(key)+'" data-rfi-read-unfiled="'+esc(q.gapKey)+'"><span class="rfikind sym">'+(unknown?'status unknown':'not filed')+'</span><div class=rfitx>'+esc(q.question)
27808
+ +rfiReadMembersHtml(q.memberIds)+rfiReadFailHtml(key)+raise+'</div></div>';
27809
+ }
27810
+ html+='</div>';
27811
+ }
27812
+ if(rq.heldBack>0)html+='<div class=rfimore>'+esc(rq.heldBack)+' more question'+(rq.heldBack===1?'':'s')+' from the read are not listed here.</div>';
27813
+ return html+'</section>';
27814
+ }
27815
+ /** Files read questions: one (a row's Raise an RFI) or every question of one kind as grouped RFIs. */
27816
+ async function rfiReadRaise(gapKeys,asOne,busyKey){
27817
+ const rq=rfiState.readQuestions;
27818
+ if(rfiReadBusy!==null||!rq||!gapKeys.length)return;
27819
+ rfiReadBusy=busyKey;rfiReadFail=null;
27820
+ rfiFocusOverride={rows:[busyKey],ctl:asOne?'read-raise-all':'read-raise'};renderRfiList();
27821
+ // Where focus goes once this row or group has left the list: the next one, else the section, else the title.
27822
+ const order=rfiReadGroups().flatMap(g=>['readgroup:'+g.kind,...g.rows.map(q=>'read:'+q.gapKey)]);
27823
+ const after=order.slice(order.indexOf(busyKey)+1).filter(k=>!(k.startsWith('read:')&&gapKeys.includes(k.slice(5))));
27824
+ let filed=false;
27825
+ try{
27826
+ const res=await fetch('/api/projects/'+encodeURIComponent(PROJECT)+'/versions/'+encodeURIComponent(rq.versionN)+'/read-questions',
27827
+ {method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(asOne?{gapKeys,asOne:true}:{gapKeys})});
27828
+ const body=await res.json().catch(()=>null);
27829
+ if(res.ok&&body&&body.ok){
27830
+ const outcomes=Array.isArray(body.outcomes)?body.outcomes:[];
27831
+ const made=new Set(outcomes.filter(o=>['created','reused','reopened','successor'].includes(o.result)).map(o=>o.rfiId));
27832
+ const already=outcomes.filter(o=>o.result==='already-seeded').length;
27833
+ // Only what genuinely failed to file stays listed: a question the model no longer asks leaves on the reread.
27834
+ const notFiled=outcomes.filter(o=>o.result==='over-capacity'||o.result==='unplaceable'||o.result==='unchecked').length;
27835
+ filed=made.size>0||already>0;
27836
+ if(made.size)toast((made.size===1?[...made][0]+' raised':made.size+' RFIs raised')+(already?'; '+already+' question'+(already===1?' was':'s were')+' filed already':'')+'.');
27837
+ else if(already)toast('Already filed: '+(already===1?'that question is':'those questions are')+' an RFI.');
27838
+ if(notFiled)rfiReadFail={key:busyKey,text:notFiled+' question'+(notFiled===1?'':'s')+' could not be filed as an RFI, so '+(notFiled===1?'it stays':'they stay')+' listed here'+(made.size||already?'; the others were filed':'')+'. Try again, or ask in AI Chat why.'};
27839
+ }else rfiReadFail={key:busyKey,text:'This could not be filed: '+((body&&body.error)||'the RFI file could not be written')+'. Nothing was changed.'};
27840
+ }catch(e){
27841
+ console.error('[steel] could not file the read questions',e);
27842
+ rfiReadFail={key:busyKey,text:'FloLess could not be reached, so it is not known whether this was filed. Reopen the RFIs step: anything that was filed shows there as an RFI.'};
27843
+ }
27844
+ finally{
27845
+ rfiReadBusy=null;
27846
+ await refreshRfiRecords();
27847
+ rfiFocusOverride=filed&&!rfiReadFail?{rows:[...after,'readsection'],ctl:'*first'}:{rows:[busyKey],ctl:asOne?'read-raise-all':'read-raise'};
27848
+ // Through the shared settle, which yields to somebody typing on another row (review): never a bare repaint.
27849
+ rfiSettleRepaint({force:true,actingRow:busyKey});
27850
+ // A repaint deferred for somebody typing on another row must not steal their focus later (review round 2).
27851
+ if(rfiListIsStale)rfiFocusOverride=null;
27852
+ if(window.__tip)window.__tip.hide();
27853
+ }
27854
+ }
27855
+
26969
27856
  function rfiRecordRowHtml(r){
26970
27857
  if(r&&r.grouped)return rfiGroupedRecordRowHtml(r);
26971
27858
  const rowKey=rfiRowKey('record',r.id);
@@ -27072,13 +27959,14 @@ function rfiRecordRowHtml(r){
27072
27959
  else if(delivery.status==='confirmed-sent')deliveryHtml='<div class=rfiaccepted role=note>Confirmed in the connected account’s Sent folder.</div>';
27073
27960
  else if(delivery.status==='failed')deliveryHtml='<div class=rfifail role=note>Gmail did not receive this RFI. Nothing was sent.</div>';
27074
27961
  else if(delivery.status==='prepared')deliveryHtml='<div class=rfiunknown role=note>This Gmail send was prepared, but FloLess has not finished recording its result. Do not start another send.</div>';
27075
- else if(delivery.status==='outcome-unknown')deliveryHtml='<div class=rfiunknown role=note>FloLess cannot confirm whether Gmail accepted this RFI. Do not send it again. Check the connected account’s Sent folder'+(delivery.reconciliationMarker?' for '+esc(delivery.reconciliationMarker):'')+'.</div>';
27962
+ else if(delivery.status==='outcome-unknown')deliveryHtml='<div class=rfiunknown role=note>FloLess cannot confirm whether Gmail accepted this RFI. Do not send it again. Check the connected account’s Sent folder'+(delivery.reconciliationMarker?' for '+esc(delivery.reconciliationMarker):'')+'. If you don’t find it, choose I didn’t find it.</div>';
27076
27963
  if(delivery.status==='prepared'&&delivery.canContinue&&delivery.attemptId){const busy=deliveryBusy&&rfiGmailBusy.action==='continue';
27077
27964
  deliveryActs='<button data-command-id="steel.rfi-gmail-continue#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'" aria-label="Continue recording this send: '+esc(r.id)+'" data-rfi-ctl="gmail:continue" data-rfi-gmail-action=continue data-rfi-gmail-on="'+esc(r.id)+'" data-rfi-gmail-attempt="'+esc(delivery.attemptId)+'" data-tip="Resume only this prepared Gmail attempt"'+(busy?' aria-busy=true aria-disabled=true data-blocked-reason="This prepared Gmail attempt is already being continued"':'')+'>'+(busy?'Continuing this send…':'Continue recording this send')+'</button>';}
27078
27965
  if(delivery.status==='outcome-unknown'&&delivery.canConfirmFoundInSent&&delivery.attemptId){const busy=deliveryBusy&&rfiGmailBusy.action==='confirm';
27079
27966
  deliveryActs='<button data-command-id="steel.rfi-gmail-confirm-sent#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'" aria-label="I found it in Sent: '+esc(r.id)+'" data-rfi-ctl="gmail:confirm" data-rfi-gmail-action=confirm data-rfi-gmail-on="'+esc(r.id)+'" data-rfi-gmail-attempt="'+esc(delivery.attemptId)+'" data-tip="Use only after matching this exact attempt in the connected account’s Sent folder"'+(busy?' aria-busy=true aria-disabled=true data-blocked-reason="This Sent-folder confirmation is already being recorded"':'')+'>'+(busy?'Recording confirmation…':'I found it in Sent')+'</button>';}
27080
27967
  if(deliveryBusy)deliveryHtml+='<div class=rfinote role=note>'+esc(rfiGmailBusyMessage(rfiGmailBusy.action,r.id))+'</div>';
27081
27968
  }
27969
+ deliveryActs+=rfiSettleButton(r,delivery,rowKey);
27082
27970
  if(rfiOutcome&&rfiOutcome.rowKey===rowKey&&delivery&&['failed','prepared','outcome-unknown'].includes(delivery.status))deliveryHtml='';
27083
27971
  if(!delivery&&rfiGmailUnknownRows.has(rowKey))deliveryHtml='<div class=rfiunknown role=note>FloLess lost the Gmail response. Do not send this RFI again until a fresh read proves what happened.</div>';
27084
27972
  // Said out loud rather than left as an absence somebody has to infer.
@@ -27096,7 +27984,7 @@ function rfiRecordRowHtml(r){
27096
27984
  +(answerMismatch&&!profileMismatch?'<div class=rfinote role="note" data-rfi-answer-truth>'+esc(rfiSentence(answerMismatch.fact))+' The saved model must match the answer before Mark applied is available.</div>':'')
27097
27985
  +(receiptMismatch&&!profileMismatch?'<div class=rfinote role="note" data-rfi-receipt-truth>'+esc(rfiSentence(receiptMismatch.fact))+' Refresh the model view before closing this RFI as resolved.</div>':'')
27098
27986
  +(settling?'<div class=rfinote role="note" data-rfi-profile-settle>'+esc(settling.message)+'</div>':'')
27099
- +deliveryHtml
27987
+ +deliveryHtml+rfiSettleHtml(r,rowKey)
27100
27988
  +(rfiCopyFallbackId===r.id&&r.text?'<div class=rfinote style="white-space:pre-wrap;user-select:text">'+esc(r.text)+'</div>':'')
27101
27989
  +(elevGap&&!formOpen&&!recovering?rfiElevationControls(rowKey,r.id,elevGap):'')
27102
27990
  // The outcome renders INSIDE the form when one is open (directly above Submit, where focus lands);
@@ -27385,6 +28273,10 @@ function wireRfiList(){
27385
28273
  // `promote` comes off the CARRIER, because the row key alone cannot say which namespace it is in.
27386
28274
  if(v==='apply')return Promise.resolve(rfiApplyAction(id,occurrence)).catch(rfiGestureFailure);return rfiOpenForm(id,v,promote,occurrence,scopeKind);});
27387
28275
  root.querySelectorAll('[data-rfi-quick-refile]').forEach(b=>b.onclick=()=>Promise.resolve(rfiQuickRefile(Number(b.dataset.rfiQuickRefile))).catch(rfiGestureFailure));
28276
+ // #2920: the read's unfiled questions — one, every one of a kind, or show and hide a kind.
28277
+ root.querySelectorAll('[data-rfi-read-raise]').forEach(b=>b.onclick=()=>{const k=b.dataset.rfiReadRaise;return Promise.resolve(rfiReadRaise([k],false,'read:'+k)).catch(rfiGestureFailure);});
28278
+ root.querySelectorAll('[data-rfi-read-raise-all]').forEach(b=>b.onclick=()=>{const kind=b.dataset.rfiReadRaiseAll,g=rfiReadGroups().find(x=>x.kind===kind);if(!g)return;return Promise.resolve(rfiReadRaise(g.rows.map(q=>q.gapKey),true,'readgroup:'+kind)).catch(rfiGestureFailure);});
28279
+ root.querySelectorAll('[data-rfi-read-toggle]').forEach(b=>b.onclick=()=>{const kind=b.dataset.rfiReadToggle;if(rfiReadOpenKinds.has(kind))rfiReadOpenKinds.delete(kind);else rfiReadOpenKinds.add(kind);rfiFocusOverride={rows:['readgroup:'+kind],ctl:'read-toggle'};renderRfiList();});
27388
28280
  root.querySelectorAll('[data-rfi-expand]').forEach(b=>b.onclick=()=>{
27389
28281
  const id=b.dataset.rfiExpand;if(rfiExpandedGroups.has(id))rfiExpandedGroups.delete(id);else rfiExpandedGroups.add(id);
27390
28282
  rfiFocusOverride={rows:[rfiRowKey('record',id)],ctl:'expand'};renderRfiList();});
@@ -27397,6 +28289,23 @@ function wireRfiList(){
27397
28289
  rfiFocusOverride={rows:[rfiRowKey('record',id)],ctl:'occ:'+index+':technical'};renderRfiList();});
27398
28290
  root.querySelectorAll('[data-rfi-gmail-action]').forEach(b=>b.onclick=()=>
27399
28291
  Promise.resolve(rfiRecoverGmail(b)).catch(rfiGestureFailure));
28292
+ root.querySelectorAll('[data-rfi-settle-open]').forEach(b=>b.onclick=()=>rfiOpenSettle(b.dataset.rfiSettleOpen,b.dataset.rfiSettleAttempt));
28293
+ root.querySelectorAll('[data-rfi-settle-way]').forEach(b=>b.onclick=()=>rfiSettleChoose('way',b.dataset.rfiSettleWay));
28294
+ root.querySelectorAll('[data-rfi-settle-via]').forEach(b=>b.onclick=()=>rfiSettleChoose('via',b.dataset.rfiSettleVia));
28295
+ root.querySelectorAll('[data-rfi-settle-cancel]').forEach(b=>b.onclick=()=>rfiCloseSettle());
28296
+ root.querySelectorAll('[data-rfi-settle-submit]').forEach(b=>b.onclick=()=>{if(b.getAttribute('aria-disabled')==='true'){toast(b.dataset.blockedReason||'Wait for it to finish.');return;}rfiSettleSubmit();});
28297
+ root.querySelectorAll('[data-rfi-settle-history]').forEach(b=>b.onclick=()=>{
28298
+ const id=b.dataset.rfiSettleHistory;if(rfiSettledOpen.has(id))rfiSettledOpen.delete(id);else rfiSettledOpen.add(id);
28299
+ rfiFocusOverride={rows:[rfiRowKey('record',id)],ctl:'settle:history'};renderRfiList();});
28300
+ root.querySelectorAll('[data-rfi-settle-input]').forEach(i=>i.oninput=()=>{
28301
+ if(!rfiSettleFor)return;rfiSettleFor[i.dataset.rfiSettleInput]=i.value;
28302
+ const count=i.dataset.rfiSettleInput==='how'&&i.closest('[data-rfi-settle-panel]')?.querySelector('[data-rfi-settle-count]');
28303
+ if(count)count.textContent=i.value.length+' of '+RFI_HOW_MAX;});
28304
+ // The settle choices are radio groups: arrows move and choose.
28305
+ root.querySelectorAll('[data-rfi-settle-panel] [role=radiogroup]').forEach(g=>g.onkeydown=e=>{
28306
+ if(!['ArrowDown','ArrowRight','ArrowUp','ArrowLeft'].includes(e.key))return;
28307
+ const radios=[...g.querySelectorAll('[role=radio]')],i=radios.indexOf(document.activeElement);if(i<0)return;
28308
+ e.preventDefault();radios[(i+(e.key==='ArrowDown'||e.key==='ArrowRight'?1:radios.length-1))%radios.length].click();});
27400
28309
  root.querySelectorAll('[data-rfi-disp]').forEach(b=>b.onclick=()=>rfiSetDisposition(b.dataset.rfiDisp));
27401
28310
  root.querySelectorAll('[data-rfi-submit]').forEach(b=>b.onclick=()=>Promise.resolve(rfiSubmitForm()).catch(rfiGestureFailure));
27402
28311
  root.querySelectorAll('[data-rfi-cancel]').forEach(b=>b.onclick=()=>rfiCloseForm());
@@ -28464,7 +29373,7 @@ document.getElementById('coCardModal').addEventListener('keydown',e=>{
28464
29373
  e.stopPropagation();
28465
29374
  if(e.key==='Escape'){e.preventDefault();if(window.OverlayEscape)window.OverlayEscape.markUsed(e);closeCalloutCard();return;}
28466
29375
  if(e.key!=='Tab')return;
28467
- const f=[...document.querySelectorAll('#coCardModal button')].filter(n=>!n.disabled&&n.offsetParent!==null);if(!f.length)return;
29376
+ const f=[...document.querySelectorAll('#coCardModal button, #coCardModal input')].filter(n=>!n.disabled&&n.offsetParent!==null);if(!f.length)return;
28468
29377
  const first=f[0],last=f[f.length-1];
28469
29378
  if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus();}
28470
29379
  else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus();}
@@ -30910,6 +31819,7 @@ legendPanelHost=ModelPanelBridge.createPanelHost({win:window,root:legendBody('ro
30910
31819
  modelPanelBridge=ModelPanelBridge.createModelPanelBridge({win:window,origin:location.origin,snapshot:modelPanelSnapshot,
30911
31820
  selectedId:()=>[...selIds].at(-1)||null,selectedIds:()=>[...selIds],selectedSubjects:modelSubjects,
30912
31821
  chatLinksChanged:()=>refreshChatLinks(true),
31822
+ view:(command,target)=>applySteelModelView(command,target), // #2876: an AI view command this window claimed, applied in this viewer
30913
31823
  select:()=>false,expand:()=>false, // no list tabs to pick from or expand
30914
31824
  panel:showLegendTab});
30915
31825
  modelPanelBridge.ready(String(PROJECT||APP_ID));modelPanelGeneration=modelEditGeneration;
@@ -30969,13 +31879,17 @@ rfiPostShell({type:'floless:editor-ready'});
30969
31879
  function set(el,txt){ if(el && el.textContent!==txt) el.textContent=txt; }
30970
31880
  function refresh(){
30971
31881
  set(document.getElementById('structN'),String(num(document.getElementById('mc'))));
30972
- const bad=num(document.getElementById('rc'))+num(document.getElementById('dpc'))+num(document.getElementById('endsCount'));
31882
+ // #2920: a question the read asked and nobody filed is unresolved too, so it counts here and keeps "Nothing
31883
+ // unresolved" from being said over it. The RFI readout itself shows it apart from the open RFIs.
31884
+ const bad=num(document.getElementById('rc'))+num(document.getElementById('rcReadN'))+num(document.getElementById('dpc'))+num(document.getElementById('endsCount'));
30973
31885
  set(document.getElementById('qualN'),String(bad));
30974
31886
  qual.classList.toggle('has',bad>0);
30975
31887
  // Four zeroes state the numbers but not the answer. Only when the ends check has actually RUN, though:
30976
31888
  // "—" means not known, and calling that all-clear would be the panel asserting something it cannot see.
30977
31889
  const endsKnown=(document.getElementById('endsCount').textContent||'').trim()!=='—';
30978
- document.getElementById('qualClear').hidden=!(bad===0&&endsKnown);
31890
+ // #2920: nor while the drawing read's questions could not be listed (Codex on #2929).
31891
+ const readUnknown=document.getElementById('rfiStat').classList.contains('readunknown');
31892
+ document.getElementById('qualClear').hidden=!(bad===0&&endsKnown&&!readUnknown);
30979
31893
  // The pounds line follows Weight, so it hides with it rather than being left behind on its own.
30980
31894
  document.getElementById('wtLbStat').style.display=document.getElementById('wtStat').style.display;
30981
31895
  // Structure is Members + Weight and nothing else, so when stats() hides both for a sheet with no plan