@floless/app 0.115.0 → 0.116.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.
@@ -54472,7 +54472,7 @@ function appVersion() {
54472
54472
  return resolveVersion({
54473
54473
  isSea: isSea2(),
54474
54474
  sqVersionXml: readSqVersionXml(),
54475
- define: true ? "0.115.0" : void 0,
54475
+ define: true ? "0.116.0" : void 0,
54476
54476
  pkgVersion: readPkgVersion()
54477
54477
  });
54478
54478
  }
@@ -54488,7 +54488,7 @@ function resolveChannel(s) {
54488
54488
  function appChannel() {
54489
54489
  return resolveChannel({
54490
54490
  isSea: isSea2(),
54491
- define: true ? "0.115.0" : void 0,
54491
+ define: true ? "0.116.0" : void 0,
54492
54492
  // argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
54493
54493
  // carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
54494
54494
  modulePath: process.argv[1]
@@ -2,7 +2,7 @@
2
2
  name: floless-app-bridge
3
3
  description: This skill should be used when the user is driving the floless.app web UI (the local prompt-native front door at http://127.0.0.1:4317) and wants the terminal AI to act on what they did there — picking up queued Tweak requests, "use this template" requests, or the context of a node they selected/edited on the canvas. Use it when the user says things like "apply the tweak I just queued", "I clicked Tweak on the bom node — make that change", "pick up my floless request", "what's pending in floless", or after they double-click/Tweak a node in the UI. ALSO use it the moment the user pastes a message that begins with a `[floless-request type=… id=…]` marker — that is a request copied from the FloLess Dashboard, NOT a literal instruction to run; resolve it via the API. It reads the floless.app local API, applies the change to the app's .flo, recompiles, and clears the request.
4
4
  metadata:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  ---
7
7
 
8
8
  # floless.app ↔ terminal bridge
@@ -2,7 +2,7 @@
2
2
  name: floless-app-onboarding
3
3
  description: This skill should be used to onboard a user into floless.app and its AWARE runtime as a guided, re-runnable walkthrough. It first explains what AWARE is (the runtime), checks the installed AWARE version and offers an update, maps the command surface, and shows the AVAILABLE agents via the `aware agent catalog` command (installing one on request); then it tours floless.app (the 3-column chat/canvas/inspect UI, the Compile-Approve-Run gate, Simulate vs real Run, Templates, Routines, the Agents library, Bake and Graft, the Inspect tabs, the version footer) and the three floless skills (bridge, routines, workflows). Use it when the user is new or wants a refresher, on triggers like "onboard me", "get me started", "I'm new to floless.app or AWARE", "give me a tour", "how do I use this", "walk me through floless.app", "what can AWARE do", "show me the agents", or "/floless-app-onboarding". It can be re-invoked anytime for the whole tour or a single section.
4
4
  metadata:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  ---
7
7
 
8
8
  # Onboarding a user into floless.app + AWARE
@@ -2,7 +2,7 @@
2
2
  name: floless-app-queue
3
3
  description: This skill should be used when the user has MULTIPLE floless.app requests queued from the Dashboard and wants to see them and choose which to process, rather than the AI just picking up the oldest one. Use it when the user says things like "what's in my floless queue", "list my queued floless requests", "show me the pending requests and let me pick", "I queued a few tweaks — which should I apply?", "let me choose what to process", or "pick from the floless queue". It lists the pending requests from GET /api/requests in plain language (type, which app/node, the instruction), asks the user which one(s) to apply, then hands each chosen request to the owning skill (floless-app-workflows / -tweak-contract / -ui / -rebake) which applies it and clears it. It is the interactive picker that sits in front of floless-app-bridge (which is the actual pull-apply-clear engine).
4
4
  metadata:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  ---
7
7
 
8
8
  # floless.app queue picker
@@ -2,7 +2,7 @@
2
2
  name: floless-app-routines
3
3
  description: This skill should be used when the user wants to set up a floless.app workflow (.flo app) to run automatically — "routines" — either on a timer (schedule) or on a live event (trigger). Triggers on requests like "schedule tekla-bom-by-phase every weekday at 7am", "run this workflow every 2 hours", "run my BOM whenever the Tekla model changes", "watch the model and run X on each change", "set up a trigger routine", "list my routines", "disable the morning routine", "delete that routine". Covers the floless.app routines REST API (create / list / edit / enable-disable / delete / run-now), the schedule presets, the event-trigger kind, the confirm-first rule, and the runnable gate.
4
4
  metadata:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  ---
7
7
 
8
8
  # Setting up floless.app routines (automatic .flo runs)
@@ -2,7 +2,7 @@
2
2
  name: floless-app-steel-model
3
3
  description: The front-door guide for turning a structural steel drawing SET into an editable model in floless.app — the "Steel Model" flow. This skill orchestrates the whole pipeline — set up a project folder, learn the set into plain-English knowledge files, provision the right AWARE agents (region-specific steel detailer plus any bake targets), confirm which sheets are plans / elevations / details, then hand off to the Steel Takeoff reader to read each plan into a steel.takeoff/v1 contract — with explicit confirm gates between stages. Use it when a user wants to model steel from a drawing SET or asks things like "model this steel job from the drawings", "take off this whole set", "start a steel takeoff project", "turn these structural drawings into a model", "I have a PDF set of framing plans", or "/floless-app-steel-model". It is re-runnable — resume at any stage. For a single already-isolated framing plan the Steel Takeoff reader (floless-app-steel-takeoff) can be used directly; this guide is for driving a real job end to end.
4
4
  metadata:
5
- version: 0.3.0
5
+ version: 0.4.0
6
6
  ---
7
7
 
8
8
  # Steel Model — guide a steel drawing set into an editable model
@@ -2,7 +2,7 @@
2
2
  name: floless-app-steel-takeoff
3
3
  description: Read a structural steel drawing into an editable steel.takeoff/v1 contract in floless.app — the "Steel Takeoff" reader. Triggers on a pending floless `rebake` request for the `steel-model` app (queued from its "Re-read & re-bake ▸" button), or asks like "read this framing plan into a takeoff", "turn this structural drawing into a takeoff", "bake my drawing into steel-model", "extract members from this PDF". Teaches the host AI to READ a steel drawing (PDF/image) with its own vision at COMPOSE time, build a steel.takeoff/v1 contract (members + profiles + elevations + weights from AISC lookup), write it to the contract store, and hand control to the editor — no model in the run path, no API key.
4
4
  metadata:
5
- version: 0.10.0
5
+ version: 0.11.0
6
6
  ---
7
7
 
8
8
  # Steel Takeoff — read a drawing into a steel.takeoff/v1 contract
@@ -251,7 +251,12 @@ native/display coords):
251
251
  - **The GET returned a contract** → send only the pre-read blocks to
252
252
  **`PUT /api/projects/<projectId>/steel-prepass`** with `{ filter }` and `If-Match: <that ETag>`.
253
253
  - **The GET returned nothing** (a project created by dropping a drawing) → this is the create case,
254
- so compose the whole document and `PUT /api/contract/steel-model` with `If-None-Match: *`.
254
+ so compose the whole document and
255
+ `PUT /api/contract/steel-model?project=<projectId>` with `If-None-Match: *`.
256
+ **`?project=` is not optional here.** The contract route scopes a write to a project ONLY through
257
+ that query parameter; without it you write the app-scoped draft instead — the project's pre-read
258
+ filter never lands, and `If-None-Match: *` can come back `412` against an unrelated draft that
259
+ happens to exist on the app.
255
260
 
256
261
  The prepass verb takes `filter`, `datum` and per-sheet `{ grid, datum_at, datum_ref, control2_at,
257
262
  control2_ref, elevation_in }` and **refuses `members`, `connections` and `joints` by name**, so it
@@ -1041,8 +1046,30 @@ Key field rules:
1041
1046
  |---|---|
1042
1047
  | the pre-read blocks — §1b `filter`, §1c `grid`, §1d `datum` + the per-sheet registration keys | **`PUT /api/projects/<projectId>/steel-prepass`** |
1043
1048
  | the same, on a **`steel.model/v2`** model — `filter` + the per-sheet registration keys ONLY, no `grid`, no `datum` | the same verb; it refuses the other two by name |
1044
- | the finished takeoff (§4's whole document: `members`, profiles, elevations) | `PUT /api/contract/steel-model` |
1045
- | a project's FIRST document, when the `GET` returned nothing at all | `PUT /api/contract/steel-model` with `If-None-Match: *` |
1049
+ | the finished takeoff (§4's whole document: `members`, profiles, elevations) **into a Workspaces project** — including the project's FIRST one | **`POST /api/projects/<projectId>/revision-requests`** then **`POST /api/projects/<projectId>/revision-read`** (§9) |
1050
+ | the finished takeoff when there is **no project** (a plain app-scoped contract) | `PUT /api/contract/steel-model` (add `If-None-Match: *` when the `GET` returned no ETag) |
1051
+
1052
+ **A finished takeoff into a project goes through `revision-read`, never the contract PUT — and "it is the
1053
+ first document" does not change that** (#492). Both routes store the members, so the contract PUT looks
1054
+ like it worked: `200`, an ETag, and a project the user can open. What it silently skips is everything that
1055
+ makes the read a *version*:
1056
+
1057
+ - **No entry in the ledger.** An ordinary contract PUT calls `createVersion` nowhere — only rollback,
1058
+ Approve, `revision-read` and the v2 migration commit do. The project's History reads *"No versions
1059
+ yet"* over a document that plainly exists, so there is nothing to compare, roll back to, or sign off.
1060
+ - **No provenance.** `revision-read` records the drawing files the read came from (`source.files`) and the
1061
+ request it answered. A contract PUT records that the document changed, and nothing about where it came from.
1062
+ - **The Steel Filter checkpoint does not run.** `revisionReadContractError` is wired into `revision-read`
1063
+ only. It is what refuses a member read whose work-points are not backed by the saved filter selection —
1064
+ the check that catches a mis-registered read *before* it becomes the model.
1065
+
1066
+ So the create case belongs to `revision-read` too: queue the request with the drawing snapshots, then post
1067
+ the contract against that `requestId`. §9 has the call shape and the identity rules.
1068
+
1069
+ The one create that **is** the contract route's is the **pre-read** document in §1b — the prepass verb
1070
+ cannot create a document, so a project whose `GET` returned nothing needs the contract PUT to bring the
1071
+ `filter` blocks into being. That is staging, not a read: it carries no members, and the member read that
1072
+ follows still goes through `revision-read` and still mints v1.
1046
1073
 
1047
1074
  The prepass verb exists because the pre-read pass used to GET the contract and PUT the **whole document**
1048
1075
  back. That is a full-document replacement: it can overwrite members, joints and connections that the
@@ -1052,11 +1079,18 @@ control2_ref, elevation_in }`, and refuses everything else **by name** with a `4
1052
1079
  `steel.model/v2` model the accepted set is narrower** — `filter` plus the per-sheet registration keys,
1053
1080
  with `grid` and `datum` refused (§1c, §1d), because a v2 grid is model-global canonical structure rather
1054
1081
  than a pre-read block. It cannot create a
1055
- document and it cannot add a sheet (an unknown sheet is a `400`, never a new plan), so the create case
1056
- above genuinely does belong to the contract route.
1082
+ document and it cannot add a sheet (an unknown sheet is a `400`, never a new plan), which is why the
1083
+ **§1b pre-read** create — and only that one — belongs to the contract route.
1057
1084
 
1058
- Both routes take the same preconditions, the same `412`/`428` answers, and the same lock — they share one
1059
- implementation, so the rules below apply to whichever you use.
1085
+ The two **contract-store** routes (the prepass verb and `PUT /api/contract/steel-model`) share one
1086
+ implementation, so the `412`/`428` answers and the lock below apply to whichever you use — **with one
1087
+ deliberate exception**: the prepass verb refuses `If-Match: *` with its own `428`. It patches the
1088
+ document you read, and `*` cannot detect a write that landed since your GET, so it demands the EXACT
1089
+ ETag (§1b). `If-None-Match: *` is no use there either, since that verb cannot create a document. In
1090
+ short: on the prepass verb, always send the exact ETag.
1091
+
1092
+ `revision-read` is a different shape again and is covered in §9: it carries no ETag at all, because the
1093
+ AI composed that document from the drawing set rather than from one it read here.
1060
1094
 
1061
1095
  **Read first, then write.** `GET` the contract before you write and keep its `ETag` response header —
1062
1096
  that tag is what makes the write safe, and you need it even when you are replacing the document
@@ -1066,7 +1100,7 @@ wholesale.
1066
1100
  header depends on what that `GET` returned:
1067
1101
 
1068
1102
  ```
1069
- PUT http://localhost:<port>/api/contract/steel-model
1103
+ PUT http://localhost:<port>/api/contract/steel-model?project=<projectId> # ?project= = which store
1070
1104
  Content-Type: application/json
1071
1105
  If-Match: <the ETag from your GET> # replacing — the usual case
1072
1106
  If-None-Match: * # ONLY if the GET returned no ETag at all (no draft yet)
@@ -1074,6 +1108,11 @@ If-None-Match: * # ONLY if the GET returned no ETag at
1074
1108
  <contract JSON body>
1075
1109
  ```
1076
1110
 
1111
+ **Drop `?project=` and you have written a different document.** It is the only thing that scopes this
1112
+ route to a project; without it the write lands on the app-scoped draft. Omit it *only* for a genuinely
1113
+ app-scoped contract (no project involved) — and keep it on the `GET` too, so the ETag you send back
1114
+ belongs to the store you are writing.
1115
+
1077
1116
  The server schema-validates the body. Responses that need action:
1078
1117
 
1079
1118
  - **`400`** — schema-invalid. Read the error, fix the offending fields, and re-PUT.
@@ -1084,7 +1123,9 @@ The server schema-validates the body. Responses that need action:
1084
1123
  ETag) and retry.
1085
1124
 
1086
1125
  Sending a precondition is not optional politeness: without it a slow edit silently overwrites whatever
1087
- landed while you were working. Read back the current contract with `GET /api/contract/steel-model`.
1126
+ landed while you were working. Read back the current contract with
1127
+ `GET /api/contract/steel-model?project=<projectId>` — same `?project=` rule as the write, or you read
1128
+ one store and precondition the other.
1088
1129
 
1089
1130
  ### 6. Hand off to the user
1090
1131
 
@@ -1124,19 +1165,27 @@ contract carries the source path in `source.path` and an embedded raster in `ras
1124
1165
  are machine-local (stored under `~/.floless/contracts/steel-model.json` by the server and
1125
1166
  never committed). Clip title blocks from any embedded preview.
1126
1167
 
1127
- ### 9. Revision re-read — preserve member identity (Slice 5)
1168
+ ### 9. Reading into a project — the `revision-read` route (Slice 5)
1169
+
1170
+ **This is the route for EVERY member read into a Workspaces project — the first one and every re-read**
1171
+ (§5). The two differ only in how much of the section below applies: a first read has no prior members,
1172
+ so the identity rules are vacuous and you can skip to *"No request queued yet"* at the end.
1128
1173
 
1129
- When the trigger is a **`revision-read`** request (a REVISED drawing set attached to an *existing*
1130
- project), the Workspaces **History → "What changed"** compare matches members between versions by
1131
- their `id`, scoped per `sheet`. So the re-read must keep identity stable:
1174
+ On a **re-read** (a REVISED drawing set attached to a project that already has versions) the Workspaces
1175
+ **History → "What changed"** compare matches members between versions by their `id`, scoped per `sheet`.
1176
+ So the re-read must keep identity stable:
1132
1177
 
1133
- 1. **Fetch the current contract first** — `GET /api/contract/steel-model?project=<projectId>` (the
1134
- project id is in the request body). That is the previous version's working tree.
1178
+ 1. **Fetch the current contract first** — `GET /api/contract/steel-model?project=<projectId>`. (When a
1179
+ queued request triggered you, the project id is in that request's body; on a first read you queued
1180
+ the request yourself, so you already have it.) That is the previous version's working tree.
1135
1181
  2. **Carry ids + sheets forward** — for every member that still exists in the revised set, reuse its
1136
1182
  existing `id` and keep it on the same `sheet` label (e.g. `S-201` stays `S-201`). Mint a NEW id
1137
1183
  only for a genuinely new member; simply drop the id of a member the revision deleted.
1138
1184
  3. Then compose the updated `steel.takeoff/v1` and `POST /api/projects/<projectId>/revision-read
1139
- { contract, message, requestId }` (that POST clears the request — do **not** DELETE it).
1185
+ { contract, message, requestId }`. On the **v1** arm that POST commits the version and clears the
1186
+ request for you — do **not** DELETE it. On an already-migrated **v2** project it instead answers
1187
+ `202` and stages the read for human confirmation; the request stays queued and must not be deleted
1188
+ either (see "Notes that bite" below).
1140
1189
 
1141
1190
  > **On a `steel.model/v2` project compose a `steel.model/v2` document instead** — check the `type`
1142
1191
  > of the contract you GET-ed in step 1. Members live in one root `members[]` in world millimetres,
@@ -1144,6 +1193,38 @@ their `id`, scoped per `sheet`. So the re-read must keep identity stable:
1144
1193
  > new place, in which case write the new one and it becomes a proposal the user accepts (§1c).
1145
1194
  > Never drop the `grid` key to mean "unchanged" — a read that omits it is refused.
1146
1195
 
1196
+ **No request queued yet? Queue it yourself — this is also the FIRST read's route** (§5). The two-call
1197
+ shape is the same whether the project already has versions or none at all:
1198
+
1199
+ ```
1200
+ POST http://localhost:<port>/api/projects/<projectId>/revision-requests
1201
+ Content-Type: application/json
1202
+
1203
+ { "snapshots": [ { "name": "S-201.pdf", "dataUrl": "data:application/pdf;base64,…" } ],
1204
+ "message": "First read of the framing plans" }
1205
+ -> { ok: true, request: { id: "<requestId>", … } }
1206
+ ```
1207
+
1208
+ Then post the contract against that id, exactly as step 3 above. Notes that bite:
1209
+
1210
+ - **At least one snapshot is required** (`400` otherwise) — they become the version's durable
1211
+ `source.files` provenance, so this is also how the drawing files get stored, not just how the request
1212
+ gets made. Send the real sheets you read.
1213
+ - **At most EIGHT snapshots** (`400 too many snapshots (max 8)`), each within the per-file byte cap.
1214
+ A real set has more sheets than that, so send the ones this read is actually based on rather than the
1215
+ whole set, and queue a further read for the rest.
1216
+ - **`snapshots[].dataUrl` is a base64 data-URL and the server SNIFFS the bytes** — it accepts PNG, JPEG,
1217
+ WebP and PDF, and `400`s on anything else. A DXF/SVG/TIFF sheet must be rendered to one of those
1218
+ first. `name` is optional but worth sending: it is the durable provenance label stored with the file.
1219
+ (It is not rendered in the History table today — send it because it is the record, not for display.)
1220
+ - **The queue stamps the ledger head as the read's base.** If a version lands between the queue and the
1221
+ post, `revision-read` answers `409` — re-GET and re-read rather than retrying the same body.
1222
+ - **On an already-migrated `steel.model/v2` project the post does NOT commit.** A v2 document is
1223
+ *staged* for human review: the answer is `202` with `ok: true` — so check the STATUS, not `ok` — the
1224
+ request stays queued as `staged`, no version is minted, and nothing is written until the user
1225
+ confirms in Workspaces. Hand off at the `202`; do not treat it as a finished read, and do not delete
1226
+ the request. Only the v1 arm commits in one step and clears the request itself.
1227
+
1147
1228
  If you renumber everything, the diff shows a misleading "all removed + all added" and the app warns
1148
1229
  **"identity not preserved."** Carrying ids forward is what makes *"beam B12 was upsized"* come out
1149
1230
  exact instead of a churn of the whole model.
@@ -2,7 +2,7 @@
2
2
  name: floless-app-ui
3
3
  description: This skill should be used when the user wants to customize the floless.app Dashboard — add, change, rearrange, or remove custom panels (stat cards, data tables, report buttons, run buttons) — or when picking up queued 'ui-customize' requests from the floless.app Customize box. Use it when the user says things like "add a panel showing last night's BOM run", "pin a run button to my dashboard", "apply my dashboard change", "customize my floless dashboard", "pick up my floless UI request", after they type into the Dashboard's Customize box, OR when they paste a message beginning with a `[floless-request type=ui-customize id=…]` marker (a request copied from the Dashboard — resolve it via /api/requests, don't run it verbatim). It edits ~/.floless/ui/extensions.json (the declarative UI descriptor), validates with the AWARE ui agent, and the app re-renders live.
4
4
  metadata:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  ---
7
7
 
8
8
  # floless.app Custom Panels — the dashboard descriptor
@@ -2,7 +2,7 @@
2
2
  name: floless-app-workflows
3
3
  description: This skill should be used when building, modifying, or reasoning about FloLess .flo workflows for floless.app — especially reusable apps that take inputs (e.g. a phase number) and run across different Tekla models, exec nodes that run Roslyn C# against the live model, the in-app HTML Viewer, the Code tab, or "Debug in VS". Covers the exec contract, the install→validate→compile→run loop, app inputs templating, reading an approved Workspace project's data from a running workflow via the floless-workspace REST seam plus its workspace-project input picker, and the server seams (aware-adapter, app-reader, index).
4
4
  metadata:
5
- version: 0.3.1
5
+ version: 0.3.2
6
6
  ---
7
7
 
8
8
  # Building reusable .flo workflows in floless.app
@@ -2,7 +2,7 @@
2
2
  name: reading-structural-drawings
3
3
  description: This skill should be used BEFORE modelling anything from a structural/architectural drawing SET (PDF). Use it whenever turning drawings into a 3D frame, takeoff, IFC, or Tekla model — it is the prerequisite reading discipline for the `floless-app-steel-takeoff` reader (and the `floless-app-steel-model` guide that orchestrates the full flow). Triggers on "read this drawing set", "model this structure from the PDF", "take off this steel", "build a model from these drawings", or any pure-PDF → structure task. It encodes the method that stops the classic failures (missing that a set is TWO buildings, missing a curved/sloped roof, conflating grids across sheets, tracing dimension lines as members) — establish MASSING + COORDINATE FRAME first (from the index + elevations + sections), members LAST; deterministic geometry feeds the reasoning; cross-validate every view; verify before presenting.
4
4
  metadata:
5
- version: 0.2.0
5
+ version: 0.2.1
6
6
  ---
7
7
 
8
8
  # Reading a structural drawing set — the discipline (do this BEFORE you model anything)
@@ -2,7 +2,7 @@
2
2
  name: steel-drawing-abbreviations
3
3
  description: Default legend of standard US (AISC, imperial) structural-steel drawing abbreviations, note conventions, and shape designations — the fallback meaning when a drawing set omits or only partially supplies its own abbreviations/legend sheet. This skill should be used while reading a structural steel drawing whenever an abbreviation, note code, or profile designation needs expanding (TYP, TOS, UON, EQ, (E)/(N), SIM, HSS, WT, and so on), or when the steel reader (floless-app-steel-takeoff / floless-app-steel-model) meets a note or label whose meaning is not defined on the supplied sheets. The project's own legend always overrides these defaults.
4
4
  metadata:
5
- version: "0.2.0"
5
+ version: "0.2.1"
6
6
  ---
7
7
 
8
8
  # Steel drawing abbreviations — default legend
package/dist/web/app.css CHANGED
@@ -2039,6 +2039,23 @@
2039
2039
  .import-failed-remedy-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-muted); margin-bottom: 6px; }
2040
2040
  .import-failed-cmd-row { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 6px; padding: 8px 8px 8px 12px; margin-bottom: 6px; }
2041
2041
  .import-failed-cmd-row:last-child { margin-bottom: 0; }
2042
+ /* #366 — the in-app verb beneath the copyable command. Two lines rather than three controls on one,
2043
+ so a long agent id still reads. The button reuses .lib-update (the Agent Library's own Update) —
2044
+ same verb, same treatment, nothing new to learn. */
2045
+ .import-failed-agent { margin-bottom: 10px; }
2046
+ .import-failed-agent:last-child { margin-bottom: 0; }
2047
+ .import-failed-act { display: flex; align-items: baseline; gap: 10px; margin: 5px 0 0 12px; flex-wrap: wrap; }
2048
+ .import-failed-agent-status { font-size: 11px; color: var(--text-dim); }
2049
+ .import-failed-agent-status.is-updated { color: var(--ok); }
2050
+ .import-failed-agent-status.is-error { color: var(--err); }
2051
+ /* "Nothing to update" is the ANSWER, not a success and not a failure — deliberately calmer than
2052
+ both, so it cannot read as either. Muted, no glyph. */
2053
+ .import-failed-agent-status.is-current { color: var(--text-muted); }
2054
+ .import-failed-retry { margin: 12px 0 0; font-size: 11.5px; color: var(--text-muted); }
2055
+ .import-failed-retry-go { font: inherit; color: var(--accent-bright); background: none; border: 0;
2056
+ padding: 0; cursor: pointer; text-decoration: underline; }
2057
+ .import-failed-retry-go:hover { color: var(--text); }
2058
+ .import-failed-retry-go:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
2042
2059
  .import-failed-cmd { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; color: var(--accent-bright); overflow-x: auto; white-space: pre; user-select: all;
2043
2060
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
2044
2061
  .import-failed-cmd::-webkit-scrollbar { height: 7px; }
@@ -4161,6 +4178,30 @@ table.hist tr.current td { background:var(--accent-soft); }
4161
4178
  .rev-row-title { font-size:12.5px; font-weight:600; color:var(--text); font-family:var(--mono); overflow-wrap:anywhere; }
4162
4179
  .rev-row-sub { font-size:11px; color:var(--text-dim); margin-top:3px; }
4163
4180
  .rev-row-note { font-size:11px; color:var(--text-dim); font-style:italic; margin-top:4px; }
4181
+ /* Fan-out disclosure on a collapsed decision row (#493). One row can stand for hundreds of identical
4182
+ decisions, so the individual items are offered as evidence rather than asked to be trusted — closed
4183
+ by default, because auto-opening 230 items would bury the sibling rows the user must also see.
4184
+ The list is CAPPED and therefore a scroll container: at 230 items an uncapped block pushes the other
4185
+ decisions far off screen whenever it is opened. A cap means a scrollbar, and a scrollbar here must be
4186
+ themed in the same pass — a native white bar against the dark theme is exactly what the standing
4187
+ rule exists to stop. Reuses .ws-archived-summary's caret rotation idiom rather than a new one. */
4188
+ /* What ticking the row actually covers — stated visibly, not only in the accessible name. */
4189
+ .mig-fanout-scope { margin-top:5px; font-size:11px; color:var(--text-muted); }
4190
+ .mig-fanout { margin-top:7px; }
4191
+ .mig-fanout-summary { list-style:none; cursor:pointer; font-size:11px; color:var(--text-dim);
4192
+ display:flex; align-items:center; gap:5px; user-select:none; }
4193
+ .mig-fanout-summary::-webkit-details-marker { display:none; }
4194
+ .mig-fanout-summary:hover { color:var(--text-muted); }
4195
+ .mig-fanout-summary:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:3px; }
4196
+ .mig-fanout[open] > .mig-fanout-summary .ws-archived-caret { transform:rotate(90deg); }
4197
+ .mig-fanout-list { margin-top:6px; max-height:172px; overflow-y:auto; display:flex; flex-direction:column;
4198
+ gap:2px; padding:6px 8px; border:1px solid var(--border); border-radius:5px; background:var(--surface-2);
4199
+ scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent; }
4200
+ .mig-fanout-list::-webkit-scrollbar { width:9px; }
4201
+ .mig-fanout-list::-webkit-scrollbar-thumb { background:var(--border-strong); border-radius:5px; }
4202
+ .mig-fanout-list::-webkit-scrollbar-track { background:transparent; }
4203
+ .mig-fanout-item { font:500 11px/1.5 var(--mono); color:var(--text-muted); overflow-wrap:anywhere; }
4204
+
4164
4205
  .rev-fields { margin:6px 0 0; display:flex; flex-direction:column; gap:3px; }
4165
4206
  .rev-field { font-size:11.5px; color:var(--text-muted); overflow-wrap:anywhere; }
4166
4207
  .rev-field-key { font-family:var(--mono); color:var(--text-dim); margin-right:6px; }
@@ -4453,6 +4494,17 @@ tr.hist-diff-row[hidden] { display:none; }
4453
4494
  .kb-organize[aria-disabled="true"] { opacity:.6; cursor:default; background:var(--surface-2);
4454
4495
  border-color:var(--border-strong); color:var(--text-muted); box-shadow:none; }
4455
4496
  .kb-organize[aria-disabled="true"]:hover { background:var(--surface-2); border-color:var(--border-strong); box-shadow:none; }
4497
+ /* The header ✓ Approve when the project has no model to approve (#490). `aria-disabled` and not
4498
+ `disabled`, for the reason .kb-organize and .ecard .e-act already record — a disabled button is
4499
+ unhoverable and unfocusable, so the data-tip explaining WHY would never reach the person who needs
4500
+ it, and approveProject re-checks the state itself. THIS RULE IS THE OTHER HALF OF THAT BARGAIN:
4501
+ without it `aria-disabled` renders as nothing, a sighted user sees an ordinary live button and only
4502
+ a screen-reader user is told it is unavailable — which is the same "offering an action there is
4503
+ nothing to perform" the fix is about, just moved. Found by review, after shipping the attribute
4504
+ alone and citing three precedents that all ship a matching visual rule. */
4505
+ #ws-approve[aria-disabled="true"] { opacity:.6; cursor:default; background:var(--surface-2);
4506
+ border-color:var(--border-strong); color:var(--text-muted); box-shadow:none; }
4507
+ #ws-approve[aria-disabled="true"]:hover { background:var(--surface-2); border-color:var(--border-strong); box-shadow:none; }
4456
4508
  .kb-organize:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
4457
4509
  /* Stage D — Adjust: steer the compiled wiki in plain English. A collapsed disclosure below Organize
4458
4510
  (only once a wiki exists), same idiom as .ws-archived. The submit is class="primary kb-adjust-submit"
package/dist/web/aware.js CHANGED
@@ -4277,6 +4277,12 @@
4277
4277
  function closeImportFailedModal() {
4278
4278
  hideModal($importFailedModal);
4279
4279
  dropImportFailedEsc();
4280
+ _importFailedFile = null; // don't hold a File handle past the dialog it belongs to
4281
+ _importFailedTouched = new Set();
4282
+ // AND the in-flight map. Leaving it populated meant a result for an update started in THIS dialog
4283
+ // could land after a DIFFERENT import had failed and opened a new one — writing its outcome into
4284
+ // the new dialog's rows and offering to retry an unrelated file.
4285
+ _importFailedVersions.clear();
4280
4286
  // Import has no single stable trigger (a menu item that has already closed, an OS file drop with
4281
4287
  // no DOM node, a hidden input), so fall back to the menu button rather than pretend otherwise.
4282
4288
  // <body> counts as no target: it is what activeElement reports when nothing is focused, and
@@ -4292,6 +4298,12 @@
4292
4298
  // stderr, and there is no reason to route it through a string template at all.
4293
4299
  function importFailedCmdRow(agent) {
4294
4300
  const cmd = `aware agent update ${agent}`;
4301
+ // TWO LINES, not three controls crammed onto one. The command line is left exactly as it was —
4302
+ // zero risk to what already works, and it stays readable when an agent id is long.
4303
+ const wrap = document.createElement('div');
4304
+ wrap.className = 'import-failed-agent';
4305
+ wrap.dataset.agent = agent;
4306
+
4295
4307
  const row = document.createElement('div');
4296
4308
  row.className = 'import-failed-cmd-row';
4297
4309
  const code = document.createElement('code');
@@ -4304,10 +4316,79 @@
4304
4316
  copy.dataset.tip = 'Copy this command';
4305
4317
  copy.textContent = '⎘ Copy';
4306
4318
  row.append(code, copy);
4307
- return row;
4319
+
4320
+ // The in-app verb. Same class and glyph as the Agent Library's own Update button, because it IS
4321
+ // the same verb (`updateAgent` → POST /api/agents/update) — a second visual treatment for one
4322
+ // action would just be a second thing to learn. Copy stays as the secondary: someone who prefers
4323
+ // to run it in their own terminal session should not lose that, which is this app's whole premise.
4324
+ const act = document.createElement('div');
4325
+ act.className = 'import-failed-act';
4326
+ const upd = document.createElement('button');
4327
+ upd.type = 'button';
4328
+ upd.className = 'lib-update';
4329
+ upd.dataset.agentUpdate = agent;
4330
+ upd.dataset.tip = `Update ${agent} right here — no need to leave FloLess`;
4331
+ upd.textContent = '↑ Update it now';
4332
+ const status = document.createElement('span');
4333
+ status.className = 'import-failed-agent-status';
4334
+ status.dataset.agentStatus = agent;
4335
+ act.append(upd, status);
4336
+
4337
+ wrap.append(row, act);
4338
+ return wrap;
4339
+ }
4340
+
4341
+ /**
4342
+ * Report one agent's update outcome in the import-failure dialog.
4343
+ *
4344
+ * THREE outcomes, and the third is the one the copy has to get right. `aware agent update` re-pulls
4345
+ * the latest REGISTRY version of an already-installed agent — it cannot conjure a build upstream has
4346
+ * never made. So "nothing to update" is neither success nor failure, it is the ANSWER: this agent has
4347
+ * not been released as runnable yet. It gets the calmest treatment of the three (muted, no glyph)
4348
+ * precisely so it does not read as either.
4349
+ */
4350
+ function importFailedAgentStatus(agent, state, detail) {
4351
+ if (!$importFailedModal) return;
4352
+ const el = $importFailedModal.querySelector(`[data-agent-status="${CSS.escape(agent)}"]`);
4353
+ if (!el) return;
4354
+ el.className = `import-failed-agent-status is-${state}`;
4355
+ el.textContent = state === 'updated' ? `✓ Updated to v${detail}`
4356
+ : state === 'current' ? 'Nothing to update — already the latest version. This agent hasn’t been released as runnable yet.'
4357
+ // We captured no "before" version, so we cannot honestly claim a change happened. Report what
4358
+ // AWARE now has and say nothing we do not know.
4359
+ : state === 'done' ? `AWARE finished — it reports v${detail || '?'} installed.`
4360
+ : state === 'busy' ? 'Updating… this can take a minute or two'
4361
+ : `Couldn’t update — ${String(detail || '').slice(0, 90)}`;
4362
+
4363
+ // EVERY TERMINAL STATE releases the button. Setting only the text left `aria-busy="true"` and
4364
+ // `disabled` in place forever, so assistive tech kept announcing "busy" on a finished row and the
4365
+ // user could not try again after a failure.
4366
+ const btn = $importFailedModal.querySelector(`[data-agent-update="${CSS.escape(agent)}"]`);
4367
+ if (btn && state !== 'busy') {
4368
+ btn.removeAttribute('aria-busy');
4369
+ btn.disabled = false;
4370
+ if (state === 'error') btn.textContent = '↻ Try again';
4371
+ }
4308
4372
  }
4309
4373
 
4310
- function openImportFailedModal(reason, agents) {
4374
+ /** The version the catalog currently reports for an agent, or null — used to tell the three apart. */
4375
+ function installedAgentVersion(id) {
4376
+ const a = agentCatalog.find((x) => x.id === id);
4377
+ return (a && (a.version || (a.manifest && a.manifest.version))) || null;
4378
+ }
4379
+
4380
+ /** The file this dialog is about, so "Retry the import" is genuinely ONE click rather than a polite
4381
+ * way of asking the user to find the file again. Cleared when the dialog closes. */
4382
+ let _importFailedFile = null;
4383
+ /** Agent ids whose in-app update finished — any one of them means a retry is worth offering. */
4384
+ let _importFailedTouched = new Set();
4385
+ /** id → the version installed BEFORE its in-app update, so the SSE result can tell "updated to vX"
4386
+ * from "already current". The agent-install-result payload carries ok/error and no version. */
4387
+ const _importFailedVersions = new Map();
4388
+
4389
+ function openImportFailedModal(reason, agents, file) {
4390
+ _importFailedFile = file || null;
4391
+ _importFailedTouched = new Set();
4311
4392
  const $sub = document.getElementById('import-failed-sub');
4312
4393
  const $remedy = document.getElementById('import-failed-remedy');
4313
4394
  const $rows = document.getElementById('import-failed-remedy-rows');
@@ -4326,6 +4407,19 @@
4326
4407
  : `This workflow needs ${agents.length} agents that aren’t runnable yet on this machine: ${named}.`
4327
4408
  + ' Updating usually fixes it. Any that report nothing to update haven’t been released yet — this workflow can’t run here until they are.';
4328
4409
  $rows.append(...agents.map(importFailedCmdRow)); // one command per agent, never a guessed multi-agent form
4410
+ // ONE retry offer for the whole dialog, not one per row: "retry THE import" is singular, and N
4411
+ // buttons doing the identical thing would just be N ways to ask the same question. Hidden until
4412
+ // something has actually changed — see importFailedOfferRetry.
4413
+ // REMOVE ANY PREVIOUS ONE FIRST. `$rows.replaceChildren()` above clears the rows' children, but
4414
+ // this banner is a SIBLING of $rows — so re-opening the dialog (a failed retry, or simply the
4415
+ // next bad import) used to leave the old one on screen and mint a second element with the same
4416
+ // id, until the dialog showed several retry prompts at once.
4417
+ document.getElementById('import-failed-retry')?.remove();
4418
+ const retry = document.createElement('div');
4419
+ retry.className = 'import-failed-retry';
4420
+ retry.id = 'import-failed-retry';
4421
+ retry.hidden = true;
4422
+ $rows.after(retry);
4329
4423
  $remedy.hidden = false;
4330
4424
  $detail.open = false; // the fix is the answer; the raw output is backup
4331
4425
  } else {
@@ -4346,7 +4440,61 @@
4346
4440
  document.addEventListener('keydown', _importFailedEsc);
4347
4441
  }
4348
4442
 
4443
+ /**
4444
+ * Offer a retry once ANY row has finished — a real version bump or a "nothing to update" both count,
4445
+ * because either is new information and a sibling agent's row may genuinely have fixed things.
4446
+ *
4447
+ * Purely additive: it never auto-triggers, never closes the dialog, and never removes the rows or the
4448
+ * raw-output details. Nothing the user was already reading disappears out from under them.
4449
+ */
4450
+ function importFailedOfferRetry() {
4451
+ const box = document.getElementById('import-failed-retry');
4452
+ if (!box || !_importFailedTouched.size || !_importFailedFile || box.childElementCount) return;
4453
+ const msg = document.createElement('span');
4454
+ msg.textContent = 'Worth another try — ';
4455
+ const go = document.createElement('button');
4456
+ go.type = 'button';
4457
+ go.className = 'import-failed-retry-go';
4458
+ go.dataset.tip = 'Import this workflow again, now that something has changed';
4459
+ go.textContent = 'Retry the import';
4460
+ // No ↺ glyph: it already means Rollback elsewhere in this app, and that is a materially
4461
+ // higher-stakes action to borrow an icon from.
4462
+ go.onclick = () => {
4463
+ const f = _importFailedFile;
4464
+ closeImportFailedModal();
4465
+ if (f) importFlo(f);
4466
+ };
4467
+ const tail = document.createElement('span');
4468
+ tail.textContent = ' now that something’s changed.';
4469
+ box.append(msg, go, tail);
4470
+ box.hidden = false;
4471
+ }
4472
+
4349
4473
  if ($importFailedModal) {
4474
+ // The in-app verb, per row. `updateAgent` is the SAME function the Agent Library's Update button
4475
+ // drives, so this inherits its in-flight dedupe and its SSE completion path rather than growing a
4476
+ // second way to run one command.
4477
+ $importFailedModal.addEventListener('click', async (e) => {
4478
+ const btn = e.target && e.target.closest && e.target.closest('[data-agent-update]');
4479
+ if (!btn) return;
4480
+ const id = btn.dataset.agentUpdate;
4481
+ if (!id || installingIds.has(id)) return;
4482
+ btn.setAttribute('aria-busy', 'true');
4483
+ btn.disabled = true;
4484
+ importFailedAgentStatus(id, 'busy');
4485
+ // LOAD THE CATALOGUE FIRST if we have not got one. The whole three-way outcome rests on knowing
4486
+ // the version BEFORE, and the catalogue loads lazily — with an empty one, `before` is null, and
4487
+ // "null !== '0.1.0'" would then report a confident "✓ Updated to v0.1.0" for a command that
4488
+ // found nothing to do. If it still cannot be read we say so rather than guess (state 'done').
4489
+ if (!agentCatalog.length) await loadAgentCatalog().catch(() => {});
4490
+ _importFailedVersions.set(id, installedAgentVersion(id));
4491
+ // The START can fail (bad id, server down) and `updateAgent`'s own catch cannot reach this row,
4492
+ // so it would sit disabled on "Updating…" forever. Own that end here.
4493
+ updateAgent(id, null, (err) => {
4494
+ _importFailedVersions.delete(id);
4495
+ importFailedAgentStatus(id, 'error', (err && err.message) || err);
4496
+ });
4497
+ });
4350
4498
  const $close = document.getElementById('import-failed-close');
4351
4499
  if ($close) $close.onclick = closeImportFailedModal;
4352
4500
  onBackdropDismiss($importFailedModal, closeImportFailedModal);
@@ -4391,7 +4539,9 @@
4391
4539
  // Only an install refusal carries AWARE's output. A bad file or a name clash is a one-line
4392
4540
  // problem the toast already states well — a dialog there would be ceremony.
4393
4541
  if (reason && $importFailedModal) {
4394
- openImportFailedModal(reason, Array.isArray(body.agentsUnavailable) ? body.agentsUnavailable : []);
4542
+ // The File goes with it, so "Retry the import" can genuinely be one click rather than a
4543
+ // polite way of asking the user to locate the file again.
4544
+ openImportFailedModal(reason, Array.isArray(body.agentsUnavailable) ? body.agentsUnavailable : [], file);
4395
4545
  return;
4396
4546
  }
4397
4547
  showToast(msg, body && body.code === 'exists' ? 'warn' : 'err');
@@ -6144,13 +6294,49 @@
6144
6294
  const a = availableCatalog.find((x) => x.id === m.id);
6145
6295
  showToast(`Installed “${a && a.display_name ? a.display_name : m.id}” — find it in Installed`, 'ok');
6146
6296
  }
6297
+ // `isUpdate` as well as the id. Without it, an INSTALL result for the same agent — started
6298
+ // in another tab, and deduped server-side so our update produced no event of its own —
6299
+ // would be reported as this dialog's update outcome.
6300
+ const forDialog = isUpdate && _importFailedVersions.has(m.id);
6147
6301
  loadAgentCatalog().then(() => {
6302
+ // Report it in the import-failure dialog too, if that is where the update was started
6303
+ // from. The catalogue has just been reloaded, so comparing against the version captured at
6304
+ // click time is what distinguishes a real bump from "already the latest" — the result
6305
+ // event itself says only ok/error.
6306
+ if (forDialog) {
6307
+ const before = _importFailedVersions.get(m.id);
6308
+ const after = installedAgentVersion(m.id);
6309
+ _importFailedVersions.delete(m.id);
6310
+ _importFailedTouched.add(m.id);
6311
+ // `before == null` means we never knew — claiming "Updated to vX" off that comparison
6312
+ // would be inventing a change we cannot see. Say what is installed and stop there.
6313
+ const state = before == null ? 'done' : (after && after !== before ? 'updated' : 'current');
6314
+ importFailedAgentStatus(m.id, state, after);
6315
+ importFailedOfferRetry();
6316
+ }
6148
6317
  if (!($libModal && $libModal.classList.contains('show'))) return;
6149
6318
  renderAvailable();
6150
6319
  if (libTab === 'installed') renderLibrary();
6151
- }).catch(() => {});
6320
+ }).catch(() => {
6321
+ // The update SUCCEEDED; only the catalogue refresh failed. Without this the row sits on
6322
+ // "Updating…" forever with its button disabled, for a command that actually worked.
6323
+ if (!forDialog) return;
6324
+ _importFailedVersions.delete(m.id);
6325
+ _importFailedTouched.add(m.id);
6326
+ importFailedAgentStatus(m.id, 'done', null);
6327
+ importFailedOfferRetry();
6328
+ });
6152
6329
  } else {
6153
6330
  showToast(`${isUpdate ? 'Update' : 'Install'} failed: ${String(m.error || '').slice(0, 80)}`, 'err');
6331
+ if (_importFailedVersions.has(m.id)) {
6332
+ // A failed update is NOT the "nothing to update" answer — say which it was, and re-arm the
6333
+ // row's own button so the user can try that one again without redoing the others.
6334
+ _importFailedVersions.delete(m.id);
6335
+ importFailedAgentStatus(m.id, 'error', m.error);
6336
+ const b = $importFailedModal
6337
+ && $importFailedModal.querySelector(`[data-agent-update="${CSS.escape(m.id)}"]`);
6338
+ if (b) { b.disabled = false; b.removeAttribute('aria-busy'); b.textContent = '↻ Try again'; }
6339
+ }
6154
6340
  if ($libModal && $libModal.classList.contains('show')) {
6155
6341
  if (isUpdate) renderLibrary();
6156
6342
  else renderAvailable();
@@ -7039,7 +7225,9 @@
7039
7225
  // (`agent-install-result`, action:'update'), so we flip the card to a busy spinner
7040
7226
  // and let the SSE handler refresh the catalog + re-render. `installingIds` is the
7041
7227
  // shared in-flight set (an id can't be installing and updating at once).
7042
- function updateAgent(id, btn) {
7228
+ // `onStartError` lets a caller that owns its own chrome (the import-failure dialog's per-agent row)
7229
+ // restore it when the START fails — the shared handling below can only reach the Library's cards.
7230
+ function updateAgent(id, btn, onStartError) {
7043
7231
  if (installingIds.has(id)) return; // already in flight (server dedupes too)
7044
7232
  installingIds.add(id);
7045
7233
  if (btn) { // immediate feedback before the next render
@@ -7053,6 +7241,7 @@
7053
7241
  .catch((e) => { // the START failed (bad id / server) — completion errors arrive via SSE
7054
7242
  installingIds.delete(id);
7055
7243
  if ($libModal && $libModal.classList.contains('show')) renderLibrary();
7244
+ if (onStartError) { try { onStartError(e); } catch { /* the caller's chrome, not ours */ } }
7056
7245
  reportErr(e);
7057
7246
  });
7058
7247
  }
@@ -398,7 +398,7 @@
398
398
  <div class="modal-title" id="import-failed-title">Import failed</div>
399
399
  <div class="modal-sub" id="import-failed-sub"></div>
400
400
  <div class="import-failed-remedy" id="import-failed-remedy" hidden>
401
- <div class="import-failed-remedy-label">Try this in your terminal AI, then import again:</div>
401
+ <div class="import-failed-remedy-label">Update it here, or run it in your terminal AI:</div>
402
402
  <div id="import-failed-remedy-rows"></div>
403
403
  </div>
404
404
  <details class="import-failed-detail" id="import-failed-detail">
@@ -193,6 +193,14 @@
193
193
  capability: 'Open model → new project',
194
194
  sub: 'Copies the steel model open in Workflows into a new project here.',
195
195
  label: 'Copy the open model',
196
+ // Describes the MECHANISM, never a live fact. Disabling this card when there is nothing to
197
+ // copy would need a server probe whose answer goes stale between render and click — so it
198
+ // could never be the only gate anyway (the rollback in createSeeded is). A tip that says
199
+ // what the card does sets the same expectation and cannot be wrong.
200
+ // "nothing is KEPT", not "nothing gets created" — the rollback's archive POST can itself
201
+ // fail, and on that branch a project does briefly exist. A tip must not promise what the
202
+ // failure path cannot honour.
203
+ tip: 'Copies the steel model currently open in Workflows. If nothing’s open there, nothing is kept.',
196
204
  },
197
205
  ],
198
206
  editor: '/steel-editor.html',
@@ -339,6 +347,35 @@
339
347
  let wsAppEntries = wsDefaultAppEntries();
340
348
  let current = null; // the open project (null = landing)
341
349
 
350
+ /**
351
+ * Does the open project hold a model, as far as the Exports pane knows? (#490)
352
+ *
353
+ * Module state rather than a `paintExports` parameter because there are eighteen call sites — a
354
+ * repaint triggered by a finished export, a host-readiness probe, an SSE nudge — and every one of
355
+ * them would have to remember to thread it through. One that forgot would silently repaint the gate
356
+ * as if a model existed, which is the exact bug being fixed. `renderExports` owns refreshing it;
357
+ * `openProject` resets it so a model-less project cannot leave a stale `false` on the next one.
358
+ *
359
+ * Declared HERE with the other project-scoped state rather than beside `paintExports`, because
360
+ * `openProject` assigns it and sits earlier in the file — a `let` further down works only as long as
361
+ * nothing calls that function during module init, which is not a property worth depending on.
362
+ *
363
+ * Defaults TRUE, matching `projectHasContract`'s fail-open: the cost of a wrong `true` is the
364
+ * pre-existing 404, and the cost of a wrong `false` is telling someone their real model is missing.
365
+ */
366
+ let exportsHasModel = true;
367
+
368
+ /** Sequence number for model-presence probes. A project-id check is NOT a staleness guard: two
369
+ * probes can be in flight for the SAME project, and an older "absent" answer landing last would
370
+ * re-disable Approve on a project that now has a model. Every writer bumps it; older results drop. */
371
+ let modelPresenceGen = 0;
372
+
373
+ /** The header's AUTHORED tooltip, captured from the static markup so the has-a-model state restores
374
+ * it verbatim. The first cut substituted "exports unlock after it", which is a FALSE description of
375
+ * an already-approved project — its exports are unlocked and its gate is gone. */
376
+ const APPROVE_TIP = document.getElementById('ws-approve')?.getAttribute('data-tip')
377
+ || 'Locks in this version — your edits already auto-save; this is the sign-off.';
378
+
342
379
  // The open app's visible label for a step key (Model→"Model" for steel, "Traced" for vectorize) —
343
380
  // so shared chrome (banners, prompts) names the app's OWN step, never hard-coded steel vocabulary.
344
381
  // Falls back to a capitalized key if the descriptor is missing a step.
@@ -685,6 +722,7 @@
685
722
  const target = entry.ambiguous ? entry.appId : '';
686
723
  return `<button type="button" class="ws-seed${isDrawing ? ' ws-seed-drop' : ''}" ` +
687
724
  `aria-label="${escapeAttr((action.label || action.headline) + (target ? ` (on the ${target} workflow)` : ''))}" ` +
725
+ (action.tip ? `data-tip="${escapeAttr(action.tip)}" ` : '') +
688
726
  `data-seed-app="${escapeAttr(entry.appId)}" data-seed-template="${escapeAttr(entry.templateId)}" data-seed-action="${escapeAttr(action.kind)}"` +
689
727
  (isDrawing ? ` data-seed-drop="${escapeAttr(entry.appId)}"` : '') +
690
728
  `>` +
@@ -943,11 +981,32 @@
943
981
  if (!name) return;
944
982
  try {
945
983
  const { project, seeded } = await api('/api/projects', { method: 'POST', body: JSON.stringify({ name, app: appId, seedFromApp: true }) });
946
- // Tell the truth about the import: seeded=false means there was no current model to copy
947
- // (or it was unreadable) — the project is EMPTY, don't imply the model came across.
948
984
  const seedLabel = (WORKSPACE_APPS[templateId] && WORKSPACE_APPS[templateId].seedLabel) || 'model';
949
- if (seeded) showToast(`Project "${project.name}" created from the current ${seedLabel}`, 'ok');
950
- else showToast(`Project "${project.name}" created — empty (no current ${seedLabel} to import)`, 'warn');
985
+ // ROLL BACK when there was nothing to copy (#489). `seeded:false` means the app held no current
986
+ // model (or it was unreadable), so this card's ONE job did not happen. Saying so in a toast was
987
+ // honest but not enough: it still created and opened a project indistinguishable from a real
988
+ // one, whose Model tab reads "No model for steel-model" and whose only other signal is a 404 in
989
+ // a console the user never opens. They then have to discover the failure two clicks later and
990
+ // clean up a junk project. The sibling drop-a-drawing create already rolls its own failure back
991
+ // through archiveEmptyProject; this is the same move, and it can make the stronger statement —
992
+ // the branch happens BEFORE openProject, so nothing was ever shown and "no project was created"
993
+ // is literally true, where the drawing path can only say the empty one "was removed".
994
+ if (!seeded) {
995
+ const removed = await archiveEmptyProject(project.id);
996
+ showToast(
997
+ removed
998
+ ? `There’s no ${seedLabel} currently open in Workflows to copy — no project was created.`
999
+ : `There’s no ${seedLabel} currently open in Workflows to copy — but an empty project was left behind; archive it from the ⋯ menu.`,
1000
+ 'warn',
1001
+ );
1002
+ // `archiveEmptyProject` drops the local row whether or not the archive SUCCEEDED, so on
1003
+ // failure the card the toast just told the user to open a menu on would not be there. Go back
1004
+ // to the server: it still holds that project, so the card returns and the instruction can
1005
+ // actually be followed. On success this also reconciles against any racing loadProjects().
1006
+ if (removed) renderLanding(); else await loadProjects();
1007
+ return;
1008
+ }
1009
+ showToast(`Project "${project.name}" created from the current ${seedLabel}`, 'ok');
951
1010
  track('workspace_project_created', { app: appId }); // takeoff-import create path
952
1011
  projects.unshift(project);
953
1012
  openProject(project.id);
@@ -1058,6 +1117,41 @@
1058
1117
  setStep(initialStep);
1059
1118
  applyMode();
1060
1119
  syncWorkspaceGuide(); // point the shared beacon at THIS project's document lifecycle
1120
+ // Detached, but never silent: `projectHasContract` cannot reject, yet the code after its await can
1121
+ // (stepLabel -> wsApp on a descriptor without steps), and an unhandled rejection would leave the
1122
+ // header un-updated with nothing said.
1123
+ refreshModelPresence(p.id, p.app).catch((e) => { // gate the header CHECK Approve for THIS project (#490)
1124
+ console.error('[workspaces] could not resolve model presence', e);
1125
+ });
1126
+ }
1127
+
1128
+ /**
1129
+ * One probe, three surfaces (#490). The header **✓ Approve** has the same defect the issue reported
1130
+ * on History and Exports — measured on a model-less project it is fully enabled, and the route it
1131
+ * posts to answers `404 {"error":"no contract to approve"}`. It is not an inline call-to-action
1132
+ * though: it is persistent chrome with nothing to swap it for, so it gets the codebase's
1133
+ * `aria-disabled` + `data-tip` treatment (`.e-act`, `.kb-organize`, `$migConfirm`) rather than
1134
+ * History's removal. `aria-disabled` and not `disabled`, for the reason those three already record:
1135
+ * a disabled button is unhoverable and unfocusable, so the tip explaining WHY would never reach the
1136
+ * person who needs it — and `approveProject` re-checks the same flag rather than trusting the
1137
+ * attribute.
1138
+ */
1139
+ async function refreshModelPresence(projectId, appId) {
1140
+ const gen = ++modelPresenceGen;
1141
+ const present = await projectHasContract(projectId, appId);
1142
+ if (gen !== modelPresenceGen || !current || current.id !== projectId) return; // superseded
1143
+ applyModelPresence(present);
1144
+ }
1145
+
1146
+ /** Push the answer to the flag AND the header together, so no two surfaces can disagree. */
1147
+ function applyModelPresence(present) {
1148
+ exportsHasModel = present;
1149
+ const btn = document.getElementById('ws-approve');
1150
+ if (!btn) return;
1151
+ btn.setAttribute('aria-disabled', String(!present));
1152
+ btn.setAttribute('data-tip', present
1153
+ ? APPROVE_TIP
1154
+ : `Nothing to approve yet — read a drawing on ${stepLabel('drawings')} first`);
1061
1155
  }
1062
1156
  function closeProject() {
1063
1157
  current = null;
@@ -1080,6 +1174,9 @@
1080
1174
  // was already per-project, the two variables behind it were not.)
1081
1175
  migReady = null;
1082
1176
  closeMigrate();
1177
+ // Reset with the rest of the per-project state — this file resets `histDiffSupported` for exactly
1178
+ // this reason. Bumping the generation also voids any probe still in flight for the closing project.
1179
+ exportsHasModel = true; modelPresenceGen++;
1083
1180
  lastRevState = 'none'; $revisionCard.hidden = true; closeProjMenu(); applyMode(); syncWorkspaceGuide();
1084
1181
  }
1085
1182
  document.getElementById('ws-back').addEventListener('click', closeProject);
@@ -1150,8 +1247,33 @@
1150
1247
  // Exports gate unlocks without a reload.
1151
1248
  async function approveProject() {
1152
1249
  if (!current) return;
1250
+ // The flag, not the attribute — `aria-disabled` is advisory and the button stays clickable BY
1251
+ // DESIGN (that is what keeps its data-tip reachable), so this is the check that actually holds.
1252
+ // Without it the header button still fires the 404 that #490 is about. Say what to do instead
1253
+ // rather than reporting the failure: the user has no model, and that is the only useful sentence.
1254
+ // RE-PROBE before refusing, never refuse from the cache. A stale `false` here is far worse than
1255
+ // the 404 it replaced: it blocks a legitimate sign-off while confidently telling the user to read a
1256
+ // drawing they have already read — and stale IS reachable, because a model can appear without this
1257
+ // pane hearing about it (an AI read landing while Drawings is open, a staged review confirmed
1258
+ // elsewhere, the editor's first autosave). One request at click time removes the whole class.
1259
+ if (!exportsHasModel) {
1260
+ const stillNone = !(await projectHasContract(current.id, current.app));
1261
+ if (!current) return; // closed during the probe
1262
+ applyModelPresence(!stillNone); // correct the cache either way — the header was lying too
1263
+ if (stillNone) {
1264
+ showToast(`There’s no model to approve yet — read a drawing on ${stepLabel('drawings')} first.`, 'warn');
1265
+ return;
1266
+ }
1267
+ }
1153
1268
  const approvingProject = current;
1154
1269
  const btn = document.getElementById('ws-approve');
1270
+ // Unreachable today (#ws-approve is static markup), but approveProject is driven from THREE
1271
+ // controls — a silent return would turn all three into dead clicks if the header were ever renamed.
1272
+ if (!btn) {
1273
+ console.error('[workspaces] #ws-approve is missing — Approve cannot run');
1274
+ showToast('Couldn’t start Approve — reload the page.', 'warn');
1275
+ return;
1276
+ }
1155
1277
  btn.disabled = true;
1156
1278
  const prev = btn.textContent;
1157
1279
  btn.textContent = '◆ Approving…';
@@ -3621,7 +3743,11 @@
3621
3743
  for (const attr of EXPORT_FOCUS_ATTRS) {
3622
3744
  if (element.hasAttribute(attr)) return { attr, value: element.getAttribute(attr), cardKind };
3623
3745
  }
3624
- return element.id === 'ws-exports-approve' ? { id: element.id, cardKind: null } : null;
3746
+ // BOTH gate buttons. The gate renders one or the other depending on whether a model exists, and
3747
+ // this pane repaints on a timer and on every export completion — so a keyboard user sitting on
3748
+ // "Go to <step>" would be dropped to <body> with no announcement.
3749
+ return (element.id === 'ws-exports-approve' || element.id === 'ws-exports-go-drawings')
3750
+ ? { id: element.id, cardKind: null } : null;
3625
3751
  }
3626
3752
 
3627
3753
  function restoreExportFocus(identity) {
@@ -3641,6 +3767,7 @@
3641
3767
  }
3642
3768
 
3643
3769
  function paintExports(approvedAt, requestedRestoreKind) {
3770
+ const hasModel = exportsHasModel;
3644
3771
  // An explicit kind says "put them back on the button they pressed" — but only if they are still
3645
3772
  // here. A send runs for minutes and its refresh repaints at the END; honouring the request
3646
3773
  // unconditionally would reach across and yank focus out of whatever they had moved on to, which
@@ -3653,8 +3780,14 @@
3653
3780
  const approved = !!approvedAt;
3654
3781
  let html = '';
3655
3782
  if (!approved) {
3656
- html += `<div class="ws-exports-gate">Exports go out after sign-off — ` +
3657
- `<button type="button" id="ws-exports-approve">Approve this version</button> to enable them.</div>`;
3783
+ // Same split as History's empty state (#490): with a model, Approve is genuinely the unlocking
3784
+ // action; with none, `POST …/approve` 404s, so pointing at it is a dead end and the real next
3785
+ // step is to go read a drawing. `stepLabel('drawings')` because that label is per-app.
3786
+ html += hasModel
3787
+ ? `<div class="ws-exports-gate">Exports go out after sign-off — ` +
3788
+ `<button type="button" id="ws-exports-approve">Approve this version</button> to enable them.</div>`
3789
+ : `<div class="ws-exports-gate">Nothing to export yet — ` +
3790
+ `<button type="button" id="ws-exports-go-drawings">Go to ${escapeHtml(stepLabel('drawings'))}</button> to get started.</div>`;
3658
3791
  }
3659
3792
  // The word `exports` was styled like a link (mono, accent-bright) and was inert, so people
3660
3793
  // clicked it and nothing happened. It is now the control it already looked like: a real button
@@ -3662,8 +3795,14 @@
3662
3795
  // one the per-file Reveal button uses — rather than a new icon vocabulary. Left ENABLED before
3663
3796
  // the first export on purpose: the sentence asserts the folder as a present-tense fact, and a
3664
3797
  // disabled-in-its-empty-state control is exactly the trap this pane is reviewed for.
3665
- html += `<div class="exports-note"><b>Export at any stage</b> — polishing is optional. ` +
3666
- `Each writes to this project’s <button type="button" class="exports-note-link" data-open-exports-folder ` +
3798
+ //
3799
+ // The headline used to read "Export at any stage", which flatly contradicted the gate directly
3800
+ // above it ("Exports go out after sign-off") and every card's own "Available after approval"
3801
+ // caption. The note's job — per the comment above — is to justify the exports-FOLDER button
3802
+ // staying enabled, not to claim the export actions work unapproved. "Polishing is optional" was
3803
+ // the true and useful half, and it survives; only the opening clause overreached.
3804
+ html += `<div class="exports-note"><b>Any approved version can be exported</b> — polishing further ` +
3805
+ `is optional. Each writes to this project’s <button type="button" class="exports-note-link" data-open-exports-folder ` +
3667
3806
  `aria-label="Open the exports folder" data-tip="Open this project’s exports folder">▤ exports</button> folder.</div>`;
3668
3807
  const cards = (wsApp() && wsApp().exports) || [];
3669
3808
  html += '<div class="export-grid">' + cards.map((c) => cardHtml(c, approved)).join('') + '</div>';
@@ -3735,6 +3874,47 @@
3735
3874
  * there is no identity left to restore. Carrying the kind through both paints means pressing
3736
3875
  * Send leaves you on Send.
3737
3876
  */
3877
+ /**
3878
+ * Does the open project hold a stored document at all? (#490)
3879
+ *
3880
+ * NOT the same question as "does it have versions", and conflating them is the bug. History's empty
3881
+ * state fires whenever the ledger is empty, which covers TWO situations: a real model waiting for its
3882
+ * first sign-off, and a project nothing has ever been read into. Only the second must not offer
3883
+ * Approve — `POST …/approve` 404s there, and the primary call-to-action on the screen becomes the one
3884
+ * control that lies while every export button around it is correctly gated.
3885
+ *
3886
+ * Decided HERE and shared by both panes rather than derived twice, for the reason
3887
+ * `/api/projects/:id/versions` already gives for shipping `diffSupported` from the server: a client
3888
+ * that guesses is how an affordance appears for something the server will then refuse. Two panes
3889
+ * guessing separately is the same failure with an extra way to disagree.
3890
+ *
3891
+ * `quietMissing=1` answers 204 for both kinds of absence and never emits an ETag, so this costs one
3892
+ * cheap request and cannot be confused with a real document.
3893
+ */
3894
+ async function projectHasContract(projectId, appId) {
3895
+ try {
3896
+ const url = `/api/contract/${encodeURIComponent(appId)}?project=${encodeURIComponent(projectId)}&quietMissing=1`;
3897
+ // TIMEOUT, because a HANG is not an error and would never reach the catch below. Both callers
3898
+ // await this before painting, so without a deadline a wedged connection leaves History reading
3899
+ // "Loading history…" and every Exports destination row on "Checking…" indefinitely, with no
3900
+ // error and no retry. HEAD, not GET — `web/aware.js`'s copy of this probe already does it and
3901
+ // says why: a GET pulls the whole contract (hundreds of KB on a real model) for a boolean, on
3902
+ // every repaint, and repaints fire after every export and every send to a CAD host.
3903
+ const res = await fetch(url, { method: 'HEAD', signal: AbortSignal.timeout(4000) });
3904
+ // 204 is the ONE unambiguous "nothing here" — the route collapses both kinds of absence into it
3905
+ // after its own app/project mismatch check. EVERYTHING else fails open, including a body that
3906
+ // would not parse: a truncated or malformed 200 means the probe failed, not that the model is
3907
+ // gone, and reading that as absence would disable Approve on a real project.
3908
+ return res.status !== 204;
3909
+ } catch {
3910
+ // Fail OPEN, deliberately. A network blip must not repaint a real project's History as "nothing
3911
+ // here yet — go read a drawing", which is a lie about the user's work and hides the Approve they
3912
+ // were about to click. The cost of the other direction is the pre-existing behaviour: Approve is
3913
+ // offered, and if there is genuinely nothing it answers 404 exactly as it does today.
3914
+ return true;
3915
+ }
3916
+ }
3917
+
3738
3918
  async function renderExports(restoreKind) {
3739
3919
  if (!current) return;
3740
3920
  const id = current.id, app = current.app;
@@ -3745,7 +3925,18 @@
3745
3925
  ? Object.fromEntries(SEND_HOSTS.map((h) => [h.host, { ok: false, state: 'checking' }]))
3746
3926
  : {};
3747
3927
  renderReadinessState = hasRender ? { ok: false, state: 'checking' } : null;
3928
+ // WHAT WAS PAINTED, not what the flag says. The header's probe can settle between this paint and
3929
+ // ours and move the flag WITHOUT repainting this pane — comparing to the flag then finds them
3930
+ // equal, skips the repaint, and leaves the gate drawn with the old value. That is #490 reproduced
3931
+ // inside the pane this fix is for, reachable by opening an empty project and clicking Exports
3932
+ // while the open-time probe is still in flight.
3933
+ const paintedWith = exportsHasModel;
3748
3934
  paintExports(current.approvedAt, restoreKind);
3935
+ const gen = ++modelPresenceGen;
3936
+ const modelPresent = await projectHasContract(id, app);
3937
+ if (gen !== modelPresenceGen || !current || current.id !== id || $wsExports.hidden) return;
3938
+ applyModelPresence(modelPresent);
3939
+ if (modelPresent !== paintedWith) paintExports(current.approvedAt, restoreKind);
3749
3940
  let state = null;
3750
3941
  let approvedAt = current.approvedAt; // fallback if the fetch fails (best-known)
3751
3942
  const exportPromise = api(`/api/contract/${encodeURIComponent(app)}/exports?project=${encodeURIComponent(id)}`);
@@ -4170,6 +4361,8 @@
4170
4361
 
4171
4362
  $wsExports.addEventListener('click', (e) => {
4172
4363
  if (e.target.closest('#ws-exports-approve')) { approveProject(); return; }
4364
+ // The no-model gate's real next step — mirrors History's #hist-go-drawings.
4365
+ if (e.target.closest('#ws-exports-go-drawings')) { setStep('drawings'); return; }
4173
4366
  if (e.target.closest('[data-open-exports-folder]')) { openExportsFolder(); return; }
4174
4367
  const details = e.target.closest('[data-export-details]');
4175
4368
  if (details) { showExportReceiptDetails(details.dataset.exportDetails, details); return; }
@@ -4346,6 +4539,11 @@
4346
4539
  const tip = (vr.versions || [])[0];
4347
4540
  if (tip && tip.kind === 'revision-read' && tip.n > revBaseVersion) {
4348
4541
  current.approvedAt = vr.approvedAt || undefined; // the AI read cleared the sign-off (exports re-lock)
4542
+ // A model may have just come into existence, and the repaints below fire only for the VISIBLE
4543
+ // pane — which on the drop-a-drawing flow is Drawings, neither of them. Without this the header
4544
+ // stays gated, telling the user to read a drawing they just finished reading. (approveProject
4545
+ // re-probes so the ACTION is never blocked; this stops the chrome lying in the meantime.)
4546
+ refreshModelPresence(current.id, current.app).catch(() => { /* header stays as-is */ });
4349
4547
  if (!$wsHistory.hidden) renderHistory();
4350
4548
  // …and the Exports pane, if it is the one showing. "Exports re-lock" was the intent, but
4351
4549
  // nothing repainted them: the pane kept its live buttons and its per-destination Details
@@ -5198,6 +5396,143 @@
5198
5396
  }
5199
5397
 
5200
5398
  /** One tickable decision. `idx` indexes the decision list, which is what the progress count walks. */
5399
+ /**
5400
+ * Group decisions that are the SAME decision reported many times (#493).
5401
+ *
5402
+ * On a real read this is the difference between a usable gate and an unreachable one: a 218-member
5403
+ * model produced 260 decisions, 230 of them carrying one identical sentence — sheet S-203 declares
5404
+ * no `default_tos`, restated once per member end. Those are not 230 judgements. They are one fact,
5405
+ * and ticking it 230 times cannot inform the decision that is actually being made.
5406
+ *
5407
+ * THE KEY IS EXACT (code, message) EQUALITY, and that is the safety property rather than a
5408
+ * convenience. A `dedup-merge-proposed` row always names its own survivor and retired members in its
5409
+ * message, so two of them can never collide — the key structurally cannot sweep up a decision whose
5410
+ * instances differ, which is what keeps this a collapse of duplicates and not a bulk-accept in
5411
+ * disguise. (The "Needs your decision" bucket still renders NO bulk bar; that rule is untouched.)
5412
+ *
5413
+ * Runs are built in list order, so the rows stay in the order the reader would otherwise have met
5414
+ * them.
5415
+ */
5416
+ /**
5417
+ * The decisions a fan-out row may collapse — and NOTHING ELSE MAY.
5418
+ *
5419
+ * DEFAULT-DENY, for the same reason `BULKABLE_DECISIONS` and `MIGRATE_TOPIC` are: a collapsed row is
5420
+ * one confirmation standing for many, which is the act epic §8 restricts, so eligibility has to be
5421
+ * granted deliberately rather than inherited by any code whose sentence happens to repeat. The first
5422
+ * cut keyed purely on (code, message) and was opt-out — review proved that reintroduced a bulk accept
5423
+ * by exactly the route the sibling tables were written to prevent.
5424
+ *
5425
+ * THE TEST IS THE SAME ONE `BULKABLE_DECISIONS` applies, one level down: is the repeated sentence a
5426
+ * statement about a SHEET (or the document) that the migrator restates per item, or a finding about
5427
+ * each particular item? `elevation-default-missing` is the first: it says sheet X declares no
5428
+ * `default_tos`, and every end that follows that sheet default gets the identical sentence. Resolving
5429
+ * it means giving sheet X a default — one act, whatever the fan-out.
5430
+ *
5431
+ * `col-metadata-unassigned` is the counter-example and the reason this list exists. Its message names
5432
+ * only the column mark ("column \"C1\" carries col-level note …"), so two DIFFERENT columns sharing a
5433
+ * mark across two sheets produce the identical sentence — and its question ("assign it to an end,
5434
+ * both ends, or the member") genuinely can be answered differently for each. Under the opt-out key
5435
+ * they collapsed into one row, titled with only the first sheet. Measured by review, not reasoned.
5436
+ */
5437
+ const FANOUT_ELIGIBLE = new Set(['elevation-default-missing']);
5438
+
5439
+ function byIdenticalCause(list) {
5440
+ const runs = new Map();
5441
+ for (const d of list) {
5442
+ // `sheet` IS PART OF THE KEY, even though the eligible code names its sheet in the message. The
5443
+ // server's own `decisionsDigest` keys a decision on [code, sheet, path, message], so dropping a
5444
+ // field it treats as identity is how the two disagree about what "the same decision" means.
5445
+ // `path` is the axis a fan-out is meant to collapse, so it — and only it — is left out.
5446
+ //
5447
+ // JSON.stringify of the tuple, not a delimiter-joined string: a separator has to be a character
5448
+ // the fields cannot contain, and choosing one invisibly is how a raw NUL ended up in this source
5449
+ // on the first cut. Encoding the tuple needs no reserved character at all.
5450
+ //
5451
+ // An INELIGIBLE code is keyed by identity, so it can never share a run with anything.
5452
+ const key = FANOUT_ELIGIBLE.has(d.code)
5453
+ ? JSON.stringify([d.code, d.sheet ?? null, d.message || ''])
5454
+ : JSON.stringify(['@solo', runs.size, d.code]);
5455
+ if (!runs.has(key)) runs.set(key, []);
5456
+ runs.get(key).push(d);
5457
+ }
5458
+ return [...runs.values()];
5459
+ }
5460
+
5461
+ /**
5462
+ * One row standing for N identical decisions, with the individual items disclosed behind an
5463
+ * expander. One real checkbox, so `syncMigrateProgress`'s `boxes.length` counts DECISIONS — which is
5464
+ * what "0 of 4 confirmed" should have meant all along.
5465
+ *
5466
+ * Honest by construction: the count is on the row face (not hidden in a tooltip), the expander
5467
+ * offers the evidence proactively rather than asking to be trusted, the badge stays "Decide", and
5468
+ * the message is the server's own sentence shown once, verbatim.
5469
+ *
5470
+ * Safe because the commit does not depend on these boxes. `confirmMigrate` sends
5471
+ * `acknowledgeDecisions: report.decisionsDigest` — a digest the SERVER computed over the whole
5472
+ * decision set at preview time — so the ticking is a client-side "prove you read them" gate and
5473
+ * collapsing rows cannot weaken the precondition. Verified against the route before building this.
5474
+ */
5475
+ function migFanoutRow(run, idx) {
5476
+ const first = run[0];
5477
+ const row = revEl('div', 'rev-row k-changed');
5478
+ const id = `mig-dec-${idx}`;
5479
+ const label = revEl('label', 'rev-check');
5480
+ const box = document.createElement('input');
5481
+ box.type = 'checkbox';
5482
+ box.dataset.migidx = String(idx);
5483
+ box.dataset.migcode = first.code;
5484
+ box.dataset.migfanout = String(run.length); // read by syncMigrateProgress for the "ends affected" line
5485
+ // The scope belongs in the ACCESSIBLE NAME, not only in the visible count — a screen-reader user
5486
+ // must hear what they are confirming before they tick it, not after.
5487
+ box.setAttribute('aria-label', `Confirm this decision for all ${run.length} affected items`);
5488
+ box.setAttribute('aria-describedby', `${id}-msg`);
5489
+ label.appendChild(box);
5490
+
5491
+ const main = revEl('div', 'rev-row-main');
5492
+ const head = revEl('div', 'rev-row-head');
5493
+ head.appendChild(revEl('span', 'rev-kind-badge', 'Decide'));
5494
+ // The shared ROOT CAUSE names the row — there is no single member to name, and naming one of the
5495
+ // 230 would be worse than naming none.
5496
+ const title = revEl('span', 'rev-row-title', first.sheet || first.path || migTopic(first.code));
5497
+ title.id = `${id}-title`;
5498
+ head.appendChild(title);
5499
+ head.appendChild(revEl('span', 'ws-archived-count', String(run.length)));
5500
+ main.appendChild(head);
5501
+
5502
+ const msg = revEl('div', 'rev-row-note', first.message || first.code);
5503
+ msg.id = `${id}-msg`;
5504
+ main.appendChild(msg);
5505
+
5506
+ // SAY WHAT THE TICK COVERS, in the visible row and not only in the accessible name. The count
5507
+ // badge above states the scale; this states the CONSEQUENCE, which is the part someone consenting
5508
+ // needs. Without it the row reads as one decision that happens to mention a number.
5509
+ main.appendChild(revEl('div', 'mig-fanout-scope',
5510
+ `Confirming this row confirms it for all ${run.length}.`));
5511
+
5512
+ // CLOSED by default — never auto-open a 230-item list next to sibling rows the user must also see.
5513
+ const det = document.createElement('details');
5514
+ det.className = 'mig-fanout';
5515
+ const sum = document.createElement('summary');
5516
+ sum.className = 'mig-fanout-summary';
5517
+ sum.setAttribute('data-tip', 'See exactly which items this covers');
5518
+ sum.appendChild(revEl('span', 'ws-archived-caret', '›'));
5519
+ sum.appendChild(document.createTextNode(`Show all ${run.length} affected items`));
5520
+ det.appendChild(sum);
5521
+ const listEl = revEl('div', 'mig-fanout-list');
5522
+ for (const d of run) {
5523
+ // Read-only evidence, not 230 more checkboxes: the commit is digest-based, so per-item ticks
5524
+ // would imply a granularity the server cannot honour.
5525
+ listEl.appendChild(revEl('span', 'mig-fanout-item',
5526
+ [d.sheet, d.path, d.id].filter(Boolean).join(' · ') || d.code));
5527
+ }
5528
+ det.appendChild(listEl);
5529
+ main.appendChild(det);
5530
+
5531
+ row.appendChild(label);
5532
+ row.appendChild(main);
5533
+ return row;
5534
+ }
5535
+
5201
5536
  function migDecisionRow(issue, idx, proposal) {
5202
5537
  const row = revEl('div', 'rev-row k-changed');
5203
5538
  const id = `mig-dec-${idx}`;
@@ -5335,11 +5670,21 @@
5335
5670
  };
5336
5671
  if (choices.length) {
5337
5672
  body.appendChild(section('Needs your decision',
5338
- 'each of these could have gone another way — take them one at a time'));
5673
+ 'each of these could have gone another way — take them one at a time; '
5674
+ + 'some apply to many parts of the model at once'));
5339
5675
  for (const [topic, list] of byTopic(choices)) {
5676
+ const runs = byIdenticalCause(list);
5677
+ // THE HEADER COUNTS DECISIONS, matching the rows beneath it and the progress line. Passing the
5678
+ // raw instance count made the same unlabelled number mean two different things on one screen —
5679
+ // a topic would read "230" over a single row that the progress line counted as one. The
5680
+ // fan-out is stated on the row that owns it, which is the only place it means something.
5340
5681
  // `null` bucket → `group` renders no bulk bar. The absence IS the rule, not an oversight.
5341
- const g = group(topic, list.length, null);
5342
- for (const d of list) g.appendChild(migDecisionRow(d, idxOf.get(d), proposalFor(d)));
5682
+ const g = group(topic, runs.length, null);
5683
+ for (const run of runs) {
5684
+ g.appendChild(run.length === 1
5685
+ ? migDecisionRow(run[0], idxOf.get(run[0]), proposalFor(run[0]))
5686
+ : migFanoutRow(run, idxOf.get(run[0])));
5687
+ }
5343
5688
  body.appendChild(g);
5344
5689
  }
5345
5690
  }
@@ -5385,11 +5730,18 @@
5385
5730
  const boxes = [...$migBody.querySelectorAll('input[type="checkbox"][data-migidx]')];
5386
5731
  const done = boxes.filter((b) => b.checked).length;
5387
5732
  const left = boxes.length - done;
5733
+ // A collapsed row stands for many items (#493), so the count of BOXES is the count of decisions
5734
+ // while the count of ITEMS is what the reader is actually agreeing about. State both, and only
5735
+ // when they differ — on a model with no fan-out the parenthetical would be noise.
5736
+ const items = boxes.reduce((n, b) => n + (Number(b.dataset.migfanout) || 1), 0);
5737
+ const fannedOut = items > boxes.length;
5388
5738
  if (!boxes.length) { $migProgress.hidden = true; }
5389
5739
  else {
5390
5740
  $migProgress.replaceChildren();
5391
5741
  $migProgress.appendChild(revEl('b', null, String(done)));
5392
- $migProgress.appendChild(document.createTextNode(` of ${boxes.length} confirmed`));
5742
+ $migProgress.appendChild(document.createTextNode(
5743
+ ` of ${boxes.length} decision${boxes.length === 1 ? '' : 's'} confirmed`));
5744
+ if (fannedOut) $migProgress.appendChild(document.createTextNode(` (${items} items affected)`));
5393
5745
  if (left) $migProgress.appendChild(document.createTextNode(` — ${left} still to go.`));
5394
5746
  $migProgress.hidden = false;
5395
5747
  }
@@ -5397,7 +5749,8 @@
5397
5749
  $migConfirm.setAttribute('aria-disabled', String(!ready));
5398
5750
  $migConfirm.setAttribute('data-tip', ready
5399
5751
  ? 'Convert this project — a new version is recorded'
5400
- : `Confirm all ${boxes.length} before converting — ${left} left`);
5752
+ : `Confirm all ${boxes.length} decision${boxes.length === 1 ? '' : 's'} before converting`
5753
+ + `${fannedOut ? ` (covers ${items} items)` : ''} — ${left} left`);
5401
5754
  }
5402
5755
 
5403
5756
  function closeMigrate() {
@@ -5728,9 +6081,42 @@
5728
6081
  versions = rows;
5729
6082
  if (!rows.length) {
5730
6083
  // Empty = an inline-action banner (never a bare header row that reads as broken/loading).
5731
- $wsHistory.innerHTML =
5732
- '<div class="hist-empty">No versions yet — <button type="button" id="hist-approve">Approve this version</button> ' +
5733
- 'to create <b>v1</b> and start the ledger.</div>';
6084
+ //
6085
+ // TWO empty states, because "no versions" has two causes and only one of them is Approve's.
6086
+ // With a model present, Approve genuinely is the next step and creates v1. With NO model the
6087
+ // approve route 404s — so offering it made the screen's most prominent control the only one that
6088
+ // lied, while every export button beside it was correctly gated. The honest next step there is a
6089
+ // different action on a different step, so Approve is REMOVED rather than disabled: the same
6090
+ // reasoning `migRefusal` records for rendering no Confirm at all — an inert primary button reads
6091
+ // as an invitation to find the way around it, and here there is nothing to get around.
6092
+ //
6093
+ // stepLabel('drawings'), never the literal word: the step key is shared but its LABEL is per-app
6094
+ // ("Drawings" on steel-model, "Source" on vectorize), so hardcoding it would ship a new
6095
+ // wrong-word bug on the other workspace app in a change about correctness.
6096
+ //
6097
+ // Built with DOM methods rather than innerHTML — the label comes from a descriptor, so it is the
6098
+ // same "don't route it through a string template at all" rule `importFailedCmdRow` follows.
6099
+ const gen = ++modelPresenceGen;
6100
+ const hasModel = await projectHasContract(id, current.app);
6101
+ if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden) return;
6102
+ applyModelPresence(hasModel); // one answer, every surface — History used to keep its own
6103
+ const empty = document.createElement('div');
6104
+ empty.className = 'hist-empty';
6105
+ const btn = document.createElement('button');
6106
+ btn.type = 'button';
6107
+ if (hasModel) {
6108
+ btn.id = 'hist-approve';
6109
+ btn.textContent = 'Approve this version';
6110
+ empty.append('No versions yet — ', btn, ' to create ');
6111
+ const v1 = document.createElement('b');
6112
+ v1.textContent = 'v1';
6113
+ empty.append(v1, ' and start the ledger.');
6114
+ } else {
6115
+ btn.id = 'hist-go-drawings';
6116
+ btn.textContent = `Go to ${stepLabel('drawings')}`;
6117
+ empty.append('Nothing here yet — ', btn, ' to get started.');
6118
+ }
6119
+ $wsHistory.replaceChildren(empty);
5734
6120
  return;
5735
6121
  }
5736
6122
  // Working copy = the draft; when it isn't signed off (approvedAt cleared by an edit or a
@@ -6192,6 +6578,9 @@
6192
6578
 
6193
6579
  $wsHistory.addEventListener('click', (e) => {
6194
6580
  if (e.target.closest('#hist-approve')) { approveProject(); return; }
6581
+ // The no-model empty state's real next step: go read a drawing. Same handler shape as the
6582
+ // Approve it replaces, so the pane keeps owning its own inline actions.
6583
+ if (e.target.closest('#hist-go-drawings')) { setStep('drawings'); return; }
6195
6584
  if (e.target.closest('.hc-cancel')) { closeRollbackConfirm(); return; }
6196
6585
  const go = e.target.closest('[data-hc-go]');
6197
6586
  if (go) { rollbackTo(Number(go.dataset.hcGo)); return; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.115.0",
3
+ "version": "0.116.0",
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": {
@@ -25,6 +25,7 @@
25
25
  "build": "node build/bundle.mjs",
26
26
  "build:exe": "node build/bundle.mjs && node build/make-sea.mjs",
27
27
  "verify:skills": "node build/verify-shipped-skills.mjs",
28
+ "verify:skill-versions": "node build/verify-skill-versions.mjs",
28
29
  "verify:flo": "node build/verify-flo-descriptions.mjs",
29
30
  "verify:no-title": "node build/verify-no-title.mjs",
30
31
  "verify:display-sync": "node build/verify-display-sync.mjs",