@floless/app 0.111.3 → 0.112.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.
@@ -55,7 +55,7 @@ each learned from a real failure:
55
55
  mark / grid) or as **per-column size tags at each base**. That sheet is the biggest candidate; make
56
56
  reading it for column sizes a REQUIRED step, not an afterthought. (Designers occasionally put the
57
57
  schedule elsewhere — a general/schedule sheet, or sections/details through the column, or a general
58
- note like "ALL COLS HSS6×6×3/8 UON" — so if the foundation plan doesn't have it, keep looking there.)
58
+ note like "ALL COLS HSS6X6X3/8 UON" — so if the foundation plan doesn't have it, keep looking there.)
59
59
  Match each plan column to its size by **grid mark** (+ story). Only when the size is genuinely
60
60
  nowhere in the entire set — foundation plan checked FIRST — does the column stay `rfi:true`.
61
61
  - **Column ROTATION (`rot`) is MANDATORY — and derive it from the FLANGE-SEGMENT INK, not the bounding
@@ -264,18 +264,27 @@ native/display coords):
264
264
  **On a `steel.model/v2` model it takes less — `filter` plus per-sheet `{ datum_at, datum_ref,
265
265
  control2_at, control2_ref, elevation_in }`, and no grid or datum at all.** Check the `type` in the
266
266
  document you just GET-ed. A v2 model keeps ONE grid for the whole model instead of one per sheet, and
267
- that grid is not writable from a read: the human moves it in the editor's Grid panel. Sending a
268
- `grid` or a `datum` earns a `400` that says so. So on v2: **skip §1c entirely, and in §1d skip only
267
+ that grid is not writable from THIS verb: the human moves it in the editor's Grid panel, and a
268
+ re-read proposes a move through its own contract (§1c). Sending a
269
+ `grid` or a `datum` HERE earns a `400` that says so. So on v2: **skip §1c's pre-read part, and in §1d skip only
269
270
  the root `datum` block — the per-sheet registration in §1d is still yours to write**, and a migrated
270
271
  model usually has none of it yet. Everything else in this section is unchanged.
271
272
 
272
273
  ### 1c. Grid lines — read the printed grid (quick, per sheet)
273
274
 
274
- > **`steel.model/v2` models: SKIP this section.** A v2 model already has its grid — one grid for the
275
- > whole model, worked out when the model was migrated — and it is not something a read may change. If
276
- > you send one you will get a `400` explaining that the grid belongs to the human, who moves it in the
277
- > editor's Grid panel. If a revised set genuinely shows the grid in a new place, say so in your summary
278
- > so the user can move it; do not try to write it.
275
+ > **`steel.model/v2` models: SKIP this section for the PRE-READ pass — but carry the grid in the
276
+ > contract you re-read.** Two different endpoints, and the difference matters:
277
+ >
278
+ > - **The pre-read verb (`/steel-prepass`) still refuses a grid.** A v2 model keeps ONE grid for the
279
+ > whole model, so there is no per-sheet `grid` to send. You will get a `400` saying so.
280
+ > - **The re-read contract (`POST /revision-read`) carries the model grid, at the root, as `grid`.**
281
+ > Copy the CURRENT model's `grid` through unchanged — do not drop the key. If the revised set
282
+ > genuinely shows the printed grid in a new place, write the new grid there instead: it is staged as
283
+ > a **proposal the user accepts** in the review, never a silent write.
284
+ >
285
+ > **Never omit `grid` to mean "I did not change it".** Omitting a key is not how you say that — copy
286
+ > it through. (A read that drops it is refused and reported, precisely so an omission can never be
287
+ > mistaken for "delete the model grid".) Removing the grid is a human edit in the editor, not a read.
279
288
 
280
289
  With the filter elements in hand, populate each plan's **`plan.grid`** (Tekla-style grid lines the
281
290
  editor renders in 2D + 3D and snaps to). The geometry is deterministic — the editor's Grid panel has
@@ -307,7 +316,8 @@ Skip silently only when the sheet genuinely has no grid bubbles (rare for framin
307
316
 
308
317
  > **`steel.model/v2` models: the root `datum` part is SKIPPED, the per-sheet part is not.** A v2 model
309
318
  > has no root `datum`: the "which intersection is 0,0,0" question was answered when the model was
310
- > migrated, and the answer lives in the model grid's origin, which a read may not move. **The per-sheet
319
+ > migrated, and the answer lives in the model grid's origin, which the pre-read verb may not move (a
320
+ > re-read may PROPOSE a new grid — see §1c). **The per-sheet
311
321
  > registration below is still yours to write** — `datum_at`, `datum_ref`, `control2_at`, `control2_ref`
312
322
  > — because those say something different: where that already-chosen origin falls on THIS sheet. A
313
323
  > migrated model usually has none of them yet, so this is real work, not a no-op. Send them under
@@ -1128,6 +1138,12 @@ their `id`, scoped per `sheet`. So the re-read must keep identity stable:
1128
1138
  3. Then compose the updated `steel.takeoff/v1` and `POST /api/projects/<projectId>/revision-read
1129
1139
  { contract, message, requestId }` (that POST clears the request — do **not** DELETE it).
1130
1140
 
1141
+ > **On a `steel.model/v2` project compose a `steel.model/v2` document instead** — check the `type`
1142
+ > of the contract you GET-ed in step 1. Members live in one root `members[]` in world millimetres,
1143
+ > and the root **`grid` comes across unchanged** unless the revised set shows the printed grid in a
1144
+ > new place, in which case write the new one and it becomes a proposal the user accepts (§1c).
1145
+ > Never drop the `grid` key to mean "unchanged" — a read that omits it is refused.
1146
+
1131
1147
  If you renumber everything, the diff shows a misleading "all removed + all added" and the app warns
1132
1148
  **"identity not preserved."** Carrying ids forward is what makes *"beam B12 was upsized"* come out
1133
1149
  exact instead of a churn of the whole model.
@@ -265,7 +265,15 @@ any external count.
265
265
  label ~20 px.
266
266
  - Place each member by the **grid lines it spans** + its level. Read its size label; **confirm size
267
267
  against the schedule** (column schedule = authoritative per tier/splice; beam schedule maps marks).
268
- Map W18×35 = wide-flange, 18" nominal depth, 35 lb/ft, etc.
268
+ Map W18X35 = wide-flange, 18" nominal depth, 35 lb/ft, etc.
269
+ - **Transcribe the designation as ASCII.** Drawing text and OCR routinely emit typographic
270
+ lookalikes — the multiplication sign in place of `X`, en/em dashes for the hyphen, primes for
271
+ inch marks, non-breaking spaces, Cyrillic characters that render identically. Downstream
272
+ lookups match the literal string, so ONE lookalike turns a known section into an unknown one:
273
+ no real dimensions, a placeholder solid in 3D/IFC/the host model, and a size that still reads
274
+ correct to a human on screen. Fold to ASCII at the point of extraction, then confirm the
275
+ normalised designation actually resolves against the section table — a designation that "looks
276
+ right" is not evidence it matched.
269
277
  - **Use a structured schema that enforces the order** (vision agent or your own): fill
270
278
  `coordinate_system → buildings(+roof) → grids_per_building → members`, every value carrying
271
279
  `source_view`, `evidence_bbox`, `confidence`, plus mandatory `unreadable[]` and `contradictions[]`.
@@ -302,6 +310,8 @@ Only then build the scene / overlay / IFC. If unsure, present the **massing + gr
302
310
  - [ ] A member spanning two levels emitted on both plans (doubles the tonnage).
303
311
  - [ ] A size left as an RFI when the set does show it — a lazy RFI is as wrong as a fabricated number.
304
312
  - [ ] A built-up shape (double angle, etc.) taken off as its single component (half the steel).
313
+ - [ ] A designation carrying a typographic lookalike (multiplication sign for `X`, en-dash for `-`,
314
+ prime for `"`) — it renders correctly and silently fails every downstream size lookup.
305
315
  - [ ] Vector coordinates compared against a render without applying the page rotation — silently transposed
306
316
  at 90/270, silently point-reflected at 180 (where the page shape gives no hint at all).
307
317
  - [ ] Sheets identified by extracting text, on a set whose text layer is boilerplate only.
package/dist/web/app.css CHANGED
@@ -4009,6 +4009,71 @@ table.hist tr.current td { background:var(--accent-soft); }
4009
4009
  .rev-issue:last-child { border-bottom:none; }
4010
4010
  .rev-issue-path { font-family:var(--mono); font-size:10.5px; color:var(--text-dim); display:block; margin-top:2px; }
4011
4011
 
4012
+ /* ── Convert to the model (steel.takeoff/v1 → steel.model/v2, unit 5, P7e) ────────────────────────
4013
+ `.migreview` rides on `.modal.revreview` and adds only the genuine deltas. Everything visual — the
4014
+ width, the themed inner scrollbar, the rows, the custom checkboxes at .rev-check — is inherited, so
4015
+ there is no second vocabulary to keep in step. */
4016
+
4017
+ /* The offer banner. Reuses `.ws-exports-gate` wholesale (neutral accent-dim rail, never --warn/--err:
4018
+ an older format is not an error) and only re-homes it, since it sits in the project column rather
4019
+ than the exports pane. */
4020
+ .ws-migrate-gate { margin:12px 20px 0; }
4021
+ /* `[hidden]` DOES NOTHING WITHOUT THIS, and the banner was visible on every project as a result.
4022
+ `.ws-exports-gate` sets `display:flex`, an author-origin rule that beats the UA's
4023
+ `[hidden] { display:none }` — and this stylesheet has no global `[hidden]` rule, only per-class ones
4024
+ (`.ws-drawings-bar[hidden]`, `.ws-revision-card[hidden]`, the `!important` list at :3551). Without it
4025
+ every `$migGate.hidden = true` was a no-op: an empty bordered strip painted under the step tabs for
4026
+ EVERY workspace project, a v1 project's banner followed the user onto Drawings and History, and it
4027
+ survived a successful conversion still offering to convert. Caught by review measuring computed
4028
+ `display`; the browser pass asserted the `hidden` PROPERTY, which was true the whole time. */
4029
+ .ws-migrate-gate[hidden] { display:none; }
4030
+
4031
+ /* AN UNTICKED BOX INSIDE A ROW WAS INVISIBLE, and this is a contrast fix, not a restyle.
4032
+ `.rev-check input` sets `border: var(--border-strong)` on `background: var(--surface-2)` — and those
4033
+ two tokens are THE SAME COLOUR (both hsl(217.2 32.6% 17.5%)). On `.modal-check` that is harmless,
4034
+ because the fork-consent checkbox sits on the darker modal surface where the fill itself reads as the
4035
+ box. Inside `.rev-row`, whose background is ALSO --surface-2, all three match: measured
4036
+ rgb(30,41,59) for the row, the fill and the border alike. The result is a 16×16 invisible square that
4037
+ only appears once focused.
4038
+ Pre-existing and shared with the revision-review modal, so this fixes that surface too — scoped to
4039
+ the row context, which is the only place the collision happens, rather than restyling every consent
4040
+ checkbox in the app. Found by measuring computed styles in the browser pass; a screenshot alone
4041
+ showed "a row with no checkbox" and could not say why. */
4042
+ .rev-row .rev-check input[type="checkbox"] { border-color: var(--text-dim); }
4043
+ .rev-row .rev-check input[type="checkbox"]:hover { border-color: var(--text-muted); }
4044
+ .rev-row .rev-check input[type="checkbox"]:checked { border-color: var(--accent); }
4045
+
4046
+ /* The kind heading — the OUTER grouping axis, above the topic groups. Load-bearing rather than
4047
+ decorative: a topic can carry decisions of both kinds ("Saved views" does), so without this the same
4048
+ title appears twice, one block with a bulk control and one without, and nothing says why. */
4049
+ .mig-section { display:flex; align-items:baseline; gap:8px; flex-wrap:wrap;
4050
+ margin:14px 0 6px; padding-bottom:5px; border-bottom:1px solid var(--border); }
4051
+ .mig-section:first-child { margin-top:2px; }
4052
+ .mig-section-title { font-size:12px; font-weight:600; color:var(--text); letter-spacing:0.01em; }
4053
+ .mig-section-sub { font-size:11px; color:var(--text-dim); }
4054
+
4055
+ /* The tick progress, distinct from `.rev-counts` above the body: that line says what you GET, this one
4056
+ says what is LEFT. Sits tight to the actions it gates, and right-aligned so the eye finds it on the
4057
+ way to the button rather than having to come back up the modal. */
4058
+ .mig-progress { margin:2px 0 8px; text-align:right; }
4059
+ .mig-progress[hidden] { display:none; }
4060
+
4061
+ /* Confirm while anything is unticked. `aria-disabled`, NEVER the `disabled` attribute — the same
4062
+ recipe `.kb-organize` and `.ecard .e-act` use, and for the same reason: a disabled button is neither
4063
+ hoverable nor focusable, so the `data-tip` saying WHY it will not go would never reach the person who
4064
+ needs it. Reads as inert to assistive tech; `confirmMigrate` checks the same attribute, so the gate
4065
+ is behaviour rather than styling. */
4066
+ .migreview .modal-actions button.primary[aria-disabled="true"] {
4067
+ opacity:0.55; cursor:default;
4068
+ background:var(--surface-2); border-color:var(--border-strong); color:var(--text-dim);
4069
+ }
4070
+ .migreview .modal-actions button.primary[aria-disabled="true"]:hover {
4071
+ background:var(--surface-2); border-color:var(--border-strong); color:var(--text-dim);
4072
+ }
4073
+ /* A REFUSED conversion renders no Confirm at all, so the attribute has to actually take: `.modal-actions
4074
+ button` sets a display, which beats the UA's `[hidden]` rule on its own. */
4075
+ .migreview .modal-actions button[hidden] { display:none; }
4076
+
4012
4077
  /* ── Workspaces: revision re-read (Slice 4b) — attach band + pending/failed card ── */
4013
4078
  .ws-drawings-bar { flex:none; display:flex; align-items:center; gap:10px; padding:8px 14px; border-bottom:1px solid var(--border); background:var(--surface); }
4014
4079
  .ws-drawings-bar[hidden] { display:none !important; }
package/dist/web/aware.js CHANGED
@@ -5921,7 +5921,7 @@
5921
5921
  // fabricated elevation silently relocates steel; and what each SHEET showed is recorded as
5922
5922
  // evidence on that plan's `memberObservations` instead of by owning the member.
5923
5923
  if (req.contractType === 'steel.model/v2') {
5924
- return `In floless project "${req.project}" (app "${req.appId}"), a REVISED drawing set was attached — re-read it into the SAME project as a new version (do NOT create a new project). This project holds a steel.model/v2 model, so compose a steel.model/v2 document, NOT a steel.takeoff/v1: members live in ONE root \`members[]\` array in WORLD MILLIMETRES (each with \`from\`/\`to\` as { x, y, z }), not per sheet in display pixels. Member ids are MODEL-GLOBAL — preserve the id of every member the revision still shows and mint a new one only for a genuinely new member; there is no sheet label to preserve alongside it. Where the drawing does not give an elevation, write \`{ unknown: true }\` for that z — never a substituted default, because a fabricated elevation moves steel. Record what each SHEET actually showed as evidence on that plan's \`memberObservations\` (with its \`binding.memberIds\`), and use \`plans[].memberRefs\` for members a sheet displays but never observed. Follow the floless-app-steel-takeoff skill's mandatory two-phase gate exactly as for v1: FIRST GET /api/contract/${req.appId}?project=${req.project} to read the CURRENT model and KEEP its ETag, do the deterministic PyMuPDF steel-filter pass only, send ONLY the pre-read blocks to PUT /api/projects/${req.project}/steel-prepass with { filter } and If-Match: <that ETag> — never the whole contract — then STOP and tell me to open Drawings → Steel Filter, review the facets, and Save. Do NOT read members, build the model, open 3D, or POST /revision-read until I explicitly come back after saving the filter. ${post}${snaps}${note}`;
5924
+ return `In floless project "${req.project}" (app "${req.appId}"), a REVISED drawing set was attached — re-read it into the SAME project as a new version (do NOT create a new project). This project holds a steel.model/v2 model, so compose a steel.model/v2 document, NOT a steel.takeoff/v1: members live in ONE root \`members[]\` array in WORLD MILLIMETRES (each with \`from\`/\`to\` as { x, y, z }), not per sheet in display pixels. Member ids are MODEL-GLOBAL — preserve the id of every member the revision still shows and mint a new one only for a genuinely new member; there is no sheet label to preserve alongside it. Where the drawing does not give an elevation, write \`{ unknown: true }\` for that z — never a substituted default, because a fabricated elevation moves steel. Record what each SHEET actually showed as evidence on that plan's \`memberObservations\` (with its \`binding.memberIds\`), and use \`plans[].memberRefs\` for members a sheet displays but never observed. COPY THE CURRENT MODEL'S ROOT \`grid\` THROUGH UNCHANGED into the document you post to /revision-read — never omit the key, because omitting it is not how you say "unchanged" and a read that drops it is refused. If the revised set genuinely shows the printed grid in a NEW place, write the new grid there instead: it is staged as a proposal the user accepts in the review, never a silent write. (The pre-read verb below still refuses a grid — that is a different endpoint.) Follow the floless-app-steel-takeoff skill's mandatory two-phase gate exactly as for v1: FIRST GET /api/contract/${req.appId}?project=${req.project} to read the CURRENT model and KEEP its ETag, do the deterministic PyMuPDF steel-filter pass only, send ONLY the pre-read blocks to PUT /api/projects/${req.project}/steel-prepass with { filter } and If-Match: <that ETag> — never the whole contract — then STOP and tell me to open Drawings → Steel Filter, review the facets, and Save. Do NOT read members, build the model, open 3D, or POST /revision-read until I explicitly come back after saving the filter. ${post}${snaps}${note}`;
5925
5925
  }
5926
5926
  if (isInitialRead) {
5927
5927
  return `In floless project "${req.project}" (app "${req.appId}"), an initial drawing set was attached — read it into this project as its first steel model version (do NOT create a new project). Follow the floless-app-steel-takeoff skill's mandatory two-phase gate. FIRST, GET /api/contract/${req.appId}?project=${req.project} and KEEP its ETag response header. A 404 "no contract for this app yet" here is NORMAL and not an error — a project created by dropping a drawing starts empty; it simply means this is the create case, so you will send If-None-Match: * instead of an ETag. (A project seeded from an existing model does return a contract and an ETag.) Then do the deterministic PyMuPDF steel-filter pass only: identify the framing-plan sheets, enumerate the drawing elements by layer/thickness/color into contract.filter.sheets/facets, write it back — if that GET returned NO contract this is the create case, so PUT the whole document to /api/contract/${req.appId}?project=${req.project} with If-None-Match: * ; if it DID return one, send only the pre-read blocks to PUT /api/projects/${req.project}/steel-prepass with { filter } and If-Match: <that ETag>. The prepass verb takes filter, datum and per-sheet { grid, datum_at, datum_ref, control2_at, control2_ref, elevation_in } and REFUSES members, connections and joints by name, so it cannot replace the model you are about to read. Either write is refused with 428 if it carries no precondition, and If-Match must be the exact ETag — If-Match: * is refused, because this verb patches the document you read. On 412 re-GET, re-apply your changes to the new document, and retry rather than repeating the same body. Then STOP and tell me to open Drawings → Steel Filter, review/narrow the steel facets, and Save. Do NOT read members, build the model, open 3D, or POST /revision-read until I explicitly come back after saving the filter. AFTER that saved-filter checkpoint, read members from the saved filter selection and compose the steel.takeoff/v1 contract. ${post}${snaps}${note}`;
@@ -193,6 +193,12 @@
193
193
  <input type="file" id="ws-revision-file" accept=".pdf,image/*" multiple hidden>
194
194
  </div>
195
195
  <div class="ws-revision-card" id="ws-revision-card" hidden></div>
196
+ <!-- The v1 → v2 conversion offer (unit 5, P7e). A thin NEUTRAL gate-banner, the same register
197
+ .ws-exports-gate and .hist-working use for "there is a forward step you have not taken" —
198
+ deliberately not a card like #ws-revision-card above: that one is Drawings-scoped and
199
+ revision-shaped, and borrowing its weight for a one-time act would both misstate the
200
+ frequency and compete with an actual pending read on the same project. Model-step only. -->
201
+ <div class="ws-exports-gate ws-migrate-gate" id="ws-migrate-gate" hidden></div>
196
202
  <!-- Two lazily-srced iframes so switching steps never reloads the editor's 3D state.
197
203
  Same-origin like #contract-editor-frame (they call /api/contract directly). -->
198
204
  <iframe id="ws-frame-model" class="ws-frame" title="Project model editor" hidden></iframe>
@@ -576,6 +582,32 @@
576
582
  </div>
577
583
  </div>
578
584
 
585
+ <!-- Convert to the model (steel.takeoff/v1 → steel.model/v2, unit 5, P7e).
586
+ A SEPARATE element from #revreview-modal rather than a reuse of it: the two have different
587
+ titles, different sub-copy and materially different Confirm semantics — that one applies a
588
+ SELECTION and is legitimately clickable with nothing ticked, this one is all-or-nothing. Sharing
589
+ the element would mean one Confirm handler with two meanings. It carries `revreview` so it
590
+ inherits the whole .rev-* vocabulary (width, scroll, rows, themed checkboxes) for free, and
591
+ `migreview` carries only the genuine deltas. -->
592
+ <div class="modal-backdrop" id="migrate-modal" role="dialog" aria-modal="true" aria-labelledby="migrate-title">
593
+ <div class="modal revreview migreview">
594
+ <div class="modal-title" id="migrate-title">Convert to the 3D model</div>
595
+ <div class="modal-sub" id="migrate-sub"></div>
596
+ <div class="rev-changed" id="migrate-changed" role="status" aria-live="polite" hidden></div>
597
+ <div class="rev-counts" id="migrate-counts"></div>
598
+ <div class="revreview-body" id="migrate-body"></div>
599
+ <!-- The tick progress, separate from the counts line above it: that one says what you GET, this
600
+ one says what is left to do. Live region so the count reaches a screen reader as it moves. -->
601
+ <div class="rev-counts mig-progress" id="migrate-progress" role="status" aria-live="polite" hidden></div>
602
+ <div class="modal-actions">
603
+ <button id="migrate-cancel">Cancel</button>
604
+ <!-- Hidden outright when the conversion is refused, never shown disabled: a blocked migration
605
+ is not something you can tick past, so an inert primary button would be an invitation. -->
606
+ <button id="migrate-confirm" class="primary">Convert</button>
607
+ </div>
608
+ </div>
609
+ </div>
610
+
579
611
  <!-- Save-on-switch confirmation — shown when switching workflows with unsaved
580
612
  input changes. Reuses the shared modal styling; no new backdrop look. -->
581
613
  <div class="modal-backdrop" id="confirm-modal">
@@ -124,7 +124,7 @@ function candOnActiveWP(c, dragged, wp) {
124
124
  return candidateOnPlane(c, dragged, wp.origin, wp.normal, WP_SNAP_TOL_MM);
125
125
  }
126
126
  let rightDownXY = null, rightMoved = false; // right button: dragged (= orbit/pan, no menu) vs clicked (= snap menu)
127
- let teklaDrag = null; // Ctrl+Shift drag-out to Tekla: { ids } from the moment the gesture is armed until dragend
127
+ let teklaDrag = null; // Ctrl+Shift drag-out to a CAD host: { ids, stack, target } from the moment the gesture is armed until release
128
128
  const dimLock = new Set(); // locked MEASURE axes (subset of x|y|z); empty = Free/aligned. Toggle+combine like Move/Copy's tfLock (measures along the resolved/dominant axis; the 2nd point still free-snaps).
129
129
  let dims3dVisibleFlag = true; // show/hide placed dims
130
130
  let dimDraft3d = null; // { a:[x,y,z] } once the first point is placed (awaiting the 2nd)
@@ -3743,12 +3743,25 @@ function onDown(e) {
3743
3743
  // to the Ctrl-copy this modifier combination would otherwise mean, quietly duplicating members
3744
3744
  // in the draft), it simply never becomes a drag-out.
3745
3745
  if (ids.length) {
3746
- teklaDrag = { ids, active: false, blocked: !!(api.teklaSendBusy && api.teklaSendBusy()) };
3747
- // Capture the pointer so move/up keep arriving once the cursor is over Tekla — that stream is
3748
- // the whole gesture. (A native HTML5 drag would carry an image over other windows, but the OS
3749
- // then paints its own "no drop here" cursor the entire way, because Tekla never accepts the
3750
- // data — it looks like a refusal while the send actually works.)
3746
+ teklaDrag = { ids, active: false, blocked: !!(api.teklaSendBusy && api.teklaSendBusy()), stack: null, running: [], target: null };
3747
+ // Capture the pointer so move/up keep arriving once the cursor is over the other app — that
3748
+ // stream is the whole gesture. (A native HTML5 drag would carry an image over other windows,
3749
+ // but the OS then paints its own "no drop here" cursor the entire way, because a CAD host
3750
+ // never accepts the data — it looks like a refusal while the send actually works.)
3751
3751
  try { canvasEl.setPointerCapture(e.pointerId); teklaDrag.pointerId = e.pointerId; } catch { /* capture is an optimisation; window-level listeners still fire */ }
3752
+ // Snapshot where the CAD windows are, ONCE, so the badge can name what the cursor is over
3753
+ // without a round-trip per pointer-move (a live probe costs ~350ms). Advisory only: the
3754
+ // release re-resolves authoritatively, so a stale snapshot can mislabel the badge for an
3755
+ // instant but can never send members to the wrong application. Fire-and-forget — if it never
3756
+ // arrives the badge simply stays unnamed and the drop still works.
3757
+ const claimed = teklaDrag;
3758
+ if (api.hostWindows) {
3759
+ api.hostWindows().then((snap) => {
3760
+ if (teklaDrag !== claimed) return; // the gesture ended before the answer came back
3761
+ claimed.stack = Array.isArray(snap && snap.stack) ? snap.stack : [];
3762
+ claimed.running = Array.isArray(snap && snap.running) ? snap.running : [];
3763
+ }).catch(() => { /* no snapshot: the badge stays unnamed, the drop is unaffected */ });
3764
+ }
3752
3765
  }
3753
3766
  }
3754
3767
  pending = {
@@ -3775,6 +3788,46 @@ function onDown(e) {
3775
3788
  // keeps move/up flowing while the cursor is over Tekla, leaves the cursor alone, and makes Esc a real
3776
3789
  // cancel (during a native drag the page never sees the key).
3777
3790
 
3791
+ /** Short display names for the drop targets. The badge has no room for "Tekla Structures". */
3792
+ const HOST_SHORT = { tekla: 'Tekla', revit: 'Revit', sketchup: 'SketchUp' };
3793
+
3794
+ /**
3795
+ * Which host is under this screen point, per the snapshot taken at dragstart?
3796
+ *
3797
+ * The topmost window containing the point decides, host or not — non-host windows are in the stack
3798
+ * precisely so an app sitting over Revit reads as "not Revit" rather than being ignored. Browser
3799
+ * screen coordinates are CSS pixels; the snapshot is in physical pixels, so they are scaled by the
3800
+ * device pixel ratio before comparison or the hit lands off by the display scale factor.
3801
+ */
3802
+ function hostUnderPointer(drag, e) {
3803
+ if (!drag || !Array.isArray(drag.stack) || !drag.stack.length) return null;
3804
+ const dpr = window.devicePixelRatio || 1;
3805
+ const x = e.screenX * dpr, y = e.screenY * dpr;
3806
+ for (const w of drag.stack) {
3807
+ if (x >= w.left && x < w.right && y >= w.top && y < w.bottom) return w.host || null;
3808
+ }
3809
+ return null;
3810
+ }
3811
+
3812
+ /**
3813
+ * Keep the badge's words in step with what the cursor is actually over.
3814
+ *
3815
+ * A named target reads "3 members → Revit", so the promise is specific before the user commits.
3816
+ * Over something we do not recognise the badge must NOT name a host it is not going to reach — it
3817
+ * says where to go instead. Only the text node is rewritten, so the brand glyph is never rebuilt.
3818
+ */
3819
+ function paintDragBadge(drag) {
3820
+ if (!drag || !drag.badge) return;
3821
+ const n = drag.ids.length, noun = n === 1 ? 'member' : 'members';
3822
+ const label = drag.target ? HOST_SHORT[drag.target] : null;
3823
+ // With no recognised target the arrow is DROPPED rather than pointed at a guess: the badge is
3824
+ // decorative (it clips at the window edge anyway), and the status chip below carries the sentence
3825
+ // that actually teaches where to go. A badge promising a destination it cannot reach is worse
3826
+ // than a badge that just counts.
3827
+ const node = drag.badge.lastChild;
3828
+ if (node && node.nodeType === 3) node.nodeValue = label ? `${n} ${noun} → ${label}` : `${n} ${noun}`;
3829
+ }
3830
+
3778
3831
  /** The badge that follows the cursor while a drag-out is live (same recipe as the legend's drag ghost). */
3779
3832
  function teklaBadge(n) {
3780
3833
  const el = document.createElement('div');
@@ -3782,7 +3835,7 @@ function teklaBadge(n) {
3782
3835
  el.innerHTML = '<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" focusable="false">'
3783
3836
  + '<path d="M9.5 2.5H13.5V6.5M13.5 2.5 8 8M11 9.5V12a1.5 1.5 0 0 1-1.5 1.5h-6A1.5 1.5 0 0 1 2 12V6a1.5 1.5 0 0 1 1.5-1.5H6"'
3784
3837
  + ' fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
3785
- el.append(document.createTextNode(`${n} ${n === 1 ? 'member' : 'members'} → Tekla`));
3838
+ el.append(document.createTextNode(`${n} ${n === 1 ? 'member' : 'members'}`)); // paintDragBadge names the target
3786
3839
  document.body.appendChild(el);
3787
3840
  return el;
3788
3841
  }
@@ -3837,7 +3890,14 @@ function onTeklaDragMove(e) {
3837
3890
  // the message from there.
3838
3891
  teklaDrag.badge.style.left = (e.clientX + 16) + 'px';
3839
3892
  teklaDrag.badge.style.top = (e.clientY + 14) + 'px';
3840
- if (canvasEl) canvasEl.style.cursor = pointerOutsideWindow(e) ? 'default' : 'alias';
3893
+ // Only name a target once the pointer has actually left FloLess. Inside our own window the answer
3894
+ // is always "release here to cancel", and naming a host underneath us would invite the user to
3895
+ // let go somewhere that abandons the gesture.
3896
+ const outside = pointerOutsideWindow(e);
3897
+ const nextTarget = outside ? hostUnderPointer(teklaDrag, e) : null;
3898
+ if (nextTarget !== teklaDrag.target) { teklaDrag.target = nextTarget; updateStatusChip(); }
3899
+ paintDragBadge(teklaDrag);
3900
+ if (canvasEl) canvasEl.style.cursor = outside ? 'default' : 'alias';
3841
3901
  }
3842
3902
 
3843
3903
  // Vertical (Alt) drag: raise/lower the member's elevation, snapping to other members' T.O.S levels.
@@ -4055,11 +4115,21 @@ function onUp(e) {
4055
4115
  // or readout left over from before the gesture would otherwise sit on the canvas until the next
4056
4116
  // hover. The send is deferred to just past that line for the same reason.
4057
4117
  pending = dragging = null; downXY = null; if (controls) controls.enabled = true;
4058
- if (pointerOutsideWindow(e) && api && api.onSendToTekla) teklaSend = drag.ids;
4118
+ // Carry the RELEASE POINT, not the badge's guess. The badge reads a snapshot taken at
4119
+ // dragstart, which is advisory; the send re-resolves the window under this exact point so a
4120
+ // window that moved, or an app that came to the front mid-drag, cannot misdirect the members.
4121
+ // `hinted` is only what the badge promised, so the caller can tell a real change of target
4122
+ // from an unresolvable drop.
4123
+ if (pointerOutsideWindow(e) && api && api.onSendToHost) {
4124
+ // CSS screen pixels, plus OUR ratio. The physical conversion belongs to the server, which
4125
+ // knows about monitors; a mixed-DPI desktop makes this window's ratio a poor guide once the
4126
+ // cursor is over a differently-scaled screen.
4127
+ teklaSend = { ids: drag.ids, screenX: e.screenX, screenY: e.screenY, dpr: window.devicePixelRatio || 1, hinted: drag.target, running: drag.running };
4128
+ }
4059
4129
  }
4060
4130
  }
4061
4131
  if (marker) marker.visible = false; if (readout) readout.style.display = 'none'; if (rubber) rubber.style.display = 'none'; if (epPreview) epPreview.visible = false; if (epMovedLine) epMovedLine.visible = false; clearCopyGhost(); dragEp = null; // always clear overlays
4062
- if (teklaSend) { api.onSendToTekla(teklaSend); return; }
4132
+ if (teklaSend) { api.onSendToHost(teklaSend); return; }
4063
4133
  if (!renderer || !canvasEl || canvasEl.style.display === 'none') { downXY = null; boxSel = pending = dragging = null; if (controls) controls.enabled = true; return; } // 3D hidden mid-gesture → drop stale gesture state (no resume on re-show)
4064
4134
  const bs = boxSel; boxSel = null;
4065
4135
  if (bs) { // empty-space gesture: drag = box-select, click = clear selection
@@ -4284,7 +4354,13 @@ function updateStatusChip() {
4284
4354
  const showId = hoverId || (selIds.size === 1 ? [...selIds][0] : null);
4285
4355
  // The badge follows the cursor and so clips away at the window edge — from there this chip is the
4286
4356
  // only thing still telling the user what releasing will do.
4287
- if (teklaDrag && teklaDrag.active) txt = `Release over the Tekla window to insert ${teklaDrag.ids.length} member${teklaDrag.ids.length === 1 ? '' : 's'} · release here or Esc to cancel`;
4357
+ if (teklaDrag && teklaDrag.active) {
4358
+ const n = teklaDrag.ids.length, noun = n === 1 ? 'member' : 'members';
4359
+ // Name the app the pointer is actually over, so the chip and the badge never disagree.
4360
+ txt = teklaDrag.target
4361
+ ? `Release to insert ${n} ${noun} into ${HOST_SHORT[teklaDrag.target]} · release here or Esc to cancel`
4362
+ : `Release over Tekla, Revit or SketchUp to insert ${n} ${noun} · release here or Esc to cancel`;
4363
+ }
4288
4364
  else if (wpMode === 'face') txt = 'Click a member face — the working plane lands on it · Esc to cancel';
4289
4365
  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] || '';
4290
4366
  else if (addActive()) txt = drDraft ? 'Click the member end · X/Y/Z lock to the local axes, Shift straight · Esc drops the start' + lockChipTxt() : 'Draw a member on the working plane — click the start point · Esc exits';