@floless/app 0.120.2 → 0.122.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.
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: floless-app-approval
3
+ description: Review and act on FloLess Workspace approval state through the local server API. Use when the user asks what changed or is pending, wants to approve selected changes, leave changes pending, discard a change, inspect approved history or saved checkpoints, start from an older approved version, resume or move saved work forward, or export the latest approved version, an older version, the working DRAFT, or a checkpoint DRAFT.
4
+ metadata:
5
+ version: 0.1.0
6
+ ---
7
+
8
+ # FloLess Workspace approval
9
+
10
+ Use the server as the authority. Present its review prose and stable IDs; never invent a diff,
11
+ patch, merge, lineage, conflict, export source, or approval result.
12
+
13
+ ## Resolve the server and project
14
+
15
+ 1. Resolve the running FloLess base URL. Prefer the port supplied by the request/context; otherwise
16
+ read `~/.floless/port`, then try the installed default `http://127.0.0.1:4317`. Confirm with
17
+ `GET /api/health`.
18
+ 2. Resolve the project with `GET /api/projects`. If the name is ambiguous, ask the user to choose.
19
+ Keep the returned project `id` and `app`; never construct an ID from its display name.
20
+
21
+ Approval, discard, and conflict-resolution mutation bodies must use `claimedChannel: "terminal"`.
22
+ This is informational telemetry, not proof of identity.
23
+
24
+ ## Review and approve
25
+
26
+ 1. Fetch `GET /api/projects/:id/approval-review`.
27
+ 2. Present the server's baseline/head, summary, cautions, and every change ID with its headline and
28
+ detail. If `moveForward` is present, state its old base, current approved head, and every reported
29
+ overlap. Do this before any mutation, even when this AI authored the changes.
30
+ 3. Ask for decisions unless the user's request already names exact server IDs and dispositions.
31
+ Never treat omission, silence, or an unchecked item as Leave pending.
32
+ 4. Submit the exact frozen `reviewId` and an exhaustive decision map to
33
+ `POST /api/contract/:appId/approve?project=:id`:
34
+
35
+ ```json
36
+ {
37
+ "mode": "head",
38
+ "reviewId": "...",
39
+ "decisions": { "change-id": "approve", "other-id": "leave-pending" },
40
+ "conflicts": { "conflict-id": "use-draft", "other-conflict": "keep-latest-pending" },
41
+ "claimedChannel": "terminal"
42
+ }
43
+ ```
44
+
45
+ Every returned group and move-forward conflict must appear exactly once. Respect dependency grouping
46
+ and whole-version restrictions. At least one group must be approved. A conflict whose linked change
47
+ is approved requires `use-draft`; one left pending requires `keep-latest-pending`. Never send internal
48
+ technical facts as patches. An old-base review is replayed only onto the current approved head; never
49
+ emulate a merge locally.
50
+
51
+ On success, report the new approved version, approved count, remaining pending count, and publication
52
+ or recovery state returned by the server. On 409, fetch and present a fresh review; never replay stale
53
+ prose or silently change the user's choices. On 428/400/422, report the refusal and remediation without
54
+ falling back to the old blind-approval request.
55
+
56
+ ## Leave pending and discard
57
+
58
+ Leave pending is an explicit approval-review decision, not rejection. It keeps the authored intent.
59
+
60
+ Discard is separate and destructive. Confirm the exact server change IDs with the user, then POST
61
+ `/api/projects/:id/approval-review/discard`:
62
+
63
+ ```json
64
+ {
65
+ "reviewId": "...",
66
+ "changes": ["change-id"],
67
+ "claimedChannel": "terminal"
68
+ }
69
+ ```
70
+
71
+ The set must be dependency-closed. Never translate Leave pending into discard, and never discard a
72
+ three-way conflict by guessing; use only a server-offered destructive action and its frozen review.
73
+
74
+ ## History and saved work
75
+
76
+ - List approved history with `GET /api/projects/:id/versions`.
77
+ - List immutable saved work with `GET /api/projects/:id/checkpoints`; present server lineage,
78
+ summaries, status, base version/hash, and allowed actions.
79
+ - Start a historical working revision with `POST /api/projects/:id/revisions/start` using
80
+ `{version, expectedEtag, expectedEpoch}`. This checkpoints acknowledged dirty work first.
81
+ - Resume exact saved work with `POST /api/projects/:id/checkpoints/:checkpointId/resume`, supplying
82
+ only the current destination ETag/epoch CAS fields returned by the server.
83
+ - To move saved intent forward, resume that checkpoint exactly, fetch its approval review, and use
84
+ the review's server-computed `moveForward` result. Present and submit its explicit overlap choices;
85
+ the server keeps a durable author-source checkpoint before publishing the resolved head.
86
+
87
+ Never offer or attempt “apply checkpoint to v7” or any caller-selected backward target. Move-forward
88
+ always resolves the current head server-side. If the server refuses ancestry, acceptance, stale epoch,
89
+ or backward application, preserve that refusal; do not reconstruct the operation from raw contracts.
90
+
91
+ ## Export an explicit source
92
+
93
+ 1. Fetch `GET /api/projects/:id/export-sources` and present the server's allowed selectors and format
94
+ eligibility.
95
+ 2. Default to `{ "kind": "latest-approved" }`. Require an explicit user choice for an older approved
96
+ version or either DRAFT source:
97
+ - `{ "kind": "approved", "version": 12, "expectedHash": "..." }`
98
+ - `{ "kind": "working", "expectedEtag": "...", "expectedEpoch": 4 }`
99
+ - `{ "kind": "checkpoint", "checkpointId": "...", "expectedHash": "..." }`
100
+ 3. POST the chosen selector to `/api/projects/:id/export-captures`. For a working DRAFT, first ensure
101
+ the visible editor has saved and use the returned ETag/epoch. Use the resolved leased handle and
102
+ route/format eligibility returned by the server for the export; do not re-read the mutable draft.
103
+ 4. Report the resolved source kind/reference/hash, capture time, DRAFT label, filename and receipt.
104
+ Do not describe the selector alone as proof of what exported.
105
+
106
+ When active resume or derived export is blocked by an obsolete or schema-rejected source,
107
+ offer `POST /api/projects/:id/export-raw` with `{ "sourceHandle": "..." }` as the universal fallback. Label it
108
+ **DRAFT** where applicable. Do not use raw file reads to bypass the API or turn the package into an
109
+ accepted active project.
110
+
111
+ ## Hard boundaries
112
+
113
+ - Never auto-approve because this AI created or edited the contract.
114
+ - Never call raw `aware` commands for project approval, history, checkpoints, merges, or exports.
115
+ - Never edit contract JSON to synthesize a selective approval, discard, rebase, or checkpoint action.
116
+ - Never use the legacy body-less project approval as a fallback. A 428 is a required review gate.
117
+ - Never claim `claimedChannel` authenticates the caller.
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: floless-app-bridge
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.
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 queued requests are pending", 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. Workspace approval, pending model changes, history/checkpoints, and export-source choices belong to floless-app-approval instead.
4
4
  metadata:
5
- version: 0.1.1
5
+ version: 0.2.0
6
6
  ---
7
7
 
8
8
  # floless.app ↔ terminal bridge
@@ -13,6 +13,12 @@ and you **pull** them here, do the real work (edit the `.flo`, recompile), and c
13
13
  skill is that pull side. Pair it with the **`floless-app-workflows`** skill, which owns
14
14
  the actual `.flo` authoring / install → compile → run loop.
15
15
 
16
+ Workspace approval is not a queued-request or raw workflow operation. When the user asks what changed
17
+ or is pending, wants to approve/leave pending/discard, navigate approved history or checkpoints, or
18
+ export an approved/DRAFT source, invoke **`floless-app-approval`**. Never auto-approve a change merely
19
+ because this bridge or another AI produced it; the shared skill presents the server review and relays
20
+ explicit human decisions without calling raw `aware` commands.
21
+
16
22
  ## Receiving a *pasted* request (the `[floless-request]` marker)
17
23
 
18
24
  The user can either ask you to **pull** pending requests (below) **or paste one straight into
@@ -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 steel.model/v2 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. The reader composes steel.takeoff/v1 only as internal first-read staging; floless.app converts it transactionally so a new project is born steel.model/v2. 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.5.0
5
+ version: 0.6.0
6
6
  ---
7
7
 
8
8
  # Steel Model — guide a steel drawing set into an editable model
@@ -177,11 +177,16 @@ the user at the editor:
177
177
  leader clearly lands on a member end, set that end's `detail` to the callout text so the end is buildable
178
178
  without the user re-picking it by hand. Where it is ambiguous, leave it unset — the editor's ⌖ pick is
179
179
  the fallback, and a wrong binding is worse than none.
180
- - **Point at the rest of the canvas:** the **filter** view (refine the kept linework), **Approve**
181
- (bake the lock — the determinism gate), **3D** model, **IFC** / **Tekla** export, the **BOM**
180
+ - **Point at the rest of the canvas:** the **filter** view (refine the kept linework), **Review changes**
181
+ (the human approval gate), **3D** model, **IFC** / **Tekla** export, the **BOM**
182
182
  (exportable to **CSV / Excel**), the **confidence report**, and the **callout bubbles** (click a
183
183
  section/elevation/detail mark on a plan to jump to the referenced sheet).
184
184
 
185
+ For any request to inspect pending changes, approve or leave selected changes pending, discard a
186
+ change, navigate approved history/checkpoints, or choose an approved/DRAFT export source, invoke
187
+ **`floless-app-approval`**. That shared skill presents the server review and performs the explicit
188
+ decision protocol. Never auto-approve work produced by this reading pipeline.
189
+
185
190
  **Done** when each framing plan has an approved, editor-reviewed contract and the user knows which
186
191
  on-canvas tool does what. The 3D/IFC/Tekla exports are on-demand from the editor; the **BOM is
187
192
  exported two ways** — on-demand via the editor's *Export BOM (CSV)/(Excel)* buttons, **and written
@@ -2,7 +2,7 @@
2
2
  name: floless-app-tweak-contract
3
3
  description: This skill should be used when there is a pending floless `tweak-contract` request — the user typed an instruction in the Steel Model contract editor and clicked Send (Ask AI). Also triggers on asks like "edit the steel takeoff contract via AI", "adjust the steel takeoff in the contract editor", "the user asked me to change the steel contract", "pick up my tweak-contract request", "update the member profile in the contract". It teaches the host AI to read the request, fetch the current steel.takeoff/v1 contract, apply the instruction (and any pasted screenshots), PUT the updated contract back, and resolve the request.
4
4
  metadata:
5
- version: 0.2.0
5
+ version: 0.3.0
6
6
  ---
7
7
 
8
8
  # Handle a `tweak-contract` request (Slice 2 AI round-trip)
@@ -16,8 +16,8 @@ a `tweak-contract` request in the reverse channel. You pick it up here, edit the
16
16
  document, write it back, and the editor reloads it.
17
17
 
18
18
  The contract is `~/.floless/contracts/<appId>.json`, a `steel.takeoff/v1` document. It is the
19
- single source of truth — the editor is its view, the exporters (IFC/Tekla/viewer-3d) consume
20
- it, and **Approve** bakes the lock. A PUT writeback is schema-validated on the server; a 400
19
+ single source of truth — the editor is its view, and the exporters (IFC/Tekla/viewer-3d) consume
20
+ server-resolved export sources. A PUT writeback is schema-validated on the server; a 400
21
21
  means invalid — fix and retry.
22
22
 
23
23
  > **Pasted a request?** If the user pastes a message with a `[floless-request type=tweak-contract id=…]`
@@ -119,8 +119,10 @@ means invalid — fix and retry.
119
119
  `tos` / `bos` / `elev_in` fields are always decimal inches (`16.5` = 16½ inches).
120
120
  - **Screenshots don't lie; instructions generalize.** If the screenshot shows a specific member
121
121
  and the instruction says "this beam", resolve "this" from the visual, not a guess.
122
- - **Never auto-approve.** Writing the contract back is the AI act; the user still clicks
123
- **Approve** in the editor to bake the lock. You write; they gate.
122
+ - **Never auto-approve.** Writing the contract back is the AI act. If the user asks what changed,
123
+ wants to approve/leave pending/discard, navigate history/checkpoints, or export an approved/DRAFT
124
+ source, invoke **`floless-app-approval`**. It presents the server review and relays explicit human
125
+ decisions; writing a tweak never implies approval.
124
126
  - **Thin-UI contract holds.** The browser recorded intent + screenshots; the brain is you, in
125
127
  the terminal. The editor never edits the contract directly (it's read-only from its side
126
128
  until the user clicks Save after a manual edit — and that is a different path). This skill
@@ -2,7 +2,7 @@
2
2
  name: floless-app-vectorize
3
3
  description: Vectorize a drawing into an editable drawing.vector/v1 contract in floless.app — the "Vectorize" reader. Triggers on a pending floless `rebake` request for the `vectorize` app (queued from its "Re-read & re-bake ▸" button), or asks like "vectorize this PDF", "turn my sketch into clean CAD linework", "read this detail into vectors", "trace this photo", "make this drawing 3D". Teaches the host AI to read a drawing at COMPOSE time — a vector PDF via ONE deterministic PyMuPDF pass (no LLM), a scan/photo/hand sketch by MEASURING its ink with a deterministic OpenCV centerline tracer for geometry plus AWARE's fenced vision.extract for the text (schema-bound, cached) — emit the drawing.vector/v1 contract, PUT it to the contract store, and hand the 2D vector editor to the user; and, for a multi-view set (plan + elevation), to classify views, read datums, and declare entities so the server reconstructs a viewable 3D model.
4
4
  metadata:
5
- version: 0.6.0
5
+ version: 0.7.0
6
6
  ---
7
7
 
8
8
  # Vectorize — read a drawing into a drawing.vector/v1 contract
@@ -272,9 +272,10 @@ Tell the user:
272
272
  the user at the **Confidence** panel — each trace the model was unsure about (confidence
273
273
  < 0.5) is listed there with **Accept** (mark correct) and **Delete** (remove, with Undo), and
274
274
  a "Reviewed N/M" counter tracks progress. Edits auto-save to the contract store.
275
- - **Approve & bake lock**: when satisfied, the user clicks Approve in the editor header — it
276
- bakes the (edited) contract into the `read` node's `config.takeoff` and recompiles, arming
277
- the Run gate. Never auto-approve on their behalf.
275
+ - **Review changes**: when satisfied, route approval, pending/discard decisions, approved history,
276
+ checkpoints, and explicit approved/DRAFT export-source requests through
277
+ **`floless-app-approval`**. It presents the server's canonical comparison and performs only the
278
+ user's explicit decisions. Never auto-approve on their behalf.
278
279
  - **View 3D ▸** (after a multi-view pass, step 3c): the node action opens the read-only
279
280
  reconstruction viewer — orbit/pan/zoom, solid/wire/x-ray, per-group toggles, and the
280
281
  "Not shown in 3D" panel listing every entity that couldn't be placed, with the reason.
package/dist/web/app.css CHANGED
@@ -4040,6 +4040,33 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
4040
4040
  /* ── Workspaces ▸ Exports step (shell-rendered pane; export cards over the project's OWN
4041
4041
  contract). Ports the mockup's .ecard grid into app tokens; all states baseline-faithful. */
4042
4042
  .ws-exports { flex:1; min-height:0; display:flex; flex-direction:column; }
4043
+ .export-source { flex:none; position:relative; margin:12px 20px 0; display:grid; grid-template-columns:126px minmax(240px, 360px) auto 1fr; align-items:center; gap:10px; }
4044
+ .export-source > label { color:var(--text-muted); font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
4045
+ .export-source-combo { position:relative; }
4046
+ .export-source-trigger { width:100%; min-height:34px; justify-content:space-between; }
4047
+ .export-source-popover { left:0; right:auto; top:calc(100% + 5px); width:360px; max-width:min(88vw, 360px); max-height:300px; overflow-y:auto;
4048
+ scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent; }
4049
+ .export-source-popover::-webkit-scrollbar { width:8px; }
4050
+ .export-source-popover::-webkit-scrollbar-thumb { background:var(--border-strong); border-radius:5px; }
4051
+ .export-source-popover::-webkit-scrollbar-track { background:transparent; }
4052
+ .export-source-group + .export-source-group { border-top:1px solid var(--border); margin-top:5px; padding-top:5px; }
4053
+ .export-source-group-label { padding:5px 10px 3px; color:var(--text-dim); font-size:9px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; }
4054
+ .export-source-option { width:100%; padding:7px 10px; display:flex; flex-direction:column; align-items:flex-start; gap:2px; border:0; border-radius:5px; background:none; color:var(--text-muted); text-align:left; cursor:pointer; }
4055
+ .export-source-option:hover, .export-source-option:focus-visible { background:var(--surface-3); color:var(--text); outline:none; }
4056
+ .export-source-option.selected { color:var(--text); background:var(--accent-dim); }
4057
+ .export-source-option small { color:var(--text-dim); font-size:10px; }
4058
+ .export-source-raw { min-height:34px; padding:0 11px; border:1px solid var(--border); border-radius:6px; background:var(--surface-2); color:var(--text-muted); font:inherit; font-size:11px; cursor:pointer; white-space:nowrap; }
4059
+ .export-source-raw:hover { border-color:var(--border-strong); color:var(--text); background:var(--surface-3); }
4060
+ .export-source-raw:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
4061
+ .export-source-banner { min-width:0; padding:7px 10px; border-left:2px solid var(--accent); background:var(--accent-dim); color:var(--text-muted); font-size:11px; line-height:1.4; }
4062
+ .export-source-banner b { color:var(--text); }
4063
+ .export-source-banner.draft { border-left-color:var(--warn); background:color-mix(in srgb, var(--warn) 8%, var(--surface-2)); }
4064
+ .export-source-banner.historical { border-left-color:var(--border-strong); background:var(--surface-2); }
4065
+ .export-source-banner button { padding:0; border:0; background:none; color:var(--accent); font:inherit; cursor:pointer; }
4066
+ .export-source-banner button:hover { text-decoration:underline; }
4067
+ .export-source-status { flex:none; margin:12px 20px 0; padding:8px 11px; border:1px solid var(--border); border-radius:7px; color:var(--text-muted); font-size:11px; }
4068
+ .export-source-status.unavailable { color:var(--warn); }
4069
+ @media (max-width:840px) { .export-source { grid-template-columns:1fr; } }
4043
4070
  /* The Approve gate — a project's Model must be signed off before its exports go out. Not an
4044
4071
  error (accent-dim rail, never a danger color); the inline "Approve" deep-links the sign-off. */
4045
4072
  .ws-exports-gate { flex:none; margin:12px 20px 0; padding:9px 13px; display:flex; align-items:center; gap:6px;
@@ -4176,6 +4203,19 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
4176
4203
  .hist-empty b { color:var(--text); }
4177
4204
  .hist-empty button { background:none; border:none; padding:0; font:inherit; color:var(--accent); cursor:pointer; }
4178
4205
  .hist-empty button:hover { color:var(--accent-bright); text-decoration:underline; }
4206
+ .saved-work { margin-top:20px; padding-top:16px; border-top:1px solid var(--border); }
4207
+ .saved-work-head { display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin-bottom:9px; }
4208
+ .saved-work-head h3 { margin:0; color:var(--text); font-size:13px; font-weight:600; }
4209
+ .saved-work-head span { color:var(--text-dim); font-size:10px; text-transform:uppercase; letter-spacing:.05em; }
4210
+ .saved-work-state { padding:11px 13px; border:1px solid var(--border); border-radius:7px; background:var(--surface-2); color:var(--text-muted); font-size:11.5px; }
4211
+ .saved-work-state.warn { color:var(--warn); }
4212
+ .saved-work-list { display:grid; gap:8px; }
4213
+ .saved-work-card { display:flex; justify-content:space-between; align-items:flex-start; gap:14px; padding:10px 12px; border:1px solid var(--border); border-radius:7px; background:var(--surface-2); }
4214
+ .saved-work-card > div { display:flex; flex-direction:column; gap:3px; }
4215
+ .saved-work-card b { color:var(--text); font-size:12px; }
4216
+ .saved-work-card span, .saved-work-card p { color:var(--text-dim); font-size:10.5px; }
4217
+ .saved-work-card p { margin:0; max-width:320px; text-align:right; line-height:1.4; }
4218
+ @media (max-width:620px) { .saved-work-card { flex-direction:column; } .saved-work-card p { text-align:left; } }
4179
4219
 
4180
4220
  table.hist { width:100%; border-collapse:collapse; font-size:12.5px; }
4181
4221
  table.hist th { text-align:left; font-size:10px; text-transform:uppercase; letter-spacing:.1em; color:var(--text-dim);
@@ -4221,6 +4261,42 @@ table.hist tr.current td { background:var(--accent-soft); }
4221
4261
  .revreview-body::-webkit-scrollbar-thumb { background:var(--border-strong); border-radius:5px; }
4222
4262
  .revreview-body::-webkit-scrollbar-track { background:transparent; }
4223
4263
 
4264
+ /* Approval review — the existing revision-review shell with explicit, mutually-exclusive outcomes. */
4265
+ .modal.approval-review { width:760px; }
4266
+ .approval-impact { margin:8px 0 10px; padding:9px 12px; border-left:2px solid var(--accent);
4267
+ background:var(--accent-dim); color:var(--text-muted); font-size:12px; line-height:1.45; }
4268
+ .approval-impact:empty { display:none; }
4269
+ .approval-review-body { padding-bottom:12px; scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent; }
4270
+ .approval-group { padding:13px 14px; margin:0 0 9px; border:1px solid var(--border); border-radius:8px; background:var(--surface-2); }
4271
+ .approval-group-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; color:var(--text); font-size:12.5px; }
4272
+ .approval-group-head > div { display:flex; align-items:center; gap:8px; min-width:0; }
4273
+ .approval-group-head > span { color:var(--text-dim); font-size:11px; text-align:right; }
4274
+ .approval-group p { margin:7px 0 10px; color:var(--text-muted); font-size:12px; line-height:1.45; }
4275
+ .approval-risk { padding:2px 6px; border:1px solid var(--border-strong); border-radius:999px; color:var(--text-dim); font-size:9px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; }
4276
+ .approval-risk.medium { color:var(--warn); border-color:color-mix(in srgb, var(--warn) 45%, var(--border)); }
4277
+ .approval-risk.high { color:var(--err); border-color:color-mix(in srgb, var(--err) 45%, var(--border)); }
4278
+ .approval-decisions { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
4279
+ .approval-decisions button { min-height:34px; border:1px solid var(--border-strong); border-radius:6px; background:var(--surface-3); color:var(--text-muted); font:inherit; cursor:pointer; }
4280
+ .approval-decisions button:hover { color:var(--text); border-color:var(--accent); }
4281
+ .approval-decisions button.selected { color:var(--text); border-color:var(--accent); background:var(--accent-dim); box-shadow:inset 0 0 0 1px var(--accent); }
4282
+ .approval-decisions button:focus-visible, .approval-discard:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
4283
+ .approval-tech { margin-top:9px; color:var(--text-dim); font-size:11px; }
4284
+ .approval-tech summary { width:max-content; max-width:100%; cursor:pointer; color:var(--text-muted); }
4285
+ .approval-tech div { display:flex; gap:8px; padding:5px 0 0 12px; overflow-wrap:anywhere; }
4286
+ .approval-tech b { color:var(--text-muted); }
4287
+ .approval-discard { margin-top:10px; padding:0; border:0; background:none; color:var(--err); font:inherit; font-size:11px; cursor:pointer; }
4288
+ .approval-discard:hover { text-decoration:underline; }
4289
+ .approval-review-footer { flex:none; position:sticky; bottom:0; padding-top:10px; background:var(--surface-2); border-top:1px solid var(--border); }
4290
+ .approval-review-footer .rev-counts { margin:0 0 8px; }
4291
+ .approval-review-footer .modal-actions { margin-top:0; }
4292
+ .approval-empty, .approval-loading { padding:16px; border:1px solid var(--border); border-radius:8px; color:var(--text-muted); text-align:center; }
4293
+ #ws-approve.approval-clean { background:transparent; color:var(--text-muted); border-color:var(--border-strong); box-shadow:none; }
4294
+ @media (max-width:620px) {
4295
+ .approval-decisions { grid-template-columns:1fr; }
4296
+ .approval-group-head { flex-direction:column; gap:5px; }
4297
+ .approval-group-head > span { text-align:left; }
4298
+ }
4299
+
4224
4300
  /* Counts: informational, and the ABSENCE of chrome is what says so — no border, no card,
4225
4301
  no icon, no hover. Everything actionable below has at least one. */
4226
4302
  .rev-counts { font-size:11px; color:var(--text-dim); margin:0 0 10px; }
@@ -86,7 +86,13 @@
86
86
  const status = String(payload.status || payload.state || payload.kind || '').toLowerCase();
87
87
  const target = payload.target || payload.targetVersion || null;
88
88
  const observedVersion = payload.observedVersion || payload.version || payload.runtimeVersion || null;
89
- const base = { transaction, target, observedVersion };
89
+ // Carried on EVERY normalized state, not set once at adoption. normalize() rebuilds state
90
+ // from each status response, so a field applied only when the job was adopted would be lost
91
+ // on the very first poll — restoring "Upgrading AWARE…" over a bridge repair, and
92
+ // re-enabling the modal hijack for a failure the user never initiated.
93
+ const operation = payload.operation === 'bridge-repair' ? 'bridge-repair' : 'runtime-update';
94
+ const origin = payload.origin === 'auto' ? 'auto' : 'user';
95
+ const base = { transaction, target, observedVersion, operation, origin };
90
96
  if (status === 'running') {
91
97
  return {
92
98
  ...base, status, stage: payload.stage || 'preparing',
@@ -114,7 +120,10 @@
114
120
  ...base, status: 'runtime-failed',
115
121
  error: {
116
122
  code: String(error.code || payload.code || 'runtime-update-failed'),
117
- message: String(error.message || payload.message || 'AWARE could not be upgraded.'),
123
+ message: String(error.message || payload.message
124
+ || (operation === 'bridge-repair'
125
+ ? "AWARE's installed bridges could not be refreshed."
126
+ : 'AWARE could not be upgraded.')),
118
127
  },
119
128
  };
120
129
  }
@@ -152,7 +161,10 @@
152
161
  check = probed.response.ok ? probed.body : null;
153
162
  } catch { /* current readiness remains unknown */ }
154
163
  return emit({
155
- status: 'expired', transaction: null, check,
164
+ // origin carried through so a terminal state the user never initiated is still
165
+ // recognisable as such. Belt and braces alongside adopt() no longer storing: every
166
+ // state the subscriber may act on has to say where it came from.
167
+ status: 'expired', transaction: null, check, origin: state.origin || 'user',
156
168
  message: wasLostAfterRestart
157
169
  ? 'The previous upgrade could not be recovered after the server restarted. Current AWARE status was checked again.'
158
170
  : 'The previous upgrade result expired. Current AWARE status was checked again.',
@@ -161,12 +173,17 @@
161
173
  if (!result.response.ok) {
162
174
  const message = result.body.error || `Could not read AWARE upgrade status (HTTP ${result.response.status}).`;
163
175
  return emit({ status: 'runtime-failed', transaction, target: state.target, observedVersion: null,
176
+ // Identity is immutable, and DEFAULTED because start()/resume() emit before any poll
177
+ // has supplied it — copying a bare `state.operation` there copies undefined, which
178
+ // renders as a runtime upgrade anyway. The defaults match normalize()'s own.
179
+ operation: state.operation || 'runtime-update', origin: state.origin || 'user',
164
180
  error: { code: 'status-request-failed', message: String(message) } });
165
181
  }
166
182
  let next;
167
183
  try { next = normalize(result.body, transaction); }
168
184
  catch (error) {
169
185
  return emit({ status: 'runtime-failed', transaction, target: state.target, observedVersion: null,
186
+ operation: state.operation || 'runtime-update', origin: state.origin || 'user',
170
187
  error: { code: 'transaction-mismatch', message: error.message } });
171
188
  }
172
189
  emit(next);
@@ -245,6 +262,62 @@
245
262
  return poll(transaction, myGeneration);
246
263
  }
247
264
 
265
+ /**
266
+ * Adopt a job the SERVER started — an automatic bridge repair this browser has no stored
267
+ * transaction for, or an automatic failure that happened before it connected.
268
+ *
269
+ * Deliberately hits /active rather than the ordinary check route: the repair holds AWARE's
270
+ * exclusive lease, and the check route takes a shared one, so polling it to discover the repair
271
+ * would block on the very thing being discovered.
272
+ *
273
+ * Single-flight and idempotent — it is called at init AND on the aware-update SSE event, and
274
+ * both can land together.
275
+ */
276
+ let adopting = null;
277
+ async function adopt() {
278
+ if (adopting) return adopting;
279
+ adopting = (async () => {
280
+ let result;
281
+ try {
282
+ result = await request('/api/aware/update/active');
283
+ } catch {
284
+ return state; // discovery is best-effort; the pill's own poll remains the fallback
285
+ }
286
+ if (!result.response.ok) return state;
287
+ const job = result.body && result.body.job;
288
+ const transaction = transactionOf(job);
289
+ if (!transaction) return state;
290
+ // Already following this one (resume() got there first, or a duplicate SSE event).
291
+ if (state.transaction === transaction && state.status !== 'idle') return state;
292
+ generation += 1;
293
+ const myGeneration = generation;
294
+ // Deliberately NOT stored, unlike start(). Storage exists so a reload can resume a job the
295
+ // USER began; an adopted job is rediscovered from /active, which is the server's own
296
+ // authority and needs no client memory. Storing it caused a real regression: after a
297
+ // server restart the stored id 404s, poll() emits `expired` — a state with no origin, and
298
+ // one the subscriber treats as worth interrupting for — so a repair the user never started
299
+ // threw a modal over the workspace on the next load. Not storing removes the path entirely.
300
+ let next;
301
+ try { next = normalize({ ...job, transaction }, transaction); }
302
+ catch { return state; }
303
+ emit({ ...next, adopted: true });
304
+ if (terminal(next)) return next;
305
+ return poll(transaction, myGeneration);
306
+ })().finally(() => { adopting = null; });
307
+ return adopting;
308
+ }
309
+
310
+ /** Retire a terminal automatic result the user has now seen. Best-effort. */
311
+ async function acknowledge(transaction) {
312
+ const id = transaction || state.transaction;
313
+ if (!id) return state;
314
+ try {
315
+ await request(`/api/aware/update/status/${encodeURIComponent(id)}/acknowledge`, { method: 'POST' });
316
+ clearStored();
317
+ } catch { /* the server retires it on its own retention timer regardless */ }
318
+ return state;
319
+ }
320
+
248
321
  async function check() {
249
322
  const result = await request('/api/aware/update');
250
323
  if (!result.response.ok) throw new Error(result.body.error || `Could not check AWARE updates (HTTP ${result.response.status}).`);
@@ -289,7 +362,7 @@
289
362
  }
290
363
 
291
364
  return {
292
- start, resume, retryFailed, check,
365
+ start, resume, adopt, acknowledge, retryFailed, check,
293
366
  getState: () => state,
294
367
  getStoredTransaction: readStored,
295
368
  subscribe(listener) {