@floless/app 0.170.0 → 0.171.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +33000 -22928
- package/dist/schemas/steel.model.v2.schema.json +194 -3
- package/dist/skills/floless-app-bridge/SKILL.md +3 -3
- package/dist/skills/floless-app-knowledge/SKILL.md +4 -3
- package/dist/skills/floless-app-onboarding/SKILL.md +5 -4
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +0 -3
- package/dist/skills/floless-app-queue/SKILL.md +2 -3
- package/dist/skills/floless-app-report-issue/SKILL.md +2 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +35 -35
- package/dist/skills/floless-app-steel-model/references/custom-connections.md +47 -0
- package/dist/skills/floless-app-steel-model/references/custom-sections.md +32 -0
- package/dist/skills/floless-app-ui/SKILL.md +71 -126
- package/dist/web/add-ons.js +407 -0
- package/dist/web/analytics.js +1 -1
- package/dist/web/app.css +108 -189
- package/dist/web/app.js +11 -12
- package/dist/web/aware.js +49 -29
- package/dist/web/chat.css +6 -1
- package/dist/web/chat.js +133 -18
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +39 -67
- package/dist/web/commands-steel.js +9 -1
- package/dist/web/commands-tekla-parser.js +23 -0
- package/dist/web/connections.js +14 -3
- package/dist/web/failure-copy.js +1 -0
- package/dist/web/guide.js +3 -3
- package/dist/web/index.html +29 -56
- package/dist/web/instructor.js +2 -2
- package/dist/web/kb-categories.js +64 -7
- package/dist/web/model-change-findings.js +430 -0
- package/dist/web/model-change-review.js +414 -0
- package/dist/web/model-editor-steel-adapter.js +2 -2
- package/dist/web/project-history.js +7 -1
- package/dist/web/revit-editor.css +85 -0
- package/dist/web/revit-editor.js +36 -1
- package/dist/web/sha256-sync.js +62 -0
- package/dist/web/steel-3d-core.js +7 -0
- package/dist/web/steel-3d-flo.js +127 -3
- package/dist/web/steel-3d-view.js +25 -2
- package/dist/web/steel-custom-connection.js +161 -0
- package/dist/web/steel-custom-sections.js +1796 -0
- package/dist/web/steel-editor.html +279 -41
- package/dist/web/steel-filter-usage.js +299 -0
- package/dist/web/steel-filter.html +101 -4
- package/dist/web/steel-model-v2-client-validation.js +3 -0
- package/dist/web/steel-model-v2-commands.js +95 -6
- package/dist/web/steel-model-v2-projection.js +1 -1
- package/dist/web/steel-read-confidence.js +1 -56
- package/dist/web/tekla-editor.html +1 -0
- package/dist/web/workspaces.js +263 -28
- package/launch.mjs +87 -9
- package/package.json +1 -1
- package/dist/web/panels.js +0 -831
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/* My add-ons (≡ → My add-ons), add-ons S1b (#3296). The one screen where a person sees, turns on, turns off, goes back
|
|
2
|
+
and removes their own add-ons. It renders what the server says (server/add-on-routes.ts) and composes nothing: the AI
|
|
3
|
+
chat writes add-ons, FloLess stores and checks them, and turning one on is the person's click here or on a chat card.
|
|
4
|
+
"Ask AI to change / fix" only puts a message in the chat box; it never sends. */
|
|
5
|
+
(() => {
|
|
6
|
+
'use strict';
|
|
7
|
+
const modal = document.getElementById('add-ons-modal');
|
|
8
|
+
if (!modal) return;
|
|
9
|
+
const listEl = document.getElementById('add-ons-list');
|
|
10
|
+
const detailEl = document.getElementById('add-ons-detail');
|
|
11
|
+
const statusEl = document.getElementById('add-ons-status');
|
|
12
|
+
const closeBtn = document.getElementById('add-ons-close');
|
|
13
|
+
const importBtn = document.getElementById('add-ons-import');
|
|
14
|
+
const fileInput = document.getElementById('add-ons-file');
|
|
15
|
+
let opener = null;
|
|
16
|
+
let addOns = [];
|
|
17
|
+
let selected = null;
|
|
18
|
+
let current = null;
|
|
19
|
+
let busy = false;
|
|
20
|
+
|
|
21
|
+
const make = (tag, className, text) => {
|
|
22
|
+
const node = document.createElement(tag);
|
|
23
|
+
if (className) node.className = className;
|
|
24
|
+
if (text != null) node.textContent = text;
|
|
25
|
+
return node;
|
|
26
|
+
};
|
|
27
|
+
const button = (label, commandId, opts = {}) => {
|
|
28
|
+
const b = make('button', opts.className || '', label);
|
|
29
|
+
b.type = 'button';
|
|
30
|
+
b.dataset.commandId = commandId;
|
|
31
|
+
if (opts.tip) b.dataset.tip = opts.tip;
|
|
32
|
+
if (opts.onClick) b.addEventListener('click', opts.onClick);
|
|
33
|
+
return b;
|
|
34
|
+
};
|
|
35
|
+
const say = (text, kind = '') => { statusEl.textContent = text || ''; statusEl.dataset.kind = kind; };
|
|
36
|
+
const when = (iso) => { try { return new Date(iso).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' }); } catch { return ''; } };
|
|
37
|
+
|
|
38
|
+
async function call(method, path, body, rev) {
|
|
39
|
+
const headers = {};
|
|
40
|
+
if (body !== undefined) headers['Content-Type'] = 'application/json';
|
|
41
|
+
if (rev !== undefined) headers['If-Match'] = String(rev);
|
|
42
|
+
let res;
|
|
43
|
+
try { res = await fetch(path, { method, headers, ...(body !== undefined ? { body: JSON.stringify(body) } : {}) }); }
|
|
44
|
+
catch { throw Object.assign(new Error('FloLess could not be reached. Check that it is open, then try again.'), { status: 0 }); }
|
|
45
|
+
const data = await res.json().catch(() => ({}));
|
|
46
|
+
if (!res.ok || data.ok === false) throw Object.assign(new Error(data.error || 'FloLess could not do that just now. Try again in a moment.'), { status: res.status, body: data });
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Put a message in the AI chat box for the person to read and send; never sends it. */
|
|
51
|
+
function askAi(text) {
|
|
52
|
+
const chat = window.flolessChat;
|
|
53
|
+
if (chat && typeof chat.fillMessageBox === 'function') {
|
|
54
|
+
close();
|
|
55
|
+
chat.fillMessageBox(text);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
say(`Open AI Chat and ask: “${text}”`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ── list ────────────────────────────────────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
async function refresh(keep = selected) {
|
|
64
|
+
try {
|
|
65
|
+
const data = await call('GET', '/api/add-ons');
|
|
66
|
+
addOns = Array.isArray(data.addOns) ? data.addOns : [];
|
|
67
|
+
} catch (error) { addOns = []; say(error.message, 'warn'); }
|
|
68
|
+
modal.classList.toggle('add-ons-empty', addOns.length === 0);
|
|
69
|
+
paintList();
|
|
70
|
+
if (!addOns.length) { selected = null; current = null; paintEmpty(); return; }
|
|
71
|
+
selected = addOns.some((a) => a.id === keep) ? keep : addOns[0].id;
|
|
72
|
+
paintList();
|
|
73
|
+
await load(selected);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function paintList() {
|
|
77
|
+
listEl.replaceChildren();
|
|
78
|
+
for (const a of addOns) {
|
|
79
|
+
const row = button('', 'shell.add-ons-select', { className: 'add-ons-row' });
|
|
80
|
+
row.setAttribute('aria-current', a.id === selected ? 'true' : 'false');
|
|
81
|
+
row.append(make('span', 'add-ons-row-name', a.name));
|
|
82
|
+
const meta = make('span', 'add-ons-row-meta');
|
|
83
|
+
meta.append(make('span', `add-ons-pill ${a.on ? 'on' : ''}`, a.on ? 'On' : 'Off'));
|
|
84
|
+
if (a.candidateVersion) meta.append(make('span', 'add-ons-pill waiting', 'Waiting for you'));
|
|
85
|
+
else if (a.hasDraft) meta.append(make('span', 'add-ons-pill', 'Draft'));
|
|
86
|
+
row.append(meta);
|
|
87
|
+
row.addEventListener('click', () => { selected = a.id; paintList(); void load(a.id); });
|
|
88
|
+
listEl.append(row);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function paintEmpty() {
|
|
93
|
+
detailEl.replaceChildren();
|
|
94
|
+
const box = make('div', 'add-ons-empty-state');
|
|
95
|
+
box.append(make('h3', '', 'No add-ons yet'));
|
|
96
|
+
box.append(make('p', '', 'An add-on is your own extension, made for you by the AI chat. Right now it can add steel sections of your own, such as a welded I-beam with the sizes you choose. Nothing turns on until you say so.'));
|
|
97
|
+
box.append(button('Ask AI to make one', 'shell.add-ons-ask-make', {
|
|
98
|
+
className: 'primary',
|
|
99
|
+
onClick: () => askAi('Make me an add-on with a custom steel section: '),
|
|
100
|
+
}));
|
|
101
|
+
box.append(make('p', 'add-ons-muted', 'This puts a message in the chat box. You choose whether to send it.'));
|
|
102
|
+
detailEl.append(box);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ── detail ──────────────────────────────────────────────────────────────────────────────────────
|
|
106
|
+
|
|
107
|
+
async function load(id) {
|
|
108
|
+
try {
|
|
109
|
+
const data = await call('GET', `/api/add-ons/${encodeURIComponent(id)}`);
|
|
110
|
+
if (selected !== id) return;
|
|
111
|
+
current = data.addOn;
|
|
112
|
+
paintDetail();
|
|
113
|
+
} catch (error) { detailEl.replaceChildren(make('p', 'add-ons-callout', error.message)); }
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const VERDICT = { works: 'Works with this FloLess', 'works-partly': 'Works partly', off: 'Off here' };
|
|
117
|
+
|
|
118
|
+
function verdictLine(compat) {
|
|
119
|
+
const line = make('div', `add-ons-verdict ${compat.verdict}`);
|
|
120
|
+
line.append(make('span', 'add-ons-dot'), make('span', 'add-ons-verdict-word', VERDICT[compat.verdict] || compat.verdict));
|
|
121
|
+
return line;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The outline of a definition at its example size, drawn to fit its own box. */
|
|
125
|
+
function thumb(def) {
|
|
126
|
+
const tile = make('div', 'add-ons-def');
|
|
127
|
+
const pic = make('div', 'add-ons-def-pic');
|
|
128
|
+
const outline = def.preview?.outline;
|
|
129
|
+
if (Array.isArray(outline) && outline.length >= 3) {
|
|
130
|
+
const xs = outline.map((p) => p[0]); const ys = outline.map((p) => p[1]);
|
|
131
|
+
const minX = Math.min(...xs), maxX = Math.max(...xs), minY = Math.min(...ys), maxY = Math.max(...ys);
|
|
132
|
+
const pad = Math.max(maxX - minX, maxY - minY) * 0.08 || 1;
|
|
133
|
+
const ns = 'http://www.w3.org/2000/svg';
|
|
134
|
+
const svg = document.createElementNS(ns, 'svg');
|
|
135
|
+
svg.setAttribute('viewBox', `${minX - pad} ${-(maxY + pad)} ${maxX - minX + 2 * pad} ${maxY - minY + 2 * pad}`);
|
|
136
|
+
svg.setAttribute('role', 'img');
|
|
137
|
+
svg.setAttribute('aria-label', `Outline of ${def.name}`);
|
|
138
|
+
const poly = document.createElementNS(ns, 'polygon');
|
|
139
|
+
poly.setAttribute('points', outline.map(([x, y]) => `${x},${-y}`).join(' '));
|
|
140
|
+
svg.append(poly);
|
|
141
|
+
pic.append(svg);
|
|
142
|
+
} else {
|
|
143
|
+
pic.classList.add('none');
|
|
144
|
+
pic.textContent = 'No preview';
|
|
145
|
+
}
|
|
146
|
+
tile.append(pic);
|
|
147
|
+
tile.append(make('div', 'add-ons-def-name', def.name));
|
|
148
|
+
tile.append(make('div', 'add-ons-def-id', def.id));
|
|
149
|
+
if (def.works && def.preview) {
|
|
150
|
+
tile.append(make('div', 'add-ons-def-facts', `${def.preview.designation} · ${Math.round(def.preview.area).toLocaleString()} mm² · ${Number(def.preview.kgPerM).toLocaleString(undefined, { maximumFractionDigits: 1 })} kg/m`));
|
|
151
|
+
tile.dataset.tip = `Shown at its example size, in ${def.preview.densityBasis}. The sizes you place can differ.`;
|
|
152
|
+
} else {
|
|
153
|
+
tile.append(make('div', 'add-ons-def-off', def.reasons?.[0] ? `Off: ${def.reasons[0]}` : 'Off here'));
|
|
154
|
+
}
|
|
155
|
+
return tile;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function section(title) {
|
|
159
|
+
const s = make('section', 'add-ons-section');
|
|
160
|
+
s.append(make('h4', '', title));
|
|
161
|
+
return s;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** A button that asks once more before it acts: the first click says what will happen, the second does it. */
|
|
165
|
+
function twoStep(label, confirmLabel, commandId, act, opts = {}) {
|
|
166
|
+
const b = button(label, commandId, opts);
|
|
167
|
+
let armed = null;
|
|
168
|
+
b.addEventListener('click', async () => {
|
|
169
|
+
if (!armed) {
|
|
170
|
+
b.textContent = confirmLabel;
|
|
171
|
+
b.classList.add('armed');
|
|
172
|
+
armed = setTimeout(() => { armed = null; b.textContent = label; b.classList.remove('armed'); }, 4000);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
clearTimeout(armed); armed = null;
|
|
176
|
+
await act();
|
|
177
|
+
});
|
|
178
|
+
return b;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async function act(fn, done) {
|
|
182
|
+
if (busy) return;
|
|
183
|
+
busy = true;
|
|
184
|
+
detailEl.querySelectorAll('button').forEach((b) => { b.disabled = true; });
|
|
185
|
+
try {
|
|
186
|
+
await fn();
|
|
187
|
+
say(done);
|
|
188
|
+
await refresh(selected);
|
|
189
|
+
detailEl.querySelector('h3')?.focus();
|
|
190
|
+
} catch (error) {
|
|
191
|
+
say(error.message, 'warn');
|
|
192
|
+
if (error.status === 409) await refresh(selected);
|
|
193
|
+
} finally {
|
|
194
|
+
busy = false;
|
|
195
|
+
detailEl.querySelectorAll('button').forEach((b) => { b.disabled = false; });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const at = () => new Date().toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });
|
|
199
|
+
|
|
200
|
+
function paintDetail() {
|
|
201
|
+
const a = current;
|
|
202
|
+
detailEl.replaceChildren();
|
|
203
|
+
const id = encodeURIComponent(a.id);
|
|
204
|
+
// Off with nothing waiting: the newest stored version describes it (display only; it is not turned on).
|
|
205
|
+
const shown = a.active || a.candidate || a.newest;
|
|
206
|
+
|
|
207
|
+
// Header: name, on/off, who made it, unreviewed, verdict.
|
|
208
|
+
const head = make('div', 'add-ons-head');
|
|
209
|
+
const h3 = make('h3', '', a.name);
|
|
210
|
+
h3.tabIndex = -1;
|
|
211
|
+
const titleRow = make('div', 'add-ons-title-row');
|
|
212
|
+
titleRow.append(h3, make('span', `add-ons-pill ${a.on ? 'on' : ''}`, a.on ? 'On' : 'Off'));
|
|
213
|
+
head.append(titleRow);
|
|
214
|
+
head.append(make('div', 'add-ons-muted add-ons-ident', `${a.id}${a.author ? ` · by ${a.author}` : ''}${a.active ? ` · version ${a.active.label} is on` : ''}${!a.active && !a.candidate && a.newest ? ` · newest version ${a.newest.label}` : ''}`));
|
|
215
|
+
const chips = make('div', 'add-ons-chips');
|
|
216
|
+
const unrev = make('span', 'add-ons-chip', 'Unreviewed · your own work');
|
|
217
|
+
unrev.dataset.tip = 'FloLess has not checked this add-on. It came from you and the AI chat, so you use it at your own risk.';
|
|
218
|
+
chips.append(unrev);
|
|
219
|
+
if (shown) chips.append(verdictLine(shown.compatibility));
|
|
220
|
+
head.append(chips);
|
|
221
|
+
if (a.on) {
|
|
222
|
+
head.append(button('Turn off', 'shell.add-ons-turn-off', {
|
|
223
|
+
className: 'add-ons-quiet',
|
|
224
|
+
tip: 'Stops offering this add-on. What it made stays in your models.',
|
|
225
|
+
onClick: () => act(() => call('POST', `/api/add-ons/${id}/turn-off`, {}, a.rev), `Turned off ${a.name} · ${at()}`),
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
detailEl.append(head);
|
|
229
|
+
|
|
230
|
+
// Something does not work: say what, and offer the AI's help.
|
|
231
|
+
const troubled = shown && shown.compatibility.verdict !== 'works';
|
|
232
|
+
if (troubled) {
|
|
233
|
+
const warn = make('div', 'add-ons-callout');
|
|
234
|
+
const list = make('ul');
|
|
235
|
+
for (const r of shown.compatibility.reasons.slice(0, 3)) list.append(make('li', '', r));
|
|
236
|
+
warn.append(list);
|
|
237
|
+
warn.append(button('Ask AI to fix', 'shell.add-ons-ask-fix', {
|
|
238
|
+
onClick: () => askAi(`My add-on “${a.name}” (${a.id}) version ${shown.label} does not fully work here: ${shown.compatibility.reasons.join('; ')}. Please fix it as a new draft.`),
|
|
239
|
+
}));
|
|
240
|
+
warn.append(make('span', 'add-ons-muted', 'Puts a message in the chat box. Nothing is sent.'));
|
|
241
|
+
detailEl.append(warn);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// The version waiting for the person: the one primary decision on this screen.
|
|
245
|
+
if (a.candidate) {
|
|
246
|
+
const c = a.candidate;
|
|
247
|
+
const card = make('section', 'add-ons-waiting');
|
|
248
|
+
card.setAttribute('aria-labelledby', 'add-ons-waiting-title');
|
|
249
|
+
const t = make('h4', '', `Version ${c.label} is waiting for you`);
|
|
250
|
+
t.id = 'add-ons-waiting-title';
|
|
251
|
+
card.append(t);
|
|
252
|
+
const changes = make('ul', 'add-ons-changes');
|
|
253
|
+
for (const line of a.compare?.changes || []) changes.append(make('li', '', line));
|
|
254
|
+
card.append(changes);
|
|
255
|
+
const canDo = c.compatibility.definitions.length ? 'It runs no code and cannot reach the internet.' : '';
|
|
256
|
+
card.append(make('p', 'add-ons-muted', `You haven't reviewed this; FloLess has not either. ${canDo}${a.versions.length > 1 ? ' You can go back to another version at any time.' : ''}`.trim()));
|
|
257
|
+
const row = make('div', 'add-ons-actions');
|
|
258
|
+
if (c.bundle === 'ok') {
|
|
259
|
+
row.append(button(`Turn on ${c.label}`, 'shell.add-ons-turn-on', {
|
|
260
|
+
className: 'primary',
|
|
261
|
+
onClick: () => act(() => call('POST', `/api/add-ons/${id}/turn-on`, { version: c.label, digest: c.digest }, a.rev),
|
|
262
|
+
`Turned on ${c.label}${c.compatibility.verdict === 'works' ? '' : ', with the parts that do not work here left off'} · ${at()}`),
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
row.append(button('Discard', 'shell.add-ons-discard-preview', {
|
|
266
|
+
tip: 'Stops offering this version. It stays in the history.',
|
|
267
|
+
onClick: () => act(() => call('POST', `/api/add-ons/${id}/discard-preview`, {}, a.rev), `Discarded the waiting version · ${at()}`),
|
|
268
|
+
}));
|
|
269
|
+
card.append(row);
|
|
270
|
+
detailEl.append(card);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// A draft is the AI's work in progress, not a version.
|
|
274
|
+
if (a.draft) {
|
|
275
|
+
const d = make('div', 'add-ons-draft');
|
|
276
|
+
d.append(make('span', '', a.draft.unreadable
|
|
277
|
+
? `FloLess cannot read the draft of ${a.draft.version}. Ask the AI to write it again.`
|
|
278
|
+
: `The AI is working on a draft for ${a.draft.version}. It is not a version yet, and nothing runs it.`));
|
|
279
|
+
detailEl.append(d);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// What it can do, and the definitions drawn at their example size.
|
|
283
|
+
if (shown) {
|
|
284
|
+
const s = section('What it can do');
|
|
285
|
+
const ul = make('ul', 'add-ons-cando');
|
|
286
|
+
const lines = shown.compatibility.definitions.map((d) => `Adds the section “${d.name}” for steel models${d.works ? '' : ' (off here)'}`);
|
|
287
|
+
lines.push('Runs no code and cannot reach the internet');
|
|
288
|
+
for (const line of lines) ul.append(make('li', '', line));
|
|
289
|
+
s.append(ul);
|
|
290
|
+
if (shown.compatibility.definitions.length) {
|
|
291
|
+
const grid = make('div', 'add-ons-defs');
|
|
292
|
+
for (const def of shown.compatibility.definitions) grid.append(thumb(def));
|
|
293
|
+
s.append(grid);
|
|
294
|
+
}
|
|
295
|
+
detailEl.append(s);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// History: every version, newest first; go back to any that is not on.
|
|
299
|
+
if (a.versions.length) {
|
|
300
|
+
const s = section('Versions');
|
|
301
|
+
const ol = make('ol', 'add-ons-versions');
|
|
302
|
+
const rows = a.versions;
|
|
303
|
+
rows.forEach((v, i) => {
|
|
304
|
+
const li = make('li', 'add-ons-version');
|
|
305
|
+
if (i >= 3) li.hidden = true;
|
|
306
|
+
li.append(make('span', 'add-ons-version-label', v.label));
|
|
307
|
+
li.append(make('span', 'add-ons-chip', v.channel === 'release' ? 'Release' : 'Preview'));
|
|
308
|
+
li.append(make('span', 'add-ons-muted', when(v.at)));
|
|
309
|
+
const notes = make('span', 'add-ons-version-notes', v.notes || '');
|
|
310
|
+
if (v.notes) notes.dataset.tip = v.notes;
|
|
311
|
+
li.append(notes);
|
|
312
|
+
if (v.isActive) li.append(make('span', 'add-ons-pill on', 'On'));
|
|
313
|
+
else if (v.isCandidate) li.append(make('span', 'add-ons-pill waiting', 'Waiting'));
|
|
314
|
+
if (!v.isActive && v.bundle === 'ok') {
|
|
315
|
+
// Definitions only: going back is turning that version on, on this click (design §6a).
|
|
316
|
+
li.append(twoStep('Go back to this version', `Yes, turn on ${v.label}`, 'shell.add-ons-go-back',
|
|
317
|
+
() => act(() => call('POST', `/api/add-ons/${id}/turn-on`, { version: v.label, digest: v.digest }, a.rev), `Went back to ${v.label}, which is now on · ${at()}`),
|
|
318
|
+
{ className: 'add-ons-link', tip: 'Turns this version on instead. It carries no code, so there is nothing new to allow.' }));
|
|
319
|
+
} else if (v.bundle !== 'ok') {
|
|
320
|
+
li.append(make('span', 'add-ons-def-off', 'Changed since it was made; FloLess will not use it'));
|
|
321
|
+
}
|
|
322
|
+
ol.append(li);
|
|
323
|
+
});
|
|
324
|
+
s.append(ol);
|
|
325
|
+
if (rows.length > 3) {
|
|
326
|
+
const more = button(`Show older (${rows.length - 3})`, 'shell.add-ons-show-older', { className: 'add-ons-link' });
|
|
327
|
+
more.addEventListener('click', () => { ol.querySelectorAll('li[hidden]').forEach((li) => { li.hidden = false; }); more.remove(); });
|
|
328
|
+
s.append(more);
|
|
329
|
+
}
|
|
330
|
+
detailEl.append(s);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Quiet actions.
|
|
334
|
+
const foot = make('div', 'add-ons-foot');
|
|
335
|
+
foot.append(button('Ask AI to change', 'shell.add-ons-ask-change', {
|
|
336
|
+
tip: 'Puts a message in the chat box. Nothing is sent, and a change arrives as a new version for you to turn on.',
|
|
337
|
+
onClick: () => askAi(`Please change my add-on “${a.name}” (${a.id})${shown ? `, starting from version ${shown.label}` : ''}: `),
|
|
338
|
+
}));
|
|
339
|
+
foot.append(twoStep('Remove', 'Yes, remove it', 'shell.add-ons-remove',
|
|
340
|
+
() => act(() => call('DELETE', `/api/add-ons/${id}`, undefined, a.rev), `Removed ${a.name}. What it made stays in your models.`),
|
|
341
|
+
{ className: 'add-ons-danger', tip: 'Turns it off and takes it out of this list. What it made stays in your models.' }));
|
|
342
|
+
detailEl.append(foot);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// ── import ──────────────────────────────────────────────────────────────────────────────────────
|
|
346
|
+
|
|
347
|
+
async function importPackage(pkg, choice, newId, expectVersion) {
|
|
348
|
+
let data;
|
|
349
|
+
try {
|
|
350
|
+
data = await call('POST', '/api/add-ons/import', { addOn: pkg, ...(choice ? { choice } : {}), ...(newId ? { newId } : {}), ...(expectVersion ? { expectVersion } : {}) });
|
|
351
|
+
} catch (error) { say(error.message, 'warn'); return; }
|
|
352
|
+
// A clash comes back as a question with its choices; nothing was imported until the person picks one.
|
|
353
|
+
if (data.outcome === 'question' && Array.isArray(data.choices)) {
|
|
354
|
+
statusEl.replaceChildren(make('span', '', data.question));
|
|
355
|
+
statusEl.dataset.kind = 'ask';
|
|
356
|
+
for (const c of data.choices) {
|
|
357
|
+
statusEl.append(button(c.label, 'shell.add-ons-import-choice', { onClick: () => importPackage(pkg, c.choice, c.newId, c.version) }));
|
|
358
|
+
}
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
say(data.outcome === 'added' ? `Imported ${data.version}. It arrived off; look at it, then turn it on.` : 'Nothing changed: that version is already here.');
|
|
362
|
+
await refresh(data.id);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
importBtn.addEventListener('click', () => fileInput.click());
|
|
366
|
+
fileInput.addEventListener('change', async () => {
|
|
367
|
+
const file = fileInput.files?.[0];
|
|
368
|
+
fileInput.value = '';
|
|
369
|
+
if (!file) return;
|
|
370
|
+
let parsed;
|
|
371
|
+
try { parsed = JSON.parse(await file.text()); } catch { say(`${file.name} is not an add-on file FloLess can read.`, 'warn'); return; }
|
|
372
|
+
await importPackage(parsed && parsed.addOn ? parsed.addOn : parsed);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// ── open / close ────────────────────────────────────────────────────────────────────────────────
|
|
376
|
+
|
|
377
|
+
function open(focusId) {
|
|
378
|
+
opener = document.activeElement;
|
|
379
|
+
modal.classList.add('show');
|
|
380
|
+
say('');
|
|
381
|
+
// What was painted when the screen last closed may be out of date: never offer its buttons while the fresh read runs.
|
|
382
|
+
current = null;
|
|
383
|
+
detailEl.replaceChildren(make('p', 'add-ons-muted', 'Loading your add-ons…'));
|
|
384
|
+
void refresh(typeof focusId === 'string' ? focusId : selected).then(() => modal.querySelector('.modal')?.focus());
|
|
385
|
+
}
|
|
386
|
+
function close() {
|
|
387
|
+
modal.classList.remove('show');
|
|
388
|
+
const target = opener && document.contains(opener) ? opener : document.getElementById('menu-btn');
|
|
389
|
+
target?.focus?.();
|
|
390
|
+
opener = null;
|
|
391
|
+
}
|
|
392
|
+
closeBtn.addEventListener('click', close);
|
|
393
|
+
modal.addEventListener('click', (event) => { if (event.target === modal) close(); });
|
|
394
|
+
modal.addEventListener('keydown', (event) => {
|
|
395
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); close(); }
|
|
396
|
+
});
|
|
397
|
+
// Another window, or the chat, changed an add-on: repaint what is on screen. The echo of a change this screen already
|
|
398
|
+
// shows (same add-on, same revision) is skipped, so it cannot reset a button the person has armed for a second click.
|
|
399
|
+
window.addEventListener('floless:add-ons-changed', (event) => {
|
|
400
|
+
if (!modal.classList.contains('show') || busy) return;
|
|
401
|
+
const { id, rev } = event.detail || {};
|
|
402
|
+
if (current && id === current.id && rev != null && rev === current.rev) return;
|
|
403
|
+
void refresh(selected);
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
window.flolessAddOns = { open, close };
|
|
407
|
+
})();
|
package/dist/web/analytics.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* handling for a desktop app — a dedicated later pass (spec §5.2). Until then,
|
|
8
8
|
* trackEvent() is defined and callable everywhere, and simply does nothing.
|
|
9
9
|
*
|
|
10
|
-
* Loaded as a classic <script> (like app.js/aware.js/
|
|
10
|
+
* Loaded as a classic <script> (like app.js/aware.js/workspaces.js) and
|
|
11
11
|
* exposed on window — NOT an ESM export — to match the codebase's module pattern.
|
|
12
12
|
* Callers: workspaces.js emits the Slice-6 Workspaces events through window.trackEvent.
|
|
13
13
|
*
|