@floless/app 0.158.0 → 0.159.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 (35) hide show
  1. package/dist/floless-server.cjs +92620 -75445
  2. package/dist/schemas/drawing-check.profile.v1.schema.json +33 -1
  3. package/dist/skills/floless-app-actions/SKILL.md +23 -5
  4. package/dist/skills/floless-app-bridge/SKILL.md +5 -3
  5. package/dist/skills/floless-app-onboarding/SKILL.md +67 -4
  6. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +7 -4
  7. package/dist/skills/floless-app-queue/SKILL.md +3 -1
  8. package/dist/skills/floless-app-steel-model/SKILL.md +11 -5
  9. package/dist/skills/floless-app-steel-takeoff/SKILL.md +28 -8
  10. package/dist/skills/floless-app-workflows/SKILL.md +6 -3
  11. package/dist/web/agents.js +12 -5
  12. package/dist/web/app.css +87 -13
  13. package/dist/web/app.js +6 -0
  14. package/dist/web/aware.js +29 -4
  15. package/dist/web/chat.css +42 -22
  16. package/dist/web/chat.js +181 -30
  17. package/dist/web/commands-shell.js +305 -4
  18. package/dist/web/commands-steel.js +1 -0
  19. package/dist/web/drawing-check-editor.html +10 -0
  20. package/dist/web/drawing-check-editor.js +44 -0
  21. package/dist/web/guide.js +4 -2
  22. package/dist/web/index.html +41 -9
  23. package/dist/web/instructor.js +20 -8
  24. package/dist/web/pages.js +71 -13
  25. package/dist/web/project-access.js +67 -8
  26. package/dist/web/project-modules.js +474 -0
  27. package/dist/web/project-workflows.js +274 -0
  28. package/dist/web/steel-3d-core.js +46 -0
  29. package/dist/web/steel-3d-view.js +8 -38
  30. package/dist/web/steel-editor.html +192 -49
  31. package/dist/web/workspace-root-recovery.js +119 -0
  32. package/dist/web/workspaces.js +358 -114
  33. package/launch-starting-page.mjs +5 -2
  34. package/launch.mjs +136 -78
  35. package/package.json +5 -1
@@ -1463,6 +1463,17 @@ rect.lblhot:focus-visible{outline:2px solid var(--brand);outline-offset:2px;stro
1463
1463
  #rfiList .rfimeta span{background:var(--sunken);border:1px solid var(--line);color:var(--mut);
1464
1464
  border-radius:4px;padding:0 5px;font-size:10px;line-height:1.7}
1465
1465
  #rfiList .rfinote{margin-top:4px;color:var(--mut);font-size:11px;line-height:1.5}
1466
+ /* #2521 row 3b-2 — the AI's mark. The word "AI" carries it, so it survives losing colour; the brand
1467
+ outline only says it is not one of the grey facts beside it. Shown where the AI wrote the proposal. */
1468
+ #rfiList .rfimeta .rfiby.ai{color:var(--brand);border-color:var(--brand)}
1469
+ #rfiList .rfioccurrence-title{display:inline-flex;align-items:baseline;gap:6px;flex-wrap:wrap;margin-top:0}
1470
+ /* A Quick version's questions the AI could not get into the RFI file. Rows, not the banner: they are
1471
+ questions waiting on a filing, and the dashed badge already means "not filed" in this list. */
1472
+ #rfiList .rfiunfiled{padding:6px 0 8px;border-bottom:1px solid var(--line);margin-bottom:4px}
1473
+ #rfiList .rfiunfiled .glab{font-size:10px;text-transform:uppercase;letter-spacing:.06em;color:var(--mut);padding:0 8px}
1474
+ #rfiList .rfiunfiled>.rfinote,#rfiList .rfiunfiled>.rfiacts{padding:0 8px}
1475
+ #rfiList .rfiunfiled .rfiwhy{color:var(--warn)}
1476
+ #rfiList .rfiunfiled b.rfiwarn{color:var(--warn)}
1466
1477
  #rfiList .rfiacts{margin-top:6px;display:flex;flex-wrap:wrap;gap:5px;align-items:center}
1467
1478
  #rfiList .rfiacts button{font-size:11px;padding:3px 8px}
1468
1479
  #rfiList .rfiacts [aria-disabled=true]{opacity:.48;cursor:progress;background:var(--btn);border-color:var(--ctrl-border)}
@@ -14041,7 +14052,20 @@ function toast(msg,sticky,ms,visualOnly){let t=document.getElementById('toast');
14041
14052
  if(!t){t=document.createElement('div');t.id='toast';t.style.cssText='position:fixed;left:50%;bottom:18px;transform:translateX(-50%);background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:8px;padding:8px 14px;box-shadow:var(--shadow-md);z-index:60;font:13px var(--ui);line-height:1.5;max-width:min(480px,86vw);opacity:0;transition:opacity .2s;pointer-events:none';document.body.appendChild(t);}
14042
14053
  if(visualOnly){t.removeAttribute('role');t.removeAttribute('aria-live');t.removeAttribute('aria-atomic');}
14043
14054
  else{t.setAttribute('role','status');t.setAttribute('aria-live','polite');t.setAttribute('aria-atomic','true');}
14044
- t.textContent=msg;t.style.opacity='1';clearTimeout(t._h);if(!sticky)t._h=setTimeout(()=>{t.style.opacity='0';},ms>0?ms:TOAST_MS);}
14055
+ t.textContent=msg;t.style.opacity='1';clearTimeout(t._h);if(!sticky)t._h=setTimeout(()=>{t.style.opacity='0';},ms>0?ms:TOAST_MS);
14056
+ t._holdUntil=0;t._deferred=null;clearTimeout(t._dh);} // any later toast ends a hold and drops a waiting status line (#2621)
14057
+ // #2621: the answer to something the person asked for from outside (Open / Show in the model) holds the toast for
14058
+ // its full time. The 3D bake lands in the same moment and its build-status line used to replace the answer 2 ms
14059
+ // later, so the person never read why their press failed.
14060
+ const ANSWER_TOAST_MS=9000;
14061
+ function answerToast(msg){toast(msg,false,ANSWER_TOAST_MS);document.getElementById('toast')._holdUntil=Date.now()+ANSWER_TOAST_MS;}
14062
+ // A passive status line (the build status after a bake) waits out a held answer and then shows for its own full
14063
+ // time. `line` is called when it SHOWS, not when it was asked for, so what it says is what is true then (an empty
14064
+ // line shows nothing); only the latest waits, since it reads the same live state the older one would have.
14065
+ function statusToast(line){const t=document.getElementById('toast'),left=t?t._holdUntil-Date.now():0;
14066
+ if(!(left>0)){const msg=line();if(msg)toast(msg);return;}
14067
+ clearTimeout(t._dh);t._deferred=line;
14068
+ t._dh=setTimeout(()=>{const l=t._deferred;t._deferred=null;const msg=l?l():'';if(msg)toast(msg);},left);}
14045
14069
  // --- pointer: select(+ctrl toggle / box) + group-move + endpoint (Shift = ortho) ---
14046
14070
  function applyProfileLabel(prof){
14047
14071
  if(mode!=='add'&&picking&&pickKind==='profile'&&selIds.size===1){const id=[...selIds][0];picking=false;edit(()=>{const m=byId(id);ModelCmd.patchMember(m,{profile:prof,rfi:_wtPlf(prof)==null});if(!profs.includes(prof)){profs.push(prof);profs.sort();}});restoreProfilePickerOwnerAfterApply('pickProf');return true;}
@@ -15304,20 +15328,35 @@ function connectionRefusalCopy(d,m){
15304
15328
  };
15305
15329
  return byCode[d.code]||{head:'Not built · Connection was refused',detail:'The connection engine refused '+(d.jointId||'this joint')+' ('+(d.code||'unknown reason')+'). No geometry or member trim was created.'};
15306
15330
  }
15331
+ // The build-status line, written when it SHOWS rather than when the bake landed (#2621): one that waited out a held
15332
+ // answer says what is true then. A diagnostic counts as told only once this line reaches the screen, so one whose
15333
+ // line was replaced or dropped is still said by the next; one that went away meanwhile is not. While a re-bake is
15334
+ // in flight the list is empty, so the line is empty and nothing is marked told. `connectionSkipNote` is the latest
15335
+ // bake's skipped counts, kept until said: a bake without skips clears it.
15336
+ let connectionSkipNote=null;
15337
+ function connectionStatusLine(){
15338
+ const fresh=connectionDiagnostics.filter(d=>!shownConnectionDiagnosticSignatures.has(connectionDiagnosticSignature(d)));
15339
+ const refused=fresh.filter(d=>d.severity==='error').length,adjusted=fresh.filter(d=>d.code==='bolt-gauge-adjusted').length;
15340
+ const limited=fresh.filter(d=>d.code==='support-section-unsupported').length,sk=connectionSkipNote||{unreported:0,noFit:0};
15341
+ const bits=[];
15342
+ if(refused)bits.push(refused+' connection'+(refused>1?'s':'')+' not built');
15343
+ if(adjusted)bits.push(adjusted+' built with an adjusted bolt gauge');
15344
+ if(limited)bits.push(limited+' connection'+(limited>1?'s':'')+' built with limited support-side fit');
15345
+ if(sk.unreported)bits.push(sk.unreported+' connection'+(sk.unreported>1?'s':'')+' not shown in 3D');
15346
+ if(sk.noFit)bits.push(sk.noFit+' member'+(sk.noFit>1?'s':'')+' priced but not drawn — no tabulated footprint');
15347
+ if(!bits.length)return '';
15348
+ for(const d of fresh)shownConnectionDiagnosticSignatures.add(connectionDiagnosticSignature(d));
15349
+ connectionSkipNote=null;
15350
+ return bits.join(' · ')+' — see the member’s Properties panel.';
15351
+ }
15307
15352
  function updateConnectionDiagnostics(raw,announce=true){
15308
15353
  const unique=[],seen=new Set();
15309
15354
  for(const d of (Array.isArray(raw)?raw:[])){if(!d||typeof d!=='object'||!d.jointId||!d.code)continue;const sig=connectionDiagnosticSignature(d);if(seen.has(sig))continue;seen.add(sig);unique.push(d);}
15310
15355
  for(const sig of [...shownConnectionDiagnosticSignatures])if(!seen.has(sig))shownConnectionDiagnosticSignatures.delete(sig);
15311
15356
  const fresh=unique.filter(d=>!shownConnectionDiagnosticSignatures.has(connectionDiagnosticSignature(d)));
15312
15357
  connectionDiagnostics=unique;connectionDiagnosticsStatus='ready';announceConnectionTruth('Connection build status checked.',false);
15313
- for(const d of fresh)shownConnectionDiagnosticSignatures.add(connectionDiagnosticSignature(d));
15314
- if(announce&&fresh.length){
15315
- const refused=fresh.filter(d=>d.severity==='error').length,adjusted=fresh.filter(d=>d.code==='bolt-gauge-adjusted').length;
15316
- const limited=fresh.filter(d=>d.code==='support-section-unsupported').length;
15317
- const bits=[];if(refused)bits.push(refused+' connection'+(refused>1?'s':'')+' not built');if(adjusted)bits.push(adjusted+' built with an adjusted bolt gauge');if(limited)bits.push(limited+' connection'+(limited>1?'s':'')+' built with limited support-side fit');
15318
- toast(bits.join(' · ')+' — see the member’s Properties panel.');
15319
- }
15320
- return {count:fresh.length,refused:fresh.filter(d=>d.severity==='error').length,adjusted:fresh.filter(d=>d.code==='bolt-gauge-adjusted').length,limited:fresh.filter(d=>d.code==='support-section-unsupported').length};
15358
+ if(announce&&fresh.length)statusToast(connectionStatusLine);
15359
+ return fresh.length;
15321
15360
  }
15322
15361
  function applyConnectionBakeTruth(j,announce=true){
15323
15362
  const fresh=updateConnectionDiagnostics(j&&j.diagnostics,false),sk=Array.isArray(j&&j.skipped)?j.skipped:[];
@@ -15328,15 +15367,9 @@ function applyConnectionBakeTruth(j,announce=true){
15328
15367
  // the silence below was justified by, so it gets said (#627).
15329
15368
  const noFit=sk.filter(s=>String(s).startsWith('nofootprint:')).length;
15330
15369
  if(sk.length)console.warn('3D bake skipped '+sk.length+' item(s):',sk);
15331
- if(announce&&(fresh.count||unreported||noFit)){
15332
- const bits=[];
15333
- if(fresh.refused)bits.push(fresh.refused+' connection'+(fresh.refused>1?'s':'')+' not built');
15334
- if(fresh.adjusted)bits.push(fresh.adjusted+' built with an adjusted bolt gauge');
15335
- if(fresh.limited)bits.push(fresh.limited+' connection'+(fresh.limited>1?'s':'')+' built with limited support-side fit');
15336
- if(unreported)bits.push(unreported+' connection'+(unreported>1?'s':'')+' not shown in 3D');
15337
- if(noFit)bits.push(noFit+' member'+(noFit>1?'s':'')+' priced but not drawn — no tabulated footprint');
15338
- toast(bits.join(' · ')+' — see the member’s Properties panel.');
15339
- }
15370
+ if(!announce)return;
15371
+ connectionSkipNote=unreported||noFit?{unreported,noFit}:null;
15372
+ if(fresh||unreported||noFit)statusToast(connectionStatusLine);
15340
15373
  }
15341
15374
  async function fetchScenePayload(contract=C){
15342
15375
  const r=await fetch('/api/contract/'+encodeURIComponent(APP_ID)+'/scene'+PROJECT_QS,{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({contract})});
@@ -15371,6 +15404,7 @@ function connectionTruthRequest(){
15371
15404
  }
15372
15405
  function invalidateConnectionDiagnostics(immediate=false){
15373
15406
  const seq=++connectionDiagnosticsSeq,truth=connectionTruthRequest();
15407
+ connectionSkipNote=null; // the last bake's skips are stale now too; a status line still waiting must not say them (#2621)
15374
15408
  if(connectionDiagnosticsTimer){clearTimeout(connectionDiagnosticsTimer);connectionDiagnosticsTimer=null;}
15375
15409
  connectionPreviewJointByEnd=truth.previewByEnd;
15376
15410
  if((!Array.isArray(C&&C.joints)||!C.joints.length)&&!truth.count){connectionDiagnostics=[];connectionDiagnosticsStatus='ready';announceConnectionTruth('',false);return;}
@@ -22843,12 +22877,14 @@ async function setView(on,{remember=true}={}){
22843
22877
  // Bounded by a WALL-CLOCK deadline rather than a tick count: setTimeout is clamped to >=1s in a
22844
22878
  // background tab, which would stretch a counted 5 s into roughly a hundred.
22845
22879
  let viewWantSeq=0; // any newer request supersedes an outstanding wait
22880
+ let viewChoiceSeq=0; // bumped only by the person's own 2D/3D/Split choice; view3dSettled stops waiting on it
22881
+ let viewRestorePending=false; // the boot restore of the saved layout is queued; a focus request takes it over (#2622)
22846
22882
  function setViewBusy(on){const g=document.getElementById('viewToggle');if(g){if(on)g.setAttribute('aria-busy','true');else g.removeAttribute('aria-busy');}}
22847
22883
  // Both handlers key on the MODE, not on the active pane. Keying on view3d made each a no-op in a split:
22848
22884
  // with the 2D pane active the 2D segment did nothing, with the 3D pane active the 3D segment did nothing,
22849
22885
  // and split became a trap you could not leave by the control that got you into it.
22850
22886
  function requestView2d(){viewWantSeq++;setViewBusy(false);if(viewMode!=='2d')setView('2d');}
22851
- function requestView3d(){
22887
+ function requestView3d({remember=true}={}){
22852
22888
  const want=++viewWantSeq,deadline=Date.now()+5000;
22853
22889
  return new Promise(resolve=>{
22854
22890
  const tick=async()=>{
@@ -22858,7 +22894,7 @@ function requestView3d(){
22858
22894
  try{
22859
22895
  let appliedSeq=viewSeq;
22860
22896
  if(viewMode==='3d'){if(viewTransition)await viewTransition;}
22861
- else{const pending=setView('3d');appliedSeq=viewSeq;await pending;}
22897
+ else{const pending=setView('3d',{remember});appliedSeq=viewSeq;await pending;}
22862
22898
  resolve(want===viewWantSeq&&appliedSeq===viewSeq&&viewMode==='3d');
22863
22899
  }catch(error){console.error('[steel] could not finish changing views',error);resolve(false);}
22864
22900
  return;
@@ -22870,22 +22906,30 @@ function requestView3d(){
22870
22906
  }
22871
22907
  // Split needs the renderer exactly as 3D does, so it waits on the same deadline rather than refusing
22872
22908
  // instantly — see requestView3d's comment above for why an instant refusal is the worse failure.
22873
- function requestViewSplit(){
22909
+ // It answers whether Split landed, so a caller can await it and a newer request still supersedes it while it waits.
22910
+ function requestViewSplit({remember=true}={}){
22874
22911
  const want=++viewWantSeq,deadline=Date.now()+5000;
22912
+ return new Promise(resolve=>{
22875
22913
  const tick=()=>{
22876
- if(want!==viewWantSeq)return;
22877
- if(viewMode==='split'){setViewBusy(false);return;}
22878
- if(window.Steel3DView||Date.now()>=deadline){setViewBusy(false);setView('split');return;}
22914
+ if(want!==viewWantSeq){resolve(false);return;}
22915
+ if(viewMode==='split'){setViewBusy(false);resolve(true);return;}
22916
+ if(window.Steel3DView||Date.now()>=deadline){
22917
+ setViewBusy(false);
22918
+ setView('split',{remember}).then(()=>resolve(want===viewWantSeq&&viewMode==='split'),
22919
+ error=>{console.error('[steel] could not finish changing views',error);resolve(false);});
22920
+ return;
22921
+ }
22879
22922
  setTimeout(tick,50);
22880
22923
  };
22881
22924
  tick();
22925
+ });
22882
22926
  }
22883
22927
  // Each clears pendingView: between the hand-over below and its deferred start, view3d is still false,
22884
22928
  // so a REAL 2D click landing in that gap is a no-op AND would then be overridden by the queued 3D
22885
22929
  // switch — silently doing the opposite of the last thing the user asked for.
22886
- document.getElementById('vt2d').onclick=()=>{pendingView=null;requestView2d();};
22887
- document.getElementById('vt3d').onclick=()=>{pendingView=null;requestView3d();};
22888
- {const s=document.getElementById('vtSplit');if(s)s.onclick=()=>{pendingView=null;requestViewSplit();};}
22930
+ document.getElementById('vt2d').onclick=()=>{pendingView=null;viewChoiceSeq++;requestView2d();};
22931
+ document.getElementById('vt3d').onclick=()=>{pendingView=null;viewChoiceSeq++;requestView3d();};
22932
+ {const s=document.getElementById('vtSplit');if(s)s.onclick=()=>{pendingView=null;viewChoiceSeq++;requestViewSplit();};}
22889
22933
  // CAPTURE phase, so the pane is active BEFORE the canvas's own handler runs: the 3D engine's onDown is
22890
22934
  // itself a capture-phase listener on #stage3d, and it must see inputActive already true.
22891
22935
  document.getElementById('pane2d').addEventListener('pointerdown',()=>setActivePane('2d'),true);
@@ -22941,7 +22985,8 @@ viewHandlersLive=true;
22941
22985
  // hand-over below is: main() is still wiring the state setView acts on.
22942
22986
  if(pendingView===null&&requestedMode!=='2d'){
22943
22987
  const want=requestedMode;
22944
- setTimeout(()=>{if(pendingView!==null)return;setView(want,{remember:false});},0);
22988
+ viewRestorePending=true;
22989
+ setTimeout(()=>{if(pendingView!==null||!viewRestorePending)return;viewRestorePending=false;setView(want,{remember:false});},0);
22945
22990
  }
22946
22991
  // A model without an editable 2D plan defaults to 3D, where the full model is visible.
22947
22992
  //
@@ -24373,7 +24418,9 @@ async function refreshRfiRecords(opts){
24373
24418
  // unknown project, a malformed id, a project with no incarnation yet — carry no code at all, so an
24374
24419
  // arm that switched on one would fall through for a state a real project can reach.
24375
24420
  rfiState={status:'fail',records:live,sizeTruth:'known',liveTruth:j.liveTruth==='unavailable'?'unavailable':'known',detail:'',
24376
- liveDetail:String(j.liveTruthDetail||''),http:r.status||0,error:String((j&&j.error)||'')};
24421
+ liveDetail:String(j.liveTruthDetail||''),http:r.status||0,error:String((j&&j.error)||''),
24422
+ // #2521 row 3b-2: a Quick version's unfiled questions live in the version, so they show even now.
24423
+ quickFiling:Array.isArray(j&&j.quickFiling)?j.quickFiling:[]};
24377
24424
  }else{
24378
24425
  const filed=j.rfis.map(r=>{
24379
24426
  const g=r&&r.liveGap,targets=liveDrawingTargets(g);
@@ -24388,7 +24435,8 @@ async function refreshRfiRecords(opts){
24388
24435
  // reassuring answer, so it is the one that must be earned rather than defaulted to.
24389
24436
  sizeTruth:j.sizeTruth==='known'?'known':'unavailable',
24390
24437
  liveTruth:j.liveTruth==='known'?'known':'unavailable',
24391
- detail:String(j.sizeTruthDetail||''),liveDetail:String(j.liveTruthDetail||''),http:200,error:''};
24438
+ detail:String(j.sizeTruthDetail||''),liveDetail:String(j.liveTruthDetail||''),http:200,error:'',
24439
+ quickFiling:Array.isArray(j.quickFiling)?j.quickFiling:[]};
24392
24440
  }
24393
24441
  }catch(e){
24394
24442
  if(mine!==rfiFetchSeq)return false;
@@ -25899,14 +25947,14 @@ function renderRfiList(){
25899
25947
  :rfiStatusFilter==='all'
25900
25948
  ?'<b>No RFIs yet.</b>Nothing has been asked about this project, and every member has a size FloLess can price.'
25901
25949
  :'<b>Nothing is waiting on an answer.</b>Every question that was asked has been closed, and every member has a size FloLess can price.';
25902
- list.innerHTML='<div class=rfiempty>'+empty+'</div>';
25950
+ list.innerHTML=rfiQuickFilingHtml()+'<div class=rfiempty>'+empty+'</div>';
25903
25951
  wireRfiList();
25904
25952
  rfiRestoreFocus(restore);
25905
25953
  return;
25906
25954
  }
25907
25955
 
25908
25956
  const shown=rows.slice(0,RFI_ROW_CAP);
25909
- let html='';
25957
+ let html=rfiQuickFilingHtml();
25910
25958
  for(const row of shown)html+=(row.kind==='record'?rfiRecordRowHtml(row.record):rfiSymptomRowHtml(row));
25911
25959
  if(rows.length>shown.length)html+='<div class=rfimore>'+(rows.length-shown.length)+' more not listed here — narrow the filter above.</div>';
25912
25960
  list.innerHTML=html;
@@ -26270,7 +26318,7 @@ async function runEditorFocus(req,current){
26270
26318
  if(!m||!current())return null;
26271
26319
  if(!m.ok){
26272
26320
  const said=m.reason==='missing'?m.said+' Ask about it again in the chat.':m.reason==='view'?m.said+' Switch to the 3D view, then press Show in the model again.':m.said;
26273
- toast(said,false,9000);
26321
+ answerToast(said);
26274
26322
  return {ok:false,reason:m.reason,said};
26275
26323
  }
26276
26324
  return {ok:true};
@@ -26286,17 +26334,17 @@ async function runEditorFocus(req,current){
26286
26334
  if(req.raiseRfi){
26287
26335
  const why=r.ok||(r.reason!=='missing'&&r.reason!=='busy')?openRaiseRfi(req.jointId,req.checkId||null):'';
26288
26336
  raise={raised:r.ok||(r.reason!=='missing'&&r.reason!=='busy')?!why:false,...(why?{raiseSaid:why}:{})};
26289
- if(why)toast(why,false,9000);
26337
+ if(why)answerToast(why);
26290
26338
  }
26291
26339
  if(!r.ok){
26292
26340
  const said=r.reason==='missing'?'Connection '+req.jointId+' is no longer in the model. Ask about it again in the chat to get a fresh card.'
26293
26341
  :r.reason==='view'?r.said+' Switch to the 3D view, then press Open in the model again.'
26294
26342
  :r.reason==='unbuilt'&&!(raise&&raise.raised)?r.said+' Its row on the readiness card says why; raise an RFI or record an assumption from there.'
26295
26343
  :r.said;
26296
- toast(said,false,9000);
26344
+ answerToast(said);
26297
26345
  return {ok:false,reason:r.reason,said,...(raise||{})};
26298
26346
  }
26299
- if(r.fallback){toast(r.said,false,9000);return {ok:true,fallback:r.fallback,said:r.said,...(raise||{})};}
26347
+ if(r.fallback){answerToast(r.said);return {ok:true,fallback:r.fallback,said:r.said,...(raise||{})};}
26300
26348
  return {ok:true,...(raise||{})};
26301
26349
  }
26302
26350
  // A bug in the runner still ends in a sentence where the person is looking, and the cause in the console.
@@ -26306,7 +26354,7 @@ EditorFocus.setRunner(async(req,current)=>{
26306
26354
  console.error('[steel] could not show the connection asked for',error);
26307
26355
  if(!current())return null;
26308
26356
  const said=req.memberId?'The model could not show member '+req.memberId+'. Press Show in the model again, or find it in the Model panel.':'The model could not show connection '+req.jointId+'. Press Open in the model again, or find it in the Model panel.';
26309
- toast(said,false,9000);
26357
+ answerToast(said);
26310
26358
  return {ok:false,said};
26311
26359
  }
26312
26360
  });
@@ -26361,8 +26409,11 @@ async function focusConnection(jointId,opts){
26361
26409
  if(!joint)return {ok:false,reason:'missing',said:'Connection '+jointId+' is no longer in the model.'};
26362
26410
  if(o.viewPending)o.viewPending(true);
26363
26411
  let ready=false;
26364
- try{ready=await requestView3d();}finally{if(o.viewPending)o.viewPending(false);}
26412
+ const choice=viewChoiceSeq;
26413
+ try{ready=await requestFocusView();}finally{if(o.viewPending)o.viewPending(false);}
26365
26414
  if(!current())return null;
26415
+ ready=await view3dSettled(ready,current,choice);
26416
+ if(ready===null)return null;
26366
26417
  const busy=o.beforeSelect?o.beforeSelect():'';
26367
26418
  if(busy)return {ok:false,reason:'busy',said:busy};
26368
26419
  const parts=connChildIdsEditor(jointId);
@@ -26373,6 +26424,8 @@ async function focusConnection(jointId,opts){
26373
26424
  if(!selIdOK(main))return {ok:false,reason:'filter',said:'FloLess could not build connection '+jointId+', and its main member '+main+' is excluded by the selection filter. Turn on that member type under Select, then try again.'};
26374
26425
  // The editor's own "go to the main member" sequence (cmpMember): leave any whole-connection selection
26375
26426
  // first, or its envelope, breadcrumb and inspector stay on the connection picked before.
26427
+ // In a split the 3D pane takes the tools — only now, so a refusal never disarms a 2D tool for nothing (#2622).
26428
+ if(viewMode==='split')setActivePane('3d');
26376
26429
  if(modelEditor.isReady()&&modelEditor.steel.clearConnSel)modelEditor.steel.clearConnSel();
26377
26430
  modelSelection.replaceMembers([main]);selDimIds.clear();sel3dDimIds.clear();modelSelection.clearGrids();render();
26378
26431
  if(!selIds.has(main))return {ok:false,reason:'select',said:'FloLess could not build connection '+jointId+', and the 3D view could not select its main member '+main+'.'};
@@ -26387,6 +26440,7 @@ async function focusConnection(jointId,opts){
26387
26440
  if(!ready||!window.Steel3DView)return {ok:false,reason:'view',said:'The 3D view could not show connection '+jointId+'.'};
26388
26441
  if(!parts.length)return {ok:false,reason:'unbuilt',said:'FloLess could not build connection '+jointId+', so the model has nothing of it to show.'};
26389
26442
  if(!parts.every(selIdOK))return {ok:false,reason:'filter',said:'Connection '+jointId+' is excluded by the selection filter. Turn on '+(joint.kind||'its type')+' connections under Select, then try again.'};
26443
+ if(viewMode==='split')setActivePane('3d'); // as above: the 3D pane holds the selection and its tools
26390
26444
  const selectedThisAttempt=treeSelectConn(jointId,{});
26391
26445
  const selected=connSelInfo();
26392
26446
  if(!selectedThisAttempt||!selected||selected.conn!==jointId||!selected.whole)return {ok:false,reason:'select',said:'The 3D view could not select connection '+jointId+'.'};
@@ -26394,24 +26448,55 @@ async function focusConnection(jointId,opts){
26394
26448
  if(modelEditor.dispatch('model.fit-selection')===false)return {ok:false,reason:'frame',said:'Connection '+jointId+' is selected, but it is hidden in the 3D view. Use Show all in the Visibility menu, then press Open in the model again.'};
26395
26449
  return {ok:true};
26396
26450
  }
26451
+ // The 3D view a request needs, in the layout the person chose (#2622). Split already shows a live 3D pane, so it is
26452
+ // kept; a saved Split the boot restore has not applied yet is asked for rather than overridden by full 3D, and
26453
+ // awaited, so cancelling the request (rfiCancelTarget) still stops it. Otherwise full 3D. Neither switch writes
26454
+ // the saved layout: opening a connection is not the person choosing a view. A boot restore still queued is taken
26455
+ // over, since this already honours the saved layout: left to run, it would switch Split a second time under the
26456
+ // rebuild this started, or, on a window too narrow for Split, drop the full 3D asked for back to 2D. A Split taken
26457
+ // over that then does not land (the request was cancelled, or the switch failed) is asked for once more — unless the person chose a view,
26458
+ // a newer request has taken over (it asks for the layout itself, and the hand-back would cancel it), or Split no
26459
+ // longer fits.
26460
+ let focusViewSeq=0;
26461
+ async function requestFocusView(){
26462
+ const restoring=viewRestorePending,choice=viewChoiceSeq,mine=++focusViewSeq;
26463
+ viewRestorePending=false;
26464
+ if(viewMode==='split')return !viewTransition;
26465
+ if(requestedMode==='split'&&splitAvailable){
26466
+ const landed=await requestViewSplit({remember:false});
26467
+ if(!landed&&restoring&&mine===focusViewSeq&&viewChoiceSeq===choice&&splitAvailable&&viewMode!=='split')requestViewSplit({remember:false});
26468
+ return landed;
26469
+ }
26470
+ return requestView3d({remember:false});
26471
+ }
26472
+ // Opened from another step, the editor restores its own last view at the same moment and that supersedes a
26473
+ // requestView3d() (it answers false), although 3D comes up anyway (#2471, #2581): give it a few seconds to settle
26474
+ // before saying it could not show the thing asked for. Split counts, as its 3D pane is live (#2622). Answers whether 3D is up, or null once `current()` says a
26475
+ // newer request replaced this one. A view the person chose themselves since `choice` (viewChoiceSeq, read before the
26476
+ // request) is never waited out: a 2D click means they changed their mind, and a later 3D click must not revive it.
26477
+ async function view3dSettled(ready,current,choice){
26478
+ for(const until=Date.now()+5000;!ready&&viewChoiceSeq===choice&&Date.now()<until;){
26479
+ await new Promise(resolve=>setTimeout(resolve,100));
26480
+ if(!current())return null;
26481
+ ready=viewChoiceSeq===choice&&!!window.Steel3DView&&(viewMode==='3d'||viewMode==='split')&&!viewTransition;
26482
+ }
26483
+ return ready;
26484
+ }
26397
26485
  // #2471: one member, selected and framed in the 3D view — an AI Chat answer's "Show in the model" for a member it cited.
26398
26486
  // The connection fallback's own sequence (cmpMember): leave any connection selection, select the member, frame it.
26399
26487
  async function focusMember(memberId,opts){
26400
26488
  const o=opts||{},current=o.current||(()=>true);
26401
26489
  if(!(C.members||[]).some(m=>m&&m.id===memberId))return {ok:false,reason:'missing',said:'Member '+memberId+' is no longer in the model.'};
26402
- let ready=await requestView3d();
26490
+ const choice=viewChoiceSeq;
26491
+ let ready=await requestFocusView();
26403
26492
  if(!current())return null;
26404
- // Opened from another step, the editor restores its own last view at the same moment and that supersedes this request,
26405
- // although 3D comes up anyway: give it a few seconds to settle before saying it could not show the member.
26406
- for(const until=Date.now()+5000;!ready&&Date.now()<until;){
26407
- await new Promise(resolve=>setTimeout(resolve,100));
26408
- if(!current())return null;
26409
- ready=!!window.Steel3DView&&viewMode==='3d'&&!viewTransition;
26410
- }
26493
+ ready=await view3dSettled(ready,current,choice);
26494
+ if(ready===null)return null;
26411
26495
  const busy=o.beforeSelect?o.beforeSelect():'';
26412
26496
  if(busy)return {ok:false,reason:'busy',said:busy};
26413
26497
  if(!ready||!window.Steel3DView)return {ok:false,reason:'view',said:'The 3D view could not show member '+memberId+'.'};
26414
26498
  if(!selIdOK(memberId))return {ok:false,reason:'filter',said:'Member '+memberId+' is excluded by the selection filter. Turn on that member type under Select, then try again.'};
26499
+ if(viewMode==='split')setActivePane('3d');
26415
26500
  if(modelEditor.isReady()&&modelEditor.steel.clearConnSel)modelEditor.steel.clearConnSel();
26416
26501
  modelSelection.replaceMembers([memberId]);selDimIds.clear();sel3dDimIds.clear();modelSelection.clearGrids();render();
26417
26502
  if(!selIds.has(memberId))return {ok:false,reason:'select',said:'The 3D view could not select member '+memberId+'.'};
@@ -26550,7 +26635,7 @@ function rfiGroupedRecordRowHtml(r){
26550
26635
  const targetView=occ.liveGap?{...occ.liveGap,id:r.id,kind:r.kind,recordRevision:r.recordRevision,liveGapId:occ.liveGap.id}:view;
26551
26636
  const targets=rfiTargetControls(targetView,index);
26552
26637
  const error=rfiTargetErrors.get(key);
26553
- return '<li class=rfioccurrence data-rfi-occurrence="'+index+'"><article aria-labelledby="rfi-occ-'+r.seq+'-'+index+'"><div class=rfioccurrence-head><h4 id="rfi-occ-'+r.seq+'-'+index+'" tabindex="-1">Occurrence '+(index+1)+' of '+count+' — '+esc(rfiGroupedOccurrenceSubject(occ))+'</h4><span class="rfikind '+rfiStatusTone(occ)+'">'+esc(rfiStatusWords(occ))+'</span></div>'
26638
+ 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>'
26554
26639
  +'<div class=rfinote>'+esc(occ.question)+(sheets?' · '+esc(sheets):'')+'</div>'
26555
26640
  +(error?'<div class=rfifail role=alert>'+esc(error.message)+'</div>':'')
26556
26641
  +(occurrenceForm?rfiFormHtml(view,'occurrence '+(index+1)+' of '+count,rowKey):(formOpen?'':'<div class=rfiacts>'+rfiGroupedOccurrenceVerbs(r,occ,rowBusy)+targets+'</div>'))
@@ -26566,6 +26651,60 @@ function rfiGroupedRecordRowHtml(r){
26566
26651
  +(formOpen?'':rfiOutcomeHtml(rowKey))+occurrences+'</div></div>';
26567
26652
  }
26568
26653
 
26654
+ /* #2521 row 3b-2 — "AI" beside a proposal the AI wrote (the sighting's `latestBy`), in a Quick model. Not
26655
+ for `raisedBy` alone: a later sighting by a guided read carries its own proposal and no AI mark. */
26656
+ const RFI_AI_TIP='Proposed by the AI in a Quick model: this answer is the AI\'s decision, not a person\'s.';
26657
+ function rfiAiMark(by){
26658
+ return by==='ai'?'<span class="rfiby ai" tabindex="0" aria-label="'+esc(RFI_AI_TIP)+'" data-tip="'+esc(RFI_AI_TIP)+'">AI</span>':'';
26659
+ }
26660
+ /* Where each Quick version's questions stand, and the ones the AI could not get into the RFI file yet.
26661
+ The counts keep every zero: they are the accounting, and a missing class would read as "none". */
26662
+ let rfiQuickRefileBusy=null;
26663
+ function rfiQuickFilingHtml(){
26664
+ const versions=(rfiState.quickFiling||[]).filter(v=>v&&v.counts);
26665
+ if(!versions.length)return '';
26666
+ const n=x=>x===null||x===undefined?'not known':String(x);
26667
+ return versions.map(v=>{
26668
+ const c=v.counts,unfiled=Array.isArray(v.notFiled)?v.notFiled:[];
26669
+ const counts='<div class=rfinote data-rfi-quick-counts="'+esc(v.versionN)+'">Quick model v'+esc(v.versionN)+': '
26670
+ +esc(n(c.settled))+' settled by the AI · '+esc(n(c.filed))+' filed as AI RFIs · '
26671
+ +(c.filedByLaterRead?esc(c.filedByLaterRead)+' filed by a later read · ':'')
26672
+ +'<b class=rfiwarn>'+esc(n(c.notFiled))+' not filed yet</b> · <b>'+esc(n(c.changedInReview))+' changed in your review</b> · '
26673
+ +esc(n(c.appearedAfter))+' appeared after the AI\'s work'
26674
+ +(c.settledAndGone?' · '+esc(c.settledAndGone)+' settled and gone from the final read':'')
26675
+ +(c.leftOutByAudit?' · '+esc(c.leftOutByAudit)+' left out by the audit':'')+'</div>'
26676
+ +(v.snapshotUnavailable?'<div class=rfinote>'+esc(v.snapshotUnavailable.charAt(0).toUpperCase()+v.snapshotUnavailable.slice(1))+'.</div>':'');
26677
+ if(!unfiled.length)return '<div class=rfiunfiled data-rfi-quick-version="'+esc(v.versionN)+'">'+counts+'</div>';
26678
+ const busy=rfiQuickRefileBusy===v.versionN;
26679
+ const retry=v.rfiFileUnavailable?'':'<div class=rfiacts><button data-command-id="steel.rfi-quick-refile#v'+esc(v.versionN)+'" data-command-instance-label="'+esc('version '+v.versionN)+'" data-rfi-ctl="quick-refile:'+esc(v.versionN)+'" data-rfi-quick-refile="'+esc(v.versionN)+'" data-tip="File the questions version '+esc(v.versionN)+' keeps, as the AI\'s; anything already filed is not filed twice"'
26680
+ +(busy?' aria-busy=true aria-disabled=true data-blocked-reason="These questions are being filed"':'')+'>'+(busy?'Filing…':'Try filing again')+'</button></div>';
26681
+ // With the RFI file unreadable, whether these were filed is not known: the section says so, never "not filed".
26682
+ const unknown=!!v.rfiFileUnavailable,heading=unknown?'Filing status unknown':'Not filed yet';
26683
+ return '<section class=rfiunfiled data-rfi-quick-version="'+esc(v.versionN)+'" aria-label="'+heading+', version '+esc(v.versionN)+'"><div class=glab>'+heading+'</div>'+counts+retry
26684
+ +unfiled.map(q=>'<div class=rfirow data-rfi-quick-unfiled="'+esc(q.gapKey)+'"><span class="rfikind sym">'+(unknown?'status unknown':'not filed')+'</span><div class=rfitx>'+esc(q.question)
26685
+ +'<div class=rfimeta>'+rfiAiMark('ai')+'</div>'
26686
+ +(q.proposed?'<div class=rfinote>AI\'s proposed answer: '+esc(q.proposed)+'</div>':'')
26687
+ +(q.tried?'<div class=rfinote>Tried: '+esc(q.tried)+'</div>':'')
26688
+ +'<div class="rfinote rfiwhy">'+esc(q.reason.charAt(0).toUpperCase()+q.reason.slice(1))+'</div></div></div>').join('')
26689
+ +(v.notFiledHeldBack?'<div class=rfimore>'+esc(v.notFiledHeldBack)+(unknown?' more whose filing status is unknown':' more not filed yet')+' are not listed here.</div>':'')+'</section>';
26690
+ }).join('');
26691
+ }
26692
+ async function rfiQuickRefile(versionN){
26693
+ if(rfiQuickRefileBusy!==null)return;
26694
+ rfiQuickRefileBusy=versionN;renderRfiList();
26695
+ try{
26696
+ const res=await fetch('/api/projects/'+encodeURIComponent(PROJECT)+'/versions/'+encodeURIComponent(versionN)+'/rfis',{method:'POST',headers:{'content-type':'application/json'},body:'{}'});
26697
+ const body=await res.json().catch(()=>null);
26698
+ if(res.ok&&body&&body.ok){
26699
+ const filed=(body.outcomes||[]).filter(o=>['created','reused','reopened','successor'].includes(o.result)).length;
26700
+ const notFiled=(body.outcomes||[]).filter(o=>o.result==='over-capacity'||o.result==='unplaceable').length;
26701
+ toast(filed?filed+' question'+(filed===1?'':'s')+' filed as the AI\'s'+(notFiled?'; '+notFiled+' still could not be filed':'')+'.':notFiled?'Nothing more could be filed: '+notFiled+' still do not fit.':'Nothing was left to file.');
26702
+ }else toast('These questions could not be filed: '+((body&&body.error)||'the RFI file could not be written')+'. Nothing was changed.');
26703
+ }catch(e){console.error('[steel] could not retry filing the AI questions',e);toast('These questions could not be filed, because FloLess could not be reached. Nothing was changed.');}
26704
+ // The button the pointer is over is replaced by the repaint, so no pointer-out ever hides its tip.
26705
+ finally{rfiQuickRefileBusy=null;await refreshRfiRecords();if(rfiOpen())renderRfiList();if(window.__tip)window.__tip.hide();}
26706
+ }
26707
+
26569
26708
  function rfiRecordRowHtml(r){
26570
26709
  if(r&&r.grouped)return rfiGroupedRecordRowHtml(r);
26571
26710
  const rowKey=rfiRowKey('record',r.id);
@@ -26591,7 +26730,7 @@ function rfiRecordRowHtml(r){
26591
26730
  +rfiElevationControls(rowKey,r.id,g)
26592
26731
  +'<div class=rfiacts>'+copy+targets+'</div></div></div>';
26593
26732
  }
26594
- const meta=['<span>'+esc(r.id)+'</span>','<span>'+esc(rfiStatusWords(r))+'</span>']
26733
+ const meta=[rfiAiMark(r.latestBy),'<span>'+esc(r.id)+'</span>','<span>'+esc(rfiStatusWords(r))+'</span>']
26595
26734
  .concat(ids.slice(0,6).map(id=>'<span>'+esc(id)+'</span>'))
26596
26735
  .concat(sheets.map(sh=>'<span>Sheet '+esc(sh)+'</span>'))
26597
26736
  .join('');
@@ -26612,7 +26751,10 @@ function rfiRecordRowHtml(r){
26612
26751
  if(r.applied)notes.push('Recorded as applied to the model on '+esc(rfiWhen(r.applied.at))+'.');
26613
26752
  if(r.closed)notes.push('Closed '+esc(rfiDispositionWords(r.closed.disposition))
26614
26753
  +' on '+esc(rfiWhen(r.closed.at))+(r.closed.note?' — '+esc(rfiSentence(r.closed.note)):'.'));
26615
- if(r.proposed)notes.push('FloLess would have proceeded with '+esc(rfiSentence(r.proposed)));
26754
+ // #2521 row 3b-2: the AI's recommendation. Not "built on": a question about an unbuilt connection or an unresolved
26755
+ // placement was never applied, and a later edit can change the model (Codex review).
26756
+ if(r.proposed)notes.push(r.latestBy==='ai'?'The AI’s proposed answer: '+esc(rfiSentence(r.proposed))
26757
+ :'FloLess would have proceeded with '+esc(rfiSentence(r.proposed)));
26616
26758
  if(r.targetsOmitted)notes.push('Showing '+esc((r.targets||[]).filter(t=>t&&t.where==='drawing').length)+' drawing locations. '+esc(r.targetsOmitted)+' additional drawing locations are not available here.');
26617
26759
  if(r.kind==='unbuilt-connection'&&r.subjectsOmitted)notes.push(esc(r.subjectsOmitted)+' additional verified markers are not listed in this RFI.');
26618
26760
  // The one member a Locate can fly to — only ids the model STILL has, since the list may have been
@@ -26980,6 +27122,7 @@ function wireRfiList(){
26980
27122
  const scopeKind=b.dataset.rfiScopeKind;
26981
27123
  // `promote` comes off the CARRIER, because the row key alone cannot say which namespace it is in.
26982
27124
  if(v==='apply')return Promise.resolve(rfiApplyAction(id,occurrence)).catch(rfiGestureFailure);return rfiOpenForm(id,v,promote,occurrence,scopeKind);});
27125
+ root.querySelectorAll('[data-rfi-quick-refile]').forEach(b=>b.onclick=()=>Promise.resolve(rfiQuickRefile(Number(b.dataset.rfiQuickRefile))).catch(rfiGestureFailure));
26983
27126
  root.querySelectorAll('[data-rfi-expand]').forEach(b=>b.onclick=()=>{
26984
27127
  const id=b.dataset.rfiExpand;if(rfiExpandedGroups.has(id))rfiExpandedGroups.delete(id);else rfiExpandedGroups.add(id);
26985
27128
  rfiFocusOverride={rows:[rfiRowKey('record',id)],ctl:'expand'};renderRfiList();});
@@ -0,0 +1,119 @@
1
+ /* The chooser points to chat's existing recovery controls; it never ends a reply or switches a folder. */
2
+ (() => {
3
+ const modal = document.getElementById('workspace-root-modal');
4
+ if (!modal) return;
5
+ const section = document.createElement('section');
6
+ section.className = 'workspace-root-management workspace-root-recovery';
7
+ section.setAttribute('aria-label', 'Replies to check before switching folders');
8
+ modal.querySelector('#workspace-root-status').after(section);
9
+ let data = null, problem = '', reading = false, sequence = 0, navigation = 0;
10
+ let shown = modal.classList.contains('show');
11
+ const root = () => window.flolessWorkspaceRoot?.current()?.root;
12
+ const sameRoot = (a, b) => !!a && !!b && a.rootId === b.rootId && a.generation === b.generation;
13
+ const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
14
+ function availability() {
15
+ const reload = section.querySelector('[data-recovery-reload]');
16
+ if (reload) {
17
+ reload.setAttribute('aria-disabled', String(reading));
18
+ if (reading) {
19
+ reload.setAttribute('aria-busy', 'true');
20
+ reload.setAttribute('data-blocked-reason', 'FloLess is reading the recorded replies.');
21
+ } else { reload.removeAttribute('aria-busy'); reload.removeAttribute('data-blocked-reason'); }
22
+ }
23
+ const busy = reading || window.flolessWorkspaceRoot?.isBusy?.();
24
+ for (const button of section.querySelectorAll('[data-recovery-open]')) {
25
+ button.setAttribute('aria-disabled', String(!!busy));
26
+ if (busy) {
27
+ button.setAttribute('aria-busy', 'true');
28
+ button.setAttribute('data-blocked-reason', reading ? 'FloLess is reading the recorded replies.' : 'A folder choice or review is in progress. Let it finish before opening a conversation.');
29
+ } else { button.removeAttribute('aria-busy'); button.removeAttribute('data-blocked-reason'); }
30
+ }
31
+ }
32
+ function render() {
33
+ const focused = section.contains(document.activeElement);
34
+ const key = focused ? document.activeElement?.getAttribute('data-recovery-chat') : null;
35
+ section.setAttribute('aria-busy', String(reading));
36
+ let html = '<h3 tabindex="-1">Replies to check before switching folders</h3>';
37
+ html += '<p class="workspace-root-management-note">Open a conversation to check its reply and use its recovery controls. Afterwards, reopen this chooser and choose the folder again.</p>';
38
+ html += reading ? '<p class="workspace-root-management-message" role="status">Reading recorded replies…</p>' : '';
39
+ if (problem) html += `<p class="workspace-root-error" role="alert">${esc(problem)}</p>`;
40
+ if (data) {
41
+ if (data.startupWarning) html += '<p class="workspace-root-management-note">FloLess did not finish checking replies from before it restarted. These are the records it can read now; open a conversation to check it.</p>';
42
+ if (data.unreadableCount || data.ownershipUnavailable) html += '<p class="workspace-root-management-note">Some recorded replies could not be read. Reconnect or restore this directory if it is unavailable, then reload this list. Other replies are listed below.</p>';
43
+ if (data.protectedCount) html += '<p class="workspace-root-management-note">A recorded reply belongs to another account’s Guide. Sign in as the account that started that Guide to recover its reply.</p>';
44
+ if (data.replies.length) {
45
+ html += '<div class="workspace-root-management-list">';
46
+ data.replies.forEach((reply, index) => {
47
+ const owner = reply.owner.kind === 'workspace' ? 'Workspace conversation' : reply.owner.kind === 'workflow' ? 'Workflow conversation' : 'Project conversation';
48
+ const time = new Date(reply.startedAt);
49
+ html += `<div class="workspace-root-management-row"><div style="overflow-wrap:anywhere"><strong>${esc(reply.title)}</strong><br>` +
50
+ `<span class="workspace-root-management-state">${owner}${reply.archived ? ' · Archived' : ''} · Reply started ${esc(Number.isFinite(time.getTime()) ? time.toLocaleString() : 'at an unknown time')}<br>${esc(reply.state)}</span></div>` +
51
+ `<button type="button" data-recovery-open="${index}" data-recovery-chat="${esc(reply.chatId)}" data-command-id="shell.workspace-root-recovery-open#${esc(reply.chatId)}" data-command-instance-label="${esc(reply.title)}">Open conversation</button></div>`;
52
+ });
53
+ html += '</div>';
54
+ } else if (!data.protectedCount && !data.unreadableCount && !data.ownershipUnavailable) html += '<p class="workspace-root-management-note">No replies to show. Choose the folder again to check whether it can switch.</p>';
55
+ if (data.otherWork.length) html += '<p class="workspace-root-management-note">Other recorded work: ' + data.otherWork.map(row => esc(row.label)).join(' · ') + '.</p>';
56
+ if (data.recordedCount) html += '<p class="workspace-root-management-note">Some records may clear when you choose the folder again. This list does not guarantee the directory can switch.</p>';
57
+ }
58
+ html += '<button type="button" data-recovery-reload data-command-id="shell.workspace-root-recovery-reload">Reload replies</button>';
59
+ section.innerHTML = html;
60
+ availability();
61
+ if (focused) (key === null ? section.querySelector('[data-recovery-reload]') : [...section.querySelectorAll('[data-recovery-chat]')].find(button => button.dataset.recoveryChat === key) || section.querySelector('h3'))?.focus();
62
+ }
63
+ async function session() {
64
+ const response = await fetch('/api/chat/session', { credentials: 'same-origin' });
65
+ if (!response.ok) throw new Error('FloLess could not open a local chat session. Close this chooser and open it again.');
66
+ }
67
+ async function load() {
68
+ const mine = ++sequence, captured = root();
69
+ reading = true; problem = ''; render();
70
+ try {
71
+ await session();
72
+ let response = await fetch('/api/chat/recovery', { credentials: 'same-origin' });
73
+ if (response.status === 401) { await session(); response = await fetch('/api/chat/recovery', { credentials: 'same-origin' }); }
74
+ if (!response.ok) throw new Error('FloLess could not read the recorded replies. Reconnect or restore this directory if it is unavailable, then reload this list.');
75
+ const next = await response.json();
76
+ if (mine !== sequence || !shown || !sameRoot(captured, root())) return;
77
+ if (!sameRoot(next.root, captured) || !Array.isArray(next.replies) || !Array.isArray(next.otherWork)) throw new Error('The Workspace directory changed. Reload this list before opening a conversation.');
78
+ data = next;
79
+ } catch (error) { if (mine === sequence && shown && sameRoot(captured, root())) problem = error.message; }
80
+ finally { if (mine === sequence) { reading = false; render(); } }
81
+ }
82
+ section.addEventListener('click', async event => {
83
+ const button = event.target.closest('[data-recovery-open], [data-recovery-reload]');
84
+ if (!button || reading) return;
85
+ if (button.hasAttribute('data-recovery-reload')) { void load(); return; }
86
+ const captured = root(), reply = data?.replies[Number(button.dataset.recoveryOpen)];
87
+ if (!reply || !sameRoot(data.root, captured)) { problem = 'The Workspace directory changed. Reload this list first.'; render(); return; }
88
+ if (window.flolessWorkspaceRoot?.isBusy?.()) { problem = 'A folder choice or review is in progress. Let it finish before opening a conversation.'; render(); return; }
89
+ const open = window.flolessChat?.openConversationIn;
90
+ if (typeof open !== 'function') { problem = 'AI Chat is not ready. Close this chooser, then open AI Chat and try again.'; render(); return; }
91
+ if (!window.flolessWorkspaceRoot?.close?.()) { problem = 'A folder choice or review is in progress. Let it finish, then try again.'; render(); return; }
92
+ const mine = ++navigation;
93
+ try {
94
+ const opened = await open({ owner: reply.owner, label: reply.title }, reply.chatId);
95
+ if (mine !== navigation || !sameRoot(captured, root()) || modal.classList.contains('show')) return;
96
+ if (!opened) throw new Error('FloLess could not open that conversation. Reload this list and try again.');
97
+ const recovery = document.getElementById('chat-recovery-stop');
98
+ (recovery && !recovery.hidden ? recovery : document.getElementById('chat-input'))?.focus();
99
+ } catch (error) {
100
+ if (mine !== navigation || !sameRoot(captured, root())) return;
101
+ await window.flolessWorkspaceRoot.open();
102
+ problem = error.message; render();
103
+ }
104
+ });
105
+ new MutationObserver(records => {
106
+ const open = modal.classList.contains('show');
107
+ if (open !== shown) {
108
+ shown = open; sequence += 1; reading = false;
109
+ if (open) { navigation += 1; data = null; void load(); }
110
+ }
111
+ if (records.some(record => !section.contains(record.target) && record.target !== section)) availability();
112
+ }).observe(modal, { attributes: true, subtree: true, attributeFilter: ['class', 'aria-busy'] });
113
+ window.addEventListener('floless:workspace-root-state', () => {
114
+ if (data && !sameRoot(data.root, root())) { navigation += 1; data = null; }
115
+ if (shown) void load();
116
+ });
117
+ render();
118
+ if (shown) void load();
119
+ })();