@floless/app 0.165.0 → 0.167.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 (34) hide show
  1. package/dist/floless-server.cjs +30794 -25371
  2. package/dist/schemas/drawing-check.profile.v1.schema.json +4 -2
  3. package/dist/schemas/steel.model.v2.schema.json +2 -1
  4. package/dist/skills/floless-app-knowledge/SKILL.md +8 -1
  5. package/dist/skills/floless-app-rfi/SKILL.md +7 -2
  6. package/dist/skills/floless-app-steel-model/SKILL.md +4 -1
  7. package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -17
  8. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +15 -1
  9. package/dist/templates/college-phase-exporter.flo +41 -49
  10. package/dist/templates/screenshot-to-saved-settings.flo +12 -2
  11. package/dist/web/app.css +120 -1
  12. package/dist/web/aware.js +385 -88
  13. package/dist/web/chat-question-card.js +3 -1
  14. package/dist/web/chat.css +32 -0
  15. package/dist/web/chat.js +1021 -88
  16. package/dist/web/commands-drawing-check.js +1 -0
  17. package/dist/web/commands-filter.js +23 -0
  18. package/dist/web/commands-shell.js +231 -19
  19. package/dist/web/commands-steel.js +22 -2
  20. package/dist/web/drawing-check-editor.html +4 -0
  21. package/dist/web/drawing-check-editor.js +82 -2
  22. package/dist/web/index.html +14 -6
  23. package/dist/web/project-history.js +163 -19
  24. package/dist/web/project-modules.js +5 -0
  25. package/dist/web/project-rfis.js +206 -20
  26. package/dist/web/steel-ai-marks.js +173 -2
  27. package/dist/web/steel-editor.html +770 -49
  28. package/dist/web/steel-filter-flo.js +171 -7
  29. package/dist/web/steel-filter.html +36 -10
  30. package/dist/web/steel-model-v2-projection.js +26 -20
  31. package/dist/web/terminal-requests.js +5 -0
  32. package/dist/web/tool-updates.js +65 -20
  33. package/dist/web/workspaces.js +632 -85
  34. package/package.json +3 -2
@@ -1466,9 +1466,16 @@ rect.lblhot:focus-visible{outline:2px solid var(--brand);outline-offset:2px;stro
1466
1466
  #rfiList .rfimeta span{background:var(--sunken);border:1px solid var(--line);color:var(--mut);
1467
1467
  border-radius:4px;padding:0 5px;font-size:10px;line-height:1.7}
1468
1468
  #rfiList .rfinote{margin-top:4px;color:var(--mut);font-size:11px;line-height:1.5}
1469
+ /* #2470 R6.6d: an RFI's earlier rounds, oldest first, under its current round. Existing tokens only. */
1470
+ #rfiList .rfirounds{list-style:none;margin:4px 0 0;padding:0;display:grid;gap:6px}
1471
+ #rfiList .rfiround-head{color:var(--mut);font-size:11px;font-weight:600;line-height:1.5}
1472
+ #rfiList .rfiround-entries{margin:2px 0 0;padding-left:16px;color:var(--mut);font-size:11px;line-height:1.5}
1473
+ #rfiList .rfirounds-body:empty{display:none}
1469
1474
  /* #2521 row 3b-2 — the AI's mark. The word "AI" carries it, so it survives losing colour; the brand
1470
1475
  outline only says it is not one of the grey facts beside it. Shown where the AI wrote the proposal. */
1471
1476
  #rfiList .rfimeta .rfiby.ai{color:var(--brand);border-color:var(--brand)}
1477
+ /* #2925 — "Filed by you": a grey fact like its neighbours, focusable so its exact time is reachable by keyboard. */
1478
+ #rfiList .rfimeta .rfifiled:focus-visible,#rfiList .rfimeta .rfiby:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
1472
1479
  #rfiList .rfioccurrence-title{display:inline-flex;align-items:baseline;gap:6px;flex-wrap:wrap;margin-top:0}
1473
1480
  /* A Quick version's questions the AI could not get into the RFI file. Rows, not the banner: they are
1474
1481
  questions waiting on a filing, and the dashed badge already means "not filed" in this list. */
@@ -1920,6 +1927,66 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
1920
1927
  .v2-ai-decisions .ai-head{display:flex;align-items:center;gap:6px;margin-bottom:2px}
1921
1928
  .v2-ai-decisions .ai-row{margin:2px 0}
1922
1929
  .v2-ai-decisions .ai-foot{color:var(--mut);margin-top:3px}
1930
+ /* #2521 row 8a: the way in to Make precise (a quiet button, the strip is a note) and its Properties-panel takeover,
1931
+ which reuses the member-end review's chrome (#panel .mer-*). Tokens only; reviewed reads neutral, never green. */
1932
+ .ai-strip .ai-precise{border:1px solid var(--line);background:transparent;color:var(--text);font:inherit;font-weight:600;padding:0 8px;border-radius:4px;cursor:pointer;white-space:nowrap}
1933
+ .ai-strip .ai-precise:hover{background:var(--hover-soft)}
1934
+ .ai-strip .ai-precise:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
1935
+ .ai-strip .ai-precise .ai-precise-n{font-weight:400;color:var(--mut);font-variant-numeric:tabular-nums}
1936
+ @media (max-width:720px){.ai-strip .ai-precise .ai-precise-n{display:none}}
1937
+ #panel .mer-title[tabindex]:focus{outline:none}
1938
+ #panel .mer-title[tabindex]:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
1939
+ #panel .mp-bar{height:4px;margin-top:8px;background:var(--line);border-radius:2px;overflow:hidden}
1940
+ #panel .mp-bar span{display:block;height:100%;background:var(--brand)}
1941
+ #panel .mp-intro{margin:8px 0 0;font-size:11px;line-height:1.45;color:var(--mut)}
1942
+ #panel .mp-banner{margin-top:8px;padding:6px 8px;border:1px solid var(--warn-edge);border-radius:5px;font-size:11.5px;line-height:1.45;color:var(--text)}
1943
+ #panel .mp-ghead{display:flex;align-items:baseline;justify-content:space-between;gap:6px 8px;flex-wrap:wrap}
1944
+ #panel .mp-ghead button{font-size:11px;padding:3px 8px}
1945
+ #panel .mp-gtitle{margin:0;font-size:12px;font-weight:600;line-height:1.4;color:var(--text);text-transform:none;letter-spacing:0}
1946
+ #panel .mp-gcount{font-weight:400;font-size:11px;color:var(--mut);font-variant-numeric:tabular-nums}
1947
+ #panel .mp-cons{margin:2px 0 2px;font-size:11px;line-height:1.4;color:var(--mut)}
1948
+ #panel .mp-arm{display:flex;gap:6px;flex-wrap:wrap}
1949
+ #panel .mp-arm .hint{align-self:center}
1950
+ #panel .mp-yes{background:var(--brand);border-color:var(--brand);color:var(--brand-ink);font-weight:700}
1951
+ #panel .mp-card{padding:7px 5px 7px 8px;border-left:3px solid transparent;border-radius:4px}
1952
+ #panel .mp-card+.mp-card{border-top:1px solid var(--line)}
1953
+ #panel .mp-card.changed{border-left-color:var(--warn);background:var(--hover-soft)}
1954
+ #panel .mp-card .chip{margin:0 0 4px}
1955
+ #panel .mp-q{display:block;width:100%;padding:0;border:0;background:transparent;color:var(--text);font:600 12px/1.4 var(--ui);text-align:left;cursor:pointer;overflow-wrap:anywhere}
1956
+ #panel .mp-q:hover{color:var(--brand)}
1957
+ #panel .mp-q:focus-visible,#panel .mp-why summary:focus-visible,#panel .mp-done:focus-visible{outline:2px solid var(--brand);outline-offset:2px;border-radius:3px}
1958
+ #panel .mp-q-text{font:600 12px/1.4 var(--ui);color:var(--text);overflow-wrap:anywhere}
1959
+ #panel .mp-chose{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:4px;font-size:11.5px;line-height:1.4;color:var(--mut)}
1960
+ #panel .mp-chose>span{min-width:0;overflow-wrap:anywhere}
1961
+ #panel .mp-chose b{color:var(--text);font-weight:600}
1962
+ #panel .mp-chose b.ai-restated{text-decoration:underline dotted var(--mut);text-underline-offset:2px;cursor:help} /* #2998: shown in project units; the tip says what the AI wrote */
1963
+ #panel .mp-confirm{flex:none;font-size:11px;padding:4px 10px}
1964
+ #panel .mp-chose{flex-wrap:wrap}
1965
+ #panel .mp-acts{display:flex;flex:none;flex-wrap:wrap;gap:6px;margin-left:auto}
1966
+ #panel .mp-changeb{font-size:11px;padding:4px 8px}
1967
+ #panel .mp-changeb[aria-expanded=true]{border-color:var(--brand)}
1968
+ #panel .mp-mark{display:grid;gap:5px;margin-top:6px;padding:7px 8px;border:1px solid var(--line);border-radius:6px;background:var(--hover-soft)}
1969
+ #panel .mp-note-l{font-size:11px;color:var(--text);text-transform:none;letter-spacing:0}
1970
+ #panel .mp-note{min-height:44px;resize:vertical}
1971
+ #panel .mp-mark .mp-arm button{font-size:11px;padding:4px 10px}
1972
+ #panel .mp-why-not{margin-top:3px}
1973
+ #panel .mp-why{margin-top:4px;font-size:11px;line-height:1.45;color:var(--mut)}
1974
+ #panel .mp-why summary{display:inline-flex;align-items:center;gap:4px;list-style:none;cursor:pointer;color:var(--text)}
1975
+ #panel .mp-why summary::-webkit-details-marker{display:none}
1976
+ #panel .mp-why summary::before{content:'▸';width:9px;color:var(--mut)}
1977
+ #panel .mp-why[open] summary::before{content:'▾'}
1978
+ #panel .mp-why dl{display:grid;grid-template-columns:auto 1fr;gap:3px 8px;margin:5px 0 0 13px}
1979
+ #panel .mp-why dt{color:var(--mut)}
1980
+ #panel .mp-why dd{margin:0;color:var(--text);overflow-wrap:anywhere}
1981
+ #panel .mp-why ul{margin:0;padding-left:14px}
1982
+ #panel .mp-change{margin-top:6px}
1983
+ #panel .mp-change button{font-size:11px;padding:3px 8px}
1984
+ #panel .mp-change .hint{margin-top:3px}
1985
+ #panel .mp-more{width:100%;margin-top:6px;font-size:11px;padding:4px 7px}
1986
+ #panel .mp-sheet{font-weight:400;color:var(--mut)}
1987
+ #panel .mp-done{margin-top:12px;font-size:12px;line-height:1.5;color:var(--text)}
1988
+ #panel .mp-done:focus:not(:focus-visible){outline:none}
1989
+ #panel .mp-done .hint{margin-top:4px}
1923
1990
  #quickStat.is-unknown{text-decoration:underline dashed;text-underline-offset:3px}
1924
1991
  .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}
1925
1992
  .conf-quick b{color:var(--warn)}
@@ -2826,6 +2893,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
2826
2893
  #m3dLegend .lsearch .lsx:hover{color:#fecaca;background:#7f1d1d}
2827
2894
  #m3dLegend .lrow.qhide,#m3dLegend .cat-hdr.qhide{display:none} /* filtered OUT by search → gone (distinct from .off = hidden-in-3D, which only dims the swatch) */
2828
2895
  #m3dLegend .lsempty{color:var(--mut);font-size:11px;padding:10px 4px;text-align:center}
2896
+ #m3dLegend .lidhit{color:var(--mut);font-size:11px;margin-left:2px;min-width:0;overflow:hidden;text-overflow:ellipsis} /* #2998: the member id a search matched, after a profile row's label */
2829
2897
  /* Show-all reset bar — panel-local entry to showAllGroups(); shown only when something is hidden/isolated. Clones the
2830
2898
  .lsearch full-width box recipe; brand border on hover only (a one-shot action, not a mode → no solid fill). */
2831
2899
  #m3dLegend .lreset{display:none;align-items:center;justify-content:center;gap:6px;height:26px;margin-bottom:6px;background:var(--bg);border:1px solid var(--line);border-radius:6px;color:var(--text);font:12px var(--ui);cursor:pointer;flex:none;user-select:none}
@@ -3656,7 +3724,7 @@ const EditorFocus = (() => {
3656
3724
  Promise.resolve().then(() => runner(job.req, current)).then(
3657
3725
  (outcome) => vacate(job, current() && outcome ? outcome : { superseded: true }),
3658
3726
  // The runner shows its own sentences; this is only the last line of defence, so the caller is never left waiting.
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 }); });
3727
+ (error) => { console.error('[steel] could not show the connection asked for', error); vacate(job, current() ? { ok: false, said: job.req.makePrecise ? 'FloLess could not open Make precise. Press Open Make precise again, or press Make precise on the AI decisions strip.' : 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 }); });
3660
3728
  };
3661
3729
  window.flolessEditorState = { project: PROJECT, ready: false };
3662
3730
  const text = (value) => typeof value === 'string' && value ? value : '';
@@ -3666,7 +3734,18 @@ const EditorFocus = (() => {
3666
3734
  const normalise = (req) => req && text(req.jointId)
3667
3735
  ? { jointId: req.jointId, ...(req.raiseRfi === true ? { raiseRfi: true } : {}), ...(text(req.checkId) ? { checkId: req.checkId } : {}) }
3668
3736
  : req && text(req.memberId) ? { memberId: req.memberId }
3669
- : req && text(req.rfiId) && /^RFI-\d{3,16}$/.test(req.rfiId) ? { rfiId: req.rfiId } : null;
3737
+ : req && text(req.rfiId) && /^RFI-\d{3,16}$/.test(req.rfiId) ? { rfiId: req.rfiId }
3738
+ // #2521 row 9: or Make precise itself, the chat's "Open Make precise" (the panel opens; nothing is confirmed).
3739
+ : req && req.makePrecise === true ? { makePrecise: true } : null;
3740
+ // The failure sentence names a connection; every other request is told what it asked for, worded as the shell words it (#2980).
3741
+ // The button to press again, and the step that explains, are the asker's own too.
3742
+ const failedFor = (req) => {
3743
+ const asked = !req ? '' : req.makePrecise ? 'Make precise' : req.rfiId ? req.rfiId : req.memberId ? 'the member' : '';
3744
+ if (!asked) return failed;
3745
+ const again = req.makePrecise ? 'Open Make precise' : req.rfiId ? req.rfiId + ' in the chat' : 'Show in the model';
3746
+ const said = failed.replace(/the connection/g, asked).replace('press Open in the model again', 'press ' + again + ' again');
3747
+ return req.rfiId ? said.replace('The Model step says why', 'The RFIs step says why') : said;
3748
+ };
3670
3749
  window.flolessEditorFocus = (req) => {
3671
3750
  if (!normalise(req)) return false;
3672
3751
  const id = typeof req.requestId === 'string' && req.requestId ? req.requestId : 'editor-' + (++made);
@@ -3674,7 +3753,7 @@ const EditorFocus = (() => {
3674
3753
  const outcome = new Promise((resolve) => { settle = resolve; });
3675
3754
  const job = { id, req: normalise(req), settle, running: false };
3676
3755
  // The editor will never be ready (no model, or it failed to load): answer at once, never leave it waiting.
3677
- if (failed) { settle({ ok: false, said: failed }); return outcome; }
3756
+ if (failed) { settle({ ok: false, said: failedFor(job.req) }); return outcome; }
3678
3757
  const previous = slot;
3679
3758
  slot = job;
3680
3759
  // A held request is answered now; a running one learns it at its next await, through current().
@@ -3712,7 +3791,7 @@ const EditorFocus = (() => {
3712
3791
  failed = sentence;
3713
3792
  window.flolessEditorState = { project: PROJECT, ready: false, failed: true };
3714
3793
  const job = slot; slot = null;
3715
- if (job) job.settle({ ok: false, said: failed });
3794
+ if (job) job.settle({ ok: false, said: failedFor(job.req) });
3716
3795
  },
3717
3796
  };
3718
3797
  })();
@@ -4444,6 +4523,8 @@ function handleReviewChanged(m){
4444
4523
  read: undefined until a snapshot or save answered (the marks then say they could not read everything), null only
4445
4524
  for an explicit precise answer, {state:'unknown'} for a verdict it cannot read. */
4446
4525
  let lastSavedVerdict;
4526
+ /* #2521 row 8a: which AI decisions a person reviewed in Make precise, as the server last said ({ reviewed: { id: at } }). */
4527
+ let lastAiReviews=null;
4447
4528
  function paintQuickStat(q){
4448
4529
  if(q===undefined)return; // a reply whose body could not be read leaves the last label in place; null = precise
4449
4530
  lastSavedVerdict=q===null?null:q&&q.state==='quick'&&typeof q.short==='string'?q:{state:'unknown'};
@@ -4848,6 +4929,7 @@ async function boot() {
4848
4929
  // live, and observable to anything that runs in between. Validate, then publish.
4849
4930
  const snapshotPayload = await res.json();
4850
4931
  paintQuickStat(snapshotPayload && typeof snapshotPayload === 'object' ? (snapshotPayload.quick ?? null) : undefined);
4932
+ lastAiReviews = snapshotPayload && typeof snapshotPayload === 'object' && snapshotPayload.aiReviews && typeof snapshotPayload.aiReviews === 'object' ? snapshotPayload.aiReviews : null; // #2521 row 8a
4851
4933
  const loaded = snapshotPayload && snapshotPayload.contract;
4852
4934
  // Shape first, then type. A body that is null, an array or a scalar has no `type` to test, so a
4853
4935
  // type-only gate waved it through and the failure surfaced as a raw red `boot().catch` — "Cannot read
@@ -5433,6 +5515,7 @@ let v2IdSeq=0;
5433
5515
  FINDING: unmarked never means drawn, and the strip says so whenever anything is shown. */
5434
5516
  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
5517
  let aiMarksMemo=null,aiStripOpen=false,aiMarks3dSent=null;
5518
+ let aiShownMemo=null,aiReviewsMemo={src:undefined,map:new Map()}; // #2521 row 8a: the marks of what nobody has reviewed
5436
5519
  function aiMarksNow(){
5437
5520
  if(!AiMarks||!C||C.type!=='steel.model/v2')return null;
5438
5521
  // Every edit, undo, redo and installed save reply bumps the generation; a replaced model is a new C. So hover, zoom and
@@ -5440,12 +5523,12 @@ function aiMarksNow(){
5440
5523
  if(aiMarksMemo&&aiMarksMemo.c===C&&aiMarksMemo.gen===modelEditGeneration)return aiMarksMemo.marks;
5441
5524
  const marks=AiMarks.aiDecisionMarksOf(C);aiMarksMemo={c:C,gen:modelEditGeneration,marks};return marks;
5442
5525
  }
5443
- function aiMarksState(){if(!AiMarks)return'none';return AiMarks.aiMarksDisplayState(aiMarksNow()||{state:'none'},lastSavedVerdict);}
5526
+ function aiMarksState(){if(!AiMarks)return'none';return AiMarks.aiMarksDisplayState(aiMarksShown()||{state:'none'},lastSavedVerdict);}
5444
5527
  const aiHasCanvasMarks=m=>!!m&&(m.ends.length>0||m.joints.length>0);
5445
5528
  const aiEndWord=(role,end)=>role==='column'?(end===0?'base':'top'):(end===0?'start':'end');
5446
5529
  /* What the mark means, on the member's OWN tooltip (the marks themselves never take a pointer). */
5447
5530
  function aiTipFor(m){
5448
- if(!showAiMarks||!m)return'';const marks=aiMarksNow(),list=marks&&marks.members.get(m.id);if(!list)return'';
5531
+ if(!showAiMarks||!m)return'';const marks=aiMarksShown(),list=marks&&marks.members.get(m.id);if(!list)return'';
5449
5532
  const ends=list.filter(x=>x.kind==='height').map(x=>aiEndWord(m.role,x.end));
5450
5533
  const parts=[];
5451
5534
  if(ends.length)parts.push('The AI chose this member’s '+ends.join(' and ')+' height'+(ends.length>1?'s':'')+'.');
@@ -5466,7 +5549,7 @@ function aiJointPoint2d(j,byId){
5466
5549
  /* The canvas marks of the plan on screen, sized in 1/zoom like the review marker (updateBadges redraws them on zoom). */
5467
5550
  function aiMarksInner(){
5468
5551
  if(!showAiMarks||!P||!Array.isArray(P.members))return'';
5469
- const marks=aiMarksNow();if(!aiHasCanvasMarks(marks))return'';
5552
+ const marks=aiMarksShown();if(!aiHasCanvasMarks(marks))return'';
5470
5553
  // Positions come from every member this plan draws; visibility only decides whether a mark is shown. An end mark needs
5471
5554
  // its member shown; a ring needs ANY member of the joint shown (it rests on the connection whichever one is hidden).
5472
5555
  const byId=new Map(),shown=new Set();
@@ -5480,22 +5563,35 @@ function aiMarksInner(){
5480
5563
  }
5481
5564
  function aiPlanLabel(viewId){const plan=(C.plans||[]).find(p=>V2Projection.planViewId(p)===viewId);return plan?String(plan.title||plan.sheet||viewId):String(viewId);}
5482
5565
  /* 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){
5566
+ // #2998: a length the AI wrote in the other unit system is shown in the project's (decisionChoiceInUnits); what it
5567
+ // actually wrote goes into `wrote`, for the row's tooltip.
5568
+ function aiChosenWords(chosen,value,wrote){
5569
+ const said=AiMarks&&chosen?AiMarks.decisionChoiceInUnits(chosen,value,displayUnits()):{text:chosen||''};
5570
+ if(said.wrote&&wrote)wrote.push(said.wrote);
5571
+ return said.text;
5572
+ }
5573
+ const aiWroteTip=wrote=>wrote.length?'Shown in this project’s units. The AI wrote '+[...new Set(wrote)].join(', ')+'.':'';
5574
+ // The tip on hover, and the same words for a screen reader, which never sees a data-tip.
5575
+ function aiWroteMark(el,wrote){if(!wrote.length)return;const tip=aiWroteTip(wrote);el.dataset.tip=tip;el.appendChild(Object.assign(document.createElement('span'),{className:'sr-only',textContent:' '+tip}));}
5576
+ function aiChosenText(id,marks,wrote){
5484
5577
  const entry=marks.entries.get(id),rec=aiRecord.rows.get(id);
5485
- const chosen=(entry&&typeof entry.chosen==='string'&&entry.chosen)||(rec&&rec.chosen)||'';
5578
+ const chosen=aiChosenWords((entry&&typeof entry.chosen==='string'&&entry.chosen)||(rec&&rec.chosen)||'',(entry&&entry.value)||(rec&&rec.value),wrote);
5486
5579
  let t=chosen?'the AI chose '+chosen:'the AI decided it';
5487
5580
  if(rec&&rec.why)t+=' (why: '+String(rec.why).replace(/\.\s*$/,'')+(rec.confidence?'; '+rec.confidence+' confidence':'')+')';
5488
5581
  else if(!AI_DECISION_ID.test(id))t+=' (FloLess cannot read this decision’s id, so it cannot say why)';
5489
5582
  else if(aiRecord.absent.has(id))t+=' (this decision is not in the project’s record, so FloLess cannot say why)';
5490
5583
  else if(aiRecordFailed(id))t+=' (FloLess could not read why just now; it tries again when you select the member)';
5491
5584
  else if(aiRecord.inflight.has(id))t+=' (reading why…)';
5585
+ const at=aiReviewedNow().get(id),note=aiChangedNow().get(id); // #2521 row 8a; row 8b: a change says it was one
5586
+ if(at)t+=(note===undefined?', reviewed by you':', changed by you')+(mpDate(at)?' on '+mpDate(at):'')+(note?' ('+note.replace(/\.\s*$/,'')+')':'');
5492
5587
  return t;
5493
5588
  }
5494
- function aiNoteText(item,marks){
5495
- const entry=item.decisionId?marks.entries.get(item.decisionId):null,chosen=entry&&entry.chosen?': '+entry.chosen:'';
5589
+ function aiNoteText(item,marks,wrote){
5590
+ const entry=item.decisionId?marks.entries.get(item.decisionId):null,chosen=entry&&entry.chosen?': '+aiChosenWords(entry.chosen,entry.value,wrote):'';
5496
5591
  if(item.reason==='unreadable')return'An AI decision FloLess could not read.';
5497
5592
  switch(item.channel){
5498
5593
  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.';
5594
+ case'scope':return'The drawing set was too large to read at once, so the AI chose which files to read'+chosen+'. The model covers only those files.';
5499
5595
  case'setup-origin':return'The model origin was chosen by the AI'+chosen+'. Every member’s position rests on it.';
5500
5596
  case'audit-gap':return'The AI settled a question the drawings left open'+chosen+'.';
5501
5597
  case'unmodelled-detail':return'The AI left a detail unmodelled'+chosen+'.';
@@ -5509,9 +5605,10 @@ function renderAiStrip(){
5509
5605
  const el=document.getElementById('aiStrip');if(!el)return;
5510
5606
  const state=C?aiMarksState():'none';
5511
5607
  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()};
5608
+ const marks=aiMarksShown()||{ends:[],joints:[],views:new Map(),model:[],entries:new Map(),members:new Map()};
5513
5609
  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('|');
5610
+ const saved=lastSavedVerdict&&lastSavedVerdict.state==='quick'?lastSavedVerdict:null,reviewedHere=aiReviewedCount();
5611
+ const key=[state,showAiMarks,aiStripOpen,aiMarksMemo&&aiMarksMemo.gen,vid,aiRecord.epoch,reviewedHere,saved&&saved.decisions,!!makePrecise].join('|');
5515
5612
  if(el.dataset.key===key&&!el.hidden)return; // render() calls this on every repaint: rebuild only when something it shows moved
5516
5613
  const hadFocus=el.contains(document.activeElement)?document.activeElement.getAttribute('data-command-id'):null;
5517
5614
  el.dataset.key=key;el.textContent='';el.hidden=false;
@@ -5531,13 +5628,23 @@ function renderAiStrip(){
5531
5628
  const chip=span('chip assumed','AI chose this view’s '+rows.map(r=>r==='scale'?'scale':'level').join(' and '));
5532
5629
  chip.tabIndex=0;chip.setAttribute('role','note');
5533
5630
  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.';
5631
+ const wrote=[],said=viewRows.map(v=>{const e=marks.entries.get(v.decisionId);return 'its '+(v.row==='scale'?'drawing scale':'level')+(e&&e.chosen?' ('+aiChosenWords(e.chosen,e.value,wrote)+')':'');}).join(' and ');
5632
+ 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.'+(wrote.length?' '+aiWroteTip(wrote):'');
5536
5633
  chip.setAttribute('data-tip',tip);chip.setAttribute('aria-label',tip);
5537
5634
  line.appendChild(chip);
5538
5635
  }
5539
5636
  if(marks.model.length)line.appendChild(span('','+ '+marks.model.length+' that bear'+(marks.model.length===1?'s':'')+' on the whole model.'));
5540
5637
  line.appendChild(span('','Unmarked members may still rest on AI decisions FloLess cannot trace.'));
5638
+ // #2521 row 8a: the way in to Make precise, while the saved model is a Quick model. A quiet button: the strip is a note.
5639
+ if(saved&&PROJECT){
5640
+ const go=document.createElement('button');go.type='button';go.className='ai-precise';go.id='aiPreciseB';
5641
+ const n=Number.isSafeInteger(saved.decisions)&&saved.decisions>0?saved.decisions:null;
5642
+ go.textContent='Make precise';if(n)go.appendChild(span('ai-precise-n',' · '+n+' to review'));
5643
+ go.setAttribute('data-command-id','steel.make-precise-open');go.setAttribute('aria-expanded',String(!!makePrecise));go.setAttribute('aria-controls','panel');
5644
+ go.setAttribute('data-tip','Review the AI decisions this model rests on, one group at a time, and confirm each');
5645
+ go.onclick=e=>{e.stopPropagation();openMakePrecise();};
5646
+ line.appendChild(go);
5647
+ }
5541
5648
  const more=document.createElement('button');more.type='button';more.className='ai-more';more.textContent=aiStripOpen?'Less':'Details';
5542
5649
  more.setAttribute('data-command-id','steel.ai-decisions-note');more.setAttribute('aria-expanded',String(aiStripOpen));more.setAttribute('aria-controls','aiStripDetails');
5543
5650
  more.setAttribute('data-tip','What the AI decided that bears on the whole model, and what the marks and the label each describe');
@@ -5545,10 +5652,11 @@ function renderAiStrip(){
5545
5652
  line.appendChild(more);
5546
5653
  if(aiStripOpen){
5547
5654
  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);}
5655
+ if(marks.model.length){const ul=document.createElement('ul');for(const item of marks.model){const li=document.createElement('li'),wrote=[];li.textContent=aiNoteText(item,marks,wrote);aiWroteMark(li,wrote);ul.appendChild(li);}d.appendChild(ul);}
5549
5656
  const n=marks.decisionCount;
5550
5657
  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.'));
5658
+ +'The marks follow your current edits; the Quick model label describes the model as last saved. '
5659
+ +(reviewedHere?'You have reviewed '+reviewedHere+' other'+(reviewedHere===1?'':'s')+' in Make precise; '+(reviewedHere===1?'it is':'they are')+' no longer marked.':'None of these decisions is reviewed.')));
5552
5660
  el.appendChild(d);
5553
5661
  }
5554
5662
  if(hadFocus){const back=el.querySelector('[data-command-id="'+CSS.escape(hadFocus)+'"]');if(back)back.focus();}
@@ -5575,22 +5683,25 @@ function fillAiNote(box,m,canonical,list,marks){
5575
5683
  const chip=document.createElement('span');chip.className='chip assumed';chip.textContent='AI decision';
5576
5684
  const b=document.createElement('b');b.textContent='Rests on AI decisions';head.append(chip,b);box.appendChild(head);
5577
5685
  for(const mark of list){
5578
- const row=document.createElement('div');row.className='ai-row';
5686
+ const row=document.createElement('div'),wrote=[];row.className='ai-row';
5579
5687
  if(mark.kind==='height'){
5580
- const z=(mark.end===0?canonical.from:canonical.to)?.z,now=z&&Number.isFinite(z.known)?fmtDispElev(z.known):'';
5688
+ const z=(mark.end===0?canonical.from:canonical.to)?.z,now=z&&Number.isFinite(z.known)?fmtDispElev(z.known):''; // the full analysis: a reviewed decision is listed, and says so (aiChosenText)
5581
5689
  const word=aiEndWord(m.role,mark.end),n=mark.decisionIds.length;
5582
5690
  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('; ')+'.';
5691
+ +(mark.derived?', derived from '+(n===1?'it':'them')+' by a copy, split or merge':'')+': '+mark.decisionIds.map(id=>aiChosenText(id,marks,wrote)).join('; ')+'.';
5584
5692
  }else if(mark.kind==='connection'){
5585
5693
  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)+'.';
5694
+ row.textContent='Its connection '+String(joint&&joint.name||mark.jointId)+' rests on an AI assumption: '+aiChosenText(mark.decisionId,marks,wrote)+'.';
5587
5695
  }else{
5588
- row.textContent='Drawn on '+aiPlanLabel(mark.viewId)+', whose '+(mark.row==='scale'?'drawing scale':'level')+' the AI decided: '+aiChosenText(mark.decisionId,marks)+'.';
5696
+ row.textContent='Drawn on '+aiPlanLabel(mark.viewId)+', whose '+(mark.row==='scale'?'drawing scale':'level')+' the AI decided: '+aiChosenText(mark.decisionId,marks,wrote)+'.';
5589
5697
  }
5698
+ aiWroteMark(row,wrote);
5590
5699
  box.appendChild(row);
5591
5700
  }
5592
5701
  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);
5702
+ const ids=[...new Set(list.flatMap(x=>x.kind==='height'?x.decisionIds:[x.decisionId]))],rv=aiReviewedNow(),nRev=ids.filter(id=>rv.has(id)).length;
5703
+ foot.textContent=(nRev===ids.length?'Reviewed by you in Make precise.':nRev?'Not all reviewed: Make precise lists the rest.':'Not reviewed.')
5704
+ +' FloLess lists what it can trace; this member may still rest on other AI decisions.';box.appendChild(foot);
5594
5705
  }
5595
5706
  /* The record's words (why, confidence), read by id on demand (plan R8, V2). In-flight requests are shared; an epoch,
5596
5707
  bumped when the record changes or the model is replaced, drops an answer that arrives after it is stale, before it
@@ -5622,15 +5733,373 @@ function aiRecordWant(ids){
5622
5733
  /* The 3D marks follow the 2D ones: the same analysis, the same switch. Pushed only when they change. */
5623
5734
  function syncAiMarks3d(force){
5624
5735
  if(!view3dReady)return; // through the Steel adapter, never the raw viewport (the seam ratchet only shrinks)
5625
- const marks=showAiMarks?aiMarksNow():null;
5736
+ const marks=showAiMarks?aiMarksShown():null;
5626
5737
  if(!force&&aiMarks3dSent&&aiMarks3dSent.marks===marks)return;
5627
5738
  aiMarks3dSent={marks};
5628
5739
  modelEditor.steel.setAiMarks(aiHasCanvasMarks(marks)?AiMarks.canvasMarksOf(marks):null);
5629
5740
  }
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));}
5741
+ function updAiMarksToggle(){const b=document.getElementById('aiMarksToggleB');if(!b)return;b.hidden=!aiHasCanvasMarks(aiMarksShown());b.classList.toggle('on',showAiMarks);b.setAttribute('aria-checked',String(showAiMarks));}
5631
5742
  /* The two callers outside main(): the label paint (paintQuickStat) and the record-changed event. */
5632
5743
  window.aiMarksRepaintStrip=renderAiStrip;
5633
- window.aiMarksRecordChanged=()=>{aiRecordInvalidate();render();};
5744
+ window.aiMarksRecordChanged=()=>{aiRecordInvalidate();aiReviewsRefresh();render();};
5745
+ /* #2521 row 8a: Make precise. The person reviews the AI decisions the saved model rests on, a group at a time, and
5746
+ confirms each. A review is written on the decision's row in the project's record and changes nothing in the model
5747
+ (plan docs/superpowers/specs/2026-10-29-quick-model-row8-PLAN.md, Revision 3.1). The list is the server's, so the
5748
+ panel and the Quick label never disagree; a confirm goes only through the chat UI session from this window, which
5749
+ the AI chat cannot reach. The canvas, 3D and strip mark only what nobody has reviewed; Inspect lists every decision. */
5750
+ let makePrecise=null,mpSessionReady=null;
5751
+ // #2994: each group shows its first MP_FIRST cards (all of them up to MP_FIRST+2), then MP_PAGE more per press, so every
5752
+ // group’s heading and Confirm all are on screen from the start. MP_BATCH: what one confirm request may carry (make-precise-service.ts).
5753
+ const MP_FIRST=5,MP_PAGE=25,MP_TWO_STEP=10,MP_BATCH=500;
5754
+ const mpDate=at=>{const d=new Date(at);return Number.isFinite(d.getTime())?d.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'}):'';};
5755
+ function aiReviewedNow(){
5756
+ if(aiReviewsMemo.src!==lastAiReviews){
5757
+ const map=new Map(),r=lastAiReviews&&lastAiReviews.reviewed;
5758
+ if(r&&typeof r==='object')for(const [id,at] of Object.entries(r))if(AI_DECISION_ID.test(id)&&typeof at==='string')map.set(id,at);
5759
+ aiReviewsMemo={src:lastAiReviews,map};
5760
+ }
5761
+ return aiReviewsMemo.map;
5762
+ }
5763
+ /* #2521 row 8b: the decisions the person marked changed, with their note ('' when none). */
5764
+ let aiChangedMemo={src:undefined,map:new Map()};
5765
+ function aiChangedNow(){
5766
+ if(aiChangedMemo.src!==lastAiReviews){
5767
+ const map=new Map(),c=lastAiReviews&&lastAiReviews.changed;
5768
+ if(c&&typeof c==='object')for(const [id,note] of Object.entries(c))if(AI_DECISION_ID.test(id)&&typeof note==='string')map.set(id,note);
5769
+ aiChangedMemo={src:lastAiReviews,map};
5770
+ }
5771
+ return aiChangedMemo.map;
5772
+ }
5773
+ function aiMarksShown(){
5774
+ const all=aiMarksNow();if(!all||!AiMarks.unreviewedMarksOf)return all;
5775
+ const reviewed=aiReviewedNow();
5776
+ if(aiShownMemo&&aiShownMemo.all===all&&aiShownMemo.reviewed===reviewed)return aiShownMemo.marks;
5777
+ const marks=AiMarks.unreviewedMarksOf(all,reviewed);aiShownMemo={all,reviewed,marks};return marks;
5778
+ }
5779
+ /* How many of the decisions the live model rests on a person has reviewed: the strip says they are no longer marked. */
5780
+ function aiReviewedCount(){const all=aiMarksNow(),rv=aiReviewedNow();return all&&rv.size?all.dependencyIds.filter(id=>rv.has(id)).length:0;}
5781
+ function mpAdopt(d){
5782
+ lastAiReviews=d&&d.aiReviews&&typeof d.aiReviews==='object'?d.aiReviews:null;
5783
+ if(d&&'quick' in d)paintQuickStat(d.quick??null); // the label as it stands now, reviews counted
5784
+ }
5785
+ const mpRead=()=>fetch('/api/projects/'+encodeURIComponent(PROJECT)+'/make-precise',{cache:'no-store'})
5786
+ .then(async r=>{const d=await r.json().catch(()=>null);if(!r.ok||!d||!Array.isArray(d.groups))throw new Error('make-precise read '+r.status);return d;});
5787
+ /* Another window, or this one, recorded a review: read who reviewed what again (and the list, if it is open). */
5788
+ function aiReviewsRefresh(){
5789
+ if(!PROJECT)return;
5790
+ if(makePrecise){if(!makePrecise.busy)mpLoad(true);return;}
5791
+ mpRead().then(d=>{mpAdopt(d);render();}).catch(e=>console.warn('make precise: could not read the reviews again; the marks show them on the next load',String(e&&e.message||e)));
5792
+ }
5793
+ /* Reads of the list can overlap (a reopen during a confirm, then the confirm's own refresh): only the latest one
5794
+ started is applied, so an older answer arriving last never offers again what was just recorded. */
5795
+ let mpLoadSeq=0;
5796
+ const MP_REFRESH_FAILED='FloLess could not refresh the list just now, so it may still show some that are already reviewed. Close and reopen Make precise to see the latest.';
5797
+ async function mpLoad(keepLive){
5798
+ const state=makePrecise;if(!state||!PROJECT)return;
5799
+ const seq=++mpLoadSeq;
5800
+ try{
5801
+ const d=await mpRead();if(makePrecise!==state||seq!==mpLoadSeq)return;
5802
+ mpAdopt(d);state.review=d;state.status='ready';if(!keepLive)state.live='';
5803
+ const ids=new Set(d.groups.flatMap(g=>g.items.map(c=>c.decisionId)));for(const id of [...state.changed])if(!ids.has(id))state.changed.delete(id);
5804
+ }catch(e){
5805
+ if(makePrecise!==state||seq!==mpLoadSeq)return;
5806
+ console.warn('make precise: could not read the AI decisions',String(e&&e.message||e));
5807
+ // What the confirm said stays (it may be that FloLess cannot tell what was recorded); only its promise that the
5808
+ // list shows the latest is taken back.
5809
+ if(state.review){
5810
+ const said=keepLive&&state.live&&!state.live.endsWith(MP_REFRESH_FAILED)?state.live.replace(/ ?The list now shows what is still to review\.$/,''):'';
5811
+ state.live=keepLive&&state.live.endsWith(MP_REFRESH_FAILED)?state.live:(said?said+' ':'')+MP_REFRESH_FAILED;
5812
+ }
5813
+ else state.status='error';
5814
+ }
5815
+ render();
5816
+ }
5817
+ function openMakePrecise(){
5818
+ if(!PROJECT)return;
5819
+ if(makePrecise){document.getElementById('mpTitle')?.focus();return;}
5820
+ if(!memberEndYieldPanel('Make precise',openMakePrecise,'aiPreciseB'))return; // the member-end review gives way first, or asks
5821
+ if(viewPropsId)releaseViewProps();
5822
+ if(gridMode)setGridMode(false);
5823
+ if(dimStyleMode)setDimStyleMode(false);
5824
+ if(csaxisMode){csaxisMode=false;setCsMode();}
5825
+ if(dimMode){dimMode=false;setDimMode();}
5826
+ makePrecise={status:'loading',review:null,live:'',busy:false,changed:new Set(),arm:null,armTimer:0,limits:{},focus:{key:'title'},mark:null};
5827
+ render();mpLoad();
5828
+ }
5829
+ function closeMakePrecise(){
5830
+ if(!makePrecise)return;clearTimeout(makePrecise.armTimer);makePrecise=null;render();
5831
+ (document.getElementById('aiPreciseB')||moreBtn).focus();
5832
+ }
5833
+ /* The chat UI session cookie the confirm route asks for. Minted once; asked again once if it expired. */
5834
+ function mpSession(){
5835
+ if(!mpSessionReady)mpSessionReady=fetch('/api/chat/session',{credentials:'same-origin',cache:'no-store'})
5836
+ .then(r=>{if(!r.ok)throw new Error('chat session '+r.status);}).catch(e=>{mpSessionReady=null;throw e;});
5837
+ return mpSessionReady;
5838
+ }
5839
+ const mpCards=()=>makePrecise&&makePrecise.review?makePrecise.review.groups.flatMap(g=>g.items):[];
5840
+ // How many of a group's cards are on screen: what Show more asked for, else the first MP_FIRST (a group only a couple
5841
+ // longer shows whole, since a button for one or two cards costs more than the cards).
5842
+ const mpShownIn=g=>{const n=makePrecise&&makePrecise.limits[g.id];return Math.min(g.items.length,n||(g.items.length<=MP_FIRST+2?g.items.length:MP_FIRST));};
5843
+ const mpSheet=c=>{const e=Array.isArray(c.evidence)?c.evidence.find(x=>x&&x.sheet):null;return e?String(e.sheet):'';};
5844
+ // The member end a height sits on, in the words Properties uses: a column's base or top, a beam's start or end end.
5845
+ const mpEndName=c=>{
5846
+ const e=c.heightEnds&&c.heightEnds.length===1?c.heightEnds[0]:null,m=e&&byId(e.memberId);if(!e)return'';
5847
+ return m&&m.role==='column'?(e.end===0?'Base':'Top'):(e.end===0?'Start end':'End end');
5848
+ };
5849
+ // What tells cards that ask the same question apart, said beside each (#2994): their sheet when every one is on its own
5850
+ // sheet, else the member end when that differs (a beam's two ends ask alike), else the sheet where it varies and a
5851
+ // number. Worked out over the whole group, so a label never changes when more cards are shown.
5852
+ function mpTwinLabels(items){
5853
+ const out=new Map(),asked=new Map(),distinct=a=>a.every(Boolean)&&new Set(a).size===a.length;
5854
+ for(const c of items){const q=c.question||c.chosen||'';asked.set(q,(asked.get(q)||[]).concat(c));}
5855
+ for(const list of asked.values()){
5856
+ if(list.length<2)continue;
5857
+ const sheets=list.map(mpSheet),ends=list.map(mpEndName);
5858
+ if(distinct(sheets)){list.forEach((c,i)=>out.set(c.decisionId,'Sheet '+sheets[i]));continue;}
5859
+ if(distinct(ends)){list.forEach((c,i)=>out.set(c.decisionId,ends[i]));continue;}
5860
+ const varies=new Set(sheets).size>1,bySheet=new Map();
5861
+ list.forEach((c,i)=>bySheet.set(sheets[i],(bySheet.get(sheets[i])||[]).concat(c)));
5862
+ for(const [sh,same] of bySheet)same.forEach((c,i)=>out.set(c.decisionId,[varies&&sh?'Sheet '+sh:'',same.length>1?(i+1)+' of '+same.length:''].filter(Boolean).join(' · ')));
5863
+ }
5864
+ return out;
5865
+ }
5866
+ async function mpConfirm(items){
5867
+ const state=makePrecise;if(!state||state.busy||!items.length)return;
5868
+ const order=mpCards().filter(c=>c.confirmable).map(c=>c.decisionId),last=order.indexOf(items[items.length-1].decisionId);
5869
+ const after=order.slice(last+1).filter(id=>!items.some(c=>c.decisionId===id));
5870
+ state.busy=true;state.arm=null;clearTimeout(state.armTimer);
5871
+ state.live=items.length===1?'Recording your review…':'Recording '+items.length+' reviews…';panel();
5872
+ const post=batch=>fetch('/api/chat/make-precise/'+encodeURIComponent(PROJECT)+'/confirm',{method:'POST',credentials:'same-origin',
5873
+ headers:{'Content-Type':'application/json'},body:JSON.stringify({items:batch.map(c=>({decisionId:c.decisionId,card:c.card,...(c.outcome==='changed'?{outcome:'changed',...(c.note?{note:c.note}:{})}:{})}))})});
5874
+ // One request, with the chat session it needs (minted again once if it lapsed). No session means the request never
5875
+ // left, so nothing can have been recorded (notSent); a lost answer after it left is another matter (confirmInBatches).
5876
+ const session=async()=>{try{await mpSession();}catch(e){throw Object.assign(new Error(String(e&&e.message||e)),{notSent:true});}};
5877
+ const send=async batch=>{
5878
+ await session();const res=await post(batch);
5879
+ if(res.status!==401)return res;
5880
+ const d=await res.clone().json().catch(()=>null);if(!(d&&d.code==='chat-session-required'))return res;
5881
+ mpSessionReady=null;await session();return post(batch);
5882
+ };
5883
+ // A group larger than one request takes goes a batch at a time (confirmInBatches, tested); what is said is worded only
5884
+ // from what THIS confirm did (makePreciseOutcome, tested).
5885
+ const run=await AiMarks.confirmInBatches(items,MP_BATCH,send,n=>{if(makePrecise===state){state.live='Recording reviews… '+n+' of '+items.length+' done.';panel();}});
5886
+ if(run.error)console.warn('make precise: the review could not be sent',String(run.error&&run.error.message||run.error));
5887
+ const {res,d,settled,byYou,already}=run;
5888
+ if(run.reviewedIds.length){
5889
+ const at=new Date().toISOString(),next={...(lastAiReviews&&lastAiReviews.reviewed||{})},changedNow={...(lastAiReviews&&lastAiReviews.changed||{})};
5890
+ for(const id of run.reviewedIds)if(!next[id]){next[id]=at;const it=items.find(c=>c.decisionId===id);if(it&&it.outcome==='changed')changedNow[id]=it.note||'';}
5891
+ lastAiReviews={reviewed:next,...(Object.keys(changedNow).length?{changed:changedNow}:{})};
5892
+ }
5893
+ if(run.quick!==undefined)paintQuickStat(run.quick);
5894
+ state.busy=false; // this confirm's own panel, on every way out
5895
+ // The panel was closed meanwhile: whatever is open now (a reopened Make precise, or the canvas) is refreshed, so it
5896
+ // never offers what this confirm just recorded.
5897
+ const touched=settled>0||run.unknown;
5898
+ if(makePrecise!==state){if(touched){if(makePrecise)await mpLoad(true);else render();}return;}
5899
+ if(settled)state.mark=null; // what it recorded leaves the list, and its Change area with it
5900
+ // #2521 row 8b: another window recorded a different review of one of these. It is said, never dropped: the list is
5901
+ // refreshed to what is recorded now.
5902
+ const differently=!!(res&&res.status===409&&d&&d.code==='make-precise-reviewed-differently');
5903
+ const rest=items.slice(settled).map(c=>c.decisionId),conflict=!differently&&!!(res&&res.status===409&&d&&d.review&&Array.isArray(d.review.groups));
5904
+ // FloLess's own refusals are worded for a person; anything else (no answer, a session the browser could not open) is worded by the helper.
5905
+ const refusal=d&&typeof d.code==='string'&&/^(make-precise|ai-decisions)/.test(d.code)&&typeof d.error==='string'?d.error:undefined;
5906
+ const left=!rest.length&&d&&d.progress&&Number.isSafeInteger(d.progress.remaining)?d.progress.remaining:null;
5907
+ const failure=!rest.length?null:conflict?'changed':run.unknown?'unknown':'error';
5908
+ state.live=AiMarks.makePreciseOutcome({byYou,already,unsettled:rest.length,left,...(failure?{failure}:{}),...(refusal&&failure==='error'?{refusal}:{}),
5909
+ ...(items.every(c=>c.outcome==='changed')?{changed:true}:{})});
5910
+ if(differently){state.mark=null;state.focus={after:[...rest,...after]};await mpLoad(true);return;}
5911
+ if(conflict){
5912
+ state.review=d.review;for(const id of d.changed||[])state.changed.add(id);
5913
+ state.focus={after:[...(d.changed||[]),...rest,...after]};render();return;
5914
+ }
5915
+ // Focus: after a full confirm the next one to review; otherwise the first one this confirm did not record.
5916
+ state.focus={after:rest.length?[...rest,...after]:after};
5917
+ if(touched){await mpLoad(true);return;} // the server's list, so the panel and the label never disagree
5918
+ panel();
5919
+ }
5920
+ /* Select what a decision bears on, and frame it on this sheet. The panel stays: the selection shows on the canvas. */
5921
+ function mpSelect(ids){
5922
+ const keep=[...new Set(ids)].filter(id=>byId(id));
5923
+ if(!keep.length){makePrecise.live='These members are no longer in the model.';panel();return 0;}
5924
+ if(modelEditor.isReady()&&modelEditor.steel.clearConnSel)modelEditor.steel.clearConnSel();
5925
+ modelSelection.replaceMembers(keep);selDimIds.clear();sel3dDimIds.clear();modelSelection.clearGrids();
5926
+ const set=new Set(keep),here=view3d?[]:P.members.filter(m=>set.has(m.id)&&visible2d(m));
5927
+ makePrecise.live='Selected '+keep.length+' member'+(keep.length===1?'':'s')+(view3d||here.length===keep.length?'.':'; '+(keep.length-here.length)+' '+(keep.length-here.length===1?'is':'are')+' not drawn on this sheet.');
5928
+ render();if(here.length)zoomToMembers(here);
5929
+ return keep.length;
5930
+ }
5931
+ function mpAffects(c){
5932
+ const a=c.affects,parts=[],s=n=>n===1?'':'s';
5933
+ if(a.wholeModel)parts.push('the whole model');
5934
+ if(a.viewId)parts.push('every member drawn on '+aiPlanLabel(a.viewId));
5935
+ if(a.jointIds.length)parts.push(a.jointIds.length+' connection'+s(a.jointIds.length));
5936
+ if(a.memberIds.length&&!a.viewId)parts.push(a.memberIds.length+' member'+s(a.memberIds.length));
5937
+ return parts.length?parts.join(', '):'Nothing FloLess can point to on the model';
5938
+ }
5939
+ /* The Elevation field of the end a height decision is on: a column's bottom or top, a beam's start or end. */
5940
+ function mpHeightField(e){const m=e&&byId(e.memberId);if(!m)return null;return m.role==='column'?(e.end===0?'bos':'tosC'):(e.end===0?'tosA':'tosB');}
5941
+ function mpElevationField(e){const id=mpHeightField(e);return id?document.getElementById(id):null;}
5942
+ /* With several members selected, each Elevation field writes that end of EVERY selected member. So the ends a height
5943
+ sits on can be edited together only when they all land in the same field (same kind of member, same end); otherwise
5944
+ one member is edited at a time, or typing would move an end the decision does not sit on. */
5945
+ /* What the change-height button says, worked out from what its click selects: k of the n ends the height sits on. */
5946
+ function mpHeightWords(k,n){
5947
+ if(k>=n)return{label:`Select ${n} member end${n===1?'':'s'}`,tip:'Select the member ends that carry this height and show them in Properties',
5948
+ toast:'Type the new height in Elevation. Make precise in the AI decisions strip takes you back to the list.'};
5949
+ const these=k===1?'1 of them is':k+' of them are';
5950
+ return{label:`Select ${k} of ${n} member ends`,tip:`This height sits on ${n} member ends that cannot all be changed together: select the ${k===1?'one':k} that can, and show ${k===1?'it':'them'} in Properties`,
5951
+ toast:`This height sits on ${n} member ends that cannot all be changed together, so ${these} selected. Type the new height in Elevation; Make precise in the AI decisions strip takes you back to the list for the rest.`};
5952
+ }
5953
+ function mpHeightEnds(c){
5954
+ const ends=c.heightEnds||[],shown=ends.filter(e=>mpHeightField(e)); // an end on a member this view cannot show has no field
5955
+ if(!shown.length)return ends.slice(0,1);
5956
+ return new Set(shown.map(mpHeightField)).size===1?shown:shown.slice(0,1);
5957
+ }
5958
+ const MP_CONFIDENCE={high:'High',medium:'Medium',low:'Low'};
5959
+ /* #2521 row 8b: where a person changes each kind of AI decision themselves, before marking it changed. A height is typed
5960
+ (its own button); a view's scale and the grid origin cannot change in an existing model (MP_FIXED_SETUP). */
5961
+ const MP_NOTE_MAX=600;
5962
+ const MP_FIXED_SETUP='A view’s scale and the grid origin can’t be changed in an existing model, so this can only be confirmed. If the AI’s choice is wrong, read the drawings into a new project.';
5963
+ function mpWhereToChange(c){
5964
+ switch(c.channel){
5965
+ case'connection':return'Change the connection in the model. Select it with the question above.';
5966
+ case'filter':return'Read the drawings again from Attach revised drawings in the workspace, and save a different Drawing Filter in that read.';
5967
+ default:return'Change it in the model here in the editor, or read the drawings again from Attach revised drawings in the workspace.';
5968
+ }
5969
+ }
5970
+ function renderMakePrecisePanel(p){
5971
+ const state=makePrecise,review=state.review,prog=review&&review.progress;
5972
+ // The rebuild replaces every node: keep focus, the list's scroll and each open "Why?".
5973
+ const active=document.activeElement,keepKey=active&&p.contains(active)?active.getAttribute('data-mp-key'):null;
5974
+ const oldList=p.querySelector('#mpList'),keepScroll=oldList?oldList.scrollTop:0;
5975
+ const openWhy=new Set([...p.querySelectorAll('details.mp-why[open]')].map(x=>x.dataset.mpId));
5976
+ p.setAttribute('aria-busy',String(!!state.busy));p.setAttribute('aria-labelledby','mpTitle');
5977
+ const dis=state.busy?' disabled':'',s=n=>n===1?'':'s';
5978
+ const sub=!prog?'Reading the AI decisions…':prog.remaining?prog.remaining+' of '+prog.total+' AI decision'+s(prog.total)+' to review':'Nothing left to review';
5979
+ let html=`<div class=mer-head><div><div class=mer-title id=mpTitle tabindex=-1 data-mp-key=title>Make precise</div><div class=hint>${esc(sub)}</div></div><button id=mpDone data-mp-key=done data-command-id="steel.make-precise-close" class=ghost data-tip="Close Make precise. What you confirmed is saved."${dis}>Done</button></div>`;
5980
+ if(prog&&prog.total)html+=`<div class=mp-bar aria-hidden=true><span style="width:${Math.round(100*prog.reviewed/prog.total)}%"></span></div>`;
5981
+ if(!prog||prog.remaining)html+='<p class=mp-intro>Confirming a decision records that you looked at it. It doesn’t check the value or change the model. The model stays a Quick model until you’ve reviewed every AI decision.</p>';
5982
+ if(state.status==='loading')html+='<div class=mer-empty role=status>Reading the AI decisions…</div>';
5983
+ else if(state.status==='error')html+=`<div class=mer-empty>FloLess could not read the AI decisions just now. Your model is unchanged.<div class=mer-toolbar><button id=mpRetry data-mp-key=retry data-command-id="steel.make-precise-retry" class=ghost>Try again</button></div></div>`;
5984
+ else if(!prog.remaining){
5985
+ html+=`<div class=mp-done id=mpDoneMsg tabindex=-1 data-mp-key=done-msg><b>${prog.total?(prog.total===1?'The AI decision is reviewed.':'All '+prog.total+' AI decisions are reviewed.'):'This model rests on no AI decision.'}</b> This model is no longer labelled Quick model.<div class=hint>Reviewing records your look at each decision. It does not verify the model.</div></div>`;
5986
+ }else{
5987
+ if(review.record==='unreadable')html+='<div class=mp-banner role=note>The review record can’t be read, so nothing can be marked reviewed yet. Your model is unchanged.</div>';
5988
+ else if(review.record==='absent')html+='<div class=mp-banner role=note>FloLess has no record of how the AI made these decisions, so they can’t be confirmed here, and the model stays a Quick model while it rests on them. Reading the drawings again records them.</div>';
5989
+ html+='<div class=mer-list id=mpList>';
5990
+ review.groups.forEach((g,gi)=>{
5991
+ const items=g.items.slice(0,mpShownIn(g)),hidden=g.items.length-items.length;
5992
+ const can=g.items.filter(c=>c.confirmable),gk=esc(g.id),gl=esc(g.title);
5993
+ const unseen=can.filter(c=>!items.includes(c)).length; // Confirm all records these too, so the armed step says so
5994
+ const twin=mpTwinLabels(g.items);
5995
+ let act='';
5996
+ if(can.length>1){
5997
+ act=state.arm===g.id
5998
+ ?`<div class=mp-arm role=group aria-label="Confirm ${can.length} decisions"><button data-mp-all-yes="${gk}" data-mp-key="yes:${gk}" data-command-id="steel.make-precise-confirm-all#${esc(g.id)}" data-command-instance-label="${gl}" class=mp-yes aria-label="Yes, record all ${can.length} in ${gl} as reviewed${unseen?', including '+unseen+' not shown yet':''}"${dis}>Yes, record ${can.length} as reviewed</button><button data-mp-all-no="${gk}" data-mp-key="no:${gk}" data-command-id="steel.make-precise-confirm-all-cancel" class=ghost${dis}>Cancel</button>${unseen?`<span class=hint>Includes ${unseen} not shown yet.</span>`:''}</div>`
5999
+ :`<button data-mp-all="${gk}" data-mp-key="all:${gk}" data-command-id="steel.make-precise-confirm-all#${esc(g.id)}" data-command-instance-label="${gl}" class=ghost aria-label="Confirm all ${can.length} in ${gl}" data-tip="Record every decision in this group as reviewed by you"${dis}>Confirm all ${can.length}</button>`;
6000
+ }
6001
+ html+=`<section class="mer-group mp-group" aria-labelledby="mpG${gi}"><div class=mp-ghead><h3 class=mp-gtitle id="mpG${gi}">${gl} <span class=mp-gcount>· ${g.items.length} to review</span></h3>${act}</div>`;
6002
+ if(g.consequence)html+=`<p class=mp-cons>${esc(g.consequence)}</p>`;
6003
+ for(const c of items){
6004
+ const which=twin.get(c.decisionId)||'';
6005
+ const id=esc(c.decisionId),changed=state.changed.has(c.decisionId),q0=c.question||c.chosen||'An AI decision';
6006
+ // The accessible names keep what tells it apart even when the question is cut short.
6007
+ const cut=q0.length>60?q0.slice(0,57)+'…':q0,short=esc(which?cut+' ('+which+')':cut),q=which?q0+' ('+which+')':q0;
6008
+ const qHtml=which?`${esc(q0)} <span class=mp-sheet>· ${esc(which)}</span>`:esc(q0);
6009
+ html+=`<div class="mp-card${changed?' changed':''}" data-mp-id="${id}">`;
6010
+ if(changed)html+='<span class="chip assumed">Updated</span>'; // its words changed since it was shown (row 8b: not "Changed", the person's verb)
6011
+ html+=c.affects.memberIds.length
6012
+ ?`<button type=button class=mp-q data-mp-locate="${id}" data-mp-key="q:${id}" data-command-id="steel.make-precise-locate#${esc(c.decisionId)}" data-command-instance-label="${short}" data-tip="Select the ${c.affects.memberIds.length} member${s(c.affects.memberIds.length)} this decision bears on">${qHtml}</button>`
6013
+ :`<div class=mp-q-text>${qHtml}</div>`;
6014
+ const marking=!!(state.mark&&state.mark.id===c.decisionId);
6015
+ const changeB=c.canMarkChanged?`<button type=button class="ghost mp-changeb" data-mp-mark="${id}" data-mp-key="m:${id}" data-command-id="steel.make-precise-mark-changed#${esc(c.decisionId)}" data-command-instance-label="${short}" aria-expanded="${marking}" aria-controls="mpM${id}" aria-label="Changed it myself: ${esc(q)}" data-tip="Change it in the model yourself, then record here that you did"${dis}>Changed it myself</button>`:'';
6016
+ const chWrote=[],chText=aiChosenWords(c.chosen,c.value,chWrote);
6017
+ html+=`<div class=mp-chose><span>The AI chose: <b${chWrote.length?` class=ai-restated data-tip="${esc(aiWroteTip(chWrote))}"`:''}>${esc(chText||'(not recorded)')}</b>${chWrote.length?`<span class=sr-only> ${esc(aiWroteTip(chWrote))}</span>`:''}</span>${c.confirmable?`<span class=mp-acts><button class=mp-confirm data-mp-confirm="${id}" data-mp-key="c:${id}" data-command-id="steel.make-precise-confirm#${esc(c.decisionId)}" data-command-instance-label="${short}" aria-label="Confirm: ${esc(q)}"${dis}>Confirm</button>${changeB}</span>`:''}</div>`;
6018
+ if(!c.confirmable&&c.notConfirmable)html+=`<div class="hint mp-why-not">${esc(c.notConfirmable)}</div>`;
6019
+ if(c.confirmable&&!c.canMarkChanged&&!c.canEditHeight&&c.channel==='setup')html+=`<div class="hint mp-why-not">${esc(MP_FIXED_SETUP)}</div>`;
6020
+ if(marking)html+=`<div class=mp-mark id="mpM${id}" role=group aria-label="Record your change: ${esc(q)}"><div class=hint id="mpMl${id}">${esc(mpWhereToChange(c))}</div>`
6021
+ +`<label class=mp-note-l for="mpN${id}">What you changed <span class=hint>(optional)</span></label><textarea id="mpN${id}" class=mp-note data-mp-note="${id}" data-mp-key="n:${id}" data-command-id="steel.make-precise-mark-changed-note#${esc(c.decisionId)}" data-command-instance-label="${short}" rows=2 maxlength=${MP_NOTE_MAX} aria-describedby="mpMl${id} mpMd${id}"${dis}>${esc(state.mark.note||'')}</textarea>`
6022
+ +`<div class=hint id="mpMd${id}">This records that you changed it. FloLess doesn’t check the model.</div>`
6023
+ +`<div class=mp-arm><button class=ghost data-mp-mark-yes="${id}" data-mp-key="my:${id}" data-command-id="steel.make-precise-mark-changed-record#${esc(c.decisionId)}" data-command-instance-label="${short}" aria-label="Record my change: ${esc(q)}"${dis}>Record my change</button><button class=ghost data-mp-mark-no="${id}" data-mp-key="mn:${id}" data-command-id="steel.make-precise-mark-changed-cancel"${dis}>Cancel</button></div></div>`;
6024
+ let dl='';
6025
+ if(c.why)dl+=`<dt>Reason</dt><dd>${esc(c.why)}</dd>`;
6026
+ if(c.confidence)dl+=`<dt>Confidence</dt><dd>${esc(MP_CONFIDENCE[c.confidence]||c.confidence)}</dd>`;
6027
+ if(Array.isArray(c.evidence)&&c.evidence.length)dl+=`<dt>Evidence</dt><dd><ul>${c.evidence.map(e=>{const where=[e.sheet,e.location].filter(Boolean).join(', ');return`<li>${esc(where?where+': ':'')}${esc(e.reading||'')}</li>`;}).join('')}</ul></dd>`;
6028
+ dl+=`<dt>Affects</dt><dd>${esc(mpAffects(c))}</dd>`;
6029
+ html+=`<details class=mp-why data-mp-id="${id}"${openWhy.has(c.decisionId)?' open':''}><summary data-mp-key="w:${id}" data-command-id="steel.make-precise-why#${esc(c.decisionId)}" data-command-instance-label="${short}">Why?</summary><dl>${dl}</dl></details>`;
6030
+ if(c.canEditHeight){
6031
+ const words=mpHeightWords(mpHeightEnds(c).length,c.heightEnds.length);
6032
+ html+=`<div class=mp-change><button type=button class=ghost data-mp-height="${id}" data-mp-key="h:${id}" data-command-id="steel.make-precise-change-height#${esc(c.decisionId)}" data-command-instance-label="${short}" data-tip="${esc(words.tip)}"${dis}>${esc(words.label)}</button><div class=hint>To change it, type the new height in Elevation. This decision stays until no member end uses it (${c.heightEnds.length} now).</div></div>`;
6033
+ }
6034
+ html+='</div>';
6035
+ }
6036
+ if(hidden){
6037
+ const next=Math.min(MP_PAGE,hidden);
6038
+ html+=`<button type=button data-mp-more="${gk}" data-mp-key="more:${gk}" data-command-id="steel.make-precise-more#${esc(g.id)}" data-command-instance-label="${gl}" class="ghost mp-more" aria-label="Show ${next} more of ${g.items.length} in ${gl}, ${hidden} not shown yet"${dis}>Show ${next} more of ${g.items.length}</button>`;
6039
+ }
6040
+ html+='</section>';
6041
+ });
6042
+ html+='</div>';
6043
+ }
6044
+ html+=`<div class=mer-live id=mpLive role=status aria-live=polite>${esc(state.live||'')}</div>`;
6045
+ p.innerHTML=html;
6046
+ const card=id=>mpCards().find(c=>c.decisionId===id),group=id=>review&&review.groups.find(g=>g.id===id);
6047
+ p.querySelector('#mpDone').onclick=()=>closeMakePrecise();
6048
+ p.querySelector('#mpRetry')?.addEventListener('click',()=>{state.status='loading';state.live='';panel();mpLoad();});
6049
+ for(const b of p.querySelectorAll('[data-mp-more]'))b.onclick=()=>{
6050
+ const g=group(b.dataset.mpMore);if(!g)return;
6051
+ const from=mpShownIn(g),first=g.items[from];state.limits[g.id]=from+MP_PAGE;
6052
+ const left=g.items.length-mpShownIn(g);
6053
+ state.live=`${mpShownIn(g)-from} more shown in ${g.title}.${left?' '+left+' not shown yet.':''}`;
6054
+ if(first)state.focus={key:'q:'+first.decisionId,orCard:first.decisionId};panel();
6055
+ };
6056
+ for(const b of p.querySelectorAll('[data-mp-confirm]'))b.onclick=()=>{const c=card(b.dataset.mpConfirm);if(c)mpConfirm([c]);};
6057
+ // #2521 row 8b: Change opens the area under its card (one at a time); the note is kept as typed, without a redraw.
6058
+ for(const b of p.querySelectorAll('[data-mp-mark]'))b.onclick=()=>{
6059
+ const id=b.dataset.mpMark,open=state.mark&&state.mark.id===id;
6060
+ state.mark=open?null:{id,note:''};state.focus={key:open?'m:'+id:'n:'+id};panel();
6061
+ };
6062
+ for(const t of p.querySelectorAll('[data-mp-note]')){
6063
+ t.oninput=()=>{if(state.mark&&state.mark.id===t.dataset.mpNote)state.mark.note=t.value;};
6064
+ t.onkeydown=e=>{if(e.key==='Escape'){e.preventDefault();e.stopPropagation();state.mark=null;state.focus={key:'m:'+t.dataset.mpNote};panel();}};
6065
+ }
6066
+ for(const b of p.querySelectorAll('[data-mp-mark-no]'))b.onclick=()=>{state.mark=null;state.focus={key:'m:'+b.dataset.mpMarkNo};panel();};
6067
+ for(const b of p.querySelectorAll('[data-mp-mark-yes]'))b.onclick=()=>{
6068
+ const c=card(b.dataset.mpMarkYes);if(!c||!state.mark||state.mark.id!==c.decisionId)return;
6069
+ const note=String(state.mark.note||'').trim();
6070
+ mpConfirm([{...c,outcome:'changed',...(note?{note}:{})}]);
6071
+ };
6072
+ for(const b of p.querySelectorAll('[data-mp-locate]'))b.onclick=()=>{const c=card(b.dataset.mpLocate);if(c)mpSelect(c.affects.memberIds);};
6073
+ for(const b of p.querySelectorAll('[data-mp-height]'))b.onclick=()=>{
6074
+ const c=card(b.dataset.mpHeight);if(!c)return;
6075
+ // Elevation is in Properties, which this panel covers: close it, select the ends, and say how to come back.
6076
+ const ends=mpHeightEnds(c);
6077
+ if(!mpSelect([...new Set(ends.map(e=>e.memberId))]))return;
6078
+ clearTimeout(state.armTimer);makePrecise=null;render();
6079
+ toast(mpHeightWords(ends.length,c.heightEnds.length).toast);
6080
+ queueMicrotask(()=>mpElevationField(ends[0])?.focus());
6081
+ };
6082
+ for(const b of p.querySelectorAll('[data-mp-all]'))b.onclick=()=>{
6083
+ const g=group(b.dataset.mpAll);if(!g)return;const can=g.items.filter(c=>c.confirmable);
6084
+ // A small group whose cards are all on screen confirms at once. A large one, or one with cards not shown yet (#2994:
6085
+ // they would be recorded unseen), asks once, in place, saying how many are not shown; it goes back by itself if left.
6086
+ const shown=g.items.slice(0,mpShownIn(g));
6087
+ if(can.length<=MP_TWO_STEP&&can.every(c=>shown.includes(c))){mpConfirm(can);return;}
6088
+ state.arm=g.id;clearTimeout(state.armTimer);
6089
+ state.armTimer=setTimeout(()=>{if(makePrecise===state&&state.arm===g.id){state.arm=null;state.focus=p.contains(document.activeElement)&&document.activeElement.closest('.mp-arm')?{key:'all:'+g.id}:null;panel();}},8000);
6090
+ state.focus={key:'yes:'+g.id};panel();
6091
+ };
6092
+ for(const b of p.querySelectorAll('[data-mp-all-yes]'))b.onclick=()=>{const g=group(b.dataset.mpAllYes);if(g)mpConfirm(g.items.filter(c=>c.confirmable));};
6093
+ for(const b of p.querySelectorAll('[data-mp-all-no]'))b.onclick=()=>{clearTimeout(state.armTimer);state.arm=null;state.focus={key:'all:'+b.dataset.mpAllNo};panel();};
6094
+ const list=p.querySelector('#mpList');if(list)list.scrollTop=keepScroll;
6095
+ const f=state.focus;state.focus=null;
6096
+ const byKey=k=>p.querySelector('[data-mp-key="'+CSS.escape(k)+'"]');
6097
+ let el=null;
6098
+ if(f&&f.after){for(const id of f.after){el=byKey('c:'+id);if(el)break;}if(!el)el=p.querySelector('[data-mp-confirm]')||p.querySelector('#mpDoneMsg')||byKey('title');}
6099
+ else if(f&&f.key)el=byKey(f.key)||(f.orCard?p.querySelector('[data-mp-id="'+CSS.escape(f.orCard)+'"] summary'):null);
6100
+ else if(keepKey)el=byKey(keepKey);
6101
+ if(el)el.focus({preventScroll:!(f&&(f.after||f.orCard))});
6102
+ }
5634
6103
  const newModelId=()=>`m-v2-${Date.now().toString(36)}-${(v2IdSeq++).toString(36)}`;
5635
6104
  V2_SESSION=V2Commands.createV2CommandSession(C,{
5636
6105
  validate:doc=>V2Validation.validateClientSteelModelV2(doc,V2_SCHEMA),
@@ -11143,7 +11612,7 @@ function projectedMemberLookup(presence=V2Projection.createMemberPresenceIndex(C
11143
11612
  };}
11144
11613
 
11145
11614
  function syncV2SelectionNotice(p){
11146
- if(!p||!selIds.size||viewPropsId)return; // a view in the panel keeps the selection, not its notices
11615
+ if(!p||!selIds.size||viewPropsId||makePrecise)return; // a view in the panel, or Make precise (#2521 row 8a), keeps the selection, not its notices
11147
11616
  p.querySelectorAll('.v2-selection-notice,.v2-elevation-warning,.v2-elevation-proposal,.v2-elevation-answered,.v2-ai-decisions').forEach(el=>el.remove());
11148
11617
  const presence=V2Projection.createMemberPresenceIndex(C);
11149
11618
  const ids=[...selIds].filter(id=>presence.members.has(id));
@@ -11412,7 +11881,7 @@ function refPanelPreempted(){
11412
11881
  }
11413
11882
  // Review list view-model: type -> member -> ends, narrowed by a filter. PURE (no DOM, no globals) so a test can run
11414
11883
  // the shipped function. `typeOf(finding)` -> {k,label}; `textOf(finding)` is the reason text the filter also matches;
11415
- // `typeOrder` is the Objects tree's type order. The filter matches a member's mark, its type and any end's reason
11884
+ // `typeOrder` is the Objects tree's type order. The filter matches a member's ID, its type and any end's reason
11416
11885
  // text, every space-separated word having to hit. `endOrder` is the Previous/Next walk (every shown end, in the order
11417
11886
  // the list draws them); `order` is the member order Shift+click ranges over.
11418
11887
  function memberEndBuildView(findings,opts){
@@ -11527,7 +11996,7 @@ function renderMemberEndPanel(p){
11527
11996
  const toolbar=[];if(shownReady.length>shownTicked)toolbar.push(`<button id=merAll data-command-id="steel.member-end-select-all" data-tip="Tick every end in the groups shown below. Collapsed groups are left alone." class=ghost${disabled}>Select all</button>`);if(selected)toolbar.push(`<button id=merClear data-command-id="steel.member-end-select-clear" class=ghost${disabled}>Clear</button>`);
11528
11997
  const counts=selected+' end'+(selected===1?'':'s')+' ticked'+(hiddenTicked>0?' ('+hiddenTicked+' hidden by filter)':'')+(selectedMembers>1?' · '+selectedMembers+' members selected':'');
11529
11998
  html+=`<div class=mer-toolbar>${toolbar.join('')}<span class=hint>${counts}</span></div>`;
11530
- html+=`<div class="mer-search${query?' has':''}"><span class=lsico aria-hidden=true><svg viewBox="0 0 16 16" width=12 height=12 fill=none stroke=currentColor stroke-width=1.6 stroke-linecap=round><circle cx=7 cy=7 r=4.5></circle><line x1=10.6 y1=10.6 x2=14 y2=14></line></svg></span><input id=merFilter type=text role=searchbox autocomplete=off placeholder="Filter members…" aria-label="Filter members by mark, type or reason" data-command-id="steel.member-end-filter" value="${esc(query)}"><button type=button class=lsx id=merFilterClear aria-label="Clear filter" data-command-id="steel.member-end-filter-clear" data-tip="Clear">×</button></div>`;
11999
+ html+=`<div class="mer-search${query?' has':''}"><span class=lsico aria-hidden=true><svg viewBox="0 0 16 16" width=12 height=12 fill=none stroke=currentColor stroke-width=1.6 stroke-linecap=round><circle cx=7 cy=7 r=4.5></circle><line x1=10.6 y1=10.6 x2=14 y2=14></line></svg></span><input id=merFilter type=text role=searchbox autocomplete=off placeholder="Filter members…" aria-label="Filter members by ID, type or reason" data-command-id="steel.member-end-filter" value="${esc(query)}"><button type=button class=lsx id=merFilterClear aria-label="Clear filter" data-command-id="steel.member-end-filter-clear" data-tip="Clear">×</button></div>`;
11531
12000
  if(query)html+=`<div class=hint id=merFilterCount role=status>${view.shownMembers} of ${view.totalMembers} member${view.totalMembers===1?'':'s'}</div>`;
11532
12001
  html+='<div class=mer-list id=merList>';
11533
12002
  if(query&&!view.groups.length)html+=`<div class=mer-empty role=status>No members match “${esc(query)}”. <button type=button id=merFilterReset class=mer-link data-command-id="steel.member-end-filter-reset">Clear</button></div>`;
@@ -11663,31 +12132,36 @@ function nativeElevationContextHtml(){
11663
12132
  * editing command handed one would resolve nothing (see `selCanonicalArr`). The panel says where to edit
11664
12133
  * instead.
11665
12134
  */
12135
+ /** #2948: a member's drawing marks as panel HTML, or a muted "No mark" (real text, so it is read out) when it has none. */
12136
+ function markHtml(id){const k=memberMarks(id);return k.length?`<span style="overflow-wrap:anywhere">${esc(k.join(', '))}</span>`:'<span style="color:var(--mut)">No mark</span>';}
11666
12137
  function refusedSheetPropsHtml(rows){
11667
12138
  const kv=(l,val)=>`<div style="display:flex;justify-content:space-between;gap:8px;font-size:12px;margin:3px 0"><span style="color:var(--mut)">${esc(l)}</span><span style="font-variant-numeric:tabular-nums">${val}</span></div>`;
11668
12139
  const sec=t=>`<div class=divrow><hr><span class=sect style="margin:0">${esc(t)}</span><hr></div>`;
11669
- // NOT pre-escaped: `kv` escapes its own label, so escaping here rendered a legal mark like `A&B` as
12140
+ // NOT pre-escaped: `kv` escapes its own label, so escaping here rendered a legal id like `A&B` as
11670
12141
  // `A&amp;B` — the panel misquoting the user's own id, which is the small untruth this whole issue is about.
11671
- const mark=m=>(m.id==null?'—':String(m.id));
12142
+ const idText=m=>(m.id==null?'—':String(m.id));
11672
12143
  // A multi-selection gets one identifying line each rather than N full property lists — a box-select can
11673
12144
  // carry hundreds, and a panel that long is not a readout. CAP keeps it a panel; the count says what was cut.
11674
12145
  if(rows.length!==1){
11675
12146
  const CAP=12,shown=rows.slice(0,CAP);
11676
12147
  return sec('Selected members')
11677
- +shown.map(m=>kv(mark(m),esc((m.profile||'—')+' · '+memberTypeLabel(memberTypeOf(m))))).join('')
12148
+ +shown.map(m=>kv(idText(m),esc((m.profile||'—')+' · '+memberTypeLabel(memberTypeOf(m))))).join('')
11678
12149
  +(rows.length>CAP?'<div class=hint style="margin-top:6px">…and '+(rows.length-CAP)+' more.</div>':'')
11679
12150
  +'<div class=hint style="margin-top:6px">Select a single member to see its full properties.</div>';}
11680
12151
  const m=ensureMeta(rows[0]);
11681
- // The mark is a DATA row, not the section header. `.sect` uppercases, and a mark is the member's stored
11682
- // id — rendering `m-beam-1` as `M-BEAM-1` would be the panel restating the user's own data as something
11683
- // it is not. Section headers are labels and may be uppercased; ids may not.
12152
+ // The id is a DATA row, not the section header. `.sect` uppercases, and rendering `m-beam-1` as `M-BEAM-1`
12153
+ // would be the panel restating the user's own data as something it is not. Section headers are labels and
12154
+ // may be uppercased; ids and marks may not.
12155
+ // #2948: the id is the model's name for the member, never its Mark. The Mark row is what the drawings gave it,
12156
+ // or "No mark" (muted, as real text) when they gave none: this label is what led the AI to cite ids as marks.
11684
12157
  let out=sec('Properties');
11685
- out+=kv('Mark',esc(m.id==null?'—':String(m.id)));
12158
+ out+=kv('ID',esc(idText(m)));
12159
+ out+=kv('Mark',markHtml(m.id));
11686
12160
  out+=kv('Profile',esc(m.profile||'—'));
11687
12161
  out+=kv('Material',m.material?esc(m.material):esc(profileDefaultMaterial(m.profile))+' <span style="color:var(--mut);font-size:11px">· profile default</span>');
11688
12162
  const withheld=[];
11689
12163
  for(const def of PROP_DEFS){
11690
- if(def.key==='id'||def.key==='profile')continue; // the mark heads the block; the profile leads it
12164
+ if(def.key==='id'||def.key==='mark'||def.key==='profile')continue; // the ID and Mark head the block; the profile leads it
11691
12165
  // A row that really is coordinate-derived is NAMED as withheld, never quietly dropped: a property
11692
12166
  // missing without explanation reads as "this member has none", which is the class of silence #935 and
11693
12167
  // #942 both exist to end. `canonicalGet` first, though — see `needsPlan` in PROP_DEFS: a stored
@@ -11786,8 +12260,10 @@ function panel(){
11786
12260
  if(!selDimIds.size||!dimsVisible)dimSplitMode=false;document.body.classList.toggle('dimsplit',dimSplitMode); // split mode is meaningless without a (visible) dim selected — also disarms when dims are hidden
11787
12261
  if(viewPropsId&&viewPropsClaim()!==viewPropsClaimSig)releaseViewProps(); // a saved view holds the panel only until something selects or arms a tool
11788
12262
  if(viewPropsId&&renderViewPropsPanel(p))return;
12263
+ if(makePrecise&&(memberEndScan||memberEndReview||gridMode||dimStyleMode||csaxisMode||dimMode)){clearTimeout(makePrecise.armTimer);makePrecise=null;} // #2521 row 8a: another takeover armed has the panel; Make precise reopens from the strip
11789
12264
  if(memberEndScan){renderMemberEndScanPanel(p);return;}
11790
12265
  if(memberEndReview){renderMemberEndPanel(p);return;}
12266
+ if(makePrecise){renderMakePrecisePanel(p);return;}
11791
12267
  if(gridMode){renderGridPanel(p);return;}
11792
12268
  if(provisionalSelId){
11793
12269
  const member=selectedProvisionalTrace(provisionalMembersForActiveView(),provisionalSelId);
@@ -12631,7 +13107,8 @@ function panel(){
12631
13107
  // This note lives OUT here on purpose. It was first written as an HTML comment inside the template
12632
13108
  // below, where a backtick and a ${...} in the prose are not prose at all: they closed the literal and
12633
13109
  // the rest parsed as code. An HTML comment inside a template literal is still template text.
12634
- p.innerHTML=`<h3>Member ${esc(m.id)}</h3>
13110
+ p.innerHTML=`<h3>Member <span style="text-transform:none">${esc(m.id)}</span></h3>
13111
+ <div class="row hint" id=memberMark>${memberMarks(m.id).length?'Mark <b style="overflow-wrap:anywhere">'+esc(memberMarks(m.id).join(', '))+'</b>':'No mark'}</div>
12635
13112
  ${typeFilterHTML(arr)}
12636
13113
  ${memberTypeField('mTypeS',[m])}
12637
13114
  <div class="f"><div class=elab>Profile</div><div style="display:flex;gap:6px"><input data-command-id="steel.member-profile" aria-label="Profile" id=pf class=combo data-src=profiles value="${esc(m.profile)}" style="flex:1" autocomplete=off><button data-command-id="steel.browse-profile-catalog" id=profileBrowseS class=ghost aria-label="Search the profile catalog" data-tip="Search the profile catalog — 4,516 profiles, by designation or alias"><svg viewBox="0 0 16 16" aria-hidden=true width=13 height=13 fill=none stroke=currentColor stroke-width=1.4 stroke-linecap=round><circle cx="6.9" cy="6.9" r="4.3"/><path d="M10.1 10.1 13.7 13.7"/></svg></button><button data-command-id="steel.pick-profile" id=pickProf class="ghost${(picking&&pickKind==='profile')?' on':''}" aria-pressed="${(picking&&pickKind==='profile')?'true':'false'}" aria-label="Pick profile from a drawing label" data-tip="Pick profile from drawing labels by click, Enter, or Space">⌖</button></div>${(picking&&pickKind==='profile')?'<div class="hint" data-profile-pick-status role=status aria-live=polite style="margin-top:4px;font-style:italic;color:var(--brand)">'+esc(profilePickGuidance())+'</div>':''}</div>
@@ -13303,7 +13780,29 @@ function _len3dFt(m,ppf,dTos){
13303
13780
  * 2. The array length, checked alongside identity on every lookup.
13304
13781
  */
13305
13782
  let _v2MemberIndex=null,_v2MemberIndexFor=null,_v2MemberIndexLen=-1;
13306
- function v2InvalidateMemberIndex(){_v2MemberIndex=null;_v2MemberIndexFor=null;_v2MemberIndexLen=-1;}
13783
+ function v2InvalidateMemberIndex(){_v2MemberIndex=null;_v2MemberIndexFor=null;_v2MemberIndexLen=-1;_memberMarksIndex=null;}
13784
+ /*
13785
+ * #2948: the marks the drawings gave a member, which is NOT its id. A member's id (`c-A/3`, `m-beam-1`) is the
13786
+ * model's own name for it; a mark (`B202-49`) is what a drawing printed beside it, and many members have none.
13787
+ * The same rule as the server's `marksByMember` (server/steel-schedule-agreement.ts), which is what the AI chat
13788
+ * cites by: only an ACTIVE observation binding counts (a superseded one is what an earlier read believed), and
13789
+ * the mark is the observation's trimmed `evidence.observed.mark.value`. Exact repeats are dropped, order is the
13790
+ * plans' own. `steel-member-mark-ui.test.ts` holds the two to the same answer.
13791
+ * Indexed once per model state: rebuilt when the plans array is replaced, and on every command commit.
13792
+ */
13793
+ let _memberMarksIndex=null,_memberMarksFor=null;
13794
+ function memberMarks(id){
13795
+ if(id==null)return [];
13796
+ const plans=C.plans;
13797
+ if(_memberMarksIndex===null||_memberMarksFor!==plans){
13798
+ _memberMarksIndex=new Map();_memberMarksFor=plans;
13799
+ for(const plan of Array.isArray(plans)?plans:[])for(const o of (plan&&Array.isArray(plan.memberObservations))?plan.memberObservations:[]){
13800
+ const b=o&&o.binding,v=o&&o.evidence&&o.evidence.observed&&o.evidence.observed.mark&&o.evidence.observed.mark.value;
13801
+ if(!b||b.status!=='active'||!Array.isArray(b.memberIds)||typeof v!=='string'||!v.trim())continue;
13802
+ for(const mid of b.memberIds){if(typeof mid!=='string')continue;const set=_memberMarksIndex.get(mid)||new Set();set.add(v.trim());_memberMarksIndex.set(mid,set);}
13803
+ }
13804
+ }
13805
+ return [...(_memberMarksIndex.get(id)||[])];}
13307
13806
  function v2CanonicalMember(id){
13308
13807
  if(id==null)return undefined;
13309
13808
  const members=modelMembersV2();
@@ -13360,7 +13859,10 @@ function _lenFtLabel(m){
13360
13859
  const v=_lenFt(m);
13361
13860
  return (Number.isFinite(v)&&v>0)?v:undefined;}
13362
13861
  const PROP_DEFS=[
13363
- {key:'id', label:'Mark', get:m=>m.id, fmt:v=>v==null?'':String(v)},
13862
+ // #2948: the id is labelled ID, never Mark. The key stays `id`, so a label someone already picked still shows.
13863
+ {key:'id', label:'ID', get:m=>m.id, fmt:v=>v==null?'':String(v)},
13864
+ // A member the drawings gave no mark answers undefined, so no label chip and no view-query fact claim one.
13865
+ {key:'mark', label:'Mark', get:m=>{const k=memberMarks(m&&m.id);return k.length?k.join(', '):undefined;}, fmt:v=>v==null?'':String(v)},
13364
13866
  {key:'profile', label:'Profile', get:m=>m.profile, fmt:v=>v==null?'':String(v)},
13365
13867
  {key:'type', label:'Type', get:m=>memberTypeLabel(memberTypeOf(m)), fmt:v=>v==null?'':String(v)},
13366
13868
  {key:'role', label:'Role', get:m=>m.role==='column'?'Column':'Beam', fmt:v=>v||''},
@@ -17566,6 +18068,7 @@ let legendMode=(localStorage.getItem('floless.legendMode')==='type')?'type':'pro
17566
18068
  legMenu.addEventListener('keydown',e=>menuKeys(e,legMenu,legBtn,legClose));
17567
18069
  let collapsedCats=new Set((()=>{try{return JSON.parse(localStorage.getItem('floless.legendCollapsed')||'[]');}catch{return [];}})());
17568
18070
  let legendQuery=''; // transient objects-list search filter (members + connections only) — NOT persisted
18071
+ let legendIdHits=[]; // #2998: the member ids the current search matched by id (applyLegendFilter); one → Enter selects it
17569
18072
  // While a search is active, object categories (member types + connections) render EXPANDED so a match inside a
17570
18073
  // manually-collapsed category still surfaces — WITHOUT mutating the persisted collapsedCats.
17571
18074
  function catForceOpen(cat){return !!legendQuery&&(cat==='placed-details'||memberTypeRecords().some(t=>t.k===cat)||/^conn-/.test(cat));}
@@ -22553,7 +23056,8 @@ function build3DLegend(){const host=legendBody('objects'),vis=legendVis(),in3d=l
22553
23056
  const inp=document.createElement('input');inp.id='legSearch';inp.type='text';inp.placeholder='Search objects…';inp.autocomplete='off';inp.value=legendQuery;inp.setAttribute('role','searchbox');inp.setAttribute('aria-label','Search objects in the list');
22554
23057
  const clr=Object.assign(document.createElement('span'),{className:'lsx',textContent:'×'});clr.dataset.tip='Clear';
22555
23058
  inp.addEventListener('input',()=>onLegendSearchInput(inp.value));
22556
- inp.addEventListener('keydown',e=>{if(e.key==='Escape'){e.stopPropagation();if(inp.value){inp.value='';onLegendSearchInput('');}else{inp.blur();}}});
23059
+ inp.addEventListener('keydown',e=>{if(e.key==='Escape'){e.stopPropagation();if(inp.value){inp.value='';onLegendSearchInput('');}else{inp.blur();}}
23060
+ else if(e.key==='Enter'&&legendIdHits.length===1){e.preventDefault();legendSelectMemberId(legendIdHits[0]);}}); // #2998: the one member the search found by id
22557
23061
  clr.addEventListener('click',()=>{if(!inp.value&&!legendQuery)return;inp.value='';onLegendSearchInput('');inp.focus();});
22558
23062
  sb.append(ico,inp,clr);
22559
23063
  host.insertBefore(sb,hint);
@@ -22718,6 +23222,15 @@ function refresh3DLegend(){const vis=legendVis();if(!vis)return;const st=vis.gro
22718
23222
  function legendRowClick(e,row){if(row&&row._dragging)return;const mods={ctrl:e.ctrlKey||e.metaKey,shift:e.shiftKey};clearTimeout(leg3dClickT);if(mods.ctrl||mods.shift)legendSelect(row,mods);else leg3dClickT=setTimeout(()=>legendSelect(row,mods),220);}
22719
23223
  // A selection made IN the list is already where the person is looking, so Follow selection must not scroll the list
22720
23224
  // away from it. The flag covers every way the list selects (click, Ctrl, Shift range, Enter), whatever branch it takes.
23225
+ // #2998: select ONE member the search found by its id (Enter in the search box), as a plain row click selects a group,
23226
+ // and frame it in the pane being searched: `model.fit-selection` only reaches the 3D camera, so a plan zooms itself.
23227
+ // The search box keeps focus, so a person can refine the query and press Enter again.
23228
+ function legendSelectMemberId(id){
23229
+ if(!legendMembers().some(m=>m&&String(m.id)===id))return;
23230
+ legendSelecting=true;try{clearWholeReferenceSelection();modelSelection.replaceMembers([id]);modelSelection.clearGrids();selDimIds.clear();sel3dDimIds.clear();legendSelAnchor=null;render();}finally{legendSelecting=false;}
23231
+ if(legendView()==='2d'){if(sel2d().length)zoomToSelection();}
23232
+ else if(modelEditor.isReady())modelEditor.dispatch('model.fit-selection');
23233
+ }
22721
23234
  function legendSelect(row,mods){legendSelecting=true;try{legendSelectRows(row,mods);}finally{legendSelecting=false;}}
22722
23235
  function legendSelectRows(row,mods){
22723
23236
  if(!row)return;const ids=legRowIds(row);if(!ids.length)return;
@@ -22784,9 +23297,29 @@ function applyLegendFilter(){
22784
23297
  const q=(legendQuery||'').trim().toLowerCase();
22785
23298
  const old=host.querySelector('.lsnomatch');if(old)old.remove(); // only its own note: an empty sheet's stays
22786
23299
  const rows=[...host.querySelectorAll('.lrow[data-key],.lrow[data-connkey],.lrow[data-detailkey]')];
23300
+ host.querySelectorAll('.lidhit').forEach(t=>t.remove());legendIdHits=[]; // a row's own text, never last pass's tag, is what it is matched on
22787
23301
  if(!q){rows.forEach(r=>r.classList.remove('qhide'));host.querySelectorAll('.cat-hdr.qhide').forEach(h=>h.classList.remove('qhide'));return;}
22788
- let any=false;
22789
- rows.forEach(r=>{const hit=(r.textContent||'').toLowerCase().includes(q);r.classList.toggle('qhide',!hit);if(hit)any=true;});
23302
+ // #2998: a row also matches by the ids of what it holds (a member id such as c-021, the id AI decisions, Make precise,
23303
+ // Inspect and the chat all use). A row grouped by profile holds many, so the matched id is shown after its label.
23304
+ const byKey=new Map();for(const m of legendMembers())if(m&&m.id!=null){const k=profileKeyOf(m);if(!byKey.has(k))byKey.set(k,[]);byKey.get(k).push(String(m.id));}
23305
+ let any=false;const tagged=[];
23306
+ rows.forEach(r=>{const textHit=(r.textContent||'').toLowerCase().includes(q);
23307
+ const ids=r.dataset.key?(byKey.get(r.dataset.key)||[]):(r._ids||[]).map(String);
23308
+ const exactFirst=(a,b)=>(b.toLowerCase()===q)-(a.toLowerCase()===q)||a.localeCompare(b); // a typed whole id leads its row's tag
23309
+ // Every member whose id matches is a candidate for Enter, also in a row its label already matched (a member IPE300 in
23310
+ // the IPE300 row); only a row found by id alone needs the tag that says why it is shown.
23311
+ const idMatches=ids.filter(id=>id.toLowerCase().includes(q)).sort(exactFirst),idHits=textHit?[]:idMatches;
23312
+ if(r.dataset.key)legendIdHits.push(...idMatches);
23313
+ const hit=textHit||idHits.length>0;r.classList.toggle('qhide',!hit);if(hit)any=true;
23314
+ if(idHits.length)tagged.push([r,idHits]);});
23315
+ // A whole id typed is that member, even when it also begins longer ids (m-12 of m-120, m-121).
23316
+ const exact=legendIdHits.filter(id=>id.toLowerCase()===q);if(exact.length===1)legendIdHits=exact;
23317
+ const one=legendIdHits.length===1;
23318
+ for(const [r,idHits] of tagged){const t=document.createElement('span');t.className='lidhit';
23319
+ t.textContent='· '+idHits[0]+(idHits.length>1?' +'+(idHits.length-1)+' more':'');
23320
+ t.dataset.tip=one&&r.dataset.key&&idHits[0]===legendIdHits[0]?'Member '+idHits[0]+' is in this group. Press Enter in the search box to select only it.'
23321
+ :'Matched by id: '+idHits.slice(0,8).join(', ')+(idHits.length>8?', …':'')+'. Clicking the row selects the whole group.';
23322
+ r.appendChild(t);}
22790
23323
  host.querySelectorAll('.cat-hdr').forEach(h=>{const cat=h.dataset.cat||'';
22791
23324
  if(!(memberTypeRecords().some(t=>t.k===cat)||/^conn-/.test(cat)||cat==='placed-details'))return; // leave the Dimensions/Clip headers untouched
22792
23325
  let vis=false;
@@ -24742,6 +25275,96 @@ const rfiElsewhereGroups=new Set();
24742
25275
  const rfiTechnicalOccurrences=new Set();
24743
25276
  const rfiTargetErrors=new Map();
24744
25277
  const rfiOccurrenceKey=(recordId,index)=>recordId+'\u0000'+index;
25278
+ /* ── Earlier rounds (#2470 R6.6d carve-out) ───────────────────────────────────────────────────────────────────────
25279
+ A reopened RFI — or one member of a grouped RFI — keeps every earlier round. The list carries only how many; the
25280
+ rounds load when the person opens them, oldest first, each as what happened in order. Keyed by record or occurrence,
25281
+ cached with the revision they were read at, never a failure. */
25282
+ const rfiRoundsOpen=new Set(),rfiRoundsCache=new Map();
25283
+ const rfiRoundsKey=(id,index)=>index==null?'record\u0000'+id:rfiOccurrenceKey(id,index);
25284
+ function rfiExactWhen(iso){const d=new Date(String(iso||''));return isNaN(d.getTime())?String(iso||''):d.toLocaleString(undefined,{weekday:'short',day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'});}
25285
+ /** A short date to read; the exact one to point at and for a screen reader. */
25286
+ function rfiDated(iso){return '<time datetime="'+esc(iso)+'" data-tip="'+esc(rfiExactWhen(iso))+'"><span aria-hidden="true">'+esc(rfiWhen(iso))+'</span><span class=sr-only>'+esc(rfiExactWhen(iso))+'</span></time>';}
25287
+ function rfiRoundEntryHtml(e){
25288
+ const line=t=>'<li>'+rfiDated(e.at)+' · '+t+'</li>';
25289
+ const email=e.group?' (one email for the whole RFI)':'';
25290
+ switch(e.t){
25291
+ case 'raised':return line('Filed: '+esc(e.question));
25292
+ case 'seen-again':return line('Seen again on a newer drawing: '+esc(e.question));
25293
+ case 'reopened':return line(e.why?'Reopened: '+esc(e.why):'Reopened.');
25294
+ case 'sent':return line((e.via==='gmail'?'Sent with Gmail to ':'Marked sent to ')+esc(e.to)+email);
25295
+ case 'answered':return line('Answer: '+esc(rfiAnswerText(e.answer)));
25296
+ case 'applied':return line('Recorded as applied to the model.');
25297
+ case 'closed':return line('Closed '+esc(rfiDispositionWords(e.disposition))+(e.note?' — '+esc(e.note):'.'));
25298
+ default:return '';
25299
+ }
25300
+ }
25301
+ /** The Earlier rounds toggle and, when open, its rounds — for a plain record (index null) or one grouped occurrence. */
25302
+ function rfiRoundsHtml(r,count,index){
25303
+ if(!count)return '';
25304
+ const key=rfiRoundsKey(r.id,index),open=rfiRoundsOpen.has(key);
25305
+ const bodyId='rfi-rounds-'+r.seq+(index==null?'':'-'+index);
25306
+ const label=r.id+(index==null?'':' — occurrence '+(index+1));
25307
+ const occ=index==null?'':' data-rfi-rounds-occ="'+index+'"';
25308
+ const toggle='<button class=ghost data-command-id="steel.rfi-earlier-rounds#'+esc(label)+'" data-command-instance-label="'+esc(label)+'" data-rfi-ctl="'+(index==null?'rounds':'occ:'+index+':rounds')+'" data-rfi-rounds="'+esc(r.id)+'"'+occ
25309
+ +' aria-expanded="'+open+'" aria-controls="'+bodyId+'" data-tip="What was asked, sent, answered and closed before this was reopened">Earlier rounds ('+count+')</button>';
25310
+ let body='';
25311
+ // A record's revision only rises, so rounds read at or after the list's revision are current for it.
25312
+ const got=rfiRoundsCache.get(key),fresh=got&&got.revision>=r.recordRevision?got:null;
25313
+ const busy=open&&(!fresh||fresh.status==='loading');
25314
+ // Open on an RFI the list says changed since its rounds were read, with nothing in flight: read them again.
25315
+ if(open&&!fresh&&!(got&&got.status==='loading'))queueMicrotask(()=>rfiLoadRounds(r.id,index,r.recordRevision));
25316
+ if(open){
25317
+ if(!fresh||fresh.status==='loading')body='<div class=rfinote role=status>Loading earlier rounds…</div>';
25318
+ else if(fresh.status==='error')body='<div class=rfinote role=status>'+esc(fresh.error)+'</div><div class=rfiacts><button class=ghost data-command-id="steel.rfi-earlier-rounds-again#'+esc(label)+'" data-command-instance-label="'+esc(label)+'" data-rfi-ctl="'+(index==null?'rounds-again':'occ:'+index+':rounds-again')+'" data-rfi-rounds-again="'+esc(r.id)+'"'+occ+'>Try again</button></div>';
25319
+ else if(!fresh.rounds.length)body='<div class=rfinote role=status>No earlier rounds were found for this RFI.</div>';
25320
+ else body='<ol class=rfirounds aria-label="'+esc('Earlier rounds of '+label)+'">'+fresh.rounds.map(rd=>{
25321
+ const first=rd.entries[0],how=first?(first.t==='reopened'?'Reopened ':first.t==='seen-again'?'Seen again ':'Filed ')+rfiDated(first.at):'';
25322
+ return '<li><div class=rfiround-head>Round '+rd.round+(how?' · '+how:'')+'</div><ul class=rfiround-entries>'+rd.entries.map(rfiRoundEntryHtml).join('')+'</ul></li>';
25323
+ }).join('')+'</ol>';
25324
+ }
25325
+ return '<div class=rfiacts>'+toggle+'</div><div id="'+bodyId+'" class=rfirounds-body'+(busy?' aria-busy="true"':'')+'>'+body+'</div>';
25326
+ }
25327
+ async function rfiLoadRounds(id,index,revision){
25328
+ const key=rfiRoundsKey(id,index);
25329
+ rfiRoundsCache.set(key,{status:'loading',revision});
25330
+ const project=PROJECT;
25331
+ try{
25332
+ const r=await fetch('/api/projects/'+encodeURIComponent(project)+'/rfis/'+encodeURIComponent(id)+'/rounds'+(index==null?'':'?occurrenceIndex='+index));
25333
+ const j=await r.json().catch(()=>({}));
25334
+ if(project!==PROJECT)return;
25335
+ if(!r.ok||!j||j.ok===false)rfiRoundsCache.set(key,{status:'error',revision,error:j&&typeof j.error==='string'&&j.error?j.error:'FloLess couldn’t load the earlier rounds just now.'});
25336
+ else{
25337
+ // Never below the revision asked for: an answer behind the list cannot start the reads over (Codex review).
25338
+ const read=Number.isSafeInteger(j.recordRevision)?Math.max(j.recordRevision,revision):revision;
25339
+ rfiRoundsCache.set(key,{status:'ready',revision:read,rounds:Array.isArray(j.rounds)?j.rounds:[]});
25340
+ // The rounds are newer than the list (changed elsewhere): read the list once, never the rounds again.
25341
+ const now=(rfiState.records||[]).find(x=>x&&x.id===id);
25342
+ if(now&&Number.isSafeInteger(now.recordRevision)&&now.recordRevision<read)void refreshRfiRecords();
25343
+ }
25344
+ }catch(_){
25345
+ if(project!==PROJECT)return;
25346
+ rfiRoundsCache.set(key,{status:'error',revision,error:'FloLess couldn’t load the earlier rounds just now.'});
25347
+ }
25348
+ if(!rfiOpen())return;
25349
+ // Back to the toggle only if the person is still on it (or on its Try again, gone while loading), and through the
25350
+ // guarded repaint, which yields to somebody typing on ANY row, this RFI's own included: a row's profile combo keeps
25351
+ // its text only in the DOM, and rounds landing are not an action on the row, so no row is exempt (Codex review).
25352
+ const at=document.activeElement,occ=index==null?null:String(index);
25353
+ const mine=at&&typeof at.getAttribute==='function'&&(at.getAttribute('data-rfi-rounds')===id||at.getAttribute('data-rfi-rounds-again')===id)&&at.getAttribute('data-rfi-rounds-occ')===occ;
25354
+ if(mine||!at||at===document.body)rfiFocusOverride={rows:[rfiRowKey('record',id)],ctl:index==null?'rounds':'occ:'+index+':rounds'};
25355
+ rfiSettleRepaint({force:true});
25356
+ }
25357
+ /** Open or close one Earlier rounds, reading the rounds the first time (or when the RFI changed since). */
25358
+ function rfiToggleRounds(id,index){
25359
+ const key=rfiRoundsKey(id,index);
25360
+ if(rfiRoundsOpen.has(key))rfiRoundsOpen.delete(key);
25361
+ else{
25362
+ rfiRoundsOpen.add(key);
25363
+ const r=(rfiState.records||[]).find(x=>x&&x.id===id),got=rfiRoundsCache.get(key);
25364
+ if(r&&!(got&&got.revision>=r.recordRevision&&got.status!=='error'))void rfiLoadRounds(id,index,r.recordRevision);
25365
+ }
25366
+ rfiFocusOverride={rows:[rfiRowKey('record',id)],ctl:index==null?'rounds':'occ:'+index+':rounds'};renderRfiList();
25367
+ }
24745
25368
 
24746
25369
  /* ── RFI actions and outcomes (#1090) ──────────────────────────────────────────────────────────────
24747
25370
  THE OUTCOME OF AN ACTION IS ITS OWN SURFACE, on its own branch. `paintRfiBanner` says what FloLess
@@ -24977,13 +25600,38 @@ function paintRfiStat(){
24977
25600
 
24978
25601
  const liveDrawingTargets=g=>{const rows=Array.isArray(g&&g.drawingTargets)&&g.drawingTargets.length?g.drawingTargets:g&&g.drawingTarget?[g.drawingTarget]:[];
24979
25602
  return rows.map(dt=>({where:'drawing',role:'member location',...dt}));};
25603
+ /** #2928: set once the page says it is leaving (`beforeunload`), so a read the browser cuts off on the way out
25604
+ * is not reported as a failure. See the catch in `refreshRfiRecords`. */
25605
+ let rfiPageLeaving=false;
25606
+ const RFI_LEAVE_GRACE_MS=3000;
25607
+ /** #2924: every records read has one owner that can cancel it, so a stalled read never keeps holding one of the
25608
+ * browser's six connections to FloLess. `rfiReadCtl` is the current read's: a newer read (or a merge that
25609
+ * supersedes it, see rfiMergeResponse) aborts it, and so does its own deadline. The deadline is longer than an RFI
25610
+ * action's (RFI_ACTION_TIMEOUT_MS): when FloLess stalls, the action's own recovery speaks first, and the list says it
25611
+ * stopped waiting only if it is still stuck after that. */
25612
+ let rfiReadCtl=null;
25613
+ const RFI_READ_DEADLINE_MS=45000;
25614
+ const RFI_READ_TIMEOUT_SAID='FloLess got no answer within '+Math.round(RFI_READ_DEADLINE_MS/1000)+' seconds, so it stopped waiting. Press Retry to read them again.';
25615
+ function rfiAbortRead(){if(rfiReadCtl){const c=rfiReadCtl;rfiReadCtl=null;c.abort();}}
24980
25616
  async function refreshRfiRecords(opts){
24981
25617
  if(!PROJECT){rfiState={status:'off',records:[],sizeTruth:'known',liveTruth:'known',detail:'',liveDetail:'',http:0,error:''};rfiTargetErrors.clear();paintRfiStat();if(rfiOpen())renderRfiList();return true;}
24982
25618
  const mine=++rfiFetchSeq;
25619
+ // The read this one supersedes is cancelled, not only ignored: its answer could never be shown anyway.
25620
+ rfiAbortRead();
25621
+ const ctl=new AbortController();rfiReadCtl=ctl;
25622
+ let late=false;
25623
+ // A caller's own signal (a chat mention's deadline, a row action) cancels this read, and its deadline is the one
25624
+ // that bounds it: an action's recovery read must not get a second deadline and a second, competing banner.
25625
+ const outer=opts&&opts.signal,follow=()=>ctl.abort();
25626
+ const deadline=outer?null:setTimeout(()=>{late=true;ctl.abort();},RFI_READ_DEADLINE_MS);
25627
+ if(outer){if(outer.aborted)ctl.abort();else outer.addEventListener('abort',follow,{once:true});}
24983
25628
  try{
24984
- const r=await fetch('/api/projects/'+encodeURIComponent(PROJECT)+'/rfis',{signal:opts&&opts.signal});
25629
+ const r=await fetch('/api/projects/'+encodeURIComponent(PROJECT)+'/rfis',{signal:ctl.signal});
24985
25630
  const j=await r.json().catch(()=>({}));
24986
25631
  if(mine!==rfiFetchSeq)return false; // a later read owns the state now — see rfiFetchSeq
25632
+ // The deadline can land while the body is read, which `.catch` above turns into an empty body: that is a
25633
+ // read that took too long, never a broken answer from the server.
25634
+ if(late)throw new Error('the RFI records read passed its deadline');
24987
25635
  rfiLiveContractHash=typeof j.liveContractHash==='string'?j.liveContractHash:'';
24988
25636
  const live=(Array.isArray(j.liveRfis)?j.liveRfis:[]).map(g=>{const subjects=g.subjects||[],targets=liveDrawingTargets(g),dt=targets[0];
24989
25637
  const ids=subjects.map(s=>s&&s.memberId).filter(Boolean),source=dt
@@ -25032,11 +25680,31 @@ async function refreshRfiRecords(opts){
25032
25680
  // FloLess disposed this editor (the project is being reopened or switched) and is replacing the frame, which cuts
25033
25681
  // off any read still in flight. Nobody is looking at this page any more, so that is not a failure to report.
25034
25682
  if(editorTerminalDisposed)return false;
25683
+ // #2928: a reload or a navigation away cuts the read off too, and in Chrome the rejection can land BEFORE
25684
+ // `pagehide` disposes the editor. Once the page has said it is leaving, wait: a page that really goes never
25685
+ // runs the timer, so nothing is reported; a page that is still here afterwards (the person stayed) reports
25686
+ // the failure as any other.
25687
+ if(rfiPageLeaving){
25688
+ await new Promise(r=>setTimeout(r,RFI_LEAVE_GRACE_MS));
25689
+ rfiPageLeaving=false; // the page is still here: it did not leave after all
25690
+ if(mine!==rfiFetchSeq||editorTerminalDisposed||(opts&&opts.signal&&opts.signal.aborted))return false;
25691
+ }
25692
+ // #2924: the read's own deadline stopped it. Said in plain words, with what to do; it is not a fault in the page.
25693
+ if(late){
25694
+ console.warn('[steel] the filed RFIs read took too long and was stopped');
25695
+ rfiState={status:'fail',records:[],sizeTruth:'known',liveTruth:'known',detail:'',liveDetail:'',http:0,error:RFI_READ_TIMEOUT_SAID};
25696
+ }else{
25035
25697
  // Bind and log it. A dead server, a DNS failure and a TypeError thrown by our own code inside the
25036
25698
  // try all render the same banner, and a bug report cannot tell them apart from that banner alone.
25037
25699
  console.error('[steel] could not read the filed RFIs', e);
25038
25700
  rfiState={status:'fail',records:[],sizeTruth:'known',liveTruth:'known',detail:'',liveDetail:'',http:0,
25039
25701
  error:String((e&&e.message)||'')};
25702
+ }
25703
+ }finally{
25704
+ // Every way out of the read ends what it owned: its deadline, its link to the caller's signal, and its slot.
25705
+ clearTimeout(deadline);
25706
+ if(outer)outer.removeEventListener('abort',follow);
25707
+ if(rfiReadCtl===ctl)rfiReadCtl=null;
25040
25708
  }
25041
25709
  rfiRecordsSeq++;
25042
25710
  if(rfiState.status==='ok')rfiPruneTargetErrors();
@@ -25738,7 +26406,7 @@ function rfiDeadline(ms){
25738
26406
  }
25739
26407
  // Leaving the page has no UI left to recover into. Retire every request and, through `cancelled()`,
25740
26408
  // prevent its rejection from starting a fresh RFI read during teardown.
25741
- window.addEventListener('beforeunload',()=>{for(const deadline of [...rfiDeadlines])deadline.abort();uncertainWrites.clear();});
26409
+ window.addEventListener('beforeunload',()=>{rfiPageLeaving=true;for(const deadline of [...rfiDeadlines])deadline.abort();uncertainWrites.clear();});
25742
26410
 
25743
26411
  /** Take whatever a response gave us of the record. It rides out on a NON-2xx only through the
25744
26412
  * reconcile arm — every other refusal sends a bare `{ok,code,error}`, which is why rules below
@@ -25758,7 +26426,8 @@ function rfiMergeResponse(j){
25758
26426
  // assumed: a truth that flipped to `unavailable` would otherwise leave Apply and `resolved` offered.
25759
26427
  if(j&&(j.sizeTruth==='known'||j.sizeTruth==='unavailable'))rfiState={...rfiState,sizeTruth:j.sizeTruth};
25760
26428
  if(merged){
25761
- rfiFetchSeq++;rfiRecordsSeq++;rfiPruneTargetErrors();paintRfiStat();rfiRepaintHeightNotes();
26429
+ // #2924: the read this merge supersedes is cancelled too, so it stops holding a connection.
26430
+ rfiFetchSeq++;rfiRecordsSeq++;rfiPruneTargetErrors();paintRfiStat();rfiRepaintHeightNotes();rfiAbortRead();
25762
26431
  // The bump above cancels any read still in flight. If one of those owned the `loading` transition
25763
26432
  // that Retry started, nothing would ever end it — `openRFI` will not re-read while `loading` and
25764
26433
  // the loading banner offers no Retry, so the dialog sticks with no way out.
@@ -27117,6 +27786,7 @@ function rfiTargetControls(r,occurrenceIndex){
27117
27786
  const EDITOR_FOCUS_3D_WAIT_MS=20000;
27118
27787
  /** The last-resort sentence when showing what was asked for failed in a way the runner did not foresee. */
27119
27788
  function editorFocusFailed(req){
27789
+ if(req.makePrecise)return 'FloLess could not open Make precise. Press Open Make precise again, or press Make precise on the AI decisions strip.';
27120
27790
  if(req.rfiId)return 'FloLess could not show '+req.rfiId+'. Find it on the RFIs page, or press it in the chat again.';
27121
27791
  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
27792
  :'The model could not show connection '+req.jointId+'. Press Open in the model again, or find it in the Model panel.';
@@ -27185,7 +27855,29 @@ async function runRfiFocus(rfiId,current){
27185
27855
  const shown=_rfiByAttr(document.getElementById('rfiList'),'data-rfi-row',rfiRowKey('record',rfiId));if(shown)shown.classList.remove('is-mentioned');},2400);
27186
27856
  return widened?{ok:true,said:'Showing all RFIs, so '+rfiId+' is in view.'}:{ok:true};
27187
27857
  }
27858
+ /**
27859
+ * #2521 row 9: the chat's "Open Make precise" opens the panel itself, as the strip's button does. It only opens it:
27860
+ * every confirm stays the person's click. It waits for the saved model's verdict (the strip offers Make precise only
27861
+ * for a Quick model) and says, in a sentence, why it did not open.
27862
+ */
27863
+ async function runMakePreciseFocus(current){
27864
+ const until=Date.now()+EDITOR_FOCUS_3D_WAIT_MS;
27865
+ while(lastSavedVerdict===undefined&&Date.now()<until){await new Promise(resolve=>setTimeout(resolve,100));if(!current())return null;}
27866
+ if(!current())return null; // replaced before it started, with the verdict already known: open nothing over the newer request
27867
+ const refuse=said=>{answerToast(said);return {ok:false,said};};
27868
+ if(lastSavedVerdict===undefined)return refuse('FloLess is still checking whether this model has AI decisions, so Make precise did not open. Wait a moment, then press Open Make precise again.');
27869
+ if(lastSavedVerdict===null)return refuse('This model is precise as last saved: no AI decision it rests on is left to review.');
27870
+ if(lastSavedVerdict.state!=='quick')return refuse('FloLess could not read the AI decisions in this model, so Make precise did not open. Reopen the Model step, then press Open Make precise again.');
27871
+ openMakePrecise();
27872
+ if(makePrecise)return {ok:true};
27873
+ // The member-end review asks first, on screen, and opens Make precise once the person answers.
27874
+ if(memberEndReview&&memberEndReview.leaving&&memberEndReview.leaving.name==='Make precise')return {ok:true};
27875
+ // Otherwise the member-end review said why where the person is looking (memberEndYieldPanel); the card says the same.
27876
+ if(memberEndReview&&memberEndReview.busy)return {ok:false,said:'Make precise could not open because a member-end change is still being applied. Press Open Make precise again when it finishes.'};
27877
+ return {ok:false,said:'Make precise could not open because a check on the member ends is still running. Press Open Make precise again when it finishes.'};
27878
+ }
27188
27879
  async function runEditorFocus(req,current){
27880
+ if(req.makePrecise)return runMakePreciseFocus(current);
27189
27881
  if(req.rfiId)return runRfiFocus(req.rfiId,current);
27190
27882
  const until=Date.now()+EDITOR_FOCUS_3D_WAIT_MS;
27191
27883
  while(!window.Steel3DView&&Date.now()<until){await new Promise(resolve=>setTimeout(resolve,100));if(!current())return null;}
@@ -27416,6 +28108,8 @@ function steelViewCandidates(){
27416
28108
  for(const def of PROP_DEFS){
27417
28109
  // A row the panel withholds (a plan-derived default) is not a value to match on.
27418
28110
  if(def.needsPlan&&!def.canonicalGet)continue;
28111
+ // #2948: each mark the drawings gave is its own value, so Mark eq "B7" finds a member marked both B7 and X9.
28112
+ if(def.key==='mark'){for(const k of memberMarks(m.id))add(def.label,k);continue;}
27419
28113
  let raw,shown;
27420
28114
  try{raw=def.needsPlan?def.canonicalGet(m):(def.labelGet||def.get)(m);if(raw===undefined||raw===null)continue;shown=def.fmt(raw);}
27421
28115
  catch(_){continue;}
@@ -27657,6 +28351,8 @@ function rfiGroupedRecordRowHtml(r){
27657
28351
  const error=rfiTargetErrors.get(key);
27658
28352
  return '<li class=rfioccurrence data-rfi-occurrence="'+index+'"><article aria-labelledby="rfi-occ-'+r.seq+'-'+index+'"><div class=rfioccurrence-head><span class="rfioccurrence-title rfimeta"><h4 id="rfi-occ-'+r.seq+'-'+index+'" tabindex="-1">Occurrence '+(index+1)+' of '+count+' — '+esc(rfiGroupedOccurrenceSubject(occ))+'</h4>'+rfiAiMark(occ.latestBy)+'</span><span class="rfikind '+rfiStatusTone(occ)+'">'+esc(rfiStatusWords(occ))+'</span></div>'
27659
28353
  +'<div class=rfinote>'+esc(occ.question)+(sheets?' · '+esc(sheets):'')+'</div>'
28354
+ +(occ.reopened?'<div class=rfinote>Reopened '+rfiDated(occ.reopened.at)+(occ.reopened.why?': '+esc(occ.reopened.why):'.')+'</div>':'')
28355
+ +rfiRoundsHtml(r,occ.earlierRounds,index)
27660
28356
  +(error?'<div class=rfifail role=alert>'+esc(error.message)+'</div>':'')
27661
28357
  +(occurrenceForm?rfiFormHtml(view,'occurrence '+(index+1)+' of '+count,rowKey):(formOpen?'':'<div class=rfiacts>'+rfiGroupedOccurrenceVerbs(r,occ,rowBusy)+targets+'</div>'))
27662
28358
  +'<div class=rfitechnical><button class=ghost data-command-id="steel.rfi-technical#'+esc(r.id+' occurrence '+(index+1))+'" data-command-instance-label="'+esc(r.id+' — occurrence '+(index+1))+'" data-rfi-ctl="occ:'+index+':technical" data-rfi-technical="'+index+'" data-rfi-on="'+esc(r.id)+'" aria-expanded="'+technical+'" aria-controls="rfi-tech-'+r.seq+'-'+index+'">Technical details</button>'
@@ -27665,12 +28361,23 @@ function rfiGroupedRecordRowHtml(r){
27665
28361
  :'<ol id="'+panelId+'" class=rfioccurrences aria-label="Occurrences in '+esc(r.id)+'" hidden></ol>';
27666
28362
  const sheetSummary=rfiScope==='sheet'?matching.length+' of '+count+' occurrences on this sheet · ':'';
27667
28363
  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>'
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>'
28364
+ +esc(r.question||'This grouped RFI records no question.')+'<div class=rfimeta><span>'+esc(r.id)+'</span>'+rfiFiledByYou(r)+'<span>'+esc(rfiStatusWords(r))+'</span><span>'+sheetSummary+count+' occurrences · '+r.counts.sheets+' sheets · '+r.counts.entities+' members/connections</span></div>'
27669
28365
  +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>'))
27670
28366
  +'<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>'
27671
28367
  +(formOpen?'':rfiOutcomeHtml(rowKey))+occurrences+'</div></div>';
27672
28368
  }
27673
28369
 
28370
+ /* #2925 — "Filed by you" on an RFI a person filed (from "From the read, not filed", or raised from the model): the
28371
+ record's FIRST event is the person's. Reader-filed rows carry no chip. Short date on the chip, the exact time in the
28372
+ tooltip and the accessible name, so keyboard and touch users get the date without hovering. */
28373
+ function rfiFiledByYou(r){
28374
+ if(!r||r.raisedBy!=='user'||typeof r.raisedAt!=='string'||Number.isNaN(Date.parse(r.raisedAt)))return '';
28375
+ const at=new Date(r.raisedAt),now=new Date();
28376
+ const day=at.toDateString()===now.toDateString()?'today'
28377
+ :at.toLocaleDateString(undefined,at.getFullYear()===now.getFullYear()?{day:'numeric',month:'short'}:{day:'numeric',month:'short',year:'numeric'});
28378
+ const full='Filed by you on '+at.toLocaleString(undefined,{weekday:'short',day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'});
28379
+ return '<span class=rfifiled tabindex="0" data-command-id="steel.rfi-filed-by#'+esc(r.id)+'" data-command-instance-label="'+esc(r.id)+'" aria-label="'+esc(full)+'" data-tip="'+esc(full)+'">Filed by you · '+esc(day)+'</span>';
28380
+ }
27674
28381
  /* #2521 row 3b-2 — "AI" beside a proposal the AI wrote (the sighting's `latestBy`), in a Quick model. Not
27675
28382
  for `raisedBy` alone: a later sighting by a guided read carries its own proposal and no AI mark. */
27676
28383
  const RFI_AI_TIP='Proposed by the AI in a Quick model: this answer is the AI\'s decision, not a person\'s.';
@@ -27878,7 +28585,7 @@ function rfiRecordRowHtml(r){
27878
28585
  +rfiElevationControls(rowKey,r.id,g)
27879
28586
  +'<div class=rfiacts>'+copy+targets+'</div></div></div>';
27880
28587
  }
27881
- const meta=[rfiAiMark(r.latestBy),'<span>'+esc(r.id)+'</span>','<span>'+esc(rfiStatusWords(r))+'</span>']
28588
+ const meta=[rfiAiMark(r.latestBy),'<span>'+esc(r.id)+'</span>',rfiFiledByYou(r),'<span>'+esc(rfiStatusWords(r))+'</span>']
27882
28589
  .concat(ids.slice(0,6).map(id=>'<span>'+esc(id)+'</span>'))
27883
28590
  .concat(sheets.map(sh=>'<span>Sheet '+esc(sh)+'</span>'))
27884
28591
  .join('');
@@ -27899,6 +28606,8 @@ function rfiRecordRowHtml(r){
27899
28606
  if(r.applied)notes.push('Recorded as applied to the model on '+esc(rfiWhen(r.applied.at))+'.');
27900
28607
  if(r.closed)notes.push('Closed '+esc(rfiDispositionWords(r.closed.disposition))
27901
28608
  +' on '+esc(rfiWhen(r.closed.at))+(r.closed.note?' — '+esc(rfiSentence(r.closed.note)):'.'));
28609
+ // #2470 R6.6d: why the current round is open again.
28610
+ if(r.reopened)notes.push('Reopened '+rfiDated(r.reopened.at)+(r.reopened.why?': '+esc(rfiSentence(r.reopened.why)):'.'));
27902
28611
  // #2521 row 3b-2: the AI's recommendation. Not "built on": a question about an unbuilt connection or an unresolved
27903
28612
  // placement was never applied, and a later edit can change the model (Codex review).
27904
28613
  if(r.proposed)notes.push(r.latestBy==='ai'?'The AI’s proposed answer: '+esc(rfiSentence(r.proposed))
@@ -27980,6 +28689,7 @@ function rfiRecordRowHtml(r){
27980
28689
  +esc(r.question||'This RFI records no question.')
27981
28690
  +'<div class=rfimeta>'+meta+'</div>'
27982
28691
  +(notes.length?'<div class=rfinote>'+notes.join(' ')+'</div>':'')
28692
+ +rfiRoundsHtml(r,r.earlierRounds,null)
27983
28693
  +(profileMismatch?'<div class=rfinote role="note" data-rfi-profile-truth>'+esc(rfiProfileTruthMessage(profileMismatch))+'</div>':'')
27984
28694
  +(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>':'')
27985
28695
  +(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>':'')
@@ -28277,6 +28987,12 @@ function wireRfiList(){
28277
28987
  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
28988
  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
28989
  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();});
28990
+ // #2470 R6.6d: Earlier rounds, on a record or on one occurrence of a grouped record.
28991
+ root.querySelectorAll('[data-rfi-rounds]').forEach(b=>b.onclick=()=>rfiToggleRounds(b.dataset.rfiRounds,b.dataset.rfiRoundsOcc==null?null:Number(b.dataset.rfiRoundsOcc)));
28992
+ root.querySelectorAll('[data-rfi-rounds-again]').forEach(b=>b.onclick=()=>{const id=b.dataset.rfiRoundsAgain,index=b.dataset.rfiRoundsOcc==null?null:Number(b.dataset.rfiRoundsOcc);
28993
+ const r=(rfiState.records||[]).find(x=>x&&x.id===id);if(r)void rfiLoadRounds(id,index,r.recordRevision);
28994
+ // Try again is gone while it loads: keep focus on the toggle it belongs to.
28995
+ rfiFocusOverride={rows:[rfiRowKey('record',id)],ctl:index==null?'rounds':'occ:'+index+':rounds'};renderRfiList();});
28280
28996
  root.querySelectorAll('[data-rfi-expand]').forEach(b=>b.onclick=()=>{
28281
28997
  const id=b.dataset.rfiExpand;if(rfiExpandedGroups.has(id))rfiExpandedGroups.delete(id);else rfiExpandedGroups.add(id);
28282
28998
  rfiFocusOverride={rows:[rfiRowKey('record',id)],ctl:'expand'};renderRfiList();});
@@ -31916,7 +32632,8 @@ boot().catch(err => { EditorFocus.fail('The model did not open, so the connectio
31916
32632
  // data-tip hover after a short delay, positioned below the control and clamped to the viewport. A function of
31917
32633
  // its document because the 3D panel's tabs can live in a second one: the left Model section's host frame.
31918
32634
  function installThemedTips(doc){ const win=doc.defaultView||window; const tip=doc.createElement('div'); tip.id='tooltip'; doc.body.appendChild(tip); let t=null;
31919
- function show(el){ if(el.getAttribute('aria-haspopup')==='menu'&&el.getAttribute('aria-expanded')==='true')return; // an opening trigger can still have a pending hover timer; never let its tip cover the menu below it
32635
+ function show(el){ if(!el.isConnected)return; // a panel that re-rendered under the pointer replaced it: its box is gone, so the tip would sit at the window's corner
32636
+ if(el.getAttribute('aria-haspopup')==='menu'&&el.getAttribute('aria-expanded')==='true')return; // an opening trigger can still have a pending hover timer; never let its tip cover the menu below it
31920
32637
  const txt=el.getAttribute('data-tip'); if(!txt) return; tip.textContent=txt; tip.classList.add('show');
31921
32638
  const r=el.getBoundingClientRect(), tw=tip.offsetWidth, th=tip.offsetHeight;
31922
32639
  let x=Math.max(6,Math.min(r.left+r.width/2-tw/2, win.innerWidth-tw-6)), y=r.bottom+6; if(y+th>win.innerHeight-6) y=r.top-th-6;
@@ -31925,6 +32642,10 @@ function installThemedTips(doc){ const win=doc.defaultView||window; const tip=do
31925
32642
  doc.addEventListener('pointerover', e=>{ const el=e.target.closest('[data-tip]'); if(!el) return; clearTimeout(t); t=setTimeout(()=>show(el),400); });
31926
32643
  doc.addEventListener('pointerout', e=>{ if(e.target.closest('[data-tip]')) hide(); });
31927
32644
  doc.addEventListener('pointerdown', hide, true); // a click hides the tip immediately
32645
+ // #2925: a focusable RFI label ("Filed by you", the AI mark) has nothing to click, so its tip is its whole content;
32646
+ // a keyboard user gets it on focus too. Scoped to those labels: buttons keep their pointer-only tips.
32647
+ doc.addEventListener('focusin', e=>{ const el=e.target.closest&&e.target.closest('.rfimeta [data-tip][tabindex]'); if(el&&el.matches(':focus-visible')){ clearTimeout(t); show(el); } });
32648
+ doc.addEventListener('focusout', e=>{ if(e.target.closest&&e.target.closest('.rfimeta [data-tip][tabindex]')) hide(); });
31928
32649
  // Programmatic access for canvas handles (the 3D gizmo has no DOM to carry data-tip). Same shared themed
31929
32650
  // #tooltip element, positioned at a client point, clamped to the viewport — so a WebGL handle's tooltip is
31930
32651
  // themed exactly like every toolbar tip and never a native light title=. showText hides on the next hover-out