@floless/app 0.109.4 → 0.111.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.
- package/dist/floless-server.cjs +569 -80
- package/dist/skills/floless-app-steel-model/SKILL.md +117 -2
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +54 -8
- package/dist/web/app.css +73 -9
- package/dist/web/aware.js +4 -4
- package/dist/web/index.html +19 -0
- package/dist/web/steel-3d-view.js +19 -6
- package/dist/web/steel-editor.html +59 -31
- package/dist/web/workspaces.js +417 -6
- package/package.json +2 -2
package/dist/web/workspaces.js
CHANGED
|
@@ -948,7 +948,7 @@
|
|
|
948
948
|
teklaReadinessState = null;
|
|
949
949
|
renderReadinessState = null;
|
|
950
950
|
track('workspace_project_opened', { app: p.app }); // a real open (card click or post-create landing)
|
|
951
|
-
lastRevState = 'none'; stopRevisionPoll(); // fresh project — drop any prior revision-poll state
|
|
951
|
+
lastRevState = 'none'; stopRevisionPoll(); closeRevReview(); // fresh project — drop any prior revision-poll state and any open review
|
|
952
952
|
// Per-project, like everything above it: never let one project's answer describe another's. Not
|
|
953
953
|
// observable today (every history render is preceded by a fetch that sets it, and a failed fetch
|
|
954
954
|
// renders no rows), but leaving a stale cross-project value in place is the shape of bug this
|
|
@@ -981,6 +981,12 @@
|
|
|
981
981
|
renderReadinessState = null;
|
|
982
982
|
stopRevisionPoll();
|
|
983
983
|
stopKnowledgePoll(); kbCloseConfirm(); kbResetViewer(); knowledgeState = null; // the KB pane is per-project — never carry it across
|
|
984
|
+
// A STAGED REVIEW IS PER-PROJECT TOO, and the line above is the precedent. Without this the modal
|
|
985
|
+
// survived leaving the project: it kept rendering the old project's proposals over the landing, and
|
|
986
|
+
// `revReviewState.projectId` still named the project the user had just left — so confirming would
|
|
987
|
+
// have applied a review to a project that was no longer on screen. The card is hidden two lines
|
|
988
|
+
// down for the same reason; the modal was simply missed.
|
|
989
|
+
closeRevReview();
|
|
984
990
|
lastRevState = 'none'; $revisionCard.hidden = true; closeProjMenu(); applyMode(); syncWorkspaceGuide();
|
|
985
991
|
}
|
|
986
992
|
document.getElementById('ws-back').addEventListener('click', closeProject);
|
|
@@ -3302,6 +3308,19 @@
|
|
|
3302
3308
|
copy.type = 'button'; copy.dataset.revcopy = ''; copy.setAttribute('data-tip', 'Copy the instruction again');
|
|
3303
3309
|
return [spin, txt, copy];
|
|
3304
3310
|
}
|
|
3311
|
+
function buildStagedCard(req) {
|
|
3312
|
+
// A STATIC dot, not the pending spinner: the read has finished and nothing is in flight. The
|
|
3313
|
+
// spinner would say the opposite, and this state can sit here indefinitely — it waits on a person.
|
|
3314
|
+
const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
|
|
3315
|
+
const txt = revEl('span', 'wrc-text');
|
|
3316
|
+
txt.appendChild(revEl('b', null, 'A revision is ready for your review.'));
|
|
3317
|
+
txt.appendChild(document.createTextNode(' Nothing has been applied yet — decide what this read may change.'));
|
|
3318
|
+
const actions = revEl('span', 'wrc-actions');
|
|
3319
|
+
const review = revEl('button', 'btn-mini', 'Review changes');
|
|
3320
|
+
review.type = 'button'; review.dataset.revreview = '';
|
|
3321
|
+
actions.appendChild(review);
|
|
3322
|
+
return [dot, txt, actions];
|
|
3323
|
+
}
|
|
3305
3324
|
function buildFailedCard(req) {
|
|
3306
3325
|
const ico = revEl('span', 'wrc-err-ico', '⚠'); ico.setAttribute('aria-hidden', 'true');
|
|
3307
3326
|
const txt = revEl('span', 'wrc-text');
|
|
@@ -3321,8 +3340,11 @@
|
|
|
3321
3340
|
try { const b = await api('/api/requests'); reqs = Array.isArray(b) ? b : (b.requests || []); } catch { return; }
|
|
3322
3341
|
const mine = reqs.filter((r) => r && r.type === 'revision-read' && r.project === current.id);
|
|
3323
3342
|
const failed = mine.find((r) => r.status === 'failed');
|
|
3343
|
+
const staged = mine.find((r) => r.status === 'staged');
|
|
3324
3344
|
const pending = mine.find((r) => r.status === 'pending');
|
|
3325
|
-
|
|
3345
|
+
// `failed` first, then `staged`, then `pending` — most-resolved wins, so a project holding both a
|
|
3346
|
+
// finished review and a newly queued read shows the one the user can act on.
|
|
3347
|
+
const state = failed ? 'failed' : staged ? 'staged' : pending ? 'pending' : 'none';
|
|
3326
3348
|
// Was pending, now nothing in flight. Confirm a NEW version actually committed (the head advanced
|
|
3327
3349
|
// past the attach baseVersion) before celebrating — a bare request DELETE (Dismiss / footer-clear)
|
|
3328
3350
|
// must NOT show a false "complete" toast or re-lock exports.
|
|
@@ -3339,19 +3361,39 @@
|
|
|
3339
3361
|
}
|
|
3340
3362
|
lastRevState = state;
|
|
3341
3363
|
if (state === 'none') { stopRevisionPoll(); $revisionCard.hidden = true; $revisionCard.replaceChildren(); return; }
|
|
3364
|
+
// `failed` STOPS the poll; `staged` KEEPS it, and the design note that said otherwise rested on an
|
|
3365
|
+
// assumption review disproved. It read "staged is resolved and actionable, nothing changes on its
|
|
3366
|
+
// own" — true of THIS tab's user, false of the system: a second tab, the footer's Clear all, or a
|
|
3367
|
+
// request DELETE removes the request without this tab acting. With the poll stopped there was
|
|
3368
|
+
// nothing left to notice, so the card sat offering "Review changes" for a review that no longer
|
|
3369
|
+
// existed, and the button led to a 410.
|
|
3370
|
+
//
|
|
3371
|
+
// The reason the poll was stopped in the first place is real, so it is handled directly instead:
|
|
3372
|
+
// a tick must not re-render the card underneath an OPEN review. That is what `revReviewState`
|
|
3373
|
+
// guards below — the poll keeps running, and only the repaint waits.
|
|
3342
3374
|
if (state === 'failed') stopRevisionPoll();
|
|
3343
3375
|
else if (!revisionPoll) startRevisionPoll(); // a pending read seen on load → keep it fresh
|
|
3344
3376
|
if (currentStep !== 'drawings') { $revisionCard.hidden = true; return; } // card is Drawings-scoped
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3377
|
+
// A REVIEW IS OPEN — leave the card alone. Repainting it would replace the button focus returns to,
|
|
3378
|
+
// and the modal is the authority on this request until it closes. If the request vanished from
|
|
3379
|
+
// under it, the modal's own confirm learns that from the server and closes; the next tick then
|
|
3380
|
+
// paints the truth.
|
|
3381
|
+
if (revReviewState) return;
|
|
3382
|
+
revCardReq = failed || staged || pending;
|
|
3383
|
+
$revisionCard.className = 'ws-revision-card state-' + state;
|
|
3384
|
+
$revisionCard.replaceChildren(...(
|
|
3385
|
+
state === 'failed' ? buildFailedCard(failed)
|
|
3386
|
+
: state === 'staged' ? buildStagedCard(staged)
|
|
3387
|
+
: buildPendingCard(pending)));
|
|
3348
3388
|
$revisionCard.hidden = false;
|
|
3349
3389
|
}
|
|
3350
3390
|
|
|
3351
3391
|
$revisionCard.addEventListener('click', async (e) => {
|
|
3352
3392
|
const req = revCardReq;
|
|
3353
3393
|
if (!req) return;
|
|
3354
|
-
if (e.target.closest('[data-
|
|
3394
|
+
if (e.target.closest('[data-revreview]')) {
|
|
3395
|
+
openRevisionReview(req);
|
|
3396
|
+
} else if (e.target.closest('[data-revcopy]') && bridge.markedInstruction && bridge.copyToClipboard) {
|
|
3355
3397
|
const ok = await bridge.copyToClipboard(bridge.markedInstruction(req));
|
|
3356
3398
|
showToast(ok ? 'Instruction copied' : 'Copy blocked — use the Requests panel', ok ? 'ok' : 'warn');
|
|
3357
3399
|
} else if (e.target.closest('[data-revdismiss]')) {
|
|
@@ -3362,6 +3404,375 @@
|
|
|
3362
3404
|
}
|
|
3363
3405
|
});
|
|
3364
3406
|
|
|
3407
|
+
// ── Revision review (unit 5, P6e) ───────────────────────────────────────────────
|
|
3408
|
+
// The human decides what a re-read may change. The server has already taken the half that cannot
|
|
3409
|
+
// destroy anything (new evidence, binding updates it is sure of) and REFUSED the half that is out of
|
|
3410
|
+
// policy; what arrives here is the middle — proposals that need a decision — plus counts for the
|
|
3411
|
+
// first and a read-only list of the second.
|
|
3412
|
+
//
|
|
3413
|
+
// NOT A VISUAL DIFF, deliberately (epic §15.1). The organising structure is a checkbox-gated list,
|
|
3414
|
+
// because that is what the server's contract is: selections go back as per-bucket ARRAY INDICES into
|
|
3415
|
+
// the arrays it sent. So this render must preserve the order it was given, and must never filter or
|
|
3416
|
+
// re-sort a bucket — an index is only meaningful against the array it was shown in.
|
|
3417
|
+
const $revReview = document.getElementById('revreview-modal');
|
|
3418
|
+
const $revReviewBody = document.getElementById('revreview-body');
|
|
3419
|
+
const $revReviewCounts = document.getElementById('revreview-counts');
|
|
3420
|
+
const $revReviewChanged = document.getElementById('revreview-changed');
|
|
3421
|
+
const $revReviewSub = document.getElementById('revreview-sub');
|
|
3422
|
+
const $revReviewConfirm = document.getElementById('revreview-confirm');
|
|
3423
|
+
const $revReviewCancel = document.getElementById('revreview-cancel');
|
|
3424
|
+
let revReviewState = null; // { projectId, requestId, stageId, summary, returnFocus }
|
|
3425
|
+
|
|
3426
|
+
/** `elevation_in` → `Elevation in`. A fallback, not a dictionary — the keys are schema names. */
|
|
3427
|
+
const prettyKey = (k) => String(k).replace(/_/g, ' ').replace(/^./, (c) => c.toUpperCase());
|
|
3428
|
+
const shortVal = (v) => {
|
|
3429
|
+
if (v === undefined) return '—';
|
|
3430
|
+
if (v === null) return 'none';
|
|
3431
|
+
if (typeof v === 'string') return v.length > 60 ? v.slice(0, 57) + '…' : v;
|
|
3432
|
+
if (typeof v === 'number' || typeof v === 'boolean') return String(v);
|
|
3433
|
+
// A LIST IS SUMMARISED, not truncated. `memberIds` is the common case, and running the generic
|
|
3434
|
+
// string-truncator over it produced `["B12","B14","B19","B2…` — cut mid-token, which reads as a
|
|
3435
|
+
// rendering fault rather than as a deliberate abbreviation.
|
|
3436
|
+
if (Array.isArray(v)) {
|
|
3437
|
+
if (!v.length) return 'none';
|
|
3438
|
+
const flat = v.map((x) => (typeof x === 'string' || typeof x === 'number' ? String(x) : '…'));
|
|
3439
|
+
const joined = flat.join(', ');
|
|
3440
|
+
if (joined.length <= 48) return joined;
|
|
3441
|
+
// LENGTH GATES THE "+N more" FORM, not just the character count. Keying only on the joined width
|
|
3442
|
+
// meant a SHORT list of LONG items took the elide branch and computed `v.length - 3` on a list
|
|
3443
|
+
// that had fewer than three: one long id rendered `… +-2 more`, three rendered `+0 more`. A list
|
|
3444
|
+
// too short to elide gets the ordinary string truncation instead.
|
|
3445
|
+
if (v.length <= 3) return joined.slice(0, 45) + '…';
|
|
3446
|
+
return `${flat.slice(0, 3).join(', ')} +${v.length - 3} more`;
|
|
3447
|
+
}
|
|
3448
|
+
try { const s = JSON.stringify(v); return s.length > 60 ? s.slice(0, 57) + '…' : s; } catch { return '…'; }
|
|
3449
|
+
};
|
|
3450
|
+
|
|
3451
|
+
/** A before → after line, reusing History's existing transform chip rather than inventing one. */
|
|
3452
|
+
function fieldLine(key, before, after) {
|
|
3453
|
+
const row = revEl('div', 'rev-field');
|
|
3454
|
+
row.appendChild(revEl('span', 'rev-field-key', prettyKey(key)));
|
|
3455
|
+
row.appendChild(revEl('span', 'hd-prof', shortVal(before)));
|
|
3456
|
+
row.appendChild(revEl('span', 'hd-arrow', '→'));
|
|
3457
|
+
row.appendChild(revEl('span', 'hd-prof', shortVal(after)));
|
|
3458
|
+
return row;
|
|
3459
|
+
}
|
|
3460
|
+
|
|
3461
|
+
const KIND_LABEL = {
|
|
3462
|
+
'member-added': 'Member added', 'member-removed': 'Member removed', 'member-changed': 'Member changed',
|
|
3463
|
+
'plan-added': 'Sheet added', 'plan-changed': 'Sheet changed',
|
|
3464
|
+
};
|
|
3465
|
+
const KIND_CLASS = {
|
|
3466
|
+
'member-added': 'k-added', 'member-removed': 'k-removed', 'member-changed': 'k-changed',
|
|
3467
|
+
'plan-added': 'k-added', 'plan-changed': 'k-changed',
|
|
3468
|
+
};
|
|
3469
|
+
/** The 2–3 headline fields worth showing for an added member — not the whole record. */
|
|
3470
|
+
const MEMBER_HEADLINE = ['profile', 'role', 'material'];
|
|
3471
|
+
|
|
3472
|
+
function proposalRow(p, idx, bucket) {
|
|
3473
|
+
const row = revEl('div', 'rev-row ' + (KIND_CLASS[p.kind] || 'k-changed'));
|
|
3474
|
+
const id = `rev-${bucket}-${idx}`;
|
|
3475
|
+
const label = revEl('label', 'rev-check');
|
|
3476
|
+
const box = document.createElement('input');
|
|
3477
|
+
box.type = 'checkbox'; box.dataset.revbucket = bucket; box.dataset.revidx = String(idx);
|
|
3478
|
+
box.setAttribute('aria-labelledby', `${id}-title`);
|
|
3479
|
+
label.appendChild(box);
|
|
3480
|
+
const main = revEl('div', 'rev-row-main');
|
|
3481
|
+
const head = revEl('div', 'rev-row-head');
|
|
3482
|
+
head.appendChild(revEl('span', 'rev-kind-badge', KIND_LABEL[p.kind] || p.kind));
|
|
3483
|
+
const title = revEl('span', 'rev-row-title', p.memberId || p.sheet || '');
|
|
3484
|
+
title.id = `${id}-title`;
|
|
3485
|
+
head.appendChild(title);
|
|
3486
|
+
main.appendChild(head);
|
|
3487
|
+
|
|
3488
|
+
if (p.kind === 'member-changed' || p.kind === 'plan-changed') {
|
|
3489
|
+
const fields = revEl('div', 'rev-fields');
|
|
3490
|
+
for (const f of p.fields || []) fields.appendChild(fieldLine(f.key, f.before, f.after));
|
|
3491
|
+
main.appendChild(fields);
|
|
3492
|
+
} else if (p.kind === 'member-added' && p.member) {
|
|
3493
|
+
const sub = MEMBER_HEADLINE.map((k) => p.member[k]).filter((v) => v != null && v !== '').map(shortVal).join(' · ');
|
|
3494
|
+
if (sub) main.appendChild(revEl('div', 'rev-row-sub', sub));
|
|
3495
|
+
} else if (p.kind === 'plan-added') {
|
|
3496
|
+
const keys = Object.keys(p.plan || {}).filter((k) => k !== 'sheet');
|
|
3497
|
+
main.appendChild(revEl('div', 'rev-row-sub', keys.length ? `${keys.length} field${keys.length > 1 ? 's' : ''}: ${keys.slice(0, 6).map(prettyKey).join(', ')}${keys.length > 6 ? '…' : ''}` : 'a new sheet'));
|
|
3498
|
+
// The omission is NAMED. A reviewer who cannot see the page image should be told it comes with
|
|
3499
|
+
// the sheet, rather than left to read the field list as complete.
|
|
3500
|
+
if ((p.omitted || []).length) {
|
|
3501
|
+
main.appendChild(revEl('div', 'rev-row-note', `The page image and traced linework come with this sheet (${p.omitted.map(prettyKey).join(', ')}).`));
|
|
3502
|
+
}
|
|
3503
|
+
}
|
|
3504
|
+
row.appendChild(label);
|
|
3505
|
+
row.appendChild(main);
|
|
3506
|
+
return row;
|
|
3507
|
+
}
|
|
3508
|
+
|
|
3509
|
+
function bindingRow(b, idx) {
|
|
3510
|
+
const row = revEl('div', 'rev-row k-binding');
|
|
3511
|
+
const id = `rev-bindingProposals-${idx}`;
|
|
3512
|
+
const label = revEl('label', 'rev-check');
|
|
3513
|
+
const box = document.createElement('input');
|
|
3514
|
+
box.type = 'checkbox'; box.dataset.revbucket = 'bindingProposals'; box.dataset.revidx = String(idx);
|
|
3515
|
+
box.setAttribute('aria-labelledby', `${id}-title`);
|
|
3516
|
+
label.appendChild(box);
|
|
3517
|
+
const main = revEl('div', 'rev-row-main');
|
|
3518
|
+
const head = revEl('div', 'rev-row-head');
|
|
3519
|
+
head.appendChild(revEl('span', 'rev-kind-badge', b.kind || 'binding'));
|
|
3520
|
+
const title = revEl('span', 'rev-row-title', b.observationId || '');
|
|
3521
|
+
title.id = `${id}-title`;
|
|
3522
|
+
head.appendChild(title);
|
|
3523
|
+
main.appendChild(head);
|
|
3524
|
+
// UNENRICHED, unlike the canonical proposals: a BindingUpdate carries raw before/after snapshots,
|
|
3525
|
+
// so the row diffs them itself and emits a line ONLY where they differ — otherwise it renders
|
|
3526
|
+
// noise like `status: active → active`.
|
|
3527
|
+
const from = b.from || {}, to = b.to || {};
|
|
3528
|
+
const fields = revEl('div', 'rev-fields');
|
|
3529
|
+
let any = false;
|
|
3530
|
+
for (const k of ['verified', 'status', 'memberIds']) {
|
|
3531
|
+
const a = JSON.stringify(from[k] === undefined ? null : from[k]);
|
|
3532
|
+
const z = JSON.stringify(to[k] === undefined ? null : to[k]);
|
|
3533
|
+
if (a !== z) { fields.appendChild(fieldLine(k, from[k], to[k])); any = true; }
|
|
3534
|
+
}
|
|
3535
|
+
if (any) main.appendChild(fields);
|
|
3536
|
+
row.appendChild(label);
|
|
3537
|
+
row.appendChild(main);
|
|
3538
|
+
return row;
|
|
3539
|
+
}
|
|
3540
|
+
|
|
3541
|
+
function bulkBar(bucket, count) {
|
|
3542
|
+
const bar = revEl('div', 'rev-group-actions');
|
|
3543
|
+
const all = revEl('button', 'btn-mini', 'Accept all'); all.type = 'button';
|
|
3544
|
+
all.dataset.revbulk = bucket; all.dataset.revbulkon = '1';
|
|
3545
|
+
all.setAttribute('data-tip', `Tick all ${count} in this group`);
|
|
3546
|
+
const none = revEl('button', 'btn-mini', 'Clear'); none.type = 'button';
|
|
3547
|
+
none.dataset.revbulk = bucket; none.dataset.revbulkon = '';
|
|
3548
|
+
none.setAttribute('data-tip', 'Untick all in this group');
|
|
3549
|
+
bar.appendChild(all); bar.appendChild(none);
|
|
3550
|
+
return bar;
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
function group(title, count, bucket) {
|
|
3554
|
+
const g = revEl('section', 'rev-group');
|
|
3555
|
+
const head = revEl('div', 'rev-group-head');
|
|
3556
|
+
// The COUNT IS VISIBLE, not only in the bulk button's tooltip. At 200 proposals the reader had no
|
|
3557
|
+
// glanceable sense of scale until they scrolled — and the refused list two blocks down already
|
|
3558
|
+
// shows its count this way, using this same class.
|
|
3559
|
+
const label = revEl('span', 'rev-group-label');
|
|
3560
|
+
label.appendChild(revEl('span', 'rev-group-title', title));
|
|
3561
|
+
if (count) label.appendChild(revEl('span', 'ws-archived-count', String(count)));
|
|
3562
|
+
head.appendChild(label);
|
|
3563
|
+
// BULK ACTIONS PER BUCKET, not one pair for the whole section: the two buckets are separate index
|
|
3564
|
+
// spaces sent back separately, and a shared "Accept all" would blur that for the person clicking it.
|
|
3565
|
+
if (bucket && count) head.appendChild(bulkBar(bucket, count));
|
|
3566
|
+
g.appendChild(head);
|
|
3567
|
+
return g;
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3570
|
+
function renderReview(summary) {
|
|
3571
|
+
// COUNTS: one quiet line, and never "0 of X" — the zero clause is simply omitted.
|
|
3572
|
+
// The numbers carry a <b>, so the two figures worth scanning stand out of the muted sentence —
|
|
3573
|
+
// the rule for it existed and nothing emitted the element.
|
|
3574
|
+
const bits = [];
|
|
3575
|
+
if (summary.accepted) bits.push([String(summary.accepted), ` change${summary.accepted > 1 ? 's' : ''} taken automatically`]);
|
|
3576
|
+
if (summary.bindingUpdates) bits.push([String(summary.bindingUpdates), ` evidence link${summary.bindingUpdates > 1 ? 's' : ''} updated`]);
|
|
3577
|
+
$revReviewCounts.replaceChildren();
|
|
3578
|
+
if (bits.length) {
|
|
3579
|
+
bits.forEach(([n, rest], i) => {
|
|
3580
|
+
if (i) $revReviewCounts.appendChild(document.createTextNode(' · '));
|
|
3581
|
+
$revReviewCounts.appendChild(revEl('b', null, n));
|
|
3582
|
+
$revReviewCounts.appendChild(document.createTextNode(rest));
|
|
3583
|
+
});
|
|
3584
|
+
$revReviewCounts.appendChild(document.createTextNode(' — what the read was sure of, already taken.'));
|
|
3585
|
+
$revReviewCounts.hidden = false;
|
|
3586
|
+
} else { $revReviewCounts.hidden = true; }
|
|
3587
|
+
|
|
3588
|
+
const props = summary.proposals || [];
|
|
3589
|
+
const binds = summary.bindingProposals || [];
|
|
3590
|
+
const issues = summary.issues || [];
|
|
3591
|
+
const body = document.createDocumentFragment();
|
|
3592
|
+
|
|
3593
|
+
if (!props.length && !binds.length) {
|
|
3594
|
+
// No disabled control standing in for an empty state — the group simply is not rendered.
|
|
3595
|
+
body.appendChild(revEl('div', 'hd-empty', issues.length
|
|
3596
|
+
? 'Nothing needs your decision — every change this read proposed is listed below as refused.'
|
|
3597
|
+
: 'This read found no changes to make — the revised set matches what is already in the model.'));
|
|
3598
|
+
}
|
|
3599
|
+
if (props.length) {
|
|
3600
|
+
const g = group('Needs your decision', props.length, 'proposals');
|
|
3601
|
+
props.forEach((p, i) => g.appendChild(proposalRow(p, i, 'proposals')));
|
|
3602
|
+
body.appendChild(g);
|
|
3603
|
+
}
|
|
3604
|
+
if (binds.length) {
|
|
3605
|
+
const g = group('Evidence links', binds.length, 'bindingProposals');
|
|
3606
|
+
binds.forEach((b, i) => g.appendChild(bindingRow(b, i)));
|
|
3607
|
+
body.appendChild(g);
|
|
3608
|
+
}
|
|
3609
|
+
if (issues.length) {
|
|
3610
|
+
// Collapsed by default with the count in the summary, so it is visible without competing —
|
|
3611
|
+
// unless it is the only content, in which case there is nothing for it to compete with.
|
|
3612
|
+
const det = document.createElement('details');
|
|
3613
|
+
det.className = 'ws-archived rev-issues';
|
|
3614
|
+
if (!props.length && !binds.length) det.open = true;
|
|
3615
|
+
const sum = document.createElement('summary');
|
|
3616
|
+
sum.className = 'ws-archived-summary';
|
|
3617
|
+
sum.appendChild(revEl('span', 'ws-archived-caret', '›'));
|
|
3618
|
+
sum.appendChild(document.createTextNode('Refused by the model rules '));
|
|
3619
|
+
sum.appendChild(revEl('span', 'ws-archived-count', String(issues.length)));
|
|
3620
|
+
det.appendChild(sum);
|
|
3621
|
+
for (const it of issues) {
|
|
3622
|
+
const row = revEl('div', 'rev-issue', it.message || it.code || 'refused');
|
|
3623
|
+
row.appendChild(revEl('span', 'rev-issue-path', it.path || ''));
|
|
3624
|
+
det.appendChild(row);
|
|
3625
|
+
}
|
|
3626
|
+
body.appendChild(det);
|
|
3627
|
+
}
|
|
3628
|
+
$revReviewBody.replaceChildren(body);
|
|
3629
|
+
}
|
|
3630
|
+
|
|
3631
|
+
/**
|
|
3632
|
+
* Close the review and REPAINT THE CARD, on every path.
|
|
3633
|
+
*
|
|
3634
|
+
* The repaint lived at the Cancel call site, which review showed was one of four ways out — Escape
|
|
3635
|
+
* and a backdrop click closed without it, and confirm's own paths had their own call. The card is
|
|
3636
|
+
* frozen for as long as a review is open (`renderRevisionCard` skips its repaint while
|
|
3637
|
+
* `revReviewState` is set), so whichever path closes it owes the repaint that catches up. Missing it
|
|
3638
|
+
* on the `failed` transition was permanent: that state stops the poll, so nothing else would ever
|
|
3639
|
+
* repaint the card and it kept offering a review that no longer existed.
|
|
3640
|
+
*
|
|
3641
|
+
* Safe to call unconditionally, which is what lets `closeProject` use it: it clears a class, nulls
|
|
3642
|
+
* the state, restores focus, and `renderRevisionCard` returns immediately when no project is open.
|
|
3643
|
+
*/
|
|
3644
|
+
function closeRevReview() {
|
|
3645
|
+
const wasOpen = !!revReviewState;
|
|
3646
|
+
$revReview.classList.remove('show');
|
|
3647
|
+
const st = revReviewState;
|
|
3648
|
+
revReviewState = null;
|
|
3649
|
+
$revReviewChanged.hidden = true;
|
|
3650
|
+
$revReviewConfirm.disabled = false;
|
|
3651
|
+
const back = st && st.returnFocus;
|
|
3652
|
+
if (back instanceof HTMLElement && back.isConnected) back.focus();
|
|
3653
|
+
else { const b = $revisionCard.querySelector('[data-revreview]'); if (b) b.focus(); }
|
|
3654
|
+
// Only when something was actually open — otherwise every `closeProject` would fire a stray fetch.
|
|
3655
|
+
if (wasOpen) renderRevisionCard();
|
|
3656
|
+
}
|
|
3657
|
+
|
|
3658
|
+
async function openRevisionReview(req) {
|
|
3659
|
+
if (!current || !req) return;
|
|
3660
|
+
const projectId = current.id;
|
|
3661
|
+
const returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
3662
|
+
let body;
|
|
3663
|
+
try {
|
|
3664
|
+
body = await api(`/api/projects/${encodeURIComponent(projectId)}/revision-read/staged?requestId=${encodeURIComponent(req.id)}`);
|
|
3665
|
+
} catch (err) {
|
|
3666
|
+
showToast('Could not load the review: ' + ((err && err.message) || err), 'warn');
|
|
3667
|
+
renderRevisionCard();
|
|
3668
|
+
return;
|
|
3669
|
+
}
|
|
3670
|
+
if (!current || current.id !== projectId) return; // switched projects during the fetch
|
|
3671
|
+
const summary = body && body.staged;
|
|
3672
|
+
if (!summary) { showToast('That review is no longer available', 'warn'); renderRevisionCard(); return; }
|
|
3673
|
+
// RENDER BEFORE ADOPTING THE STATE — the same ordering the 409 path was fixed to use, and this was
|
|
3674
|
+
// the arm that still had it backwards. `revReviewState` is what makes `renderRevisionCard` skip its
|
|
3675
|
+
// repaint, so setting it first and then throwing inside `renderReview` left the guard latched with
|
|
3676
|
+
// no modal on screen: the card would never repaint again for the life of the page.
|
|
3677
|
+
$revReviewSub.textContent = 'Nothing is applied until you confirm. Everything starts unticked — tick what this read may change.';
|
|
3678
|
+
$revReviewChanged.hidden = true;
|
|
3679
|
+
renderReview(summary);
|
|
3680
|
+
revReviewState = { projectId, requestId: req.id, stageId: summary.stageId, summary, returnFocus };
|
|
3681
|
+
$revReview.classList.add('show');
|
|
3682
|
+
const first = $revReviewBody.querySelector('input[type="checkbox"]');
|
|
3683
|
+
(first || $revReviewCancel).focus();
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
async function confirmRevisionReview() {
|
|
3687
|
+
const st = revReviewState;
|
|
3688
|
+
if (!st) return;
|
|
3689
|
+
const accept = { proposals: [], bindingProposals: [] };
|
|
3690
|
+
for (const box of $revReviewBody.querySelectorAll('input[type="checkbox"]:checked')) {
|
|
3691
|
+
const bucket = box.dataset.revbucket;
|
|
3692
|
+
const idx = Number(box.dataset.revidx);
|
|
3693
|
+
// An OWN-PROPERTY check and a real integer test, not `if (accept[bucket])`. The bucket names are
|
|
3694
|
+
// this file's own literals so nothing else can reach here today — but `accept['constructor']` is
|
|
3695
|
+
// truthy on any object, so the shorter guard would have read as validation while validating
|
|
3696
|
+
// nothing, and `Number('')` is 0, which is a VALID index. The server refuses a bad selection
|
|
3697
|
+
// either way; the point is that this reads as what it is.
|
|
3698
|
+
if (Object.hasOwn(accept, bucket) && Number.isInteger(idx) && idx >= 0) accept[bucket].push(idx);
|
|
3699
|
+
}
|
|
3700
|
+
// Ascending, because the server reads them as indices into the array it sent and a client has no
|
|
3701
|
+
// reason to hand back a shuffled list.
|
|
3702
|
+
accept.proposals.sort((a, b) => a - b);
|
|
3703
|
+
accept.bindingProposals.sort((a, b) => a - b);
|
|
3704
|
+
$revReviewConfirm.disabled = true; // busy state, NOT an empty-selection state
|
|
3705
|
+
$revReviewConfirm.setAttribute('aria-busy', 'true');
|
|
3706
|
+
// A busy LABEL too. Approve, the KB adjust and every export card swap their text while working; a
|
|
3707
|
+
// button that only dims leaves the user unsure the click registered.
|
|
3708
|
+
const confirmLabel = $revReviewConfirm.textContent;
|
|
3709
|
+
$revReviewConfirm.textContent = 'Applying…';
|
|
3710
|
+
// The busy chrome comes off in `finally`, not on each exit path. Review found the re-render branch
|
|
3711
|
+
// could leave it latched: a throw inside `renderReview` skipped the two lines that restore it, and
|
|
3712
|
+
// the user was left with a modal they could read and not act on. A `finally` cannot be forgotten by
|
|
3713
|
+
// a path added later, which is the actual fix — restoring it in three places was the bug waiting.
|
|
3714
|
+
try {
|
|
3715
|
+
let res;
|
|
3716
|
+
try {
|
|
3717
|
+
res = await api(`/api/projects/${encodeURIComponent(st.projectId)}/revision-read/confirm`, {
|
|
3718
|
+
method: 'POST', body: JSON.stringify({ requestId: st.requestId, stageId: st.stageId, accept }),
|
|
3719
|
+
});
|
|
3720
|
+
} catch (err) {
|
|
3721
|
+
// THE MODEL MOVED WHILE THE USER WAS READING. The server has already re-staged and handed back the
|
|
3722
|
+
// CURRENT review with a fresh stageId, so this re-renders in place rather than closing: closing
|
|
3723
|
+
// would lose the user's place and make them re-open a card to see what changed.
|
|
3724
|
+
const fresh = err && err.body && err.body.staged;
|
|
3725
|
+
if (fresh) {
|
|
3726
|
+
// RENDER FIRST, THEN adopt the new stage. The order matters on the failure path review found:
|
|
3727
|
+
// if `renderReview` throws, the modal still shows the OLD rows, and having already moved
|
|
3728
|
+
// `revReviewState` to the fresh stageId would leave the user looking at one review while the
|
|
3729
|
+
// next confirm submitted indices against another. Rendering first means a throw leaves the
|
|
3730
|
+
// stale-but-consistent pair, and the `finally` below still restores the button.
|
|
3731
|
+
renderReview(fresh); // replaceChildren builds new, unticked inputs — no tick can survive it
|
|
3732
|
+
revReviewState = { ...st, stageId: fresh.stageId, summary: fresh };
|
|
3733
|
+
$revReviewChanged.replaceChildren();
|
|
3734
|
+
$revReviewChanged.appendChild(revEl('b', null, 'The model changed while you were reviewing.'));
|
|
3735
|
+
$revReviewChanged.appendChild(document.createTextNode(' This is the current review, and your ticks were cleared — the same change can mean something different against a model that moved, so each one needs deciding again.'));
|
|
3736
|
+
$revReviewChanged.hidden = false;
|
|
3737
|
+
return;
|
|
3738
|
+
}
|
|
3739
|
+
showToast('Could not apply: ' + ((err && err.message) || err), 'warn');
|
|
3740
|
+
closeRevReview(); // repaints the card itself
|
|
3741
|
+
return;
|
|
3742
|
+
}
|
|
3743
|
+
const n = accept.proposals.length + accept.bindingProposals.length;
|
|
3744
|
+
// Settle the surrounding state BEFORE closing, because closing is what repaints the card now —
|
|
3745
|
+
// `lastRevState` in particular, or the repaint would read the old value and re-run the
|
|
3746
|
+
// completion check against a request confirm has already deleted.
|
|
3747
|
+
lastRevState = 'none';
|
|
3748
|
+
if (current && current.id === st.projectId) {
|
|
3749
|
+
current.approvedAt = undefined; // applying a read clears the sign-off; exports re-lock
|
|
3750
|
+
if (!$wsHistory.hidden) renderHistory();
|
|
3751
|
+
}
|
|
3752
|
+
if (bridge.loadRequests) bridge.loadRequests().catch(() => {});
|
|
3753
|
+
showToast(n ? `Applied ${n} change${n > 1 ? 's' : ''} — a new version is on History` : 'Applied the evidence — no proposed changes were taken', 'ok');
|
|
3754
|
+
closeRevReview(); // one close, one repaint
|
|
3755
|
+
} finally {
|
|
3756
|
+
// Always, on every path including a throw from the re-render above.
|
|
3757
|
+
$revReviewConfirm.disabled = false;
|
|
3758
|
+
$revReviewConfirm.removeAttribute('aria-busy');
|
|
3759
|
+
$revReviewConfirm.textContent = confirmLabel;
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
$revReviewBody.addEventListener('click', (e) => {
|
|
3764
|
+
const bulk = e.target.closest('[data-revbulk]');
|
|
3765
|
+
if (!bulk) return;
|
|
3766
|
+
const on = bulk.dataset.revbulkon === '1';
|
|
3767
|
+
for (const box of $revReviewBody.querySelectorAll(`input[data-revbucket="${bulk.dataset.revbulk}"]`)) box.checked = on;
|
|
3768
|
+
});
|
|
3769
|
+
$revReviewConfirm.addEventListener('click', confirmRevisionReview);
|
|
3770
|
+
$revReviewCancel.addEventListener('click', closeRevReview);
|
|
3771
|
+
onBackdropDismiss($revReview, closeRevReview, () => !$revReviewConfirm.disabled);
|
|
3772
|
+
$revReview.addEventListener('keydown', (e) => {
|
|
3773
|
+
if (e.key === 'Escape') { e.preventDefault(); if (!$revReviewConfirm.disabled) closeRevReview(); }
|
|
3774
|
+
});
|
|
3775
|
+
|
|
3365
3776
|
// ── History step ────────────────────────────────────────────────────────────────
|
|
3366
3777
|
// The project's version ledger. A version = a commit (Approve = Model gate, Rollback = unsigned).
|
|
3367
3778
|
// The draft contract is the working tree; an unapproved draft shows the working-copy banner.
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floless/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.111.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Thin localhost host for floless.app
|
|
5
|
+
"description": "Thin localhost host for floless.app \u00e2\u20ac\u201d serves web/ and shells the aware CLI. No engine, no LLM.",
|
|
6
6
|
"bin": {
|
|
7
7
|
"floless-app": "bin/floless.mjs"
|
|
8
8
|
},
|