@floless/app 0.99.0 → 0.99.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53106,7 +53106,7 @@ function appVersion() {
53106
53106
  return resolveVersion({
53107
53107
  isSea: isSea2(),
53108
53108
  sqVersionXml: readSqVersionXml(),
53109
- define: true ? "0.99.0" : void 0,
53109
+ define: true ? "0.99.1" : void 0,
53110
53110
  pkgVersion: readPkgVersion()
53111
53111
  });
53112
53112
  }
@@ -53116,7 +53116,7 @@ function resolveChannel(s) {
53116
53116
  return "dev";
53117
53117
  }
53118
53118
  function appChannel() {
53119
- return resolveChannel({ isSea: isSea2(), define: true ? "0.99.0" : void 0 });
53119
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.99.1" : void 0 });
53120
53120
  }
53121
53121
 
53122
53122
  // workflow-update.ts
@@ -1490,7 +1490,7 @@ function edit(fn){const pv=snapshot();fn();pushUndo(pv);render();sync3D();}
1490
1490
  // --- auto-save: edits persist to this browser (localStorage). Raster stays embedded; only members + TOS are stored. ---
1491
1491
  const LSKEY = 'steeltakeoff:edits:v1:' + APP_ID;
1492
1492
  function dataSig(){return C.plans.map(p=>p.sheet+':'+((p.segments||[]).length)).join('|');} // ignore stored edits if the dataset changed
1493
- let saveT=null;
1493
+ let saveT=null, saveSeq=0; // saveSeq: monotonic id per server save. Only the LATEST save's response may set the pill — an older in-flight PUT that resolves late must not overwrite a newer verdict (e.g. a stale 'ok' clobbering a fresh 'err').
1494
1494
  function setSaved(state,msg){const el=document.getElementById('saveStat');if(!el)return;el.classList.remove('dirty','ok','err');
1495
1495
  if(state==='ok'){el.classList.add('ok');el.textContent=msg||'Saved ✓';}
1496
1496
  else if(state==='dirty'){el.classList.add('dirty');el.textContent='Saving…';}
@@ -1502,19 +1502,23 @@ function setSaved(state,msg){const el=document.getElementById('saveStat');if(!el
1502
1502
  // snapshots as-is (activateView applies each defensively — a malformed sub-snapshot is caught, not fatal —
1503
1503
  // since the engine's setClipState does NOT re-sanitise its input), and caps the list at 10.
1504
1504
  function sanitizeViews(arr){if(!Array.isArray(arr))return [];const out=[];for(const v of arr){if(!v||typeof v!=='object')continue;const id=(typeof v.id==='string'&&v.id)?v.id:('v'+Math.random().toString(36).slice(2,9));const name=(typeof v.name==='string'&&v.name.trim())?v.name.slice(0,80):'View';out.push({v:1,id,name,order:typeof v.order==='number'?v.order:out.length,camera:(v.camera&&typeof v.camera==='object')?v.camera:null,projection:v.projection==='ortho'?'ortho':'persp',mode:['solid','wire','xray'].includes(v.mode)?v.mode:'solid',clips:(v.clips&&typeof v.clips==='object')?v.clips:null,objects:(v.objects&&typeof v.objects==='object')?v.objects:null});if(out.length>=10)break;}return out;}
1505
+ // B9: do NOT flip to 'Saved ✓' here. localStorage is the instant per-browser draft; the durable copy is the
1506
+ // async persistServer() PUT (or flushContract()), which resolves later and OWNS the 'ok'/'err' transition — so
1507
+ // green means the server truly has it. Every persist() caller is paired with such a server write (before or
1508
+ // after), so the pill always resolves. A localStorage write failure is still logged + flagged 'err' here.
1505
1509
  function persist(){try{localStorage.setItem(LSKEY,JSON.stringify({sig:dataSig(),ts:Date.now(),active:C.active,
1506
1510
  custom_details:C.custom_details, profile_colors:C.profile_colors, member_styles:C.member_styles, member_types:C.member_types, target_confidence:C.target_confidence, dims3d:C.dims3d, dim_overlays:C.dim_overlays, dim_style:C.dim_style, prop_labels:C.prop_labels, joints:C.joints, detail_placements:C.detail_placements, views:C.views,
1507
- plans:C.plans.map(p=>({sheet:p.sheet,members:p.members,default_tos:p.default_tos,details:p.details,dims:p.dims,frame:p.frame||null,grid:p.grid||null}))}));setSaved('ok');}catch(e){setSaved('err');console.error('local autosave failed',e);}}
1511
+ plans:C.plans.map(p=>({sheet:p.sheet,members:p.members,default_tos:p.default_tos,details:p.details,dims:p.dims,frame:p.frame||null,grid:p.grid||null}))}));}catch(e){setSaved('err');console.error('local autosave failed',e);}}
1508
1512
  // --- server-side draft save: PUT the FULL contract C — this is the copy Approve bakes.
1509
1513
  // localStorage (persist) stays the instant per-browser draft cache; this is the durable one.
1510
1514
  // fetch does NOT reject on HTTP 400 (schema rejection), so treat !res.ok as 'err' (not a false 'Saved ✓'). ---
1511
- async function persistServer(){try{
1515
+ async function persistServer(){const seq=saveSeq;try{ // capture THIS intent's id (scheduleSave already bumped saveSeq for the edit) — a newer edit/flush bumps it again and invalidates this PUT's late response
1512
1516
  lastLocalPut = Date.now();
1513
1517
  const res=await fetch('/api/contract/'+encodeURIComponent(APP_ID)+PROJECT_QS,{method:'PUT',headers:{'content-type':'application/json'},body:JSON.stringify(C)});
1514
- setSaved(res.ok?'ok':'err');
1518
+ if(seq===saveSeq)setSaved(res.ok?'ok':'err'); // only the latest save owns the pill (a stale late response must not clobber a newer verdict)
1515
1519
  if(!res.ok)console.error('server save rejected ('+res.status+')',await res.text().catch(()=>'')); // 400 = schema reject: edits won't be what Approve bakes
1516
- }catch(e){setSaved('err');console.error('server save failed',e);}}
1517
- function scheduleSave(){setSaved('dirty');clearTimeout(saveT);saveT=setTimeout(()=>{persist();persistServer();},500);}
1520
+ }catch(e){if(seq===saveSeq)setSaved('err');console.error('server save failed',e);}}
1521
+ function scheduleSave(){setSaved('dirty');++saveSeq;clearTimeout(saveT);saveT=setTimeout(()=>{persist();persistServer();},500);} // ++saveSeq: a fresh edit is a new save intent — it invalidates any still-in-flight PUT so that PUT's late response can't flip the pill to a stale 'Saved ✓' while this edit is still unsaved (persistServer below captures this same intent id)
1518
1522
  // Flush: cancel the pending debounce and PUT the current in-memory contract to the
1519
1523
  // server right now. The parent (aware.js #contract-editor-approve) awaits this before
1520
1524
  // POSTing approve, so Approve always bakes the latest edits — not a stale debounce
@@ -1522,10 +1526,17 @@ function scheduleSave(){setSaved('dirty');clearTimeout(saveT);saveT=setTimeout((
1522
1526
  window.flushContract = async () => {
1523
1527
  clearTimeout(saveT);
1524
1528
  lastLocalPut = Date.now();
1525
- const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS, {
1526
- method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(C),
1527
- });
1528
- setSaved(res.ok ? 'ok' : 'err');
1529
+ const seq = ++saveSeq;
1530
+ let res;
1531
+ try {
1532
+ res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS, {
1533
+ method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(C),
1534
+ });
1535
+ } catch (e) {
1536
+ if (seq === saveSeq) setSaved('err'); // B9: a network rejection must show "Save failed", not leave the pill stuck on "Saving…" (this fn cancels the debounced persistServer that would otherwise flag it)
1537
+ throw e; // still reject so the parent (Approve) aborts — regardless of seq
1538
+ }
1539
+ if (seq === saveSeq) setSaved(res.ok ? 'ok' : 'err'); // only the latest save owns the pill
1529
1540
  if (!res.ok) throw new Error('save failed (' + res.status + ')');
1530
1541
  };
1531
1542
  function restoreSaved(){try{const raw=localStorage.getItem(LSKEY);if(!raw)return false;const d=JSON.parse(raw);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.99.0",
3
+ "version": "0.99.1",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {