@floless/app 0.105.0 → 0.107.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,7 +33,7 @@
33
33
  "detail_bubbles": { "type": "object", "additionalProperties": true, "description": "sheet -> { detail number -> normalized [fx,fy] bubble anchor }." },
34
34
  "source": { "type": "object", "additionalProperties": true, "description": "Provenance: where this takeoff was read from (name/path/sheet/sha256/read_at)." },
35
35
  "filter": { "type": "object", "additionalProperties": true, "description": "Layer/thickness/colour filter pre-stage, unchanged from v1. Carries no member ids and no world coordinates, so identity migration does not touch it — hence still open (epic §5.4 enumeration is scoped to the objects this epic defines)." },
36
- "connections": { "type": "array", "items": { "type": "object", "required": ["id"], "additionalProperties": true, "properties": { "id": { "type": "string", "minLength": 1 } } }, "description": "Vendor-neutral connection library. `ends[].conn` and `joints[].conn` reference a row's `id`, so the id is required and non-empty here; every other field stays open (the library's shape is not what this epic changes)." },
36
+ "connections": { "type": "array", "items": { "type": "object", "required": ["id"], "additionalProperties": true, "properties": { "id": { "type": "string", "minLength": 1 } } }, "description": "Vendor-neutral connection library. `ends[].conn` and `joints[].conn` reference a row's `id`, so the id is required and non-empty here; every other field stays open (the library's shape is not what this epic changes). A row may also carry `recipe` / `notes` / `image` — what the detail BUILDS, and the rules that come with it — which is how a detail callout on a member end becomes real geometry (v1 $defs/connectionRecipe documents the shape; server/detail-recipes.ts is the reader). Deliberately NOT constrained here: that shape belongs to the detailing feature and migrates through this key untouched, because `connections` is copied wholesale and $.connections[] is not enumerated by the migration's field dispositions." },
37
37
  "joints": { "type": "array", "items": { "$ref": "#/$defs/joint" }, "description": "Placed connections the connection engine expands into real 3D parts." },
38
38
  "dims3d": { "type": "array", "items": { "$ref": "#/$defs/dim3" }, "description": "Draft-only 3D dimensions, world mm. Model-global. NOT baked into the lock / IFC / BOM." },
39
39
  "detail_placements": { "type": "array", "items": { "$ref": "#/$defs/detailPlacement" }, "description": "Draft-only placed 2D detail images. Ids are SHEET-unique, not global." },
@@ -247,13 +247,63 @@
247
247
  "type": "object",
248
248
  "required": ["id", "type"],
249
249
  "additionalProperties": true,
250
- "description": "One connection-library row. `detail` is the firm's VENDOR-NEUTRAL design detail#; `targets` is an open map platform→component id (tekla/sds2/revit/…), never hardcoded to one platform.",
250
+ "description": "One connection-library row. `detail` is the firm's VENDOR-NEUTRAL design detail#; `targets` is an open map platform→component id (tekla/sds2/revit/…), never hardcoded to one platform. A row may also say what the detail BUILDS (`recipe`) and carry the notes that come with it (`notes`), which is what lets a detail bound to a member end become real connection geometry — see server/detail-recipes.ts.",
251
251
  "properties": {
252
252
  "id": { "type": "string", "description": "Stable row id, e.g. cx-moment-1." },
253
253
  "type": { "type": "string", "description": "moment | drag | shear | braced | pinned | fixed (free string allowed)." },
254
- "detail": { "type": "string", "description": "Design detail number, e.g. 50S504 — the firm's document, platform-neutral." },
254
+ "detail": { "type": "string", "description": "Design detail number, e.g. 50S504 — the firm's document, platform-neutral. Also the key an end's `detail` callout is matched against, on a NARROW normalisation (case/whitespace, and -/ treated alike); a callout matching two rows is refused as ambiguous rather than resolved to either." },
255
255
  "targets": { "type": "object", "additionalProperties": { "type": "string" }, "description": "platform → component id, e.g. { \"tekla\": \"146\" }. Open map; add sds2/revit freely." },
256
- "source": { "enum": ["company-rules", "user", "drawing"], "description": "Where the row came from (drives the connection confidence band)." }
256
+ "source": { "enum": ["company-rules", "user", "drawing"], "description": "Where the row came from (drives the connection confidence band)." },
257
+ "recipe": { "$ref": "#/$defs/connectionRecipe", "description": "What this detail builds. Absent = the row is an identity/mapping only (its ends can still be annotated; they just can't be built from it)." },
258
+ "notes": {
259
+ "type": "array",
260
+ "items": { "type": "object", "required": ["text"], "additionalProperties": true, "properties": {
261
+ "text": { "type": "string", "description": "The note verbatim, e.g. \"All bolts 3/4\\\"Ø A325 UNO\"." },
262
+ "source": { "type": "string", "description": "drawing | user | ai — where the note came from." }
263
+ } },
264
+ "description": "Everything else the detail says — the rules the detailing must follow. STORED, SURFACED and RELAYED to the terminal AI, never interpreted by the UI (turning a note into params is an AI read; floless does not call an LLM). Rendered escaped."
265
+ },
266
+ "image": { "type": "string", "description": "Optional `custom_details` key for this detail's figure. Explicit because the fallback (previewFor) parses S-### sheet names, which is a convention no project is required to follow." }
267
+ }
268
+ },
269
+ "connectionRecipe": {
270
+ "type": "object",
271
+ "additionalProperties": true,
272
+ "description": "A detail as a buildable thing: a TYPICAL arrangement (`kind` + `params`) plus a `schedule` that varies the numbers by member size. Real details work this way — a typical figure on the sheet, dimensions in a table beside it — so one row covers every size it is drawn for.",
273
+ "properties": {
274
+ "kind": { "type": "string", "description": "The joint kind this detail builds: base-plate | shear-plate (a new engine kind needs no schema change here). A base-plate resolves only at a column base and a shear-plate only at a beam end; the mismatch is refused." },
275
+ "params": { "type": "object", "additionalProperties": true, "description": "The typical detail's geometry settings (mm), same vocabulary as `joint.params`. Sparse — engine defaults fill the rest at expansion time, never here." },
276
+ "schedule": {
277
+ "type": "array",
278
+ "items": { "$ref": "#/$defs/connectionScheduleRow" },
279
+ "description": "Per-size variation, merged OVER `params`. SPECIFICITY-ranked, not author-ordered, so a catch-all written first cannot kill the rows after it. If a schedule is present and a member's size matches no row, that end is REFUSED rather than quietly given the typical's numbers — the schedule exists because the numbers vary."
280
+ }
281
+ }
282
+ },
283
+ "connectionScheduleRow": {
284
+ "type": "object",
285
+ "additionalProperties": true,
286
+ "description": "One schedule line: which members it covers, and what it changes for them.",
287
+ "properties": {
288
+ "match": {
289
+ "type": "object",
290
+ "additionalProperties": true,
291
+ "description": "Matchers, ANDed. An EMPTY object is the catch-all. Ranked most-specific-first: profile → profilePrefix → depth → role → catch-all; a row carrying several ranks by its most specific one, and a tie inside a rank breaks on document order.",
292
+ "properties": {
293
+ "profile": { "type": "string", "description": "Exact designation, compared canonically (case / x-vs-× / spacing insensitive)." },
294
+ "profilePrefix": { "type": "string", "description": "Designation prefix, e.g. \"W18\" — plain string matching, so it works on any naming system (metric, European, bespoke), tabulated or not." },
295
+ "depth": {
296
+ "type": "object", "required": ["unit"], "additionalProperties": true,
297
+ "description": "Actual section depth range, inclusive. A designation with no tabulated depth FAILS this matcher rather than being assigned one — use profilePrefix for those.",
298
+ "properties": {
299
+ "min": { "type": "number" }, "max": { "type": "number" },
300
+ "unit": { "enum": ["in", "mm"], "description": "REQUIRED — a bare number is not a measurement." }
301
+ }
302
+ },
303
+ "role": { "enum": ["beam", "column"], "description": "Member role." }
304
+ }
305
+ },
306
+ "params": { "type": "object", "additionalProperties": true, "description": "Overrides for the members this row covers — only the keys it names; everything else falls through to the typical." }
257
307
  }
258
308
  },
259
309
  "joint": {
package/dist/web/app.css CHANGED
@@ -1322,6 +1322,14 @@
1322
1322
  color:var(--text-muted); font:500 11px/1.55 var(--mono);
1323
1323
  scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent;
1324
1324
  }
1325
+ /* Live footnote under a form's fields (formModal `onChange`) — the running cost of what is
1326
+ currently picked. Muted and rule-separated because it reports on the form rather than being
1327
+ part of it. Set via textContent (never innerHTML), so it carries no markup — the estimate
1328
+ instead leads with its number, which is the part read at a glance. */
1329
+ .fm-footnote {
1330
+ margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--border);
1331
+ color: var(--text-muted); font: 500 12px/1.5 var(--ui);
1332
+ }
1325
1333
  .fm-note::-webkit-scrollbar { width:9px; height:9px; }
1326
1334
  .fm-note::-webkit-scrollbar-thumb { background:var(--border-strong); border-radius:5px; }
1327
1335
  .fm-note::-webkit-scrollbar-track { background:transparent; }
@@ -3540,7 +3548,11 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
3540
3548
  #ws-proj-trigger { display:inline-flex; align-items:center; gap:8px; }
3541
3549
 
3542
3550
  /* landing */
3543
- .ws-landing { flex:1; min-height:0; overflow-y:auto; padding:6px 20px 24px; }
3551
+ /* scrollbar-* as well as the global ::-webkit-scrollbar rule: this is a scroll container, and the
3552
+ webkit rule alone leaves Firefox drawing its native light bar straight through the dark theme.
3553
+ Same pair every other scroll surface here already sets (.ws-archived-list, .ws-history). */
3554
+ .ws-landing { flex:1; min-height:0; overflow-y:auto; padding:6px 20px 24px;
3555
+ scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent; }
3544
3556
  .ws-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
3545
3557
  .ws-head-text { min-width:0; }
3546
3558
  .ws-head h2 { font-size:17px; font-weight:650; letter-spacing:.01em; }
@@ -3565,6 +3577,51 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
3565
3577
  .ws-card .ws-name { display:block; font-size:13px; font-weight:600; color:var(--text); }
3566
3578
  .ws-card .ws-meta { display:block; font-size:11px; color:var(--text-muted); margin-top:4px; }
3567
3579
  .ws-card .ws-meta .t { font-family:var(--mono); font-size:10px; color:var(--text-dim); }
3580
+ /* The "type · workflow · time" line.
3581
+ *
3582
+ * The LIVE workflow slug appears here only when the workflow was renamed or duplicated away from its
3583
+ * built-in id (see wsRenamed in workspaces.js). Mono + dim is the same recipe as .t beside it and as
3584
+ * .rtn-wf / .wf-option-meta elsewhere — this app's "technical identifier, not prose" treatment, so it
3585
+ * doesn't read as another capability line. NOT a bordered chip: .ws-kind above already is one.
3586
+ *
3587
+ * The line must NEVER wrap, because CSS Grid stretches every card in a row to the tallest — one long
3588
+ * name would push its whole ROW taller. Two attempts at a width cap on the slug were each disproved by
3589
+ * a case slightly wider than the one they were tuned on (18ch, measured on a 278px card, wrapped at the
3590
+ * 254px one and grew the card 175px → 192px; then 30%, checked against "2 h ago", clipped the wider
3591
+ * "59 min ago"). The room left over depends on the card width AND the display name AND the time string,
3592
+ * so no constant is right.
3593
+ *
3594
+ * `.ws-body > span` needs `min-width:0` first: it is a flex child, so it defaulted to min-width:auto and
3595
+ * simply GREW to fit the nowrap line (a 238px box holding 392px of content). The card clipped that, so
3596
+ * it looked correct while the timestamp had been pushed out of sight.
3597
+ *
3598
+ * Then the rule is stated as PRIORITY rather than as a width. Only the separators and the timestamp are
3599
+ * truly fixed — losing "59 min ago" is the one outcome with no recovery. Everything else may be
3600
+ * ellipsised, in a deliberate order: the slug shrinks first (shrink factor 4) because it is the only
3601
+ * part with a tooltip carrying its full value, and the type label only after that (factor 1) — it is
3602
+ * normally a short constant like "Steel model", but falls back to a raw 40-character app id for a
3603
+ * project whose app has no descriptor, which is exactly the case that must not shove the clock off the
3604
+ * card. */
3605
+ .ws-card .ws-body > span { min-width:0; } /* the text column must be allowed to SHRINK, see above */
3606
+ .ws-card .ws-meta-app { display:flex; align-items:baseline; white-space:nowrap; min-width:0; overflow:hidden; }
3607
+ .ws-card .ws-meta-app > .ws-sep,
3608
+ .ws-card .ws-meta-app > .t { flex:none; } /* never abbreviated */
3609
+ .ws-card .ws-meta-app > .ws-sep { white-space:pre; } /* keep the spaces around · at an item boundary */
3610
+ .ws-card .ws-meta-app > .ws-meta-kind {
3611
+ flex:0 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis;
3612
+ }
3613
+ .ws-card .ws-meta .ws-meta-wf {
3614
+ flex:0 4 auto; /* gives way before the type label does */
3615
+ /* ...but not to NOTHING. `min-width:0` let it collapse to zero width in the extreme case, which
3616
+ quietly broke the very thing that justifies abbreviating this part first: with no box left there
3617
+ is nothing to hover, so the data-tip carrying the full value became unreachable exactly when the
3618
+ user most needed it. The floor is a hit-target minimum — enough to show the ellipsis and be
3619
+ hoverable — not a layout budget, which is why a constant is the right tool here where it was the
3620
+ wrong one for the line. `.ws-meta-kind` absorbs what this no longer gives up. */
3621
+ min-width:4ch;
3622
+ overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
3623
+ font-family:var(--mono); font-size:10px; color:var(--text-dim);
3624
+ }
3568
3625
  .ws-card .ws-kebab { background:transparent; border:1px solid transparent; color:var(--text-dim);
3569
3626
  padding:2px 7px; border-radius:4px; font-size:14px; line-height:1; flex:none; }
3570
3627
  .ws-card .ws-kebab:hover { border-color:var(--border-strong); color:var(--text); }
@@ -3611,6 +3668,13 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
3611
3668
  .ws-seed .ws-seed-headline { font-size:12.5px; font-weight:600; color:var(--text); line-height:1.35; }
3612
3669
  .ws-seed .ws-seed-sub { font-size:11px; color:var(--text-dim); line-height:1.4; max-width:220px; }
3613
3670
  .ws-seed .ws-seed-capability { font-size:11px; font-weight:600; color:var(--text-muted); line-height:1.35; max-width:220px; }
3671
+ /* Which live workflow this card creates on — rendered ONLY when more than one installed app shares
3672
+ the descriptor's lineage root (an original plus a duplicate), so the ordinary card is unchanged.
3673
+ Same mono + dim identifier treatment as .ws-meta-wf, capped and ellipsised for the same reason. */
3674
+ .ws-seed .ws-seed-target {
3675
+ max-width:22ch; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
3676
+ font-family:var(--mono); font-size:10px; color:var(--text-dim);
3677
+ }
3614
3678
  .ws-empty-note { color:var(--text-dim); font-size:12px; margin-top:10px; }
3615
3679
  /* A FAILED load, not an empty workspace. Same inline-banner recipe as .hist-empty / .hd-warn below
3616
3680
  (surface-2 + a left rail) so it reads as a sibling of the app's other status banners, railed in
@@ -3707,6 +3771,37 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
3707
3771
  .ecard .e-link { background:none; border:none; padding:0; font:inherit; font-size:11px; color:var(--text-muted); cursor:pointer; }
3708
3772
  .ecard .e-link:hover { color:var(--accent); }
3709
3773
  .ecard .e-link + .e-link { border-left:1px solid var(--border); padding-left:8px; } /* thin divider, keeps them tertiary */
3774
+ /* The rendered-files list. Every other card reports ONE artifact; this one accumulates a still per
3775
+ viewpoint plus turntables, so it is the only .e-meta that can grow without bound — and because
3776
+ the grid stretches a row to its tallest card, an uncapped list pushed all four siblings down.
3777
+ The cap is ~4.5 rows: a half-row peeking under the fold is what says "there is more" without a
3778
+ count. Themed scrollbar (never the native white bar) — a new scroll container is themed in the
3779
+ same pass that creates it. */
3780
+ .ecard .e-renders { align-self:stretch; width:100%; display:flex; flex-direction:column; gap:6px;
3781
+ max-height:104px; overflow-y:auto; overscroll-behavior:contain; padding-right:3px;
3782
+ scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent; }
3783
+ .ecard .e-renders::-webkit-scrollbar { width:8px; }
3784
+ .ecard .e-renders::-webkit-scrollbar-thumb { background:var(--border-strong); border-radius:4px; }
3785
+ .ecard .e-renders::-webkit-scrollbar-track { background:transparent; }
3786
+ .ecard .e-renders:focus-visible { outline:1px solid var(--accent-dim); outline-offset:2px; border-radius:4px; }
3787
+ /* One line per artifact: name left, links right. Two lines each (the previous stacking) doubled a
3788
+ list that is already the tallest thing on the card. */
3789
+ .ecard .e-render-row { display:flex; align-items:center; justify-content:space-between; gap:10px; }
3790
+ /* The render preview. Mirrors the .fm-thumb / .req-thumb frame recipe (1px strong border, dark
3791
+ inset, object-fit cover) rather than inventing a treatment — this is the first arbitrary-coloured
3792
+ imagery in this UI, so the token palette must still own every pixel of chrome around it. No glow,
3793
+ no accent ring, no shadow. It makes this card ~86px taller and the grid stretches items, so the
3794
+ whole row grows; .e-act is bottom-pinned above, which keeps every button aligned regardless. */
3795
+ .ecard .e-thumb { display:block; width:100%; height:80px; margin:0 0 10px; padding:0; overflow:hidden;
3796
+ border:1px solid var(--border-strong); border-radius:6px; background:var(--bg); cursor:pointer;
3797
+ transition:border-color .15s; }
3798
+ .ecard .e-thumb:hover { border-color:var(--accent-dim); }
3799
+ .ecard .e-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
3800
+ /* A 200 that will not decode: say so plainly instead of a broken-image glyph in a card that
3801
+ otherwise reports success. */
3802
+ .ecard .e-thumb-failed { display:flex; align-items:center; justify-content:center; height:34px;
3803
+ font-size:11px; color:var(--text-dim); cursor:default; }
3804
+ .ecard .e-thumb-failed:hover { border-color:var(--border-strong); }
3710
3805
  .ecard .e-act { margin-top:auto; }
3711
3806
  .ecard .e-act button { width:100%; padding:7px 10px; font-size:12px; border-radius:5px; font-family:var(--ui);
3712
3807
  background:var(--surface-2); border:1px solid var(--border-strong); color:var(--text-muted); cursor:pointer; transition:all .15s; }
package/dist/web/aware.js CHANGED
@@ -2070,8 +2070,21 @@
2070
2070
  const isVisual = (inp) => inp.widget === 'file' || inp.type === 'image' || inp.type === 'file';
2071
2071
  const isProject = (inp) => inp.widget === 'workspace-project';
2072
2072
  const visualNames = new Set(app.inputs.filter(isVisual).map((i) => i.name));
2073
- // A project-picker input needs the live list of approved projects — fetch once per open.
2074
- const approved = app.inputs.some(isProject) ? await fetchApprovedProjects() : [];
2073
+ // A project-picker input needs the live list of approved projects. Fetch ONE list per DISTINCT
2074
+ // `workspaceApp` filter and let the SERVER decide what matches, rather than fetching everything
2075
+ // and re-filtering here.
2076
+ //
2077
+ // That is a correctness requirement, not a tidy-up. Matching a `.flo`'s declared app to a project
2078
+ // means comparing their LINEAGE ROOTS (a rename moves a project off the built-in id the `.flo`
2079
+ // names). The server can resolve both sides; this side knows a project's root but never the
2080
+ // FILTER's, so any client-side comparison is necessarily narrower — and it would disagree with the
2081
+ // REST seam that the very same `.flo` reads at runtime, offering a project the workflow can't have
2082
+ // or hiding one it can. One authority, asked once per filter. Almost always exactly one fetch:
2083
+ // an app declares one project input.
2084
+ const projectFilters = [...new Set(app.inputs.filter(isProject)
2085
+ .map((i) => (typeof i.workspaceApp === 'string' && i.workspaceApp ? i.workspaceApp : '')))];
2086
+ const approvedByFilter = new Map();
2087
+ for (const f of projectFilters) approvedByFilter.set(f, await fetchApprovedProjects(f || undefined));
2075
2088
  const fields = app.inputs.map((inp) => {
2076
2089
  if (isVisual(inp)) return {
2077
2090
  name: inp.name,
@@ -2081,15 +2094,16 @@
2081
2094
  value: cur[inp.name] != null ? cur[inp.name] : '',
2082
2095
  };
2083
2096
  if (isProject(inp)) {
2084
- const wantApp = typeof inp.workspaceApp === 'string' ? inp.workspaceApp : null;
2085
- const options = approved
2086
- .filter((p) => !wantApp || p.app === wantApp)
2097
+ // Already filtered, by the server, for THIS input's `workspaceApp` — see above.
2098
+ const options = (approvedByFilter.get(typeof inp.workspaceApp === 'string' && inp.workspaceApp ? inp.workspaceApp : '') || [])
2087
2099
  .slice().sort((a, b) => String(a.name).localeCompare(String(b.name)))
2088
2100
  .map((p) => ({
2089
2101
  value: p.id,
2102
+ // Name the KIND from the lineage root — after a rename `p.app` is a slug that says
2103
+ // nothing about what the project IS. The live id stays searchable below.
2104
+ meta: `${appLabel(p.templateId || p.app)} · v${p.latestApprovedVersion}`,
2090
2105
  label: p.name,
2091
- meta: `${appLabel(p.app)} · v${p.latestApprovedVersion}`,
2092
- search: `${p.name} ${p.app} ${appLabel(p.app)}`,
2106
+ search: `${p.name} ${p.app} ${appLabel(p.templateId || p.app)}`,
2093
2107
  }));
2094
2108
  return {
2095
2109
  name: inp.name,
@@ -2876,7 +2890,10 @@
2876
2890
  // END of setup (not here) so a synchronous setup error can't latch it shut for the whole
2877
2891
  // session; done() clears it on every close.
2878
2892
  let _formModalOpen = false;
2879
- function formModal({ title, sub = '', fields, okLabel = 'Save', danger = false, hideCancel = false, returnFocusTo = null, returnFocusFallback = null }) {
2893
+ // `onChange(values) -> string` makes the dialog able to answer a question no static label can:
2894
+ // one whose answer DEPENDS on the choices (five viewpoints cost five times one). Its return value
2895
+ // becomes the footnote line under the fields. Optional — dialogs that don't pass it are unchanged.
2896
+ function formModal({ title, sub = '', fields, okLabel = 'Save', danger = false, hideCancel = false, returnFocusTo = null, returnFocusFallback = null, footnote = '', onChange = null }) {
2880
2897
  return new Promise((resolve) => {
2881
2898
  if (_formModalOpen) { console.warn('formModal: a modal is already open — refusing re-entry'); resolve(null); return; }
2882
2899
  const returnFocus = returnFocusTo instanceof HTMLElement
@@ -2944,15 +2961,28 @@
2944
2961
  // the combo just displays a friendly label and updates that input. Popover flows
2945
2962
  // in-line (not absolute) so it can't be clipped by the modal body's scroll.
2946
2963
  const opts = Array.isArray(f.options) ? f.options : [];
2947
- const sel = opts.find((o) => String(o.value) === val);
2964
+ // `multiple` keeps the SAME control — the value is just a comma-joined list, and the
2965
+ // popover toggles instead of replacing. Picking several viewpoints in one pass is the
2966
+ // reason it exists: rendering them one at a time meant reopening this dialog per angle.
2967
+ const multi = !!f.multiple;
2968
+ const chosen = multi ? val.split(',').map((s) => s.trim()).filter(Boolean) : [];
2969
+ const isOn = (o) => (multi ? chosen.includes(String(o.value)) : String(o.value) === val);
2970
+ const sel = opts.find(isOn);
2948
2971
  const disabled = !opts.length;
2972
+ const summarise = () => {
2973
+ const on = opts.filter(isOn);
2974
+ if (!on.length) return f.placeholder || 'Select…';
2975
+ if (on.length <= 2) return on.map((o) => o.label).join(', ');
2976
+ return `${on.length} selected`;
2977
+ };
2949
2978
  const trigLabel = disabled ? (f.disabledLabel || 'None available')
2979
+ : multi ? summarise()
2950
2980
  : sel ? sel.label + (sel.meta ? ` (${sel.meta})` : '') : (f.placeholder || 'Select…');
2951
2981
  const rows = opts.map((o) =>
2952
- `<div class="wf-option" role="option" data-id="${escapeAttr(String(o.value))}" data-search="${escapeAttr(String(o.search || o.label).toLowerCase())}" tabindex="-1" aria-selected="${String(o.value) === val ? 'true' : 'false'}"><span class="wf-option-name">${escapeHtml(o.label)}</span>${o.meta ? `<span class="wf-option-meta">${escapeHtml(o.meta)}</span>` : ''}</div>`).join('');
2953
- ctl = `<div class="wf-combo fm-select" data-fm-select="${escapeAttr(f.name)}">
2982
+ `<div class="wf-option${isOn(o) ? ' selected' : ''}" role="option" data-id="${escapeAttr(String(o.value))}" data-search="${escapeAttr(String(o.search || o.label).toLowerCase())}" tabindex="-1" aria-selected="${isOn(o) ? 'true' : 'false'}"><span class="wf-option-name">${escapeHtml(o.label)}</span>${o.meta ? `<span class="wf-option-meta">${escapeHtml(o.meta)}</span>` : ''}</div>`).join('');
2983
+ ctl = `<div class="wf-combo fm-select${multi ? ' fm-select-multi' : ''}" data-fm-select="${escapeAttr(f.name)}"${multi ? ' data-multi="1"' : ''}${f.placeholder ? ` data-placeholder="${escapeAttr(f.placeholder)}"` : ''}>
2954
2984
  <input type="hidden" data-fm="${escapeHtml(f.name)}" value="${escapeAttr(val)}">
2955
- <button type="button" class="wf-trigger fm-select-trigger" aria-haspopup="listbox" aria-expanded="false"${disabled ? ' disabled' : ''}>
2985
+ <button type="button" class="wf-trigger fm-select-trigger" aria-haspopup="listbox" aria-expanded="false"${multi ? ' aria-multiselectable="true"' : ''}${disabled ? ' disabled' : ''}>
2956
2986
  <span class="wf-trigger-label fm-select-label"${sel ? '' : ' data-empty="1"'}>${escapeHtml(trigLabel)}</span>
2957
2987
  <svg class="wf-caret" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path fill="currentColor" d="M0 0l5 6 5-6z"/></svg>
2958
2988
  </button>
@@ -2968,6 +2998,12 @@
2968
2998
  }
2969
2999
  return `<div class="modal-field"><label for="${id}">${escapeHtml(f.label || f.name)}</label>${ctl}</div>`;
2970
3000
  }).join('');
3001
+ // The footnote sits below every field because what it reports is a property of the whole
3002
+ // form, not of any one control. aria-live so a screen reader hears the cost change too.
3003
+ if (footnote || onChange) {
3004
+ $body.insertAdjacentHTML('beforeend',
3005
+ `<div class="fm-footnote" data-fm-footnote role="status" aria-live="polite"${footnote ? '' : ' hidden'}>${escapeHtml(footnote)}</div>`);
3006
+ }
2971
3007
  $ok.textContent = okLabel;
2972
3008
  // A destructive confirm flips the emphasis: the commit button is neutral→red
2973
3009
  // (.danger) and the SAFE Cancel becomes the accent primary + gets focus, so a
@@ -2977,9 +3013,23 @@
2977
3013
  $cancel.classList.toggle('primary', !!danger);
2978
3014
  $cancel.hidden = !!hideCancel;
2979
3015
  showModal($formModal);
2980
- // Prefer a real text input; else a file drop zone (so keyboard users land somewhere
2981
- // actionable rather than a possibly-disabled OK button).
2982
- const first = $body.querySelector('input:not(.fm-file-input),textarea')
3016
+ // Prefer a real text input; else a select's trigger; else a file drop zone (so keyboard
3017
+ // users land somewhere actionable rather than a possibly-disabled OK button).
3018
+ //
3019
+ // `[type="hidden"]` must be excluded, and it is not theoretical: a `type: 'select'` field
3020
+ // renders its value carrier as a hidden input FIRST inside the control, so a dialog whose
3021
+ // fields are all selects matched that, `.focus()` did nothing, and the `$ok.focus()` fallback
3022
+ // was skipped because `first` was truthy. Focus then stayed on the button behind the
3023
+ // backdrop — and since the Esc/Tab handler is bound to $formModal, the dialog could not be
3024
+ // dismissed with Escape and the focus trap never engaged. The render options dialog is the
3025
+ // first all-select caller, so it hit this every single time.
3026
+ // `.wf-search` must be excluded too: a select renders a search box inside its POPOVER, which
3027
+ // is `hidden` until the trigger is opened. It is a visible-typed text input, so excluding
3028
+ // only `[type=hidden]` still selected it — and focusing an input inside a hidden container
3029
+ // is exactly as much of a no-op as focusing the hidden one. Caught by driving the dialog,
3030
+ // not by reading it: the DOM says both are inputs.
3031
+ const first = $body.querySelector('input:not(.fm-file-input):not([type="hidden"]):not(.wf-search),textarea')
3032
+ || $body.querySelector('.fm-select-trigger:not([disabled])')
2983
3033
  || $body.querySelector('.fm-files .fm-drop, .fm-file .fm-drop, .fm-images .fm-drop');
2984
3034
  if (first) { first.focus(); if (first.select) first.select(); }
2985
3035
  else if (danger && !hideCancel) $cancel.focus();
@@ -3151,6 +3201,9 @@
3151
3201
  renderList(); syncDrop();
3152
3202
  });
3153
3203
  // ── select field setup (themed picker: search + keyboard + click-to-choose) ──
3204
+ // Assigned once collect() exists (below); the combo handlers below only ever CALL it, and
3205
+ // they can't run before then because a click is needed to reach them.
3206
+ let fireChange = () => {};
3154
3207
  $body.querySelectorAll('.fm-select').forEach((box) => {
3155
3208
  const hidden = box.querySelector('input[type="hidden"][data-fm]');
3156
3209
  const trigger = box.querySelector('.fm-select-trigger');
@@ -3178,16 +3231,56 @@
3178
3231
  };
3179
3232
  const open = () => { popover.hidden = false; trigger.classList.add('open'); trigger.setAttribute('aria-expanded', 'true'); if (search) { search.value = ''; filter(''); setTimeout(() => search.focus(), 0); } };
3180
3233
  const close = (focusTrig) => { popover.hidden = true; trigger.classList.remove('open'); trigger.setAttribute('aria-expanded', 'false'); clearHi(); if (focusTrig) trigger.focus(); };
3234
+ const multi = box.dataset.multi === '1';
3235
+ const nameOf = (o) => { const n = o.querySelector('.wf-option-name'); return n ? n.textContent : o.dataset.id; };
3181
3236
  const choose = (opt) => {
3237
+ if (multi) {
3238
+ // Toggle, and deliberately DO NOT close — picking three viewpoints should be three
3239
+ // clicks, not three round trips through the trigger.
3240
+ const on = !opt.classList.contains('selected');
3241
+ opt.classList.toggle('selected', on);
3242
+ opt.setAttribute('aria-selected', on ? 'true' : 'false');
3243
+ const picked = opts().filter((o) => o.classList.contains('selected'));
3244
+ if (hidden) hidden.value = picked.map((o) => o.dataset.id).join(',');
3245
+ if (label) {
3246
+ // The field's own placeholder, not a hardcoded 'Select…' — emptying a multi-select
3247
+ // used to replace "Pick one or more" with generic filler the caller never asked for.
3248
+ label.textContent = !picked.length ? (box.dataset.placeholder || 'Select…')
3249
+ : picked.length <= 2 ? picked.map(nameOf).join(', ')
3250
+ : `${picked.length} selected`;
3251
+ if (picked.length) label.removeAttribute('data-empty'); else label.setAttribute('data-empty', '1');
3252
+ }
3253
+ fireChange();
3254
+ return;
3255
+ }
3182
3256
  if (hidden) hidden.value = opt.dataset.id;
3183
3257
  opts().forEach((o) => { const s = o === opt; o.classList.toggle('selected', s); o.setAttribute('aria-selected', s ? 'true' : 'false'); });
3184
- const nm = opt.querySelector('.wf-option-name');
3185
3258
  const mt = opt.querySelector('.wf-option-meta');
3186
- if (label) { label.textContent = (nm ? nm.textContent : opt.dataset.id) + (mt ? ` (${mt.textContent})` : ''); label.removeAttribute('data-empty'); }
3259
+ if (label) { label.textContent = nameOf(opt) + (mt ? ` (${mt.textContent})` : ''); label.removeAttribute('data-empty'); }
3260
+ fireChange();
3187
3261
  close(true);
3188
3262
  };
3189
- trigger.addEventListener('click', (e) => { e.stopPropagation(); popover.hidden ? open() : close(false); });
3190
- trigger.addEventListener('keydown', (e) => { if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(); } });
3263
+ // Close any OTHER expanded combo. These popovers expand in-line rather than overlaying, so
3264
+ // two open at once push the remaining fields below the modal's scroll fold — and the
3265
+ // outside-click handler cannot do it, because the trigger handler below stops the event
3266
+ // from ever reaching it. Called from BOTH the pointer and the keyboard path: opening with
3267
+ // Enter went straight to open() and reproduced the same stacking for keyboard users.
3268
+ const closeOthers = () => {
3269
+ $body.querySelectorAll('.fm-select').forEach((other) => {
3270
+ if (other === box) return;
3271
+ const pop = other.querySelector('.fm-select-popover');
3272
+ if (!pop || pop.hidden) return;
3273
+ pop.hidden = true;
3274
+ const t = other.querySelector('.fm-select-trigger');
3275
+ if (t) { t.classList.remove('open'); t.setAttribute('aria-expanded', 'false'); }
3276
+ });
3277
+ };
3278
+ trigger.addEventListener('click', (e) => {
3279
+ e.stopPropagation();
3280
+ closeOthers();
3281
+ popover.hidden ? open() : close(false);
3282
+ });
3283
+ trigger.addEventListener('keydown', (e) => { if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') { e.preventDefault(); closeOthers(); open(); } });
3191
3284
  list.addEventListener('click', (e) => { const o = e.target.closest('.wf-option'); if (o) { e.stopPropagation(); choose(o); } });
3192
3285
  if (search) search.addEventListener('input', () => filter(search.value));
3193
3286
  // Keep combo keys inside the combo — don't submit/cancel the whole modal.
@@ -3287,6 +3380,20 @@
3287
3380
  });
3288
3381
  return out;
3289
3382
  };
3383
+ if (onChange) {
3384
+ const $note = $body.querySelector('[data-fm-footnote]');
3385
+ fireChange = () => {
3386
+ let text = '';
3387
+ // A throwing estimator must not take the dialog's controls down with it — the form still
3388
+ // works without its footnote, so degrade to hiding the line.
3389
+ try { text = String(onChange(collect()) || ''); }
3390
+ catch (err) { console.warn('formModal: onChange failed', err); }
3391
+ if (!$note) return;
3392
+ $note.textContent = text;
3393
+ $note.hidden = !text;
3394
+ };
3395
+ fireChange(); // state the cost of the DEFAULTS, before anything is touched
3396
+ }
3290
3397
  const done = (result) => {
3291
3398
  _formModalOpen = false;
3292
3399
  modalClosed = true;
@@ -5340,6 +5447,11 @@
5340
5447
  // (installing only) → dim ticker; `status`/`reason` drive the card state.
5341
5448
  if (m.line != null) setBootstrapLogLine(m.line);
5342
5449
  if (m.status) updateBootstrap({ status: m.status, reason: m.reason ?? null, remediation: m.remediation ?? null });
5450
+ } else if (m.type === 'render-progress') {
5451
+ // Relayed as a DOM event rather than widening the bridge: workspaces.js owns the Exports
5452
+ // card and is the only listener, and a render can outlive several repaints of it.
5453
+ try { window.dispatchEvent(new CustomEvent('floless:render-progress', { detail: m })); }
5454
+ catch { /* a listener throwing must not break the SSE loop */ }
5343
5455
  } else if (m.type === 'contract-changed' && typeof m.appId === 'string' && !m.project) {
5344
5456
  // A receipt belongs to the exact scene that was exported. Once its contract changes, remove
5345
5457
  // the session summary immediately so an earlier model cannot masquerade as the current one.
@@ -5663,7 +5775,11 @@
5663
5775
  // App-aware: the target contract shape differs per workspace app. A vectorize project holds a
5664
5776
  // drawing.vector/v1 (clean editable 2D linework), NOT a steel takeoff — instructing the AI to
5665
5777
  // read steel members would produce the wrong contract for the vector editor (spec §3.3g).
5666
- if (req.appId === 'vectorize') {
5778
+ // The lineage ROOT, not the live id: these branches encode what CONTRACT SHAPE the app's
5779
+ // document has, and a rename moves the id off the built-in they are written against. Sending a
5780
+ // renamed vector project down the steel branch asks the AI for a steel.takeoff/v1 — the wrong
5781
+ // document entirely. Falls back to appId for an older server that ships no templateId.
5782
+ if ((req.appTemplateId || req.appId) === 'vectorize') {
5667
5783
  if (isInitialRead) {
5668
5784
  return `In floless project "${req.project}" (app "${req.appId}"), an initial drawing was attached — trace it into this project as its first version (do NOT create a new project). Vectorize the drawing per the floless-app-vectorize skill into a drawing.vector/v1 contract: emit clean, editable 2D vector geometry (sheets → elements: lines / polylines / curves / text, each on its layer), NOT steel members or a takeoff. A vector PDF is read deterministically (exact geometry, no guessing); a photo, scan or hand sketch is traced by a fenced vision extraction that flags every uncertain stroke (low confidence) for the user's review. ${post}${snaps}${note}`;
5669
5785
  }
@@ -5725,14 +5841,14 @@
5725
5841
  // revision-read's skill is app-specific: steel takeoff by default, floless-app-vectorize for a
5726
5842
  // vector project — keep the clipboard marker in step with the app-aware instruction body above.
5727
5843
  let skill = REQUEST_SKILL[req.type] || 'floless-app-workflows';
5728
- if (req.type === 'revision-read' && req.appId === 'vectorize') skill = 'floless-app-vectorize';
5844
+ if (req.type === 'revision-read' && (req.appTemplateId || req.appId) === 'vectorize') skill = 'floless-app-vectorize';
5729
5845
  const base = (typeof location !== 'undefined' && location.origin) ? location.origin : 'http://127.0.0.1:4317';
5730
5846
  // A revision-read is cleared by its own /revision-read POST — a separate DELETE would 404. A
5731
5847
  // knowledge-organize is likewise lifecycle-owned: its finish/fail POST clears it, and a stray
5732
5848
  // DELETE would strand the organize lock until the stale timeout. Every other type is
5733
5849
  // applied-then-DELETEd by the terminal AI.
5734
5850
  const clears = req.type === 'revision-read'
5735
- ? (req.appId === 'steel-model'
5851
+ ? ((req.appTemplateId || req.appId) === 'steel-model'
5736
5852
  ? `apply it in two phases: first write the Steel Filter checkpoint to the project contract and stop for user Save; only after that checkpoint use the route in the line below (that POST clears this request — do NOT DELETE it separately).`
5737
5853
  : `apply it via the route in the line below (that POST clears this request — do NOT DELETE it separately).`)
5738
5854
  : req.type === 'knowledge-organize'