@floless/app 0.134.4 → 0.135.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +908 -346
- package/dist/schemas/steel.model.v2.schema.json +1 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +12 -15
- package/dist/web/aware-update-client.js +137 -25
- package/dist/web/aware.js +280 -31
- package/dist/web/commands-shell.js +35 -4
- package/dist/web/index.html +1 -1
- package/dist/web/steel-filter.html +77 -31
- package/dist/web/steel-model-v2-client-validation.js +12 -1
- package/dist/web/steel-plan-transform.js +74 -15
- package/dist/web/workspaces.js +73 -17
- package/package.json +1 -1
|
@@ -368,7 +368,7 @@ body.publication-blocked #empty{position:static;flex:1}
|
|
|
368
368
|
</div>
|
|
369
369
|
<span id="src" class="stat"></span>
|
|
370
370
|
<span class="sp"></span>
|
|
371
|
-
<span id="saved" class="stat"></span>
|
|
371
|
+
<span id="saved" class="stat" role="status" aria-live="polite" aria-atomic="true"></span>
|
|
372
372
|
<span id="saveRequiredStatus" class="stat required-step" role="status" aria-live="polite" tabindex="-1" hidden>Ready — press Save filter</span>
|
|
373
373
|
<button id="save" data-command-id="filter.save" class="primary" disabled>Save filter</button>
|
|
374
374
|
</header>
|
|
@@ -491,9 +491,13 @@ const APP_ID = new URLSearchParams(location.search).get('app') || '';
|
|
|
491
491
|
// Workspaces use a project-keyed contract; an empty project id is the app-keyed workflow surface.
|
|
492
492
|
const PROJECT = new URLSearchParams(location.search).get('project') || '';
|
|
493
493
|
let revisionRequest = new URLSearchParams(location.search).get('revisionRequest') || '';
|
|
494
|
-
|
|
495
|
-
//
|
|
494
|
+
let revisionFilterSavedEtag = new URLSearchParams(location.search).get('revisionFilterSavedEtag') || '';
|
|
495
|
+
// Monotonic ownership for async Save results. Saved evidence may advance many times for one request;
|
|
496
|
+
// only an actual A→B/A→empty identity transition increments this generation.
|
|
496
497
|
let revisionCheckpointGeneration = 0;
|
|
498
|
+
// A request can retain its identity across many exact saved-filter receipts. Decision surfaces and
|
|
499
|
+
// in-flight previews belong to one such receipt, so they need a separate evidence generation.
|
|
500
|
+
let revisionCheckpointEvidenceGeneration = 0;
|
|
497
501
|
const PROJECT_QS = PROJECT ? ('?project=' + encodeURIComponent(PROJECT)) : '';
|
|
498
502
|
const CONTRACT_QS = PROJECT ? (PROJECT_QS + '&quietMissing=1') : PROJECT_QS;
|
|
499
503
|
const SVGNS = 'http://www.w3.org/2000/svg';
|
|
@@ -677,7 +681,8 @@ function setRequiredSaveCue(checkpoint, ready){
|
|
|
677
681
|
function syncRequiredSaveCue(){
|
|
678
682
|
if(saveInFlight){ setRequiredSaveCue(false, false); saveBtn.disabled = true; return; }
|
|
679
683
|
if(checkpointSaveBlocked){ setRequiredSaveCue(false, false); saveBtn.disabled = true; return; }
|
|
680
|
-
const
|
|
684
|
+
const checkpointCurrent = !!revisionRequest && !!revisionFilterSavedEtag && revisionFilterSavedEtag === serverEtag;
|
|
685
|
+
const checkpoint = !!revisionRequest && !checkpointCurrent && !!C && !!F && !!sel && !conflicted;
|
|
681
686
|
const ready = checkpoint && sheets.some(sheet => (sheet.elements || []).some(el => matchesActive(el, mode, sel)));
|
|
682
687
|
setRequiredSaveCue(checkpoint, ready);
|
|
683
688
|
// The checkpoint always explains the next action, but only a non-empty selection can be saved.
|
|
@@ -714,36 +719,50 @@ function setFilterEditingLocked(locked){
|
|
|
714
719
|
// Same-origin parent bridge: polling may complete, fail, or clear a checkpoint while this editor has
|
|
715
720
|
// unsaved facet changes. Update only the checkpoint state and URL; never reload the document away.
|
|
716
721
|
window.__floRevisionCheckpoint = {
|
|
717
|
-
setRequest(value){
|
|
722
|
+
setRequest(value, savedEtag){
|
|
718
723
|
const nextRequest = String(value || '');
|
|
719
|
-
|
|
724
|
+
const nextSavedEtag = nextRequest ? String(savedEtag || '') : '';
|
|
725
|
+
const requestChanged = nextRequest !== revisionRequest;
|
|
726
|
+
const evidenceChanged = nextSavedEtag !== revisionFilterSavedEtag;
|
|
727
|
+
// The 3-second poll ordinarily repeats the same projection. It must be a true no-op: retiring
|
|
728
|
+
// focus, repainting the live status, or re-running cue state on every identical tick is churn.
|
|
729
|
+
if(!requestChanged && !evidenceChanged) return true;
|
|
730
|
+
// The contract PUT intentionally invalidates the old receipt before `/filter-saved` can publish
|
|
731
|
+
// the replacement. A poll can observe that E1→empty window while this exact Save owns the editor.
|
|
732
|
+
// Defer only same-request evidence changes: request replacement/settlement must still supersede the
|
|
733
|
+
// Save. The parent honours `false` by preserving its prior iframe target until this Save reports its
|
|
734
|
+
// outcome, so neither the decision state nor the reloadable URL can regress to the transient gap.
|
|
735
|
+
if(saveInFlight && !requestChanged && evidenceChanged) return false;
|
|
736
|
+
if(requestChanged){
|
|
720
737
|
revisionCheckpointGeneration += 1;
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
conflicted = false;
|
|
738
|
-
setSaved(dirty ? 'dirty' : '');
|
|
739
|
-
}
|
|
738
|
+
}
|
|
739
|
+
revisionCheckpointEvidenceGeneration += 1;
|
|
740
|
+
// The sign-off list belongs to the exact request + saved evidence that opened it. A same-request
|
|
741
|
+
// E1→E2/E1→empty transition is just as invalidating as request replacement: otherwise an old
|
|
742
|
+
// exclusion decision or dismissed refusal can be approved against the newer checkpoint.
|
|
743
|
+
retireSignOffForCheckpointChange();
|
|
744
|
+
checkpointSaveBlocked = false;
|
|
745
|
+
// Reload-only recovery belongs to the exact checkpoint that failed. Retire it on either identity
|
|
746
|
+
// or evidence change while preserving the user's facet selections and ordinary dirty state.
|
|
747
|
+
const recovery = document.getElementById('conflictBanner');
|
|
748
|
+
if(recovery && recovery.dataset.requiredRecovery === 'true'){
|
|
749
|
+
recovery.remove();
|
|
750
|
+
lastBanner = undefined;
|
|
751
|
+
// `conflicted` belongs to the refused conditional write that produced this recovery surface.
|
|
752
|
+
// An unrelated external-edit conflict has no requiredRecovery marker and remains untouched.
|
|
753
|
+
conflicted = false;
|
|
740
754
|
}
|
|
741
755
|
revisionRequest = nextRequest;
|
|
756
|
+
revisionFilterSavedEtag = nextSavedEtag;
|
|
742
757
|
const url = new URL(location.href);
|
|
743
758
|
if(revisionRequest) url.searchParams.set('revisionRequest', revisionRequest);
|
|
744
759
|
else url.searchParams.delete('revisionRequest');
|
|
760
|
+
if(revisionFilterSavedEtag) url.searchParams.set('revisionFilterSavedEtag', revisionFilterSavedEtag);
|
|
761
|
+
else url.searchParams.delete('revisionFilterSavedEtag');
|
|
745
762
|
history.replaceState(null, '', url.pathname + url.search);
|
|
763
|
+
if(!dirty) setSaved(revisionRequest && revisionFilterSavedEtag === serverEtag ? 'saved' : '');
|
|
746
764
|
syncRequiredSaveCue();
|
|
765
|
+
return true;
|
|
747
766
|
},
|
|
748
767
|
};
|
|
749
768
|
|
|
@@ -1060,6 +1079,7 @@ function initFromFilter(){
|
|
|
1060
1079
|
buildFacet('colors', F.colors || [], it => it.hex);
|
|
1061
1080
|
buildSheetSwitcher();
|
|
1062
1081
|
setSheet(active);
|
|
1082
|
+
if(revisionRequest && revisionFilterSavedEtag && revisionFilterSavedEtag === serverEtag) setSaved('saved');
|
|
1063
1083
|
syncRequiredSaveCue();
|
|
1064
1084
|
}
|
|
1065
1085
|
|
|
@@ -2305,6 +2325,8 @@ async function saveNow(){
|
|
|
2305
2325
|
// the same checkpoint it started, so capture the id once and use it for both requests.
|
|
2306
2326
|
const checkpointRequest = revisionRequest;
|
|
2307
2327
|
const checkpointGeneration = revisionCheckpointGeneration;
|
|
2328
|
+
let checkpointEvidenceGeneration = revisionCheckpointEvidenceGeneration;
|
|
2329
|
+
let completedCheckpoint = false;
|
|
2308
2330
|
try {
|
|
2309
2331
|
const headers = { 'content-type': 'application/json', 'x-floless-mutation-id': mid };
|
|
2310
2332
|
// TOTAL, as of P1c: a write with no precondition is refused (428). No tag means we read through the
|
|
@@ -2350,6 +2372,18 @@ async function saveNow(){
|
|
|
2350
2372
|
// actually returned — assembled there rather than here so this write cannot invent an approval
|
|
2351
2373
|
// the human never saw.
|
|
2352
2374
|
if(pendingSignOff) body.exclusionSignOff = pendingSignOff;
|
|
2375
|
+
// The successful contract PUT has already cleared the historical receipt on the server. Adopt
|
|
2376
|
+
// that expected transition locally only AFTER snapshotting the sign-off body: retiring it through
|
|
2377
|
+
// the parent bridge here would erase the approval this very POST must carry. Advance our baseline
|
|
2378
|
+
// so the Save does not mistake its own E1→empty invalidation for a superseding actor.
|
|
2379
|
+
if(revisionRequest === checkpointRequest && revisionFilterSavedEtag){
|
|
2380
|
+
revisionFilterSavedEtag = '';
|
|
2381
|
+
revisionCheckpointEvidenceGeneration += 1;
|
|
2382
|
+
checkpointEvidenceGeneration = revisionCheckpointEvidenceGeneration;
|
|
2383
|
+
const url = new URL(location.href);
|
|
2384
|
+
url.searchParams.delete('revisionFilterSavedEtag');
|
|
2385
|
+
history.replaceState(null, '', url.pathname + url.search);
|
|
2386
|
+
}
|
|
2353
2387
|
const checkpoint = await fetch(`/api/projects/${encodeURIComponent(PROJECT)}/revision-requests/${encodeURIComponent(checkpointRequest)}/filter-saved`, {
|
|
2354
2388
|
method:'POST', headers:{'content-type':'application/json'}, body:JSON.stringify(body),
|
|
2355
2389
|
});
|
|
@@ -2396,19 +2430,31 @@ async function saveNow(){
|
|
|
2396
2430
|
throw new Error(payload ? (payload.error || JSON.stringify(payload)) : 'the Drawing Filter checkpoint was refused');
|
|
2397
2431
|
}
|
|
2398
2432
|
if(revisionRequest === checkpointRequest){
|
|
2399
|
-
|
|
2433
|
+
revisionFilterSavedEtag = serverEtag;
|
|
2434
|
+
completedCheckpoint = true;
|
|
2400
2435
|
const url = new URL(location.href);
|
|
2401
|
-
url.searchParams.
|
|
2436
|
+
url.searchParams.set('revisionRequest', revisionRequest);
|
|
2437
|
+
url.searchParams.set('revisionFilterSavedEtag', revisionFilterSavedEtag);
|
|
2402
2438
|
history.replaceState(null, '', url.pathname + url.search);
|
|
2403
2439
|
}
|
|
2404
2440
|
}
|
|
2405
2441
|
// A newer request can become the required checkpoint after BOTH of A's writes succeeded. A's
|
|
2406
2442
|
// success is real, but it cannot satisfy B or turn off B's required Save cue. Leave the editor's
|
|
2407
2443
|
// existing dirty state intact so the user is still told exactly what the new checkpoint needs.
|
|
2408
|
-
const checkpointAdvanced = checkpointRequest &&
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2444
|
+
const checkpointAdvanced = checkpointRequest && (
|
|
2445
|
+
revisionCheckpointGeneration !== checkpointGeneration
|
|
2446
|
+
|| revisionCheckpointEvidenceGeneration !== checkpointEvidenceGeneration
|
|
2447
|
+
);
|
|
2448
|
+
if(checkpointAdvanced){ setSaved(dirty ? 'dirty' : ''); syncRequiredSaveCue(); return; }
|
|
2449
|
+
if(completedCheckpoint){
|
|
2450
|
+
revisionCheckpointEvidenceGeneration += 1;
|
|
2451
|
+
// Invalidate every parent `/api/requests` read that began before this receipt committed, adopt
|
|
2452
|
+
// the exact ETag into the iframe target, then let the parent start a fresh authoritative poll.
|
|
2453
|
+
// Without this handshake an older response can replay E1/empty over this local E2 success.
|
|
2454
|
+
globalThis.parent?.flolessWorkspaces?.drawingFilterCheckpointSaved({
|
|
2455
|
+
projectId: PROJECT, requestId: revisionRequest, savedEtag: revisionFilterSavedEtag,
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2412
2458
|
dirty = false; setSaved('saved'); syncRequiredSaveCue();
|
|
2413
2459
|
} catch(e){
|
|
2414
2460
|
// The id is deliberately KEPT here. No response arrived, so we do not know whether the write landed —
|
|
@@ -55,7 +55,18 @@ export function validateClientSteelModelV2(doc, schema) {
|
|
|
55
55
|
// browser. Say it directly rather than leaving it to be inferred from an unresolved control: with the
|
|
56
56
|
// rows unpairable every reader falls back to the override string, so the controls DO resolve and the
|
|
57
57
|
// only visible symptom of a rebound axis list would be the dimension and view anchors.
|
|
58
|
-
|
|
58
|
+
// Both halves of the comparison, named (#918) — the bare `grid-axis-count at $.grid.axes` never
|
|
59
|
+
// said that the entries it counts come from the `$.grid.x`/`$.grid.y` spacing string, so an author
|
|
60
|
+
// who had populated only the axis rows could not act on it.
|
|
61
|
+
//
|
|
62
|
+
// NOT USER-VISIBLE TODAY, and deliberately left that way: these strings become
|
|
63
|
+
// `V2CommandError.details` (steel-model-v2-commands.js), and steel-editor.html toasts only
|
|
64
|
+
// `err.message`. This is PARITY with the server's message, for the debugger and for whatever ever
|
|
65
|
+
// does render `details` — not a fix for anything a user reads. Surfacing the array in the toast
|
|
66
|
+
// would put raw JSON paths in front of a human, which is a worse answer than the generic sentence
|
|
67
|
+
// they get now. (Codex review, #918.)
|
|
68
|
+
const declared = axes.filter((a) => object(a) && a.dir === dir).length;
|
|
69
|
+
if (declared !== n) issues.push(`grid-axis-count at $.grid.axes — $.grid.${dir} parses to ${n} ${dir} ${n === 1 ? 'entry' : 'entries'} but $.grid.axes declares ${declared} ${dir} ${declared === 1 ? 'axis' : 'axes'}`);
|
|
59
70
|
for (const label of axisLabelsFor(doc.grid, dir, style, n)) counts.set(label, (counts.get(label) || 0) + 1);
|
|
60
71
|
return counts;
|
|
61
72
|
};
|
|
@@ -28,21 +28,70 @@ const refuse = (code, message, plan) => {
|
|
|
28
28
|
throw new PlanTransformError(code, message, plan && plan.viewKind);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Contract text quoted back into a refusal. `sheet` and the axis labels are schema-unbounded strings an
|
|
33
|
+
* author supplies, and these messages now travel further than the console — the read audit reports them
|
|
34
|
+
* and the request log keeps them (#925) — so a value is identified, never reproduced whole.
|
|
35
|
+
*/
|
|
36
|
+
const MAX_QUOTED_CHARS = 48;
|
|
37
|
+
// Built from a string so no literal control character sits in this source file.
|
|
38
|
+
const CONTROL_CHARS = new RegExp('[\\u0000-\\u001f\\u007f]', 'g');
|
|
39
|
+
// A surrogate that was ALREADY unpaired in the contract, not one this clip broke. Repaired either way:
|
|
40
|
+
// an audit report and a request log are not places to reproduce invalid text.
|
|
41
|
+
// LOOKBEHIND, not a consuming prefix group: `[^\ud800-\udbff][\udc00-\udfff]` eats the character before
|
|
42
|
+
// the low surrogate, so a global replace skips past the next one and `\udc00\udc01` repairs only half.
|
|
43
|
+
const LONE_SURROGATE = new RegExp('[\\ud800-\\udbff](?![\\udc00-\\udfff])|(?<![\\ud800-\\udbff])[\\udc00-\\udfff]', 'g');
|
|
44
|
+
const wellFormed = (text) => typeof text.toWellFormed === 'function'
|
|
45
|
+
? text.toWellFormed() : text.replace(LONE_SURROGATE, '�');
|
|
46
|
+
/**
|
|
47
|
+
* EXPORTED, and the server's diagnosis notes use this one rather than a mirror of it (#925). The audit
|
|
48
|
+
* side of this same change deletes a duplicated reason list on the grounds that two lists which must
|
|
49
|
+
* agree are one list waiting to disagree; two clips which must agree are the same thing, and the
|
|
50
|
+
* server module already imports from here.
|
|
51
|
+
*
|
|
52
|
+
* `max` may be shortened by a caller that has its own budget; a non-positive one yields the empty
|
|
53
|
+
* string rather than looping, so the bound-enforcing helper honours its own contract.
|
|
54
|
+
*/
|
|
55
|
+
export const clipQuoted = (value, max = MAX_QUOTED_CHARS) => {
|
|
56
|
+
const text = wellFormed(typeof value === 'string' && value ? value : '?').replace(CONTROL_CHARS, ' ');
|
|
57
|
+
if (max <= 0) return '';
|
|
58
|
+
if (text.length <= max) return text;
|
|
59
|
+
// Never cut a surrogate pair in half: a lone surrogate is not text, and this string is serialized
|
|
60
|
+
// into an audit report and a request log, not only shown in a console.
|
|
61
|
+
let end = max - 1;
|
|
62
|
+
const code = text.charCodeAt(end - 1);
|
|
63
|
+
if (end > 0 && code >= 0xd800 && code <= 0xdbff) end--;
|
|
64
|
+
return `${text.slice(0, end)}…`;
|
|
65
|
+
};
|
|
66
|
+
const quote = (value) => clipQuoted(value);
|
|
67
|
+
|
|
31
68
|
/**
|
|
32
69
|
* Resolve one labelled model-grid intersection. Labels are evidence, not identity, so a duplicate is
|
|
33
70
|
* ambiguous and refuses instead of quietly selecting the first matching axis.
|
|
34
71
|
*/
|
|
35
|
-
function gridIntersection(grid, ref, plan) {
|
|
36
|
-
if (!grid || typeof grid !== 'object'
|
|
37
|
-
return refuse('grid-unavailable', `sheet "${plan.sheet
|
|
72
|
+
function gridIntersection(grid, ref, plan, field) {
|
|
73
|
+
if (!grid || typeof grid !== 'object') {
|
|
74
|
+
return refuse('grid-unavailable', `sheet "${quote(plan.sheet)}" has no model grid to resolve its registration controls`, plan);
|
|
75
|
+
}
|
|
76
|
+
// A grid that carries axes, spacings and labels but no `origin` used to share the message above, and
|
|
77
|
+
// it sent authors back to the half they had already filled in (#925). `$.grid.origin` is optional in
|
|
78
|
+
// the schema and unmentioned by every other check, so its name has to be in the refusal or nothing
|
|
79
|
+
// says it. Same CODE deliberately: `_PLAN_XF_UNREGISTERED` in steel-editor.html classifies by code.
|
|
80
|
+
if (!finite2(grid.origin)) {
|
|
81
|
+
return refuse(
|
|
82
|
+
'grid-unavailable',
|
|
83
|
+
`sheet "${quote(plan.sheet)}" cannot resolve its registration controls: $.grid.origin is missing or unreadable — it must be two finite world-mm numbers giving where the first x and y grid axes cross`,
|
|
84
|
+
plan,
|
|
85
|
+
);
|
|
38
86
|
}
|
|
39
87
|
if (!ref || typeof ref !== 'object' || typeof ref.axis_x !== 'string' || typeof ref.axis_y !== 'string') {
|
|
40
|
-
return refuse('control-ref-invalid', `sheet "${plan.sheet
|
|
88
|
+
return refuse('control-ref-invalid', `sheet "${quote(plan.sheet)}" has an unreadable ${field}: a registration control needs string axis_x and axis_y labels`, plan);
|
|
41
89
|
}
|
|
42
90
|
|
|
43
91
|
const X = parseSpacings(grid.x), Y = parseSpacings(grid.y);
|
|
44
92
|
if (X.err || Y.err) {
|
|
45
|
-
|
|
93
|
+
const bad = X.err ? '$.grid.x' : '$.grid.y';
|
|
94
|
+
return refuse('grid-spacing-invalid', `sheet "${quote(plan.sheet)}" cannot use ${bad}: ${quote(X.err || Y.err)}`, plan);
|
|
46
95
|
}
|
|
47
96
|
// The SAME resolver the bubbles are drawn from, so a control ref matches the name on the sheet (#740).
|
|
48
97
|
const xs = axisLabelsFor(grid, 'x', 'num', X.offsets.length);
|
|
@@ -55,7 +104,7 @@ function gridIntersection(grid, ref, plan) {
|
|
|
55
104
|
if (xi < 0 || yi < 0) {
|
|
56
105
|
return refuse(
|
|
57
106
|
'control-ref-unresolved',
|
|
58
|
-
`sheet "${plan.sheet
|
|
107
|
+
`sheet "${quote(plan.sheet)}" ${field} names ${quote(ref.axis_x)}/${quote(ref.axis_y)}, which is not exactly one x and one y label on the model grid`,
|
|
59
108
|
plan,
|
|
60
109
|
);
|
|
61
110
|
}
|
|
@@ -71,30 +120,30 @@ function gridIntersection(grid, ref, plan) {
|
|
|
71
120
|
export function planTransform(plan) {
|
|
72
121
|
const kind = plan && plan.viewKind;
|
|
73
122
|
if (kind !== 'plan') {
|
|
74
|
-
const named = typeof kind === 'string' ? kind : 'unknown';
|
|
123
|
+
const named = typeof kind === 'string' && kind ? quote(kind) : 'unknown';
|
|
75
124
|
return refuse(
|
|
76
125
|
'view-kind-unsupported',
|
|
77
|
-
`sheet "${plan && plan.sheet
|
|
126
|
+
`sheet "${quote(plan && plan.sheet)}" is a ${named} view; ${named} views are not supported by the plan transform`,
|
|
78
127
|
plan,
|
|
79
128
|
);
|
|
80
129
|
}
|
|
81
130
|
if (!finite2(plan.datum_at) || !finite2(plan.control2_at) || !plan.control2_ref) {
|
|
82
131
|
return refuse(
|
|
83
132
|
'registration-incomplete',
|
|
84
|
-
`sheet "${plan.sheet
|
|
133
|
+
`sheet "${quote(plan.sheet)}" needs $.datum_at, $.control2_at and $.control2_ref before it can be edited`,
|
|
85
134
|
plan,
|
|
86
135
|
);
|
|
87
136
|
}
|
|
88
137
|
const ptPerFt = Number(plan.pt_per_ft);
|
|
89
138
|
if (!(ptPerFt > 0) || !Number.isFinite(ptPerFt)) {
|
|
90
|
-
return refuse('scale-invalid', `sheet "${plan.sheet
|
|
139
|
+
return refuse('scale-invalid', `sheet "${quote(plan.sheet)}" has no positive $.pt_per_ft, so it has no drawing scale`, plan);
|
|
91
140
|
}
|
|
92
141
|
|
|
93
142
|
// Editor projections expose a display-space `grid` because grid-core draws in pixels. The canonical
|
|
94
143
|
// world grid rides beside it as `modelGrid`; standalone callers and stored-plan fixtures use `grid`.
|
|
95
144
|
const registrationGrid = plan.modelGrid || plan.grid;
|
|
96
|
-
const world0 = plan.datum_ref ? gridIntersection(registrationGrid, plan.datum_ref, plan) : [0, 0];
|
|
97
|
-
const world1 = gridIntersection(registrationGrid, plan.control2_ref, plan);
|
|
145
|
+
const world0 = plan.datum_ref ? gridIntersection(registrationGrid, plan.datum_ref, plan, '$.datum_ref') : [0, 0];
|
|
146
|
+
const world1 = gridIntersection(registrationGrid, plan.control2_ref, plan, '$.control2_ref');
|
|
98
147
|
// The shared plan scale. Its zero/negative fallback is unreachable here — the guard above already
|
|
99
148
|
// refused any sheet whose `pt_per_ft` is not a positive finite number — so this is the same value
|
|
100
149
|
// the inline `FT_MM / ptPerFt` produced, from the one implementation.
|
|
@@ -106,15 +155,25 @@ export function planTransform(plan) {
|
|
|
106
155
|
const worldDelta = [world1[0] - world0[0], world1[1] - world0[1]];
|
|
107
156
|
const localLen = Math.hypot(local1[0], local1[1]);
|
|
108
157
|
const worldLen = Math.hypot(worldDelta[0], worldDelta[1]);
|
|
109
|
-
|
|
110
|
-
|
|
158
|
+
// TWO different defects, and one recovery cannot serve both: the display points can coincide while the
|
|
159
|
+
// refs are fine, or the refs can resolve to one intersection while the display points differ. Naming
|
|
160
|
+
// the wrong pair sends the author to fields that are already correct (#925's own failure mode).
|
|
161
|
+
if (!(localLen > 1e-9)) {
|
|
162
|
+
return refuse('registration-degenerate', `sheet "${quote(plan.sheet)}" has coincident registration controls: $.datum_at and $.control2_at are the same point on the sheet`, plan);
|
|
163
|
+
}
|
|
164
|
+
if (!(worldLen > 1e-9)) {
|
|
165
|
+
// `datum_ref` is ABSENT for the "datum_at is the model origin" case, and naming a field that is
|
|
166
|
+
// not there is the same wrong-half misdirection this refusal exists to avoid.
|
|
167
|
+
const datum = plan.datum_ref ? '$.datum_ref and $.control2_ref resolve to the same grid intersection'
|
|
168
|
+
: '$.control2_ref resolves to the model origin, which is where an absent $.datum_ref already puts the datum';
|
|
169
|
+
return refuse('registration-degenerate', `sheet "${quote(plan.sheet)}" has coincident registration controls: ${datum}`, plan);
|
|
111
170
|
}
|
|
112
171
|
const fitScale = worldLen / localLen;
|
|
113
172
|
const rotation = Math.atan2(worldDelta[1], worldDelta[0]) - Math.atan2(local1[1], local1[0]);
|
|
114
173
|
const c = Math.cos(rotation) * fitScale;
|
|
115
174
|
const s = Math.sin(rotation) * fitScale;
|
|
116
175
|
if (![c, s, fitScale, world0[0], world0[1]].every(Number.isFinite)) {
|
|
117
|
-
return refuse('registration-invalid', `sheet "${plan.sheet
|
|
176
|
+
return refuse('registration-invalid', `sheet "${quote(plan.sheet)}" has a non-finite registration transform`, plan);
|
|
118
177
|
}
|
|
119
178
|
return { datumPx: plan.datum_at, world0, mmPerPx: scale, fitScale, rotation, c, s };
|
|
120
179
|
}
|
package/dist/web/workspaces.js
CHANGED
|
@@ -1886,7 +1886,7 @@
|
|
|
1886
1886
|
// stages until this probe produces a real lifecycle answer.
|
|
1887
1887
|
if (projectContractLifecycle === 'unknown') return '';
|
|
1888
1888
|
if (step === 'model') {
|
|
1889
|
-
if (waitingForInitial && revCardReq?.
|
|
1889
|
+
if (waitingForInitial && revCardReq?.filterCheckpointCurrent) return 'The Drawing Filter is saved. Return to the same terminal AI session that prepared it and tell it to continue the drawing read.';
|
|
1890
1890
|
if (waitingForInitial && revCardReq?.prepassReady) return 'Review the selected lines, then press Save filter. After Save, return to the terminal AI that prepared it and tell it to continue.';
|
|
1891
1891
|
if (waitingForInitial) return 'The initial drawing read is waiting for your terminal AI. The model unlocks after you review the Drawing Filter and press Save filter.';
|
|
1892
1892
|
if (projectContractLifecycle === 'filter-checkpoint') return 'Attach the drawing set again in Drawing Filter to restart the read. The earlier request is no longer available to receive a saved filter.';
|
|
@@ -1962,7 +1962,7 @@
|
|
|
1962
1962
|
: `The drawing read failed · ${revCardReq?.clearWhy || 'FloLess cannot safely release this drawing read yet.'} Open Requests for the available recovery.`)
|
|
1963
1963
|
: unavailableInitial
|
|
1964
1964
|
? 'This drawing read uses a status this version of FloLess does not recognize · Open Requests for details and update FloLess before continuing.'
|
|
1965
|
-
: waitingForInitial && revCardReq?.
|
|
1965
|
+
: waitingForInitial && revCardReq?.filterCheckpointCurrent
|
|
1966
1966
|
? 'Stage 1 of 4 complete · The Drawing Filter is saved. Return to the same terminal AI session that prepared it and tell it to continue the drawing read. Model, Exports, and History unlock when it finishes.'
|
|
1967
1967
|
: waitingForInitial && revCardReq?.prepassReady
|
|
1968
1968
|
? 'Stage 1 of 4 · Review the selected layers, line weights, and colours below. Then press Save filter in the top-right corner, return to the terminal AI that prepared it, and tell it to continue. Model, Exports, and History unlock when the read finishes.'
|
|
@@ -5605,6 +5605,13 @@
|
|
|
5605
5605
|
let revisionOwnerGen = 0; // bumped only when navigation retires actions owned by the current project
|
|
5606
5606
|
let revisionAttachGen = 0; // newest Attach owns its delayed copy/modal completion within that project
|
|
5607
5607
|
let revRequestsFailed = false; // one log per outage, not one per 3-second poll tick
|
|
5608
|
+
// A full-page navigation aborts any revision-card fetch that happens to be in flight. Chromium
|
|
5609
|
+
// reports that teardown as `TypeError: Failed to fetch`, indistinguishable from a live outage by
|
|
5610
|
+
// error shape alone. Track the page lifecycle so the retired document does not emit a false console
|
|
5611
|
+
// error; `pageshow` resets the flag when the same document returns from the back-forward cache.
|
|
5612
|
+
let workspacePageUnloading = false;
|
|
5613
|
+
window.addEventListener('pagehide', () => { workspacePageUnloading = true; });
|
|
5614
|
+
window.addEventListener('pageshow', () => { workspacePageUnloading = false; });
|
|
5608
5615
|
/**
|
|
5609
5616
|
* Every piece of revision state above is PER-PROJECT, so opening or closing one must clear all of
|
|
5610
5617
|
* it — and until this existed only `lastRevState` was. What the other three left behind:
|
|
@@ -5722,7 +5729,7 @@
|
|
|
5722
5729
|
|
|
5723
5730
|
function buildPendingCard(req) {
|
|
5724
5731
|
const n = (req.sourceRefs && req.sourceRefs.length) || (req.snapshots && req.snapshots.length) || 1;
|
|
5725
|
-
if (req.prepassReady && req.
|
|
5732
|
+
if (req.prepassReady && req.filterCheckpointCurrent) {
|
|
5726
5733
|
const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
|
|
5727
5734
|
const txt = revEl('span', 'wrc-text');
|
|
5728
5735
|
txt.appendChild(revEl('b', null, 'Drawing Filter saved.'));
|
|
@@ -5749,7 +5756,11 @@
|
|
|
5749
5756
|
const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
|
|
5750
5757
|
const txt = revEl('span', 'wrc-text');
|
|
5751
5758
|
txt.appendChild(revEl('b', null, `${isInitialRevisionRead(req) ? 'Initial' : 'Updated'} drawing read is running.`));
|
|
5752
|
-
|
|
5759
|
+
// Reachable ONLY for an updated read: `run` exists only for a FloLess-started headless run,
|
|
5760
|
+
// which needs canRun, which run-relay refuses for a first read. So no stage gate applies and
|
|
5761
|
+
// "keep working" is true here. "Leave FloLess open" is load-bearing, not padding - stopAllRuns
|
|
5762
|
+
// kills every spawned run on shutdown.
|
|
5763
|
+
txt.appendChild(document.createTextNode(` Your terminal AI is preparing ${n} file${n > 1 ? 's' : ''}. Leave FloLess open — you can keep working elsewhere in it. Progress and what to do next appear here. Open Requests if you need to stop it.`));
|
|
5753
5764
|
return [dot, txt];
|
|
5754
5765
|
}
|
|
5755
5766
|
// `pending` means the request is waiting for the terminal AI handoff; it does not prove that an
|
|
@@ -5763,7 +5774,16 @@
|
|
|
5763
5774
|
const handoff = !isInitialRevisionRead(req) && req.canRun
|
|
5764
5775
|
? 'Open Requests. If Start automatically is shown, choose it; otherwise copy the request into Claude Code, Codex, or OpenCode.'
|
|
5765
5776
|
: 'Open Requests and copy the request into Claude Code, Codex, or OpenCode.';
|
|
5766
|
-
|
|
5777
|
+
// No numeric cap. "up to 30 minutes" was a promise this card cannot keep: the read runs in
|
|
5778
|
+
// someone else's terminal AI over a drawing set whose size we do not bound, and a stated
|
|
5779
|
+
// ceiling that is routinely blown past reads as a stall or a hang rather than as normal work.
|
|
5780
|
+
// "How long" is unanswerable, so this says what happens NEXT instead - the prepassReady branch
|
|
5781
|
+
// above is the card that replaces this one, and startRevisionPoll repaints every 3s.
|
|
5782
|
+
// Deliberately carries NO "keep working meanwhile" either. Unlike the running card, this one
|
|
5783
|
+
// renders for an INITIAL read, where stageGateFor locks Model/Exports/History and bounces the
|
|
5784
|
+
// user back to a Drawing Filter that is not ready yet - and the stage banner above already
|
|
5785
|
+
// says so. The duration warning is unconditional because the cap was false for both states.
|
|
5786
|
+
txt.appendChild(document.createTextNode(` ${n} file${n > 1 ? 's' : ''} queued. ${handoff} Then return here. Larger drawing sets take longer; FloLess updates this card when the Drawing Filter is ready for your review.`));
|
|
5767
5787
|
const copy = revEl('button', 'btn-mini', '⧉ Copy');
|
|
5768
5788
|
copy.type = 'button'; copy.dataset.revcopy = ''; copy.dataset.commandId = 'shell.revision-request-copy';
|
|
5769
5789
|
copy.setAttribute('data-tip', 'Copy the instruction again');
|
|
@@ -5876,6 +5896,7 @@
|
|
|
5876
5896
|
reqs = Array.isArray(b) ? b : (b.requests || []);
|
|
5877
5897
|
revRequestsFailed = false;
|
|
5878
5898
|
} catch (e) {
|
|
5899
|
+
if (workspacePageUnloading) return;
|
|
5879
5900
|
if (!revRequestsFailed) console.error('[workspaces] could not load requests for the revision card', e);
|
|
5880
5901
|
revRequestsFailed = true;
|
|
5881
5902
|
return;
|
|
@@ -5971,20 +5992,23 @@
|
|
|
5971
5992
|
// returning to Drawing Filter briefly resurrects the old "reading" state and can leave Save filter
|
|
5972
5993
|
// unaware that the terminal prepass finished until a later poll happens to repaint the tab.
|
|
5973
5994
|
revCardReq = failed || staged || pending || activeRequest;
|
|
5974
|
-
syncDrawingRevisionRequest(
|
|
5995
|
+
syncDrawingRevisionRequest(
|
|
5996
|
+
pending?.prepassReady ? pending.id : '',
|
|
5997
|
+
pending?.prepassReady && pending.filterCheckpointCurrent ? pending.filterSavedEtag : '',
|
|
5998
|
+
);
|
|
5975
5999
|
if (currentStep !== 'drawings') { $revisionCard.hidden = true; applyStageGating(); return; } // card is Drawing Filter-scoped
|
|
5976
6000
|
// A REVIEW IS OPEN — leave the card alone. Repainting it would replace the button focus returns to,
|
|
5977
6001
|
// and the modal is the authority on this request until it closes. If the request vanished from
|
|
5978
6002
|
// under it, the modal's own confirm learns that from the server and closes; the next tick then
|
|
5979
6003
|
// paints the truth.
|
|
5980
6004
|
if (revReviewState || revDiscardState) return;
|
|
5981
|
-
const cardKey = `${state}:${revCardReq ? revCardReq.id : ''}:${pending && pending.
|
|
6005
|
+
const cardKey = `${state}:${revCardReq ? revCardReq.id : ''}:${pending && pending.filterCheckpointCurrent ? 'filter-saved' : pending && pending.prepassReady ? 'filter-ready' : 'read-pending'}:${pending && pending.run ? pending.run.state || '' : ''}`
|
|
5982
6006
|
+ (staged ? `:${staged.baseVersion}:${staged.headVersion}:${staged.stageId || ''}:${staged.canDiscardRevision === true}:${staged.discardState || ''}:${staged.discardWhy || ''}:${staged.canClear === true}:${staged.clearWhy || ''}:${unavailableRevisionReviewStages.has(staged.stageId)}` : '');
|
|
5983
6007
|
if ($revisionCard._renderKey === cardKey && !$revisionCard.hidden) return; // preserve focus across the 3 s poll
|
|
5984
6008
|
const restoreFocus = typeof document !== 'undefined' && $revisionCard.contains(document.activeElement);
|
|
5985
6009
|
$revisionCard._renderKey = cardKey;
|
|
5986
6010
|
$revisionCard.className = 'ws-revision-card state-' + state
|
|
5987
|
-
+ (pending && pending.
|
|
6011
|
+
+ (pending && pending.filterCheckpointCurrent ? ' state-filter-saved' : pending && pending.prepassReady ? ' state-filter-ready' : '')
|
|
5988
6012
|
+ (staged && isRevisionStale(staged) ? ' state-stale' : '');
|
|
5989
6013
|
$revisionCard.replaceChildren(...(
|
|
5990
6014
|
state === 'failed' ? buildFailedCard(failed)
|
|
@@ -5997,25 +6021,54 @@
|
|
|
5997
6021
|
}
|
|
5998
6022
|
|
|
5999
6023
|
/** Keep the request checkpoint in the already-open Drawing Filter without navigating away edits. */
|
|
6000
|
-
function syncDrawingRevisionRequest(targetRequest) {
|
|
6024
|
+
function syncDrawingRevisionRequest(targetRequest, targetSavedEtag = '') {
|
|
6001
6025
|
const frame = frames.drawings;
|
|
6002
6026
|
if (!frame?.dataset.want) return;
|
|
6003
6027
|
const requestId = String(targetRequest || '');
|
|
6028
|
+
const savedEtag = requestId ? String(targetSavedEtag || '') : '';
|
|
6029
|
+
let bridged = false;
|
|
6030
|
+
if (frame.dataset.loaded) {
|
|
6031
|
+
try {
|
|
6032
|
+
const checkpoint = frame.contentWindow?.__floRevisionCheckpoint;
|
|
6033
|
+
if (checkpoint && typeof checkpoint.setRequest === 'function') {
|
|
6034
|
+
// `false` means this exact child Save owns a transient E1→empty invalidation. Do not let the
|
|
6035
|
+
// same stale poll rewrite dataset.want either, or the next iframe load would replay the gap.
|
|
6036
|
+
if (checkpoint.setRequest(requestId, savedEtag) === false) return false;
|
|
6037
|
+
bridged = true;
|
|
6038
|
+
}
|
|
6039
|
+
} catch { /* not ready or not same-origin yet — reconcile through the target URL below */ }
|
|
6040
|
+
}
|
|
6004
6041
|
const wanted = new URL(frame.dataset.want, location.origin);
|
|
6005
6042
|
if (requestId) wanted.searchParams.set('revisionRequest', requestId);
|
|
6006
6043
|
else wanted.searchParams.delete('revisionRequest');
|
|
6044
|
+
if (savedEtag) wanted.searchParams.set('revisionFilterSavedEtag', savedEtag);
|
|
6045
|
+
else wanted.searchParams.delete('revisionFilterSavedEtag');
|
|
6007
6046
|
frame.dataset.want = wanted.pathname + wanted.search;
|
|
6008
|
-
if (!frame.dataset.loaded) return;
|
|
6047
|
+
if (!frame.dataset.loaded || bridged) return true;
|
|
6009
6048
|
try {
|
|
6010
|
-
const checkpoint = frame.contentWindow?.__floRevisionCheckpoint;
|
|
6011
|
-
if (checkpoint && typeof checkpoint.setRequest === 'function') {
|
|
6012
|
-
checkpoint.setRequest(requestId);
|
|
6013
|
-
return;
|
|
6014
|
-
}
|
|
6015
6049
|
const shown = new URL(frame.contentWindow.location.href);
|
|
6016
|
-
if ((shown.searchParams.get('revisionRequest') || '') === requestId
|
|
6050
|
+
if ((shown.searchParams.get('revisionRequest') || '') === requestId
|
|
6051
|
+
&& (shown.searchParams.get('revisionFilterSavedEtag') || '') === savedEtag) return true;
|
|
6017
6052
|
} catch { /* not ready or not same-origin yet — navigate to the authoritative target below */ }
|
|
6018
6053
|
frame.src = frame.dataset.want;
|
|
6054
|
+
return true;
|
|
6055
|
+
}
|
|
6056
|
+
|
|
6057
|
+
/**
|
|
6058
|
+
* The child completed both halves of a required Filter Save. Invalidate any request-list poll that
|
|
6059
|
+
* began before that commit, adopt the exact receipt immediately, and start a fresh authoritative
|
|
6060
|
+
* read. ETags are hashes, not ordered versions, so a child-side "keep whichever looks newer" rule
|
|
6061
|
+
* cannot distinguish a stale poll from a genuine later invalidation; the existing poll generation can.
|
|
6062
|
+
*/
|
|
6063
|
+
function drawingFilterCheckpointSaved(notice) {
|
|
6064
|
+
const projectId = String(notice?.projectId || '');
|
|
6065
|
+
const requestId = String(notice?.requestId || '');
|
|
6066
|
+
const savedEtag = String(notice?.savedEtag || '');
|
|
6067
|
+
if (!current || current.id !== projectId || !requestId || !savedEtag) return false;
|
|
6068
|
+
revisionGen += 1;
|
|
6069
|
+
syncDrawingRevisionRequest(requestId, savedEtag);
|
|
6070
|
+
void renderRevisionCard();
|
|
6071
|
+
return true;
|
|
6019
6072
|
}
|
|
6020
6073
|
|
|
6021
6074
|
/**
|
|
@@ -8278,6 +8331,9 @@
|
|
|
8278
8331
|
renderKnowledge();
|
|
8279
8332
|
}
|
|
8280
8333
|
|
|
8281
|
-
window.flolessWorkspaces = {
|
|
8334
|
+
window.flolessWorkspaces = {
|
|
8335
|
+
setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind,
|
|
8336
|
+
openHistory: wsOpenHistory, openKnowledgePage, drawingFilterCheckpointSaved,
|
|
8337
|
+
};
|
|
8282
8338
|
applyMode(); // restore persisted mode immediately (matches panels.js applyView timing)
|
|
8283
8339
|
})();
|