@floless/app 0.162.0 → 0.163.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.
Files changed (36) hide show
  1. package/dist/floless-server.cjs +11754 -8096
  2. package/dist/schemas/steel.model.v2.schema.json +16 -2
  3. package/dist/skills/floless-app-actions/SKILL.md +54 -3
  4. package/dist/skills/floless-app-onboarding/SKILL.md +2 -2
  5. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +8 -6
  6. package/dist/skills/floless-app-report-issue/SKILL.md +12 -1
  7. package/dist/skills/floless-app-rfi/SKILL.md +36 -9
  8. package/dist/skills/floless-app-steel-model/SKILL.md +5 -3
  9. package/dist/skills/floless-app-steel-takeoff/SKILL.md +39 -34
  10. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +10 -6
  11. package/dist/web/agents.js +24 -4
  12. package/dist/web/app.css +45 -7
  13. package/dist/web/app.js +22 -3
  14. package/dist/web/aware.js +157 -43
  15. package/dist/web/chat.css +26 -1
  16. package/dist/web/chat.js +32 -8
  17. package/dist/web/commands-shell.js +190 -4
  18. package/dist/web/commands-steel.js +14 -0
  19. package/dist/web/failure-copy.js +168 -0
  20. package/dist/web/index.html +35 -1
  21. package/dist/web/instructor.js +3 -1
  22. package/dist/web/landing-sort.js +277 -0
  23. package/dist/web/model-editor-steel-adapter.js +3 -0
  24. package/dist/web/model-panel-bridge.js +13 -2
  25. package/dist/web/model-view-query.js +23 -15
  26. package/dist/web/project-access.js +3 -3
  27. package/dist/web/project-rfis.js +250 -7
  28. package/dist/web/project-workflows.js +1 -1
  29. package/dist/web/steel-3d-view.js +8 -1
  30. package/dist/web/steel-editor.html +441 -12
  31. package/dist/web/steel-filter-core.js +2 -0
  32. package/dist/web/steel-filter.html +38 -5
  33. package/dist/web/steel-model-v2-commands.js +3 -1
  34. package/dist/web/steel-profile-colours.js +124 -24
  35. package/dist/web/workspaces.js +243 -38
  36. package/package.json +1 -1
@@ -650,6 +650,8 @@ export function statChip(state) {
650
650
  case 'dirty': return { cls: 'dirty', text: 'Unsaved ', badge: '●' };
651
651
  case 'saving': return { cls: '', text: 'Saving filter…', badge: null };
652
652
  case 'saved': return { cls: 'saved', text: 'Filter saved ', badge: '✓' };
653
+ // #2521 row 2c: saved, but by the AI's choice in a Quick model build: never worded as the person's Save.
654
+ case 'ai-saved': return { cls: 'saved', text: 'Saved as the AI’s choice ', badge: '✓' };
653
655
  case 'err': return { cls: 'err', text: 'Save failed ', badge: '✕' };
654
656
  // Not an error: the user's selection is fine, the model simply moved under them.
655
657
  case 'conflict': return { cls: 'conflict', text: 'Save conflict', badge: null };
@@ -914,6 +914,10 @@ const APP_ID = new URLSearchParams(location.search).get('app') || '';
914
914
  const PROJECT = new URLSearchParams(location.search).get('project') || '';
915
915
  let revisionRequest = new URLSearchParams(location.search).get('revisionRequest') || '';
916
916
  let revisionFilterSavedEtag = new URLSearchParams(location.search).get('revisionFilterSavedEtag') || '';
917
+ // #2521 row 2c: the saved checkpoint is the AI's choice in a Quick model build, not the person's Save. Then Save stays
918
+ // pressable (with nothing changed) so the person can save it as theirs, and the chip says whose save it is.
919
+ let revisionFilterChosenByAi = !!revisionFilterSavedEtag && new URLSearchParams(location.search).get('revisionFilterChosenBy') === 'ai';
920
+ const checkpointSavedState = () => (revisionFilterChosenByAi ? 'ai-saved' : 'saved');
917
921
  // Monotonic ownership for async Save results. Saved evidence may advance many times for one request;
918
922
  // only an actual A→B/A→empty identity transition increments this generation.
919
923
  let revisionCheckpointGeneration = 0;
@@ -1610,7 +1614,12 @@ function syncRequiredSaveCue(){
1610
1614
  // The checkpoint always explains the next action, but only a non-empty selection can be saved.
1611
1615
  // A valid prepared filter may already be ready; otherwise the first facet edit re-evaluates it.
1612
1616
  if(checkpoint) saveBtn.disabled = !ready;
1613
- else saveBtn.disabled = !dirty && !conflicted;
1617
+ else {
1618
+ // #2521 row 2c: the AI's saved choice can be saved as the person's own, unchanged; nothing else saved can.
1619
+ const aiChoice = checkpointCurrent && revisionFilterChosenByAi && !conflicted;
1620
+ saveBtn.disabled = !dirty && !conflicted && !aiChoice;
1621
+ if(aiChoice) saveBtn.setAttribute('data-tip', 'The AI chose this Drawing Filter for the Quick model. Press Save filter to save it as yours; you are shown what it leaves out first.');
1622
+ }
1614
1623
  }
1615
1624
 
1616
1625
  // A checkpoint Save is two writes: first the exact Filter, then the request's "filter saved" receipt.
@@ -1642,15 +1651,33 @@ function setFilterEditingLocked(locked){
1642
1651
 
1643
1652
  // Same-origin parent bridge: polling may complete, fail, or clear a checkpoint while this editor has
1644
1653
  // unsaved facet changes. Update only the checkpoint state and URL; never reload the document away.
1654
+ /** Keep the reloadable URL saying whose save the checkpoint is, so a reload shows the same chip and Save state. */
1655
+ function syncChosenByParam(){
1656
+ const url = new URL(location.href);
1657
+ if(revisionFilterChosenByAi) url.searchParams.set('revisionFilterChosenBy', 'ai');
1658
+ else url.searchParams.delete('revisionFilterChosenBy');
1659
+ history.replaceState(null, '', url.pathname + url.search);
1660
+ }
1645
1661
  window.__floRevisionCheckpoint = {
1646
- setRequest(value, savedEtag){
1662
+ setRequest(value, savedEtag, chosenBy){
1647
1663
  const nextRequest = String(value || '');
1648
1664
  const nextSavedEtag = nextRequest ? String(savedEtag || '') : '';
1649
1665
  const requestChanged = nextRequest !== revisionRequest;
1650
1666
  const evidenceChanged = nextSavedEtag !== revisionFilterSavedEtag;
1667
+ // #2521 row 2c: whose save the checkpoint is. Only ever the AI's on a saved checkpoint.
1668
+ const nextChosenByAi = !!nextSavedEtag && chosenBy === 'ai';
1651
1669
  // The 3-second poll ordinarily repeats the same projection. It must be a true no-op: retiring
1652
1670
  // focus, repainting the live status, or re-running cue state on every identical tick is churn.
1653
- if(!requestChanged && !evidenceChanged) return true;
1671
+ if(!requestChanged && !evidenceChanged){
1672
+ // The same checkpoint changing hands (never expected, but the server's word wins) is a label, not new evidence.
1673
+ if(nextChosenByAi !== revisionFilterChosenByAi && !saveInFlight){
1674
+ revisionFilterChosenByAi = nextChosenByAi;
1675
+ syncChosenByParam();
1676
+ if(!dirty && revisionRequest && revisionFilterSavedEtag === serverEtag) setSaved(checkpointSavedState());
1677
+ syncRequiredSaveCue();
1678
+ }
1679
+ return true;
1680
+ }
1654
1681
  // The contract PUT intentionally invalidates the old receipt before `/filter-saved` can publish
1655
1682
  // the replacement. A poll can observe that E1→empty window while this exact Save owns the editor.
1656
1683
  // Defer only same-request evidence changes: request replacement/settlement must still supersede the
@@ -1679,13 +1706,16 @@ window.__floRevisionCheckpoint = {
1679
1706
  }
1680
1707
  revisionRequest = nextRequest;
1681
1708
  revisionFilterSavedEtag = nextSavedEtag;
1709
+ revisionFilterChosenByAi = nextChosenByAi;
1682
1710
  const url = new URL(location.href);
1683
1711
  if(revisionRequest) url.searchParams.set('revisionRequest', revisionRequest);
1684
1712
  else url.searchParams.delete('revisionRequest');
1685
1713
  if(revisionFilterSavedEtag) url.searchParams.set('revisionFilterSavedEtag', revisionFilterSavedEtag);
1686
1714
  else url.searchParams.delete('revisionFilterSavedEtag');
1715
+ if(revisionFilterChosenByAi) url.searchParams.set('revisionFilterChosenBy', 'ai');
1716
+ else url.searchParams.delete('revisionFilterChosenBy');
1687
1717
  history.replaceState(null, '', url.pathname + url.search);
1688
- if(!dirty) setSaved(revisionRequest && revisionFilterSavedEtag === serverEtag ? 'saved' : '');
1718
+ if(!dirty) setSaved(revisionRequest && revisionFilterSavedEtag === serverEtag ? checkpointSavedState() : '');
1689
1719
  syncRequiredSaveCue();
1690
1720
  // The size notice belongs to the checkpoint it was checked against (#1780): a new request voids
1691
1721
  // any answer in flight and anything on screen, and asks again for the new one.
@@ -2043,7 +2073,7 @@ function initFromFilter(){
2043
2073
  buildFacet('colors', F.colors || [], it => it.hex);
2044
2074
  buildSheetSwitcher();
2045
2075
  setSheet(active);
2046
- if(revisionRequest && revisionFilterSavedEtag && revisionFilterSavedEtag === serverEtag) setSaved('saved');
2076
+ if(revisionRequest && revisionFilterSavedEtag && revisionFilterSavedEtag === serverEtag) setSaved(checkpointSavedState());
2047
2077
  syncRequiredSaveCue();
2048
2078
  }
2049
2079
 
@@ -4571,10 +4601,13 @@ async function saveNow(){
4571
4601
  }
4572
4602
  if(revisionRequest === checkpointRequest){
4573
4603
  revisionFilterSavedEtag = serverEtag;
4604
+ // #2521 row 2c: the person's own Save: whatever the AI chose before is now theirs.
4605
+ revisionFilterChosenByAi = false;
4574
4606
  completedCheckpoint = true;
4575
4607
  const url = new URL(location.href);
4576
4608
  url.searchParams.set('revisionRequest', revisionRequest);
4577
4609
  url.searchParams.set('revisionFilterSavedEtag', revisionFilterSavedEtag);
4610
+ url.searchParams.delete('revisionFilterChosenBy');
4578
4611
  history.replaceState(null, '', url.pathname + url.search);
4579
4612
  }
4580
4613
  }
@@ -53,7 +53,9 @@ const elevMm = (mm) => ({ known: Math.round(Number(mm) * 1e9) / 1e9 });
53
53
  * gesture as "correct this value", which is what a detailer actually does.
54
54
  */
55
55
  const carryAssumed = (prev, next) => (prev && prev.assumed === true
56
- ? { ...next, assumed: true, why: prev.why, checked: prev.checked }
56
+ // #2873: the read's provisional estimate rides along as the record of what was estimated. Once a move
57
+ // changes the height it is history, and the server's note then says "the estimate was …", never "this is it".
58
+ ? { ...next, assumed: true, why: prev.why, checked: prev.checked, ...(prev.estimate && typeof prev.estimate === 'object' ? { estimate: prev.estimate } : {}) }
57
59
  // A height the PERSON answered on a question card (#1882) rides along only while it is still the height
58
60
  // they gave: a move that keeps the height keeps the provenance; any change of height drops it, because
59
61
  // the new number is no longer what they answered (and a typed elevation is their own statement anyway).
@@ -1,6 +1,20 @@
1
1
  /*
2
2
  * One pure profile-colour identity seam for the browser editor and the server scene bake.
3
3
  * Keep policy here: consumers choose neither a different canonicalizer nor a different alias winner.
4
+ *
5
+ * SPELLINGS (#2877). One catalogue section can be written several ways (`UC305X97`, `UC305*305*97`,
6
+ * `305X305X97 UC`), and `canonicalProfile` only folds case, the multiplication sign and spaces, so it
7
+ * cannot tell that those name the same steel. The catalogue can. Each consumer hands this module a
8
+ * `spellingsOf(profile)` built from its own catalogue with `catalogueSpellings`, and a colour keyed
9
+ * under ANY spelling of a section is that section's colour. Without that the editor wrote `UC305X97`
10
+ * while the bake looked up `UC305*305*97`, so a UK model drew every member in the palette's last
11
+ * colour in 3D while 2D showed the chosen one.
12
+ *
13
+ * Determinism: the candidate order for a section depends only on the MODEL, never on which member is
14
+ * asking, so 2D (per member) and 3D (per group) always pick the same key. The order is the spellings
15
+ * the model's members actually carry (sorted), then the asking profile, then the catalogue spellings
16
+ * in catalogue order (`sectionSpellings`). The editor writes a colour under the member's own spelling
17
+ * and removes every key under that same list, so after one edit no other key the lookup reads remains.
4
18
  */
5
19
 
6
20
  export const canonicalProfile = (value) => String(value == null ? '' : value)
@@ -8,47 +22,133 @@ export const canonicalProfile = (value) => String(value == null ? '' : value)
8
22
 
9
23
  const warnedCollisions = new Set();
10
24
 
11
- /** Exact canonical key first; otherwise the lexicographically first equivalent raw key. */
12
- export function resolveProfileColour(profile, overrides, warn) {
13
- const canonical = canonicalProfile(profile);
25
+ /**
26
+ * Every spelling of one catalogue row that resolves BACK to that row: `[designation, ...aliases]`
27
+ * minus any alias that is another row's own name. The US catalogue carries such aliases (`RE#3`
28
+ * lists `RE#10`, which is also a primary), and treating them as the same steel would leak one
29
+ * section's colour onto another and delete it on edit. `resolve(spelling)` is the caller's own
30
+ * catalogue lookup, so the browser and the server each answer from the catalogue they hold.
31
+ */
32
+ export function catalogueSpellings(row, resolve) {
33
+ if (!row || !row.designation) return [];
34
+ const own = String(row.designation);
35
+ return [own, ...(Array.isArray(row.aliases) ? row.aliases : [])]
36
+ .filter((spelling) => spelling === own || resolve(spelling)?.designation === own);
37
+ }
38
+
39
+ /** The canonical identities to try, in order: the profile itself, then the given spellings. */
40
+ export function profileColourCandidates(profile, spellings) {
41
+ const out = [];
42
+ for (const value of [profile, ...(Array.isArray(spellings) ? spellings : [])]) {
43
+ const canonical = canonicalProfile(value);
44
+ if (canonical && !out.includes(canonical)) out.push(canonical);
45
+ }
46
+ return out;
47
+ }
48
+
49
+ /**
50
+ * The first candidate (see `profileColourCandidates`) that has a key wins. Within that candidate the
51
+ * exact canonical key wins, otherwise the lexicographically first equivalent raw key.
52
+ */
53
+ export function resolveProfileColour(profile, overrides, warn, spellings) {
54
+ const candidates = profileColourCandidates(profile, spellings);
14
55
  const map = overrides && typeof overrides === 'object' ? overrides : {};
15
- const aliases = Object.keys(map).filter((key) => canonicalProfile(key) === canonical).sort();
56
+ const aliases = Object.keys(map).filter((key) => candidates.includes(canonicalProfile(key))).sort();
16
57
  if (!aliases.length) return { value: null, winnerKey: null, aliases: [], collision: false };
17
- const winnerKey = Object.prototype.hasOwnProperty.call(map, canonical) ? canonical : aliases[0];
58
+ let winnerKey = aliases[0];
59
+ for (const candidate of candidates) {
60
+ const matches = aliases.filter((key) => canonicalProfile(key) === candidate);
61
+ if (!matches.length) continue;
62
+ winnerKey = Object.prototype.hasOwnProperty.call(map, candidate) ? candidate : matches[0];
63
+ break;
64
+ }
18
65
  const collision = new Set(aliases.map((key) => map[key])).size > 1;
19
- if (collision && typeof warn === 'function' && !warnedCollisions.has(canonical)) {
20
- warnedCollisions.add(canonical);
21
- warn(`Profile colour aliases collide for ${canonical}: ${aliases.join(', ')}. Using ${winnerKey}.`);
66
+ const label = candidates[0];
67
+ if (collision && typeof warn === 'function' && !warnedCollisions.has(label)) {
68
+ warnedCollisions.add(label);
69
+ warn(`Profile colour aliases collide for ${label}: ${aliases.join(', ')}. Using ${winnerKey}.`);
22
70
  }
23
71
  return { value: map[winnerKey], winnerKey, aliases, collision };
24
72
  }
25
73
 
26
- /** Mutates the persisted map into its canonical write shape: one key per profile identity. */
27
- export function setCanonicalProfileColour(overrides, profile, colour) {
74
+ /**
75
+ * Mutates the persisted map into its canonical write shape: one key per section. Keys under any other
76
+ * spelling of the same section (`spellings`: pass `sectionSpellings(context, profile)`, every spelling
77
+ * a lookup reads) go too, so a colour stored twice collapses to the key the editor writes instead of
78
+ * leaving a stale twin that a lookup would still prefer.
79
+ */
80
+ export function setCanonicalProfileColour(overrides, profile, colour, spellings) {
28
81
  const canonical = canonicalProfile(profile);
29
82
  if (!canonical || !overrides || typeof overrides !== 'object') return canonical;
30
- for (const key of Object.keys(overrides)) if (canonicalProfile(key) === canonical) delete overrides[key];
83
+ const candidates = profileColourCandidates(canonical, spellings);
84
+ for (const key of Object.keys(overrides)) if (candidates.includes(canonicalProfile(key))) delete overrides[key];
31
85
  overrides[canonical] = colour;
32
86
  return canonical;
33
87
  }
34
88
 
35
- /** Native v2 owns one root member array; only the explicit legacy branch reads plan-local members. */
36
- export function profileColourRank(model, weights) {
37
- const members = model?.type === 'steel.model/v2'
38
- ? (Array.isArray(model.members) ? model.members : [])
39
- : (Array.isArray(model?.plans) ? model.plans.flatMap((plan) => Array.isArray(plan?.members) ? plan.members : []) : []);
40
- return [...new Set([
41
- ...members.map((member) => canonicalProfile(member?.profile)).filter(Boolean),
42
- ...Object.keys(weights && typeof weights === 'object' ? weights : {}).map(canonicalProfile).filter(Boolean),
43
- ])].sort();
89
+ const modelMembers = (model) => (model?.type === 'steel.model/v2'
90
+ ? (Array.isArray(model.members) ? model.members : [])
91
+ : (Array.isArray(model?.plans) ? model.plans.flatMap((plan) => Array.isArray(plan?.members) ? plan.members : []) : []));
92
+
93
+ const spellingsFn = (spellingsOf) => (typeof spellingsOf === 'function'
94
+ ? (profile) => { const out = spellingsOf(profile); return Array.isArray(out) ? out : []; }
95
+ : () => []);
96
+
97
+ /** A section's identity: its catalogue designation when the catalogue knows it, else its own spelling. */
98
+ const sectionIdentity = (profile, spell) => canonicalProfile(spell(profile)[0] ?? profile) || canonicalProfile(profile);
99
+
100
+ /**
101
+ * The palette rank: the sorted unique set of every member's section and the weight-table keys. Native
102
+ * v2 owns one root member array; only the explicit legacy branch reads plan-local members. With
103
+ * `spellingsOf` the rank holds one entry per SECTION, so two spellings of one section share a slot.
104
+ */
105
+ export function profileColourRank(model, weights, spellingsOf) {
106
+ const spell = spellingsFn(spellingsOf);
107
+ const profiles = [
108
+ ...modelMembers(model).map((member) => member?.profile),
109
+ ...Object.keys(weights && typeof weights === 'object' ? weights : {}),
110
+ ].filter((profile) => canonicalProfile(profile));
111
+ return [...new Set(profiles.map((profile) => sectionIdentity(profile, spell)))].sort();
112
+ }
113
+
114
+ /**
115
+ * Everything a colour lookup needs from one model, built once per render (editor) or per bake
116
+ * (server): the palette rank and, per section, the spellings its members carry.
117
+ */
118
+ export function profileColourContext(model, weights, spellingsOf) {
119
+ const spell = spellingsFn(spellingsOf);
120
+ const used = new Map();
121
+ for (const member of modelMembers(model)) {
122
+ const own = canonicalProfile(member?.profile);
123
+ if (!own) continue;
124
+ const id = sectionIdentity(member.profile, spell);
125
+ if (!used.has(id)) used.set(id, new Set());
126
+ used.get(id).add(own);
127
+ }
128
+ return { rank: profileColourRank(model, weights, spellingsOf), spell, used };
44
129
  }
45
130
 
46
- export function profileColour(profile, overrides, rank, palette, warn) {
47
- const canonical = canonicalProfile(profile);
48
- const resolved = resolveProfileColour(canonical, overrides, warn);
131
+ /**
132
+ * Every spelling a lookup for `profile` reads, in priority order: the spellings the model's members
133
+ * carry for that section (sorted), the profile itself, then its catalogue spellings. A member spelling
134
+ * the catalogue resolves but does not list (the takeoff's spaced mixed fraction `HSS3 1/2X3 1/2X1/4`)
135
+ * is read here, so an edit must remove it too: `setCanonicalProfileColour` takes this same list.
136
+ */
137
+ export function sectionSpellings(context, profile) {
138
+ const spell = typeof context?.spell === 'function' ? context.spell : () => [];
139
+ const id = sectionIdentity(profile, spell);
140
+ return [...[...(context?.used?.get(id) ?? [])].sort(), profile, ...spell(profile)];
141
+ }
142
+
143
+ /** An override under any spelling first, else the section's palette slot (the last colour if unranked). */
144
+ export function profileColour(profile, overrides, context, palette, warn) {
145
+ const spell = typeof context?.spell === 'function' ? context.spell : () => [];
146
+ const id = sectionIdentity(profile, spell);
147
+ const ordered = sectionSpellings(context, profile);
148
+ const resolved = resolveProfileColour(ordered[0], overrides, warn, ordered.slice(1));
49
149
  if (resolved.value) return resolved.value;
50
150
  const colours = Array.isArray(palette) && palette.length ? palette : [];
51
151
  if (!colours.length) return null;
52
- const index = rank.indexOf(canonical);
152
+ const index = Array.isArray(context?.rank) ? context.rank.indexOf(id) : -1;
53
153
  return colours[((index % colours.length) + colours.length) % colours.length];
54
154
  }