@floless/app 0.168.0 → 0.170.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 (80) hide show
  1. package/cli-actions.mjs +8 -1
  2. package/dist/floless-server.cjs +125533 -99597
  3. package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
  4. package/dist/schemas/steel.model.v2.schema.json +2 -1
  5. package/dist/skills/floless-app-knowledge/SKILL.md +43 -13
  6. package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
  7. package/dist/skills/floless-app-rfi/SKILL.md +4 -2
  8. package/dist/skills/floless-app-routines/SKILL.md +2 -2
  9. package/dist/skills/floless-app-routines/references/routines-api.md +20 -8
  10. package/dist/skills/floless-app-steel-model/SKILL.md +8 -5
  11. package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
  12. package/dist/skills/floless-app-workflows/SKILL.md +22 -3
  13. package/dist/skills/floless-app-workflows/references/agent-steps.md +40 -6
  14. package/dist/skills/floless-app-workflows/references/exec-contract.md +27 -0
  15. package/dist/skills/floless-app-workflows/references/script-runner.md +105 -0
  16. package/dist/templates/college-phase-exporter.flo +7 -2
  17. package/dist/templates/trimble-list-projects.flo +10 -2
  18. package/dist/web/agent-steps.js +90 -19
  19. package/dist/web/agents.js +77 -31
  20. package/dist/web/app.css +267 -4
  21. package/dist/web/app.js +71 -7
  22. package/dist/web/aware-update-client.js +4 -4
  23. package/dist/web/aware.js +1277 -219
  24. package/dist/web/chat.css +10 -0
  25. package/dist/web/chat.js +407 -117
  26. package/dist/web/checkpoint-standard.js +5 -3
  27. package/dist/web/commands-drawing-check.js +4 -0
  28. package/dist/web/commands-shell.js +551 -15
  29. package/dist/web/commands-steel.js +68 -2
  30. package/dist/web/commands-vector.js +69 -0
  31. package/dist/web/drawing-check-editor.html +10 -0
  32. package/dist/web/drawing-check-editor.js +821 -237
  33. package/dist/web/failure-copy.js +50 -2
  34. package/dist/web/filter-ai-proposal.js +11 -8
  35. package/dist/web/flo-3d.js +310 -0
  36. package/dist/web/flo-card.js +72 -0
  37. package/dist/web/guide.js +33 -24
  38. package/dist/web/index.html +95 -5
  39. package/dist/web/instructor.js +102 -15
  40. package/dist/web/left-pane.js +4 -1
  41. package/dist/web/local-discovery.js +8 -7
  42. package/dist/web/missed-routines.js +239 -0
  43. package/dist/web/model-editor-steel-adapter.js +41 -1
  44. package/dist/web/model-measure.js +6 -0
  45. package/dist/web/model-spatial-panel.js +19 -4
  46. package/dist/web/model-spatial-tools.js +3 -3
  47. package/dist/web/model-viewport-revit-adapter.js +3 -3
  48. package/dist/web/model-viewport-toolbar.js +11 -0
  49. package/dist/web/origin-rule.js +155 -0
  50. package/dist/web/pages.js +17 -14
  51. package/dist/web/panels.js +1 -1
  52. package/dist/web/project-access.js +1 -1
  53. package/dist/web/project-history.js +2 -2
  54. package/dist/web/project-modules.js +5 -5
  55. package/dist/web/project-reconciliation.js +1 -1
  56. package/dist/web/project-rfis.js +8 -3
  57. package/dist/web/project-workflows.js +8 -6
  58. package/dist/web/renderers.js +6 -0
  59. package/dist/web/report-csp.js +68 -0
  60. package/dist/web/revit-editor.js +22 -8
  61. package/dist/web/run-history.js +14 -4
  62. package/dist/web/steel-3d-core.js +39 -9
  63. package/dist/web/steel-3d-flo.js +331 -0
  64. package/dist/web/steel-3d-view.js +164 -0
  65. package/dist/web/steel-ai-marks.js +3 -1
  66. package/dist/web/steel-editor.html +583 -129
  67. package/dist/web/steel-environments.js +297 -0
  68. package/dist/web/steel-filter.html +3 -2
  69. package/dist/web/steel-model-v2-client-validation.js +8 -1
  70. package/dist/web/steel-model-v2-commands.js +23 -9
  71. package/dist/web/steel-model-v2-projection.js +1 -1
  72. package/dist/web/step-rename.js +3 -2
  73. package/dist/web/terminal-requests.js +79 -1
  74. package/dist/web/tool-updates.js +9 -7
  75. package/dist/web/vector-3d.html +1 -1
  76. package/dist/web/vector-editor.html +50 -8
  77. package/dist/web/workspace-root-management.js +1 -1
  78. package/dist/web/workspaces.js +2334 -253
  79. package/launch.mjs +5 -0
  80. package/package.json +11 -8
@@ -0,0 +1,155 @@
1
+ /**
2
+ * origin-rule — the model origin's default, worked out by FloLess from the model itself (#2909).
3
+ *
4
+ * Owner rulings: Pawel 2026-10-29 (*"for the model origin, as a general rule, we can use on the plan view bottom left
5
+ * corner, so first intersection of grid lines, at the bottom left"*) and 2026-11-08 (the four recommendations of
6
+ * `docs/superpowers/specs/2026-11-08-quick-model-origin-2909-PLAN.md`, Revision 2 V1).
7
+ *
8
+ * THE RULE. The default is where the model grid's FIRST X line and FIRST Y line cross (the lowest world offset in each
9
+ * direction), counting only a crossing both lines actually reach (`grid.ends`). When those two do not meet, it is the
10
+ * first crossing in world order that both lines reach: the lowest Y line, then the lowest X line along it.
11
+ *
12
+ * WHY THE MODEL GRID, NOT EACH DRAWING VIEW. A plan row records no list of the grid lines it shows, so "this view's
13
+ * bottom-left" would claim something FloLess cannot see (Codex plan review round 2, finding 1). The model grid's corner
14
+ * is exact. It is called the bottom-left AS DRAWN only when every registered plan view draws world +X to the right and
15
+ * world +Y up the sheet: a plan's registration is a similarity (scale and rotation, never a mirror), so that is its
16
+ * rotation within `UPRIGHT_TOLERANCE_DEG`. A view that fails, or no straight grid, gives no default and a reason;
17
+ * nothing here blocks anything. Whoever chooses (the AI in a Quick read, the person on the card) still chooses, and a
18
+ * departure from the default is labelled, never refused (owner ruling 2026-11-08).
19
+ *
20
+ * Pure and shared: the server's audit and the steel editor's AI note both call it, on the same grid and registration
21
+ * readers the editor draws with, so the default the person reads can never disagree with the one the audit used.
22
+ */
23
+ import { axisLabelsFor, gridGeometry, parseSpacings } from './grid-core.js';
24
+ import { PlanTransformError, planTransform } from './steel-plan-transform.js';
25
+
26
+ /** A plan view counts as upright when its registration rotates the grid by at most this much. */
27
+ export const UPRIGHT_TOLERANCE_DEG = 10;
28
+ /** A crossing counts as reached when it sits within this of a line's drawn end (world mm). */
29
+ export const REACH_TOLERANCE_MM = 0.5;
30
+
31
+ const isRecord = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
32
+
33
+ /** The model grid's straight lines of one direction, in world order, each with its drawn extent; or a reason. */
34
+ function linesOf(grid, dir) {
35
+ const spacing = parseSpacings(grid[dir]);
36
+ const up = dir.toUpperCase();
37
+ if (spacing.err) return `the grid's ${up} spacing cannot be read`;
38
+ const rows = (Array.isArray(grid.axes) ? grid.axes : []).filter((a) => isRecord(a) && a.dir === dir);
39
+ if (rows.length !== spacing.offsets.length) return `the grid's ${up} lines and spacings do not match`;
40
+ if (rows.some((a) => typeof a.id !== 'string' || !a.id)) return `a grid ${up} line has no id`;
41
+ // Native grid: world mm, Y up, identity scale; `ends` keyed by axis id (grid-core's own reader).
42
+ const geo = gridGeometry(grid, 1, { yUp: true });
43
+ const drawn = dir === 'x' ? geo.v.map((l) => ({ at: l.x, lo: l.lo, hi: l.hi })) : geo.h.map((l) => ({ at: l.y, lo: l.lo, hi: l.hi }));
44
+ const labels = axisLabelsFor(grid, dir, dir === 'x' ? 'num' : 'alpha', rows.length);
45
+ return rows.map((a, i) => ({ id: a.id, label: String(labels[i] ?? ''), ...drawn[i] })).sort((a, b) => a.at - b.at);
46
+ }
47
+
48
+ const reaches = (line, at) => at >= line.lo - REACH_TOLERANCE_MM && at <= line.hi + REACH_TOLERANCE_MM;
49
+
50
+ /** The rotation (degrees, -180..180] a registered plan view draws the model grid at, or null when it is not registered. */
51
+ function viewRotationDeg(plan, grid) {
52
+ let t;
53
+ try {
54
+ t = planTransform({ ...plan, modelGrid: grid });
55
+ } catch (err) {
56
+ if (err instanceof PlanTransformError) return null;
57
+ throw err;
58
+ }
59
+ let deg = (t.rotation * 180) / Math.PI;
60
+ while (deg > 180) deg -= 360;
61
+ while (deg <= -180) deg += 360;
62
+ return deg;
63
+ }
64
+
65
+ /**
66
+ * The model grid's bottom-left corner, without the "as drawn" condition: the first crossing in world order that both
67
+ * lines reach. `corner` says whether it is the first X and first Y line themselves.
68
+ * @returns {{ ok: true, corner: boolean, choice: { xAxisId: string, yAxisId: string, xLabel: string, yLabel: string } } | { ok: false, reason: string }}
69
+ */
70
+ export function modelGridCorner(grid) {
71
+ if (!isRecord(grid)) return { ok: false, reason: 'the model has no grid' };
72
+ const xs = linesOf(grid, 'x'); if (typeof xs === 'string') return { ok: false, reason: xs };
73
+ const ys = linesOf(grid, 'y'); if (typeof ys === 'string') return { ok: false, reason: ys };
74
+ if (!xs.length || !ys.length) return { ok: false, reason: `the grid has no straight ${!xs.length ? 'X' : 'Y'} lines` };
75
+ for (const y of ys) {
76
+ for (const x of xs) {
77
+ // An X line runs along world Y (its extent is in Y); a Y line runs along world X.
78
+ if (reaches(x, y.at) && reaches(y, x.at)) {
79
+ return { ok: true, corner: x === xs[0] && y === ys[0], choice: { xAxisId: x.id, yAxisId: y.id, xLabel: x.label, yLabel: y.label } };
80
+ }
81
+ }
82
+ }
83
+ return { ok: false, reason: 'no two grid lines both reach where they cross' };
84
+ }
85
+
86
+ /**
87
+ * The default for a model: the corner, when every registered plan view draws the grid upright. Plan views not yet
88
+ * registered are not counted (they say nothing about orientation); with none registered there is no default, because
89
+ * "as drawn" cannot be checked.
90
+ * @returns {{ ok: true, corner: boolean, choice: { xAxisId: string, yAxisId: string, xLabel: string, yLabel: string } } | { ok: false, reason: string }}
91
+ */
92
+ export function bottomLeftOrigin(model) {
93
+ if (!isRecord(model)) return { ok: false, reason: 'there is no model' };
94
+ const corner = modelGridCorner(model.grid);
95
+ if (!corner.ok) return corner;
96
+ const plans = (Array.isArray(model.plans) ? model.plans : []).filter((p) => isRecord(p) && p.viewKind === 'plan');
97
+ let registered = 0;
98
+ for (const plan of plans) {
99
+ const deg = viewRotationDeg(plan, model.grid);
100
+ if (deg === null) continue;
101
+ registered += 1;
102
+ if (Math.abs(deg) > UPRIGHT_TOLERANCE_DEG) {
103
+ const name = typeof plan.id === 'string' && plan.id ? plan.id : typeof plan.sheet === 'string' && plan.sheet ? plan.sheet : 'a plan view';
104
+ return { ok: false, reason: `plan view ${name} draws the grid rotated ${Math.round(Math.abs(deg))} degrees, so no corner is the bottom-left as drawn on every plan` };
105
+ }
106
+ }
107
+ if (!registered) return { ok: false, reason: 'no plan view is registered to the grid yet, so FloLess cannot tell which corner is drawn bottom-left' };
108
+ return corner;
109
+ }
110
+
111
+ /**
112
+ * #2909 V4/W1: does a chosen crossing lie where both its grid lines are drawn? `null` when the grid cannot say (no grid,
113
+ * an unreadable one, or ids it does not have); otherwise `{ ok }`, and when a line stops short, the plain sentence the
114
+ * card and the audit say. A crossing past a line's end is still allowed: 0,0 sits where that line would reach if
115
+ * extended. It is said, never refused.
116
+ * @returns {null | { ok: true } | { ok: false, short: string[], sentence: string }}
117
+ */
118
+ export function crossingReach(grid, chosen) {
119
+ if (!isRecord(grid) || !isRecord(chosen)) return null;
120
+ const xs = linesOf(grid, 'x'); const ys = linesOf(grid, 'y');
121
+ if (typeof xs === 'string' || typeof ys === 'string') return null;
122
+ const x = xs.find((l) => l.id === chosen.xAxisId); const y = ys.find((l) => l.id === chosen.yAxisId);
123
+ if (!x || !y) return null;
124
+ const short = [...(reaches(x, y.at) ? [] : [x.label]), ...(reaches(y, x.at) ? [] : [y.label])];
125
+ if (!short.length) return { ok: true };
126
+ const lines = short.length === 1 ? `line ${short[0]} stops` : `lines ${short[0]} and ${short[1]} stop`;
127
+ return { ok: false, short, sentence: `on the model grid ${lines} short of ${x.label}/${y.label}, so 0,0 sits where ${short.length === 1 ? 'it' : 'they'} would reach if extended` };
128
+ }
129
+
130
+ /** Does a chosen origin follow the default? `null` when there is no default. */
131
+ export function followsDefault(rule, chosen) {
132
+ if (!rule || !rule.ok || !isRecord(chosen)) return null;
133
+ return rule.choice.xAxisId === chosen.xAxisId && rule.choice.yAxisId === chosen.yAxisId;
134
+ }
135
+
136
+ /**
137
+ * One plain sentence on how a chosen origin stands against the default, for the person (the editor's AI note) and the
138
+ * read (the audit's pass text). `who` is "The AI" or "You". Never a block, never a claim FloLess did not check.
139
+ */
140
+ export function originRuleSentence(rule, chosen, who = 'The AI') {
141
+ const named = isRecord(chosen) && chosen.xLabel && chosen.yLabel ? `${chosen.xLabel}/${chosen.yLabel}` : 'this origin';
142
+ if (!rule || !rule.ok) return `FloLess could not work out a bottom-left default here: ${rule && rule.reason ? rule.reason : 'the model gives it nothing to work from'}. ${who} chose ${named}.`;
143
+ const def = `${rule.choice.xLabel}/${rule.choice.yLabel}`;
144
+ const kind = rule.corner ? 'the bottom-left grid intersection' : 'the first grid intersection both lines reach at the bottom left';
145
+ return followsDefault(rule, chosen)
146
+ ? `${who} chose ${named}, ${kind}: the default.`
147
+ : `${who} chose ${named}, not the bottom-left default (${def}).`;
148
+ }
149
+
150
+ /** The same verdict as a short follow-on sentence, for a place that has already named the origin and who chose it. */
151
+ export function originRuleNote(rule, chosen) {
152
+ if (!rule || !rule.ok) return `FloLess could not work out a bottom-left default here: ${rule && rule.reason ? rule.reason : 'the model gives it nothing to work from'}.`;
153
+ if (followsDefault(rule, chosen)) return rule.corner ? 'It is the bottom-left grid intersection, the default.' : 'It is the first grid intersection both lines reach at the bottom left, the default.';
154
+ return `It is not the bottom-left default (${rule.choice.xLabel}/${rule.choice.yLabel}).`;
155
+ }
package/dist/web/pages.js CHANGED
@@ -21,10 +21,12 @@
21
21
  if (!res.ok || body.ok === false) {
22
22
  // #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
23
23
  const readOnly = /^(GET|HEAD)$/.test(String(opts.method || 'GET').toUpperCase());
24
- const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err;
24
+ const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err;
25
25
  }
26
26
  return body;
27
27
  });
28
+ // #3097: a change that failed without a sentence for the person may still have gone through, so never "Try again".
29
+ const UNSURE_WRITE = 'FloLess can’t tell whether it went through, so check before trying again.';
28
30
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
29
31
  const toast = (msg, kind) => { if (typeof window.showToast === 'function') window.showToast(msg, kind); };
30
32
  const AI_TIP = 'Made by AI. FloLess doesn’t check its figures or statements — check them before you rely on it or share it.';
@@ -165,7 +167,7 @@
165
167
  if (container.dataset.pagesToken !== token) return;
166
168
  // A failed list is said out loud, on the landing too: an empty-looking section would read as "no Pages".
167
169
  console.warn('Pages list could not be read', err);
168
- container.innerHTML = `${opts.headHtml || ''}<p class="pg-empty">FloLess couldn’t read this list of Pages. ${esc(err?.body?.error || 'Try opening it again in a moment.')}</p>`;
170
+ container.innerHTML = `${opts.headHtml || ''}<p class="pg-empty">FloLess couldn’t read this list of Pages. ${esc(personText(err?.body) || 'Try opening it again in a moment.')}</p>`;
169
171
  return;
170
172
  }
171
173
  if (container.dataset.pagesToken !== token) return;
@@ -355,7 +357,7 @@
355
357
  announceDeleted(home, id);
356
358
  toast('Page deleted.', 'ok');
357
359
  } catch (err) {
358
- toast(`FloLess couldn’t delete it. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
360
+ toast(`FloLess couldn’t delete it. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
359
361
  }
360
362
  refreshLists();
361
363
  }
@@ -386,7 +388,7 @@
386
388
  } else toast('Page deleted.', 'ok');
387
389
  }
388
390
  } catch (err) {
389
- toast(`FloLess couldn’t ${act === 'cancel' ? 'cancel publishing' : 'delete it'}. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
391
+ toast(`FloLess couldn’t ${act === 'cancel' ? 'cancel publishing' : 'delete it'}. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
390
392
  }
391
393
  refreshLists();
392
394
  }
@@ -515,7 +517,7 @@
515
517
  : `Version ${n} isn't in this Page's history any more, so you're now seeing the latest.`;
516
518
  }
517
519
  function failedNote(n, err) {
518
- return `FloLess couldn’t load version ${n}, so you're seeing the latest. ${err?.body?.error || 'The Page could not be read just now.'} Choose the version again from the list to retry.`;
520
+ return `FloLess couldn’t load version ${n}, so you're seeing the latest. ${personText(err?.body) || 'The Page could not be read just now.'} Choose the version again from the list to retry.`;
519
521
  }
520
522
 
521
523
  /** A response replaced the record (a site change, a refresh): keep the person's version selected and its labels —
@@ -629,7 +631,7 @@
629
631
  if (typeof window.flolessWorkspaces?.openPagesHome === 'function' && await window.flolessWorkspaces.openPagesHome(home, id, closeViewer)) return true;
630
632
  return false;
631
633
  }
632
- toast(`FloLess couldn’t open this Page. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
634
+ toast(`FloLess couldn’t open this Page. ${personText(err?.body) || 'Try again in a moment.'}`, 'warn');
633
635
  return false;
634
636
  }
635
637
  // Another Page: a share action still out for the previous one no longer owns the Share button.
@@ -803,7 +805,7 @@
803
805
  let found;
804
806
  try { found = await ensureKnown(Math.max(1, before - 200)); }
805
807
  catch (err) {
806
- toast(`FloLess couldn’t show older versions. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
808
+ toast(`FloLess couldn’t show older versions. ${personText(err?.body) || 'Try again in a moment.'}`, 'warn');
807
809
  if (!$versionPop.hidden) openVersionPicker();
808
810
  return;
809
811
  } finally { view.pagingOlder = false; }
@@ -878,7 +880,7 @@
878
880
  loadFrame();
879
881
  return true;
880
882
  } catch (err) {
881
- toast(`FloLess couldn’t change that. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
883
+ toast(`FloLess couldn’t change that. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
882
884
  return false;
883
885
  }
884
886
  }
@@ -1063,7 +1065,7 @@
1063
1065
  const body = await api(`/api/pages/${encodeURIComponent(view.home)}/${encodeURIComponent(p.id)}`, { method: 'DELETE' });
1064
1066
  revokePending = body?.revokePending === true;
1065
1067
  } catch (err) {
1066
- toast(`FloLess couldn’t delete this Page. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
1068
+ toast(`FloLess couldn’t delete this Page. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
1067
1069
  return;
1068
1070
  }
1069
1071
  announceDeleted(view.home, p.id);
@@ -1235,7 +1237,7 @@
1235
1237
  if (seq !== view.openSeq || shareSeq !== view.shareSeq) return;
1236
1238
  // Said, not swallowed: the Page's own record still shows its link, and the banner says why the rest is missing.
1237
1239
  view.share = { share: view.page?.share ?? null, eligibility: null,
1238
- error: { code: err?.body?.code || 'offline', message: err?.body?.error || 'FloLess couldn’t check this Page’s link just now. Close the Page and open it again to retry.', path: null } };
1240
+ error: { code: err?.body?.code || 'offline', message: personText(err?.body) || 'FloLess couldn’t check this Page’s link just now. Close the Page and open it again to retry.', path: null } };
1239
1241
  }
1240
1242
  paintShareButton();
1241
1243
  // Painted while closed too: the Instructor reaches Revoke, Copy and the rest by opening this menu (data-reveal-by).
@@ -1322,7 +1324,8 @@
1322
1324
  const code = err?.body?.code || 'offline';
1323
1325
  view.shareQuota = err?.body?.quota || null;
1324
1326
  const path = code === 'share-too-large' && (payload?.version ?? latestN()) === latestN() ? view.share?.eligibility?.path || null : null;
1325
- view.share = { ...(view.share || {}), error: { code, message: err?.body?.error || outcomeSentence('offline'), path } };
1327
+ // A server that answered without a sentence for the person is not "offline": say it can't tell (UNSURE_WRITE).
1328
+ view.share = { ...(view.share || {}), error: { code, message: personText(err?.body) || (err?.status ? UNSURE_WRITE : outcomeSentence('offline')), path } };
1326
1329
  return null;
1327
1330
  } finally {
1328
1331
  // Only the newest action owns the busy mark (even after the viewer moved to another Page, so nothing is left busy),
@@ -1473,7 +1476,7 @@
1473
1476
  const path = view.share?.error?.path;
1474
1477
  if (!path) return;
1475
1478
  try { await api('/api/reveal', { method: 'POST', body: JSON.stringify({ path }) }); }
1476
- catch (err) { toast(`FloLess couldn’t show the file. ${err?.body?.error || 'Try again in a moment.'}`, 'warn'); }
1479
+ catch (err) { toast(`FloLess couldn’t show the file. ${personText(err?.body) || 'Try again in a moment.'}`, 'warn'); }
1477
1480
  return;
1478
1481
  }
1479
1482
  if (act === 'dismiss') { view.share = { ...(view.share || {}), error: null }; view.shareBannerDismissed = true; paintBanner(); $frame.focus(); return; }
@@ -1606,7 +1609,7 @@
1606
1609
  if (gen !== sl.gen) return;
1607
1610
  slPaintUsage(null);
1608
1611
  $slNote.hidden = false;
1609
- $slNote.textContent = `FloLess couldn’t list your shared links. ${err?.body?.error || 'Try again in a moment.'}`;
1612
+ $slNote.textContent = `FloLess couldn’t list your shared links. ${personText(err?.body) || 'Try again in a moment.'}`;
1610
1613
  } finally {
1611
1614
  if (gen === sl.gen) {
1612
1615
  sl.loading = false;
@@ -1671,7 +1674,7 @@
1671
1674
  else if (body.outcome === 'revoke-pending') toast('FloLess will revoke the link as soon as it can reach floless.io.', 'warn');
1672
1675
  else toast(outcomeSentence(body.outcome) || 'FloLess couldn’t revoke the link just now. Try again in a moment.', 'warn');
1673
1676
  } catch (err) {
1674
- toast(`FloLess couldn’t revoke the link. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
1677
+ toast(`FloLess couldn’t revoke the link. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
1675
1678
  }
1676
1679
  await slLoad(false);
1677
1680
  // The Pages lists' chips and an open viewer's Share button read the same link: repaint them too.
@@ -24,7 +24,7 @@
24
24
  if (!res.ok || body.ok === false) {
25
25
  // #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
26
26
  const readOnly = /^(GET|HEAD)$/.test(String(requestOptions.method || 'GET').toUpperCase());
27
- const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text);
27
+ const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text);
28
28
  err.body = body;
29
29
  err.status = res.status;
30
30
  throw err;
@@ -487,7 +487,7 @@
487
487
  try {
488
488
  await go();
489
489
  } catch (error) {
490
- toast(error instanceof Error && error.message && !/request failed/.test(error.message) ? error.message : 'FloLess could not open that just now. Try again.', 'warn');
490
+ toast(errorText(error, { action: 'open that', retrySafe: true }), 'warn');
491
491
  }
492
492
  }
493
493
 
@@ -12,7 +12,7 @@
12
12
  return fetch(path).then(async (res) => {
13
13
  const body = await res.json().catch(() => ({}));
14
14
  // #3097: the server's own sentence when it wrote one, else the shared one (this only reads); never "HTTP <status>".
15
- if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
15
+ if (!res.ok || body.ok === false) { const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
16
16
  return body;
17
17
  });
18
18
  };
@@ -345,7 +345,7 @@
345
345
  // Keep what is shown, and say it may be out of date.
346
346
  if (st.loaded && !st.unavailable) { st.stale = true; paint(pane); return; }
347
347
  st.loaded = false;
348
- st.error = typeof err?.body?.error === 'string' && err.body.error ? err.body.error : VARIANTS[st.variant].failed;
348
+ st.error = personText(err?.body) || VARIANTS[st.variant].failed;
349
349
  paint(pane);
350
350
  return;
351
351
  }
@@ -17,15 +17,15 @@
17
17
  const body = await res.json().catch(() => ({}));
18
18
  // #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
19
19
  const readOnly = /^(GET|HEAD)$/.test(String(init?.method || 'GET').toUpperCase());
20
- if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
20
+ if (!res.ok || body.ok === false) { const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
21
21
  return body;
22
22
  });
23
23
  };
24
24
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
25
25
  const toast = (msg, kind, options) => (typeof window.showToast === 'function' ? window.showToast(msg, kind, options) : null);
26
26
  // A sentence the server wrote for the person is shown as written; anything else gets the fixed line.
27
- const said = (error, fallback) => (typeof error?.body?.error === 'string' && error.body.error ? error.body.error
28
- : !error?.status && typeof error?.message === 'string' && /^FloLess /.test(error.message) ? error.message : fallback);
27
+ const said = (error, fallback) => (personText(error?.body)
28
+ || (!error?.status && typeof error?.message === 'string' && /^FloLess /.test(error.message) ? error.message : fallback));
29
29
 
30
30
  /** The module names a person knows, by template id (LINKABLE_APPS on the server). */
31
31
  const MODULE_NAMES = {
@@ -331,7 +331,7 @@
331
331
  if (!project || !linkFrom) return;
332
332
  const general = linkFrom.name || 'the General project';
333
333
  const back = { label: `Back to ${general}`, commandId: 'shell.project-modules-back',
334
- onClick: () => Promise.resolve(ws().openModulesStep?.(linkFrom.projectId)).catch((e) => toast(e?.message || 'FloLess couldn’t open that project. Open it from Workspaces.', 'warn')) };
334
+ onClick: () => Promise.resolve(ws().openModulesStep?.(linkFrom.projectId)).catch((e) => toast(errorText(e, { action: 'open that project', retrySafe: true }), 'warn')) };
335
335
  if (outcome === 'archived-empty' || outcome === 'left-empty') {
336
336
  let removed = false;
337
337
  try {
@@ -399,7 +399,7 @@
399
399
  if (open) {
400
400
  event.preventDefault();
401
401
  Promise.resolve(ws().openLinkedProject?.(open.getAttribute('data-pm-open'))).catch((error) => {
402
- toast(error?.message || 'FloLess couldn’t open that project. Try again, or open it from Workspaces.', 'warn');
402
+ toast(errorText(error, { action: 'open that project', retrySafe: true }), 'warn');
403
403
  void load();
404
404
  });
405
405
  return;
@@ -59,7 +59,7 @@
59
59
  ...(body === undefined ? {} : { method: 'POST', body: JSON.stringify(body) }) });
60
60
  const result = await response.json();
61
61
  if (!response.ok || result.ok === false) {
62
- const message = [result.userMessage, result.message, result.error].find((value) => typeof value === 'string' && value.trim());
62
+ const message = [result.userMessage, result.message, personText(result)].find((value) => typeof value === 'string' && value.trim());
63
63
  throw new Error(message || 'FloLess could not finish this folder review. Check the folder and try again.');
64
64
  }
65
65
  return result;
@@ -21,13 +21,13 @@
21
21
  const body = await res.json().catch(() => ({}));
22
22
  // #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
23
23
  const readOnly = /^(GET|HEAD)$/.test(String(init?.method || 'GET').toUpperCase());
24
- if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
24
+ if (!res.ok || body.ok === false) { const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
25
25
  return body;
26
26
  });
27
27
  };
28
28
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
29
29
  const toast = (msg, kind, options) => (typeof window.showToast === 'function' ? window.showToast(msg, kind, options) : null);
30
- const said = (error, fallback) => (typeof error?.body?.error === 'string' && error.body.error ? error.body.error : fallback);
30
+ const said = (error, fallback) => (personText(error?.body) || fallback);
31
31
  /** A refusal the server wrote (a 4xx with a sentence) — as opposed to an outcome nobody confirmed. */
32
32
  const refused = (error) => !!error?.status && error.status >= 400 && error.status < 500 && typeof error?.body?.error === 'string';
33
33
  const newKey = () => `rfi-${crypto.randomUUID()}`;
@@ -517,7 +517,12 @@
517
517
  if (data.store === 'ok') {
518
518
  const n = data.rfis.length;
519
519
  if (!mine.quietLoad) announce(n === 0 ? 'No RFIs in this project yet' : `${n} RFI${n === 1 ? '' : 's'}`);
520
- } else announce(data.message || 'FloLess couldn’t load this project’s RFIs.');
520
+ } else {
521
+ // #3097: not thrown text: a store state's `message` is one of the fixed sentences rfi-correspondence.ts writes
522
+ // for the person (quarantined, newer, transport).
523
+ const storeSentence = typeof data.message === 'string' ? data.message : '';
524
+ announce(storeSentence || 'FloLess couldn’t load this project’s RFIs.');
525
+ }
521
526
  mine.quietLoad = false;
522
527
  } catch (error) {
523
528
  if (state !== mine || mine.generation !== generation) return;
@@ -14,7 +14,7 @@
14
14
  return fetch(path).then(async (res) => {
15
15
  const body = await res.json().catch(() => ({}));
16
16
  // #3097: the server's own sentence when it wrote one, else the shared one (this only reads); never "HTTP <status>".
17
- if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
17
+ if (!res.ok || body.ok === false) { const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
18
18
  return body;
19
19
  });
20
20
  };
@@ -310,7 +310,7 @@
310
310
  .then(async (res) => {
311
311
  const answer = await res.json().catch(() => ({}));
312
312
  // #3097: a POST, so the shared sentence never tells the person to retry blindly; never "HTTP <status>".
313
- if (!res.ok || answer.ok === false) { const err = new Error(answer.error || failureCopy({ status: res.status, body: answer }, { retrySafe: false }).text); err.status = res.status; err.body = answer; throw err; }
313
+ if (!res.ok || answer.ok === false) { const err = new Error(personText(answer) || failureCopy({ status: res.status, body: answer }, { retrySafe: false }).text); err.status = res.status; err.body = answer; throw err; }
314
314
  return answer;
315
315
  });
316
316
 
@@ -344,9 +344,11 @@
344
344
  const code = error?.body?.code;
345
345
  const unreadable = code === 'source-unreadable';
346
346
  // The server's own sentence when it wrote one (it says what changed); a fixed one only when nothing answered.
347
- const said = typeof error?.body?.error === 'string' && error.body.error ? error.body.error : null;
347
+ const said = personText(error?.body) || null;
348
348
  if (!said) console.error('[project-workflows] a set-apart folder could not be answered', error);
349
- const message = unreadable ? null : said || 'FloLess couldn’t reach the server just now. Look at the list again before trying once more.';
349
+ const message = unreadable ? null : said || (error?.status
350
+ ? 'FloLess couldn’t tell whether that went through. Look at the list again before trying once more.'
351
+ : 'FloLess couldn’t reach the server just now. Look at the list again before trying once more.');
350
352
  if (!ctx.alive()) return;
351
353
  ctx.setRow(id, { unreadable: unreadable || !!ctx.rows()[id]?.unreadable, error: message });
352
354
  ctx.repaint();
@@ -420,10 +422,10 @@
420
422
  mine.view = { ...mine.view, busyNew: true };
421
423
  paint();
422
424
  try {
423
- if (typeof bridge().newWorkflow !== 'function') throw new Error('Use ≡ → New workflow and choose this project as its location.');
425
+ if (typeof bridge().newWorkflow !== 'function') throw Object.assign(new Error('Use ≡ → New workflow and choose this project as its location.'), { forPerson: true });
424
426
  await bridge().newWorkflow({ ownerProjectId: mine.project.id });
425
427
  } catch (error) {
426
- toast(error?.message || 'FloLess couldn’t open New workflow.', 'warn');
428
+ toast(errorText(error, { action: 'open New workflow', retrySafe: true }), 'warn');
427
429
  } finally {
428
430
  if (state === mine) {
429
431
  mine.view = { ...mine.view, busyNew: false };
@@ -27,6 +27,12 @@ window.CONTRACT_RENDERERS = {
27
27
  // Local read-only 3D reconstruction viewer (views-to-scene) — NOT the AWARE exporter chain
28
28
  // (`scene`), which only steel supports; extrusion bodies render floless-side only for now.
29
29
  viewerUrl: (appId) => '/vector-3d.html?app=' + encodeURIComponent(appId),
30
+ // What the shell's close question calls it (#3143) — the same name the leave guard uses.
31
+ name: 'the drawing editor',
32
+ // It autosaves to the server and keeps no copy on this computer, so closing the overlay over a
33
+ // write that is unfinished, failed or refused as a conflict loses those edits: Close asks first.
34
+ // (The steel editor keeps such edits as a local draft, so it does not set this.)
35
+ asksBeforeClose: true,
30
36
  },
31
37
  };
32
38
 
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The report viewer's own content rules (#3130, audit 1 F3).
3
+ *
4
+ * A static report is painted into `#report-frame` through `srcdoc`. That frame has no `allow-scripts`, but nothing else
5
+ * limited what the report could ask for: a picture or stylesheet at any `http:` address — FloLess's own loopback API
6
+ * included, which the frame's `allow-same-origin` makes a same-origin request — a form, a `<base>`. `withReportCsp` puts
7
+ * the policy FloLess already gives a report's browser copy (#2476, `INERT_REPORT_CSP` in server/report-files-inert.ts) at
8
+ * the very top of the report: no script, no form, no `<base>`, nothing from FloLess or any `http:` address, while pictures,
9
+ * styles, fonts and media from `data:` or `https:` keep working as the report was written. A report cannot loosen it — a
10
+ * second policy only narrows.
11
+ *
12
+ * `openDocument` is what ↗ Open shows in a new tab. It used to be the report itself as a blob: URL, and a blob: URL has
13
+ * the ORIGIN OF THE PAGE THAT MADE IT — so the report ran as FloLess, and any script in it (the interactive 3D view runs
14
+ * scripts by design) could call the local API as the app. Now the tab is always a script-free page holding the report in
15
+ * a sandboxed frame with no `allow-same-origin`, so the browser itself keeps the report away from FloLess: the policy
16
+ * cannot stop a `<meta http-equiv="refresh">` navigating an unsandboxed tab, and no parse of the report on FloLess's side
17
+ * can be sure to find one the way the browser does (Codex, PR review), but a sandbox stops it whatever the markup.
18
+ * The cost: printing that tab prints only the frame's one screen (follow-up listed in epic #3137).
19
+ *
20
+ * Loaded as a classic script before aware.js; tested by server/report-csp-ui.test.ts.
21
+ */
22
+ (function (root) {
23
+ 'use strict';
24
+
25
+ var POLICY = "default-src 'none'; img-src data: https:; style-src 'unsafe-inline' https:; font-src data: https:; media-src data: https:; form-action 'none'; base-uri 'none'";
26
+ var META = '<meta http-equiv="Content-Security-Policy" content="' + POLICY + '">';
27
+ // Whether the report asks for standards mode. This only ever chooses the rendering mode, never where the policy goes:
28
+ // the policy is the first thing in the document either way, ahead of anything the report says, so no markup in the
29
+ // report — a comment the browser closes early, a `>` inside a quoted doctype — can put an element before it.
30
+ var LOOKS_LIKE_DOCTYPE = /^\s*(?:<!--[\s\S]*?-->\s*)*<!doctype/i;
31
+
32
+ function withReportCsp(html) {
33
+ var text = String(html == null ? '' : html).replace(/^/, '');
34
+ // With a doctype, ours comes first (the report's own, now later, is ignored by the parser): a policy placed before a
35
+ // doctype would put the report into quirks mode. Without one the report keeps the mode it always had.
36
+ return (LOOKS_LIKE_DOCTYPE.test(text) ? '<!doctype html>' : '') + META + text;
37
+ }
38
+
39
+ function escapeAttr(value) {
40
+ return String(value).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
41
+ }
42
+
43
+ function page(title, frame) {
44
+ return '<!doctype html><html><head><meta charset="utf-8"><title>' + escapeAttr(title) + '</title>'
45
+ + '<style>html,body{margin:0;height:100%}iframe{display:block;border:0;width:100%;height:100%}</style></head><body>'
46
+ + frame + '</body></html>';
47
+ }
48
+
49
+ /** What ↗ Open puts in a new tab: a page with no script and no policy of its own (a frame inherits its parent's, which
50
+ * would stop the 3D view's scripts), holding the report in an opaque-origin frame. A static report goes in like
51
+ * #report-frame, with its policy first, but without `allow-same-origin` — no script, no automatic navigation, links
52
+ * still open in a new tab. The interactive 3D view goes in like #report-frame-3d, as a `data:` frame with only
53
+ * `allow-scripts`: its scripts run, but their requests carry `Origin: null`, which the server's origin guard refuses.
54
+ * `name` (the workflow's) titles the tab. */
55
+ function openDocument(html, interactive, name) {
56
+ var text = String(html == null ? '' : html);
57
+ if (!interactive) {
58
+ return page(name ? 'FloLess report – ' + name : 'FloLess report',
59
+ '<iframe sandbox="allow-popups allow-popups-to-escape-sandbox" title="Report" srcdoc="'
60
+ + escapeAttr(withReportCsp(text)) + '"></iframe>');
61
+ }
62
+ return page(name ? 'FloLess 3D view – ' + name : 'FloLess 3D view',
63
+ '<iframe sandbox="allow-scripts" title="3D view" src="data:text/html;charset=utf-8,'
64
+ + escapeAttr(encodeURIComponent(text)) + '"></iframe>');
65
+ }
66
+
67
+ root.FlolessReportCsp = { POLICY: POLICY, withReportCsp: withReportCsp, openDocument: openDocument };
68
+ })(typeof window !== 'undefined' ? window : globalThis);
@@ -212,6 +212,17 @@ function fail(failure = null) {
212
212
  if (failure) { $('editorRoot').dataset.modelState = 'empty'; renderRevitNoModelState(state, failure); return; }
213
213
  state.replaceChildren(); const strong = document.createElement('strong'); strong.textContent = 'Model unavailable'; const copy = document.createElement('span'); copy.textContent = modelUnavailableCopy(); state.append(strong, copy);
214
214
  }
215
+ /**
216
+ * #3097 3b: what a model route wrote for the person. These routes answer in two shapes: the Revit and editor-state
217
+ * routes send `{ error: <code>, message: <developer text>, userMessage? }` ("editorState.clips must be an object",
218
+ * "Revit import requires an active desktop session"), and the Tekla route sends `{ code, error: <sentence>, userMessage? }`.
219
+ * So `message` is never said, and an `error` is said only when it is a sentence (personText), never a bare code.
220
+ */
221
+ function modelReplyText(value) {
222
+ if (typeof value?.userMessage === 'string' && value.userMessage.trim()) return value.userMessage.trim();
223
+ const said =typeof globalThis.personText === 'function' ? globalThis.personText(value) : '';
224
+ return /\s/.test(said) ? said : '';
225
+ }
215
226
  // Any answer that is not ok rides on the error (`status`, `body`), so a failure can say what the server wrote for a person.
216
227
  // #3097: the message is the server's own sentence when it wrote one, else the shared one (failure-copy.js); never "(<status>)".
217
228
  function sharedFailureText(response, value, ctx, thrown) {
@@ -220,7 +231,7 @@ function sharedFailureText(response, value, ctx, thrown) {
220
231
  if (typeof copy === 'function') return copy(thrown && !thrown.status ? thrown : { status: response.status, body: value }, ctx).text;
221
232
  return `Couldn’t ${ctx?.action || 'finish that'}. Reload this window, then try again.`;
222
233
  }
223
- async function json(url, options) { const response = await fetch(url, { credentials: 'same-origin', ...options }); const value = await response.json().catch(() => ({})); if (!response.ok || value.ok === false) throw Object.assign(new Error(value.message || value.error || sharedFailureText(response, value, { retrySafe: /^(GET|HEAD)$/.test(String(options?.method || 'GET').toUpperCase()) })), { status: response.status, body: value }); return value; }
234
+ async function json(url, options) { const response = await fetch(url, { credentials: 'same-origin', ...options }); const value = await response.json().catch(() => ({})); if (!response.ok || value.ok === false) throw Object.assign(new Error(modelReplyText(value) || sharedFailureText(response, value, { retrySafe: /^(GET|HEAD)$/.test(String(options?.method || 'GET').toUpperCase()) })), { status: response.status, body: value }); return value; }
224
235
 
225
236
  function propertySection(heading, rows) {
226
237
  return { id: heading.toLowerCase().replace(/\W+/g, '-'), heading, editable: false, render(host) {
@@ -1099,7 +1110,7 @@ function renderTeklaAudit() {
1099
1110
  const name = document.createElement('span'); name.textContent = entity?.name || entity?.typeName || finding.entityId;
1100
1111
  const location = document.createElement('span'); location.className = finding.hasGeometry ? 'tekla-audit-location' : 'tekla-audit-location missing'; location.textContent = finding.hasGeometry ? 'Shown in 3D' : 'No 3D location';
1101
1112
  button.dataset.commandId = 'tekla-parser.audit-finding'; button.dataset.commandInstanceLabel = `${copy?.title ?? 'Import finding'}: ${name.textContent}`;
1102
- button.append(heading, name, location); button.addEventListener('click', () => { try { selectAuditFinding(finding); window.__instructor?.notifyChanged(); } catch (error) { toast(error.message); } }); list.append(button);
1113
+ button.append(heading, name, location); button.addEventListener('click', () => { try { selectAuditFinding(finding); window.__instructor?.notifyChanged(); } catch (error) { toast(errorText(error, { action: 'show that import finding', retrySafe: true })); } }); list.append(button);
1103
1114
  }
1104
1115
  };
1105
1116
  for (const [key, label] of filterSpecs) {
@@ -1361,8 +1372,11 @@ function payloadOnly(state) {
1361
1372
  return payload;
1362
1373
  }
1363
1374
 
1364
- // #3097: the editor-state route answers `{ error: <code>, message }`. The message is shown as written; a code that came
1365
- // without one is said in words, and anything else gets the shared sentence. A bare code or a status is never shown.
1375
+ // #3097: the editor-state route answers `{ error: <code>, message }`. 3b: its `message` is a developer's text for most
1376
+ // codes ("editorState.clips must be an object"), so it is said as written only for the codes whose message the route
1377
+ // writes for the person (EDITOR_STATE_PERSON_MESSAGE, reviewed against server/model-editor-state.ts). Any other code
1378
+ // is said in words, and anything else gets the shared sentence. A bare code, a status or a developer message is never shown.
1379
+ const EDITOR_STATE_PERSON_MESSAGE = new Set(['state-access-unconfirmed']);
1366
1380
  const EDITOR_STATE_CODE_WORDS = {
1367
1381
  'state-access-unconfirmed': 'FloLess couldn’t confirm your access to this model.',
1368
1382
  model_module_unavailable: 'This model is open for viewing only here, so its view settings aren’t saved.',
@@ -1371,8 +1385,8 @@ const EDITOR_STATE_CODE_WORDS = {
1371
1385
  'state-pin-unavailable': 'This version of the model is no longer available.',
1372
1386
  };
1373
1387
  function editorStateFailureText(response, value, action, retrySafe) {
1374
- if (typeof value?.message === 'string' && value.message.trim()) return value.message;
1375
- console.warn('[model] editor state request failed', action, response?.status, value?.error);
1388
+ if (EDITOR_STATE_PERSON_MESSAGE.has(value?.error) && typeof value?.message === 'string' && value.message.trim()) return value.message.trim();
1389
+ console.warn('[model] editor state request failed', action, response?.status, value?.error, value?.message);
1376
1390
  const words = EDITOR_STATE_CODE_WORDS[value?.error];
1377
1391
  if (words) return `Couldn’t ${action}. ${words}`;
1378
1392
  return sharedFailureText(response, value, retrySafe ? { action, retrySafe: true } : { action, unsure: 'Change the view again to save it once more.' });
@@ -1505,7 +1519,7 @@ function commitSpatialForRevision(candidate) {
1505
1519
  spatialTools.subscribe((value) => { $('modelFrameStatus').textContent = spatialTools.activeFrame().label; window.__revitInstructorState = { ...(window.__revitInstructorState || {}), activeFrame: value.activeFrameId }; reflectToolbarState(); });
1506
1520
  spatialPanel = mountModelSpatialPanel({ tools: spatialTools, trigger: $('modelFrameStatus'), onBeforeOpen: () => { closeSpatialDialog(); toolbarChrome?.closeMenus(); selectionFilterChrome?.close(); lightingPanel?.close({ restoreFocus: false }); },
1507
1521
  lengthDisplay: { format: (mm) => formatLength(mm, displayUnitControl.units()), parse: (text) => parseLengthMm(text, displayUnitControl.units()), unitLabel: () => displayUnitControl.units() },
1508
- onError: (error) => toast(error.message || 'That spatial action is unavailable.') });
1522
+ onError: (error) => toast(errorText(error, { action: 'use that spatial tool', retrySafe: true })) });
1509
1523
  if (candidate.recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) => reportEditorStateSaveError(error, 'restore this model view')), 0); }
1510
1524
  }
1511
1525
 
@@ -1660,7 +1674,7 @@ function wireToolbar() {
1660
1674
  reflectToolbarState();
1661
1675
  modelPanelBridge?.publishSnapshot();
1662
1676
  window.__instructor?.notifyChanged();
1663
- } catch (error) { toast(error.message || 'That view action is unavailable.'); }
1677
+ } catch (error) { toast(errorText(error, { action: 'change the view', retrySafe: true })); }
1664
1678
  });
1665
1679
  updateSelectionActions();
1666
1680
  reflectToolbarState();