@floless/app 0.93.1 → 0.94.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.93.1" : void 0,
53109
+ define: true ? "0.94.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.93.1" : void 0 });
53119
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.94.1" : void 0 });
53120
53120
  }
53121
53121
 
53122
53122
  // workflow-update.ts
@@ -54466,6 +54466,40 @@ function deleteArchivedProject(id) {
54466
54466
  // knowledge-routes.ts
54467
54467
  var import_node_fs22 = require("node:fs");
54468
54468
 
54469
+ // sse.ts
54470
+ var clients = /* @__PURE__ */ new Set();
54471
+ var HEARTBEAT_MS = 2e4;
54472
+ function addClient(reply) {
54473
+ clients.add(reply);
54474
+ const ping2 = setInterval(() => {
54475
+ try {
54476
+ reply.raw.write(":ping\n\n");
54477
+ } catch {
54478
+ clearInterval(ping2);
54479
+ clients.delete(reply);
54480
+ }
54481
+ }, HEARTBEAT_MS);
54482
+ reply.raw.on("close", () => {
54483
+ clearInterval(ping2);
54484
+ clients.delete(reply);
54485
+ });
54486
+ }
54487
+ function broadcast(event) {
54488
+ const frame = `data: ${JSON.stringify(event)}
54489
+
54490
+ `;
54491
+ for (const reply of clients) {
54492
+ try {
54493
+ reply.raw.write(frame);
54494
+ } catch {
54495
+ clients.delete(reply);
54496
+ }
54497
+ }
54498
+ }
54499
+ function clientCount() {
54500
+ return clients.size;
54501
+ }
54502
+
54469
54503
  // knowledge-store.ts
54470
54504
  var import_node_crypto7 = require("node:crypto");
54471
54505
  var import_node_fs21 = require("node:fs");
@@ -55204,6 +55238,36 @@ function knowledgeErrorStatus(e) {
55204
55238
  if (e.code === "io-error") return 500;
55205
55239
  return 400;
55206
55240
  }
55241
+ var QUEUED_ORGANIZE_TTL_MS = 24 * 60 * 60 * 1e3;
55242
+ function organizeInFlight(projectId, now = Date.now()) {
55243
+ if (readOrganize(projectId) !== null) return true;
55244
+ const lock = readLock(projectId);
55245
+ return lock !== null && now - lock.createdAt < LOCK_STALE_MS;
55246
+ }
55247
+ function expiredOrganizeRequestIds(requests, isInFlight, now, ttlMs = QUEUED_ORGANIZE_TTL_MS) {
55248
+ const out = [];
55249
+ for (const r of requests) {
55250
+ if (r.type !== "knowledge-organize" || !r.project) continue;
55251
+ const age = now - Date.parse(r.createdAt);
55252
+ if (!Number.isFinite(age) || age <= ttlMs) continue;
55253
+ if (isInFlight(r.project)) continue;
55254
+ out.push(r.id);
55255
+ }
55256
+ return out;
55257
+ }
55258
+ function sweepExpiredOrganizeRequests(now = Date.now()) {
55259
+ const ids = expiredOrganizeRequestIds(listRequests(), (p) => organizeInFlight(p, now), now);
55260
+ let swept = 0;
55261
+ for (const id of ids) {
55262
+ try {
55263
+ if (deleteRequest(id)) swept++;
55264
+ } catch (e) {
55265
+ console.warn(`sweepExpiredOrganizeRequests: could not delete ${id}: ${e instanceof Error ? e.message : e}`);
55266
+ }
55267
+ }
55268
+ if (swept > 0) broadcast({ type: "requests-changed" });
55269
+ return swept;
55270
+ }
55207
55271
  function registerKnowledgeRoutes(app) {
55208
55272
  app.post(
55209
55273
  "/api/projects/:id/knowledge/sources",
@@ -55428,6 +55492,28 @@ function registerKnowledgeRoutes(app) {
55428
55492
  }
55429
55493
  }
55430
55494
  );
55495
+ app.delete(
55496
+ "/api/projects/:id/knowledge/requests/:requestId",
55497
+ async (req, reply) => {
55498
+ try {
55499
+ const project = getProject(req.params.id);
55500
+ if (!project) return reply.status(404).send({ ok: false, error: `unknown project: ${req.params.id}` });
55501
+ if (!resolveOrganizeRequest(project.id, req.params.requestId)) {
55502
+ return reply.status(404).send({ ok: false, error: "unknown organize request", code: "not-found" });
55503
+ }
55504
+ if (organizeInFlight(project.id)) {
55505
+ return reply.status(409).send({ ok: false, error: "organize already started \u2014 it can no longer be cancelled", code: "already-started" });
55506
+ }
55507
+ deleteRequest(req.params.requestId);
55508
+ broadcast({ type: "requests-changed" });
55509
+ return { ok: true };
55510
+ } catch (e) {
55511
+ if (e instanceof ProjectError) return reply.status(400).send({ ok: false, error: e.message });
55512
+ if (e instanceof KnowledgeError) return reply.status(knowledgeErrorStatus(e)).send({ ok: false, error: e.message });
55513
+ throw e;
55514
+ }
55515
+ }
55516
+ );
55431
55517
  }
55432
55518
 
55433
55519
  // project-versions-store.ts
@@ -62235,40 +62321,6 @@ var import_node_path29 = require("node:path");
62235
62321
  var import_node_fs32 = require("node:fs");
62236
62322
  var import_node_path28 = require("node:path");
62237
62323
 
62238
- // sse.ts
62239
- var clients = /* @__PURE__ */ new Set();
62240
- var HEARTBEAT_MS = 2e4;
62241
- function addClient(reply) {
62242
- clients.add(reply);
62243
- const ping2 = setInterval(() => {
62244
- try {
62245
- reply.raw.write(":ping\n\n");
62246
- } catch {
62247
- clearInterval(ping2);
62248
- clients.delete(reply);
62249
- }
62250
- }, HEARTBEAT_MS);
62251
- reply.raw.on("close", () => {
62252
- clearInterval(ping2);
62253
- clients.delete(reply);
62254
- });
62255
- }
62256
- function broadcast(event) {
62257
- const frame = `data: ${JSON.stringify(event)}
62258
-
62259
- `;
62260
- for (const reply of clients) {
62261
- try {
62262
- reply.raw.write(frame);
62263
- } catch {
62264
- clients.delete(reply);
62265
- }
62266
- }
62267
- }
62268
- function clientCount() {
62269
- return clients.size;
62270
- }
62271
-
62272
62324
  // trigger-sessions.ts
62273
62325
  var import_node_fs31 = require("node:fs");
62274
62326
  var import_node_os16 = require("node:os");
@@ -67934,7 +67986,10 @@ async function startServer() {
67934
67986
  broadcast({ type: "steel-favourites-changed" });
67935
67987
  return { ok: true };
67936
67988
  });
67937
- app.get("/api/requests", async () => ({ ok: true, requests: listRequests() }));
67989
+ app.get("/api/requests", async () => {
67990
+ sweepExpiredOrganizeRequests();
67991
+ return { ok: true, requests: listRequests() };
67992
+ });
67938
67993
  app.get("/api/requests/:id/snapshot/:n", async (req, reply) => {
67939
67994
  const n = Number.parseInt(req.params.n, 10);
67940
67995
  const p = Number.isInteger(n) ? snapshotPathFor(req.params.id, n) : null;
package/dist/web/app.css CHANGED
@@ -3473,6 +3473,9 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
3473
3473
  .ws-card .ws-kebab { background:transparent; border:1px solid transparent; color:var(--text-dim);
3474
3474
  padding:2px 7px; border-radius:4px; font-size:14px; line-height:1; flex:none; }
3475
3475
  .ws-card .ws-kebab:hover { border-color:var(--border-strong); color:var(--text); }
3476
+ /* Just-duplicated / just-renamed card gets one glow so the eye finds it before the background reload lands. */
3477
+ .ws-card.is-new { border-color:var(--accent-bright); animation:card-pulse 0.6s ease-in-out; }
3478
+ @media (prefers-reduced-motion: reduce) { .ws-card.is-new { animation:none; box-shadow:0 0 0 1px var(--accent); } }
3476
3479
  /* Archived projects ("Trash") — a collapsed disclosure below the live grid. Demoted vs .ws-card:
3477
3480
  flat rows in one contained panel, muted text — reads as "put away", not "open me". */
3478
3481
  .ws-archived { margin-top:22px; border-top:1px solid var(--border); padding-top:10px; }
@@ -3879,6 +3882,17 @@ tr.hist-diff-row[hidden] { display:none; }
3879
3882
  .kb-spin { width:11px; height:11px; border:2px solid var(--accent-dim); border-top-color:var(--accent-bright);
3880
3883
  border-radius:50%; animation:spin .8s linear infinite; flex:none; }
3881
3884
  @media (prefers-reduced-motion: reduce) { .kb-spin { animation:none; } }
3885
+ /* Cancel a QUEUED organize — a quiet link-style action flowing inline at the end of the "waiting to
3886
+ start…" line (the rail is too narrow to pin a separate control beside wrapping text). Cancel DELETES
3887
+ a queued request, so it follows the house "reversible destructive" idiom (#requests-clear / .ws-del):
3888
+ neutral at rest, var(--err) on hover — NOT the .kb-fname navigation hover. Overrides the global
3889
+ `select, button` grey-surface base to a bare text button; only existing tokens; data-tip, never title. */
3890
+ .kb-pending-cancel { font:inherit; font-size:10.5px; background:none; border:none; padding:0; margin-left:6px;
3891
+ color:var(--text-dim); cursor:pointer; text-decoration:underline; text-underline-offset:2px;
3892
+ text-decoration-color:transparent; transition:color .12s, text-decoration-color .12s; }
3893
+ .kb-pending-cancel:hover { color:var(--err); text-decoration-color:color-mix(in srgb, var(--err) 55%, transparent); }
3894
+ .kb-pending-cancel:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:2px; }
3895
+ .kb-pending-cancel:disabled { opacity:.6; cursor:default; text-decoration:none; }
3882
3896
 
3883
3897
  /* Stage C/D placeholder — reads as forthcoming, never as a broken blank canvas. */
3884
3898
  .kb-placeholder { background:var(--bg); display:flex; align-items:center; justify-content:center; padding:24px;
@@ -182,20 +182,21 @@ export function projectToPlane(p, origin, normal) {
182
182
  }
183
183
 
184
184
  /**
185
- * Signed world distance t from axisP to the point on the axis line closest to the cursor ray
186
- * (rayO + s·rayD) — the standard closest-approach of two lines. axisN is normalized internally,
187
- * so t is a distance along the UNIT axis n̂ and the locked point is `axisP + t·n̂` (NOT axisP +
188
- * t·axisN for a non-unit axisN). Returns null when the ray is ~parallel to the axis (Top-view
189
- * degeneracy: |r̂·n̂| > ~0.999), where the closest-approach is singular and the caller must fall
190
- * back to a screen-space map. rayD/axisN need not be unit — both are normalized here.
185
+ * Does a candidate's proposed point (for `dragged`) lie ON the plane (origin,normal), within `tolMm`?
186
+ * Backs the 3D "workplane-only" snap mode (the SNAP-bar 3D toggle, off). `dragged` here is the cursor's
187
+ * point already resolved on the working plane. On a HORIZONTAL working plane, plan-steering candidates
188
+ * (columns / grid) keep the dragged Z (see candidatePoint), which IS the level, so they lie on the plane
189
+ * and stay snappable; a fixed point (end / mid / intersection) or a centerline passes only where it
190
+ * genuinely meets the plane. On a TILTED plane a plan-steering candidate's own X/Y pushes it off, so it
191
+ * would drop — hence the caller (candOnActiveWP) only applies this gate on a level plane. Pure — no DOM.
192
+ * The signed distance uses the full normalized normal, so it is correct for any orientation. tolMm
193
+ * defaults to 1 mm (on-plane candidates land exactly — Z is tos_inches × 25.4 — this only absorbs rounding).
191
194
  */
192
- export function rayAxisT(rayO, rayD, axisP, axisN) {
193
- const r = _norm(rayD), n = _norm(axisN);
194
- if (!r || !n) return null;
195
- const b = _dot(r, n), denom = 1 - b * b; // 1 − cos²θ; → 0 as the ray aligns with the axis
196
- if (denom < 2e-3) return null; // |r̂·n̂| > ~0.999 → singular; caller maps screen-Y → t
197
- const w = [rayO[0] - axisP[0], rayO[1] - axisP[1], rayO[2] - axisP[2]];
198
- return (_dot(n, w) - b * _dot(r, w)) / denom; // t = (e − b·d)/denom, unit basis so a=c=1
195
+ export function candidateOnPlane(c, dragged, origin, normal, tolMm = 1) {
196
+ const p = candidatePoint(c, dragged);
197
+ const n = _norm(normal) || [0, 0, 1];
198
+ const d = (p[0] - origin[0]) * n[0] + (p[1] - origin[1]) * n[1] + (p[2] - origin[2]) * n[2];
199
+ return Math.abs(d) <= tolMm;
199
200
  }
200
201
 
201
202
  /** Plane from 3 picked points (Tekla flow): origin=a, xAxis toward b, normal = x̂ × (c−a). null when degenerate. */
@@ -17,7 +17,7 @@
17
17
  import * as THREE from 'three';
18
18
  import { OrbitControls } from 'three/addons/OrbitControls.js';
19
19
  import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
20
- import { snapCandidates, snapPoint, planPointToWp, memberGeometry, elevationLevels, snapElevation, dim3dGeom, planeBasis, planeFrom3Points, vecToPlane, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, rayAxisT } from './steel-3d-core.js';
20
+ import { snapCandidates, snapPoint, planPointToWp, memberGeometry, elevationLevels, snapElevation, dim3dGeom, planeBasis, planeFrom3Points, vecToPlane, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane } from './steel-3d-core.js';
21
21
  import { gridGeometry, gridCandidates3d, mmPerPx } from './grid-core.js';
22
22
 
23
23
  let renderer, scene, perspCam, orthoCam, camera, controls, root, api, canvasEl, ro, rafId, grid, raycaster, downXY, lastPick = '(none)';
@@ -61,6 +61,8 @@ const meshById = new Map(); // member id -> THREE.Mesh
61
61
  const groupColor = new Map(); // group key -> THREE.Color
62
62
  const baseMat = new Map(); // group key -> MeshStandardMaterial (shared per profile)
63
63
  const SELECT_EMISSIVE = 0x3b82f6; // --brand: selected members glow blue
64
+ const HOVER_EMISSIVE = 0x38bdf8; // sky: a cooler, lighter hue than the selection blue — paired with a softer glow (HOVER_INTENSITY) so hover reads distinct from selection
65
+ const HOVER_INTENSITY = 0.3; // hover glow strength (softer than the 0.6 selection glow)
64
66
  const EP_START = 0xfacc15; // start endpoint (end 1) — yellow
65
67
  const EP_END = 0xf472b6; // end endpoint (end 2) — magenta
66
68
 
@@ -78,6 +80,24 @@ function candAllowed3d(type) {
78
80
  const pref = api && api.snapEnabled && api.snapEnabled(); const k = SNAP3D_PREF[type];
79
81
  return !k || !pref || pref[k] !== false;
80
82
  }
83
+ // The SNAP-bar "3D snapping" toggle (⋯ menu → Snapping; default ON). ON = snap freely to any point in
84
+ // 3D at any elevation (Pawel D5 — the whole model is a snap target). OFF = constrain PLACEMENT snapping
85
+ // (Move/Copy/Add-member) to the current working LEVEL: only candidates whose proposed point lands on
86
+ // effectiveWP() survive, so on a horizontal working plane grid lines and columns still snap (they keep
87
+ // the cursor Z, which IS the level) while a beam end on a DIFFERENT elevation drops out instead of
88
+ // yanking the point off-plane. The constraint is a LEVEL constraint, so it only engages on a (near-)
89
+ // horizontal working plane; on a tilted ◇ Plane / local-UCS it does NOT gate (there a plan-steering
90
+ // candidate's own X/Y pushes it off the tilt — gating would silently drop grid/columns), so snapping
91
+ // stays free there. Dimensions stay free 3D (they measure across elevations). Read live from the editor
92
+ // per hover so the toggle is instant — no candidate-cache rebuild. `dragged` is the cursor on the plane.
93
+ const WP_SNAP_TOL_MM = 1;
94
+ function candOnActiveWP(c, dragged, wp) {
95
+ if (!api || !api.snap3dFree || api.snap3dFree()) return true; // free 3D (default) → no plane constraint
96
+ if (!wp || !wp.normal || !wp.origin) return true; // no valid plane → fail open (free); never throw out of the .filter() and break the pointer interaction
97
+ const n = wp.normal, L = Math.hypot(n[0], n[1], n[2]) || 1;
98
+ if (Math.abs(n[2]) <= 0.999 * L) return true; // not a level (tilted/vertical plane) → don't gate; see above
99
+ return candidateOnPlane(c, dragged, wp.origin, wp.normal, WP_SNAP_TOL_MM);
100
+ }
81
101
  let rightDownXY = null, rightMoved = false; // right button: dragged (= orbit/pan, no menu) vs clicked (= snap menu)
82
102
  let dimAxis3d = 'free'; // sticky axis: free | x | y | z
83
103
  let dims3dVisibleFlag = true; // show/hide placed dims
@@ -195,6 +215,7 @@ function init(canvas, theApi) {
195
215
  window.addEventListener('pointermove', onMove); // window so a drag keeps tracking off-canvas
196
216
  window.addEventListener('pointerup', onUp);
197
217
  canvas.addEventListener('pointermove', onHoverMove); // canvas-only: cursor + hover readout when idle
218
+ canvas.addEventListener('pointerleave', () => { hoverEp = null; if (hoverRAF) { cancelAnimationFrame(hoverRAF); hoverRAF = 0; } setHover(null); updateStatusChip(); }); // leaving the canvas clears the hover glow + chip; cancel any queued hover frame so it can't re-glow the last member after the cursor left
198
219
  canvas.addEventListener('dblclick', onDblClick); // "zoom to detail": dbl-click a part zooms to it (empty = no-op)
199
220
  window.addEventListener('keydown', onKey); // Tekla keyboard nav: arrows pan, Ctrl/Shift+arrows rotate
200
221
  ro = new ResizeObserver(resize); ro.observe(canvas.parentElement || canvas);
@@ -505,12 +526,14 @@ function clearRoot() {
505
526
  for (const [id, m] of meshById) {
506
527
  m.geometry.dispose();
507
528
  if (m.userData._selMat) m.userData._selMat.dispose(); // per-mesh selection clone (else it leaks per rebuild)
529
+ if (m.userData._hovMat) m.userData._hovMat.dispose(); // per-mesh hover clone — same leak-per-rebuild story as _selMat
508
530
  // A placed detail (Slice 4) owns a per-mesh MeshBasicMaterial + its image texture (NOT a shared baseMat);
509
531
  // dispose both or every rebuild — which happens on each edit — leaks the old material + GPU texture.
510
532
  if (String(id).startsWith('det:') && m.material) { if (m.material.map) m.material.map.dispose(); m.material.dispose(); }
511
533
  root.remove(m);
512
534
  }
513
535
  meshById.clear();
536
+ hoverId = null; hoverEp = null; // the meshes are gone — drop stale hover state so the next pointermove re-glows the fresh mesh
514
537
  }
515
538
 
516
539
  // Subtract each cope (a `cut` part) from a member's solid via CSG — a real coped beam end. Cut boxes are
@@ -869,8 +892,15 @@ function positionSelLenLabels() {
869
892
  let structGridGroup = null, gridLabelGroup = null;
870
893
  const gridTexCache = new Map(); // 'b:LABEL' bubble / 't:LABEL' tag -> CanvasTexture (kept until dispose)
871
894
 
895
+ // Snap targets for the 3D tools. Members come from the WHOLE model — every sheet, not just the active
896
+ // one — so "3D snapping on" can grab any member at any elevation (the 3D scene shows all sheets; snapping
897
+ // must match). Each sheet is resolved in its OWN px→ft scale (sheets may differ); the elevation (Z) is
898
+ // scale-independent. Intersections stay within a sheet (pairwise across the whole model is O(n²) noise).
899
+ // Grid is the active sheet's (the plan-locked reference the user is drawing against).
872
900
  function allCandidates(excludeId) {
873
- const base = snapCandidates(members(), api.ptPerFt(), api.defaultTosMm(), excludeId);
901
+ const dtos = api.defaultTosMm();
902
+ const byPlan = (api.membersByPlan && api.membersByPlan()) || [{ members: members(), ptPerFt: api.ptPerFt(), defaultTosMm: dtos }];
903
+ const base = byPlan.flatMap((pl) => snapCandidates(pl.members, pl.ptPerFt, pl.defaultTosMm != null ? pl.defaultTosMm : dtos, excludeId)); // each sheet's OWN default T.O.S — a default-elevation member on a non-active sheet must snap at the level it RENDERS at (the bake uses the same per-plan default), not the active sheet's
874
904
  if (frame3d && !(pending && pending.frameDrag)) base.push({ type: 'origin', p: [...frame3d.origin], fromId: 'ucs-origin' }); // the local UCS origin is a snap target for every tool (Move/Copy, Add, Dimension); excluded while dragging the origin itself → no self-snap
875
905
  try { return base.concat(gridCandidates3d(api.getGrid ? api.getGrid() : null, api.ptPerFt())); }
876
906
  catch { return base; } // a malformed hand-edited grid must never break member dragging
@@ -1656,7 +1686,8 @@ function setSelection(ids) {
1656
1686
  applyDisplayMode(); // selection swapped the materials → re-apply wire/xray
1657
1687
  selIds = new Set(set);
1658
1688
  reconcileConnState(set); // any selection path (2D click, box-select, keyboard) must not leave a stale connection envelope/drill
1659
- rebuildEndpoints(); // endpoint dots follow the selection (+ any hover)
1689
+ rebuildEndpoints(); // endpoint dots follow the selection
1690
+ if (hoverId != null && !set.has(hoverId)) setHoverGlow(hoverId, true); // a still-hovered, now-unselected member keeps its glow (the material swap above cleared it)
1660
1691
  updateStatusChip();
1661
1692
  }
1662
1693
  let selIds = new Set();
@@ -1664,15 +1695,40 @@ function selectedMaterial(mesh) {
1664
1695
  if (!mesh.userData._selMat) mesh.userData._selMat = materialFor(mesh.userData.group).clone();
1665
1696
  return mesh.userData._selMat;
1666
1697
  }
1698
+ // ---- sky hover glow (replaces the on-hover endpoint dots) ----
1699
+ // A per-mesh clone so glowing one member doesn't tint its whole profile group (same trick as
1700
+ // selection). Selection always wins: a selected member keeps its blue glow and is left untouched.
1701
+ function hoverMaterial(mesh) {
1702
+ if (!mesh.userData._hovMat) mesh.userData._hovMat = materialFor(mesh.userData.group).clone();
1703
+ return mesh.userData._hovMat;
1704
+ }
1705
+ function setHoverGlow(id, on) {
1706
+ if (id == null) return;
1707
+ const mesh = meshById.get(id);
1708
+ if (!mesh || String(id).startsWith('det:')) return; // placed details use a texture, no emissive to glow
1709
+ if (selIds.has(id)) return; // selected beats hovered — don't disturb its blue glow
1710
+ mesh.material = on ? hoverMaterial(mesh) : materialFor(mesh.userData.group);
1711
+ mesh.material.emissive = new THREE.Color(on ? HOVER_EMISSIVE : 0x000000);
1712
+ mesh.material.emissiveIntensity = on ? HOVER_INTENSITY : 0;
1713
+ applyDisplayMode(); // ALWAYS re-sync after a material swap (mirrors setSelection): the swapped-in clone may have been cloned in another mode, and on clear the restored shared material can itself be stale — for a sole-profile member it stays detached while its mesh wears _hovMat, so applyDisplayMode never updated it. emissive is preserved (applyDisplayMode never touches it).
1714
+ }
1715
+ // Move the hover glow from the previous member to `id` (null = clear). One entry point so every
1716
+ // hoverId transition stays consistent.
1717
+ function setHover(id) {
1718
+ if (id === hoverId) return;
1719
+ setHoverGlow(hoverId, false);
1720
+ hoverId = id;
1721
+ setHoverGlow(hoverId, true);
1722
+ }
1667
1723
 
1668
1724
  // ---- yellow (start) / magenta (end) endpoint markers — also the drag handles ----
1669
- // Shown for every selected member, plus the hovered member. The dot at the member's `from` end
1725
+ // Shown for every SELECTED member (hover shows a sky glow instead — setHoverGlow). The dot at the member's `from` end
1670
1726
  // (start / end 1) is yellow; the `to` end (end 2 / column top) is magenta. Sizes held ~constant on
1671
1727
  // screen in the render loop (sizeEndpoints).
1672
1728
  function rebuildEndpoints() {
1673
1729
  if (!epGroup) return;
1674
1730
  for (const c of [...epGroup.children]) epGroup.remove(c); // shared geom/material → nothing to dispose
1675
- const show = new Set(selIds); if (hoverId) show.add(hoverId);
1731
+ const show = new Set(selIds); // dots follow the SELECTION only — hover now shows a glow instead (setHoverGlow)
1676
1732
  for (const id of show) {
1677
1733
  const mesh = meshById.get(id); if (mesh && !mesh.visible) continue; // a legend-hidden member shows no dots
1678
1734
  const m = memberById(id); if (!m) continue;
@@ -2605,15 +2661,6 @@ function rayToWP(cx, cy, wp) {
2605
2661
  const hit = new THREE.Vector3();
2606
2662
  return raycaster.ray.intersectPlane(plane, hit) ? [hit.x, hit.y, hit.z] : null;
2607
2663
  }
2608
- // The cursor's world-space pick ray {o, d} (d unit), mirroring rayToWP's NDC → raycaster setup.
2609
- function cameraRay(cx, cy) {
2610
- camera.updateMatrixWorld();
2611
- const rect = canvasEl.getBoundingClientRect(); if (!rect.width || !rect.height) return null;
2612
- const ndc = new THREE.Vector2(((cx - rect.left) / rect.width) * 2 - 1, -((cy - rect.top) / rect.height) * 2 + 1);
2613
- raycaster.setFromCamera(ndc, camera);
2614
- const o = raycaster.ray.origin, d = raycaster.ray.direction;
2615
- return { o: [o.x, o.y, o.z], d: [d.x, d.y, d.z] };
2616
- }
2617
2664
 
2618
2665
  // ---- 3D Move/Copy (spec §3+§6): the EDITOR owns the tool state (cmState via api); this side owns
2619
2666
  // picking/preview in scene mm against the working plane, and hands commit offsets back. ----
@@ -2621,14 +2668,25 @@ let tfDraft = null; // {base:[mm], vA:[mm]|null}
2621
2668
  let tfLastShift = false; // shiftKey mirror for the rAF-synthetic hover event
2622
2669
  let tfLast = null; // last constrained preview point (HUD distance direction)
2623
2670
  let tfLastClient = null; // last pointer client [x,y] (HUD placement)
2624
- let tfAxis = 'free'; // 'free' | 'u' | 'v' | 'n' — X/Y force in-plane, 'n' = normal-axis lock (UCS Stage 4)
2671
+ const tfLock = new Set(); // subset of {'u','v','n'} the move is LINE-locked to — 0 = free; 1 = that axis; 2 or 3 = whichever locked axis the cursor drags toward (dominantAmong). Multi-axis lock; UCS Stage 4.
2625
2672
  let tfCandidates = null;
2626
2673
  let tfGhost = null, tfRubber = null, tfRubberA = null, tfGhostMat = null;
2627
2674
  const cmActive = () => (api && api.cmState ? api.cmState() : null);
2628
2675
  const cmHasBase = () => !!tfDraft;
2629
2676
  const cmLastClient = () => tfLastClient;
2630
- function setCmAxis(a) { tfAxis = a === 'x' ? 'u' : a === 'y' ? 'v' : a === 'z' ? 'n' : 'free'; }
2631
- function cmClear3d() { tfDraft = null; tfCandidates = null; tfAxis = 'free'; tfPreviewClear(); if (canvasEl) canvasEl.style.cursor = 'default'; } // callable BEFORE init() (editor boot) — every touched handle is guarded
2677
+ // X/Y/Z each TOGGLE their axis in the lock set (press again to release, press another to ADD → the move
2678
+ // snaps to whichever locked axis you drag toward); F clears to free. shiftHeld = the Shift state at the key
2679
+ // press (the editor passes it), so the immediate preview refresh matches a click.
2680
+ function setCmAxis(a, shiftHeld) {
2681
+ const ax = a === 'x' ? 'u' : a === 'y' ? 'v' : a === 'z' ? 'n' : null;
2682
+ if (ax === null) tfLock.clear(); else if (tfLock.has(ax)) tfLock.delete(ax); else tfLock.add(ax);
2683
+ // Refresh the ghost/readout NOW so a key press then a click WITHOUT moving commits what's shown. The
2684
+ // editor's axis-key handler fires only with Alt UP, so use altKey:false (NOT the stale hover mirror
2685
+ // dimLastAlt, which lags a modifier released without a pointer move); Shift comes live from the key event.
2686
+ if (tfDraft && lastHoverXY) tfPreview({ clientX: lastHoverXY[0], clientY: lastHoverXY[1], altKey: false, shiftKey: !!shiftHeld });
2687
+ updateStatusChip();
2688
+ }
2689
+ function cmClear3d() { tfDraft = null; tfCandidates = null; tfLock.clear(); tfPreviewClear(); if (canvasEl) canvasEl.style.cursor = 'default'; } // callable BEFORE init() (editor boot) — every touched handle is guarded
2632
2690
  function cmEscape() { if (!tfDraft) return false; if (tfDraft.vA) { tfDraft.vA = null; tfPreviewClear(); return true; } tfDraft = null; tfPreviewClear(); return true; }
2633
2691
  function tfDisposeGhost() { if (!tfGhost) return; if (scene) scene.remove(tfGhost); for (const c of tfGhost.children) { if (c.userData._ownGeom && c.geometry) c.geometry.dispose(); } tfGhost = null; } // clones share the source geometry/material; only the >600 fallback BoxGeometry is per-ghost → dispose those (flagged _ownGeom) so the preview can't leak
2634
2692
  function tfPreviewClear() { tfDisposeGhost(); if (tfRubber) tfRubber.visible = false; if (tfRubberA) tfRubberA.visible = false; if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; }
@@ -2638,62 +2696,76 @@ function wpPointAt(e) {
2638
2696
  const hit = rayToWP(e.clientX, e.clientY, wp); if (!hit) return null;
2639
2697
  if (!e.altKey) {
2640
2698
  if (!tfCandidates) tfCandidates = allCandidates(null); // members + grid, so Move/Copy + draw-on-plane snap to the grid too
2641
- const r = snapPoint(hit, tfCandidates.filter((c) => candAllowed3d(c.type)), toScreen, SNAP_TOL_PX); // honour the running-snaps / override
2642
- if (r.candidate) return { p: r.snapped, snap: true, type: r.candidate.type }; // land on the TRUE 3D snap (member end / grid), NOT projected onto the plane — snapping stays free to the whole model, same as global (Pawel D5); a free (non-snapped) click still rides the plane below
2699
+ const cands = tfCandidates.filter((c) => candAllowed3d(c.type) && candOnActiveWP(c, hit, wp)); // running-snaps / override, then (3D toggle off) the working-plane constraint
2700
+ const r = snapPoint(hit, cands, toScreen, SNAP_TOL_PX);
2701
+ if (r.candidate) return { p: r.snapped, snap: true, type: r.candidate.type }; // land on the TRUE 3D snap (member end / grid) when the SNAP-bar 3D toggle is ON — free to the whole model, same as global (Pawel D5); OFF constrains to the working plane above; a free (non-snapped) click still rides the plane below
2643
2702
  }
2644
2703
  return { p: hit, snap: false, type: null };
2645
2704
  }
2646
- // Shift = dominant in-plane axis; X/Y force follows the plane basis (like the 2D local frame)
2647
- function tfConstrain(p, e) {
2648
- if (!tfDraft) return p;
2649
- const wp = effectiveWP(), { u, v } = planeBasis(wp.normal, wp.xAxis), b = tfDraft.base;
2650
- const d = [p[0] - b[0], p[1] - b[1], p[2] - b[2]], c = vecToPlane(d, u, v, wp.normal);
2651
- let ax = tfAxis;
2652
- if (e && e.shiftKey) ax = Math.abs(c.du) >= Math.abs(c.dv) ? 'u' : 'v';
2653
- if (ax === 'u') return [b[0] + c.du * u[0], b[1] + c.du * u[1], b[2] + c.du * u[2]];
2654
- if (ax === 'v') return [b[0] + c.dv * v[0], b[1] + c.dv * v[1], b[2] + c.dv * v[2]];
2655
- return p;
2656
- }
2657
- // Move/Copy normal-axis lock (UCS Stage 4): with a base picked, hold Alt (transient) or press Z (sticky)
2658
- // to constrain the move to the working frame's normal. Project the cursor ray onto base + t·normal and
2659
- // commit that. Top-view degeneracy (view ray ~∥ normal → rayAxisT returns null): fall back to a TRUE
2660
- // screen-Y → distance map from the base's screen position. A ~vertical normal then snaps to framing
2661
- // levels (same feel as the plain-drag Alt-elevation move).
2662
- function cmNormalLock(e) {
2663
- const base = tfDraft.base, n = _unit3(effectiveWP().normal);
2664
- const ray = cameraRay(e.clientX, e.clientY);
2665
- let t = ray ? rayAxisT(ray.o, ray.d, base, n) : null;
2666
- if (t == null) { // singular → screen-Y drives the distance
2667
- const bs = toScreen(base), rect = canvasEl.getBoundingClientRect();
2668
- const dy = bs.y - (e.clientY - rect.top); // cursor above the base → +normal (fixed sign)
2669
- t = dy * pxToWorldAt(1, base);
2670
- // ponytail: uses the horizontal px→world scale as the vertical proxy (a straight-down view has no true
2671
- // vertical scale). Fine for the rare look-down-the-normal case; the level snap fixes the landing.
2672
- }
2673
- if (!Number.isFinite(t)) t = 0; // never commit a NaN offset — a non-finite scale/ray pins the destination to the base (no move)
2705
+ // Basis of the active frame: in-plane u/v (from the plane basis) + the normal n.
2706
+ function frameBasis() { const wp = effectiveWP(), b = planeBasis(wp.normal, wp.xAxis); return { u: b.u || [1, 0, 0], v: b.v || [0, 1, 0], n: _unit3(wp.normal) }; }
2707
+ // Line-lock the Move/Copy destination to ONE axis via a SCREEN-space drag: move along the axis in
2708
+ // proportion to how far the cursor is dragged along the axis's on-screen direction. This tracks the cursor
2709
+ // and is bounded by the actual drag — unlike a working-plane-hit projection it does NOT blow up to a huge
2710
+ // offset when the cursor nears the horizon (the axis grazes the view). Edge-on axis (its screen projection
2711
+ // collapses because you're looking down it): a ~vertical axis falls back to screen-Y → Z (Top view); any
2712
+ // other axis → no move. A ~vertical axis then snaps t to the framing levels. X/Y/Z + Alt normal-lock alike.
2713
+ function cmAxisLock(e, axisVec) {
2714
+ const base = tfDraft.base, n = _unit3(axisVec), bs = toScreen(base), rect = canvasEl.getBoundingClientRect();
2715
+ const sc = pxToWorldAt(120, base) || 1; // a world length that spans ~120 px at the base
2716
+ const q = toScreen([base[0] + n[0] * sc, base[1] + n[1] * sc, base[2] + n[2] * sc]);
2717
+ const sdx = q.x - bs.x, sdy = q.y - bs.y, slen = Math.hypot(sdx, sdy); // the axis's screen vector for `sc` world units
2718
+ let t;
2719
+ if (slen < 4) { // axis ~edge-on (looking down it) → no usable screen direction
2720
+ if (Math.abs(n[2]) > 0.999) t = (bs.y - (e.clientY - rect.top)) * pxToWorldAt(1, base); // vertical axis (Top) → screen-Y → Z
2721
+ else t = 0; // other axis edge-on → no move (orbit, or use typed entry)
2722
+ } else {
2723
+ const cdx = (e.clientX - rect.left) - bs.x, cdy = (e.clientY - rect.top) - bs.y; // cursor's screen offset from the base
2724
+ t = ((cdx * sdx + cdy * sdy) / slen) * (sc / slen); // (signed px along the axis) × (world per screen px along it)
2725
+ }
2726
+ if (!Number.isFinite(t)) t = 0; // never commit a NaN offset
2674
2727
  let p = [base[0] + n[0] * t, base[1] + n[1] * t, base[2] + n[2] * t];
2675
2728
  let snap = false, type = null;
2676
- if (Math.abs(n[2]) > 0.999) { // ~vertical normal → snap the elevation to a framing level
2677
- // World-space snap (NOT screen-space): in Top view every level projects to the same screen point, so a
2678
- // screen snap can't tell them apart and would pin to one level regardless of the cursor. Snap p.z to the
2679
- // nearest level within a screen-proportional world tolerance, then re-solve t so the point stays exactly
2680
- // on base + t·normal (the normal may tilt a hair even at |n.z| > 0.999).
2729
+ if (Math.abs(n[2]) > 0.999) { // ~vertical axis → snap the elevation to a framing level (WORLD-space: in Top view all levels share one screen point)
2681
2730
  const tol = pxToWorldAt(SNAP_TOL_PX, base);
2682
2731
  let best = null, bestD = tol;
2683
2732
  for (const z of elevationLevels(members(), api.ptPerFt(), api.defaultTosMm(), null)) { const d = Math.abs(p[2] - z); if (d <= bestD) { bestD = d; best = z; } }
2684
- if (best != null) { t = (best - base[2]) / n[2]; p = [base[0] + n[0] * t, base[1] + n[1] * t, best]; snap = true; type = 'level'; }
2733
+ if (best != null) { t = (best - base[2]) / n[2]; p = [base[0] + n[0] * t, base[1] + n[1] * t, best]; snap = true; type = 'level'; } // re-solve t so the point stays exactly on base + t·axis
2685
2734
  }
2686
2735
  return { p, snap, type };
2687
2736
  }
2688
- // Resolve the Move/Copy destination with axis precedence: Alt (normal) > Shift (in-plane) > sticky tfAxis.
2689
- // Returns { p, snap, type }; snap means p landed ON a candidate (show the reticle). null = no valid pick
2690
- // (cursor off the plane, edge-on) for the in-plane path — the normal-lock path never needs the plane.
2737
+ // Among `axes` (basis keys), the ONE the cursor is dragging toward: the axis whose SCREEN direction best
2738
+ // matches the cursor's screen move from the base (|cos|). Lets a 2-axis lock (X+Z) snap the move to X or Z
2739
+ // (whichever you lean toward), and Shift pick the dominant in-plane axis — one straight axis, never diagonal.
2740
+ function dominantAmong(e, axes) {
2741
+ const base = tfDraft.base, bs = toScreen(base), rect = canvasEl.getBoundingClientRect();
2742
+ const cx = (e.clientX - rect.left) - bs.x, cy = (e.clientY - rect.top) - bs.y, cl = Math.hypot(cx, cy) || 1;
2743
+ const bv = frameBasis(), sc = pxToWorldAt(120, base) || 1; // world length spanning ~120 px → a well-conditioned axis screen vector
2744
+ let best = axes[0], bestScore = -1;
2745
+ for (const a of axes) {
2746
+ const av = bv[a], q = toScreen([base[0] + av[0] * sc, base[1] + av[1] * sc, base[2] + av[2] * sc]);
2747
+ const ax2 = q.x - bs.x, ay2 = q.y - bs.y, al = Math.hypot(ax2, ay2) || 1;
2748
+ const score = Math.abs((cx * ax2 + cy * ay2) / (cl * al));
2749
+ if (score > bestScore) { bestScore = score; best = a; }
2750
+ }
2751
+ return best;
2752
+ }
2753
+ // The single axis the move is line-locked to ('u'|'v'|'n'), or null = free. Precedence: Alt (normal) >
2754
+ // Shift (dominant in-plane) > the sticky lock set (the lone locked axis, or the dominant of two).
2755
+ function cmEffAxis(e) {
2756
+ if (!tfDraft) return null;
2757
+ if (e && e.altKey) return 'n';
2758
+ if (e && e.shiftKey) return dominantAmong(e, ['u', 'v']);
2759
+ if (!tfLock.size) return null; // no lock → free
2760
+ return tfLock.size === 1 ? [...tfLock][0] : dominantAmong(e, [...tfLock]); // 1 = that axis; 2 or 3 = whichever locked axis the cursor drags toward
2761
+ }
2762
+ // Resolve the Move/Copy destination: a line-lock along the effective axis (ray-to-axis), else the free
2763
+ // working-plane pick (with snapping). null = no valid pick (cursor off the plane, edge-on).
2691
2764
  function cmDestPoint(e) {
2692
- const alt = !!(e && e.altKey), shift = !!(e && e.shiftKey);
2693
- if (tfDraft && (alt || (tfAxis === 'n' && !shift))) return cmNormalLock(e);
2765
+ const ax = cmEffAxis(e);
2766
+ if (ax) return cmAxisLock(e, frameBasis()[ax]);
2694
2767
  const r = wpPointAt(e); if (!r) return null;
2695
- const p = tfConstrain(r.p, e);
2696
- return { p, snap: r.snap && tfAxis === 'free' && !shift, type: r.type }; // in-plane force moves p off the raw snap → no reticle
2768
+ return { p: r.p, snap: r.snap, type: r.type };
2697
2769
  }
2698
2770
  // the offset list is the pure core `offsetsFor` (unit-tested for linear/grid) — counts INCLUDE the original, grid skips (0,0)
2699
2771
  function tfOffsetsFor(v, st) { return offsetsFor(v, st, tfDraft ? tfDraft.vA : null); }
@@ -3378,9 +3450,9 @@ function onHoverMove(e) {
3378
3450
  }
3379
3451
  if (selectedClipIds.size) { let ch = null; try { ch = pickClipHandle(lastHoverXY[0], lastHoverXY[1]); } catch { ch = null; } if (ch) { canvasEl.style.cursor = 'move'; return; } } // over a clip handle → move cursor
3380
3452
  let ep = null; try { ep = pickEndpoint(lastHoverXY[0], lastHoverXY[1]); } catch { ep = null; }
3381
- if (ep) { // over an end node → ring + move cursor; keep its member's dots shown
3453
+ if (ep) { // over an end node (a selected member's drag handle) → ring + move cursor
3382
3454
  hoverEp = ep; canvasEl.style.cursor = 'move';
3383
- if (hoverId !== ep.id) { hoverId = ep.id; rebuildEndpoints(); }
3455
+ setHover(ep.id); // glow is a no-op here (ep.id is selected → selection wins), but this clears any prior member's glow
3384
3456
  updateStatusChip(); return;
3385
3457
  }
3386
3458
  hoverEp = null;
@@ -3388,7 +3460,7 @@ function onHoverMove(e) {
3388
3460
  const topMesh = top ? meshById.get(top) : null, isPart = !!(topMesh && topMesh.userData.derived);
3389
3461
  const canDrag = api && api.dragMoveEnabled && api.dragMoveEnabled();
3390
3462
  canvasEl.style.cursor = geoMode() ? 'crosshair' : (top ? ((isPart || !canDrag) ? 'pointer' : 'grab') : 'default'); // derived part → pointer (select-only); member → grab only when drag-move is ON, else pointer (a click just selects — the cursor tells the truth, like 2D)
3391
- if (top !== hoverId) { hoverId = top; rebuildEndpoints(); updateStatusChip(); }
3463
+ if (top !== hoverId) { setHover(top); updateStatusChip(); }
3392
3464
  });
3393
3465
  }
3394
3466
  function updateStatusChip() {
@@ -3399,7 +3471,7 @@ function updateStatusChip() {
3399
3471
  if (wpMode === 'face') txt = 'Click a member face — the working plane lands on it · Esc to cancel';
3400
3472
  else if (wpMode === '3pt') txt = ['Click the plane origin (snapped) · Esc to cancel', 'Click the local-X direction point · Esc to cancel', 'Click a point on the plane’s Y side · Esc to cancel'][(wpDraft || []).length] || '';
3401
3473
  else if (addActive()) txt = drDraft ? 'Click the member end · Shift straight · Esc drops the start' : 'Draw a member on the working plane — click the start point · Esc exits';
3402
- else if (cmActive()) { const st = cmActive(), lock = tfAxis === 'u' ? ' · X locked' : tfAxis === 'v' ? ' · Y locked' : tfAxis === 'n' ? ' · Z locked' : '';
3474
+ else if (cmActive()) { const st = cmActive(), _lk = ['u', 'v', 'n'].filter((a) => tfLock.has(a)), lock = _lk.length ? ' · ' + _lk.map((a) => (a === 'u' ? 'X' : a === 'v' ? 'Y' : 'Z')).join(', ') + ' locked' : '';
3403
3475
  txt = (!tfDraft ? ((st.tool === 'move' ? 'Move' : (st.array ? 'Copy array' : 'Copy')) + ' — click the base point on the working plane · type after the pick for an exact value')
3404
3476
  : (st.array && !tfDraft.vA ? 'Click the direction-A point — or type its spacing' : st.array ? 'Click the direction-B point — the grid previews live' : 'Click the destination — X/Y lock to the plane axes · Esc cancels')) + lock; }
3405
3477
  else if (clipMode === 'plane') txt = 'Click a face to set a clip plane · Esc to cancel';
@@ -3503,6 +3575,7 @@ function debug() {
3503
3575
  near: camera?.near, far: camera?.far,
3504
3576
  clips: getClips(), clipPlaneCount: renderer && renderer.clippingPlanes ? renderer.clippingPlanes.length : 0, clipMode, workArea: workAreaState(), selectedClips: [...selectedClipIds],
3505
3577
  workPlane: workPlaneInfo(), tfHasBase: !!tfDraft, tfGhosts: tfGhost ? tfGhost.children.length : 0, drHasStart: !!drDraft,
3578
+ wp: { origin: [...effectiveWP().origin], normal: [...effectiveWP().normal] }, // resolved working plane (◇ Plane, local UCS, or default level) — lets an E2E pick an off-plane vertex + assert the workplane-only snap constraint
3506
3579
  };
3507
3580
  }
3508
3581
  // test helper: the current material colour + emissive of a member (verifies deselect restores colour)
@@ -43,7 +43,12 @@
43
43
  #connCrumb .seg.cur{color:var(--brand);font-weight:600;cursor:default;text-decoration:none}
44
44
  #connCrumb .sep{color:var(--mut);opacity:.7;padding:0 2px}
45
45
  .pilllink{background:none;border:0;color:var(--brand);cursor:pointer;font:inherit;padding:0;text-decoration:underline}
46
- aside{width:240px;flex:none;background:var(--panel);border-left:1px solid var(--line);padding:12px;overflow:auto}
46
+ aside{width:var(--panelw,240px);flex:none;background:var(--panel);border-left:1px solid var(--line);padding:12px;overflow:auto}
47
+ /* draggable width handle on the panel's left edge (persisted) */
48
+ #panelResizer{flex:none;width:7px;margin-right:-1px;cursor:col-resize;background:transparent;position:relative;z-index:6;touch-action:none;align-self:stretch}
49
+ #panelResizer::before{content:"";position:absolute;inset:0 3px;border-radius:2px;transition:background-color .12s}
50
+ #panelResizer:hover::before,#panelResizer.drag::before{background:var(--brand)}
51
+ #panelResizer:focus-visible{outline:none} #panelResizer:focus-visible::before{background:var(--brand)}
47
52
  aside h3{margin:0 0 8px;font-size:12px;color:var(--mut);text-transform:uppercase;letter-spacing:.05em}
48
53
  select,input{background:#0f172a;color:var(--text);border:1px solid #475569;border-radius:6px;padding:6px;width:100%;font:13px system-ui}
49
54
  .row{margin:8px 0} .danger{background:#7f1d1d;border-color:#991b1b} .danger:hover{background:#991b1b}
@@ -242,6 +247,11 @@
242
247
  #snapBar button.on{background:var(--brand);color:#0f172a;opacity:1}
243
248
  #snapBar button:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
244
249
  body.v3d #snapBar [data-snap=perp],body.v3d #snapBar [data-snap=par],body.v3d #snapSect [data-snap=perp],body.v3d #snapSect [data-snap=par]{display:none} /* ⟂/∥ are 2D-only for now (no 3D snap candidates) — hide in 3D, mirroring the insWrap 2D/3D-scoped idiom */
250
+ /* The "3D" snap-MODE toggle is the inverse: 3D-only. A short text label (not an osnap glyph) → smaller/bolder; a hair-line divider before it marks it as a mode, not a peer snap type. */
251
+ #snapBar [data-snap3d]{display:none;font-size:11px;font-weight:700;letter-spacing:.02em;margin-left:4px;border-left:1px solid var(--line);border-radius:0 5px 5px 0;padding-left:4px;box-sizing:border-box;width:32px}
252
+ body.v3d #snapBar [data-snap3d]{display:grid}
253
+ #snapSect [data-snap3d]{display:none}
254
+ body.v3d #snapSect [data-snap3d]{display:flex}
245
255
  #moreMenu .mhint{color:var(--mut);font-size:11px;line-height:1.4;padding:4px 12px 6px;max-width:230px;white-space:normal}
246
256
  #rfiStat{cursor:pointer;text-decoration:underline dotted} #rfiStat:hover b{color:#fff}
247
257
  #confStat{cursor:pointer;text-decoration:underline dotted} #confStat:hover b{filter:brightness(1.25)}
@@ -753,6 +763,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
753
763
  <button class="msnap" data-snap=perp role=menuitemcheckbox aria-checked=false data-tip="Perpendicular — from your first point, snap the second square (90°) to a target line (member, grid, or drawing linework). With Extension on, the foot may land on the line’s extension."><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>⟂</span>Perpendicular</button>
754
764
  <button class="msnap" data-snap=par role=menuitemcheckbox aria-checked=false data-tip="Parallel — when you draw roughly parallel to a nearby line, snap the direction to exactly parallel."><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>∥</span>Parallel</button>
755
765
  <button class="msnap" data-snap=ext role=menuitemcheckbox aria-checked=false data-tip="Snap along the invisible extension of a member/line past its endpoint, with a dashed guide line"><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>┈</span>Extension</button>
766
+ <button class="msnap on" data-snap3d role=menuitemcheckbox aria-checked=true data-tip="On: snap freely to any point in 3D, at any elevation. Off: snap only on the current working level. (3D view only.)"><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>◈</span>3D snapping</button>
756
767
  <div class=mhint>Right-click the canvas any time to force one snap type for a single pick.</div>
757
768
  </div>
758
769
  <button class=msec-hdr data-sec=display aria-expanded=false data-tip="Show/hide plan layers, and edit grid lines">Display<span class=chev aria-hidden=true>▸</span></button>
@@ -924,10 +935,12 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
924
935
  <button data-snap=perp data-tip="Perpendicular snap — square (90°) to a target line from your first point">⟂</button>
925
936
  <button data-snap=par data-tip="Parallel snap — run parallel to a nearby line">∥</button>
926
937
  <button data-snap=ext data-tip="Extension snap">┈</button>
938
+ <button data-snap3d aria-label="3D snapping" data-tip="3D snapping — on: snap freely to any point in 3D, at any elevation; off: snap only on the current working level.">3D</button>
927
939
  </div>
928
940
  </div>
929
941
  <div id=selFly role=menu aria-label="Selectable types"></div>
930
942
  </div>
943
+ <div id=panelResizer role=separator aria-orientation=vertical aria-label="Resize properties panel" tabindex=0 data-tip="Drag to resize · double-click to reset"></div>
931
944
  <aside id=panel></aside>
932
945
  </main>
933
946
  <datalist id=conntypes><option>moment</option><option>drag</option><option>shear</option><option>braced</option><option>pinned</option><option>fixed</option></datalist>
@@ -2376,7 +2389,7 @@ function panel(){
2376
2389
  <div class=hint id=cmHint style="margin-top:8px">${esc(cmHintText())}</div>
2377
2390
  ${cmTool==='copy'&&!cmArrayMode?`<div class=sect style="margin-top:12px">Copies</div><input id=cmN inputmode=numeric value="${cmCount}" autocomplete=off><div class=hint style="margin-top:4px">×N places a row — each copy one step further along the pick (linear).</div>`:''}
2378
2391
  ${cmArrayMode?`<div class=sect style="margin-top:12px">Array counts</div><div class=elab>Direction A</div><input id=cmNA inputmode=numeric value="${cmCountA}" autocomplete=off><div class=elab>Direction B</div><input id=cmNB inputmode=numeric value="${cmCountB}" autocomplete=off><div class=hint id=cmCapHint style="margin-top:4px">Counts include the original — 4 × 6 fills a 4-by-6 grid (max 100).</div>`:''}
2379
- <div class=hint style="margin-top:8px">${nsel} member${nsel===1?'':'s'} selected. <b>Shift</b>=straight · <b>X/Y/F</b> axis · <b>Alt</b>=no snap · type after the first pick for an exact value · <b>Esc</b> cancels. Connections don't copy.</div>`;
2392
+ <div class=hint style="margin-top:8px">${nsel} member${nsel===1?'':'s'} selected. ${view3d?'<b>Shift</b>=straight · <b>X/Y/Z</b> lock (press again to release · <b>F</b> clears; lock two to snap to whichever you drag toward) · <b>Alt</b>=lock out-of-plane':'<b>Shift</b>=straight · <b>X/Y/F</b> axis · <b>Alt</b>=no snap'} · type after the first pick for an exact value · <b>Esc</b> cancels. Connections don't copy.</div>`;
2380
2393
  const wireN=(id,set)=>{const i=document.getElementById(id);if(i)i.onchange=e=>{const n=Math.max(1,Math.min(99,Math.round(Number(e.target.value)||1)));set(n);e.target.value=n;
2381
2394
  const ch=document.getElementById('cmCapHint');if(ch)ch.style.color=(cmArrayMode&&cmCountA*cmCountB>100)?'#fca5a5':'';cmRefreshPrev();};};
2382
2395
  wireN('cmN',n=>cmCount=n);wireN('cmNA',n=>cmCountA=n);wireN('cmNB',n=>cmCountB=n);
@@ -2758,11 +2771,12 @@ function panel(){
2758
2771
  const _dpFI=(view3d&&window.Steel3DView&&window.Steel3DView.frameInfo)?window.Steel3DView.frameInfo():null;
2759
2772
  const _dp3d=!!(_dpFI&&_dpFI.mode==='local'); // a 3D UCS (frame3d) is set
2760
2773
  const _dp2d=!!(!view3d&&P&&P.frame); // 2D local axes (P.frame) set
2761
- // A column is a single plan point at a fixed elevation; under a TILTED 3D frame local X′/Y′ would be Z-coupled
2762
- // (no clean 2-DOF answer), so show the column's local row only for a planar frame (2D, or a horizontal 3D UCS).
2763
- const _dpLocal=(_dp3d||_dp2d)&&(!col||_dp2d||(_dp3d&&_dpFI.horizontal));
2764
- const _dpZin=i=>col?(i===0?(Number.isFinite(+m.col.bos)?+m.col.bos:0):(Number.isFinite(+m.col.tos)?+m.col.tos:defaultTOS)):effEndTos(m.ends[i]);
2765
- const _dpGlobal=i=>[m.wp[i][0]*12/_dpPpf,-m.wp[i][1]*12/_dpPpf,_dpZin(i)]; // end i → world point, inches
2774
+ const _dpLocal=_dp3d||_dp2d;
2775
+ // A column is plumb: its two definition points share the plan point (wp[0]) and differ only in elevation —
2776
+ // Bottom = BOS, Top = TOS (respecting the "follow default" flag). A beam's two ends can differ in all of X/Y/Z.
2777
+ const _dpColZ=i=>i===0?(Number.isFinite(+m.col.bos)?+m.col.bos:0):(m.col.tosDef!==false?defaultTOS:(Number.isFinite(+m.col.tos)?+m.col.tos:defaultTOS));
2778
+ const _dpZin=i=>col?_dpColZ(i):effEndTos(m.ends[i]);
2779
+ const _dpGlobal=i=>{const p=col?m.wp[0]:m.wp[i];return [p[0]*12/_dpPpf,-p[1]*12/_dpPpf,_dpZin(i)];}; // point i → world, inches (a column's Bottom/Top share wp[0])
2766
2780
  const _dpToLocal=g=>{ // world-in [x,y,z] → local-in, or null
2767
2781
  if(_dp3d){const o=_dpFI.origin,X=_dpFI.xAxis,Y=_dpFI.yAxis,Z=_dpFI.normal,d=[g[0]*25.4-o[0],g[1]*25.4-o[1],g[2]*25.4-o[2]];
2768
2782
  return [(d[0]*X[0]+d[1]*X[1]+d[2]*X[2])/25.4,(d[0]*Y[0]+d[1]*Y[1]+d[2]*Y[2])/25.4,(d[0]*Z[0]+d[1]*Z[1]+d[2]*Z[2])/25.4];}
@@ -2775,23 +2789,24 @@ function panel(){
2775
2789
  if(_dp2d){const o=P.frame.o,u=P.frame.u,du=l[0]*_dpPpf/12,dv=l[1]*_dpPpf/12,px=o[0]+du*u[0]+dv*u[1],py=o[1]+du*u[1]-dv*u[0];
2776
2790
  return [px*12/_dpPpf,-py*12/_dpPpf,l[2]];}
2777
2791
  return null;};
2778
- // Commit a new world-in point Pt=[x,y,z] to end i. Column stays plumb (both wp) and leaves BOS/TOS to the
2779
- // Elevation section (Pt[2] unused for a column); a beam writes wp[i], and touches this end's TOS ONLY when the
2780
- // world Z actually changed — so a plain X/Y move keeps the end following the sheet default (a local-axis edit
2781
- // under a tilted 3D frame legitimately changes Z and DOES clear the default, which this comparison allows).
2782
- const _dpCommit=(i,Pt)=>edit(()=>{const nx=Pt[0]*_dpPpf/12,ny=-Pt[1]*_dpPpf/12;
2783
- if(col){m.wp[0]=[nx,ny];m.wp[1]=[nx,ny];}
2784
- else{m.wp[i]=[nx,ny];if(Math.abs(Pt[2]-effEndTos(m.ends[i]))>1e-6){m.ends[i].tos=Pt[2];m.ends[i].tosDef=false;}}});
2785
- const _dpAxes=col?['X','Y']:['X','Y','Z']; // a column has one plan point → X/Y only
2792
+ // Commit a new world-in point Pt=[x,y,z] to point i. A column stays plumb — X/Y write BOTH wp; Z writes this
2793
+ // point's elevation (Bottom→col.bos, Top→col.tos). Touch the elevation ONLY when world Z actually changed, so a
2794
+ // plain X/Y move keeps a default-following Top on the sheet default (a tilted-frame local edit that really moves
2795
+ // Z still clears it). Same per-end TOS rule for a beam.
2796
+ const _dpCommit=(i,Pt)=>edit(()=>{const nx=Pt[0]*_dpPpf/12,ny=-Pt[1]*_dpPpf/12,zChg=Math.abs(Pt[2]-_dpZin(i))>1e-6;
2797
+ if(col){m.wp[0]=[nx,ny];m.wp[1]=[nx,ny];
2798
+ if(zChg){if(i===0)m.col.bos=Pt[2];else{m.col.tos=Pt[2];m.col.tosDef=false;}}}
2799
+ else{m.wp[i]=[nx,ny];if(zChg){m.ends[i].tos=Pt[2];m.ends[i].tosDef=false;}}});
2800
+ const _dpAxes=['X','Y','Z'];
2786
2801
  const _dpPH='5 3/4&quot; · 1&#39;-0 1/4&quot;';
2787
2802
  const _dpIn=(id,lbl,vin)=>{const v=Math.abs(vin)<1e-6?0:vin;return `<label class=detf><span>${lbl}</span><input id=${id} inputmode=decimal placeholder="${_dpPH}" value="${esc(fmtFtIn(v))}" autocomplete=off></label>`;}; // snap float-noise to 0 (no "-0"" from a local round-trip)
2788
2803
  const _dpBlock=(i,head)=>{const g=_dpGlobal(i),loc=_dpLocal?_dpToLocal(g):null;
2789
2804
  const grow=`<div class=detrow>${_dpAxes.map((ax,a)=>_dpIn('dpG_'+i+'_'+a,ax,g[a])).join('')}</div>`;
2790
2805
  const lrow=loc?`<div class=elab style="color:#22d3ee;margin:4px 0 0">Local frame</div><div class="detrow dp-local">${_dpAxes.map((ax,a)=>_dpIn('dpL_'+i+'_'+a,ax+'′',loc[a])).join('')}</div>`:'';
2791
2806
  return head+(loc?'<div class=elab style="margin:2px 0 0">Global</div>':'')+grow+lrow;};
2792
- const defPts=`<div class=divrow><hr><span class=sect style="margin:0" data-tip="The member's start &amp; end work points in global coordinates${_dpLocal?' and the current local frame':''}. Type a value to move that end.">Definition points</span><hr></div>`
2807
+ const defPts=`<div class=divrow><hr><span class=sect style="margin:0" data-tip="The member's two work points in global coordinates${_dpLocal?' and the current local frame':''}. Type a value to move that point.">Definition points</span><hr></div>`
2793
2808
  +(col
2794
- ? `<div class=hint style="margin:0 0 4px">A column runs plumb — one plan position; its elevation (bottom → top) is set above.</div>`+_dpBlock(0,`<div class=sect>Plan position</div>`)
2809
+ ? `<div class=hint style="margin:0 0 4px">A column is plumb — Bottom &amp; Top share the plan X/Y (edit either); Z is the base / top-of-steel elevation.</div>`+_dpBlock(0,`<div class=sect>${dotS}Bottom</div>`)+`<div class=divrow><hr></div>`+_dpBlock(1,`<div class=sect>${dotE}Top</div>`)
2795
2810
  : _dpBlock(0,`<div class=sect>${dotS}Start</div>`)+`<div class=divrow><hr></div>`+_dpBlock(1,`<div class=sect>${dotE}End</div>`));
2796
2811
  p.innerHTML=`<h3>Member ${esc(m.id)}</h3>
2797
2812
  ${typeFilterHTML()}
@@ -2913,7 +2928,7 @@ function panel(){
2913
2928
  else{Pt=g.slice();Pt[a]=vin;}
2914
2929
  if(Pt)_dpCommit(i,Pt);};};
2915
2930
  const wireEnd=i=>_dpAxes.forEach((ax,a)=>{dpWire('dpG_'+i+'_'+a,i,a,false);if(_dpLocal)dpWire('dpL_'+i+'_'+a,i,a,true);});
2916
- wireEnd(0);if(!col)wireEnd(1);}
2931
+ wireEnd(0);wireEnd(1);} // both points (beam Start/End, column Bottom/Top)
2917
2932
  document.getElementById('del').onclick=()=>edit(()=>{P.members=P.members.filter(x=>x.id!==m.id);selIds.clear();if(selDimIds.size){P.dims=P.dims.filter(d=>!selDimIds.has(d.id));selDimIds.clear();}}); // also drop any dims a mixed marquee selected
2918
2933
  {const vb=document.getElementById('verifyBtn');if(vb)vb.onclick=()=>edit(()=>{m.verified=!m.verified;});}
2919
2934
  }
@@ -2937,6 +2952,13 @@ let snapOnly=null; // Tekla-style TRANSIENT override: one snap kind ('end'|'in
2937
2952
  const SNAP_PREF_KEY='steel:snapPrefs:v1', SNAP_DEFAULTS={end:true,int:true,mid:true,line:true,ext:false,perp:false,par:false};
2938
2953
  let snapEnabled=(()=>{try{return Object.assign({},SNAP_DEFAULTS,JSON.parse(localStorage.getItem(SNAP_PREF_KEY)||'{}'));}catch(_){return {...SNAP_DEFAULTS};}})();
2939
2954
  function saveSnapPrefs(){try{localStorage.setItem(SNAP_PREF_KEY,JSON.stringify(snapEnabled));}catch(_){}}
2955
+ // The SNAP-bar "3D snapping" MODE — distinct from the running-snap TYPES above (it gates WHERE they may
2956
+ // land, not which are on). ON (default) = snap freely to any point in 3D at any elevation; OFF = constrain
2957
+ // 3D placement snapping (Move/Copy/Add) to the current working plane. 3D-only surface; read live by the 3D
2958
+ // view (api.snap3dFree). Own persistence key so it never mixes into the per-type snapEnabled map.
2959
+ const SNAP3D_KEY='steel:snap3dFree:v1';
2960
+ let snap3dFree=(()=>{try{return localStorage.getItem(SNAP3D_KEY)!=='0';}catch(_){return true;}})(); // default ON; only an explicit '0' is OFF (unset OR a corrupted value falls back to the ON default)
2961
+ function saveSnap3d(){try{localStorage.setItem(SNAP3D_KEY,snap3dFree?'1':'0');}catch(_){}}
2940
2962
  // ── Selection filter (Tekla "select switches"): which object CLASSES — and which member types /
2941
2963
  // connection kinds — may enter a selection. One persisted source of truth, consulted at every pick
2942
2964
  // sink (2D click/marquee/Ctrl+A, 3D pick/box). Default: everything ON, so nothing is filtered out
@@ -4165,8 +4187,8 @@ addEventListener('keydown',e=>{
4165
4187
  if(dk==='c'){e.preventDefault();toggleDimChain();return;}} // C — toggle chained (continuous) dimensioning
4166
4188
  if(cmTool&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ak=e.key.toLowerCase(); // Move/Copy armed: X/Y/F force the axis, Z (3D only) locks the frame normal, typing opens the exact-value HUD
4167
4189
  if(ak==='x'||ak==='y'||ak==='f'||(ak==='z'&&view3d)){e.preventDefault(); // Z is 3D-only (the normal-axis lock); 2D has no Z, and Alt+Z stays Zoom-Selected (never reaches here — this block requires !altKey)
4168
- if(view3d&&window.Steel3DView&&window.Steel3DView.setCmAxis)window.Steel3DView.setCmAxis(ak);
4169
- else{cmAxis=ak==='f'?'free':ak;cmRefreshPrev();}return;}
4190
+ if(view3d&&window.Steel3DView&&window.Steel3DView.setCmAxis)window.Steel3DView.setCmAxis(ak,e.shiftKey); // pass live Shift so the immediate 3D preview refresh matches a click (Alt is up here — this block requires it)
4191
+ else{const wa=ak==='f'?'free':ak;cmAxis=(wa!=='free'&&cmAxis===wa)?'free':wa;cmRefreshPrev();}return;} // same axis key again toggles the lock off (F always frees)
4170
4192
  const hasBase=cmDraft||(view3d&&window.Steel3DView&&window.Steel3DView.cmHasBase&&window.Steel3DView.cmHasBase());
4171
4193
  if(hasBase&&/^[0-9.\-',]$/.test(e.key)){e.preventDefault();cmHudShow(e.key);return;}} // comma included so a leading-comma entry (,Y) can open the HUD
4172
4194
  if(view3d&&mode==='add'&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&/^[0-9.\-',]$/.test(e.key)){e.preventDefault();cmHudShow(e.key);return;} // 3D Add-member: typing opens the shared point-entry HUD (own branch, OUTSIDE the Move/Copy guard)
@@ -4215,12 +4237,36 @@ moreMenu.addEventListener('click',e=>{if(e.target.closest('button')&&!e.target.c
4215
4237
  // call it, so they can't drift. The transient right-click override is separate and never writes here. ---
4216
4238
  const snapBar=document.getElementById('snapBar');
4217
4239
  function reflectSnapPrefs(){
4218
- for(const b of moreMenu.querySelectorAll('button.msnap')){const on=snapEnabled[b.dataset.snap]!==false;b.classList.toggle('on',on);b.setAttribute('aria-checked',String(on));}
4219
- for(const b of snapBar.querySelectorAll('button')){const on=snapEnabled[b.dataset.snap]!==false;b.classList.toggle('on',on);b.setAttribute('aria-pressed',String(on));}}
4240
+ for(const b of moreMenu.querySelectorAll('button.msnap[data-snap]')){const on=snapEnabled[b.dataset.snap]!==false;b.classList.toggle('on',on);b.setAttribute('aria-checked',String(on));}
4241
+ for(const b of snapBar.querySelectorAll('button[data-snap]')){const on=snapEnabled[b.dataset.snap]!==false;b.classList.toggle('on',on);b.setAttribute('aria-pressed',String(on));}}
4220
4242
  function toggleSnap(k){snapEnabled[k]=!(snapEnabled[k]!==false);saveSnapPrefs();reflectSnapPrefs();snapClear();} // clear any stale marker so the change shows on the next move
4221
- for(const b of moreMenu.querySelectorAll('button.msnap'))b.onclick=e=>{e.stopPropagation();toggleSnap(b.dataset.snap);}; // menu switch (keeps the menu open — settings, not a one-shot action)
4222
- for(const b of snapBar.querySelectorAll('button'))b.onclick=()=>toggleSnap(b.dataset.snap); // quick-bar glyph
4243
+ for(const b of moreMenu.querySelectorAll('button.msnap[data-snap]'))b.onclick=e=>{e.stopPropagation();toggleSnap(b.dataset.snap);}; // menu switch (keeps the menu open — settings, not a one-shot action)
4244
+ for(const b of snapBar.querySelectorAll('button[data-snap]'))b.onclick=()=>toggleSnap(b.dataset.snap); // quick-bar glyph
4223
4245
  reflectSnapPrefs();
4246
+ // The 3D-snapping MODE toggle rides both surfaces too (bar button = aria-pressed, ⋯ row = aria-checked),
4247
+ // but writes its own snap3dFree (not the per-type map). 3D-only (CSS-hidden in 2D). No marker to clear —
4248
+ // the next canvas hover re-evaluates candidates against the new mode (the view reads api.snap3dFree live).
4249
+ const snap3dBtns=[...document.querySelectorAll('[data-snap3d]')];
4250
+ function reflectSnap3d(){for(const b of snap3dBtns){b.classList.toggle('on',snap3dFree);b.setAttribute(b.classList.contains('msnap')?'aria-checked':'aria-pressed',String(snap3dFree));}}
4251
+ function toggleSnap3d(){snap3dFree=!snap3dFree;saveSnap3d();reflectSnap3d();}
4252
+ for(const b of snap3dBtns)b.onclick=e=>{e.stopPropagation();toggleSnap3d();};
4253
+ reflectSnap3d();
4254
+ // Property-panel width: draggable handle on its left edge (persisted, clamped so it can't swallow the canvas).
4255
+ (function(){
4256
+ const rz=document.getElementById('panelResizer'); if(!rz)return;
4257
+ const KEY='steel:panelw:v1', MIN=240, root=document.documentElement, pnl=document.getElementById('panel');
4258
+ const maxW=()=>Math.max(MIN,Math.min(680,Math.round(window.innerWidth*0.6)));
4259
+ const curW=()=>{const v=parseFloat(getComputedStyle(root).getPropertyValue('--panelw')); return Number.isFinite(v)?v:pnl.getBoundingClientRect().width;}; // read the source-of-truth var (border-box, == what apply() sets); getComputedStyle(pnl).width is the CONTENT box (25px short → drift)
4260
+ const apply=(w,save)=>{const c=Math.round(Math.max(MIN,Math.min(maxW(),w)));root.style.setProperty('--panelw',c+'px');if(save)localStorage.setItem(KEY,String(c));};
4261
+ const saved=parseFloat(localStorage.getItem(KEY)); if(Number.isFinite(saved))apply(saved,false);
4262
+ let startX=0,startW=0;
4263
+ const onMove=e=>apply(startW+(startX-e.clientX),false); // handle on the panel's LEFT edge → drag left = wider
4264
+ const onUp=()=>{rz.classList.remove('drag');document.body.style.userSelect='';window.removeEventListener('pointermove',onMove);window.removeEventListener('pointerup',onUp);localStorage.setItem(KEY,String(Math.round(curW())));};
4265
+ rz.addEventListener('pointerdown',e=>{e.preventDefault();startX=e.clientX;startW=curW();rz.classList.add('drag');document.body.style.userSelect='none';window.addEventListener('pointermove',onMove);window.addEventListener('pointerup',onUp);});
4266
+ rz.addEventListener('dblclick',()=>{root.style.removeProperty('--panelw');localStorage.removeItem(KEY);}); // reset to the 240px default
4267
+ rz.addEventListener('keydown',e=>{if(e.key==='ArrowLeft'){e.preventDefault();apply(curW()+(e.shiftKey?40:12),true);}else if(e.key==='ArrowRight'){e.preventDefault();apply(curW()-(e.shiftKey?40:12),true);}});
4268
+ window.addEventListener('resize',()=>{if(root.style.getPropertyValue('--panelw'))apply(curW(),false);}); // re-clamp if the viewport shrank
4269
+ })();
4224
4270
  // --- Selection-filter toolbar (Select bar): same discipline as the snap bar — selFilter is the one source
4225
4271
  // of truth; the 4 class switches + the two type flyouts (Members / Connections) all reflect off it, and every
4226
4272
  // toggle persists + re-renders. Tekla-style: a switch gates what future picks CAN select — it does NOT
@@ -4316,7 +4362,9 @@ const view3dApi={
4316
4362
  if(mode==='add'){mode='sel';setMode();}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D box-select → shared selection
4317
4363
  getMembers:()=>P.members, // active-sheet members (wp) for snap geometry (one ppf)
4318
4364
  allMembers, // EVERY sheet's members — the 3D box-select tests all visible meshes, not just the active sheet's
4365
+ membersByPlan:()=>((C&&Array.isArray(C.plans))?C.plans:[]).map(p=>({members:p.members||[],ptPerFt:(p.pt_per_ft>0?p.pt_per_ft:1),defaultTosMm:(p.default_tos!=null?p.default_tos:0)*25.4})), // every sheet's members WITH its OWN px→ft scale AND its OWN default T.O.S — 3D snapping targets the whole model (any elevation), each plan resolved exactly like the server bake (contract-to-scene: per-plan pt_per_ft + `default_tos ?? 0`) so candidates land on the rendered steel. Guards a not-yet-loaded contract (C.plans absent) so a hover can't throw out of the pointer handler.
4319
4366
  snapEnabled:()=>snapEnabled, // the persistent running-snaps (⋯ menu → Snapping) — 3D honours the same on/off set
4367
+ snap3dFree:()=>snap3dFree, // SNAP-bar "3D snapping" mode — ON: free 3D snap; OFF: 3D placement snap constrained to the working plane
4320
4368
  canSelectId:(id)=>selIdOK(id), // Select-filter predicate for the 3D view (e.g. don't draw a whole-connection envelope for a fully-filtered connection)
4321
4369
  ptPerFt:()=>(P&&P.pt_per_ft>0?P.pt_per_ft:1),
4322
4370
  defaultTosMm:()=>(defaultTOS!=null?defaultTOS*25.4:0), // editor stores default T.O.S in inches
@@ -783,7 +783,7 @@
783
783
  function kbPending(st) {
784
784
  if (st.organize) return { started: true, since: Date.parse(st.organize.startedAt) };
785
785
  const q = st.queued[0];
786
- if (q) return { started: false, since: Date.parse(q.createdAt) };
786
+ if (q) return { started: false, since: Date.parse(q.createdAt), id: q.id }; // id: which queued request Cancel deletes
787
787
  return null;
788
788
  }
789
789
  const kbAgo = (ms) => {
@@ -862,10 +862,19 @@
862
862
  : '<span class="kb-ico" aria-hidden="true">◷</span>';
863
863
  const lead = pending.started
864
864
  ? `Organizing…${age ? ` started ${escapeHtml(age)}` : ''}`
865
- : 'Queued for your terminal AI — waiting to start…';
865
+ : `Queued for your terminal AI — waiting to start…${age ? ` (${escapeHtml(age)})` : ''}`;
866
+ // A queued organize (not yet started) can be cancelled — at that point there is no organize lock
867
+ // to strand, so this is the immediate, user-initiated escape from a button wedged by an organize
868
+ // no terminal AI drains (the 24h TTL sweep is the automatic backstop). It sits INSIDE the text
869
+ // span, flowing like a trailing word: the rail is too narrow to pin a separate control beside text
870
+ // that may wrap. Never offered once started — a running pass is lifecycle-owned (its finish/fail
871
+ // clears it), and the guarded DELETE route refuses it (409) anyway.
872
+ const cancel = (!pending.started && pending.id)
873
+ ? ` <button type="button" class="kb-pending-cancel" data-kb-cancel-organize="${escapeAttr(pending.id)}" data-tip="Cancel — you can queue a new organize anytime">Cancel</button>`
874
+ : '';
866
875
  pendingLine = `<div class="${cls}">${ico}<span>${lead}` +
867
876
  (stale ? ' <span class="kb-stale">taking longer than expected — check your terminal AI is running.</span>' : '') +
868
- '</span></div>';
877
+ cancel + '</span></div>';
869
878
  }
870
879
 
871
880
  let status;
@@ -873,7 +882,8 @@
873
882
  else if (gen) {
874
883
  status = `<span class="ok">✓ organized</span> · ${escapeHtml(kbAgo(Date.now() - Date.parse(gen.publishedAt)))}` +
875
884
  (st.manifest.lastLintSummary ? ` · ${escapeHtml(st.manifest.lastLintSummary)}` : '');
876
- } else status = st.sources.length ? 'Not yet organized — press Organize when you’re ready.' : '';
885
+ } else if (pending) status = ''; // the pending line already narrates it — never invite a press on the (correctly) disabled Organize
886
+ else status = st.sources.length ? 'Not yet organized — press Organize when you’re ready.' : '';
877
887
 
878
888
  // Organize is this panel's ONE persistent primary action — always visible, even at zero sources,
879
889
  // because its presence teaches the two-step model (collect, then Organize). When unavailable it
@@ -1448,6 +1458,37 @@
1448
1458
  if (current === proj) renderKnowledge();
1449
1459
  }
1450
1460
 
1461
+ // Cancel a QUEUED (not-yet-started) organize via its GUARDED lifecycle route — the immediate,
1462
+ // user-initiated escape from an Organize button wedged by an organize no terminal AI drained (the
1463
+ // server-side 24h TTL sweep is the automatic backstop). The SERVER decides safety atomically: it
1464
+ // refuses (409 already-started) the instant the pass is in flight, so the client can never strand
1465
+ // the organize lock by racing the terminal AI's /start. A module re-entry flag stops a fast
1466
+ // double-click firing a second (404-ing) delete. renderKnowledge() repaints the true state either way.
1467
+ let kbCancelBusy = false;
1468
+ async function kbCancelOrganize(reqId) {
1469
+ const proj = current;
1470
+ if (!proj || !reqId || kbCancelBusy) return;
1471
+ kbCancelBusy = true;
1472
+ try {
1473
+ await api(kbUrl(proj.id, `/requests/${encodeURIComponent(reqId)}`), { method: 'DELETE' });
1474
+ showToast('Organize cancelled — queue a new one anytime', 'ok');
1475
+ track('kb_organize_cancelled', { app: proj.app });
1476
+ } catch (err) {
1477
+ const code = err && err.body && err.body.code;
1478
+ // already-started: the terminal AI won a fair race — not a failure; the repaint shows "Organizing…".
1479
+ // not-found: already gone (drained/cancelled elsewhere) — silent; the repaint shows it's cleared.
1480
+ if (code === 'already-started') showToast('Organize already started — it’ll finish in your terminal', 'warn');
1481
+ else if (code !== 'not-found') showToast('Couldn’t cancel: ' + ((err && err.message) || err), 'warn');
1482
+ } finally {
1483
+ kbCancelBusy = false;
1484
+ // Refresh the footer Requests counter now for immediate feedback. (The guarded DELETE also
1485
+ // broadcasts requests-changed, which loadRequests()es in this tab too — but async; this is the
1486
+ // ahead-of-SSE immediacy call, mirroring kbOrganize/kbAdjustSubmit.)
1487
+ if (bridge.loadRequests) await bridge.loadRequests();
1488
+ if (current === proj) renderKnowledge();
1489
+ }
1490
+ }
1491
+
1451
1492
  // Live-toggle the Adjust submit from the textarea content (the generated HTML always renders it
1452
1493
  // empty+disabled; this reflects what the user has actually typed, between repaints). An IMPERATIVE
1453
1494
  // refs-DOM mutation the generated HTML never encodes — so it must NOT kbInvalidateRefs() (that would
@@ -1604,6 +1645,8 @@
1604
1645
  if (x) { rowEl.scrollIntoView({ block: 'nearest' }); x.click(); }
1605
1646
  return;
1606
1647
  }
1648
+ const cancelOrg = e.target.closest('[data-kb-cancel-organize]');
1649
+ if (cancelOrg) { kbCancelOrganize(cancelOrg.getAttribute('data-kb-cancel-organize')); return; }
1607
1650
  const org = e.target.closest('#kb-organize');
1608
1651
  if (org) { if (org.getAttribute('aria-disabled') !== 'true') kbOrganize(); return; } // aria-disabled still receives clicks
1609
1652
  const adjBtn = e.target.closest('#kb-adjust-submit');
@@ -2318,10 +2361,34 @@
2318
2361
  doProjectAction(act.dataset.act, menuFor);
2319
2362
  });
2320
2363
 
2364
+ // Ring the card that just changed so the eye lands on it before the background reload repaints —
2365
+ // reuses the existing card-pulse glow. A freshly-duplicated/renamed card is unshifted to the top
2366
+ // (usually already visible), so scrollIntoView is a no-op unless the grid was scrolled. The
2367
+ // animationend handler ends the glow ~0.6s later; if a reconcile repaint (or reduced-motion, where
2368
+ // there is no animation) gets there first, renderLanding's full innerHTML rebuild drops `is-new`
2369
+ // anyway — so nothing sticks either way.
2370
+ function flashCard(id, opts) {
2371
+ const el = $landing.querySelector(`.ws-card[data-open="${escapeAttr(id)}"]`);
2372
+ if (!el) return;
2373
+ if (opts && opts.scroll) el.scrollIntoView({ block: 'nearest' });
2374
+ el.classList.add('is-new');
2375
+ el.addEventListener('animationend', () => el.classList.remove('is-new'), { once: true });
2376
+ }
2377
+
2321
2378
  // Shared rename/duplicate/archive — used by both the kebab menu (one project, from the
2322
2379
  // landing grid) and the header project-picker's inline row actions below (any project,
2323
2380
  // from anywhere). Never switches projects itself — the caller decides navigation.
2381
+ // Each branch updates the local `projects` array from the endpoint's result (unshift a duplicate,
2382
+ // move a rename to the front, filter out an archive — the unshift mirrors createSeeded/
2383
+ // createFromDrawing) and repaints the grid IMMEDIATELY, so the change is on screen WITH the toast
2384
+ // instead of seconds later when loadProjects() re-fetches; the trailing loadProjects() is then just
2385
+ // a background reconcile. projActionBusy blocks a double-submit (e.g. Duplicate twice on a large
2386
+ // project whose copy is still in flight) — a re-entry while one is in flight is toasted, not
2387
+ // silently dropped, so the user knows why the second click did nothing.
2388
+ let projActionBusy = false;
2324
2389
  async function doProjectAction(action, id) {
2390
+ if (projActionBusy) { showToast('Hold on — finishing the last action…', 'warn'); return; }
2391
+ projActionBusy = true;
2325
2392
  const proj = projects.find((p) => p.id === id);
2326
2393
  try {
2327
2394
  if (action === 'rename') {
@@ -2329,16 +2396,30 @@
2329
2396
  if (!name) return;
2330
2397
  const { project } = await api(`/api/projects/${encodeURIComponent(id)}`, { method: 'PATCH', body: JSON.stringify({ name }) });
2331
2398
  if (current && current.id === id) { current = project; $projName.textContent = project.name; $crumbName.textContent = project.name; }
2332
- showToast('Renamed', 'ok');
2399
+ // Rename bumps updatedAt server-side and the grid is newest-activity-first, so the reconcile
2400
+ // will move this card to the front regardless. Do that move now (not an in-place swap) so it
2401
+ // happens once, with the flash, rather than as a jump a second later when loadProjects() lands.
2402
+ const i = projects.findIndex((p) => p.id === id);
2403
+ if (i >= 0) projects.splice(i, 1);
2404
+ projects.unshift(project);
2405
+ renderLanding();
2406
+ flashCard(project.id, { scroll: true });
2407
+ showToast(`Renamed to "${project.name}"`, 'ok');
2333
2408
  } else if (action === 'duplicate') {
2334
2409
  const { project } = await api(`/api/projects/${encodeURIComponent(id)}/duplicate`, { method: 'POST', body: '{}' });
2410
+ projects.unshift(project); // newest → front, matching the server's newest-first list order
2411
+ renderLanding();
2412
+ flashCard(project.id, { scroll: true });
2335
2413
  showToast(`Duplicated as "${project.name}"`, 'ok');
2336
2414
  } else if (action === 'archive') {
2337
2415
  await api(`/api/projects/${encodeURIComponent(id)}/archive`, { method: 'POST', body: '{}' });
2416
+ projects = projects.filter((p) => p.id !== id); // drop the card now, don't wait for the reload
2417
+ renderLanding(); // repaint BEFORE the closeProject early-return so archive-current reveals a fresh (card-gone) grid too
2338
2418
  showToast('Archived — recoverable from ~/.floless/projects/.archive', 'ok');
2339
2419
  if (current && current.id === id) { closeProject(); return; }
2340
2420
  }
2341
2421
  } catch (err) { showToast('Action failed: ' + (err && err.message || err), 'warn'); }
2422
+ finally { projActionBusy = false; }
2342
2423
  loadProjects();
2343
2424
  }
2344
2425
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.93.1",
3
+ "version": "0.94.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": {